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.
Files changed (72) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +908 -0
  3. package/dist/adapters/vite/dev-server.d.ts +23 -0
  4. package/dist/adapters/vite/dev-server.d.ts.map +1 -0
  5. package/dist/adapters/vite/dev-server.js +428 -0
  6. package/dist/adapters/vite/logger.d.ts +33 -0
  7. package/dist/adapters/vite/logger.d.ts.map +1 -0
  8. package/dist/adapters/vite/logger.js +112 -0
  9. package/dist/core/context/create-context.d.ts +39 -0
  10. package/dist/core/context/create-context.d.ts.map +1 -0
  11. package/dist/core/context/create-context.js +34 -0
  12. package/dist/core/file-system/scan-api-dir.d.ts +26 -0
  13. package/dist/core/file-system/scan-api-dir.d.ts.map +1 -0
  14. package/dist/core/file-system/scan-api-dir.js +83 -0
  15. package/dist/core/file-system/watch-api-dir.d.ts +18 -0
  16. package/dist/core/file-system/watch-api-dir.d.ts.map +1 -0
  17. package/dist/core/file-system/watch-api-dir.js +40 -0
  18. package/dist/core/middleware/compose.d.ts +12 -0
  19. package/dist/core/middleware/compose.d.ts.map +1 -0
  20. package/dist/core/middleware/compose.js +27 -0
  21. package/dist/core/middleware/get-applicable-middlewares.d.ts +17 -0
  22. package/dist/core/middleware/get-applicable-middlewares.d.ts.map +1 -0
  23. package/dist/core/middleware/get-applicable-middlewares.js +47 -0
  24. package/dist/core/middleware/load-global.d.ts +13 -0
  25. package/dist/core/middleware/load-global.d.ts.map +1 -0
  26. package/dist/core/middleware/load-global.js +37 -0
  27. package/dist/core/normalize/normalize-path.d.ts +25 -0
  28. package/dist/core/normalize/normalize-path.d.ts.map +1 -0
  29. package/dist/core/normalize/normalize-path.js +76 -0
  30. package/dist/core/routing/route-matcher.d.ts +10 -0
  31. package/dist/core/routing/route-matcher.d.ts.map +1 -0
  32. package/dist/core/routing/route-matcher.js +32 -0
  33. package/dist/core/routing/route-parser.d.ts +28 -0
  34. package/dist/core/routing/route-parser.d.ts.map +1 -0
  35. package/dist/core/routing/route-parser.js +52 -0
  36. package/dist/core/routing/route-types.d.ts +43 -0
  37. package/dist/core/routing/route-types.d.ts.map +1 -0
  38. package/dist/core/routing/route-types.js +5 -0
  39. package/dist/core/types/extract-ast.d.ts +18 -0
  40. package/dist/core/types/extract-ast.d.ts.map +1 -0
  41. package/dist/core/types/extract-ast.js +26 -0
  42. package/dist/core/types/generate.d.ts +22 -0
  43. package/dist/core/types/generate.d.ts.map +1 -0
  44. package/dist/core/types/generate.js +576 -0
  45. package/dist/core/types/schema.d.ts +21 -0
  46. package/dist/core/types/schema.d.ts.map +1 -0
  47. package/dist/core/types/schema.js +17 -0
  48. package/dist/core/validation/types.d.ts +27 -0
  49. package/dist/core/validation/types.d.ts.map +1 -0
  50. package/dist/core/validation/types.js +5 -0
  51. package/dist/core/validation/validator.d.ts +22 -0
  52. package/dist/core/validation/validator.d.ts.map +1 -0
  53. package/dist/core/validation/validator.js +131 -0
  54. package/dist/index.d.ts +8 -0
  55. package/dist/index.d.ts.map +1 -0
  56. package/dist/index.js +4 -0
  57. package/dist/plugin.d.ts +27 -0
  58. package/dist/plugin.d.ts.map +1 -0
  59. package/dist/plugin.js +54 -0
  60. package/dist/shared/constants.d.ts +13 -0
  61. package/dist/shared/constants.d.ts.map +1 -0
  62. package/dist/shared/constants.js +12 -0
  63. package/dist/shared/errors.d.ts +75 -0
  64. package/dist/shared/errors.d.ts.map +1 -0
  65. package/dist/shared/errors.js +118 -0
  66. package/dist/shared/response-helpers.d.ts +61 -0
  67. package/dist/shared/response-helpers.d.ts.map +1 -0
  68. package/dist/shared/response-helpers.js +100 -0
  69. package/dist/shared/utils.d.ts +17 -0
  70. package/dist/shared/utils.d.ts.map +1 -0
  71. package/dist/shared/utils.js +27 -0
  72. 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,5 @@
1
+ /**
2
+ * Route-related types
3
+ * Core types - no dependencies
4
+ */
5
+ export {};
@@ -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"}