@xube/kit-aws-hooks 0.0.39 → 0.0.41
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/send.js +7 -2
- package/package.json +5 -5
- package/src/send.ts +20 -3
package/dist/send.js
CHANGED
|
@@ -10,17 +10,21 @@ const kit_constants_1 = require("@xube/kit-constants");
|
|
|
10
10
|
const kit_log_1 = require("@xube/kit-log");
|
|
11
11
|
const sendDataToEndpoints = async (webhookTableName, indexName, items, log = kit_log_1.XubeLog.getInstance()) => {
|
|
12
12
|
const endpointSends = [];
|
|
13
|
+
log.info(`Sending data to endpoints based on ${items.length} items.}`);
|
|
13
14
|
for (const item of items) {
|
|
14
15
|
const invertedWebhookKey = {
|
|
15
16
|
PK: (0, keys_1.getWebhookSortKey)(item.id, types_1.WebhookTypes.data),
|
|
16
17
|
};
|
|
18
|
+
log.info(`Searching for webhooks with key: ${JSON.stringify(invertedWebhookKey)}`);
|
|
17
19
|
const getWebhookEndpointsResponse = await (0, kit_aws_1.queryItemsFromTable)(webhookTableName, invertedWebhookKey, indexName);
|
|
18
20
|
if (getWebhookEndpointsResponse.hasFailed()) {
|
|
21
|
+
log.error(`Failed to get webhook endpoints for webhook endpoint ${item.id} and type ${types_1.WebhookTypes.data}`);
|
|
22
|
+
log.info(`${JSON.stringify(getWebhookEndpointsResponse, null, 2)}}`);
|
|
19
23
|
return getWebhookEndpointsResponse.switchXubeResponseType();
|
|
20
24
|
}
|
|
21
25
|
if (!getWebhookEndpointsResponse.data ||
|
|
22
26
|
!getWebhookEndpointsResponse.data.length) {
|
|
23
|
-
|
|
27
|
+
log.info(`No webhook endpoints found for webhook endpoint ${item.id} and type ${types_1.WebhookTypes.data}`);
|
|
24
28
|
continue;
|
|
25
29
|
}
|
|
26
30
|
log.info(`Found webhook endpoint ${JSON.stringify(invertedWebhookKey)} for id: ${item.id}`);
|
|
@@ -31,9 +35,10 @@ const sendDataToEndpoints = async (webhookTableName, indexName, items, log = kit
|
|
|
31
35
|
continue;
|
|
32
36
|
}
|
|
33
37
|
if (!webhookEndpoint.endpoints || !webhookEndpoint.endpoints.length) {
|
|
34
|
-
|
|
38
|
+
log.info(`No endpoints found for webhook endpoint ${webhookEndpoint.id}`);
|
|
35
39
|
continue;
|
|
36
40
|
}
|
|
41
|
+
log.info(`Preparing to send data to endpoints: ${JSON.stringify(webhookEndpoint.endpoints, null, 2)}`);
|
|
37
42
|
for (const endpoint of webhookEndpoint.endpoints) {
|
|
38
43
|
endpointSends.push(fetch(endpoint.url, {
|
|
39
44
|
body: JSON.stringify(item),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xube/kit-aws-hooks",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.41",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -17,12 +17,12 @@
|
|
|
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.41"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@xube/kit-aws": "^0.0.
|
|
24
|
-
"@xube/kit-log": "^0.0.
|
|
25
|
-
"@xube/kit-request": "^0.0.
|
|
23
|
+
"@xube/kit-aws": "^0.0.41",
|
|
24
|
+
"@xube/kit-log": "^0.0.41",
|
|
25
|
+
"@xube/kit-request": "^0.0.41",
|
|
26
26
|
"zod": "^3.22.4"
|
|
27
27
|
}
|
|
28
28
|
}
|
package/src/send.ts
CHANGED
|
@@ -14,11 +14,16 @@ export const sendDataToEndpoints = async (
|
|
|
14
14
|
): Promise<XubeResponse<boolean>> => {
|
|
15
15
|
const endpointSends: Promise<Response>[] = [];
|
|
16
16
|
|
|
17
|
+
log.info(`Sending data to endpoints based on ${items.length} items.}`);
|
|
18
|
+
|
|
17
19
|
for (const item of items) {
|
|
18
20
|
const invertedWebhookKey: PartialTableKey = {
|
|
19
21
|
PK: getWebhookSortKey(item.id, WebhookTypes.data),
|
|
20
22
|
};
|
|
21
23
|
|
|
24
|
+
log.info(
|
|
25
|
+
`Searching for webhooks with key: ${JSON.stringify(invertedWebhookKey)}`
|
|
26
|
+
);
|
|
22
27
|
|
|
23
28
|
const getWebhookEndpointsResponse = await queryItemsFromTable(
|
|
24
29
|
webhookTableName,
|
|
@@ -27,6 +32,10 @@ export const sendDataToEndpoints = async (
|
|
|
27
32
|
);
|
|
28
33
|
|
|
29
34
|
if (getWebhookEndpointsResponse.hasFailed()) {
|
|
35
|
+
log.error(
|
|
36
|
+
`Failed to get webhook endpoints for webhook endpoint ${item.id} and type ${WebhookTypes.data}`
|
|
37
|
+
);
|
|
38
|
+
log.info(`${JSON.stringify(getWebhookEndpointsResponse, null, 2)}}`);
|
|
30
39
|
return getWebhookEndpointsResponse.switchXubeResponseType();
|
|
31
40
|
}
|
|
32
41
|
|
|
@@ -34,7 +43,7 @@ export const sendDataToEndpoints = async (
|
|
|
34
43
|
!getWebhookEndpointsResponse.data ||
|
|
35
44
|
!getWebhookEndpointsResponse.data.length
|
|
36
45
|
) {
|
|
37
|
-
|
|
46
|
+
log.info(
|
|
38
47
|
`No webhook endpoints found for webhook endpoint ${item.id} and type ${WebhookTypes.data}`
|
|
39
48
|
);
|
|
40
49
|
continue;
|
|
@@ -45,7 +54,7 @@ export const sendDataToEndpoints = async (
|
|
|
45
54
|
item.id
|
|
46
55
|
}`
|
|
47
56
|
);
|
|
48
|
-
|
|
57
|
+
|
|
49
58
|
const webhookEndpoints: TableItem[] = getWebhookEndpointsResponse.data;
|
|
50
59
|
|
|
51
60
|
for (const webhookEndpoint of webhookEndpoints) {
|
|
@@ -57,12 +66,20 @@ export const sendDataToEndpoints = async (
|
|
|
57
66
|
}
|
|
58
67
|
|
|
59
68
|
if (!webhookEndpoint.endpoints || !webhookEndpoint.endpoints.length) {
|
|
60
|
-
|
|
69
|
+
log.info(
|
|
61
70
|
`No endpoints found for webhook endpoint ${webhookEndpoint.id}`
|
|
62
71
|
);
|
|
63
72
|
continue;
|
|
64
73
|
}
|
|
65
74
|
|
|
75
|
+
log.info(
|
|
76
|
+
`Preparing to send data to endpoints: ${JSON.stringify(
|
|
77
|
+
webhookEndpoint.endpoints,
|
|
78
|
+
null,
|
|
79
|
+
2
|
|
80
|
+
)}`
|
|
81
|
+
);
|
|
82
|
+
|
|
66
83
|
for (const endpoint of webhookEndpoint.endpoints) {
|
|
67
84
|
endpointSends.push(
|
|
68
85
|
fetch(endpoint.url, {
|