@api-client/core 0.3.11 → 0.3.12
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 +1 -1
- package/build/index.d.ts +1 -1
- package/build/src/mocking/ProjectMock.d.ts +6 -0
- package/build/src/mocking/ProjectMock.js +6 -0
- package/build/src/mocking/ProjectMock.js.map +1 -1
- package/build/src/mocking/lib/History.d.ts +70 -0
- package/build/src/mocking/lib/History.js +120 -0
- package/build/src/mocking/lib/History.js.map +1 -0
- package/build/src/mocking/lib/User.d.ts +20 -0
- package/build/src/mocking/lib/User.js +51 -0
- package/build/src/mocking/lib/User.js.map +1 -0
- package/build/src/models/Backend.d.ts +85 -0
- package/build/src/models/HttpHistory.d.ts +34 -17
- package/build/src/models/HttpHistory.js +42 -18
- package/build/src/models/HttpHistory.js.map +1 -1
- package/package.json +1 -1
- package/src/mocking/ProjectMock.ts +8 -0
- package/src/mocking/lib/History.ts +179 -0
- package/src/mocking/lib/User.ts +67 -0
- package/src/models/Backend.ts +93 -0
- package/src/models/HttpHistory.ts +58 -26
package/build/browser.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { IApplication } from './src/models/Application.js';
|
|
|
2
2
|
export { ArcResponse, IArcResponse, Kind as ArcResponseKind } from './src/models/ArcResponse.js';
|
|
3
3
|
export { IAuthorizationSettingsUnion, IApiKeyAuthorization, IAuthorizationParams, IBasicAuthorization, IBearerAuthorization, ICCAuthorization, IDigestAuthorization, INtlmAuthorization, IOAuth1Authorization, IOAuth2Authorization, IOAuth2AuthorizationRequestCustomData, IOAuth2CustomData, IOAuth2CustomParameter, IOAuth2TokenRequestCustomData, IOauth2GrantType, IOauth2ResponseType, IOidcAuthorization, IOidcTokenError, IOidcTokenInfo, IPassThroughAuthorization, IRamlCustomAuthorization, ITokenError, ITokenInfo, ITokenRemoveOptions, OAuth2DeliveryMethod } from './src/models/Authorization.js';
|
|
4
4
|
export { AuthorizationData, IAuthorizationData } from './src/models/AuthorizationData.js';
|
|
5
|
-
export { IBackendInfo, IBackendCommand, IBackendEvent, IListResponse, IListOptions } from './src/models/Backend.js';
|
|
5
|
+
export { IBackendInfo, IBackendCommand, IBackendEvent, IListResponse, IListOptions, HistoryListOptions, IHistorySpaceListOptions, IHistoryProjectListOptions, IHistoryRequestListOptions, IHistoryUserListOptions, IHistoryAppListOptions, ICursorOptions } from './src/models/Backend.js';
|
|
6
6
|
export { CertificateType, ICertificate, ICertificateIndex, IClientCertificate, IRequestCertificate } from './src/models/ClientCertificate.js';
|
|
7
7
|
export { Environment, IEnvironment, Kind as EnvironmentKind } from './src/models/Environment.js';
|
|
8
8
|
export { ErrorResponse, IErrorResponse } from './src/models/ErrorResponse.js';
|
package/build/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { IApplication } from './src/models/Application.js';
|
|
|
2
2
|
export { ArcResponse, IArcResponse, Kind as ArcResponseKind } from './src/models/ArcResponse.js';
|
|
3
3
|
export { IAuthorizationSettingsUnion, IApiKeyAuthorization, IAuthorizationParams, IBasicAuthorization, IBearerAuthorization, ICCAuthorization, IDigestAuthorization, INtlmAuthorization, IOAuth1Authorization, IOAuth2Authorization, IOAuth2AuthorizationRequestCustomData, IOAuth2CustomData, IOAuth2CustomParameter, IOAuth2TokenRequestCustomData, IOauth2GrantType, IOauth2ResponseType, IOidcAuthorization, IOidcTokenError, IOidcTokenInfo, IPassThroughAuthorization, IRamlCustomAuthorization, ITokenError, ITokenInfo, ITokenRemoveOptions, OAuth2DeliveryMethod } from './src/models/Authorization.js';
|
|
4
4
|
export { AuthorizationData, IAuthorizationData } from './src/models/AuthorizationData.js';
|
|
5
|
-
export { IBackendInfo, IBackendCommand, IBackendEvent, IListResponse, IListOptions } from './src/models/Backend.js';
|
|
5
|
+
export { IBackendInfo, IBackendCommand, IBackendEvent, IListResponse, IListOptions, HistoryListOptions, IHistorySpaceListOptions, IHistoryProjectListOptions, IHistoryRequestListOptions, IHistoryUserListOptions, IHistoryAppListOptions, ICursorOptions } from './src/models/Backend.js';
|
|
6
6
|
export { CertificateType, ICertificate, ICertificateIndex, IClientCertificate, IRequestCertificate } from './src/models/ClientCertificate.js';
|
|
7
7
|
export { Environment, IEnvironment, Kind as EnvironmentKind } from './src/models/Environment.js';
|
|
8
8
|
export { ErrorResponse, IErrorResponse } from './src/models/ErrorResponse.js';
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { DataMock, DataMockInit } from '@pawel-up/data-mock';
|
|
2
2
|
import { Request } from './lib/Request.js';
|
|
3
3
|
import { Response } from './lib/Response.js';
|
|
4
|
+
import { User } from './lib/User.js';
|
|
5
|
+
import { History } from './lib/History.js';
|
|
4
6
|
export { IRequestLogInit } from './lib/Request.js';
|
|
5
7
|
export { IArcResponseInit } from './lib/Response.js';
|
|
8
|
+
export { ISpaceUserInit, IUserInit } from './lib/User.js';
|
|
9
|
+
export { IHttpHistoryInit, IHttpHistoryListInit } from './lib/History.js';
|
|
6
10
|
export declare class ProjectMock extends DataMock {
|
|
7
11
|
projectRequest: Request;
|
|
8
12
|
response: Response;
|
|
13
|
+
user: User;
|
|
14
|
+
history: History;
|
|
9
15
|
/**
|
|
10
16
|
* @param init The library init options.
|
|
11
17
|
*/
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { DataMock } from '@pawel-up/data-mock';
|
|
2
2
|
import { Request } from './lib/Request.js';
|
|
3
3
|
import { Response } from './lib/Response.js';
|
|
4
|
+
import { User } from './lib/User.js';
|
|
5
|
+
import { History } from './lib/History.js';
|
|
4
6
|
export class ProjectMock extends DataMock {
|
|
5
7
|
projectRequest;
|
|
6
8
|
response;
|
|
9
|
+
user;
|
|
10
|
+
history;
|
|
7
11
|
/**
|
|
8
12
|
* @param init The library init options.
|
|
9
13
|
*/
|
|
@@ -11,6 +15,8 @@ export class ProjectMock extends DataMock {
|
|
|
11
15
|
super(init);
|
|
12
16
|
this.projectRequest = new Request(init);
|
|
13
17
|
this.response = new Response(init);
|
|
18
|
+
this.user = new User(init);
|
|
19
|
+
this.history = new History(init);
|
|
14
20
|
}
|
|
15
21
|
}
|
|
16
22
|
//# sourceMappingURL=ProjectMock.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProjectMock.js","sourceRoot":"","sources":["../../../src/mocking/ProjectMock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAgB,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"ProjectMock.js","sourceRoot":"","sources":["../../../src/mocking/ProjectMock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAgB,MAAM,qBAAqB,CAAC;AAC7D,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;AAO3C,MAAM,OAAO,WAAY,SAAQ,QAAQ;IACvC,cAAc,CAAU;IACxB,QAAQ,CAAW;IACnB,IAAI,CAAO;IACX,OAAO,CAAU;IAEjB;;OAEG;IACH,YAAY,IAAmB;QAC7B,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;IACnC,CAAC;CACF"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Internet, Types, DataMockInit, Person, Random, TypeDateTimeInit } from '@pawel-up/data-mock';
|
|
2
|
+
import { IHttpHistory } from '../../models/HttpHistory.js';
|
|
3
|
+
import { Request, IRequestLogInit } from './Request.js';
|
|
4
|
+
export interface IHttpHistoryInit {
|
|
5
|
+
/**
|
|
6
|
+
* Either space id, list of spaces to pick one or whether to generate a space.
|
|
7
|
+
*/
|
|
8
|
+
space?: boolean | string | string[];
|
|
9
|
+
/**
|
|
10
|
+
* User is always generated per store requirements.
|
|
11
|
+
*/
|
|
12
|
+
user?: string | string[];
|
|
13
|
+
/**
|
|
14
|
+
* Either project id, list of projects to pick one or whether to generate a project.
|
|
15
|
+
*/
|
|
16
|
+
project?: boolean | string | string[];
|
|
17
|
+
/**
|
|
18
|
+
* Either request id, list of requests to pick one or whether to generate a request.
|
|
19
|
+
*/
|
|
20
|
+
request?: boolean | string | string[];
|
|
21
|
+
/**
|
|
22
|
+
* Either app id, list of apps to pick one or whether to generate an app.
|
|
23
|
+
*/
|
|
24
|
+
app?: boolean | string | string[];
|
|
25
|
+
/**
|
|
26
|
+
* The log init options
|
|
27
|
+
*/
|
|
28
|
+
log?: IRequestLogInit;
|
|
29
|
+
/**
|
|
30
|
+
* The created time init options.
|
|
31
|
+
*/
|
|
32
|
+
created?: TypeDateTimeInit;
|
|
33
|
+
}
|
|
34
|
+
export interface IHttpHistoryListInit extends IHttpHistoryInit {
|
|
35
|
+
/**
|
|
36
|
+
* When set it generates as many user IDs.
|
|
37
|
+
* Ignored when the `user` is set.
|
|
38
|
+
*/
|
|
39
|
+
usersSize?: number;
|
|
40
|
+
/**
|
|
41
|
+
* When set it generates as many space ids.
|
|
42
|
+
* Ignored when the `space` is set.
|
|
43
|
+
*/
|
|
44
|
+
spacesSize?: number;
|
|
45
|
+
/**
|
|
46
|
+
* When set it generates as many project ids.
|
|
47
|
+
* Ignored when the `project` is set.
|
|
48
|
+
*/
|
|
49
|
+
projectsSize?: number;
|
|
50
|
+
/**
|
|
51
|
+
* When set it generates as many request ids.
|
|
52
|
+
* Ignored when the `request` is set.
|
|
53
|
+
*/
|
|
54
|
+
requestsSize?: number;
|
|
55
|
+
/**
|
|
56
|
+
* When set it generates as many app ids.
|
|
57
|
+
* Ignored when the `app` is set.
|
|
58
|
+
*/
|
|
59
|
+
appsSize?: number;
|
|
60
|
+
}
|
|
61
|
+
export declare class History {
|
|
62
|
+
person: Person;
|
|
63
|
+
types: Types;
|
|
64
|
+
internet: Internet;
|
|
65
|
+
random: Random;
|
|
66
|
+
request: Request;
|
|
67
|
+
constructor(init?: DataMockInit);
|
|
68
|
+
httpHistory(init?: IHttpHistoryInit): IHttpHistory;
|
|
69
|
+
httpHistoryList(size?: number, init?: IHttpHistoryListInit): IHttpHistory[];
|
|
70
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { Internet, Types, Person, Random } from '@pawel-up/data-mock';
|
|
2
|
+
// import { randomValue } from '@pawel-up/data-mock/src/lib/Http.js';
|
|
3
|
+
import { Kind as HttpHistoryKind } from '../../models/HttpHistory.js';
|
|
4
|
+
import { Request } from './Request.js';
|
|
5
|
+
export class History {
|
|
6
|
+
person;
|
|
7
|
+
types;
|
|
8
|
+
internet;
|
|
9
|
+
random;
|
|
10
|
+
request;
|
|
11
|
+
constructor(init = {}) {
|
|
12
|
+
this.person = new Person(init);
|
|
13
|
+
this.types = new Types(init.seed);
|
|
14
|
+
this.internet = new Internet(init);
|
|
15
|
+
this.random = new Random(init.seed);
|
|
16
|
+
this.request = new Request(init);
|
|
17
|
+
}
|
|
18
|
+
httpHistory(init = {}) {
|
|
19
|
+
const date = this.types.datetime(init.created);
|
|
20
|
+
const result = {
|
|
21
|
+
kind: HttpHistoryKind,
|
|
22
|
+
created: date.getTime(),
|
|
23
|
+
log: this.request.log(init.log),
|
|
24
|
+
user: '',
|
|
25
|
+
};
|
|
26
|
+
date.setHours(0, 0, 0, 0);
|
|
27
|
+
result.midnight = date.getTime();
|
|
28
|
+
if (typeof init.space === 'string') {
|
|
29
|
+
result.space = init.space;
|
|
30
|
+
}
|
|
31
|
+
else if (Array.isArray(init.space)) {
|
|
32
|
+
result.space = this.random.pickOne(init.space);
|
|
33
|
+
}
|
|
34
|
+
else if (init.space) {
|
|
35
|
+
result.space = this.types.string(10);
|
|
36
|
+
}
|
|
37
|
+
if (typeof init.user === 'string') {
|
|
38
|
+
result.user = init.user;
|
|
39
|
+
}
|
|
40
|
+
else if (Array.isArray(init.user)) {
|
|
41
|
+
result.user = this.random.pickOne(init.user);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
result.user = this.types.uuid();
|
|
45
|
+
}
|
|
46
|
+
if (typeof init.project === 'string') {
|
|
47
|
+
result.project = init.project;
|
|
48
|
+
}
|
|
49
|
+
else if (Array.isArray(init.project)) {
|
|
50
|
+
result.project = this.random.pickOne(init.project);
|
|
51
|
+
}
|
|
52
|
+
else if (init.project) {
|
|
53
|
+
result.project = this.types.uuid();
|
|
54
|
+
}
|
|
55
|
+
if (typeof init.request === 'string') {
|
|
56
|
+
result.request = init.request;
|
|
57
|
+
}
|
|
58
|
+
else if (Array.isArray(init.request)) {
|
|
59
|
+
result.request = this.random.pickOne(init.request);
|
|
60
|
+
}
|
|
61
|
+
else if (init.request) {
|
|
62
|
+
result.request = this.types.uuid();
|
|
63
|
+
}
|
|
64
|
+
if (typeof init.app === 'string') {
|
|
65
|
+
result.app = init.app;
|
|
66
|
+
}
|
|
67
|
+
else if (Array.isArray(init.app)) {
|
|
68
|
+
result.app = this.random.pickOne(init.app);
|
|
69
|
+
}
|
|
70
|
+
else if (init.app) {
|
|
71
|
+
result.app = this.types.uuid();
|
|
72
|
+
}
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
75
|
+
httpHistoryList(size = 25, init = {}) {
|
|
76
|
+
const { usersSize, spacesSize, projectsSize, requestsSize, appsSize } = init;
|
|
77
|
+
const copy = { ...init };
|
|
78
|
+
if (usersSize && typeof init.user === 'undefined') {
|
|
79
|
+
const users = [];
|
|
80
|
+
for (let i = 0; i < usersSize; i++) {
|
|
81
|
+
users.push(this.types.uuid());
|
|
82
|
+
}
|
|
83
|
+
copy.user = users;
|
|
84
|
+
}
|
|
85
|
+
if (spacesSize && typeof init.space === 'undefined') {
|
|
86
|
+
const space = [];
|
|
87
|
+
for (let i = 0; i < spacesSize; i++) {
|
|
88
|
+
space.push(this.types.string(10));
|
|
89
|
+
}
|
|
90
|
+
copy.space = space;
|
|
91
|
+
}
|
|
92
|
+
if (projectsSize && typeof init.project === 'undefined') {
|
|
93
|
+
const project = [];
|
|
94
|
+
for (let i = 0; i < projectsSize; i++) {
|
|
95
|
+
project.push(this.types.uuid());
|
|
96
|
+
}
|
|
97
|
+
copy.project = project;
|
|
98
|
+
}
|
|
99
|
+
if (requestsSize && typeof init.request === 'undefined') {
|
|
100
|
+
const requests = [];
|
|
101
|
+
for (let i = 0; i < requestsSize; i++) {
|
|
102
|
+
requests.push(this.types.uuid());
|
|
103
|
+
}
|
|
104
|
+
copy.request = requests;
|
|
105
|
+
}
|
|
106
|
+
if (appsSize && typeof init.app === 'undefined') {
|
|
107
|
+
const apps = [];
|
|
108
|
+
for (let i = 0; i < appsSize; i++) {
|
|
109
|
+
apps.push(this.types.uuid());
|
|
110
|
+
}
|
|
111
|
+
copy.app = apps;
|
|
112
|
+
}
|
|
113
|
+
const result = [];
|
|
114
|
+
for (let i = 0; i < size; i++) {
|
|
115
|
+
result.push(this.httpHistory(copy));
|
|
116
|
+
}
|
|
117
|
+
return result;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=History.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"History.js","sourceRoot":"","sources":["../../../../src/mocking/lib/History.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAgB,MAAM,EAAE,MAAM,EAAoB,MAAM,qBAAqB,CAAC;AACtG,qEAAqE;AACrE,OAAO,EAAgB,IAAI,I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AAmB,EAAE,CAAC;QAClC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,EAAE;YAC7B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;SACrC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Internet, Types, DataMockInit, Person, Random } from '@pawel-up/data-mock';
|
|
2
|
+
import { IUser, ISpaceUser, AccessControlLevel } from '../../models/User.js';
|
|
3
|
+
export interface IUserInit {
|
|
4
|
+
noEmail?: boolean;
|
|
5
|
+
noPicture?: boolean;
|
|
6
|
+
noProvider?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface ISpaceUserInit extends IUserInit {
|
|
9
|
+
level?: AccessControlLevel;
|
|
10
|
+
levelPool?: AccessControlLevel[];
|
|
11
|
+
}
|
|
12
|
+
export declare class User {
|
|
13
|
+
person: Person;
|
|
14
|
+
types: Types;
|
|
15
|
+
internet: Internet;
|
|
16
|
+
random: Random;
|
|
17
|
+
constructor(init?: DataMockInit);
|
|
18
|
+
user(init?: IUserInit): IUser;
|
|
19
|
+
spaceUser(init?: ISpaceUserInit): ISpaceUser;
|
|
20
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Internet, Types, Person, Random } from '@pawel-up/data-mock';
|
|
2
|
+
const accessPool = ['read', 'comment', 'write', 'admin', 'owner'];
|
|
3
|
+
export class User {
|
|
4
|
+
person;
|
|
5
|
+
types;
|
|
6
|
+
internet;
|
|
7
|
+
random;
|
|
8
|
+
constructor(init = {}) {
|
|
9
|
+
this.person = new Person(init);
|
|
10
|
+
this.types = new Types(init.seed);
|
|
11
|
+
this.internet = new Internet(init);
|
|
12
|
+
this.random = new Random(init.seed);
|
|
13
|
+
}
|
|
14
|
+
user(init = {}) {
|
|
15
|
+
const result = {
|
|
16
|
+
key: this.types.uuid(),
|
|
17
|
+
name: this.person.name(),
|
|
18
|
+
};
|
|
19
|
+
if (!init.noEmail) {
|
|
20
|
+
result.email = [{
|
|
21
|
+
email: this.internet.email(),
|
|
22
|
+
verified: this.types.boolean(),
|
|
23
|
+
}];
|
|
24
|
+
}
|
|
25
|
+
if (!init.noPicture) {
|
|
26
|
+
result.picture = {
|
|
27
|
+
url: this.internet.avatar(),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
if (!init.noProvider) {
|
|
31
|
+
result.provider = {
|
|
32
|
+
refreshToken: this.types.uuid(),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
spaceUser(init = {}) {
|
|
38
|
+
const user = this.user(init);
|
|
39
|
+
if (init.level) {
|
|
40
|
+
user.level = init.level;
|
|
41
|
+
}
|
|
42
|
+
else if (Array.isArray(init.levelPool)) {
|
|
43
|
+
user.level = this.random.pickOne(init.levelPool);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
user.level = this.random.pickOne(accessPool);
|
|
47
|
+
}
|
|
48
|
+
return user;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=User.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"User.js","sourceRoot":"","sources":["../../../../src/mocking/lib/User.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAgB,MAAM,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAgBpF,MAAM,UAAU,GAAyB,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAExF,MAAM,OAAO,IAAI;IACf,MAAM,CAAS;IACf,KAAK,CAAQ;IACb,QAAQ,CAAW;IACnB,MAAM,CAAS;IAEf,YAAY,OAAmB,EAAE;QAC/B,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,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AC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SAClD;aAAM;YACL,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;SAC9C;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -98,4 +98,89 @@ export interface IListOptions {
|
|
|
98
98
|
* Only with the `query` property. Tells the system in which fields to search for the query term.
|
|
99
99
|
*/
|
|
100
100
|
queryField?: string[];
|
|
101
|
+
type?: string;
|
|
102
|
+
}
|
|
103
|
+
export interface ICursorOptions {
|
|
104
|
+
/**
|
|
105
|
+
* Page cursor to use with the query.
|
|
106
|
+
*/
|
|
107
|
+
cursor?: string;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Listing options for the HTTP history.
|
|
111
|
+
*/
|
|
112
|
+
export declare type HistoryListOptions = IHistorySpaceListOptions | IHistoryProjectListOptions | IHistoryRequestListOptions | IHistoryUserListOptions | IHistoryAppListOptions;
|
|
113
|
+
/**
|
|
114
|
+
* Query options to list history for a user space.
|
|
115
|
+
* The user has to have access to the user space to read / create / delete the history.
|
|
116
|
+
*/
|
|
117
|
+
export interface IHistorySpaceListOptions extends IListOptions {
|
|
118
|
+
type: 'space';
|
|
119
|
+
/**
|
|
120
|
+
* The id of the space.
|
|
121
|
+
*/
|
|
122
|
+
id: string;
|
|
123
|
+
/**
|
|
124
|
+
* Whether to limit the list of results to the history that belongs to the current user.
|
|
125
|
+
*/
|
|
126
|
+
user?: boolean;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Query options to list history for an HTTP project.
|
|
130
|
+
* The user has to have access to the parent user space to read / create / delete the history.
|
|
131
|
+
*/
|
|
132
|
+
export interface IHistoryProjectListOptions extends IListOptions {
|
|
133
|
+
type: 'project';
|
|
134
|
+
/**
|
|
135
|
+
* The id of the space containing the project.
|
|
136
|
+
* The access to the history records for the project is tested against the user space.
|
|
137
|
+
*/
|
|
138
|
+
space: string;
|
|
139
|
+
/**
|
|
140
|
+
* The id of the project.
|
|
141
|
+
*/
|
|
142
|
+
id: string;
|
|
143
|
+
/**
|
|
144
|
+
* Whether to limit the list of results to the history that belongs to the current user.
|
|
145
|
+
*/
|
|
146
|
+
user?: boolean;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Query options to list history for a request in a project.
|
|
150
|
+
* The user has to have access to the parent user space to read / create / delete the history.
|
|
151
|
+
*/
|
|
152
|
+
export interface IHistoryRequestListOptions extends IListOptions {
|
|
153
|
+
type: 'request';
|
|
154
|
+
/**
|
|
155
|
+
* The id of the space containing the project that contains the request.
|
|
156
|
+
* The access to the history records for the request is tested against the user space.
|
|
157
|
+
*/
|
|
158
|
+
space: string;
|
|
159
|
+
/**
|
|
160
|
+
* The id of the request.
|
|
161
|
+
*/
|
|
162
|
+
id: string;
|
|
163
|
+
/**
|
|
164
|
+
* Whether to limit the list of results to the history that belongs to the current user.
|
|
165
|
+
*/
|
|
166
|
+
user?: boolean;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Query options to list history for a user. This targets lists all user history. If you need to
|
|
170
|
+
* filter the user history use other interfaces with the `user` flag set.
|
|
171
|
+
*/
|
|
172
|
+
export interface IHistoryUserListOptions extends IListOptions {
|
|
173
|
+
type: 'user';
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Query options to list history for a history object that was created by an application that has no concept
|
|
177
|
+
* of user spaces. In this case the queries are always made against the current user.
|
|
178
|
+
*/
|
|
179
|
+
export interface IHistoryAppListOptions extends IListOptions {
|
|
180
|
+
type: 'app';
|
|
181
|
+
/**
|
|
182
|
+
* The id of the application.
|
|
183
|
+
* These queries are always made for a user.
|
|
184
|
+
*/
|
|
185
|
+
id: string;
|
|
101
186
|
}
|
|
@@ -5,19 +5,29 @@ export declare const midnightSymbol: unique symbol;
|
|
|
5
5
|
export interface IHttpHistory {
|
|
6
6
|
kind: typeof Kind;
|
|
7
7
|
/**
|
|
8
|
-
* The
|
|
9
|
-
*
|
|
8
|
+
* The data store key. Only present when the object was already inserted into the data store.
|
|
9
|
+
* In majority of cases this value is set. It is not set when generating the history object before sending it to the store.
|
|
10
|
+
*
|
|
11
|
+
* Note for data store implementations. This must be a URL-safe value so the id should be encoded if needed.
|
|
10
12
|
*/
|
|
11
|
-
|
|
13
|
+
key?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Optional user space id. Must be set when the originating request belongs to a user space.
|
|
16
|
+
*/
|
|
17
|
+
space?: string;
|
|
12
18
|
/**
|
|
13
|
-
*
|
|
14
|
-
* Optional. Also note, the project may not exist anymore in the store or the request has been removed from the project.
|
|
19
|
+
* Optional project id. Must be set when the originating request belongs to a user space.
|
|
15
20
|
*/
|
|
16
21
|
project?: string;
|
|
17
22
|
/**
|
|
18
|
-
*
|
|
23
|
+
* Optional application id. Must be set when the application that created this record does not use the concept of a user space.
|
|
24
|
+
*/
|
|
25
|
+
app?: string;
|
|
26
|
+
/**
|
|
27
|
+
* The user id that made that request.
|
|
28
|
+
* Note, the default API Client's store automatically adds the user information to the record overriding any pre-set user id.
|
|
19
29
|
*/
|
|
20
|
-
user
|
|
30
|
+
user: string;
|
|
21
31
|
/**
|
|
22
32
|
* The optional request id in the project that generated this log.
|
|
23
33
|
*/
|
|
@@ -38,9 +48,6 @@ export interface IHttpHistory {
|
|
|
38
48
|
/**
|
|
39
49
|
* An HTTP history is an object containing an information of a request and response
|
|
40
50
|
* made with the application.
|
|
41
|
-
* It consist of the RequestLog and optional information about the application that made that request and the HTTP project
|
|
42
|
-
* the request belongs to as well as the id of the request.
|
|
43
|
-
* However, this object may not contain these information for general purpose of the history store.
|
|
44
51
|
*
|
|
45
52
|
* Note, history object are not mutable. Can only be created or deleted.
|
|
46
53
|
*/
|
|
@@ -49,19 +56,29 @@ export declare class HttpHistory {
|
|
|
49
56
|
[midnightSymbol]: number;
|
|
50
57
|
kind: string;
|
|
51
58
|
/**
|
|
52
|
-
* The
|
|
53
|
-
*
|
|
59
|
+
* The data store key. Only present when the object was already inserted into the data store.
|
|
60
|
+
* In majority of cases this value is set. It is not set when generating the history object before sending it to the store.
|
|
61
|
+
*
|
|
62
|
+
* Note for data store implementations. This must be a URL-safe value so the id should be encoded if needed.
|
|
54
63
|
*/
|
|
55
|
-
|
|
64
|
+
key?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Optional user space id. Must be set when the originating request belongs to a user space.
|
|
67
|
+
*/
|
|
68
|
+
space?: string;
|
|
56
69
|
/**
|
|
57
|
-
*
|
|
58
|
-
* Optional. Also note, the project may not exist anymore in the store or the request has been removed from the project.
|
|
70
|
+
* Optional project id. Must be set when the originating request belongs to a user space.
|
|
59
71
|
*/
|
|
60
72
|
project?: string;
|
|
61
73
|
/**
|
|
62
|
-
*
|
|
74
|
+
* Optional application id. Must be set when the application that created this record does not use the concept of a user space.
|
|
75
|
+
*/
|
|
76
|
+
app?: string;
|
|
77
|
+
/**
|
|
78
|
+
* The user id that made that request.
|
|
79
|
+
* Note, the default API Client's store automatically adds the user information to the record overriding any pre-set user id.
|
|
63
80
|
*/
|
|
64
|
-
user
|
|
81
|
+
user: string;
|
|
65
82
|
/**
|
|
66
83
|
* The optional request id in the project that generated this log.
|
|
67
84
|
*/
|
|
@@ -5,9 +5,6 @@ export const midnightSymbol = Symbol('midnight');
|
|
|
5
5
|
/**
|
|
6
6
|
* An HTTP history is an object containing an information of a request and response
|
|
7
7
|
* made with the application.
|
|
8
|
-
* It consist of the RequestLog and optional information about the application that made that request and the HTTP project
|
|
9
|
-
* the request belongs to as well as the id of the request.
|
|
10
|
-
* However, this object may not contain these information for general purpose of the history store.
|
|
11
8
|
*
|
|
12
9
|
* Note, history object are not mutable. Can only be created or deleted.
|
|
13
10
|
*/
|
|
@@ -16,19 +13,29 @@ export class HttpHistory {
|
|
|
16
13
|
[midnightSymbol];
|
|
17
14
|
kind = Kind;
|
|
18
15
|
/**
|
|
19
|
-
* The
|
|
20
|
-
*
|
|
16
|
+
* The data store key. Only present when the object was already inserted into the data store.
|
|
17
|
+
* In majority of cases this value is set. It is not set when generating the history object before sending it to the store.
|
|
18
|
+
*
|
|
19
|
+
* Note for data store implementations. This must be a URL-safe value so the id should be encoded if needed.
|
|
21
20
|
*/
|
|
22
|
-
|
|
21
|
+
key;
|
|
22
|
+
/**
|
|
23
|
+
* Optional user space id. Must be set when the originating request belongs to a user space.
|
|
24
|
+
*/
|
|
25
|
+
space;
|
|
23
26
|
/**
|
|
24
|
-
*
|
|
25
|
-
* Optional. Also note, the project may not exist anymore in the store or the request has been removed from the project.
|
|
27
|
+
* Optional project id. Must be set when the originating request belongs to a user space.
|
|
26
28
|
*/
|
|
27
29
|
project;
|
|
28
30
|
/**
|
|
29
|
-
*
|
|
31
|
+
* Optional application id. Must be set when the application that created this record does not use the concept of a user space.
|
|
32
|
+
*/
|
|
33
|
+
app;
|
|
34
|
+
/**
|
|
35
|
+
* The user id that made that request.
|
|
36
|
+
* Note, the default API Client's store automatically adds the user information to the record overriding any pre-set user id.
|
|
30
37
|
*/
|
|
31
|
-
user;
|
|
38
|
+
user = '';
|
|
32
39
|
/**
|
|
33
40
|
* The optional request id in the project that generated this log.
|
|
34
41
|
*/
|
|
@@ -90,6 +97,7 @@ export class HttpHistory {
|
|
|
90
97
|
init = {
|
|
91
98
|
kind: Kind,
|
|
92
99
|
created: now,
|
|
100
|
+
user: '',
|
|
93
101
|
log: {
|
|
94
102
|
kind: RequestLogKind,
|
|
95
103
|
},
|
|
@@ -98,11 +106,14 @@ export class HttpHistory {
|
|
|
98
106
|
this.new(init);
|
|
99
107
|
}
|
|
100
108
|
new(init) {
|
|
101
|
-
const { log, created = Date.now(), midnight,
|
|
109
|
+
const { log, created = Date.now(), midnight, space, project, request, user, key, app } = init;
|
|
102
110
|
this.log = new RequestLog(log);
|
|
103
111
|
this.created = created;
|
|
104
|
-
if (
|
|
105
|
-
this.
|
|
112
|
+
if (key) {
|
|
113
|
+
this.key = key;
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
this.key = undefined;
|
|
106
117
|
}
|
|
107
118
|
if (app) {
|
|
108
119
|
this.app = app;
|
|
@@ -110,6 +121,15 @@ export class HttpHistory {
|
|
|
110
121
|
else {
|
|
111
122
|
this.app = undefined;
|
|
112
123
|
}
|
|
124
|
+
if (midnight) {
|
|
125
|
+
this.midnight = midnight;
|
|
126
|
+
}
|
|
127
|
+
if (space) {
|
|
128
|
+
this.space = space;
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
this.space = undefined;
|
|
132
|
+
}
|
|
113
133
|
if (project) {
|
|
114
134
|
this.project = project;
|
|
115
135
|
}
|
|
@@ -126,7 +146,7 @@ export class HttpHistory {
|
|
|
126
146
|
this.user = user;
|
|
127
147
|
}
|
|
128
148
|
else {
|
|
129
|
-
this.user =
|
|
149
|
+
this.user = '';
|
|
130
150
|
}
|
|
131
151
|
}
|
|
132
152
|
toJSON() {
|
|
@@ -135,9 +155,13 @@ export class HttpHistory {
|
|
|
135
155
|
created: this.created,
|
|
136
156
|
midnight: this.midnight,
|
|
137
157
|
log: this.log.toJSON(),
|
|
158
|
+
user: this.user,
|
|
138
159
|
};
|
|
139
|
-
if (this.
|
|
140
|
-
result.
|
|
160
|
+
if (this.key) {
|
|
161
|
+
result.key = this.key;
|
|
162
|
+
}
|
|
163
|
+
if (this.space) {
|
|
164
|
+
result.space = this.space;
|
|
141
165
|
}
|
|
142
166
|
if (this.project) {
|
|
143
167
|
result.project = this.project;
|
|
@@ -145,8 +169,8 @@ export class HttpHistory {
|
|
|
145
169
|
if (this.request) {
|
|
146
170
|
result.request = this.request;
|
|
147
171
|
}
|
|
148
|
-
if (this.
|
|
149
|
-
result.
|
|
172
|
+
if (this.app) {
|
|
173
|
+
result.app = this.app;
|
|
150
174
|
}
|
|
151
175
|
return result;
|
|
152
176
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpHistory.js","sourceRoot":"","sources":["../../../src/models/HttpHistory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,UAAU,EAAE,IAAI,IAAI,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAElF,MAAM,CAAC,MAAM,IAAI,GAAG,iBAAiB,CAAC;AACtC,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;AAC/C,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"HttpHistory.js","sourceRoot":"","sources":["../../../src/models/HttpHistory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,UAAU,EAAE,IAAI,IAAI,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAElF,MAAM,CAAC,MAAM,IAAI,GAAG,iBAAiB,CAAC;AACtC,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;AAC/C,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;AA8CjD;;;;;GAKG;AACH,MAAM,OAAO,WAAW;IACtB,CAAC,aAAa,CAAC,CAAS;IACxB,CAAC,cAAc,CAAC,CAAS;IACzB,IAAI,GAAG,IAAI,CAAC;IACZ;;;;;OAKG;IACH,GAAG,CAAU;IACb;;OAEG;IACH,KAAK,CAAU;IACf;;OAEG;IACH,OAAO,CAAU;IACjB;;OAEG;IACH,GAAG,CAAU;IACb;;;OAGG;IACH,IAAI,GAAG,EAAE,CAAC;IACV;;OAEG;IACH,OAAO,CAAU;IACjB;;OAEG;IACH,GAAG,GAAe,IAAI,UAAU,EAAE,CAAC;IAEnC;;OAEG;IACH,IAAI,OAAO,CAAC,KAAyB;QACnC,IAAI,CAAC,KAAK,EAAE;YACV,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;SAClC;aAAM;YACL,IAAI,CAAC,aAAa,CAAC,GAAG,KAAK,C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ACV,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE;YACtB,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC;QACF,IAAI,IAAI,CAAC,GAAG,EAAE;YACZ,MAAM,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;SACvB;QACD,IAAI,IAAI,CAAC,KAAK,EAAE;YACd,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;SAC3B;QACD,IAAI,IAAI,CAAC,OAAO,EAAE;YAChB,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;SAC/B;QACD,IAAI,IAAI,CAAC,OAAO,EAAE;YAChB,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;SAC/B;QACD,IAAI,IAAI,CAAC,GAAG,EAAE;YACZ,MAAM,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;SACvB;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,eAAe;QACb,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACjC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACvB,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC;IACrB,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import { DataMock, DataMockInit } from '@pawel-up/data-mock';
|
|
2
2
|
import { Request } from './lib/Request.js';
|
|
3
3
|
import { Response } from './lib/Response.js';
|
|
4
|
+
import { User } from './lib/User.js';
|
|
5
|
+
import { History } from './lib/History.js';
|
|
4
6
|
|
|
5
7
|
export { IRequestLogInit } from './lib/Request.js';
|
|
6
8
|
export { IArcResponseInit } from './lib/Response.js';
|
|
9
|
+
export { ISpaceUserInit, IUserInit } from './lib/User.js';
|
|
10
|
+
export { IHttpHistoryInit, IHttpHistoryListInit } from './lib/History.js';
|
|
7
11
|
|
|
8
12
|
export class ProjectMock extends DataMock {
|
|
9
13
|
projectRequest: Request;
|
|
10
14
|
response: Response;
|
|
15
|
+
user: User;
|
|
16
|
+
history: History;
|
|
11
17
|
|
|
12
18
|
/**
|
|
13
19
|
* @param init The library init options.
|
|
@@ -16,5 +22,7 @@ export class ProjectMock extends DataMock {
|
|
|
16
22
|
super(init);
|
|
17
23
|
this.projectRequest = new Request(init);
|
|
18
24
|
this.response = new Response(init);
|
|
25
|
+
this.user = new User(init);
|
|
26
|
+
this.history = new History(init);
|
|
19
27
|
}
|
|
20
28
|
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { Internet, Types, DataMockInit, Person, Random, TypeDateTimeInit } from '@pawel-up/data-mock';
|
|
2
|
+
// import { randomValue } from '@pawel-up/data-mock/src/lib/Http.js';
|
|
3
|
+
import { IHttpHistory, Kind as HttpHistoryKind } from '../../models/HttpHistory.js';
|
|
4
|
+
import { Request, IRequestLogInit } from './Request.js';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export interface IHttpHistoryInit {
|
|
8
|
+
/**
|
|
9
|
+
* Either space id, list of spaces to pick one or whether to generate a space.
|
|
10
|
+
*/
|
|
11
|
+
space?: boolean | string | string[];
|
|
12
|
+
/**
|
|
13
|
+
* User is always generated per store requirements.
|
|
14
|
+
*/
|
|
15
|
+
user?: string | string[];
|
|
16
|
+
/**
|
|
17
|
+
* Either project id, list of projects to pick one or whether to generate a project.
|
|
18
|
+
*/
|
|
19
|
+
project?: boolean | string | string[];
|
|
20
|
+
/**
|
|
21
|
+
* Either request id, list of requests to pick one or whether to generate a request.
|
|
22
|
+
*/
|
|
23
|
+
request?: boolean | string | string[];
|
|
24
|
+
/**
|
|
25
|
+
* Either app id, list of apps to pick one or whether to generate an app.
|
|
26
|
+
*/
|
|
27
|
+
app?: boolean | string | string[];
|
|
28
|
+
/**
|
|
29
|
+
* The log init options
|
|
30
|
+
*/
|
|
31
|
+
log?: IRequestLogInit;
|
|
32
|
+
/**
|
|
33
|
+
* The created time init options.
|
|
34
|
+
*/
|
|
35
|
+
created?: TypeDateTimeInit;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface IHttpHistoryListInit extends IHttpHistoryInit {
|
|
39
|
+
/**
|
|
40
|
+
* When set it generates as many user IDs.
|
|
41
|
+
* Ignored when the `user` is set.
|
|
42
|
+
*/
|
|
43
|
+
usersSize?: number;
|
|
44
|
+
/**
|
|
45
|
+
* When set it generates as many space ids.
|
|
46
|
+
* Ignored when the `space` is set.
|
|
47
|
+
*/
|
|
48
|
+
spacesSize?: number;
|
|
49
|
+
/**
|
|
50
|
+
* When set it generates as many project ids.
|
|
51
|
+
* Ignored when the `project` is set.
|
|
52
|
+
*/
|
|
53
|
+
projectsSize?: number;
|
|
54
|
+
/**
|
|
55
|
+
* When set it generates as many request ids.
|
|
56
|
+
* Ignored when the `request` is set.
|
|
57
|
+
*/
|
|
58
|
+
requestsSize?: number;
|
|
59
|
+
/**
|
|
60
|
+
* When set it generates as many app ids.
|
|
61
|
+
* Ignored when the `app` is set.
|
|
62
|
+
*/
|
|
63
|
+
appsSize?: number;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export class History {
|
|
67
|
+
person: Person;
|
|
68
|
+
types: Types;
|
|
69
|
+
internet: Internet;
|
|
70
|
+
random: Random;
|
|
71
|
+
request: Request;
|
|
72
|
+
|
|
73
|
+
constructor(init: DataMockInit={}) {
|
|
74
|
+
this.person = new Person(init);
|
|
75
|
+
this.types = new Types(init.seed);
|
|
76
|
+
this.internet = new Internet(init);
|
|
77
|
+
this.random = new Random(init.seed);
|
|
78
|
+
this.request = new Request(init);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
httpHistory(init: IHttpHistoryInit = {}): IHttpHistory {
|
|
82
|
+
const date = this.types.datetime(init.created);
|
|
83
|
+
const result: IHttpHistory = {
|
|
84
|
+
kind: HttpHistoryKind,
|
|
85
|
+
created: date.getTime(),
|
|
86
|
+
log: this.request.log(init.log),
|
|
87
|
+
user: '',
|
|
88
|
+
}
|
|
89
|
+
date.setHours(0, 0, 0, 0);
|
|
90
|
+
result.midnight = date.getTime();
|
|
91
|
+
|
|
92
|
+
if (typeof init.space === 'string') {
|
|
93
|
+
result.space = init.space;
|
|
94
|
+
} else if (Array.isArray(init.space)) {
|
|
95
|
+
result.space = this.random.pickOne(init.space);
|
|
96
|
+
} else if (init.space) {
|
|
97
|
+
result.space = this.types.string(10);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (typeof init.user === 'string') {
|
|
101
|
+
result.user = init.user;
|
|
102
|
+
} else if (Array.isArray(init.user)) {
|
|
103
|
+
result.user = this.random.pickOne(init.user);
|
|
104
|
+
} else {
|
|
105
|
+
result.user = this.types.uuid();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (typeof init.project === 'string') {
|
|
109
|
+
result.project = init.project;
|
|
110
|
+
} else if (Array.isArray(init.project)) {
|
|
111
|
+
result.project = this.random.pickOne(init.project);
|
|
112
|
+
} else if (init.project) {
|
|
113
|
+
result.project = this.types.uuid();
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (typeof init.request === 'string') {
|
|
117
|
+
result.request = init.request;
|
|
118
|
+
} else if (Array.isArray(init.request)) {
|
|
119
|
+
result.request = this.random.pickOne(init.request);
|
|
120
|
+
} else if (init.request) {
|
|
121
|
+
result.request = this.types.uuid();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (typeof init.app === 'string') {
|
|
125
|
+
result.app = init.app;
|
|
126
|
+
} else if (Array.isArray(init.app)) {
|
|
127
|
+
result.app = this.random.pickOne(init.app);
|
|
128
|
+
} else if (init.app) {
|
|
129
|
+
result.app = this.types.uuid();
|
|
130
|
+
}
|
|
131
|
+
return result;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
httpHistoryList(size=25, init: IHttpHistoryListInit = {}): IHttpHistory[] {
|
|
135
|
+
const { usersSize, spacesSize, projectsSize, requestsSize, appsSize } = init;
|
|
136
|
+
const copy = { ...init };
|
|
137
|
+
if (usersSize && typeof init.user === 'undefined') {
|
|
138
|
+
const users: string[] = [];
|
|
139
|
+
for (let i = 0; i < usersSize; i++) {
|
|
140
|
+
users.push(this.types.uuid());
|
|
141
|
+
}
|
|
142
|
+
copy.user = users;
|
|
143
|
+
}
|
|
144
|
+
if (spacesSize && typeof init.space === 'undefined') {
|
|
145
|
+
const space: string[] = [];
|
|
146
|
+
for (let i = 0; i < spacesSize; i++) {
|
|
147
|
+
space.push(this.types.string(10));
|
|
148
|
+
}
|
|
149
|
+
copy.space = space;
|
|
150
|
+
}
|
|
151
|
+
if (projectsSize && typeof init.project === 'undefined') {
|
|
152
|
+
const project: string[] = [];
|
|
153
|
+
for (let i = 0; i < projectsSize; i++) {
|
|
154
|
+
project.push(this.types.uuid());
|
|
155
|
+
}
|
|
156
|
+
copy.project = project;
|
|
157
|
+
}
|
|
158
|
+
if (requestsSize && typeof init.request === 'undefined') {
|
|
159
|
+
const requests: string[] = [];
|
|
160
|
+
for (let i = 0; i < requestsSize; i++) {
|
|
161
|
+
requests.push(this.types.uuid());
|
|
162
|
+
}
|
|
163
|
+
copy.request = requests;
|
|
164
|
+
}
|
|
165
|
+
if (appsSize && typeof init.app === 'undefined') {
|
|
166
|
+
const apps: string[] = [];
|
|
167
|
+
for (let i = 0; i < appsSize; i++) {
|
|
168
|
+
apps.push(this.types.uuid());
|
|
169
|
+
}
|
|
170
|
+
copy.app = apps;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const result: IHttpHistory[] = [];
|
|
174
|
+
for (let i = 0; i < size; i++) {
|
|
175
|
+
result.push(this.httpHistory(copy));
|
|
176
|
+
}
|
|
177
|
+
return result;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Internet, Types, DataMockInit, Person, Random } from '@pawel-up/data-mock';
|
|
2
|
+
// import { randomValue } from '@pawel-up/data-mock/src/lib/Http.js';
|
|
3
|
+
import { IUser, ISpaceUser, AccessControlLevel } from '../../models/User.js';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export interface IUserInit {
|
|
7
|
+
noEmail?: boolean;
|
|
8
|
+
noPicture?: boolean;
|
|
9
|
+
noProvider?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ISpaceUserInit extends IUserInit {
|
|
13
|
+
level?: AccessControlLevel;
|
|
14
|
+
levelPool?: AccessControlLevel[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const accessPool: AccessControlLevel[] = ['read', 'comment', 'write', 'admin', 'owner'];
|
|
18
|
+
|
|
19
|
+
export class User {
|
|
20
|
+
person: Person;
|
|
21
|
+
types: Types;
|
|
22
|
+
internet: Internet;
|
|
23
|
+
random: Random;
|
|
24
|
+
|
|
25
|
+
constructor(init: DataMockInit={}) {
|
|
26
|
+
this.person = new Person(init);
|
|
27
|
+
this.types = new Types(init.seed);
|
|
28
|
+
this.internet = new Internet(init);
|
|
29
|
+
this.random = new Random(init.seed);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
user(init: IUserInit = {}): IUser {
|
|
33
|
+
const result: IUser = {
|
|
34
|
+
key: this.types.uuid(),
|
|
35
|
+
name: this.person.name(),
|
|
36
|
+
}
|
|
37
|
+
if (!init.noEmail) {
|
|
38
|
+
result.email = [{
|
|
39
|
+
email: this.internet.email(),
|
|
40
|
+
verified: this.types.boolean(),
|
|
41
|
+
}];
|
|
42
|
+
}
|
|
43
|
+
if (!init.noPicture) {
|
|
44
|
+
result.picture = {
|
|
45
|
+
url: this.internet.avatar(),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
if (!init.noProvider) {
|
|
49
|
+
result.provider = {
|
|
50
|
+
refreshToken: this.types.uuid(),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
spaceUser(init: ISpaceUserInit = {}): ISpaceUser {
|
|
57
|
+
const user = this.user(init) as ISpaceUser;
|
|
58
|
+
if (init.level) {
|
|
59
|
+
user.level = init.level;
|
|
60
|
+
} else if (Array.isArray(init.levelPool)) {
|
|
61
|
+
user.level = this.random.pickOne(init.levelPool);
|
|
62
|
+
} else {
|
|
63
|
+
user.level = this.random.pickOne(accessPool);
|
|
64
|
+
}
|
|
65
|
+
return user;
|
|
66
|
+
}
|
|
67
|
+
}
|
package/src/models/Backend.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable import/export */
|
|
1
2
|
export type BackendMode = 'single-user' | 'multi-user';
|
|
2
3
|
|
|
3
4
|
export interface IBackendInfo {
|
|
@@ -104,4 +105,96 @@ export interface IListOptions {
|
|
|
104
105
|
* Only with the `query` property. Tells the system in which fields to search for the query term.
|
|
105
106
|
*/
|
|
106
107
|
queryField?: string[];
|
|
108
|
+
type?: string;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface ICursorOptions {
|
|
112
|
+
/**
|
|
113
|
+
* Page cursor to use with the query.
|
|
114
|
+
*/
|
|
115
|
+
cursor?: string;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Listing options for the HTTP history.
|
|
120
|
+
*/
|
|
121
|
+
export type HistoryListOptions = IHistorySpaceListOptions | IHistoryProjectListOptions | IHistoryRequestListOptions | IHistoryUserListOptions | IHistoryAppListOptions;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Query options to list history for a user space.
|
|
125
|
+
* The user has to have access to the user space to read / create / delete the history.
|
|
126
|
+
*/
|
|
127
|
+
export interface IHistorySpaceListOptions extends IListOptions {
|
|
128
|
+
type: 'space';
|
|
129
|
+
/**
|
|
130
|
+
* The id of the space.
|
|
131
|
+
*/
|
|
132
|
+
id: string;
|
|
133
|
+
/**
|
|
134
|
+
* Whether to limit the list of results to the history that belongs to the current user.
|
|
135
|
+
*/
|
|
136
|
+
user?: boolean;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Query options to list history for an HTTP project.
|
|
141
|
+
* The user has to have access to the parent user space to read / create / delete the history.
|
|
142
|
+
*/
|
|
143
|
+
export interface IHistoryProjectListOptions extends IListOptions {
|
|
144
|
+
type: 'project';
|
|
145
|
+
/**
|
|
146
|
+
* The id of the space containing the project.
|
|
147
|
+
* The access to the history records for the project is tested against the user space.
|
|
148
|
+
*/
|
|
149
|
+
space: string;
|
|
150
|
+
/**
|
|
151
|
+
* The id of the project.
|
|
152
|
+
*/
|
|
153
|
+
id: string;
|
|
154
|
+
/**
|
|
155
|
+
* Whether to limit the list of results to the history that belongs to the current user.
|
|
156
|
+
*/
|
|
157
|
+
user?: boolean;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Query options to list history for a request in a project.
|
|
162
|
+
* The user has to have access to the parent user space to read / create / delete the history.
|
|
163
|
+
*/
|
|
164
|
+
export interface IHistoryRequestListOptions extends IListOptions {
|
|
165
|
+
type: 'request';
|
|
166
|
+
/**
|
|
167
|
+
* The id of the space containing the project that contains the request.
|
|
168
|
+
* The access to the history records for the request is tested against the user space.
|
|
169
|
+
*/
|
|
170
|
+
space: string;
|
|
171
|
+
/**
|
|
172
|
+
* The id of the request.
|
|
173
|
+
*/
|
|
174
|
+
id: string;
|
|
175
|
+
/**
|
|
176
|
+
* Whether to limit the list of results to the history that belongs to the current user.
|
|
177
|
+
*/
|
|
178
|
+
user?: boolean;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Query options to list history for a user. This targets lists all user history. If you need to
|
|
183
|
+
* filter the user history use other interfaces with the `user` flag set.
|
|
184
|
+
*/
|
|
185
|
+
export interface IHistoryUserListOptions extends IListOptions {
|
|
186
|
+
type: 'user';
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Query options to list history for a history object that was created by an application that has no concept
|
|
191
|
+
* of user spaces. In this case the queries are always made against the current user.
|
|
192
|
+
*/
|
|
193
|
+
export interface IHistoryAppListOptions extends IListOptions {
|
|
194
|
+
type: 'app';
|
|
195
|
+
/**
|
|
196
|
+
* The id of the application.
|
|
197
|
+
* These queries are always made for a user.
|
|
198
|
+
*/
|
|
199
|
+
id: string;
|
|
107
200
|
}
|
|
@@ -7,19 +7,29 @@ export const midnightSymbol = Symbol('midnight');
|
|
|
7
7
|
export interface IHttpHistory {
|
|
8
8
|
kind: typeof Kind;
|
|
9
9
|
/**
|
|
10
|
-
* The
|
|
11
|
-
*
|
|
10
|
+
* The data store key. Only present when the object was already inserted into the data store.
|
|
11
|
+
* In majority of cases this value is set. It is not set when generating the history object before sending it to the store.
|
|
12
|
+
*
|
|
13
|
+
* Note for data store implementations. This must be a URL-safe value so the id should be encoded if needed.
|
|
12
14
|
*/
|
|
13
|
-
|
|
15
|
+
key?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Optional user space id. Must be set when the originating request belongs to a user space.
|
|
18
|
+
*/
|
|
19
|
+
space?: string;
|
|
14
20
|
/**
|
|
15
|
-
*
|
|
16
|
-
* Optional. Also note, the project may not exist anymore in the store or the request has been removed from the project.
|
|
21
|
+
* Optional project id. Must be set when the originating request belongs to a user space.
|
|
17
22
|
*/
|
|
18
23
|
project?: string;
|
|
19
24
|
/**
|
|
20
|
-
*
|
|
25
|
+
* Optional application id. Must be set when the application that created this record does not use the concept of a user space.
|
|
21
26
|
*/
|
|
22
|
-
|
|
27
|
+
app?: string;
|
|
28
|
+
/**
|
|
29
|
+
* The user id that made that request.
|
|
30
|
+
* Note, the default API Client's store automatically adds the user information to the record overriding any pre-set user id.
|
|
31
|
+
*/
|
|
32
|
+
user: string;
|
|
23
33
|
/**
|
|
24
34
|
* The optional request id in the project that generated this log.
|
|
25
35
|
*/
|
|
@@ -41,9 +51,6 @@ export interface IHttpHistory {
|
|
|
41
51
|
/**
|
|
42
52
|
* An HTTP history is an object containing an information of a request and response
|
|
43
53
|
* made with the application.
|
|
44
|
-
* It consist of the RequestLog and optional information about the application that made that request and the HTTP project
|
|
45
|
-
* the request belongs to as well as the id of the request.
|
|
46
|
-
* However, this object may not contain these information for general purpose of the history store.
|
|
47
54
|
*
|
|
48
55
|
* Note, history object are not mutable. Can only be created or deleted.
|
|
49
56
|
*/
|
|
@@ -52,19 +59,29 @@ export class HttpHistory {
|
|
|
52
59
|
[midnightSymbol]: number;
|
|
53
60
|
kind = Kind;
|
|
54
61
|
/**
|
|
55
|
-
* The
|
|
56
|
-
*
|
|
62
|
+
* The data store key. Only present when the object was already inserted into the data store.
|
|
63
|
+
* In majority of cases this value is set. It is not set when generating the history object before sending it to the store.
|
|
64
|
+
*
|
|
65
|
+
* Note for data store implementations. This must be a URL-safe value so the id should be encoded if needed.
|
|
57
66
|
*/
|
|
58
|
-
|
|
67
|
+
key?: string;
|
|
59
68
|
/**
|
|
60
|
-
*
|
|
61
|
-
|
|
69
|
+
* Optional user space id. Must be set when the originating request belongs to a user space.
|
|
70
|
+
*/
|
|
71
|
+
space?: string;
|
|
72
|
+
/**
|
|
73
|
+
* Optional project id. Must be set when the originating request belongs to a user space.
|
|
62
74
|
*/
|
|
63
75
|
project?: string;
|
|
64
76
|
/**
|
|
65
|
-
*
|
|
77
|
+
* Optional application id. Must be set when the application that created this record does not use the concept of a user space.
|
|
78
|
+
*/
|
|
79
|
+
app?: string;
|
|
80
|
+
/**
|
|
81
|
+
* The user id that made that request.
|
|
82
|
+
* Note, the default API Client's store automatically adds the user information to the record overriding any pre-set user id.
|
|
66
83
|
*/
|
|
67
|
-
user
|
|
84
|
+
user = '';
|
|
68
85
|
/**
|
|
69
86
|
* The optional request id in the project that generated this log.
|
|
70
87
|
*/
|
|
@@ -84,7 +101,7 @@ export class HttpHistory {
|
|
|
84
101
|
this[createdSymbol] = value;
|
|
85
102
|
}
|
|
86
103
|
const d = new Date(this[createdSymbol]);
|
|
87
|
-
d.setHours(0, 0, 0, 0)
|
|
104
|
+
d.setHours(0, 0, 0, 0);
|
|
88
105
|
this[midnightSymbol] = d.getTime();
|
|
89
106
|
}
|
|
90
107
|
|
|
@@ -127,6 +144,7 @@ export class HttpHistory {
|
|
|
127
144
|
init = {
|
|
128
145
|
kind: Kind,
|
|
129
146
|
created: now,
|
|
147
|
+
user: '',
|
|
130
148
|
log: {
|
|
131
149
|
kind: RequestLogKind,
|
|
132
150
|
},
|
|
@@ -136,17 +154,27 @@ export class HttpHistory {
|
|
|
136
154
|
}
|
|
137
155
|
|
|
138
156
|
new(init: IHttpHistory): void {
|
|
139
|
-
const { log, created = Date.now(), midnight,
|
|
157
|
+
const { log, created = Date.now(), midnight, space, project, request, user, key, app } = init;
|
|
140
158
|
this.log = new RequestLog(log);
|
|
141
159
|
this.created = created;
|
|
142
|
-
if (
|
|
143
|
-
this.
|
|
160
|
+
if (key) {
|
|
161
|
+
this.key = key;
|
|
162
|
+
} else {
|
|
163
|
+
this.key = undefined;
|
|
144
164
|
}
|
|
145
165
|
if (app) {
|
|
146
166
|
this.app = app;
|
|
147
167
|
} else {
|
|
148
168
|
this.app = undefined;
|
|
149
169
|
}
|
|
170
|
+
if (midnight) {
|
|
171
|
+
this.midnight = midnight;
|
|
172
|
+
}
|
|
173
|
+
if (space) {
|
|
174
|
+
this.space = space;
|
|
175
|
+
} else {
|
|
176
|
+
this.space = undefined;
|
|
177
|
+
}
|
|
150
178
|
if (project) {
|
|
151
179
|
this.project = project;
|
|
152
180
|
} else {
|
|
@@ -160,7 +188,7 @@ export class HttpHistory {
|
|
|
160
188
|
if (user) {
|
|
161
189
|
this.user = user;
|
|
162
190
|
} else {
|
|
163
|
-
this.user =
|
|
191
|
+
this.user = '';
|
|
164
192
|
}
|
|
165
193
|
}
|
|
166
194
|
|
|
@@ -170,9 +198,13 @@ export class HttpHistory {
|
|
|
170
198
|
created: this.created,
|
|
171
199
|
midnight: this.midnight,
|
|
172
200
|
log: this.log.toJSON(),
|
|
201
|
+
user: this.user,
|
|
173
202
|
};
|
|
174
|
-
if (this.
|
|
175
|
-
result.
|
|
203
|
+
if (this.key) {
|
|
204
|
+
result.key = this.key;
|
|
205
|
+
}
|
|
206
|
+
if (this.space) {
|
|
207
|
+
result.space = this.space;
|
|
176
208
|
}
|
|
177
209
|
if (this.project) {
|
|
178
210
|
result.project = this.project;
|
|
@@ -180,8 +212,8 @@ export class HttpHistory {
|
|
|
180
212
|
if (this.request) {
|
|
181
213
|
result.request = this.request;
|
|
182
214
|
}
|
|
183
|
-
if (this.
|
|
184
|
-
result.
|
|
215
|
+
if (this.app) {
|
|
216
|
+
result.app = this.app;
|
|
185
217
|
}
|
|
186
218
|
return result;
|
|
187
219
|
}
|