@cumulusds/aws-apig-bypass 0.2.4 → 0.3.0-jnnode21.1.gaa6b5b9

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.
@@ -27,7 +27,6 @@ const defaultRequestContext = {
27
27
  resourceId: "",
28
28
  resourcePath: ""
29
29
  };
30
-
31
30
  function createAPIGatewayEvent({
32
31
  body = null,
33
32
  headers = {},
@@ -4,15 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = createClient;
7
-
8
7
  var _createLambdaClient = _interopRequireDefault(require("./create-lambda-client"));
9
-
10
8
  var _jsonStringify = _interopRequireDefault(require("./json-stringify"));
11
-
12
9
  var _parsePayload = _interopRequireDefault(require("./parse-payload"));
13
-
14
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
11
+ /**
12
+ * Client that directly invokes an API Gateway handler, bypassing the gateway. The client handles packing and unpacking messages for invoking the handler.
13
+ */
16
14
  /**
17
15
  * Create an APIGatewayHandlerClient. The client invokes an API Gateway handler, bypassing the gateway. It adapts the AWS SDK by packing and unpacking messages for invoking the handler.
18
16
  *
@@ -21,5 +19,5 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
21
19
  */
22
20
  function createClient(options) {
23
21
  const client = (0, _createLambdaClient.default)(options);
24
- return async event => (0, _parsePayload.default)((await client((0, _jsonStringify.default)(event))));
22
+ return async event => (0, _parsePayload.default)(await client((0, _jsonStringify.default)(event)));
25
23
  }
@@ -5,23 +5,18 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = createLambdaClient;
7
7
  exports.LambdaInvokeError = void 0;
8
-
9
8
  class LambdaInvokeError extends Error {
10
9
  constructor(response) {
11
10
  var _response$FunctionErr;
12
-
13
11
  super(["Invocation Failed", response.ExecutedVersion, response.StatusCode, response.FunctionError, response.Payload, response.LogResult != null ? Buffer.from(response.LogResult, "base64").toString("utf-8") : null].filter(x => x != null).join(": "));
14
12
  this.code = (_response$FunctionErr = response.FunctionError) !== null && _response$FunctionErr !== void 0 ? _response$FunctionErr : "";
15
13
  }
16
-
17
14
  }
15
+
18
16
  /**
19
17
  * AWS Lambda SDK adapter for createClient.
20
18
  */
21
-
22
-
23
19
  exports.LambdaInvokeError = LambdaInvokeError;
24
-
25
20
  function createLambdaClient({
26
21
  Lambda,
27
22
  FunctionName
@@ -31,15 +26,12 @@ function createLambdaClient({
31
26
  FunctionName,
32
27
  Payload
33
28
  }).promise();
34
-
35
29
  if (invocationResponse.StatusCode !== 200 || invocationResponse.FunctionError != null) {
36
30
  throw new LambdaInvokeError(invocationResponse);
37
31
  }
38
-
39
32
  if (typeof invocationResponse.Payload !== "string") {
40
33
  throw new Error(`AWS Lambda invocation API returned the wrong payload type '${typeof invocationResponse.Payload}'; expected 'string'`);
41
34
  }
42
-
43
35
  return invocationResponse.Payload;
44
36
  };
45
37
  }
package/lib/index.js CHANGED
@@ -15,9 +15,6 @@ Object.defineProperty(exports, "createAPIGatewayEvent", {
15
15
  return _createApiGatewayEvent.default;
16
16
  }
17
17
  });
18
-
19
18
  var _createClient = _interopRequireDefault(require("./create-client"));
20
-
21
19
  var _createApiGatewayEvent = _interopRequireDefault(require("./create-api-gateway-event"));
22
-
23
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
package/lib/index.js.flow CHANGED
@@ -1,4 +1,5 @@
1
1
  // @flow
2
2
 
3
3
  export { default as createClient } from "./create-client";
4
+ export type { APIGatewayHandlerClient } from "./create-client";
4
5
  export { default as createAPIGatewayEvent } from "./create-api-gateway-event";
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = jsonStringify;
7
-
8
7
  /**
9
8
  * Stringify to JSON, returning a string or else throwing an exception because of unserializable input.
10
9
  *
@@ -14,10 +13,8 @@ exports.default = jsonStringify;
14
13
  // flowlint-next-line unclear-type:off
15
14
  function jsonStringify(value) {
16
15
  const result = JSON.stringify(value);
17
-
18
16
  if (result == null) {
19
17
  throw new Error("Cannot stringify value");
20
18
  }
21
-
22
19
  return result;
23
20
  }
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = parsePayload;
7
-
8
7
  /**
9
8
  * Decode the handler response
10
9
  *
@@ -14,13 +13,10 @@ exports.default = parsePayload;
14
13
  */
15
14
  function parsePayload(payload, validate) {
16
15
  var _proxyResult$headers;
17
-
18
16
  const proxyResult = JSON.parse(payload);
19
-
20
17
  if (proxyResult.isBase64Encoded === true) {
21
18
  throw new Error("A base64 encoded response from API Gateway handler was received, but is not supported.");
22
19
  }
23
-
24
20
  const data = JSON.parse(proxyResult.body);
25
21
  validate === null || validate === void 0 ? void 0 : validate(data);
26
22
  return {
package/package.json CHANGED
@@ -1,31 +1,44 @@
1
1
  {
2
2
  "name": "@cumulusds/aws-apig-bypass",
3
- "version": "0.2.4",
3
+ "version": "0.3.0-jnnode21.1.gaa6b5b9",
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",
7
7
  "license": "MIT",
8
- "private": false,
9
8
  "engines": {
10
- "node": ">=10"
9
+ "node": "^18.0.0 || ^20.0.0 || >=21.0.0"
11
10
  },
12
11
  "main": "lib/index.js",
13
- "src": [
14
- "bin, lib",
12
+ "files": [
13
+ "README.md",
14
+ "lib/*",
15
+ "lib/dynamodb/**",
16
+ "lib/services/**",
15
17
  "package.json"
16
18
  ],
17
19
  "scripts": {
18
- "build": "run-p build:babel build:flow-copy-source build:license-checker",
20
+ "build": "yarn run build:babel && yarn run build:flow-copy-source && yarn run build:license-checker",
19
21
  "build:babel": "babel src --out-dir lib --ignore test.js",
20
22
  "build:flow-copy-source": "flow-copy-source --ignore test.js src lib",
21
23
  "build:license-checker": "license-checker --csv --out var/licenses.csv",
22
24
  "clean": "shx rm -rf lib",
25
+ "git:commit": "git add package.json .yarn/versions && git commit -m v${npm_package_version}",
26
+ "git:commit:publish": "git add package.json .yarn/versions/* && git commit -m v${npm_package_version}",
27
+ "git:commit:version": "git add .yarn/versions/* && git commit -m 'Deferred version bump'",
23
28
  "git:push": "git push --follow-tags",
24
- "publish:patch": "run-s version:patch git:push",
25
- "publish:minor": "run-s version:minor git:push",
26
- "publish:major": "run-s version:major git:push",
29
+ "git:tag": "git tag -a v${npm_package_version} -m v${npm_package_version}",
30
+ "npm:tag:remove": "yarn npm tag remove ${npm_package_name} $0",
31
+ "prepack": "yarn run build",
32
+ "prerelease": "yarn version apply && yarn run version:feature $0",
33
+ "publish:patch": "yarn version patch && yarn publish:sync",
34
+ "publish:minor": "yarn version minor && yarn publish:sync",
35
+ "publish:major": "yarn version major && yarn publish:sync",
36
+ "publish:prepatch": "yarn run version:prepatch && yarn run git:push",
37
+ "publish:prerelease": "yarn npm publish",
38
+ "publish:sync": "yarn run git:commit && yarn run git:tag && yarn git:push",
27
39
  "sites": "node bin/sites.js",
28
- "test": "run-p --aggregate-output test:**",
40
+ "test": "yarn run test:flow && yarn run test:jest && yarn run test:lint && yarn run test:prettier",
41
+ "test:flow": "yarn run test:flow:coverage-report && yarn run test:flow:status",
29
42
  "test:flow:coverage-report": "flow-coverage-report -i '{src,test}/**/*.js' -t html -t text --threshold 99 --output-dir var/coverage/flow",
30
43
  "test:flow:status": "flow status",
31
44
  "test:jest": "jest --color",
@@ -33,7 +46,10 @@
33
46
  "test:prettier": "prettier --list-different \"{src,test}/**/*.{js,jsx,yml}\" \"*.{js,yml}\"",
34
47
  "version:patch": "yarn version --new-version patch",
35
48
  "version:minor": "yarn version --new-version minor",
36
- "version:major": "yarn version --new-version major"
49
+ "version:major": "yarn version --new-version major",
50
+ "version:feature": "yarn version ${npm_package_version}-$0.$(git describe | rev | cut -d '-' -f 2 | rev).g$(git rev-parse --short HEAD)",
51
+ "version:prepatch": "yarn version --new-version prepatch",
52
+ "version:prerelease": "yarn version ${npm_package_version}"
37
53
  },
38
54
  "jest": {
39
55
  "verbose": true,
@@ -56,14 +72,15 @@
56
72
  "@cumulusds/flow-aws-lambda": "^1.0.0"
57
73
  },
58
74
  "devDependencies": {
59
- "@babel/cli": "^7.0.0",
75
+ "@babel/cli": "^7.22.15",
60
76
  "@babel/core": "^7.7.4",
61
77
  "@babel/plugin-proposal-nullish-coalescing-operator": "^7.7.4",
62
78
  "@babel/plugin-proposal-optional-chaining": "^7.12.7",
63
79
  "@babel/preset-env": "^7.0.0",
64
80
  "@babel/preset-flow": "^7.0.0",
65
81
  "@cumulusds/flow-aws-sdk": "^2.818.3",
66
- "aws-sdk": "^2.977.0",
82
+ "@cumulusds/flow-coverage-report": "^0.8.1",
83
+ "aws-sdk": "^2.1460.0",
67
84
  "babel-eslint": "10.0.3",
68
85
  "babel-jest": "^24.9.0",
69
86
  "eslint": "^7.5.0",
@@ -75,13 +92,13 @@
75
92
  "eslint-plugin-prettier": "^2.6.0",
76
93
  "flow-bin": "^0.142.0",
77
94
  "flow-copy-source": "^2.0.9",
78
- "flow-coverage-report": "^0.8.0",
79
- "flow-typed": "^3.2.1",
95
+ "flow-typed": "^3.9.0",
80
96
  "git-describe": "^4.0.4",
81
- "jest": "^26.0.0",
97
+ "jest": "^29.7.0",
82
98
  "license-checker": "^25.0.1",
83
- "npm-run-all": "^4.1.3",
84
99
  "prettier": "^1.14.0",
85
100
  "shx": "^0.3.2"
86
- }
87
- }
101
+ },
102
+ "packageManager": "yarn@3.5.0",
103
+ "stableVersion": "0.3.0"
104
+ }
package/.babelrc.js DELETED
@@ -1,15 +0,0 @@
1
- module.exports = {
2
- presets: [
3
- [
4
- "@babel/preset-env",
5
- {
6
- targets: {
7
- node: "10.15.0"
8
- },
9
- exclude: ["proposal-async-generator-functions"] // Do not transform async generator functions, since they are supported natively in Node 10 & 12.
10
- }
11
- ],
12
- "@babel/preset-flow"
13
- ],
14
- plugins: ["@babel/plugin-proposal-nullish-coalescing-operator", "@babel/plugin-proposal-optional-chaining"]
15
- };
package/.eslintrc.js DELETED
@@ -1,15 +0,0 @@
1
- module.exports = {
2
- extends: ["airbnb-base", "plugin:prettier/recommended", "plugin:flowtype/recommended"],
3
- rules: {
4
- "linebreak-style": "off",
5
- "no-console": "off",
6
- "no-restricted-syntax": "off"
7
- },
8
- plugins: ["jest", "flowtype"],
9
- env: {
10
- "jest/globals": true
11
- },
12
- parserOptions: {
13
- ecmaVersion: 2020
14
- }
15
- };
package/.flowconfig DELETED
@@ -1,12 +0,0 @@
1
- [ignore]
2
- <PROJECT_ROOT>/node_modules/config-chain/test/broken.json
3
- <PROJECT_ROOT>/node_modules/license-checker/tests/config/custom_format_broken.json
4
- <PROJECT_ROOT>/lib
5
-
6
- [libs]
7
- node_modules/@cumulusds/flow-aws-sdk/index.js
8
- node_modules/@cumulusds/flow-aws-sdk/clients
9
- node_modules/@cumulusds/flow-aws-sdk/lib
10
-
11
- [lints]
12
- all=error
@@ -1,15 +0,0 @@
1
- version: 2
2
-
3
- updates:
4
- - package-ecosystem: "github-actions"
5
- directory: "/"
6
- schedule:
7
- interval: "daily"
8
- time: "07:00"
9
- timezone: "America/New_York"
10
- labels:
11
- - "actions"
12
- assignees:
13
- - "jeffsays"
14
- reviewers:
15
- - "jeffsays"
@@ -1,18 +0,0 @@
1
- ## Summary
2
- What does this PR do?
3
-
4
- ## Dependencies
5
- - [Name of the change](https://link-to-PR-or-commit)
6
-
7
- ## Changes
8
- ### Interface
9
- - Is there a change to the package's interface?
10
-
11
- ### Developer
12
- - What are the other changes that are not directly visible to the user ?
13
-
14
- ## Details
15
- Why did you make this change? What does it affect?
16
-
17
- ## Testing
18
- How can the other reviewers check that your change works?
@@ -1,88 +0,0 @@
1
- name: ci-cd
2
-
3
- on:
4
- push:
5
- branches:
6
- - '**/*'
7
- pull_request:
8
- release:
9
- types: [released]
10
-
11
- jobs:
12
- unit:
13
- runs-on: ubuntu-18.04
14
- strategy:
15
- matrix:
16
- node: [10, 12, 13, 14, 15]
17
- steps:
18
- - name: Checkout
19
- uses: actions/checkout@v2
20
- - name: Install Node ${{ matrix.node }}
21
- uses: actions/setup-node@v2
22
- with:
23
- node-version: ${{ matrix.node }}
24
- - name: Install NPM credentials
25
- run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
26
- env:
27
- NPM_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
28
- - name: Get yarn cache
29
- id: yarn-cache
30
- run: echo "::set-output name=dir::$(yarn cache dir)"
31
- - name: Restore yarn cache
32
- uses: actions/cache@v2
33
- with:
34
- path: ${{ steps.yarn-cache.outputs.dir }}
35
- key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
36
- restore-keys: |
37
- ${{ runner.os }}-yarn-
38
- - name: Install NPM Packages
39
- run: yarn install --frozen-lockfile
40
- - name: Check licenses
41
- run: yarn build:license-checker
42
- - name: Test
43
- run: yarn test
44
- - uses: 8398a7/action-slack@v2
45
- with:
46
- status: ${{ job.status }}
47
- author_name: ${{ github.repository }} ${{ github.workflow }}
48
- env:
49
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50
- SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
51
- if: always()
52
- - name: Upload artifacts
53
- uses: actions/upload-artifact@v2
54
- with:
55
- name: var
56
- path: var
57
- if: always()
58
- publish:
59
- runs-on: ubuntu-18.04
60
- needs: unit
61
- if: github.event_name == 'release'
62
- steps:
63
- - name: Checkout
64
- uses: actions/checkout@v2
65
- - name: Install Node 14
66
- uses: actions/setup-node@v2
67
- with:
68
- node-version: 14
69
- - name: Install NPM credentials
70
- run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
71
- env:
72
- NPM_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
73
- - name: Get yarn cache
74
- id: yarn-cache
75
- run: echo "::set-output name=dir::$(yarn cache dir)"
76
- - name: Restore yarn cache
77
- uses: actions/cache@v2
78
- with:
79
- path: ${{ steps.yarn-cache.outputs.dir }}
80
- key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
81
- restore-keys: |
82
- ${{ runner.os }}-yarn-
83
- - name: Install NPM Packages
84
- run: yarn install --frozen-lockfile
85
- - name: Build
86
- run: yarn build
87
- - name: Publish
88
- run: npm publish
Binary file