@http-forge/core 0.6.35 → 0.6.36-beta.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/README.md +51 -0
- package/dist/__tests__/api-discovery/golden-utils.d.ts +10 -0
- package/dist/index.d.ts +50 -23
- package/dist/index.js +456 -480
- package/dist/index.mjs +456 -480
- package/dist/infrastructure/ai/ai-context.d.ts +109 -0
- package/dist/infrastructure/ai/ai-provider.d.ts +1 -1
- package/dist/infrastructure/ai/ai-utils.d.ts +38 -0
- package/dist/infrastructure/ai/http-providers.d.ts +34 -0
- package/dist/infrastructure/api-discovery/analyzer/component-analyzer.d.ts +60 -0
- package/dist/infrastructure/api-discovery/analyzer/express-component-analyzer.d.ts +14 -0
- package/dist/infrastructure/api-discovery/analyzer/fastify-component-analyzer.d.ts +14 -0
- package/dist/infrastructure/api-discovery/analyzer/index.d.ts +11 -0
- package/dist/infrastructure/api-discovery/analyzer/lambda-component-analyzer.d.ts +18 -0
- package/dist/infrastructure/api-discovery/api-discovery-service.d.ts +49 -0
- package/dist/infrastructure/api-discovery/auth-validation.d.ts +34 -0
- package/dist/infrastructure/api-discovery/drift-engine.d.ts +139 -0
- package/dist/infrastructure/api-discovery/fastapi/fastapi-discovery-provider.d.ts +19 -0
- package/dist/infrastructure/api-discovery/fastapi/fastapi-parser.d.ts +60 -0
- package/dist/infrastructure/api-discovery/framework-detector.d.ts +8 -0
- package/dist/infrastructure/api-discovery/index.d.ts +29 -0
- package/dist/infrastructure/api-discovery/path-utils.d.ts +17 -0
- package/dist/infrastructure/api-discovery/project-name.d.ts +2 -0
- package/dist/infrastructure/api-discovery/provider.d.ts +29 -0
- package/dist/infrastructure/api-discovery/providers/express-discovery-provider.d.ts +13 -0
- package/dist/infrastructure/api-discovery/providers/fastify-discovery-provider.d.ts +13 -0
- package/dist/infrastructure/api-discovery/providers/lambda-discovery-provider.d.ts +19 -0
- package/dist/infrastructure/api-discovery/providers/nest-discovery-provider.d.ts +12 -0
- package/dist/infrastructure/api-discovery/seed-loader.d.ts +11 -0
- package/dist/infrastructure/api-discovery/source-files.d.ts +1 -0
- package/dist/infrastructure/api-discovery/spring/controller-visitor.d.ts +141 -0
- package/dist/infrastructure/api-discovery/spring/endpoint-parser.d.ts +51 -0
- package/dist/infrastructure/api-discovery/spring/file-utils.d.ts +28 -0
- package/dist/infrastructure/api-discovery/spring/model.d.ts +84 -0
- package/dist/infrastructure/api-discovery/spring/schema-generator.d.ts +65 -0
- package/dist/infrastructure/api-discovery/spring/spring-discovery-provider.d.ts +30 -0
- package/dist/infrastructure/api-discovery/spring/spring-types.d.ts +27 -0
- package/dist/infrastructure/api-discovery/test-generator.d.ts +69 -0
- package/dist/infrastructure/api-discovery/types.d.ts +154 -0
- package/dist/infrastructure/api-discovery/workflow-discovery.d.ts +55 -0
- package/dist/infrastructure/architect/api-architect-service.d.ts +85 -0
- package/dist/infrastructure/architect/architect-prompt.d.ts +22 -0
- package/dist/infrastructure/architect/collection-to-endpoints.d.ts +13 -0
- package/dist/infrastructure/architect/index.d.ts +10 -0
- package/dist/infrastructure/collection/collection-service.d.ts +1 -5
- package/dist/infrastructure/collection/json-collection-loader.d.ts +0 -8
- package/dist/infrastructure/config/config-service.d.ts +2 -1
- package/dist/infrastructure/config/config.interface.d.ts +17 -0
- package/dist/infrastructure/config/index.d.ts +1 -1
- package/dist/infrastructure/cookie/cookie-service.d.ts +2 -13
- package/dist/infrastructure/cookie/cookie-utils.d.ts +5 -0
- package/dist/infrastructure/docs/index.d.ts +5 -0
- package/dist/infrastructure/docs/release-notes.d.ts +51 -0
- package/dist/infrastructure/environment/environment-config-service.d.ts +0 -1
- package/dist/infrastructure/environment/variable-interpolator.d.ts +9 -0
- package/dist/infrastructure/http/header-utils.d.ts +13 -0
- package/dist/infrastructure/http/http-request-service.d.ts +3 -3
- package/dist/infrastructure/http/interceptor-chain.d.ts +35 -16
- package/dist/infrastructure/http/native-http-client.d.ts +0 -10
- package/dist/infrastructure/openapi/interfaces.d.ts +14 -0
- package/dist/infrastructure/openapi/openapi-exporter.d.ts +11 -91
- package/dist/infrastructure/openapi/openapi-importer.d.ts +19 -0
- package/dist/infrastructure/openapi/openapi-operation-builder.d.ts +36 -0
- package/dist/infrastructure/openapi/openapi-schema-merger.d.ts +33 -0
- package/dist/infrastructure/openapi/openapi-spec-writer.d.ts +27 -0
- package/dist/infrastructure/openapi/openapi-utils.d.ts +62 -0
- package/dist/infrastructure/parsers/har-parser.d.ts +63 -0
- package/dist/infrastructure/parsers/index.d.ts +2 -0
- package/dist/infrastructure/review/index.d.ts +5 -0
- package/dist/infrastructure/review/review-engine.d.ts +95 -0
- package/dist/infrastructure/script/crypto-js-compat.d.ts +123 -0
- package/dist/infrastructure/script/request-object-factory.d.ts +54 -0
- package/dist/infrastructure/script/request-script-session.d.ts +0 -5
- package/dist/infrastructure/script/script-executor.d.ts +4 -33
- package/dist/infrastructure/script/script-factories.d.ts +13 -0
- package/dist/infrastructure/script/variable-scopes.d.ts +101 -0
- package/dist/infrastructure/test-suite/interfaces.d.ts +6 -0
- package/dist/runtime/collection-traversal.d.ts +32 -0
- package/dist/runtime/direct-execution.d.ts +7 -0
- package/dist/runtime/execution-helpers.d.ts +30 -0
- package/dist/runtime/mcp-dispatcher.d.ts +10 -34
- package/dist/runtime/mcp-handlers/ai.d.ts +6 -0
- package/dist/runtime/mcp-handlers/collection.d.ts +5 -0
- package/dist/runtime/mcp-handlers/discovery.d.ts +12 -0
- package/dist/runtime/mcp-handlers/environment-management.d.ts +6 -0
- package/dist/runtime/mcp-handlers/environment.d.ts +5 -0
- package/dist/runtime/mcp-handlers/execution.d.ts +6 -0
- package/dist/runtime/mcp-handlers/helpers.d.ts +43 -0
- package/dist/runtime/mcp-handlers/inspection.d.ts +5 -0
- package/dist/runtime/mcp-handlers/registry.d.ts +12 -0
- package/dist/runtime/mcp-handlers/request.d.ts +5 -0
- package/dist/runtime/mcp-handlers/review.d.ts +10 -0
- package/dist/runtime/mcp-handlers/run-status.d.ts +5 -0
- package/dist/runtime/mcp-handlers/suite.d.ts +6 -0
- package/dist/runtime/mcp-handlers/types.d.ts +59 -0
- package/dist/runtime/mcp-prompts.d.ts +16 -2
- package/dist/runtime/mcp-tool-schemas.d.ts +8 -0
- package/dist/runtime/suite-executor.d.ts +20 -0
- package/dist/types/types.d.ts +0 -9
- package/dist/utils/env-hints.d.ts +17 -0
- package/package.json +16 -6
|
@@ -98,11 +98,12 @@ export interface IErrorInterceptor {
|
|
|
98
98
|
handle(error: Error, request: HttpRequest, context: InterceptorContext): Promise<HttpResponse | void> | HttpResponse | void;
|
|
99
99
|
}
|
|
100
100
|
/**
|
|
101
|
-
* Interceptor
|
|
102
|
-
*
|
|
103
|
-
*
|
|
101
|
+
* Interceptor registry interface
|
|
102
|
+
* Defines the contract for managing registered interceptors.
|
|
103
|
+
* Consumers that only register/interrogate interceptors depend on this
|
|
104
|
+
* narrow interface instead of the full chain.
|
|
104
105
|
*/
|
|
105
|
-
export interface
|
|
106
|
+
export interface IInterceptorRegistry {
|
|
106
107
|
/**
|
|
107
108
|
* Register a request interceptor
|
|
108
109
|
*/
|
|
@@ -127,18 +128,6 @@ export interface IInterceptorChain {
|
|
|
127
128
|
* Remove an error interceptor by name
|
|
128
129
|
*/
|
|
129
130
|
removeErrorInterceptor(name: string): boolean;
|
|
130
|
-
/**
|
|
131
|
-
* Execute request interceptors
|
|
132
|
-
*/
|
|
133
|
-
executeRequestInterceptors(request: HttpRequest, context: InterceptorContext): Promise<HttpRequest>;
|
|
134
|
-
/**
|
|
135
|
-
* Execute response interceptors
|
|
136
|
-
*/
|
|
137
|
-
executeResponseInterceptors(response: HttpResponse, request: HttpRequest, context: InterceptorContext): Promise<HttpResponse>;
|
|
138
|
-
/**
|
|
139
|
-
* Execute error interceptors
|
|
140
|
-
*/
|
|
141
|
-
executeErrorInterceptors(error: Error, request: HttpRequest, context: InterceptorContext): Promise<HttpResponse | undefined>;
|
|
142
131
|
/**
|
|
143
132
|
* Clear all interceptors
|
|
144
133
|
*/
|
|
@@ -152,6 +141,36 @@ export interface IInterceptorChain {
|
|
|
152
141
|
error: string[];
|
|
153
142
|
};
|
|
154
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* Interceptor executor interface
|
|
146
|
+
* Defines the contract for running the interceptor pipeline.
|
|
147
|
+
* Consumers that only execute interceptors depend on this narrow interface
|
|
148
|
+
* instead of the full chain.
|
|
149
|
+
*/
|
|
150
|
+
export interface IInterceptorExecutor {
|
|
151
|
+
/**
|
|
152
|
+
* Execute request interceptors
|
|
153
|
+
*/
|
|
154
|
+
executeRequestInterceptors(request: HttpRequest, context: InterceptorContext): Promise<HttpRequest>;
|
|
155
|
+
/**
|
|
156
|
+
* Execute response interceptors
|
|
157
|
+
*/
|
|
158
|
+
executeResponseInterceptors(response: HttpResponse, request: HttpRequest, context: InterceptorContext): Promise<HttpResponse>;
|
|
159
|
+
/**
|
|
160
|
+
* Execute error interceptors
|
|
161
|
+
*/
|
|
162
|
+
executeErrorInterceptors(error: Error, request: HttpRequest, context: InterceptorContext): Promise<HttpResponse | undefined>;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Interceptor chain interface
|
|
166
|
+
* Same as plugin's IInterceptorChain
|
|
167
|
+
* Defines the full contract for managing and executing interceptors.
|
|
168
|
+
* Segregated into IInterceptorRegistry (management) and
|
|
169
|
+
* IInterceptorExecutor (execution); this type composes both so existing
|
|
170
|
+
* consumers keep a single, complete dependency.
|
|
171
|
+
*/
|
|
172
|
+
export interface IInterceptorChain extends IInterceptorRegistry, IInterceptorExecutor {
|
|
173
|
+
}
|
|
155
174
|
/**
|
|
156
175
|
* Interceptor chain manager
|
|
157
176
|
* Same implementation as plugin's InterceptorChain class
|
|
@@ -80,16 +80,6 @@ export declare class NodeHttpClient implements IHttpClient {
|
|
|
80
80
|
private findCertificateMapping;
|
|
81
81
|
private mappingMatchesHost;
|
|
82
82
|
private readOptionalFile;
|
|
83
|
-
/**
|
|
84
|
-
* Sanitize header value to remove/replace invalid characters
|
|
85
|
-
* Same implementation as plugin's RequestPreprocessor.sanitizeHeaderValue
|
|
86
|
-
*/
|
|
87
|
-
private sanitizeHeaderValue;
|
|
88
|
-
/**
|
|
89
|
-
* Sanitize all headers
|
|
90
|
-
* Same implementation as plugin's RequestPreprocessor.sanitizeHeaders
|
|
91
|
-
*/
|
|
92
|
-
private sanitizeHeaders;
|
|
93
83
|
/**
|
|
94
84
|
* Parse Set-Cookie headers into structured objects
|
|
95
85
|
* Same implementation as plugin's HttpRequestService.parseCookies
|
|
@@ -32,6 +32,20 @@ export interface IOpenApiImporter {
|
|
|
32
32
|
collection: Collection;
|
|
33
33
|
environmentCreated?: string;
|
|
34
34
|
}>;
|
|
35
|
+
/**
|
|
36
|
+
* Import an OpenAPI spec fetched from a URL.
|
|
37
|
+
*/
|
|
38
|
+
importFromUrl(url: string, options?: OpenApiImportOptions): Promise<{
|
|
39
|
+
collection: Collection;
|
|
40
|
+
environmentCreated?: string;
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* Import an OpenAPI spec from an in-memory string (JSON or YAML).
|
|
44
|
+
*/
|
|
45
|
+
importFromString(rawContent: string, options?: OpenApiImportOptions): Promise<{
|
|
46
|
+
collection: Collection;
|
|
47
|
+
environmentCreated?: string;
|
|
48
|
+
}>;
|
|
35
49
|
}
|
|
36
50
|
/**
|
|
37
51
|
* Schema inferrer interface (low-level)
|
|
@@ -3,28 +3,25 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Generates a valid OpenAPI 3.0.3 document from an HTTP Forge collection.
|
|
5
5
|
* Implements all mapping rules per the solution document §4.3.2.
|
|
6
|
+
*
|
|
7
|
+
* Orchestrates the export pipeline across focused collaborators:
|
|
8
|
+
* - OpenApiOperationBuilder: request → operation mapping
|
|
9
|
+
* - OpenApiSchemaMerger: reconciliation of colliding path+method variants
|
|
10
|
+
* - OpenApiSpecWriter: component deduplication, finalization, serialization
|
|
11
|
+
* - openapi-utils: pure mapping helpers
|
|
6
12
|
*/
|
|
7
13
|
import { ICollectionService } from '../../types/collection';
|
|
8
14
|
import { IEnvironmentConfigService } from '../../types/environment-config';
|
|
9
15
|
import { SchemaInferenceService } from './schema-inference-service';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
/** Environment name(s) to use for server URL resolution */
|
|
13
|
-
environments?: string[];
|
|
14
|
-
/** Include inferred response schemas from history */
|
|
15
|
-
inferFromHistory?: boolean;
|
|
16
|
-
/** OpenAPI info metadata overrides */
|
|
17
|
-
info?: {
|
|
18
|
-
title?: string;
|
|
19
|
-
version?: string;
|
|
20
|
-
description?: string;
|
|
21
|
-
};
|
|
22
|
-
}
|
|
16
|
+
import { OpenApiExportOptions } from './openapi-utils';
|
|
17
|
+
export type { OpenApiExportOptions } from './openapi-utils';
|
|
23
18
|
export declare class OpenApiExporter {
|
|
24
19
|
private collectionService;
|
|
25
20
|
private envConfigService;
|
|
26
21
|
private inferenceService;
|
|
27
|
-
private
|
|
22
|
+
private readonly merger;
|
|
23
|
+
private readonly operationBuilder;
|
|
24
|
+
private readonly specWriter;
|
|
28
25
|
constructor(collectionService: ICollectionService, envConfigService: IEnvironmentConfigService, inferenceService: SchemaInferenceService);
|
|
29
26
|
/**
|
|
30
27
|
* Export a collection as an OpenAPI 3.0.3 document.
|
|
@@ -34,83 +31,6 @@ export declare class OpenApiExporter {
|
|
|
34
31
|
private buildServers;
|
|
35
32
|
private processItems;
|
|
36
33
|
private processRequest;
|
|
37
|
-
/**
|
|
38
|
-
* Merge a new operation into an existing one at the same path+method.
|
|
39
|
-
* - Parameters: union enum values for same-name params; append new params
|
|
40
|
-
* - Description: append the variant name
|
|
41
|
-
* - Tags: union
|
|
42
|
-
* - Responses: merge (new status codes added, existing kept)
|
|
43
|
-
*/
|
|
44
|
-
private mergeOperation;
|
|
45
|
-
/**
|
|
46
|
-
* Merge parameter schemas when the same parameter appears in colliding operations.
|
|
47
|
-
*
|
|
48
|
-
* Strategy: if both variants use the SAME constraint kind (both enum, both pattern,
|
|
49
|
-
* both numeric range, etc.) they are merged in-place (union enum, widen range, etc.).
|
|
50
|
-
* If they use DIFFERENT constraint kinds the schemas are incompatible,
|
|
51
|
-
* so we wrap them in `oneOf` — each variant keeps its own self-consistent schema.
|
|
52
|
-
*
|
|
53
|
-
* Description and examples are always accumulated.
|
|
54
|
-
*/
|
|
55
|
-
private mergeParameterSchema;
|
|
56
|
-
/** Identify the primary constraint kind of a schema. */
|
|
57
|
-
private getConstraintKind;
|
|
58
|
-
/** Merge constraints when both schemas use the same kind. */
|
|
59
|
-
private mergeSameKindConstraints;
|
|
60
|
-
/** Build a self-contained variant schema from constraint properties. */
|
|
61
|
-
private buildVariantSchema;
|
|
62
|
-
/** Remove constraint properties from a schema (keeps type, oneOf, etc.). */
|
|
63
|
-
private stripConstraints;
|
|
64
|
-
/** Extract constraint properties from a schema into a new object. */
|
|
65
|
-
private extractConstraints;
|
|
66
|
-
/** Widen the type field if the incoming type differs. */
|
|
67
|
-
private widenType;
|
|
68
|
-
private normalizeUrl;
|
|
69
|
-
private generateOperationId;
|
|
70
|
-
private collectOperationIds;
|
|
71
|
-
private toCamelCase;
|
|
72
|
-
private buildParameters;
|
|
73
|
-
private buildKeyValueParam;
|
|
74
|
-
/**
|
|
75
|
-
* Parse a Cookie header value into individual in:cookie parameters.
|
|
76
|
-
*/
|
|
77
|
-
private parseCookieHeader;
|
|
78
|
-
/**
|
|
79
|
-
* Infer a type from a string value (for path/query params without explicit type).
|
|
80
|
-
*/
|
|
81
|
-
private inferTypeFromValue;
|
|
82
|
-
/**
|
|
83
|
-
* Coerce a string value to the appropriate JS type for the 'example' field.
|
|
84
|
-
* Sanitizes {{varName}} placeholders to <varName> before coercion.
|
|
85
|
-
*/
|
|
86
|
-
private coerceExample;
|
|
87
|
-
/** Replace {{varName}} placeholders with <varName> so they don't appear raw in examples. */
|
|
88
|
-
private sanitizeEnvVar;
|
|
89
|
-
/** Recursively sanitize {{varName}} placeholders in string values of a parsed example object. */
|
|
90
|
-
private sanitizeObjectExamples;
|
|
91
|
-
private buildRequestBody;
|
|
92
|
-
private getContentType;
|
|
93
|
-
private tryParseBodyContent;
|
|
94
|
-
private buildFormDataSchemaFromBody;
|
|
95
|
-
private buildResponses;
|
|
96
|
-
/**
|
|
97
|
-
* Map operation-level response definitions (from metadata) to OpenAPI format.
|
|
98
|
-
* Converts OperationResponse[] indexed by status code into OpenAPI responses object.
|
|
99
|
-
*/
|
|
100
|
-
private mapResponseDefinitions;
|
|
101
|
-
private buildOperationSecurity;
|
|
102
|
-
private mapAuthToSecurityScheme;
|
|
103
|
-
private parseScopes;
|
|
104
|
-
/**
|
|
105
|
-
* When multiple operations share structurally identical schemas,
|
|
106
|
-
* promote them to components/schemas and replace with $ref.
|
|
107
|
-
*/
|
|
108
|
-
private deduplicateComponents;
|
|
109
|
-
private trackSchema;
|
|
110
|
-
private replaceInlineSchema;
|
|
111
|
-
private sanitizeComponentName;
|
|
112
|
-
private cleanSummary;
|
|
113
|
-
private hasDeprecatedPrefix;
|
|
114
34
|
/**
|
|
115
35
|
* For each host variable found in request URLs (e.g. {{dcqHost}}),
|
|
116
36
|
* attempt to resolve it from the configured environments and add it
|
|
@@ -25,6 +25,25 @@ export declare class OpenApiImporter {
|
|
|
25
25
|
collection: Collection;
|
|
26
26
|
environmentCreated?: string;
|
|
27
27
|
}>;
|
|
28
|
+
/**
|
|
29
|
+
* Import an OpenAPI spec fetched from a URL (e.g. a public schema endpoint
|
|
30
|
+
* or an OpenAPI-introspection endpoint). Uses the Node 18+ global `fetch`.
|
|
31
|
+
*/
|
|
32
|
+
importFromUrl(url: string, options?: OpenApiImportOptions): Promise<{
|
|
33
|
+
collection: Collection;
|
|
34
|
+
environmentCreated?: string;
|
|
35
|
+
}>;
|
|
36
|
+
/**
|
|
37
|
+
* Import an OpenAPI spec from an in-memory string (JSON or YAML).
|
|
38
|
+
*/
|
|
39
|
+
importFromString(rawContent: string, options?: OpenApiImportOptions): Promise<{
|
|
40
|
+
collection: Collection;
|
|
41
|
+
environmentCreated?: string;
|
|
42
|
+
}>;
|
|
43
|
+
/** Parse YAML/JSON raw content into a spec object (format-inferred). */
|
|
44
|
+
private parseSpec;
|
|
45
|
+
/** Shared import path after the spec object has been produced. */
|
|
46
|
+
private importFromSpec;
|
|
28
47
|
private processOperation;
|
|
29
48
|
/**
|
|
30
49
|
* Convert OpenAPI path parameters from {param} to :param syntax.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAPI export — request → operation mapping.
|
|
3
|
+
*
|
|
4
|
+
* Maps a single collection request (params, query, headers, body, responses,
|
|
5
|
+
* auth) into an OpenAPI operation object. Pure with respect to the returned
|
|
6
|
+
* operation; mutation of shared export state (tags, securitySchemes) is
|
|
7
|
+
* performed through the explicitly-passed collections.
|
|
8
|
+
*/
|
|
9
|
+
import { Collection, CollectionRequestItem } from '../../types/collection';
|
|
10
|
+
import { RequestAuth } from '../../types/types';
|
|
11
|
+
import { SchemaInferrer } from './schema-inferrer';
|
|
12
|
+
import { OpenApiExportOptions } from './openapi-utils';
|
|
13
|
+
export declare class OpenApiOperationBuilder {
|
|
14
|
+
private inferrer;
|
|
15
|
+
constructor(inferrer: SchemaInferrer);
|
|
16
|
+
/**
|
|
17
|
+
* Build a single OpenAPI operation from a collection request.
|
|
18
|
+
* Registers any discovered security schemes / tags into the shared maps.
|
|
19
|
+
*/
|
|
20
|
+
buildOperation(request: CollectionRequestItem, method: string, path: string, spec: any, securitySchemes: Map<string, any>, tags: Set<string>, parentTag: string | undefined, collection: Collection, options: OpenApiExportOptions): Promise<any>;
|
|
21
|
+
private generateOperationId;
|
|
22
|
+
private collectOperationIds;
|
|
23
|
+
private buildRequestBody;
|
|
24
|
+
private buildResponses;
|
|
25
|
+
/**
|
|
26
|
+
* Map operation-level response definitions (from metadata) to OpenAPI format.
|
|
27
|
+
* Converts OperationResponse[] indexed by status code into OpenAPI responses object.
|
|
28
|
+
*/
|
|
29
|
+
private mapResponseDefinitions;
|
|
30
|
+
private buildOperationSecurity;
|
|
31
|
+
mapAuthToSecurityScheme(auth: RequestAuth): {
|
|
32
|
+
schemeName: string;
|
|
33
|
+
scheme: any;
|
|
34
|
+
requirement: any;
|
|
35
|
+
} | undefined;
|
|
36
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare class OpenApiSchemaMerger {
|
|
2
|
+
/**
|
|
3
|
+
* Merge a new operation into an existing one at the same path+method.
|
|
4
|
+
* - Parameters: union enum values for same-name params; append new params
|
|
5
|
+
* - Description: append the variant name
|
|
6
|
+
* - Tags: union
|
|
7
|
+
* - Responses: merge (new status codes added, existing kept)
|
|
8
|
+
*/
|
|
9
|
+
mergeOperation(existing: any, incoming: any, incomingName: string): void;
|
|
10
|
+
/**
|
|
11
|
+
* Merge parameter schemas when the same parameter appears in colliding operations.
|
|
12
|
+
*
|
|
13
|
+
* Strategy: if both variants use the SAME constraint kind (both enum, both pattern,
|
|
14
|
+
* both numeric range, etc.) they are merged in-place (union enum, widen range, etc.).
|
|
15
|
+
* If they use DIFFERENT constraint kinds the schemas are incompatible,
|
|
16
|
+
* so we wrap them in `oneOf` — each variant keeps its own self-consistent schema.
|
|
17
|
+
*
|
|
18
|
+
* Description and examples are always accumulated.
|
|
19
|
+
*/
|
|
20
|
+
mergeParameterSchema(existing: any, incoming: any, variantName: string): void;
|
|
21
|
+
/** Identify the primary constraint kind of a schema. */
|
|
22
|
+
getConstraintKind(schema: any): 'enum' | 'pattern' | 'range' | 'length' | 'format' | 'oneOf' | 'array' | 'none';
|
|
23
|
+
/** Merge constraints when both schemas use the same kind. */
|
|
24
|
+
mergeSameKindConstraints(es: any, is: any, kind: string): void;
|
|
25
|
+
/** Build a self-contained variant schema from constraint properties. */
|
|
26
|
+
buildVariantSchema(schema: any): any;
|
|
27
|
+
/** Remove constraint properties from a schema (keeps type, oneOf, etc.). */
|
|
28
|
+
stripConstraints(schema: any): void;
|
|
29
|
+
/** Extract constraint properties from a schema into a new object. */
|
|
30
|
+
extractConstraints(schema: any): any;
|
|
31
|
+
/** Widen the type field if the incoming type differs. */
|
|
32
|
+
widenType(es: any, is: any): void;
|
|
33
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAPI export — spec finalization and serialization.
|
|
3
|
+
*
|
|
4
|
+
* Post-processes a fully-populated OpenAPI document:
|
|
5
|
+
* - promotes structurally-identical inline schemas into components/schemas
|
|
6
|
+
* - installs collected security schemes and tags
|
|
7
|
+
* - removes empty component sections
|
|
8
|
+
* - serializes to JSON or YAML
|
|
9
|
+
*
|
|
10
|
+
* Stateless and pure with respect to its inputs (mutating only the `spec`
|
|
11
|
+
* object it is given to finalize).
|
|
12
|
+
*/
|
|
13
|
+
import { OpenApiExportOptions } from './openapi-utils';
|
|
14
|
+
export declare class OpenApiSpecWriter {
|
|
15
|
+
/**
|
|
16
|
+
* Finalize the collected spec state into a serialized document string.
|
|
17
|
+
*/
|
|
18
|
+
finalize(spec: any, securitySchemes: Map<string, any>, tags: Set<string>, options: OpenApiExportOptions): string;
|
|
19
|
+
/**
|
|
20
|
+
* When multiple operations share structurally identical schemas,
|
|
21
|
+
* promote them to components/schemas and replace with $ref.
|
|
22
|
+
*/
|
|
23
|
+
private deduplicateComponents;
|
|
24
|
+
private trackSchema;
|
|
25
|
+
private replaceInlineSchema;
|
|
26
|
+
private sanitizeComponentName;
|
|
27
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAPI export — pure mapping helpers.
|
|
3
|
+
*
|
|
4
|
+
* Stateless functions shared by the operation builder (URL normalization,
|
|
5
|
+
* type/example coercion, request body parsing, key-value params, cookie
|
|
6
|
+
* parsing, operation-id casing). Kept free of class state so they are trivial
|
|
7
|
+
* to unit-test and reuse.
|
|
8
|
+
*/
|
|
9
|
+
import type { CollectionRequestItem } from '../../types/collection';
|
|
10
|
+
import type { JSONSchema7, KeyValueEntry } from '../../types/types';
|
|
11
|
+
export interface OpenApiExportOptions {
|
|
12
|
+
format: 'json' | 'yaml';
|
|
13
|
+
/** Environment name(s) to use for server URL resolution */
|
|
14
|
+
environments?: string[];
|
|
15
|
+
/** Include inferred response schemas from history */
|
|
16
|
+
inferFromHistory?: boolean;
|
|
17
|
+
/** OpenAPI info metadata overrides */
|
|
18
|
+
info?: {
|
|
19
|
+
title?: string;
|
|
20
|
+
version?: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/** Headers excluded from 'in: header' parameters on export */
|
|
25
|
+
export declare const EXCLUDED_HEADERS: Set<string>;
|
|
26
|
+
/** Normalize a collection request URL into an OpenAPI path + optional host var. */
|
|
27
|
+
export declare function normalizeUrl(url: string): {
|
|
28
|
+
path: string;
|
|
29
|
+
hostVar: string | null;
|
|
30
|
+
};
|
|
31
|
+
/** Infer a JSON schema type from a primitive string value. */
|
|
32
|
+
export declare function inferTypeFromValue(value: string): string;
|
|
33
|
+
/** Widen the numeric type pair 'integer'/'number' to 'number'. Returns 'number' or undefined. */
|
|
34
|
+
export declare function widenNumericType(a: string | undefined, b: string | undefined): string | undefined;
|
|
35
|
+
/** Replace {{varName}} placeholders with <varName> so they don't appear raw in examples. */
|
|
36
|
+
export declare function sanitizeEnvVar(value: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Coerce a string value to the appropriate JS type for the 'example' field.
|
|
39
|
+
* Sanitizes {{varName}} placeholders to <varName> before coercion.
|
|
40
|
+
*/
|
|
41
|
+
export declare function coerceExample(value: string, type: string): any;
|
|
42
|
+
/** Recursively sanitize {{varName}} placeholders in string values of a parsed example object. */
|
|
43
|
+
export declare function sanitizeObjectExamples(value: any): any;
|
|
44
|
+
/** Try to parse a request body's content into structured data (sanitized). */
|
|
45
|
+
export declare function tryParseBodyContent(body: any): any;
|
|
46
|
+
/** Map a request body's type/format to an OpenAPI content type. */
|
|
47
|
+
export declare function getContentType(body: any): string;
|
|
48
|
+
/** Build an object schema from form-data / urlencoded entries. */
|
|
49
|
+
export declare function buildFormDataSchemaFromBody(body: any): JSONSchema7;
|
|
50
|
+
/** Build a query/header parameter object from a key-value entry. */
|
|
51
|
+
export declare function buildKeyValueParam(entry: KeyValueEntry, location: 'query' | 'header'): any;
|
|
52
|
+
/** Parse a Cookie header value into individual in:cookie parameters. */
|
|
53
|
+
export declare function parseCookieHeader(value: string): any[];
|
|
54
|
+
/** Build an OpenAPI path/query/header/cookie parameter list from a request. */
|
|
55
|
+
export declare function buildParameters(request: CollectionRequestItem): any[];
|
|
56
|
+
/** camelCase a request name for use as an OpenAPI operationId. */
|
|
57
|
+
export declare function toCamelCase(str: string): string;
|
|
58
|
+
/** Strip a [DEPRECATED] prefix from a request name. */
|
|
59
|
+
export declare function cleanSummary(name: string): string;
|
|
60
|
+
export declare function hasDeprecatedPrefix(name: string): boolean;
|
|
61
|
+
/** Parse a whitespace-separated OAuth2 scope string into a scope map. */
|
|
62
|
+
export declare function parseScopes(scopeStr: string): Record<string, string>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HAR (HTTP Archive) Parser
|
|
3
|
+
*
|
|
4
|
+
* Parses a HAR 1.2 archive into HTTP Forge requests. Extracts method, URL,
|
|
5
|
+
* headers, query params, cookies, postData body, and a response-time hint from
|
|
6
|
+
* each `log.entries[]` network transaction.
|
|
7
|
+
*
|
|
8
|
+
* Platform-independent: pure string/JSON handling, no Node.js or VS Code dep.
|
|
9
|
+
*/
|
|
10
|
+
import type { RequestBody, UnifiedCollection } from '../../types/types';
|
|
11
|
+
/** Structured representation of a single HAR entry converted to a request. */
|
|
12
|
+
export interface ParsedHarRequest {
|
|
13
|
+
name: string;
|
|
14
|
+
method: string;
|
|
15
|
+
url: string;
|
|
16
|
+
headers: Array<{
|
|
17
|
+
key: string;
|
|
18
|
+
value: string;
|
|
19
|
+
enabled: boolean;
|
|
20
|
+
}>;
|
|
21
|
+
query: Array<{
|
|
22
|
+
key: string;
|
|
23
|
+
value: string;
|
|
24
|
+
enabled: boolean;
|
|
25
|
+
}>;
|
|
26
|
+
cookies: Array<{
|
|
27
|
+
key: string;
|
|
28
|
+
value: string;
|
|
29
|
+
enabled: boolean;
|
|
30
|
+
}>;
|
|
31
|
+
/** Parsed postData body, or null when no body is present. */
|
|
32
|
+
body: RequestBody | null;
|
|
33
|
+
/** Observed response status from the HAR entry (if any). */
|
|
34
|
+
responseStatus?: number;
|
|
35
|
+
/** Observed response time in ms (if any). */
|
|
36
|
+
responseTimeMs?: number;
|
|
37
|
+
/** HAR content type of the response body (if any). */
|
|
38
|
+
responseContentType?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface HarImportOptions {
|
|
41
|
+
/** Collection name override (default: "Imported from HAR"). */
|
|
42
|
+
collectionName?: string;
|
|
43
|
+
/** Skip entries that failed (HTTP 4xx/5xx). Default: false. */
|
|
44
|
+
skipFailed?: boolean;
|
|
45
|
+
/** Only include entries whose URL hostname matches this value. */
|
|
46
|
+
filterHost?: string;
|
|
47
|
+
}
|
|
48
|
+
/** Data extracted from a parsed HAR body, when it looks like JSON. */
|
|
49
|
+
export interface HarJsonBody {
|
|
50
|
+
parsed: unknown;
|
|
51
|
+
text: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Parse a HAR archive (as an object or a JSON string) into HTTP Forge
|
|
55
|
+
* requests. Returns the flattened requests and a unified collection with the
|
|
56
|
+
* entries grouped by top-level hostname folders.
|
|
57
|
+
*/
|
|
58
|
+
export declare function parseHar(har: string | Record<string, any>, options?: HarImportOptions): {
|
|
59
|
+
requests: ParsedHarRequest[];
|
|
60
|
+
collection: UnifiedCollection;
|
|
61
|
+
};
|
|
62
|
+
/** Parse a HAR archive's entry list into a unified collection directly. */
|
|
63
|
+
export declare function harToCollection(har: string | Record<string, any>, options?: HarImportOptions): UnifiedCollection;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Review Engine
|
|
3
|
+
*
|
|
4
|
+
* Single Responsibility: Run the deterministic review rules over a suite +
|
|
5
|
+
* run-results pair (Phase 3, Layer 7) and produce a structured ReviewReport.
|
|
6
|
+
*
|
|
7
|
+
* Determinism contract (from the plan): rules are pure, repeatable functions —
|
|
8
|
+
* the same suite + run-results always yield the same findings. This is what
|
|
9
|
+
* makes the review gate CI-usable (a reviewer that depends on an LLM is
|
|
10
|
+
* non-deterministic and unreviewable). An LLM may ENRICH the report later
|
|
11
|
+
* (see mcp-prompts buildReviewSuitePrompt), but it never IS the rules.
|
|
12
|
+
*
|
|
13
|
+
* The engine deliberately has zero `vscode` imports and depends only on the
|
|
14
|
+
* normalized inputs below so CLI/MCP/CI all share the same implementation.
|
|
15
|
+
*/
|
|
16
|
+
import type { TestSuite } from '../test-suite/interfaces';
|
|
17
|
+
export type ReviewSeverity = 'error' | 'warn' | 'info';
|
|
18
|
+
/**
|
|
19
|
+
* A single request-level result. The run stores use `responseStatus` on failed
|
|
20
|
+
* results and `status` elsewhere, and may split failed tests into `failedTests`,
|
|
21
|
+
* so both shapes are accepted and normalized here.
|
|
22
|
+
*/
|
|
23
|
+
export interface ReviewRequestResult {
|
|
24
|
+
name: string;
|
|
25
|
+
method?: string;
|
|
26
|
+
url?: string;
|
|
27
|
+
/** Numeric HTTP status (accepts either storage shape). */
|
|
28
|
+
status?: number;
|
|
29
|
+
responseStatus?: number;
|
|
30
|
+
/** Raw response body (string or parsed). */
|
|
31
|
+
body?: unknown;
|
|
32
|
+
requestBody?: unknown;
|
|
33
|
+
/** Transport/script-level error (request never produced a response). */
|
|
34
|
+
error?: string;
|
|
35
|
+
/** Response time in milliseconds. */
|
|
36
|
+
duration?: number;
|
|
37
|
+
assertions?: Array<{
|
|
38
|
+
name: string;
|
|
39
|
+
passed: boolean;
|
|
40
|
+
message?: string;
|
|
41
|
+
}>;
|
|
42
|
+
/** Alternative shape used by direct-execution failed results. */
|
|
43
|
+
failedTests?: Array<{
|
|
44
|
+
name: string;
|
|
45
|
+
message?: string;
|
|
46
|
+
}>;
|
|
47
|
+
}
|
|
48
|
+
export interface ReviewFinding {
|
|
49
|
+
/** Stable rule id (used by CI gates and the LLM-enrichment step). */
|
|
50
|
+
rule: string;
|
|
51
|
+
severity: ReviewSeverity;
|
|
52
|
+
/** Short headline, safe to render as a list item. */
|
|
53
|
+
title: string;
|
|
54
|
+
/** Human-readable detail. */
|
|
55
|
+
message: string;
|
|
56
|
+
/** The affected request, when the finding is request-scoped. */
|
|
57
|
+
requestName?: string;
|
|
58
|
+
/** Concrete remediation, when known. */
|
|
59
|
+
suggestion?: string;
|
|
60
|
+
}
|
|
61
|
+
export interface ReviewOptions {
|
|
62
|
+
/** Responses slower than this (ms) are flagged slow-response. Default 2000. */
|
|
63
|
+
slowResponseMs?: number;
|
|
64
|
+
/** When a request has no assertions, skip the missing-assertions warning. */
|
|
65
|
+
allowNoAssertions?: boolean;
|
|
66
|
+
}
|
|
67
|
+
export interface ReviewReport {
|
|
68
|
+
suiteId?: string;
|
|
69
|
+
suiteName?: string;
|
|
70
|
+
runId?: string;
|
|
71
|
+
generatedAt: number;
|
|
72
|
+
summary: {
|
|
73
|
+
errors: number;
|
|
74
|
+
warnings: number;
|
|
75
|
+
infos: number;
|
|
76
|
+
total: number;
|
|
77
|
+
pass: boolean;
|
|
78
|
+
};
|
|
79
|
+
findings: ReviewFinding[];
|
|
80
|
+
rulesRun: string[];
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Review a suite run: run every deterministic rule over the normalized
|
|
84
|
+
* request results and summarize into a ReviewReport.
|
|
85
|
+
*
|
|
86
|
+
* `suite` is optional — run-results alone produce a valid review. When
|
|
87
|
+
* provided, its id/name are carried into the report and its request nodes are
|
|
88
|
+
* used to annotate assertion coverage (see `annotateSuiteCoverage`).
|
|
89
|
+
*/
|
|
90
|
+
export declare function reviewSuiteRun(suite: TestSuite | undefined, results: ReviewRequestResult[], options?: ReviewOptions): ReviewReport;
|
|
91
|
+
/**
|
|
92
|
+
* Normalize an McpRunRecord-style run into ReviewRequestResult[].
|
|
93
|
+
* Accepts both a full record ({ allResults }) and a bare array.
|
|
94
|
+
*/
|
|
95
|
+
export declare function toReviewRequestResults(run: unknown): ReviewRequestResult[];
|