@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.
- package/README.md +25 -4
- package/dist/application/dto/index.d.ts +8 -0
- package/dist/application/dto/request-dtos.d.ts +105 -0
- package/dist/application/dto/response-dtos.d.ts +185 -0
- package/dist/application/events/application-events.d.ts +53 -0
- package/dist/application/events/index.d.ts +6 -0
- package/dist/application/index.d.ts +25 -0
- package/dist/application/mappers/collection-mapper.d.ts +39 -0
- package/dist/application/mappers/execution-result-mapper.d.ts +16 -0
- package/dist/application/mappers/index.d.ts +9 -0
- package/dist/application/mappers/request-mapper.d.ts +29 -0
- package/dist/application/queries/get-request-schema.query.d.ts +32 -0
- package/dist/application/queries/index.d.ts +6 -0
- package/dist/application/use-cases/create-request.use-case.d.ts +23 -0
- package/dist/application/use-cases/delete-request.use-case.d.ts +15 -0
- package/dist/application/use-cases/execute-request.use-case.d.ts +46 -0
- package/dist/application/use-cases/export-collection.use-case.d.ts +22 -0
- package/dist/application/use-cases/get-collection.use-case.d.ts +13 -0
- package/dist/application/use-cases/index.d.ts +12 -0
- package/dist/application/use-cases/list-requests.use-case.d.ts +14 -0
- package/dist/application/use-cases/load-collection.use-case.d.ts +30 -0
- package/dist/application/use-cases/save-collection.use-case.d.ts +25 -0
- package/dist/application/use-cases/update-request.use-case.d.ts +17 -0
- package/dist/container.d.ts +34 -18
- package/dist/di/core-bootstrap.d.ts +25 -0
- package/dist/di/index.d.ts +19 -0
- package/dist/di/platform-adapters.d.ts +66 -0
- package/dist/di/service-container.d.ts +97 -0
- package/dist/di/service-identifiers.d.ts +34 -0
- package/dist/domain/errors/domain-errors.d.ts +52 -0
- package/dist/domain/errors/index.d.ts +4 -0
- package/dist/domain/index.d.ts +24 -0
- package/dist/domain/models/execution.d.ts +88 -0
- package/dist/domain/models/index.d.ts +4 -0
- package/dist/domain/services/domain-events.d.ts +60 -0
- package/dist/domain/services/execution-planner.domain-service.d.ts +40 -0
- package/dist/domain/services/index.d.ts +9 -0
- package/dist/domain/services/schema-inference.domain-service.d.ts +54 -0
- package/dist/domain/value-objects/entity-id.d.ts +26 -0
- package/dist/domain/value-objects/http-method.d.ts +30 -0
- package/dist/domain/value-objects/index.d.ts +9 -0
- package/dist/domain/value-objects/request-url.d.ts +28 -0
- package/dist/index.d.ts +90 -84
- package/dist/index.js +187 -187
- package/dist/index.mjs +187 -187
- package/dist/infrastructure/adapters/index.d.ts +5 -0
- package/dist/infrastructure/adapters/logger.adapter.d.ts +25 -0
- package/dist/infrastructure/adapters/node-file-system.adapter.d.ts +18 -0
- package/dist/{auth → infrastructure/auth}/interfaces.d.ts +1 -1
- package/dist/{auth → infrastructure/auth}/oauth2-token-manager.d.ts +3 -3
- package/dist/{collection → infrastructure/collection}/collection-loader.d.ts +3 -3
- package/dist/{collection → infrastructure/collection}/collection-service.d.ts +2 -2
- package/dist/{collection → infrastructure/collection}/collection-store.d.ts +2 -2
- package/dist/infrastructure/collection/folder-collection-loader.d.ts +45 -0
- package/dist/{collection → infrastructure/collection}/folder-collection-store.d.ts +9 -2
- package/dist/infrastructure/collection/folder-io.d.ts +113 -0
- package/dist/{collection → infrastructure/collection}/json-collection-loader.d.ts +1 -1
- package/dist/{collection → infrastructure/collection}/parser-registry.d.ts +1 -1
- package/dist/{config → infrastructure/config}/config-service.d.ts +1 -1
- package/dist/{cookie → infrastructure/cookie}/cookie-service.d.ts +1 -1
- package/dist/infrastructure/di/complete-bootstrap.d.ts +24 -0
- package/dist/infrastructure/di/index.d.ts +6 -0
- package/dist/infrastructure/di/infrastructure-di-config.d.ts +33 -0
- package/dist/infrastructure/di/simple-event-publisher.d.ts +17 -0
- package/dist/{environment → infrastructure/environment}/environment-config-service.d.ts +6 -3
- package/dist/infrastructure/environment/environment-file-loader.d.ts +42 -0
- package/dist/{environment → infrastructure/environment}/environment-resolver.d.ts +1 -1
- package/dist/{environment → infrastructure/environment}/forge-env.d.ts +1 -1
- package/dist/{environment → infrastructure/environment}/variable-interpolator.d.ts +1 -1
- package/dist/{execution → infrastructure/execution}/collection-request-executor-interfaces.d.ts +1 -1
- package/dist/{execution → infrastructure/execution}/collection-request-executor.d.ts +3 -3
- package/dist/{execution → infrastructure/execution}/request-executor.d.ts +4 -4
- package/dist/{execution → infrastructure/execution}/request-preparer-interfaces.d.ts +2 -2
- package/dist/{execution → infrastructure/execution}/request-preparer.d.ts +5 -5
- package/dist/{graphql → infrastructure/graphql}/graphql-schema-service.d.ts +1 -1
- package/dist/{history → infrastructure/history}/history-interfaces.d.ts +1 -1
- package/dist/{history → infrastructure/history}/request-history.d.ts +1 -1
- package/dist/{http → infrastructure/http}/fetch-http-client.d.ts +2 -2
- package/dist/{http → infrastructure/http}/http-request-service.d.ts +2 -2
- package/dist/infrastructure/http/index.d.ts +4 -0
- package/dist/{http → infrastructure/http}/interceptor-chain.d.ts +1 -1
- package/dist/{http → infrastructure/http}/interfaces.d.ts +1 -1
- package/dist/{http → infrastructure/http}/merge-request-settings.d.ts +1 -1
- package/dist/{http → infrastructure/http}/native-http-client.d.ts +2 -2
- package/dist/infrastructure/http/node-http-executor.adapter.d.ts +25 -0
- package/dist/{http → infrastructure/http}/request-preprocessor.d.ts +1 -1
- package/dist/{import-export → infrastructure/import-export}/import-postman-environment.d.ts +3 -3
- package/dist/{import-export → infrastructure/import-export}/rest-client-export.d.ts +3 -3
- package/dist/infrastructure/index.d.ts +31 -0
- package/dist/{openapi → infrastructure/openapi}/example-generator.d.ts +1 -1
- package/dist/{openapi → infrastructure/openapi}/history-analyzer.d.ts +1 -1
- package/dist/{openapi → infrastructure/openapi}/interfaces.d.ts +2 -2
- package/dist/{openapi → infrastructure/openapi}/openapi-exporter.d.ts +2 -2
- package/dist/{openapi → infrastructure/openapi}/openapi-importer.d.ts +2 -2
- package/dist/{openapi → infrastructure/openapi}/schema-inference-service.d.ts +1 -1
- package/dist/{openapi → infrastructure/openapi}/schema-inferrer.d.ts +1 -1
- package/dist/infrastructure/parsers/collection-parser.adapter.d.ts +32 -0
- package/dist/{parsers → infrastructure/parsers}/http-forge-parser.d.ts +2 -2
- package/dist/infrastructure/parsers/index.d.ts +7 -0
- package/dist/infrastructure/persistence/file-system-history-loader.d.ts +31 -0
- package/dist/infrastructure/persistence/index.d.ts +6 -0
- package/dist/{platform → infrastructure/platform}/node-file-system.d.ts +1 -1
- package/dist/infrastructure/repositories/file-system/fs-collection-repository.d.ts +72 -0
- package/dist/infrastructure/repositories/file-system/fs-environment-file-loader.adapter.d.ts +41 -0
- package/dist/infrastructure/repositories/file-system/fs-environment-repository.d.ts +34 -0
- package/dist/infrastructure/repositories/file-system/fs-request-repository.d.ts +31 -0
- package/dist/infrastructure/repositories/file-system/index.d.ts +7 -0
- package/dist/infrastructure/repositories/in-memory/in-memory-collection-repository.d.ts +18 -0
- package/dist/infrastructure/repositories/in-memory/in-memory-environment-repository.d.ts +25 -0
- package/dist/infrastructure/repositories/in-memory/in-memory-request-repository.d.ts +25 -0
- package/dist/infrastructure/repositories/in-memory/index.d.ts +7 -0
- package/dist/infrastructure/script/index.d.ts +4 -0
- package/dist/{script → infrastructure/script}/interfaces.d.ts +13 -1
- package/dist/{script → infrastructure/script}/request-script-session.d.ts +3 -0
- package/dist/{script → infrastructure/script}/script-factories.d.ts +15 -4
- package/dist/{script → infrastructure/script}/script-utils.d.ts +3 -2
- package/dist/infrastructure/script/vm-script-executor.adapter.d.ts +19 -0
- package/dist/{test-suite → infrastructure/test-suite}/result-storage-service.d.ts +1 -1
- package/dist/{test-suite → infrastructure/test-suite}/result-storage.d.ts +1 -1
- package/dist/{test-suite → infrastructure/test-suite}/test-suite-service.d.ts +1 -1
- package/dist/{test-suite → infrastructure/test-suite}/test-suite-store.d.ts +1 -1
- package/dist/ports/executors/http-executor.interface.d.ts +34 -0
- package/dist/ports/executors/index.d.ts +5 -0
- package/dist/ports/executors/script-executor.interface.d.ts +43 -0
- package/dist/ports/external/file-system.interface.d.ts +44 -0
- package/dist/ports/external/http-client.interface.d.ts +25 -0
- package/dist/ports/external/index.d.ts +7 -0
- package/dist/ports/external/logger.interface.d.ts +17 -0
- package/dist/ports/index.d.ts +17 -0
- package/dist/ports/parsers/collection-parser.interface.d.ts +23 -0
- package/dist/ports/parsers/index.d.ts +4 -0
- package/dist/ports/repositories/collection-repository.interface.d.ts +32 -0
- package/dist/ports/repositories/environment-repository.interface.d.ts +31 -0
- package/dist/ports/repositories/index.d.ts +6 -0
- package/dist/ports/repositories/request-repository.interface.d.ts +32 -0
- package/dist/ports/storage/cache-store.interface.d.ts +26 -0
- package/dist/ports/storage/history-loader.interface.d.ts +37 -0
- package/dist/ports/storage/index.d.ts +5 -0
- package/dist/{collection/collection-service-interfaces.d.ts → types/collection.d.ts} +19 -4
- package/dist/types/environment-config.d.ts +143 -0
- package/dist/types/types.d.ts +27 -7
- package/package.json +2 -2
- package/dist/collection/folder-collection-loader.d.ts +0 -256
- package/dist/collection/interfaces.d.ts +0 -32
- package/dist/parsers/index.d.ts +0 -6
- package/dist/{collection → infrastructure/collection}/collection-loader-factory.d.ts +1 -1
- package/dist/{config → infrastructure/config}/config.interface.d.ts +0 -0
- package/dist/{config → infrastructure/config}/default-config.d.ts +0 -0
- package/dist/{config → infrastructure/config}/index.d.ts +0 -0
- package/dist/{cookie → infrastructure/cookie}/cookie-jar.d.ts +0 -0
- package/dist/{cookie → infrastructure/cookie}/cookie-utils.d.ts +0 -0
- package/dist/{cookie → infrastructure/cookie}/in-memory-cookie-jar.d.ts +1 -1
- package/dist/{cookie → infrastructure/cookie}/interfaces.d.ts +0 -0
- package/dist/{cookie → infrastructure/cookie}/persistent-cookie-jar.d.ts +1 -1
- package/dist/{environment → infrastructure/environment}/interfaces.d.ts +0 -0
- package/dist/{graphql → infrastructure/graphql}/graphql-completion-provider.d.ts +0 -0
- package/dist/{history → infrastructure/history}/request-history-service-interfaces.d.ts +0 -0
- package/dist/{history → infrastructure/history}/request-history-service.d.ts +0 -0
- package/dist/{http → infrastructure/http}/url-builder.d.ts +0 -0
- package/dist/{openapi → infrastructure/openapi}/index.d.ts +0 -0
- package/dist/{openapi → infrastructure/openapi}/ref-resolver.d.ts +0 -0
- package/dist/{openapi → infrastructure/openapi}/script-analyzer.d.ts +0 -0
- package/dist/{platform → infrastructure/platform}/data-file-parser.d.ts +0 -0
- package/dist/{script → infrastructure/script}/module-loader.d.ts +0 -0
- package/dist/{script → infrastructure/script}/script-executor.d.ts +1 -1
- /package/dist/{test-suite → infrastructure/test-suite}/index.d.ts +0 -0
- /package/dist/{test-suite → infrastructure/test-suite}/interfaces.d.ts +0 -0
- /package/dist/{test-suite → infrastructure/test-suite}/statistics-service.d.ts +0 -0
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* Interface Segregation: Each interface has a focused purpose
|
|
9
9
|
*/
|
|
10
10
|
import { Cookie } from '../cookie/interfaces';
|
|
11
|
-
import { PreparedRequest, RequestAuth, RequestBody, RequestScripts, RequestSettings, ScriptInfo, TestAssertion } from '
|
|
11
|
+
import { PreparedRequest, RequestAuth, RequestBody, RequestScripts, RequestSettings, ScriptInfo, TestAssertion } from '../../types/types';
|
|
12
12
|
export type { Cookie, ScriptInfo };
|
|
13
13
|
/**
|
|
14
14
|
* Cookie Jar Interface
|
|
@@ -68,6 +68,7 @@ export interface CommonScriptContext {
|
|
|
68
68
|
info?: ScriptInfo;
|
|
69
69
|
iteration?: number;
|
|
70
70
|
iterationCount?: number;
|
|
71
|
+
iterationData?: Record<string, any>;
|
|
71
72
|
onSessionChange?: (action: 'set' | 'unset' | 'clear', key?: string, value?: string) => void;
|
|
72
73
|
onEnvironmentChange?: (action: 'set' | 'unset' | 'clear', key?: string, value?: string) => void;
|
|
73
74
|
}
|
|
@@ -98,6 +99,10 @@ export interface PreRequestScriptResult {
|
|
|
98
99
|
modifiedSessionVariables?: Record<string, string>;
|
|
99
100
|
modifiedEnvironmentVariables?: Record<string, string>;
|
|
100
101
|
consoleOutput?: string[];
|
|
102
|
+
/** Postman-compatible: pm.execution.setNextRequest() value. null = stop runner. */
|
|
103
|
+
nextRequest?: string | null;
|
|
104
|
+
/** Postman-compatible: pm.execution.skipRequest() was called */
|
|
105
|
+
skipRequest?: boolean;
|
|
101
106
|
}
|
|
102
107
|
/**
|
|
103
108
|
* Script execution result for post-response scripts
|
|
@@ -107,6 +112,13 @@ export interface PostResponseScriptResult {
|
|
|
107
112
|
consoleOutput?: string[];
|
|
108
113
|
modifiedEnvironmentVariables?: Record<string, string>;
|
|
109
114
|
modifiedSessionVariables?: Record<string, string>;
|
|
115
|
+
/** Postman-compatible: pm.execution.setNextRequest() value. null = stop runner. */
|
|
116
|
+
nextRequest?: string | null;
|
|
117
|
+
/** Postman-compatible: pm.visualizer.set(template, data) output */
|
|
118
|
+
visualizerData?: {
|
|
119
|
+
template: string;
|
|
120
|
+
data?: any;
|
|
121
|
+
};
|
|
110
122
|
}
|
|
111
123
|
/**
|
|
112
124
|
* Test script execution context
|
|
@@ -36,6 +36,9 @@ export declare class RequestScriptSession implements IRequestScriptSession {
|
|
|
36
36
|
private _globals;
|
|
37
37
|
private _sessionVariables;
|
|
38
38
|
private _environmentVariables;
|
|
39
|
+
private _nextRequest;
|
|
40
|
+
private _skipRequest;
|
|
41
|
+
private _visualizerData;
|
|
39
42
|
constructor(deps: SessionDependencies, initialContext: PreRequestScriptContext);
|
|
40
43
|
/**
|
|
41
44
|
* Initialize the shared VM context
|
|
@@ -28,6 +28,7 @@ export interface ScriptResponse {
|
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* Response assertion helpers (Postman-style)
|
|
31
|
+
* Note: be.ok/error/etc. are getters that execute assertions on property access
|
|
31
32
|
*/
|
|
32
33
|
export interface ResponseAssertions {
|
|
33
34
|
have: {
|
|
@@ -37,10 +38,11 @@ export interface ResponseAssertions {
|
|
|
37
38
|
jsonBody(expectedJson?: any): void;
|
|
38
39
|
};
|
|
39
40
|
be: {
|
|
40
|
-
ok
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
readonly ok: any;
|
|
42
|
+
readonly success: any;
|
|
43
|
+
readonly error: any;
|
|
44
|
+
readonly clientError: any;
|
|
45
|
+
readonly serverError: any;
|
|
44
46
|
};
|
|
45
47
|
}
|
|
46
48
|
/**
|
|
@@ -54,14 +56,17 @@ export declare function createResponseObject(response: ResponseContext): ScriptR
|
|
|
54
56
|
export interface ExpectChain {
|
|
55
57
|
_value: any;
|
|
56
58
|
_negated: boolean;
|
|
59
|
+
_deep: boolean;
|
|
57
60
|
not: ExpectChain;
|
|
58
61
|
to: ExpectChain;
|
|
59
62
|
be: ExpectChain;
|
|
60
63
|
have: ExpectChain;
|
|
64
|
+
deep: ExpectChain;
|
|
61
65
|
equal(expected: any): ExpectChain;
|
|
62
66
|
eql(expected: any): ExpectChain;
|
|
63
67
|
property(name: string, value?: any): ExpectChain;
|
|
64
68
|
ok: ExpectChain;
|
|
69
|
+
exist: ExpectChain;
|
|
65
70
|
include(value: any): ExpectChain;
|
|
66
71
|
oneOf(values: any[]): ExpectChain;
|
|
67
72
|
match(pattern: RegExp): ExpectChain;
|
|
@@ -70,12 +75,18 @@ export interface ExpectChain {
|
|
|
70
75
|
greaterThan(num: number): ExpectChain;
|
|
71
76
|
lessThan(num: number): ExpectChain;
|
|
72
77
|
within(start: number, end: number): ExpectChain;
|
|
78
|
+
a(type: string): ExpectChain;
|
|
79
|
+
an(type: string): ExpectChain;
|
|
73
80
|
true: ExpectChain;
|
|
74
81
|
false: ExpectChain;
|
|
75
82
|
null: ExpectChain;
|
|
76
83
|
undefined: ExpectChain;
|
|
77
84
|
empty: ExpectChain;
|
|
78
85
|
length(len: number): ExpectChain;
|
|
86
|
+
lengthOf(len: number): ExpectChain;
|
|
87
|
+
members(arr: any[]): ExpectChain;
|
|
88
|
+
keys(...args: any[]): ExpectChain;
|
|
89
|
+
string(substr: string): ExpectChain;
|
|
79
90
|
}
|
|
80
91
|
/**
|
|
81
92
|
* Create Chai-style expect chain for assertions
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Single Responsibility: Pure utility functions for script execution
|
|
5
5
|
* These are stateless helper functions with no side effects
|
|
6
6
|
*/
|
|
7
|
-
import { TestAssertion } from '
|
|
7
|
+
import { TestAssertion } from '../../types/types';
|
|
8
8
|
/**
|
|
9
9
|
* Console message structure for script output
|
|
10
10
|
*/
|
|
@@ -32,8 +32,9 @@ export declare function formatConsoleOutput(messages: ConsoleMessage[]): string[
|
|
|
32
32
|
export declare function createScriptConsole(messages: ConsoleMessage[]): Console;
|
|
33
33
|
/**
|
|
34
34
|
* Create a test function that records assertions
|
|
35
|
+
* Supports both sync and async test functions (Postman-compatible)
|
|
35
36
|
*/
|
|
36
|
-
export declare function createTestFunction(assertions: TestAssertion[]):
|
|
37
|
+
export declare function createTestFunction(assertions: TestAssertion[]): any;
|
|
37
38
|
/**
|
|
38
39
|
* Normalize HTTP headers to Record<string, string>
|
|
39
40
|
* Converts multi-value headers (string[]) to comma-separated strings
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VM Script Executor Adapter - Implements IScriptExecutor (port)
|
|
3
|
+
*
|
|
4
|
+
* Wraps existing ScriptExecutor to conform to the new port interface.
|
|
5
|
+
* The legacy ScriptExecutor uses `createRequestSession()` pattern;
|
|
6
|
+
* this adapter translates to the simpler `executePreRequest` / `executePostResponse` port API.
|
|
7
|
+
*/
|
|
8
|
+
import { IScriptExecutor as IScriptExecutorPort, IScriptSession, IScriptResult } from '../../ports/executors/script-executor.interface';
|
|
9
|
+
import { HttpResponse } from '../../types/types';
|
|
10
|
+
import { ScriptExecutor } from './script-executor';
|
|
11
|
+
/**
|
|
12
|
+
* Adapter that implements ports/IScriptExecutor using the legacy ScriptExecutor
|
|
13
|
+
*/
|
|
14
|
+
export declare class VmScriptExecutorAdapter implements IScriptExecutorPort {
|
|
15
|
+
private scriptExecutor;
|
|
16
|
+
constructor(scriptExecutor: ScriptExecutor);
|
|
17
|
+
executePreRequest(session: IScriptSession, script: string): Promise<IScriptResult>;
|
|
18
|
+
executePostResponse(session: IScriptSession, script: string, response: HttpResponse): Promise<IScriptResult>;
|
|
19
|
+
}
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* - Aggregated stats in memory (constant size)
|
|
8
8
|
* - On-demand result loading
|
|
9
9
|
*/
|
|
10
|
-
import { ExecutionResult } from '../types/types';
|
|
11
10
|
import { IConfigService } from '../config';
|
|
11
|
+
import { ExecutionResult } from '../../types/types';
|
|
12
12
|
import { FullResultDetails, IndexPage, IResultStorageService, RecentError, RequestStats, ResultSummary, RunConfig, RunManifest, RunStats } from './result-storage';
|
|
13
13
|
/**
|
|
14
14
|
* File-based Result Storage Service for Test Suite
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* - Interface Segregation: Separate interfaces for different concerns
|
|
6
6
|
* - Dependency Inversion: Define abstractions for storage operations
|
|
7
7
|
*/
|
|
8
|
-
import { ExecutionResult } from '
|
|
8
|
+
import { ExecutionResult } from '../../types/types';
|
|
9
9
|
/**
|
|
10
10
|
* HTTP Method encoding for memory efficiency
|
|
11
11
|
* Using numbers instead of strings saves ~5 bytes per summary
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Manages CRUD operations for Test Suites.
|
|
5
5
|
* Platform-agnostic version (no VS Code dependency).
|
|
6
6
|
*/
|
|
7
|
-
import { ICollectionService } from '
|
|
7
|
+
import { ICollectionService } from '../../types/collection';
|
|
8
8
|
import { IConfigService } from '../config';
|
|
9
9
|
import { ITestSuiteService, SuiteRequest, TestSuite } from './interfaces';
|
|
10
10
|
/**
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* Single Responsibility: Maintain suite state and resolve requests from collections
|
|
8
8
|
* Dependency Inversion: Depends on ICollectionService abstraction
|
|
9
9
|
*/
|
|
10
|
-
import { CollectionRequest, ICollectionService, RequestScripts } from '
|
|
10
|
+
import { CollectionRequest, ICollectionService, RequestScripts } from '../../types/collection';
|
|
11
11
|
import { SuiteRequest, TestSuite } from './interfaces';
|
|
12
12
|
/**
|
|
13
13
|
* Cached request entry with full context
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP Executor Port - Abstract HTTP execution
|
|
3
|
+
* Hides HTTP client details and interceptors
|
|
4
|
+
*
|
|
5
|
+
* Implementations: NodeHttpExecutor, FetchHttpExecutor
|
|
6
|
+
*/
|
|
7
|
+
import { HttpRequest, HttpResponse } from '../../types/types';
|
|
8
|
+
/**
|
|
9
|
+
* Execution plan that describes how to prepare and execute an HTTP request
|
|
10
|
+
*/
|
|
11
|
+
export interface IExecutionPlan {
|
|
12
|
+
request: HttpRequest;
|
|
13
|
+
preScripts?: string[];
|
|
14
|
+
postScripts?: string[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* HTTP Executor - Handles HTTP request execution with interceptors and middleware
|
|
18
|
+
*/
|
|
19
|
+
export interface IHttpExecutor {
|
|
20
|
+
/**
|
|
21
|
+
* Prepare request for execution
|
|
22
|
+
* - Apply interceptors
|
|
23
|
+
* - Add cookies
|
|
24
|
+
* - Resolve variables
|
|
25
|
+
*/
|
|
26
|
+
prepare(plan: IExecutionPlan): Promise<HttpRequest>;
|
|
27
|
+
/**
|
|
28
|
+
* Execute prepared HTTP request
|
|
29
|
+
* - Send over network
|
|
30
|
+
* - Apply response interceptors
|
|
31
|
+
* - Save cookies
|
|
32
|
+
*/
|
|
33
|
+
execute(prepared: HttpRequest): Promise<HttpResponse>;
|
|
34
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Script Executor Port - Abstract script execution
|
|
3
|
+
* Hides VM and runtime details
|
|
4
|
+
*
|
|
5
|
+
* Implementations: VmScriptExecutor, NodeScriptExecutor
|
|
6
|
+
*/
|
|
7
|
+
import { HttpResponse } from '../../types/types';
|
|
8
|
+
/**
|
|
9
|
+
* Script execution session - tracks state during execution
|
|
10
|
+
*/
|
|
11
|
+
export interface IScriptSession {
|
|
12
|
+
variables: Record<string, any>;
|
|
13
|
+
environment: Record<string, any>;
|
|
14
|
+
cookies: Record<string, string>;
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Result of script execution
|
|
19
|
+
*/
|
|
20
|
+
export interface IScriptResult {
|
|
21
|
+
success: boolean;
|
|
22
|
+
output: any;
|
|
23
|
+
errors: string[];
|
|
24
|
+
logs: string[];
|
|
25
|
+
variableChanges: Record<string, any>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Script Executor - Handles pre-request and post-response scripts
|
|
29
|
+
*/
|
|
30
|
+
export interface IScriptExecutor {
|
|
31
|
+
/**
|
|
32
|
+
* Execute pre-request script
|
|
33
|
+
* - Modifies request before sending
|
|
34
|
+
* - Can set variables, headers, etc.
|
|
35
|
+
*/
|
|
36
|
+
executePreRequest(session: IScriptSession, script: string): Promise<IScriptResult>;
|
|
37
|
+
/**
|
|
38
|
+
* Execute post-response script
|
|
39
|
+
* - Processes response after receiving
|
|
40
|
+
* - Can validate, test, extract data
|
|
41
|
+
*/
|
|
42
|
+
executePostResponse(session: IScriptSession, script: string, response: HttpResponse): Promise<IScriptResult>;
|
|
43
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File System Port - Abstract file system operations
|
|
3
|
+
* Enables platform-agnostic code (Node.js, browser, etc.)
|
|
4
|
+
*
|
|
5
|
+
* Implementation: NodeFileSystem
|
|
6
|
+
*/
|
|
7
|
+
export interface IFileSystem {
|
|
8
|
+
/**
|
|
9
|
+
* Check if a path exists (file or directory)
|
|
10
|
+
*/
|
|
11
|
+
exists(path: string): Promise<boolean>;
|
|
12
|
+
/**
|
|
13
|
+
* Read file contents as UTF-8 string
|
|
14
|
+
*/
|
|
15
|
+
readFile(path: string): Promise<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Write file contents
|
|
18
|
+
*/
|
|
19
|
+
writeFile(path: string, content: string): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* List directory contents
|
|
22
|
+
*/
|
|
23
|
+
readDir(path: string): Promise<string[]>;
|
|
24
|
+
/**
|
|
25
|
+
* Create directory (recursively)
|
|
26
|
+
*/
|
|
27
|
+
mkdir(path: string, options?: {
|
|
28
|
+
recursive?: boolean;
|
|
29
|
+
}): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Delete file or empty directory
|
|
32
|
+
*/
|
|
33
|
+
delete(path: string): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Get file metadata
|
|
36
|
+
*/
|
|
37
|
+
stat(path: string): Promise<FileStat>;
|
|
38
|
+
}
|
|
39
|
+
export interface FileStat {
|
|
40
|
+
isDirectory(): boolean;
|
|
41
|
+
isFile(): boolean;
|
|
42
|
+
size: number;
|
|
43
|
+
mtimeMs?: number;
|
|
44
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP Client Port - Abstract HTTP operations
|
|
3
|
+
* Enables switching between fetch, Node.js fetch, Node.js http, etc.
|
|
4
|
+
*
|
|
5
|
+
* Implementations: NodeHttpClient, FetchHttpClient
|
|
6
|
+
*/
|
|
7
|
+
export interface IHttpClient {
|
|
8
|
+
/**
|
|
9
|
+
* Execute HTTP request
|
|
10
|
+
*/
|
|
11
|
+
execute(request: IHttpClientRequest): Promise<IHttpClientResponse>;
|
|
12
|
+
}
|
|
13
|
+
export interface IHttpClientRequest {
|
|
14
|
+
method: string;
|
|
15
|
+
url: string;
|
|
16
|
+
headers: Record<string, string>;
|
|
17
|
+
body?: string | Buffer;
|
|
18
|
+
timeout?: number;
|
|
19
|
+
}
|
|
20
|
+
export interface IHttpClientResponse {
|
|
21
|
+
status: number;
|
|
22
|
+
statusText: string;
|
|
23
|
+
headers: Record<string, string | string[]>;
|
|
24
|
+
body: Buffer | string;
|
|
25
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logger Port - Abstract logging operations
|
|
3
|
+
*
|
|
4
|
+
* Implementations: ConsoleLogger, SilentLogger, CustomLogger
|
|
5
|
+
*/
|
|
6
|
+
export declare enum LogLevel {
|
|
7
|
+
DEBUG = "DEBUG",
|
|
8
|
+
INFO = "INFO",
|
|
9
|
+
WARN = "WARN",
|
|
10
|
+
ERROR = "ERROR"
|
|
11
|
+
}
|
|
12
|
+
export interface ILogger {
|
|
13
|
+
debug(message: string, context?: Record<string, any>): void;
|
|
14
|
+
info(message: string, context?: Record<string, any>): void;
|
|
15
|
+
warn(message: string, context?: Record<string, any>): void;
|
|
16
|
+
error(message: string, error?: Error | Record<string, any>): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ports Layer - Abstract interfaces (Hexagonal Architecture)
|
|
3
|
+
*
|
|
4
|
+
* Defines contracts for:
|
|
5
|
+
* - Data access (Repositories)
|
|
6
|
+
* - Execution (HTTP, Scripts)
|
|
7
|
+
* - Storage (History, Cache)
|
|
8
|
+
* - External systems (FileSystem, HTTP Client, Logger)
|
|
9
|
+
* - Parsing (Collection formats)
|
|
10
|
+
*
|
|
11
|
+
* Implementations are in the infrastructure layer
|
|
12
|
+
*/
|
|
13
|
+
export * from './external';
|
|
14
|
+
export * from './repositories';
|
|
15
|
+
export * from './executors';
|
|
16
|
+
export * from './storage';
|
|
17
|
+
export * from './parsers';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collection Parser Port - Abstract collection parsing
|
|
3
|
+
*
|
|
4
|
+
* Implementations: HttpForgeParser, PostmanParser, OpenAPIParser
|
|
5
|
+
*/
|
|
6
|
+
import { UnifiedCollection } from '../../types/types';
|
|
7
|
+
/**
|
|
8
|
+
* Collection Parser - Parses different collection formats
|
|
9
|
+
*/
|
|
10
|
+
export interface ICollectionParser {
|
|
11
|
+
/**
|
|
12
|
+
* Check if this parser can handle the content
|
|
13
|
+
*/
|
|
14
|
+
canHandle(content: string, format?: string): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Parse collection from content
|
|
17
|
+
*/
|
|
18
|
+
parse(content: string): Promise<UnifiedCollection>;
|
|
19
|
+
/**
|
|
20
|
+
* Supported formats (e.g., 'http-forge', 'postman', 'openapi')
|
|
21
|
+
*/
|
|
22
|
+
readonly supportedFormats: string[];
|
|
23
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collection Repository Port - Abstract collection data access
|
|
3
|
+
* Enables switching between file-based, in-memory, cloud storage, etc.
|
|
4
|
+
*
|
|
5
|
+
* Implementations: FileSystemCollectionRepository, InMemoryCollectionRepository
|
|
6
|
+
*/
|
|
7
|
+
import { UnifiedCollection } from '../../types/types';
|
|
8
|
+
/**
|
|
9
|
+
* Repository for managing collections
|
|
10
|
+
*/
|
|
11
|
+
export interface ICollectionRepository {
|
|
12
|
+
/**
|
|
13
|
+
* Find collection by ID
|
|
14
|
+
*/
|
|
15
|
+
findById(id: string): Promise<UnifiedCollection | null>;
|
|
16
|
+
/**
|
|
17
|
+
* Find all collections
|
|
18
|
+
*/
|
|
19
|
+
findAll(): Promise<UnifiedCollection[]>;
|
|
20
|
+
/**
|
|
21
|
+
* Save or update collection
|
|
22
|
+
*/
|
|
23
|
+
save(id: string, collection: UnifiedCollection): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Delete collection by ID
|
|
26
|
+
*/
|
|
27
|
+
delete(id: string): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Check if collection exists
|
|
30
|
+
*/
|
|
31
|
+
exists(id: string): Promise<boolean>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment Repository Port - Abstract environment data access
|
|
3
|
+
*
|
|
4
|
+
* Implementations: FileSystemEnvironmentRepository
|
|
5
|
+
*/
|
|
6
|
+
import { Environment } from '../../infrastructure/environment/environment-resolver';
|
|
7
|
+
/**
|
|
8
|
+
* Repository for managing environments
|
|
9
|
+
*/
|
|
10
|
+
export interface IEnvironmentRepository {
|
|
11
|
+
/**
|
|
12
|
+
* Find environment by ID/name
|
|
13
|
+
*/
|
|
14
|
+
findById(id: string): Promise<Environment | null>;
|
|
15
|
+
/**
|
|
16
|
+
* Find active environment
|
|
17
|
+
*/
|
|
18
|
+
findActive(): Promise<Environment | null>;
|
|
19
|
+
/**
|
|
20
|
+
* Find all environments
|
|
21
|
+
*/
|
|
22
|
+
findAll(): Promise<Environment[]>;
|
|
23
|
+
/**
|
|
24
|
+
* Save or update environment
|
|
25
|
+
*/
|
|
26
|
+
save(environment: Environment): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Delete environment by ID
|
|
29
|
+
*/
|
|
30
|
+
delete(id: string): Promise<void>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request Repository Port - Abstract request data access
|
|
3
|
+
* Enables switching between file-based, in-memory, cloud storage, etc.
|
|
4
|
+
*
|
|
5
|
+
* Implementations: FileSystemRequestRepository, InMemoryRequestRepository
|
|
6
|
+
*/
|
|
7
|
+
import { UnifiedRequest } from '../../types/types';
|
|
8
|
+
/**
|
|
9
|
+
* Repository for managing individual requests
|
|
10
|
+
*/
|
|
11
|
+
export interface IRequestRepository {
|
|
12
|
+
/**
|
|
13
|
+
* Find request by ID
|
|
14
|
+
*/
|
|
15
|
+
findById(id: string): Promise<UnifiedRequest | null>;
|
|
16
|
+
/**
|
|
17
|
+
* Find all requests in a collection
|
|
18
|
+
*/
|
|
19
|
+
findAll(collectionId: string): Promise<UnifiedRequest[]>;
|
|
20
|
+
/**
|
|
21
|
+
* Save or update request
|
|
22
|
+
*/
|
|
23
|
+
save(request: UnifiedRequest): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Delete request by ID
|
|
26
|
+
*/
|
|
27
|
+
delete(id: string): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Check if request exists
|
|
30
|
+
*/
|
|
31
|
+
exists(id: string): Promise<boolean>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cache Store Port - Abstract caching
|
|
3
|
+
*
|
|
4
|
+
* Implementations: GraphQLSchemaCacheStore, MemoryCacheStore
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Generic cache store
|
|
8
|
+
*/
|
|
9
|
+
export interface ICacheStore<T> {
|
|
10
|
+
/**
|
|
11
|
+
* Get value from cache
|
|
12
|
+
*/
|
|
13
|
+
get(key: string): Promise<T | null>;
|
|
14
|
+
/**
|
|
15
|
+
* Set value in cache
|
|
16
|
+
*/
|
|
17
|
+
set(key: string, value: T, ttl?: number): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Delete value from cache
|
|
20
|
+
*/
|
|
21
|
+
delete(key: string): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Clear all cache
|
|
24
|
+
*/
|
|
25
|
+
clear(): Promise<void>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* History Loader Port - Abstract history loading
|
|
3
|
+
*
|
|
4
|
+
* Implementations: FileSystemHistoryLoader, InMemoryHistoryLoader
|
|
5
|
+
*/
|
|
6
|
+
import { HttpResponse } from '../../types/types';
|
|
7
|
+
/**
|
|
8
|
+
* History entry metadata
|
|
9
|
+
*/
|
|
10
|
+
export interface IHistoryEntry {
|
|
11
|
+
id: string;
|
|
12
|
+
requestId: string;
|
|
13
|
+
collectionId: string;
|
|
14
|
+
timestamp: Date;
|
|
15
|
+
status: number;
|
|
16
|
+
duration: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* History Loader - Loads request execution history
|
|
20
|
+
*/
|
|
21
|
+
export interface IHistoryLoader {
|
|
22
|
+
/**
|
|
23
|
+
* Load history entries for a request
|
|
24
|
+
*/
|
|
25
|
+
loadHistory(collectionId: string, requestId: string, options?: {
|
|
26
|
+
limit?: number;
|
|
27
|
+
offset?: number;
|
|
28
|
+
}): Promise<IHistoryEntry[]>;
|
|
29
|
+
/**
|
|
30
|
+
* Load full response from history
|
|
31
|
+
*/
|
|
32
|
+
loadFullResponse(collectionId: string, requestId: string, entryId: string): Promise<HttpResponse | null>;
|
|
33
|
+
/**
|
|
34
|
+
* Save history entry
|
|
35
|
+
*/
|
|
36
|
+
saveEntry(collectionId: string, requestId: string, response: HttpResponse, duration: number): Promise<IHistoryEntry>;
|
|
37
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Collection
|
|
2
|
+
* Collection Types
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Migrated from src/collection/ for better organization
|
|
5
|
+
* These types define the contracts for collection management
|
|
6
6
|
*/
|
|
7
|
-
import { CollectionRequest, KeyValueEntry, RequestAuth, RequestScripts, RequestSettings } from '
|
|
7
|
+
import { CollectionRequest, KeyValueEntry, RequestAuth, RequestScripts, RequestSettings } from './types';
|
|
8
8
|
export type { CollectionRequest, KeyValueEntry, RequestAuth, RequestScripts, RequestSettings };
|
|
9
9
|
/**
|
|
10
10
|
* Request item in a collection - CollectionRequest with type discriminator
|
|
@@ -117,3 +117,18 @@ export interface ICollectionImportExport {
|
|
|
117
117
|
export interface ICollectionService extends ICollectionReader, ICollectionWriter, IRequestManager, IFolderManager, ICollectionVariableManager, ICollectionImportExport {
|
|
118
118
|
dispose(): void;
|
|
119
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* Collection loader interface
|
|
122
|
+
*/
|
|
123
|
+
export interface ICollectionLoader {
|
|
124
|
+
load(filePath: string, options?: any): Promise<import('./types').UnifiedCollection> | import('./types').UnifiedCollection | undefined;
|
|
125
|
+
loadAll(): Promise<import('./types').UnifiedCollection[]> | import('./types').UnifiedCollection[];
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Collection parser interface (infrastructure-level)
|
|
129
|
+
* Different from ports/parsers/ICollectionParser
|
|
130
|
+
*/
|
|
131
|
+
export interface ICollectionParser {
|
|
132
|
+
canParse(content: string): boolean;
|
|
133
|
+
parse(content: string, filePath?: string): import('./types').UnifiedCollection;
|
|
134
|
+
}
|