@kayjs/kay 1.105.0 → 1.107.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 (467) hide show
  1. package/README.md +2 -2
  2. package/dist/eslint.js +777 -210
  3. package/editors/zed/extension.toml +2 -2
  4. package/llms/action-protection.md +2 -2
  5. package/llms/actions-from-islands.md +2 -2
  6. package/llms/actions-refused-fields.md +22 -0
  7. package/llms/actions.md +24 -41
  8. package/llms/analytics.md +1 -1
  9. package/llms/api-from-islands.md +1 -1
  10. package/llms/api-routes.md +6 -6
  11. package/llms/browser-only.md +1 -1
  12. package/llms/check-and-tools.md +1 -1
  13. package/llms/code-lints.md +2 -2
  14. package/llms/compiler-api.md +1 -1
  15. package/llms/component-libraries.md +1 -0
  16. package/llms/components.md +1 -1
  17. package/llms/content-cms.md +1 -1
  18. package/llms/content-markdown-to-caching.md +1 -1
  19. package/llms/content-preview.md +2 -2
  20. package/llms/content.md +21 -21
  21. package/llms/deprecated-lints-1-105-libraries.md +2 -0
  22. package/llms/deprecated-lints-1-105.md +3 -3
  23. package/llms/deprecated-lints.md +4 -4
  24. package/llms/dev-tool.md +2 -2
  25. package/llms/environment.md +22 -22
  26. package/llms/files.md +5 -5
  27. package/llms/island-and-form-lints.md +1 -0
  28. package/llms/islands-state-to-ids.md +2 -1
  29. package/llms/islands.md +10 -1
  30. package/llms/local-collections.md +2 -2
  31. package/llms/mcp.md +2 -1
  32. package/llms/navigation-from-code.md +1 -1
  33. package/llms/notifications.md +4 -2
  34. package/llms/project-new-and-add.md +1 -1
  35. package/llms/project.md +3 -3
  36. package/llms/rate-limits.md +1 -1
  37. package/llms/recipes.md +16 -16
  38. package/llms/rooms.md +4 -4
  39. package/llms/routing-endpoints-and-base.md +1 -1
  40. package/llms/routing.md +5 -5
  41. package/llms/schemas.md +14 -7
  42. package/llms/server.md +7 -7
  43. package/llms/site.md +9 -9
  44. package/llms/sitemap-search-fonts.md +2 -0
  45. package/llms/styles-and-assets.md +2 -1
  46. package/llms/templates-elements-slots-snippets.md +2 -2
  47. package/llms/testing-browser.md +20 -0
  48. package/llms/testing.md +1 -1
  49. package/llms/upgrading-1-105-config.md +2 -2
  50. package/llms/upgrading.md +37 -4
  51. package/llms/whats-new-archive.md +35 -66
  52. package/llms/whats-new.md +47 -28
  53. package/llms.txt +1 -1
  54. package/package.json +24 -11
  55. package/src/add.ts +1 -1
  56. package/src/build/class-table.ts +2 -2
  57. package/src/build/client.ts +27 -30
  58. package/src/build/entry-files.ts +19 -0
  59. package/src/build/lazy-components.ts +130 -0
  60. package/src/build/lazy-manifest.ts +56 -0
  61. package/src/build/lazy-stubs.ts +31 -0
  62. package/src/build/plugin.ts +16 -11
  63. package/src/build/runtime-chunk.ts +1 -1
  64. package/src/build/styles.ts +3 -3
  65. package/src/build/transform.ts +19 -7
  66. package/src/build/ui-layers.ts +30 -0
  67. package/src/build/ui.ts +108 -11
  68. package/src/build/variants.ts +125 -46
  69. package/src/build/worker-bundle.ts +6 -0
  70. package/src/check/action-options.ts +56 -0
  71. package/src/check/boot.ts +22 -1
  72. package/src/check/call-result.ts +242 -0
  73. package/src/check/config-objects.ts +17 -2
  74. package/src/check/diagnose.ts +22 -0
  75. package/src/check/handler-events.ts +149 -0
  76. package/src/check/index.ts +6 -2
  77. package/src/check/link-flag-tests.ts +130 -0
  78. package/src/check/project.ts +4 -3
  79. package/src/check/refusal-calls.ts +2 -2
  80. package/src/check/regroup.ts +5 -3
  81. package/src/check/renamed-packages.ts +58 -14
  82. package/src/check/schema-builders.ts +256 -0
  83. package/src/check/schema-json.ts +226 -0
  84. package/src/check/secret-keys.ts +15 -2
  85. package/src/check/shadow-types.ts +13 -9
  86. package/src/check/template-hints.ts +1 -1
  87. package/src/check/tool-labels.ts +11 -9
  88. package/src/check/ui-types.ts +4 -3
  89. package/src/check/ui.ts +14 -11
  90. package/src/commands/env-declare.ts +18 -6
  91. package/src/commands/routes.ts +1 -1
  92. package/src/compiler/a11y.ts +8 -1
  93. package/src/compiler/ast.ts +1 -1
  94. package/src/compiler/bound-props.ts +1 -1
  95. package/src/compiler/codegen.ts +13 -23
  96. package/src/compiler/deprecated-lints-1-105.ts +41 -0
  97. package/src/compiler/deprecated-lints-1-106.ts +14 -0
  98. package/src/compiler/deprecated-lints-1-107.ts +14 -0
  99. package/src/compiler/deprecated-lints.ts +17 -60
  100. package/src/compiler/deprecated-typed-lints.ts +23 -0
  101. package/src/compiler/dom-here.ts +72 -0
  102. package/src/compiler/dom.ts +23 -23
  103. package/src/compiler/fence-checks.ts +12 -11
  104. package/src/compiler/field-described.ts +2 -2
  105. package/src/compiler/helper-imports.ts +1 -1
  106. package/src/compiler/html-fields.ts +92 -0
  107. package/src/compiler/html-initial.ts +5 -3
  108. package/src/compiler/html.ts +14 -31
  109. package/src/compiler/import-edits.ts +15 -0
  110. package/src/compiler/index.ts +10 -3
  111. package/src/compiler/island-declaration.ts +15 -0
  112. package/src/compiler/items.ts +5 -5
  113. package/src/compiler/kay-exports.ts +1 -0
  114. package/src/compiler/lazy-imports.ts +357 -0
  115. package/src/compiler/link-flags.ts +6 -5
  116. package/src/compiler/lints.ts +12 -12
  117. package/src/compiler/parser.ts +2 -2
  118. package/src/compiler/rest-omits.ts +15 -0
  119. package/src/compiler/route-lints.ts +2 -0
  120. package/src/compiler/schema-lints.ts +13 -0
  121. package/src/compiler/script-server.ts +6 -3
  122. package/src/config-loader.ts +10 -2
  123. package/src/config-resolve.ts +3 -1
  124. package/src/config-shape.ts +2 -2
  125. package/src/config.ts +20 -4
  126. package/src/content/markdown.ts +2 -3
  127. package/src/content/validate.ts +1 -1
  128. package/src/generate-resource.ts +9 -9
  129. package/src/generate.ts +1 -1
  130. package/src/mcp/guards.ts +1 -1
  131. package/src/mcp/tools.ts +1 -1
  132. package/src/migrate/content.ts +61 -55
  133. package/src/new.ts +6 -2
  134. package/src/runtime/action-shared.ts +2 -2
  135. package/src/runtime/action.ts +51 -4
  136. package/src/runtime/client.ts +10 -0
  137. package/src/runtime/dom-lazy.ts +276 -0
  138. package/src/runtime/field-errors.ts +58 -0
  139. package/src/runtime/field-refusal.ts +179 -0
  140. package/src/runtime/form-types.ts +99 -0
  141. package/src/runtime/form.ts +25 -9
  142. package/src/runtime/html.ts +42 -6
  143. package/src/runtime/index.ts +2 -0
  144. package/src/runtime/island.server.ts +36 -2
  145. package/src/runtime/markdown-autolink.ts +69 -0
  146. package/src/runtime/markdown-render.client.ts +39 -3
  147. package/src/runtime/markdown.client.ts +6 -3
  148. package/src/runtime/markdown.server.ts +6 -3
  149. package/src/runtime/markdown.ts +125 -1
  150. package/src/runtime/navigate-api.ts +10 -5
  151. package/src/runtime/persist.ts +7 -7
  152. package/src/runtime/query-param.ts +1 -1
  153. package/src/runtime/reactive.ts +14 -0
  154. package/src/runtime/sanitize.ts +3 -1
  155. package/src/runtime/schema-record.ts +32 -0
  156. package/src/runtime/schema.client.ts +101 -14
  157. package/src/runtime/schema.ts +328 -26
  158. package/src/runtime/standard-schema.ts +32 -0
  159. package/src/runtime/swap-focus.ts +59 -11
  160. package/src/runtime/validate-run.client.ts +179 -0
  161. package/src/runtime/validate.client.ts +11 -0
  162. package/src/runtime/validate.ts +4 -137
  163. package/src/server/action-module.ts +16 -0
  164. package/src/server/actions.ts +54 -57
  165. package/src/server/answer.ts +102 -0
  166. package/src/server/api-input.ts +166 -0
  167. package/src/server/api-modules.ts +1 -1
  168. package/src/server/api.ts +12 -32
  169. package/src/server/app-stages.ts +38 -26
  170. package/src/server/app.ts +5 -2
  171. package/src/server/client.ts +2 -0
  172. package/src/server/dev-ui.ts +2 -2
  173. package/src/server/dev.ts +7 -9
  174. package/src/server/env-state.ts +1 -1
  175. package/src/server/env.ts +11 -3
  176. package/src/server/favicon.ts +47 -1
  177. package/src/server/file-limit.ts +7 -1
  178. package/src/server/forms.ts +1 -1
  179. package/src/server/host-allowlist.ts +7 -7
  180. package/src/server/image-metadata-bmff.ts +1 -1
  181. package/src/server/index.ts +2 -0
  182. package/src/server/kay-routes.ts +221 -0
  183. package/src/server/kay-server.ts +228 -0
  184. package/src/server/kept-exports.ts +1 -0
  185. package/src/server/kept-pages.ts +3 -3
  186. package/src/server/library.ts +2 -2
  187. package/src/server/mcp.ts +14 -13
  188. package/src/server/notifications.ts +4 -2
  189. package/src/server/offline.ts +24 -7
  190. package/src/server/openapi.ts +12 -3
  191. package/src/server/phases.ts +249 -0
  192. package/src/server/protection.ts +6 -6
  193. package/src/server/proxy-key.ts +8 -8
  194. package/src/server/push-settings.ts +16 -2
  195. package/src/server/push.ts +12 -4
  196. package/src/server/query.ts +17 -31
  197. package/src/server/receive.ts +43 -0
  198. package/src/server/render-document.ts +13 -3
  199. package/src/server/render.ts +1 -1
  200. package/src/server/request-context.ts +137 -0
  201. package/src/server/schema-check.ts +1 -1
  202. package/src/server/scope.ts +20 -13
  203. package/src/server/signals.ts +4 -4
  204. package/src/server/socket.ts +19 -47
  205. package/src/server/stream.ts +1 -1
  206. package/src/server/validate.ts +346 -0
  207. package/src/template-ws.ts +1 -1
  208. package/src/test/a11y-dom.ts +70 -0
  209. package/src/test/html-snapshot.ts +103 -0
  210. package/src/test/index.ts +2 -1
  211. package/src/test/mount.ts +14 -3
  212. package/src/test/page-checks.ts +12 -0
  213. package/src/test/screenshot-match.ts +2 -2
  214. package/src/test/shared-modules.ts +27 -5
  215. package/src/test/site-types.ts +5 -1
  216. package/types/build/class-table.d.ts +1 -1
  217. package/types/build/class-table.d.ts.map +1 -1
  218. package/types/build/client.d.ts +3 -2
  219. package/types/build/client.d.ts.map +1 -1
  220. package/types/build/entry-files.d.ts +4 -0
  221. package/types/build/entry-files.d.ts.map +1 -0
  222. package/types/build/lazy-components.d.ts +6 -0
  223. package/types/build/lazy-components.d.ts.map +1 -0
  224. package/types/build/lazy-manifest.d.ts +19 -0
  225. package/types/build/lazy-manifest.d.ts.map +1 -0
  226. package/types/build/lazy-stubs.d.ts +5 -0
  227. package/types/build/lazy-stubs.d.ts.map +1 -0
  228. package/types/build/plugin.d.ts +1 -0
  229. package/types/build/plugin.d.ts.map +1 -1
  230. package/types/build/transform.d.ts +4 -1
  231. package/types/build/transform.d.ts.map +1 -1
  232. package/types/build/ui-layers.d.ts +5 -0
  233. package/types/build/ui-layers.d.ts.map +1 -0
  234. package/types/build/ui.d.ts +7 -0
  235. package/types/build/ui.d.ts.map +1 -1
  236. package/types/build/variants.d.ts +1 -1
  237. package/types/build/variants.d.ts.map +1 -1
  238. package/types/build/worker-bundle.d.ts +1 -0
  239. package/types/build/worker-bundle.d.ts.map +1 -1
  240. package/types/check/action-options.d.ts +3 -0
  241. package/types/check/action-options.d.ts.map +1 -0
  242. package/types/check/boot.d.ts.map +1 -1
  243. package/types/check/call-result.d.ts +7 -0
  244. package/types/check/call-result.d.ts.map +1 -0
  245. package/types/check/config-objects.d.ts.map +1 -1
  246. package/types/check/diagnose.d.ts.map +1 -1
  247. package/types/check/handler-events.d.ts +9 -0
  248. package/types/check/handler-events.d.ts.map +1 -0
  249. package/types/check/index.d.ts +1 -0
  250. package/types/check/index.d.ts.map +1 -1
  251. package/types/check/link-flag-tests.d.ts +4 -0
  252. package/types/check/link-flag-tests.d.ts.map +1 -0
  253. package/types/check/project.d.ts.map +1 -1
  254. package/types/check/regroup.d.ts +1 -1
  255. package/types/check/regroup.d.ts.map +1 -1
  256. package/types/check/renamed-packages.d.ts +1 -0
  257. package/types/check/renamed-packages.d.ts.map +1 -1
  258. package/types/check/schema-builders.d.ts +3 -0
  259. package/types/check/schema-builders.d.ts.map +1 -0
  260. package/types/check/schema-json.d.ts +3 -0
  261. package/types/check/schema-json.d.ts.map +1 -0
  262. package/types/check/secret-keys.d.ts.map +1 -1
  263. package/types/check/shadow-types.d.ts.map +1 -1
  264. package/types/check/template-hints.d.ts +1 -0
  265. package/types/check/template-hints.d.ts.map +1 -1
  266. package/types/check/tool-labels.d.ts.map +1 -1
  267. package/types/check/ui-types.d.ts.map +1 -1
  268. package/types/check/ui.d.ts.map +1 -1
  269. package/types/commands/env-declare.d.ts.map +1 -1
  270. package/types/compiler/a11y.d.ts.map +1 -1
  271. package/types/compiler/bound-props.d.ts +1 -0
  272. package/types/compiler/bound-props.d.ts.map +1 -1
  273. package/types/compiler/codegen.d.ts +3 -0
  274. package/types/compiler/codegen.d.ts.map +1 -1
  275. package/types/compiler/deprecated-lints-1-105.d.ts +39 -0
  276. package/types/compiler/deprecated-lints-1-105.d.ts.map +1 -0
  277. package/types/compiler/deprecated-lints-1-106.d.ts +12 -0
  278. package/types/compiler/deprecated-lints-1-106.d.ts.map +1 -0
  279. package/types/compiler/deprecated-lints-1-107.d.ts +12 -0
  280. package/types/compiler/deprecated-lints-1-107.d.ts.map +1 -0
  281. package/types/compiler/deprecated-lints.d.ts +41 -22
  282. package/types/compiler/deprecated-lints.d.ts.map +1 -1
  283. package/types/compiler/deprecated-typed-lints.d.ts +21 -0
  284. package/types/compiler/deprecated-typed-lints.d.ts.map +1 -0
  285. package/types/compiler/dom-here.d.ts +14 -0
  286. package/types/compiler/dom-here.d.ts.map +1 -0
  287. package/types/compiler/dom.d.ts +1 -0
  288. package/types/compiler/dom.d.ts.map +1 -1
  289. package/types/compiler/fence-checks.d.ts.map +1 -1
  290. package/types/compiler/field-described.d.ts +1 -1
  291. package/types/compiler/field-described.d.ts.map +1 -1
  292. package/types/compiler/html-fields.d.ts +19 -0
  293. package/types/compiler/html-fields.d.ts.map +1 -0
  294. package/types/compiler/html-initial.d.ts +3 -2
  295. package/types/compiler/html-initial.d.ts.map +1 -1
  296. package/types/compiler/html.d.ts.map +1 -1
  297. package/types/compiler/import-edits.d.ts +1 -0
  298. package/types/compiler/import-edits.d.ts.map +1 -1
  299. package/types/compiler/index.d.ts +3 -0
  300. package/types/compiler/index.d.ts.map +1 -1
  301. package/types/compiler/island-declaration.d.ts +5 -0
  302. package/types/compiler/island-declaration.d.ts.map +1 -1
  303. package/types/compiler/items.d.ts +4 -1
  304. package/types/compiler/items.d.ts.map +1 -1
  305. package/types/compiler/kay-exports.d.ts.map +1 -1
  306. package/types/compiler/lazy-imports.d.ts +33 -0
  307. package/types/compiler/lazy-imports.d.ts.map +1 -0
  308. package/types/compiler/link-flags.d.ts +6 -0
  309. package/types/compiler/link-flags.d.ts.map +1 -1
  310. package/types/compiler/lints.d.ts +61 -34
  311. package/types/compiler/lints.d.ts.map +1 -1
  312. package/types/compiler/rest-omits.d.ts +4 -0
  313. package/types/compiler/rest-omits.d.ts.map +1 -0
  314. package/types/compiler/route-lints.d.ts +8 -0
  315. package/types/compiler/route-lints.d.ts.map +1 -1
  316. package/types/compiler/schema-lints.d.ts +11 -0
  317. package/types/compiler/schema-lints.d.ts.map +1 -0
  318. package/types/compiler/script-server.d.ts.map +1 -1
  319. package/types/config-loader.d.ts.map +1 -1
  320. package/types/config-resolve.d.ts.map +1 -1
  321. package/types/config.d.ts +15 -2
  322. package/types/config.d.ts.map +1 -1
  323. package/types/content/markdown.d.ts.map +1 -1
  324. package/types/migrate/content.d.ts.map +1 -1
  325. package/types/new.d.ts +1 -0
  326. package/types/new.d.ts.map +1 -1
  327. package/types/runtime/action-shared.d.ts +1 -1
  328. package/types/runtime/action-shared.d.ts.map +1 -1
  329. package/types/runtime/action.d.ts +29 -1
  330. package/types/runtime/action.d.ts.map +1 -1
  331. package/types/runtime/client.d.ts.map +1 -1
  332. package/types/runtime/dom-lazy.d.ts +6 -0
  333. package/types/runtime/dom-lazy.d.ts.map +1 -0
  334. package/types/runtime/field-errors.d.ts +4 -0
  335. package/types/runtime/field-errors.d.ts.map +1 -0
  336. package/types/runtime/field-refusal.d.ts +37 -0
  337. package/types/runtime/field-refusal.d.ts.map +1 -0
  338. package/types/runtime/form-types.d.ts +6 -0
  339. package/types/runtime/form-types.d.ts.map +1 -0
  340. package/types/runtime/form.d.ts +4 -2
  341. package/types/runtime/form.d.ts.map +1 -1
  342. package/types/runtime/html.d.ts +3 -0
  343. package/types/runtime/html.d.ts.map +1 -1
  344. package/types/runtime/index.d.ts +2 -0
  345. package/types/runtime/index.d.ts.map +1 -1
  346. package/types/runtime/island.server.d.ts +2 -0
  347. package/types/runtime/island.server.d.ts.map +1 -1
  348. package/types/runtime/markdown-autolink.d.ts +11 -0
  349. package/types/runtime/markdown-autolink.d.ts.map +1 -0
  350. package/types/runtime/markdown-render.client.d.ts +2 -1
  351. package/types/runtime/markdown-render.client.d.ts.map +1 -1
  352. package/types/runtime/markdown.client.d.ts +3 -1
  353. package/types/runtime/markdown.client.d.ts.map +1 -1
  354. package/types/runtime/markdown.d.ts +11 -0
  355. package/types/runtime/markdown.d.ts.map +1 -1
  356. package/types/runtime/markdown.server.d.ts +3 -1
  357. package/types/runtime/markdown.server.d.ts.map +1 -1
  358. package/types/runtime/navigate-api.d.ts +1 -1
  359. package/types/runtime/navigate-api.d.ts.map +1 -1
  360. package/types/runtime/persist.d.ts +2 -2
  361. package/types/runtime/persist.d.ts.map +1 -1
  362. package/types/runtime/reactive.d.ts +3 -0
  363. package/types/runtime/reactive.d.ts.map +1 -1
  364. package/types/runtime/sanitize.d.ts.map +1 -1
  365. package/types/runtime/schema-record.d.ts +9 -0
  366. package/types/runtime/schema-record.d.ts.map +1 -0
  367. package/types/runtime/schema.client.d.ts.map +1 -1
  368. package/types/runtime/schema.d.ts +99 -10
  369. package/types/runtime/schema.d.ts.map +1 -1
  370. package/types/runtime/standard-schema.d.ts +37 -0
  371. package/types/runtime/standard-schema.d.ts.map +1 -0
  372. package/types/runtime/swap-focus.d.ts.map +1 -1
  373. package/types/runtime/validate-run.client.d.ts +4 -0
  374. package/types/runtime/validate-run.client.d.ts.map +1 -0
  375. package/types/runtime/validate.client.d.ts +4 -0
  376. package/types/runtime/validate.client.d.ts.map +1 -0
  377. package/types/runtime/validate.d.ts +1 -21
  378. package/types/runtime/validate.d.ts.map +1 -1
  379. package/types/server/action-module.d.ts +2 -0
  380. package/types/server/action-module.d.ts.map +1 -0
  381. package/types/server/actions.d.ts +1 -0
  382. package/types/server/actions.d.ts.map +1 -1
  383. package/types/server/answer.d.ts +6 -0
  384. package/types/server/answer.d.ts.map +1 -0
  385. package/types/server/api-input.d.ts +19 -0
  386. package/types/server/api-input.d.ts.map +1 -0
  387. package/types/server/api.d.ts.map +1 -1
  388. package/types/server/app-stages.d.ts +7 -3
  389. package/types/server/app-stages.d.ts.map +1 -1
  390. package/types/server/app.d.ts +2 -0
  391. package/types/server/app.d.ts.map +1 -1
  392. package/types/server/client.d.ts +1 -0
  393. package/types/server/client.d.ts.map +1 -1
  394. package/types/server/dev.d.ts +1 -1
  395. package/types/server/dev.d.ts.map +1 -1
  396. package/types/server/env-state.d.ts.map +1 -1
  397. package/types/server/env.d.ts +5 -1
  398. package/types/server/env.d.ts.map +1 -1
  399. package/types/server/favicon.d.ts +3 -1
  400. package/types/server/favicon.d.ts.map +1 -1
  401. package/types/server/file-limit.d.ts.map +1 -1
  402. package/types/server/host-allowlist.d.ts +3 -3
  403. package/types/server/host-allowlist.d.ts.map +1 -1
  404. package/types/server/index.d.ts +2 -0
  405. package/types/server/index.d.ts.map +1 -1
  406. package/types/server/kay-routes.d.ts +47 -0
  407. package/types/server/kay-routes.d.ts.map +1 -0
  408. package/types/server/kay-server.d.ts +25 -0
  409. package/types/server/kay-server.d.ts.map +1 -0
  410. package/types/server/kept-exports.d.ts.map +1 -1
  411. package/types/server/kept-pages.d.ts +1 -1
  412. package/types/server/kept-pages.d.ts.map +1 -1
  413. package/types/server/library.d.ts +2 -1
  414. package/types/server/library.d.ts.map +1 -1
  415. package/types/server/mcp.d.ts +1 -1
  416. package/types/server/mcp.d.ts.map +1 -1
  417. package/types/server/notifications.d.ts +2 -1
  418. package/types/server/notifications.d.ts.map +1 -1
  419. package/types/server/offline.d.ts.map +1 -1
  420. package/types/server/openapi.d.ts.map +1 -1
  421. package/types/server/phases.d.ts +36 -0
  422. package/types/server/phases.d.ts.map +1 -0
  423. package/types/server/protection.d.ts +3 -2
  424. package/types/server/protection.d.ts.map +1 -1
  425. package/types/server/proxy-key.d.ts +3 -3
  426. package/types/server/proxy-key.d.ts.map +1 -1
  427. package/types/server/push-settings.d.ts +1 -1
  428. package/types/server/push-settings.d.ts.map +1 -1
  429. package/types/server/push.d.ts +1 -0
  430. package/types/server/push.d.ts.map +1 -1
  431. package/types/server/query.d.ts.map +1 -1
  432. package/types/server/receive.d.ts +9 -0
  433. package/types/server/receive.d.ts.map +1 -0
  434. package/types/server/render-document.d.ts.map +1 -1
  435. package/types/server/request-context.d.ts +29 -0
  436. package/types/server/request-context.d.ts.map +1 -0
  437. package/types/server/schema-check.d.ts +1 -0
  438. package/types/server/schema-check.d.ts.map +1 -1
  439. package/types/server/scope.d.ts +1 -1
  440. package/types/server/scope.d.ts.map +1 -1
  441. package/types/server/socket.d.ts +3 -5
  442. package/types/server/socket.d.ts.map +1 -1
  443. package/types/server/validate.d.ts +26 -0
  444. package/types/server/validate.d.ts.map +1 -0
  445. package/types/test/a11y-dom.d.ts +20 -0
  446. package/types/test/a11y-dom.d.ts.map +1 -0
  447. package/types/test/html-snapshot.d.ts +4 -0
  448. package/types/test/html-snapshot.d.ts.map +1 -0
  449. package/types/test/index.d.ts.map +1 -1
  450. package/types/test/mount.d.ts +3 -0
  451. package/types/test/mount.d.ts.map +1 -1
  452. package/types/test/page-checks.d.ts +6 -0
  453. package/types/test/page-checks.d.ts.map +1 -0
  454. package/types/test/screenshot-match.d.ts +1 -1
  455. package/types/test/screenshot-match.d.ts.map +1 -1
  456. package/types/test/shared-modules.d.ts.map +1 -1
  457. package/types/test/site-types.d.ts +3 -1
  458. package/types/test/site-types.d.ts.map +1 -1
  459. package/src/check/schema-type.ts +0 -9
  460. package/src/compiler/deprecated-script-fence.ts +0 -26
  461. package/src/server/field-errors.ts +0 -136
  462. package/types/check/schema-type.d.ts +0 -3
  463. package/types/check/schema-type.d.ts.map +0 -1
  464. package/types/compiler/deprecated-script-fence.d.ts +0 -3
  465. package/types/compiler/deprecated-script-fence.d.ts.map +0 -1
  466. package/types/server/field-errors.d.ts +0 -6
  467. package/types/server/field-errors.d.ts.map +0 -1
