@http-forge/core 0.1.0 → 0.2.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.
Files changed (128) hide show
  1. package/README.md +194 -41
  2. package/dist/auth/interfaces.d.ts +63 -0
  3. package/dist/auth/oauth2-token-manager.d.ts +103 -0
  4. package/dist/collection/collection-loader-factory.d.ts +20 -0
  5. package/dist/{services → collection}/collection-loader.d.ts +3 -3
  6. package/dist/collection/collection-service-interfaces.d.ts +119 -0
  7. package/dist/collection/collection-service.d.ts +75 -0
  8. package/dist/collection/collection-store.d.ts +109 -0
  9. package/dist/collection/folder-collection-loader.d.ts +256 -0
  10. package/dist/collection/folder-collection-store.d.ts +168 -0
  11. package/dist/collection/interfaces.d.ts +32 -0
  12. package/dist/collection/json-collection-loader.d.ts +95 -0
  13. package/dist/{services → collection}/parser-registry.d.ts +1 -2
  14. package/dist/config/config-service.d.ts +79 -0
  15. package/dist/config/config.interface.d.ts +140 -0
  16. package/dist/config/default-config.d.ts +29 -0
  17. package/dist/config/index.d.ts +6 -0
  18. package/dist/container.d.ts +22 -14
  19. package/dist/{implementations → cookie}/cookie-jar.d.ts +2 -3
  20. package/dist/cookie/cookie-service.d.ts +98 -0
  21. package/dist/{implementations → cookie}/cookie-utils.d.ts +1 -2
  22. package/dist/cookie/in-memory-cookie-jar.d.ts +44 -0
  23. package/dist/{interfaces/cookie.d.ts → cookie/interfaces.d.ts} +22 -3
  24. package/dist/cookie/persistent-cookie-jar.d.ts +35 -0
  25. package/dist/environment/environment-config-service.d.ts +95 -0
  26. package/dist/{services → environment}/environment-resolver.d.ts +6 -5
  27. package/dist/{services → environment}/forge-env.d.ts +1 -2
  28. package/dist/environment/interfaces.d.ts +139 -0
  29. package/dist/environment/variable-interpolator.d.ts +100 -0
  30. package/dist/execution/collection-request-executor-interfaces.d.ts +36 -0
  31. package/dist/execution/collection-request-executor.d.ts +78 -0
  32. package/dist/{services → execution}/request-executor.d.ts +23 -11
  33. package/dist/execution/request-preparer-interfaces.d.ts +36 -0
  34. package/dist/execution/request-preparer.d.ts +35 -0
  35. package/dist/graphql/graphql-completion-provider.d.ts +39 -0
  36. package/dist/graphql/graphql-schema-service.d.ts +89 -0
  37. package/dist/{interfaces/history.d.ts → history/history-interfaces.d.ts} +29 -6
  38. package/dist/history/request-history-service-interfaces.d.ts +43 -0
  39. package/dist/history/request-history-service.d.ts +133 -0
  40. package/dist/{implementations → history}/request-history.d.ts +2 -3
  41. package/dist/{implementations → http}/fetch-http-client.d.ts +4 -5
  42. package/dist/http/http-request-service.d.ts +36 -0
  43. package/dist/{implementations → http}/interceptor-chain.d.ts +1 -2
  44. package/dist/http/interfaces.d.ts +25 -0
  45. package/dist/http/merge-request-settings.d.ts +12 -0
  46. package/dist/{implementations → http}/native-http-client.d.ts +6 -15
  47. package/dist/{implementations → http}/request-preprocessor.d.ts +1 -2
  48. package/dist/{services → http}/url-builder.d.ts +7 -10
  49. package/dist/import-export/import-postman-environment.d.ts +21 -0
  50. package/dist/import-export/rest-client-export.d.ts +35 -0
  51. package/dist/index.d.ts +88 -6
  52. package/dist/index.js +262 -35
  53. package/dist/index.mjs +262 -35
  54. package/dist/openapi/example-generator.d.ts +26 -0
  55. package/dist/openapi/history-analyzer.d.ts +29 -0
  56. package/dist/openapi/index.d.ts +16 -0
  57. package/dist/openapi/interfaces.d.ts +42 -0
  58. package/dist/openapi/openapi-exporter.d.ts +73 -0
  59. package/dist/openapi/openapi-importer.d.ts +72 -0
  60. package/dist/openapi/ref-resolver.d.ts +28 -0
  61. package/dist/openapi/schema-inference-service.d.ts +40 -0
  62. package/dist/openapi/schema-inferrer.d.ts +26 -0
  63. package/dist/openapi/script-analyzer.d.ts +41 -0
  64. package/dist/parsers/http-forge-parser.d.ts +2 -3
  65. package/dist/parsers/index.d.ts +0 -1
  66. package/dist/{implementations → platform}/data-file-parser.d.ts +0 -1
  67. package/dist/{implementations → platform}/node-file-system.d.ts +1 -2
  68. package/dist/script/interfaces.d.ts +149 -0
  69. package/dist/script/module-loader.d.ts +115 -0
  70. package/dist/script/request-script-session.d.ts +70 -0
  71. package/dist/script/script-executor.d.ts +60 -0
  72. package/dist/script/script-factories.d.ts +83 -0
  73. package/dist/script/script-utils.d.ts +41 -0
  74. package/dist/test-suite/index.d.ts +10 -0
  75. package/dist/test-suite/interfaces.d.ts +164 -0
  76. package/dist/test-suite/result-storage-service.d.ts +70 -0
  77. package/dist/test-suite/result-storage.d.ts +296 -0
  78. package/dist/test-suite/statistics-service.d.ts +51 -0
  79. package/dist/test-suite/test-suite-service.d.ts +97 -0
  80. package/dist/test-suite/test-suite-store.d.ts +155 -0
  81. package/dist/types/console-service.d.ts +40 -0
  82. package/dist/types/platform.d.ts +206 -0
  83. package/dist/{interfaces → types}/types.d.ts +282 -12
  84. package/dist/utils/dynamic-variables.d.ts +38 -0
  85. package/dist/utils/expression-evaluator.d.ts +34 -0
  86. package/dist/utils/filter-engine.d.ts +47 -0
  87. package/dist/utils/helpers.d.ts +47 -0
  88. package/package.json +11 -3
  89. package/dist/container.d.ts.map +0 -1
  90. package/dist/implementations/cookie-jar.d.ts.map +0 -1
  91. package/dist/implementations/cookie-utils.d.ts.map +0 -1
  92. package/dist/implementations/data-file-parser.d.ts.map +0 -1
  93. package/dist/implementations/fetch-http-client.d.ts.map +0 -1
  94. package/dist/implementations/index.d.ts +0 -22
  95. package/dist/implementations/index.d.ts.map +0 -1
  96. package/dist/implementations/interceptor-chain.d.ts.map +0 -1
  97. package/dist/implementations/module-loader.d.ts +0 -74
  98. package/dist/implementations/module-loader.d.ts.map +0 -1
  99. package/dist/implementations/native-http-client.d.ts.map +0 -1
  100. package/dist/implementations/node-file-system.d.ts.map +0 -1
  101. package/dist/implementations/request-history.d.ts.map +0 -1
  102. package/dist/implementations/request-preprocessor.d.ts.map +0 -1
  103. package/dist/implementations/variable-interpolator.d.ts +0 -55
  104. package/dist/implementations/variable-interpolator.d.ts.map +0 -1
  105. package/dist/implementations/vm2-script-runner.d.ts +0 -76
  106. package/dist/implementations/vm2-script-runner.d.ts.map +0 -1
  107. package/dist/index.d.ts.map +0 -1
  108. package/dist/interfaces/cookie.d.ts.map +0 -1
  109. package/dist/interfaces/history.d.ts.map +0 -1
  110. package/dist/interfaces/index.d.ts +0 -170
  111. package/dist/interfaces/index.d.ts.map +0 -1
  112. package/dist/interfaces/types.d.ts.map +0 -1
  113. package/dist/parsers/http-forge-parser.d.ts.map +0 -1
  114. package/dist/parsers/index.d.ts.map +0 -1
  115. package/dist/services/collection-loader.d.ts.map +0 -1
  116. package/dist/services/environment-resolver.d.ts.map +0 -1
  117. package/dist/services/folder-collection-loader.d.ts +0 -91
  118. package/dist/services/folder-collection-loader.d.ts.map +0 -1
  119. package/dist/services/forge-env.d.ts.map +0 -1
  120. package/dist/services/index.d.ts +0 -20
  121. package/dist/services/index.d.ts.map +0 -1
  122. package/dist/services/parser-registry.d.ts.map +0 -1
  123. package/dist/services/request-executor.d.ts.map +0 -1
  124. package/dist/services/script-pipeline.d.ts +0 -43
  125. package/dist/services/script-pipeline.d.ts.map +0 -1
  126. package/dist/services/script-session.d.ts +0 -66
  127. package/dist/services/script-session.d.ts.map +0 -1
  128. package/dist/services/url-builder.d.ts.map +0 -1
