@http-forge/core 0.6.32 → 0.6.36-beta.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.
Files changed (100) hide show
  1. package/README.md +51 -0
  2. package/dist/__tests__/api-discovery/golden-utils.d.ts +10 -0
  3. package/dist/index.d.ts +49 -22
  4. package/dist/index.js +456 -480
  5. package/dist/index.mjs +456 -480
  6. package/dist/infrastructure/ai/ai-context.d.ts +109 -0
  7. package/dist/infrastructure/ai/ai-provider.d.ts +1 -1
  8. package/dist/infrastructure/ai/ai-utils.d.ts +38 -0
  9. package/dist/infrastructure/ai/http-providers.d.ts +34 -0
  10. package/dist/infrastructure/api-discovery/analyzer/component-analyzer.d.ts +60 -0
  11. package/dist/infrastructure/api-discovery/analyzer/express-component-analyzer.d.ts +14 -0
  12. package/dist/infrastructure/api-discovery/analyzer/fastify-component-analyzer.d.ts +14 -0
  13. package/dist/infrastructure/api-discovery/analyzer/index.d.ts +11 -0
  14. package/dist/infrastructure/api-discovery/analyzer/lambda-component-analyzer.d.ts +18 -0
  15. package/dist/infrastructure/api-discovery/api-discovery-service.d.ts +49 -0
  16. package/dist/infrastructure/api-discovery/auth-validation.d.ts +34 -0
  17. package/dist/infrastructure/api-discovery/drift-engine.d.ts +139 -0
  18. package/dist/infrastructure/api-discovery/fastapi/fastapi-discovery-provider.d.ts +19 -0
  19. package/dist/infrastructure/api-discovery/fastapi/fastapi-parser.d.ts +60 -0
  20. package/dist/infrastructure/api-discovery/framework-detector.d.ts +8 -0
  21. package/dist/infrastructure/api-discovery/index.d.ts +29 -0
  22. package/dist/infrastructure/api-discovery/path-utils.d.ts +17 -0
  23. package/dist/infrastructure/api-discovery/project-name.d.ts +2 -0
  24. package/dist/infrastructure/api-discovery/provider.d.ts +29 -0
  25. package/dist/infrastructure/api-discovery/providers/express-discovery-provider.d.ts +13 -0
  26. package/dist/infrastructure/api-discovery/providers/fastify-discovery-provider.d.ts +13 -0
  27. package/dist/infrastructure/api-discovery/providers/lambda-discovery-provider.d.ts +19 -0
  28. package/dist/infrastructure/api-discovery/providers/nest-discovery-provider.d.ts +12 -0
  29. package/dist/infrastructure/api-discovery/seed-loader.d.ts +11 -0
  30. package/dist/infrastructure/api-discovery/source-files.d.ts +1 -0
  31. package/dist/infrastructure/api-discovery/spring/controller-visitor.d.ts +141 -0
  32. package/dist/infrastructure/api-discovery/spring/endpoint-parser.d.ts +51 -0
  33. package/dist/infrastructure/api-discovery/spring/file-utils.d.ts +28 -0
  34. package/dist/infrastructure/api-discovery/spring/model.d.ts +84 -0
  35. package/dist/infrastructure/api-discovery/spring/schema-generator.d.ts +65 -0
  36. package/dist/infrastructure/api-discovery/spring/spring-discovery-provider.d.ts +30 -0
  37. package/dist/infrastructure/api-discovery/spring/spring-types.d.ts +27 -0
  38. package/dist/infrastructure/api-discovery/test-generator.d.ts +69 -0
  39. package/dist/infrastructure/api-discovery/types.d.ts +154 -0
  40. package/dist/infrastructure/api-discovery/workflow-discovery.d.ts +55 -0
  41. package/dist/infrastructure/architect/api-architect-service.d.ts +85 -0
  42. package/dist/infrastructure/architect/architect-prompt.d.ts +22 -0
  43. package/dist/infrastructure/architect/collection-to-endpoints.d.ts +13 -0
  44. package/dist/infrastructure/architect/index.d.ts +10 -0
  45. package/dist/infrastructure/collection/collection-service.d.ts +1 -5
  46. package/dist/infrastructure/collection/json-collection-loader.d.ts +0 -8
  47. package/dist/infrastructure/cookie/cookie-service.d.ts +2 -13
  48. package/dist/infrastructure/cookie/cookie-utils.d.ts +5 -0
  49. package/dist/infrastructure/docs/index.d.ts +5 -0
  50. package/dist/infrastructure/docs/release-notes.d.ts +51 -0
  51. package/dist/infrastructure/environment/environment-config-service.d.ts +0 -1
  52. package/dist/infrastructure/environment/variable-interpolator.d.ts +9 -0
  53. package/dist/infrastructure/http/header-utils.d.ts +13 -0
  54. package/dist/infrastructure/http/http-request-service.d.ts +3 -3
  55. package/dist/infrastructure/http/interceptor-chain.d.ts +35 -16
  56. package/dist/infrastructure/http/native-http-client.d.ts +0 -10
  57. package/dist/infrastructure/openapi/interfaces.d.ts +14 -0
  58. package/dist/infrastructure/openapi/openapi-exporter.d.ts +11 -91
  59. package/dist/infrastructure/openapi/openapi-importer.d.ts +19 -0
  60. package/dist/infrastructure/openapi/openapi-operation-builder.d.ts +36 -0
  61. package/dist/infrastructure/openapi/openapi-schema-merger.d.ts +33 -0
  62. package/dist/infrastructure/openapi/openapi-spec-writer.d.ts +27 -0
  63. package/dist/infrastructure/openapi/openapi-utils.d.ts +62 -0
  64. package/dist/infrastructure/parsers/har-parser.d.ts +63 -0
  65. package/dist/infrastructure/parsers/index.d.ts +2 -0
  66. package/dist/infrastructure/review/index.d.ts +5 -0
  67. package/dist/infrastructure/review/review-engine.d.ts +95 -0
  68. package/dist/infrastructure/script/crypto-js-compat.d.ts +123 -0
  69. package/dist/infrastructure/script/request-object-factory.d.ts +54 -0
  70. package/dist/infrastructure/script/request-script-session.d.ts +0 -5
  71. package/dist/infrastructure/script/script-executor.d.ts +4 -33
  72. package/dist/infrastructure/script/script-factories.d.ts +13 -0
  73. package/dist/infrastructure/script/variable-scopes.d.ts +101 -0
  74. package/dist/infrastructure/test-suite/interfaces.d.ts +6 -0
  75. package/dist/infrastructure/test-suite/result-storage-service.d.ts +6 -1
  76. package/dist/infrastructure/test-suite/result-storage.d.ts +14 -1
  77. package/dist/runtime/collection-traversal.d.ts +32 -0
  78. package/dist/runtime/direct-execution.d.ts +7 -0
  79. package/dist/runtime/execution-helpers.d.ts +30 -0
  80. package/dist/runtime/mcp-dispatcher.d.ts +10 -34
  81. package/dist/runtime/mcp-handlers/ai.d.ts +6 -0
  82. package/dist/runtime/mcp-handlers/collection.d.ts +5 -0
  83. package/dist/runtime/mcp-handlers/discovery.d.ts +12 -0
  84. package/dist/runtime/mcp-handlers/environment-management.d.ts +6 -0
  85. package/dist/runtime/mcp-handlers/environment.d.ts +5 -0
  86. package/dist/runtime/mcp-handlers/execution.d.ts +6 -0
  87. package/dist/runtime/mcp-handlers/helpers.d.ts +43 -0
  88. package/dist/runtime/mcp-handlers/inspection.d.ts +5 -0
  89. package/dist/runtime/mcp-handlers/registry.d.ts +12 -0
  90. package/dist/runtime/mcp-handlers/request.d.ts +5 -0
  91. package/dist/runtime/mcp-handlers/review.d.ts +10 -0
  92. package/dist/runtime/mcp-handlers/run-status.d.ts +5 -0
  93. package/dist/runtime/mcp-handlers/suite.d.ts +6 -0
  94. package/dist/runtime/mcp-handlers/types.d.ts +59 -0
  95. package/dist/runtime/mcp-prompts.d.ts +16 -2
  96. package/dist/runtime/mcp-tool-schemas.d.ts +8 -0
  97. package/dist/runtime/suite-executor.d.ts +20 -0
  98. package/dist/types/types.d.ts +0 -9
  99. package/dist/utils/env-hints.d.ts +17 -0
  100. package/package.json +16 -6
