@cloudsnorkel/cdk-github-runners 0.14.23 → 0.15.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.
Files changed (139) hide show
  1. package/.jsii +5397 -252
  2. package/API.md +1048 -24
  3. package/README.md +52 -0
  4. package/assets/delete-failed-runner.lambda/index.js +105 -9
  5. package/assets/idle-runner-repear.lambda/index.js +136 -14
  6. package/assets/image-builders/aws-image-builder/delete-resources.lambda/index.js +1 -1
  7. package/assets/image-builders/build-image.lambda/index.js +1 -1
  8. package/assets/providers/ami-root-device.lambda/index.js +1 -1
  9. package/assets/setup.lambda/index.html +7 -7
  10. package/assets/setup.lambda/index.js +101 -8
  11. package/assets/status.lambda/index.js +104 -8
  12. package/assets/token-retriever.lambda/index.js +104 -8
  13. package/assets/warm-runner-manager.lambda/index.js +5892 -0
  14. package/assets/webhook-handler.lambda/index.js +109 -11
  15. package/assets/webhook-redelivery.lambda/index.js +122 -24
  16. package/lib/access.js +1 -1
  17. package/lib/delete-failed-runner.lambda.js +2 -2
  18. package/lib/idle-runner-repear.lambda.js +33 -7
  19. package/lib/image-builders/api.js +1 -1
  20. package/lib/image-builders/aws-image-builder/base-image.d.ts +13 -0
  21. package/lib/image-builders/aws-image-builder/base-image.js +36 -3
  22. package/lib/image-builders/aws-image-builder/builder.js +4 -4
  23. package/lib/image-builders/aws-image-builder/delete-resources.lambda.js +2 -2
  24. package/lib/image-builders/aws-image-builder/deprecated/ami.js +1 -1
  25. package/lib/image-builders/aws-image-builder/deprecated/container.js +1 -1
  26. package/lib/image-builders/aws-image-builder/deprecated/linux-components.js +1 -1
  27. package/lib/image-builders/aws-image-builder/deprecated/windows-components.js +1 -1
  28. package/lib/image-builders/build-image.lambda.js +2 -2
  29. package/lib/image-builders/codebuild-deprecated.js +1 -1
  30. package/lib/image-builders/components.js +3 -3
  31. package/lib/image-builders/static.js +1 -1
  32. package/lib/index.d.ts +1 -0
  33. package/lib/index.js +2 -1
  34. package/lib/lambda-github.d.ts +1 -1
  35. package/lib/lambda-github.js +3 -2
  36. package/lib/lambda-helpers.js +4 -4
  37. package/lib/providers/ami-root-device.lambda.js +2 -2
  38. package/lib/providers/codebuild.d.ts +16 -0
  39. package/lib/providers/codebuild.js +16 -5
  40. package/lib/providers/common.js +3 -3
  41. package/lib/providers/composite.js +1 -1
  42. package/lib/providers/ec2.d.ts +5 -0
  43. package/lib/providers/ec2.js +42 -29
  44. package/lib/providers/ecs.d.ts +17 -0
  45. package/lib/providers/ecs.js +43 -38
  46. package/lib/providers/fargate.js +10 -32
  47. package/lib/providers/lambda.js +2 -2
  48. package/lib/runner.d.ts +25 -2
  49. package/lib/runner.js +119 -17
  50. package/lib/secrets.js +1 -1
  51. package/lib/setup.lambda.js +2 -2
  52. package/lib/utils.d.ts +10 -1
  53. package/lib/utils.js +15 -1
  54. package/lib/warm-runner-manager-function.d.ts +18 -0
  55. package/lib/warm-runner-manager-function.js +24 -0
  56. package/lib/warm-runner-manager.lambda.d.ts +41 -0
  57. package/lib/warm-runner-manager.lambda.js +487 -0
  58. package/lib/warm-runner.d.ts +147 -0
  59. package/lib/warm-runner.js +210 -0
  60. package/lib/webhook-handler.lambda.js +5 -3
  61. package/lib/webhook-redelivery.lambda.js +17 -16
  62. package/lib/webhook.d.ts +4 -0
  63. package/lib/webhook.js +2 -1
  64. package/node_modules/cron-parser/LICENSE +21 -0
  65. package/node_modules/cron-parser/README.md +408 -0
  66. package/node_modules/cron-parser/dist/CronDate.js +518 -0
  67. package/node_modules/cron-parser/dist/CronExpression.js +520 -0
  68. package/node_modules/cron-parser/dist/CronExpressionParser.js +382 -0
  69. package/node_modules/cron-parser/dist/CronFieldCollection.js +371 -0
  70. package/node_modules/cron-parser/dist/CronFileParser.js +109 -0
  71. package/node_modules/cron-parser/dist/fields/CronDayOfMonth.js +44 -0
  72. package/node_modules/cron-parser/dist/fields/CronDayOfWeek.js +51 -0
  73. package/node_modules/cron-parser/dist/fields/CronField.js +214 -0
  74. package/node_modules/cron-parser/dist/fields/CronHour.js +40 -0
  75. package/node_modules/cron-parser/dist/fields/CronMinute.js +40 -0
  76. package/node_modules/cron-parser/dist/fields/CronMonth.js +44 -0
  77. package/node_modules/cron-parser/dist/fields/CronSecond.js +40 -0
  78. package/node_modules/cron-parser/dist/fields/index.js +24 -0
  79. package/node_modules/cron-parser/dist/fields/types.js +2 -0
  80. package/node_modules/cron-parser/dist/index.js +31 -0
  81. package/node_modules/cron-parser/dist/types/CronDate.d.ts +288 -0
  82. package/node_modules/cron-parser/dist/types/CronExpression.d.ts +118 -0
  83. package/node_modules/cron-parser/dist/types/CronExpressionParser.d.ts +70 -0
  84. package/node_modules/cron-parser/dist/types/CronFieldCollection.d.ts +153 -0
  85. package/node_modules/cron-parser/dist/types/CronFileParser.d.ts +30 -0
  86. package/node_modules/cron-parser/dist/types/fields/CronDayOfMonth.d.ts +25 -0
  87. package/node_modules/cron-parser/dist/types/fields/CronDayOfWeek.d.ts +30 -0
  88. package/node_modules/cron-parser/dist/types/fields/CronField.d.ts +130 -0
  89. package/node_modules/cron-parser/dist/types/fields/CronHour.d.ts +23 -0
  90. package/node_modules/cron-parser/dist/types/fields/CronMinute.d.ts +23 -0
  91. package/node_modules/cron-parser/dist/types/fields/CronMonth.d.ts +24 -0
  92. package/node_modules/cron-parser/dist/types/fields/CronSecond.d.ts +23 -0
  93. package/node_modules/cron-parser/dist/types/fields/index.d.ts +8 -0
  94. package/node_modules/cron-parser/dist/types/fields/types.d.ts +18 -0
  95. package/node_modules/cron-parser/dist/types/index.d.ts +8 -0
  96. package/node_modules/cron-parser/dist/types/utils/random.d.ts +10 -0
  97. package/node_modules/cron-parser/dist/utils/random.js +38 -0
  98. package/node_modules/cron-parser/package.json +117 -0
  99. package/node_modules/luxon/LICENSE.md +7 -0
  100. package/node_modules/luxon/README.md +55 -0
  101. package/node_modules/luxon/build/amd/luxon.js +8741 -0
  102. package/node_modules/luxon/build/amd/luxon.js.map +1 -0
  103. package/node_modules/luxon/build/cjs-browser/luxon.js +8739 -0
  104. package/node_modules/luxon/build/cjs-browser/luxon.js.map +1 -0
  105. package/node_modules/luxon/build/es6/luxon.mjs +8133 -0
  106. package/node_modules/luxon/build/es6/luxon.mjs.map +1 -0
  107. package/node_modules/luxon/build/global/luxon.js +8744 -0
  108. package/node_modules/luxon/build/global/luxon.js.map +1 -0
  109. package/node_modules/luxon/build/global/luxon.min.js +1 -0
  110. package/node_modules/luxon/build/global/luxon.min.js.map +1 -0
  111. package/node_modules/luxon/build/node/luxon.js +7792 -0
  112. package/node_modules/luxon/build/node/luxon.js.map +1 -0
  113. package/node_modules/luxon/package.json +87 -0
  114. package/node_modules/luxon/src/datetime.js +2603 -0
  115. package/node_modules/luxon/src/duration.js +1009 -0
  116. package/node_modules/luxon/src/errors.js +61 -0
  117. package/node_modules/luxon/src/impl/conversions.js +206 -0
  118. package/node_modules/luxon/src/impl/diff.js +95 -0
  119. package/node_modules/luxon/src/impl/digits.js +94 -0
  120. package/node_modules/luxon/src/impl/english.js +233 -0
  121. package/node_modules/luxon/src/impl/formats.js +176 -0
  122. package/node_modules/luxon/src/impl/formatter.js +434 -0
  123. package/node_modules/luxon/src/impl/invalid.js +14 -0
  124. package/node_modules/luxon/src/impl/locale.js +569 -0
  125. package/node_modules/luxon/src/impl/regexParser.js +335 -0
  126. package/node_modules/luxon/src/impl/tokenParser.js +505 -0
  127. package/node_modules/luxon/src/impl/util.js +330 -0
  128. package/node_modules/luxon/src/impl/zoneUtil.js +34 -0
  129. package/node_modules/luxon/src/info.js +205 -0
  130. package/node_modules/luxon/src/interval.js +669 -0
  131. package/node_modules/luxon/src/luxon.js +26 -0
  132. package/node_modules/luxon/src/package.json +4 -0
  133. package/node_modules/luxon/src/settings.js +180 -0
  134. package/node_modules/luxon/src/zone.js +97 -0
  135. package/node_modules/luxon/src/zones/IANAZone.js +235 -0
  136. package/node_modules/luxon/src/zones/fixedOffsetZone.js +150 -0
  137. package/node_modules/luxon/src/zones/invalidZone.js +53 -0
  138. package/node_modules/luxon/src/zones/systemZone.js +61 -0
  139. package/package.json +33 -24
