@jsb188/schedule 1.1.2
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/package.json +62 -0
- package/src/constants/schedule.ts +549 -0
- package/src/css.d.ts +7 -0
- package/src/libs/gantt-geometry.ts +771 -0
- package/src/libs/gantt-histogram.ts +124 -0
- package/src/libs/gantt-keyboard.ts +113 -0
- package/src/libs/gantt-state.ts +57 -0
- package/src/libs/gantt-url.ts +63 -0
- package/src/modules/Gantt.helpers.ts +119 -0
- package/src/modules/Gantt.tsx +584 -0
- package/src/types/schedule.d.ts +1149 -0
- package/src/ui/ActivityFormUI.tsx +133 -0
- package/src/ui/GanttEditorsUI.tsx +102 -0
- package/src/ui/GanttHistogramUI.tsx +236 -0
- package/src/ui/GanttUI.tsx +792 -0
- package/src/ui/ProjectFormUI.tsx +250 -0
- package/src/ui/ProjectMobileListUI.tsx +80 -0
- package/src/ui/ProjectToolbarUI.tsx +54 -0
- package/src/ui/RelationshipListUI.tsx +176 -0
- package/src/ui/ScheduleRunUI.tsx +173 -0
- package/src/ui/ScheduleSettingsUI.tsx +420 -0
- package/src/utils/coverage.helpers.ts +679 -0
- package/src/utils/coverage.ts +630 -0
- package/src/utils/cpm.helpers.ts +674 -0
- package/src/utils/cpm.ts +907 -0
- package/src/utils/cpmLeveling.helpers.ts +564 -0
- package/src/utils/cpmLeveling.ts +367 -0
- package/src/utils/defaults.ts +8 -0
- package/src/utils/eligibility.ts +457 -0
- package/src/utils/planCsv.ts +344 -0
- package/src/utils/predecessorText.ts +96 -0
- package/src/utils/recurrence.ts +616 -0
- package/src/utils/request.ts +153 -0
- package/src/utils/resource.ts +182 -0
- package/src/utils/rule.ts +216 -0
- package/src/utils/run.ts +43 -0
- package/src/utils/series.ts +161 -0
- package/src/utils/slot.ts +208 -0
- package/src/utils/workTime.ts +1382 -0
- package/tests/coverage.fixtures.ts +111 -0
- package/tests/coverage.test.ts +503 -0
- package/tests/cpm.bench.test.ts +154 -0
- package/tests/cpm.test.ts +354 -0
- package/tests/cpmCorrectness.test.ts +327 -0
- package/tests/cpmLeveling.test.ts +471 -0
- package/tests/eligibility.test.ts +320 -0
- package/tests/gantt-geometry.test.ts +367 -0
- package/tests/gantt-histogram.test.ts +78 -0
- package/tests/gantt-keyboard.test.ts +69 -0
- package/tests/helpers/cpmFixtures.ts +101 -0
- package/tests/projectInputs.test.ts +165 -0
- package/tests/recurrence.test.ts +68 -0
- package/tests/request.test.ts +99 -0
- package/tests/resource.test.ts +95 -0
- package/tests/rule.test.ts +98 -0
- package/tests/series.test.ts +120 -0
- package/tests/workTime.test.ts +1007 -0
- package/tests/workTimeContracts.test.ts +111 -0
- package/tsconfig.json +13 -0
- package/vitest.config.ts +8 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import {
|
|
3
|
+
addWorkingMinutes,
|
|
4
|
+
buildWorkCalendarTable,
|
|
5
|
+
getCumulativeMinutesAt,
|
|
6
|
+
getDateKeyForDayIndex,
|
|
7
|
+
getDayIndexAt,
|
|
8
|
+
getDayIndexForDateKey,
|
|
9
|
+
getStandardWorkCalendarDef,
|
|
10
|
+
getWorkCalendarTable,
|
|
11
|
+
getWorkingIntervalsInRange,
|
|
12
|
+
workingMinutesBetween,
|
|
13
|
+
WorkTimeEmptyCalendarError,
|
|
14
|
+
WorkTimeInvalidZoneError,
|
|
15
|
+
WorkTimeRangeError,
|
|
16
|
+
} from '../src/utils/workTime.ts';
|
|
17
|
+
|
|
18
|
+
describe('working-time contracts', () => {
|
|
19
|
+
it('computes exact forty-year working spans and throws a typed range error beyond', () => {
|
|
20
|
+
const hours: [string, string][] = [['08:00', '16:00']];
|
|
21
|
+
const calendar = {
|
|
22
|
+
id: 'every-day',
|
|
23
|
+
timeZone: 'UTC',
|
|
24
|
+
weekHours: {
|
|
25
|
+
'0': hours,
|
|
26
|
+
'1': hours,
|
|
27
|
+
'2': hours,
|
|
28
|
+
'3': hours,
|
|
29
|
+
'4': hours,
|
|
30
|
+
'5': hours,
|
|
31
|
+
'6': hours,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
const from = new Date('2026-01-01T08:00:00Z');
|
|
35
|
+
const to = new Date('2066-01-01T08:00:00Z');
|
|
36
|
+
expect(workingMinutesBetween(calendar, from, to)).toBe(14610 * 480);
|
|
37
|
+
expect(addWorkingMinutes(calendar, from, 14610 * 480).getTime()).toBe(
|
|
38
|
+
new Date('2065-12-31T16:00:00Z').getTime(),
|
|
39
|
+
);
|
|
40
|
+
expect(() =>
|
|
41
|
+
workingMinutesBetween(calendar, from, new Date('2066-01-02T08:00:00Z')),
|
|
42
|
+
).toThrow(WorkTimeRangeError);
|
|
43
|
+
}, 10000);
|
|
44
|
+
it('throws typed zone and empty-calendar errors carrying the calendar id', () => {
|
|
45
|
+
expect(() =>
|
|
46
|
+
buildWorkCalendarTable(
|
|
47
|
+
{ ...getStandardWorkCalendarDef('Invalid/Zone'), id: 'bad' },
|
|
48
|
+
new Date(),
|
|
49
|
+
new Date(),
|
|
50
|
+
),
|
|
51
|
+
).toThrow(WorkTimeInvalidZoneError);
|
|
52
|
+
expect(() =>
|
|
53
|
+
buildWorkCalendarTable(
|
|
54
|
+
{ id: 'empty', timeZone: 'UTC', weekHours: {} },
|
|
55
|
+
new Date(),
|
|
56
|
+
new Date(),
|
|
57
|
+
),
|
|
58
|
+
).toThrow(WorkTimeEmptyCalendarError);
|
|
59
|
+
});
|
|
60
|
+
it('keeps immutable ledger day indices stable while memoized arithmetic tables extend', () => {
|
|
61
|
+
const cal = getStandardWorkCalendarDef('America/New_York');
|
|
62
|
+
const from = new Date('2026-03-01T00:00:00-05:00');
|
|
63
|
+
const to = new Date('2026-03-15T00:00:00-04:00');
|
|
64
|
+
const table = buildWorkCalendarTable(cal, from, to);
|
|
65
|
+
const old = table.days.map((day) => ({ ...day }));
|
|
66
|
+
getWorkCalendarTable(
|
|
67
|
+
cal,
|
|
68
|
+
new Date('2020-01-01T00:00:00Z'),
|
|
69
|
+
new Date('2030-01-01T00:00:00Z'),
|
|
70
|
+
);
|
|
71
|
+
expect(table.days).toEqual(old);
|
|
72
|
+
for (let i = 0; i < table.days.length; i++)
|
|
73
|
+
expect(
|
|
74
|
+
getDayIndexForDateKey(table, getDateKeyForDayIndex(table, i)),
|
|
75
|
+
).toBe(i);
|
|
76
|
+
expect(getDayIndexForDateKey(table, '2025-01-01')).toBe(-1);
|
|
77
|
+
expect(getDayIndexForDateKey(table, '2027-01-01')).toBe(table.days.length);
|
|
78
|
+
});
|
|
79
|
+
it('matches cumulative positions to signed working-minute arithmetic', () => {
|
|
80
|
+
const cal = getStandardWorkCalendarDef('America/New_York');
|
|
81
|
+
const from = new Date('2026-03-06T00:00:00-05:00');
|
|
82
|
+
const to = new Date('2026-03-10T14:30:00-04:00');
|
|
83
|
+
const table = buildWorkCalendarTable(cal, from, to);
|
|
84
|
+
expect(getCumulativeMinutesAt(table, to.getTime())).toBe(
|
|
85
|
+
workingMinutesBetween(cal, from, to),
|
|
86
|
+
);
|
|
87
|
+
expect(getDayIndexAt(table, to)).toBe(4);
|
|
88
|
+
});
|
|
89
|
+
it('returns clipped merged intervals and treats an empty coverage calendar as closed', () => {
|
|
90
|
+
const cal = getStandardWorkCalendarDef('UTC');
|
|
91
|
+
const from = new Date('2026-01-05T10:00:00Z');
|
|
92
|
+
const to = new Date('2026-01-05T14:00:00Z');
|
|
93
|
+
expect(getWorkingIntervalsInRange(cal, from, to)).toEqual([
|
|
94
|
+
{
|
|
95
|
+
startAt: from.getTime(),
|
|
96
|
+
endAt: new Date('2026-01-05T12:00:00Z').getTime(),
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
startAt: new Date('2026-01-05T13:00:00Z').getTime(),
|
|
100
|
+
endAt: to.getTime(),
|
|
101
|
+
},
|
|
102
|
+
]);
|
|
103
|
+
expect(
|
|
104
|
+
getWorkingIntervalsInRange(
|
|
105
|
+
{ id: 'empty', timeZone: 'UTC', weekHours: {} },
|
|
106
|
+
from,
|
|
107
|
+
to,
|
|
108
|
+
),
|
|
109
|
+
).toEqual([]);
|
|
110
|
+
});
|
|
111
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ESNext",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "Bundler",
|
|
6
|
+
"allowImportingTsExtensions": true,
|
|
7
|
+
"noEmit": true,
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"jsx": "react-jsx"
|
|
11
|
+
},
|
|
12
|
+
"include": ["src/**/*"]
|
|
13
|
+
}
|