Skip to content

Commit d2a33a9

Browse files
horiuchiPierre Lezan
andauthored
Support serverless-appsync-plugin v2 (#183)
feat: Support serverless-appsync-plugin v2 feat: Added support for Node 20 feat: Rewrite in TypeScript BREAKING CHANGE: Dropped support for serverless-appsync-plugin v1 BREAKING CHANGE: Dropped support for Node < 18 --------- Co-authored-by: Pierre Lezan <pierrelezan@gmail.com>
1 parent 1337fb4 commit d2a33a9

37 files changed

+6717
-4215
lines changed

.babelrc

Lines changed: 0 additions & 18 deletions
This file was deleted.

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

.eslintrc.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"root": true,
3+
"env": {
4+
"jest": true,
5+
"node": true,
6+
"es6": true
7+
},
8+
"parser": "@typescript-eslint/parser",
9+
"parserOptions": {
10+
"project": "./tsconfig_test.json"
11+
},
12+
"extends": [
13+
"eslint:recommended",
14+
"plugin:@typescript-eslint/recommended",
15+
"plugin:@typescript-eslint/recommended-requiring-type-checking",
16+
"prettier"
17+
],
18+
"plugins": ["@typescript-eslint", "import", "unused-imports"],
19+
"rules": {
20+
"prefer-const": "error",
21+
"no-var": "error",
22+
"no-console": "off",
23+
"sort-imports": "off",
24+
"import/order": [
25+
"error",
26+
{
27+
"alphabetize": {
28+
"order": "asc",
29+
"caseInsensitive": true
30+
}
31+
}
32+
],
33+
"class-methods-use-this": "error",
34+
"unused-imports/no-unused-imports": "error",
35+
"@typescript-eslint/ban-ts-comment": "off",
36+
"@typescript-eslint/no-unused-vars": "off"
37+
},
38+
"ignorePatterns": [
39+
"lib/**/*",
40+
"node_modules"
41+
]
42+
}

.eslintrc.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- master
7+
- beta
78

89
jobs:
910
publish:

.prettierrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
"tabWidth": 2,
33
"useTabs": false,
44
"singleQuote": true,
5-
"trailingComma": "all"
5+
"trailingComma": "all",
6+
"endOfLine": "auto"
67
}

jest.config.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { JestConfigWithTsJest } from 'ts-jest';
2+
3+
const config: JestConfigWithTsJest = {
4+
preset: 'ts-jest',
5+
testEnvironment: 'node',
6+
silent: true,
7+
moduleDirectories: ['node_modules', 'src'],
8+
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$'],
9+
};
10+
11+
export default config;

package.json

