@cumulusds/aws-apig-bypass 0.1.0 → 0.2.0

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.
@@ -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.0",
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",
@@ -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
  }