@http-forge/core 0.1.0
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 +500 -0
- package/dist/container.d.ts +146 -0
- package/dist/container.d.ts.map +1 -0
- package/dist/implementations/cookie-jar.d.ts +97 -0
- package/dist/implementations/cookie-jar.d.ts.map +1 -0
- package/dist/implementations/cookie-utils.d.ts +78 -0
- package/dist/implementations/cookie-utils.d.ts.map +1 -0
- package/dist/implementations/data-file-parser.d.ts +71 -0
- package/dist/implementations/data-file-parser.d.ts.map +1 -0
- package/dist/implementations/fetch-http-client.d.ts +19 -0
- package/dist/implementations/fetch-http-client.d.ts.map +1 -0
- package/dist/implementations/index.d.ts +22 -0
- package/dist/implementations/index.d.ts.map +1 -0
- package/dist/implementations/interceptor-chain.d.ts +262 -0
- package/dist/implementations/interceptor-chain.d.ts.map +1 -0
- package/dist/implementations/module-loader.d.ts +74 -0
- package/dist/implementations/module-loader.d.ts.map +1 -0
- package/dist/implementations/native-http-client.d.ts +72 -0
- package/dist/implementations/native-http-client.d.ts.map +1 -0
- package/dist/implementations/node-file-system.d.ts +52 -0
- package/dist/implementations/node-file-system.d.ts.map +1 -0
- package/dist/implementations/request-history.d.ts +73 -0
- package/dist/implementations/request-history.d.ts.map +1 -0
- package/dist/implementations/request-preprocessor.d.ts +78 -0
- package/dist/implementations/request-preprocessor.d.ts.map +1 -0
- package/dist/implementations/variable-interpolator.d.ts +55 -0
- package/dist/implementations/variable-interpolator.d.ts.map +1 -0
- package/dist/implementations/vm2-script-runner.d.ts +76 -0
- package/dist/implementations/vm2-script-runner.d.ts.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +46 -0
- package/dist/index.mjs +46 -0
- package/dist/interfaces/cookie.d.ts +101 -0
- package/dist/interfaces/cookie.d.ts.map +1 -0
- package/dist/interfaces/history.d.ts +117 -0
- package/dist/interfaces/history.d.ts.map +1 -0
- package/dist/interfaces/index.d.ts +170 -0
- package/dist/interfaces/index.d.ts.map +1 -0
- package/dist/interfaces/types.d.ts +308 -0
- package/dist/interfaces/types.d.ts.map +1 -0
- package/dist/parsers/http-forge-parser.d.ts +35 -0
- package/dist/parsers/http-forge-parser.d.ts.map +1 -0
- package/dist/parsers/index.d.ts +7 -0
- package/dist/parsers/index.d.ts.map +1 -0
- package/dist/services/collection-loader.d.ts +52 -0
- package/dist/services/collection-loader.d.ts.map +1 -0
- package/dist/services/environment-resolver.d.ts +91 -0
- package/dist/services/environment-resolver.d.ts.map +1 -0
- package/dist/services/folder-collection-loader.d.ts +91 -0
- package/dist/services/folder-collection-loader.d.ts.map +1 -0
- package/dist/services/forge-env.d.ts +166 -0
- package/dist/services/forge-env.d.ts.map +1 -0
- package/dist/services/index.d.ts +20 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/parser-registry.d.ts +49 -0
- package/dist/services/parser-registry.d.ts.map +1 -0
- package/dist/services/request-executor.d.ts +86 -0
- package/dist/services/request-executor.d.ts.map +1 -0
- package/dist/services/script-pipeline.d.ts +43 -0
- package/dist/services/script-pipeline.d.ts.map +1 -0
- package/dist/services/script-session.d.ts +66 -0
- package/dist/services/script-session.d.ts.map +1 -0
- package/dist/services/url-builder.d.ts +60 -0
- package/dist/services/url-builder.d.ts.map +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Native HTTP Client Implementation
|
|
3
|
+
*
|
|
4
|
+
* Extracted 100% from VS Code plugin: src/services/http-request-service.ts
|
|
5
|
+
* Uses Node.js native http/https modules instead of fetch for full control.
|
|
6
|
+
*
|
|
7
|
+
* DO NOT modify the core logic - it has been tested and is reliable.
|
|
8
|
+
*
|
|
9
|
+
* Features (same as plugin):
|
|
10
|
+
* - Redirect handling (301, 302, 303, 307, 308)
|
|
11
|
+
* - SSL certificate verification control
|
|
12
|
+
* - Automatic decompression (gzip, deflate)
|
|
13
|
+
* - Timeout handling
|
|
14
|
+
* - Request cancellation via AbortSignal
|
|
15
|
+
* - Cookie parsing from Set-Cookie headers
|
|
16
|
+
*/
|
|
17
|
+
import { IHttpClient } from '../interfaces';
|
|
18
|
+
import { ParsedCookie } from '../interfaces/cookie';
|
|
19
|
+
import { HttpRequest, HttpResponse, RequestSettings } from '../interfaces/types';
|
|
20
|
+
/**
|
|
21
|
+
* Default request settings
|
|
22
|
+
* Same as plugin's DEFAULT_REQUEST_SETTINGS from shared/constants.ts
|
|
23
|
+
*/
|
|
24
|
+
export declare const DEFAULT_REQUEST_SETTINGS: Required<RequestSettings>;
|
|
25
|
+
/**
|
|
26
|
+
* Extended HTTP response with raw cookie data for internal use
|
|
27
|
+
* Compatible with HttpResponse through the cookies field
|
|
28
|
+
*/
|
|
29
|
+
export interface HttpResponseWithCookies extends HttpResponse {
|
|
30
|
+
/** Parsed cookie objects with full details */
|
|
31
|
+
rawCookies: ParsedCookie[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Native HTTP client using Node.js http/https modules
|
|
35
|
+
*
|
|
36
|
+
* Implementation extracted 100% from plugin's HttpRequestService.executeInternal
|
|
37
|
+
*/
|
|
38
|
+
export declare class NativeHttpClient implements IHttpClient {
|
|
39
|
+
private settings;
|
|
40
|
+
constructor(defaultSettings?: Partial<RequestSettings>);
|
|
41
|
+
/**
|
|
42
|
+
* Execute an HTTP request
|
|
43
|
+
*/
|
|
44
|
+
execute(request: HttpRequest): Promise<HttpResponse>;
|
|
45
|
+
/**
|
|
46
|
+
* Merge user settings with defaults
|
|
47
|
+
* Same implementation as plugin's HttpRequestService.mergeSettings
|
|
48
|
+
*/
|
|
49
|
+
private mergeSettings;
|
|
50
|
+
/**
|
|
51
|
+
* Internal execute method that handles redirects
|
|
52
|
+
*
|
|
53
|
+
* Implementation extracted 100% from plugin's HttpRequestService.executeInternal
|
|
54
|
+
*/
|
|
55
|
+
private executeInternal;
|
|
56
|
+
/**
|
|
57
|
+
* Sanitize header value to remove/replace invalid characters
|
|
58
|
+
* Same implementation as plugin's RequestPreprocessor.sanitizeHeaderValue
|
|
59
|
+
*/
|
|
60
|
+
private sanitizeHeaderValue;
|
|
61
|
+
/**
|
|
62
|
+
* Sanitize all headers
|
|
63
|
+
* Same implementation as plugin's RequestPreprocessor.sanitizeHeaders
|
|
64
|
+
*/
|
|
65
|
+
private sanitizeHeaders;
|
|
66
|
+
/**
|
|
67
|
+
* Parse Set-Cookie headers into structured objects
|
|
68
|
+
* Same implementation as plugin's HttpRequestService.parseCookies
|
|
69
|
+
*/
|
|
70
|
+
private parseCookies;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=native-http-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-http-client.d.ts","sourceRoot":"","sources":["../../src/implementations/native-http-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAMH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEjF;;;GAGG;AACH,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,eAAe,CAS9D,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,uBAAwB,SAAQ,YAAY;IACzD,8CAA8C;IAC9C,UAAU,EAAE,YAAY,EAAE,CAAC;CAC9B;AAED;;;;GAIG;AACH,qBAAa,gBAAiB,YAAW,WAAW;IAChD,OAAO,CAAC,QAAQ,CAA4B;gBAEhC,eAAe,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC;IAYtD;;OAEG;IACG,OAAO,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAM1D;;;OAGG;IACH,OAAO,CAAC,aAAa;IAarB;;;;OAIG;YACW,eAAe;IAsM7B;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IAU3B;;;OAGG;IACH,OAAO,CAAC,eAAe;IAQvB;;;OAGG;IACH,OAAO,CAAC,YAAY;CA0CvB"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node.js File System Implementation
|
|
3
|
+
*
|
|
4
|
+
* Single Responsibility: File operations using Node.js fs module
|
|
5
|
+
* Dependency Inversion: Implements IFileSystem interface
|
|
6
|
+
*/
|
|
7
|
+
import { IFileSystem } from '../interfaces';
|
|
8
|
+
/**
|
|
9
|
+
* Node.js implementation of IFileSystem.
|
|
10
|
+
* Uses Node.js fs/promises for all operations.
|
|
11
|
+
*/
|
|
12
|
+
export declare class NodeFileSystem implements IFileSystem {
|
|
13
|
+
/**
|
|
14
|
+
* Read file contents as string
|
|
15
|
+
*/
|
|
16
|
+
readFile(filePath: string): Promise<string>;
|
|
17
|
+
/**
|
|
18
|
+
* Write string content to file
|
|
19
|
+
*/
|
|
20
|
+
writeFile(filePath: string, content: string): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Check if file or directory exists
|
|
23
|
+
*/
|
|
24
|
+
exists(filePath: string): Promise<boolean>;
|
|
25
|
+
/**
|
|
26
|
+
* Create directory (recursive)
|
|
27
|
+
*/
|
|
28
|
+
mkdir(dirPath: string): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* List files matching glob pattern
|
|
31
|
+
* Simple implementation using readdir + filter
|
|
32
|
+
*/
|
|
33
|
+
glob(patterns: string[], cwd?: string): Promise<string[]>;
|
|
34
|
+
/**
|
|
35
|
+
* Read directory contents
|
|
36
|
+
*/
|
|
37
|
+
readDir(dirPath: string): Promise<string[]>;
|
|
38
|
+
/**
|
|
39
|
+
* Check if path is a directory
|
|
40
|
+
*/
|
|
41
|
+
isDirectory(filePath: string): Promise<boolean>;
|
|
42
|
+
/**
|
|
43
|
+
* Walk directory recursively
|
|
44
|
+
*/
|
|
45
|
+
private walkDirectory;
|
|
46
|
+
/**
|
|
47
|
+
* Simple glob pattern matching
|
|
48
|
+
* Supports: *.ext, prefix*, *suffix
|
|
49
|
+
*/
|
|
50
|
+
private matchPattern;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=node-file-system.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-file-system.d.ts","sourceRoot":"","sources":["../../src/implementations/node-file-system.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;GAGG;AACH,qBAAa,cAAe,YAAW,WAAW;IAC9C;;OAEG;IACG,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIjD;;OAEG;IACG,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOjE;;OAEG;IACG,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAShD;;OAEG;IACG,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI3C;;;OAGG;IACG,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAqB/D;;OAEG;IACG,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAIjD;;OAEG;IACG,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IASrD;;OAEG;YACW,aAAa;IAiB3B;;;OAGG;IACH,OAAO,CAAC,YAAY;CASvB"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request History - In-Memory Implementation
|
|
3
|
+
*
|
|
4
|
+
* Core package version - memory-based, no persistence
|
|
5
|
+
* Consumers can extend or replace with persistent storage if needed
|
|
6
|
+
*
|
|
7
|
+
* Based on VS Code plugin's RequestHistoryService logic,
|
|
8
|
+
* but adapted for storage-agnostic design.
|
|
9
|
+
*/
|
|
10
|
+
import { FullResponse, HistoryEntry, IRequestHistory } from '../interfaces/history';
|
|
11
|
+
import { HttpRequest, HttpResponse } from '../interfaces/types';
|
|
12
|
+
/**
|
|
13
|
+
* In-memory request history storage
|
|
14
|
+
*
|
|
15
|
+
* Features:
|
|
16
|
+
* - Stores history entries in memory
|
|
17
|
+
* - Automatic cleanup when maxEntriesPerRequest is exceeded
|
|
18
|
+
* - Optional full response storage
|
|
19
|
+
* - No persistence (resets on process restart)
|
|
20
|
+
*/
|
|
21
|
+
export declare class RequestHistoryStore implements IRequestHistory {
|
|
22
|
+
/** Map of entryId -> HistoryEntry */
|
|
23
|
+
private entries;
|
|
24
|
+
/** Map of requestId -> entryIds (ordered, newest first) */
|
|
25
|
+
private requestIndex;
|
|
26
|
+
/** Map of entryId -> FullResponse */
|
|
27
|
+
private fullResponses;
|
|
28
|
+
/** Maximum entries per request */
|
|
29
|
+
maxEntriesPerRequest: number;
|
|
30
|
+
/** Whether to store full responses */
|
|
31
|
+
private storeFullResponses;
|
|
32
|
+
constructor(options?: {
|
|
33
|
+
maxEntriesPerRequest?: number;
|
|
34
|
+
storeFullResponses?: boolean;
|
|
35
|
+
});
|
|
36
|
+
/**
|
|
37
|
+
* Get all entries for a request
|
|
38
|
+
*/
|
|
39
|
+
getEntries(requestId: string, environment?: string): HistoryEntry[];
|
|
40
|
+
/**
|
|
41
|
+
* Get a specific entry by ID
|
|
42
|
+
*/
|
|
43
|
+
getEntry(entryId: string): HistoryEntry | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Get full response for an entry
|
|
46
|
+
*/
|
|
47
|
+
getFullResponse(entryId: string): FullResponse | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Get total entry count
|
|
50
|
+
*/
|
|
51
|
+
get count(): number;
|
|
52
|
+
/**
|
|
53
|
+
* Add a new history entry
|
|
54
|
+
*/
|
|
55
|
+
addEntry(requestId: string, request: HttpRequest, response: HttpResponse, environment: string, metadata?: {
|
|
56
|
+
ticket?: string;
|
|
57
|
+
branch?: string;
|
|
58
|
+
note?: string;
|
|
59
|
+
}): HistoryEntry;
|
|
60
|
+
/**
|
|
61
|
+
* Delete a specific entry
|
|
62
|
+
*/
|
|
63
|
+
deleteEntry(entryId: string): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Clear all history for a request
|
|
66
|
+
*/
|
|
67
|
+
clearHistory(requestId: string): void;
|
|
68
|
+
/**
|
|
69
|
+
* Clear all history
|
|
70
|
+
*/
|
|
71
|
+
clearAll(): void;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=request-history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-history.d.ts","sourceRoot":"","sources":["../../src/implementations/request-history.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAahE;;;;;;;;GAQG;AACH,qBAAa,mBAAoB,YAAW,eAAe;IACvD,qCAAqC;IACrC,OAAO,CAAC,OAAO,CAAwC;IAEvD,2DAA2D;IAC3D,OAAO,CAAC,YAAY,CAAoC;IAExD,qCAAqC;IACrC,OAAO,CAAC,aAAa,CAAwC;IAE7D,kCAAkC;IAClC,oBAAoB,EAAE,MAAM,CAAC;IAE7B,sCAAsC;IACtC,OAAO,CAAC,kBAAkB,CAAU;gBAExB,OAAO,GAAE;QACjB,oBAAoB,CAAC,EAAE,MAAM,CAAC;QAC9B,kBAAkB,CAAC,EAAE,OAAO,CAAC;KAC3B;IAKN;;OAEG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,YAAY,EAAE;IAgBnE;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAInD;;OAEG;IACH,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAI1D;;OAEG;IACH,IAAI,KAAK,IAAI,MAAM,CAElB;IAED;;OAEG;IACH,QAAQ,CACJ,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,YAAY,EACtB,WAAW,EAAE,MAAM,EACnB,QAAQ,CAAC,EAAE;QACP,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;KACjB,GACF,YAAY;IA4Df;;OAEG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAyBrC;;OAEG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAcrC;;OAEG;IACH,QAAQ,IAAI,IAAI;CAKnB"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request Preprocessor
|
|
3
|
+
*
|
|
4
|
+
* Extracted 100% from VS Code plugin: src/services/request-preprocessor.ts
|
|
5
|
+
*
|
|
6
|
+
* Single Responsibility: Handles request preparation (header sanitization, body encoding)
|
|
7
|
+
* DO NOT modify the core logic - it has been tested and is reliable.
|
|
8
|
+
*/
|
|
9
|
+
import { RequestBody } from '../interfaces/types';
|
|
10
|
+
/**
|
|
11
|
+
* Request Preprocessor Interface
|
|
12
|
+
* Same as plugin's IRequestPreprocessor
|
|
13
|
+
*/
|
|
14
|
+
export interface IRequestPreprocessor {
|
|
15
|
+
/**
|
|
16
|
+
* Sanitize header value to remove/replace invalid characters
|
|
17
|
+
*/
|
|
18
|
+
sanitizeHeaderValue(value: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Sanitize all headers
|
|
21
|
+
*/
|
|
22
|
+
sanitizeHeaders(headers: Record<string, string>): Record<string, string>;
|
|
23
|
+
/**
|
|
24
|
+
* Encode body from RequestBody wrapped format
|
|
25
|
+
*/
|
|
26
|
+
encodeBody(body: RequestBody | null | undefined): any;
|
|
27
|
+
/**
|
|
28
|
+
* Set Content-Type header based on RequestBody if not already set
|
|
29
|
+
*/
|
|
30
|
+
setContentTypeHeader(headers: Record<string, string>, body: RequestBody | null | undefined, bodyContentType?: string): void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Request Preprocessor implementation
|
|
34
|
+
*
|
|
35
|
+
* Extracted 100% from plugin's RequestPreprocessor class
|
|
36
|
+
*
|
|
37
|
+
* Handles:
|
|
38
|
+
* - Header sanitization (removing invalid characters)
|
|
39
|
+
* - Body encoding (URL encoding, JSON, etc.)
|
|
40
|
+
* - Content-Type header management
|
|
41
|
+
*/
|
|
42
|
+
export declare class RequestPreprocessor implements IRequestPreprocessor {
|
|
43
|
+
/**
|
|
44
|
+
* Sanitize header value to remove/replace invalid characters
|
|
45
|
+
* Node.js http module doesn't allow certain characters in header values
|
|
46
|
+
*
|
|
47
|
+
* Same implementation as plugin's RequestPreprocessor.sanitizeHeaderValue
|
|
48
|
+
*/
|
|
49
|
+
sanitizeHeaderValue(value: string): string;
|
|
50
|
+
/**
|
|
51
|
+
* Sanitize all headers
|
|
52
|
+
* Same implementation as plugin's RequestPreprocessor.sanitizeHeaders
|
|
53
|
+
*/
|
|
54
|
+
sanitizeHeaders(headers: Record<string, string>): Record<string, string>;
|
|
55
|
+
/**
|
|
56
|
+
* Encode body from RequestBody wrapped format
|
|
57
|
+
* Extracts type and content, encodes based on body type
|
|
58
|
+
*
|
|
59
|
+
* Same implementation as plugin's RequestPreprocessor.encodeBody
|
|
60
|
+
*/
|
|
61
|
+
encodeBody(body: RequestBody | null | undefined): any;
|
|
62
|
+
/**
|
|
63
|
+
* Encode URL-encoded body
|
|
64
|
+
* Same implementation as plugin's RequestPreprocessor.encodeUrlEncodedBody
|
|
65
|
+
*/
|
|
66
|
+
private encodeUrlEncodedBody;
|
|
67
|
+
/**
|
|
68
|
+
* Encode GraphQL body
|
|
69
|
+
* Same implementation as plugin's RequestPreprocessor.encodeGraphQLBody
|
|
70
|
+
*/
|
|
71
|
+
private encodeGraphQLBody;
|
|
72
|
+
/**
|
|
73
|
+
* Set Content-Type header based on RequestBody if not already set
|
|
74
|
+
* Same implementation as plugin's RequestPreprocessor.setContentTypeHeader
|
|
75
|
+
*/
|
|
76
|
+
setContentTypeHeader(headers: Record<string, string>, body: RequestBody | null | undefined, bodyContentType?: string): void;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=request-preprocessor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-preprocessor.d.ts","sourceRoot":"","sources":["../../src/implementations/request-preprocessor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACjC;;OAEG;IACH,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAE3C;;OAEG;IACH,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEzE;;OAEG;IACH,UAAU,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GAAG,GAAG,CAAC;IAEtD;;OAEG;IACH,oBAAoB,CAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,EACpC,eAAe,CAAC,EAAE,MAAM,GACzB,IAAI,CAAC;CACX;AAkBD;;;;;;;;;GASG;AACH,qBAAa,mBAAoB,YAAW,oBAAoB;IAC5D;;;;;OAKG;IACI,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAUjD;;;OAGG;IACI,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAQ/E;;;;;OAKG;IACI,UAAU,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GAAG,GAAG;IA8B5D;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAe5B;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAYzB;;;OAGG;IACI,oBAAoB,CACvB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,EACpC,eAAe,CAAC,EAAE,MAAM,GACzB,IAAI;CAkDV"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Variable Interpolator Implementation
|
|
3
|
+
*
|
|
4
|
+
* Single Responsibility: Replace template variables in strings and objects
|
|
5
|
+
*
|
|
6
|
+
* Extracted from: src/services/request-execution/variable-replacer.ts
|
|
7
|
+
* Changes: Renamed to match interface, added extractVariables method
|
|
8
|
+
*/
|
|
9
|
+
import { IVariableInterpolator } from '../interfaces';
|
|
10
|
+
/**
|
|
11
|
+
* Default implementation of variable interpolator.
|
|
12
|
+
* Replaces {{variableName}} patterns with values from a variables map.
|
|
13
|
+
*/
|
|
14
|
+
export declare class VariableInterpolator implements IVariableInterpolator {
|
|
15
|
+
/**
|
|
16
|
+
* Regex pattern for matching {{variable}} syntax
|
|
17
|
+
* Uses \w+ to match word characters (alphanumeric + underscore)
|
|
18
|
+
* This is consistent with the VS Code extension implementation
|
|
19
|
+
*/
|
|
20
|
+
private readonly variablePattern;
|
|
21
|
+
/**
|
|
22
|
+
* Escape special characters in a value when inside a string literal
|
|
23
|
+
* @param value - The value to escape
|
|
24
|
+
* @param quoteChar - The quote character (" or ')
|
|
25
|
+
* @returns Escaped value safe for use in the string literal
|
|
26
|
+
*/
|
|
27
|
+
private escapeForString;
|
|
28
|
+
/**
|
|
29
|
+
* Determine if position is inside a quoted string and which quote type
|
|
30
|
+
* Returns null if not inside a string, or the quote character if inside
|
|
31
|
+
*/
|
|
32
|
+
private getStringContext;
|
|
33
|
+
/**
|
|
34
|
+
* Replace {{variable}} placeholders with values
|
|
35
|
+
* Automatically escapes values when inside quoted strings
|
|
36
|
+
* @param input - Text containing variable placeholders
|
|
37
|
+
* @param variables - Map of variable names to values
|
|
38
|
+
* @returns Text with variables replaced
|
|
39
|
+
*/
|
|
40
|
+
interpolate(input: string, variables: Record<string, string>): string;
|
|
41
|
+
/**
|
|
42
|
+
* Extract variable names from a string
|
|
43
|
+
* @param input - Text containing variable placeholders
|
|
44
|
+
* @returns Array of variable names found
|
|
45
|
+
*/
|
|
46
|
+
extractVariables(input: string): string[];
|
|
47
|
+
/**
|
|
48
|
+
* Replace variables in all string values of an object (recursive)
|
|
49
|
+
* @param obj - Object containing string values with variable placeholders
|
|
50
|
+
* @param variables - Map of variable names to values
|
|
51
|
+
* @returns New object with variables replaced
|
|
52
|
+
*/
|
|
53
|
+
interpolateObject<T>(obj: T, variables: Record<string, string>): T;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=variable-interpolator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variable-interpolator.d.ts","sourceRoot":"","sources":["../../src/implementations/variable-interpolator.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEtD;;;GAGG;AACH,qBAAa,oBAAqB,YAAW,qBAAqB;IAC9D;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAoB;IAEpD;;;;;OAKG;IACH,OAAO,CAAC,eAAe;IAkBvB;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IA2BxB;;;;;;OAMG;IACI,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM;IAoC5E;;;;OAIG;IACI,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IAqBhD;;;;;OAKG;IACI,iBAAiB,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC;CAuB5E"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VM2 Script Runner Implementation
|
|
3
|
+
*
|
|
4
|
+
* Single Responsibility: Execute scripts in sandboxed VM environment
|
|
5
|
+
* Dependency Inversion: Implements IScriptRunner interface
|
|
6
|
+
*
|
|
7
|
+
* Supports custom modules from workspace via ModuleLoader when forgeRoot is provided.
|
|
8
|
+
* This ensures consistent behavior across:
|
|
9
|
+
* - VS Code Extension
|
|
10
|
+
* - @http-forge/standalone
|
|
11
|
+
* - @http-forge/playwright
|
|
12
|
+
*/
|
|
13
|
+
import { IHttpClient, IScriptRunner } from '../interfaces';
|
|
14
|
+
import { ScriptContext, ScriptResult } from '../interfaces/types';
|
|
15
|
+
/**
|
|
16
|
+
* VM2-based script runner for secure script execution
|
|
17
|
+
*/
|
|
18
|
+
export declare class VM2ScriptRunner implements IScriptRunner {
|
|
19
|
+
private timeout;
|
|
20
|
+
private httpClient?;
|
|
21
|
+
private moduleLoader?;
|
|
22
|
+
/**
|
|
23
|
+
* Create a new VM2ScriptRunner
|
|
24
|
+
*
|
|
25
|
+
* @param options.timeout - Script execution timeout in ms (default: 5000)
|
|
26
|
+
* @param options.httpClient - HTTP client for sendRequest support
|
|
27
|
+
* @param options.forgeRoot - Path to http-forge folder for custom modules support
|
|
28
|
+
*
|
|
29
|
+
* If forgeRoot is provided, custom modules from http-forge/modules/ will be available.
|
|
30
|
+
* This enables consistent behavior across VS Code, standalone CLI, and Playwright.
|
|
31
|
+
*/
|
|
32
|
+
constructor(options?: {
|
|
33
|
+
timeout?: number;
|
|
34
|
+
httpClient?: IHttpClient;
|
|
35
|
+
forgeRoot?: string;
|
|
36
|
+
});
|
|
37
|
+
/**
|
|
38
|
+
* Execute a script with the given context (implements IScriptRunner.run)
|
|
39
|
+
*/
|
|
40
|
+
run(script: string, context: ScriptContext): Promise<ScriptResult>;
|
|
41
|
+
/**
|
|
42
|
+
* Create request object with getters/setters for modification tracking
|
|
43
|
+
* Matches VS Code plugin's script-session.ts createRequestObject API
|
|
44
|
+
*/
|
|
45
|
+
private createRequestObject;
|
|
46
|
+
/**
|
|
47
|
+
* Create response object for post-response scripts
|
|
48
|
+
* Matches VS Code plugin's script-factories.ts createResponseObject API
|
|
49
|
+
*/
|
|
50
|
+
private createResponseObject;
|
|
51
|
+
/**
|
|
52
|
+
* Create a variable scope object with get/set/has/toObject methods
|
|
53
|
+
*/
|
|
54
|
+
private createVariableScope;
|
|
55
|
+
/**
|
|
56
|
+
* Create environment variable scope with name property
|
|
57
|
+
* Matches VS Code plugin's createEnvironmentScope API
|
|
58
|
+
*/
|
|
59
|
+
private createEnvironmentScope;
|
|
60
|
+
/**
|
|
61
|
+
* Create merged variable scope with cascading lookup (Postman-style)
|
|
62
|
+
* Lookup order: variables → environment → collectionVariables → globals
|
|
63
|
+
* Matches VS Code plugin's createMergedVariableScope API (without session)
|
|
64
|
+
*/
|
|
65
|
+
private createMergedVariableScope;
|
|
66
|
+
/**
|
|
67
|
+
* Create sendRequest function
|
|
68
|
+
*/
|
|
69
|
+
private createSendRequest;
|
|
70
|
+
/**
|
|
71
|
+
* Create require function with only built-in modules (no custom workspace modules)
|
|
72
|
+
* Used when no forgeRoot is provided
|
|
73
|
+
*/
|
|
74
|
+
private createBuiltinOnlyRequire;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=vm2-script-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vm2-script-runner.d.ts","sourceRoot":"","sources":["../../src/implementations/vm2-script-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAUH,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,YAAY,EAAiB,MAAM,qBAAqB,CAAC;AA+DjF;;GAEG;AACH,qBAAa,eAAgB,YAAW,aAAa;IACjD,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,UAAU,CAAC,CAAc;IACjC,OAAO,CAAC,YAAY,CAAC,CAAe;IAEpC;;;;;;;;;OASG;gBACS,OAAO,GAAE;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,UAAU,CAAC,EAAE,WAAW,CAAC;QACzB,SAAS,CAAC,EAAE,MAAM,CAAC;KACjB;IAUN;;OAEG;IACG,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;IA6KxE;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IAmD3B;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IA0H5B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAW3B;;;OAGG;IACH,OAAO,CAAC,sBAAsB;IAY9B;;;;OAIG;IACH,OAAO,CAAC,yBAAyB;IAiCjC;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAqCzB;;;OAGG;IACH,OAAO,CAAC,wBAAwB;CAsBnC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @http-forge/core
|
|
3
|
+
*
|
|
4
|
+
* Lightweight, VS Code-independent HTTP API testing engine.
|
|
5
|
+
* This package is the single source of truth for HTTP Forge execution logic.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { ForgeContainer } from '@http-forge/core';
|
|
10
|
+
*
|
|
11
|
+
* const forge = new ForgeContainer();
|
|
12
|
+
* const collection = await forge.loadCollection('./api.forge.json');
|
|
13
|
+
* const result = await forge.execute(collection.items[0], collection);
|
|
14
|
+
*
|
|
15
|
+
* console.log(result.response.status);
|
|
16
|
+
* console.log(result.postResponseResult?.assertions);
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export { ForgeContainer } from './container';
|
|
20
|
+
export type { ForgeContainerOptions, StorageFormat } from './container';
|
|
21
|
+
export * from './interfaces';
|
|
22
|
+
export { FetchHttpClient, NodeFileSystem, VariableInterpolator, VM2ScriptRunner } from './implementations';
|
|
23
|
+
export { HttpForgeParser } from './parsers';
|
|
24
|
+
export { CollectionLoader, EnvironmentResolver, FolderCollectionLoader, ForgeEnv, ParserRegistry, RequestExecutor, ScriptPipeline, ScriptSession, UrlBuilder } from './services';
|
|
25
|
+
export { generateSlug } from './services/folder-collection-loader';
|
|
26
|
+
export type { Environment, EnvironmentConfig, ExecuteOptions, ExecuteResult, IForgeEnv, IUrlBuilder, LoadOptions } from './services';
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,YAAY,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGxE,cAAc,cAAc,CAAC;AAG7B,OAAO,EACH,eAAe,EAAE,cAAc,EAAE,oBAAoB,EAAE,eAAe,EACzE,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAG5C,OAAO,EACH,gBAAgB,EAChB,mBAAmB,EACnB,sBAAsB,EACtB,QAAQ,EACR,cAAc,EACd,eAAe,EACf,cAAc,EACd,aAAa,EACb,UAAU,EACb,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAEnE,YAAY,EACR,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,SAAS,EACT,WAAW,EACX,WAAW,EACd,MAAM,YAAY,CAAC"}
|