@http-forge/core 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/README.md +217 -43
  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 +45 -0
  10. package/dist/collection/folder-collection-store.d.ts +175 -0
  11. package/dist/collection/folder-io.d.ts +113 -0
  12. package/dist/collection/interfaces.d.ts +32 -0
  13. package/dist/collection/json-collection-loader.d.ts +95 -0
  14. package/dist/{services → collection}/parser-registry.d.ts +1 -2
  15. package/dist/config/config-service.d.ts +79 -0
  16. package/dist/config/config.interface.d.ts +140 -0
  17. package/dist/config/default-config.d.ts +29 -0
  18. package/dist/config/index.d.ts +6 -0
  19. package/dist/container.d.ts +26 -19
  20. package/dist/{implementations → cookie}/cookie-jar.d.ts +2 -3
  21. package/dist/cookie/cookie-service.d.ts +98 -0
  22. package/dist/{implementations → cookie}/cookie-utils.d.ts +1 -2
  23. package/dist/cookie/in-memory-cookie-jar.d.ts +44 -0
  24. package/dist/{interfaces/cookie.d.ts → cookie/interfaces.d.ts} +22 -3
  25. package/dist/cookie/persistent-cookie-jar.d.ts +35 -0
  26. package/dist/di/core-bootstrap.d.ts +25 -0
  27. package/dist/di/index.d.ts +11 -0
  28. package/dist/di/platform-adapters.d.ts +53 -0
  29. package/dist/di/service-container.d.ts +97 -0
  30. package/dist/di/service-identifiers.d.ts +34 -0
  31. package/dist/environment/environment-config-service.d.ts +98 -0
  32. package/dist/environment/environment-file-loader.d.ts +42 -0
  33. package/dist/{services → environment}/environment-resolver.d.ts +6 -5
  34. package/dist/{services → environment}/forge-env.d.ts +1 -2
  35. package/dist/environment/interfaces.d.ts +139 -0
  36. package/dist/environment/variable-interpolator.d.ts +100 -0
  37. package/dist/execution/collection-request-executor-interfaces.d.ts +36 -0
  38. package/dist/execution/collection-request-executor.d.ts +78 -0
  39. package/dist/{services → execution}/request-executor.d.ts +23 -11
  40. package/dist/execution/request-preparer-interfaces.d.ts +36 -0
  41. package/dist/execution/request-preparer.d.ts +35 -0
  42. package/dist/graphql/graphql-completion-provider.d.ts +39 -0
  43. package/dist/graphql/graphql-schema-service.d.ts +89 -0
  44. package/dist/{interfaces/history.d.ts → history/history-interfaces.d.ts} +29 -6
  45. package/dist/history/request-history-service-interfaces.d.ts +43 -0
  46. package/dist/history/request-history-service.d.ts +133 -0
  47. package/dist/{implementations → history}/request-history.d.ts +2 -3
  48. package/dist/{implementations → http}/fetch-http-client.d.ts +4 -5
  49. package/dist/http/http-request-service.d.ts +36 -0
  50. package/dist/{implementations → http}/interceptor-chain.d.ts +1 -2
  51. package/dist/http/interfaces.d.ts +25 -0
  52. package/dist/http/merge-request-settings.d.ts +12 -0
  53. package/dist/{implementations → http}/native-http-client.d.ts +6 -15
  54. package/dist/{implementations → http}/request-preprocessor.d.ts +1 -2
  55. package/dist/{services → http}/url-builder.d.ts +7 -10
  56. package/dist/import-export/import-postman-environment.d.ts +21 -0
  57. package/dist/import-export/rest-client-export.d.ts +35 -0
  58. package/dist/index.d.ts +94 -6
  59. package/dist/index.js +262 -35
  60. package/dist/index.mjs +262 -35
  61. package/dist/openapi/example-generator.d.ts +26 -0
  62. package/dist/openapi/history-analyzer.d.ts +29 -0
  63. package/dist/openapi/index.d.ts +16 -0
  64. package/dist/openapi/interfaces.d.ts +42 -0
  65. package/dist/openapi/openapi-exporter.d.ts +73 -0
  66. package/dist/openapi/openapi-importer.d.ts +72 -0
  67. package/dist/openapi/ref-resolver.d.ts +28 -0
  68. package/dist/openapi/schema-inference-service.d.ts +40 -0
  69. package/dist/openapi/schema-inferrer.d.ts +26 -0
  70. package/dist/openapi/script-analyzer.d.ts +41 -0
  71. package/dist/parsers/http-forge-parser.d.ts +2 -3
  72. package/dist/parsers/index.d.ts +0 -1
  73. package/dist/{implementations → platform}/data-file-parser.d.ts +0 -1
  74. package/dist/{implementations → platform}/node-file-system.d.ts +1 -2
  75. package/dist/script/interfaces.d.ts +161 -0
  76. package/dist/script/module-loader.d.ts +115 -0
  77. package/dist/script/request-script-session.d.ts +73 -0
  78. package/dist/script/script-executor.d.ts +60 -0
  79. package/dist/script/script-factories.d.ts +94 -0
  80. package/dist/script/script-utils.d.ts +42 -0
  81. package/dist/test-suite/index.d.ts +10 -0
  82. package/dist/test-suite/interfaces.d.ts +164 -0
  83. package/dist/test-suite/result-storage-service.d.ts +70 -0
  84. package/dist/test-suite/result-storage.d.ts +296 -0
  85. package/dist/test-suite/statistics-service.d.ts +51 -0
  86. package/dist/test-suite/test-suite-service.d.ts +97 -0
  87. package/dist/test-suite/test-suite-store.d.ts +155 -0
  88. package/dist/types/console-service.d.ts +40 -0
  89. package/dist/types/platform.d.ts +206 -0
  90. package/dist/{interfaces → types}/types.d.ts +289 -12
  91. package/dist/utils/dynamic-variables.d.ts +38 -0
  92. package/dist/utils/expression-evaluator.d.ts +34 -0
  93. package/dist/utils/filter-engine.d.ts +47 -0
  94. package/dist/utils/helpers.d.ts +47 -0
  95. package/package.json +12 -4
  96. package/dist/container.d.ts.map +0 -1
  97. package/dist/implementations/cookie-jar.d.ts.map +0 -1
  98. package/dist/implementations/cookie-utils.d.ts.map +0 -1
  99. package/dist/implementations/data-file-parser.d.ts.map +0 -1
  100. package/dist/implementations/fetch-http-client.d.ts.map +0 -1
  101. package/dist/implementations/index.d.ts +0 -22
  102. package/dist/implementations/index.d.ts.map +0 -1
  103. package/dist/implementations/interceptor-chain.d.ts.map +0 -1
  104. package/dist/implementations/module-loader.d.ts +0 -74
  105. package/dist/implementations/module-loader.d.ts.map +0 -1
  106. package/dist/implementations/native-http-client.d.ts.map +0 -1
  107. package/dist/implementations/node-file-system.d.ts.map +0 -1
  108. package/dist/implementations/request-history.d.ts.map +0 -1
  109. package/dist/implementations/request-preprocessor.d.ts.map +0 -1
  110. package/dist/implementations/variable-interpolator.d.ts +0 -55
  111. package/dist/implementations/variable-interpolator.d.ts.map +0 -1
  112. package/dist/implementations/vm2-script-runner.d.ts +0 -76
  113. package/dist/implementations/vm2-script-runner.d.ts.map +0 -1
  114. package/dist/index.d.ts.map +0 -1
  115. package/dist/interfaces/cookie.d.ts.map +0 -1
  116. package/dist/interfaces/history.d.ts.map +0 -1
  117. package/dist/interfaces/index.d.ts +0 -170
  118. package/dist/interfaces/index.d.ts.map +0 -1
  119. package/dist/interfaces/types.d.ts.map +0 -1
  120. package/dist/parsers/http-forge-parser.d.ts.map +0 -1
  121. package/dist/parsers/index.d.ts.map +0 -1
  122. package/dist/services/collection-loader.d.ts.map +0 -1
  123. package/dist/services/environment-resolver.d.ts.map +0 -1
  124. package/dist/services/folder-collection-loader.d.ts +0 -91
  125. package/dist/services/folder-collection-loader.d.ts.map +0 -1
  126. package/dist/services/forge-env.d.ts.map +0 -1
  127. package/dist/services/index.d.ts +0 -20
  128. package/dist/services/index.d.ts.map +0 -1
  129. package/dist/services/parser-registry.d.ts.map +0 -1
  130. package/dist/services/request-executor.d.ts.map +0 -1
  131. package/dist/services/script-pipeline.d.ts +0 -43
  132. package/dist/services/script-pipeline.d.ts.map +0 -1
  133. package/dist/services/script-session.d.ts +0 -66
  134. package/dist/services/script-session.d.ts.map +0 -1
  135. package/dist/services/url-builder.d.ts.map +0 -1
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Platform Adapters
3
+ *
4
+ * Interface for platform-specific implementations that must be
5
+ * provided by the host environment (VS Code, CLI, etc.).
6
+ *
7
+ * The core bootstrap uses these adapters to wire up services
8
+ * without depending on any specific platform.
9
+ */
10
+ import type { IConsoleService } from '../types/console-service';
11
+ import type { IApplicationInfo, IExternalBrowserService, IFileWatcherFactory, IKeyValueStore, INotificationService, ISecretStore } from '../types/platform';
12
+ /**
13
+ * Platform adapters required by core service bootstrap.
14
+ *
15
+ * The host environment (VS Code extension, CLI tool, etc.) creates
16
+ * concrete implementations and passes them to `registerCoreServices()`.
17
+ *
18
+ * @example VS Code extension:
19
+ * ```typescript
20
+ * const adapters: PlatformAdapters = {
21
+ * workspaceFolder: '/path/to/workspace',
22
+ * fileWatcherFactory: new VscodeFileWatcherFactory(),
23
+ * notificationService: new VscodeNotificationService(),
24
+ * workspaceStore: new VscodeKeyValueStore(context.workspaceState),
25
+ * globalStore: new VscodeKeyValueStore(context.globalState),
26
+ * secretStore: vscodeSecretStoreAdapter,
27
+ * browserService: vscodeBrowserAdapter,
28
+ * applicationInfo: { name: 'HttpForge', version: '1.0.0' },
29
+ * consoleService: new ConsoleService('HTTP Forge'),
30
+ * };
31
+ * registerCoreServices(container, adapters);
32
+ * ```
33
+ */
34
+ export interface PlatformAdapters {
35
+ /** Workspace root folder path */
36
+ workspaceFolder: string;
37
+ /** File watcher factory — watches for file changes (ConfigService, CollectionService) */
38
+ fileWatcherFactory: IFileWatcherFactory;
39
+ /** Notification service — shows info/warning/error messages (ConfigService) */
40
+ notificationService: INotificationService;
41
+ /** Per-workspace key-value store (EnvironmentConfigService) */
42
+ workspaceStore: IKeyValueStore;
43
+ /** Global key-value store (CookieService) */
44
+ globalStore: IKeyValueStore;
45
+ /** Secret storage for tokens (OAuth2TokenManager). Optional — OAuth2 disabled if absent. */
46
+ secretStore?: ISecretStore;
47
+ /** External browser service for OAuth2 flows. Optional — OAuth2 disabled if absent. */
48
+ browserService?: IExternalBrowserService;
49
+ /** Application name/version for User-Agent header (RequestPreparer) */
50
+ applicationInfo?: IApplicationInfo;
51
+ /** Structured logging service. Optional — a no-op console is used if absent. */
52
+ consoleService?: IConsoleService;
53
+ }
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Service Container
3
+ *
4
+ * Generic dependency injection container.
5
+ * Platform-agnostic — no VS Code dependencies.
6
+ *
7
+ * Principles:
8
+ * - Dependency Inversion: Services accessed through interfaces
9
+ * - Single Responsibility: Container only manages service lifecycle
10
+ * - Open/Closed: New services registered without modifying existing code
11
+ */
12
+ import type { IAsyncCookieService } from '../cookie/interfaces';
13
+ import type { IRequestPreparer } from '../execution/request-preparer-interfaces';
14
+ import type { IRequestHistoryService } from '../history/request-history-service-interfaces';
15
+ import type { IHttpRequestService } from '../http/interfaces';
16
+ import type { IScriptExecutor } from '../script/interfaces';
17
+ import type { IConsoleService } from '../types/console-service';
18
+ import type { IHttpClient } from '../types/platform';
19
+ import type { ServiceIdentifier } from './service-identifiers';
20
+ import type { IOAuth2TokenManager } from '../auth/interfaces';
21
+ import type { ICollectionService } from '../collection/collection-service-interfaces';
22
+ import type { IConfigService } from '../config';
23
+ import type { IEnvironmentConfigService } from '../environment/interfaces';
24
+ import type { IGraphQLSchemaService } from '../graphql/graphql-schema-service';
25
+ import type { IDataFileParser } from '../platform/data-file-parser';
26
+ import type { ICookieJar } from '../script/interfaces';
27
+ /**
28
+ * Factory function type for creating services
29
+ */
30
+ type ServiceFactory<T> = (container: ServiceContainer) => T;
31
+ /**
32
+ * Service Container implementation
33
+ * Provides dependency injection capabilities
34
+ */
35
+ export declare class ServiceContainer {
36
+ private static _instance;
37
+ private services;
38
+ private primitives;
39
+ private constructor();
40
+ /**
41
+ * Get the singleton instance
42
+ */
43
+ static get instance(): ServiceContainer;
44
+ /**
45
+ * Reset the container (useful for testing)
46
+ */
47
+ static reset(): void;
48
+ /**
49
+ * Register a primitive value (like workspace folder path)
50
+ */
51
+ registerValue<T>(identifier: ServiceIdentifier, value: T): this;
52
+ /**
53
+ * Register a service factory as a singleton
54
+ * The service will be created on first resolution and reused
55
+ */
56
+ registerSingleton<T>(identifier: ServiceIdentifier, factory: ServiceFactory<T>): this;
57
+ /**
58
+ * Register a service factory as transient
59
+ * A new instance will be created on each resolution
60
+ */
61
+ registerTransient<T>(identifier: ServiceIdentifier, factory: ServiceFactory<T>): this;
62
+ /**
63
+ * Register an already instantiated service
64
+ */
65
+ registerInstance<T>(identifier: ServiceIdentifier, instance: T): this;
66
+ /**
67
+ * Resolve a service by its identifier
68
+ */
69
+ resolve<T>(identifier: ServiceIdentifier): T;
70
+ /**
71
+ * Check if a service is registered
72
+ */
73
+ has(identifier: ServiceIdentifier): boolean;
74
+ /**
75
+ * Clear all registrations
76
+ */
77
+ clear(): void;
78
+ get config(): IConfigService;
79
+ get console(): IConsoleService;
80
+ get environmentConfig(): IEnvironmentConfigService;
81
+ get collection(): ICollectionService;
82
+ get httpRequest(): IHttpRequestService;
83
+ get httpClient(): IHttpClient;
84
+ get cookie(): IAsyncCookieService;
85
+ get requestHistory(): IRequestHistoryService;
86
+ get dataFileParser(): IDataFileParser;
87
+ get scriptExecutor(): IScriptExecutor;
88
+ get requestPreparer(): IRequestPreparer;
89
+ get persistentCookieJar(): ICookieJar;
90
+ get oauth2TokenManager(): IOAuth2TokenManager;
91
+ get graphqlSchemaService(): IGraphQLSchemaService;
92
+ }
93
+ /**
94
+ * Convenience function to get the service container instance
95
+ */
96
+ export declare function getServiceContainer(): ServiceContainer;
97
+ export {};
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Service Identifiers
3
+ *
4
+ * Symbol-based identifiers for type-safe service resolution.
5
+ * Used by ServiceContainer for dependency injection.
6
+ */
7
+ export declare const ServiceIdentifiers: {
8
+ readonly Config: symbol;
9
+ readonly Console: symbol;
10
+ readonly EnvironmentConfig: symbol;
11
+ readonly Collection: symbol;
12
+ readonly HttpRequest: symbol;
13
+ readonly HttpClient: symbol;
14
+ readonly Cookie: symbol;
15
+ readonly RequestHistory: symbol;
16
+ readonly UrlBuilder: symbol;
17
+ readonly RequestPreprocessor: symbol;
18
+ readonly RequestPreparer: symbol;
19
+ readonly InterceptorChain: symbol;
20
+ readonly ScriptExecutor: symbol;
21
+ readonly DataFileParser: symbol;
22
+ readonly CollectionRequestExecutor: symbol;
23
+ readonly WorkspaceFolder: symbol;
24
+ readonly PersistentCookieJar: symbol;
25
+ readonly OAuth2TokenManager: symbol;
26
+ readonly GraphQLSchemaService: symbol;
27
+ readonly SchemaInferrer: symbol;
28
+ readonly HistoryAnalyzer: symbol;
29
+ readonly ScriptAnalyzer: symbol;
30
+ readonly SchemaInferenceService: symbol;
31
+ readonly OpenApiExporter: symbol;
32
+ readonly OpenApiImporter: symbol;
33
+ };
34
+ export type ServiceIdentifier = typeof ServiceIdentifiers[keyof typeof ServiceIdentifiers];
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Environment Configuration Service
3
+ *
4
+ * Platform-agnostic — uses IKeyValueStore for persistence instead of
5
+ * VS Code's workspaceState/globalState.
6
+ */
7
+ import { IConfigService } from '../config';
8
+ import { IKeyValueStore } from '../types/platform';
9
+ import { IEnvironmentConfigService, ImportedEnvironment, LocalConfig, ResolvedEnvironment, SharedConfig } from './interfaces';
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 getEnvLocalConfigPath;
73
+ private loadFolderConfigs;
74
+ /**
75
+ * Create a VariableResolver pre-loaded with environment + session variables.
76
+ */
77
+ private createResolver;
78
+ private saveFolderSharedConfig;
79
+ reload(): void;
80
+ getAllEnvironments(): Array<{
81
+ id: string;
82
+ name: string;
83
+ active: boolean;
84
+ variables: Record<string, string>;
85
+ }>;
86
+ setActiveEnvironment(environmentId: string): Promise<void>;
87
+ createEnvironment(name: string): Promise<void>;
88
+ deleteEnvironment(environmentId: string): Promise<void>;
89
+ duplicateEnvironment(environmentId: string, newName: string): Promise<void>;
90
+ renameEnvironment(environmentId: string, newName: string): Promise<void>;
91
+ private validateEnvironmentName;
92
+ private validateEnvironmentExists;
93
+ private validateEnvironmentNameNotTaken;
94
+ private validateConfigLoaded;
95
+ updateEnvironmentVariables(environmentId: string, variables: Record<string, string>): Promise<void>;
96
+ private loadJsonFile;
97
+ private saveJsonFile;
98
+ }
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Environment File Loader
3
+ *
4
+ * Shared logic for reading the multi-file environment folder format:
5
+ * _global.json — global variables + default headers
6
+ * {env}.json — per-environment variables
7
+ * _global.local.json — local variable overrides (gitignored)
8
+ * {env}.local.json — per-environment local overrides (gitignored)
9
+ *
10
+ * Used by both EnvironmentConfigService (extension) and
11
+ * ForgeContainer.fromForgeRoot (standalone).
12
+ */
13
+ export interface EnvironmentFolderData {
14
+ /** Variables available in all environments */
15
+ globalVariables: Record<string, string>;
16
+ /** Default headers sent with every request */
17
+ defaultHeaders: Record<string, string>;
18
+ /** Per-environment configs keyed by environment name */
19
+ environments: Record<string, EnvironmentEntry>;
20
+ /** Local global variable overrides from _global.local.json */
21
+ localVariables: Record<string, string>;
22
+ /** Per-environment local variable overrides from {env}.local.json */
23
+ localCredentials: Record<string, {
24
+ variables: Record<string, string>;
25
+ }>;
26
+ }
27
+ export interface EnvironmentEntry {
28
+ description?: string;
29
+ requiresConfirmation?: boolean;
30
+ variables: Record<string, string>;
31
+ }
32
+ /**
33
+ * Determine whether a filename is a system/meta file (not an environment file).
34
+ */
35
+ export declare function isSystemEnvironmentFile(fileName: string): boolean;
36
+ /**
37
+ * Load environment configuration from a multi-file folder.
38
+ *
39
+ * @param envDir - Absolute path to the environments folder
40
+ * @returns Parsed environment data (or empty defaults when the folder is missing)
41
+ */
42
+ export declare function loadEnvironmentsFromFolder(envDir: string): EnvironmentFolderData;
@@ -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,8 +30,8 @@
30
30
  * env.get('token'); // 'abc'
31
31
  * ```
32
32
  */
33
- import { IEnvironmentStore, IVariableInterpolator } from '../interfaces';
34
33
  import { EnvironmentResolver } from './environment-resolver';
34
+ import { IEnvironmentStore, IVariableInterpolator } from './interfaces';
35
35
  /**
36
36
  * ForgeEnv interface - the public API for environment management
37
37
  */
@@ -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
+ }