@http-forge/core 0.6.1 → 0.6.2-2.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 (39) hide show
  1. package/README.md +223 -251
  2. package/dist/di/platform-adapters.d.ts +11 -4
  3. package/dist/index.d.ts +13 -2
  4. package/dist/index.js +497 -283
  5. package/dist/index.mjs +496 -282
  6. package/dist/infrastructure/ai/ai-provider.d.ts +16 -0
  7. package/dist/infrastructure/analysis/ai-env-suggester.d.ts +22 -0
  8. package/dist/infrastructure/analysis/collection-enhancer.d.ts +23 -0
  9. package/dist/infrastructure/analysis/env-suggester.d.ts +57 -0
  10. package/dist/infrastructure/collection/collection-store.d.ts +1 -1
  11. package/dist/infrastructure/config/config-service.d.ts +20 -1
  12. package/dist/infrastructure/config/config.interface.d.ts +26 -2
  13. package/dist/infrastructure/config/default-config.d.ts +4 -2
  14. package/dist/infrastructure/environment/environment-config-service.d.ts +2 -1
  15. package/dist/infrastructure/execution/collection-request-executor.d.ts +3 -2
  16. package/dist/infrastructure/execution/request-executor.d.ts +5 -0
  17. package/dist/infrastructure/execution/request-preparer.d.ts +1 -0
  18. package/dist/infrastructure/http/native-http-client.d.ts +6 -1
  19. package/dist/infrastructure/openapi/openapi-exporter.d.ts +5 -0
  20. package/dist/infrastructure/parsers/curl-parser.d.ts +61 -0
  21. package/dist/infrastructure/script/interfaces.d.ts +3 -0
  22. package/dist/infrastructure/script/module-loader.d.ts +1 -1
  23. package/dist/infrastructure/script/script-factories.d.ts +17 -0
  24. package/dist/infrastructure/test-suite/interfaces.d.ts +103 -6
  25. package/dist/infrastructure/test-suite/result-storage.d.ts +6 -0
  26. package/dist/infrastructure/test-suite/statistics-service.d.ts +1 -1
  27. package/dist/infrastructure/test-suite/test-suite-service.d.ts +2 -2
  28. package/dist/infrastructure/test-suite/test-suite-store.d.ts +27 -9
  29. package/dist/runtime/mcp-collection-utils.d.ts +29 -1
  30. package/dist/runtime/mcp-prompts.d.ts +39 -0
  31. package/dist/runtime/mcp-run-store.d.ts +11 -1
  32. package/dist/runtime/mcp-tool-builder.d.ts +6 -0
  33. package/dist/runtime/mcp-tool-name.d.ts +4 -5
  34. package/dist/runtime/mcp-tool-schemas.d.ts +45 -0
  35. package/dist/runtime/node-bootstrap.d.ts +9 -0
  36. package/dist/runtime/runtime-contracts.d.ts +14 -0
  37. package/dist/types/types.d.ts +67 -1
  38. package/dist/utils/typed-value.d.ts +14 -0
  39. package/package.json +20 -6