@@ -0,0 +1,288 @@
1
+ export declare enum TimeUnit {
2
+ Second = "Second",
3
+ Minute = "Minute",
4
+ Hour = "Hour",
5
+ Day = "Day",
6
+ Month = "Month",
7
+ Year = "Year"
8
+ }
9
+ export declare enum DateMathOp {
10
+ Add = "Add",
11
+ Subtract = "Subtract"
12
+ }
13
+ export declare const DAYS_IN_MONTH: readonly number[];
14
+ /**
15
+ * CronDate class that wraps the Luxon DateTime object to provide
16
+ * a consistent API for working with dates and times in the context of cron.
17
+ */
18
+ export declare class CronDate {
19
+ #private;
20
+ /**
21
+ * Constructs a new CronDate instance.
22
+ * @param {CronDate | Date | number | string} [timestamp] - The timestamp to initialize the CronDate with.
23
+ * @param {string} [tz] - The timezone to use for the CronDate.
24
+ */
25
+ constructor(timestamp?: CronDate | Date | number | string, tz?: string);
26
+ /**
27
+ * Returns daylight savings start time.
28
+ * @returns {number | null}
29
+ */
30
+ get dstStart(): number | null;
31
+ /**
32
+ * Sets daylight savings start time.
33
+ * @param {number | null} value
34
+ */
35
+ set dstStart(value: number | null);
36
+ /**
37
+ * Returns daylight savings end time.
38
+ * @returns {number | null}
39
+ */
40
+ get dstEnd(): number | null;
41
+ /**
42
+ * Sets daylight savings end time.
43
+ * @param {number | null} value
44
+ */
45
+ set dstEnd(value: number | null);
46
+ /**
47
+ * Adds one year to the current CronDate.
48
+ */
49
+ addYear(): void;
50
+ /**
51
+ * Adds one month to the current CronDate.
52
+ */
53
+ addMonth(): void;
54
+ /**
55
+ * Adds one day to the current CronDate.
56
+ */
57
+ addDay(): void;
58
+ /**
59
+ * Adds one hour to the current CronDate.
60
+ */
61
+ addHour(): void;
62
+ /**
63
+ * Adds one minute to the current CronDate.
64
+ */
65
+ addMinute(): void;
66
+ /**
67
+ * Adds one second to the current CronDate.
68
+ */
69
+ addSecond(): void;
70
+ /**
71
+ * Subtracts one year from the current CronDate.
72
+ */
73
+ subtractYear(): void;
74
+ /**
75
+ * Subtracts one month from the current CronDate.
76
+ * If the month is 1, it will subtract one year instead.
77
+ */
78
+ subtractMonth(): void;
79
+ /**
80
+ * Subtracts one day from the current CronDate.
81
+ * If the day is 1, it will subtract one month instead.
82
+ */
83
+ subtractDay(): void;
84
+ /**
85
+ * Subtracts one hour from the current CronDate.
86
+ * If the hour is 0, it will subtract one day instead.
87
+ */
88
+ subtractHour(): void;
89
+ /**
90
+ * Subtracts one minute from the current CronDate.
91
+ * If the minute is 0, it will subtract one hour instead.
92
+ */
93
+ subtractMinute(): void;
94
+ /**
95
+ * Subtracts one second from the current CronDate.
96
+ * If the second is 0, it will subtract one minute instead.
97
+ */
98
+ subtractSecond(): void;
99
+ /**
100
+ * Adds a unit of time to the current CronDate.
101
+ * @param {TimeUnit} unit
102
+ */
103
+ addUnit(unit: TimeUnit): void;
104
+ /**
105
+ * Subtracts a unit of time from the current CronDate.
106
+ * @param {TimeUnit} unit
107
+ */
108
+ subtractUnit(unit: TimeUnit): void;
109
+ /**
110
+ * Handles a math operation.
111
+ * @param {DateMathOp} verb - {'add' | 'subtract'}
112
+ * @param {TimeUnit} unit - {'year' | 'month' | 'day' | 'hour' | 'minute' | 'second'}
113
+ */
114
+ invokeDateOperation(verb: DateMathOp, unit: TimeUnit): void;
115
+ /**
116
+ * Returns the day.
117
+ * @returns {number}
118
+ */
119
+ getDate(): number;
120
+ /**
121
+ * Returns the year.
122
+ * @returns {number}
123
+ */
124
+ getFullYear(): number;
125
+ /**
126
+ * Returns the day of the week.
127
+ * @returns {number}
128
+ */
129
+ getDay(): number;
130
+ /**
131
+ * Returns the month.
132
+ * @returns {number}
133
+ */
134
+ getMonth(): number;
135
+ /**
136
+ * Returns the hour.
137
+ * @returns {number}
138
+ */
139
+ getHours(): number;
140
+ /**
141
+ * Returns the minutes.
142
+ * @returns {number}
143
+ */
144
+ getMinutes(): number;
145
+ /**
146
+ * Returns the seconds.
147
+ * @returns {number}
148
+ */
149
+ getSeconds(): number;
150
+ /**
151
+ * Returns the milliseconds.
152
+ * @returns {number}
153
+ */
154
+ getMilliseconds(): number;
155
+ /**
156
+ * Returns the timezone offset from UTC in minutes (e.g. UTC+2 => 120).
157
+ * Useful for detecting DST transition days.
158
+ *
159
+ * @returns {number} UTC offset in minutes
160
+ */
161
+ getUTCOffset(): number;
162
+ /**
163
+ * Sets the time to the start of the day (00:00:00.000) in the current timezone.
164
+ */
165
+ setStartOfDay(): void;
166
+ /**
167
+ * Sets the time to the end of the day (23:59:59.999) in the current timezone.
168
+ */
169
+ setEndOfDay(): void;
170
+ /**
171
+ * Returns the time.
172
+ * @returns {number}
173
+ */
174
+ getTime(): number;
175
+ /**
176
+ * Returns the UTC day.
177
+ * @returns {number}
178
+ */
179
+ getUTCDate(): number;
180
+ /**
181
+ * Returns the UTC year.
182
+ * @returns {number}
183
+ */
184
+ getUTCFullYear(): number;
185
+ /**
186
+ * Returns the UTC day of the week.
187
+ * @returns {number}
188
+ */
189
+ getUTCDay(): number;
190
+ /**
191
+ * Returns the UTC month.
192
+ * @returns {number}
193
+ */
194
+ getUTCMonth(): number;
195
+ /**
196
+ * Returns the UTC hour.
197
+ * @returns {number}
198
+ */
199
+ getUTCHours(): number;
200
+ /**
201
+ * Returns the UTC minutes.
202
+ * @returns {number}
203
+ */
204
+ getUTCMinutes(): number;
205
+ /**
206
+ * Returns the UTC seconds.
207
+ * @returns {number}
208
+ */
209
+ getUTCSeconds(): number;
210
+ /**
211
+ * Returns the UTC milliseconds.
212
+ * @returns {string | null}
213
+ */
214
+ toISOString(): string | null;
215
+ /**
216
+ * Returns the date as a JSON string.
217
+ * @returns {string | null}
218
+ */
219
+ toJSON(): string | null;
220
+ /**
221
+ * Sets the day.
222
+ * @param d
223
+ */
224
+ setDate(d: number): void;
225
+ /**
226
+ * Sets the year.
227
+ * @param y
228
+ */
229
+ setFullYear(y: number): void;
230
+ /**
231
+ * Sets the day of the week.
232
+ * @param d
233
+ */
234
+ setDay(d: number): void;
235
+ /**
236
+ * Sets the month.
237
+ * @param m
238
+ */
239
+ setMonth(m: number): void;
240
+ /**
241
+ * Sets the hour.
242
+ * @param h
243
+ */
244
+ setHours(h: number): void;
245
+ /**
246
+ * Sets the minutes.
247
+ * @param m
248
+ */
249
+ setMinutes(m: number): void;
250
+ /**
251
+ * Sets the seconds.
252
+ * @param s
253
+ */
254
+ setSeconds(s: number): void;
255
+ /**
256
+ * Sets the milliseconds.
257
+ * @param s
258
+ */
259
+ setMilliseconds(s: number): void;
260
+ /**
261
+ * Returns the date as a string.
262
+ * @returns {string}
263
+ */
264
+ toString(): string;
265
+ /**
266
+ * Returns the date as a Date object.
267
+ * @returns {Date}
268
+ */
269
+ toDate(): Date;
270
+ /**
271
+ * Returns true if the day is the last day of the month.
272
+ * @returns {boolean}
273
+ */
274
+ isLastDayOfMonth(): boolean;
275
+ /**
276
+ * Returns true if the day is the last weekday of the month.
277
+ * @returns {boolean}
278
+ */
279
+ isLastWeekdayOfMonth(): boolean;
280
+ /**
281
+ * Primarily for internal use.
282
+ * @param {DateMathOp} op - The operation to perform.
283
+ * @param {TimeUnit} unit - The unit of time to use.
284
+ * @param {number} [hoursLength] - The length of the hours. Required when unit is not month or day.
285
+ */
286
+ applyDateOperation(op: DateMathOp, unit: TimeUnit, hoursLength?: number): void;
287
+ }
288
+ export default CronDate;
@@ -0,0 +1,118 @@
1
+ import { CronDate } from './CronDate';
2
+ import { CronFieldCollection } from './CronFieldCollection';
3
+ export type CronExpressionOptions = {
4
+ currentDate?: Date | string | number | CronDate;
5
+ endDate?: Date | string | number | CronDate;
6
+ startDate?: Date | string | number | CronDate;
7
+ tz?: string;
8
+ expression?: string;
9
+ hashSeed?: string;
10
+ strict?: boolean;
11
+ };
12
+ /**
13
+ * Error message for when the current date is outside the specified time span.
14
+ */
15
+ export declare const TIME_SPAN_OUT_OF_BOUNDS_ERROR_MESSAGE = "Out of the time span range";
16
+ /**
17
+ * Error message for when the loop limit is exceeded during iteration.
18
+ */
19
+ export declare const LOOPS_LIMIT_EXCEEDED_ERROR_MESSAGE = "Invalid expression, loop limit exceeded";
20
+ /**
21
+ * Class representing a Cron expression.
22
+ */
23
+ export declare class CronExpression {
24
+ #private;
25
+ /**
26
+ * Creates a new CronExpression instance.
27
+ *
28
+ * @param {CronFieldCollection} fields - Cron fields.
29
+ * @param {CronExpressionOptions} options - Parser options.
30
+ */
31
+ constructor(fields: CronFieldCollection, options: CronExpressionOptions);
32
+ /**
33
+ * Getter for the cron fields.
34
+ *
35
+ * @returns {CronFieldCollection} Cron fields.
36
+ */
37
+ get fields(): CronFieldCollection;
38
+ /**
39
+ * Converts cron fields back to a CronExpression instance.
40
+ *
41
+ * @public
42
+ * @param {Record<string, number[]>} fields - The input cron fields object.
43
+ * @param {CronExpressionOptions} [options] - Optional parsing options.
44
+ * @returns {CronExpression} - A new CronExpression instance.
45
+ */
46
+ static fieldsToExpression(fields: CronFieldCollection, options?: CronExpressionOptions): CronExpression;
47
+ /**
48
+ * Find the next scheduled date based on the cron expression.
49
+ * @returns {CronDate} - The next scheduled date or an ES6 compatible iterator object.
50
+ * @memberof CronExpression
51
+ * @public
52
+ */
53
+ next(): CronDate;
54
+ /**
55
+ * Find the previous scheduled date based on the cron expression.
56
+ * @returns {CronDate} - The previous scheduled date or an ES6 compatible iterator object.
57
+ * @memberof CronExpression
58
+ * @public
59
+ */
60
+ prev(): CronDate;
61
+ /**
62
+ * Check if there is a next scheduled date based on the current date and cron expression.
63
+ * @returns {boolean} - Returns true if there is a next scheduled date, false otherwise.
64
+ * @memberof CronExpression
65
+ * @public
66
+ */
67
+ hasNext(): boolean;
68
+ /**
69
+ * Check if there is a previous scheduled date based on the current date and cron expression.
70
+ * @returns {boolean} - Returns true if there is a previous scheduled date, false otherwise.
71
+ * @memberof CronExpression
72
+ * @public
73
+ */
74
+ hasPrev(): boolean;
75
+ /**
76
+ * Iterate over a specified number of steps and optionally execute a callback function for each step.
77
+ * @param {number} steps - The number of steps to iterate. Positive value iterates forward, negative value iterates backward.
78
+ * @returns {CronDate[]} - An array of iterator fields or CronDate objects.
79
+ * @memberof CronExpression
80
+ * @public
81
+ */
82
+ take(limit: number): CronDate[];
83
+ /**
84
+ * Reset the iterators current date to a new date or the initial date.
85
+ * @param {Date | CronDate} [newDate] - Optional new date to reset to. If not provided, it will reset to the initial date.
86
+ * @memberof CronExpression
87
+ * @public
88
+ */
89
+ reset(newDate?: Date | CronDate): void;
90
+ /**
91
+ * Generate a string representation of the cron expression.
92
+ * @param {boolean} [includeSeconds=false] - Whether to include the seconds field in the string representation.
93
+ * @returns {string} - The string representation of the cron expression.
94
+ * @memberof CronExpression
95
+ * @public
96
+ */
97
+ stringify(includeSeconds?: boolean): string;
98
+ /**
99
+ * Check if the cron expression includes the given date
100
+ * @param {Date|CronDate} date
101
+ * @returns {boolean}
102
+ */
103
+ includesDate(date: Date | CronDate): boolean;
104
+ /**
105
+ * Returns the string representation of the cron expression.
106
+ * @returns {CronDate} - The next schedule date.
107
+ */
108
+ toString(): string;
109
+ /**
110
+ * Returns an iterator for iterating through future CronDate instances
111
+ *
112
+ * @name Symbol.iterator
113
+ * @memberof CronExpression
114
+ * @returns {Iterator<CronDate>} An iterator object for CronExpression that returns CronDate values.
115
+ */
116
+ [Symbol.iterator](): Iterator<CronDate>;
117
+ }
118
+ export default CronExpression;
@@ -0,0 +1,70 @@
1
+ import { CronExpression, CronExpressionOptions } from './CronExpression';
2
+ export declare enum PredefinedExpressions {
3
+ '@yearly' = "0 0 0 1 1 *",
4
+ '@annually' = "0 0 0 1 1 *",
5
+ '@monthly' = "0 0 0 1 * *",
6
+ '@weekly' = "0 0 0 * * 0",
7
+ '@daily' = "0 0 0 * * *",
8
+ '@hourly' = "0 0 * * * *",
9
+ '@minutely' = "0 * * * * *",
10
+ '@secondly' = "* * * * * *",
11
+ '@weekdays' = "0 0 0 * * 1-5",
12
+ '@weekends' = "0 0 0 * * 0,6"
13
+ }
14
+ export declare enum CronUnit {
15
+ Second = "Second",
16
+ Minute = "Minute",
17
+ Hour = "Hour",
18
+ DayOfMonth = "DayOfMonth",
19
+ Month = "Month",
20
+ DayOfWeek = "DayOfWeek"
21
+ }
22
+ export declare enum Months {
23
+ jan = 1,
24
+ feb = 2,
25
+ mar = 3,
26
+ apr = 4,
27
+ may = 5,
28
+ jun = 6,
29
+ jul = 7,
30
+ aug = 8,
31
+ sep = 9,
32
+ oct = 10,
33
+ nov = 11,
34
+ dec = 12
35
+ }
36
+ export declare enum DayOfWeek {
37
+ sun = 0,
38
+ mon = 1,
39
+ tue = 2,
40
+ wed = 3,
41
+ thu = 4,
42
+ fri = 5,
43
+ sat = 6
44
+ }
45
+ export type RawCronFields = {
46
+ second: string;
47
+ minute: string;
48
+ hour: string;
49
+ dayOfMonth: string;
50
+ month: string;
51
+ dayOfWeek: string;
52
+ };
53
+ /**
54
+ * Static class that parses a cron expression and returns a CronExpression object.
55
+ * @static
56
+ * @class CronExpressionParser
57
+ */
58
+ export declare class CronExpressionParser {
59
+ #private;
60
+ /**
61
+ * Parses a cron expression and returns a CronExpression object.
62
+ * @param {string} expression - The cron expression to parse.
63
+ * @param {CronExpressionOptions} [options={}] - The options to use when parsing the expression.
64
+ * @param {boolean} [options.strict=false] - If true, will throw an error if the expression contains both dayOfMonth and dayOfWeek.
65
+ * @param {CronDate} [options.currentDate=new CronDate(undefined, 'UTC')] - The date to use when calculating the next/previous occurrence.
66
+ *
67
+ * @returns {CronExpression} A CronExpression object.
68
+ */
69
+ static parse(expression: string, options?: CronExpressionOptions): CronExpression;
70
+ }
@@ -0,0 +1,153 @@
1
+ import { CronSecond, CronMinute, CronHour, CronDayOfMonth, CronMonth, CronDayOfWeek, CronField, SerializedCronField, CronChars } from './fields';
2
+ import { SixtyRange, HourRange, DayOfMonthRange, MonthRange, DayOfWeekRange } from './fields/types';
3
+ export type FieldRange = {
4
+ start: number | CronChars;
5
+ count: number;
6
+ end?: number;
7
+ step?: number;
8
+ };
9
+ export type CronFields = {
10
+ second: CronSecond;
11
+ minute: CronMinute;
12
+ hour: CronHour;
13
+ dayOfMonth: CronDayOfMonth;
14
+ month: CronMonth;
15
+ dayOfWeek: CronDayOfWeek;
16
+ };
17
+ export type CronFieldOverride = {
18
+ second?: CronSecond | SixtyRange[];
19
+ minute?: CronMinute | SixtyRange[];
20
+ hour?: CronHour | HourRange[];
21
+ dayOfMonth?: CronDayOfMonth | DayOfMonthRange[];
22
+ month?: CronMonth | MonthRange[];
23
+ dayOfWeek?: CronDayOfWeek | DayOfWeekRange[];
24
+ };
25
+ export type SerializedCronFields = {
26
+ second: SerializedCronField;
27
+ minute: SerializedCronField;
28
+ hour: SerializedCronField;
29
+ dayOfMonth: SerializedCronField;
30
+ month: SerializedCronField;
31
+ dayOfWeek: SerializedCronField;
32
+ };
33
+ /**
34
+ * Represents a complete set of cron fields.
35
+ * @class CronFieldCollection
36
+ */
37
+ export declare class CronFieldCollection {
38
+ #private;
39
+ /**
40
+ * Creates a new CronFieldCollection instance by partially overriding fields from an existing one.
41
+ * @param {CronFieldCollection} base - The base CronFieldCollection to copy fields from
42
+ * @param {CronFieldOverride} fields - The fields to override, can be CronField instances or raw values
43
+ * @returns {CronFieldCollection} A new CronFieldCollection instance
44
+ * @example
45
+ * const base = new CronFieldCollection({
46
+ * second: new CronSecond([0]),
47
+ * minute: new CronMinute([0]),
48
+ * hour: new CronHour([12]),
49
+ * dayOfMonth: new CronDayOfMonth([1]),
50
+ * month: new CronMonth([1]),
51
+ * dayOfWeek: new CronDayOfWeek([1])
52
+ * });
53
+ *
54
+ * // Using CronField instances
55
+ * const modified1 = CronFieldCollection.from(base, {
56
+ * hour: new CronHour([15]),
57
+ * minute: new CronMinute([30])
58
+ * });
59
+ *
60
+ * // Using raw values
61
+ * const modified2 = CronFieldCollection.from(base, {
62
+ * hour: [15], // Will create new CronHour
63
+ * minute: [30] // Will create new CronMinute
64
+ * });
65
+ */
66
+ static from(base: CronFieldCollection, fields: CronFieldOverride): CronFieldCollection;
67
+ /**
68
+ * Resolves a field value, either using the provided CronField instance or creating a new one from raw values.
69
+ * @param constructor - The constructor for creating new field instances
70
+ * @param baseField - The base field to use if no override is provided
71
+ * @param fieldValue - The override value, either a CronField instance or raw values
72
+ * @returns The resolved CronField instance
73
+ * @private
74
+ */
75
+ private static resolveField;
76
+ /**
77
+ * CronFieldCollection constructor. Initializes the cron fields with the provided values.
78
+ * @param {CronFields} param0 - The cron fields values
79
+ * @throws {Error} if validation fails
80
+ * @example
81
+ * const cronFields = new CronFieldCollection({
82
+ * second: new CronSecond([0]),
83
+ * minute: new CronMinute([0, 30]),
84
+ * hour: new CronHour([9]),
85
+ * dayOfMonth: new CronDayOfMonth([15]),
86
+ * month: new CronMonth([1]),
87
+ * dayOfWeek: new CronDayOfTheWeek([1, 2, 3, 4, 5]),
88
+ * })
89
+ *
90
+ * console.log(cronFields.second.values); // [0]
91
+ * console.log(cronFields.minute.values); // [0, 30]
92
+ * console.log(cronFields.hour.values); // [9]
93
+ * console.log(cronFields.dayOfMonth.values); // [15]
94
+ * console.log(cronFields.month.values); // [1]
95
+ * console.log(cronFields.dayOfWeek.values); // [1, 2, 3, 4, 5]
96
+ */
97
+ constructor({ second, minute, hour, dayOfMonth, month, dayOfWeek }: CronFields);
98
+ /**
99
+ * Returns the second field.
100
+ * @returns {CronSecond}
101
+ */
102
+ get second(): CronSecond;
103
+ /**
104
+ * Returns the minute field.
105
+ * @returns {CronMinute}
106
+ */
107
+ get minute(): CronMinute;
108
+ /**
109
+ * Returns the hour field.
110
+ * @returns {CronHour}
111
+ */
112
+ get hour(): CronHour;
113
+ /**
114
+ * Returns the day of the month field.
115
+ * @returns {CronDayOfMonth}
116
+ */
117
+ get dayOfMonth(): CronDayOfMonth;
118
+ /**
119
+ * Returns the month field.
120
+ * @returns {CronMonth}
121
+ */
122
+ get month(): CronMonth;
123
+ /**
124
+ * Returns the day of the week field.
125
+ * @returns {CronDayOfWeek}
126
+ */
127
+ get dayOfWeek(): CronDayOfWeek;
128
+ /**
129
+ * Returns a string representation of the cron fields.
130
+ * @param {(number | CronChars)[]} input - The cron fields values
131
+ * @static
132
+ * @returns {FieldRange[]} - The compacted cron fields
133
+ */
134
+ static compactField(input: (number | CronChars)[]): FieldRange[];
135
+ /**
136
+ * Returns a string representation of the cron fields.
137
+ * @param {CronField} field - The cron field to stringify
138
+ * @static
139
+ * @returns {string} - The stringified cron field
140
+ */
141
+ stringifyField(field: CronField): string;
142
+ /**
143
+ * Returns a string representation of the cron field values.
144
+ * @param {boolean} includeSeconds - Whether to include seconds in the output
145
+ * @returns {string} The formatted cron string
146
+ */
147
+ stringify(includeSeconds?: boolean): string;
148
+ /**
149
+ * Returns a serialized representation of the cron fields values.
150
+ * @returns {SerializedCronFields} An object containing the cron field values
151
+ */
152
+ serialize(): SerializedCronFields;
153
+ }
@@ -0,0 +1,30 @@
1
+ import { CronExpression } from './CronExpression';
2
+ export type CronFileParserResult = {
3
+ variables: {
4
+ [key: string]: string;
5
+ };
6
+ expressions: CronExpression[];
7
+ errors: {
8
+ [key: string]: unknown;
9
+ };
10
+ };
11
+ /**
12
+ * Parser for crontab files that handles both synchronous and asynchronous operations.
13
+ */
14
+ export declare class CronFileParser {
15
+ #private;
16
+ /**
17
+ * Parse a crontab file asynchronously
18
+ * @param filePath Path to crontab file
19
+ * @returns Promise resolving to parse results
20
+ * @throws If file cannot be read
21
+ */
22
+ static parseFile(filePath: string): Promise<CronFileParserResult>;
23
+ /**
24
+ * Parse a crontab file synchronously
25
+ * @param filePath Path to crontab file
26
+ * @returns Parse results
27
+ * @throws If file cannot be read
28
+ */
29
+ static parseFileSync(filePath: string): CronFileParserResult;
30
+ }
@@ -0,0 +1,25 @@
1
+ import { CronField, CronFieldOptions } from './CronField';
2
+ import { CronChars, CronMax, CronMin, DayOfMonthRange } from './types';
3
+ /**
4
+ * Represents the "day of the month" field within a cron expression.
5
+ * @class CronDayOfMonth
6
+ * @extends CronField
7
+ */
8
+ export declare class CronDayOfMonth extends CronField {
9
+ static get min(): CronMin;
10
+ static get max(): CronMax;
11
+ static get chars(): CronChars[];
12
+ static get validChars(): RegExp;
13
+ /**
14
+ * CronDayOfMonth constructor. Initializes the "day of the month" field with the provided values.
15
+ * @param {DayOfMonthRange[]} values - Values for the "day of the month" field
16
+ * @param {CronFieldOptions} [options] - Options provided by the parser
17
+ * @throws {Error} if validation fails
18
+ */
19
+ constructor(values: DayOfMonthRange[], options?: CronFieldOptions);
20
+ /**
21
+ * Returns an array of allowed values for the "day of the month" field.
22
+ * @returns {DayOfMonthRange[]}
23
+ */
24
+ get values(): DayOfMonthRange[];
25
+ }