@api-client/core 0.3.11 → 0.4.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.
- package/build/browser.d.ts +10 -8
- package/build/browser.js +11 -7
- package/build/browser.js.map +1 -1
- package/build/index.d.ts +12 -11
- package/build/index.js +9 -9
- package/build/index.js.map +1 -1
- package/build/src/data/JmesparthReader.d.ts +1 -1
- package/build/src/data/JmesparthReader.js +1 -1
- package/build/src/events/models/ProjectEvents.d.ts +1 -1
- package/build/src/events/models/ProjectEvents.js +1 -2
- package/build/src/events/models/ProjectEvents.js.map +1 -1
- package/build/src/lib/transformers/PayloadSerializer.d.ts +2 -2
- package/build/src/lib/transformers/PayloadSerializer.js +3 -3
- package/build/src/lib/transformers/PayloadSerializer.js.map +1 -1
- package/build/src/mocking/ProjectMock.d.ts +7 -1
- package/build/src/mocking/ProjectMock.js +6 -0
- package/build/src/mocking/ProjectMock.js.map +1 -1
- package/build/src/mocking/lib/History.d.ts +70 -0
- package/build/src/mocking/lib/History.js +120 -0
- package/build/src/mocking/lib/History.js.map +1 -0
- package/build/src/mocking/lib/Request.d.ts +2 -2
- package/build/src/mocking/lib/Request.js +3 -2
- package/build/src/mocking/lib/Request.js.map +1 -1
- package/build/src/mocking/lib/Response.d.ts +6 -6
- package/build/src/mocking/lib/Response.js +6 -6
- package/build/src/mocking/lib/Response.js.map +1 -1
- package/build/src/mocking/lib/User.d.ts +20 -0
- package/build/src/mocking/lib/User.js +54 -0
- package/build/src/mocking/lib/User.js.map +1 -0
- package/build/src/models/AuthorizationData.d.ts +2 -2
- package/build/src/models/AuthorizationData.js +2 -2
- package/build/src/models/Backend.d.ts +85 -0
- package/build/src/models/ClientCertificate.d.ts +1 -1
- package/build/src/models/Environment.d.ts +3 -3
- package/build/src/models/Environment.js +3 -3
- package/build/src/models/Environment.js.map +1 -1
- package/build/src/models/ErrorResponse.d.ts +1 -1
- package/build/src/models/ErrorResponse.js +1 -1
- package/build/src/models/HostRule.d.ts +4 -4
- package/build/src/models/HostRule.js +4 -4
- package/build/src/models/HostRule.js.map +1 -1
- package/build/src/models/HttpHistory.d.ts +64 -18
- package/build/src/models/HttpHistory.js +43 -19
- package/build/src/models/HttpHistory.js.map +1 -1
- package/build/src/models/HttpProject.d.ts +4 -5
- package/build/src/models/HttpProject.js +3 -3
- package/build/src/models/HttpProject.js.map +1 -1
- package/build/src/models/HttpProjectListItem.d.ts +1 -1
- package/build/src/models/HttpProjectListItem.js +1 -1
- package/build/src/models/HttpProjectListItem.js.map +1 -1
- package/build/src/models/HttpRequest.d.ts +2 -2
- package/build/src/models/HttpRequest.js +2 -2
- package/build/src/models/HttpRequest.js.map +1 -1
- package/build/src/models/HttpResponse.d.ts +2 -2
- package/build/src/models/HttpResponse.js +3 -3
- package/build/src/models/HttpResponse.js.map +1 -1
- package/build/src/models/License.d.ts +3 -3
- package/build/src/models/License.js +3 -3
- package/build/src/models/License.js.map +1 -1
- package/build/src/models/ProjectFolder.d.ts +2 -2
- package/build/src/models/ProjectFolder.js +3 -3
- package/build/src/models/ProjectFolder.js.map +1 -1
- package/build/src/models/ProjectItem.d.ts +1 -1
- package/build/src/models/ProjectItem.js +2 -2
- package/build/src/models/ProjectItem.js.map +1 -1
- package/build/src/models/ProjectRequest.d.ts +2 -2
- package/build/src/models/ProjectRequest.js +1 -1
- package/build/src/models/ProjectRequest.js.map +1 -1
- package/build/src/models/ProjectSchema.d.ts +2 -2
- package/build/src/models/ProjectSchema.js +1 -1
- package/build/src/models/ProjectSchema.js.map +1 -1
- package/build/src/models/Property.d.ts +4 -4
- package/build/src/models/Property.js +4 -4
- package/build/src/models/Property.js.map +1 -1
- package/build/src/models/Provider.d.ts +3 -3
- package/build/src/models/Provider.js +3 -3
- package/build/src/models/Provider.js.map +1 -1
- package/build/src/models/Request.d.ts +2 -2
- package/build/src/models/Request.js +3 -3
- package/build/src/models/Request.js.map +1 -1
- package/build/src/models/RequestActions.d.ts +2 -4
- package/build/src/models/RequestActions.js +2 -4
- package/build/src/models/RequestActions.js.map +1 -1
- package/build/src/models/RequestAuthorization.d.ts +3 -5
- package/build/src/models/RequestAuthorization.js +2 -4
- package/build/src/models/RequestAuthorization.js.map +1 -1
- package/build/src/models/RequestConfig.d.ts +3 -5
- package/build/src/models/RequestConfig.js +1 -3
- package/build/src/models/RequestConfig.js.map +1 -1
- package/build/src/models/RequestLog.d.ts +14 -8
- package/build/src/models/RequestLog.js +18 -7
- package/build/src/models/RequestLog.js.map +1 -1
- package/build/src/models/RequestTime.d.ts +4 -6
- package/build/src/models/RequestTime.js +2 -4
- package/build/src/models/RequestTime.js.map +1 -1
- package/build/src/models/RequestUiMeta.d.ts +5 -5
- package/build/src/models/RequestUiMeta.js +2 -2
- package/build/src/models/RequestUiMeta.js.map +1 -1
- package/build/src/models/RequestsSize.d.ts +1 -3
- package/build/src/models/RequestsSize.js +1 -3
- package/build/src/models/RequestsSize.js.map +1 -1
- package/build/src/models/{ArcResponse.d.ts → Response.d.ts} +7 -9
- package/build/src/models/{ArcResponse.js → Response.js} +4 -6
- package/build/src/models/Response.js.map +1 -0
- package/build/src/models/ResponseAuthorization.d.ts +3 -3
- package/build/src/models/ResponseAuthorization.js +3 -3
- package/build/src/models/ResponseAuthorization.js.map +1 -1
- package/build/src/models/ResponseRedirect.d.ts +3 -5
- package/build/src/models/ResponseRedirect.js +1 -3
- package/build/src/models/ResponseRedirect.js.map +1 -1
- package/build/src/models/RevisionInfo.d.ts +1 -1
- package/build/src/models/RevisionInfo.js +1 -1
- package/build/src/models/RevisionInfo.js.map +1 -1
- package/build/src/models/SentRequest.d.ts +2 -4
- package/build/src/models/SentRequest.js +1 -3
- package/build/src/models/SentRequest.js.map +1 -1
- package/build/src/models/Server.d.ts +3 -3
- package/build/src/models/Server.js +3 -3
- package/build/src/models/Server.js.map +1 -1
- package/build/src/models/Thing.d.ts +3 -3
- package/build/src/models/Thing.js +3 -3
- package/build/src/models/Thing.js.map +1 -1
- package/build/src/models/Url.d.ts +2 -4
- package/build/src/models/Url.js +2 -4
- package/build/src/models/Url.js.map +1 -1
- package/build/src/models/User.d.ts +2 -1
- package/build/src/models/User.js +1 -1
- package/build/src/models/User.js.map +1 -1
- package/build/src/models/WebApi.d.ts +1 -1
- package/build/src/models/WebApi.js +1 -1
- package/build/src/models/WebApi.js.map +1 -1
- package/build/src/models/WebApiIndex.d.ts +1 -1
- package/build/src/models/WebApiIndex.js +1 -1
- package/build/src/models/WebApiIndex.js.map +1 -1
- package/build/src/models/Workspace.d.ts +4 -4
- package/build/src/models/Workspace.js +4 -4
- package/build/src/models/Workspace.js.map +1 -1
- package/build/src/models/actions/Action.d.ts +2 -2
- package/build/src/models/actions/Action.js +1 -1
- package/build/src/models/actions/Action.js.map +1 -1
- package/build/src/models/actions/Condition.d.ts +2 -2
- package/build/src/models/actions/Condition.js +1 -1
- package/build/src/models/actions/Condition.js.map +1 -1
- package/build/src/models/actions/RunnableAction.d.ts +1 -1
- package/build/src/models/actions/RunnableAction.js +1 -1
- package/build/src/models/actions/RunnableAction.js.map +1 -1
- package/build/src/models/actions/runnable/DeleteCookieAction.d.ts +2 -2
- package/build/src/models/actions/runnable/DeleteCookieAction.js +1 -1
- package/build/src/models/actions/runnable/DeleteCookieAction.js.map +1 -1
- package/build/src/models/actions/runnable/SetCookieAction.d.ts +2 -2
- package/build/src/models/actions/runnable/SetCookieAction.js +1 -1
- package/build/src/models/actions/runnable/SetCookieAction.js.map +1 -1
- package/build/src/models/actions/runnable/SetVariableAction.d.ts +2 -2
- package/build/src/models/actions/runnable/SetVariableAction.js +1 -1
- package/build/src/models/actions/runnable/SetVariableAction.js.map +1 -1
- package/build/src/models/transformers/ImportUtils.d.ts +1 -1
- package/build/src/models/transformers/ImportUtils.js +1 -1
- package/build/src/models/transformers/PostmanBackupTransformer.js +2 -1
- package/build/src/models/transformers/PostmanBackupTransformer.js.map +1 -1
- package/build/src/models/transformers/PostmanV21Transformer.js +2 -1
- package/build/src/models/transformers/PostmanV21Transformer.js.map +1 -1
- package/build/src/models/transformers/PostmanV2Transformer.js +2 -1
- package/build/src/models/transformers/PostmanV2Transformer.js.map +1 -1
- package/build/src/runtime/actions/RunnableCondition.d.ts +6 -7
- package/build/src/runtime/actions/RunnableCondition.js +4 -5
- package/build/src/runtime/actions/RunnableCondition.js.map +1 -1
- package/build/src/runtime/http-engine/{ArcEngine.d.ts → CoreEngine.d.ts} +3 -3
- package/build/src/runtime/http-engine/{ArcEngine.js → CoreEngine.js} +8 -8
- package/build/src/runtime/http-engine/CoreEngine.js.map +1 -0
- package/build/src/runtime/http-engine/HttpEngine.d.ts +3 -3
- package/build/src/runtime/http-engine/HttpEngine.js +3 -20
- package/build/src/runtime/http-engine/HttpEngine.js.map +1 -1
- package/build/src/runtime/modules/BasicAuthCache.js +2 -5
- package/build/src/runtime/modules/BasicAuthCache.js.map +1 -1
- package/build/src/runtime/modules/RequestCookies.d.ts +1 -1
- package/build/src/runtime/modules/RequestCookies.js +3 -2
- package/build/src/runtime/modules/RequestCookies.js.map +1 -1
- package/build/src/runtime/node/InteropInterfaces.d.ts +115 -0
- package/build/src/runtime/node/InteropInterfaces.js +2 -0
- package/build/src/runtime/node/InteropInterfaces.js.map +1 -0
- package/build/src/runtime/node/ProjectParallelRunner.d.ts +2 -7
- package/build/src/runtime/node/ProjectParallelRunner.js.map +1 -1
- package/build/src/runtime/node/ProjectRequestRunner.d.ts +17 -49
- package/build/src/runtime/node/ProjectRequestRunner.js +39 -10
- package/build/src/runtime/node/ProjectRequestRunner.js.map +1 -1
- package/build/src/runtime/node/ProjectRunner.d.ts +1 -59
- package/build/src/runtime/node/ProjectRunner.js.map +1 -1
- package/build/src/runtime/node/ProjectRunnerWorker.js.map +1 -1
- package/build/src/runtime/node/RequestFactory.d.ts +1 -1
- package/build/src/runtime/node/RequestFactory.js +3 -3
- package/build/src/runtime/node/RequestFactory.js.map +1 -1
- package/build/src/runtime/reporters/ProjectRunCliReporter.js.map +1 -1
- package/build/src/runtime/reporters/Reporter.js.map +1 -1
- package/build/src/runtime/store/AuthSdk.d.ts +28 -0
- package/build/src/runtime/store/AuthSdk.js +123 -0
- package/build/src/runtime/store/AuthSdk.js.map +1 -0
- package/build/src/runtime/store/BackendSdk.d.ts +8 -0
- package/build/src/runtime/store/BackendSdk.js +25 -0
- package/build/src/runtime/store/BackendSdk.js.map +1 -0
- package/build/src/runtime/store/HistorySdk.d.ts +48 -0
- package/build/src/runtime/store/HistorySdk.js +142 -0
- package/build/src/runtime/store/HistorySdk.js.map +1 -0
- package/build/src/runtime/store/Http.d.ts +14 -0
- package/build/src/runtime/store/Http.js +4 -0
- package/build/src/runtime/store/Http.js.map +1 -0
- package/build/src/runtime/store/HttpNode.d.ts +16 -0
- package/build/src/runtime/store/HttpNode.js +95 -0
- package/build/src/runtime/store/HttpNode.js.map +1 -0
- package/build/src/runtime/store/HttpWeb.d.ts +15 -0
- package/build/src/runtime/store/HttpWeb.js +83 -0
- package/build/src/runtime/store/HttpWeb.js.map +1 -0
- package/build/src/runtime/store/ProjectsSdk.d.ts +43 -0
- package/build/src/runtime/store/ProjectsSdk.js +144 -0
- package/build/src/runtime/store/ProjectsSdk.js.map +1 -0
- package/build/src/runtime/store/RouteBuilder.d.ts +42 -0
- package/build/src/runtime/store/RouteBuilder.js +75 -0
- package/build/src/runtime/store/RouteBuilder.js.map +1 -0
- package/build/src/runtime/store/Sdk.d.ts +79 -0
- package/build/src/runtime/store/Sdk.js +117 -0
- package/build/src/runtime/store/Sdk.js.map +1 -0
- package/build/src/runtime/store/SdkBase.d.ts +45 -0
- package/build/src/runtime/store/SdkBase.js +40 -0
- package/build/src/runtime/store/SdkBase.js.map +1 -0
- package/build/src/runtime/store/SpacesSdk.d.ts +50 -0
- package/build/src/runtime/store/SpacesSdk.js +185 -0
- package/build/src/runtime/store/SpacesSdk.js.map +1 -0
- package/build/src/runtime/store/StoreSdkNode.d.ts +10 -0
- package/build/src/runtime/store/StoreSdkNode.js +11 -0
- package/build/src/runtime/store/StoreSdkNode.js.map +1 -0
- package/build/src/runtime/store/StoreSdkWeb.d.ts +10 -0
- package/build/src/runtime/store/StoreSdkWeb.js +11 -0
- package/build/src/runtime/store/StoreSdkWeb.js.map +1 -0
- package/build/src/runtime/store/UsersSdk.d.ts +18 -0
- package/build/src/runtime/store/UsersSdk.js +88 -0
- package/build/src/runtime/store/UsersSdk.js.map +1 -0
- package/build/src/runtime/store/WsClient.d.ts +24 -0
- package/build/src/runtime/store/WsClient.js +4 -0
- package/build/src/runtime/store/WsClient.js.map +1 -0
- package/build/src/runtime/store/WsClientNode.d.ts +24 -0
- package/build/src/runtime/store/WsClientNode.js +66 -0
- package/build/src/runtime/store/WsClientNode.js.map +1 -0
- package/build/src/runtime/store/WsClientWeb.d.ts +23 -0
- package/build/src/runtime/store/WsClientWeb.js +73 -0
- package/build/src/runtime/store/WsClientWeb.js.map +1 -0
- package/package.json +6 -8
- package/readme.md +5 -5
- package/src/data/JmesparthReader.ts +1 -1
- package/src/events/models/ProjectEvents.ts +2 -2
- package/src/events/readme.md +1 -1
- package/src/lib/transformers/PayloadSerializer.ts +3 -3
- package/src/mocking/ProjectMock.ts +9 -1
- package/src/mocking/lib/History.ts +179 -0
- package/src/mocking/lib/Request.ts +5 -5
- package/src/mocking/lib/Response.ts +10 -10
- package/src/mocking/lib/User.ts +68 -0
- package/src/models/AuthorizationData.ts +2 -2
- package/src/models/Backend.ts +93 -0
- package/src/models/ClientCertificate.ts +1 -1
- package/src/models/Environment.ts +4 -4
- package/src/models/ErrorResponse.ts +1 -1
- package/src/models/HostRule.ts +5 -5
- package/src/models/HttpHistory.ts +89 -27
- package/src/models/HttpProject.ts +5 -6
- package/src/models/HttpProjectListItem.ts +1 -1
- package/src/models/HttpRequest.ts +2 -2
- package/src/models/HttpResponse.ts +3 -3
- package/src/models/License.ts +4 -4
- package/src/models/ProjectFolder.ts +3 -3
- package/src/models/ProjectItem.ts +2 -2
- package/src/models/ProjectRequest.ts +2 -2
- package/src/models/ProjectSchema.ts +2 -2
- package/src/models/Property.ts +5 -5
- package/src/models/Provider.ts +4 -4
- package/src/models/README.md +2 -2
- package/src/models/Request.ts +4 -4
- package/src/models/RequestActions.ts +2 -4
- package/src/models/RequestAuthorization.ts +3 -5
- package/src/models/RequestConfig.ts +3 -5
- package/src/models/RequestLog.ts +25 -11
- package/src/models/RequestTime.ts +4 -6
- package/src/models/RequestUiMeta.ts +5 -5
- package/src/models/RequestsSize.ts +1 -3
- package/src/models/{ArcResponse.ts → Response.ts} +12 -14
- package/src/models/ResponseAuthorization.ts +4 -4
- package/src/models/ResponseRedirect.ts +3 -5
- package/src/models/RevisionInfo.ts +1 -1
- package/src/models/SentRequest.ts +2 -4
- package/src/models/Server.ts +4 -4
- package/src/models/Thing.ts +4 -4
- package/src/models/Url.ts +2 -4
- package/src/models/User.ts +2 -1
- package/src/models/WebApi.ts +1 -1
- package/src/models/WebApiIndex.ts +1 -1
- package/src/models/Workspace.ts +5 -5
- package/src/models/actions/Action.ts +2 -2
- package/src/models/actions/Condition.ts +2 -2
- package/src/models/actions/RunnableAction.ts +1 -1
- package/src/models/actions/runnable/DeleteCookieAction.ts +2 -2
- package/src/models/actions/runnable/SetCookieAction.ts +2 -2
- package/src/models/actions/runnable/SetVariableAction.ts +2 -2
- package/src/models/transformers/ImportUtils.ts +1 -1
- package/src/models/transformers/PostmanBackupTransformer.ts +2 -1
- package/src/models/transformers/PostmanV21Transformer.ts +2 -1
- package/src/models/transformers/PostmanV2Transformer.ts +2 -1
- package/src/runtime/actions/RunnableCondition.ts +6 -7
- package/src/runtime/http-engine/{ArcEngine.ts → CoreEngine.ts} +7 -7
- package/src/runtime/http-engine/HttpEngine.ts +5 -24
- package/src/runtime/modules/BasicAuthCache.ts +2 -6
- package/src/runtime/modules/RequestCookies.ts +6 -5
- package/src/runtime/node/InteropInterfaces.ts +121 -0
- package/src/runtime/node/ProjectParallelRunner.ts +2 -9
- package/src/runtime/node/ProjectRequestRunner.ts +42 -61
- package/src/runtime/node/ProjectRunner.ts +1 -60
- package/src/runtime/node/ProjectRunnerWorker.ts +2 -1
- package/src/runtime/node/RequestFactory.ts +3 -3
- package/src/runtime/reporters/ProjectRunCliReporter.ts +2 -2
- package/src/runtime/reporters/Reporter.ts +4 -4
- package/src/runtime/store/AuthSdk.ts +126 -0
- package/src/runtime/store/BackendSdk.ts +25 -0
- package/src/runtime/store/HistorySdk.ts +157 -0
- package/src/runtime/store/Http.ts +18 -0
- package/src/runtime/store/HttpNode.ts +100 -0
- package/src/runtime/store/HttpWeb.ts +89 -0
- package/src/runtime/store/ProjectsSdk.ts +147 -0
- package/src/runtime/store/RouteBuilder.ts +89 -0
- package/src/runtime/store/Sdk.ts +131 -0
- package/src/runtime/store/SdkBase.ts +72 -0
- package/src/runtime/store/SpacesSdk.ts +190 -0
- package/src/runtime/store/StoreSdkNode.ts +13 -0
- package/src/runtime/store/StoreSdkWeb.ts +13 -0
- package/src/runtime/store/UsersSdk.ts +89 -0
- package/src/runtime/store/WsClient.ts +28 -0
- package/src/runtime/store/WsClientNode.ts +68 -0
- package/src/runtime/store/WsClientWeb.ts +75 -0
- package/build/src/models/ArcResponse.js.map +0 -1
- package/build/src/models/HistoryIndex.d.ts +0 -43
- package/build/src/models/HistoryIndex.js +0 -53
- package/build/src/models/HistoryIndex.js.map +0 -1
- package/build/src/models/HistoryRequest.d.ts +0 -13
- package/build/src/models/HistoryRequest.js +0 -25
- package/build/src/models/HistoryRequest.js.map +0 -1
- package/build/src/runtime/http-engine/ArcEngine.js.map +0 -1
- package/build/src/runtime/http-engine/NodeEngine.d.ts +0 -154
- package/build/src/runtime/http-engine/NodeEngine.js +0 -766
- package/build/src/runtime/http-engine/NodeEngine.js.map +0 -1
- package/build/src/runtime/http-engine/NodeEngineDirect.d.ts +0 -113
- package/build/src/runtime/http-engine/NodeEngineDirect.js +0 -449
- package/build/src/runtime/http-engine/NodeEngineDirect.js.map +0 -1
- package/build/src/runtime/store/StoreSdk.d.ts +0 -279
- package/build/src/runtime/store/StoreSdk.js +0 -840
- package/build/src/runtime/store/StoreSdk.js.map +0 -1
- package/src/models/HistoryIndex.ts +0 -76
- package/src/models/HistoryRequest.ts +0 -28
- package/src/runtime/http-engine/NodeEngine.ts +0 -792
- package/src/runtime/http-engine/NodeEngineDirect.ts +0 -482
- package/src/runtime/store/StoreSdk.ts +0 -895
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
import { IRunnableAction, RunnableAction } from '../../models/actions/RunnableAction.js';
|
|
2
2
|
import { IHttpRequest } from '../../models/HttpRequest.js';
|
|
3
|
-
import {
|
|
3
|
+
import { IResponse } from '../../models/Response.js';
|
|
4
4
|
import { ISentRequest } from '../../models/SentRequest.js';
|
|
5
5
|
import { IErrorResponse } from '../../models/ErrorResponse.js';
|
|
6
6
|
import { RequestDataExtractor } from '../../data/RequestDataExtractor.js';
|
|
7
7
|
import { checkCondition } from './ConditionRunner.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* A class that represents
|
|
10
|
+
* A class that represents API Client condition that runs actions when the condition is met.
|
|
11
11
|
*/
|
|
12
12
|
export class RunnableCondition extends RunnableAction {
|
|
13
13
|
/**
|
|
14
14
|
* Tests whether the condition is satisfied for request and/or response.
|
|
15
15
|
*
|
|
16
|
-
* @param request The
|
|
17
|
-
* @param
|
|
18
|
-
* @param response The ARC response object, if available.
|
|
16
|
+
* @param request The API Client request object.
|
|
17
|
+
* @param response The API Client response object, if available.
|
|
19
18
|
* @return True when the condition is satisfied.
|
|
20
19
|
*/
|
|
21
|
-
async satisfied(request: IHttpRequest | ISentRequest, response?:
|
|
20
|
+
async satisfied(request: IHttpRequest | ISentRequest, response?: IResponse | IErrorResponse): Promise<boolean> {
|
|
22
21
|
if (this.enabled === false) {
|
|
23
22
|
return false;
|
|
24
23
|
}
|
|
@@ -38,7 +37,7 @@ export class RunnableCondition extends RunnableAction {
|
|
|
38
37
|
|
|
39
38
|
/**
|
|
40
39
|
* Maps runnables interface to
|
|
41
|
-
* If an item is not an instance of `
|
|
40
|
+
* If an item is not an instance of `RunnableCondition` then it creates an instance of it
|
|
42
41
|
* by passing the map as an argument.
|
|
43
42
|
*
|
|
44
43
|
* @param value Passed list of actions.
|
|
@@ -5,7 +5,7 @@ import https from 'https';
|
|
|
5
5
|
import { HttpEngine, HttpEngineOptions, HeadersReceivedDetail } from './HttpEngine.js';
|
|
6
6
|
import { IRequestLog } from 'src/models/RequestLog.js';
|
|
7
7
|
import { IHttpRequest } from '../../models/HttpRequest.js';
|
|
8
|
-
import {
|
|
8
|
+
import { Response } from '../../models/Response.js';
|
|
9
9
|
import { SerializableError } from '../../models/SerializableError.js';
|
|
10
10
|
import { Headers } from '../../lib/headers/Headers.js';
|
|
11
11
|
import { PayloadSupport } from './PayloadSupport.js';
|
|
@@ -34,11 +34,11 @@ interface ResponseInfo {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
37
|
+
* API Client's HTTP engine.
|
|
38
38
|
* An HTTP 1.1 engine working directly on the socket. It communicates with the remote machine and
|
|
39
39
|
* collects stats about the request and response.
|
|
40
40
|
*/
|
|
41
|
-
export class
|
|
41
|
+
export class CoreEngine extends HttpEngine {
|
|
42
42
|
state = RequestState.Status;
|
|
43
43
|
rawHeaders?: Buffer;
|
|
44
44
|
_hostTestReg = /^\s*host\s*:/im;
|
|
@@ -119,7 +119,7 @@ export class ArcEngine extends HttpEngine {
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
/**
|
|
122
|
-
* Prepares an HTTP message from
|
|
122
|
+
* Prepares an HTTP message from API Client's request object.
|
|
123
123
|
*
|
|
124
124
|
* @returns Resolved promise to an `ArrayBuffer`.
|
|
125
125
|
*/
|
|
@@ -539,7 +539,7 @@ export class ArcEngine extends HttpEngine {
|
|
|
539
539
|
* @return Redirect response object
|
|
540
540
|
*/
|
|
541
541
|
async _createRedirectResponse(location: string): Promise<ResponseRedirect> {
|
|
542
|
-
const { currentResponse = new
|
|
542
|
+
const { currentResponse = new Response() } = this;
|
|
543
543
|
this.currentResponse = currentResponse;
|
|
544
544
|
if (!this.currentResponse.payload) {
|
|
545
545
|
if (this._rawBody) {
|
|
@@ -626,7 +626,7 @@ export class ArcEngine extends HttpEngine {
|
|
|
626
626
|
if (this.aborted) {
|
|
627
627
|
return;
|
|
628
628
|
}
|
|
629
|
-
const response =
|
|
629
|
+
const response = Response.fromValues(0);
|
|
630
630
|
response.loadingTime = 0;
|
|
631
631
|
this.currentResponse = response;
|
|
632
632
|
if (!data) {
|
|
@@ -1000,7 +1000,7 @@ export class ArcEngine extends HttpEngine {
|
|
|
1000
1000
|
}
|
|
1001
1001
|
if (res.statusCode === 401) {
|
|
1002
1002
|
this.currentHeaders = new Headers(res.headers);
|
|
1003
|
-
const currentResponse =
|
|
1003
|
+
const currentResponse = Response.fromValues(res.statusCode, res.statusMessage, this.currentHeaders.toString());
|
|
1004
1004
|
currentResponse.loadingTime = 0;
|
|
1005
1005
|
this.currentResponse = currentResponse;
|
|
1006
1006
|
if (head.length) {
|
|
@@ -12,7 +12,7 @@ import { IRequestAuthorization } from '../../models/RequestAuthorization.js';
|
|
|
12
12
|
import { HostRule } from '../../models/HostRule.js';
|
|
13
13
|
import { IRequestCertificate } from '../../models/ClientCertificate.js';
|
|
14
14
|
import { SentRequest } from '../../models/SentRequest.js';
|
|
15
|
-
import {
|
|
15
|
+
import { Response } from '../../models/Response.js';
|
|
16
16
|
import { ErrorResponse } from '../../models/ErrorResponse.js';
|
|
17
17
|
import { RequestsSize } from '../../models/RequestsSize.js';
|
|
18
18
|
import { HttpResponse } from '../../models/HttpResponse.js';
|
|
@@ -154,7 +154,7 @@ export abstract class HttpEngine extends EventEmitter {
|
|
|
154
154
|
/**
|
|
155
155
|
* The response object build during the execution.
|
|
156
156
|
*/
|
|
157
|
-
currentResponse?:
|
|
157
|
+
currentResponse?: Response;
|
|
158
158
|
|
|
159
159
|
/**
|
|
160
160
|
* @return True if following redirects is allowed.
|
|
@@ -470,7 +470,7 @@ export abstract class HttpEngine extends EventEmitter {
|
|
|
470
470
|
* @return Redirect response object
|
|
471
471
|
*/
|
|
472
472
|
async _createRedirectResponse(location: string): Promise<ResponseRedirect> {
|
|
473
|
-
const { currentResponse = new
|
|
473
|
+
const { currentResponse = new Response() } = this;
|
|
474
474
|
|
|
475
475
|
const response = HttpResponse.fromValues(
|
|
476
476
|
currentResponse.status,
|
|
@@ -498,7 +498,7 @@ export abstract class HttpEngine extends EventEmitter {
|
|
|
498
498
|
*
|
|
499
499
|
* @return A response object.
|
|
500
500
|
*/
|
|
501
|
-
async _createResponse(): Promise<
|
|
501
|
+
async _createResponse(): Promise<Response | undefined> {
|
|
502
502
|
if (this.aborted) {
|
|
503
503
|
return;
|
|
504
504
|
}
|
|
@@ -513,36 +513,17 @@ It means that the successful connection wasn't made.
|
|
|
513
513
|
Check your request parameters.`);
|
|
514
514
|
}
|
|
515
515
|
const body = await this.decompress(this._rawBody);
|
|
516
|
-
const response =
|
|
516
|
+
const response = Response.fromValues(
|
|
517
517
|
status,
|
|
518
518
|
currentResponse.statusText,
|
|
519
519
|
currentResponse.headers,
|
|
520
520
|
);
|
|
521
521
|
response.timings = this._computeStats(this.stats);
|
|
522
522
|
response.loadingTime = response.timings.total();
|
|
523
|
-
|
|
524
|
-
// const response = /** @type ArcResponse */ ({
|
|
525
|
-
// size: {
|
|
526
|
-
// request: 0,
|
|
527
|
-
// response: 0,
|
|
528
|
-
// },
|
|
529
|
-
// });
|
|
530
|
-
|
|
531
523
|
if (body) {
|
|
532
524
|
await response.writePayload(body);
|
|
533
525
|
currentResponse.payload = response.payload;
|
|
534
526
|
}
|
|
535
|
-
// if (body) {
|
|
536
|
-
// response.payload = body;
|
|
537
|
-
// currentResponse.payload = body;
|
|
538
|
-
// response.size.response = body.length;
|
|
539
|
-
// }
|
|
540
|
-
// if (this.sentRequest.httpMessage) {
|
|
541
|
-
// response.size.request = Buffer.from(this.sentRequest.httpMessage).length;
|
|
542
|
-
// }
|
|
543
|
-
// if (opts.includeRedirects && this.redirects.length) {
|
|
544
|
-
// response.redirects = Array.from(this.redirects);
|
|
545
|
-
// }
|
|
546
527
|
if (status === 401) {
|
|
547
528
|
response.auth = this._getAuth();
|
|
548
529
|
}
|
|
@@ -2,7 +2,7 @@ import { Headers } from '../../lib/headers/Headers.js';
|
|
|
2
2
|
import { IHttpRequest } from '../../models/HttpRequest.js';
|
|
3
3
|
import { INtlmAuthorization, IBasicAuthorization } from '../../models/Authorization.js';
|
|
4
4
|
import { ExecutionContext } from './ModulesRegistry.js';
|
|
5
|
-
import { IRequestAuthorization } from '../../models/RequestAuthorization.js';
|
|
5
|
+
import { IRequestAuthorization, Kind as RequestAuthorizationKind } from '../../models/RequestAuthorization.js';
|
|
6
6
|
|
|
7
7
|
const cache: any = {};
|
|
8
8
|
|
|
@@ -89,16 +89,12 @@ export function applyRequestBasicAuthData(request: IHttpRequest, data: IBasicAut
|
|
|
89
89
|
* but whole NTLM configuration object.
|
|
90
90
|
*
|
|
91
91
|
* Applied the `auth` object to the event's `detail.auth` object.
|
|
92
|
-
*
|
|
93
|
-
* @param {ArcBaseRequest} request The event's detail object. Changes made here will be propagated to
|
|
94
|
-
* the event.
|
|
95
|
-
* @param {NtlmAuthorization} values The authorization data to apply.
|
|
96
92
|
*/
|
|
97
93
|
function applyRequestNtlmAuthData(authorization: IRequestAuthorization[], values: INtlmAuthorization): void {
|
|
98
94
|
let ntlm: IRequestAuthorization | undefined = authorization.find(((method) => method.type === 'ntlm'));
|
|
99
95
|
if (!ntlm) {
|
|
100
96
|
ntlm = {
|
|
101
|
-
kind:
|
|
97
|
+
kind: RequestAuthorizationKind,
|
|
102
98
|
enabled: true,
|
|
103
99
|
type: 'ntlm',
|
|
104
100
|
config: {},
|
|
@@ -4,10 +4,11 @@ import { Headers } from '../../lib/headers/Headers.js';
|
|
|
4
4
|
import { IHttpRequest } from '../../models/HttpRequest.js';
|
|
5
5
|
import { ExecutionContext } from './ModulesRegistry.js';
|
|
6
6
|
import { IResponseRedirect } from '../../models/ResponseRedirect.js';
|
|
7
|
-
import {
|
|
7
|
+
import { IResponse } from '../../models/Response.js';
|
|
8
8
|
import { IErrorResponse } from '../../models/ErrorResponse.js';
|
|
9
9
|
import { IRequestLog } from '../../models/RequestLog.js';
|
|
10
10
|
import { HttpCookie } from '../../models/HttpCookie.js';
|
|
11
|
+
import { Kind as RequestConfigKind } from '../../models/RequestConfig.js';
|
|
11
12
|
import { Cookie } from '../../lib/cookies/Cookie.js';
|
|
12
13
|
|
|
13
14
|
/**
|
|
@@ -51,7 +52,7 @@ function applyCookieHeader(header: string, request: IHttpRequest): void {
|
|
|
51
52
|
* @param redirects List of redirect responses
|
|
52
53
|
* @returns An object with `cookies` and `expired` arrays of cookies.
|
|
53
54
|
*/
|
|
54
|
-
function extract(response:
|
|
55
|
+
function extract(response: IResponse, url: string, redirects?: IResponseRedirect[]): Record<'expired'|'cookies', Cookie[]> {
|
|
55
56
|
let expired: Cookie[] = [];
|
|
56
57
|
let parser;
|
|
57
58
|
let exp;
|
|
@@ -100,7 +101,7 @@ function extract(response: IArcResponse, url: string, redirects?: IResponseRedir
|
|
|
100
101
|
*
|
|
101
102
|
* Unregister this module when the application settings change to not to use session storage.
|
|
102
103
|
*
|
|
103
|
-
* In
|
|
104
|
+
* In electron the session storage is a chrome persistent partition with a session shared with the "log in to a web service".
|
|
104
105
|
* This way cookies can be acquired in through the browser login and store in the application to use them with the request.
|
|
105
106
|
*/
|
|
106
107
|
export async function processRequestCookies(request: IHttpRequest, context: ExecutionContext): Promise<void> {
|
|
@@ -126,7 +127,7 @@ export async function processResponseCookies(log: IRequestLog, context: Executio
|
|
|
126
127
|
return;
|
|
127
128
|
}
|
|
128
129
|
const config = context.config || {
|
|
129
|
-
kind:
|
|
130
|
+
kind: RequestConfigKind,
|
|
130
131
|
enabled: false,
|
|
131
132
|
};
|
|
132
133
|
let ignore = false;
|
|
@@ -137,7 +138,7 @@ export async function processResponseCookies(log: IRequestLog, context: Executio
|
|
|
137
138
|
if (ignore) {
|
|
138
139
|
return;
|
|
139
140
|
}
|
|
140
|
-
const typedResponse = log.response as
|
|
141
|
+
const typedResponse = log.response as IResponse;
|
|
141
142
|
const result = extract(typedResponse, log.request.url, log.redirects);
|
|
142
143
|
if (result.cookies.length) {
|
|
143
144
|
await CookieEvents.updateBulk(context.eventsTarget, result.cookies.map(c => HttpCookie.fromCookieParser(c).toJSON()));
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { IProjectRequestIterator, IHttpProject } from '../../models/HttpProject.js';
|
|
2
|
+
import { Environment } from '../../models/Environment.js';
|
|
3
|
+
import { Logger } from '../../lib/logging/Logger.js';
|
|
4
|
+
import { IRequestLog } from '../../models/RequestLog.js';
|
|
5
|
+
|
|
6
|
+
export interface ProjectRunnerOptions {
|
|
7
|
+
/**
|
|
8
|
+
* When provided it overrides any project / folder defined environment.
|
|
9
|
+
*/
|
|
10
|
+
environment?: Environment;
|
|
11
|
+
/**
|
|
12
|
+
* Additional variables to pass to the selected environment.
|
|
13
|
+
* This can be use to pass system variables, when needed.
|
|
14
|
+
*
|
|
15
|
+
* To use system variables tou can use `init.variables = process.env`;
|
|
16
|
+
*/
|
|
17
|
+
variables?: Record<string, string>;
|
|
18
|
+
/**
|
|
19
|
+
* Overrides the default logger (console).
|
|
20
|
+
*/
|
|
21
|
+
logger?: Logger;
|
|
22
|
+
/**
|
|
23
|
+
* The event target to use.
|
|
24
|
+
* By default it creates its own target.
|
|
25
|
+
*/
|
|
26
|
+
eventTarget?: EventTarget;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface ProjectRunnerRunOptions extends IProjectRequestIterator {
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface RunResult {
|
|
33
|
+
/**
|
|
34
|
+
* The key of the request from the HttpProject that was executed.
|
|
35
|
+
*/
|
|
36
|
+
key: string;
|
|
37
|
+
/**
|
|
38
|
+
* The key of parent folder of the executed request.
|
|
39
|
+
*/
|
|
40
|
+
parent?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Set when a fatal error occurred so the request couldn't be executed.
|
|
43
|
+
* This is not the same as error reported during a request. The log's response can still be IResponseError.
|
|
44
|
+
*/
|
|
45
|
+
error?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* The error message. Always set when the `error` is `true`.
|
|
48
|
+
*/
|
|
49
|
+
errorMessage?: string;
|
|
50
|
+
/**
|
|
51
|
+
* The request log.
|
|
52
|
+
* Always set when the `error` is `false`.
|
|
53
|
+
*/
|
|
54
|
+
log?: IRequestLog;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface IProjectParallelRunnerOptions extends IProjectRunnerOptions {
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface IProjectParallelWorkerOptions extends IProjectRunnerOptions {
|
|
61
|
+
project: IHttpProject;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface IProjectRunnerOptions {
|
|
65
|
+
/**
|
|
66
|
+
* The environment to use.
|
|
67
|
+
* This can be a name or the key of the environment located under the parent or root.
|
|
68
|
+
* It can also be a path to the environment definition. If the file exists it is used. Otherwise it tried to
|
|
69
|
+
* find the environment in the project.
|
|
70
|
+
*/
|
|
71
|
+
environment?: string;
|
|
72
|
+
/**
|
|
73
|
+
* The parent folder to execute.
|
|
74
|
+
*/
|
|
75
|
+
parent?: string;
|
|
76
|
+
/**
|
|
77
|
+
* The names or the keys of requests to execute.
|
|
78
|
+
* This can be used to limit the number of requests.
|
|
79
|
+
*/
|
|
80
|
+
request?: string[];
|
|
81
|
+
/**
|
|
82
|
+
* The number of times the execution should be repeated.
|
|
83
|
+
* Default to 1.
|
|
84
|
+
*/
|
|
85
|
+
iterations?: number;
|
|
86
|
+
/**
|
|
87
|
+
* The number of milliseconds to wait between each iteration.
|
|
88
|
+
* Default to the next frame (vary from 1 to tens of milliseconds).
|
|
89
|
+
*/
|
|
90
|
+
iterationDelay?: number;
|
|
91
|
+
/**
|
|
92
|
+
* When set it performs parallel execution for each iteration.
|
|
93
|
+
* The number of executions at the same time depends on the number of processor cores
|
|
94
|
+
* available on the current machine. The maximum of the parallel execution
|
|
95
|
+
* is the number of available cores. When the `iterations` number is higher
|
|
96
|
+
* then the "rest" is added to the iterations per each core.
|
|
97
|
+
*/
|
|
98
|
+
parallel?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* When set it includes requests in the current folder and sub-folder according to the order
|
|
101
|
+
* defined in the folder.
|
|
102
|
+
*/
|
|
103
|
+
recursive?: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* The opposite of the `requests`. The list of names or keys of requests or folders to ignore.
|
|
106
|
+
* Note, ignore is tested before the `requests`.
|
|
107
|
+
*/
|
|
108
|
+
ignore?: string[];
|
|
109
|
+
/**
|
|
110
|
+
* The logger to use with the request factory.
|
|
111
|
+
* When not set it uses the dummy logger (no output).
|
|
112
|
+
*/
|
|
113
|
+
logger?: Logger;
|
|
114
|
+
/**
|
|
115
|
+
* When true it copies all system variables to the execution environment.
|
|
116
|
+
* When an array of strings, only takes system variables that are listed in the array.
|
|
117
|
+
* When a map, it uses this map as a list of variables.
|
|
118
|
+
* When not set it does not read system variables.
|
|
119
|
+
*/
|
|
120
|
+
variables?: boolean | string[] | Record<string, string>;
|
|
121
|
+
}
|
|
@@ -2,10 +2,10 @@ import cluster, { Worker } from 'cluster';
|
|
|
2
2
|
import { cpus } from 'os';
|
|
3
3
|
import { dirname, join } from 'path';
|
|
4
4
|
import { fileURLToPath } from 'url';
|
|
5
|
-
import { HttpProject
|
|
6
|
-
import { IProjectRunnerOptions } from './ProjectRunner.js';
|
|
5
|
+
import { HttpProject } from '../../models/HttpProject.js';
|
|
7
6
|
import { IProjectExecutionLog, IProjectExecutionIteration } from '../reporters/Reporter.js';
|
|
8
7
|
import { BaseRunner } from './BaseRunner.js';
|
|
8
|
+
import { IProjectParallelRunnerOptions, IProjectParallelWorkerOptions } from './InteropInterfaces.js'
|
|
9
9
|
|
|
10
10
|
const numCPUs = cpus().length;
|
|
11
11
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
@@ -40,13 +40,6 @@ export interface IWorkerMessage {
|
|
|
40
40
|
data?: unknown;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
export interface IProjectParallelRunnerOptions extends IProjectRunnerOptions {
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export interface IProjectParallelWorkerOptions extends IProjectRunnerOptions {
|
|
47
|
-
project: IHttpProject;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
43
|
export interface ProjectParallelRunner {
|
|
51
44
|
/**
|
|
52
45
|
* Dispatched when a status of a worker change.
|
|
@@ -6,64 +6,14 @@ import { Property } from '../../models/Property.js';
|
|
|
6
6
|
import { ProjectFolder, Kind as ProjectFolderKind } from '../../models/ProjectFolder.js';
|
|
7
7
|
import { ProjectRequest } from '../../models/ProjectRequest.js';
|
|
8
8
|
import { IHttpRequest } from '../../models/HttpRequest.js';
|
|
9
|
-
import { HttpProject
|
|
9
|
+
import { HttpProject } from '../../models/HttpProject.js';
|
|
10
10
|
import { SentRequest } from '../../models/SentRequest.js';
|
|
11
11
|
import { ErrorResponse } from '../../models/ErrorResponse.js';
|
|
12
12
|
import { VariablesStore } from './VariablesStore.js';
|
|
13
13
|
import { VariablesProcessor } from '../variables/VariablesProcessor.js';
|
|
14
14
|
import { RequestFactory } from './RequestFactory.js';
|
|
15
15
|
import { EventTypes } from '../../events/EventTypes.js';
|
|
16
|
-
|
|
17
|
-
export interface ProjectRunnerOptions {
|
|
18
|
-
/**
|
|
19
|
-
* When provided it overrides any project / folder defined environment.
|
|
20
|
-
*/
|
|
21
|
-
environment?: Environment;
|
|
22
|
-
/**
|
|
23
|
-
* Additional variables to pass to the selected environment.
|
|
24
|
-
* This can be use to pass system variables, when needed.
|
|
25
|
-
*
|
|
26
|
-
* To use system variables tou can use `init.variables = process.env`;
|
|
27
|
-
*/
|
|
28
|
-
variables?: Record<string, string>;
|
|
29
|
-
/**
|
|
30
|
-
* Overrides the default logger (console).
|
|
31
|
-
*/
|
|
32
|
-
logger?: Logger;
|
|
33
|
-
/**
|
|
34
|
-
* The event target to use.
|
|
35
|
-
* By default it creates its own target.
|
|
36
|
-
*/
|
|
37
|
-
eventTarget?: EventTarget;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export interface ProjectRunnerRunOptions extends IProjectRequestIterator {
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export interface RunResult {
|
|
44
|
-
/**
|
|
45
|
-
* The key of the request from the HttpProject that was executed.
|
|
46
|
-
*/
|
|
47
|
-
key: string;
|
|
48
|
-
/**
|
|
49
|
-
* The key of parent folder of the executed request.
|
|
50
|
-
*/
|
|
51
|
-
parent?: string;
|
|
52
|
-
/**
|
|
53
|
-
* Set when a fatal error occurred so the request couldn't be executed.
|
|
54
|
-
* This is not the same as error reported during a request. The log's response can still be IResponseError.
|
|
55
|
-
*/
|
|
56
|
-
error?: boolean;
|
|
57
|
-
/**
|
|
58
|
-
* The error message. Always set when the `error` is `true`.
|
|
59
|
-
*/
|
|
60
|
-
errorMessage?: string;
|
|
61
|
-
/**
|
|
62
|
-
* The request log.
|
|
63
|
-
* Always set when the `error` is `false`.
|
|
64
|
-
*/
|
|
65
|
-
log?: IRequestLog;
|
|
66
|
-
}
|
|
16
|
+
import { ProjectRunnerOptions, ProjectRunnerRunOptions, RunResult } from './InteropInterfaces.js';
|
|
67
17
|
|
|
68
18
|
export interface ProjectRequestRunner {
|
|
69
19
|
/**
|
|
@@ -130,20 +80,50 @@ export class ProjectRequestRunner extends EventEmitter {
|
|
|
130
80
|
const { project } = this;
|
|
131
81
|
const executed: RunResult[] = [];
|
|
132
82
|
for (const request of project.requestIterator(options)) {
|
|
133
|
-
const
|
|
134
|
-
let variables: Record<string, string>;
|
|
135
|
-
if (VariablesStore.has(parent)) {
|
|
136
|
-
variables = VariablesStore.get(parent);
|
|
137
|
-
} else {
|
|
138
|
-
variables = await this.getVariables(parent);
|
|
139
|
-
VariablesStore.set(parent, variables);
|
|
140
|
-
}
|
|
141
|
-
const info = await this.execute(request, variables);
|
|
83
|
+
const info = await this._runItem(request);
|
|
142
84
|
executed.push(info);
|
|
143
85
|
}
|
|
144
86
|
return executed;
|
|
145
87
|
}
|
|
146
88
|
|
|
89
|
+
/**
|
|
90
|
+
* Allows to iterate over project requests recursively and execute each request
|
|
91
|
+
* in order. The generator yields the `RunResult` for the request.
|
|
92
|
+
*
|
|
93
|
+
* Example:
|
|
94
|
+
*
|
|
95
|
+
* ```javascript
|
|
96
|
+
* const runner = new ProjectRequestRunner(...);
|
|
97
|
+
* for await (let runResult of runner) {
|
|
98
|
+
* console.log(runResult);
|
|
99
|
+
* }
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
async* [Symbol.asyncIterator](): AsyncGenerator<RunResult> {
|
|
103
|
+
const { project } = this;
|
|
104
|
+
for (const request of project.requestIterator({ recursive: true })) {
|
|
105
|
+
const info = await this._runItem(request);
|
|
106
|
+
yield info;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
private async _runItem(request: ProjectRequest): Promise<RunResult> {
|
|
111
|
+
const folder = request.getParent();
|
|
112
|
+
const parent = folder || this.project;
|
|
113
|
+
let variables: Record<string, string>;
|
|
114
|
+
if (VariablesStore.has(parent)) {
|
|
115
|
+
variables = VariablesStore.get(parent);
|
|
116
|
+
} else {
|
|
117
|
+
variables = await this.getVariables(parent);
|
|
118
|
+
VariablesStore.set(parent, variables);
|
|
119
|
+
}
|
|
120
|
+
const info = await this.execute(request, variables);
|
|
121
|
+
if (folder && folder !== this.project) {
|
|
122
|
+
info.parent = folder.key;
|
|
123
|
+
}
|
|
124
|
+
return info;
|
|
125
|
+
}
|
|
126
|
+
|
|
147
127
|
protected async execute(request: ProjectRequest, variables: Record<string, string>): Promise<RunResult> {
|
|
148
128
|
const config = request.getConfig();
|
|
149
129
|
const factory = new RequestFactory(this.eventTarget);
|
|
@@ -189,6 +169,7 @@ export class ProjectRequestRunner extends EventEmitter {
|
|
|
189
169
|
this.emit('request', request.key, { ...requestCopy });
|
|
190
170
|
await factory.processRequestLogic(requestCopy);
|
|
191
171
|
const result = await factory.executeRequest(requestCopy);
|
|
172
|
+
result.requestId = request.key;
|
|
192
173
|
await factory.processResponse(result);
|
|
193
174
|
request.setLog(result);
|
|
194
175
|
info.log = result;
|
|
@@ -3,75 +3,16 @@ import { HttpProject } from '../../models/HttpProject.js';
|
|
|
3
3
|
import { ProjectFolder } from '../../models/ProjectFolder.js';
|
|
4
4
|
import { Environment, IEnvironment } from '../../models/Environment.js';
|
|
5
5
|
import { DummyLogger } from '../../lib/logging/DummyLogger.js';
|
|
6
|
-
import { Logger } from '../../lib/logging/Logger.js';
|
|
7
6
|
import { IRequestLog } from '../../models/RequestLog.js';
|
|
8
7
|
import { IHttpRequest } from '../../models/HttpRequest.js';
|
|
9
8
|
import { ProjectRequestRunner } from './ProjectRequestRunner.js';
|
|
10
9
|
import { IProjectExecutionIteration, IProjectExecutionLog } from '../reporters/Reporter.js';
|
|
11
10
|
import { pathExists, readJson } from '../../lib/fs/Fs.js';
|
|
12
11
|
import { BaseRunner } from './BaseRunner.js';
|
|
12
|
+
import { IProjectRunnerOptions } from './InteropInterfaces.js';
|
|
13
13
|
|
|
14
14
|
type ProjectParent = HttpProject | ProjectFolder;
|
|
15
15
|
|
|
16
|
-
export interface IProjectRunnerOptions {
|
|
17
|
-
/**
|
|
18
|
-
* The environment to use.
|
|
19
|
-
* This can be a name or the key of the environment located under the parent or root.
|
|
20
|
-
* It can also be a path to the environment definition. If the file exists it is used. Otherwise it tried to
|
|
21
|
-
* find the environment in the project.
|
|
22
|
-
*/
|
|
23
|
-
environment?: string;
|
|
24
|
-
/**
|
|
25
|
-
* The parent folder to execute.
|
|
26
|
-
*/
|
|
27
|
-
parent?: string;
|
|
28
|
-
/**
|
|
29
|
-
* The names or the keys of requests to execute.
|
|
30
|
-
* This can be used to limit the number of requests.
|
|
31
|
-
*/
|
|
32
|
-
request?: string[];
|
|
33
|
-
/**
|
|
34
|
-
* The number of times the execution should be repeated.
|
|
35
|
-
* Default to 1.
|
|
36
|
-
*/
|
|
37
|
-
iterations?: number;
|
|
38
|
-
/**
|
|
39
|
-
* The number of milliseconds to wait between each iteration.
|
|
40
|
-
* Default to the next frame (vary from 1 to tens of milliseconds).
|
|
41
|
-
*/
|
|
42
|
-
iterationDelay?: number;
|
|
43
|
-
/**
|
|
44
|
-
* When set it performs parallel execution for each iteration.
|
|
45
|
-
* The number of executions at the same time depends on the number of processor cores
|
|
46
|
-
* available on the current machine. The maximum of the parallel execution
|
|
47
|
-
* is the number of available cores. When the `iterations` number is higher
|
|
48
|
-
* then the "rest" is added to the iterations per each core.
|
|
49
|
-
*/
|
|
50
|
-
parallel?: boolean;
|
|
51
|
-
/**
|
|
52
|
-
* When set it includes requests in the current folder and sub-folder according to the order
|
|
53
|
-
* defined in the folder.
|
|
54
|
-
*/
|
|
55
|
-
recursive?: boolean;
|
|
56
|
-
/**
|
|
57
|
-
* The opposite of the `requests`. The list of names or keys of requests or folders to ignore.
|
|
58
|
-
* Note, ignore is tested before the `requests`.
|
|
59
|
-
*/
|
|
60
|
-
ignore?: string[];
|
|
61
|
-
/**
|
|
62
|
-
* The logger to use with the request factory.
|
|
63
|
-
* When not set it uses the dummy logger (no output).
|
|
64
|
-
*/
|
|
65
|
-
logger?: Logger;
|
|
66
|
-
/**
|
|
67
|
-
* When true it copies all system variables to the execution environment.
|
|
68
|
-
* When an array of strings, only takes system variables that are listed in the array.
|
|
69
|
-
* When a map, it uses this map as a list of variables.
|
|
70
|
-
* When not set it does not read system variables.
|
|
71
|
-
*/
|
|
72
|
-
variables?: boolean | string[] | Record<string, string>;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
16
|
export interface ProjectRunner {
|
|
76
17
|
/**
|
|
77
18
|
* Event dispatched when an iteration is about to start.
|
|
@@ -3,7 +3,8 @@ import process from 'process';
|
|
|
3
3
|
import cluster from 'cluster';
|
|
4
4
|
import { HttpProject } from '../../models/HttpProject.js';
|
|
5
5
|
import { IProjectExecutionLog } from '../reporters/Reporter.js';
|
|
6
|
-
import { IWorkerMessage
|
|
6
|
+
import { IWorkerMessage } from './ProjectParallelRunner.js';
|
|
7
|
+
import { IProjectParallelWorkerOptions } from './InteropInterfaces.js';
|
|
7
8
|
import { sleep } from '../../lib/timers/Timers.js';
|
|
8
9
|
import { ProjectRunner } from './ProjectRunner.js';
|
|
9
10
|
|
|
@@ -11,14 +11,14 @@ import { Action } from '../../models/actions/Action.js';
|
|
|
11
11
|
import { RunnableCondition } from '../actions/RunnableCondition.js';
|
|
12
12
|
import { ActionRunner } from '../actions/ActionRunner.js';
|
|
13
13
|
import { HttpEngineOptions } from '../http-engine/HttpEngine.js';
|
|
14
|
-
import {
|
|
14
|
+
import { CoreEngine } from '../http-engine/CoreEngine.js';
|
|
15
15
|
import { ModulesRegistry, RegisteredRequestModule, RegisteredResponseModule, ExecutionContext, RegistryPermission } from '../modules/ModulesRegistry.js';
|
|
16
16
|
import { ExecutionResponse } from '../modules/ExecutionResponse.js';
|
|
17
17
|
import { Events } from '../../events/Events.js';
|
|
18
18
|
import { Logger } from '../../lib/logging/Logger.js';
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
* The main class to make HTTP requests in the API Client
|
|
21
|
+
* The main class to make HTTP requests in the API Client.
|
|
22
22
|
* This factory includes all logic components to perform the entire HTTP request lifecycle. This includes:
|
|
23
23
|
*
|
|
24
24
|
* - variables evaluation on the request object
|
|
@@ -294,7 +294,7 @@ export class RequestFactory {
|
|
|
294
294
|
*/
|
|
295
295
|
async executeRequest(request: IHttpRequest): Promise<IRequestLog> {
|
|
296
296
|
const opts = await this.prepareEngineConfig();
|
|
297
|
-
const engine = new
|
|
297
|
+
const engine = new CoreEngine(request, opts);
|
|
298
298
|
return engine.send();
|
|
299
299
|
}
|
|
300
300
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Table } from 'console-table-printer';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
import { ErrorResponse, IErrorResponse } from '../../models/ErrorResponse.js';
|
|
4
|
-
import {
|
|
4
|
+
import { IResponse } from '../../models/Response.js';
|
|
5
5
|
import { ISerializedError } from '../../models/SerializableError.js';
|
|
6
6
|
import { Reporter } from './Reporter.js';
|
|
7
7
|
|
|
@@ -70,7 +70,7 @@ export class ProjectRunCliReporter extends Reporter {
|
|
|
70
70
|
process.stdout.write('Request not executed.\n');
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
|
-
const response = log.response as
|
|
73
|
+
const response = log.response as IResponse;
|
|
74
74
|
process.stdout.write(`${prefix} Status code is: ${response.status}\n`);
|
|
75
75
|
});
|
|
76
76
|
process.stdout.write('\n\n');
|