dabke 0.83.0 → 0.84.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.
- package/CHANGELOG.md +21 -0
- package/README.md +22 -27
- package/dist/client.d.ts +39 -3
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js.map +1 -1
- package/dist/client.schemas.d.ts +118 -18
- package/dist/client.schemas.d.ts.map +1 -1
- package/dist/client.schemas.js +110 -6
- package/dist/client.schemas.js.map +1 -1
- package/dist/client.types.d.ts +63 -7
- package/dist/client.types.d.ts.map +1 -1
- package/dist/client.types.js.map +1 -1
- package/dist/cpsat/cost.d.ts +5 -2
- package/dist/cpsat/cost.d.ts.map +1 -1
- package/dist/cpsat/cost.js +13 -6
- package/dist/cpsat/cost.js.map +1 -1
- package/dist/cpsat/model-builder.d.ts +42 -61
- package/dist/cpsat/model-builder.d.ts.map +1 -1
- package/dist/cpsat/model-builder.js +451 -56
- package/dist/cpsat/model-builder.js.map +1 -1
- package/dist/cpsat/response.d.ts +19 -7
- package/dist/cpsat/response.d.ts.map +1 -1
- package/dist/cpsat/response.js +48 -9
- package/dist/cpsat/response.js.map +1 -1
- package/dist/cpsat/rule-descriptor.d.ts +250 -0
- package/dist/cpsat/rule-descriptor.d.ts.map +1 -0
- package/dist/cpsat/rule-descriptor.js +51 -0
- package/dist/cpsat/rule-descriptor.js.map +1 -0
- package/dist/cpsat/rules/artifacts.d.ts +9 -0
- package/dist/cpsat/rules/artifacts.d.ts.map +1 -0
- package/dist/cpsat/rules/artifacts.js +31 -0
- package/dist/cpsat/rules/artifacts.js.map +1 -0
- package/dist/cpsat/rules/assign-together.d.ts +18 -20
- package/dist/cpsat/rules/assign-together.d.ts.map +1 -1
- package/dist/cpsat/rules/assign-together.js +90 -54
- package/dist/cpsat/rules/assign-together.js.map +1 -1
- package/dist/cpsat/rules/assigned-day.d.ts +12 -0
- package/dist/cpsat/rules/assigned-day.d.ts.map +1 -0
- package/dist/cpsat/rules/assigned-day.js +43 -0
- package/dist/cpsat/rules/assigned-day.js.map +1 -0
- package/dist/cpsat/rules/assignment-priority.d.ts +15 -29
- package/dist/cpsat/rules/assignment-priority.d.ts.map +1 -1
- package/dist/cpsat/rules/assignment-priority.js +47 -50
- package/dist/cpsat/rules/assignment-priority.js.map +1 -1
- package/dist/cpsat/rules/assignment-terms.d.ts +6 -0
- package/dist/cpsat/rules/assignment-terms.d.ts.map +1 -0
- package/dist/cpsat/rules/assignment-terms.js +19 -0
- package/dist/cpsat/rules/assignment-terms.js.map +1 -0
- package/dist/cpsat/rules/concurrent-intervals.d.ts +19 -0
- package/dist/cpsat/rules/concurrent-intervals.d.ts.map +1 -0
- package/dist/cpsat/rules/concurrent-intervals.js +57 -0
- package/dist/cpsat/rules/concurrent-intervals.js.map +1 -0
- package/dist/cpsat/rules/cost-utils.d.ts +1 -3
- package/dist/cpsat/rules/cost-utils.d.ts.map +1 -1
- package/dist/cpsat/rules/cost-utils.js +0 -7
- package/dist/cpsat/rules/cost-utils.js.map +1 -1
- package/dist/cpsat/rules/day-cost-multiplier.d.ts +10 -10
- package/dist/cpsat/rules/day-cost-multiplier.d.ts.map +1 -1
- package/dist/cpsat/rules/day-cost-multiplier.js +88 -77
- package/dist/cpsat/rules/day-cost-multiplier.js.map +1 -1
- package/dist/cpsat/rules/day-cost-surcharge.d.ts +10 -10
- package/dist/cpsat/rules/day-cost-surcharge.d.ts.map +1 -1
- package/dist/cpsat/rules/day-cost-surcharge.js +76 -65
- package/dist/cpsat/rules/day-cost-surcharge.js.map +1 -1
- package/dist/cpsat/rules/index.d.ts +30 -24
- package/dist/cpsat/rules/index.d.ts.map +1 -1
- package/dist/cpsat/rules/index.js +30 -24
- package/dist/cpsat/rules/index.js.map +1 -1
- package/dist/cpsat/rules/location-preference.d.ts +14 -21
- package/dist/cpsat/rules/location-preference.d.ts.map +1 -1
- package/dist/cpsat/rules/location-preference.js +45 -45
- package/dist/cpsat/rules/location-preference.js.map +1 -1
- package/dist/cpsat/rules/max-concurrent-assignments.d.ts +46 -0
- package/dist/cpsat/rules/max-concurrent-assignments.d.ts.map +1 -0
- package/dist/cpsat/rules/max-concurrent-assignments.js +121 -0
- package/dist/cpsat/rules/max-concurrent-assignments.js.map +1 -0
- package/dist/cpsat/rules/max-consecutive-days.d.ts +18 -17
- package/dist/cpsat/rules/max-consecutive-days.d.ts.map +1 -1
- package/dist/cpsat/rules/max-consecutive-days.js +67 -66
- package/dist/cpsat/rules/max-consecutive-days.js.map +1 -1
- package/dist/cpsat/rules/max-days-of-week-per-period.d.ts +45 -0
- package/dist/cpsat/rules/max-days-of-week-per-period.d.ts.map +1 -0
- package/dist/cpsat/rules/max-days-of-week-per-period.js +95 -0
- package/dist/cpsat/rules/max-days-of-week-per-period.js.map +1 -0
- package/dist/cpsat/rules/max-days-week.d.ts +17 -31
- package/dist/cpsat/rules/max-days-week.d.ts.map +1 -1
- package/dist/cpsat/rules/max-days-week.js +69 -81
- package/dist/cpsat/rules/max-days-week.js.map +1 -1
- package/dist/cpsat/rules/max-hours-day.d.ts +14 -31
- package/dist/cpsat/rules/max-hours-day.d.ts.map +1 -1
- package/dist/cpsat/rules/max-hours-day.js +56 -72
- package/dist/cpsat/rules/max-hours-day.js.map +1 -1
- package/dist/cpsat/rules/max-hours-week.d.ts +15 -31
- package/dist/cpsat/rules/max-hours-week.d.ts.map +1 -1
- package/dist/cpsat/rules/max-hours-week.js +60 -75
- package/dist/cpsat/rules/max-hours-week.js.map +1 -1
- package/dist/cpsat/rules/max-shifts-day.d.ts +17 -33
- package/dist/cpsat/rules/max-shifts-day.d.ts.map +1 -1
- package/dist/cpsat/rules/max-shifts-day.js +57 -73
- package/dist/cpsat/rules/max-shifts-day.js.map +1 -1
- package/dist/cpsat/rules/min-consecutive-days.d.ts +18 -18
- package/dist/cpsat/rules/min-consecutive-days.d.ts.map +1 -1
- package/dist/cpsat/rules/min-consecutive-days.js +123 -94
- package/dist/cpsat/rules/min-consecutive-days.js.map +1 -1
- package/dist/cpsat/rules/min-days-of-week-per-period.d.ts +35 -0
- package/dist/cpsat/rules/min-days-of-week-per-period.d.ts.map +1 -0
- package/dist/cpsat/rules/min-days-of-week-per-period.js +108 -0
- package/dist/cpsat/rules/min-days-of-week-per-period.js.map +1 -0
- package/dist/cpsat/rules/min-days-week.d.ts +13 -26
- package/dist/cpsat/rules/min-days-week.d.ts.map +1 -1
- package/dist/cpsat/rules/min-days-week.js +85 -74
- package/dist/cpsat/rules/min-days-week.js.map +1 -1
- package/dist/cpsat/rules/min-hours-day.d.ts +14 -17
- package/dist/cpsat/rules/min-hours-day.d.ts.map +1 -1
- package/dist/cpsat/rules/min-hours-day.js +72 -54
- package/dist/cpsat/rules/min-hours-day.js.map +1 -1
- package/dist/cpsat/rules/min-hours-week.d.ts +15 -18
- package/dist/cpsat/rules/min-hours-week.d.ts.map +1 -1
- package/dist/cpsat/rules/min-hours-week.js +75 -57
- package/dist/cpsat/rules/min-hours-week.js.map +1 -1
- package/dist/cpsat/rules/min-rest-between-shifts.d.ts +14 -17
- package/dist/cpsat/rules/min-rest-between-shifts.d.ts.map +1 -1
- package/dist/cpsat/rules/min-rest-between-shifts.js +148 -138
- package/dist/cpsat/rules/min-rest-between-shifts.js.map +1 -1
- package/dist/cpsat/rules/minimize-cost.d.ts +2 -18
- package/dist/cpsat/rules/minimize-cost.d.ts.map +1 -1
- package/dist/cpsat/rules/minimize-cost.js +151 -163
- package/dist/cpsat/rules/minimize-cost.js.map +1 -1
- package/dist/cpsat/rules/must-assign.d.ts +5 -42
- package/dist/cpsat/rules/must-assign.d.ts.map +1 -1
- package/dist/cpsat/rules/must-assign.js +43 -75
- package/dist/cpsat/rules/must-assign.js.map +1 -1
- package/dist/cpsat/rules/overtime-daily-multiplier.d.ts +6 -10
- package/dist/cpsat/rules/overtime-daily-multiplier.d.ts.map +1 -1
- package/dist/cpsat/rules/overtime-daily-multiplier.js +118 -112
- package/dist/cpsat/rules/overtime-daily-multiplier.js.map +1 -1
- package/dist/cpsat/rules/overtime-daily-surcharge.d.ts +6 -11
- package/dist/cpsat/rules/overtime-daily-surcharge.d.ts.map +1 -1
- package/dist/cpsat/rules/overtime-daily-surcharge.js +104 -99
- package/dist/cpsat/rules/overtime-daily-surcharge.js.map +1 -1
- package/dist/cpsat/rules/overtime-tiered-multiplier.d.ts +9 -21
- package/dist/cpsat/rules/overtime-tiered-multiplier.d.ts.map +1 -1
- package/dist/cpsat/rules/overtime-tiered-multiplier.js +181 -199
- package/dist/cpsat/rules/overtime-tiered-multiplier.js.map +1 -1
- package/dist/cpsat/rules/overtime-weekly-multiplier.d.ts +13 -12
- package/dist/cpsat/rules/overtime-weekly-multiplier.d.ts.map +1 -1
- package/dist/cpsat/rules/overtime-weekly-multiplier.js +143 -143
- package/dist/cpsat/rules/overtime-weekly-multiplier.js.map +1 -1
- package/dist/cpsat/rules/overtime-weekly-surcharge.d.ts +7 -11
- package/dist/cpsat/rules/overtime-weekly-surcharge.d.ts.map +1 -1
- package/dist/cpsat/rules/overtime-weekly-surcharge.js +124 -119
- package/dist/cpsat/rules/overtime-weekly-surcharge.js.map +1 -1
- package/dist/cpsat/rules/pattern-eligibility.d.ts +6 -0
- package/dist/cpsat/rules/pattern-eligibility.d.ts.map +1 -0
- package/dist/cpsat/rules/pattern-eligibility.js +16 -0
- package/dist/cpsat/rules/pattern-eligibility.js.map +1 -0
- package/dist/cpsat/rules/pattern-time.d.ts +5 -0
- package/dist/cpsat/rules/pattern-time.d.ts.map +1 -0
- package/dist/cpsat/rules/pattern-time.js +20 -0
- package/dist/cpsat/rules/pattern-time.js.map +1 -0
- package/dist/cpsat/rules/registry.d.ts +217 -30
- package/dist/cpsat/rules/registry.d.ts.map +1 -1
- package/dist/cpsat/rules/registry.js +98 -34
- package/dist/cpsat/rules/registry.js.map +1 -1
- package/dist/cpsat/rules/resolver.d.ts +9 -7
- package/dist/cpsat/rules/resolver.d.ts.map +1 -1
- package/dist/cpsat/rules/resolver.js +19 -18
- package/dist/cpsat/rules/resolver.js.map +1 -1
- package/dist/cpsat/rules/role-preference.d.ts +24 -0
- package/dist/cpsat/rules/role-preference.d.ts.map +1 -0
- package/dist/cpsat/rules/role-preference.js +72 -0
- package/dist/cpsat/rules/role-preference.js.map +1 -0
- package/dist/cpsat/rules/rules.types.d.ts +90 -17
- package/dist/cpsat/rules/rules.types.d.ts.map +1 -1
- package/dist/cpsat/rules/scope.types.d.ts +24 -11
- package/dist/cpsat/rules/scope.types.d.ts.map +1 -1
- package/dist/cpsat/rules/scope.types.js +14 -19
- package/dist/cpsat/rules/scope.types.js.map +1 -1
- package/dist/cpsat/rules/target-days-week.d.ts +31 -0
- package/dist/cpsat/rules/target-days-week.d.ts.map +1 -0
- package/dist/cpsat/rules/target-days-week.js +80 -0
- package/dist/cpsat/rules/target-days-week.js.map +1 -0
- package/dist/cpsat/rules/target-peak-concurrent-assignments.d.ts +33 -0
- package/dist/cpsat/rules/target-peak-concurrent-assignments.d.ts.map +1 -0
- package/dist/cpsat/rules/target-peak-concurrent-assignments.js +146 -0
- package/dist/cpsat/rules/target-peak-concurrent-assignments.js.map +1 -0
- package/dist/cpsat/rules/time-cost-surcharge.d.ts +15 -14
- package/dist/cpsat/rules/time-cost-surcharge.d.ts.map +1 -1
- package/dist/cpsat/rules/time-cost-surcharge.js +82 -96
- package/dist/cpsat/rules/time-cost-surcharge.js.map +1 -1
- package/dist/cpsat/rules/time-off.d.ts +21 -57
- package/dist/cpsat/rules/time-off.d.ts.map +1 -1
- package/dist/cpsat/rules/time-off.js +114 -127
- package/dist/cpsat/rules/time-off.js.map +1 -1
- package/dist/cpsat/rules/variables.d.ts +4 -0
- package/dist/cpsat/rules/variables.d.ts.map +1 -0
- package/dist/cpsat/rules/variables.js +10 -0
- package/dist/cpsat/rules/variables.js.map +1 -0
- package/dist/cpsat/rules.d.ts +20 -3
- package/dist/cpsat/rules.d.ts.map +1 -1
- package/dist/cpsat/rules.js +19 -2
- package/dist/cpsat/rules.js.map +1 -1
- package/dist/cpsat/semantic-time.d.ts +7 -6
- package/dist/cpsat/semantic-time.d.ts.map +1 -1
- package/dist/cpsat/semantic-time.js +15 -28
- package/dist/cpsat/semantic-time.js.map +1 -1
- package/dist/cpsat/types.d.ts +47 -4
- package/dist/cpsat/types.d.ts.map +1 -1
- package/dist/cpsat/types.js +24 -1
- package/dist/cpsat/types.js.map +1 -1
- package/dist/cpsat/utils.d.ts +23 -6
- package/dist/cpsat/utils.d.ts.map +1 -1
- package/dist/cpsat/utils.js +76 -15
- package/dist/cpsat/utils.js.map +1 -1
- package/dist/cpsat/validation-reporter.d.ts +6 -2
- package/dist/cpsat/validation-reporter.d.ts.map +1 -1
- package/dist/cpsat/validation-reporter.js +122 -10
- package/dist/cpsat/validation-reporter.js.map +1 -1
- package/dist/cpsat/validation.types.d.ts +21 -10
- package/dist/cpsat/validation.types.d.ts.map +1 -1
- package/dist/datetime.utils.d.ts +7 -13
- package/dist/datetime.utils.d.ts.map +1 -1
- package/dist/datetime.utils.js +29 -36
- package/dist/datetime.utils.js.map +1 -1
- package/dist/index.d.ts +12 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -3
- package/dist/index.js.map +1 -1
- package/dist/schedule/cost.d.ts +48 -60
- package/dist/schedule/cost.d.ts.map +1 -1
- package/dist/schedule/cost.js +15 -51
- package/dist/schedule/cost.js.map +1 -1
- package/dist/schedule/coverage.d.ts +57 -28
- package/dist/schedule/coverage.d.ts.map +1 -1
- package/dist/schedule/coverage.js +24 -1
- package/dist/schedule/coverage.js.map +1 -1
- package/dist/schedule/definition.d.ts +138 -19
- package/dist/schedule/definition.d.ts.map +1 -1
- package/dist/schedule/definition.js +99 -90
- package/dist/schedule/definition.js.map +1 -1
- package/dist/schedule/index.d.ts +4 -4
- package/dist/schedule/index.d.ts.map +1 -1
- package/dist/schedule/index.js +2 -2
- package/dist/schedule/index.js.map +1 -1
- package/dist/schedule/rules.d.ts +438 -113
- package/dist/schedule/rules.d.ts.map +1 -1
- package/dist/schedule/rules.js +310 -108
- package/dist/schedule/rules.js.map +1 -1
- package/dist/schedule/shift-patterns.d.ts +0 -17
- package/dist/schedule/shift-patterns.d.ts.map +1 -1
- package/dist/schedule/shift-patterns.js +0 -17
- package/dist/schedule/shift-patterns.js.map +1 -1
- package/dist/schedule/time-periods.d.ts +37 -27
- package/dist/schedule/time-periods.d.ts.map +1 -1
- package/dist/schedule/time-periods.js +37 -27
- package/dist/schedule/time-periods.js.map +1 -1
- package/dist/types.d.ts +67 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +64 -0
- package/dist/types.js.map +1 -1
- package/package.json +8 -9
- package/solver/src/solver/models.py +41 -4
- package/solver/src/solver/solver.py +546 -157
- package/solver/tests/test_solver.py +363 -7
- package/src/client.schemas.ts +127 -10
- package/src/client.ts +3 -0
- package/src/client.types.ts +73 -7
- package/src/cpsat/cost.ts +17 -7
- package/src/cpsat/model-builder.ts +614 -129
- package/src/cpsat/response.ts +57 -13
- package/src/cpsat/rule-descriptor.ts +311 -0
- package/src/cpsat/rules/artifacts.ts +56 -0
- package/src/cpsat/rules/assign-together.ts +104 -69
- package/src/cpsat/rules/assigned-day.ts +70 -0
- package/src/cpsat/rules/assignment-priority.ts +54 -58
- package/src/cpsat/rules/assignment-terms.ts +43 -0
- package/src/cpsat/rules/concurrent-intervals.ts +93 -0
- package/src/cpsat/rules/cost-utils.ts +1 -9
- package/src/cpsat/rules/day-cost-multiplier.ts +101 -81
- package/src/cpsat/rules/day-cost-surcharge.ts +91 -70
- package/src/cpsat/rules/index.ts +30 -24
- package/src/cpsat/rules/location-preference.ts +47 -52
- package/src/cpsat/rules/max-concurrent-assignments.ts +170 -0
- package/src/cpsat/rules/max-consecutive-days.ts +74 -91
- package/src/cpsat/rules/max-days-of-week-per-period.ts +127 -0
- package/src/cpsat/rules/max-days-week.ts +89 -115
- package/src/cpsat/rules/max-hours-day.ts +64 -84
- package/src/cpsat/rules/max-hours-week.ts +74 -90
- package/src/cpsat/rules/max-shifts-day.ts +65 -85
- package/src/cpsat/rules/min-consecutive-days.ts +161 -127
- package/src/cpsat/rules/min-days-of-week-per-period.ts +144 -0
- package/src/cpsat/rules/min-days-week.ts +93 -91
- package/src/cpsat/rules/min-hours-day.ts +79 -58
- package/src/cpsat/rules/min-hours-week.ts +87 -62
- package/src/cpsat/rules/min-rest-between-shifts.ts +191 -178
- package/src/cpsat/rules/minimize-cost.ts +175 -188
- package/src/cpsat/rules/must-assign.ts +44 -81
- package/src/cpsat/rules/overtime-daily-multiplier.ts +158 -140
- package/src/cpsat/rules/overtime-daily-surcharge.ts +141 -126
- package/src/cpsat/rules/overtime-tiered-multiplier.ts +234 -253
- package/src/cpsat/rules/overtime-weekly-multiplier.ts +183 -175
- package/src/cpsat/rules/overtime-weekly-surcharge.ts +161 -150
- package/src/cpsat/rules/pattern-eligibility.ts +26 -0
- package/src/cpsat/rules/pattern-time.ts +30 -0
- package/src/cpsat/rules/registry.ts +140 -62
- package/src/cpsat/rules/resolver.ts +58 -30
- package/src/cpsat/rules/role-preference.ts +92 -0
- package/src/cpsat/rules/rules.types.ts +89 -17
- package/src/cpsat/rules/scope.types.ts +31 -26
- package/src/cpsat/rules/target-days-week.ts +105 -0
- package/src/cpsat/rules/target-peak-concurrent-assignments.ts +212 -0
- package/src/cpsat/rules/time-cost-surcharge.ts +116 -122
- package/src/cpsat/rules/time-off.ts +154 -163
- package/src/cpsat/rules/variables.ts +11 -0
- package/src/cpsat/rules.ts +43 -17
- package/src/cpsat/semantic-time.ts +29 -43
- package/src/cpsat/types.ts +53 -4
- package/src/cpsat/utils.ts +92 -20
- package/src/cpsat/validation-reporter.ts +170 -19
- package/src/cpsat/validation.types.ts +22 -11
- package/src/datetime.utils.ts +45 -44
- package/src/index.ts +64 -12
- package/src/schedule/cost.ts +40 -61
- package/src/schedule/coverage.ts +57 -28
- package/src/schedule/definition.ts +565 -76
- package/src/schedule/index.ts +23 -3
- package/src/schedule/rules.ts +631 -132
- package/src/schedule/shift-patterns.ts +0 -17
- package/src/schedule/time-periods.ts +37 -27
- package/src/types.ts +114 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../src/schedule/rules.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../src/schedule/rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EACV,wBAAwB,EACxB,uBAAuB,EAEvB,iBAAiB,EAClB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAMrE;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,WAAW;IAC1B,sEAAsE;IACtE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC9B,6CAA6C;IAC7C,SAAS,CAAC,EAAE,SAAS,CAAC,SAAS,EAAE,GAAG,SAAS,EAAE,CAAC,CAAC;IACjD,gCAAgC;IAChC,SAAS,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3C,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,8CAA8C;IAC9C,gBAAgB,CAAC,EAAE,CAAC,eAAe,EAAE,GAAG,eAAe,EAAE,CAAC,CAAC;IAC3D,iCAAiC;IACjC,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,qBAAqB;IACpC,sEAAsE;IACtE,SAAS,CAAC,EAAE,MAAM,GAAG,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,EAAE,CAAC,EAC/C,IAAI,EAAE,0BAA0B,GAC/B,+BAA+B,CAwBjC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,SAAS,CAAC,SAAS,EAAE,GAAG,SAAS,EAAE,CAAC,EAC/C,IAAI,EAAE,0BAA0B,GAC/B,+BAA+B,CAwBjC;AAMD;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,EACxC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,EAC1B,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,EAC3B,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,GAC7B;IACD,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;IAClC,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;IAChC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;CAClC,CA6CA"}
|
package/dist/schedule/rules.js
CHANGED
|
@@ -1,29 +1,90 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Scheduling rules: constraints, preferences, and time-off.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*
|
|
4
|
+
* Rules answer "what schedules are allowed or preferred?". Use
|
|
5
|
+
* {@link cover} for lower-bound demand, then use rules for caps, limits, rest
|
|
6
|
+
* periods, time off, fairness, and other constraints on assignments.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* rules: [
|
|
11
|
+
* // Hour and day limits
|
|
12
|
+
* maxHoursPerDay(10),
|
|
13
|
+
* maxHoursPerWeek(48),
|
|
14
|
+
* maxHoursPerWeek(20, { appliesTo: "part-time" }),
|
|
15
|
+
* maxDaysPerWeek(5, { priority: "HIGH" }),
|
|
16
|
+
* targetDaysPerWeek(4, { appliesTo: "full-time", priority: "HIGH" }),
|
|
17
|
+
* minDaysPerWeek(4, { appliesTo: "full-time", priority: "HIGH" }),
|
|
18
|
+
* maxShiftsPerDay(1),
|
|
19
|
+
* maxConcurrentAssignments(5, { appliesTo: "chair_stylist" }),
|
|
20
|
+
* targetPeakConcurrentAssignments(5, { appliesTo: "chair_stylist", dayOfWeek: ["thursday"], priority: "HIGH" }),
|
|
21
|
+
* minRestBetweenShifts(11),
|
|
22
|
+
*
|
|
23
|
+
* // Staffing obligations and preferences
|
|
24
|
+
* mustAssign({ appliesTo: ["diana", "yavuz"] }),
|
|
25
|
+
* timeOff({ appliesTo: "alice", dateRange: { start: "2024-02-01", end: "2024-02-05" } }),
|
|
26
|
+
* timeOff({ appliesTo: "student", dayOfWeek: ["wednesday"], from: t(14) }),
|
|
27
|
+
* preferAssignment({ appliesTo: "waiter" }),
|
|
28
|
+
* avoidAssignment({ appliesTo: "student", dayOfWeek: weekdays }),
|
|
29
|
+
* assignTogether(["alice", "bob"]),
|
|
30
|
+
* ]
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* Custom rules can stay type-safe too:
|
|
8
34
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
35
|
+
* ```typescript
|
|
36
|
+
* const debugRuleRegistry = createCpsatRuleRegistry({
|
|
37
|
+
* debug: defineRuleDescriptor({
|
|
38
|
+
* name: "debug",
|
|
39
|
+
* schema: z.object({ flag: z.boolean() }),
|
|
40
|
+
* compile() {
|
|
41
|
+
* return { rule: "debug", artifacts: [] };
|
|
42
|
+
* },
|
|
43
|
+
* }),
|
|
44
|
+
* });
|
|
45
|
+
*
|
|
46
|
+
* const defineDebugRule = defineRuleFor(debugRuleRegistry);
|
|
47
|
+
*
|
|
48
|
+
* schedule({
|
|
49
|
+
* roleIds: ["waiter"],
|
|
50
|
+
* times: { lunch: time({ startTime: t(12), endTime: t(15) }) },
|
|
51
|
+
* coverage: [cover("lunch", "waiter", 1)],
|
|
52
|
+
* shiftPatterns: [shift("lunch", t(12), t(15))],
|
|
53
|
+
* ruleRegistry: debugRuleRegistry,
|
|
54
|
+
* rules: [defineDebugRule("debug", { flag: true })],
|
|
55
|
+
* });
|
|
56
|
+
* ```
|
|
12
57
|
*
|
|
13
|
-
* @
|
|
14
|
-
* @param fields - Rule-specific configuration fields.
|
|
15
|
-
* @param resolve - Optional custom resolver. When omitted, the default
|
|
16
|
-
* resolution applies: `appliesTo` is mapped to `roleIds`/`skillIds`/`memberIds`,
|
|
17
|
-
* `dates` is renamed to `specificDates`, and all other fields pass through.
|
|
58
|
+
* @module
|
|
18
59
|
*/
|
|
19
60
|
export function defineRule(name, fields, resolve) {
|
|
20
|
-
const
|
|
21
|
-
|
|
61
|
+
const safeFields = { ...fields };
|
|
62
|
+
delete safeFields._type;
|
|
63
|
+
delete safeFields._rule;
|
|
64
|
+
const entry = {
|
|
65
|
+
_type: "rule",
|
|
66
|
+
_rule: name,
|
|
67
|
+
...safeFields,
|
|
68
|
+
};
|
|
22
69
|
if (resolve) {
|
|
23
70
|
Object.defineProperty(entry, "_resolve", { value: resolve, enumerable: false });
|
|
24
71
|
}
|
|
25
72
|
return entry;
|
|
26
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Creates a registry-bound `defineRule` helper.
|
|
76
|
+
*
|
|
77
|
+
* @remarks
|
|
78
|
+
* Use this when authoring custom rules directly and you want immediate
|
|
79
|
+
* compile-time validation of the rule name and config fields against a specific
|
|
80
|
+
* rule registry.
|
|
81
|
+
*
|
|
82
|
+
* @category Rules
|
|
83
|
+
*/
|
|
84
|
+
export function defineRuleFor(ruleRegistry) {
|
|
85
|
+
void ruleRegistry;
|
|
86
|
+
return (name, fields, resolve) => defineRule(name, fields, resolve);
|
|
87
|
+
}
|
|
27
88
|
function makeRule(rule, fields) {
|
|
28
89
|
return defineRule(rule, fields);
|
|
29
90
|
}
|
|
@@ -33,11 +94,9 @@ function makeRule(rule, fields) {
|
|
|
33
94
|
/**
|
|
34
95
|
* Limits hours per day.
|
|
35
96
|
*
|
|
36
|
-
* @
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* maxHoursPerDay(4, { appliesTo: "student", dayOfWeek: weekdays })
|
|
40
|
-
* ```
|
|
97
|
+
* @remarks
|
|
98
|
+
* Use this when the requirements or operating constraints explicitly impose a
|
|
99
|
+
* daily hours cap. Do not infer it just from the chosen shift pattern lengths.
|
|
41
100
|
*
|
|
42
101
|
* @category Rules
|
|
43
102
|
*/
|
|
@@ -47,11 +106,10 @@ export function maxHoursPerDay(hours, opts) {
|
|
|
47
106
|
/**
|
|
48
107
|
* Limits hours per scheduling week.
|
|
49
108
|
*
|
|
50
|
-
* @
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* ```
|
|
109
|
+
* @remarks
|
|
110
|
+
* Use this when the requirements or operating constraints explicitly impose a
|
|
111
|
+
* weekly hours cap. Do not infer it just from a stated working pattern such
|
|
112
|
+
* as "4-day week" unless the requirements also make the hour limit explicit.
|
|
55
113
|
*
|
|
56
114
|
* @category Rules
|
|
57
115
|
*/
|
|
@@ -61,11 +119,6 @@ export function maxHoursPerWeek(hours, opts) {
|
|
|
61
119
|
/**
|
|
62
120
|
* Minimum hours when assigned on a day.
|
|
63
121
|
*
|
|
64
|
-
* @example
|
|
65
|
-
* ```typescript
|
|
66
|
-
* minHoursPerDay(4)
|
|
67
|
-
* ```
|
|
68
|
-
*
|
|
69
122
|
* @category Rules
|
|
70
123
|
*/
|
|
71
124
|
export function minHoursPerDay(hours, opts) {
|
|
@@ -74,24 +127,18 @@ export function minHoursPerDay(hours, opts) {
|
|
|
74
127
|
/**
|
|
75
128
|
* Minimum hours per scheduling week.
|
|
76
129
|
*
|
|
77
|
-
* @example
|
|
78
|
-
* ```typescript
|
|
79
|
-
* minHoursPerWeek(20, { priority: "HIGH" })
|
|
80
|
-
* ```
|
|
81
|
-
*
|
|
82
130
|
* @category Rules
|
|
83
131
|
*/
|
|
84
132
|
export function minHoursPerWeek(hours, opts) {
|
|
85
133
|
return makeRule("min-hours-week", { hours, ...opts });
|
|
86
134
|
}
|
|
87
135
|
/**
|
|
88
|
-
*
|
|
136
|
+
* Caps assigned days per scheduling week.
|
|
89
137
|
*
|
|
90
|
-
* @
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
* ```
|
|
138
|
+
* @remarks
|
|
139
|
+
* Use this when the requirements explicitly impose a weekly day cap. If the same
|
|
140
|
+
* number is the normal weekly pattern rather than just a hard limit, pair it
|
|
141
|
+
* with {@link targetDaysPerWeek}.
|
|
95
142
|
*
|
|
96
143
|
* @category Rules
|
|
97
144
|
*/
|
|
@@ -99,13 +146,13 @@ export function maxDaysPerWeek(days, opts) {
|
|
|
99
146
|
return makeRule("max-days-week", { days, ...opts });
|
|
100
147
|
}
|
|
101
148
|
/**
|
|
102
|
-
*
|
|
149
|
+
* Enforces a minimum number of assigned days per scheduling week.
|
|
103
150
|
*
|
|
104
|
-
* @
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
151
|
+
* @remarks
|
|
152
|
+
* Use this when the requirements explicitly require a weekly minimum. Language like
|
|
153
|
+
* "works a 4-day week" often implies a hard cap via {@link maxDaysPerWeek}
|
|
154
|
+
* and possibly a softer target via {@link targetDaysPerWeek}, not a mandatory
|
|
155
|
+
* weekly minimum for every member.
|
|
109
156
|
*
|
|
110
157
|
* @category Rules
|
|
111
158
|
*/
|
|
@@ -113,13 +160,26 @@ export function minDaysPerWeek(days, opts) {
|
|
|
113
160
|
return makeRule("min-days-week", { days, ...opts });
|
|
114
161
|
}
|
|
115
162
|
/**
|
|
116
|
-
*
|
|
163
|
+
* Softly targets assigned days per scheduling week.
|
|
117
164
|
*
|
|
118
|
-
* @
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
165
|
+
* @remarks
|
|
166
|
+
* Use this for stated working patterns like "works a 4-day week" when the
|
|
167
|
+
* pattern should remain the norm but can flex around holidays, time off, or
|
|
168
|
+
* other tradeoffs. Deviations in either direction are penalized, so working
|
|
169
|
+
* fewer days or more days than the target both count as misses. Pair it with
|
|
170
|
+
* {@link maxDaysPerWeek} when the same number is also a hard cap, and use
|
|
171
|
+
* {@link minDaysPerWeek} only when the requirements explicitly require a minimum.
|
|
172
|
+
*
|
|
173
|
+
* @param days - Target number of assigned days per scheduling week.
|
|
174
|
+
* @param opts - Optional entity scope and soft priority.
|
|
175
|
+
*
|
|
176
|
+
* @category Rules
|
|
177
|
+
*/
|
|
178
|
+
export function targetDaysPerWeek(days, opts) {
|
|
179
|
+
return makeRule("target-days-week", { days, ...opts });
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Maximum distinct shifts per day.
|
|
123
183
|
*
|
|
124
184
|
* @category Rules
|
|
125
185
|
*/
|
|
@@ -127,12 +187,56 @@ export function maxShiftsPerDay(shifts, opts) {
|
|
|
127
187
|
return makeRule("max-shifts-day", { shifts, ...opts });
|
|
128
188
|
}
|
|
129
189
|
/**
|
|
130
|
-
*
|
|
190
|
+
* Caps how many targeted assignments may overlap at the same time.
|
|
131
191
|
*
|
|
132
|
-
* @
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
192
|
+
* @remarks
|
|
193
|
+
* Use this for hard productive capacity limits that should stay separate from
|
|
194
|
+
* the minimum staffing requirement expressed by {@link cover}. Pair a
|
|
195
|
+
* lower-bound `cover(...)` with `maxConcurrentAssignments(...)` when the
|
|
196
|
+
* business needs both demand and capacity modeled explicitly.
|
|
197
|
+
*
|
|
198
|
+
* On days with staggered opening and closing shifts, keep lower-bound coverage
|
|
199
|
+
* scoped to the windows that truly need minimum staffing. Do not turn a total
|
|
200
|
+
* daily headcount target into a whole-day lower-bound `cover(...)` unless the
|
|
201
|
+
* business explicitly requires that many people in every overlapping bucket.
|
|
202
|
+
*
|
|
203
|
+
* Unlike {@link maxShiftsPerDay}, this limits simultaneous overlap, not total
|
|
204
|
+
* assignments on a day.
|
|
205
|
+
*
|
|
206
|
+
* @param assignments - Maximum number of concurrent overlapping assignments.
|
|
207
|
+
* @param opts - Optional scope and time-window settings.
|
|
208
|
+
*
|
|
209
|
+
* @category Rules
|
|
210
|
+
*/
|
|
211
|
+
export function maxConcurrentAssignments(assignments, opts) {
|
|
212
|
+
return makeRule("max-concurrent-assignments", { assignments, ...opts });
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Softly targets the daily peak number of concurrent overlapping assignments.
|
|
216
|
+
*
|
|
217
|
+
* @remarks
|
|
218
|
+
* Use this when the business wants to hit full productive occupancy at the
|
|
219
|
+
* busy point of a day, but does not mean that same number must be present
|
|
220
|
+
* throughout the full span. This is not a whole-day lower bound. Pair it with
|
|
221
|
+
* {@link cover} for edge minima and with
|
|
222
|
+
* {@link maxConcurrentAssignments} when the same value is also a hard cap.
|
|
223
|
+
* Prefer this over a whole-day `cover(...)` when the brief means "reach the
|
|
224
|
+
* peak" rather than "maintain this minimum throughout the day".
|
|
225
|
+
*
|
|
226
|
+
* This is a rule-level peak target, not a variant of {@link cover}. Do not
|
|
227
|
+
* introduce a synthetic semantic time just to attach a whole-window
|
|
228
|
+
* `cover(...)` when the requirement is really about the day's peak.
|
|
229
|
+
*
|
|
230
|
+
* @param assignments - Target peak number of concurrent overlapping assignments.
|
|
231
|
+
* @param opts - Optional scope and soft priority.
|
|
232
|
+
*
|
|
233
|
+
* @category Rules
|
|
234
|
+
*/
|
|
235
|
+
export function targetPeakConcurrentAssignments(assignments, opts) {
|
|
236
|
+
return makeRule("target-peak-concurrent-assignments", { assignments, ...opts });
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Maximum consecutive assigned days.
|
|
136
240
|
*
|
|
137
241
|
* @category Rules
|
|
138
242
|
*/
|
|
@@ -142,11 +246,6 @@ export function maxConsecutiveDays(days, opts) {
|
|
|
142
246
|
/**
|
|
143
247
|
* Once working, continue for at least this many consecutive days.
|
|
144
248
|
*
|
|
145
|
-
* @example
|
|
146
|
-
* ```typescript
|
|
147
|
-
* minConsecutiveDays(2, { priority: "HIGH" })
|
|
148
|
-
* ```
|
|
149
|
-
*
|
|
150
249
|
* @category Rules
|
|
151
250
|
*/
|
|
152
251
|
export function minConsecutiveDays(days, opts) {
|
|
@@ -155,37 +254,88 @@ export function minConsecutiveDays(days, opts) {
|
|
|
155
254
|
/**
|
|
156
255
|
* Minimum rest hours between shifts.
|
|
157
256
|
*
|
|
158
|
-
* @example
|
|
159
|
-
* ```typescript
|
|
160
|
-
* minRestBetweenShifts(10)
|
|
161
|
-
* ```
|
|
162
|
-
*
|
|
163
257
|
* @category Rules
|
|
164
258
|
*/
|
|
165
259
|
export function minRestBetweenShifts(hours, opts) {
|
|
166
260
|
return makeRule("min-rest-between-shifts", { hours, ...opts });
|
|
167
261
|
}
|
|
168
262
|
/**
|
|
169
|
-
*
|
|
263
|
+
* Nudge the solver toward scheduling targeted members.
|
|
170
264
|
*
|
|
171
|
-
* @
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
265
|
+
* @remarks
|
|
266
|
+
* Soft constraint. The solver adds a bonus for each assignment of the
|
|
267
|
+
* targeted members, making them more likely to appear on the schedule.
|
|
268
|
+
* Use `priority` to control how strong the nudge is; higher priority
|
|
269
|
+
* means a larger bonus. Even at `"MANDATORY"` strength the solver can
|
|
270
|
+
* still leave a member unassigned if hard constraints prevent it.
|
|
271
|
+
*
|
|
272
|
+
* Opposite of {@link avoidAssignment}. Both map to the same underlying
|
|
273
|
+
* `assignment-priority` rule with different directions.
|
|
274
|
+
*
|
|
275
|
+
* @param opts - See {@link RuleOptions}
|
|
176
276
|
*
|
|
177
277
|
* @category Rules
|
|
178
278
|
*/
|
|
179
|
-
export function
|
|
180
|
-
return makeRule("assignment-priority", { preference:
|
|
279
|
+
export function preferAssignment(opts) {
|
|
280
|
+
return makeRule("assignment-priority", { preference: "prefer", ...opts });
|
|
181
281
|
}
|
|
182
282
|
/**
|
|
183
|
-
*
|
|
283
|
+
* Nudge the solver away from scheduling targeted members.
|
|
184
284
|
*
|
|
185
|
-
* @
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
285
|
+
* @remarks
|
|
286
|
+
* Soft constraint. The solver adds a penalty for each assignment of the
|
|
287
|
+
* targeted members, making them less likely to appear on the schedule.
|
|
288
|
+
* The member is still assigned when coverage requires it; the penalty
|
|
289
|
+
* only matters when the solver has a choice.
|
|
290
|
+
*
|
|
291
|
+
* Opposite of {@link preferAssignment}. Both map to the same underlying
|
|
292
|
+
* `assignment-priority` rule with different directions.
|
|
293
|
+
*
|
|
294
|
+
* @param opts - See {@link RuleOptions}
|
|
295
|
+
*
|
|
296
|
+
* @category Rules
|
|
297
|
+
*/
|
|
298
|
+
export function avoidAssignment(opts) {
|
|
299
|
+
return makeRule("assignment-priority", { preference: "avoid", ...opts });
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Steer a multi-role member toward shifts tagged with a specific role.
|
|
303
|
+
*
|
|
304
|
+
* @remarks
|
|
305
|
+
* Penalizes assignment to shift patterns whose `roleIds` do not include
|
|
306
|
+
* the preferred role. The member is still assigned to other roles when
|
|
307
|
+
* coverage requires it; the penalty only matters when the solver has a
|
|
308
|
+
* choice. Shift patterns without any `roleIds` (open to all) are also
|
|
309
|
+
* penalized since they are not explicitly tagged with the preferred role.
|
|
310
|
+
*
|
|
311
|
+
* The targeted members must actually hold the preferred role in their
|
|
312
|
+
* `roleIds`. If none of them do, compilation reports an error because
|
|
313
|
+
* the rule would silently penalize all their assignments (the opposite
|
|
314
|
+
* of the intent).
|
|
315
|
+
*
|
|
316
|
+
* Typical use case: a waiter who can cover kitchen pass shifts in a
|
|
317
|
+
* pinch. Give the member both roles (`roleIds: ["waiter", "pass"]`)
|
|
318
|
+
* and use `preferRole("waiter", ...)` so the solver keeps them on the
|
|
319
|
+
* floor unless the pass team is short-staffed.
|
|
320
|
+
*
|
|
321
|
+
* @param roleId - The role to prefer
|
|
322
|
+
* @param opts - See {@link EntityOnlyRuleOptions}
|
|
323
|
+
*
|
|
324
|
+
* @category Rules
|
|
325
|
+
*/
|
|
326
|
+
export function preferRole(roleId, opts) {
|
|
327
|
+
return makeRule("role-preference", { roleId, ...opts });
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Steer a member toward shifts at a specific location.
|
|
331
|
+
*
|
|
332
|
+
* @remarks
|
|
333
|
+
* Penalizes assignment to shift patterns whose `locationId` does not
|
|
334
|
+
* match the preferred location. The member is still assigned elsewhere
|
|
335
|
+
* when coverage requires it.
|
|
336
|
+
*
|
|
337
|
+
* @param locationId - The location to prefer
|
|
338
|
+
* @param opts - See {@link EntityOnlyRuleOptions}
|
|
189
339
|
*
|
|
190
340
|
* @category Rules
|
|
191
341
|
*/
|
|
@@ -206,12 +356,6 @@ export function preferLocation(locationId, opts) {
|
|
|
206
356
|
* messaging from {@link minDaysPerWeek}. Priority is not configurable;
|
|
207
357
|
* the rule name communicates the intent.
|
|
208
358
|
*
|
|
209
|
-
* @example
|
|
210
|
-
* ```typescript
|
|
211
|
-
* mustAssign({ appliesTo: "diana" })
|
|
212
|
-
* mustAssign({ appliesTo: ["diana", "yavuz"] })
|
|
213
|
-
* ```
|
|
214
|
-
*
|
|
215
359
|
* @category Rules
|
|
216
360
|
*/
|
|
217
361
|
export function mustAssign(opts) {
|
|
@@ -224,18 +368,6 @@ export function mustAssign(opts) {
|
|
|
224
368
|
* Block assignments during specified periods.
|
|
225
369
|
* Requires at least one time scope (`dayOfWeek`, `dateRange`, `dates`, or `from`/`until`).
|
|
226
370
|
*
|
|
227
|
-
* @example
|
|
228
|
-
* ```typescript
|
|
229
|
-
* // Full days off
|
|
230
|
-
* timeOff({ appliesTo: "alice", dateRange: { start: "2024-02-01", end: "2024-02-05" } })
|
|
231
|
-
*
|
|
232
|
-
* // Every weekend off
|
|
233
|
-
* timeOff({ appliesTo: "mauro", dayOfWeek: weekend })
|
|
234
|
-
*
|
|
235
|
-
* // Wednesday afternoons off
|
|
236
|
-
* timeOff({ appliesTo: "student", dayOfWeek: ["wednesday"], from: t(14) })
|
|
237
|
-
* ```
|
|
238
|
-
*
|
|
239
371
|
* @category Rules
|
|
240
372
|
*/
|
|
241
373
|
export function timeOff(opts) {
|
|
@@ -244,7 +376,7 @@ export function timeOff(opts) {
|
|
|
244
376
|
if (!rest.dayOfWeek && !rest.dateRange && !rest.dates && !rest.recurringPeriods) {
|
|
245
377
|
throw new Error("timeOff() requires at least one time scope (dayOfWeek, dateRange, dates, or recurringPeriods).");
|
|
246
378
|
}
|
|
247
|
-
const { appliesTo, dates, ...passthrough } = rest;
|
|
379
|
+
const { appliesTo, dates, priority, ...passthrough } = rest;
|
|
248
380
|
const entityScope = resolveAppliesTo(appliesTo, ctx.roles, ctx.skills, ctx.memberIds);
|
|
249
381
|
const resolvedDates = dates ? { specificDates: dates } : {};
|
|
250
382
|
const partialDay = {};
|
|
@@ -260,24 +392,20 @@ export function timeOff(opts) {
|
|
|
260
392
|
partialDay.startTime = { hours: 0, minutes: 0 };
|
|
261
393
|
partialDay.endTime = until;
|
|
262
394
|
}
|
|
263
|
-
|
|
395
|
+
const resolved = {
|
|
264
396
|
name: "time-off",
|
|
397
|
+
priority: priority ?? "MANDATORY",
|
|
265
398
|
...passthrough,
|
|
266
399
|
...entityScope,
|
|
267
400
|
...resolvedDates,
|
|
268
401
|
...partialDay,
|
|
269
402
|
};
|
|
403
|
+
return resolved;
|
|
270
404
|
});
|
|
271
405
|
}
|
|
272
406
|
/**
|
|
273
407
|
* Members work the same shifts on days they are both assigned.
|
|
274
408
|
*
|
|
275
|
-
* @example
|
|
276
|
-
* ```typescript
|
|
277
|
-
* assignTogether(["alice", "bob"])
|
|
278
|
-
* assignTogether(["alice", "bob", "charlie"], { priority: "HIGH" })
|
|
279
|
-
* ```
|
|
280
|
-
*
|
|
281
409
|
* @category Rules
|
|
282
410
|
*/
|
|
283
411
|
export function assignTogether(memberIds, opts) {
|
|
@@ -288,11 +416,85 @@ export function assignTogether(memberIds, opts) {
|
|
|
288
416
|
`Known member IDs: ${[...ctx.memberIds].join(", ")}`);
|
|
289
417
|
}
|
|
290
418
|
}
|
|
291
|
-
|
|
419
|
+
const resolved = {
|
|
292
420
|
name: "assign-together",
|
|
293
421
|
groupMemberIds: memberIds,
|
|
294
|
-
|
|
422
|
+
priority: opts?.priority ?? "MANDATORY",
|
|
423
|
+
};
|
|
424
|
+
return resolved;
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Caps how many times a person works on specific days of the week within
|
|
429
|
+
* each period.
|
|
430
|
+
*
|
|
431
|
+
* @remarks
|
|
432
|
+
* The scheduling window is divided into non-overlapping chunks of the
|
|
433
|
+
* configured period length. Within each chunk, only days matching the
|
|
434
|
+
* `dayOfWeek` filter are counted. The constraint bounds that count.
|
|
435
|
+
*
|
|
436
|
+
* @param days - Maximum number of matching days allowed per period.
|
|
437
|
+
* @param dayOfWeek - Which days of the week count toward the limit.
|
|
438
|
+
* @param opts - Period length and optional scoping.
|
|
439
|
+
*
|
|
440
|
+
* @category Rules
|
|
441
|
+
*/
|
|
442
|
+
export function maxDaysOfWeekPerPeriod(days, dayOfWeek, opts) {
|
|
443
|
+
const { appliesTo, priority, ...periodOpts } = opts;
|
|
444
|
+
const period = "weeks" in periodOpts && periodOpts.weeks != null
|
|
445
|
+
? { type: "weeks", value: periodOpts.weeks }
|
|
446
|
+
: { type: "months", value: periodOpts.months };
|
|
447
|
+
return defineRule("max-days-of-week-per-period", { days, dayOfWeek: [...dayOfWeek], period, appliesTo, priority }, (ctx) => {
|
|
448
|
+
const entityScope = resolveAppliesTo(appliesTo, ctx.roles, ctx.skills, ctx.memberIds);
|
|
449
|
+
const resolved = {
|
|
450
|
+
name: "max-days-of-week-per-period",
|
|
451
|
+
days,
|
|
452
|
+
dayOfWeek: [...dayOfWeek],
|
|
453
|
+
period,
|
|
454
|
+
priority: priority ?? "MANDATORY",
|
|
455
|
+
...entityScope,
|
|
456
|
+
};
|
|
457
|
+
return resolved;
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Enforces a minimum number of times a person works on specific days of the
|
|
462
|
+
* week within each period.
|
|
463
|
+
*
|
|
464
|
+
* @remarks
|
|
465
|
+
* The scheduling window is divided into non-overlapping chunks of the
|
|
466
|
+
* configured period length. Within each chunk, only days matching the
|
|
467
|
+
* `dayOfWeek` filter are counted. The constraint ensures the count meets
|
|
468
|
+
* the minimum.
|
|
469
|
+
*
|
|
470
|
+
* When the scheduling window does not align evenly with the period
|
|
471
|
+
* boundaries, the last chunk may contain fewer matching days than the
|
|
472
|
+
* minimum. A MANDATORY priority will make the model infeasible in that
|
|
473
|
+
* case. Use a soft priority (HIGH, MEDIUM, LOW) if partial periods at
|
|
474
|
+
* the edges of the window are expected.
|
|
475
|
+
*
|
|
476
|
+
* @param days - Minimum number of matching days required per period.
|
|
477
|
+
* @param dayOfWeek - Which days of the week count toward the limit.
|
|
478
|
+
* @param opts - Period length and optional scoping.
|
|
479
|
+
*
|
|
480
|
+
* @category Rules
|
|
481
|
+
*/
|
|
482
|
+
export function minDaysOfWeekPerPeriod(days, dayOfWeek, opts) {
|
|
483
|
+
const { appliesTo, priority, ...periodOpts } = opts;
|
|
484
|
+
const period = "weeks" in periodOpts && periodOpts.weeks != null
|
|
485
|
+
? { type: "weeks", value: periodOpts.weeks }
|
|
486
|
+
: { type: "months", value: periodOpts.months };
|
|
487
|
+
return defineRule("min-days-of-week-per-period", { days, dayOfWeek: [...dayOfWeek], period, appliesTo, priority }, (ctx) => {
|
|
488
|
+
const entityScope = resolveAppliesTo(appliesTo, ctx.roles, ctx.skills, ctx.memberIds);
|
|
489
|
+
const resolved = {
|
|
490
|
+
name: "min-days-of-week-per-period",
|
|
491
|
+
days,
|
|
492
|
+
dayOfWeek: [...dayOfWeek],
|
|
493
|
+
period,
|
|
494
|
+
priority: priority ?? "MANDATORY",
|
|
495
|
+
...entityScope,
|
|
295
496
|
};
|
|
497
|
+
return resolved;
|
|
296
498
|
});
|
|
297
499
|
}
|
|
298
500
|
// ============================================================================
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules.js","sourceRoot":"","sources":["../../src/schedule/rules.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"rules.js","sourceRoot":"","sources":["../../src/schedule/rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AA6SH,MAAM,UAAU,UAAU,CACxB,IAAU,EACV,MAAc,EACd,OAA+E;IAE/E,MAAM,UAAU,GAAG,EAAE,GAAG,MAAM,EAG7B,CAAC;IACF,OAAO,UAAU,CAAC,KAAK,CAAC;IACxB,OAAO,UAAU,CAAC,KAAK,CAAC;IAExB,MAAM,KAAK,GAAiD;QAC1D,KAAK,EAAE,MAAM;QACb,KAAK,EAAE,IAAI;QACX,GAAG,UAAU;KACd,CAAC;IACF,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;IAClF,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,aAAa,CAC3B,YAA2B;IAS3B,KAAK,YAAY,CAAC;IAElB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AACtE,CAAC;AAED,SAAS,QAAQ,CACf,IAAU,EACV,MAAc;IAEd,OAA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,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CACb,uDAAuD,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK;YAClF,YAAY,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM;YACrF,+CAA+C,CAClD,CAAC;IACJ,CAAC;IAED,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7B,OAAO,EAAE,OAAO,EAAE,aAAsC,EAAE,CAAC;IAC7D,CAAC;IACD,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9B,OAAO,EAAE,QAAQ,EAAE,cAAuC,EAAE,CAAC;IAC/D,CAAC;IACD,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/B,OAAO,EAAE,SAAS,EAAE,eAAwC,EAAE,CAAC;IACjE,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -11,23 +11,6 @@ import type { ShiftPattern } from "../cpsat/types.js";
|
|
|
11
11
|
* @remarks
|
|
12
12
|
* Each pattern repeats daily unless filtered by `dayOfWeek`.
|
|
13
13
|
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```typescript
|
|
16
|
-
* shiftPatterns: [
|
|
17
|
-
* shift("morning", t(11, 30), t(15)),
|
|
18
|
-
* shift("evening", t(17), t(22)),
|
|
19
|
-
*
|
|
20
|
-
* // Role-restricted shift
|
|
21
|
-
* shift("kitchen", t(6), t(14), { roleIds: ["chef", "prep_cook"] }),
|
|
22
|
-
*
|
|
23
|
-
* // Day-restricted shift
|
|
24
|
-
* shift("saturday_short", t(9), t(14), { dayOfWeek: ["saturday"] }),
|
|
25
|
-
*
|
|
26
|
-
* // Location-specific shift
|
|
27
|
-
* shift("terrace_lunch", t(12), t(16), { locationId: "terrace" }),
|
|
28
|
-
* ]
|
|
29
|
-
* ```
|
|
30
|
-
*
|
|
31
14
|
* @category Shift Patterns
|
|
32
15
|
*/
|
|
33
16
|
export declare function shift(id: string, startTime: TimeOfDay, endTime: TimeOfDay, opts?: Pick<ShiftPattern, "roleIds" | "dayOfWeek" | "locationId">): ShiftPattern;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shift-patterns.d.ts","sourceRoot":"","sources":["../../src/schedule/shift-patterns.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD
|
|
1
|
+
{"version":3,"file":"shift-patterns.d.ts","sourceRoot":"","sources":["../../src/schedule/shift-patterns.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;;;;;;GAOG;AACH,wBAAgB,KAAK,CACnB,EAAE,EAAE,MAAM,EACV,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,SAAS,EAClB,IAAI,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,SAAS,GAAG,WAAW,GAAG,YAAY,CAAC,GAChE,YAAY,CAMd"}
|