@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
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Lorem, Types, Internet } from '@pawel-up/data-mock';
|
|
2
|
+
import { ArcDataMockInit } from '../LegacyInterfaces.js';
|
|
3
|
+
import { ARCCookie } from '../../models/legacy/models/Cookies.js';
|
|
4
|
+
|
|
5
|
+
export class Cookies {
|
|
6
|
+
types: Types;
|
|
7
|
+
lorem: Lorem;
|
|
8
|
+
internet: Internet;
|
|
9
|
+
|
|
10
|
+
constructor(init: ArcDataMockInit={}) {
|
|
11
|
+
this.types = new Types(init.seed);
|
|
12
|
+
this.lorem = new Lorem(init);
|
|
13
|
+
this.internet = new Internet(init);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Generates random Cookie data
|
|
18
|
+
*/
|
|
19
|
+
cookie(): ARCCookie {
|
|
20
|
+
const time = this.types.datetime().getTime();
|
|
21
|
+
const result = {
|
|
22
|
+
created: time,
|
|
23
|
+
updated: time,
|
|
24
|
+
expires: this.types.datetime().getTime(),
|
|
25
|
+
maxAge: this.types.number({ min: 100, max: 1000 }),
|
|
26
|
+
name: this.lorem.word(),
|
|
27
|
+
value: this.lorem.word(),
|
|
28
|
+
_id: this.types.uuid(),
|
|
29
|
+
domain: this.internet.domain(),
|
|
30
|
+
hostOnly: this.types.boolean(),
|
|
31
|
+
httpOnly: this.types.boolean(),
|
|
32
|
+
lastAccess: time,
|
|
33
|
+
path: this.types.boolean() ? '/' : `/${this.lorem.word()}`,
|
|
34
|
+
persistent: this.types.boolean(),
|
|
35
|
+
};
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Generates a list of cookies
|
|
41
|
+
*
|
|
42
|
+
* @return List of datastore entries.
|
|
43
|
+
*/
|
|
44
|
+
cookies(size = 25): ARCCookie[] {
|
|
45
|
+
const result = [];
|
|
46
|
+
for (let i = 0; i < size; i++) {
|
|
47
|
+
result.push(this.cookie());
|
|
48
|
+
}
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Lorem, Types, Internet } from '@pawel-up/data-mock';
|
|
2
|
+
import { ArcDataMockInit } from '../LegacyInterfaces.js';
|
|
3
|
+
import { ARCHostRule } from '../../models/legacy/models/HostRule.js';
|
|
4
|
+
|
|
5
|
+
export class HostRules {
|
|
6
|
+
types: Types;
|
|
7
|
+
lorem: Lorem;
|
|
8
|
+
internet: Internet;
|
|
9
|
+
|
|
10
|
+
constructor(init: ArcDataMockInit = {}) {
|
|
11
|
+
this.types = new Types(init.seed);
|
|
12
|
+
this.lorem = new Lorem(init);
|
|
13
|
+
this.internet = new Internet(init);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Generates random host rule data object.
|
|
18
|
+
*/
|
|
19
|
+
rule(): ARCHostRule {
|
|
20
|
+
const result: ARCHostRule = {
|
|
21
|
+
_id: this.types.uuid(),
|
|
22
|
+
from: this.internet.uri(),
|
|
23
|
+
to: this.internet.uri(),
|
|
24
|
+
enabled: this.types.boolean(),
|
|
25
|
+
comment: this.lorem.paragraph(),
|
|
26
|
+
};
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Generates a list of host rules.
|
|
32
|
+
*
|
|
33
|
+
* @param size Number of items to generate. Default to 25.
|
|
34
|
+
* @return List of datastore entries.
|
|
35
|
+
*/
|
|
36
|
+
rules(size = 25): ARCHostRule[] {
|
|
37
|
+
const result = [];
|
|
38
|
+
for (let i = 0; i < size; i++) {
|
|
39
|
+
result.push(this.rule());
|
|
40
|
+
}
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { Http as Base, Types, Lorem, Time, HttpRequestInit } from '@pawel-up/data-mock';
|
|
2
|
+
import { randomValue } from '@pawel-up/data-mock/src/lib/Http.js';
|
|
3
|
+
import { ArcDataMockInit } from '../LegacyInterfaces.js';
|
|
4
|
+
import { HttpResponse } from './HttpResponse.js';
|
|
5
|
+
import { ARCHistoryRequest, ARCSavedRequest, TransportRequest } from '../../models/legacy/request/ArcRequest.js';
|
|
6
|
+
import { ARCProject } from '../../models/legacy/models/ArcLegacyProject.js';
|
|
7
|
+
|
|
8
|
+
export interface RequestHistoryInit extends HttpRequestInit {
|
|
9
|
+
noId?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface RequestSavedInit extends HttpRequestInit {
|
|
13
|
+
forceDescription?: boolean;
|
|
14
|
+
noDescription?: boolean;
|
|
15
|
+
project?: string;
|
|
16
|
+
projects?: ARCProject[];
|
|
17
|
+
forceProject?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface ProjectCreateInit {
|
|
21
|
+
/**
|
|
22
|
+
* Request id to add to `requests` array
|
|
23
|
+
*/
|
|
24
|
+
requestId?: string;
|
|
25
|
+
/**
|
|
26
|
+
* If set it generates request ID to add to `requests` array
|
|
27
|
+
*/
|
|
28
|
+
autoRequestId?: boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export declare interface GenerateSavedResult {
|
|
32
|
+
projects: ARCProject[];
|
|
33
|
+
requests: ARCSavedRequest[];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface TransportRequestInit extends HttpRequestInit {
|
|
37
|
+
noHttpMessage?: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export class Http extends Base {
|
|
41
|
+
LAST_TIME: number;
|
|
42
|
+
types: Types;
|
|
43
|
+
lorem: Lorem;
|
|
44
|
+
response: HttpResponse;
|
|
45
|
+
time: Time;
|
|
46
|
+
|
|
47
|
+
constructor(init: ArcDataMockInit={}) {
|
|
48
|
+
super(init);
|
|
49
|
+
this.LAST_TIME = Date.now();
|
|
50
|
+
this.types = new Types(init.seed);
|
|
51
|
+
this.lorem = new Lorem(init);
|
|
52
|
+
this.response = new HttpResponse(init);
|
|
53
|
+
this.time = new Time(init);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
history(opts: RequestHistoryInit={}): ARCHistoryRequest {
|
|
57
|
+
const base = this.request(opts);
|
|
58
|
+
this.LAST_TIME -= this.types.datetime().getTime();
|
|
59
|
+
const midnight = this.time.midnight(this.LAST_TIME);
|
|
60
|
+
|
|
61
|
+
const item: ARCHistoryRequest = {
|
|
62
|
+
...base,
|
|
63
|
+
created: this.LAST_TIME,
|
|
64
|
+
updated: this.LAST_TIME,
|
|
65
|
+
type: 'history',
|
|
66
|
+
midnight,
|
|
67
|
+
};
|
|
68
|
+
if (!opts.noId) {
|
|
69
|
+
item._id = this.types.uuid();
|
|
70
|
+
}
|
|
71
|
+
return item;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
saved(opts: RequestSavedInit={}): ARCSavedRequest {
|
|
75
|
+
const base = this.request(opts);
|
|
76
|
+
const time = this.types.datetime().getTime();
|
|
77
|
+
const requestName = this.lorem.words(2);
|
|
78
|
+
const description = this.description(opts);
|
|
79
|
+
const midnight = this.time.midnight(this.LAST_TIME);
|
|
80
|
+
const item: ARCSavedRequest = {
|
|
81
|
+
...base,
|
|
82
|
+
created: time,
|
|
83
|
+
updated: time,
|
|
84
|
+
type: 'saved',
|
|
85
|
+
name: requestName,
|
|
86
|
+
midnight,
|
|
87
|
+
};
|
|
88
|
+
if (description) {
|
|
89
|
+
item.description = description;
|
|
90
|
+
}
|
|
91
|
+
item._id = this.types.uuid();
|
|
92
|
+
if (opts.project) {
|
|
93
|
+
item.projects = [opts.project];
|
|
94
|
+
}
|
|
95
|
+
return item;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Generates a description for a request.
|
|
100
|
+
*
|
|
101
|
+
* @param opts Configuration options
|
|
102
|
+
* @returns Items description.
|
|
103
|
+
*/
|
|
104
|
+
description(opts: RequestSavedInit={}): string|undefined {
|
|
105
|
+
const { noDescription, forceDescription } = opts;
|
|
106
|
+
if (noDescription) {
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
if (forceDescription) {
|
|
110
|
+
return this.lorem.paragraph();
|
|
111
|
+
}
|
|
112
|
+
return this.types.boolean({ likelihood: 70 }) ? this.lorem.paragraph() : undefined;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* @param size The number of requests to generate.
|
|
117
|
+
* @param init History init options.
|
|
118
|
+
*/
|
|
119
|
+
listHistory(size = 25, init: RequestHistoryInit={}): ARCHistoryRequest[] {
|
|
120
|
+
const result = [];
|
|
121
|
+
for (let i = 0; i < size; i++) {
|
|
122
|
+
result.push(this.history(init));
|
|
123
|
+
}
|
|
124
|
+
return result;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* @param size The number of requests to generate.
|
|
129
|
+
* @param init Saved init options
|
|
130
|
+
*/
|
|
131
|
+
listSaved(size = 25, init: RequestSavedInit = {}): ARCSavedRequest[] {
|
|
132
|
+
const list = [];
|
|
133
|
+
for (let i = 0; i < size; i++) {
|
|
134
|
+
const project = this.pickProject(init);
|
|
135
|
+
const opts = { ...init };
|
|
136
|
+
if (project && project._id) {
|
|
137
|
+
opts.project = project._id;
|
|
138
|
+
}
|
|
139
|
+
const item = this.saved(opts);
|
|
140
|
+
if (project) {
|
|
141
|
+
if (!project.requests) {
|
|
142
|
+
project.requests = [];
|
|
143
|
+
}
|
|
144
|
+
project.requests.push(item._id as string);
|
|
145
|
+
}
|
|
146
|
+
list.push(item);
|
|
147
|
+
}
|
|
148
|
+
return list;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Picks a random project from the list of passed in `opts` projects.
|
|
153
|
+
*
|
|
154
|
+
* @param opts
|
|
155
|
+
* @returns A project or undefined.
|
|
156
|
+
*/
|
|
157
|
+
pickProject(opts: RequestSavedInit = {}): ARCProject|undefined {
|
|
158
|
+
if (!opts.projects || !opts.projects.length) {
|
|
159
|
+
return undefined;
|
|
160
|
+
}
|
|
161
|
+
let allow;
|
|
162
|
+
if (opts.forceProject) {
|
|
163
|
+
allow = true;
|
|
164
|
+
} else {
|
|
165
|
+
allow = this.types.boolean();
|
|
166
|
+
}
|
|
167
|
+
if (allow) {
|
|
168
|
+
return this[randomValue].pickOne(opts.projects);
|
|
169
|
+
}
|
|
170
|
+
return undefined;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
project(init: ProjectCreateInit={}): ARCProject {
|
|
174
|
+
const project: ARCProject = {
|
|
175
|
+
_id: this.types.uuid(),
|
|
176
|
+
name: this.lorem.sentence({ words: 2 }),
|
|
177
|
+
order: 0,
|
|
178
|
+
description: this.lorem.paragraph(),
|
|
179
|
+
requests: [],
|
|
180
|
+
};
|
|
181
|
+
if (init.requestId) {
|
|
182
|
+
project.requests!.push(init.requestId);
|
|
183
|
+
} else if (init.autoRequestId) {
|
|
184
|
+
project.requests!.push(this.types.uuid());
|
|
185
|
+
}
|
|
186
|
+
return project;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
listProjects(size = 5, init: ProjectCreateInit = {}): ARCProject[] {
|
|
190
|
+
const result = [];
|
|
191
|
+
for (let i = 0; i < size; i++) {
|
|
192
|
+
result.push(this.project(init));
|
|
193
|
+
}
|
|
194
|
+
return result;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* @returns A map with `projects` and `requests` arrays.
|
|
199
|
+
*/
|
|
200
|
+
savedData(requestsSize = 25, projectsSize = 5, requestsInit: RequestSavedInit = {}, projectInit: ProjectCreateInit = {}): GenerateSavedResult {
|
|
201
|
+
const projects = this.listProjects(projectsSize, projectInit);
|
|
202
|
+
const rCopy = { ...requestsInit };
|
|
203
|
+
rCopy.projects = projects;
|
|
204
|
+
const requests = this.listSaved(requestsSize, rCopy);
|
|
205
|
+
return {
|
|
206
|
+
requests,
|
|
207
|
+
projects,
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Generates a transport request object.
|
|
213
|
+
* @param opts Generate options
|
|
214
|
+
* @returns The transport request object
|
|
215
|
+
*/
|
|
216
|
+
transportRequest(opts: TransportRequestInit={}): TransportRequest {
|
|
217
|
+
const base = this.request(opts);
|
|
218
|
+
const request: TransportRequest = {
|
|
219
|
+
...base,
|
|
220
|
+
startTime: Date.now() - 1000,
|
|
221
|
+
endTime: Date.now(),
|
|
222
|
+
httpMessage: '',
|
|
223
|
+
};
|
|
224
|
+
if (!opts.noHttpMessage) {
|
|
225
|
+
request.httpMessage = `GET / HTTP 1.1\n${request.headers}\n`;
|
|
226
|
+
if (request.payload) {
|
|
227
|
+
request.httpMessage += `\n${request.payload}\n`;
|
|
228
|
+
}
|
|
229
|
+
request.httpMessage += '\n';
|
|
230
|
+
} else {
|
|
231
|
+
// @ts-ignore
|
|
232
|
+
delete request.httpMessage;
|
|
233
|
+
}
|
|
234
|
+
return request;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { HttpResponse as Base, headersValue, payloadValue, typesValue, loremValue } from '@pawel-up/data-mock/src/lib/http/HttpResponse.js';
|
|
2
|
+
import { Har, DataMockLocale } from '@pawel-up/data-mock';
|
|
3
|
+
import { ArcDataMockInit, HttpResponseArcInit, HttpResponseRedirectInit } from '../LegacyInterfaces.js';
|
|
4
|
+
import { ResponseRedirect, Response, ErrorResponse } from '../../models/legacy/request/ArcResponse.js';
|
|
5
|
+
|
|
6
|
+
export class HttpResponse extends Base {
|
|
7
|
+
har: Har;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @param init The library init options.
|
|
11
|
+
*/
|
|
12
|
+
constructor(init: ArcDataMockInit={}) {
|
|
13
|
+
super(init);
|
|
14
|
+
this.har = new Har(init);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
seed(value?: number): void {
|
|
18
|
+
super.seed(value);
|
|
19
|
+
this.har.seed(value);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @param locale The locale to set. When nothing is passed then it uses the default locale.
|
|
24
|
+
*/
|
|
25
|
+
locale(locale?: DataMockLocale): void {
|
|
26
|
+
super.locale(locale);
|
|
27
|
+
this.har.locale(locale);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @returns Generated redirect response.
|
|
32
|
+
*/
|
|
33
|
+
redirectResponse(init: HttpResponseRedirectInit={}): ResponseRedirect {
|
|
34
|
+
const ct = init.body ? this[headersValue].contentType() : undefined;
|
|
35
|
+
let headers = this[headersValue].headers('response', { mime: ct });
|
|
36
|
+
const url = this[headersValue].link();
|
|
37
|
+
headers += `\nlocation: ${url}`;
|
|
38
|
+
const { code, status } = this.redirectStatus(init);
|
|
39
|
+
const body = init.body ? this[payloadValue].payload(ct) : undefined;
|
|
40
|
+
const startTime = this[typesValue].datetime().getTime();
|
|
41
|
+
const duration = this[typesValue].number({ min: 10, max: 4000 });
|
|
42
|
+
const result: ResponseRedirect = {
|
|
43
|
+
url: '',
|
|
44
|
+
response: {
|
|
45
|
+
status: code,
|
|
46
|
+
statusText: status,
|
|
47
|
+
headers,
|
|
48
|
+
},
|
|
49
|
+
startTime,
|
|
50
|
+
endTime: startTime + duration,
|
|
51
|
+
};
|
|
52
|
+
if (body) {
|
|
53
|
+
result.response.payload = body;
|
|
54
|
+
}
|
|
55
|
+
if (init.timings) {
|
|
56
|
+
result.timings = this.har.timing(init);
|
|
57
|
+
}
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
arcResponse(init: HttpResponseArcInit = {}): Response {
|
|
62
|
+
const ct = init.noBody ? undefined : this[headersValue].contentType();
|
|
63
|
+
const body = init.noBody ? undefined : this[payloadValue].payload(ct);
|
|
64
|
+
const headers = this[headersValue].headers('response', { mime: ct });
|
|
65
|
+
const statusGroup = init.statusGroup ? init.statusGroup : this[typesValue].number({ min: 2, max: 5 });
|
|
66
|
+
const sCode = this[typesValue].number({ min: 0, max: 99 }).toString();
|
|
67
|
+
const code = Number(`${statusGroup}${sCode.padStart(2, '0')}`);
|
|
68
|
+
const status = this[loremValue].word();
|
|
69
|
+
const length = this[typesValue].number({ min: 10, max: 4000 });
|
|
70
|
+
const result: Response = {
|
|
71
|
+
status: code,
|
|
72
|
+
statusText: status,
|
|
73
|
+
headers,
|
|
74
|
+
loadingTime: length,
|
|
75
|
+
};
|
|
76
|
+
if (init.timings) {
|
|
77
|
+
result.timings = this.har.timing(init);
|
|
78
|
+
}
|
|
79
|
+
if (!init.noBody) {
|
|
80
|
+
result.payload = body;
|
|
81
|
+
}
|
|
82
|
+
if (!init.noSize) {
|
|
83
|
+
const hSize = headers.length;
|
|
84
|
+
const bSize = body ? body.length : 0;
|
|
85
|
+
result.size = {
|
|
86
|
+
request: this[typesValue].number({ min: 10 }),
|
|
87
|
+
response: hSize + bSize,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
if (init.redirects) {
|
|
91
|
+
const size = this[typesValue].number({ min: 1, max: 4 });
|
|
92
|
+
const cnf = { timings: init.timings, body: true };
|
|
93
|
+
result.redirects = new Array(size).fill(0).map(() => this.redirectResponse(cnf));
|
|
94
|
+
}
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
arcErrorResponse(): ErrorResponse {
|
|
99
|
+
const error = new Error(this[loremValue].paragraph());
|
|
100
|
+
const result: ErrorResponse = {
|
|
101
|
+
status: 0,
|
|
102
|
+
error,
|
|
103
|
+
};
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Lorem, Types, Internet } from '@pawel-up/data-mock';
|
|
2
|
+
import { ArcDataMockInit, RestApiIndexInit } from '../LegacyInterfaces.js';
|
|
3
|
+
import { ARCRestApi, ARCRestApiIndex } from '../../models/legacy/models/RestApi.js';
|
|
4
|
+
|
|
5
|
+
export class RestApi {
|
|
6
|
+
types: Types;
|
|
7
|
+
lorem: Lorem;
|
|
8
|
+
internet: Internet;
|
|
9
|
+
|
|
10
|
+
constructor(init: ArcDataMockInit={}) {
|
|
11
|
+
this.types = new Types(init.seed);
|
|
12
|
+
this.lorem = new Lorem(init);
|
|
13
|
+
this.internet = new Internet(init);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
apiIndex(opts: RestApiIndexInit = {}): ARCRestApiIndex {
|
|
17
|
+
const result: ARCRestApiIndex = {
|
|
18
|
+
order: opts.order || 0,
|
|
19
|
+
title: this.lorem.sentence({ words: 2 }),
|
|
20
|
+
type: 'RAML 1.0',
|
|
21
|
+
_id: this.internet.uri(),
|
|
22
|
+
versions: [],
|
|
23
|
+
latest: '',
|
|
24
|
+
};
|
|
25
|
+
const versionsSize = opts.versionSize ? opts.versionSize : this.types.number({ min: 1, max: 5 });
|
|
26
|
+
const versions = [];
|
|
27
|
+
let last = '';
|
|
28
|
+
for (let i = 0; i < versionsSize; i++) {
|
|
29
|
+
last = `v${i}`;
|
|
30
|
+
versions[versions.length] = last;
|
|
31
|
+
}
|
|
32
|
+
result.versions = versions;
|
|
33
|
+
result.latest = last;
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
apiIndexList(size=25, opts: RestApiIndexInit = {}): ARCRestApiIndex[] {
|
|
38
|
+
const result = [];
|
|
39
|
+
for (let i = 0; i < size; i++) {
|
|
40
|
+
result.push(this.apiIndex({ ...opts, order: i }));
|
|
41
|
+
}
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
apiData(index: ARCRestApiIndex): ARCRestApi[] {
|
|
46
|
+
const result: ARCRestApi[] = [];
|
|
47
|
+
index.versions.forEach((version) => {
|
|
48
|
+
const item: ARCRestApi = {
|
|
49
|
+
data: '[{}]',
|
|
50
|
+
indexId: index._id || '',
|
|
51
|
+
version,
|
|
52
|
+
_id: `${index._id}|${version}`,
|
|
53
|
+
};
|
|
54
|
+
result[result.length] = item;
|
|
55
|
+
});
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
apiDataList(indexes: ARCRestApiIndex[]): ARCRestApi[] {
|
|
60
|
+
const size = indexes.length;
|
|
61
|
+
let result: ARCRestApi[] = [];
|
|
62
|
+
for (let i = 0; i < size; i++) {
|
|
63
|
+
const data = this.apiData(indexes[i]);
|
|
64
|
+
result = result.concat(data);
|
|
65
|
+
}
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Internet, Types, Time } from '@pawel-up/data-mock';
|
|
2
|
+
import { ArcDataMockInit } from '../LegacyInterfaces.js';
|
|
3
|
+
import { ARCUrlHistory } from '../../models/legacy/models/UrlHistory.js';
|
|
4
|
+
|
|
5
|
+
export class Urls {
|
|
6
|
+
types: Types;
|
|
7
|
+
internet: Internet;
|
|
8
|
+
time: Time;
|
|
9
|
+
|
|
10
|
+
constructor(init: ArcDataMockInit={}) {
|
|
11
|
+
this.types = new Types(init.seed);
|
|
12
|
+
this.internet = new Internet(init);
|
|
13
|
+
this.time = new Time(init);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Generates a single ARC URL model item.
|
|
18
|
+
*/
|
|
19
|
+
url(): ARCUrlHistory {
|
|
20
|
+
const url = this.internet.uri();
|
|
21
|
+
const time = this.types.datetime().getTime();
|
|
22
|
+
const result: ARCUrlHistory = {
|
|
23
|
+
time,
|
|
24
|
+
cnt: this.types.number({ min: 100, max: 1000 }),
|
|
25
|
+
_id: url,
|
|
26
|
+
url,
|
|
27
|
+
midnight: this.time.midnight(time),
|
|
28
|
+
};
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Generates list of ARC URL models.
|
|
34
|
+
*
|
|
35
|
+
* @returns List of datastore entries.
|
|
36
|
+
*/
|
|
37
|
+
urls(size = 25): ARCUrlHistory[] {
|
|
38
|
+
const result = [];
|
|
39
|
+
for (let i = 0; i < size; i++) {
|
|
40
|
+
result.push(this.url());
|
|
41
|
+
}
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Lorem, Types } from '@pawel-up/data-mock';
|
|
2
|
+
import { ArcDataMockInit, VariableInit } from '../LegacyInterfaces.js';
|
|
3
|
+
import { ARCVariable } from '../../models/legacy/models/Variable.js';
|
|
4
|
+
|
|
5
|
+
export class Variables {
|
|
6
|
+
types: Types;
|
|
7
|
+
lorem: Lorem;
|
|
8
|
+
|
|
9
|
+
constructor(init: ArcDataMockInit={}) {
|
|
10
|
+
this.types = new Types(init.seed);
|
|
11
|
+
this.lorem = new Lorem(init);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Generates a random variable
|
|
16
|
+
*/
|
|
17
|
+
variable(init: VariableInit={}): ARCVariable {
|
|
18
|
+
let isDefault;
|
|
19
|
+
if (init.defaultEnv) {
|
|
20
|
+
isDefault = true;
|
|
21
|
+
} else if (init.randomEnv) {
|
|
22
|
+
isDefault = false;
|
|
23
|
+
} else {
|
|
24
|
+
isDefault = this.types.boolean();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const result = /** @type ARCVariable */ ({
|
|
28
|
+
enabled: this.types.boolean({ likelihood: 85 }),
|
|
29
|
+
value: this.lorem.sentence({ words: 2 }),
|
|
30
|
+
name: this.lorem.word(),
|
|
31
|
+
_id: this.types.uuid(),
|
|
32
|
+
environment: '',
|
|
33
|
+
});
|
|
34
|
+
if (isDefault) {
|
|
35
|
+
result.environment = 'default';
|
|
36
|
+
} else {
|
|
37
|
+
result.environment = this.lorem.sentence({ words: 2 });
|
|
38
|
+
}
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Generates a number of variables.
|
|
44
|
+
* @param size The number of variables to generate.
|
|
45
|
+
*/
|
|
46
|
+
listVariables(size = 25, init: VariableInit={}): ARCVariable[] {
|
|
47
|
+
const result = [];
|
|
48
|
+
for (let i = 0; i < size; i++) {
|
|
49
|
+
result.push(this.variable(init));
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Http, Types, Lorem, Time, DataMockInit, HttpRequestInit } from '@pawel-up/data-mock';
|
|
2
|
+
// import { randomValue } from '@pawel-up/data-mock/src/lib/Http.js';
|
|
3
|
+
import { IHttpRequest, Kind as HttpRequestKind } from '../../models/HttpRequest.js';
|
|
4
|
+
import { IRequest, Kind as RequestKind } from '../../models/Request.js';
|
|
5
|
+
import { ISentRequest } from '../../models/SentRequest.js';
|
|
6
|
+
import { IRequestLog } from '../../models/RequestLog.js';
|
|
7
|
+
import { IArcResponseInit, Response } from './Response.js';
|
|
8
|
+
|
|
9
|
+
export interface IRequestLogInit {
|
|
10
|
+
request?: HttpRequestInit;
|
|
11
|
+
response?: IArcResponseInit;
|
|
12
|
+
/**
|
|
13
|
+
* When set it ignores size information
|
|
14
|
+
*/
|
|
15
|
+
noSize?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Adds redirects to the request
|
|
18
|
+
*/
|
|
19
|
+
redirects?: boolean;
|
|
20
|
+
noResponse?: boolean;
|
|
21
|
+
noRequest?: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export class Request {
|
|
25
|
+
types: Types;
|
|
26
|
+
lorem: Lorem;
|
|
27
|
+
time: Time;
|
|
28
|
+
http: Http;
|
|
29
|
+
response: Response;
|
|
30
|
+
|
|
31
|
+
constructor(init: DataMockInit={}) {
|
|
32
|
+
this.types = new Types(init.seed);
|
|
33
|
+
this.lorem = new Lorem(init);
|
|
34
|
+
this.time = new Time(init);
|
|
35
|
+
this.http = new Http(init);
|
|
36
|
+
this.response = new Response(init);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
request(init?: HttpRequestInit): IRequest {
|
|
40
|
+
return {
|
|
41
|
+
kind: RequestKind,
|
|
42
|
+
expects: this.httpRequest(init),
|
|
43
|
+
info: {
|
|
44
|
+
name: this.lorem.words(2),
|
|
45
|
+
description: this.lorem.paragraph(),
|
|
46
|
+
},
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
httpRequest(init?: HttpRequestInit): IHttpRequest {
|
|
51
|
+
const request = this.http.request(init);
|
|
52
|
+
return {
|
|
53
|
+
kind: HttpRequestKind,
|
|
54
|
+
...request,
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
sentRequest(init?: HttpRequestInit): ISentRequest {
|
|
59
|
+
const start = this.time.timestamp();
|
|
60
|
+
return {
|
|
61
|
+
startTime: start,
|
|
62
|
+
endTime: this.time.timestamp({ min: start + 1 }),
|
|
63
|
+
...this.httpRequest(init),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
log(init: IRequestLogInit = {}): IRequestLog {
|
|
68
|
+
const result: IRequestLog = {
|
|
69
|
+
kind: 'ARC#ResponseLog',
|
|
70
|
+
};
|
|
71
|
+
if (!init.noRequest) {
|
|
72
|
+
result.request = this.sentRequest(init.request);
|
|
73
|
+
}
|
|
74
|
+
if (!init.noResponse) {
|
|
75
|
+
result.response = this.response.arcResponse(init.response);
|
|
76
|
+
}
|
|
77
|
+
if (init.redirects) {
|
|
78
|
+
result.redirects = this.response.redirects();
|
|
79
|
+
}
|
|
80
|
+
if (!init.noSize) {
|
|
81
|
+
result.size = this.response.size();
|
|
82
|
+
}
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
}
|