@aws-amplify/graphql-model-transformer 0.17.0-rds-support-preview1.0.0 → 0.17.0-rdsv2preview.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.
Files changed (53) hide show
  1. package/CHANGELOG.md +8 -1
  2. package/lib/graphql-model-transformer.d.ts.map +1 -1
  3. package/lib/graphql-model-transformer.js +12 -8
  4. package/lib/graphql-model-transformer.js.map +1 -1
  5. package/lib/rds-lambda.zip +0 -0
  6. package/lib/resolvers/generators/rds-vtl-generator.d.ts.map +1 -1
  7. package/lib/resolvers/generators/rds-vtl-generator.js +1 -1
  8. package/lib/resolvers/generators/rds-vtl-generator.js.map +1 -1
  9. package/lib/resolvers/rds/index.d.ts +1 -0
  10. package/lib/resolvers/rds/index.d.ts.map +1 -1
  11. package/lib/resolvers/rds/index.js +1 -0
  12. package/lib/resolvers/rds/index.js.map +1 -1
  13. package/lib/resolvers/rds/mutation.d.ts.map +1 -1
  14. package/lib/resolvers/rds/mutation.js +7 -2
  15. package/lib/resolvers/rds/mutation.js.map +1 -1
  16. package/lib/resolvers/rds/query.d.ts +2 -0
  17. package/lib/resolvers/rds/query.d.ts.map +1 -0
  18. package/lib/resolvers/rds/query.js +25 -0
  19. package/lib/resolvers/rds/query.js.map +1 -0
  20. package/lib/resolvers/rds/resolver.d.ts.map +1 -1
  21. package/lib/resolvers/rds/resolver.js +10 -9
  22. package/lib/resolvers/rds/resolver.js.map +1 -1
  23. package/package.json +7 -7
  24. package/rds-lambda/clients/DBClient.ts +3 -3
  25. package/rds-lambda/clients/mysql/MySQLClient.ts +54 -15
  26. package/rds-lambda/clients/mysql/MySQLPasswordClient.ts +4 -3
  27. package/rds-lambda/interfaces/BaseRequest.ts +2 -2
  28. package/rds-lambda/interfaces/ListRequest.ts +11 -0
  29. package/rds-lambda/node_modules/.package-lock.json +22 -14
  30. package/rds-lambda/node_modules/long/LICENSE +202 -202
  31. package/rds-lambda/node_modules/long/README.md +246 -280
  32. package/rds-lambda/node_modules/long/package.json +32 -43
  33. package/rds-lambda/node_modules/mysql2/README.md +2 -8
  34. package/rds-lambda/node_modules/mysql2/node_modules/lru-cache/LICENSE +1 -1
  35. package/rds-lambda/node_modules/mysql2/node_modules/lru-cache/README.md +102 -775
  36. package/rds-lambda/node_modules/mysql2/node_modules/lru-cache/package.json +9 -49
  37. package/rds-lambda/node_modules/mysql2/node_modules/yallist/LICENSE +15 -0
  38. package/rds-lambda/node_modules/mysql2/node_modules/yallist/README.md +204 -0
  39. package/rds-lambda/node_modules/mysql2/node_modules/yallist/package.json +29 -0
  40. package/rds-lambda/node_modules/mysql2/package.json +15 -21
  41. package/rds-lambda/package-lock.json +44 -28
  42. package/rds-lambda/package.json +1 -1
  43. package/rds-lambda/utils/rds_utils.ts +107 -0
  44. package/src/__tests__/model-transformer.test.ts +89 -1
  45. package/src/__tests__/test-utils/rds_utils.test.ts +299 -0
  46. package/src/graphql-model-transformer.ts +5 -1
  47. package/src/resolvers/generators/rds-vtl-generator.ts +2 -1
  48. package/src/resolvers/rds/index.ts +1 -0
  49. package/src/resolvers/rds/mutation.ts +7 -2
  50. package/src/resolvers/rds/query.ts +33 -0
  51. package/src/resolvers/rds/resolver.ts +25 -16
  52. package/tsconfig.tsbuildinfo +1 -1
  53. package/rds-lambda/node_modules/long/umd/package.json +0 -3
