@geekmidas/constructs 9.2.1 → 9.3.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 (46) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +1 -1
  3. package/dist/{AWSScheduledFunction-DPMzOjZP.d.cts → AWSScheduledFunction-DAGP_vz5.d.cts} +43 -11
  4. package/dist/AWSScheduledFunction-DAGP_vz5.d.cts.map +1 -0
  5. package/dist/{AWSScheduledFunction-a6hRp3nk.d.mts → AWSScheduledFunction-Dg6TPIxn.d.mts} +42 -10
  6. package/dist/AWSScheduledFunction-Dg6TPIxn.d.mts.map +1 -0
  7. package/dist/{Endpoint-nhjtdDL3.d.cts → Endpoint-CxBdXNZm.d.cts} +2 -2
  8. package/dist/{Endpoint-nhjtdDL3.d.cts.map → Endpoint-CxBdXNZm.d.cts.map} +1 -1
  9. package/dist/Endpoint-DEydLuBs.d.mts.map +1 -1
  10. package/dist/adaptors/aws.d.cts +3 -3
  11. package/dist/adaptors/aws.d.mts +1 -1
  12. package/dist/adaptors/hono.d.cts +2 -2
  13. package/dist/adaptors/testing.d.cts +2 -2
  14. package/dist/crons/index.cjs +4 -0
  15. package/dist/crons/index.cjs.map +1 -1
  16. package/dist/crons/index.d.cts +12 -8
  17. package/dist/crons/index.d.cts.map +1 -1
  18. package/dist/crons/index.d.mts +7 -3
  19. package/dist/crons/index.d.mts.map +1 -1
  20. package/dist/crons/index.mjs +4 -0
  21. package/dist/crons/index.mjs.map +1 -1
  22. package/dist/endpoints/index.d.cts +4 -4
  23. package/dist/functions/index.d.cts +1 -1
  24. package/dist/{index-CXpim5mV.d.cts → index-CeoLMr7c.d.cts} +5 -5
  25. package/dist/{index-CXpim5mV.d.cts.map → index-CeoLMr7c.d.cts.map} +1 -1
  26. package/dist/monitors/index.cjs +1 -1
  27. package/dist/monitors/index.cjs.map +1 -1
  28. package/dist/monitors/index.d.cts +1 -1
  29. package/dist/monitors/index.d.mts +1 -1
  30. package/dist/monitors/index.mjs +1 -1
  31. package/dist/monitors/index.mjs.map +1 -1
  32. package/dist/queue/index.d.cts +2 -2
  33. package/dist/subscribers/index.d.cts +2 -2
  34. package/package.json +22 -22
  35. package/src/__tests__/Construct.environment.spec.ts +2 -2
  36. package/src/__tests__/builder-reuse.spec.ts +2 -2
  37. package/src/__tests__/monitor.spec.ts +16 -16
  38. package/src/crons/Cron.ts +187 -60
  39. package/src/crons/CronBuilder.ts +10 -4
  40. package/src/crons/__tests__/AWSScheduledFunction.spec.ts +8 -6
  41. package/src/crons/__tests__/Cron.spec.ts +53 -91
  42. package/src/crons/__tests__/CronBuilder.state-isolation.spec.ts +28 -28
  43. package/src/crons/index.ts +2 -1
  44. package/src/monitors/heartbeat.ts +1 -1
  45. package/dist/AWSScheduledFunction-DPMzOjZP.d.cts.map +0 -1
  46. package/dist/AWSScheduledFunction-a6hRp3nk.d.mts.map +0 -1
package/src/crons/Cron.ts CHANGED
@@ -73,45 +73,94 @@ export class Cron<
73
73
  }
74
74
  }
75
75
 