@@ -0,0 +1,17 @@
1
+ import * as ts from 'typescript';
2
+ import { EndpointConfidence } from './types';
3
+ export interface ResolutionContext {
4
+ variables?: Record<string, string>;
5
+ env?: Record<string, string>;
6
+ }
7
+ export interface PathValue {
8
+ pathExpression: string;
9
+ resolvedPath?: string;
10
+ confidence: EndpointConfidence;
11
+ }
12
+ export declare function createResolutionContext(sourceFile: ts.SourceFile, projectRoot?: string, envOverrides?: Record<string, string>): ResolutionContext;
13
+ export declare function toPathValue(expr: ts.Expression | undefined, sourceFile: ts.SourceFile, resolutionContext?: ResolutionContext): PathValue;
14
+ export declare function joinPaths(prefix?: string, route?: string): {
15
+ pathExpression: string;
16
+ resolvedPath?: string;
17
+ };
@@ -0,0 +1,2 @@
1
+ import { DiscoveredApi } from './types';
2
+ export declare function resolveProjectName(endpoint: DiscoveredApi, projectRoots: string[]): string | undefined;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * API Discovery — Provider Contract
3
+ *
4
+ * One provider per framework (Express, NestJS, Fastify, Lambda, Spring, FastAPI).
5
+ * New frameworks are additive: implement this interface and register it — never
6
+ * modify `ApiDiscoveryService` to special-case a framework (Open/Closed).
7
+ *
8
+ * Ported from `node-api-forge/src/discovery/provider.ts` (unchanged semantics).
9
+ */
10
+ import { DiscoveryContext, DiscoveryResult, FrameworkFingerprint, ApiFramework } from './types';
11
+ export interface ProviderSupport {
12
+ supported: boolean;
13
+ confidence: number;
14
+ reasons: string[];
15
+ }
16
+ export interface ApiDiscoveryProvider {
17
+ readonly id: string;
18
+ /** The framework this provider parses. Used to filter providers by detection. */
19
+ readonly framework: ApiFramework;
20
+ /** Whether this provider can parse the given project root (cheap check). */
21
+ supports(fingerprint: FrameworkFingerprint): ProviderSupport;
22
+ /**
23
+ * Discover endpoints for one project root. Must return deterministic ordering
24
+ * (method asc, path asc, file asc) — see DECISIONS D11.
25
+ */
26
+ discover(context: DiscoveryContext, fingerprint: FrameworkFingerprint): Promise<DiscoveryResult>;
27
+ /** Release per-project caches (e.g. after a file change or refresh). */
28
+ clearCache?(projectRoot?: string): void;
29
+ }
@@ -0,0 +1,13 @@
1
+ import { ApiDiscoveryProvider, ProviderSupport } from '../provider';
2
+ import { ApiFramework, DiscoveryContext, DiscoveryResult, FrameworkFingerprint } from '../types';
3
+ export declare class ExpressDiscoveryProvider implements ApiDiscoveryProvider {
4
+ readonly id = "provider.express";
5
+ readonly framework: ApiFramework;
6
+ private analyzer;
7
+ private readonly fileCache;
8
+ private readonly projectFileIndex;
9
+ clearCache(projectRoot?: string): void;
10
+ supports(fingerprint: FrameworkFingerprint): ProviderSupport;
11
+ discover(_context: DiscoveryContext, fingerprint: FrameworkFingerprint): Promise<DiscoveryResult>;
12
+ private pruneDeletedFiles;
13
+ }
@@ -0,0 +1,13 @@
1
+ import { ApiDiscoveryProvider, ProviderSupport } from '../provider';
2
+ import { ApiFramework, DiscoveryContext, DiscoveryResult, FrameworkFingerprint } from '../types';
3
+ export declare class FastifyDiscoveryProvider implements ApiDiscoveryProvider {
4
+ readonly id = "provider.fastify";
5
+ readonly framework: ApiFramework;
6
+ private analyzer;
7
+ private readonly fileCache;
8
+ private readonly projectFileIndex;
9
+ clearCache(projectRoot?: string): void;
10
+ supports(fingerprint: FrameworkFingerprint): ProviderSupport;
11
+ discover(_context: DiscoveryContext, fingerprint: FrameworkFingerprint): Promise<DiscoveryResult>;
12
+ private pruneDeletedFiles;
13
+ }
@@ -0,0 +1,19 @@
1
+ import { ApiDiscoveryProvider, ProviderSupport } from '../provider';
2
+ import { ApiFramework, DiscoveryContext, DiscoveryResult, FrameworkFingerprint } from '../types';
3
+ export declare class LambdaDiscoveryProvider implements ApiDiscoveryProvider {
4
+ readonly id = "provider.lambda";
5
+ readonly framework: ApiFramework;
6
+ private readonly analyzer;
7
+ private readonly fileCache;
8
+ private readonly projectFileIndex;
9
+ clearCache(projectRoot?: string): void;
10
+ supports(fingerprint: FrameworkFingerprint): ProviderSupport;
11
+ discover(context: DiscoveryContext, fingerprint: FrameworkFingerprint): Promise<DiscoveryResult>;
12
+ private pruneDeletedFiles;
13
+ }
14
+ /**
15
+ * Parse a subset of YAML into a plain JS object tree.
16
+ * Supports: string scalars, objects (indented key:value), arrays (- item),
17
+ * multi-line values are not supported — sufficient for serverless/SAM configs.
18
+ */
19
+ export declare function parseYamlToObject(content: string): Record<string, unknown>;
@@ -0,0 +1,12 @@
1
+ import { ApiDiscoveryProvider, ProviderSupport } from '../provider';
2
+ import { ApiFramework, DiscoveryContext, DiscoveryResult, FrameworkFingerprint } from '../types';
3
+ export declare class NestDiscoveryProvider implements ApiDiscoveryProvider {
4
+ readonly id = "provider.nestjs";
5
+ readonly framework: ApiFramework;
6
+ private readonly fileCache;
7
+ private readonly projectFileIndex;
8
+ clearCache(projectRoot?: string): void;
9
+ supports(fingerprint: FrameworkFingerprint): ProviderSupport;
10
+ discover(_context: DiscoveryContext, _fingerprint: FrameworkFingerprint): Promise<DiscoveryResult>;
11
+ private pruneDeletedFiles;
12
+ }
@@ -0,0 +1,11 @@
1
+ import { DiscoveredApi, DiscoveryContext, DiscoveryWarning } from './types';
2
+ /**
3
+ * Loads seed endpoints from an optional custom loader module.
4
+ *
5
+ * Ported from `node-api-forge/src/discovery/seed-loader.ts`. Only active when
6
+ * `context.customSeedLoaderModulePath` is set (hybrid seed + auto-discovery).
7
+ */
8
+ export declare function loadHybridSeedEndpoints(projectRoot: string, context: DiscoveryContext): {
9
+ endpoints: DiscoveredApi[];
10
+ warnings: DiscoveryWarning[];
11
+ };
@@ -0,0 +1 @@
1
+ export declare function collectSourceFiles(projectRoot: string): string[];
@@ -0,0 +1,141 @@
1
+ import { BaseJavaCstVisitorWithDefaults } from 'java-parser';
2
+ import { Controller, Endpoint } from './model';
3
+ export declare function extractPathParams(path: string): string[];
4
+ export interface AnnotationInfo {
5
+ name: string;
6
+ attributes: Map<string, string | string[]>;
7
+ }
8
+ export interface ClassContext {
9
+ type: 'class';
10
+ name: string;
11
+ line: number;
12
+ annotations: AnnotationInfo[];
13
+ endpoints: Endpoint[];
14
+ basePath?: string;
15
+ }
16
+ export interface MethodContext {
17
+ type: 'method';
18
+ name: string;
19
+ line: number;
20
+ annotations: AnnotationInfo[];
21
+ }
22
+ export declare class ControllerVisitor extends BaseJavaCstVisitorWithDefaults {
23
+ controllers: Controller[];
24
+ private contextStack;
25
+ constructor();
26
+ annotation(ctx: any): void;
27
+ /**
28
+ * Visit nested annotation nodes found in element values of a container
29
+ * annotation (e.g. @ApiResponses containing @ApiResponse entries).
30
+ */
31
+ private visitNestedAnnotations;
32
+ typeIdentifier(ctx: any): void;
33
+ classDeclaration(ctx: any): void;
34
+ methodDeclarator(ctx: any): void;
35
+ methodDeclaration(ctx: any): void;
36
+ /**
37
+ * Recursively collect all tokens from a CST subtree, sorted by position.
38
+ * This is the most robust way to extract text from deeply nested expression trees.
39
+ */
40
+ private collectTokens;
41
+ /**
42
+ * Extract the value from an `elementValue` CST node.
43
+ *
44
+ * The java-parser CST structure for elementValue is:
45
+ * elementValue
46
+ * └─ conditionalExpression (for single values: strings, identifiers, enums)
47
+ * └─ elementValueArrayInitializer (for array values like {"a","b"})
48
+ *
49
+ * String literals are deeply nested:
50
+ * conditionalExpression → binaryExpression → unaryExpression →
51
+ * primary → primaryPrefix → literal → StringLiteral
52
+ *
53
+ * Enum references (e.g. RequestMethod.GET) are similarly nested:
54
+ * ... → primaryPrefix → fqnOrRefType → (tokens: RequestMethod . GET)
55
+ */
56
+ private extractElementValue;
57
+ private buildEndpoint;
58
+ /**
59
+ * Extract OpenAPI/Swagger annotations from method and class annotations.
60
+ */
61
+ private extractOpenApiAnnotations;
62
+ /**
63
+ * Parse a single @ApiResponse annotation into ApiResponseInfo.
64
+ */
65
+ private parseApiResponse;
66
+ /**
67
+ * Get a raw attribute value from an annotation without quote stripping.
68
+ */
69
+ private getAnnotationAttrRaw;
70
+ /**
71
+ * Extract a string attribute from a raw annotation expression.
72
+ * Example: mediaType="application/json" -> application/json
73
+ */
74
+ private extractAttrFromRaw;
75
+ /**
76
+ * Extract implementation type from @Schema(implementation=Foo.class).
77
+ */
78
+ private extractImplementationType;
79
+ /**
80
+ * Extract @ExampleObject(name=..., value=...) blocks from @Content(...).
81
+ */
82
+ private extractExampleObjects;
83
+ /**
84
+ * Extract @Header(name=..., description=..., schema=@Schema(...)) blocks.
85
+ */
86
+ private extractHeaderObjects;
87
+ /**
88
+ * Parse an @ExampleObject value payload and coerce JSON strings when possible.
89
+ */
90
+ private parseExampleValue;
91
+ /**
92
+ * Get a string attribute from an annotation, stripping quotes.
93
+ */
94
+ private getAnnotationAttrString;
95
+ /**
96
+ * Extract the return type from a methodDeclaration CST node.
97
+ * CST path: methodHeader → result → unannType
98
+ */
99
+ private extractReturnType;
100
+ /**
101
+ * Extract parameter metadata from a methodDeclaration CST node's children.
102
+ *
103
+ * CST path to parameters:
104
+ * methodDeclaration.children (= methodDeclCtx)
105
+ * → methodHeader[0].children
106
+ * → methodDeclarator[0].children
107
+ * → formalParameterList[0].children
108
+ * → formalParameter[]
109
+ *
110
+ * Each formalParameter has:
111
+ * formalParameter.children
112
+ * → variableParaRegularParameter[0].children
113
+ * → variableModifier[] (contains annotations)
114
+ * → unannType[0] (the type)
115
+ * → variableDeclaratorId[0].children.Identifier[0].image (the name)
116
+ */
117
+ private extractParameters;
118
+ /**
119
+ * Build a ParameterMeta from @Parameter annotation, Java type info, and validation annotations.
120
+ */
121
+ private buildParameterMeta;
122
+ /**
123
+ * Extract constraint metadata from Java validation annotations on a parameter.
124
+ * Handles @Schema, @Pattern, @Size, @Min, @Max, @DecimalMin, @DecimalMax,
125
+ * @Email, @Positive, @PositiveOrZero, @Negative, @NegativeOrZero, @NotNull, @NotBlank, @NotEmpty.
126
+ */
127
+ private extractConstraintAnnotations;
128
+ /**
129
+ * Get the string value from an annotation's "value" attribute, stripping quotes.
130
+ */
131
+ private getAnnotationStringValue;
132
+ /**
133
+ * Extract a type name from an unannType CST node.
134
+ *
135
+ * unannType → unannReferenceType → unannClassOrInterfaceType → unannClassType → Identifier
136
+ * unannType → unannPrimitiveTypeWithOptionalDimsSuffix → ...
137
+ */
138
+ private extractUnannTypeName;
139
+ private collectAnnotationsFromModifiers;
140
+ private extractTypeName;
141
+ }
@@ -0,0 +1,51 @@
1
+ import { Controller, Endpoint } from './model';
2
+ export declare class EndpointParser {
3
+ private fileCache;
4
+ private generatedRe;
5
+ /** Clear the per-file cache so the next scan re-parses everything. */
6
+ clearCache(): void;
7
+ /**
8
+ * Evict all cached files whose path starts with any of the given
9
+ * directory prefixes.
10
+ */
11
+ evictPaths(dirs: string[]): void;
12
+ /**
13
+ * Scan the project root for Java files, parse the controllers, populate
14
+ * the cache and return every controller found.
15
+ */
16
+ parseControllers(projectRoot: string): Promise<Controller[]>;
17
+ /** Remove a file from the cache (e.g. on delete). */
18
+ removeFile(fsPath: string): void;
19
+ /**
20
+ * Lightweight regex pre-check: returns true if the file text likely
21
+ * contains a Spring controller. This avoids the expensive AST parse
22
+ * for the vast majority of Java files (DTOs, services, utils, etc.).
23
+ *
24
+ * Checks for:
25
+ * - @RestController or @Controller class-level annotations
26
+ * - @RequestMapping / @GetMapping / @PostMapping / etc.
27
+ */
28
+ private static readonly CONTROLLER_HINT_RE;
29
+ private looksLikeController;
30
+ /** Parse a single file and return the controllers found in it. */
31
+ private parseFile;
32
+ findEndpoints(projectRoot: string): Promise<Endpoint[]>;
33
+ private parseWithAst;
34
+ private parseWithRegex;
35
+ /**
36
+ * Extract a path value from annotation arguments string.
37
+ * Handles: "path", value = "path", path = "path"
38
+ */
39
+ private extractPathFromArgs;
40
+ /**
41
+ * Collect the full method signature starting from a line, spanning
42
+ * across continuation lines until we hit the opening `{`.
43
+ */
44
+ private collectMethodSignature;
45
+ /**
46
+ * Extract @RequestHeader, @RequestParam, @RequestBody, @RequestPart,
47
+ * @ModelAttribute and body type from a full method signature string.
48
+ */
49
+ private extractParameterMetadataFromSig;
50
+ private deduplicateEndpoints;
51
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Pure filesystem helpers for Spring discovery (no vscode imports).
3
+ * Ported from `spring-api-tester/src/utils/fileUtils.ts` with all
4
+ * `vscode.workspace.fs` / `vscode.Uri` glue replaced by node `fs`/`path`
5
+ * calls over concrete paths (DECISIONS D2 — no vscode in core).
6
+ */
7
+ /**
8
+ * Recursively find files under `baseDir` whose name matches `include`,
9
+ * skipping directories in SKIP_DIRS.
10
+ */
11
+ export declare function findFilesRecursive(baseDir: string, include: RegExp): string[];
12
+ /** Collect every `.java` file under `projectRoot` (skipping build/cache dirs). */
13
+ export declare function collectJavaFiles(projectRoot: string): string[];
14
+ /** Read a file as UTF-8 text. */
15
+ export declare function readFileText(filePath: string): Promise<string>;
16
+ /** Normalise a file-system path so that comparisons work cross-platform. */
17
+ export declare function normalizePath(fsPath: string): string;
18
+ /** Return the last segment (file or folder name) of a path. */
19
+ export declare function baseName(fsPath: string): string;
20
+ /** Return the parent directory of a file-system path. */
21
+ export declare function dirName(fsPath: string): string;
22
+ /** Clear the Java type file cache (e.g. when files change on disk). */
23
+ export declare function clearJavaTypeFileCache(): void;
24
+ /**
25
+ * Find Java files by simple class name under `projectRoot`.
26
+ * Returns [] if no file matches the simple name.
27
+ */
28
+ export declare function findJavaTypeFiles(projectRoot: string, simpleName: string): Promise<string[]>;
@@ -0,0 +1,84 @@
1
+ export interface Endpoint {
2
+ method: string;
3
+ path: string;
4
+ file: string;
5
+ line: number;
6
+ pathParams?: string[];
7
+ bodyType?: string;
8
+ headers?: string[];
9
+ queryParams?: string[];
10
+ hasBody?: boolean;
11
+ consumes?: string[];
12
+ produces?: string[];
13
+ formParts?: FormPart[];
14
+ modelAttributeType?: string;
15
+ returnType?: string;
16
+ summary?: string;
17
+ description?: string;
18
+ operationId?: string;
19
+ tags?: string[];
20
+ deprecated?: boolean;
21
+ responses?: ApiResponseInfo[];
22
+ parameterMeta?: ParameterMeta[];
23
+ security?: string[];
24
+ }
25
+ /** Metadata from @ApiResponse annotations on a method. */
26
+ export interface ApiResponseInfo {
27
+ statusCode: string;
28
+ description?: string;
29
+ contentType?: string;
30
+ schemaType?: string;
31
+ examples?: Record<string, any>;
32
+ headers?: Record<string, ApiHeaderInfo>;
33
+ }
34
+ /** Metadata from @Header annotations nested in @ApiResponse(headers=...). */
35
+ export interface ApiHeaderInfo {
36
+ description?: string;
37
+ schemaType?: string;
38
+ format?: string;
39
+ required?: boolean;
40
+ deprecated?: boolean;
41
+ }
42
+ /** Metadata from @Parameter annotations on method parameters. */
43
+ export interface ParameterMeta {
44
+ name: string;
45
+ in: 'path' | 'query' | 'header';
46
+ description?: string;
47
+ required?: boolean;
48
+ example?: string;
49
+ deprecated?: boolean;
50
+ schemaType?: string;
51
+ pattern?: string;
52
+ format?: string;
53
+ enum?: string[];
54
+ minimum?: number;
55
+ maximum?: number;
56
+ exclusiveMinimum?: number;
57
+ exclusiveMaximum?: number;
58
+ minLength?: number;
59
+ maxLength?: number;
60
+ }
61
+ /** A single @RequestPart or @RequestParam MultipartFile parameter in a multipart endpoint. */
62
+ export interface FormPart {
63
+ name: string;
64
+ type: string;
65
+ isFile: boolean;
66
+ }
67
+ export interface Controller {
68
+ name: string;
69
+ basePath: string;
70
+ file: string;
71
+ line: number;
72
+ endpoints: Endpoint[];
73
+ }
74
+ /**
75
+ * Represents a Spring Boot application detected in the workspace.
76
+ * Groups controllers that belong to the same project.
77
+ */
78
+ export interface SpringApp {
79
+ name: string;
80
+ rootDir: string;
81
+ port?: number;
82
+ contextPath?: string;
83
+ controllers: Controller[];
84
+ }
@@ -0,0 +1,65 @@
1
+ /**
2
+ * JSON Schema type definition (OpenAPI 3.0 compatible subset).
3
+ */
4
+ export type JSONSchema = Record<string, any>;
5
+ /**
6
+ * Generates JSON Schema from Java class source files.
7
+ *
8
+ * Extracts field types, validation annotations (@Schema, @NotNull, @Size, @Min, @Max, etc.)
9
+ * and produces OpenAPI 3.0 compatible JSON Schema objects.
10
+ */
11
+ export declare class SchemaGenerator {
12
+ private readonly projectRoot;
13
+ private cache;
14
+ constructor(projectRoot: string);
15
+ clearCache(): void;
16
+ /**
17
+ * Generate a JSON Schema for a given Java class name.
18
+ * Returns undefined if the class cannot be found.
19
+ */
20
+ generate(typeName: string): Promise<JSONSchema | undefined>;
21
+ /**
22
+ * Generate a JSON Schema for a response type, potentially wrapping in
23
+ * response-level metadata.
24
+ */
25
+ generateResponseSchema(returnType: string): Promise<JSONSchema | undefined>;
26
+ private parseClassToSchema;
27
+ /**
28
+ * Build a map from declared type parameters (T, U, etc.) to actual type arguments.
29
+ * E.g. for class GenericResponse<T> with genericArgs=['BookmarkB2B'],
30
+ * returns Map { 'T' => 'BookmarkB2B' }
31
+ */
32
+ private buildTypeParamMap;
33
+ /**
34
+ * Split a comma-separated generic type argument string, respecting nested angle brackets.
35
+ * E.g. 'List<String>, BookmarkB2B' → ['List<String>', 'BookmarkB2B']
36
+ */
37
+ private splitGenericArgs;
38
+ /**
39
+ * Replace type parameter names with their actual types in a Java type string.
40
+ * E.g. 'T' → 'BookmarkB2B', 'List<T>' → 'List<BookmarkB2B>'
41
+ */
42
+ private resolveTypeParams;
43
+ private extractFieldsRegex;
44
+ private parseFieldAnnotations;
45
+ private fieldToSchema;
46
+ /**
47
+ * Map a Java type to a JSON Schema type/format.
48
+ */
49
+ private javaTypeToJsonSchema;
50
+ /**
51
+ * Return a JSON Schema for a primitive/built-in type, or undefined if it's a complex type.
52
+ */
53
+ private primitiveSchema;
54
+ /**
55
+ * Map a Java type to an OpenAPI parameter type string.
56
+ */
57
+ static javaTypeToParamType(javaType: string): 'string' | 'integer' | 'number' | 'boolean' | 'array';
58
+ /**
59
+ * Map a Java type to an OpenAPI format string (or undefined).
60
+ */
61
+ static javaTypeToFormat(javaType: string): string | undefined;
62
+ private extractAttr;
63
+ private extractSingleArg;
64
+ private coerceValue;
65
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * API Discovery — Spring Provider
3
+ *
4
+ * Parses Spring Boot (Spring MVC) controllers from Java sources.
5
+ * Ported from `spring-api-tester` (controllerVisitor / endpointParser /
6
+ * schemaGenerator), with all vscode fs/workspace glue swapped onto node
7
+ * `fs`/`path` over concrete project roots (DECISIONS D2).
8
+ *
9
+ * `java-parser` is a heavy external dependency (~1 MB). It is loaded LAZILY:
10
+ * `supports()` stays cheap (build-file + controller-hint scan, no parser), and
11
+ * the AST parser module is `import()`'d only when `discover()` runs (D10).
12
+ */
13
+ import { ApiDiscoveryProvider, ProviderSupport } from '../provider';
14
+ import type { DiscoveryContext, DiscoveryResult, FrameworkFingerprint } from '../types';
15
+ export declare class SpringDiscoveryProvider implements ApiDiscoveryProvider {
16
+ readonly id = "provider.spring";
17
+ readonly framework: 'spring';
18
+ private parserModule?;
19
+ supports(fingerprint: FrameworkFingerprint): ProviderSupport;
20
+ discover(context: DiscoveryContext, fingerprint: FrameworkFingerprint): Promise<DiscoveryResult>;
21
+ clearCache(): void;
22
+ private loadParser;
23
+ private endpointToDiscoveredApi;
24
+ private buildParams;
25
+ private paramFromMeta;
26
+ private constraintsToSchema;
27
+ private buildRequestBody;
28
+ private buildResponses;
29
+ private maybeSchema;
30
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Shared utilities for resolving Spring type names and MediaType constants.
3
+ */
4
+ /**
5
+ * Resolve a `consumes` value to a MIME type string.
6
+ *
7
+ * Handles:
8
+ * - Already-resolved strings: `"application/json"` → returned as-is
9
+ * - MediaType constants: `MediaType.APPLICATION_JSON_VALUE` → `"application/json"`
10
+ * - Partial references: `APPLICATION_JSON_VALUE` → `"application/json"`
11
+ */
12
+ export declare function resolveMediaType(raw: string): string;
13
+ /**
14
+ * Resolve an array of consumes values, expanding MediaType constants.
15
+ */
16
+ export declare function resolveMediaTypes(values: string[]): string[];
17
+ /**
18
+ * If `typeName` is a known wrapper type (e.g. `HttpEntity<Foo>`), return
19
+ * the inner type (`Foo`). Otherwise return the original type unchanged.
20
+ */
21
+ export declare function unwrapBodyType(typeName: string): string;
22
+ /** Returns true if the type should be sent as raw text (not JSON). */
23
+ export declare function isRawTextType(typeName: string): boolean;
24
+ /** Returns true if the type should be sent as binary. */
25
+ export declare function isBinaryType(typeName: string): boolean;
26
+ /** Returns true if the type is a MultipartFile (file upload). */
27
+ export declare function isMultipartFileType(typeName: string): boolean;
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Phase 2a — Test generation (L4).
3
+ *
4
+ * Generates a runnable `.suite.json` (a `TestSuite`) from discovered endpoints.
5
+ * One request node per endpoint, each with a post-response script asserting the
6
+ * discovered status code. Generated artifacts are tagged `ai_generated: true`
7
+ * and `derived_from: <endpointId>` — the Phase 2b drift hook.
8
+ *
9
+ * Requests referenced by the suite must already exist in the target collection
10
+ * (created from the endpoint via `create_request_from_endpoint` semantics);
11
+ * this module only performs the discovery → suite mapping.
12
+ */
13
+ import { TestSuite } from '../test-suite/interfaces';
14
+ import type { DiscoveredApi } from './types';
15
+ /**
16
+ * Options for suite generation.
17
+ */
18
+ export interface GenerateSuiteOptions {
19
+ /** Collection name to reference from every suite request node. */
20
+ collectionName: string;
21
+ /** Collection id to reference from every suite request node. */
22
+ collectionId: string;
23
+ /** Base folder path within the collection where requests live (default ''). */
24
+ folderPath?: string;
25
+ /** Suite name (default: "Generated from discovery"). */
26
+ name?: string;
27
+ /** Suite id (default: deterministic from name). */
28
+ id?: string;
29
+ /** Also assert the response body schema when a JSON schema was discovered. */
30
+ assertBodySchema?: boolean;
31
+ }
32
+ /** Result of generation — the suite plus a mapping of which endpoints were included. */
33
+ export interface GenerateSuiteResult {
34
+ suite: TestSuite;
35
+ /** endpointId → generated request node name (the drift hook). */
36
+ derived: Array<{
37
+ endpointId: string;
38
+ requestName: string;
39
+ method: string;
40
+ path: string;
41
+ }>;
42
+ }
43
+ /** Deterministic suite id from a name (slug + short hash — no timestamps). */
44
+ export declare function suiteIdFromName(name: string): string;
45
+ /**
46
+ * Generate a TestSuite from discovered endpoints.
47
+ */
48
+ export declare function generateSuiteFromEndpoints(endpoints: DiscoveredApi[], options: GenerateSuiteOptions): GenerateSuiteResult;
49
+ /**
50
+ * Options for .flow.js generation.
51
+ */
52
+ export interface GenerateFlowOptions {
53
+ /**
54
+ * Maps a discovered endpoint to the request path/name that `f.send(...)`
55
+ * resolves in the collection (e.g. `users/get-user` or a request id).
56
+ * Defaults to `#<requestId>` when the endpoint id is a real collection
57
+ * request id, else falls back to the request name/symbol.
58
+ */
59
+ requestPathOf?: (ep: DiscoveredApi) => string;
60
+ /** Flow name used in the header comment (default derived from first endpoint). */
61
+ name?: string;
62
+ }
63
+ /**
64
+ * Generate a `.flow.js` source string from discovered endpoints using the
65
+ * `http-forge.flow` runtime API (`f.send` / `f.expect` / `f.set` / `f.get`).
66
+ * Every flow is tagged `ai_generated: true` + `derived_from: <endpointId>` in
67
+ * the header comment (the Phase 2b drift hook).
68
+ */
69
+ export declare function generateFlowFromEndpoints(endpoints: DiscoveredApi[], options: GenerateFlowOptions): string;