@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.
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyramp/skyramp",
3
- "version": "0.4.88",
3
+ "version": "0.4.90",
4
4
  "description": "module for leveraging skyramp cli functionality",
5
5
  "scripts": {
6
6
  "lint": "eslint 'src/**/*.js' 'src/**/*.ts' --fix",
@@ -0,0 +1,8 @@
1
+ declare const Protocol: {
2
+ readonly REST: 'rest';
3
+ readonly GRAPHQL: 'graphql';
4
+ readonly GRPC: 'grpc';
5
+ };
6
+
7
+ export default Protocol;
8
+
@@ -0,0 +1,8 @@
1
+ const Protocol = Object.freeze({
2
+ REST: 'rest',
3
+ GRAPHQL: 'graphql',
4
+ GRPC: 'grpc'
5
+ })
6
+
7
+ module.exports=Protocol;
8
+
@@ -7,9 +7,10 @@ interface RequestValueOptions {
7
7
  methodType?: string;
8
8
  methodName?: string;
9
9
  params?: RestParam[];
10
- headers?: Map<string, string>;
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: 'rest'
67
+ protocol: protocol,
58
68
  }],
59
69
  endpoints: [{
60
70
  name: serviceName + '-endpoint',
package/src/index.d.ts CHANGED
@@ -8,3 +8,4 @@ export * from './classes/ResponseValue';
8
8
  export * from './classes/RestParam';
9
9
  export * from './classes/TrafficConfig';
10
10
  export * from './classes/DelayConfig';
11
+ export * from './classes/Protocol';
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
+ }