76
- export type RateExpression = `rate(${string})`;
76
+ // ---- Cron expression types ------------------------------------------------
77
+ //
78
+ // `.schedule()` takes a `cron(…)` in either of two dialects, told apart by the
79
+ // field count, and checks each by its own rules:
80
+ //
81
+ // - Unix, five fields: `min hour day-of-month month day-of-week`, with
82
+ // day-of-week 0–7 (SUN = 0 or 7) and no `?`.
83
+ // - AWS, six fields: `min hour day-of-month month day-of-week year`, with
84
+ // day-of-week 1–7 (SUN = 1), `?` in exactly one day field, and `L`, `W`
85
+ // and `#` where EventBridge allows them.
86
+ //
87
+ // The types are generic because a plain union of every field's forms is too
88
+ // large for TypeScript, so the literal is checked field by field instead.
89
+ // `@geekmidas/manifest`'s `parseCron` applies the same rules at build time.
77
90
 
78
- type CronMinute =
79
- | '*'
80
- | number
81
- | `${number}`
82
- | `${number}-${number}`
83
- | `${number}/${number}`
84
- | `*/${number}`
85
- | `${number},${number}`
86
- | string; // Allow more complex patterns
87
-
88
- type CronHour =
89
- | '*'
90
- | number
91
- | `${number}`
92
- | `${number}-${number}`
93
- | `${number}/${number}`
94
- | `*/${number}`
95
- | `${number},${number}`
96
- | string; // Allow more complex patterns
97
-
98
- type CronDay =
99
- | '*'
100
- | number
101
- | `${number}`
102
- | `${number}-${number}`
103
- | `${number}/${number}`
104
- | `*/${number}`
105
- | `${number},${number}`
106
- | string; // Allow more complex patterns
107
-
108
- type CronMonth =
109
- | '*'
110
- | number
111
- | `${number}`
112
- | `${number}-${number}`
113
- | `${number}/${number}`
114
- | `*/${number}`
91
+ type Digit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';
92
+
93
+ /** `'0'`…`'99'`, with an optional leading zero (`'08'`). */
94
+ type UpTo99 = Digit | `${Digit}${Digit}`;
95
+
96
+ type ToNumber<S extends string> = S extends `0${infer R extends `${number}`}`
97
+ ? R extends ''
98
+ ? 0
99
+ : ToNumber<R>
100
+ : S extends `${infer N extends number}`
101
+ ? N
102
+ : never;
103
+
104
+ type Range<
105
+ N extends number,
106
+ Acc extends number[] = [],
107
+ > = Acc['length'] extends N ? Acc[number] : Range<N, [...Acc, Acc['length']]>;
108
+
109
+ /** Numbers from `Min` to `Max` inclusive. */
110
+ type Between<Min extends number, Max extends number> =
111
+ | Exclude<Range<Max>, Range<Min>>
112
+ | Max;
113
+
114
+ /** A single value: a number in range, or one of the field's names. */
115
+ type IsValue<
116
+ S extends string,
117
+ Min extends number,
118
+ Max extends number,
119
+ Names extends string,
120
+ > = S extends Names
121
+ ? true
122
+ : S extends UpTo99
123
+ ? ToNumber<S> extends Between<Min, Max>
124
+ ? true
125
+ : false
126
+ : false;
127
+
128
+ /** `v`, `a-b` or `*`, with an optional `/step`. */
129
+ type IsAtom<
130
+ S extends string,
131
+ Min extends number,
132
+ Max extends number,
133
+ Names extends string,
134
+ > = S extends `${infer Base}/${infer Step}`
135
+ ? Step extends UpTo99
136
+ ? Base extends '*'
137
+ ? true
138
+ : IsAtom<Base, Min, Max, Names>
139
+ : false
140
+ : S extends '*'
141
+ ? true
142
+ : S extends `${infer A}-${infer B}`
143
+ ? [IsValue<A, Min, Max, Names>, IsValue<B, Min, Max, Names>] extends [
144
+ true,
145
+ true,
146
+ ]
147
+ ? true
148
+ : false
149
+ : IsValue<S, Min, Max, Names>;
150
+
151
+ /** A comma-separated list of atoms. */
152
+ type IsField<
153
+ S extends string,
154
+ Min extends number,
155
+ Max extends number,
156
+ Names extends string = never,
157
+ > = S extends `${infer Head},${infer Rest}`
158
+ ? IsAtom<Head, Min, Max, Names> extends true
159
+ ? IsField<Rest, Min, Max, Names>
160
+ : false
161
+ : IsAtom<S, Min, Max, Names>;
162
+
163
+ type MonthName =
115
164
  | 'JAN'