Lines changed: 44 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,46 +11,59 @@
1111
"url": "git+https://github.com/serverless-appsync/serverless-appsync-simulator.git"
1212
},
1313
"scripts": {
14-
"lint": "eslint src/*/**.js",
1514
"tests": "jest",
16-
"build": "babel src/ -d lib/ --delete-dir-on-start --ignore '**/__tests__'",
17-
"prepare": "yarn run build",
15+
"build": "tsc -p .",
16+
"watch": "yarn run build -w",
17+
"lint": "eslint . && tsc --noEmit",
18+
"prepare": "rm -rf lib && yarn run build",
1819
"start-dev": "yarn run build -w --verbose"
1920
},
2021
"files": [
2122
"/lib"
2223
],
2324
"dependencies": {
24-
"@graphql-tools/merge": "^8.2.1",
25-
"amplify-appsync-simulator": "^1.27.4",
26-
"amplify-nodejs-function-runtime-provider": "^1.1.6",
27-
"aws-sdk": "^2.792.0",
28-
"axios": "^0.21.0",
29-
"babel-jest": "^26.6.3",
30-
"bluebird": "^3.7.2",
31-
"cfn-resolver-lib": "^1.1.7",
32-
"dataloader": "^2.0.0",
33-
"fb-watchman": "^2.0.1",
34-
"globby": "^11.0.3",
35-
"jest": "^26.6.3",
36-
"lodash": "^4.17.20",
37-
"mysql2": "^2.2.5",
38-
"pg": "^8.6.0"
25+
"@graphql-tools/merge": "^8.4.0",
26+
"amplify-appsync-simulator": "^2.4.1",
27+
"amplify-nodejs-function-runtime-provider": "^2.3.13",
28+
"aws-sdk": "^2.1341.0",
29+
"axios": "^1.3.4",
30+
"cfn-resolver-lib": "^1.1.8",
31+
"dataloader": "^2.2.2",
32+
"fb-watchman": "^2.0.2",
33+
"globby": "^11.1.0",
34+
"graphql": "^16.6.0",
35+
"graphql-tools": "^8.3.19",
36+
"lodash": "^4.17.21",
37+
"mysql2": "^2.3.3",
38+
"pg": "^8.10.0",
39+
"ts-toolbelt": "^9.6.0"
3940
},
4041
"devDependencies": {
41-
"@babel/cli": "^7.12.1",
42-
"@babel/core": "^7.12.3",
43-
"@babel/plugin-transform-modules-commonjs": "^7.12.1",
44-
"@babel/preset-env": "^7.12.1",
45-
"@semantic-release/git": "^9.0.0",
46-
"all-contributors-cli": "^6.19.0",
47-
"babel-eslint": "^10.1.0",
48-
"babel-plugin-inline-import": "^3.0.0",
49-
"eslint": "^7.13.0",
50-
"eslint-config-prettier": "^7.0.0",
51-
"eslint-plugin-prettier": "^3.2.0",
52-
"prettier": "^2.2.1",
53-
"semantic-release": "19"
42+
"@semantic-release/git": "^10.0.1",
43+
"@serverless/typescript": "^3.27.0",
44+
"@types/fb-watchman": "^2.0.1",
45+
"@types/jest": "^29.5.0",
46+
"@types/lodash": "^4.14.191",
47+
"@types/node": "^16.18.18",
48+
"@types/pg": "^8.6.6",
49+
"@typescript-eslint/eslint-plugin": "^5.56.0",
50+
"@typescript-eslint/parser": "^5.56.0",
51+
"all-contributors-cli": "^6.24.0",
52+
"eslint": "^8.36.0",
53+
"eslint-config-prettier": "^8.8.0",
54+
"eslint-plugin-import": "^2.27.5",
55+
"eslint-plugin-prettier": "^4.2.1",
56+
"eslint-plugin-unused-imports": "^2.0.0",
57+
"jest": "^29.5.0",
58+
"prettier": "^2.8.6",
59+
"semantic-release": "^20.1.3",
60+
"serverless": "^3.28.1",
61+
"ts-jest": "^29.0.5",
62+
"ts-node": "^10.9.1",
63+
"typescript": "^4.9.5"
64+
},
65+
"peerDependencies": {
66+
"serverless": "3"
5467
},
5568
"keywords": [
5669
"serverless",
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`resolveConfiguration should generate a valid config 1`] = `
4+
{
5+
"additionalAuthentications": [
6+
{
7+
"config": {
8+
"userPoolId": "us-west-2_123456789",
9+
},
10+
"type": "AMAZON_COGNITO_USER_POOLS",
11+
},
12+
],
13+
"apiKeys": {
14+
"foo-bar": {
15+
"name": "foo-bar",
16+
},
17+
},
18+
"authentication": {
19+
"type": "API_KEY",
20+
},
21+
"dataSources": {
22+
"dynamodb": {
23+
"config": {
24+
"tableName": "myTable",
25+
},
26+
"name": "dynamodb",
27+
"type": "AMAZON_DYNAMODB",
28+
},
29+
"http": {
30+
"config": {
31+
"endpoint": "http://127.0.0.1",
32+
},
33+
"name": "http",
34+
"type": "HTTP",
35+
},
36+
"lambda": {
37+
"config": {
38+
"functionName": "resolver",
39+
},
40+
"name": "lambda",
41+
"type": "AWS_LAMBDA",
42+
},
43+
"none": {
44+
"name": "none",
45+
"type": "NONE",
46+
},
47+
},
48+
"name": "myAPI",
49+
"pipelineFunctions": {
50+
"func": {
51+
"dataSource": "lambda",
52+
"name": "func",
53+
"request": "src/__tests__/files/mapping-templates/templates.request.vtl",
54+
"response": "src/__tests__/files/mapping-templates/templates.response.vtl",
55+
"substitutions": {
56+
"mySubVar": "template-function",
57+
},
58+
},
59+
"funcDirect": {
60+
"dataSource": "lambda",
61+
"name": "funcDirect",
62+
},
63+
},
64+
"resolvers": {
65+
"Mutation.updateNode": {
66+
"dataSource": "lambda",
67+
"field": "updateNode",
68+
"kind": "UNIT",
69+
"type": "Mutation",
70+
},
71+
"Query.node": {
72+
"dataSource": "lambda",
73+
"field": "node",
74+
"kind": "UNIT",
75+
"type": "Query",
76+
},
77+
"Query.pipeline": {
78+
"field": "pipeline",
79+
"functions": [
80+
"func",
81+
"funcDirect",
82+
],
83+
"kind": "PIPELINE",
84+
"type": "Query",
85+
},
86+
"Query.templates": {
87+
"dataSource": "lambda",
88+
"field": "templates",
89+
"kind": "UNIT",
90+
"request": "src/__tests__/files/mapping-templates/templates.request.vtl",
91+
"response": "src/__tests__/files/mapping-templates/templates.response.vtl",
92+
"substitutions": {
93+
"mySubVar": "lambda",
94+
},
95+
"type": "Query",
96+
},
97+
},
98+
"schema": [
99+
"src/__tests__/files/*.graphql",
100+
],
101+
}
102+
`;
103+
104+
exports[`resolveConfiguration should generate a valid config 2`] = `
105+
{
106+
"apiKey": "0123456789",
107+
"dynamoDb": {
108+
"accessKeyId": "DEFAULT_ACCESS_KEY",
109+
"endpoint": "http://localhost:8000",
110+
"region": "localhost",
111+
"secretAccessKey": "DEFAULT_SECRET",
112+
},
113+
"getAttMap": {},
114+
"importValueMap": {},
115+
"lambdaPort": 3002,
116+
"location": ".",
117+
"openSearch": {},
118+
"port": 20002,
119+
"rds": {},
120+
"refMap": {},
121+
"watch": [
122+
"*.graphql",
123+
"*.vtl",
124+
],
125+
"wsPort": 20003,
126+
}
127+
`;

0 commit comments

Comments
 (0)