@keystrokehq/sendgrid 0.0.1 → 0.0.4

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.
@@ -15,7 +15,7 @@ declare const getUserProfile: _keystrokehq_core0.Operation<z.ZodOptional<z.ZodOb
15
15
  state: z.ZodOptional<z.ZodString>;
16
16
  website: z.ZodOptional<z.ZodString>;
17
17
  zip: z.ZodOptional<z.ZodString>;
18
- }, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"sendgrid", z.ZodObject<{
18
+ }, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:sendgrid", z.ZodObject<{
19
19
  SENDGRID_API_KEY: z.ZodString;
20
20
  SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
21
21
  SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
@@ -37,7 +37,7 @@ declare const getUserProfile: _keystrokehq_core0.Operation<z.ZodOptional<z.ZodOb
37
37
  declare const getAccountInfo: _keystrokehq_core0.Operation<z.ZodOptional<z.ZodObject<{}, z.core.$strip>>, z.ZodObject<{
38
38
  type: z.ZodString;
39
39
  reputation: z.ZodOptional<z.ZodNumber>;
40
- }, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"sendgrid", z.ZodObject<{
40
+ }, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:sendgrid", z.ZodObject<{
41
41
  SENDGRID_API_KEY: z.ZodString;
42
42
  SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
43
43
  SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
@@ -58,7 +58,7 @@ declare const getAccountInfo: _keystrokehq_core0.Operation<z.ZodOptional<z.ZodOb
58
58
  }, z.core.$strip>>[] | undefined>], undefined>;
