@cumulusds/aws-apig-bypass 0.1.0 → 0.2.1

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.
@@ -18,7 +18,7 @@ jobs:
18
18
  - name: Checkout
19
19
  uses: actions/checkout@v2
20
20
  - name: Install Node ${{ matrix.node }}
21
- uses: actions/setup-node@v2.1.4
21
+ uses: actions/setup-node@v2.1.5
22
22
  with:
23
23
  node-version: ${{ matrix.node }}
24
24
  - name: Install NPM credentials
@@ -28,7 +28,7 @@ jobs:
28
28
  - name: Get yarn cache
29
29
  id: yarn-cache
30
30
  run: echo "::set-output name=dir::$(yarn cache dir)"
31
- - uses: actions/cache@v2.1.3
31
+ - uses: actions/cache@v2.1.4
32
32
  with:
33
33
  path: ${{ steps.yarn-cache.outputs.dir }}
34
34
  key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
@@ -62,7 +62,7 @@ jobs:
62
62
  - name: Checkout
63
63
  uses: actions/checkout@v2
64
64
  - name: Install Node 14
65
- uses: actions/setup-node@v2.1.4
65
+ uses: actions/setup-node@v2.1.5
66
66
  with:
67
67
  node-version: 14
68
68
  - name: Install NPM credentials
@@ -72,7 +72,7 @@ jobs:
72
72
  - name: Get yarn cache
73
73
  id: yarn-cache
74
74
  run: echo "::set-output name=dir::$(yarn cache dir)"
75
- - uses: actions/cache@v2.1.3
75
+ - uses: actions/cache@v2.1.4
76
76
  with:
77
77
  path: ${{ steps.yarn-cache.outputs.dir }}
78
78
  key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
@@ -4,48 +4,56 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = createAPIGatewayEvent;
7
+ const defaultRequestContext = {
8
+ accountId: "",
9
+ apiId: "",
10
+ httpMethod: "",
11
+ identity: {
12
+ accessKey: null,
13
+ accountId: null,
14
+ apiKey: null,
15
+ caller: null,
16
+ cognitoAuthenticationProvider: null,
17
+ cognitoAuthenticationType: null,
18
+ cognitoIdentityId: null,
19
+ cognitoIdentityPoolId: null,
20
+ sourceIp: "",
21
+ user: null,
22
+ userAgent: null,
23
+ userArn: null
24
+ },
25
+ stage: "",
26
+ requestId: "",
27
+ resourceId: "",
28
+ resourcePath: ""
29
+ };
7
30
 
8
31
  function createAPIGatewayEvent({
32
+ body = null,
33
+ headers = {},
34
+ multiValueHeaders = {},
35
+ httpMethod = "",
36
+ isBase64Encoded = false,
9
37
  pathParameters = null,
10
38
  path = "",
11
- body = null,
12
39
  queryStringParameters = null,
13
- isBase64Encoded = false
40
+ multiValueQueryStringParameters = null,
41
+ stageVariables = null,
42
+ requestContext = defaultRequestContext,
43
+ resource = ""
14
44
  } = {}) {
15
45
  return {
16
46
  body,
17
- headers: {},
18
- multiValueHeaders: {},
19
- httpMethod: "",
47
+ headers,
48
+ multiValueHeaders,
49
+ httpMethod,
20
50
  isBase64Encoded,
21
51
  path,
22
52
  pathParameters,
23
53
  queryStringParameters,
24
- multiValueQueryStringParameters: null,
25
- stageVariables: null,
26
- requestContext: {
27
- accountId: "",
28
- apiId: "",
29
- httpMethod: "",
30
- identity: {
31
- accessKey: null,
32
- accountId: null,
33
- apiKey: null,
34
- caller: null,
35
- cognitoAuthenticationProvider: null,
36
- cognitoAuthenticationType: null,
37
- cognitoIdentityId: null,
38
- cognitoIdentityPoolId: null,
39
- sourceIp: "",
40
- user: null,
41
- userAgent: null,
42
- userArn: null
43
- },
44
- stage: "",
45
- requestId: "",
46
- resourceId: "",
47
- resourcePath: ""
48
- },
49
- resource: ""
54
+ multiValueQueryStringParameters,
55
+ stageVariables,
56
+ requestContext,
57
+ resource
50
58
  };
51
59
  }
