@hookflo/tern 4.2.1-beta → 4.2.3-beta

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,4 +1,4 @@
1
- import type { AlertPayloadBuilderInput } from '../../types';
1
+ import type { AlertPayloadBuilderInput } from "../../types";
2
2
  export declare function buildDiscordPayload(input: AlertPayloadBuilderInput): {
3
3
  embeds: {
4
4
  title: string;
@@ -4,34 +4,44 @@ exports.buildDiscordPayload = buildDiscordPayload;
4
4
  const utils_1 = require("../../utils");
5
5
  const constants_1 = require("../../constants");
6
6
  function buildDiscordPayload(input) {
7
- const fields = [
8
- {
9
- name: 'Severity',
10
- value: input.severity.toUpperCase(),
11
- inline: true,
12
- },
13
- ];
14
- if (input.eventId) {
15
- fields.push({ name: 'Event ID', value: `\`${input.eventId}\``, inline: true });
16
- }
7
+ const isDLQ = input.dlq;
8
+ const title = isDLQ ? "Dead Letter Queue — Event Failed" : "Webhook Received";
9
+ const description = isDLQ
10
+ ? "Event exhausted all retries. Manual replay required."
11
+ : "Event verified and queued for processing.";
12
+ const fields = [];
17
13
  if (input.source) {
18
- fields.push({ name: 'Source', value: input.source, inline: true });
14
+ fields.push({ name: "Platform", value: input.source, inline: true });
19
15
  }
20
- if (input.dlq) {
21
- fields.push({ name: 'Queue', value: 'DLQ', inline: true });
16
+ fields.push({
17
+ name: "Severity",
18
+ value: input.severity.toLowerCase(),
19
+ inline: true,
20
+ });
21
+ if (isDLQ) {
22
+ fields.push({ name: "Queue", value: "dlq", inline: true });
23
+ }
24
+ if (input.eventId) {
25
+ fields.push({
26
+ name: isDLQ ? "DLQ ID" : "Event ID",
27
+ value: `\`${input.eventId}\``,
28
+ inline: false,
29
+ });
22
30
  }
23
31
  const metadataString = (0, utils_1.compactMetadata)(input.metadata);
24
32
  if (metadataString) {
25
- fields.push({ name: 'Details', value: `\`\`\`${metadataString}\`\`\`` });
33
+ fields.push({ name: "Details", value: `\`\`\`${metadataString}\`\`\`` });
26
34
  }
27
- const replayLine = input.replayUrl ? `\n\n[${input.replayLabel}](${input.replayUrl})` : '';
28
- const footerText = input.branding === false ? undefined : 'Alert from Tern • tern.hookflo.com';
35
+ const replayLine = input.replayUrl
36
+ ? `\n\n[${input.replayLabel ?? "Replay Event"}](${input.replayUrl})`
37
+ : "";
38
+ const footerText = input.branding === false ? undefined : "Alert from Tern · tern.hookflo.com";
29
39
  return {
30
40
  embeds: [
31
41
  {
32
- title: input.title,
33
- description: `${input.message}${replayLine}`,
34
- color: parseInt(constants_1.severityColorMap[input.severity].replace('#', ''), 16),
42
+ title,
43
+ description: `${description}${replayLine}`,
44
+ color: parseInt(constants_1.severityColorMap[input.severity].replace("#", ""), 16),
35
45
  fields,
36
46
  footer: footerText ? { text: footerText } : undefined,
37
47
  timestamp: new Date().toISOString(),
@@ -1,4 +1,4 @@
1
- import type { AlertPayloadBuilderInput } from '../../types';
1
+ import type { AlertPayloadBuilderInput } from "../../types";
2
2
  export declare function buildSlackPayload(input: AlertPayloadBuilderInput): {
3
3
  text: string;
4
4
  blocks: Record<string, unknown>[];
@@ -4,29 +4,33 @@ exports.buildSlackPayload = buildSlackPayload;
4
4
  const utils_1 = require("../../utils");
5
5
  const constants_1 = require("../../constants");
6
6
  function buildSlackPayload(input) {
7
+ const isDLQ = input.dlq;
8
+ const title = isDLQ ? "Dead Letter Queue — Event Failed" : "Webhook Received";
9
+ const message = isDLQ
10
+ ? "Event exhausted all retries. Manual replay required."
11
+ : "Event verified and queued for processing.";
7
12
  const fields = [
8
- input.eventId ? { type: 'mrkdwn', text: `*Event ID*\n\`${input.eventId}\`` } : null,
9
- input.source ? { type: 'mrkdwn', text: `*Source*\n${input.source}` } : null,
13
+ input.source
14
+ ? { type: "mrkdwn", text: `*Platform*\n${input.source}` }
15
+ : null,
10
16
  {
11
- type: 'mrkdwn',
12
- text: `*Severity*\n${input.severity.toUpperCase()}`,
17
+ type: "mrkdwn",
18
+ text: `*Severity*\n${input.severity.toLowerCase()}`,
13
19
  },
14
- input.dlq ? { type: 'mrkdwn', text: '*Queue*\nDLQ' } : null,
20
+ isDLQ ? { type: "mrkdwn", text: "*Queue*\ndlq" } : null,
21
+ input.eventId
22
+ ? {
23
+ type: "mrkdwn",
24
+ text: `*${isDLQ ? "DLQ ID" : "Event ID"}*\n\`${input.eventId}\``,
25
+ }
26
+ : null,
15
27
  ].filter(Boolean);
16
28
  const blocks = [
17
29
  {
18
- type: 'header',
30
+ type: "section",
19
31
  text: {
20
- type: 'plain_text',
21
- text: input.title,
22
- emoji: true,
23
- },
24
- },
25
- {
26
- type: 'section',
27
- text: {
28
- type: 'mrkdwn',
29
- text: input.message,
32
+ type: "mrkdwn",
33
+ text: `*${title}*\n${message}`,
30
34
  },
31
35
  fields,
32
36
  },
@@ -34,43 +38,43 @@ function buildSlackPayload(input) {
34
38
  const metadataString = (0, utils_1.compactMetadata)(input.metadata);
35
39
  if (metadataString) {
36
40
  blocks.push({
37
- type: 'section',
41
+ type: "section",
38
42
  text: {
39
- type: 'mrkdwn',
40
- text: `*Details*\n\`\`\`${metadataString}\`\`\``,
43
+ type: "mrkdwn",
44
+ text: `\`\`\`${metadataString}\`\`\``,
41
45
  },
42
46
  });
43
47
  }
44
48
  if (input.replayUrl) {
45
49
  blocks.push({
46
- type: 'actions',
50
+ type: "actions",
47
51
  elements: [
48
52
  {
49
- type: 'button',
53
+ type: "button",
50
54
  text: {
51
- type: 'plain_text',
52
- text: input.replayLabel,
53
- emoji: true,
55
+ type: "plain_text",
56
+ text: input.replayLabel ?? "Replay Event",
57
+ emoji: false,
54
58
  },
55
59
  url: input.replayUrl,
56
- style: 'primary',
60
+ style: "danger",
57
61
  },
58
62
  ],
59
63
  });
60
64
  }
61
65
  if (input.branding !== false) {
62
66
  blocks.push({
63
- type: 'context',
67
+ type: "context",
64
68
  elements: [
65
69
  {
66
- type: 'mrkdwn',
70
+ type: "mrkdwn",
67
71
  text: `Alert from <${constants_1.TERN_BRAND_URL}|Tern>`,
68
72
  },
69
73
  ],
70
74
  });
71
75
  }
72
76
  return {
73
- text: `${input.title} - ${input.message}`,
77
+ text: title,
74
78
  blocks,
75
79
  };
76
80
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hookflo/tern",
3
- "version": "4.2.1-beta",
3
+ "version": "4.2.3-beta",
4
4
  "description": "A robust, scalable webhook verification framework supporting multiple platforms and signature algorithms",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",