@kayjs/kay 1.108.0 → 1.110.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 (595) hide show
  1. package/dist/eslint.js +2093 -3774
  2. package/editors/zed/extension.toml +2 -2
  3. package/llms/action-protection.md +1 -1
  4. package/llms/actions-from-islands.md +5 -5
  5. package/llms/actions-refused-fields.md +4 -4
  6. package/llms/api-from-islands.md +6 -6
  7. package/llms/browser-only.md +2 -2
  8. package/llms/cdn-caching.md +1 -1
  9. package/llms/checks.md +1 -1
  10. package/llms/code-lints.md +1 -2
  11. package/llms/component-library-conventions.md +1 -1
  12. package/llms/components.md +5 -5
  13. package/llms/deprecated-lints.md +2 -7
  14. package/llms/effects.md +1 -1
  15. package/llms/errors.md +2 -2
  16. package/llms/events.md +1 -1
  17. package/llms/guards.md +1 -1
  18. package/llms/head.md +1 -1
  19. package/llms/hooks.md +2 -2
  20. package/llms/images.md +1 -1
  21. package/llms/island-and-form-lints.md +4 -2
  22. package/llms/island-sources.md +1 -1
  23. package/llms/islands-state-to-ids.md +2 -2
  24. package/llms/islands.md +8 -4
  25. package/llms/lints.md +1 -1
  26. package/llms/live-values.md +4 -4
  27. package/llms/local-collections.md +1 -1
  28. package/llms/locales.md +1 -1
  29. package/llms/mcp.md +2 -2
  30. package/llms/metrics.md +1 -1
  31. package/llms/navigation-from-code.md +7 -7
  32. package/llms/navigation.md +4 -2
  33. package/llms/prerendering.md +1 -0
  34. package/llms/production.md +2 -2
  35. package/llms/project-new-and-add.md +1 -1
  36. package/llms/project.md +4 -4
  37. package/llms/proxy-and-security.md +1 -1
  38. package/llms/queues.md +1 -1
  39. package/llms/rate-limits.md +4 -4
  40. package/llms/rendering.md +1 -1
  41. package/llms/server-islands.md +2 -2
  42. package/llms/server.md +1 -1
  43. package/llms/stores.md +1 -1
  44. package/llms/styles-and-assets.md +1 -1
  45. package/llms/templates-elements-slots-snippets.md +2 -2
  46. package/llms/testing-mount.md +49 -0
  47. package/llms/testing.md +4 -45
  48. package/llms/upgrading-1-105-config.md +13 -13
  49. package/llms/upgrading-archive.md +64 -74
  50. package/llms/upgrading.md +92 -70
  51. package/llms/whats-new.md +24 -0
  52. package/llms.txt +5 -6
  53. package/package.json +6 -10
  54. package/src/build/route-sizes.ts +2 -3
  55. package/src/build/variants.ts +132 -18
  56. package/src/check/browser-global-reads.ts +2 -2
  57. package/src/check/config-objects.ts +1 -1
  58. package/src/check/diagnose.ts +0 -22
  59. package/src/check/env-types.ts +1 -1
  60. package/src/check/export-homes.ts +1 -1
  61. package/src/check/guards.ts +3 -3
  62. package/src/check/index.ts +2 -7
  63. package/src/check/moved-keys.ts +1 -1
  64. package/src/check/project.ts +6 -7
  65. package/src/check/schema-builders.ts +125 -26
  66. package/src/check/shadow-types.ts +0 -86
  67. package/src/commands/check.ts +2 -2
  68. package/src/commands/env.ts +25 -3
  69. package/src/commands/upgrade.ts +2 -1
  70. package/src/compiler/allow-comments.ts +38 -2
  71. package/src/compiler/ast.ts +21 -19
  72. package/src/compiler/browser.ts +2 -14
  73. package/src/compiler/class-items.ts +16 -0
  74. package/src/compiler/codegen.ts +10 -10
  75. package/src/compiler/deprecated-library.ts +0 -12
  76. package/src/compiler/deprecated-lints-1-106.ts +2 -2
  77. package/src/compiler/deprecated-lints.ts +3 -495
  78. package/src/compiler/deprecated-ui-props.ts +5 -5
  79. package/src/compiler/errors.ts +2 -2
  80. package/src/compiler/fence-checks.ts +2 -121
  81. package/src/compiler/hand-parts.ts +83 -0
  82. package/src/compiler/helper-imports.ts +2 -2
  83. package/src/compiler/image-attributes.ts +1 -3
  84. package/src/compiler/index.ts +23 -23
  85. package/src/compiler/island-arguments.ts +17 -95
  86. package/src/compiler/island-cause.ts +7 -7
  87. package/src/compiler/island-declaration.ts +2 -8
  88. package/src/compiler/island-lints.ts +19 -0
  89. package/src/compiler/island-marker.ts +3 -3
  90. package/src/compiler/island-problems.ts +25 -0
  91. package/src/compiler/items.ts +12 -0
  92. package/src/compiler/jsx-class.ts +1 -25
  93. package/src/compiler/jsx.ts +7 -6
  94. package/src/compiler/kay-exports.ts +0 -2
  95. package/src/compiler/link-flags.ts +9 -38
  96. package/src/compiler/lints.ts +10 -18
  97. package/src/compiler/markup.ts +33 -41
  98. package/src/compiler/module-signals.ts +2 -2
  99. package/src/compiler/names.ts +1 -1
  100. package/src/compiler/page-settings.ts +11 -0
  101. package/src/compiler/parser.ts +6 -8
  102. package/src/compiler/plan.ts +1 -3
  103. package/src/compiler/removed-lints.ts +90 -0
  104. package/src/compiler/rewrite.ts +3 -18
  105. package/src/compiler/script-server.ts +8 -3
  106. package/src/compiler/signal-from-prop.ts +141 -0
  107. package/src/compiler/template-reads.ts +16 -0
  108. package/src/compiler/validate.ts +3 -8
  109. package/src/config-loader.ts +14 -4
  110. package/src/config-resolve.ts +18 -142
  111. package/src/config-shape.ts +44 -34
  112. package/src/config.ts +10 -114
  113. package/src/dev/preload.ts +4 -1
  114. package/src/lsp/server.ts +4 -0
  115. package/src/migrate/markup.ts +4 -1
  116. package/src/runtime/action-call.ts +0 -8
  117. package/src/runtime/action-encode.ts +26 -0
  118. package/src/runtime/action-error.ts +3 -11
  119. package/src/runtime/action-protection.ts +2 -2
  120. package/src/runtime/action-run.ts +2 -27
  121. package/src/runtime/action-shared.ts +14 -37
  122. package/src/runtime/action-stream.ts +0 -1
  123. package/src/runtime/action.ts +1 -1
  124. package/src/runtime/call-result.ts +2 -10
  125. package/src/runtime/checks.ts +25 -13
  126. package/src/runtime/client.ts +7 -11
  127. package/src/runtime/core.ts +5 -23
  128. package/src/runtime/dom.ts +1 -1
  129. package/src/runtime/html.ts +1 -1
  130. package/src/runtime/i18n.client.ts +1 -4
  131. package/src/runtime/i18n.server.ts +1 -4
  132. package/src/runtime/i18n.ts +3 -3
  133. package/src/runtime/image.ts +2 -19
  134. package/src/runtime/index.ts +3 -3
  135. package/src/runtime/island.server.ts +56 -13
  136. package/src/runtime/live-resource.server.ts +0 -1
  137. package/src/runtime/live-value.server.ts +2 -2
  138. package/src/runtime/live-value.shared.ts +7 -20
  139. package/src/runtime/live.ts +1 -12
  140. package/src/runtime/local-types.ts +1 -11
  141. package/src/runtime/local.ts +4 -14
  142. package/src/runtime/navigate-api.ts +2 -5
  143. package/src/runtime/navigate.ts +9 -0
  144. package/src/runtime/navigation-state.ts +0 -12
  145. package/src/runtime/navigation.ts +5 -1
  146. package/src/runtime/page-swap.ts +8 -8
  147. package/src/runtime/persist.ts +11 -3
  148. package/src/runtime/persisted.ts +4 -30
  149. package/src/runtime/presence.ts +6 -7
  150. package/src/runtime/query-param.ts +20 -12
  151. package/src/runtime/reactive.ts +3 -1
  152. package/src/runtime/refuse.ts +3 -17
  153. package/src/runtime/store-base.ts +4 -6
  154. package/src/runtime/swap-fetch.ts +1 -1
  155. package/src/runtime/swap-flight.ts +10 -10
  156. package/src/runtime/swap-kept.ts +69 -29
  157. package/src/runtime/swap-morph.ts +49 -9
  158. package/src/runtime/text-hash.ts +17 -0
  159. package/src/runtime/uid.server.ts +6 -4
  160. package/src/runtime/values.ts +52 -23
  161. package/src/runtime/with-query.ts +9 -0
  162. package/src/server/action-hooks.ts +8 -8
  163. package/src/server/actions.ts +13 -14
  164. package/src/server/api-modules.ts +2 -3
  165. package/src/server/app-stages.ts +15 -33
  166. package/src/server/app.ts +10 -5
  167. package/src/server/auth-mails.ts +0 -2
  168. package/src/server/env-state.ts +40 -10
  169. package/src/server/flash.ts +1 -1
  170. package/src/server/guard-requirement.ts +4 -4
  171. package/src/server/image.ts +2 -2
  172. package/src/server/index.ts +0 -2
  173. package/src/server/job-context.ts +3 -3
  174. package/src/server/jobs-page.ts +1 -1
  175. package/src/server/jobs.ts +5 -9
  176. package/src/server/kept-exports.ts +0 -2
  177. package/src/server/kv.ts +11 -14
  178. package/src/server/library.ts +1 -3
  179. package/src/server/live.ts +2 -2
  180. package/src/server/mcp.ts +3 -9
  181. package/src/server/metrics.ts +2 -4
  182. package/src/server/page-settings.ts +10 -19
  183. package/src/server/prerender.ts +19 -2
  184. package/src/server/protection.ts +15 -18
  185. package/src/server/queue.ts +3 -6
  186. package/src/server/rate-limit.ts +0 -3
  187. package/src/server/render-document.ts +9 -7
  188. package/src/server/render.ts +1 -1
  189. package/src/server/routes.ts +7 -3
  190. package/src/server/scope.ts +3 -2
  191. package/src/server/session.ts +5 -6
  192. package/src/server/setup.ts +1 -1
  193. package/src/server/signals.ts +17 -7
  194. package/src/server/signed.ts +1 -3
  195. package/src/server/source.ts +20 -4
  196. package/src/server/speculation.ts +1 -1
  197. package/src/server/storage.ts +3 -8
  198. package/src/server/validate.ts +1 -1
  199. package/src/server/vitals.ts +1 -3
  200. package/src/server/work-scope.ts +2 -4
  201. package/src/server/work.ts +1 -1
  202. package/src/server/workflow.ts +1 -1
  203. package/src/test/index.ts +2 -1
  204. package/src/test/site-actions.ts +16 -6
  205. package/src/test/site-keys.ts +10 -15
  206. package/src/test/site-socket.ts +1 -2
  207. package/src/test/site-types.ts +0 -8
  208. package/types/build/route-sizes.d.ts.map +1 -1
  209. package/types/build/variants.d.ts +9 -1
  210. package/types/build/variants.d.ts.map +1 -1
  211. package/types/check/diagnose.d.ts.map +1 -1
  212. package/types/check/index.d.ts +1 -2
  213. package/types/check/index.d.ts.map +1 -1
  214. package/types/check/project.d.ts.map +1 -1
  215. package/types/check/schema-builders.d.ts.map +1 -1
  216. package/types/check/shadow-types.d.ts.map +1 -1
  217. package/types/commands/env.d.ts.map +1 -1
  218. package/types/commands/upgrade.d.ts.map +1 -1
  219. package/types/compiler/allow-comments.d.ts +2 -0
  220. package/types/compiler/allow-comments.d.ts.map +1 -1
  221. package/types/compiler/ast.d.ts +1 -2
  222. package/types/compiler/ast.d.ts.map +1 -1
  223. package/types/compiler/browser.d.ts.map +1 -1
  224. package/types/compiler/class-items.d.ts +7 -0
  225. package/types/compiler/class-items.d.ts.map +1 -0
  226. package/types/compiler/deprecated-library.d.ts.map +1 -1
  227. package/types/compiler/deprecated-lints-1-106.d.ts +2 -2
  228. package/types/compiler/deprecated-lints-1-106.d.ts.map +1 -1
  229. package/types/compiler/deprecated-lints.d.ts +2 -553
  230. package/types/compiler/deprecated-lints.d.ts.map +1 -1
  231. package/types/compiler/deprecated-ui-props.d.ts +1 -8
  232. package/types/compiler/deprecated-ui-props.d.ts.map +1 -1
  233. package/types/compiler/errors.d.ts +2 -2
  234. package/types/compiler/errors.d.ts.map +1 -1
  235. package/types/compiler/fence-checks.d.ts +0 -1
  236. package/types/compiler/fence-checks.d.ts.map +1 -1
  237. package/types/compiler/hand-parts.d.ts +10 -0
  238. package/types/compiler/hand-parts.d.ts.map +1 -0
  239. package/types/compiler/image-attributes.d.ts +0 -1
  240. package/types/compiler/image-attributes.d.ts.map +1 -1
  241. package/types/compiler/index.d.ts.map +1 -1
  242. package/types/compiler/island-arguments.d.ts +7 -11
  243. package/types/compiler/island-arguments.d.ts.map +1 -1
  244. package/types/compiler/island-cause.d.ts +1 -1
  245. package/types/compiler/island-cause.d.ts.map +1 -1
  246. package/types/compiler/island-declaration.d.ts +1 -3
  247. package/types/compiler/island-declaration.d.ts.map +1 -1
  248. package/types/compiler/island-lints.d.ts +17 -0
  249. package/types/compiler/island-lints.d.ts.map +1 -0
  250. package/types/compiler/island-problems.d.ts +7 -0
  251. package/types/compiler/island-problems.d.ts.map +1 -0
  252. package/types/compiler/items.d.ts +1 -0
  253. package/types/compiler/items.d.ts.map +1 -1
  254. package/types/compiler/jsx-class.d.ts +1 -2
  255. package/types/compiler/jsx-class.d.ts.map +1 -1
  256. package/types/compiler/jsx.d.ts.map +1 -1
  257. package/types/compiler/kay-exports.d.ts.map +1 -1
  258. package/types/compiler/link-flags.d.ts +0 -6
  259. package/types/compiler/link-flags.d.ts.map +1 -1
  260. package/types/compiler/lints.d.ts +21 -566
  261. package/types/compiler/lints.d.ts.map +1 -1
  262. package/types/compiler/markup.d.ts +1 -1
  263. package/types/compiler/markup.d.ts.map +1 -1
  264. package/types/compiler/module-signals.d.ts.map +1 -1
  265. package/types/compiler/names.d.ts.map +1 -1
  266. package/types/compiler/page-settings.d.ts +4 -0
  267. package/types/compiler/page-settings.d.ts.map +1 -1
  268. package/types/compiler/parser.d.ts.map +1 -1
  269. package/types/compiler/plan.d.ts.map +1 -1
  270. package/types/compiler/removed-lints.d.ts +3 -0
  271. package/types/compiler/removed-lints.d.ts.map +1 -0
  272. package/types/compiler/script-server.d.ts.map +1 -1
  273. package/types/compiler/signal-from-prop.d.ts +4 -0
  274. package/types/compiler/signal-from-prop.d.ts.map +1 -0
  275. package/types/compiler/template-reads.d.ts +1 -0
  276. package/types/compiler/template-reads.d.ts.map +1 -1
  277. package/types/compiler/validate.d.ts.map +1 -1
  278. package/types/config-loader.d.ts.map +1 -1
  279. package/types/config-resolve.d.ts.map +1 -1
  280. package/types/config-shape.d.ts +1 -1
  281. package/types/config-shape.d.ts.map +1 -1
  282. package/types/config.d.ts +5 -105
  283. package/types/config.d.ts.map +1 -1
  284. package/types/dev/preload.d.ts.map +1 -1
  285. package/types/lsp/server.d.ts.map +1 -1
  286. package/types/migrate/markup.d.ts.map +1 -1
  287. package/types/runtime/action-call.d.ts.map +1 -1
  288. package/types/runtime/action-encode.d.ts +1 -0
  289. package/types/runtime/action-encode.d.ts.map +1 -1
  290. package/types/runtime/action-error.d.ts +1 -2
  291. package/types/runtime/action-error.d.ts.map +1 -1
  292. package/types/runtime/action-run.d.ts.map +1 -1
  293. package/types/runtime/action-shared.d.ts +1 -27
  294. package/types/runtime/action-shared.d.ts.map +1 -1
  295. package/types/runtime/action-stream.d.ts.map +1 -1
  296. package/types/runtime/action.d.ts +1 -1
  297. package/types/runtime/action.d.ts.map +1 -1
  298. package/types/runtime/call-result.d.ts +0 -10
  299. package/types/runtime/call-result.d.ts.map +1 -1
  300. package/types/runtime/checks.d.ts +14 -11
  301. package/types/runtime/checks.d.ts.map +1 -1
  302. package/types/runtime/client.d.ts.map +1 -1
  303. package/types/runtime/core.d.ts +2 -20
  304. package/types/runtime/core.d.ts.map +1 -1
  305. package/types/runtime/dom.d.ts +1 -1
  306. package/types/runtime/dom.d.ts.map +1 -1
  307. package/types/runtime/html.d.ts +1 -1
  308. package/types/runtime/html.d.ts.map +1 -1
  309. package/types/runtime/i18n.client.d.ts +0 -1
  310. package/types/runtime/i18n.client.d.ts.map +1 -1
  311. package/types/runtime/i18n.d.ts +1 -1
  312. package/types/runtime/i18n.d.ts.map +1 -1
  313. package/types/runtime/i18n.server.d.ts +0 -1
  314. package/types/runtime/i18n.server.d.ts.map +1 -1
  315. package/types/runtime/image.d.ts.map +1 -1
  316. package/types/runtime/index.d.ts +3 -3
  317. package/types/runtime/index.d.ts.map +1 -1
  318. package/types/runtime/island.server.d.ts +2 -0
  319. package/types/runtime/island.server.d.ts.map +1 -1
  320. package/types/runtime/live-resource.server.d.ts.map +1 -1
  321. package/types/runtime/live-value.shared.d.ts +7 -15
  322. package/types/runtime/live-value.shared.d.ts.map +1 -1
  323. package/types/runtime/live.d.ts +0 -11
  324. package/types/runtime/live.d.ts.map +1 -1
  325. package/types/runtime/local-types.d.ts +0 -14
  326. package/types/runtime/local-types.d.ts.map +1 -1
  327. package/types/runtime/navigate-api.d.ts +0 -4
  328. package/types/runtime/navigate-api.d.ts.map +1 -1
  329. package/types/runtime/navigate.d.ts.map +1 -1
  330. package/types/runtime/navigation-state.d.ts +0 -4
  331. package/types/runtime/navigation-state.d.ts.map +1 -1
  332. package/types/runtime/navigation.d.ts +2 -0
  333. package/types/runtime/navigation.d.ts.map +1 -1
  334. package/types/runtime/page-swap.d.ts.map +1 -1
  335. package/types/runtime/persist.d.ts +1 -0
  336. package/types/runtime/persist.d.ts.map +1 -1
  337. package/types/runtime/persisted.d.ts +0 -15
  338. package/types/runtime/persisted.d.ts.map +1 -1
  339. package/types/runtime/presence.d.ts +0 -2
  340. package/types/runtime/presence.d.ts.map +1 -1
  341. package/types/runtime/query-param.d.ts.map +1 -1
  342. package/types/runtime/reactive.d.ts +2 -1
  343. package/types/runtime/reactive.d.ts.map +1 -1
  344. package/types/runtime/refuse.d.ts +0 -7
  345. package/types/runtime/refuse.d.ts.map +1 -1
  346. package/types/runtime/store-base.d.ts +1 -2
  347. package/types/runtime/store-base.d.ts.map +1 -1
  348. package/types/runtime/swap-flight.d.ts +1 -1
  349. package/types/runtime/swap-flight.d.ts.map +1 -1
  350. package/types/runtime/swap-kept.d.ts.map +1 -1
  351. package/types/runtime/swap-morph.d.ts.map +1 -1
  352. package/types/runtime/text-hash.d.ts +2 -0
  353. package/types/runtime/text-hash.d.ts.map +1 -0
  354. package/types/runtime/uid.server.d.ts.map +1 -1
  355. package/types/runtime/values.d.ts +6 -1
  356. package/types/runtime/values.d.ts.map +1 -1
  357. package/types/runtime/with-query.d.ts +2 -0
  358. package/types/runtime/with-query.d.ts.map +1 -1
  359. package/types/server/action-hooks.d.ts +4 -4
  360. package/types/server/action-hooks.d.ts.map +1 -1
  361. package/types/server/actions.d.ts.map +1 -1
  362. package/types/server/api-modules.d.ts +0 -1
  363. package/types/server/api-modules.d.ts.map +1 -1
  364. package/types/server/app-stages.d.ts +5 -13
  365. package/types/server/app-stages.d.ts.map +1 -1
  366. package/types/server/app.d.ts +3 -8
  367. package/types/server/app.d.ts.map +1 -1
  368. package/types/server/auth-mails.d.ts +0 -5
  369. package/types/server/auth-mails.d.ts.map +1 -1
  370. package/types/server/env-state.d.ts +1 -0
  371. package/types/server/env-state.d.ts.map +1 -1
  372. package/types/server/guard-requirement.d.ts +0 -1
  373. package/types/server/guard-requirement.d.ts.map +1 -1
  374. package/types/server/image.d.ts +0 -1
  375. package/types/server/image.d.ts.map +1 -1
  376. package/types/server/index.d.ts +0 -2
  377. package/types/server/index.d.ts.map +1 -1
  378. package/types/server/job-context.d.ts +1 -1
  379. package/types/server/job-context.d.ts.map +1 -1
  380. package/types/server/jobs.d.ts +0 -4
  381. package/types/server/jobs.d.ts.map +1 -1
  382. package/types/server/kept-exports.d.ts.map +1 -1
  383. package/types/server/kv.d.ts +4 -4
  384. package/types/server/kv.d.ts.map +1 -1
  385. package/types/server/library.d.ts +1 -3
  386. package/types/server/library.d.ts.map +1 -1
  387. package/types/server/mcp.d.ts +0 -1
  388. package/types/server/mcp.d.ts.map +1 -1
  389. package/types/server/metrics.d.ts +0 -5
  390. package/types/server/metrics.d.ts.map +1 -1
  391. package/types/server/page-settings.d.ts +3 -3
  392. package/types/server/page-settings.d.ts.map +1 -1
  393. package/types/server/prerender.d.ts.map +1 -1
  394. package/types/server/protection.d.ts +6 -6
  395. package/types/server/protection.d.ts.map +1 -1
  396. package/types/server/queue.d.ts +1 -3
  397. package/types/server/queue.d.ts.map +1 -1
  398. package/types/server/rate-limit.d.ts +0 -2
  399. package/types/server/rate-limit.d.ts.map +1 -1
  400. package/types/server/render-document.d.ts +1 -1
  401. package/types/server/render-document.d.ts.map +1 -1
  402. package/types/server/routes.d.ts +1 -1
  403. package/types/server/routes.d.ts.map +1 -1
  404. package/types/server/scope.d.ts.map +1 -1
  405. package/types/server/session.d.ts +1 -1
  406. package/types/server/session.d.ts.map +1 -1
  407. package/types/server/signals.d.ts.map +1 -1
  408. package/types/server/signed.d.ts +0 -2
  409. package/types/server/signed.d.ts.map +1 -1
  410. package/types/server/source.d.ts +1 -1
  411. package/types/server/source.d.ts.map +1 -1
  412. package/types/server/storage.d.ts +0 -4
  413. package/types/server/storage.d.ts.map +1 -1
  414. package/types/server/vitals.d.ts +0 -1
  415. package/types/server/vitals.d.ts.map +1 -1
  416. package/types/server/work-scope.d.ts +0 -2
  417. package/types/server/work-scope.d.ts.map +1 -1
  418. package/types/server/workflow.d.ts +1 -1
  419. package/types/server/workflow.d.ts.map +1 -1
  420. package/types/test/index.d.ts.map +1 -1
  421. package/types/test/site-actions.d.ts +1 -1
  422. package/types/test/site-actions.d.ts.map +1 -1
  423. package/types/test/site-keys.d.ts +1 -1
  424. package/types/test/site-keys.d.ts.map +1 -1
  425. package/types/test/site-socket.d.ts +1 -1
  426. package/types/test/site-socket.d.ts.map +1 -1
  427. package/types/test/site-types.d.ts +0 -8
  428. package/types/test/site-types.d.ts.map +1 -1
  429. package/llms/deprecated-lints-1-105-libraries.md +0 -32
  430. package/llms/deprecated-lints-1-105.md +0 -58
  431. package/src/check/action-readers.ts +0 -115
  432. package/src/check/action-type.ts +0 -44
  433. package/src/check/ai-language.ts +0 -56
  434. package/src/check/app-hooks.ts +0 -90
  435. package/src/check/auth-methods.ts +0 -85
  436. package/src/check/auth-rate-limits.ts +0 -99
  437. package/src/check/call-result.ts +0 -242
  438. package/src/check/client-keys.ts +0 -10
  439. package/src/check/cms-options.ts +0 -81
  440. package/src/check/config-groups.ts +0 -22
  441. package/src/check/config-switches.ts +0 -38
  442. package/src/check/context-import.ts +0 -51
  443. package/src/check/env-files.ts +0 -31
  444. package/src/check/format-duration.ts +0 -75
  445. package/src/check/guard-options.ts +0 -58
  446. package/src/check/handler-events.ts +0 -149
  447. package/src/check/hook-context.ts +0 -94
  448. package/src/check/hook-names.ts +0 -104
  449. package/src/check/i18n-keys.ts +0 -50
  450. package/src/check/images-keys.ts +0 -54
  451. package/src/check/job-shapes.ts +0 -273
  452. package/src/check/link-flag-tests.ts +0 -130
  453. package/src/check/live-api.ts +0 -137
  454. package/src/check/mail-api.ts +0 -67
  455. package/src/check/one-state-api.ts +0 -357
  456. package/src/check/pages-options.ts +0 -35
  457. package/src/check/rate-enforce.ts +0 -53
  458. package/src/check/refusal-calls.ts +0 -185
  459. package/src/check/retired-lints.ts +0 -49
  460. package/src/check/route-keys.ts +0 -166
  461. package/src/check/secret-keys.ts +0 -83
  462. package/src/check/socket-frames.ts +0 -102
  463. package/src/check/source-readers.ts +0 -257
  464. package/src/check/store-ms.ts +0 -72
  465. package/src/check/store-names.ts +0 -88
  466. package/src/check/test-helpers.ts +0 -98
  467. package/src/check/ttl-names.ts +0 -142
  468. package/src/compiler/deprecated-ai-labels.ts +0 -97
  469. package/src/compiler/deprecated-ai-links.ts +0 -63
  470. package/src/compiler/deprecated-allow.ts +0 -50
  471. package/src/compiler/deprecated-auth-lints.ts +0 -14
  472. package/src/compiler/deprecated-auth-signed.ts +0 -29
  473. package/src/compiler/deprecated-children.ts +0 -66
  474. package/src/compiler/deprecated-image.ts +0 -116
  475. package/src/compiler/deprecated-island.ts +0 -155
  476. package/src/compiler/deprecated-lints-1-105.ts +0 -41
  477. package/src/compiler/deprecated-page.ts +0 -125
  478. package/src/compiler/deprecated-parts.ts +0 -22
  479. package/src/compiler/deprecated-typed-lints.ts +0 -23
  480. package/src/compiler/deprecated-ui-callbacks.ts +0 -66
  481. package/src/compiler/deprecated-ui-input.ts +0 -97
  482. package/src/compiler/deprecated-ui-items.ts +0 -47
  483. package/src/compiler/old-parts.ts +0 -84
  484. package/src/runtime/mount.compat.ts +0 -8
  485. package/src/server/moved-exports.ts +0 -17
  486. package/types/check/action-readers.d.ts +0 -3
  487. package/types/check/action-readers.d.ts.map +0 -1
  488. package/types/check/action-type.d.ts +0 -3
  489. package/types/check/action-type.d.ts.map +0 -1
  490. package/types/check/ai-language.d.ts +0 -3
  491. package/types/check/ai-language.d.ts.map +0 -1
  492. package/types/check/app-hooks.d.ts +0 -3
  493. package/types/check/app-hooks.d.ts.map +0 -1
  494. package/types/check/auth-methods.d.ts +0 -3
  495. package/types/check/auth-methods.d.ts.map +0 -1
  496. package/types/check/auth-rate-limits.d.ts +0 -3
  497. package/types/check/auth-rate-limits.d.ts.map +0 -1
  498. package/types/check/call-result.d.ts +0 -7
  499. package/types/check/call-result.d.ts.map +0 -1
  500. package/types/check/client-keys.d.ts +0 -3
  501. package/types/check/client-keys.d.ts.map +0 -1
  502. package/types/check/cms-options.d.ts +0 -3
  503. package/types/check/cms-options.d.ts.map +0 -1
  504. package/types/check/config-groups.d.ts +0 -3
  505. package/types/check/config-groups.d.ts.map +0 -1
  506. package/types/check/config-switches.d.ts +0 -3
  507. package/types/check/config-switches.d.ts.map +0 -1
  508. package/types/check/context-import.d.ts +0 -3
  509. package/types/check/context-import.d.ts.map +0 -1
  510. package/types/check/env-files.d.ts +0 -3
  511. package/types/check/env-files.d.ts.map +0 -1
  512. package/types/check/format-duration.d.ts +0 -5
  513. package/types/check/format-duration.d.ts.map +0 -1
  514. package/types/check/guard-options.d.ts +0 -3
  515. package/types/check/guard-options.d.ts.map +0 -1
  516. package/types/check/handler-events.d.ts +0 -9
  517. package/types/check/handler-events.d.ts.map +0 -1
  518. package/types/check/hook-context.d.ts +0 -3
  519. package/types/check/hook-context.d.ts.map +0 -1
  520. package/types/check/hook-names.d.ts +0 -3
  521. package/types/check/hook-names.d.ts.map +0 -1
  522. package/types/check/i18n-keys.d.ts +0 -3
  523. package/types/check/i18n-keys.d.ts.map +0 -1
  524. package/types/check/images-keys.d.ts +0 -3
  525. package/types/check/images-keys.d.ts.map +0 -1
  526. package/types/check/job-shapes.d.ts +0 -6
  527. package/types/check/job-shapes.d.ts.map +0 -1
  528. package/types/check/link-flag-tests.d.ts +0 -4
  529. package/types/check/link-flag-tests.d.ts.map +0 -1
  530. package/types/check/live-api.d.ts +0 -3
  531. package/types/check/live-api.d.ts.map +0 -1
  532. package/types/check/mail-api.d.ts +0 -3
  533. package/types/check/mail-api.d.ts.map +0 -1
  534. package/types/check/one-state-api.d.ts +0 -9
  535. package/types/check/one-state-api.d.ts.map +0 -1
  536. package/types/check/pages-options.d.ts +0 -3
  537. package/types/check/pages-options.d.ts.map +0 -1
  538. package/types/check/rate-enforce.d.ts +0 -3
  539. package/types/check/rate-enforce.d.ts.map +0 -1
  540. package/types/check/refusal-calls.d.ts +0 -3
  541. package/types/check/refusal-calls.d.ts.map +0 -1
  542. package/types/check/retired-lints.d.ts +0 -3
  543. package/types/check/retired-lints.d.ts.map +0 -1
  544. package/types/check/route-keys.d.ts +0 -3
  545. package/types/check/route-keys.d.ts.map +0 -1
  546. package/types/check/secret-keys.d.ts +0 -3
  547. package/types/check/secret-keys.d.ts.map +0 -1
  548. package/types/check/socket-frames.d.ts +0 -3
  549. package/types/check/socket-frames.d.ts.map +0 -1
  550. package/types/check/source-readers.d.ts +0 -3
  551. package/types/check/source-readers.d.ts.map +0 -1
  552. package/types/check/store-ms.d.ts +0 -3
  553. package/types/check/store-ms.d.ts.map +0 -1
  554. package/types/check/store-names.d.ts +0 -3
  555. package/types/check/store-names.d.ts.map +0 -1
  556. package/types/check/test-helpers.d.ts +0 -3
  557. package/types/check/test-helpers.d.ts.map +0 -1
  558. package/types/check/ttl-names.d.ts +0 -3
  559. package/types/check/ttl-names.d.ts.map +0 -1
  560. package/types/compiler/deprecated-ai-labels.d.ts +0 -5
  561. package/types/compiler/deprecated-ai-labels.d.ts.map +0 -1
  562. package/types/compiler/deprecated-ai-links.d.ts +0 -5
  563. package/types/compiler/deprecated-ai-links.d.ts.map +0 -1
  564. package/types/compiler/deprecated-allow.d.ts +0 -5
  565. package/types/compiler/deprecated-allow.d.ts.map +0 -1
  566. package/types/compiler/deprecated-auth-lints.d.ts +0 -12
  567. package/types/compiler/deprecated-auth-lints.d.ts.map +0 -1
  568. package/types/compiler/deprecated-auth-signed.d.ts +0 -5
  569. package/types/compiler/deprecated-auth-signed.d.ts.map +0 -1
  570. package/types/compiler/deprecated-children.d.ts +0 -4
  571. package/types/compiler/deprecated-children.d.ts.map +0 -1
  572. package/types/compiler/deprecated-image.d.ts +0 -5
  573. package/types/compiler/deprecated-image.d.ts.map +0 -1
  574. package/types/compiler/deprecated-island.d.ts +0 -9
  575. package/types/compiler/deprecated-island.d.ts.map +0 -1
  576. package/types/compiler/deprecated-lints-1-105.d.ts +0 -39
  577. package/types/compiler/deprecated-lints-1-105.d.ts.map +0 -1
  578. package/types/compiler/deprecated-page.d.ts +0 -4
  579. package/types/compiler/deprecated-page.d.ts.map +0 -1
  580. package/types/compiler/deprecated-parts.d.ts +0 -3
  581. package/types/compiler/deprecated-parts.d.ts.map +0 -1
  582. package/types/compiler/deprecated-typed-lints.d.ts +0 -21
  583. package/types/compiler/deprecated-typed-lints.d.ts.map +0 -1
  584. package/types/compiler/deprecated-ui-callbacks.d.ts +0 -5
  585. package/types/compiler/deprecated-ui-callbacks.d.ts.map +0 -1
  586. package/types/compiler/deprecated-ui-input.d.ts +0 -5
  587. package/types/compiler/deprecated-ui-input.d.ts.map +0 -1
  588. package/types/compiler/deprecated-ui-items.d.ts +0 -5
  589. package/types/compiler/deprecated-ui-items.d.ts.map +0 -1
  590. package/types/compiler/old-parts.d.ts +0 -9
  591. package/types/compiler/old-parts.d.ts.map +0 -1
  592. package/types/runtime/mount.compat.d.ts +0 -7
  593. package/types/runtime/mount.compat.d.ts.map +0 -1
  594. package/types/server/moved-exports.d.ts +0 -12
  595. package/types/server/moved-exports.d.ts.map +0 -1
