@forinda/kickjs-cli 8.5.0 → 8.6.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 (105) hide show
  1. package/dist/{project-docs-Y6vOc-Uj.mjs → agent-docs-BFOgLbXq.mjs} +9 -71
  2. package/dist/agent-docs-BFOgLbXq.mjs.map +1 -0
  3. package/dist/{project-docs-BE8DKCWP.mjs → agent-docs-BU1rORKA.mjs} +3 -65
  4. package/dist/{build-D3rNfcxu.mjs → build-CdIpRyfy.mjs} +3 -3
  5. package/dist/{build-D3rNfcxu.mjs.map → build-CdIpRyfy.mjs.map} +1 -1
  6. package/dist/{build-DwfrMHgx.mjs → build-DlfIkjcw.mjs} +2 -2
  7. package/dist/{builtins-D4pwODzu.mjs → builtins-CfAXBoIM.mjs} +2 -2
  8. package/dist/{builtins-DtTYiDg0.mjs → builtins-CmuUgcIq.mjs} +36 -31
  9. package/dist/cli.mjs +2 -2
  10. package/dist/config-SvlcF3Ls.mjs +12 -0
  11. package/dist/config-ndsVdO8u.mjs +13 -0
  12. package/dist/config-ndsVdO8u.mjs.map +1 -0
  13. package/dist/{doctor-Df6zCPr5.mjs → doctor-D3RMXkxE.mjs} +6 -6
  14. package/dist/{doctor-Df6zCPr5.mjs.map → doctor-D3RMXkxE.mjs.map} +1 -1
  15. package/dist/fs-DdNMcW_P.mjs +12 -0
  16. package/dist/fs-DdNMcW_P.mjs.map +1 -0
  17. package/dist/fs-v57MCgpH.mjs +11 -0
  18. package/dist/fullstack-DOufUeMv.mjs +95 -0
  19. package/dist/fullstack-LJwhodT-.mjs +96 -0
  20. package/dist/fullstack-LJwhodT-.mjs.map +1 -0
  21. package/dist/index.d.mts +15 -24
  22. package/dist/index.d.mts.map +1 -1
  23. package/dist/index.mjs +2 -2
  24. package/dist/{plugin-B8fmVbk8.mjs → plugin-Dighdqh-.mjs} +2 -2
  25. package/dist/{plugin-B-mP0jvi.mjs → plugin-Dn67elEZ.mjs} +2 -2
  26. package/dist/project-AXCA1hD9.mjs +45 -0
  27. package/dist/project-Cb_NLUWI.mjs +46 -0
  28. package/dist/project-Cb_NLUWI.mjs.map +1 -0
  29. package/dist/{project-root-BzyIWFlH.mjs → project-root-C7TrLJlZ.mjs} +3 -3
  30. package/dist/{project-root-BzyIWFlH.mjs.map → project-root-C7TrLJlZ.mjs.map} +1 -1
  31. package/dist/{project-root-CSHMf3L7.mjs → project-root-Dgvy5kYG.mjs} +2 -2
  32. package/dist/{prompts-wFEGsPZt.mjs → prompts-CSATvwXw.mjs} +2 -2
  33. package/dist/{prompts-wFEGsPZt.mjs.map → prompts-CSATvwXw.mjs.map} +1 -1
  34. package/dist/{rolldown-runtime-DzFISCwE.mjs → rolldown-runtime-BhxEEqxa.mjs} +1 -1
  35. package/dist/{run-plugins-ByRyAAZe.mjs → run-plugins-Cf_6BgGZ.mjs} +34 -29
  36. package/dist/run-plugins-Cf_6BgGZ.mjs.map +1 -0
  37. package/dist/{typegen-BfOYvlWo.mjs → typegen-97E_RYNp.mjs} +4 -4
  38. package/dist/typegen-CYhFNfIu.mjs +132 -0
  39. package/dist/{typegen-Bx2IQ-w5.mjs.map → typegen-CYhFNfIu.mjs.map} +1 -1
  40. package/dist/{types-dUiZnaWm.mjs → types-lHwt_SNI.mjs} +1 -1
  41. package/package.json +10 -9
  42. package/templates/base/feature.json +18 -0
  43. package/templates/base/files/README.md +61 -0
  44. package/templates/base/files/_dot_editorconfig +13 -0
  45. package/templates/base/files/_dot_env +2 -0
  46. package/templates/base/files/_dot_env.example +2 -0
  47. package/templates/base/files/_dot_env.test +9 -0
  48. package/templates/base/files/_dot_env.test.example +11 -0
  49. package/templates/base/files/_dot_gitattributes +18 -0
  50. package/templates/base/files/_dot_gitignore +14 -0
  51. package/templates/base/files/_dot_oxfmtrc.json +9 -0
  52. package/templates/base/files/kick.config.ts +58 -0
  53. package/templates/base/files/src/modules/hello/hello.controller.ts +26 -0
  54. package/templates/base/files/src/modules/hello/hello.module.ts +21 -0
  55. package/templates/base/files/src/modules/hello/hello.service.ts +12 -0
  56. package/templates/base/files/src/modules/index.ts +7 -0
  57. package/templates/base/files/tsconfig.json +21 -0
  58. package/templates/base/files/vite.config.ts +31 -0
  59. package/templates/base/files/vitest.config.ts +18 -0
  60. package/templates/feature-devtools/feature.json +13 -0
  61. package/templates/feature-queue/feature.json +16 -0
  62. package/templates/feature-queue/files/_dot_env.append +2 -0
  63. package/templates/feature-queue/files/_dot_env.example.append +2 -0
  64. package/templates/feature-swagger/feature.json +16 -0
  65. package/templates/feature-ws/feature.json +13 -0
  66. package/templates/fullstack-root/files/_dot_gitignore +8 -0
  67. package/templates/fullstack-root/files/netlify.toml +13 -0
  68. package/templates/fullstack-root/files/vercel.json +5 -0
  69. package/templates/host-config/files/netlify.toml +6 -0
  70. package/templates/host-config/files/vercel.json +5 -0
  71. package/templates/runtime-express/feature.json +22 -0
  72. package/templates/runtime-fastify/feature.json +13 -0
  73. package/templates/runtime-h3/feature.json +13 -0
  74. package/templates/schema-valibot/feature.json +3 -0
  75. package/templates/schema-valibot/files/src/config/index.ts +41 -0
  76. package/templates/schema-yup/feature.json +3 -0
  77. package/templates/schema-yup/files/src/config/index.ts +43 -0
  78. package/templates/schema-zod/feature.json +3 -0
  79. package/templates/schema-zod/files/src/config/index.ts +41 -0
  80. package/templates/server-fullstack/feature.json +13 -0
  81. package/templates/template-minimal/feature.json +10 -0
  82. package/templates/template-minimal/files/src/index.ts +17 -0
  83. package/templates/template-rest/feature.json +10 -0
  84. package/templates/template-rest/files/src/index.ts +28 -0
  85. package/templates/web-kick/files/web/index.html +12 -0
  86. package/templates/web-kick/files/web/src/App.tsx +45 -0
  87. package/templates/web-kick/files/web/src/api.ts +14 -0
  88. package/templates/web-kick/files/web/src/main.tsx +9 -0
  89. package/templates/web-kick/files/web/tsconfig.json +15 -0
  90. package/templates/web-kick/files/web/vite.config.ts +13 -0
  91. package/dist/agent-docs-CXX06wib.mjs +0 -11
  92. package/dist/agent-docs-CXs5UDAM.mjs +0 -12
  93. package/dist/agent-docs-CXs5UDAM.mjs.map +0 -1
  94. package/dist/config-BUYf44lU.mjs +0 -13
  95. package/dist/config-BUYf44lU.mjs.map +0 -1
  96. package/dist/config-F1NW28_P.mjs +0 -12
  97. package/dist/fullstack-BcJ5lOwt.mjs +0 -194
  98. package/dist/fullstack-D3W7RS2W.mjs +0 -195
  99. package/dist/fullstack-D3W7RS2W.mjs.map +0 -1
  100. package/dist/project-5aAVIQV5.mjs +0 -450
  101. package/dist/project-DdYD7xPw.mjs +0 -451
  102. package/dist/project-DdYD7xPw.mjs.map +0 -1
  103. package/dist/project-docs-Y6vOc-Uj.mjs.map +0 -1
  104. package/dist/run-plugins-ByRyAAZe.mjs.map +0 -1
  105. package/dist/typegen-Bx2IQ-w5.mjs +0 -132
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs-cli v8.5.0
2
+ * @forinda/kickjs-cli v8.6.0
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import{t as e}from"./rolldown-runtime-DzFISCwE.mjs";import{c as t,l as n,s as r}from"./project-docs-Y6vOc-Uj.mjs";import{a as i,c as a,d as o,i as s,l as c,n as l,o as u,r as d,s as f,t as p,u as m}from"./prompts-wFEGsPZt.mjs";import{A as h,C as g,D as _,E as v,M as y,N as b,O as x,P as S,S as C,T as ee,_ as te,a as ne,b as re,c as ie,f as ae,g as oe,h as se,i as ce,j as le,k as ue,l as de,m as fe,p as pe,r as me,u as he,v as ge,w as _e,x as ve,y as ye}from"./doctor-Df6zCPr5.mjs";import{c as be,m as xe,r as Se,s as Ce,t as we,u as Te}from"./project-DdYD7xPw.mjs";import{a as Ee,c as De,i as Oe,l as ke,o as w,s as T,u as Ae}from"./config-BUYf44lU.mjs";import{t as E}from"./project-root-BzyIWFlH.mjs";import{n as D,t as je}from"./types-dUiZnaWm.mjs";import{t as Me}from"./build-D3rNfcxu.mjs";import{n as Ne}from"./agent-docs-CXs5UDAM.mjs";import{C as Pe,S as O,T as Fe,_ as Ie,a as Le,b as Re,c as ze,d as Be,f as Ve,g as He,h as Ue,i as We,l as Ge,m as Ke,o as qe,p as Je,r as Ye,s as Xe,t as Ze,u as Qe,v as $e,w as et,x as tt,y as nt}from"./typegen-Bx2IQ-w5.mjs";import{createRequire as rt}from"node:module";import k,{basename as it,dirname as A,join as j,relative as M,resolve as N,sep as P}from"node:path";import{cpSync as at,existsSync as F,mkdirSync as ot,readFileSync as I,readdirSync as st,rmSync as ct,writeFileSync as L}from"node:fs";import{copyFile as lt,mkdir as ut,readFile as R,readdir as dt,rm as ft,stat as pt,writeFile as z}from"node:fs/promises";import{fork as mt,spawn as ht,spawnSync as gt}from"node:child_process";import{fileURLToPath as _t,pathToFileURL as B}from"node:url";import{parseSync as vt}from"oxc-parser";import{arch as yt,platform as bt,release as xt}from"node:os";import{createHash as St}from"node:crypto";const Ct=[{value:`swagger`,label:`Swagger`,hint:`OpenAPI docs`},{value:`ws`,label:`WebSocket`,hint:`rooms, heartbeat`},{value:`queue`,label:`Queue`,hint:`BullMQ/RabbitMQ/Kafka`},{value:`devtools`,label:`DevTools`,hint:`debug dashboard`}];function wt(e){e.command(`new [name]`).alias(`init`).description(`Create a new KickJS project (use "." for current directory)`).option(`-d, --directory <dir>`,`Target directory (defaults to project name)`).option(`--pm <manager>`,`Package manager: pnpm | npm | yarn | bun`).option(`--git`,`Initialize git repository`).option(`--no-git`,`Skip git initialization`).option(`--install`,`Install dependencies after scaffolding`).option(`--no-install`,`Skip dependency installation`).option(`-f, --force`,`Remove existing files without prompting`).option(`-t, --template <type>`,`Project template: rest | minimal | fullstack`).option(`--runtime <engine>`,`HTTP runtime: express | fastify | h3`).option(`-r, --repo <type>`,`Repository name (inmemory, or any DB name e.g. postgres)`).option(`-s, --schema <lib>`,`Schema library for env / DTOs: zod | valibot | yup (default: zod)`).option(`--frontend <kind>`,`Fullstack web/ scaffold: 'kick' (wired React app) or 'vite' (create-vite, unwired)`).option(`--vite-template <name>`,`create-vite TypeScript template for --frontend vite (default 'react-ts')`).option(`--packages <packages>`,`Comma-separated packages to include (e.g. swagger,ws,queue,devtools)`).option(`-y, --yes`,`Pick safe defaults for every prompt (template=minimal, repo=inmemory, no extras, git+install on)`).option(`--non-interactive`,`alias for --yes`).action(async(e,t)=>{l(`KickJS — Create a new project`);let n=!!(t.yes||t.nonInteractive);e||=n?`my-api`:await a({message:`Project name`,placeholder:`my-api`,defaultValue:`my-api`});let r;if(e===`.`?(r=N(`.`),e=it(r)):r=N(t.directory||e),F(r)){let a=st(r);if(a.length>0){if(t.force)d.warn(`Clearing existing files in ${r}`);else if(n){d.warn(`Directory "${e}" is not empty. Pass --force to clear it.`),i(`Aborted.`);return}else{d.warn(`Directory "${e}" is not empty:`);let t=a.slice(0,5);for(let e of t)d.message(` - ${e}`);if(a.length>5&&d.message(` ... and ${a.length-5} more`),!await p({message:m.red(`Remove all existing files and proceed?`),initialValue:!1})){i(`Aborted.`);return}}for(let e of a)ct(N(r,e),{recursive:!0,force:!0})}}let o=t.template;o||=n?`minimal`:await u({message:`Project template`,options:[{value:`rest`,label:`REST API`,hint:`Express + Swagger`},{value:`minimal`,label:`Minimal`,hint:`bare Express`},{value:`fullstack`,label:`Fullstack`,hint:`server + Vite React web, typed client`}]});let c=t.runtime;c||=n?`express`:await u({message:`HTTP runtime`,options:[{value:`express`,label:`Express`,hint:`default, zero-config`},{value:`fastify`,label:`Fastify`,hint:`fastify + @fastify/middie`},{value:`h3`,label:`h3`,hint:`Nitro / Nuxt engine`}]});let f=t.pm;f||=n?await Te(void 0):await u({message:`Package manager`,options:[{value:`pnpm`,label:`pnpm`},{value:`npm`,label:`npm`},{value:`yarn`,label:`yarn`},{value:`bun`,label:`bun`}]});let h=t.repo;h||=n?`inmemory`:await a({message:`Repository name`,placeholder:`inmemory (or a DB name, e.g. postgres)`,defaultValue:`inmemory`}),Ae(h);let g=t.schema;g||=n?`zod`:await u({message:`Schema library (env + DTO validation)`,options:[{value:`zod`,label:`Zod`,hint:`default — broad ecosystem`},{value:`valibot`,label:`Valibot`,hint:`smaller bundle`},{value:`yup`,label:`Yup`,hint:`classic API`}]}),[`zod`,`valibot`,`yup`].includes(g)||(d.warn(`Unknown --schema "${g}", falling back to zod.`),g=`zod`);let _;if(t.packages!==void 0){let e=t.packages.trim().toLowerCase();_=e===``||e===`none`||e===`false`?[]:t.packages.split(`,`).map(e=>e.trim()).filter(Boolean)}else _=n?[]:await s({message:`Select packages to include`,options:[...Ct],required:!1});let v;v=t.git===void 0?n?!0:await p({message:`Initialize git repository?`,initialValue:!0}):t.git;let y;if(y=t.install===void 0?n?!0:await p({message:`Install dependencies?`,initialValue:!0}):t.install,t.frontend!==void 0&&t.frontend!==`kick`&&t.frontend!==`vite`){d.error(`Unknown --frontend '${String(t.frontend)}'. Use 'kick' (wired React app) or 'vite' (create-vite).`),i(`Aborted.`);return}let{VITE_TEMPLATES:b,DEFAULT_VITE_TEMPLATE:x}=await import(`./fullstack-D3W7RS2W.mjs`);if(t.viteTemplate!==void 0&&!b.some(e=>e.value===t.viteTemplate)){d.error(`Unknown --vite-template '${String(t.viteTemplate)}'. TypeScript templates only: ${b.map(e=>e.value).join(`, `)}.`),i(`Aborted.`);return}let S=t.frontend===`vite`?`vite`:`kick`,C=t.viteTemplate??x;if(o===`fullstack`&&!t.frontend&&!n&&(S=await u({message:`Frontend for web/`,options:[{value:`kick`,label:`KickJS React app`,hint:`typed client, /api proxy, route types — wired`},{value:`vite`,label:`Delegate to create-vite`,hint:`pick any framework; wiring is manual (guide printed after)`}]})),S===`vite`&&!t.viteTemplate&&!n&&(C=await u({message:`create-vite template`,options:b.map(e=>({value:e.value,label:e.label})),initialValue:x})),o===`fullstack`){let{initFullstackProject:t}=await import(`./fullstack-D3W7RS2W.mjs`);await t({name:e,directory:r,packageManager:f,initGit:v,installDeps:y,schemaLib:g,runtime:c,frontend:S,viteTemplate:C}),i(`Done! Next steps: ${m.cyan(`cd ${e} && ${f}${f===`pnpm`?` dev`:` run dev:server`}`)}`);return}await we({name:e,directory:r,packageManager:f,initGit:v,installDeps:y,template:o,defaultRepo:h,packages:_,schemaLib:g,runtime:c}),i(`Done! Next steps: ${m.cyan(`cd ${e} && ${f} dev`)}`)})}function Tt(e,t=[]){let n=new Map;for(let t of e){let e=(n.get(t.name)??0)+1;if(n.set(t.name,e),e===2)throw new je(`plugin`,t.name,[t.name,t.name])}let r=new Map,i=[];for(let t of e)for(let e of t.commands??[]){let n=r.get(e.name);if(n)throw new je(`command`,e.name,[n,t.name]);r.set(e.name,t.name),i.push(e)}let a=new Set(t.map(e=>e.name)),o=[...i.filter(e=>!a.has(e.name)),...t],s=new Map,c=[];for(let t of e)for(let e of t.typegens??[]){let n=s.get(e.id);if(n)throw new je(`typegen`,e.id,[n,t.name]);s.set(e.id,t.name),c.push(e)}let l=new Map,u=[];for(let t of e)for(let e of t.generators??[]){let n=l.get(e.name);if(n)throw new je(`generator`,e.name,[n,t.name]);l.set(e.name,t.name),u.push({source:t.name,spec:e})}return{commands:o,typegens:c,generators:u,register:async(t,n)=>{let r;if(n)r={generators:u,...n};else{let{findProjectRoot:e}=await import(`./project-root-BzyIWFlH.mjs`).then(e=>e.n),t=process.cwd();r={cwd:t,projectRoot:e(t),config:null,log:()=>{},generators:u}}for(let n of e)n.register&&await n.register(t,r)}}}async function Et(e){let{name:t,outDir:r}=e,i=b(t),a=S(t),o=[],s=j(r,`${i}.plugin.ts`);return await n(s,`import {
11
+ import{t as e}from"./rolldown-runtime-BhxEEqxa.mjs";import{n as t,r as n,t as r}from"./fs-DdNMcW_P.mjs";import{a as i,c as a,d as o,i as s,l as c,n as l,o as u,r as d,s as f,t as p,u as m}from"./prompts-CSATvwXw.mjs";import{A as h,C as g,D as _,E as v,M as y,N as b,O as x,P as S,S as C,T as ee,_ as te,a as ne,b as re,c as ie,f as ae,g as oe,h as se,i as ce,j as le,k as ue,l as de,m as fe,p as pe,r as me,u as he,v as ge,w as _e,x as ve,y as ye}from"./doctor-D3RMXkxE.mjs";import{d as be,l as xe,o as Se,r as Ce,s as we,t as Te}from"./project-Cb_NLUWI.mjs";import{a as Ee,c as De,i as Oe,l as ke,o as w,s as T,u as Ae}from"./config-ndsVdO8u.mjs";import{t as E}from"./project-root-C7TrLJlZ.mjs";import{n as D,t as je}from"./types-lHwt_SNI.mjs";import{t as Me}from"./build-CdIpRyfy.mjs";import{n as Ne}from"./agent-docs-BFOgLbXq.mjs";import{C as Pe,S as O,T as Fe,_ as Ie,a as Le,b as Re,c as ze,d as Be,f as Ve,g as He,h as Ue,i as We,l as Ge,m as Ke,o as qe,p as Je,r as Ye,s as Xe,t as Ze,u as Qe,v as $e,w as et,x as tt,y as nt}from"./typegen-CYhFNfIu.mjs";import{createRequire as rt}from"node:module";import k,{basename as it,dirname as A,join as j,relative as M,resolve as N,sep as P}from"node:path";import{cpSync as at,existsSync as F,mkdirSync as ot,readFileSync as I,readdirSync as st,rmSync as ct,writeFileSync as L}from"node:fs";import{copyFile as lt,mkdir as ut,readFile as R,readdir as dt,rm as ft,stat as pt,writeFile as z}from"node:fs/promises";import{fork as mt,spawn as ht,spawnSync as gt}from"node:child_process";import{fileURLToPath as _t,pathToFileURL as B}from"node:url";import{parseSync as vt}from"oxc-parser";import{arch as yt,platform as bt,release as xt}from"node:os";import{createHash as St}from"node:crypto";const Ct=[{value:`swagger`,label:`Swagger`,hint:`OpenAPI docs`},{value:`ws`,label:`WebSocket`,hint:`rooms, heartbeat`},{value:`queue`,label:`Queue`,hint:`BullMQ/RabbitMQ/Kafka`},{value:`devtools`,label:`DevTools`,hint:`debug dashboard`}];function wt(e){e.command(`new [name]`).alias(`init`).description(`Create a new KickJS project (use "." for current directory)`).option(`-d, --directory <dir>`,`Target directory (defaults to project name)`).option(`--pm <manager>`,`Package manager: pnpm | npm | yarn | bun`).option(`--git`,`Initialize git repository`).option(`--no-git`,`Skip git initialization`).option(`--install`,`Install dependencies after scaffolding`).option(`--no-install`,`Skip dependency installation`).option(`-f, --force`,`Remove existing files without prompting`).option(`-t, --template <type>`,`Project template: rest | minimal | fullstack`).option(`--runtime <engine>`,`HTTP runtime: express | fastify | h3`).option(`-r, --repo <type>`,`Repository name (inmemory, or any DB name e.g. postgres)`).option(`-s, --schema <lib>`,`Schema library for env / DTOs: zod | valibot | yup (default: zod)`).option(`--frontend <kind>`,`Fullstack web/ scaffold: 'kick' (wired React app) or 'vite' (create-vite, unwired)`).option(`--vite-template <name>`,`create-vite TypeScript template for --frontend vite (default 'react-ts')`).option(`--packages <packages>`,`Comma-separated packages to include (e.g. swagger,ws,queue,devtools)`).option(`-y, --yes`,`Pick safe defaults for every prompt (template=minimal, repo=inmemory, no extras, git+install on)`).option(`--non-interactive`,`alias for --yes`).action(async(e,t)=>{l(`KickJS — Create a new project`);let n=!!(t.yes||t.nonInteractive);e||=n?`my-api`:await a({message:`Project name`,placeholder:`my-api`,defaultValue:`my-api`});let r;if(e===`.`?(r=N(`.`),e=it(r)):r=N(t.directory||e),F(r)){let a=st(r);if(a.length>0){if(t.force)d.warn(`Clearing existing files in ${r}`);else if(n){d.warn(`Directory "${e}" is not empty. Pass --force to clear it.`),i(`Aborted.`);return}else{d.warn(`Directory "${e}" is not empty:`);let t=a.slice(0,5);for(let e of t)d.message(` - ${e}`);if(a.length>5&&d.message(` ... and ${a.length-5} more`),!await p({message:m.red(`Remove all existing files and proceed?`),initialValue:!1})){i(`Aborted.`);return}}for(let e of a)ct(N(r,e),{recursive:!0,force:!0})}}let o=t.template;o||=n?`minimal`:await u({message:`Project template`,options:[{value:`rest`,label:`REST API`,hint:`Express + Swagger`},{value:`minimal`,label:`Minimal`,hint:`bare Express`},{value:`fullstack`,label:`Fullstack`,hint:`server + Vite React web, typed client`}]});let c=t.runtime;c||=n?`express`:await u({message:`HTTP runtime`,options:[{value:`express`,label:`Express`,hint:`default, zero-config`},{value:`fastify`,label:`Fastify`,hint:`fastify + @fastify/middie`},{value:`h3`,label:`h3`,hint:`Nitro / Nuxt engine`}]});let f=t.pm;f||=n?await xe(void 0):await u({message:`Package manager`,options:[{value:`pnpm`,label:`pnpm`},{value:`npm`,label:`npm`},{value:`yarn`,label:`yarn`},{value:`bun`,label:`bun`}]});let h=t.repo;h||=n?`inmemory`:await a({message:`Repository name`,placeholder:`inmemory (or a DB name, e.g. postgres)`,defaultValue:`inmemory`}),Ae(h);let g=t.schema;g||=n?`zod`:await u({message:`Schema library (env + DTO validation)`,options:[{value:`zod`,label:`Zod`,hint:`default — broad ecosystem`},{value:`valibot`,label:`Valibot`,hint:`smaller bundle`},{value:`yup`,label:`Yup`,hint:`classic API`}]}),[`zod`,`valibot`,`yup`].includes(g)||(d.warn(`Unknown --schema "${g}", falling back to zod.`),g=`zod`);let _;if(t.packages!==void 0){let e=t.packages.trim().toLowerCase();_=e===``||e===`none`||e===`false`?[]:t.packages.split(`,`).map(e=>e.trim()).filter(Boolean)}else _=n?[]:await s({message:`Select packages to include`,options:[...Ct],required:!1});let v;v=t.git===void 0?n?!0:await p({message:`Initialize git repository?`,initialValue:!0}):t.git;let y;if(y=t.install===void 0?n?!0:await p({message:`Install dependencies?`,initialValue:!0}):t.install,t.frontend!==void 0&&t.frontend!==`kick`&&t.frontend!==`vite`){d.error(`Unknown --frontend '${String(t.frontend)}'. Use 'kick' (wired React app) or 'vite' (create-vite).`),i(`Aborted.`);return}let{VITE_TEMPLATES:b,DEFAULT_VITE_TEMPLATE:x}=await import(`./fullstack-LJwhodT-.mjs`);if(t.viteTemplate!==void 0&&!b.some(e=>e.value===t.viteTemplate)){d.error(`Unknown --vite-template '${String(t.viteTemplate)}'. TypeScript templates only: ${b.map(e=>e.value).join(`, `)}.`),i(`Aborted.`);return}let S=t.frontend===`vite`?`vite`:`kick`,C=t.viteTemplate??x;if(o===`fullstack`&&!t.frontend&&!n&&(S=await u({message:`Frontend for web/`,options:[{value:`kick`,label:`KickJS React app`,hint:`typed client, /api proxy, route types — wired`},{value:`vite`,label:`Delegate to create-vite`,hint:`pick any framework; wiring is manual (guide printed after)`}]})),S===`vite`&&!t.viteTemplate&&!n&&(C=await u({message:`create-vite template`,options:b.map(e=>({value:e.value,label:e.label})),initialValue:x})),o===`fullstack`){let{initFullstackProject:t}=await import(`./fullstack-LJwhodT-.mjs`);await t({name:e,directory:r,packageManager:f,initGit:v,installDeps:y,schemaLib:g,runtime:c,packages:_,frontend:S,viteTemplate:C}),i(`Done! Next steps: ${m.cyan(`cd ${e} && ${f}${f===`pnpm`?` dev`:` run dev:server`}`)}`);return}await Te({name:e,directory:r,packageManager:f,initGit:v,installDeps:y,template:o,defaultRepo:h,packages:_,schemaLib:g,runtime:c}),i(`Done! Next steps: ${m.cyan(`cd ${e} && ${f} dev`)}`)})}function Tt(e,t=[]){let n=new Map;for(let t of e){let e=(n.get(t.name)??0)+1;if(n.set(t.name,e),e===2)throw new je(`plugin`,t.name,[t.name,t.name])}let r=new Map,i=[];for(let t of e)for(let e of t.commands??[]){let n=r.get(e.name);if(n)throw new je(`command`,e.name,[n,t.name]);r.set(e.name,t.name),i.push(e)}let a=new Set(t.map(e=>e.name)),o=[...i.filter(e=>!a.has(e.name)),...t],s=new Map,c=[];for(let t of e)for(let e of t.typegens??[]){let n=s.get(e.id);if(n)throw new je(`typegen`,e.id,[n,t.name]);s.set(e.id,t.name),c.push(e)}let l=new Map,u=[];for(let t of e)for(let e of t.generators??[]){let n=l.get(e.name);if(n)throw new je(`generator`,e.name,[n,t.name]);l.set(e.name,t.name),u.push({source:t.name,spec:e})}return{commands:o,typegens:c,generators:u,register:async(t,n)=>{let r;if(n)r={generators:u,...n};else{let{findProjectRoot:e}=await import(`./project-root-C7TrLJlZ.mjs`).then(e=>e.n),t=process.cwd();r={cwd:t,projectRoot:e(t),config:null,log:()=>{},generators:u}}for(let n of e)n.register&&await n.register(t,r)}}}async function Et(e){let{name:t,outDir:r}=e,i=b(t),a=S(t),o=[],s=j(r,`${i}.plugin.ts`);return await n(s,`import {
12
12
  definePlugin,
13
13
  type AppAdapter,
14
14
  type AppModuleEntry,
@@ -344,7 +344,7 @@ describe('${s}', () => {
344
344
  Example: kick g scaffold Post title:string body:text:optional published:boolean:optional
345
345
  Optional: append :optional (shell-safe, no quoting needed)
346
346
  `),process.exit(1));let o=await w(process.cwd()),s=T(o),c=r.modulesDir??s.dir??`src/modules`,l=Ut(n),u=ke(o,process.cwd()),d=Ee(E()),f=await Wt({name:e,fields:l,modulesDir:N(c),noEntity:r.entity===!1,noTests:r.tests===!1,pluralize:r.pluralize===!1?!1:s.pluralize??!0,tokenScope:u,swagger:d,style:s.style});console.log(`\n Scaffolded ${e} with ${l.length} field(s):`);for(let e of l)console.log(` ${e.name}: ${e.type}${e.optional?` (optional)`:``}`);W(f,a),await Xt(a)}),r.command(`config`).description(`Generate a kick.config.ts at the project root`).option(`--modules-dir <dir>`,`Modules directory path`,`src/modules`).option(`--repo <type>`,`Repository name: inmemory (default) or any DB name`,`inmemory`).option(`-f, --force`,`Overwrite existing kick.config.ts without prompting`).action(async(e,n)=>{let r=U(n);t(r),W(await kt({outDir:N(`.`),modulesDir:e.modulesDir,defaultRepo:e.repo,force:e.force}),r)}),r.command(`agents`).alias(`agent-docs`).alias(`ai-docs`).description(`Regenerate .agents/* + root CLAUDE.md (sync after framework upgrades)`).option(`--only <which>`,`Limit scope: agents | claude | skills | gemini | copilot | both (agents+claude) | all (default: all)`,`all`).option(`--name <name>`,`Project name (defaults to package.json name)`).option(`--pm <pm>`,`Package manager (defaults to package.json packageManager)`).option(`--template <template>`,`Template: rest | minimal | fullstack`).option(`-f, --force`,`Overwrite existing files without prompting`).action(async(e,n)=>{let r=U(n);t(r);let i=e.only??`all`;if(!Yt.includes(i)){console.error(` Invalid --only value: ${i}. Expected: ${Yt.join(` | `)}`),process.exitCode=1;return}W(await Ne({outDir:N(`.`),only:i,name:e.name,pm:e.pm,template:e.template,force:e.force}),r)});for(let e of n?.generators??[])rn(r,e,n?.projectRoot)}function rn(e,n,r){let{source:i,spec:a}=n,o=a.args?.[0],s=o?.name??`itemName`,c=o?.required?`<${s}>`:`[${s}]`,l=`${a.name} ${c} [extraArgs...]`,u=e.command(l).description(`${a.description} [${i}]`);for(let e of a.flags??[]){let t=e.takesValue?`--${e.name} <value>`:`--${e.name}`,n=e.alias?`-${e.alias}, ${t}`:t;u.option(n,e.description??``)}u.action(async(e,i,o,s)=>{let c=U(s);t(c);let l=await ne({generatorName:a.name,itemName:e??``,args:i??[],flags:o,cwd:process.cwd(),projectRoot:r},[n]);l&&W(l.files,c)})}const an=`/* AUTO-GENERATED by kick typegen — do not edit. Plugin: `;async function on(e){let t=k.resolve(e.cwd,`.kickjs/types`);e.check||await ut(t,{recursive:!0});let n=new Map,r=e.scan??He,i=k.resolve(e.cwd,`.kickjs`,`cache`),a=e.scan?void 0:e.changedFiles,o={cwd:e.cwd,config:e.config,async importTs(e){return await import(B(e).href)},async writeFile(t,n){let r=k.resolve(e.cwd,t);await ut(k.dirname(r),{recursive:!0}),await z(r,n,`utf8`)},getScanResult:e=>{let t=sn(e),o=n.get(t);if(!o){let s={cacheDir:i,...e};o=a?Ie(s,a):r(s),n.set(t,o)}return o},log:console,watch:e.watch,check:e.check},s=[],c=[];for(let n of e.plugins){let r=n.outExtension??`.d.ts`,i=k.join(t,`${n.id.replace(/\//g,`__`)}${r}`),a;try{a=await n.generate(o)}catch(t){let r=t instanceof Error?t.message:String(t);if(e.check)throw Error(`kick typegen --check: ${n.id} failed to generate (${r})`,{cause:t});o.log.error(` ${n.id}: typegen failed (${r}) — keeping previous output`),s.push({id:n.id,status:`error`,outFile:i});continue}if(a===null){s.push({id:n.id,status:`skipped`});continue}let l=`${an}${n.id} */\n\n`+a+`
347
- `,u=``;if(F(i)&&(u=await R(i,`utf8`)),u===l){s.push({id:n.id,status:`unchanged`,outFile:i});continue}if(e.check){c.push({id:n.id,outFile:i}),s.push({id:n.id,status:`drifted`,outFile:i});continue}await z(i,l,`utf8`),s.push({id:n.id,status:`written`,outFile:i})}if(c.length>0)throw new he(c);return s}function sn(e){let t=(e.extensions??[]).slice().toSorted().join(`,`),n=(e.exclude??[]).slice().toSorted().join(`,`);return[`root=${e.root}`,`cwd=${e.cwd}`,`extensions=${t}`,`exclude=${n}`,`envFile=${e.envFile??``}`].join(`|`)}function cn(e,t){let n=new Set(t),r=[],i=[],a=new Set;for(let t of e)n.has(t.id)?(i.push(t),a.add(t.id)):r.push(t);return{enabled:r,skipped:i,unknown:[...n].filter(e=>!a.has(e))}}var ln=e({applyDisableFilter:()=>cn,runAllPluginTypegens:()=>G});async function G(e){let{enabled:t,skipped:n,unknown:r}=cn(Tt([...Wi,...e.config?.plugins??[]],e.config?.commands??[]).typegens,e.config?.typegen?.disable??[]);if(!e.silent&&n.length>0)for(let e of n)console.log(` ${e.id}: disabled (typegen.disable)`);if(!e.silent&&r.length>0&&console.warn(` kick typegen: disable list references unknown id(s): ${r.map(e=>`'${e}'`).join(`, `)}. Run \`kick typegen --list\` to see registered ids.`),t.length===0)return[];try{let n=await on({cwd:e.cwd,config:e.config??{},plugins:t,watch:e.watch,check:e.check,changedFiles:e.changedFiles});if(!e.silent&&ae())for(let e of n)console.log(` ${e.id}: ${e.status}`);return n}catch(t){if(t instanceof he||e.check)throw t;if(!e.silent){let e=t instanceof Error?t.message:String(t);console.warn(` kick typegen plugins: skipped (${e})`)}return[]}}function un(e){let t=j(e,`node_modules`,`.bin`),n=process.platform===`win32`;for(let e of[`vue-tsc`,`tsgo`,`tsc`]){let r=n?[`${e}.CMD`,`${e}.cmd`,`${e}.exe`]:[e];for(let i of r){let r=j(t,i);if(F(r))return{cmd:r,args:[`--noEmit`],shell:n,kind:e}}}return null}function dn(e){let t=e.spawnFn??ht,n=null,r=0,i=!1;return{schedule(){if(i)return;let a=++r;n&&=(n.kill(),null);let o=Date.now(),s=t(e.bin.cmd,e.bin.args,{cwd:e.cwd,shell:e.bin.shell,stdio:[`ignore`,`pipe`,`pipe`]});n=s;let c=``;s.stdout?.on(`data`,e=>{c+=e.toString()}),s.stderr?.on(`data`,e=>{c+=e.toString()}),s.on(`error`,()=>{a===r&&(n=null)}),s.on(`close`,t=>{i||a!==r||(n=null,e.onResult({ok:t===0,output:c,durationMs:Date.now()-o,kind:e.bin.kind}))})},dispose(){i=!0,n&&=(n.kill(),null)}}}function fn(e,t=12){let n=e.trim().split(/\r?\n/);return n.length<=t?n.join(`
347
+ `,u=``;if(F(i)&&(u=await R(i,`utf8`)),u===l){s.push({id:n.id,status:`unchanged`,outFile:i});continue}if(e.check){c.push({id:n.id,outFile:i}),s.push({id:n.id,status:`drifted`,outFile:i});continue}await z(i,l,`utf8`),s.push({id:n.id,status:`written`,outFile:i})}if(c.length>0)throw new he(c);return s}function sn(e){let t=(e.extensions??[]).slice().toSorted().join(`,`),n=(e.exclude??[]).slice().toSorted().join(`,`);return[`root=${e.root}`,`cwd=${e.cwd}`,`extensions=${t}`,`exclude=${n}`,`envFile=${e.envFile??``}`].join(`|`)}function cn(e,t){let n=new Set(t),r=[],i=[],a=new Set;for(let t of e)n.has(t.id)?(i.push(t),a.add(t.id)):r.push(t);return{enabled:r,skipped:i,unknown:[...n].filter(e=>!a.has(e))}}var ln=e({applyDisableFilter:()=>cn,runAllPluginTypegens:()=>G});async function G(e){let{enabled:t,skipped:n,unknown:r}=cn(Tt([...Yi,...e.config?.plugins??[]],e.config?.commands??[]).typegens,e.config?.typegen?.disable??[]);if(!e.silent&&n.length>0)for(let e of n)console.log(` ${e.id}: disabled (typegen.disable)`);if(!e.silent&&r.length>0&&console.warn(` kick typegen: disable list references unknown id(s): ${r.map(e=>`'${e}'`).join(`, `)}. Run \`kick typegen --list\` to see registered ids.`),t.length===0)return[];try{let n=await on({cwd:e.cwd,config:e.config??{},plugins:t,watch:e.watch,check:e.check,changedFiles:e.changedFiles});if(!e.silent&&ae())for(let e of n)console.log(` ${e.id}: ${e.status}`);return n}catch(t){if(t instanceof he||e.check)throw t;if(!e.silent){let e=t instanceof Error?t.message:String(t);console.warn(` kick typegen plugins: skipped (${e})`)}return[]}}function un(e){let t=j(e,`node_modules`,`.bin`),n=process.platform===`win32`;for(let e of[`vue-tsc`,`tsgo`,`tsc`]){let r=n?[`${e}.CMD`,`${e}.cmd`,`${e}.exe`]:[e];for(let i of r){let r=j(t,i);if(F(r))return{cmd:r,args:[`--noEmit`],shell:n,kind:e}}}return null}function dn(e){let t=e.spawnFn??ht,n=null,r=0,i=!1;return{schedule(){if(i)return;let a=++r;n&&=(n.kill(),null);let o=Date.now(),s=t(e.bin.cmd,e.bin.args,{cwd:e.cwd,shell:e.bin.shell,stdio:[`ignore`,`pipe`,`pipe`]});n=s;let c=``;s.stdout?.on(`data`,e=>{c+=e.toString()}),s.stderr?.on(`data`,e=>{c+=e.toString()}),s.on(`error`,()=>{a===r&&(n=null)}),s.on(`close`,t=>{i||a!==r||(n=null,e.onResult({ok:t===0,output:c,durationMs:Date.now()-o,kind:e.bin.kind}))})},dispose(){i=!0,n&&=(n.kill(),null)}}}function fn(e,t=12){let n=e.trim().split(/\r?\n/);return n.length<=t?n.join(`
348
348
  `):`${n.slice(0,t).join(`
349
349
  `)}\n… ${n.length-t} more line(s)`}function pn(e){if(typeof e==`boolean`)return e;let t=process.env.KICKJS_WATCH_POLLING;return t===`1`||t===`true`}async function mn(e,t=`127.0.0.1`){let n=await import(`node:inspector`);n.open(e,t,!1);let r=n.url();if(!r)throw Error(`inspector.open() reported no URL`);return r}async function hn(e,t,n={}){t&&(process.env.PORT=t);let r=pn(n.polling),i=process.cwd(),a=await w(i),o=a?.typegen?.schemaValidator??`zod`,s=a?.typegen?.envFile;try{await Ze({cwd:i,allowDuplicates:!0,schemaValidator:o,envFile:s,srcDir:a?.typegen?.srcDir,outDir:a?.typegen?.outDir,assetMap:a?.assetMap,runPlugins:!1})}catch(e){console.warn(` kick typegen: skipped (${e?.message??e})`)}let c=N(i,a?.typegen?.outDir??`.kickjs/types`);try{let e=await G({cwd:i,config:a});await We(c,e,!1)}catch(e){console.warn(` kick typegen: plugin pass skipped (${e?.message??e})`)}let{createRequire:l}=await import(`node:module`),u=l(N(`package.json`)).resolve(`vite`),{createServer:d}=await import(B(u).href);globalThis[ie]=`kick-dev`;let f=await d({configFile:N(`vite.config.ts`),server:{port:t?parseInt(t,10):void 0,...r?{watch:{usePolling:!0,interval:100}}:{}}}),p=n.typecheck??a?.dev?.typecheck??!1,m=null,h=!0;if(p){let e=un(i);e?m=dn({cwd:i,bin:e,onResult:e=>{f.hot.send({type:`custom`,event:`kickjs:typecheck`,data:{ok:e.ok,output:e.output,durationMs:e.durationMs}}),e.ok?h||(h=!0,console.log(` kick typecheck: clean again (${e.kind}, ${e.durationMs}ms)`)):(h=!1,console.warn(`\n kick typecheck (${e.kind}, ${e.durationMs}ms):`),console.warn(fn(e.output).replace(/^/gm,` `)))}}):console.warn(` kick dev: --typecheck requested but neither tsgo (@typescript/native-preview) nor typescript is installed in this project — skipping type checks.`)}let g=de({cwd:i,config:a,emitWarning:e=>{console.warn(e),f.hot.send({type:`custom`,event:`kickjs:typegen-error`,data:{message:e,timestamp:Date.now()}})},onPassComplete:()=>m?.schedule()});f.watcher.on(`add`,e=>g.handleWatchEvent(`add`,e)),f.watcher.on(`unlink`,e=>g.handleWatchEvent(`unlink`,e)),f.watcher.on(`change`,e=>g.handleWatchEvent(`change`,e)),f.watcher.on(`unlinkDir`,e=>g.handleWatchEvent(`unlinkDir`,e)),g.assetSrcRoots.length>0&&f.watcher.add([...g.assetSrcRoots]),await f.listen(),f.printUrls(),console.log(`
350
350
  KickJS dev server running (Vite + @forinda/kickjs-vite)
@@ -361,12 +361,12 @@ describe('${s}', () => {
361
361
  `)}),e.command(`build:assets`).description(`Rebuild the .kickjs-assets.json manifest under the configured outDir (no JS rebuild)`).action(async()=>{let e=await w(process.cwd());if(!e?.assetMap||Object.keys(e.assetMap).length===0){console.log(` No assetMap entries — nothing to build.`);return}console.log(`
362
362
  Building asset map...`);try{await Me(e,{cwd:process.cwd()}),console.log(`
363
363
  Asset build complete.
364
- `)}catch(e){console.error(` ✗ ${e instanceof Error?e.message:String(e)}`),process.exit(1)}}),e.command(`start`).description(`Start production server`).option(`-e, --entry <file>`,`Entry file`,`dist/index.js`).option(`-p, --port <port>`,`Port number`).action(e=>{let t={NODE_ENV:`production`};e.port&&(t.PORT=String(e.port)),xe(e.entry,t)}),e.command(`typecheck`).description(`Type-check the project with its own tsgo/tsc`).option(`--cwd <dir>`,`Directory to type-check`,`.`).option(`--no-typegen`,`Skip refreshing .kickjs/types first`).action(async e=>{let t=N(process.cwd(),e.cwd??`.`);e.typegen!==!1&&await gn(t);let n=un(t);if(!n){console.error(`
364
+ `)}catch(e){console.error(` ✗ ${e instanceof Error?e.message:String(e)}`),process.exit(1)}}),e.command(`start`).description(`Start production server`).option(`-e, --entry <file>`,`Entry file`,`dist/index.js`).option(`-p, --port <port>`,`Port number`).action(e=>{let t={NODE_ENV:`production`};e.port&&(t.PORT=String(e.port)),be(e.entry,t)}),e.command(`typecheck`).description(`Type-check the project with its own tsgo/tsc`).option(`--cwd <dir>`,`Directory to type-check`,`.`).option(`--no-typegen`,`Skip refreshing .kickjs/types first`).action(async e=>{let t=N(process.cwd(),e.cwd??`.`);e.typegen!==!1&&await gn(t);let n=un(t);if(!n){console.error(`
365
365
  No type-checker found. Install one in this project:
366
366
  pnpm add -D typescript (tsc)
367
367
  pnpm add -D @typescript/native-preview (tsgo, faster)
368
368
  `),process.exit(1);return}let r=gt(n.cmd,n.args,{stdio:`inherit`,shell:n.shell,cwd:t});process.exit(r.status??1)}),e.command(`dev:debug`).description(`Start dev server with Node.js inspector attached`).option(`-e, --entry <file>`,`Entry file`,`src/index.ts`).option(`-p, --port <port>`,`Port number`).option(`--inspect-port <port>`,`Inspector port`,`9229`).option(`--inspect-host <host>`,`Inspector bind address (use 0.0.0.0 to reach it from outside a container)`,`127.0.0.1`).action(async e=>{let t=Number(e.inspectPort??`9229`),n=e.inspectHost??`127.0.0.1`;[`127.0.0.1`,`localhost`,`::1`].includes(n)||console.warn(` WARNING: the debugger is bound to ${n}, not loopback. Anyone who can\n reach port ${t} can run code in this process. Use it on a trusted\n network only, and prefer publishing the port from your container instead.`);let r;try{r=await mn(t,n)}catch(e){console.error(`\n Could not open the inspector on ${t}: ${e.message??e}\n Another process may already hold it — try --inspect-port <port>.`),process.exit(1);return}console.log(` Debugger: ${r}`);try{await hn(e.entry,e.port)}catch(e){console.error(`
369
- Dev server (debug) failed:`,e.message??e),process.exit(1)}})}function vn(){try{let e=A(_t(import.meta.url));return JSON.parse(I(j(e,`..`,`package.json`),`utf-8`)).version??`unknown`}catch{return`unknown`}}const yn=new Set(Object.values(Se).filter(e=>e.deprecated).map(e=>e.pkg));function bn(e){let t=j(e,`package.json`);if(!F(t))return[];let n;try{n=JSON.parse(I(t,`utf-8`))}catch{return[]}let r={...n.dependencies,...n.devDependencies};return Object.keys(r).filter(e=>e===`@forinda/kickjs`||e.startsWith(`@forinda/kickjs-`)).toSorted().map(t=>{let n=null,i=j(e,`node_modules`,...t.split(`/`),`package.json`);if(F(i))try{n=JSON.parse(I(i,`utf-8`)).version??null}catch{}return{name:t,installed:n,declared:r[t]??null,deprecated:yn.has(t)}})}function xn(e){let t=e;for(;;){if(F(j(t,`package.json`)))return t;let e=A(t);if(e===t)return null;t=e}}function Sn(e){e.command(`info`).description(`Print system and framework info`).action(()=>{let e=[``,` KickJS CLI v${vn()}`,``,` System:`,` OS: ${bt()} ${xt()} (${yt()})`,` Node: ${process.version}`],t=xn(process.cwd()),n=t?bn(t):[];if(!t)e.push(``,` Packages: (not inside a project — no package.json found)`);else if(n.length===0)e.push(``,` Packages: (no @forinda/kickjs* dependencies in ${t})`);else{e.push(``,` Packages:`);let t=Math.max(...n.map(e=>e.name.length));for(let r of n){let n=r.installed??`${r.declared??`?`} (declared — not installed)`,i=r.deprecated?" [DEPRECATED — see `kick add --list --all`]":``;e.push(` ${r.name.padEnd(t+2)} ${n}${i}`)}}e.push(``),console.log(e.join(`
369
+ Dev server (debug) failed:`,e.message??e),process.exit(1)}})}function vn(){try{let e=A(_t(import.meta.url));return JSON.parse(I(j(e,`..`,`package.json`),`utf-8`)).version??`unknown`}catch{return`unknown`}}const yn=new Set(Object.values(Ce).filter(e=>e.deprecated).map(e=>e.pkg));function bn(e){let t=j(e,`package.json`);if(!F(t))return[];let n;try{n=JSON.parse(I(t,`utf-8`))}catch{return[]}let r={...n.dependencies,...n.devDependencies};return Object.keys(r).filter(e=>e===`@forinda/kickjs`||e.startsWith(`@forinda/kickjs-`)).toSorted().map(t=>{let n=null,i=j(e,`node_modules`,...t.split(`/`),`package.json`);if(F(i))try{n=JSON.parse(I(i,`utf-8`)).version??null}catch{}return{name:t,installed:n,declared:r[t]??null,deprecated:yn.has(t)}})}function xn(e){let t=e;for(;;){if(F(j(t,`package.json`)))return t;let e=A(t);if(e===t)return null;t=e}}function Sn(e){e.command(`info`).description(`Print system and framework info`).action(()=>{let e=[``,` KickJS CLI v${vn()}`,``,` System:`,` OS: ${bt()} ${xt()} (${yt()})`,` Node: ${process.version}`],t=xn(process.cwd()),n=t?bn(t):[];if(!t)e.push(``,` Packages: (not inside a project — no package.json found)`);else if(n.length===0)e.push(``,` Packages: (no @forinda/kickjs* dependencies in ${t})`);else{e.push(``,` Packages:`);let t=Math.max(...n.map(e=>e.name.length));for(let r of n){let n=r.installed??`${r.declared??`?`} (declared — not installed)`,i=r.deprecated?" [DEPRECATED — see `kick add --list --all`]":``;e.push(` ${r.name.padEnd(t+2)} ${n}${i}`)}}e.push(``),console.log(e.join(`
370
370
  `))})}const{bold:K,dim:q,green:Cn,red:wn,yellow:Tn,blue:En}=m;function Dn(e){let t=Math.floor(e/86400),n=Math.floor(e%86400/3600),r=Math.floor(e%3600/60),i=e%60,a=[];return t&&a.push(`${t}d`),n&&a.push(`${n}h`),r&&a.push(`${r}m`),a.push(`${i}s`),a.join(` `)}async function On(e){let t=await fetch(e,{signal:AbortSignal.timeout(5e3)});if(!t.ok)throw Error(`${t.status} ${t.statusText}`);return t.json()}async function J(e,t){try{return await On(`${e}${t}`)}catch{return null}}async function kn(e){let[t,n,r,i,a]=await Promise.all([J(e,`/health`),J(e,`/metrics`),J(e,`/routes`),J(e,`/container`),J(e,`/ws`)]);return{health:t,metrics:n,routes:r,container:i,ws:a}}function An(e,t){let{health:n,metrics:r,routes:i,container:a,ws:o}=t,s=q(`─`.repeat(60));if(console.log(),console.log(K(` KickJS Inspector`)+q(` → ${e}`)),console.log(s),n){let e=n.status===`healthy`?Cn(`● healthy`):wn(`● `+n.status);console.log(` ${K(`Health:`)} ${e}`)}else console.log(` ${K(`Health:`)} ${wn(`● unreachable`)}`);if(r){let e=((r.errorRate??0)*100).toFixed(1),t=r.errorRate>.1?wn:r.errorRate>0?Tn:Cn;console.log(` ${K(`Uptime:`)} ${Dn(r.uptimeSeconds)}`),console.log(` ${K(`Requests:`)} ${r.requests}`),console.log(` ${K(`Errors:`)} ${r.serverErrors} server, ${r.clientErrors??0} client ${q(`(`)}${t(e+`%`)}${q(`)`)}`)}if(a&&console.log(` ${K(`DI:`)} ${a.count} bindings`),o&&o.enabled&&console.log(` ${K(`WS:`)} ${o.connections??0} connections, ${o.namespaces??0} namespaces`),i?.routes?.length){console.log(),console.log(K(` Routes`)),console.log(s),console.log(` ${q(`METHOD`)} ${q(`PATH`.padEnd(36))} ${q(`CONTROLLER`)}`);for(let e of i.routes){let t=e.path.length>36?e.path.slice(0,33)+`...`:e.path.padEnd(36);console.log(` ${c(e.method)} ${t} ${En(e.controller)}.${q(e.handler)}`)}}console.log(s),console.log()}function jn(e){e.command(`inspect [url]`).description(`Connect to a running KickJS app and display debug info`).option(`-p, --port <port>`,`Override port`).option(`-w, --watch`,`Poll every 5 seconds`).option(`-j, --json`,`Output raw JSON`).action(async(e,t)=>{let n=e??`http://localhost:3000`;if(t.port)try{let e=new URL(n);e.port=t.port,n=e.origin}catch{n=`http://localhost:${t.port}`}let r=`${n.replace(/\/$/,``)}/_debug`,i=async()=>{try{let e=await kn(r);t.json?console.log(JSON.stringify(e,null,2)):An(n,e)}catch(e){t.json?console.log(JSON.stringify({error:String(e)})):(console.error(wn(` ✖ Could not connect to ${n}`)),console.error(q(` ${e instanceof Error?e.message:String(e)}`))),t.watch||(process.exitCode=1)}};if(t.watch){let e=async()=>{process.stdout.write(`\x1B[2J\x1B[H`),await i()};await e(),setInterval(e,5e3)}else await i()})}function Y(e,t){let n=e.toLowerCase();return t.every(e=>n.includes(e.toLowerCase()))}function X(e,t){let n=e.toLowerCase();return t.some(e=>n.includes(e.toLowerCase()))}const Mn=[{match(e,t){let n=Y(e,[`config`,`get`])&&X(e,[`undefined`,`null`]),r=e.includes(`@Value`)&&X(e,[`undefined`,`is not defined`]);return!n&&!r?null:X(e,[`vitest`,`createTestApp`,`__tests__`,`.test.`,`.spec.`])?{confidence:85,diagnosis:{id:`env-schema-not-registered-in-test`,title:`ConfigService.get() returns undefined inside a test`,explanation:`The env schema is registered by a module-load side effect in
371
371
  src/config/index.ts, and src/index.ts imports it before bootstrap().
372
372
  Tests never load src/index.ts — \`createTestApp\` builds the app
@@ -676,7 +676,7 @@ server.on('exit', () => {
676
676
  Cancelled.
677
677
  `);return}await ft(l,{recursive:!0,force:!0}),console.log(` Deleted: ${l}`);let u=j(n,`index.ts`);if(await r(u)){let e=await R(u,`utf-8`),t=e,n=RegExp(`^import\\s*\\{\\s*${ue(s)}Module\\s*\\}\\s*from\\s*['"][^'"]*${ue(c)}(?:/[^'"]*)?['"].*\\n?`,`gm`);e=e.replace(n,``),e=ir(e,s),e=e.replace(/\n{3,}/g,`
678
678
 
679
- `),e!==t&&(await z(u,e,`utf-8`),console.log(` Unregistered: ${s}Module from ${u}`))}console.log(`\n Module '${c}' removed.\n`)}function or(e){e.command(`remove`).alias(`rm`).description(`Remove generated code`).command(`module <names...>`).description(`Remove one or more modules (e.g. kick rm module user task)`).option(`--modules-dir <dir>`,`Modules directory`).option(`--no-pluralize`,`Use singular module name`).option(`-f, --force`,`Skip confirmation prompt`).action(async(e,t)=>{let n=await w(process.cwd()),r=T(n),i=t.modulesDir??r.dir??`src/modules`,a=t.pluralize===!1?!1:r.pluralize??!0;for(let n of e)await ar({name:n,modulesDir:N(i),force:t.force,pluralize:a})})}function sr(e){if(e!==void 0){if(e===`false`||e===`off`||e===`none`)return!1;if(e===`zod`)return`zod`;if(e===`kickjs-schema`||e===`schema`)return`kickjs-schema`;console.warn(` kick typegen: unknown --schema-validator '${e}' (supported: 'zod', 'kickjs-schema', 'false'). Falling back to project config.`)}}function cr(e){if(e!==void 0)return e===`false`||e===`off`||e===`none`?!1:e}function lr(e){e.command(`typegen`).description(`Generate type-safe DI registry and module types into .kickjs/types/`).option(`-w, --watch`,`Watch source files and regenerate on change`).option(`-s, --src <dir>`,`Source directory to scan`,`src`).option(`-o, --out <dir>`,`Output directory`,`.kickjs/types`).option(`--silent`,`Suppress output`).option(`--allow-duplicates`,`Auto-namespace duplicate class names instead of failing (use with caution)`).option(`--schema-validator <name>`,`Schema validator for body/query/params typing (currently 'zod' or 'false')`).option(`--env-file <path>`,`Path to env schema file for KickEnv typing (default 'src/env.ts'; pass 'false' to disable)`).option(`--check`,`CI gate: exit non-zero if any generated file in .kickjs/types/ is out of date (routes, env, db, assets, adopter plugins) instead of writing it`).option(`--fix`,`Patch module import.meta.glob() calls to cover decorated classes that aren't loaded by any glob (orphans)`).option(`--list`,"List every registered typegen plugin id (use to populate `typegen.disable`)").option(`--no-cache`,`Disable the persistent scan cache; re-read + re-extract every file from cold`).action(async e=>{let t=E(process.cwd()),n=await w(t);if(e.list){let{mergeCliPlugins:e}=await import(`./plugin-B8fmVbk8.mjs`),{builtinCliPlugins:t}=await import(`./builtins-D4pwODzu.mjs`),r=e([...t,...n?.plugins??[]],n?.commands??[]),i=new Set(n?.typegen?.disable??[]);if(r.typegens.length===0){console.log(` No typegen plugins registered.`);return}let a=Math.max(...r.typegens.map(e=>e.id.length));console.log(`
679
+ `),e!==t&&(await z(u,e,`utf-8`),console.log(` Unregistered: ${s}Module from ${u}`))}console.log(`\n Module '${c}' removed.\n`)}function or(e){e.command(`remove`).alias(`rm`).description(`Remove generated code`).command(`module <names...>`).description(`Remove one or more modules (e.g. kick rm module user task)`).option(`--modules-dir <dir>`,`Modules directory`).option(`--no-pluralize`,`Use singular module name`).option(`-f, --force`,`Skip confirmation prompt`).action(async(e,t)=>{let n=await w(process.cwd()),r=T(n),i=t.modulesDir??r.dir??`src/modules`,a=t.pluralize===!1?!1:r.pluralize??!0;for(let n of e)await ar({name:n,modulesDir:N(i),force:t.force,pluralize:a})})}function sr(e){if(e!==void 0){if(e===`false`||e===`off`||e===`none`)return!1;if(e===`zod`)return`zod`;if(e===`kickjs-schema`||e===`schema`)return`kickjs-schema`;console.warn(` kick typegen: unknown --schema-validator '${e}' (supported: 'zod', 'kickjs-schema', 'false'). Falling back to project config.`)}}function cr(e){if(e!==void 0)return e===`false`||e===`off`||e===`none`?!1:e}function lr(e){e.command(`typegen`).description(`Generate type-safe DI registry and module types into .kickjs/types/`).option(`-w, --watch`,`Watch source files and regenerate on change`).option(`-s, --src <dir>`,`Source directory to scan`,`src`).option(`-o, --out <dir>`,`Output directory`,`.kickjs/types`).option(`--silent`,`Suppress output`).option(`--allow-duplicates`,`Auto-namespace duplicate class names instead of failing (use with caution)`).option(`--schema-validator <name>`,`Schema validator for body/query/params typing (currently 'zod' or 'false')`).option(`--env-file <path>`,`Path to env schema file for KickEnv typing (default 'src/env.ts'; pass 'false' to disable)`).option(`--check`,`CI gate: exit non-zero if any generated file in .kickjs/types/ is out of date (routes, env, db, assets, adopter plugins) instead of writing it`).option(`--fix`,`Patch module import.meta.glob() calls to cover decorated classes that aren't loaded by any glob (orphans)`).option(`--list`,"List every registered typegen plugin id (use to populate `typegen.disable`)").option(`--no-cache`,`Disable the persistent scan cache; re-read + re-extract every file from cold`).action(async e=>{let t=E(process.cwd()),n=await w(t);if(e.list){let{mergeCliPlugins:e}=await import(`./plugin-Dighdqh-.mjs`),{builtinCliPlugins:t}=await import(`./builtins-CfAXBoIM.mjs`),r=e([...t,...n?.plugins??[]],n?.commands??[]),i=new Set(n?.typegen?.disable??[]);if(r.typegens.length===0){console.log(` No typegen plugins registered.`);return}let a=Math.max(...r.typegens.map(e=>e.id.length));console.log(`
680
680
  Registered typegen plugins:
681
681
  `);for(let e of r.typegens){let t=i.has(e.id)?` (disabled)`:``,n=`${e.id.replace(/\//g,`__`)}${e.outExtension??`.d.ts`}`;console.log(` ${e.id.padEnd(a+2)}→ .kickjs/types/${n}${t}`),console.log(` ${` `.repeat(a+2)} watches: ${e.inputs.join(`, `)||`(none)`}`)}console.log(`
682
682
  Disable one in kick.config.ts:
@@ -703,14 +703,19 @@ server.on('exit', () => {
703
703
  Always commit before running with --apply.
704
704
  `),process.exit(1));let i=await w(process.cwd()),a=T(i),o=N(e.modulesDir??a.dir??`src/modules`),s;e.target===`define`||e.target===`class`?s=e.target:e.target===void 0?s=a.style??`define`:(console.error(`\n ${m.red(`Error:`)} --target must be 'define' or 'class' (got '${e.target}').\n`),process.exit(1));let c=m.dim(`→ ${s}`),l=r?m.dim(`(dry-run)`):m.bold(`(applying)`);console.log(`\n ${m.bold(`kick codemod modules`)} ${c} ${l}`),console.log(` modulesDir: ${m.dim(o)}\n`);let u=e.backup!==!1&&!r,d=await Bt(o,{dryRun:r,target:s,backup:u});if(d.backupDir){let e=d.backupDir;console.log(` ${m.green(`✓`)} backup: ${m.dim(e)}\n ${m.dim(`(restore: rm -rf <modulesDir> && mv "<backup>" <modulesDir>)`)}\n`)}else!r&&e.backup===!1&&console.log(` ${m.dim(`(--no-backup — skipping snapshot)`)}\n`);let f=0,p=0;for(let e of d.files)if(e.status===`migrated`)f++,console.log(` ${m.green(`✓`)} ${e.path}`);else{p++;let t=m.dim(`(${e.reason??`skipped`})`);console.log(` ${m.dim(`-`)} ${e.path} ${t}`)}if(console.log(),d.indexStatus===`migrated`)console.log(` ${m.green(`✓`)} ${d.indexPath}`);else if(d.indexStatus===`skipped`){let e=m.dim(`(${d.indexReason??`skipped`})`);console.log(` ${m.dim(`-`)} ${d.indexPath} ${e}`)}else console.log(` ${m.dim(`-`)} ${d.indexPath} ${m.dim(`(not found)`)}`);let h=r?m.dim(` (dry-run — pass --apply to write)`):``;console.log(`\n ${m.bold(String(f))} migrated, ${m.bold(String(p))} skipped${h}\n`)})}function jr(e,t=F){let n=A(e);return(t(N(n,`pnpm-workspace.yaml`))||t(N(n,`package.json`)))&&t(N(n,`web`,`package.json`))?{staticDir:`../web/dist`,siteRoot:`..`,apiPath:`/api`}:{siteRoot:`.`,apiPath:``}}function Mr(e,t,n){let r=jr(t,n),i=e?.staticDir===!1?void 0:e?.staticDir??r.staticDir;return{entry:e?.entry??`src/serverless.ts`,outDir:e?.outDir??`dist/serverless`,staticDir:i,siteRoot:e?.siteRoot??r.siteRoot,publishDir:e?.publishDir??`dist/public`,apiPath:e?.apiPath??r.apiPath,external:e?.external??[`valibot`,`yup`],vercelRuntime:e?.vercelRuntime??`nodejs22.x`}}function Nr(e,t){return`import { handler } from '${e}'
705
705
 
706
- export default (request) => handler.fetch(request)
706
+ // Netlify's context carries waitUntil, so ctx.waitUntil() work finishes after the response.
707
+ export default (request, context) => handler.fetch(request, context)
707
708
 
708
709
  export const config = {
709
710
  path: '${t}/*',
710
711
  }
711
- `}function Pr(e){return/^\s*publish\s*=\s*["']([^"']+)["']/m.exec(e)?.[1]?.replace(/^\.\//,``).replace(/\/+$/,``)}function Fr(e,t){let n=[{handle:`filesystem`},{src:`^${e}/(.*)$`,dest:`/api`}];return t&&n.push({src:`^/(.*)$`,dest:`/index.html`}),n}function Ir(e){let t=e=>{if(typeof e==`string`)return e;if(!e||typeof e!=`object`)return;let n=e;for(let e of[`import`,`module`,`node`,`default`]){let r=t(n[e]);if(r)return r}},n=e.exports;return t(typeof n==`string`||Array.isArray(n)?n:n?.[`.`]??n)??e.module??e.main}async function Lr(e,t){let{createRequire:n}=await import(`node:module`),r=n(N(e,`package.json`)),i;try{i=r.resolve(`${t}/package.json`)}catch{i=N(e,`node_modules`,t,`package.json`)}if(!F(i))throw Error(`${t} is not installed in this project. Run: pnpm add -D vite unplugin-swc @forinda/kickjs-vite`);let a=Ir(JSON.parse(I(i,`utf-8`)));if(!a)throw Error(`${t} has no importable entry point`);return import(B(N(A(i),a)).href)}async function Rr(e,t,n){let r=N(e,t.entry);if(!F(r))throw Error(`${t.entry} not found. The serverless entry exports \`handler = createHandler({ modules })\` — see the Serverless guide.`);let{build:i}=await Lr(e,`vite`),{default:a}=await Lr(e,`unplugin-swc`),{devtoolsFlagPlugin:o,devtoolsStripPlugin:s}=await Lr(e,`@forinda/kickjs-vite`);await i({configFile:!1,root:e,logLevel:`warn`,oxc:!1,plugins:[a.vite(),o(),s()],resolve:{alias:{"@":N(e,`src`)}},ssr:{noExternal:!0,target:`node`},build:{ssr:!0,target:`node20`,outDir:N(e,t.outDir),emptyOutDir:!0,minify:!1,rollupOptions:{input:r,external:t.external.filter(t=>!F(N(e,`node_modules`,t))),output:{format:`esm`,entryFileNames:`server.mjs`,codeSplitting:!1}}}});let c=N(e,t.outDir,`server.mjs`);return n(`bundled ${M(process.cwd(),c)}`),c}function zr(e,t){let n=t.projectRoot,r=()=>Mr(t.config?.deploy,n);e.command(`build:netlify`).description(`Bundle the serverless entry and write the Netlify function`).action(async()=>{let e=r(),i=await Rr(n,e,t.log),a=N(n,e.siteRoot),o=N(a,`.netlify/v1/functions`);ot(o,{recursive:!0});let s=M(o,i).split(P).join(`/`);L(N(o,`api.mjs`),Nr(s,e.apiPath)),t.log(`wrote ${M(process.cwd(),N(o,`api.mjs`))}`);let c=e.staticDir??e.publishDir;e.staticDir||(ot(N(n,c),{recursive:!0}),t.log(`publish directory ready at ${M(process.cwd(),N(n,c))}`));let l=N(a,`netlify.toml`);if(F(l)){let e=Pr(I(l,`utf-8`)),r=M(a,N(n,c)).split(P).join(`/`);e!==void 0&&e!==r&&t.log(`warning: netlify.toml publishes "${e}", but this build fills "${r}". Update netlify.toml, or set \`deploy.publishDir\` / \`deploy.staticDir\` to match.`)}}),e.command(`build:vercel`).description(`Bundle the serverless entry and write .vercel/output (Build Output API v3)`).action(async()=>{let e=r(),i=await Rr(n,e,t.log),a=N(n,e.siteRoot),o=e.staticDir?N(n,e.staticDir):void 0,s=N(a,`.vercel/output`),c=N(s,`functions/api.func`);if(ct(s,{recursive:!0,force:!0}),ot(c,{recursive:!0}),at(i,N(c,`server.mjs`)),L(N(c,`index.mjs`),`import { handler } from './server.mjs'
712
- export default handler.node
713
- `),L(N(c,`.vc-config.json`),`${JSON.stringify({runtime:e.vercelRuntime,handler:`index.mjs`,launcherType:`Nodejs`,supportsResponseStreaming:!0},null,2)}\n`),o){if(!F(o))throw Error(`build:vercel: ${e.staticDir} does not exist — build the frontend first`);at(o,N(s,`static`),{recursive:!0})}L(N(s,`config.json`),`${JSON.stringify({version:3,routes:Fr(e.apiPath,!!o)},null,2)}\n`),t.log(`wrote ${M(process.cwd(),s)}`)})}const Br=()=>({id:`kick/assets`,inputs:[`kick.config.ts`,`kick.config.js`,`kick.config.mjs`],async generate(e){let t=k.resolve(e.cwd,`kick.config.ts`);if(!F(t))return null;let n=await w(e.cwd);if(!n?.assetMap)return null;let r=Le(n.assetMap,e.cwd);return r.count===0?null:qe(r)}}),Vr="/* eslint-disable */\n// AUTO-GENERATED by `kick typegen`. DO NOT EDIT.\n// Re-run with `kick typegen` or rely on `kick dev` to refresh.\n";function Hr(e,t,n,r={}){if(e.length===0)return`${Vr}
712
+ `}function Pr(){return`import { handler } from './server.mjs'
713
+
714
+ const requestContext = () => globalThis[Symbol.for('@vercel/request-context')]?.get?.()
715
+
716
+ export default (req, res) => handler.node(req, res, requestContext())
717
+ `}function Fr(e){return/^\s*publish\s*=\s*["']([^"']+)["']/m.exec(e)?.[1]?.replace(/^\.\//,``).replace(/\/+$/,``)}function Ir(e,t,n=!1){let r=[{handle:`filesystem`},{src:`^${e}/(.*)$`,dest:`/api`}];return n&&e!==``&&r.push({src:`^/_kick/(.*)$`,dest:`/api`}),t&&r.push({src:`^/(.*)$`,dest:`/index.html`}),r}function Lr(e,t){let n;try{n=vt(t,e).program}catch{return[]}let r=[],i=t=>e.slice(0,t).split(`
718
+ `).length,a=e=>{if(!e||typeof e!=`object`)return;if(Array.isArray(e))return e.forEach(a);let n=e,o=n.expression;if(n.type===`Decorator`&&o?.type===`CallExpression`&&o.callee?.type===`Identifier`&&o.callee.name===`Cron`){let[e,a]=o.arguments??[],s=e?.type===`Literal`&&typeof e.value==`string`?e.value:e?.type===`TemplateLiteral`&&e.expressions.length===0?e.quasis[0]?.value?.cooked:void 0;r.push({file:t,line:i(n.start??0),expression:s,timezone:a?.type===`ObjectExpression`&&a.properties.some(e=>(e.key?.name??e.key?.value)===`timezone`)})}for(let e in n)e!==`parent`&&a(n[e])};return a(n),r}function Rr(e){let t=N(e,`src`);return F(t)?st(t,{recursive:!0,encoding:`utf-8`}).filter(e=>/\.m?ts$/.test(e)&&!/\.(test|spec|d)\.m?ts$/.test(e)).flatMap(e=>{let n=I(N(t,e),`utf-8`);return n.includes(`@Cron`)?Lr(n,`src/${e}`):[]}):[]}function zr(e){let t=2166136261;for(let n of e.trim().replace(/\s+/g,` `))t^=n.codePointAt(0),t=Math.imul(t,16777619)>>>0;return t.toString(36)}function Br(e){let t=[],n=new Map;for(let r of e){let e=`${r.file}:${r.line}`;if(r.expression===void 0){t.push(`${e}: @Cron expression is not a string literal, so it has no Vercel cron entry`);continue}r.timezone&&t.push(`${e}: Vercel crons run in UTC — the timezone option is ignored there`);let i=r.expression.trim().replace(/\s+/g,` `);if(i.split(` `).length!==5){t.push(`${e}: Vercel crons need a five-field expression, so it has no Vercel cron entry`);continue}n.set(zr(i),i)}return{crons:[...n].map(([e,t])=>({path:`/_kick/cron/${e}`,schedule:t})),warnings:t}}function Vr(e){let t=e=>{if(typeof e==`string`)return e;if(!e||typeof e!=`object`)return;let n=e;for(let e of[`import`,`module`,`node`,`default`]){let r=t(n[e]);if(r)return r}},n=e.exports;return t(typeof n==`string`||Array.isArray(n)?n:n?.[`.`]??n)??e.module??e.main}async function Hr(e,t){let{createRequire:n}=await import(`node:module`),r=n(N(e,`package.json`)),i;try{i=r.resolve(`${t}/package.json`)}catch{i=N(e,`node_modules`,t,`package.json`)}if(!F(i))throw Error(`${t} is not installed in this project. Run: pnpm add -D vite unplugin-swc @forinda/kickjs-vite`);let a=Vr(JSON.parse(I(i,`utf-8`)));if(!a)throw Error(`${t} has no importable entry point`);return import(B(N(A(i),a)).href)}async function Ur(e,t,n){let r=N(e,t.entry);if(!F(r))throw Error(`${t.entry} not found. The serverless entry exports \`handler = createHandler({ modules })\` — see the Serverless guide.`);let{build:i}=await Hr(e,`vite`),{default:a}=await Hr(e,`unplugin-swc`),{devtoolsFlagPlugin:o,devtoolsStripPlugin:s}=await Hr(e,`@forinda/kickjs-vite`);await i({configFile:!1,root:e,logLevel:`warn`,oxc:!1,plugins:[a.vite(),o(),s()],resolve:{alias:{"@":N(e,`src`)}},ssr:{noExternal:!0,target:`node`},build:{ssr:!0,target:`node20`,outDir:N(e,t.outDir),emptyOutDir:!0,minify:!1,rollupOptions:{input:r,external:t.external.filter(t=>!F(N(e,`node_modules`,t))),output:{format:`esm`,entryFileNames:`server.mjs`,codeSplitting:!1}}}});let c=N(e,t.outDir,`server.mjs`);return n(`bundled ${M(process.cwd(),c)}`),c}function Wr(e,t){let n=t.projectRoot,r=()=>Mr(t.config?.deploy,n);e.command(`build:netlify`).description(`Bundle the serverless entry and write the Netlify function`).action(async()=>{let e=r(),i=await Ur(n,e,t.log),a=N(n,e.siteRoot),o=Rr(n);o.length>0&&t.log(`warning: ${o.length} @Cron job(s) found — Netlify has no cron trigger for them, so they will not run. Use Netlify scheduled functions, or deploy to Vercel or Workers.`);let s=N(a,`.netlify/v1/functions`);ot(s,{recursive:!0});let c=M(s,i).split(P).join(`/`);L(N(s,`api.mjs`),Nr(c,e.apiPath)),t.log(`wrote ${M(process.cwd(),N(s,`api.mjs`))}`);let l=e.staticDir??e.publishDir;e.staticDir||(ot(N(n,l),{recursive:!0}),t.log(`publish directory ready at ${M(process.cwd(),N(n,l))}`));let u=N(a,`netlify.toml`);if(F(u)){let e=Fr(I(u,`utf-8`)),r=M(a,N(n,l)).split(P).join(`/`);e!==void 0&&e!==r&&t.log(`warning: netlify.toml publishes "${e}", but this build fills "${r}". Update netlify.toml, or set \`deploy.publishDir\` / \`deploy.staticDir\` to match.`)}}),e.command(`build:vercel`).description(`Bundle the serverless entry and write .vercel/output (Build Output API v3)`).action(async()=>{let e=r(),i=await Ur(n,e,t.log),a=N(n,e.siteRoot),o=e.staticDir?N(n,e.staticDir):void 0,s=N(a,`.vercel/output`),c=N(s,`functions/api.func`);if(ct(s,{recursive:!0,force:!0}),ot(c,{recursive:!0}),at(i,N(c,`server.mjs`)),L(N(c,`index.mjs`),Pr()),L(N(c,`.vc-config.json`),`${JSON.stringify({runtime:e.vercelRuntime,handler:`index.mjs`,launcherType:`Nodejs`,supportsResponseStreaming:!0},null,2)}\n`),o){if(!F(o))throw Error(`build:vercel: ${e.staticDir} does not exist — build the frontend first`);at(o,N(s,`static`),{recursive:!0})}let{crons:l,warnings:u}=Br(Rr(n));for(let e of u)t.log(`warning: ${e}`);let d={version:3,routes:Ir(e.apiPath,!!o,l.length>0),...l.length>0?{crons:l}:{}};L(N(s,`config.json`),`${JSON.stringify(d,null,2)}\n`),t.log(`wrote ${M(process.cwd(),s)}`),l.length>0&&t.log(`${l.length} cron schedule(s) written. Set CRON_SECRET in the Vercel project — the trigger is not mounted without it.`)})}const Gr=()=>({id:`kick/assets`,inputs:[`kick.config.ts`,`kick.config.js`,`kick.config.mjs`],async generate(e){let t=k.resolve(e.cwd,`kick.config.ts`);if(!F(t))return null;let n=await w(e.cwd);if(!n?.assetMap)return null;let r=Le(n.assetMap,e.cwd);return r.count===0?null:qe(r)}}),Kr="/* eslint-disable */\n// AUTO-GENERATED by `kick typegen`. DO NOT EDIT.\n// Re-run with `kick typegen` or rely on `kick dev` to refresh.\n";function qr(e,t,n,r={}){if(e.length===0)return`${Kr}
714
719
  // (no routes discovered yet — annotate a controller method with
715
720
  // @Get/@Post/@Put/@Delete/@Patch and re-run \`kick typegen\`)
716
721
  declare global {
@@ -727,14 +732,14 @@ declare global {
727
732
 
728
733
  /** Empty until the first route exists — see kick typegen. */
729
734
  export const kickRpc = {} as const
730
- `;let i=new Map;for(let t of e){let e=i.get(t.controller)??[];e.push(t),i.set(t.controller,e)}let a=new Map,o=new Map,s=e=>{let t=`${e.filePath}::${e.controller}`,n=o.get(t);return n||(n=`_C${o.size}`,o.set(t,n)),n},c=(e,i,o)=>{let s=Kr(e,i.filePath,t,n,a);if(!s){if(e&&n!==!1){let t=o===`params`?`URL-pattern params`:o===`query`&&i.queryFilterable!==null?`the @ApiQueryParams-derived query shape`:`'unknown'`;r.onWarn?.(`route ${i.controller}.${i.method} (${i.httpMethod} ${i.path}): ${o} schema '${e.identifier}' could not be statically resolved — falling back to ${t}. Export the schema from the controller file or import it with a static specifier.`)}return null}return n===`kickjs-schema`?`import('@forinda/kickjs-schema').InferSchemaOutput<typeof ${s}>`:`import('zod').infer<typeof ${s}>`},l=[];for(let[e,t]of i){let n=[` interface ${e} {`];for(let e of t){let t=e.pathParams.length>0?`{ ${e.pathParams.map(e=>`${e}: string`).join(`; `)} }`:`{}`,r=c(e.bodySchema,e,`body`),i=c(e.querySchema,e,`query`),a=c(e.paramsSchema,e,`params`)??t,o=r??`unknown`,l=i??Wr(e),u=c(e.responseSchema??null,e,`response`),d=s(e),f=u??`import('@forinda/kickjs').InferHandlerResponse<${d}['${e.method}']>`,p=Gr(e);n.push(` /**`,` * ${e.httpMethod} ${e.path}`,...p.map(e=>` * ${e}`),` */`,` ${e.method}: {`,` params: ${a}`,` body: ${o}`,` query: ${l}`,` response: ${f}`,` contextKeys: ${Ur(e)}`,` }`)}n.push(` }`),l.push(n.join(`
735
+ `;let i=new Map;for(let t of e){let e=i.get(t.controller)??[];e.push(t),i.set(t.controller,e)}let a=new Map,o=new Map,s=e=>{let t=`${e.filePath}::${e.controller}`,n=o.get(t);return n||(n=`_C${o.size}`,o.set(t,n)),n},c=(e,i,o)=>{let s=Zr(e,i.filePath,t,n,a);if(!s){if(e&&n!==!1){let t=o===`params`?`URL-pattern params`:o===`query`&&i.queryFilterable!==null?`the @ApiQueryParams-derived query shape`:`'unknown'`;r.onWarn?.(`route ${i.controller}.${i.method} (${i.httpMethod} ${i.path}): ${o} schema '${e.identifier}' could not be statically resolved — falling back to ${t}. Export the schema from the controller file or import it with a static specifier.`)}return null}return n===`kickjs-schema`?`import('@forinda/kickjs-schema').InferSchemaOutput<typeof ${s}>`:`import('zod').infer<typeof ${s}>`},l=[];for(let[e,t]of i){let n=[` interface ${e} {`];for(let e of t){let t=e.pathParams.length>0?`{ ${e.pathParams.map(e=>`${e}: string`).join(`; `)} }`:`{}`,r=c(e.bodySchema,e,`body`),i=c(e.querySchema,e,`query`),a=c(e.paramsSchema,e,`params`)??t,o=r??`unknown`,l=i??Yr(e),u=c(e.responseSchema??null,e,`response`),d=s(e),f=u??`import('@forinda/kickjs').InferHandlerResponse<${d}['${e.method}']>`,p=Xr(e);n.push(` /**`,` * ${e.httpMethod} ${e.path}`,...p.map(e=>` * ${e}`),` */`,` ${e.method}: {`,` params: ${a}`,` body: ${o}`,` query: ${l}`,` response: ${f}`,` contextKeys: ${Jr(e)}`,` }`)}n.push(` }`),l.push(n.join(`
731
736
  `))}let u=[],d=new Set,f=new Set;i.has(`Api`)&&r.onWarn?.(`controller class 'Api' collides with the reserved KickRoutes.Api client map — its interface declaration-merges into the flat route map. Rename the controller.`);for(let[e,t]of i)for(let n of t){let t=`${n.httpMethod} ${n.mountedPath??n.path}`;if(d.has(t)){r.onWarn?.(`duplicate route '${t}' (${e}.${n.method}) — two handlers claim the same verb+path at runtime. KickRoutes.Api keeps the first (scan order, which may not match runtime dispatch); resolve the conflict in the modules.`);continue}d.add(t),f.add(`${e}.${n.method}`),u.push(` '${t}': ${e}['${n.method}']`)}let p=[` interface Api {`,...u,` }`].join(`
732
- `);l.push(p);let m=[],h=new Set;for(let[e,t]of i){let n=Yr(e);if(h.has(n)){r.onWarn?.(`RPC manifest: controller key '${n}' (from ${e}) collides with another controller — keeping the first; rename one class for distinct RPC namespaces.`);continue}h.add(n);let i=[];for(let n of t){if(!f.has(`${e}.${n.method}`))continue;let t=`${n.httpMethod} ${n.mountedPath??n.path}`;i.push(` ${n.method}: '${t}',`)}i.length>0&&m.push(` ${n}: {\n${i.join(`
737
+ `);l.push(p);let m=[],h=new Set;for(let[e,t]of i){let n=ei(e);if(h.has(n)){r.onWarn?.(`RPC manifest: controller key '${n}' (from ${e}) collides with another controller — keeping the first; rename one class for distinct RPC namespaces.`);continue}h.add(n);let i=[];for(let n of t){if(!f.has(`${e}.${n.method}`))continue;let t=`${n.httpMethod} ${n.mountedPath??n.path}`;i.push(` ${n.method}: '${t}',`)}i.length>0&&m.push(` ${n}: {\n${i.join(`
733
738
  `)}\n },`)}let g=[`/**`,` * Runtime route manifest for the tRPC-style sugar:`," * `createRpc(api, kickRpc)` from @forinda/kickjs-client.",` */`,`export const kickRpc = {`,...m,`} as const`].join(`
734
- `),_=[],v=new Map;for(let t of e)v.set(`${t.filePath}::${t.controller}`,t);for(let[e,n]of o){let r=v.get(e),i=Jr(``,r.filePath,t),a=r.controllerIsDefaultExport?`default as ${n}`:`${r.controller} as ${n}`;_.push(`import type { ${a} } from '${i}'`)}let y=_.length>0?_.join(`
739
+ `),_=[],v=new Map;for(let t of e)v.set(`${t.filePath}::${t.controller}`,t);for(let[e,n]of o){let r=v.get(e),i=$r(``,r.filePath,t),a=r.controllerIsDefaultExport?`default as ${n}`:`${r.controller} as ${n}`;_.push(`import type { ${a} } from '${i}'`)}let y=_.length>0?_.join(`
735
740
  `)+`
736
- `:``,b=qr(a)+y,x=l.join(`
737
- `);return`${Vr}${b}
741
+ `:``,b=Qr(a)+y,x=l.join(`
742
+ `);return`${Kr}${b}
738
743
  declare global {
739
744
  // eslint-disable-next-line @typescript-eslint/no-namespace
740
745
  namespace KickRoutes {
@@ -746,18 +751,18 @@ ${x}
746
751
  }
747
752
 
748
753
  ${g}
749
- `}function Ur(e){let t=e.contextKeys;return t==null?`string`:t.length===0?`never`:t.map(e=>JSON.stringify(e)).join(` | `)}function Wr(e){if(e.queryFilterable===null)return`unknown`;let t=e.querySortable??[];return`{ filter?: string | string[]; sort?: ${t.length>0?t.flatMap(e=>[`'${e}'`,`'-${e}'`]).join(` | `):`string`}; q?: string; page?: string; limit?: string }`}function Gr(e){let t=[];return e.queryFilterable&&e.queryFilterable.length>0&&t.push(`Filterable: ${e.queryFilterable.join(`, `)}`),e.querySortable&&e.querySortable.length>0&&t.push(`Sortable: ${e.querySortable.join(`, `)}`),e.querySearchable&&e.querySearchable.length>0&&t.push(`Searchable: ${e.querySearchable.join(`, `)}`),t}function Kr(e,t,n,r,i){if(!e||r===!1||e.source===null)return null;let a=Jr(e.source,t,n);if(a===`unknown`)return null;let o=`${a}::${e.identifier}`,s=i.get(o)?.specifier;return s?s=i.get(o).specifier:(s=`_S${i.size}`,i.set(o,{identifier:e.identifier,specifier:s})),s}function qr(e){if(e.size===0)return``;let t=[];for(let[n,r]of e){let[e]=n.split(`::`);t.push(`import type { ${r.identifier} as ${r.specifier} } from '${e}'`)}return t.join(`
754
+ `}function Jr(e){let t=e.contextKeys;return t==null?`string`:t.length===0?`never`:t.map(e=>JSON.stringify(e)).join(` | `)}function Yr(e){if(e.queryFilterable===null)return`unknown`;let t=e.querySortable??[];return`{ filter?: string | string[]; sort?: ${t.length>0?t.flatMap(e=>[`'${e}'`,`'-${e}'`]).join(` | `):`string`}; q?: string; page?: string; limit?: string }`}function Xr(e){let t=[];return e.queryFilterable&&e.queryFilterable.length>0&&t.push(`Filterable: ${e.queryFilterable.join(`, `)}`),e.querySortable&&e.querySortable.length>0&&t.push(`Sortable: ${e.querySortable.join(`, `)}`),e.querySearchable&&e.querySearchable.length>0&&t.push(`Searchable: ${e.querySearchable.join(`, `)}`),t}function Zr(e,t,n,r,i){if(!e||r===!1||e.source===null)return null;let a=$r(e.source,t,n);if(a===`unknown`)return null;let o=`${a}::${e.identifier}`,s=i.get(o)?.specifier;return s?s=i.get(o).specifier:(s=`_S${i.size}`,i.set(o,{identifier:e.identifier,specifier:s})),s}function Qr(e){if(e.size===0)return``;let t=[];for(let[n,r]of e){let[e]=n.split(`::`);t.push(`import type { ${r.identifier} as ${r.specifier} } from '${e}'`)}return t.join(`
750
755
  `)+`
751
- `}function Jr(e,t,n){if(e===null)return`unknown`;let r=A(n);if(e===``){let e=M(r,t).split(P).join(`/`);return e=e.replace(/\.(ts|tsx|mts|cts)$/i,``),e.startsWith(`.`)||(e=`./`+e),e}if(!e.startsWith(`.`)&&!e.startsWith(`/`))return e;let i=A(t),a=N(i,e),o=M(r,a).split(P).join(`/`);return o=o.replace(/\.(ts|tsx|mts|cts)$/i,``),o.startsWith(`.`)||(o=`./`+o),o}function Yr(e){let t=e.endsWith(`Controller`)?e.slice(0,-10):e,n=t.length>0?t:e;return n.charAt(0).toLowerCase()+n.slice(1)}const Xr=()=>({id:`kick/routes`,outExtension:`.ts`,inputs:[`src/**/*.controller.ts`,`src/**/*.module.ts`],async generate(e){let t=await e.getScanResult({root:Zr(e),cwd:e.cwd,envFile:Qr(e)}),n=e.config?.typegen?.schemaValidator??`zod`,r=k.resolve(e.cwd,`.kickjs/types/kick__routes.ts`);return Hr(t.routes,r,n,{onWarn:t=>e.log.warn(t)})}});function Zr(e){return k.resolve(e.cwd,e.config?.typegen?.srcDir??`src`)}function Qr(e){let t=e.config?.typegen?.envFile;if(t!==!1)return t}const $r=`@typescript/typescript6`;function ei(e){return typeof e?.createProgram==`function`}function ti(e){if(ei(e.typescript))return{api:e.typescript,source:`typescript`};if(ei(e.ts6))return{api:e.ts6,source:$r};let t=`Install it in the project:\n pnpm add -D ${$r}`;throw e.typescript?Error(`kick typegen: the client route map needs a TypeScript compiler API.
752
- TypeScript 7 does not ship a compiler API, so the compatibility package is required.\n ${t}`):Error(`kick typegen: the client route map needs a TypeScript compiler API, and neither 'typescript' nor '${$r}' resolved from this project.\n ${t}`)}async function ni(e){let t=rt(j(e,`package.json`)),n=async e=>{try{return await import(B(t.resolve(e)).href)}catch{return null}},[r,i]=await Promise.all([n(`typescript`),n($r)]);return ti({typescript:ri(r),ts6:ri(i)}).api}function ri(e){let t=e;return t?.default&&typeof t.default==`object`?t.default:e}const ii=Symbol(`kick/client: expansion budget exhausted`);var ai=class{ts;checker;program;opts;get printFlags(){return this.ts.TypeFormatFlags.NoTruncation}hoistedByType=new Map;inProgress=new Map;jsonInProgress=new Set;nextName=0;blocks=[];maxDepth;truncations=0;budget;constructor(e,t,n,r={}){this.ts=e,this.checker=t,this.program=n,this.opts=r,this.maxDepth=r.maxDepth??12,this.budget=r.truncationBudget??1e3}hoisted(){return this.blocks}expand(e){this.truncations=0;try{return this.render(e,0)}catch(e){if(e!==ii)throw e;return this.opts.onWarn?.(`expansion abandoned after ${this.budget} truncations — emitting 'unknown'. This usually means a recursive type. Declare a response schema on the route for an exact type.`),`unknown`}}render(e,t){let n=this.ts.TypeFlags;if(t>this.maxDepth){if(++this.truncations>this.budget)throw ii;return this.opts.onWarn?.(`type nesting exceeded ${this.maxDepth} levels — emitting 'unknown'. Declare a response schema on the route for an exact type.`),`unknown`}if(e.flags&(n.String|n.Number|n.Boolean|n.BigInt|n.ESSymbol)||e.flags&(n.Any|n.Unknown|n.Never|n.Void|n.Undefined|n.Null)||e.isLiteral()||e.flags&n.BooleanLiteral)return this.checker.typeToString(e,void 0,this.printFlags);if(e.isUnion()){let n=e.types.filter(e=>!this.isCallable(e));return(n.length>0?n:e.types).map(e=>this.render(e,t+1)).join(` | `)}if(e.isIntersection())return e.types.map(e=>this.render(e,t+1)).join(` & `);if(this.isTuple(e))return this.renderTuple(e,t);let r=this.arrayElement(e);if(r){let e=this.render(r.element,t+1),n=/[|&]/.test(e)?`(${e})[]`:`${e}[]`;return r.readonly?`readonly ${n}`:n}let i=this.toJsonType(e);if(i){if(this.jsonInProgress.has(e))return this.opts.onWarn?.(`'${this.checker.typeToString(e,void 0,this.printFlags)}' has a cyclic toJSON() — emitting 'unknown', since it has no serializable form.`),`unknown`;this.jsonInProgress.add(e);try{return this.render(i,t)}finally{this.jsonInProgress.delete(e)}}return this.isLibType(e)?this.renderLibType(e,t):e.flags&n.Object?this.renderObject(e,t):(this.opts.onWarn?.(`could not expand type '${this.checker.typeToString(e)}' — emitting 'unknown'`),`unknown`)}renderObject(e,t){let n=this.hoistedByType.get(e);if(n)return n;if(this.isNamed(e)){let t=this.allocName();this.hoistedByType.set(e,t);let n=this.blocks.length;return this.blocks.push(``),this.blocks[n]=`interface ${t} {\n${this.members(e,0,` `)}\n}`,t}let r=this.inProgress.get(e);if(r)return r.name??=this.allocName();let i={name:null};this.inProgress.set(e,i);let a;try{a=this.members(e,t,``,`; `)}finally{this.inProgress.delete(e)}if(i.name){this.hoistedByType.set(e,i.name);let t=this.blocks.length;return this.blocks.push(``),this.blocks[t]=`interface ${i.name} {\n${this.members(e,0,` `)}\n}`,i.name}return a.length>0?`{ ${a} }`:`{}`}allocName(){return`__T${this.nextName++}`}members(e,t,n,r=`
756
+ `}function $r(e,t,n){if(e===null)return`unknown`;let r=A(n);if(e===``){let e=M(r,t).split(P).join(`/`);return e=e.replace(/\.(ts|tsx|mts|cts)$/i,``),e.startsWith(`.`)||(e=`./`+e),e}if(!e.startsWith(`.`)&&!e.startsWith(`/`))return e;let i=A(t),a=N(i,e),o=M(r,a).split(P).join(`/`);return o=o.replace(/\.(ts|tsx|mts|cts)$/i,``),o.startsWith(`.`)||(o=`./`+o),o}function ei(e){let t=e.endsWith(`Controller`)?e.slice(0,-10):e,n=t.length>0?t:e;return n.charAt(0).toLowerCase()+n.slice(1)}const ti=()=>({id:`kick/routes`,outExtension:`.ts`,inputs:[`src/**/*.controller.ts`,`src/**/*.module.ts`],async generate(e){let t=await e.getScanResult({root:ni(e),cwd:e.cwd,envFile:ri(e)}),n=e.config?.typegen?.schemaValidator??`zod`,r=k.resolve(e.cwd,`.kickjs/types/kick__routes.ts`);return qr(t.routes,r,n,{onWarn:t=>e.log.warn(t)})}});function ni(e){return k.resolve(e.cwd,e.config?.typegen?.srcDir??`src`)}function ri(e){let t=e.config?.typegen?.envFile;if(t!==!1)return t}const ii=`@typescript/typescript6`;function ai(e){return typeof e?.createProgram==`function`}function oi(e){if(ai(e.typescript))return{api:e.typescript,source:`typescript`};if(ai(e.ts6))return{api:e.ts6,source:ii};let t=`Install it in the project:\n pnpm add -D ${ii}`;throw e.typescript?Error(`kick typegen: the client route map needs a TypeScript compiler API.
757
+ TypeScript 7 does not ship a compiler API, so the compatibility package is required.\n ${t}`):Error(`kick typegen: the client route map needs a TypeScript compiler API, and neither 'typescript' nor '${ii}' resolved from this project.\n ${t}`)}async function si(e){let t=rt(j(e,`package.json`)),n=async e=>{try{return await import(B(t.resolve(e)).href)}catch{return null}},[r,i]=await Promise.all([n(`typescript`),n(ii)]);return oi({typescript:ci(r),ts6:ci(i)}).api}function ci(e){let t=e;return t?.default&&typeof t.default==`object`?t.default:e}const li=Symbol(`kick/client: expansion budget exhausted`);var ui=class{ts;checker;program;opts;get printFlags(){return this.ts.TypeFormatFlags.NoTruncation}hoistedByType=new Map;inProgress=new Map;jsonInProgress=new Set;nextName=0;blocks=[];maxDepth;truncations=0;budget;constructor(e,t,n,r={}){this.ts=e,this.checker=t,this.program=n,this.opts=r,this.maxDepth=r.maxDepth??12,this.budget=r.truncationBudget??1e3}hoisted(){return this.blocks}expand(e){this.truncations=0;try{return this.render(e,0)}catch(e){if(e!==li)throw e;return this.opts.onWarn?.(`expansion abandoned after ${this.budget} truncations — emitting 'unknown'. This usually means a recursive type. Declare a response schema on the route for an exact type.`),`unknown`}}render(e,t){let n=this.ts.TypeFlags;if(t>this.maxDepth){if(++this.truncations>this.budget)throw li;return this.opts.onWarn?.(`type nesting exceeded ${this.maxDepth} levels — emitting 'unknown'. Declare a response schema on the route for an exact type.`),`unknown`}if(e.flags&(n.String|n.Number|n.Boolean|n.BigInt|n.ESSymbol)||e.flags&(n.Any|n.Unknown|n.Never|n.Void|n.Undefined|n.Null)||e.isLiteral()||e.flags&n.BooleanLiteral)return this.checker.typeToString(e,void 0,this.printFlags);if(e.isUnion()){let n=e.types.filter(e=>!this.isCallable(e));return(n.length>0?n:e.types).map(e=>this.render(e,t+1)).join(` | `)}if(e.isIntersection())return e.types.map(e=>this.render(e,t+1)).join(` & `);if(this.isTuple(e))return this.renderTuple(e,t);let r=this.arrayElement(e);if(r){let e=this.render(r.element,t+1),n=/[|&]/.test(e)?`(${e})[]`:`${e}[]`;return r.readonly?`readonly ${n}`:n}let i=this.toJsonType(e);if(i){if(this.jsonInProgress.has(e))return this.opts.onWarn?.(`'${this.checker.typeToString(e,void 0,this.printFlags)}' has a cyclic toJSON() — emitting 'unknown', since it has no serializable form.`),`unknown`;this.jsonInProgress.add(e);try{return this.render(i,t)}finally{this.jsonInProgress.delete(e)}}return this.isLibType(e)?this.renderLibType(e,t):e.flags&n.Object?this.renderObject(e,t):(this.opts.onWarn?.(`could not expand type '${this.checker.typeToString(e)}' — emitting 'unknown'`),`unknown`)}renderObject(e,t){let n=this.hoistedByType.get(e);if(n)return n;if(this.isNamed(e)){let t=this.allocName();this.hoistedByType.set(e,t);let n=this.blocks.length;return this.blocks.push(``),this.blocks[n]=`interface ${t} {\n${this.members(e,0,` `)}\n}`,t}let r=this.inProgress.get(e);if(r)return r.name??=this.allocName();let i={name:null};this.inProgress.set(e,i);let a;try{a=this.members(e,t,``,`; `)}finally{this.inProgress.delete(e)}if(i.name){this.hoistedByType.set(e,i.name);let t=this.blocks.length;return this.blocks.push(``),this.blocks[t]=`interface ${i.name} {\n${this.members(e,0,` `)}\n}`,i.name}return a.length>0?`{ ${a} }`:`{}`}allocName(){return`__T${this.nextName++}`}members(e,t,n,r=`
753
758
  `){let i=[];for(let r of this.checker.getIndexInfosOfType(e)){let e=this.checker.typeToString(r.keyType,void 0,this.printFlags);i.push(`${n}[key: ${e}]: ${this.render(r.type,t+1)}`)}for(let r of this.checker.getPropertiesOfType(e)){let e=this.typeOfProperty(r);if(this.isCallable(e)||r.getName().startsWith(`__@`))continue;let a=(r.flags&this.ts.SymbolFlags.Optional)!==0,o=this.renderPropertyType(e,a,r,t+1),s=this.isReadonlyProp(r)?`readonly `:``;i.push(`${n}${s}${this.propName(r.getName())}${a?`?`:``}: ${o}`)}return i.join(r===`
754
759
  `?`
755
- `:r)}typeOfProperty(e){let t=this.checker;if(typeof t.getTypeOfSymbol==`function`)return t.getTypeOfSymbol(e);let n=e.valueDeclaration??e.declarations?.[0];return n?this.checker.getTypeOfSymbolAtLocation(e,n):this.checker.getDeclaredTypeOfSymbol(e)}renderPropertyType(e,t,n,r){if(!t||!e.isUnion()||this.declaresUndefined(n))return this.render(e,r);let i=e.types.filter(e=>!(e.flags&this.ts.TypeFlags.Undefined));return i.length===0?`undefined`:i.map(e=>this.render(e,r)).join(` | `)}isReadonlyProp(e){let t=e.valueDeclaration??e.declarations?.[0];return t?(this.ts.getCombinedModifierFlags(t)&this.ts.ModifierFlags.Readonly)!==0:!1}declaresUndefined(e){let t=e.valueDeclaration??e.declarations?.[0];if(!t||!(this.ts.isPropertySignature(t)||this.ts.isPropertyDeclaration(t))||!t.type)return!1;let n=this.checker.getTypeFromTypeNode(t.type);return(n.isUnion()?n.types:[n]).some(e=>(e.flags&this.ts.TypeFlags.Undefined)!==0)}renderTuple(e,t){let n=this.ts.ElementFlags,r=this.checker.getTypeArguments(e),i=e.target,a=i.elementFlags??[],o=r.map((e,r)=>{let i=a[r]??n.Required;return i&n.Optional?`${(e.isUnion()?e.types.filter(e=>!(e.flags&this.ts.TypeFlags.Undefined)):[e]).map(e=>this.render(e,t+1)).join(` | `)}?`:i&n.Rest?`...${this.render(e,t+1)}[]`:i&n.Variadic?`...${this.render(e,t+1)}`:this.render(e,t+1)});return`${i.readonly?`readonly `:``}[${o.join(`, `)}]`}propName(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)?e:JSON.stringify(e)}isLibType(e){let t=e.aliasSymbol?.declarations??e.getSymbol()?.declarations;return!t||t.length===0?!1:t.every(e=>this.program.isSourceFileDefaultLibrary(e.getSourceFile()))}renderLibType(e,t){let n=(e.aliasSymbol??e.getSymbol())?.getName(),r=e.aliasTypeArguments??this.typeArguments(e);return!n||r.length===0?this.checker.typeToString(e,void 0,this.printFlags):`${n}<${r.map(e=>this.render(e,t+1)).join(`, `)}>`}typeArguments(e){return!(e.flags&this.ts.TypeFlags.Object)||!(e.objectFlags&this.ts.ObjectFlags.Reference)?[]:this.checker.getTypeArguments(e)}toJsonType(e){if(!(e.flags&this.ts.TypeFlags.Object))return null;let t=this.checker.getPropertyOfType(e,`toJSON`);if(!t)return null;let[n]=this.checker.getSignaturesOfType(this.typeOfProperty(t),this.ts.SignatureKind.Call);if(!n)return null;let r=this.checker.getReturnTypeOfSignature(n);return r===e?null:r}isCallable(e){if(e.isUnion()){let t=e.types.filter(e=>!(e.flags&(this.ts.TypeFlags.Undefined|this.ts.TypeFlags.Null)));return t.length>0&&t.every(e=>this.isCallable(e))}return this.checker.getSignaturesOfType(e,this.ts.SignatureKind.Call).length>0||this.checker.getSignaturesOfType(e,this.ts.SignatureKind.Construct).length>0}isNamed(e){let t=e.getSymbol();if(!t)return!1;let n=t.getName();return n!==`__type`&&n!==`__object`&&n.length>0}isTuple(e){let t=this.ts.ObjectFlags;if(!(e.flags&this.ts.TypeFlags.Object)||!(e.objectFlags&t.Reference))return!1;let n=e.target;return!!(n&&n.objectFlags&t.Tuple)}arrayElement(e){let t=e.getSymbol()?.getName();if(t!==`Array`&&t!==`ReadonlyArray`)return null;let n=this.checker.getTypeArguments(e);return n.length===1?{element:n[0],readonly:t===`ReadonlyArray`}:null}};const oi=[`pnpm-lock.yaml`,`package-lock.json`,`yarn.lock`,`bun.lock`,`bun.lockb`],si=/(?:^|[\\/])(?:node_modules|\.kickjs)(?:[\\/]|$)/;function ci(e){return St(`sha1`).update(e).digest(`hex`)}function li(e){let t=St(`sha1`);t.update(e.cliVersion),t.update(JSON.stringify(e.options??{})),t.update(e.keys.join(`
756
- `));for(let n of oi){let r=j(e.projectDir,n);if(F(r))try{t.update(I(r))}catch(e){throw Error(`kick/client: cannot read lockfile ${r}`,{cause:e})}}for(let n of e.fileNames.toSorted())if(!si.test(n)){t.update(n);try{t.update(I(n))}catch(e){throw Error(`kick/client: cannot read project file ${n}`,{cause:e})}}return t.digest(`hex`)}async function ui(e){try{let t=await ni(e.compilerFrom??e.projectDir),n={...t.sys,onUnRecoverableConfigFileDiagnostic:()=>{}},r=t.getParsedCommandLineOfConfigFile(j(e.projectDir,`tsconfig.json`),{},n);return r?li({projectDir:e.projectDir,fileNames:r.fileNames,keys:e.keys,options:{...r.options,__kickMaxDepth:e.maxDepth??null},cliVersion:e.cliVersion}):null}catch{return null}}async function di(e){let t=await ni(e.compilerFrom??e.projectDir),n=j(A(e.routesFile),`__kick_client_probe__.ts`),r=mi(e.routesFile,e.keys),i=_i(t,e.projectDir,n,r),a=i.getTypeChecker(),o=i.getSourceFile(n);if(!o)throw Error(`kick/client: could not add the resolution probe to the program. Check that ${e.routesFile} exists — run \`kick typegen\` first.`);fi(t,i,e.routesFile);let s=hi(t,i,o,e.keys),c=null,l=new ai(t,a,i,{maxDepth:e.maxDepth,onWarn:t=>e.onWarn?.(c?`route '${c}': ${t}`:t)}),u=new Map;for(let[n,r]of e.keys.entries()){if(s.has(r)){e.onWarn?.(`route '${r}' is not present in KickRoutes.Api — skipped. Re-run \`kick typegen\` so the two maps agree.`);continue}let i=o.statements.find(e=>t.isTypeAliasDeclaration(e)&&e.name.text===pi(n));if(!i){e.onWarn?.(`route '${r}' could not be resolved — skipped.`);continue}let d=a.getTypeAtLocation(i.type);if(d.flags&t.TypeFlags.Any){e.onWarn?.(`route '${r}' resolved to 'any' — skipped rather than emitted, since an 'any' entry silently accepts every call. Check that the server type-checks.`);continue}c=r,u.set(r,l.expand(d)),c=null}return{entries:u,hoisted:l.hoisted()}}function fi(e,t,n){let r=t.getSourceFile(n);if(!r)throw Error(`kick/client: ${n} is not in the TypeScript program. Run \`kick typegen\` first, and check that tsconfig.json includes .kickjs.`);let i=t.getSemanticDiagnostics(r);if(i.length===0)return;let a=i.slice(0,3).map(t=>` ${e.flattenDiagnosticMessageText(t.messageText,` `)}`).join(`
757
- `);throw Error(`${n} has ${i.length} type error(s), so its route types cannot be resolved — every entry would come out as 'any'.\n${a}\n Usually this means dependencies are not installed or the server does not type-check.`)}function pi(e){return`_K${e}`}function mi(e,t){let n=`./`+it(e).replace(/\.tsx?$/,``),r=t.map((e,t)=>`type ${pi(t)} = KickRoutes.Api[${JSON.stringify(e)}]`);return[`import ${JSON.stringify(n)}`,...r].join(`
760
+ `:r)}typeOfProperty(e){let t=this.checker;if(typeof t.getTypeOfSymbol==`function`)return t.getTypeOfSymbol(e);let n=e.valueDeclaration??e.declarations?.[0];return n?this.checker.getTypeOfSymbolAtLocation(e,n):this.checker.getDeclaredTypeOfSymbol(e)}renderPropertyType(e,t,n,r){if(!t||!e.isUnion()||this.declaresUndefined(n))return this.render(e,r);let i=e.types.filter(e=>!(e.flags&this.ts.TypeFlags.Undefined));return i.length===0?`undefined`:i.map(e=>this.render(e,r)).join(` | `)}isReadonlyProp(e){let t=e.valueDeclaration??e.declarations?.[0];return t?(this.ts.getCombinedModifierFlags(t)&this.ts.ModifierFlags.Readonly)!==0:!1}declaresUndefined(e){let t=e.valueDeclaration??e.declarations?.[0];if(!t||!(this.ts.isPropertySignature(t)||this.ts.isPropertyDeclaration(t))||!t.type)return!1;let n=this.checker.getTypeFromTypeNode(t.type);return(n.isUnion()?n.types:[n]).some(e=>(e.flags&this.ts.TypeFlags.Undefined)!==0)}renderTuple(e,t){let n=this.ts.ElementFlags,r=this.checker.getTypeArguments(e),i=e.target,a=i.elementFlags??[],o=r.map((e,r)=>{let i=a[r]??n.Required;return i&n.Optional?`${(e.isUnion()?e.types.filter(e=>!(e.flags&this.ts.TypeFlags.Undefined)):[e]).map(e=>this.render(e,t+1)).join(` | `)}?`:i&n.Rest?`...${this.render(e,t+1)}[]`:i&n.Variadic?`...${this.render(e,t+1)}`:this.render(e,t+1)});return`${i.readonly?`readonly `:``}[${o.join(`, `)}]`}propName(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)?e:JSON.stringify(e)}isLibType(e){let t=e.aliasSymbol?.declarations??e.getSymbol()?.declarations;return!t||t.length===0?!1:t.every(e=>this.program.isSourceFileDefaultLibrary(e.getSourceFile()))}renderLibType(e,t){let n=(e.aliasSymbol??e.getSymbol())?.getName(),r=e.aliasTypeArguments??this.typeArguments(e);return!n||r.length===0?this.checker.typeToString(e,void 0,this.printFlags):`${n}<${r.map(e=>this.render(e,t+1)).join(`, `)}>`}typeArguments(e){return!(e.flags&this.ts.TypeFlags.Object)||!(e.objectFlags&this.ts.ObjectFlags.Reference)?[]:this.checker.getTypeArguments(e)}toJsonType(e){if(!(e.flags&this.ts.TypeFlags.Object))return null;let t=this.checker.getPropertyOfType(e,`toJSON`);if(!t)return null;let[n]=this.checker.getSignaturesOfType(this.typeOfProperty(t),this.ts.SignatureKind.Call);if(!n)return null;let r=this.checker.getReturnTypeOfSignature(n);return r===e?null:r}isCallable(e){if(e.isUnion()){let t=e.types.filter(e=>!(e.flags&(this.ts.TypeFlags.Undefined|this.ts.TypeFlags.Null)));return t.length>0&&t.every(e=>this.isCallable(e))}return this.checker.getSignaturesOfType(e,this.ts.SignatureKind.Call).length>0||this.checker.getSignaturesOfType(e,this.ts.SignatureKind.Construct).length>0}isNamed(e){let t=e.getSymbol();if(!t)return!1;let n=t.getName();return n!==`__type`&&n!==`__object`&&n.length>0}isTuple(e){let t=this.ts.ObjectFlags;if(!(e.flags&this.ts.TypeFlags.Object)||!(e.objectFlags&t.Reference))return!1;let n=e.target;return!!(n&&n.objectFlags&t.Tuple)}arrayElement(e){let t=e.getSymbol()?.getName();if(t!==`Array`&&t!==`ReadonlyArray`)return null;let n=this.checker.getTypeArguments(e);return n.length===1?{element:n[0],readonly:t===`ReadonlyArray`}:null}};const di=[`pnpm-lock.yaml`,`package-lock.json`,`yarn.lock`,`bun.lock`,`bun.lockb`],fi=/(?:^|[\\/])(?:node_modules|\.kickjs)(?:[\\/]|$)/;function pi(e){return St(`sha1`).update(e).digest(`hex`)}function mi(e){let t=St(`sha1`);t.update(e.cliVersion),t.update(JSON.stringify(e.options??{})),t.update(e.keys.join(`
761
+ `));for(let n of di){let r=j(e.projectDir,n);if(F(r))try{t.update(I(r))}catch(e){throw Error(`kick/client: cannot read lockfile ${r}`,{cause:e})}}for(let n of e.fileNames.toSorted())if(!fi.test(n)){t.update(n);try{t.update(I(n))}catch(e){throw Error(`kick/client: cannot read project file ${n}`,{cause:e})}}return t.digest(`hex`)}async function hi(e){try{let t=await si(e.compilerFrom??e.projectDir),n={...t.sys,onUnRecoverableConfigFileDiagnostic:()=>{}},r=t.getParsedCommandLineOfConfigFile(j(e.projectDir,`tsconfig.json`),{},n);return r?mi({projectDir:e.projectDir,fileNames:r.fileNames,keys:e.keys,options:{...r.options,__kickMaxDepth:e.maxDepth??null},cliVersion:e.cliVersion}):null}catch{return null}}async function gi(e){let t=await si(e.compilerFrom??e.projectDir),n=j(A(e.routesFile),`__kick_client_probe__.ts`),r=yi(e.routesFile,e.keys),i=Si(t,e.projectDir,n,r),a=i.getTypeChecker(),o=i.getSourceFile(n);if(!o)throw Error(`kick/client: could not add the resolution probe to the program. Check that ${e.routesFile} exists — run \`kick typegen\` first.`);_i(t,i,e.routesFile);let s=bi(t,i,o,e.keys),c=null,l=new ui(t,a,i,{maxDepth:e.maxDepth,onWarn:t=>e.onWarn?.(c?`route '${c}': ${t}`:t)}),u=new Map;for(let[n,r]of e.keys.entries()){if(s.has(r)){e.onWarn?.(`route '${r}' is not present in KickRoutes.Api — skipped. Re-run \`kick typegen\` so the two maps agree.`);continue}let i=o.statements.find(e=>t.isTypeAliasDeclaration(e)&&e.name.text===vi(n));if(!i){e.onWarn?.(`route '${r}' could not be resolved — skipped.`);continue}let d=a.getTypeAtLocation(i.type);if(d.flags&t.TypeFlags.Any){e.onWarn?.(`route '${r}' resolved to 'any' — skipped rather than emitted, since an 'any' entry silently accepts every call. Check that the server type-checks.`);continue}c=r,u.set(r,l.expand(d)),c=null}return{entries:u,hoisted:l.hoisted()}}function _i(e,t,n){let r=t.getSourceFile(n);if(!r)throw Error(`kick/client: ${n} is not in the TypeScript program. Run \`kick typegen\` first, and check that tsconfig.json includes .kickjs.`);let i=t.getSemanticDiagnostics(r);if(i.length===0)return;let a=i.slice(0,3).map(t=>` ${e.flattenDiagnosticMessageText(t.messageText,` `)}`).join(`
762
+ `);throw Error(`${n} has ${i.length} type error(s), so its route types cannot be resolved — every entry would come out as 'any'.\n${a}\n Usually this means dependencies are not installed or the server does not type-check.`)}function vi(e){return`_K${e}`}function yi(e,t){let n=`./`+it(e).replace(/\.tsx?$/,``),r=t.map((e,t)=>`type ${vi(t)} = KickRoutes.Api[${JSON.stringify(e)}]`);return[`import ${JSON.stringify(n)}`,...r].join(`
758
763
  `)+`
759
- `}function hi(e,t,n,r){let i=new Set,a=new Map;for(let t of n.statements)e.isTypeAliasDeclaration(t)&&a.set(t.name.text,t);for(let e of t.getSemanticDiagnostics(n))if(e.start!==void 0)for(let[t,o]of r.entries()){let r=a.get(pi(t));r&&e.start>=r.getStart(n)&&e.start<r.getEnd()&&i.add(o)}return i}function gi(e,t){let n=e.filter(e=>/\.d\.(ts|mts|cts)$/.test(e)),r=[];try{r=st(t).filter(e=>e.endsWith(`.ts`)).map(e=>j(t,e))}catch{}return[...new Set([...n,...r])]}function _i(e,t,n,r){let i=j(t,`tsconfig.json`),a={...e.sys,onUnRecoverableConfigFileDiagnostic:t=>{throw Error(e.flattenDiagnosticMessageText(t.messageText,`
760
- `))}},o=e.getParsedCommandLineOfConfigFile(i,{},a);if(!o)throw Error(`kick/client: could not read ${i}`);let s=e.createCompilerHost(o.options,!0),c=s.readFile.bind(s),l=s.getSourceFile.bind(s),u=s.fileExists.bind(s);return s.readFile=e=>e===n?r:c(e),s.fileExists=e=>e===n||u(e),s.getSourceFile=(t,i,a,o)=>t===n?e.createSourceFile(t,r,i,!0):l(t,i,a,o),e.createProgram({rootNames:[...gi(o.fileNames,A(n)),n],options:o.options,host:s})}const vi=`/* eslint-disable */
764
+ `}function bi(e,t,n,r){let i=new Set,a=new Map;for(let t of n.statements)e.isTypeAliasDeclaration(t)&&a.set(t.name.text,t);for(let e of t.getSemanticDiagnostics(n))if(e.start!==void 0)for(let[t,o]of r.entries()){let r=a.get(vi(t));r&&e.start>=r.getStart(n)&&e.start<r.getEnd()&&i.add(o)}return i}function xi(e,t){let n=e.filter(e=>/\.d\.(ts|mts|cts)$/.test(e)),r=[];try{r=st(t).filter(e=>e.endsWith(`.ts`)).map(e=>j(t,e))}catch{}return[...new Set([...n,...r])]}function Si(e,t,n,r){let i=j(t,`tsconfig.json`),a={...e.sys,onUnRecoverableConfigFileDiagnostic:t=>{throw Error(e.flattenDiagnosticMessageText(t.messageText,`
765
+ `))}},o=e.getParsedCommandLineOfConfigFile(i,{},a);if(!o)throw Error(`kick/client: could not read ${i}`);let s=e.createCompilerHost(o.options,!0),c=s.readFile.bind(s),l=s.getSourceFile.bind(s),u=s.fileExists.bind(s);return s.readFile=e=>e===n?r:c(e),s.fileExists=e=>e===n||u(e),s.getSourceFile=(t,i,a,o)=>t===n?e.createSourceFile(t,r,i,!0):l(t,i,a,o),e.createProgram({rootNames:[...xi(o.fileNames,A(n)),n],options:o.options,host:s})}const Ci=`/* eslint-disable */
761
766
  // AUTO-GENERATED by \`kick typegen\`. DO NOT EDIT.
762
767
  //
763
768
  // Self-contained: this file has no imports, so a frontend consumes it without
@@ -771,7 +776,7 @@ ${g}
771
776
  //
772
777
  // Not refreshed by \`kick dev\` — resolving these types builds a full
773
778
  // TypeScript program over the server. Re-run \`kick typegen\`.
774
- `;function yi(e,t){let n=t.filter(t=>e.entries.has(t));if(n.length===0)return`${vi}
779
+ `;function wi(e,t){let n=t.filter(t=>e.entries.has(t));if(n.length===0)return`${Ci}
775
780
  // (no routes discovered yet — annotate a controller method with
776
781
  // @Get/@Post/@Put/@Delete/@Patch and re-run \`kick typegen\`)
777
782
  interface Api {}
@@ -788,7 +793,7 @@ export type { Api }
788
793
 
789
794
  `)+`
790
795
 
791
- `:``,i=n.map(t=>` ${JSON.stringify(t)}: ${e.entries.get(t)}`);return`${vi}
796
+ `:``,i=n.map(t=>` ${JSON.stringify(t)}: ${e.entries.get(t)}`);return`${Ci}
792
797
  ${r}interface Api {
793
798
  ${i.join(`
794
799
  `)}
@@ -802,7 +807,7 @@ declare global {
802
807
  }
803
808
 
804
809
  export type { Api }
805
- `}const bi=`kick/client`,Q=`.kickjs/types/kick__client.d.ts`,xi=`.kickjs/cache/client-map.sha1`,Si=(()=>{try{return rt(import.meta.url)(`../../../package.json`).version??`0.0.0`}catch{return`0.0.0`}})();function Ci(e){try{if(!F(e))return null;let[t,n]=I(e,`utf-8`).trim().split(/\s+/);return t&&n?{inputs:t,output:n}:null}catch{return null}}function wi(e){return`${an}${bi} */\n\n${e}\n`}function Ti(e){try{return F(e)?I(e,`utf-8`):null}catch{return null}}async function Ei(e){let t=k.resolve(e.cwd,Q);if(!F(t))return!1;try{await ft(t,{force:!0})}catch(t){return e.log.warn(` kick/client: could not remove the stale ${Q} — treat it as out of date (${t instanceof Error?t.message:String(t)})`),!0}return e.log.warn(` kick/client: removed the previously generated ${Q} rather than leave a stale one — re-run \`kick typegen\` once the cause above is fixed.`),!0}function Di(e){let t=e?.typegen?.client;return typeof t==`object`?t.maxDepth:void 0}function Oi(e){let t=e.config?.typegen?.client;return typeof t==`boolean`?t:t&&typeof t==`object`?t.enabled!==!1:(F(k.resolve(e.cwd,Q))&&e.log.warn(` kick/client: ${Q} exists but typegen.client is not set, so it is NOT being refreshed.\n Add \`typegen: { client: true }\` to kick.config.ts to keep it current, or delete the file if nothing reads it.`),!1)}const ki=()=>({id:bi,outExtension:`.d.ts`,inputs:[`src/**/*.controller.ts`,`src/**/*.module.ts`],async generate(e){if(!Oi(e))return null;if(e.watch)return e.log.info?.(" kick/client: skipped under watch (builds a full TypeScript program). Run `kick typegen` to refresh the client route map."),null;let t=await e.getScanResult({root:k.resolve(e.cwd,e.config?.typegen?.srcDir??`src`),cwd:e.cwd}),n=[],r=new Set;for(let e of t.routes){let t=`${e.httpMethod} ${e.mountedPath??e.path}`;r.has(t)||(r.add(t),n.push(t))}let i=Di(e.config),a=await ui({projectDir:e.cwd,keys:n,maxDepth:i,cliVersion:Si}),o=Ci(k.resolve(e.cwd,xi)),s=Ti(k.resolve(e.cwd,Q));if(a&&o&&s!==null&&o.inputs===a&&o.output===ci(s))return ae()&&e.log.info?.(` kick/client: unchanged, keeping ${Q}`),null;try{let t=yi(await di({projectDir:e.cwd,routesFile:k.resolve(e.cwd,`.kickjs/types/kick__routes.ts`),keys:n,maxDepth:i,onWarn:t=>e.log.warn(t)}),n);return a&&!e.check&&await e.writeFile(xi,`${a} ${ci(wi(t))}`),t}catch(t){let n=F(k.resolve(e.cwd,Q)),r=` kick/client: skipped — ${t instanceof Error?t.message:String(t)}`;return n?e.log.warn(r):ae()&&e.log.info?.(r),n&&await Ei(e),null}}});function Ai(e,t,n=`zod`){if(!e)return null;let r=A(t),i=M(r,e.filePath).split(P).join(`/`);return i=i.replace(/\.(ts|tsx|mts|cts)$/i,``),i.startsWith(`.`)||(i=`./`+i),`/* eslint-disable */
810
+ `}const Ti=`kick/client`,Q=`.kickjs/types/kick__client.d.ts`,Ei=`.kickjs/cache/client-map.sha1`,Di=(()=>{try{return rt(import.meta.url)(`../../../package.json`).version??`0.0.0`}catch{return`0.0.0`}})();function Oi(e){try{if(!F(e))return null;let[t,n]=I(e,`utf-8`).trim().split(/\s+/);return t&&n?{inputs:t,output:n}:null}catch{return null}}function ki(e){return`${an}${Ti} */\n\n${e}\n`}function Ai(e){try{return F(e)?I(e,`utf-8`):null}catch{return null}}async function ji(e){let t=k.resolve(e.cwd,Q);if(!F(t))return!1;try{await ft(t,{force:!0})}catch(t){return e.log.warn(` kick/client: could not remove the stale ${Q} — treat it as out of date (${t instanceof Error?t.message:String(t)})`),!0}return e.log.warn(` kick/client: removed the previously generated ${Q} rather than leave a stale one — re-run \`kick typegen\` once the cause above is fixed.`),!0}function Mi(e){let t=e?.typegen?.client;return typeof t==`object`?t.maxDepth:void 0}function Ni(e){let t=e.config?.typegen?.client;return typeof t==`boolean`?t:t&&typeof t==`object`?t.enabled!==!1:(F(k.resolve(e.cwd,Q))&&e.log.warn(` kick/client: ${Q} exists but typegen.client is not set, so it is NOT being refreshed.\n Add \`typegen: { client: true }\` to kick.config.ts to keep it current, or delete the file if nothing reads it.`),!1)}const Pi=()=>({id:Ti,outExtension:`.d.ts`,inputs:[`src/**/*.controller.ts`,`src/**/*.module.ts`],async generate(e){if(!Ni(e))return null;if(e.watch)return e.log.info?.(" kick/client: skipped under watch (builds a full TypeScript program). Run `kick typegen` to refresh the client route map."),null;let t=await e.getScanResult({root:k.resolve(e.cwd,e.config?.typegen?.srcDir??`src`),cwd:e.cwd}),n=[],r=new Set;for(let e of t.routes){let t=`${e.httpMethod} ${e.mountedPath??e.path}`;r.has(t)||(r.add(t),n.push(t))}let i=Mi(e.config),a=await hi({projectDir:e.cwd,keys:n,maxDepth:i,cliVersion:Di}),o=Oi(k.resolve(e.cwd,Ei)),s=Ai(k.resolve(e.cwd,Q));if(a&&o&&s!==null&&o.inputs===a&&o.output===pi(s))return ae()&&e.log.info?.(` kick/client: unchanged, keeping ${Q}`),null;try{let t=wi(await gi({projectDir:e.cwd,routesFile:k.resolve(e.cwd,`.kickjs/types/kick__routes.ts`),keys:n,maxDepth:i,onWarn:t=>e.log.warn(t)}),n);return a&&!e.check&&await e.writeFile(Ei,`${a} ${pi(ki(t))}`),t}catch(t){let n=F(k.resolve(e.cwd,Q)),r=` kick/client: skipped — ${t instanceof Error?t.message:String(t)}`;return n?e.log.warn(r):ae()&&e.log.info?.(r),n&&await ji(e),null}}});function Fi(e,t,n=`zod`){if(!e)return null;let r=A(t),i=M(r,e.filePath).split(P).join(`/`);return i=i.replace(/\.(ts|tsx|mts|cts)$/i,``),i.startsWith(`.`)||(i=`./`+i),`/* eslint-disable */
806
811
  // AUTO-GENERATED by \`kick typegen\`. DO NOT EDIT.
807
812
  // Re-run with \`kick typegen\` or rely on \`kick dev\` to refresh.
808
813
 
@@ -840,6 +845,6 @@ declare global {
840
845
  }
841
846
 
842
847
  export {}
843
- `}const ji=()=>({id:`kick/env`,outExtension:`.ts`,inputs:[`src/env.ts`,`src/**/env.ts`,`src/**/*.env.ts`],async generate(e){let t=Ni(e);if(t===!1)return null;let n=await e.getScanResult({root:Mi(e),cwd:e.cwd,envFile:t});if(!n.env)return null;let r=e.config?.typegen?.schemaValidator??`zod`,i=k.resolve(e.cwd,`.kickjs/types/kick__env.ts`);return Ai(n.env,i,r)}});function Mi(e){return k.resolve(e.cwd,e.config?.typegen?.srcDir??`src`)}function Ni(e){return e.config?.typegen?.envFile}function Pi(e){return k.resolve(e.cwd,e.config?.typegen?.srcDir??`src`)}function Fi(e){let t=e.config?.typegen?.envFile;if(t!==!1)return t}function $(e){return{root:Pi(e),cwd:e.cwd,envFile:Fi(e)}}const Ii=()=>({id:`kick/registry`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e)),n=k.resolve(e.cwd,`.kickjs/types/kick__registry.d.ts`),r=new Set(t.collisions.map(e=>e.className));return Je(t.classes,n,r)}}),Li=()=>({id:`kick/services`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e)),n=new Set(t.collisions.map(e=>e.className)),r=Ge(t.classes,t.tokens,t.injects,n);return Ue(`ServiceToken`,r,"(no tokens discovered — declare with createToken<T>() or `kick g service <name>`)")}}),Ri=()=>({id:`kick/modules`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e));return Ue(`ModuleToken`,ze(t.classes),"(no @Module classes discovered — `kick g module <name>` to add one)")}}),zi=()=>({id:`kick/plugins`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e));return Ve(t.pluginsAndAdapters)}}),Bi=()=>({id:`kick/augmentations`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e));return Qe(t.augmentations)}}),Vi=()=>({id:`kick/context`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e));return t.contextKeys.length===0?null:Be(t.contextKeys)}}),Hi=()=>({id:`kick/route-flags`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e));return Ke(t.routeFlags)}}),Ui={fastify:{subpath:`@forinda/kickjs/fastify`,typeName:`FastifyRuntimeTypes`},h3:{subpath:`@forinda/kickjs/h3`,typeName:`H3RuntimeTypes`}},Wi=[D({name:`kick/init`,register:wt}),D({name:`kick/generate`,register:nn}),D({name:`kick/run`,register:_n}),D({name:`kick/info`,register:Sn}),D({name:`kick/inspect`,register:jn}),D({name:`kick/add`,register:Ce}),D({name:`kick/list`,register:be}),D({name:`kick/explain`,register:Bn}),D({name:`kick/mcp`,register:Xn}),D({name:`kick/tinker`,register:er}),D({name:`kick/remove`,register:or}),D({name:`kick/typegen`,register:lr}),D({name:`kick/check`,register:Or}),D({name:`kick/doctor`,register:me}),D({name:`kick/codemod`,register:Ar}),D({name:`kick/deploy`,register:zr}),D({name:`kick/registry`,typegens:[Ii()]}),D({name:`kick/services`,typegens:[Li()]}),D({name:`kick/modules`,typegens:[Ri()]}),D({name:`kick/plugins`,typegens:[zi()]}),D({name:`kick/augmentations`,typegens:[Bi()]}),D({name:`kick/context`,typegens:[Vi()]}),D({name:`kick/route-flags`,typegens:[Hi()]}),D({name:`kick/assets`,typegens:[Br()]}),D({name:`kick/routes`,typegens:[Xr()]}),D({name:`kick/client`,typegens:[ki()]}),D({name:`kick/env`,typegens:[ji()]}),D({name:`kick/runtime`,typegens:[{id:`kick/runtime`,outExtension:`.ts`,inputs:[`kick.config.ts`,`kick.config.js`,`kick.config.mjs`,`kick.config.json`],async generate(e){let t=e.config?.runtime;if(t!==`fastify`&&t!==`h3`)return null;let{subpath:n,typeName:r}=Ui[t];return[`// Runtime escape-hatch types for the '${t}' engine (kick.config runtime).`,`declare module '@forinda/kickjs' {`,` interface KickRuntimeRegister {`,` runtime: import('${n}').${r}`,` }`,`}`,``,`export {}`,``].join(`
844
- `)}}]})];export{cn as applyDisableFilter,ln as n,Tt as r,G as runAllPluginTypegens,Wi as t};
845
- //# sourceMappingURL=run-plugins-ByRyAAZe.mjs.map
848
+ `}const Ii=()=>({id:`kick/env`,outExtension:`.ts`,inputs:[`src/env.ts`,`src/**/env.ts`,`src/**/*.env.ts`],async generate(e){let t=Ri(e);if(t===!1)return null;let n=await e.getScanResult({root:Li(e),cwd:e.cwd,envFile:t});if(!n.env)return null;let r=e.config?.typegen?.schemaValidator??`zod`,i=k.resolve(e.cwd,`.kickjs/types/kick__env.ts`);return Fi(n.env,i,r)}});function Li(e){return k.resolve(e.cwd,e.config?.typegen?.srcDir??`src`)}function Ri(e){return e.config?.typegen?.envFile}function zi(e){return k.resolve(e.cwd,e.config?.typegen?.srcDir??`src`)}function Bi(e){let t=e.config?.typegen?.envFile;if(t!==!1)return t}function $(e){return{root:zi(e),cwd:e.cwd,envFile:Bi(e)}}const Vi=()=>({id:`kick/registry`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e)),n=k.resolve(e.cwd,`.kickjs/types/kick__registry.d.ts`),r=new Set(t.collisions.map(e=>e.className));return Je(t.classes,n,r)}}),Hi=()=>({id:`kick/services`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e)),n=new Set(t.collisions.map(e=>e.className)),r=Ge(t.classes,t.tokens,t.injects,n);return Ue(`ServiceToken`,r,"(no tokens discovered — declare with createToken<T>() or `kick g service <name>`)")}}),Ui=()=>({id:`kick/modules`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e));return Ue(`ModuleToken`,ze(t.classes),"(no @Module classes discovered — `kick g module <name>` to add one)")}}),Wi=()=>({id:`kick/plugins`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e));return Ve(t.pluginsAndAdapters)}}),Gi=()=>({id:`kick/augmentations`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e));return Qe(t.augmentations)}}),Ki=()=>({id:`kick/context`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e));return t.contextKeys.length===0?null:Be(t.contextKeys)}}),qi=()=>({id:`kick/route-flags`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e));return Ke(t.routeFlags)}}),Ji={fastify:{subpath:`@forinda/kickjs/fastify`,typeName:`FastifyRuntimeTypes`},h3:{subpath:`@forinda/kickjs/h3`,typeName:`H3RuntimeTypes`}},Yi=[D({name:`kick/init`,register:wt}),D({name:`kick/generate`,register:nn}),D({name:`kick/run`,register:_n}),D({name:`kick/info`,register:Sn}),D({name:`kick/inspect`,register:jn}),D({name:`kick/add`,register:Se}),D({name:`kick/list`,register:we}),D({name:`kick/explain`,register:Bn}),D({name:`kick/mcp`,register:Xn}),D({name:`kick/tinker`,register:er}),D({name:`kick/remove`,register:or}),D({name:`kick/typegen`,register:lr}),D({name:`kick/check`,register:Or}),D({name:`kick/doctor`,register:me}),D({name:`kick/codemod`,register:Ar}),D({name:`kick/deploy`,register:Wr}),D({name:`kick/registry`,typegens:[Vi()]}),D({name:`kick/services`,typegens:[Hi()]}),D({name:`kick/modules`,typegens:[Ui()]}),D({name:`kick/plugins`,typegens:[Wi()]}),D({name:`kick/augmentations`,typegens:[Gi()]}),D({name:`kick/context`,typegens:[Ki()]}),D({name:`kick/route-flags`,typegens:[qi()]}),D({name:`kick/assets`,typegens:[Gr()]}),D({name:`kick/routes`,typegens:[ti()]}),D({name:`kick/client`,typegens:[Pi()]}),D({name:`kick/env`,typegens:[Ii()]}),D({name:`kick/runtime`,typegens:[{id:`kick/runtime`,outExtension:`.ts`,inputs:[`kick.config.ts`,`kick.config.js`,`kick.config.mjs`,`kick.config.json`],async generate(e){let t=e.config?.runtime;if(t!==`fastify`&&t!==`h3`)return null;let{subpath:n,typeName:r}=Ji[t];return[`// Runtime escape-hatch types for the '${t}' engine (kick.config runtime).`,`declare module '@forinda/kickjs' {`,` interface KickRuntimeRegister {`,` runtime: import('${n}').${r}`,` }`,`}`,``,`export {}`,``].join(`
849
+ `)}}]})];export{cn as applyDisableFilter,ln as n,Tt as r,G as runAllPluginTypegens,Yi as t};
850
+ //# sourceMappingURL=run-plugins-Cf_6BgGZ.mjs.map