@xube/kit-aws-hooks-infrastructure 0.0.45 → 0.0.47

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.
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.handler = exports.invertedIndexName = exports.tableName = void 0;
4
- const kit_aws_1 = require("@xube/kit-aws");
5
4
  const kit_aws_hooks_1 = require("@xube/kit-aws-hooks");
5
+ const kit_aws_1 = require("@xube/kit-aws");
6
+ const kit_aws_schema_1 = require("@xube/kit-aws-schema");
6
7
  exports.tableName = process.env[kit_aws_hooks_1.WEBHOOK_TABLE_NAME_ENV_VAR] || "";
7
8
  exports.invertedIndexName = process.env[kit_aws_hooks_1.WEBHOOK_TABLE_INVERTED_INDEX_NAME_ENV_VAR] ?? "";
8
9
  const handler = async (event, context, callback) => {
@@ -22,7 +23,7 @@ const handler = async (event, context, callback) => {
22
23
  continue;
23
24
  }
24
25
  const tableItem = (0, kit_aws_1.unmarshallItem)(newItem);
25
- if (!(0, kit_aws_1.isTableItem)(tableItem)) {
26
+ if (!(0, kit_aws_schema_1.isTableItem)(tableItem)) {
26
27
  console.log("Item is not a valid table item");
27
28
  continue;
28
29
  }
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WebhookManagement = exports.HANDLE_STREAMS_FUNCTION_NAME = exports.GET_WEBHOOK_ENDPOINTS_FUNCTION_NAME = exports.REMOVE_WEBHOOK_ENDPOINTS_FUNCTION_NAME = exports.ADD_WEBHOOK_ENDPOINTS_FUNCTION_NAME = void 0;
4
- const kit_aws_1 = require("@xube/kit-aws");
5
- const kit_aws_2 = require("@xube/kit-aws");
6
4
  const kit_aws_hooks_1 = require("@xube/kit-aws-hooks");
5
+ const kit_aws_schema_1 = require("@xube/kit-aws-schema");
7
6
  const kit_log_1 = require("@xube/kit-log");
8
7
  const aws_cdk_lib_1 = require("aws-cdk-lib");
9
8
  const aws_apigateway_1 = require("aws-cdk-lib/aws-apigateway");
@@ -30,11 +29,11 @@ class WebhookManagement extends constructs_1.Construct {
30
29
  this.table = new aws_dynamodb_1.Table(scope, id + "-table", {
31
30
  tableName: (props.name ?? `webhook-management`) + "-table",
32
31
  partitionKey: {
33
- name: kit_aws_2.PARTITION_KEY,
32
+ name: kit_aws_schema_1.PARTITION_KEY,
34
33
  type: aws_dynamodb_1.AttributeType.STRING,
35
34
  },
36
35
  sortKey: {
37
- name: kit_aws_1.SORT_KEY,
36
+ name: kit_aws_schema_1.SORT_KEY,
38
37
  type: aws_dynamodb_1.AttributeType.STRING,
39
38
  },
40
39
  });
@@ -42,11 +41,11 @@ class WebhookManagement extends constructs_1.Construct {
42
41
  this.table.addGlobalSecondaryIndex({
43
42
  indexName: invertedIndexName,
44
43
  partitionKey: {
45
- name: kit_aws_1.SORT_KEY,
44
+ name: kit_aws_schema_1.SORT_KEY,
46
45
  type: aws_dynamodb_1.AttributeType.STRING,
47
46
  },
48
47
  sortKey: {
49
- name: kit_aws_2.PARTITION_KEY,
48
+ name: kit_aws_schema_1.PARTITION_KEY,
50
49
  type: aws_dynamodb_1.AttributeType.STRING,
51
50
  },
52
51
  });
@@ -110,6 +109,8 @@ class WebhookManagement extends constructs_1.Construct {
110
109
  [kit_aws_hooks_1.WEBHOOK_TABLE_NAME_ENV_VAR]: this.table.tableName,
111
110
  [kit_aws_hooks_1.WEBHOOK_TABLE_INVERTED_INDEX_NAME_ENV_VAR]: invertedIndexName,
112
111
  },
112
+ memorySize: 512,
113
+ timeout: aws_cdk_lib_1.Duration.seconds(10),
113
114
  });
114
115
  this.table.grantReadData(this.handleStreams);
115
116
  this.handleStreams.addToRolePolicy(new aws_iam_1.PolicyStatement({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xube/kit-aws-hooks-infrastructure",
3
- "version": "0.0.45",
3
+ "version": "0.0.47",
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.45"
20
+ "@xube/kit-build": "^0.0.47"
21
21
  },
22
22
  "dependencies": {
23
- "@xube/kit-aws": "^0.0.45",
24
- "@xube/kit-aws-hooks": "^0.0.45",
25
- "@xube/kit-aws-infrastructure": "^0.0.45",
26
- "@xube/kit-constants": "^0.0.45",
27
- "@xube/kit-log": "^0.0.45",
23
+ "@xube/kit-aws": "^0.0.47",
24
+ "@xube/kit-aws-hooks": "^0.0.47",
25
+ "@xube/kit-aws-infrastructure": "^0.0.47",
26
+ "@xube/kit-constants": "^0.0.47",
27
+ "@xube/kit-log": "^0.0.47",
28
28
  "aws-cdk-lib": "^2.100.0",
29
29
  "aws-lambda": "^1.0.7",
30
30
  "constructs": "^10.3.0"
@@ -1,12 +1,12 @@
1
- import { isTableItem, unmarshallItem } from "@xube/kit-aws";
2
1
  import {
3
2
  WEBHOOK_TABLE_INVERTED_INDEX_NAME_ENV_VAR,
4
3
  WEBHOOK_TABLE_NAME_ENV_VAR,
5
4
  sendDataToEndpoints,
6
5
  } from "@xube/kit-aws-hooks";
7
6
  import { Callback, Context, DynamoDBStreamEvent } from "aws-lambda";
8
- import { TableItem } from "@xube/kit-aws";
9
7
  import { XubeResponse } from "@xube/kit-request";
8
+ import { unmarshallItem } from "@xube/kit-aws";
9
+ import { TableItem, isTableItem } from "@xube/kit-aws-schema";
10
10
 
11
11
  export const tableName = process.env[WEBHOOK_TABLE_NAME_ENV_VAR] || "";
12
12
  export const invertedIndexName =
@@ -46,6 +46,7 @@ export const handler = async (
46
46
 
47
47
  tableItems.push(tableItem);
48
48
  }
49
+
49
50
  const sendDataResponse: XubeResponse<boolean> = await sendDataToEndpoints(
50
51
  tableName,
51
52
  invertedIndexName,
@@ -1,9 +1,8 @@
1
- import { SORT_KEY } from "@xube/kit-aws";
2
- import { PARTITION_KEY } from "@xube/kit-aws";
3
1
  import {
4
2
  WEBHOOK_TABLE_INVERTED_INDEX_NAME_ENV_VAR,
5
3
  WEBHOOK_TABLE_NAME_ENV_VAR,
6
4
  } from "@xube/kit-aws-hooks";
5
+ import { PARTITION_KEY, SORT_KEY } from "@xube/kit-aws-schema";
7
6
  import { XubeLog } from "@xube/kit-log";
8
7
  import { Duration } from "aws-cdk-lib";
9
8
  import {
@@ -181,6 +180,8 @@ export class WebhookManagement extends Construct {
181
180
  [WEBHOOK_TABLE_NAME_ENV_VAR]: this.table.tableName,
182
181
  [WEBHOOK_TABLE_INVERTED_INDEX_NAME_ENV_VAR]: invertedIndexName,
183
182
  },
183
+ memorySize: 512,
184
+ timeout: Duration.seconds(10),
184
185
  });
185
186
 
186
187
  this.table.grantReadData(this.handleStreams);
@@ -1,3 +0,0 @@
1
- import { APIGatewayProxyResult, APIGatewayProxyWithCognitoAuthorizerEvent } from "aws-lambda";
2
- export declare const webhookTableName: string;
3
- export declare const handler: (event: APIGatewayProxyWithCognitoAuthorizerEvent) => Promise<APIGatewayProxyResult>;
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.handler = exports.webhookTableName = void 0;
4
- const kit_aws_hooks_1 = require("@xube/kit-aws-hooks");
5
- const kit_constants_1 = require("@xube/kit-constants");
6
- const kit_log_1 = require("@xube/kit-log");
7
- exports.webhookTableName = process.env.WEBHOOK_TABLE_NAME_ENV_VAR || "";
8
- const handler = async (event) => {
9
- if (!exports.webhookTableName) {
10
- return {
11
- body: `Could not find webhook table name in environment variables`,
12
- statusCode: kit_constants_1.StatusCode.InternalError,
13
- };
14
- }
15
- if (!event.body) {
16
- return {
17
- body: `No body provided`,
18
- statusCode: kit_constants_1.StatusCode.BadRequest,
19
- };
20
- }
21
- const request = JSON.parse(event.body);
22
- if (!(0, kit_aws_hooks_1.isCreateWebhookForAccountRequest)(request)) {
23
- return {
24
- body: `Request body is not a valid Webhook Endpoint creation request`,
25
- statusCode: kit_constants_1.StatusCode.BadRequest,
26
- };
27
- }
28
- const response = await (0, kit_aws_hooks_1.createWebhookForAccount)(request, exports.webhookTableName, kit_log_1.XubeLog.getInstance());
29
- return {
30
- body: JSON.stringify(response),
31
- statusCode: response.statusCode,
32
- };
33
- };
34
- exports.handler = handler;
File without changes
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,4 +0,0 @@
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>;
@@ -1,36 +0,0 @@
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;
File without changes
@@ -1 +0,0 @@
1
- "use strict";