vitek-plugin 0.1.0-beta
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/LICENSE +21 -0
- package/README.md +908 -0
- package/dist/adapters/vite/dev-server.d.ts +23 -0
- package/dist/adapters/vite/dev-server.d.ts.map +1 -0
- package/dist/adapters/vite/dev-server.js +428 -0
- package/dist/adapters/vite/logger.d.ts +33 -0
- package/dist/adapters/vite/logger.d.ts.map +1 -0
- package/dist/adapters/vite/logger.js +112 -0
- package/dist/core/context/create-context.d.ts +39 -0
- package/dist/core/context/create-context.d.ts.map +1 -0
- package/dist/core/context/create-context.js +34 -0
- package/dist/core/file-system/scan-api-dir.d.ts +26 -0
- package/dist/core/file-system/scan-api-dir.d.ts.map +1 -0
- package/dist/core/file-system/scan-api-dir.js +83 -0
- package/dist/core/file-system/watch-api-dir.d.ts +18 -0
- package/dist/core/file-system/watch-api-dir.d.ts.map +1 -0
- package/dist/core/file-system/watch-api-dir.js +40 -0
- package/dist/core/middleware/compose.d.ts +12 -0
- package/dist/core/middleware/compose.d.ts.map +1 -0
- package/dist/core/middleware/compose.js +27 -0
- package/dist/core/middleware/get-applicable-middlewares.d.ts +17 -0
- package/dist/core/middleware/get-applicable-middlewares.d.ts.map +1 -0
- package/dist/core/middleware/get-applicable-middlewares.js +47 -0
- package/dist/core/middleware/load-global.d.ts +13 -0
- package/dist/core/middleware/load-global.d.ts.map +1 -0
- package/dist/core/middleware/load-global.js +37 -0
- package/dist/core/normalize/normalize-path.d.ts +25 -0
- package/dist/core/normalize/normalize-path.d.ts.map +1 -0
- package/dist/core/normalize/normalize-path.js +76 -0
- package/dist/core/routing/route-matcher.d.ts +10 -0
- package/dist/core/routing/route-matcher.d.ts.map +1 -0
- package/dist/core/routing/route-matcher.js +32 -0
- package/dist/core/routing/route-parser.d.ts +28 -0
- package/dist/core/routing/route-parser.d.ts.map +1 -0
- package/dist/core/routing/route-parser.js +52 -0
- package/dist/core/routing/route-types.d.ts +43 -0
- package/dist/core/routing/route-types.d.ts.map +1 -0
- package/dist/core/routing/route-types.js +5 -0
- package/dist/core/types/extract-ast.d.ts +18 -0
- package/dist/core/types/extract-ast.d.ts.map +1 -0
- package/dist/core/types/extract-ast.js +26 -0
- package/dist/core/types/generate.d.ts +22 -0
- package/dist/core/types/generate.d.ts.map +1 -0
- package/dist/core/types/generate.js +576 -0
- package/dist/core/types/schema.d.ts +21 -0
- package/dist/core/types/schema.d.ts.map +1 -0
- package/dist/core/types/schema.js +17 -0
- package/dist/core/validation/types.d.ts +27 -0
- package/dist/core/validation/types.d.ts.map +1 -0
- package/dist/core/validation/types.js +5 -0
- package/dist/core/validation/validator.d.ts +22 -0
- package/dist/core/validation/validator.d.ts.map +1 -0
- package/dist/core/validation/validator.js +131 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/plugin.d.ts +27 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +54 -0
- package/dist/shared/constants.d.ts +13 -0
- package/dist/shared/constants.d.ts.map +1 -0
- package/dist/shared/constants.js +12 -0
- package/dist/shared/errors.d.ts +75 -0
- package/dist/shared/errors.d.ts.map +1 -0
- package/dist/shared/errors.js +118 -0
- package/dist/shared/response-helpers.d.ts +61 -0
- package/dist/shared/response-helpers.d.ts.map +1 -0
- package/dist/shared/response-helpers.js +100 -0
- package/dist/shared/utils.d.ts +17 -0
- package/dist/shared/utils.d.ts.map +1 -0
- package/dist/shared/utils.js +27 -0
- package/package.json +48 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Route-related types
|
|
3
|
+
* Core types - no dependencies
|
|
4
|
+
*/
|
|
5
|
+
import type { HttpMethod } from '../../shared/constants.js';
|
|
6
|
+
import type { VitekContext } from '../context/create-context.js';
|
|
7
|
+
/**
|
|
8
|
+
* Route handler
|
|
9
|
+
*/
|
|
10
|
+
export type RouteHandler = (context: VitekContext) => Promise<any> | any;
|
|
11
|
+
/**
|
|
12
|
+
* Middleware function
|
|
13
|
+
*/
|
|
14
|
+
export type Middleware = (context: VitekContext, next: () => Promise<void>) => Promise<void> | void;
|
|
15
|
+
/**
|
|
16
|
+
* Definition of a registered route
|
|
17
|
+
*/
|
|
18
|
+
export interface Route {
|
|
19
|
+
/** Path pattern (ex: "users/:id") */
|
|
20
|
+
pattern: string;
|
|
21
|
+
/** HTTP method */
|
|
22
|
+
method: HttpMethod;
|
|
23
|
+
/** Route handler */
|
|
24
|
+
handler: RouteHandler;
|
|
25
|
+
/** Path parameters (ex: ["id"]) */
|
|
26
|
+
params: string[];
|
|
27
|
+
/** Source file (for debugging) */
|
|
28
|
+
file: string;
|
|
29
|
+
/** Regex for matching */
|
|
30
|
+
regex: RegExp;
|
|
31
|
+
/** Body type (name of the type exported from the file, ex: "Body") */
|
|
32
|
+
bodyType?: string;
|
|
33
|
+
/** Query type (name of the type exported from the file, ex: "Query") */
|
|
34
|
+
queryType?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Route matching result
|
|
38
|
+
*/
|
|
39
|
+
export interface RouteMatch {
|
|
40
|
+
route: Route;
|
|
41
|
+
params: Record<string, string>;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=route-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-types.d.ts","sourceRoot":"","sources":["../../../src/core/routing/route-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAEjE;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,YAAY,KAAK,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;AAEzE;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,CACvB,OAAO,EAAE,YAAY,EACrB,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,KACtB,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAE1B;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB,qCAAqC;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,kBAAkB;IAClB,MAAM,EAAE,UAAU,CAAC;IACnB,oBAAoB;IACpB,OAAO,EAAE,YAAY,CAAC;IACtB,mCAAmC;IACnC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,yBAAyB;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,sEAAsE;IACtE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,wEAAwE;IACxE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AST-based type extraction using ts-morph
|
|
3
|
+
* Falls back to regex if AST parsing fails or ts-morph is not available
|
|
4
|
+
*
|
|
5
|
+
* Note: This is a placeholder for future AST-based extraction.
|
|
6
|
+
* To use this, add ts-morph as an optional dependency:
|
|
7
|
+
* npm install --save-optional ts-morph
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Extracts a type definition from a TypeScript file using AST parsing
|
|
11
|
+
* Returns the type body as a string, or undefined if not found
|
|
12
|
+
*
|
|
13
|
+
* @deprecated This function requires ts-morph which is not currently installed.
|
|
14
|
+
* The regex-based extraction in dev-server.ts is used instead.
|
|
15
|
+
* To enable AST parsing, install ts-morph and update the extraction logic.
|
|
16
|
+
*/
|
|
17
|
+
export declare function extractTypeFromFileAST(filePath: string, typeName: string): Promise<string | undefined>;
|
|
18
|
+
//# sourceMappingURL=extract-ast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract-ast.d.ts","sourceRoot":"","sources":["../../../src/core/types/extract-ast.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAC1C,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAS7B"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AST-based type extraction using ts-morph
|
|
3
|
+
* Falls back to regex if AST parsing fails or ts-morph is not available
|
|
4
|
+
*
|
|
5
|
+
* Note: This is a placeholder for future AST-based extraction.
|
|
6
|
+
* To use this, add ts-morph as an optional dependency:
|
|
7
|
+
* npm install --save-optional ts-morph
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Extracts a type definition from a TypeScript file using AST parsing
|
|
11
|
+
* Returns the type body as a string, or undefined if not found
|
|
12
|
+
*
|
|
13
|
+
* @deprecated This function requires ts-morph which is not currently installed.
|
|
14
|
+
* The regex-based extraction in dev-server.ts is used instead.
|
|
15
|
+
* To enable AST parsing, install ts-morph and update the extraction logic.
|
|
16
|
+
*/
|
|
17
|
+
export async function extractTypeFromFileAST(filePath, typeName) {
|
|
18
|
+
// AST parsing is not currently implemented
|
|
19
|
+
// This would require:
|
|
20
|
+
// 1. Adding ts-morph as optional dependency
|
|
21
|
+
// 2. Making extractTypeFromFile async
|
|
22
|
+
// 3. Updating all call sites
|
|
23
|
+
//
|
|
24
|
+
// For now, regex-based extraction is used (see dev-server.ts)
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript type generation for the API
|
|
3
|
+
* Core logic - no Vite dependencies
|
|
4
|
+
*/
|
|
5
|
+
import type { RouteSchema } from './schema.js';
|
|
6
|
+
/**
|
|
7
|
+
* Generates the content of the generated types file
|
|
8
|
+
*/
|
|
9
|
+
export declare function generateTypesContent(routes: RouteSchema[], apiBasePath: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Writes the generated types file
|
|
12
|
+
*/
|
|
13
|
+
export declare function generateTypesFile(outputPath: string, routes: RouteSchema[], apiBasePath: string): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Generates the content of the generated services file
|
|
16
|
+
*/
|
|
17
|
+
export declare function generateServicesContent(routes: RouteSchema[], apiBasePath: string, isTypeScript?: boolean): string;
|
|
18
|
+
/**
|
|
19
|
+
* Writes the generated services file
|
|
20
|
+
*/
|
|
21
|
+
export declare function generateServicesFile(outputPath: string, routes: RouteSchema[], apiBasePath: string, isTypeScript?: boolean): Promise<void>;
|
|
22
|
+
//# sourceMappingURL=generate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/core/types/generate.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CA8FvF;AA6LD;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,WAAW,EAAE,EACrB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC,CAUf;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,GAAE,OAAc,GAAG,MAAM,CAuKxH;AA6KD;;GAEG;AACH,wBAAsB,oBAAoB,CACxC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,WAAW,EAAE,EACrB,WAAW,EAAE,MAAM,EACnB,YAAY,GAAE,OAAc,GAC3B,OAAO,CAAC,IAAI,CAAC,CAUf"}
|