@lighthouse/common 6.4.0-canary.5 → 6.5.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/dist/constants.js +13 -7
- package/dist/errors/DomainError.js +4 -2
- package/dist/errors/ValidationError.js +8 -0
- package/dist/errors/index.js +5 -1
- package/dist/helpers/build-fetch-url/index.js +5 -0
- package/dist/helpers/fetch-image/index.js +32 -16
- package/dist/helpers/fetch-image-for-pdf-generator-service/index.js +44 -22
- package/dist/helpers/fetch-image-for-web/index.js +9 -0
- package/dist/helpers/fetch-lighthouse-logo/index.js +13 -2
- package/dist/helpers/floatify/index.js +1 -0
- package/dist/helpers/get-assignees-full-names/index.js +4 -0
- package/dist/helpers/get-audit-entry-details/index.js +3 -0
- package/dist/helpers/get-audit-items-data/index.js +6 -2
- package/dist/helpers/get-geometry-geocoded-string/index.js +3 -0
- package/dist/helpers/get-issue-details/index.js +9 -0
- package/dist/helpers/get-job-details/index.js +7 -0
- package/dist/helpers/get-location-reference/index.js +21 -18
- package/dist/helpers/get-pretty-duration/index.js +5 -0
- package/dist/helpers/get-reference-details/index.js +4 -0
- package/dist/helpers/get-status-details/index.js +9 -2
- package/dist/helpers/get-task-entry-details/index.js +3 -0
- package/dist/helpers/get-timezone-abbr/index.js +4 -0
- package/dist/helpers/get-timezone-datetime/index.js +5 -0
- package/dist/helpers/get-user-full-name/index.js +1 -0
- package/dist/helpers/get-value-as-percentage/index.js +1 -0
- package/dist/helpers/image-validators/index.js +9 -8
- package/dist/helpers/index.js +33 -16
- package/dist/images/index.js +9 -5
- package/dist/index.js +20 -4
- package/dist/pdf/activity-report/index.js +62 -41
- package/dist/pdf/audit/index.js +14 -0
- package/dist/pdf/helpers/build-audit-content/index.js +15 -4
- package/dist/pdf/helpers/build-audit-follow-ups/index.js +14 -4
- package/dist/pdf/helpers/build-location-scans-content/index.js +17 -4
- package/dist/pdf/helpers/build-template-content/index.js +14 -5
- package/dist/pdf/helpers/default-footer/index.js +3 -2
- package/dist/pdf/helpers/default-header/index.js +2 -0
- package/dist/pdf/helpers/default-styles/index.js +3 -2
- package/dist/pdf/helpers/fields/index.js +51 -21
- package/dist/pdf/helpers/format-location-address/index.js +3 -0
- package/dist/pdf/helpers/generate-definition/index.js +12 -0
- package/dist/pdf/helpers/horizontal-line/index.js +1 -0
- package/dist/pdf/helpers/html-transformer/index.js +23 -11
- package/dist/pdf/helpers/index.js +55 -40
- package/dist/pdf/helpers/parse-value/index.js +6 -2
- package/dist/pdf/helpers/table/index.js +31 -13
- package/dist/pdf/helpers/text/index.js +1 -0
- package/dist/pdf/icons/index.js +5 -3
- package/dist/pdf/index.js +10 -4
- package/dist/pdf/issue/index.js +14 -0
- package/dist/pdf/job/index.js +13 -1
- package/dist/pdf/shift-report/emptyFixtures.js +6 -4
- package/dist/pdf/shift-report/index.js +25 -2
- package/dist/pdf/task/index.js +13 -0
- package/dist/scheduling/generators/index.js +6 -0
- package/dist/scheduling/generators/occurrenceIntervalsGenerator.js +6 -1
- package/dist/scheduling/generators/scheduleIntervalsGenerator.js +5 -0
- package/dist/scheduling/generators/serviceIntervalsGenerator.js +27 -13
- package/dist/scheduling/helpers/convertToTimezone.js +6 -1
- package/dist/scheduling/helpers/generateNonRepeatingSchedule.js +9 -3
- package/dist/scheduling/helpers/generateRepeatingSchedule.js +18 -11
- package/dist/scheduling/helpers/generateScheduleEnd.js +8 -2
- package/dist/scheduling/helpers/hasValidStartAndEnd.js +6 -0
- package/dist/scheduling/helpers/index.js +28 -0
- package/dist/scheduling/helpers/intervalCovers.js +1 -0
- package/dist/scheduling/helpers/intervalIntersectsEnd.js +1 -0
- package/dist/scheduling/helpers/intervalIntersectsStart.js +1 -0
- package/dist/scheduling/helpers/intervalOnlyIntersectsEnd.js +3 -1
- package/dist/scheduling/helpers/intervalOnlyIntersectsStart.js +3 -0
- package/dist/scheduling/helpers/intervalOutside.js +1 -0
- package/dist/scheduling/helpers/intervalWithin.js +1 -0
- package/dist/scheduling/helpers/mergeIntervals.js +4 -0
- package/dist/scheduling/helpers/splitIntervals.js +3 -0
- package/dist/scheduling/index.js +6 -0
- package/dist/scheduling/scheduling.types.js +18 -10
- package/dist/scheduling/strategies/getNext.js +13 -2
- package/dist/scheduling/strategies/getNextExactDateOfMonth.js +12 -0
- package/dist/scheduling/strategies/getNextLastDayOfMonth.js +10 -0
- package/dist/scheduling/strategies/getNextLastWeekdayOfMonth.js +11 -0
- package/dist/scheduling/strategies/getNextNoRepeat.js +7 -0
- package/dist/scheduling/strategies/getNextWeekday.js +10 -0
- package/dist/scheduling/strategies/getNextXDayOfXWeekOfMonth.js +12 -0
- package/dist/scheduling/strategies/index.js +14 -0
- package/dist/schema/index.js +2 -0
- package/dist/schema/schema.js +7 -2
- package/dist/service-hours/__helpers__/calculate-hours.js +13 -4
- package/dist/service-hours/__helpers__/isOpen.js +9 -0
- package/dist/service-hours/index.js +4 -0
- package/dist/service-hours/schema.js +43 -20
- package/lib/constants.js.map +1 -1
- package/lib/errors/DomainError.js +47 -11
- package/lib/errors/DomainError.js.map +1 -1
- package/lib/errors/ValidationError.js +52 -15
- package/lib/errors/ValidationError.js.map +1 -1
- package/lib/errors/index.js.map +1 -1
- package/lib/helpers/build-fetch-url/index.js +20 -14
- package/lib/helpers/build-fetch-url/index.js.map +1 -1
- package/lib/helpers/fetch-image/index.js +27 -20
- package/lib/helpers/fetch-image/index.js.map +1 -1
- package/lib/helpers/fetch-image-for-pdf-generator-service/index.js +242 -201
- package/lib/helpers/fetch-image-for-pdf-generator-service/index.js.map +1 -1
- package/lib/helpers/fetch-image-for-web/index.js +66 -50
- package/lib/helpers/fetch-image-for-web/index.js.map +1 -1
- package/lib/helpers/fetch-lighthouse-logo/index.js +59 -47
- package/lib/helpers/fetch-lighthouse-logo/index.js.map +1 -1
- package/lib/helpers/floatify/index.js.map +1 -1
- package/lib/helpers/get-assignees-full-names/index.js +1 -0
- package/lib/helpers/get-assignees-full-names/index.js.map +1 -1
- package/lib/helpers/get-audit-entry-details/index.js +8 -8
- package/lib/helpers/get-audit-entry-details/index.js.map +1 -1
- package/lib/helpers/get-audit-items-data/index.js +19 -16
- package/lib/helpers/get-audit-items-data/index.js.map +1 -1
- package/lib/helpers/get-geometry-geocoded-string/index.js.map +1 -1
- package/lib/helpers/get-issue-details/index.js +12 -9
- package/lib/helpers/get-issue-details/index.js.map +1 -1
- package/lib/helpers/get-job-details/index.js +12 -12
- package/lib/helpers/get-job-details/index.js.map +1 -1
- package/lib/helpers/get-location-reference/index.js +36 -32
- package/lib/helpers/get-location-reference/index.js.map +1 -1
- package/lib/helpers/get-pretty-duration/index.js +4 -0
- package/lib/helpers/get-pretty-duration/index.js.map +1 -1
- package/lib/helpers/get-reference-details/index.js +3 -1
- package/lib/helpers/get-reference-details/index.js.map +1 -1
- package/lib/helpers/get-status-details/index.js +4 -0
- package/lib/helpers/get-status-details/index.js.map +1 -1
- package/lib/helpers/get-task-entry-details/index.js +5 -5
- package/lib/helpers/get-task-entry-details/index.js.map +1 -1
- package/lib/helpers/get-timezone-abbr/index.js.map +1 -1
- package/lib/helpers/get-timezone-datetime/index.js +6 -6
- package/lib/helpers/get-timezone-datetime/index.js.map +1 -1
- package/lib/helpers/get-user-full-name/index.js.map +1 -1
- package/lib/helpers/get-value-as-percentage/index.js.map +1 -1
- package/lib/helpers/image-validators/index.js +7 -8
- package/lib/helpers/image-validators/index.js.map +1 -1
- package/lib/helpers/index.js.map +1 -1
- package/lib/images/index.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/pdf/activity-report/index.js +416 -360
- package/lib/pdf/activity-report/index.js.map +1 -1
- package/lib/pdf/audit/index.js +36 -25
- package/lib/pdf/audit/index.js.map +1 -1
- package/lib/pdf/fonts/index.js.map +1 -1
- package/lib/pdf/helpers/build-audit-content/index.js +5 -3
- package/lib/pdf/helpers/build-audit-content/index.js.map +1 -1
- package/lib/pdf/helpers/build-audit-follow-ups/index.js +12 -5
- package/lib/pdf/helpers/build-audit-follow-ups/index.js.map +1 -1
- package/lib/pdf/helpers/build-location-scans-content/index.js +9 -4
- package/lib/pdf/helpers/build-location-scans-content/index.js.map +1 -1
- package/lib/pdf/helpers/build-template-content/index.js +9 -7
- package/lib/pdf/helpers/build-template-content/index.js.map +1 -1
- package/lib/pdf/helpers/default-footer/index.js +8 -9
- package/lib/pdf/helpers/default-footer/index.js.map +1 -1
- package/lib/pdf/helpers/default-header/index.js +5 -5
- package/lib/pdf/helpers/default-header/index.js.map +1 -1
- package/lib/pdf/helpers/default-styles/index.js.map +1 -1
- package/lib/pdf/helpers/fields/index.js +81 -48
- package/lib/pdf/helpers/fields/index.js.map +1 -1
- package/lib/pdf/helpers/format-location-address/index.js.map +1 -1
- package/lib/pdf/helpers/generate-definition/index.js +29 -22
- package/lib/pdf/helpers/generate-definition/index.js.map +1 -1
- package/lib/pdf/helpers/horizontal-line/index.js +1 -1
- package/lib/pdf/helpers/horizontal-line/index.js.map +1 -1
- package/lib/pdf/helpers/html-transformer/index.js +30 -19
- package/lib/pdf/helpers/html-transformer/index.js.map +1 -1
- package/lib/pdf/helpers/index.js.map +1 -1
- package/lib/pdf/helpers/parse-value/index.js +4 -2
- package/lib/pdf/helpers/parse-value/index.js.map +1 -1
- package/lib/pdf/helpers/table/index.js +84 -78
- package/lib/pdf/helpers/table/index.js.map +1 -1
- package/lib/pdf/helpers/text/index.js +5 -2
- package/lib/pdf/helpers/text/index.js.map +1 -1
- package/lib/pdf/icons/index.js.map +1 -1
- package/lib/pdf/index.js.map +1 -1
- package/lib/pdf/issue/index.js +28 -19
- package/lib/pdf/issue/index.js.map +1 -1
- package/lib/pdf/job/index.js +19 -12
- package/lib/pdf/job/index.js.map +1 -1
- package/lib/pdf/shift-report/emptyFixtures.js.map +1 -1
- package/lib/pdf/shift-report/index.js +374 -308
- package/lib/pdf/shift-report/index.js.map +1 -1
- package/lib/pdf/task/index.js +19 -11
- package/lib/pdf/task/index.js.map +1 -1
- package/lib/scheduling/generators/index.js.map +1 -1
- package/lib/scheduling/generators/occurrenceIntervalsGenerator.js +38 -27
- package/lib/scheduling/generators/occurrenceIntervalsGenerator.js.map +1 -1
- package/lib/scheduling/generators/scheduleIntervalsGenerator.js +30 -19
- package/lib/scheduling/generators/scheduleIntervalsGenerator.js.map +1 -1
- package/lib/scheduling/generators/serviceIntervalsGenerator.js +181 -139
- package/lib/scheduling/generators/serviceIntervalsGenerator.js.map +1 -1
- package/lib/scheduling/helpers/convertToTimezone.js +1 -1
- package/lib/scheduling/helpers/convertToTimezone.js.map +1 -1
- package/lib/scheduling/helpers/generateNonRepeatingSchedule.js +124 -84
- package/lib/scheduling/helpers/generateNonRepeatingSchedule.js.map +1 -1
- package/lib/scheduling/helpers/generateRepeatingSchedule.js +175 -107
- package/lib/scheduling/helpers/generateRepeatingSchedule.js.map +1 -1
- package/lib/scheduling/helpers/generateScheduleEnd.js +6 -6
- package/lib/scheduling/helpers/generateScheduleEnd.js.map +1 -1
- package/lib/scheduling/helpers/hasValidStartAndEnd.js +2 -1
- package/lib/scheduling/helpers/hasValidStartAndEnd.js.map +1 -1
- package/lib/scheduling/helpers/index.js.map +1 -1
- package/lib/scheduling/helpers/intervalCovers.js.map +1 -1
- package/lib/scheduling/helpers/intervalIntersectsEnd.js.map +1 -1
- package/lib/scheduling/helpers/intervalIntersectsStart.js.map +1 -1
- package/lib/scheduling/helpers/intervalOnlyIntersectsEnd.js +0 -1
- package/lib/scheduling/helpers/intervalOnlyIntersectsEnd.js.map +1 -1
- package/lib/scheduling/helpers/intervalOnlyIntersectsStart.js +1 -1
- package/lib/scheduling/helpers/intervalOnlyIntersectsStart.js.map +1 -1
- package/lib/scheduling/helpers/intervalOutside.js.map +1 -1
- package/lib/scheduling/helpers/intervalWithin.js.map +1 -1
- package/lib/scheduling/helpers/mergeIntervals.js +3 -0
- package/lib/scheduling/helpers/mergeIntervals.js.map +1 -1
- package/lib/scheduling/helpers/splitIntervals.js +1 -1
- package/lib/scheduling/helpers/splitIntervals.js.map +1 -1
- package/lib/scheduling/index.js.map +1 -1
- package/lib/scheduling/scheduling.types.js +14 -9
- package/lib/scheduling/scheduling.types.js.map +1 -1
- package/lib/scheduling/strategies/getNext.js +30 -22
- package/lib/scheduling/strategies/getNext.js.map +1 -1
- package/lib/scheduling/strategies/getNextExactDateOfMonth.js +31 -22
- package/lib/scheduling/strategies/getNextExactDateOfMonth.js.map +1 -1
- package/lib/scheduling/strategies/getNextLastDayOfMonth.js +28 -21
- package/lib/scheduling/strategies/getNextLastDayOfMonth.js.map +1 -1
- package/lib/scheduling/strategies/getNextLastWeekdayOfMonth.js +28 -21
- package/lib/scheduling/strategies/getNextLastWeekdayOfMonth.js.map +1 -1
- package/lib/scheduling/strategies/getNextNoRepeat.js +23 -15
- package/lib/scheduling/strategies/getNextNoRepeat.js.map +1 -1
- package/lib/scheduling/strategies/getNextWeekday.js +78 -43
- package/lib/scheduling/strategies/getNextWeekday.js.map +1 -1
- package/lib/scheduling/strategies/getNextXDayOfXWeekOfMonth.js +28 -21
- package/lib/scheduling/strategies/getNextXDayOfXWeekOfMonth.js.map +1 -1
- package/lib/scheduling/strategies/index.js.map +1 -1
- package/lib/schema/index.js.map +1 -1
- package/lib/schema/schema.js +30 -22
- package/lib/schema/schema.js.map +1 -1
- package/lib/service-hours/__helpers__/calculate-hours.js +13 -4
- package/lib/service-hours/__helpers__/calculate-hours.js.map +1 -1
- package/lib/service-hours/__helpers__/isOpen.js +7 -3
- package/lib/service-hours/__helpers__/isOpen.js.map +1 -1
- package/lib/service-hours/index.js.map +1 -1
- package/lib/service-hours/schema.js +36 -21
- package/lib/service-hours/schema.js.map +1 -1
- package/package.json +4 -5
- package/mise.toml +0 -6
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
|
|
6
7
|
var _convertToTimezone = require("./convertToTimezone");
|
|
8
|
+
|
|
7
9
|
Object.keys(_convertToTimezone).forEach(function (key) {
|
|
8
10
|
if (key === "default" || key === "__esModule") return;
|
|
9
11
|
if (key in exports && exports[key] === _convertToTimezone[key]) return;
|
|
@@ -14,7 +16,9 @@ Object.keys(_convertToTimezone).forEach(function (key) {
|
|
|
14
16
|
}
|
|
15
17
|
});
|
|
16
18
|
});
|
|
19
|
+
|
|
17
20
|
var _generateNonRepeatingSchedule = require("./generateNonRepeatingSchedule");
|
|
21
|
+
|
|
18
22
|
Object.keys(_generateNonRepeatingSchedule).forEach(function (key) {
|
|
19
23
|
if (key === "default" || key === "__esModule") return;
|
|
20
24
|
if (key in exports && exports[key] === _generateNonRepeatingSchedule[key]) return;
|
|
@@ -25,7 +29,9 @@ Object.keys(_generateNonRepeatingSchedule).forEach(function (key) {
|
|
|
25
29
|
}
|
|
26
30
|
});
|
|
27
31
|
});
|
|
32
|
+
|
|
28
33
|
var _generateRepeatingSchedule = require("./generateRepeatingSchedule");
|
|
34
|
+
|
|
29
35
|
Object.keys(_generateRepeatingSchedule).forEach(function (key) {
|
|
30
36
|
if (key === "default" || key === "__esModule") return;
|
|
31
37
|
if (key in exports && exports[key] === _generateRepeatingSchedule[key]) return;
|
|
@@ -36,7 +42,9 @@ Object.keys(_generateRepeatingSchedule).forEach(function (key) {
|
|
|
36
42
|
}
|
|
37
43
|
});
|
|
38
44
|
});
|
|
45
|
+
|
|
39
46
|
var _generateScheduleEnd = require("./generateScheduleEnd");
|
|
47
|
+
|
|
40
48
|
Object.keys(_generateScheduleEnd).forEach(function (key) {
|
|
41
49
|
if (key === "default" || key === "__esModule") return;
|
|
42
50
|
if (key in exports && exports[key] === _generateScheduleEnd[key]) return;
|
|
@@ -47,7 +55,9 @@ Object.keys(_generateScheduleEnd).forEach(function (key) {
|
|
|
47
55
|
}
|
|
48
56
|
});
|
|
49
57
|
});
|
|
58
|
+
|
|
50
59
|
var _hasValidStartAndEnd = require("./hasValidStartAndEnd");
|
|
60
|
+
|
|
51
61
|
Object.keys(_hasValidStartAndEnd).forEach(function (key) {
|
|
52
62
|
if (key === "default" || key === "__esModule") return;
|
|
53
63
|
if (key in exports && exports[key] === _hasValidStartAndEnd[key]) return;
|
|
@@ -58,7 +68,9 @@ Object.keys(_hasValidStartAndEnd).forEach(function (key) {
|
|
|
58
68
|
}
|
|
59
69
|
});
|
|
60
70
|
});
|
|
71
|
+
|
|
61
72
|
var _intervalCovers = require("./intervalCovers");
|
|
73
|
+
|
|
62
74
|
Object.keys(_intervalCovers).forEach(function (key) {
|
|
63
75
|
if (key === "default" || key === "__esModule") return;
|
|
64
76
|
if (key in exports && exports[key] === _intervalCovers[key]) return;
|
|
@@ -69,7 +81,9 @@ Object.keys(_intervalCovers).forEach(function (key) {
|
|
|
69
81
|
}
|
|
70
82
|
});
|
|
71
83
|
});
|
|
84
|
+
|
|
72
85
|
var _intervalIntersectsEnd = require("./intervalIntersectsEnd");
|
|
86
|
+
|
|
73
87
|
Object.keys(_intervalIntersectsEnd).forEach(function (key) {
|
|
74
88
|
if (key === "default" || key === "__esModule") return;
|
|
75
89
|
if (key in exports && exports[key] === _intervalIntersectsEnd[key]) return;
|
|
@@ -80,7 +94,9 @@ Object.keys(_intervalIntersectsEnd).forEach(function (key) {
|
|
|
80
94
|
}
|
|
81
95
|
});
|
|
82
96
|
});
|
|
97
|
+
|
|
83
98
|
var _intervalIntersectsStart = require("./intervalIntersectsStart");
|
|
99
|
+
|
|
84
100
|
Object.keys(_intervalIntersectsStart).forEach(function (key) {
|
|
85
101
|
if (key === "default" || key === "__esModule") return;
|
|
86
102
|
if (key in exports && exports[key] === _intervalIntersectsStart[key]) return;
|
|
@@ -91,7 +107,9 @@ Object.keys(_intervalIntersectsStart).forEach(function (key) {
|
|
|
91
107
|
}
|
|
92
108
|
});
|
|
93
109
|
});
|
|
110
|
+
|
|
94
111
|
var _intervalOnlyIntersectsEnd = require("./intervalOnlyIntersectsEnd");
|
|
112
|
+
|
|
95
113
|
Object.keys(_intervalOnlyIntersectsEnd).forEach(function (key) {
|
|
96
114
|
if (key === "default" || key === "__esModule") return;
|
|
97
115
|
if (key in exports && exports[key] === _intervalOnlyIntersectsEnd[key]) return;
|
|
@@ -102,7 +120,9 @@ Object.keys(_intervalOnlyIntersectsEnd).forEach(function (key) {
|
|
|
102
120
|
}
|
|
103
121
|
});
|
|
104
122
|
});
|
|
123
|
+
|
|
105
124
|
var _intervalOnlyIntersectsStart = require("./intervalOnlyIntersectsStart");
|
|
125
|
+
|
|
106
126
|
Object.keys(_intervalOnlyIntersectsStart).forEach(function (key) {
|
|
107
127
|
if (key === "default" || key === "__esModule") return;
|
|
108
128
|
if (key in exports && exports[key] === _intervalOnlyIntersectsStart[key]) return;
|
|
@@ -113,7 +133,9 @@ Object.keys(_intervalOnlyIntersectsStart).forEach(function (key) {
|
|
|
113
133
|
}
|
|
114
134
|
});
|
|
115
135
|
});
|
|
136
|
+
|
|
116
137
|
var _intervalOutside = require("./intervalOutside");
|
|
138
|
+
|
|
117
139
|
Object.keys(_intervalOutside).forEach(function (key) {
|
|
118
140
|
if (key === "default" || key === "__esModule") return;
|
|
119
141
|
if (key in exports && exports[key] === _intervalOutside[key]) return;
|
|
@@ -124,7 +146,9 @@ Object.keys(_intervalOutside).forEach(function (key) {
|
|
|
124
146
|
}
|
|
125
147
|
});
|
|
126
148
|
});
|
|
149
|
+
|
|
127
150
|
var _intervalWithin = require("./intervalWithin");
|
|
151
|
+
|
|
128
152
|
Object.keys(_intervalWithin).forEach(function (key) {
|
|
129
153
|
if (key === "default" || key === "__esModule") return;
|
|
130
154
|
if (key in exports && exports[key] === _intervalWithin[key]) return;
|
|
@@ -135,7 +159,9 @@ Object.keys(_intervalWithin).forEach(function (key) {
|
|
|
135
159
|
}
|
|
136
160
|
});
|
|
137
161
|
});
|
|
162
|
+
|
|
138
163
|
var _mergeIntervals = require("./mergeIntervals");
|
|
164
|
+
|
|
139
165
|
Object.keys(_mergeIntervals).forEach(function (key) {
|
|
140
166
|
if (key === "default" || key === "__esModule") return;
|
|
141
167
|
if (key in exports && exports[key] === _mergeIntervals[key]) return;
|
|
@@ -146,7 +172,9 @@ Object.keys(_mergeIntervals).forEach(function (key) {
|
|
|
146
172
|
}
|
|
147
173
|
});
|
|
148
174
|
});
|
|
175
|
+
|
|
149
176
|
var _splitIntervals = require("./splitIntervals");
|
|
177
|
+
|
|
150
178
|
Object.keys(_splitIntervals).forEach(function (key) {
|
|
151
179
|
if (key === "default" || key === "__esModule") return;
|
|
152
180
|
if (key in exports && exports[key] === _splitIntervals[key]) return;
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.intervalIntersectsEnd = intervalIntersectsEnd;
|
|
7
|
+
|
|
7
8
|
/**
|
|
8
9
|
* Check if interval intersects another interval's end
|
|
9
10
|
* Accepts two intervals and checks whether the first intersects the second's end
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.intervalIntersectsStart = intervalIntersectsStart;
|
|
7
|
+
|
|
7
8
|
/**
|
|
8
9
|
* Check if interval intersects another interval's start
|
|
9
10
|
* Accepts two intervals and checks whether the first intersects the second's start
|
|
@@ -4,8 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.intervalOnlyIntersectsEnd = intervalOnlyIntersectsEnd;
|
|
7
|
+
|
|
7
8
|
var _intervalIntersectsEnd = require("./intervalIntersectsEnd");
|
|
9
|
+
|
|
8
10
|
var _intervalIntersectsStart = require("./intervalIntersectsStart");
|
|
11
|
+
|
|
9
12
|
/**
|
|
10
13
|
* Check if interval only intersects another interval's end
|
|
11
14
|
* Accepts two intervals and checks whether the first only intersects the second's end
|
|
@@ -13,7 +16,6 @@ var _intervalIntersectsStart = require("./intervalIntersectsStart");
|
|
|
13
16
|
* intervalIntersectsEnd([12,20], [5,15]))
|
|
14
17
|
* returns true
|
|
15
18
|
*/
|
|
16
|
-
|
|
17
19
|
function intervalOnlyIntersectsEnd(firstInterval, secondInterval) {
|
|
18
20
|
return !(0, _intervalIntersectsStart.intervalIntersectsStart)(firstInterval, secondInterval) && (0, _intervalIntersectsEnd.intervalIntersectsEnd)(firstInterval, secondInterval);
|
|
19
21
|
}
|
|
@@ -4,8 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.intervalOnlyIntersectsStart = intervalOnlyIntersectsStart;
|
|
7
|
+
|
|
7
8
|
var _intervalIntersectsEnd = require("./intervalIntersectsEnd");
|
|
9
|
+
|
|
8
10
|
var _intervalIntersectsStart = require("./intervalIntersectsStart");
|
|
11
|
+
|
|
9
12
|
/**
|
|
10
13
|
* Check if interval only intersects another interval's start
|
|
11
14
|
* Accepts two intervals and checks whether the first only intersects the second's start
|
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.mergeIntervals = mergeIntervals;
|
|
7
|
+
|
|
7
8
|
var _fp = require("lodash/fp");
|
|
9
|
+
|
|
8
10
|
/**
|
|
9
11
|
* Merges overlapping intervals
|
|
10
12
|
* Accepts arrays of intervals and returns a flattened result of overlapping intervals
|
|
@@ -20,12 +22,14 @@ function mergeIntervals(intervals) {
|
|
|
20
22
|
const top = accum[accum.length - 1];
|
|
21
23
|
const topBeforeInterval = top[1] < interval[0];
|
|
22
24
|
const topOverlapsInterval = top[1] < interval[1];
|
|
25
|
+
|
|
23
26
|
if (topBeforeInterval) {
|
|
24
27
|
accum.push(interval);
|
|
25
28
|
} else if (topOverlapsInterval) {
|
|
26
29
|
accum.pop();
|
|
27
30
|
accum.push([top[0], interval[1]]);
|
|
28
31
|
}
|
|
32
|
+
|
|
29
33
|
return accum;
|
|
30
34
|
}, [firstInterval], sortedIntervals);
|
|
31
35
|
return stack;
|
|
@@ -4,8 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.splitIntervals = splitIntervals;
|
|
7
|
+
|
|
7
8
|
var _fp = require("lodash/fp");
|
|
9
|
+
|
|
8
10
|
var _ = require(".");
|
|
11
|
+
|
|
9
12
|
/**
|
|
10
13
|
* Applies closed intervals to intervals
|
|
11
14
|
* Accepts two sets of intervals and splits the first set by the second set
|
package/dist/scheduling/index.js
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
|
|
6
7
|
var _generators = require("./generators");
|
|
8
|
+
|
|
7
9
|
Object.keys(_generators).forEach(function (key) {
|
|
8
10
|
if (key === "default" || key === "__esModule") return;
|
|
9
11
|
if (key in exports && exports[key] === _generators[key]) return;
|
|
@@ -14,7 +16,9 @@ Object.keys(_generators).forEach(function (key) {
|
|
|
14
16
|
}
|
|
15
17
|
});
|
|
16
18
|
});
|
|
19
|
+
|
|
17
20
|
var _scheduling = require("./scheduling.types");
|
|
21
|
+
|
|
18
22
|
Object.keys(_scheduling).forEach(function (key) {
|
|
19
23
|
if (key === "default" || key === "__esModule") return;
|
|
20
24
|
if (key in exports && exports[key] === _scheduling[key]) return;
|
|
@@ -25,7 +29,9 @@ Object.keys(_scheduling).forEach(function (key) {
|
|
|
25
29
|
}
|
|
26
30
|
});
|
|
27
31
|
});
|
|
32
|
+
|
|
28
33
|
var _helpers = require("./helpers");
|
|
34
|
+
|
|
29
35
|
Object.keys(_helpers).forEach(function (key) {
|
|
30
36
|
if (key === "default" || key === "__esModule") return;
|
|
31
37
|
if (key in exports && exports[key] === _helpers[key]) return;
|
|
@@ -3,13 +3,19 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
let IntervalTypes
|
|
6
|
+
exports.StrategyTypes = exports.Unit = exports.IntervalTypes = void 0;
|
|
7
|
+
let IntervalTypes;
|
|
8
|
+
exports.IntervalTypes = IntervalTypes;
|
|
9
|
+
|
|
10
|
+
(function (IntervalTypes) {
|
|
8
11
|
IntervalTypes["Occurrence"] = "occurrence";
|
|
9
12
|
IntervalTypes["Service"] = "service";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
let Unit
|
|
13
|
+
})(IntervalTypes || (exports.IntervalTypes = IntervalTypes = {}));
|
|
14
|
+
|
|
15
|
+
let Unit;
|
|
16
|
+
exports.Unit = Unit;
|
|
17
|
+
|
|
18
|
+
(function (Unit) {
|
|
13
19
|
Unit["Millisecond"] = "millisecond";
|
|
14
20
|
Unit["Second"] = "second";
|
|
15
21
|
Unit["Minute"] = "minute";
|
|
@@ -18,9 +24,12 @@ let Unit = exports.Unit = /*#__PURE__*/function (Unit) {
|
|
|
18
24
|
Unit["Week"] = "isoWeek";
|
|
19
25
|
Unit["Month"] = "month";
|
|
20
26
|
Unit["Year"] = "year";
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
let StrategyTypes
|
|
27
|
+
})(Unit || (exports.Unit = Unit = {}));
|
|
28
|
+
|
|
29
|
+
let StrategyTypes;
|
|
30
|
+
exports.StrategyTypes = StrategyTypes;
|
|
31
|
+
|
|
32
|
+
(function (StrategyTypes) {
|
|
24
33
|
StrategyTypes["ExactDateOfMonth"] = "exactDateOfMonth";
|
|
25
34
|
StrategyTypes["LastDayOfMonth"] = "lastDayOfMonth";
|
|
26
35
|
StrategyTypes["LastWeekdayOfMonth"] = "lastWeekdayOfMonth";
|
|
@@ -29,5 +38,4 @@ let StrategyTypes = exports.StrategyTypes = /*#__PURE__*/function (StrategyTypes
|
|
|
29
38
|
StrategyTypes["Weekdays"] = "weekdays";
|
|
30
39
|
StrategyTypes["Window"] = "window";
|
|
31
40
|
StrategyTypes["XDayOfXWeekOfMonth"] = "xDayOfxWeekOfMonth";
|
|
32
|
-
|
|
33
|
-
}({});
|
|
41
|
+
})(StrategyTypes || (exports.StrategyTypes = StrategyTypes = {}));
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.getNext = getNext;
|
|
9
|
+
|
|
8
10
|
var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
|
|
11
|
+
|
|
9
12
|
var _scheduling = require("../scheduling.types");
|
|
13
|
+
|
|
10
14
|
/**
|
|
11
15
|
* Generates next occurrence interval for stopwatch and window strategy
|
|
12
16
|
*/
|
|
@@ -32,29 +36,36 @@ function* getNext({
|
|
|
32
36
|
} = frequency;
|
|
33
37
|
let initial = isInitial;
|
|
34
38
|
let dateCursor = initial ? _momentTimezone.default.tz(start, timezone).valueOf() : _momentTimezone.default.tz(start, timezone).add(1, _scheduling.Unit.Millisecond).valueOf();
|
|
39
|
+
|
|
35
40
|
while (dateCursor < end) {
|
|
36
41
|
let nextOccurrenceStart;
|
|
37
42
|
let nextOccurrenceEnd;
|
|
43
|
+
|
|
38
44
|
if (type === _scheduling.StrategyTypes.Stopwatch) {
|
|
39
45
|
nextOccurrenceStart = dateCursor;
|
|
40
46
|
nextOccurrenceEnd = _momentTimezone.default.tz(dateCursor, timezone).add(durationValue, durationUnit).valueOf();
|
|
41
47
|
} else {
|
|
42
48
|
nextOccurrenceEnd = _momentTimezone.default.tz(dateCursor, timezone).add(frequencyValue, frequencyUnit).valueOf();
|
|
49
|
+
|
|
43
50
|
const nextOccurrenceStartByBackCalculation = _momentTimezone.default.tz(nextOccurrenceEnd, timezone).subtract(durationValue, durationUnit);
|
|
44
|
-
const earliestNextOccurrenceStart = _momentTimezone.default.tz(dateCursor, timezone);
|
|
45
51
|
|
|
46
|
-
// NOTE: this is to ensure that the next occurrence start is always
|
|
52
|
+
const earliestNextOccurrenceStart = _momentTimezone.default.tz(dateCursor, timezone); // NOTE: this is to ensure that the next occurrence start is always
|
|
47
53
|
// greater than or equal to the date cursor. Moment js handles month addition and subtraction
|
|
48
54
|
// with estimations (Dec 31st + 2 months gives Feb 28th/29th). This can lead to inaccurate start times when calculating forwards then backwards at the end of the month.
|
|
55
|
+
|
|
56
|
+
|
|
49
57
|
nextOccurrenceStart = _momentTimezone.default.max(earliestNextOccurrenceStart, nextOccurrenceStartByBackCalculation).valueOf();
|
|
50
58
|
}
|
|
59
|
+
|
|
51
60
|
if (nextOccurrenceEnd <= nextOccurrenceStart || nextOccurrenceEnd > end) {
|
|
52
61
|
return;
|
|
53
62
|
}
|
|
63
|
+
|
|
54
64
|
if (nextOccurrenceStart >= start) {
|
|
55
65
|
const nextOccurrence = [nextOccurrenceStart, nextOccurrenceEnd - 1];
|
|
56
66
|
yield nextOccurrence;
|
|
57
67
|
}
|
|
68
|
+
|
|
58
69
|
dateCursor = nextOccurrenceEnd;
|
|
59
70
|
}
|
|
60
71
|
}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.getNextExactDateOfMonth = getNextExactDateOfMonth;
|
|
9
|
+
|
|
8
10
|
var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
|
|
11
|
+
|
|
9
12
|
var _scheduling = require("../scheduling.types");
|
|
13
|
+
|
|
10
14
|
/**
|
|
11
15
|
* Generates next occurrence interval for exact date of month strategy
|
|
12
16
|
*/
|
|
@@ -31,21 +35,29 @@ function* getNextExactDateOfMonth({
|
|
|
31
35
|
value: frequencyValue
|
|
32
36
|
} = frequency;
|
|
33
37
|
let dateCursor = isInitial ? _momentTimezone.default.tz(start, timezone).startOf(_scheduling.Unit.Month).valueOf() : _momentTimezone.default.tz(start, timezone).add(frequencyValue, frequencyUnit).startOf(_scheduling.Unit.Month).valueOf();
|
|
38
|
+
|
|
34
39
|
while (dateCursor < end) {
|
|
35
40
|
const monthDate = _momentTimezone.default.tz(dateCursor, timezone).date(date).date();
|
|
41
|
+
|
|
36
42
|
const hasExactDate = monthDate === date;
|
|
43
|
+
|
|
37
44
|
if (hasExactDate) {
|
|
38
45
|
const nextOccurrenceEnd = _momentTimezone.default.tz(dateCursor, timezone).date(date).add(1, _scheduling.Unit.Day).valueOf();
|
|
46
|
+
|
|
39
47
|
const nextOccurrenceStart = _momentTimezone.default.tz(nextOccurrenceEnd, timezone).subtract(durationValue, durationUnit).valueOf();
|
|
48
|
+
|
|
40
49
|
if (nextOccurrenceEnd <= nextOccurrenceStart || nextOccurrenceEnd > end) {
|
|
41
50
|
return;
|
|
42
51
|
}
|
|
52
|
+
|
|
43
53
|
if (nextOccurrenceStart >= start) {
|
|
44
54
|
const nextOccurrence = [nextOccurrenceStart, nextOccurrenceEnd - 1];
|
|
45
55
|
yield nextOccurrence;
|
|
46
56
|
}
|
|
47
57
|
}
|
|
58
|
+
|
|
48
59
|
const nextDateCursor = _momentTimezone.default.tz(dateCursor, timezone).add(1, _scheduling.Unit.Month).valueOf();
|
|
60
|
+
|
|
49
61
|
dateCursor = nextDateCursor;
|
|
50
62
|
}
|
|
51
63
|
}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.getNextLastDayOfMonth = getNextLastDayOfMonth;
|
|
9
|
+
|
|
8
10
|
var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
|
|
11
|
+
|
|
9
12
|
var _scheduling = require("../scheduling.types");
|
|
13
|
+
|
|
10
14
|
/**
|
|
11
15
|
* Generates next occurrence interval for last day of month strategy
|
|
12
16
|
*/
|
|
@@ -30,17 +34,23 @@ function* getNextLastDayOfMonth({
|
|
|
30
34
|
value: frequencyValue
|
|
31
35
|
} = frequency;
|
|
32
36
|
let dateCursor = isInitial ? _momentTimezone.default.tz(start, timezone).startOf(_scheduling.Unit.Month).valueOf() : _momentTimezone.default.tz(start, timezone).add(frequencyValue, frequencyUnit).startOf(_scheduling.Unit.Month).valueOf();
|
|
37
|
+
|
|
33
38
|
while (dateCursor < end) {
|
|
34
39
|
const nextOccurrenceEnd = _momentTimezone.default.tz(dateCursor, timezone).endOf(_scheduling.Unit.Month).add(1, _scheduling.Unit.Day).startOf(_scheduling.Unit.Day).valueOf();
|
|
40
|
+
|
|
35
41
|
const nextOccurrenceStart = _momentTimezone.default.tz(nextOccurrenceEnd, timezone).subtract(durationValue, durationUnit).valueOf();
|
|
42
|
+
|
|
36
43
|
if (nextOccurrenceEnd <= nextOccurrenceStart || nextOccurrenceEnd > end) {
|
|
37
44
|
return;
|
|
38
45
|
}
|
|
46
|
+
|
|
39
47
|
if (nextOccurrenceStart >= start) {
|
|
40
48
|
const nextOccurrence = [nextOccurrenceStart, nextOccurrenceEnd - 1];
|
|
41
49
|
yield nextOccurrence;
|
|
42
50
|
}
|
|
51
|
+
|
|
43
52
|
const nextDateCursor = _momentTimezone.default.tz(dateCursor, timezone).add(1, _scheduling.Unit.Month).valueOf();
|
|
53
|
+
|
|
44
54
|
dateCursor = nextDateCursor;
|
|
45
55
|
}
|
|
46
56
|
}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.getNextLastWeekdayOfMonth = getNextLastWeekdayOfMonth;
|
|
9
|
+
|
|
8
10
|
var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
|
|
11
|
+
|
|
9
12
|
var _scheduling = require("../scheduling.types");
|
|
13
|
+
|
|
10
14
|
/**
|
|
11
15
|
* Generates next occurrence interval for last weekday of month strategy
|
|
12
16
|
*/
|
|
@@ -31,21 +35,28 @@ function* getNextLastWeekdayOfMonth({
|
|
|
31
35
|
value: frequencyValue
|
|
32
36
|
} = frequency;
|
|
33
37
|
let dateCursor = isInitial ? _momentTimezone.default.tz(start, timezone).startOf(_scheduling.Unit.Month).valueOf() : _momentTimezone.default.tz(start, timezone).add(frequencyValue, frequencyUnit).startOf(_scheduling.Unit.Month).valueOf();
|
|
38
|
+
|
|
34
39
|
while (dateCursor < end) {
|
|
35
40
|
const mStartOfMonth = _momentTimezone.default.tz(dateCursor, timezone).add(1, _scheduling.Unit.Month);
|
|
41
|
+
|
|
36
42
|
const year = mStartOfMonth.year();
|
|
37
43
|
const month = mStartOfMonth.month();
|
|
38
44
|
const startDay = mStartOfMonth.isoWeekday();
|
|
39
45
|
const date = startDay > weekday ? weekday - startDay + 8 : weekday - startDay + 1;
|
|
46
|
+
|
|
40
47
|
const nextOccurrenceEnd = _momentTimezone.default.tz(timezone).year(year).month(month).date(date).add(1, _scheduling.Unit.Day).startOf(_scheduling.Unit.Day).subtract(1, _scheduling.Unit.Week).valueOf();
|
|
48
|
+
|
|
41
49
|
const nextOccurrenceStart = _momentTimezone.default.tz(nextOccurrenceEnd, timezone).subtract(durationValue, durationUnit).valueOf();
|
|
50
|
+
|
|
42
51
|
if (nextOccurrenceEnd <= nextOccurrenceStart || nextOccurrenceEnd > end) {
|
|
43
52
|
return;
|
|
44
53
|
}
|
|
54
|
+
|
|
45
55
|
if (nextOccurrenceStart >= start) {
|
|
46
56
|
const nextOccurrence = [nextOccurrenceStart, nextOccurrenceEnd - 1];
|
|
47
57
|
yield nextOccurrence;
|
|
48
58
|
}
|
|
59
|
+
|
|
49
60
|
const nextDateCursor = mStartOfMonth.valueOf();
|
|
50
61
|
dateCursor = nextDateCursor;
|
|
51
62
|
}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.getNextNoRepeat = getNextNoRepeat;
|
|
9
|
+
|
|
8
10
|
var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
|
|
11
|
+
|
|
9
12
|
/**
|
|
10
13
|
* Generates next occurrence interval for non repeat strategy
|
|
11
14
|
*/
|
|
@@ -15,13 +18,17 @@ function* getNextNoRepeat({
|
|
|
15
18
|
timezone
|
|
16
19
|
}) {
|
|
17
20
|
const nextOccurrenceStart = _momentTimezone.default.tz(start, timezone).valueOf();
|
|
21
|
+
|
|
18
22
|
const nextOccurrenceEnd = _momentTimezone.default.tz(end, timezone).valueOf() - 1;
|
|
23
|
+
|
|
19
24
|
if (nextOccurrenceStart < start) {
|
|
20
25
|
return;
|
|
21
26
|
}
|
|
27
|
+
|
|
22
28
|
if (nextOccurrenceEnd <= nextOccurrenceStart) {
|
|
23
29
|
return;
|
|
24
30
|
}
|
|
31
|
+
|
|
25
32
|
const nextOccurrence = [nextOccurrenceStart, nextOccurrenceEnd];
|
|
26
33
|
yield nextOccurrence;
|
|
27
34
|
}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.getNextWeekday = getNextWeekday;
|
|
9
|
+
|
|
8
10
|
var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
|
|
11
|
+
|
|
9
12
|
var _scheduling = require("../scheduling.types");
|
|
13
|
+
|
|
10
14
|
/**
|
|
11
15
|
* Generates next occurrence interval for weekdays strategy
|
|
12
16
|
*/
|
|
@@ -32,20 +36,26 @@ function* getNextWeekday({
|
|
|
32
36
|
} = frequency;
|
|
33
37
|
let initial = isInitial;
|
|
34
38
|
let dateCursor = initial ? _momentTimezone.default.tz(start, timezone).startOf(_scheduling.Unit.Week).valueOf() : _momentTimezone.default.tz(start, timezone).add(frequencyValue, frequencyUnit).startOf(_scheduling.Unit.Week).valueOf();
|
|
39
|
+
|
|
35
40
|
while (dateCursor < end) {
|
|
36
41
|
for (const weekday of weekdays) {
|
|
37
42
|
const nextOccurrenceEnd = _momentTimezone.default.tz(dateCursor, timezone).isoWeekday(weekday).add(1, _scheduling.Unit.Day).startOf(_scheduling.Unit.Day).valueOf();
|
|
43
|
+
|
|
38
44
|
const nextOccurrenceStart = _momentTimezone.default.tz(nextOccurrenceEnd, timezone).subtract(durationValue, durationUnit).valueOf();
|
|
45
|
+
|
|
39
46
|
if (nextOccurrenceEnd <= nextOccurrenceStart || nextOccurrenceEnd > end) {
|
|
40
47
|
return;
|
|
41
48
|
}
|
|
49
|
+
|
|
42
50
|
if (nextOccurrenceStart >= start) {
|
|
43
51
|
const nextOccurrence = [nextOccurrenceStart, nextOccurrenceEnd - 1];
|
|
44
52
|
yield nextOccurrence;
|
|
45
53
|
initial = false;
|
|
46
54
|
}
|
|
47
55
|
}
|
|
56
|
+
|
|
48
57
|
const nextDateCursor = _momentTimezone.default.tz(dateCursor, timezone).add(1, _scheduling.Unit.Week).valueOf();
|
|
58
|
+
|
|
49
59
|
dateCursor = nextDateCursor;
|
|
50
60
|
}
|
|
51
61
|
}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.getNextXDayOfXWeekOfMonth = getNextXDayOfXWeekOfMonth;
|
|
9
|
+
|
|
8
10
|
var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
|
|
11
|
+
|
|
9
12
|
var _scheduling = require("../scheduling.types");
|
|
13
|
+
|
|
10
14
|
/**
|
|
11
15
|
* Generates next occurrence interval for x day of x week of month strategy
|
|
12
16
|
*/
|
|
@@ -32,24 +36,32 @@ function* getNextXDayOfXWeekOfMonth({
|
|
|
32
36
|
value: frequencyValue
|
|
33
37
|
} = frequency;
|
|
34
38
|
let dateCursor = isInitial ? _momentTimezone.default.tz(start, timezone).startOf(_scheduling.Unit.Month).valueOf() : _momentTimezone.default.tz(start, timezone).add(frequencyValue, frequencyUnit).startOf(_scheduling.Unit.Month).valueOf();
|
|
39
|
+
|
|
35
40
|
while (dateCursor < end) {
|
|
36
41
|
const mStartOfMonth = _momentTimezone.default.tz(dateCursor, timezone);
|
|
42
|
+
|
|
37
43
|
const year = mStartOfMonth.year();
|
|
38
44
|
const month = mStartOfMonth.month();
|
|
39
45
|
const startDayOfMonth = mStartOfMonth.isoWeekday();
|
|
40
46
|
const weekOffset = (weekOfMonth - 1) * 7;
|
|
41
47
|
const day = startDayOfMonth > dayOfWeek ? dayOfWeek - startDayOfMonth + 8 : dayOfWeek - startDayOfMonth + 1;
|
|
42
48
|
const date = weekOffset + day;
|
|
49
|
+
|
|
43
50
|
const nextOccurrenceEnd = _momentTimezone.default.tz(timezone).year(year).month(month).date(date).add(1, _scheduling.Unit.Day).startOf(_scheduling.Unit.Day).valueOf();
|
|
51
|
+
|
|
44
52
|
const nextOccurrenceStart = _momentTimezone.default.tz(nextOccurrenceEnd, timezone).subtract(durationValue, durationUnit).valueOf();
|
|
53
|
+
|
|
45
54
|
if (nextOccurrenceEnd <= nextOccurrenceStart || nextOccurrenceEnd > end) {
|
|
46
55
|
return;
|
|
47
56
|
}
|
|
57
|
+
|
|
48
58
|
if (nextOccurrenceStart >= start) {
|
|
49
59
|
const nextOccurrence = [nextOccurrenceStart, nextOccurrenceEnd - 1];
|
|
50
60
|
yield nextOccurrence;
|
|
51
61
|
}
|
|
62
|
+
|
|
52
63
|
const nextDateCursor = _momentTimezone.default.tz(dateCursor, timezone).add(1, _scheduling.Unit.Month).valueOf();
|
|
64
|
+
|
|
53
65
|
dateCursor = nextDateCursor;
|
|
54
66
|
}
|
|
55
67
|
}
|