59
59
  declare const getUserScopes: _keystrokehq_core0.Operation<z.ZodOptional<z.ZodObject<{}, z.core.$strip>>, z.ZodObject<{
60
60
  scopes: z.ZodArray<z.ZodString>;
61
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"sendgrid", z.ZodObject<{
61
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:sendgrid", z.ZodObject<{
62
62
  SENDGRID_API_KEY: z.ZodString;
63
63
  SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
64
64
  SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
@@ -85,7 +85,7 @@ declare const getCreditBalance: _keystrokehq_core0.Operation<z.ZodOptional<z.Zod
85
85
  last_reset: z.ZodOptional<z.ZodString>;
86
86
  next_reset: z.ZodOptional<z.ZodString>;
87
87
  reset_frequency: z.ZodOptional<z.ZodString>;
88
- }, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"sendgrid", z.ZodObject<{
88
+ }, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:sendgrid", z.ZodObject<{
89
89
  SENDGRID_API_KEY: z.ZodString;
90
90
  SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
91
91
  SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
@@ -39,7 +39,7 @@ declare const createEventWebhook: _keystrokehq_core0.Operation<z.ZodObject<{
39
39
  dropped: z.ZodOptional<z.ZodBoolean>;
40
40
  oauth_client_id: z.ZodOptional<z.ZodString>;
41
41
  oauth_token_url: z.ZodOptional<z.ZodString>;
42
- }, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"sendgrid", z.ZodObject<{
42
+ }, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:sendgrid", z.ZodObject<{
43
43
  SENDGRID_API_KEY: z.ZodString;
44
44
  SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
45
45
  SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
@@ -95,7 +95,7 @@ declare const updateEventWebhook: _keystrokehq_core0.Operation<z.ZodObject<{
95
95
  dropped: z.ZodOptional<z.ZodBoolean>;
96
96
  oauth_client_id: z.ZodOptional<z.ZodString>;
97
97
  oauth_token_url: z.ZodOptional<z.ZodString>;
98
- }, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"sendgrid", z.ZodObject<{
98
+ }, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:sendgrid", z.ZodObject<{
99
99
  SENDGRID_API_KEY: z.ZodString;
100
100
  SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
101
101
  SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
@@ -118,7 +118,7 @@ declare const deleteEventWebhook: _keystrokehq_core0.Operation<z.ZodObject<{
118
118
  webhookId: z.ZodString;
119
119
  }, z.core.$strip>, z.ZodObject<{
120
120
  success: z.ZodBoolean;
121
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"sendgrid", z.ZodObject<{
121
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:sendgrid", z.ZodObject<{
122
122
  SENDGRID_API_KEY: z.ZodString;
123
123
  SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
124
124
  SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
@@ -158,7 +158,7 @@ declare const listEventWebhooks: _keystrokehq_core0.Operation<z.ZodOptional<z.Zo
158
158
  oauth_client_id: z.ZodOptional<z.ZodString>;
159
159
  oauth_token_url: z.ZodOptional<z.ZodString>;
160
160
  }, z.core.$catchall<z.ZodUnknown>>>;
161
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"sendgrid", z.ZodObject<{
161
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:sendgrid", z.ZodObject<{
162
162
  SENDGRID_API_KEY: z.ZodString;
163
163
  SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
164
164
  SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
@@ -197,7 +197,7 @@ declare const getEventWebhook: _keystrokehq_core0.Operation<z.ZodObject<{
197
197
  dropped: z.ZodOptional<z.ZodBoolean>;
198
198
  oauth_client_id: z.ZodOptional<z.ZodString>;
199
199
  oauth_token_url: z.ZodOptional<z.ZodString>;
200
- }, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"sendgrid", z.ZodObject<{
200
+ }, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:sendgrid", z.ZodObject<{
201
201
  SENDGRID_API_KEY: z.ZodString;
202
202
  SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
203
203
  SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
@@ -218,7 +218,7 @@ declare const getEventWebhook: _keystrokehq_core0.Operation<z.ZodObject<{
218
218
  }, z.core.$strip>>[] | undefined>], undefined>;
219
219
  declare const getSignedPublicKey: _keystrokehq_core0.Operation<z.ZodOptional<z.ZodObject<{}, z.core.$strip>>, z.ZodObject<{
220
220
  public_key: z.ZodString;
221
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"sendgrid", z.ZodObject<{
221
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:sendgrid", z.ZodObject<{
222
222
  SENDGRID_API_KEY: z.ZodString;
223
223
  SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
224
224
  SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
@@ -241,7 +241,7 @@ declare const toggleWebhookSignature: _keystrokehq_core0.Operation<z.ZodObject<{
241
241
  enabled: z.ZodBoolean;
242
242
  }, z.core.$strip>, z.ZodObject<{
243
243
  enabled: z.ZodBoolean;
244
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"sendgrid", z.ZodObject<{
244
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:sendgrid", z.ZodObject<{
245
245
  SENDGRID_API_KEY: z.ZodString;
246
246
  SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
247
247
  SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
@@ -264,7 +264,7 @@ declare const testEventWebhook: _keystrokehq_core0.Operation<z.ZodObject<{
264
264
  url: z.ZodString;
265
265
  }, z.core.$strip>, z.ZodObject<{
266
266
  success: z.ZodBoolean;
267
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"sendgrid", z.ZodObject<{
267
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:sendgrid", z.ZodObject<{
268
268
  SENDGRID_API_KEY: z.ZodString;
269
269
  SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
270
270
  SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
@@ -13,7 +13,7 @@ declare const createParseSetting: _keystrokehq_core0.Operation<z.ZodObject<{
13
13
  hostname: z.ZodString;
14
14
  spam_check: z.ZodOptional<z.ZodBoolean>;
15
15
  send_raw: z.ZodOptional<z.ZodBoolean>;
16
- }, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"sendgrid", z.ZodObject<{
16
+ }, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:sendgrid", z.ZodObject<{
17
17
  SENDGRID_API_KEY: z.ZodString;
18
18
  SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
19
19
  SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
@@ -42,7 +42,7 @@ declare const updateParseSetting: _keystrokehq_core0.Operation<z.ZodObject<{
42
42
  hostname: z.ZodString;
43
43
  spam_check: z.ZodOptional<z.ZodBoolean>;
44
44
  send_raw: z.ZodOptional<z.ZodBoolean>;
45
- }, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"sendgrid", z.ZodObject<{
45
+ }, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:sendgrid", z.ZodObject<{
46
46
  SENDGRID_API_KEY: z.ZodString;
47
47
  SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
48
48
  SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
@@ -65,7 +65,7 @@ declare const deleteParseSetting: _keystrokehq_core0.Operation<z.ZodObject<{
65
65
  hostname: z.ZodString;
66
66
  }, z.core.$strip>, z.ZodObject<{
67
67
  success: z.ZodBoolean;
68
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"sendgrid", z.ZodObject<{
68
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:sendgrid", z.ZodObject<{
69
69
  SENDGRID_API_KEY: z.ZodString;
70
70
  SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
71
71
  SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
@@ -91,7 +91,7 @@ declare const listParseSettings: _keystrokehq_core0.Operation<z.ZodOptional<z.Zo
91
91
  spam_check: z.ZodOptional<z.ZodBoolean>;
92
92
  send_raw: z.ZodOptional<z.ZodBoolean>;
93
93
  }, z.core.$catchall<z.ZodUnknown>>>;
94
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"sendgrid", z.ZodObject<{
94
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:sendgrid", z.ZodObject<{
95
95
  SENDGRID_API_KEY: z.ZodString;
96
96
  SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
97
97
  SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
@@ -117,7 +117,7 @@ declare const getParseSetting: _keystrokehq_core0.Operation<z.ZodObject<{
117
117
  hostname: z.ZodString;
118
118
  spam_check: z.ZodOptional<z.ZodBoolean>;
119
119
  send_raw: z.ZodOptional<z.ZodBoolean>;
120
- }, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"sendgrid", z.ZodObject<{
120
+ }, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:sendgrid", z.ZodObject<{
121
121
  SENDGRID_API_KEY: z.ZodString;
122
122
  SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
123
123
  SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
@@ -149,7 +149,7 @@ declare const getParseStats: _keystrokehq_core0.Operation<z.ZodOptional<z.ZodObj
149
149
  }, z.core.$strip>>, z.ZodArray<z.ZodObject<{
150
150
  date: z.ZodString;
151
151
  stats: z.ZodArray<z.ZodUnknown>;
152
- }, z.core.$catchall<z.ZodUnknown>>>, readonly [_keystrokehq_core0.CredentialSet<"sendgrid", z.ZodObject<{
152
+ }, z.core.$catchall<z.ZodUnknown>>>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:sendgrid", z.ZodObject<{
153
153
  SENDGRID_API_KEY: z.ZodString;
154
154
  SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
155
155
  SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keystrokehq/sendgrid",
3
- "version": "0.0.1",
3
+ "version": "0.0.4",
4
4
  "private": false,
5
5
  "sideEffects": false,
6
6
  "type": "module",
@@ -29,10 +29,6 @@
29
29
  "types": "./dist/events.d.mts",
30
30
  "default": "./dist/events.mjs"
31
31
  },
32
- "./triggers": {
33
- "types": "./dist/triggers.d.mts",
34
- "default": "./dist/triggers.mjs"
35
- },
36
32
  "./verification": {
37
33
  "types": "./dist/verification.d.mts",
38
34
  "default": "./dist/verification.mjs"
@@ -119,27 +115,18 @@
119
115
  "README.md",
120
116
  "LICENSE"
121
117
  ],
122
- "scripts": {
123
- "typecheck": "tsgo --build",
124
- "build": "tsdown",
125
- "lint": "biome check .",
126
- "test:unit": "vitest run --passWithNoTests --project unit",
127
- "test:int": "vitest run --passWithNoTests --project int",
128
- "prepublishOnly": "pnpm build && pnpm test:unit",
129
- "lint:fix": "biome check --write ."
130
- },
131
118
  "dependencies": {
132
- "@keystrokehq/integration-authoring": "^0.0.1",
133
- "@keystrokehq/core": "^0.0.5",
119
+ "@keystrokehq/core": "^0.0.7",
120
+ "@keystrokehq/integration-authoring": "^0.0.4",
134
121
  "zod": "^4.3.6"
135
122
  },
136
123
  "devDependencies": {
137
- "@types/node": "catalog:",
138
- "@keystrokehq/test-utils": "workspace:*",
139
- "@keystrokehq/typescript-config": "workspace:*",
140
- "tsdown": "catalog:",
141
- "typescript": "catalog:",
142
- "vitest": "catalog:"
124
+ "@types/node": "^22.19.11",
125
+ "tsdown": "^0.20.3",
126
+ "typescript": "^5.9.3",
127
+ "vitest": "^4.0.18",
128
+ "@keystrokehq/test-utils": "0.0.0",
129
+ "@keystrokehq/typescript-config": "0.0.0"
143
130
  },
144
131
  "keywords": [
145
132
  "sendgrid",
@@ -158,5 +145,13 @@
158
145
  "publishConfig": {
159
146
  "access": "public",
160
147
  "registry": "https://registry.npmjs.org/"
148
+ },
149
+ "scripts": {
150
+ "typecheck": "tsgo --build",
151
+ "build": "tsdown",
152
+ "lint": "biome check .",
153
+ "test:unit": "vitest run --passWithNoTests --project unit",
154
+ "test:int": "vitest run --passWithNoTests --project int",
155
+ "lint:fix": "biome check --write ."
161
156
  }
162
- }
157
+ }
@@ -1,35 +0,0 @@
1
- import { n as sendgrid } from "./integration-CmJ2TILG.mjs";
2
- import { sendgridEventWebhookEventSchema, sendgridEventWebhookPayloadSchema, sendgridInboundParsePayloadSchema } from "./schemas/index.mjs";
3
- import { z } from "zod";
4
- import { IntegrationTriggerBindingOptions } from "@keystrokehq/integration-authoring";
5
- import { BoundTrigger, WebhookRequest } from "@keystrokehq/core";
6
- import { WebhookTriggerManifest } from "@keystrokehq/core/trigger";
7
-
8
- //#region src/triggers.d.ts
9
- type SendGridCredentialSets = readonly [typeof sendgrid];
10
- type EventPayload = z.output<typeof sendgridEventWebhookEventSchema>;
11
- type InboundParsePayload = z.output<typeof sendgridInboundParsePayloadSchema>;
12
- type EventBindingOptions<TOutput = EventPayload> = IntegrationTriggerBindingOptions<EventPayload, TOutput, WebhookRequest>;
13
- type EventBoundTrigger<TOutput = EventPayload> = BoundTrigger<z.output<typeof sendgridEventWebhookPayloadSchema>, SendGridCredentialSets, WebhookTriggerManifest, TOutput, WebhookRequest>;
14
- type InboundParseBindingOptions<TOutput = InboundParsePayload> = IntegrationTriggerBindingOptions<InboundParsePayload, TOutput, WebhookRequest>;
15
- type InboundParseBoundTrigger<TOutput = InboundParsePayload> = BoundTrigger<InboundParsePayload, SendGridCredentialSets, WebhookTriggerManifest, TOutput, WebhookRequest>;
16
- type EventBindingSurface = <TOutput = EventPayload>(options?: EventBindingOptions<TOutput>) => EventBoundTrigger<TOutput>;
17
- type InboundParseBindingSurface = <TOutput = InboundParsePayload>(options?: InboundParseBindingOptions<TOutput>) => InboundParseBoundTrigger<TOutput>;
18
- interface SendGridEventTriggerNamespace {
19
- readonly processed: EventBindingSurface;
20
- readonly dropped: EventBindingSurface;
21
- readonly deferred: EventBindingSurface;
22
- readonly delivered: EventBindingSurface;
23
- readonly bounce: EventBindingSurface;
24
- readonly open: EventBindingSurface;
25
- readonly click: EventBindingSurface;
26
- readonly spamReport: EventBindingSurface;
27
- readonly unsubscribe: EventBindingSurface;
28
- readonly groupUnsubscribe: EventBindingSurface;
29
- readonly groupResubscribe: EventBindingSurface;
30
- readonly inboundParseReceived: InboundParseBindingSurface;
31
- }
32
- declare const triggers: SendGridEventTriggerNamespace;
33
- declare const sendgridEventEventNames: readonly ["processed", "dropped", "deferred", "delivered", "bounce", "open", "click", "spam_report", "unsubscribe", "group_unsubscribe", "group_resubscribe"];
34
- //#endregion
35
- export { SendGridEventTriggerNamespace, sendgridEventEventNames, triggers };
package/dist/triggers.mjs DELETED
@@ -1,98 +0,0 @@
1
- import { t as sendgrid } from "./integration-37BovSeK.mjs";
2
- import { a as sendgridInboundParsePayloadSchema, r as sendgridEventWebhookPayloadSchema } from "./webhooks-CKdsIikb.mjs";
3
- import { sendgridEventWebhookEventNames } from "./events.mjs";
4
- import { verifyInboundParseRequest, verifySendGridEventWebhookRequest } from "./verification.mjs";
5
- import { createWebhookTriggerBindingFactory } from "@keystrokehq/integration-authoring";
6
-
7
- //#region src/triggers.ts
8
- const EVENT_ROUTE = "/sendgrid/events";
9
- const INBOUND_PARSE_ROUTE = "/sendgrid/inbound-parse";
10
- const SIGNATURE_HEADER = "x-twilio-email-event-webhook-signature";
11
- const TIMESTAMP_HEADER = "x-twilio-email-event-webhook-timestamp";
12
- function findHeader(headers, name) {
13
- const direct = headers[name] ?? headers[name.toLowerCase()];
14
- if (direct !== void 0) return direct;
15
- for (const [key, value] of Object.entries(headers)) if (key.toLowerCase() === name.toLowerCase()) return value;
16
- }
17
- function findFirstMatching(payload, event) {
18
- for (const entry of payload) if (entry.event === event) return entry;
19
- return null;
20
- }
21
- function createEventWebhookBinding(event, defaultName, defaultDescription) {
22
- return createWebhookTriggerBindingFactory({
23
- defaultName,
24
- defaultDescription,
25
- path: EVENT_ROUTE,
26
- method: "POST",
27
- payload: sendgridEventWebhookPayloadSchema,
28
- credentialSets: [sendgrid],
29
- verify: (request, ctx) => {
30
- const publicKeyPem = ctx.credentials[sendgrid.id].SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY;
31
- if (!publicKeyPem) throw new Error("SendGrid event-webhook signature key is not configured. Fetch the Ed25519 public key via `getSignedPublicKey` and store it on the connection as `SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY`.");
32
- const signature = findHeader(request.headers, SIGNATURE_HEADER);
33
- const timestamp = findHeader(request.headers, TIMESTAMP_HEADER);
34
- if (!signature || !timestamp) throw new Error("SendGrid event-webhook signature headers are missing.");
35
- if (!verifySendGridEventWebhookRequest({
36
- rawBody: request.rawBody,
37
- signature,
38
- timestamp,
39
- publicKeyPem
40
- })) throw new Error("Invalid SendGrid event-webhook signature.");
41
- },
42
- definitionFilter: (payload) => Array.isArray(payload) && payload.some((entry) => entry.event === event),
43
- mapPayload: (payload) => findFirstMatching(payload, event),
44
- idempotencyKey: (_payload, mapped) => mapped ? `${mapped.event}:${mapped.sg_event_id}` : void 0,
45
- response: { successStatus: 200 }
46
- });
47
- }
48
- const processedBinding = createEventWebhookBinding("processed", "SendGrid Event: Processed", "Fires when SendGrid accepts a message for delivery.");
49
- const droppedBinding = createEventWebhookBinding("dropped", "SendGrid Event: Dropped", "Fires when SendGrid drops a message (e.g. suppressed recipient, invalid email).");
50
- const deferredBinding = createEventWebhookBinding("deferred", "SendGrid Event: Deferred", "Fires when the receiving mail server temporarily rejects the message.");
51
- const deliveredBinding = createEventWebhookBinding("delivered", "SendGrid Event: Delivered", "Fires when the receiving mail server accepts the message.");
52
- const bounceBinding = createEventWebhookBinding("bounce", "SendGrid Event: Bounce", "Fires when the receiving mail server permanently rejects the message.");
53
- const openBinding = createEventWebhookBinding("open", "SendGrid Event: Open", "Fires when the recipient opens the message. Filter `sg_machine_open` to exclude Apple MPP cache-fetches.");
54
- const clickBinding = createEventWebhookBinding("click", "SendGrid Event: Click", "Fires when the recipient clicks a tracked link.");
55
- const spamReportBinding = createEventWebhookBinding("spam_report", "SendGrid Event: Spam Report", "Fires when the recipient marks the message as spam via the ISP feedback loop.");
56
- const unsubscribeBinding = createEventWebhookBinding("unsubscribe", "SendGrid Event: Unsubscribe", "Fires when the recipient uses one-click or List-Unsubscribe headers.");
57
- const groupUnsubscribeBinding = createEventWebhookBinding("group_unsubscribe", "SendGrid Event: Group Unsubscribe", "Fires when the recipient unsubscribes from a specific suppression group. Includes `asm_group_id`.");
58
- const groupResubscribeBinding = createEventWebhookBinding("group_resubscribe", "SendGrid Event: Group Resubscribe", "Fires when the recipient re-subscribes to a specific suppression group.");
59
- const inboundParseBinding = createWebhookTriggerBindingFactory({
60
- defaultName: "SendGrid Inbound Parse Received",
61
- defaultDescription: "Fires when SendGrid receives an email for a configured Inbound Parse hostname. Payload is multipart; key fields like `from`, `to`, `subject`, `html`, `text`, and parsed `envelope` pass through.",
62
- path: INBOUND_PARSE_ROUTE,
63
- method: "POST",
64
- payload: sendgridInboundParsePayloadSchema,
65
- credentialSets: [sendgrid],
66
- verify: (request, ctx) => {
67
- const token = ctx.credentials[sendgrid.id].SENDGRID_INBOUND_PARSE_TOKEN;
68
- if (!token) throw new Error("SendGrid Inbound Parse token is not configured. Generate one and store it on the connection as `SENDGRID_INBOUND_PARSE_TOKEN`; include it in the receiver URL path.");
69
- if (!verifyInboundParseRequest({
70
- path: request.path,
71
- expectedToken: token
72
- })) throw new Error("Invalid SendGrid Inbound Parse token in request path.");
73
- },
74
- idempotencyKey: (payload) => {
75
- const messageId = typeof payload.headers === "string" ? payload.headers.match(/Message-ID:\s*([^\r\n]+)/iu)?.[1] : void 0;
76
- if (messageId) return messageId.trim();
77
- return `${typeof payload.envelope === "string" ? payload.envelope : ""}:${typeof payload.subject === "string" ? payload.subject : ""}`.slice(0, 200);
78
- },
79
- response: { successStatus: 200 }
80
- });
81
- const triggers = Object.freeze({
82
- processed: processedBinding,
83
- dropped: droppedBinding,
84
- deferred: deferredBinding,
85
- delivered: deliveredBinding,
86
- bounce: bounceBinding,
87
- open: openBinding,
88
- click: clickBinding,
89
- spamReport: spamReportBinding,
90
- unsubscribe: unsubscribeBinding,
91
- groupUnsubscribe: groupUnsubscribeBinding,
92
- groupResubscribe: groupResubscribeBinding,
93
- inboundParseReceived: inboundParseBinding
94
- });
95
- const sendgridEventEventNames = sendgridEventWebhookEventNames;
96
-
97
- //#endregion
98
- export { sendgridEventEventNames, triggers };