@http-forge/core 0.6.18 → 0.6.21

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.
@@ -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'>;
@@ -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
@@ -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
@@ -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>;
@@ -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 */
@@ -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
  */
@@ -55,6 +55,11 @@ export interface ITestSuiteStore {
55
55
  * Get all suite requests with their resolved data
56
56
  */
57
57
  getAllSuiteRequests(): SuiteRequestEntry[];
58
+ /**
59
+ * Resolve a SuiteRequest to a full entry with collection context.
60
+ * Works for any SuiteRequest object regardless of whether it's in suite.requests.
61
+ */
62
+ resolveRequestEntry(suiteRequest: SuiteRequest): SuiteRequestEntry | undefined;
58
63
  /**
59
64
  * Get resolved requests for webview display
60
65
  */
@@ -70,6 +75,7 @@ export interface ITestSuiteStore {
70
75
  enabled: boolean;
71
76
  hasEmbeddedRequest: boolean;
72
77
  slug?: string;
78
+ description?: string;
73
79
  }>;
74
80
  /**
75
81
  * Get suite requests by selection state
@@ -107,6 +113,7 @@ export declare class TestSuiteStore implements ITestSuiteStore {
107
113
  constructor(collectionService: ICollectionService);
108
114
  /**
109
115
  * Set the suite
116
+ * Converts legacy requests to request nodes for unified nodes-only architecture
110
117
  */
111
118
  setSuite(suite: TestSuite): void;
112
119
  /**
@@ -124,7 +131,7 @@ export declare class TestSuiteStore implements ITestSuiteStore {
124
131
  private loadSuiteRequest;
125
132
  /**
126
133
  * Save a suite request to its folder.
127
- * Writes request.json + scripts/pre-request.js + scripts/post-response.js
134
+ * Writes request.json + scripts/pre-request.js + scripts/post-response.js atomically.
128
135
  */
129
136
  private saveSuiteRequest;
130
137
  /**
@@ -135,7 +142,7 @@ export declare class TestSuiteStore implements ITestSuiteStore {
135
142
  * Resolve a suite request to its full request data.
136
143
  * Priority: suite folder → collection (fallback for legacy suites)
137
144
  */
138
- private resolveRequest;
145
+ resolveRequestEntry(suiteRequest: SuiteRequest): SuiteRequestEntry | undefined;
139
146
  /**
140
147
  * Find a request in a collection, including folder scripts
141
148
  */
@@ -165,8 +172,8 @@ export declare class TestSuiteStore implements ITestSuiteStore {
165
172
  */
166
173
  getAllSuiteRequests(): SuiteRequestEntry[];
167
174
  /**
168
- * Get resolved requests for webview display
169
- * Returns simplified format with display-relevant properties
175
+ * Get resolved requests for webview display.
176
+ * Returns simplified format with display-relevant properties, ordered by nodes.
170
177
  */
171
178
  getResolvedRequests(): Array<{
172
179
  id: string;
@@ -180,6 +187,7 @@ export declare class TestSuiteStore implements ITestSuiteStore {
180
187
  enabled: boolean;
181
188
  hasEmbeddedRequest: boolean;
182
189
  slug?: string;
190
+ description?: string;
183
191
  }>;
184
192
  /**
185
193
  * Get selected requests in order
@@ -187,8 +195,9 @@ export declare class TestSuiteStore implements ITestSuiteStore {
187
195
  */
188
196
  getSelectedRequests(selectedIds: string[]): SuiteRequestEntry[];
189
197
  /**
190
- * Add a request to the suite.
191
- * If fullRequest is provided and suiteDir is set, creates a folder with request.json + scripts.
198
+ * Add a request to the suite as a flow node.
199
+ * Copy-on-write: do NOT create an embedded request folder at add time.
200
+ * A folder snapshot is created only when the request is edited/reset in-suite.
192
201
  */
193
202
  addRequest(request: SuiteRequest, fullRequest?: CollectionRequest): void;
194
203
  /**
@@ -196,11 +205,11 @@ export declare class TestSuiteStore implements ITestSuiteStore {
196
205
  */
197
206
  private resolveUniqueSlug;
198
207
  /**
199
- * Remove a request from the suite
208
+ * Remove a request from the suite (removes its node)
200
209
  */
201
210
  removeRequest(requestId: string): void;
202
211
  /**
203
- * Reorder requests by request IDs (format: "collectionId:requestId")
212
+ * Reorder request nodes by "collectionId:requestId" keys
204
213
  */
205
214
  reorderRequests(orderedKeys: string[]): void;
206
215
  /**
@@ -213,4 +222,9 @@ export declare class TestSuiteStore implements ITestSuiteStore {
213
222
  * Overwrites the request folder content.
214
223
  */
215
224
  resyncFromCollection(slug: string): CollectionRequest | undefined;
225
+ /**
226
+ * Extract all SuiteRequest objects from top-level request nodes.
227
+ * Nodes is the sole source of truth — no suite.requests access.
228
+ */
229
+ private _getRequestNodes;
216
230
  }
@@ -21,12 +21,11 @@
21
21
  * human-readable names), so the exact tool name does not affect tool choice.
22
22
  */
23
23
  /**
24
- * Deterministic short token for an ID or folder path (12 hex chars).
25
- * @param value The value to be hashed.
26
- * @param maxLen The maximum length of the raw segment before appending the hash.
27
- * @returns A string combining the truncated value and its hash.
24
+ * Deterministic readable token for an ID or folder path.
25
+ *
26
+ * Shape: `<slug>_<hash12>`
28
27
  */
29
- export declare function mcpToolToken(value: string, maxLen?: number): string;
28
+ export declare function mcpToolToken(value: string): string;
30
29
  /**
31
30
  * Return `value` verbatim when it is a safe, short raw segment (discoverable),
32
31
  * otherwise its deterministic hash token. Either way the result never contains
@@ -226,6 +226,12 @@ export declare const GENERIC_TOOL_NAMES: {
226
226
  readonly getSuite: "get_suite";
227
227
  readonly createSuite: "create_suite";
228
228
  readonly updateSuiteConfig: "update_suite_config";
229
+ readonly getSuiteNode: "get_suite_node";
230
+ readonly listSuiteNodePaths: "list_suite_node_paths";
231
+ readonly addSuiteNode: "add_suite_node";
232
+ readonly updateSuiteNode: "update_suite_node";
233
+ readonly removeSuiteNode: "remove_suite_node";
234
+ readonly moveSuiteNode: "move_suite_node";
229
235
  readonly addSuiteRequests: "add_suite_requests";
230
236
  readonly removeSuiteRequest: "remove_suite_request";
231
237
  readonly reorderSuiteRequests: "reorder_suite_requests";
@@ -191,6 +191,36 @@ export interface RequestSettings {
191
191
  strictSSL?: boolean;
192
192
  decompress?: boolean;
193
193
  includeCookies?: boolean;
194
+ tls?: TlsSettings;
195
+ certificates?: TlsCertificateMapping[];
196
+ }
197
+ /**
198
+ * TLS options for HTTPS requests
199
+ */
200
+ export interface TlsSettings {
201
+ /** Path to CA certificate bundle (PEM) */
202
+ caPath?: string;
203
+ /** Path to client certificate (PEM) */
204
+ certPath?: string;
205
+ /** Path to client private key (PEM) */
206
+ keyPath?: string;
207
+ /** Path to client certificate/key bundle (PFX/P12) */
208
+ pfxPath?: string;
209
+ /** Passphrase for key/pfx if required */
210
+ passphrase?: string;
211
+ /** Optional TLS servername (SNI override) */
212
+ servername?: string;
213
+ }
214
+ /**
215
+ * Host-based TLS certificate mapping (Postman-style global certificate settings)
216
+ */
217
+ export interface TlsCertificateMapping extends TlsSettings {
218
+ /** Host matcher: exact host (api.example.com), wildcard (*.example.com), or '*' */
219
+ host: string;
220
+ /** Optional port filter */
221
+ port?: number;
222
+ /** Enable/disable mapping */
223
+ enabled?: boolean;
194
224
  }
195
225
  /**
196
226
  * HTTP request ready for execution
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Serialize a value for storage in variable scopes.
3
+ * Strings are stored as-is; other values are JSON payloads with U+001E marker.
4
+ */
5
+ export declare function serializeTypedValue(raw: unknown): string;
6
+ /**
7
+ * Deserialize a value stored by script variable scopes.
8
+ * Values prefixed with U+001E are JSON payloads and are parsed back.
9
+ */
10
+ export declare function deserializeTypedValue(raw: unknown): unknown;
11
+ /**
12
+ * Deserialize every value in a variable map.
13
+ */
14
+ export declare function deserializeTypedRecord(record: Record<string, unknown> | undefined): Record<string, unknown>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@http-forge/core",
3
- "version": "0.6.18",
3
+ "version": "0.6.21",
4
4
  "description": "Headless Postman-compatible API testing engine for Node.js, CI/CD, OpenAPI workflows, and HTTP Forge automation",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",