@ttoss/lambda-postgres-query 0.3.1 → 0.3.3
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.
- package/dist/cloudformation/index.js +12 -0
- package/dist/esm/cloudformation/index.js +12 -0
- package/dist/esm/index.js +7 -3
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +7 -3
- package/package.json +8 -8
|
@@ -163,6 +163,18 @@ var createLambdaPostgresQueryTemplate = ({
|
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
|
+
},
|
|
167
|
+
LambdaQueryFunctionLogs: {
|
|
168
|
+
Type: "AWS::Logs::LogGroup",
|
|
169
|
+
DependsOn: "LambdaQueryFunction",
|
|
170
|
+
Properties: {
|
|
171
|
+
LogGroupName: {
|
|
172
|
+
"Fn::Join": ["", ["/aws/lambda/", {
|
|
173
|
+
Ref: "LambdaQueryFunction"
|
|
174
|
+
}]]
|
|
175
|
+
},
|
|
176
|
+
RetentionInDays: 7
|
|
177
|
+
}
|
|
166
178
|
}
|
|
167
179
|
},
|
|
168
180
|
Outputs: {
|
|
@@ -128,6 +128,18 @@ var createLambdaPostgresQueryTemplate = ({
|
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
+
},
|
|
132
|
+
LambdaQueryFunctionLogs: {
|
|
133
|
+
Type: "AWS::Logs::LogGroup",
|
|
134
|
+
DependsOn: "LambdaQueryFunction",
|
|
135
|
+
Properties: {
|
|
136
|
+
LogGroupName: {
|
|
137
|
+
"Fn::Join": ["", ["/aws/lambda/", {
|
|
138
|
+
Ref: "LambdaQueryFunction"
|
|
139
|
+
}]]
|
|
140
|
+
},
|
|
141
|
+
RetentionInDays: 7
|
|
142
|
+
}
|
|
131
143
|
}
|
|
132
144
|
},
|
|
133
145
|
Outputs: {
|
package/dist/esm/index.js
CHANGED
|
@@ -4,13 +4,14 @@
|
|
|
4
4
|
import { InvokeCommand, LambdaClient } from "@aws-sdk/client-lambda";
|
|
5
5
|
import camelcaseKeys from "camelcase-keys";
|
|
6
6
|
var lambdaClient = new LambdaClient();
|
|
7
|
-
var
|
|
7
|
+
var textDecoder = new TextDecoder("utf-8");
|
|
8
8
|
var query = async params => {
|
|
9
9
|
try {
|
|
10
10
|
const {
|
|
11
11
|
readOnly = true,
|
|
12
12
|
// eslint-disable-next-line turbo/no-undeclared-env-vars
|
|
13
13
|
lambdaPostgresQueryFunction = process.env.LAMBDA_POSTGRES_QUERY_FUNCTION,
|
|
14
|
+
camelCaseKeys = true,
|
|
14
15
|
...pgParams
|
|
15
16
|
} = typeof params === "string" ? {
|
|
16
17
|
text: params
|
|
@@ -31,14 +32,17 @@ var query = async params => {
|
|
|
31
32
|
});
|
|
32
33
|
throw new Error("No payload returned from lambda query");
|
|
33
34
|
}
|
|
34
|
-
const data =
|
|
35
|
+
const data = textDecoder.decode(Payload);
|
|
35
36
|
const result = JSON.parse(data);
|
|
36
37
|
if ("errorType" in result) {
|
|
37
|
-
throw result;
|
|
38
|
+
throw new Error(result.errorMessage);
|
|
38
39
|
}
|
|
39
40
|
return {
|
|
40
41
|
...result,
|
|
41
42
|
rows: result.rows.map(row => {
|
|
43
|
+
if (!camelCaseKeys) {
|
|
44
|
+
return row;
|
|
45
|
+
}
|
|
42
46
|
return {
|
|
43
47
|
...row,
|
|
44
48
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -46,13 +46,14 @@ module.exports = __toCommonJS(index_exports);
|
|
|
46
46
|
var import_client_lambda = require("@aws-sdk/client-lambda");
|
|
47
47
|
var import_camelcase_keys = __toESM(require("camelcase-keys"), 1);
|
|
48
48
|
var lambdaClient = new import_client_lambda.LambdaClient();
|
|
49
|
-
var
|
|
49
|
+
var textDecoder = new TextDecoder("utf-8");
|
|
50
50
|
var query = async params => {
|
|
51
51
|
try {
|
|
52
52
|
const {
|
|
53
53
|
readOnly = true,
|
|
54
54
|
// eslint-disable-next-line turbo/no-undeclared-env-vars
|
|
55
55
|
lambdaPostgresQueryFunction = process.env.LAMBDA_POSTGRES_QUERY_FUNCTION,
|
|
56
|
+
camelCaseKeys = true,
|
|
56
57
|
...pgParams
|
|
57
58
|
} = typeof params === "string" ? {
|
|
58
59
|
text: params
|
|
@@ -73,14 +74,17 @@ var query = async params => {
|
|
|
73
74
|
});
|
|
74
75
|
throw new Error("No payload returned from lambda query");
|
|
75
76
|
}
|
|
76
|
-
const data =
|
|
77
|
+
const data = textDecoder.decode(Payload);
|
|
77
78
|
const result = JSON.parse(data);
|
|
78
79
|
if ("errorType" in result) {
|
|
79
|
-
throw result;
|
|
80
|
+
throw new Error(result.errorMessage);
|
|
80
81
|
}
|
|
81
82
|
return {
|
|
82
83
|
...result,
|
|
83
84
|
rows: result.rows.map(row => {
|
|
85
|
+
if (!camelCaseKeys) {
|
|
86
|
+
return row;
|
|
87
|
+
}
|
|
84
88
|
return {
|
|
85
89
|
...row,
|
|
86
90
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/lambda-postgres-query",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "Create a Lambda function that queries a PostgreSQL database.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "ttoss",
|
|
@@ -29,19 +29,19 @@
|
|
|
29
29
|
"dist"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@aws-sdk/client-lambda": "^3.
|
|
32
|
+
"@aws-sdk/client-lambda": "^3.731.1",
|
|
33
33
|
"camelcase-keys": "^7.0.2",
|
|
34
|
-
"pg": "^8.
|
|
35
|
-
"@ttoss/cloudformation": "^0.10.
|
|
34
|
+
"pg": "^8.13.1",
|
|
35
|
+
"@ttoss/cloudformation": "^0.10.16"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/jest": "^29.5.14",
|
|
39
|
-
"@types/pg": "^8.11.
|
|
40
|
-
"aws-sdk-client-mock": "^4.0
|
|
39
|
+
"@types/pg": "^8.11.10",
|
|
40
|
+
"aws-sdk-client-mock": "^4.1.0",
|
|
41
41
|
"jest": "^29.7.0",
|
|
42
42
|
"tsup": "^8.3.5",
|
|
43
|
-
"@ttoss/
|
|
44
|
-
"@ttoss/
|
|
43
|
+
"@ttoss/test-utils": "^2.1.22",
|
|
44
|
+
"@ttoss/config": "^1.35.2"
|
|
45
45
|
},
|
|
46
46
|
"keywords": [
|
|
47
47
|
"aws",
|