@kayjs/kay 1.108.0 → 1.109.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 (543) hide show
  1. package/dist/eslint.js +1790 -3751
  2. package/editors/zed/extension.toml +2 -2
  3. package/llms/action-protection.md +1 -1
  4. package/llms/actions-from-islands.md +4 -4
  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 +4 -4
  13. package/llms/deprecated-lints.md +1 -6
  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 +2 -1
  22. package/llms/island-sources.md +1 -1
  23. package/llms/islands-state-to-ids.md +2 -2
  24. package/llms/islands.md +4 -2
  25. package/llms/lints.md +1 -1
  26. package/llms/live-values.md +3 -3
  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 +6 -6
  32. package/llms/prerendering.md +1 -0
  33. package/llms/production.md +2 -2
  34. package/llms/project-new-and-add.md +1 -1
  35. package/llms/project.md +4 -4
  36. package/llms/proxy-and-security.md +1 -1
  37. package/llms/queues.md +1 -1
  38. package/llms/rate-limits.md +4 -4
  39. package/llms/rendering.md +1 -1
  40. package/llms/server-islands.md +2 -2
  41. package/llms/server.md +1 -1
  42. package/llms/stores.md +1 -1
  43. package/llms/styles-and-assets.md +1 -1
  44. package/llms/testing-mount.md +49 -0
  45. package/llms/testing.md +4 -45
  46. package/llms/upgrading-1-105-config.md +13 -13
  47. package/llms/upgrading-archive.md +42 -82
  48. package/llms/upgrading.md +91 -63
  49. package/llms/whats-new.md +9 -0
  50. package/llms.txt +5 -6
  51. package/package.json +6 -10
  52. package/src/build/route-sizes.ts +2 -3
  53. package/src/check/browser-global-reads.ts +2 -2
  54. package/src/check/config-objects.ts +1 -1
  55. package/src/check/diagnose.ts +0 -22
  56. package/src/check/export-homes.ts +1 -1
  57. package/src/check/guards.ts +3 -3
  58. package/src/check/index.ts +2 -7
  59. package/src/check/moved-keys.ts +1 -1
  60. package/src/check/project.ts +3 -8
  61. package/src/check/shadow-types.ts +0 -86
  62. package/src/commands/check.ts +2 -2
  63. package/src/commands/env.ts +25 -3
  64. package/src/compiler/ast.ts +18 -16
  65. package/src/compiler/browser.ts +2 -14
  66. package/src/compiler/class-items.ts +16 -0
  67. package/src/compiler/codegen.ts +8 -8
  68. package/src/compiler/deprecated-library.ts +0 -12
  69. package/src/compiler/deprecated-lints.ts +3 -495
  70. package/src/compiler/deprecated-ui-props.ts +5 -5
  71. package/src/compiler/errors.ts +2 -2
  72. package/src/compiler/fence-checks.ts +2 -121
  73. package/src/compiler/hand-parts.ts +55 -0
  74. package/src/compiler/helper-imports.ts +2 -2
  75. package/src/compiler/image-attributes.ts +1 -3
  76. package/src/compiler/index.ts +20 -21
  77. package/src/compiler/island-arguments.ts +8 -95
  78. package/src/compiler/island-cause.ts +7 -7
  79. package/src/compiler/island-declaration.ts +2 -8
  80. package/src/compiler/island-lints.ts +12 -0
  81. package/src/compiler/island-marker.ts +3 -3
  82. package/src/compiler/island-problems.ts +25 -0
  83. package/src/compiler/jsx-class.ts +1 -25
  84. package/src/compiler/jsx.ts +2 -2
  85. package/src/compiler/kay-exports.ts +0 -2
  86. package/src/compiler/link-flags.ts +9 -38
  87. package/src/compiler/lints.ts +7 -14
  88. package/src/compiler/markup.ts +23 -26
  89. package/src/compiler/module-signals.ts +2 -2
  90. package/src/compiler/names.ts +1 -1
  91. package/src/compiler/page-settings.ts +11 -0
  92. package/src/compiler/parser.ts +6 -8
  93. package/src/compiler/plan.ts +1 -3
  94. package/src/compiler/rewrite.ts +3 -18
  95. package/src/compiler/script-server.ts +8 -3
  96. package/src/compiler/validate.ts +3 -8
  97. package/src/config-loader.ts +14 -4
  98. package/src/config-resolve.ts +18 -142
  99. package/src/config-shape.ts +44 -34
  100. package/src/config.ts +10 -114
  101. package/src/dev/preload.ts +4 -1
  102. package/src/lsp/server.ts +4 -0
  103. package/src/migrate/markup.ts +4 -1
  104. package/src/runtime/action-call.ts +0 -8
  105. package/src/runtime/action-encode.ts +26 -0
  106. package/src/runtime/action-error.ts +3 -11
  107. package/src/runtime/action-protection.ts +2 -2
  108. package/src/runtime/action-run.ts +2 -27
  109. package/src/runtime/action-shared.ts +14 -37
  110. package/src/runtime/action-stream.ts +0 -1
  111. package/src/runtime/action.ts +1 -1
  112. package/src/runtime/call-result.ts +2 -10
  113. package/src/runtime/checks.ts +11 -11
  114. package/src/runtime/client.ts +2 -2
  115. package/src/runtime/core.ts +5 -23
  116. package/src/runtime/dom.ts +1 -1
  117. package/src/runtime/html.ts +1 -1
  118. package/src/runtime/i18n.client.ts +1 -4
  119. package/src/runtime/i18n.server.ts +1 -4
  120. package/src/runtime/i18n.ts +3 -3
  121. package/src/runtime/index.ts +2 -2
  122. package/src/runtime/island.server.ts +18 -5
  123. package/src/runtime/live-resource.server.ts +0 -1
  124. package/src/runtime/live-value.server.ts +2 -2
  125. package/src/runtime/live-value.shared.ts +7 -20
  126. package/src/runtime/live.ts +1 -12
  127. package/src/runtime/local-types.ts +1 -11
  128. package/src/runtime/local.ts +4 -14
  129. package/src/runtime/navigate-api.ts +2 -5
  130. package/src/runtime/navigation-state.ts +0 -12
  131. package/src/runtime/page-swap.ts +6 -6
  132. package/src/runtime/persist.ts +11 -3
  133. package/src/runtime/persisted.ts +4 -30
  134. package/src/runtime/presence.ts +6 -7
  135. package/src/runtime/query-param.ts +20 -12
  136. package/src/runtime/reactive.ts +3 -1
  137. package/src/runtime/refuse.ts +3 -17
  138. package/src/runtime/store-base.ts +4 -6
  139. package/src/runtime/swap-fetch.ts +1 -1
  140. package/src/runtime/values.ts +40 -23
  141. package/src/runtime/with-query.ts +9 -0
  142. package/src/server/action-hooks.ts +8 -8
  143. package/src/server/actions.ts +13 -14
  144. package/src/server/api-modules.ts +2 -3
  145. package/src/server/app-stages.ts +15 -33
  146. package/src/server/app.ts +10 -5
  147. package/src/server/auth-mails.ts +0 -2
  148. package/src/server/env-state.ts +40 -10
  149. package/src/server/flash.ts +1 -1
  150. package/src/server/guard-requirement.ts +4 -4
  151. package/src/server/image.ts +2 -2
  152. package/src/server/index.ts +0 -2
  153. package/src/server/job-context.ts +3 -3
  154. package/src/server/jobs-page.ts +1 -1
  155. package/src/server/jobs.ts +5 -9
  156. package/src/server/kept-exports.ts +0 -2
  157. package/src/server/kv.ts +11 -14
  158. package/src/server/library.ts +1 -3
  159. package/src/server/live.ts +2 -2
  160. package/src/server/mcp.ts +3 -9
  161. package/src/server/metrics.ts +2 -4
  162. package/src/server/page-settings.ts +10 -19
  163. package/src/server/prerender.ts +19 -2
  164. package/src/server/protection.ts +15 -18
  165. package/src/server/queue.ts +3 -6
  166. package/src/server/rate-limit.ts +0 -3
  167. package/src/server/render-document.ts +1 -1
  168. package/src/server/routes.ts +7 -3
  169. package/src/server/scope.ts +3 -2
  170. package/src/server/session.ts +5 -6
  171. package/src/server/setup.ts +1 -1
  172. package/src/server/signals.ts +17 -7
  173. package/src/server/signed.ts +1 -3
  174. package/src/server/source.ts +20 -4
  175. package/src/server/speculation.ts +1 -1
  176. package/src/server/storage.ts +3 -8
  177. package/src/server/validate.ts +1 -1
  178. package/src/server/vitals.ts +1 -3
  179. package/src/server/work-scope.ts +2 -4
  180. package/src/server/work.ts +1 -1
  181. package/src/server/workflow.ts +1 -1
  182. package/src/test/index.ts +2 -1
  183. package/src/test/site-actions.ts +16 -6
  184. package/src/test/site-keys.ts +10 -15
  185. package/src/test/site-socket.ts +1 -2
  186. package/src/test/site-types.ts +0 -8
  187. package/types/build/route-sizes.d.ts.map +1 -1
  188. package/types/check/diagnose.d.ts.map +1 -1
  189. package/types/check/index.d.ts +1 -2
  190. package/types/check/index.d.ts.map +1 -1
  191. package/types/check/project.d.ts.map +1 -1
  192. package/types/check/shadow-types.d.ts.map +1 -1
  193. package/types/commands/env.d.ts.map +1 -1
  194. package/types/compiler/ast.d.ts +1 -2
  195. package/types/compiler/ast.d.ts.map +1 -1
  196. package/types/compiler/browser.d.ts.map +1 -1
  197. package/types/compiler/class-items.d.ts +7 -0
  198. package/types/compiler/class-items.d.ts.map +1 -0
  199. package/types/compiler/deprecated-library.d.ts.map +1 -1
  200. package/types/compiler/deprecated-lints.d.ts +0 -551
  201. package/types/compiler/deprecated-lints.d.ts.map +1 -1
  202. package/types/compiler/deprecated-ui-props.d.ts +1 -8
  203. package/types/compiler/deprecated-ui-props.d.ts.map +1 -1
  204. package/types/compiler/errors.d.ts +2 -2
  205. package/types/compiler/errors.d.ts.map +1 -1
  206. package/types/compiler/fence-checks.d.ts +0 -1
  207. package/types/compiler/fence-checks.d.ts.map +1 -1
  208. package/types/compiler/hand-parts.d.ts +7 -0
  209. package/types/compiler/hand-parts.d.ts.map +1 -0
  210. package/types/compiler/image-attributes.d.ts +0 -1
  211. package/types/compiler/image-attributes.d.ts.map +1 -1
  212. package/types/compiler/index.d.ts.map +1 -1
  213. package/types/compiler/island-arguments.d.ts +2 -11
  214. package/types/compiler/island-arguments.d.ts.map +1 -1
  215. package/types/compiler/island-cause.d.ts +1 -1
  216. package/types/compiler/island-cause.d.ts.map +1 -1
  217. package/types/compiler/island-declaration.d.ts +1 -3
  218. package/types/compiler/island-declaration.d.ts.map +1 -1
  219. package/types/compiler/island-lints.d.ts +10 -0
  220. package/types/compiler/island-lints.d.ts.map +1 -0
  221. package/types/compiler/island-problems.d.ts +7 -0
  222. package/types/compiler/island-problems.d.ts.map +1 -0
  223. package/types/compiler/jsx-class.d.ts +1 -2
  224. package/types/compiler/jsx-class.d.ts.map +1 -1
  225. package/types/compiler/kay-exports.d.ts.map +1 -1
  226. package/types/compiler/link-flags.d.ts +0 -6
  227. package/types/compiler/link-flags.d.ts.map +1 -1
  228. package/types/compiler/lints.d.ts +11 -563
  229. package/types/compiler/lints.d.ts.map +1 -1
  230. package/types/compiler/markup.d.ts +1 -1
  231. package/types/compiler/markup.d.ts.map +1 -1
  232. package/types/compiler/module-signals.d.ts.map +1 -1
  233. package/types/compiler/names.d.ts.map +1 -1
  234. package/types/compiler/page-settings.d.ts +4 -0
  235. package/types/compiler/page-settings.d.ts.map +1 -1
  236. package/types/compiler/parser.d.ts.map +1 -1
  237. package/types/compiler/plan.d.ts.map +1 -1
  238. package/types/compiler/script-server.d.ts.map +1 -1
  239. package/types/compiler/validate.d.ts.map +1 -1
  240. package/types/config-loader.d.ts.map +1 -1
  241. package/types/config-resolve.d.ts.map +1 -1
  242. package/types/config-shape.d.ts +1 -1
  243. package/types/config-shape.d.ts.map +1 -1
  244. package/types/config.d.ts +5 -105
  245. package/types/config.d.ts.map +1 -1
  246. package/types/dev/preload.d.ts.map +1 -1
  247. package/types/lsp/server.d.ts.map +1 -1
  248. package/types/migrate/markup.d.ts.map +1 -1
  249. package/types/runtime/action-call.d.ts.map +1 -1
  250. package/types/runtime/action-encode.d.ts +1 -0
  251. package/types/runtime/action-encode.d.ts.map +1 -1
  252. package/types/runtime/action-error.d.ts +1 -2
  253. package/types/runtime/action-error.d.ts.map +1 -1
  254. package/types/runtime/action-run.d.ts.map +1 -1
  255. package/types/runtime/action-shared.d.ts +1 -27
  256. package/types/runtime/action-shared.d.ts.map +1 -1
  257. package/types/runtime/action-stream.d.ts.map +1 -1
  258. package/types/runtime/action.d.ts +1 -1
  259. package/types/runtime/action.d.ts.map +1 -1
  260. package/types/runtime/call-result.d.ts +0 -10
  261. package/types/runtime/call-result.d.ts.map +1 -1
  262. package/types/runtime/checks.d.ts +6 -9
  263. package/types/runtime/checks.d.ts.map +1 -1
  264. package/types/runtime/core.d.ts +2 -20
  265. package/types/runtime/core.d.ts.map +1 -1
  266. package/types/runtime/dom.d.ts +1 -1
  267. package/types/runtime/dom.d.ts.map +1 -1
  268. package/types/runtime/html.d.ts +1 -1
  269. package/types/runtime/html.d.ts.map +1 -1
  270. package/types/runtime/i18n.client.d.ts +0 -1
  271. package/types/runtime/i18n.client.d.ts.map +1 -1
  272. package/types/runtime/i18n.d.ts +1 -1
  273. package/types/runtime/i18n.d.ts.map +1 -1
  274. package/types/runtime/i18n.server.d.ts +0 -1
  275. package/types/runtime/i18n.server.d.ts.map +1 -1
  276. package/types/runtime/index.d.ts +2 -2
  277. package/types/runtime/index.d.ts.map +1 -1
  278. package/types/runtime/island.server.d.ts +1 -0
  279. package/types/runtime/island.server.d.ts.map +1 -1
  280. package/types/runtime/live-resource.server.d.ts.map +1 -1
  281. package/types/runtime/live-value.shared.d.ts +7 -15
  282. package/types/runtime/live-value.shared.d.ts.map +1 -1
  283. package/types/runtime/live.d.ts +0 -11
  284. package/types/runtime/live.d.ts.map +1 -1
  285. package/types/runtime/local-types.d.ts +0 -14
  286. package/types/runtime/local-types.d.ts.map +1 -1
  287. package/types/runtime/navigate-api.d.ts +0 -4
  288. package/types/runtime/navigate-api.d.ts.map +1 -1
  289. package/types/runtime/navigation-state.d.ts +0 -4
  290. package/types/runtime/navigation-state.d.ts.map +1 -1
  291. package/types/runtime/page-swap.d.ts.map +1 -1
  292. package/types/runtime/persist.d.ts +1 -0
  293. package/types/runtime/persist.d.ts.map +1 -1
  294. package/types/runtime/persisted.d.ts +0 -15
  295. package/types/runtime/persisted.d.ts.map +1 -1
  296. package/types/runtime/presence.d.ts +0 -2
  297. package/types/runtime/presence.d.ts.map +1 -1
  298. package/types/runtime/query-param.d.ts.map +1 -1
  299. package/types/runtime/reactive.d.ts +2 -1
  300. package/types/runtime/reactive.d.ts.map +1 -1
  301. package/types/runtime/refuse.d.ts +0 -7
  302. package/types/runtime/refuse.d.ts.map +1 -1
  303. package/types/runtime/store-base.d.ts +1 -2
  304. package/types/runtime/store-base.d.ts.map +1 -1
  305. package/types/runtime/values.d.ts +2 -1
  306. package/types/runtime/values.d.ts.map +1 -1
  307. package/types/runtime/with-query.d.ts +2 -0
  308. package/types/runtime/with-query.d.ts.map +1 -1
  309. package/types/server/action-hooks.d.ts +4 -4
  310. package/types/server/action-hooks.d.ts.map +1 -1
  311. package/types/server/actions.d.ts.map +1 -1
  312. package/types/server/api-modules.d.ts +0 -1
  313. package/types/server/api-modules.d.ts.map +1 -1
  314. package/types/server/app-stages.d.ts +5 -13
  315. package/types/server/app-stages.d.ts.map +1 -1
  316. package/types/server/app.d.ts +3 -8
  317. package/types/server/app.d.ts.map +1 -1
  318. package/types/server/auth-mails.d.ts +0 -5
  319. package/types/server/auth-mails.d.ts.map +1 -1
  320. package/types/server/env-state.d.ts +1 -0
  321. package/types/server/env-state.d.ts.map +1 -1
  322. package/types/server/guard-requirement.d.ts +0 -1
  323. package/types/server/guard-requirement.d.ts.map +1 -1
  324. package/types/server/image.d.ts +0 -1
  325. package/types/server/image.d.ts.map +1 -1
  326. package/types/server/index.d.ts +0 -2
  327. package/types/server/index.d.ts.map +1 -1
  328. package/types/server/job-context.d.ts +1 -1
  329. package/types/server/job-context.d.ts.map +1 -1
  330. package/types/server/jobs.d.ts +0 -4
  331. package/types/server/jobs.d.ts.map +1 -1
  332. package/types/server/kept-exports.d.ts.map +1 -1
  333. package/types/server/kv.d.ts +4 -4
  334. package/types/server/kv.d.ts.map +1 -1
  335. package/types/server/library.d.ts +1 -3
  336. package/types/server/library.d.ts.map +1 -1
  337. package/types/server/mcp.d.ts +0 -1
  338. package/types/server/mcp.d.ts.map +1 -1
  339. package/types/server/metrics.d.ts +0 -5
  340. package/types/server/metrics.d.ts.map +1 -1
  341. package/types/server/page-settings.d.ts +3 -3
  342. package/types/server/page-settings.d.ts.map +1 -1
  343. package/types/server/prerender.d.ts.map +1 -1
  344. package/types/server/protection.d.ts +6 -6
  345. package/types/server/protection.d.ts.map +1 -1
  346. package/types/server/queue.d.ts +1 -3
  347. package/types/server/queue.d.ts.map +1 -1
  348. package/types/server/rate-limit.d.ts +0 -2
  349. package/types/server/rate-limit.d.ts.map +1 -1
  350. package/types/server/routes.d.ts +1 -1
  351. package/types/server/routes.d.ts.map +1 -1
  352. package/types/server/scope.d.ts.map +1 -1
  353. package/types/server/session.d.ts +1 -1
  354. package/types/server/session.d.ts.map +1 -1
  355. package/types/server/signals.d.ts.map +1 -1
  356. package/types/server/signed.d.ts +0 -2
  357. package/types/server/signed.d.ts.map +1 -1
  358. package/types/server/source.d.ts +1 -1
  359. package/types/server/source.d.ts.map +1 -1
  360. package/types/server/storage.d.ts +0 -4
  361. package/types/server/storage.d.ts.map +1 -1
  362. package/types/server/vitals.d.ts +0 -1
  363. package/types/server/vitals.d.ts.map +1 -1
  364. package/types/server/work-scope.d.ts +0 -2
  365. package/types/server/work-scope.d.ts.map +1 -1
  366. package/types/server/workflow.d.ts +1 -1
  367. package/types/server/workflow.d.ts.map +1 -1
  368. package/types/test/index.d.ts.map +1 -1
  369. package/types/test/site-actions.d.ts +1 -1
  370. package/types/test/site-actions.d.ts.map +1 -1
  371. package/types/test/site-keys.d.ts +1 -1
  372. package/types/test/site-keys.d.ts.map +1 -1
  373. package/types/test/site-socket.d.ts +1 -1
  374. package/types/test/site-socket.d.ts.map +1 -1
  375. package/types/test/site-types.d.ts +0 -8
  376. package/types/test/site-types.d.ts.map +1 -1
  377. package/llms/deprecated-lints-1-105-libraries.md +0 -32
  378. package/llms/deprecated-lints-1-105.md +0 -58
  379. package/src/check/action-readers.ts +0 -115
  380. package/src/check/action-type.ts +0 -44
  381. package/src/check/ai-language.ts +0 -56
  382. package/src/check/app-hooks.ts +0 -90
  383. package/src/check/auth-methods.ts +0 -85
  384. package/src/check/auth-rate-limits.ts +0 -99
  385. package/src/check/call-result.ts +0 -242
  386. package/src/check/client-keys.ts +0 -10
  387. package/src/check/cms-options.ts +0 -81
  388. package/src/check/config-groups.ts +0 -22
  389. package/src/check/config-switches.ts +0 -38
  390. package/src/check/context-import.ts +0 -51
  391. package/src/check/env-files.ts +0 -31
  392. package/src/check/format-duration.ts +0 -75
  393. package/src/check/guard-options.ts +0 -58
  394. package/src/check/handler-events.ts +0 -149
  395. package/src/check/hook-context.ts +0 -94
  396. package/src/check/hook-names.ts +0 -104
  397. package/src/check/i18n-keys.ts +0 -50
  398. package/src/check/images-keys.ts +0 -54
  399. package/src/check/job-shapes.ts +0 -273
  400. package/src/check/link-flag-tests.ts +0 -130
  401. package/src/check/live-api.ts +0 -137
  402. package/src/check/mail-api.ts +0 -67
  403. package/src/check/one-state-api.ts +0 -357
  404. package/src/check/pages-options.ts +0 -35
  405. package/src/check/rate-enforce.ts +0 -53
  406. package/src/check/refusal-calls.ts +0 -185
  407. package/src/check/retired-lints.ts +0 -49
  408. package/src/check/route-keys.ts +0 -166
  409. package/src/check/secret-keys.ts +0 -83
  410. package/src/check/socket-frames.ts +0 -102
  411. package/src/check/source-readers.ts +0 -257
  412. package/src/check/store-ms.ts +0 -72
  413. package/src/check/store-names.ts +0 -88
  414. package/src/check/test-helpers.ts +0 -98
  415. package/src/check/ttl-names.ts +0 -142
  416. package/src/compiler/deprecated-ai-labels.ts +0 -97
  417. package/src/compiler/deprecated-ai-links.ts +0 -63
  418. package/src/compiler/deprecated-allow.ts +0 -50
  419. package/src/compiler/deprecated-auth-lints.ts +0 -14
  420. package/src/compiler/deprecated-auth-signed.ts +0 -29
  421. package/src/compiler/deprecated-children.ts +0 -66
  422. package/src/compiler/deprecated-image.ts +0 -116
  423. package/src/compiler/deprecated-island.ts +0 -155
  424. package/src/compiler/deprecated-lints-1-105.ts +0 -41
  425. package/src/compiler/deprecated-page.ts +0 -125
  426. package/src/compiler/deprecated-parts.ts +0 -22
  427. package/src/compiler/deprecated-typed-lints.ts +0 -23
  428. package/src/compiler/deprecated-ui-callbacks.ts +0 -66
  429. package/src/compiler/deprecated-ui-input.ts +0 -97
  430. package/src/compiler/deprecated-ui-items.ts +0 -47
  431. package/src/compiler/old-parts.ts +0 -84
  432. package/src/runtime/mount.compat.ts +0 -8
  433. package/src/server/moved-exports.ts +0 -17
  434. package/types/check/action-readers.d.ts +0 -3
  435. package/types/check/action-readers.d.ts.map +0 -1
  436. package/types/check/action-type.d.ts +0 -3
  437. package/types/check/action-type.d.ts.map +0 -1
  438. package/types/check/ai-language.d.ts +0 -3
  439. package/types/check/ai-language.d.ts.map +0 -1
  440. package/types/check/app-hooks.d.ts +0 -3
  441. package/types/check/app-hooks.d.ts.map +0 -1
  442. package/types/check/auth-methods.d.ts +0 -3
  443. package/types/check/auth-methods.d.ts.map +0 -1
  444. package/types/check/auth-rate-limits.d.ts +0 -3
  445. package/types/check/auth-rate-limits.d.ts.map +0 -1
  446. package/types/check/call-result.d.ts +0 -7
  447. package/types/check/call-result.d.ts.map +0 -1
  448. package/types/check/client-keys.d.ts +0 -3
  449. package/types/check/client-keys.d.ts.map +0 -1
  450. package/types/check/cms-options.d.ts +0 -3
  451. package/types/check/cms-options.d.ts.map +0 -1
  452. package/types/check/config-groups.d.ts +0 -3
  453. package/types/check/config-groups.d.ts.map +0 -1
  454. package/types/check/config-switches.d.ts +0 -3
  455. package/types/check/config-switches.d.ts.map +0 -1
  456. package/types/check/context-import.d.ts +0 -3
  457. package/types/check/context-import.d.ts.map +0 -1
  458. package/types/check/env-files.d.ts +0 -3
  459. package/types/check/env-files.d.ts.map +0 -1
  460. package/types/check/format-duration.d.ts +0 -5
  461. package/types/check/format-duration.d.ts.map +0 -1
  462. package/types/check/guard-options.d.ts +0 -3
  463. package/types/check/guard-options.d.ts.map +0 -1
  464. package/types/check/handler-events.d.ts +0 -9
  465. package/types/check/handler-events.d.ts.map +0 -1
  466. package/types/check/hook-context.d.ts +0 -3
  467. package/types/check/hook-context.d.ts.map +0 -1
  468. package/types/check/hook-names.d.ts +0 -3
  469. package/types/check/hook-names.d.ts.map +0 -1
  470. package/types/check/i18n-keys.d.ts +0 -3
  471. package/types/check/i18n-keys.d.ts.map +0 -1
  472. package/types/check/images-keys.d.ts +0 -3
  473. package/types/check/images-keys.d.ts.map +0 -1
  474. package/types/check/job-shapes.d.ts +0 -6
  475. package/types/check/job-shapes.d.ts.map +0 -1
  476. package/types/check/link-flag-tests.d.ts +0 -4
  477. package/types/check/link-flag-tests.d.ts.map +0 -1
  478. package/types/check/live-api.d.ts +0 -3
  479. package/types/check/live-api.d.ts.map +0 -1
  480. package/types/check/mail-api.d.ts +0 -3
  481. package/types/check/mail-api.d.ts.map +0 -1
  482. package/types/check/one-state-api.d.ts +0 -9
  483. package/types/check/one-state-api.d.ts.map +0 -1
  484. package/types/check/pages-options.d.ts +0 -3
  485. package/types/check/pages-options.d.ts.map +0 -1
  486. package/types/check/rate-enforce.d.ts +0 -3
  487. package/types/check/rate-enforce.d.ts.map +0 -1
  488. package/types/check/refusal-calls.d.ts +0 -3
  489. package/types/check/refusal-calls.d.ts.map +0 -1
  490. package/types/check/retired-lints.d.ts +0 -3
  491. package/types/check/retired-lints.d.ts.map +0 -1
  492. package/types/check/route-keys.d.ts +0 -3
  493. package/types/check/route-keys.d.ts.map +0 -1
  494. package/types/check/secret-keys.d.ts +0 -3
  495. package/types/check/secret-keys.d.ts.map +0 -1
  496. package/types/check/socket-frames.d.ts +0 -3
  497. package/types/check/socket-frames.d.ts.map +0 -1
  498. package/types/check/source-readers.d.ts +0 -3
  499. package/types/check/source-readers.d.ts.map +0 -1
  500. package/types/check/store-ms.d.ts +0 -3
  501. package/types/check/store-ms.d.ts.map +0 -1
  502. package/types/check/store-names.d.ts +0 -3
  503. package/types/check/store-names.d.ts.map +0 -1
  504. package/types/check/test-helpers.d.ts +0 -3
  505. package/types/check/test-helpers.d.ts.map +0 -1
  506. package/types/check/ttl-names.d.ts +0 -3
  507. package/types/check/ttl-names.d.ts.map +0 -1
  508. package/types/compiler/deprecated-ai-labels.d.ts +0 -5
  509. package/types/compiler/deprecated-ai-labels.d.ts.map +0 -1
  510. package/types/compiler/deprecated-ai-links.d.ts +0 -5
  511. package/types/compiler/deprecated-ai-links.d.ts.map +0 -1
  512. package/types/compiler/deprecated-allow.d.ts +0 -5
  513. package/types/compiler/deprecated-allow.d.ts.map +0 -1
  514. package/types/compiler/deprecated-auth-lints.d.ts +0 -12
  515. package/types/compiler/deprecated-auth-lints.d.ts.map +0 -1
  516. package/types/compiler/deprecated-auth-signed.d.ts +0 -5
  517. package/types/compiler/deprecated-auth-signed.d.ts.map +0 -1
  518. package/types/compiler/deprecated-children.d.ts +0 -4
  519. package/types/compiler/deprecated-children.d.ts.map +0 -1
  520. package/types/compiler/deprecated-image.d.ts +0 -5
  521. package/types/compiler/deprecated-image.d.ts.map +0 -1
  522. package/types/compiler/deprecated-island.d.ts +0 -9
  523. package/types/compiler/deprecated-island.d.ts.map +0 -1
  524. package/types/compiler/deprecated-lints-1-105.d.ts +0 -39
  525. package/types/compiler/deprecated-lints-1-105.d.ts.map +0 -1
  526. package/types/compiler/deprecated-page.d.ts +0 -4
  527. package/types/compiler/deprecated-page.d.ts.map +0 -1
  528. package/types/compiler/deprecated-parts.d.ts +0 -3
  529. package/types/compiler/deprecated-parts.d.ts.map +0 -1
  530. package/types/compiler/deprecated-typed-lints.d.ts +0 -21
  531. package/types/compiler/deprecated-typed-lints.d.ts.map +0 -1
  532. package/types/compiler/deprecated-ui-callbacks.d.ts +0 -5
  533. package/types/compiler/deprecated-ui-callbacks.d.ts.map +0 -1
  534. package/types/compiler/deprecated-ui-input.d.ts +0 -5
  535. package/types/compiler/deprecated-ui-input.d.ts.map +0 -1
  536. package/types/compiler/deprecated-ui-items.d.ts +0 -5
  537. package/types/compiler/deprecated-ui-items.d.ts.map +0 -1
  538. package/types/compiler/old-parts.d.ts +0 -9
  539. package/types/compiler/old-parts.d.ts.map +0 -1
  540. package/types/runtime/mount.compat.d.ts +0 -7
  541. package/types/runtime/mount.compat.d.ts.map +0 -1
  542. package/types/server/moved-exports.d.ts +0 -12
  543. package/types/server/moved-exports.d.ts.map +0 -1
