@lark-apaas/devtool-kits 1.2.19 → 1.2.21

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.d.cts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { IncomingMessage, ServerResponse } from 'node:http';
2
- import { Router, RequestHandler, Application } from 'express';
3
- import { ServerResponse as ServerResponse$1, IncomingMessage as IncomingMessage$1 } from 'http';
2
+ import { RequestHandler, Router, Application } from 'express';
3
+ import * as t from '@babel/types';
4
+ import { IncomingMessage as IncomingMessage$1, ServerResponse as ServerResponse$1 } from 'http';
4
5
 
5
6
  /**
6
7
  * 标准化基础路径,确保以 '/' 开头且不包含 trailing slash
@@ -165,12 +166,23 @@ type Middleware = RouteMiddleware | GlobalMiddleware;
165
166
  interface OpenapiMiddlewareOptions {
166
167
  /** Path to the openapi.json file */
167
168
  openapiFilePath: string;
169
+ /** Path to the OpenAPI spec source file (when set, serves /openapi/spec with /openapi/* filtered and $refs resolved) */
170
+ openapiSpecFilePath?: string;
168
171
  /** Enable source code enhancement */
169
172
  enableEnhancement?: boolean;
170
173
  /** Server directory for source code scanning (defaults to context.rootDir) */
171
174
  serverDir?: string;
172
175
  }
173
176
 
177
+ /**
178
+ * Scan serverDir for NestJS controller files and extract all parameterized API routes.
179
+ * Synchronous — safe to call at preset config time (before bundling).
180
+ */
181
+ declare function parseApiRoutes(serverDir: string): Array<{
182
+ method: string;
183
+ path: string;
184
+ }>;
185
+
174
186
  /**
175
187
  * Creates OpenAPI middleware that serves enhanced openapi.json
176
188
  * Supports both rspack/webpack and Vite dev servers
@@ -271,4 +283,30 @@ declare function getQueryParam(req: AnyRequest, key: string): string | undefined
271
283
  */
272
284
  declare function registerMiddlewares(server: ExpressApp | ViteMiddleware, middlewares: Middleware[], options?: Partial<MiddlewareContext>): Promise<void>;
273
285
 
274
- export { type GlobalMiddleware, type Middleware, type MiddlewareContext, type Options, type RouteInfo, type RouteMiddleware, createCollectLogsMiddleware, createDevLogsMiddleware, createOpenapiMiddleware, getQuery, getQueryParam, handleDevProxyError, normalizeBasePath, parseAndGenerateNestResourceTemplate, postprocessDrizzleSchema, registerMiddlewares, sendError, sendJson, sendSuccess };
286
+ interface PageRouteInfo {
287
+ path?: string;
288
+ index?: boolean;
289
+ [key: string]: unknown;
290
+ }
291
+ interface ParseRoutesOptions {
292
+ /** If true, prefix all routes with basePath. Default: true */
293
+ applyBasePath?: boolean;
294
+ }
295
+ declare function routeParserLog(level: 'log' | 'warn' | 'error' | 'info', message: string, ...args: unknown[]): void;
296
+ declare function calculateFileHash(filePath: string): string | null;
297
+ declare function isRouteComponent(openingElement: t.JSXOpeningElement): boolean;
298
+ declare function evaluateTemplateLiteral(templateLiteral: t.TemplateLiteral): string;
299
+ declare function extractPageRouteInfo(openingElement: t.JSXOpeningElement): PageRouteInfo;
300
+ declare function buildFullPath(routeStack: PageRouteInfo[], currentRoute: PageRouteInfo): string | null;
301
+ /**
302
+ * Parse routes from the app file at build time.
303
+ * @param appPath - Path to app.tsx (relative to cwd or absolute)
304
+ * @param basePath - Normalized base path prefix (e.g., '/my_plugin', or '' for no prefix)
305
+ * @param options - Parse options
306
+ * @returns Array of route definitions
307
+ */
308
+ declare function parseRoutesFromFile(appPath: string, basePath: string, options?: ParseRoutesOptions): Array<{
309
+ path: string;
310
+ }>;
311
+
312
+ export { type GlobalMiddleware, type Middleware, type MiddlewareContext, type Options, type PageRouteInfo, type ParseRoutesOptions, type RouteInfo, type RouteMiddleware, buildFullPath, calculateFileHash, createCollectLogsMiddleware, createDevLogsMiddleware, createOpenapiMiddleware, evaluateTemplateLiteral, extractPageRouteInfo, getQuery, getQueryParam, handleDevProxyError, isRouteComponent, normalizeBasePath, parseAndGenerateNestResourceTemplate, parseApiRoutes, parseRoutesFromFile, postprocessDrizzleSchema, registerMiddlewares, routeParserLog, sendError, sendJson, sendSuccess };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { IncomingMessage, ServerResponse } from 'node:http';
2
- import { Router, RequestHandler, Application } from 'express';
3
- import { ServerResponse as ServerResponse$1, IncomingMessage as IncomingMessage$1 } from 'http';
2
+ import { RequestHandler, Router, Application } from 'express';
3
+ import * as t from '@babel/types';
4
+ import { IncomingMessage as IncomingMessage$1, ServerResponse as ServerResponse$1 } from 'http';
4
5
 
