@forinda/kickjs-cli 5.4.7 → 5.5.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.
- package/dist/{builtins-DI-a8PeJ.mjs → builtins-5aWa9xTa.mjs} +4 -4
- package/dist/{builtins-BIiKePdP.mjs → builtins-BpWIctor.mjs} +4 -4
- package/dist/{builtins-BIiKePdP.mjs.map → builtins-BpWIctor.mjs.map} +1 -1
- package/dist/cli.mjs +2 -2
- package/dist/{config-D86MJ8hU.mjs → config-BSo8gLtM.mjs} +3 -3
- package/dist/{config-D86MJ8hU.mjs.map → config-BSo8gLtM.mjs.map} +1 -1
- package/dist/{config-C2Uwu0Kn.mjs → config-BefQBc0L.mjs} +2 -2
- package/dist/{generator-extension-DSIVI-lg.mjs → generator-extension-CEYm6tuj.mjs} +3 -3
- package/dist/{generator-extension-DSIVI-lg.mjs.map → generator-extension-CEYm6tuj.mjs.map} +1 -1
- package/dist/index.d.mts +25 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/{plugin-U6UJv-8Z.mjs → plugin-By4fjCki.mjs} +2 -2
- package/dist/{plugin-DdpKMy8M.mjs → plugin-CVRofuDz.mjs} +3 -3
- package/dist/{plugin-DdpKMy8M.mjs.map → plugin-CVRofuDz.mjs.map} +1 -1
- package/dist/{rolldown-runtime-DLdkstHq.mjs → rolldown-runtime-BrsfUx5e.mjs} +1 -1
- package/dist/{run-plugins-D1Qi28Th.mjs → run-plugins-GOyvsWi5.mjs} +2 -2
- package/dist/typegen-CZMLNEJQ.mjs +116 -0
- package/dist/typegen-DyXcnNCk.mjs +117 -0
- package/dist/typegen-DyXcnNCk.mjs.map +1 -0
- package/dist/{types-CJysTJO3.mjs → types-CYw_hoZY.mjs} +2 -2
- package/dist/{types-CJysTJO3.mjs.map → types-CYw_hoZY.mjs.map} +1 -1
- package/package.json +3 -3
- package/dist/typegen-BL07Yyj4.mjs +0 -117
- package/dist/typegen-BL07Yyj4.mjs.map +0 -1
- package/dist/typegen-DyhkvERd.mjs +0 -116
package/dist/index.d.mts
CHANGED
|
@@ -167,6 +167,25 @@ interface DiscoveredAugmentation {
|
|
|
167
167
|
/** Path relative to scan root, with forward slashes */
|
|
168
168
|
relativePath: string;
|
|
169
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* A decorated class whose file sits inside a module directory but
|
|
172
|
+
* isn't picked up by any of the module's `import.meta.glob(...)`
|
|
173
|
+
* patterns. Surfaced as a typegen warning per forinda/kick-js#235 §4
|
|
174
|
+
* so adopters notice silent registration drift before it bites them
|
|
175
|
+
* at runtime with a `MissingContributorError` or wrong code path.
|
|
176
|
+
*/
|
|
177
|
+
interface OrphanedClass {
|
|
178
|
+
/** The decorated class name */
|
|
179
|
+
className: string;
|
|
180
|
+
/** Absolute path of the class file */
|
|
181
|
+
filePath: string;
|
|
182
|
+
/** Path relative to scan root, with forward slashes */
|
|
183
|
+
relativePath: string;
|
|
184
|
+
/** Absolute path of the module file whose globs didn't match */
|
|
185
|
+
moduleFilePath: string;
|
|
186
|
+
/** The decorator name (`Service`, `Controller`, `Repository`, …) */
|
|
187
|
+
decorator: DecoratorName;
|
|
188
|
+
}
|
|
170
189
|
/** Aggregated scanner output */
|
|
171
190
|
interface ScanResult {
|
|
172
191
|
classes: DiscoveredClass[];
|
|
@@ -180,6 +199,12 @@ interface ScanResult {
|
|
|
180
199
|
pluginsAndAdapters: DiscoveredPluginOrAdapter[];
|
|
181
200
|
/** Augmentation interfaces declared via `defineAugmentation('Name', meta)` */
|
|
182
201
|
augmentations: DiscoveredAugmentation[];
|
|
202
|
+
/**
|
|
203
|
+
* Decorated classes that sit inside a module directory but aren't
|
|
204
|
+
* picked up by any of the module's `import.meta.glob(...)` patterns.
|
|
205
|
+
* Empty when every decorator file is matched. forinda/kick-js#235 §4.
|
|
206
|
+
*/
|
|
207
|
+
orphanedClasses: OrphanedClass[];
|
|
183
208
|
}
|
|
184
209
|
/** Options for the scanner */
|
|
185
210
|
interface ScanOptions {
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/typegen/scanner.ts","../src/typegen/plugin.ts","../src/generator-extension/define.ts","../src/plugin/types.ts","../src/config.ts","../src/generators/templates/types.ts","../src/generators/module.ts","../src/generators/adapter.ts","../src/generators/middleware.ts","../src/generators/guard.ts","../src/generators/service.ts","../src/generators/controller.ts","../src/generators/dto.ts","../src/generators/project.ts","../src/generator-extension/discover.ts","../src/generator-extension/context.ts","../src/utils/naming.ts"],"mappings":";;;;;;;AAgCA;;;;;AASA;;;;;AAGA;;;;;;;;;;;;AAcA;;cA1Ba,eAAA;AAAA,KASD,aAAA,WAAwB,eAAA;;UAGnB,eAAA;EA2CQ;EAzCvB,SAAA;EAcA;EAZA,SAAA,EAAW,aAAA;EAgBX;EAdA,QAAA;EAkBA;EAhBA,YAAA;EAyBA;EAvBA,SAAA;AAAA;;UAIe,eAAA;EA4BF;EA1Bb,UAAA;EA2Bc;EAzBd,MAAA;EA6BA;EA3BA,UAAA;EA2BY;EAzBZ,IAAA;EA6BwB;EA3BxB,UAAA;EA6BA;;AAUF;;;;;EA/BE,eAAA;EACA,aAAA;EACA,eAAA;EAqCY;;AAId;;;;EAlCE,UAAA,EAAY,SAAA;EACZ,WAAA,EAAa,SAAA;EACb,YAAA,EAAc,SAAA;EAsCF;EApCZ,QAAA;EAwCe;EAtCf,YAAA;AAAA;;UAIe,SAAA;EAsCf;EApCA,UAAA;EAoCwB;;AAU1B;;;EAxCE,MAAA;AAAA;AAwDF;AAAA,UApDiB,eAAA;;EAEf,IAAA;EAoDA;EAlDA,QAAA;EAsDA;EApDA,QAAA;EAsDY;EApDZ,YAAA;AAAA;;UAIe,gBAAA;EAwDsB;EAtDrC,IAAA;EA0DA;EAxDA,QAAA;EA4DA;EA1DA,YAAA;AAAA;;UAIe,cAAA;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/typegen/scanner.ts","../src/typegen/plugin.ts","../src/generator-extension/define.ts","../src/plugin/types.ts","../src/config.ts","../src/generators/templates/types.ts","../src/generators/module.ts","../src/generators/adapter.ts","../src/generators/middleware.ts","../src/generators/guard.ts","../src/generators/service.ts","../src/generators/controller.ts","../src/generators/dto.ts","../src/generators/project.ts","../src/generator-extension/discover.ts","../src/generator-extension/context.ts","../src/utils/naming.ts"],"mappings":";;;;;;;AAgCA;;;;;AASA;;;;;AAGA;;;;;;;;;;;;AAcA;;cA1Ba,eAAA;AAAA,KASD,aAAA,WAAwB,eAAA;;UAGnB,eAAA;EA2CQ;EAzCvB,SAAA;EAcA;EAZA,SAAA,EAAW,aAAA;EAgBX;EAdA,QAAA;EAkBA;EAhBA,YAAA;EAyBA;EAvBA,SAAA;AAAA;;UAIe,eAAA;EA4BF;EA1Bb,UAAA;EA2Bc;EAzBd,MAAA;EA6BA;EA3BA,UAAA;EA2BY;EAzBZ,IAAA;EA6BwB;EA3BxB,UAAA;EA6BA;;AAUF;;;;;EA/BE,eAAA;EACA,aAAA;EACA,eAAA;EAqCY;;AAId;;;;EAlCE,UAAA,EAAY,SAAA;EACZ,WAAA,EAAa,SAAA;EACb,YAAA,EAAc,SAAA;EAsCF;EApCZ,QAAA;EAwCe;EAtCf,YAAA;AAAA;;UAIe,SAAA;EAsCf;EApCA,UAAA;EAoCwB;;AAU1B;;;EAxCE,MAAA;AAAA;AAwDF;AAAA,UApDiB,eAAA;;EAEf,IAAA;EAoDA;EAlDA,QAAA;EAsDA;EApDA,QAAA;EAsDY;EApDZ,YAAA;AAAA;;UAIe,gBAAA;EAwDsB;EAtDrC,IAAA;EA0DA;EAxDA,QAAA;EA4DA;EA1DA,YAAA;AAAA;;UAIe,cAAA;EAkEa;EAhE5B,SAAA;EA0EwB;EAxExB,OAAA,EAAS,eAAA;AAAA;;;;;;;AA4EX;UAlEiB,aAAA;;EAEf,QAAA;EAkEQ;EAhER,YAAA;AAAA;;;;;;;;;;U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EACf,UAAA,EAAY,mBAAA;EduBZ;EcrBA,MAAA;EduBW;;;;EclBX,MAAA,EAAQ,KAAA;IAAQ,MAAA;IAAgB,MAAA;EAAA;AAAA;;;;;AdElC;;;;iBehBgB,qBAAA,CAAsB,KAAA;EACpC,IAAA;EACA,IAAA;EACA,KAAA,GAAQ,MAAA;EACR,UAAA;EACA,GAAA;EACA,SAAA;AAAA,IACE,gBAAA;;;;iBCpBY,YAAA,CAAa,IAAA;;iBAOb,WAAA,CAAY,IAAA;;iBAMZ,WAAA,CAAY,IAAA;;;AhByB5B;;;iBgBbgB,SAAA,CAAU,IAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-cli v5.
|
|
2
|
+
* @forinda/kickjs-cli v5.5.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import{C as e,S as t,_ as n,a as r,b as i,d as a,f as o,i as s,l as c,m as l,p as u,r as d,u as f,w as p}from"./generator-extension-
|
|
11
|
+
import{C as e,S as t,_ as n,a as r,b as i,d as a,f as o,i as s,l as c,m as l,p as u,r as d,u as f,w as p}from"./generator-extension-CEYm6tuj.mjs";import{i as m,r as h}from"./config-BSo8gLtM.mjs";import{n as g,t as _}from"./types-CYw_hoZY.mjs";export{_ as KickPluginConflictError,d as buildGeneratorContext,g as defineCliPlugin,h as defineConfig,s as defineGenerator,l as generateAdapter,f as generateController,c as generateDto,o as generateGuard,u as generateMiddleware,n as generateModule,a as generateService,r as initProject,m as loadKickConfig,i as pluralize,t as toCamelCase,e as toKebabCase,p as toPascalCase};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-cli v5.
|
|
2
|
+
* @forinda/kickjs-cli v5.5.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import{t as e}from"./rolldown-runtime-
|
|
11
|
+
import{t as e}from"./rolldown-runtime-BrsfUx5e.mjs";function t(e){return e}var n=class extends Error{constructor(e,t,n){super(`Two plugins registered the same ${e} '${t}': ${n.join(`, `)}. Plugins must use unique ${e} names.`),this.name=`KickPluginConflictError`}};function r(e,t=[]){let r=new Map;for(let t of e){let e=(r.get(t.name)??0)+1;if(r.set(t.name,e),e===2)throw new n(`plugin`,t.name,[t.name,t.name])}let i=new Map,a=[];for(let t of e)for(let e of t.commands??[]){let r=i.get(e.name);if(r)throw new n(`command`,e.name,[r,t.name]);i.set(e.name,t.name),a.push(e)}let o=new Set(t.map(e=>e.name)),s=[...a.filter(e=>!o.has(e.name)),...t],c=new Map,l=[];for(let t of e)for(let e of t.typegens??[]){let r=c.get(e.id);if(r)throw new n(`typegen`,e.id,[r,t.name]);c.set(e.id,t.name),l.push(e)}let u=new Map,d=[];for(let t of e)for(let e of t.generators??[]){let r=u.get(e.name);if(r)throw new n(`generator`,e.name,[r,t.name]);u.set(e.name,t.name),d.push({source:t.name,spec:e})}return{commands:s,typegens:l,generators:d,register:async(t,n)=>{let r=n??{cwd:process.cwd(),config:null,log:()=>{}};for(let n of e)n.register&&await n.register(t,r)}}}var i=e({mergeCliPlugins:()=>r});export{r as n,t as r,i as t};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-cli v5.
|
|
2
|
+
* @forinda/kickjs-cli v5.5.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import{t as e}from"./rolldown-runtime-
|
|
12
|
-
//# sourceMappingURL=plugin-
|
|
11
|
+
import{t as e}from"./rolldown-runtime-BrsfUx5e.mjs";import{t}from"./types-CYw_hoZY.mjs";function n(e,n=[]){let r=new Map;for(let n of e){let e=(r.get(n.name)??0)+1;if(r.set(n.name,e),e===2)throw new t(`plugin`,n.name,[n.name,n.name])}let i=new Map,a=[];for(let n of e)for(let e of n.commands??[]){let r=i.get(e.name);if(r)throw new t(`command`,e.name,[r,n.name]);i.set(e.name,n.name),a.push(e)}let o=new Set(n.map(e=>e.name)),s=[...a.filter(e=>!o.has(e.name)),...n],c=new Map,l=[];for(let n of e)for(let e of n.typegens??[]){let r=c.get(e.id);if(r)throw new t(`typegen`,e.id,[r,n.name]);c.set(e.id,n.name),l.push(e)}let u=new Map,d=[];for(let n of e)for(let e of n.generators??[]){let r=u.get(e.name);if(r)throw new t(`generator`,e.name,[r,n.name]);u.set(e.name,n.name),d.push({source:n.name,spec:e})}return{commands:s,typegens:l,generators:d,register:async(t,n)=>{let r=n??{cwd:process.cwd(),config:null,log:()=>{}};for(let n of e)n.register&&await n.register(t,r)}}}var r=e({mergeCliPlugins:()=>n});export{n,r as t};
|
|
12
|
+
//# sourceMappingURL=plugin-CVRofuDz.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-
|
|
1
|
+
{"version":3,"file":"plugin-CVRofuDz.mjs","names":[],"sources":["../src/plugin/merge.ts","../src/plugin/index.ts"],"sourcesContent":["// Plugin → unified registry merge.\n//\n// Resolution rules (per the v1 spec + dogfood pivot):\n// - duplicate plugin `name` across the input array → conflict error.\n// Catches the double-install case (built-in shipped twice, or\n// adopter requiring the same plugin twice).\n// - plugin commands appear first in the merged list, then adopter\n// commands; adopter `commands` of the same name override the\n// plugin entry (filter pass).\n// - duplicate command name across two plugins → conflict error\n// listing both plugin names. Adopter overriding a plugin is\n// allowed and not an error.\n// - duplicate typegen id across two plugins → same error. Typegens\n// have no adopter override path; only plugins contribute them.\n// - register() functions are collected in input order; the caller\n// invokes each one against the same Command program. They have no\n// id-level conflict surface — owners are responsible for picking\n// non-colliding command names inside their own register().\n// - plugin order = array order. No implicit precedence rules.\n\nimport type { Command } from 'commander'\n\nimport type { KickCommandDefinition } from '../config'\nimport type { TypegenPlugin } from '../typegen/plugin'\nimport type { GeneratorSpec } from '../generator-extension/define'\nimport type { DiscoveredGenerator } from '../generator-extension/discover'\nimport { KickPluginConflictError, type KickCliPlugin, type KickCliPluginContext } from './types'\n\nexport interface MergedPlugins {\n commands: KickCommandDefinition[]\n typegens: TypegenPlugin[]\n /** DiscoveredGenerator shape so this list slots into the existing\n * dispatch path next to package.json-discovered entries. `source`\n * carries the plugin name for error attribution. */\n generators: DiscoveredGenerator[]\n /**\n * Apply every plugin's register() in input order. ctx is optional so\n * tests + lightweight callers can invoke `register(program)` without\n * constructing a full context; it falls back to cwd=process.cwd(),\n * config=null, log=no-op.\n */\n register: (program: Command, ctx?: KickCliPluginContext) => Promise<void>\n}\n\nexport function mergeCliPlugins(\n plugins: readonly KickCliPlugin[],\n adopterCommands: readonly KickCommandDefinition[] = [],\n): MergedPlugins {\n // Plugin-name dedup — catches double-install.\n const seenPluginNames = new Map<string, number>()\n for (const p of plugins) {\n const count = (seenPluginNames.get(p.name) ?? 0) + 1\n seenPluginNames.set(p.name, count)\n if (count === 2) {\n throw new KickPluginConflictError('plugin', p.name, [p.name, p.name])\n }\n }\n\n const commandOwners = new Map<string, string>()\n const pluginCommands: KickCommandDefinition[] = []\n for (const p of plugins) {\n for (const cmd of p.commands ?? []) {\n const prior = commandOwners.get(cmd.name)\n if (prior) {\n throw new KickPluginConflictError('command', cmd.name, [prior, p.name])\n }\n commandOwners.set(cmd.name, p.name)\n pluginCommands.push(cmd)\n }\n }\n\n const adopterNames = new Set(adopterCommands.map((c) => c.name))\n const filteredPlugin = pluginCommands.filter((c) => !adopterNames.has(c.name))\n const commands = [...filteredPlugin, ...adopterCommands]\n\n const typegenOwners = new Map<string, string>()\n const typegens: TypegenPlugin[] = []\n for (const p of plugins) {\n for (const tg of p.typegens ?? []) {\n const prior = typegenOwners.get(tg.id)\n if (prior) {\n throw new KickPluginConflictError('typegen', tg.id, [prior, p.name])\n }\n typegenOwners.set(tg.id, p.name)\n typegens.push(tg)\n }\n }\n\n const generatorOwners = new Map<string, string>()\n const generators: DiscoveredGenerator[] = []\n for (const p of plugins) {\n for (const spec of p.generators ?? []) {\n const prior = generatorOwners.get(spec.name)\n if (prior) {\n throw new KickPluginConflictError('generator', spec.name, [prior, p.name])\n }\n generatorOwners.set(spec.name, p.name)\n generators.push({ source: p.name, spec: spec satisfies GeneratorSpec })\n }\n }\n\n const register = async (program: Command, ctx?: KickCliPluginContext): Promise<void> => {\n const resolved: KickCliPluginContext = ctx ?? {\n cwd: process.cwd(),\n config: null,\n log: () => {},\n }\n for (const p of plugins) {\n if (p.register) await p.register(program, resolved)\n }\n }\n\n return { commands, typegens, generators, register }\n}\n","// Barrel intentionally omits `./builtins` — that module top-level-imports\n// every register*Command, which pulls heavy modules (project scaffolders,\n// fs reads at import time) into the graph. Importers that need the\n// builtin list go through `./plugin/builtins` directly; tests + adopter\n// plugins consuming only the contract types import from here.\n\nexport type { KickCliPlugin } from './types'\nexport { defineCliPlugin, KickPluginConflictError } from './types'\nexport { mergeCliPlugins, type MergedPlugins } from './merge'\n"],"mappings":";;;;;;;;;;wFA4CA,SAAgB,EACd,EACA,EAAoD,EAAE,CACvC,CAEf,IAAM,EAAkB,IAAI,IAC5B,IAAK,IAAM,KAAK,EAAS,CACvB,IAAM,GAAS,EAAgB,IAAI,EAAE,KAAK,EAAI,GAAK,EAEnD,GADA,EAAgB,IAAI,EAAE,KAAM,EAAM,CAC9B,IAAU,EACZ,MAAM,IAAI,EAAwB,SAAU,EAAE,KAAM,CAAC,EAAE,KAAM,EAAE,KAAK,CAAC,CAIzE,IAAM,EAAgB,IAAI,IACpB,EAA0C,EAAE,CAClD,IAAK,IAAM,KAAK,EACd,IAAK,IAAM,KAAO,E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,SAAS,EAAS,EAAS,EAIJ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-cli v5.
|
|
2
|
+
* @forinda/kickjs-cli v5.5.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import{n as e,t}from"./builtins-
|
|
11
|
+
import{n as e,t}from"./builtins-BpWIctor.mjs";export{e as applyDisableFilter,t as runAllPluginTypegens};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @forinda/kickjs-cli v5.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-BrsfUx5e.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{globSync as m}from"glob";import{groupAssetKeys as h}from"@forinda/kickjs";const g=[`Service`,`Controller`,`Repository`,`Injectable`,`Component`,`Module`],_=[`.ts`,`.tsx`,`.mts`,`.cts`],v=[`node_modules`,`.kickjs`,`dist`,`build`,`.test.`,`.spec.`,`.d.ts`],y=new RegExp(String.raw`@(${g.join(`|`)})\s*\([^)]*\)`+String.raw`(?:\s*@[A-Z]\w*(?:\s*\([^)]*\))?)*`+String.raw`\s*export\s+(default\s+)?(?:abstract\s+)?class\s+(\w+)`,`g`),b=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`),x=/(?:export\s+)?const\s+(\w+)\s*(?::\s*[^=]+)?=\s*createToken\s*(?:<[^>]*>)?\s*\(\s*['"`]([^'"`]+)['"`]\s*\)/g,S=/createToken\s*(?:<[^>]*>)?\s*\(\s*['"`]([^'"`]+)['"`]\s*\)/g,C=/@Inject\s*\(\s*['"`]([^'"`]+)['"`]\s*\)/g,w=/\b(defineAdapter|definePlugin)\s*(?:<[^>]*>)?\s*\(/g,T=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`),ee=/\bname\s*(?::\s*[^=]+)?=\s*['"`]([^'"`]+)['"`]/,E=/\bdefineAugmentation\s*\(\s*['"`]([^'"`]+)['"`]\s*(,\s*\{)?/g,D=new RegExp(String.raw`@(${[`Get`,`Post`,`Put`,`Delete`,`Patch`].join(`|`)})\s*\(`,`g`);function O(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 te(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=O(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 ne(e){return(e.match(/:([a-zA-Z_]\w*)/g)??[]).map(e=>e.slice(1))}function k(e,t){let n=e.endsWith(`/`)?e.slice(0,-1):e;return!t||t===`/`?n||`/`:n+(t.startsWith(`/`)?t:`/`+t)||`/`}const A=/\b(?:public\s+|private\s+|protected\s+)?routes\s*\([^)]*\)\s*(?::\s*[A-Za-z_][\w<>[\]\s,|]*\s*)?\{/g,j=/\bpath\s*:\s*['"`]([^'"`]*)['"`]/g,M=/\bcontroller\s*:\s*([A-Z]\w*)\b/g,N=/\bimport\.meta\.glob\s*\(/g;function P(e){let t=[];for(N.lastIndex=0;N.exec(e)!==null;){let n=N.lastIndex-1,r=O(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 re(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 ie(e,t){let n=e.startsWith(`./`)?e:`./`+e,r=!1;for(let e of t){let t=e.startsWith(`!`);re(t?e.slice(1):e).test(n)&&(r=!t)}return r}function ae(e){let t=[];A.lastIndex=0;let n;for(;(n=A.exec(e))!==null;){let r=e.indexOf(`{`,n.index+n[0].length-1);if(r<0)continue;let i=H(e,r);if(i<0)continue;let a=e.slice(r+1,i),o=[];j.lastIndex=0;let s;for(;(s=j.exec(a))!==null;)o.push(s[1]??``);let c=[];M.lastIndex=0;let l;for(;(l=M.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 F(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 I(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 oe(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?L(n[1].trim(),t):null}return L(n[1].trim(),t)}function L(e,t){if(e.startsWith(`{`))return z(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 z(r[1])}return{filterable:[],sortable:[],searchable:[]}}function R(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 z(e){return{filterable:R(e,`filterable`),sortable:R(e,`sortable`),searchable:R(e,`searchable`)}}async function B(e,t){let n=t.extensions??_,r=t.exclude??v,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 B(s,t)):c.isFile()&&n.some(e=>c.name.endsWith(e))&&o.push(s))}return o}function V(e,t){return a(t,e).split(s).join(`/`)}function se(e,t,n){let r=[],i=V(t,n);y.lastIndex=0;let a;for(;(a=y.exec(e))!==null;){let[,e,n,o]=a;r.push({className:o,decorator:e,filePath:t,relativePath:i,isDefault:!!n})}b.lastIndex=0;let o;for(;(o=b.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})}return r}function ce(e,t,n){let r=[],i=V(t,n),a=new Set;x.lastIndex=0;let o;for(;(o=x.exec(e))!==null;){let[e,n,s]=o;a.add(e),r.push({name:s,variable:n,filePath:t,relativePath:i})}for(S.lastIndex=0;(o=S.exec(e))!==null;)a.has(o[0])||r.push({name:o[1],variable:null,filePath:t,relativePath:i});return r}function le(e,t,n,r,i=new Map){let a=[];if(r.length===0)return a;let o=V(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);D.lastIndex=0;let d;for(;(d=D.exec(u))!==null;){let n=d[1],s=d.index,c=D.lastIndex-1,l=O(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=te(u,l+1);if(!h)continue;let{methodName:g,endPos:_}=h;D.lastIndex=_;let v=oe(u.slice(s,_),e),y=F(f,`body`),b=F(f,`query`),x=F(f,`params`),S=i.get(r.className)??``,C=S?k(S,m):m;a.push({controller:r.className,method:g,httpMethod:n.toUpperCase(),path:m,pathParams:ne(C),queryFilterable:v?.filterable??null,querySortable:v?.sortable??null,querySearchable:v?.searchable??null,bodySchema:y?{identifier:y,source:I(e,y)}:null,querySchema:b?{identifier:b,source:I(e,b)}:null,paramsSchema:x?{identifier:x,source:I(e,x)}:null,filePath:t,relativePath:o})}}return a}function ue(e,t,n){let r=[],i=V(t,n);C.lastIndex=0;let a;for(;(a=C.exec(e))!==null;)r.push({name:a[1],filePath:t,relativePath:i});return r}function H(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 de(e,t,n){let r=[],i=V(t,n),a=new Set;w.lastIndex=0;let o;for(;(o=w.exec(e))!==null;){let n=o[1],s=w.lastIndex-1,c=O(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}))}T.lastIndex=0;let s;for(;(s=T.exec(e))!==null;){let n=s.index,o=e.indexOf(`{`,n);if(o<0)continue;let c=H(e,o);if(c<0)continue;let l=e.slice(o+1,c),u=ee.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 fe(e,t,n){let r=[],i=V(t,n);E.lastIndex=0;let a;for(;(a=E.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=H(e,t);if(n>=0){let r=e.slice(t+1,n);o=U(r,`description`),s=U(r,`example`)}}}r.push({name:n,description:o,example:s,filePath:t,relativePath:i})}return r}function U(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 pe=[`src/config/index.ts`,`src/config/env.ts`,`src/config.ts`,`src/env.ts`];async function me(e,t){let n=t===`src/env.ts`?pe:[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)&&/export\s+default\b/.test(r))return{filePath:n,relativePath:V(n,e)}}return null}function he(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}async function W(e){let t=await B(o(e.root),e),n=[],r=[],i=[],a=[],c=[],u=[],d=new Map;for(let r of t){let t;try{t=await l(r,`utf-8`)}catch{continue}d.set(r,t),n.push(...se(t,r,e.cwd)),i.push(...ce(t,r,e.cwd)),a.push(...ue(t,r,e.cwd)),c.push(...de(t,r,e.cwd)),u.push(...fe(t,r,e.cwd))}let f=new Map;for(let[,e]of d)for(let{controller:t,mountPath:n}of ae(e))f.has(t)||f.set(t,n);for(let[t,i]of d){let a=n.filter(e=>e.filePath===t);r.push(...le(i,t,e.cwd,a,f))}let p=[];for(let[e,t]of d){if(!/\.module\.[mc]?[tj]sx?$/.test(e))continue;let r=P(t);if(r.length===0)continue;let i=e.replaceAll(s,`/`),a=i.slice(0,i.lastIndexOf(`/`));for(let t of n){if(t.decorator===`Module`)continue;let n=t.filePath.replaceAll(s,`/`);n.startsWith(a+`/`)&&n!==i&&(ie(n.slice(a.length+1),r)||p.push({className:t.className,filePath:t.filePath,relativePath:t.relativePath,moduleFilePath:e,decorator:t.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)),c.sort((e,t)=>e.name.localeCompare(t.name)||e.relativePath.localeCompare(t.relativePath)),u.sort((e,t)=>e.name.localeCompare(t.name)||e.relativePath.localeCompare(t.relativePath));let m=he(n),h=await me(e.cwd,e.envFile??`src/env.ts`);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,env:h,pluginsAndAdapters:c,augmentations:u,orphanedClasses:p}}const G="/* 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",K=new Set([`Service`,`Repository`,`Injectable`,`Component`]);var q=class extends Error{collisions;constructor(e){super(ge(e)),this.name=`TokenCollisionError`,this.collisions=e}};function ge(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 _e(e,t){let n=a(r(t),e).split(s).join(`/`);return n=n.replace(/\.(ts|tsx|mts|cts)$/i,``),n.startsWith(`.`)||(n=`./`+n),n}function J(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 ve(e,t,n){let r=new Set,i=[];for(let a of e){if(!K.has(a.decorator))continue;let e=n.has(a.className)?J(a):a.className;if(r.has(e))continue;r.add(e);let o=_e(a.filePath,t),s=a.isDefault?`import('${o}').default`:`import('${o}').${a.className}`;i.push(` '${e}': ${s}`)}return`${G}
|
|
14
|
+
declare module '@forinda/kickjs' {
|
|
15
|
+
interface KickJsRegistry {
|
|
16
|
+
${i.length?i.join(`
|
|
17
|
+
`):" // (no services discovered yet — run `kick g service <name>` to add one)"}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export {}
|
|
22
|
+
`}function Y(e,t,n){return t.length===0?`${G}
|
|
23
|
+
// ${n}
|
|
24
|
+
export type ${e} = never
|
|
25
|
+
`:`${G}
|
|
26
|
+
export type ${e} =
|
|
27
|
+
${[...new Set(t)].toSorted().map(e=>` | '${e}'`).join(`
|
|
28
|
+
`)}
|
|
29
|
+
`}function ye(e,t){return`${G}
|
|
30
|
+
export type { ServiceToken } from './services'
|
|
31
|
+
export type { ModuleToken } from './modules'
|
|
32
|
+
|
|
33
|
+
// The registry, routes, plugins, assets, and env augmentations are
|
|
34
|
+
// loaded as side-effects — importing this file (or having it on
|
|
35
|
+
// tsconfig include) is enough for \`container.resolve()\`,
|
|
36
|
+
// \`Ctx<KickRoutes.UserController['getUser']>\`,
|
|
37
|
+
// \`dependsOn: ['TenantAdapter']\`, \`assets.mails.welcome()\`, and
|
|
38
|
+
// \`@Value('PORT')\` to resolve.
|
|
39
|
+
import './registry'
|
|
40
|
+
import './kick__routes'
|
|
41
|
+
import './plugins'
|
|
42
|
+
import './augmentations'
|
|
43
|
+
${t?`import './kick__assets'
|
|
44
|
+
`:``}${e?`import './kick__env'
|
|
45
|
+
`:``}`}function be(e){let t=new Map;for(let n of e)t.has(n.name)||t.set(n.name,n);return`${G}
|
|
46
|
+
declare module '@forinda/kickjs' {
|
|
47
|
+
/**
|
|
48
|
+
* Map of every plugin/adapter \`name\` discovered in the project. The
|
|
49
|
+
* value type is the kind tag (\`'plugin'\` or \`'adapter'\`); the
|
|
50
|
+
* \`keyof\` of this interface narrows \`dependsOn\` so misspelled deps
|
|
51
|
+
* become compile errors instead of boot-time \`MissingMountDepError\`.
|
|
52
|
+
*/
|
|
53
|
+
interface KickJsPluginRegistry {
|
|
54
|
+
${[...t.values()].toSorted((e,t)=>e.name.localeCompare(t.name)).map(e=>` '${e.name}': '${e.kind}'`).join(`
|
|
55
|
+
`)||" // (no plugins/adapters discovered yet — `defineAdapter`/`definePlugin` calls feed this)"}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export {}
|
|
60
|
+
`}function xe(e){if(e.length===0)return`${G}
|
|
61
|
+
// No augmentations discovered.
|
|
62
|
+
//
|
|
63
|
+
// Plugins advertise augmentable interfaces via:
|
|
64
|
+
//
|
|
65
|
+
// import { defineAugmentation } from '@forinda/kickjs'
|
|
66
|
+
// defineAugmentation('FeatureFlags', {
|
|
67
|
+
// description: 'Feature flag shape consumed by FlagsPlugin',
|
|
68
|
+
// example: '{ beta: boolean; rolloutPercentage: number }',
|
|
69
|
+
// })
|
|
70
|
+
//
|
|
71
|
+
// See \`docs/guide/typegen.md#augmentations\` for the full pattern.
|
|
72
|
+
export {}
|
|
73
|
+
`;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(`
|
|
74
|
+
`))t.push(` * ${n}`);if(e.example){t.push(` * @example`," * ```ts");for(let n of e.example.split(`
|
|
75
|
+
`))t.push(` * ${n}`);t.push(" * ```")}t.push(` * @see ${e.relativePath}`),n.push([`/**`,...t,` */`,`export interface ${e.name}Augmentation {}`].join(`
|
|
76
|
+
`))}return`${G}
|
|
77
|
+
// Catalogue of augmentable interfaces in this project. The interfaces
|
|
78
|
+
// below are documentation only — augment the source-of-truth interfaces
|
|
79
|
+
// in your own \`d.ts\` files (the framework declares the actual types).
|
|
80
|
+
|
|
81
|
+
${n.join(`
|
|
82
|
+
|
|
83
|
+
`)}
|
|
84
|
+
`}async function Se(e){let{classes:t,routes:n=[],tokens:a=[],injects:o=[],collisions:s=[],env:l=null,pluginsAndAdapters:u=[],augmentations:d=[],assets:f={entries:[],count:0},outDir:m,allowDuplicates:h=!1,schemaValidator:g=!1}=e;if(s.length>0&&!h)throw new q(s);await c(m,{recursive:!0});let _=i(m,`registry.d.ts`),v=i(m,`services.d.ts`),y=i(m,`modules.d.ts`),b=i(m,`plugins.d.ts`),x=i(m,`augmentations.d.ts`),S=i(m,`index.d.ts`),C=new Set(s.map(e=>e.className)),w=ve(t,_,C),T=t.filter(e=>K.has(e.decorator)).map(e=>C.has(e.className)?J(e):e.className),ee=a.map(e=>e.name),E=o.map(e=>e.name),D=[...T,...ee,...E],O=t.filter(e=>e.decorator===`Module`).map(e=>e.className),te=Y(`ServiceToken`,D,"(no tokens discovered — declare with createToken<T>() or `kick g service <name>`)"),ne=Y(`ModuleToken`,O,"(no @Module classes discovered — `kick g module <name>` to add one)"),k=be(u),A=xe(d),j=ye(l!==null,f.count>0);await p(_,w,`utf-8`),await p(v,te,`utf-8`),await p(y,ne,`utf-8`),await p(b,k,`utf-8`),await p(x,A,`utf-8`),await p(S,j,`utf-8`);let M=[_,v,y,b,x,S];await p(i(r(m),`.gitignore`),`# Auto-generated by kick typegen
|
|
85
|
+
*
|
|
86
|
+
`,`utf-8`);let N=new Set(u.map(e=>e.name)).size,P=new Set(d.map(e=>e.name)).size;return{registryEntries:T.length,serviceTokens:new Set(D).size,moduleTokens:O.length,routeEntries:n.length,pluginEntries:N,augmentationEntries:P,assetEntries:f.count,envWritten:l!==null,written:M,resolvedCollisions:s.length}}const Ce=/^(kick\/)?([a-z][\w-]*\/[A-Z]\w*)(\/.+)?(:[a-z][\w-]+(:[a-z][\w-]+)*)?$/;function we(e){let t=[];for(let n of e){let e=n.name;e.startsWith(`kickjs.`)||Ce.test(e)||t.push({token:e,variable:n.variable,filePath:n.relativePath,reason:"does not match `<scope>/<PascalKey>[/<suffix>][:<instance>]`",suggestion:Te(e)})}return t}function Te(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 X(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=o(t,i.src);if(!ke(e))continue;let a=m(i.glob??`**/*`,{cwd:e,nodir:!0,dot:!1,posix:!0});a.sort();let{pairs:s}=h(r,a,{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 Ee(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}
|
|
87
|
+
declare module '@forinda/kickjs' {
|
|
88
|
+
/**
|
|
89
|
+
* Map of every typed asset discovered in the project's assetMap.
|
|
90
|
+
* (No assetMap entries discovered yet — declare with
|
|
91
|
+
* \`assetMap: { name: { src: 'src/...' } }\` in kick.config.ts.)
|
|
92
|
+
*/
|
|
93
|
+
interface KickAssets {}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export {}
|
|
97
|
+
`;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===Z){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]=Z)}return`${t}
|
|
98
|
+
declare module '@forinda/kickjs' {
|
|
99
|
+
/**
|
|
100
|
+
* Map of every typed asset discovered in the project's assetMap.
|
|
101
|
+
* Each leaf is a \`() => string\` thunk that returns the resolved
|
|
102
|
+
* absolute path for the file in the current run mode (dev → src,
|
|
103
|
+
* prod → dist).
|
|
104
|
+
*/
|
|
105
|
+
interface KickAssets {
|
|
106
|
+
${De(n,` `)}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export {}
|
|
111
|
+
`}const Z=Symbol(`asset-leaf`);function De(e,t){let n=Object.keys(e).toSorted(),r=[];for(let i of n){let n=e[i],a=Oe(i)?i:JSON.stringify(i);n===Z?r.push(`${t}${a}: () => string`):(r.push(`${t}${a}: {`),r.push(De(n,`${t} `)),r.push(`${t}}`))}return r.join(`
|
|
112
|
+
`)}function Oe(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)}function ke(e){try{return t(e).isDirectory()}catch{return!1}}var Ae=e({runTypegen:()=>Q,sweepStaleTypegen:()=>$,watchTypegen:()=>Me});function je(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 Q(e={}){let{cwd:t,srcDir:n,outDir:r,silent:i,allowDuplicates:a,schemaValidator:o,envFile:s}=je(e),c=Date.now(),l=await W({root:n,cwd:t,envFile:s===!1?void 0:s}),u=X(e.assetMap,t),d=await Se({classes:l.classes,routes:l.routes,tokens:l.tokens,injects:l.injects,collisions:l.collisions,env:s===!1?null:l.env,pluginsAndAdapters:l.pluginsAndAdapters,augmentations:l.augmentations,assets:u,outDir:r,allowDuplicates:a,schemaValidator:o}),f=[];if(e.runPlugins!==!1)try{let{runAllPluginTypegens:e}=await import(`./builtins-5aWa9xTa.mjs`).then(e=>e.r),{loadKickConfig:n}=await import(`./config-BefQBc0L.mjs`).then(e=>e.n);f=await e({cwd:t,config:await n(t),silent:!0})}catch(e){if(!i){let t=e instanceof Error?e.message:String(e);console.warn(` kick typegen: plugin pipeline failed (${t}) — continuing`)}}e.runPlugins!==!1&&await $(r,d.written,f,i);let p=we(l.tokens),m=Date.now()-c;if(!i){let e=r.replace(t+`/`,``),n=d.resolvedCollisions>0?`, ${d.resolvedCollisions} collisions namespaced`:``,i=d.envWritten?`, env typed`:``,a=d.pluginEntries>0?`, ${d.pluginEntries} plugins/adapters`:``,o=d.augmentationEntries>0?`, ${d.augmentationEntries} augmentations`:``,s=d.assetEntries>0?`, ${d.assetEntries} assets`:``;if(console.log(` kick typegen → ${d.serviceTokens} services, ${d.routeEntries} routes, ${d.moduleTokens} modules${a}${o}${s}${i}${n} → ${e} (${m}ms)`),p.length>0){console.warn(` kick typegen: ${p.length} token(s) don't match the §22.2 convention:`);for(let e of p){let t=e.variable?` [${e.variable}]`:``;console.warn(` '${e.token}' (${e.filePath})${t} — ${e.reason}`),e.suggestion&&console.warn(` → suggestion: ${e.suggestion}`)}}if(l.orphanedClasses.length>0){console.warn(` kick typegen: ${l.orphanedClasses.length} decorated class(es) not matched by any module's import.meta.glob():`);for(let e of l.orphanedClasses)console.warn(` @${e.decorator} ${e.className} (${e.relativePath})`),console.warn(` → not picked up by any glob in ${e.moduleFilePath}`)}}return{scan:l,result:d,tokenWarnings:p}}async function Me(e={}){let t=je(e),{srcDir:n,silent:r,cwd:i}=t,a={...t,allowDuplicates:!0,runPlugins:!1},o=process.env.KICKJS_WATCH_POLLING===`1`||process.env.KICKJS_WATCH_POLLING===`true`,[{runAllPluginTypegens:s},{loadKickConfig:c}]=await Promise.all([import(`./builtins-5aWa9xTa.mjs`).then(e=>e.r),import(`./config-BefQBc0L.mjs`).then(e=>e.n)]),l=await c(i),u=[],d=async()=>{try{u=(await Q({...a})).result.written}catch(e){if(r)return;if(e instanceof q)console.error(`
|
|
113
|
+
`+e.message+`
|
|
114
|
+
`);else{let t=e instanceof Error?e.message:String(e);console.error(` kick typegen failed: ${t}`)}}},f=async()=>{try{let e=await s({cwd:i,config:l,silent:!0});await $(t.outDir,u,e,!0)}catch{}};await d(),await f();let{watch:p}=await import(`node:fs`),m=null,h=e=>{e&&/\.(ts|tsx|mts|cts)$/.test(e)&&(e.includes(`.kickjs`)||e.endsWith(`.d.ts`)||(m&&clearTimeout(m),m=setTimeout(()=>{d().then(f)},100)))};if(o){r||console.log(` kick typegen: polling mode (KICKJS_WATCH_POLLING)`);let e=setInterval(()=>{Ne({...a,silent:!0},!0)},2e3);return()=>clearInterval(e)}let g;try{g=p(n,{recursive:!0},(e,t)=>{h(t)})}catch(e){r||console.warn(` kick typegen: watch mode unavailable (${e?.message??e}). Falling back to polling.`);let t=setInterval(()=>{Ne({...a,silent:!0},!0)},2e3);return()=>clearInterval(t)}return()=>{m&&clearTimeout(m),g.close()}}async function Ne(e,t){try{await Q(e)}catch(e){if(t)return;if(e instanceof q)console.error(`
|
|
115
|
+
`+e.message+`
|
|
116
|
+
`);else{let t=e instanceof Error?e.message:String(e);console.error(` kick typegen failed: ${t}`)}}}async function $(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(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}export{X as a,W as c,Me as i,$ as n,Ee as o,Ae as r,q as s,Q as t};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @forinda/kickjs-cli v5.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-BrsfUx5e.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";const g=[`Service`,`Controller`,`Repository`,`Injectable`,`Component`,`Module`],_=[`.ts`,`.tsx`,`.mts`,`.cts`],v=[`node_modules`,`.kickjs`,`dist`,`build`,`.test.`,`.spec.`,`.d.ts`],y=new RegExp(String.raw`@(${g.join(`|`)})\s*\([^)]*\)`+String.raw`(?:\s*@[A-Z]\w*(?:\s*\([^)]*\))?)*`+String.raw`\s*export\s+(default\s+)?(?:abstract\s+)?class\s+(\w+)`,`g`),b=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`),x=/(?:export\s+)?const\s+(\w+)\s*(?::\s*[^=]+)?=\s*createToken\s*(?:<[^>]*>)?\s*\(\s*['"`]([^'"`]+)['"`]\s*\)/g,S=/createToken\s*(?:<[^>]*>)?\s*\(\s*['"`]([^'"`]+)['"`]\s*\)/g,C=/@Inject\s*\(\s*['"`]([^'"`]+)['"`]\s*\)/g,w=/\b(defineAdapter|definePlugin)\s*(?:<[^>]*>)?\s*\(/g,T=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`),ee=/\bname\s*(?::\s*[^=]+)?=\s*['"`]([^'"`]+)['"`]/,E=/\bdefineAugmentation\s*\(\s*['"`]([^'"`]+)['"`]\s*(,\s*\{)?/g,D=new RegExp(String.raw`@(${[`Get`,`Post`,`Put`,`Delete`,`Patch`].join(`|`)})\s*\(`,`g`);function O(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 te(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=O(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 ne(e){return(e.match(/:([a-zA-Z_]\w*)/g)??[]).map(e=>e.slice(1))}function k(e,t){let n=e.endsWith(`/`)?e.slice(0,-1):e;return!t||t===`/`?n||`/`:n+(t.startsWith(`/`)?t:`/`+t)||`/`}const A=/\b(?:public\s+|private\s+|protected\s+)?routes\s*\([^)]*\)\s*(?::\s*[A-Za-z_][\w<>[\]\s,|]*\s*)?\{/g,j=/\bpath\s*:\s*['"`]([^'"`]*)['"`]/g,M=/\bcontroller\s*:\s*([A-Z]\w*)\b/g,N=/\bimport\.meta\.glob\s*\(/g;function P(e){let t=[];for(N.lastIndex=0;N.exec(e)!==null;){let n=N.lastIndex-1,r=O(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 re(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 ie(e,t){let n=e.startsWith(`./`)?e:`./`+e,r=!1;for(let e of t){let t=e.startsWith(`!`);re(t?e.slice(1):e).test(n)&&(r=!t)}return r}function ae(e){let t=[];A.lastIndex=0;let n;for(;(n=A.exec(e))!==null;){let r=e.indexOf(`{`,n.index+n[0].length-1);if(r<0)continue;let i=H(e,r);if(i<0)continue;let a=e.slice(r+1,i),o=[];j.lastIndex=0;let s;for(;(s=j.exec(a))!==null;)o.push(s[1]??``);let c=[];M.lastIndex=0;let l;for(;(l=M.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 F(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 I(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 oe(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?L(n[1].trim(),t):null}return L(n[1].trim(),t)}function L(e,t){if(e.startsWith(`{`))return z(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 z(r[1])}return{filterable:[],sortable:[],searchable:[]}}function R(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 z(e){return{filterable:R(e,`filterable`),sortable:R(e,`sortable`),searchable:R(e,`searchable`)}}async function B(e,t){let n=t.extensions??_,a=t.exclude??v,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 B(s,t)):c.isFile()&&n.some(e=>c.name.endsWith(e))&&o.push(s))}return o}function V(e,t){return i(t,e).split(o).join(`/`)}function se(e,t,n){let r=[],i=V(t,n);y.lastIndex=0;let a;for(;(a=y.exec(e))!==null;){let[,e,n,o]=a;r.push({className:o,decorator:e,filePath:t,relativePath:i,isDefault:!!n})}b.lastIndex=0;let o;for(;(o=b.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})}return r}function ce(e,t,n){let r=[],i=V(t,n),a=new Set;x.lastIndex=0;let o;for(;(o=x.exec(e))!==null;){let[e,n,s]=o;a.add(e),r.push({name:s,variable:n,filePath:t,relativePath:i})}for(S.lastIndex=0;(o=S.exec(e))!==null;)a.has(o[0])||r.push({name:o[1],variable:null,filePath:t,relativePath:i});return r}function le(e,t,n,r,i=new Map){let a=[];if(r.length===0)return a;let o=V(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);D.lastIndex=0;let d;for(;(d=D.exec(u))!==null;){let n=d[1],s=d.index,c=D.lastIndex-1,l=O(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=te(u,l+1);if(!h)continue;let{methodName:g,endPos:_}=h;D.lastIndex=_;let v=oe(u.slice(s,_),e),y=F(f,`body`),b=F(f,`query`),x=F(f,`params`),S=i.get(r.className)??``,C=S?k(S,m):m;a.push({controller:r.className,method:g,httpMethod:n.toUpperCase(),path:m,pathParams:ne(C),queryFilterable:v?.filterable??null,querySortable:v?.sortable??null,querySearchable:v?.searchable??null,bodySchema:y?{identifier:y,source:I(e,y)}:null,querySchema:b?{identifier:b,source:I(e,b)}:null,paramsSchema:x?{identifier:x,source:I(e,x)}:null,filePath:t,relativePath:o})}}return a}function ue(e,t,n){let r=[],i=V(t,n);C.lastIndex=0;let a;for(;(a=C.exec(e))!==null;)r.push({name:a[1],filePath:t,relativePath:i});return r}function H(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 de(e,t,n){let r=[],i=V(t,n),a=new Set;w.lastIndex=0;let o;for(;(o=w.exec(e))!==null;){let n=o[1],s=w.lastIndex-1,c=O(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}))}T.lastIndex=0;let s;for(;(s=T.exec(e))!==null;){let n=s.index,o=e.indexOf(`{`,n);if(o<0)continue;let c=H(e,o);if(c<0)continue;let l=e.slice(o+1,c),u=ee.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 fe(e,t,n){let r=[],i=V(t,n);E.lastIndex=0;let a;for(;(a=E.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=H(e,t);if(n>=0){let r=e.slice(t+1,n);o=U(r,`description`),s=U(r,`example`)}}}r.push({name:n,description:o,example:s,filePath:t,relativePath:i})}return r}function U(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 pe=[`src/config/index.ts`,`src/config/env.ts`,`src/config.ts`,`src/env.ts`];async function me(e,t){let n=t===`src/env.ts`?pe:[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)&&/export\s+default\b/.test(r))return{filePath:n,relativePath:V(n,e)}}return null}function he(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}async function W(e){let t=await B(a(e.root),e),n=[],r=[],i=[],s=[],c=[],u=[],d=new Map;for(let r of t){let t;try{t=await l(r,`utf-8`)}catch{continue}d.set(r,t),n.push(...se(t,r,e.cwd)),i.push(...ce(t,r,e.cwd)),s.push(...ue(t,r,e.cwd)),c.push(...de(t,r,e.cwd)),u.push(...fe(t,r,e.cwd))}let f=new Map;for(let[,e]of d)for(let{controller:t,mountPath:n}of ae(e))f.has(t)||f.set(t,n);for(let[t,i]of d){let a=n.filter(e=>e.filePath===t);r.push(...le(i,t,e.cwd,a,f))}let p=[];for(let[e,t]of d){if(!/\.module\.[mc]?[tj]sx?$/.test(e))continue;let r=P(t);if(r.length===0)continue;let i=e.replaceAll(o,`/`),a=i.slice(0,i.lastIndexOf(`/`));for(let t of n){if(t.decorator===`Module`)continue;let n=t.filePath.replaceAll(o,`/`);n.startsWith(a+`/`)&&n!==i&&(ie(n.slice(a.length+1),r)||p.push({className:t.className,filePath:t.filePath,relativePath:t.relativePath,moduleFilePath:e,decorator:t.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)),s.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)),c.sort((e,t)=>e.name.localeCompare(t.name)||e.relativePath.localeCompare(t.relativePath)),u.sort((e,t)=>e.name.localeCompare(t.name)||e.relativePath.localeCompare(t.relativePath));let m=he(n),h=await me(e.cwd,e.envFile??`src/env.ts`);return p.sort((e,t)=>e.relativePath.localeCompare(t.relativePath)||e.className.localeCompare(t.className)),{classes:n,routes:r,tokens:i,injects:s,collisions:m,env:h,pluginsAndAdapters:c,augmentations:u,orphanedClasses:p}}const G="/* 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",K=new Set([`Service`,`Repository`,`Injectable`,`Component`]);var q=class extends Error{collisions;constructor(e){super(ge(e)),this.name=`TokenCollisionError`,this.collisions=e}};function ge(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 _e(e,t){let r=i(n(t),e).split(o).join(`/`);return r=r.replace(/\.(ts|tsx|mts|cts)$/i,``),r.startsWith(`.`)||(r=`./`+r),r}function J(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 ve(e,t,n){let r=new Set,i=[];for(let a of e){if(!K.has(a.decorator))continue;let e=n.has(a.className)?J(a):a.className;if(r.has(e))continue;r.add(e);let o=_e(a.filePath,t),s=a.isDefault?`import('${o}').default`:`import('${o}').${a.className}`;i.push(` '${e}': ${s}`)}return`${G}
|
|
14
|
+
declare module '@forinda/kickjs' {
|
|
15
|
+
interface KickJsRegistry {
|
|
16
|
+
${i.length?i.join(`
|
|
17
|
+
`):" // (no services discovered yet — run `kick g service <name>` to add one)"}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export {}
|
|
22
|
+
`}function Y(e,t,n){return t.length===0?`${G}
|
|
23
|
+
// ${n}
|
|
24
|
+
export type ${e} = never
|
|
25
|
+
`:`${G}
|
|
26
|
+
export type ${e} =
|
|
27
|
+
${[...new Set(t)].toSorted().map(e=>` | '${e}'`).join(`
|
|
28
|
+
`)}
|
|
29
|
+
`}function ye(e,t){return`${G}
|
|
30
|
+
export type { ServiceToken } from './services'
|
|
31
|
+
export type { ModuleToken } from './modules'
|
|
32
|
+
|
|
33
|
+
// The registry, routes, plugins, assets, and env augmentations are
|
|
34
|
+
// loaded as side-effects — importing this file (or having it on
|
|
35
|
+
// tsconfig include) is enough for \`container.resolve()\`,
|
|
36
|
+
// \`Ctx<KickRoutes.UserController['getUser']>\`,
|
|
37
|
+
// \`dependsOn: ['TenantAdapter']\`, \`assets.mails.welcome()\`, and
|
|
38
|
+
// \`@Value('PORT')\` to resolve.
|
|
39
|
+
import './registry'
|
|
40
|
+
import './kick__routes'
|
|
41
|
+
import './plugins'
|
|
42
|
+
import './augmentations'
|
|
43
|
+
${t?`import './kick__assets'
|
|
44
|
+
`:``}${e?`import './kick__env'
|
|
45
|
+
`:``}`}function be(e){let t=new Map;for(let n of e)t.has(n.name)||t.set(n.name,n);return`${G}
|
|
46
|
+
declare module '@forinda/kickjs' {
|
|
47
|
+
/**
|
|
48
|
+
* Map of every plugin/adapter \`name\` discovered in the project. The
|
|
49
|
+
* value type is the kind tag (\`'plugin'\` or \`'adapter'\`); the
|
|
50
|
+
* \`keyof\` of this interface narrows \`dependsOn\` so misspelled deps
|
|
51
|
+
* become compile errors instead of boot-time \`MissingMountDepError\`.
|
|
52
|
+
*/
|
|
53
|
+
interface KickJsPluginRegistry {
|
|
54
|
+
${[...t.values()].toSorted((e,t)=>e.name.localeCompare(t.name)).map(e=>` '${e.name}': '${e.kind}'`).join(`
|
|
55
|
+
`)||" // (no plugins/adapters discovered yet — `defineAdapter`/`definePlugin` calls feed this)"}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export {}
|
|
60
|
+
`}function xe(e){if(e.length===0)return`${G}
|
|
61
|
+
// No augmentations discovered.
|
|
62
|
+
//
|
|
63
|
+
// Plugins advertise augmentable interfaces via:
|
|
64
|
+
//
|
|
65
|
+
// import { defineAugmentation } from '@forinda/kickjs'
|
|
66
|
+
// defineAugmentation('FeatureFlags', {
|
|
67
|
+
// description: 'Feature flag shape consumed by FlagsPlugin',
|
|
68
|
+
// example: '{ beta: boolean; rolloutPercentage: number }',
|
|
69
|
+
// })
|
|
70
|
+
//
|
|
71
|
+
// See \`docs/guide/typegen.md#augmentations\` for the full pattern.
|
|
72
|
+
export {}
|
|
73
|
+
`;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(`
|
|
74
|
+
`))t.push(` * ${n}`);if(e.example){t.push(` * @example`," * ```ts");for(let n of e.example.split(`
|
|
75
|
+
`))t.push(` * ${n}`);t.push(" * ```")}t.push(` * @see ${e.relativePath}`),n.push([`/**`,...t,` */`,`export interface ${e.name}Augmentation {}`].join(`
|
|
76
|
+
`))}return`${G}
|
|
77
|
+
// Catalogue of augmentable interfaces in this project. The interfaces
|
|
78
|
+
// below are documentation only — augment the source-of-truth interfaces
|
|
79
|
+
// in your own \`d.ts\` files (the framework declares the actual types).
|
|
80
|
+
|
|
81
|
+
${n.join(`
|
|
82
|
+
|
|
83
|
+
`)}
|
|
84
|
+
`}async function Se(e){let{classes:t,routes:i=[],tokens:a=[],injects:o=[],collisions:s=[],env:l=null,pluginsAndAdapters:u=[],augmentations:d=[],assets:f={entries:[],count:0},outDir:m,allowDuplicates:h=!1,schemaValidator:g=!1}=e;if(s.length>0&&!h)throw new q(s);await c(m,{recursive:!0});let _=r(m,`registry.d.ts`),v=r(m,`services.d.ts`),y=r(m,`modules.d.ts`),b=r(m,`plugins.d.ts`),x=r(m,`augmentations.d.ts`),S=r(m,`index.d.ts`),C=new Set(s.map(e=>e.className)),w=ve(t,_,C),T=t.filter(e=>K.has(e.decorator)).map(e=>C.has(e.className)?J(e):e.className),ee=a.map(e=>e.name),E=o.map(e=>e.name),D=[...T,...ee,...E],O=t.filter(e=>e.decorator===`Module`).map(e=>e.className),te=Y(`ServiceToken`,D,"(no tokens discovered — declare with createToken<T>() or `kick g service <name>`)"),ne=Y(`ModuleToken`,O,"(no @Module classes discovered — `kick g module <name>` to add one)"),k=be(u),A=xe(d),j=ye(l!==null,f.count>0);await p(_,w,`utf-8`),await p(v,te,`utf-8`),await p(y,ne,`utf-8`),await p(b,k,`utf-8`),await p(x,A,`utf-8`),await p(S,j,`utf-8`);let M=[_,v,y,b,x,S];await p(r(n(m),`.gitignore`),`# Auto-generated by kick typegen
|
|
85
|
+
*
|
|
86
|
+
`,`utf-8`);let N=new Set(u.map(e=>e.name)).size,P=new Set(d.map(e=>e.name)).size;return{registryEntries:T.length,serviceTokens:new Set(D).size,moduleTokens:O.length,routeEntries:i.length,pluginEntries:N,augmentationEntries:P,assetEntries:f.count,envWritten:l!==null,written:M,resolvedCollisions:s.length}}const Ce=/^(kick\/)?([a-z][\w-]*\/[A-Z]\w*)(\/.+)?(:[a-z][\w-]+(:[a-z][\w-]+)*)?$/;function we(e){let t=[];for(let n of e){let e=n.name;e.startsWith(`kickjs.`)||Ce.test(e)||t.push({token:e,variable:n.variable,filePath:n.relativePath,reason:"does not match `<scope>/<PascalKey>[/<suffix>][:<instance>]`",suggestion:Te(e)})}return t}function Te(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 X(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(!ke(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 Ee(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}
|
|
87
|
+
declare module '@forinda/kickjs' {
|
|
88
|
+
/**
|
|
89
|
+
* Map of every typed asset discovered in the project's assetMap.
|
|
90
|
+
* (No assetMap entries discovered yet — declare with
|
|
91
|
+
* \`assetMap: { name: { src: 'src/...' } }\` in kick.config.ts.)
|
|
92
|
+
*/
|
|
93
|
+
interface KickAssets {}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export {}
|
|
97
|
+
`;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===Z){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]=Z)}return`${t}
|
|
98
|
+
declare module '@forinda/kickjs' {
|
|
99
|
+
/**
|
|
100
|
+
* Map of every typed asset discovered in the project's assetMap.
|
|
101
|
+
* Each leaf is a \`() => string\` thunk that returns the resolved
|
|
102
|
+
* absolute path for the file in the current run mode (dev → src,
|
|
103
|
+
* prod → dist).
|
|
104
|
+
*/
|
|
105
|
+
interface KickAssets {
|
|
106
|
+
${De(n,` `)}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export {}
|
|
111
|
+
`}const Z=Symbol(`asset-leaf`);function De(e,t){let n=Object.keys(e).toSorted(),r=[];for(let i of n){let n=e[i],a=Oe(i)?i:JSON.stringify(i);n===Z?r.push(`${t}${a}: () => string`):(r.push(`${t}${a}: {`),r.push(De(n,`${t} `)),r.push(`${t}}`))}return r.join(`
|
|
112
|
+
`)}function Oe(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)}function ke(e){try{return s(e).isDirectory()}catch{return!1}}var Ae=e({runTypegen:()=>Q,sweepStaleTypegen:()=>$,watchTypegen:()=>Me});function je(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 Q(e={}){let{cwd:t,srcDir:n,outDir:r,silent:i,allowDuplicates:a,schemaValidator:o,envFile:s}=je(e),c=Date.now(),l=await W({root:n,cwd:t,envFile:s===!1?void 0:s}),u=X(e.assetMap,t),d=await Se({classes:l.classes,routes:l.routes,tokens:l.tokens,injects:l.injects,collisions:l.collisions,env:s===!1?null:l.env,pluginsAndAdapters:l.pluginsAndAdapters,augmentations:l.augmentations,assets:u,outDir:r,allowDuplicates:a,schemaValidator:o}),f=[];if(e.runPlugins!==!1)try{let{runAllPluginTypegens:e}=await import(`./run-plugins-GOyvsWi5.mjs`),{loadKickConfig:n}=await import(`./config-BSo8gLtM.mjs`).then(e=>e.n);f=await e({cwd:t,config:await n(t),silent:!0})}catch(e){if(!i){let t=e instanceof Error?e.message:String(e);console.warn(` kick typegen: plugin pipeline failed (${t}) — continuing`)}}e.runPlugins!==!1&&await $(r,d.written,f,i);let p=we(l.tokens),m=Date.now()-c;if(!i){let e=r.replace(t+`/`,``),n=d.resolvedCollisions>0?`, ${d.resolvedCollisions} collisions namespaced`:``,i=d.envWritten?`, env typed`:``,a=d.pluginEntries>0?`, ${d.pluginEntries} plugins/adapters`:``,o=d.augmentationEntries>0?`, ${d.augmentationEntries} augmentations`:``,s=d.assetEntries>0?`, ${d.assetEntries} assets`:``;if(console.log(` kick typegen → ${d.serviceTokens} services, ${d.routeEntries} routes, ${d.moduleTokens} modules${a}${o}${s}${i}${n} → ${e} (${m}ms)`),p.length>0){console.warn(` kick typegen: ${p.length} token(s) don't match the §22.2 convention:`);for(let e of p){let t=e.variable?` [${e.variable}]`:``;console.warn(` '${e.token}' (${e.filePath})${t} — ${e.reason}`),e.suggestion&&console.warn(` → suggestion: ${e.suggestion}`)}}if(l.orphanedClasses.length>0){console.warn(` kick typegen: ${l.orphanedClasses.length} decorated class(es) not matched by any module's import.meta.glob():`);for(let e of l.orphanedClasses)console.warn(` @${e.decorator} ${e.className} (${e.relativePath})`),console.warn(` → not picked up by any glob in ${e.moduleFilePath}`)}}return{scan:l,result:d,tokenWarnings:p}}async function Me(e={}){let t=je(e),{srcDir:n,silent:r,cwd:i}=t,a={...t,allowDuplicates:!0,runPlugins:!1},o=process.env.KICKJS_WATCH_POLLING===`1`||process.env.KICKJS_WATCH_POLLING===`true`,[{runAllPluginTypegens:s},{loadKickConfig:c}]=await Promise.all([import(`./run-plugins-GOyvsWi5.mjs`),import(`./config-BSo8gLtM.mjs`).then(e=>e.n)]),l=await c(i),u=[],d=async()=>{try{u=(await Q({...a})).result.written}catch(e){if(r)return;if(e instanceof q)console.error(`
|
|
113
|
+
`+e.message+`
|
|
114
|
+
`);else{let t=e instanceof Error?e.message:String(e);console.error(` kick typegen failed: ${t}`)}}},f=async()=>{try{let e=await s({cwd:i,config:l,silent:!0});await $(t.outDir,u,e,!0)}catch{}};await d(),await f();let{watch:p}=await import(`node:fs`),m=null,h=e=>{e&&/\.(ts|tsx|mts|cts)$/.test(e)&&(e.includes(`.kickjs`)||e.endsWith(`.d.ts`)||(m&&clearTimeout(m),m=setTimeout(()=>{d().then(f)},100)))};if(o){r||console.log(` kick typegen: polling mode (KICKJS_WATCH_POLLING)`);let e=setInterval(()=>{Ne({...a,silent:!0},!0)},2e3);return()=>clearInterval(e)}let g;try{g=p(n,{recursive:!0},(e,t)=>{h(t)})}catch(e){r||console.warn(` kick typegen: watch mode unavailable (${e?.message??e}). Falling back to polling.`);let t=setInterval(()=>{Ne({...a,silent:!0},!0)},2e3);return()=>clearInterval(t)}return()=>{m&&clearTimeout(m),g.close()}}async function Ne(e,t){try{await Q(e)}catch(e){if(t)return;if(e instanceof q)console.error(`
|
|
115
|
+
`+e.message+`
|
|
116
|
+
`);else{let t=e instanceof Error?e.message:String(e);console.error(` kick typegen failed: ${t}`)}}}async function $(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(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}export{X as a,W as c,Me as i,$ as n,Ee as o,Ae as r,q as s,Q as t};
|
|
117
|
+
//# sourceMappingURL=typegen-DyXcnNCk.mjs.map
|