@@ -1,58 +0,0 @@
1
- import type { CheckDiagnostic, CheckOptions } from '.'
2
- import type { Edit } from './renamed-exports'
3
- import { basename } from 'node:path'
4
- import { lintLevel } from '../compiler/lints'
5
- import { constBindings, exportedObject, keyName, objectOf } from '../compiler/object-literal'
6
- import { featureProperties } from './config-objects'
7
- import { renamedCallOptions } from './renamed-call-options'
8
- import { scan } from './renamed-exports'
9
-
10
- const GUARD = /\bguard\b|\brequireGuards\b/
11
- const FROM_SERVER = (source: string) => source === 'kay/server' || source === '@kayjs/kay/server'
12
-
13
- // `guard` in `vitals({ guard })`, in the `jobs` and `images` of kay.config.ts: `guards` since 1.105, the one name of a guard option; and `requireGuards`, `guards: { default }` since 1.105.
14
- export async function guardOptions(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
15
- if (lintLevel('deprecated-guard-option', options.lints) === 'allow')
16
- return []
17
-
18
- const calls = await renamedCallOptions(root, options, { lint: 'deprecated-guard-option', needle: GUARD, from: FROM_SERVER, calls: { vitals: 0 }, renames: [['guard', 'guards']], since: '1.105', of: '`vitals()`' })
19
-
20
- const config = await scan(root, options, 'deprecated-guard-option', GUARD, ({ file, parsed, report }) => {
21
- if (basename(file) !== 'kay.config.ts')
22
- return
23
-
24
- for (const { ast, base } of parsed) {
25
- const bindings = constBindings(ast)
26
- const exported = exportedObject(ast, bindings)
27
-
28
- const own = (exported?.properties ?? []).filter((one): one is Extract<typeof one, { type: 'Property' }> => one.type === 'Property')
29
- const required = own.find(one => keyName(one) === 'requireGuards')
30
-
31
- if (required) {
32
- const { value } = required
33
- const taken = own.some(one => keyName(one) === 'guards')
34
- const known = value.type === 'Literal' && typeof value.value === 'boolean'
35
- const edits: Edit[] | null = taken || !known || required.shorthand || required.computed ? null : [{ start: base + required.start, end: base + required.end, text: `guards: { default: '${value.value ? 'closed' : 'open'}' }` }]
36
-
37
- report(base + required.start, base + required.end, '`requireGuards` is deprecated since 1.105: `guards: { default }` says what a route no guard covers comes to', 'write `guards: { default: \'closed\' }` for `true` and `\'open\'` for `false`', edits)
38
- }
39
-
40
- const features = exported === undefined ? [] : [...featureProperties(exported, bindings, 'ops', 'jobs').map(feature => ({ name: 'jobs', feature })), ...featureProperties(exported, bindings, 'assets', 'images').map(feature => ({ name: 'images', feature }))]
41
-
42
- for (const { name, feature } of features) {
43
- const section = objectOf(feature.value, bindings)
44
- const properties = (section?.properties ?? []).filter((one): one is Extract<typeof one, { type: 'Property' }> => one.type === 'Property')
45
- const old = properties.find(one => keyName(one) === 'guard')
46
-
47
- if (!old)
48
- continue
49
-
50
- const edits: Edit[] | null = properties.some(one => keyName(one) === 'guards') || old.computed ? null : [old.shorthand ? { start: base + old.start, end: base + old.end, text: 'guards: guard' } : { start: base + old.key.start, end: base + old.key.end, text: 'guards' }]
51
-
52
- report(base + old.start, base + old.end, `\`guard\` of \`${name}\` is deprecated since 1.105: the option is \`guards\``, 'write `guards`', edits)
53
- }
54
- }
55
- })
56
-
57
- return [...calls, ...config]
58
- }
@@ -1,149 +0,0 @@
1
- import type { Fix, Span } from '../compiler/ast'
2
- import { attributeNamed } from './template-hints'
3
-
4
- // `Type '(next: boolean) => void' is not assignable to type '(event: { checked: boolean; }) => unknown'.` and the incompatible parameter that follows.
5
- const EVENT_CALLBACK = /^Type '([\s\S]+?)' is not assignable to type '\(event: \{ ([\s\S]*?) \}\) => unknown'\.\n\s+Types of parameters '[^']*' and 'event' are incompatible\.\n([\s\S]*)$/
6
- const PARAMETER_TYPE = /(?:to type|from type) '([\s\S]*?)'(?:\.|:)/
7
- const FIELD = /^(\w+)\??:/
8
- const CALLBACK_NAME = /^on[A-Z]\w*$/
9
- const HANDLER_NAME = /^[A-Z_$][\w$]*(?:\??\.[A-Z_$][\w$]*)*$/i
10
- // An object literal type or a named type, which no old argument was apart from a `File`: the handler may be written for the event already.
11
- const OBJECT_TYPE = /^(?:\{|object\b|(?!File\b)[A-Z])/
12
- const COMPONENT = /^([A-Z][\w$]*)(?:[.#][^\s(]*)?\(/
13
- const NAME_AT = /^[\w$]+/
14
- const EVENT_WORD = /\bevent\b/
15
- const ELEMENT = /^[a-z.#][^\s(]*\(/
16
-
17
- // What an old-form lint of the type check reports.
18
- export interface OldFormLint {
19
- message: string
20
- help: string
21
- span: Span
22
- fixes?: Fix[]
23
- }
24
-
25
- // The segments of a type's text between its top-level `separator`s.
26
- function splitTop(text: string, separator: string): string[] {
27
- const parts: string[] = []
28
- let depth = 0
29
- let from = 0
30
-
31
- for (const [index, char] of [...text].entries()) {
32
- if ('{([<'.includes(char)) {
33
- depth++
34
- }
35
- else if ('})]'.includes(char) || (char === '>' && text[index - 1] !== '=')) {
36
- depth--
37
- }
38
- else if (char === separator && depth === 0) {
39
- parts.push(text.slice(from, index))
40
- from = index + 1
41
- }
42
- }
43
-
44
- parts.push(text.slice(from))
45
-
46
- return parts.map(part => part.trim()).filter(part => part !== '')
47
- }
48
-
49
- // How many parameters a function type written as `(a: A, b: B) => R` takes, 1 for any other type, as a signal's `Setter<T>` takes one.
50
- function parameterCount(type: string): number {
51
- if (!type.startsWith('('))
52
- return 1
53
-
54
- let depth = 0
55
-
56
- for (const [index, char] of [...type].entries()) {
57
- if (char === '(')
58
- depth++
59
- else if (char === ')' && --depth === 0)
60
- return splitTop(type.slice(1, index), ',').length
61
- }
62
-
63
- return 1
64
- }
65
-
66
- // Whether the first parameter of a function type written as `(a: A, b: B) => R` is typed as an object, a literal or a named type.
67
- function takesObject(type: string): boolean {
68
- if (!type.startsWith('('))
69
- return false
70
-
71
- const first = splitTop(type.slice(1), ',')[0] ?? ''
72
-
73
- // A destructured parameter takes an object whatever its type is called.
74
- if (first.startsWith('{'))
75
- return true
76
-
77
- const colon = first.indexOf(':')
78
-
79
- return colon !== -1 && OBJECT_TYPE.test(first.slice(colon + 1).trim())
80
- }
81
-
82
- // The component an attribute is written on, read off its line or, for an attribute on a line of its own, the line above it that opens the call.
83
- function componentAt(source: string, at: number): string | undefined {
84
- const lineEnd = source.indexOf('\n', at)
85
- const [own, ...above] = source.slice(0, lineEnd === -1 ? source.length : lineEnd).split('\n').toReversed()
86
- const opened = COMPONENT.exec(own!.trimStart())
87
-
88
- if (opened !== null)
89
- return opened[1]
90
-
91
- if (ELEMENT.test(own!.trimStart()))
92
- return undefined
93
-
94
- const indent = own!.length - own!.trimStart().length
95
-
96
- for (const line of above) {
97
- const trimmed = line.trimStart()
98
-
99
- if (trimmed !== '' && line.length - trimmed.length < indent)
100
- return COMPONENT.exec(trimmed)?.[1]
101
- }
102
-
103
- return undefined
104
- }
105
-
106
- // A callback a component of a kayjs library takes as one event object since 1.105, given a function written for its positional arguments: the handler of `onValueChange={query.set}`, `onCheckedChange={toggle}` or `onFiles={upload}`.
107
- // The fix wraps a handler written as a name, `event => query.set(event.value)`, passing the fields the handler took, first ones first. It is applied where the handler's parameter is no object, which the old arguments were; a handler taking an object may be written for the event already, so its fix is offered.
108
- export function handlerEventLint(message: string, source: string, span: Span | undefined): OldFormLint | undefined {
109
- const found = EVENT_CALLBACK.exec(message)
110
-
111
- if (found === null || span === undefined)
112
- return undefined
113
-
114
- const name = NAME_AT.exec(source.slice(span.start))?.[0]
115
-
116
- if (name === undefined || !CALLBACK_NAME.test(name))
117
- return undefined
118
-
119
- const component = componentAt(source, span.start)
120
-
121
- if (component === undefined || !new RegExp(`^import\\b[^\\n]*\\b${component}\\b[^\\n]*from\\s+['"]@kayjs/`, 'm').test(source))
122
- return undefined
123
-
124
- const [, handlerType, eventFields, rest] = found
125
- const fields = splitTop(eventFields!, ';').flatMap(segment => FIELD.exec(segment)?.[1] ?? [])
126
-
127
- if (fields.length === 0)
128
- return undefined
129
-
130
- const object = takesObject(handlerType!) || PARAMETER_TYPE.exec(rest!)?.[1]?.startsWith('{') === true
131
- const taken = fields.slice(0, Math.max(1, Math.min(parameterCount(handlerType!), fields.length)))
132
- const attribute = attributeNamed(source, { start: span.start, end: source.length }, name)
133
- const value = attribute === undefined ? undefined : source.slice(attribute.start + name.length + 1, attribute.end)
134
- const inner = value?.startsWith('{') && value.endsWith('}') ? value.slice(1, -1).trim() : undefined
135
- const handler = inner !== undefined && HANDLER_NAME.test(inner) && !EVENT_WORD.test(inner) ? inner : undefined
136
- const written = `event => ${handler}(${taken.map(field => `event.${field}`).join(', ')})`
137
- const report = {
138
- message: `\`${name}\` on \`${component}\` takes one event object since 1.105, \`{ ${fields.join(', ')} }\`, where it took ${fields.map(field => `\`${field}\``).join(', ')} as ${fields.length === 1 ? 'its argument' : 'arguments'}`,
139
- help: handler === undefined ? 'take the event object, `({ value }) => ...`, and read the fields from it' : `write \`${name}={${written}}\``,
140
- span,
141
- }
142
-
143
- if (handler === undefined || attribute === undefined)
144
- return report
145
-
146
- const start = attribute.start + name.length + 1 + value!.indexOf(handler)
147
-
148
- return { ...report, fixes: [{ title: `Write \`${name}={${written}}\``, safe: !object, edits: [{ start, end: start + handler.length, text: written }] }] }
149
- }
@@ -1,94 +0,0 @@
1
- import type { CheckDiagnostic, CheckOptions } from '.'
2
- import type { Node, NodeOfType } from '../compiler/estree'
3
- import type { Edit } from './renamed-exports'
4
- import { lintLevel } from '../compiler/lints'
5
- import { keyName } from '../compiler/object-literal'
6
- import { importsOf, walk } from './ast'
7
- import { configObjects, isProperty, propertiesOf } from './config-objects'
8
- import { scan } from './renamed-exports'
9
-
10
- type ObjectExpression = NodeOfType<'ObjectExpression'>
11
-
12
- const NEEDLE = /\bctx\b/
13
- const HOOKS = ['beforeRun', 'onSuccess', 'onError']
14
- const FROM_KAY = (source: string): boolean => source === 'kay' || source === 'kay/server'
15
-
16
- type Hook = NodeOfType<'ArrowFunctionExpression'> | NodeOfType<'FunctionExpression'>
17
-
18
- // The `ctx` an action hook reads off its event, `context` since 1.105: the one field every hook event carries, which holds the action's own context besides who asks.
19
- // A hook is the function written under `beforeRun`, `onSuccess` or `onError` in the `actions` of the config or the options of an `action()` call; the fix renames what a destructured parameter or a member read of the event names, and offers none where the name is given a default or the event is used another way.
20
- function hookEdits(hook: Hook, base: number): { start: number, end: number, edits: Edit[] | null }[] {
21
- const [event] = hook.params
22
- const found: { start: number, end: number, edits: Edit[] | null }[] = []
23
-
24
- if (event?.type === 'ObjectPattern') {
25
- for (const property of event.properties) {
26
- if (property.type !== 'Property' || property.computed || keyName(property) !== 'ctx')
27
- continue
28
-
29
- const value = property.value
30
- const renamed = property.shorthand ? { start: base + property.start, end: base + property.end, text: 'context: ctx' } : { start: base + property.key.start, end: base + property.key.end, text: 'context' }
31
- const edits: Edit[] | null = property.shorthand && value.type !== 'Identifier' ? null : [renamed]
32
-
33
- found.push({ start: base + property.start, end: base + property.end, edits })
34
- }
35
-
36
- return found
37
- }
38
-
39
- if (event?.type !== 'Identifier' || hook.body === null || hook.body === undefined)
40
- return found
41
-
42
- walk(hook.body, (node) => {
43
- if (node.type === 'MemberExpression' && !node.computed && node.object.type === 'Identifier' && node.object.name === event.name && node.property.type === 'Identifier' && node.property.name === 'ctx')
44
- found.push({ start: base + node.property.start, end: base + node.property.end, edits: [{ start: base + node.property.start, end: base + node.property.end, text: 'context' }] })
45
- })
46
-
47
- return found
48
- }
49
-
50
- const isHook = (node: Node): node is Hook => node.type === 'ArrowFunctionExpression' || node.type === 'FunctionExpression'
51
-
52
- // The hook functions an object of action hooks holds.
53
- function hooksOf(object: ObjectExpression): Hook[] {
54
- return HOOKS.flatMap(name => propertiesOf(object, name)).flatMap(property => isProperty(property) && isHook(property.value) ? [property.value] : [])
55
- }
56
-
57
- export async function hookContext(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
58
- if (lintLevel('deprecated-hook-context', options.lints) === 'allow')
59
- return []
60
-
61
- return scan(root, options, 'deprecated-hook-context', NEEDLE, ({ file, parsed, report }) => {
62
- for (const { ast, base } of parsed) {
63
- const objects: ObjectExpression[] = []
64
-
65
- for (const { object } of configObjects(file, ast)) {
66
- const [actions] = propertiesOf(object, 'actions')
67
-
68
- if (actions?.value.type === 'ObjectExpression')
69
- objects.push(actions.value)
70
- }
71
-
72
- const { locals, namespaces } = importsOf(ast, FROM_KAY, 'action')
73
-
74
- if (locals.size > 0 || namespaces.size > 0) {
75
- walk(ast, (node) => {
76
- if (node.type !== 'CallExpression')
77
- return
78
-
79
- const callee = node.callee
80
- const called = callee.type === 'Identifier' ? locals.has(callee.name) : callee.type === 'MemberExpression' && !callee.computed && callee.object.type === 'Identifier' && namespaces.has(callee.object.name) && callee.property.type === 'Identifier' && callee.property.name === 'action'
81
- const last = node.arguments.at(-1)
82
-
83
- if (called && last?.type === 'ObjectExpression')
84
- objects.push(last)
85
- })
86
- }
87
-
88
- for (const hook of objects.flatMap(hooksOf)) {
89
- for (const { start, end, edits } of hookEdits(hook, base))
90
- report(start, end, '`ctx` of an action hook\'s event is deprecated since 1.105: every hook event carries one `context`, which holds the action\'s own context beside who asks', 'read `context`', edits)
91
- }
92
- }
93
- })
94
- }
@@ -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
- }