@geekmidas/cli 0.2.4 → 0.4.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/README.md +488 -71
- package/dist/{EndpointGenerator-C73wNoih.cjs → EndpointGenerator-BxNCkus4.cjs} +60 -6
- package/dist/EndpointGenerator-BxNCkus4.cjs.map +1 -0
- package/dist/{EndpointGenerator-CWh18d92.mjs → EndpointGenerator-CzDhG7Or.mjs} +60 -6
- package/dist/EndpointGenerator-CzDhG7Or.mjs.map +1 -0
- package/dist/OpenApiTsGenerator-NBNEoaeO.cjs +501 -0
- package/dist/OpenApiTsGenerator-NBNEoaeO.cjs.map +1 -0
- package/dist/OpenApiTsGenerator-q3aWNkuM.mjs +495 -0
- package/dist/OpenApiTsGenerator-q3aWNkuM.mjs.map +1 -0
- package/dist/build/index.cjs +4 -4
- package/dist/build/index.mjs +4 -4
- package/dist/build/manifests.cjs +3 -2
- package/dist/build/manifests.mjs +2 -2
- package/dist/{build-BVng9MQX.cjs → build-CWtHnJMQ.cjs} +19 -17
- package/dist/build-CWtHnJMQ.cjs.map +1 -0
- package/dist/{build-BqexeI-W.mjs → build-DyDgu_D1.mjs} +20 -18
- package/dist/build-DyDgu_D1.mjs.map +1 -0
- package/dist/{config-U-mdW-7Y.mjs → config-AFmFKmU0.mjs} +3 -3
- package/dist/config-AFmFKmU0.mjs.map +1 -0
- package/dist/{config-D1EpSGk6.cjs → config-BVIJpAsa.cjs} +3 -3
- package/dist/config-BVIJpAsa.cjs.map +1 -0
- package/dist/config.cjs +1 -1
- package/dist/config.mjs +1 -1
- package/dist/dev/index.cjs +5 -4
- package/dist/dev/index.mjs +4 -4
- package/dist/{dev-DbtyToc7.cjs → dev-CgDYC4o8.cjs} +95 -31
- package/dist/dev-CgDYC4o8.cjs.map +1 -0
- package/dist/{dev-DnGYXuMn.mjs → dev-CpA8AQPX.mjs} +90 -32
- package/dist/dev-CpA8AQPX.mjs.map +1 -0
- package/dist/generators/EndpointGenerator.cjs +1 -1
- package/dist/generators/EndpointGenerator.mjs +1 -1
- package/dist/generators/OpenApiTsGenerator.cjs +3 -0
- package/dist/generators/OpenApiTsGenerator.mjs +3 -0
- package/dist/generators/index.cjs +1 -1
- package/dist/generators/index.mjs +1 -1
- package/dist/index.cjs +16 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +16 -10
- package/dist/index.mjs.map +1 -1
- package/dist/manifests-C2eMoMUm.mjs +68 -0
- package/dist/manifests-C2eMoMUm.mjs.map +1 -0
- package/dist/manifests-CK1VV_pM.cjs +80 -0
- package/dist/manifests-CK1VV_pM.cjs.map +1 -0
- package/dist/openapi-DRTRGhTt.mjs +50 -0
- package/dist/openapi-DRTRGhTt.mjs.map +1 -0
- package/dist/openapi-DhK4b0lB.cjs +56 -0
- package/dist/openapi-DhK4b0lB.cjs.map +1 -0
- package/dist/openapi.cjs +4 -3
- package/dist/openapi.mjs +4 -3
- package/docs/OPENAPI_TYPESCRIPT_DESIGN.md +408 -0
- package/docs/manifest-refactor-design.md +287 -0
- package/package.json +10 -3
- package/src/__tests__/openapi.spec.ts +78 -63
- package/src/build/__tests__/index-new.spec.ts +43 -72
- package/src/build/__tests__/manifests.spec.ts +346 -0
- package/src/build/index.ts +59 -62
- package/src/build/manifests.ts +85 -13
- package/src/build/types.ts +13 -2
- package/src/config.ts +4 -2
- package/src/dev/__tests__/index.spec.ts +98 -1
- package/src/dev/index.ts +152 -25
- package/src/generators/EndpointGenerator.ts +69 -5
- package/src/generators/OpenApiTsGenerator.ts +798 -0
- package/src/index.ts +6 -3
- package/src/openapi.ts +36 -15
- package/src/types.ts +23 -7
- package/dist/EndpointGenerator-C73wNoih.cjs.map +0 -1
- package/dist/EndpointGenerator-CWh18d92.mjs.map +0 -1
- package/dist/build-BVng9MQX.cjs.map +0 -1
- package/dist/build-BqexeI-W.mjs.map +0 -1
- package/dist/config-D1EpSGk6.cjs.map +0 -1
- package/dist/config-U-mdW-7Y.mjs.map +0 -1
- package/dist/dev-DbtyToc7.cjs.map +0 -1
- package/dist/dev-DnGYXuMn.mjs.map +0 -1
- package/dist/manifests-BrJXpHrf.mjs +0 -21
- package/dist/manifests-BrJXpHrf.mjs.map +0 -1
- package/dist/manifests-D0saShvH.cjs +0 -27
- package/dist/manifests-D0saShvH.cjs.map +0 -1
- package/dist/openapi-BTHbPrxS.mjs +0 -36
- package/dist/openapi-BTHbPrxS.mjs.map +0 -1
- package/dist/openapi-CewcfoRH.cjs +0 -42
- package/dist/openapi-CewcfoRH.cjs.map +0 -1
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { join, relative } from "path";
|
|
2
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
3
|
+
|
|
4
|
+
//#region src/build/manifests.ts
|
|
5
|
+
const logger = console;
|
|
6
|
+
async function generateAwsManifest(outputDir, routes, functions, crons, subscribers) {
|
|
7
|
+
const manifestDir = join(outputDir, "manifest");
|
|
8
|
+
await mkdir(manifestDir, { recursive: true });
|
|
9
|
+
const awsRoutes = routes.filter((r) => r.method !== "ALL");
|
|
10
|
+
const content = `export const manifest = {
|
|
11
|
+
routes: ${JSON.stringify(awsRoutes, null, 2)},
|
|
12
|
+
functions: ${JSON.stringify(functions, null, 2)},
|
|
13
|
+
crons: ${JSON.stringify(crons, null, 2)},
|
|
14
|
+
subscribers: ${JSON.stringify(subscribers, null, 2)},
|
|
15
|
+
} as const;
|
|
16
|
+
|
|
17
|
+
// Derived types
|
|
18
|
+
export type Route = (typeof manifest.routes)[number];
|
|
19
|
+
export type Function = (typeof manifest.functions)[number];
|
|
20
|
+
export type Cron = (typeof manifest.crons)[number];
|
|
21
|
+
export type Subscriber = (typeof manifest.subscribers)[number];
|
|
22
|
+
|
|
23
|
+
// Useful union types
|
|
24
|
+
export type Authorizer = Route['authorizer'];
|
|
25
|
+
export type HttpMethod = Route['method'];
|
|
26
|
+
export type RoutePath = Route['path'];
|
|
27
|
+
`;
|
|
28
|
+
const manifestPath = join(manifestDir, "aws.ts");
|
|
29
|
+
await writeFile(manifestPath, content);
|
|
30
|
+
logger.log(`Generated AWS manifest with ${awsRoutes.length} routes, ${functions.length} functions, ${crons.length} crons, ${subscribers.length} subscribers`);
|
|
31
|
+
logger.log(`Manifest: ${relative(process.cwd(), manifestPath)}`);
|
|
32
|
+
}
|
|
33
|
+
async function generateServerManifest(outputDir, appInfo, routes, subscribers) {
|
|
34
|
+
const manifestDir = join(outputDir, "manifest");
|
|
35
|
+
await mkdir(manifestDir, { recursive: true });
|
|
36
|
+
const serverRoutes = routes.filter((r) => r.method !== "ALL").map((r) => ({
|
|
37
|
+
path: r.path,
|
|
38
|
+
method: r.method,
|
|
39
|
+
authorizer: r.authorizer
|
|
40
|
+
}));
|
|
41
|
+
const serverSubscribers = subscribers.map((s) => ({
|
|
42
|
+
name: s.name,
|
|
43
|
+
subscribedEvents: s.subscribedEvents
|
|
44
|
+
}));
|
|
45
|
+
const content = `export const manifest = {
|
|
46
|
+
app: ${JSON.stringify(appInfo, null, 2)},
|
|
47
|
+
routes: ${JSON.stringify(serverRoutes, null, 2)},
|
|
48
|
+
subscribers: ${JSON.stringify(serverSubscribers, null, 2)},
|
|
49
|
+
} as const;
|
|
50
|
+
|
|
51
|
+
// Derived types
|
|
52
|
+
export type Route = (typeof manifest.routes)[number];
|
|
53
|
+
export type Subscriber = (typeof manifest.subscribers)[number];
|
|
54
|
+
|
|
55
|
+
// Useful union types
|
|
56
|
+
export type Authorizer = Route['authorizer'];
|
|
57
|
+
export type HttpMethod = Route['method'];
|
|
58
|
+
export type RoutePath = Route['path'];
|
|
59
|
+
`;
|
|
60
|
+
const manifestPath = join(manifestDir, "server.ts");
|
|
61
|
+
await writeFile(manifestPath, content);
|
|
62
|
+
logger.log(`Generated server manifest with ${serverRoutes.length} routes, ${serverSubscribers.length} subscribers`);
|
|
63
|
+
logger.log(`Manifest: ${relative(process.cwd(), manifestPath)}`);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
//#endregion
|
|
67
|
+
export { generateAwsManifest, generateServerManifest };
|
|
68
|
+
//# sourceMappingURL=manifests-C2eMoMUm.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifests-C2eMoMUm.mjs","names":["outputDir: string","routes: RouteInfo[]","functions: FunctionInfo[]","crons: CronInfo[]","subscribers: SubscriberInfo[]","appInfo: ServerAppInfo"],"sources":["../src/build/manifests.ts"],"sourcesContent":["import { mkdir, writeFile } from 'node:fs/promises';\nimport { join, relative } from 'path';\nimport type {\n CronInfo,\n FunctionInfo,\n RouteInfo,\n SubscriberInfo,\n} from '../types';\n\nconst logger = console;\n\nexport type ManifestProvider = 'aws' | 'server';\n\nexport interface ServerAppInfo {\n handler: string;\n endpoints: string;\n}\n\nexport async function generateAwsManifest(\n outputDir: string,\n routes: RouteInfo[],\n functions: FunctionInfo[],\n crons: CronInfo[],\n subscribers: SubscriberInfo[],\n): Promise<void> {\n const manifestDir = join(outputDir, 'manifest');\n await mkdir(manifestDir, { recursive: true });\n\n // Filter out 'ALL' method routes (server-specific)\n const awsRoutes = routes.filter((r) => r.method !== 'ALL');\n\n const content = `export const manifest = {\n routes: ${JSON.stringify(awsRoutes, null, 2)},\n functions: ${JSON.stringify(functions, null, 2)},\n crons: ${JSON.stringify(crons, null, 2)},\n subscribers: ${JSON.stringify(subscribers, null, 2)},\n} as const;\n\n// Derived types\nexport type Route = (typeof manifest.routes)[number];\nexport type Function = (typeof manifest.functions)[number];\nexport type Cron = (typeof manifest.crons)[number];\nexport type Subscriber = (typeof manifest.subscribers)[number];\n\n// Useful union types\nexport type Authorizer = Route['authorizer'];\nexport type HttpMethod = Route['method'];\nexport type RoutePath = Route['path'];\n`;\n\n const manifestPath = join(manifestDir, 'aws.ts');\n await writeFile(manifestPath, content);\n\n logger.log(\n `Generated AWS manifest with ${awsRoutes.length} routes, ${functions.length} functions, ${crons.length} crons, ${subscribers.length} subscribers`,\n );\n logger.log(`Manifest: ${relative(process.cwd(), manifestPath)}`);\n}\n\nexport async function generateServerManifest(\n outputDir: string,\n appInfo: ServerAppInfo,\n routes: RouteInfo[],\n subscribers: SubscriberInfo[],\n): Promise<void> {\n const manifestDir = join(outputDir, 'manifest');\n await mkdir(manifestDir, { recursive: true });\n\n // For server, extract route metadata (path, method, authorizer)\n const serverRoutes = routes\n .filter((r) => r.method !== 'ALL')\n .map((r) => ({\n path: r.path,\n method: r.method,\n authorizer: r.authorizer,\n }));\n\n // Server subscribers only need name and events\n const serverSubscribers = subscribers.map((s) => ({\n name: s.name,\n subscribedEvents: s.subscribedEvents,\n }));\n\n const content = `export const manifest = {\n app: ${JSON.stringify(appInfo, null, 2)},\n routes: ${JSON.stringify(serverRoutes, null, 2)},\n subscribers: ${JSON.stringify(serverSubscribers, null, 2)},\n} as const;\n\n// Derived types\nexport type Route = (typeof manifest.routes)[number];\nexport type Subscriber = (typeof manifest.subscribers)[number];\n\n// Useful union types\nexport type Authorizer = Route['authorizer'];\nexport type HttpMethod = Route['method'];\nexport type RoutePath = Route['path'];\n`;\n\n const manifestPath = join(manifestDir, 'server.ts');\n await writeFile(manifestPath, content);\n\n logger.log(\n `Generated server manifest with ${serverRoutes.length} routes, ${serverSubscribers.length} subscribers`,\n );\n logger.log(`Manifest: ${relative(process.cwd(), manifestPath)}`);\n}\n"],"mappings":";;;;AASA,MAAM,SAAS;AASf,eAAsB,oBACpBA,WACAC,QACAC,WACAC,OACAC,aACe;CACf,MAAM,cAAc,KAAK,WAAW,WAAW;AAC/C,OAAM,MAAM,aAAa,EAAE,WAAW,KAAM,EAAC;CAG7C,MAAM,YAAY,OAAO,OAAO,CAAC,MAAM,EAAE,WAAW,MAAM;CAE1D,MAAM,WAAW;YACP,KAAK,UAAU,WAAW,MAAM,EAAE,CAAC;eAChC,KAAK,UAAU,WAAW,MAAM,EAAE,CAAC;WACvC,KAAK,UAAU,OAAO,MAAM,EAAE,CAAC;iBACzB,KAAK,UAAU,aAAa,MAAM,EAAE,CAAC;;;;;;;;;;;;;;CAepD,MAAM,eAAe,KAAK,aAAa,SAAS;AAChD,OAAM,UAAU,cAAc,QAAQ;AAEtC,QAAO,KACJ,8BAA8B,UAAU,OAAO,WAAW,UAAU,OAAO,cAAc,MAAM,OAAO,UAAU,YAAY,OAAO,cACrI;AACD,QAAO,KAAK,YAAY,SAAS,QAAQ,KAAK,EAAE,aAAa,CAAC,EAAE;AACjE;AAED,eAAsB,uBACpBJ,WACAK,SACAJ,QACAG,aACe;CACf,MAAM,cAAc,KAAK,WAAW,WAAW;AAC/C,OAAM,MAAM,aAAa,EAAE,WAAW,KAAM,EAAC;CAG7C,MAAM,eAAe,OAClB,OAAO,CAAC,MAAM,EAAE,WAAW,MAAM,CACjC,IAAI,CAAC,OAAO;EACX,MAAM,EAAE;EACR,QAAQ,EAAE;EACV,YAAY,EAAE;CACf,GAAE;CAGL,MAAM,oBAAoB,YAAY,IAAI,CAAC,OAAO;EAChD,MAAM,EAAE;EACR,kBAAkB,EAAE;CACrB,GAAE;CAEH,MAAM,WAAW;SACV,KAAK,UAAU,SAAS,MAAM,EAAE,CAAC;YAC9B,KAAK,UAAU,cAAc,MAAM,EAAE,CAAC;iBACjC,KAAK,UAAU,mBAAmB,MAAM,EAAE,CAAC;;;;;;;;;;;;CAa1D,MAAM,eAAe,KAAK,aAAa,YAAY;AACnD,OAAM,UAAU,cAAc,QAAQ;AAEtC,QAAO,KACJ,iCAAiC,aAAa,OAAO,WAAW,kBAAkB,OAAO,cAC3F;AACD,QAAO,KAAK,YAAY,SAAS,QAAQ,KAAK,EAAE,aAAa,CAAC,EAAE;AACjE"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
+
const path = require_chunk.__toESM(require("path"));
|
|
3
|
+
const node_fs_promises = require_chunk.__toESM(require("node:fs/promises"));
|
|
4
|
+
|
|
5
|
+
//#region src/build/manifests.ts
|
|
6
|
+
const logger = console;
|
|
7
|
+
async function generateAwsManifest(outputDir, routes, functions, crons, subscribers) {
|
|
8
|
+
const manifestDir = (0, path.join)(outputDir, "manifest");
|
|
9
|
+
await (0, node_fs_promises.mkdir)(manifestDir, { recursive: true });
|
|
10
|
+
const awsRoutes = routes.filter((r) => r.method !== "ALL");
|
|
11
|
+
const content = `export const manifest = {
|
|
12
|
+
routes: ${JSON.stringify(awsRoutes, null, 2)},
|
|
13
|
+
functions: ${JSON.stringify(functions, null, 2)},
|
|
14
|
+
crons: ${JSON.stringify(crons, null, 2)},
|
|
15
|
+
subscribers: ${JSON.stringify(subscribers, null, 2)},
|
|
16
|
+
} as const;
|
|
17
|
+
|
|
18
|
+
// Derived types
|
|
19
|
+
export type Route = (typeof manifest.routes)[number];
|
|
20
|
+
export type Function = (typeof manifest.functions)[number];
|
|
21
|
+
export type Cron = (typeof manifest.crons)[number];
|
|
22
|
+
export type Subscriber = (typeof manifest.subscribers)[number];
|
|
23
|
+
|
|
24
|
+
// Useful union types
|
|
25
|
+
export type Authorizer = Route['authorizer'];
|
|
26
|
+
export type HttpMethod = Route['method'];
|
|
27
|
+
export type RoutePath = Route['path'];
|
|
28
|
+
`;
|
|
29
|
+
const manifestPath = (0, path.join)(manifestDir, "aws.ts");
|
|
30
|
+
await (0, node_fs_promises.writeFile)(manifestPath, content);
|
|
31
|
+
logger.log(`Generated AWS manifest with ${awsRoutes.length} routes, ${functions.length} functions, ${crons.length} crons, ${subscribers.length} subscribers`);
|
|
32
|
+
logger.log(`Manifest: ${(0, path.relative)(process.cwd(), manifestPath)}`);
|
|
33
|
+
}
|
|
34
|
+
async function generateServerManifest(outputDir, appInfo, routes, subscribers) {
|
|
35
|
+
const manifestDir = (0, path.join)(outputDir, "manifest");
|
|
36
|
+
await (0, node_fs_promises.mkdir)(manifestDir, { recursive: true });
|
|
37
|
+
const serverRoutes = routes.filter((r) => r.method !== "ALL").map((r) => ({
|
|
38
|
+
path: r.path,
|
|
39
|
+
method: r.method,
|
|
40
|
+
authorizer: r.authorizer
|
|
41
|
+
}));
|
|
42
|
+
const serverSubscribers = subscribers.map((s) => ({
|
|
43
|
+
name: s.name,
|
|
44
|
+
subscribedEvents: s.subscribedEvents
|
|
45
|
+
}));
|
|
46
|
+
const content = `export const manifest = {
|
|
47
|
+
app: ${JSON.stringify(appInfo, null, 2)},
|
|
48
|
+
routes: ${JSON.stringify(serverRoutes, null, 2)},
|
|
49
|
+
subscribers: ${JSON.stringify(serverSubscribers, null, 2)},
|
|
50
|
+
} as const;
|
|
51
|
+
|
|
52
|
+
// Derived types
|
|
53
|
+
export type Route = (typeof manifest.routes)[number];
|
|
54
|
+
export type Subscriber = (typeof manifest.subscribers)[number];
|
|
55
|
+
|
|
56
|
+
// Useful union types
|
|
57
|
+
export type Authorizer = Route['authorizer'];
|
|
58
|
+
export type HttpMethod = Route['method'];
|
|
59
|
+
export type RoutePath = Route['path'];
|
|
60
|
+
`;
|
|
61
|
+
const manifestPath = (0, path.join)(manifestDir, "server.ts");
|
|
62
|
+
await (0, node_fs_promises.writeFile)(manifestPath, content);
|
|
63
|
+
logger.log(`Generated server manifest with ${serverRoutes.length} routes, ${serverSubscribers.length} subscribers`);
|
|
64
|
+
logger.log(`Manifest: ${(0, path.relative)(process.cwd(), manifestPath)}`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
//#endregion
|
|
68
|
+
Object.defineProperty(exports, 'generateAwsManifest', {
|
|
69
|
+
enumerable: true,
|
|
70
|
+
get: function () {
|
|
71
|
+
return generateAwsManifest;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
Object.defineProperty(exports, 'generateServerManifest', {
|
|
75
|
+
enumerable: true,
|
|
76
|
+
get: function () {
|
|
77
|
+
return generateServerManifest;
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
//# sourceMappingURL=manifests-CK1VV_pM.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifests-CK1VV_pM.cjs","names":["outputDir: string","routes: RouteInfo[]","functions: FunctionInfo[]","crons: CronInfo[]","subscribers: SubscriberInfo[]","appInfo: ServerAppInfo"],"sources":["../src/build/manifests.ts"],"sourcesContent":["import { mkdir, writeFile } from 'node:fs/promises';\nimport { join, relative } from 'path';\nimport type {\n CronInfo,\n FunctionInfo,\n RouteInfo,\n SubscriberInfo,\n} from '../types';\n\nconst logger = console;\n\nexport type ManifestProvider = 'aws' | 'server';\n\nexport interface ServerAppInfo {\n handler: string;\n endpoints: string;\n}\n\nexport async function generateAwsManifest(\n outputDir: string,\n routes: RouteInfo[],\n functions: FunctionInfo[],\n crons: CronInfo[],\n subscribers: SubscriberInfo[],\n): Promise<void> {\n const manifestDir = join(outputDir, 'manifest');\n await mkdir(manifestDir, { recursive: true });\n\n // Filter out 'ALL' method routes (server-specific)\n const awsRoutes = routes.filter((r) => r.method !== 'ALL');\n\n const content = `export const manifest = {\n routes: ${JSON.stringify(awsRoutes, null, 2)},\n functions: ${JSON.stringify(functions, null, 2)},\n crons: ${JSON.stringify(crons, null, 2)},\n subscribers: ${JSON.stringify(subscribers, null, 2)},\n} as const;\n\n// Derived types\nexport type Route = (typeof manifest.routes)[number];\nexport type Function = (typeof manifest.functions)[number];\nexport type Cron = (typeof manifest.crons)[number];\nexport type Subscriber = (typeof manifest.subscribers)[number];\n\n// Useful union types\nexport type Authorizer = Route['authorizer'];\nexport type HttpMethod = Route['method'];\nexport type RoutePath = Route['path'];\n`;\n\n const manifestPath = join(manifestDir, 'aws.ts');\n await writeFile(manifestPath, content);\n\n logger.log(\n `Generated AWS manifest with ${awsRoutes.length} routes, ${functions.length} functions, ${crons.length} crons, ${subscribers.length} subscribers`,\n );\n logger.log(`Manifest: ${relative(process.cwd(), manifestPath)}`);\n}\n\nexport async function generateServerManifest(\n outputDir: string,\n appInfo: ServerAppInfo,\n routes: RouteInfo[],\n subscribers: SubscriberInfo[],\n): Promise<void> {\n const manifestDir = join(outputDir, 'manifest');\n await mkdir(manifestDir, { recursive: true });\n\n // For server, extract route metadata (path, method, authorizer)\n const serverRoutes = routes\n .filter((r) => r.method !== 'ALL')\n .map((r) => ({\n path: r.path,\n method: r.method,\n authorizer: r.authorizer,\n }));\n\n // Server subscribers only need name and events\n const serverSubscribers = subscribers.map((s) => ({\n name: s.name,\n subscribedEvents: s.subscribedEvents,\n }));\n\n const content = `export const manifest = {\n app: ${JSON.stringify(appInfo, null, 2)},\n routes: ${JSON.stringify(serverRoutes, null, 2)},\n subscribers: ${JSON.stringify(serverSubscribers, null, 2)},\n} as const;\n\n// Derived types\nexport type Route = (typeof manifest.routes)[number];\nexport type Subscriber = (typeof manifest.subscribers)[number];\n\n// Useful union types\nexport type Authorizer = Route['authorizer'];\nexport type HttpMethod = Route['method'];\nexport type RoutePath = Route['path'];\n`;\n\n const manifestPath = join(manifestDir, 'server.ts');\n await writeFile(manifestPath, content);\n\n logger.log(\n `Generated server manifest with ${serverRoutes.length} routes, ${serverSubscribers.length} subscribers`,\n );\n logger.log(`Manifest: ${relative(process.cwd(), manifestPath)}`);\n}\n"],"mappings":";;;;;AASA,MAAM,SAAS;AASf,eAAsB,oBACpBA,WACAC,QACAC,WACAC,OACAC,aACe;CACf,MAAM,cAAc,eAAK,WAAW,WAAW;AAC/C,OAAM,4BAAM,aAAa,EAAE,WAAW,KAAM,EAAC;CAG7C,MAAM,YAAY,OAAO,OAAO,CAAC,MAAM,EAAE,WAAW,MAAM;CAE1D,MAAM,WAAW;YACP,KAAK,UAAU,WAAW,MAAM,EAAE,CAAC;eAChC,KAAK,UAAU,WAAW,MAAM,EAAE,CAAC;WACvC,KAAK,UAAU,OAAO,MAAM,EAAE,CAAC;iBACzB,KAAK,UAAU,aAAa,MAAM,EAAE,CAAC;;;;;;;;;;;;;;CAepD,MAAM,eAAe,eAAK,aAAa,SAAS;AAChD,OAAM,gCAAU,cAAc,QAAQ;AAEtC,QAAO,KACJ,8BAA8B,UAAU,OAAO,WAAW,UAAU,OAAO,cAAc,MAAM,OAAO,UAAU,YAAY,OAAO,cACrI;AACD,QAAO,KAAK,YAAY,mBAAS,QAAQ,KAAK,EAAE,aAAa,CAAC,EAAE;AACjE;AAED,eAAsB,uBACpBJ,WACAK,SACAJ,QACAG,aACe;CACf,MAAM,cAAc,eAAK,WAAW,WAAW;AAC/C,OAAM,4BAAM,aAAa,EAAE,WAAW,KAAM,EAAC;CAG7C,MAAM,eAAe,OAClB,OAAO,CAAC,MAAM,EAAE,WAAW,MAAM,CACjC,IAAI,CAAC,OAAO;EACX,MAAM,EAAE;EACR,QAAQ,EAAE;EACV,YAAY,EAAE;CACf,GAAE;CAGL,MAAM,oBAAoB,YAAY,IAAI,CAAC,OAAO;EAChD,MAAM,EAAE;EACR,kBAAkB,EAAE;CACrB,GAAE;CAEH,MAAM,WAAW;SACV,KAAK,UAAU,SAAS,MAAM,EAAE,CAAC;YAC9B,KAAK,UAAU,cAAc,MAAM,EAAE,CAAC;iBACjC,KAAK,UAAU,mBAAmB,MAAM,EAAE,CAAC;;;;;;;;;;;;CAa1D,MAAM,eAAe,eAAK,aAAa,YAAY;AACnD,OAAM,gCAAU,cAAc,QAAQ;AAEtC,QAAO,KACJ,iCAAiC,aAAa,OAAO,WAAW,kBAAkB,OAAO,cAC3F;AACD,QAAO,KAAK,YAAY,mBAAS,QAAQ,KAAK,EAAE,aAAa,CAAC,EAAE;AACjE"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { loadConfig } from "./config-AFmFKmU0.mjs";
|
|
2
|
+
import { EndpointGenerator } from "./EndpointGenerator-CzDhG7Or.mjs";
|
|
3
|
+
import { OpenApiTsGenerator } from "./OpenApiTsGenerator-q3aWNkuM.mjs";
|
|
4
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
5
|
+
import { dirname, join } from "node:path";
|
|
6
|
+
import { Endpoint } from "@geekmidas/constructs/endpoints";
|
|
7
|
+
|
|
8
|
+
//#region src/openapi.ts
|
|
9
|
+
async function openapiCommand(options = {}) {
|
|
10
|
+
const logger = console;
|
|
11
|
+
try {
|
|
12
|
+
const config = await loadConfig(options.cwd);
|
|
13
|
+
const endpointGenerator = new EndpointGenerator();
|
|
14
|
+
const loadedEndpoints = await endpointGenerator.load(config.routes);
|
|
15
|
+
if (loadedEndpoints.length === 0) {
|
|
16
|
+
logger.log("No valid endpoints found");
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const endpoints = loadedEndpoints.map(({ construct }) => construct);
|
|
20
|
+
const isJson = options.json === true;
|
|
21
|
+
const defaultOutput = isJson ? "openapi.json" : "openapi.ts";
|
|
22
|
+
const outputPath = options.output || join(process.cwd(), defaultOutput);
|
|
23
|
+
await mkdir(dirname(outputPath), { recursive: true });
|
|
24
|
+
if (isJson) {
|
|
25
|
+
const spec = await Endpoint.buildOpenApiSchema(endpoints, {
|
|
26
|
+
title: "API Documentation",
|
|
27
|
+
version: "1.0.0",
|
|
28
|
+
description: "Auto-generated API documentation from endpoints"
|
|
29
|
+
});
|
|
30
|
+
await writeFile(outputPath, JSON.stringify(spec, null, 2));
|
|
31
|
+
logger.log(`OpenAPI JSON spec generated: ${outputPath}`);
|
|
32
|
+
} else {
|
|
33
|
+
const tsGenerator = new OpenApiTsGenerator();
|
|
34
|
+
const tsContent = await tsGenerator.generate(endpoints, {
|
|
35
|
+
title: "API Documentation",
|
|
36
|
+
version: "1.0.0",
|
|
37
|
+
description: "Auto-generated API documentation from endpoints"
|
|
38
|
+
});
|
|
39
|
+
await writeFile(outputPath, tsContent);
|
|
40
|
+
logger.log(`OpenAPI TypeScript module generated: ${outputPath}`);
|
|
41
|
+
}
|
|
42
|
+
logger.log(`Found ${endpoints.length} endpoints`);
|
|
43
|
+
} catch (error) {
|
|
44
|
+
throw new Error(`OpenAPI generation failed: ${error.message}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
49
|
+
export { openapiCommand };
|
|
50
|
+
//# sourceMappingURL=openapi-DRTRGhTt.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi-DRTRGhTt.mjs","names":["options: OpenAPIOptions"],"sources":["../src/openapi.ts"],"sourcesContent":["#!/usr/bin/env -S npx tsx\n\nimport { mkdir, writeFile } from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\nimport { Endpoint } from '@geekmidas/constructs/endpoints';\nimport { loadConfig } from './config.js';\nimport { EndpointGenerator } from './generators/EndpointGenerator.js';\nimport { OpenApiTsGenerator } from './generators/OpenApiTsGenerator.js';\n\ninterface OpenAPIOptions {\n output?: string;\n json?: boolean;\n cwd?: string;\n}\n\nexport async function openapiCommand(\n options: OpenAPIOptions = {},\n): Promise<void> {\n const logger = console;\n\n try {\n // Load config using existing function\n const config = await loadConfig(options.cwd);\n const endpointGenerator = new EndpointGenerator();\n\n // Load all endpoints using the refactored function\n const loadedEndpoints = await endpointGenerator.load(config.routes);\n\n if (loadedEndpoints.length === 0) {\n logger.log('No valid endpoints found');\n return;\n }\n\n // Extract just the endpoint instances for OpenAPI generation\n const endpoints = loadedEndpoints.map(({ construct }) => construct);\n\n // Determine output format (TypeScript is default)\n const isJson = options.json === true;\n const defaultOutput = isJson ? 'openapi.json' : 'openapi.ts';\n const outputPath = options.output || join(process.cwd(), defaultOutput);\n\n // Ensure output directory exists\n await mkdir(dirname(outputPath), { recursive: true });\n\n if (isJson) {\n // Generate JSON OpenAPI spec (legacy)\n const spec = await Endpoint.buildOpenApiSchema(endpoints, {\n title: 'API Documentation',\n version: '1.0.0',\n description: 'Auto-generated API documentation from endpoints',\n });\n\n await writeFile(outputPath, JSON.stringify(spec, null, 2));\n logger.log(`OpenAPI JSON spec generated: ${outputPath}`);\n } else {\n // Generate TypeScript OpenAPI module (default)\n const tsGenerator = new OpenApiTsGenerator();\n const tsContent = await tsGenerator.generate(endpoints, {\n title: 'API Documentation',\n version: '1.0.0',\n description: 'Auto-generated API documentation from endpoints',\n });\n\n await writeFile(outputPath, tsContent);\n logger.log(`OpenAPI TypeScript module generated: ${outputPath}`);\n }\n\n logger.log(`Found ${endpoints.length} endpoints`);\n } catch (error) {\n throw new Error(`OpenAPI generation failed: ${(error as Error).message}`);\n }\n}\n"],"mappings":";;;;;;;;AAeA,eAAsB,eACpBA,UAA0B,CAAE,GACb;CACf,MAAM,SAAS;AAEf,KAAI;EAEF,MAAM,SAAS,MAAM,WAAW,QAAQ,IAAI;EAC5C,MAAM,oBAAoB,IAAI;EAG9B,MAAM,kBAAkB,MAAM,kBAAkB,KAAK,OAAO,OAAO;AAEnE,MAAI,gBAAgB,WAAW,GAAG;AAChC,UAAO,IAAI,2BAA2B;AACtC;EACD;EAGD,MAAM,YAAY,gBAAgB,IAAI,CAAC,EAAE,WAAW,KAAK,UAAU;EAGnE,MAAM,SAAS,QAAQ,SAAS;EAChC,MAAM,gBAAgB,SAAS,iBAAiB;EAChD,MAAM,aAAa,QAAQ,UAAU,KAAK,QAAQ,KAAK,EAAE,cAAc;AAGvE,QAAM,MAAM,QAAQ,WAAW,EAAE,EAAE,WAAW,KAAM,EAAC;AAErD,MAAI,QAAQ;GAEV,MAAM,OAAO,MAAM,SAAS,mBAAmB,WAAW;IACxD,OAAO;IACP,SAAS;IACT,aAAa;GACd,EAAC;AAEF,SAAM,UAAU,YAAY,KAAK,UAAU,MAAM,MAAM,EAAE,CAAC;AAC1D,UAAO,KAAK,+BAA+B,WAAW,EAAE;EACzD,OAAM;GAEL,MAAM,cAAc,IAAI;GACxB,MAAM,YAAY,MAAM,YAAY,SAAS,WAAW;IACtD,OAAO;IACP,SAAS;IACT,aAAa;GACd,EAAC;AAEF,SAAM,UAAU,YAAY,UAAU;AACtC,UAAO,KAAK,uCAAuC,WAAW,EAAE;EACjE;AAED,SAAO,KAAK,QAAQ,UAAU,OAAO,YAAY;CAClD,SAAQ,OAAO;AACd,QAAM,IAAI,OAAO,6BAA8B,MAAgB,QAAQ;CACxE;AACF"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
+
const require_config = require('./config-BVIJpAsa.cjs');
|
|
3
|
+
const require_EndpointGenerator = require('./EndpointGenerator-BxNCkus4.cjs');
|
|
4
|
+
const require_OpenApiTsGenerator = require('./OpenApiTsGenerator-NBNEoaeO.cjs');
|
|
5
|
+
const node_fs_promises = require_chunk.__toESM(require("node:fs/promises"));
|
|
6
|
+
const node_path = require_chunk.__toESM(require("node:path"));
|
|
7
|
+
const __geekmidas_constructs_endpoints = require_chunk.__toESM(require("@geekmidas/constructs/endpoints"));
|
|
8
|
+
|
|
9
|
+
//#region src/openapi.ts
|
|
10
|
+
async function openapiCommand(options = {}) {
|
|
11
|
+
const logger = console;
|
|
12
|
+
try {
|
|
13
|
+
const config = await require_config.loadConfig(options.cwd);
|
|
14
|
+
const endpointGenerator = new require_EndpointGenerator.EndpointGenerator();
|
|
15
|
+
const loadedEndpoints = await endpointGenerator.load(config.routes);
|
|
16
|
+
if (loadedEndpoints.length === 0) {
|
|
17
|
+
logger.log("No valid endpoints found");
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const endpoints = loadedEndpoints.map(({ construct }) => construct);
|
|
21
|
+
const isJson = options.json === true;
|
|
22
|
+
const defaultOutput = isJson ? "openapi.json" : "openapi.ts";
|
|
23
|
+
const outputPath = options.output || (0, node_path.join)(process.cwd(), defaultOutput);
|
|
24
|
+
await (0, node_fs_promises.mkdir)((0, node_path.dirname)(outputPath), { recursive: true });
|
|
25
|
+
if (isJson) {
|
|
26
|
+
const spec = await __geekmidas_constructs_endpoints.Endpoint.buildOpenApiSchema(endpoints, {
|
|
27
|
+
title: "API Documentation",
|
|
28
|
+
version: "1.0.0",
|
|
29
|
+
description: "Auto-generated API documentation from endpoints"
|
|
30
|
+
});
|
|
31
|
+
await (0, node_fs_promises.writeFile)(outputPath, JSON.stringify(spec, null, 2));
|
|
32
|
+
logger.log(`OpenAPI JSON spec generated: ${outputPath}`);
|
|
33
|
+
} else {
|
|
34
|
+
const tsGenerator = new require_OpenApiTsGenerator.OpenApiTsGenerator();
|
|
35
|
+
const tsContent = await tsGenerator.generate(endpoints, {
|
|
36
|
+
title: "API Documentation",
|
|
37
|
+
version: "1.0.0",
|
|
38
|
+
description: "Auto-generated API documentation from endpoints"
|
|
39
|
+
});
|
|
40
|
+
await (0, node_fs_promises.writeFile)(outputPath, tsContent);
|
|
41
|
+
logger.log(`OpenAPI TypeScript module generated: ${outputPath}`);
|
|
42
|
+
}
|
|
43
|
+
logger.log(`Found ${endpoints.length} endpoints`);
|
|
44
|
+
} catch (error) {
|
|
45
|
+
throw new Error(`OpenAPI generation failed: ${error.message}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
Object.defineProperty(exports, 'openapiCommand', {
|
|
51
|
+
enumerable: true,
|
|
52
|
+
get: function () {
|
|
53
|
+
return openapiCommand;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
//# sourceMappingURL=openapi-DhK4b0lB.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi-DhK4b0lB.cjs","names":["options: OpenAPIOptions","EndpointGenerator","OpenApiTsGenerator"],"sources":["../src/openapi.ts"],"sourcesContent":["#!/usr/bin/env -S npx tsx\n\nimport { mkdir, writeFile } from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\nimport { Endpoint } from '@geekmidas/constructs/endpoints';\nimport { loadConfig } from './config.js';\nimport { EndpointGenerator } from './generators/EndpointGenerator.js';\nimport { OpenApiTsGenerator } from './generators/OpenApiTsGenerator.js';\n\ninterface OpenAPIOptions {\n output?: string;\n json?: boolean;\n cwd?: string;\n}\n\nexport async function openapiCommand(\n options: OpenAPIOptions = {},\n): Promise<void> {\n const logger = console;\n\n try {\n // Load config using existing function\n const config = await loadConfig(options.cwd);\n const endpointGenerator = new EndpointGenerator();\n\n // Load all endpoints using the refactored function\n const loadedEndpoints = await endpointGenerator.load(config.routes);\n\n if (loadedEndpoints.length === 0) {\n logger.log('No valid endpoints found');\n return;\n }\n\n // Extract just the endpoint instances for OpenAPI generation\n const endpoints = loadedEndpoints.map(({ construct }) => construct);\n\n // Determine output format (TypeScript is default)\n const isJson = options.json === true;\n const defaultOutput = isJson ? 'openapi.json' : 'openapi.ts';\n const outputPath = options.output || join(process.cwd(), defaultOutput);\n\n // Ensure output directory exists\n await mkdir(dirname(outputPath), { recursive: true });\n\n if (isJson) {\n // Generate JSON OpenAPI spec (legacy)\n const spec = await Endpoint.buildOpenApiSchema(endpoints, {\n title: 'API Documentation',\n version: '1.0.0',\n description: 'Auto-generated API documentation from endpoints',\n });\n\n await writeFile(outputPath, JSON.stringify(spec, null, 2));\n logger.log(`OpenAPI JSON spec generated: ${outputPath}`);\n } else {\n // Generate TypeScript OpenAPI module (default)\n const tsGenerator = new OpenApiTsGenerator();\n const tsContent = await tsGenerator.generate(endpoints, {\n title: 'API Documentation',\n version: '1.0.0',\n description: 'Auto-generated API documentation from endpoints',\n });\n\n await writeFile(outputPath, tsContent);\n logger.log(`OpenAPI TypeScript module generated: ${outputPath}`);\n }\n\n logger.log(`Found ${endpoints.length} endpoints`);\n } catch (error) {\n throw new Error(`OpenAPI generation failed: ${(error as Error).message}`);\n }\n}\n"],"mappings":";;;;;;;;;AAeA,eAAsB,eACpBA,UAA0B,CAAE,GACb;CACf,MAAM,SAAS;AAEf,KAAI;EAEF,MAAM,SAAS,MAAM,0BAAW,QAAQ,IAAI;EAC5C,MAAM,oBAAoB,IAAIC;EAG9B,MAAM,kBAAkB,MAAM,kBAAkB,KAAK,OAAO,OAAO;AAEnE,MAAI,gBAAgB,WAAW,GAAG;AAChC,UAAO,IAAI,2BAA2B;AACtC;EACD;EAGD,MAAM,YAAY,gBAAgB,IAAI,CAAC,EAAE,WAAW,KAAK,UAAU;EAGnE,MAAM,SAAS,QAAQ,SAAS;EAChC,MAAM,gBAAgB,SAAS,iBAAiB;EAChD,MAAM,aAAa,QAAQ,UAAU,oBAAK,QAAQ,KAAK,EAAE,cAAc;AAGvE,QAAM,4BAAM,uBAAQ,WAAW,EAAE,EAAE,WAAW,KAAM,EAAC;AAErD,MAAI,QAAQ;GAEV,MAAM,OAAO,MAAM,0CAAS,mBAAmB,WAAW;IACxD,OAAO;IACP,SAAS;IACT,aAAa;GACd,EAAC;AAEF,SAAM,gCAAU,YAAY,KAAK,UAAU,MAAM,MAAM,EAAE,CAAC;AAC1D,UAAO,KAAK,+BAA+B,WAAW,EAAE;EACzD,OAAM;GAEL,MAAM,cAAc,IAAIC;GACxB,MAAM,YAAY,MAAM,YAAY,SAAS,WAAW;IACtD,OAAO;IACP,SAAS;IACT,aAAa;GACd,EAAC;AAEF,SAAM,gCAAU,YAAY,UAAU;AACtC,UAAO,KAAK,uCAAuC,WAAW,EAAE;EACjE;AAED,SAAO,KAAK,QAAQ,UAAU,OAAO,YAAY;CAClD,SAAQ,OAAO;AACd,QAAM,IAAI,OAAO,6BAA8B,MAAgB,QAAQ;CACxE;AACF"}
|
package/dist/openapi.cjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env -S npx tsx
|
|
2
|
-
require('./config-
|
|
2
|
+
require('./config-BVIJpAsa.cjs');
|
|
3
3
|
require('./Generator-CDoEXCDg.cjs');
|
|
4
|
-
require('./EndpointGenerator-
|
|
5
|
-
|
|
4
|
+
require('./EndpointGenerator-BxNCkus4.cjs');
|
|
5
|
+
require('./OpenApiTsGenerator-NBNEoaeO.cjs');
|
|
6
|
+
const require_openapi = require('./openapi-DhK4b0lB.cjs');
|
|
6
7
|
|
|
7
8
|
exports.openapiCommand = require_openapi.openapiCommand;
|
package/dist/openapi.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env -S npx tsx
|
|
2
|
-
import "./config-
|
|
2
|
+
import "./config-AFmFKmU0.mjs";
|
|
3
3
|
import "./Generator-UanJW0_V.mjs";
|
|
4
|
-
import "./EndpointGenerator-
|
|
5
|
-
import
|
|
4
|
+
import "./EndpointGenerator-CzDhG7Or.mjs";
|
|
5
|
+
import "./OpenApiTsGenerator-q3aWNkuM.mjs";
|
|
6
|
+
import { openapiCommand } from "./openapi-DRTRGhTt.mjs";
|
|
6
7
|
|
|
7
8
|
export { openapiCommand };
|