116
165
  | 'FEB'
117
166
  | 'MAR'
@@ -123,27 +172,105 @@ type CronMonth =
123
172
  | 'SEP'
124
173
  | 'OCT'
125
174
  | 'NOV'
126
- | 'DEC'
127
- | string; // Allow more complex patterns
175
+ | 'DEC';
176
+ type DayName = 'SUN' | 'MON' | 'TUE' | 'WED' | 'THU' | 'FRI' | 'SAT';
128
177
 
129
- type CronWeekday =
178
+ type AllTrue<T extends boolean[]> = T extends true[] ? true : false;
179
+
180
+ type IsUnix<S extends string> =
181
+ S extends `${infer Mi} ${infer H} ${infer Dom} ${infer Mo} ${infer Dow}`
182
+ ? AllTrue<
183
+ [
184
+ IsField<Mi, 0, 59>,
185
+ IsField<H, 0, 23>,
186
+ IsField<Dom, 1, 31>,
187
+ IsField<Mo, 1, 12, MonthName>,
188
+ IsField<Dow, 0, 7, DayName>,
189
+ ]
190
+ >
191
+ : false;
192
+
193
+ type IsAwsDayOfMonth<S extends string> = S extends 'L' | `L-${UpTo99}` | 'LW'
194
+ ? true
195
+ : S extends `${infer D}W`
196
+ ? IsValue<D, 1, 31, never>
197
+ : IsField<S, 1, 31>;
198
+
199
+ type IsAwsDayOfWeek<S extends string> = S extends `${infer D}L`
200
+ ? IsValue<D, 1, 7, DayName>
201
+ : S extends `${infer D}#${infer N}`
202
+ ? AllTrue<[IsValue<D, 1, 7, DayName>, IsValue<N, 1, 5, never>]>
203
+ : IsField<S, 1, 7, DayName>;
204
+
205
+ /** 1970–2199, EventBridge's range. */
206
+ type Year = `19${'7' | '8' | '9'}${Digit}` | `${'20' | '21'}${Digit}${Digit}`;
207
+
208
+ type IsYearAtom<S extends string> = S extends
130
209
  | '*'
