@forinda/kickjs-cli 8.2.2 → 8.2.4

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 (45) hide show
  1. package/dist/{agent-docs-DZr7FzZj.mjs → agent-docs-C6ZYsFJV.mjs} +3 -3
  2. package/dist/{agent-docs-DZr7FzZj.mjs.map → agent-docs-C6ZYsFJV.mjs.map} +1 -1
  3. package/dist/{agent-docs-BM62y5Ls.mjs → agent-docs-GCMhcDHy.mjs} +2 -2
  4. package/dist/{build-UyYIuF7x.mjs → build-DTs2SHKS.mjs} +2 -2
  5. package/dist/{build-DePaCEwC.mjs → build-hdxD_kEK.mjs} +3 -3
  6. package/dist/{build-DePaCEwC.mjs.map → build-hdxD_kEK.mjs.map} +1 -1
  7. package/dist/{builtins-BMFWC4BT.mjs → builtins-BZGJgOyW.mjs} +2 -2
  8. package/dist/{builtins-B-PqsutG.mjs → builtins-Ci7vBC42.mjs} +10 -15
  9. package/dist/cli.mjs +2 -2
  10. package/dist/{config-CKj2JDsP.mjs → config-Bsokk8bV.mjs} +2 -2
  11. package/dist/{config-BD0-dCTW.mjs → config-Dgap2WmJ.mjs} +3 -3
  12. package/dist/{config-BD0-dCTW.mjs.map → config-Dgap2WmJ.mjs.map} +1 -1
  13. package/dist/{doctor-GDaIVDho.mjs → doctor-Crq8eZsF.mjs} +4 -4
  14. package/dist/{doctor-GDaIVDho.mjs.map → doctor-Crq8eZsF.mjs.map} +1 -1
  15. package/dist/{fullstack-CqtrWxWC.mjs → fullstack-C7Q-BJcj.mjs} +11 -15
  16. package/dist/{fullstack-D_8yP2IS.mjs → fullstack-onQslndx.mjs} +12 -16
  17. package/dist/fullstack-onQslndx.mjs.map +1 -0
  18. package/dist/index.d.mts +8 -0
  19. package/dist/index.d.mts.map +1 -1
  20. package/dist/index.mjs +2 -2
  21. package/dist/{plugin-CsZ1uy9o.mjs → plugin-BYqbu6uO.mjs} +2 -2
  22. package/dist/{plugin-TPTLqV5n.mjs → plugin-BuSzbyf2.mjs} +2 -2
  23. package/dist/project-4kpuS1ud.mjs +434 -0
  24. package/dist/{project-CXfIXH0R.mjs → project-BnXVCMd6.mjs} +32 -25
  25. package/dist/project-BnXVCMd6.mjs.map +1 -0
  26. package/dist/{project-docs-B25hGwDz.mjs → project-docs-CDr1HNPD.mjs} +2 -2
  27. package/dist/{project-docs-B25hGwDz.mjs.map → project-docs-CDr1HNPD.mjs.map} +1 -1
  28. package/dist/{project-docs-QdA-uXKP.mjs → project-docs-Dn60gTjG.mjs} +1 -1
  29. package/dist/{project-root-C2D12O-n.mjs → project-root-B1lyUoe8.mjs} +3 -3
  30. package/dist/{project-root-C2D12O-n.mjs.map → project-root-B1lyUoe8.mjs.map} +1 -1
  31. package/dist/{project-root-aksYdjTp.mjs → project-root-B5MNmlIn.mjs} +2 -2
  32. package/dist/{prompts-CFLyw4_b.mjs → prompts-8ssKQ4Kn.mjs} +2 -2
  33. package/dist/{prompts-CFLyw4_b.mjs.map → prompts-8ssKQ4Kn.mjs.map} +1 -1
  34. package/dist/{rolldown-runtime-BgqrGhnH.mjs → rolldown-runtime-DtbiLYsN.mjs} +1 -1
  35. package/dist/{run-plugins-DSqJuFsH.mjs → run-plugins-CxuPMW4H.mjs} +9 -14
  36. package/dist/run-plugins-CxuPMW4H.mjs.map +1 -0
  37. package/dist/{typegen-C5X7j_d9.mjs → typegen-Ca46MGcE.mjs} +5 -5
  38. package/dist/{typegen-C5X7j_d9.mjs.map → typegen-Ca46MGcE.mjs.map} +1 -1
  39. package/dist/{typegen-D024Elzf.mjs → typegen-ClJqftm9.mjs} +4 -4
  40. package/dist/{types-BB70_2Oi.mjs → types-CJlHwJb4.mjs} +1 -1
  41. package/package.json +10 -10
  42. package/dist/fullstack-D_8yP2IS.mjs.map +0 -1
  43. package/dist/project-BXTRWY8c.mjs +0 -427
  44. package/dist/project-CXfIXH0R.mjs.map +0 -1
  45. package/dist/run-plugins-DSqJuFsH.mjs.map +0 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs-cli v8.2.2