@@ -19,6 +19,8 @@ The lints of the `deprecated` group that came in 1.105 for kayjs-ai, kayjs-ui, k
19
19
  | `deprecated-auth-signed` | warn | deprecated | kayjs-auth's `SignedIn(role=...)` and `SignedOut`, one check written three ways before 1.105: `SignedIn` takes `require` since 1.105, which is what `auth.guard({ require })` takes (a role, a list of which any one passes, a predicate), and its `@else` block holds what a visitor sees, in place of a `SignedOut` beside it. The old forms work until 1.108. Found on a component bound to the library's file in a template. The fix renames `role` to `require`; `SignedOut` and a `role` written beside a `require` are reported with no fix, since the children of a `SignedOut` join the `SignedIn` beside it by hand. |
20
20
  | `deprecated-auth-methods` | warn | deprecated | kayjs-auth's methods under the names they had before 1.105, when the verbs of a group differed and some methods sat on `auth` itself: every group lists with `list`, reads with `get`, writes with `create` and `update`, removes with `delete` and takes back with `revoke`. `organizations.members`, `invitations`, `myInvitations` and `invitation` are `listMembers`, `listInvitations`, `listMyInvitations` and `getInvitation`, `setMemberRoles` and `removeMember` are `updateMemberRoles` and `deleteMember`; `admin.roles` and `admin.auditLog` are `listRoles` and `listAuditLog`; `oauthServer.clients` is `listClients`; `passkeys.rename` is `passkeys.update`; `account.changeUsername`, `profile` and `saveProfile` are `updateUsername`, `getProfile` and `updateProfile`; `oauth.identities` and `providerToken` are `listIdentities` and `getProviderToken`; `magicLink.signInWithCode` is `email.signInWithCode`, the code being the email's. The methods on `auth` went into the group they belong to: `requireAdmin()` is `admin.require()`, `captchaRequired()` and `captchaChallenge()` are `captcha.required()` and `captcha.challenge()`, `provedLately()` and `reprove()` are `proof.recent()` and `proof.renew()`, `scopes()` and `hasScope()` are `tokens.scopes()` and `tokens.hasScope()`, and `oauthResource()`, `oauthOrigin()` and `oauthFixed()` are `oauthServer.resource()`, `origin()` and `fixed()`. The old names work until 1.108. Found on a call whose receiver is named `auth` (`ctx.locals.auth`, `locals.auth`), in the TypeScript files and `.kay` files of the project, a template expression excluded; the fix writes the new name. |
21
21
  | `deprecated-ui-callbacks` | warn | deprecated | A kayjs-ui prop under the name it had before 1.105, when its callback took positional arguments: `onChange` on an Accordion, Tabs or ThemeToggle is `onValueChange`, on a ZoomPane `onPlateChange`, `onSort` on a Table `onSortChange`, and `onActive` on a BarChart, LineChart, ScatterChart, Sparkline or ContributionGraph `onActiveChange`, each name saying what changed and its callback taking one event object (`{ value, tab }`, `{ plate }`, `{ sort }`, `{ index }`). The old names work until 1.108 with their old arguments. Found on a component bound to the library's file in a template. The fix writes the new name and, for an inline arrow function with plain parameter names, destructures the event under them; any other value is renamed by an unsafe fix, which `kay upgrade` leaves to you, since the callback has to take the event. The other callbacks that took positional arguments (`onChange` of a TextInput, `onOpenChange` of a Dialog) keep their names and take the event object with no old form to find: `kay check` reports each call. |
