@forinda/kickjs-cli 8.16.7 → 8.17.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 (36) hide show
  1. package/dist/{agent-docs-buI7Tj1n.mjs → agent-docs-BCgn3jTD.mjs} +2 -2
  2. package/dist/{agent-docs-Dy6kMeRU.mjs → agent-docs-BkoYR-bq.mjs} +3 -3
  3. package/dist/{agent-docs-Dy6kMeRU.mjs.map → agent-docs-BkoYR-bq.mjs.map} +1 -1
  4. package/dist/{build-EiFZLMe9.mjs → build-B0DNAPYL.mjs} +2 -2
  5. package/dist/{build-Uc8ph5YA.mjs → build-ByZMvCD0.mjs} +3 -3
  6. package/dist/{build-Uc8ph5YA.mjs.map → build-ByZMvCD0.mjs.map} +1 -1
  7. package/dist/{builtins-DTXc9hTj.mjs → builtins-BXCr0VP8.mjs} +2 -2
  8. package/dist/{builtins-5-QXn0O3.mjs → builtins-DAucpgiM.mjs} +32 -32
  9. package/dist/cli.mjs +2 -2
  10. package/dist/{config-DoVEXp14.mjs → config-BdvviVyU.mjs} +3 -3
  11. package/dist/{config-DoVEXp14.mjs.map → config-BdvviVyU.mjs.map} +1 -1
  12. package/dist/{config-DLxZpAwN.mjs → config-CjQ2Z43B.mjs} +2 -2
  13. package/dist/{doctor-DqSntgXB.mjs → doctor-C7UorUoN.mjs} +4 -4
  14. package/dist/{doctor-DqSntgXB.mjs.map → doctor-C7UorUoN.mjs.map} +1 -1
  15. package/dist/{fullstack-B2OHY0K4.mjs → fullstack-BRCCVrIH.mjs} +4 -4
  16. package/dist/{fullstack-B2OHY0K4.mjs.map → fullstack-BRCCVrIH.mjs.map} +1 -1
  17. package/dist/{fullstack-1dsidO8X.mjs → fullstack-DjyPVpMg.mjs} +3 -3
  18. package/dist/index.mjs +2 -2
  19. package/dist/{plugin-DzlA2uuk.mjs → plugin-BLiFnUHv.mjs} +2 -2
  20. package/dist/{plugin-h7j4xQb1.mjs → plugin-DJ8l55--.mjs} +2 -2
  21. package/dist/{project-BKEjuej4.mjs → project-BktGFUEX.mjs} +4 -4
  22. package/dist/{project-DIPsmDkV.mjs → project-a6ySsOdn.mjs} +5 -5
  23. package/dist/{project-DIPsmDkV.mjs.map → project-a6ySsOdn.mjs.map} +1 -1
  24. package/dist/{project-root-BhubgoTb.mjs → project-root-B440ayQv.mjs} +3 -3
  25. package/dist/{project-root-BhubgoTb.mjs.map → project-root-B440ayQv.mjs.map} +1 -1
  26. package/dist/{project-root-CxTvojiE.mjs → project-root-DXjh5yeq.mjs} +2 -2
  27. package/dist/{rolldown-runtime-BGq_wXRf.mjs → rolldown-runtime-CP6a3t1y.mjs} +1 -1
  28. package/dist/{run-plugins-BqI-pxkn.mjs → run-plugins-DA8d-SRc.mjs} +33 -33
  29. package/dist/run-plugins-DA8d-SRc.mjs.map +1 -0
  30. package/dist/{typegen-Dw60oC5m.mjs → typegen-BSqoTT4o.mjs} +5 -5
  31. package/dist/{typegen-Dw60oC5m.mjs.map → typegen-BSqoTT4o.mjs.map} +1 -1
  32. package/dist/{typegen-AI0KbOiO.mjs → typegen-CV1AL1yd.mjs} +4 -4
  33. package/dist/{types-CTZ70fug.mjs → types-Dhmt7m7y.mjs} +1 -1
  34. package/package.json +4 -4
  35. package/templates/base/files/README.md +1 -1
  36. package/dist/run-plugins-BqI-pxkn.mjs.map +0 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs-cli v8.16.7