@@ -5,55 +5,71 @@ import type { APIGatewayEvent } from "flow-aws-lambda";
5
5
  export type PathParameters = { [name: string]: string } | null;
6
6
  export type QueryStringParameters = { [name: string]: string } | null;
7
7
 
8
+ const defaultRequestContext = {
9
+ accountId: "",
10
+ apiId: "",
11
+ httpMethod: "",
12
+ identity: {
13
+ accessKey: null,
14
+ accountId: null,
15
+ apiKey: null,
16
+ caller: null,
17
+ cognitoAuthenticationProvider: null,
18
+ cognitoAuthenticationType: null,
19
+ cognitoIdentityId: null,
20
+ cognitoIdentityPoolId: null,
21
+ sourceIp: "",
22
+ user: null,
23
+ userAgent: null,
24
+ userArn: null
25
+ },
26
+ stage: "",
27
+ requestId: "",
28
+ resourceId: "",
29
+ resourcePath: ""
30
+ };
31
+
8
32
  export type CreateAPIGatewayEventOptions = {
9
33
  body?: string,
34
+ headers?: { [name: string]: string },
35
+ multiValueHeaders?: { [name: string]: string[] },
36
+ httpMethod?: string,
37
+ isBase64Encoded?: boolean,
10
38
  path?: string,
11
39
  pathParameters?: PathParameters,
12
40
  queryStringParameters?: QueryStringParameters,
13
- isBase64Encoded?: boolean
41
+ multiValueQueryStringParameters?: { [name: string]: string[] },
42
+ stageVariables?: { [name: string]: string },
43
+ requestContext?: typeof defaultRequestContext,
44
+ resource?: string
14
45
  };
15
46
 
16
47
  export default function createAPIGatewayEvent({
48
+ body = null,
49
+ headers = {},
50
+ multiValueHeaders = {},
51
+ httpMethod = "",
52
+ isBase64Encoded = false,
17
53
  pathParameters = null,
18
54
  path = "",
19
- body = null,
20
55
  queryStringParameters = null,
21
- isBase64Encoded = false
56
+ multiValueQueryStringParameters = null,
57
+ stageVariables = null,
58
+ requestContext = defaultRequestContext,
59
+ resource = ""
22
60
  }: CreateAPIGatewayEventOptions = {}): APIGatewayEvent<string> {
23
61
  return {
24
62
  body,
25
- headers: {},
26
- multiValueHeaders: {},
27
- httpMethod: "",
63
+ headers,
64
+ multiValueHeaders,
65
+ httpMethod,
28
66
  isBase64Encoded,
29
67
  path,
30
68
  pathParameters,
31
69
  queryStringParameters,
32
- multiValueQueryStringParameters: null,
33
- stageVariables: null,
34
- requestContext: {
35
- accountId: "",
36
- apiId: "",
37
- httpMethod: "",
38
- identity: {
39
- accessKey: null,
40
- accountId: null,
41
- apiKey: null,
42
- caller: null,
43
- cognitoAuthenticationProvider: null,
44
- cognitoAuthenticationType: null,
45
- cognitoIdentityId: null,
46
- cognitoIdentityPoolId: null,
47
- sourceIp: "",
48
- user: null,
49
- userAgent: null,
50
- userArn: null
51
- },
52
- stage: "",
53
- requestId: "",
54
- resourceId: "",
55
- resourcePath: ""
56
- },
57
- resource: ""
70
+ multiValueQueryStringParameters,
71
+ stageVariables,
72
+ requestContext,
73
+ resource
58
74
  };
59
75
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cumulusds/aws-apig-bypass",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "Client for API Gateway handlers, bypassing API Gateway by directly invoking the Lambda",
5
5
  "repository": "https://github.com/CumulusDS/aws-apig-bypass",
6
6
  "author": "Cumulus Digital Systems",
@@ -52,10 +52,7 @@
52
52
  }
53
53
  }
54
54
  },
