@lark-apaas/devtool-kits 0.1.0-alpha.1 → 0.1.0-alpha.2
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/index.cjs +14 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +14 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -119,6 +119,8 @@ interface OpenapiMiddlewareOptions {
|
|
|
119
119
|
openapiFilePath: string;
|
|
120
120
|
/** Enable source code enhancement */
|
|
121
121
|
enableEnhancement?: boolean;
|
|
122
|
+
/** Server directory for source code scanning (defaults to context.rootDir) */
|
|
123
|
+
serverDir?: string;
|
|
122
124
|
}
|
|
123
125
|
|
|
124
126
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -119,6 +119,8 @@ interface OpenapiMiddlewareOptions {
|
|
|
119
119
|
openapiFilePath: string;
|
|
120
120
|
/** Enable source code enhancement */
|
|
121
121
|
enableEnhancement?: boolean;
|
|
122
|
+
/** Server directory for source code scanning (defaults to context.rootDir) */
|
|
123
|
+
serverDir?: string;
|
|
122
124
|
}
|
|
123
125
|
|
|
124
126
|
/**
|
package/dist/index.js
CHANGED
|
@@ -28496,8 +28496,8 @@ __name(transformOpenapiPaths, "transformOpenapiPaths");
|
|
|
28496
28496
|
// src/middlewares/openapi/services.ts
|
|
28497
28497
|
async function enhanceOpenApiWithSourceInfo(options = {}) {
|
|
28498
28498
|
const startTime = Date.now();
|
|
28499
|
-
const openapiPath = options.openapiPath || path3.resolve(__dirname, "
|
|
28500
|
-
const serverDir = options.serverDir || path3.resolve(__dirname, "
|
|
28499
|
+
const openapiPath = options.openapiPath || path3.resolve(__dirname, "../client/src/api/gen/openapi.json");
|
|
28500
|
+
const serverDir = options.serverDir || path3.resolve(__dirname, "../server");
|
|
28501
28501
|
const writeFile = options.writeFile !== false;
|
|
28502
28502
|
let openapi;
|
|
28503
28503
|
if (options.openapiData) {
|
|
@@ -28610,7 +28610,7 @@ function extractControllerMetadata(sourceFile, filePath) {
|
|
|
28610
28610
|
__name(extractControllerMetadata, "extractControllerMetadata");
|
|
28611
28611
|
|
|
28612
28612
|
// src/middlewares/openapi/controller.ts
|
|
28613
|
-
function createOpenapiHandler(openapiFilePath, enableEnhancement) {
|
|
28613
|
+
function createOpenapiHandler(openapiFilePath, enableEnhancement, serverDir) {
|
|
28614
28614
|
let cache = null;
|
|
28615
28615
|
return async (_req, res, context) => {
|
|
28616
28616
|
try {
|
|
@@ -28623,7 +28623,8 @@ function createOpenapiHandler(openapiFilePath, enableEnhancement) {
|
|
|
28623
28623
|
if (enableEnhancement && context.isDev) {
|
|
28624
28624
|
const { openapi: enhancedPayload, stats } = await enhanceOpenApiWithSourceInfo({
|
|
28625
28625
|
openapiData: payload,
|
|
28626
|
-
writeFile: false
|
|
28626
|
+
writeFile: false,
|
|
28627
|
+
serverDir: serverDir || context.rootDir
|
|
28627
28628
|
});
|
|
28628
28629
|
payload = enhancedPayload;
|
|
28629
28630
|
console.log(`[OpenAPI] Enhanced in ${stats.duration}ms (${stats.endpointsEnhanced} endpoints)`);
|
|
@@ -28646,9 +28647,10 @@ function createOpenapiHandler(openapiFilePath, enableEnhancement) {
|
|
|
28646
28647
|
__name(createOpenapiHandler, "createOpenapiHandler");
|
|
28647
28648
|
|
|
28648
28649
|
// src/middlewares/openapi/router.ts
|
|
28649
|
-
function createOpenapiRouter(
|
|
28650
|
+
function createOpenapiRouter(options, context) {
|
|
28651
|
+
const { openapiFilePath, enableEnhancement, serverDir } = options;
|
|
28650
28652
|
const router = import_express.default.Router();
|
|
28651
|
-
const handler = createOpenapiHandler(openapiFilePath, enableEnhancement);
|
|
28653
|
+
const handler = createOpenapiHandler(openapiFilePath, enableEnhancement, serverDir);
|
|
28652
28654
|
router.get("/openapi.json", (req, res) => handler(req, res, context));
|
|
28653
28655
|
return router;
|
|
28654
28656
|
}
|
|
@@ -28663,14 +28665,18 @@ var OPENAPI_ROUTES = [
|
|
|
28663
28665
|
}
|
|
28664
28666
|
];
|
|
28665
28667
|
function createOpenapiMiddleware(options) {
|
|
28666
|
-
const { openapiFilePath, enableEnhancement = true } = options;
|
|
28668
|
+
const { openapiFilePath, enableEnhancement = true, serverDir } = options;
|
|
28667
28669
|
return {
|
|
28668
28670
|
name: "openapi",
|
|
28669
28671
|
mountPath: "/dev",
|
|
28670
28672
|
routes: OPENAPI_ROUTES,
|
|
28671
28673
|
enabled: /* @__PURE__ */ __name((context) => context.isDev, "enabled"),
|
|
28672
28674
|
createRouter: /* @__PURE__ */ __name((context) => {
|
|
28673
|
-
return createOpenapiRouter(
|
|
28675
|
+
return createOpenapiRouter({
|
|
28676
|
+
openapiFilePath,
|
|
28677
|
+
enableEnhancement,
|
|
28678
|
+
serverDir
|
|
28679
|
+
}, context);
|
|
28674
28680
|
}, "createRouter")
|
|
28675
28681
|
};
|
|
28676
28682
|
}
|