dabke 0.82.0 → 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 (83) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +6 -3
  3. package/dist/cpsat/rules/index.d.ts +3 -0
  4. package/dist/cpsat/rules/index.d.ts.map +1 -1
  5. package/dist/cpsat/rules/index.js +3 -0
  6. package/dist/cpsat/rules/index.js.map +1 -1
  7. package/dist/cpsat/rules/max-days-week.d.ts +44 -0
  8. package/dist/cpsat/rules/max-days-week.d.ts.map +1 -0
  9. package/dist/cpsat/rules/max-days-week.js +95 -0
  10. package/dist/cpsat/rules/max-days-week.js.map +1 -0
  11. package/dist/cpsat/rules/min-days-week.d.ts +34 -0
  12. package/dist/cpsat/rules/min-days-week.d.ts.map +1 -0
  13. package/dist/cpsat/rules/min-days-week.js +84 -0
  14. package/dist/cpsat/rules/min-days-week.js.map +1 -0
  15. package/dist/cpsat/rules/must-assign.d.ts +49 -0
  16. package/dist/cpsat/rules/must-assign.d.ts.map +1 -0
  17. package/dist/cpsat/rules/must-assign.js +86 -0
  18. package/dist/cpsat/rules/must-assign.js.map +1 -0
  19. package/dist/cpsat/rules/registry.d.ts +4 -1
  20. package/dist/cpsat/rules/registry.d.ts.map +1 -1
  21. package/dist/cpsat/rules/registry.js +4 -1
  22. package/dist/cpsat/rules/registry.js.map +1 -1
  23. package/dist/cpsat/rules/rules.types.d.ts +3 -0
  24. package/dist/cpsat/rules/rules.types.d.ts.map +1 -1
  25. package/dist/cpsat/rules/scope.types.d.ts +1 -1
  26. package/dist/index.d.ts +5 -3
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +4 -2
  29. package/dist/index.js.map +1 -1
  30. package/dist/schedule/cost.d.ts +204 -0
  31. package/dist/schedule/cost.d.ts.map +1 -0
  32. package/dist/schedule/cost.js +187 -0
  33. package/dist/schedule/cost.js.map +1 -0
  34. package/dist/schedule/coverage.d.ts +85 -0
  35. package/dist/schedule/coverage.d.ts.map +1 -0
  36. package/dist/schedule/coverage.js +33 -0
  37. package/dist/schedule/coverage.js.map +1 -0
  38. package/dist/schedule/definition.d.ts +227 -0
  39. package/dist/schedule/definition.d.ts.map +1 -0
  40. package/dist/{schedule.js → schedule/definition.js} +9 -673
  41. package/dist/schedule/definition.js.map +1 -0
  42. package/dist/schedule/index.d.ts +67 -0
  43. package/dist/schedule/index.d.ts.map +1 -0
  44. package/dist/schedule/index.js +69 -0
  45. package/dist/schedule/index.js.map +1 -0
  46. package/dist/schedule/rules.d.ts +353 -0
  47. package/dist/schedule/rules.d.ts.map +1 -0
  48. package/dist/schedule/rules.js +352 -0
  49. package/dist/schedule/rules.js.map +1 -0
  50. package/dist/schedule/shift-patterns.d.ts +34 -0
  51. package/dist/schedule/shift-patterns.d.ts.map +1 -0
  52. package/dist/schedule/shift-patterns.js +41 -0
  53. package/dist/schedule/shift-patterns.js.map +1 -0
  54. package/dist/schedule/time-periods.d.ts +69 -0
  55. package/dist/schedule/time-periods.d.ts.map +1 -0
  56. package/dist/schedule/time-periods.js +91 -0
  57. package/dist/schedule/time-periods.js.map +1 -0
  58. package/package.json +4 -9
  59. package/src/cpsat/rules/index.ts +3 -0
  60. package/src/cpsat/rules/max-days-week.ts +143 -0
  61. package/src/cpsat/rules/min-days-week.ts +120 -0
  62. package/src/cpsat/rules/must-assign.ts +108 -0
  63. package/src/cpsat/rules/registry.ts +6 -0
  64. package/src/cpsat/rules/rules.types.ts +3 -0
  65. package/src/cpsat/rules/scope.types.ts +1 -1
  66. package/src/index.ts +8 -3
  67. package/src/schedule/cost.ts +242 -0
  68. package/src/schedule/coverage.ts +135 -0
  69. package/src/schedule/definition.ts +958 -0
  70. package/src/schedule/index.ts +112 -0
  71. package/src/schedule/rules.ts +529 -0
  72. package/src/schedule/shift-patterns.ts +46 -0
  73. package/src/schedule/time-periods.ts +110 -0
  74. package/dist/llms.d.ts +0 -2
  75. package/dist/llms.d.ts.map +0 -1
  76. package/dist/llms.js +0 -3
  77. package/dist/llms.js.map +0 -1
  78. package/dist/schedule.d.ts +0 -917
  79. package/dist/schedule.d.ts.map +0 -1
  80. package/dist/schedule.js.map +0 -1
  81. package/llms.txt +0 -758
  82. package/src/llms.ts +0 -3
  83. package/src/schedule.ts +0 -1960