55
- "dependencies": {
56
- "@cumulusds/flow-aws-sdk": "^2.818.0",
57
- "flow-aws-lambda": "CumulusDS/flow-aws-lambda#ef1bd9a0342e55a0e9e1b225bdbc2a3c2a4d5632"
58
- },
55
+ "dependencies": {},
59
56
  "devDependencies": {
60
57
  "@babel/cli": "^7.0.0",
61
58
  "@babel/core": "^7.7.4",
@@ -63,6 +60,7 @@
63
60
  "@babel/plugin-proposal-optional-chaining": "^7.12.7",
64
61
  "@babel/preset-env": "^7.0.0",
65
62
  "@babel/preset-flow": "^7.0.0",
63
+ "@cumulusds/flow-aws-sdk": "^2.818.0",
66
64
  "babel-eslint": "10.0.3",
67
65
  "babel-jest": "^24.9.0",
68
66
  "eslint": "^7.5.0",
@@ -72,6 +70,7 @@
72
70
  "eslint-plugin-import": "2.18.2",
73
71
  "eslint-plugin-jest": "^21.15.1",
74
72
  "eslint-plugin-prettier": "^2.6.0",
73
+ "flow-aws-lambda": "^1.0.6",
75
74
  "flow-bin": "^0.141.0",
76
75
  "flow-copy-source": "^2.0.9",
77
76
  "flow-coverage-report": "^0.8.0",
@@ -5,55 +5,71 @@ import type { APIGatewayEvent } from "flow-aws-lambda";
5
5
  export type PathParameters = { [name: string]: string } | null;
6
6
  export type QueryStringParameters = { [name: string]: string } | null;
7
7
 
8
+ const defaultRequestContext = {
9
+ accountId: "",
10
+ apiId: "",
11
+ httpMethod: "",
12
+ identity: {
13
+ accessKey: null,
14
+ accountId: null,
15
+ apiKey: null,
16
+ caller: null,
17
+ cognitoAuthenticationProvider: null,
18
+ cognitoAuthenticationType: null,
19
+ cognitoIdentityId: null,
20
+ cognitoIdentityPoolId: null,
21
+ sourceIp: "",
22
+ user: null,
23
+ userAgent: null,
24
+ userArn: null
25
+ },
26
+ stage: "",
27
+ requestId: "",
28
+ resourceId: "",
29
+ resourcePath: ""
30
+ };
31
+
8
32
  export type CreateAPIGatewayEventOptions = {
9
33
  body?: string,
34
+ headers?: { [name: string]: string },
35
+ multiValueHeaders?: { [name: string]: string[] },
36
+ httpMethod?: string,
37
+ isBase64Encoded?: boolean,
10
38
  path?: string,
11
39
  pathParameters?: PathParameters,
12
40
  queryStringParameters?: QueryStringParameters,
13
- isBase64Encoded?: boolean
41
+ multiValueQueryStringParameters?: { [name: string]: string[] },
42
+ stageVariables?: { [name: string]: string },
43
+ requestContext?: typeof defaultRequestContext,
44
+ resource?: string
14
45
  };
15
46
 
16
47
  export default function createAPIGatewayEvent({
48
+ body = null,
49
+ headers = {},
50
+ multiValueHeaders = {},
51
+ httpMethod = "",
52
+ isBase64Encoded = false,
17
53
  pathParameters = null,
18
54
  path = "",
19
- body = null,
20
55
  queryStringParameters = null,
21
- isBase64Encoded = false
56
+ multiValueQueryStringParameters = null,
57
+ stageVariables = null,
58
+ requestContext = defaultRequestContext,
59
+ resource = ""
22
60
  }: CreateAPIGatewayEventOptions = {}): APIGatewayEvent<string> {
23
61
  return {
24
62
  body,
25
- headers: {},
26
- multiValueHeaders: {},
27
- httpMethod: "",
63
+ headers,
64
+ multiValueHeaders,
65
+ httpMethod,
28
66
  isBase64Encoded,
29
67
  path,
30
68
  pathParameters,
31
69
  queryStringParameters,
32
- multiValueQueryStringParameters: null,
33
- stageVariables: null,
34
- requestContext: {
35
- accountId: "",
36
- apiId: "",
37
- httpMethod: "",
38
- identity: {
39
- accessKey: null,
40
- accountId: null,
41
- apiKey: null,
42
- caller: null,
43
- cognitoAuthenticationProvider: null,
44
- cognitoAuthenticationType: null,
45
- cognitoIdentityId: null,
46
- cognitoIdentityPoolId: null,
47
- sourceIp: "",
48
- user: null,
49
- userAgent: null,
50
- userArn: null
51
- },
52
- stage: "",
53
- requestId: "",
54
- resourceId: "",
55
- resourcePath: ""
56
- },
57
- resource: ""
70
+ multiValueQueryStringParameters,
71
+ stageVariables,
72
+ requestContext,
73
+ resource
58
74
  };
59
75
  }