@@ -1,104 +0,0 @@
1
- import type { CheckDiagnostic, CheckOptions } from '.'
2
- import type { Node, NodeOfType } from '../compiler/estree'
3
- import { lintLevel } from '../compiler/lints'
4
- import { keyName } from '../compiler/object-literal'
5
- import { renamePackages } from '../package-names'
6
- import { importsOf, walk } from './ast'
7
- import { scan } from './renamed-exports'
8
-
9
- type ObjectNode = NodeOfType<'ObjectExpression'>
10
- type Property = Extract<ObjectNode['properties'][number], { type: 'Property' }>
11
-
12
- interface Library {
13
- // The package whose imports the calls come from.
14
- package: string
15
- // The functions of the package that take hooks in their options.
16
- calls: readonly string[]
17
- // The options of kayjs-mail's lists are read off any `.list()` call in a file importing the package.
18
- lists?: boolean
19
- // `cms({ collections: { posts: { onSave } } })` sets the same hooks per collection.
20
- collections?: boolean
21
- hooks: Readonly<Record<string, string>>
22
- }
23
-
24
- const LIBRARIES: readonly Library[] = [
25
- { package: '@kayjs/auth', calls: ['auth', 'authCore'], hooks: { onSignUp: 'afterSignUp' } },
26
- { package: '@kayjs/mail', calls: ['mail', 'mailer', 'contactForm'], lists: true, hooks: { onSend: 'afterSend', onSuppress: 'afterSuppress', onSubscribe: 'afterSubscribe', onConfirm: 'afterConfirm', onUnsubscribe: 'afterUnsubscribe', onBroadcast: 'afterBroadcast' } },
27
- { package: '@kayjs/cms', calls: ['cms'], collections: true, hooks: { onSave: 'afterSave', onUpload: 'afterUpload' } },
28
- { package: '@kayjs/ai', calls: ['ai', 'ask', 'speak', 'embed', 'transcribe', 'describeImage'], hooks: { onStep: 'afterStep', onToolCall: 'afterToolCall', onSuccess: 'afterRequest' } },
29
- ]
30
-
31
- const NEEDLE = /\b(?:onSignUp|onSend|onSuppress|onSubscribe|onConfirm|onUnsubscribe|onBroadcast|onSave|onUpload|onStep|onToolCall|onSuccess)\b/
32
- const HELP = 'write the `after` name: a hook that is told what happened is `after<Verb>`, one that may refuse or change it `before<Verb>`'
33
-
34
- // A server hook of kayjs-auth, -mail, -cms or -ai under its name before 1.105, when the ones that observe became `after<Verb>`: `onSignUp` is `afterSignUp`, `onSend` and `onSuppress` of the mailer and `onSend` of `contactForm()` are `afterSend` and `afterSuppress`, a list's `onSubscribe`, `onConfirm`, `onUnsubscribe` and `onBroadcast` follow, `onSave` and `onUpload` of `cms()` (and of each collection) are `afterSave` and `afterUpload`, and `onStep`, `onToolCall` and `onSuccess` of kayjs-ai are `afterStep`, `afterToolCall` and `afterRequest`; `onError` and `onEvent` keep their names.
35
- // Found in the options object written in a call of the library's function imported from it, and in the `hooks` object of kayjs-auth's `src/auth.ts`; the fix renames the key, a bare `{ onSave }` becoming `afterSave: onSave`, and offers none where the object spreads another or already writes the new name.
36
- export async function hookNames(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
37
- if (lintLevel('deprecated-hook-names', options.lints) === 'allow')
38
- return []
39
-
40
- return scan(root, options, 'deprecated-hook-names', NEEDLE, ({ parsed, report }) => {
41
- for (const { ast, base } of parsed) {
42
- for (const library of LIBRARIES) {
43
- const from = (source: string) => renamePackages(source) === library.package
44
- const found = library.calls.map(name => ({ name, ...importsOf(ast, from, name) }))
45
- const imported = ast.body.some(statement => statement.type === 'ImportDeclaration' && statement.importKind !== 'type' && from(statement.source.value))
46
-
47
- if (!imported && library.package !== '@kayjs/auth')
48
- continue
49
-
50
- const isCall = (callee: Node): boolean => found.some(({ name, locals, namespaces }) => callee.type === 'Identifier'
51
- ? locals.has(callee.name)
52
- : callee.type === 'MemberExpression' && !callee.computed && callee.object.type === 'Identifier' && namespaces.has(callee.object.name) && callee.property.type === 'Identifier' && callee.property.name === name)
53
- const isList = (callee: Node): boolean => library.lists === true && imported && callee.type === 'MemberExpression' && !callee.computed && callee.property.type === 'Identifier' && callee.property.name === 'list'
54
-
55
- const check = (object: ObjectNode): void => {
56
- const properties = object.properties.filter((property): property is Property => property.type === 'Property')
57
- const spread = object.properties.some(property => property.type === 'SpreadElement')
58
- const keys = new Set(properties.filter(property => !property.computed).map(property => keyName(property)))
59
-
60
- for (const property of properties) {
61
- const old = property.computed ? undefined : keyName(property)
62
- const name = old === undefined ? undefined : library.hooks[old]
63
-
64
- if (old === undefined || name === undefined)
65
- continue
66
-
67
- const fixable = !spread && !keys.has(name)
68
- const text = property.shorthand ? `${name}: ${old}` : name
69
- const edit = property.shorthand ? { start: base + property.start, end: base + property.end, text } : { start: base + property.key.start, end: base + property.key.end, text }
70
-
71
- report(base + property.start, base + property.end, `\`${old}\` is \`${name}\` since 1.105: a server hook that is told what happened is \`after<Verb>\``, HELP, fixable ? [edit] : null)
72
- }
73
-
74
- if (!library.collections)
75
- return
76
-
77
- const collections = properties.find(property => !property.computed && keyName(property) === 'collections')?.value
78
-
79
- if (collections?.type !== 'ObjectExpression')
80
- return
81
-
82
- for (const each of collections.properties) {
83
- if (each.type === 'Property' && each.value.type === 'ObjectExpression')
84
- check(each.value)
85
- }
86
- }
87
-
88
- walk(ast, (node) => {
89
- if (node.type === 'CallExpression' && (isCall(node.callee) || isList(node.callee))) {
90
- for (const argument of node.arguments) {
91
- if (argument.type === 'ObjectExpression')
92
- check(argument)
93
- }
94
-
95
- return
96
- }
97
-
98
- if (library.package === '@kayjs/auth' && node.type === 'VariableDeclarator' && node.id.type === 'Identifier' && node.id.name === 'hooks' && node.init?.type === 'ObjectExpression')
99
- check(node.init)
100
- })
101
- }
102
- }
103
- })
104
- }
@@ -1,50 +0,0 @@
1
- import type { CheckDiagnostic, CheckOptions } from '.'
2
- import type { Edit } from './renamed-exports'
3
- import { lintLevel } from '../compiler/lints'
4
- import { configObjects, propertyOf } from './config-objects'
5
- import { scan } from './renamed-exports'
6
-
7
- const NEEDLE = /\b(?:defaultLocale|prefixDefault|domains)\b/
8
-
9
- // The keys `defaultLocale`, `prefixDefault` and `domains` of `i18n` in the config, which are `default` and `mode` since 1.105: `mode: 'always'` for `prefixDefault: true`, `mode: { domains }` for `domains`.
10
- // The fix renames or rewrites one key where the object is written in place and `default` and `mode` are not yet there, and offers none for `domains` together with `prefixDefault`, a `prefixDefault` that is no literal, or a key written as a method or a getter.
11
- export async function i18nKeys(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
12
- if (lintLevel('deprecated-i18n-keys', options.lints) === 'allow')
13
- return []
14
-
15
- return scan(root, options, 'deprecated-i18n-keys', NEEDLE, ({ file, parsed, report }) => {
16
- for (const { ast, base, text } of parsed) {
17
- for (const { object, call } of configObjects(file, ast)) {
18
- const i18n = call === undefined ? propertyOf(object, 'i18n') : undefined
19
- const group = i18n?.value.type === 'ObjectExpression' ? i18n.value : undefined
20
-
21
- if (group === undefined)
22
- continue
23
-
24
- const plain = group.properties.flatMap(property => property.type === 'Property' && !property.computed && !property.method && property.kind === 'init' ? [property] : [])
25
- const named = (name: string) => plain.find(property => property.key.type === 'Identifier' ? property.key.name === name : property.key.type === 'Literal' && property.key.value === name)
26
- const [defaultLocale, prefixDefault, domains] = [named('defaultLocale'), named('prefixDefault'), named('domains')]
27
- const spread = group.properties.some(property => property.type !== 'Property')
28
-
29
- if (defaultLocale !== undefined) {
30
- const edits: Edit[] | null = spread || named('default') !== undefined ? null : [defaultLocale.shorthand ? { start: base + defaultLocale.start, end: base + defaultLocale.end, text: 'default: defaultLocale' } : { start: base + defaultLocale.key.start, end: base + defaultLocale.key.end, text: 'default' }]
31
-
32
- report(base + defaultLocale.start, base + defaultLocale.end, '`i18n.defaultLocale` is `i18n.default` since 1.105', 'write `default`', edits)
33
- }
34
-
35
- if (prefixDefault !== undefined) {
36
- const { value } = prefixDefault
37
- const free = !spread && named('mode') === undefined && domains === undefined && value.type === 'Literal' && value.value === true
38
-
39
- report(base + prefixDefault.start, base + prefixDefault.end, '`i18n.prefixDefault` is `i18n.mode: \'always\'` since 1.105', 'write `mode: \'always\'`', free && !prefixDefault.shorthand ? [{ start: base + prefixDefault.start, end: base + prefixDefault.end, text: 'mode: \'always\'' }] : null)
40
- }
41
-
42
- if (domains !== undefined) {
43
- const free = !spread && named('mode') === undefined && prefixDefault === undefined
44
-
45
- report(base + domains.start, base + domains.end, '`i18n.domains` is `i18n.mode: { domains }` since 1.105', 'write `mode: { domains }`', free ? [{ start: base + domains.start, end: base + domains.end, text: domains.shorthand ? 'mode: { domains }' : `mode: { domains: ${text.slice(domains.value.start, domains.value.end)} }` }] : null)
46
- }
47
- }
48
- }
49
- })
50
- }
@@ -1,54 +0,0 @@
1
- import type { CheckDiagnostic, CheckOptions } from '.'
2
- import { basename } from 'node:path'
3
- import { lintLevel } from '../compiler/lints'
4
- import { constBindings, exportedObject, objectOf } from '../compiler/object-literal'
5
- import { featureProperties } from './config-objects'
6
- import { nameOf, regrouped } from './regroup'
7
- import { scan } from './renamed-exports'
8
-
9
- const NEEDLE = /\bimages\b/
10
- const HELP = 'group the key, `remote: { maxSize, timeout }`, `formats: { quality, webp, avif }`, `limits: { variants, queue }`'
11
-
12
- // Each flat key of `images` before 1.105 and the group and part it became.
13
- const MOVED: Record<string, [string, string]> = {
14
- remoteMaxSize: ['remote', 'maxSize'],
15
- remoteTimeout: ['remote', 'timeout'],
16
- maxVariants: ['limits', 'variants'],
17
- queue: ['limits', 'queue'],
18
- quality: ['formats', 'quality'],
19
- webp: ['formats', 'webp'],
20
- avif: ['formats', 'avif'],
21
- }
22
-
23
- const movedTo = (name: string): [string, string] | undefined => Object.hasOwn(MOVED, name) ? MOVED[name] : undefined
24
-
25
- // The flat keys of `images` in kay.config.ts, grouped since 1.105: `remote: { hosts, maxSize, timeout }`, `formats: { quality, webp, avif }`, `limits: { variants, queue }`.
26
- // The fix, from the first report of an object, moves only those keys and offers none where the object spreads, holds a computed or shorthand key, names a part twice or already has the group.
27
- export async function imagesKeys(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
28
- if (lintLevel('deprecated-images-keys', options.lints) === 'allow')
29
- return []
30
-
31
- return scan(root, options, 'deprecated-images-keys', NEEDLE, ({ file, parsed, report }) => {
32
- if (basename(file) !== 'kay.config.ts')
33
- return
34
-
35
- for (const { ast, base, text } of parsed) {
36
- const bindings = constBindings(ast)
37
- const exported = exportedObject(ast, bindings)
38
-
39
- for (const images of exported === undefined ? [] : featureProperties(exported, bindings, 'assets', 'images')) {
40
- const object = objectOf(images.value, bindings)
41
- const old = object?.properties.filter(property => property.type === 'Property' && !property.computed && movedTo(nameOf(property)) !== undefined) ?? []
42
-
43
- if (object === undefined || old.length === 0)
44
- continue
45
-
46
- // A bound object lives elsewhere in the file, so its keys are found and not rewritten from here.
47
- const fixed = images.value === object ? regrouped(object, text, movedTo) : undefined
48
-
49
- for (const [index, property] of old.entries())
50
- report(base + property.start, base + property.end, `\`images.${nameOf(property)}\` is grouped since 1.105`, HELP, index === 0 && fixed !== undefined ? fixed.map(edit => ({ ...edit, start: base + edit.start, end: base + edit.end })) : null)
51
- }
52
- }
53
- })
54
- }
@@ -1,273 +0,0 @@
1
- import type { CheckDiagnostic, CheckOptions } from '.'
2
- import type { Node, NodeOfType } from '../compiler/estree'
3
- import type { Edit, Found } from './renamed-exports'
4
- import { lintLevel } from '../compiler/lints'
5
- import { keyName } from '../compiler/object-literal'
6
- import { DURATION_TEXT } from '../runtime/duration'
7
- import { importsOf, walk } from './ast'
8
- import { renamedCallOptions } from './renamed-call-options'
9
- import { scan } from './renamed-exports'
10
-
11
- const FROM_SERVER = (source: string) => source === 'kay/server' || source === '@kayjs/kay/server'
12
- const JOBS = /\b(?:queue|workflow|schedule|background)\b/
13
- const UNDERSCORE = /(?<![\w$])_(?:input)?(?![\w$])/
14
- const SCHEDULE = /\bschedule\b/
15
- const LOST_AFTER = /\blostAfter\b/
16
- const DISK_FILES = /\bdiskFiles\b/
17
- const COMMENT = /\/[*/]/
18
- const SIGNAL_NAME = /signal|abort/i
19
- const JOB_CALLS = ['queue', 'workflow', 'schedule', 'background'] as const
20
-
21
- type CallNode = NodeOfType<'CallExpression'>
22
- type FunctionNode = NodeOfType<'ArrowFunctionExpression'> | NodeOfType<'FunctionExpression'>
23
- type Param = FunctionNode['params'][number]
24
-
25
- const isFunction = (node: Node | undefined): node is FunctionNode => node?.type === 'ArrowFunctionExpression' || node?.type === 'FunctionExpression'
26
-
27
- // The job function a call of `queue`, `workflow`, `schedule` or `background` from `kay/server` is: its name, as it was imported or read off `import * as`.
28
- function jobCall(ast: Parameters<typeof importsOf>[0]): (callee: Node) => (typeof JOB_CALLS)[number] | undefined {
29
- const bound = JOB_CALLS.map(name => ({ name, ...importsOf(ast, FROM_SERVER, name) })).filter(call => call.locals.size > 0 || call.namespaces.size > 0)
30
-
31
- return callee => bound.find(call => callee.type === 'Identifier'
32
- ? call.locals.has(callee.name)
33
- : callee.type === 'MemberExpression' && !callee.computed && callee.object.type === 'Identifier' && call.namespaces.has(callee.object.name) && callee.property.type === 'Identifier' && callee.property.name === call.name)?.name
34
- }
35
-
36
- // Whether a parameter is a plain name, with no default, no `?` and no annotation but `AbortSignal` when `signal` allows it.
37
- function plainName(param: Param | undefined, signal = false): param is NodeOfType<'Identifier'> {
38
- if (param?.type !== 'Identifier' || param.optional)
39
- return false
40
-
41
- const annotation = param.typeAnnotation?.typeAnnotation
42
-
43
- if (annotation === undefined)
44
- return true
45
-
46
- return signal && annotation.type === 'TSTypeReference' && annotation.typeName.type === 'Identifier' && annotation.typeName.name === 'AbortSignal' && annotation.typeArguments == null
47
- }
48
-
49
- // Whether a parameter reads as the signal of the old shape: named like one, or annotated `AbortSignal`, and not a context.
50
- function signalLike(param: NodeOfType<'Identifier'>): boolean {
51
- const annotation = param.typeAnnotation?.typeAnnotation
52
-
53
- if (annotation == null)
54
- return SIGNAL_NAME.test(param.name)
55
-
56
- return annotation.type === 'TSTypeReference' && annotation.typeName.type === 'Identifier' && annotation.typeName.name === 'AbortSignal'
57
- }
58
-
59
- const binding = (name: string, key: string) => name === key ? key : `${key}: ${name}`
60
-
61
- // The handlers a call of one of the four hands over, where the handler is: a queue's or workflow's second argument, a background job's first, a schedule's jobs, the second argument, a list of them or the values of a table.
62
- function handlersOf(call: CallNode, name: (typeof JOB_CALLS)[number]): FunctionNode[] {
63
- const args = call.arguments
64
-
65
- if (name === 'queue' || name === 'workflow')
66
- return isFunction(args[1]) ? [args[1]] : []
67
-
68
- if (name === 'background')
69
- return isFunction(args[0]) ? [args[0]] : []
70
-
71
- const listed = (node: Node | undefined): FunctionNode[] => {
72
- if (isFunction(node))
73
- return [node]
74
-
75
- return node?.type === 'ArrayExpression' ? node.elements.filter((element): element is FunctionNode => isFunction(element ?? undefined)) : []
76
- }
77
-
78
- const [first] = args
79
-
80
- if (first?.type === 'ObjectExpression' && !first.properties.some(property => property.type === 'Property' && ['every', 'cron'].includes(keyName(property) ?? '')))
81
- return first.properties.flatMap(property => property.type === 'Property' ? listed(property.value) : [])
82
-
83
- return listed(args[1])
84
- }
85
-
86
- // The edits giving a queue handler `(payload, { signal, job })` for `(payload, signal, job)`, null where the parameters are not plain names.
87
- function queueEdits(fn: FunctionNode, base: number): Edit[] | null | undefined {
88
- const [, signal, job] = fn.params
89
-
90
- if (signal === undefined || signal.type !== 'Identifier' || (fn.params.length < 3 && !signalLike(signal)))
91
- return undefined
92
-
93
- if (fn.params.length > 3 || !plainName(signal, true) || (job !== undefined && !plainName(job)))
94
- return null
95
-
96
- const text = `{ ${[binding(signal.name, 'signal'), ...job === undefined ? [] : [binding((job as NodeOfType<'Identifier'>).name, 'job')]].join(', ')} }`
97
-
98
- return [{ start: base + signal.start, end: base + (job ?? signal).end, text }]
99
- }
100
-
101
- // The edits giving a workflow `(input, { step, job: { id } })` for `({ id, input, step })`.
102
- function workflowEdits(fn: FunctionNode, base: number): Edit[] | null | undefined {
103
- const [run] = fn.params
104
-
105
- if (run?.type !== 'ObjectPattern' || fn.params.length > 1)
106
- return undefined
107
-
108
- const keys = run.properties.map(property => property.type === 'Property' ? keyName(property) : undefined)
109
-
110
- if (!keys.some(key => key === 'step' || key === 'input'))
111
- return undefined
112
-
113
- if (run.typeAnnotation != null || run.properties.some((property, at) => property.type !== 'Property' || property.computed || !['id', 'input', 'step'].includes(keys[at]!) || property.value.type !== 'Identifier'))
114
- return null
115
-
116
- const names = new Map(run.properties.map(property => [keyName(property as NodeOfType<'Property'>)!, (property as NodeOfType<'Property'> & { value: NodeOfType<'Identifier'> }).value.name]))
117
- const context = [...names.has('step') ? [binding(names.get('step')!, 'step')] : [], ...names.has('id') ? [`job: { ${binding(names.get('id')!, 'id')} }`] : []]
118
-
119
- return [{ start: base + run.start, end: base + run.end, text: `${names.get('input') ?? '_input'}${context.length === 0 ? '' : `, { ${context.join(', ')} }`}` }]
120
- }
121
-
122
- // The edits giving a scheduled or background job `(_, { signal })` for `(signal)`.
123
- function signalEdits(fn: FunctionNode, base: number, source: string): Edit[] | null | undefined {
124
- const [signal] = fn.params
125
-
126
- if (fn.params.length !== 1 || signal?.type !== 'Identifier' || !signalLike(signal))
127
- return undefined
128
-
129
- if (!plainName(signal, true))
130
- return null
131
-
132
- // An arrow function written `signal => ...` needs the parentheses two parameters take.
133
- const text = `_, { ${binding(signal.name, 'signal')} }`
134
- const bare = source.slice(0, base + signal.start).trimEnd().at(-1) !== '('
135
-
136
- return [{ start: base + signal.start, end: base + signal.end, text: bare ? `(${text})` : text }]
137
- }
138
-
139
- function editsOf(fn: FunctionNode, name: (typeof JOB_CALLS)[number], base: number, source: string): Edit[] | null | undefined {
140
- if (name === 'queue')
141
- return queueEdits(fn, base)
142
-
143
- const edits = name === 'workflow' ? workflowEdits(fn, base) : signalEdits(fn, base, source)
144
-
145
- // The fix adds an unused parameter named `_` or `_input`, which would shadow one the body reads.
146
- return edits && UNDERSCORE.test(source.slice(base + fn.body!.start, base + fn.body!.end)) ? null : edits
147
- }
148
-
149
- // The options written after a first argument, as the properties of the new object or, for any other expression, spread into it.
150
- function spreadOf(source: string, base: number, options: Node | undefined): string[] {
151
- if (options === undefined)
152
- return []
153
-
154
- if (options.type === 'ObjectExpression')
155
- return options.properties.map(property => source.slice(base + property.start, base + property.end))
156
-
157
- return [`...${source.slice(base + options.start, base + options.end)}`]
158
- }
159
-
160
- // A handler written before 1.105, which gets its signal and its job as arguments of their own: `queue(name, (payload, signal, job) => ...)`, `workflow(name, ({ id, input, step }) => ...)`, `schedule(when, (signal) => ...)` and `background((signal) => ...)`.
161
- // Every job handler is `(input, ctx)` since 1.105, with `ctx.signal`, `ctx.job`, `ctx.log`, `ctx.locale` and a workflow's `ctx.step`. Found on a handler written inline in the call, where its parameters are plain names; the fix destructures them off the context, so the body reads them under the names it used. A queue handler written in the old shape still runs, as its second argument is the signal; a workflow's, a schedule's and a background job's does not.
162
- export async function jobHandlers(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
163
- if (lintLevel('deprecated-job-handler', options.lints) === 'allow')
164
- return []
165
-
166
- return scan(root, options, 'deprecated-job-handler', JOBS, ({ source, parsed, report }) => {
167
- for (const { ast, base } of parsed) {
168
- const named = jobCall(ast)
169
-
170
- walk(ast, (node) => {
171
- if (node.type !== 'CallExpression')
172
- return
173
-
174
- const name = named(node.callee)
175
-
176
- if (name === undefined)
177
- return
178
-
179
- for (const fn of handlersOf(node, name)) {
180
- const edits = editsOf(fn, name, base, source)
181
-
182
- if (edits === undefined)
183
- continue
184
-
185
- // A comment in a range the fix replaces would be lost with it.
186
- const lost = edits?.some(edit => COMMENT.test(source.slice(edit.start, edit.end)))
187
-
188
- report(base + fn.params[0]!.start, base + fn.params.at(-1)!.end, `the handler of \`${name}()\` is \`(input, ctx)\` since 1.105: its signal and job are read off \`ctx\``, 'take `ctx` and read `signal`, `job`, `log` and `locale` off it', lost ? null : edits)
189
- }
190
- })
191
- }
192
- })
193
- }
194
-
195
- // `schedule(when, job, options)`, `schedule({ cron | every, ...options }, job)` since 1.105: one shape, the schedule and its options in one object, as `queue` and `workflow` keep theirs in one.
196
- // Found on a call of `schedule` from `kay/server` whose first argument is a string or number literal; the fix writes `every` for a length and `cron` for the rest, and spreads the options after it.
197
- export async function scheduleCalls(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
198
- if (lintLevel('deprecated-schedule-call', options.lints) === 'allow')
199
- return []
200
-
201
- return scan(root, options, 'deprecated-schedule-call', SCHEDULE, ({ source, parsed, report }) => {
202
- for (const { ast, base } of parsed) {
203
- const named = jobCall(ast)
204
-
205
- walk(ast, (node) => {
206
- if (node.type !== 'CallExpression' || named(node.callee) !== 'schedule')
207
- return
208
-
209
- const [when, job, rest] = node.arguments
210
-
211
- if (when?.type !== 'Literal' || (typeof when.value !== 'string' && typeof when.value !== 'number') || job === undefined || node.arguments.length > 3 || node.arguments.some(argument => argument.type === 'SpreadElement'))
212
- return
213
-
214
- const key = typeof when.value === 'number' || DURATION_TEXT.test(when.value) ? 'every' : 'cron'
215
- const spread = spreadOf(source, base, rest)
216
-
217
- const edits: Edit[] = [{ start: base + when.start, end: base + when.end, text: `{ ${[`${key}: ${source.slice(base + when.start, base + when.end)}`, ...spread].join(', ')} }` }]
218
-
219
- if (rest !== undefined)
220
- edits.push({ start: base + job.end, end: base + rest.end, text: '' })
221
-
222
- const lost = rest !== undefined && COMMENT.test(source.slice(base + job.end, base + rest.end))
223
-
224
- report(base + when.start, base + when.end, '`schedule(when, job, options)` is deprecated since 1.105: the schedule and its options are one object', `write \`schedule({ ${key}: ... }, job)\``, lost ? null : edits)
225
- })
226
- }
227
- })
228
- }
229
-
230
- // `lostAfter` in the options of `queue()` or `workflow()`, `timeout` since 1.105: the one name of a job's time limit, as a schedule's.
231
- export async function jobOptions(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
232
- return renamedCallOptions(root, options, { lint: 'deprecated-job-options', needle: LOST_AFTER, from: FROM_SERVER, calls: { queue: 2, workflow: 2 }, renames: [['lostAfter', 'timeout']], since: '1.105', of: '`queue()` and `workflow()`' })
233
- }
234
-
235
- // `diskFiles(dir, hooks)`, `diskFiles({ dir, ...hooks })` since 1.105: the options of every file store are one object, as `s3Files({ ...settings, ...hooks })` and `memoryFiles({ ...hooks })` take them.
236
- export async function diskFilesCalls(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
237
- if (lintLevel('deprecated-disk-files', options.lints) === 'allow')
238
- return []
239
-
240
- return scan(root, options, 'deprecated-disk-files', DISK_FILES, ({ source, parsed, report }: Found) => {
241
- for (const { ast, base } of parsed) {
242
- const { locals, namespaces } = importsOf(ast, FROM_SERVER, 'diskFiles')
243
-
244
- if (locals.size === 0 && namespaces.size === 0)
245
- continue
246
-
247
- walk(ast, (node) => {
248
- if (node.type !== 'CallExpression' || node.arguments.length === 0 || node.arguments.length > 2 || node.arguments.some(argument => argument.type === 'SpreadElement'))
249
- return
250
-
251
- const { callee } = node
252
- const isDisk = callee.type === 'Identifier'
253
- ? locals.has(callee.name)
254
- : callee.type === 'MemberExpression' && !callee.computed && callee.object.type === 'Identifier' && namespaces.has(callee.object.name) && callee.property.type === 'Identifier' && callee.property.name === 'diskFiles'
255
- const [dir, hooks] = node.arguments
256
-
257
- // A string is the old form; an object, or any other expression that may hold one, is the new.
258
- const oldForm = node.arguments.length === 2 || dir!.type === 'TemplateLiteral' || (dir!.type === 'Literal' && typeof dir!.value === 'string')
259
-
260
- if (!isDisk || !oldForm)
261
- return
262
-
263
- const spread = spreadOf(source, base, hooks)
264
-
265
- const last = hooks ?? dir!
266
- const text = `{ ${[`dir: ${source.slice(base + dir!.start, base + dir!.end)}`, ...spread].join(', ')} }`
267
- const lost = COMMENT.test(source.slice(base + dir!.start, base + last.end))
268
-
269
- report(base + dir!.start, base + last.end, '`diskFiles(dir, hooks)` is deprecated since 1.105: the options of a file store are one object', 'write `diskFiles({ dir, ...hooks })`', lost ? null : [{ start: base + dir!.start, end: base + last.end, text }])
270
- })
271
- }
272
- })
273
- }
@@ -1,130 +0,0 @@
1
- import type { CheckDiagnostic } from '.'
2
- import type { Fix } from '../compiler/ast'
3
- import type { Node } from '../compiler/estree'
4
- import type { LintLevels } from '../compiler/lints'
5
- import { findProjectFiles } from '../build/files'
6
- import { parseProgram } from '../compiler/estree'
7
- import { OLD_LINK_FLAGS } from '../compiler/link-flags'
8
- import { lintLevel } from '../compiler/lints'
9
- import { childrenOf } from './ast'
10
-
11
- const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$/
12
- const OLD_FLAG = new RegExp(`(?<![\\w-])(${Object.keys(OLD_LINK_FLAGS).join('|')})(?![\\w-])`, 'g')
13
- const DATASET_END = /dataset$/
14
- const ATTRIBUTE_CALL = /\.(?:get|has|set|remove|toggle)Attribute\(\s*$/
15
-
16
- // The `dataset` property of each old flag: `data-keep-scroll` is `keepScroll`.
17
- const DATASET_NAMES = new Map(Object.keys(OLD_LINK_FLAGS).map(name => [name.slice(5).replace(/-(\w)/g, (_, letter: string) => letter.toUpperCase()), name]))
18
-
19
- interface Scanned {
20
- // The content of each string literal and template chunk, as `[start, end]` offsets.
21
- strings: [number, number][]
22
- // The `x.dataset.<flag>` member expressions, and whether each is assigned, updated or deleted.
23
- datasets: { node: Node, written: boolean, direct: boolean }[]
24
- }
25
-
26
- const WRAPPERS = new Set(['ChainExpression', 'TSNonNullExpression', 'ParenthesizedExpression'])
27
-
28
- // The expression under any wrappers.
29
- function unwrapped(node: Node): Node {
30
- let inner = node
31
-
32
- while (inner.type === 'ChainExpression' || inner.type === 'TSNonNullExpression' || inner.type === 'ParenthesizedExpression')
33
- inner = inner.expression
34
-
35
- return inner
36
- }
37
-
38
- function isDataset(node: Node): boolean {
39
- const inner = unwrapped(node)
40
-
41
- return inner.type === 'MemberExpression' && !inner.computed && inner.property.type === 'Identifier' && inner.property.name === 'dataset'
42
- }
43
-
44
- // What the parsed program holds that names a flag, so a regex literal or a comment cannot shift what is a string.
45
- function scan(source: string): Scanned {
46
- const found: Scanned = { strings: [], datasets: [] }
47
- const visit = (node: Node, ancestors: Node[]) => {
48
- if (node.type === 'Literal' && typeof node.value === 'string') {
49
- found.strings.push([node.start + 1, node.end - 1])
50
- }
51
- else if (node.type === 'TemplateElement') {
52
- // The span holds its delimiters: a backtick or `}` before, a backtick or `${` after.
53
- found.strings.push([node.start + 1, node.end - (source[node.end - 1] === '`' ? 1 : 2)])
54
- }
55
- else if (node.type === 'MemberExpression' && !node.computed && node.property.type === 'Identifier' && DATASET_NAMES.has(node.property.name) && isDataset(node.object)) {
56
- // Through `?.`, `!` and parentheses: `delete el?.dataset.keepScroll` and `el.dataset!.keepScroll = 1` write it.
57
- let at = ancestors.length - 1
58
- let target: Node = node
59
-
60
- while (at >= 0 && WRAPPERS.has(ancestors[at]!.type))
61
- target = ancestors[at--]!
62
-
63
- const parent = ancestors[at]
64
- const assigned = parent?.type === 'AssignmentExpression' && parent.left === target
65
-
66
- found.datasets.push({ node, written: assigned || parent?.type === 'UpdateExpression' || (parent?.type === 'UnaryExpression' && parent.operator === 'delete'), direct: unwrapped(node.object) === node.object })
67
- }
68
-
69
- for (const child of childrenOf(node))
70
- visit(child, [...ancestors, node])
71
- }
72
-
73
- visit(parseProgram(source, { lang: 'ts', recover: true }).program, [])
74
-
75
- return found
76
- }
77
-
78
- // The selectors, attribute reads and `dataset` reads of an app's test files that name a link flag by its name before 1.105, which `deprecated-link-flags` rewrites in the templates: `[data-keep-scroll]` is written `[data-scroll=keep]`, as the template's attribute was.
79
- // An attribute read by name (`getAttribute('data-keep-scroll')`) and a read of `dataset.keepScroll` get a fix that is not safe, as the new name holds a word where the old one was there or not; any other string naming the flag (a selector with a value, one built in a template) and a write of `dataset` are reported with no fix.
80
- export async function linkFlagTests(root: string, levels: LintLevels | undefined): Promise<CheckDiagnostic[]> {
81
- const level = lintLevel('deprecated-link-flags', levels)
82
-
83
- if (level === 'allow')
84
- return []
85
-
86
- const found: CheckDiagnostic[] = []
87
-
88
- for (const file of (await findProjectFiles(root, TEST_FILE, { project: true, ownKayOnly: true })).sort()) {
89
- const source = await Bun.file(file).text()
90
- const { strings, datasets } = scan(source)
91
- const report = (start: number, end: number, message: string, help: string, fixes: Fix[] | undefined) => {
92
- const before = source.slice(0, start).split('\n')
93
-
94
- found.push({ file, line: before.length, column: before.at(-1)!.length + 1, end, severity: level === 'warn' ? 'warning' : 'error', code: 'deprecated-link-flags', message, help, ...fixes === undefined ? {} : { fixes } })
95
- }
96
-
97
- for (const match of source.matchAll(OLD_FLAG)) {
98
- const name = match[1]!
99
- const end = match.index + name.length
100
- const string = strings.find(([from, to]) => match.index >= from && end <= to)
101
-
102
- if (string === undefined)
103
- continue
104
-
105
- const next = OLD_LINK_FLAGS[name]!
106
- const written = `${next.name}=${next.value}`
107
- const selector = source[match.index - 1] === '[' && source[end] === ']'
108
- const read = !selector && string[1] - string[0] === name.length && ATTRIBUTE_CALL.test(source.slice(Math.max(0, string[0] - 201), string[0] - 1))
109
- let fixes: Fix[] | undefined
110
-
111
- if (selector)
112
- fixes = [{ title: `write [${written}]`, safe: true, edits: [{ start: match.index - 1, end: end + 1, text: `[${written}]` }] }]
113
- else if (read)
114
- fixes = [{ title: `write ${next.name}`, safe: false, edits: [{ start: match.index, end, text: next.name }] }]
115
-
116
- report(match.index, end, `\`${name}\` is \`${written}\`, deprecated since 1.105: a template written with the new attribute no longer matches this`, `select \`[${written}]\`; an attribute read follows the new name, whose value is \`${next.value}\` where the old one was present`, fixes)
117
- }
118
-
119
- for (const { node, written, direct } of datasets) {
120
- const member = node as Node & { object: Node, property: Node & { name: string } }
121
- const old = OLD_LINK_FLAGS[DATASET_NAMES.get(member.property.name)!]!
122
- const to = `dataset.${old.name.slice(5)} === '${old.value}'`
123
- const fixes: Fix[] | undefined = written || !direct ? undefined : [{ title: `write ${to}`, safe: false, edits: [{ start: node.start, end: node.end, text: `(${source.slice(member.object.start, member.object.end).replace(DATASET_END, '')}${to})` }] }]
124
-
125
- report(node.start, node.end, `\`dataset.${member.property.name}\` is \`${to}\`, deprecated since 1.105: the template's attribute is \`${old.name}\``, `read \`${to}\`; a write is set on \`${old.name}\` by hand`, fixes)
126
- }
127
- }
128
-
129
- return found.sort((a, b) => a.file.localeCompare(b.file) || a.line - b.line || a.column - b.column)
130
- }