@api-client/core 0.7.6 → 0.7.9
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/browser.js.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.js.map +1 -1
- package/build/src/cookies/CookieParser.d.ts +11 -0
- package/build/src/cookies/CookieParser.js +39 -26
- package/build/src/cookies/CookieParser.js.map +1 -1
- package/build/src/events/BaseEvents.d.ts +4 -0
- package/build/src/events/BaseEvents.js.map +1 -1
- package/build/src/events/EventTypes.d.ts +3 -4
- package/build/src/events/Events.d.ts +3 -4
- package/build/src/events/transport/TransportEventTypes.d.ts +3 -4
- package/build/src/events/transport/TransportEventTypes.js +3 -7
- package/build/src/events/transport/TransportEventTypes.js.map +1 -1
- package/build/src/events/transport/TransportEvents.d.ts +32 -14
- package/build/src/events/transport/TransportEvents.js +33 -22
- package/build/src/events/transport/TransportEvents.js.map +1 -1
- package/build/src/lib/transformers/PayloadSerializer.js +1 -0
- package/build/src/lib/transformers/PayloadSerializer.js.map +1 -1
- package/build/src/models/AppProject.d.ts +10 -0
- package/build/src/models/AppProject.js +14 -0
- package/build/src/models/AppProject.js.map +1 -1
- package/build/src/models/HttpResponse.js.map +1 -1
- package/build/src/models/ProjectRequest.js.map +1 -1
- package/build/src/models/Request.js.map +1 -1
- package/build/src/models/legacy/DataExport.d.ts +69 -0
- package/build/src/models/legacy/Normalizer.d.ts +1 -1
- package/build/src/models/legacy/Normalizer.js +1 -1
- package/build/src/runtime/node/InteropInterfaces.d.ts +2 -1
- package/build/src/runtime/node/ProjectParallelRunner.d.ts +3 -2
- package/build/src/runtime/node/ProjectParallelRunner.js.map +1 -1
- package/build/src/runtime/node/ProjectRunner.d.ts +3 -3
- package/build/src/runtime/node/ProjectRunner.js.map +1 -1
- package/build/src/runtime/node/ProjectRunnerWorker.js +23 -5
- package/build/src/runtime/node/ProjectRunnerWorker.js.map +1 -1
- package/package.json +1 -1
- package/src/cookies/CookieParser.ts +40 -26
- package/src/events/BaseEvents.ts +4 -0
- package/src/events/transport/TransportEventTypes.ts +4 -8
- package/src/events/transport/TransportEvents.ts +51 -24
- package/src/lib/transformers/PayloadSerializer.ts +1 -0
- package/src/models/AppProject.ts +16 -0
- package/src/models/HttpResponse.ts +2 -2
- package/src/models/ProjectRequest.ts +8 -8
- package/src/models/Request.ts +7 -7
- package/src/models/legacy/DataExport.ts +77 -0
- package/src/models/legacy/Normalizer.ts +1 -1
- package/src/runtime/node/InteropInterfaces.ts +2 -1
- package/src/runtime/node/ProjectParallelRunner.ts +3 -2
- package/src/runtime/node/ProjectRunner.ts +3 -3
- package/src/runtime/node/ProjectRunnerWorker.ts +21 -5
package/package.json
CHANGED
|
@@ -71,19 +71,20 @@ export class CookieParser {
|
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
73
|
* Parses the `set-cookie` header value and creates a list of cookies.
|
|
74
|
-
* The cookie configuration must match the `url`. This means that if the cookie has a `host` property
|
|
75
|
-
* this must match the request URL (browsers do not allow setting cookies from one domain for another).
|
|
76
74
|
*
|
|
77
|
-
*
|
|
75
|
+
* Notes:
|
|
76
|
+
* - This does not check whether the cookie should be stored in the Cookie Jar based on the request URL, use `parse()` instead
|
|
77
|
+
* - This will fill up cookies' `domain` and `path` when `requestUrl` is provided. Otherwise it will leave these fields empty which makes the cookie invalid. Use `parse()` instead
|
|
78
78
|
*
|
|
79
|
-
* @param requestUrl The HTTP request URL. Cookies must match this URL or will be ignored.
|
|
80
79
|
* @param setCookie The value of the `set-cookie` string.
|
|
80
|
+
* @param requestUrl The HTTP request URL.
|
|
81
81
|
*/
|
|
82
|
-
static
|
|
82
|
+
static parseRelaxed(setCookie?: string, requestUrl?: string): HttpCookie[] {
|
|
83
83
|
const result: HttpCookie[] = [];
|
|
84
84
|
if (!setCookie || typeof setCookie !== 'string') {
|
|
85
85
|
return result;
|
|
86
86
|
}
|
|
87
|
+
|
|
87
88
|
const blocks = setCookie.split(';').map(i => i.trim());
|
|
88
89
|
blocks.forEach((part, index) => {
|
|
89
90
|
// Consider the following set-cookie string:
|
|
@@ -153,28 +154,41 @@ export class CookieParser {
|
|
|
153
154
|
}
|
|
154
155
|
});
|
|
155
156
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
157
|
+
if (requestUrl) {
|
|
158
|
+
const url = new URL(requestUrl);
|
|
159
|
+
const domain = this.canonicalDomain(url.host);
|
|
160
|
+
const path = this.getPath(url);
|
|
161
|
+
|
|
162
|
+
result.forEach((cookie) => {
|
|
163
|
+
if (!cookie.path) {
|
|
164
|
+
cookie.path = path;
|
|
165
|
+
}
|
|
166
|
+
if (!cookie.domain) {
|
|
167
|
+
// point 6. of https://tools.ietf.org/html/rfc6265#section-5.3
|
|
168
|
+
cookie.domain = domain;
|
|
169
|
+
cookie.hostOnly = true;
|
|
170
|
+
} else if (cookie.domain[0] !== '.') {
|
|
171
|
+
// https://stackoverflow.com/a/1063760/1127848
|
|
172
|
+
cookie.domain = `.${cookie.domain}`;
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
return result;
|
|
177
|
+
}
|
|
163
178
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
return this.filterCookies(result, requestUrl);
|
|
179
|
+
/**
|
|
180
|
+
* Parses the `set-cookie` header value and creates a list of cookies.
|
|
181
|
+
* The cookie configuration must match the `url`. This means that if the cookie has a `host` property
|
|
182
|
+
* this must match the request URL (browsers do not allow setting cookies from one domain for another).
|
|
183
|
+
*
|
|
184
|
+
* When `host` or `path` part is missing from the cookie, the URL values are used.
|
|
185
|
+
*
|
|
186
|
+
* @param requestUrl The HTTP request URL. Cookies must match this URL or will be ignored.
|
|
187
|
+
* @param setCookie The value of the `set-cookie` string.
|
|
188
|
+
*/
|
|
189
|
+
static parse(requestUrl: string, setCookie?: string): HttpCookie[] {
|
|
190
|
+
const cookies = this.parseRelaxed(setCookie, requestUrl);
|
|
191
|
+
return this.filterCookies(cookies, requestUrl);
|
|
178
192
|
}
|
|
179
193
|
|
|
180
194
|
/**
|
package/src/events/BaseEvents.ts
CHANGED
|
@@ -319,6 +319,10 @@ export interface ContextListOptions {
|
|
|
319
319
|
* A string that should be used with the pagination.
|
|
320
320
|
*/
|
|
321
321
|
nextPageToken?: string;
|
|
322
|
+
/**
|
|
323
|
+
* Optional parent for the query.
|
|
324
|
+
*/
|
|
325
|
+
parent?: string;
|
|
322
326
|
}
|
|
323
327
|
|
|
324
328
|
export class ContextListEvent<T> extends ContextEvent<ContextListOptions, ContextListResult<T>> {
|
|
@@ -3,9 +3,11 @@ export const TransportEventTypes = Object.freeze({
|
|
|
3
3
|
* Transport via the CoreEngine.
|
|
4
4
|
*/
|
|
5
5
|
Core: Object.freeze({
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
request: 'transportcorerequest',
|
|
7
|
+
httpProject: 'transportcorehttpproject',
|
|
8
|
+
appProject: 'transportcoreappproject',
|
|
8
9
|
}),
|
|
10
|
+
|
|
9
11
|
/**
|
|
10
12
|
* Transport via the native platform's bindings.
|
|
11
13
|
*/
|
|
@@ -13,12 +15,6 @@ export const TransportEventTypes = Object.freeze({
|
|
|
13
15
|
send: 'httptransportsend',
|
|
14
16
|
}),
|
|
15
17
|
|
|
16
|
-
// project runner
|
|
17
|
-
Project: Object.freeze({
|
|
18
|
-
// for both a request or a folder (since it's all single configuration.)
|
|
19
|
-
send: 'transportprojectsend',
|
|
20
|
-
}),
|
|
21
|
-
|
|
22
18
|
// web sockets.
|
|
23
19
|
Ws: Object.freeze({
|
|
24
20
|
/**
|
|
@@ -5,6 +5,7 @@ import { IHttpRequest } from "../../models/HttpRequest.js";
|
|
|
5
5
|
import { IRequestBaseConfig } from "../../models/RequestConfig.js";
|
|
6
6
|
import { IRequestLog } from '../../models/RequestLog.js';
|
|
7
7
|
import { HttpProject } from "../../models/HttpProject.js";
|
|
8
|
+
import { AppProject } from "../../models/AppProject.js";
|
|
8
9
|
import { ContextEvent } from "../BaseEvents.js";
|
|
9
10
|
import { TransportEventTypes } from "./TransportEventTypes.js";
|
|
10
11
|
import { IProjectRunnerOptions } from "../../runtime/node/InteropInterfaces.js";
|
|
@@ -21,11 +22,25 @@ export interface IHttpRequestDetail {
|
|
|
21
22
|
init?: RequestInit;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
export interface
|
|
25
|
+
export interface IHttpRequestResult {
|
|
26
|
+
log: IRequestLog;
|
|
27
|
+
/**
|
|
28
|
+
* The variables evaluated during the run.
|
|
29
|
+
* These variables have values set by request HTTP flows.
|
|
30
|
+
*/
|
|
31
|
+
variables: Record<string, string>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface IHttpProjectRequestDetail {
|
|
25
35
|
project: HttpProject | string;
|
|
26
36
|
opts: IProjectRunnerOptions;
|
|
27
37
|
}
|
|
28
38
|
|
|
39
|
+
export interface IAppProjectRequestDetail {
|
|
40
|
+
project: AppProject | string;
|
|
41
|
+
opts: IProjectRunnerOptions;
|
|
42
|
+
}
|
|
43
|
+
|
|
29
44
|
/* eslint-disable no-unused-vars */
|
|
30
45
|
export const TransportEvent = Object.freeze({
|
|
31
46
|
/**
|
|
@@ -39,10 +54,10 @@ export const TransportEvent = Object.freeze({
|
|
|
39
54
|
* @param request The request definition
|
|
40
55
|
* @param authorization When known, a list of authorization configuration to apply to the request.
|
|
41
56
|
* @param config Optional request configuration.
|
|
42
|
-
* @returns The execution log or `undefined` when the event was not handled.
|
|
57
|
+
* @returns The execution log with the variables evaluated during the run or `undefined` when the event was not handled.
|
|
43
58
|
*/
|
|
44
|
-
|
|
45
|
-
const e = new ContextEvent<ICoreRequestDetail,
|
|
59
|
+
request: async (request: IHttpRequest, authorization?: IRequestAuthorization[], config?: IRequestBaseConfig, target: EventTarget = window): Promise<IHttpRequestResult | undefined> => {
|
|
60
|
+
const e = new ContextEvent<ICoreRequestDetail, IHttpRequestResult>(TransportEventTypes.Core.request, {
|
|
46
61
|
request,
|
|
47
62
|
authorization,
|
|
48
63
|
config
|
|
@@ -50,6 +65,38 @@ export const TransportEvent = Object.freeze({
|
|
|
50
65
|
target.dispatchEvent(e);
|
|
51
66
|
return e.detail.result;
|
|
52
67
|
},
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* For both the project or a folder (since it's all single configuration.)
|
|
71
|
+
*
|
|
72
|
+
* @param target The events target
|
|
73
|
+
* @param project The instance of a project or an id of the project to execute. The current user has to be already authenticated.
|
|
74
|
+
* @param opts The project execution options.
|
|
75
|
+
*/
|
|
76
|
+
httpProject: async (project: HttpProject | string, opts: IProjectRunnerOptions, target: EventTarget = window): Promise<IProjectExecutionLog | undefined> => {
|
|
77
|
+
const e = new ContextEvent<IHttpProjectRequestDetail, IProjectExecutionLog>(TransportEventTypes.Core.httpProject, {
|
|
78
|
+
project,
|
|
79
|
+
opts,
|
|
80
|
+
});
|
|
81
|
+
target.dispatchEvent(e);
|
|
82
|
+
return e.detail.result;
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* For both the project or a folder (since it's all single configuration.)
|
|
87
|
+
*
|
|
88
|
+
* @param target The events target
|
|
89
|
+
* @param project The instance of a project or an id of the project to execute. The current user has to be already authenticated.
|
|
90
|
+
* @param opts The project execution options.
|
|
91
|
+
*/
|
|
92
|
+
appProject: async (project: AppProject | string, opts: IProjectRunnerOptions, target: EventTarget = window): Promise<IProjectExecutionLog | undefined> => {
|
|
93
|
+
const e = new ContextEvent<IAppProjectRequestDetail, IProjectExecutionLog>(TransportEventTypes.Core.appProject, {
|
|
94
|
+
project,
|
|
95
|
+
opts,
|
|
96
|
+
});
|
|
97
|
+
target.dispatchEvent(e);
|
|
98
|
+
return e.detail.result;
|
|
99
|
+
},
|
|
53
100
|
}),
|
|
54
101
|
/**
|
|
55
102
|
* Transport via the native platform's bindings.
|
|
@@ -74,26 +121,6 @@ export const TransportEvent = Object.freeze({
|
|
|
74
121
|
},
|
|
75
122
|
}),
|
|
76
123
|
|
|
77
|
-
// project runner
|
|
78
|
-
Project: Object.freeze({
|
|
79
|
-
/**
|
|
80
|
-
* For both a request or a folder (since it's all single configuration.)
|
|
81
|
-
*
|
|
82
|
-
* @param target The events target
|
|
83
|
-
* @param project The instance of a project or an id of the project to execute. The current user has to be already authenticated.
|
|
84
|
-
* @param opts The project execution options.
|
|
85
|
-
* @returns
|
|
86
|
-
*/
|
|
87
|
-
send: async (project: HttpProject | string, opts: IProjectRunnerOptions, target: EventTarget = window): Promise<IProjectExecutionLog | undefined> => {
|
|
88
|
-
const e = new ContextEvent<IProjectRequestDetail, IProjectExecutionLog>(TransportEventTypes.Project.send, {
|
|
89
|
-
project,
|
|
90
|
-
opts,
|
|
91
|
-
});
|
|
92
|
-
target.dispatchEvent(e);
|
|
93
|
-
return e.detail.result;
|
|
94
|
-
},
|
|
95
|
-
}),
|
|
96
|
-
|
|
97
124
|
// web sockets.
|
|
98
125
|
Ws: Object.freeze({
|
|
99
126
|
/**
|
|
@@ -154,6 +154,7 @@ export class PayloadSerializer {
|
|
|
154
154
|
const result = await PayloadSerializer.stringifyFormData(payload);
|
|
155
155
|
return result;
|
|
156
156
|
} catch (e: unknown) {
|
|
157
|
+
// eslint-disable-next-line no-console
|
|
157
158
|
console.warn(`Unable to transform FormData: ${(e as Error).message}`);
|
|
158
159
|
}
|
|
159
160
|
}
|
package/src/models/AppProject.ts
CHANGED
|
@@ -983,6 +983,13 @@ export class AppProjectFolder extends AppProjectParent {
|
|
|
983
983
|
listEnvironments(): Environment[] {
|
|
984
984
|
return this.project.listEnvironments({ parent: this.key });
|
|
985
985
|
}
|
|
986
|
+
|
|
987
|
+
/**
|
|
988
|
+
* @returns The list of environments defined in this folder
|
|
989
|
+
*/
|
|
990
|
+
getEnvironments(): Environment[] {
|
|
991
|
+
return this.project.getEnvironments({ parent: this.key });
|
|
992
|
+
}
|
|
986
993
|
}
|
|
987
994
|
|
|
988
995
|
/**
|
|
@@ -1879,6 +1886,15 @@ export class AppProject extends AppProjectParent {
|
|
|
1879
1886
|
return env;
|
|
1880
1887
|
}
|
|
1881
1888
|
|
|
1889
|
+
/**
|
|
1890
|
+
* This method is a link to `listEnvironments()` to be compatible with the HttpProject.
|
|
1891
|
+
*
|
|
1892
|
+
* @returns The list of environments defined in this folder
|
|
1893
|
+
*/
|
|
1894
|
+
getEnvironments(opts?: IAppProjectItemOptions): Environment[] {
|
|
1895
|
+
return this.listEnvironments(opts);
|
|
1896
|
+
}
|
|
1897
|
+
|
|
1882
1898
|
/**
|
|
1883
1899
|
* This is a link to the `getEnvironments()`. The difference is that on the
|
|
1884
1900
|
* project level it won't return environments defined with the class initialization.
|
|
@@ -72,7 +72,7 @@ export class HttpResponse extends SerializablePayload {
|
|
|
72
72
|
/**
|
|
73
73
|
* @param input The response definition used to restore the state.
|
|
74
74
|
*/
|
|
75
|
-
constructor(input?: string|IHttpResponse) {
|
|
75
|
+
constructor(input?: string | IHttpResponse) {
|
|
76
76
|
super();
|
|
77
77
|
let init: IHttpResponse;
|
|
78
78
|
if (typeof input === 'string') {
|
|
@@ -97,7 +97,7 @@ export class HttpResponse extends SerializablePayload {
|
|
|
97
97
|
if (!HttpResponse.isHttpResponse(init)) {
|
|
98
98
|
throw new Error(`Not a response.`);
|
|
99
99
|
}
|
|
100
|
-
const { status, statusText, headers, payload, kind=Kind } = init;
|
|
100
|
+
const { status, statusText, headers, payload, kind = Kind } = init;
|
|
101
101
|
this.kind = kind;
|
|
102
102
|
this.status = status;
|
|
103
103
|
this.statusText = statusText;
|
|
@@ -70,7 +70,7 @@ export class ProjectRequest extends Request implements ProjectDefinitionProperty
|
|
|
70
70
|
if (!project) {
|
|
71
71
|
throw new Error(`The project is required.`);
|
|
72
72
|
}
|
|
73
|
-
const now:number = Date.now();
|
|
73
|
+
const now: number = Date.now();
|
|
74
74
|
const request = new ProjectRequest(project, {
|
|
75
75
|
key: v4(),
|
|
76
76
|
kind: Kind,
|
|
@@ -100,7 +100,7 @@ export class ProjectRequest extends Request implements ProjectDefinitionProperty
|
|
|
100
100
|
if (!project) {
|
|
101
101
|
throw new Error(`The project is required.`);
|
|
102
102
|
}
|
|
103
|
-
const now:number = Date.now();
|
|
103
|
+
const now: number = Date.now();
|
|
104
104
|
const request = new ProjectRequest(project, {
|
|
105
105
|
key: v4(),
|
|
106
106
|
kind: Kind,
|
|
@@ -130,7 +130,7 @@ export class ProjectRequest extends Request implements ProjectDefinitionProperty
|
|
|
130
130
|
if (!project) {
|
|
131
131
|
throw new Error(`The project is required.`);
|
|
132
132
|
}
|
|
133
|
-
const now:number = Date.now();
|
|
133
|
+
const now: number = Date.now();
|
|
134
134
|
const request = new ProjectRequest(project, {
|
|
135
135
|
key: v4(),
|
|
136
136
|
kind: Kind,
|
|
@@ -160,8 +160,8 @@ export class ProjectRequest extends Request implements ProjectDefinitionProperty
|
|
|
160
160
|
const result = new ProjectRequest(project, init);
|
|
161
161
|
return result;
|
|
162
162
|
}
|
|
163
|
-
|
|
164
|
-
constructor(project: HttpProject, input?: string|IProjectRequest | IAppProjectRequest) {
|
|
163
|
+
|
|
164
|
+
constructor(project: HttpProject, input?: string | IProjectRequest | IAppProjectRequest) {
|
|
165
165
|
super(input);
|
|
166
166
|
this.project = project;
|
|
167
167
|
let init: IProjectRequest | IAppProjectRequest;
|
|
@@ -170,7 +170,7 @@ export class ProjectRequest extends Request implements ProjectDefinitionProperty
|
|
|
170
170
|
} else if (typeof input === 'object') {
|
|
171
171
|
init = input;
|
|
172
172
|
} else {
|
|
173
|
-
const now:number = Date.now();
|
|
173
|
+
const now: number = Date.now();
|
|
174
174
|
init = {
|
|
175
175
|
key: v4(),
|
|
176
176
|
kind: Kind,
|
|
@@ -192,7 +192,7 @@ export class ProjectRequest extends Request implements ProjectDefinitionProperty
|
|
|
192
192
|
|
|
193
193
|
new(init: IProjectRequest | IAppProjectRequest): void {
|
|
194
194
|
super.new(init);
|
|
195
|
-
|
|
195
|
+
|
|
196
196
|
const { key } = init;
|
|
197
197
|
this.key = key || v4();
|
|
198
198
|
}
|
|
@@ -224,7 +224,7 @@ export class ProjectRequest extends Request implements ProjectDefinitionProperty
|
|
|
224
224
|
/**
|
|
225
225
|
* @returns The instance of the HttpProject or a ProjectFolder that is a closes parent of this instance.
|
|
226
226
|
*/
|
|
227
|
-
getParent(): ProjectFolder|HttpProject|undefined {
|
|
227
|
+
getParent(): ProjectFolder | HttpProject | undefined {
|
|
228
228
|
const { project, key } = this;
|
|
229
229
|
return project.findParent(key);
|
|
230
230
|
}
|
package/src/models/Request.ts
CHANGED
|
@@ -117,7 +117,7 @@ export class Request {
|
|
|
117
117
|
* @param url The Request URL.
|
|
118
118
|
*/
|
|
119
119
|
static fromUrl(url: string): Request {
|
|
120
|
-
const now:number = Date.now();
|
|
120
|
+
const now: number = Date.now();
|
|
121
121
|
const request = new Request({
|
|
122
122
|
kind: Kind,
|
|
123
123
|
created: now,
|
|
@@ -141,7 +141,7 @@ export class Request {
|
|
|
141
141
|
* @param name The Request name.
|
|
142
142
|
*/
|
|
143
143
|
static fromName(name: string): Request {
|
|
144
|
-
const now:number = Date.now();
|
|
144
|
+
const now: number = Date.now();
|
|
145
145
|
const request = new Request({
|
|
146
146
|
kind: Kind,
|
|
147
147
|
created: now,
|
|
@@ -165,7 +165,7 @@ export class Request {
|
|
|
165
165
|
* @param info The request data.
|
|
166
166
|
*/
|
|
167
167
|
static fromHttpRequest(info: IHttpRequest): Request {
|
|
168
|
-
const now:number = Date.now();
|
|
168
|
+
const now: number = Date.now();
|
|
169
169
|
const request = new Request({
|
|
170
170
|
kind: Kind,
|
|
171
171
|
created: now,
|
|
@@ -185,12 +185,12 @@ export class Request {
|
|
|
185
185
|
return request;
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
-
static async fromLegacy(request: ARCSavedRequest|ARCHistoryRequest): Promise<Request> {
|
|
188
|
+
static async fromLegacy(request: ARCSavedRequest | ARCHistoryRequest): Promise<Request> {
|
|
189
189
|
const normalized = Normalizer.normalizeRequest(request) as ARCSavedRequest;
|
|
190
190
|
if (!normalized) {
|
|
191
191
|
throw new Error(`Unknown object.`);
|
|
192
192
|
}
|
|
193
|
-
const init:IRequest = {
|
|
193
|
+
const init: IRequest = {
|
|
194
194
|
kind: Kind,
|
|
195
195
|
expects: {
|
|
196
196
|
kind: HttpRequestKind,
|
|
@@ -312,14 +312,14 @@ export class Request {
|
|
|
312
312
|
return this.defaultMidnight();
|
|
313
313
|
}
|
|
314
314
|
|
|
315
|
-
constructor(input?: string|IRequest) {
|
|
315
|
+
constructor(input?: string | IRequest) {
|
|
316
316
|
let init: IRequest;
|
|
317
317
|
if (typeof input === 'string') {
|
|
318
318
|
init = JSON.parse(input);
|
|
319
319
|
} else if (typeof input === 'object') {
|
|
320
320
|
init = input;
|
|
321
321
|
} else {
|
|
322
|
-
const now:number = Date.now();
|
|
322
|
+
const now: number = Date.now();
|
|
323
323
|
init = {
|
|
324
324
|
kind: Kind,
|
|
325
325
|
created: now,
|
|
@@ -122,6 +122,24 @@ export interface EncryptionOptions {
|
|
|
122
122
|
passphrase?: string;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
+
export interface ProviderOptions {
|
|
126
|
+
/**
|
|
127
|
+
* Export file name or path to render in the save dialog or file name
|
|
128
|
+
* in the cloud provider.
|
|
129
|
+
*/
|
|
130
|
+
file: string;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* The folder where to put the file.
|
|
134
|
+
*/
|
|
135
|
+
parent?: string;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Content's mime type
|
|
139
|
+
*/
|
|
140
|
+
contentType?: string;
|
|
141
|
+
}
|
|
142
|
+
|
|
125
143
|
/**
|
|
126
144
|
* @deprecated
|
|
127
145
|
*/
|
|
@@ -154,15 +172,25 @@ export interface ExportOptionsInternal extends ExportOptions {
|
|
|
154
172
|
appVersion: string;
|
|
155
173
|
}
|
|
156
174
|
|
|
175
|
+
/**
|
|
176
|
+
* @deprecated
|
|
177
|
+
*/
|
|
157
178
|
export interface ArcExportProcessedData {
|
|
158
179
|
key: keyof ArcNativeDataExport;
|
|
159
180
|
data: any[];
|
|
160
181
|
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* @deprecated
|
|
185
|
+
*/
|
|
161
186
|
export interface ArcExportClientCertificateData {
|
|
162
187
|
item: ARCCertificateIndex;
|
|
163
188
|
data: ARCRequestCertificate;
|
|
164
189
|
}
|
|
165
190
|
|
|
191
|
+
/**
|
|
192
|
+
* @deprecated
|
|
193
|
+
*/
|
|
166
194
|
export interface ArcNativeDataExport {
|
|
167
195
|
authdata?: boolean | ARCAuthData[];
|
|
168
196
|
clientcertificates?: boolean;
|
|
@@ -175,3 +203,52 @@ export interface ArcNativeDataExport {
|
|
|
175
203
|
websocketurlhistory?: boolean | ARCWebsocketUrlHistory[];
|
|
176
204
|
urlhistory?: boolean | ARCUrlHistory[];
|
|
177
205
|
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* @deprecated
|
|
209
|
+
*/
|
|
210
|
+
export declare const ExportKey: keyof ArcNativeDataExport;
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* @deprecated
|
|
214
|
+
*/
|
|
215
|
+
export interface ArcLegacyNativeDataExport extends ArcNativeDataExport {
|
|
216
|
+
'websocket-url-history': boolean | ARCWebsocketUrlHistory[];
|
|
217
|
+
'auth-data': boolean | ARCAuthData[];
|
|
218
|
+
'url-history': boolean | ARCUrlHistory[];
|
|
219
|
+
'host-rules': boolean | ARCHostRule[];
|
|
220
|
+
'client-certificates': boolean | ARCVariable[];
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* @deprecated
|
|
225
|
+
*/
|
|
226
|
+
export interface ArcExportResult {
|
|
227
|
+
/**
|
|
228
|
+
* Whether an export operation was a success
|
|
229
|
+
*/
|
|
230
|
+
success: boolean;
|
|
231
|
+
/**
|
|
232
|
+
* Whether the operation was interrupted by the user.
|
|
233
|
+
*/
|
|
234
|
+
interrupted: boolean;
|
|
235
|
+
/**
|
|
236
|
+
* With the cloud based export this is the ID of parent folder.
|
|
237
|
+
* For file export it is the path of the file.
|
|
238
|
+
*/
|
|
239
|
+
parentId: string;
|
|
240
|
+
/**
|
|
241
|
+
* The generated file id.
|
|
242
|
+
* With the cloud based export this is the ID of created file entry.
|
|
243
|
+
* For file export it is the file name that the user provided in the save dialog.
|
|
244
|
+
*/
|
|
245
|
+
fileId: string;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Options interface for file import
|
|
250
|
+
* @deprecated
|
|
251
|
+
*/
|
|
252
|
+
export interface FileImportOptions {
|
|
253
|
+
driveId?: string;
|
|
254
|
+
}
|
|
@@ -82,7 +82,7 @@ export class Normalizer {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
/**
|
|
85
|
-
* Transforms the `TransformedPayload` object to its original data type.
|
|
85
|
+
* Transforms the legacy `TransformedPayload` object to its original data type.
|
|
86
86
|
*/
|
|
87
87
|
static restoreTransformedPayload(body: string | ArrayBuffer | Buffer | LegacyTransformedPayload): string | Buffer | ArrayBuffer | undefined {
|
|
88
88
|
if (!body) {
|
|
@@ -4,6 +4,7 @@ import { Environment } from '../../models/Environment.js';
|
|
|
4
4
|
import { Logger } from '../../lib/logging/Logger.js';
|
|
5
5
|
import { IRequestLog } from '../../models/RequestLog.js';
|
|
6
6
|
import { CookieJar } from '../../cookies/CookieJar.js';
|
|
7
|
+
import { IAppProject } from 'browser.js';
|
|
7
8
|
|
|
8
9
|
export interface IRequestRunnerOptions {
|
|
9
10
|
/**
|
|
@@ -71,7 +72,7 @@ export interface IProjectParallelRunnerOptions extends IProjectRunnerOptions {
|
|
|
71
72
|
}
|
|
72
73
|
|
|
73
74
|
export interface IProjectParallelWorkerOptions extends IProjectRunnerOptions {
|
|
74
|
-
project: IHttpProject;
|
|
75
|
+
project: IHttpProject | IAppProject;
|
|
75
76
|
}
|
|
76
77
|
|
|
77
78
|
export interface IProjectRunnerOptions {
|
|
@@ -3,6 +3,7 @@ import { cpus } from 'os';
|
|
|
3
3
|
import { dirname, join } from 'path';
|
|
4
4
|
import { fileURLToPath } from 'url';
|
|
5
5
|
import { HttpProject } from '../../models/HttpProject.js';
|
|
6
|
+
import { AppProject } from '../../models/AppProject.js';
|
|
6
7
|
import { IProjectExecutionLog, IProjectExecutionIteration } from '../reporters/Reporter.js';
|
|
7
8
|
import { BaseRunner } from './BaseRunner.js';
|
|
8
9
|
import { State } from './enums.js';
|
|
@@ -66,13 +67,13 @@ export interface ProjectParallelRunner {
|
|
|
66
67
|
* change. This event can be user to refresh the UI to reflect the newest state.
|
|
67
68
|
*/
|
|
68
69
|
export class ProjectParallelRunner extends BaseRunner {
|
|
69
|
-
project: HttpProject;
|
|
70
|
+
project: HttpProject | AppProject;
|
|
70
71
|
options: IProjectParallelRunnerOptions;
|
|
71
72
|
workers: WorkerInfoInternal[] = [];
|
|
72
73
|
private mainResolver?: (report: IProjectExecutionLog) => void;
|
|
73
74
|
private mainRejecter?: (err: Error) => void;
|
|
74
75
|
|
|
75
|
-
constructor(project: HttpProject, opts: IProjectParallelRunnerOptions = {}) {
|
|
76
|
+
constructor(project: HttpProject | AppProject, opts: IProjectParallelRunnerOptions = {}) {
|
|
76
77
|
super();
|
|
77
78
|
this.project = project;
|
|
78
79
|
this.options = opts;
|
|
@@ -11,9 +11,9 @@ import { pathExists, readJson } from '../../lib/fs/Fs.js';
|
|
|
11
11
|
import { BaseRunner } from './BaseRunner.js';
|
|
12
12
|
import { IProjectRunnerOptions, IRequestRunnerOptions } from './InteropInterfaces.js';
|
|
13
13
|
import { State } from './enums.js';
|
|
14
|
-
import { AppProject } from '../../models/AppProject.js';
|
|
14
|
+
import { AppProject, AppProjectFolder } from '../../models/AppProject.js';
|
|
15
15
|
|
|
16
|
-
type ProjectParent = HttpProject | ProjectFolder;
|
|
16
|
+
type ProjectParent = HttpProject | ProjectFolder | AppProject | AppProjectFolder;
|
|
17
17
|
|
|
18
18
|
export interface ProjectRunner {
|
|
19
19
|
/**
|
|
@@ -173,7 +173,7 @@ export abstract class ProjectRunner extends BaseRunner {
|
|
|
173
173
|
* A required step before running the project.
|
|
174
174
|
* It configures the execution context. It may throw an error when configuration is not valid.
|
|
175
175
|
*/
|
|
176
|
-
async configure(project: HttpProject, opts: IProjectRunnerOptions = {}): Promise<void> {
|
|
176
|
+
async configure(project: HttpProject | AppProject, opts: IProjectRunnerOptions = {}): Promise<void> {
|
|
177
177
|
this.project = project;
|
|
178
178
|
this.options = opts || {};
|
|
179
179
|
if (typeof this.options.iterations === 'number' && this.options.iterations >= 0) {
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
/* eslint-disable no-unused-vars */
|
|
3
3
|
import process from 'process';
|
|
4
4
|
import cluster from 'cluster';
|
|
5
|
-
import { HttpProject } from '../../models/HttpProject.js';
|
|
5
|
+
import { HttpProject, Kind as HttpProjectKind } from '../../models/HttpProject.js';
|
|
6
|
+
import { AppProject, AppProjectKind } from '../../models/AppProject.js';
|
|
6
7
|
import { IProjectExecutionLog } from '../reporters/Reporter.js';
|
|
7
8
|
import { IWorkerMessage } from './ProjectParallelRunner.js';
|
|
8
9
|
import { IProjectParallelWorkerOptions } from './InteropInterfaces.js';
|
|
@@ -16,7 +17,9 @@ class ProjectExeWorker extends ProjectRunner {
|
|
|
16
17
|
if (cluster.isPrimary) {
|
|
17
18
|
throw new Error(`This file should not be called directly.`);
|
|
18
19
|
}
|
|
19
|
-
process.send
|
|
20
|
+
if (process.send) {
|
|
21
|
+
process.send({ cmd: 'online' });
|
|
22
|
+
}
|
|
20
23
|
process.on('message', this.messageHandler.bind(this));
|
|
21
24
|
}
|
|
22
25
|
|
|
@@ -29,11 +32,22 @@ class ProjectExeWorker extends ProjectRunner {
|
|
|
29
32
|
async run(options: IProjectParallelWorkerOptions): Promise<void> {
|
|
30
33
|
options.cookies = new InMemoryCookieJar();
|
|
31
34
|
try {
|
|
32
|
-
|
|
35
|
+
const schema = options.project;
|
|
36
|
+
let project: HttpProject | AppProject;
|
|
37
|
+
if (schema.kind === HttpProjectKind) {
|
|
38
|
+
project = new HttpProject(schema);
|
|
39
|
+
} else if (schema.kind === AppProjectKind) {
|
|
40
|
+
project = new AppProject(schema);
|
|
41
|
+
} else {
|
|
42
|
+
throw new Error(`Unknown project kind: ${schema.kind}`);
|
|
43
|
+
}
|
|
44
|
+
await this.configure(project, options);
|
|
33
45
|
await this.execute();
|
|
34
46
|
} catch (e) {
|
|
35
47
|
const cause = e as Error;
|
|
36
|
-
process.send
|
|
48
|
+
if (process.send) {
|
|
49
|
+
process.send({ cmd: 'error', data: cause.message });
|
|
50
|
+
}
|
|
37
51
|
}
|
|
38
52
|
}
|
|
39
53
|
|
|
@@ -58,7 +72,9 @@ class ProjectExeWorker extends ProjectRunner {
|
|
|
58
72
|
this.endTime = Date.now();
|
|
59
73
|
|
|
60
74
|
const log = await this.createReport();
|
|
61
|
-
process.send
|
|
75
|
+
if (process.send) {
|
|
76
|
+
process.send({ cmd: 'result', data: log.iterations });
|
|
77
|
+
}
|
|
62
78
|
this._state = State.Idle as State;
|
|
63
79
|
return log;
|
|
64
80
|
}
|