2
+ * @forinda/kickjs-cli v8.17.0
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -8,5 +8,5 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import{t as e}from"./rolldown-runtime-BGq_wXRf.mjs";import{dirname as t,parse as n,resolve as r}from"node:path";import{existsSync as i}from"node:fs";var a=/* @__PURE__ */ e({findProjectRoot:()=>s});const o=[`kick.config.ts`,`kick.config.js`,`kick.config.mjs`,`kick.config.json`];function s(e=process.cwd()){let a=r(e),{root:s}=n(a),c=null,l=a;for(;;){for(let e of o)if(i(r(l,e)))return l;if(c===null&&i(r(l,`package.json`))&&(c=l),l===s)break;let e=t(l);if(e===l)break;l=e}return c??a}export{a as n,s as t};
12
- //# sourceMappingURL=project-root-BhubgoTb.mjs.map
11
+ import{t as e}from"./rolldown-runtime-CP6a3t1y.mjs";import{dirname as t,parse as n,resolve as r}from"node:path";import{existsSync as i}from"node:fs";var a=/* @__PURE__ */ e({findProjectRoot:()=>s});const o=[`kick.config.ts`,`kick.config.js`,`kick.config.mjs`,`kick.config.json`];function s(e=process.cwd()){let a=r(e),{root:s}=n(a),c=null,l=a;for(;;){for(let e of o)if(i(r(l,e)))return l;if(c===null&&i(r(l,`package.json`))&&(c=l),l===s)break;let e=t(l);if(e===l)break;l=e}return c??a}export{a as n,s as t};
12
+ //# sourceMappingURL=project-root-B440ayQv.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"project-root-BhubgoTb.mjs","names":["__exportAll","project_root_exports","findProjectRoot","CONFIG_FILENAMES","start","resolve","startDir","fsRoot","parse","firstPackageJson","cursor","name","existsSync","parent","dirname"],"sources":["../src/utils/project-root.ts"],"sourcesContent":["import { existsSync } from 'node:fs'\nimport { dirname, parse, resolve } from 'node:path'\n\nconst CONFIG_FILENAMES = ['kick.config.ts', 'kick.config.js', 'kick.config.mjs', 'kick.config.json']\n\n/**\n * Walk up from `startDir` looking for the project root. A directory\n * counts as the root when it contains any of:\n * - `kick.config.{ts,js,mjs,json}` (strongest signal)\n * - `package.json` (fallback when no config file exists yet)\n *\n * Returns the absolute path of the first matching directory, or\n * `startDir` itself when nothing was found (no surprises — callers\n * that didn't find a config still get a reasonable cwd).\n *\n * `kick.config.*` wins over `package.json` when both appear at\n * different levels, so adopters running `kick typegen` from `src/`\n * land on the project root that owns the config, not on the nearest\n * workspace package boundary in a monorepo.\n */\nexport function findProjectRoot(startDir: string = process.cwd()): string {\n const start = resolve(startDir)\n const { root: fsRoot } = parse(start)\n\n let firstPackageJson: string | null = null\n let cursor = start\n while (true) {\n for (const name of CONFIG_FILENAMES) {\n if (existsSync(resolve(cursor, name))) return cursor\n }\n if (firstPackageJson === null && existsSync(resolve(cursor, 'package.json'))) {\n firstPackageJson = cursor\n }\n if (cursor === fsRoot) break\n const parent = dirname(cursor)\n if (parent === cursor) break\n cursor = parent\n }\n\n return firstPackageJson ?? start\n}\n"],"mappings":";;;;;;;;;;sMAGA,MAAMG,EAAmB,CAAC,iBAAkB,iBAAkB,kBAAmB,kBAAkB,EAiBnG,SAAgBD,EAAgB,EAAmB,QAAQ,IAAI,EAAW,CACxE,IAAME,EAAQC,EAAQC,CAAQ,EACxB,CAAE,KAAMC,GAAWC,EAAMJ,CAAK,EAEhCK,EAAkC,KAClCC,EAASN,EACb,OAAa,CACX,IAAK,IAAMO,KAAQR,EACjB,GAAIS,EAAWP,EAAQK,EAAQC,CAAI,CAAC,EAAG,OAAOD,EAKhD,GAHID,IAAqB,MAAQG,EAAWP,EAAQK,EAAQ,cAAc,CAAC,IACzE,EAAmBA,GAEjBA,IAAWH,EAAQ,MACvB,IAAMM,EAASC,EAAQJ,CAAM,EAC7B,GAAIG,IAAWH,EAAQ,MACvB,EAASG,CACX,CAEA,OAAOJ,GAAoBL,CAC7B"}
1
+ {"version":3,"file":"project-root-B440ayQv.mjs","names":["__exportAll","project_root_exports","findProjectRoot","CONFIG_FILENAMES","start","resolve","startDir","fsRoot","parse","firstPackageJson","cursor","name","existsSync","parent","dirname"],"sources":["../src/utils/project-root.ts"],"sourcesContent":["import { existsSync } from 'node:fs'\nimport { dirname, parse, resolve } from 'node:path'\n\nconst CONFIG_FILENAMES = ['kick.config.ts', 'kick.config.js', 'kick.config.mjs', 'kick.config.json']\n\n/**\n * Walk up from `startDir` looking for the project root. A directory\n * counts as the root when it contains any of:\n * - `kick.config.{ts,js,mjs,json}` (strongest signal)\n * - `package.json` (fallback when no config file exists yet)\n *\n * Returns the absolute path of the first matching directory, or\n * `startDir` itself when nothing was found (no surprises — callers\n * that didn't find a config still get a reasonable cwd).\n *\n * `kick.config.*` wins over `package.json` when both appear at\n * different levels, so adopters running `kick typegen` from `src/`\n * land on the project root that owns the config, not on the nearest\n * workspace package boundary in a monorepo.\n */\nexport function findProjectRoot(startDir: string = process.cwd()): string {\n const start = resolve(startDir)\n const { root: fsRoot } = parse(start)\n\n let firstPackageJson: string | null = null\n let cursor = start\n while (true) {\n for (const name of CONFIG_FILENAMES) {\n if (existsSync(resolve(cursor, name))) return cursor\n }\n if (firstPackageJson === null && existsSync(resolve(cursor, 'package.json'))) {\n firstPackageJson = cursor\n }\n if (cursor === fsRoot) break\n const parent = dirname(cursor)\n if (parent === cursor) break\n cursor = parent\n }\n\n return firstPackageJson ?? start\n}\n"],"mappings":";;;;;;;;;;sMAGA,MAAMG,EAAmB,CAAC,iBAAkB,iBAAkB,kBAAmB,kBAAkB,EAiBnG,SAAgBD,EAAgB,EAAmB,QAAQ,IAAI,EAAW,CACxE,IAAME,EAAQC,EAAQC,CAAQ,EACxB,CAAE,KAAMC,GAAWC,EAAMJ,CAAK,EAEhCK,EAAkC,KAClCC,EAASN,EACb,OAAa,CACX,IAAK,IAAMO,KAAQR,EACjB,GAAIS,EAAWP,EAAQK,EAAQC,CAAI,CAAC,EAAG,OAAOD,EAKhD,GAHID,IAAqB,MAAQG,EAAWP,EAAQK,EAAQ,cAAc,CAAC,IACzE,EAAmBA,GAEjBA,IAAWH,EAAQ,MACvB,IAAMM,EAASC,EAAQJ,CAAM,EAC7B,GAAIG,IAAWH,EAAQ,MACvB,EAASG,CACX,CAEA,OAAOJ,GAAoBL,CAC7B"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs-cli v8.16.7
2
+ * @forinda/kickjs-cli v8.17.0
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -8,4 +8,4 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import{t as e}from"./rolldown-runtime-BGq_wXRf.mjs";import{existsSync as t}from"node:fs";import{dirname as n,parse as r,resolve as i}from"node:path";var a=/* @__PURE__ */ e({findProjectRoot:()=>s});const o=[`kick.config.ts`,`kick.config.js`,`kick.config.mjs`,`kick.config.json`];function s(e=process.cwd()){let a=i(e),{root:s}=r(a),c=null,l=a;for(;;){for(let e of o)if(t(i(l,e)))return l;if(c===null&&t(i(l,`package.json`))&&(c=l),l===s)break;let e=n(l);if(e===l)break;l=e}return c??a}export{a as n,s as t};
11
+ import{t as e}from"./rolldown-runtime-CP6a3t1y.mjs";import{existsSync as t}from"node:fs";import{dirname as n,parse as r,resolve as i}from"node:path";var a=/* @__PURE__ */ e({findProjectRoot:()=>s});const o=[`kick.config.ts`,`kick.config.js`,`kick.config.mjs`,`kick.config.json`];function s(e=process.cwd()){let a=i(e),{root:s}=r(a),c=null,l=a;for(;;){for(let e of o)if(t(i(l,e)))return l;if(c===null&&t(i(l,`package.json`))&&(c=l),l===s)break;let e=n(l);if(e===l)break;l=e}return c??a}export{a as n,s as t};
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs-cli v8.16.7
2
+ * @forinda/kickjs-cli v8.17.0
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs-cli v8.16.7
2
+ * @forinda/kickjs-cli v8.17.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-BGq_wXRf.mjs";import{C as t,S as n,_ as r,a as i,b as a,d as o,f as s,g as c,h as l,i as u,m as d,n as f,o as p,p as m,u as h,v as g,x as _,y as v}from"./agent-docs-Dy6kMeRU.mjs";import{A as y,C as b,D as x,E as ee,F as S,M as te,N as ne,O as re,P as C,S as ie,T as ae,_ as oe,a as se,b as ce,c as le,f as ue,g as de,h as fe,i as pe,j as me,k as he,l as ge,m as _e,p as ve,r as ye,u as be,v as xe,w as Se,x as Ce,y as we}from"./doctor-DqSntgXB.mjs";import{a as Te,c as w,d as Ee,f as De,h as Oe,l as T,m as ke,o as Ae,p as je,s as E,u as Me}from"./config-DoVEXp14.mjs";import{_ as Ne,a as Pe,b as Fe,d as Ie,g as Le,h as Re,l as ze,m as Be,n as Ve,o as He,p as Ue,r as We,s as D,t as Ge,u as Ke,v as qe,x as Je,y as Ye}from"./project-DIPsmDkV.mjs";import{t as O}from"./project-root-BhubgoTb.mjs";import{n as k,t as Xe}from"./types-CTZ70fug.mjs";import{t as Ze}from"./build-Uc8ph5YA.mjs";import{C as Qe,S as $e,_ as et,a as tt,b as nt,c as rt,d as it,f as at,g as ot,h as st,i as ct,l as lt,m as ut,o as dt,p as ft,r as pt,s as mt,t as ht,u as gt,v as _t,w as vt,x as A,y as yt}from"./typegen-Dw60oC5m.mjs";import{createRequire as bt}from"node:module";import j,{basename as xt,dirname as M,join as N,relative as P,resolve as F,sep as I}from"node:path";import{cpSync as St,existsSync as L,mkdirSync as Ct,readFileSync as R,readdirSync as z,rmSync as wt,statSync as Tt,writeFileSync as B}from"node:fs";import{copyFile as Et,mkdir as Dt,readFile as V,readdir as Ot,rm as kt,stat as At,writeFile as jt}from"node:fs/promises";import{fork as Mt,spawn as Nt,spawnSync as Pt}from"node:child_process";import{createHash as Ft}from"node:crypto";import{fileURLToPath as It,pathToFileURL as H}from"node:url";import{parseSync as Lt}from"oxc-parser";import{arch as Rt,platform as zt,release as Bt}from"node:os";const Vt=[{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`},{value:`storage`,label:`Storage`,hint:`disk, S3 / R2 / MinIO`},{value:`views`,label:`Views`,hint:`server-rendered .kick templates`}];function Ht(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 | inertia`).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(`--deploy <targets>`,`Comma-separated deploy targets to write files for: netlify, vercel, docker (later: kick g deploy)`).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)=>{o(`KickJS — Create a new project`);let n=We(),a=e=>{e&&s.warn(`kick ${Ge} is behind the latest release, ${e} — templates and options added since are missing. Upgrade: npm i -g @forinda/kickjs-cli@latest`)},c=[];try{c=t.deploy?Je(t.deploy):[]}catch(e){s.error(e.message),d(`Aborted.`),process.exitCode=1;return}let u=!!(t.yes||t.nonInteractive);e||=u?`my-api`:await r({message:`Project name`,placeholder:`my-api`,defaultValue:`my-api`});let f;if(e===`.`?(f=F(`.`),e=xt(f)):f=F(t.directory||e),L(f)){let n=z(f);if(n.length>0){if(t.force)s.warn(`Clearing existing files in ${f}`);else if(u){s.warn(`Directory "${e}" is not empty. Pass --force to clear it.`),d(`Aborted.`);return}else{s.warn(`Directory "${e}" is not empty:`);let t=n.slice(0,5);for(let e of t)s.message(` - ${e}`);if(n.length>5&&s.message(` ... and ${n.length-5} more`),!await h({message:v.red(`Remove all existing files and proceed?`),initialValue:!1})){d(`Aborted.`);return}}for(let e of n)wt(F(f,e),{recursive:!0,force:!0})}}u||a(await Promise.race([n,new Promise(e=>setTimeout(e,3e3,null).unref())]));let p=t.template;p||=u?`minimal`:await l({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`},{value:`inertia`,label:`Inertia`,hint:`server-driven React pages, one app, SSR`}]});let g=t.runtime;g||=u?`express`:await l({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 _=t.pm;_||=u?await i(void 0):await l({message:`Package manager`,options:[{value:`pnpm`,label:`pnpm`},{value:`npm`,label:`npm`},{value:`yarn`,label:`yarn`},{value:`bun`,label:`bun`}]});let y=t.repo;y||=u?`inmemory`:await r({message:`Repository name`,placeholder:`inmemory (or a DB name, e.g. postgres)`,defaultValue:`inmemory`}),Oe(y);let b=t.schema;p===`inertia`&&(b&&b!==`zod`&&s.warn(`The inertia template uses zod — ignoring --schema ${b}.`),b=`zod`),b||=u?`zod`:await l({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(b)||(s.warn(`Unknown --schema "${b}", falling back to zod.`),b=`zod`);let x;if(t.packages!==void 0){let e=t.packages.trim().toLowerCase();x=e===``||e===`none`||e===`false`?[]:t.packages.split(`,`).map(e=>e.trim()).filter(Boolean)}else x=u?[]:await m({message:`Select packages to include`,options:[...Vt],required:!1});let ee;ee=t.git===void 0?u?!0:await h({message:`Initialize git repository?`,initialValue:!0}):t.git;let S;if(S=t.install===void 0?u?!0:await h({message:`Install dependencies?`,initialValue:!0}):t.install,t.frontend!==void 0&&t.frontend!==`kick`&&t.frontend!==`vite`){s.error(`Unknown --frontend '${String(t.frontend)}'. Use 'kick' (wired React app) or 'vite' (create-vite).`),d(`Aborted.`);return}let{VITE_TEMPLATES:te,DEFAULT_VITE_TEMPLATE:ne}=await import(`./fullstack-B2OHY0K4.mjs`);if(t.viteTemplate!==void 0&&!te.some(e=>e.value===t.viteTemplate)){s.error(`Unknown --vite-template '${String(t.viteTemplate)}'. TypeScript templates only: ${te.map(e=>e.value).join(`, `)}.`),d(`Aborted.`);return}let re=t.frontend===`vite`?`vite`:`kick`,C=t.viteTemplate??ne;if(p===`fullstack`&&!t.frontend&&!u&&(re=await l({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)`}]})),re===`vite`&&!t.viteTemplate&&!u&&(C=await l({message:`create-vite template`,options:te.map(e=>({value:e.value,label:e.label})),initialValue:ne})),p===`fullstack`){let{initFullstackProject:t}=await import(`./fullstack-B2OHY0K4.mjs`);await t({name:e,directory:f,packageManager:_,initGit:ee,installDeps:S,schemaLib:b,runtime:g,packages:x,frontend:re,viteTemplate:C,deploy:c}),u&&a(await n),d(`Done! Next steps: ${v.cyan(`cd ${e} && ${_}${_===`pnpm`?` dev`:` run dev:server`}`)}`)}else await Ve({name:e,directory:f,packageManager:_,initGit:ee,installDeps:S,template:p,defaultRepo:y,packages:x,schemaLib:b,runtime:g,deploy:c}),u&&a(await n),d(`Done! Next steps: ${v.cyan(`cd ${e} && ${je(_,`dev`)}`)}`)})}function Ut(e,t=[]){let n=/* @__PURE__ */ 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 Xe(`plugin`,t.name,[t.name,t.name])}let r=/* @__PURE__ */ new Map,i=[];for(let t of e)for(let e of t.commands??[]){let n=r.get(e.name);if(n)throw new Xe(`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=/* @__PURE__ */ new Map,c=[];for(let t of e)for(let e of t.typegens??[]){let n=s.get(e.id);if(n)throw new Xe(`typegen`,e.id,[n,t.name]);s.set(e.id,t.name),c.push(e)}let l=/* @__PURE__ */ new Map,u=[];for(let t of e)for(let e of t.generators??[]){let n=l.get(e.name);if(n)throw new Xe(`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-BhubgoTb.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 Wt(e){let{name:n,outDir:r}=e,i=C(n),a=S(n),o=[],s=N(r,`${i}.plugin.ts`);return await t(s,`import {
11
+ import{t as e}from"./rolldown-runtime-CP6a3t1y.mjs";import{C as t,S as n,_ as r,a as i,b as a,d as o,f as s,g as c,h as l,i as u,m as d,n as f,o as p,p as m,u as h,v as g,x as _,y as v}from"./agent-docs-BkoYR-bq.mjs";import{A as y,C as b,D as x,E as ee,F as S,M as te,N as ne,O as re,P as C,S as ie,T as ae,_ as oe,a as se,b as ce,c as le,f as ue,g as de,h as fe,i as pe,j as me,k as he,l as ge,m as _e,p as ve,r as ye,u as be,v as xe,w as Se,x as Ce,y as we}from"./doctor-C7UorUoN.mjs";import{a as Te,c as w,d as Ee,f as De,h as Oe,l as T,m as ke,o as Ae,p as je,s as E,u as Me}from"./config-BdvviVyU.mjs";import{_ as Ne,a as Pe,b as Fe,d as Ie,g as Le,h as Re,l as ze,m as Be,n as Ve,o as He,p as Ue,r as We,s as D,t as Ge,u as Ke,v as qe,x as Je,y as Ye}from"./project-a6ySsOdn.mjs";import{t as O}from"./project-root-B440ayQv.mjs";import{n as k,t as Xe}from"./types-Dhmt7m7y.mjs";import{t as Ze}from"./build-ByZMvCD0.mjs";import{C as Qe,S as $e,_ as et,a as tt,b as nt,c as rt,d as it,f as at,g as ot,h as st,i as ct,l as lt,m as ut,o as dt,p as ft,r as pt,s as mt,t as ht,u as gt,v as _t,w as vt,x as A,y as yt}from"./typegen-BSqoTT4o.mjs";import{createRequire as bt}from"node:module";import j,{basename as xt,dirname as M,join as N,relative as P,resolve as F,sep as I}from"node:path";import{cpSync as St,existsSync as L,mkdirSync as Ct,readFileSync as R,readdirSync as z,rmSync as wt,statSync as Tt,writeFileSync as B}from"node:fs";import{copyFile as Et,mkdir as Dt,readFile as V,readdir as Ot,rm as kt,stat as At,writeFile as jt}from"node:fs/promises";import{fork as Mt,spawn as Nt,spawnSync as Pt}from"node:child_process";import{createHash as Ft}from"node:crypto";import{fileURLToPath as It,pathToFileURL as H}from"node:url";import{parseSync as Lt}from"oxc-parser";import{arch as Rt,platform as zt,release as Bt}from"node:os";const Vt=[{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`},{value:`storage`,label:`Storage`,hint:`disk, S3 / R2 / MinIO`},{value:`views`,label:`Views`,hint:`server-rendered .kick templates`}];function Ht(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 | inertia`).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(`--deploy <targets>`,`Comma-separated deploy targets to write files for: netlify, vercel, docker (later: kick g deploy)`).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)=>{o(`KickJS — Create a new project`);let n=We(),a=e=>{e&&s.warn(`kick ${Ge} is behind the latest release, ${e} — templates and options added since are missing. Upgrade: npm i -g @forinda/kickjs-cli@latest`)},c=[];try{c=t.deploy?Je(t.deploy):[]}catch(e){s.error(e.message),d(`Aborted.`),process.exitCode=1;return}let u=!!(t.yes||t.nonInteractive);e||=u?`my-api`:await r({message:`Project name`,placeholder:`my-api`,defaultValue:`my-api`});let f;if(e===`.`?(f=F(`.`),e=xt(f)):f=F(t.directory||e),L(f)){let n=z(f);if(n.length>0){if(t.force)s.warn(`Clearing existing files in ${f}`);else if(u){s.warn(`Directory "${e}" is not empty. Pass --force to clear it.`),d(`Aborted.`);return}else{s.warn(`Directory "${e}" is not empty:`);let t=n.slice(0,5);for(let e of t)s.message(` - ${e}`);if(n.length>5&&s.message(` ... and ${n.length-5} more`),!await h({message:v.red(`Remove all existing files and proceed?`),initialValue:!1})){d(`Aborted.`);return}}for(let e of n)wt(F(f,e),{recursive:!0,force:!0})}}u||a(await Promise.race([n,new Promise(e=>setTimeout(e,3e3,null).unref())]));let p=t.template;p||=u?`minimal`:await l({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`},{value:`inertia`,label:`Inertia`,hint:`server-driven React pages, one app, SSR`}]});let g=t.runtime;g||=u?`express`:await l({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 _=t.pm;_||=u?await i(void 0):await l({message:`Package manager`,options:[{value:`pnpm`,label:`pnpm`},{value:`npm`,label:`npm`},{value:`yarn`,label:`yarn`},{value:`bun`,label:`bun`}]});let y=t.repo;y||=u?`inmemory`:await r({message:`Repository name`,placeholder:`inmemory (or a DB name, e.g. postgres)`,defaultValue:`inmemory`}),Oe(y);let b=t.schema;p===`inertia`&&(b&&b!==`zod`&&s.warn(`The inertia template uses zod — ignoring --schema ${b}.`),b=`zod`),b||=u?`zod`:await l({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(b)||(s.warn(`Unknown --schema "${b}", falling back to zod.`),b=`zod`);let x;if(t.packages!==void 0){let e=t.packages.trim().toLowerCase();x=e===``||e===`none`||e===`false`?[]:t.packages.split(`,`).map(e=>e.trim()).filter(Boolean)}else x=u?[]:await m({message:`Select packages to include`,options:[...Vt],required:!1});let ee;ee=t.git===void 0?u?!0:await h({message:`Initialize git repository?`,initialValue:!0}):t.git;let S;if(S=t.install===void 0?u?!0:await h({message:`Install dependencies?`,initialValue:!0}):t.install,t.frontend!==void 0&&t.frontend!==`kick`&&t.frontend!==`vite`){s.error(`Unknown --frontend '${String(t.frontend)}'. Use 'kick' (wired React app) or 'vite' (create-vite).`),d(`Aborted.`);return}let{VITE_TEMPLATES:te,DEFAULT_VITE_TEMPLATE:ne}=await import(`./fullstack-BRCCVrIH.mjs`);if(t.viteTemplate!==void 0&&!te.some(e=>e.value===t.viteTemplate)){s.error(`Unknown --vite-template '${String(t.viteTemplate)}'. TypeScript templates only: ${te.map(e=>e.value).join(`, `)}.`),d(`Aborted.`);return}let re=t.frontend===`vite`?`vite`:`kick`,C=t.viteTemplate??ne;if(p===`fullstack`&&!t.frontend&&!u&&(re=await l({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)`}]})),re===`vite`&&!t.viteTemplate&&!u&&(C=await l({message:`create-vite template`,options:te.map(e=>({value:e.value,label:e.label})),initialValue:ne})),p===`fullstack`){let{initFullstackProject:t}=await import(`./fullstack-BRCCVrIH.mjs`);await t({name:e,directory:f,packageManager:_,initGit:ee,installDeps:S,schemaLib:b,runtime:g,packages:x,frontend:re,viteTemplate:C,deploy:c}),u&&a(await n),d(`Done! Next steps: ${v.cyan(`cd ${e} && ${_}${_===`pnpm`?` dev`:` run dev:server`}`)}`)}else await Ve({name:e,directory:f,packageManager:_,initGit:ee,installDeps:S,template:p,defaultRepo:y,packages:x,schemaLib:b,runtime:g,deploy:c}),u&&a(await n),d(`Done! Next steps: ${v.cyan(`cd ${e} && ${je(_,`dev`)}`)}`)})}function Ut(e,t=[]){let n=/* @__PURE__ */ 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 Xe(`plugin`,t.name,[t.name,t.name])}let r=/* @__PURE__ */ new Map,i=[];for(let t of e)for(let e of t.commands??[]){let n=r.get(e.name);if(n)throw new Xe(`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=/* @__PURE__ */ new Map,c=[];for(let t of e)for(let e of t.typegens??[]){let n=s.get(e.id);if(n)throw new Xe(`typegen`,e.id,[n,t.name]);s.set(e.id,t.name),c.push(e)}let l=/* @__PURE__ */ new Map,u=[];for(let t of e)for(let e of t.generators??[]){let n=l.get(e.name);if(n)throw new Xe(`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-B440ayQv.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 Wt(e){let{name:n,outDir:r}=e,i=C(n),a=S(n),o=[],s=N(r,`${i}.plugin.ts`);return await t(s,`import {
12
12
  definePlugin,
13
13
  type AppAdapter,
14
14
  type AppModuleEntry,
@@ -347,7 +347,7 @@ describe('${c}', () => {
347
347
  Example: kick g scaffold Post title:string body:text:optional published:boolean:optional
348
348
  Optional: append :optional (shell-safe, no quoting needed)
349
349
  `),process.exit(1));let s=await E(process.cwd()),c=w(s),l=a.modulesDir??c.dir??`src/modules`,u=cn(t),d=De(s,process.cwd()),f=Ae(O()),p=await ln({name:e,fields:u,modulesDir:F(l),noEntity:a.entity===!1,noTests:a.tests===!1,pluralize:T(a.pluralize,c),pluralizeRoutes:Me(a.pluralizeRoutes,c),tokenScope:d,swagger:f,style:c.style});console.log(`\n Scaffolded ${e} with ${u.length} field(s):`);for(let e of u)console.log(` ${e.name}: ${e.type}${e.optional?` (optional)`:``}`);K(p,o),await hn(o)}),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,t)=>{let r=G(t);n(r),K(await qt({outDir:F(`.`),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 (default: detected from kick.config, packageManager, or the lockfile)`).option(`--template <template>`,`Template: rest | minimal | fullstack | inertia`).option(`-f, --force`,`Overwrite existing files without prompting`).action(async(e,t)=>{let r=G(t);n(r);let i=e.only??`all`;mn.includes(i)?K(await f({outDir:F(`.`),only:i,name:e.name,pm:e.pm,template:e.template,force:e.force}),r):(console.error(` Invalid --only value: ${i}. Expected: ${mn.join(` | `)}`),process.exitCode=1)}),r.command(`deploy <targets...>`).description(`Add deploy files: netlify | vercel | docker (config, serverless entry, build script)`).option(`--pm <pm>`,`Package manager (default: detected)`).option(`-f, --force`,`Overwrite existing files without prompting`).action(async(e,t,r)=>{let i=G(r);n(i);let a;try{a=Je(e.flatMap(e=>e.split(`,`))),K(await Fe({dir:F(`.`),targets:a,pm:t.pm,force:t.force}),i)}catch(e){console.error(` ${e.message}`),process.exitCode=1}});for(let e of t?.generators??[])Cn(r,e,t?.projectRoot)}function Cn(e,t,r){let{source:i,spec:a}=t,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=G(s);n(c);let l=await se({generatorName:a.name,itemName:e??``,args:i??[],flags:o,cwd:process.cwd(),projectRoot:r},[t]);l&&K(l.files,c)})}const wn=`/* AUTO-GENERATED by kick typegen — do not edit. Plugin: `;async function Tn(e){let t=j.resolve(e.cwd,`.kickjs/types`);e.check||await Dt(t,{recursive:!0});let n=/* @__PURE__ */ new Map,r=e.scan??st,i=j.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(H(e).href)},async writeFile(t,n){let r=j.resolve(e.cwd,t);await Dt(j.dirname(r),{recursive:!0}),await jt(r,n,`utf8`)},getScanResult:e=>{let t=En(e),o=n.get(t);if(!o){let s={cacheDir:i,...e};o=a?ot(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=j.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=`${wn}${n.id} */\n\n`+a+`
350
- `,u=``;L(i)&&(u=await V(i,`utf8`)),u===l?s.push({id:n.id,status:`unchanged`,outFile:i}):e.check?(c.push({id:n.id,outFile:i}),s.push({id:n.id,status:`drifted`,outFile:i})):(await jt(i,l,`utf8`),s.push({id:n.id,status:`written`,outFile:i}))}if(c.length>0)throw new be(c);return s}function En(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 Dn(e,t){let n=new Set(t),r=[],i=[],a=/* @__PURE__ */ 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 On=/* @__PURE__ */ e({applyDisableFilter:()=>Dn,runAllPluginTypegens:()=>kn});async function kn(e){let{enabled:t,skipped:n,unknown:r}=Dn(Ut([...ro,...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 Tn({cwd:e.cwd,config:e.config??{},plugins:t,watch:e.watch,check:e.check,changedFiles:e.changedFiles});if(!e.silent&&ue())for(let e of n)console.log(` ${e.id}: ${e.status}`);return n}catch(t){if(t instanceof be||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 An(e){let t=process.platform===`win32`;for(let n of jn(e))for(let e of[`vue-tsc`,`tsgo`,`tsc`]){let r=t?[`${e}.CMD`,`${e}.cmd`,`${e}.exe`]:[e];for(let i of r){let r=N(n,i);if(L(r))return{cmd:r,args:[`--noEmit`],shell:t,kind:e}}}return null}function jn(e){let t=F(e),n=Mn(t);return(n?[t,n]:[t]).map(e=>N(e,`node_modules`,`.bin`))}function Mn(e){for(let t=M(e);t!==M(t);t=M(t)){let n=N(t,`pnpm-workspace.yaml`),r=N(t,`package.json`);if(L(n)||L(r))return Nn(n,r).some(n=>Pn(n,P(t,e)))?t:void 0}}function Nn(e,t){try{if(L(e)){let t=R(e,`utf-8`).split(/^packages:\s*$/m)[1]??``,n=[];for(let e of t.split(`
350
+ `,u=``;L(i)&&(u=await V(i,`utf8`)),u===l?s.push({id:n.id,status:`unchanged`,outFile:i}):e.check?(c.push({id:n.id,outFile:i}),s.push({id:n.id,status:`drifted`,outFile:i})):(await jt(i,l,`utf8`),s.push({id:n.id,status:`written`,outFile:i}))}if(c.length>0)throw new be(c);return s}function En(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 Dn(e,t){let n=new Set(t),r=[],i=[],a=/* @__PURE__ */ 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 On=/* @__PURE__ */ e({applyDisableFilter:()=>Dn,runAllPluginTypegens:()=>kn});async function kn(e){let{enabled:t,skipped:n,unknown:r}=Dn(Ut([...io,...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 Tn({cwd:e.cwd,config:e.config??{},plugins:t,watch:e.watch,check:e.check,changedFiles:e.changedFiles});if(!e.silent&&ue())for(let e of n)console.log(` ${e.id}: ${e.status}`);return n}catch(t){if(t instanceof be||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 An(e){let t=process.platform===`win32`;for(let n of jn(e))for(let e of[`vue-tsc`,`tsgo`,`tsc`]){let r=t?[`${e}.CMD`,`${e}.cmd`,`${e}.exe`]:[e];for(let i of r){let r=N(n,i);if(L(r))return{cmd:r,args:[`--noEmit`],shell:t,kind:e}}}return null}function jn(e){let t=F(e),n=Mn(t);return(n?[t,n]:[t]).map(e=>N(e,`node_modules`,`.bin`))}function Mn(e){for(let t=M(e);t!==M(t);t=M(t)){let n=N(t,`pnpm-workspace.yaml`),r=N(t,`package.json`);if(L(n)||L(r))return Nn(n,r).some(n=>Pn(n,P(t,e)))?t:void 0}}function Nn(e,t){try{if(L(e)){let t=R(e,`utf-8`).split(/^packages:\s*$/m)[1]??``,n=[];for(let e of t.split(`
351
351
  `)){if(!e.trim()||e.trim().startsWith(`#`))continue;let t=/^\s+-\s*['"]?([^'"#]+?)['"]?\s*$/.exec(e);if(!t)break;n.push(t[1])}return n}let{workspaces:n}=JSON.parse(R(t,`utf-8`)),r=Array.isArray(n)?n:n?.packages;return Array.isArray(r)?r.filter(e=>typeof e==`string`):[]}catch{return[]}}function Pn(e,t){let n=e.replace(/^\.\//,``).replace(/\/+$/,``).split(`/`).map(e=>e===`**`?`.*`:e.replace(/[.+^${}()|[\]\\]/g,`\\$&`).replace(/\*/g,`[^/]*`)).join(`/`);return RegExp(`^${n}$`).test(t.split(I).join(`/`))}function Fn(e){let t=e.spawnFn??Nt,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 In(e,t=12){let n=e.trim().split(/\r?\n/);return n.length<=t?n.join(`
352
352
  `):`${n.slice(0,t).join(`
353
353
  `)}\n… ${n.length-t} more line(s)`}function Ln(e){if(typeof e==`boolean`)return e;let t=process.env.KICKJS_WATCH_POLLING;return t===`1`||t===`true`}async function Rn(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 zn(e,t,n={}){t&&(process.env.PORT=t);let r=Ln(n.polling),i=process.cwd(),a=await E(i),o=a?.typegen?.schemaValidator??`zod`,s=a?.typegen?.envFile;try{await ht({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=F(i,a?.typegen?.outDir??`.kickjs/types`);try{let e=await kn({cwd:i,config:a});await ct(c,e,!1)}catch(e){console.warn(` kick typegen: plugin pass skipped (${e?.message??e})`)}let{createRequire:l}=await import(`node:module`),u=l(F(`package.json`)).resolve(`vite`),{createServer:d}=await import(H(u).href);globalThis[le]=`kick-dev`;let f=await d({configFile:F(`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=An(i);e?m=Fn({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(In(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=ge({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(`
@@ -682,7 +682,7 @@ server.on('exit', () => {
682
682
  Cancelled.
683
683
  `);return}await kt(l,{recursive:!0,force:!0}),console.log(` Deleted: ${l}`);let u=N(r,`index.ts`);if(await _(u)){let e=await V(u,`utf-8`),n=e,r=RegExp(`^import\\s*\\{\\s*${y(s)}Module\\s*\\}\\s*from\\s*['"][^'"]*${y(c)}(?:/[^'"]*)?['"].*\\n?`,`gm`);e=e.replace(r,``),e=Xr(e,s),e=e.replace(/\n{3,}/g,`
684
684
 
685
- `),e!==n&&(await t(u,e),console.log(` Unregistered: ${s}Module from ${u}`))}console.log(`\n Module '${c}' removed.\n`)}function Qr(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(`--pluralize`,`The module folder is pluralized (users/ for user)`).option(`--no-pluralize`,`The module folder is the name as typed (the default)`).option(`-f, --force`,`Skip confirmation prompt`).action(async(e,t)=>{let n=await E(process.cwd()),r=w(n),i=t.modulesDir??r.dir??`src/modules`,a=T(t.pluralize,r);for(let n of e)await Zr({name:n,modulesDir:F(i),force:t.force,pluralize:a})})}function $r(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 ei(e){if(e!==void 0)return e===`false`||e===`off`||e===`none`?!1:e}function ti(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=O(process.cwd()),n=await E(t);if(e.list){let{mergeCliPlugins:e}=await import(`./plugin-DzlA2uuk.mjs`),{builtinCliPlugins:t}=await import(`./builtins-DTXc9hTj.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(`
685
+ `),e!==n&&(await t(u,e),console.log(` Unregistered: ${s}Module from ${u}`))}console.log(`\n Module '${c}' removed.\n`)}function Qr(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(`--pluralize`,`The module folder is pluralized (users/ for user)`).option(`--no-pluralize`,`The module folder is the name as typed (the default)`).option(`-f, --force`,`Skip confirmation prompt`).action(async(e,t)=>{let n=await E(process.cwd()),r=w(n),i=t.modulesDir??r.dir??`src/modules`,a=T(t.pluralize,r);for(let n of e)await Zr({name:n,modulesDir:F(i),force:t.force,pluralize:a})})}function $r(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 ei(e){if(e!==void 0)return e===`false`||e===`off`||e===`none`?!1:e}function ti(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=O(process.cwd()),n=await E(t);if(e.list){let{mergeCliPlugins:e}=await import(`./plugin-BLiFnUHv.mjs`),{builtinCliPlugins:t}=await import(`./builtins-BXCr0VP8.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(`
686
686
  Registered typegen plugins:
687
687
  `);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(`
688
688
  Disable one in kick.config.ts:
@@ -698,24 +698,24 @@ server.on('exit', () => {
698
698
  Available checks:
699
699
  --deploy Audit for production readiness (security, config, best practices)
700
700
  --di Find REQUEST-scoped dependencies injected into singleton constructors
701
- `);return}let t=process.cwd();o(e.deploy?`KickJS Deploy Check`:`KickJS DI Check`);let n=c();n.start(`Scanning project...`);let r=[...e.deploy?vi(t):[],...e.di?yi(t):[]];n.stop(`Scan complete`);let i={CRITICAL:0,WARNING:1,INFO:2};r.sort((e,t)=>i[e.severity]-i[t.severity]);for(let e of r)s.message(`${a(e.severity)} ${e.message}`);let l=r.filter(e=>e.severity===`CRITICAL`).length,u=r.filter(e=>e.severity===`WARNING`).length,f=r.filter(e=>e.severity===`INFO`).length,p=u===1?`warning`:`warnings`,m=[l>0?v.red(`${l} critical`):`${l} critical`,u>0?v.yellow(`${u} ${p}`):`${u} ${p}`,`${f} info`].join(`, `);l>0?(d(v.red(`${m} — fix critical issues before deploying`)),process.exit(1)):d(v.green(`${m} — looking good!`))})}const xi=Symbol.for(`kickjs.handler.entryCapture`),Si=Symbol.for(`kickjs.config.describe`);function Ci(e){return Array.isArray(e)?e.join(`,`):typeof e==`object`&&e||typeof e==`string`&&/[\r\n]/.test(e)?JSON.stringify(e):String(e)}function wi(e){let t=[];for(let n of e){let e=[n.description,n.list?`comma-separated list`:void 0].filter(Boolean);for(let n of e.length>0?e.join(` — `).split(/\r?\n/):[])t.push(`# ${n}`);n.required?t.push(`${n.name}=`):t.push(`# ${n.name}=${n.default===void 0?``:Ci(n.default)}`)}return t}function Ti(e){let t=[`# Generated by \`kick env example\` from the env schema and the declared settings
701
+ `);return}let t=process.cwd();o(e.deploy?`KickJS Deploy Check`:`KickJS DI Check`);let n=c();n.start(`Scanning project...`);let r=[...e.deploy?vi(t):[],...e.di?yi(t):[]];n.stop(`Scan complete`);let i={CRITICAL:0,WARNING:1,INFO:2};r.sort((e,t)=>i[e.severity]-i[t.severity]);for(let e of r)s.message(`${a(e.severity)} ${e.message}`);let l=r.filter(e=>e.severity===`CRITICAL`).length,u=r.filter(e=>e.severity===`WARNING`).length,f=r.filter(e=>e.severity===`INFO`).length,p=u===1?`warning`:`warnings`,m=[l>0?v.red(`${l} critical`):`${l} critical`,u>0?v.yellow(`${u} ${p}`):`${u} ${p}`,`${f} info`].join(`, `);l>0?(d(v.red(`${m} — fix critical issues before deploying`)),process.exit(1)):d(v.green(`${m} — looking good!`))})}const xi=Symbol.for(`kickjs.handler.entryCapture`),Si=Symbol.for(`kickjs.config.describe`);function Ci(e){return Array.isArray(e)?e.join(`,`):typeof e==`object`&&e||typeof e==`string`&&/[\r\n]/.test(e)?JSON.stringify(e):String(e)}const wi=e=>e.split(/\r?\n/).map(e=>`# ${e}`);function Ti(e,t=!1){let n=[];for(let r of e){let e=[r.description,r.list?`comma-separated list`:void 0,t&&r.required?`required when used`:void 0].filter(Boolean);e.length>0&&n.push(...wi(e.join(` — `))),r.required&&!t?n.push(`${r.name}=`):n.push(`# ${r.name}=${r.default===void 0?``:Ci(r.default)}`)}return n}function Ei(e){let t=[`# Generated by \`kick env example\` from the env schema and the declared settings
702
702
  # sections. Re-run it after changing them; \`kick env example --check\` fails when stale.
703
703
  #
704
704
  # Uncommented variables are required. Commented ones are optional; the value shown
705
- # is the default. Any variable can come from a file instead: NAME_FILE=/run/secrets/name`];e.env.length>0&&t.push([`# ── App env schema ──`,...wi(e.env)].join(`
706
- `));for(let n of e.sections)t.push([`# ── ${n.prefix} settings (declared by ${n.declaredBy}) ──`,...wi(n.vars)].join(`
705
+ # is the default. Any variable can come from a file instead: NAME_FILE=/run/secrets/name`];e.env.length>0&&t.push([`# ── App env schema ──`,...Ti(e.env)].join(`
706
+ `));for(let n of e.sections)t.push([`# ── ${n.prefix} settings (${n.optional?`optional, `:``}declared by ${n.declaredBy}) ──`,...n.description?wi(n.description):[],...Ti(n.vars,n.optional)].join(`
707
707
  `));return`${t.join(`
708
708
 
709
- `)}\n`}async function Ei(e,t){let n=F(e,t);if(!L(n))throw Error(`${t} not found`);let r=F(e,`vite.config.ts`);if(!L(r))throw Error(`vite.config.ts not found — kick env example loads the app through it`);let{createRequire:i}=await import(`node:module`),a=i(F(e,`package.json`)),{createServer:o}=await import(H(a.resolve(`vite`)).href),s=globalThis,c;s[xi]=e=>{c??=e},s[Si]=!0,s[le]=`kick-env`;let l=await o({configFile:r,root:e,logLevel:`error`,appType:`custom`,server:{middlewareMode:!0,hmr:!1,watch:null}});try{await l.ssrLoadModule(n)}finally{delete s[xi],delete s[Si],delete s[le],await l.close()}if(!c)throw Error(`${t} finished loading without calling bootstrap()`);return c.describeConfig()}function Di(e){e.command(`env`).description(`Work with the environment the app reads`).command(`example`).description(`Write .env.example from the env schema and declared settings sections`).option(`-e, --entry <file>`,`App entry that calls bootstrap()`,`src/index.ts`).option(`-o, --out <file>`,`File to write`,`.env.example`).option(`--check`,`Exit 1 if the file is missing or out of date, instead of writing it`).action(async e=>{let t=process.cwd(),n=F(t,e.out),r;try{r=Ti(await Ei(t,e.entry))}catch(e){console.error(`\n kick env example: ${e.message}\n`),process.exit(1)}e.check?((L(n)?R(n,`utf8`):void 0)!==r&&(console.error(`\n ${e.out} is out of date — run \`kick env example\`.\n`),process.exit(1)),console.log(` ${e.out} is up to date.`)):(B(n,r),console.log(` Wrote ${e.out}`))})}function Oi(e){return e.optsWithGlobals().dryRun??!1}function ki(e){e.command(`codemod`).description(`Codebase migration commands (AST-style rewrites — distinct from db migrate)`).command(`modules`).description(`Rewrite module declarations between class form and the defineModule factory.
709
+ `)}\n`}async function Di(e,t){let n=F(e,t);if(!L(n))throw Error(`${t} not found`);let r=F(e,`vite.config.ts`);if(!L(r))throw Error(`vite.config.ts not found — kick env example loads the app through it`);let{createRequire:i}=await import(`node:module`),a=i(F(e,`package.json`)),{createServer:o}=await import(H(a.resolve(`vite`)).href),s=globalThis,c;s[xi]=e=>{c??=e},s[Si]=!0,s[le]=`kick-env`;let l=await o({configFile:r,root:e,logLevel:`error`,appType:`custom`,server:{middlewareMode:!0,hmr:!1,watch:null}});try{await l.ssrLoadModule(n)}finally{delete s[xi],delete s[Si],delete s[le],await l.close()}if(!c)throw Error(`${t} finished loading without calling bootstrap()`);return c.describeConfig()}function Oi(e){e.command(`env`).description(`Work with the environment the app reads`).command(`example`).description(`Write .env.example from the env schema and declared settings sections`).option(`-e, --entry <file>`,`App entry that calls bootstrap()`,`src/index.ts`).option(`-o, --out <file>`,`File to write`,`.env.example`).option(`--check`,`Exit 1 if the file is missing or out of date, instead of writing it`).action(async e=>{let t=process.cwd(),n=F(t,e.out),r;try{r=Ei(await Di(t,e.entry))}catch(e){console.error(`\n kick env example: ${e.message}\n`),process.exit(1)}e.check?((L(n)?R(n,`utf8`):void 0)!==r&&(console.error(`\n ${e.out} is out of date — run \`kick env example\`.\n`),process.exit(1)),console.log(` ${e.out} is up to date.`)):(B(n,r),console.log(` Wrote ${e.out}`))})}function ki(e){return e.optsWithGlobals().dryRun??!1}function Ai(e){e.command(`codemod`).description(`Codebase migration commands (AST-style rewrites — distinct from db migrate)`).command(`modules`).description(`Rewrite module declarations between class form and the defineModule factory.
710
710
  Direction defaults to \`modules.style\` from kick.config (or "define").
711
711
  --target define|class Override the migration direction.
712
712
  --apply Apply the changes (default: dry-run preview).
713
- --experimental Acknowledge that AST migration is experimental.`).option(`--modules-dir <dir>`,`Modules directory (default: src/modules from kick.config)`).option(`--apply`,`Apply the migration to disk (default: dry-run)`).option(`--experimental`,`Acknowledge that this command is experimental`).option(`--target <style>`,`Migration direction — 'define' or 'class'`).option(`--no-backup`,`Skip the .kickjs/codemod-backups/ snapshot (default: backup on)`).action(async(e,t)=>{let r=Oi(t)||!e.apply;n(r),e.experimental||(console.error(`
713
+ --experimental Acknowledge that AST migration is experimental.`).option(`--modules-dir <dir>`,`Modules directory (default: src/modules from kick.config)`).option(`--apply`,`Apply the migration to disk (default: dry-run)`).option(`--experimental`,`Acknowledge that this command is experimental`).option(`--target <style>`,`Migration direction — 'define' or 'class'`).option(`--no-backup`,`Skip the .kickjs/codemod-backups/ snapshot (default: backup on)`).action(async(e,t)=>{let r=ki(t)||!e.apply;n(r),e.experimental||(console.error(`
714
714
  `+v.red(`Error:`)+` kick codemod modules is experimental — pass --experimental to acknowledge.
715
715
  The regex-based rewrite handles the shapes our templates produce.
716
716
  Hand-rolled modules with non-standard structures may be skipped.
717
717
  Always commit before running with --apply.
718
- `),process.exit(1));let i=await E(process.cwd()),a=w(i),o=F(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 ${v.red(`Error:`)} --target must be 'define' or 'class' (got '${e.target}').\n`),process.exit(1));let c=v.dim(`→ ${s}`),l=r?v.dim(`(dry-run)`):v.bold(`(applying)`);console.log(`\n ${v.bold(`kick codemod modules`)} ${c} ${l}`),console.log(` modulesDir: ${v.dim(o)}\n`);let u=e.backup!==!1&&!r,d=await an(o,{dryRun:r,target:s,backup:u});if(d.backupDir){let e=d.backupDir;console.log(` ${v.green(`✓`)} backup: ${v.dim(e)}\n ${v.dim(`(restore: rm -rf <modulesDir> && mv "<backup>" <modulesDir>)`)}\n`)}else!r&&e.backup===!1&&console.log(` ${v.dim(`(--no-backup — skipping snapshot)`)}\n`);let f=0,p=0;for(let e of d.files)if(e.status===`migrated`)f++,console.log(` ${v.green(`✓`)} ${e.path}`);else{p++;let t=v.dim(`(${e.reason??`skipped`})`);console.log(` ${v.dim(`-`)} ${e.path} ${t}`)}if(console.log(),d.indexStatus===`migrated`)console.log(` ${v.green(`✓`)} ${d.indexPath}`);else if(d.indexStatus===`skipped`){let e=v.dim(`(${d.indexReason??`skipped`})`);console.log(` ${v.dim(`-`)} ${d.indexPath} ${e}`)}else console.log(` ${v.dim(`-`)} ${d.indexPath} ${v.dim(`(not found)`)}`);let m=r?v.dim(` (dry-run — pass --apply to write)`):``;console.log(`\n ${v.bold(String(f))} migrated, ${v.bold(String(p))} skipped${m}\n`)})}function Ai(e){try{let t=JSON.parse(R(F(e,`package.json`),`utf-8`));return{...t.dependencies,...t.devDependencies}}catch{return{}}}function ji(e,t=L,n=Ai(e)){if(n[`@forinda/kickjs-inertia`])return{staticDir:`dist/client`,siteRoot:`.`,apiPath:``,include:[`dist/client/.vite/manifest.json`,`dist/ssr`]};let r=M(e);return(t(F(r,`pnpm-workspace.yaml`))||t(F(r,`package.json`)))&&t(F(r,`web`,`package.json`))?{staticDir:`../web/dist`,siteRoot:`..`,apiPath:`/api`}:n[`@forinda/kickjs-view`]?{staticDir:`dist/public`,siteRoot:`.`,apiPath:``}:{siteRoot:`.`,apiPath:``}}function Mi(e,t,n,r){let i=ji(t,n,r),a=e?.staticDir===!1?void 0:e?.staticDir??i.staticDir;return{entry:e?.entry??`src/serverless.ts`,outDir:e?.outDir??`dist/serverless`,staticDir:a,siteRoot:e?.siteRoot??i.siteRoot,publishDir:e?.publishDir??`dist/public`,apiPath:e?.apiPath??i.apiPath,external:e?.external??[`valibot`,`yup`],vercelRuntime:e?.vercelRuntime??`nodejs22.x`,include:e?.include??i.include??[]}}function Ni(e,t,n={projectDir:`.`}){let r=[` path: '${t}/*',`,...n.preferStatic?[` preferStatic: true,`]:[],...n.includedFiles?.length?[` includedFiles: ${JSON.stringify(n.includedFiles)},`]:[]];return`import { fileURLToPath } from 'node:url'
718
+ `),process.exit(1));let i=await E(process.cwd()),a=w(i),o=F(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 ${v.red(`Error:`)} --target must be 'define' or 'class' (got '${e.target}').\n`),process.exit(1));let c=v.dim(`→ ${s}`),l=r?v.dim(`(dry-run)`):v.bold(`(applying)`);console.log(`\n ${v.bold(`kick codemod modules`)} ${c} ${l}`),console.log(` modulesDir: ${v.dim(o)}\n`);let u=e.backup!==!1&&!r,d=await an(o,{dryRun:r,target:s,backup:u});if(d.backupDir){let e=d.backupDir;console.log(` ${v.green(`✓`)} backup: ${v.dim(e)}\n ${v.dim(`(restore: rm -rf <modulesDir> && mv "<backup>" <modulesDir>)`)}\n`)}else!r&&e.backup===!1&&console.log(` ${v.dim(`(--no-backup — skipping snapshot)`)}\n`);let f=0,p=0;for(let e of d.files)if(e.status===`migrated`)f++,console.log(` ${v.green(`✓`)} ${e.path}`);else{p++;let t=v.dim(`(${e.reason??`skipped`})`);console.log(` ${v.dim(`-`)} ${e.path} ${t}`)}if(console.log(),d.indexStatus===`migrated`)console.log(` ${v.green(`✓`)} ${d.indexPath}`);else if(d.indexStatus===`skipped`){let e=v.dim(`(${d.indexReason??`skipped`})`);console.log(` ${v.dim(`-`)} ${d.indexPath} ${e}`)}else console.log(` ${v.dim(`-`)} ${d.indexPath} ${v.dim(`(not found)`)}`);let m=r?v.dim(` (dry-run — pass --apply to write)`):``;console.log(`\n ${v.bold(String(f))} migrated, ${v.bold(String(p))} skipped${m}\n`)})}function ji(e){try{let t=JSON.parse(R(F(e,`package.json`),`utf-8`));return{...t.dependencies,...t.devDependencies}}catch{return{}}}function Mi(e,t=L,n=ji(e)){if(n[`@forinda/kickjs-inertia`])return{staticDir:`dist/client`,siteRoot:`.`,apiPath:``,include:[`dist/client/.vite/manifest.json`,`dist/ssr`]};let r=M(e);return(t(F(r,`pnpm-workspace.yaml`))||t(F(r,`package.json`)))&&t(F(r,`web`,`package.json`))?{staticDir:`../web/dist`,siteRoot:`..`,apiPath:`/api`}:n[`@forinda/kickjs-view`]?{staticDir:`dist/public`,siteRoot:`.`,apiPath:``}:{siteRoot:`.`,apiPath:``}}function Ni(e,t,n,r){let i=Mi(t,n,r),a=e?.staticDir===!1?void 0:e?.staticDir??i.staticDir;return{entry:e?.entry??`src/serverless.ts`,outDir:e?.outDir??`dist/serverless`,staticDir:a,siteRoot:e?.siteRoot??i.siteRoot,publishDir:e?.publishDir??`dist/public`,apiPath:e?.apiPath??i.apiPath,external:e?.external??[`valibot`,`yup`],vercelRuntime:e?.vercelRuntime??`nodejs22.x`,include:e?.include??i.include??[]}}function Pi(e,t,n={projectDir:`.`}){let r=[` path: '${t}/*',`,...n.preferStatic?[` preferStatic: true,`]:[],...n.includedFiles?.length?[` includedFiles: ${JSON.stringify(n.includedFiles)},`]:[]];return`import { fileURLToPath } from 'node:url'
719
719
  import { handler } from '${e}'
720
720
 
721
721
  // Where the app's build files were packaged; the platform starts this
@@ -729,7 +729,7 @@ export const config = {
729
729
  ${r.join(`
730
730
  `)}
731
731
  }
732
- `}function Pi(){return`import { fileURLToPath } from 'node:url'
732
+ `}function Fi(){return`import { fileURLToPath } from 'node:url'
733
733
  import { handler } from './server.mjs'
734
734
 
735
735
  // The app's build files are copied into this function at their project
@@ -739,11 +739,11 @@ process.env.KICK_APP_ROOT ??= fileURLToPath(new URL('./', import.meta.url))
739
739
  const requestContext = () => globalThis[Symbol.for('@vercel/request-context')]?.get?.()
740
740
 
741
741
  export default (req, res) => handler.node(req, res, requestContext())
742
- `}function Fi(e){return/^\s*publish\s*=\s*["']([^"']+)["']/m.exec(e)?.[1]?.replace(/^\.\//,``).replace(/\/+$/,``)}function Ii(e,t,n=!1){let r=[{handle:`filesystem`},{src:`^${e}/(.*)$`,dest:`/api`}];return n&&e!==``&&r.push({src:`^/_kick/(.*)$`,dest:`/api`}),t&&e!==``&&r.push({src:`^/(.*)$`,dest:`/index.html`}),r}function Li(e,t){let n;try{n=Lt(t,e).program}catch{return[]}let r=[],i=t=>e.slice(0,t).split(`
743
- `).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 Ri(e){let t=F(e,`src`);return L(t)?z(t,{recursive:!0,encoding:`utf-8`}).filter(e=>/\.m?ts$/.test(e)&&!/\.(test|spec|d)\.m?ts$/.test(e)).flatMap(e=>{let n=R(F(t,e),`utf-8`);return n.includes(`@Cron`)?Li(n,`src/${e}`):[]}):[]}function zi(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 Bi(e){let t=[],n=/* @__PURE__ */ 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,` `);i.split(` `).length===5?n.set(zi(i),i):t.push(`${e}: Vercel crons need a five-field expression, so it has no Vercel cron entry`)}return{crons:[...n].map(([e,t])=>({path:`/_kick/cron/${e}`,schedule:t})),warnings:t}}function Vi(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 Hi(e,t){let{createRequire:n}=await import(`node:module`),r=n(F(e,`package.json`)),i;try{i=r.resolve(`${t}/package.json`)}catch{i=F(e,`node_modules`,t,`package.json`)}if(!L(i))throw Error(`${t} is not installed in this project. Run: ${u(e)} add -D vite unplugin-swc @forinda/kickjs-vite`);let a=Vi(JSON.parse(R(i,`utf-8`)));if(!a)throw Error(`${t} has no importable entry point`);return import(H(F(M(i),a)).href)}function Ui(e,t){if(!t.staticDir)return{clientFiles:`bundle`};let n=F(e,t.outDir);return{publicDir:P(n,F(e,t.staticDir)).split(I).join(`/`)}}function Wi(e,t){let n=t?.resolve?.alias,r=Array.isArray(n)?n:Object.entries(n??{}).map(([e,t])=>({find:e,replacement:t}));return{define:t?.define??{},resolve:{alias:[...r,{find:`@`,replacement:F(e,`src`)}]}}}async function Gi(e,t){return(await t({command:`build`,mode:`production`,isSsrBuild:!0},void 0,e))?.config}async function Ki(e,t,n){let r=F(e,t.entry);if(!L(r))throw Error(`${t.entry} not found. The serverless entry exports \`handler = createHandler({ modules })\` — see the Serverless guide.`);let{build:i,loadConfigFromFile:a}=await Hi(e,`vite`),o=await Gi(e,(e,t,n)=>a(e,t,n,`silent`)),{default:s}=await Hi(e,`unplugin-swc`),{devtoolsFlagPlugin:c,devtoolsStripPlugin:l,kickViewsPlugin:u}=await Hi(e,`@forinda/kickjs-vite`),d=Ai(e)[`@forinda/kickjs-view`]?[u(Ui(e,t))]:[];await i({configFile:!1,root:e,logLevel:`warn`,oxc:!1,plugins:[s.vite(),c(),l(),...d],...Wi(e,o),ssr:{noExternal:!0,target:`node`},build:{ssr:!0,target:`node20`,outDir:F(e,t.outDir),emptyOutDir:!0,minify:!1,rollupOptions:{input:r,external:(n,r)=>Ji(n,r?M(r):e)||t.external.includes(n)&&Ji(n,e),output:{format:`esm`,entryFileNames:`server.mjs`,codeSplitting:!1}}}}),d.length&&t.staticDir&&Ct(F(e,t.staticDir),{recursive:!0});let f=F(e,t.outDir,`server.mjs`);return n(`bundled ${P(process.cwd(),f)}`),f}function qi(e){return/^((?:@[a-z0-9][\w.-]*\/)?[a-z0-9][\w.-]*)(?:\/|$)/i.exec(e)?.[1]}function Ji(e,t,n=L){let r=qi(e);if(!r)return!1;for(let e=t;;e=M(e)){if(n(F(e,`node_modules`,r,`package.json`)))return!1;if(M(e)===e)return!0}}function Yi(e,t){let n=P(e,t).split(I)[0];return n!==void 0&&n.startsWith(`.`)}function Xi(e){return e.flatMap(e=>[`/${e} /404 404!`,`/${e}/* /404 404!`])}function Zi(e){try{return Tt(e)}catch{return}}function Qi(e,t){let n=t.filter(t=>!L(F(e,t)));if(n.length>0)throw Error(`${n.join(`, `)} not found — the function reads ${n.length===1?`it`:`them`} at runtime. Run the full build first (\`${je(u(e),`build`)}\`), or fix \`deploy.include\`.`)}function $i(e,t){let n=t.projectRoot,r=()=>Mi(t.config?.deploy,n);e.command(`build:netlify`).description(`Bundle the serverless entry and write the Netlify function`).action(async()=>{let e=r();Qi(n,e.include);let i=await Ki(n,e,t.log),a=F(n,e.siteRoot),o=Ri(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=F(a,`.netlify/v1/functions`);Ct(s,{recursive:!0});let c=P(s,i).split(I).join(`/`),l=e=>e.split(I).join(`/`);B(F(s,`api.mjs`),Ni(c,e.apiPath,{projectDir:l(P(s,n)),preferStatic:e.apiPath===``&&!!e.staticDir,includedFiles:e.include.flatMap(e=>{let t=l(P(s,F(n,e)));return Zi(F(n,e))?.isDirectory()?[`${t}/**`]:[t]})})),t.log(`wrote ${P(process.cwd(),F(s,`api.mjs`))}`);let u=e.staticDir??e.publishDir;if(!e.staticDir)Ct(F(n,u),{recursive:!0}),t.log(`publish directory ready at ${P(process.cwd(),F(n,u))}`);else if(L(F(n,u))){let e=z(F(n,u)).filter(e=>e.startsWith(`.`));if(e.length>0){let t=F(n,u,`_redirects`),r=L(t)?R(t,`utf-8`):``,i=Xi(e).filter(e=>!r.includes(e));i.length>0&&B(t,`${r}${r&&!r.endsWith(`
742
+ `}function Ii(e){return/^\s*publish\s*=\s*["']([^"']+)["']/m.exec(e)?.[1]?.replace(/^\.\//,``).replace(/\/+$/,``)}function Li(e,t,n=!1){let r=[{handle:`filesystem`},{src:`^${e}/(.*)$`,dest:`/api`}];return n&&e!==``&&r.push({src:`^/_kick/(.*)$`,dest:`/api`}),t&&e!==``&&r.push({src:`^/(.*)$`,dest:`/index.html`}),r}function Ri(e,t){let n;try{n=Lt(t,e).program}catch{return[]}let r=[],i=t=>e.slice(0,t).split(`
743
+ `).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 zi(e){let t=F(e,`src`);return L(t)?z(t,{recursive:!0,encoding:`utf-8`}).filter(e=>/\.m?ts$/.test(e)&&!/\.(test|spec|d)\.m?ts$/.test(e)).flatMap(e=>{let n=R(F(t,e),`utf-8`);return n.includes(`@Cron`)?Ri(n,`src/${e}`):[]}):[]}function Bi(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 Vi(e){let t=[],n=/* @__PURE__ */ 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,` `);i.split(` `).length===5?n.set(Bi(i),i):t.push(`${e}: Vercel crons need a five-field expression, so it has no Vercel cron entry`)}return{crons:[...n].map(([e,t])=>({path:`/_kick/cron/${e}`,schedule:t})),warnings:t}}function Hi(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 Ui(e,t){let{createRequire:n}=await import(`node:module`),r=n(F(e,`package.json`)),i;try{i=r.resolve(`${t}/package.json`)}catch{i=F(e,`node_modules`,t,`package.json`)}if(!L(i))throw Error(`${t} is not installed in this project. Run: ${u(e)} add -D vite unplugin-swc @forinda/kickjs-vite`);let a=Hi(JSON.parse(R(i,`utf-8`)));if(!a)throw Error(`${t} has no importable entry point`);return import(H(F(M(i),a)).href)}function Wi(e,t){if(!t.staticDir)return{clientFiles:`bundle`};let n=F(e,t.outDir);return{publicDir:P(n,F(e,t.staticDir)).split(I).join(`/`)}}function Gi(e,t){let n=t?.resolve?.alias,r=Array.isArray(n)?n:Object.entries(n??{}).map(([e,t])=>({find:e,replacement:t}));return{define:t?.define??{},resolve:{alias:[...r,{find:`@`,replacement:F(e,`src`)}]}}}async function Ki(e,t){return(await t({command:`build`,mode:`production`,isSsrBuild:!0},void 0,e))?.config}async function qi(e,t,n){let r=F(e,t.entry);if(!L(r))throw Error(`${t.entry} not found. The serverless entry exports \`handler = createHandler({ modules })\` — see the Serverless guide.`);let{build:i,loadConfigFromFile:a}=await Ui(e,`vite`),o=await Ki(e,(e,t,n)=>a(e,t,n,`silent`)),{default:s}=await Ui(e,`unplugin-swc`),{devtoolsFlagPlugin:c,devtoolsStripPlugin:l,kickViewsPlugin:u}=await Ui(e,`@forinda/kickjs-vite`),d=ji(e)[`@forinda/kickjs-view`]?[u(Wi(e,t))]:[];await i({configFile:!1,root:e,logLevel:`warn`,oxc:!1,plugins:[s.vite(),c(),l(),...d],...Gi(e,o),ssr:{noExternal:!0,target:`node`},build:{ssr:!0,target:`node20`,outDir:F(e,t.outDir),emptyOutDir:!0,minify:!1,rollupOptions:{input:r,external:(n,r)=>Yi(n,r?M(r):e)||t.external.includes(n)&&Yi(n,e),output:{format:`esm`,entryFileNames:`server.mjs`,codeSplitting:!1}}}}),d.length&&t.staticDir&&Ct(F(e,t.staticDir),{recursive:!0});let f=F(e,t.outDir,`server.mjs`);return n(`bundled ${P(process.cwd(),f)}`),f}function Ji(e){return/^((?:@[a-z0-9][\w.-]*\/)?[a-z0-9][\w.-]*)(?:\/|$)/i.exec(e)?.[1]}function Yi(e,t,n=L){let r=Ji(e);if(!r)return!1;for(let e=t;;e=M(e)){if(n(F(e,`node_modules`,r,`package.json`)))return!1;if(M(e)===e)return!0}}function Xi(e,t){let n=P(e,t).split(I)[0];return n!==void 0&&n.startsWith(`.`)}function Zi(e){return e.flatMap(e=>[`/${e} /404 404!`,`/${e}/* /404 404!`])}function Qi(e){try{return Tt(e)}catch{return}}function $i(e,t){let n=t.filter(t=>!L(F(e,t)));if(n.length>0)throw Error(`${n.join(`, `)} not found — the function reads ${n.length===1?`it`:`them`} at runtime. Run the full build first (\`${je(u(e),`build`)}\`), or fix \`deploy.include\`.`)}function ea(e,t){let n=t.projectRoot,r=()=>Ni(t.config?.deploy,n);e.command(`build:netlify`).description(`Bundle the serverless entry and write the Netlify function`).action(async()=>{let e=r();$i(n,e.include);let i=await qi(n,e,t.log),a=F(n,e.siteRoot),o=zi(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=F(a,`.netlify/v1/functions`);Ct(s,{recursive:!0});let c=P(s,i).split(I).join(`/`),l=e=>e.split(I).join(`/`);B(F(s,`api.mjs`),Pi(c,e.apiPath,{projectDir:l(P(s,n)),preferStatic:e.apiPath===``&&!!e.staticDir,includedFiles:e.include.flatMap(e=>{let t=l(P(s,F(n,e)));return Qi(F(n,e))?.isDirectory()?[`${t}/**`]:[t]})})),t.log(`wrote ${P(process.cwd(),F(s,`api.mjs`))}`);let u=e.staticDir??e.publishDir;if(!e.staticDir)Ct(F(n,u),{recursive:!0}),t.log(`publish directory ready at ${P(process.cwd(),F(n,u))}`);else if(L(F(n,u))){let e=z(F(n,u)).filter(e=>e.startsWith(`.`));if(e.length>0){let t=F(n,u,`_redirects`),r=L(t)?R(t,`utf-8`):``,i=Zi(e).filter(e=>!r.includes(e));i.length>0&&B(t,`${r}${r&&!r.endsWith(`
744
744
  `)?`
745
745
  `:``}${i.join(`
746
- `)}\n`)}}let d=F(a,`netlify.toml`);if(L(d)){let e=Fi(R(d,`utf-8`)),r=P(a,F(n,u)).split(I).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();Qi(n,e.include);let i=await Ki(n,e,t.log),a=F(n,e.siteRoot),o=e.staticDir?F(n,e.staticDir):void 0,s=F(a,`.vercel/output`),c=F(s,`functions/api.func`);wt(s,{recursive:!0,force:!0}),Ct(c,{recursive:!0}),St(i,F(c,`server.mjs`)),B(F(c,`index.mjs`),Pi());for(let t of e.include)St(F(n,t),F(c,t),{recursive:!0});if(B(F(c,`.vc-config.json`),`${JSON.stringify({runtime:e.vercelRuntime,handler:`index.mjs`,launcherType:`Nodejs`,supportsResponseStreaming:!0},null,2)}\n`),o){if(!L(o))throw Error(`build:vercel: ${e.staticDir} does not exist — build the frontend first`);St(o,F(s,`static`),{recursive:!0,filter:e=>!Yi(o,e)})}let{crons:l,warnings:u}=Bi(Ri(n));for(let e of u)t.log(`warning: ${e}`);let d={version:3,routes:Ii(e.apiPath,!!o,l.length>0),...l.length>0?{crons:l}:{}};B(F(s,`config.json`),`${JSON.stringify(d,null,2)}\n`),t.log(`wrote ${P(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 ea=()=>({id:`kick/assets`,inputs:[`kick.config.ts`,`kick.config.js`,`kick.config.mjs`],async generate(e){let t=j.resolve(e.cwd,`kick.config.ts`);if(!L(t))return null;let n=await E(e.cwd);if(!n?.assetMap)return null;let r=tt(n.assetMap,e.cwd);return r.count===0?null:dt(r)}}),ta="/* 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 na(e,t,n,r={}){if(e.length===0)return`${ta}
746
+ `)}\n`)}}let d=F(a,`netlify.toml`);if(L(d)){let e=Ii(R(d,`utf-8`)),r=P(a,F(n,u)).split(I).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(n,e.include);let i=await qi(n,e,t.log),a=F(n,e.siteRoot),o=e.staticDir?F(n,e.staticDir):void 0,s=F(a,`.vercel/output`),c=F(s,`functions/api.func`);wt(s,{recursive:!0,force:!0}),Ct(c,{recursive:!0}),St(i,F(c,`server.mjs`)),B(F(c,`index.mjs`),Fi());for(let t of e.include)St(F(n,t),F(c,t),{recursive:!0});if(B(F(c,`.vc-config.json`),`${JSON.stringify({runtime:e.vercelRuntime,handler:`index.mjs`,launcherType:`Nodejs`,supportsResponseStreaming:!0},null,2)}\n`),o){if(!L(o))throw Error(`build:vercel: ${e.staticDir} does not exist — build the frontend first`);St(o,F(s,`static`),{recursive:!0,filter:e=>!Xi(o,e)})}let{crons:l,warnings:u}=Vi(zi(n));for(let e of u)t.log(`warning: ${e}`);let d={version:3,routes:Li(e.apiPath,!!o,l.length>0),...l.length>0?{crons:l}:{}};B(F(s,`config.json`),`${JSON.stringify(d,null,2)}\n`),t.log(`wrote ${P(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 ta=()=>({id:`kick/assets`,inputs:[`kick.config.ts`,`kick.config.js`,`kick.config.mjs`],async generate(e){let t=j.resolve(e.cwd,`kick.config.ts`);if(!L(t))return null;let n=await E(e.cwd);if(!n?.assetMap)return null;let r=tt(n.assetMap,e.cwd);return r.count===0?null:dt(r)}}),na="/* 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 ra(e,t,n,r={}){if(e.length===0)return`${na}
747
747
  // (no routes discovered yet — annotate a controller method with
748
748
  // @Get/@Post/@Put/@Delete/@Patch and re-run \`kick typegen\`)
749
749
  declare global {
@@ -760,15 +760,15 @@ declare global {
760
760
 
761
761
  /** Empty until the first route exists — see kick typegen. */
762
762
  export const kickRpc = {} as const
763
- `;let i=/* @__PURE__ */ new Map;for(let t of e){let e=i.get(t.controller)??[];e.push(t),i.set(t.controller,e)}let a=/* @__PURE__ */ new Map,o=/* @__PURE__ */ 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=oa(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'`,n=`route ${i.controller}.${i.method} (${i.httpMethod} ${i.path})`;r.onWarn?.(e.unexported?`${n}: ${o} schema '${e.identifier}' is declared in ${P(process.cwd(),i.filePath)} but not exported, so the generated types can't import it — ${o} is typed as ${t}. Export it (\`export const ${e.identifier} = ...\`) to type ctx.${o}.`:`${n}: ${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??ia(e),u=c(e.responseSchema??null,e,`response`),d=s(e),f=u??`import('@forinda/kickjs').InferHandlerResponse<${d}['${e.method}']>`,p=aa(e);n.push(` /**`,` * ${e.httpMethod} ${e.path}`,...p.map(e=>` * ${e}`),` */`,` ${e.method}: {`,` params: ${a}`,` body: ${o}`,` query: ${l}`,` response: ${f}`,` contextKeys: ${ra(e)}`,` }`)}n.push(` }`),l.push(n.join(`
763
+ `;let i=/* @__PURE__ */ new Map;for(let t of e){let e=i.get(t.controller)??[];e.push(t),i.set(t.controller,e)}let a=/* @__PURE__ */ new Map,o=/* @__PURE__ */ 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=sa(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'`,n=`route ${i.controller}.${i.method} (${i.httpMethod} ${i.path})`;r.onWarn?.(e.unexported?`${n}: ${o} schema '${e.identifier}' is declared in ${P(process.cwd(),i.filePath)} but not exported, so the generated types can't import it — ${o} is typed as ${t}. Export it (\`export const ${e.identifier} = ...\`) to type ctx.${o}.`:`${n}: ${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??aa(e),u=c(e.responseSchema??null,e,`response`),d=s(e),f=u??`import('@forinda/kickjs').InferHandlerResponse<${d}['${e.method}']>`,p=oa(e);n.push(` /**`,` * ${e.httpMethod} ${e.path}`,...p.map(e=>` * ${e}`),` */`,` ${e.method}: {`,` params: ${a}`,` body: ${o}`,` query: ${l}`,` response: ${f}`,` contextKeys: ${ia(e)}`,` }`)}n.push(` }`),l.push(n.join(`
764
764
  `))}let u=[],d=/* @__PURE__ */ new Set,f=/* @__PURE__ */ new Set;i.has(`Named`)&&r.onWarn?.(`controller class 'Named' collides with the reserved KickRoutes.Named route-name map — its interface declaration-merges into it. Rename the controller.`),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}`;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.`):(d.add(t),f.add(`${e}.${n.method}`),u.push(` '${t}': ${e}['${n.method}']`))}let p=[` interface Api {`,...u,` }`].join(`
765
765
  `);l.push(p);let m=[];for(let[e,t]of i)for(let n of t)f.has(`${e}.${n.method}`)&&m.push(` '${e}.${n.method}': ${e}['${n.method}']`);l.push([` interface Named {`,...m,` }`].join(`
766
- `));let h=[],g=/* @__PURE__ */ new Set;for(let[e,t]of i){let n=la(e);if(g.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}g.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&&h.push(` ${n}: {\n${i.join(`
766
+ `));let h=[],g=/* @__PURE__ */ new Set;for(let[e,t]of i){let n=ua(e);if(g.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}g.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&&h.push(` ${n}: {\n${i.join(`
767
767
  `)}\n },`)}let _=[`/**`,` * Runtime route manifest for the tRPC-style sugar:`," * `createRpc(api, kickRpc)` from @forinda/kickjs-client.",` */`,`export const kickRpc = {`,...h,`} as const`].join(`
768
- `),v=[],y=/* @__PURE__ */ new Map;for(let t of e)y.set(`${t.filePath}::${t.controller}`,t);for(let[e,n]of o){let r=y.get(e),i=ca(``,r.filePath,t),a=r.controllerIsDefaultExport?`default as ${n}`:`${r.controller} as ${n}`;v.push(`import type { ${a} } from '${i}'`)}let b=v.length>0?v.join(`
768
+ `),v=[],y=/* @__PURE__ */ new Map;for(let t of e)y.set(`${t.filePath}::${t.controller}`,t);for(let[e,n]of o){let r=y.get(e),i=la(``,r.filePath,t),a=r.controllerIsDefaultExport?`default as ${n}`:`${r.controller} as ${n}`;v.push(`import type { ${a} } from '${i}'`)}let b=v.length>0?v.join(`
769
769
  `)+`
770
- `:``,x=sa(a)+b,ee=l.join(`
771
- `);return`${ta}${x}
770
+ `:``,x=ca(a)+b,ee=l.join(`
771
+ `);return`${na}${x}
772
772
  declare global {
773
773
  // eslint-disable-next-line @typescript-eslint/no-namespace
774
774
  namespace KickRoutes {
@@ -780,18 +780,18 @@ ${ee}
780
780
  }
781
781
 
782
782
  ${_}
783
- `}function ra(e){let t=e.contextKeys;return t==null?`string`:t.length===0?`never`:t.map(e=>JSON.stringify(e)).join(` | `)}function ia(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; cursor?: string }`}function aa(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 oa(e,t,n,r,i){if(!e||r===!1||e.source===null)return null;let a=ca(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 sa(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(`
783
+ `}function ia(e){let t=e.contextKeys;return t==null?`string`:t.length===0?`never`:t.map(e=>JSON.stringify(e)).join(` | `)}function aa(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; cursor?: string }`}function oa(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 sa(e,t,n,r,i){if(!e||r===!1||e.source===null)return null;let a=la(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 ca(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(`
784
784
  `)+`
785
- `}function ca(e,t,n){if(e===null)return`unknown`;let r=M(n);if(e===``){let e=P(r,t).split(I).join(`/`);return e=e.replace(/\.(ts|tsx|mts|cts)$/i,``),e.startsWith(`.`)||(e=`./`+e),e}if(!e.startsWith(`.`)&&!e.startsWith(`/`))return e;let i=M(t),a=F(i,e),o=P(r,a).split(I).join(`/`);return o=o.replace(/\.(ts|tsx|mts|cts)$/i,``),o.startsWith(`.`)||(o=`./`+o),o}function la(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 ua=()=>({id:`kick/routes`,outExtension:`.ts`,inputs:[`src/**/*.controller.ts`,`src/**/*.module.ts`],async generate(e){let t=await e.getScanResult({root:da(e),cwd:e.cwd,envFile:fa(e)}),n=e.config?.typegen?.schemaValidator??`zod`,r=j.resolve(e.cwd,`.kickjs/types/kick__routes.ts`);return na(t.routes,r,n,{onWarn:t=>e.log.warn(t)})}});function da(e){return j.resolve(e.cwd,e.config?.typegen?.srcDir??`src`)}function fa(e){let t=e.config?.typegen?.envFile;if(t!==!1)return t}const pa=`@typescript/typescript6`;function ma(e){return typeof e?.createProgram==`function`}function ha(e){if(ma(e.typescript))return{api:e.typescript,source:`typescript`};if(ma(e.ts6))return{api:e.ts6,source:pa};let t=`Install it in the project:\n ${u()} add -D ${pa}`;throw e.typescript?Error(`kick typegen: the client route map needs a TypeScript compiler API.
786
- 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 '${pa}' resolved from this project.\n ${t}`)}async function ga(e){let t=bt(N(e,`package.json`)),n=async e=>{try{return await import(H(t.resolve(e)).href)}catch{return null}},[r,i]=await Promise.all([n(`typescript`),n(pa)]);return ha({typescript:_a(r),ts6:_a(i)}).api}function _a(e){let t=e;return t?.default&&typeof t.default==`object`?t.default:e}const va=Symbol(`kick/client: expansion budget exhausted`);var ya=class{ts;checker;program;opts;get printFlags(){return this.ts.TypeFormatFlags.NoTruncation}hoistedByType=/* @__PURE__ */ new Map;inProgress=/* @__PURE__ */ new Map;jsonInProgress=/* @__PURE__ */ 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;let t=this.blocks.length,n=this.nextName,r=new Set(this.hoistedByType.keys());try{return this.render(e,0)}catch(e){if(e!==va)throw e;this.blocks.length=t,this.nextName=n;for(let e of this.hoistedByType.keys())r.has(e)||this.hoistedByType.delete(e);return this.opts.onWarn?.(`expansion abandoned after ${this.budget} depth hoists — emitting 'unknown'. Either the response type never repeats (a generic that grows at every level) or it nests more distinct types than the budget allows; raising maxDepth hoists fewer of them. Declare a response schema on the route for an exact type.`),`unknown`}}render(e,t,n=!0){let r=this.ts.TypeFlags;if(n){let t=this.hoistedByType.get(e);if(t)return t}if(t>this.maxDepth&&!this.isLeaf(e))return this.hoistDeep(e);if(e.flags&(r.String|r.Number|r.Boolean|r.BigInt|r.ESSymbol)||e.flags&(r.Any|r.Unknown|r.Never|r.Void|r.Undefined|r.Null)||e.isLiteral()||e.flags&r.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 i=this.arrayElement(e);if(i){let e=this.render(i.element,t+1),n=/[|&]/.test(e)?`(${e})[]`:`${e}[]`;return i.readonly?`readonly ${n}`:n}let a=this.toJsonType(e);if(a){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(a,t)}finally{this.jsonInProgress.delete(e)}}return this.isLibType(e)?this.renderLibType(e,t):e.flags&r.Object?this.renderObject(e,t):(this.opts.onWarn?.(`could not expand type '${this.checker.typeToString(e)}' — emitting 'unknown'`),`unknown`)}isLeaf(e){let t=this.ts.TypeFlags;return(e.flags&(t.String|t.Number|t.Boolean|t.BigInt|t.ESSymbol|t.Any|t.Unknown|t.Never|t.Void|t.Undefined|t.Null|t.BooleanLiteral))!==0||e.isLiteral()}hoistDeep(e){if(++this.truncations>this.budget)throw va;let t=this.allocName();this.hoistedByType.set(e,t);let n=this.blocks.length;return this.blocks.push(``),this.blocks[n]=this.isPlainObject(e)?`interface ${t} {\n${this.members(e,0,` `)}\n}`:`type ${t} = ${this.render(e,0,!1)}`,t}isPlainObject(e){return(e.flags&this.ts.TypeFlags.Object)!==0&&!e.isUnionOrIntersection()&&!this.isTuple(e)&&!this.arrayElement(e)&&!this.toJsonType(e)&&!this.isLibType(e)}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=`
785
+ `}function la(e,t,n){if(e===null)return`unknown`;let r=M(n);if(e===``){let e=P(r,t).split(I).join(`/`);return e=e.replace(/\.(ts|tsx|mts|cts)$/i,``),e.startsWith(`.`)||(e=`./`+e),e}if(!e.startsWith(`.`)&&!e.startsWith(`/`))return e;let i=M(t),a=F(i,e),o=P(r,a).split(I).join(`/`);return o=o.replace(/\.(ts|tsx|mts|cts)$/i,``),o.startsWith(`.`)||(o=`./`+o),o}function ua(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 da=()=>({id:`kick/routes`,outExtension:`.ts`,inputs:[`src/**/*.controller.ts`,`src/**/*.module.ts`],async generate(e){let t=await e.getScanResult({root:fa(e),cwd:e.cwd,envFile:pa(e)}),n=e.config?.typegen?.schemaValidator??`zod`,r=j.resolve(e.cwd,`.kickjs/types/kick__routes.ts`);return ra(t.routes,r,n,{onWarn:t=>e.log.warn(t)})}});function fa(e){return j.resolve(e.cwd,e.config?.typegen?.srcDir??`src`)}function pa(e){let t=e.config?.typegen?.envFile;if(t!==!1)return t}const ma=`@typescript/typescript6`;function ha(e){return typeof e?.createProgram==`function`}function ga(e){if(ha(e.typescript))return{api:e.typescript,source:`typescript`};if(ha(e.ts6))return{api:e.ts6,source:ma};let t=`Install it in the project:\n ${u()} add -D ${ma}`;throw e.typescript?Error(`kick typegen: the client route map needs a TypeScript compiler API.
786
+ 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 '${ma}' resolved from this project.\n ${t}`)}async function _a(e){let t=bt(N(e,`package.json`)),n=async e=>{try{return await import(H(t.resolve(e)).href)}catch{return null}},[r,i]=await Promise.all([n(`typescript`),n(ma)]);return ga({typescript:va(r),ts6:va(i)}).api}function va(e){let t=e;return t?.default&&typeof t.default==`object`?t.default:e}const ya=Symbol(`kick/client: expansion budget exhausted`);var ba=class{ts;checker;program;opts;get printFlags(){return this.ts.TypeFormatFlags.NoTruncation}hoistedByType=/* @__PURE__ */ new Map;inProgress=/* @__PURE__ */ new Map;jsonInProgress=/* @__PURE__ */ 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;let t=this.blocks.length,n=this.nextName,r=new Set(this.hoistedByType.keys());try{return this.render(e,0)}catch(e){if(e!==ya)throw e;this.blocks.length=t,this.nextName=n;for(let e of this.hoistedByType.keys())r.has(e)||this.hoistedByType.delete(e);return this.opts.onWarn?.(`expansion abandoned after ${this.budget} depth hoists — emitting 'unknown'. Either the response type never repeats (a generic that grows at every level) or it nests more distinct types than the budget allows; raising maxDepth hoists fewer of them. Declare a response schema on the route for an exact type.`),`unknown`}}render(e,t,n=!0){let r=this.ts.TypeFlags;if(n){let t=this.hoistedByType.get(e);if(t)return t}if(t>this.maxDepth&&!this.isLeaf(e))return this.hoistDeep(e);if(e.flags&(r.String|r.Number|r.Boolean|r.BigInt|r.ESSymbol)||e.flags&(r.Any|r.Unknown|r.Never|r.Void|r.Undefined|r.Null)||e.isLiteral()||e.flags&r.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 i=this.arrayElement(e);if(i){let e=this.render(i.element,t+1),n=/[|&]/.test(e)?`(${e})[]`:`${e}[]`;return i.readonly?`readonly ${n}`:n}let a=this.toJsonType(e);if(a){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(a,t)}finally{this.jsonInProgress.delete(e)}}return this.isLibType(e)?this.renderLibType(e,t):e.flags&r.Object?this.renderObject(e,t):(this.opts.onWarn?.(`could not expand type '${this.checker.typeToString(e)}' — emitting 'unknown'`),`unknown`)}isLeaf(e){let t=this.ts.TypeFlags;return(e.flags&(t.String|t.Number|t.Boolean|t.BigInt|t.ESSymbol|t.Any|t.Unknown|t.Never|t.Void|t.Undefined|t.Null|t.BooleanLiteral))!==0||e.isLiteral()}hoistDeep(e){if(++this.truncations>this.budget)throw ya;let t=this.allocName();this.hoistedByType.set(e,t);let n=this.blocks.length;return this.blocks.push(``),this.blocks[n]=this.isPlainObject(e)?`interface ${t} {\n${this.members(e,0,` `)}\n}`:`type ${t} = ${this.render(e,0,!1)}`,t}isPlainObject(e){return(e.flags&this.ts.TypeFlags.Object)!==0&&!e.isUnionOrIntersection()&&!this.isTuple(e)&&!this.arrayElement(e)&&!this.toJsonType(e)&&!this.isLibType(e)}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=`
787
787
  `){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===`
788
788
  `?`
789
- `: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 ba=[`pnpm-lock.yaml`,`package-lock.json`,`yarn.lock`,`bun.lock`,`bun.lockb`],xa=/(?:^|[\\/])(?:node_modules|\.kickjs)(?:[\\/]|$)/;function Sa(e){return Ft(`sha1`).update(e).digest(`hex`)}function Ca(e){let t=Ft(`sha1`);t.update(e.cliVersion),t.update(JSON.stringify(e.options??{})),t.update(e.keys.join(`
790
- `));for(let n of ba){let r=N(e.projectDir,n);if(L(r))try{t.update(R(r))}catch(e){throw Error(`kick/client: cannot read lockfile ${r}`,{cause:e})}}for(let n of e.fileNames.toSorted())if(!xa.test(n)){t.update(n);try{t.update(R(n))}catch(e){throw Error(`kick/client: cannot read project file ${n}`,{cause:e})}}return t.digest(`hex`)}async function wa(e){try{let t=await ga(e.compilerFrom??e.projectDir),n={...t.sys,onUnRecoverableConfigFileDiagnostic:()=>{}},r=t.getParsedCommandLineOfConfigFile(N(e.projectDir,`tsconfig.json`),{},n);return r?Ca({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 Ta(e){let t=await ga(e.compilerFrom??e.projectDir),n=N(M(e.routesFile),`__kick_client_probe__.ts`),r=Oa(e.routesFile,e.keys),i=ja(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.`);Ea(t,i,e.routesFile);let s=ka(t,i,o,e.keys),c=null,l=new ya(t,a,i,{maxDepth:e.maxDepth,onWarn:t=>e.onWarn?.(c?`route '${c}': ${t}`:t)}),u=/* @__PURE__ */ 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===Da(n));if(!i){e.onWarn?.(`route '${r}' could not be resolved — skipped.`);continue}let d=a.getTypeAtLocation(i.type);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.`):(c=r,u.set(r,l.expand(d)),c=null)}return{entries:u,hoisted:l.hoisted()}}function Ea(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(`
791
- `);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 Da(e){return`_K${e}`}function Oa(e,t){let n=`./`+xt(e).replace(/\.tsx?$/,``),r=t.map((e,t)=>`type ${Da(t)} = KickRoutes.Api[${JSON.stringify(e)}]`);return[`import ${JSON.stringify(n)}`,...r].join(`
789
+ `: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 xa=[`pnpm-lock.yaml`,`package-lock.json`,`yarn.lock`,`bun.lock`,`bun.lockb`],Sa=/(?:^|[\\/])(?:node_modules|\.kickjs)(?:[\\/]|$)/;function Ca(e){return Ft(`sha1`).update(e).digest(`hex`)}function wa(e){let t=Ft(`sha1`);t.update(e.cliVersion),t.update(JSON.stringify(e.options??{})),t.update(e.keys.join(`
790
+ `));for(let n of xa){let r=N(e.projectDir,n);if(L(r))try{t.update(R(r))}catch(e){throw Error(`kick/client: cannot read lockfile ${r}`,{cause:e})}}for(let n of e.fileNames.toSorted())if(!Sa.test(n)){t.update(n);try{t.update(R(n))}catch(e){throw Error(`kick/client: cannot read project file ${n}`,{cause:e})}}return t.digest(`hex`)}async function Ta(e){try{let t=await _a(e.compilerFrom??e.projectDir),n={...t.sys,onUnRecoverableConfigFileDiagnostic:()=>{}},r=t.getParsedCommandLineOfConfigFile(N(e.projectDir,`tsconfig.json`),{},n);return r?wa({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 Ea(e){let t=await _a(e.compilerFrom??e.projectDir),n=N(M(e.routesFile),`__kick_client_probe__.ts`),r=ka(e.routesFile,e.keys),i=Ma(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.`);Da(t,i,e.routesFile);let s=Aa(t,i,o,e.keys),c=null,l=new ba(t,a,i,{maxDepth:e.maxDepth,onWarn:t=>e.onWarn?.(c?`route '${c}': ${t}`:t)}),u=/* @__PURE__ */ 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===Oa(n));if(!i){e.onWarn?.(`route '${r}' could not be resolved — skipped.`);continue}let d=a.getTypeAtLocation(i.type);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.`):(c=r,u.set(r,l.expand(d)),c=null)}return{entries:u,hoisted:l.hoisted()}}function Da(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(`
791
+ `);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 Oa(e){return`_K${e}`}function ka(e,t){let n=`./`+xt(e).replace(/\.tsx?$/,``),r=t.map((e,t)=>`type ${Oa(t)} = KickRoutes.Api[${JSON.stringify(e)}]`);return[`import ${JSON.stringify(n)}`,...r].join(`
792
792
  `)+`
793
- `}function ka(e,t,n,r){let i=/* @__PURE__ */ new Set,a=/* @__PURE__ */ 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(Da(t));r&&e.start>=r.getStart(n)&&e.start<r.getEnd()&&i.add(o)}return i}function Aa(e,t){let n=e.filter(e=>/\.d\.(ts|mts|cts)$/.test(e)),r=[];try{r=z(t).filter(e=>e.endsWith(`.ts`)).map(e=>N(t,e))}catch{}return[.../* @__PURE__ */ new Set([...n,...r])]}function ja(e,t,n,r){let i=N(t,`tsconfig.json`),a={...e.sys,onUnRecoverableConfigFileDiagnostic:t=>{throw Error(e.flattenDiagnosticMessageText(t.messageText,`
794
- `))}},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:[...Aa(o.fileNames,M(n)),n],options:o.options,host:s})}const Ma=`/* eslint-disable */
793
+ `}function Aa(e,t,n,r){let i=/* @__PURE__ */ new Set,a=/* @__PURE__ */ 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(Oa(t));r&&e.start>=r.getStart(n)&&e.start<r.getEnd()&&i.add(o)}return i}function ja(e,t){let n=e.filter(e=>/\.d\.(ts|mts|cts)$/.test(e)),r=[];try{r=z(t).filter(e=>e.endsWith(`.ts`)).map(e=>N(t,e))}catch{}return[.../* @__PURE__ */ new Set([...n,...r])]}function Ma(e,t,n,r){let i=N(t,`tsconfig.json`),a={...e.sys,onUnRecoverableConfigFileDiagnostic:t=>{throw Error(e.flattenDiagnosticMessageText(t.messageText,`
794
+ `))}},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:[...ja(o.fileNames,M(n)),n],options:o.options,host:s})}const Na=`/* eslint-disable */
795
795
  // AUTO-GENERATED by \`kick typegen\`. DO NOT EDIT.
796
796
  //
797
797
  // Self-contained: this file has no imports, so a frontend consumes it without
@@ -805,7 +805,7 @@ ${_}
805
805
  //
806
806
  // Written when \`kick dev\` starts, not on save — resolving these types builds a
807
807
  // full TypeScript program over the server. Re-run \`kick typegen\`.
808
- `;function Na(e,t){let n=t.filter(t=>e.entries.has(t));if(n.length===0)return`${Ma}
808
+ `;function Pa(e,t){let n=t.filter(t=>e.entries.has(t));if(n.length===0)return`${Na}
809
809
  // (no routes discovered yet — annotate a controller method with
810
810
  // @Get/@Post/@Put/@Delete/@Patch and re-run \`kick typegen\`)
811
811
  interface Api {}
@@ -822,7 +822,7 @@ export type { Api }
822
822
 
823
823
  `)+`
824
824
 
825
- `:``,i=n.map(t=>` ${JSON.stringify(t)}: ${e.entries.get(t)}`);return`${Ma}
825
+ `:``,i=n.map(t=>` ${JSON.stringify(t)}: ${e.entries.get(t)}`);return`${Na}
826
826
  ${r}interface Api {
827
827
  ${i.join(`
828
828
  `)}
@@ -836,7 +836,7 @@ declare global {
836
836
  }
837
837
 
838
838
  export type { Api }
839
- `}const Pa=`kick/client`,Q=`.kickjs/types/kick__client.d.ts`,Fa=`.kickjs/cache/client-map.sha1`,Ia=(()=>{try{return bt(import.meta.url)(`../../../package.json`).version??`0.0.0`}catch{return`0.0.0`}})();function La(e){try{if(!L(e))return null;let[t,n]=R(e,`utf-8`).trim().split(/\s+/);return t&&n?{inputs:t,output:n}:null}catch{return null}}function Ra(e){return`${wn}${Pa} */\n\n${e}\n`}function za(e){try{return L(e)?R(e,`utf-8`):null}catch{return null}}async function Ba(e){let t=j.resolve(e.cwd,Q);if(!L(t))return!1;try{await kt(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 Va(e){let t=e?.typegen?.client;return typeof t==`object`?t.maxDepth:void 0}function Ha(e){let t=e.config?.typegen?.client;return typeof t==`boolean`?t:t&&typeof t==`object`?t.enabled!==!1:(L(j.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 Ua=()=>({id:Pa,outExtension:`.d.ts`,inputs:[`src/**/*.controller.ts`,`src/**/*.module.ts`],async generate(e){if(!Ha(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:j.resolve(e.cwd,e.config?.typegen?.srcDir??`src`),cwd:e.cwd}),n=[],r=/* @__PURE__ */ 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=Va(e.config),a=await wa({projectDir:e.cwd,keys:n,maxDepth:i,cliVersion:Ia}),o=La(j.resolve(e.cwd,Fa)),s=za(j.resolve(e.cwd,Q));if(a&&o&&s!==null&&o.inputs===a&&o.output===Sa(s))return ue()&&e.log.info?.(` kick/client: unchanged, keeping ${Q}`),null;try{let t=Na(await Ta({projectDir:e.cwd,routesFile:j.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(Fa,`${a} ${Sa(Ra(t))}`),t}catch(t){let n=L(j.resolve(e.cwd,Q)),r=` kick/client: skipped — ${t instanceof Error?t.message:String(t)}`;return n?e.log.warn(r):ue()&&e.log.info?.(r),n&&await Ba(e),null}}});function Wa(e,t,n=`zod`){if(!e)return null;let r=M(t),i=P(r,e.filePath).split(I).join(`/`);return i=i.replace(/\.(ts|tsx|mts|cts)$/i,``),i.startsWith(`.`)||(i=`./`+i),`/* eslint-disable */
839
+ `}const Fa=`kick/client`,Q=`.kickjs/types/kick__client.d.ts`,Ia=`.kickjs/cache/client-map.sha1`,La=(()=>{try{return bt(import.meta.url)(`../../../package.json`).version??`0.0.0`}catch{return`0.0.0`}})();function Ra(e){try{if(!L(e))return null;let[t,n]=R(e,`utf-8`).trim().split(/\s+/);return t&&n?{inputs:t,output:n}:null}catch{return null}}function za(e){return`${wn}${Fa} */\n\n${e}\n`}function Ba(e){try{return L(e)?R(e,`utf-8`):null}catch{return null}}async function Va(e){let t=j.resolve(e.cwd,Q);if(!L(t))return!1;try{await kt(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 Ha(e){let t=e?.typegen?.client;return typeof t==`object`?t.maxDepth:void 0}function Ua(e){let t=e.config?.typegen?.client;return typeof t==`boolean`?t:t&&typeof t==`object`?t.enabled!==!1:(L(j.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 Wa=()=>({id:Fa,outExtension:`.d.ts`,inputs:[`src/**/*.controller.ts`,`src/**/*.module.ts`],async generate(e){if(!Ua(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:j.resolve(e.cwd,e.config?.typegen?.srcDir??`src`),cwd:e.cwd}),n=[],r=/* @__PURE__ */ 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=Ha(e.config),a=await Ta({projectDir:e.cwd,keys:n,maxDepth:i,cliVersion:La}),o=Ra(j.resolve(e.cwd,Ia)),s=Ba(j.resolve(e.cwd,Q));if(a&&o&&s!==null&&o.inputs===a&&o.output===Ca(s))return ue()&&e.log.info?.(` kick/client: unchanged, keeping ${Q}`),null;try{let t=Pa(await Ea({projectDir:e.cwd,routesFile:j.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(Ia,`${a} ${Ca(za(t))}`),t}catch(t){let n=L(j.resolve(e.cwd,Q)),r=` kick/client: skipped — ${t instanceof Error?t.message:String(t)}`;return n?e.log.warn(r):ue()&&e.log.info?.(r),n&&await Va(e),null}}});function Ga(e,t,n=`zod`){if(!e)return null;let r=M(t),i=P(r,e.filePath).split(I).join(`/`);return i=i.replace(/\.(ts|tsx|mts|cts)$/i,``),i.startsWith(`.`)||(i=`./`+i),`/* eslint-disable */
840
840
  // AUTO-GENERATED by \`kick typegen\`. DO NOT EDIT.
841
841
  // Re-run with \`kick typegen\` or rely on \`kick dev\` to refresh.
842
842
 
@@ -874,6 +874,6 @@ declare global {
874
874
  }
875
875
 
876
876
  export {}
877
- `}const Ga=()=>({id:`kick/env`,outExtension:`.ts`,inputs:[`src/env.ts`,`src/**/env.ts`,`src/**/*.env.ts`],async generate(e){let t=qa(e);if(t===!1)return null;let n=await e.getScanResult({root:Ka(e),cwd:e.cwd,envFile:t});if(!n.env)return null;let r=e.config?.typegen?.schemaValidator??`zod`,i=j.resolve(e.cwd,`.kickjs/types/kick__env.ts`);return Wa(n.env,i,r)}});function Ka(e){return j.resolve(e.cwd,e.config?.typegen?.srcDir??`src`)}function qa(e){return e.config?.typegen?.envFile}function Ja(e){return j.resolve(e.cwd,e.config?.typegen?.srcDir??`src`)}function Ya(e){let t=e.config?.typegen?.envFile;if(t!==!1)return t}function $(e){return{root:Ja(e),cwd:e.cwd,envFile:Ya(e)}}const Xa=()=>({id:`kick/registry`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e)),n=j.resolve(e.cwd,`.kickjs/types/kick__registry.d.ts`),r=new Set(t.collisions.map(e=>e.className));return at(t.classes,n,r)}}),Za=()=>({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=lt(t.classes,t.tokens,t.injects,n);return ut(`ServiceToken`,r,"(no tokens discovered — declare with createToken<T>() or `kick g service <name>`)")}}),Qa=()=>({id:`kick/modules`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e));return ut(`ModuleToken`,rt(t.classes),"(no @Module classes discovered — `kick g module <name>` to add one)")}}),$a=()=>({id:`kick/plugins`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e));return it(t.pluginsAndAdapters)}}),eo=()=>({id:`kick/context`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e));return t.contextKeys.length===0?null:gt(t.contextKeys)}}),to=()=>({id:`kick/route-flags`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e));return ft(t.routeFlags)}}),no={express:{subpath:`@forinda/kickjs/express`,typeName:`ExpressRuntimeTypes`},fastify:{subpath:`@forinda/kickjs/fastify`,typeName:`FastifyRuntimeTypes`},h3:{subpath:`@forinda/kickjs/h3`,typeName:`H3RuntimeTypes`}},ro=[k({name:`kick/init`,register:Ht}),k({name:`kick/generate`,register:Sn}),k({name:`kick/run`,register:Vn}),k({name:`kick/info`,register:Kn}),k({name:`kick/inspect`,register:nr}),k({name:`kick/add`,register:Ke}),k({name:`kick/runtime-swap`,register:vr}),k({name:`kick/list`,register:Ie}),k({name:`kick/explain`,register:jr}),k({name:`kick/mcp`,register:Hr}),k({name:`kick/tinker`,register:Kr}),k({name:`kick/remove`,register:Qr}),k({name:`kick/typegen`,register:ti}),k({name:`kick/check`,register:bi}),k({name:`kick/doctor`,register:ye}),k({name:`kick/env-command`,register:Di}),k({name:`kick/codemod`,register:ki}),k({name:`kick/deploy`,register:$i}),k({name:`kick/registry`,typegens:[Xa()]}),k({name:`kick/services`,typegens:[Za()]}),k({name:`kick/modules`,typegens:[Qa()]}),k({name:`kick/plugins`,typegens:[$a()]}),k({name:`kick/context`,typegens:[eo()]}),k({name:`kick/route-flags`,typegens:[to()]}),k({name:`kick/assets`,typegens:[ea()]}),k({name:`kick/routes`,typegens:[ua()]}),k({name:`kick/client`,typegens:[Ua()]}),k({name:`kick/env`,typegens:[Ga()]}),k({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??`express`;if(t!==`express`&&t!==`fastify`&&t!==`h3`)return null;let{subpath:n,typeName:r}=no[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(`
878
- `)}}]})];export{Dn as applyDisableFilter,On as n,Ut as r,kn as runAllPluginTypegens,ro as t};
879
- //# sourceMappingURL=run-plugins-BqI-pxkn.mjs.map
877
+ `}const Ka=()=>({id:`kick/env`,outExtension:`.ts`,inputs:[`src/env.ts`,`src/**/env.ts`,`src/**/*.env.ts`],async generate(e){let t=Ja(e);if(t===!1)return null;let n=await e.getScanResult({root:qa(e),cwd:e.cwd,envFile:t});if(!n.env)return null;let r=e.config?.typegen?.schemaValidator??`zod`,i=j.resolve(e.cwd,`.kickjs/types/kick__env.ts`);return Ga(n.env,i,r)}});function qa(e){return j.resolve(e.cwd,e.config?.typegen?.srcDir??`src`)}function Ja(e){return e.config?.typegen?.envFile}function Ya(e){return j.resolve(e.cwd,e.config?.typegen?.srcDir??`src`)}function Xa(e){let t=e.config?.typegen?.envFile;if(t!==!1)return t}function $(e){return{root:Ya(e),cwd:e.cwd,envFile:Xa(e)}}const Za=()=>({id:`kick/registry`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e)),n=j.resolve(e.cwd,`.kickjs/types/kick__registry.d.ts`),r=new Set(t.collisions.map(e=>e.className));return at(t.classes,n,r)}}),Qa=()=>({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=lt(t.classes,t.tokens,t.injects,n);return ut(`ServiceToken`,r,"(no tokens discovered — declare with createToken<T>() or `kick g service <name>`)")}}),$a=()=>({id:`kick/modules`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e));return ut(`ModuleToken`,rt(t.classes),"(no @Module classes discovered — `kick g module <name>` to add one)")}}),eo=()=>({id:`kick/plugins`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e));return it(t.pluginsAndAdapters)}}),to=()=>({id:`kick/context`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e));return t.contextKeys.length===0?null:gt(t.contextKeys)}}),no=()=>({id:`kick/route-flags`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e));return ft(t.routeFlags)}}),ro={express:{subpath:`@forinda/kickjs/express`,typeName:`ExpressRuntimeTypes`},fastify:{subpath:`@forinda/kickjs/fastify`,typeName:`FastifyRuntimeTypes`},h3:{subpath:`@forinda/kickjs/h3`,typeName:`H3RuntimeTypes`}},io=[k({name:`kick/init`,register:Ht}),k({name:`kick/generate`,register:Sn}),k({name:`kick/run`,register:Vn}),k({name:`kick/info`,register:Kn}),k({name:`kick/inspect`,register:nr}),k({name:`kick/add`,register:Ke}),k({name:`kick/runtime-swap`,register:vr}),k({name:`kick/list`,register:Ie}),k({name:`kick/explain`,register:jr}),k({name:`kick/mcp`,register:Hr}),k({name:`kick/tinker`,register:Kr}),k({name:`kick/remove`,register:Qr}),k({name:`kick/typegen`,register:ti}),k({name:`kick/check`,register:bi}),k({name:`kick/doctor`,register:ye}),k({name:`kick/env-command`,register:Oi}),k({name:`kick/codemod`,register:Ai}),k({name:`kick/deploy`,register:ea}),k({name:`kick/registry`,typegens:[Za()]}),k({name:`kick/services`,typegens:[Qa()]}),k({name:`kick/modules`,typegens:[$a()]}),k({name:`kick/plugins`,typegens:[eo()]}),k({name:`kick/context`,typegens:[to()]}),k({name:`kick/route-flags`,typegens:[no()]}),k({name:`kick/assets`,typegens:[ta()]}),k({name:`kick/routes`,typegens:[da()]}),k({name:`kick/client`,typegens:[Wa()]}),k({name:`kick/env`,typegens:[Ka()]}),k({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??`express`;if(t!==`express`&&t!==`fastify`&&t!==`h3`)return null;let{subpath:n,typeName:r}=ro[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(`
878
+ `)}}]})];export{Dn as applyDisableFilter,On as n,Ut as r,kn as runAllPluginTypegens,io as t};
879
+ //# sourceMappingURL=run-plugins-DA8d-SRc.mjs.map