toiljs 0.0.116 → 0.0.118

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 (337) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +16 -7
  3. package/build/backend/.tsbuildinfo +1 -1
  4. package/build/cli/.tsbuildinfo +1 -1
  5. package/build/cli/index.js +2375 -258
  6. package/build/client/.tsbuildinfo +1 -1
  7. package/build/client/auth.d.ts +3 -0
  8. package/build/client/auth.js +19 -10
  9. package/build/client/dev/devtools.js +1 -1
  10. package/build/client/dev/error-overlay.js +1 -1
  11. package/build/client/index.d.ts +1 -1
  12. package/build/client/index.js +1 -1
  13. package/build/client/navigation/navigation.js +28 -3
  14. package/build/client/routing/Router.js +5 -2
  15. package/build/client/routing/mount.js +1 -1
  16. package/build/compiler/.tsbuildinfo +1 -1
  17. package/build/compiler/auth-emails.js +7 -3
  18. package/build/compiler/emails.js +1 -1
  19. package/build/compiler/index.d.ts +1 -0
  20. package/build/compiler/index.js +26 -5
  21. package/build/compiler/pages.js +2 -3
  22. package/build/compiler/prerender.d.ts +3 -8
  23. package/build/compiler/prerender.js +88 -127
  24. package/build/compiler/ssg.js +3 -4
  25. package/build/compiler/template-build.js +3 -4
  26. package/build/compiler/toil-docs.generated.js +8 -7
  27. package/build/compiler/vite.js +4 -6
  28. package/build/devserver/.tsbuildinfo +1 -1
  29. package/build/devserver/db/database.js +7 -3
  30. package/build/devserver/db/types.js +1 -1
  31. package/build/devserver/production.js +4 -3
  32. package/build/devserver/runtime/crypto.d.ts +1 -1
  33. package/build/io/.tsbuildinfo +1 -1
  34. package/build/logger/.tsbuildinfo +1 -1
  35. package/build/shared/.tsbuildinfo +1 -1
  36. package/examples/basic/client/routes/analytics.tsx +7 -5
  37. package/examples/basic/client/routes/pq.tsx +2 -1
  38. package/examples/basic/server/tsconfig.json +1 -3
  39. package/package.json +45 -44
  40. package/presets/no-uint8array-tostring.js +120 -153
  41. package/presets/oxlint.d.ts +5 -0
  42. package/presets/oxlint.js +224 -0
  43. package/server/auth/AuthController.ts +53 -14
  44. package/server/auth/FactorSettings.ts +41 -0
  45. package/server/auth/SessionEpochs.ts +58 -0
  46. package/server/auth/SessionRevocations.ts +13 -0
  47. package/server/globals/auth.ts +27 -2
  48. package/server/runtime/tsconfig.json +1 -3
  49. package/tsconfig.json +2 -11
  50. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
  51. package/.github/ISSUE_TEMPLATE/bug_report.yml +0 -90
  52. package/.github/ISSUE_TEMPLATE/config.yml +0 -8
  53. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  54. package/.github/PULL_REQUEST_TEMPLATE.md +0 -43
  55. package/.github/changelog-config.json +0 -45
  56. package/.github/dependabot.yml +0 -27
  57. package/.github/workflows/ci.yml +0 -222
  58. package/.vscode/settings.json +0 -10
  59. package/docs/README.md +0 -107
  60. package/docs/auth/README.md +0 -104
  61. package/docs/auth/configuration.md +0 -105
  62. package/docs/auth/emails.md +0 -92
  63. package/docs/auth/extending.md +0 -202
  64. package/docs/auth/how-it-works.md +0 -138
  65. package/docs/auth/usage.md +0 -188
  66. package/docs/backend/README.md +0 -143
  67. package/docs/backend/data.md +0 -351
  68. package/docs/backend/rest.md +0 -402
  69. package/docs/backend/rpc.md +0 -226
  70. package/docs/background/README.md +0 -114
  71. package/docs/background/daemons.md +0 -276
  72. package/docs/background/derive.md +0 -179
  73. package/docs/cli/README.md +0 -379
  74. package/docs/concepts/ai-guide.md +0 -132
  75. package/docs/concepts/config.md +0 -416
  76. package/docs/concepts/decorators.md +0 -127
  77. package/docs/concepts/security.md +0 -108
  78. package/docs/concepts/tiers.md +0 -166
  79. package/docs/concepts/types.md +0 -216
  80. package/docs/database/README.md +0 -143
  81. package/docs/database/capacity.md +0 -350
  82. package/docs/database/counters.md +0 -174
  83. package/docs/database/documents.md +0 -277
  84. package/docs/database/events.md +0 -307
  85. package/docs/database/membership.md +0 -246
  86. package/docs/database/setup.md +0 -155
  87. package/docs/database/unique.md +0 -216
  88. package/docs/database/views.md +0 -246
  89. package/docs/frontend/README.md +0 -104
  90. package/docs/frontend/components.md +0 -286
  91. package/docs/frontend/data-fetching.md +0 -260
  92. package/docs/frontend/images.md +0 -148
  93. package/docs/frontend/metadata.md +0 -344
  94. package/docs/frontend/navigation.md +0 -296
  95. package/docs/frontend/rendering.md +0 -236
  96. package/docs/frontend/routing.md +0 -346
  97. package/docs/frontend/scripts.md +0 -118
  98. package/docs/frontend/search.md +0 -191
  99. package/docs/frontend/styling.md +0 -147
  100. package/docs/frontend/toil-global.md +0 -216
  101. package/docs/getting-started/README.md +0 -81
  102. package/docs/getting-started/create-project.md +0 -131
  103. package/docs/getting-started/deploy.md +0 -101
  104. package/docs/getting-started/first-app.md +0 -215
  105. package/docs/getting-started/installation.md +0 -124
  106. package/docs/getting-started/migrating.md +0 -125
  107. package/docs/getting-started/project-structure.md +0 -163
  108. package/docs/introduction/README.md +0 -66
  109. package/docs/introduction/design-principles.md +0 -81
  110. package/docs/introduction/distributed.md +0 -91
  111. package/docs/introduction/how-it-works.md +0 -121
  112. package/docs/introduction/hyperscale.md +0 -70
  113. package/docs/introduction/modern-stack.md +0 -85
  114. package/docs/introduction/vs-other-frameworks.md +0 -64
  115. package/docs/introduction/why-toil.md +0 -99
  116. package/docs/llms.txt +0 -95
  117. package/docs/realtime/README.md +0 -102
  118. package/docs/realtime/channels.md +0 -211
  119. package/docs/realtime/streams.md +0 -369
  120. package/docs/services/README.md +0 -60
  121. package/docs/services/analytics.md +0 -279
  122. package/docs/services/caching.md +0 -175
  123. package/docs/services/cookies.md +0 -235
  124. package/docs/services/crypto.md +0 -209
  125. package/docs/services/email.md +0 -289
  126. package/docs/services/environment.md +0 -141
  127. package/docs/services/ratelimit.md +0 -174
  128. package/docs/services/time.md +0 -85
  129. package/eslint.config.js +0 -57
  130. package/examples/basic/client/routes/docs/[...slug].tsx +0 -12
  131. package/presets/eslint.js +0 -88
  132. package/src/backend/index.ts +0 -204
  133. package/src/cli/configure.ts +0 -363
  134. package/src/cli/create.ts +0 -924
  135. package/src/cli/db.ts +0 -158
  136. package/src/cli/diagnostics.ts +0 -665
  137. package/src/cli/doctor.ts +0 -982
  138. package/src/cli/features.ts +0 -170
  139. package/src/cli/index.ts +0 -326
  140. package/src/cli/notify.ts +0 -120
  141. package/src/cli/proc.ts +0 -56
  142. package/src/cli/ui.ts +0 -169
  143. package/src/cli/update.ts +0 -248
  144. package/src/cli/updates.ts +0 -92
  145. package/src/cli/validate.ts +0 -31
  146. package/src/cli/version-check.ts +0 -125
  147. package/src/client/auth.ts +0 -869
  148. package/src/client/channel/channel.ts +0 -146
  149. package/src/client/components/Form.tsx +0 -65
  150. package/src/client/components/Image.tsx +0 -160
  151. package/src/client/components/Script.tsx +0 -113
  152. package/src/client/components/Slot.tsx +0 -21
  153. package/src/client/dev/devtools.tsx +0 -1089
  154. package/src/client/dev/error-overlay.tsx +0 -225
  155. package/src/client/errors.ts +0 -11
  156. package/src/client/head/head.ts +0 -182
  157. package/src/client/head/metadata.ts +0 -110
  158. package/src/client/index.ts +0 -130
  159. package/src/client/navigation/Link.tsx +0 -108
  160. package/src/client/navigation/NavLink.tsx +0 -86
  161. package/src/client/navigation/navigation.ts +0 -235
  162. package/src/client/navigation/prefetch.ts +0 -169
  163. package/src/client/navigation/scroll.ts +0 -53
  164. package/src/client/routing/Router.tsx +0 -216
  165. package/src/client/routing/action.ts +0 -122
  166. package/src/client/routing/error-boundary.tsx +0 -43
  167. package/src/client/routing/hooks.ts +0 -140
  168. package/src/client/routing/lazy.ts +0 -77
  169. package/src/client/routing/loader.ts +0 -381
  170. package/src/client/routing/match.ts +0 -47
  171. package/src/client/routing/mount.tsx +0 -90
  172. package/src/client/routing/params-context.ts +0 -10
  173. package/src/client/routing/slot-context.ts +0 -7
  174. package/src/client/rpc.ts +0 -97
  175. package/src/client/search/search.ts +0 -189
  176. package/src/client/search/use-page-search.ts +0 -73
  177. package/src/client/ssr/markers.tsx +0 -172
  178. package/src/client/stream/client.ts +0 -237
  179. package/src/client/types.ts +0 -73
  180. package/src/compiler/auth-emails.ts +0 -312
  181. package/src/compiler/config.ts +0 -369
  182. package/src/compiler/docs.ts +0 -127
  183. package/src/compiler/email-preview.ts +0 -314
  184. package/src/compiler/emails.ts +0 -404
  185. package/src/compiler/fonts.ts +0 -89
  186. package/src/compiler/generate.ts +0 -471
  187. package/src/compiler/image-blur.ts +0 -42
  188. package/src/compiler/image-report.ts +0 -88
  189. package/src/compiler/index.ts +0 -1362
  190. package/src/compiler/pages.ts +0 -49
  191. package/src/compiler/plugin.ts +0 -391
  192. package/src/compiler/prerender.ts +0 -263
  193. package/src/compiler/routes.ts +0 -170
  194. package/src/compiler/seo.ts +0 -415
  195. package/src/compiler/sri.ts +0 -144
  196. package/src/compiler/ssg.ts +0 -177
  197. package/src/compiler/ssr-codegen.ts +0 -85
  198. package/src/compiler/template-build.ts +0 -676
  199. package/src/compiler/template.ts +0 -262
  200. package/src/compiler/toil-docs.generated.ts +0 -77
  201. package/src/compiler/vite.ts +0 -245
  202. package/src/devserver/analytics/index.ts +0 -317
  203. package/src/devserver/config/dotenv.ts +0 -102
  204. package/src/devserver/config/env.ts +0 -30
  205. package/src/devserver/config/ratelimit.ts +0 -123
  206. package/src/devserver/daemon/catalog.ts +0 -120
  207. package/src/devserver/daemon/cron.ts +0 -87
  208. package/src/devserver/daemon/host.ts +0 -134
  209. package/src/devserver/daemon/index.ts +0 -369
  210. package/src/devserver/daemon/runtime.ts +0 -48
  211. package/src/devserver/db/catalog.ts +0 -109
  212. package/src/devserver/db/database.ts +0 -1834
  213. package/src/devserver/db/derives.ts +0 -121
  214. package/src/devserver/db/index.ts +0 -20
  215. package/src/devserver/db/routeKinds.ts +0 -191
  216. package/src/devserver/db/types.ts +0 -168
  217. package/src/devserver/email/caps.ts +0 -0
  218. package/src/devserver/email/config.ts +0 -141
  219. package/src/devserver/email/console.ts +0 -348
  220. package/src/devserver/email/index.ts +0 -155
  221. package/src/devserver/email/providers.ts +0 -131
  222. package/src/devserver/email/status.ts +0 -23
  223. package/src/devserver/email/validate.ts +0 -37
  224. package/src/devserver/email/wire.ts +0 -55
  225. package/src/devserver/http/cache.ts +0 -0
  226. package/src/devserver/http/envelope.ts +0 -157
  227. package/src/devserver/http/proxy.ts +0 -172
  228. package/src/devserver/http/runtime.ts +0 -387
  229. package/src/devserver/index.ts +0 -43
  230. package/src/devserver/production-ipc.ts +0 -63
  231. package/src/devserver/production-worker.ts +0 -83
  232. package/src/devserver/production.ts +0 -718
  233. package/src/devserver/runtime/crypto.ts +0 -587
  234. package/src/devserver/runtime/host.ts +0 -427
  235. package/src/devserver/runtime/module.ts +0 -442
  236. package/src/devserver/server.ts +0 -251
  237. package/src/devserver/ssr.ts +0 -208
  238. package/src/devserver/stream/catalog.ts +0 -106
  239. package/src/devserver/stream/host.ts +0 -42
  240. package/src/devserver/stream/index.ts +0 -301
  241. package/src/devserver/stream/manager.ts +0 -167
  242. package/src/devserver/stream/router.ts +0 -101
  243. package/src/devserver/stream/wire.ts +0 -58
  244. package/src/devserver/stream/ws.ts +0 -78
  245. package/src/devserver/wasm/sections.ts +0 -59
  246. package/src/devserver/wasm/surface.ts +0 -115
  247. package/src/io/FastMap.ts +0 -151
  248. package/src/io/FastSet.ts +0 -113
  249. package/src/io/codec.ts +0 -362
  250. package/src/io/index.ts +0 -10
  251. package/src/io/lengths.ts +0 -14
  252. package/src/io/types.ts +0 -19
  253. package/src/logger/index.ts +0 -22
  254. package/src/shared/index.ts +0 -46
  255. package/test/analytics-dev.test.ts +0 -113
  256. package/test/assembly/aspect-shim.ts +0 -33
  257. package/test/assembly/cookie.spec.ts +0 -303
  258. package/test/assembly/example.spec.ts +0 -22
  259. package/test/assembly/ssr.spec.ts +0 -95
  260. package/test/assembly.test.ts +0 -59
  261. package/test/auth-emails.test.ts +0 -118
  262. package/test/built-ssr.test.ts +0 -148
  263. package/test/channel.test.ts +0 -21
  264. package/test/config-host-port.test.ts +0 -59
  265. package/test/configure.test.ts +0 -94
  266. package/test/daemon-build.test.ts +0 -278
  267. package/test/daemon-catalog.test.ts +0 -349
  268. package/test/daemon-emulation.test.ts +0 -256
  269. package/test/db.test.ts +0 -0
  270. package/test/devserver-database.test.ts +0 -1102
  271. package/test/devserver-email.test.ts +0 -306
  272. package/test/devserver-pqauth.test.ts +0 -93
  273. package/test/devserver-secrets.test.ts +0 -63
  274. package/test/devserver.test.ts +0 -259
  275. package/test/doctor.test.ts +0 -298
  276. package/test/dom/Image.test.tsx +0 -144
  277. package/test/dom/Link.test.tsx +0 -67
  278. package/test/dom/NavLink.test.tsx +0 -37
  279. package/test/dom/Script.test.tsx +0 -48
  280. package/test/dom/action.test.tsx +0 -146
  281. package/test/dom/error-overlay.test.tsx +0 -44
  282. package/test/dom/loader.test.tsx +0 -121
  283. package/test/dom/navigation.test.ts +0 -59
  284. package/test/dom/revalidate.test.tsx +0 -38
  285. package/test/dom/route-head.test.tsx +0 -56
  286. package/test/dom/router-loading.test.tsx +0 -44
  287. package/test/dom/scroll.test.ts +0 -56
  288. package/test/dom/slot.test.tsx +0 -131
  289. package/test/dom/use-metadata.test.tsx +0 -58
  290. package/test/dom/view-transitions.test.tsx +0 -53
  291. package/test/dynamic-routing.test.ts +0 -132
  292. package/test/email-console.test.ts +0 -86
  293. package/test/email-preview.test.ts +0 -73
  294. package/test/emails.test.ts +0 -58
  295. package/test/errors.test.ts +0 -21
  296. package/test/example-guestbook.test.ts +0 -123
  297. package/test/features.test.ts +0 -149
  298. package/test/fixtures/bignum-wire/spec.ts +0 -25
  299. package/test/fixtures/daemon-app.ts +0 -65
  300. package/test/fixtures/stream-echo.ts +0 -26
  301. package/test/fixtures/stream-gate.ts +0 -28
  302. package/test/fixtures/stream-trap.ts +0 -18
  303. package/test/fixtures/stream-typed.ts +0 -41
  304. package/test/fonts.test.ts +0 -28
  305. package/test/global-setup.ts +0 -17
  306. package/test/head.test.ts +0 -42
  307. package/test/image-blur.test.ts +0 -50
  308. package/test/io.test.ts +0 -117
  309. package/test/metadata.test.ts +0 -40
  310. package/test/navlink.test.ts +0 -28
  311. package/test/pages.test.ts +0 -105
  312. package/test/placeholder.test.ts +0 -9
  313. package/test/pqauth-e2e.test.ts +0 -216
  314. package/test/pqauth-email.test.ts +0 -801
  315. package/test/prerender.test.ts +0 -116
  316. package/test/prettier-plugin.test.ts +0 -46
  317. package/test/routes.test.ts +0 -76
  318. package/test/rpc-bignum-wire.test.ts +0 -164
  319. package/test/rpc-dispatch.test.ts +0 -132
  320. package/test/rpc-kinds.test.ts +0 -18
  321. package/test/rpc.test.ts +0 -66
  322. package/test/search.test.ts +0 -114
  323. package/test/seo.test.ts +0 -175
  324. package/test/slot-layouts.test.ts +0 -69
  325. package/test/sri.test.ts +0 -129
  326. package/test/ssg.test.ts +0 -36
  327. package/test/ssr-hydration.test.tsx +0 -122
  328. package/test/ssr-render.test.ts +0 -197
  329. package/test/ssr-template.test.tsx +0 -482
  330. package/test/stream-emulation.test.ts +0 -479
  331. package/test/ui.test.ts +0 -40
  332. package/test/update.test.ts +0 -58
  333. package/test/validate.test.ts +0 -42
  334. package/test/version-check.test.ts +0 -130
  335. package/tests/data-parity/generated-parity.ts +0 -99
  336. package/tests/data-parity/parity.ts +0 -80
  337. package/tests/data-parity/spec.ts +0 -46
