@xube/kit-aws-hooks-infrastructure 0.0.34 → 0.0.35

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.
@@ -0,0 +1,4 @@
1
+ import { Callback, Context, DynamoDBStreamEvent } from "aws-lambda";
2
+ export declare const tableName: string;
3
+ export declare const invertedIndexName: string;
4
+ export declare const handler: (event: DynamoDBStreamEvent, context: Context, callback: Callback) => Promise<void>;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handler = exports.invertedIndexName = exports.tableName = void 0;
4
+ const kit_aws_1 = require("@xube/kit-aws");
5
+ const kit_aws_hooks_1 = require("@xube/kit-aws-hooks");
6
+ exports.tableName = process.env.WEBHOOK_TABLE_NAME || "";
7
+ exports.invertedIndexName = process.env.WEBHOOK_TABLE_INVERTED_INDEX_NAME || "";
8
+ const handler = async (event, context, callback) => {
9
+ if (!exports.tableName) {
10
+ console.log("No table name found");
11
+ return;
12
+ }
13
+ if (!exports.invertedIndexName) {
14
+ console.log("No inverted index name found");
15
+ return;
16
+ }
17
+ const tableItems = [];
18
+ for (const record of event.Records) {
19
+ const newItem = record.dynamodb?.NewImage;
20
+ if (!newItem) {
21
+ console.log("No new item found");
22
+ continue;
23
+ }
24
+ const tableItem = (0, kit_aws_1.unmarshallItem)(newItem);
25
+ if (!(0, kit_aws_1.isTableItem)(tableItem)) {
26
+ console.log("Item is not a valid table item");
27
+ continue;
28
+ }
29
+ }
30
+ const sendDataResponse = await (0, kit_aws_hooks_1.sendDataToEndpoints)(exports.tableName, exports.invertedIndexName, tableItems);
31
+ if (sendDataResponse.hasFailed()) {
32
+ console.log(`Failed to send data to endpoints: ${sendDataResponse.error}`);
33
+ }
34
+ return callback(`Failed to send data to endpoints`, sendDataResponse.data);
35
+ };
36
+ exports.handler = handler;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xube/kit-aws-hooks-infrastructure",
3
- "version": "0.0.34",
3
+ "version": "0.0.35",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -17,14 +17,14 @@
17
17
  },
18
18
  "homepage": "https://github.com/XubeLtd/dev-kit#readme",
19
19
  "devDependencies": {
20
- "@xube/kit-build": "^0.0.34"
20
+ "@xube/kit-build": "^0.0.35"
21
21
  },
22
22
  "dependencies": {
23
- "@xube/kit-aws": "^0.0.34",
24
- "@xube/kit-aws-hooks": "^0.0.34",
25
- "@xube/kit-aws-infrastructure": "^0.0.34",
26
- "@xube/kit-constants": "^0.0.34",
27
- "@xube/kit-log": "^0.0.34",
23
+ "@xube/kit-aws": "^0.0.35",
24
+ "@xube/kit-aws-hooks": "^0.0.35",
25
+ "@xube/kit-aws-infrastructure": "^0.0.35",
26
+ "@xube/kit-constants": "^0.0.35",
27
+ "@xube/kit-log": "^0.0.35",
28
28
  "aws-cdk-lib": "^2.100.0",
29
29
  "aws-lambda": "^1.0.7",
30
30
  "constructs": "^10.3.0"