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.
Files changed (209) hide show
  1. package/core/actions/dist/src/deploy/index.js +2 -2
  2. package/core/actions/dist/src/upgrade.js +1 -1
  3. package/core/actions/package.json +1 -1
  4. package/core/actions/src/build/cli.ts +1 -1
  5. package/core/actions/src/build/server.ts +9 -0
  6. package/core/actions/src/deploy/index.ts +2 -2
  7. package/core/actions/tsconfig.json +3 -0
  8. package/core/ai/package.json +1 -1
  9. package/core/ai/tsconfig.json +3 -0
  10. package/core/alias/package.json +1 -1
  11. package/core/alias/tsconfig.json +3 -0
  12. package/core/analytics/package.json +1 -1
  13. package/core/analytics/tsconfig.json +3 -0
  14. package/core/api/package.json +1 -1
  15. package/core/api/tsconfig.json +3 -0
  16. package/core/arrays/package.json +1 -1
  17. package/core/arrays/tsconfig.json +3 -0
  18. package/core/auth/package.json +1 -1
  19. package/core/auth/tsconfig.json +3 -0
  20. package/core/buddy/dist/{chunk-91084836e95161e8.js → chunk-d52e40a990b45728.js} +152 -84
  21. package/core/buddy/dist/cli.js +4 -1
  22. package/core/buddy/dist/index.js +3 -1
  23. package/core/buddy/package.json +1 -1
  24. package/core/buddy/src/cli.ts +2 -0
  25. package/core/buddy/src/commands/build.ts +17 -1
  26. package/core/buddy/src/commands/deploy.ts +2 -2
  27. package/core/buddy/src/commands/index.ts +1 -0
  28. package/core/buddy/src/commands/list.ts +39 -0
  29. package/core/buddy/src/commands/setup.ts +57 -1
  30. package/core/buddy/tsconfig.json +3 -0
  31. package/core/build/package.json +1 -1
  32. package/core/build/tsconfig.json +3 -0
  33. package/core/bun-create/bud/package.json +1 -1
  34. package/core/bun-create/buddy/package.json +1 -1
  35. package/core/bun-create/stack/package.json +1 -1
  36. package/core/bun-create/stacks/package.json +1 -1
  37. package/core/bun-create/stx/package.json +2 -1
  38. package/core/bun-plugin-yaml/package.json +1 -1
  39. package/core/bun-plugin-yaml/tsconfig.json +3 -0
  40. package/core/cache/package.json +1 -1
  41. package/core/cache/tsconfig.json +3 -0
  42. package/core/chat/package.json +8 -8
  43. package/core/chat/tsconfig.json +3 -0
  44. package/core/cli/dist/index.js +1 -1
  45. package/core/cli/package.json +1 -1
  46. package/core/cli/tsconfig.json +3 -0
  47. package/core/cloud/build.ts +1 -1
  48. package/core/cloud/deploy.ts +10 -1
  49. package/core/cloud/dist/index.js +167 -807
  50. package/core/cloud/package.json +2 -3
  51. package/core/cloud/src/cloud/aws-sdk-layer/nodejs/package.json +1 -1
  52. package/core/cloud/src/cloud/cdn.ts +59 -6
  53. package/core/cloud/src/cloud/compute.ts +29 -19
  54. package/core/cloud/src/cloud/dns.ts +8 -0
  55. package/core/cloud/src/cloud/index.ts +8 -2
  56. package/core/cloud/src/cloud/queue.ts +46 -0
  57. package/core/cloud/src/cloud/router-layer/nodejs/package.json +2 -2
  58. package/core/cloud/src/cloud/security.ts +1 -1
  59. package/core/cloud/src/helpers.ts +13 -1
  60. package/core/cloud/tsconfig.json +3 -0
  61. package/core/collections/package.json +1 -1
  62. package/core/collections/tsconfig.json +3 -0
  63. package/core/config/dist/index.js +154 -83
  64. package/core/config/package.json +2 -2
  65. package/core/config/tsconfig.json +3 -0
  66. package/core/database/package.json +1 -1
  67. package/core/database/src/kysely-bun-worker/mitt.ts +1 -1
  68. package/core/database/tsconfig.json +3 -0
  69. package/core/datetime/package.json +1 -1
  70. package/core/datetime/tsconfig.json +3 -0
  71. package/core/desktop/package.json +1 -1
  72. package/core/desktop/tsconfig.json +3 -0
  73. package/core/development/package.json +1 -1
  74. package/core/development/tsconfig.json +3 -0
  75. package/core/dns/package.json +1 -1
  76. package/core/dns/tsconfig.json +3 -0
  77. package/core/docs/package.json +1 -1
  78. package/core/docs/tsconfig.json +3 -0
  79. package/core/email/package.json +12 -12
  80. package/core/email/tsconfig.json +3 -0
  81. package/core/enums/dist/index.js +1 -0
  82. package/core/enums/package.json +1 -1
  83. package/core/enums/src/index.ts +1 -0
  84. package/core/enums/tsconfig.json +3 -0
  85. package/core/env/package.json +1 -1
  86. package/core/env/tsconfig.json +3 -0
  87. package/core/error-handling/package.json +1 -1
  88. package/core/error-handling/tsconfig.json +3 -0
  89. package/core/eslint-config/package.json +3 -3
  90. package/core/eslint-config/src/configs/typescript.ts +1 -0
  91. package/core/eslint-config/src/factory.ts +1 -0
  92. package/core/events/package.json +1 -1
  93. package/core/events/src/index.ts +3 -6
  94. package/core/events/tsconfig.json +3 -0
  95. package/core/faker/package.json +1 -1
  96. package/core/faker/tsconfig.json +3 -0
  97. package/core/git/package.json +1 -1
  98. package/core/git/tsconfig.json +3 -0
  99. package/core/health/package.json +1 -1
  100. package/core/health/tsconfig.json +3 -0
  101. package/core/http/package.json +1 -1
  102. package/core/http/tsconfig.json +3 -0
  103. package/core/lint/package.json +1 -1
  104. package/core/lint/tsconfig.json +3 -0
  105. package/core/logging/package.json +1 -1
  106. package/core/logging/tsconfig.json +3 -0
  107. package/core/notifications/package.json +22 -22
  108. package/core/notifications/tsconfig.json +3 -0
  109. package/core/objects/package.json +1 -1
  110. package/core/objects/tsconfig.json +3 -0
  111. package/core/orm/package.json +1 -1
  112. package/core/orm/tsconfig.json +3 -0
  113. package/core/path/package.json +1 -1
  114. package/core/path/tsconfig.json +3 -0
  115. package/core/payments/dist/index.js +21 -3
  116. package/core/payments/package.json +1 -1
  117. package/core/payments/tsconfig.json +3 -0
  118. package/core/push/package.json +5 -5
  119. package/core/push/tsconfig.json +3 -0
  120. package/core/query-builder/package.json +1 -1
  121. package/core/query-builder/tsconfig.json +3 -0
  122. package/core/queue/package.json +1 -1
  123. package/core/queue/tsconfig.json +3 -0
  124. package/core/raycast/package.json +1 -1
  125. package/core/realtime/package.json +1 -1
  126. package/core/realtime/tsconfig.json +3 -0
  127. package/core/repl/package.json +1 -1
  128. package/core/repl/tsconfig.json +3 -0
  129. package/core/router/dist/index.js +3 -4
  130. package/core/router/package.json +1 -1
  131. package/core/router/src/router.ts +11 -11
  132. package/core/router/src/server.ts +4 -4
  133. package/core/router/tsconfig.json +3 -0
  134. package/core/scheduler/build.ts +1 -1
  135. package/core/scheduler/dist/index.js +682 -152
  136. package/core/scheduler/package.json +7 -4
  137. package/core/scheduler/src/constants.ts +81 -0
  138. package/core/scheduler/src/errors.ts +7 -0
  139. package/core/scheduler/src/index.ts +15 -317
  140. package/core/scheduler/src/job.ts +315 -0
  141. package/core/scheduler/src/schedule.ts +111 -0
  142. package/core/scheduler/src/time.ts +823 -0
  143. package/core/scheduler/src/types/cron.ts +98 -0
  144. package/core/scheduler/src/types/utils.ts +14 -0
  145. package/core/scheduler/src/utils.ts +19 -0
  146. package/core/scheduler/tests/cron.fuzz.ts +120 -0
  147. package/core/scheduler/tests/cron.test.ts +1241 -0
  148. package/core/scheduler/tests/crontime.test.ts +778 -0
  149. package/core/scheduler/tsconfig.json +3 -0
  150. package/core/search-engine/package.json +1 -1
  151. package/core/search-engine/tsconfig.json +3 -0
  152. package/core/security/package.json +1 -1
  153. package/core/security/tsconfig.json +3 -0
  154. package/core/server/package.json +1 -1
  155. package/core/server/tsconfig.json +3 -0
  156. package/core/signals/package.json +1 -1
  157. package/core/signals/tsconfig.json +3 -0
  158. package/core/slug/package.json +1 -1
  159. package/core/slug/tsconfig.json +3 -0
  160. package/core/sms/package.json +11 -11
  161. package/core/sms/tsconfig.json +3 -0
  162. package/core/storage/package.json +1 -1
  163. package/core/storage/tsconfig.json +3 -0
  164. package/core/strings/package.json +1 -1
  165. package/core/strings/tsconfig.json +3 -0
  166. package/core/tables/package.json +1 -1
  167. package/core/tables/tsconfig.json +3 -0
  168. package/core/testing/package.json +1 -1
  169. package/core/testing/tsconfig.json +3 -0
  170. package/core/tinker/package.json +1 -1
  171. package/core/tinker/tsconfig.json +3 -0
  172. package/core/tunnel/package.json +1 -1
  173. package/core/tunnel/tsconfig.json +3 -0
  174. package/core/types/package.json +3 -3
  175. package/core/types/src/app.ts +2 -2
  176. package/core/types/src/cli.ts +1 -1
  177. package/core/types/src/cloud.ts +5 -1
  178. package/core/types/src/cron-jobs.ts +1 -0
  179. package/core/types/src/queue.ts +3 -1
  180. package/core/types/tsconfig.json +3 -0
  181. package/core/ui/package.json +4 -4
  182. package/core/ui/tsconfig.json +3 -0
  183. package/core/utils/dist/index.js +1 -1
  184. package/core/utils/package.json +1 -1
  185. package/core/utils/src/promise.ts +2 -2
  186. package/core/utils/tsconfig.json +3 -0
  187. package/core/validation/package.json +1 -1
  188. package/core/validation/src/rules.ts +3 -3
  189. package/core/validation/tsconfig.json +3 -0
  190. package/core/vite/dist/index.js +1 -1
  191. package/core/vite/package.json +1 -1
  192. package/core/vite/tsconfig.json +3 -0
  193. package/core/whois/package.json +1 -1
  194. package/core/whois/tsconfig.json +3 -0
  195. package/core/x-ray/package.json +1 -1
  196. package/core/x-ray/tsconfig.json +3 -0
  197. package/core/zsh-buddy/README.md +6 -2
  198. package/core/zsh-buddy/buddy.plugin.zsh +109 -0
  199. package/core/zsh-buddy/package.json +1 -1
  200. package/ide/dictionary.txt +2 -0
  201. package/ide/vscode/package.json +1 -1
  202. package/package.json +1 -1
  203. package/buddy +0 -2
  204. package/core/actions/src/zip/api.ts +0 -22
  205. package/core/bud +0 -2
  206. package/core/cloud/buddy +0 -2
  207. package/core/cloud/src/cloud/package/README.md +0 -59
  208. package/core/cloud/src/cloud/package/package.json +0 -63
  209. 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
+ )