@@ -1,278 +0,0 @@
1
- /**
2
- * Two-pass build pipeline (doc 08 section 1). Asserts:
3
- *
4
- * - `serverArtifacts` derives the `-hot`/`-cold` paths from `outFile` when
5
- * `hotFile`/`coldFile` are absent, and honors them when present.
6
- * - `SURFACE_DECORATOR` matches `@stream`/`@daemon`/`@scheduled` at line start
7
- * (not in a comment).
8
- * - `buildServer` on a project that declares a `@daemon` runs TWO toilscript
9
- * passes (one `--targetMode cold`, one `--targetMode hot`) and produces BOTH
10
- * `release-hot.wasm` and `release-cold.wasm`; the cold artifact decodes to a
11
- * daemon catalog and its `toil.surface` is target_mode = cold.
12
- * - a project with only the default request surface keeps the single-artifact
13
- * path (no cold pass, no cold artifact).
14
- *
15
- * The build invokes the LOCAL toilscript (branch feat/streams-phase0-compiler),
16
- * which supports `--targetMode`; the test links it into the fixture project's
17
- * `node_modules` the same way the dev build resolves it (`require.resolve`).
18
- */
19
-
20
- import {
21
- existsSync,
22
- mkdirSync,
23
- mkdtempSync,
24
- readFileSync,
25
- rmSync,
26
- symlinkSync,
27
- writeFileSync,
28
- } from 'node:fs';
29
- import { tmpdir } from 'node:os';
30
- import { dirname, join } from 'node:path';
31
- import { fileURLToPath } from 'node:url';
32
-
33
- import { afterEach, beforeEach, describe, expect, it } from 'vitest';
34
-
35
- import {
36
- assertNoStreamInRequestTier,
37
- buildServer,
38
- serverArtifacts,
39
- splitSurfaceFiles,
40
- SURFACE_DECORATOR,
41
- } from '../src/compiler/index.js';
42
- import { parseDaemonCatalog } from '../src/devserver/daemon/catalog.js';
43
- import { parseSurface } from '../src/devserver/wasm/surface.js';
44
-
45
- const here = dirname(fileURLToPath(import.meta.url));
46
- const LOCAL_TOILSCRIPT = join(here, '..', '..', 'toilscript');
47
-
48
- let tmp: string;
49
-
50
- beforeEach(() => {
51
- tmp = mkdtempSync(join(tmpdir(), 'daemon-build-'));
52
- });
53
- afterEach(() => {
54
- rmSync(tmp, { recursive: true, force: true });
55
- });
56
-
57
- /** Scaffold a minimal project at `tmp` with `server/main.ts` = `serverSrc`, the
58
- * given toilconfig, and `node_modules/toilscript` symlinked to the local build. */
59
- function scaffold(serverSrc: string, toilconfig: object): void {
60
- writeFileSync(join(tmp, 'package.json'), JSON.stringify({ name: 'fixture', type: 'module' }));
61
- writeFileSync(join(tmp, 'toilconfig.json'), JSON.stringify(toilconfig, null, 2));
62
- mkdirSync(join(tmp, 'server'), { recursive: true });
63
- writeFileSync(join(tmp, 'server', 'main.ts'), serverSrc);
64
- mkdirSync(join(tmp, 'node_modules'), { recursive: true });
65
- symlinkSync(LOCAL_TOILSCRIPT, join(tmp, 'node_modules', 'toilscript'), 'dir');
66
- }
67
-
68
- const BASE_TOILCONFIG = {
69
- entries: ['server/main.ts'],
70
- targets: { release: { outFile: 'build/server/release.wasm' } },
71
- options: { runtime: 'stub', optimizeLevel: 0, shrinkLevel: 0 },
72
- };
73
-
74
- // A @daemon that declares its host imports directly (no toiljs globals lib needed).
75
- const DAEMON_SRC = `@daemon
76
- class Jobs {
77
- @scheduled("2s") fast(): void {}
78
- @scheduled("0 0 * * *") nightly(): void {}
79
- }
80
- export function probe(): i32 { return 1; }
81
- `;
82
-
83
- const LEGACY_SRC = `export function handle(ofs: i32, len: i32): i64 { return 0; }
84
- export function probe(): i32 { return 1; }
85
- `;
86
-
87
- describe('serverArtifacts path derivation', () => {
88
- it('derives -hot/-cold from outFile when hotFile/coldFile are absent', () => {
89
- writeFileSync(
90
- join(tmp, 'toilconfig.json'),
91
- JSON.stringify({ targets: { release: { outFile: 'build/server/release.wasm' } } }),
92
- );
93
- const a = serverArtifacts(tmp);
94
- expect(a.hot).toBe(join(tmp, 'build/server/release-hot.wasm'));
95
- expect(a.cold).toBe(join(tmp, 'build/server/release-cold.wasm'));
96
- expect(a.stream).toBe(join(tmp, 'build/server/release-stream.wasm'));
97
- });
98
-
99
- it('honors explicit hotFile/coldFile/streamFile when present', () => {
100
- writeFileSync(
101
- join(tmp, 'toilconfig.json'),
102
- JSON.stringify({
103
- targets: {
104
- release: {
105
- outFile: 'build/server/release.wasm',
106
- hotFile: 'out/hot.wasm',
107
- coldFile: 'out/cold.wasm',
108
- streamFile: 'out/stream.wasm',
109
- },
110
- },
111
- }),
112
- );
113
- const a = serverArtifacts(tmp);
114
- expect(a.hot).toBe(join(tmp, 'out/hot.wasm'));
115
- expect(a.cold).toBe(join(tmp, 'out/cold.wasm'));
116
- expect(a.stream).toBe(join(tmp, 'out/stream.wasm'));
117
- });
118
- });
119
-
120
- describe('SURFACE_DECORATOR', () => {
121
- it('matches the streams/daemon decorators at line start', () => {
122
- for (const deco of ['@stream', '@daemon', '@scheduled', '@rest', '@data']) {
123
- expect(SURFACE_DECORATOR.test(`${deco} class X {}`)).toBe(true);
124
- expect(SURFACE_DECORATOR.test(` ${deco}\nclass X {}`)).toBe(true);
125
- }
126
- });
127
-
128
- it('does NOT match a decorator mentioned only in a comment', () => {
129
- expect(SURFACE_DECORATOR.test('// the @daemon decorator marks a cold class')).toBe(false);
130
- expect(SURFACE_DECORATOR.test('const s = "uses @scheduled internally";')).toBe(false);
131
- });
132
- });
133
-
134
- describe('splitSurfaceFiles per-pass classification', () => {
135
- /** Lay down `name -> contents` files under `tmp` and return their relative paths. */
136
- function lay(files: Record<string, string>): string[] {
137
- mkdirSync(join(tmp, 'server'), { recursive: true });
138
- const rels: string[] = [];
139
- for (const [name, src] of Object.entries(files)) {
140
- writeFileSync(join(tmp, name), src);
141
- rels.push(name);
142
- }
143
- return rels;
144
- }
145
-
146
- it('routes each surface to its tier (request/stream/cold) and shares plain helpers', () => {
147
- const rels = lay({
148
- 'server/jobs.ts': '@daemon\nclass J { @scheduled("1s") t(): void {} }\n',
149
- 'server/api.ts': '@rest\nclass A {}\n',
150
- 'server/chat.ts': "@stream('chat')\nclass C {}\n",
151
- 'server/model.ts': '@data\nclass M {}\n',
152
- 'server/util.ts': 'export function helper(): i32 { return 1; }\n',
153
- });
154
- const split = splitSurfaceFiles(tmp, rels);
155
- expect(split.hasDaemon).toBe(true);
156
- expect(split.hasStream).toBe(true);
157
- const shared = ['server/model.ts', 'server/util.ts'];
158
- // Each surface goes to ONLY its tier; the @data/helper files are shared into all three.
159
- expect(split.cold.sort()).toEqual(['server/jobs.ts', ...shared].sort());
160
- expect(split.stream.sort()).toEqual(['server/chat.ts', ...shared].sort());
161
- expect(split.request.sort()).toEqual(['server/api.ts', ...shared].sort());
162
- });
163
-
164
- it('routes entries by the *.stream.ts / *.daemon.ts naming and the runtime-export request entry', () => {
165
- const RT = "export * from 'toiljs/server/runtime/exports';\n";
166
- const rels = lay({
167
- 'server/main.ts': RT, // runtime entry, not *.stream/.daemon -> request
168
- 'server/main.stream.ts': RT, // *.stream.ts -> stream (not request, despite the runtime export)
169
- 'server/main.daemon.ts': "import './daemon/Jobs';\n", // *.daemon.ts -> cold
170
- });
171
- const split = splitSurfaceFiles(tmp, rels);
172
- expect(split.hasStream).toBe(true);
173
- expect(split.hasDaemon).toBe(true);
174
- // Each entry is routed to EXACTLY one tier (so two entries never collide on `export *`).
175
- expect(split.request).toEqual(['server/main.ts']);
176
- expect(split.stream).toEqual(['server/main.stream.ts']);
177
- expect(split.cold).toEqual(['server/main.daemon.ts']);
178
- });
179
-
180
- it('keeps a file that mixes daemon + request surfaces in both of those passes (not stream)', () => {
181
- const rels = lay({ 'server/both.ts': '@daemon\nclass J {}\n@rest\nclass A {}\n' });
182
- const split = splitSurfaceFiles(tmp, rels);
183
- expect(split.cold).toContain('server/both.ts');
184
- expect(split.request).toContain('server/both.ts');
185
- expect(split.stream).not.toContain('server/both.ts');
186
- });
187
-
188
- it('exposes the actual @stream modules in streamModules (not @rest or shared helpers)', () => {
189
- const rels = lay({
190
- 'server/chat.ts': "@stream('chat')\nclass C {}\n",
191
- 'server/api.ts': '@rest\nclass A {}\n',
192
- 'server/util.ts': 'export function helper(): i32 { return 1; }\n',
193
- });
194
- const split = splitSurfaceFiles(tmp, rels);
195
- expect(split.streamModules).toEqual(['server/chat.ts']);
196
- });
197
-
198
- it('REJECTS a value-import of a @stream module; allows clean/type-only/commented (audit #17/#7)', () => {
199
- const rels = lay({
200
- 'server/main.ts': "import { A } from './api';\n", // request-tier (shared) entry
201
- 'server/api.ts': '@rest\nclass A {}\n',
202
- 'server/chat.ts': "@stream('chat')\nclass C {}\n",
203
- });
204
- const check = () => assertNoStreamInRequestTier(tmp, splitSurfaceFiles(tmp, rels));
205
-
206
- // main imports only the @rest surface -> no stream code leaks into release.wasm.
207
- expect(check).not.toThrow();
208
-
209
- // The footgun: a request-tier file value-imports the @stream module.
210
- writeFileSync(join(tmp, 'server', 'main.ts'), "import { C } from './chat';\nvoid C;\n");
211
- expect(check).toThrow(/@stream class would be compiled into the REQUEST tier/);
212
-
213
- // A type-only import is erased and never compiles @stream code -> allowed.
214
- writeFileSync(join(tmp, 'server', 'main.ts'), "import type { C } from './chat';\n");
215
- expect(check).not.toThrow();
216
-
217
- // A COMMENTED-OUT import is dead code and must not false-positive (audit #7).
218
- writeFileSync(
219
- join(tmp, 'server', 'main.ts'),
220
- "// import { C } from './chat';\nimport { A } from './api';\n",
221
- );
222
- expect(check).not.toThrow();
223
- });
224
-
225
- it('catches a @stream reached transitively through a plain helper NOT in the surface list (audit #6)', () => {
226
- // util.ts is an UNDECORATED helper -> not in serverEntryFiles, so production hands splitSurfaceFiles
227
- // only the entries+surfaces. The filesystem-resolving BFS must still traverse util.ts to reach the
228
- // @stream module behind it.
229
- lay({
230
- 'server/main.ts': "import './util';\n",
231
- 'server/util.ts': "import { C } from './chat';\nexport const x = 1;\n",
232
- 'server/chat.ts': "@stream('chat')\nclass C {}\n",
233
- });
234
- const surfacesOnly = ['server/main.ts', 'server/chat.ts']; // no plain util.ts, as in production
235
- expect(() => assertNoStreamInRequestTier(tmp, splitSurfaceFiles(tmp, surfacesOnly))).toThrow(
236
- /@stream class would be compiled into the REQUEST tier/,
237
- );
238
- });
239
- });
240
-
241
- // Needs the local toilscript dev build (with --targetMode) linked as a sibling
242
- // repo; skip where it is absent (e.g. CI, which has only the published dep).
243
- describe.skipIf(!existsSync(LOCAL_TOILSCRIPT))('buildServer two-pass (daemon project)', () => {
244
- it('runs the cold pass and produces the cold artifact with a daemon catalog', async () => {
245
- scaffold(DAEMON_SRC, BASE_TOILCONFIG);
246
- await buildServer(tmp);
247
-
248
- const cold = join(tmp, 'build/server/release-cold.wasm');
249
- expect(existsSync(cold), 'cold artifact missing').toBe(true);
250
-
251
- // The cold artifact carries the daemon surface + catalog (decoded byte-for-byte).
252
- const coldBytes = readFileSync(cold);
253
- const surface = parseSurface(coldBytes);
254
- expect(surface !== 'invalid' && surface.targetMode).toBe('cold');
255
- expect(surface !== 'invalid' && surface.flags.daemon).toBe(true);
256
-
257
- const catalog = parseDaemonCatalog(coldBytes);
258
- expect(catalog).not.toBeNull();
259
- expect(catalog!.hasDaemon).toBe(true);
260
- expect(catalog!.tasks.map((t) => t.name)).toEqual(['fast', 'nightly']);
261
- expect(catalog!.tasks[0].schedule.kind).toBe('interval');
262
- expect(catalog!.tasks[1].schedule.kind).toBe('cron');
263
-
264
- // A daemon-only project (no request/stream surface) has no hot files, so the hot pass is
265
- // skipped (toilscript would HARD-ERROR a @daemon class under --targetMode hot). The default
266
- // request artifact `release.wasm` is therefore not produced for a pure background worker.
267
- expect(existsSync(join(tmp, 'build/server/release.wasm'))).toBe(false);
268
- }, 60_000);
269
-
270
- it('keeps the single-artifact path for a request-only project', async () => {
271
- scaffold(LEGACY_SRC, BASE_TOILCONFIG);
272
- await buildServer(tmp);
273
-
274
- expect(existsSync(join(tmp, 'build/server/release.wasm'))).toBe(true);
275
- // No @daemon -> no cold pass -> no cold artifact.
276
- expect(existsSync(join(tmp, 'build/server/release-cold.wasm'))).toBe(false);
277
- }, 60_000);
278
- });
@@ -1,349 +0,0 @@
1
- /**
2
- * Unit tests for the daemon-side custom-section parsers and cron evaluator
3
- * (RECONCILIATION Part 5 byte layouts / F6 bitmask cron). These mirror the DB
4
- * catalog tests' style: hand-build the Part 5 bytes with `DataWriter`, wrap them
5
- * in a minimal wasm custom section, and assert the parser decodes them field-for-
6
- * field and fails CLOSED on a truncated/garbage section.
7
- */
8
-
9
- import { describe, expect, it } from 'vitest';
10
-
11
- import { DataWriter } from '../src/io/codec.js';
12
- import { parseDaemonCatalog } from '../src/devserver/daemon/catalog.js';
13
- import { cronMatches, cronNeverFires, nextCronFireMs } from '../src/devserver/daemon/cron.js';
14
- import { customSection } from '../src/devserver/wasm/sections.js';
15
- import { parseSurface } from '../src/devserver/wasm/surface.js';
16
-
17
- /** Wrap a section payload (after the name) into a minimal one-section wasm module.
18
- * Mirrors the DB catalog test's `wasmWithSection` helper. */
19
- function wasmWithSection(name: string, payload: Uint8Array): Buffer {
20
- const nameBytes = Buffer.from(name);
21
- const sectionPayload = Buffer.concat([
22
- Buffer.from([nameBytes.length]),
23
- nameBytes,
24
- Buffer.from(payload),
25
- ]);
26
- return Buffer.concat([
27
- Buffer.from([0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x00, sectionPayload.length]),
28
- sectionPayload,
29
- ]);
30
- }
31
-
32
- // --- toildaemon.catalog (Part 5) byte builders -----------------------------
33
-
34
- interface BuildTask {
35
- name: string;
36
- taskIndex: number;
37
- kind: 0 | 1;
38
- intervalMs?: bigint;
39
- cron?: { minute: bigint; hour: number; dom: number; month: number; dow: number };
40
- }
41
-
42
- /** Emit a Part 5 `toildaemon.catalog` body (the bytes AFTER the section name). */
43
- function buildDaemonCatalogBytes(hasDaemon: boolean, tasks: BuildTask[]): Uint8Array {
44
- const w = new DataWriter();
45
- w.writeU16(1); // format_version
46
- w.writeU8(hasDaemon ? 1 : 0);
47
- w.writeU16(tasks.length); // n_scheduled
48
- for (const t of tasks) {
49
- w.writeString(t.name);
50
- w.writeU16(t.taskIndex);
51
- w.writeU8(t.kind);
52
- w.writeU64(t.kind === 0 ? (t.intervalMs ?? 0n) : 0n); // interval_ms
53
- w.writeU64(t.cron?.minute ?? 0n); // cron_minute_mask
54
- w.writeU32(t.cron?.hour ?? 0); // cron_hour_mask
55
- w.writeU32(t.cron?.dom ?? 0); // cron_dom_mask
56
- w.writeU16(t.cron?.month ?? 0); // cron_month_mask
57
- w.writeU8(t.cron?.dow ?? 0); // cron_dow_mask
58
- w.writeU8(0); // overlap_policy
59
- w.writeU8(0); // catchup_policy
60
- w.writeU64(0n); // gas_hint
61
- }
62
- return w.toBytes();
63
- }
64
-
65
- describe('parseDaemonCatalog (Part 5)', () => {
66
- it('decodes an interval task and a cron task field-for-field', () => {
67
- // `0 */6 * * *`: minute 0; hours 0,6,12,18; dom 1..31; month 1..12; dow 0..6.
68
- const payload = buildDaemonCatalogBytes(true, [
69
- { name: 'tick', taskIndex: 0, kind: 0, intervalMs: 1000n },
70
- {
71
- name: 'sixHourly',
72
- taskIndex: 1,
73
- kind: 1,
74
- cron: {
75
- minute: 1n, // bit 0 (minute 0)
76
- hour: (1 << 0) | (1 << 6) | (1 << 12) | (1 << 18),
77
- dom: 0xfffffffe, // bits 1..31
78
- month: 0x1ffe, // bits 1..12
79
- dow: 0x7f, // bits 0..6
80
- },
81
- },
82
- ]);
83
- const wasm = wasmWithSection('toildaemon.catalog', payload);
84
- const cat = parseDaemonCatalog(wasm);
85
- expect(cat).not.toBeNull();
86
- expect(cat!.hasDaemon).toBe(true);
87
- expect(cat!.tasks).toHaveLength(2);
88
-
89
- const [interval, cron] = cat!.tasks;
90
- expect(interval.name).toBe('tick');
91
- expect(interval.taskIndex).toBe(0);
92
- expect(interval.schedule).toEqual({ kind: 'interval', ms: 1000 });
93
- expect(interval.overlapPolicy).toBe(0);
94
- expect(interval.catchupPolicy).toBe(0);
95
- expect(interval.gasHint).toBe(0n);
96
-
97
- expect(cron.name).toBe('sixHourly');
98
- expect(cron.taskIndex).toBe(1);
99
- expect(cron.schedule.kind).toBe('cron');
100
- if (cron.schedule.kind === 'cron') {
101
- // The masks round-trip as BIT TESTS, never a string parse.
102
- const m = cron.schedule.masks;
103
- expect(m.minute).toBe(1n);
104
- expect((m.hour & (1 << 6)) !== 0).toBe(true);
105
- expect((m.hour & (1 << 7)) !== 0).toBe(false);
106
- expect(m.dom).toBe(0xfffffffe);
107
- expect(m.month).toBe(0x1ffe);
108
- expect(m.dow).toBe(0x7f);
109
- }
110
- });
111
-
112
- it('decodes a 60-bit minute mask without precision loss', () => {
113
- // minute 59 = bit 59, which is above 2^53 and must survive as a bigint.
114
- const minuteMask = 1n << 59n;
115
- const payload = buildDaemonCatalogBytes(true, [
116
- {
117
- name: 'lateMinute',
118
- taskIndex: 0,
119
- kind: 1,
120
- cron: {
121
- minute: minuteMask,
122
- hour: 0xffffff,
123
- dom: 0xfffffffe,
124
- month: 0x1ffe,
125
- dow: 0x7f,
126
- },
127
- },
128
- ]);
129
- const cat = parseDaemonCatalog(wasmWithSection('toildaemon.catalog', payload));
130
- const t = cat!.tasks[0];
131
- expect(t.schedule.kind === 'cron' && t.schedule.masks.minute).toBe(minuteMask);
132
- });
133
-
134
- it('returns null for an absent section (no daemon -> emulator stays off)', () => {
135
- const wasm = wasmWithSection('toildb.catalog', Buffer.from([0x01, 0x00]));
136
- expect(parseDaemonCatalog(wasm)).toBeNull();
137
- });
138
-
139
- it('fails closed: a truncated record yields only the cleanly-decoded prefix', () => {
140
- // Claim 2 tasks but truncate inside the second record's interval_ms.
141
- const full = buildDaemonCatalogBytes(true, [
142
- { name: 'a', taskIndex: 0, kind: 0, intervalMs: 5000n },
143
- { name: 'b', taskIndex: 1, kind: 0, intervalMs: 9000n },
144
- ]);
145
- const truncated = full.subarray(0, full.length - 20); // chop the 2nd record's tail
146
- const cat = parseDaemonCatalog(wasmWithSection('toildaemon.catalog', truncated));
147
- expect(cat).not.toBeNull();
148
- // Only the first task survived; the loop stopped on the short read.
149
- expect(cat!.tasks.map((t) => t.name)).toEqual(['a']);
150
- });
151
-
152
- it('returns null for a wholly garbage section (header short-read, no daemon)', () => {
153
- const cat = parseDaemonCatalog(wasmWithSection('toildaemon.catalog', Buffer.from([0x01])));
154
- expect(cat).toBeNull();
155
- });
156
- });
157
-
158
- // --- toil.surface (Part 5) -------------------------------------------------
159
-
160
- function buildSurfaceBytes(opts: {
161
- mode: number;
162
- flags: number;
163
- version?: number;
164
- reserved0?: number;
165
- abi?: number;
166
- buildId?: string;
167
- }): Uint8Array {
168
- const w = new DataWriter();
169
- w.writeU16(opts.version ?? 1); // format_version
170
- w.writeU8(opts.mode); // target_mode
171
- w.writeU8(opts.reserved0 ?? 0); // reserved0
172
- w.writeU32(opts.flags); // surface_flags
173
- w.writeU16(opts.abi ?? 1); // abi_version
174
- w.writeString(opts.buildId ?? ''); // build_id
175
- w.writeU32(0xdeadbeef); // fingerprint
176
- w.writeU32(0x11111111); // data_coherence_hash
177
- w.writeU32(0x22222222); // pair_coherence_hash (exactly THREE u32 after build_id)
178
- return w.toBytes();
179
- }
180
-
181
- describe('parseSurface (Part 5)', () => {
182
- it('decodes a cold daemon surface with exactly three trailing u32 hashes', () => {
183
- const flags = 0b000100 | 0b001000; // daemon (bit2) + scheduled (bit3)
184
- const s = parseSurface(
185
- wasmWithSection('toil.surface', buildSurfaceBytes({ mode: 1, flags })),
186
- );
187
- expect(s).not.toBe('invalid');
188
- if (s !== 'invalid') {
189
- expect(s.targetMode).toBe('cold');
190
- expect(s.flags.daemon).toBe(true);
191
- expect(s.flags.scheduled).toBe(true);
192
- expect(s.flags.rest).toBe(false);
193
- expect(s.abiVersion).toBe(1);
194
- expect(s.fingerprint).toBe(0xdeadbeef);
195
- expect(s.dataCoherenceHash).toBe(0x11111111);
196
- expect(s.pairCoherenceHash).toBe(0x22222222);
197
- }
198
- });
199
-
200
- it('decodes a hot surface (target_mode 0)', () => {
201
- const s = parseSurface(
202
- wasmWithSection('toil.surface', buildSurfaceBytes({ mode: 0, flags: 1 })),
203
- );
204
- expect(s !== 'invalid' && s.targetMode).toBe('hot');
205
- });
206
-
207
- it('fails closed when toil.surface is absent', () => {
208
- const wasm = wasmWithSection('toildb.catalog', Buffer.from([0x01, 0x00]));
209
- expect(parseSurface(wasm)).toBe('invalid');
210
- });
211
-
212
- it("fails closed: a PRESENT but truncated section is 'invalid'", () => {
213
- const full = buildSurfaceBytes({ mode: 1, flags: 4 });
214
- const truncated = full.subarray(0, full.length - 3); // chop a trailing hash
215
- expect(parseSurface(wasmWithSection('toil.surface', truncated))).toBe('invalid');
216
- });
217
-
218
- it("fails closed: trailing bytes after toil.surface are 'invalid'", () => {
219
- const full = Buffer.from(buildSurfaceBytes({ mode: 0, flags: 1 }));
220
- const withGarbage = Buffer.concat([full, Buffer.from([0xff])]);
221
- expect(parseSurface(wasmWithSection('toil.surface', withGarbage))).toBe('invalid');
222
- });
223
-
224
- it("fails closed: unsupported format version is 'invalid'", () => {
225
- expect(
226
- parseSurface(
227
- wasmWithSection(
228
- 'toil.surface',
229
- buildSurfaceBytes({ version: 2, mode: 0, flags: 1 }),
230
- ),
231
- ),
232
- ).toBe('invalid');
233
- });
234
-
235
- it("fails closed: unsupported abi_version is 'invalid'", () => {
236
- expect(
237
- parseSurface(
238
- wasmWithSection('toil.surface', buildSurfaceBytes({ mode: 0, flags: 1, abi: 2 })),
239
- ),
240
- ).toBe('invalid');
241
- });
242
-
243
- it('fails closed: target_mode 2 is not silently treated as hot', () => {
244
- expect(
245
- parseSurface(wasmWithSection('toil.surface', buildSurfaceBytes({ mode: 2, flags: 1 }))),
246
- ).toBe('invalid');
247
- });
248
-
249
- it("fails closed: nonzero reserved byte is 'invalid'", () => {
250
- expect(
251
- parseSurface(
252
- wasmWithSection(
253
- 'toil.surface',
254
- buildSurfaceBytes({ mode: 0, flags: 1, reserved0: 1 }),
255
- ),
256
- ),
257
- ).toBe('invalid');
258
- });
259
-
260
- it("fails closed: reserved surface flag bits are 'invalid'", () => {
261
- expect(
262
- parseSurface(
263
- wasmWithSection('toil.surface', buildSurfaceBytes({ mode: 0, flags: 1 << 6 })),
264
- ),
265
- ).toBe('invalid');
266
- });
267
-
268
- it('fails closed: daemon flags are illegal on hot artifacts', () => {
269
- expect(
270
- parseSurface(
271
- wasmWithSection('toil.surface', buildSurfaceBytes({ mode: 0, flags: 1 | 4 })),
272
- ),
273
- ).toBe('invalid');
274
- });
275
-
276
- it('fails closed: stream flags are illegal on cold artifacts', () => {
277
- expect(
278
- parseSurface(
279
- wasmWithSection('toil.surface', buildSurfaceBytes({ mode: 1, flags: 4 | 2 })),
280
- ),
281
- ).toBe('invalid');
282
- });
283
-
284
- it('fails closed: scheduled requires daemon', () => {
285
- expect(
286
- parseSurface(wasmWithSection('toil.surface', buildSurfaceBytes({ mode: 1, flags: 8 }))),
287
- ).toBe('invalid');
288
- });
289
- });
290
-
291
- describe('customSection bounds-checking', () => {
292
- it('returns null for a non-wasm buffer', () => {
293
- expect(customSection(Buffer.from('not a wasm module at all'), 'toil.surface')).toBeNull();
294
- });
295
-
296
- it('returns null for a truncated section table (no over-read)', () => {
297
- // Magic + version, then a custom-section id with a length that runs past the end.
298
- const wasm = Buffer.from([0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x00, 0x7f]);
299
- expect(customSection(wasm, 'toil.surface')).toBeNull();
300
- });
301
- });
302
-
303
- describe('cron bitmask evaluation (F6, never a string parse)', () => {
304
- // `0 */6 * * *`: minute 0; hours 0,6,12,18; every dom/month/dow.
305
- const sixHourly = {
306
- minute: 1n, // bit 0
307
- hour: (1 << 0) | (1 << 6) | (1 << 12) | (1 << 18),
308
- dom: 0xfffffffe,
309
- month: 0x1ffe,
310
- dow: 0x7f,
311
- };
312
-
313
- it('matches the right minute/hour and rejects others', () => {
314
- expect(cronMatches(sixHourly, new Date(2026, 5, 22, 6, 0, 0))).toBe(true);
315
- expect(cronMatches(sixHourly, new Date(2026, 5, 22, 12, 0, 0))).toBe(true);
316
- expect(cronMatches(sixHourly, new Date(2026, 5, 22, 6, 1, 0))).toBe(false); // wrong minute
317
- expect(cronMatches(sixHourly, new Date(2026, 5, 22, 7, 0, 0))).toBe(false); // wrong hour
318
- });
319
-
320
- it('computes the next fire time by walking forward minute by minute', () => {
321
- const from = new Date(2026, 5, 22, 6, 1, 0).getTime();
322
- const next = nextCronFireMs(sixHourly, from);
323
- expect(next).not.toBeNull();
324
- expect(new Date(next!).getHours()).toBe(12);
325
- expect(new Date(next!).getMinutes()).toBe(0);
326
- });
327
-
328
- it('honors the dom/dow union rule', () => {
329
- // Fire on the 1st of the month OR on Sunday (both restricted -> union).
330
- const masks = {
331
- minute: 1n, // minute 0
332
- hour: 1, // hour 0
333
- dom: 1 << 1, // only day-of-month 1
334
- month: 0x1ffe, // every month
335
- dow: 1 << 0, // only Sunday
336
- };
337
- // 2026-06-01 is a Monday -> matches via dom (the 1st).
338
- expect(cronMatches(masks, new Date(2026, 5, 1, 0, 0, 0))).toBe(true);
339
- // 2026-06-07 is a Sunday -> matches via dow.
340
- expect(cronMatches(masks, new Date(2026, 5, 7, 0, 0, 0))).toBe(true);
341
- // 2026-06-03 is a Wednesday, not the 1st -> no match.
342
- expect(cronMatches(masks, new Date(2026, 5, 3, 0, 0, 0))).toBe(false);
343
- });
344
-
345
- it('flags an all-zero (unsatisfiable) mask as never-firing', () => {
346
- expect(cronNeverFires({ minute: 0n, hour: 0, dom: 0, month: 0, dow: 0 })).toBe(true);
347
- expect(cronNeverFires(sixHourly)).toBe(false);
348
- });
349
- });