@fintalk.ai/lambda-handlers 1.0.4 → 2.1.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/README.md +62 -20
- package/lib/errors/bad-request-error.d.ts +1 -1
- package/lib/errors/bad-request-error.js +3 -2
- package/lib/errors/bad-request-error.js.map +1 -1
- package/lib/errors/conflict-error.d.ts +1 -1
- package/lib/errors/conflict-error.js +4 -2
- package/lib/errors/conflict-error.js.map +1 -1
- package/lib/errors/fintalk-error.d.ts +11 -6
- package/lib/errors/fintalk-error.js +3 -2
- package/lib/errors/fintalk-error.js.map +1 -1
- package/lib/errors/forbidden-error.d.ts +1 -1
- package/lib/errors/forbidden-error.js +4 -2
- package/lib/errors/forbidden-error.js.map +1 -1
- package/lib/errors/gone-error.d.ts +1 -1
- package/lib/errors/gone-error.js +4 -2
- package/lib/errors/gone-error.js.map +1 -1
- package/lib/errors/internal-server-error.d.ts +1 -1
- package/lib/errors/internal-server-error.js +4 -2
- package/lib/errors/internal-server-error.js.map +1 -1
- package/lib/errors/not-acceptable-error.d.ts +1 -1
- package/lib/errors/not-acceptable-error.js +4 -2
- package/lib/errors/not-acceptable-error.js.map +1 -1
- package/lib/errors/not-found-error.d.ts +1 -1
- package/lib/errors/not-found-error.js +4 -2
- package/lib/errors/not-found-error.js.map +1 -1
- package/lib/errors/payment-required-error.d.ts +1 -1
- package/lib/errors/payment-required-error.js +4 -2
- package/lib/errors/payment-required-error.js.map +1 -1
- package/lib/errors/precondition-failed-error.d.ts +1 -1
- package/lib/errors/precondition-failed-error.js +4 -2
- package/lib/errors/precondition-failed-error.js.map +1 -1
- package/lib/errors/service-unavailable-error.d.ts +1 -1
- package/lib/errors/service-unavailable-error.js +4 -2
- package/lib/errors/service-unavailable-error.js.map +1 -1
- package/lib/errors/teapot-error.d.ts +1 -1
- package/lib/errors/teapot-error.js +4 -2
- package/lib/errors/teapot-error.js.map +1 -1
- package/lib/errors/too-many-requests-error.d.ts +1 -1
- package/lib/errors/too-many-requests-error.js +4 -2
- package/lib/errors/too-many-requests-error.js.map +1 -1
- package/lib/errors/unauthorized-error.d.ts +1 -1
- package/lib/errors/unauthorized-error.js +4 -2
- package/lib/errors/unauthorized-error.js.map +1 -1
- package/lib/errors/unprocessable-entity-error.d.ts +1 -1
- package/lib/errors/unprocessable-entity-error.js +4 -3
- package/lib/errors/unprocessable-entity-error.js.map +1 -1
- package/lib/errors/websocket-error.d.ts +40 -0
- package/lib/errors/websocket-error.js +54 -0
- package/lib/errors/websocket-error.js.map +1 -0
- package/lib/handlers/api-proxy.js +150 -56
- package/lib/handlers/api-proxy.js.map +1 -1
- package/lib/handlers/api.d.ts +5 -1
- package/lib/handlers/api.js +130 -38
- package/lib/handlers/api.js.map +1 -1
- package/lib/handlers/authorizer.d.ts +7 -0
- package/lib/handlers/authorizer.js +181 -0
- package/lib/handlers/authorizer.js.map +1 -0
- package/lib/handlers/cloudwatch.d.ts +7 -0
- package/lib/handlers/cloudwatch.js +143 -0
- package/lib/handlers/cloudwatch.js.map +1 -0
- package/lib/handlers/invoke.d.ts +7 -1
- package/lib/handlers/invoke.js +101 -26
- package/lib/handlers/invoke.js.map +1 -1
- package/lib/handlers/kinesis.d.ts +13 -0
- package/lib/handlers/kinesis.js +193 -0
- package/lib/handlers/kinesis.js.map +1 -0
- package/lib/handlers/lambda-proxy/index.d.ts +8 -0
- package/lib/handlers/lambda-proxy/index.js +182 -0
- package/lib/handlers/lambda-proxy/index.js.map +1 -0
- package/lib/handlers/lambda-proxy/validate-event-data.d.ts +3 -0
- package/lib/handlers/lambda-proxy/validate-event-data.js +26 -0
- package/lib/handlers/lambda-proxy/validate-event-data.js.map +1 -0
- package/lib/handlers/sqs-v2.d.ts +5 -3
- package/lib/handlers/sqs-v2.js +110 -22
- package/lib/handlers/sqs-v2.js.map +1 -1
- package/lib/handlers/sqs.d.ts +11 -2
- package/lib/handlers/sqs.js +119 -16
- package/lib/handlers/sqs.js.map +1 -1
- package/lib/index.d.ts +4 -0
- package/lib/index.js +9 -1
- package/lib/index.js.map +1 -1
- package/lib/models.d.ts +9 -2
- package/lib/utils/check-envs.d.ts +3 -0
- package/lib/utils/check-envs.js +14 -0
- package/lib/utils/check-envs.js.map +1 -0
- package/lib/utils/convert-query-string.d.ts +3 -0
- package/lib/utils/convert-query-string.js +18 -0
- package/lib/utils/convert-query-string.js.map +1 -0
- package/lib/utils/extract-queue-name.d.ts +2 -0
- package/lib/utils/extract-queue-name.js +9 -0
- package/lib/utils/extract-queue-name.js.map +1 -0
- package/lib/utils/find-path.d.ts +2 -0
- package/lib/utils/find-path.js +14 -0
- package/lib/utils/find-path.js.map +1 -0
- package/lib/utils/kinesis-parse.d.ts +2 -0
- package/lib/utils/kinesis-parse.js +14 -0
- package/lib/utils/kinesis-parse.js.map +1 -0
- package/lib/utils/lower-case-headers.d.ts +2 -2
- package/lib/utils/lower-case-headers.js.map +1 -1
- package/lib/utils/parse-authorizer-request.d.ts +4 -0
- package/lib/utils/parse-authorizer-request.js +32 -0
- package/lib/utils/parse-authorizer-request.js.map +1 -0
- package/lib/utils/parse-path-params.d.ts +2 -0
- package/lib/utils/parse-path-params.js +14 -0
- package/lib/utils/parse-path-params.js.map +1 -0
- package/lib/utils/parse-request.d.ts +0 -1
- package/lib/utils/parse-request.js +3 -12
- package/lib/utils/parse-request.js.map +1 -1
- package/lib/utils/provider-flush.d.ts +4 -0
- package/lib/utils/provider-flush.js +81 -0
- package/lib/utils/provider-flush.js.map +1 -0
- package/lib/utils/sleep.d.ts +2 -0
- package/lib/utils/sleep.js +7 -0
- package/lib/utils/sleep.js.map +1 -0
- package/package.json +26 -34
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.tryParseFloat = void 0;
|
|
43
|
+
var fintalk_logger_1 = __importDefault(require("fintalk-logger"));
|
|
44
|
+
var tryParseFloat = function (defaultValue, value) {
|
|
45
|
+
if (!value) {
|
|
46
|
+
return defaultValue;
|
|
47
|
+
}
|
|
48
|
+
var result = parseFloat(value);
|
|
49
|
+
if (isNaN(result)) {
|
|
50
|
+
return defaultValue;
|
|
51
|
+
}
|
|
52
|
+
return result;
|
|
53
|
+
};
|
|
54
|
+
exports.tryParseFloat = tryParseFloat;
|
|
55
|
+
var providerFlush = function (tracerProvider, timeout) { return __awaiter(void 0, void 0, void 0, function () {
|
|
56
|
+
var tms;
|
|
57
|
+
return __generator(this, function (_a) {
|
|
58
|
+
tms = timeout !== null && timeout !== void 0 ? timeout : (0, exports.tryParseFloat)(200, process.env.OTLP_TIMEOUT);
|
|
59
|
+
return [2, new Promise(function (resolve) {
|
|
60
|
+
var t = setTimeout(function () {
|
|
61
|
+
fintalk_logger_1.default.error({
|
|
62
|
+
message: 'Tracer provider timeout',
|
|
63
|
+
});
|
|
64
|
+
resolve();
|
|
65
|
+
}, tms);
|
|
66
|
+
tracerProvider
|
|
67
|
+
.forceFlush()
|
|
68
|
+
.catch(function (error) {
|
|
69
|
+
fintalk_logger_1.default.error({
|
|
70
|
+
message: 'Tracer provider error',
|
|
71
|
+
error_message: error.message,
|
|
72
|
+
});
|
|
73
|
+
}).finally(function () {
|
|
74
|
+
clearTimeout(t);
|
|
75
|
+
resolve();
|
|
76
|
+
});
|
|
77
|
+
})];
|
|
78
|
+
});
|
|
79
|
+
}); };
|
|
80
|
+
exports.default = providerFlush;
|
|
81
|
+
//# sourceMappingURL=provider-flush.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-flush.js","sourceRoot":"","sources":["../../src/utils/provider-flush.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,kEAAmC;AAE5B,IAAM,aAAa,GAAG,UAAC,YAAoB,EAAE,KAAc;IAChE,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,YAAY,CAAA;KACpB;IAED,IAAM,MAAM,GAAG,UAAU,CAAC,KAAK,CAAC,CAAA;IAEhC,IAAI,KAAK,CAAC,MAAM,CAAC,EAAE;QACjB,OAAO,YAAY,CAAA;KACpB;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAZY,QAAA,aAAa,iBAYzB;AAED,IAAM,aAAa,GAAG,UACpB,cAAkC,EAClC,OAAgB;;;QAEV,GAAG,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,IAAA,qBAAa,EAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;QAEnE,WAAO,IAAI,OAAO,CAAC,UAAC,OAAO;gBACzB,IAAM,CAAC,GAAG,UAAU,CAAC;oBACnB,wBAAM,CAAC,KAAK,CAAC;wBACX,OAAO,EAAE,yBAAyB;qBACnC,CAAC,CAAA;oBAEF,OAAO,EAAE,CAAA;gBACX,CAAC,EAAE,GAAG,CAAC,CAAA;gBAEP,cAAc;qBACX,UAAU,EAAE;qBACZ,KAAK,CAAC,UAAC,KAAU;oBAChB,wBAAM,CAAC,KAAK,CAAC;wBACX,OAAO,EAAE,uBAAuB;wBAChC,aAAa,EAAE,KAAK,CAAC,OAAO;qBAC7B,CAAC,CAAA;gBACJ,CAAC,CAAC,CAAC,OAAO,CAAC;oBACT,YAAY,CAAC,CAAC,CAAC,CAAA;oBACf,OAAO,EAAE,CAAA;gBACX,CAAC,CAAC,CAAA;YACN,CAAC,CAAC,EAAA;;KACH,CAAA;AAED,kBAAe,aAAa,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sleep.js","sourceRoot":"","sources":["../../src/utils/sleep.ts"],"names":[],"mappings":";;AAAA,IAAM,KAAK,GAAG,UAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,IAAK,OAAA,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,EAAvB,CAAuB,CAAC,CAAA;AAC1D,CAAC,CAAA;AAED,kBAAe,KAAK,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fintalk.ai/lambda-handlers",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "
|
|
5
|
-
"author": "Fintalk.
|
|
6
|
-
"homepage": "https://github.com/fintalk-ai/lambda-handlers#readme",
|
|
3
|
+
"version": "2.1.3",
|
|
4
|
+
"description": "Biblioteca para integração com AWS Lambda",
|
|
5
|
+
"author": "Fintalk AI <corp@fintalk.ai>",
|
|
6
|
+
"homepage": "https://github.com/fintalk-ai/fintalk-npm-libs/tree/main/packages/lambda-handlers#readme",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"directories": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
],
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
17
|
-
"url": "git+https://github.com/fintalk-ai/
|
|
17
|
+
"url": "git+https://github.com/fintalk-ai/fintalk-npm-libs.git"
|
|
18
18
|
},
|
|
19
19
|
"publishConfig": {
|
|
20
20
|
"access": "public"
|
|
@@ -25,41 +25,33 @@
|
|
|
25
25
|
"lint": "eslint --cache --ext .ts src/",
|
|
26
26
|
"test": "LOGGER_LEVEL=silent jest",
|
|
27
27
|
"test:coverage": "LOGGER_LEVEL=silent jest --coverage",
|
|
28
|
-
"build": "run-s clean tsc"
|
|
28
|
+
"build": "run-s clean tsc",
|
|
29
|
+
"publish-npm": "npm publish --access public"
|
|
29
30
|
},
|
|
30
31
|
"bugs": {
|
|
31
|
-
"url": "https://github.com/fintalk-ai/
|
|
32
|
+
"url": "https://github.com/fintalk-ai/fintalk-npm-libs/issues"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
|
-
"@
|
|
35
|
-
"@
|
|
36
|
-
"@
|
|
37
|
-
"@
|
|
38
|
-
"@types/
|
|
39
|
-
"@types/qs": "^6.9.
|
|
40
|
-
"
|
|
41
|
-
"@typescript-eslint/parser": "^5.10.1",
|
|
42
|
-
"esbuild": "^0.14.21",
|
|
43
|
-
"esbuild-jest": "^0.5.0",
|
|
44
|
-
"eslint": "^8.14.0",
|
|
45
|
-
"eslint-config-standard": "^17.0.0",
|
|
46
|
-
"eslint-plugin-import": "^2.26.0",
|
|
47
|
-
"eslint-plugin-n": "^15.2.0",
|
|
48
|
-
"eslint-plugin-promise": "^6.0.0",
|
|
49
|
-
"fintalk-logger": "~1.1.3",
|
|
50
|
-
"jest": "^28.1.3",
|
|
51
|
-
"jest-mock": "^28.1.0",
|
|
52
|
-
"jest-mock-extended": "^2.0.6",
|
|
35
|
+
"@opentelemetry/exporter-trace-otlp-http": "0.41.2",
|
|
36
|
+
"@opentelemetry/sdk-trace-node": "1.15.2",
|
|
37
|
+
"@stone-ton/env": "^1.0.0",
|
|
38
|
+
"@stone-ton/otlp": "0.0.5",
|
|
39
|
+
"@types/aws-lambda": "^8.10.125",
|
|
40
|
+
"@types/qs": "^6.9.9",
|
|
41
|
+
"fintalk-logger": "~1.3.0",
|
|
53
42
|
"node-match-path": "^0.6.3",
|
|
54
|
-
"qs": "^6.
|
|
55
|
-
"rimraf": "^3.0.2",
|
|
56
|
-
"npm-run-all": "^4.1.5"
|
|
43
|
+
"qs": "^6.11.2"
|
|
57
44
|
},
|
|
58
45
|
"peerDependencies": {
|
|
59
|
-
"@
|
|
60
|
-
"@
|
|
61
|
-
"
|
|
46
|
+
"@opentelemetry/exporter-trace-otlp-http": "0.41.2",
|
|
47
|
+
"@opentelemetry/sdk-trace-node": "1.15.2",
|
|
48
|
+
"@stone-ton/env": ">=1.0.0",
|
|
49
|
+
"@stone-ton/otlp": "0.0.5",
|
|
50
|
+
"@types/aws-lambda": ">=8.10.125",
|
|
51
|
+
"@types/qs": ">=6.9.9",
|
|
52
|
+
"fintalk-logger": "~1.3.0",
|
|
62
53
|
"node-match-path": ">=0.6.3",
|
|
63
|
-
"qs": ">=6.
|
|
64
|
-
}
|
|
54
|
+
"qs": ">=6.11.2"
|
|
55
|
+
},
|
|
56
|
+
"gitHead": "baaf0cf46d7d6007d4447be1f9f53dc3f7c8a395"
|
|
65
57
|
}
|