@@ -0,0 +1,206 @@
1
+ /**
2
+ * Platform Abstraction Interfaces
3
+ *
4
+ * These interfaces decouple core business logic from platform-specific APIs
5
+ * (VS Code, Node.js CLI, browser, etc.), enabling the same logic to run
6
+ * in any environment by providing different implementations.
7
+ *
8
+ * Pattern:
9
+ * - Extension: implements via vscode.* APIs
10
+ * - CLI/Standalone: implements via chokidar, node-keytar, open, etc.
11
+ * - Browser/Web: implements via browser APIs or server-side proxies
12
+ */
13
+ /**
14
+ * Represents a resource that can be disposed/cleaned up.
15
+ */
16
+ export interface IDisposable {
17
+ dispose(): void;
18
+ }
19
+ /**
20
+ * Callback type for file watcher events.
21
+ */
22
+ export type FileWatcherCallback = (uri: string) => void;
23
+ /**
24
+ * Watches a set of files for changes.
25
+ *
26
+ * VS Code impl: wraps `vscode.FileSystemWatcher`
27
+ * Node impl: wraps `chokidar` or `fs.watch`
28
+ */
29
+ export interface IFileWatcher extends IDisposable {
30
+ onDidChange(callback: FileWatcherCallback): IDisposable;
31
+ onDidCreate(callback: FileWatcherCallback): IDisposable;
32
+ onDidDelete(callback: FileWatcherCallback): IDisposable;
33
+ }
34
+ /**
35
+ * Factory for creating file watchers.
36
+ *
37
+ * VS Code impl: `vscode.workspace.createFileSystemWatcher(new RelativePattern(base, glob))`
38
+ * Node impl: `chokidar.watch(path.join(base, glob))`
39
+ */
40
+ export interface IFileWatcherFactory {
41
+ /**
42
+ * Create a watcher for files matching the glob pattern under the base directory.
43
+ * @param base - Base directory path
44
+ * @param glob - Glob pattern relative to base (e.g. `'**\/*.json'`)
45
+ */
46
+ createFileWatcher(base: string, glob: string): IFileWatcher;
47
+ }
48
+ /**
49
+ * Simple key-value store for persisting state.
50
+ *
51
+ * VS Code impl: wraps `ExtensionContext.globalState` or `.workspaceState`
52
+ * Node/CLI impl: wraps a JSON file or SQLite
53
+ * Browser impl: wraps localStorage or IndexedDB
54
+ */
55
+ export interface IKeyValueStore {
56
+ /**
57
+ * Get a value by key. Returns `defaultValue` (or undefined) if not found.
58
+ */
59
+ get<T>(key: string, defaultValue?: T): T | undefined;
60
+ /**
61
+ * Set a value for a key. Pass `undefined` to delete.
62
+ */
63
+ update(key: string, value: any): Promise<void>;
64
+ }
65
+ /**
66
+ * Secure storage for sensitive data (tokens, passwords).
67
+ *
68
+ * VS Code impl: wraps `ExtensionContext.secrets`
69
+ * Node/CLI impl: wraps `keytar` or encrypted file store
70
+ * Browser impl: wraps server-side encrypted store via API
71
+ */
72
+ export interface ISecretStore {
73
+ get(key: string): Promise<string | undefined>;
74
+ store(key: string, value: string): Promise<void>;
75
+ delete(key: string): Promise<void>;
76
+ }
77
+ /**
78
+ * Shows user-facing notifications/messages.
79
+ *
80
+ * VS Code impl: wraps `vscode.window.show{Information,Warning,Error}Message`
81
+ * CLI impl: console.log / chalk
82
+ * Browser impl: toast / alert
83
+ */
84
+ export interface INotificationService {
85
+ showInformation(message: string): Promise<string | undefined>;
86
+ showWarning(message: string): Promise<string | undefined>;
87
+ showError(message: string): Promise<string | undefined>;
88
+ }
89
+ /**
90
+ * A named output channel for structured logging with UI controls.
91
+ * Extends ILogger with show/clear/dispose capabilities.
92
+ *
93
+ * VS Code impl: wraps `vscode.LogOutputChannel`
94
+ * CLI impl: writes to a log file or stdout with prefixed channel name
95
+ * Browser impl: writes to a panel or developer console
96
+ */
97
+ export interface IOutputChannel extends IDisposable {
98
+ readonly name: string;
99
+ trace(message: string): void;
100
+ debug(message: string): void;
101
+ info(message: string): void;
102
+ warn(message: string): void;
103
+ error(message: string): void;
104
+ /** Show/focus the output channel */
105
+ show(preserveFocus?: boolean): void;
106
+ /** Clear all output */
107
+ clear(): void;
108
+ }
109
+ /**
110
+ * Factory for creating named output channels.
111
+ *
112
+ * VS Code impl: wraps `vscode.window.createOutputChannel(name, { log: true })`
113
+ * Node/CLI impl: creates file-backed or console-backed loggers
114
+ */
115
+ export interface IOutputChannelFactory {
116
+ createOutputChannel(name: string): IOutputChannel;
117
+ }
118
+ /**
119
+ * Service for interacting with the system browser.
120
+ * Used primarily for OAuth2 authorization flows.
121
+ *
122
+ * VS Code impl: wraps `vscode.env.openExternal`, `.uriScheme`, `.asExternalUri`
123
+ * Node/CLI impl: wraps `open` package + local HTTP callback server
124
+ * Browser impl: `window.open()` + `postMessage` callback
125
+ */
126
+ export interface IExternalBrowserService {
127
+ /**
128
+ * The URI scheme for this platform (e.g. 'vscode', 'http-forge', 'http').
129
+ */
130
+ readonly uriScheme: string;
131
+ /**
132
+ * Open a URL in the system's default browser.
133
+ */
134
+ openExternal(url: string): Promise<boolean>;
135
+ /**
136
+ * Convert a local URI to an externally accessible URI.
137
+ * Used for OAuth2 callback URLs.
138
+ */
139
+ asExternalUri(uri: string): Promise<string>;
140
+ }
141
+ /**
142
+ * Metadata about the running application/extension.
143
+ * Used for User-Agent headers, telemetry, etc.
144
+ *
145
+ * VS Code impl: reads from `vscode.extensions.getExtension(id)?.packageJSON`
146
+ * CLI impl: reads from package.json
147
+ */
148
+ export interface IApplicationInfo {
149
+ readonly name: string;
150
+ readonly version: string;
151
+ readonly displayName?: string;
152
+ }
153
+ /**
154
+ * Aggregate interface providing all platform-specific services.
155
+ * Consumers that need multiple platform services can depend on this
156
+ * instead of injecting each service individually.
157
+ *
158
+ * All properties are optional — consumers should only use what they need.
159
+ */
160
+ export interface IPlatformContext {
161
+ /** Factory for creating file watchers */
162
+ readonly fileWatcherFactory?: IFileWatcherFactory;
163
+ /** Workspace-scoped key-value store (per-workspace state) */
164
+ readonly workspaceStore?: IKeyValueStore;
165
+ /** Global key-value store (cross-workspace state) */
166
+ readonly globalStore?: IKeyValueStore;
167
+ /** Secure storage for tokens and credentials */
168
+ readonly secretStore?: ISecretStore;
169
+ /** User-facing notifications */
170
+ readonly notifications?: INotificationService;
171
+ /** Output channel factory for structured logging */
172
+ readonly outputChannelFactory?: IOutputChannelFactory;
173
+ /** External browser interaction (OAuth2, etc.) */
174
+ readonly browser?: IExternalBrowserService;
175
+ /** Application metadata */
176
+ readonly appInfo?: IApplicationInfo;
177
+ }
178
+ /**
179
+ * Interface for file system operations.
180
+ * Allows mocking in tests and platform-agnostic code.
181
+ */
182
+ export interface IFileSystem {
183
+ readFile(filePath: string): Promise<string>;
184
+ writeFile(filePath: string, content: string): Promise<void>;
185
+ exists(filePath: string): Promise<boolean>;
186
+ mkdir(dirPath: string): Promise<void>;
187
+ glob(patterns: string[], cwd?: string): Promise<string[]>;
188
+ readDir(dirPath: string): Promise<string[]>;
189
+ isDirectory(filePath: string): Promise<boolean>;
190
+ }
191
+ import { HttpRequestOptions, HttpResponse } from './types';
192
+ /**
193
+ * Interface for executing HTTP requests.
194
+ */
195
+ export interface IHttpClient {
196
+ send(options: HttpRequestOptions): Promise<HttpResponse>;
197
+ }
198
+ /**
199
+ * Interface for logging.
200
+ */
201
+ export interface ILogger {
202
+ debug(message: string, ...args: any[]): void;
203
+ info(message: string, ...args: any[]): void;
204
+ warn(message: string, ...args: any[]): void;
205
+ error(message: string, ...args: any[]): void;
206
+ }
@@ -4,6 +4,8 @@
4
4
  * Core data types used throughout the framework.
