stacks 0.58.50 → 0.58.52
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/core/actions/dist/src/deploy/index.js +2 -2
- package/core/actions/dist/src/upgrade.js +1 -1
- package/core/actions/package.json +1 -1
- package/core/actions/src/build/cli.ts +1 -1
- package/core/actions/src/build/server.ts +9 -0
- package/core/actions/src/deploy/index.ts +2 -2
- package/core/actions/tsconfig.json +3 -0
- package/core/ai/package.json +1 -1
- package/core/ai/tsconfig.json +3 -0
- package/core/alias/package.json +1 -1
- package/core/alias/tsconfig.json +3 -0
- package/core/analytics/package.json +1 -1
- package/core/analytics/tsconfig.json +3 -0
- package/core/api/package.json +1 -1
- package/core/api/tsconfig.json +3 -0
- package/core/arrays/package.json +1 -1
- package/core/arrays/tsconfig.json +3 -0
- package/core/auth/package.json +1 -1
- package/core/auth/tsconfig.json +3 -0
- package/core/buddy/dist/{chunk-91084836e95161e8.js → chunk-d52e40a990b45728.js} +152 -84
- package/core/buddy/dist/cli.js +4 -1
- package/core/buddy/dist/index.js +3 -1
- package/core/buddy/package.json +1 -1
- package/core/buddy/src/cli.ts +2 -0
- package/core/buddy/src/commands/build.ts +17 -1
- package/core/buddy/src/commands/deploy.ts +2 -2
- package/core/buddy/src/commands/index.ts +1 -0
- package/core/buddy/src/commands/list.ts +39 -0
- package/core/buddy/src/commands/setup.ts +57 -1
- package/core/buddy/tsconfig.json +3 -0
- package/core/build/package.json +1 -1
- package/core/build/tsconfig.json +3 -0
- package/core/bun-create/bud/package.json +1 -1
- package/core/bun-create/buddy/package.json +1 -1
- package/core/bun-create/stack/package.json +1 -1
- package/core/bun-create/stacks/package.json +1 -1
- package/core/bun-create/stx/package.json +2 -1
- package/core/bun-plugin-yaml/package.json +1 -1
- package/core/bun-plugin-yaml/tsconfig.json +3 -0
- package/core/cache/package.json +1 -1
- package/core/cache/tsconfig.json +3 -0
- package/core/chat/package.json +8 -8
- package/core/chat/tsconfig.json +3 -0
- package/core/cli/dist/index.js +1 -1
- package/core/cli/package.json +1 -1
- package/core/cli/tsconfig.json +3 -0
- package/core/cloud/build.ts +1 -1
- package/core/cloud/deploy.ts +10 -1
- package/core/cloud/dist/index.js +167 -807
- package/core/cloud/package.json +2 -3
- package/core/cloud/src/cloud/aws-sdk-layer/nodejs/package.json +1 -1
- package/core/cloud/src/cloud/cdn.ts +59 -6
- package/core/cloud/src/cloud/compute.ts +29 -19
- package/core/cloud/src/cloud/dns.ts +8 -0
- package/core/cloud/src/cloud/index.ts +8 -2
- package/core/cloud/src/cloud/queue.ts +46 -0
- package/core/cloud/src/cloud/router-layer/nodejs/package.json +2 -2
- package/core/cloud/src/cloud/security.ts +1 -1
- package/core/cloud/src/helpers.ts +13 -1
- package/core/cloud/tsconfig.json +3 -0
- package/core/collections/package.json +1 -1
- package/core/collections/tsconfig.json +3 -0
- package/core/config/dist/index.js +154 -83
- package/core/config/package.json +2 -2
- package/core/config/tsconfig.json +3 -0
- package/core/database/package.json +1 -1
- package/core/database/src/kysely-bun-worker/mitt.ts +1 -1
- package/core/database/tsconfig.json +3 -0
- package/core/datetime/package.json +1 -1
- package/core/datetime/tsconfig.json +3 -0
- package/core/desktop/package.json +1 -1
- package/core/desktop/tsconfig.json +3 -0
- package/core/development/package.json +1 -1
- package/core/development/tsconfig.json +3 -0
- package/core/dns/package.json +1 -1
- package/core/dns/tsconfig.json +3 -0
- package/core/docs/package.json +1 -1
- package/core/docs/tsconfig.json +3 -0
- package/core/email/package.json +12 -12
- package/core/email/tsconfig.json +3 -0
- package/core/enums/dist/index.js +1 -0
- package/core/enums/package.json +1 -1
- package/core/enums/src/index.ts +1 -0
- package/core/enums/tsconfig.json +3 -0
- package/core/env/package.json +1 -1
- package/core/env/tsconfig.json +3 -0
- package/core/error-handling/package.json +1 -1
- package/core/error-handling/tsconfig.json +3 -0
- package/core/eslint-config/package.json +3 -3
- package/core/eslint-config/src/configs/typescript.ts +1 -0
- package/core/eslint-config/src/factory.ts +1 -0
- package/core/events/package.json +1 -1
- package/core/events/src/index.ts +3 -6
- package/core/events/tsconfig.json +3 -0
- package/core/faker/package.json +1 -1
- package/core/faker/tsconfig.json +3 -0
- package/core/git/package.json +1 -1
- package/core/git/tsconfig.json +3 -0
- package/core/health/package.json +1 -1
- package/core/health/tsconfig.json +3 -0
- package/core/http/package.json +1 -1
- package/core/http/tsconfig.json +3 -0
- package/core/lint/package.json +1 -1
- package/core/lint/tsconfig.json +3 -0
- package/core/logging/package.json +1 -1
- package/core/logging/tsconfig.json +3 -0
- package/core/notifications/package.json +22 -22
- package/core/notifications/tsconfig.json +3 -0
- package/core/objects/package.json +1 -1
- package/core/objects/tsconfig.json +3 -0
- package/core/orm/package.json +1 -1
- package/core/orm/tsconfig.json +3 -0
- package/core/path/package.json +1 -1
- package/core/path/tsconfig.json +3 -0
- package/core/payments/dist/index.js +21 -3
- package/core/payments/package.json +1 -1
- package/core/payments/tsconfig.json +3 -0
- package/core/push/package.json +5 -5
- package/core/push/tsconfig.json +3 -0
- package/core/query-builder/package.json +1 -1
- package/core/query-builder/tsconfig.json +3 -0
- package/core/queue/package.json +1 -1
- package/core/queue/tsconfig.json +3 -0
- package/core/raycast/package.json +1 -1
- package/core/realtime/package.json +1 -1
- package/core/realtime/tsconfig.json +3 -0
- package/core/repl/package.json +1 -1
- package/core/repl/tsconfig.json +3 -0
- package/core/router/dist/index.js +3 -4
- package/core/router/package.json +1 -1
- package/core/router/src/router.ts +11 -11
- package/core/router/src/server.ts +4 -4
- package/core/router/tsconfig.json +3 -0
- package/core/scheduler/build.ts +1 -1
- package/core/scheduler/dist/index.js +682 -152
- package/core/scheduler/package.json +7 -4
- package/core/scheduler/src/constants.ts +81 -0
- package/core/scheduler/src/errors.ts +7 -0
- package/core/scheduler/src/index.ts +15 -317
- package/core/scheduler/src/job.ts +315 -0
- package/core/scheduler/src/schedule.ts +111 -0
- package/core/scheduler/src/time.ts +823 -0
- package/core/scheduler/src/types/cron.ts +98 -0
- package/core/scheduler/src/types/utils.ts +14 -0
- package/core/scheduler/src/utils.ts +19 -0
- package/core/scheduler/tests/cron.fuzz.ts +120 -0
- package/core/scheduler/tests/cron.test.ts +1241 -0
- package/core/scheduler/tests/crontime.test.ts +778 -0
- package/core/scheduler/tsconfig.json +3 -0
- package/core/search-engine/package.json +1 -1
- package/core/search-engine/tsconfig.json +3 -0
- package/core/security/package.json +1 -1
- package/core/security/tsconfig.json +3 -0
- package/core/server/package.json +1 -1
- package/core/server/tsconfig.json +3 -0
- package/core/signals/package.json +1 -1
- package/core/signals/tsconfig.json +3 -0
- package/core/slug/package.json +1 -1
- package/core/slug/tsconfig.json +3 -0
- package/core/sms/package.json +11 -11
- package/core/sms/tsconfig.json +3 -0
- package/core/storage/package.json +1 -1
- package/core/storage/tsconfig.json +3 -0
- package/core/strings/package.json +1 -1
- package/core/strings/tsconfig.json +3 -0
- package/core/tables/package.json +1 -1
- package/core/tables/tsconfig.json +3 -0
- package/core/testing/package.json +1 -1
- package/core/testing/tsconfig.json +3 -0
- package/core/tinker/package.json +1 -1
- package/core/tinker/tsconfig.json +3 -0
- package/core/tunnel/package.json +1 -1
- package/core/tunnel/tsconfig.json +3 -0
- package/core/types/package.json +3 -3
- package/core/types/src/app.ts +2 -2
- package/core/types/src/cli.ts +1 -1
- package/core/types/src/cloud.ts +5 -1
- package/core/types/src/cron-jobs.ts +1 -0
- package/core/types/src/queue.ts +3 -1
- package/core/types/tsconfig.json +3 -0
- package/core/ui/package.json +4 -4
- package/core/ui/tsconfig.json +3 -0
- package/core/utils/dist/index.js +1 -1
- package/core/utils/package.json +1 -1
- package/core/utils/src/promise.ts +2 -2
- package/core/utils/tsconfig.json +3 -0
- package/core/validation/package.json +1 -1
- package/core/validation/src/rules.ts +3 -3
- package/core/validation/tsconfig.json +3 -0
- package/core/vite/dist/index.js +1 -1
- package/core/vite/package.json +1 -1
- package/core/vite/tsconfig.json +3 -0
- package/core/whois/package.json +1 -1
- package/core/whois/tsconfig.json +3 -0
- package/core/x-ray/package.json +1 -1
- package/core/x-ray/tsconfig.json +3 -0
- package/core/zsh-buddy/README.md +6 -2
- package/core/zsh-buddy/buddy.plugin.zsh +109 -0
- package/core/zsh-buddy/package.json +1 -1
- package/ide/dictionary.txt +2 -0
- package/ide/vscode/package.json +1 -1
- package/package.json +1 -1
- package/buddy +0 -2
- package/core/actions/src/zip/api.ts +0 -22
- package/core/bud +0 -2
- package/core/cloud/buddy +0 -2
- package/core/cloud/src/cloud/package/README.md +0 -59
- package/core/cloud/src/cloud/package/package.json +0 -63
- package/core/scheduler/tests/example.test.ts +0 -5
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { SpawnOptions } from 'node:child_process'
|
|
2
|
+
import type { DateTime } from 'luxon'
|
|
3
|
+
import type { CONSTRAINTS, TIME_UNITS_MAP } from '../constants'
|
|
4
|
+
import type { CronJob } from '../job'
|
|
5
|
+
import type { IntRange } from './utils'
|
|
6
|
+
|
|
7
|
+
interface BaseCronJobParams<
|
|
8
|
+
OC extends CronOnCompleteCommand | null = null,
|
|
9
|
+
C = null,
|
|
10
|
+
> {
|
|
11
|
+
cronTime: string | Date | DateTime
|
|
12
|
+
onTick: CronCommand<C, WithOnComplete<OC>>
|
|
13
|
+
onComplete?: OC
|
|
14
|
+
start?: boolean | null
|
|
15
|
+
context?: C
|
|
16
|
+
runOnInit?: boolean | null
|
|
17
|
+
unrefTimeout?: boolean | null
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type CronJobParams<
|
|
21
|
+
OC extends CronOnCompleteCommand | null = null,
|
|
22
|
+
C = null,
|
|
23
|
+
> = BaseCronJobParams<OC, C> &
|
|
24
|
+
(
|
|
25
|
+
| {
|
|
26
|
+
timeZone?: string | null
|
|
27
|
+
utcOffset?: never
|
|
28
|
+
}
|
|
29
|
+
| {
|
|
30
|
+
timeZone?: never
|
|
31
|
+
utcOffset?: number | null
|
|
32
|
+
}
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
export type CronContext<C> = C extends null ? CronJob : NonNullable<C>
|
|
36
|
+
|
|
37
|
+
export type CronCallback<C, WithOnCompleteBool extends boolean = false> = (
|
|
38
|
+
this: CronContext<C>,
|
|
39
|
+
onComplete: WithOnCompleteBool extends true ? CronOnCompleteCallback : never
|
|
40
|
+
) => void | Promise<void>
|
|
41
|
+
|
|
42
|
+
export type CronOnCompleteCallback = () => void | Promise<void>
|
|
43
|
+
|
|
44
|
+
export type CronSystemCommand =
|
|
45
|
+
| string
|
|
46
|
+
| {
|
|
47
|
+
command: string
|
|
48
|
+
args?: readonly string[] | null
|
|
49
|
+
options?: SpawnOptions | null
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export type CronCommand<C, WithOnCompleteBool extends boolean = false> =
|
|
53
|
+
| CronCallback<C, WithOnCompleteBool>
|
|
54
|
+
| CronSystemCommand
|
|
55
|
+
|
|
56
|
+
export type CronOnCompleteCommand = CronOnCompleteCallback | CronSystemCommand
|
|
57
|
+
|
|
58
|
+
export type WithOnComplete<OC> = OC extends null ? false : true
|
|
59
|
+
|
|
60
|
+
export type TimeUnit = (typeof TIME_UNITS_MAP)[keyof typeof TIME_UNITS_MAP]
|
|
61
|
+
|
|
62
|
+
export type TimeUnitField<T extends TimeUnit> = Partial<
|
|
63
|
+
Record<Ranges[T], boolean>
|
|
64
|
+
>
|
|
65
|
+
|
|
66
|
+
export interface Ranges {
|
|
67
|
+
second: SecondRange
|
|
68
|
+
minute: MinuteRange
|
|
69
|
+
hour: HourRange
|
|
70
|
+
dayOfMonth: DayOfMonthRange
|
|
71
|
+
month: MonthRange
|
|
72
|
+
dayOfWeek: DayOfWeekRange
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export type SecondRange = IntRange<
|
|
76
|
+
(typeof CONSTRAINTS)['second'][0],
|
|
77
|
+
(typeof CONSTRAINTS)['second'][1]
|
|
78
|
+
>
|
|
79
|
+
export type MinuteRange = IntRange<
|
|
80
|
+
(typeof CONSTRAINTS)['minute'][0],
|
|
81
|
+
(typeof CONSTRAINTS)['minute'][1]
|
|
82
|
+
>
|
|
83
|
+
export type HourRange = IntRange<
|
|
84
|
+
(typeof CONSTRAINTS)['hour'][0],
|
|
85
|
+
(typeof CONSTRAINTS)['hour'][1]
|
|
86
|
+
>
|
|
87
|
+
export type DayOfMonthRange = IntRange<
|
|
88
|
+
(typeof CONSTRAINTS)['dayOfMonth'][0],
|
|
89
|
+
(typeof CONSTRAINTS)['dayOfMonth'][1]
|
|
90
|
+
>
|
|
91
|
+
export type MonthRange = IntRange<
|
|
92
|
+
(typeof CONSTRAINTS)['month'][0],
|
|
93
|
+
(typeof CONSTRAINTS)['month'][1]
|
|
94
|
+
>
|
|
95
|
+
export type DayOfWeekRange = IntRange<
|
|
96
|
+
(typeof CONSTRAINTS)['dayOfWeek'][0],
|
|
97
|
+
(typeof CONSTRAINTS)['dayOfWeek'][1]
|
|
98
|
+
>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type IntRange<F extends number, T extends number> = Exclude<
|
|
2
|
+
Enumerate<T>,
|
|
3
|
+
Enumerate<F, false>
|
|
4
|
+
>
|
|
5
|
+
|
|
6
|
+
type Enumerate<
|
|
7
|
+
N extends number,
|
|
8
|
+
WithTail extends boolean = true,
|
|
9
|
+
Acc extends number[] = [],
|
|
10
|
+
> = Acc['length'] extends N
|
|
11
|
+
? WithTail extends true
|
|
12
|
+
? [...Acc, Acc['length']][number]
|
|
13
|
+
: Acc[number]
|
|
14
|
+
: Enumerate<N, WithTail, [...Acc, Acc['length']]>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Ranges } from './types/cron'
|
|
2
|
+
import { ExclusiveParametersError } from './errors'
|
|
3
|
+
|
|
4
|
+
export function getRecordKeys<K extends Ranges[keyof Ranges]>(record: Partial<Record<K, boolean>>) {
|
|
5
|
+
return Object.keys(record) as unknown as (keyof typeof record)[]
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function getTimeZoneAndOffset(timeZone?: string | null, utcOffset?: number | null) {
|
|
9
|
+
if (timeZone != null && utcOffset != null)
|
|
10
|
+
throw new ExclusiveParametersError('timeZone', 'utcOffset')
|
|
11
|
+
|
|
12
|
+
if (timeZone != null)
|
|
13
|
+
return { timeZone, utcOffset: null }
|
|
14
|
+
|
|
15
|
+
if (utcOffset != null)
|
|
16
|
+
return { timeZone: null, utcOffset }
|
|
17
|
+
|
|
18
|
+
return { timeZone: null, utcOffset: null }
|
|
19
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { fc, test } from '@fast-check/jest'
|
|
2
|
+
import { CronJob } from '../src'
|
|
3
|
+
import { CronError } from '../src/errors'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* fuzzing might result in an infinite loop in our code, so Jest will simply timeout.
|
|
7
|
+
* experimental worker implementation of ```@fast-check/jest``` could help detect that issue
|
|
8
|
+
* that would be better as it would also give the counter-example that causes the bug
|
|
9
|
+
* but since it is still experimental, simply uncomment the log line in testCronJob
|
|
10
|
+
* function, so you can see the input causing the infinite loop.
|
|
11
|
+
*/
|
|
12
|
+
function testCronJob(
|
|
13
|
+
{
|
|
14
|
+
cronTime,
|
|
15
|
+
start,
|
|
16
|
+
timeZone,
|
|
17
|
+
runOnInit,
|
|
18
|
+
utcOffset,
|
|
19
|
+
unrefTimeout,
|
|
20
|
+
tzOrOffset,
|
|
21
|
+
}: {
|
|
22
|
+
cronTime: string
|
|
23
|
+
start: boolean
|
|
24
|
+
timeZone: string
|
|
25
|
+
runOnInit: boolean
|
|
26
|
+
utcOffset: number
|
|
27
|
+
unrefTimeout: boolean
|
|
28
|
+
tzOrOffset: boolean
|
|
29
|
+
},
|
|
30
|
+
checkError: (err: unknown) => boolean,
|
|
31
|
+
) {
|
|
32
|
+
// console.debug(cronTime, '|', timeZone, '|', utcOffset);
|
|
33
|
+
try {
|
|
34
|
+
const job = new CronJob(
|
|
35
|
+
cronTime,
|
|
36
|
+
() => {},
|
|
37
|
+
null,
|
|
38
|
+
start,
|
|
39
|
+
(tzOrOffset ? timeZone : null) as typeof tzOrOffset extends true
|
|
40
|
+
? string
|
|
41
|
+
: null,
|
|
42
|
+
null,
|
|
43
|
+
runOnInit,
|
|
44
|
+
(tzOrOffset ? null : utcOffset) as typeof tzOrOffset extends true
|
|
45
|
+
? null
|
|
46
|
+
: number,
|
|
47
|
+
unrefTimeout,
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
expect(job.running).toBe(start)
|
|
51
|
+
job.stop()
|
|
52
|
+
expect(job.running).toBe(false)
|
|
53
|
+
|
|
54
|
+
expect(job.cronTime.source).toBe(cronTime)
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
const isOk = checkError(error)
|
|
58
|
+
if (!isOk) {
|
|
59
|
+
console.error(error)
|
|
60
|
+
console.error(
|
|
61
|
+
'Make sure the relevant code is using an instance of CronError (or derived) when throwing.',
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
expect(isOk).toBe(true)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
test.prop(
|
|
69
|
+
{
|
|
70
|
+
cronTime: fc.stringMatching(/^(((\d+,)+\d+|(\d+(\/|-)\d+)|\d+|\*) ){5,6}$/),
|
|
71
|
+
start: fc.boolean(),
|
|
72
|
+
timeZone: fc.stringMatching(
|
|
73
|
+
/^((?:Z|[+-](?:2[0-3]|[01][0-9]):[0-5][0-9])|(Africa\/Abidjan|Asia\/Singapore|Australia\/Sydney|CET|EST|Europe\/Paris|America\/New_York))$/,
|
|
74
|
+
),
|
|
75
|
+
runOnInit: fc.boolean(),
|
|
76
|
+
utcOffset: fc.integer(),
|
|
77
|
+
unrefTimeout: fc.boolean(),
|
|
78
|
+
tzOrOffset: fc.boolean(),
|
|
79
|
+
},
|
|
80
|
+
{ numRuns: 100_000 },
|
|
81
|
+
)(
|
|
82
|
+
'CronJob should behave as expected and not error unexpectedly (with matching inputs)',
|
|
83
|
+
params => testCronJob(params, err => err instanceof CronError),
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
test.prop(
|
|
87
|
+
{
|
|
88
|
+
cronTime: fc.string(),
|
|
89
|
+
start: fc.boolean(),
|
|
90
|
+
timeZone: fc.string(),
|
|
91
|
+
runOnInit: fc.boolean(),
|
|
92
|
+
utcOffset: fc.integer(),
|
|
93
|
+
unrefTimeout: fc.boolean(),
|
|
94
|
+
tzOrOffset: fc.boolean(),
|
|
95
|
+
},
|
|
96
|
+
{ numRuns: 100_000 },
|
|
97
|
+
)(
|
|
98
|
+
'CronJob should behave as expected and not error unexpectedly (with random inputs)',
|
|
99
|
+
params => testCronJob(params, err => err instanceof CronError),
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
test.prop(
|
|
103
|
+
{
|
|
104
|
+
cronTime: fc.anything(),
|
|
105
|
+
start: fc.anything(),
|
|
106
|
+
timeZone: fc.anything(),
|
|
107
|
+
runOnInit: fc.anything(),
|
|
108
|
+
utcOffset: fc.anything(),
|
|
109
|
+
unrefTimeout: fc.anything(),
|
|
110
|
+
tzOrOffset: fc.boolean(),
|
|
111
|
+
},
|
|
112
|
+
{ numRuns: 100_000 },
|
|
113
|
+
)(
|
|
114
|
+
'CronJob should behave as expected and not error unexpectedly (with anything inputs)',
|
|
115
|
+
params =>
|
|
116
|
+
testCronJob(
|
|
117
|
+
params as any,
|
|
118
|
+
err => err instanceof CronError || err instanceof TypeError,
|
|
119
|
+
),
|
|
120
|
+
)
|