@acmekit/acmekit 2.13.40 → 2.13.43
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/api/admin/views/[entity]/configurations/validators.d.ts +8 -8
- package/dist/commands/develop.d.ts.map +1 -1
- package/dist/commands/develop.js +1 -0
- package/dist/commands/develop.js.map +1 -1
- package/dist/commands/generate/crud.d.ts +8 -0
- package/dist/commands/generate/crud.d.ts.map +1 -0
- package/dist/commands/generate/crud.js +223 -0
- package/dist/commands/generate/crud.js.map +1 -0
- package/dist/commands/generate/docs.d.ts +7 -0
- package/dist/commands/generate/docs.d.ts.map +1 -0
- package/dist/commands/generate/docs.js +236 -0
- package/dist/commands/generate/docs.js.map +1 -0
- package/dist/commands/generate/index.d.ts +2 -0
- package/dist/commands/generate/index.d.ts.map +1 -0
- package/dist/commands/generate/index.js +10 -0
- package/dist/commands/generate/index.js.map +1 -0
- package/dist/commands/generate/job.d.ts +7 -0
- package/dist/commands/generate/job.d.ts.map +1 -0
- package/dist/commands/generate/job.js +38 -0
- package/dist/commands/generate/job.js.map +1 -0
- package/dist/commands/generate/link.d.ts +7 -0
- package/dist/commands/generate/link.d.ts.map +1 -0
- package/dist/commands/generate/link.js +63 -0
- package/dist/commands/generate/link.js.map +1 -0
- package/dist/commands/generate/module.d.ts +8 -0
- package/dist/commands/generate/module.d.ts.map +1 -0
- package/dist/commands/generate/module.js +78 -0
- package/dist/commands/generate/module.js.map +1 -0
- package/dist/commands/generate/route.d.ts +7 -0
- package/dist/commands/generate/route.d.ts.map +1 -0
- package/dist/commands/generate/route.js +54 -0
- package/dist/commands/generate/route.js.map +1 -0
- package/dist/commands/generate/subscriber.d.ts +7 -0
- package/dist/commands/generate/subscriber.d.ts.map +1 -0
- package/dist/commands/generate/subscriber.js +41 -0
- package/dist/commands/generate/subscriber.js.map +1 -0
- package/dist/commands/generate/types.d.ts +7 -0
- package/dist/commands/generate/types.d.ts.map +1 -0
- package/dist/commands/generate/types.js +243 -0
- package/dist/commands/generate/types.js.map +1 -0
- package/dist/commands/generate/utils/config-updater.d.ts +12 -0
- package/dist/commands/generate/utils/config-updater.d.ts.map +1 -0
- package/dist/commands/generate/utils/config-updater.js +38 -0
- package/dist/commands/generate/utils/config-updater.js.map +1 -0
- package/dist/commands/generate/utils/file-writer.d.ts +17 -0
- package/dist/commands/generate/utils/file-writer.d.ts.map +1 -0
- package/dist/commands/generate/utils/file-writer.js +31 -0
- package/dist/commands/generate/utils/file-writer.js.map +1 -0
- package/dist/commands/generate/utils/log.d.ts +13 -0
- package/dist/commands/generate/utils/log.d.ts.map +1 -0
- package/dist/commands/generate/utils/log.js +37 -0
- package/dist/commands/generate/utils/log.js.map +1 -0
- package/dist/commands/generate/utils/model-introspector.d.ts +22 -0
- package/dist/commands/generate/utils/model-introspector.d.ts.map +1 -0
- package/dist/commands/generate/utils/model-introspector.js +93 -0
- package/dist/commands/generate/utils/model-introspector.js.map +1 -0
- package/dist/commands/generate/utils/naming.d.ts +21 -0
- package/dist/commands/generate/utils/naming.d.ts.map +1 -0
- package/dist/commands/generate/utils/naming.js +74 -0
- package/dist/commands/generate/utils/naming.js.map +1 -0
- package/dist/commands/generate/workflow.d.ts +7 -0
- package/dist/commands/generate/workflow.d.ts.map +1 -0
- package/dist/commands/generate/workflow.js +66 -0
- package/dist/commands/generate/workflow.js.map +1 -0
- package/dist/loaders/docs.d.ts +10 -0
- package/dist/loaders/docs.d.ts.map +1 -0
- package/dist/loaders/docs.js +129 -0
- package/dist/loaders/docs.js.map +1 -0
- package/dist/loaders/index.d.ts.map +1 -1
- package/dist/loaders/index.js +2 -0
- package/dist/loaders/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +41 -37
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Add a module to the `modules` array in acmekit-config.ts.
|
|
3
|
+
* Handles three cases:
|
|
4
|
+
* 1. `modules` array exists → append entry
|
|
5
|
+
* 2. `modules` key missing → add it to defineConfig
|
|
6
|
+
* 3. Module already registered → skip (idempotent)
|
|
7
|
+
*/
|
|
8
|
+
export declare function addModuleToConfig(directory: string, modulePath: string): {
|
|
9
|
+
updated: boolean;
|
|
10
|
+
configPath: string;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=config-updater.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-updater.d.ts","sourceRoot":"","sources":["../../../../src/commands/generate/utils/config-updater.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACjB;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAiC1C"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addModuleToConfig = addModuleToConfig;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
/**
|
|
7
|
+
* Add a module to the `modules` array in acmekit-config.ts.
|
|
8
|
+
* Handles three cases:
|
|
9
|
+
* 1. `modules` array exists → append entry
|
|
10
|
+
* 2. `modules` key missing → add it to defineConfig
|
|
11
|
+
* 3. Module already registered → skip (idempotent)
|
|
12
|
+
*/
|
|
13
|
+
function addModuleToConfig(directory, modulePath) {
|
|
14
|
+
const configPath = (0, path_1.join)(directory, "acmekit-config.ts");
|
|
15
|
+
let content = (0, fs_1.readFileSync)(configPath, "utf-8");
|
|
16
|
+
// Check if already registered
|
|
17
|
+
if (content.includes(`"${modulePath}"`) ||
|
|
18
|
+
content.includes(`'${modulePath}'`)) {
|
|
19
|
+
return { updated: false, configPath };
|
|
20
|
+
}
|
|
21
|
+
const entry = `\n {\n resolve: "${modulePath}",\n },`;
|
|
22
|
+
// Case 1: modules array exists — insert before closing ]
|
|
23
|
+
const modulesArrayRegex = /(modules\s*:\s*\[)([\s\S]*?)(\s*\])/;
|
|
24
|
+
const match = content.match(modulesArrayRegex);
|
|
25
|
+
if (match) {
|
|
26
|
+
const [full, open, items, close] = match;
|
|
27
|
+
content = content.replace(full, `${open}${items}${entry}${close}`);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
// Case 2: no modules key — add before closing }) of defineConfig
|
|
31
|
+
// Match optional trailing comma before the closing })
|
|
32
|
+
const defineConfigClose = /(,?)(\s*\n\s*}\s*\))/;
|
|
33
|
+
content = content.replace(defineConfigClose, `,\n modules: [${entry}\n ]$2`);
|
|
34
|
+
}
|
|
35
|
+
(0, fs_1.writeFileSync)(configPath, content, "utf-8");
|
|
36
|
+
return { updated: true, configPath };
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=config-updater.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-updater.js","sourceRoot":"","sources":["../../../../src/commands/generate/utils/config-updater.ts"],"names":[],"mappings":";;AAUA,8CAoCC;AA9CD,2BAAgD;AAChD,+BAA2B;AAE3B;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAC/B,SAAiB,EACjB,UAAkB;IAElB,MAAM,UAAU,GAAG,IAAA,WAAI,EAAC,SAAS,EAAE,mBAAmB,CAAC,CAAA;IACvD,IAAI,OAAO,GAAG,IAAA,iBAAY,EAAC,UAAU,EAAE,OAAO,CAAC,CAAA;IAE/C,8BAA8B;IAC9B,IACE,OAAO,CAAC,QAAQ,CAAC,IAAI,UAAU,GAAG,CAAC;QACnC,OAAO,CAAC,QAAQ,CAAC,IAAI,UAAU,GAAG,CAAC,EACnC,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,CAAA;IACvC,CAAC;IAED,MAAM,KAAK,GAAG,4BAA4B,UAAU,YAAY,CAAA;IAEhE,yDAAyD;IACzD,MAAM,iBAAiB,GAAG,qCAAqC,CAAA;IAC/D,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAA;IAE9C,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,GAAG,KAAK,CAAA;QACxC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,IAAI,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,EAAE,CAAC,CAAA;IACpE,CAAC;SAAM,CAAC;QACN,iEAAiE;QACjE,sDAAsD;QACtD,MAAM,iBAAiB,GAAG,sBAAsB,CAAA;QAChD,OAAO,GAAG,OAAO,CAAC,OAAO,CACvB,iBAAiB,EACjB,kBAAkB,KAAK,SAAS,CACjC,CAAA;IACH,CAAC;IAED,IAAA,kBAAa,EAAC,UAAU,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;IAC3C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,CAAA;AACtC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type FileToCreate = {
|
|
2
|
+
path: string;
|
|
3
|
+
content: string;
|
|
4
|
+
};
|
|
5
|
+
export type WriteResult = {
|
|
6
|
+
created: string[];
|
|
7
|
+
skipped: string[];
|
|
8
|
+
overwritten: string[];
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Write multiple files, creating directories as needed.
|
|
12
|
+
* Skips files that already exist (idempotent) unless overwrite is true.
|
|
13
|
+
*/
|
|
14
|
+
export declare function writeFiles(files: FileToCreate[], options?: {
|
|
15
|
+
overwrite?: boolean;
|
|
16
|
+
}): WriteResult;
|
|
17
|
+
//# sourceMappingURL=file-writer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-writer.d.ts","sourceRoot":"","sources":["../../../../src/commands/generate/utils/file-writer.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,WAAW,EAAE,MAAM,EAAE,CAAA;CACtB,CAAA;AAED;;;GAGG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,YAAY,EAAE,EACrB,OAAO,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,GAChC,WAAW,CAsBb"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.writeFiles = writeFiles;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
/**
|
|
7
|
+
* Write multiple files, creating directories as needed.
|
|
8
|
+
* Skips files that already exist (idempotent) unless overwrite is true.
|
|
9
|
+
*/
|
|
10
|
+
function writeFiles(files, options) {
|
|
11
|
+
const created = [];
|
|
12
|
+
const skipped = [];
|
|
13
|
+
const overwritten = [];
|
|
14
|
+
for (const file of files) {
|
|
15
|
+
if ((0, fs_1.existsSync)(file.path)) {
|
|
16
|
+
if (options?.overwrite) {
|
|
17
|
+
(0, fs_1.writeFileSync)(file.path, file.content, "utf-8");
|
|
18
|
+
overwritten.push(file.path);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
skipped.push(file.path);
|
|
22
|
+
}
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
(0, fs_1.mkdirSync)((0, path_1.dirname)(file.path), { recursive: true });
|
|
26
|
+
(0, fs_1.writeFileSync)(file.path, file.content, "utf-8");
|
|
27
|
+
created.push(file.path);
|
|
28
|
+
}
|
|
29
|
+
return { created, skipped, overwritten };
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=file-writer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-writer.js","sourceRoot":"","sources":["../../../../src/commands/generate/utils/file-writer.ts"],"names":[],"mappings":";;AAkBA,gCAyBC;AA3CD,2BAAyD;AACzD,+BAA8B;AAa9B;;;GAGG;AACH,SAAgB,UAAU,CACxB,KAAqB,EACrB,OAAiC;IAEjC,MAAM,OAAO,GAAa,EAAE,CAAA;IAC5B,MAAM,OAAO,GAAa,EAAE,CAAA;IAC5B,MAAM,WAAW,GAAa,EAAE,CAAA;IAEhC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAA,eAAU,EAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1B,IAAI,OAAO,EAAE,SAAS,EAAE,CAAC;gBACvB,IAAA,kBAAa,EAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;gBAC/C,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YAC7B,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YACzB,CAAC;YACD,SAAQ;QACV,CAAC;QAED,IAAA,cAAS,EAAC,IAAA,cAAO,EAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;QAClD,IAAA,kBAAa,EAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QAC/C,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACzB,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,CAAA;AAC1C,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare function printSummary(args: {
|
|
2
|
+
type: string;
|
|
3
|
+
name: string;
|
|
4
|
+
created: string[];
|
|
5
|
+
skipped: string[];
|
|
6
|
+
overwritten?: string[];
|
|
7
|
+
configUpdated?: {
|
|
8
|
+
path: string;
|
|
9
|
+
};
|
|
10
|
+
nextSteps: string[];
|
|
11
|
+
directory: string;
|
|
12
|
+
}): void;
|
|
13
|
+
//# sourceMappingURL=log.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../../../src/commands/generate/utils/log.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,CAAC,IAAI,EAAE;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;IACtB,aAAa,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;IAChC,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;CAClB,QA+CA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.printSummary = printSummary;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
function printSummary(args) {
|
|
6
|
+
const { type, name, created, skipped, overwritten, configUpdated, nextSteps, directory, } = args;
|
|
7
|
+
console.log(`\n✔ Generated ${type}: ${name}\n`);
|
|
8
|
+
if (created.length > 0) {
|
|
9
|
+
console.log("Created files:");
|
|
10
|
+
for (const file of created) {
|
|
11
|
+
console.log(` + ${(0, path_1.relative)(directory, file)}`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
if (overwritten && overwritten.length > 0) {
|
|
15
|
+
console.log("\nOverwritten:");
|
|
16
|
+
for (const file of overwritten) {
|
|
17
|
+
console.log(` ↻ ${(0, path_1.relative)(directory, file)}`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (skipped.length > 0) {
|
|
21
|
+
console.log("\nSkipped (already exist):");
|
|
22
|
+
for (const file of skipped) {
|
|
23
|
+
console.log(` - ${(0, path_1.relative)(directory, file)}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (configUpdated) {
|
|
27
|
+
console.log(`\nUpdated: ${(0, path_1.relative)(directory, configUpdated.path)}`);
|
|
28
|
+
}
|
|
29
|
+
if (nextSteps.length > 0) {
|
|
30
|
+
console.log("\nNext steps:");
|
|
31
|
+
for (const step of nextSteps) {
|
|
32
|
+
console.log(` → ${step}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
console.log();
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=log.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../../../src/commands/generate/utils/log.ts"],"names":[],"mappings":";;AAEA,oCAwDC;AA1DD,+BAA+B;AAE/B,SAAgB,YAAY,CAAC,IAS5B;IACC,MAAM,EACJ,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,OAAO,EACP,WAAW,EACX,aAAa,EACb,SAAS,EACT,SAAS,GACV,GAAG,IAAI,CAAA;IAER,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,KAAK,IAAI,IAAI,CAAC,CAAA;IAE/C,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAA;QAC7B,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;YAC3B,OAAO,CAAC,GAAG,CAAC,OAAO,IAAA,eAAQ,EAAC,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,CAAA;QACjD,CAAC;IACH,CAAC;IAED,IAAI,WAAW,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1C,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAA;QAC7B,KAAK,MAAM,IAAI,IAAI,WAAW,EAAE,CAAC;YAC/B,OAAO,CAAC,GAAG,CAAC,OAAO,IAAA,eAAQ,EAAC,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,CAAA;QACjD,CAAC;IACH,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAA;QACzC,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;YAC3B,OAAO,CAAC,GAAG,CAAC,OAAO,IAAA,eAAQ,EAAC,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,CAAA;QACjD,CAAC;IACH,CAAC;IAED,IAAI,aAAa,EAAE,CAAC;QAClB,OAAO,CAAC,GAAG,CAAC,cAAc,IAAA,eAAQ,EAAC,SAAS,EAAE,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACtE,CAAC;IAED,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzB,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;QAC5B,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE,CAAC;YAC7B,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,CAAA;QAC5B,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,EAAE,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type FieldInfo = {
|
|
2
|
+
name: string;
|
|
3
|
+
dataType: string;
|
|
4
|
+
nullable: boolean;
|
|
5
|
+
primaryKey: boolean;
|
|
6
|
+
hasDefault: boolean;
|
|
7
|
+
enumChoices?: string[];
|
|
8
|
+
searchable?: boolean;
|
|
9
|
+
computed?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export type EntityInfo = {
|
|
12
|
+
name: string;
|
|
13
|
+
fields: FieldInfo[];
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Load all DML entities from a module's models/ directory.
|
|
17
|
+
* Returns structured metadata for each entity.
|
|
18
|
+
*/
|
|
19
|
+
export declare function introspectModule(directory: string, moduleName: string): EntityInfo[];
|
|
20
|
+
export declare function fieldToTsType(field: FieldInfo): string;
|
|
21
|
+
export declare function fieldToZodType(field: FieldInfo): string;
|
|
22
|
+
//# sourceMappingURL=model-introspector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-introspector.d.ts","sourceRoot":"","sources":["../../../../src/commands/generate/utils/model-introspector.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,OAAO,CAAA;IACjB,UAAU,EAAE,OAAO,CAAA;IACnB,UAAU,EAAE,OAAO,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;IACtB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,SAAS,EAAE,CAAA;CACpB,CAAA;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACjB,UAAU,EAAE,CA4Dd;AAeD,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAKtD;AAYD,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAMvD"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.introspectModule = introspectModule;
|
|
4
|
+
exports.fieldToTsType = fieldToTsType;
|
|
5
|
+
exports.fieldToZodType = fieldToZodType;
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
/**
|
|
9
|
+
* Load all DML entities from a module's models/ directory.
|
|
10
|
+
* Returns structured metadata for each entity.
|
|
11
|
+
*/
|
|
12
|
+
function introspectModule(directory, moduleName) {
|
|
13
|
+
const modelsDir = (0, path_1.join)(directory, "src", "modules", moduleName, "models");
|
|
14
|
+
const files = (0, fs_1.readdirSync)(modelsDir).filter((f) => f.endsWith(".ts") && f !== "index.ts");
|
|
15
|
+
const entities = [];
|
|
16
|
+
for (const file of files) {
|
|
17
|
+
const modelPath = (0, path_1.join)(modelsDir, file);
|
|
18
|
+
const mod = require(modelPath);
|
|
19
|
+
const entity = mod.default || mod;
|
|
20
|
+
// Skip non-DML exports
|
|
21
|
+
if (!entity?.parse) {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
const parsed = entity.parse();
|
|
25
|
+
const fields = [];
|
|
26
|
+
for (const [key, property] of Object.entries(parsed.schema)) {
|
|
27
|
+
// Skip items without a parse method
|
|
28
|
+
if (typeof property.parse !== "function") {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const meta = property.parse(key);
|
|
32
|
+
// Skip relationships (no fieldName)
|
|
33
|
+
if (!("fieldName" in meta)) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
// Skip auto-added timestamp fields
|
|
37
|
+
if (["created_at", "updated_at", "deleted_at"].includes(key)) {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
// Skip computed fields
|
|
41
|
+
if (meta.computed) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
fields.push({
|
|
45
|
+
name: meta.fieldName,
|
|
46
|
+
dataType: meta.dataType.name,
|
|
47
|
+
nullable: meta.nullable,
|
|
48
|
+
primaryKey: !!meta.primaryKey,
|
|
49
|
+
hasDefault: meta.defaultValue !== undefined,
|
|
50
|
+
enumChoices: meta.dataType.options?.choices,
|
|
51
|
+
searchable: meta.dataType.options?.searchable,
|
|
52
|
+
computed: meta.computed,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
entities.push({ name: parsed.name, fields });
|
|
56
|
+
}
|
|
57
|
+
return entities;
|
|
58
|
+
}
|
|
59
|
+
const TS_TYPE_MAP = {
|
|
60
|
+
text: "string",
|
|
61
|
+
id: "string",
|
|
62
|
+
boolean: "boolean",
|
|
63
|
+
number: "number",
|
|
64
|
+
float: "number",
|
|
65
|
+
bigNumber: "number",
|
|
66
|
+
serial: "number",
|
|
67
|
+
dateTime: "Date",
|
|
68
|
+
json: "Record<string, unknown>",
|
|
69
|
+
array: "string[]",
|
|
70
|
+
};
|
|
71
|
+
function fieldToTsType(field) {
|
|
72
|
+
if (field.dataType === "enum" && field.enumChoices) {
|
|
73
|
+
return field.enumChoices.map((c) => `"${c}"`).join(" | ");
|
|
74
|
+
}
|
|
75
|
+
return TS_TYPE_MAP[field.dataType] || "unknown";
|
|
76
|
+
}
|
|
77
|
+
const ZOD_TYPE_MAP = {
|
|
78
|
+
text: "z.string()",
|
|
79
|
+
boolean: "z.boolean()",
|
|
80
|
+
number: "z.number()",
|
|
81
|
+
float: "z.number()",
|
|
82
|
+
bigNumber: "z.number()",
|
|
83
|
+
json: "z.record(z.unknown())",
|
|
84
|
+
array: "z.array(z.string())",
|
|
85
|
+
};
|
|
86
|
+
function fieldToZodType(field) {
|
|
87
|
+
if (field.dataType === "enum" && field.enumChoices) {
|
|
88
|
+
const choices = field.enumChoices.map((c) => `"${c}"`).join(", ");
|
|
89
|
+
return `z.enum([${choices}])`;
|
|
90
|
+
}
|
|
91
|
+
return ZOD_TYPE_MAP[field.dataType] || "z.unknown()";
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=model-introspector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-introspector.js","sourceRoot":"","sources":["../../../../src/commands/generate/utils/model-introspector.ts"],"names":[],"mappings":";;AAuBA,4CA+DC;AA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CAAC;QACnD,OAAO,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC3D,CAAC;IACD,OAAO,WAAW,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,SAAS,CAAA;AACjD,CAAC;AAED,MAAM,YAAY,GAA2B;IAC3C,IAAI,EAAE,YAAY;IAClB,OAAO,EAAE,aAAa;IACtB,MAAM,EAAE,YAAY;IACpB,KAAK,EAAE,YAAY;IACnB,SAAS,EAAE,YAAY;IACvB,IAAI,EAAE,uBAAuB;IAC7B,KAAK,EAAE,qBAAqB;CAC7B,CAAA;AAED,SAAgB,cAAc,CAAC,KAAgB;IAC7C,IAAI,KAAK,CAAC,QAAQ,KAAK,MAAM,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC;QACnD,MAAM,OAAO,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACjE,OAAO,WAAW,OAAO,IAAI,CAAA;IAC/B,CAAC;IACD,OAAO,YAAY,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,aAAa,CAAA;AACtD,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Naming convention helpers for code generators.
|
|
3
|
+
*
|
|
4
|
+
* Input names follow these conventions:
|
|
5
|
+
* - Module/Entity names: PascalCase (Blog, BlogPost)
|
|
6
|
+
* - Workflow/subscriber/job names: kebab-case (publish-post)
|
|
7
|
+
* - Route paths: slash-separated (admin/posts)
|
|
8
|
+
*/
|
|
9
|
+
/** "BlogPost" → "blog-post", "blog-post" → "blog-post" */
|
|
10
|
+
export declare function toKebabCase(str: string): string;
|
|
11
|
+
/** "blog-post" → "BlogPost", "BlogPost" → "BlogPost" */
|
|
12
|
+
export declare function toPascalCase(str: string): string;
|
|
13
|
+
/** "blog-post" → "blogPost", "BlogPost" → "blogPost" */
|
|
14
|
+
export declare function toCamelCase(str: string): string;
|
|
15
|
+
/** "BlogPost" → "blog_post" */
|
|
16
|
+
export declare function toSnakeCase(str: string): string;
|
|
17
|
+
/** "Post" → "posts", "Category" → "categories", "Status" → "statuses" */
|
|
18
|
+
export declare function pluralize(str: string): string;
|
|
19
|
+
/** "BlogPost" → "blog-posts" (kebab + pluralize) */
|
|
20
|
+
export declare function toResourcePath(entity: string): string;
|
|
21
|
+
//# sourceMappingURL=naming.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"naming.d.ts","sourceRoot":"","sources":["../../../../src/commands/generate/utils/naming.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,0DAA0D;AAC1D,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAM/C;AAED,wDAAwD;AACxD,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIhD;AAED,wDAAwD;AACxD,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG/C;AAED,+BAA+B;AAC/B,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE/C;AAcD,yEAAyE;AACzE,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAqB7C;AAED,oDAAoD;AACpD,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAErD"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Naming convention helpers for code generators.
|
|
4
|
+
*
|
|
5
|
+
* Input names follow these conventions:
|
|
6
|
+
* - Module/Entity names: PascalCase (Blog, BlogPost)
|
|
7
|
+
* - Workflow/subscriber/job names: kebab-case (publish-post)
|
|
8
|
+
* - Route paths: slash-separated (admin/posts)
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.toKebabCase = toKebabCase;
|
|
12
|
+
exports.toPascalCase = toPascalCase;
|
|
13
|
+
exports.toCamelCase = toCamelCase;
|
|
14
|
+
exports.toSnakeCase = toSnakeCase;
|
|
15
|
+
exports.pluralize = pluralize;
|
|
16
|
+
exports.toResourcePath = toResourcePath;
|
|
17
|
+
/** "BlogPost" → "blog-post", "blog-post" → "blog-post" */
|
|
18
|
+
function toKebabCase(str) {
|
|
19
|
+
return str
|
|
20
|
+
.replace(/([a-z0-9])([A-Z])/g, "$1-$2")
|
|
21
|
+
.replace(/([A-Z])([A-Z][a-z])/g, "$1-$2")
|
|
22
|
+
.replace(/[_\s]+/g, "-")
|
|
23
|
+
.toLowerCase();
|
|
24
|
+
}
|
|
25
|
+
/** "blog-post" → "BlogPost", "BlogPost" → "BlogPost" */
|
|
26
|
+
function toPascalCase(str) {
|
|
27
|
+
return str
|
|
28
|
+
.replace(/[-_\s]+(.)?/g, (_, c) => (c ? c.toUpperCase() : ""))
|
|
29
|
+
.replace(/^(.)/, (_, c) => c.toUpperCase());
|
|
30
|
+
}
|
|
31
|
+
/** "blog-post" → "blogPost", "BlogPost" → "blogPost" */
|
|
32
|
+
function toCamelCase(str) {
|
|
33
|
+
const pascal = toPascalCase(str);
|
|
34
|
+
return pascal.charAt(0).toLowerCase() + pascal.slice(1);
|
|
35
|
+
}
|
|
36
|
+
/** "BlogPost" → "blog_post" */
|
|
37
|
+
function toSnakeCase(str) {
|
|
38
|
+
return toKebabCase(str).replace(/-/g, "_");
|
|
39
|
+
}
|
|
40
|
+
const IRREGULAR_PLURALS = {
|
|
41
|
+
person: "people",
|
|
42
|
+
child: "children",
|
|
43
|
+
man: "men",
|
|
44
|
+
woman: "women",
|
|
45
|
+
mouse: "mice",
|
|
46
|
+
goose: "geese",
|
|
47
|
+
ox: "oxen",
|
|
48
|
+
foot: "feet",
|
|
49
|
+
tooth: "teeth",
|
|
50
|
+
};
|
|
51
|
+
/** "Post" → "posts", "Category" → "categories", "Status" → "statuses" */
|
|
52
|
+
function pluralize(str) {
|
|
53
|
+
const lower = str.toLowerCase();
|
|
54
|
+
if (IRREGULAR_PLURALS[lower]) {
|
|
55
|
+
// Preserve the original casing of the first char
|
|
56
|
+
const plural = IRREGULAR_PLURALS[lower];
|
|
57
|
+
return str.charAt(0) === str.charAt(0).toUpperCase()
|
|
58
|
+
? plural.charAt(0).toUpperCase() + plural.slice(1)
|
|
59
|
+
: plural;
|
|
60
|
+
}
|
|
61
|
+
if (lower.endsWith("s") || lower.endsWith("x") || lower.endsWith("z") ||
|
|
62
|
+
lower.endsWith("ch") || lower.endsWith("sh")) {
|
|
63
|
+
return str + "es";
|
|
64
|
+
}
|
|
65
|
+
if (lower.endsWith("y") && !/[aeiou]y$/i.test(str)) {
|
|
66
|
+
return str.slice(0, -1) + "ies";
|
|
67
|
+
}
|
|
68
|
+
return str + "s";
|
|
69
|
+
}
|
|
70
|
+
/** "BlogPost" → "blog-posts" (kebab + pluralize) */
|
|
71
|
+
function toResourcePath(entity) {
|
|
72
|
+
return pluralize(toKebabCase(entity));
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=naming.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"naming.js","sourceRoot":"","sources":["../../../../src/commands/generate/utils/naming.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;AAGH,kCAMC;AAGD,oCAIC;AAGD,kCAGC;AAGD,kCAEC;AAeD,8BAqBC;AAGD,wCAEC;AAlED,0DAA0D;AAC1D,SAAgB,WAAW,CAAC,GAAW;IACrC,OAAO,GAAG;SACP,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC;SACtC,OAAO,CAAC,sBAAsB,EAAE,OAAO,CAAC;SACxC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC;SACvB,WAAW,EAAE,CAAA;AAClB,CAAC;AAED,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AK,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE;YAClD,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAClD,CAAC,CAAC,MAAM,CAAA;IACZ,CAAC;IAED,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC;QACjE,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACjD,OAAO,GAAG,GAAG,IAAI,CAAA;IACnB,CAAC;IAED,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACnD,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,CAAA;IACjC,CAAC;IAED,OAAO,GAAG,GAAG,GAAG,CAAA;AAClB,CAAC;AAED,oDAAoD;AACpD,SAAgB,cAAc,CAAC,MAAc;IAC3C,OAAO,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAA;AACvC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../../src/commands/generate/workflow.ts"],"names":[],"mappings":"AAKA,KAAK,OAAO,GAAG;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,wBAA8B,gBAAgB,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,iBA6D1E"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = generateWorkflow;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const file_writer_1 = require("./utils/file-writer");
|
|
6
|
+
const naming_1 = require("./utils/naming");
|
|
7
|
+
const log_1 = require("./utils/log");
|
|
8
|
+
async function generateWorkflow({ name, directory }) {
|
|
9
|
+
const kebabName = (0, naming_1.toKebabCase)(name);
|
|
10
|
+
const camelName = (0, naming_1.toCamelCase)(name);
|
|
11
|
+
const pascalName = (0, naming_1.toPascalCase)(name);
|
|
12
|
+
const filePath = (0, path_1.join)(directory, "src", "workflows", `${kebabName}.ts`);
|
|
13
|
+
const content = `import {
|
|
14
|
+
createStep,
|
|
15
|
+
createWorkflow,
|
|
16
|
+
StepResponse,
|
|
17
|
+
WorkflowResponse,
|
|
18
|
+
} from "@acmekit/framework/workflows-sdk"
|
|
19
|
+
import type { WorkflowData } from "@acmekit/framework/workflows-sdk"
|
|
20
|
+
|
|
21
|
+
type ${pascalName}Input = {
|
|
22
|
+
// TODO: define input fields
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
type ${pascalName}Output = {
|
|
26
|
+
// TODO: define output fields
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const ${camelName}StepId = "${kebabName}-step"
|
|
30
|
+
|
|
31
|
+
const ${camelName}Step = createStep(
|
|
32
|
+
${camelName}StepId,
|
|
33
|
+
async (input: ${pascalName}Input, { container }) => {
|
|
34
|
+
// TODO: implement step logic
|
|
35
|
+
const result = {}
|
|
36
|
+
return new StepResponse(result, input)
|
|
37
|
+
},
|
|
38
|
+
async (compensationData, { container }) => {
|
|
39
|
+
// TODO: implement compensation (rollback) logic
|
|
40
|
+
}
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
export const ${camelName}WorkflowId = "${kebabName}"
|
|
44
|
+
|
|
45
|
+
export const ${camelName}Workflow = createWorkflow(
|
|
46
|
+
${camelName}WorkflowId,
|
|
47
|
+
(input: WorkflowData<${pascalName}Input>) => {
|
|
48
|
+
const result = ${camelName}Step(input)
|
|
49
|
+
return new WorkflowResponse(result)
|
|
50
|
+
}
|
|
51
|
+
)
|
|
52
|
+
`;
|
|
53
|
+
const result = (0, file_writer_1.writeFiles)([{ path: filePath, content }]);
|
|
54
|
+
(0, log_1.printSummary)({
|
|
55
|
+
type: "workflow",
|
|
56
|
+
name: kebabName,
|
|
57
|
+
...result,
|
|
58
|
+
nextSteps: [
|
|
59
|
+
`Define input/output types in src/workflows/${kebabName}.ts`,
|
|
60
|
+
"Implement the step logic and compensation",
|
|
61
|
+
`Use the workflow in an API route: ${camelName}Workflow(req.scope).run({ input: { ... } })`,
|
|
62
|
+
],
|
|
63
|
+
directory,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=workflow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow.js","sourceRoot":"","sources":["../../../src/commands/generate/workflow.ts"],"names":[],"mappings":";;AAUA,mCA6DC;AAvED,+BAA2B;AAC3B,qDAAgD;AAChD,2CAAuE;AACvE,qCAA0C;AAO3B,KAAK,UAAU,gBAAgB,CAAC,EAAE,IAAI,EAAE,SAAS,EAAW;IACzE,MAAM,SAAS,GAAG,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAA;IACnC,MAAM,SAAS,GAAG,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAA;IACnC,MAAM,UAAU,GAAG,IAAA,qBAAY,EAAC,IAAI,CAAC,CAAA;IAErC,MAAM,QAAQ,GAAG,IAAA,WAAI,EAAC,SAAS,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,SAAS,KAAK,CAAC,CAAA;IAEvE,MAAM,OAAO,GAAG;;;;;;;;OAQX,UAAU;;;;OAIV,UAAU;;;;QAIT,SAAS,aAAa,SAAS;;QAE/B,SAAS;IACb,SAAS;kBACK,UAAU;;;;;;;;;;eAUb,SAAS,iBAAiB,SAAS;;eAEnC,SAAS;IACpB,SAAS;yBACY,UAAU;qBACd,SAAS;;;;CAI7B,CAAA;IAEC,MAAM,MAAM,GAAG,IAAA,wBAAU,EAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC,CAAA;IAExD,IAAA,kBAAY,EAAC;QACX,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,SAAS;QACf,GAAG,MAAM;QACT,SAAS,EAAE;YACT,8CAA8C,SAAS,KAAK;YAC5D,2CAA2C;YAC3C,qCAAqC,SAAS,6CAA6C;SAC5F;QACD,SAAS;KACV,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PluginDetails } from "@acmekit/framework/types";
|
|
2
|
+
import { Express } from "express";
|
|
3
|
+
type Options = {
|
|
4
|
+
app: Express;
|
|
5
|
+
rootDirectory: string;
|
|
6
|
+
plugins: PluginDetails[];
|
|
7
|
+
};
|
|
8
|
+
export default function docsLoader({ app, rootDirectory, plugins, }: Options): Promise<Express>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=docs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/loaders/docs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAExD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAQjC,KAAK,OAAO,GAAG;IACb,GAAG,EAAE,OAAO,CAAA;IACZ,aAAa,EAAE,MAAM,CAAA;IACrB,OAAO,EAAE,aAAa,EAAE,CAAA;CACzB,CAAA;AAmDD,wBAA8B,UAAU,CAAC,EACvC,GAAG,EACH,aAAa,EACb,OAAO,GACR,EAAE,OAAO,oBAoDT"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = docsLoader;
|
|
7
|
+
const logger_1 = require("@acmekit/framework/logger");
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const DOCS_RELATIVE_OUTPUT_DIR = "./public/docs";
|
|
11
|
+
const DEFAULT_DOCS_PATH = "/docs";
|
|
12
|
+
const NOT_ALLOWED_PATHS = ["/auth", "/client", "/admin"];
|
|
13
|
+
function slugifyPluginName(name) {
|
|
14
|
+
return name
|
|
15
|
+
.replace(/^@[^/]+\//, "")
|
|
16
|
+
.replace(/[^a-z0-9-]/gi, "-")
|
|
17
|
+
.toLowerCase();
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Loads docs config.ts using esbuild (same loader as vite plugin).
|
|
21
|
+
* Inlined here to avoid importing the vite plugin at runtime.
|
|
22
|
+
*/
|
|
23
|
+
function loadDocsConfig(docsDir) {
|
|
24
|
+
const tsPath = path_1.default.join(docsDir, "config.ts");
|
|
25
|
+
const jsPath = path_1.default.join(docsDir, "config.js");
|
|
26
|
+
const configPath = fs_1.default.existsSync(tsPath)
|
|
27
|
+
? tsPath
|
|
28
|
+
: fs_1.default.existsSync(jsPath)
|
|
29
|
+
? jsPath
|
|
30
|
+
: null;
|
|
31
|
+
if (!configPath) {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
const { transformSync } = require("esbuild");
|
|
36
|
+
const raw = fs_1.default.readFileSync(configPath, "utf-8");
|
|
37
|
+
const ext = path_1.default.extname(configPath);
|
|
38
|
+
const { code } = transformSync(raw, {
|
|
39
|
+
loader: ext === ".ts" ? "ts" : "js",
|
|
40
|
+
format: "cjs",
|
|
41
|
+
});
|
|
42
|
+
const mod = { exports: {} };
|
|
43
|
+
new Function("module", "exports", code)(mod, mod.exports);
|
|
44
|
+
return mod.exports.default || mod.exports;
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async function docsLoader({ app, rootDirectory, plugins, }) {
|
|
51
|
+
const projectDocsDir = path_1.default.join(rootDirectory, "src", "docs");
|
|
52
|
+
// No src/docs/ folder → no docs
|
|
53
|
+
if (!fs_1.default.existsSync(projectDocsDir)) {
|
|
54
|
+
return app;
|
|
55
|
+
}
|
|
56
|
+
// Load config.ts from src/docs/
|
|
57
|
+
const config = loadDocsConfig(projectDocsDir);
|
|
58
|
+
const docsPath = config?.path || DEFAULT_DOCS_PATH;
|
|
59
|
+
if (NOT_ALLOWED_PATHS.includes(docsPath)) {
|
|
60
|
+
logger_1.logger.error(`The docs path "${docsPath}" is reserved. Please set a different path in src/docs/config.ts. Reserved: ${NOT_ALLOWED_PATHS.join(", ")}.`);
|
|
61
|
+
}
|
|
62
|
+
// Collect plugin docs sources
|
|
63
|
+
const pluginDocsPaths = [];
|
|
64
|
+
const pluginSources = [];
|
|
65
|
+
for (const plugin of plugins) {
|
|
66
|
+
if (!plugin.docs) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (plugin.docs.type === "local") {
|
|
70
|
+
pluginSources.push({
|
|
71
|
+
slug: slugifyPluginName(plugin.name),
|
|
72
|
+
resolve: plugin.docs.resolve,
|
|
73
|
+
type: "local",
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
pluginDocsPaths.push(plugin.docs.resolve);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const bundlerOptions = {
|
|
81
|
+
path: docsPath,
|
|
82
|
+
outDir: path_1.default.join(rootDirectory, DOCS_RELATIVE_OUTPUT_DIR),
|
|
83
|
+
sources: [rootDirectory],
|
|
84
|
+
plugins: pluginDocsPaths,
|
|
85
|
+
pluginSources: pluginSources.length ? pluginSources : undefined,
|
|
86
|
+
backendUrl: config?.backendUrl,
|
|
87
|
+
};
|
|
88
|
+
if (process.env.NODE_ENV === "development") {
|
|
89
|
+
return initDevelopmentServer(app, bundlerOptions);
|
|
90
|
+
}
|
|
91
|
+
return serveProductionBuild(app, bundlerOptions);
|
|
92
|
+
}
|
|
93
|
+
async function initDevelopmentServer(app, options) {
|
|
94
|
+
try {
|
|
95
|
+
const { develop } = await import("@acmekit/docs-bundler");
|
|
96
|
+
const docsMiddleware = await develop(options);
|
|
97
|
+
app.use(options.path, docsMiddleware);
|
|
98
|
+
}
|
|
99
|
+
catch (err) {
|
|
100
|
+
if (err.code === "MODULE_NOT_FOUND" ||
|
|
101
|
+
err.code === "ERR_MODULE_NOT_FOUND") {
|
|
102
|
+
logger_1.logger.warn(`src/docs/ found but @acmekit/docs-bundler is not installed. ` +
|
|
103
|
+
`Run "npm add @acmekit/docs-bundler" to enable docs.`);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
throw err;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return app;
|
|
110
|
+
}
|
|
111
|
+
async function serveProductionBuild(app, options) {
|
|
112
|
+
try {
|
|
113
|
+
const { serve } = await import("@acmekit/docs-bundler");
|
|
114
|
+
const docsRoute = await serve(options);
|
|
115
|
+
app.use(options.path, docsRoute);
|
|
116
|
+
}
|
|
117
|
+
catch (err) {
|
|
118
|
+
if (err.code === "MODULE_NOT_FOUND" ||
|
|
119
|
+
err.code === "ERR_MODULE_NOT_FOUND") {
|
|
120
|
+
logger_1.logger.warn(`src/docs/ found but @acmekit/docs-bundler is not installed. ` +
|
|
121
|
+
`Run "npm add @acmekit/docs-bundler" to enable docs.`);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
throw err;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return app;
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=docs.js.map
|