@geekmidas/cli 1.9.1 → 1.10.1
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/CHANGELOG.md +24 -0
- package/README.md +42 -6
- package/dist/{config-6JHOwLCx.cjs → config-D3ORuiUs.cjs} +2 -2
- package/dist/{config-6JHOwLCx.cjs.map → config-D3ORuiUs.cjs.map} +1 -1
- package/dist/{config-DxASSNjr.mjs → config-jsRYHOHU.mjs} +2 -2
- package/dist/{config-DxASSNjr.mjs.map → config-jsRYHOHU.mjs.map} +1 -1
- package/dist/config.cjs +2 -2
- package/dist/config.d.cts +2 -2
- package/dist/config.d.mts +2 -2
- package/dist/config.mjs +2 -2
- package/dist/{index-Bt2kX0-R.d.mts → index-3n-giNaw.d.mts} +18 -6
- package/dist/index-3n-giNaw.d.mts.map +1 -0
- package/dist/{index-Cyk2rTyj.d.cts → index-CiEOtKEX.d.cts} +18 -6
- package/dist/index-CiEOtKEX.d.cts.map +1 -0
- package/dist/index.cjs +189 -165
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +186 -162
- package/dist/index.mjs.map +1 -1
- package/dist/{openapi-CnvwSRDU.cjs → openapi-BYxAWwok.cjs} +178 -32
- package/dist/openapi-BYxAWwok.cjs.map +1 -0
- package/dist/{openapi-BYlyAbH3.mjs → openapi-DenF-okj.mjs} +148 -32
- package/dist/openapi-DenF-okj.mjs.map +1 -0
- package/dist/openapi.cjs +3 -3
- package/dist/openapi.d.cts +1 -1
- package/dist/openapi.d.cts.map +1 -1
- package/dist/openapi.d.mts +1 -1
- package/dist/openapi.d.mts.map +1 -1
- package/dist/openapi.mjs +3 -3
- package/dist/{types-l53qUmGt.d.cts → types-C7QJJl9f.d.cts} +6 -2
- package/dist/types-C7QJJl9f.d.cts.map +1 -0
- package/dist/{types-wXMIMOyK.d.mts → types-Iqsq_FIG.d.mts} +6 -2
- package/dist/types-Iqsq_FIG.d.mts.map +1 -0
- package/dist/workspace/index.cjs +1 -1
- package/dist/workspace/index.d.cts +2 -2
- package/dist/workspace/index.d.mts +2 -2
- package/dist/workspace/index.mjs +1 -1
- package/dist/{workspace-D2ocAlpl.cjs → workspace-4SP3Gx4Y.cjs} +11 -3
- package/dist/{workspace-D2ocAlpl.cjs.map → workspace-4SP3Gx4Y.cjs.map} +1 -1
- package/dist/{workspace-9IQIjwkQ.mjs → workspace-D4z4A4cq.mjs} +11 -3
- package/dist/{workspace-9IQIjwkQ.mjs.map → workspace-D4z4A4cq.mjs.map} +1 -1
- package/package.json +4 -4
- package/src/build/__tests__/manifests.spec.ts +171 -0
- package/src/build/__tests__/partitions.spec.ts +110 -0
- package/src/build/index.ts +58 -15
- package/src/build/manifests.ts +153 -32
- package/src/build/partitions.ts +58 -0
- package/src/deploy/sniffer.ts +6 -1
- package/src/generators/Generator.ts +27 -7
- package/src/generators/OpenApiTsGenerator.ts +4 -4
- package/src/init/versions.ts +7 -7
- package/src/openapi.ts +2 -1
- package/src/types.ts +17 -1
- package/src/workspace/client-generator.ts +6 -3
- package/src/workspace/schema.ts +13 -3
- package/dist/index-Bt2kX0-R.d.mts.map +0 -1
- package/dist/index-Cyk2rTyj.d.cts.map +0 -1
- package/dist/openapi-BYlyAbH3.mjs.map +0 -1
- package/dist/openapi-CnvwSRDU.cjs.map +0 -1
- package/dist/types-l53qUmGt.d.cts.map +0 -1
- package/dist/types-wXMIMOyK.d.mts.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
-
const require_config = require('./config-
|
|
2
|
+
const require_config = require('./config-D3ORuiUs.cjs');
|
|
3
|
+
const node_fs = require_chunk.__toESM(require("node:fs"));
|
|
3
4
|
const node_path = require_chunk.__toESM(require("node:path"));
|
|
4
5
|
const node_fs_promises = require_chunk.__toESM(require("node:fs/promises"));
|
|
5
6
|
const fast_glob = require_chunk.__toESM(require("fast-glob"));
|
|
@@ -7,6 +8,12 @@ const lodash_kebabcase = require_chunk.__toESM(require("lodash.kebabcase"));
|
|
|
7
8
|
const __geekmidas_constructs_endpoints = require_chunk.__toESM(require("@geekmidas/constructs/endpoints"));
|
|
8
9
|
const __geekmidas_schema_conversion = require_chunk.__toESM(require("@geekmidas/schema/conversion"));
|
|
9
10
|
|
|
11
|
+
//#region src/types.ts
|
|
12
|
+
function isPartitionedRoutes(routes) {
|
|
13
|
+
return typeof routes === "object" && routes !== null && !Array.isArray(routes) && "paths" in routes;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
10
17
|
//#region src/generators/Generator.ts
|
|
11
18
|
var ConstructGenerator = class {
|
|
12
19
|
static async build(context, outputDir, generator, patterns, options) {
|
|
@@ -14,8 +21,13 @@ var ConstructGenerator = class {
|
|
|
14
21
|
return generator.build(context, constructs, outputDir, options);
|
|
15
22
|
}
|
|
16
23
|
async load(patterns, cwd = process.cwd(), bustCache = false) {
|
|
17
|
-
const logger = console;
|
|
18
|
-
|
|
24
|
+
const logger$1 = console;
|
|
25
|
+
let globPatterns;
|
|
26
|
+
let partitionFn;
|
|
27
|
+
if (isPartitionedRoutes(patterns)) {
|
|
28
|
+
globPatterns = Array.isArray(patterns.paths) ? patterns.paths : [patterns.paths];
|
|
29
|
+
partitionFn = patterns.partition;
|
|
30
|
+
} else globPatterns = Array.isArray(patterns) ? patterns : patterns ? [patterns] : [];
|
|
19
31
|
const files = fast_glob.default.stream(globPatterns, {
|
|
20
32
|
cwd,
|
|
21
33
|
absolute: true
|
|
@@ -25,6 +37,7 @@ var ConstructGenerator = class {
|
|
|
25
37
|
const file = f.toString();
|
|
26
38
|
const importPath = bustCache ? `${file}?t=${Date.now()}` : file;
|
|
27
39
|
const module$1 = await import(importPath);
|
|
40
|
+
const partition = partitionFn ? partitionFn(file) : void 0;
|
|
28
41
|
for (const [key, construct] of Object.entries(module$1)) if (this.isConstruct(construct)) constructs.push({
|
|
29
42
|
key,
|
|
30
43
|
name: (0, lodash_kebabcase.default)(key),
|
|
@@ -32,10 +45,11 @@ var ConstructGenerator = class {
|
|
|
32
45
|
path: {
|
|
33
46
|
absolute: file,
|
|
34
47
|
relative: (0, node_path.relative)(process.cwd(), file)
|
|
35
|
-
}
|
|
48
|
+
},
|
|
49
|
+
partition
|
|
36
50
|
});
|
|
37
51
|
} catch (error) {
|
|
38
|
-
logger.warn(`Failed to load ${f}:`, error.message);
|
|
52
|
+
logger$1.warn(`Failed to load ${f}:`, error.message);
|
|
39
53
|
throw new Error("Failed to load constructs. Please check the logs for details.");
|
|
40
54
|
}
|
|
41
55
|
return constructs;
|
|
@@ -631,7 +645,7 @@ var EndpointGenerator = class extends ConstructGenerator {
|
|
|
631
645
|
async build(context, constructs, outputDir, options) {
|
|
632
646
|
const provider = options?.provider || "aws-apigatewayv2";
|
|
633
647
|
const enableOpenApi = options?.enableOpenApi || false;
|
|
634
|
-
const logger = console;
|
|
648
|
+
const logger$1 = console;
|
|
635
649
|
const routes = [];
|
|
636
650
|
if (constructs.length === 0) return routes;
|
|
637
651
|
if (provider === "server") {
|
|
@@ -643,7 +657,7 @@ var EndpointGenerator = class extends ConstructGenerator {
|
|
|
643
657
|
handler: (0, node_path.relative)(process.cwd(), appFile),
|
|
644
658
|
authorizer: "none"
|
|
645
659
|
});
|
|
646
|
-
logger.log(`Generated server with ${constructs.length} endpoints${enableOpenApi ? " (OpenAPI enabled)" : ""}`);
|
|
660
|
+
logger$1.log(`Generated server with ${constructs.length} endpoints${enableOpenApi ? " (OpenAPI enabled)" : ""}`);
|
|
647
661
|
} else if (provider === "aws-lambda") {
|
|
648
662
|
const routesDir = (0, node_path.join)(outputDir, "routes");
|
|
649
663
|
await (0, node_fs_promises.mkdir)(routesDir, { recursive: true });
|
|
@@ -659,7 +673,7 @@ var EndpointGenerator = class extends ConstructGenerator {
|
|
|
659
673
|
authorizer: construct.authorizer?.name ?? "none"
|
|
660
674
|
};
|
|
661
675
|
routes.push(routeInfo);
|
|
662
|
-
logger.log(`Generated handler for ${routeInfo.method} ${routeInfo.path}`);
|
|
676
|
+
logger$1.log(`Generated handler for ${routeInfo.method} ${routeInfo.path}`);
|
|
663
677
|
}
|
|
664
678
|
} else for (const { key, construct, path } of constructs) {
|
|
665
679
|
const handlerFile = await this.generateHandlerFile(outputDir, path.relative, key, provider, construct, context);
|
|
@@ -673,7 +687,7 @@ var EndpointGenerator = class extends ConstructGenerator {
|
|
|
673
687
|
authorizer: construct.authorizer?.name ?? "none"
|
|
674
688
|
};
|
|
675
689
|
routes.push(routeInfo);
|
|
676
|
-
logger.log(`Generated handler for ${routeInfo.method} ${routeInfo.path}`);
|
|
690
|
+
logger$1.log(`Generated handler for ${routeInfo.method} ${routeInfo.path}`);
|
|
677
691
|
}
|
|
678
692
|
return routes;
|
|
679
693
|
}
|
|
@@ -762,7 +776,7 @@ export async function setupEndpoints(
|
|
|
762
776
|
* Generate optimized endpoints files with nested folder structure (per-endpoint files)
|
|
763
777
|
*/
|
|
764
778
|
async generateOptimizedEndpointsFile(endpointsPath, endpoints, _endpointImports, _allExportNames) {
|
|
765
|
-
const logger = console;
|
|
779
|
+
const logger$1 = console;
|
|
766
780
|
const outputDir = (0, node_path.dirname)(endpointsPath);
|
|
767
781
|
const endpointsDir = (0, node_path.join)(outputDir, "endpoints");
|
|
768
782
|
await (0, node_fs_promises.mkdir)((0, node_path.join)(endpointsDir, "minimal"), { recursive: true });
|
|
@@ -779,11 +793,11 @@ export async function setupEndpoints(
|
|
|
779
793
|
};
|
|
780
794
|
});
|
|
781
795
|
const summary = summarizeAnalysis(analyses);
|
|
782
|
-
logger.log(`\n📊 Endpoint Analysis:`);
|
|
783
|
-
logger.log(` Total: ${summary.total} endpoints`);
|
|
784
|
-
logger.log(` - Minimal (near-raw-Hono): ${summary.byTier.minimal} endpoints`);
|
|
785
|
-
logger.log(` - Standard (auth/services): ${summary.byTier.standard} endpoints`);
|
|
786
|
-
logger.log(` - Full (audits/rls/rate-limit): ${summary.byTier.full} endpoints`);
|
|
796
|
+
logger$1.log(`\n📊 Endpoint Analysis:`);
|
|
797
|
+
logger$1.log(` Total: ${summary.total} endpoints`);
|
|
798
|
+
logger$1.log(` - Minimal (near-raw-Hono): ${summary.byTier.minimal} endpoints`);
|
|
799
|
+
logger$1.log(` - Standard (auth/services): ${summary.byTier.standard} endpoints`);
|
|
800
|
+
logger$1.log(` - Full (audits/rls/rate-limit): ${summary.byTier.full} endpoints`);
|
|
787
801
|
const files = generateEndpointFilesNested(analyses, endpointImports);
|
|
788
802
|
for (const [filename, content] of Object.entries(files)) {
|
|
789
803
|
const filePath = (0, node_path.join)(endpointsDir, filename);
|
|
@@ -792,7 +806,7 @@ export async function setupEndpoints(
|
|
|
792
806
|
}
|
|
793
807
|
const endpointFiles = Object.keys(files).filter((f) => !f.endsWith("index.ts") && !f.endsWith("validators.ts")).length;
|
|
794
808
|
const indexFiles = Object.keys(files).filter((f) => f.endsWith("index.ts")).length;
|
|
795
|
-
logger.log(` Generated ${endpointFiles} endpoint files + ${indexFiles} index files + validators.ts`);
|
|
809
|
+
logger$1.log(` Generated ${endpointFiles} endpoint files + ${indexFiles} index files + validators.ts`);
|
|
796
810
|
return (0, node_path.join)(endpointsDir, "index.ts");
|
|
797
811
|
}
|
|
798
812
|
async generateAppFile(outputDir, context) {
|
|
@@ -1557,7 +1571,7 @@ export function createApi(options: CreateApiOptions) {
|
|
|
1557
1571
|
// API Client Factory
|
|
1558
1572
|
// ============================================================
|
|
1559
1573
|
|
|
1560
|
-
import {
|
|
1574
|
+
import { createTypedFetcher, type FetcherOptions } from '@geekmidas/client/fetcher';
|
|
1561
1575
|
import { createEndpointHooks } from '@geekmidas/client/endpoint-hooks';
|
|
1562
1576
|
import type { QueryClient } from '@tanstack/react-query';
|
|
1563
1577
|
|
|
@@ -1589,11 +1603,11 @@ export interface CreateApiOptions extends Omit<FetcherOptions, 'baseURL'> {
|
|
|
1589
1603
|
*/
|
|
1590
1604
|
export function createApi(options: CreateApiOptions) {
|
|
1591
1605
|
const { queryClient, ...fetcherOptions } = options;
|
|
1592
|
-
const
|
|
1606
|
+
const request = createTypedFetcher<paths>(fetcherOptions);
|
|
1593
1607
|
|
|
1594
|
-
const hooks = createEndpointHooks<paths>(
|
|
1608
|
+
const hooks = createEndpointHooks<paths>(request, { queryClient });
|
|
1595
1609
|
|
|
1596
|
-
return Object.assign(
|
|
1610
|
+
return Object.assign(request, hooks);
|
|
1597
1611
|
}
|
|
1598
1612
|
`;
|
|
1599
1613
|
return `// Auto-generated by @geekmidas/cli - DO NOT EDIT
|
|
@@ -1671,6 +1685,108 @@ ${createApiSection}
|
|
|
1671
1685
|
}
|
|
1672
1686
|
};
|
|
1673
1687
|
|
|
1688
|
+
//#endregion
|
|
1689
|
+
//#region src/workspace/client-generator.ts
|
|
1690
|
+
const logger = console;
|
|
1691
|
+
/**
|
|
1692
|
+
* Normalize routes to an array of patterns.
|
|
1693
|
+
* Handles string, string[], and PartitionedRoutes (extracts paths).
|
|
1694
|
+
* @internal Exported for use in dev command
|
|
1695
|
+
*/
|
|
1696
|
+
function normalizeRoutes(routes) {
|
|
1697
|
+
if (!routes) return [];
|
|
1698
|
+
if (isPartitionedRoutes(routes)) return Array.isArray(routes.paths) ? routes.paths : [routes.paths];
|
|
1699
|
+
return Array.isArray(routes) ? routes : [routes];
|
|
1700
|
+
}
|
|
1701
|
+
/**
|
|
1702
|
+
* Get frontend apps that depend on a backend app.
|
|
1703
|
+
*/
|
|
1704
|
+
function getDependentFrontends(workspace, backendAppName) {
|
|
1705
|
+
const dependentApps = [];
|
|
1706
|
+
for (const [appName, app] of Object.entries(workspace.apps)) if (app.type === "frontend" && app.dependencies.includes(backendAppName)) dependentApps.push(appName);
|
|
1707
|
+
return dependentApps;
|
|
1708
|
+
}
|
|
1709
|
+
/**
|
|
1710
|
+
* Get the path to a backend's OpenAPI spec file.
|
|
1711
|
+
*/
|
|
1712
|
+
function getBackendOpenApiPath(workspace, backendAppName) {
|
|
1713
|
+
const app = workspace.apps[backendAppName];
|
|
1714
|
+
if (!app || app.type !== "backend") return null;
|
|
1715
|
+
return (0, node_path.join)(workspace.root, app.path, ".gkm", "openapi.ts");
|
|
1716
|
+
}
|
|
1717
|
+
/**
|
|
1718
|
+
* Count endpoints in an OpenAPI spec content.
|
|
1719
|
+
*/
|
|
1720
|
+
function countEndpoints(content) {
|
|
1721
|
+
const endpointMatches = content.match(/'(GET|POST|PUT|PATCH|DELETE)\s+\/[^']+'/g);
|
|
1722
|
+
return endpointMatches?.length ?? 0;
|
|
1723
|
+
}
|
|
1724
|
+
/**
|
|
1725
|
+
* Copy the OpenAPI client from a backend to all dependent frontend apps.
|
|
1726
|
+
* Called when the backend's .gkm/openapi.ts file changes.
|
|
1727
|
+
*/
|
|
1728
|
+
async function copyClientToFrontends(workspace, backendAppName, options = {}) {
|
|
1729
|
+
const log = options.silent ? () => {} : logger.log.bind(logger);
|
|
1730
|
+
const results = [];
|
|
1731
|
+
const backendApp = workspace.apps[backendAppName];
|
|
1732
|
+
if (!backendApp || backendApp.type !== "backend") return results;
|
|
1733
|
+
const openApiPath = (0, node_path.join)(workspace.root, backendApp.path, ".gkm", "openapi.ts");
|
|
1734
|
+
if (!(0, node_fs.existsSync)(openApiPath)) return results;
|
|
1735
|
+
const content = await (0, node_fs_promises.readFile)(openApiPath, "utf-8");
|
|
1736
|
+
const endpointCount = countEndpoints(content);
|
|
1737
|
+
const dependentFrontends = getDependentFrontends(workspace, backendAppName);
|
|
1738
|
+
for (const frontendAppName of dependentFrontends) {
|
|
1739
|
+
const frontendApp = workspace.apps[frontendAppName];
|
|
1740
|
+
if (!frontendApp || frontendApp.type !== "frontend") continue;
|
|
1741
|
+
const clientOutput = frontendApp.client?.output;
|
|
1742
|
+
if (!clientOutput) continue;
|
|
1743
|
+
const result = {
|
|
1744
|
+
frontendApp: frontendAppName,
|
|
1745
|
+
backendApp: backendAppName,
|
|
1746
|
+
outputPath: "",
|
|
1747
|
+
endpointCount,
|
|
1748
|
+
success: false
|
|
1749
|
+
};
|
|
1750
|
+
try {
|
|
1751
|
+
const frontendPath = (0, node_path.join)(workspace.root, frontendApp.path);
|
|
1752
|
+
const outputDir = (0, node_path.join)(frontendPath, clientOutput);
|
|
1753
|
+
await (0, node_fs_promises.mkdir)(outputDir, { recursive: true });
|
|
1754
|
+
const fileName = `${backendAppName}.ts`;
|
|
1755
|
+
const outputPath = (0, node_path.join)(outputDir, fileName);
|
|
1756
|
+
const backendRelPath = (0, node_path.relative)((0, node_path.dirname)(outputPath), (0, node_path.join)(workspace.root, backendApp.path));
|
|
1757
|
+
const clientContent = `/**
|
|
1758
|
+
* Auto-generated API client for ${backendAppName}
|
|
1759
|
+
* Generated from: ${backendRelPath}
|
|
1760
|
+
*
|
|
1761
|
+
* DO NOT EDIT - This file is automatically regenerated when backend schemas change.
|
|
1762
|
+
*/
|
|
1763
|
+
|
|
1764
|
+
${content}
|
|
1765
|
+
`;
|
|
1766
|
+
await (0, node_fs_promises.writeFile)(outputPath, clientContent);
|
|
1767
|
+
result.outputPath = outputPath;
|
|
1768
|
+
result.success = true;
|
|
1769
|
+
log(`📦 Copied client to ${frontendAppName} from ${backendAppName} (${endpointCount} endpoints)`);
|
|
1770
|
+
} catch (error) {
|
|
1771
|
+
result.error = error.message;
|
|
1772
|
+
}
|
|
1773
|
+
results.push(result);
|
|
1774
|
+
}
|
|
1775
|
+
return results;
|
|
1776
|
+
}
|
|
1777
|
+
/**
|
|
1778
|
+
* Copy clients from all backends to their dependent frontends.
|
|
1779
|
+
* Useful for initial setup or force refresh.
|
|
1780
|
+
*/
|
|
1781
|
+
async function copyAllClients(workspace, options = {}) {
|
|
1782
|
+
const allResults = [];
|
|
1783
|
+
for (const [appName, app] of Object.entries(workspace.apps)) if (app.type === "backend" && app.routes) {
|
|
1784
|
+
const results = await copyClientToFrontends(workspace, appName, options);
|
|
1785
|
+
allResults.push(...results);
|
|
1786
|
+
}
|
|
1787
|
+
return allResults;
|
|
1788
|
+
}
|
|
1789
|
+
|
|
1674
1790
|
//#endregion
|
|
1675
1791
|
//#region src/openapi.ts
|
|
1676
1792
|
/**
|
|
@@ -1700,13 +1816,13 @@ function resolveOpenApiConfig(config) {
|
|
|
1700
1816
|
* @returns Object with output path and endpoint count, or null if disabled
|
|
1701
1817
|
*/
|
|
1702
1818
|
async function generateOpenApi(config, options = {}) {
|
|
1703
|
-
const logger = options.silent ? { log: () => {} } : console;
|
|
1819
|
+
const logger$1 = options.silent ? { log: () => {} } : console;
|
|
1704
1820
|
const openApiConfig = resolveOpenApiConfig(config);
|
|
1705
1821
|
if (!openApiConfig.enabled) return null;
|
|
1706
1822
|
const endpointGenerator = new EndpointGenerator();
|
|
1707
1823
|
const loadedEndpoints = await endpointGenerator.load(config.routes, void 0, options.bustCache);
|
|
1708
1824
|
if (loadedEndpoints.length === 0) {
|
|
1709
|
-
logger.log("No valid endpoints found for OpenAPI generation");
|
|
1825
|
+
logger$1.log("No valid endpoints found for OpenAPI generation");
|
|
1710
1826
|
return null;
|
|
1711
1827
|
}
|
|
1712
1828
|
const endpoints = loadedEndpoints.map(({ construct }) => construct);
|
|
@@ -1719,34 +1835,34 @@ async function generateOpenApi(config, options = {}) {
|
|
|
1719
1835
|
description: openApiConfig.description
|
|
1720
1836
|
});
|
|
1721
1837
|
await (0, node_fs_promises.writeFile)(outputPath, tsContent);
|
|
1722
|
-
logger.log(`📄 OpenAPI client generated: ${OPENAPI_OUTPUT_PATH}`);
|
|
1838
|
+
logger$1.log(`📄 OpenAPI client generated: ${OPENAPI_OUTPUT_PATH}`);
|
|
1723
1839
|
return {
|
|
1724
1840
|
outputPath,
|
|
1725
1841
|
endpointCount: loadedEndpoints.length
|
|
1726
1842
|
};
|
|
1727
1843
|
}
|
|
1728
1844
|
async function openapiCommand(options = {}) {
|
|
1729
|
-
const logger = console;
|
|
1845
|
+
const logger$1 = console;
|
|
1730
1846
|
try {
|
|
1731
1847
|
const loadedConfig = await require_config.loadWorkspaceConfig(options.cwd);
|
|
1732
1848
|
if (loadedConfig.type === "single") {
|
|
1733
1849
|
const config = loadedConfig.raw;
|
|
1734
1850
|
if (!config.openapi) config.openapi = { enabled: true };
|
|
1735
1851
|
const result = await generateOpenApi(config);
|
|
1736
|
-
if (result) logger.log(`Found ${result.endpointCount} endpoints`);
|
|
1852
|
+
if (result) logger$1.log(`Found ${result.endpointCount} endpoints`);
|
|
1737
1853
|
} else {
|
|
1738
1854
|
const { workspace } = loadedConfig;
|
|
1739
1855
|
const workspaceRoot = options.cwd || process.cwd();
|
|
1740
1856
|
const backendApps = Object.entries(workspace.apps).filter(([_, app]) => app.type === "backend" && (app.openapi === true || typeof app.openapi === "object" && app.openapi.enabled !== false));
|
|
1741
1857
|
if (backendApps.length === 0) {
|
|
1742
|
-
logger.log("No backend apps with OpenAPI enabled found");
|
|
1858
|
+
logger$1.log("No backend apps with OpenAPI enabled found");
|
|
1743
1859
|
return;
|
|
1744
1860
|
}
|
|
1745
1861
|
const frontendApps = Object.entries(workspace.apps).filter(([_, app]) => app.type === "frontend" && app.client?.output);
|
|
1746
1862
|
for (const [appName, app] of backendApps) {
|
|
1747
1863
|
if (app.type !== "backend" || !app.routes) continue;
|
|
1748
1864
|
const appPath = (0, node_path.join)(workspaceRoot, app.path);
|
|
1749
|
-
const routes =
|
|
1865
|
+
const routes = normalizeRoutes(app.routes);
|
|
1750
1866
|
const routesGlob = routes.map((r) => (0, node_path.join)(appPath, r));
|
|
1751
1867
|
const gkmConfig = {
|
|
1752
1868
|
routes: routesGlob,
|
|
@@ -1759,7 +1875,7 @@ async function openapiCommand(options = {}) {
|
|
|
1759
1875
|
const result = await generateOpenApi(gkmConfig, { silent: true });
|
|
1760
1876
|
process.chdir(originalCwd);
|
|
1761
1877
|
if (result) {
|
|
1762
|
-
logger.log(`📄 [${appName}] Generated OpenAPI (${result.endpointCount} endpoints)`);
|
|
1878
|
+
logger$1.log(`📄 [${appName}] Generated OpenAPI (${result.endpointCount} endpoints)`);
|
|
1763
1879
|
for (const [frontendName, frontendApp] of frontendApps) {
|
|
1764
1880
|
if (frontendApp.type !== "frontend") continue;
|
|
1765
1881
|
const dependsOnBackend = !frontendApp.dependencies || frontendApp.dependencies.includes(appName);
|
|
@@ -1767,10 +1883,10 @@ async function openapiCommand(options = {}) {
|
|
|
1767
1883
|
const frontendPath = (0, node_path.join)(workspaceRoot, frontendApp.path);
|
|
1768
1884
|
const clientOutputPath = (0, node_path.join)(frontendPath, frontendApp.client.output, "openapi.ts");
|
|
1769
1885
|
await (0, node_fs_promises.mkdir)((0, node_path.dirname)(clientOutputPath), { recursive: true });
|
|
1770
|
-
const { readFile } = await import("node:fs/promises");
|
|
1771
|
-
const content = await readFile(result.outputPath, "utf-8");
|
|
1886
|
+
const { readFile: readFile$1 } = await import("node:fs/promises");
|
|
1887
|
+
const content = await readFile$1(result.outputPath, "utf-8");
|
|
1772
1888
|
await (0, node_fs_promises.writeFile)(clientOutputPath, content);
|
|
1773
|
-
logger.log(` → [${frontendName}] ${frontendApp.client.output}/openapi.ts`);
|
|
1889
|
+
logger$1.log(` → [${frontendName}] ${frontendApp.client.output}/openapi.ts`);
|
|
1774
1890
|
}
|
|
1775
1891
|
}
|
|
1776
1892
|
}
|
|
@@ -1800,12 +1916,42 @@ Object.defineProperty(exports, 'OPENAPI_OUTPUT_PATH', {
|
|
|
1800
1916
|
return OPENAPI_OUTPUT_PATH;
|
|
1801
1917
|
}
|
|
1802
1918
|
});
|
|
1919
|
+
Object.defineProperty(exports, 'copyAllClients', {
|
|
1920
|
+
enumerable: true,
|
|
1921
|
+
get: function () {
|
|
1922
|
+
return copyAllClients;
|
|
1923
|
+
}
|
|
1924
|
+
});
|
|
1925
|
+
Object.defineProperty(exports, 'copyClientToFrontends', {
|
|
1926
|
+
enumerable: true,
|
|
1927
|
+
get: function () {
|
|
1928
|
+
return copyClientToFrontends;
|
|
1929
|
+
}
|
|
1930
|
+
});
|
|
1803
1931
|
Object.defineProperty(exports, 'generateOpenApi', {
|
|
1804
1932
|
enumerable: true,
|
|
1805
1933
|
get: function () {
|
|
1806
1934
|
return generateOpenApi;
|
|
1807
1935
|
}
|
|
1808
1936
|
});
|
|
1937
|
+
Object.defineProperty(exports, 'getBackendOpenApiPath', {
|
|
1938
|
+
enumerable: true,
|
|
1939
|
+
get: function () {
|
|
1940
|
+
return getBackendOpenApiPath;
|
|
1941
|
+
}
|
|
1942
|
+
});
|
|
1943
|
+
Object.defineProperty(exports, 'isPartitionedRoutes', {
|
|
1944
|
+
enumerable: true,
|
|
1945
|
+
get: function () {
|
|
1946
|
+
return isPartitionedRoutes;
|
|
1947
|
+
}
|
|
1948
|
+
});
|
|
1949
|
+
Object.defineProperty(exports, 'normalizeRoutes', {
|
|
1950
|
+
enumerable: true,
|
|
1951
|
+
get: function () {
|
|
1952
|
+
return normalizeRoutes;
|
|
1953
|
+
}
|
|
1954
|
+
});
|
|
1809
1955
|
Object.defineProperty(exports, 'openapiCommand', {
|
|
1810
1956
|
enumerable: true,
|
|
1811
1957
|
get: function () {
|
|
@@ -1818,4 +1964,4 @@ Object.defineProperty(exports, 'resolveOpenApiConfig', {
|
|
|
1818
1964
|
return resolveOpenApiConfig;
|
|
1819
1965
|
}
|
|
1820
1966
|
});
|
|
1821
|
-
//# sourceMappingURL=openapi-
|
|
1967
|
+
//# sourceMappingURL=openapi-BYxAWwok.cjs.map
|