@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,35 @@
1
+ /**
2
+ * Persistent Cookie Jar
3
+ *
4
+ * Adapts an ICookieService to the ICookieJar interface with write-through caching.
5
+ *
6
+ * - Maintains a local in-memory cache reflecting immediate changes (set/delete).
7
+ * - Allows scripts to read their own cookie modifications within the same execution.
8
+ * - Batches and persists all changes to the underlying ICookieService after execution.
9
+ *
10
+ * Extracted from extension's request-execution/PersistentCookieJar.ts.
11
+ */
12
+ import { Cookie, IAsyncCookieService, ICookieService } from './interfaces';
13
+ import { ICookieJar } from '../script/interfaces';
14
+ export declare class PersistentCookieJar implements ICookieJar {
15
+ private cookieService;
16
+ /** Local cache that reflects script modifications */
17
+ private localCache;
18
+ /** Track pending operations to batch them after script execution */
19
+ private pendingOperations;
20
+ constructor(cookieService: ICookieService | IAsyncCookieService);
21
+ get(name: string, domain?: string): Cookie | undefined;
22
+ has(name: string, domain?: string): boolean;
23
+ set(cookie: Cookie): void;
24
+ delete(name: string, domain?: string, path?: string): boolean;
25
+ getAll(domain?: string): Cookie[];
26
+ getCookiesForDomain(domain: string): Cookie[];
27
+ setCookiesFromResponse(url: string, headers: Record<string, string | string[]>): Promise<void>;
28
+ getCookieHeader(url: string): string | undefined;
29
+ clear(): void;
30
+ /**
31
+ * Flush all pending cookie operations to the underlying service.
32
+ * Should be called after script execution completes.
33
+ */
34
+ flush(): Promise<void>;
35
+ }
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Environment Configuration Service
3
+ *
4
+ * Platform-agnostic — uses IKeyValueStore for persistence instead of
5
+ * VS Code's workspaceState/globalState.
6
+ */
7
+ import { IEnvironmentConfigService, ImportedEnvironment, LocalConfig, ResolvedEnvironment, SharedConfig } from './interfaces';
8
+ import { IKeyValueStore } from '../types/platform';
9
+ import { IConfigService } from '../config';
10
+ export declare class EnvironmentConfigService implements IEnvironmentConfigService {
11
+ private workspaceFolder;
12
+ private workspaceStore;
13
+ private configService;
14
+ private environmentsPath;
15
+ private sharedConfigPath;
16
+ private localConfigPath;
17
+ private historiesPath;
18
+ private sharedConfig;
19
+ private localConfig;
20
+ private selectedEnvironment;
21
+ /**
22
+ * In-memory Local Values for variables (not persisted)
23
+ * These are set via forge.*.set() in scripts and override file values
24
+ * Cleared when the process exits
25
+ */
26
+ private localGlobalValues;
27
+ private localEnvironmentValues;
28
+ constructor(workspaceFolder: string, workspaceStore: IKeyValueStore, configService: IConfigService);
29
+ getWorkspaceFolder(): string;
30
+ getRootPath(): string;
31
+ loadConfigs(): void;
32
+ getSharedConfig(): SharedConfig | null;
33
+ getLocalConfig(): LocalConfig | null;
34
+ getEnvironmentNames(): string[];
35
+ getSelectedEnvironment(): string;
36
+ setSelectedEnvironment(envName: string): Promise<void>;
37
+ setEnvironmentVariable(key: string, value: unknown): void;
38
+ deleteEnvironmentVariable(key: string): void;
39
+ clearEnvironmentVariables(): void;
40
+ getEnvironmentVariableLocal(key: string): string | undefined;
41
+ getEnvironmentVariableLocals(): Record<string, string>;
42
+ setGlobalVariable(key: string, value: unknown): void;
43
+ getGlobalVariable(key: string): string | undefined;
44
+ getGlobalVariableLocal(key: string): string | undefined;
45
+ getGlobalVariables(): Record<string, string>;
46
+ getGlobalVariableLocals(): Record<string, string>;
47
+ deleteGlobalVariable(key: string): void;
48
+ clearGlobalVariables(): void;
49
+ private getSessionStateKey;
50
+ setSessionVariable(key: string, value: unknown): Promise<void>;
51
+ getSessionVariable(key: string): string | undefined;
52
+ getSessionVariables(): Record<string, string>;
53
+ deleteSessionVariable(key: string): Promise<void>;
54
+ clearSessionVariables(): Promise<void>;
55
+ hasSessionVariable(key: string): boolean;
56
+ getResolvedEnvironment(envName?: string): ResolvedEnvironment | null;
57
+ resolveVariables(input: string, envName?: string): string;
58
+ exportEnvironmentsToFolder(outDir: string, mergeGlobals?: boolean): void;
59
+ resolveVariablesWithExtra(input: string, extraVariables: Record<string, string>, envName?: string): string;
60
+ resolveVariablesInObject<T>(obj: T, envName?: string): T;
61
+ resolveVariablesInObjectWithExtra<T>(obj: T, extraVariables: Record<string, string>, envName?: string): T;
62
+ getHistoriesPath(): string;
63
+ getSharedConfigPath(): string;
64
+ getLocalConfigPath(): string;
65
+ getEnvironmentConfigPath(envName: string): string;
66
+ localConfigExists(): boolean;
67
+ saveSharedConfig(config: SharedConfig): void;
68
+ saveLocalConfig(config: LocalConfig): void;
69
+ importPostmanEnvironmentFile(filePath: string): ImportedEnvironment;
70
+ saveEnvLocalConfig(envName: string, variables: Record<string, string>): void;
71
+ getEnvLocalPath(envName: string): string;
72
+ private isSystemEnvironmentFile;
73
+ private getEnvLocalConfigPath;
74
+ private loadFolderConfigs;
75
+ private saveFolderSharedConfig;
76
+ reload(): void;
77
+ getAllEnvironments(): Array<{
78
+ id: string;
79
+ name: string;
80
+ active: boolean;
81
+ variables: Record<string, string>;
82
+ }>;
83
+ setActiveEnvironment(environmentId: string): Promise<void>;
84
+ createEnvironment(name: string): Promise<void>;
85
+ deleteEnvironment(environmentId: string): Promise<void>;
86
+ duplicateEnvironment(environmentId: string, newName: string): Promise<void>;
87
+ renameEnvironment(environmentId: string, newName: string): Promise<void>;
88
+ private validateEnvironmentName;
89
+ private validateEnvironmentExists;
90
+ private validateEnvironmentNameNotTaken;
91
+ private validateConfigLoaded;
92
+ updateEnvironmentVariables(environmentId: string, variables: Record<string, string>): Promise<void>;
93
+ private loadJsonFile;
94
+ private saveJsonFile;
95
+ }
@@ -4,7 +4,7 @@
4
4
  * Single Responsibility: Resolve environment variables for request execution