22
+ | `deprecated-callback-handler` | deny | deprecated | A function written for the arguments a kayjs-ui, kayjs-ai or kayjs-cms callback took before 1.105, given to a callback that takes one event object since: `onValueChange={query.set}`, `onCheckedChange={toggle}` with `toggle(on: boolean)` or `onFiles={upload}` with `upload(files: File[])`. Found where the type check refuses the function and the component comes from a `@kayjs` library; the fix writes `event => query.set(event.value)`, passing the fields the handler took, first ones first, and is applied where its parameter is no object (a parameter typed as an object may be written for the event already, so that fix is offered). A handler that is not a plain name, such as an arrow function, is reported with no fix. The old form fails the type check, and would receive the event where it took the value, so the level is `deny` until it is rewritten. |
23
+ | `deprecated-call-result` | deny | deprecated | An island's call read as its data, `const list = await call(notes, '/')` then `list.items`, or `await add(input)` then `.id`, which resolved with the data before 1.105 and answers a `CallResult`, `{ ok: true, data }` or `{ ok: false, error }`, since. Found where the type check refuses a field of a `CallResult`, in a `.kay` script or a module. The fix writes `.orThrow()` after the call, which resolves with the data and throws a refusal as the call did; it is applied where the call is written on an imported name and nothing reads `ok`, `data` or `error` of the answer, and offered otherwise. The old form fails the type check, so the level is `deny`. |
22
24
  | `deprecated-ui-items` | warn | deprecated | The prop holding the list a kayjs-ui component draws, `items` since 1.105 on every one: `tabs` on a Tabs, `avatars` on an AvatarGroup, `entries` on a CommandPalette or a Timeline, `links` on a SideNav, SiteNav or AppHeader, `steps` on Steps, `icons` on an IconPicker and `slides` on a Carousel, and the infinite source `list` of a Table, Carousel, Masonry, MediaGallery, VirtualList and LoadMore, which `items` takes as well (an array or an `infiniteList`; on a Table `items` is the infinite source and `rows` stays the array). `rows` of a Table and `options` of a choice control keep their names. The old names work until 1.108. Found on a component bound to the library's file in a template. The fix writes `items`; it offers none where `items` is already written. TabNav's `tabs` and `links` are two shapes picked by `param`, and the `links` of a SideNav group are data: both keep their names. |
23
25
  | `deprecated-ui-input` | warn | deprecated | The `id`, `title` and `data-*` attributes of a kayjs-ui Toggle, Checkbox, Slider, ColorInput, Combobox (its `id` names the list and stays) or DateInput, which reached the input before 1.105 and are on the root element now, as on every component; the input takes `inputProps`. The old form works on the root until 1.108, so a stylesheet or a script that found the input by its `id` is what changes. Found on a component bound to the library's file in a template. The fix writes them all into one `inputProps={{ ... }}`; it offers none beside an `inputProps` already written. |
24
26
  | `deprecated-ai-language` | warn | deprecated | `language` in the options of kayjs-ai's `transcribe()` and `describeImage()`, `locale` since 1.105: a BCP 47 tag such as `fr` or `pt-BR` as everywhere in kay, which `transcribe()` turns into the ISO 639-1 code its provider takes. The old name works until 1.108. Found on a call of either imported from `@kayjs/ai`, in the options object written in the call, in the TypeScript files and `.kay` files of the project. The fix renames the key, a bare `{ language }` becoming `locale: language`; an object that spreads another, or that has a `locale` already, is reported with no fix. |
@@ -24,9 +24,9 @@ The lints of the `deprecated` group that came in 1.105, each reported until 1.10
24
24
  | `deprecated-config-switch` | warn | deprecated | `proxy: 2` in kay.config.ts, `proxy: { hops: 2 }` since 1.105, where `proxy: 1` is `proxy: true`: every feature key of the config is `false` for off, `true` for its defaults or an object of options, so the number of proxies was a third form of the same switch. The number works until 1.108. Found in the object kay.config.ts exports. The fix writes `true` for 1 and `{ hops: n }` for a whole number above it; a number that is no whole number from 1 is reported with no fix. |
25
25
  | `deprecated-images-keys` | warn | deprecated | The flat keys of `images` in kay.config.ts, grouped since 1.105: `remoteMaxSize` and `remoteTimeout` are `remote: { maxSize, timeout }`, `quality`, `webp` and `avif` are `formats: { quality, webp, avif }`, `maxVariants` and `queue` are `limits: { variants, queue }`. They work until 1.108. The fix moves the keys into their group, unless the object spreads or already has it. |
26
26
  | `deprecated-client-keys` | warn | deprecated | The keys `links`, `offline` and `search` of kay.config.ts, written in `client` since 1.105 with the rest of what the browser is given: `client: { links, offline, search }`. They work until 1.108. Found in the object kay.config.ts exports and in the `config` of `pages()` and `testSite()`. The fix moves the keys into `client` as written, unless the object spreads, holds a computed key or has a `client` already. |
27
- | `deprecated-config-groups` | warn | deprecated | The keys `images`, `fonts`, `favicon`, `manifest` and `publicCache` of kay.config.ts, written in `assets` since 1.105, and `observe`, `health`, `metrics` and `jobs`, written in `ops`: `assets: { images, fonts, favicon, manifest, publicCache }`, `ops: { observe, health, metrics, jobs }`. They work until 1.108. Found in the object kay.config.ts exports and in the `config` of `pages()` and `testSite()`. The fix moves the keys into their group as written, unless the object spreads, holds a computed key or has the group already. |
27
+ | `deprecated-config-groups` | warn | deprecated | The keys `images`, `fonts`, `favicon`, `manifest` and `publicCache` of kay.config.ts, written in `assets` since 1.105, and `observe`, `health`, `metrics` and `jobs`, written in `ops`: `assets: { images, fonts, favicon, manifest, publicCache }`, `ops: { observe, health, metrics, jobs }`. They work until 1.108. Found in the object kay.config.ts exports, in the `config` of `pages()` and `testSite()` and in the `config` of an extension a file types `KayExtension`, which takes the same keys. The fix moves the keys into their group as written, unless the object spreads, holds a computed key or has the group already. |
28
28
  | `deprecated-i18n-keys` | warn | deprecated | The keys `defaultLocale`, `prefixDefault` and `domains` of `i18n` in kay.config.ts, since 1.105 `default` and `mode`: `mode: 'always'` is `prefixDefault: true` and `mode: { domains }` is `domains`, so a config can no longer give both. They work until 1.108. Found in the object kay.config.ts exports and in the `config` of `pages()` and `testSite()`. The fix renames or rewrites the key where `i18n` is written in place and `default` and `mode` are not there yet; `domains` beside `prefixDefault`, a `prefixDefault` that is no literal `true` and an `i18n` that spreads are reported with no fix. |
29
- | `deprecated-secret-keys` | warn | deprecated | The secrets of kay.config.ts in one shape since 1.105, each `string | { env } | { file }`: `mcp.key` is `mcp.token`, and `proxy.key`, a header name, is `{ header, secret? }`, so `proxy: { key: { header: 'x-upstream-key' } }`; the `mcpKey` and `proxyKey` options of `testSite()` are the `token` and the `secret` of its `config`. They work until 1.108. Found in the object kay.config.ts exports and in the `config` of `pages()` and `testSite()`. The fix renames `mcp.key` (a `key: false` and an `mcp` that spreads or has a `token` are reported with no fix) and wraps the header of `proxy.key`; the options of `testSite()` are reported with no fix. |
29
+ | `deprecated-secret-keys` | warn | deprecated | The secrets of kay.config.ts in one shape since 1.105, each `string | { env } | { file }`: `mcp.key` is `mcp.token`, and `proxy.key`, a header name, is `{ header, secret? }`, so `proxy: { key: { header: 'x-upstream-key' } }`; the `mcpKey` and `proxyKey` options of `testSite()` are the `token` and the `secret` of its `config`. They work until 1.108. Found in the object kay.config.ts exports and in the `config` of `pages()` and `testSite()`. The fix renames `mcp.key` (a `key: false` and an `mcp` that spreads or has a `token` are reported with no fix) and wraps the header of `proxy.key`; the options of `testSite()` move into its `config`, `mcpKey` always and `proxyKey` where the app's config names the header, and are reported with no fix beside a `config` already written. |
30
30
  | `deprecated-route-keys` | warn | deprecated | `serve.apiPrefix` and the `path` of `openapi`, `mcp`, `health`, `metrics` and `jobs` are `endpoints.api`, `.openapi`, `.mcp`, `.health`, `.metrics` and `.jobs` since 1.105; `openapi.referencePath` is `reference: { path }`. The fix writes a new `endpoints`, unless the object spreads, has an `endpoints` or a comment would be lost. |
31
31
  | `deprecated-app-hooks` | warn | deprecated | The hooks and log of the config under their names before 1.105, when the hooks became flat keys named by the moment they run: `onStart` is `onListen` (a job's `onStart` keeps its name), `observe.onError` is `onError` beside `observe`, and `observe.log` as `'json'` or a function is `{ format: 'json' }` or `{ sink }`. The old forms work until 1.108. Found in the object kay.config.ts exports and in the options of `pages()` and `testSite()` with their `config`. The fix renames and moves the keys; an `onListen` or `onError` already written, a comment in the way or an `observe` that is no literal is reported with no fix. |
32
32
  | `deprecated-hook-context` | warn | deprecated | `ctx` read off the event of an action's `beforeRun`, `onSuccess` and `onError`, `context` since 1.105: every hook event carries one `context`, an action's being its own context beside `ip`, `userAgent` and `userId`. The old field works until 1.108. Found in the hooks written in `actions` of kay.config.ts and in the options of an `action()` call imported from `kay`, as `{ ctx }` in the parameters or `event.ctx`. The fix writes `context: ctx` or `context`; a name given a default is reported with no fix, a hook passed by name is not found. |
@@ -37,7 +37,7 @@ The lints of the `deprecated` group that came in 1.105, each reported until 1.10
37
37
  | `deprecated-env-files` | warn | deprecated | `env: { compose, example }` in kay.config.ts, `envFiles` since 1.105: the key names the compose and example files the declared variables are compared with (or `false` for no comparison), where `env` read as the variables themselves. It works until 1.108. The fix renames the key, unless an `envFiles` is written too. |
38
38
  | `deprecated-context-import` | warn | deprecated | `defineContext` imported from `kay/library`, `kay/server` since 1.105, where `defineEnv` and the other helpers an app imports live. `kay/library` keeps it until 1.108. The fix changes the import's source, or moves the specifier to a new import when others share the line. |
39
39
  | `deprecated-rate-enforce` | warn | deprecated | `enforce(ctx)` on what `rateLimit()` returns, `check(ctx)` since 1.105: `limiter().enforce(key)` counts under a key and refuses nothing, so one name held two jobs, and `check` is the guard's call that refuses with a 429. `count(from)` now gives the window, `{ count, resetAt, wait }`, beside `hit`. The old name works until 1.108. Found on a name bound once to a call of `rateLimit` imported from `kay/server`, in the TypeScript files and `.kay` files of the project, as `kay check` reads no types: a limit reached through a property, a parameter or another file is not found. The fix renames the method. |
40
- | `deprecated-deny-call` | warn | deprecated | `deny(status, 'message', data)` of a guard, a page, an action and an endpoint, `deny(status, { message, errors, data })` since 1.105: a refusal takes one object in every place, as `refuse(status, { message, errors, data })` does, so `errors` puts a message on a field and the text is no longer an argument beside the data. An action answers `deny(status, { data, errors })` as `ctx.fail`: the page again, or an `ActionError`. The text form works until 1.108. Found on a call of `deny`, bare or read off a name, with a literal status from 400 to 599 and a text second argument, in the TypeScript files and `.kay` files of the project. The fix writes the object, unless a comment sits between the arguments or a `data` is given, which an action answers as a failure, not plain text. |
40
+ | `deprecated-deny-call` | warn | deprecated | `deny(status, 'message', data)` of a guard, a page, an action and an endpoint, `deny(status, { message, errors, data })` since 1.105: a refusal takes one object in every place, as `refuse(status, { message, errors, data })` does, so `errors` puts a message on a field and the text is no longer an argument beside the data. An action answers `deny(status, { message, data, errors })` as `ctx.fail` did, the page again or an `ActionError`, so its text form, which stopped with plain text, becomes the form's message after the fix. The text form works until 1.108. Found on a call of `deny`, bare or read off a name, with a literal status from 400 to 599 and a text second argument, in the TypeScript files and `.kay` files of the project. The fix writes the object, unless a comment sits between the arguments or a `data` is given, which an action answers as a failure, not plain text. |
41
41
  | `deprecated-ctx-fail` | warn | deprecated | `ctx.fail(status, data, errors)` of an action, `ctx.deny(status, { data, errors })` since 1.105: an action refuses as a guard and a page do, with one call and one shape, and `deny` throws, so a statement ends the handler as well and `unreturned-fail` has nothing left to report. A text `data` is the `message`: `ctx.fail(409, 'Taken')` is `ctx.deny(409, { message: 'Taken' })`, and `failed()?.data` no longer holds it. `ctx.fail` works until 1.108. Found on `ctx.fail` of an action handler's `ctx`, in the TypeScript files and `.kay` files of the project. The fix is made where the call is returned (`return ctx.fail(...)`, a branch of a conditional or an arrow's body), since a call that was not returned did nothing and `deny` would now stop; the others are reported with no fix. |
42
42
  | `deprecated-refuse-call` | warn | deprecated | `refuse(message, { status, errors, data })`, `refuse(status, { message, errors, data })` since 1.105: the status leads and the rest is the one object `ctx.deny` takes. The old form works until 1.108. Found on a call of `refuse` imported from `kay` or `kay/library` whose first argument is a text, in the TypeScript files and `.kay` files of the project. The fix writes the status (the 403 or 422 the old call chose, when `errors` names fields written in the call) and the object; options that are not an object written in the call, or an `errors` that is not, are reported with no fix. |
43
43
  | `deprecated-format-duration` | warn | deprecated | `formatDuration(ms)` with a bare number, a `Duration` since 1.105: kay's durations carry their unit everywhere, `formatDuration('125m')`, and `formatBytes` takes a `ByteSize` the same way (`formatBytes('1.5kb')`), which also still takes a number of bytes. The old form works until 1.108. Found on a call imported from `kay/i18n` whose argument is a number written as a literal or as arithmetic of literals, in the TypeScript files and `.kay` files of the project; a number held in a variable is a type error in the editor and `kay check` reads no types here. The fix writes the value in milliseconds, `'7500000ms'`. |
@@ -12,12 +12,12 @@ The lints of the `deprecated` group, each the old form a minor replaced, reporte
12
12
 
13
13
  | Lint | Default | Group | Reports |
14
14
  | --- | --- | --- | --- |
15
+ | `deprecated-action-options` | warn | deprecated | The arguments of `action` before 1.107, `action(schema, handler, options)` and `action(handler, options)`: the options come first, with the input in them, as an API route's do, `action({ input: schema, ...options }, handler)` and `action(options, handler)`. `input` is a plain record of fields or any schema. The old forms work until 2.0. Found on the `action` a file imports from `kay`, in the TypeScript files and the fences of `.kay` files; the fix moves the arguments and keeps their text. |
16
+ | `deprecated-schema-builders` | warn | deprecated | The PascalCase builders of `s` before 1.106, which kay's own lowercase builders replace, each taking the same field options (`optional`, `default`, `error`, `label`, `description`, `example`) and short names for the rest: `s.String` is `s.string` (`min`, `max`), `s.Integer` `s.int`, `s.Number` and `s.Numeric` `s.number`, `s.Boolean` and `s.BooleanString` `s.boolean`, `s.Array` `s.list`, `s.UnionEnum` and `s.UnionKeys` `s.enum`, and `s.Date`, `s.Literal`, `s.Union`, `s.Object`, `s.File`, `s.Files`, `s.Secret` and `s.Public` their lowercase names; `s.Optional(field)` is `optional: true` in the options of the field; an `s.Object({ ... })` that is the schema of an `action` or a `defineEnv` is the record of fields alone; and a file size written `'2m'` is `'2mb'`. The old names work until 2.0. Found on the `s` a file imports from `kay`, in the TypeScript files and the fences of `.kay` files. The fix renames the builder and the options that changed; an `s.Optional` around anything but one of these builders, such as a helper of `kay/content`, is left as it is. A lowercase `s.object` refuses a key its shape lacks where kay reads the schema itself (an action's input, an API route's body, `defineEnv`, collection frontmatter), where `s.Object` let it by: write `{ extra: 'strip' }` where the old way is wanted. A query, the headers and the cookies of a request carry keys no schema names, so their unknown keys are dropped whatever the schema says. |
15
17
  | `deprecated-uncaught-await` | warn | deprecated | A `// kay-allow uncaught-await` comment or a `lints: { 'uncaught-await': ... }` entry of kay.config.ts, since 1.105: the `uncaught-await` lint is gone, as an `await` with no `catch` renders the `catch` of the `try` around it, else an alert (`data-kay-await-failed`, worded by the `kay.await.failed` message) in its place, the rejection reported either way. The fix removes the comment, or the name from a list of lints, or the config entry. |
