@api-client/core 0.3.3 → 0.3.6
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 +3 -0
- package/build/browser.js +9 -0
- package/build/browser.js.map +1 -1
- package/build/index.d.ts +11 -2
- package/build/index.js +20 -2
- package/build/index.js.map +1 -1
- package/build/src/lib/fs/Fs.d.ts +52 -0
- package/build/src/lib/fs/Fs.js +245 -0
- package/build/src/lib/fs/Fs.js.map +1 -0
- package/build/src/lib/timers/Timers.d.ts +5 -0
- package/build/src/lib/timers/Timers.js +10 -0
- package/build/src/lib/timers/Timers.js.map +1 -0
- package/build/src/mocking/ProjectMock.d.ts +13 -0
- package/build/src/mocking/ProjectMock.js +16 -0
- package/build/src/mocking/ProjectMock.js.map +1 -0
- package/build/src/mocking/lib/Request.d.ts +32 -0
- package/build/src/mocking/lib/Request.js +63 -0
- package/build/src/mocking/lib/Request.js.map +1 -0
- package/build/src/mocking/lib/Response.d.ts +33 -0
- package/build/src/mocking/lib/Response.js +79 -0
- package/build/src/mocking/lib/Response.js.map +1 -0
- package/build/src/models/ErrorResponse.d.ts +5 -4
- package/build/src/models/ErrorResponse.js +18 -5
- package/build/src/models/ErrorResponse.js.map +1 -1
- package/build/src/models/SerializableError.d.ts +30 -0
- package/build/src/models/SerializableError.js +63 -0
- package/build/src/models/SerializableError.js.map +1 -0
- package/build/src/runtime/http-engine/ArcEngine.js +8 -4
- package/build/src/runtime/http-engine/ArcEngine.js.map +1 -1
- package/build/src/runtime/http-engine/HttpEngine.d.ts +3 -3
- package/build/src/runtime/http-engine/HttpEngine.js +3 -3
- package/build/src/runtime/http-engine/HttpEngine.js.map +1 -1
- package/build/src/runtime/http-engine/NodeEngine.js +9 -4
- package/build/src/runtime/http-engine/NodeEngine.js.map +1 -1
- package/build/src/runtime/http-engine/NodeEngineDirect.js +8 -2
- package/build/src/runtime/http-engine/NodeEngineDirect.js.map +1 -1
- package/build/src/runtime/node/BaseRunner.d.ts +21 -0
- package/build/src/runtime/node/BaseRunner.js +27 -0
- package/build/src/runtime/node/BaseRunner.js.map +1 -0
- package/build/src/runtime/node/ProjectParallelRunner.d.ts +81 -0
- package/build/src/runtime/node/ProjectParallelRunner.js +173 -0
- package/build/src/runtime/node/ProjectParallelRunner.js.map +1 -0
- package/build/src/runtime/node/ProjectRequestRunner.d.ts +125 -0
- package/build/src/runtime/node/ProjectRequestRunner.js +185 -0
- package/build/src/runtime/node/ProjectRequestRunner.js.map +1 -0
- package/build/src/runtime/node/ProjectRunner.d.ts +166 -64
- package/build/src/runtime/node/ProjectRunner.js +191 -139
- package/build/src/runtime/node/ProjectRunner.js.map +1 -1
- package/build/src/runtime/node/ProjectRunnerWorker.d.ts +1 -0
- package/build/src/runtime/node/ProjectRunnerWorker.js +58 -0
- package/build/src/runtime/node/ProjectRunnerWorker.js.map +1 -0
- package/build/src/runtime/node/ProjectSerialRunner.d.ts +11 -0
- package/build/src/runtime/node/ProjectSerialRunner.js +34 -0
- package/build/src/runtime/node/ProjectSerialRunner.js.map +1 -0
- package/build/src/runtime/reporters/ProjectRunCliReporter.d.ts +7 -0
- package/build/src/runtime/reporters/ProjectRunCliReporter.js +73 -0
- package/build/src/runtime/reporters/ProjectRunCliReporter.js.map +1 -0
- package/build/src/runtime/reporters/Reporter.d.ts +62 -0
- package/build/src/runtime/reporters/Reporter.js +98 -0
- package/build/src/runtime/reporters/Reporter.js.map +1 -0
- package/build/src/testing/TestCliHelper.d.ts +23 -0
- package/build/src/testing/TestCliHelper.js +71 -0
- package/build/src/testing/TestCliHelper.js.map +1 -0
- package/build/src/testing/getPort.d.ts +52 -0
- package/build/src/testing/getPort.js +169 -0
- package/build/src/testing/getPort.js.map +1 -0
- package/package.json +2 -1
- package/src/data/DataReader.ts +11 -0
- package/src/data/DataUtils.ts +108 -0
- package/src/data/JmesparthReader.ts +26 -0
- package/src/data/Json2Xml.ts +190 -0
- package/src/data/JsonReader.ts +41 -0
- package/src/data/PayloadPointer.ts +48 -0
- package/src/data/RequestDataExtractor.ts +133 -0
- package/src/data/UrlEncodedReader.ts +20 -0
- package/src/data/XmlReader.ts +103 -0
- package/src/events/BaseEvents.ts +259 -0
- package/src/events/CustomEvent.ts +27 -0
- package/src/events/EventTypes.ts +19 -0
- package/src/events/Events.ts +19 -0
- package/src/events/authorization/AuthorizationEventTypes.ts +22 -0
- package/src/events/authorization/AuthorizationEvents.ts +61 -0
- package/src/events/cookies/CookieEventTypes.ts +13 -0
- package/src/events/cookies/CookieEvents.ts +157 -0
- package/src/events/encryption/EncryptionEventTypes.ts +4 -0
- package/src/events/encryption/EncryptionEvents.ts +51 -0
- package/src/events/environment/EnvironmentEventTypes.ts +3 -0
- package/src/events/environment/EnvironmentEvents.ts +24 -0
- package/src/events/models/ClientCertificateEvents.ts +87 -0
- package/src/events/models/ModelEventTypes.ts +47 -0
- package/src/events/models/ModelEvents.ts +7 -0
- package/src/events/models/ProjectEvents.ts +331 -0
- package/src/events/process/ProcessEventTypes.ts +5 -0
- package/src/events/process/ProcessEvents.ts +76 -0
- package/src/events/readme.md +22 -0
- package/src/events/reporting/ReportingEventTypes.ts +3 -0
- package/src/events/reporting/ReportingEvents.ts +28 -0
- package/src/events/telemetry/TelemetryEventTypes.ts +10 -0
- package/src/events/telemetry/TelemetryEvents.ts +156 -0
- package/src/lib/cookies/Cookie.ts +312 -0
- package/src/lib/cookies/Cookies.ts +326 -0
- package/src/lib/cookies/Utils.ts +168 -0
- package/src/lib/fs/Fs.ts +258 -0
- package/src/lib/headers/Headers.ts +219 -0
- package/src/lib/logging/DefaultLogger.ts +19 -0
- package/src/lib/logging/DummyLogger.ts +21 -0
- package/src/lib/logging/Logger.ts +16 -0
- package/src/lib/timers/Timers.ts +9 -0
- package/src/lib/transformers/PayloadSerializer.ts +332 -0
- package/src/lib/transformers/Utils.ts +18 -0
- package/src/lib/uuid.ts +40 -0
- package/src/mocking/LegacyInterfaces.ts +52 -0
- package/src/mocking/LegacyMock.ts +37 -0
- package/src/mocking/ProjectMock.ts +20 -0
- package/src/mocking/legacy/Authorization.ts +39 -0
- package/src/mocking/legacy/Certificates.ts +145 -0
- package/src/mocking/legacy/Cookies.ts +51 -0
- package/src/mocking/legacy/HostRules.ts +43 -0
- package/src/mocking/legacy/Http.ts +236 -0
- package/src/mocking/legacy/HttpResponse.ts +106 -0
- package/src/mocking/legacy/RestApi.ts +68 -0
- package/src/mocking/legacy/Urls.ts +44 -0
- package/src/mocking/legacy/Variables.ts +53 -0
- package/src/mocking/lib/Request.ts +85 -0
- package/src/mocking/lib/Response.ts +101 -0
- package/src/models/ArcResponse.ts +166 -0
- package/src/models/Authorization.ts +481 -0
- package/src/models/AuthorizationData.ts +60 -0
- package/src/models/Backend.ts +107 -0
- package/src/models/ClientCertificate.ts +68 -0
- package/src/models/Environment.ts +279 -0
- package/src/models/ErrorResponse.ts +113 -0
- package/src/models/HistoryIndex.ts +76 -0
- package/src/models/HistoryRequest.ts +28 -0
- package/src/models/HostRule.ts +163 -0
- package/src/models/HttpCookie.ts +285 -0
- package/src/models/HttpProject.ts +1294 -0
- package/src/models/HttpProjectListItem.ts +23 -0
- package/src/models/HttpRequest.ts +124 -0
- package/src/models/HttpResponse.ts +143 -0
- package/src/models/License.ts +113 -0
- package/src/models/ProjectDefinitionProperty.ts +40 -0
- package/src/models/ProjectFolder.ts +439 -0
- package/src/models/ProjectItem.ts +135 -0
- package/src/models/ProjectParent.ts +113 -0
- package/src/models/ProjectRequest.ts +277 -0
- package/src/models/ProjectSchema.ts +202 -0
- package/src/models/Property.ts +423 -0
- package/src/models/Provider.ts +98 -0
- package/src/models/README.md +20 -0
- package/src/models/Request.ts +452 -0
- package/src/models/RequestActions.ts +163 -0
- package/src/models/RequestAuthorization.ts +115 -0
- package/src/models/RequestConfig.ts +317 -0
- package/src/models/RequestLog.ts +159 -0
- package/src/models/RequestTime.ts +108 -0
- package/src/models/RequestUiMeta.ts +258 -0
- package/src/models/RequestsSize.ts +65 -0
- package/src/models/ResponseAuthorization.ts +104 -0
- package/src/models/ResponseRedirect.ts +158 -0
- package/src/models/RevisionInfo.ts +37 -0
- package/src/models/SentRequest.ts +125 -0
- package/src/models/SerializableError.ts +80 -0
- package/src/models/SerializablePayload.ts +68 -0
- package/src/models/Server.ts +153 -0
- package/src/models/Thing.ts +110 -0
- package/src/models/Url.ts +90 -0
- package/src/models/User.ts +120 -0
- package/src/models/WebApi.ts +234 -0
- package/src/models/WebApiIndex.ts +122 -0
- package/src/models/Workspace.ts +182 -0
- package/src/models/actions/Action.ts +213 -0
- package/src/models/actions/ActionView.ts +40 -0
- package/src/models/actions/Condition.ts +207 -0
- package/src/models/actions/ConditionView.ts +42 -0
- package/src/models/actions/Enums.ts +29 -0
- package/src/models/actions/RunnableAction.ts +144 -0
- package/src/models/actions/runnable/DeleteCookieAction.ts +113 -0
- package/src/models/actions/runnable/Runnable.ts +9 -0
- package/src/models/actions/runnable/SetCookieAction.ts +216 -0
- package/src/models/actions/runnable/SetVariableAction.ts +81 -0
- package/src/models/legacy/DataExport.ts +172 -0
- package/src/models/legacy/Normalizer.ts +110 -0
- package/src/models/legacy/actions/Actions.ts +269 -0
- package/src/models/legacy/authorization/Authorization.ts +572 -0
- package/src/models/legacy/models/ApiTypes.ts +202 -0
- package/src/models/legacy/models/ArcLegacyProject.ts +39 -0
- package/src/models/legacy/models/AuthData.ts +17 -0
- package/src/models/legacy/models/ClientCertificate.ts +95 -0
- package/src/models/legacy/models/Cookies.ts +52 -0
- package/src/models/legacy/models/HostRule.ts +35 -0
- package/src/models/legacy/models/RestApi.ts +49 -0
- package/src/models/legacy/models/UrlHistory.ts +37 -0
- package/src/models/legacy/models/Variable.ts +43 -0
- package/src/models/legacy/models/base.d.ts +95 -0
- package/src/models/legacy/request/ArcRequest.ts +405 -0
- package/src/models/legacy/request/ArcResponse.ts +177 -0
- package/src/models/legacy/request/HistoryData.ts +47 -0
- package/src/models/legacy/request/Legacy.ts +45 -0
- package/src/models/legacy/request/RequestBody.ts +87 -0
- package/src/models/transformers/ArcDexieTransformer.ts +323 -0
- package/src/models/transformers/ArcLegacyNormalizer.ts +85 -0
- package/src/models/transformers/ArcLegacyTransformer.ts +200 -0
- package/src/models/transformers/ArcPouchTransformer.ts +184 -0
- package/src/models/transformers/BaseTransformer.ts +116 -0
- package/src/models/transformers/ImportUtils.ts +141 -0
- package/src/models/transformers/LegacyDataExportToApiProject.ts +76 -0
- package/src/models/transformers/LegacyExportProcessor.ts +252 -0
- package/src/models/transformers/PostmanBackupTransformer.ts +306 -0
- package/src/models/transformers/PostmanDataTransformer.ts +50 -0
- package/src/models/transformers/PostmanTransformer.ts +106 -0
- package/src/models/transformers/PostmanV21Transformer.ts +311 -0
- package/src/models/transformers/PostmanV2Transformer.ts +308 -0
- package/src/models/transformers/har.ts +865 -0
- package/src/runtime/actions/ActionRunner.ts +83 -0
- package/src/runtime/actions/ConditionRunner.ts +194 -0
- package/src/runtime/actions/RunnableCondition.ts +57 -0
- package/src/runtime/actions/runnable/ActionRunnable.ts +19 -0
- package/src/runtime/actions/runnable/DeleteCookieRunnable.ts +39 -0
- package/src/runtime/actions/runnable/SetCookieRunnable.ts +92 -0
- package/src/runtime/actions/runnable/SetVariableRunnable.ts +53 -0
- package/src/runtime/http-engine/ArcEngine.ts +1068 -0
- package/src/runtime/http-engine/FormData.ts +85 -0
- package/src/runtime/http-engine/HttpEngine.ts +874 -0
- package/src/runtime/http-engine/HttpErrorCodes.ts +270 -0
- package/src/runtime/http-engine/NodeEngine.ts +792 -0
- package/src/runtime/http-engine/NodeEngineDirect.ts +482 -0
- package/src/runtime/http-engine/PayloadSupport.ts +84 -0
- package/src/runtime/http-engine/RequestUtils.ts +164 -0
- package/src/runtime/http-engine/ntlm/Des.ts +345 -0
- package/src/runtime/http-engine/ntlm/MD4.ts +135 -0
- package/src/runtime/http-engine/ntlm/NtlmAuth.ts +186 -0
- package/src/runtime/http-engine/ntlm/NtlmMessage.ts +57 -0
- package/src/runtime/modules/BasicAuthCache.ts +133 -0
- package/src/runtime/modules/ExecutionResponse.ts +4 -0
- package/src/runtime/modules/ModulesRegistry.ts +136 -0
- package/src/runtime/modules/RequestAuthorization.ts +110 -0
- package/src/runtime/modules/RequestCookies.ts +145 -0
- package/src/runtime/node/BaseRunner.ts +29 -0
- package/src/runtime/node/ProjectParallelRunner.ts +234 -0
- package/src/runtime/node/ProjectRequestRunner.ts +281 -0
- package/src/runtime/node/ProjectRunner.ts +374 -0
- package/src/runtime/node/ProjectRunnerWorker.ts +62 -0
- package/src/runtime/node/ProjectSerialRunner.ts +36 -0
- package/src/runtime/node/RequestFactory.ts +422 -0
- package/src/runtime/node/VariablesStore.ts +25 -0
- package/src/runtime/reporters/ProjectRunCliReporter.ts +79 -0
- package/src/runtime/reporters/Reporter.ts +142 -0
- package/src/runtime/store/StoreSdk.ts +838 -0
- package/src/runtime/variables/Cache.ts +53 -0
- package/src/runtime/variables/EvalFunctions.ts +132 -0
- package/src/runtime/variables/ProjectVariables.ts +6 -0
- package/src/runtime/variables/VariablesProcessor.ts +543 -0
- package/src/runtime/variables/VariablesTokenizer.ts +55 -0
- package/src/testing/TestCliHelper.ts +76 -0
- package/src/testing/getPort.ts +212 -0
- package/build/src/runtime/http-engine/Errors.d.ts +0 -10
- package/build/src/runtime/http-engine/Errors.js +0 -14
- package/build/src/runtime/http-engine/Errors.js.map +0 -1
|
@@ -1,178 +1,230 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { SerializableError } from '../../models/SerializableError.js';
|
|
2
|
+
import { Environment } from '../../models/Environment.js';
|
|
3
|
+
import { DummyLogger } from '../../lib/logging/DummyLogger.js';
|
|
4
|
+
import { ProjectRequestRunner } from './ProjectRequestRunner.js';
|
|
5
|
+
import { pathExists, readJson } from '../../lib/fs/Fs.js';
|
|
6
|
+
import { BaseRunner } from './BaseRunner.js';
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
* Developers can run the entire project with the `recursive` flag set. They can also
|
|
10
|
-
* set the starting point with the `parent` options.
|
|
8
|
+
* A class to be extended to run an entire API Project for the given configuration options.
|
|
11
9
|
*
|
|
12
|
-
*
|
|
10
|
+
* The main purpose of this class (and its children) is to iterate over requests
|
|
11
|
+
* in the project and execute them one-by-one.
|
|
12
|
+
*
|
|
13
|
+
* Implementations allow to execute the requests in a serial model or in parallel mode, where
|
|
14
|
+
* a separate workers are created to run the same HTTP requests in each worker.
|
|
15
|
+
*
|
|
16
|
+
* This class generates a run report which other programs can use to build all kinds of UIs
|
|
17
|
+
* around the data collected during the run.
|
|
13
18
|
*/
|
|
14
|
-
export class ProjectRunner extends
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
export class ProjectRunner extends BaseRunner {
|
|
20
|
+
/**
|
|
21
|
+
* The HTTP project to run requests from.
|
|
22
|
+
*/
|
|
17
23
|
project;
|
|
18
|
-
masterEnvironment;
|
|
19
|
-
extraVariables;
|
|
20
24
|
/**
|
|
21
|
-
* The
|
|
25
|
+
* The execution options for the project.
|
|
26
|
+
*/
|
|
27
|
+
options;
|
|
28
|
+
/**
|
|
29
|
+
* The root object (project or a folder) where the program starts iterating over the requests.
|
|
30
|
+
*/
|
|
31
|
+
root;
|
|
32
|
+
/**
|
|
33
|
+
* The selected environment to apply to the requests.
|
|
34
|
+
*/
|
|
35
|
+
environment;
|
|
36
|
+
/**
|
|
37
|
+
* The events target instance for events dispatched by the request factory.
|
|
38
|
+
*/
|
|
39
|
+
target = new EventTarget();
|
|
40
|
+
/**
|
|
41
|
+
* This is used with `--iterations`. The index of the current iteration.
|
|
42
|
+
*/
|
|
43
|
+
index = 0;
|
|
44
|
+
/**
|
|
45
|
+
* The currently executed iteration loop.
|
|
22
46
|
*/
|
|
23
|
-
|
|
24
|
-
|
|
47
|
+
currentIteration;
|
|
48
|
+
/**
|
|
49
|
+
* The number of remaining iterations to run.
|
|
50
|
+
*/
|
|
51
|
+
remaining = 1;
|
|
52
|
+
/**
|
|
53
|
+
* Whether the configuration allows iterations (the parallel mode).
|
|
54
|
+
*/
|
|
55
|
+
hasIterations = false;
|
|
56
|
+
/**
|
|
57
|
+
* When set it won't amit any event.
|
|
58
|
+
* This can be used in a background worker when events are never handled.
|
|
59
|
+
*/
|
|
60
|
+
noEmit = false;
|
|
61
|
+
constructor() {
|
|
25
62
|
super();
|
|
26
|
-
this.
|
|
27
|
-
this.
|
|
28
|
-
this.
|
|
29
|
-
this.masterEnvironment = opts.environment;
|
|
30
|
-
this.extraVariables = opts.variables;
|
|
63
|
+
this._requestHandler = this._requestHandler.bind(this);
|
|
64
|
+
this._responseHandler = this._responseHandler.bind(this);
|
|
65
|
+
this._errorHandler = this._errorHandler.bind(this);
|
|
31
66
|
}
|
|
32
67
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const parent = request.getParent() || project;
|
|
42
|
-
let variables;
|
|
43
|
-
if (VariablesStore.has(parent)) {
|
|
44
|
-
variables = VariablesStore.get(parent);
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
variables = await this.getVariables(parent);
|
|
48
|
-
VariablesStore.set(parent, variables);
|
|
49
|
-
}
|
|
50
|
-
const info = await this.execute(request, variables);
|
|
51
|
-
executed.push(info);
|
|
68
|
+
* A required step before running the project.
|
|
69
|
+
* It configures the execution context. It may throw an error when configuration is not valid.
|
|
70
|
+
*/
|
|
71
|
+
async configure(project, opts = {}) {
|
|
72
|
+
this.project = project;
|
|
73
|
+
this.options = opts || {};
|
|
74
|
+
if (typeof this.options.iterations === 'number' && this.options.iterations >= 0) {
|
|
75
|
+
this.remaining = this.options.iterations;
|
|
52
76
|
}
|
|
53
|
-
|
|
77
|
+
this.hasIterations = this.remaining > 1;
|
|
78
|
+
const root = opts.parent ? project.findFolder(opts.parent) : project;
|
|
79
|
+
if (!root) {
|
|
80
|
+
throw new Error(`Unable to locate the folder: ${opts.parent}`);
|
|
81
|
+
}
|
|
82
|
+
this.root = root;
|
|
83
|
+
this.environment = await this.getEnvironment();
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Creates the report of the execution.
|
|
87
|
+
*/
|
|
88
|
+
async createReport() {
|
|
89
|
+
const log = {
|
|
90
|
+
started: this.startTime,
|
|
91
|
+
ended: this.endTime,
|
|
92
|
+
iterations: this.executed,
|
|
93
|
+
};
|
|
94
|
+
return log;
|
|
54
95
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
96
|
+
/**
|
|
97
|
+
* Reads the environment data to use with the execution.
|
|
98
|
+
* If the configured environment is a location of a file
|
|
99
|
+
* it is read as API Client's environment and used in the execution.
|
|
100
|
+
* Otherwise it searches for the environment in the list of the defined
|
|
101
|
+
* environments by the name of the key.
|
|
102
|
+
*
|
|
103
|
+
* It throws when the environment cannot be found or when the file contents is invalid.
|
|
104
|
+
*/
|
|
105
|
+
async getEnvironment() {
|
|
106
|
+
const { options } = this;
|
|
107
|
+
if (!options) {
|
|
108
|
+
throw new Error(`Run configure() first.`);
|
|
61
109
|
}
|
|
62
|
-
if (
|
|
63
|
-
|
|
110
|
+
if (!options.environment) {
|
|
111
|
+
return;
|
|
64
112
|
}
|
|
65
|
-
|
|
66
|
-
|
|
113
|
+
const fileExists = await pathExists(options.environment);
|
|
114
|
+
if (fileExists) {
|
|
115
|
+
const contents = await readJson(options.environment);
|
|
116
|
+
return new Environment(contents);
|
|
67
117
|
}
|
|
68
|
-
|
|
69
|
-
|
|
118
|
+
const root = this.root;
|
|
119
|
+
const envs = root.getEnvironments();
|
|
120
|
+
const env = envs.find(i => i.key === options.environment || i.info.name === options.environment);
|
|
121
|
+
if (!env) {
|
|
122
|
+
throw new SerializableError(`The environment cannot be found: ${options.environment}.`, 'EENVNOTFOUND');
|
|
123
|
+
}
|
|
124
|
+
return env;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Runs the requests from the project as configured.
|
|
128
|
+
*/
|
|
129
|
+
async executeIteration() {
|
|
130
|
+
const { environment, project, options, hasIterations, index, noEmit } = this;
|
|
131
|
+
if (!options || !project) {
|
|
132
|
+
throw new Error(`Run configure() first.`);
|
|
70
133
|
}
|
|
71
|
-
if (
|
|
72
|
-
|
|
134
|
+
if (!noEmit) {
|
|
135
|
+
this.emit('before-iteration', index, hasIterations);
|
|
73
136
|
}
|
|
74
|
-
const
|
|
75
|
-
|
|
137
|
+
const runner = new ProjectRequestRunner(project, {
|
|
138
|
+
environment,
|
|
139
|
+
logger: options.logger ? options.logger : new DummyLogger(),
|
|
140
|
+
eventTarget: this.target,
|
|
141
|
+
variables: this.getSystemVariables(),
|
|
142
|
+
});
|
|
143
|
+
runner.on('request', this._requestHandler);
|
|
144
|
+
runner.on('response', this._responseHandler);
|
|
145
|
+
runner.on('error', this._errorHandler);
|
|
146
|
+
this.currentIteration = {
|
|
147
|
+
index: this.index,
|
|
148
|
+
executed: [],
|
|
76
149
|
};
|
|
77
|
-
const requestData = request.expects.toJSON();
|
|
78
|
-
requestData.url = this.prepareRequestUrl(requestData.url, variables);
|
|
79
|
-
function variableHandler(e) {
|
|
80
|
-
if (e.defaultPrevented) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
const { name, value } = e.detail;
|
|
84
|
-
variables[name] = value;
|
|
85
|
-
e.preventDefault();
|
|
86
|
-
e.detail.result = Promise.resolve();
|
|
87
|
-
}
|
|
88
|
-
this.eventTarget.addEventListener(EventTypes.Environment.set, variableHandler);
|
|
89
150
|
try {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
await factory.processResponse(result);
|
|
97
|
-
request.setLog(result);
|
|
98
|
-
info.log = result;
|
|
99
|
-
this.emit('response', request.key, { ...result });
|
|
151
|
+
await runner.run({
|
|
152
|
+
parent: options.parent,
|
|
153
|
+
requests: options.request,
|
|
154
|
+
ignore: options.ignore,
|
|
155
|
+
recursive: options.recursive
|
|
156
|
+
});
|
|
100
157
|
}
|
|
101
158
|
catch (e) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
this.
|
|
159
|
+
const cause = e;
|
|
160
|
+
console.error(e);
|
|
161
|
+
this.currentIteration.error = cause.message || 'Unknown error ocurred';
|
|
162
|
+
// ...
|
|
105
163
|
}
|
|
106
|
-
this.
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
async getVariables(parent) {
|
|
110
|
-
if (this.masterEnvironment) {
|
|
111
|
-
return this.applyVariables([this.masterEnvironment]);
|
|
164
|
+
this.executed.push(this.currentIteration);
|
|
165
|
+
if (!noEmit) {
|
|
166
|
+
this.emit('after-iteration', index, hasIterations);
|
|
112
167
|
}
|
|
113
|
-
return this.createEnvironment(parent);
|
|
114
168
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
169
|
+
/**
|
|
170
|
+
* Retargets the "request" event from the factory.
|
|
171
|
+
*/
|
|
172
|
+
_requestHandler(key, request) {
|
|
173
|
+
if (!this.noEmit) {
|
|
174
|
+
this.emit('request', key, request);
|
|
175
|
+
}
|
|
118
176
|
}
|
|
119
177
|
/**
|
|
120
|
-
*
|
|
178
|
+
* Retargets the "response" event from the factory.
|
|
121
179
|
*/
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
180
|
+
_responseHandler(key, log) {
|
|
181
|
+
this.currentIteration?.executed.push(log);
|
|
182
|
+
if (!this.noEmit) {
|
|
183
|
+
this.emit('response', key, log);
|
|
184
|
+
}
|
|
125
185
|
}
|
|
126
186
|
/**
|
|
127
|
-
*
|
|
187
|
+
* Retargets the "error" event from the factory.
|
|
128
188
|
*/
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
const { server, variables: envVariables } = environment;
|
|
134
|
-
if (server) {
|
|
135
|
-
baseUri = server.readUri();
|
|
136
|
-
}
|
|
137
|
-
if (envVariables.length) {
|
|
138
|
-
envVariables.forEach((item) => {
|
|
139
|
-
const defined = variables.findIndex(i => i.name === item.name);
|
|
140
|
-
if (defined >= 0) {
|
|
141
|
-
variables[defined] = item;
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
variables.push(item);
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
const { extraVariables } = this;
|
|
150
|
-
const ctx = VariablesProcessor.createContextFromProperties(variables);
|
|
151
|
-
if (extraVariables) {
|
|
152
|
-
Object.keys(extraVariables).forEach((key) => {
|
|
153
|
-
ctx[key] = extraVariables[key];
|
|
154
|
-
});
|
|
189
|
+
_errorHandler(key, log, message) {
|
|
190
|
+
this.currentIteration?.executed.push(log);
|
|
191
|
+
if (!this.noEmit) {
|
|
192
|
+
this.emit('error', key, log, message);
|
|
155
193
|
}
|
|
156
|
-
// the `baseUri` is reserved and always set to the environment's `baseUri`.
|
|
157
|
-
ctx.baseUri = baseUri || '';
|
|
158
|
-
return this.variablesProcessor.buildContext(ctx);
|
|
159
194
|
}
|
|
160
195
|
/**
|
|
161
|
-
*
|
|
162
|
-
* @param currentUrl The URL to process.
|
|
196
|
+
* @returns Reads the system variables based on the library configuration.
|
|
163
197
|
*/
|
|
164
|
-
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
198
|
+
getSystemVariables() {
|
|
199
|
+
const result = {};
|
|
200
|
+
const { options } = this;
|
|
201
|
+
if (!options) {
|
|
202
|
+
return result;
|
|
203
|
+
}
|
|
204
|
+
const { variables } = options;
|
|
205
|
+
if (typeof variables === 'undefined') {
|
|
206
|
+
return result;
|
|
168
207
|
}
|
|
169
|
-
if (
|
|
170
|
-
return
|
|
208
|
+
if (typeof variables === 'boolean') {
|
|
209
|
+
return variables ? this._readSystemVariables() : result;
|
|
171
210
|
}
|
|
172
|
-
if (
|
|
173
|
-
return
|
|
211
|
+
if (Array.isArray(variables)) {
|
|
212
|
+
return this._readSystemVariables(variables);
|
|
174
213
|
}
|
|
175
|
-
return
|
|
214
|
+
return variables;
|
|
215
|
+
}
|
|
216
|
+
_readSystemVariables(names) {
|
|
217
|
+
const result = {};
|
|
218
|
+
Object.keys(process.env).forEach((key) => {
|
|
219
|
+
if (names && !names.includes(key)) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
const value = process.env[key];
|
|
223
|
+
if (value) {
|
|
224
|
+
result[key] = value;
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
return result;
|
|
176
228
|
}
|
|
177
229
|
}
|
|
178
230
|
//# sourceMappingURL=ProjectRunner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProjectRunner.js","sourceRoot":"","sources":["../../../../src/runtime/node/ProjectRunner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ProjectRunner.js","sourceRoot":"","sources":["../../../../src/runtime/node/ProjectRunner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAGtE,OAAO,EAAE,WAAW,EAAgB,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAI/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AA0H7C;;;;;;;;;;;GAWG;AACH,MAAM,OAAgB,aAAc,SAAQ,UAAU;IACpD;;OAEG;IACH,OAAO,CAAe;IACtB;;OAEG;IACH,OAAO,CAAyB;IAChC;;OAEG;IACH,IAAI,CAAiB;IACrB;;OAEG;IACH,WAAW,CAAe;IAC1B;;OAEG;IACH,MAAM,GAAG,IAAI,WAAW,E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AS,EAAE,GAAG,OAAO,CAAC;QAC9B,IAAI,OAAO,SAAS,KAAK,WAAW,EAAE;YACpC,OAAO,MAAM,CAAC;SACf;QACD,IAAI,OAAO,SAAS,KAAK,SAAS,EAAE;YAClC,OAAO,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,oBAAoB,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;SACzD;QACD,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;YAC5B,OAAO,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC;SAC7C;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAEO,oBAAoB,CAAC,KAAgB;QAC3C,MAAM,MAAM,GAA2B,EAAE,CAAC;QAC1C,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YACvC,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;gBACjC,OAAO;aACR;YACD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC/B,IAAI,KAAK,EAAE;gBACT,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;aACrB;QACH,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/* eslint-disable no-unused-vars */
|
|
2
|
+
import process from 'process';
|
|
3
|
+
import cluster from 'cluster';
|
|
4
|
+
import { HttpProject } from '../../models/HttpProject.js';
|
|
5
|
+
import { sleep } from '../../lib/timers/Timers.js';
|
|
6
|
+
import { ProjectRunner } from './ProjectRunner.js';
|
|
7
|
+
class ProjectExeWorker extends ProjectRunner {
|
|
8
|
+
initialize() {
|
|
9
|
+
if (cluster.isPrimary) {
|
|
10
|
+
throw new Error(`This file should not be called directly.`);
|
|
11
|
+
}
|
|
12
|
+
process.send({ cmd: 'online' });
|
|
13
|
+
process.on('message', this.messageHandler.bind(this));
|
|
14
|
+
}
|
|
15
|
+
messageHandler(message) {
|
|
16
|
+
switch (message.cmd) {
|
|
17
|
+
case 'run':
|
|
18
|
+
this.run(message.data);
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
async run(options) {
|
|
23
|
+
try {
|
|
24
|
+
await this.configure(new HttpProject(options.project), options);
|
|
25
|
+
await this.execute();
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
const cause = e;
|
|
29
|
+
process.send({ cmd: 'error', data: cause.message });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async execute() {
|
|
33
|
+
const { root } = this;
|
|
34
|
+
if (!root) {
|
|
35
|
+
throw new Error(`The project runner is not configured.`);
|
|
36
|
+
}
|
|
37
|
+
function unhandledRejection() { }
|
|
38
|
+
process.on('unhandledRejection', unhandledRejection);
|
|
39
|
+
this.startTime = Date.now();
|
|
40
|
+
while (this.remaining > 0) {
|
|
41
|
+
this.remaining--;
|
|
42
|
+
await this.executeIteration();
|
|
43
|
+
this.index++;
|
|
44
|
+
if (this.remaining && this.options?.iterationDelay) {
|
|
45
|
+
await sleep(this.options.iterationDelay);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
process.off('unhandledRejection', unhandledRejection);
|
|
49
|
+
this.endTime = Date.now();
|
|
50
|
+
const log = await this.createReport();
|
|
51
|
+
process.send({ cmd: 'result', data: log.iterations });
|
|
52
|
+
return log;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const instance = new ProjectExeWorker();
|
|
56
|
+
instance.noEmit = true;
|
|
57
|
+
instance.initialize();
|
|
58
|
+
//# sourceMappingURL=ProjectRunnerWorker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProjectRunnerWorker.js","sourceRoot":"","sources":["../../../../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AAC;QACtB,IAAI,CAAC,IAAI,EAAE;YACT,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;SAC1D;QACD,SAAS,kBAAkB,KAAU,CAAC;QACtC,OAAO,CAAC,EAAE,CAAC,oBAAoB,EAAE,kBAAkB,CAAC,CAAC;QACrD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAC,SAAS,GAAG,CAAC,EAAE;YACzB,IAAI,CAAC,SAAS,EAAE,CAAC;YACjB,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC9B,IAAI,CAAC,KAAK,EAAE,CAAC;YACb,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE;gBAClD,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;aAC1C;SACF;QACD,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,kBAAkB,CAAC,CAAC;QACtD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAE1B,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;QACtC,OAAO,CAAC,IAAK,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC;QACvD,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AAED,MAAM,QAAQ,GAAG,IAAI,gBAAgB,EAAE,CAAC;AACxC,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC;AACvB,QAAQ,CAAC,UAAU,EAAE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ProjectRunner } from './ProjectRunner.js';
|
|
2
|
+
import { IProjectExecutionLog } from '../reporters/Reporter.js';
|
|
3
|
+
/**
|
|
4
|
+
* Project runner that runs the requests in the project one-by-one.
|
|
5
|
+
*/
|
|
6
|
+
export declare class ProjectSerialRunner extends ProjectRunner {
|
|
7
|
+
/**
|
|
8
|
+
* Executes the requests in the project.
|
|
9
|
+
*/
|
|
10
|
+
execute(): Promise<IProjectExecutionLog>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { SerializableError } from '../../models/SerializableError.js';
|
|
2
|
+
import { sleep } from '../../lib/timers/Timers.js';
|
|
3
|
+
import { ProjectRunner } from './ProjectRunner.js';
|
|
4
|
+
/**
|
|
5
|
+
* Project runner that runs the requests in the project one-by-one.
|
|
6
|
+
*/
|
|
7
|
+
export class ProjectSerialRunner extends ProjectRunner {
|
|
8
|
+
/**
|
|
9
|
+
* Executes the requests in the project.
|
|
10
|
+
*/
|
|
11
|
+
async execute() {
|
|
12
|
+
const { root } = this;
|
|
13
|
+
if (!root) {
|
|
14
|
+
throw new SerializableError(`The project runner is not configured.`, 'ECONFIGURE');
|
|
15
|
+
}
|
|
16
|
+
this.startTime = Date.now();
|
|
17
|
+
while (this.remaining > 0) {
|
|
18
|
+
this.remaining--;
|
|
19
|
+
await this.executeIteration();
|
|
20
|
+
this.index++;
|
|
21
|
+
if (this.remaining && this.options?.iterationDelay) {
|
|
22
|
+
this.emit('before-sleep');
|
|
23
|
+
await sleep(this.options.iterationDelay);
|
|
24
|
+
this.emit('after-sleep');
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
await sleep(0);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
this.endTime = Date.now();
|
|
31
|
+
return this.createReport();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=ProjectSerialRunner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProjectSerialRunner.js","sourceRoot":"","sources":["../../../../src/runtime/node/ProjectSerialRunner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,aAAa;IACpD;;OAEG;IACH,KAAK,CAAC,OAAO;QACX,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,IAAI,EAAE;YACT,MAAM,IAAI,iBAAiB,CAAC,uCAAuC,EAAE,YAAY,CAAC,CAAC;SACpF;QAED,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAC,SAAS,GAAG,CAAC,EAAE;YACzB,IAAI,CAAC,SAAS,EAAE,CAAC;YACjB,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC9B,IAAI,CAAC,KAAK,EAAE,CAAC;YACb,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE;gBAClD,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;gBAC1B,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;gBACzC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;aAC1B;iBAAM;gBACL,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC;aAChB;SACF;QAED,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC,YAAY,EAAE,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Table } from 'console-table-printer';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { ErrorResponse } from '../../models/ErrorResponse.js';
|
|
4
|
+
import { Reporter } from './Reporter.js';
|
|
5
|
+
/**
|
|
6
|
+
* HTTP project execution reporter for a terminal output.
|
|
7
|
+
*/
|
|
8
|
+
export class ProjectRunCliReporter extends Reporter {
|
|
9
|
+
async generate() {
|
|
10
|
+
const { info } = this;
|
|
11
|
+
const table = new Table({
|
|
12
|
+
title: 'Project execution summary',
|
|
13
|
+
columns: [
|
|
14
|
+
{ name: 'position', title: ' ', alignment: 'left', },
|
|
15
|
+
{ name: 'succeeded', title: 'Succeeded', alignment: 'right', },
|
|
16
|
+
{ name: 'failed', title: 'Failed', alignment: 'right', },
|
|
17
|
+
{ name: 'total', title: 'Total', alignment: 'right', },
|
|
18
|
+
],
|
|
19
|
+
});
|
|
20
|
+
table.addRow({
|
|
21
|
+
position: 'Iterations',
|
|
22
|
+
succeeded: info.iterations.length,
|
|
23
|
+
failed: 0,
|
|
24
|
+
total: info.iterations.length,
|
|
25
|
+
});
|
|
26
|
+
const failed = this.computeFailed();
|
|
27
|
+
const succeeded = this.computeSucceeded();
|
|
28
|
+
table.addRow({
|
|
29
|
+
position: 'Requests',
|
|
30
|
+
succeeded,
|
|
31
|
+
failed: failed > 0 ? chalk.redBright(failed) : failed,
|
|
32
|
+
total: failed + succeeded,
|
|
33
|
+
});
|
|
34
|
+
table.printTable();
|
|
35
|
+
process.stdout.write('\n');
|
|
36
|
+
info.iterations.forEach((run, index) => {
|
|
37
|
+
const itNumber = index + 1;
|
|
38
|
+
if (run.error) {
|
|
39
|
+
process.stdout.write(`Iteration ${itNumber} failed: ${run.error}\n\n`);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const failed = run.executed.filter(log => this.isFailedLog(log));
|
|
43
|
+
if (!failed.length) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
process.stdout.write(`Iteration ${itNumber} Errors\n`);
|
|
47
|
+
failed.forEach((log) => {
|
|
48
|
+
let url = 'Unknown request URL.';
|
|
49
|
+
if (log.request) {
|
|
50
|
+
url = log.request.url;
|
|
51
|
+
}
|
|
52
|
+
const prefix = chalk.dim(`[${url}] `);
|
|
53
|
+
if (log.response && ErrorResponse.isErrorResponse(log.response)) {
|
|
54
|
+
const response = log.response;
|
|
55
|
+
let message = response.error.message ? response.error.message : response.error;
|
|
56
|
+
if (typeof message !== 'string') {
|
|
57
|
+
message = 'Unknown error.';
|
|
58
|
+
}
|
|
59
|
+
process.stdout.write(`${prefix}${message}\n`);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (!log.request) {
|
|
63
|
+
process.stdout.write('Request not executed.\n');
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const response = log.response;
|
|
67
|
+
process.stdout.write(`${prefix} Status code is: ${response.status}\n`);
|
|
68
|
+
});
|
|
69
|
+
process.stdout.write('\n\n');
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=ProjectRunCliReporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProjectRunCliReporter.js","sourceRoot":"","sources":["../../../../src/runtime/reporters/ProjectRunCliReporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAkB,MAAM,+BAA+B,CAAC;AAG9E,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,QAAQ;IACjD,KAAK,CAAC,QAAQ;QACZ,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QAEtB,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC;YACtB,KAAK,EAAE,2BAA2B;YAClC,OAAO,EAAE;gBACP,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,GAAI;gBACrD,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,GAAG;gBAC9D,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,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