5
6
  /**
6
7
  * 标准化基础路径,确保以 '/' 开头且不包含 trailing slash
@@ -165,12 +166,23 @@ type Middleware = RouteMiddleware | GlobalMiddleware;
165
166
  interface OpenapiMiddlewareOptions {
166
167
  /** Path to the openapi.json file */
167
168
  openapiFilePath: string;
169
+ /** Path to the OpenAPI spec source file (when set, serves /openapi/spec with /openapi/* filtered and $refs resolved) */
170
+ openapiSpecFilePath?: string;
168
171
  /** Enable source code enhancement */
169
172
  enableEnhancement?: boolean;
170
173
  /** Server directory for source code scanning (defaults to context.rootDir) */
171
174
  serverDir?: string;
172
175
  }
173
176
 
177
+ /**
178
+ * Scan serverDir for NestJS controller files and extract all parameterized API routes.
179
+ * Synchronous — safe to call at preset config time (before bundling).
180
+ */
181
+ declare function parseApiRoutes(serverDir: string): Array<{
182
+ method: string;
183
+ path: string;
184
+ }>;
185
+
174
186
  /**
175
187
  * Creates OpenAPI middleware that serves enhanced openapi.json
176
188
  * Supports both rspack/webpack and Vite dev servers
@@ -271,4 +283,30 @@ declare function getQueryParam(req: AnyRequest, key: string): string | undefined
271
283
  */
272
284
  declare function registerMiddlewares(server: ExpressApp | ViteMiddleware, middlewares: Middleware[], options?: Partial<MiddlewareContext>): Promise<void>;
273
285
 
274
- export { type GlobalMiddleware, type Middleware, type MiddlewareContext, type Options, type RouteInfo, type RouteMiddleware, createCollectLogsMiddleware, createDevLogsMiddleware, createOpenapiMiddleware, getQuery, getQueryParam, handleDevProxyError, normalizeBasePath, parseAndGenerateNestResourceTemplate, postprocessDrizzleSchema, registerMiddlewares, sendError, sendJson, sendSuccess };
286
+ interface PageRouteInfo {
287
+ path?: string;
288
+ index?: boolean;
289
+ [key: string]: unknown;
290
+ }
291
+ interface ParseRoutesOptions {
292
+ /** If true, prefix all routes with basePath. Default: true */
293
+ applyBasePath?: boolean;
294
+ }
295
+ declare function routeParserLog(level: 'log' | 'warn' | 'error' | 'info', message: string, ...args: unknown[]): void;
296
+ declare function calculateFileHash(filePath: string): string | null;
297
+ declare function isRouteComponent(openingElement: t.JSXOpeningElement): boolean;
298
+ declare function evaluateTemplateLiteral(templateLiteral: t.TemplateLiteral): string;
299
+ declare function extractPageRouteInfo(openingElement: t.JSXOpeningElement): PageRouteInfo;
300
+ declare function buildFullPath(routeStack: PageRouteInfo[], currentRoute: PageRouteInfo): string | null;
301
+ /**
302
+ * Parse routes from the app file at build time.
303
+ * @param appPath - Path to app.tsx (relative to cwd or absolute)
304
+ * @param basePath - Normalized base path prefix (e.g., '/my_plugin', or '' for no prefix)
305
+ * @param options - Parse options
306
+ * @returns Array of route definitions
307
+ */
308
+ declare function parseRoutesFromFile(appPath: string, basePath: string, options?: ParseRoutesOptions): Array<{
309
+ path: string;
310
+ }>;
311
+
312
+ export { type GlobalMiddleware, type Middleware, type MiddlewareContext, type Options, type PageRouteInfo, type ParseRoutesOptions, type RouteInfo, type RouteMiddleware, buildFullPath, calculateFileHash, createCollectLogsMiddleware, createDevLogsMiddleware, createOpenapiMiddleware, evaluateTemplateLiteral, extractPageRouteInfo, getQuery, getQueryParam, handleDevProxyError, isRouteComponent, normalizeBasePath, parseAndGenerateNestResourceTemplate, parseApiRoutes, parseRoutesFromFile, postprocessDrizzleSchema, registerMiddlewares, routeParserLog, sendError, sendJson, sendSuccess };