@@ -1,74 +1,34 @@
1
1
  {
2
2
  "name": "lru-cache",
3
3
  "description": "A cache object that deletes the least-recently-used items.",
4
- "version": "7.14.1",
4
+ "version": "6.0.0",
5
5
  "author": "Isaac Z. Schlueter <i@izs.me>",
6
6
  "keywords": [
7
7
  "mru",
8
8
  "lru",
9
9
  "cache"
10
10
  ],
11
- "sideEffects": false,
12
11
  "scripts": {
13
- "build": "",
14
- "size": "size-limit",
15
12
  "test": "tap",
16
13
  "snap": "tap",
17
14
  "preversion": "npm test",
18
15
  "postversion": "npm publish",
19
- "prepublishOnly": "git push origin --follow-tags",
20
- "format": "prettier --write ."
16
+ "prepublishOnly": "git push origin --follow-tags"
21
17
  },
22
18
  "main": "index.js",
23
19
  "repository": "git://github.com/isaacs/node-lru-cache.git",
24
20
  "devDependencies": {
25
- "@size-limit/preset-small-lib": "^7.0.8",
26
- "@types/node": "^17.0.31",
27
- "@types/tap": "^15.0.6",
28
21
  "benchmark": "^2.1.4",
29
- "c8": "^7.11.2",
30
- "clock-mock": "^1.0.6",
31
- "eslint-config-prettier": "^8.5.0",
32
- "prettier": "^2.6.2",
33
- "size-limit": "^7.0.8",
34
- "tap": "^16.0.1",
35
- "ts-node": "^10.7.0",
36
- "tslib": "^2.4.0",
37
- "typescript": "^4.6.4"
22
+ "tap": "^14.10.7"
38
23
  },
39
24
  "license": "ISC",
25
+ "dependencies": {
26
+ "yallist": "^4.0.0"
27
+ },
40
28
  "files": [
41
- "index.js",
42
- "index.d.ts"
29
+ "index.js"
43
30
  ],
44
31
  "engines": {
45
- "node": ">=12"
46
- },
47
- "prettier": {
48
- "semi": false,
49
- "printWidth": 70,
50
- "tabWidth": 2,
51
- "useTabs": false,
52
- "singleQuote": true,
53
- "jsxSingleQuote": false,
54
- "bracketSameLine": true,
55
- "arrowParens": "avoid",
56
- "endOfLine": "lf"
57
- },
58
- "tap": {
59
- "nyc-arg": [
60
- "--include=index.js"
61
- ],
62
- "node-arg": [
63
- "--expose-gc",
64
- "--require",
65
- "ts-node/register"
66
- ],
67
- "ts": false
68
- },
69
- "size-limit": [
70
- {
71
- "path": "./index.js"
72
- }
73
- ]
32
+ "node": ">=10"
33
+ }
74
34
  }
