@forinda/kickjs-cli 8.5.0 → 8.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/dist/{project-docs-Y6vOc-Uj.mjs → agent-docs-BFOgLbXq.mjs} +9 -71
  2. package/dist/agent-docs-BFOgLbXq.mjs.map +1 -0
  3. package/dist/{project-docs-BE8DKCWP.mjs → agent-docs-BU1rORKA.mjs} +3 -65
  4. package/dist/{build-D3rNfcxu.mjs → build-CdIpRyfy.mjs} +3 -3
  5. package/dist/{build-D3rNfcxu.mjs.map → build-CdIpRyfy.mjs.map} +1 -1
  6. package/dist/{build-DwfrMHgx.mjs → build-DlfIkjcw.mjs} +2 -2
  7. package/dist/{builtins-D4pwODzu.mjs → builtins-CfAXBoIM.mjs} +2 -2
  8. package/dist/{builtins-DtTYiDg0.mjs → builtins-CmuUgcIq.mjs} +36 -31
  9. package/dist/cli.mjs +2 -2
  10. package/dist/config-SvlcF3Ls.mjs +12 -0
  11. package/dist/config-ndsVdO8u.mjs +13 -0
  12. package/dist/config-ndsVdO8u.mjs.map +1 -0
  13. package/dist/{doctor-Df6zCPr5.mjs → doctor-D3RMXkxE.mjs} +6 -6
  14. package/dist/{doctor-Df6zCPr5.mjs.map → doctor-D3RMXkxE.mjs.map} +1 -1
  15. package/dist/fs-DdNMcW_P.mjs +12 -0
  16. package/dist/fs-DdNMcW_P.mjs.map +1 -0
  17. package/dist/fs-v57MCgpH.mjs +11 -0
  18. package/dist/fullstack-DOufUeMv.mjs +95 -0
  19. package/dist/fullstack-LJwhodT-.mjs +96 -0
  20. package/dist/fullstack-LJwhodT-.mjs.map +1 -0
  21. package/dist/index.d.mts +15 -24
  22. package/dist/index.d.mts.map +1 -1
  23. package/dist/index.mjs +2 -2
  24. package/dist/{plugin-B8fmVbk8.mjs → plugin-Dighdqh-.mjs} +2 -2
  25. package/dist/{plugin-B-mP0jvi.mjs → plugin-Dn67elEZ.mjs} +2 -2
  26. package/dist/project-AXCA1hD9.mjs +45 -0
  27. package/dist/project-Cb_NLUWI.mjs +46 -0
  28. package/dist/project-Cb_NLUWI.mjs.map +1 -0
  29. package/dist/{project-root-BzyIWFlH.mjs → project-root-C7TrLJlZ.mjs} +3 -3
  30. package/dist/{project-root-BzyIWFlH.mjs.map → project-root-C7TrLJlZ.mjs.map} +1 -1
  31. package/dist/{project-root-CSHMf3L7.mjs → project-root-Dgvy5kYG.mjs} +2 -2
  32. package/dist/{prompts-wFEGsPZt.mjs → prompts-CSATvwXw.mjs} +2 -2
  33. package/dist/{prompts-wFEGsPZt.mjs.map → prompts-CSATvwXw.mjs.map} +1 -1
  34. package/dist/{rolldown-runtime-DzFISCwE.mjs → rolldown-runtime-BhxEEqxa.mjs} +1 -1
  35. package/dist/{run-plugins-ByRyAAZe.mjs → run-plugins-Cf_6BgGZ.mjs} +34 -29
  36. package/dist/run-plugins-Cf_6BgGZ.mjs.map +1 -0
  37. package/dist/{typegen-BfOYvlWo.mjs → typegen-97E_RYNp.mjs} +4 -4
  38. package/dist/typegen-CYhFNfIu.mjs +132 -0
  39. package/dist/{typegen-Bx2IQ-w5.mjs.map → typegen-CYhFNfIu.mjs.map} +1 -1
  40. package/dist/{types-dUiZnaWm.mjs → types-lHwt_SNI.mjs} +1 -1
  41. package/package.json +10 -9
  42. package/templates/base/feature.json +18 -0
  43. package/templates/base/files/README.md +61 -0
  44. package/templates/base/files/_dot_editorconfig +13 -0
  45. package/templates/base/files/_dot_env +2 -0
  46. package/templates/base/files/_dot_env.example +2 -0
  47. package/templates/base/files/_dot_env.test +9 -0
  48. package/templates/base/files/_dot_env.test.example +11 -0
  49. package/templates/base/files/_dot_gitattributes +18 -0
  50. package/templates/base/files/_dot_gitignore +14 -0
  51. package/templates/base/files/_dot_oxfmtrc.json +9 -0
  52. package/templates/base/files/kick.config.ts +58 -0
  53. package/templates/base/files/src/modules/hello/hello.controller.ts +26 -0
  54. package/templates/base/files/src/modules/hello/hello.module.ts +21 -0
  55. package/templates/base/files/src/modules/hello/hello.service.ts +12 -0
  56. package/templates/base/files/src/modules/index.ts +7 -0
  57. package/templates/base/files/tsconfig.json +21 -0
  58. package/templates/base/files/vite.config.ts +31 -0
  59. package/templates/base/files/vitest.config.ts +18 -0
  60. package/templates/feature-devtools/feature.json +13 -0
  61. package/templates/feature-queue/feature.json +16 -0
  62. package/templates/feature-queue/files/_dot_env.append +2 -0
  63. package/templates/feature-queue/files/_dot_env.example.append +2 -0
  64. package/templates/feature-swagger/feature.json +16 -0
  65. package/templates/feature-ws/feature.json +13 -0
  66. package/templates/fullstack-root/files/_dot_gitignore +8 -0
  67. package/templates/fullstack-root/files/netlify.toml +13 -0
  68. package/templates/fullstack-root/files/vercel.json +5 -0
  69. package/templates/host-config/files/netlify.toml +6 -0
  70. package/templates/host-config/files/vercel.json +5 -0
  71. package/templates/runtime-express/feature.json +22 -0
  72. package/templates/runtime-fastify/feature.json +13 -0
  73. package/templates/runtime-h3/feature.json +13 -0
  74. package/templates/schema-valibot/feature.json +3 -0
  75. package/templates/schema-valibot/files/src/config/index.ts +41 -0
  76. package/templates/schema-yup/feature.json +3 -0
  77. package/templates/schema-yup/files/src/config/index.ts +43 -0
  78. package/templates/schema-zod/feature.json +3 -0
  79. package/templates/schema-zod/files/src/config/index.ts +41 -0
  80. package/templates/server-fullstack/feature.json +13 -0
  81. package/templates/template-minimal/feature.json +10 -0
  82. package/templates/template-minimal/files/src/index.ts +17 -0
  83. package/templates/template-rest/feature.json +10 -0
  84. package/templates/template-rest/files/src/index.ts +28 -0
  85. package/templates/web-kick/files/web/index.html +12 -0
  86. package/templates/web-kick/files/web/src/App.tsx +45 -0
  87. package/templates/web-kick/files/web/src/api.ts +14 -0
  88. package/templates/web-kick/files/web/src/main.tsx +9 -0
  89. package/templates/web-kick/files/web/tsconfig.json +15 -0
  90. package/templates/web-kick/files/web/vite.config.ts +13 -0
  91. package/dist/agent-docs-CXX06wib.mjs +0 -11
  92. package/dist/agent-docs-CXs5UDAM.mjs +0 -12
  93. package/dist/agent-docs-CXs5UDAM.mjs.map +0 -1
  94. package/dist/config-BUYf44lU.mjs +0 -13
  95. package/dist/config-BUYf44lU.mjs.map +0 -1
  96. package/dist/config-F1NW28_P.mjs +0 -12
  97. package/dist/fullstack-BcJ5lOwt.mjs +0 -194
  98. package/dist/fullstack-D3W7RS2W.mjs +0 -195
  99. package/dist/fullstack-D3W7RS2W.mjs.map +0 -1
  100. package/dist/project-5aAVIQV5.mjs +0 -450
  101. package/dist/project-DdYD7xPw.mjs +0 -451
  102. package/dist/project-DdYD7xPw.mjs.map +0 -1
  103. package/dist/project-docs-Y6vOc-Uj.mjs.map +0 -1
  104. package/dist/run-plugins-ByRyAAZe.mjs.map +0 -1
  105. package/dist/typegen-Bx2IQ-w5.mjs +0 -132
