@jsb188/schedule 1.1.12 → 1.1.13

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 (59) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +33 -14
  3. package/src/constants/schedule.ts +710 -306
  4. package/src/types/schedule.d.ts +1827 -456
  5. package/src/ui/ScheduleSettingsUI.tsx +21 -23
  6. package/src/utils/autofill.ts +469 -0
  7. package/src/utils/availability.ts +167 -0
  8. package/src/utils/candidates.ts +447 -0
  9. package/src/utils/coverage.helpers.ts +509 -554
  10. package/src/utils/coverage.ts +1121 -526
  11. package/src/utils/cpm.helpers.ts +27 -29
  12. package/src/utils/cpm.ts +53 -41
  13. package/src/utils/cpmLeveling.helpers.ts +89 -16
  14. package/src/utils/cpmLeveling.ts +28 -26
  15. package/src/utils/cycle.ts +325 -0
  16. package/src/utils/demand.ts +239 -0
  17. package/src/utils/eligibility.ts +553 -400
  18. package/src/utils/ids.ts +47 -0
  19. package/src/utils/laborRules.ts +740 -0
  20. package/src/utils/localTime.ts +312 -0
  21. package/src/utils/offer.ts +300 -0
  22. package/src/utils/planCsv.ts +73 -19
  23. package/src/utils/predicate.ts +111 -0
  24. package/src/utils/request.ts +212 -114
  25. package/src/utils/resource.ts +412 -112
  26. package/src/utils/rule.ts +697 -163
  27. package/src/utils/rulePresets.ts +116 -0
  28. package/src/utils/run.ts +0 -8
  29. package/src/utils/scheduleText.ts +4074 -0
  30. package/src/utils/shiftChange.ts +279 -0
  31. package/src/utils/standing.ts +730 -0
  32. package/src/utils/template.ts +619 -0
  33. package/src/utils/violation.ts +184 -0
  34. package/src/utils/workTime.ts +341 -120
  35. package/src/utils/defaults.ts +0 -8
  36. package/src/utils/recurrence.ts +0 -616
  37. package/src/utils/series.ts +0 -161
  38. package/src/utils/slot.ts +0 -208
  39. package/tests/coverage.fixtures.ts +0 -111
  40. package/tests/coverage.test.ts +0 -503
  41. package/tests/cpm.bench.test.ts +0 -154
  42. package/tests/cpm.test.ts +0 -354
  43. package/tests/cpmCorrectness.test.ts +0 -327
  44. package/tests/cpmLeveling.test.ts +0 -471
  45. package/tests/eligibility.test.ts +0 -320
  46. package/tests/gantt-geometry.test.ts +0 -367
  47. package/tests/gantt-histogram.test.ts +0 -78
  48. package/tests/gantt-keyboard.test.ts +0 -69
  49. package/tests/helpers/cpmFixtures.ts +0 -101
  50. package/tests/projectInputs.test.ts +0 -165
  51. package/tests/recurrence.test.ts +0 -68
  52. package/tests/request.test.ts +0 -99
  53. package/tests/resource.test.ts +0 -95
  54. package/tests/rule.test.ts +0 -98
  55. package/tests/series.test.ts +0 -120
  56. package/tests/workTime.test.ts +0 -1007
  57. package/tests/workTimeContracts.test.ts +0 -111
  58. package/tsconfig.json +0 -13
  59. package/vitest.config.ts +0 -8
