@xube/kit-aws-hooks-infrastructure 0.0.22 → 0.0.23
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/functions/add-webhook-endpoints.d.ts +3 -0
- package/dist/functions/add-webhook-endpoints.js +34 -0
- package/dist/functions/get-webhook-endpoints.js +1 -0
- package/dist/functions/remove-webhook-endpoints.js +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +20 -0
- package/dist/webhook-management.d.ts +3 -3
- package/dist/webhook-management.js +14 -14
- package/package.json +7 -7
- package/src/functions/get-webhook-endpoints.ts +0 -0
- package/src/functions/remove-webhook-endpoints.ts +0 -0
- package/src/index.ts +4 -0
- package/src/webhook-management.ts +15 -15
- /package/{src/functions/get-webhook-endpoint.ts → dist/functions/get-webhook-endpoints.d.ts} +0 -0
- /package/{src/functions/remove-webhook-endpoint.ts → dist/functions/remove-webhook-endpoints.d.ts} +0 -0
- /package/src/functions/{add-webhook-endpoint.ts → add-webhook-endpoints.ts} +0 -0
|
@@ -0,0 +1,34 @@
|
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./webhook-management"), exports);
|
|
18
|
+
__exportStar(require("./functions/add-webhook-endpoints"), exports);
|
|
19
|
+
// export * from "./functions/get-webhook-endpoints";
|
|
20
|
+
// export * from "./functions/remove-webhook-endpoints";
|
|
@@ -3,8 +3,8 @@ import { ICertificate } from "aws-cdk-lib/aws-certificatemanager";
|
|
|
3
3
|
import { ITable } from "aws-cdk-lib/aws-dynamodb";
|
|
4
4
|
import { NodejsFunction } from "aws-cdk-lib/aws-lambda-nodejs";
|
|
5
5
|
import { Construct } from "constructs";
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
6
|
+
export declare const ADD_WEBHOOK_ENDPOINTS_FUNCTION_NAME = "add-webhook-endpoints";
|
|
7
|
+
export declare const REMOVE_WEBHOOK_ENDPOINTS_FUNCTION_NAME = "remove-webhook-endpoints";
|
|
8
8
|
export declare const GET_WEBHOOK_ENDPOINTS_FUNCTION_NAME = "get-webhook-endpoints";
|
|
9
9
|
export interface WebhookManagementProps {
|
|
10
10
|
table?: ITable;
|
|
@@ -18,7 +18,7 @@ export interface WebhookManagementProps {
|
|
|
18
18
|
}
|
|
19
19
|
export declare class WebhookManagement extends Construct {
|
|
20
20
|
table: ITable;
|
|
21
|
-
|
|
21
|
+
addWebhookEndpoints: NodejsFunction;
|
|
22
22
|
removeWebhookEndpoint: NodejsFunction;
|
|
23
23
|
getWebhookEndpoints: NodejsFunction;
|
|
24
24
|
webhookAPI: RestApi;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WebhookManagement = exports.GET_WEBHOOK_ENDPOINTS_FUNCTION_NAME = exports.
|
|
3
|
+
exports.WebhookManagement = exports.GET_WEBHOOK_ENDPOINTS_FUNCTION_NAME = exports.REMOVE_WEBHOOK_ENDPOINTS_FUNCTION_NAME = exports.ADD_WEBHOOK_ENDPOINTS_FUNCTION_NAME = void 0;
|
|
4
4
|
const kit_aws_1 = require("@xube/kit-aws");
|
|
5
5
|
const kit_aws_2 = require("@xube/kit-aws");
|
|
6
6
|
const aws_apigateway_1 = require("aws-cdk-lib/aws-apigateway");
|
|
@@ -8,12 +8,12 @@ const aws_dynamodb_1 = require("aws-cdk-lib/aws-dynamodb");
|
|
|
8
8
|
const aws_lambda_1 = require("aws-cdk-lib/aws-lambda");
|
|
9
9
|
const aws_lambda_nodejs_1 = require("aws-cdk-lib/aws-lambda-nodejs");
|
|
10
10
|
const constructs_1 = require("constructs");
|
|
11
|
-
exports.
|
|
12
|
-
exports.
|
|
11
|
+
exports.ADD_WEBHOOK_ENDPOINTS_FUNCTION_NAME = "add-webhook-endpoints";
|
|
12
|
+
exports.REMOVE_WEBHOOK_ENDPOINTS_FUNCTION_NAME = "remove-webhook-endpoints";
|
|
13
13
|
exports.GET_WEBHOOK_ENDPOINTS_FUNCTION_NAME = "get-webhook-endpoints";
|
|
14
14
|
class WebhookManagement extends constructs_1.Construct {
|
|
15
15
|
table;
|
|
16
|
-
|
|
16
|
+
addWebhookEndpoints;
|
|
17
17
|
removeWebhookEndpoint;
|
|
18
18
|
getWebhookEndpoints;
|
|
19
19
|
webhookAPI;
|
|
@@ -32,16 +32,16 @@ class WebhookManagement extends constructs_1.Construct {
|
|
|
32
32
|
type: aws_dynamodb_1.AttributeType.STRING,
|
|
33
33
|
},
|
|
34
34
|
});
|
|
35
|
-
this.
|
|
36
|
-
entry: __dirname + "./functions/" + exports.
|
|
37
|
-
functionName: (props.name ?? "webhook") + "-add-
|
|
35
|
+
this.addWebhookEndpoints = new aws_lambda_nodejs_1.NodejsFunction(this, id + "-add-hooks-function", {
|
|
36
|
+
entry: __dirname + "./functions/" + exports.ADD_WEBHOOK_ENDPOINTS_FUNCTION_NAME,
|
|
37
|
+
functionName: (props.name ?? "webhook") + "-add-hooks",
|
|
38
38
|
environment: {
|
|
39
39
|
WEBHOOK_TABLE_NAME_ENV_VAR: this.table.tableName,
|
|
40
40
|
},
|
|
41
41
|
});
|
|
42
|
-
this.removeWebhookEndpoint = new aws_lambda_nodejs_1.NodejsFunction(this, id + "-remove-
|
|
43
|
-
entry: __dirname + "./functions/" + exports.
|
|
44
|
-
functionName: (props.name ?? "webhook") + "-remove-
|
|
42
|
+
this.removeWebhookEndpoint = new aws_lambda_nodejs_1.NodejsFunction(this, id + "-remove-hooks-function", {
|
|
43
|
+
entry: __dirname + "./functions/" + exports.REMOVE_WEBHOOK_ENDPOINTS_FUNCTION_NAME,
|
|
44
|
+
functionName: (props.name ?? "webhook") + "-remove-hooks",
|
|
45
45
|
environment: {
|
|
46
46
|
WEBHOOK_TABLE_NAME_ENV_VAR: this.table.tableName,
|
|
47
47
|
},
|
|
@@ -73,12 +73,12 @@ class WebhookManagement extends constructs_1.Construct {
|
|
|
73
73
|
stageName: props.stage ?? "production",
|
|
74
74
|
},
|
|
75
75
|
});
|
|
76
|
-
const
|
|
77
|
-
const
|
|
76
|
+
const addWebhookEndpointsTarget = new aws_apigateway_1.LambdaIntegration(this.addWebhookEndpoints);
|
|
77
|
+
const removeWebhookEndpointsTarget = new aws_apigateway_1.LambdaIntegration(this.removeWebhookEndpoint);
|
|
78
78
|
const getWebhookEndpointsTarget = new aws_apigateway_1.LambdaIntegration(this.getWebhookEndpoints);
|
|
79
79
|
this.webhookAPI.root.addMethod(aws_lambda_1.HttpMethod.GET, getWebhookEndpointsTarget);
|
|
80
|
-
this.webhookAPI.root.addMethod(aws_lambda_1.HttpMethod.POST,
|
|
81
|
-
this.webhookAPI.root.addMethod(aws_lambda_1.HttpMethod.DELETE,
|
|
80
|
+
this.webhookAPI.root.addMethod(aws_lambda_1.HttpMethod.POST, addWebhookEndpointsTarget);
|
|
81
|
+
this.webhookAPI.root.addMethod(aws_lambda_1.HttpMethod.DELETE, removeWebhookEndpointsTarget);
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
exports.WebhookManagement = WebhookManagement;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xube/kit-aws-hooks-infrastructure",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.23",
|
|
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.
|
|
20
|
+
"@xube/kit-build": "^0.0.23"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@xube/kit-aws": "^0.0.
|
|
24
|
-
"@xube/kit-aws-hooks": "^0.0.
|
|
25
|
-
"@xube/kit-aws-infrastructure": "^0.0.
|
|
26
|
-
"@xube/kit-constants": "^0.0.
|
|
27
|
-
"@xube/kit-log": "^0.0.
|
|
23
|
+
"@xube/kit-aws": "^0.0.23",
|
|
24
|
+
"@xube/kit-aws-hooks": "^0.0.23",
|
|
25
|
+
"@xube/kit-aws-infrastructure": "^0.0.23",
|
|
26
|
+
"@xube/kit-constants": "^0.0.23",
|
|
27
|
+
"@xube/kit-log": "^0.0.23",
|
|
28
28
|
"aws-cdk-lib": "^2.100.0",
|
|
29
29
|
"aws-lambda": "^1.0.7",
|
|
30
30
|
"constructs": "^10.3.0"
|
|
File without changes
|
|
File without changes
|
package/src/index.ts
ADDED
|
@@ -14,8 +14,8 @@ import { HttpMethod } from "aws-cdk-lib/aws-lambda";
|
|
|
14
14
|
import { NodejsFunction } from "aws-cdk-lib/aws-lambda-nodejs";
|
|
15
15
|
import { Construct } from "constructs";
|
|
16
16
|
|
|
17
|
-
export const
|
|
18
|
-
export const
|
|
17
|
+
export const ADD_WEBHOOK_ENDPOINTS_FUNCTION_NAME = "add-webhook-endpoints";
|
|
18
|
+
export const REMOVE_WEBHOOK_ENDPOINTS_FUNCTION_NAME = "remove-webhook-endpoints";
|
|
19
19
|
export const GET_WEBHOOK_ENDPOINTS_FUNCTION_NAME = "get-webhook-endpoints";
|
|
20
20
|
|
|
21
21
|
export interface WebhookManagementProps {
|
|
@@ -31,7 +31,7 @@ export interface WebhookManagementProps {
|
|
|
31
31
|
|
|
32
32
|
export class WebhookManagement extends Construct {
|
|
33
33
|
table: ITable;
|
|
34
|
-
|
|
34
|
+
addWebhookEndpoints: NodejsFunction;
|
|
35
35
|
removeWebhookEndpoint: NodejsFunction;
|
|
36
36
|
getWebhookEndpoints: NodejsFunction;
|
|
37
37
|
|
|
@@ -54,12 +54,12 @@ export class WebhookManagement extends Construct {
|
|
|
54
54
|
},
|
|
55
55
|
});
|
|
56
56
|
|
|
57
|
-
this.
|
|
57
|
+
this.addWebhookEndpoints = new NodejsFunction(
|
|
58
58
|
this,
|
|
59
|
-
id + "-add-
|
|
59
|
+
id + "-add-hooks-function",
|
|
60
60
|
{
|
|
61
|
-
entry: __dirname + "./functions/" +
|
|
62
|
-
functionName: (props.name ?? "webhook") + "-add-
|
|
61
|
+
entry: __dirname + "./functions/" + ADD_WEBHOOK_ENDPOINTS_FUNCTION_NAME,
|
|
62
|
+
functionName: (props.name ?? "webhook") + "-add-hooks",
|
|
63
63
|
environment: {
|
|
64
64
|
WEBHOOK_TABLE_NAME_ENV_VAR: this.table.tableName,
|
|
65
65
|
},
|
|
@@ -67,11 +67,11 @@ export class WebhookManagement extends Construct {
|
|
|
67
67
|
);
|
|
68
68
|
this.removeWebhookEndpoint = new NodejsFunction(
|
|
69
69
|
this,
|
|
70
|
-
id + "-remove-
|
|
70
|
+
id + "-remove-hooks-function",
|
|
71
71
|
{
|
|
72
72
|
entry:
|
|
73
|
-
__dirname + "./functions/" +
|
|
74
|
-
functionName: (props.name ?? "webhook") + "-remove-
|
|
73
|
+
__dirname + "./functions/" + REMOVE_WEBHOOK_ENDPOINTS_FUNCTION_NAME,
|
|
74
|
+
functionName: (props.name ?? "webhook") + "-remove-hooks",
|
|
75
75
|
environment: {
|
|
76
76
|
WEBHOOK_TABLE_NAME_ENV_VAR: this.table.tableName,
|
|
77
77
|
},
|
|
@@ -110,11 +110,11 @@ export class WebhookManagement extends Construct {
|
|
|
110
110
|
},
|
|
111
111
|
});
|
|
112
112
|
|
|
113
|
-
const
|
|
114
|
-
this.
|
|
113
|
+
const addWebhookEndpointsTarget = new LambdaIntegration(
|
|
114
|
+
this.addWebhookEndpoints
|
|
115
115
|
);
|
|
116
116
|
|
|
117
|
-
const
|
|
117
|
+
const removeWebhookEndpointsTarget = new LambdaIntegration(
|
|
118
118
|
this.removeWebhookEndpoint
|
|
119
119
|
);
|
|
120
120
|
|
|
@@ -123,10 +123,10 @@ export class WebhookManagement extends Construct {
|
|
|
123
123
|
);
|
|
124
124
|
|
|
125
125
|
this.webhookAPI.root.addMethod(HttpMethod.GET, getWebhookEndpointsTarget);
|
|
126
|
-
this.webhookAPI.root.addMethod(HttpMethod.POST,
|
|
126
|
+
this.webhookAPI.root.addMethod(HttpMethod.POST, addWebhookEndpointsTarget);
|
|
127
127
|
this.webhookAPI.root.addMethod(
|
|
128
128
|
HttpMethod.DELETE,
|
|
129
|
-
|
|
129
|
+
removeWebhookEndpointsTarget
|
|
130
130
|
);
|
|
131
131
|
}
|
|
132
132
|
}
|
/package/{src/functions/get-webhook-endpoint.ts → dist/functions/get-webhook-endpoints.d.ts}
RENAMED
|
File without changes
|
/package/{src/functions/remove-webhook-endpoint.ts → dist/functions/remove-webhook-endpoints.d.ts}
RENAMED
|
File without changes
|
|
File without changes
|