@@ -1,132 +0,0 @@
1
- /**
2
- * @forinda/kickjs-cli v8.5.0
3
- *
4
- * Copyright (c) Felix Orinda
5
- *
6
- * This source code is licensed under the MIT license found in the
7
- * LICENSE file in the root directory of this source tree.
8
- *
9
- * @license MIT
10
- */
11
- import{t as e}from"./rolldown-runtime-DzFISCwE.mjs";import{basename as t,dirname as n,join as r,relative as i,resolve as a,sep as o}from"node:path";import{statSync as s}from"node:fs";import{mkdir as c,readFile as l,readdir as u,stat as d,unlink as f,writeFile as p}from"node:fs/promises";import{globSync as m}from"glob";import{groupAssetKeys as h}from"@forinda/kickjs";import{parseSync as ee}from"oxc-parser";const g=[`classes`,`tokens`,`injects`,`pluginsAndAdapters`,`augmentations`,`contextKeys`,`routeFlags`,`routes`,`moduleMounts`,`globPatterns`];function _(e){if(!e||typeof e!=`object`)return!1;let t=e;return g.every(e=>Array.isArray(t[e]))}var v=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=r(t,`scan.json`),i=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`&&_(n.extract)&&i.set(e,n)}catch{}return new e(n,i)}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(n(this.path),{recursive:!0}),await p(this.path,JSON.stringify(t),`utf-8`)}catch{}}};let y=null;function b(){return y??=new Set(F),y}const x=new Set([`Get`,`Post`,`Put`,`Delete`,`Patch`]);function S(e){return typeof e==`object`&&!!e&&typeof e.type==`string`}function C(e,t){if(Array.isArray(e)){for(let n of e)C(n,t);return}if(S(e)){t(e);for(let n of Object.keys(e)){if(n===`type`)continue;let r=e[n];typeof r==`object`&&r&&C(r,t)}}}function w(e){if(!S(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 T(e){return S(e)&&e.type===`Identifier`?e.name:null}function E(e){return T(e.callee)}function D(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((T(e)??(e.type===`Literal`?String(e.value):w(e)))===t)return n.value}return null}function O(e){let t=e.arguments?.[0];return S(t)&&t.type===`ObjectExpression`?t:null}function k(e,t){let n=D(e,t);if(!S(n)||n.type!==`ArrayExpression`)return[];let r=[];for(let e of n.elements??[]){let t=w(e);t!==null&&r.push(t)}return r}function te(e,t){return i(t,e).split(o).join(`/`)}function ne(e){return(e.match(/:([a-zA-Z_]\w*)/g)??[]).map(e=>e.slice(1))}function re(e,t){for(let n of e.implements??[]){let e=n.expression??n;if(T(e)===t)return!0;if(e.type===`TSQualifiedName`||e.type===`MemberExpression`){let n=e.right??e.property;if(n&&T(n)===t)return!0}}return!1}function A(e){return e.decorators??[]}function j(e){let t=e.expression;if(!S(t)||t.type!==`CallExpression`)return null;let n=E(t);return n?{name:n,call:t}:null}function ie(e){let t=new Map,n=new Set;for(let r of e.body??[]){if(r.type===`ImportDeclaration`){let e=w(r.source)??``;for(let n of r.specifiers??[]){let r=T(n.local);r&&t.set(r,{source:e})}continue}let e=r.type===`VariableDeclaration`?r:r.type===`ExportNamedDeclaration`&&S(r.declaration)?r.declaration:null;if(S(e)&&e.type===`VariableDeclaration`)for(let t of e.declarations??[]){let e=T(t.id);e&&n.add(e)}}return{imports:t,topLevelConsts:n}}function ae(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 oe(e,t){let n=[];for(let r of e){let e=j(r),i=e?e.name:T(r.expression);if(!i||x.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 M=new Set([`bootstrap`,`createWebApp`,`Application`]);function se(e,t){if(!M.has(e))return!1;let n=t.imports.get(e)?.source;return n===`@forinda/kickjs`||(n?.startsWith(`@forinda/kickjs/`)??!1)}function ce(e,t){let n={refs:[],resolved:!1},r=le(e);if(!r||r.type!==`ArrayExpression`)return n;let i=[];for(let e of r.elements??[]){if(!S(e)||e.type!==`MemberExpression`||T(e.property)!==`registration`)return n;let r=e.object,a=T(r);if(!a&&S(r)&&r.type===`CallExpression`){let e=r.callee;S(e)&&e.type===`MemberExpression`&&T(e.property)===`with`&&(a=T(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 le(e){let t=e.value??e;if(!S(t))return null;if(t.type===`ArrayExpression`)return t;let n=t.body;if(!S(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 S(i)?i:null}function N(e,t,n){let r=T(D(e,t));return r?ae(r,n):null}function ue(e,t){for(let n of e){let e=j(n);if(!e||e.name!==`ApiQueryParams`)continue;let r=e.call.arguments?.[0],i=null;if(S(r)&&r.type===`ObjectExpression`)i=r;else{let e=T(r);if(e){let n=t.get(e);n&&n.type===`ObjectExpression`&&(i=n)}}return{filterable:k(i,`filterable`),sortable:k(i,`sortable`),searchable:k(i,`searchable`)}}return null}function P(e,t,n){let r;try{let n=ee(t,e);if(n.errors.length>0)return null;r=n.program}catch{return null}let i=te(t,n),a=ie(r),o=[],s=[],c=[],l=[],u=[],d=[],f=[],p=new Set,m=[],h=[],g=[],_=new Set,v=new Set,y=new Map;C(r,e=>{if(e.type!==`VariableDeclarator`)return;let t=T(e.id),n=e.init;t&&S(n)&&y.set(n,t)});let k=new Set,ae=new Map;for(let e of r.body??[]){let t=e.type===`VariableDeclaration`?e:e.type===`ExportNamedDeclaration`&&S(e.declaration)?e.declaration:null;if(S(t)&&t.type===`VariableDeclaration`)for(let e of t.declarations??[]){let t=T(e.id);t&&S(e.init)&&ae.set(t,e.init)}}let M=[];for(let e of r.body??[])if(e.type===`ExportNamedDeclaration`&&S(e.declaration)){let t=e.declaration;t.type===`ClassDeclaration`&&M.push({cls:t,isDefault:!1})}else if(e.type===`ExportDefaultDeclaration`&&S(e.declaration)){let t=e.declaration;t.type===`ClassDeclaration`&&M.push({cls:t,isDefault:!0})}for(let{cls:e,isDefault:n}of M){let r=T(e.id);if(!r)continue;let a=null;for(let t of A(e)){let e=j(t);if(e&&b().has(e.name)){a=e.name;break}}a?o.push({className:r,decorator:a,filePath:t,relativePath:i,isDefault:n}):re(e,`AppModule`)&&o.push({className:r,decorator:`Module`,filePath:t,relativePath:i,isDefault:n})}for(let e of r.body??[]){if(e.type!==`ExportNamedDeclaration`||!S(e.declaration))continue;let n=e.declaration;if(n.type===`VariableDeclaration`)for(let e of n.declarations??[]){let n=T(e.id),r=e.init;n&&S(r)&&r.type===`CallExpression`&&E(r)===`defineModule`&&(o.some(e=>e.className===n)||o.push({className:n,decorator:`Module`,filePath:t,relativePath:i,isDefault:!1}))}}C(r,n=>{if(n.type===`VariableDeclarator`){let e=n.init;if(S(e)&&e.type===`CallExpression`&&E(e)===`createToken`){let r=w(e.arguments?.[0]);r!==null&&(k.add(e),s.push({name:r,variable:T(n.id),filePath:t,relativePath:i}))}return}if(n.type!==`CallExpression`){if(n.type===`Decorator`){let e=j(n);if(e?.name===`Inject`){let n=w(e.call.arguments?.[0]);n!==null&&c.push({name:n,filePath:t,relativePath:i})}}return}let r=n.callee,a=E(n);if(a===`createToken`&&!k.has(n)){let e=w(n.arguments?.[0]);e!==null&&s.push({name:e,variable:null,filePath:t,relativePath:i});return}if(a===`defineAdapter`||a===`definePlugin`){let e=w(D(O(n),`name`));if(e!==null){let n=a===`definePlugin`?`plugin`:`adapter`,r=`${a}::${e}::${t}`;_.has(r)||(_.add(r),l.push({kind:n,name:e,filePath:t,relativePath:i}))}return}if(a===`defineAugmentation`){let e=n.arguments??[],r=w(e[0]);if(r!==null){let n=S(e[1])&&e[1].type===`ObjectExpression`?e[1]:null;u.push({name:r,description:w(D(n,`description`)),example:w(D(n,`example`)),filePath:t,relativePath:i})}return}if(a===`defineRouteFlag`){let r=w(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=w(D(O(n),`key`));e!==null&&!v.has(e)&&(v.add(e),d.push({key:e,exportName:y.get(n)??null,filePath:t,relativePath:i}));return}if(S(r)&&r.type===`CallExpression`){let e=r.callee;if(S(e)&&e.type===`MemberExpression`&&T(e.property)===`withParams`){let r=T(e.object);if(r===`defineContextDecorator`||r===`defineHttpContextDecorator`){let e=w(D(O(n),`key`));e!==null&&!v.has(e)&&(v.add(e),d.push({key:e,exportName:y.get(n)??null,filePath:t,relativePath:i}))}}return}if(S(r)&&r.type===`MemberExpression`&&T(r.property)===`glob`){let e=r.object;S(e)&&e.type===`MetaProperty`&&C(n.arguments,e=>{let t=w(e);t!==null&&g.push(t)})}});let le=[];C(r,e=>{if(e.type===`ClassDeclaration`||e.type===`ClassExpression`){let t=T(e.id);t&&le.push({cls:e,className:t})}});for(let{cls:e,className:n}of le){let r=o.find(e=>e.className===n),s=e.body?.body;if(re(e,`AppAdapter`))for(let e of s??[]){if(e.type!==`PropertyDefinition`||T(e.key)!==`name`)continue;let n=w(e.value);if(n===null)continue;let r=`class::${n}::${t}`;_.has(r)||(_.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=T(o.key);if(!s)continue;if(s===`routes`){de(o.value,h);continue}if(!r)continue;let c=A(o),l=ue(c,ae),u=[...oe(A(e),a),...oe(c,a)];for(let e of c){let o=j(e);if(!o||!x.has(o.name))continue;let c=o.call.arguments??[],d=w(c[0]),f=d&&d.length>0?d:`/`,p=S(c[1])&&c[1].type===`ObjectExpression`?c[1]:null;m.push({controller:n,method:s,httpMethod:o.name.toUpperCase(),path:f,pathParams:ne(f),queryFilterable:l?.filterable??null,querySortable:l?.sortable??null,querySearchable:l?.searchable??null,bodySchema:N(p,`body`,a),querySchema:N(p,`query`,a),paramsSchema:N(p,`params`,a),responseSchema:N(p,`response`,a),filePath:t,relativePath:i,controllerIsDefaultExport:r.isDefault,appliedDecorators:u,mountedPath:f})}}}C(r,e=>{if(e.type!==`Property`||T(e.key)!==`routes`)return;let t=e.value;S(t)&&(t.type===`FunctionExpression`||t.type===`ArrowFunctionExpression`)&&de(t,h)});let P=new Set,F=new Set;C(r,e=>{let t=e.type===`Property`&&T(e.key)===`contributors`,n=e.type===`MethodDefinition`&&T(e.key)===`contributors`;(t||n)&&F.add(e)});let fe=e=>e.properties??e.body?.body??[];C(r,e=>{if(e.type!==`ObjectExpression`&&e.type!==`ClassDeclaration`)return;let t=fe(e);if(t.map(e=>T(e.key)).includes(`routes`))for(let e of t)T(e.key)===`contributors`&&P.add(e)});let I=new Set;C(r,e=>{let t=e.type===`CallExpression`?E(e):e.type===`NewExpression`?T(e.callee):null;if(t===null||!se(t,a))return;let n=O(e);if(n)for(let e of n.properties??[])e.type===`Property`&&T(e.key)===`contributors`&&I.add(e)});let L=e=>{if(e.size===0)return null;let n=[],r=!0;for(let t of e){let e=ce(t,a);e.resolved||(r=!1),n.push(...e.refs)}return{refs:n,resolved:r,filePath:t}},R=L(P),z=L(I);return{classes:o,tokens:s,injects:c,pluginsAndAdapters:l,augmentations:u,contextKeys:d,routeFlags:f,routes:m,moduleMounts:h,globPatterns:/\.module\.[mc]?[tj]sx?$/.test(t)?g:[],moduleContributors:R,appContributors:z,hasNonDecoratorContributors:F.size>P.size+I.size}}function de(e,t){let n=[],r=[];C(e.body,e=>{if(e.type!==`Property`)return;let t=T(e.key);if(t===`path`){let t=w(e.value);t!==null&&n.push(t)}else if(t===`controller`){let t=T(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 F=[`Service`,`Controller`,`Repository`,`Injectable`,`Component`,`Module`],fe=[`.ts`,`.tsx`,`.mts`,`.cts`],I=[`node_modules`,`.kickjs`,`dist`,`build`,`.test.`,`.spec.`,`.d.ts`],L=new RegExp(String.raw`@(${F.join(`|`)})\s*\([^)]*\)`+String.raw`(?:\s*@[A-Z]\w*(?:\s*\([^)]*\))?)*`+String.raw`\s*export\s+(default\s+)?(?:abstract\s+)?class\s+(\w+)`,`g`),R=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`),z=/export\s+const\s+(\w+)\s*(?::\s*[^=]+)?=\s*defineModule\s*(?:<[^>]*>)?\s*\(/g,pe=/(?:export\s+)?const\s+(\w+)\s*(?::\s*[^=]+)?=\s*createToken\s*(?:<[^>]*>)?\s*\(\s*['"`]([^'"`]+)['"`]\s*\)/g,me=/createToken\s*(?:<[^>]*>)?\s*\(\s*['"`]([^'"`]+)['"`]\s*\)/g,he=/@Inject\s*\(\s*['"`]([^'"`]+)['"`]\s*\)/g,B=/\b(defineAdapter|definePlugin)\s*(?:<[^>]*>)?\s*\(/g,V=/(?:(?:export\s+)?(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*(?::[^=]+)?=\s*)?\b(?:defineContextDecorator|defineHttpContextDecorator)\s*(?:\.withParams\s*<(?:[^<>]|<[^<>]*>)*>\s*\(\s*\))?\s*(?:<(?:[^<>]|<[^<>]*>)*>)?\s*\(/g,ge=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`),_e=/\bname\s*(?::\s*[^=]+)?=\s*['"`]([^'"`]+)['"`]/,ve=/\bdefineAugmentation\s*\(\s*['"`]([^'"`]+)['"`]\s*(,\s*\{)?/g,H=new RegExp(String.raw`@(${[`Get`,`Post`,`Put`,`Delete`,`Patch`].join(`|`)})\s*\(`,`g`);function U(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 ye(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=U(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 be(e){return(e.match(/:([a-zA-Z_]\w*)/g)??[]).map(e=>e.slice(1))}function xe(e,t){let n=e.endsWith(`/`)?e.slice(0,-1):e;return!t||t===`/`?n||`/`:n+(t.startsWith(`/`)?t:`/`+t)||`/`}const Se=/\b(?:public\s+|private\s+|protected\s+)?routes\s*\([^)]*\)\s*(?::\s*[A-Za-z_][\w<>[\]\s,|]*\s*)?\{/g,Ce=/\bpath\s*:\s*['"`]([^'"`]*)['"`]/g,we=/\bcontroller\s*:\s*([A-Z]\w*)\b/g,Te=/\bimport\.meta\.glob\s*\(/g;function Ee(e){let t=[];for(Te.lastIndex=0;Te.exec(e)!==null;){let n=Te.lastIndex-1,r=U(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 De(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 Oe(e,t){let n=e.startsWith(`./`)?e:`./`+e,r=!1;for(let e of t){let t=e.startsWith(`!`);De(t?e.slice(1):e).test(n)&&(r=!t)}return r}function ke(e){let t=[];Se.lastIndex=0;let n;for(;(n=Se.exec(e))!==null;){let r=e.indexOf(`{`,n.index+n[0].length-1);if(r<0)continue;let i=J(e,r);if(i<0)continue;let a=e.slice(r+1,i),o=[];Ce.lastIndex=0;let s;for(;(s=Ce.exec(a))!==null;)o.push(s[1]??``);let c=[];we.lastIndex=0;let l;for(;(l=we.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 W(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 G(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 Ae(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?je(n[1].trim(),t):null}return je(n[1].trim(),t)}function je(e,t){if(e.startsWith(`{`))return Me(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 Me(r[1])}return{filterable:[],sortable:[],searchable:[]}}function K(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 Me(e){return{filterable:K(e,`filterable`),sortable:K(e,`sortable`),searchable:K(e,`searchable`)}}async function Ne(e,t){let n=t.extensions??fe,a=t.exclude??I,o=[],s;try{s=await u(e,{withFileTypes:!0,encoding:`utf-8`})}catch{return o}for(let c of s){let s=r(e,c.name),l=i(t.cwd,s);a.some(e=>l.includes(e))||(c.isDirectory()?o.push(...await Ne(s,t)):c.isFile()&&n.some(e=>c.name.endsWith(e))&&o.push(s))}return o}function q(e,t){return i(t,e).split(o).join(`/`)}function Pe(e,t,n){let r=[],i=q(t,n);L.lastIndex=0;let a;for(;(a=L.exec(e))!==null;){let[,e,n,o]=a;r.push({className:o,decorator:e,filePath:t,relativePath:i,isDefault:!!n})}R.lastIndex=0;let o;for(;(o=R.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})}z.lastIndex=0;let s;for(;(s=z.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 Fe(e,t,n){let r=[],i=q(t,n),a=new Set;pe.lastIndex=0;let o;for(;(o=pe.exec(e))!==null;){let[e,n,s]=o;a.add(e),r.push({name:s,variable:n,filePath:t,relativePath:i})}for(me.lastIndex=0;(o=me.exec(e))!==null;)a.has(o[0])||r.push({name:o[1],variable:null,filePath:t,relativePath:i});return r}function Ie(e,t,n,r,i=new Map){let a=[];if(r.length===0)return a;let o=q(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);H.lastIndex=0;let d;for(;(d=H.exec(u))!==null;){let n=d[1],s=d.index,c=H.lastIndex-1,l=U(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=ye(u,l+1);if(!h)continue;let{methodName:ee,endPos:g}=h;H.lastIndex=g;let _=Ae(u.slice(s,g),e),v=W(f,`body`),y=W(f,`query`),b=W(f,`params`),x=W(f,`response`),S=i.get(r.className)??``,C=S?xe(S,m):m;a.push({controller:r.className,method:ee,httpMethod:n.toUpperCase(),path:m,pathParams:be(C),queryFilterable:_?.filterable??null,querySortable:_?.sortable??null,querySearchable:_?.searchable??null,bodySchema:v?{identifier:v,source:G(e,v)}:null,querySchema:y?{identifier:y,source:G(e,y)}:null,paramsSchema:b?{identifier:b,source:G(e,b)}:null,responseSchema:x?{identifier:x,source:G(e,x)}:null,filePath:t,relativePath:o,controllerIsDefaultExport:r.isDefault,mountedPath:C})}}return a}function Le(e,t,n){let r=[],i=q(t,n);he.lastIndex=0;let a;for(;(a=he.exec(e))!==null;)r.push({name:a[1],filePath:t,relativePath:i});return r}function J(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 Re(e,t,n){let r=[],i=q(t,n),a=new Set;B.lastIndex=0;let o;for(;(o=B.exec(e))!==null;){let n=o[1],s=B.lastIndex-1,c=U(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}))}ge.lastIndex=0;let s;for(;(s=ge.exec(e))!==null;){let n=s.index,o=e.indexOf(`{`,n);if(o<0)continue;let c=J(e,o);if(c<0)continue;let l=e.slice(o+1,c),u=_e.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 ze(e,t,n){let r=[],i=q(t,n),a=new Set;V.lastIndex=0;let o;for(;(o=V.exec(e))!==null;){let n=V.lastIndex-1,s=U(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 Be(e,t,n){let r=[],i=q(t,n);ve.lastIndex=0;let a;for(;(a=ve.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=J(e,t);if(n>=0){let r=e.slice(t+1,n);o=Ve(r,`description`),s=Ve(r,`example`)}}}r.push({name:n,description:o,example:s,filePath:t,relativePath:i})}return r}function Ve(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
- `:t===`t`?` `:t===`r`?`\r`:t)}const He=[`src/config/index.ts`,`src/config/env.ts`,`src/config.ts`,`src/env.ts`];async function Ue(e,t){let n=t===`src/env.ts`?He:[t];for(let t of n){let n=a(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:q(n,e)}}return null}function We(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 Ge=new Set([`Controller`,`Service`,`Repository`,`Injectable`,`Component`,`Module`,`Middleware`,`ApiQueryParams`,`Public`,`Roles`,`Cron`,`Cacheable`,`CacheEvict`,`FileUpload`,`Asset`,`Builder`,`PostConstruct`,`PreDestroy`,`Value`,`Inject`,`Autowired`]);function Y(e){return e.split(o).join(`/`).replace(/\.[mc]?[tj]sx?$/,``)}function Ke(e,t,r){let i=Y(r);if(t===``)return i===Y(e);if(t.startsWith(`.`)){let r=Y(a(n(e),t));return i===r||i===`${r}/index`}let o=t.replace(/^[@~#]\//,``);if(o===t&&t.startsWith(`@`))return!1;let s=Y(o);return i===s||i.endsWith(`/${s}`)}function qe(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 Je(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=>Ke(e,t.source,n.filePath));return n.length===1?n[0].key:null};for(let r of e){if(Ge.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 Ye=/\bcontributors\s*(?::|\()/;function Xe(e,t,n){return P(e,t,n)||{...Ze(e,t,n),hasNonDecoratorContributors:Ye.test(e)}}function Ze(e,t,n){let r=Pe(e,t,n);return{classes:r,tokens:Fe(e,t,n),injects:Le(e,t,n),pluginsAndAdapters:Re(e,t,n),routeFlags:[],augmentations:Be(e,t,n),contextKeys:ze(e,t,n),routes:Ie(e,t,n,r,new Map),moduleMounts:ke(e),globPatterns:/\.module\.[mc]?[tj]sx?$/.test(t)?Ee(e):[],hasNonDecoratorContributors:!1}}async function Qe(e,t,n){let r=n?await v.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=Xe(i,e,t);return n&&r&&n.set(e,r,a),a}async function $e(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 X(e){let t=(await Ne(a(e.root),e)).toSorted(),n=e.cacheDir?await v.load(e.cacheDir):null,r=nt(t,await $e(t,16,t=>Qe(t,e.cwd,n))),i=await Ue(e.cwd,e.envFile??`src/env.ts`);return n&&await n.save(),{...r,env:i}}function et(e,t,n){let r=n.extensions??fe,a=n.exclude??I;if(!e.startsWith(t+o)&&e!==t||!r.some(t=>e.endsWith(t)))return!1;let s=i(n.cwd,e);return!a.some(e=>s.includes(e))}async function tt(e,t){if(!e.cacheDir)return X(e);let n=a(e.root),r=await v.load(e.cacheDir),i=r.cachedFiles();if(i.length===0)return X(e);let o=new Set(t.removed.map(t=>a(e.cwd,t))),s=t.changed.map(t=>a(e.cwd,t)).filter(t=>!o.has(t)&&et(t,n,e)),c=new Set(s),u=new Set(i);for(let e of c)u.add(e);for(let e of o)u.delete(e);let d=new Map;await $e(s,16,async t=>{if(!u.has(t))return;let n=await v.signature(t),i;try{i=await l(t,`utf-8`)}catch{u.delete(t);return}let a=Xe(i,t,e.cwd);d.set(t,a),n&&r.set(t,n,a)});let f=[...u].toSorted(),p=nt(f,f.map(e=>d.get(e)||(r.carry(e),r.peek(e)))),m=await Ue(e.cwd,e.envFile??`src/env.ts`);return await r.save(),{...p,env:m}}function nt(e,t){let n=[],r=[],i=[],a=[],s=[],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 o=0;o<e.length;o++){let p=t[o];if(p){n.push(...p.classes),i.push(...p.tokens),a.push(...p.injects),s.push(...p.pluginsAndAdapters),c.push(...p.augmentations),l.push(...p.contextKeys),u.push(...p.routeFlags),p.globPatterns.length>0&&f.set(e[o],p.globPatterns);for(let e of p.routes){let t=d.get(e.controller);if(t){let n=xe(t,e.path);r.push({...e,pathParams:be(n),mountedPath:n})}else r.push({...e,mountedPath:e.mountedPath??e.path})}}}Je(r,l,t.some(e=>e?.hasNonDecoratorContributors===!0),qe(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(o,`/`),i=r.slice(0,r.lastIndexOf(`/`));for(let a of n){if(a.decorator===`Module`)continue;let n=a.filePath.replaceAll(o,`/`);n.startsWith(i+`/`)&&n!==r&&(Oe(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)),s.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=We(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:s,augmentations:c,contextKeys:l,routeFlags:u,orphanedClasses:p}}function rt(e){let t=e.lastIndexOf(`.`);return t<=0?{stem:e,ext:``}:{stem:e.slice(0,t),ext:e.slice(t+1)}}function it(e){let t=e.replaceAll(`\\`,`/`),{stem:n,ext:r}=rt(t.slice(t.lastIndexOf(`/`)+1)),i=r||`ts`,a=n.lastIndexOf(`.`);return a>0?`./**/*.${n.slice(a+1)}.${i}`:`./**/*.${i}`}function at(e){let t=new Set;for(let n of e)t.add(it(n.relativePath));return[...t].toSorted()}function ot(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 st(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 ct(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 lt(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=ot(e,t);i<0||n.push({start:r.index,open:t,close:i})}return n}function ut(e,t){let n=lt(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(Ee(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=st(e,`[`,r.open,r.close);if(c>=0){let t=ct(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 Z="/* 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",Q=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
- `)}function pt(e,t){let r=n(t),a=i(r,e).split(o).join(`/`);return a=a.replace(/\.(ts|tsx|mts|cts)$/i,``),a.startsWith(`.`)||(a=`./`+a),a}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(!Q.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
- `):" // (no services discovered yet — run `kick g service <name>` to add one)";return`${Z}
15
- declare module '@forinda/kickjs' {
16
- interface KickJsRegistry {
17
- ${a}
18
- }
19
- }
20
-
21
- export {}
22
- `}function gt(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)}function _t(e){let t=[...new Set(e.map(e=>e.key))].toSorted().map(e=>` ${gt(e)?e:JSON.stringify(e)}: true`).join(`
23
- `);return`${Z}
24
- declare module '@forinda/kickjs' {
25
- /**
26
- * Key-only registry of every context key produced by a
27
- * \`defineContextDecorator\` / \`defineHttpContextDecorator\` in the
28
- * project. Feeds \`dependsOn\` typo-checking. Value types live in
29
- * \`ContextMeta\`; this only records that the key exists.
30
- */
31
- interface ContextKeys {
32
- ${t}
33
- }
34
- }
35
-
36
- export {}
37
- `}function vt(e,t,n){if(t.length===0)return`${Z}
38
- // ${n}
39
- export type ${e} = never
40
- `;let r=[...new Set(t)].toSorted();return`${Z}
41
- export type ${e} =
42
- ${r.map(e=>` | '${e}'`).join(`
43
- `)}
44
- `}function yt(e,t,n,r){return[...e.filter(e=>Q.has(e.decorator)).map(e=>r.has(e.className)?mt(e):e.className),...t.map(e=>e.name),...n.map(e=>e.name)]}function bt(e){return e.filter(e=>e.decorator===`Module`).map(e=>e.className)}const xt=new Set(`string.number.boolean.bigint.symbol.object.unknown.any.never.void.null.undefined.true.false.Array.ReadonlyArray.Record.Partial.Required.Readonly.Pick.Omit.Date.RegExp.Map.Set.ReadonlyMap.ReadonlySet.Promise.Error.URL.Uint8Array.ArrayBuffer`.split(`.`));function St(e){return(e.replace(/'[^']*'|"[^"]*"|`[^`]*`/g,``).replace(/[A-Za-z_$][A-Za-z0-9_$]*\s*\??\s*:/g,`:`).match(/[A-Za-z_$][A-Za-z0-9_$]*/g)??[]).every(e=>xt.has(e))}const Ct=e=>{let t=e??`true`,n=[];return t.replace(/'[^']*'|"[^"]*"|`[^`]*`/g,e=>(n.push(e),`@@kicklit${n.length-1}@@`)).replace(/\s+/g,``).replace(/@@kicklit(\d+)@@/g,(e,t)=>n[Number(t)])};function wt(e){let t=new Map;for(let n of e){let e=t.get(n.name);if(!e){t.set(n.name,n);continue}if(Ct(e.valueType)!==Ct(n.valueType))throw Error(`Route flag '${n.name}' is declared with two different value types:\n ${e.relativePath}: ${e.valueType??`true`}\n ${n.relativePath}: ${n.valueType??`true`}\nDeclare the flag once and import it, or give the two flags different names.`)}let n=[...t.values()].toSorted((e,t)=>e.name.localeCompare(t.name)).map(e=>{let t=JSON.stringify(e.name);return e.valueType===null?` ${t}: true`:St(e.valueType)?` ${t}: ${e.valueType}`:` // '${e.valueType.replace(/\s+/g,` `).trim()}' is declared in ${e.relativePath}, not in scope here.\n // Inline the type at the defineRouteFlag call, or declare this flag by hand.\n ${t}: unknown`}).join(`
45
- `);return`${Z}
46
- declare module '@forinda/kickjs' {
47
- /**
48
- * Every route flag declared in this project, from its \`defineRouteFlag\`
49
- * call site. A bare flag carries \`true\`; one declared with an explicit
50
- * value type carries that type.
51
- *
52
- * The \`keyof\` narrows every flag name in the codebase — \`skipWhen\`,
53
- * \`onlyWhen\`, \`exemptWhen\`, \`flags.has()\` — so a typo is a compile
54
- * error rather than a flag that silently never matches.
55
- */
56
- interface KickRouteFlags {
57
- ${n||" // (no route flags discovered yet — `defineRouteFlag(...)` calls feed this)"}
58
- }
59
- }
60
-
61
- export {}
62
- `}function Tt(e){let t=new Map;for(let n of e)t.has(n.name)||t.set(n.name,n);let n=[...t.values()].toSorted((e,t)=>e.name.localeCompare(t.name)).map(e=>` '${e.name}': '${e.kind}'`).join(`
63
- `);return`${Z}
64
- declare module '@forinda/kickjs' {
65
- /**
66
- * Map of every plugin/adapter \`name\` discovered in the project. The
67
- * value type is the kind tag (\`'plugin'\` or \`'adapter'\`); the
68
- * \`keyof\` of this interface narrows \`dependsOn\` so misspelled deps
69
- * become compile errors instead of boot-time \`MissingMountDepError\`.
70
- */
71
- interface KickJsPluginRegistry {
72
- ${n||" // (no plugins/adapters discovered yet — `defineAdapter`/`definePlugin` calls feed this)"}
73
- }
74
- }
75
-
76
- export {}
77
- `}function Et(e){if(e.length===0)return`${Z}
78
- // No augmentations discovered.
79
- //
80
- // Plugins advertise augmentable interfaces via:
81
- //
82
- // import { defineAugmentation } from '@forinda/kickjs'
83
- // defineAugmentation('FeatureFlags', {
84
- // description: 'Feature flag shape consumed by FlagsPlugin',
85
- // example: '{ beta: boolean; rolloutPercentage: number }',
86
- // })
87
- //
88
- // See \`docs/guide/typegen.md#augmentations\` for the full pattern.
89
- export {}
90
- `;let t=new Map;for(let n of e)t.has(n.name)||t.set(n.name,n);let n=[];for(let e of[...t.values()].toSorted((e,t)=>e.name.localeCompare(t.name))){let t=[];if(e.description)for(let n of e.description.split(`
91
- `))t.push(` * ${n}`);if(e.example){t.push(` * @example`," * ```ts");for(let n of e.example.split(`
92
- `))t.push(` * ${n}`);t.push(" * ```")}t.push(` * @see ${e.relativePath}`),n.push([`/**`,...t,` */`,`export interface ${e.name}Augmentation {}`].join(`
93
- `))}return`${Z}
94
- // Catalogue of augmentable interfaces in this project. The interfaces
95
- // below are documentation only — augment the source-of-truth interfaces
96
- // in your own \`d.ts\` files (the framework declares the actual types).
97
-
98
- ${n.join(`
99
-
100
- `)}
101
- `}const Dt=/^(kick\/)?([a-z][\w-]*\/[A-Z]\w*)(\/.+)?(:[a-z][\w-]+(:[a-z][\w-]+)*)?$/;function Ot(e){let t=[];for(let n of e){let e=n.name;e.startsWith(`kickjs.`)||Dt.test(e)||t.push({token:e,variable:n.variable,filePath:n.relativePath,reason:"does not match `<scope>/<PascalKey>[/<suffix>][:<instance>]`",suggestion:kt(e)})}return t}function kt(e){if(/^[A-Z]\w*$/.test(e))return`'<scope>/${e}' (e.g. 'mycorp/${e}')`;if(e.includes(`.`))return`consider '<scope>/PascalKey' instead of dotted form`;let t=/^([a-z][\w-]*)\/([a-z]\w*)$/.exec(e);if(t){let[,e,n]=t;return`'${e}/${n.charAt(0).toUpperCase()}${n.slice(1)}'`}}function At(e,t){if(!e)return{entries:[],count:0};let n=new Map;for(let[r,i]of Object.entries(e)){if(!i||typeof i.src!=`string`)continue;let e=a(t,i.src);if(!Ft(e))continue;let o=m(i.glob??`**/*`,{cwd:e,nodir:!0,dot:!1,posix:!0});o.sort();let{pairs:s}=h(r,o,{strategy:i.keys??`auto`});for(let{key:e}of s){let t=e.slice(r.length+1);n.set(e,{namespace:r,key:t})}}return{entries:[...n.values()],count:n.size}}function jt(e){let t="/* 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";if(e.entries.length===0)return`${t}
102
- declare module '@forinda/kickjs' {
103
- /**
104
- * Map of every typed asset discovered in the project's assetMap.
105
- * (No assetMap entries discovered yet — declare with
106
- * \`assetMap: { name: { src: 'src/...' } }\` in kick.config.ts.)
107
- */
108
- interface KickAssets {}
109
- }
110
-
111
- export {}
112
- `;let n={};for(let t of e.entries){let e=`${t.namespace}/${t.key}`.split(`/`),r=n;for(let t=0;t<e.length-1;t++){let n=e[t],i=r[n];if(i===Mt){let e={};r[n]=e,r=e}else i||(r[n]={}),r=r[n]}let i=e[e.length-1];typeof r[i]!=`object`&&(r[i]=Mt)}return`${t}
113
- declare module '@forinda/kickjs' {
114
- /**
115
- * Map of every typed asset discovered in the project's assetMap.
116
- * Each leaf is a \`() => string\` thunk that returns the resolved
117
- * absolute path for the file in the current run mode (dev → src,
118
- * prod → dist).
119
- */
120
- interface KickAssets {
121
- ${Nt(n,` `)}
122
- }
123
- }
124
-
125
- export {}
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 s(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:a(t,e.srcDir??`src`),outDir:a(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:o,envFile:s}=Lt(e),c=Date.now(),l={root:n,cwd:t,cacheDir:e.noCache?void 0:a(t,`.kickjs`,`cache`),envFile:s===!1?void 0:s},u=e.changedFiles?await tt(l,e.changedFiles):await X(l);if(u.collisions.length>0&&!o)throw new dt(u.collisions);let d=At(e.assetMap,t),f=[],p=[];if(e.runPlugins!==!1){try{let{runAllPluginTypegens:n}=await import(`./run-plugins-ByRyAAZe.mjs`).then(e=>e.n),{loadKickConfig:r}=await import(`./config-BUYf44lU.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),ee=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} (${ee}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=at(a);try{let a=await l(i,`utf-8`),o=ut(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}: ${at(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=at(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=>Q.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,i){await c(e,{recursive:!0}),await p(r(n(e),`.gitignore`),`# Auto-generated by kick typegen
128
- *
129
- `,`utf-8`);let a=t.filter(e=>e.outFile).map(e=>e.outFile);return await Ht(e,a,t,i),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(`./run-plugins-ByRyAAZe.mjs`).then(e=>e.n),import(`./config-BUYf44lU.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
- `+e.message+`
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,n,r,i){let o=new Set;for(let e of n)o.add(t(e));for(let e of r)e.outFile&&o.add(t(e.outFile));let s;try{s=await u(e)}catch{return[]}let c=[];for(let t of s){if(!Ut.has(t)||o.has(t))continue;let n=a(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{S as C,T as S,C as T,tt as _,At as a,O as b,bt as c,_t as d,Tt as f,X 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,j as v,w,D as x,A as y};
132
- //# sourceMappingURL=typegen-Bx2IQ-w5.mjs.map