@@ -0,0 +1,15 @@
1
+ The ISC License
2
+
3
+ Copyright (c) Isaac Z. Schlueter and Contributors
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
15
+ IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
@@ -0,0 +1,204 @@
1
+ # yallist
2
+
3
+ Yet Another Linked List
4
+
5
+ There are many doubly-linked list implementations like it, but this
6
+ one is mine.
7
+
8
+ For when an array would be too big, and a Map can't be iterated in
9
+ reverse order.
10
+
11
+
12
+ [![Build Status](https://travis-ci.org/isaacs/yallist.svg?branch=master)](https://travis-ci.org/isaacs/yallist) [![Coverage Status](https://coveralls.io/repos/isaacs/yallist/badge.svg?service=github)](https://coveralls.io/github/isaacs/yallist)
13
+
14
+ ## basic usage
15
+
16
+ ```javascript
17
+ var yallist = require('yallist')
18
+ var myList = yallist.create([1, 2, 3])
19
+ myList.push('foo')
20
+ myList.unshift('bar')
21
+ // of course pop() and shift() are there, too
22
+ console.log(myList.toArray()) // ['bar', 1, 2, 3, 'foo']
23
+ myList.forEach(function (k) {
24
+ // walk the list head to tail
25
+ })
26
+ myList.forEachReverse(function (k, index, list) {
27
+ // walk the list tail to head
28
+ })
29
+ var myDoubledList = myList.map(function (k) {
30
+ return k + k
31
+ })
32
+ // now myDoubledList contains ['barbar', 2, 4, 6, 'foofoo']
33
+ // mapReverse is also a thing
34
+ var myDoubledListReverse = myList.mapReverse(function (k) {
35
+ return k + k
36
+ }) // ['foofoo', 6, 4, 2, 'barbar']
37
+
38
+ var reduced = myList.reduce(function (set, entry) {
39
+ set += entry
40
+ return set
41
+ }, 'start')
42
+ console.log(reduced) // 'startfoo123bar'
43
+ ```
44
+
45
+ ## api
46
+
47
+ The whole API is considered "public".
48
+
49
+ Functions with the same name as an Array method work more or less the
50
+ same way.
51
+
52
+ There's reverse versions of most things because that's the point.
53
+
54
+ ### Yallist
55
+
56
+ Default export, the class that holds and manages a list.
57
+
58
+ Call it with either a forEach-able (like an array) or a set of
59
+ arguments, to initialize the list.
60
+
61
+ The Array-ish methods all act like you'd expect. No magic length,
62
+ though, so if you change that it won't automatically prune or add
63
+ empty spots.
64
+
65
+ ### Yallist.create(..)
66
+
67
+ Alias for Yallist function. Some people like factories.
68
+
69
+ #### yallist.head
70
+
71
+ The first node in the list
72
+
73
+ #### yallist.tail
74
+
75
+ The last node in the list
76
+
77
+ #### yallist.length
78
+
79
+ The number of nodes in the list. (Change this at your peril. It is
80
+ not magic like Array length.)
81
+
82
+ #### yallist.toArray()
83
+
84
+ Convert the list to an array.
85
+
86
+ #### yallist.forEach(fn, [thisp])
87
+
88
+ Call a function on each item in the list.
89
+
90
+ #### yallist.forEachReverse(fn, [thisp])
91
+
92
+ Call a function on each item in the list, in reverse order.
93
+
94
+ #### yallist.get(n)
95
+
96
+ Get the data at position `n` in the list. If you use this a lot,
97
+ probably better off just using an Array.
98
+
99
+ #### yallist.getReverse(n)
100
+
101
+ Get the data at position `n`, counting from the tail.
102
+
103
+ #### yallist.map(fn, thisp)
104
+
105
+ Create a new Yallist with the result of calling the function on each
106
+ item.
107
+
108
+ #### yallist.mapReverse(fn, thisp)
109
+
110
+ Same as `map`, but in reverse.
111
+
112
+ #### yallist.pop()
113
+
114
+ Get the data from the list tail, and remove the tail from the list.
115
+
116
+ #### yallist.push(item, ...)
117
+
118
+ Insert one or more items to the tail of the list.
119
+
120
+ #### yallist.reduce(fn, initialValue)
121
+
122
+ Like Array.reduce.
123
+
124
+ #### yallist.reduceReverse
125
+
126
+ Like Array.reduce, but in reverse.
127
+
128
+ #### yallist.reverse
129
+
130
+ Reverse the list in place.
131
+
132
+ #### yallist.shift()
133
+
134
+ Get the data from the list head, and remove the head from the list.
135
+
136
+ #### yallist.slice([from], [to])
137
+
138
+ Just like Array.slice, but returns a new Yallist.
139
+
140
+ #### yallist.sliceReverse([from], [to])
141
+
142
+ Just like yallist.slice, but the result is returned in reverse.
143
+
144
+ #### yallist.toArray()
145
+
146
+ Create an array representation of the list.
147
+
148
+ #### yallist.toArrayReverse()
149
+
150
+ Create a reversed array representation of the list.
151
+
152
+ #### yallist.unshift(item, ...)
153
+
154
+ Insert one or more items to the head of the list.
155
+
156
+ #### yallist.unshiftNode(node)
157
+
158
+ Move a Node object to the front of the list. (That is, pull it out of
159
+ wherever it lives, and make it the new head.)
160
+
161
+ If the node belongs to a different list, then that list will remove it
162
+ first.
163
+
164
+ #### yallist.pushNode(node)
165
+
166
+ Move a Node object to the end of the list. (That is, pull it out of
167
+ wherever it lives, and make it the new tail.)
168
+
169
+ If the node belongs to a list already, then that list will remove it
170
+ first.
171
+
172
+ #### yallist.removeNode(node)
173
+
174
+ Remove a node from the list, preserving referential integrity of head
175
+ and tail and other nodes.
176
+
177
+ Will throw an error if you try to have a list remove a node that
178
+ doesn't belong to it.
179
+
180
+ ### Yallist.Node
181
+
182
+ The class that holds the data and is actually the list.
183
+
184
+ Call with `var n = new Node(value, previousNode, nextNode)`
185
+
186
+ Note that if you do direct operations on Nodes themselves, it's very
187
+ easy to get into weird states where the list is broken. Be careful :)
188
+
189
+ #### node.next
190
+
191
+ The next node in the list.
192
+
193
+ #### node.prev
194
+
195
+ The previous node in the list.
196
+
197
+ #### node.value
198
+
199
+ The data the node contains.
200
+
201
+ #### node.list
202
+
203
+ The list to which this node belongs. (Null if it does not belong to
204
+ any list.)
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "yallist",
3
+ "version": "4.0.0",
4
+ "description": "Yet Another Linked List",
5
+ "main": "yallist.js",
6
+ "directories": {
7
+ "test": "test"
8
+ },
9
+ "files": [
10
+ "yallist.js",
11
+ "iterator.js"
12
+ ],
13
+ "dependencies": {},
14
+ "devDependencies": {
15
+ "tap": "^12.1.0"
16
+ },
17
+ "scripts": {
18
+ "test": "tap test/*.js --100",
19
+ "preversion": "npm test",
20
+ "postversion": "npm publish",
21
+ "postpublish": "git push origin --all; git push origin --tags"
22
+ },
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/isaacs/yallist.git"
26
+ },
27
+ "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
28
+ "license": "ISC"
29
+ }
@@ -1,12 +1,11 @@
1
1
  {
2
2
  "name": "mysql2",
3
- "version": "3.1.2",
3
+ "version": "2.3.3",
4
4
  "description": "fast mysql driver. Implements core protocol, prepared statements, ssl and compression in native JS",
5
5
  "main": "index.js",
6
6
  "directories": {
7
7
  "example": "examples"
8
8
  },
9
- "typings": "typings/mysql/index",
10
9
  "scripts": {
11
10
  "lint": "npm run lint:docs && npm run lint:code",
12
11
  "lint:code": "eslint index.js promise.js \"lib/**/*.js\" \"test/**/*.js\" \"benchmarks/**/*.js\"",
@@ -18,8 +17,7 @@
18
17
  "prettier:docs": "prettier --single-quote --trailing-comma none --write README.md documentation/*",
19
18
  "precommit": "lint-staged",
20
19
  "eslint-check": "eslint --print-config .eslintrc | eslint-config-prettier-check",
21
- "wait-port": "wait-on",
22
- "type-test": "node ./node_modules/typescript/bin/tsc -p tests.json && mocha typings/test --timeout 10000"
20
+ "wait-port": "wait-on"
23
21
  },
24
22
  "lint-staged": {
25
23
  "*.js": [
@@ -38,7 +36,7 @@
38
36
  ],
39
37
  "files": [
40
38
  "lib",
41
- "typings/mysql",
39
+ "typings",
42
40
  "index.js",
43
41
  "index.d.ts",
44
42
  "promise.js",
@@ -55,33 +53,29 @@
55
53
  "author": "Andrey Sidorov <sidorares@yandex.ru>",
56
54
  "license": "MIT",
57
55
  "dependencies": {
58
- "denque": "^2.1.0",
56
+ "denque": "^2.0.1",
59
57
  "generate-function": "^2.3.1",
60
58
  "iconv-lite": "^0.6.3",
61
- "long": "^5.2.1",
62
- "lru-cache": "^7.14.1",
63
- "named-placeholders": "^1.1.3",
59
+ "long": "^4.0.0",
60
+ "lru-cache": "^6.0.0",
61
+ "named-placeholders": "^1.1.2",
64
62
  "seq-queue": "^0.0.5",
65
63
  "sqlstring": "^2.3.2"
66
64
  },
67
65
  "devDependencies": {
68
- "@types/chai": "^4.3.4",
69
- "@types/mocha": "^10.0.0",
70
- "@types/node": "^18.7.1",
71
- "@typescript-eslint/eslint-plugin": "^5.42.1",
72
- "@typescript-eslint/parser": "^5.42.1",
66
+ "@typescript-eslint/eslint-plugin": "^4.33.0",
67
+ "@typescript-eslint/parser": "^4.33.0",
73
68
  "assert-diff": "^3.0.2",
74
69
  "benchmark": "^2.1.4",
75
70
  "c8": "^7.10.0",
76
- "chai": "^4.3.7",
77
71
  "error-stack-parser": "^2.0.3",
78
- "eslint": "^8.27.0",
79
- "eslint-config-prettier": "^8.5.0",
72
+ "eslint": "^7.32.0",
73
+ "eslint-config-prettier": "^8.3.0",
80
74
  "eslint-plugin-async-await": "0.0.0",
81
- "eslint-plugin-markdown": "^3.0.0",
82
- "husky": "^8.0.2",
83
- "lint-staged": "^13.0.3",
84
- "mocha": "^10.0.0",
75
+ "eslint-plugin-markdown": "^2.2.1",
76
+ "husky": "^7.0.2",
77
+ "is-async-supported": "^1.2.0",
78
+ "lint-staged": "^11.2.0",
85
79
  "portfinder": "^1.0.28",
86
80
  "prettier": "^2.4.1",
87
81
  "progress": "^2.0.3",
@@ -9,7 +9,7 @@
9
9
  "babel-jest": "^29.1.2",
10
10
  "jest": "^29.1.2",
11
11
  "knex": "^2.3.0",
12
- "mysql2": "^3.1.0",
12
+ "mysql2": "2.3.3",
13
13
  "pg": "^8.8.0",
14
14
  "ts-jest": "^29.0.3",
15
15
  "uuid": "^9.0.0"
@@ -4884,9 +4884,9 @@
4884
4884
  "integrity": "sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag=="
4885
4885
  },
4886
4886
  "node_modules/long": {
4887
- "version": "5.2.1",
4888
- "resolved": "https://registry.npmjs.org/long/-/long-5.2.1.tgz",
4889
- "integrity": "sha512-GKSNGeNAtw8IryjjkhZxuKB3JzlcLTwjtiQCHKvqQet81I93kXslhDQruGI/QsddO83mcDToBVy7GqGS/zYf/A=="
4887
+ "version": "4.0.0",
4888
+ "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz",
4889
+ "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA=="
4890
4890
  },
4891
4891
  "node_modules/lru-cache": {
4892
4892
  "version": "5.1.1",
@@ -4965,16 +4965,16 @@
4965
4965
  "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
4966
4966
  },
4967
4967
  "node_modules/mysql2": {
4968
- "version": "3.1.2",
4969
- "resolved": "https://registry.npmjs.org/mysql2/-/mysql2-3.1.2.tgz",
4970
- "integrity": "sha512-NXz6sUvHSEOKz1jv3koSga7eb2dHrwD/mnPmqbbZzMRvjQcSpb0Eh0ectWyYt1U60CLlEbjoA3XYjjbbReRF5Q==",
4968
+ "version": "2.3.3",
4969
+ "resolved": "https://registry.npmjs.org/mysql2/-/mysql2-2.3.3.tgz",
4970
+ "integrity": "sha512-wxJUev6LgMSgACDkb/InIFxDprRa6T95+VEoR+xPvtngtccNH2dGjEB/fVZ8yg1gWv1510c9CvXuJHi5zUm0ZA==",
4971
4971
  "dependencies": {
4972
- "denque": "^2.1.0",
4972
+ "denque": "^2.0.1",
4973
4973
  "generate-function": "^2.3.1",
4974
4974
  "iconv-lite": "^0.6.3",
4975
- "long": "^5.2.1",
4976
- "lru-cache": "^7.14.1",
4977
- "named-placeholders": "^1.1.3",
4975
+ "long": "^4.0.0",
4976
+ "lru-cache": "^6.0.0",
4977
+ "named-placeholders": "^1.1.2",
4978
4978
  "seq-queue": "^0.0.5",
4979
4979
  "sqlstring": "^2.3.2"
4980
4980
  },
@@ -4983,13 +4983,21 @@
4983
4983
  }
4984
4984
  },
4985
4985
  "node_modules/mysql2/node_modules/lru-cache": {
4986
- "version": "7.14.1",
4987
- "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.14.1.tgz",
4988
- "integrity": "sha512-ysxwsnTKdAx96aTRdhDOCQfDgbHnt8SK0KY8SEjO0wHinhWOFTESbjVCMPbU1uGXg/ch4lifqx0wfjOawU2+WA==",
4986
+ "version": "6.0.0",
4987
+ "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
4988
+ "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
4989
+ "dependencies": {
4990
+ "yallist": "^4.0.0"
4991
+ },
4989
4992
  "engines": {
4990
- "node": ">=12"
4993
+ "node": ">=10"
4991
4994
  }
4992
4995
  },
4996
+ "node_modules/mysql2/node_modules/yallist": {
4997
+ "version": "4.0.0",
4998
+ "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
4999
+ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A=="
5000
+ },
4993
5001
  "node_modules/named-placeholders": {
4994
5002
  "version": "1.1.3",
4995
5003
  "resolved": "https://registry.npmjs.org/named-placeholders/-/named-placeholders-1.1.3.tgz",
@@ -9611,9 +9619,9 @@
9611
9619
  "integrity": "sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag=="
9612
9620
  },
9613
9621
  "long": {
9614
- "version": "5.2.1",
9615
- "resolved": "https://registry.npmjs.org/long/-/long-5.2.1.tgz",
9616
- "integrity": "sha512-GKSNGeNAtw8IryjjkhZxuKB3JzlcLTwjtiQCHKvqQet81I93kXslhDQruGI/QsddO83mcDToBVy7GqGS/zYf/A=="
9622
+ "version": "4.0.0",
9623
+ "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz",
9624
+ "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA=="
9617
9625
  },
9618
9626
  "lru-cache": {
9619
9627
  "version": "5.1.1",
@@ -9677,24 +9685,32 @@
9677
9685
  "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
9678
9686
  },
9679
9687
  "mysql2": {
9680
- "version": "3.1.2",
9681
- "resolved": "https://registry.npmjs.org/mysql2/-/mysql2-3.1.2.tgz",
9682
- "integrity": "sha512-NXz6sUvHSEOKz1jv3koSga7eb2dHrwD/mnPmqbbZzMRvjQcSpb0Eh0ectWyYt1U60CLlEbjoA3XYjjbbReRF5Q==",
9688
+ "version": "2.3.3",
9689
+ "resolved": "https://registry.npmjs.org/mysql2/-/mysql2-2.3.3.tgz",
9690
+ "integrity": "sha512-wxJUev6LgMSgACDkb/InIFxDprRa6T95+VEoR+xPvtngtccNH2dGjEB/fVZ8yg1gWv1510c9CvXuJHi5zUm0ZA==",
9683
9691
  "requires": {
9684
- "denque": "^2.1.0",
9692
+ "denque": "^2.0.1",
9685
9693
  "generate-function": "^2.3.1",
9686
9694
  "iconv-lite": "^0.6.3",
9687
- "long": "^5.2.1",
9688
- "lru-cache": "^7.14.1",
9689
- "named-placeholders": "^1.1.3",
9695
+ "long": "^4.0.0",
9696
+ "lru-cache": "^6.0.0",
9697
+ "named-placeholders": "^1.1.2",
9690
9698
  "seq-queue": "^0.0.5",
9691
9699
  "sqlstring": "^2.3.2"
9692
9700
  },
9693
9701
  "dependencies": {
9694
9702
  "lru-cache": {
9695
- "version": "7.14.1",
9696
- "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.14.1.tgz",
9697
- "integrity": "sha512-ysxwsnTKdAx96aTRdhDOCQfDgbHnt8SK0KY8SEjO0wHinhWOFTESbjVCMPbU1uGXg/ch4lifqx0wfjOawU2+WA=="
9703
+ "version": "6.0.0",
9704
+ "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
9705
+ "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
9706
+ "requires": {
9707
+ "yallist": "^4.0.0"
9708
+ }
9709
+ },
9710
+ "yallist": {
9711
+ "version": "4.0.0",
9712
+ "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
9713
+ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A=="
9698
9714
  }
9699
9715
  }
9700
9716
  },
@@ -10,7 +10,7 @@
10
10
  "babel-jest": "^29.1.2",
11
11
  "jest": "^29.1.2",
12
12
  "knex": "^2.3.0",
13
- "mysql2": "^3.1.0",
13
+ "mysql2": "2.3.3",
14
14
  "pg": "^8.8.0",
15
15
  "ts-jest": "^29.0.3",
16
16
  "uuid": "^9.0.0"
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Util method to convert any GraphQL input filter argument to an AWS RDS query expression
3
+ */
4
+ export const toRDSQueryExpression = (filter: any) => {
5
+ let rdsExpression = '';
6
+ let isAndAppended = false;
7
+ Object.entries(filter).forEach(([key, value]: any, index) => {
8
+ if(index != 0) {
9
+ rdsExpression += ` AND `;
10
+ isAndAppended = true;
11
+ }
12
+ switch(key) {
13
+ case 'and':
14
+ case 'or':
15
+ rdsExpression += value.map(toRDSQueryExpression).join(` ${key.toUpperCase()} `);
16
+ break;
17
+ case 'not':
18
+ rdsExpression += `NOT ${toRDSQueryExpression(value)}`;
19
+ break;
20
+ default:
21
+ Object.entries(value).forEach(([operator, operand]: any, secondIndex) => {
22
+ if(secondIndex != 0) {
23
+ rdsExpression += ` AND `;
24
+ }
25
+ switch(operator) {
26
+ case 'attributeExists':
27
+ rdsExpression += `${key} IS NOT NULL`;
28
+ break;
29
+ case 'beginsWith':
30
+ rdsExpression += `${key} LIKE '${operand}%'`;
31
+ break;
32
+ case 'between':
33
+ if (!Array.isArray(operand) || operand.length !== 2) {
34
+ throw new Error(`between condition must have two values, but got: ${operand}.length`);
35
+ }
36
+ rdsExpression += `${key} BETWEEN '${operand[0]}' AND '${operand[1]}'`;
37
+ break;
38
+ case 'contains':
39
+ rdsExpression += `${key} LIKE '%${operand}%'`;
40
+ break;
41
+ case 'eq':
42
+ rdsExpression += `${key} = '${operand}'`;
43
+ break;
44
+ case 'ge':
45
+ rdsExpression += `${key} >= '${operand}'`;
46
+ break;
47
+ case 'gt':
48
+ rdsExpression += `${key} > '${operand}'`;
49
+ break;
50
+ case 'le':
51
+ rdsExpression += `${key} <= '${operand}'`;
52
+ break;
53
+ case 'lt':
54
+ rdsExpression += `${key} < '${operand}'`;
55
+ break;
56
+ case 'ne':
57
+ rdsExpression += `${key} != '${operand}'`;
58
+ break;
59
+ case 'notContains':
60
+ // key : name , operand : 'a' , operator : notContains
61
+ rdsExpression += `${key} NOT LIKE '%${operand}%'`;
62
+ break;
63
+ case 'size':
64
+ // size has nested operators:- between, eq, ge, gt, le, lt, ne
65
+ Object.entries(operand).forEach(([sizeOperator, sizeOperand]: any) => {
66
+ if(index != 0 && !isAndAppended) {
67
+ rdsExpression += ` AND `;
68
+ isAndAppended = true;
69
+ }
70
+ switch(sizeOperator) {
71
+ case 'between':
72
+ if (!Array.isArray(sizeOperand) || sizeOperand.length !== 2) {
73
+ throw new Error(`between condition must have two values, but got: ${sizeOperand}.length`);
74
+ }
75
+ rdsExpression += `LENGTH (${key}) BETWEEN '${sizeOperand[0]}' AND '${sizeOperand[1]}'`;
76
+ break;
77
+ case 'eq':
78
+ rdsExpression += `LENGTH (${key}) = '${sizeOperand}'`;
79
+ break;
80
+ case 'ge':
81
+ rdsExpression += `LENGTH (${key}) >= '${sizeOperand}'`;
82
+ break;
83
+ case 'gt':
84
+ rdsExpression += `LENGTH (${key}) > '${sizeOperand}'`;
85
+ break;
86
+ case 'le':
87
+ rdsExpression += `LENGTH (${key}) <= '${sizeOperand}'`;
88
+ break;
89
+ case 'lt':
90
+ rdsExpression += `LENGTH (${key}) < '${sizeOperand}'`;
91
+ break;
92
+ case 'ne':
93
+ rdsExpression += `LENGTH (${key}) != '${sizeOperand}'`;
94
+ break;
95
+ default:
96
+ console.log(`Unsupported operator: ${sizeOperator}`);
97
+ }
98
+ });
99
+ break;
100
+ default:
101
+ console.log(`Unsupported operator: ${operator}`);
102
+ }
103
+ });
104
+ }
105
+ });
106
+ return `(${rdsExpression})`;
107
+ };