@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.
- package/LICENSE +21 -0
- package/package.json +33 -14
- package/src/constants/schedule.ts +710 -306
- package/src/types/schedule.d.ts +1827 -456
- package/src/ui/ScheduleSettingsUI.tsx +21 -23
- package/src/utils/autofill.ts +469 -0
- package/src/utils/availability.ts +167 -0
- package/src/utils/candidates.ts +447 -0
- package/src/utils/coverage.helpers.ts +509 -554
- package/src/utils/coverage.ts +1121 -526
- package/src/utils/cpm.helpers.ts +27 -29
- package/src/utils/cpm.ts +53 -41
- package/src/utils/cpmLeveling.helpers.ts +89 -16
- package/src/utils/cpmLeveling.ts +28 -26
- package/src/utils/cycle.ts +325 -0
- package/src/utils/demand.ts +239 -0
- package/src/utils/eligibility.ts +553 -400
- package/src/utils/ids.ts +47 -0
- package/src/utils/laborRules.ts +740 -0
- package/src/utils/localTime.ts +312 -0
- package/src/utils/offer.ts +300 -0
- package/src/utils/planCsv.ts +73 -19
- package/src/utils/predicate.ts +111 -0
- package/src/utils/request.ts +212 -114
- package/src/utils/resource.ts +412 -112
- package/src/utils/rule.ts +697 -163
- package/src/utils/rulePresets.ts +116 -0
- package/src/utils/run.ts +0 -8
- package/src/utils/scheduleText.ts +4074 -0
- package/src/utils/shiftChange.ts +279 -0
- package/src/utils/standing.ts +730 -0
- package/src/utils/template.ts +619 -0
- package/src/utils/violation.ts +184 -0
- package/src/utils/workTime.ts +341 -120
- package/src/utils/defaults.ts +0 -8
- package/src/utils/recurrence.ts +0 -616
- package/src/utils/series.ts +0 -161
- package/src/utils/slot.ts +0 -208
- package/tests/coverage.fixtures.ts +0 -111
- package/tests/coverage.test.ts +0 -503
- package/tests/cpm.bench.test.ts +0 -154
- package/tests/cpm.test.ts +0 -354
- package/tests/cpmCorrectness.test.ts +0 -327
- package/tests/cpmLeveling.test.ts +0 -471
- package/tests/eligibility.test.ts +0 -320
- package/tests/gantt-geometry.test.ts +0 -367
- package/tests/gantt-histogram.test.ts +0 -78
- package/tests/gantt-keyboard.test.ts +0 -69
- package/tests/helpers/cpmFixtures.ts +0 -101
- package/tests/projectInputs.test.ts +0 -165
- package/tests/recurrence.test.ts +0 -68
- package/tests/request.test.ts +0 -99
- package/tests/resource.test.ts +0 -95
- package/tests/rule.test.ts +0 -98
- package/tests/series.test.ts +0 -120
- package/tests/workTime.test.ts +0 -1007
- package/tests/workTimeContracts.test.ts +0 -111
- package/tsconfig.json +0 -13
- package/vitest.config.ts +0 -8
|
@@ -1,54 +1,35 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
ScheduleCalendarSettingsObj,
|
|
3
|
+
ScheduleOrganizationSettingsObj,
|
|
4
|
+
ScheduleRuleKindEnum,
|
|
5
|
+
} from '../types/schedule.d.ts';
|
|
2
6
|
|
|
3
|
-
/* Shared scheduling contracts for project plans and
|
|
4
|
-
|
|
5
|
-
export const SCHEDULE_MODE_ENUMS = ['PROJECT', 'COVERAGE'] as const;
|
|
6
|
-
|
|
7
|
-
// The home view a mode opens on; every mode can still switch to the others
|
|
8
|
-
export const SCHEDULE_DEFAULT_VIEW_ENUMS = [
|
|
9
|
-
'GANTT',
|
|
10
|
-
'WEEK',
|
|
11
|
-
'MONTH',
|
|
12
|
-
'AGENDA',
|
|
13
|
-
] as const;
|
|
7
|
+
/* Shared scheduling contracts for project plans and staff schedules. */
|
|
14
8
|
|
|
15
9
|
/**
|
|
16
10
|
* Working-time calendars
|
|
17
11
|
*
|
|
18
|
-
* A work calendar says which minutes count as work.
|
|
19
|
-
*
|
|
20
|
-
* following Tuesday.
|
|
21
|
-
* hours (when a
|
|
12
|
+
* A work calendar says which minutes count as work. Project durations are
|
|
13
|
+
* working minutes, so a five-day task spanning a weekend lands on the
|
|
14
|
+
* following Tuesday. Staff schedules use the same object for operating
|
|
15
|
+
* hours (when a location must be covered).
|
|
22
16
|
*/
|
|
23
17
|
|
|
24
|
-
// Weekdays use the JavaScript convention: 0 = Sunday ... 6 = Saturday
|
|
25
|
-
export const SCHEDULE_WEEKDAY_KEYS = [
|
|
26
|
-
'0',
|
|
27
|
-
'1',
|
|
28
|
-
'2',
|
|
29
|
-
'3',
|
|
30
|
-
'4',
|
|
31
|
-
'5',
|
|
32
|
-
'6',
|
|
33
|
-
] as const;
|
|
34
|
-
|
|
35
|
-
// A calendar that never reaches working time in this many days is treated as
|
|
36
|
-
// empty; walking past it would only spin
|
|
37
|
-
|
|
38
18
|
// The platform standard calendar every organization starts from
|
|
39
19
|
export const SCHEDULE_STANDARD_WORK_CALENDAR_KEY = 'STANDARD_8X5';
|
|
40
20
|
|
|
41
21
|
/**
|
|
42
22
|
* Resources
|
|
43
23
|
*
|
|
44
|
-
* One table serves both engines.
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
24
|
+
* One table serves both engines. PERSON is an org member with an account: it
|
|
25
|
+
* can hold shifts, be offered shifts and be texted. LABOR is a crew, trade or
|
|
26
|
+
* subcontractor with no login (project leveling only). A crane is EQUIPMENT,
|
|
27
|
+
* concrete is MATERIAL, and a classroom, bar station or booth is SPACE.
|
|
28
|
+
* Order matches schedule_resources_kind_check.
|
|
49
29
|
*/
|
|
50
30
|
|
|
51
31
|
export const SCHEDULE_RESOURCE_KIND_ENUMS = [
|
|
32
|
+
'PERSON',
|
|
52
33
|
'LABOR',
|
|
53
34
|
'EQUIPMENT',
|
|
54
35
|
'MATERIAL',
|
|
@@ -56,88 +37,640 @@ export const SCHEDULE_RESOURCE_KIND_ENUMS = [
|
|
|
56
37
|
] as const;
|
|
57
38
|
|
|
58
39
|
/**
|
|
59
|
-
*
|
|
40
|
+
* Shifts (one row = one seat)
|
|
41
|
+
*
|
|
42
|
+
* Status only moves forward: DRAFT -> PUBLISHED -> CANCELED. Only PUBLISHED
|
|
43
|
+
* seats are visible to workers; only PUBLISHED seats are journaled.
|
|
60
44
|
*/
|
|
61
45
|
|
|
62
|
-
|
|
63
|
-
// marks time a resource is unavailable (closure, maintenance, cleaning)
|
|
64
|
-
export const SCHEDULE_OCCURRENCE_KIND_ENUMS = [
|
|
65
|
-
'SHIFT',
|
|
66
|
-
'EVENT',
|
|
67
|
-
'BLOCK',
|
|
68
|
-
] as const;
|
|
69
|
-
|
|
70
|
-
// Only PUBLISHED rows are visible to workers
|
|
71
|
-
export const SCHEDULE_OCCURRENCE_STATUS_ENUMS = [
|
|
46
|
+
export const SCHEDULE_SHIFT_STATUS_ENUMS = [
|
|
72
47
|
'DRAFT',
|
|
73
48
|
'PUBLISHED',
|
|
74
49
|
'CANCELED',
|
|
75
50
|
] as const;
|
|
76
51
|
|
|
77
|
-
export const
|
|
52
|
+
export const SCHEDULE_SHIFT_CREATED_VIA_ENUMS = [
|
|
53
|
+
'MANUAL',
|
|
54
|
+
'TEMPLATE',
|
|
55
|
+
'COPY',
|
|
56
|
+
'AGENT',
|
|
57
|
+
'IMPORT',
|
|
58
|
+
] as const;
|
|
59
|
+
|
|
60
|
+
// Journal (schedule_shift_changes) kinds and origins, post-publish only
|
|
61
|
+
export const SCHEDULE_SHIFT_CHANGE_KIND_ENUMS = [
|
|
78
62
|
'ASSIGNED',
|
|
79
|
-
'
|
|
63
|
+
'UNASSIGNED',
|
|
64
|
+
'RETIMED',
|
|
65
|
+
'EDITED',
|
|
66
|
+
'CANCELED',
|
|
67
|
+
] as const;
|
|
68
|
+
|
|
69
|
+
export const SCHEDULE_SHIFT_CHANGE_VIA_ENUMS = [
|
|
70
|
+
'MANUAL',
|
|
71
|
+
'REQUEST',
|
|
72
|
+
'AGENT',
|
|
73
|
+
'SYSTEM',
|
|
74
|
+
] as const;
|
|
75
|
+
|
|
76
|
+
// Seat fields a journal row's previousValues / nextValues may carry. The
|
|
77
|
+
// assignee travels in fromResourceId / toResourceId, the status in the kind.
|
|
78
|
+
// RETIMED covers startAt / endAt / shiftDate; EDITED covers the rest.
|
|
79
|
+
export const SCHEDULE_SHIFT_RETIME_FIELDS = [
|
|
80
|
+
'startAt',
|
|
81
|
+
'endAt',
|
|
82
|
+
'shiftDate',
|
|
83
|
+
] as const;
|
|
84
|
+
|
|
85
|
+
export const SCHEDULE_SHIFT_EDIT_FIELDS = [
|
|
86
|
+
'roleId',
|
|
87
|
+
'locationResourceId',
|
|
88
|
+
'unpaidBreakMinutes',
|
|
89
|
+
'label',
|
|
90
|
+
'note',
|
|
91
|
+
] as const;
|
|
92
|
+
|
|
93
|
+
// 48-hour cap (schedule_shifts_window_check). Window reads by shiftDate look
|
|
94
|
+
// back SCHEDULE_SHIFT_MAX_DURATION_DAYS before the window's first day.
|
|
95
|
+
export const SCHEDULE_SHIFT_MAX_DURATION_MINUTES = 2880;
|
|
96
|
+
export const SCHEDULE_SHIFT_MAX_DURATION_DAYS = 2;
|
|
97
|
+
|
|
98
|
+
// A change notice collects a person's seat changes for this long after the
|
|
99
|
+
// first change before it is sent (coalesced SHIFTS_CHANGED rows)
|
|
100
|
+
export const SCHEDULE_CHANGE_NOTICE_SETTLE_MS = 120_000;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Templates and the standing schedule
|
|
104
|
+
*/
|
|
105
|
+
|
|
106
|
+
// schedule_templates_rotation_check: week A ... week D
|
|
107
|
+
export const SCHEDULE_ROTATION_MAX_WEEKS = 4;
|
|
108
|
+
|
|
109
|
+
// How texts name rotation weeks 1..4
|
|
110
|
+
export const SCHEDULE_ROTATION_WEEK_LABELS = ['A', 'B', 'C', 'D'] as const;
|
|
111
|
+
|
|
112
|
+
// A seat write's scope: the seat only, or the standing schedule and the later
|
|
113
|
+
// seats made from it too ("from now on")
|
|
114
|
+
export const SCHEDULE_EDIT_SCOPE_ENUMS = [
|
|
115
|
+
'THIS_SHIFT',
|
|
116
|
+
'THIS_AND_FUTURE',
|
|
117
|
+
] as const;
|
|
118
|
+
|
|
119
|
+
// The name of a standing schedule the system creates
|
|
120
|
+
export const SCHEDULE_STANDING_TEMPLATE_NAME = 'Standing schedule';
|
|
121
|
+
|
|
122
|
+
// Field groups a THIS_AND_FUTURE change carries to later seats (one-offs keep
|
|
123
|
+
// their own value)
|
|
124
|
+
export const SCHEDULE_STANDING_FIELD_GROUP_ENUMS = [
|
|
125
|
+
'HOURS',
|
|
126
|
+
'ROLE',
|
|
127
|
+
'LOCATION',
|
|
128
|
+
'BREAK',
|
|
129
|
+
'LABEL',
|
|
130
|
+
'PERSON',
|
|
131
|
+
] as const;
|
|
132
|
+
|
|
133
|
+
// Repeat detection over a standing item's last published seats
|
|
134
|
+
export const SCHEDULE_REPEAT_COVER_RUN = 3; // someone else worked it this many times running
|
|
135
|
+
export const SCHEDULE_REPEAT_ALTERNATING_RUN = 4; // two people alternated over this many
|
|
136
|
+
export const SCHEDULE_REPEAT_LOOKBACK_WEEKS = 8; // x rotationWeeks, before the period
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Availability (recurring weekly windows per PERSON)
|
|
140
|
+
*/
|
|
141
|
+
|
|
142
|
+
export const SCHEDULE_AVAILABILITY_KIND_ENUMS = [
|
|
143
|
+
'UNAVAILABLE',
|
|
144
|
+
'PREFERRED',
|
|
80
145
|
] as const;
|
|
81
146
|
|
|
82
147
|
/**
|
|
83
|
-
*
|
|
84
|
-
*
|
|
148
|
+
* Rules. Each kind maps to exactly one evaluator, so adding a kind is one
|
|
149
|
+
* evaluator plus one value here and in both DDL CHECKs (rules, violations).
|
|
85
150
|
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
151
|
+
* STAFFING_REQUIREMENT at least minCount people of given roles in weekly windows
|
|
152
|
+
* RATIO enough adults for the children in a room (demand)
|
|
153
|
+
* ROOM_CAPACITY children in a room never exceed its capacity
|
|
154
|
+
* OPERATING_HOURS at least minAdults while the location (or a room) is open
|
|
155
|
+
* ELIGIBILITY one person x one seat: role, qualifications, time off, overlap, availability
|
|
156
|
+
* MAX_HOURS worked minutes per day, pay week or rolling days
|
|
157
|
+
* MIN_REST the gap between a person's consecutive seats
|
|
158
|
+
* MAX_CONSECUTIVE_DAYS consecutive local days with any seat
|
|
159
|
+
* SHIFT_LENGTH one seat's duration
|
|
160
|
+
* NOTICE_PERIOD publishing late, and post-publish changes inside the window
|
|
91
161
|
*/
|
|
92
162
|
|
|
93
163
|
export const SCHEDULE_RULE_KIND_ENUMS = [
|
|
94
|
-
'
|
|
95
|
-
'
|
|
164
|
+
'STAFFING_REQUIREMENT',
|
|
165
|
+
'RATIO',
|
|
96
166
|
'ROOM_CAPACITY',
|
|
97
167
|
'OPERATING_HOURS',
|
|
98
168
|
'ELIGIBILITY',
|
|
99
|
-
'
|
|
169
|
+
'MAX_HOURS',
|
|
170
|
+
'MIN_REST',
|
|
171
|
+
'MAX_CONSECUTIVE_DAYS',
|
|
172
|
+
'SHIFT_LENGTH',
|
|
173
|
+
'NOTICE_PERIOD',
|
|
100
174
|
] as const;
|
|
101
175
|
|
|
102
|
-
// BLOCK prevents publishing the window
|
|
176
|
+
// BLOCK prevents publishing the window (coverage and notice rules) or refuses
|
|
177
|
+
// the assignee write (person rules); WARN records the breach and lets the
|
|
103
178
|
// publisher acknowledge it
|
|
104
179
|
export const SCHEDULE_RULE_SEVERITY_ENUMS = ['BLOCK', 'WARN'] as const;
|
|
105
180
|
|
|
181
|
+
// Person rules are checked by simulation when an assignee is set; a BLOCK
|
|
182
|
+
// refuses the write. ELIGIBILITY is evaluated by utils/eligibility.ts, the
|
|
183
|
+
// timeline kinds by utils/laborRules.ts.
|
|
184
|
+
export const SCHEDULE_PERSON_RULE_KINDS = [
|
|
185
|
+
'ELIGIBILITY',
|
|
186
|
+
'MAX_HOURS',
|
|
187
|
+
'MIN_REST',
|
|
188
|
+
'MAX_CONSECUTIVE_DAYS',
|
|
189
|
+
'SHIFT_LENGTH',
|
|
190
|
+
] as const;
|
|
191
|
+
|
|
192
|
+
// At most one rule of these kinds per scope, whatever its key (checked in
|
|
193
|
+
// ops). The ladder for them is per kind, not per key.
|
|
194
|
+
export const SCHEDULE_SINGLETON_RULE_KINDS = [
|
|
195
|
+
'ROOM_CAPACITY',
|
|
196
|
+
'OPERATING_HOURS',
|
|
197
|
+
'ELIGIBILITY',
|
|
198
|
+
] as const;
|
|
199
|
+
|
|
200
|
+
// Kinds that apply with no rule row: ROOM_CAPACITY at BLOCK, ELIGIBILITY with
|
|
201
|
+
// its hard checks at BLOCK and UNAVAILABLE at WARN
|
|
202
|
+
export const SCHEDULE_IMPLICIT_RULE_KINDS = [
|
|
203
|
+
'ROOM_CAPACITY',
|
|
204
|
+
'ELIGIBILITY',
|
|
205
|
+
] as const;
|
|
206
|
+
|
|
207
|
+
// What a resource-scoped rule's resourceId must be: ROOM = a SPACE, PERSON = a
|
|
208
|
+
// PERSON, NONE = the kind cannot be resource-scoped (STAFFING_REQUIREMENT
|
|
209
|
+
// names its location in config.locationResourceId). A mismatch is a
|
|
210
|
+
// RULE_SUBJECT_KIND_MISMATCH diagnostic.
|
|
211
|
+
export const SCHEDULE_RULE_SUBJECT_BY_KIND = {
|
|
212
|
+
STAFFING_REQUIREMENT: 'NONE',
|
|
213
|
+
RATIO: 'ROOM',
|
|
214
|
+
ROOM_CAPACITY: 'ROOM',
|
|
215
|
+
OPERATING_HOURS: 'ROOM',
|
|
216
|
+
ELIGIBILITY: 'PERSON',
|
|
217
|
+
MAX_HOURS: 'PERSON',
|
|
218
|
+
MIN_REST: 'PERSON',
|
|
219
|
+
MAX_CONSECUTIVE_DAYS: 'PERSON',
|
|
220
|
+
SHIFT_LENGTH: 'PERSON',
|
|
221
|
+
NOTICE_PERIOD: 'PERSON',
|
|
222
|
+
} as const satisfies Record<ScheduleRuleKindEnum, 'ROOM' | 'PERSON' | 'NONE'>;
|
|
223
|
+
|
|
224
|
+
// MAX_HOURS periods: DAY and PAY_WEEK use local dates in the evaluated
|
|
225
|
+
// calendar's zone and the org's payWeekStart; ROLLING_DAYS uses config.days
|
|
226
|
+
export const SCHEDULE_MAX_HOURS_PERIOD_ENUMS = [
|
|
227
|
+
'DAY',
|
|
228
|
+
'PAY_WEEK',
|
|
229
|
+
'ROLLING_DAYS',
|
|
230
|
+
] as const;
|
|
231
|
+
|
|
232
|
+
// RATIO: BLENDED = ceil(children / ratio) per age group, summed; YOUNGEST =
|
|
233
|
+
// ceil(all children / ratio of the youngest group present)
|
|
234
|
+
export const SCHEDULE_RATIO_MODE_ENUMS = ['BLENDED', 'YOUNGEST'] as const;
|
|
235
|
+
|
|
236
|
+
// Rule configuration bounds (validators in utils/rule.ts)
|
|
237
|
+
export const SCHEDULE_RULE_MAX_RATIO = 50;
|
|
238
|
+
export const SCHEDULE_RULE_MAX_GROUP_SIZE = 200;
|
|
239
|
+
export const SCHEDULE_RULE_MAX_MIN_ADULTS = 99;
|
|
240
|
+
export const SCHEDULE_RULE_MAX_MIN_COUNT = 99;
|
|
241
|
+
export const SCHEDULE_RULE_MAX_STAFFING_WINDOWS = 50;
|
|
242
|
+
export const SCHEDULE_RULE_MAX_ROLE_IDS = 20;
|
|
243
|
+
// ROLLING_DAYS, MAX_CONSECUTIVE_DAYS and NOTICE_PERIOD days
|
|
244
|
+
export const SCHEDULE_RULE_MAX_DAYS = 31;
|
|
245
|
+
// MAX_HOURS maxMinutes (31 days of minutes)
|
|
246
|
+
export const SCHEDULE_RULE_MAX_MINUTES = 44_640;
|
|
247
|
+
// MIN_REST minMinutes
|
|
248
|
+
export const SCHEDULE_RULE_MAX_REST_MINUTES = 1440;
|
|
249
|
+
|
|
106
250
|
/**
|
|
107
|
-
*
|
|
251
|
+
* Coverage findings
|
|
252
|
+
*/
|
|
253
|
+
|
|
254
|
+
// ELIGIBILITY violation codes (one person x one seat). Hard codes are always
|
|
255
|
+
// BLOCK; UNAVAILABLE takes its severity from the ELIGIBILITY rule config.
|
|
256
|
+
export const SCHEDULE_ELIGIBILITY_VIOLATION_CODE_ENUMS = [
|
|
257
|
+
'NOT_PERSON',
|
|
258
|
+
'RESOURCE_RETIRED',
|
|
259
|
+
'NOT_MEMBER',
|
|
260
|
+
'ROLE_MISSING',
|
|
261
|
+
'QUALIFICATION_MISSING',
|
|
262
|
+
'QUALIFICATION_EXPIRED',
|
|
263
|
+
'TIME_OFF',
|
|
264
|
+
'OVERLAP',
|
|
265
|
+
'UNAVAILABLE',
|
|
266
|
+
] as const;
|
|
267
|
+
|
|
268
|
+
// RATIO emits two findings: too few adults, and an age group over its maximum
|
|
269
|
+
// group size
|
|
270
|
+
export const SCHEDULE_RATIO_VIOLATION_CODE_ENUMS = [
|
|
271
|
+
'ADULTS',
|
|
272
|
+
'GROUP_SIZE',
|
|
273
|
+
] as const;
|
|
274
|
+
|
|
275
|
+
// NOTICE_PERIOD: a seat published (or about to be) inside the window, and a
|
|
276
|
+
// post-publish change inside the window
|
|
277
|
+
export const SCHEDULE_NOTICE_VIOLATION_CODE_ENUMS = [
|
|
278
|
+
'LATE_PUBLISH',
|
|
279
|
+
'LATE_CHANGE',
|
|
280
|
+
] as const;
|
|
281
|
+
|
|
282
|
+
// Picker / request reasons (one person x one seat), in presentation order
|
|
283
|
+
export const SCHEDULE_ELIGIBILITY_REASON_ENUMS = [
|
|
284
|
+
'NOT_PERSON',
|
|
285
|
+
'RESOURCE_RETIRED',
|
|
286
|
+
'NOT_MEMBER',
|
|
287
|
+
'SHIFT_CANCELED',
|
|
288
|
+
'SHIFT_ENDED',
|
|
289
|
+
'ALREADY_ASSIGNED',
|
|
290
|
+
'ROLE_MISSING',
|
|
291
|
+
'QUALIFICATION_MISSING',
|
|
292
|
+
'QUALIFICATION_EXPIRED',
|
|
293
|
+
'TIME_OFF',
|
|
294
|
+
'OVERLAP',
|
|
295
|
+
'UNAVAILABLE',
|
|
296
|
+
'MAX_HOURS',
|
|
297
|
+
'MIN_REST',
|
|
298
|
+
'MAX_CONSECUTIVE_DAYS',
|
|
299
|
+
'SHIFT_LENGTH',
|
|
300
|
+
'COVERAGE_IMPACT',
|
|
301
|
+
] as const;
|
|
302
|
+
|
|
303
|
+
// Any diagnostic means the evaluation is incomplete: the server keeps the
|
|
304
|
+
// previous ledger and refuses publish
|
|
305
|
+
export const SCHEDULE_COVERAGE_DIAGNOSTIC_CODE_ENUMS = [
|
|
306
|
+
'WINDOW_INVALID', // window empty or longer than SCHEDULE_COVERAGE_MAX_WINDOW_DAYS
|
|
307
|
+
'RATIO_NOT_CONFIGURED', // demand key with no ratio in the effective RATIO rule
|
|
308
|
+
'AGE_GROUP_UNKNOWN', // YOUNGEST mode: a demand key missing from the org's ageGroups
|
|
309
|
+
'OPERATING_HOURS_NOT_CONFIGURED', // an OPERATING_HOURS rule applies but the calendar has no/empty work calendar
|
|
310
|
+
'QUALIFICATION_EXPIRY_INVALID', // expiresAt unparsable in engine input (treated as expired; never "never expires")
|
|
311
|
+
'UNKNOWN_RESOURCE', // a seat/demand/time-off/availability/rule references a resource not in input
|
|
312
|
+
'UNKNOWN_ROLE', // a seat or rule references a role not in the role catalog
|
|
313
|
+
'RULE_CONFIG_INVALID', // rule row failed validateScheduleRuleConfig at evaluation time
|
|
314
|
+
'RULE_SUBJECT_KIND_MISMATCH', // rule.resourceId kind is not SCHEDULE_RULE_SUBJECT_BY_KIND[kind]
|
|
315
|
+
'VIOLATION_CAP', // pre-merge cap reached; output truncated
|
|
316
|
+
] as const;
|
|
317
|
+
|
|
318
|
+
export const SCHEDULE_COVERAGE_MAX_WINDOW_DAYS = 62;
|
|
319
|
+
|
|
320
|
+
// The longest coverage window as instants: SCHEDULE_COVERAGE_MAX_WINDOW_DAYS local days run one hour longer across a
|
|
321
|
+
// fall-back change
|
|
322
|
+
export const SCHEDULE_COVERAGE_MAX_WINDOW_MS =
|
|
323
|
+
SCHEDULE_COVERAGE_MAX_WINDOW_DAYS * 86_400_000 + 3_600_000;
|
|
324
|
+
|
|
325
|
+
export const SCHEDULE_COVERAGE_MAX_VIOLATIONS = 50_000;
|
|
326
|
+
|
|
327
|
+
// schedule_violations.message is VARCHAR(500)
|
|
328
|
+
export const SCHEDULE_VIOLATION_MESSAGE_MAX_LENGTH = 500;
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Requests
|
|
108
332
|
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
333
|
+
* CLAIM take an open seat
|
|
334
|
+
* DROP give up a seat; it stays theirs until approved
|
|
335
|
+
* CALL_OUT cannot work it (sick, emergency); policy may auto-approve
|
|
336
|
+
* RETIME keep the seat with different hours
|
|
337
|
+
* SWAP trade with a colleague; counterparty consent first, then a decision
|
|
112
338
|
*/
|
|
113
339
|
|
|
114
|
-
export const
|
|
115
|
-
'
|
|
116
|
-
'
|
|
117
|
-
'
|
|
118
|
-
'
|
|
340
|
+
export const SCHEDULE_REQUEST_KIND_ENUMS = [
|
|
341
|
+
'CLAIM',
|
|
342
|
+
'DROP',
|
|
343
|
+
'CALL_OUT',
|
|
344
|
+
'RETIME',
|
|
345
|
+
'SWAP',
|
|
119
346
|
] as const;
|
|
120
347
|
|
|
121
|
-
|
|
122
|
-
|
|
348
|
+
export const SCHEDULE_REQUEST_STATUS_ENUMS = [
|
|
349
|
+
'PENDING',
|
|
350
|
+
'ACCEPTED_BY_COUNTERPARTY',
|
|
351
|
+
'APPROVED',
|
|
352
|
+
'DECLINED',
|
|
353
|
+
'CANCELLED',
|
|
354
|
+
'EXPIRED',
|
|
355
|
+
] as const;
|
|
123
356
|
|
|
124
|
-
//
|
|
125
|
-
|
|
126
|
-
export const SCHEDULE_RECURRENCE_MAX_ITERATIONS = 20_000;
|
|
357
|
+
// Where a request came from
|
|
358
|
+
export const SCHEDULE_REQUEST_VIA_ENUMS = ['APP', 'SMS', 'AGENT'] as const;
|
|
127
359
|
|
|
128
|
-
|
|
129
|
-
|
|
360
|
+
export const SCHEDULE_TIME_OFF_STATUS_ENUMS = [
|
|
361
|
+
'PENDING',
|
|
362
|
+
'APPROVED',
|
|
363
|
+
'DECLINED',
|
|
364
|
+
'CANCELLED',
|
|
365
|
+
] as const;
|
|
130
366
|
|
|
131
367
|
/**
|
|
132
|
-
*
|
|
133
|
-
* rows, how far back a first pass may reach, and per-pass caps.
|
|
368
|
+
* Notifications (outbox rows plus one delivery row per account x channel)
|
|
134
369
|
*/
|
|
135
370
|
|
|
136
|
-
export const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
371
|
+
export const SCHEDULE_NOTIFICATION_STATUS_ENUMS = [
|
|
372
|
+
'PENDING',
|
|
373
|
+
'SENT',
|
|
374
|
+
'FAILED',
|
|
375
|
+
'DEAD',
|
|
376
|
+
] as const;
|
|
377
|
+
|
|
378
|
+
export const SCHEDULE_NOTIFICATION_EVENT_KIND_ENUMS = [
|
|
379
|
+
'SCHEDULE_PUBLISHED',
|
|
380
|
+
'SHIFTS_CHANGED',
|
|
381
|
+
'REQUEST_OPENED',
|
|
382
|
+
'REQUEST_DECIDED',
|
|
383
|
+
'CALL_OUT',
|
|
384
|
+
'OFFER_FILLED',
|
|
385
|
+
'OFFER_UNFILLED',
|
|
386
|
+
'TIME_OFF_REQUESTED',
|
|
387
|
+
'TIME_OFF_DECIDED',
|
|
388
|
+
'VIOLATION_RAISED',
|
|
389
|
+
'TASK_ASSIGNED',
|
|
390
|
+
'SCHEDULE_RUN_COMPLETE',
|
|
391
|
+
'MILESTONE_AT_RISK',
|
|
392
|
+
'RESOURCE_OVERALLOCATED',
|
|
393
|
+
'PROJECT_DIGEST',
|
|
394
|
+
] as const;
|
|
395
|
+
|
|
396
|
+
export const SCHEDULE_NOTIFY_CHANNEL_ENUMS = [
|
|
397
|
+
'IN_APP',
|
|
398
|
+
'EMAIL',
|
|
399
|
+
'SMS',
|
|
400
|
+
] as const;
|
|
401
|
+
|
|
402
|
+
export const SCHEDULE_NOTIFICATION_DELIVERY_STATUS_ENUMS = [
|
|
403
|
+
'QUEUED',
|
|
404
|
+
'SENT',
|
|
405
|
+
'FAILED',
|
|
406
|
+
'SKIPPED',
|
|
407
|
+
] as const;
|
|
408
|
+
|
|
409
|
+
// Why a delivery was SKIPPED instead of attempted (never counted as a
|
|
410
|
+
// failure). NOT_OPTED_IN / OPTED_OUT: the schedule SMS consent rule; ASKED: an
|
|
411
|
+
// ask about the same event is this person's text.
|
|
412
|
+
export const SCHEDULE_NOTIFICATION_SKIP_REASON_ENUMS = [
|
|
413
|
+
'NO_CONTACT',
|
|
414
|
+
'CHANNEL_OFF',
|
|
415
|
+
'NOT_VISIBLE',
|
|
416
|
+
'NOT_OPTED_IN',
|
|
417
|
+
'OPTED_OUT',
|
|
418
|
+
'ASKED',
|
|
419
|
+
] as const;
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Asks (one question to one person with a defined yes and no effect) and
|
|
423
|
+
* offers (outreach for one open published seat, sent as OFFER asks in waves)
|
|
424
|
+
*
|
|
425
|
+
* OFFER a worker: take this open seat? yes -> CLAIM (first yes wins)
|
|
426
|
+
* SWAP_CONSENT a worker: swap with a colleague? yes -> the swap goes on to a decision
|
|
427
|
+
* REQUEST_DECISION a manager: approve this request? yes -> approve, no -> decline
|
|
428
|
+
* TIME_OFF_DECISION a manager: approve this time off? yes -> approve, no -> decline
|
|
429
|
+
* PUBLISH_REVIEW a manager: publish the prepared period? yes -> publish
|
|
430
|
+
* SHIFTS_CONFIRM a worker: these are your shifts, OK? yes -> confirmed
|
|
431
|
+
* SMS_CONSENT a worker: get shift texts from this org? yes -> opted in
|
|
432
|
+
* PLAN_REVIEW a project manager: accept the plan? yes -> its activities are marked reviewed
|
|
433
|
+
* PROGRESS_CHECK a responsible person: how is work going? free text -> the agent records progress
|
|
434
|
+
*/
|
|
435
|
+
|
|
436
|
+
export const SCHEDULE_ASK_KIND_ENUMS = [
|
|
437
|
+
'OFFER',
|
|
438
|
+
'SWAP_CONSENT',
|
|
439
|
+
'REQUEST_DECISION',
|
|
440
|
+
'TIME_OFF_DECISION',
|
|
441
|
+
'PUBLISH_REVIEW',
|
|
442
|
+
'SHIFTS_CONFIRM',
|
|
443
|
+
'SMS_CONSENT',
|
|
444
|
+
'PLAN_REVIEW',
|
|
445
|
+
'PROGRESS_CHECK',
|
|
446
|
+
] as const;
|
|
447
|
+
|
|
448
|
+
export const SCHEDULE_ASK_STATUS_ENUMS = [
|
|
449
|
+
'PENDING',
|
|
450
|
+
'SENT',
|
|
451
|
+
'ANSWERED',
|
|
452
|
+
'EXPIRED',
|
|
453
|
+
'CANCELLED',
|
|
454
|
+
'SKIPPED',
|
|
455
|
+
] as const;
|
|
456
|
+
|
|
457
|
+
export const SCHEDULE_ASK_CHANNEL_ENUMS = ['SMS', 'IN_APP'] as const;
|
|
458
|
+
|
|
459
|
+
export const SCHEDULE_ASK_ANSWER_ENUMS = ['YES', 'NO'] as const;
|
|
460
|
+
|
|
461
|
+
// How an answer arrived: the deterministic SMS step, a web button, the agent
|
|
462
|
+
export const SCHEDULE_ASK_ANSWER_VIA_ENUMS = ['SMS', 'APP', 'AGENT'] as const;
|
|
463
|
+
|
|
464
|
+
// Why an ask was SKIPPED or CANCELLED
|
|
465
|
+
export const SCHEDULE_ASK_REASON_ENUMS = [
|
|
466
|
+
'NO_CONTACT',
|
|
467
|
+
'NOT_OPTED_IN',
|
|
468
|
+
'OPTED_OUT',
|
|
469
|
+
'CHANNEL_OFF',
|
|
470
|
+
'NO_ACCESS',
|
|
471
|
+
'BECAME_INELIGIBLE',
|
|
472
|
+
'ANSWERED_BY_OTHER',
|
|
473
|
+
'TOO_LATE',
|
|
474
|
+
'SUBJECT_CLOSED',
|
|
475
|
+
'SUPERSEDED',
|
|
476
|
+
] as const;
|
|
477
|
+
|
|
478
|
+
// UNFILLED: every ask closed with no taker and no live claim
|
|
479
|
+
export const SCHEDULE_OFFER_STATUS_ENUMS = [
|
|
480
|
+
'OPEN',
|
|
481
|
+
'FILLED',
|
|
482
|
+
'UNFILLED',
|
|
483
|
+
'EXPIRED',
|
|
484
|
+
'CANCELLED',
|
|
485
|
+
] as const;
|
|
486
|
+
|
|
487
|
+
export const SCHEDULE_OFFER_CREATED_VIA_ENUMS = [
|
|
488
|
+
'MANUAL',
|
|
489
|
+
'AGENT',
|
|
490
|
+
'CALL_OUT',
|
|
491
|
+
'DROP',
|
|
492
|
+
'SYSTEM',
|
|
493
|
+
] as const;
|
|
494
|
+
|
|
495
|
+
// schedule_resources."smsConsent": consent to schedule texts from this org
|
|
496
|
+
// (PERSON only). OPTED_IN allows schedule SMS to an unverified phone.
|
|
497
|
+
export const SCHEDULE_SMS_CONSENT_ENUMS = [
|
|
498
|
+
'NONE',
|
|
499
|
+
'ASKED',
|
|
500
|
+
'OPTED_IN',
|
|
501
|
+
'OPTED_OUT',
|
|
502
|
+
] as const;
|
|
503
|
+
|
|
504
|
+
// Top eligible candidates considered per offer
|
|
505
|
+
export const SCHEDULE_OFFER_MAX_ASKS = 20;
|
|
506
|
+
// A seat starting sooner than this ignores quiet hours
|
|
507
|
+
export const SCHEDULE_OFFER_URGENT_HOURS = 12;
|
|
508
|
+
export const SCHEDULE_OFFER_MESSAGE_MAX_LENGTH = 300;
|
|
509
|
+
// An offer's expiresAt must be at least this far ahead (and the seat's start)
|
|
510
|
+
export const SCHEDULE_OFFER_MIN_LEAD_MINUTES = 5;
|
|
511
|
+
// Offers a candidate declined within this many days lower their score
|
|
512
|
+
export const SCHEDULE_OFFER_DECLINE_LOOKBACK_DAYS = 14;
|
|
513
|
+
// Fairness and same-slot lookback (Phase 3 auto-fill reuses it)
|
|
514
|
+
export const SCHEDULE_CANDIDATE_HISTORY_DAYS = 28;
|
|
515
|
+
// Same slot = same weekday and role, local start within this many minutes
|
|
516
|
+
export const SCHEDULE_CANDIDATE_SLOT_TOLERANCE_MINUTES = 60;
|
|
517
|
+
|
|
518
|
+
// Candidate ranking points (utils/candidates.ts); every score is rounded to
|
|
519
|
+
// an integer
|
|
520
|
+
export const SCHEDULE_CANDIDATE_SCORE_POINTS = {
|
|
521
|
+
preferredTime: 20, // x the fraction of the seat inside PREFERRED windows
|
|
522
|
+
underTarget: 15, // the seat fits under targetWeeklyMinutes in its pay week (pro rata when it partly fits)
|
|
523
|
+
overTargetPerHour: -5, // per started hour over target after the seat
|
|
524
|
+
overTargetFloor: -30,
|
|
525
|
+
ruleWarning: { MAX_HOURS: -40, UNAVAILABLE: -30, OTHER: -20 }, // per WARN eligibility code
|
|
526
|
+
declinePerOffer: -10,
|
|
527
|
+
declineFloor: -30,
|
|
528
|
+
fairnessPerDay: 1, // per day since their last seat at this calendar
|
|
529
|
+
fairnessMax: 10, // also the value when none in the lookback
|
|
530
|
+
sameSlotPerShift: 5,
|
|
531
|
+
sameSlotMax: 20,
|
|
532
|
+
} as const;
|
|
533
|
+
|
|
534
|
+
// A consent ask expires after this many days (consent stays ASKED)
|
|
535
|
+
export const SCHEDULE_SMS_CONSENT_ASK_DAYS = 7;
|
|
536
|
+
// An unanswered publish review is re-sent once, this long before the period
|
|
537
|
+
export const SCHEDULE_PUBLISH_REVIEW_NUDGE_HOURS = 24;
|
|
538
|
+
// payload.line: one line for chat context and lists
|
|
539
|
+
export const SCHEDULE_ASK_LINE_MAX_LENGTH = 160;
|
|
540
|
+
// schedule_asks."replyText"
|
|
541
|
+
export const SCHEDULE_ASK_REPLY_TEXT_MAX_LENGTH = 500;
|
|
542
|
+
|
|
543
|
+
/**
|
|
544
|
+
* To-dos (schedule_tasks, Phase 4): light tasks scoped to one calendar or one
|
|
545
|
+
* project, optionally on a seat or an activity. Status: OPEN -> IN_PROGRESS
|
|
546
|
+
* -> DONE | CANCELED.
|
|
547
|
+
*/
|
|
548
|
+
|
|
549
|
+
export const SCHEDULE_TASK_STATUS_ENUMS = [
|
|
550
|
+
'OPEN',
|
|
551
|
+
'IN_PROGRESS',
|
|
552
|
+
'DONE',
|
|
553
|
+
'CANCELED',
|
|
554
|
+
] as const;
|
|
555
|
+
|
|
556
|
+
export const SCHEDULE_TASK_OPEN_STATUSES = ['OPEN', 'IN_PROGRESS'] as const;
|
|
557
|
+
|
|
558
|
+
export const SCHEDULE_TASK_CREATED_VIA_ENUMS = [
|
|
559
|
+
'MANUAL',
|
|
560
|
+
'AGENT',
|
|
561
|
+
'SMS',
|
|
562
|
+
'IMPORT',
|
|
563
|
+
] as const;
|
|
564
|
+
|
|
565
|
+
// Priority by its stored number (the index): 0 NONE ... 3 HIGH
|
|
566
|
+
export const SCHEDULE_TASK_PRIORITY_ENUMS = [
|
|
567
|
+
'NONE',
|
|
568
|
+
'LOW',
|
|
569
|
+
'MEDIUM',
|
|
570
|
+
'HIGH',
|
|
571
|
+
] as const;
|
|
572
|
+
|
|
573
|
+
export const SCHEDULE_TASK_TITLE_MAX_LENGTH = 255;
|
|
574
|
+
export const SCHEDULE_TASK_NOTE_MAX_LENGTH = 2000;
|
|
575
|
+
|
|
576
|
+
// Rows one to-do read returns
|
|
577
|
+
export const SCHEDULE_TASK_LIST_MAX = 200;
|
|
578
|
+
|
|
579
|
+
/**
|
|
580
|
+
* Calendar and organization settings (validated JSON, no DDL)
|
|
581
|
+
*/
|
|
582
|
+
|
|
583
|
+
// Non-managers see every seat (ALL), or only their own plus the open seats
|
|
584
|
+
// they are eligible for (OWN)
|
|
585
|
+
export const SCHEDULE_STAFF_VISIBILITY_ENUMS = ['ALL', 'OWN'] as const;
|
|
586
|
+
|
|
587
|
+
// settings.cycle.weeks: how far ahead one prepared period reaches
|
|
588
|
+
export const SCHEDULE_CYCLE_MAX_WEEKS = 2;
|
|
589
|
+
|
|
590
|
+
// settings.cycle.prepareDaysBefore: at least one day (a period due on its own
|
|
591
|
+
// first day stops being the next period at that day's midnight, and its
|
|
592
|
+
// review would expire before it is asked), at most four weeks
|
|
593
|
+
export const SCHEDULE_CYCLE_MIN_PREPARE_DAYS_BEFORE = 1;
|
|
594
|
+
export const SCHEDULE_CYCLE_MAX_PREPARE_DAYS_BEFORE = 28;
|
|
595
|
+
|
|
596
|
+
// Auto-fill: recent-slot and fairness history, in periods of the cycle
|
|
597
|
+
export const SCHEDULE_AUTOFILL_HISTORY_PERIODS = 4;
|
|
598
|
+
export const SCHEDULE_ROSTER_UNFILLED_REASON_ENUMS = [
|
|
599
|
+
'NO_CANDIDATES',
|
|
600
|
+
'NONE_ELIGIBLE',
|
|
601
|
+
'WARNINGS_ONLY',
|
|
602
|
+
] as const;
|
|
603
|
+
|
|
604
|
+
// Diff baseline: published weeks looked at before the period
|
|
605
|
+
export const SCHEDULE_PERIOD_BASELINE_LOOKBACK_WEEKS = 16;
|
|
606
|
+
|
|
607
|
+
// Instructions pass edits (the model's verbs)
|
|
608
|
+
export const SCHEDULE_PREPARE_EDIT_KIND_ENUMS = [
|
|
609
|
+
'assign',
|
|
610
|
+
'unassign',
|
|
611
|
+
'retime',
|
|
612
|
+
'create',
|
|
613
|
+
'delete',
|
|
614
|
+
] as const;
|
|
615
|
+
|
|
616
|
+
// settings.instructions: standing instructions for the preparation pass
|
|
617
|
+
export const SCHEDULE_INSTRUCTIONS_MAX_COUNT = 20;
|
|
618
|
+
export const SCHEDULE_INSTRUCTION_MAX_LENGTH = 300;
|
|
619
|
+
|
|
620
|
+
// organizations.settings.schedule.ageGroups
|
|
621
|
+
export const SCHEDULE_AGE_GROUPS_MAX_COUNT = 20;
|
|
622
|
+
|
|
623
|
+
// Every key of schedule_calendars.settings with its default. Readers resolve
|
|
624
|
+
// missing keys from here; the calendar write path validates and stores.
|
|
625
|
+
// The defaults run the schedule by itself (the system is chat-first and
|
|
626
|
+
// autonomous): the next period is prepared before it starts (nothing is
|
|
627
|
+
// prepared until a standing schedule exists, and nothing is ever published
|
|
628
|
+
// without a manager); a call-out opens the seat and offers it at once; the
|
|
629
|
+
// first eligible yes to an offer (or a claim of an open seat) takes it; drops
|
|
630
|
+
// and swaps still go to a manager; notices go by SMS (consent-gated) and in-app.
|
|
631
|
+
export const SCHEDULE_CALENDAR_DEFAULT_SETTINGS: Readonly<ScheduleCalendarSettingsObj> =
|
|
632
|
+
{
|
|
633
|
+
cycle: {
|
|
634
|
+
enabled: true,
|
|
635
|
+
weeks: 1,
|
|
636
|
+
prepareDaysBefore: 3,
|
|
637
|
+
prepareAtHour: 9,
|
|
638
|
+
},
|
|
639
|
+
instructions: [],
|
|
640
|
+
requestPolicy: {
|
|
641
|
+
autoApproveClaims: true,
|
|
642
|
+
autoApproveDrops: false,
|
|
643
|
+
autoApproveCallOuts: true,
|
|
644
|
+
autoApproveSwaps: false,
|
|
645
|
+
minNoticeHours: 24,
|
|
646
|
+
requestExpiryHours: 72,
|
|
647
|
+
},
|
|
648
|
+
offerDefaults: {
|
|
649
|
+
waveSize: 3,
|
|
650
|
+
responseWindowMinutes: 30,
|
|
651
|
+
autoApprove: true,
|
|
652
|
+
autoOfferOnOpen: true,
|
|
653
|
+
quietHours: { start: '22:00', end: '08:00' },
|
|
654
|
+
},
|
|
655
|
+
decisionMakers: [],
|
|
656
|
+
staffVisibility: 'ALL',
|
|
657
|
+
notify: { defaultChannels: ['SMS', 'IN_APP'] },
|
|
658
|
+
};
|
|
659
|
+
|
|
660
|
+
// organizations.settings.schedule defaults (payWeekStart 1 = Monday)
|
|
661
|
+
export const SCHEDULE_ORGANIZATION_DEFAULT_SETTINGS: Readonly<ScheduleOrganizationSettingsObj> =
|
|
662
|
+
{
|
|
663
|
+
ageGroups: [],
|
|
664
|
+
payWeekStart: 1,
|
|
665
|
+
};
|
|
666
|
+
|
|
667
|
+
/**
|
|
668
|
+
* Text previews (utils/scheduleText.ts)
|
|
669
|
+
*/
|
|
670
|
+
|
|
671
|
+
// A period summary targets this many SMS segments; it lists exceptions, not
|
|
672
|
+
// every shift
|
|
673
|
+
export const SCHEDULE_TEXT_SUMMARY_MAX_SEGMENTS = 3;
|
|
141
674
|
|
|
142
675
|
/**
|
|
143
676
|
* Query limits
|
|
@@ -146,14 +679,11 @@ export const SCHEDULE_MATERIALIZATION_TOP_UP_MAX_PASSES = 5;
|
|
|
146
679
|
// Longest calendar window one query may request; refused rather than clipped
|
|
147
680
|
export const SCHEDULE_QUERY_MAX_WINDOW_DAYS = 400;
|
|
148
681
|
|
|
149
|
-
// Most
|
|
150
|
-
export const
|
|
151
|
-
|
|
152
|
-
// Longest one occurrence may span (31 days)
|
|
153
|
-
export const SCHEDULE_OCCURRENCE_MAX_DURATION_MINUTES = 31 * 24 * 60;
|
|
682
|
+
// Most seats one window read may return
|
|
683
|
+
export const SCHEDULE_QUERY_MAX_SHIFTS = 2000;
|
|
154
684
|
|
|
155
685
|
/**
|
|
156
|
-
* Projects
|
|
686
|
+
* Projects
|
|
157
687
|
*
|
|
158
688
|
* Everything below is the critical-path model: a project holds a work
|
|
159
689
|
* breakdown structure, activities with durations and logic, and the engine
|
|
@@ -193,10 +723,6 @@ export const SCHEDULE_ACTIVITY_STATUS_ENUMS = [
|
|
|
193
723
|
'COMPLETE',
|
|
194
724
|
] as const;
|
|
195
725
|
|
|
196
|
-
// Which two of Duration, Units and Units/Time stay fixed when the third changes
|
|
197
|
-
|
|
198
|
-
// How percent complete is measured
|
|
199
|
-
|
|
200
726
|
// Relationship types between a predecessor and a successor
|
|
201
727
|
export const SCHEDULE_RELATIONSHIP_TYPE_ENUMS = [
|
|
202
728
|
'FS',
|
|
@@ -222,6 +748,13 @@ export const SCHEDULE_CONSTRAINT_TYPE_ENUMS = [
|
|
|
222
748
|
'AS_LATE_AS_POSSIBLE',
|
|
223
749
|
] as const;
|
|
224
750
|
|
|
751
|
+
export const SCHEDULE_SECONDARY_CONSTRAINT_TYPE_ENUMS = [
|
|
752
|
+
'START_ON_OR_AFTER',
|
|
753
|
+
'START_ON_OR_BEFORE',
|
|
754
|
+
'FINISH_ON_OR_AFTER',
|
|
755
|
+
'FINISH_ON_OR_BEFORE',
|
|
756
|
+
] as const;
|
|
757
|
+
|
|
225
758
|
// What an in-progress activity's remaining work waits for
|
|
226
759
|
// RETAINED remaining work still honours unfinished predecessors
|
|
227
760
|
// OVERRIDE remaining work resumes at the data date regardless
|
|
@@ -235,7 +768,14 @@ export const SCHEDULE_LAG_CALENDAR_ENUMS = [
|
|
|
235
768
|
'CONTINUOUS',
|
|
236
769
|
] as const;
|
|
237
770
|
|
|
238
|
-
|
|
771
|
+
export const SCHEDULE_PROJECT_RUN_KIND_ENUMS = ['CPM', 'LEVEL'] as const;
|
|
772
|
+
|
|
773
|
+
export const SCHEDULE_PROJECT_RUN_TRIGGER_ENUMS = [
|
|
774
|
+
'MANUAL',
|
|
775
|
+
'AUTO',
|
|
776
|
+
'IMPORT',
|
|
777
|
+
'AGENT',
|
|
778
|
+
] as const;
|
|
239
779
|
|
|
240
780
|
export const SCHEDULE_PROJECT_RUN_STATUS_ENUMS = [
|
|
241
781
|
'QUEUED',
|
|
@@ -257,7 +797,7 @@ export const SCHEDULE_DIAGNOSTIC_CODE_ENUMS = [
|
|
|
257
797
|
'EMPTY_CALENDAR',
|
|
258
798
|
'UNKNOWN_ACTIVITY',
|
|
259
799
|
'OPEN_START',
|
|
260
|
-
'OPEN_FINISH',
|
|
800
|
+
'OPEN_FINISH', // WARN, unstarted work with no successor, or (dangling) only SS/SF successors; the latest true open finish is exempt
|
|
261
801
|
'NEGATIVE_FLOAT',
|
|
262
802
|
'CONSTRAINT_OVERRIDES_LOGIC',
|
|
263
803
|
'OUT_OF_SEQUENCE',
|
|
@@ -271,148 +811,39 @@ export const SCHEDULE_DIAGNOSTIC_CODE_ENUMS = [
|
|
|
271
811
|
'LEVELING_DELAYED', // INFO, per delayed activity (minutes, resourceId)
|
|
272
812
|
'LEVELING_EXCEEDED_FLOAT', // WARN, levelWithinFloat refused every start whose finish ≤ LF; placed at its bound start, overallocation kept
|
|
273
813
|
'LEVELING_EXCEEDED_HORIZON', // WARN, no feasible start inside the horizon; placed at its bound start
|
|
814
|
+
'LEVELING_PAST_PINNED_SUCCESSOR', // WARN, leveling moved an activity past a successor pinned by progress or a MANDATORY_* date (activityId = moved predecessor, relatedActivityId = pinned successor, minutes past the pinned date)
|
|
274
815
|
] as const;
|
|
275
816
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
export const SCHEDULE_PROJECT_MAX_ACTIVITIES = 20_000;
|
|
281
|
-
export const SCHEDULE_PROJECT_MAX_RELATIONSHIPS = 100_000;
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* Where an activity came from; the provenance the RFP extraction pipeline
|
|
285
|
-
* writes so a planner can review machine-proposed scope
|
|
286
|
-
*/
|
|
287
|
-
|
|
288
|
-
export const SCHEDULE_SOURCE_KIND_ENUMS = [
|
|
289
|
-
'MANUAL',
|
|
290
|
-
'IMPORT',
|
|
291
|
-
'EXTRACTION',
|
|
292
|
-
'AGENT',
|
|
293
|
-
] as const;
|
|
294
|
-
|
|
295
|
-
export const SCHEDULE_SOURCE_REVIEW_STATUS_ENUMS = [
|
|
296
|
-
'UNREVIEWED',
|
|
297
|
-
'ACCEPTED',
|
|
298
|
-
'REJECTED',
|
|
817
|
+
export const SCHEDULE_DIAGNOSTIC_SEVERITY_ENUMS = [
|
|
818
|
+
'ERROR',
|
|
819
|
+
'WARN',
|
|
820
|
+
'INFO',
|
|
299
821
|
] as const;
|
|
300
822
|
|
|
301
|
-
|
|
302
|
-
* Column widths shared with the DDL
|
|
303
|
-
*/
|
|
304
|
-
|
|
305
|
-
export const SCHEDULE_TITLE_MAX_LENGTH = 255;
|
|
306
|
-
export const SCHEDULE_NAME_MAX_LENGTH = 150;
|
|
307
|
-
export const SCHEDULE_CODE_MAX_LENGTH = 40;
|
|
308
|
-
export const SCHEDULE_KEY_MAX_LENGTH = 60;
|
|
309
|
-
export const SCHEDULE_SLOT_LABEL_MAX_LENGTH = 100;
|
|
310
|
-
|
|
311
|
-
/**
|
|
312
|
-
* Doc access: calendars and projects use the same access_grants rows Sheets
|
|
313
|
-
* and Notes use, keyed by these entity types
|
|
314
|
-
*/
|
|
823
|
+
export const SCHEDULE_DIAGNOSTIC_CAP_PER_CODE = 200;
|
|
315
824
|
|
|
316
|
-
export const
|
|
317
|
-
export const SCHEDULE_PROJECT_ACCESS_ENTITY_TYPE = 'SCHEDULE_PROJECT';
|
|
825
|
+
export const SCHEDULE_DIAGNOSTIC_MAX_ACTIVITY_IDS = 50;
|
|
318
826
|
|
|
319
|
-
|
|
320
|
-
export const SCHEDULE_ASSIGNMENT_VIA_ENUMS = [
|
|
321
|
-
'MANUAL',
|
|
322
|
-
'REQUEST',
|
|
323
|
-
'IMPORT',
|
|
324
|
-
'AGENT',
|
|
325
|
-
] as const;
|
|
326
|
-
export const SCHEDULE_ASSIGNMENT_RELEASE_REASON_ENUMS = [
|
|
327
|
-
'MANUAL',
|
|
328
|
-
'REQUEST',
|
|
329
|
-
'OCCURRENCE_CANCELED',
|
|
330
|
-
'SERIES_CHANGE',
|
|
331
|
-
'RESOURCE_RETIRED',
|
|
332
|
-
'AGENT',
|
|
333
|
-
] as const;
|
|
334
|
-
export const SCHEDULE_REQUEST_KIND_ENUMS = ['CLAIM', 'DROP', 'SWAP'] as const;
|
|
335
|
-
export const SCHEDULE_REQUEST_STATUS_ENUMS = [
|
|
336
|
-
'PENDING',
|
|
337
|
-
'ACCEPTED_BY_COUNTERPARTY',
|
|
338
|
-
'APPROVED',
|
|
339
|
-
'DECLINED',
|
|
340
|
-
'CANCELLED',
|
|
341
|
-
'EXPIRED',
|
|
342
|
-
] as const;
|
|
343
|
-
export const SCHEDULE_PROJECT_RUN_KIND_ENUMS = ['CPM', 'LEVEL'] as const;
|
|
344
|
-
export const SCHEDULE_PROJECT_RUN_TRIGGER_ENUMS = [
|
|
345
|
-
'MANUAL',
|
|
346
|
-
'AUTO',
|
|
347
|
-
'IMPORT',
|
|
348
|
-
'AGENT',
|
|
349
|
-
] as const;
|
|
350
|
-
export const SCHEDULE_NOTIFICATION_STATUS_ENUMS = [
|
|
351
|
-
'PENDING',
|
|
352
|
-
'SENT',
|
|
353
|
-
'FAILED',
|
|
354
|
-
'DEAD',
|
|
355
|
-
] as const;
|
|
356
|
-
export const SCHEDULE_NOTIFICATION_EVENT_KIND_ENUMS = [
|
|
357
|
-
'SCHEDULE_PUBLISHED',
|
|
358
|
-
'ASSIGNMENT_CHANGED',
|
|
359
|
-
'OCCURRENCE_CHANGED',
|
|
360
|
-
'REQUEST_OPENED',
|
|
361
|
-
'REQUEST_DECIDED',
|
|
362
|
-
'TIME_OFF_DECIDED',
|
|
363
|
-
'VIOLATION_RAISED',
|
|
364
|
-
'SCHEDULE_RUN_COMPLETE',
|
|
365
|
-
'MILESTONE_AT_RISK',
|
|
366
|
-
'RESOURCE_OVERALLOCATED',
|
|
367
|
-
] as const;
|
|
368
|
-
export const SCHEDULE_SECONDARY_CONSTRAINT_TYPE_ENUMS = [
|
|
369
|
-
'START_ON_OR_AFTER',
|
|
370
|
-
'START_ON_OR_BEFORE',
|
|
371
|
-
'FINISH_ON_OR_AFTER',
|
|
372
|
-
'FINISH_ON_OR_BEFORE',
|
|
373
|
-
] as const;
|
|
827
|
+
export const SCHEDULE_CYCLE_MESSAGE_MAX_HOPS = 20;
|
|
374
828
|
|
|
375
|
-
|
|
376
|
-
export const SCHEDULE_DEFAULTS_BY_OPERATION = {
|
|
377
|
-
CONSTRUCTION: {
|
|
378
|
-
defaultSurface: 'PROJECT',
|
|
379
|
-
defaultView: 'GANTT',
|
|
380
|
-
vocabulary: 'PROJECT',
|
|
381
|
-
},
|
|
382
|
-
UTILITIES: {
|
|
383
|
-
defaultSurface: 'PROJECT',
|
|
384
|
-
defaultView: 'GANTT',
|
|
385
|
-
vocabulary: 'PROJECT',
|
|
386
|
-
},
|
|
387
|
-
CHILDCARE: {
|
|
388
|
-
defaultSurface: 'COVERAGE',
|
|
389
|
-
defaultView: 'WEEK',
|
|
390
|
-
vocabulary: 'STAFFING',
|
|
391
|
-
},
|
|
392
|
-
RESTAURANT: {
|
|
393
|
-
defaultSurface: 'COVERAGE',
|
|
394
|
-
defaultView: 'WEEK',
|
|
395
|
-
vocabulary: 'STAFFING',
|
|
396
|
-
},
|
|
397
|
-
} as const;
|
|
829
|
+
export const SCHEDULE_WORK_TIME_MAX_SPAN_DAYS = 14_610;
|
|
398
830
|
|
|
399
|
-
|
|
400
|
-
export const
|
|
401
|
-
requests: {
|
|
402
|
-
autoApproveClaims: false,
|
|
403
|
-
autoApproveDrops: false,
|
|
404
|
-
requireCounterpartyConsent: true,
|
|
405
|
-
minNoticeHours: 24,
|
|
406
|
-
requestExpiryHours: 72,
|
|
407
|
-
},
|
|
408
|
-
notify: { channels: ['IN_APP'] },
|
|
409
|
-
} as const;
|
|
831
|
+
// Total float at or below this many minutes marks an activity critical
|
|
832
|
+
export const SCHEDULE_CRITICAL_FLOAT_THRESHOLD_MINUTES = 0;
|
|
410
833
|
|
|
411
834
|
export const SCHEDULE_CRITICALITY_MODE_ENUMS = [
|
|
412
835
|
'FLOAT',
|
|
413
836
|
'LONGEST_PATH',
|
|
414
837
|
] as const;
|
|
415
838
|
|
|
839
|
+
// Guards against a network no browser or worker could render
|
|
840
|
+
export const SCHEDULE_PROJECT_MAX_ACTIVITIES = 20_000;
|
|
841
|
+
export const SCHEDULE_PROJECT_MAX_RELATIONSHIPS = 100_000;
|
|
842
|
+
|
|
843
|
+
/**
|
|
844
|
+
* Resource leveling
|
|
845
|
+
*/
|
|
846
|
+
|
|
416
847
|
export const SCHEDULE_LEVELING_PRIORITY_RULE_ENUMS = [
|
|
417
848
|
'TOTAL_FLOAT',
|
|
418
849
|
'LATE_START',
|
|
@@ -443,107 +874,80 @@ export const SCHEDULE_LEVELING_MAX_HORIZON_DAYS = 3660;
|
|
|
443
874
|
|
|
444
875
|
export const SCHEDULE_LEVELING_LEDGER_GUARD_DAYS = 366;
|
|
445
876
|
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
export const SCHEDULE_CYCLE_MESSAGE_MAX_HOPS = 20;
|
|
451
|
-
|
|
452
|
-
export const SCHEDULE_WORK_TIME_MAX_SPAN_DAYS = 14_610;
|
|
877
|
+
/**
|
|
878
|
+
* Where an activity came from; the provenance the RFP extraction pipeline
|
|
879
|
+
* writes so a planner can review machine-proposed scope
|
|
880
|
+
*/
|
|
453
881
|
|
|
454
|
-
export const
|
|
455
|
-
'
|
|
456
|
-
'
|
|
457
|
-
'
|
|
882
|
+
export const SCHEDULE_SOURCE_KIND_ENUMS = [
|
|
883
|
+
'MANUAL',
|
|
884
|
+
'IMPORT',
|
|
885
|
+
'EXTRACTION',
|
|
886
|
+
'AGENT',
|
|
458
887
|
] as const;
|
|
459
888
|
|
|
460
|
-
export const
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
OPERATING_HOURS: 'ROOM',
|
|
465
|
-
ELIGIBILITY: 'PERSON',
|
|
466
|
-
ACTOR_WINDOW_AGGREGATE: 'PERSON',
|
|
467
|
-
} as const satisfies Record<ScheduleRuleKindEnum, 'ROOM' | 'PERSON'>;
|
|
468
|
-
|
|
469
|
-
export const SCHEDULE_IMPLICIT_RULE_KINDS = [
|
|
470
|
-
'REQUIRED_COUNT',
|
|
471
|
-
'ROOM_CAPACITY',
|
|
472
|
-
'ELIGIBILITY',
|
|
889
|
+
export const SCHEDULE_SOURCE_REVIEW_STATUS_ENUMS = [
|
|
890
|
+
'UNREVIEWED',
|
|
891
|
+
'ACCEPTED',
|
|
892
|
+
'REJECTED',
|
|
473
893
|
] as const;
|
|
474
894
|
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
'PREDICATE_MISMATCH',
|
|
480
|
-
'QUALIFICATION_EXPIRED',
|
|
481
|
-
'TIME_OFF',
|
|
482
|
-
'OVERLAP',
|
|
483
|
-
] as const;
|
|
895
|
+
/**
|
|
896
|
+
* Projects by chat (Phase 5): schedule_projects.settings (progress check-ins
|
|
897
|
+
* and the weekly digest), plan reviews and check-in asks
|
|
898
|
+
*/
|
|
484
899
|
|
|
485
|
-
export const
|
|
486
|
-
'
|
|
487
|
-
'
|
|
900
|
+
export const SCHEDULE_PROJECT_CHECK_CADENCE_ENUMS = [
|
|
901
|
+
'DAILY',
|
|
902
|
+
'WEEKLY',
|
|
488
903
|
] as const;
|
|
489
904
|
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
'NOT_LABOR',
|
|
493
|
-
'RESOURCE_RETIRED',
|
|
494
|
-
'OCCURRENCE_NOT_SHIFT',
|
|
495
|
-
'OCCURRENCE_ENDED',
|
|
496
|
-
'ALREADY_ASSIGNED',
|
|
497
|
-
'SLOT_UNKNOWN',
|
|
498
|
-
'SLOT_FULL',
|
|
499
|
-
'NO_MATCHING_SLOT',
|
|
500
|
-
'PREDICATE_MISMATCH',
|
|
501
|
-
'QUALIFICATION_EXPIRED',
|
|
502
|
-
'QUALIFICATION_EXPIRES_DURING_SHIFT',
|
|
503
|
-
'TIME_OFF',
|
|
504
|
-
'OVERLAP',
|
|
505
|
-
'WINDOW_HOURS_EXCEEDED',
|
|
506
|
-
'MIN_REST',
|
|
507
|
-
] as const;
|
|
905
|
+
// settings.progressCheck.weekday when WEEKLY and none is given (1 = Monday)
|
|
906
|
+
export const SCHEDULE_PROGRESS_CHECK_DEFAULT_WEEKDAY = 1;
|
|
508
907
|
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
'RULE_CONFIG_INVALID', // rule row failed validateScheduleRuleConfig at evaluation time
|
|
516
|
-
'RULE_SUBJECT_KIND_MISMATCH', // rule.resourceId kind ≠ SCHEDULE_RULE_SUBJECT_BY_KIND[kind]
|
|
517
|
-
'VIOLATION_CAP', // pre-merge cap reached; output truncated
|
|
518
|
-
] as const;
|
|
908
|
+
// settings.digest keys that are absent read as these
|
|
909
|
+
export const SCHEDULE_PROJECT_DIGEST_DEFAULTS = {
|
|
910
|
+
enabled: true,
|
|
911
|
+
weekday: 1,
|
|
912
|
+
atHour: 7,
|
|
913
|
+
} as const;
|
|
519
914
|
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
'APPROVED',
|
|
523
|
-
'DECLINED',
|
|
524
|
-
'CANCELLED',
|
|
525
|
-
] as const;
|
|
915
|
+
// Activities listed in one check-in, numbered
|
|
916
|
+
export const SCHEDULE_PROGRESS_CHECK_MAX_ITEMS = 8;
|
|
526
917
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
'EMAIL',
|
|
530
|
-
'SMS',
|
|
531
|
-
] as const;
|
|
918
|
+
// A plan review ask expires after this many days
|
|
919
|
+
export const SCHEDULE_PLAN_REVIEW_ASK_DAYS = 7;
|
|
532
920
|
|
|
533
|
-
|
|
921
|
+
// A proposed activity with a source confidence below this is listed as unsure
|
|
922
|
+
export const SCHEDULE_PLAN_LOW_CONFIDENCE = 0.6;
|
|
534
923
|
|
|
535
|
-
|
|
924
|
+
// The digest lists activities starting within this many days of its date
|
|
925
|
+
export const SCHEDULE_PROJECT_DIGEST_LOOKAHEAD_DAYS = 7;
|
|
536
926
|
|
|
537
|
-
|
|
927
|
+
/**
|
|
928
|
+
* Column widths and list caps shared with the DDL and validators
|
|
929
|
+
*/
|
|
538
930
|
|
|
539
|
-
export const
|
|
931
|
+
export const SCHEDULE_TITLE_MAX_LENGTH = 255;
|
|
932
|
+
export const SCHEDULE_NAME_MAX_LENGTH = 150;
|
|
933
|
+
export const SCHEDULE_CODE_MAX_LENGTH = 40;
|
|
934
|
+
export const SCHEDULE_KEY_MAX_LENGTH = 60;
|
|
935
|
+
// schedule_shifts.label, schedule_template_items.label, schedule_roles.name
|
|
936
|
+
export const SCHEDULE_LABEL_MAX_LENGTH = 100;
|
|
937
|
+
// schedule_shifts.note
|
|
938
|
+
export const SCHEDULE_NOTE_MAX_LENGTH = 1000;
|
|
939
|
+
// schedule_requests.reason / decisionNote
|
|
940
|
+
export const SCHEDULE_REASON_MAX_LENGTH = 500;
|
|
540
941
|
|
|
942
|
+
export const SCHEDULE_RESOURCE_MAX_QUALIFICATIONS = 50;
|
|
943
|
+
// Most roles one PERSON may hold (schedule_resource_roles rows)
|
|
541
944
|
export const SCHEDULE_RESOURCE_MAX_ROLES = 20;
|
|
542
|
-
|
|
543
945
|
export const SCHEDULE_RESOURCE_MAX_TAGS = 50;
|
|
544
946
|
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
947
|
+
/**
|
|
948
|
+
* Doc access: calendars and projects use the same access_grants rows Sheets
|
|
949
|
+
* and Notes use, keyed by these entity types
|
|
950
|
+
*/
|
|
548
951
|
|
|
549
|
-
export const
|
|
952
|
+
export const SCHEDULE_CALENDAR_ACCESS_ENTITY_TYPE = 'SCHEDULE_CALENDAR';
|
|
953
|
+
export const SCHEDULE_PROJECT_ACCESS_ENTITY_TYPE = 'SCHEDULE_PROJECT';
|