@api-client/core 0.5.28 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/src/mocking/LegacyInterfaces.d.ts +4 -4
- package/build/src/mocking/LegacyMock.js +1 -0
- package/build/src/mocking/LegacyMock.js.map +1 -1
- package/build/src/mocking/ProjectMock.d.ts +2 -2
- package/build/src/mocking/ProjectMock.js.map +1 -1
- package/build/src/mocking/legacy/Http.d.ts +5 -4
- package/build/src/mocking/legacy/Http.js +8 -6
- package/build/src/mocking/legacy/Http.js.map +1 -1
- package/build/src/mocking/legacy/HttpResponse.d.ts +1 -1
- package/build/src/mocking/legacy/HttpResponse.js +1 -1
- package/build/src/mocking/legacy/HttpResponse.js.map +1 -1
- package/build/src/mocking/lib/History.d.ts +5 -5
- package/build/src/mocking/lib/History.js +4 -4
- package/build/src/mocking/lib/History.js.map +1 -1
- package/build/src/mocking/lib/Request.d.ts +14 -7
- package/build/src/mocking/lib/Request.js +4 -4
- package/build/src/mocking/lib/Request.js.map +1 -1
- package/build/src/mocking/lib/Response.d.ts +9 -11
- package/build/src/mocking/lib/Response.js +28 -14
- package/build/src/mocking/lib/Response.js.map +1 -1
- package/build/src/mocking/lib/Url.d.ts +2 -2
- package/build/src/mocking/lib/Url.js.map +1 -1
- package/build/src/mocking/lib/User.d.ts +2 -2
- package/build/src/mocking/lib/User.js +0 -1
- package/build/src/mocking/lib/User.js.map +1 -1
- package/package.json +5 -5
- package/src/mocking/LegacyInterfaces.ts +4 -4
- package/src/mocking/LegacyMock.ts +1 -0
- package/src/mocking/ProjectMock.ts +2 -2
- package/src/mocking/legacy/Http.ts +12 -9
- package/src/mocking/legacy/HttpResponse.ts +3 -3
- package/src/mocking/lib/History.ts +7 -7
- package/src/mocking/lib/Request.ts +18 -10
- package/src/mocking/lib/Response.ts +34 -22
- package/src/mocking/lib/Url.ts +2 -2
- package/src/mocking/lib/User.ts +2 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface ArcDataMockInit extends
|
|
1
|
+
import { IDataMockInit, IHarTimingInit, IHttpResponseRedirectStatusInit } from '@pawel-up/data-mock';
|
|
2
|
+
export interface ArcDataMockInit extends IDataMockInit {
|
|
3
3
|
}
|
|
4
4
|
export interface VariableInit {
|
|
5
5
|
defaultEnv?: boolean;
|
|
@@ -9,7 +9,7 @@ export declare interface RestApiIndexInit {
|
|
|
9
9
|
versionSize?: number;
|
|
10
10
|
order?: number;
|
|
11
11
|
}
|
|
12
|
-
export declare interface HttpResponseArcInit extends
|
|
12
|
+
export declare interface HttpResponseArcInit extends IHarTimingInit {
|
|
13
13
|
/**
|
|
14
14
|
* When set it does not generate a response payload.
|
|
15
15
|
*/
|
|
@@ -31,7 +31,7 @@ export declare interface HttpResponseArcInit extends HarTimingInit {
|
|
|
31
31
|
*/
|
|
32
32
|
redirects?: boolean;
|
|
33
33
|
}
|
|
34
|
-
export declare interface HttpResponseRedirectInit extends
|
|
34
|
+
export declare interface HttpResponseRedirectInit extends IHttpResponseRedirectStatusInit, IHarTimingInit {
|
|
35
35
|
/**
|
|
36
36
|
* When set it adds body to the response
|
|
37
37
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LegacyMock.js","sourceRoot":"","sources":["../../../src/mocking/LegacyMock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,IAA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;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGlD,MAAM,OAAO,UAAW,SAAQ,QAAQ;IACtC,aAAa;IACb,IAAI,CAAO;IACX,SAAS,CAAY;IACrB,OAAO,CAAU;IACjB,SAAS,CAAY;IACrB,YAAY,CAAe;IAC3B,IAAI,CAAO;IACX,aAAa,CAAgB;IAC7B,OAAO,CAAU;IAEjB;;OAEG;IACH,YAAY,IAAsB;QAChC,KAAK,CAAC,IAAI,CAAC,CAAC;QAEZ,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,YAAY,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;QAC3C,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3B,IAAI,CAAC,aAAa,GAAG,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataMock,
|
|
1
|
+
import { DataMock, IDataMockInit } from '@pawel-up/data-mock';
|
|
2
2
|
import { Request } from './lib/Request.js';
|
|
3
3
|
import { Response } from './lib/Response.js';
|
|
4
4
|
import { User } from './lib/User.js';
|
|
@@ -17,5 +17,5 @@ export declare class ProjectMock extends DataMock {
|
|
|
17
17
|
/**
|
|
18
18
|
* @param init The library init options.
|
|
19
19
|
*/
|
|
20
|
-
constructor(init?:
|
|
20
|
+
constructor(init?: IDataMockInit);
|
|
21
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProjectMock.js","sourceRoot":"","sources":["../../../src/mocking/ProjectMock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"ProjectMock.js","sourceRoot":"","sources":["../../../src/mocking/ProjectMock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAiB,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAOnC,MAAM,OAAO,WAAY,SAAQ,QAAQ;IACvC,cAAc,CAAU;IACxB,QAAQ,CAAW;IACnB,IAAI,CAAO;IACX,OAAO,CAAU;IACjB,GAAG,CAAM;IAET;;OAEG;IACH,YAAY,IAAoB;QAC9B,KAAK,CAAC,IAAI,CAAC,CAAC;QACZ,IAAI,CAAC,cAAc,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;QACxC,IAAI,CAAC,QAAQ,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;CACF"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Http as Base, Types, Lorem, Time,
|
|
1
|
+
import { Http as Base, Types, Lorem, Time, IHttpRequestInit, Random } from '@pawel-up/data-mock';
|
|
2
2
|
import { ArcDataMockInit } from '../LegacyInterfaces.js';
|
|
3
3
|
import { HttpResponse } from './HttpResponse.js';
|
|
4
4
|
import { ARCHistoryRequest, ARCSavedRequest, TransportRequest } from '../../models/legacy/request/ArcRequest.js';
|
|
5
5
|
import { ARCProject } from '../../models/legacy/models/ArcLegacyProject.js';
|
|
6
|
-
export interface RequestHistoryInit extends
|
|
6
|
+
export interface RequestHistoryInit extends IHttpRequestInit {
|
|
7
7
|
noId?: boolean;
|
|
8
8
|
}
|
|
9
|
-
export interface RequestSavedInit extends
|
|
9
|
+
export interface RequestSavedInit extends IHttpRequestInit {
|
|
10
10
|
forceDescription?: boolean;
|
|
11
11
|
noDescription?: boolean;
|
|
12
12
|
project?: string;
|
|
@@ -27,7 +27,7 @@ export declare interface GenerateSavedResult {
|
|
|
27
27
|
projects: ARCProject[];
|
|
28
28
|
requests: ARCSavedRequest[];
|
|
29
29
|
}
|
|
30
|
-
export interface TransportRequestInit extends
|
|
30
|
+
export interface TransportRequestInit extends IHttpRequestInit {
|
|
31
31
|
noHttpMessage?: boolean;
|
|
32
32
|
}
|
|
33
33
|
export declare class Http extends Base {
|
|
@@ -36,6 +36,7 @@ export declare class Http extends Base {
|
|
|
36
36
|
lorem: Lorem;
|
|
37
37
|
response: HttpResponse;
|
|
38
38
|
time: Time;
|
|
39
|
+
protected _random: Random;
|
|
39
40
|
constructor(init?: ArcDataMockInit);
|
|
40
41
|
history(opts?: RequestHistoryInit): ARCHistoryRequest;
|
|
41
42
|
saved(opts?: RequestSavedInit): ARCSavedRequest;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { Http as Base, Types, Lorem, Time } from '@pawel-up/data-mock';
|
|
2
|
-
import { randomValue } from '@pawel-up/data-mock/build/src/lib/Http.js';
|
|
1
|
+
import { Http as Base, Types, Lorem, Time, Random } from '@pawel-up/data-mock';
|
|
3
2
|
import { HttpResponse } from './HttpResponse.js';
|
|
4
3
|
export class Http extends Base {
|
|
5
4
|
LAST_TIME;
|
|
6
5
|
types;
|
|
7
6
|
lorem;
|
|
7
|
+
// @ts-ignore
|
|
8
8
|
response;
|
|
9
9
|
time;
|
|
10
|
+
_random;
|
|
10
11
|
constructor(init = {}) {
|
|
11
12
|
super(init);
|
|
12
13
|
this.LAST_TIME = Date.now();
|
|
@@ -14,9 +15,10 @@ export class Http extends Base {
|
|
|
14
15
|
this.lorem = new Lorem(init);
|
|
15
16
|
this.response = new HttpResponse(init);
|
|
16
17
|
this.time = new Time(init);
|
|
18
|
+
this._random = new Random(init.seed);
|
|
17
19
|
}
|
|
18
20
|
history(opts = {}) {
|
|
19
|
-
const base = this.request(opts);
|
|
21
|
+
const base = this.request.request(opts);
|
|
20
22
|
this.LAST_TIME -= this.types.datetime().getTime();
|
|
21
23
|
const midnight = this.time.midnight(this.LAST_TIME);
|
|
22
24
|
const item = {
|
|
@@ -32,7 +34,7 @@ export class Http extends Base {
|
|
|
32
34
|
return item;
|
|
33
35
|
}
|
|
34
36
|
saved(opts = {}) {
|
|
35
|
-
const base = this.request(opts);
|
|
37
|
+
const base = this.request.request(opts);
|
|
36
38
|
const time = this.types.datetime().getTime();
|
|
37
39
|
const requestName = this.lorem.words(2);
|
|
38
40
|
const description = this.description(opts);
|
|
@@ -122,7 +124,7 @@ export class Http extends Base {
|
|
|
122
124
|
allow = this.types.boolean();
|
|
123
125
|
}
|
|
124
126
|
if (allow) {
|
|
125
|
-
return this
|
|
127
|
+
return this._random.pickOne(opts.projects);
|
|
126
128
|
}
|
|
127
129
|
return undefined;
|
|
128
130
|
}
|
|
@@ -168,7 +170,7 @@ export class Http extends Base {
|
|
|
168
170
|
* @returns The transport request object
|
|
169
171
|
*/
|
|
170
172
|
transportRequest(opts = {}) {
|
|
171
|
-
const base = this.request(opts);
|
|
173
|
+
const base = this.request.request(opts);
|
|
172
174
|
const request = {
|
|
173
175
|
...base,
|
|
174
176
|
startTime: Date.now() - 1000,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Http.js","sourceRoot":"","sources":["../../../../src/mocking/legacy/Http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"Http.js","sourceRoot":"","sources":["../../../../src/mocking/legacy/Http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAoB,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAEjG,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAoCjD,MAAM,OAAO,IAAK,SAAQ,IAAI;IAC5B,SAAS,CAAS;IAClB,KAAK,CAAQ;IACb,KAAK,CAAQ;IACb,aAAa;IACb,QAAQ,CAAe;IACvB,IAAI,CAAO;IAED,OAAO,CAAS;IAE1B,YAAY,OAAsB,EAAE;QAClC,KAAK,CAAC,IAAI,CAAC,CAAC;QACZ,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC5B,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClC,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC;QAC7B,IAAI,CAAC,QAAQ,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;QACvC,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IAED,OAAO,CAAC,OAAyB,EAAE;QACjC,MAAM,IAAI,GAAG,IAAI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C,GAAG,EAAE,GAAG,IAAI;YAC5B,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE;YACnB,WAAW,EAAE,EAAE;SAChB,CAAC;QACF,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE;YACvB,OAAO,CAAC,WAAW,GAAG,mBAAmB,OAAO,CAAC,OAAO,IAAI,CAAC;YAC7D,IAAI,OAAO,CAAC,OAAO,EAAE;gBACnB,OAAO,CAAC,WAAW,IAAI,KAAK,OAAO,CAAC,OAAO,IAAI,CAAC;aACjD;YACD,OAAO,CAAC,WAAW,IAAI,IAAI,CAAC;SAC7B;aAAM;YACL,aAAa;YACb,OAAO,OAAO,CAAC,WAAW,CAAC;SAC5B;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Base from '@pawel-up/data-mock/build/src/lib/http/Response.js';
|
|
2
2
|
import { Har, DataMockLocale } from '@pawel-up/data-mock';
|
|
3
3
|
import { ArcDataMockInit, HttpResponseArcInit, HttpResponseRedirectInit } from '../LegacyInterfaces.js';
|
|
4
4
|
import { ResponseRedirect, Response, ErrorResponse } from '../../models/legacy/request/ArcResponse.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Base, { headersValue, payloadValue, typesValue, loremValue } from '@pawel-up/data-mock/build/src/lib/http/Response.js';
|
|
2
2
|
import { Har } from '@pawel-up/data-mock';
|
|
3
3
|
export class HttpResponse extends Base {
|
|
4
4
|
har;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpResponse.js","sourceRoot":"","sources":["../../../../src/mocking/legacy/HttpResponse.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"HttpResponse.js","sourceRoot":"","sources":["../../../../src/mocking/legacy/HttpResponse.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,YAAY,EAAE,UAA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KAAK,GAAG,KAAK;aACxB,CAAC;SACH;QACD,IAAI,IAAI,CAAC,SAAS,EAAE;YAClB,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;YACzD,MAAM,GAAG,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;YAClD,MAAM,CAAC,SAAS,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC;SAClF;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,gBAAgB;QACd,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC;QACtD,MAAM,MAAM,GAAkB;YAC5B,MAAM,EAAE,CAAC;YACT,KAAK;SACN,CAAC;QACF,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Internet, Types,
|
|
1
|
+
import { Internet, Types, IDataMockInit, Person, Random, ITypeDateTimeInit } from '@pawel-up/data-mock';
|
|
2
2
|
import { IHttpHistory } from '../../models/HttpHistory.js';
|
|
3
3
|
import { Request, IRequestLogInit } from './Request.js';
|
|
4
4
|
export interface IHttpHistoryInit {
|
|
@@ -29,7 +29,7 @@ export interface IHttpHistoryInit {
|
|
|
29
29
|
/**
|
|
30
30
|
* The created time init options.
|
|
31
31
|
*/
|
|
32
|
-
created?:
|
|
32
|
+
created?: ITypeDateTimeInit;
|
|
33
33
|
}
|
|
34
34
|
export interface IHttpHistoryListInit extends IHttpHistoryInit {
|
|
35
35
|
/**
|
|
@@ -64,7 +64,7 @@ export declare class History {
|
|
|
64
64
|
internet: Internet;
|
|
65
65
|
random: Random;
|
|
66
66
|
request: Request;
|
|
67
|
-
constructor(init?:
|
|
68
|
-
httpHistory(init?: IHttpHistoryInit): IHttpHistory
|
|
69
|
-
httpHistoryList(size?: number, init?: IHttpHistoryListInit): IHttpHistory[]
|
|
67
|
+
constructor(init?: IDataMockInit);
|
|
68
|
+
httpHistory(init?: IHttpHistoryInit): Promise<IHttpHistory>;
|
|
69
|
+
httpHistoryList(size?: number, init?: IHttpHistoryListInit): Promise<IHttpHistory[]>;
|
|
70
70
|
}
|
|
@@ -15,12 +15,12 @@ export class History {
|
|
|
15
15
|
this.random = new Random(init.seed);
|
|
16
16
|
this.request = new Request(init);
|
|
17
17
|
}
|
|
18
|
-
httpHistory(init = {}) {
|
|
18
|
+
async httpHistory(init = {}) {
|
|
19
19
|
const date = this.types.datetime(init.created);
|
|
20
20
|
const result = {
|
|
21
21
|
kind: HttpHistoryKind,
|
|
22
22
|
created: date.getTime(),
|
|
23
|
-
log: this.request.log(init.log),
|
|
23
|
+
log: await this.request.log(init.log),
|
|
24
24
|
user: '',
|
|
25
25
|
};
|
|
26
26
|
date.setHours(0, 0, 0, 0);
|
|
@@ -72,7 +72,7 @@ export class History {
|
|
|
72
72
|
}
|
|
73
73
|
return result;
|
|
74
74
|
}
|
|
75
|
-
httpHistoryList(size = 25, init = {}) {
|
|
75
|
+
async httpHistoryList(size = 25, init = {}) {
|
|
76
76
|
const { usersSize, spacesSize, projectsSize, requestsSize, appsSize } = init;
|
|
77
77
|
const copy = { ...init };
|
|
78
78
|
if (usersSize && typeof init.user === 'undefined') {
|
|
@@ -112,7 +112,7 @@ export class History {
|
|
|
112
112
|
}
|
|
113
113
|
const result = [];
|
|
114
114
|
for (let i = 0; i < size; i++) {
|
|
115
|
-
result.push(this.httpHistory(copy));
|
|
115
|
+
result.push(await this.httpHistory(copy));
|
|
116
116
|
}
|
|
117
117
|
return result;
|
|
118
118
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"History.js","sourceRoot":"","sources":["../../../../src/mocking/lib/History.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"History.js","sourceRoot":"","sources":["../../../../src/mocking/lib/History.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAiB,MAAM,EAAE,MAAM,EAAqB,MAAM,qBAAqB,CAAC;AACxG,qEAAqE;AACrE,OAAO,EAAgB,IAAI,IAAI,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACpF,OAAO,EAAE,OAAO,EAAmB,MAAM,cAAc,CAAC;AA8DxD,MAAM,OAAO,OAAO;IAClB,MAAM,CAAS;IACf,KAAK,CAAQ;IACb,QAAQ,CAAW;IACnB,MAAM,CAAS;IACf,OAAO,CAAU;IAEjB,YAAY,OAAoB,EAAE;QAChC,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClC,IAAI,CAAC,QAAQ,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,OAAyB,EAAE;QAC3C,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC/C,MAAM,MAAM,GAAiB;YAC3B,IAAI,EAAE,eAAe;YACrB,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE;YACvB,GAAG,EAAE,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,C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,CAAC;SACzB;QACD,IAAI,QAAQ,IAAI,OAAO,IAAI,CAAC,GAAG,KAAK,WAAW,EAAE;YAC/C,MAAM,IAAI,GAAa,EAAE,CAAC;YAC1B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,EAAE,CAAC,EAAE,EAAE;gBACjC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;aAC9B;YACD,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC;SACjB;QAED,MAAM,MAAM,GAAmB,EAAE,CAAC;QAClC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,EAAE;YAC7B,MAAM,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;SAC3C;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Http, Types, Lorem, Time,
|
|
1
|
+
import { Http, Types, Lorem, Time, IDataMockInit, IHttpRequestInit } from '@pawel-up/data-mock';
|
|
2
2
|
import { IHttpRequest } from '../../models/HttpRequest.js';
|
|
3
3
|
import { IRequest } from '../../models/Request.js';
|
|
4
4
|
import { ISentRequest } from '../../models/SentRequest.js';
|
|
5
5
|
import { IRequestLog } from '../../models/RequestLog.js';
|
|
6
6
|
import { IResponseInit, Response } from './Response.js';
|
|
7
7
|
export interface IRequestLogInit {
|
|
8
|
-
request?:
|
|
8
|
+
request?: IHttpRequestInit;
|
|
9
9
|
response?: IResponseInit;
|
|
10
10
|
/**
|
|
11
11
|
* When set it ignores size information
|
|
@@ -18,15 +18,22 @@ export interface IRequestLogInit {
|
|
|
18
18
|
noResponse?: boolean;
|
|
19
19
|
noRequest?: boolean;
|
|
20
20
|
}
|
|
21
|
+
export interface IRequestInit extends IResponseInit {
|
|
22
|
+
/**
|
|
23
|
+
* The content type to generate the body for.
|
|
24
|
+
* Has no effect when `noBody` is set.
|
|
25
|
+
*/
|
|
26
|
+
contentType?: string;
|
|
27
|
+
}
|
|
21
28
|
export declare class Request {
|
|
22
29
|
types: Types;
|
|
23
30
|
lorem: Lorem;
|
|
24
31
|
time: Time;
|
|
25
32
|
http: Http;
|
|
26
33
|
response: Response;
|
|
27
|
-
constructor(init?:
|
|
28
|
-
request(init?:
|
|
29
|
-
httpRequest(init?:
|
|
30
|
-
sentRequest(init?:
|
|
31
|
-
log(init?: IRequestLogInit): IRequestLog
|
|
34
|
+
constructor(init?: IDataMockInit);
|
|
35
|
+
request(init?: IHttpRequestInit): IRequest;
|
|
36
|
+
httpRequest(init?: IHttpRequestInit): IHttpRequest;
|
|
37
|
+
sentRequest(init?: IHttpRequestInit): ISentRequest;
|
|
38
|
+
log(init?: IRequestLogInit): Promise<IRequestLog>;
|
|
32
39
|
}
|
|
@@ -28,7 +28,7 @@ export class Request {
|
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
httpRequest(init) {
|
|
31
|
-
const request = this.http.request(init);
|
|
31
|
+
const request = this.http.request.request(init);
|
|
32
32
|
return {
|
|
33
33
|
kind: HttpRequestKind,
|
|
34
34
|
...request,
|
|
@@ -42,7 +42,7 @@ export class Request {
|
|
|
42
42
|
...this.httpRequest(init),
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
|
-
log(init = {}) {
|
|
45
|
+
async log(init = {}) {
|
|
46
46
|
const result = {
|
|
47
47
|
kind: RequestLogKind,
|
|
48
48
|
};
|
|
@@ -50,10 +50,10 @@ export class Request {
|
|
|
50
50
|
result.request = this.sentRequest(init.request);
|
|
51
51
|
}
|
|
52
52
|
if (!init.noResponse) {
|
|
53
|
-
result.response = this.response.response(init.response);
|
|
53
|
+
result.response = await this.response.response(init.response);
|
|
54
54
|
}
|
|
55
55
|
if (init.redirects) {
|
|
56
|
-
result.redirects = this.response.redirects();
|
|
56
|
+
result.redirects = await this.response.redirects(undefined, init.response);
|
|
57
57
|
}
|
|
58
58
|
if (!init.noSize) {
|
|
59
59
|
result.size = this.response.size();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Request.js","sourceRoot":"","sources":["../../../../src/mocking/lib/Request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"Request.js","sourceRoot":"","sources":["../../../../src/mocking/lib/Request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAmC,MAAM,qBAAqB,CAAC;AAChG,qEAAqE;AACrE,OAAO,EAAgB,IAAI,IAAI,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACpF,OAAO,EAAY,IAAI,IAAI,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAExE,OAAO,EAAe,IAAI,IAAI,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjF,OAAO,EAAiB,QAAQ,EAAE,MAAM,eAAe,CAAC;AAyBxD,MAAM,OAAO,OAAO;IAClB,KAAK,CAAQ;IACb,KAAK,CAAQ;IACb,IAAI,CAAO;IACX,IAAI,CAAO;IACX,QAAQ,CAAW;IAEnB,YAAY,OAAoB,EAAE;QAChC,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClC,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IAED,OAAO,CAAC,IAAuB;QAC7B,OAAO;YACL,IAAI,EAAE,WAAW;YACjB,OAAO,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CAAC,CAAC;SAC5E;QACD,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YAChB,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;SACpC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import { Http, Har, Types, Lorem, Time,
|
|
1
|
+
import { Http, Har, Types, Lorem, Time, IDataMockInit, IHttpResponseInit, IHarTimingInit, Internet } from '@pawel-up/data-mock';
|
|
2
2
|
import { IHttpResponse } from '../../models/HttpResponse.js';
|
|
3
3
|
import { IResponse } from '../../models/Response.js';
|
|
4
4
|
import { IRequestsSize } from '../../models/RequestsSize.js';
|
|
5
5
|
import { IResponseRedirect } from '../../models/ResponseRedirect.js';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* When set it does not generate a response payload.
|
|
9
|
-
*/
|
|
10
|
-
noBody?: boolean;
|
|
6
|
+
import { DeserializedPayload } from '../../lib/transformers/PayloadSerializer.js';
|
|
7
|
+
export interface IResponseInit extends IHttpResponseInit, IHarTimingInit {
|
|
11
8
|
/**
|
|
12
9
|
* The first number of the status group. Other 2 are auto generated
|
|
13
10
|
*/
|
|
@@ -24,10 +21,11 @@ export declare class Response {
|
|
|
24
21
|
http: Http;
|
|
25
22
|
har: Har;
|
|
26
23
|
internet: Internet;
|
|
27
|
-
constructor(init?:
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
constructor(init?: IDataMockInit);
|
|
25
|
+
protected _getPayload(mime?: string): DeserializedPayload;
|
|
26
|
+
httpResponse(init?: IResponseInit): Promise<IHttpResponse>;
|
|
27
|
+
response(init?: IResponseInit): Promise<IResponse>;
|
|
30
28
|
size(): IRequestsSize;
|
|
31
|
-
redirect(init?: IResponseInit): IResponseRedirect
|
|
32
|
-
redirects(size?: number, init?: IResponseInit): IResponseRedirect[]
|
|
29
|
+
redirect(init?: IResponseInit): Promise<IResponseRedirect>;
|
|
30
|
+
redirects(size?: number, init?: IResponseInit): Promise<IResponseRedirect[]>;
|
|
33
31
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Http, Har, Types, Lorem, Time, Internet } from '@pawel-up/data-mock';
|
|
2
|
-
import { Kind as HttpResponseKind } from '../../models/HttpResponse.js';
|
|
2
|
+
import { HttpResponse, Kind as HttpResponseKind } from '../../models/HttpResponse.js';
|
|
3
3
|
import { Kind as ResponseKind } from '../../models/Response.js';
|
|
4
4
|
import { Kind as ResponseRedirectKind } from '../../models/ResponseRedirect.js';
|
|
5
5
|
export class Response {
|
|
@@ -17,10 +17,20 @@ export class Response {
|
|
|
17
17
|
this.har = new Har(init);
|
|
18
18
|
this.internet = new Internet(init);
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
_getPayload(mime) {
|
|
21
|
+
if (!mime) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
switch (mime) {
|
|
25
|
+
case 'multipart/form-data': return this.http.formData.form();
|
|
26
|
+
default:
|
|
27
|
+
return this.http.payload.payload(mime);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
async httpResponse(init = {}) {
|
|
31
|
+
const mime = this.http.headers.contentType(init.payload);
|
|
32
|
+
const body = this._getPayload(mime);
|
|
33
|
+
const headers = this.http.headers.headers('response', { mime: mime });
|
|
24
34
|
const statusGroup = init.statusGroup ? init.statusGroup : this.types.number({ min: 2, max: 5 });
|
|
25
35
|
const sCode = this.types.number({ min: 0, max: 99 }).toString();
|
|
26
36
|
const code = Number(`${statusGroup}${sCode.padStart(2, '0')}`);
|
|
@@ -31,13 +41,14 @@ export class Response {
|
|
|
31
41
|
statusText: status,
|
|
32
42
|
headers,
|
|
33
43
|
};
|
|
34
|
-
|
|
35
|
-
|
|
44
|
+
const response = new HttpResponse(result);
|
|
45
|
+
if (body) {
|
|
46
|
+
await response.writePayload(body);
|
|
36
47
|
}
|
|
37
|
-
return
|
|
48
|
+
return response.toJSON();
|
|
38
49
|
}
|
|
39
|
-
response(init = {}) {
|
|
40
|
-
const base = this.httpResponse(init);
|
|
50
|
+
async response(init = {}) {
|
|
51
|
+
const base = await this.httpResponse(init);
|
|
41
52
|
const length = this.types.number({ min: 10, max: 4000 });
|
|
42
53
|
const result = {
|
|
43
54
|
...base,
|
|
@@ -56,7 +67,7 @@ export class Response {
|
|
|
56
67
|
};
|
|
57
68
|
return result;
|
|
58
69
|
}
|
|
59
|
-
redirect(init) {
|
|
70
|
+
async redirect(init = {}) {
|
|
60
71
|
const start = this.time.timestamp();
|
|
61
72
|
const end = this.time.timestamp({ min: start + 1 });
|
|
62
73
|
const info = {
|
|
@@ -64,16 +75,19 @@ export class Response {
|
|
|
64
75
|
startTime: start,
|
|
65
76
|
endTime: end,
|
|
66
77
|
url: this.internet.uri(),
|
|
67
|
-
response: this.httpResponse({ ...init, statusGroup: 3 }),
|
|
78
|
+
response: await this.httpResponse({ ...init, statusGroup: 3 }),
|
|
68
79
|
};
|
|
80
|
+
if (init.timings) {
|
|
81
|
+
info.timings = this.har.timing(init);
|
|
82
|
+
}
|
|
69
83
|
return info;
|
|
70
84
|
}
|
|
71
|
-
redirects(size = 1, init) {
|
|
85
|
+
async redirects(size = 1, init) {
|
|
72
86
|
const result = [];
|
|
73
87
|
for (let i = 0; i < size; i++) {
|
|
74
88
|
result.push(this.redirect(init));
|
|
75
89
|
}
|
|
76
|
-
return result;
|
|
90
|
+
return Promise.all(result);
|
|
77
91
|
}
|
|
78
92
|
}
|
|
79
93
|
//# sourceMappingURL=Response.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Response.js","sourceRoot":"","sources":["../../../../src/mocking/lib/Response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"Response.js","sourceRoot":"","sources":["../../../../src/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9D,CAAC;QACF,IAAI,IAAI,CAAC,OAAO,EAAE;YAChB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;SACtC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,IAAI,GAAC,CAAC,EAAE,IAAoB;QAC1C,MAAM,MAAM,GAAiC,EAAE,CAAC;QAChD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,EAAE;YAC7B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;SAClC;QACD,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IDataMockInit, Internet, Types } from "@pawel-up/data-mock";
|
|
2
2
|
import { IUrl } from "../../models/Url.js";
|
|
3
3
|
/**
|
|
4
4
|
* Mocks the URL data.
|
|
@@ -6,7 +6,7 @@ import { IUrl } from "../../models/Url.js";
|
|
|
6
6
|
export declare class Url {
|
|
7
7
|
types: Types;
|
|
8
8
|
internet: Internet;
|
|
9
|
-
constructor(init?:
|
|
9
|
+
constructor(init?: IDataMockInit);
|
|
10
10
|
url(): IUrl;
|
|
11
11
|
urls(size?: number): IUrl[];
|
|
12
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Url.js","sourceRoot":"","sources":["../../../../src/mocking/lib/Url.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Url.js","sourceRoot":"","sources":["../../../../src/mocking/lib/Url.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,QAAQ,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAGrE;;GAEG;AACH,MAAM,OAAO,GAAG;IACd,KAAK,CAAQ;IACb,QAAQ,CAAW;IAEnB,YAAY,OAAoB,EAAE;QAChC,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClC,IAAI,CAAC,QAAQ,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IAED,GAAG;QACD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QACnC,MAAM,MAAM,GAAS;YACnB,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE;YACxB,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;YAClC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE;SACrB,CAAC;QACF,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAC1B,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QACjC,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAI,CAAC,IAAI,GAAC,EAAE;QACV,MAAM,MAAM,GAAW,EAAE,CAAC;QAC1B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,EAAE;YAC7B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;SACzB;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Internet, Types,
|
|
1
|
+
import { Internet, Types, IDataMockInit, Person, Random } from '@pawel-up/data-mock';
|
|
2
2
|
import { IUser } from '../../models/store/User.js';
|
|
3
3
|
export interface IUserInit {
|
|
4
4
|
noEmail?: boolean;
|
|
@@ -10,6 +10,6 @@ export declare class User {
|
|
|
10
10
|
types: Types;
|
|
11
11
|
internet: Internet;
|
|
12
12
|
random: Random;
|
|
13
|
-
constructor(init?:
|
|
13
|
+
constructor(init?: IDataMockInit);
|
|
14
14
|
user(init?: IUserInit): IUser;
|
|
15
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"User.js","sourceRoot":"","sources":["../../../../src/mocking/lib/User.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"User.js","sourceRoot":"","sources":["../../../../src/mocking/lib/User.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAiB,MAAM,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACrF,OAAO,EAAS,IAAI,IAAI,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAQrE,MAAM,OAAO,IAAI;IACf,MAAM,CAAS;IACf,KAAK,CAAQ;IACb,QAAQ,CAAW;IACnB,MAAM,CAAS;IAEf,YAAY,OAAoB,EAAE;QAChC,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClC,IAAI,CAAC,QAAQ,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,IAAI,CAAC,OAAkB,EAAE;QACvB,MAAM,MAAM,GAAU;YACpB,IAAI,EAAE,QAAQ;YACd,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;YACtB,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE;SACzB,CAAA;QACD,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,MAAM,CAAC,KAAK,GAAG,CAAC;oBACd,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE;oBAC5B,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;iBAC/B,CAAC,CAAC;SACJ;QACD,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACnB,MAAM,CAAC,OAAO,GAAG;gBACf,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE;aAC5B,CAAC;SACH;QACD,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YACpB,MAAM,CAAC,QAAQ,GAAG;gBAChB,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;aAChC,CAAC;SACH;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@api-client/core",
|
|
3
3
|
"description": "The API Client's core client library. Works in NodeJS and in a ES enabled browser.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.6.2",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "build/index.js",
|
|
7
7
|
"module": "build/index.js",
|
|
@@ -84,12 +84,12 @@
|
|
|
84
84
|
]
|
|
85
85
|
},
|
|
86
86
|
"dependencies": {
|
|
87
|
-
"@api-client/json": "^0.1.
|
|
87
|
+
"@api-client/json": "^0.1.3",
|
|
88
88
|
"@metrichor/jmespath": "^0.3.1",
|
|
89
|
-
"@pawel-up/data-mock": "^0.
|
|
89
|
+
"@pawel-up/data-mock": "^0.3.0",
|
|
90
90
|
"@pawel-up/jexl": "^3.0.0",
|
|
91
|
-
"@xmldom/xmldom": "^0.8.
|
|
92
|
-
"console-table-printer": "^2.
|
|
91
|
+
"@xmldom/xmldom": "^0.8.2",
|
|
92
|
+
"console-table-printer": "^2.11.0",
|
|
93
93
|
"form-data": "^4.0.0",
|
|
94
94
|
"ws": "^8.5.0",
|
|
95
95
|
"xpath": "^0.0.32"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IDataMockInit, IHarTimingInit, IHttpResponseRedirectStatusInit } from '@pawel-up/data-mock'
|
|
2
2
|
|
|
3
|
-
export interface ArcDataMockInit extends
|
|
3
|
+
export interface ArcDataMockInit extends IDataMockInit {
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
export interface VariableInit {
|
|
@@ -13,7 +13,7 @@ export declare interface RestApiIndexInit {
|
|
|
13
13
|
order?: number;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export declare interface HttpResponseArcInit extends
|
|
16
|
+
export declare interface HttpResponseArcInit extends IHarTimingInit {
|
|
17
17
|
/**
|
|
18
18
|
* When set it does not generate a response payload.
|
|
19
19
|
*/
|
|
@@ -36,7 +36,7 @@ export declare interface HttpResponseArcInit extends HarTimingInit {
|
|
|
36
36
|
redirects?: boolean;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
export declare interface HttpResponseRedirectInit extends
|
|
39
|
+
export declare interface HttpResponseRedirectInit extends IHttpResponseRedirectStatusInit, IHarTimingInit {
|
|
40
40
|
/**
|
|
41
41
|
* When set it adds body to the response
|
|
42
42
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataMock,
|
|
1
|
+
import { DataMock, IDataMockInit } from '@pawel-up/data-mock';
|
|
2
2
|
import { Request } from './lib/Request.js';
|
|
3
3
|
import { Response } from './lib/Response.js';
|
|
4
4
|
import { User } from './lib/User.js';
|
|
@@ -20,7 +20,7 @@ export class ProjectMock extends DataMock {
|
|
|
20
20
|
/**
|
|
21
21
|
* @param init The library init options.
|
|
22
22
|
*/
|
|
23
|
-
constructor(init?:
|
|
23
|
+
constructor(init?: IDataMockInit) {
|
|
24
24
|
super(init);
|
|
25
25
|
this.projectRequest = new Request(init);
|
|
26
26
|
this.response = new Response(init);
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { Http as Base, Types, Lorem, Time,
|
|
2
|
-
import { randomValue } from '@pawel-up/data-mock/build/src/lib/Http.js';
|
|
1
|
+
import { Http as Base, Types, Lorem, Time, IHttpRequestInit, Random } from '@pawel-up/data-mock';
|
|
3
2
|
import { ArcDataMockInit } from '../LegacyInterfaces.js';
|
|
4
3
|
import { HttpResponse } from './HttpResponse.js';
|
|
5
4
|
import { ARCHistoryRequest, ARCSavedRequest, TransportRequest } from '../../models/legacy/request/ArcRequest.js';
|
|
6
5
|
import { ARCProject } from '../../models/legacy/models/ArcLegacyProject.js';
|
|
7
6
|
|
|
8
|
-
export interface RequestHistoryInit extends
|
|
7
|
+
export interface RequestHistoryInit extends IHttpRequestInit {
|
|
9
8
|
noId?: boolean;
|
|
10
9
|
}
|
|
11
10
|
|
|
12
|
-
export interface RequestSavedInit extends
|
|
11
|
+
export interface RequestSavedInit extends IHttpRequestInit {
|
|
13
12
|
forceDescription?: boolean;
|
|
14
13
|
noDescription?: boolean;
|
|
15
14
|
project?: string;
|
|
@@ -33,7 +32,7 @@ export declare interface GenerateSavedResult {
|
|
|
33
32
|
requests: ARCSavedRequest[];
|
|
34
33
|
}
|
|
35
34
|
|
|
36
|
-
export interface TransportRequestInit extends
|
|
35
|
+
export interface TransportRequestInit extends IHttpRequestInit {
|
|
37
36
|
noHttpMessage?: boolean;
|
|
38
37
|
}
|
|
39
38
|
|
|
@@ -41,9 +40,12 @@ export class Http extends Base {
|
|
|
41
40
|
LAST_TIME: number;
|
|
42
41
|
types: Types;
|
|
43
42
|
lorem: Lorem;
|
|
43
|
+
// @ts-ignore
|
|
44
44
|
response: HttpResponse;
|
|
45
45
|
time: Time;
|
|
46
46
|
|
|
47
|
+
protected _random: Random;
|
|
48
|
+
|
|
47
49
|
constructor(init: ArcDataMockInit={}) {
|
|
48
50
|
super(init);
|
|
49
51
|
this.LAST_TIME = Date.now();
|
|
@@ -51,10 +53,11 @@ export class Http extends Base {
|
|
|
51
53
|
this.lorem = new Lorem(init);
|
|
52
54
|
this.response = new HttpResponse(init);
|
|
53
55
|
this.time = new Time(init);
|
|
56
|
+
this._random = new Random(init.seed);
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
history(opts: RequestHistoryInit={}): ARCHistoryRequest {
|
|
57
|
-
const base = this.request(opts);
|
|
60
|
+
const base = this.request.request(opts);
|
|
58
61
|
this.LAST_TIME -= this.types.datetime().getTime();
|
|
59
62
|
const midnight = this.time.midnight(this.LAST_TIME);
|
|
60
63
|
|
|
@@ -72,7 +75,7 @@ export class Http extends Base {
|
|
|
72
75
|
}
|
|
73
76
|
|
|
74
77
|
saved(opts: RequestSavedInit={}): ARCSavedRequest {
|
|
75
|
-
const base = this.request(opts);
|
|
78
|
+
const base = this.request.request(opts);
|
|
76
79
|
const time = this.types.datetime().getTime();
|
|
77
80
|
const requestName = this.lorem.words(2);
|
|
78
81
|
const description = this.description(opts);
|
|
@@ -165,7 +168,7 @@ export class Http extends Base {
|
|
|
165
168
|
allow = this.types.boolean();
|
|
166
169
|
}
|
|
167
170
|
if (allow) {
|
|
168
|
-
return this
|
|
171
|
+
return this._random.pickOne(opts.projects);
|
|
169
172
|
}
|
|
170
173
|
return undefined;
|
|
171
174
|
}
|
|
@@ -214,7 +217,7 @@ export class Http extends Base {
|
|
|
214
217
|
* @returns The transport request object
|
|
215
218
|
*/
|
|
216
219
|
transportRequest(opts: TransportRequestInit={}): TransportRequest {
|
|
217
|
-
const base = this.request(opts);
|
|
220
|
+
const base = this.request.request(opts);
|
|
218
221
|
const request: TransportRequest = {
|
|
219
222
|
...base,
|
|
220
223
|
startTime: Date.now() - 1000,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Base, { headersValue, payloadValue, typesValue, loremValue } from '@pawel-up/data-mock/build/src/lib/http/Response.js';
|
|
2
2
|
import { Har, DataMockLocale } from '@pawel-up/data-mock';
|
|
3
3
|
import { ArcDataMockInit, HttpResponseArcInit, HttpResponseRedirectInit } from '../LegacyInterfaces.js';
|
|
4
4
|
import { ResponseRedirect, Response, ErrorResponse } from '../../models/legacy/request/ArcResponse.js';
|
|
@@ -36,7 +36,7 @@ export class HttpResponse extends Base {
|
|
|
36
36
|
const url = this[headersValue].link();
|
|
37
37
|
headers += `\nlocation: ${url}`;
|
|
38
38
|
const { code, status } = this.redirectStatus(init);
|
|
39
|
-
const body = init.body ? this[payloadValue].payload(ct) : undefined;
|
|
39
|
+
const body = init.body ? this[payloadValue].payload(ct as string) : undefined;
|
|
40
40
|
const startTime = this[typesValue].datetime().getTime();
|
|
41
41
|
const duration = this[typesValue].number({ min: 10, max: 4000 });
|
|
42
42
|
const result: ResponseRedirect = {
|
|
@@ -60,7 +60,7 @@ export class HttpResponse extends Base {
|
|
|
60
60
|
|
|
61
61
|
arcResponse(init: HttpResponseArcInit = {}): Response {
|
|
62
62
|
const ct = init.noBody ? undefined : this[headersValue].contentType();
|
|
63
|
-
const body = init.noBody ? undefined : this[payloadValue].payload(ct);
|
|
63
|
+
const body = init.noBody ? undefined : this[payloadValue].payload(ct as string);
|
|
64
64
|
const headers = this[headersValue].headers('response', { mime: ct });
|
|
65
65
|
const statusGroup = init.statusGroup ? init.statusGroup : this[typesValue].number({ min: 2, max: 5 });
|
|
66
66
|
const sCode = this[typesValue].number({ min: 0, max: 99 }).toString();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Internet, Types,
|
|
1
|
+
import { Internet, Types, IDataMockInit, Person, Random, ITypeDateTimeInit } from '@pawel-up/data-mock';
|
|
2
2
|
// import { randomValue } from '@pawel-up/data-mock/src/lib/Http.js';
|
|
3
3
|
import { IHttpHistory, Kind as HttpHistoryKind } from '../../models/HttpHistory.js';
|
|
4
4
|
import { Request, IRequestLogInit } from './Request.js';
|
|
@@ -32,7 +32,7 @@ export interface IHttpHistoryInit {
|
|
|
32
32
|
/**
|
|
33
33
|
* The created time init options.
|
|
34
34
|
*/
|
|
35
|
-
created?:
|
|
35
|
+
created?: ITypeDateTimeInit;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
export interface IHttpHistoryListInit extends IHttpHistoryInit {
|
|
@@ -70,7 +70,7 @@ export class History {
|
|
|
70
70
|
random: Random;
|
|
71
71
|
request: Request;
|
|
72
72
|
|
|
73
|
-
constructor(init:
|
|
73
|
+
constructor(init: IDataMockInit={}) {
|
|
74
74
|
this.person = new Person(init);
|
|
75
75
|
this.types = new Types(init.seed);
|
|
76
76
|
this.internet = new Internet(init);
|
|
@@ -78,12 +78,12 @@ export class History {
|
|
|
78
78
|
this.request = new Request(init);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
httpHistory(init: IHttpHistoryInit = {}): IHttpHistory {
|
|
81
|
+
async httpHistory(init: IHttpHistoryInit = {}): Promise<IHttpHistory> {
|
|
82
82
|
const date = this.types.datetime(init.created);
|
|
83
83
|
const result: IHttpHistory = {
|
|
84
84
|
kind: HttpHistoryKind,
|
|
85
85
|
created: date.getTime(),
|
|
86
|
-
log: this.request.log(init.log),
|
|
86
|
+
log: await this.request.log(init.log),
|
|
87
87
|
user: '',
|
|
88
88
|
}
|
|
89
89
|
date.setHours(0, 0, 0, 0);
|
|
@@ -131,7 +131,7 @@ export class History {
|
|
|
131
131
|
return result;
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
httpHistoryList(size=25, init: IHttpHistoryListInit = {}): IHttpHistory[] {
|
|
134
|
+
async httpHistoryList(size=25, init: IHttpHistoryListInit = {}): Promise<IHttpHistory[]> {
|
|
135
135
|
const { usersSize, spacesSize, projectsSize, requestsSize, appsSize } = init;
|
|
136
136
|
const copy = { ...init };
|
|
137
137
|
if (usersSize && typeof init.user === 'undefined') {
|
|
@@ -172,7 +172,7 @@ export class History {
|
|
|
172
172
|
|
|
173
173
|
const result: IHttpHistory[] = [];
|
|
174
174
|
for (let i = 0; i < size; i++) {
|
|
175
|
-
result.push(this.httpHistory(copy));
|
|
175
|
+
result.push(await this.httpHistory(copy));
|
|
176
176
|
}
|
|
177
177
|
return result;
|
|
178
178
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Http, Types, Lorem, Time,
|
|
1
|
+
import { Http, Types, Lorem, Time, IDataMockInit, IHttpRequestInit } from '@pawel-up/data-mock';
|
|
2
2
|
// import { randomValue } from '@pawel-up/data-mock/src/lib/Http.js';
|
|
3
3
|
import { IHttpRequest, Kind as HttpRequestKind } from '../../models/HttpRequest.js';
|
|
4
4
|
import { IRequest, Kind as RequestKind } from '../../models/Request.js';
|
|
@@ -7,7 +7,7 @@ import { IRequestLog, Kind as RequestLogKind } from '../../models/RequestLog.js'
|
|
|
7
7
|
import { IResponseInit, Response } from './Response.js';
|
|
8
8
|
|
|
9
9
|
export interface IRequestLogInit {
|
|
10
|
-
request?:
|
|
10
|
+
request?: IHttpRequestInit;
|
|
11
11
|
response?: IResponseInit;
|
|
12
12
|
/**
|
|
13
13
|
* When set it ignores size information
|
|
@@ -21,6 +21,14 @@ export interface IRequestLogInit {
|
|
|
21
21
|
noRequest?: boolean;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
export interface IRequestInit extends IResponseInit {
|
|
25
|
+
/**
|
|
26
|
+
* The content type to generate the body for.
|
|
27
|
+
* Has no effect when `noBody` is set.
|
|
28
|
+
*/
|
|
29
|
+
contentType?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
24
32
|
export class Request {
|
|
25
33
|
types: Types;
|
|
26
34
|
lorem: Lorem;
|
|
@@ -28,7 +36,7 @@ export class Request {
|
|
|
28
36
|
http: Http;
|
|
29
37
|
response: Response;
|
|
30
38
|
|
|
31
|
-
constructor(init:
|
|
39
|
+
constructor(init: IDataMockInit={}) {
|
|
32
40
|
this.types = new Types(init.seed);
|
|
33
41
|
this.lorem = new Lorem(init);
|
|
34
42
|
this.time = new Time(init);
|
|
@@ -36,7 +44,7 @@ export class Request {
|
|
|
36
44
|
this.response = new Response(init);
|
|
37
45
|
}
|
|
38
46
|
|
|
39
|
-
request(init?:
|
|
47
|
+
request(init?: IHttpRequestInit): IRequest {
|
|
40
48
|
return {
|
|
41
49
|
kind: RequestKind,
|
|
42
50
|
expects: this.httpRequest(init),
|
|
@@ -47,15 +55,15 @@ export class Request {
|
|
|
47
55
|
}
|
|
48
56
|
}
|
|
49
57
|
|
|
50
|
-
httpRequest(init?:
|
|
51
|
-
const request = this.http.request(init);
|
|
58
|
+
httpRequest(init?: IHttpRequestInit): IHttpRequest {
|
|
59
|
+
const request = this.http.request.request(init);
|
|
52
60
|
return {
|
|
53
61
|
kind: HttpRequestKind,
|
|
54
62
|
...request,
|
|
55
63
|
}
|
|
56
64
|
}
|
|
57
65
|
|
|
58
|
-
sentRequest(init?:
|
|
66
|
+
sentRequest(init?: IHttpRequestInit): ISentRequest {
|
|
59
67
|
const start = this.time.timestamp();
|
|
60
68
|
return {
|
|
61
69
|
startTime: start,
|
|
@@ -64,7 +72,7 @@ export class Request {
|
|
|
64
72
|
};
|
|
65
73
|
}
|
|
66
74
|
|
|
67
|
-
log(init: IRequestLogInit = {}): IRequestLog {
|
|
75
|
+
async log(init: IRequestLogInit = {}): Promise<IRequestLog> {
|
|
68
76
|
const result: IRequestLog = {
|
|
69
77
|
kind: RequestLogKind,
|
|
70
78
|
};
|
|
@@ -72,10 +80,10 @@ export class Request {
|
|
|
72
80
|
result.request = this.sentRequest(init.request);
|
|
73
81
|
}
|
|
74
82
|
if (!init.noResponse) {
|
|
75
|
-
result.response = this.response.response(init.response);
|
|
83
|
+
result.response = await this.response.response(init.response);
|
|
76
84
|
}
|
|
77
85
|
if (init.redirects) {
|
|
78
|
-
result.redirects = this.response.redirects();
|
|
86
|
+
result.redirects = await this.response.redirects(undefined, init.response);
|
|
79
87
|
}
|
|
80
88
|
if (!init.noSize) {
|
|
81
89
|
result.size = this.response.size();
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import { Http, Har, Types, Lorem, Time,
|
|
2
|
-
import { IHttpResponse, Kind as HttpResponseKind } from '../../models/HttpResponse.js';
|
|
1
|
+
import { Http, Har, Types, Lorem, Time, IDataMockInit, IHttpResponseInit, IHarTimingInit, Internet, IHttpPayloadInit } from '@pawel-up/data-mock';
|
|
2
|
+
import { IHttpResponse, HttpResponse, Kind as HttpResponseKind } from '../../models/HttpResponse.js';
|
|
3
3
|
import { IResponse, Kind as ResponseKind } from '../../models/Response.js';
|
|
4
4
|
import { IRequestsSize } from '../../models/RequestsSize.js';
|
|
5
5
|
import { IResponseRedirect, Kind as ResponseRedirectKind } from '../../models/ResponseRedirect.js';
|
|
6
|
+
import { DeserializedPayload } from '../../lib/transformers/PayloadSerializer.js';
|
|
6
7
|
|
|
7
|
-
export interface IResponseInit extends
|
|
8
|
-
/**
|
|
9
|
-
* When set it does not generate a response payload.
|
|
10
|
-
*/
|
|
11
|
-
noBody?: boolean;
|
|
8
|
+
export interface IResponseInit extends IHttpResponseInit, IHarTimingInit {
|
|
12
9
|
/**
|
|
13
10
|
* The first number of the status group. Other 2 are auto generated
|
|
14
11
|
*/
|
|
@@ -27,7 +24,7 @@ export class Response {
|
|
|
27
24
|
har: Har;
|
|
28
25
|
internet: Internet;
|
|
29
26
|
|
|
30
|
-
constructor(init:
|
|
27
|
+
constructor(init: IDataMockInit={}) {
|
|
31
28
|
this.types = new Types(init.seed);
|
|
32
29
|
this.lorem = new Lorem(init);
|
|
33
30
|
this.time = new Time(init);
|
|
@@ -36,10 +33,21 @@ export class Response {
|
|
|
36
33
|
this.internet = new Internet(init);
|
|
37
34
|
}
|
|
38
35
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
protected _getPayload(mime?: string): DeserializedPayload {
|
|
37
|
+
if (!mime) {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
switch (mime) {
|
|
41
|
+
case 'multipart/form-data': return this.http.formData.form();
|
|
42
|
+
default:
|
|
43
|
+
return this.http.payload.payload(mime as string);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async httpResponse(init: IResponseInit = {}): Promise<IHttpResponse> {
|
|
48
|
+
const mime = this.http.headers.contentType(init.payload as IHttpPayloadInit);
|
|
49
|
+
const body = this._getPayload(mime);
|
|
50
|
+
const headers = this.http.headers.headers('response', { mime: mime });
|
|
43
51
|
const statusGroup = init.statusGroup ? init.statusGroup : this.types.number({ min: 2, max: 5 });
|
|
44
52
|
const sCode = this.types.number({ min: 0, max: 99 }).toString();
|
|
45
53
|
const code = Number(`${statusGroup}${sCode.padStart(2, '0')}`);
|
|
@@ -50,14 +58,15 @@ export class Response {
|
|
|
50
58
|
statusText: status,
|
|
51
59
|
headers,
|
|
52
60
|
};
|
|
53
|
-
|
|
54
|
-
|
|
61
|
+
const response = new HttpResponse(result);
|
|
62
|
+
if (body) {
|
|
63
|
+
await response.writePayload(body)
|
|
55
64
|
}
|
|
56
|
-
return
|
|
65
|
+
return response.toJSON();
|
|
57
66
|
}
|
|
58
67
|
|
|
59
|
-
response(init: IResponseInit={}): IResponse {
|
|
60
|
-
const base = this.httpResponse(init);
|
|
68
|
+
async response(init: IResponseInit={}): Promise<IResponse> {
|
|
69
|
+
const base = await this.httpResponse(init);
|
|
61
70
|
const length = this.types.number({ min: 10, max: 4000 });
|
|
62
71
|
const result: IResponse = {
|
|
63
72
|
...base,
|
|
@@ -78,7 +87,7 @@ export class Response {
|
|
|
78
87
|
return result;
|
|
79
88
|
}
|
|
80
89
|
|
|
81
|
-
redirect(init
|
|
90
|
+
async redirect(init: IResponseInit = {}): Promise<IResponseRedirect> {
|
|
82
91
|
const start = this.time.timestamp();
|
|
83
92
|
const end = this.time.timestamp({ min: start + 1 })
|
|
84
93
|
const info: IResponseRedirect = {
|
|
@@ -86,16 +95,19 @@ export class Response {
|
|
|
86
95
|
startTime: start,
|
|
87
96
|
endTime: end,
|
|
88
97
|
url: this.internet.uri(),
|
|
89
|
-
response: this.httpResponse({ ...init, statusGroup: 3}),
|
|
98
|
+
response: await this.httpResponse({ ...init, statusGroup: 3}),
|
|
90
99
|
};
|
|
100
|
+
if (init.timings) {
|
|
101
|
+
info.timings = this.har.timing(init);
|
|
102
|
+
}
|
|
91
103
|
return info;
|
|
92
104
|
}
|
|
93
105
|
|
|
94
|
-
redirects(size=1, init?: IResponseInit): IResponseRedirect[] {
|
|
95
|
-
const result: IResponseRedirect[] = [];
|
|
106
|
+
async redirects(size=1, init?: IResponseInit): Promise<IResponseRedirect[]> {
|
|
107
|
+
const result: Promise<IResponseRedirect>[] = [];
|
|
96
108
|
for (let i = 0; i < size; i++) {
|
|
97
109
|
result.push(this.redirect(init));
|
|
98
110
|
}
|
|
99
|
-
return result;
|
|
111
|
+
return Promise.all(result);
|
|
100
112
|
}
|
|
101
113
|
}
|
package/src/mocking/lib/Url.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IDataMockInit, Internet, Types } from "@pawel-up/data-mock";
|
|
2
2
|
import { IUrl } from "../../models/Url.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -8,7 +8,7 @@ export class Url {
|
|
|
8
8
|
types: Types;
|
|
9
9
|
internet: Internet;
|
|
10
10
|
|
|
11
|
-
constructor(init:
|
|
11
|
+
constructor(init: IDataMockInit={}) {
|
|
12
12
|
this.types = new Types(init.seed);
|
|
13
13
|
this.internet = new Internet(init);
|
|
14
14
|
}
|
package/src/mocking/lib/User.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Internet, Types,
|
|
2
|
-
// import { randomValue } from '@pawel-up/data-mock/src/lib/Http.js';
|
|
1
|
+
import { Internet, Types, IDataMockInit, Person, Random } from '@pawel-up/data-mock';
|
|
3
2
|
import { IUser, Kind as UserKind } from '../../models/store/User.js';
|
|
4
3
|
|
|
5
4
|
export interface IUserInit {
|
|
@@ -14,7 +13,7 @@ export class User {
|
|
|
14
13
|
internet: Internet;
|
|
15
14
|
random: Random;
|
|
16
15
|
|
|
17
|
-
constructor(init:
|
|
16
|
+
constructor(init: IDataMockInit={}) {
|
|
18
17
|
this.person = new Person(init);
|
|
19
18
|
this.types = new Types(init.seed);
|
|
20
19
|
this.internet = new Internet(init);
|