@@ -0,0 +1,16 @@
1
+ /**
2
+ * AI Provider Interface
3
+ *
4
+ * Platform-agnostic abstraction for text-completion AI.
5
+ * Implementations:
6
+ * - VS Code extension: CopilotAiProvider (wraps vscode.lm)
7
+ * - CLI: OpenAiProvider / AnthropicProvider (plain HTTP)
8
+ */
9
+ /** Minimal interface required by all AI-powered core utilities. */
10
+ export interface IAiProvider {
11
+ /**
12
+ * Send a single user prompt and return the full completion text.
13
+ * Implementations should throw on hard failures; the caller handles retries.
14
+ */
15
+ complete(prompt: string): Promise<string>;
16
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * AI Environment Variable Suggester (platform-agnostic)
3
+ *
4
+ * Uses any IAiProvider to scan a collection for hardcoded values and produce
5
+ * EnvSuggestion objects — the same shape returned by the rule-based suggester
6
+ * in env-suggester.ts, so apply logic is shared.
7
+ *
8
+ * Platform-independent: no Node.js or VS Code dependency.
9
+ */
10
+ import type { Collection } from '../../types/collection';
11
+ import type { IAiProvider } from '../ai/ai-provider';
12
+ import type { EnvSuggestion } from './env-suggester';
13
+ /**
14
+ * Ask the AI to scan a collection for hardcoded values that should become
15
+ * environment variables. Returns suggestions in the same `EnvSuggestion` shape
16
+ * used by the rule-based detector so `applyEnvSuggestionsToItems` works for both.
17
+ *
18
+ * @param collection The collection to scan.
19
+ * @param aiProvider Any IAiProvider (Copilot, OpenAI, Anthropic, …).
20
+ * @returns Suggestions sorted by occurrence count descending.
21
+ */
22
+ export declare function scanCollectionForEnvVarsWithAi(collection: Collection, aiProvider: IAiProvider): Promise<EnvSuggestion[]>;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * AI Collection Enhancer
3
+ *
4
+ * Post-import pass that uses an IAiProvider to:
5
+ * 1. Generate realistic request body examples (replacing schema-inferred placeholders)
6
+ * 2. Write a postResponse test script for each request (status checks + schema assertions)
7
+ *
8
+ * Platform-independent — no VS Code or Node.js-specific dependency.
9
+ * The caller supplies the AI provider implementation.
10
+ */
11
+ import type { Collection, ICollectionService } from '../../types/collection';
12
+ import type { IAiProvider } from '../ai/ai-provider';
13
+ /** Progress callback: (message, percentIncrement) */
14
+ export type EnhanceProgressCallback = (message: string, increment: number) => void;
15
+ /**
16
+ * Enhance a collection with AI-generated body examples and test scripts.
17
+ *
18
+ * @param collection The collection to enhance (mutated in place, then saved).
19
+ * @param collectionService Service used to persist the collection after enhancement.
20
+ * @param aiProvider AI backend to use (Copilot, OpenAI, Anthropic, …).
21
+ * @param onProgress Optional progress callback fired once per batch.
22
+ */
23
+ export declare function enhanceCollection(collection: Collection, collectionService: ICollectionService, aiProvider: IAiProvider, onProgress?: EnhanceProgressCallback): Promise<void>;
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Environment Variable Suggester (rule-based)
3
+ *
4
+ * Scans an HTTP Forge collection for hardcoded values (auth tokens, API keys,
5
+ * shared base URLs, …) and suggests replacing them with environment variable
6
+ * placeholders (`{{VAR_NAME}}`).
7
+ *
8
+ * No AI dependency — detection is entirely heuristic:
9
+ * 1. `Authorization` header values (Bearer / Basic / Token / Digest)
10
+ * 2. Common sensitive header names (X-API-Key, X-Auth-Token, …)
11
+ * 3. Common sensitive query-param keys (api_key, access_token, …)
12
+ * 4. Shared base URL across ≥ 2 requests → BASE_URL
13
+ * 5. Long opaque strings (≥ 20 chars) in any header value
14
+ *
15
+ * Platform-independent (no Node.js or VS Code dependency).
16
+ */
17
+ import type { Collection, CollectionItem } from '../../types/collection';
18
+ /** A single detected hardcoded-value candidate. */
19
+ export interface EnvSuggestion {
20
+ /** Suggested variable name (e.g. `BEARER_TOKEN`). */
21
+ varName: string;
22
+ /** The hardcoded value found in the collection. */
23
+ value: string;
24
+ /** Human-readable explanation of why this was flagged. */
25
+ reason: string;
26
+ /** Every location where this value appears. */
27
+ occurrences: Array<{
28
+ requestId: string;
29
+ requestName: string;
30
+ field: string;
31
+ }>;
32
+ }
33
+ /**
34
+ * Scan a collection and return suggestions for replacing hardcoded values with
35
+ * environment variables.
36
+ *
37
+ * @param collection The collection to analyse.
38
+ * @param minOccurrences Only return suggestions seen in at least this many
39
+ * request locations (default: 1).
40
+ */
41
+ export declare function detectEnvSuggestions(collection: Collection, minOccurrences?: number): EnvSuggestion[];
42
+ /**
43
+ * Apply env-variable replacements to a collection's items in-place.
44
+ *
45
+ * For each suggestion, the hardcoded value is replaced with `{{VAR_NAME}}` in:
46
+ * - request URLs
47
+ * - header values (auth prefix like "Bearer " is preserved)
48
+ * - query-param values
49
+ *
50
+ * @param items The mutable `CollectionItem[]` to modify.
51
+ * @param suggestions Which replacements to apply.
52
+ * @returns Map of `varName → replacement count`.
53
+ */
54
+ export declare function applyEnvSuggestionsToItems(items: CollectionItem[], suggestions: Array<{
55
+ varName: string;
56
+ value: string;
57
+ }>): Record<string, number>;
@@ -110,4 +110,4 @@ export interface FolderMetadata {
110
110
  /**
111
111
  * Metadata stored in request.json (scripts stored separately in scripts/ directory)
112
112
  */
113
- export type RequestMetadata = Omit<CollectionRequest, 'scripts' | 'disabled' | 'bodyContentType'>;
113
+ export type RequestMetadata = Omit<CollectionRequest, 'scripts'>;
@@ -21,8 +21,9 @@ export declare class ConfigService implements IConfigService {
21
21
  private notifications?;
22
22
  private config;
23
23
  private configPath;
24
- private fileWatcher?;
24
+ private fileWatchers;
25
25
  constructor(workspacePath: string, fileWatcherFactory?: IFileWatcherFactory | undefined, notifications?: INotificationService | undefined);
26
+ private resolveConfigPath;
26
27
  /**
27
28
  * Load configuration from file, merging with defaults
28
29
  */
@@ -57,6 +58,24 @@ export declare class ConfigService implements IConfigService {
57
58
  * Resolve a path relative to workspace
58
59
  */
59
60
  private resolvePath;
61
+ /**
62
+ * Detect whether a root path contains folder-format collections.
63
+ * We require at least one collection folder with a collection.json file
64
+ * to avoid false positives on unrelated empty directories.
65
+ */
66
+ private hasFolderCollectionsAtRoot;
67
+ /**
68
+ * Returns true when a directory exists and contains at least one entry.
69
+ */
70
+ private hasAnyEntries;
71
+ /**
72
+ * Resolve storage root with backward compatibility for config-less workspaces.
73
+ *
74
+ * In v0.6.16 the default root changed to `.http-forge/assets`. If a workspace
75
+ * has no config file and existing collections were created under an older
76
+ * default location, prefer that legacy location so collections remain visible.
77
+ */
78
+ private resolveStorageRootPath;
60
79
  getRootPath(): string;
61
80
  getCollectionsPath(): string;
62
81
  getEnvironmentsPath(): string;
@@ -28,6 +28,27 @@ export interface RequestConfig {
28
28
  maxRedirects: number;
29
29
  /** Whether to verify SSL certificates */
30
30
  strictSSL: boolean;
31
+ /** Per-request TLS defaults (paths resolved relative to workspace root) */
32
+ tls?: {
33
+ caPath?: string;
34
+ certPath?: string;
35
+ keyPath?: string;
36
+ pfxPath?: string;
37
+ passphrase?: string;
38
+ servername?: string;
39
+ };
40
+ /** Host-based certificate mappings (Postman-style global certificates) */
41
+ certificates?: Array<{
42
+ host: string;
43
+ port?: number;
44
+ enabled?: boolean;
45
+ caPath?: string;
46
+ certPath?: string;
47
+ keyPath?: string;
48
+ pfxPath?: string;
49
+ passphrase?: string;
50
+ servername?: string;
51
+ }>;
31
52
  }
32
53
  /**
33
54
  * Script configuration
@@ -100,10 +121,13 @@ export interface McpCorsConfig {
100
121
  export type McpToolMode = 'flat' | 'drilldown' | 'auto';
101
122
  /**
102
123
  * MCP Server project-level configuration (stored in http-forge.config.json)
103
- *
104
- * Machine-specific settings (port, autoStart) remain in VS Code settings.
105
124
  */
106
125
  export interface McpConfig {
126
+ /**
127
+ * Port for the embedded MCP HTTP server. Defaults to 3100.
128
+ * Runtime callers can still override this via `createMcpRuntime({ port })`.
129
+ */
130
+ port: number;
107
131
  /**
108
132
  * Collection IDs or names to hide from MCP tools.
109
133
  * Empty array (default) = expose all collections.
@@ -11,8 +11,10 @@ export declare const DEFAULT_CONFIG: HttpForgeConfig;
11
11
  * Configuration file names
12
12
  */
13
13
  export declare const CONFIG_FILES: {
14
- /** Main configuration file */
15
- config: string;
14
+ /** Preferred main configuration file */
15
+ preferred: string;
16
+ /** Backward-compatible legacy configuration file */
17
+ legacy: string;
16
18
  };
17
19
  /**
18
20
  * Directory names within the root
@@ -13,6 +13,7 @@ export declare class EnvironmentConfigService implements IEnvironmentConfigServi
13
13
  private configService;
14
14
  private fileWatcherFactory?;
15
15
  private secretStore?;
16
+ private persistOverrides;
16
17
  private environmentsPath;
17
18
  private sharedConfigPath;
18
19
  private localConfigPath;
@@ -35,7 +36,7 @@ export declare class EnvironmentConfigService implements IEnvironmentConfigServi
35
36
  * Set by the extension host to refresh tree views and panels.
36
37
  */
37
38
  onEnvironmentsChanged?: () => void;
38
- constructor(workspaceFolder: string, workspaceStore: IKeyValueStore, configService: IConfigService, fileWatcherFactory?: IFileWatcherFactory | undefined, secretStore?: ISecretStore | undefined);
39
+ constructor(workspaceFolder: string, workspaceStore: IKeyValueStore | undefined, configService: IConfigService, fileWatcherFactory?: IFileWatcherFactory | undefined, secretStore?: ISecretStore | undefined, persistOverrides?: boolean);
39
40
  private setupFileWatcher;
40
41
  dispose(): void;
41
42
  getWorkspaceFolder(): string;
@@ -11,7 +11,7 @@
11
11
  * Platform-independent — no vscode dependency.
12
12
  */
13
13
  import { IEnvironmentConfigService } from '../../types/environment-config';
14
- import { ExecutionRequest, ExecutionResult, PreparedRequest, RequestScripts } from '../../types/types';
14
+ import { ExecutionRequest, ExecutionResult, PreparedRequest, RequestAuth, RequestScripts } from '../../types/types';
15
15
  import { IHttpRequestService } from '../http/interfaces';
16
16
  import { ICookieJar, IScriptExecutor } from '../script/interfaces';
17
17
  import { ConsoleOutputCallback, ICollectionRequestExecutor } from './collection-request-executor-interfaces';
@@ -32,9 +32,10 @@ export declare class CollectionRequestExecutor implements ICollectionRequestExec
32
32
  private readonly folderScriptsChain?;
33
33
  private readonly onConsoleOutput?;
34
34
  private readonly collectionName?;
35
+ private readonly collectionAuth?;
35
36
  private readonly iteration?;
36
37
  private readonly iterationCount?;
37
- constructor(httpService: IHttpRequestService, scriptExecutor: IScriptExecutor, envConfigService: IEnvironmentConfigService, requestPreparer: IRequestPreparer, environment: string, cookieJar?: ICookieJar | undefined, collectionScripts?: RequestScripts | undefined, folderScriptsChain?: (RequestScripts | RequestScripts[]) | undefined, onConsoleOutput?: ConsoleOutputCallback | undefined, collectionName?: string | undefined, iteration?: number | undefined, iterationCount?: number | undefined);
38
+ constructor(httpService: IHttpRequestService, scriptExecutor: IScriptExecutor, envConfigService: IEnvironmentConfigService, requestPreparer: IRequestPreparer, environment: string, cookieJar?: ICookieJar | undefined, collectionScripts?: RequestScripts | undefined, folderScriptsChain?: (RequestScripts | RequestScripts[]) | undefined, onConsoleOutput?: ConsoleOutputCallback | undefined, collectionName?: string | undefined, collectionAuth?: RequestAuth | undefined, iteration?: number | undefined, iterationCount?: number | undefined);
38
39
  /**
39
40
  * Execute a request with full Postman parity.
40
41
  */
@@ -85,6 +85,11 @@ export declare class RequestExecutor {
85
85
  * Handles both {{variable}} and :pathParam patterns in URL
86
86
  */
87
87
  private interpolateRequest;
88
+ /**
89
+ * Convert Postman form-data entries into a native FormData body so fetch can
90
+ * send a real multipart request with an auto-generated boundary.
91
+ */
92
+ private buildMultipartFormData;
88
93
  /**
89
94
  * Build script chain for a request
90
95
  * Returns scripts in execution order: collection → folders → request
@@ -34,4 +34,5 @@ export declare class RequestPreparer implements IRequestPreparer {
34
34
  prepareRequest(input: ExecutionRequest, environment: string, resolvedEnv: ResolvedEnvironment, extraVariables?: Record<string, string>): Promise<PreparedRequest>;
35
35
  private applyOAuth2;
36
36
  private applyApiKey;
37
+ private buildMultipartFormData;
37
38
  }
@@ -29,7 +29,8 @@ export declare const DEFAULT_REQUEST_SETTINGS: Required<RequestSettings>;
29
29
  export declare class NodeHttpClient implements IHttpClient {
30
30
  private settings;
31
31
  private version;
32
- constructor(defaultSettings?: Partial<RequestSettings>);
32
+ private readonly basePath;
33
+ constructor(defaultSettings?: Partial<RequestSettings>, basePath?: string);
33
34
  /**
34
35
  * Send an HTTP request
35
36
  */
@@ -45,6 +46,10 @@ export declare class NodeHttpClient implements IHttpClient {
45
46
  * Implementation extracted 100% from plugin's HttpRequestService.executeInternal
46
47
  */
47
48
  private executeInternal;
49
+ private resolveTlsSettings;
50
+ private findCertificateMapping;
51
+ private mappingMatchesHost;
52
+ private readOptionalFile;
48
53
  /**
49
54
  * Sanitize header value to remove/replace invalid characters
50
55
  * Same implementation as plugin's RequestPreprocessor.sanitizeHeaderValue
@@ -93,6 +93,11 @@ export declare class OpenApiExporter {
93
93
  private tryParseBodyContent;
94
94
  private buildFormDataSchemaFromBody;
95
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;
96
101
  private buildOperationSecurity;
97
102
  private mapAuthToSecurityScheme;
98
103
  private parseScopes;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Curl Command Parser (rule-based)
3
+ *
4
+ * Parses a curl command string into a structured HTTP request definition.
5
+ * No AI dependency — works entirely with shell tokenization and flag matching.
6
+ * Platform-independent (no Node.js dependency).
7
+ *
8
+ * Supported curl flags:
9
+ * -X / --request HTTP method
10
+ * -H / --header Request headers
11
+ * -d / --data / --data-raw / --data-binary / --data-ascii Request body
12
+ * --json JSON body (also sets Content-Type: application/json)
13
+ * -u / --user Basic auth (user:pass → Authorization: Basic …)
14
+ * -b / --cookie Cookie string (added as Cookie header)
15
+ * --url Explicit URL
16
+ * -G / --get Force GET method
17
+ * -F / --form Form-data fields
18
+ * --data-urlencode URL-encoded body field
19
+ * -A / --user-agent User-Agent header
20
+ * -e / --referer Referer header
21
+ * Backslash-newline continuation is normalised to spaces before parsing.
22
+ */
23
+ /** Structured representation of a parsed curl command. */
24
+ export interface ParsedCurlRequest {
25
+ /** Suggested request name derived from the URL path segment. */
26
+ name: string;
27
+ method: string;
28
+ url: string;
29
+ /** Headers without curl-internal additions (Content-Type from --json, etc. are still included). */
30
+ headers: Array<{
31
+ key: string;
32
+ value: string;
33
+ enabled: boolean;
34
+ }>;
35
+ queryParams: Array<{
36
+ key: string;
37
+ value: string;
38
+ enabled: boolean;
39
+ }>;
40
+ /** Parsed body, or null when no body is present. */
41
+ body: {
42
+ type: 'raw';
43
+ format: 'json' | 'text';
44
+ content: string;
45
+ } | null;
46
+ /**
47
+ * Detected hardcoded values (tokens, API keys, base URLs) that are good
48
+ * environment-variable candidates.
49
+ */
50
+ suggestedVars: Array<{
51
+ key: string;
52
+ value: string;
53
+ }>;
54
+ }
55
+ /**
56
+ * Parse a curl command string into a structured HTTP request definition.
57
+ *
58
+ * @param cmd - Full curl command including the `curl` prefix (e.g. `"curl -X POST ..."`)
59
+ * @returns Parsed request with headers, query params, body, and suggested env variables.
60
+ */
61
+ export declare function parseCurlCommand(cmd: string): ParsedCurlRequest;
@@ -24,6 +24,7 @@ export interface ICookieJar {
24
24
  setCookiesFromResponse(url: string, headers: Record<string, string | string[]>): void;
25
25
  getCookieHeader(url: string): string | undefined;
26
26
  clear(): void;
27
+ clearDomain?(domain: string): void;
27
28
  flush?(): Promise<void>;
28
29
  }
29
30
  /**
@@ -121,6 +122,8 @@ export interface PreRequestScriptResult {
121
122
  export interface PostResponseScriptResult {
122
123
  testResults: TestAssertion[];
123
124
  consoleOutput?: string[];
125
+ modifiedVariables?: Record<string, string>;
126
+ localVariables?: Record<string, string>;
124
127
  modifiedEnvironmentVariables?: Record<string, string>;
125
128
  modifiedGlobals?: Record<string, string>;
126
129
  modifiedCollectionVariables?: Record<string, string>;
@@ -39,7 +39,7 @@ export declare function createLodashShim(): any;
39
39
  *
40
40
  * Directory structure:
41
41
  * ```
42
- * http-forge-assets/modules/ ← modulePath
42
+ * .http-forge/assets/modules/ ← modulePath
43
43
  * ├── package.json ← Declares dependencies
44
44
  * ├── global-setup.js ← Global exports injected into sandbox
45
45
  * └── auth-helpers.js ← User's custom code
@@ -138,21 +138,38 @@ export interface ExpectChain {
138
138
  still: ExpectChain;
139
139
  also: ExpectChain;
140
140
  equal(expected: any): ExpectChain;
141
+ eq(expected: any): ExpectChain;
142
+ equals(expected: any): ExpectChain;
141
143
  eql(expected: any): ExpectChain;
144
+ eqls(expected: any): ExpectChain;
142
145
  property(name: string, value?: any): ExpectChain;
143
146
  ok: ExpectChain;
144
147
  exist: ExpectChain;
145
148
  include(value: any): ExpectChain;
149
+ includes(value: any): ExpectChain;
146
150
  contain(value: any): ExpectChain;
151
+ contains(value: any): ExpectChain;
147
152
  oneOf(values: any[]): ExpectChain;
148
153
  match(pattern: RegExp): ExpectChain;
149
154
  above(num: number): ExpectChain;
150
155
  below(num: number): ExpectChain;
156
+ gt(num: number): ExpectChain;
157
+ lt(num: number): ExpectChain;
158
+ least(num: number): ExpectChain;
159
+ most(num: number): ExpectChain;
160
+ gte(num: number): ExpectChain;
161
+ lte(num: number): ExpectChain;
151
162
  greaterThan(num: number): ExpectChain;
152
163
  lessThan(num: number): ExpectChain;
164
+ closeTo(expected: number, delta: number): ExpectChain;
165
+ approximately(expected: number, delta: number): ExpectChain;
153
166
  within(start: number, end: number): ExpectChain;
154
167
  a(type: string): ExpectChain;
155
168
  an(type: string): ExpectChain;
169
+ "throw"(expected?: any): ExpectChain;
170
+ throws(expected?: any): ExpectChain;
171
+ instanceOf(constructor: Function): ExpectChain;
172
+ "instanceof"(constructor: Function): ExpectChain;
156
173
  true: ExpectChain;
157
174
  false: ExpectChain;
158
175
  null: ExpectChain;
@@ -26,6 +26,76 @@ export interface SuiteRequest {
26
26
  /** Optional description of what this request does in the suite */
27
27
  description?: string;
28
28
  }
29
+ /**
30
+ * Base properties for suite flow nodes.
31
+ */
32
+ export interface SuiteFlowNodeBase {
33
+ /** Optional stable node id */
34
+ id?: string;
35
+ /** Optional display label */
36
+ name?: string;
37
+ /** Whether this node is enabled */
38
+ enabled?: boolean;
39
+ /** JavaScript boolean expression evaluated before entering the node */
40
+ condition?: string;
41
+ }
42
+ export interface SuiteRequestNode extends SuiteFlowNodeBase {
43
+ type: 'request';
44
+ request: SuiteRequest;
45
+ }
46
+ export interface SuiteBlockNode extends SuiteFlowNodeBase {
47
+ type: 'block';
48
+ nodes: SuiteFlowNode[];
49
+ }
50
+ export interface SuiteElseIfBranch {
51
+ condition: string;
52
+ nodes: SuiteFlowNode[];
53
+ }
54
+ export interface SuiteIfNode extends SuiteFlowNodeBase {
55
+ type: 'if';
56
+ if: string;
57
+ then: SuiteFlowNode[];
58
+ elseif?: SuiteElseIfBranch[];
59
+ else?: SuiteFlowNode[];
60
+ }
61
+ export interface SuiteSwitchCase {
62
+ /** If provided, this case matches when `equals === switchExpressionResult` */
63
+ equals?: unknown;
64
+ /** Optional boolean expression when equals is omitted */
65
+ condition?: string;
66
+ nodes: SuiteFlowNode[];
67
+ }
68
+ export interface SuiteSwitchNode extends SuiteFlowNodeBase {
69
+ type: 'switch';
70
+ expression: string;
71
+ cases: SuiteSwitchCase[];
72
+ default?: SuiteFlowNode[];
73
+ }
74
+ export interface SuiteForNode extends SuiteFlowNodeBase {
75
+ type: 'for';
76
+ init?: string | string[];
77
+ /** Loop continuation expression. Distinct from `condition` (guard) on SuiteFlowNodeBase. */
78
+ loopCondition?: string;
79
+ update?: string | string[];
80
+ nodes: SuiteFlowNode[];
81
+ maxIterations?: number;
82
+ }
83
+ export interface SuiteWhileNode extends SuiteFlowNodeBase {
84
+ type: 'while';
85
+ while: string;
86
+ nodes: SuiteFlowNode[];
87
+ maxIterations?: number;
88
+ }
89
+ export interface SuiteScriptNode extends SuiteFlowNodeBase {
90
+ type: 'script';
91
+ /** Inline script source */
92
+ script?: string | string[];
93
+ /** Reusable script key from TestSuite.scripts */
94
+ scriptRef?: string;
95
+ /** Optional phase hint. Defaults to 'pre'. */
96
+ phase?: 'pre' | 'post';
97
+ }
98
+ export type SuiteFlowNode = SuiteRequestNode | SuiteBlockNode | SuiteIfNode | SuiteSwitchNode | SuiteForNode | SuiteWhileNode | SuiteScriptNode;
29
99
  /**
30
100
  * Test Suite run configuration
31
101
  */
@@ -44,7 +114,26 @@ export interface SuiteConfig {
44
114
  dataFilePath?: string;
45
115
  }
46
116
  /**
47
- * Test Suite definition
117
+ * Raw shape of a suite.json file on disk — includes the deprecated `requests`
118
+ * field that may be present in legacy files. Never used as an in-memory model.
119
+ */
120
+ export interface LegacySuiteFileData {
121
+ id: string;
122
+ name: string;
123
+ description?: string;
124
+ /** @deprecated Legacy flat list — migrated to `nodes` on load. */
125
+ requests?: SuiteRequest[];
126
+ scripts?: Record<string, string | string[]>;
127
+ nodes?: SuiteFlowNode[];
128
+ config?: SuiteConfig;
129
+ isTemporary?: boolean;
130
+ createdAt?: number;
131
+ updatedAt?: number;
132
+ [key: string]: unknown;
133
+ }
134
+ /**
135
+ * Test Suite definition — in-memory model only.
136
+ * `requests` never appears here; legacy files are migrated to `nodes` on load.
48
137
  */
49
138
  export interface TestSuite {
50
139
  /** Unique identifier */
@@ -53,8 +142,14 @@ export interface TestSuite {
53
142
  name: string;
54
143
  /** Optional description */
55
144
  description?: string;
56
- /** Ordered list of request references */
57
- requests: SuiteRequest[];
145
+ /**
146
+ * Optional reusable script library addressable by `scriptRef` from flow nodes.
147
+ */
148
+ scripts?: Record<string, string | string[]>;
149
+ /**
150
+ * Control-flow graph — the primary and only execution model.
151
+ */
152
+ nodes: SuiteFlowNode[];
58
153
  /** Run configuration */
59
154
  config: SuiteConfig;
60
155
  /** Whether this is a temporary suite (not saved) */
@@ -68,6 +163,8 @@ export interface TestSuite {
68
163
  * Per-request statistics
69
164
  */
70
165
  export interface RequestStatistics {
166
+ /** Unique identity key for this request in statistics */
167
+ key: string;
71
168
  /** Request name */
72
169
  name: string;
73
170
  /** Number of executions */
@@ -129,7 +226,7 @@ export interface ErrorSummary {
129
226
  export interface RunStatistics {
130
227
  /** Summary statistics */
131
228
  summary: RunSummary;
132
- /** Statistics grouped by request name */
229
+ /** Statistics grouped by request identity key */
133
230
  byRequest: Map<string, RequestStatistics>;
134
231
  /** Overall statistics across all requests */
135
232
  overall: RequestStatistics;
@@ -140,7 +237,7 @@ export interface RunStatistics {
140
237
  * Test Suite Service Interface
141
238
  */
142
239
  export interface ITestSuiteService {
143
- createSuite(name: string, requests?: SuiteRequest[]): Promise<TestSuite>;
240
+ createSuite(name: string): Promise<TestSuite>;
144
241
  getSuite(id: string): Promise<TestSuite | undefined>;
145
242
  getAllSuites(): Promise<TestSuite[]>;
146
243
  updateSuite(suite: TestSuite): Promise<void>;
@@ -155,7 +252,7 @@ export interface ITestSuiteService {
155
252
  */
156
253
  export interface IStatisticsService {
157
254
  /** Add a result and update statistics */
158
- addResult(requestName: string, duration: number, passed: boolean, skipped: boolean, error?: string): void;
255
+ addResult(requestKey: string, requestName: string, duration: number, passed: boolean, skipped: boolean, error?: string): void;
159
256
  /** Get current statistics */
160
257
  getStatistics(): RunStatistics;
161
258
  /** Reset statistics for a new run */
@@ -114,6 +114,12 @@ export interface RunStats {
114
114
  minDuration: number;
115
115
  /** Maximum duration */
116
116
  maxDuration: number;
117
+ /** 50th percentile latency across all requests */
118
+ p50?: number;
119
+ /** 95th percentile latency across all requests */
120
+ p95?: number;
121
+ /** 99th percentile latency across all requests */
122
+ p99?: number;
117
123
  }
118
124
  /**
119
125
  * Run configuration stored in manifest
@@ -34,7 +34,7 @@ export declare class StatisticsService implements IStatisticsService {
34
34
  /**
35
35
  * Add a result and update statistics
36
36
  */
37
- addResult(requestName: string, duration: number, passed: boolean, skipped: boolean, error?: string): void;
37
+ addResult(requestKey: string, requestName: string, duration: number, passed: boolean, skipped: boolean, error?: string): void;
38
38
  /**
39
39
  * Get current statistics
40
40
  */
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import { ICollectionService } from '../../types/collection';
8
8
  import { IConfigService } from '../config';
9
- import { ITestSuiteService, SuiteRequest, TestSuite } from './interfaces';
9
+ import { ITestSuiteService, TestSuite } from './interfaces';
10
10
  /**
11
11
  * Callback invoked when the suites on disk change.
12
12
  */
@@ -58,7 +58,7 @@ export declare class TestSuiteService implements ITestSuiteService {
58
58
  /**
59
59
  * Create a new suite
60
60
  */
61
- createSuite(name: string, requests?: SuiteRequest[]): Promise<TestSuite>;
61
+ createSuite(name: string): Promise<TestSuite>;
62
62
  /**
63
63
  * Update an existing suite
64
64
  */