16
- | `deprecated-script-fence` | warn | deprecated | `--- script` as the first fence of a file, since 1.102: `---`, the same fence, so a file has one spelling of it. `--- script` stays for a script that follows a `--- server`, `--- module` or `--- style` fence, where a bare `---` would close that fence. The old form works until 1.105. The fix drops the word, keeping the type parameters of `--- script <T>`. |
17
- | `deprecated-schema-type` | warn | deprecated | `TSchema` imported from `kay/library`, `Schema` since 1.103: kay's own name for what `s` builds and every schema option takes, so a signature of the app does not name TypeBox, whose type follows the Elysia kay is built on. The old name works until 1.106. Found on an import from `kay/library` in the TypeScript files and `.kay` files of the project. The fix renames the import and each use of it; a file that already has a `Schema` of its own is reported with no fix, and one that imports it aliased with only the import renamed. |
18
- | `deprecated-package-names` | warn | deprecated | A package of kay under the `@kaynooo` scope, `@kayjs` since 1.104: `@kaynooo/kayjs` is `@kayjs/kay`, and `@kaynooo/kayjs-ui`, `-auth`, `-mail`, `-cms` and `-ai` are `@kayjs/ui`, `@kayjs/auth`, `@kayjs/mail`, `@kayjs/cms` and `@kayjs/ai`. The old names stop at 1.103, which stays installable, so an app on them installs and checks as before until it moves; this lint goes in 1.107. Found in the imports, config keys and stylesheet imports of the project's TypeScript, `.kay` and CSS files, and in its package.json and tsconfig files, never in a comment or a sentence of a string that names a package. The fix writes the new name, raising a package.json range below 1.104 to it, and `kay check` loads a `kay.config.ts` that still imports an old name no longer installed as if renamed, so an app that renamed `package.json` by hand can run `kay check --fix`; a package.json that lists the new name already is reported with a fix that is not safe, and `kay upgrade` does the whole move, package.json and install included. |
18
+ | `deprecated-package-names` | warn | deprecated | A package of kay under the `@kaynooo` scope, `@kayjs` since 1.104: `@kaynooo/kayjs` is `@kayjs/kay`, and `@kaynooo/kayjs-ui`, `-auth`, `-mail`, `-cms` and `-ai` are `@kayjs/ui`, `@kayjs/auth`, `@kayjs/mail`, `@kayjs/cms` and `@kayjs/ai`. The old names stop at 1.103, which stays installable, so an app on them installs and checks as before until it moves; this lint goes in 1.107. Found where a name is an `import` or `export ... from` specifier, a `require()`, `import()` or `mock.module()` argument or a config key (a quoted name keyed to anything but a package name or a version, as `librarySettings`) of the project's TypeScript and `.kay` files, in the `@import` and `@plugin` paths of its CSS, and in its package.json and tsconfig files; a name in a comment or any other string, as data a tool reads or a table of renames, is left alone. The fix writes the new name, raising a package.json range below 1.104 to it, and `kay check` loads a `kay.config.ts` that still imports an old name no longer installed as if renamed, so an app that renamed `package.json` by hand can run `kay check --fix`; a package.json that lists the new name already is reported with a fix that is not safe, and `kay upgrade` does the whole move, package.json and install included. |
19
19
  | `deprecated-children-prop` | warn | deprecated | `children?: Snippet` in a props type beside a bare `slot`, since 1.105: the template types the children, so a component declares none. `children: Snippet` still requires them. The old declaration works until 1.108. The fix removes the member. |
20
- | `deprecated-link-flags` | warn | deprecated | `data-keep-scroll`, `data-no-transition` and `data-no-prefetch`, since 1.105 `data-scroll="keep"`, `data-transition="false"` and `data-prefetch="false"`, named as the options of `navigate()`. The old names work until 1.108. The fix writes the new attribute; a dynamic `data-no-transition` or `data-no-prefetch` has none. |
20
+ | `deprecated-link-flags` | warn | deprecated | `data-keep-scroll`, `data-no-transition` and `data-no-prefetch`, since 1.105 `data-scroll="keep"`, `data-transition="false"` and `data-prefetch="false"`, named as the options of `navigate()`. The old names work until 1.108. The fix writes the new attribute; a dynamic `data-no-transition` or `data-no-prefetch` has none. The app's test files (`*.test.*`, `*.spec.*`) are checked too: a selector `[data-keep-scroll]` is written `[data-scroll=keep]` by the fix, an attribute read by name (`getAttribute('data-keep-scroll')`) has a fix that is not safe, a read of `dataset.keepScroll` (and `noTransition`, `noPrefetch`) has one too, and a write of it and any other string naming an old flag have none. |
21
21
  | `deprecated-parts-class` | warn | deprecated | The parts of a component given as its `class`, `parts` since 1.105: `Card(class={{ head: 'p-6' }})` is `Card(parts={{ head: 'p-6' }})`. The old form, an object literal of strings by part name, works until 1.108, the compiler handing it on as `parts`. The fix writes `parts` for `class`. |
22
22
 
23
23
  The rows of the lints that came in 1.105 are in [Deprecated lints of 1.105](deprecated-lints-1-105.md).
package/llms/dev-tool.md CHANGED
@@ -26,8 +26,8 @@ The Request tab shows the route matched, the layouts, the params, the locale, th
26
26
  - When a page's loads together take longer than `ops.observe.loadBudget` (`'300ms'`, `false` for none), the Request tab counts one warning, says so under the server's time naming the slowest load, and the page's console and `kay dev`'s log carry the same message. A layout whose load outlasts the page's own loads and the budget adds a second warning naming the layout file and both times, with the fix: start it unawaited and stream it with an `await` block, or cache it.
27
27
  - Its Network tab lists what the page fetched, read off Resource Timing, by navigation, newest first: the load, then each page swap, the last 5 kept, each request with its kind (document, page for a swap or prefetch, action, server island, fetch, script, stylesheet, image, font), status, size or `from the cache`, time and start after the navigation, an error status counted on the tab for the page shown; the tool's own requests, the live reload's and `/_kay/dev/` are left out, a hover prefetch is listed under its page, and another site's answer shows no status or size without `Timing-Allow-Origin`;
28
28
  - Its Head tab shows the page's head as it is now: the search result it makes, its title and description with their length and the description's limit of 160 characters, the canonical link, hreflang alternates, the robots tag, whether the sitemap lists the page, the og and twitter tags with a preview of the social card image, and each JSON-LD block parsed or with its parse error; what `kay check` would flag in a built page's head shows as a problem, and with `seo` set but no origin it says there is no canonical link or sitemap; it reads again after each page swap;
