@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
package/src/utils/ids.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Engine ids are strings: decimal database ids on the server, or any stable
|
|
3
|
+
* string in a browser preview or a test. This module orders them the same
|
|
4
|
+
* way everywhere, so every engine's output is deterministic.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const FILE_CONSTANTS = {
|
|
8
|
+
decimalId: /^\d+$/,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/*
|
|
12
|
+
* Compare two ids: numerically when both are decimal ids, otherwise by code
|
|
13
|
+
* unit. A decimal id and a non-decimal id compare by code unit as well.
|
|
14
|
+
*/
|
|
15
|
+
export function compareScheduleIds(a: string, b: string): number {
|
|
16
|
+
if (FILE_CONSTANTS.decimalId.test(a) && FILE_CONSTANTS.decimalId.test(b)) {
|
|
17
|
+
const left = BigInt(a);
|
|
18
|
+
const right = BigInt(b);
|
|
19
|
+
if (left !== right) return left < right ? -1 : 1;
|
|
20
|
+
}
|
|
21
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/*
|
|
25
|
+
* Validate a list of ids (rule roleIdsAny, decision makers): every entry a
|
|
26
|
+
* non-empty trimmed string of at most 60 characters, or a non-negative safe
|
|
27
|
+
* integer, and at most `limit` entries. Returns the deduplicated string list
|
|
28
|
+
* in compareScheduleIds order, or null when any entry is invalid.
|
|
29
|
+
*/
|
|
30
|
+
export function normalizeScheduleIdList(
|
|
31
|
+
value: unknown,
|
|
32
|
+
limit: number,
|
|
33
|
+
): string[] | null {
|
|
34
|
+
if (!Array.isArray(value) || value.length > limit) return null;
|
|
35
|
+
const ids: string[] = [];
|
|
36
|
+
for (const item of value) {
|
|
37
|
+
const id =
|
|
38
|
+
typeof item === 'number' && Number.isSafeInteger(item) && item >= 0
|
|
39
|
+
? String(item)
|
|
40
|
+
: typeof item === 'string'
|
|
41
|
+
? item.trim()
|
|
42
|
+
: '';
|
|
43
|
+
if (!id || id.length > 60) return null;
|
|
44
|
+
ids.push(id);
|
|
45
|
+
}
|
|
46
|
+
return [...new Set(ids)].sort(compareScheduleIds);
|
|
47
|
+
}
|