5
5
  * Simplified design for maximum compatibility.
6
6
  */
7
+ import { ParsedCookie } from '../cookie/interfaces';
8
+ export type { ParsedCookie };
7
9
  /**
8
10
  * Unified Collection - the common format all parsers produce
9
11
  */
@@ -108,6 +110,31 @@ export interface RequestBody {
108
110
  format?: RawFormat;
109
111
  content?: any;
110
112
  }
113
+ /**
114
+ * Form data entry for multipart form-data bodies
115
+ */
116
+ export interface FormDataEntry {
117
+ key: string;
118
+ value: string;
119
+ type?: 'text' | 'file';
120
+ enabled?: boolean;
121
+ }
122
+ /**
123
+ * URL-encoded form entry
124
+ */
125
+ export interface UrlEncodedEntry {
126
+ key: string;
127
+ value: string;
128
+ enabled?: boolean;
129
+ }
130
+ /**
131
+ * GraphQL request content
132
+ */
133
+ export interface GraphQLContent {
134
+ query: string;
135
+ variables?: Record<string, unknown>;
136
+ operationName?: string;
137
+ }
111
138
  /**
112
139
  * Request settings
113
140
  */
@@ -127,41 +154,67 @@ export interface RequestSettings {
127
154
  export interface HttpRequest {
128
155
  method: string;
129
156
  url: string;
130
- headers: Record<string, string>;
157
+ headers?: Record<string, string>;
131
158
  body?: any;
132
159
  timeout?: number;
160
+ signal?: AbortSignal;
133
161
  settings?: RequestSettings;
134
162
  }
163
+ /**
164
+ * HTTP request options (alias for HttpRequest)
165
+ * Matches extension's HttpRequestOptions interface
166
+ */
167
+ export type HttpRequestOptions = HttpRequest;
135
168
  /**
136
169
  * HTTP response from execution
137
170
  */
138
171
  export interface HttpResponse {
139
172
  status: number;
140
173
  statusText: string;
141
- headers: Record<string, string>;
174
+ headers: Record<string, string | string[]>;
175
+ cookies: ParsedCookie[];
142
176
  body: any;
143
177
  time: number;
144
178
  size?: number;
145
- /** Parsed cookies from Set-Cookie headers */
146
- cookies?: Record<string, string>;
147
179
  }
148
180
  /**
149
- * Environment configuration
181
+ * Normalized request ready for execution pipeline.
182
+ * Contains unresolved variables — the executor resolves them before sending.
183
+ * Matches extension's ExecutionRequest.
150
184
  */
151
- export interface Environment {
185
+ export interface ExecutionRequest {
186
+ id: string;
152
187
  name: string;
153
- description?: string;
154
- variables: Record<string, string>;
188
+ method: string;
189
+ url: string;
155
190
  headers?: Record<string, string>;
191
+ query?: Record<string, string>;
192
+ body?: RequestBody | null;
193
+ bodyContentType?: string;
194
+ params?: Record<string, string>;
195
+ settings?: RequestSettings;
196
+ scripts?: RequestScripts;
197
+ auth?: RequestAuth;
198
+ }
199
+ /**
200
+ * Variable scopes for script/request execution.
201
+ * Matches extension's ExecutionVariables.
202
+ */
203
+ export interface ExecutionVariables {
204
+ variables: Record<string, string>;
205
+ collectionVariables?: Record<string, string>;
206
+ globals?: Record<string, string>;
207
+ sessionVariables?: Record<string, string>;
208
+ environmentVariables?: Record<string, string>;
156
209
  }
157
210
  /**
158
- * Resolved environment with all inherited values merged
211
+ * Environment configuration
159
212
  */
160
- export interface ResolvedEnvironment {
213
+ export interface Environment {
161
214
  name: string;
162
215
  description?: string;
163
216
  variables: Record<string, string>;
164
- headers: Record<string, string>;
217
+ headers?: Record<string, string>;
165
218
  }
166
219
  /**
167
220
  * Context available to scripts during execution
@@ -183,6 +236,8 @@ export interface ScriptContext {
183
236
  variables: Record<string, string>;
184
237
  /** Information about the current execution */
185
238
  info?: ScriptInfo;
239
+ /** Cookie jar for accessing/modifying cookies in scripts */
240
+ cookieJar?: any;
186
241
  }
187
242
  /**
188
243
  * Script execution metadata
@@ -193,6 +248,7 @@ export interface ScriptInfo {
193
248
  iterationCount?: number;
194
249
  requestName?: string;
195
250
  requestId?: string;
251
+ collectionName?: string;
196
252
  }
197
253
  /**
198
254
  * Result of script execution
@@ -305,4 +361,218 @@ export interface ForgeConfig {
305
361
  /** Whether to verify SSL certificates */
306
362
  strictSSL?: boolean;
307
363
  }
308
- //# sourceMappingURL=types.d.ts.map
364
+ /**
365
+ * JSON Schema compatible type (OAS 3.0 subset)
366
+ */
367
+ export type JSONSchema7 = Record<string, any>;
368
+ /**
369
+ * JSON-compatible value types (for response body)
370
+ */
371
+ export type JsonValue = string | number | boolean | null | JsonValue[] | {
372
+ [key: string]: JsonValue;
373
+ };
374
+ /**
375
+ * Header/Query entry with enabled flag (for CollectionRequest Array format)
376
+ */
377
+ export interface KeyValueEntry {
378
+ key: string;
379
+ value: string;
380
+ enabled?: boolean;
381
+ type?: 'string' | 'integer' | 'number' | 'boolean' | 'array';
382
+ required?: boolean;
383
+ description?: string;
384
+ format?: string;
385
+ enum?: string[];
386
+ deprecated?: boolean;
387
+ }
388
+ /**
389
+ * Path parameter entry with OpenAPI metadata
390
+ */
391
+ export interface PathParamEntry {
392
+ value: string;
393
+ type?: 'string' | 'integer' | 'number' | 'boolean';
394
+ description?: string;
395
+ format?: string;
396
+ enum?: string[];
397
+ deprecated?: boolean;
398
+ }
399
+ /**
400
+ * Per-property encoding metadata for multipart/form-data request bodies.
401
+ * Mirrors the OpenAPI 3.0 Encoding Object.
402
+ */
403
+ export interface EncodingDefinition {
404
+ contentType?: string;
405
+ style?: 'form' | 'spaceDelimited' | 'pipeDelimited' | 'deepObject';
406
+ explode?: boolean;
407
+ allowReserved?: boolean;
408
+ headers?: Record<string, {
409
+ description?: string;
410
+ schema: JSONSchema7;
411
+ }>;
412
+ }
413
+ /**
414
+ * Content definition for a single media type.
415
+ */
416
+ export interface ContentDefinition {
417
+ schema?: JSONSchema7;
418
+ examples?: Record<string, {
419
+ summary?: string;
420
+ value: any;
421
+ }>;
422
+ encoding?: Record<string, EncodingDefinition>;
423
+ }
424
+ /**
425
+ * Response definition for a specific HTTP status code.
426
+ */
427
+ export interface ResponseDefinition {
428
+ description?: string;
429
+ contentType?: string;
430
+ schema?: JSONSchema7;
431
+ examples?: Record<string, {
432
+ summary?: string;
433
+ value: any;
434
+ }>;
435
+ content?: Record<string, ContentDefinition>;
436
+ headers?: Record<string, {
437
+ description?: string;
438
+ schema: JSONSchema7;
439
+ }>;
440
+ }
441
+ /**
442
+ * Response schema definition with per-status response schemas.
443
+ */
444
+ export interface ResponseSchemaDefinition {
445
+ responses: Record<string, ResponseDefinition>;
446
+ components?: Record<string, JSONSchema7>;
447
+ }
448
+ /**
449
+ * Body schema definition for request bodies.
450
+ */
451
+ export interface BodySchemaDefinition {
452
+ contentType?: string;
453
+ schema: JSONSchema7;
454
+ components?: Record<string, JSONSchema7>;
455
+ content?: Record<string, ContentDefinition>;
456
+ encoding?: Record<string, EncodingDefinition>;
457
+ }
458
+ /**
459
+ * Basic authentication configuration
460
+ */
461
+ export interface BasicAuthConfig {
462
+ username: string;
463
+ password: string;
464
+ }
465
+ /**
466
+ * API Key authentication configuration
467
+ */
468
+ export interface ApiKeyConfig {
469
+ key: string;
470
+ value: string;
471
+ in?: 'header' | 'query';
472
+ }
473
+ /**
474
+ * OAuth2 authentication configuration
475
+ */
476
+ export interface OAuth2Config {
477
+ grantType: 'authorization_code' | 'client_credentials' | 'password' | 'implicit';
478
+ tokenUrl?: string;
479
+ authUrl?: string;
480
+ clientId?: string;
481
+ clientSecret?: string;
482
+ scope?: string;
483
+ username?: string;
484
+ password?: string;
485
+ accessToken?: string;
486
+ refreshToken?: string;
487
+ tokenPrefix?: string;
488
+ tokenField?: string;
489
+ callbackUrl?: string;
490
+ usePkce?: boolean;
491
+ pkceMethod?: 'S256' | 'plain';
492
+ audience?: string;
493
+ resource?: string;
494
+ extraParams?: Record<string, string>;
495
+ clientAuthentication?: 'header' | 'body';
496
+ state?: string;
497
+ }
498
+ /**
499
+ * Full request authentication configuration (matches extension's RequestAuth)
500
+ */
501
+ export interface RequestAuth {
502
+ type?: 'none' | 'inherit' | 'basic' | 'bearer' | 'apikey' | 'oauth2';
503
+ bearerToken?: string;
504
+ basicAuth?: BasicAuthConfig;
505
+ apikey?: ApiKeyConfig;
506
+ oauth2?: OAuth2Config;
507
+ }
508
+ /**
509
+ * Request scripts configuration
510
+ */
511
+ export interface RequestScripts {
512
+ preRequest?: string;
513
+ postResponse?: string;
514
+ }
515
+ /**
516
+ * Collection request - the on-disk/storage format
517
+ */
518
+ export interface CollectionRequest {
519
+ id: string;
520
+ name: string;
521
+ method: string;
522
+ url: string;
523
+ headers?: KeyValueEntry[];
524
+ query?: KeyValueEntry[];
525
+ body?: RequestBody | null;
526
+ bodyContentType?: string;
527
+ params?: Record<string, string | PathParamEntry>;
528
+ settings?: RequestSettings;
529
+ scripts?: RequestScripts;
530
+ auth?: RequestAuth;
531
+ description?: string;
532
+ disabled?: boolean;
533
+ deprecated?: boolean;
534
+ responseSchema?: ResponseSchemaDefinition;
535
+ bodySchema?: BodySchemaDefinition;
536
+ }
537
+ /**
538
+ * Encoded request body ready for HTTP transmission
539
+ */
540
+ export type RequestBodyEncoded = string | Buffer | null;
541
+ /**
542
+ * Resolved body ready for HTTP transmission
543
+ */
544
+ export interface ResolvedBody {
545
+ type: BodyType;
546
+ format?: RawFormat;
547
+ content: RequestBodyEncoded;
548
+ }
549
+ /**
550
+ * Fully prepared request ready for execution (all variables resolved)
551
+ */
552
+ export interface PreparedRequest {
553
+ url: string;
554
+ method: string;
555
+ headers: Record<string, string>;
556
+ body: ResolvedBody;
557
+ params: Record<string, string>;
558
+ query: Record<string, string>;
559
+ }
560
+ /**
561
+ * Complete execution result from running a request
562
+ */
563
+ export interface ExecutionResult {
564
+ requestId: string;
565
+ name: string;
566
+ executedRequest: PreparedRequest;
567
+ response: HttpResponse;
568
+ duration: number;
569
+ timestamp: number;
570
+ passed: boolean;
571
+ assertions: TestAssertion[];
572
+ consoleOutput?: string[];
573
+ modifiedVariables?: Record<string, string>;
574
+ modifiedEnvironmentVariables?: Record<string, string>;
575
+ modifiedCollectionVariables?: Record<string, string>;
576
+ modifiedSessionVariables?: Record<string, string>;
577
+ error?: string;
578
+ }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Dynamic Variables Utility
3
+ *
4
+ * Single Responsibility: Generate Postman-compatible dynamic variable values
5
+ * Handles: $randomInt, $timestamp, $guid, $uuid, $randomString, $randomHexadecimal, etc.
6
+ */
7
+ /**
8
+ * Dynamic variables supported by HTTP Forge (Postman-compatible)
9
+ */
10
+ export declare const DYNAMIC_VARIABLES: Record<string, (...args: any[]) => any>;
11
+ /**
12
+ * Check if a variable name is a dynamic variable
13
+ * @param varName - Variable name (without $ prefix)
14
+ * @returns True if this is a recognized dynamic variable
15
+ */
16
+ export declare function isDynamicVariable(varName: string): boolean;
17
+ /**
18
+ * Resolve a dynamic variable to its value
19
+ * @param varName - Variable name (without $ prefix)
20
+ * @param args - Optional arguments for parameterized variables
21
+ * @returns The generated value for the dynamic variable, or null if not recognized
22
+ */
23
+ export declare function resolveDynamicVariable(varName: string, args?: any[]): any;
24
+ /**
25
+ * Resolve all dynamic variables in a string
26
+ * @param text - Text containing {{$variableName}} patterns
27
+ * @returns Text with all dynamic variables replaced
28
+ */
29
+ export declare function resolveDynamicVariablesInString(text: string): string;
30
+ /**
31
+ * Scan an expression for $varName references and pre-resolve them as dynamic variables.
32
+ * Returns an augmented variables object so JS expressions like `$timestamp ?? 1` work
33
+ * (the sandbox needs `$timestamp` to be a defined identifier, not a ReferenceError).
34
+ *
35
+ * Only resolves simple $varName references (no parameterized args).
36
+ * Returns the original variables object unchanged if no dynamic vars are found.
37
+ */
38
+ export declare function augmentWithDynamicVars(expression: string, variables: Record<string, any>): Record<string, any>;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Expression Evaluator
3
+ *
4
+ * Single Responsibility: Evaluate JavaScript expressions within {{ }} templates
5
+ * Uses Node.js vm module for sandboxed execution with timeout protection
6
+ *
7
+ * Supports:
8
+ * - Simple expressions: {{ var1 + 'abc' }}
9
+ * - Math operations: {{ price * quantity }}
10
+ * - Ternary: {{ status === 'active' ? 'yes' : 'no' }}
11
+ * - String methods: {{ name.toUpperCase() }}
12
+ * - Template literals: {{ `Hello ${name}` }}
13
+ * - Built-in functions: Math.*, Date.now(), JSON.stringify(), etc.
14
+ *
15
+ * Security:
16
+ * - Sandboxed execution via vm.createContext (no access to require, process, fs, etc.)
17
+ * - 100ms timeout to prevent infinite loops
18
+ * - Only variables and safe built-ins are available
19
+ */
20
+ /**
21
+ * Check if an expression looks like a JS expression (not a simple variable name)
22
+ *
23
+ * Simple variable names like "myVar" or "$timestamp" should NOT be treated as expressions.
24
+ * Expressions contain operators, function calls, property access, etc.
25
+ */
26
+ export declare function isExpression(content: string): boolean;
27
+ /**
28
+ * Evaluate a JavaScript expression with the given variables in a sandboxed context
29
+ *
30
+ * @param expression - The JavaScript expression to evaluate
31
+ * @param variables - Variables available as bare identifiers in the expression
32
+ * @returns The result of the expression, or undefined if evaluation fails
33
+ */
34
+ export declare function evaluateExpression(expression: string, variables?: Record<string, any>): any;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Filter Engine
3
+ *
4
+ * Single Responsibility: Parse and apply pipe-based filters to values
5
+ * Thunder Client-compatible filter syntax: {{variable | filter1 | filter2(args)}}
6
+ *
7
+ * Supports:
8
+ * - Chained filters: {{variable | upper | substring(0, 5)}}
9
+ * - No-input filters using @: {{@ | filter1}}
10
+ * - Dynamic variable input: {{$guid | upper}}
11
+ * - Filter arguments: {{variable | replace("old", "new")}}
12
+ * - Variable references in args: {{number | add("otherVar")}}
13
+ */
14
+ /**
15
+ * Parsed filter with name and arguments
16
+ */
17
+ interface ParsedFilter {
18
+ name: string;
19
+ args: string[];
20
+ }
21
+ /**
22
+ * Result of parsing a template expression containing pipes
23
+ */
24
+ export interface ParsedFilterChain {
25
+ /** The input portion (variable name, $dynamic, or @ for no-input) */
26
+ input: string;
27
+ /** Ordered list of filters to apply */
28
+ filters: ParsedFilter[];
29
+ }
30
+ /**
31
+ * Parse a filter chain from a template expression
32
+ * e.g. "variable | upper | substring(0, 5)" → { input: "variable", filters: [...] }
33
+ *
34
+ * @param expression - The content inside {{ }}, e.g. "myVar | upper | replace('a', 'b')"
35
+ * @returns Parsed filter chain, or null if no filters present
36
+ */
37
+ export declare function parseFilterChain(expression: string): ParsedFilterChain | null;
38
+ /**
39
+ * Apply a chain of filters to a value
40
+ *
41
+ * @param value - The input value (resolved variable value)
42
+ * @param filters - Array of parsed filters to apply in order
43
+ * @param variables - Available variables (for variable reference args like add("otherVar"))
44
+ * @returns The filtered result
45
+ */
46
+ export declare function applyFilterChain(value: any, filters: ParsedFilter[], variables?: Record<string, any>): any;
47
+ export {};