131
- | number
132
- | `${number}`
133
- | `${number}-${number}`
134
- | `${number}/${number}`
135
- | `*/${number}`
136
- | 'SUN'
137
- | 'MON'
138
- | 'TUE'
139
- | 'WED'
140
- | 'THU'
141
- | 'FRI'
142
- | 'SAT'
143
- | `${string}-${string}` // Allow patterns like MON-FRI
144
- | string; // Allow more complex patterns
145
-
146
- export type CronExpression =
147
- `cron(${CronMinute} ${CronHour} ${CronDay} ${CronMonth} ${CronWeekday})`;
148
-
149
- export type ScheduleExpression = RateExpression | CronExpression;
210
+ | Year
211
+ | `${'*' | Year}/${UpTo99}`
212
+ | `${Year}-${Year}`
213
+ ? true
214
+ : false;
215
+
216
+ type IsAwsYear<S extends string> = S extends `${infer Head},${infer Rest}`
217
+ ? IsYearAtom<Head> extends true
218
+ ? IsAwsYear<Rest>
219
+ : false
220
+ : IsYearAtom<S>;
221
+
222
+ type IsAws<S extends string> =
223
+ S extends `${infer Mi} ${infer H} ${infer Dom} ${infer Mo} ${infer Dow} ${infer Y}`
224
+ ? AllTrue<
225
+ [
226
+ IsField<Mi, 0, 59>,
227
+ IsField<H, 0, 23>,
228
+ IsField<Mo, 1, 12, MonthName>,
229
+ IsAwsYear<Y>,
230
+ Dom extends '?'
231
+ ? Dow extends '?'
232
+ ? false
233
+ : IsAwsDayOfWeek<Dow>
234
+ : Dow extends '?'
235
+ ? IsAwsDayOfMonth<Dom>
236
+ : false,
237
+ ]
238
+ >
239
+ : false;
240
+
241
+ /** `T` when it is a valid five-field Unix `cron(…)`. */
242
+ export type UnixCronExpression<T extends string> = T extends `cron(${infer S})`
243
+ ? IsUnix<S> extends true
244
+ ? T
245
+ : never
246
+ : never;
247
+
248
+ /** `T` when it is a valid six-field AWS (EventBridge) `cron(…)`. */
249
+ export type AwsCronExpression<T extends string> = T extends `cron(${infer S})`
250
+ ? IsAws<S> extends true
251
+ ? T
252
+ : never
253
+ : never;
254
+
255
+ /**
256
+ * `T` when it is a valid cron expression in either dialect, otherwise a
257
+ * message saying what's expected. A schedule built at runtime can be cast to
258
+ * {@link ScheduleExpression}, which `gkm build` then checks.
259
+ */
260
+ export type CronExpression<T extends string> = [T] extends [ScheduleExpression]
261
+ ? [ScheduleExpression] extends [T]
262
+ ? T
263
+ : CheckedCronExpression<T>
264
+ : CheckedCronExpression<T>;
265
+
266
+ type CheckedCronExpression<T extends string> = [
267
+ UnixCronExpression<T> | AwsCronExpression<T>,
268
+ ] extends [never]
269
+ ? 'Expected cron(…) with 5 fields (Unix) or 6 fields (AWS)'
270
+ : T;
271
+
272
+ /**
273
+ * A cron's schedule once set. Literals are checked by {@link CronExpression};
274
+ * every schedule is checked again by `gkm build`.
275
+ */
276
+ export type ScheduleExpression = `cron(${string})`;
@@ -7,7 +7,7 @@ import uniqBy from 'lodash.uniqby';
7
7
  import { ConstructType } from '../Construct';
8
8
  import { cloneWith } from '../clone';
9
9
  import { FunctionBuilder, type FunctionHandler } from '../functions';
10
- import { Cron, type ScheduleExpression } from './Cron';
10
+ import { Cron, type CronExpression, type ScheduleExpression } from './Cron';
11
11
 
12
12
  export class CronBuilder<
13
13
  TInput extends ComposableStandardSchema,
@@ -40,8 +40,12 @@ export class CronBuilder<
40
40
  return cloneWith(this, { _memorySize: memorySize });
41
41
  }
42
42
 