@@ -0,0 +1,116 @@
1
+ import type { ScheduleRulePresetObj } from '../types/schedule.d.ts';
2
+
3
+ /**
4
+ * Named rule sets per vertical that set_schedule_rule applies by name. Each
5
+ * rule is valid under validateScheduleRuleConfig, stored normalized, and
6
+ * never names an org-specific id (so no STAFFING_REQUIREMENT and no role
7
+ * predicates). The numbers are a starting point to check against local
8
+ * rules, and each description says so.
9
+ */
10
+
11
+ const FILE_CONSTANTS: { presets: ScheduleRulePresetObj[] } = {
12
+ presets: [
13
+ {
14
+ name: 'DAYCARE_LICENSING',
15
+ label: 'Daycare licensing',
16
+ description:
17
+ 'Children per adult and group sizes by age group (the youngest child in a room sets the ratio), and two adults on site while open (needs the opening hours). Common starting numbers: check them against your licensing rules.',
18
+ ageGroups: [
19
+ { key: 'INFANT', label: 'Infants' },
20
+ { key: 'TODDLER', label: 'Toddlers' },
21
+ { key: 'PRESCHOOL', label: 'Preschool' },
22
+ { key: 'SCHOOL_AGE', label: 'School age' },
23
+ ],
24
+ rules: [
25
+ {
26
+ kind: 'RATIO',
27
+ key: 'LICENSING_RATIO',
28
+ label: 'Children per adult',
29
+ severity: 'BLOCK',
30
+ config: {
31
+ ratios: { INFANT: 4, PRESCHOOL: 10, SCHOOL_AGE: 15, TODDLER: 6 },
32
+ mode: 'YOUNGEST',
33
+ maxGroupSize: {
34
+ INFANT: 8,
35
+ PRESCHOOL: 20,
36
+ SCHOOL_AGE: 30,
37
+ TODDLER: 12,
38
+ },
39
+ predicate: null,
40
+ },
41
+ },
42
+ {
43
+ kind: 'OPERATING_HOURS',
44
+ key: 'TWO_ADULTS_ON_SITE',
45
+ label: 'Two adults on site while open',
46
+ severity: 'BLOCK',
47
+ config: { minAdults: 2, predicate: null },
48
+ },
49
+ ],
50
+ },
51
+ {
52
+ name: 'BAR_LABOR',
53
+ label: 'Bar labor',
54
+ description:
55
+ 'Warnings for overtime (over 8 hours a day or 40 a pay week), under 10 hours of rest between shifts, more than 6 days in a row, and shifts outside 3 to 12 hours. Common starting numbers: check them against your local labor rules.',
56
+ ageGroups: null,
57
+ rules: [
58
+ {
59
+ kind: 'MAX_HOURS',
60
+ key: 'DAILY_OVERTIME',
61
+ label: 'Over 8 hours a day',
62
+ severity: 'WARN',
63
+ config: { period: 'DAY', days: null, maxMinutes: 480 },
64
+ },
65
+ {
66
+ kind: 'MAX_HOURS',
67
+ key: 'WEEKLY_OVERTIME',
68
+ label: 'Over 40 hours a pay week',
69
+ severity: 'WARN',
70
+ config: { period: 'PAY_WEEK', days: null, maxMinutes: 2400 },
71
+ },
72
+ {
73
+ kind: 'MIN_REST',
74
+ key: 'REST_BETWEEN_SHIFTS',
75
+ label: '10 hours between shifts',
76
+ severity: 'WARN',
77
+ config: { minMinutes: 600 },
78
+ },
79
+ {
80
+ kind: 'MAX_CONSECUTIVE_DAYS',
81
+ key: 'DAY_OFF_IN_SEVEN',
82
+ label: 'At most 6 days in a row',
83
+ severity: 'WARN',
84
+ config: { days: 6 },
85
+ },
86
+ {
87
+ kind: 'SHIFT_LENGTH',
88
+ key: 'SHIFT_LENGTH',
89
+ label: 'Shifts of 3 to 12 hours',
90
+ severity: 'WARN',
91
+ config: { minMinutes: 180, maxMinutes: 720 },
92
+ },
93
+ ],
94
+ },
95
+ ],
96
+ };
97
+
98
+ /*
99
+ * Return every rule preset (fresh copies, safe to change).
100
+ */
101
+ export function getScheduleRulePresets(): ScheduleRulePresetObj[] {
102
+ return structuredClone(FILE_CONSTANTS.presets);
103
+ }
104
+
105
+ /*
106
+ * Return one preset by name (trimmed, any case), or null when there is none.
107
+ */
108
+ export function getScheduleRulePreset(
109
+ name: string,
110
+ ): ScheduleRulePresetObj | null {
111
+ const wanted = String(name ?? '')
112
+ .trim()
113
+ .toUpperCase();
114
+ const preset = FILE_CONSTANTS.presets.find((item) => item.name === wanted);
115
+ return preset ? structuredClone(preset) : null;
116
+ }
package/src/utils/run.ts CHANGED
@@ -33,11 +33,3 @@ export function getLatestScheduleRun<
33
33
  }
34
34
  return latest;
35
35
  }
36
- /* Identify the durable job currently waiting or executing. */
37
- export function getActiveScheduleRun<T extends { status: string }>(
38
- run: T | null,
39
- ): T | null {
40
- return run && (run.status === 'QUEUED' || run.status === 'RUNNING')
41
- ? run
42
- : null;
43
- }