@@ -1 +1 @@
1
- {"version":3,"file":"rules.types.d.ts","sourceRoot":"","sources":["../../../src/cpsat/rules/rules.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D,MAAM,MAAM,uBAAuB,CAAC,OAAO,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,OAAO,KAAK,eAAe,CAAC;AAG1F,MAAM,WAAW,iBAAiB;IAChC,iBAAiB,EAAE,OAAO,sBAAsB,EAAE,oBAAoB,CAAC;IACvE,qBAAqB,EAAE,OAAO,0BAA0B,EAAE,wBAAwB,CAAC;IACnF,qBAAqB,EAAE,OAAO,0BAA0B,EAAE,wBAAwB,CAAC;IACnF,sBAAsB,EAAE,OAAO,2BAA2B,EAAE,wBAAwB,CAAC;IACrF,eAAe,EAAE,OAAO,oBAAoB,EAAE,iBAAiB,CAAC;IAChE,gBAAgB,EAAE,OAAO,qBAAqB,EAAE,kBAAkB,CAAC;IACnE,gBAAgB,EAAE,OAAO,qBAAqB,EAAE,kBAAkB,CAAC;IACnE,sBAAsB,EAAE,OAAO,2BAA2B,EAAE,wBAAwB,CAAC;IACrF,eAAe,EAAE,OAAO,oBAAoB,EAAE,iBAAiB,CAAC;IAChE,gBAAgB,EAAE,OAAO,qBAAqB,EAAE,kBAAkB,CAAC;IACnE,yBAAyB,EAAE,OAAO,8BAA8B,EAAE,0BAA0B,CAAC;IAC7F,UAAU,EAAE,OAAO,eAAe,EAAE,aAAa,CAAC;IAClD,eAAe,EAAE,OAAO,oBAAoB,EAAE,kBAAkB,CAAC;IACjE,qBAAqB,EAAE,OAAO,0BAA0B,EAAE,uBAAuB,CA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B,EAAE,OAAO,iCAAiC,EAAE,8BAA8B,CAAC;IACvG,2BAA2B,EAAE,OAAO,gCAAgC,EAAE,6BAA6B,CAAC;IACpG,2BAA2B,EAAE,OAAO,gCAAgC,EAAE,6BAA6B,CAAC;IACpG,0BAA0B,EAAE,OAAO,+BAA+B,EAAE,4BAA4B,CAAC;IACjG,4BAA4B,EAAE,OAAO,iCAAiC,EAAE,8BAA8B,CAAC;CACxG;AAED,MAAM,MAAM,aAAa,GAAG,MAAM,iBAAiB,CAAC;AAEpD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,CAAC,QAAQ,EAAE,MAAM,GAAG,uBAAuB,CAAC,GAAG,CAAC,CAAC;CAClD,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;KACrC,CAAC,IAAI,aAAa,GAAG,uBAAuB,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;CACpE,CAAC;AAEF,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAChC,CAAC,SAAS,uBAAuB,CAAC,MAAM,MAAM,CAAC,GAAG,MAAM,GAAG,KAAK,CAAC;AAEnE,MAAM,MAAM,8BAA8B,CAAC,CAAC,SAAS,kBAAkB,IAAI;KACxE,CAAC,IAAI,MAAM,CAAC,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC3C,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,oBAAoB,GAAG;KAChC,CAAC,IAAI,aAAa,GAAG;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,GAAG,iBAAiB,CAAC,CAAC,CAAC;CACzD,CAAC,aAAa,CAAC,CAAC"}
@@ -79,7 +79,7 @@ type NonEmptyArray<T> = [T, ...T[]];
79
79
  /**
80
80
  * Recurring calendar period for time scoping.
81
81
  *
82
- * @category Rules
82
+ * @category Supporting Types
83
83
  */
84
84
  export interface RecurringPeriod {
85
85
  name: string;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  /**
2
- * @privateRemarks
2
+ * Scheduling library powered by constraint programming (CP-SAT).
3
+ *
4
+ * @remarks
3
5
  * ## Core Concepts
4
6
  *
5
7
  * **Schedule**: The primary API. Small, composable functions
@@ -48,6 +50,6 @@ export type { HourlyPay, SalariedPay, SchedulingMember, ShiftPattern, Priority,
48
50
  export { OBJECTIVE_WEIGHTS } from "./cpsat/utils.js";
49
51
  export type { ValidationGroup, ScheduleValidation, ScheduleError, CoverageError, RuleError, SolverError, ScheduleViolation, CoverageViolation, RuleViolation, SchedulePassed, CoveragePassed, RulePassed, ValidationSummary, } from "./cpsat/validation.types.js";
50
52
  export { summarizeValidation } from "./cpsat/validation-reporter.js";
51
- export { schedule, partialSchedule, Schedule, t, time, cover, shift, maxHoursPerDay, maxHoursPerWeek, minHoursPerDay, minHoursPerWeek, maxShiftsPerDay, maxConsecutiveDays, minConsecutiveDays, minRestBetweenShifts, preference, preferLocation, timeOff, assignTogether, defineRule, minimizeCost, dayMultiplier, daySurcharge, timeSurcharge, overtimeMultiplier, overtimeSurcharge, dailyOvertimeMultiplier, dailyOvertimeSurcharge, tieredOvertimeMultiplier, weekdays, weekend, } from "./schedule.js";
52
- export type { CoverageEntry, CoverageOptions, CoverageVariant, RuleEntry, RuleResolveContext, RuleOptions, EntityOnlyRuleOptions, TimeOffOptions, AssignTogetherOptions, CostRuleOptions, ScheduleConfig, SolveResult, SolveStatus, SolveOptions, } from "./schedule.js";
53
+ export { schedule, partialSchedule, Schedule, t, time, cover, shift, maxHoursPerDay, maxHoursPerWeek, minHoursPerDay, minHoursPerWeek, maxDaysPerWeek, minDaysPerWeek, maxShiftsPerDay, maxConsecutiveDays, minConsecutiveDays, minRestBetweenShifts, mustAssign, preference, preferLocation, timeOff, assignTogether, defineRule, minimizeCost, dayMultiplier, daySurcharge, timeSurcharge, overtimeMultiplier, overtimeSurcharge, dailyOvertimeMultiplier, dailyOvertimeSurcharge, tieredOvertimeMultiplier, weekdays, weekend, } from "./schedule/index.js";
54
+ export type { CoverageEntry, CoverageOptions, CoverageVariant, RuleEntry, RuleResolveContext, RuleOptions, EntityOnlyRuleOptions, TimeOffOptions, AssignTogetherOptions, CostRuleOptions, ScheduleConfig, SolveResult, SolveStatus, SolveOptions, } from "./schedule/index.js";
53
55
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAMH,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEzE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAM7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,YAAY,EACV,YAAY,EACZ,aAAa,EACb,cAAc,EACd,YAAY,EACZ,uBAAuB,EACvB,WAAW,GACZ,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAMpG,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,YAAY,EACV,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,qBAAqB,EACrB,SAAS,EACT,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAMlC,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9E,YAAY,EAAE,eAAe,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAMlG,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEvE,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAM9F,YAAY,EACV,oBAAoB,EACpB,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,8BAA8B,CAAC;AAEtC,YAAY,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEpE,YAAY,EAAE,YAAY,EAAE,MAAM,6CAA6C,CAAC;AAMhF,YAAY,EACV,SAAS,EACT,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,QAAQ,GACT,MAAM,kBAAkB,CAAC;AAM1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAMrD,YAAY,EACV,eAAe,EACf,kBAAkB,EAClB,aAAa,EACb,aAAa,EACb,SAAS,EACT,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,cAAc,EACd,UAAU,EACV,iBAAiB,GAClB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAMrE,OAAO,EACL,QAAQ,EACR,eAAe,EACf,QAAQ,EACR,CAAC,EACD,IAAI,EACJ,KAAK,EACL,KAAK,EACL,cAAc,EACd,eAAe,EACf,cAAc,EACd,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,UAAU,EACV,cAAc,EACd,OAAO,EACP,cAAc,EACd,UAAU,EACV,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,uBAAuB,EACvB,sBAAsB,EACtB,wBAAwB,EACxB,QAAQ,EACR,OAAO,GACR,MAAM,eAAe,CAAC;AAEvB,YAAY,EACV,aAAa,EACb,eAAe,EACf,eAAe,EACf,SAAS,EACT,kBAAkB,EAClB,WAAW,EACX,qBAAqB,EACrB,cAAc,EACd,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,WAAW,EACX,WAAW,EACX,YAAY,GACb,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;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iB,EAAE,MAAM,kBAAkB,CAAC;AAMrD,YAAY,EACV,eAAe,EACf,kBAAkB,EAClB,aAAa,EACb,aAAa,EACb,SAAS,EACT,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,cAAc,EACd,UAAU,EACV,iBAAiB,GAClB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAMrE,OAAO,EACL,QAAQ,EACR,eAAe,EACf,QAAQ,EACR,CAAC,EACD,IAAI,EACJ,KAAK,EACL,KAAK,EACL,cAAc,EACd,eAAe,EACf,cAAc,EACd,eAAe,EACf,cAAc,EACd,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,UAAU,EACV,UAAU,EACV,cAAc,EACd,OAAO,EACP,cAAc,EACd,UAAU,EACV,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,uBAAuB,EACvB,sBAAsB,EACtB,wBAAwB,EACxB,QAAQ,EACR,OAAO,GACR,MAAM,qBAAqB,CAAC;AAE7B,YAAY,EACV,aAAa,EACb,eAAe,EACf,eAAe,EACf,SAAS,EACT,kBAAkB,EAClB,WAAW,EACX,qBAAqB,EACrB,cAAc,EACd,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,WAAW,EACX,WAAW,EACX,YAAY,GACb,MAAM,qBAAqB,CAAC"}
package/dist/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  /**
2
- * @privateRemarks
2
+ * Scheduling library powered by constraint programming (CP-SAT).
3
+ *
4
+ * @remarks
3
5
  * ## Core Concepts
4
6
  *
5
7
  * **Schedule**: The primary API. Small, composable functions
@@ -56,5 +58,5 @@ export { summarizeValidation } from "./cpsat/validation-reporter.js";
56
58
  // ============================================================================
57
59
  // Schedule API
58
60
  // ============================================================================
59
- export { schedule, partialSchedule, Schedule, t, time, cover, shift, maxHoursPerDay, maxHoursPerWeek, minHoursPerDay, minHoursPerWeek, maxShiftsPerDay, maxConsecutiveDays, minConsecutiveDays, minRestBetweenShifts, preference, preferLocation, timeOff, assignTogether, defineRule, minimizeCost, dayMultiplier, daySurcharge, timeSurcharge, overtimeMultiplier, overtimeSurcharge, dailyOvertimeMultiplier, dailyOvertimeSurcharge, tieredOvertimeMultiplier, weekdays, weekend, } from "./schedule.js";
61
+ export { schedule, partialSchedule, Schedule, t, time, cover, shift, maxHoursPerDay, maxHoursPerWeek, minHoursPerDay, minHoursPerWeek, maxDaysPerWeek, minDaysPerWeek, maxShiftsPerDay, maxConsecutiveDays, minConsecutiveDays, minRestBetweenShifts, mustAssign, preference, preferLocation, timeOff, assignTogether, defineRule, minimizeCost, dayMultiplier, daySurcharge, timeSurcharge, overtimeMultiplier, overtimeSurcharge, dailyOvertimeMultiplier, dailyOvertimeSurcharge, tieredOvertimeMultiplier, weekdays, weekend, } from "./schedule/index.js";
60
62
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAQH,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,+EAA+E;AAC/E,gBAAgB;AAChB,+EAA+E;AAE/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAW/C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEpG,+EAA+E;AAC/E,gBAAgB;AAChB,+EAA+E;AAE/E,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAWxD,+EAA+E;AAC/E,0BAA0B;AAC1B,+EAA+E;AAE/E,OAAO,EAAE,mBAAmB,EAAE,kBAAk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C;AAWxD,+EAA+E;AAC/E,0BAA0B;AAC1B,+EAA+E;AAE/E,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAI9E,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AA8BvE,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAsBrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAErE,+EAA+E;AAC/E,eAAe;AACf,+EAA+E;AAE/E,OAAO,EACL,QAAQ,EACR,eAAe,EACf,QAAQ,EACR,CAAC,EACD,IAAI,EACJ,KAAK,EACL,KAAK,EACL,cAAc,EACd,eAAe,EACf,cAAc,EACd,eAAe,EACf,cAAc,EACd,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,UAAU,EACV,UAAU,EACV,cAAc,EACd,OAAO,EACP,cAAc,EACd,UAAU,EACV,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,uBAAuB,EACvB,sBAAsB,EACtB,wBAAwB,EACxB,QAAQ,EACR,OAAO,GACR,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,204 @@
1
+ /**
2
+ * Cost optimization rules: minimize labor cost with modifiers.
3
+ *
4
+ * @module
5
+ */
6
+ import type { DayOfWeek, TimeOfDay } from "../types.js";
7
+ import type { OvertimeTier } from "../cpsat/rules/overtime-tiered-multiplier.js";
8
+ import type { RecurringPeriod } from "../cpsat/rules/scope.types.js";
9
+ import type { RuleEntry } from "./rules.js";
10
+ /**
11
+ * Options for cost rules.
12
+ *
13
+ * Cost rules are objective terms, not constraints. The `priority` field from
14
+ * {@link RuleOptions} does not apply.
15
+ *
16
+ * @category Cost Optimization
17
+ */
18
+ export interface CostRuleOptions {
19
+ /** Who this rule applies to (role name, skill name, or member ID). */
20
+ appliesTo?: string | string[];
21
+ /** Restrict to specific days of the week. */
22
+ dayOfWeek?: readonly [DayOfWeek, ...DayOfWeek[]];
23
+ /** Restrict to a date range. */
24
+ dateRange?: {
25
+ start: string;
26
+ end: string;
27
+ };
28
+ /** Restrict to specific dates (YYYY-MM-DD). */
29
+ dates?: string[];
30
+ /** Restrict to recurring calendar periods. */
31
+ recurringPeriods?: [RecurringPeriod, ...RecurringPeriod[]];
32
+ }
33
+ /**
34
+ * Tells the solver to minimize total labor cost.
35
+ *
36
+ * @remarks
37
+ * Without this rule, cost modifiers only affect post-solve calculation.
38
+ * When present, the solver actively prefers cheaper assignments.
39
+ *
40
+ * For hourly members, penalizes each assignment proportionally to cost.
41
+ * For salaried members, adds a fixed weekly salary cost when they have
42
+ * any assignment that week (zero marginal cost up to contracted hours).
43
+ *
44
+ * Cost modifiers adjust the calculation:
45
+ * - `dayMultiplier(factor, opts?)` - multiply base rate on specific days
46
+ * - `daySurcharge(amount, opts?)` - flat extra per hour on specific days
47
+ * - `timeSurcharge(amount, window, opts?)` - flat extra per hour during a time window
48
+ * - `overtimeMultiplier({ after, factor }, opts?)` - weekly overtime multiplier
49
+ * - `overtimeSurcharge({ after, amount }, opts?)` - weekly overtime surcharge
50
+ * - `dailyOvertimeMultiplier({ after, factor }, opts?)` - daily overtime multiplier
51
+ * - `dailyOvertimeSurcharge({ after, amount }, opts?)` - daily overtime surcharge
52
+ * - `tieredOvertimeMultiplier(tiers, opts?)` - multiple overtime thresholds
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * minimizeCost()
57
+ * ```
58
+ *
59
+ * @category Cost Optimization
60
+ */
61
+ export declare function minimizeCost(opts?: CostRuleOptions): RuleEntry;
62
+ /**
63
+ * Multiplies the base rate for assignments on specified days.
64
+ *
65
+ * @remarks
66
+ * The base cost (1x) is already counted by {@link minimizeCost};
67
+ * this rule adds only the extra portion above 1x.
68
+ *
69
+ * @category Cost Optimization
70
+ *
71
+ * @example Weekend multiplier
72
+ * ```typescript
73
+ * dayMultiplier(1.5, { dayOfWeek: weekend })
74
+ * ```
75
+ */
76
+ export declare function dayMultiplier(factor: number, opts?: CostRuleOptions): RuleEntry;
77
+ /**
78
+ * Adds a flat extra amount per hour for assignments on specified days.
79
+ *
80
+ * @remarks
81
+ * The surcharge is independent of the member's base rate.
82
+ *
83
+ * @category Cost Optimization
84
+ *
85
+ * @example Weekend surcharge
86
+ * ```typescript
87
+ * daySurcharge(500, { dayOfWeek: weekend })
88
+ * ```
89
+ */
90
+ export declare function daySurcharge(amountPerHour: number, opts?: CostRuleOptions): RuleEntry;
91
+ /**
92
+ * Adds a flat surcharge per hour for the portion of a shift that overlaps a time-of-day window.
93
+ *
94
+ * @remarks
95
+ * The window supports overnight spans (e.g., 22:00-06:00). The surcharge
96
+ * is independent of the member's base rate.
97
+ *
98
+ * @param amountPerHour - Flat surcharge per hour in smallest currency unit
99
+ * @param window - Time-of-day window
100
+ * @param opts - Entity and time scoping
101
+ *
102
+ * @category Cost Optimization
103
+ *
104
+ * @example Night differential
105
+ * ```typescript
106
+ * timeSurcharge(200, { from: t(22), until: t(6) })
107
+ * ```
108
+ */
109
+ export declare function timeSurcharge(amountPerHour: number, window: {
110
+ from: TimeOfDay;
111
+ until: TimeOfDay;
112
+ }, opts?: CostRuleOptions): RuleEntry;
113
+ /**
114
+ * Applies a multiplier to hours beyond a weekly threshold.
115
+ *
116
+ * @remarks
117
+ * Only the extra portion above 1x is added (the base cost is already
118
+ * counted by {@link minimizeCost}).
119
+ *
120
+ * @category Cost Optimization
121
+ *
122
+ * @example
123
+ * ```typescript
124
+ * overtimeMultiplier({ after: 40, factor: 1.5 })
125
+ * ```
126
+ */
127
+ export declare function overtimeMultiplier(opts: {
128
+ after: number;
129
+ factor: number;
130
+ } & CostRuleOptions): RuleEntry;
131
+ /**
132
+ * Adds a flat surcharge per hour beyond a weekly threshold.
133
+ *
134
+ * @remarks
135
+ * The surcharge is independent of the member's base rate.
136
+ *
137
+ * @category Cost Optimization
138
+ *
139
+ * @example
140
+ * ```typescript
141
+ * overtimeSurcharge({ after: 40, amount: 1000 })
142
+ * ```
143
+ */
144
+ export declare function overtimeSurcharge(opts: {
145
+ after: number;
146
+ amount: number;
147
+ } & CostRuleOptions): RuleEntry;
148
+ /**
149
+ * Applies a multiplier to hours beyond a daily threshold.
150
+ *
151
+ * @remarks
152
+ * Only the extra portion above 1x is added (the base cost is already
153
+ * counted by {@link minimizeCost}).
154
+ *
155
+ * @category Cost Optimization
156
+ *
157
+ * @example
158
+ * ```typescript
159
+ * dailyOvertimeMultiplier({ after: 8, factor: 1.5 })
160
+ * ```
161
+ */
162
+ export declare function dailyOvertimeMultiplier(opts: {
163
+ after: number;
164
+ factor: number;
165
+ } & CostRuleOptions): RuleEntry;
166
+ /**
167
+ * Adds a flat surcharge per hour beyond a daily threshold.
168
+ *
169
+ * @remarks
170
+ * The surcharge is independent of the member's base rate.
171
+ *
172
+ * @category Cost Optimization
173
+ *
174
+ * @example
175
+ * ```typescript
176
+ * dailyOvertimeSurcharge({ after: 8, amount: 500 })
177
+ * ```
178
+ */
179
+ export declare function dailyOvertimeSurcharge(opts: {
180
+ after: number;
181
+ amount: number;
182
+ } & CostRuleOptions): RuleEntry;
183
+ /**
184
+ * Applies multiple overtime thresholds with increasing multipliers.
185
+ *
186
+ * @remarks
187
+ * Each tier applies only to the hours between its threshold and the next.
188
+ * Tiers must be sorted by threshold ascending.
189
+ *
190
+ * @category Cost Optimization
191
+ *
192
+ * @example
193
+ * ```typescript
194
+ * // Hours 0-40: base rate
195
+ * // Hours 40-48: 1.5x
196
+ * // Hours 48+: 2.0x
197
+ * tieredOvertimeMultiplier([
198
+ * { after: 40, factor: 1.5 },
199
+ * { after: 48, factor: 2.0 },
200
+ * ])
201
+ * ```
202
+ */
203
+ export declare function tieredOvertimeMultiplier(tiers: [OvertimeTier, ...OvertimeTier[]], opts?: CostRu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AiBG;AACH,wBAAgB,aAAa,CAC3B,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,EAC7C,IAAI,CAAC,EAAE,eAAe,GACrB,SAAS,CAEX;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,eAAe,GACxD,SAAS,CAEX;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,eAAe,GACxD,SAAS,CAEX;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,eAAe,GACxD,SAAS,CAEX;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,eAAe,GACxD,SAAS,CAEX;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,CAAC,YAAY,EAAE,GAAG,YAAY,EAAE,CAAC,EACxC,IAAI,CAAC,EAAE,eAAe,GACrB,SAAS,CAEX"}
@@ -0,0 +1,187 @@
1
+ /**
2
+ * Cost optimization rules: minimize labor cost with modifiers.
3
+ *
4
+ * @module
5
+ */
6
+ import { defineRule } from "./rules.js";
7
+ // ============================================================================
8
+ // Cost Rules
9
+ // ============================================================================
10
+ function makeCostRule(rule, fields) {
11
+ return defineRule(rule, fields);
12
+ }
13
+ /**
14
+ * Tells the solver to minimize total labor cost.
15
+ *
16
+ * @remarks
17
+ * Without this rule, cost modifiers only affect post-solve calculation.
18
+ * When present, the solver actively prefers cheaper assignments.
19
+ *
20
+ * For hourly members, penalizes each assignment proportionally to cost.
21
+ * For salaried members, adds a fixed weekly salary cost when they have
22
+ * any assignment that week (zero marginal cost up to contracted hours).
23
+ *
24
+ * Cost modifiers adjust the calculation:
25
+ * - `dayMultiplier(factor, opts?)` - multiply base rate on specific days
26
+ * - `daySurcharge(amount, opts?)` - flat extra per hour on specific days
27
+ * - `timeSurcharge(amount, window, opts?)` - flat extra per hour during a time window
28
+ * - `overtimeMultiplier({ after, factor }, opts?)` - weekly overtime multiplier
29
+ * - `overtimeSurcharge({ after, amount }, opts?)` - weekly overtime surcharge
30
+ * - `dailyOvertimeMultiplier({ after, factor }, opts?)` - daily overtime multiplier
31
+ * - `dailyOvertimeSurcharge({ after, amount }, opts?)` - daily overtime surcharge
32
+ * - `tieredOvertimeMultiplier(tiers, opts?)` - multiple overtime thresholds
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * minimizeCost()
37
+ * ```
38
+ *
39
+ * @category Cost Optimization
40
+ */
41
+ export function minimizeCost(opts) {
42
+ return makeCostRule("minimize-cost", { ...opts });
43
+ }
44
+ /**
45
+ * Multiplies the base rate for assignments on specified days.
46
+ *
47
+ * @remarks
48
+ * The base cost (1x) is already counted by {@link minimizeCost};
49
+ * this rule adds only the extra portion above 1x.
50
+ *
51
+ * @category Cost Optimization
52
+ *
53
+ * @example Weekend multiplier
54
+ * ```typescript
55
+ * dayMultiplier(1.5, { dayOfWeek: weekend })
56
+ * ```
57
+ */
58
+ export function dayMultiplier(factor, opts) {
59
+ return makeCostRule("day-cost-multiplier", { factor, ...opts });
60
+ }
61
+ /**
62
+ * Adds a flat extra amount per hour for assignments on specified days.
63
+ *
64
+ * @remarks
65
+ * The surcharge is independent of the member's base rate.
66
+ *
67
+ * @category Cost Optimization
68
+ *
69
+ * @example Weekend surcharge
70
+ * ```typescript
71
+ * daySurcharge(500, { dayOfWeek: weekend })
72
+ * ```
73
+ */
74
+ export function daySurcharge(amountPerHour, opts) {
75
+ return makeCostRule("day-cost-surcharge", { amountPerHour, ...opts });
76
+ }
77
+ /**
78
+ * Adds a flat surcharge per hour for the portion of a shift that overlaps a time-of-day window.
79
+ *
80
+ * @remarks
81
+ * The window supports overnight spans (e.g., 22:00-06:00). The surcharge
82
+ * is independent of the member's base rate.
83
+ *
84
+ * @param amountPerHour - Flat surcharge per hour in smallest currency unit
85
+ * @param window - Time-of-day window
86
+ * @param opts - Entity and time scoping
87
+ *
88
+ * @category Cost Optimization
89
+ *
90
+ * @example Night differential
91
+ * ```typescript
92
+ * timeSurcharge(200, { from: t(22), until: t(6) })
93
+ * ```
94
+ */
95
+ export function timeSurcharge(amountPerHour, window, opts) {
96
+ return makeCostRule("time-cost-surcharge", { amountPerHour, window, ...opts });
97
+ }
98
+ /**
99
+ * Applies a multiplier to hours beyond a weekly threshold.
100
+ *
101
+ * @remarks
102
+ * Only the extra portion above 1x is added (the base cost is already
103
+ * counted by {@link minimizeCost}).
104
+ *
105
+ * @category Cost Optimization
106
+ *
107
+ * @example
108
+ * ```typescript
109
+ * overtimeMultiplier({ after: 40, factor: 1.5 })
110
+ * ```
111
+ */
112
+ export function overtimeMultiplier(opts) {
113
+ return makeCostRule("overtime-weekly-multiplier", { ...opts });
114
+ }
115
+ /**
116
+ * Adds a flat surcharge per hour beyond a weekly threshold.
117
+ *
118
+ * @remarks
119
+ * The surcharge is independent of the member's base rate.
120
+ *
121
+ * @category Cost Optimization
122
+ *
123
+ * @example
124
+ * ```typescript
125
+ * overtimeSurcharge({ after: 40, amount: 1000 })
126
+ * ```
127
+ */
128
+ export function overtimeSurcharge(opts) {
129
+ return makeCostRule("overtime-weekly-surcharge", { ...opts });
130
+ }
131
+ /**
132
+ * Applies a multiplier to hours beyond a daily threshold.
133
+ *
134
+ * @remarks
135
+ * Only the extra portion above 1x is added (the base cost is already
136
+ * counted by {@link minimizeCost}).
137
+ *
138
+ * @category Cost Optimization
139
+ *
140
+ * @example
141
+ * ```typescript
142
+ * dailyOvertimeMultiplier({ after: 8, factor: 1.5 })
143
+ * ```
144
+ */
145
+ export function dailyOvertimeMultiplier(opts) {
146
+ return makeCostRule("overtime-daily-multiplier", { ...opts });
147
+ }
148
+ /**
149
+ * Adds a flat surcharge per hour beyond a daily threshold.
150
+ *
151
+ * @remarks
152
+ * The surcharge is independent of the member's base rate.
153
+ *
154
+ * @category Cost Optimization
155
+ *
156
+ * @example
157
+ * ```typescript
158
+ * dailyOvertimeSurcharge({ after: 8, amount: 500 })
159
+ * ```
160
+ */
161
+ export function dailyOvertimeSurcharge(opts) {
162
+ return makeCostRule("overtime-daily-surcharge", { ...opts });
163
+ }
164
+ /**
165
+ * Applies multiple overtime thresholds with increasing multipliers.
166
+ *
167
+ * @remarks
168
+ * Each tier applies only to the hours between its threshold and the next.
169
+ * Tiers must be sorted by threshold ascending.
170
+ *
171
+ * @category Cost Optimization
172
+ *
173
+ * @example
174
+ * ```typescript
175
+ * // Hours 0-40: base rate
176
+ * // Hours 40-48: 1.5x
177
+ * // Hours 48+: 2.0x
178
+ * tieredOvertimeMultiplier([
179
+ * { after: 40, factor: 1.5 },
180
+ * { after: 48, factor: 2.0 },
181
+ * ])
182
+ * ```
183
+ */
184
+ export function tieredOvertimeMultiplier(tiers, opts) {
185
+ return makeCostRule("overtime-tiered-multiplier", { tiers, ...opts });
186
+ }
187
+ //# sourceMappingURL=cost.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cost.js","sourceRoot":"","sources":["../../src/schedule/cost.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AA2BxC,+EAA+E;AAC/E,aAAa;AACb,+EAA+E;AAE/E,SAAS,YAAY,CAAC,IAAY,EAAE,MAA+B;IACjE,OAAO,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAClC,CAAC;AAED;;;;;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AAO,YAAY,CAAC,0BAA0B,EAAE,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;AAC/D,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,wBAAwB,CACtC,KAAwC,EACxC,IAAsB;IAEtB,OAAO,YAAY,CAAC,4BAA4B,EAAE,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;AACxE,CAAC"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Coverage definitions: staffing requirements per semantic time period.
3
+ *
4
+ * @module
5
+ */
6
+ import type { DayOfWeek } from "../types.js";
7
+ import type { CoverageVariant } from "../cpsat/semantic-time.js";
8
+ import type { Priority } from "../cpsat/types.js";
9
+ export type { CoverageVariant } from "../cpsat/semantic-time.js";
10
+ /**
11
+ * Options for a {@link cover} call.
12
+ *
13
+ * @remarks
14
+ * Day/date scoping controls which days this coverage entry applies to.
15
+ * An entry without `dayOfWeek` or `dates` applies every day in the
16
+ * scheduling period.
17
+ *
18
+ * @category Coverage
19
+ */
20
+ export interface CoverageOptions {
21
+ /** Additional skill ID filter (AND logic with the target role). */
22
+ skillIds?: [string, ...string[]];
23
+ /** Restrict to specific days of the week. */
24
+ dayOfWeek?: readonly [DayOfWeek, ...DayOfWeek[]];
25
+ /** Restrict to specific dates (YYYY-MM-DD). */
26
+ dates?: string[];
27
+ /** Defaults to `"MANDATORY"`. */
28
+ priority?: Priority;
29
+ }
30
+ /**
31
+ * A coverage entry returned by {@link cover}.
32
+ *
33
+ * @remarks
34
+ * Carries the semantic time name and target type information for
35
+ * compile-time validation by {@link schedule}. This is an opaque
36
+ * token; pass it directly into the `coverage` array.
37
+ */
38
+ export interface CoverageEntry<T extends string = string, R extends string = string> {
39
+ /** @internal */ readonly _type: "coverage";
40
+ /** @internal */ readonly timeName: T;
41
+ /** @internal */ readonly target: R | R[];
42
+ /** @internal */ readonly count: number;
43
+ /** @internal */ readonly options: CoverageOptions;
44
+ /** @internal When present, this entry uses variant-based resolution. */
45
+ readonly variants?: readonly CoverageVariant[];
46
+ }
47
+ /**
48
+ * Defines a staffing requirement for a semantic time period.
49
+ *
50
+ * @remarks
51
+ * Entries for the same time and role **stack additively**.
52
+ * For weekday vs weekend staffing, use mutually exclusive `dayOfWeek`
53
+ * on both entries.
54
+ *
55
+ * @param timeName - Name of a declared semantic time
56
+ * @param target - Role name (string), array of role names (OR logic), or skill name
57
+ * @param count - Number of people needed
58
+ * @param opts - Options: `skillIds` (AND filter), `dayOfWeek`, `dates`, `priority`
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * coverage: [
63
+ * // 2 waiters during lunch
64
+ * cover("lunch", "waiter", 2),
65
+ *
66
+ * // 1 manager OR supervisor during dinner
67
+ * cover("dinner", ["manager", "supervisor"], 1),
68
+ *
69
+ * // 1 person with keyholder skill at opening
70
+ * cover("opening", "keyholder", 1),
71
+ *
72
+ * // 1 senior waiter (role + skill AND)
73
+ * cover("lunch", "waiter", 1, { skillIds: ["senior"] }),
74
+ *
75
+ * // Different counts by day (mutually exclusive dayOfWeek!)
76
+ * cover("lunch", "waiter", 2, { dayOfWeek: weekdays }),
77
+ * cover("lunch", "waiter", 3, { dayOfWeek: weekend }),
78
+ * ]
79
+ * ```
80
+ *
81
+ * @category Coverage
82
+ */
83
+ export declare function cover<T extends string, const R extends string>(timeName: T, target: R | [R, ...R[]], count: number, opts?: CoverageOptions): CoverageEntry<T, R>;
84
+ export declare function cover<T extends string, const R extends string>(timeName: T, target: R | [R, ...R[]], ...variants: [CoverageVariant, ...CoverageVariant[]]): CoverageEntry<T, R>;
85
+ //# sourceMappingURL=coverage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coverage.d.ts","sourceRoot":"","sources":["../../src/schedule/coverage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC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AAE,eAAe,GACrB,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACvB,wBAAgB,KAAK,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,CAAC,CAAC,SAAS,MAAM,EAC5D,QAAQ,EAAE,CAAC,EACX,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,EACvB,GAAG,QAAQ,EAAE,CAAC,eAAe,EAAE,GAAG,eAAe,EAAE,CAAC,GACnD,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Coverage definitions: staffing requirements per semantic time period.
3
+ *
4
+ * @module
5
+ */
6
+ export function cover(timeName, target, countOrFirstVariant, ...rest) {
7
+ if (typeof countOrFirstVariant === "number") {
8
+ // Simple form: cover(time, target, count, opts?)
9
+ return {
10
+ _type: "coverage",
11
+ timeName,
12
+ target,
13
+ count: countOrFirstVariant,
14
+ options: rest[0] ?? {},
15
+ };
16
+ }
17
+ // Variant form: cover(time, target, ...variants)
18
+ const variants = [countOrFirstVariant, ...rest];
19
+ const defaults = variants.filter((v) => !v.dayOfWeek && !v.dates);
20
+ if (defaults.length > 1) {
21
+ throw new Error("cover() accepts at most one default variant (without dayOfWeek or dates). " +
22
+ `Found ${defaults.length} default variants.`);
23
+ }
24
+ return {
25
+ _type: "coverage",
26
+ timeName,
27
+ target,
28
+ count: 0,
29
+ options: {},
30
+ variants,
31
+ };
32
+ }
33
+ //# sourceMappingURL=coverage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coverage.js","sourceRoot":"","sources":["../../src/schedule/coverage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA8FH,MAAM,UAAU,KAAK,CACnB,QAAW,EACX,MAAuB,EACvB,mBAA6C,EAC7C,GAAG,IAAe;IAElB,IAAI,OAAO,mBAAmB,KAAK,QAAQ,EAAE,CAAC;QAC5C,iDAAiD;QACjD,OAAO;YACL,KAAK,EAAE,UAAU;YACjB,QAAQ;YACR,MAAM;YACN,KAAK,EAAE,mBAAmB;YAC1B,OAAO,EAAG,IAAI,CAAC,CAAC,CAAiC,IAAI,EAAE;SACxD,CAAC;IACJ,CAAC;IAED,iDAAiD;IACjD,MAAM,QAAQ,GAAG,CAAC,mBAAmB,EAAE,GAAI,IAA0B,CAAC,CAAC;IAEvE,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAClE,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CACb,4EAA4E;YAC1E,SAAS,QAAQ,CAAC,MAAM,oBAAoB,CAC/C,CAAC;IACJ,CAAC;IAED,OAAO;QACL,KAAK,EAAE,UAAU;QACjB,QAAQ;QACR,MAAM;QACN,KAAK,EAAE,CAAC;QACR,OAAO,EAAE,EAAE;QACX,QAAQ;KACT,CAAC;AACJ,CAAC"}