43
- schedule(
44
- _expression: ScheduleExpression,
43
+ /**
44
+ * When the cron runs: a five-field Unix `cron(…)` or a six-field AWS one.
45
+ * `gkm build` writes it to the manifest in the AWS form.
46
+ */
47
+ schedule<const T extends string>(
48
+ _expression: CronExpression<T>,
45
49
  ): CronBuilder<
46
50
  TInput,
47
51
  TServices,
@@ -52,7 +56,9 @@ export class CronBuilder<
52
56
  TDatabase,
53
57
  TDatabaseServiceName
54
58
  > {
55
- return cloneWith(this, { _schedule: _expression });
59
+ return cloneWith(this, {
60
+ _schedule: _expression as ScheduleExpression,
61
+ });
56
62
  }
57
63
 
58
64
  override input<T extends ComposableStandardSchema>(
@@ -77,9 +77,11 @@ describe('AWSScheduledFunction', () => {
77
77
 
78
78
  it('runs the cron handler on a scheduled event', async () => {
79
79
  const ran = vi.fn();
80
- const cron = new CronBuilder().schedule('rate(1 day)').handle(async () => {
81
- ran();
82
- });
80
+ const cron = new CronBuilder()
81
+ .schedule('cron(0 0 * * *)')
82
+ .handle(async () => {
83
+ ran();
84
+ });
83
85
 
84
86
  const adapter = new AWSScheduledFunction(envParser, cron);
85
87
  const result = await adapter.handler(
@@ -96,7 +98,7 @@ describe('AWSScheduledFunction', () => {
96
98
 
97
99
  it('parses and returns output when the cron declares an output schema', async () => {
98
100
  const cron = new CronBuilder()
99
- .schedule('rate(1 day)')
101
+ .schedule('cron(0 0 * * *)')
100
102
  .output(z.object({ cancelled: z.number() }))
101
103
  .handle(async () => ({ cancelled: 3 }));
102
104
 
@@ -113,7 +115,7 @@ describe('AWSScheduledFunction', () => {
113
115
  it('exposes services to the cron handler', async () => {
114
116
  let observed = 0;
115
117
  const cron = new CronBuilder()
116
- .schedule('rate(1 hour)')
118
+ .schedule('cron(0 * * * *)')
117
119
  .services([new CounterService()])
118
120
  .handle(async ({ services }) => {
119
121
  observed = services.counter.increment();
@@ -134,7 +136,7 @@ describe('AWSScheduledFunction', () => {
134
136
  const logger = makeSpyLogger();
135
137
 
136
138
  const cron = new CronBuilder()
137
- .schedule('rate(1 day)')
139
+ .schedule('cron(0 0 * * *)')
138
140
  .logger(logger)
139
141
  .handle(async () => {
140
142
  hadContext = serviceContext.hasContext();
@@ -3,7 +3,7 @@ import type { Service } from '@geekmidas/services';
3
3
  import { describe, expect, it, vi } from 'vitest';
4
4
  import { z } from 'zod';
5
5
  import { ConstructType } from '../../Construct';
6
- import { Cron, type CronExpression, type RateExpression } from '../Cron';
6
+ import { Cron, type ScheduleExpression } from '../Cron';
7
7
  import { CronBuilder } from '../CronBuilder';
8
8
 
9
9
  // Mock service for testing
@@ -41,7 +41,7 @@ describe('Cron', () => {
41
41
 
42
42
  it('should create a Cron instance with schedule expression', () => {
43
43
  const handler = vi.fn();
44
- const schedule: CronExpression = 'cron(0 12 * * MON)';
44
+ const schedule: ScheduleExpression = 'cron(0 12 * * MON)';
45
45
  const cron = new Cron(handler, undefined, schedule);
46
46
 
47
47
  expect(cron).toBeInstanceOf(Cron);
@@ -134,7 +134,7 @@ describe('Cron', () => {
134
134
  it('should create a Cron with all parameters', () => {
135
135
  const inputSchema = z.object({ name: z.string() });
136
136
  const outputSchema = z.object({ greeting: z.string() });
137
- const schedule: RateExpression = 'rate(5 minutes)';
137
+ const schedule: ScheduleExpression = 'cron(*/5 * * * *)';
138
138
  const timeout = 60000;
139
139
  const service = new MockService();
140
140
  const logger = new ConsoleLogger();
@@ -207,7 +207,7 @@ describe('Cron', () => {
207
207
 
208
208
  it('should set schedule with schedule() method', () => {
209
209
  const builder = new CronBuilder();
210
- const schedule: CronExpression = 'cron(0 0 * * SUN)';
210
+ const schedule: ScheduleExpression = 'cron(0 0 * * SUN)';
211
211
 
212
212
  const result = builder.schedule(schedule);
213
213
 
@@ -231,7 +231,7 @@ describe('Cron', () => {
231
231
  it('should build Cron with full builder chain', () => {
232
232
  const inputSchema = z.object({ task: z.string() });
233
233
  const outputSchema = z.object({ completed: z.boolean() });
234
- const schedule: RateExpression = 'rate(1 hour)';
234
+ const schedule: ScheduleExpression = 'cron(0 * * * *)';
235
235
  const service = new MockService();
236
236
  const logger = new ConsoleLogger();
237
237
 
@@ -259,7 +259,7 @@ describe('Cron', () => {
259
259
 
260
260
  it('should support method chaining in any order', () => {
261
261
  const builder = new CronBuilder();
262
- const schedule: CronExpression = 'cron(30 2 * * TUE)';
262
+ const schedule: ScheduleExpression = 'cron(30 2 * * TUE)';
263
263
 
264
264
  const chained = builder
265
265
  .timeout(30000)
@@ -274,90 +274,52 @@ describe('Cron', () => {
274
274
  });
275
275
 
276
276
  describe('Schedule Expression Types', () => {
277
- it('should accept valid rate expressions', () => {
278
- const validRates: RateExpression[] = [
279
- 'rate(5 minutes)',
280
- 'rate(1 hour)',
281
- 'rate(7 days)',
282
- 'rate(30 seconds)',
283
- 'rate(2 weeks)',
284
- ];
285
-
286
- validRates.forEach((rate) => {
287
- const builder = new CronBuilder();
288
- expect(() => builder.schedule(rate)).not.toThrow();
289
- });
290
- });
291
-
292
- it('should accept valid cron expressions', () => {
293
- const validCrons: CronExpression[] = [
294
- 'cron(0 12 * * MON)',
295
- 'cron(15 10 * * FRI)',
296
- 'cron(0 0 1 JAN SUN)',
297
- 'cron(*/5 * * * *)',
298
- 'cron(0 0-23/2 * * *)',
299
- 'cron(30 4 1,15 * *)',
300
- 'cron(0 12 * DEC MON)',
301
- ];
302
-
303
- validCrons.forEach((cron) => {
304
- const builder = new CronBuilder();
305
- expect(() => builder.schedule(cron)).not.toThrow();
306
- });
307
- });
308
-
309
- it('should work with complex cron patterns', () => {
310
- const complexPatterns: CronExpression[] = [
311
- 'cron(*/15 * * * *)', // Every 15 minutes
312
- 'cron(0 */4 * * *)', // Every 4 hours
313
- 'cron(0 9-17 * * MON-FRI)', // Every hour 9-5 on weekdays
314
- 'cron(0 0 1-7 * SUN)', // First Sunday of month
315
- 'cron(*/30 8-18 * * *)', // Every 30 min during business hours
316
- ];
317
-
318
- complexPatterns.forEach((pattern) => {
319
- const builder = new CronBuilder();
320
- expect(() => builder.schedule(pattern)).not.toThrow();
321
- });
322
- });
323
-
324
- it('should handle all month names', () => {
325
- const months: CronExpression[] = [
326
- 'cron(0 0 1 JAN *)',
327
- 'cron(0 0 1 FEB *)',
328
- 'cron(0 0 1 MAR *)',
329
- 'cron(0 0 1 APR *)',
330
- 'cron(0 0 1 MAY *)',
331
- 'cron(0 0 1 JUN *)',
332
- 'cron(0 0 1 JUL *)',
333
- 'cron(0 0 1 AUG *)',
334
- 'cron(0 0 1 SEP *)',
335
- 'cron(0 0 1 OCT *)',
336
- 'cron(0 0 1 NOV *)',
337
- 'cron(0 0 1 DEC *)',
338
- ];
339
-
340
- months.forEach((expression) => {
341
- const builder = new CronBuilder();
342
- expect(() => builder.schedule(expression)).not.toThrow();
343
- });
344
- });
345
-
346
- it('should handle all weekday names', () => {
347
- const weekdays: CronExpression[] = [
348
- 'cron(0 0 * * SUN)',
349
- 'cron(0 0 * * MON)',
350
- 'cron(0 0 * * TUE)',
351
- 'cron(0 0 * * WED)',
352
- 'cron(0 0 * * THU)',
353
- 'cron(0 0 * * FRI)',
354
- 'cron(0 0 * * SAT)',
355
- ];
356
-
357
- weekdays.forEach((expression) => {
358
- const builder = new CronBuilder();
359
- expect(() => builder.schedule(expression)).not.toThrow();
360
- });
277
+ it('accepts Unix and AWS literals and rejects invalid ones', () => {
278
+ const c = new CronBuilder();
279
+
280
+ c.schedule('cron(0 8 * * *)');
281
+ c.schedule('cron(0 9 * * MON-FRI)');
282
+ c.schedule('cron(0 9 1 * MON)');
283
+ c.schedule('cron(0 0 * * 7)');
284
+ c.schedule('cron(0 8 * * ? *)');
285
+ c.schedule('cron(0 9 ? * MON-FRI *)');
286
+ c.schedule('cron(0 9 L * ? *)');
287
+ c.schedule('cron(0 9 15W * ? *)');
288
+ c.schedule('cron(0 9 ? * 6#3 *)');
289
+ c.schedule('cron(0 9 ? * FRIL 2026-2027)');
290
+
291
+ // @ts-expect-error 4 fields
292
+ c.schedule('cron(0 8 * *)');
293
+ // @ts-expect-error 7 fields
294
+ c.schedule('cron(0 0 8 * * ? *)');
295
+ // @ts-expect-error `?` is AWS, not Unix
296
+ c.schedule('cron(0 8 * * ?)');
297
+ // @ts-expect-error AWS needs `?` in one day field
298
+ c.schedule('cron(0 8 * * * *)');
299
+ // @ts-expect-error AWS with `?` in both day fields
300
+ c.schedule('cron(0 8 ? * ? *)');
301
+ // @ts-expect-error AWS with both day fields restricted
302
+ c.schedule('cron(0 9 1 * MON *)');
303
+ // @ts-expect-error AWS day-of-week is 1-7
304
+ c.schedule('cron(0 9 ? * 0 *)');
305
+ // @ts-expect-error hour 25
306
+ c.schedule('cron(0 25 * * *)');
307
+ // @ts-expect-error minute 60
308
+ c.schedule('cron(60 * * * ? *)');
309
+ // @ts-expect-error `L` is AWS only
310
+ c.schedule('cron(0 9 L * *)');
311
+ // @ts-expect-error rate() is not supported
312
+ c.schedule('rate(1 day)');
313
+ // @ts-expect-error double space
314
+ c.schedule('cron(0 8 * * *)');
315
+ // @ts-expect-error not a month
316
+ c.schedule('cron(0 8 * FOO *)');
317
+ // @ts-expect-error a year before 1970
318
+ c.schedule('cron(0 8 * * ? 1969)');
319
+ // @ts-expect-error a plain string needs a cast
320
+ c.schedule('cron(0 8 * * *)' as string);
321
+ // A runtime schedule cast to ScheduleExpression is checked at build.
322
+ c.schedule('cron(0 8 * * *)' as ScheduleExpression);
361
323
  });
362
324
  });
363
325
 
@@ -454,7 +416,7 @@ describe('Cron', () => {
454
416
 
455
417
  const cron1 = new CronBuilder()
456
418
  .timeout(1000)
457
- .schedule('rate(5 minutes)')
419
+ .schedule('cron(*/5 * * * *)')
458
420
  .handle(handler1);
459
421
 
460
422
  const cron2 = new CronBuilder()