@geekmidas/cli 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{CronGenerator-DXRfHQcV.mjs → CronGenerator-Bh26MaNA.mjs} +2 -1
- package/dist/CronGenerator-Bh26MaNA.mjs.map +1 -0
- package/dist/{CronGenerator-1PflEYe2.cjs → CronGenerator-C6MF8rlG.cjs} +2 -1
- package/dist/CronGenerator-C6MF8rlG.cjs.map +1 -0
- package/dist/{EndpointGenerator-BbGrDiCP.cjs → EndpointGenerator-C73wNoih.cjs} +12 -5
- package/dist/EndpointGenerator-C73wNoih.cjs.map +1 -0
- package/dist/{EndpointGenerator-BmZ9BxbO.mjs → EndpointGenerator-CWh18d92.mjs} +12 -5
- package/dist/EndpointGenerator-CWh18d92.mjs.map +1 -0
- package/dist/{FunctionGenerator-DOEB_yPh.mjs → FunctionGenerator-BNE_GC7N.mjs} +2 -1
- package/dist/FunctionGenerator-BNE_GC7N.mjs.map +1 -0
- package/dist/{FunctionGenerator-Clw64SwQ.cjs → FunctionGenerator-FgZUTd8L.cjs} +2 -1
- package/dist/FunctionGenerator-FgZUTd8L.cjs.map +1 -0
- package/dist/{SubscriberGenerator-CB-NHtZW.cjs → SubscriberGenerator-Bd-a7aiw.cjs} +2 -1
- package/dist/SubscriberGenerator-Bd-a7aiw.cjs.map +1 -0
- package/dist/{SubscriberGenerator-Cuu4co3-.mjs → SubscriberGenerator-Dnlj_1FK.mjs} +2 -1
- package/dist/SubscriberGenerator-Dnlj_1FK.mjs.map +1 -0
- package/dist/build/index.cjs +5 -5
- package/dist/build/index.mjs +5 -5
- package/dist/{build-Ajg356_5.cjs → build-BVng9MQX.cjs} +5 -5
- package/dist/{build-Ajg356_5.cjs.map → build-BVng9MQX.cjs.map} +1 -1
- package/dist/{build-zpABVsc0.mjs → build-BqexeI-W.mjs} +5 -5
- package/dist/{build-zpABVsc0.mjs.map → build-BqexeI-W.mjs.map} +1 -1
- package/dist/dev/index.cjs +13 -0
- package/dist/dev/index.mjs +11 -0
- package/dist/dev-DbtyToc7.cjs +259 -0
- package/dist/dev-DbtyToc7.cjs.map +1 -0
- package/dist/dev-DnGYXuMn.mjs +241 -0
- package/dist/dev-DnGYXuMn.mjs.map +1 -0
- package/dist/generators/CronGenerator.cjs +1 -1
- package/dist/generators/CronGenerator.mjs +1 -1
- package/dist/generators/EndpointGenerator.cjs +1 -1
- package/dist/generators/EndpointGenerator.mjs +1 -1
- package/dist/generators/FunctionGenerator.cjs +1 -1
- package/dist/generators/FunctionGenerator.mjs +1 -1
- package/dist/generators/SubscriberGenerator.cjs +1 -1
- package/dist/generators/SubscriberGenerator.mjs +1 -1
- package/dist/generators/index.cjs +4 -4
- package/dist/generators/index.mjs +4 -4
- package/dist/index.cjs +33 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +33 -12
- package/dist/index.mjs.map +1 -1
- package/dist/{openapi-BQx3_JbM.mjs → openapi-BTHbPrxS.mjs} +2 -2
- package/dist/{openapi-BQx3_JbM.mjs.map → openapi-BTHbPrxS.mjs.map} +1 -1
- package/dist/{openapi-CMLr04cz.cjs → openapi-CewcfoRH.cjs} +2 -2
- package/dist/{openapi-CMLr04cz.cjs.map → openapi-CewcfoRH.cjs.map} +1 -1
- package/dist/{openapi-react-query-Dvjqx_Eo.cjs → openapi-react-query-D9Z7lh0p.cjs} +1 -1
- package/dist/{openapi-react-query-Dvjqx_Eo.cjs.map → openapi-react-query-D9Z7lh0p.cjs.map} +1 -1
- package/dist/{openapi-react-query-DbrWwQzb.mjs → openapi-react-query-MEBlYIM1.mjs} +1 -1
- package/dist/{openapi-react-query-DbrWwQzb.mjs.map → openapi-react-query-MEBlYIM1.mjs.map} +1 -1
- package/dist/openapi-react-query.cjs +1 -1
- package/dist/openapi-react-query.mjs +1 -1
- package/dist/openapi.cjs +2 -2
- package/dist/openapi.mjs +2 -2
- package/package.json +12 -6
- package/src/dev/__tests__/index.spec.ts +208 -0
- package/src/dev/index.ts +377 -0
- package/src/generators/CronGenerator.ts +8 -3
- package/src/generators/EndpointGenerator.ts +94 -6
- package/src/generators/FunctionGenerator.ts +21 -3
- package/src/generators/SubscriberGenerator.ts +1 -0
- package/src/generators/__tests__/SubscriberGenerator.spec.ts +12 -9
- package/src/index.ts +27 -0
- package/src/types.ts +3 -0
- package/dist/CronGenerator-1PflEYe2.cjs.map +0 -1
- package/dist/CronGenerator-DXRfHQcV.mjs.map +0 -1
- package/dist/EndpointGenerator-BbGrDiCP.cjs.map +0 -1
- package/dist/EndpointGenerator-BmZ9BxbO.mjs.map +0 -1
- package/dist/FunctionGenerator-Clw64SwQ.cjs.map +0 -1
- package/dist/FunctionGenerator-DOEB_yPh.mjs.map +0 -1
- package/dist/SubscriberGenerator-CB-NHtZW.cjs.map +0 -1
- package/dist/SubscriberGenerator-Cuu4co3-.mjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -2,21 +2,22 @@
|
|
|
2
2
|
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
3
3
|
require('./config-D1EpSGk6.cjs');
|
|
4
4
|
require('./Generator-CDoEXCDg.cjs');
|
|
5
|
-
require('./CronGenerator-
|
|
6
|
-
require('./EndpointGenerator-
|
|
7
|
-
require('./FunctionGenerator-
|
|
8
|
-
require('./SubscriberGenerator-
|
|
5
|
+
require('./CronGenerator-C6MF8rlG.cjs');
|
|
6
|
+
require('./EndpointGenerator-C73wNoih.cjs');
|
|
7
|
+
require('./FunctionGenerator-FgZUTd8L.cjs');
|
|
8
|
+
require('./SubscriberGenerator-Bd-a7aiw.cjs');
|
|
9
9
|
require('./generators-CEKtVh81.cjs');
|
|
10
10
|
require('./manifests-D0saShvH.cjs');
|
|
11
11
|
require('./providerResolver-DgvzNfP4.cjs');
|
|
12
|
-
const require_build = require('./build-
|
|
13
|
-
const
|
|
14
|
-
const
|
|
12
|
+
const require_build = require('./build-BVng9MQX.cjs');
|
|
13
|
+
const require_dev = require('./dev-DbtyToc7.cjs');
|
|
14
|
+
const require_openapi_react_query = require('./openapi-react-query-D9Z7lh0p.cjs');
|
|
15
|
+
const require_openapi = require('./openapi-CewcfoRH.cjs');
|
|
15
16
|
const commander = require_chunk.__toESM(require("commander"));
|
|
16
17
|
|
|
17
18
|
//#region package.json
|
|
18
19
|
var name = "@geekmidas/cli";
|
|
19
|
-
var version = "0.2.
|
|
20
|
+
var version = "0.2.4";
|
|
20
21
|
var private$1 = false;
|
|
21
22
|
var type = "module";
|
|
22
23
|
var exports$1 = {
|
|
@@ -43,25 +44,31 @@ var scripts = {
|
|
|
43
44
|
"test:once": "vitest run",
|
|
44
45
|
"test:coverage": "vitest run --coverage"
|
|
45
46
|
};
|
|
47
|
+
var repository = {
|
|
48
|
+
"type": "git",
|
|
49
|
+
"url": "https://github.com/geekmidas/toolbox"
|
|
50
|
+
};
|
|
46
51
|
var dependencies = {
|
|
47
52
|
"@apidevtools/swagger-parser": "^10.1.0",
|
|
53
|
+
"chokidar": "~4.0.3",
|
|
48
54
|
"commander": "^12.1.0",
|
|
49
55
|
"fast-glob": "^3.3.2",
|
|
50
56
|
"lodash.kebabcase": "^4.1.1",
|
|
51
57
|
"openapi-typescript": "^7.4.2"
|
|
52
58
|
};
|
|
53
59
|
var devDependencies = {
|
|
54
|
-
"@types/lodash.kebabcase": "^4.1.9",
|
|
55
60
|
"@geekmidas/testkit": "workspace:*",
|
|
61
|
+
"@types/lodash.kebabcase": "^4.1.9",
|
|
62
|
+
"@types/node": "~24.9.1",
|
|
56
63
|
"typescript": "^5.8.2",
|
|
57
64
|
"vitest": "^3.2.4",
|
|
58
|
-
"zod": "
|
|
65
|
+
"zod": "~4.1.13"
|
|
59
66
|
};
|
|
60
67
|
var peerDependencies = {
|
|
61
68
|
"@geekmidas/constructs": "workspace:~",
|
|
62
|
-
"@geekmidas/schema": "workspace:~",
|
|
63
69
|
"@geekmidas/envkit": "workspace:~",
|
|
64
|
-
"@geekmidas/logger": "workspace:~"
|
|
70
|
+
"@geekmidas/logger": "workspace:~",
|
|
71
|
+
"@geekmidas/schema": "workspace:~"
|
|
65
72
|
};
|
|
66
73
|
var package_default = {
|
|
67
74
|
name,
|
|
@@ -71,6 +78,7 @@ var package_default = {
|
|
|
71
78
|
exports: exports$1,
|
|
72
79
|
bin,
|
|
73
80
|
scripts,
|
|
81
|
+
repository,
|
|
74
82
|
dependencies,
|
|
75
83
|
devDependencies,
|
|
76
84
|
peerDependencies
|
|
@@ -106,6 +114,19 @@ program.command("build").description("Build handlers from endpoints, functions,
|
|
|
106
114
|
process.exit(1);
|
|
107
115
|
}
|
|
108
116
|
});
|
|
117
|
+
program.command("dev").description("Start development server with automatic reload").option("--port <port>", "Port to run the development server on", "3000").option("--enable-openapi", "Enable OpenAPI documentation for development server", true).action(async (options) => {
|
|
118
|
+
try {
|
|
119
|
+
const globalOptions = program.opts();
|
|
120
|
+
if (globalOptions.cwd) process.chdir(globalOptions.cwd);
|
|
121
|
+
await require_dev.devCommand({
|
|
122
|
+
port: options.port ? Number.parseInt(options.port) : 3e3,
|
|
123
|
+
enableOpenApi: options.enableOpenapi ?? true
|
|
124
|
+
});
|
|
125
|
+
} catch (error) {
|
|
126
|
+
console.error("Dev server failed:", error.message);
|
|
127
|
+
process.exit(1);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
109
130
|
program.command("cron").description("Manage cron jobs").action(() => {
|
|
110
131
|
const globalOptions = program.opts();
|
|
111
132
|
if (globalOptions.cwd) process.chdir(globalOptions.cwd);
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["Command","pkg","options: {\n provider?: string;\n providers?: string;\n enableOpenapi?: boolean;\n }","options: { output?: string }","options: { input?: string; output?: string; name?: string }"],"sources":["../package.json","../src/index.ts"],"sourcesContent":["{\n \"name\": \"@geekmidas/cli\",\n \"version\": \"0.2.3\",\n \"private\": false,\n \"type\": \"module\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./openapi\": {\n \"types\": \"./dist/openapi.d.ts\",\n \"import\": \"./dist/openapi.mjs\",\n \"require\": \"./dist/openapi.cjs\"\n },\n \"./openapi-react-query\": {\n \"types\": \"./dist/openapi-react-query.d.ts\",\n \"import\": \"./dist/openapi-react-query.mjs\",\n \"require\": \"./dist/openapi-react-query.cjs\"\n }\n },\n \"bin\": {\n \"gkm\": \"./dist/index.cjs\"\n },\n \"scripts\": {\n \"ts\": \"tsc --noEmit --skipLibCheck src/**/*.ts\",\n \"test\": \"vitest\",\n \"test:once\": \"vitest run\",\n \"test:coverage\": \"vitest run --coverage\"\n },\n \"dependencies\": {\n \"@apidevtools/swagger-parser\": \"^10.1.0\",\n \"commander\": \"^12.1.0\",\n \"fast-glob\": \"^3.3.2\",\n \"lodash.kebabcase\": \"^4.1.1\",\n \"openapi-typescript\": \"^7.4.2\"\n },\n \"devDependencies\": {\n \"@types/lodash.kebabcase\": \"^4.1.9\",\n \"@geekmidas/testkit\": \"workspace:*\",\n \"typescript\": \"^5.8.2\",\n \"vitest\": \"^3.2.4\",\n \"zod\": \"^3.23.8\"\n },\n \"peerDependencies\": {\n \"@geekmidas/constructs\": \"workspace:~\",\n \"@geekmidas/schema\": \"workspace:~\",\n \"@geekmidas/envkit\": \"workspace:~\",\n \"@geekmidas/logger\": \"workspace:~\"\n }\n}\n","#!/usr/bin/env -S npx tsx\n\nimport { Command } from 'commander';\nimport pkg from '../package.json' assert { type: 'json' };\nimport { buildCommand } from './build/index.ts';\nimport { generateReactQueryCommand } from './openapi-react-query.ts';\nimport { openapiCommand } from './openapi.ts';\nimport type { LegacyProvider, MainProvider } from './types.ts';\n\nconst program = new Command();\n\nprogram\n .name('gkm')\n .description('GeekMidas backend framework CLI')\n .version(pkg.version)\n .option('--cwd <path>', 'Change working directory');\n\nprogram\n .command('build')\n .description('Build handlers from endpoints, functions, and crons')\n .option(\n '--provider <provider>',\n 'Target provider for generated handlers (aws, server)',\n )\n .option(\n '--providers <providers>',\n '[DEPRECATED] Use --provider instead. Target providers for generated handlers (comma-separated)',\n )\n .option(\n '--enable-openapi',\n 'Enable OpenAPI documentation generation for server builds',\n )\n .action(\n async (options: {\n provider?: string;\n providers?: string;\n enableOpenapi?: boolean;\n }) => {\n try {\n const globalOptions = program.opts();\n if (globalOptions.cwd) {\n process.chdir(globalOptions.cwd);\n }\n\n // Handle new single provider option\n if (options.provider) {\n if (!['aws', 'server'].includes(options.provider)) {\n console.error(\n `Invalid provider: ${options.provider}. Must be 'aws' or 'server'.`,\n );\n process.exit(1);\n }\n await buildCommand({\n provider: options.provider as MainProvider,\n enableOpenApi: options.enableOpenapi || false,\n });\n }\n // Handle legacy providers option\n else if (options.providers) {\n console.warn(\n '⚠️ --providers flag is deprecated. Use --provider instead.',\n );\n const providerList = [\n ...new Set(options.providers.split(',').map((p) => p.trim())),\n ] as LegacyProvider[];\n await buildCommand({\n providers: providerList,\n enableOpenApi: options.enableOpenapi || false,\n });\n }\n // Default to config-driven build\n else {\n await buildCommand({\n enableOpenApi: options.enableOpenapi || false,\n });\n }\n } catch (error) {\n console.error('Build failed:', (error as Error).message);\n process.exit(1);\n }\n },\n );\n\nprogram\n .command('cron')\n .description('Manage cron jobs')\n .action(() => {\n const globalOptions = program.opts();\n if (globalOptions.cwd) {\n process.chdir(globalOptions.cwd);\n }\n process.stdout.write('Cron management - coming soon\\n');\n });\n\nprogram\n .command('function')\n .description('Manage serverless functions')\n .action(() => {\n const globalOptions = program.opts();\n if (globalOptions.cwd) {\n process.chdir(globalOptions.cwd);\n }\n process.stdout.write('Serverless function management - coming soon\\n');\n });\n\nprogram\n .command('api')\n .description('Manage REST API endpoints')\n .action(() => {\n const globalOptions = program.opts();\n if (globalOptions.cwd) {\n process.chdir(globalOptions.cwd);\n }\n process.stdout.write('REST API management - coming soon\\n');\n });\n\nprogram\n .command('openapi')\n .description('Generate OpenAPI 3.0 specification from endpoints')\n .option(\n '--output <path>',\n 'Output file path for the OpenAPI spec',\n 'openapi.json',\n )\n .action(async (options: { output?: string }) => {\n try {\n const globalOptions = program.opts();\n if (globalOptions.cwd) {\n process.chdir(globalOptions.cwd);\n }\n await openapiCommand(options);\n } catch (error) {\n console.error('OpenAPI generation failed:', (error as Error).message);\n process.exit(1);\n }\n });\n\nprogram\n .command('generate:react-query')\n .description('Generate React Query hooks from OpenAPI specification')\n .option('--input <path>', 'Input OpenAPI spec file path', 'openapi.json')\n .option(\n '--output <path>',\n 'Output file path for generated hooks',\n 'src/api/hooks.ts',\n )\n .option('--name <name>', 'API name prefix for generated code', 'API')\n .action(\n async (options: { input?: string; output?: string; name?: string }) => {\n try {\n const globalOptions = program.opts();\n if (globalOptions.cwd) {\n process.chdir(globalOptions.cwd);\n }\n await generateReactQueryCommand(options);\n } catch (error) {\n console.error(\n 'React Query generation failed:',\n (error as Error).message,\n );\n process.exit(1);\n }\n },\n );\n\nprogram.parse();\n"],"mappings":";;;;;;;;;;;;;;;;;WACU;cACG;gBACA;WACH;gBACG;CACT,KAAK;EACH,SAAS;EACT,UAAU;EACV,WAAW;CACZ;CACD,aAAa;EACX,SAAS;EACT,UAAU;EACV,WAAW;CACZ;CACD,yBAAyB;EACvB,SAAS;EACT,UAAU;EACV,WAAW;CACZ;AACF;UACM,EACL,OAAO,mBACR;cACU;CACT,MAAM;CACN,QAAQ;CACR,aAAa;CACb,iBAAiB;AAClB;mBACe;CACd,+BAA+B;CAC/B,aAAa;CACb,aAAa;CACb,oBAAoB;CACpB,sBAAsB;AACvB;sBACkB;CACjB,2BAA2B;CAC3B,sBAAsB;CACtB,cAAc;CACd,UAAU;CACV,OAAO;AACR;uBACmB;CAClB,yBAAyB;CACzB,qBAAqB;CACrB,qBAAqB;CACrB,qBAAqB;AACtB;sBAlDH;;;;;;;;;;;AAmDC;;;;AC1CD,MAAM,UAAU,IAAIA;AAEpB,QACG,KAAK,MAAM,CACX,YAAY,kCAAkC,CAC9C,Q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SAAQ,MAAM,cAAc,IAAI;AAElC,SAAQ,OAAO,MAAM,iDAAiD;AACvE,EAAC;AAEJ,QACG,QAAQ,MAAM,CACd,YAAY,4BAA4B,CACxC,OAAO,MAAM;CACZ,MAAM,gBAAgB,QAAQ,MAAM;AACpC,KAAI,cAAc,IAChB,SAAQ,MAAM,cAAc,IAAI;AAElC,SAAQ,OAAO,MAAM,sCAAsC;AAC5D,EAAC;AAEJ,QACG,QAAQ,UAAU,CAClB,YAAY,oDAAoD,CAChE,OACC,mBACA,yCACA,eACD,CACA,OAAO,OAAOC,YAAiC;AAC9C,KAAI;EACF,MAAM,gBAAgB,QAAQ,MAAM;AACpC,MAAI,cAAc,IAChB,SAAQ,MAAM,cAAc,IAAI;AAElC,QAAM,+BAAe,QAAQ;CAC9B,SAAQ,OAAO;AACd,UAAQ,MAAM,8BAA+B,MAAgB,QAAQ;AACrE,UAAQ,KAAK,EAAE;CAChB;AACF,EAAC;AAEJ,QACG,QAAQ,uBAAuB,CAC/B,YAAY,wDAAwD,CACpE,OAAO,kBAAkB,gCAAgC,eAAe,CACxE,OACC,mBACA,wCACA,mBACD,CACA,OAAO,iBAAiB,sCAAsC,MAAM,CACpE,OACC,OAAOC,YAAgE;AACrE,KAAI;EACF,MAAM,gBAAgB,QAAQ,MAAM;AACpC,MAAI,cAAc,IAChB,SAAQ,MAAM,cAAc,IAAI;AAElC,QAAM,sDAA0B,QAAQ;CACzC,SAAQ,OAAO;AACd,UAAQ,MACN,kCACC,MAAgB,QAClB;AACD,UAAQ,KAAK,EAAE;CAChB;AACF,EACF;AAEH,QAAQ,OAAO"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["Command","pkg","options: {\n provider?: string;\n providers?: string;\n enableOpenapi?: boolean;\n }","options: { port?: string; enableOpenapi?: boolean }","options: { output?: string }","options: { input?: string; output?: string; name?: string }"],"sources":["../package.json","../src/index.ts"],"sourcesContent":["{\n \"name\": \"@geekmidas/cli\",\n \"version\": \"0.2.4\",\n \"private\": false,\n \"type\": \"module\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./openapi\": {\n \"types\": \"./dist/openapi.d.ts\",\n \"import\": \"./dist/openapi.mjs\",\n \"require\": \"./dist/openapi.cjs\"\n },\n \"./openapi-react-query\": {\n \"types\": \"./dist/openapi-react-query.d.ts\",\n \"import\": \"./dist/openapi-react-query.mjs\",\n \"require\": \"./dist/openapi-react-query.cjs\"\n }\n },\n \"bin\": {\n \"gkm\": \"./dist/index.cjs\"\n },\n \"scripts\": {\n \"ts\": \"tsc --noEmit --skipLibCheck src/**/*.ts\",\n \"test\": \"vitest\",\n \"test:once\": \"vitest run\",\n \"test:coverage\": \"vitest run --coverage\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/geekmidas/toolbox\"\n },\n \"dependencies\": {\n \"@apidevtools/swagger-parser\": \"^10.1.0\",\n \"chokidar\": \"~4.0.3\",\n \"commander\": \"^12.1.0\",\n \"fast-glob\": \"^3.3.2\",\n \"lodash.kebabcase\": \"^4.1.1\",\n \"openapi-typescript\": \"^7.4.2\"\n },\n \"devDependencies\": {\n \"@geekmidas/testkit\": \"workspace:*\",\n \"@types/lodash.kebabcase\": \"^4.1.9\",\n \"@types/node\": \"~24.9.1\",\n \"typescript\": \"^5.8.2\",\n \"vitest\": \"^3.2.4\",\n \"zod\": \"~4.1.13\"\n },\n \"peerDependencies\": {\n \"@geekmidas/constructs\": \"workspace:~\",\n \"@geekmidas/envkit\": \"workspace:~\",\n \"@geekmidas/logger\": \"workspace:~\",\n \"@geekmidas/schema\": \"workspace:~\"\n }\n}\n","#!/usr/bin/env -S npx tsx\n\nimport { Command } from 'commander';\nimport pkg from '../package.json' assert { type: 'json' };\nimport { buildCommand } from './build/index.ts';\nimport { devCommand } from './dev/index.ts';\nimport { generateReactQueryCommand } from './openapi-react-query.ts';\nimport { openapiCommand } from './openapi.ts';\nimport type { LegacyProvider, MainProvider } from './types.ts';\n\nconst program = new Command();\n\nprogram\n .name('gkm')\n .description('GeekMidas backend framework CLI')\n .version(pkg.version)\n .option('--cwd <path>', 'Change working directory');\n\nprogram\n .command('build')\n .description('Build handlers from endpoints, functions, and crons')\n .option(\n '--provider <provider>',\n 'Target provider for generated handlers (aws, server)',\n )\n .option(\n '--providers <providers>',\n '[DEPRECATED] Use --provider instead. Target providers for generated handlers (comma-separated)',\n )\n .option(\n '--enable-openapi',\n 'Enable OpenAPI documentation generation for server builds',\n )\n .action(\n async (options: {\n provider?: string;\n providers?: string;\n enableOpenapi?: boolean;\n }) => {\n try {\n const globalOptions = program.opts();\n if (globalOptions.cwd) {\n process.chdir(globalOptions.cwd);\n }\n\n // Handle new single provider option\n if (options.provider) {\n if (!['aws', 'server'].includes(options.provider)) {\n console.error(\n `Invalid provider: ${options.provider}. Must be 'aws' or 'server'.`,\n );\n process.exit(1);\n }\n await buildCommand({\n provider: options.provider as MainProvider,\n enableOpenApi: options.enableOpenapi || false,\n });\n }\n // Handle legacy providers option\n else if (options.providers) {\n console.warn(\n '⚠️ --providers flag is deprecated. Use --provider instead.',\n );\n const providerList = [\n ...new Set(options.providers.split(',').map((p) => p.trim())),\n ] as LegacyProvider[];\n await buildCommand({\n providers: providerList,\n enableOpenApi: options.enableOpenapi || false,\n });\n }\n // Default to config-driven build\n else {\n await buildCommand({\n enableOpenApi: options.enableOpenapi || false,\n });\n }\n } catch (error) {\n console.error('Build failed:', (error as Error).message);\n process.exit(1);\n }\n },\n );\n\nprogram\n .command('dev')\n .description('Start development server with automatic reload')\n .option('--port <port>', 'Port to run the development server on', '3000')\n .option(\n '--enable-openapi',\n 'Enable OpenAPI documentation for development server',\n true,\n )\n .action(async (options: { port?: string; enableOpenapi?: boolean }) => {\n try {\n const globalOptions = program.opts();\n if (globalOptions.cwd) {\n process.chdir(globalOptions.cwd);\n }\n\n await devCommand({\n port: options.port ? Number.parseInt(options.port) : 3000,\n enableOpenApi: options.enableOpenapi ?? true,\n });\n } catch (error) {\n console.error('Dev server failed:', (error as Error).message);\n process.exit(1);\n }\n });\n\nprogram\n .command('cron')\n .description('Manage cron jobs')\n .action(() => {\n const globalOptions = program.opts();\n if (globalOptions.cwd) {\n process.chdir(globalOptions.cwd);\n }\n process.stdout.write('Cron management - coming soon\\n');\n });\n\nprogram\n .command('function')\n .description('Manage serverless functions')\n .action(() => {\n const globalOptions = program.opts();\n if (globalOptions.cwd) {\n process.chdir(globalOptions.cwd);\n }\n process.stdout.write('Serverless function management - coming soon\\n');\n });\n\nprogram\n .command('api')\n .description('Manage REST API endpoints')\n .action(() => {\n const globalOptions = program.opts();\n if (globalOptions.cwd) {\n process.chdir(globalOptions.cwd);\n }\n process.stdout.write('REST API management - coming soon\\n');\n });\n\nprogram\n .command('openapi')\n .description('Generate OpenAPI 3.0 specification from endpoints')\n .option(\n '--output <path>',\n 'Output file path for the OpenAPI spec',\n 'openapi.json',\n )\n .action(async (options: { output?: string }) => {\n try {\n const globalOptions = program.opts();\n if (globalOptions.cwd) {\n process.chdir(globalOptions.cwd);\n }\n await openapiCommand(options);\n } catch (error) {\n console.error('OpenAPI generation failed:', (error as Error).message);\n process.exit(1);\n }\n });\n\nprogram\n .command('generate:react-query')\n .description('Generate React Query hooks from OpenAPI specification')\n .option('--input <path>', 'Input OpenAPI spec file path', 'openapi.json')\n .option(\n '--output <path>',\n 'Output file path for generated hooks',\n 'src/api/hooks.ts',\n )\n .option('--name <name>', 'API name prefix for generated code', 'API')\n .action(\n async (options: { input?: string; output?: string; name?: string }) => {\n try {\n const globalOptions = program.opts();\n if (globalOptions.cwd) {\n process.chdir(globalOptions.cwd);\n }\n await generateReactQueryCommand(options);\n } catch (error) {\n console.error(\n 'React Query generation failed:',\n (error as Error).message,\n );\n process.exit(1);\n }\n },\n );\n\nprogram.parse();\n"],"mappings":";;;;;;;;;;;;;;;;;;WACU;cACG;gBACA;WACH;gBACG;CACT,KAAK;EACH,SAAS;EACT,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IAChB,SAAQ,MAAM,cAAc,IAAI;AAElC,SAAQ,OAAO,MAAM,sCAAsC;AAC5D,EAAC;AAEJ,QACG,QAAQ,UAAU,CAClB,YAAY,oDAAoD,CAChE,OACC,mBACA,yCACA,eACD,CACA,OAAO,OAAOC,YAAiC;AAC9C,KAAI;EACF,MAAM,gBAAgB,QAAQ,MAAM;AACpC,MAAI,cAAc,IAChB,SAAQ,MAAM,cAAc,IAAI;AAElC,QAAM,+BAAe,QAAQ;CAC9B,SAAQ,OAAO;AACd,UAAQ,MAAM,8BAA+B,MAAgB,QAAQ;AACrE,UAAQ,KAAK,EAAE;CAChB;AACF,EAAC;AAEJ,QACG,QAAQ,uBAAuB,CAC/B,YAAY,wDAAwD,CACpE,OAAO,kBAAkB,gCAAgC,eAAe,CACxE,OACC,mBACA,wCACA,mBACD,CACA,OAAO,iBAAiB,sCAAsC,MAAM,CACpE,OACC,OAAOC,YAAgE;AACrE,KAAI;EACF,MAAM,gBAAgB,QAAQ,MAAM;AACpC,MAAI,cAAc,IAChB,SAAQ,MAAM,cAAc,IAAI;AAElC,QAAM,sDAA0B,QAAQ;CACzC,SAAQ,OAAO;AACd,UAAQ,MACN,kCACC,MAAgB,QAClB;AACD,UAAQ,KAAK,EAAE;CAChB;AACF,EACF;AAEH,QAAQ,OAAO"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env -S npx tsx
|
|
2
2
|
import "./config-U-mdW-7Y.mjs";
|
|
3
3
|
import "./Generator-UanJW0_V.mjs";
|
|
4
|
-
import "./CronGenerator-
|
|
5
|
-
import "./EndpointGenerator-
|
|
6
|
-
import "./FunctionGenerator-
|
|
7
|
-
import "./SubscriberGenerator-
|
|
4
|
+
import "./CronGenerator-Bh26MaNA.mjs";
|
|
5
|
+
import "./EndpointGenerator-CWh18d92.mjs";
|
|
6
|
+
import "./FunctionGenerator-BNE_GC7N.mjs";
|
|
7
|
+
import "./SubscriberGenerator-Dnlj_1FK.mjs";
|
|
8
8
|
import "./generators-CsLujGXs.mjs";
|
|
9
9
|
import "./manifests-BrJXpHrf.mjs";
|
|
10
10
|
import "./providerResolver-B_TjNF0_.mjs";
|
|
11
|
-
import { buildCommand } from "./build-
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
11
|
+
import { buildCommand } from "./build-BqexeI-W.mjs";
|
|
12
|
+
import { devCommand } from "./dev-DnGYXuMn.mjs";
|
|
13
|
+
import { generateReactQueryCommand } from "./openapi-react-query-MEBlYIM1.mjs";
|
|
14
|
+
import { openapiCommand } from "./openapi-BTHbPrxS.mjs";
|
|
14
15
|
import { Command } from "commander";
|
|
15
16
|
|
|
16
17
|
//#region package.json
|
|
17
18
|
var name = "@geekmidas/cli";
|
|
18
|
-
var version = "0.2.
|
|
19
|
+
var version = "0.2.4";
|
|
19
20
|
var private$1 = false;
|
|
20
21
|
var type = "module";
|
|
21
22
|
var exports = {
|
|
@@ -42,25 +43,31 @@ var scripts = {
|
|
|
42
43
|
"test:once": "vitest run",
|
|
43
44
|
"test:coverage": "vitest run --coverage"
|
|
44
45
|
};
|
|
46
|
+
var repository = {
|
|
47
|
+
"type": "git",
|
|
48
|
+
"url": "https://github.com/geekmidas/toolbox"
|
|
49
|
+
};
|
|
45
50
|
var dependencies = {
|
|
46
51
|
"@apidevtools/swagger-parser": "^10.1.0",
|
|
52
|
+
"chokidar": "~4.0.3",
|
|
47
53
|
"commander": "^12.1.0",
|
|
48
54
|
"fast-glob": "^3.3.2",
|
|
49
55
|
"lodash.kebabcase": "^4.1.1",
|
|
50
56
|
"openapi-typescript": "^7.4.2"
|
|
51
57
|
};
|
|
52
58
|
var devDependencies = {
|
|
53
|
-
"@types/lodash.kebabcase": "^4.1.9",
|
|
54
59
|
"@geekmidas/testkit": "workspace:*",
|
|
60
|
+
"@types/lodash.kebabcase": "^4.1.9",
|
|
61
|
+
"@types/node": "~24.9.1",
|
|
55
62
|
"typescript": "^5.8.2",
|
|
56
63
|
"vitest": "^3.2.4",
|
|
57
|
-
"zod": "
|
|
64
|
+
"zod": "~4.1.13"
|
|
58
65
|
};
|
|
59
66
|
var peerDependencies = {
|
|
60
67
|
"@geekmidas/constructs": "workspace:~",
|
|
61
|
-
"@geekmidas/schema": "workspace:~",
|
|
62
68
|
"@geekmidas/envkit": "workspace:~",
|
|
63
|
-
"@geekmidas/logger": "workspace:~"
|
|
69
|
+
"@geekmidas/logger": "workspace:~",
|
|
70
|
+
"@geekmidas/schema": "workspace:~"
|
|
64
71
|
};
|
|
65
72
|
var package_default = {
|
|
66
73
|
name,
|
|
@@ -70,6 +77,7 @@ var package_default = {
|
|
|
70
77
|
exports,
|
|
71
78
|
bin,
|
|
72
79
|
scripts,
|
|
80
|
+
repository,
|
|
73
81
|
dependencies,
|
|
74
82
|
devDependencies,
|
|
75
83
|
peerDependencies
|
|
@@ -105,6 +113,19 @@ program.command("build").description("Build handlers from endpoints, functions,
|
|
|
105
113
|
process.exit(1);
|
|
106
114
|
}
|
|
107
115
|
});
|
|
116
|
+
program.command("dev").description("Start development server with automatic reload").option("--port <port>", "Port to run the development server on", "3000").option("--enable-openapi", "Enable OpenAPI documentation for development server", true).action(async (options) => {
|
|
117
|
+
try {
|
|
118
|
+
const globalOptions = program.opts();
|
|
119
|
+
if (globalOptions.cwd) process.chdir(globalOptions.cwd);
|
|
120
|
+
await devCommand({
|
|
121
|
+
port: options.port ? Number.parseInt(options.port) : 3e3,
|
|
122
|
+
enableOpenApi: options.enableOpenapi ?? true
|
|
123
|
+
});
|
|
124
|
+
} catch (error) {
|
|
125
|
+
console.error("Dev server failed:", error.message);
|
|
126
|
+
process.exit(1);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
108
129
|
program.command("cron").description("Manage cron jobs").action(() => {
|
|
109
130
|
const globalOptions = program.opts();
|
|
110
131
|
if (globalOptions.cwd) process.chdir(globalOptions.cwd);
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["pkg","options: {\n provider?: string;\n providers?: string;\n enableOpenapi?: boolean;\n }","options: { output?: string }","options: { input?: string; output?: string; name?: string }"],"sources":["../package.json","../src/index.ts"],"sourcesContent":["{\n \"name\": \"@geekmidas/cli\",\n \"version\": \"0.2.3\",\n \"private\": false,\n \"type\": \"module\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./openapi\": {\n \"types\": \"./dist/openapi.d.ts\",\n \"import\": \"./dist/openapi.mjs\",\n \"require\": \"./dist/openapi.cjs\"\n },\n \"./openapi-react-query\": {\n \"types\": \"./dist/openapi-react-query.d.ts\",\n \"import\": \"./dist/openapi-react-query.mjs\",\n \"require\": \"./dist/openapi-react-query.cjs\"\n }\n },\n \"bin\": {\n \"gkm\": \"./dist/index.cjs\"\n },\n \"scripts\": {\n \"ts\": \"tsc --noEmit --skipLibCheck src/**/*.ts\",\n \"test\": \"vitest\",\n \"test:once\": \"vitest run\",\n \"test:coverage\": \"vitest run --coverage\"\n },\n \"dependencies\": {\n \"@apidevtools/swagger-parser\": \"^10.1.0\",\n \"commander\": \"^12.1.0\",\n \"fast-glob\": \"^3.3.2\",\n \"lodash.kebabcase\": \"^4.1.1\",\n \"openapi-typescript\": \"^7.4.2\"\n },\n \"devDependencies\": {\n \"@types/lodash.kebabcase\": \"^4.1.9\",\n \"@geekmidas/testkit\": \"workspace:*\",\n \"typescript\": \"^5.8.2\",\n \"vitest\": \"^3.2.4\",\n \"zod\": \"^3.23.8\"\n },\n \"peerDependencies\": {\n \"@geekmidas/constructs\": \"workspace:~\",\n \"@geekmidas/schema\": \"workspace:~\",\n \"@geekmidas/envkit\": \"workspace:~\",\n \"@geekmidas/logger\": \"workspace:~\"\n }\n}\n","#!/usr/bin/env -S npx tsx\n\nimport { Command } from 'commander';\nimport pkg from '../package.json' assert { type: 'json' };\nimport { buildCommand } from './build/index.ts';\nimport { generateReactQueryCommand } from './openapi-react-query.ts';\nimport { openapiCommand } from './openapi.ts';\nimport type { LegacyProvider, MainProvider } from './types.ts';\n\nconst program = new Command();\n\nprogram\n .name('gkm')\n .description('GeekMidas backend framework CLI')\n .version(pkg.version)\n .option('--cwd <path>', 'Change working directory');\n\nprogram\n .command('build')\n .description('Build handlers from endpoints, functions, and crons')\n .option(\n '--provider <provider>',\n 'Target provider for generated handlers (aws, server)',\n )\n .option(\n '--providers <providers>',\n '[DEPRECATED] Use --provider instead. Target providers for generated handlers (comma-separated)',\n )\n .option(\n '--enable-openapi',\n 'Enable OpenAPI documentation generation for server builds',\n )\n .action(\n async (options: {\n provider?: string;\n providers?: string;\n enableOpenapi?: boolean;\n }) => {\n try {\n const globalOptions = program.opts();\n if (globalOptions.cwd) {\n process.chdir(globalOptions.cwd);\n }\n\n // Handle new single provider option\n if (options.provider) {\n if (!['aws', 'server'].includes(options.provider)) {\n console.error(\n `Invalid provider: ${options.provider}. Must be 'aws' or 'server'.`,\n );\n process.exit(1);\n }\n await buildCommand({\n provider: options.provider as MainProvider,\n enableOpenApi: options.enableOpenapi || false,\n });\n }\n // Handle legacy providers option\n else if (options.providers) {\n console.warn(\n '⚠️ --providers flag is deprecated. Use --provider instead.',\n );\n const providerList = [\n ...new Set(options.providers.split(',').map((p) => p.trim())),\n ] as LegacyProvider[];\n await buildCommand({\n providers: providerList,\n enableOpenApi: options.enableOpenapi || false,\n });\n }\n // Default to config-driven build\n else {\n await buildCommand({\n enableOpenApi: options.enableOpenapi || false,\n });\n }\n } catch (error) {\n console.error('Build failed:', (error as Error).message);\n process.exit(1);\n }\n },\n );\n\nprogram\n .command('cron')\n .description('Manage cron jobs')\n .action(() => {\n const globalOptions = program.opts();\n if (globalOptions.cwd) {\n process.chdir(globalOptions.cwd);\n }\n process.stdout.write('Cron management - coming soon\\n');\n });\n\nprogram\n .command('function')\n .description('Manage serverless functions')\n .action(() => {\n const globalOptions = program.opts();\n if (globalOptions.cwd) {\n process.chdir(globalOptions.cwd);\n }\n process.stdout.write('Serverless function management - coming soon\\n');\n });\n\nprogram\n .command('api')\n .description('Manage REST API endpoints')\n .action(() => {\n const globalOptions = program.opts();\n if (globalOptions.cwd) {\n process.chdir(globalOptions.cwd);\n }\n process.stdout.write('REST API management - coming soon\\n');\n });\n\nprogram\n .command('openapi')\n .description('Generate OpenAPI 3.0 specification from endpoints')\n .option(\n '--output <path>',\n 'Output file path for the OpenAPI spec',\n 'openapi.json',\n )\n .action(async (options: { output?: string }) => {\n try {\n const globalOptions = program.opts();\n if (globalOptions.cwd) {\n process.chdir(globalOptions.cwd);\n }\n await openapiCommand(options);\n } catch (error) {\n console.error('OpenAPI generation failed:', (error as Error).message);\n process.exit(1);\n }\n });\n\nprogram\n .command('generate:react-query')\n .description('Generate React Query hooks from OpenAPI specification')\n .option('--input <path>', 'Input OpenAPI spec file path', 'openapi.json')\n .option(\n '--output <path>',\n 'Output file path for generated hooks',\n 'src/api/hooks.ts',\n )\n .option('--name <name>', 'API name prefix for generated code', 'API')\n .action(\n async (options: { input?: string; output?: string; name?: string }) => {\n try {\n const globalOptions = program.opts();\n if (globalOptions.cwd) {\n process.chdir(globalOptions.cwd);\n }\n await generateReactQueryCommand(options);\n } catch (error) {\n console.error(\n 'React Query generation failed:',\n (error as Error).message,\n );\n process.exit(1);\n }\n },\n );\n\nprogram.parse();\n"],"mappings":";;;;;;;;;;;;;;;;WACU;cACG;gBACA;WACH;cACG;CACT,KAAK;EACH,SAAS;EACT,UAAU;EACV,WAAW;CACZ;CACD,aAAa;EACX,SAAS;EACT,UAAU;EACV,WAAW;CACZ;CACD,yBAAyB;EACvB,SAAS;EACT,UAAU;EACV,WAAW;CACZ;AACF;UACM,EACL,OAAO,mBACR;cACU;CACT,MAAM;CACN,QAAQ;CACR,aAAa;CACb,iBAAiB;AAClB;mBACe;CACd,+BAA+B;CAC/B,aAAa;CACb,aAAa;CACb,oBAAoB;CACpB,sBAAsB;AACvB;sBACkB;CACjB,2BAA2B;CAC3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
{"version":3,"file":"index.mjs","names":["pkg","options: {\n provider?: string;\n providers?: string;\n enableOpenapi?: boolean;\n }","options: { port?: string; enableOpenapi?: boolean }","options: { output?: string }","options: { input?: string; output?: string; name?: string }"],"sources":["../package.json","../src/index.ts"],"sourcesContent":["{\n \"name\": \"@geekmidas/cli\",\n \"version\": \"0.2.4\",\n \"private\": false,\n \"type\": \"module\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./openapi\": {\n \"types\": \"./dist/openapi.d.ts\",\n \"import\": \"./dist/openapi.mjs\",\n \"require\": \"./dist/openapi.cjs\"\n },\n \"./openapi-react-query\": {\n \"types\": \"./dist/openapi-react-query.d.ts\",\n \"import\": \"./dist/openapi-react-query.mjs\",\n \"require\": \"./dist/openapi-react-query.cjs\"\n }\n },\n \"bin\": {\n \"gkm\": \"./dist/index.cjs\"\n },\n \"scripts\": {\n \"ts\": \"tsc --noEmit --skipLibCheck src/**/*.ts\",\n \"test\": \"vitest\",\n \"test:once\": \"vitest run\",\n \"test:coverage\": \"vitest run --coverage\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/geekmidas/toolbox\"\n },\n \"dependencies\": {\n \"@apidevtools/swagger-parser\": \"^10.1.0\",\n \"chokidar\": \"~4.0.3\",\n \"commander\": \"^12.1.0\",\n \"fast-glob\": \"^3.3.2\",\n \"lodash.kebabcase\": \"^4.1.1\",\n \"openapi-typescript\": \"^7.4.2\"\n },\n \"devDependencies\": {\n \"@geekmidas/testkit\": \"workspace:*\",\n \"@types/lodash.kebabcase\": \"^4.1.9\",\n \"@types/node\": \"~24.9.1\",\n \"typescript\": \"^5.8.2\",\n \"vitest\": \"^3.2.4\",\n \"zod\": \"~4.1.13\"\n },\n \"peerDependencies\": {\n \"@geekmidas/constructs\": \"workspace:~\",\n \"@geekmidas/envkit\": \"workspace:~\",\n \"@geekmidas/logger\": \"workspace:~\",\n \"@geekmidas/schema\": \"workspace:~\"\n }\n}\n","#!/usr/bin/env -S npx tsx\n\nimport { Command } from 'commander';\nimport pkg from '../package.json' assert { type: 'json' };\nimport { buildCommand } from './build/index.ts';\nimport { devCommand } from './dev/index.ts';\nimport { generateReactQueryCommand } from './openapi-react-query.ts';\nimport { openapiCommand } from './openapi.ts';\nimport type { LegacyProvider, MainProvider } from './types.ts';\n\nconst program = new Command();\n\nprogram\n .name('gkm')\n .description('GeekMidas backend framework CLI')\n .version(pkg.version)\n .option('--cwd <path>', 'Change working directory');\n\nprogram\n .command('build')\n .description('Build handlers from endpoints, functions, and crons')\n .option(\n '--provider <provider>',\n 'Target provider for generated handlers (aws, server)',\n )\n .option(\n '--providers <providers>',\n '[DEPRECATED] Use --provider instead. Target providers for generated handlers (comma-separated)',\n )\n .option(\n '--enable-openapi',\n 'Enable OpenAPI documentation generation for server builds',\n )\n .action(\n async (options: {\n provider?: string;\n providers?: string;\n enableOpenapi?: boolean;\n }) => {\n try {\n const globalOptions = program.opts();\n if (globalOptions.cwd) {\n process.chdir(globalOptions.cwd);\n }\n\n // Handle new single provider option\n if (options.provider) {\n if (!['aws', 'server'].includes(options.provider)) {\n console.error(\n `Invalid provider: ${options.provider}. Must be 'aws' or 'server'.`,\n );\n process.exit(1);\n }\n await buildCommand({\n provider: options.provider as MainProvider,\n enableOpenApi: options.enableOpenapi || false,\n });\n }\n // Handle legacy providers option\n else if (options.providers) {\n console.warn(\n '⚠️ --providers flag is deprecated. Use --provider instead.',\n );\n const providerList = [\n ...new Set(options.providers.split(',').map((p) => p.trim())),\n ] as LegacyProvider[];\n await buildCommand({\n providers: providerList,\n enableOpenApi: options.enableOpenapi || false,\n });\n }\n // Default to config-driven build\n else {\n await buildCommand({\n enableOpenApi: options.enableOpenapi || false,\n });\n }\n } catch (error) {\n console.error('Build failed:', (error as Error).message);\n process.exit(1);\n }\n },\n );\n\nprogram\n .command('dev')\n .description('Start development server with automatic reload')\n .option('--port <port>', 'Port to run the development server on', '3000')\n .option(\n '--enable-openapi',\n 'Enable OpenAPI documentation for development server',\n true,\n )\n .action(async (options: { port?: string; enableOpenapi?: boolean }) => {\n try {\n const globalOptions = program.opts();\n if (globalOptions.cwd) {\n process.chdir(globalOptions.cwd);\n }\n\n await devCommand({\n port: options.port ? Number.parseInt(options.port) : 3000,\n enableOpenApi: options.enableOpenapi ?? true,\n });\n } catch (error) {\n console.error('Dev server failed:', (error as Error).message);\n process.exit(1);\n }\n });\n\nprogram\n .command('cron')\n .description('Manage cron jobs')\n .action(() => {\n const globalOptions = program.opts();\n if (globalOptions.cwd) {\n process.chdir(globalOptions.cwd);\n }\n process.stdout.write('Cron management - coming soon\\n');\n });\n\nprogram\n .command('function')\n .description('Manage serverless functions')\n .action(() => {\n const globalOptions = program.opts();\n if (globalOptions.cwd) {\n process.chdir(globalOptions.cwd);\n }\n process.stdout.write('Serverless function management - coming soon\\n');\n });\n\nprogram\n .command('api')\n .description('Manage REST API endpoints')\n .action(() => {\n const globalOptions = program.opts();\n if (globalOptions.cwd) {\n process.chdir(globalOptions.cwd);\n }\n process.stdout.write('REST API management - coming soon\\n');\n });\n\nprogram\n .command('openapi')\n .description('Generate OpenAPI 3.0 specification from endpoints')\n .option(\n '--output <path>',\n 'Output file path for the OpenAPI spec',\n 'openapi.json',\n )\n .action(async (options: { output?: string }) => {\n try {\n const globalOptions = program.opts();\n if (globalOptions.cwd) {\n process.chdir(globalOptions.cwd);\n }\n await openapiCommand(options);\n } catch (error) {\n console.error('OpenAPI generation failed:', (error as Error).message);\n process.exit(1);\n }\n });\n\nprogram\n .command('generate:react-query')\n .description('Generate React Query hooks from OpenAPI specification')\n .option('--input <path>', 'Input OpenAPI spec file path', 'openapi.json')\n .option(\n '--output <path>',\n 'Output file path for generated hooks',\n 'src/api/hooks.ts',\n )\n .option('--name <name>', 'API name prefix for generated code', 'API')\n .action(\n async (options: { input?: string; output?: string; name?: string }) => {\n try {\n const globalOptions = program.opts();\n if (globalOptions.cwd) {\n process.chdir(globalOptions.cwd);\n }\n await generateReactQueryCommand(options);\n } catch (error) {\n console.error(\n 'React Query generation failed:',\n (error as Error).message,\n );\n process.exit(1);\n }\n },\n );\n\nprogram.parse();\n"],"mappings":";;;;;;;;;;;;;;;;;WACU;cACG;gBACA;WACH;cACG;CACT,KAAK;EACH,SAAS;EACT,UAAU;EACV,WAAW;CACZ;CACD,aAAa;EACX,SAAS;EACT,UAAU;EACV,WAAW;CACZ;CACD,yBAAyB;EACvB,SAAS;EACT,UAAU;EACV,WAAW;CACZ;AACF;UACM,EACL,OAAO,mBACR;cACU;CACT,MAAM;CACN,QAAQ;CACR,aAAa;CACb,iBAAiB;AAClB;iBACa;CACZ,QAAQ;CACR,OAAO;AACR;mBACe;CACd,+BAA+B;CAC/B,YAAY;CACZ,aAAa;CACb,aAAa;CACb,oBAAoB;CACpB,sBAAsB;AACvB;sBACkB;CACjB,sBAAsB;CACtB,2BAA2B;CAC3B,eAAe;CACf,cAAc;CACd,UAAU;CACV,OAAO;AACR;uBACmB;CAClB,yBAAyB;CACzB,qBAAqB;CACrB,qBAAqB;CACrB,qBAAqB;AACtB;sBAxDH;;;;;;;;;;;;AAyDC;;;;AC/CD,MAAM,UAAU,IAAI;AAEpB,QACG,KAAK,MAAM,CACX,YAAY,kCAAkC,CAC9C,QAAQA,gBAAI,QAAQ,CACpB,OAAO,gBAAgB,2BAA2B;AAErD,QACG,QAAQ,QAAQ,CAChB,YAAY,sDAAsD,CAClE,OACC,yBACA,uDACD,CACA,OACC,2BACA,iGACD,CACA,OACC,oBACA,4DACD,CACA,OACC,OAAOC,YAID;AACJ,KAAI;EACF,MAAM,gBAAgB,QAAQ,MAAM;AACpC,MAAI,cAAc,IAChB,SAAQ,MAAM,cAAc,IAAI;AAIlC,MAAI,QAAQ,UAAU;AACpB,QAAK,CAAC,OAAO,QAAS,EAAC,SAAS,QAAQ,SAAS,EAAE;AACjD,YAAQ,OACL,oBAAoB,QAAQ,SAAS,8BACvC;AAC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M;AACpC,KAAI,cAAc,IAChB,SAAQ,MAAM,cAAc,IAAI;AAElC,SAAQ,OAAO,MAAM,iDAAiD;AACvE,EAAC;AAEJ,QACG,QAAQ,MAAM,CACd,YAAY,4BAA4B,CACxC,OAAO,MAAM;CACZ,MAAM,gBAAgB,QAAQ,MAAM;AACpC,KAAI,cAAc,IAChB,SAAQ,MAAM,cAAc,IAAI;AAElC,SAAQ,OAAO,MAAM,sCAAsC;AAC5D,EAAC;AAEJ,QACG,QAAQ,UAAU,CAClB,YAAY,oDAAoD,CAChE,OACC,mBACA,yCACA,eACD,CACA,OAAO,OAAOC,YAAiC;AAC9C,KAAI;EACF,MAAM,gBAAgB,QAAQ,MAAM;AACpC,MAAI,cAAc,IAChB,SAAQ,MAAM,cAAc,IAAI;AAElC,QAAM,eAAe,QAAQ;CAC9B,SAAQ,OAAO;AACd,UAAQ,MAAM,8BAA+B,MAAgB,QAAQ;AACrE,UAAQ,KAAK,EAAE;CAChB;AACF,EAAC;AAEJ,QACG,QAAQ,uBAAuB,CAC/B,YAAY,wDAAwD,CACpE,OAAO,kBAAkB,gCAAgC,eAAe,CACxE,OACC,mBACA,wCACA,mBACD,CACA,OAAO,iBAAiB,sCAAsC,MAAM,CACpE,OACC,OAAOC,YAAgE;AACrE,KAAI;EACF,MAAM,gBAAgB,QAAQ,MAAM;AACpC,MAAI,cAAc,IAChB,SAAQ,MAAM,cAAc,IAAI;AAElC,QAAM,0BAA0B,QAAQ;CACzC,SAAQ,OAAO;AACd,UAAQ,MACN,kCACC,MAAgB,QAClB;AACD,UAAQ,KAAK,EAAE;CAChB;AACF,EACF;AAEH,QAAQ,OAAO"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { loadConfig } from "./config-U-mdW-7Y.mjs";
|
|
2
|
-
import { EndpointGenerator } from "./EndpointGenerator-
|
|
2
|
+
import { EndpointGenerator } from "./EndpointGenerator-CWh18d92.mjs";
|
|
3
3
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import { Endpoint } from "@geekmidas/constructs/endpoints";
|
|
@@ -33,4 +33,4 @@ async function openapiCommand(options = {}) {
|
|
|
33
33
|
|
|
34
34
|
//#endregion
|
|
35
35
|
export { openapiCommand };
|
|
36
|
-
//# sourceMappingURL=openapi-
|
|
36
|
+
//# sourceMappingURL=openapi-BTHbPrxS.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openapi-
|
|
1
|
+
{"version":3,"file":"openapi-BTHbPrxS.mjs","names":["options: OpenAPIOptions"],"sources":["../src/openapi.ts"],"sourcesContent":["#!/usr/bin/env -S npx tsx\n\nimport { mkdir, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { Endpoint } from '@geekmidas/constructs/endpoints';\nimport { loadConfig } from './config.js';\nimport { EndpointGenerator } from './generators/EndpointGenerator.js';\n\ninterface OpenAPIOptions {\n output?: 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();\n const generator = new EndpointGenerator();\n\n // Load all endpoints using the refactored function\n const loadedEndpoints = await generator.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 // Generate OpenAPI spec using built-in method\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 // Write output\n const outputPath = options.output || join(process.cwd(), 'openapi.json');\n await mkdir(join(outputPath, '..'), { recursive: true });\n await writeFile(outputPath, JSON.stringify(spec, null, 2));\n\n logger.log(`OpenAPI spec generated: ${outputPath}`);\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":";;;;;;;AAYA,eAAsB,eACpBA,UAA0B,CAAE,GACb;CACf,MAAM,SAAS;AAEf,KAAI;EAEF,MAAM,SAAS,MAAM,YAAY;EACjC,MAAM,YAAY,IAAI;EAGtB,MAAM,kBAAkB,MAAM,UAAU,KAAK,OAAO,OAAO;AAE3D,MAAI,gBAAgB,WAAW,GAAG;AAChC,UAAO,IAAI,2BAA2B;AACtC;EACD;EAGD,MAAM,YAAY,gBAAgB,IAAI,CAAC,EAAE,WAAW,KAAK,UAAU;EAGnE,MAAM,OAAO,MAAM,SAAS,mBAAmB,WAAW;GACxD,OAAO;GACP,SAAS;GACT,aAAa;EACd,EAAC;EAGF,MAAM,aAAa,QAAQ,UAAU,KAAK,QAAQ,KAAK,EAAE,eAAe;AACxE,QAAM,MAAM,KAAK,YAAY,KAAK,EAAE,EAAE,WAAW,KAAM,EAAC;AACxD,QAAM,UAAU,YAAY,KAAK,UAAU,MAAM,MAAM,EAAE,CAAC;AAE1D,SAAO,KAAK,0BAA0B,WAAW,EAAE;AACnD,SAAO,KAAK,QAAQ,UAAU,OAAO,YAAY;CAClD,SAAQ,OAAO;AACd,QAAM,IAAI,OAAO,6BAA8B,MAAgB,QAAQ;CACxE;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
2
|
const require_config = require('./config-D1EpSGk6.cjs');
|
|
3
|
-
const require_EndpointGenerator = require('./EndpointGenerator-
|
|
3
|
+
const require_EndpointGenerator = require('./EndpointGenerator-C73wNoih.cjs');
|
|
4
4
|
const node_fs_promises = require_chunk.__toESM(require("node:fs/promises"));
|
|
5
5
|
const node_path = require_chunk.__toESM(require("node:path"));
|
|
6
6
|
const __geekmidas_constructs_endpoints = require_chunk.__toESM(require("@geekmidas/constructs/endpoints"));
|
|
@@ -39,4 +39,4 @@ Object.defineProperty(exports, 'openapiCommand', {
|
|
|
39
39
|
return openapiCommand;
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
|
-
//# sourceMappingURL=openapi-
|
|
42
|
+
//# sourceMappingURL=openapi-CewcfoRH.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openapi-
|
|
1
|
+
{"version":3,"file":"openapi-CewcfoRH.cjs","names":["options: OpenAPIOptions","EndpointGenerator"],"sources":["../src/openapi.ts"],"sourcesContent":["#!/usr/bin/env -S npx tsx\n\nimport { mkdir, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { Endpoint } from '@geekmidas/constructs/endpoints';\nimport { loadConfig } from './config.js';\nimport { EndpointGenerator } from './generators/EndpointGenerator.js';\n\ninterface OpenAPIOptions {\n output?: 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();\n const generator = new EndpointGenerator();\n\n // Load all endpoints using the refactored function\n const loadedEndpoints = await generator.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 // Generate OpenAPI spec using built-in method\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 // Write output\n const outputPath = options.output || join(process.cwd(), 'openapi.json');\n await mkdir(join(outputPath, '..'), { recursive: true });\n await writeFile(outputPath, JSON.stringify(spec, null, 2));\n\n logger.log(`OpenAPI spec generated: ${outputPath}`);\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":";;;;;;;;AAYA,eAAsB,eACpBA,UAA0B,CAAE,GACb;CACf,MAAM,SAAS;AAEf,KAAI;EAEF,MAAM,SAAS,MAAM,2BAAY;EACjC,MAAM,YAAY,IAAIC;EAGtB,MAAM,kBAAkB,MAAM,UAAU,KAAK,OAAO,OAAO;AAE3D,MAAI,gBAAgB,WAAW,GAAG;AAChC,UAAO,IAAI,2BAA2B;AACtC;EACD;EAGD,MAAM,YAAY,gBAAgB,IAAI,CAAC,EAAE,WAAW,KAAK,UAAU;EAGnE,MAAM,OAAO,MAAM,0CAAS,mBAAmB,WAAW;GACxD,OAAO;GACP,SAAS;GACT,aAAa;EACd,EAAC;EAGF,MAAM,aAAa,QAAQ,UAAU,oBAAK,QAAQ,KAAK,EAAE,eAAe;AACxE,QAAM,4BAAM,oBAAK,YAAY,KAAK,EAAE,EAAE,WAAW,KAAM,EAAC;AACxD,QAAM,gCAAU,YAAY,KAAK,UAAU,MAAM,MAAM,EAAE,CAAC;AAE1D,SAAO,KAAK,0BAA0B,WAAW,EAAE;AACnD,SAAO,KAAK,QAAQ,UAAU,OAAO,YAAY;CAClD,SAAQ,OAAO;AACd,QAAM,IAAI,OAAO,6BAA8B,MAAgB,QAAQ;CACxE;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openapi-react-query-Dvjqx_Eo.cjs","names":["exec","options: ReactQueryOptions","spec: OpenAPISpec","operations: OperationInfo[]","operation: any","schema: any","apiName: string","op: OperationInfo","paramParts: string[]","exports","str: string"],"sources":["../src/openapi-react-query.ts"],"sourcesContent":["#!/usr/bin/env -S npx tsx\n\nimport { exec } from 'node:child_process';\nimport { existsSync } from 'node:fs';\nimport { mkdir, readFile, writeFile } from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\nimport { promisify } from 'node:util';\n\nconst execAsync = promisify(exec);\n\ninterface ReactQueryOptions {\n input?: string;\n output?: string;\n name?: string;\n}\n\ninterface OpenAPISpec {\n openapi: string;\n info?: {\n title?: string;\n version?: string;\n };\n paths: Record<string, Record<string, any>>;\n}\n\nexport async function generateReactQueryCommand(\n options: ReactQueryOptions = {},\n): Promise<void> {\n const logger = console;\n\n try {\n // Read OpenAPI spec\n const inputPath = options.input || join(process.cwd(), 'openapi.json');\n\n if (!existsSync(inputPath)) {\n throw new Error(\n `OpenAPI spec not found at ${inputPath}. Run 'npx @geekmidas/cli openapi' first.`,\n );\n }\n\n const specContent = await readFile(inputPath, 'utf-8');\n const spec: OpenAPISpec = JSON.parse(specContent);\n\n // Generate TypeScript types from OpenAPI spec\n const outputDir = dirname(\n options.output || join(process.cwd(), 'src', 'api', 'hooks.ts'),\n );\n const typesPath = join(outputDir, 'openapi-types.d.ts');\n\n logger.log('Generating TypeScript types from OpenAPI spec...');\n\n try {\n // Use npx to run openapi-typescript\n await execAsync(\n `npx openapi-typescript \"${inputPath}\" -o \"${typesPath}\"`,\n { cwd: process.cwd() },\n );\n logger.log(`TypeScript types generated: ${typesPath}`);\n } catch (error) {\n logger.warn(\n 'Could not generate types with openapi-typescript. Install it for better type inference.',\n );\n logger.warn('Run: npm install -D openapi-typescript');\n\n // Generate basic types file\n await mkdir(dirname(typesPath), { recursive: true });\n await writeFile(\n typesPath,\n `// Auto-generated placeholder types\nexport interface paths {\n [path: string]: {\n [method: string]: {\n operationId?: string;\n parameters?: any;\n requestBody?: any;\n responses?: any;\n };\n };\n}\n`,\n );\n }\n\n // Extract operation info\n const operations = extractOperations(spec);\n\n // Generate TypeScript code\n const code = generateReactQueryCode(\n spec,\n operations,\n options.name || 'API',\n );\n\n // Write output\n const outputPath =\n options.output || join(process.cwd(), 'src', 'api', 'hooks.ts');\n await mkdir(dirname(outputPath), { recursive: true });\n await writeFile(outputPath, code);\n\n logger.log(`React Query hooks generated: ${outputPath}`);\n logger.log(`Generated ${operations.length} hooks`);\n } catch (error) {\n throw new Error(\n `React Query generation failed: ${(error as Error).message}`,\n );\n }\n}\n\ninterface OperationInfo {\n operationId: string;\n path: string;\n method: string;\n endpoint: string; // Full endpoint like 'GET /users/{id}'\n parameters?: Array<{ name: string; in: string; required?: boolean }>;\n requestBody?: boolean;\n responseType?: string;\n}\n\nfunction extractOperations(spec: OpenAPISpec): OperationInfo[] {\n const operations: OperationInfo[] = [];\n\n Object.entries(spec.paths).forEach(([path, methods]) => {\n Object.entries(methods).forEach(([method, operation]) => {\n if (operation.operationId) {\n operations.push({\n operationId: operation.operationId,\n path,\n method: method.toUpperCase(),\n endpoint: `${method.toUpperCase()} ${path}`,\n parameters: operation.parameters,\n requestBody: !!operation.requestBody,\n responseType: extractResponseType(operation),\n });\n }\n });\n });\n\n return operations;\n}\n\nfunction extractResponseType(operation: any): string {\n const responses = operation.responses;\n if (!responses) return 'unknown';\n\n const successResponse = responses['200'] || responses['201'];\n if (!successResponse?.content?.['application/json']?.schema) {\n return 'unknown';\n }\n\n // Basic type inference from schema\n const schema = successResponse.content['application/json'].schema;\n return schemaToTypeString(schema);\n}\n\nfunction schemaToTypeString(schema: any): string {\n if (!schema) return 'unknown';\n\n switch (schema.type) {\n case 'string':\n return 'string';\n case 'number':\n case 'integer':\n return 'number';\n case 'boolean':\n return 'boolean';\n case 'array':\n return `Array<${schemaToTypeString(schema.items)}>`;\n case 'object':\n if (schema.properties) {\n const props = Object.entries(schema.properties)\n .map(\n ([key, value]: [string, any]) =>\n `${key}: ${schemaToTypeString(value)}`,\n )\n .join('; ');\n return `{ ${props} }`;\n }\n return 'Record<string, unknown>';\n default:\n return 'unknown';\n }\n}\n\nfunction generateReactQueryCode(\n spec: OpenAPISpec,\n operations: OperationInfo[],\n apiName: string,\n): string {\n const imports = `import { createTypedQueryClient } from '@geekmidas/client';\nimport type { paths } from './openapi-types';\n\n// Create typed query client\nexport const ${apiName.toLowerCase()} = createTypedQueryClient<paths>({\n baseURL: process.env.NEXT_PUBLIC_API_URL || '/api',\n});\n\n// Export individual hooks for better DX\n`;\n\n const queryHooks = operations\n .filter((op) => op.method === 'GET')\n .map((op) => generateQueryHook(op, apiName))\n .join('\\n\\n');\n\n const mutationHooks = operations\n .filter((op) => op.method !== 'GET')\n .map((op) => generateMutationHook(op, apiName))\n .join('\\n\\n');\n\n const typeExports = generateTypeExports(operations);\n\n return `${imports}\n// Query Hooks\n${queryHooks}\n\n// Mutation Hooks\n${mutationHooks}\n\n// Type exports for convenience\n${typeExports}\n\n// Re-export the api for advanced usage\nexport { ${apiName.toLowerCase()} };\n`;\n}\n\nfunction generateQueryHook(op: OperationInfo, apiName: string): string {\n const hookName = `use${capitalize(op.operationId)}`;\n const endpoint = op.endpoint;\n const hasParams = op.parameters?.some((p) => p.in === 'path');\n const hasQuery = op.parameters?.some((p) => p.in === 'query');\n\n // Generate properly typed hook\n let params = '';\n let args = '';\n\n if (hasParams || hasQuery) {\n const paramParts: string[] = [];\n if (hasParams) {\n const pathParams =\n op.parameters?.filter((p) => p.in === 'path').map((p) => p.name) || [];\n paramParts.push(\n `params: { ${pathParams.map((p) => `${p}: string`).join('; ')} }`,\n );\n }\n if (hasQuery) {\n paramParts.push(`query?: Record<string, any>`);\n }\n params = `config: { ${paramParts.join('; ')} }, `;\n args = ', config';\n }\n\n return `export const ${hookName} = (\n ${params}options?: Parameters<typeof ${apiName.toLowerCase()}.useQuery>[2]\n) => {\n return ${apiName.toLowerCase()}.useQuery('${endpoint}' as any${args}, options);\n};`;\n}\n\nfunction generateMutationHook(op: OperationInfo, apiName: string): string {\n const hookName = `use${capitalize(op.operationId)}`;\n const endpoint = op.endpoint;\n\n return `export const ${hookName} = (\n options?: Parameters<typeof ${apiName.toLowerCase()}.useMutation>[1]\n) => {\n return ${apiName.toLowerCase()}.useMutation('${endpoint}' as any, options);\n};`;\n}\n\nfunction generateTypeExports(operations: OperationInfo[]): string {\n const exports = operations.map((op) => {\n const typeName = capitalize(op.operationId);\n const isQuery = op.method === 'GET';\n\n if (isQuery) {\n return `export type ${typeName}Response = Awaited<ReturnType<ReturnType<typeof use${typeName}>['data']>>;`;\n } else {\n return `export type ${typeName}Response = Awaited<ReturnType<ReturnType<typeof use${typeName}>['mutateAsync']>>;`;\n }\n });\n\n return exports.join('\\n');\n}\n\nfunction capitalize(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n"],"mappings":";;;;;;;;AAQA,MAAM,YAAY,y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AY,CAAC;CAClD,MAAM,WAAW,GAAG;AAEpB,SAAQ,eAAe,SAAS;gCACF,QAAQ,aAAa,CAAC;;WAE3C,QAAQ,aAAa,CAAC,gBAAgB,SAAS;;AAEzD;AAED,SAAS,oBAAoBH,YAAqC;CAChE,MAAMM,YAAU,WAAW,IAAI,CAAC,OAAO;EACrC,MAAM,WAAW,WAAW,GAAG,YAAY;EAC3C,MAAM,UAAU,GAAG,WAAW;AAE9B,MAAI,QACF,SAAQ,cAAc,SAAS,qDAAqD,SAAS;MAE7F,SAAQ,cAAc,SAAS,qDAAqD,SAAS;CAEhG,EAAC;AAEF,QAAO,UAAQ,KAAK,KAAK;AAC1B;AAED,SAAS,WAAWC,KAAqB;AACvC,QAAO,IAAI,OAAO,EAAE,CAAC,aAAa,GAAG,IAAI,MAAM,EAAE;AAClD"}
|
|
1
|
+
{"version":3,"file":"openapi-react-query-D9Z7lh0p.cjs","names":["exec","options: ReactQueryOptions","spec: OpenAPISpec","operations: OperationInfo[]","operation: any","schema: any","apiName: string","op: OperationInfo","paramParts: string[]","exports","str: string"],"sources":["../src/openapi-react-query.ts"],"sourcesContent":["#!/usr/bin/env -S npx tsx\n\nimport { exec } from 'node:child_process';\nimport { existsSync } from 'node:fs';\nimport { mkdir, readFile, writeFile } from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\nimport { promisify } from 'node:util';\n\nconst execAsync = promisify(exec);\n\ninterface ReactQueryOptions {\n input?: string;\n output?: string;\n name?: string;\n}\n\ninterface OpenAPISpec {\n openapi: string;\n info?: {\n title?: string;\n version?: string;\n };\n paths: Record<string, Record<string, any>>;\n}\n\nexport async function generateReactQueryCommand(\n options: ReactQueryOptions = {},\n): Promise<void> {\n const logger = console;\n\n try {\n // Read OpenAPI spec\n const inputPath = options.input || join(process.cwd(), 'openapi.json');\n\n if (!existsSync(inputPath)) {\n throw new Error(\n `OpenAPI spec not found at ${inputPath}. Run 'npx @geekmidas/cli openapi' first.`,\n );\n }\n\n const specContent = await readFile(inputPath, 'utf-8');\n const spec: OpenAPISpec = JSON.parse(specContent);\n\n // Generate TypeScript types from OpenAPI spec\n const outputDir = dirname(\n options.output || join(process.cwd(), 'src', 'api', 'hooks.ts'),\n );\n const typesPath = join(outputDir, 'openapi-types.d.ts');\n\n logger.log('Generating TypeScript types from OpenAPI spec...');\n\n try {\n // Use npx to run openapi-typescript\n await execAsync(\n `npx openapi-typescript \"${inputPath}\" -o \"${typesPath}\"`,\n { cwd: process.cwd() },\n );\n logger.log(`TypeScript types generated: ${typesPath}`);\n } catch (error) {\n logger.warn(\n 'Could not generate types with openapi-typescript. Install it for better type inference.',\n );\n logger.warn('Run: npm install -D openapi-typescript');\n\n // Generate basic types file\n await mkdir(dirname(typesPath), { recursive: true });\n await writeFile(\n typesPath,\n `// Auto-generated placeholder types\nexport interface paths {\n [path: string]: {\n [method: string]: {\n operationId?: string;\n parameters?: any;\n requestBody?: any;\n responses?: any;\n };\n };\n}\n`,\n );\n }\n\n // Extract operation info\n const operations = extractOperations(spec);\n\n // Generate TypeScript code\n const code = generateReactQueryCode(\n spec,\n operations,\n options.name || 'API',\n );\n\n // Write output\n const outputPath =\n options.output || join(process.cwd(), 'src', 'api', 'hooks.ts');\n await mkdir(dirname(outputPath), { recursive: true });\n await writeFile(outputPath, code);\n\n logger.log(`React Query hooks generated: ${outputPath}`);\n logger.log(`Generated ${operations.length} hooks`);\n } catch (error) {\n throw new Error(\n `React Query generation failed: ${(error as Error).message}`,\n );\n }\n}\n\ninterface OperationInfo {\n operationId: string;\n path: string;\n method: string;\n endpoint: string; // Full endpoint like 'GET /users/{id}'\n parameters?: Array<{ name: string; in: string; required?: boolean }>;\n requestBody?: boolean;\n responseType?: string;\n}\n\nfunction extractOperations(spec: OpenAPISpec): OperationInfo[] {\n const operations: OperationInfo[] = [];\n\n Object.entries(spec.paths).forEach(([path, methods]) => {\n Object.entries(methods).forEach(([method, operation]) => {\n if (operation.operationId) {\n operations.push({\n operationId: operation.operationId,\n path,\n method: method.toUpperCase(),\n endpoint: `${method.toUpperCase()} ${path}`,\n parameters: operation.parameters,\n requestBody: !!operation.requestBody,\n responseType: extractResponseType(operation),\n });\n }\n });\n });\n\n return operations;\n}\n\nfunction extractResponseType(operation: any): string {\n const responses = operation.responses;\n if (!responses) return 'unknown';\n\n const successResponse = responses['200'] || responses['201'];\n if (!successResponse?.content?.['application/json']?.schema) {\n return 'unknown';\n }\n\n // Basic type inference from schema\n const schema = successResponse.content['application/json'].schema;\n return schemaToTypeString(schema);\n}\n\nfunction schemaToTypeString(schema: any): string {\n if (!schema) return 'unknown';\n\n switch (schema.type) {\n case 'string':\n return 'string';\n case 'number':\n case 'integer':\n return 'number';\n case 'boolean':\n return 'boolean';\n case 'array':\n return `Array<${schemaToTypeString(schema.items)}>`;\n case 'object':\n if (schema.properties) {\n const props = Object.entries(schema.properties)\n .map(\n ([key, value]: [string, any]) =>\n `${key}: ${schemaToTypeString(value)}`,\n )\n .join('; ');\n return `{ ${props} }`;\n }\n return 'Record<string, unknown>';\n default:\n return 'unknown';\n }\n}\n\nfunction generateReactQueryCode(\n spec: OpenAPISpec,\n operations: OperationInfo[],\n apiName: string,\n): string {\n const imports = `import { createTypedQueryClient } from '@geekmidas/client';\nimport type { paths } from './openapi-types';\n\n// Create typed query client\nexport const ${apiName.toLowerCase()} = createTypedQueryClient<paths>({\n baseURL: process.env.NEXT_PUBLIC_API_URL || '/api',\n});\n\n// Export individual hooks for better DX\n`;\n\n const queryHooks = operations\n .filter((op) => op.method === 'GET')\n .map((op) => generateQueryHook(op, apiName))\n .join('\\n\\n');\n\n const mutationHooks = operations\n .filter((op) => op.method !== 'GET')\n .map((op) => generateMutationHook(op, apiName))\n .join('\\n\\n');\n\n const typeExports = generateTypeExports(operations);\n\n return `${imports}\n// Query Hooks\n${queryHooks}\n\n// Mutation Hooks\n${mutationHooks}\n\n// Type exports for convenience\n${typeExports}\n\n// Re-export the api for advanced usage\nexport { ${apiName.toLowerCase()} };\n`;\n}\n\nfunction generateQueryHook(op: OperationInfo, apiName: string): string {\n const hookName = `use${capitalize(op.operationId)}`;\n const endpoint = op.endpoint;\n const hasParams = op.parameters?.some((p) => p.in === 'path');\n const hasQuery = op.parameters?.some((p) => p.in === 'query');\n\n // Generate properly typed hook\n let params = '';\n let args = '';\n\n if (hasParams || hasQuery) {\n const paramParts: string[] = [];\n if (hasParams) {\n const pathParams =\n op.parameters?.filter((p) => p.in === 'path').map((p) => p.name) || [];\n paramParts.push(\n `params: { ${pathParams.map((p) => `${p}: string`).join('; ')} }`,\n );\n }\n if (hasQuery) {\n paramParts.push(`query?: Record<string, any>`);\n }\n params = `config: { ${paramParts.join('; ')} }, `;\n args = ', config';\n }\n\n return `export const ${hookName} = (\n ${params}options?: Parameters<typeof ${apiName.toLowerCase()}.useQuery>[2]\n) => {\n return ${apiName.toLowerCase()}.useQuery('${endpoint}' as any${args}, options);\n};`;\n}\n\nfunction generateMutationHook(op: OperationInfo, apiName: string): string {\n const hookName = `use${capitalize(op.operationId)}`;\n const endpoint = op.endpoint;\n\n return `export const ${hookName} = (\n options?: Parameters<typeof ${apiName.toLowerCase()}.useMutation>[1]\n) => {\n return ${apiName.toLowerCase()}.useMutation('${endpoint}' as any, options);\n};`;\n}\n\nfunction generateTypeExports(operations: OperationInfo[]): string {\n const exports = operations.map((op) => {\n const typeName = capitalize(op.operationId);\n const isQuery = op.method === 'GET';\n\n if (isQuery) {\n return `export type ${typeName}Response = Awaited<ReturnType<ReturnType<typeof use${typeName}>['data']>>;`;\n } else {\n return `export type ${typeName}Response = Awaited<ReturnType<ReturnType<typeof use${typeName}>['mutateAsync']>>;`;\n }\n });\n\n return exports.join('\\n');\n}\n\nfunction capitalize(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n"],"mappings":";;;;;;;;AAQA,MAAM,YAAY,yBAAUA,wBAAK;AAiBjC,eAAsB,0BACpBC,UAA6B,CAAE,GAChB;CACf,MAAM,SAAS;AAEf,KAAI;EAEF,MAAM,YAAY,QA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CAAC,gBAAgB,SAAS;;AAEzD;AAED,SAAS,oBAAoBH,YAAqC;CAChE,MAAMM,YAAU,WAAW,IAAI,CAAC,OAAO;EACrC,MAAM,WAAW,WAAW,GAAG,YAAY;EAC3C,MAAM,UAAU,GAAG,WAAW;AAE9B,MAAI,QACF,SAAQ,cAAc,SAAS,qDAAqD,SAAS;MAE7F,SAAQ,cAAc,SAAS,qDAAqD,SAAS;CAEhG,EAAC;AAEF,QAAO,UAAQ,KAAK,KAAK;AAC1B;AAED,SAAS,WAAWC,KAAqB;AACvC,QAAO,IAAI,OAAO,EAAE,CAAC,aAAa,GAAG,IAAI,MAAM,EAAE;AAClD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openapi-react-query-DbrWwQzb.mjs","names":["options: ReactQueryOptions","spec: OpenAPISpec","operations: OperationInfo[]","operation: any","schema: any","apiName: string","op: OperationInfo","paramParts: string[]","str: string"],"sources":["../src/openapi-react-query.ts"],"sourcesContent":["#!/usr/bin/env -S npx tsx\n\nimport { exec } from 'node:child_process';\nimport { existsSync } from 'node:fs';\nimport { mkdir, readFile, writeFile } from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\nimport { promisify } from 'node:util';\n\nconst execAsync = promisify(exec);\n\ninterface ReactQueryOptions {\n input?: string;\n output?: string;\n name?: string;\n}\n\ninterface OpenAPISpec {\n openapi: string;\n info?: {\n title?: string;\n version?: string;\n };\n paths: Record<string, Record<string, any>>;\n}\n\nexport async function generateReactQueryCommand(\n options: ReactQueryOptions = {},\n): Promise<void> {\n const logger = console;\n\n try {\n // Read OpenAPI spec\n const inputPath = options.input || join(process.cwd(), 'openapi.json');\n\n if (!existsSync(inputPath)) {\n throw new Error(\n `OpenAPI spec not found at ${inputPath}. Run 'npx @geekmidas/cli openapi' first.`,\n );\n }\n\n const specContent = await readFile(inputPath, 'utf-8');\n const spec: OpenAPISpec = JSON.parse(specContent);\n\n // Generate TypeScript types from OpenAPI spec\n const outputDir = dirname(\n options.output || join(process.cwd(), 'src', 'api', 'hooks.ts'),\n );\n const typesPath = join(outputDir, 'openapi-types.d.ts');\n\n logger.log('Generating TypeScript types from OpenAPI spec...');\n\n try {\n // Use npx to run openapi-typescript\n await execAsync(\n `npx openapi-typescript \"${inputPath}\" -o \"${typesPath}\"`,\n { cwd: process.cwd() },\n );\n logger.log(`TypeScript types generated: ${typesPath}`);\n } catch (error) {\n logger.warn(\n 'Could not generate types with openapi-typescript. Install it for better type inference.',\n );\n logger.warn('Run: npm install -D openapi-typescript');\n\n // Generate basic types file\n await mkdir(dirname(typesPath), { recursive: true });\n await writeFile(\n typesPath,\n `// Auto-generated placeholder types\nexport interface paths {\n [path: string]: {\n [method: string]: {\n operationId?: string;\n parameters?: any;\n requestBody?: any;\n responses?: any;\n };\n };\n}\n`,\n );\n }\n\n // Extract operation info\n const operations = extractOperations(spec);\n\n // Generate TypeScript code\n const code = generateReactQueryCode(\n spec,\n operations,\n options.name || 'API',\n );\n\n // Write output\n const outputPath =\n options.output || join(process.cwd(), 'src', 'api', 'hooks.ts');\n await mkdir(dirname(outputPath), { recursive: true });\n await writeFile(outputPath, code);\n\n logger.log(`React Query hooks generated: ${outputPath}`);\n logger.log(`Generated ${operations.length} hooks`);\n } catch (error) {\n throw new Error(\n `React Query generation failed: ${(error as Error).message}`,\n );\n }\n}\n\ninterface OperationInfo {\n operationId: string;\n path: string;\n method: string;\n endpoint: string; // Full endpoint like 'GET /users/{id}'\n parameters?: Array<{ name: string; in: string; required?: boolean }>;\n requestBody?: boolean;\n responseType?: string;\n}\n\nfunction extractOperations(spec: OpenAPISpec): OperationInfo[] {\n const operations: OperationInfo[] = [];\n\n Object.entries(spec.paths).forEach(([path, methods]) => {\n Object.entries(methods).forEach(([method, operation]) => {\n if (operation.operationId) {\n operations.push({\n operationId: operation.operationId,\n path,\n method: method.toUpperCase(),\n endpoint: `${method.toUpperCase()} ${path}`,\n parameters: operation.parameters,\n requestBody: !!operation.requestBody,\n responseType: extractResponseType(operation),\n });\n }\n });\n });\n\n return operations;\n}\n\nfunction extractResponseType(operation: any): string {\n const responses = operation.responses;\n if (!responses) return 'unknown';\n\n const successResponse = responses['200'] || responses['201'];\n if (!successResponse?.content?.['application/json']?.schema) {\n return 'unknown';\n }\n\n // Basic type inference from schema\n const schema = successResponse.content['application/json'].schema;\n return schemaToTypeString(schema);\n}\n\nfunction schemaToTypeString(schema: any): string {\n if (!schema) return 'unknown';\n\n switch (schema.type) {\n case 'string':\n return 'string';\n case 'number':\n case 'integer':\n return 'number';\n case 'boolean':\n return 'boolean';\n case 'array':\n return `Array<${schemaToTypeString(schema.items)}>`;\n case 'object':\n if (schema.properties) {\n const props = Object.entries(schema.properties)\n .map(\n ([key, value]: [string, any]) =>\n `${key}: ${schemaToTypeString(value)}`,\n )\n .join('; ');\n return `{ ${props} }`;\n }\n return 'Record<string, unknown>';\n default:\n return 'unknown';\n }\n}\n\nfunction generateReactQueryCode(\n spec: OpenAPISpec,\n operations: OperationInfo[],\n apiName: string,\n): string {\n const imports = `import { createTypedQueryClient } from '@geekmidas/client';\nimport type { paths } from './openapi-types';\n\n// Create typed query client\nexport const ${apiName.toLowerCase()} = createTypedQueryClient<paths>({\n baseURL: process.env.NEXT_PUBLIC_API_URL || '/api',\n});\n\n// Export individual hooks for better DX\n`;\n\n const queryHooks = operations\n .filter((op) => op.method === 'GET')\n .map((op) => generateQueryHook(op, apiName))\n .join('\\n\\n');\n\n const mutationHooks = operations\n .filter((op) => op.method !== 'GET')\n .map((op) => generateMutationHook(op, apiName))\n .join('\\n\\n');\n\n const typeExports = generateTypeExports(operations);\n\n return `${imports}\n// Query Hooks\n${queryHooks}\n\n// Mutation Hooks\n${mutationHooks}\n\n// Type exports for convenience\n${typeExports}\n\n// Re-export the api for advanced usage\nexport { ${apiName.toLowerCase()} };\n`;\n}\n\nfunction generateQueryHook(op: OperationInfo, apiName: string): string {\n const hookName = `use${capitalize(op.operationId)}`;\n const endpoint = op.endpoint;\n const hasParams = op.parameters?.some((p) => p.in === 'path');\n const hasQuery = op.parameters?.some((p) => p.in === 'query');\n\n // Generate properly typed hook\n let params = '';\n let args = '';\n\n if (hasParams || hasQuery) {\n const paramParts: string[] = [];\n if (hasParams) {\n const pathParams =\n op.parameters?.filter((p) => p.in === 'path').map((p) => p.name) || [];\n paramParts.push(\n `params: { ${pathParams.map((p) => `${p}: string`).join('; ')} }`,\n );\n }\n if (hasQuery) {\n paramParts.push(`query?: Record<string, any>`);\n }\n params = `config: { ${paramParts.join('; ')} }, `;\n args = ', config';\n }\n\n return `export const ${hookName} = (\n ${params}options?: Parameters<typeof ${apiName.toLowerCase()}.useQuery>[2]\n) => {\n return ${apiName.toLowerCase()}.useQuery('${endpoint}' as any${args}, options);\n};`;\n}\n\nfunction generateMutationHook(op: OperationInfo, apiName: string): string {\n const hookName = `use${capitalize(op.operationId)}`;\n const endpoint = op.endpoint;\n\n return `export const ${hookName} = (\n options?: Parameters<typeof ${apiName.toLowerCase()}.useMutation>[1]\n) => {\n return ${apiName.toLowerCase()}.useMutation('${endpoint}' as any, options);\n};`;\n}\n\nfunction generateTypeExports(operations: OperationInfo[]): string {\n const exports = operations.map((op) => {\n const typeName = capitalize(op.operationId);\n const isQuery = op.method === 'GET';\n\n if (isQuery) {\n return `export type ${typeName}Response = Awaited<ReturnType<ReturnType<typeof use${typeName}>['data']>>;`;\n } else {\n return `export type ${typeName}Response = Awaited<ReturnType<ReturnType<typeof use${typeName}>['mutateAsync']>>;`;\n }\n });\n\n return exports.join('\\n');\n}\n\nfunction capitalize(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n"],"mappings":";;;;;;;AAQA,MAAM,YAAY,UAAU,KAAK;AAiBjC,eAAsB,0BACpBA,UAA6B,CAAE,GAChB;CACf,MAAM,SAAS;AAEf,KAAI;EAEF,MAAM,YAAY,QAAQ,SAAS,KAAK,QAAQ,KAAK,EAAE,eAAe;AAEtE,OAAK,WAAW,UAAU,CACxB,OAAM,IAAI,OACP,4BAA4B,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W,WAAW,GAAG,YAAY;EAC3C,MAAM,UAAU,GAAG,WAAW;AAE9B,MAAI,QACF,SAAQ,cAAc,SAAS,qDAAqD,SAAS;MAE7F,SAAQ,cAAc,SAAS,qDAAqD,SAAS;CAEhG,EAAC;AAEF,QAAO,QAAQ,KAAK,KAAK;AAC1B;AAED,SAAS,WAAWM,KAAqB;AACvC,QAAO,IAAI,OAAO,EAAE,CAAC,aAAa,GAAG,IAAI,MAAM,EAAE;AAClD"}
|
|
1
|
+
{"version":3,"file":"openapi-react-query-MEBlYIM1.mjs","names":["options: ReactQueryOptions","spec: OpenAPISpec","operations: OperationInfo[]","operation: any","schema: any","apiName: string","op: OperationInfo","paramParts: string[]","str: string"],"sources":["../src/openapi-react-query.ts"],"sourcesContent":["#!/usr/bin/env -S npx tsx\n\nimport { exec } from 'node:child_process';\nimport { existsSync } from 'node:fs';\nimport { mkdir, readFile, writeFile } from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\nimport { promisify } from 'node:util';\n\nconst execAsync = promisify(exec);\n\ninterface ReactQueryOptions {\n input?: string;\n output?: string;\n name?: string;\n}\n\ninterface OpenAPISpec {\n openapi: string;\n info?: {\n title?: string;\n version?: string;\n };\n paths: Record<string, Record<string, any>>;\n}\n\nexport async function generateReactQueryCommand(\n options: ReactQueryOptions = {},\n): Promise<void> {\n const logger = console;\n\n try {\n // Read OpenAPI spec\n const inputPath = options.input || join(process.cwd(), 'openapi.json');\n\n if (!existsSync(inputPath)) {\n throw new Error(\n `OpenAPI spec not found at ${inputPath}. Run 'npx @geekmidas/cli openapi' first.`,\n );\n }\n\n const specContent = await readFile(inputPath, 'utf-8');\n const spec: OpenAPISpec = JSON.parse(specContent);\n\n // Generate TypeScript types from OpenAPI spec\n const outputDir = dirname(\n options.output || join(process.cwd(), 'src', 'api', 'hooks.ts'),\n );\n const typesPath = join(outputDir, 'openapi-types.d.ts');\n\n logger.log('Generating TypeScript types from OpenAPI spec...');\n\n try {\n // Use npx to run openapi-typescript\n await execAsync(\n `npx openapi-typescript \"${inputPath}\" -o \"${typesPath}\"`,\n { cwd: process.cwd() },\n );\n logger.log(`TypeScript types generated: ${typesPath}`);\n } catch (error) {\n logger.warn(\n 'Could not generate types with openapi-typescript. Install it for better type inference.',\n );\n logger.warn('Run: npm install -D openapi-typescript');\n\n // Generate basic types file\n await mkdir(dirname(typesPath), { recursive: true });\n await writeFile(\n typesPath,\n `// Auto-generated placeholder types\nexport interface paths {\n [path: string]: {\n [method: string]: {\n operationId?: string;\n parameters?: any;\n requestBody?: any;\n responses?: any;\n };\n };\n}\n`,\n );\n }\n\n // Extract operation info\n const operations = extractOperations(spec);\n\n // Generate TypeScript code\n const code = generateReactQueryCode(\n spec,\n operations,\n options.name || 'API',\n );\n\n // Write output\n const outputPath =\n options.output || join(process.cwd(), 'src', 'api', 'hooks.ts');\n await mkdir(dirname(outputPath), { recursive: true });\n await writeFile(outputPath, code);\n\n logger.log(`React Query hooks generated: ${outputPath}`);\n logger.log(`Generated ${operations.length} hooks`);\n } catch (error) {\n throw new Error(\n `React Query generation failed: ${(error as Error).message}`,\n );\n }\n}\n\ninterface OperationInfo {\n operationId: string;\n path: string;\n method: string;\n endpoint: string; // Full endpoint like 'GET /users/{id}'\n parameters?: Array<{ name: string; in: string; required?: boolean }>;\n requestBody?: boolean;\n responseType?: string;\n}\n\nfunction extractOperations(spec: OpenAPISpec): OperationInfo[] {\n const operations: OperationInfo[] = [];\n\n Object.entries(spec.paths).forEach(([path, methods]) => {\n Object.entries(methods).forEach(([method, operation]) => {\n if (operation.operationId) {\n operations.push({\n operationId: operation.operationId,\n path,\n method: method.toUpperCase(),\n endpoint: `${method.toUpperCase()} ${path}`,\n parameters: operation.parameters,\n requestBody: !!operation.requestBody,\n responseType: extractResponseType(operation),\n });\n }\n });\n });\n\n return operations;\n}\n\nfunction extractResponseType(operation: any): string {\n const responses = operation.responses;\n if (!responses) return 'unknown';\n\n const successResponse = responses['200'] || responses['201'];\n if (!successResponse?.content?.['application/json']?.schema) {\n return 'unknown';\n }\n\n // Basic type inference from schema\n const schema = successResponse.content['application/json'].schema;\n return schemaToTypeString(schema);\n}\n\nfunction schemaToTypeString(schema: any): string {\n if (!schema) return 'unknown';\n\n switch (schema.type) {\n case 'string':\n return 'string';\n case 'number':\n case 'integer':\n return 'number';\n case 'boolean':\n return 'boolean';\n case 'array':\n return `Array<${schemaToTypeString(schema.items)}>`;\n case 'object':\n if (schema.properties) {\n const props = Object.entries(schema.properties)\n .map(\n ([key, value]: [string, any]) =>\n `${key}: ${schemaToTypeString(value)}`,\n )\n .join('; ');\n return `{ ${props} }`;\n }\n return 'Record<string, unknown>';\n default:\n return 'unknown';\n }\n}\n\nfunction generateReactQueryCode(\n spec: OpenAPISpec,\n operations: OperationInfo[],\n apiName: string,\n): string {\n const imports = `import { createTypedQueryClient } from '@geekmidas/client';\nimport type { paths } from './openapi-types';\n\n// Create typed query client\nexport const ${apiName.toLowerCase()} = createTypedQueryClient<paths>({\n baseURL: process.env.NEXT_PUBLIC_API_URL || '/api',\n});\n\n// Export individual hooks for better DX\n`;\n\n const queryHooks = operations\n .filter((op) => op.method === 'GET')\n .map((op) => generateQueryHook(op, apiName))\n .join('\\n\\n');\n\n const mutationHooks = operations\n .filter((op) => op.method !== 'GET')\n .map((op) => generateMutationHook(op, apiName))\n .join('\\n\\n');\n\n const typeExports = generateTypeExports(operations);\n\n return `${imports}\n// Query Hooks\n${queryHooks}\n\n// Mutation Hooks\n${mutationHooks}\n\n// Type exports for convenience\n${typeExports}\n\n// Re-export the api for advanced usage\nexport { ${apiName.toLowerCase()} };\n`;\n}\n\nfunction generateQueryHook(op: OperationInfo, apiName: string): string {\n const hookName = `use${capitalize(op.operationId)}`;\n const endpoint = op.endpoint;\n const hasParams = op.parameters?.some((p) => p.in === 'path');\n const hasQuery = op.parameters?.some((p) => p.in === 'query');\n\n // Generate properly typed hook\n let params = '';\n let args = '';\n\n if (hasParams || hasQuery) {\n const paramParts: string[] = [];\n if (hasParams) {\n const pathParams =\n op.parameters?.filter((p) => p.in === 'path').map((p) => p.name) || [];\n paramParts.push(\n `params: { ${pathParams.map((p) => `${p}: string`).join('; ')} }`,\n );\n }\n if (hasQuery) {\n paramParts.push(`query?: Record<string, any>`);\n }\n params = `config: { ${paramParts.join('; ')} }, `;\n args = ', config';\n }\n\n return `export const ${hookName} = (\n ${params}options?: Parameters<typeof ${apiName.toLowerCase()}.useQuery>[2]\n) => {\n return ${apiName.toLowerCase()}.useQuery('${endpoint}' as any${args}, options);\n};`;\n}\n\nfunction generateMutationHook(op: OperationInfo, apiName: string): string {\n const hookName = `use${capitalize(op.operationId)}`;\n const endpoint = op.endpoint;\n\n return `export const ${hookName} = (\n options?: Parameters<typeof ${apiName.toLowerCase()}.useMutation>[1]\n) => {\n return ${apiName.toLowerCase()}.useMutation('${endpoint}' as any, options);\n};`;\n}\n\nfunction generateTypeExports(operations: OperationInfo[]): string {\n const exports = operations.map((op) => {\n const typeName = capitalize(op.operationId);\n const isQuery = op.method === 'GET';\n\n if (isQuery) {\n return `export type ${typeName}Response = Awaited<ReturnType<ReturnType<typeof use${typeName}>['data']>>;`;\n } else {\n return `export type ${typeName}Response = Awaited<ReturnType<ReturnType<typeof use${typeName}>['mutateAsync']>>;`;\n }\n });\n\n return exports.join('\\n');\n}\n\nfunction capitalize(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n"],"mappings":";;;;;;;AAQA,MAAM,YAAY,UAAU,KAAK;AAiBjC,eAAsB,0BACpBA,UAA6B,CAAE,GAChB;CACf,MAAM,SAAS;AAEf,KAAI;EAEF,MAAM,YAAY,QAAQ,SAAS,KAAK,QAAQ,KAAK,EAAE,eAAe;AAEtE,OAAK,WAAW,UAAU,CACxB,OAAM,IAAI,OACP,4BAA4B,UAAU;EAI3C,MAAM,cAAc,MAAM,SAAS,WAAW,QAAQ;EACtD,MAAMC,OAAoB,KAAK,MAAM,YAAY;EAGjD,MAAM,YAAY,QAChB,QAAQ,UAAU,KAAK,QAA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,SAAS;CAEhG,EAAC;AAEF,QAAO,QAAQ,KAAK,KAAK;AAC1B;AAED,SAAS,WAAWM,KAAqB;AACvC,QAAO,IAAI,OAAO,EAAE,CAAC,aAAa,GAAG,IAAI,MAAM,EAAE;AAClD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env -S npx tsx
|
|
2
|
-
const require_openapi_react_query = require('./openapi-react-query-
|
|
2
|
+
const require_openapi_react_query = require('./openapi-react-query-D9Z7lh0p.cjs');
|
|
3
3
|
|
|
4
4
|
exports.generateReactQueryCommand = require_openapi_react_query.generateReactQueryCommand;
|
package/dist/openapi.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env -S npx tsx
|
|
2
2
|
require('./config-D1EpSGk6.cjs');
|
|
3
3
|
require('./Generator-CDoEXCDg.cjs');
|
|
4
|
-
require('./EndpointGenerator-
|
|
5
|
-
const require_openapi = require('./openapi-
|
|
4
|
+
require('./EndpointGenerator-C73wNoih.cjs');
|
|
5
|
+
const require_openapi = require('./openapi-CewcfoRH.cjs');
|
|
6
6
|
|
|
7
7
|
exports.openapiCommand = require_openapi.openapiCommand;
|
package/dist/openapi.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env -S npx tsx
|
|
2
2
|
import "./config-U-mdW-7Y.mjs";
|
|
3
3
|
import "./Generator-UanJW0_V.mjs";
|
|
4
|
-
import "./EndpointGenerator-
|
|
5
|
-
import { openapiCommand } from "./openapi-
|
|
4
|
+
import "./EndpointGenerator-CWh18d92.mjs";
|
|
5
|
+
import { openapiCommand } from "./openapi-BTHbPrxS.mjs";
|
|
6
6
|
|
|
7
7
|
export { openapiCommand };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geekmidas/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -23,8 +23,13 @@
|
|
|
23
23
|
"bin": {
|
|
24
24
|
"gkm": "./dist/index.cjs"
|
|
25
25
|
},
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "https://github.com/geekmidas/toolbox"
|
|
29
|
+
},
|
|
26
30
|
"dependencies": {
|
|
27
31
|
"@apidevtools/swagger-parser": "^10.1.0",
|
|
32
|
+
"chokidar": "~4.0.3",
|
|
28
33
|
"commander": "^12.1.0",
|
|
29
34
|
"fast-glob": "^3.3.2",
|
|
30
35
|
"lodash.kebabcase": "^4.1.1",
|
|
@@ -32,16 +37,17 @@
|
|
|
32
37
|
},
|
|
33
38
|
"devDependencies": {
|
|
34
39
|
"@types/lodash.kebabcase": "^4.1.9",
|
|
40
|
+
"@types/node": "~24.9.1",
|
|
35
41
|
"typescript": "^5.8.2",
|
|
36
42
|
"vitest": "^3.2.4",
|
|
37
|
-
"zod": "
|
|
38
|
-
"@geekmidas/testkit": "0.0.
|
|
43
|
+
"zod": "~4.1.13",
|
|
44
|
+
"@geekmidas/testkit": "0.0.17"
|
|
39
45
|
},
|
|
40
46
|
"peerDependencies": {
|
|
47
|
+
"@geekmidas/constructs": "~0.0.21",
|
|
48
|
+
"@geekmidas/envkit": "~0.0.8",
|
|
41
49
|
"@geekmidas/logger": "~0.0.1",
|
|
42
|
-
"@geekmidas/schema": "~0.0.2"
|
|
43
|
-
"@geekmidas/envkit": "~0.0.7",
|
|
44
|
-
"@geekmidas/constructs": "~0.0.6"
|
|
50
|
+
"@geekmidas/schema": "~0.0.2"
|
|
45
51
|
},
|
|
46
52
|
"scripts": {
|
|
47
53
|
"ts": "tsc --noEmit --skipLibCheck src/**/*.ts",
|