@api-client/core 0.7.10 → 0.7.11
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/proxy/AppProjectProxy.d.ts +2 -1
- package/build/src/proxy/AppProjectProxy.js.map +1 -1
- package/build/src/proxy/HttpProjectProxy.d.ts +2 -1
- package/build/src/proxy/HttpProjectProxy.js.map +1 -1
- package/build/src/proxy/ProxyService.d.ts +10 -19
- package/build/src/proxy/ProxyService.js +8 -31
- package/build/src/proxy/ProxyService.js.map +1 -1
- package/build/src/proxy/RequestProxy.d.ts +2 -2
- package/build/src/proxy/RequestProxy.js +1 -7
- package/build/src/proxy/RequestProxy.js.map +1 -1
- package/package.json +1 -1
- package/src/proxy/AppProjectProxy.ts +2 -1
- package/src/proxy/HttpProjectProxy.ts +2 -1
- package/src/proxy/ProxyService.ts +10 -35
- package/src/proxy/RequestProxy.ts +2 -7
- package/src/proxy/readme.md +0 -5
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { IProjectRunnerOptions } from "../runtime/node/InteropInterfaces.js";
|
|
2
2
|
import { AppProject, AppProjectKind } from "../models/AppProject.js";
|
|
3
3
|
import Proxy, { IProxyResult } from "./Proxy.js";
|
|
4
|
+
import { IProjectExecutionLog } from "../runtime/reporters/Reporter.js";
|
|
4
5
|
export interface IAppProjectProxyInit {
|
|
5
6
|
kind: typeof AppProjectKind;
|
|
6
7
|
/**
|
|
@@ -23,5 +24,5 @@ export default class AppProjectProxy extends Proxy {
|
|
|
23
24
|
project?: AppProject;
|
|
24
25
|
options?: IProjectRunnerOptions;
|
|
25
26
|
configure(init: IAppProjectProxyInit, token: string, baseUri: string): Promise<void>;
|
|
26
|
-
execute(): Promise<IProxyResult
|
|
27
|
+
execute(): Promise<IProxyResult<IProjectExecutionLog>>;
|
|
27
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppProjectProxy.js","sourceRoot":"","sources":["../../../src/proxy/AppPro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C,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;SACpC;QACD,IAAI,OAAO,CAAC,GAAG,KAAK,GAAG,EAAE;YACvB,MAAM,IAAI,QAAQ,CAAC,6BAA6B,EAAE,GAAG,CAAC,CAAC;SACxD;QACD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,IAAI,UAAU,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,OAAO;QACX,MAAM,OAAO,GAAG,IAAI,CAAC,OAAqB,CAAC;QAC3C,MAAM,IAAI,GAAG,IAAI,CAAC,OAAgC,CAAC;QACnD,IAAI,OAAoD,CAAC;QACzD,IAAI,IAAI,CAAC,QAAQ,EAAE;YACjB,OAAO,GAAG,IAAI,qBAAqB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;SACpD;aAAM;YACL,OAAO,GAAG,IAAI,mBAAmB,EAAE,CAAC;YACpC,OAAO,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;SAClC;QAED,iDAAiD;QACjD,SAAS,kBAAkB;YACzB,GAAG;QACL,CAAC;QACD,4DAA4D;QAC5D,yEAAyE;QACzE,0EAA0E;QAC1E,6CAA6C;QAC7C,uCAAuC;QACvC,OAAO,CAAC,EAAE,CAAC,oBAAoB,EAAE,kBAAkB,CAAC,CAAC;QACrD,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;QACvC,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,kBAAkB,CAAC,CAAC;QACtD,OAAO;YACL,MAAM,EAAE,MAAM;SACf,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { IProjectRunnerOptions } from "../runtime/node/InteropInterfaces.js";
|
|
2
2
|
import { Kind as HttpProjectKind, HttpProject } from "../models/HttpProject.js";
|
|
3
3
|
import Proxy, { IProxyResult } from "./Proxy.js";
|
|
4
|
+
import { IProjectExecutionLog } from "../runtime/reporters/Reporter.js";
|
|
4
5
|
export interface IHttpProjectProxyInit {
|
|
5
6
|
kind: typeof HttpProjectKind;
|
|
6
7
|
/**
|
|
@@ -19,5 +20,5 @@ export default class HttpProjectProxy extends Proxy {
|
|
|
19
20
|
project?: HttpProject;
|
|
20
21
|
options?: IProjectRunnerOptions;
|
|
21
22
|
configure(init: IHttpProjectProxyInit, token: string, baseUri: string): Promise<void>;
|
|
22
|
-
execute(): Promise<IProxyResult
|
|
23
|
+
execute(): Promise<IProxyResult<IProjectExecutionLog>>;
|
|
23
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpProjectProxy.js","sourceRoot":"","sources":["../../../src/proxy/HttpProjectProxy.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,WAAW,EAAgB,MAAM,0BAA0B,CAAC;AAC9F,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,KAAuB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"HttpProjectProxy.js","sourceRoot":"","sources":["../../../src/proxy/HttpProjectProxy.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,WAAW,EAAgB,MAAM,0BAA0B,CAAC;AAC9F,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,KAAuB,MAAM,YAAY,CAAC;AAejD;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,gBA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C;QACtD,OAAO;YACL,MAAM,EAAE,MAAM;SACf,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { IProjectExecutionLog } from "../runtime/reporters/Reporter.js";
|
|
2
|
+
import { IRequestLog } from "../models/RequestLog.js";
|
|
3
|
+
import { IAppProjectProxyInit } from "./AppProjectProxy.js";
|
|
4
|
+
import { IHttpProjectProxyInit } from "./HttpProjectProxy.js";
|
|
4
5
|
import { IProxyResult } from "./Proxy.js";
|
|
5
|
-
import
|
|
6
|
-
declare type Proxy = RequestProxy | HttpProjectProxy | AppProjectProxy;
|
|
6
|
+
import { IRequestProxyInit } from "./RequestProxy.js";
|
|
7
7
|
export default class ProxyService {
|
|
8
|
-
state: Map<string, Proxy>;
|
|
9
8
|
/**
|
|
10
9
|
* Executes a single HTTP request.
|
|
10
|
+
*
|
|
11
11
|
* @param init The request to execute with additional configuration.
|
|
12
|
-
* @returns The
|
|
12
|
+
* @returns The execution log for the request.
|
|
13
13
|
*/
|
|
14
|
-
|
|
14
|
+
proxyRequest(init: IRequestProxyInit): Promise<IProxyResult<IRequestLog>>;
|
|
15
15
|
/**
|
|
16
16
|
* Executes an HttpProject.
|
|
17
17
|
*
|
|
@@ -20,7 +20,7 @@ export default class ProxyService {
|
|
|
20
20
|
* @param init The project run configuration.
|
|
21
21
|
* @returns The key under which the proxy is cached.
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
proxyHttpProject(token: string, storeUri: string, init: IHttpProjectProxyInit): Promise<IProxyResult<IProjectExecutionLog>>;
|
|
24
24
|
/**
|
|
25
25
|
* Executes an AppProject.
|
|
26
26
|
*
|
|
@@ -29,14 +29,5 @@ export default class ProxyService {
|
|
|
29
29
|
* @param init The project run configuration.
|
|
30
30
|
* @returns The key under which the proxy is cached.
|
|
31
31
|
*/
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Executes previously configured proxy.
|
|
35
|
-
*
|
|
36
|
-
* @param key The key returned by the add proxy function.
|
|
37
|
-
* @param body Optional body to send with the `HttpRequest` proxy.
|
|
38
|
-
* @returns The execution log depending on the proxy type.
|
|
39
|
-
*/
|
|
40
|
-
proxy(key: string, body?: Buffer): Promise<IProxyResult>;
|
|
32
|
+
proxyAppProject(token: string, storeUri: string, init: IAppProjectProxyInit): Promise<IProxyResult<IProjectExecutionLog>>;
|
|
41
33
|
}
|
|
42
|
-
export {};
|
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
import { ApiError } from "../runtime/store/Errors.js";
|
|
2
|
-
import v4 from "../lib/uuid.js";
|
|
3
1
|
import AppProjectProxy from "./AppProjectProxy.js";
|
|
4
2
|
import HttpProjectProxy from "./HttpProjectProxy.js";
|
|
5
3
|
import RequestProxy from "./RequestProxy.js";
|
|
6
4
|
export default class ProxyService {
|
|
7
|
-
state = new Map();
|
|
8
5
|
/**
|
|
9
6
|
* Executes a single HTTP request.
|
|
7
|
+
*
|
|
10
8
|
* @param init The request to execute with additional configuration.
|
|
11
|
-
* @returns The
|
|
9
|
+
* @returns The execution log for the request.
|
|
12
10
|
*/
|
|
13
|
-
async
|
|
11
|
+
async proxyRequest(init) {
|
|
14
12
|
const proxy = new RequestProxy();
|
|
15
13
|
await proxy.configure(init);
|
|
16
|
-
|
|
17
|
-
this.state.set(id, proxy);
|
|
18
|
-
return id;
|
|
14
|
+
return proxy.execute();
|
|
19
15
|
}
|
|
20
16
|
/**
|
|
21
17
|
* Executes an HttpProject.
|
|
@@ -25,12 +21,10 @@ export default class ProxyService {
|
|
|
25
21
|
* @param init The project run configuration.
|
|
26
22
|
* @returns The key under which the proxy is cached.
|
|
27
23
|
*/
|
|
28
|
-
async
|
|
24
|
+
async proxyHttpProject(token, storeUri, init) {
|
|
29
25
|
const proxy = new HttpProjectProxy();
|
|
30
26
|
await proxy.configure(init, token, storeUri);
|
|
31
|
-
|
|
32
|
-
this.state.set(id, proxy);
|
|
33
|
-
return id;
|
|
27
|
+
return proxy.execute();
|
|
34
28
|
}
|
|
35
29
|
/**
|
|
36
30
|
* Executes an AppProject.
|
|
@@ -40,27 +34,10 @@ export default class ProxyService {
|
|
|
40
34
|
* @param init The project run configuration.
|
|
41
35
|
* @returns The key under which the proxy is cached.
|
|
42
36
|
*/
|
|
43
|
-
async
|
|
37
|
+
async proxyAppProject(token, storeUri, init) {
|
|
44
38
|
const proxy = new AppProjectProxy();
|
|
45
39
|
await proxy.configure(init, token, storeUri);
|
|
46
|
-
|
|
47
|
-
this.state.set(id, proxy);
|
|
48
|
-
return id;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Executes previously configured proxy.
|
|
52
|
-
*
|
|
53
|
-
* @param key The key returned by the add proxy function.
|
|
54
|
-
* @param body Optional body to send with the `HttpRequest` proxy.
|
|
55
|
-
* @returns The execution log depending on the proxy type.
|
|
56
|
-
*/
|
|
57
|
-
async proxy(key, body) {
|
|
58
|
-
const proxy = this.state.get(key);
|
|
59
|
-
if (!proxy) {
|
|
60
|
-
throw new ApiError(`Unknown key: ${key}. The request may have been already executed.`, 400);
|
|
61
|
-
}
|
|
62
|
-
this.state.delete(key);
|
|
63
|
-
return proxy.execute(body);
|
|
40
|
+
return proxy.execute();
|
|
64
41
|
}
|
|
65
42
|
}
|
|
66
43
|
//# sourceMappingURL=ProxyService.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProxyService.js","sourceRoot":"","sources":["../../../src/proxy/ProxyService.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ProxyService.js","sourceRoot":"","sources":["../../../src/proxy/ProxyService.ts"],"names":[],"mappings":"AAEA,OAAO,eAAyC,MAAM,sBAAsB,CAAC;AAC7E,OAAO,gBAA2C,MAAM,uBAAuB,CAAC;AAEhF,OAAO,YAAmC,MAAM,mBAAmB,CAAC;AAEpE,MAAM,CAAC,OAAO,OAAO,YAAY;IAC/B;;;;;OAKG;IACH,KAAK,CAAC,YAAY,CAAC,IAAuB;QACxC,MAAM,KAAK,GAAG,IAAI,YAAY,EAAE,CAAC;QACjC,MAAM,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAC5B,OAAO,KAAK,CAAC,OAAO,EAAE,CAAC;IACzB,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,gBAAgB,CAAC,KAAa,EAAE,QAAgB,EAAE,IAA2B;QACjF,MAAM,KAAK,GAAG,IAAI,gBAAgB,EAAE,CAAC;QACrC,MAAM,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC7C,OAAO,KAAK,CAAC,OAAO,EAAE,CAAC;IACzB,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,eAAe,CAAC,KAAa,EAAE,QAAgB,EAAE,IAA0B;QAC/E,MAAM,KAAK,GAAG,IAAI,eAAe,EAAE,CAAC;QACpC,MAAM,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC7C,OAAO,KAAK,CAAC,OAAO,EAAiD,CAAC;IACxE,CAAC;CACF"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { IHttpRequest, Kind as HttpRequestKind } from '../models/HttpRequest.js';
|
|
3
2
|
import { IRequestAuthorization } from '../models/RequestAuthorization.js';
|
|
4
3
|
import { IRequestConfig } from '../models/RequestConfig.js';
|
|
5
4
|
import Proxy, { IProxyResult } from "./Proxy.js";
|
|
6
5
|
import { HttpCertificate } from '../models/ClientCertificate.js';
|
|
7
6
|
import { IHttpActionFlow } from '../models/http-actions/HttpActions.js';
|
|
7
|
+
import { IRequestLog } from "../models/RequestLog.js";
|
|
8
8
|
export interface IRequestProxyInit {
|
|
9
9
|
kind: typeof HttpRequestKind;
|
|
10
10
|
/**
|
|
@@ -38,5 +38,5 @@ export interface IRequestProxyInit {
|
|
|
38
38
|
export default class RequestProxy extends Proxy {
|
|
39
39
|
init?: IRequestProxyInit;
|
|
40
40
|
configure(init: IRequestProxyInit): Promise<void>;
|
|
41
|
-
execute(
|
|
41
|
+
execute(): Promise<IProxyResult<IRequestLog>>;
|
|
42
42
|
}
|
|
@@ -27,15 +27,9 @@ export default class RequestProxy extends Proxy {
|
|
|
27
27
|
}
|
|
28
28
|
this.init = init;
|
|
29
29
|
}
|
|
30
|
-
async execute(
|
|
30
|
+
async execute() {
|
|
31
31
|
const data = this.init;
|
|
32
32
|
const { request, authorization, certificate, config = {}, variables = {}, flows } = data;
|
|
33
|
-
if (body) {
|
|
34
|
-
request.payload = {
|
|
35
|
-
type: 'buffer',
|
|
36
|
-
data: [...body],
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
33
|
const factory = new HttpRequestRunner();
|
|
40
34
|
factory.variables = variables;
|
|
41
35
|
factory.logger = new DummyLogger();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequestProxy.js","sourceRoot":"","sources":["../../../src/proxy/RequestProxy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAuB,MAAM,YAAY,CAAC;AAGjD,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAC;
|
|
1
|
+
{"version":3,"file":"RequestProxy.js","sourceRoot":"","sources":["../../../src/proxy/RequestProxy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAuB,MAAM,YAAY,CAAC;AAGjD,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAC;AA+BhF;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,KAAK;IAC7C,IAAI,CAAqB;IAE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W,EAAE;YACf,OAAO,CAAC,YAAY,GAAG,CAAC,WAAW,CAAC,CAAC;SACtC;QACD,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC1C,OAAO;YACL,MAAM,EAAE,MAAM;YACd,SAAS;SACV,CAAC;IACJ,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -5,6 +5,7 @@ import { StoreSdk } from "../runtime/store/StoreSdkNode.js";
|
|
|
5
5
|
import { ProjectSerialRunner } from "../runtime/node/ProjectSerialRunner.js";
|
|
6
6
|
import { ProjectParallelRunner } from "../runtime/node/ProjectParallelRunner.js";
|
|
7
7
|
import Proxy, { IProxyResult } from "./Proxy.js";
|
|
8
|
+
import { IProjectExecutionLog } from "../runtime/reporters/Reporter.js";
|
|
8
9
|
|
|
9
10
|
export interface IAppProjectProxyInit {
|
|
10
11
|
kind: typeof AppProjectKind;
|
|
@@ -95,7 +96,7 @@ export default class AppProjectProxy extends Proxy {
|
|
|
95
96
|
this.project = new AppProject(project);
|
|
96
97
|
}
|
|
97
98
|
|
|
98
|
-
async execute(): Promise<IProxyResult
|
|
99
|
+
async execute(): Promise<IProxyResult<IProjectExecutionLog>> {
|
|
99
100
|
const project = this.project as AppProject;
|
|
100
101
|
const opts = this.options as IProjectRunnerOptions;
|
|
101
102
|
let factory: ProjectParallelRunner | ProjectSerialRunner;
|
|
@@ -5,6 +5,7 @@ import { StoreSdk } from "../runtime/store/StoreSdkNode.js";
|
|
|
5
5
|
import { ProjectSerialRunner } from "../runtime/node/ProjectSerialRunner.js";
|
|
6
6
|
import { ProjectParallelRunner } from "../runtime/node/ProjectParallelRunner.js";
|
|
7
7
|
import Proxy, { IProxyResult } from "./Proxy.js";
|
|
8
|
+
import { IProjectExecutionLog } from "../runtime/reporters/Reporter.js";
|
|
8
9
|
|
|
9
10
|
export interface IHttpProjectProxyInit {
|
|
10
11
|
kind: typeof HttpProjectKind;
|
|
@@ -83,7 +84,7 @@ export default class HttpProjectProxy extends Proxy {
|
|
|
83
84
|
this.project = new HttpProject(project);
|
|
84
85
|
}
|
|
85
86
|
|
|
86
|
-
async execute(): Promise<IProxyResult
|
|
87
|
+
async execute(): Promise<IProxyResult<IProjectExecutionLog>> {
|
|
87
88
|
const project = this.project as HttpProject;
|
|
88
89
|
const opts = this.options as IProjectRunnerOptions;
|
|
89
90
|
let factory: ProjectParallelRunner | ProjectSerialRunner;
|
|
@@ -1,26 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { IProjectExecutionLog } from "../runtime/reporters/Reporter.js";
|
|
2
|
+
import { IRequestLog } from "../models/RequestLog.js";
|
|
3
3
|
import AppProjectProxy, { IAppProjectProxyInit } from "./AppProjectProxy.js";
|
|
4
4
|
import HttpProjectProxy, { IHttpProjectProxyInit } from "./HttpProjectProxy.js";
|
|
5
5
|
import { IProxyResult } from "./Proxy.js";
|
|
6
6
|
import RequestProxy, { IRequestProxyInit } from "./RequestProxy.js";
|
|
7
7
|
|
|
8
|
-
type Proxy = RequestProxy | HttpProjectProxy | AppProjectProxy;
|
|
9
|
-
|
|
10
8
|
export default class ProxyService {
|
|
11
|
-
state = new Map<string, Proxy>();
|
|
12
|
-
|
|
13
9
|
/**
|
|
14
10
|
* Executes a single HTTP request.
|
|
11
|
+
*
|
|
15
12
|
* @param init The request to execute with additional configuration.
|
|
16
|
-
* @returns The
|
|
13
|
+
* @returns The execution log for the request.
|
|
17
14
|
*/
|
|
18
|
-
async
|
|
15
|
+
async proxyRequest(init: IRequestProxyInit): Promise<IProxyResult<IRequestLog>> {
|
|
19
16
|
const proxy = new RequestProxy();
|
|
20
17
|
await proxy.configure(init);
|
|
21
|
-
|
|
22
|
-
this.state.set(id, proxy);
|
|
23
|
-
return id;
|
|
18
|
+
return proxy.execute();
|
|
24
19
|
}
|
|
25
20
|
|
|
26
21
|
/**
|
|
@@ -31,12 +26,10 @@ export default class ProxyService {
|
|
|
31
26
|
* @param init The project run configuration.
|
|
32
27
|
* @returns The key under which the proxy is cached.
|
|
33
28
|
*/
|
|
34
|
-
async
|
|
29
|
+
async proxyHttpProject(token: string, storeUri: string, init: IHttpProjectProxyInit): Promise<IProxyResult<IProjectExecutionLog>> {
|
|
35
30
|
const proxy = new HttpProjectProxy();
|
|
36
31
|
await proxy.configure(init, token, storeUri);
|
|
37
|
-
|
|
38
|
-
this.state.set(id, proxy);
|
|
39
|
-
return id;
|
|
32
|
+
return proxy.execute();
|
|
40
33
|
}
|
|
41
34
|
|
|
42
35
|
/**
|
|
@@ -47,27 +40,9 @@ export default class ProxyService {
|
|
|
47
40
|
* @param init The project run configuration.
|
|
48
41
|
* @returns The key under which the proxy is cached.
|
|
49
42
|
*/
|
|
50
|
-
async
|
|
43
|
+
async proxyAppProject(token: string, storeUri: string, init: IAppProjectProxyInit): Promise<IProxyResult<IProjectExecutionLog>> {
|
|
51
44
|
const proxy = new AppProjectProxy();
|
|
52
45
|
await proxy.configure(init, token, storeUri);
|
|
53
|
-
|
|
54
|
-
this.state.set(id, proxy);
|
|
55
|
-
return id;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Executes previously configured proxy.
|
|
60
|
-
*
|
|
61
|
-
* @param key The key returned by the add proxy function.
|
|
62
|
-
* @param body Optional body to send with the `HttpRequest` proxy.
|
|
63
|
-
* @returns The execution log depending on the proxy type.
|
|
64
|
-
*/
|
|
65
|
-
async proxy(key: string, body?: Buffer): Promise<IProxyResult> {
|
|
66
|
-
const proxy = this.state.get(key);
|
|
67
|
-
if (!proxy) {
|
|
68
|
-
throw new ApiError(`Unknown key: ${key}. The request may have been already executed.`, 400);
|
|
69
|
-
}
|
|
70
|
-
this.state.delete(key);
|
|
71
|
-
return proxy.execute(body);
|
|
46
|
+
return proxy.execute() as Promise<IProxyResult<IProjectExecutionLog>>;
|
|
72
47
|
}
|
|
73
48
|
}
|
|
@@ -7,6 +7,7 @@ import { IHttpActionFlow } from '../models/http-actions/HttpActions.js';
|
|
|
7
7
|
import { ApiError } from '../runtime/store/Errors.js';
|
|
8
8
|
import { DummyLogger } from '../lib/logging/DummyLogger.js';
|
|
9
9
|
import { HttpRequestRunner } from '../runtime/http-runner/HttpRequestRunner.js';
|
|
10
|
+
import { IRequestLog } from "../models/RequestLog.js";
|
|
10
11
|
|
|
11
12
|
export interface IRequestProxyInit {
|
|
12
13
|
kind: typeof HttpRequestKind;
|
|
@@ -63,15 +64,9 @@ export default class RequestProxy extends Proxy {
|
|
|
63
64
|
this.init = init;
|
|
64
65
|
}
|
|
65
66
|
|
|
66
|
-
async execute(
|
|
67
|
+
async execute(): Promise<IProxyResult<IRequestLog>> {
|
|
67
68
|
const data = this.init as IRequestProxyInit;
|
|
68
69
|
const { request, authorization, certificate, config={}, variables={}, flows } = data;
|
|
69
|
-
if (body) {
|
|
70
|
-
request.payload = {
|
|
71
|
-
type: 'buffer',
|
|
72
|
-
data: [...body],
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
70
|
const factory = new HttpRequestRunner();
|
|
76
71
|
factory.variables = variables;
|
|
77
72
|
factory.logger = new DummyLogger();
|
package/src/proxy/readme.md
CHANGED
|
@@ -7,8 +7,3 @@ The libraries to create an HTTP/Socket proxy for API things (projects, requests)
|
|
|
7
7
|
- `AppProjectProxy` - a class that runs request from an `AppProject`
|
|
8
8
|
- `HttpProjectProxy` - a class that runs request from an `HttpProject`
|
|
9
9
|
- `RequestProxy` - a class that runs a single request as `HttpRequest`
|
|
10
|
-
|
|
11
|
-
## Architecture
|
|
12
|
-
|
|
13
|
-
The proxy is a 2-step process. In the first step the client sets-up a session (in a server that implements the proxy), processes the configuration, and validates the data.
|
|
14
|
-
In the second step the request is actually being executed. This 2nd step is very important when proxying `HttpRequest` as the `payload` read from the second server call is passed to the outgoing request (if any).
|