@http-forge/core 0.2.0 → 0.2.2

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 (168) hide show
  1. package/README.md +25 -4
  2. package/dist/application/dto/index.d.ts +8 -0
  3. package/dist/application/dto/request-dtos.d.ts +105 -0
  4. package/dist/application/dto/response-dtos.d.ts +185 -0
  5. package/dist/application/events/application-events.d.ts +53 -0
  6. package/dist/application/events/index.d.ts +6 -0
  7. package/dist/application/index.d.ts +25 -0
  8. package/dist/application/mappers/collection-mapper.d.ts +39 -0
  9. package/dist/application/mappers/execution-result-mapper.d.ts +16 -0
  10. package/dist/application/mappers/index.d.ts +9 -0
  11. package/dist/application/mappers/request-mapper.d.ts +29 -0
  12. package/dist/application/queries/get-request-schema.query.d.ts +32 -0
  13. package/dist/application/queries/index.d.ts +6 -0
  14. package/dist/application/use-cases/create-request.use-case.d.ts +23 -0
  15. package/dist/application/use-cases/delete-request.use-case.d.ts +15 -0
  16. package/dist/application/use-cases/execute-request.use-case.d.ts +46 -0
  17. package/dist/application/use-cases/export-collection.use-case.d.ts +22 -0
  18. package/dist/application/use-cases/get-collection.use-case.d.ts +13 -0
  19. package/dist/application/use-cases/index.d.ts +12 -0
  20. package/dist/application/use-cases/list-requests.use-case.d.ts +14 -0
  21. package/dist/application/use-cases/load-collection.use-case.d.ts +30 -0
  22. package/dist/application/use-cases/save-collection.use-case.d.ts +25 -0
  23. package/dist/application/use-cases/update-request.use-case.d.ts +17 -0
  24. package/dist/container.d.ts +34 -18
  25. package/dist/di/core-bootstrap.d.ts +25 -0
  26. package/dist/di/index.d.ts +19 -0
  27. package/dist/di/platform-adapters.d.ts +66 -0
  28. package/dist/di/service-container.d.ts +97 -0
  29. package/dist/di/service-identifiers.d.ts +34 -0
  30. package/dist/domain/errors/domain-errors.d.ts +52 -0
  31. package/dist/domain/errors/index.d.ts +4 -0
  32. package/dist/domain/index.d.ts +24 -0
  33. package/dist/domain/models/execution.d.ts +88 -0
  34. package/dist/domain/models/index.d.ts +4 -0
  35. package/dist/domain/services/domain-events.d.ts +60 -0
  36. package/dist/domain/services/execution-planner.domain-service.d.ts +40 -0
  37. package/dist/domain/services/index.d.ts +9 -0
  38. package/dist/domain/services/schema-inference.domain-service.d.ts +54 -0
  39. package/dist/domain/value-objects/entity-id.d.ts +26 -0
  40. package/dist/domain/value-objects/http-method.d.ts +30 -0
  41. package/dist/domain/value-objects/index.d.ts +9 -0
  42. package/dist/domain/value-objects/request-url.d.ts +28 -0
  43. package/dist/index.d.ts +90 -84
  44. package/dist/index.js +187 -187
  45. package/dist/index.mjs +187 -187
  46. package/dist/infrastructure/adapters/index.d.ts +5 -0
  47. package/dist/infrastructure/adapters/logger.adapter.d.ts +25 -0
  48. package/dist/infrastructure/adapters/node-file-system.adapter.d.ts +18 -0
  49. package/dist/{auth → infrastructure/auth}/interfaces.d.ts +1 -1
  50. package/dist/{auth → infrastructure/auth}/oauth2-token-manager.d.ts +3 -3
  51. package/dist/{collection → infrastructure/collection}/collection-loader.d.ts +3 -3
  52. package/dist/{collection → infrastructure/collection}/collection-service.d.ts +2 -2
  53. package/dist/{collection → infrastructure/collection}/collection-store.d.ts +2 -2
  54. package/dist/infrastructure/collection/folder-collection-loader.d.ts +45 -0
  55. package/dist/{collection → infrastructure/collection}/folder-collection-store.d.ts +9 -2
  56. package/dist/infrastructure/collection/folder-io.d.ts +113 -0
  57. package/dist/{collection → infrastructure/collection}/json-collection-loader.d.ts +1 -1
  58. package/dist/{collection → infrastructure/collection}/parser-registry.d.ts +1 -1
  59. package/dist/{config → infrastructure/config}/config-service.d.ts +1 -1
  60. package/dist/{cookie → infrastructure/cookie}/cookie-service.d.ts +1 -1
  61. package/dist/infrastructure/di/complete-bootstrap.d.ts +24 -0
  62. package/dist/infrastructure/di/index.d.ts +6 -0
  63. package/dist/infrastructure/di/infrastructure-di-config.d.ts +33 -0
  64. package/dist/infrastructure/di/simple-event-publisher.d.ts +17 -0
  65. package/dist/{environment → infrastructure/environment}/environment-config-service.d.ts +6 -3
  66. package/dist/infrastructure/environment/environment-file-loader.d.ts +42 -0
  67. package/dist/{environment → infrastructure/environment}/environment-resolver.d.ts +1 -1
  68. package/dist/{environment → infrastructure/environment}/forge-env.d.ts +1 -1
  69. package/dist/{environment → infrastructure/environment}/variable-interpolator.d.ts +1 -1
  70. package/dist/{execution → infrastructure/execution}/collection-request-executor-interfaces.d.ts +1 -1
  71. package/dist/{execution → infrastructure/execution}/collection-request-executor.d.ts +3 -3
  72. package/dist/{execution → infrastructure/execution}/request-executor.d.ts +4 -4
  73. package/dist/{execution → infrastructure/execution}/request-preparer-interfaces.d.ts +2 -2
  74. package/dist/{execution → infrastructure/execution}/request-preparer.d.ts +5 -5
  75. package/dist/{graphql → infrastructure/graphql}/graphql-schema-service.d.ts +1 -1
  76. package/dist/{history → infrastructure/history}/history-interfaces.d.ts +1 -1
  77. package/dist/{history → infrastructure/history}/request-history.d.ts +1 -1
  78. package/dist/{http → infrastructure/http}/fetch-http-client.d.ts +2 -2
  79. package/dist/{http → infrastructure/http}/http-request-service.d.ts +2 -2
  80. package/dist/infrastructure/http/index.d.ts +4 -0
  81. package/dist/{http → infrastructure/http}/interceptor-chain.d.ts +1 -1
  82. package/dist/{http → infrastructure/http}/interfaces.d.ts +1 -1
  83. package/dist/{http → infrastructure/http}/merge-request-settings.d.ts +1 -1
  84. package/dist/{http → infrastructure/http}/native-http-client.d.ts +2 -2
  85. package/dist/infrastructure/http/node-http-executor.adapter.d.ts +25 -0
  86. package/dist/{http → infrastructure/http}/request-preprocessor.d.ts +1 -1
  87. package/dist/{import-export → infrastructure/import-export}/import-postman-environment.d.ts +3 -3
  88. package/dist/{import-export → infrastructure/import-export}/rest-client-export.d.ts +3 -3
  89. package/dist/infrastructure/index.d.ts +31 -0
  90. package/dist/{openapi → infrastructure/openapi}/example-generator.d.ts +1 -1
  91. package/dist/{openapi → infrastructure/openapi}/history-analyzer.d.ts +1 -1
  92. package/dist/{openapi → infrastructure/openapi}/interfaces.d.ts +2 -2
  93. package/dist/{openapi → infrastructure/openapi}/openapi-exporter.d.ts +2 -2
  94. package/dist/{openapi → infrastructure/openapi}/openapi-importer.d.ts +2 -2
  95. package/dist/{openapi → infrastructure/openapi}/schema-inference-service.d.ts +1 -1
  96. package/dist/{openapi → infrastructure/openapi}/schema-inferrer.d.ts +1 -1
  97. package/dist/infrastructure/parsers/collection-parser.adapter.d.ts +32 -0
  98. package/dist/{parsers → infrastructure/parsers}/http-forge-parser.d.ts +2 -2
  99. package/dist/infrastructure/parsers/index.d.ts +7 -0
  100. package/dist/infrastructure/persistence/file-system-history-loader.d.ts +31 -0
  101. package/dist/infrastructure/persistence/index.d.ts +6 -0
  102. package/dist/{platform → infrastructure/platform}/node-file-system.d.ts +1 -1
  103. package/dist/infrastructure/repositories/file-system/fs-collection-repository.d.ts +72 -0
  104. package/dist/infrastructure/repositories/file-system/fs-environment-file-loader.adapter.d.ts +41 -0
  105. package/dist/infrastructure/repositories/file-system/fs-environment-repository.d.ts +34 -0
  106. package/dist/infrastructure/repositories/file-system/fs-request-repository.d.ts +31 -0
  107. package/dist/infrastructure/repositories/file-system/index.d.ts +7 -0
  108. package/dist/infrastructure/repositories/in-memory/in-memory-collection-repository.d.ts +18 -0
  109. package/dist/infrastructure/repositories/in-memory/in-memory-environment-repository.d.ts +25 -0
  110. package/dist/infrastructure/repositories/in-memory/in-memory-request-repository.d.ts +25 -0
  111. package/dist/infrastructure/repositories/in-memory/index.d.ts +7 -0
  112. package/dist/infrastructure/script/index.d.ts +4 -0
  113. package/dist/{script → infrastructure/script}/interfaces.d.ts +13 -1
  114. package/dist/{script → infrastructure/script}/request-script-session.d.ts +3 -0
  115. package/dist/{script → infrastructure/script}/script-factories.d.ts +15 -4
  116. package/dist/{script → infrastructure/script}/script-utils.d.ts +3 -2
  117. package/dist/infrastructure/script/vm-script-executor.adapter.d.ts +19 -0
  118. package/dist/{test-suite → infrastructure/test-suite}/result-storage-service.d.ts +1 -1
  119. package/dist/{test-suite → infrastructure/test-suite}/result-storage.d.ts +1 -1
  120. package/dist/{test-suite → infrastructure/test-suite}/test-suite-service.d.ts +1 -1
  121. package/dist/{test-suite → infrastructure/test-suite}/test-suite-store.d.ts +1 -1
  122. package/dist/ports/executors/http-executor.interface.d.ts +34 -0
  123. package/dist/ports/executors/index.d.ts +5 -0
  124. package/dist/ports/executors/script-executor.interface.d.ts +43 -0
  125. package/dist/ports/external/file-system.interface.d.ts +44 -0
  126. package/dist/ports/external/http-client.interface.d.ts +25 -0
  127. package/dist/ports/external/index.d.ts +7 -0
  128. package/dist/ports/external/logger.interface.d.ts +17 -0
  129. package/dist/ports/index.d.ts +17 -0
  130. package/dist/ports/parsers/collection-parser.interface.d.ts +23 -0
  131. package/dist/ports/parsers/index.d.ts +4 -0
  132. package/dist/ports/repositories/collection-repository.interface.d.ts +32 -0
  133. package/dist/ports/repositories/environment-repository.interface.d.ts +31 -0
  134. package/dist/ports/repositories/index.d.ts +6 -0
  135. package/dist/ports/repositories/request-repository.interface.d.ts +32 -0
  136. package/dist/ports/storage/cache-store.interface.d.ts +26 -0
  137. package/dist/ports/storage/history-loader.interface.d.ts +37 -0
  138. package/dist/ports/storage/index.d.ts +5 -0
  139. package/dist/{collection/collection-service-interfaces.d.ts → types/collection.d.ts} +19 -4
  140. package/dist/types/environment-config.d.ts +143 -0
  141. package/dist/types/types.d.ts +27 -7
  142. package/package.json +2 -2
  143. package/dist/collection/folder-collection-loader.d.ts +0 -256
  144. package/dist/collection/interfaces.d.ts +0 -32
  145. package/dist/parsers/index.d.ts +0 -6
  146. package/dist/{collection → infrastructure/collection}/collection-loader-factory.d.ts +1 -1
  147. package/dist/{config → infrastructure/config}/config.interface.d.ts +0 -0
  148. package/dist/{config → infrastructure/config}/default-config.d.ts +0 -0
  149. package/dist/{config → infrastructure/config}/index.d.ts +0 -0
  150. package/dist/{cookie → infrastructure/cookie}/cookie-jar.d.ts +0 -0
  151. package/dist/{cookie → infrastructure/cookie}/cookie-utils.d.ts +0 -0
  152. package/dist/{cookie → infrastructure/cookie}/in-memory-cookie-jar.d.ts +1 -1
  153. package/dist/{cookie → infrastructure/cookie}/interfaces.d.ts +0 -0
  154. package/dist/{cookie → infrastructure/cookie}/persistent-cookie-jar.d.ts +1 -1
  155. package/dist/{environment → infrastructure/environment}/interfaces.d.ts +0 -0
  156. package/dist/{graphql → infrastructure/graphql}/graphql-completion-provider.d.ts +0 -0
  157. package/dist/{history → infrastructure/history}/request-history-service-interfaces.d.ts +0 -0
  158. package/dist/{history → infrastructure/history}/request-history-service.d.ts +0 -0
  159. package/dist/{http → infrastructure/http}/url-builder.d.ts +0 -0
  160. package/dist/{openapi → infrastructure/openapi}/index.d.ts +0 -0
  161. package/dist/{openapi → infrastructure/openapi}/ref-resolver.d.ts +0 -0
  162. package/dist/{openapi → infrastructure/openapi}/script-analyzer.d.ts +0 -0
  163. package/dist/{platform → infrastructure/platform}/data-file-parser.d.ts +0 -0
  164. package/dist/{script → infrastructure/script}/module-loader.d.ts +0 -0
  165. package/dist/{script → infrastructure/script}/script-executor.d.ts +1 -1
  166. /package/dist/{test-suite → infrastructure/test-suite}/index.d.ts +0 -0
  167. /package/dist/{test-suite → infrastructure/test-suite}/interfaces.d.ts +0 -0
  168. /package/dist/{test-suite → infrastructure/test-suite}/statistics-service.d.ts +0 -0
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Export Collection Use Case
3
+ */
4
+ import { ICollectionRepository } from '../../ports/repositories/collection-repository.interface';
5
+ import { IFileSystem } from '../../ports/external/file-system.interface';
6
+ import { ILogger } from '../../ports/external/logger.interface';
7
+ import { IDomainEventPublisher } from '../../domain/services/domain-events';
8
+ import { ExportCollectionInput } from '../dto/request-dtos';
9
+ import { ExportCollectionOutput } from '../dto/response-dtos';
10
+ export type { ExportCollectionInput } from '../dto/request-dtos';
11
+ export declare class ExportCollectionUseCase {
12
+ private collectionRepository;
13
+ private fileSystem;
14
+ private eventPublisher;
15
+ private logger;
16
+ constructor(collectionRepository: ICollectionRepository, fileSystem: IFileSystem, eventPublisher: IDomainEventPublisher, logger: ILogger);
17
+ execute(input: ExportCollectionInput): Promise<ExportCollectionOutput>;
18
+ private toPostman;
19
+ private toOpenAPI;
20
+ private convertItems;
21
+ private extractPaths;
22
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Get Collection Use Case
3
+ */
4
+ import { ICollectionRepository } from '../../ports/repositories/collection-repository.interface';
5
+ import { ILogger } from '../../ports/external/logger.interface';
6
+ import { GetCollectionInput } from '../dto/request-dtos';
7
+ import { GetCollectionOutput } from '../dto/response-dtos';
8
+ export declare class GetCollectionUseCase {
9
+ private collectionRepository;
10
+ private logger;
11
+ constructor(collectionRepository: ICollectionRepository, logger: ILogger);
12
+ execute(input: GetCollectionInput): Promise<GetCollectionOutput>;
13
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Application Use Cases
3
+ */
4
+ export * from './execute-request.use-case';
5
+ export * from './load-collection.use-case';
6
+ export * from './save-collection.use-case';
7
+ export * from './create-request.use-case';
8
+ export * from './update-request.use-case';
9
+ export * from './delete-request.use-case';
10
+ export * from './list-requests.use-case';
11
+ export * from './get-collection.use-case';
12
+ export * from './export-collection.use-case';
@@ -0,0 +1,14 @@
1
+ /**
2
+ * List Requests Use Case
3
+ */
4
+ import { ICollectionRepository } from '../../ports/repositories/collection-repository.interface';
5
+ import { ILogger } from '../../ports/external/logger.interface';
6
+ import { ListRequestsInput } from '../dto/request-dtos';
7
+ import { ListRequestsOutput } from '../dto/response-dtos';
8
+ export declare class ListRequestsUseCase {
9
+ private collectionRepository;
10
+ private logger;
11
+ constructor(collectionRepository: ICollectionRepository, logger: ILogger);
12
+ execute(input: ListRequestsInput): Promise<ListRequestsOutput>;
13
+ private collectRequests;
14
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Load Collection Use Case
3
+ *
4
+ * Loads a collection from file and parses it
5
+ * Returns FULL collection with ALL metadata preserved (headers, query, scripts, etc.)
6
+ */
7
+ import { IDomainEventPublisher } from '../../domain/services/domain-events';
8
+ import { IFileSystem } from '../../ports/external/file-system.interface';
9
+ import { ILogger } from '../../ports/external/logger.interface';
10
+ import { ICollectionParser } from '../../ports/parsers/collection-parser.interface';
11
+ import { LoadCollectionInput } from '../dto/request-dtos';
12
+ import { LoadCollectionOutput } from '../dto/response-dtos';
13
+ /**
14
+ * Use Case: Load collection from file
15
+ */
16
+ export declare class LoadCollectionUseCase {
17
+ private fileSystem;
18
+ private collectionParser;
19
+ private eventPublisher;
20
+ private logger;
21
+ constructor(fileSystem: IFileSystem, collectionParser: ICollectionParser, eventPublisher: IDomainEventPublisher, logger: ILogger);
22
+ /**
23
+ * Load collection from file path
24
+ */
25
+ execute(input: LoadCollectionInput): Promise<LoadCollectionOutput>;
26
+ /**
27
+ * Count total requests recursively
28
+ */
29
+ private countRequests;
30
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Save Collection Use Case
3
+ *
4
+ * Saves a collection to file
5
+ */
6
+ import { IFileSystem } from '../../ports/external/file-system.interface';
7
+ import { ILogger } from '../../ports/external/logger.interface';
8
+ import { ICollectionRepository } from '../../ports/repositories/collection-repository.interface';
9
+ import { IDomainEventPublisher } from '../../domain/services/domain-events';
10
+ import { SaveCollectionInput } from '../dto/request-dtos';
11
+ import { SaveCollectionOutput } from '../dto/response-dtos';
12
+ /**
13
+ * Use Case: Save collection to file
14
+ */
15
+ export declare class SaveCollectionUseCase {
16
+ private fileSystem;
17
+ private collectionRepository;
18
+ private eventPublisher;
19
+ private logger;
20
+ constructor(fileSystem: IFileSystem, collectionRepository: ICollectionRepository, eventPublisher: IDomainEventPublisher, logger: ILogger);
21
+ /**
22
+ * Save collection to file
23
+ */
24
+ execute(input: SaveCollectionInput): Promise<SaveCollectionOutput>;
25
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Update Request Use Case
3
+ * Supports updating all request fields including enabled/disabled headers and schemas
4
+ */
5
+ import { IDomainEventPublisher } from '../../domain/services/domain-events';
6
+ import { ILogger } from '../../ports/external/logger.interface';
7
+ import { ICollectionRepository } from '../../ports/repositories/collection-repository.interface';
8
+ import { UpdateRequestInput } from '../dto/request-dtos';
9
+ import { UpdateRequestOutput } from '../dto/response-dtos';
10
+ export type { UpdateRequestInput } from '../dto/request-dtos';
11
+ export declare class UpdateRequestUseCase {
12
+ private collectionRepository;
13
+ private eventPublisher;
14
+ private logger;
15
+ constructor(collectionRepository: ICollectionRepository, eventPublisher: IDomainEventPublisher, logger: ILogger);
16
+ execute(input: UpdateRequestInput): Promise<UpdateRequestOutput>;
17
+ }
@@ -1,23 +1,40 @@
1
1
  /**
2
2
  * Forge Container - Dependency Injection Container
3
3
  *
4
+ * ⚠️ @deprecated 此类用于向后兼容
5
+ * 新代码应使用 infrastructure/di/complete-bootstrap 中的 bootstrapComplete() 函数
6
+ *
7
+ * 向后兼容层:
8
+ * 此文件继续提供原有的 ForgeContainer 接口
9
+ * 内部实现现已迁移至三层架构 (Domain/Application/Infrastructure)
10
+ *
11
+ * 迁移指南:
12
+ * 旧代码:
13
+ * const container = new ForgeContainer(config);
14
+ *
15
+ * 新代码:
16
+ * import { ServiceContainer } from '@http-forge/core/di';
17
+ * import { bootstrapComplete } from '@http-forge/core/infrastructure/di';
18
+ *
19
+ * const container = new ServiceContainer();
20
+ * bootstrapComplete(container, { useFileSystem: true });
21
+ *
4
22
  * Single Responsibility: Wire up all components with proper dependencies
5
23
  * Factory Pattern: Creates configured instances of services
6
24
  */
7
- import { ICookieService } from './cookie/interfaces';
8
- import { IDataFileParser } from './platform/data-file-parser';
9
- import { IErrorInterceptor, IInterceptorChain, IRequestInterceptor, IResponseInterceptor } from './http/interceptor-chain';
10
- import { IRequestPreprocessor } from './http/request-preprocessor';
25
+ import { ParserRegistry } from './infrastructure/collection/parser-registry';
26
+ import { ICookieService } from './infrastructure/cookie/interfaces';
27
+ import { EnvironmentResolver, EnvironmentStoreConfig } from './infrastructure/environment/environment-resolver';
28
+ import { ForgeEnv } from './infrastructure/environment/forge-env';
29
+ import { IVariableInterpolator } from './types/environment-config';
30
+ import { RequestExecutor } from './infrastructure/execution/request-executor';
31
+ import { IRequestHistory } from './infrastructure/history/history-interfaces';
32
+ import { IErrorInterceptor, IInterceptorChain, IRequestInterceptor, IResponseInterceptor } from './infrastructure/http/interceptor-chain';
33
+ import { IRequestPreprocessor } from './infrastructure/http/request-preprocessor';
34
+ import { IDataFileParser } from './infrastructure/platform/data-file-parser';
35
+ import { IScriptExecutor } from './infrastructure/script/interfaces';
11
36
  import { IFileSystem, IHttpClient } from './types/platform';
12
- import { ICollectionLoader } from './collection/interfaces';
13
- import { IRequestHistory } from './history/history-interfaces';
14
- import { IScriptExecutor } from './script/interfaces';
15
- import { IVariableInterpolator } from './environment/interfaces';
16
37
  import { HttpRequest, HttpResponse, RequestSettings, UnifiedCollection, UnifiedRequest } from './types/types';
17
- import { EnvironmentResolver, EnvironmentStoreConfig } from './environment/environment-resolver';
18
- import { ForgeEnv } from './environment/forge-env';
19
- import { ParserRegistry } from './collection/parser-registry';
20
- import { RequestExecutor } from './execution/request-executor';
21
38
  /**
22
39
  * Container configuration options
23
40
  */
@@ -92,7 +109,7 @@ export declare class ForgeContainer {
92
109
  readonly dataFileParser: IDataFileParser;
93
110
  readonly requestHistory: IRequestHistory | null;
94
111
  readonly parserRegistry: ParserRegistry;
95
- readonly collectionLoader: ICollectionLoader;
112
+ readonly collectionLoader: import('./types/collection').ICollectionLoader;
96
113
  readonly environmentStore: EnvironmentResolver;
97
114
  readonly forgeEnv: ForgeEnv;
98
115
  readonly requestExecutor: RequestExecutor;
@@ -135,18 +152,17 @@ export declare class ForgeContainer {
135
152
  /**
136
153
  * Create a container by auto-loading environments from forgeRoot
137
154
  *
138
- * Reads `{forgeRoot}/environments/environments.json` and creates
139
- * a container with the environment configuration pre-loaded.
155
+ * Reads the multi-file environment folder format under
156
+ * `{forgeRoot}/environments/` (same format used by the VS Code extension).
157
+ * Falls back to the legacy single-file `environments.json` when the
158
+ * multi-file format is not detected.
140
159
  *
141
160
  * @param forgeRoot - Path to http-forge folder (default: './http-forge')
142
161
  * @param options - Additional container options
143
162
  *
144
163
  * @example
145
164
  * ```typescript
146
- * // Auto-load environments from ./http-forge/environments/environments.json
147
165
  * const forge = ForgeContainer.fromForgeRoot('./http-forge');
148
- *
149
- * // Switch environment
150
166
  * forge.forgeEnv.setActiveEnvironment('sit');
151
167
  * ```
152
168
  */
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Core Service Bootstrap
3
+ *
4
+ * Registers all platform-agnostic services in the ServiceContainer.
5
+ * The host environment (VS Code, CLI, etc.) only needs to provide
6
+ * PlatformAdapters — the actual service wiring lives here.
7
+ *
8
+ * This is the single source of truth for service dependencies.
9
+ */
10
+ import type { PlatformAdapters } from './platform-adapters';
11
+ import type { ServiceContainer } from './service-container';
12
+ /**
13
+ * Register all platform-agnostic core services in the container.
14
+ *
15
+ * @param container - The service container to register into
16
+ * @param adapters - Platform-specific adapters provided by the host
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const container = ServiceContainer.instance;
21
+ * container.clear();
22
+ * registerCoreServices(container, adapters);
23
+ * ```
24
+ */
25
+ export declare function registerCoreServices(container: ServiceContainer, adapters: PlatformAdapters): void;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Dependency Injection
3
+ *
4
+ * ⚠️ @deprecated 此模块用于向后兼容
5
+ * 新代码应使用 infrastructure/di/complete-bootstrap 中的功能
6
+ *
7
+ * Provides a generic, platform-agnostic DI container and service bootstrap.
8
+ * Host environments (VS Code, CLI, etc.) only need to supply PlatformAdapters.
9
+ *
10
+ * 迁移指南:
11
+ * - 旧的 ServiceContainer 已被新的架构集成
12
+ * - 使用 bootstrapComplete() 替代 registerCoreServices()
13
+ * - 详见 ARCHITECTURE_IMPLEMENTATION.md
14
+ */
15
+ export { registerCoreServices } from './core-bootstrap';
16
+ export type { PlatformAdapters } from './platform-adapters';
17
+ export { getServiceContainer, ServiceContainer } from './service-container';
18
+ export { ServiceIdentifiers } from './service-identifiers';
19
+ export type { ServiceIdentifier } from './service-identifiers';
@@ -0,0 +1,66 @@
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, IFileSystem, IFileWatcherFactory, IHttpClient, IKeyValueStore, INotificationService, ISecretStore } from '../types/platform';
12
+ import type { IHttpExecutor } from '../ports/executors/http-executor.interface';
13
+ import type { IScriptExecutor } from '../ports/executors/script-executor.interface';
14
+ import type { ILogger } from '../ports/external/logger.interface';
15
+ /**
16
+ * Platform adapters required by core service bootstrap.
17
+ *
18
+ * The host environment (VS Code extension, CLI tool, etc.) creates
19
+ * concrete implementations and passes them to `registerCoreServices()`.
20
+ *
21
+ * @example VS Code extension:
22
+ * ```typescript
23
+ * const adapters: PlatformAdapters = {
24
+ * workspaceFolder: '/path/to/workspace',
25
+ * fileWatcherFactory: new VscodeFileWatcherFactory(),
26
+ * notificationService: new VscodeNotificationService(),
27
+ * workspaceStore: new VscodeKeyValueStore(context.workspaceState),
28
+ * globalStore: new VscodeKeyValueStore(context.globalState),
29
+ * secretStore: vscodeSecretStoreAdapter,
30
+ * browserService: vscodeBrowserAdapter,
31
+ * applicationInfo: { name: 'HttpForge', version: '1.0.0' },
32
+ * consoleService: new ConsoleService('HTTP Forge'),
33
+ * };
34
+ * registerCoreServices(container, adapters);
35
+ * ```
36
+ */
37
+ export interface PlatformAdapters {
38
+ /** Workspace root folder path */
39
+ workspaceFolder: string;
40
+ /** File watcher factory — watches for file changes (ConfigService, CollectionService) */
41
+ fileWatcherFactory: IFileWatcherFactory;
42
+ /** Notification service — shows info/warning/error messages (ConfigService) */
43
+ notificationService: INotificationService;
44
+ /** Per-workspace key-value store (EnvironmentConfigService) */
45
+ workspaceStore: IKeyValueStore;
46
+ /** Global key-value store (CookieService) */
47
+ globalStore: IKeyValueStore;
48
+ /** Secret storage for tokens (OAuth2TokenManager). Optional — OAuth2 disabled if absent. */
49
+ secretStore?: ISecretStore;
50
+ /** External browser service for OAuth2 flows. Optional — OAuth2 disabled if absent. */
51
+ browserService?: IExternalBrowserService;
52
+ /** Application name/version for User-Agent header (RequestPreparer) */
53
+ applicationInfo?: IApplicationInfo;
54
+ /** Structured logging service. Optional — a no-op console is used if absent. */
55
+ consoleService?: IConsoleService;
56
+ /** File system adapter */
57
+ fileSystem?: IFileSystem;
58
+ /** Logger adapter */
59
+ logger?: ILogger;
60
+ /** HTTP client adapter */
61
+ httpClient?: IHttpClient;
62
+ /** HTTP executor adapter */
63
+ httpExecutor?: IHttpExecutor;
64
+ /** Script executor adapter */
65
+ scriptExecutor?: IScriptExecutor;
66
+ }
@@ -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 '../infrastructure/cookie/interfaces';
13
+ import type { IRequestPreparer } from '../infrastructure/execution/request-preparer-interfaces';
14
+ import type { IRequestHistoryService } from '../infrastructure/history/request-history-service-interfaces';
15
+ import type { IHttpRequestService } from '../infrastructure/http/interfaces';
16
+ import type { IScriptExecutor } from '../infrastructure/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 '../infrastructure/auth/interfaces';
21
+ import type { ICollectionService } from '../types/collection';
22
+ import type { IConfigService } from '../infrastructure/config';
23
+ import type { IEnvironmentConfigService } from '../types/environment-config';
24
+ import type { IGraphQLSchemaService } from '../infrastructure/graphql/graphql-schema-service';
25
+ import type { IDataFileParser } from '../infrastructure/platform/data-file-parser';
26
+ import type { ICookieJar } from '../infrastructure/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] | string;
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Domain Errors - Business-specific exceptions
3
+ *
4
+ * Use these instead of generic Error for domain-level problems
5
+ */
6
+ /**
7
+ * Base domain error
8
+ */
9
+ export declare class DomainError extends Error {
10
+ readonly code: string;
11
+ readonly message: string;
12
+ readonly details?: Record<string, any> | undefined;
13
+ constructor(code: string, message: string, details?: Record<string, any> | undefined);
14
+ }
15
+ /**
16
+ * Collection not found
17
+ */
18
+ export declare class CollectionNotFoundError extends DomainError {
19
+ constructor(collectionId: string);
20
+ }
21
+ /**
22
+ * Request not found
23
+ */
24
+ export declare class RequestNotFoundError extends DomainError {
25
+ constructor(requestId: string);
26
+ }
27
+ /**
28
+ * Invalid request - validation failed
29
+ */
30
+ export declare class InvalidRequestError extends DomainError {
31
+ constructor(message: string);
32
+ constructor(requestId: string, reason: string);
33
+ }
34
+ /**
35
+ * Execution failed - HTTP or script error
36
+ */
37
+ export declare class ExecutionError extends DomainError {
38
+ readonly originalError?: Error | undefined;
39
+ constructor(requestId: string, reason: string, originalError?: Error | undefined);
40
+ }
41
+ /**
42
+ * Script error - pre/post script failed
43
+ */
44
+ export declare class ScriptExecutionError extends DomainError {
45
+ constructor(requestId: string, stage: 'pre' | 'post', reason: string);
46
+ }
47
+ /**
48
+ * Variable interpolation failed
49
+ */
50
+ export declare class VariableResolutionError extends DomainError {
51
+ constructor(variableName: string, reason: string);
52
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Domain Errors - Business exceptions
3
+ */
4
+ export * from './domain-errors';
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Domain Layer - Business logic (Clean Architecture)
3
+ *
4
+ * Contains:
5
+ * - Domain models (pure data structures)
6
+ * - Domain services (pure business logic)
7
+ * - Domain errors (business exceptions)
8
+ * - Domain events (event publishing)
9
+ *
10
+ * Constraints:
11
+ * - ZERO external dependencies
12
+ * - NO platform-specific code
13
+ * - NO persistence concerns
14
+ * - Fully testable without mocks
15
+ *
16
+ * Usage:
17
+ * - Imported by application layer
18
+ * - Used for business rule validation
19
+ * - Should be framework-agnostic
20
+ */
21
+ export * from './models';
22
+ export * from './services';
23
+ export * from './errors';
24
+ export * from './value-objects';
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Execution Domain Models - Core execution data structures
3
+ *
4
+ * These are pure domain models independent of storage or UI concerns
5
+ */
6
+ import { HttpRequest, HttpResponse } from '../../types/types';
7
+ /**
8
+ * Execution context - captures state during request execution
9
+ */
10
+ export interface IExecutionContext {
11
+ requestId: string;
12
+ collectionId: string;
13
+ variables: Record<string, any>;
14
+ environment: Record<string, any>;
15
+ cookies: Record<string, string>;
16
+ metadata?: {
17
+ userId?: string;
18
+ timestamp?: Date;
19
+ [key: string]: any;
20
+ };
21
+ }
22
+ /**
23
+ * Execution plan - describes how to execute a request
24
+ */
25
+ export interface IExecutionPlan {
26
+ requestId: string;
27
+ request: HttpRequest;
28
+ preScripts?: string[];
29
+ postScripts?: string[];
30
+ scripts?: {
31
+ preRequest?: string;
32
+ postResponse?: string;
33
+ };
34
+ }
35
+ /**
36
+ * Execution result - outcome of request execution
37
+ */
38
+ export interface IExecutionResult {
39
+ /** Request ID */
40
+ requestId: string;
41
+ /** HTTP response */
42
+ response: HttpResponse;
43
+ /** Execution time (ms) */
44
+ duration: number;
45
+ /** Pre-request script result */
46
+ preScriptResult?: {
47
+ success: boolean;
48
+ output: any;
49
+ errors: string[];
50
+ };
51
+ /** Post-response script result */
52
+ postScriptResult?: {
53
+ success: boolean;
54
+ output: any;
55
+ errors: string[];
56
+ assertions?: AssertionResult[];
57
+ };
58
+ /** Variable changes during execution */
59
+ variableChanges?: Record<string, any>;
60
+ /** Execution status */
61
+ status: 'success' | 'failed' | 'partial';
62
+ /** Error message if execution failed */
63
+ error?: string;
64
+ }
65
+ /**
66
+ * Test assertion result
67
+ */
68
+ export interface AssertionResult {
69
+ name: string;
70
+ passed: boolean;
71
+ expected: any;
72
+ actual: any;
73
+ message?: string;
74
+ }
75
+ /**
76
+ * Execution metrics
77
+ */
78
+ export interface IExecutionMetrics {
79
+ requestId: string;
80
+ duration: number;
81
+ httpStatus: number;
82
+ success: boolean;
83
+ timestamp: Date;
84
+ size?: {
85
+ requestBytes?: number;
86
+ responseBytes?: number;
87
+ };
88
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Domain Models - Core business data structures
3
+ */
4
+ export * from './execution';