29
- - Its Routes tab lists every page, endpoint and API route the server serves, each locale's copy of a page on its own line, filtered by path or file, a path no request fills in linking to itself, fetched again after each restart; a section of what kay serves itself lists the sitemap, robots.txt, feeds, manifest, favicons, service worker, health check and a library's dev pages such as kayjs-mail's `/_kay/mail`, only those the running server serves, so a path an app file took over shows as the app's, and with `seo` set but no origin it says why there is no sitemap or robots.txt; under it a "kay's plumbing" group lists kay's own endpoints the app serves, one line each with its purpose and a `docs` link (the build files, `/_kay/assets/*` and `/_kay/images/*` once the build has some, `/_kay/images`, `/_kay/card`, `/_kay/files/*`, `POST /_kay/action/<file>/<name>` and `GET /_kay/fields/<file>/<name>` once an action exists, `/_kay/live`, `/_kay/error`, `/_kay/csp` with `security.reports`, `/_kay/preview` and `/_kay/draft` with `preview`, `/_kay/env.js` with an `s.Public` field, `/_kay/search.json` and `/_kay/search/*` with a search index, the `analytics()` and `vitals()` routes, `/_kay/THIRD-PARTY-LICENSES.txt`), the filter box matching their path and purpose, a GET path with nothing to fill in linking to itself under `base`;
30
- - Its Env tab lists each public variable (`s.Public`) sent to the browser, read from `/_kay/env.js` with its value, flags one whose value looks like a secret (a URL with a password, a well-known token prefix, a hexadecimal or random string), only noting a name ending in `_KEY`, and says when the app sends no public env; the server's own env is never shown;
29
+ - Its Routes tab lists every page, endpoint and API route the server serves, each locale's copy of a page on its own line, filtered by path or file, a path no request fills in linking to itself, fetched again after each restart; a section of what kay serves itself lists the sitemap, robots.txt, feeds, manifest, favicons, service worker, health check and a library's dev pages such as kayjs-mail's `/_kay/mail`, only those the running server serves, so a path an app file took over shows as the app's, and with `seo` set but no origin it says why there is no sitemap or robots.txt; under it a "kay's plumbing" group lists kay's own endpoints the app serves, one line each with its purpose and a `docs` link (the build files, `/_kay/assets/*` and `/_kay/images/*` once the build has some, `/_kay/images`, `/_kay/card`, `/_kay/files/*`, `POST /_kay/action/<file>/<name>` and `GET /_kay/fields/<file>/<name>` once an action exists, `/_kay/live`, `/_kay/error`, `/_kay/csp` with `security.reports`, `/_kay/preview` and `/_kay/draft` with `preview`, `/_kay/env.js` with an `s.public` field, `/_kay/search.json` and `/_kay/search/*` with a search index, the `analytics()` and `vitals()` routes, `/_kay/THIRD-PARTY-LICENSES.txt`), the filter box matching their path and purpose, a GET path with nothing to fill in linking to itself under `base`;
30
+ - Its Env tab lists each public variable (`s.public`) sent to the browser, read from `/_kay/env.js` with its value, flags one whose value looks like a secret (a URL with a password, a well-known token prefix, a hexadecimal or random string), only noting a name ending in `_KEY`, and says when the app sends no public env; the server's own env is never shown;
31
31
  - Its Images tab lists each image of the page with the variant it got (a ladder width, a crop, the share card, or not resized by kay), the format and bytes the server answers with (a HEAD request, only for a loaded image of kay's image route or built variants, with a timeout; any other image is not asked), the size served against the size drawn (flagged past 4 times the pixels shown, never for an SVG, whose address ends in `.svg` or whose fetch answered `image/svg+xml`, as Resource Timing keeps it), the largest contentful paint, and an image without `width` and `height` or lazy-loaded while in view; copies of one image drawn alike share a row with their count, and hovering or focusing a row outlines each, and the list follows the page as images change;
32
32
  - Its Performance tab shows the page load's LCP (with its element), CLS and INP as the browser reports them while the page is used, each rated against its good limit (2.5 s, 0.1, 200 ms) and naming the page they were measured on once a swap moved away from it, and the page's footprint measured in the browser (the DOM elements without the tool's own, the requests of the load, the EcoIndex grade and score and the grams of CO2e per view, worked out by the server with the models `kay build` uses, [Build](build-and-start.md#build-and-start-commands)), then the HTML (the document the browser holds), CSS and JS gzipped and the images, fonts and other files as the browser says they came, measured again after a swap, with the entry, the islands' chunks and the other chunks apart (a page a swap fetched and an action are not counted, another site's file counts as a request of unknown weight); the sizes are dev sizes, not minified, larger than `kay build` makes them, and a "Last kay build" block gives the route's scripts and stylesheets from the report `.kay` keeps (its age, `~` for an estimate, nothing before a first build);
33
33
  - Its Not found tab lists the paths a production run recorded visitors found nothing at (the database of the app's `store`, SQLite or Postgres, else `data/not-found.sqlite`: the log `kay not-found` reads), most hit first, with the hosts they came from and the suggested target, those a `redirects` entry answers left out; a field holds the target (the suggestion, or one typed) and Add redirect writes it into `kay.config.ts` as `kay not-found --redirect` does, then `kay dev` restarts; `kay dev` records nothing itself, so the tab leaves the list while the file, or the Postgres table `kay_missing`, is absent (it creates none).
@@ -12,31 +12,31 @@ Reading the environment typed, and letting an island read a variable. Sessions,
12
12
  import { s } from 'kay'
13
13
  import { defineEnv } from 'kay/server'
14
14
 
15
- export const env = defineEnv(s.Object({
16
- DATABASE_URL: s.String(),
17
- PORT: s.Integer({ default: 3000 }),
18
- DEBUG: s.Optional(s.Boolean()),
19
- }))
15
+ export const env = defineEnv({
16
+ DATABASE_URL: s.string(),
17
+ PORT: s.int({ default: 3000 }),
18
+ DEBUG: s.boolean({ optional: true }),
19
+ })
20
20
  ```
21
21
 
22
22
  `defineEnv(schema, source)` reads `source` instead of `process.env`, for a module building its own env. A test gives a variable of `env` another value with `overrideEnv` from `kay/test` ([Testing](testing.md)).
23
23
 
24
24
  ### Let an island read a variable
25
25
 
26
- Mark a field of `defineEnv` `s.Public` to let an island read it, such as a map key or an analytics id; it needs no key in kay.config.ts:
26
+ Mark a field of `defineEnv` `s.public` to let an island read it, such as a map key or an analytics id; it needs no key in kay.config.ts:
27
27
 
28
28
  ```ts
29
29
  import { s } from 'kay'
30
30
  import { defineEnv } from 'kay/server'
31
31
 
32
- export const env = defineEnv(s.Object({
33
- DATABASE_URL: s.String(),
34
- MAP_KEY: s.Public(s.String()),
35
- ANALYTICS_ID: s.Public(s.Optional(s.String())),
36
- }))
32
+ export const env = defineEnv({
33
+ DATABASE_URL: s.string(),
34
+ MAP_KEY: s.public(s.string()),
35
+ ANALYTICS_ID: s.public(s.string({ optional: true })),
36
+ })
37
37
  ```
38
38
 
39
- A component reads it as `publicEnv` from `kay`, typed from the `s.Public` fields of the modules under `src` only (one outside it, such as `common/env.ts`, is not found: `kay check` reports it as `public-env-outside-src`):
39
+ A component reads it as `publicEnv` from `kay`, typed from the `s.public` fields of the modules under `src` only (one outside it, such as `common/env.ts`, is not found: `kay check` reports it as `public-env-outside-src`):
40
40
 
41
41
  ```kay
42
42
  ---
@@ -52,7 +52,7 @@ button(onClick={() => console.log(publicEnv.MAP_KEY)}) Log the map key
52
52
  - One secret, `KAY_SECRET` or `secret` in kay.config.ts (which wins), at least 32 random characters: `bun -e "console.log(crypto.randomUUID() + crypto.randomUUID())"`. An empty one counts as none; a short one stops the boot.
53
53
  - It serves everything kay seals or signs, each under a key derived for its use, so none passes for another: `session()`'s cookie (no `secret` option), kayjs-auth's keys (`deriveSecret`), form stamps (`minTime`), links to private files, the flash cookie, rate-limit keys and live proofs, and `preview`'s links and cookie (no `preview.secret`). An option giving its own secret keeps it apart.
54
54
  - Commas in `KAY_SECRET` (or a list in `secret`) rotate it: the first seals and signs, every one opens and verifies: sessions, kayjs-auth's sealed data, stamps, private-file links, the flash cookie and preview links, so a rotation breaks none of them. Keep the old secret in the list while data sealed with it exists, a session cookie or a second factor.
55
- - Development and tests (`NODE_ENV` `development` or `test`) derive one for the checkout, as `s.Secret()` does, so a fresh clone runs with nothing set. Production without any refuses `session()` and `preview`, naming `KAY_SECRET`, and refuses to start a server at all: it would sign with a key of the process, which a restart changes and other replicas do not share. `KAY_EPHEMERAL_SECRET=1` starts one anyway, for a single throwaway server, which warns once. A secret of fewer than 10 different characters warns in production.
55
+ - Development and tests (`NODE_ENV` `development` or `test`) derive one for the checkout, as `s.secret()` does, so a fresh clone runs with nothing set. Production without any refuses `session()` and `preview`, naming `KAY_SECRET`, and refuses to start a server at all: it would sign with a key of the process, which a restart changes and other replicas do not share. `KAY_EPHEMERAL_SECRET=1` starts one anyway, for a single throwaway server, which warns once. A secret of fewer than 10 different characters warns in production.
56
56
  - `session()` reads it on first use, or as the server starts, so a `session()` made as a module loads takes the config's `secret` and its rotation list as well as `KAY_SECRET`; one given `session({ secret })` keeps its own.
57
57
  - An app signs its own links and values with `signed` from `kay/server`, keyed on this secret, so no key file of its own: `signed.sign(use, value, { ttl })` gives `<expiry>.<signature>` (URL-safe, `ttl` a duration, `'1h'` when left out) and `signed.verify(use, value, token)` is `true` only for that `use`, that `value`, a token not expired and signed under any key of the list, `false` for anything else, a missing or malformed token too, and never throws. `use` keeps one feature's signatures from passing for another's, and for kay's own (private-file links, stamps). A script or job that started no server reads `KAY_SECRET` (the checkout's in development and tests); a production process with none signs under a key of its own, as stamps do. `value` and `use` are strings (anything else throws) and `ttl` is at most `'52w'.
58
58
 
@@ -61,23 +61,23 @@ button(onClick={() => console.log(publicEnv.MAP_KEY)}) Log the map key
61
61
  - `defineEnv` from `kay/server` reads `process.env` once against a schema, as the server boots, and gives it back typed.
62
62
  - Names follow one rule. kay's own start `KAY_` (`KAY_SECRET`, `KAY_PROXY_KEY`, `KAY_MCP_KEY`, `KAY_METRICS_TOKEN`) apart from the ones a host sets for the app, `PORT`, `HOST`, `SITE_URL` and `SITE_BASE`, and the web push keys `VAPID_PUBLIC_KEY` and `VAPID_PRIVATE_KEY` as the standard names them. Each library has one prefix: `AUTH_` (kayjs-auth), `MAIL_`, `AI_`, `CMS_`. A vendor's own name stays as the vendor spells it: `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `<PROVIDER>_CLIENT_ID` and `<PROVIDER>_CLIENT_SECRET`. `MAIL_INSECURE` and `AI_INSECURE` both mean `true` lets a secret go over a connection a network you trust carries in clear. The renamed ones, `KAYJS_AUTH_DATABASE_URL` (now `AUTH_DATABASE_URL`) and `MAIL_INBOUND_SECRET` (now `MAIL_EVENTS_INBOUND`), are no longer read.
63
63
  - A number or boolean is read from its text as a form field is, a variable left out takes its `default`, and any missing or refused stops the boot with an error naming each one.
64
- - An empty variable, `PORT=` or `PORT=""` in a `.env` file, counts as left out: it takes the default, satisfies `s.Optional` and fails a required one, rather than an empty string reaching the schema.
65
- - So an empty string is not a value a variable can carry: a setting that means something when blank is `s.Optional`, read as `undefined`.
64
+ - An empty variable, `PORT=` or `PORT=""` in a `.env` file, counts as left out: it takes the default, satisfies `optional: true` and fails a required one, rather than an empty string reaching the schema.
65
+ - So an empty string is not a value a variable can carry: a setting that means something when blank is `optional: true`, read as `undefined`.
66
66
  - A value of spaces is kept as it is, since only quoting makes one.
67
67
  - `kay build` runs without the server's environment: there a missing or refused variable leaves the module declaring it alone, and reading it throws naming it, which fails only a prerendered page that reads it.
68
68
  - The object holds the declared names only.
69
- - A string field also reads `<NAME>_FILE`, the path of a file holding the value, as a compose or swarm secret hands it: `API_KEY_FILE=/run/secrets/api_key` fills `API_KEY: s.String()`. The file is read once at boot and trimmed (surrounding whitespace goes), and the value is checked against the schema as any other. Both `API_KEY` and `API_KEY_FILE` set stops the boot naming both, and so does a file that is missing, unreadable or empty, naming the variable and the path, never the content; an `s.Optional` field (not `requiredInProduction`) is left unset instead, with one warning naming the file, so its default applies. `s.Public` fields, numbers and booleans have no file form, and neither has a name whose `_FILE` variable the schema declares itself. `kay env` says so under its listing, and `kay env --compose` and `kay check` count `API_KEY_FILE` in a compose file or the example as setting `API_KEY`. A build without the server's environment leaves a file it cannot read as a missing variable.
70
- - `requiredInProduction: true` on a field makes it required under `NODE_ENV=production` only: there it is refused at boot when missing, its `default` dropped and `s.Optional` no longer applying; in development and tests it takes its `default`, stays `undefined` under `s.Optional`, or is `''` when a `s.String` has neither, so `DISCORD_CLIENT_ID: s.String({ requiredInProduction: true })` types as `string` and needs no placeholder in the app and no second list of production keys; `s.Optional(s.String({ requiredInProduction: true }))` keeps `string | undefined`.
71
- - `s.Secret()` is a string of at least 32 characters required in production, which development and tests read as a derived value, so sessions survive a restart and nothing is committed: `DOWNLOAD_KEY: s.Secret()`; a value set in the environment wins, and `kay env` lists it as a secret required in production (`secret: true` in JSON). `kay new` uses it. Only under `NODE_ENV` `development` or `test` (`kay dev` and `bun test` set them) is it derived, from the path, the name and a random seed kept in `.kay/dev-secret` (git-ignored, 0600, written on first use and again when empty or cut short, read once per process; under `test` the seed is only read, and one of the process stands in when there is none, exported as `KAY_DEV_SEED` so a subprocess spawned with the inherited environment derives the same secret, one given an environment of its own another; `bun test` writes nothing to `.kay` for a secret and needs no `KAY_SECRET`); under any other `NODE_ENV`, or none, a missing one refuses the boot as a plain `s.String({ minLength: 32 })` does, and a `.kay` that cannot be written is an error naming it and the variable to set; `testSite()` building islands into a `.kay` that cannot be written fails the same way, naming the folder and `islands: false`.
69
+ - A string field also reads `<NAME>_FILE`, the path of a file holding the value, as a compose or swarm secret hands it: `API_KEY_FILE=/run/secrets/api_key` fills `API_KEY: s.string()`. The file is read once at boot and trimmed (surrounding whitespace goes), and the value is checked against the schema as any other. Both `API_KEY` and `API_KEY_FILE` set stops the boot naming both, and so does a file that is missing, unreadable or empty, naming the variable and the path, never the content; an optional field (not `requiredInProduction`) is left unset instead, with one warning naming the file, so its default applies. `s.public` fields, numbers and booleans have no file form, and neither has a name whose `_FILE` variable the schema declares itself. `kay env` says so under its listing, and `kay env --compose` and `kay check` count `API_KEY_FILE` in a compose file or the example as setting `API_KEY`. A build without the server's environment leaves a file it cannot read as a missing variable.
70
+ - `requiredInProduction: true` on a field makes it required under `NODE_ENV=production` only: there it is refused at boot when missing, its `default` dropped and `optional` no longer applying; in development and tests it takes its `default`, stays `undefined` when optional, or is `''` when a `s.string` has neither, so `DISCORD_CLIENT_ID: s.string({ requiredInProduction: true })` types as `string` and needs no placeholder in the app and no second list of production keys; `s.string({ optional: true, requiredInProduction: true })` keeps `string | undefined`.
71
+ - `s.secret()` is a string of at least 32 characters required in production, which development and tests read as a derived value, so sessions survive a restart and nothing is committed: `DOWNLOAD_KEY: s.secret()`; a value set in the environment wins, and `kay env` lists it as a secret required in production (`secret: true` in JSON). `kay new` uses it. Only under `NODE_ENV` `development` or `test` (`kay dev` and `bun test` set them) is it derived, from the path, the name and a random seed kept in `.kay/dev-secret` (git-ignored, 0600, written on first use and again when empty or cut short, read once per process; under `test` the seed is only read, and one of the process stands in when there is none, exported as `KAY_DEV_SEED` so a subprocess spawned with the inherited environment derives the same secret, one given an environment of its own another; `bun test` writes nothing to `.kay` for a secret and needs no `KAY_SECRET`); under any other `NODE_ENV`, or none, a missing one refuses the boot as a plain `s.string({ minLength: 32 })` does, and a `.kay` that cannot be written is an error naming it and the variable to set; `testSite()` building islands into a `.kay` that cannot be written fails the same way, naming the folder and `islands: false`.
72
72
  - `NODE_ENV=production kay build` counts as production too: a prerendered page reading a flagged variable needs it set for the build, or reads it where the server runs.
73
- - `kay env [dir] [--compose <file>]... [--example <file>] [--write] [--format text|json]` lists every variable the project declares, without its environment and without running the server entry, whose own `defineEnv` calls it leaves out: the `defineEnv` schemas in the modules under `src` (imported, so their top-level code runs), the `s.Public` fields among them, the `env` schema of each extension in kay.config.ts (a library's, such as kayjs-mail's `MAIL_*` variables or kayjs-ai's provider keys and `AI_MODEL`, with no wiring), and kay's own `PORT`, `HOST`, `SITE_URL` and `KAY_SECRET`, and `KAY_PROXY_KEY` (required in production) and `KAY_PROXY_KEY_FILE` while `proxy.key` is set, and `KAY_MCP_KEY` (required in production) and `KAY_MCP_KEY_FILE` while `mcp.token` is `true`; a secret given as `{ env: 'NAME' }` lists that variable instead, and a value or a `{ file }` none. A schema built inside a function is not seen. A library's mailer built in one of those modules, such as `mailer()` from kayjs-mail, is listed once under that module, as its options set it up (`mailer({ optional: true })` does not make `MAIL_URL` required); the module under `src` an extension with an `env` names as its `serverModule` is imported too, whether or not it says `defineEnv`, and one that does not load leaves the extension's own list. Each has its `name`, `source`, `type`, `required` (`'always'`, `'production'` or `false`), its `default` and `description` when it has them; a module that fails to load is under `unread`.
73
+ - `kay env [dir] [--compose <file>]... [--example <file>] [--write] [--format text|json]` lists every variable the project declares, without its environment and without running the server entry, whose own `defineEnv` calls it leaves out: the `defineEnv` schemas in the modules under `src` (imported, so their top-level code runs), the `s.public` fields among them, the `env` schema of each extension in kay.config.ts (a library's, such as kayjs-mail's `MAIL_*` variables or kayjs-ai's provider keys and `AI_MODEL`, with no wiring), and kay's own `PORT`, `HOST`, `SITE_URL` and `KAY_SECRET`, and `KAY_PROXY_KEY` (required in production) and `KAY_PROXY_KEY_FILE` while `proxy.key` is set, and `KAY_MCP_KEY` (required in production) and `KAY_MCP_KEY_FILE` while `mcp.token` is `true`; a secret given as `{ env: 'NAME' }` lists that variable instead, and a value or a `{ file }` none. A schema built inside a function is not seen. A library's mailer built in one of those modules, such as `mailer()` from kayjs-mail, is listed once under that module, as its options set it up (`mailer({ optional: true })` does not make `MAIL_URL` required); the module under `src` an extension with an `env` names as its `serverModule` is imported too, whether or not it says `defineEnv`, and one that does not load leaves the extension's own list. Each has its `name`, `source`, `type`, `required` (`'always'`, `'production'` or `false`), its `default` and `description` when it has them; a module that fails to load is under `unread`.
74
74
  - `envFiles: { compose: 'compose.prod.yaml', example: '.env.example' }` in kay.config.ts (`compose` takes several files), or `kay env --compose <file>... --example <file>`, compares what the project declares with those files, and `kay check` runs it with no flag. With neither, both compare the project's root `compose*.yaml` and `docker-compose*.yaml` files (a name with `dev`, `development`, `test`, `local` or `override` in it is left out, as it holds the services around the app) and its `.env.example`, those that exist; `env: false` turns the comparison off. A line of `.env.example` no schema declares is an error unless compose uses it: a service sets it, a value interpolates it as `${HF_TOKEN}`, or a top-level secret or config reads it as `environment: HF_TOKEN`.
75
75
  - `kay env --write` appends every declared variable the example does not mention (kay's and the libraries' included, an optional one commented out beside its default), creating the file or keeping what it holds, and writes `--example`'s file, else the config's, else `.env.example`: a variable production needs (`required` not `false`) that no compose service sets, in `environment` (a map or a list, `${VAR:-x}` included) or an `env_file` (one the checkout leaves out, such as a gitignored `.env`, sets what the `.env.example` beside it lists, an empty line included, as the deploy fills that file from it), is an error, as is `KAY_PROXY_KEY` when `proxy.key` is set and no service sets it or `KAY_PROXY_KEY_FILE` (and `KAY_MCP_KEY` for `mcp: { token: true }`, with `KAY_MCP_KEY_FILE`); so is one the example does not list unless a compose service gives it a literal, and one the example lists that no schema declares, no service sets, no `${VAR}` of the compose file reads (`POSTGRES_PASSWORD`) and neither kay.config.ts nor a module it imports by relative path reads as `process.env.X` (`COMPOSE_*` and `DOCKER_*` apart, which Docker Compose reads). A `process.env.X` or `Bun.env.X` read in `src` outside tests (`NODE_ENV` apart) that nothing declares is a warning, which `kay check --fix` can declare for you ([Check](check-and-tools.md)). A file `bun build` names in a `package.json` script (a standalone binary's entry, in `src` or anywhere else, `--cwd` honoured) with the files it imports by relative path (`./x.js` for `x.ts` and a `.kay` file included), the content config (`src/content.config.ts`, or the config's `contentConfig`), and a file with a `// kay-env: raw` line are not checked, nor rewritten by `--fix`: they read the environment themselves, so a module the entry shares with the app is exempt for the whole app. `kay env` prints the findings and exits 1 on an error; `--format json` adds `findings`, as `kay check` prints its problems. A file named and missing, or a compose file that is not YAML, is an error; leave a key out to skip its half. `--compose` and `--example` resolve against the project root and, when given, replace the config's `env` wholesale. A module under `src` that does not load is an error and stops nothing being judged undeclared; an empty value (`FOO=`, `FOO: ''`) counts as unset, as `defineEnv` reads it. Raw reads are found in one-line `process.env.X`, `process.env['X']`, `Bun.env.X` and `const { X } = process.env`, not in a multi-line destructuring, a computed name or `import.meta.env`.
76
76
  - Server code imports it: a `.ts` module, a server fence, the server entry; an island never sees the server's environment.
77
- - A field wrapped in `s.Public(...)` is one an island may read, such as a map key or an analytics id, which a component reads as `publicEnv` from `kay`, typed from the `s.Public` fields of the `.ts` modules under `src` (found by reading them as text, so the field is written `s.Public(`); `kay env` lists it as `public`.
77
+ - A field wrapped in `s.public(...)` is one an island may read, such as a map key or an analytics id, which a component reads as `publicEnv` from `kay`, typed from the `s.public` fields of the `.ts` modules under `src` (found by reading them as text, so the field is written `s.public(`); `kay env` lists it as `public`.
78
78
  - It is read as `defineEnv` reads the rest, a missing or refused one stopping the boot, and reaches the browser as the module declaring it loads: an island reading `publicEnv` needs a module with `defineEnv` imported by the server.
79
- - The browser gets them from `/_kay/env.js`, which the server answers from its environment and the island entry imports before any island hydrates, so an executable, or a page prerendered at build time, carries the values of the environment it runs in (an executable embeds the `.ts` modules declaring `s.Public`, so it needs no `src` beside it); `kay build --static` writes that file with the build's.
79
+ - The browser gets them from `/_kay/env.js`, which the server answers from its environment and the island entry imports before any island hydrates, so an executable, or a page prerendered at build time, carries the values of the environment it runs in (an executable embeds the `.ts` modules declaring `s.public`, so it needs no `src` beside it); `kay build --static` writes that file with the build's.
80
80
  - The markup a prerendered page rendered holds the build's values, though: an island showing a variable that differs at runtime hydrates with a mismatch, so a page showing one renders per request.
81
- - The server refuses to boot, before any build starts, when an `s.Public` field has a name such as `STRIPE_SECRET`, `DB_PASSWORD`, `PRIVATE_KEY`, `ACCESS_TOKEN`, `API_KEY`, `SIGNING_KEY`, `SENTRY_DSN`, `JWT_SECRET`, `AWS_CREDENTIALS` or `DATABASE_URL`, or whose value is an address with a username and password in it (`postgres://user:pass@host/db`), which every visitor would read; keep those in `defineEnv` without `s.Public`. An `s.Public` field in a `.kay` file is refused too: declare it in a `.ts` module. The values served are those of the `.ts` modules of the app booting, not of another `pages()` app in the same process. A name ending in `_KEY` is refused too unless it says it is for the browser: `MAP_KEY`, `MAPBOX_KEY`, `PUBLISHABLE_KEY`, `PUBLIC_KEY`, `ANALYTICS_KEY`, `SITE_KEY`, `CAPTCHA_KEY`, `TURNSTILE_KEY` and `CLIENT_KEY` pass.
81
+ - The server refuses to boot, before any build starts, when an `s.public` field has a name such as `STRIPE_SECRET`, `DB_PASSWORD`, `PRIVATE_KEY`, `ACCESS_TOKEN`, `API_KEY`, `SIGNING_KEY`, `SENTRY_DSN`, `JWT_SECRET`, `AWS_CREDENTIALS` or `DATABASE_URL`, or whose value is an address with a username and password in it (`postgres://user:pass@host/db`), which every visitor would read; keep those in `defineEnv` without `s.public`. An `s.public` field in a `.kay` file is refused too: declare it in a `.ts` module. The values served are those of the `.ts` modules of the app booting, not of another `pages()` app in the same process. A name ending in `_KEY` is refused too unless it says it is for the browser: `MAP_KEY`, `MAPBOX_KEY`, `PUBLISHABLE_KEY`, `PUBLIC_KEY`, `ANALYTICS_KEY`, `SITE_KEY`, `CAPTCHA_KEY`, `TURNSTILE_KEY` and `CLIENT_KEY` pass.
82
82
  - Only the public variables leave the server, and nothing else of the environment reaches an island: a module reading `process.env` or `defineEnv`'s values fails the browser build.
83
83
  - Reading `publicEnv` when nothing is public throws; a name that is not public is a type error.
package/llms/files.md CHANGED
@@ -16,7 +16,7 @@ import { s, action } from 'kay'
16
16
  import { files } from 'kay/server'
17
17
  import { photos } from '../photos'
18
18
 
19
- export const upload = action(s.Object({ photo: s.File({ type: 'image/jpeg' }) }), async ({ photo }) => {
19
+ export const upload = action({ photo: s.file({ type: 'image/jpeg' }) }, async ({ photo }) => {
20
20
  photos.push(await files.put(photo, { folder: 'photos' }))
21
21
  }, { maxSize: '20mb' })
22
22
  ---
@@ -180,12 +180,12 @@ if upload.progress() !== undefined
180
180
 
181
181
  ### Files posted to an action
182
182
 
183
- - `s.File()` or `s.Files()` in the schema, `input(type="file" name="avatar")` in the form, and the handler gets a `File`, which `files.put` stores.
183
+ - `s.file()` or `s.files()` in the schema, `input(type="file" name="avatar")` in the form, and the handler gets a `File`, which `files.put` stores.
184
184
  - Forms posting to an action are sent as `multipart/form-data` unless they set `enctype`.
185
- - A file input left empty counts as no file, so `s.Optional(s.File())` works.
185
+ - A file input left empty counts as no file, so `s.file({ optional: true })` works.
186
186
  - An island passes a `File` or `Blob` anywhere in its input, nested ones included, and a `Blob` types as a field's `File`: `await upload({ avatar: input.files[0] })`.
187
- - On a top-level field, `s.File({ type: 'image/png' })` checks the file's bytes, not its name or declared type.
187
+ - On a top-level field, `s.file({ type: 'image/png' })` checks the file's bytes, not its name or declared type.
188
188
  - A file it refuses fails like any field, under its name in `errors` with the schema's `error` option when set.
189
189
  - A nested file is checked against the type it declares only.
190
190
  - A post sends 1 MB at most unless the action raises its `maxSize` (see [Protecting actions](action-protection.md)).
191
- - `s.File({ minSize, maxSize })` and `s.Files` take a size as an action's `maxSize` does, `'2mb'`, `'600kb'` or bytes. An action with no `maxSize` of its own takes as many bytes as its sized file fields add up to (a `Files` field counting its `maxItems` files, or ten) plus 64 KB for the other fields, never less than the app's, so the limit is written once on the field; an action's own `maxSize` wins.
191
+ - `s.file({ minSize, maxSize })` and `s.files` take a size as an action's `maxSize` does, `'2mb'`, `'600kb'` or bytes. An action with no `maxSize` of its own takes as many bytes as its sized file fields add up to (a `Files` field counting its `maxItems` files, or ten) plus 64 KB for the other fields, never less than the app's, so the limit is written once on the field; an action's own `maxSize` wins.
@@ -12,6 +12,7 @@
12
12
  | --- | --- | --- | --- |
13
13
  | `invalid-autocomplete` | deny | forms | An `autocomplete` value HTML does not define. |
14
14
  | `unbounded-string` | warn | forms | A string field of an action's schema named like a short value (`name`, `email`, `title`, `subject`, `slug`...) with no `maxLength` of its own, which takes the default bound of 10,000 characters, unless its `enum`, `const` or anchored bounded `pattern` already bounds it. |
15
+ | `schema-without-json-schema` | warn | forms | A Standard Schema validator with no `~standard.jsonSchema` where an action's `input` or an API route's `body`, `query`, `params`, `headers` or `cookie` takes a schema: it validates, but a form shows no constraints, a form or a query is not read as numbers and booleans, and OpenAPI and MCP show an open schema. Found in `.ts` modules and `.kay` fences for a hand-written `~standard` object and for valibot's builders, through a `const` and a relative import. |
15
16
  | `invalid-nesting` | warn | islands | Markup HTML forbids or the parser rewrites: a block in a `p`, `form` in `form`, `tr` in a `table`, a heading in a heading, an `option` outside a `select`, an `li` outside a list, a non-`li` in one. |
16
17
  | `positional-key` | deny | islands | `for todo, i of todos key={i}` whose rows read `todo.id`: keyed by position, a row added before others hands them its state. The fix drops the key. |
17
18
  | `unkeyed-rows` | deny | islands | A keyless `for` in a component or an island (not a page or a layout) over rows with no `id`: a copy is a new row, losing its focus. The offered fix writes `key={i}`; an `id` or a `key={row.slug}` is better. |
@@ -12,7 +12,8 @@
12
12
  - On the server a module outlives the request, so a value a page's, a layout's or an island's script writes to such a signal while the page renders, as `cart = items` seeding it from props, holds for that request only, and everything rendered after it reads it.
13
13
  - A module's `memo` is computed afresh on each read on the server.
14
14
  - `persisted.cookie('theme', 'light')` from `kay` is a signal that keeps its value across pages and visits in a cookie named `theme`, which the server reads too, so a page rendered for the request shows the kept value from the first paint, and answers with `Vary: Cookie`.
15
- - A page `kay build` prerendered renders a `persisted` signal's default, and the island corrects it as it hydrates.
15
+ - A page's `--- server` fence, which loads its data before the render, reads a `persisted.cookie()` signal by calling it: `open()` there is the request's value, decoded and checked against `values` as the render does, the default when the cookie is missing or refused, so the fence needs no `ctx.cookies` and no knowledge of the cookie's encoding. The page then answers with `Vary: Cookie`.
16
+ - A page `kay build` prerendered renders a `persisted` signal's default, in its server fence too, and the island corrects it as it hydrates.
16
17
  - The cookie is named as it is given, so it never reuses the name of a cookie the app sets itself.
17
18
  - `persisted` has one entry per storage, `persisted.cookie()`, `persisted.local()` and `persisted.session()`, each taking the options its storage can use, and a call always names its storage: a bare `persisted(name, value)`, which kept a cookie without saying so, works until 1.108 and `kay upgrade` writes `.cookie` for it (`deprecated-persisted-call`). The `storage` option is gone since 1.105.
18
19
  - A query param is not persisted but `queryParam`, below: `persisted.query(name, value, options)` is `queryParam(name, { default: value, ...options })`, works until 1.108 and `kay upgrade` rewrites it (`deprecated-persisted-query`).
package/llms/islands.md CHANGED
@@ -237,7 +237,7 @@ if !connected()
237
237
  ### Islands
238
238
 
239
239
  - A component is interactive when any element in it has an `on*` handler, a `bind:` (on an element or a component) or a `ref`, or when its script uses a value from `kay`, such as `signal`; the rule is at the top.
240
- - `ActionError`, `ActionRedirectError`, `ApiError`, `apiUrl`, `byteCount`, `composing`, `ctx`, `defer`, `defineUi`, `describeField`, `durationMs`, `escapeHtml`, `formErrors`, `isEmail`, `lengthMs`, `localPath`, `postedChecked`, `postedValue`, `postedValues`, `publicEnv`, `recipe`, `route`, `s`, `sanitizeHtml`, `trustHtml`, `uid`, `withBase` and `withQuery` from `kay` compute the same on both sides and keep a component static; every other value of `kay` needs the browser (state, effects, lifecycle, browser readings, navigation: `navigate`, `refresh`, `call` and `logFrom` among them), and so does `relativeTime` of `kay/i18n`.
240
+ - `ActionError`, `ActionRedirectError`, `ApiError`, `apiUrl`, `byteCount`, `composing`, `ctx`, `defer`, `defineUi`, `describeField`, `durationMs`, `escapeHtml`, `formErrors`, `isEmail`, `lengthMs`, `localPath`, `postedChecked`, `postedValue`, `postedValues`, `publicEnv`, `recipe`, `route`, `s`, `sanitizeHtml`, `trustHtml`, `uid`, `validate`, `withBase` and `withQuery` from `kay` compute the same on both sides and keep a component static; every other value of `kay` needs the browser (state, effects, lifecycle, browser readings, navigation: `navigate`, `refresh`, `call` and `logFrom` among them), and so does `relativeTime` of `kay/i18n`.
241
241
  - A namespace or default import of `kay` or `kay/i18n` (`import * as i18n from 'kay/i18n'`) always makes an island, as the compiler cannot tell which names the component reads through it: import the names (`import { formatDate } from 'kay/i18n'`) to keep a component static that only formats.
242
242
  - An interactive component renders on the server and hydrates in the browser as an island.
243
243
  - Everything else ships no JavaScript, except the small script swapping pages in on a page posting a form to an action, and elsewhere one line keeping Back right after a reload (see [Navigation](navigation.md#navigation)).
@@ -280,4 +280,13 @@ if !connected()
280
280
 
281
281
  - The code that posts an action call and reads its answer loads with the first call, so an island that only declares or passes an action does not carry it. An island holding an action caller loads it at idle, so a call made as the page goes away finds it in; a chunk a deploy dropped reloads the page as other chunks do.
282
282
 
283
+ ### Components that load when they first draw
284
+
285
+ - A component an island imports loads on its own, with no declaration, when every tag using it sits where the island may not draw it at first paint: inside an `if`, `else`, `match` case or `@failed`, or in the lines or `@block` of a component that draws them only in such a branch (a closed `Dialog` and a `FormDialog` draw their body only when open). A tag also drawn outside a branch, a `snippet` read as a value, a dynamic tag or a server island keeps the import eager. A `for` body or a `pending` block inherits the position of the loop or `await` around it.
286
+ - What the server drew is loaded before the island hydrates (the page preloads its chunks, and the island names them in `data-lazy`), so its markup is claimed as it stands. What it did not draw loads when it first draws: a visitor reaching for the island (pointer over it, focus or touch inside it) loads every such component ahead, so the click finds the code in, except with `Save-Data`, which loads one when it opens.
287
+ - Until the code arrives the branch draws nothing, then the component in its place. A chunk that fails to load is tried again after 1 s and 3 s, a deploy that dropped it reloads the page as other chunks do, and a failure for good goes to `reportError` and `console.error`, not to `@failed`, which a render error of the branch reaches as ever; the branch tries again the next time it opens. A server-drawn chunk that fails to load leaves its island to draw that branch afresh.
288
+ - Only a component of 2,000 bytes of source or more loads this way, a chunk that only repeats code the islands load anyway is folded back into them after the bundle, so is every lazy chunk of a build when together they hold under 6,000 minified bytes (the lazy runtime would cost more), and an island that renders in the browser only (`clientOnly`) keeps its imports eager. A module with lazy imports awaits what the server drew at its top level, so a page without one carries none of this.
289
+ - A name inside a string or a whole-line comment of the file is no use of the component: only a tag or other code naming it keeps its import eager (a Table's `'Select all'` once kept its Select in every island). kayjs-ui's `Form`, `FormDialog` and `SaveForm` load the code that sends and reports a form (`forms-send`, with the toast it reports through) with the first send or blur check, tried once more when the chunk fails, so a page with a closed form-dialog does not carry it.
290
+ - `kay/dom-lazy` is the compiler's output contract for it, not API. `kay build --analyze` lists the modules of every island, a lazy component's apart from the eager ones.
291
+
283
292
  Shared and persisted state, transitions, error fallbacks, element size, context and unique ids are in [Islands: state to unique ids](islands-state-to-ids.md).
@@ -13,12 +13,12 @@ Declare the actions as for any call, one that stores a row and one that removes
13
13
  import { action, s } from 'kay'
14
14
  import { removeTodo, saveTodo } from '../data'
15
15
 
16
- export const save = action(s.Object({ id: s.String({ maxLength: 40 }), title: s.String({ minLength: 1, maxLength: 200 }), rev: s.Number() }), async (todo, ctx) => {
16
+ export const save = action({ id: s.string({ max: 40 }), title: s.string({ min: 1, max: 200 }), rev: s.number() }, async (todo, ctx) => {
17
17
  const held = await saveTodo(todo)
18
18
 
19
19
  return held.conflict ? ctx.deny(409, { data: held.row }) : held.row
20
20
  })
21
- export const remove = action(s.Object({ id: s.String({ maxLength: 40 }) }), async ({ id }) => removeTodo(id))
21
+ export const remove = action({ id: s.string({ max: 40 }) }, async ({ id }) => removeTodo(id))
22
22
  ---
23
23
  Todos
24
24
  ```
package/llms/mcp.md CHANGED
@@ -39,7 +39,7 @@ expect(await site.mcp.call('add_note', { title: 'Milk' })).toMatchObject({ isErr
39
39
  - A route's `detail.tool` is `true`, a description, or `{ name, description }`, as an action's. Its tool is named by `tool.name` else its `operationId` (a route setting only `tool.name` takes it as its `operationId`), made a safe name (`users.list` is `users_list`, a clash `_2`), described by `tool`'s description else its `summary` and `description`, its input one JSON Schema of the path params, query and JSON body, merged by name.
40
40
  - Left out: `detail: { hide: true }` routes, `tool` or not (`hidden-tool` in `kay check`), websockets, a route whose body is files, text or bytes, an action holding a file, an action in a file whose pages have route params (a post from no page cannot name one), and `in: header` parameters. `tools/list` is served behind the API directory's `_guard.ts` as the document is, and with `guards: { default: 'closed' }` it is refused (403) unless the guards cover every module; `initialize` and `ping` stay open, and a call runs the guards of its own route.
41
41
  - A route answering every method, `.all()`, that sets `tool` is a tool per method; a `tool.name` takes the method as a suffix, `echo_get`.
42
- - An action is a tool only when its third argument sets `tool`: `true`, a description, or `{ name, description }`; its name is the export in snake case, `addNote` is `add_note`, a clash `add_note_2`, and its input schema is the action's as JSON: `s.Integer()` and `s.Numeric()` read as a number, not also as the text a form sends (which a call still takes), and a top-level body or query field with a `default` is left out of `required`, as a call omitting it gets the default.
42
+ - An action is a tool only when its third argument sets `tool`: `true`, a description, or `{ name, description }`; its name is the export in snake case, `addNote` is `add_note`, a clash `add_note_2`, and its input schema is the action's as JSON: `s.int()` and `s.number()` read as a number, not also as the text a form sends (which a call still takes), and a top-level body or query field with a `default` is left out of `required`, as a call omitting it gets the default.
43
43
  - A name is made of letters, digits and `_`, at most 64 characters.
44
44
  - A call is dispatched through the whole app as a fetch to the route's or action's URL would be, so its guards, `rateLimit`, body limit, schema validation and `ctx.locals` are the web path's; `ctx.params` and `ctx.url` of an action are read as for a script's post from no page.
45
45
  - It carries the caller's `Authorization` (not the endpoint's own `mcp.token` bearer), `Cookie`, `Accept-Language` and `User-Agent`, and rate limits count the caller's address as `proxy` reads it, not the server's.
@@ -50,6 +50,7 @@ expect(await site.mcp.call('add_note', { title: 'Milk' })).toMatchObject({ isErr
50
50
  - A refused call is a result with `isError`: the schema's field errors, the `ctx.fail` data and status as `{ status, errors, data }` JSON, a route's own refusal text, a redirect naming where it leads. The agent corrects and calls again.
51
51
  - A guard answering 401 makes the endpoint answer 401 with `WWW-Authenticate: Bearer resource_metadata="<site>/.well-known/oauth-protected-resource"`, how a client learns to sign in (kay serves that document when kayjs-auth's OAuth server is on: see its "OAuth server for MCP clients"); any other refusal, 403 included, is a result. Only a guard's 401 does: a route answering 401 itself is a result too. A refused `tools/list` answers the same way (a redirect counting as a 401), as a JSON-RPC error. It keeps the guard's response headers, `Retry-After` of a 429 among them. A `tools/call` of a name no tool has is refused the same way, so names cannot be probed; a call to a tool runs its own guards.
52
52
  - A result is JSON as text, and `structuredContent` when an object; any other type read as its size. A route's object `response` is the tool's `outputSchema`, with no `detail.tool.output` ([action protection](action-protection.md#offering-an-action-to-agents)).
53
+ - Until 2.0, an app that did not set `endpoints.mcp` is answered at `/mcp` as well, in place, under the same limits, key and checks, unless a page, endpoint or file serves `/mcp`, which keeps it. Only a POST is taken there, so a `[...rest]` or `[slug]` page still answers GET and DELETE; only an exact route at `/mcp` takes POST from kay.
53
54
  - `/_kay/mcp` (`endpoints.mcp`) is claimed like a route: a page, endpoint or file serving it stops the boot, and `kay check` reports it.
54
55
  - `unguarded-tool` warns, with `mcp`, of a tool action with a `honeypot`, `minTime` or `proofOfWork` that no guard covers: an agent calls it without the form those protections ask of a person. A `...spread` in the options counts as one of them, so it warns; options that are not an object literal, `action(schema, run, options)`, are not read, so the action is not taken for a tool.
55
56
  - `site.mcp.initialize()` resolves with `{ serverInfo, instructions }` of the `initialize` answer, `instructions` being `mcp: { instructions }` or undefined.
@@ -45,7 +45,7 @@ const dispose = mount(Panel, document.querySelector('#panel')!, { title: 'Ticket
45
45
  ### Navigating from code
46
46
 
47
47
  - `navigate('/todos/1')`, imported from `kay`, goes to a page as a link would (the mount point and the current locale's prefix put on as on any `href`, `/todos/1` on a French page going to `/fr/todos/1`, a path already prefixed or another site's URL left as written; a module that gets `navigate` through a dynamic `import('kay')` is not covered, so import it statically), `{ replace: true }` taking the current history entry's place, `{ scroll: 'keep' }` leaving the window scrolled where it is instead of going to the top, `{ transition: false }` swapping without a view transition; another site's page loads, so a `?next=` param goes through `localPath()` as a redirect's does, and a `javascript:` URL throws, as it would run in the page; `mailto:`, `tel:` and other schemes go to the browser as a link would. A link or `navigate()` that a redirect takes to another site loads that page fully rather than swapping it in.
48
- - `navigate.query({ sort: 'name', page: null })` goes to the current page with those params set and a null, undefined or empty one dropped, the others and the path kept and the hash left out, keeping the scroll and the focus as `refresh()` does: a filter or a sort picked in place. It takes the options of `navigate()` and resolves as it does. `navigate({ query })`, which did this under the name that goes to a page, works until 1.108, `kay upgrade` rewriting it (`deprecated-navigate-query`). A query that is state of the page, not a one-off change, is a `queryParam` signal ([state](islands-state-to-ids.md#shared-and-persisted-state)).
48
+ - `navigate.query({ sort: 'name', page: null })` goes to the current page with those params set (a list sets one param once per item, `{ tag: ['a', 'b'] }` giving `?tag=a&tag=b`) and a null, undefined or empty one dropped, the others and the path kept and the hash left out, keeping the scroll and the focus as `refresh()` does: a filter or a sort picked in place. It takes the options of `navigate()` and resolves as it does. `navigate({ query })`, which did this under the name that goes to a page, works until 1.108, `kay upgrade` rewriting it (`deprecated-navigate-query`). A query that is state of the page, not a one-off change, is a `queryParam` signal ([state](islands-state-to-ids.md#shared-and-persisted-state)).
49
49
  - `withQuery({ page: 2, sort: null })` from `kay`, in a server fence, a template or an island (where it follows the address, so the link is built again after each `navigate.query()`, swap, Back and `queryParam` write), returns the path of the current page with those params set by the rule of `navigate.query()`, the other params kept and the hash left out, to link to it with one filter changed: `a(href={withQuery({ page: 2 })}) Next`. The path is the site's own, so `base`, `trailingSlash` and the locale prefix are put on by the link as on any `href`; in a fence it reads the request, so it throws in a page rendered once at build time.
50
50
  - `refresh()` from `kay` runs the current page's loads again and shows what they return, keeping the scroll, the focus and every island whose props did not change, as a call to an action does by itself once it went through.
51
51
  - `refresh('cart')` or `refresh(['cart', 'user'])` sends and swaps only the elements of the page reading the loads of its fence that bind those names, and leaves the rest of the page as it is: [rendering](rendering.md#refreshing-some-loads).
@@ -66,7 +66,7 @@ await notifications.erase(userId)
66
66
 
67
67
  ### Push to a person's devices
68
68
 
69
- `push()` in the extensions turns on web push: kay keeps the subscriptions in the app's store, signs and encrypts each push, and adds the `push` and `notificationclick` handlers to its service worker, which it serves and registers on every page with or without `offline`. When the browser rotates a subscription the worker subscribes again with the served key and posts it to the subscribe route with the session cookie, so the person keeps their pushes without reopening the page (a person signed out by then is not re-subscribed; a worker that could not reach the server keeps the new subscription, and a page using `webPush` posts the one the browser holds on load when it differs from the last one the server accepted, kept in `localStorage`, naming that one so the server takes it only from the person who owns it, never from whoever signed in next; a signed-out visitor's 401 is not repeated in that tab, and `unsubscribe()` or `subscribe()` leaves no stale record); an app that turns `offline` off while listing `push()` has the earlier worker's caches deleted. A person who subscribed gets every `notify()` as a push too, with no second call; `push: false` in its options keeps one in the inbox alone:
69
+ `push()` in the extensions turns on web push: kay keeps the subscriptions in the app's store, signs and encrypts each push, and adds the `push` and `notificationclick` handlers to its service worker, which it serves and registers on every page with or without `offline`. When the browser rotates a subscription the worker subscribes again with the served key and posts it to the subscribe route with the session cookie, so the person keeps their pushes without reopening the page (a person signed out by then is not re-subscribed; a worker that could not reach the server keeps the new subscription, and a page using `webPush` posts the one the browser holds on load when it differs from the last one the server accepted, kept in `localStorage`, naming that one so the server takes it only from the person who owns it, never from whoever signed in next; a signed-out visitor's 401 is not repeated in that tab, and `unsubscribe()` or `subscribe()` leaves no stale record); an app that turns `offline` off while listing `push()` has the earlier worker's caches deleted. A person who subscribed gets every `notify()` as a push too, with no second call; `push: false` in its options keeps one in the inbox alone, and the push carries the person's unread count, which the worker shows as the installed app's badge (`badge: false` leaves the badge alone):
70
70
 
71
71
  ```ts
72
72
  // kay.config.ts
@@ -109,6 +109,8 @@ button(onClick={async () => { await webPush.enable() }}) Notify me
109
109
  - Live: the route reads the inbox as `cached(..., { live: true })` does, so every open tab updates within about a second of a `notify`, a read or an erase, in any process sharing a cache store; a hidden tab catches up when shown ([Following cached values](live-values.md#following-cached-values)). The inbox is cached in the process's memory only, never in the cache store.
110
110
  - `Bell` takes `label` (the `ui.bell.label` message, "Notifications") and `placement`. A page with a Bell is the signed-in visitor's own: `private, no-cache` and rendered per request, as one reading `ctx` is. Put the Bell in a layout or a page, not inside an island: it reads the visitor on the server. Notifications from another source go through `items` ([Bell](../../ui/llms/page-layout-palette-and-trees.md#bell)).
111
111
  - Erasing a person: call `notifications.erase(userId)`, which also deletes their push subscriptions, with the rest of the function in [Privacy](privacy.md#erase-a-person-on-request).
112
- - Push: `sendPush(userId, { title, body?, url?, tag?, icon? }, { ttl?, urgency?, topic? })` answers `{ sent, dropped, failed }`. Title is 1 to 200 characters, body up to 500, tag 64; `url` and `icon` are kept as `notify` keeps a link, and a path goes under `base` in the worker. The payload is RFC 8291 aes128gcm with a VAPID (RFC 8292) JWT, on Web Crypto with no dependency. A push service answering 404 or 410 deletes that subscription; any other refusal counts as `failed` and keeps it. A person keeps their newest 10 devices. A subscription no push has reached for `push({ keep: '180d' })` is purged by an hourly sweep, a push that gets through counting as reached (`createdAt` then answers that time, written at most once a day). Idleness counts from the later of that date and the first sweep a store ever ran, so a subscription stored before an upgrade is never purged for its age alone, and the first purge comes `keep` after the upgrade. `pushSubscriptions.list(userId)` and `.erase(userId)` read and delete them.
112
+ - App badge: the Bell sets `navigator.setAppBadge(unread)`, and `clearAppBadge()` at 0, each time its count changes once its list has loaded, wherever the browser has the Badging API (an installed app on desktop Chrome and Edge, Android and iOS 16.4+, nothing elsewhere); `appBadge={false}` on `Bell` or `BellInbox` leaves it alone, and it follows `unread` of a custom source. A push from `notify()` carries `badge` (the count after the new notification, `notify(..., { badge: false })` leaves it out) and the worker sets it while no page is open; `sendPush` takes `badge` (0 to 999999, 0 clears) for a count of your own.
113
+ - The badge follows the page: a sign-out leaves the last count on the icon until the next visit, "Mark all as read" on one device reaches another's badge at its next page load (a push needs a title, so it cannot update a badge silently), and two quick `notify` calls may arrive out of order and leave the lower count until then. A Bell on a custom `items` list owns the badge too, so a page with two Bells of different counts sets `appBadge={false}` on one.
114
+ - Push: `sendPush(userId, { title, body?, url?, tag?, icon?, badge? }, { ttl?, urgency?, topic? })` answers `{ sent, dropped, failed }`. Title is 1 to 200 characters, body up to 500, tag 64; `url` and `icon` are kept as `notify` keeps a link, and a path goes under `base` in the worker. The payload is RFC 8291 aes128gcm with a VAPID (RFC 8292) JWT, on Web Crypto with no dependency. A push service answering 404 or 410 deletes that subscription; any other refusal counts as `failed` and keeps it. A person keeps their newest 10 devices. A subscription no push has reached for `push({ keep: '180d' })` is purged by an hourly sweep, a push that gets through counting as reached (`createdAt` then answers that time, written at most once a day). Idleness counts from the later of that date and the first sweep a store ever ran, so a subscription stored before an upgrade is never purged for its age alone, and the first purge comes `keep` after the upgrade. `pushSubscriptions.list(userId)` and `.erase(userId)` read and delete them.
113
115
  - Push store: `store.push` of kay.config.ts, a `PushStore` (`add`, `list`, `delete`, `erase`, and optionally `touch(endpoint, at)` and `prune(before)` for the age purge, which kay runs only for a store that has both, `prune` counting idleness from its first call as above): `sqliteData` and `pgData` fill it (the `kay_push_subscriptions` table), memory otherwise.
114
116
  - Push routes: `GET /_kay/push/key`, `POST /_kay/push/subscribe` and `/unsubscribe` (which ends the `kay_push_device` cookie), whose user comes from the request (401 when nobody is signed in) and which refuse another site; a subscription's endpoint must be https at a public address in production.
@@ -49,7 +49,7 @@ kay generate resource post title:string body:text published:boolean
49
49
  - The default `app` needs Bun alone: kayjs-auth keeps its users in `data/app.sqlite` and creates its tables when the app starts, `data` is ignored by git and docker, and `compose.prod.yaml` bind-mounts `data-prod`, a git- and docker-ignored folder to create owned by `nobody` (uid 65534), the user the image runs as, at `/app/data`, with no database service and no migration;
50
50
  - `--with postgres` (with `auth`, as in `--template app --with postgres`) swaps SQLite for Postgres: `src/db/tables.ts` lists `...authTables` among the tables, which `src/db/index.ts` builds `db` over and `pg-orm.config.ts` imports on their own, so the test preload points `DATABASE_URL` at its copy before anything builds `db`, `docker compose up -d --wait` starts the database `compose.dev.yaml` describes (on a port of its own per app name, its data in the git-ignored `data/postgres`), `bun run db:generate` writes the first migration for kayjs-auth's tables as the installed version declares them (and the next ones for yours), `bun run db:migrate` applies `migrations/`, its `bun run test` gives each test file a copy of the migrated database (see [Testing](testing.md)), its workflow runs Postgres as a service, and `compose.prod.yaml` runs the database (its data in `data-prod/postgres`, to create owned by the image's postgres uid 70) and a one-shot service applying the migrations before the app. Two Postgres roles split the work: the owner (`POSTGRES_USER`, connected by `MIGRATE_DATABASE_URL`, which `pg-orm.config.ts` reads before `DATABASE_URL`) changes the schema, and `app_rw` (the app's `DATABASE_URL`, password `APP_DB_PASSWORD`) reads and writes rows and cannot drop, alter or create anything. The database image creates `app_rw` from `db/roles.sh` when it first creates the database, with default privileges on tables, sequences and schemas, so a table a later migration creates needs no `GRANT`. An existing database runs `db/roles.sh` once, see [Upgrading](upgrading.md);
51
51
  - Every server preset's compose publishes the app on 127.0.0.1 alone, for a reverse proxy serving it over HTTPS, and its `kay.config.ts` sets `proxy: true` so rate limits count the visitor and not the proxy, its images and workflow use the Bun `kay new` ran under, and `.env` is ignored by git and docker and written readable by its owner alone;
52
- - `--kay` sets the `kay` dependency, by default `npm:@kayjs/kay@~<its version>`, or a packed copy when run from a checkout of kay.
52
+ - `--kay` sets the `kay` dependency, by default `npm:@kayjs/kay@~<its version>` (`^` from 2.0.0), or a packed copy when run from a checkout of kay.
53
53
  - The package is named after the directory, lower case with other characters turned into `-`.
54
54
  - Every template's `tsconfig.json` adds `noUncheckedIndexedAccess`, `exactOptionalPropertyTypes`, `noImplicitOverride` and `noFallthroughCasesInSwitch` to `strict`, as kay does itself, so an optional field passed `undefined` must say `?: T | undefined`;
55
55
  - `server` and `app` carry a workflow checking, formatting (`bun run fmt:check`, `kay fmt --check`), linting, testing and building the project on every pull request commit and every push to `main`, and the `site` workflow tests it before building, which checks it, then checks the formatting and lints it (see [Linting](checks.md#linting)).
package/llms/project.md CHANGED
@@ -51,7 +51,7 @@ kay migrate astro ../my-astro-site --outdir ../my-kay-site
51
51
 
52
52
  ### Project setup
53
53
 
54
- - kay is published as `@kayjs/kay` to npm, and as a mirror to the Forgejo registry at `https://git.kaynooo.fr/api/packages/kaynooo/npm/`, its libraries as `@kayjs/ui`, `@kayjs/auth`, `@kayjs/mail`, `@kayjs/cms` and `@kayjs/ai` (`@kaynooo/kayjs*` up to 1.103, which `kay upgrade` moves an app off), and installed under the name its imports use: `"kay": "npm:@kayjs/kay@~<version>"` in `package.json`, a tilde since a minor release may break what the one before it took, each break listed in [Upgrading](upgrading.md) and every one `kay check` can recognise a `deprecated` lint with a fix, which `kay upgrade` applies as it moves the app, and a major is a rewrite. Every package a project installs, pg-orm and eslint included, is on npm, so a project carries no `.npmrc` and Bun needs no registry setup.
54
+ - kay is published as `@kayjs/kay` to npm, and as a mirror to the Forgejo registry at `https://git.kaynooo.fr/api/packages/kaynooo/npm/`, its libraries as `@kayjs/ui`, `@kayjs/auth`, `@kayjs/mail`, `@kayjs/cms` and `@kayjs/ai` (`@kaynooo/kayjs*` up to 1.103, which `kay upgrade` moves an app off), and installed under the name its imports use: `"kay": "npm:@kayjs/kay@~<version>"` in `package.json`. From 2.0.0 kay follows semver (a breaking change is a major, and `kay new` writes `^<version>`); through 1.x a minor may break what the one before it took, so `kay new` writes `~<version>`, each break listed in [Upgrading](upgrading.md) and every one `kay check` can recognise a `deprecated` lint with a fix, which `kay upgrade` applies as it moves the app. Every package a project installs, pg-orm and eslint included, is on npm, so a project carries no `.npmrc` and Bun needs no registry setup.
55
55
  - `bunx -p @kayjs/kay kay new my-app` writes a project that, after `cd my-app && bun install`, checks, builds and runs (`bun run dev`), both of those included: this setup, a layout, a page, a `_404.kay` and islands, or only what is picked of them (see [Commands](commands.md#commands) for the presets and features).
56
56
 
57
57
  - kay runs on Bun 1.4.4 or later, as its `engines` says: the CLI and `pages()` refuse an older one, naming its version, its path and the fix, `bun update bun` when it is the project's npm `bun` package, which a plugin's peer dependency installs and package scripts run ahead of the system Bun.
@@ -98,7 +98,7 @@ export default defineConfig({
98
98
  - A feature key is `false` for off, `true` for its defaults or an object of options: `robots`, `sitemap`, `assets.favicon`, `security`, `ops.health`, `preview`, `client.offline`, `ops.metrics`, `openapi`, `mcp`, `proxy`, `assets.images.formats.avif` and the rate limits. `defineConfig` refuses a key it does not know in any option bag, as a type error.
99
99
  - A list that may come from a CMS or a database is the list, or a function returning it (or a promise of it): `cors.origins`, `security.hosts`, `assets.images.remote.hosts`, `proxy.trusted`, `redirects`, `robots.disallow`, `robots.allow` and `i18n.paths`. Kay calls it once as the config loads, `kay dev` again after a change to the file.
100
100
  - Keys are grouped by concern: `client` (what the browser is given: `links`, `offline`, `search`, ...), `assets` (`images`, `fonts`, `favicon`, `manifest`, `publicCache`), `ops` (`observe`, `health`, `metrics`, `jobs`), `endpoints` (where the app's API and each feature are served) and `i18n: { locales, default, mode }`, where `mode` is `'prefix'` (the default locale unprefixed), `'always'` or `{ domains }`. The old top-level keys work until 1.108 (`deprecated-client-keys`, `deprecated-config-groups`, `deprecated-i18n-keys` rewrite them).
101
- - `endpoints` holds every route the config moves, in one place: `{ api: '/api', openapi: '/api/openapi.json', mcp: '/_kay/mcp', health: '/_kay/health', metrics: '/_kay/metrics', jobs: '/_kay/jobs' }`, each an absolute path of plain segments with no trailing slash, and `api`, `openapi` and `mcp` none under `/_kay` when you set them. Every default is under `/_kay` but the app's API (and its OpenAPI document and reference page, which follow it). The reference page is `openapi: { reference: true }` or `{ reference: { path } }`. `serve.apiPrefix` and the `path` of `openapi`, `mcp`, `health`, `metrics` and `jobs`, and `openapi.referencePath`, work until 1.108 (`deprecated-route-keys` rewrites them). An app that did not move `mcp` or `metrics` keeps `/mcp` (a 308 to the new path) and `/metrics` (answered as well) until 1.108.
101
+ - `endpoints` holds every route the config moves, in one place: `{ api: '/api', openapi: '/api/openapi.json', mcp: '/_kay/mcp', health: '/_kay/health', metrics: '/_kay/metrics', jobs: '/_kay/jobs' }`, each an absolute path of plain segments with no trailing slash, and `api`, `openapi` and `mcp` none under `/_kay` when you set them. Every default is under `/_kay` but the app's API (and its OpenAPI document and reference page, which follow it). The reference page is `openapi: { reference: true }` or `{ reference: { path } }`. `serve.apiPrefix` and the `path` of `openapi`, `mcp`, `health`, `metrics` and `jobs`, and `openapi.referencePath`, work until 1.108 (`deprecated-route-keys` rewrites them). An app that did not move `mcp` or `metrics` keeps `/metrics` answering as well until 1.108, and `/mcp` answers the MCP endpoint in place (not redirected) until 2.0.
102
102
  - `assets.images` is `{ remote: { hosts, maxSize, timeout }, formats: { quality, webp, avif }, limits: { variants, queue }, rateLimit, ttl, widths, ... }`; `remote: [...]` is hosts alone.
103
103
  - A duration key is `ttl` for how long data lives, `timeout` for how long to wait and `maxAge` only for the HTTP or cookie attribute of that name.
104
104
  - `proxy: false` is none, `proxy: true` is one proxy in front, `proxy: { hops: 2 }` two, `{ header }` a header the proxy sets, `{ key: { header: 'x-upstream-key' }, open }` refuses requests without the shared key ([Production](proxy-and-security.md#behind-a-proxy)).
@@ -128,7 +128,7 @@ export default defineConfig({
128
128
  - It includes `src`, `tests`, `scripts`, the `*.config.ts` files beside it, such as `kay.config.ts`, `eslint.config.ts` and `pg-orm.config.ts`, and `.kay/types`, relative to the project's tsconfig.
129
129
  - A project adds its own `compilerOptions` beside `extends`, and an `include` of its own replaces kay's, so it lists `.kay/types` again; one setting up its tsconfig by hand needs `"jsx": "preserve"`, `"jsxImportSource": "kay"`, `"module": "Preserve"`, `"moduleResolution": "bundler"` and `"rootDirs": [".", ".kay/types"]`.
130
130
 
131
- - `kay/html`, `kay/dom`, `kay/dom-loop`, `kay/dom-await`, `kay/dom-try`, `kay/dom-spread`, `kay/dom-image`, `kay/pending`, `kay/i18n-links`, `kay/island`, `kay/await`, `kay/client`, `kay/arrival`, `kay/internal`, `kay/internal/title` and `kay/internal/server` are what compiled `.kay` files and kay's generated entries import, and `kay/jsx-runtime` is where TypeScript finds the JSX types of `jsxImportSource: "kay"`: the compiler's output contract rather than API, free to change in any release, never imported by an app. The root `kay` export also holds the compile-time types behind the generated shadow types, none of them for an app to name: `BindableMark`, `IslandBrand`, `HandedPart`, `HandsPart`, `HandedSignal`, `UnresolvedParameter`, `WidenedProps`, `CheckedHref`, `CheckedHtml`, `CheckedComputedHtml`, `BoundProp`, `BoundValue`, `PlainIslandProp`, `FunctionProp`, `Inferred`, `TemplateHelpers`, `TemplateValues` and `Truthy`, free to change in any release too.
131
+ - `kay/html`, `kay/dom`, `kay/dom-loop`, `kay/dom-await`, `kay/dom-lazy`, `kay/dom-try`, `kay/dom-spread`, `kay/dom-image`, `kay/pending`, `kay/i18n-links`, `kay/island`, `kay/await`, `kay/client`, `kay/arrival`, `kay/internal`, `kay/internal/title` and `kay/internal/server` are what compiled `.kay` files and kay's generated entries import, and `kay/jsx-runtime` is where TypeScript finds the JSX types of `jsxImportSource: "kay"`: the compiler's output contract rather than API, free to change in any release, never imported by an app. The root `kay` export also holds the compile-time types behind the generated shadow types, none of them for an app to name: `BindableMark`, `IslandBrand`, `HandedPart`, `HandsPart`, `HandedSignal`, `UnresolvedParameter`, `WidenedProps`, `CheckedHref`, `CheckedHtml`, `CheckedComputedHtml`, `BoundProp`, `BoundValue`, `PlainIslandProp`, `FunctionProp`, `Inferred`, `TemplateHelpers`, `TemplateValues` and `Truthy`, free to change in any release too.
132
132
  - A few entries also hold plumbing no page tells an app to call, free to change in any release: the paths, providers and tracker tags of `kay/analytics` (`ANALYTICS_PATH`, `ANALYTICS_SCRIPT_PATH`, `ANALYTICS_PROVIDERS`, `CUSTOM_COLLECT_PATH`, `CUSTOM_SCRIPT_PATH`, `NOTICE_SCRIPT_PATH`, `INTEGRITY`, `TRACKER_TAGS`, `isGated`, `LazyGuard`), the collection marker, publish times and cache key of `kay/content`, and the preview session reader of `kay/server`.
133
133
  - A name has one home: an entry beside a package's root exists for browser safety (`@kayjs/auth/rules`, `@kayjs/cms/form`, which an island imports without the server) and the root does not repeat its names. The copies in `kay/mount` and `kay/server` that 1.105 moved (`mount`, `s`, `RateLimit`, `sqliteCache`) stay as deprecated shims until 1.108.
134
134
  - `kay/library` is what kay's own libraries (kayjs-auth, kayjs-ui, kayjs-mail, kayjs-cms, kayjs-ai) share with kay for their server code, such as the sanitizer's lists, sealing, locale matching, escaping and the user a library names for a request (`nameUser(request, () => id)`, read back by `userOf(request)`: kayjs-auth names the signed-in user and kayjs-ai counts them) and `configError(option, value, takes)`, the `config-invalid` `KayError` a library throws for a setting it refuses at boot, so neither keeps a copy: not API either, free to change with any minor, never imported by an app. The libraries are released in lockstep with kay, each one's peer range on kay's minor, so the same holds for what a library imports from it.
@@ -13,7 +13,7 @@ How many times a client may do something in a window, on actions, in guards and
13
13
  import { s, action } from 'kay'
14
14
 
15
15
  export const subscribe = action(
16
- s.Object({ email: s.String({ format: 'email' }) }),
16
+ { email: s.string({ format: 'email' }) },
17
17
  async ({ email }) => email.length,
18
18
  { protect: { rateLimit: { max: 5, window: '1m' } } },
19
19
  )
package/llms/recipes.md CHANGED
@@ -24,7 +24,7 @@ export const Todo = defineTable('todo', f => ({
24
24
  import { s } from 'kay'
25
25
  import { defineEnv } from 'kay/server'
26
26
 
27
- export const env = defineEnv(s.Object({ DATABASE_URL: s.String() }))
27
+ export const env = defineEnv({ DATABASE_URL: s.string() })
28
28
  ```
29
29
 
30
30
  ```ts
@@ -53,13 +53,13 @@ import { s, action } from 'kay'
53
53
  import { db } from '../db'
54
54
  import { Todo } from '../db/todo'
55
55
 
56
- export const create = action(s.Object({
57
- title: s.String({ pattern: '\\S', maxLength: 120, error: 'Write a title' }),
58
- }), async ({ title }) => {
56
+ export const create = action({
57
+ title: s.string({ pattern: '\\S', max: 120, error: 'Write a title' }),
58
+ }, async ({ title }) => {
59
59
  await db.repo(Todo).write.insertOne({ title: title.trim() })
60
60
  })
61
61
 
62
- export const remove = action(s.Object({ id: s.Integer() }), async ({ id }) => {
62
+ export const remove = action({ id: s.int() }, async ({ id }) => {
63
63
  await db.repo(Todo).write.deleteOne({ id })
64
64
  })
65
65
 
@@ -88,11 +88,11 @@ import { s, action } from 'kay'
88
88
  import { db } from '../../db'
89
89
  import { Todo } from '../../db/todo'
90
90
 
91
- export const save = action(s.Object({
92
- id: s.Integer(),
93
- title: s.String({ pattern: '\\S', maxLength: 120, error: 'Write a title' }),
94
- done: s.Boolean(),
95
- }), async ({ id, title, done }, ctx) => {
91
+ export const save = action({
92
+ id: s.int(),
93
+ title: s.string({ pattern: '\\S', max: 120, error: 'Write a title' }),
94
+ done: s.boolean(),
95
+ }, async ({ id, title, done }, ctx) => {
96
96
  await db.repo(Todo).write.updateOne({ title: title.trim(), done }, { id })
97
97
 
98
98
  return ctx.redirect('/todos')
@@ -201,7 +201,7 @@ An action is covered by the guards of its folder; one that lives elsewhere check
201
201
  // src/routes/dashboard/users/index.kay, in its server fence
202
202
  import { auth } from '../../../auth'
203
203
 
204
- export const ban = action(s.Object({ id: s.String() }), async ({ id }, ctx) => {
204
+ export const ban = action({ id: s.string() }, async ({ id }, ctx) => {
205
205
  const user = await ctx.locals.auth.requireUser()
206
206
 
207
207
  if (!auth.isGranted('admin', user))
@@ -243,11 +243,11 @@ import { s } from 'kay'
243
243
  import { collection } from 'kay/content'
244
244
 
245
245
  export const posts = collection('content/posts', {
246
- schema: s.Object({
247
- title: s.String(),
248
- date: s.Date(),
249
- tags: s.Array(s.String(), { default: [] }),
250
- draft: s.Optional(s.Boolean()),
246
+ schema: s.object({
247
+ title: s.string(),
248
+ date: s.date(),
249
+ tags: s.list(s.string(), { default: [] }),
250
+ draft: s.boolean({ optional: true }),
251
251
  }),
252
252
  route: '/blog/:slug',
253
253
  draft: post => post.data.draft === true,