2
+ * @forinda/kickjs-cli v8.2.4
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-BgqrGhnH.mjs";import{statSync as t}from"node:fs";import{basename as n,dirname as r,join as i,relative as a,resolve as o,sep as s}from"node:path";import{mkdir as c,readFile as l,readdir as u,stat as d,unlink as f,writeFile as p}from"node:fs/promises";import{parseSync as m}from"oxc-parser";import{globSync as h}from"glob";import{groupAssetKeys as g}from"@forinda/kickjs";const _=[`classes`,`tokens`,`injects`,`pluginsAndAdapters`,`augmentations`,`contextKeys`,`routeFlags`,`routes`,`moduleMounts`,`globPatterns`];function v(e){if(!e||typeof e!=`object`)return!1;let t=e;return _.every(e=>Array.isArray(t[e]))}var y=class e{path;prev;next=new Map;nextSig=new Map;constructor(e,t){this.path=e,this.prev=t}static async load(t){let n=i(t,`scan.json`),r=new Map;try{let e=await l(n,`utf-8`),t=JSON.parse(e);if(t.version===3&&t.files)for(let[e,n]of Object.entries(t.files))n&&typeof n.sig==`string`&&v(n.extract)&&r.set(e,n)}catch{}return new e(n,r)}static async signature(e){try{let t=await d(e);return`${t.mtimeMs}:${t.size}`}catch{return null}}get(e,t){let n=this.prev.get(e);return n&&n.sig===t?n.extract:null}set(e,t,n){this.next.set(e,n),this.nextSig.set(e,t)}cachedFiles(){return[...this.prev.keys()]}peek(e){return this.prev.get(e)?.extract??null}carry(e){let t=this.prev.get(e);return t?(this.next.set(e,t.extract),this.nextSig.set(e,t.sig),!0):!1}async save(){let e={};for(let[t,n]of this.next){let r=this.nextSig.get(t);r&&(e[t]={sig:r,extract:n})}let t={version:3,files:e};try{await c(r(this.path),{recursive:!0}),await p(this.path,JSON.stringify(t),`utf-8`)}catch{}}};let b=null;function x(){return b??=new Set(L),b}const S=new Set([`Get`,`Post`,`Put`,`Delete`,`Patch`]);function C(e){return typeof e==`object`&&!!e&&typeof e.type==`string`}function w(e,t){if(Array.isArray(e)){for(let n of e)w(n,t);return}if(C(e)){t(e);for(let n of Object.keys(e)){if(n===`type`)continue;let r=e[n];typeof r==`object`&&r&&w(r,t)}}}function T(e){if(!C(e))return null;if(e.type===`Literal`&&typeof e.value==`string`)return e.value;if(e.type===`TemplateLiteral`){let t=e.quasis,n=e.expressions;if(t?.length===1&&(n?.length??0)===0){let e=t[0].value?.cooked;return typeof e==`string`?e:null}}return null}function E(e){return C(e)&&e.type===`Identifier`?e.name:null}function D(e){return E(e.callee)}function O(e,t){if(!e||e.type!==`ObjectExpression`)return null;for(let n of e.properties??[]){if(n.type!==`Property`)continue;let e=n.key;if((E(e)??(e.type===`Literal`?String(e.value):T(e)))===t)return n.value}return null}function k(e){let t=e.arguments?.[0];return C(t)&&t.type===`ObjectExpression`?t:null}function A(e,t){let n=O(e,t);if(!C(n)||n.type!==`ArrayExpression`)return[];let r=[];for(let e of n.elements??[]){let t=T(e);t!==null&&r.push(t)}return r}function ee(e,t){return a(t,e).split(s).join(`/`)}function te(e){return(e.match(/:([a-zA-Z_]\w*)/g)??[]).map(e=>e.slice(1))}function ne(e,t){for(let n of e.implements??[]){let e=n.expression??n;if(E(e)===t)return!0;if(e.type===`TSQualifiedName`||e.type===`MemberExpression`){let n=e.right??e.property;if(n&&E(n)===t)return!0}}return!1}function j(e){return e.decorators??[]}function M(e){let t=e.expression;if(!C(t)||t.type!==`CallExpression`)return null;let n=D(t);return n?{name:n,call:t}:null}function re(e){let t=new Map,n=new Set;for(let r of e.body??[]){if(r.type===`ImportDeclaration`){let e=T(r.source)??``;for(let n of r.specifiers??[]){let r=E(n.local);r&&t.set(r,{source:e})}continue}let e=r.type===`VariableDeclaration`?r:r.type===`ExportNamedDeclaration`&&C(r.declaration)?r.declaration:null;if(C(e)&&e.type===`VariableDeclaration`)for(let t of e.declarations??[]){let e=E(t.id);e&&n.add(e)}}return{imports:t,topLevelConsts:n}}function N(e,t){let n=t.imports.get(e);return n?{identifier:e,source:n.source}:t.topLevelConsts.has(e)?{identifier:e,source:``}:{identifier:e,source:null}}function ie(e,t){let n=[];for(let r of e){let e=M(r),i=e?e.name:E(r.expression);if(!i||S.has(i))continue;let a=t.imports.get(i);n.push({identifier:i,source:a?a.source:t.topLevelConsts.has(i)?``:null})}return n}const P=new Set([`bootstrap`,`createWebApp`,`Application`]);function ae(e,t){if(!P.has(e))return!1;let n=t.imports.get(e)?.source;return n===`@forinda/kickjs`||(n?.startsWith(`@forinda/kickjs/`)??!1)}function oe(e,t){let n={refs:[],resolved:!1},r=se(e);if(!r||r.type!==`ArrayExpression`)return n;let i=[];for(let e of r.elements??[]){if(!C(e)||e.type!==`MemberExpression`||E(e.property)!==`registration`)return n;let r=e.object,a=E(r);if(!a&&C(r)&&r.type===`CallExpression`){let e=r.callee;C(e)&&e.type===`MemberExpression`&&E(e.property)===`with`&&(a=E(e.object))}if(!a)return n;let o=t.imports.get(a);i.push({identifier:a,source:o?o.source:t.topLevelConsts.has(a)?``:null})}return{refs:i,resolved:!0}}function se(e){let t=e.value??e;if(!C(t))return null;if(t.type===`ArrayExpression`)return t;let n=t.body;if(!C(n))return null;if(n.type!==`BlockStatement`)return n;let r=(n.body??[]).filter(e=>e.type===`ReturnStatement`);if(r.length!==1)return null;let i=r[0].argument;return C(i)?i:null}function F(e,t,n){let r=E(O(e,t));return r?N(r,n):null}function ce(e,t){for(let n of e){let e=M(n);if(!e||e.name!==`ApiQueryParams`)continue;let r=e.call.arguments?.[0],i=null;if(C(r)&&r.type===`ObjectExpression`)i=r;else{let e=E(r);if(e){let n=t.get(e);n&&n.type===`ObjectExpression`&&(i=n)}}return{filterable:A(i,`filterable`),sortable:A(i,`sortable`),searchable:A(i,`searchable`)}}return null}function I(e,t,n){let r;try{let n=m(t,e);if(n.errors.length>0)return null;r=n.program}catch{return null}let i=ee(t,n),a=re(r),o=[],s=[],c=[],l=[],u=[],d=[],f=[],p=new Set,h=[],g=[],_=[],v=new Set,y=new Set,b=new Map;w(r,e=>{if(e.type!==`VariableDeclarator`)return;let t=E(e.id),n=e.init;t&&C(n)&&b.set(n,t)});let A=new Set,N=new Map;for(let e of r.body??[]){let t=e.type===`VariableDeclaration`?e:e.type===`ExportNamedDeclaration`&&C(e.declaration)?e.declaration:null;if(C(t)&&t.type===`VariableDeclaration`)for(let e of t.declarations??[]){let t=E(e.id);t&&C(e.init)&&N.set(t,e.init)}}let P=[];for(let e of r.body??[])if(e.type===`ExportNamedDeclaration`&&C(e.declaration)){let t=e.declaration;t.type===`ClassDeclaration`&&P.push({cls:t,isDefault:!1})}else if(e.type===`ExportDefaultDeclaration`&&C(e.declaration)){let t=e.declaration;t.type===`ClassDeclaration`&&P.push({cls:t,isDefault:!0})}for(let{cls:e,isDefault:n}of P){let r=E(e.id);if(!r)continue;let a=null;for(let t of j(e)){let e=M(t);if(e&&x().has(e.name)){a=e.name;break}}a?o.push({className:r,decorator:a,filePath:t,relativePath:i,isDefault:n}):ne(e,`AppModule`)&&o.push({className:r,decorator:`Module`,filePath:t,relativePath:i,isDefault:n})}for(let e of r.body??[]){if(e.type!==`ExportNamedDeclaration`||!C(e.declaration))continue;let n=e.declaration;if(n.type===`VariableDeclaration`)for(let e of n.declarations??[]){let n=E(e.id),r=e.init;n&&C(r)&&r.type===`CallExpression`&&D(r)===`defineModule`&&(o.some(e=>e.className===n)||o.push({className:n,decorator:`Module`,filePath:t,relativePath:i,isDefault:!1}))}}w(r,n=>{if(n.type===`VariableDeclarator`){let e=n.init;if(C(e)&&e.type===`CallExpression`&&D(e)===`createToken`){let r=T(e.arguments?.[0]);r!==null&&(A.add(e),s.push({name:r,variable:E(n.id),filePath:t,relativePath:i}))}return}if(n.type!==`CallExpression`){if(n.type===`Decorator`){let e=M(n);if(e?.name===`Inject`){let n=T(e.call.arguments?.[0]);n!==null&&c.push({name:n,filePath:t,relativePath:i})}}return}let r=n.callee,a=D(n);if(a===`createToken`&&!A.has(n)){let e=T(n.arguments?.[0]);e!==null&&s.push({name:e,variable:null,filePath:t,relativePath:i});return}if(a===`defineAdapter`||a===`definePlugin`){let e=T(O(k(n),`name`));if(e!==null){let n=a===`definePlugin`?`plugin`:`adapter`,r=`${a}::${e}::${t}`;v.has(r)||(v.add(r),l.push({kind:n,name:e,filePath:t,relativePath:i}))}return}if(a===`defineAugmentation`){let e=n.arguments??[],r=T(e[0]);if(r!==null){let n=C(e[1])&&e[1].type===`ObjectExpression`?e[1]:null;u.push({name:r,description:T(O(n,`description`)),example:T(O(n,`example`)),filePath:t,relativePath:i})}return}if(a===`defineRouteFlag`){let r=T(n.arguments?.[0]);if(r!==null&&!p.has(r)){p.add(r);let a=n.typeArguments,o=a?e.slice(a.start,a.end):null;f.push({name:r,valueType:o?o.slice(1,-1).trim():null,filePath:t,relativePath:i})}return}if(a===`defineContextDecorator`||a===`defineHttpContextDecorator`){let e=T(O(k(n),`key`));e!==null&&!y.has(e)&&(y.add(e),d.push({key:e,exportName:b.get(n)??null,filePath:t,relativePath:i}));return}if(C(r)&&r.type===`CallExpression`){let e=r.callee;if(C(e)&&e.type===`MemberExpression`&&E(e.property)===`withParams`){let r=E(e.object);if(r===`defineContextDecorator`||r===`defineHttpContextDecorator`){let e=T(O(k(n),`key`));e!==null&&!y.has(e)&&(y.add(e),d.push({key:e,exportName:b.get(n)??null,filePath:t,relativePath:i}))}}return}if(C(r)&&r.type===`MemberExpression`&&E(r.property)===`glob`){let e=r.object;C(e)&&e.type===`MetaProperty`&&w(n.arguments,e=>{let t=T(e);t!==null&&_.push(t)})}});let se=[];w(r,e=>{if(e.type===`ClassDeclaration`||e.type===`ClassExpression`){let t=E(e.id);t&&se.push({cls:e,className:t})}});for(let{cls:e,className:n}of se){let r=o.find(e=>e.className===n),s=e.body?.body;if(ne(e,`AppAdapter`))for(let e of s??[]){if(e.type!==`PropertyDefinition`||E(e.key)!==`name`)continue;let n=T(e.value);if(n===null)continue;let r=`class::${n}::${t}`;v.has(r)||(v.add(r),l.push({kind:`adapter`,name:n,filePath:t,relativePath:i}));break}for(let o of s??[]){if(o.type!==`MethodDefinition`)continue;let s=E(o.key);if(!s)continue;if(s===`routes`){le(o.value,g);continue}if(!r)continue;let c=j(o),l=ce(c,N),u=[...ie(j(e),a),...ie(c,a)];for(let e of c){let o=M(e);if(!o||!S.has(o.name))continue;let c=o.call.arguments??[],d=T(c[0]),f=d&&d.length>0?d:`/`,p=C(c[1])&&c[1].type===`ObjectExpression`?c[1]:null;h.push({controller:n,method:s,httpMethod:o.name.toUpperCase(),path:f,pathParams:te(f),queryFilterable:l?.filterable??null,querySortable:l?.sortable??null,querySearchable:l?.searchable??null,bodySchema:F(p,`body`,a),querySchema:F(p,`query`,a),paramsSchema:F(p,`params`,a),responseSchema:F(p,`response`,a),filePath:t,relativePath:i,controllerIsDefaultExport:r.isDefault,appliedDecorators:u,mountedPath:f})}}}w(r,e=>{if(e.type!==`Property`||E(e.key)!==`routes`)return;let t=e.value;C(t)&&(t.type===`FunctionExpression`||t.type===`ArrowFunctionExpression`)&&le(t,g)});let I=new Set,L=new Set;w(r,e=>{let t=e.type===`Property`&&E(e.key)===`contributors`,n=e.type===`MethodDefinition`&&E(e.key)===`contributors`;(t||n)&&L.add(e)});let R=e=>e.properties??e.body?.body??[];w(r,e=>{if(e.type!==`ObjectExpression`&&e.type!==`ClassDeclaration`)return;let t=R(e);if(t.map(e=>E(e.key)).includes(`routes`))for(let e of t)E(e.key)===`contributors`&&I.add(e)});let z=new Set;w(r,e=>{let t=e.type===`CallExpression`?D(e):e.type===`NewExpression`?E(e.callee):null;if(t===null||!ae(t,a))return;let n=k(e);if(n)for(let e of n.properties??[])e.type===`Property`&&E(e.key)===`contributors`&&z.add(e)});let B=e=>{if(e.size===0)return null;let n=[],r=!0;for(let t of e){let e=oe(t,a);e.resolved||(r=!1),n.push(...e.refs)}return{refs:n,resolved:r,filePath:t}},V=B(I),H=B(z);return{classes:o,tokens:s,injects:c,pluginsAndAdapters:l,augmentations:u,contextKeys:d,routeFlags:f,routes:h,moduleMounts:g,globPatterns:/\.module\.[mc]?[tj]sx?$/.test(t)?_:[],moduleContributors:V,appContributors:H,hasNonDecoratorContributors:L.size>I.size+z.size}}function le(e,t){let n=[],r=[];w(e.body,e=>{if(e.type!==`Property`)return;let t=E(e.key);if(t===`path`){let t=T(e.value);t!==null&&n.push(t)}else if(t===`controller`){let t=E(e.value);t&&/^[A-Z]/.test(t)&&r.push(t)}});let i=Math.min(n.length,r.length);for(let e=0;e<i;e++)t.push({controller:r[e],mountPath:n[e]})}const L=[`Service`,`Controller`,`Repository`,`Injectable`,`Component`,`Module`],R=[`.ts`,`.tsx`,`.mts`,`.cts`],z=[`node_modules`,`.kickjs`,`dist`,`build`,`.test.`,`.spec.`,`.d.ts`],B=new RegExp(String.raw`@(${L.join(`|`)})\s*\([^)]*\)`+String.raw`(?:\s*@[A-Z]\w*(?:\s*\([^)]*\))?)*`+String.raw`\s*export\s+(default\s+)?(?:abstract\s+)?class\s+(\w+)`,`g`),V=new RegExp(String.raw`export\s+(default\s+)?(?:abstract\s+)?class\s+(\w+)`+String.raw`(?:\s+extends\s+\w+(?:<[^>]*>)?)?`+String.raw`\s+implements\s+[^{]*\bAppModule\b`,`g`),H=/export\s+const\s+(\w+)\s*(?::\s*[^=]+)?=\s*defineModule\s*(?:<[^>]*>)?\s*\(/g,ue=/(?:export\s+)?const\s+(\w+)\s*(?::\s*[^=]+)?=\s*createToken\s*(?:<[^>]*>)?\s*\(\s*['"`]([^'"`]+)['"`]\s*\)/g,de=/createToken\s*(?:<[^>]*>)?\s*\(\s*['"`]([^'"`]+)['"`]\s*\)/g,fe=/@Inject\s*\(\s*['"`]([^'"`]+)['"`]\s*\)/g,U=/\b(defineAdapter|definePlugin)\s*(?:<[^>]*>)?\s*\(/g,W=/(?:(?:export\s+)?(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*(?::[^=]+)?=\s*)?\b(?:defineContextDecorator|defineHttpContextDecorator)\s*(?:\.withParams\s*<(?:[^<>]|<[^<>]*>)*>\s*\(\s*\))?\s*(?:<(?:[^<>]|<[^<>]*>)*>)?\s*\(/g,pe=new RegExp(String.raw`export\s+(?:default\s+)?(?:abstract\s+)?class\s+(\w+)`+String.raw`(?:\s+extends\s+\w+(?:<[^>]*>)?)?`+String.raw`\s+implements\s+[^{]*\bAppAdapter\b`,`g`),me=/\bname\s*(?::\s*[^=]+)?=\s*['"`]([^'"`]+)['"`]/,he=/\bdefineAugmentation\s*\(\s*['"`]([^'"`]+)['"`]\s*(,\s*\{)?/g,G=new RegExp(String.raw`@(${[`Get`,`Post`,`Put`,`Delete`,`Patch`].join(`|`)})\s*\(`,`g`);function K(e,t){let n=1;for(let r=t+1;r<e.length;r++){let t=e[r];if(t===`(`)n++;else if(t===`)`&&(n--,n===0))return r}return-1}function ge(e,t){let n=t;for(;n<e.length;){for(;n<e.length&&/\s/.test(e[n]);)n++;if(e[n]!==`@`)break;let t=e.slice(n).match(/^@([A-Z]\w*)/);if(!t)break;for(n+=t[0].length;n<e.length&&/\s/.test(e[n]);)n++;if(e[n]===`(`){let t=K(e,n);if(t<0)return null;n=t+1}}for(;n<e.length&&/\s/.test(e[n]);)n++;for(let t of[`public`,`private`,`protected`])if(e.slice(n,n+t.length)===t&&/\s/.test(e.charAt(n+t.length))){for(n+=t.length;n<e.length&&/\s/.test(e[n]);)n++;break}if(e.slice(n,n+5)===`async`&&/\s/.test(e.charAt(n+5)))for(n+=5;n<e.length&&/\s/.test(e[n]);)n++;let r=e.slice(n).match(/^([a-zA-Z_]\w*)\s*\(/);return r?{methodName:r[1],endPos:n+r[0].length}:null}function _e(e){return(e.match(/:([a-zA-Z_]\w*)/g)??[]).map(e=>e.slice(1))}function ve(e,t){let n=e.endsWith(`/`)?e.slice(0,-1):e;return!t||t===`/`?n||`/`:n+(t.startsWith(`/`)?t:`/`+t)||`/`}const ye=/\b(?:public\s+|private\s+|protected\s+)?routes\s*\([^)]*\)\s*(?::\s*[A-Za-z_][\w<>[\]\s,|]*\s*)?\{/g,be=/\bpath\s*:\s*['"`]([^'"`]*)['"`]/g,xe=/\bcontroller\s*:\s*([A-Z]\w*)\b/g,Se=/\bimport\.meta\.glob\s*\(/g;function Ce(e){let t=[];for(Se.lastIndex=0;Se.exec(e)!==null;){let n=Se.lastIndex-1,r=K(e,n);if(r<0)continue;let i=e.slice(n+1,r),a=/['"`]([^'"`]+)['"`]/g,o;for(;(o=a.exec(i))!==null;)t.push(o[1])}return t}function we(e){let t=e.replace(/[.+^$()|[\]\\]/g,`\\$&`).replace(/\?/g,`.`).replace(/\*\*\//g,`___DOUBLESTAR_SLASH___`).replace(/\*\*/g,`___DOUBLESTAR___`).replace(/\*/g,`[^/]*`).replace(/___DOUBLESTAR_SLASH___/g,`(?:.+/)?`).replace(/___DOUBLESTAR___/g,`.*`);return RegExp(`^`+t+`$`)}function Te(e,t){let n=e.startsWith(`./`)?e:`./`+e,r=!1;for(let e of t){let t=e.startsWith(`!`);we(t?e.slice(1):e).test(n)&&(r=!t)}return r}function Ee(e){let t=[];ye.lastIndex=0;let n;for(;(n=ye.exec(e))!==null;){let r=e.indexOf(`{`,n.index+n[0].length-1);if(r<0)continue;let i=Ie(e,r);if(i<0)continue;let a=e.slice(r+1,i),o=[];be.lastIndex=0;let s;for(;(s=be.exec(a))!==null;)o.push(s[1]??``);let c=[];xe.lastIndex=0;let l;for(;(l=xe.exec(a))!==null;)c.push(l[1]);let u=Math.min(o.length,c.length);for(let e=0;e<u;e++)t.push({controller:c[e],mountPath:o[e]})}return t}function q(e,t){let n=new RegExp(String.raw`\b${t}\s*:\s*([A-Za-z_$][\w$]*)`,`g`).exec(e);return n?n[1]:null}function J(e,t){let n=new RegExp(String.raw`import\s*(?:type\s+)?\{[^}]*\b${t}\b[^}]*\}\s*from\s*['"\`]([^'"\`]+)['"\`]`).exec(e);if(n)return n[1];let r=new RegExp(String.raw`import\s+(?:type\s+)?${t}\s+from\s*['"\`]([^'"\`]+)['"\`]`).exec(e);if(r)return r[1];let i=new RegExp(String.raw`import\s*\*\s*as\s+${t}\s+from\s*['"\`]([^'"\`]+)['"\`]`).exec(e);return i?i[1]:new RegExp(String.raw`(?:^|\n)\s*(?:export\s+)?const\s+${t}\b`).test(e)?``:null}function De(e,t){let n=/@ApiQueryParams\s*\(\s*([\s\S]*?)\s*\)\s*$/.exec(e);if(!n){let n=/@ApiQueryParams\s*\(([\s\S]*?)\)/.exec(e);return n?Oe(n[1].trim(),t):null}return Oe(n[1].trim(),t)}function Oe(e,t){if(e.startsWith(`{`))return Ae(e);let n=/^([A-Za-z_]\w*)/.exec(e);if(n){let e=n[1],r=new RegExp(String.raw`const\s+${e}\s*(?::\s*[^=]+)?=\s*(\{[\s\S]*?\n\})`,`m`).exec(t);if(r)return Ae(r[1])}return{filterable:[],sortable:[],searchable:[]}}function ke(e,t){let n=new RegExp(String.raw`${t}\s*:\s*\[([\s\S]*?)\]`).exec(e);return n?Array.from(n[1].matchAll(/['"`]([^'"`]+)['"`]/g)).map(e=>e[1]):[]}function Ae(e){return{filterable:ke(e,`filterable`),sortable:ke(e,`sortable`),searchable:ke(e,`searchable`)}}async function je(e,t){let n=t.extensions??R,r=t.exclude??z,o=[],s;try{s=await u(e,{withFileTypes:!0,encoding:`utf-8`})}catch{return o}for(let c of s){let s=i(e,c.name),l=a(t.cwd,s);r.some(e=>l.includes(e))||(c.isDirectory()?o.push(...await je(s,t)):c.isFile()&&n.some(e=>c.name.endsWith(e))&&o.push(s))}return o}function Y(e,t){return a(t,e).split(s).join(`/`)}function Me(e,t,n){let r=[],i=Y(t,n);B.lastIndex=0;let a;for(;(a=B.exec(e))!==null;){let[,e,n,o]=a;r.push({className:o,decorator:e,filePath:t,relativePath:i,isDefault:!!n})}V.lastIndex=0;let o;for(;(o=V.exec(e))!==null;){let[,e,n]=o;r.some(e=>e.className===n&&e.filePath===t)||r.push({className:n,decorator:`Module`,filePath:t,relativePath:i,isDefault:!!e})}H.lastIndex=0;let s;for(;(s=H.exec(e))!==null;){let[,e]=s;r.some(n=>n.className===e&&n.filePath===t)||r.push({className:e,decorator:`Module`,filePath:t,relativePath:i,isDefault:!1})}return r}function Ne(e,t,n){let r=[],i=Y(t,n),a=new Set;ue.lastIndex=0;let o;for(;(o=ue.exec(e))!==null;){let[e,n,s]=o;a.add(e),r.push({name:s,variable:n,filePath:t,relativePath:i})}for(de.lastIndex=0;(o=de.exec(e))!==null;)a.has(o[0])||r.push({name:o[1],variable:null,filePath:t,relativePath:i});return r}function Pe(e,t,n,r,i=new Map){let a=[];if(r.length===0)return a;let o=Y(t,n),s=[];for(let t of r){let n=new RegExp(String.raw`class\s+${t.className}\b`).exec(e);n?.index!==void 0&&s.push({cls:t,start:n.index})}s.sort((e,t)=>e.start-t.start);for(let n=0;n<s.length;n++){let{cls:r,start:c}=s[n],l=n+1<s.length?s[n+1].start:e.length,u=e.slice(c,l);G.lastIndex=0;let d;for(;(d=G.exec(u))!==null;){let n=d[1],s=d.index,c=G.lastIndex-1,l=K(u,c);if(l<0)continue;let f=u.slice(c+1,l),p=f.match(/^\s*['"`]([^'"`]*)['"`]/),m=p&&p[1].length>0?p[1]:`/`,h=ge(u,l+1);if(!h)continue;let{methodName:g,endPos:_}=h;G.lastIndex=_;let v=De(u.slice(s,_),e),y=q(f,`body`),b=q(f,`query`),x=q(f,`params`),S=q(f,`response`),C=i.get(r.className)??``,w=C?ve(C,m):m;a.push({controller:r.className,method:g,httpMethod:n.toUpperCase(),path:m,pathParams:_e(w),queryFilterable:v?.filterable??null,querySortable:v?.sortable??null,querySearchable:v?.searchable??null,bodySchema:y?{identifier:y,source:J(e,y)}:null,querySchema:b?{identifier:b,source:J(e,b)}:null,paramsSchema:x?{identifier:x,source:J(e,x)}:null,responseSchema:S?{identifier:S,source:J(e,S)}:null,filePath:t,relativePath:o,controllerIsDefaultExport:r.isDefault,mountedPath:w})}}return a}function Fe(e,t,n){let r=[],i=Y(t,n);fe.lastIndex=0;let a;for(;(a=fe.exec(e))!==null;)r.push({name:a[1],filePath:t,relativePath:i});return r}function Ie(e,t){let n=1;for(let r=t+1;r<e.length;r++){let t=e[r];if(t===`{`)n++;else if(t===`}`&&(n--,n===0))return r}return-1}function Le(e,t,n){let r=[],i=Y(t,n),a=new Set;U.lastIndex=0;let o;for(;(o=U.exec(e))!==null;){let n=o[1],s=U.lastIndex-1,c=K(e,s);if(c<0)continue;let l=e.slice(s+1,c),u=/\bname\s*:\s*['"`]([^'"`]+)['"`]/.exec(l);if(!u)continue;let d=u[1],f=`${n}::${d}::${t}`;a.has(f)||(a.add(f),r.push({kind:n===`definePlugin`?`plugin`:`adapter`,name:d,filePath:t,relativePath:i}))}pe.lastIndex=0;let s;for(;(s=pe.exec(e))!==null;){let n=s.index,o=e.indexOf(`{`,n);if(o<0)continue;let c=Ie(e,o);if(c<0)continue;let l=e.slice(o+1,c),u=me.exec(l);if(!u)continue;let d=u[1],f=`class::${d}::${t}`;a.has(f)||(a.add(f),r.push({kind:`adapter`,name:d,filePath:t,relativePath:i}))}return r}function Re(e,t,n){let r=[],i=Y(t,n),a=new Set;W.lastIndex=0;let o;for(;(o=W.exec(e))!==null;){let n=W.lastIndex-1,s=K(e,n);if(s<0)continue;let c=e.slice(n+1,s),l=/\bkey\s*:\s*['"`]([^'"`]+)['"`]/.exec(c);if(!l)continue;let u=l[1];a.has(u)||(a.add(u),r.push({key:u,exportName:o[1]??null,filePath:t,relativePath:i}))}return r}function ze(e,t,n){let r=[],i=Y(t,n);he.lastIndex=0;let a;for(;(a=he.exec(e))!==null;){let n=a[1],o=null,s=null;if(a[2]){let t=e.indexOf(`{`,a.index+a[0].length-1);if(t>=0){let n=Ie(e,t);if(n>=0){let r=e.slice(t+1,n);o=Be(r,`description`),s=Be(r,`example`)}}}r.push({name:n,description:o,example:s,filePath:t,relativePath:i})}return r}function Be(e,t){let n=RegExp(`\\b${t}\\s*:\\s*(['"\`])`,`g`).exec(e);if(!n)return null;let r=n[1],i=n.index+n[0].length,a=i,o=null;for(;a<e.length;){let t=e[a];if(t===`\\`){a+=2;continue}if(t===r){o=e.slice(i,a);break}a++}return o===null?null:o.replace(/\\(.)/g,(e,t)=>t===`n`?`
11
+ import{t as e}from"./rolldown-runtime-DtbiLYsN.mjs";import{statSync as t}from"node:fs";import{basename as n,dirname as r,join as i,relative as a,resolve as o,sep as s}from"node:path";import{mkdir as c,readFile as l,readdir as u,stat as d,unlink as f,writeFile as p}from"node:fs/promises";import{parseSync as m}from"oxc-parser";import{globSync as h}from"glob";import{groupAssetKeys as g}from"@forinda/kickjs";const _=[`classes`,`tokens`,`injects`,`pluginsAndAdapters`,`augmentations`,`contextKeys`,`routeFlags`,`routes`,`moduleMounts`,`globPatterns`];function v(e){if(!e||typeof e!=`object`)return!1;let t=e;return _.every(e=>Array.isArray(t[e]))}var y=class e{path;prev;next=new Map;nextSig=new Map;constructor(e,t){this.path=e,this.prev=t}static async load(t){let n=i(t,`scan.json`),r=new Map;try{let e=await l(n,`utf-8`),t=JSON.parse(e);if(t.version===3&&t.files)for(let[e,n]of Object.entries(t.files))n&&typeof n.sig==`string`&&v(n.extract)&&r.set(e,n)}catch{}return new e(n,r)}static async signature(e){try{let t=await d(e);return`${t.mtimeMs}:${t.size}`}catch{return null}}get(e,t){let n=this.prev.get(e);return n&&n.sig===t?n.extract:null}set(e,t,n){this.next.set(e,n),this.nextSig.set(e,t)}cachedFiles(){return[...this.prev.keys()]}peek(e){return this.prev.get(e)?.extract??null}carry(e){let t=this.prev.get(e);return t?(this.next.set(e,t.extract),this.nextSig.set(e,t.sig),!0):!1}async save(){let e={};for(let[t,n]of this.next){let r=this.nextSig.get(t);r&&(e[t]={sig:r,extract:n})}let t={version:3,files:e};try{await c(r(this.path),{recursive:!0}),await p(this.path,JSON.stringify(t),`utf-8`)}catch{}}};let b=null;function x(){return b??=new Set(L),b}const S=new Set([`Get`,`Post`,`Put`,`Delete`,`Patch`]);function C(e){return typeof e==`object`&&!!e&&typeof e.type==`string`}function w(e,t){if(Array.isArray(e)){for(let n of e)w(n,t);return}if(C(e)){t(e);for(let n of Object.keys(e)){if(n===`type`)continue;let r=e[n];typeof r==`object`&&r&&w(r,t)}}}function T(e){if(!C(e))return null;if(e.type===`Literal`&&typeof e.value==`string`)return e.value;if(e.type===`TemplateLiteral`){let t=e.quasis,n=e.expressions;if(t?.length===1&&(n?.length??0)===0){let e=t[0].value?.cooked;return typeof e==`string`?e:null}}return null}function E(e){return C(e)&&e.type===`Identifier`?e.name:null}function D(e){return E(e.callee)}function O(e,t){if(!e||e.type!==`ObjectExpression`)return null;for(let n of e.properties??[]){if(n.type!==`Property`)continue;let e=n.key;if((E(e)??(e.type===`Literal`?String(e.value):T(e)))===t)return n.value}return null}function k(e){let t=e.arguments?.[0];return C(t)&&t.type===`ObjectExpression`?t:null}function A(e,t){let n=O(e,t);if(!C(n)||n.type!==`ArrayExpression`)return[];let r=[];for(let e of n.elements??[]){let t=T(e);t!==null&&r.push(t)}return r}function ee(e,t){return a(t,e).split(s).join(`/`)}function te(e){return(e.match(/:([a-zA-Z_]\w*)/g)??[]).map(e=>e.slice(1))}function ne(e,t){for(let n of e.implements??[]){let e=n.expression??n;if(E(e)===t)return!0;if(e.type===`TSQualifiedName`||e.type===`MemberExpression`){let n=e.right??e.property;if(n&&E(n)===t)return!0}}return!1}function j(e){return e.decorators??[]}function M(e){let t=e.expression;if(!C(t)||t.type!==`CallExpression`)return null;let n=D(t);return n?{name:n,call:t}:null}function re(e){let t=new Map,n=new Set;for(let r of e.body??[]){if(r.type===`ImportDeclaration`){let e=T(r.source)??``;for(let n of r.specifiers??[]){let r=E(n.local);r&&t.set(r,{source:e})}continue}let e=r.type===`VariableDeclaration`?r:r.type===`ExportNamedDeclaration`&&C(r.declaration)?r.declaration:null;if(C(e)&&e.type===`VariableDeclaration`)for(let t of e.declarations??[]){let e=E(t.id);e&&n.add(e)}}return{imports:t,topLevelConsts:n}}function N(e,t){let n=t.imports.get(e);return n?{identifier:e,source:n.source}:t.topLevelConsts.has(e)?{identifier:e,source:``}:{identifier:e,source:null}}function ie(e,t){let n=[];for(let r of e){let e=M(r),i=e?e.name:E(r.expression);if(!i||S.has(i))continue;let a=t.imports.get(i);n.push({identifier:i,source:a?a.source:t.topLevelConsts.has(i)?``:null})}return n}const P=new Set([`bootstrap`,`createWebApp`,`Application`]);function ae(e,t){if(!P.has(e))return!1;let n=t.imports.get(e)?.source;return n===`@forinda/kickjs`||(n?.startsWith(`@forinda/kickjs/`)??!1)}function oe(e,t){let n={refs:[],resolved:!1},r=se(e);if(!r||r.type!==`ArrayExpression`)return n;let i=[];for(let e of r.elements??[]){if(!C(e)||e.type!==`MemberExpression`||E(e.property)!==`registration`)return n;let r=e.object,a=E(r);if(!a&&C(r)&&r.type===`CallExpression`){let e=r.callee;C(e)&&e.type===`MemberExpression`&&E(e.property)===`with`&&(a=E(e.object))}if(!a)return n;let o=t.imports.get(a);i.push({identifier:a,source:o?o.source:t.topLevelConsts.has(a)?``:null})}return{refs:i,resolved:!0}}function se(e){let t=e.value??e;if(!C(t))return null;if(t.type===`ArrayExpression`)return t;let n=t.body;if(!C(n))return null;if(n.type!==`BlockStatement`)return n;let r=(n.body??[]).filter(e=>e.type===`ReturnStatement`);if(r.length!==1)return null;let i=r[0].argument;return C(i)?i:null}function F(e,t,n){let r=E(O(e,t));return r?N(r,n):null}function ce(e,t){for(let n of e){let e=M(n);if(!e||e.name!==`ApiQueryParams`)continue;let r=e.call.arguments?.[0],i=null;if(C(r)&&r.type===`ObjectExpression`)i=r;else{let e=E(r);if(e){let n=t.get(e);n&&n.type===`ObjectExpression`&&(i=n)}}return{filterable:A(i,`filterable`),sortable:A(i,`sortable`),searchable:A(i,`searchable`)}}return null}function I(e,t,n){let r;try{let n=m(t,e);if(n.errors.length>0)return null;r=n.program}catch{return null}let i=ee(t,n),a=re(r),o=[],s=[],c=[],l=[],u=[],d=[],f=[],p=new Set,h=[],g=[],_=[],v=new Set,y=new Set,b=new Map;w(r,e=>{if(e.type!==`VariableDeclarator`)return;let t=E(e.id),n=e.init;t&&C(n)&&b.set(n,t)});let A=new Set,N=new Map;for(let e of r.body??[]){let t=e.type===`VariableDeclaration`?e:e.type===`ExportNamedDeclaration`&&C(e.declaration)?e.declaration:null;if(C(t)&&t.type===`VariableDeclaration`)for(let e of t.declarations??[]){let t=E(e.id);t&&C(e.init)&&N.set(t,e.init)}}let P=[];for(let e of r.body??[])if(e.type===`ExportNamedDeclaration`&&C(e.declaration)){let t=e.declaration;t.type===`ClassDeclaration`&&P.push({cls:t,isDefault:!1})}else if(e.type===`ExportDefaultDeclaration`&&C(e.declaration)){let t=e.declaration;t.type===`ClassDeclaration`&&P.push({cls:t,isDefault:!0})}for(let{cls:e,isDefault:n}of P){let r=E(e.id);if(!r)continue;let a=null;for(let t of j(e)){let e=M(t);if(e&&x().has(e.name)){a=e.name;break}}a?o.push({className:r,decorator:a,filePath:t,relativePath:i,isDefault:n}):ne(e,`AppModule`)&&o.push({className:r,decorator:`Module`,filePath:t,relativePath:i,isDefault:n})}for(let e of r.body??[]){if(e.type!==`ExportNamedDeclaration`||!C(e.declaration))continue;let n=e.declaration;if(n.type===`VariableDeclaration`)for(let e of n.declarations??[]){let n=E(e.id),r=e.init;n&&C(r)&&r.type===`CallExpression`&&D(r)===`defineModule`&&(o.some(e=>e.className===n)||o.push({className:n,decorator:`Module`,filePath:t,relativePath:i,isDefault:!1}))}}w(r,n=>{if(n.type===`VariableDeclarator`){let e=n.init;if(C(e)&&e.type===`CallExpression`&&D(e)===`createToken`){let r=T(e.arguments?.[0]);r!==null&&(A.add(e),s.push({name:r,variable:E(n.id),filePath:t,relativePath:i}))}return}if(n.type!==`CallExpression`){if(n.type===`Decorator`){let e=M(n);if(e?.name===`Inject`){let n=T(e.call.arguments?.[0]);n!==null&&c.push({name:n,filePath:t,relativePath:i})}}return}let r=n.callee,a=D(n);if(a===`createToken`&&!A.has(n)){let e=T(n.arguments?.[0]);e!==null&&s.push({name:e,variable:null,filePath:t,relativePath:i});return}if(a===`defineAdapter`||a===`definePlugin`){let e=T(O(k(n),`name`));if(e!==null){let n=a===`definePlugin`?`plugin`:`adapter`,r=`${a}::${e}::${t}`;v.has(r)||(v.add(r),l.push({kind:n,name:e,filePath:t,relativePath:i}))}return}if(a===`defineAugmentation`){let e=n.arguments??[],r=T(e[0]);if(r!==null){let n=C(e[1])&&e[1].type===`ObjectExpression`?e[1]:null;u.push({name:r,description:T(O(n,`description`)),example:T(O(n,`example`)),filePath:t,relativePath:i})}return}if(a===`defineRouteFlag`){let r=T(n.arguments?.[0]);if(r!==null&&!p.has(r)){p.add(r);let a=n.typeArguments,o=a?e.slice(a.start,a.end):null;f.push({name:r,valueType:o?o.slice(1,-1).trim():null,filePath:t,relativePath:i})}return}if(a===`defineContextDecorator`||a===`defineHttpContextDecorator`){let e=T(O(k(n),`key`));e!==null&&!y.has(e)&&(y.add(e),d.push({key:e,exportName:b.get(n)??null,filePath:t,relativePath:i}));return}if(C(r)&&r.type===`CallExpression`){let e=r.callee;if(C(e)&&e.type===`MemberExpression`&&E(e.property)===`withParams`){let r=E(e.object);if(r===`defineContextDecorator`||r===`defineHttpContextDecorator`){let e=T(O(k(n),`key`));e!==null&&!y.has(e)&&(y.add(e),d.push({key:e,exportName:b.get(n)??null,filePath:t,relativePath:i}))}}return}if(C(r)&&r.type===`MemberExpression`&&E(r.property)===`glob`){let e=r.object;C(e)&&e.type===`MetaProperty`&&w(n.arguments,e=>{let t=T(e);t!==null&&_.push(t)})}});let se=[];w(r,e=>{if(e.type===`ClassDeclaration`||e.type===`ClassExpression`){let t=E(e.id);t&&se.push({cls:e,className:t})}});for(let{cls:e,className:n}of se){let r=o.find(e=>e.className===n),s=e.body?.body;if(ne(e,`AppAdapter`))for(let e of s??[]){if(e.type!==`PropertyDefinition`||E(e.key)!==`name`)continue;let n=T(e.value);if(n===null)continue;let r=`class::${n}::${t}`;v.has(r)||(v.add(r),l.push({kind:`adapter`,name:n,filePath:t,relativePath:i}));break}for(let o of s??[]){if(o.type!==`MethodDefinition`)continue;let s=E(o.key);if(!s)continue;if(s===`routes`){le(o.value,g);continue}if(!r)continue;let c=j(o),l=ce(c,N),u=[...ie(j(e),a),...ie(c,a)];for(let e of c){let o=M(e);if(!o||!S.has(o.name))continue;let c=o.call.arguments??[],d=T(c[0]),f=d&&d.length>0?d:`/`,p=C(c[1])&&c[1].type===`ObjectExpression`?c[1]:null;h.push({controller:n,method:s,httpMethod:o.name.toUpperCase(),path:f,pathParams:te(f),queryFilterable:l?.filterable??null,querySortable:l?.sortable??null,querySearchable:l?.searchable??null,bodySchema:F(p,`body`,a),querySchema:F(p,`query`,a),paramsSchema:F(p,`params`,a),responseSchema:F(p,`response`,a),filePath:t,relativePath:i,controllerIsDefaultExport:r.isDefault,appliedDecorators:u,mountedPath:f})}}}w(r,e=>{if(e.type!==`Property`||E(e.key)!==`routes`)return;let t=e.value;C(t)&&(t.type===`FunctionExpression`||t.type===`ArrowFunctionExpression`)&&le(t,g)});let I=new Set,L=new Set;w(r,e=>{let t=e.type===`Property`&&E(e.key)===`contributors`,n=e.type===`MethodDefinition`&&E(e.key)===`contributors`;(t||n)&&L.add(e)});let R=e=>e.properties??e.body?.body??[];w(r,e=>{if(e.type!==`ObjectExpression`&&e.type!==`ClassDeclaration`)return;let t=R(e);if(t.map(e=>E(e.key)).includes(`routes`))for(let e of t)E(e.key)===`contributors`&&I.add(e)});let z=new Set;w(r,e=>{let t=e.type===`CallExpression`?D(e):e.type===`NewExpression`?E(e.callee):null;if(t===null||!ae(t,a))return;let n=k(e);if(n)for(let e of n.properties??[])e.type===`Property`&&E(e.key)===`contributors`&&z.add(e)});let B=e=>{if(e.size===0)return null;let n=[],r=!0;for(let t of e){let e=oe(t,a);e.resolved||(r=!1),n.push(...e.refs)}return{refs:n,resolved:r,filePath:t}},V=B(I),H=B(z);return{classes:o,tokens:s,injects:c,pluginsAndAdapters:l,augmentations:u,contextKeys:d,routeFlags:f,routes:h,moduleMounts:g,globPatterns:/\.module\.[mc]?[tj]sx?$/.test(t)?_:[],moduleContributors:V,appContributors:H,hasNonDecoratorContributors:L.size>I.size+z.size}}function le(e,t){let n=[],r=[];w(e.body,e=>{if(e.type!==`Property`)return;let t=E(e.key);if(t===`path`){let t=T(e.value);t!==null&&n.push(t)}else if(t===`controller`){let t=E(e.value);t&&/^[A-Z]/.test(t)&&r.push(t)}});let i=Math.min(n.length,r.length);for(let e=0;e<i;e++)t.push({controller:r[e],mountPath:n[e]})}const L=[`Service`,`Controller`,`Repository`,`Injectable`,`Component`,`Module`],R=[`.ts`,`.tsx`,`.mts`,`.cts`],z=[`node_modules`,`.kickjs`,`dist`,`build`,`.test.`,`.spec.`,`.d.ts`],B=new RegExp(String.raw`@(${L.join(`|`)})\s*\([^)]*\)`+String.raw`(?:\s*@[A-Z]\w*(?:\s*\([^)]*\))?)*`+String.raw`\s*export\s+(default\s+)?(?:abstract\s+)?class\s+(\w+)`,`g`),V=new RegExp(String.raw`export\s+(default\s+)?(?:abstract\s+)?class\s+(\w+)`+String.raw`(?:\s+extends\s+\w+(?:<[^>]*>)?)?`+String.raw`\s+implements\s+[^{]*\bAppModule\b`,`g`),H=/export\s+const\s+(\w+)\s*(?::\s*[^=]+)?=\s*defineModule\s*(?:<[^>]*>)?\s*\(/g,ue=/(?:export\s+)?const\s+(\w+)\s*(?::\s*[^=]+)?=\s*createToken\s*(?:<[^>]*>)?\s*\(\s*['"`]([^'"`]+)['"`]\s*\)/g,de=/createToken\s*(?:<[^>]*>)?\s*\(\s*['"`]([^'"`]+)['"`]\s*\)/g,fe=/@Inject\s*\(\s*['"`]([^'"`]+)['"`]\s*\)/g,U=/\b(defineAdapter|definePlugin)\s*(?:<[^>]*>)?\s*\(/g,W=/(?:(?:export\s+)?(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*(?::[^=]+)?=\s*)?\b(?:defineContextDecorator|defineHttpContextDecorator)\s*(?:\.withParams\s*<(?:[^<>]|<[^<>]*>)*>\s*\(\s*\))?\s*(?:<(?:[^<>]|<[^<>]*>)*>)?\s*\(/g,pe=new RegExp(String.raw`export\s+(?:default\s+)?(?:abstract\s+)?class\s+(\w+)`+String.raw`(?:\s+extends\s+\w+(?:<[^>]*>)?)?`+String.raw`\s+implements\s+[^{]*\bAppAdapter\b`,`g`),me=/\bname\s*(?::\s*[^=]+)?=\s*['"`]([^'"`]+)['"`]/,he=/\bdefineAugmentation\s*\(\s*['"`]([^'"`]+)['"`]\s*(,\s*\{)?/g,G=new RegExp(String.raw`@(${[`Get`,`Post`,`Put`,`Delete`,`Patch`].join(`|`)})\s*\(`,`g`);function K(e,t){let n=1;for(let r=t+1;r<e.length;r++){let t=e[r];if(t===`(`)n++;else if(t===`)`&&(n--,n===0))return r}return-1}function ge(e,t){let n=t;for(;n<e.length;){for(;n<e.length&&/\s/.test(e[n]);)n++;if(e[n]!==`@`)break;let t=e.slice(n).match(/^@([A-Z]\w*)/);if(!t)break;for(n+=t[0].length;n<e.length&&/\s/.test(e[n]);)n++;if(e[n]===`(`){let t=K(e,n);if(t<0)return null;n=t+1}}for(;n<e.length&&/\s/.test(e[n]);)n++;for(let t of[`public`,`private`,`protected`])if(e.slice(n,n+t.length)===t&&/\s/.test(e.charAt(n+t.length))){for(n+=t.length;n<e.length&&/\s/.test(e[n]);)n++;break}if(e.slice(n,n+5)===`async`&&/\s/.test(e.charAt(n+5)))for(n+=5;n<e.length&&/\s/.test(e[n]);)n++;let r=e.slice(n).match(/^([a-zA-Z_]\w*)\s*\(/);return r?{methodName:r[1],endPos:n+r[0].length}:null}function _e(e){return(e.match(/:([a-zA-Z_]\w*)/g)??[]).map(e=>e.slice(1))}function ve(e,t){let n=e.endsWith(`/`)?e.slice(0,-1):e;return!t||t===`/`?n||`/`:n+(t.startsWith(`/`)?t:`/`+t)||`/`}const ye=/\b(?:public\s+|private\s+|protected\s+)?routes\s*\([^)]*\)\s*(?::\s*[A-Za-z_][\w<>[\]\s,|]*\s*)?\{/g,be=/\bpath\s*:\s*['"`]([^'"`]*)['"`]/g,xe=/\bcontroller\s*:\s*([A-Z]\w*)\b/g,Se=/\bimport\.meta\.glob\s*\(/g;function Ce(e){let t=[];for(Se.lastIndex=0;Se.exec(e)!==null;){let n=Se.lastIndex-1,r=K(e,n);if(r<0)continue;let i=e.slice(n+1,r),a=/['"`]([^'"`]+)['"`]/g,o;for(;(o=a.exec(i))!==null;)t.push(o[1])}return t}function we(e){let t=e.replace(/[.+^$()|[\]\\]/g,`\\$&`).replace(/\?/g,`.`).replace(/\*\*\//g,`___DOUBLESTAR_SLASH___`).replace(/\*\*/g,`___DOUBLESTAR___`).replace(/\*/g,`[^/]*`).replace(/___DOUBLESTAR_SLASH___/g,`(?:.+/)?`).replace(/___DOUBLESTAR___/g,`.*`);return RegExp(`^`+t+`$`)}function Te(e,t){let n=e.startsWith(`./`)?e:`./`+e,r=!1;for(let e of t){let t=e.startsWith(`!`);we(t?e.slice(1):e).test(n)&&(r=!t)}return r}function Ee(e){let t=[];ye.lastIndex=0;let n;for(;(n=ye.exec(e))!==null;){let r=e.indexOf(`{`,n.index+n[0].length-1);if(r<0)continue;let i=Ie(e,r);if(i<0)continue;let a=e.slice(r+1,i),o=[];be.lastIndex=0;let s;for(;(s=be.exec(a))!==null;)o.push(s[1]??``);let c=[];xe.lastIndex=0;let l;for(;(l=xe.exec(a))!==null;)c.push(l[1]);let u=Math.min(o.length,c.length);for(let e=0;e<u;e++)t.push({controller:c[e],mountPath:o[e]})}return t}function q(e,t){let n=new RegExp(String.raw`\b${t}\s*:\s*([A-Za-z_$][\w$]*)`,`g`).exec(e);return n?n[1]:null}function J(e,t){let n=new RegExp(String.raw`import\s*(?:type\s+)?\{[^}]*\b${t}\b[^}]*\}\s*from\s*['"\`]([^'"\`]+)['"\`]`).exec(e);if(n)return n[1];let r=new RegExp(String.raw`import\s+(?:type\s+)?${t}\s+from\s*['"\`]([^'"\`]+)['"\`]`).exec(e);if(r)return r[1];let i=new RegExp(String.raw`import\s*\*\s*as\s+${t}\s+from\s*['"\`]([^'"\`]+)['"\`]`).exec(e);return i?i[1]:new RegExp(String.raw`(?:^|\n)\s*(?:export\s+)?const\s+${t}\b`).test(e)?``:null}function De(e,t){let n=/@ApiQueryParams\s*\(\s*([\s\S]*?)\s*\)\s*$/.exec(e);if(!n){let n=/@ApiQueryParams\s*\(([\s\S]*?)\)/.exec(e);return n?Oe(n[1].trim(),t):null}return Oe(n[1].trim(),t)}function Oe(e,t){if(e.startsWith(`{`))return Ae(e);let n=/^([A-Za-z_]\w*)/.exec(e);if(n){let e=n[1],r=new RegExp(String.raw`const\s+${e}\s*(?::\s*[^=]+)?=\s*(\{[\s\S]*?\n\})`,`m`).exec(t);if(r)return Ae(r[1])}return{filterable:[],sortable:[],searchable:[]}}function ke(e,t){let n=new RegExp(String.raw`${t}\s*:\s*\[([\s\S]*?)\]`).exec(e);return n?Array.from(n[1].matchAll(/['"`]([^'"`]+)['"`]/g)).map(e=>e[1]):[]}function Ae(e){return{filterable:ke(e,`filterable`),sortable:ke(e,`sortable`),searchable:ke(e,`searchable`)}}async function je(e,t){let n=t.extensions??R,r=t.exclude??z,o=[],s;try{s=await u(e,{withFileTypes:!0,encoding:`utf-8`})}catch{return o}for(let c of s){let s=i(e,c.name),l=a(t.cwd,s);r.some(e=>l.includes(e))||(c.isDirectory()?o.push(...await je(s,t)):c.isFile()&&n.some(e=>c.name.endsWith(e))&&o.push(s))}return o}function Y(e,t){return a(t,e).split(s).join(`/`)}function Me(e,t,n){let r=[],i=Y(t,n);B.lastIndex=0;let a;for(;(a=B.exec(e))!==null;){let[,e,n,o]=a;r.push({className:o,decorator:e,filePath:t,relativePath:i,isDefault:!!n})}V.lastIndex=0;let o;for(;(o=V.exec(e))!==null;){let[,e,n]=o;r.some(e=>e.className===n&&e.filePath===t)||r.push({className:n,decorator:`Module`,filePath:t,relativePath:i,isDefault:!!e})}H.lastIndex=0;let s;for(;(s=H.exec(e))!==null;){let[,e]=s;r.some(n=>n.className===e&&n.filePath===t)||r.push({className:e,decorator:`Module`,filePath:t,relativePath:i,isDefault:!1})}return r}function Ne(e,t,n){let r=[],i=Y(t,n),a=new Set;ue.lastIndex=0;let o;for(;(o=ue.exec(e))!==null;){let[e,n,s]=o;a.add(e),r.push({name:s,variable:n,filePath:t,relativePath:i})}for(de.lastIndex=0;(o=de.exec(e))!==null;)a.has(o[0])||r.push({name:o[1],variable:null,filePath:t,relativePath:i});return r}function Pe(e,t,n,r,i=new Map){let a=[];if(r.length===0)return a;let o=Y(t,n),s=[];for(let t of r){let n=new RegExp(String.raw`class\s+${t.className}\b`).exec(e);n?.index!==void 0&&s.push({cls:t,start:n.index})}s.sort((e,t)=>e.start-t.start);for(let n=0;n<s.length;n++){let{cls:r,start:c}=s[n],l=n+1<s.length?s[n+1].start:e.length,u=e.slice(c,l);G.lastIndex=0;let d;for(;(d=G.exec(u))!==null;){let n=d[1],s=d.index,c=G.lastIndex-1,l=K(u,c);if(l<0)continue;let f=u.slice(c+1,l),p=f.match(/^\s*['"`]([^'"`]*)['"`]/),m=p&&p[1].length>0?p[1]:`/`,h=ge(u,l+1);if(!h)continue;let{methodName:g,endPos:_}=h;G.lastIndex=_;let v=De(u.slice(s,_),e),y=q(f,`body`),b=q(f,`query`),x=q(f,`params`),S=q(f,`response`),C=i.get(r.className)??``,w=C?ve(C,m):m;a.push({controller:r.className,method:g,httpMethod:n.toUpperCase(),path:m,pathParams:_e(w),queryFilterable:v?.filterable??null,querySortable:v?.sortable??null,querySearchable:v?.searchable??null,bodySchema:y?{identifier:y,source:J(e,y)}:null,querySchema:b?{identifier:b,source:J(e,b)}:null,paramsSchema:x?{identifier:x,source:J(e,x)}:null,responseSchema:S?{identifier:S,source:J(e,S)}:null,filePath:t,relativePath:o,controllerIsDefaultExport:r.isDefault,mountedPath:w})}}return a}function Fe(e,t,n){let r=[],i=Y(t,n);fe.lastIndex=0;let a;for(;(a=fe.exec(e))!==null;)r.push({name:a[1],filePath:t,relativePath:i});return r}function Ie(e,t){let n=1;for(let r=t+1;r<e.length;r++){let t=e[r];if(t===`{`)n++;else if(t===`}`&&(n--,n===0))return r}return-1}function Le(e,t,n){let r=[],i=Y(t,n),a=new Set;U.lastIndex=0;let o;for(;(o=U.exec(e))!==null;){let n=o[1],s=U.lastIndex-1,c=K(e,s);if(c<0)continue;let l=e.slice(s+1,c),u=/\bname\s*:\s*['"`]([^'"`]+)['"`]/.exec(l);if(!u)continue;let d=u[1],f=`${n}::${d}::${t}`;a.has(f)||(a.add(f),r.push({kind:n===`definePlugin`?`plugin`:`adapter`,name:d,filePath:t,relativePath:i}))}pe.lastIndex=0;let s;for(;(s=pe.exec(e))!==null;){let n=s.index,o=e.indexOf(`{`,n);if(o<0)continue;let c=Ie(e,o);if(c<0)continue;let l=e.slice(o+1,c),u=me.exec(l);if(!u)continue;let d=u[1],f=`class::${d}::${t}`;a.has(f)||(a.add(f),r.push({kind:`adapter`,name:d,filePath:t,relativePath:i}))}return r}function Re(e,t,n){let r=[],i=Y(t,n),a=new Set;W.lastIndex=0;let o;for(;(o=W.exec(e))!==null;){let n=W.lastIndex-1,s=K(e,n);if(s<0)continue;let c=e.slice(n+1,s),l=/\bkey\s*:\s*['"`]([^'"`]+)['"`]/.exec(c);if(!l)continue;let u=l[1];a.has(u)||(a.add(u),r.push({key:u,exportName:o[1]??null,filePath:t,relativePath:i}))}return r}function ze(e,t,n){let r=[],i=Y(t,n);he.lastIndex=0;let a;for(;(a=he.exec(e))!==null;){let n=a[1],o=null,s=null;if(a[2]){let t=e.indexOf(`{`,a.index+a[0].length-1);if(t>=0){let n=Ie(e,t);if(n>=0){let r=e.slice(t+1,n);o=Be(r,`description`),s=Be(r,`example`)}}}r.push({name:n,description:o,example:s,filePath:t,relativePath:i})}return r}function Be(e,t){let n=RegExp(`\\b${t}\\s*:\\s*(['"\`])`,`g`).exec(e);if(!n)return null;let r=n[1],i=n.index+n[0].length,a=i,o=null;for(;a<e.length;){let t=e[a];if(t===`\\`){a+=2;continue}if(t===r){o=e.slice(i,a);break}a++}return o===null?null:o.replace(/\\(.)/g,(e,t)=>t===`n`?`
12
12
  `:t===`t`?` `:t===`r`?`\r`:t)}const Ve=[`src/config/index.ts`,`src/config/env.ts`,`src/config.ts`,`src/env.ts`];async function He(e,t){let n=t===`src/env.ts`?Ve:[t];for(let t of n){let n=o(e,t),r;try{r=await l(n,`utf-8`)}catch{continue}if((/\bdefineEnv\s*\(/.test(r)||/\bfrom(Zod|Valibot|Yup)\s*\(/.test(r))&&/export\s+default\b/.test(r)&&!/export\s+default\s+loadEnvFromSchema\s*\(/.test(r))return{filePath:n,relativePath:Y(n,e)}}return null}function Ue(e){let t=new Map;for(let n of e){let e=t.get(n.className)??[];e.push(n),t.set(n.className,e)}let n=[];for(let[e,r]of t)new Set(r.map(e=>e.filePath)).size>1&&n.push({className:e,classes:r});return n.sort((e,t)=>e.className.localeCompare(t.className)),n}const We=new Set([`Controller`,`Service`,`Repository`,`Injectable`,`Component`,`Module`,`Middleware`,`ApiQueryParams`,`Public`,`Roles`,`Cron`,`Cacheable`,`CacheEvict`,`FileUpload`,`Asset`,`Builder`,`PostConstruct`,`PreDestroy`,`Value`,`Inject`,`Autowired`]);function X(e){return e.split(s).join(`/`).replace(/\.[mc]?[tj]sx?$/,``)}function Ge(e,t,n){let i=X(n);if(t===``)return i===X(e);if(t.startsWith(`.`)){let n=X(o(r(e),t));return i===n||i===`${n}/index`}let a=t.replace(/^[@~#]\//,``);if(a===t&&t.startsWith(`@`))return!1;let s=X(a);return i===s||i.endsWith(`/${s}`)}function Ke(e){let t=new Map,n=new Map;for(let t of e)if(t)for(let{controller:e}of t.moduleMounts)n.set(e,(n.get(e)??0)+1);for(let r of e)if(r?.moduleContributors)for(let{controller:e}of r.moduleMounts){if((n.get(e)??0)>1){t.set(e,`ambiguous`);continue}let i=t.get(e);t.set(e,i===void 0?r.moduleContributors:`ambiguous`)}return t}function qe(e,t,n,r=new Map,i=[]){if(n){for(let t of e)t.contextKeys=null;return}let a=new Map;for(let e of t){if(!e.exportName)continue;let t=a.get(e.exportName);t?t.push(e):a.set(e.exportName,[e])}for(let t of e){let e=t.appliedDecorators;if(!e){t.contextKeys=null;continue}let n=new Set,o=!0,s=(e,t)=>{if(t.source===null)return null;let n=(a.get(t.identifier)??[]).filter(n=>Ge(e,t.source,n.filePath));return n.length===1?n[0].key:null};for(let r of e){if(We.has(r.identifier))continue;let e=s(t.filePath,r);if(e===null){o=!1;break}n.add(e)}if(o)for(let e of i){if(!e.resolved){o=!1;break}for(let t of e.refs){let r=s(e.filePath,t);if(r===null){o=!1;break}n.add(r)}if(!o)break}if(o){let e=r.get(t.controller);if(e===`ambiguous`)o=!1;else if(e){if(!e.resolved)o=!1;else for(let t of e.refs){let r=s(e.filePath,t);if(r===null){o=!1;break}n.add(r)}}}t.contextKeys=o?[...n].toSorted():null}}const Je=/\bcontributors\s*(?::|\()/;function Ye(e,t,n){return I(e,t,n)||{...Xe(e,t,n),hasNonDecoratorContributors:Je.test(e)}}function Xe(e,t,n){let r=Me(e,t,n);return{classes:r,tokens:Ne(e,t,n),injects:Fe(e,t,n),pluginsAndAdapters:Le(e,t,n),routeFlags:[],augmentations:ze(e,t,n),contextKeys:Re(e,t,n),routes:Pe(e,t,n,r,new Map),moduleMounts:Ee(e),globPatterns:/\.module\.[mc]?[tj]sx?$/.test(t)?Ce(e):[],hasNonDecoratorContributors:!1}}async function Ze(e,t,n){let r=n?await y.signature(e):null;if(n&&r){let t=n.get(e,r);if(t)return n.set(e,r,t),t}let i;try{i=await l(e,`utf-8`)}catch{return null}let a=Ye(i,e,t);return n&&r&&n.set(e,r,a),a}async function Qe(e,t,n){let r=[],i=0,a=Array.from({length:Math.min(t,e.length)},async()=>{for(;;){let t=i++;if(t>=e.length)return;r[t]=await n(e[t],t)}});return await Promise.all(a),r}async function Z(e){let t=(await je(o(e.root),e)).toSorted(),n=e.cacheDir?await y.load(e.cacheDir):null,r=tt(t,await Qe(t,16,t=>Ze(t,e.cwd,n))),i=await He(e.cwd,e.envFile??`src/env.ts`);return n&&await n.save(),{...r,env:i}}function $e(e,t,n){let r=n.extensions??R,i=n.exclude??z;if(!e.startsWith(t+s)&&e!==t||!r.some(t=>e.endsWith(t)))return!1;let o=a(n.cwd,e);return!i.some(e=>o.includes(e))}async function et(e,t){if(!e.cacheDir)return Z(e);let n=o(e.root),r=await y.load(e.cacheDir),i=r.cachedFiles();if(i.length===0)return Z(e);let a=new Set(t.removed.map(t=>o(e.cwd,t))),s=t.changed.map(t=>o(e.cwd,t)).filter(t=>!a.has(t)&&$e(t,n,e)),c=new Set(s),u=new Set(i);for(let e of c)u.add(e);for(let e of a)u.delete(e);let d=new Map;await Qe(s,16,async t=>{if(!u.has(t))return;let n=await y.signature(t),i;try{i=await l(t,`utf-8`)}catch{u.delete(t);return}let a=Ye(i,t,e.cwd);d.set(t,a),n&&r.set(t,n,a)});let f=[...u].toSorted(),p=tt(f,f.map(e=>d.get(e)||(r.carry(e),r.peek(e)))),m=await He(e.cwd,e.envFile??`src/env.ts`);return await r.save(),{...p,env:m}}function tt(e,t){let n=[],r=[],i=[],a=[],o=[],c=[],l=[],u=[],d=new Map;for(let e of t)if(e)for(let{controller:t,mountPath:n}of e.moduleMounts)d.has(t)||d.set(t,n);let f=new Map;for(let s=0;s<e.length;s++){let p=t[s];if(p){n.push(...p.classes),i.push(...p.tokens),a.push(...p.injects),o.push(...p.pluginsAndAdapters),c.push(...p.augmentations),l.push(...p.contextKeys),u.push(...p.routeFlags),p.globPatterns.length>0&&f.set(e[s],p.globPatterns);for(let e of p.routes){let t=d.get(e.controller);if(t){let n=ve(t,e.path);r.push({...e,pathParams:_e(n),mountedPath:n})}else r.push({...e,mountedPath:e.mountedPath??e.path})}}}qe(r,l,t.some(e=>e?.hasNonDecoratorContributors===!0),Ke(t),t.flatMap(e=>e?.appContributors?[e.appContributors]:[]));let p=[];for(let[e,t]of f){if(!/\.module\.[mc]?[tj]sx?$/.test(e)||t.length===0)continue;let r=e.replaceAll(s,`/`),i=r.slice(0,r.lastIndexOf(`/`));for(let a of n){if(a.decorator===`Module`)continue;let n=a.filePath.replaceAll(s,`/`);n.startsWith(i+`/`)&&n!==r&&(Te(n.slice(i.length+1),t)||p.push({className:a.className,filePath:a.filePath,relativePath:a.relativePath,moduleFilePath:e,decorator:a.decorator}))}}n.sort((e,t)=>e.className===t.className?e.relativePath.localeCompare(t.relativePath):e.className.localeCompare(t.className)),i.sort((e,t)=>e.name.localeCompare(t.name)||e.relativePath.localeCompare(t.relativePath)),a.sort((e,t)=>e.name.localeCompare(t.name)||e.relativePath.localeCompare(t.relativePath)),r.sort((e,t)=>e.controller.localeCompare(t.controller)||e.method.localeCompare(t.method)),o.sort((e,t)=>e.name.localeCompare(t.name)||e.relativePath.localeCompare(t.relativePath)),c.sort((e,t)=>e.name.localeCompare(t.name)||e.relativePath.localeCompare(t.relativePath)),l.sort((e,t)=>e.key.localeCompare(t.key)||e.relativePath.localeCompare(t.relativePath));let m=Ue(n);return p.sort((e,t)=>e.relativePath.localeCompare(t.relativePath)||e.className.localeCompare(t.className)),{classes:n,routes:r,tokens:i,injects:a,collisions:m,pluginsAndAdapters:o,augmentations:c,contextKeys:l,routeFlags:u,orphanedClasses:p}}function nt(e){let t=e.lastIndexOf(`.`);return t<=0?{stem:e,ext:``}:{stem:e.slice(0,t),ext:e.slice(t+1)}}function rt(e){let t=e.replaceAll(`\\`,`/`),{stem:n,ext:r}=nt(t.slice(t.lastIndexOf(`/`)+1)),i=r||`ts`,a=n.lastIndexOf(`.`);return a>0?`./**/*.${n.slice(a+1)}.${i}`:`./**/*.${i}`}function it(e){let t=new Set;for(let n of e)t.add(rt(n.relativePath));return[...t].toSorted()}function at(e,t){let n=0,r=null;for(let i=t;i<e.length;i++){let t=e[i];if(r){if(t===`\\`){i++;continue}t===r&&(r=null);continue}if(t===`'`||t===`"`||t==="`")r=t;else if(t===`(`)n++;else if(t===`)`&&(n--,n===0))return i}return-1}function ot(e,t,n,r){let i=null;for(let a=n;a<r;a++){let n=e[a];if(i){if(n===`\\`){a++;continue}n===i&&(i=null);continue}if(n===`'`||n===`"`||n==="`")i=n;else if(n===t)return a}return-1}function st(e,t){let n=0,r=null;for(let i=t;i<e.length;i++){let t=e[i];if(r){if(t===`\\`){i++;continue}t===r&&(r=null);continue}if(t===`'`||t===`"`||t==="`")r=t;else if(t===`[`)n++;else if(t===`]`&&(n--,n===0))return i}return-1}function ct(e){let t=/\bimport\.meta\.glob\s*\(/g,n=[],r;for(;(r=t.exec(e))!==null;){let t=e.indexOf(`(`,r.index);if(t<0)continue;let i=at(e,t);i<0||n.push({start:r.index,open:t,close:i})}return n}function lt(e,t){let n=ct(e);if(n.length===0)return null;let r=n.find(t=>/\beager\s*:\s*true\b/.test(e.slice(t.open,t.close+1)))??n[0],i=e.slice(r.start,r.close+1),a=new Set(Ce(i).map(e=>e.startsWith(`!`)?e.slice(1):e)),o=t.filter(e=>!a.has(e));if(o.length===0)return null;let s=o.map(e=>`'${e}'`).join(`, `),c=ot(e,`[`,r.open,r.close);if(c>=0){let t=st(e,c);if(t<0||t>r.close)return null;let n=e.slice(0,t);return n+(/[[,]\s*$/.test(n)?``:`, `)+s+e.slice(t)}let l=/(['"`])((?:\\.|(?!\1).)*)\1/,u=e.slice(r.open+1,r.close),d=l.exec(u);if(!d)return null;let f=r.open+1+d.index,p=f+d[0].length;return e.slice(0,f)+`[${d[0]}, ${s}]`+e.slice(p)}const Q="/* 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",ut=new Set([`Service`,`Repository`,`Injectable`,`Component`]);var dt=class extends Error{collisions;constructor(e){super(ft(e)),this.name=`TokenCollisionError`,this.collisions=e}};function ft(e){let t=[`kick typegen: token collision detected`];for(let n of e){t.push(``),t.push(` ${n.classes.length} classes named '${n.className}':`);for(let e of n.classes)t.push(` - ${e.relativePath}`)}return t.push(``),t.push(`Resolutions:`),t.push(` (a) Rename one of the classes`),t.push(` (b) Use createToken<T>('namespaced/Name') and import the token explicitly — see @forinda/kickjs`),t.push(` (c) Pass --allow-duplicates to namespace the registry keys automatically`),t.push(` (e.g. 'modules/users/UserService' instead of 'UserService')`),t.join(`
13
13
  `)}function pt(e,t){let n=r(t),i=a(n,e).split(s).join(`/`);return i=i.replace(/\.(ts|tsx|mts|cts)$/i,``),i.startsWith(`.`)||(i=`./`+i),i}function mt(e){let t=e.relativePath.replace(/^src\//,``).replace(/\.(ts|tsx|mts|cts)$/i,``).split(`/`);t.pop();let n=t.join(`/`);return n?`${n}/${e.className}`:e.className}function ht(e,t,n){let r=new Set,i=[];for(let a of e){if(!ut.has(a.decorator))continue;let e=n.has(a.className)?mt(a):a.className;if(r.has(e))continue;r.add(e);let o=pt(a.filePath,t),s=a.isDefault?`import('${o}').default`:`import('${o}').${a.className}`;i.push(` '${e}': ${s}`)}let a=i.length?i.join(`
14
14
  `):" // (no services discovered yet — run `kick g service <name>` to add one)";return`${Q}
@@ -124,8 +124,8 @@ ${Nt(n,` `)}
124
124
 
125
125
  export {}
126
126
  `}const Mt=Symbol(`asset-leaf`);function Nt(e,t){let n=Object.keys(e).toSorted(),r=[];for(let i of n){let n=e[i],a=Pt(i)?i:JSON.stringify(i);n===Mt?r.push(`${t}${a}: () => string`):(r.push(`${t}${a}: {`),r.push(Nt(n,`${t} `)),r.push(`${t}}`))}return r.join(`
127
- `)}function Pt(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)}function Ft(e){try{return t(e).isDirectory()}catch{return!1}}var It=e({runTypegen:()=>Rt,sweepStaleTypegen:()=>Ht,watchTypegen:()=>Vt,writeTypegenArtifacts:()=>$});function Lt(e){let t=e.cwd??process.cwd();return{cwd:t,srcDir:o(t,e.srcDir??`src`),outDir:o(t,e.outDir??`.kickjs/types`),silent:e.silent??!1,allowDuplicates:e.allowDuplicates??!1,schemaValidator:e.schemaValidator??!1,envFile:e.envFile??`src/env.ts`}}async function Rt(e={}){let{cwd:t,srcDir:n,outDir:r,silent:i,allowDuplicates:a,envFile:s}=Lt(e),c=Date.now(),l={root:n,cwd:t,cacheDir:e.noCache?void 0:o(t,`.kickjs`,`cache`),envFile:s===!1?void 0:s},u=e.changedFiles?await et(l,e.changedFiles):await Z(l);if(u.collisions.length>0&&!a)throw new dt(u.collisions);let d=At(e.assetMap,t),f=[],p=[];if(e.runPlugins!==!1){try{let{runAllPluginTypegens:n}=await import(`./builtins-B-PqsutG.mjs`).then(e=>e.n),{loadKickConfig:r}=await import(`./config-CKj2JDsP.mjs`).then(e=>e.n);f=await n({cwd:t,config:await r(t),silent:!0,changedFiles:e.changedFiles})}catch(e){if(!i){let t=e instanceof Error?e.message:String(e);console.warn(` kick typegen: plugin pipeline failed (${t}) — continuing`)}}p.push(...await $(r,f,i))}let m=Ot(u.tokens),h=Bt(u,d.count,p),g=Date.now()-c;if(!i){let e=r.replace(t+`/`,``),n=h.resolvedCollisions>0?`, ${h.resolvedCollisions} collisions namespaced`:``,i=h.envWritten?`, env typed`:``,a=h.pluginEntries>0?`, ${h.pluginEntries} plugins/adapters`:``,o=h.augmentationEntries>0?`, ${h.augmentationEntries} augmentations`:``,s=h.assetEntries>0?`, ${h.assetEntries} assets`:``;if(console.log(` kick typegen → ${h.serviceTokens} services, ${h.routeEntries} routes, ${h.moduleTokens} modules${a}${o}${s}${i}${n} → ${e} (${g}ms)`),m.length>0){console.warn(` kick typegen: ${m.length} token(s) don't match the §22.2 convention:`);for(let e of m){let t=e.variable?` [${e.variable}]`:``;console.warn(` '${e.token}' (${e.filePath})${t} — ${e.reason}`),e.suggestion&&console.warn(` → suggestion: ${e.suggestion}`)}}}return u.orphanedClasses.length>0&&await zt(u.orphanedClasses,{fix:e.fix??!1,silent:i}),{scan:u,result:h,tokenWarnings:m}}async function zt(e,{fix:t,silent:n}){let r=new Map;for(let t of e){let e=r.get(t.moduleFilePath)??[];e.push(t),r.set(t.moduleFilePath,e)}if(t){let e=0,t=[];for(let[i,a]of r){let r=it(a);try{let a=await l(i,`utf-8`),o=lt(a,r);o&&o!==a?(await p(i,o),e++,n||console.log(` kick typegen --fix: patched ${i}\n + ${r.join(`, `)}`)):t.push(i)}catch{t.push(i)}}if(!n&&(e>0&&console.log(` kick typegen --fix: updated ${e} module glob(s) — re-run typegen to pick up the now-loaded classes.`),t.length>0)){console.warn(` kick typegen --fix: could not auto-patch ${t.length} module(s) (no import.meta.glob() call found) — add the patterns by hand:`);for(let e of t){let t=r.get(e)??[];console.warn(` ${e}: ${it(t).join(`, `)}`)}}return}if(!n){console.warn(` kick typegen: ${e.length} decorated class(es) not matched by any module's import.meta.glob():`);for(let[e,t]of r){for(let e of t)console.warn(` @${e.decorator} ${e.className} (${e.relativePath})`);let n=it(t);console.warn(` → add to import.meta.glob([...]) in ${e}:`),console.warn(` ${n.map(e=>`'${e}'`).join(`, `)}`)}console.warn(" → or run `kick typegen --fix` to apply these automatically.")}}function Bt(e,t,n){let r=new Set(e.collisions.map(e=>e.className)),i=e.classes.filter(e=>ut.has(e.decorator)),a=yt(e.classes,e.tokens,e.injects,r);return{registryEntries:i.length,serviceTokens:new Set(a).size,moduleTokens:bt(e.classes).length,routeEntries:e.routes.length,pluginEntries:new Set(e.pluginsAndAdapters.map(e=>e.name)).size,augmentationEntries:new Set(e.augmentations.map(e=>e.name)).size,assetEntries:t,envWritten:e.env!==null,written:n,resolvedCollisions:e.collisions.length}}async function $(e,t,n){await c(e,{recursive:!0}),await p(i(r(e),`.gitignore`),`# Auto-generated by kick typegen
127
+ `)}function Pt(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)}function Ft(e){try{return t(e).isDirectory()}catch{return!1}}var It=e({runTypegen:()=>Rt,sweepStaleTypegen:()=>Ht,watchTypegen:()=>Vt,writeTypegenArtifacts:()=>$});function Lt(e){let t=e.cwd??process.cwd();return{cwd:t,srcDir:o(t,e.srcDir??`src`),outDir:o(t,e.outDir??`.kickjs/types`),silent:e.silent??!1,allowDuplicates:e.allowDuplicates??!1,schemaValidator:e.schemaValidator??!1,envFile:e.envFile??`src/env.ts`}}async function Rt(e={}){let{cwd:t,srcDir:n,outDir:r,silent:i,allowDuplicates:a,envFile:s}=Lt(e),c=Date.now(),l={root:n,cwd:t,cacheDir:e.noCache?void 0:o(t,`.kickjs`,`cache`),envFile:s===!1?void 0:s},u=e.changedFiles?await et(l,e.changedFiles):await Z(l);if(u.collisions.length>0&&!a)throw new dt(u.collisions);let d=At(e.assetMap,t),f=[],p=[];if(e.runPlugins!==!1){try{let{runAllPluginTypegens:n}=await import(`./builtins-Ci7vBC42.mjs`).then(e=>e.n),{loadKickConfig:r}=await import(`./config-Bsokk8bV.mjs`).then(e=>e.n);f=await n({cwd:t,config:await r(t),silent:!0,changedFiles:e.changedFiles})}catch(e){if(!i){let t=e instanceof Error?e.message:String(e);console.warn(` kick typegen: plugin pipeline failed (${t}) — continuing`)}}p.push(...await $(r,f,i))}let m=Ot(u.tokens),h=Bt(u,d.count,p),g=Date.now()-c;if(!i){let e=r.replace(t+`/`,``),n=h.resolvedCollisions>0?`, ${h.resolvedCollisions} collisions namespaced`:``,i=h.envWritten?`, env typed`:``,a=h.pluginEntries>0?`, ${h.pluginEntries} plugins/adapters`:``,o=h.augmentationEntries>0?`, ${h.augmentationEntries} augmentations`:``,s=h.assetEntries>0?`, ${h.assetEntries} assets`:``;if(console.log(` kick typegen → ${h.serviceTokens} services, ${h.routeEntries} routes, ${h.moduleTokens} modules${a}${o}${s}${i}${n} → ${e} (${g}ms)`),m.length>0){console.warn(` kick typegen: ${m.length} token(s) don't match the §22.2 convention:`);for(let e of m){let t=e.variable?` [${e.variable}]`:``;console.warn(` '${e.token}' (${e.filePath})${t} — ${e.reason}`),e.suggestion&&console.warn(` → suggestion: ${e.suggestion}`)}}}return u.orphanedClasses.length>0&&await zt(u.orphanedClasses,{fix:e.fix??!1,silent:i}),{scan:u,result:h,tokenWarnings:m}}async function zt(e,{fix:t,silent:n}){let r=new Map;for(let t of e){let e=r.get(t.moduleFilePath)??[];e.push(t),r.set(t.moduleFilePath,e)}if(t){let e=0,t=[];for(let[i,a]of r){let r=it(a);try{let a=await l(i,`utf-8`),o=lt(a,r);o&&o!==a?(await p(i,o),e++,n||console.log(` kick typegen --fix: patched ${i}\n + ${r.join(`, `)}`)):t.push(i)}catch{t.push(i)}}if(!n&&(e>0&&console.log(` kick typegen --fix: updated ${e} module glob(s) — re-run typegen to pick up the now-loaded classes.`),t.length>0)){console.warn(` kick typegen --fix: could not auto-patch ${t.length} module(s) (no import.meta.glob() call found) — add the patterns by hand:`);for(let e of t){let t=r.get(e)??[];console.warn(` ${e}: ${it(t).join(`, `)}`)}}return}if(!n){console.warn(` kick typegen: ${e.length} decorated class(es) not matched by any module's import.meta.glob():`);for(let[e,t]of r){for(let e of t)console.warn(` @${e.decorator} ${e.className} (${e.relativePath})`);let n=it(t);console.warn(` → add to import.meta.glob([...]) in ${e}:`),console.warn(` ${n.map(e=>`'${e}'`).join(`, `)}`)}console.warn(" → or run `kick typegen --fix` to apply these automatically.")}}function Bt(e,t,n){let r=new Set(e.collisions.map(e=>e.className)),i=e.classes.filter(e=>ut.has(e.decorator)),a=yt(e.classes,e.tokens,e.injects,r);return{registryEntries:i.length,serviceTokens:new Set(a).size,moduleTokens:bt(e.classes).length,routeEntries:e.routes.length,pluginEntries:new Set(e.pluginsAndAdapters.map(e=>e.name)).size,augmentationEntries:new Set(e.augmentations.map(e=>e.name)).size,assetEntries:t,envWritten:e.env!==null,written:n,resolvedCollisions:e.collisions.length}}async function $(e,t,n){await c(e,{recursive:!0}),await p(i(r(e),`.gitignore`),`# Auto-generated by kick typegen
128
128
  *
129
- `,`utf-8`);let a=t.filter(e=>e.outFile).map(e=>e.outFile);return await Ht(e,a,t,n),a}async function Vt(e={}){let t=Lt(e),{srcDir:n,silent:r,cwd:i}=t,a={...t,allowDuplicates:!0,runPlugins:!1,noCache:e.noCache},o=process.env.KICKJS_WATCH_POLLING===`1`||process.env.KICKJS_WATCH_POLLING===`true`,[{runAllPluginTypegens:s},{loadKickConfig:c}]=await Promise.all([import(`./builtins-B-PqsutG.mjs`).then(e=>e.n),import(`./config-CKj2JDsP.mjs`).then(e=>e.n)]),l=await c(i),u=async()=>{try{await Rt({...a})}catch(e){if(r)return;if(e instanceof dt)console.error(`
129
+ `,`utf-8`);let a=t.filter(e=>e.outFile).map(e=>e.outFile);return await Ht(e,a,t,n),a}async function Vt(e={}){let t=Lt(e),{srcDir:n,silent:r,cwd:i}=t,a={...t,allowDuplicates:!0,runPlugins:!1,noCache:e.noCache},o=process.env.KICKJS_WATCH_POLLING===`1`||process.env.KICKJS_WATCH_POLLING===`true`,[{runAllPluginTypegens:s},{loadKickConfig:c}]=await Promise.all([import(`./builtins-Ci7vBC42.mjs`).then(e=>e.n),import(`./config-Bsokk8bV.mjs`).then(e=>e.n)]),l=await c(i),u=async()=>{try{await Rt({...a})}catch(e){if(r)return;if(e instanceof dt)console.error(`
130
130
  `+e.message+`
131
131
  `);else{let t=e instanceof Error?e.message:String(e);console.error(` kick typegen failed: ${t}`)}}},d=async()=>{try{let e=await s({cwd:i,config:l,silent:!0,watch:!0});await $(t.outDir,e,!0)}catch{}};await u(),await d();let{watch:f}=await import(`node:fs`),p=null,m=e=>{e&&/\.(ts|tsx|mts|cts)$/.test(e)&&(e.includes(`.kickjs`)||e.endsWith(`.d.ts`)||(p&&clearTimeout(p),p=setTimeout(()=>{u().then(d)},100)))};if(o){r||console.log(` kick typegen: polling mode (KICKJS_WATCH_POLLING)`);let e=setInterval(()=>{u().then(d)},2e3);return()=>clearInterval(e)}let h;try{h=f(n,{recursive:!0},(e,t)=>{m(t)})}catch(e){r||console.warn(` kick typegen: watch mode unavailable (${e?.message??e}). Falling back to polling.`);let t=setInterval(()=>{u().then(d)},2e3);return()=>clearInterval(t)}return()=>{p&&clearTimeout(p),h.close()}}async function Ht(e,t,r,i){let a=new Set;for(let e of t)a.add(n(e));for(let e of r)e.outFile&&a.add(n(e.outFile));let s;try{s=await u(e)}catch{return[]}let c=[];for(let t of s){if(!Ut.has(t)||a.has(t))continue;let n=o(e,t);try{if(!(await d(n)).isFile())continue;await f(n),c.push(t)}catch{}}return c.length>0&&!i&&console.log(` kick typegen: swept ${c.length} stale file(s): ${c.join(`, `)}`),c}const Ut=new Set([`assets.d.ts`,`env.ts`,`routes.ts`,`registry.d.ts`,`services.d.ts`,`modules.d.ts`,`plugins.d.ts`,`augmentations.d.ts`,`index.d.ts`]);export{C,E as S,w as T,et as _,At as a,k as b,bt as c,_t as d,Tt as f,Z as g,vt as h,$ as i,yt as l,wt as m,It as n,jt as o,ht as p,Vt as r,dt as s,Rt as t,Et as u,M as v,T as w,O as x,j as y};
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs-cli v8.2.2
2
+ * @forinda/kickjs-cli v8.2.4
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forinda/kickjs-cli",
3
- "version": "8.2.2",
3
+ "version": "8.2.4",
4
4
  "description": "CLI for KickJS — project scaffolding, DDD module generation, dev/build/start",
5
5
  "keywords": [
6
6
  "kickjs",
@@ -32,29 +32,29 @@
32
32
  "dist"
33
33
  ],
34
34
  "dependencies": {
35
- "@clack/prompts": "^1.7.0",
35
+ "@clack/prompts": "^1.8.0",
36
36
  "commander": "^15.0.0",
37
37
  "glob": "^13.0.6",
38
38
  "jiti": "^2.7.0",
39
- "oxc-parser": "^0.148.0",
40
- "oxfmt": "^0.66.0",
39
+ "oxc-parser": "^0.149.0",
40
+ "oxfmt": "^0.67.0",
41
41
  "picocolors": "^1.1.1",
42
42
  "pluralize": "^8.0.0",
43
- "@forinda/kickjs": "8.5.0",
44
43
  "@forinda/kickjs-cli-kit": "0.1.2",
45
- "@forinda/kickjs-db": "7.3.0"
44
+ "@forinda/kickjs-db": "7.3.0",
45
+ "@forinda/kickjs": "8.6.0"
46
46
  },
47
47
  "devDependencies": {
48
- "@swc/core": "^1.16.1",
49
- "@types/node": "^26.4.1",
48
+ "@swc/core": "^1.16.2",
49
+ "@types/node": "^26.5.1",
50
50
  "@types/pg": "^8.23.1",
51
51
  "@types/pluralize": "^0.0.33",
52
52
  "@typescript/typescript6": "^6.0.2",
53
53
  "pg": "^8.23.0",
54
54
  "typescript": "^7.0.2",
55
- "vite": "^8.2.2",
55
+ "vite": "^8.3.0",
56
56
  "vitest": "^5.0.0",
57
- "@forinda/kickjs-ai": "7.0.1"
57
+ "@forinda/kickjs-ai": "8.0.0"
58
58
  },
59
59
  "publishConfig": {
60
60
  "access": "public"
@@ -1 +0,0 @@
1
- {"version":3,"file":"fullstack-D_8yP2IS.mjs","names":[],"sources":["../src/generators/fullstack.ts"],"sourcesContent":["// `kick new --template fullstack` — a pnpm-workspace monorepo:\n//\n// my-app/\n// server/ KickJS API (the standard scaffold, minus its own git/install)\n// web/ Vite + React frontend typed end-to-end via\n// @forinda/kickjs-client + the server's generated KickRoutes.Api\n//\n// The type loop: server controllers use return-value handlers → `kick\n// typegen` (run here once, re-run by `kick dev`) emits\n// server/.kickjs/types/kick__client.d.ts → web tsconfig `types` (ambient)\n// side-effect-imports that file (type-only, erased at runtime) → the web\n// client calls `api.get('/hello')` with the handler's actual response type.\n\nimport { join } from 'node:path'\nimport { execFileSync } from 'node:child_process'\n\nimport { writeFileSafe } from '../utils/fs'\nimport { runCommand } from '../utils/shell'\nimport { initProject, resolveSiblingVersions } from './project'\n\nexport interface InitFullstackOptions {\n name: string\n directory: string\n packageManager?: 'pnpm' | 'npm' | 'yarn' | 'bun'\n initGit?: boolean\n installDeps?: boolean\n schemaLib?: 'zod' | 'valibot' | 'yup'\n runtime?: 'express' | 'fastify' | 'h3'\n}\n\nexport async function initFullstackProject(options: InitFullstackOptions): Promise<void> {\n const { name, directory, schemaLib = 'zod', runtime = 'express' } = options\n // `--pm` arrives as a free CLI string — allowlist before it reaches a\n // process invocation (execFileSync takes an argv array, no shell, but a\n // bogus binary name is still a confusing failure).\n const pmValid = (['pnpm', 'npm', 'yarn', 'bun'] as const).includes(\n options.packageManager as never,\n )\n const packageManager = pmValid\n ? (options.packageManager as 'pnpm' | 'npm' | 'yarn' | 'bun')\n : 'pnpm'\n const dir = directory\n const log = (msg: string) => console.log(` ${msg}`)\n if (options.packageManager !== undefined && !pmValid) {\n log(\n `Warning: unknown package manager '${String(options.packageManager)}' — falling back to pnpm.`,\n )\n }\n\n console.log(`\\n Creating fullstack KickJS workspace: ${name}\\n`)\n\n // ── server/ — the standard scaffold, deferred install/git ──────────\n await initProject({\n name: `${name}-server`,\n directory: join(dir, 'server'),\n packageManager,\n template: 'minimal',\n schemaLib,\n runtime,\n // web/ reads the resolved route map from the ambient KickClientApi\n // namespace, which needs the TS 7 compiler API to produce.\n withClientMap: true,\n // Root owns install + git so the lockfile/commit cover the workspace.\n initGit: false,\n installDeps: false,\n // Production single-origin serving. `web/` builds to `web/dist`, and\n // nothing served it before — `pnpm build` produced a frontend the API had\n // no way to hand out, so every deploy needed a hand-wired static host or\n // a second process. The adapter is inert until `../web/dist` exists, so\n // `dev` (Vite serves the client and proxies /api here) is untouched.\n spaClientDir: '../web/dist',\n })\n\n // ── web/ — Vite + React, typed client ──────────────────────────────\n const versions = await resolveSiblingVersions()\n const clientVersion = versions['@forinda/kickjs-client'] ?? '^0.1.0'\n\n await writeFileSafe(join(dir, 'web/package.json'), webPackageJson(name, clientVersion))\n await writeFileSafe(join(dir, 'web/vite.config.ts'), webViteConfig())\n await writeFileSafe(join(dir, 'web/tsconfig.json'), webTsConfig())\n await writeFileSafe(join(dir, 'web/index.html'), webIndexHtml(name))\n await writeFileSafe(join(dir, 'web/src/main.tsx'), webMain())\n await writeFileSafe(join(dir, 'web/src/App.tsx'), webApp())\n await writeFileSafe(join(dir, 'web/src/api.ts'), webApi())\n\n // ── workspace root ──────────────────────────────────────────────────\n await writeFileSafe(\n join(dir, 'package.json'),\n rootPackageJson(name, packageManager, versions['@forinda/kickjs-cli']),\n )\n // Only pnpm reads this file. npm / yarn / bun declare workspaces via the\n // `workspaces` field in the root package.json instead — see rootPackageJson.\n if (packageManager === 'pnpm') {\n // `allowBuilds` is answered here, not left to pnpm. This scaffold installs\n // non-interactively, so pnpm cannot prompt — it writes\n // `'@swc/core': set this to true or false` and then refuses to run ANY\n // script with ERR_PNPM_IGNORED_BUILDS, leaving a fresh project unable to\n // run `pnpm typecheck` or `pnpm dev` until someone edits this file.\n //\n // Both are build tools this template chose: swc compiles the decorators,\n // esbuild is Vite's. Approving their install scripts is the same decision\n // as depending on them.\n await writeFileSafe(\n join(dir, 'pnpm-workspace.yaml'),\n `packages:\\n - server\\n - web\\n\\nallowBuilds:\\n '@swc/core': true\\n esbuild: true\\n`,\n )\n }\n await writeFileSafe(join(dir, '.gitignore'), rootGitignore())\n await writeFileSafe(join(dir, 'README.md'), rootReadme(name, packageManager))\n\n // Workspace-root agent docs (CLAUDE.md + .agents/) flavored for the\n // fullstack layout — the server/ subdir keeps its own generated set.\n const { generateAgentDocs } = await import('./agent-docs')\n await generateAgentDocs({\n outDir: dir,\n name,\n pm: packageManager,\n template: 'fullstack',\n only: 'all',\n force: true,\n })\n\n // ── install (root — covers both workspace packages) ────────────────\n if (options.installDeps) {\n console.log(`\\n Installing workspace dependencies with ${packageManager}...\\n`)\n try {\n // `runCommand`, not bare execFileSync — on Windows every package\n // manager is a `.cmd` shim that execFileSync cannot spawn.\n runCommand(packageManager, ['install'], { cwd: dir })\n } catch {\n console.log(`\\n Warning: ${packageManager} install failed. Run it manually.`)\n }\n }\n\n // ── typegen (server) so web's KickRoutes.Api resolves immediately ──\n try {\n const { runTypegen } = await import('../typegen')\n await runTypegen({ cwd: join(dir, 'server'), allowDuplicates: true, silent: true })\n } catch {\n // Non-fatal — `kick dev` in server/ retries on boot.\n }\n\n // ── git (root) ──────────────────────────────────────────────────────\n if (options.initGit) {\n try {\n execFileSync('git', ['init'], { cwd: dir, stdio: 'pipe' })\n execFileSync('git', ['branch', '-M', 'main'], { cwd: dir, stdio: 'pipe' })\n execFileSync('git', ['add', '-A'], { cwd: dir, stdio: 'pipe' })\n execFileSync('git', ['commit', '-m', 'chore: initial commit from kick new (fullstack)'], {\n cwd: dir,\n stdio: 'pipe',\n })\n log('Git repository initialized')\n } catch {\n log('Warning: git init failed (git may not be installed)')\n }\n }\n\n console.log('\\n Fullstack workspace scaffolded!')\n console.log()\n log('Next steps:')\n log(` cd ${name}`)\n if (!options.installDeps) log(` ${packageManager} install`)\n if (packageManager === 'pnpm') {\n log(' pnpm dev # runs server (kick dev) + web (vite) together')\n } else {\n log(` ${packageManager} run dev:server # terminal 1`)\n log(` ${packageManager} run dev:web # terminal 2`)\n }\n log('')\n log('The web app calls the API through @forinda/kickjs-client —')\n log(\"edit server/src/modules/hello and watch web/src/App.tsx's types follow.\")\n log('')\n}\n\n// ── web templates ─────────────────────────────────────────────────────\n\nfunction webPackageJson(name: string, clientVersion: string): string {\n return `${JSON.stringify(\n {\n name: `${name}-web`,\n private: true,\n version: '0.0.0',\n type: 'module',\n scripts: {\n dev: 'vite',\n build: 'tsc --noEmit && vite build',\n preview: 'vite preview',\n typecheck: 'tsc --noEmit',\n },\n dependencies: {\n '@forinda/kickjs-client': clientVersion,\n react: '^19.0.0',\n 'react-dom': '^19.0.0',\n },\n devDependencies: {\n '@types/react': '^19.0.0',\n '@types/react-dom': '^19.0.0',\n '@vitejs/plugin-react': '^5.0.0',\n typescript: '^5.9.0',\n vite: '^7.0.0',\n },\n },\n null,\n 2,\n )}\\n`\n}\n\nfunction webViteConfig(): string {\n return `import { defineConfig } from 'vite'\nimport react from '@vitejs/plugin-react'\n\nexport default defineConfig({\n plugins: [react()],\n server: {\n // The KickJS server (kick dev) listens on 3000; the client's baseUrl is\n // the relative '/api/v1', so the browser hits Vite and Vite forwards.\n proxy: {\n '/api': 'http://localhost:3000',\n },\n },\n})\n`\n}\n\nexport function webTsConfig(): string {\n return `${JSON.stringify(\n {\n compilerOptions: {\n target: 'ES2022',\n lib: ['ES2022', 'DOM', 'DOM.Iterable'],\n module: 'ESNext',\n moduleResolution: 'bundler',\n jsx: 'react-jsx',\n strict: true,\n skipLibCheck: true,\n noEmit: true,\n isolatedModules: true,\n // The resolved client route map, as an ambient global type package —\n // the same mechanism as \"node\" or \"vitest/globals\". It makes\n // `KickClientApi.Api` available with no import and no bridge file.\n //\n // Note this is a `types` ENTRY, not an `include`: the map is a global\n // type package, not source of this app. It also means the file must\n // exist — `kick new` runs typegen for you, and `kick typegen` in\n // server/ refreshes it. (An `include` entry tolerates the file being\n // absent; a `types` entry reports TS2688, which is the louder and\n // more useful failure for something the app depends on.)\n //\n // No `experimentalDecorators` here: unlike the ambient\n // `KickRoutes.Api` bridge, this map carries no reference to the\n // server's decorated controller sources.\n types: ['../server/.kickjs/types/kick__client'],\n },\n include: ['src'],\n },\n null,\n 2,\n )}\\n`\n}\n\nfunction webIndexHtml(name: string): string {\n return `<!doctype html>\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <title>${name}</title>\n </head>\n <body>\n <div id=\"root\"></div>\n <script type=\"module\" src=\"/src/main.tsx\"></script>\n </body>\n</html>\n`\n}\n\nfunction webMain(): string {\n return `import { StrictMode } from 'react'\nimport { createRoot } from 'react-dom/client'\nimport { App } from './App'\n\ncreateRoot(document.getElementById('root')!).render(\n <StrictMode>\n <App />\n </StrictMode>,\n)\n`\n}\n\nfunction webApp(): string {\n return `import { useEffect, useState } from 'react'\nimport { api } from './api'\n\n// The response types below are INFERRED from the server's handlers —\n// change server/src/modules/hello/hello.service.ts and these types follow on\n// the next \\`kick typegen\\`. Not under \\`kick dev\\`: resolving the client map\n// builds a whole TypeScript program, so it is a build step, not a per-save one.\ntype Greeting = Awaited<ReturnType<typeof fetchGreeting>>\n\nfunction fetchGreeting() {\n return api.get('/hello')\n}\n\nexport function App() {\n const [greeting, setGreeting] = useState<Greeting | null>(null)\n const [health, setHealth] = useState<string>('checking…')\n\n useEffect(() => {\n fetchGreeting().then(setGreeting).catch(console.error)\n api\n .get('/hello/health')\n .then((h) => setHealth(h.status))\n .catch(() => setHealth('down'))\n }, [])\n\n return (\n <main style={{ fontFamily: 'system-ui', maxWidth: 640, margin: '4rem auto', padding: '0 1rem' }}>\n <h1>KickJS fullstack</h1>\n <p>\n <strong>{greeting?.message ?? 'loading…'}</strong>\n </p>\n <p>\n Server said hello at <code>{greeting?.timestamp ?? '…'}</code> — health:{' '}\n <code>{health}</code>\n </p>\n <p style={{ color: '#666' }}>\n This call is typed end to end: <code>api.get('/hello')</code> returns the exact shape\n <code> HelloService.greet()</code> produces. Rename a field on the server and this file\n stops compiling.\n </p>\n </main>\n )\n}\n`\n}\n\nexport function webApi(): string {\n return `import { createClient } from '@forinda/kickjs-client'\n\n// KickClientApi is ambient — the resolved route map from\n// server/.kickjs/types/kick__client.d.ts, wired in tsconfig's \\`types\\`. Every\n// response type is a literal shape, so nothing from the server's source graph\n// enters this program.\n//\n// Keys are module-mount-relative paths; the bootstrap-level '/api/v1' prefix\n// lives here in baseUrl, and the Vite dev proxy forwards it to the KickJS\n// server.\n//\n// Prefer an explicit import? The same file exports the type:\n// import type { Api } from '../../server/.kickjs/types/kick__client'\nexport const api = createClient<KickClientApi.Api>({ baseUrl: '/api/v1' })\n`\n}\n\n// ── root templates ────────────────────────────────────────────────────\n\nfunction rootPackageJson(name: string, pm: string, cliVersion: string): string {\n const scripts: Record<string, string> =\n pm === 'pnpm'\n ? {\n dev: 'pnpm --parallel -r run dev',\n // One origin: the server serves `web/dist` through SpaAdapter.\n start: 'pnpm --filter ./server run start',\n 'dev:server': 'pnpm --filter ./server dev',\n 'dev:web': 'pnpm --filter ./web dev',\n build: 'pnpm -r run build',\n // No `npx`: the binary is `kick` but the package is\n // `@forinda/kickjs-cli`, so npx cannot map one to the other and\n // falls back to the REGISTRY — where `kick` is an unrelated\n // AngularJS scaffolder. It runs, prints its own help, and exits 0,\n // so this script would pass without type-checking anything.\n //\n // Every package manager puts `node_modules/.bin` on PATH for\n // scripts, so the bare name resolves locally, and a missing install\n // fails loudly instead of fetching a stranger.\n typecheck: 'kick typecheck --cwd server && kick typecheck --cwd web',\n }\n : {\n // cd-based scripts — the one form npm, yarn (classic AND berry),\n // and bun all run identically; workspace-filter flags differ per\n // manager (--workspace vs `yarn workspace <name>` vs --filter).\n start: `cd server && ${pm} run start`,\n 'dev:server': `cd server && ${pm} run dev`,\n 'dev:web': `cd web && ${pm} run dev`,\n build: `${pm} run build:server && ${pm} run build:web`,\n 'build:server': `cd server && ${pm} run build`,\n 'build:web': `cd web && ${pm} run build`,\n // No `npx`: the binary is `kick` but the package is\n // `@forinda/kickjs-cli`, so npx cannot map one to the other and\n // falls back to the REGISTRY — where `kick` is an unrelated\n // AngularJS scaffolder. It runs, prints its own help, and exits 0,\n // so this script would pass without type-checking anything.\n //\n // Every package manager puts `node_modules/.bin` on PATH for\n // scripts, so the bare name resolves locally, and a missing install\n // fails loudly instead of fetching a stranger.\n typecheck: 'kick typecheck --cwd server && kick typecheck --cwd web',\n }\n return `${JSON.stringify(\n {\n name,\n private: true,\n version: '0.0.0',\n type: 'module',\n scripts,\n // The CLI is a ROOT dependency so the bare `kick` in the scripts above\n // resolves: package managers put `node_modules/.bin` on PATH for\n // scripts, and the CLI otherwise lives only in `server/node_modules`.\n devDependencies: { '@forinda/kickjs-cli': cliVersion },\n workspaces: ['server', 'web'],\n },\n null,\n 2,\n )}\\n`\n}\n\nfunction rootGitignore(): string {\n return `node_modules/\ndist/\n.env\n*.log\n.DS_Store\n`\n}\n\nfunction rootReadme(name: string, pm: string): string {\n return `# ${name}\n\nFullstack KickJS workspace — typed end to end.\n\n| Package | What |\n| --------- | ----------------------------------------------------------------- |\n| \\`server/\\` | KickJS API (decorators, DI, \\`kick dev\\` with typegen watch) |\n| \\`web/\\` | Vite + React, typed against the API via \\`@forinda/kickjs-client\\` |\n\n## Develop\n\n\\`\\`\\`bash\n${pm} install\n${pm === 'pnpm' ? 'pnpm dev # server (kick dev) + web (vite), in parallel' : `${pm} run dev:server # terminal 1\\n${pm} run dev:web # terminal 2`}\n\\`\\`\\`\n\nServer: http://localhost:3000 · Web: http://localhost:5173 (Vite proxies \\`/api\\`).\n\n## The type loop\n\n1. Server handlers **return** their payloads (\\`return this.service.greet(...)\\`).\n2. \\`kick typegen\\` emits \\`server/.kickjs/types/kick__client.d.ts\\` — the flat\n route map with every response type resolved to a literal shape.\n3. \\`web/tsconfig.json\\` lists that file in \\`types\\`, so \\`KickClientApi\\` is\n ambient — no import, no bridge file.\n4. \\`web/src/api.ts\\`'s \\`createClient<KickClientApi.Api>\\` types every call site.\n\nBecause the map holds resolved types rather than references to controllers,\n\\`web\\` never compiles server source: no \\`experimentalDecorators\\`, no path\naliases into \\`server/src\\`.\n\nRename a field in \\`server/src/modules/hello/hello.service.ts\\` → \\`web/src/App.tsx\\`\nstops compiling. That's the point.\n\n### Keeping the map fresh\n\n\\`server/.kickjs/types/kick__client.d.ts\\` is generated, and \\`web\\` reads it as\nan ambient type package. Two things follow.\n\n**It is not refreshed by \\`kick dev\\`.** Resolving it builds a whole TypeScript\nprogram over the server, which is a build-step cost rather than a per-save one,\nso a renamed response field surfaces on the next \\`kick typegen\\` rather than on\nsave. Everything else in \\`.kickjs/types\\` still updates on save. Add\n\\`kick typegen --check\\` to CI and a stale map fails the build.\n\n**It needs a compiler API.** TypeScript 7 ships none, so \\`server\\` depends on\n\\`@typescript/typescript6\\`. Remove it and typegen skips this one file, saying\nso; \\`web\\` then reports \\`TS2688\\` because the file it lists in \\`types\\` is gone.\n\n### The other way to wire it\n\nA \\`types\\` entry says \"this is a global type package\", which is what the map is,\nand it fails loudly when the file is missing. If you would rather it be quiet\nwhen absent — say, a repo where the map is not always generated — use\n\\`include\\` instead:\n\n\\`\\`\\`json\n{ \"include\": [\"src\", \"../server/.kickjs/types/kick__client.d.ts\"] }\n\\`\\`\\`\n\nThat tolerates the file not existing, at the cost of \\`KickClientApi\\` silently\nnot resolving. Note \\`types\\` replaces TypeScript's automatic \\`@types\\`\ninclusion, so if you add entries there, list the ones you rely on too\n(\\`\"types\": [\"node\", \"../server/.kickjs/types/kick__client\"]\\`).\n\nOr skip the global entirely — the same file exports the type:\n\n\\`\\`\\`ts\nimport type { Api } from '../../server/.kickjs/types/kick__client'\n\nexport const api = createClient<Api>({ baseUrl: '/api/v1' })\n\\`\\`\\`\n\nDocs: https://kickjs.app/guide/typed-client.html\n`\n}\n"],"mappings":"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"}