@skyramp/skyramp 0.4.88 → 0.4.90
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/lib/dev-darwin-amd64.dylib +0 -0
- package/lib/dev-darwin-arm64.dylib +0 -0
- package/lib/dev-linux-386.so +0 -0
- package/lib/dev-linux-amd64.so +0 -0
- package/lib/dev-windows-amd64.dll +0 -0
- package/package.json +1 -1
- package/src/classes/Protocol.d.ts +8 -0
- package/src/classes/Protocol.js +8 -0
- package/src/classes/RequestValue.d.ts +2 -1
- package/src/classes/RequestValue.js +4 -2
- package/src/classes/RestEndpoint.d.ts +1 -0
- package/src/classes/RestEndpoint.js +12 -2
- package/src/index.d.ts +1 -0
- package/src/index.js +3 -1
|
Binary file
|
|
Binary file
|
package/lib/dev-linux-386.so
CHANGED
|
Binary file
|
package/lib/dev-linux-amd64.so
CHANGED
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -7,9 +7,10 @@ interface RequestValueOptions {
|
|
|
7
7
|
methodType?: string;
|
|
8
8
|
methodName?: string;
|
|
9
9
|
params?: RestParam[];
|
|
10
|
-
headers?:
|
|
10
|
+
headers?: {[headerName: string]: string},
|
|
11
11
|
vars?: Map<string, string | number>;
|
|
12
12
|
blob?: string;
|
|
13
|
+
graphqlParam?: string;
|
|
13
14
|
javascriptPath?: string;
|
|
14
15
|
javascriptFunction?: string;
|
|
15
16
|
}
|
|
@@ -31,6 +31,7 @@ class RequestValue {
|
|
|
31
31
|
this.headers = options.headers;
|
|
32
32
|
this.vars = options.vars;
|
|
33
33
|
this.blob = options.blob;
|
|
34
|
+
this.graphqlParam = options.graphqlParam;
|
|
34
35
|
this.javascriptPath = options.javascriptPath;
|
|
35
36
|
this.javascript = options.javascriptFunction;
|
|
36
37
|
}
|
|
@@ -82,6 +83,9 @@ class RequestValue {
|
|
|
82
83
|
if (this.blob !== undefined && this.blob !== null) {
|
|
83
84
|
requestDict.blob = this.blob;
|
|
84
85
|
}
|
|
86
|
+
if (this.graphqlParam!== undefined && this.graphqlParam!== null) {
|
|
87
|
+
requestDict.graphqlParam = this.graphqlParam;
|
|
88
|
+
}
|
|
85
89
|
if (this.vars !== undefined && this.vars !== null) {
|
|
86
90
|
requestDict.vars = this.vars;
|
|
87
91
|
}
|
|
@@ -104,8 +108,6 @@ class RequestValue {
|
|
|
104
108
|
requestDict["override"] = this.responseValue;
|
|
105
109
|
}
|
|
106
110
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
111
|
}
|
|
110
112
|
|
|
111
113
|
module.exports = RequestValue;
|
|
@@ -5,6 +5,7 @@ interface RestEndpointOptions {
|
|
|
5
5
|
restPath?: string,
|
|
6
6
|
methodType?: string[], // GET, POST, PUT, DELETE, PATCH
|
|
7
7
|
endpointAddress?: string,
|
|
8
|
+
subProtocol?: string,
|
|
8
9
|
}
|
|
9
10
|
export declare class RestEndpoint extends Endpoint {
|
|
10
11
|
constructor(name: string, openApiTag: string, port: number, openapiFile: string, endpointAddress: string);
|
|
@@ -31,7 +31,7 @@ class RestEndpoint extends Endpoint {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
function createEndpoint({ serviceName, port, restPath, methodTypes }) {
|
|
34
|
+
function createEndpoint({ serviceName, port, restPath, methodTypes, subProtocol }) {
|
|
35
35
|
// Validate required arguments
|
|
36
36
|
if (typeof serviceName !== 'string' || serviceName.length === 0) {
|
|
37
37
|
throw new Error('serviceName must be a non-empty string');
|
|
@@ -46,6 +46,16 @@ function createEndpoint({ serviceName, port, restPath, methodTypes }) {
|
|
|
46
46
|
throw new Error('restPath must be a string');
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
// Validate subProtocol
|
|
50
|
+
const allowedProtocols = ['graphql', 'jsonrpc-http', 'jsonrpc-ws'];
|
|
51
|
+
let protocol = 'rest';
|
|
52
|
+
if (subProtocol !== undefined) {
|
|
53
|
+
if (typeof subProtocol !== 'string' || !allowedProtocols.includes(subProtocol.toLowerCase())) {
|
|
54
|
+
throw new Error('Invalid subProtocol. It must not be "graphql" or "jsonrpc".');
|
|
55
|
+
}
|
|
56
|
+
protocol = subProtocol;
|
|
57
|
+
}
|
|
58
|
+
|
|
49
59
|
// allowed HTTP methods
|
|
50
60
|
const allowedMethods = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'];
|
|
51
61
|
|
|
@@ -54,7 +64,7 @@ function createEndpoint({ serviceName, port, restPath, methodTypes }) {
|
|
|
54
64
|
name: serviceName,
|
|
55
65
|
port: port,
|
|
56
66
|
alias: serviceName,
|
|
57
|
-
protocol:
|
|
67
|
+
protocol: protocol,
|
|
58
68
|
}],
|
|
59
69
|
endpoints: [{
|
|
60
70
|
name: serviceName + '-endpoint',
|
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
|
@@ -7,6 +7,7 @@ const ResponseValue = require('./classes/ResponseValue');
|
|
|
7
7
|
const RestParam = require('./classes/RestParam');
|
|
8
8
|
const TrafficConfig = require('./classes/TrafficConfig');
|
|
9
9
|
const DelayConfig = require('./classes/DelayConfig');
|
|
10
|
+
const Protocol = require('./classes/Protocol');
|
|
10
11
|
|
|
11
12
|
module.exports = {
|
|
12
13
|
SkyrampClient,
|
|
@@ -18,4 +19,5 @@ module.exports = {
|
|
|
18
19
|
RestParam,
|
|
19
20
|
TrafficConfig,
|
|
20
21
|
DelayConfig,
|
|
21
|
-
|
|
22
|
+
Protocol,
|
|
23
|
+
}
|