@hogsend/db 0.8.0 → 0.10.0

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.
@@ -134,6 +134,20 @@
134
134
  "when": 1780855021994,
135
135
  "tag": "0018_webhooks",
136
136
  "breakpoints": true
137
+ },
138
+ {
139
+ "idx": 19,
140
+ "version": "7",
141
+ "when": 1780907482971,
142
+ "tag": "0019_flippant_songbird",
143
+ "breakpoints": true
144
+ },
145
+ {
146
+ "idx": 20,
147
+ "version": "7",
148
+ "when": 1780932858220,
149
+ "tag": "0020_colossal_vengeance",
150
+ "breakpoints": true
137
151
  }
138
152
  ]
139
153
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hogsend/db",
3
- "version": "0.8.0",
3
+ "version": "0.10.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
package/src/demo-seed.ts CHANGED
@@ -542,7 +542,7 @@ function buildSend(opts: {
542
542
  complainedAt,
543
543
  bounceType,
544
544
  bounceReason,
545
- resendId:
545
+ messageId:
546
546
  status === "queued"
547
547
  ? null
548
548
  : `re_${Math.floor(rand() * 1e16).toString(36)}`,
@@ -22,7 +22,7 @@ export const emailSends = pgTable(
22
22
  userId: text("user_id"),
23
23
  userEmail: text("user_email"),
24
24
  templateKey: text("template_key"),
25
- resendId: text("resend_id"),
25
+ messageId: text("message_id"),
26
26
  fromEmail: text("from_email").notNull(),
27
27
  toEmail: text("to_email").notNull(),
28
28
  subject: text("subject").notNull(),
@@ -51,6 +51,9 @@ export const emailSends = pgTable(
51
51
  index("email_sends_created_at_idx").on(table.createdAt),
52
52
  index("email_sends_journey_state_id_idx").on(table.journeyStateId),
53
53
  index("email_sends_user_id_idx").on(table.userId),
54
+ // Serves the provider-webhook by-message resolver
55
+ // (resolveEmailSendContextByMessageId) — previously a seq-scan.
56
+ index("email_sends_message_id_idx").on(table.messageId),
54
57
  // Serves the frequency-cap COUNT (recipient + recency, optionally category).
55
58
  index("email_sends_freq_cap_idx").on(
56
59
  table.toEmail,
@@ -22,10 +22,23 @@ export const webhookEndpoints = pgTable(
22
22
  organizationId: text("organization_id"),
23
23
  url: text("url").notNull(),
24
24
  description: text("description"),
25
+ // The delivery adapter selector. "webhook" (the default) is the signed
26
+ // Standard-Webhooks POST that existing subscribers receive — byte-identical
27
+ // to before this column existed. Any other value (e.g. "posthog") selects a
28
+ // delivery-time TRANSFORM adapter that reuses the same durable delivery
29
+ // machinery but rewrites url/headers/body for a vendor destination.
30
+ kind: text("kind").notNull().default("webhook"),
31
+ // Per-destination configuration for keyed adapters (e.g. PostHog's
32
+ // `{ apiKey, host }`). Null for `kind="webhook"` (it reads `secret` instead).
33
+ // Keyed destinations keep their credentials HERE, not in a fake `whsec_`.
34
+ config: jsonb("config").$type<Record<string, unknown>>(),
25
35
  // whsec_<base64url> PLAINTEXT (recoverable; re-signed every delivery).
26
- secret: text("secret").notNull(),
27
- // e.g. "whsec_AbCd" safe to show on list/get.
28
- secretPrefix: text("secret_prefix").notNull(),
36
+ // Nullable: only `kind="webhook"` carries a signing secret; keyed
37
+ // destinations authenticate via `config` and the webhook adapter is the only
38
+ // reader of this column.
39
+ secret: text("secret"),
40
+ // e.g. "whsec_AbCd" — safe to show on list/get. Nullable alongside `secret`.
41
+ secretPrefix: text("secret_prefix"),
29
42
  eventTypes: jsonb("event_types")
30
43
  .$type<WebhookEventType[]>()
31
44
  .notNull()