5
5
  * Dependency Inversion: Implements IEnvironmentStore interface
6
6
  */
7
- import { IEnvironmentStore } from '../interfaces';
7
+ import { IEnvironmentStore } from './interfaces';
8
8
  /**
9
9
  * Environment definition
10
10
  */
@@ -15,9 +15,11 @@ export interface Environment {
15
15
  inherits?: string;
16
16
  }
17
17
  /**
18
- * Environment configuration
18
+ * Environment store configuration (for EnvironmentResolver)
19
+ * Note: Named EnvironmentStoreConfig to avoid conflict with
20
+ * interfaces/environment-config-service.ts EnvironmentConfig
19
21
  */
20
- export interface EnvironmentConfig {
22
+ export interface EnvironmentStoreConfig {
21
23
  /** Global variables (available in all environments) */
22
24
  globalVariables?: Record<string, string>;
23
25
  /** Environment definitions */
@@ -34,7 +36,7 @@ export declare class EnvironmentResolver implements IEnvironmentStore {
34
36
  /** In-memory values */
35
37
  private sessionGlobals;
36
38
  private sessionEnvironmentValues;
37
- constructor(config: EnvironmentConfig);
39
+ constructor(config: EnvironmentStoreConfig);
38
40
  /**
39
41
  * Get a single variable value
40
42
  */
@@ -88,4 +90,3 @@ export declare class EnvironmentResolver implements IEnvironmentStore {
88
90
  */
89
91
  static fromVariables(variables: Record<string, string>, name?: string): EnvironmentResolver;
90
92
  }
91
- //# sourceMappingURL=environment-resolver.d.ts.map
@@ -30,7 +30,7 @@
30
30
  * env.get('token'); // 'abc'
31
31
  * ```
32
32
  */
33
- import { IEnvironmentStore, IVariableInterpolator } from '../interfaces';
33
+ import { IEnvironmentStore, IVariableInterpolator } from './interfaces';
34
34
  import { EnvironmentResolver } from './environment-resolver';
35
35
  /**
36
36
  * ForgeEnv interface - the public API for environment management
@@ -163,4 +163,3 @@ export declare class ForgeEnv implements IForgeEnv {
163
163
  */
164
164
  static fromResolver(resolver: EnvironmentResolver): ForgeEnv;
165
165
  }
166
- //# sourceMappingURL=forge-env.d.ts.map
@@ -0,0 +1,139 @@
1
+ /**
2
+ * Environment Configuration Service Interface
3
+ *
4
+ * Interface Segregation: Separated into focused sub-interfaces
5
+ * Dependency Inversion: Consumers depend on this abstraction
6
+ */
7
+ /**
8
+ * Environment configuration structure
9
+ */
10
+ export interface EnvironmentConfig {
11
+ description?: string;
12
+ requiresConfirmation?: boolean;
13
+ variables?: Record<string, string>;
14
+ }
15
+ /**
16
+ * Shared configuration file structure
17
+ */
18
+ export interface SharedConfig {
19
+ environments: Record<string, EnvironmentConfig>;
20
+ globalVariables?: Record<string, string>;
21
+ defaultHeaders?: Record<string, string>;
22
+ }
23
+ /**
24
+ * Local configuration file structure
25
+ */
26
+ export interface LocalConfig {
27
+ credentials?: Record<string, {
28
+ variables?: Record<string, string>;
29
+ }>;
30
+ variables?: Record<string, string>;
31
+ }
32
+ /**
33
+ * Resolved environment with all inherited values
34
+ */
35
+ export interface ResolvedEnvironment {
36
+ name: string;
37
+ description?: string;
38
+ requiresConfirmation?: boolean;
39
+ headers: Record<string, string>;
40
+ variables: Record<string, string>;
41
+ }
42
+ /**
43
+ * Representation of an imported environment (from Postman)
44
+ */
45
+ export interface ImportedEnvironment {
46
+ name: string;
47
+ variables: Record<string, string>;
48
+ description?: string;
49
+ }
50
+ /**
51
+ * Import operations for environments
52
+ */
53
+ export interface IEnvironmentImporter {
54
+ importPostmanEnvironmentFile(filePath: string): ImportedEnvironment | null;
55
+ }
56
+ /**
57
+ * Read operations for environment configuration
58
+ */
59
+ export interface IEnvironmentConfigReader {
60
+ getWorkspaceFolder(): string;
61
+ getRootPath(): string;
62
+ getEnvironmentNames(): string[];
63
+ getSelectedEnvironment(): string;
64
+ getSharedConfig(): SharedConfig | null;
65
+ getSharedConfigPath(): string;
66
+ getLocalConfig(): LocalConfig | null;
67
+ getLocalConfigPath(): string;
68
+ getEnvironmentConfigPath(envName: string): string;
69
+ getEnvLocalPath(envName: string): string;
70
+ getResolvedEnvironment(envName: string): ResolvedEnvironment | null;
71
+ }
72
+ /**
73
+ * Write operations for environment configuration
74
+ */
75
+ export interface IEnvironmentConfigWriter {
76
+ saveSharedConfig(config: SharedConfig): void;
77
+ saveLocalConfig(config: LocalConfig): void;
78
+ }
79
+ /**
80
+ * Environment selection operations
81
+ */
82
+ export interface IEnvironmentSelector {
83
+ setSelectedEnvironment(envName: string): Promise<void>;
84
+ }
85
+ /**
86
+ * Variable resolution operations
87
+ */
88
+ export interface IVariableResolver {
89
+ resolveVariables(text: string, envName?: string): string;
90
+ resolveVariablesWithExtra(text: string, extraVariables: Record<string, string>, envName?: string): string;
91
+ resolveVariablesInObject<T extends Record<string, any>>(obj: T, envName?: string): T;
92
+ resolveVariablesInObjectWithExtra<T extends Record<string, any>>(obj: T, extraVariables: Record<string, string>, envName?: string): T;
93
+ }
94
+ /**
95
+ * Variable management operations (for scripts)
96
+ */
97
+ export interface IVariableManager {
98
+ setEnvironmentVariable(key: string, value: unknown): void;
99
+ deleteEnvironmentVariable(key: string): void;
100
+ clearEnvironmentVariables(): void;
101
+ getEnvironmentVariableLocals(): Record<string, string>;
102
+ setGlobalVariable(key: string, value: unknown): void;
103
+ getGlobalVariable(key: string): string | undefined;
104
+ deleteGlobalVariable(key: string): void;
105
+ clearGlobalVariables(): void;
106
+ setSessionVariable(key: string, value: unknown): void;
107
+ deleteSessionVariable(key: string): Promise<void>;
108
+ clearSessionVariables(): Promise<void>;
109
+ getSessionVariables(): Record<string, string>;
110
+ getGlobalVariables(): Record<string, string>;
111
+ }
112
+ /**
113
+ * Full environment configuration service interface
114
+ */
115
+ export interface IEnvironmentConfigService extends IEnvironmentConfigReader, IEnvironmentConfigWriter, IEnvironmentSelector, IVariableResolver, IVariableManager {
116
+ loadConfigs(): void;
117
+ exportEnvironmentsToFolder(outDir: string, mergeGlobals?: boolean): void;
118
+ }
119
+ /**
120
+ * Interface for storing and retrieving environment variables.
121
+ */
122
+ export interface IEnvironmentStore {
123
+ get(key: string): string | undefined;
124
+ set(key: string, value: string): void;
125
+ getAll(): Record<string, string>;
126
+ getActive(): string | undefined;
127
+ setActive(name: string): void;
128
+ getVariables(environmentName?: string): Record<string, string>;
129
+ }
130
+ /**
131
+ * Interface for interpolating variables in strings.
132
+ * Handles {{variable}} syntax replacement.
133
+ * @deprecated Use IVariableResolver for environment-aware resolution
134
+ */
135
+ export interface IVariableInterpolator {
136
+ interpolate(input: string, variables: Record<string, string>): string;
137
+ extractVariables(input: string): string[];
138
+ interpolateObject<T>(obj: T, variables: Record<string, string>): T;
139
+ }
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Variable Interpolator / Resolver
3
+ *
4
+ * Single Responsibility: Resolve template variables in strings and objects
5
+ *
6
+ * Features:
7
+ * - Regular variable substitution ({{myVar}} → value)
8
+ * - Dynamic variables ({{$timestamp}}, {{$randomInt(1, 100)}}, etc.)
9
+ * - Pipe-based filters (Thunder Client-compatible): {{variable | upper | replace("a", "b")}}
10
+ * - JavaScript expression evaluation: {{price * quantity}}
11
+ * - Context-aware escaping (avoids breaking quoted strings)
12
+ * - Extra variables with highest precedence
13
+ * - Recursive object traversal
14
+ * - Generic type preservation for object interpolation
15
+ *
16
+ * Resolution order (5-step pipeline):
17
+ * 1. $dynamic variables: {{$guid}}, {{$randomInt(1, 100)}}
18
+ * 2. Filter chains: {{myVar | upper | substring(0, 5)}}
19
+ * 3. Simple variable lookup: {{myVar}}
20
+ * 4. JavaScript expressions: {{price * quantity + 10}}
21
+ * 5. Return original {{...}} if nothing matched
22
+ */
23
+ import { IVariableInterpolator } from './interfaces';
24
+ /**
25
+ * Configuration for variable resolution
26
+ */
27
+ export interface VariableResolverConfig {
28
+ globals: Record<string, string>;
29
+ collectionVariables: Record<string, string>;
30
+ environmentVariables: Record<string, string>;
31
+ sessionVariables: Record<string, string>;
32
+ variables: Record<string, string>;
33
+ }
34
+ /**
35
+ * Variable Resolver - Resolves {{varName}} patterns in strings and objects
36
+ * Uses a 5-step pipeline: $dynamic → filter chains → simple lookup → JS expressions → passthrough
37
+ * Variable precedence: globals > collection > environment > session > request > extra
38
+ */
39
+ export declare class VariableResolver {
40
+ private readonly allVariables;
41
+ constructor(config: VariableResolverConfig);
42
+ /**
43
+ * Resolve variables in a string ({{varName}} syntax)
44
+ * Uses the full 5-step pipeline with optional escaping for quoted strings
45
+ */
46
+ resolveString(str: string, escape?: boolean): string;
47
+ /**
48
+ * Resolve variables in a string with additional extra variables
49
+ * Extra variables take highest precedence
50
+ */
51
+ resolveStringWithExtra(str: string, extraVariables: Record<string, string>, escape?: boolean): string;
52
+ /**
53
+ * Resolve variables in an object recursively
54
+ */
55
+ resolveObject(obj: any, escape?: boolean): any;
56
+ /**
57
+ * Resolve variables in an object with extra variables
58
+ */
59
+ resolveObjectWithExtra(obj: any, extraVariables: Record<string, string>, escape?: boolean): any;
60
+ /**
61
+ * Core 5-step resolution pipeline for template content inside {{ }}
62
+ */
63
+ private resolveTemplateContent;
64
+ /**
65
+ * Resolve the input portion of a filter chain
66
+ * Handles: @ (no-input), string literals, $dynamic variable, variable name, JS expression
67
+ */
68
+ private resolveFilterInput;
69
+ /**
70
+ * Escape special characters for string context
71
+ */
72
+ private escapeForString;
73
+ /**
74
+ * Determine if position is inside a quoted string and which quote type
75
+ */
76
+ private getStringContext;
77
+ }
78
+ /**
79
+ * VariableInterpolator — backward-compatible wrapper around VariableResolver
80
+ * Implements IVariableInterpolator interface using the 5-step resolution pipeline
81
+ */
82
+ export declare class VariableInterpolator implements IVariableInterpolator {
83
+ /**
84
+ * Replace {{variable}} placeholders with values using the 5-step pipeline
85
+ * Automatically escapes values when inside quoted strings
86
+ */
87
+ interpolate(input: string, variables: Record<string, string>): string;
88
+ /**
89
+ * Extract variable names from a string
90
+ */
91
+ extractVariables(input: string): string[];
92
+ /**
93
+ * Replace variables in all string values of an object (recursive)
94
+ */
95
+ interpolateObject<T>(obj: T, variables: Record<string, string>): T;
96
+ }
97
+ /**
98
+ * Create a variable resolver from configuration
99
+ */
100
+ export declare function createVariableResolver(config: VariableResolverConfig): VariableResolver;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Collection Request Executor Interface
3
+ *
4
+ * Defines the contract for executing a single collection request with full Postman parity:
5
+ * - Script execution order: Collection → Folder(s) → Request (pre-request)
6
+ * - Script execution order: Request → Folder(s) → Collection (post-response)
7
+ * - Supports nested folder scripts (multiple levels)
8
+ * - JavaScript variables declared in pre-request are accessible in post-response (shared VM session)
9
+ */
10
+ import { ExecutionRequest, ExecutionResult } from '../types/types';
11
+ /**
12
+ * Console output streaming callback
13
+ */
14
+ export type ConsoleOutputCallback = (output: string[]) => void;
15
+ /**
16
+ * Collection Request Executor Interface
17
+ *
18
+ * Executes a single request within a collection context, with full
19
+ * pre-request/post-response script chain support.
20
+ */
21
+ export interface ICollectionRequestExecutor {
22
+ /**
23
+ * Execute a request with full Postman parity.
24
+ *
25
+ * Flow:
26
+ * Collection pre-request → Folder(s) pre-request → Request pre-request
27
+ * → HTTP call →
28
+ * Request post-response → Folder(s) post-response → Collection post-response
29
+ *
30
+ * @param request - The request to execute
31
+ * @param variables - Current variable context (may include data file variables)
32
+ * @param signal - Optional AbortSignal for cancellation
33
+ * @returns ExecutionResult with response, assertions, timing, etc.
34
+ */
35
+ execute(request: ExecutionRequest, variables: Record<string, string>, signal?: AbortSignal): Promise<ExecutionResult>;
36
+ }
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Collection Request Executor
3
+ *
4
+ * Executes a single collection request with full Postman parity:
5
+ * - Script execution order: Collection → Folder(s) → Request (pre-request)
6
+ * - Script execution order: Request → Folder(s) → Collection (post-response)
7
+ * - Supports nested folder scripts (multiple levels)
8
+ * - JavaScript variables declared in pre-request are accessible in post-response (shared VM session)
9
+ *
10
+ * Extracted from extension's request-execution/collection-request-executor.ts.
11
+ * Platform-independent — no vscode dependency.
12
+ */
13
+ import { ExecutionRequest, ExecutionResult, PreparedRequest, RequestScripts } from '../types/types';
14
+ import { ICookieJar, IScriptExecutor } from '../script/interfaces';
15
+ import { IEnvironmentConfigService } from '../environment/interfaces';
16
+ import { ConsoleOutputCallback, ICollectionRequestExecutor } from './collection-request-executor-interfaces';
17
+ import { IHttpRequestService } from '../http/interfaces';
18
+ import { IRequestPreparer } from './request-preparer-interfaces';
19
+ /**
20
+ * Enhanced implementation with Postman parity.
21
+ * Supports: pre-request scripts, post-response scripts, cookies, settings,
22
+ * collection/folder scripts.
23
+ */
24
+ export declare class CollectionRequestExecutor implements ICollectionRequestExecutor {
25
+ private readonly httpService;
26
+ private readonly scriptExecutor;
27
+ private readonly envConfigService;
28
+ private readonly requestPreparer;
29
+ private readonly environment;
30
+ private readonly cookieJar?;
31
+ private readonly collectionScripts?;
32
+ private readonly folderScriptsChain?;
33
+ private readonly onConsoleOutput?;
34
+ private readonly collectionName?;
35
+ private readonly iteration?;
36
+ 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
+ /**
39
+ * Execute a request with full Postman parity.
40
+ */
41
+ execute(request: ExecutionRequest, variables: Record<string, string>, signal?: AbortSignal): Promise<ExecutionResult>;
42
+ protected executeWithSession(request: ExecutionRequest, variables: Record<string, string>, signal: AbortSignal | undefined, startTime: number): Promise<ExecutionResult>;
43
+ /**
44
+ * Collect pre-request scripts in order: Collection → Folder(s) → Request
45
+ */
46
+ private collectPreRequestScripts;
47
+ /**
48
+ * Collect post-response scripts in order: Request → Folder(s) → Collection
49
+ */
50
+ private collectPostResponseScripts;
51
+ /**
52
+ * Handle execution errors — returns a failed ExecutionResult.
53
+ *
54
+ * The response body is set according to `errorBodyFormat`:
55
+ * - `'text'` → plain-text error message (default, safe for CLI / headless)
56
+ * - `'html'` → styled HTML suitable for a webview Response tab
57
+ * - `'both'` → HTML body **and** `error` field with plain-text message
58
+ *
59
+ * Protected so subclasses can override error formatting entirely.
60
+ */
61
+ protected handleError(request: ExecutionRequest, prepared: PreparedRequest | null, error: any, startTime: number): ExecutionResult;
62
+ /**
63
+ * The format used for error response bodies.
64
+ *
65
+ * Override in a subclass (or set via constructor option) to switch formats:
66
+ * - `'text'` — plain text (default)
67
+ * - `'html'` — HTML for webview display
68
+ * - `'both'` — HTML body + plain `error` field
69
+ */
70
+ protected get errorBodyFormat(): 'text' | 'html' | 'both';
71
+ /**
72
+ * Build a styled HTML string from an error message and optional stack trace.
73
+ * Useful for rendering errors in a webview Response tab.
74
+ *
75
+ * Static so callers can use it independently of an executor instance.
76
+ */
77
+ static formatErrorAsHtml(message: string, stack?: string): string;
78
+ }
@@ -4,10 +4,11 @@
4
4
  * Single Responsibility: Orchestrate the complete request execution flow
5
5
  * Facade Pattern: Provides simplified interface to complex subsystem
6
6
  */
7
- import { IHttpClient, IRequestPreprocessor } from '../interfaces';
8
- import { HttpRequest, HttpResponse, RequestOverrides, ScriptResult, UnifiedCollection, UnifiedRequest } from '../interfaces/types';
9
- import { IForgeEnv } from './forge-env';
10
- import { ScriptPipeline } from './script-pipeline';
7
+ import { IHttpClient } from '../types/platform';
8
+ import { IScriptExecutor } from '../script/interfaces';
9
+ import { IRequestPreprocessor } from '../http/request-preprocessor';
10
+ import { HttpRequest, HttpResponse, RequestOverrides, ScriptResult, UnifiedCollection, UnifiedRequest } from '../types/types';
11
+ import { IForgeEnv } from '../environment/forge-env';
11
12
  /**
12
13
  * Options for request execution
13
14
  */
@@ -24,6 +25,10 @@ export interface ExecuteOptions {
24
25
  additionalVariables?: Record<string, string>;
25
26
  /** Timeout override */
26
27
  timeout?: number;
28
+ /** Callback when scripts modify session variables */
29
+ onSessionChange?: (action: 'set' | 'unset' | 'clear', key?: string, value?: string) => void;
30
+ /** Callback when scripts modify environment variables */
31
+ onEnvironmentChange?: (action: 'set' | 'unset' | 'clear', key?: string, value?: string) => void;
27
32
  }
28
33
  /**
29
34
  * Complete execution result
@@ -51,15 +56,17 @@ export interface ExecuteResult {
51
56
  export declare class RequestExecutor {
52
57
  private readonly httpClient;
53
58
  private readonly forgeEnv;
54
- private readonly scriptPipeline;
59
+ private readonly cookieJar?;
55
60
  private readonly preprocessor?;
56
- private moduleLoader?;
57
- constructor(httpClient: IHttpClient, forgeEnv: IForgeEnv, scriptPipeline: ScriptPipeline, preprocessor?: IRequestPreprocessor | undefined, options?: {
61
+ private scriptExecutor;
62
+ constructor(httpClient: IHttpClient, forgeEnv: IForgeEnv, cookieJar?: any | undefined, // ICookieJar - optional for cookie support in scripts
63
+ preprocessor?: IRequestPreprocessor | undefined, options?: {
58
64
  forgeRoot?: string;
65
+ scriptExecutor?: IScriptExecutor;
59
66
  });
60
67
  /**
61
68
  * Execute a request with full pipeline
62
- * Uses ScriptSession for shared VM context between pre-request and post-response scripts
69
+ * Uses RequestScriptSession for shared VM context between pre-request and post-response scripts
63
70
  */
64
71
  execute(request: UnifiedRequest, collection: UnifiedCollection, options?: ExecuteOptions): Promise<ExecuteResult>;
65
72
  /**
@@ -79,8 +86,13 @@ export declare class RequestExecutor {
79
86
  */
80
87
  private interpolateRequest;
81
88
  /**
82
- * Create script context
89
+ * Build script chain for a request
90
+ * Returns scripts in execution order: collection → folders → request
83
91
  */
84
- private createScriptContext;
92
+ private buildScriptChain;
93
+ /**
94
+ * Find the folder path from collection root to a request
95
+ * Returns array of folders in order from root to parent
96
+ */
97
+ private findFolderPath;
85
98
  }
86
- //# sourceMappingURL=request-executor.d.ts.map
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Request Preparer Interface
3
+ *
4
+ * Defines the contract for preparing HTTP requests before execution.
5
+ * Handles variable resolution, header merging, auth injection, body encoding.
6
+ *
7
+ * Used by both Request Tester (manual) and Collection Runner (batch).
8
+ */
9
+ import { ResolvedEnvironment } from '../environment/interfaces';
10
+ import { ExecutionRequest, PreparedRequest } from '../types/types';
11
+ /**
12
+ * Request Preparer Service Interface
13
+ *
14
+ * Extracted from extension's request-execution-handler.ts prepareRequest method.
15
+ * Shares request preparation logic between Request Tester and Collection Runner.
16
+ */
17
+ export interface IRequestPreparer {
18
+ /**
19
+ * Prepare a request for execution.
20
+ *
21
+ * Handles:
22
+ * - Variable resolution in params, query, headers, body, URL
23
+ * - Header merging (environment + request headers)
24
+ * - Authentication (Bearer, Basic, API Key, OAuth2)
25
+ * - Body encoding based on bodyType
26
+ * - Content-Type header auto-setting
27
+ * - URL building with path params, query params
28
+ *
29
+ * @param input - Request input data (ExecutionRequest format)
30
+ * @param environment - Environment name for variable resolution
31
+ * @param resolvedEnv - Resolved environment configuration
32
+ * @param extraVariables - Optional extra variables (for data files, script variables)
33
+ * @returns Prepared request ready for HTTP execution
34
+ */
35
+ prepareRequest(input: ExecutionRequest, environment: string, resolvedEnv: ResolvedEnvironment, extraVariables?: Record<string, string>): Promise<PreparedRequest>;
36
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Request Preparer
3
+ *
4
+ * Prepares HTTP requests for execution by resolving variables,
5
+ * merging headers, applying authentication, and encoding body.
6
+ *
7
+ * Extracted from extension's request-preparer.ts.
8
+ * Platform-independent — uses IApplicationInfo instead of vscode.extensions.
9
+ *
10
+ * Used by both Request Tester (manual) and Collection Runner (batch).
11
+ */
12
+ import { IRequestPreprocessor } from '../http/request-preprocessor';
13
+ import { ExecutionRequest, PreparedRequest } from '../types/types';
14
+ import { IEnvironmentConfigService, ResolvedEnvironment } from '../environment/interfaces';
15
+ import { IHttpRequestService } from '../http/interfaces';
16
+ import { IOAuth2TokenManager } from '../auth/interfaces';
17
+ import { IApplicationInfo } from '../types/platform';
18
+ import { IRequestPreparer } from './request-preparer-interfaces';
19
+ /**
20
+ * RequestPreparer implementation
21
+ *
22
+ * Logic extracted from extension's request-execution-handler.ts prepareRequest method.
23
+ * Shared by Request Tester (manual requests) and Collection Runner (batch requests).
24
+ */
25
+ export declare class RequestPreparer implements IRequestPreparer {
26
+ private readonly envConfigService;
27
+ private readonly httpService;
28
+ private readonly preprocessor;
29
+ private readonly tokenManager?;
30
+ private readonly appInfo?;
31
+ constructor(envConfigService: IEnvironmentConfigService, httpService: IHttpRequestService, preprocessor: IRequestPreprocessor, tokenManager?: IOAuth2TokenManager | undefined, appInfo?: IApplicationInfo | undefined);
32
+ prepareRequest(input: ExecutionRequest, environment: string, resolvedEnv: ResolvedEnvironment, extraVariables?: Record<string, string>): Promise<PreparedRequest>;
33
+ private applyOAuth2;
34
+ private applyApiKey;
35
+ }