@objectstack/plugin-webhooks 5.1.0 → 6.0.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.
Files changed (55) hide show
  1. package/.turbo/turbo-build.log +35 -13
  2. package/CHANGELOG.md +17 -33
  3. package/dist/chunk-33LYZT7O.js +184 -0
  4. package/dist/chunk-33LYZT7O.js.map +1 -0
  5. package/dist/chunk-BS2QTZH3.js +256 -0
  6. package/dist/chunk-BS2QTZH3.js.map +1 -0
  7. package/dist/chunk-FA66GQEO.cjs +256 -0
  8. package/dist/chunk-FA66GQEO.cjs.map +1 -0
  9. package/dist/chunk-MJZGD37S.cjs +184 -0
  10. package/dist/chunk-MJZGD37S.cjs.map +1 -0
  11. package/dist/index.cjs +908 -0
  12. package/dist/index.cjs.map +1 -0
  13. package/dist/index.d.cts +469 -0
  14. package/dist/index.d.ts +435 -70
  15. package/dist/index.js +872 -217
  16. package/dist/index.js.map +1 -1
  17. package/dist/outbox-CIn7LSyB.d.cts +155 -0
  18. package/dist/outbox-CIn7LSyB.d.ts +155 -0
  19. package/dist/schema.cjs +9 -0
  20. package/dist/schema.cjs.map +1 -0
  21. package/dist/schema.d.cts +4787 -0
  22. package/dist/schema.d.ts +4787 -0
  23. package/dist/schema.js +9 -0
  24. package/dist/schema.js.map +1 -0
  25. package/dist/sql-outbox.cjs +8 -0
  26. package/dist/sql-outbox.cjs.map +1 -0
  27. package/dist/sql-outbox.d.cts +55 -0
  28. package/dist/sql-outbox.d.ts +55 -0
  29. package/dist/sql-outbox.js +8 -0
  30. package/dist/sql-outbox.js.map +1 -0
  31. package/package.json +30 -10
  32. package/src/auto-enqueuer.test.ts +391 -0
  33. package/src/auto-enqueuer.ts +335 -0
  34. package/src/dispatcher.test.ts +324 -0
  35. package/src/dispatcher.ts +218 -0
  36. package/src/http-sender.ts +187 -0
  37. package/src/index.ts +49 -12
  38. package/src/memory-outbox.test.ts +86 -0
  39. package/src/memory-outbox.ts +155 -0
  40. package/src/outbox.ts +175 -0
  41. package/src/partition.ts +19 -0
  42. package/src/retention.test.ts +116 -0
  43. package/src/retention.ts +144 -0
  44. package/src/schema.ts +22 -0
  45. package/src/sql-outbox.test.ts +490 -0
  46. package/src/sql-outbox.ts +343 -0
  47. package/src/sys-webhook-delivery.object.ts +224 -0
  48. package/src/webhook-outbox-plugin.ts +442 -0
  49. package/tsconfig.json +5 -13
  50. package/tsup.config.ts +14 -0
  51. package/dist/index.d.mts +0 -104
  52. package/dist/index.mjs +0 -216
  53. package/dist/index.mjs.map +0 -1
  54. package/src/webhooks-plugin.test.ts +0 -218
  55. package/src/webhooks-plugin.ts +0 -294
@@ -1,22 +1,44 @@
1
1
 
2
- > @objectstack/plugin-webhooks@5.1.0 build /home/runner/work/framework/framework/packages/plugins/plugin-webhooks
3
- > tsup --config ../../../tsup.config.ts
2
+ > @objectstack/plugin-webhooks@6.0.0 build /home/runner/work/framework/framework/packages/plugins/plugin-webhooks
3
+ > tsup
4
4
 
5
- CLI Building entry: src/index.ts
5
+ CLI Building entry: src/index.ts, src/schema.ts, src/sql-outbox.ts
6
6
  CLI Using tsconfig: tsconfig.json
7
7
  CLI tsup v8.5.1
8
- CLI Using tsup config: /home/runner/work/framework/framework/tsup.config.ts
8
+ CLI Using tsup config: /home/runner/work/framework/framework/packages/plugins/plugin-webhooks/tsup.config.ts
9
9
  CLI Target: es2020
10
10
  CLI Cleaning output folder
11
11
  ESM Build start
12
12
  CJS Build start
13
- ESM dist/index.mjs 7.36 KB
14
- ESM dist/index.mjs.map 15.67 KB
15
- ESM ⚡️ Build success in 97ms
16
- CJS dist/index.js 9.02 KB
17
- CJS dist/index.js.map 16.38 KB
18
- CJS ⚡️ Build success in 110ms
13
+ ESM dist/index.js 27.98 KB
14
+ ESM dist/schema.js 175.00 B
15
+ ESM dist/sql-outbox.js 157.00 B
16
+ ESM dist/chunk-BS2QTZH3.js 6.92 KB
17
+ ESM dist/chunk-33LYZT7O.js 7.13 KB
18
+ ESM dist/index.js.map 73.03 KB
19
+ ESM dist/schema.js.map 71.00 B
20
+ ESM dist/sql-outbox.js.map 71.00 B
21
+ ESM dist/chunk-BS2QTZH3.js.map 24.11 KB
22
+ ESM dist/chunk-33LYZT7O.js.map 14.02 KB
23
+ ESM ⚡️ Build success in 958ms
24
+ CJS dist/index.cjs 33.81 KB
25
+ CJS dist/schema.cjs 309.00 B
26
+ CJS dist/sql-outbox.cjs 269.00 B
27
+ CJS dist/chunk-FA66GQEO.cjs 8.30 KB
28
+ CJS dist/chunk-MJZGD37S.cjs 7.37 KB
29
+ CJS dist/schema.cjs.map 288.00 B
30
+ CJS dist/sql-outbox.cjs.map 299.00 B
31
+ CJS dist/index.cjs.map 65.94 KB
32
+ CJS dist/chunk-FA66GQEO.cjs.map 27.71 KB
33
+ CJS dist/chunk-MJZGD37S.cjs.map 16.72 KB
34
+ CJS ⚡️ Build success in 979ms
19
35
  DTS Build start
20
- DTS ⚡️ Build success in 9704ms
21
- DTS dist/index.d.mts 3.46 KB
22
- DTS dist/index.d.ts 3.46 KB
36
+ DTS ⚡️ Build success in 13284ms
37
+ DTS dist/index.d.ts 17.42 KB
38
+ DTS dist/schema.d.ts 211.97 KB
39
+ DTS dist/sql-outbox.d.ts 2.44 KB
40
+ DTS dist/outbox-CIn7LSyB.d.ts 5.82 KB
41
+ DTS dist/index.d.cts 17.42 KB
42
+ DTS dist/schema.d.cts 211.97 KB
43
+ DTS dist/sql-outbox.d.cts 2.45 KB
44
+ DTS dist/outbox-CIn7LSyB.d.cts 5.82 KB
package/CHANGELOG.md CHANGED
@@ -1,42 +1,26 @@
1
1
  # @objectstack/plugin-webhooks
2
2
 
3
- ## 5.1.0
3
+ ## 6.0.0
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - Updated dependencies [75f4ee6]
8
- - Updated dependencies [823d559]
9
- - @objectstack/spec@5.1.0
10
- - @objectstack/core@5.1.0
7
+ - Updated dependencies [629a716]
8
+ - Updated dependencies [dbc4f7d]
9
+ - Updated dependencies [944f187]
10
+ - @objectstack/spec@6.0.0
11
+ - @objectstack/platform-objects@6.0.0
12
+ - @objectstack/core@6.0.0
13
+ - @objectstack/service-cluster@5.1.2
11
14
 
12
- ## 5.0.0
15
+ ## 5.2.0
13
16
 
14
17
  ### Patch Changes
15
18
 
16
- - Updated dependencies [2f9073a]
17
- - @objectstack/spec@5.0.0
18
- - @objectstack/core@5.0.0
19
-
20
- ## 4.2.0
21
-
22
- ### Patch Changes
23
-
24
- - Updated dependencies [2869891]
25
- - @objectstack/spec@4.2.0
26
- - @objectstack/core@4.2.0
27
-
28
- ## 4.1.1
29
-
30
- ### Patch Changes
31
-
32
- - @objectstack/spec@4.1.1
33
- - @objectstack/core@4.1.1
34
-
35
- ## 4.0.1
36
-
37
- ### Patch Changes
38
-
39
- - Updated dependencies [2108c30]
40
- - Updated dependencies [23db640]
41
- - @objectstack/spec@4.1.0
42
- - @objectstack/core@4.1.0
19
+ - Updated dependencies [bab2b20]
20
+ - Updated dependencies [fa011d8]
21
+ - Updated dependencies [f0f7c27]
22
+ - Updated dependencies [b806f58]
23
+ - @objectstack/platform-objects@5.2.0
24
+ - @objectstack/spec@5.2.0
25
+ - @objectstack/core@5.2.0
26
+ - @objectstack/service-cluster@5.1.1
@@ -0,0 +1,184 @@
1
+ // src/sys-webhook-delivery.object.ts
2
+ import { Field, ObjectSchema } from "@objectstack/spec/data";
3
+ var SysWebhookDelivery = ObjectSchema.create({
4
+ name: "sys_webhook_delivery",
5
+ label: "Webhook Delivery",
6
+ pluralLabel: "Webhook Deliveries",
7
+ icon: "package",
8
+ isSystem: true,
9
+ managedBy: "config",
10
+ userActions: { create: false, edit: false, delete: false, import: false },
11
+ description: "Durable outbox row for one webhook attempt. Managed by @objectstack/plugin-webhooks; do not write directly.",
12
+ displayNameField: "id",
13
+ titleFormat: "{event_type} \u2192 {url}",
14
+ compactLayout: ["event_type", "url", "status", "attempts", "next_retry_at"],
15
+ actions: [
16
+ {
17
+ name: "redeliver",
18
+ label: "Redeliver",
19
+ icon: "refresh-cw",
20
+ variant: "secondary",
21
+ locations: ["list_item", "record_header"],
22
+ type: "api",
23
+ target: "/api/v1/webhooks/redeliver",
24
+ method: "POST",
25
+ recordIdParam: "deliveryId",
26
+ confirmText: "Replay this delivery? The receiver will get the original payload again \u2014 they must be idempotent on the X-Objectstack-Delivery header.",
27
+ successMessage: "Queued for redelivery",
28
+ refreshAfter: true,
29
+ // Only terminal rows are safe to replay. Pending / in_flight rows
30
+ // are either already queued or actively being sent — replaying
31
+ // would double-deliver.
32
+ disabled: "!(status in ['success', 'failed', 'dead'])"
33
+ }
34
+ ],
35
+ listViews: {
36
+ recent: {
37
+ type: "grid",
38
+ name: "recent",
39
+ label: "Recent",
40
+ data: { provider: "object", object: "sys_webhook_delivery" },
41
+ columns: ["event_type", "url", "status", "attempts", "response_code", "updated_at"],
42
+ sort: [{ field: "updated_at", order: "desc" }],
43
+ pagination: { pageSize: 50 }
44
+ },
45
+ failures: {
46
+ type: "grid",
47
+ name: "failures",
48
+ label: "Failures",
49
+ data: { provider: "object", object: "sys_webhook_delivery" },
50
+ columns: ["event_type", "url", "status", "attempts", "response_code", "error", "updated_at"],
51
+ filter: [{ field: "status", operator: "in", value: ["failed", "dead"] }],
52
+ sort: [{ field: "updated_at", order: "desc" }],
53
+ pagination: { pageSize: 50 }
54
+ },
55
+ in_flight: {
56
+ type: "grid",
57
+ name: "in_flight",
58
+ label: "In Flight",
59
+ data: { provider: "object", object: "sys_webhook_delivery" },
60
+ columns: ["event_type", "url", "attempts", "claimed_by", "claimed_at"],
61
+ filter: [{ field: "status", operator: "equals", value: "in_flight" }],
62
+ sort: [{ field: "claimed_at", order: "desc" }],
63
+ pagination: { pageSize: 50 }
64
+ },
65
+ pending: {
66
+ type: "grid",
67
+ name: "pending",
68
+ label: "Pending",
69
+ data: { provider: "object", object: "sys_webhook_delivery" },
70
+ columns: ["event_type", "url", "attempts", "next_retry_at", "updated_at"],
71
+ filter: [{ field: "status", operator: "equals", value: "pending" }],
72
+ sort: [{ field: "next_retry_at", order: "asc" }],
73
+ pagination: { pageSize: 50 }
74
+ },
75
+ by_status: {
76
+ type: "grid",
77
+ name: "by_status",
78
+ label: "By Status",
79
+ data: { provider: "object", object: "sys_webhook_delivery" },
80
+ columns: ["status", "event_type", "url", "attempts", "updated_at"],
81
+ sort: [{ field: "status", order: "asc" }, { field: "updated_at", order: "desc" }],
82
+ grouping: { fields: [{ field: "status", order: "asc", collapsed: false }] },
83
+ pagination: { pageSize: 100 }
84
+ },
85
+ by_webhook: {
86
+ type: "grid",
87
+ name: "by_webhook",
88
+ label: "By Webhook",
89
+ data: { provider: "object", object: "sys_webhook_delivery" },
90
+ columns: ["webhook_id", "event_type", "status", "attempts", "updated_at"],
91
+ sort: [{ field: "webhook_id", order: "asc" }, { field: "updated_at", order: "desc" }],
92
+ grouping: { fields: [{ field: "webhook_id", order: "asc", collapsed: true }] },
93
+ pagination: { pageSize: 100 }
94
+ },
95
+ all_deliveries: {
96
+ type: "grid",
97
+ name: "all_deliveries",
98
+ label: "All",
99
+ data: { provider: "object", object: "sys_webhook_delivery" },
100
+ columns: ["event_type", "url", "status", "attempts", "response_code", "updated_at"],
101
+ sort: [{ field: "updated_at", order: "desc" }],
102
+ pagination: { pageSize: 100 }
103
+ }
104
+ },
105
+ fields: {
106
+ id: Field.text({
107
+ label: "Delivery ID",
108
+ required: true,
109
+ maxLength: 64,
110
+ description: "UUID \u2014 also doubles as the receiver-side idempotency key"
111
+ }),
112
+ webhook_id: Field.text({
113
+ label: "Webhook ID",
114
+ required: true,
115
+ maxLength: 64,
116
+ description: "FK to sys_webhook.id (loosely coupled \u2014 denormalised URL/secret on row)"
117
+ }),
118
+ event_id: Field.text({
119
+ label: "Event ID",
120
+ required: true,
121
+ maxLength: 128,
122
+ description: "Source event id; UNIQUE(event_id, webhook_id) for dedup"
123
+ }),
124
+ event_type: Field.text({
125
+ label: "Event Type",
126
+ required: true,
127
+ maxLength: 128,
128
+ description: "e.g. data.record.created"
129
+ }),
130
+ url: Field.text({
131
+ label: "Target URL",
132
+ required: true,
133
+ maxLength: 2048,
134
+ description: "Snapshotted at enqueue so config edits do not rewrite live rows"
135
+ }),
136
+ method: Field.text({ label: "Method", required: false, maxLength: 10 }),
137
+ headers_json: Field.textarea({ label: "Headers JSON", required: false }),
138
+ secret: Field.text({ label: "HMAC Secret", required: false, maxLength: 256 }),
139
+ timeout_ms: Field.number({ label: "Timeout (ms)", required: false }),
140
+ payload_json: Field.textarea({ label: "Payload JSON", required: true }),
141
+ partition_key: Field.number({
142
+ label: "Partition",
143
+ required: true,
144
+ description: "hash(webhook_id) mod partitionCount \u2014 precomputed for cheap WHERE"
145
+ }),
146
+ status: Field.text({
147
+ label: "Status",
148
+ required: true,
149
+ defaultValue: "pending",
150
+ maxLength: 16,
151
+ description: "pending | in_flight | success | failed | dead"
152
+ }),
153
+ attempts: Field.number({
154
+ label: "Attempts",
155
+ required: true,
156
+ defaultValue: 0,
157
+ description: "Number of POST attempts made so far"
158
+ }),
159
+ claimed_by: Field.text({ label: "Claimed By", required: false, maxLength: 128 }),
160
+ claimed_at: Field.number({ label: "Claimed At (ms)", required: false }),
161
+ next_retry_at: Field.number({ label: "Next Retry At (ms)", required: false }),
162
+ last_attempted_at: Field.number({ label: "Last Attempted At (ms)", required: false }),
163
+ response_code: Field.number({ label: "HTTP Status", required: false }),
164
+ response_body: Field.textarea({ label: "Response Body (capped)", required: false }),
165
+ error: Field.textarea({ label: "Error", required: false }),
166
+ created_at: Field.number({ label: "Created At (ms)", required: true }),
167
+ updated_at: Field.number({ label: "Updated At (ms)", required: true })
168
+ },
169
+ indexes: [
170
+ { fields: ["event_id", "webhook_id"], unique: true },
171
+ // Hot path: claim query
172
+ { fields: ["status", "partition_key", "next_retry_at"] },
173
+ // Reaper: scan stale in_flight rows by claimed_at
174
+ { fields: ["status", "claimed_at"] },
175
+ { fields: ["webhook_id"] }
176
+ ]
177
+ });
178
+ var SYS_WEBHOOK_DELIVERY = "sys_webhook_delivery";
179
+
180
+ export {
181
+ SysWebhookDelivery,
182
+ SYS_WEBHOOK_DELIVERY
183
+ };
184
+ //# sourceMappingURL=chunk-33LYZT7O.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/sys-webhook-delivery.object.ts"],"sourcesContent":["// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.\n\nimport { Field, ObjectSchema } from '@objectstack/spec/data';\n\n/**\n * sys_webhook_delivery — Durable outbox row for one HTTP attempt.\n *\n * Schema is owned by `@objectstack/plugin-webhooks`. Add it to your stack\n * via:\n *\n * import { SysWebhookDelivery } from '@objectstack/plugin-webhooks/schema';\n * defineStack({ objects: [SysWebhookDelivery, ...], plugins: [...] });\n *\n * Designed for the SqlWebhookOutbox claim algorithm:\n *\n * 1. Producers INSERT pending rows (dedup'd by (event_id, webhook_id)).\n * 2. The dispatcher's per-partition lock-holder runs:\n * SELECT id WHERE status='pending' AND partition_key=? AND (next_retry_at <= now OR null)\n * UPDATE SET status='in_flight' WHERE id IN (...) AND status='pending' ← atomic claim\n * POST to target URL\n * UPDATE SET status=success/pending/dead, attempts=attempts+1, ...\n *\n * `partition_key` is precomputed on enqueue (hash(webhook_id) mod N) so the\n * dispatcher can filter cheaply without DB-side hash functions.\n *\n * Indexes are tuned for the hot path: `(status, partition_key, next_retry_at)`\n * is the claim query; `(event_id, webhook_id)` is the dedup uniqueness.\n *\n * @namespace sys\n */\nexport const SysWebhookDelivery = ObjectSchema.create({\n name: 'sys_webhook_delivery',\n label: 'Webhook Delivery',\n pluralLabel: 'Webhook Deliveries',\n icon: 'package',\n isSystem: true,\n managedBy: 'config',\n userActions: { create: false, edit: false, delete: false, import: false },\n description:\n 'Durable outbox row for one webhook attempt. Managed by @objectstack/plugin-webhooks; do not write directly.',\n displayNameField: 'id',\n titleFormat: '{event_type} → {url}',\n compactLayout: ['event_type', 'url', 'status', 'attempts', 'next_retry_at'],\n\n actions: [\n {\n name: 'redeliver',\n label: 'Redeliver',\n icon: 'refresh-cw',\n variant: 'secondary',\n locations: ['list_item', 'record_header'],\n type: 'api',\n target: '/api/v1/webhooks/redeliver',\n method: 'POST',\n recordIdParam: 'deliveryId',\n confirmText:\n 'Replay this delivery? The receiver will get the original payload again — they must be idempotent on the X-Objectstack-Delivery header.',\n successMessage: 'Queued for redelivery',\n refreshAfter: true,\n // Only terminal rows are safe to replay. Pending / in_flight rows\n // are either already queued or actively being sent — replaying\n // would double-deliver.\n disabled: \"!(status in ['success', 'failed', 'dead'])\",\n },\n ],\n\n listViews: {\n recent: {\n type: 'grid',\n name: 'recent',\n label: 'Recent',\n data: { provider: 'object', object: 'sys_webhook_delivery' },\n columns: ['event_type', 'url', 'status', 'attempts', 'response_code', 'updated_at'],\n sort: [{ field: 'updated_at', order: 'desc' }],\n pagination: { pageSize: 50 },\n },\n failures: {\n type: 'grid',\n name: 'failures',\n label: 'Failures',\n data: { provider: 'object', object: 'sys_webhook_delivery' },\n columns: ['event_type', 'url', 'status', 'attempts', 'response_code', 'error', 'updated_at'],\n filter: [{ field: 'status', operator: 'in', value: ['failed', 'dead'] }],\n sort: [{ field: 'updated_at', order: 'desc' }],\n pagination: { pageSize: 50 },\n },\n in_flight: {\n type: 'grid',\n name: 'in_flight',\n label: 'In Flight',\n data: { provider: 'object', object: 'sys_webhook_delivery' },\n columns: ['event_type', 'url', 'attempts', 'claimed_by', 'claimed_at'],\n filter: [{ field: 'status', operator: 'equals', value: 'in_flight' }],\n sort: [{ field: 'claimed_at', order: 'desc' }],\n pagination: { pageSize: 50 },\n },\n pending: {\n type: 'grid',\n name: 'pending',\n label: 'Pending',\n data: { provider: 'object', object: 'sys_webhook_delivery' },\n columns: ['event_type', 'url', 'attempts', 'next_retry_at', 'updated_at'],\n filter: [{ field: 'status', operator: 'equals', value: 'pending' }],\n sort: [{ field: 'next_retry_at', order: 'asc' }],\n pagination: { pageSize: 50 },\n },\n by_status: {\n type: 'grid',\n name: 'by_status',\n label: 'By Status',\n data: { provider: 'object', object: 'sys_webhook_delivery' },\n columns: ['status', 'event_type', 'url', 'attempts', 'updated_at'],\n sort: [{ field: 'status', order: 'asc' }, { field: 'updated_at', order: 'desc' }],\n grouping: { fields: [{ field: 'status', order: 'asc', collapsed: false }] },\n pagination: { pageSize: 100 },\n },\n by_webhook: {\n type: 'grid',\n name: 'by_webhook',\n label: 'By Webhook',\n data: { provider: 'object', object: 'sys_webhook_delivery' },\n columns: ['webhook_id', 'event_type', 'status', 'attempts', 'updated_at'],\n sort: [{ field: 'webhook_id', order: 'asc' }, { field: 'updated_at', order: 'desc' }],\n grouping: { fields: [{ field: 'webhook_id', order: 'asc', collapsed: true }] },\n pagination: { pageSize: 100 },\n },\n all_deliveries: {\n type: 'grid',\n name: 'all_deliveries',\n label: 'All',\n data: { provider: 'object', object: 'sys_webhook_delivery' },\n columns: ['event_type', 'url', 'status', 'attempts', 'response_code', 'updated_at'],\n sort: [{ field: 'updated_at', order: 'desc' }],\n pagination: { pageSize: 100 },\n },\n },\n\n fields: {\n id: Field.text({\n label: 'Delivery ID',\n required: true,\n maxLength: 64,\n description: 'UUID — also doubles as the receiver-side idempotency key',\n }),\n\n webhook_id: Field.text({\n label: 'Webhook ID',\n required: true,\n maxLength: 64,\n description: 'FK to sys_webhook.id (loosely coupled — denormalised URL/secret on row)',\n }),\n\n event_id: Field.text({\n label: 'Event ID',\n required: true,\n maxLength: 128,\n description: 'Source event id; UNIQUE(event_id, webhook_id) for dedup',\n }),\n\n event_type: Field.text({\n label: 'Event Type',\n required: true,\n maxLength: 128,\n description: 'e.g. data.record.created',\n }),\n\n url: Field.text({\n label: 'Target URL',\n required: true,\n maxLength: 2048,\n description: 'Snapshotted at enqueue so config edits do not rewrite live rows',\n }),\n\n method: Field.text({ label: 'Method', required: false, maxLength: 10 }),\n headers_json: Field.textarea({ label: 'Headers JSON', required: false }),\n secret: Field.text({ label: 'HMAC Secret', required: false, maxLength: 256 }),\n timeout_ms: Field.number({ label: 'Timeout (ms)', required: false }),\n payload_json: Field.textarea({ label: 'Payload JSON', required: true }),\n\n partition_key: Field.number({\n label: 'Partition',\n required: true,\n description: 'hash(webhook_id) mod partitionCount — precomputed for cheap WHERE',\n }),\n\n status: Field.text({\n label: 'Status',\n required: true,\n defaultValue: 'pending',\n maxLength: 16,\n description: 'pending | in_flight | success | failed | dead',\n }),\n\n attempts: Field.number({\n label: 'Attempts',\n required: true,\n defaultValue: 0,\n description: 'Number of POST attempts made so far',\n }),\n\n claimed_by: Field.text({ label: 'Claimed By', required: false, maxLength: 128 }),\n claimed_at: Field.number({ label: 'Claimed At (ms)', required: false }),\n next_retry_at: Field.number({ label: 'Next Retry At (ms)', required: false }),\n last_attempted_at: Field.number({ label: 'Last Attempted At (ms)', required: false }),\n response_code: Field.number({ label: 'HTTP Status', required: false }),\n response_body: Field.textarea({ label: 'Response Body (capped)', required: false }),\n error: Field.textarea({ label: 'Error', required: false }),\n\n created_at: Field.number({ label: 'Created At (ms)', required: true }),\n updated_at: Field.number({ label: 'Updated At (ms)', required: true }),\n },\n\n indexes: [\n { fields: ['event_id', 'webhook_id'], unique: true },\n // Hot path: claim query\n { fields: ['status', 'partition_key', 'next_retry_at'] },\n // Reaper: scan stale in_flight rows by claimed_at\n { fields: ['status', 'claimed_at'] },\n { fields: ['webhook_id'] },\n ],\n});\n\n/** Canonical object name — exported so SqlWebhookOutbox callers can override if needed. */\nexport const SYS_WEBHOOK_DELIVERY = 'sys_webhook_delivery' as const;\n"],"mappings":";AAEA,SAAS,OAAO,oBAAoB;AA4B7B,IAAM,qBAAqB,aAAa,OAAO;AAAA,EAClD,MAAM;AAAA,EACN,OAAO;AAAA,EACP,aAAa;AAAA,EACb,MAAM;AAAA,EACN,UAAU;AAAA,EACV,WAAW;AAAA,EACX,aAAa,EAAE,QAAQ,OAAO,MAAM,OAAO,QAAQ,OAAO,QAAQ,MAAM;AAAA,EACxE,aACI;AAAA,EACJ,kBAAkB;AAAA,EAClB,aAAa;AAAA,EACb,eAAe,CAAC,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A;AAAA,IAEnD,EAAE,QAAQ,CAAC,UAAU,iBAAiB,eAAe,EAAE;AAAA;AAAA,IAEvD,EAAE,QAAQ,CAAC,UAAU,YAAY,EAAE;AAAA,IACnC,EAAE,QAAQ,CAAC,YAAY,EAAE;AAAA,EAC7B;AACJ,CAAC;AAGM,IAAM,uBAAuB;","names":[]}
@@ -0,0 +1,256 @@
1
+ import {
2
+ SYS_WEBHOOK_DELIVERY
3
+ } from "./chunk-33LYZT7O.js";
4
+
5
+ // src/sql-outbox.ts
6
+ import { randomUUID } from "crypto";
7
+
8
+ // src/outbox.ts
9
+ var RedeliverError = class extends Error {
10
+ constructor(message, code) {
11
+ super(message);
12
+ this.code = code;
13
+ this.name = "RedeliverError";
14
+ }
15
+ };
16
+
17
+ // src/partition.ts
18
+ function hashPartition(key, count) {
19
+ if (count <= 0) throw new Error("partition count must be > 0");
20
+ let h = 2166136261;
21
+ for (let i = 0; i < key.length; i++) {
22
+ h ^= key.charCodeAt(i);
23
+ h = Math.imul(h, 16777619);
24
+ }
25
+ return Math.abs(h | 0) % count;
26
+ }
27
+
28
+ // src/sql-outbox.ts
29
+ var SqlWebhookOutbox = class {
30
+ constructor(engine, opts) {
31
+ this.engine = engine;
32
+ if (opts.partitionCount <= 0) {
33
+ throw new Error("SqlWebhookOutbox: partitionCount must be > 0");
34
+ }
35
+ this.objectName = opts.objectName ?? SYS_WEBHOOK_DELIVERY;
36
+ this.partitionCount = opts.partitionCount;
37
+ }
38
+ async enqueue(input) {
39
+ const existing = await this.engine.findOne(this.objectName, {
40
+ where: { event_id: input.eventId, webhook_id: input.webhookId },
41
+ fields: ["id"]
42
+ });
43
+ if (existing?.id) return existing.id;
44
+ const id = randomUUID();
45
+ const now = Date.now();
46
+ const row = {
47
+ id,
48
+ webhook_id: input.webhookId,
49
+ event_id: input.eventId,
50
+ event_type: input.eventType,
51
+ url: input.url,
52
+ method: input.method ?? "POST",
53
+ headers_json: input.headers ? JSON.stringify(input.headers) : void 0,
54
+ secret: input.secret,
55
+ timeout_ms: input.timeoutMs,
56
+ payload_json: JSON.stringify(input.payload ?? null),
57
+ partition_key: hashPartition(input.webhookId, this.partitionCount),
58
+ status: "pending",
59
+ attempts: 0,
60
+ created_at: now,
61
+ updated_at: now
62
+ };
63
+ try {
64
+ await this.engine.insert(this.objectName, row);
65
+ return id;
66
+ } catch (err) {
67
+ const winner = await this.engine.findOne(this.objectName, {
68
+ where: { event_id: input.eventId, webhook_id: input.webhookId },
69
+ fields: ["id"]
70
+ });
71
+ if (winner?.id) return winner.id;
72
+ throw err;
73
+ }
74
+ }
75
+ async claim(opts) {
76
+ const now = opts.now ?? Date.now();
77
+ await this.engine.update(
78
+ this.objectName,
79
+ { status: "pending", claimed_by: null, claimed_at: null, updated_at: now },
80
+ {
81
+ where: {
82
+ status: "in_flight",
83
+ claimed_at: { $lt: now - opts.claimTtlMs }
84
+ },
85
+ multi: true
86
+ }
87
+ );
88
+ const partitionFilter = opts.partition ? { partition_key: opts.partition.index } : {};
89
+ const candidates = await this.engine.find(this.objectName, {
90
+ where: {
91
+ status: "pending",
92
+ ...partitionFilter,
93
+ // next_retry_at <= now OR null
94
+ $or: [
95
+ { next_retry_at: null },
96
+ { next_retry_at: { $lte: now } }
97
+ ]
98
+ },
99
+ fields: ["id"],
100
+ // No orderBy for portability — drivers handle the natural insert order.
101
+ limit: opts.limit
102
+ });
103
+ if (candidates.length === 0) return [];
104
+ const ids = candidates.map((c) => c.id);
105
+ await this.engine.update(
106
+ this.objectName,
107
+ {
108
+ status: "in_flight",
109
+ claimed_by: opts.nodeId,
110
+ claimed_at: now,
111
+ updated_at: now
112
+ },
113
+ {
114
+ where: { id: { $in: ids }, status: "pending" },
115
+ multi: true
116
+ }
117
+ );
118
+ const claimed = await this.engine.find(this.objectName, {
119
+ where: {
120
+ id: { $in: ids },
121
+ claimed_by: opts.nodeId,
122
+ claimed_at: now,
123
+ status: "in_flight"
124
+ }
125
+ });
126
+ return claimed.map((r) => this.toDelivery(r));
127
+ }
128
+ async ack(id, result) {
129
+ const current = await this.engine.findOne(this.objectName, {
130
+ where: { id },
131
+ fields: ["attempts"]
132
+ });
133
+ if (!current) return;
134
+ const now = Date.now();
135
+ let status;
136
+ let nextRetryAt;
137
+ let error;
138
+ if (result.success) {
139
+ status = "success";
140
+ nextRetryAt = null;
141
+ error = null;
142
+ } else if (result.dead) {
143
+ status = "dead";
144
+ nextRetryAt = null;
145
+ error = result.error ?? null;
146
+ } else {
147
+ status = "pending";
148
+ nextRetryAt = result.nextRetryAt ?? null;
149
+ error = result.error ?? null;
150
+ }
151
+ await this.engine.update(
152
+ this.objectName,
153
+ {
154
+ status,
155
+ attempts: (current.attempts ?? 0) + 1,
156
+ last_attempted_at: now,
157
+ claimed_by: null,
158
+ claimed_at: null,
159
+ response_code: result.httpStatus ?? null,
160
+ response_body: result.responseBody ?? null,
161
+ next_retry_at: nextRetryAt,
162
+ error,
163
+ updated_at: now
164
+ },
165
+ { where: { id }, multi: false }
166
+ );
167
+ }
168
+ async list(filter) {
169
+ const rows = await this.engine.find(this.objectName, {
170
+ where: filter?.status ? { status: filter.status } : {}
171
+ });
172
+ return rows.map((r) => this.toDelivery(r));
173
+ }
174
+ async redeliver(id) {
175
+ const current = await this.engine.findOne(this.objectName, {
176
+ where: { id }
177
+ });
178
+ if (!current) {
179
+ throw new RedeliverError(
180
+ `Delivery row '${id}' not found`,
181
+ "not_found"
182
+ );
183
+ }
184
+ if (current.status !== "success" && current.status !== "failed" && current.status !== "dead") {
185
+ throw new RedeliverError(
186
+ `Delivery row '${id}' is '${current.status}', expected one of: success, failed, dead`,
187
+ "not_eligible"
188
+ );
189
+ }
190
+ const now = Date.now();
191
+ await this.engine.update(
192
+ this.objectName,
193
+ {
194
+ status: "pending",
195
+ attempts: 0,
196
+ claimed_by: null,
197
+ claimed_at: null,
198
+ next_retry_at: null,
199
+ last_attempted_at: null,
200
+ response_code: null,
201
+ response_body: null,
202
+ error: null,
203
+ updated_at: now
204
+ },
205
+ {
206
+ where: {
207
+ id,
208
+ status: { $in: ["success", "failed", "dead"] }
209
+ },
210
+ multi: false
211
+ }
212
+ );
213
+ const after = await this.engine.findOne(this.objectName, {
214
+ where: { id }
215
+ });
216
+ if (!after || after.status !== "pending") {
217
+ throw new RedeliverError(
218
+ `Delivery row '${id}' state changed during redeliver`,
219
+ "not_eligible"
220
+ );
221
+ }
222
+ return this.toDelivery(after);
223
+ }
224
+ toDelivery(r) {
225
+ return {
226
+ id: r.id,
227
+ webhookId: r.webhook_id,
228
+ eventId: r.event_id,
229
+ eventType: r.event_type,
230
+ url: r.url,
231
+ method: r.method ?? void 0,
232
+ headers: r.headers_json ? JSON.parse(r.headers_json) : void 0,
233
+ secret: r.secret ?? void 0,
234
+ timeoutMs: r.timeout_ms ?? void 0,
235
+ payload: JSON.parse(r.payload_json),
236
+ status: r.status,
237
+ attempts: r.attempts,
238
+ claimedBy: r.claimed_by ?? void 0,
239
+ claimedAt: r.claimed_at ?? void 0,
240
+ nextRetryAt: r.next_retry_at ?? void 0,
241
+ lastAttemptedAt: r.last_attempted_at ?? void 0,
242
+ responseCode: r.response_code ?? void 0,
243
+ responseBody: r.response_body ?? void 0,
244
+ error: r.error ?? void 0,
245
+ createdAt: r.created_at,
246
+ updatedAt: r.updated_at
247
+ };
248
+ }
249
+ };
250
+
251
+ export {
252
+ RedeliverError,
253
+ hashPartition,
254
+ SqlWebhookOutbox
255
+ };
256
+ //# sourceMappingURL=chunk-BS2QTZH3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/sql-outbox.ts","../src/outbox.ts","../src/partition.ts"],"sourcesContent":["// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.\n\nimport { randomUUID } from 'node:crypto';\nimport type { IDataEngine } from '@objectstack/spec/contracts';\nimport type {\n AckResult,\n ClaimOptions,\n DeliveryStatus,\n EnqueueInput,\n IWebhookOutbox,\n WebhookDelivery,\n} from './outbox.js';\nimport { RedeliverError } from './outbox.js';\nimport { hashPartition } from './partition.js';\nimport { SYS_WEBHOOK_DELIVERY } from './schema.js';\n\nexport interface SqlWebhookOutboxOptions {\n /**\n * Total partition count — MUST match the dispatcher's `partitionCount`.\n * Used at enqueue time to precompute `partition_key`.\n */\n partitionCount: number;\n /**\n * Object name to read/write. Defaults to `sys_webhook_delivery`. Override\n * only if you've registered the schema under a different name.\n */\n objectName?: string;\n}\n\ninterface DeliveryRow {\n id: string;\n webhook_id: string;\n event_id: string;\n event_type: string;\n url: string;\n method?: string | null;\n headers_json?: string | null;\n secret?: string | null;\n timeout_ms?: number | null;\n payload_json: string;\n partition_key: number;\n status: DeliveryStatus;\n attempts: number;\n claimed_by?: string | null;\n claimed_at?: number | null;\n next_retry_at?: number | null;\n last_attempted_at?: number | null;\n response_code?: number | null;\n response_body?: string | null;\n error?: string | null;\n created_at: number;\n updated_at: number;\n}\n\n/**\n * Durable `IWebhookOutbox` backed by ObjectQL — the production storage\n * impl. Works against any registered driver (SQL, Turso, Mongo, in-memory)\n * because everything goes through the driver-agnostic `IDataEngine` API.\n *\n * **Why no `FOR UPDATE SKIP LOCKED`?** ObjectQL is driver-agnostic — that\n * SQL feature is Postgres-only. We get equivalent safety from two layers:\n *\n * 1. `cluster.lock` held per partition by the dispatcher (the primary\n * mutex). One node owns one partition at a time → no two claimers.\n * 2. Atomic `UPDATE WHERE status='pending'` (the backup). Even if two\n * claimers slip through (e.g. admin reschedule + dispatcher), only\n * the first UPDATE matches each row.\n *\n * **Why precompute `partition_key` on enqueue?** ObjectQL has no\n * cross-driver `hash()` function in WHERE clauses. Storing the partition\n * as a column makes the claim query a plain indexed lookup.\n *\n * **Dedup race**: SELECT-then-INSERT has a tiny window where two\n * concurrent producers both miss the SELECT and both INSERT. The unique\n * index `(event_id, webhook_id)` on the table catches it — the second\n * INSERT errors, the producer ignores it. Receivers MUST be idempotent\n * on the `X-Objectstack-Delivery` header anyway.\n */\nexport class SqlWebhookOutbox implements IWebhookOutbox {\n private readonly objectName: string;\n private readonly partitionCount: number;\n\n constructor(\n private readonly engine: IDataEngine,\n opts: SqlWebhookOutboxOptions,\n ) {\n if (opts.partitionCount <= 0) {\n throw new Error('SqlWebhookOutbox: partitionCount must be > 0');\n }\n this.objectName = opts.objectName ?? SYS_WEBHOOK_DELIVERY;\n this.partitionCount = opts.partitionCount;\n }\n\n async enqueue(input: EnqueueInput): Promise<string> {\n // Cheap pre-check to absorb most duplicates without hitting the\n // unique-index error path. Race window with the INSERT below is\n // intentional and documented.\n const existing = await this.engine.findOne(this.objectName, {\n where: { event_id: input.eventId, webhook_id: input.webhookId },\n fields: ['id'],\n });\n if (existing?.id) return existing.id as string;\n\n const id = randomUUID();\n const now = Date.now();\n const row: Omit<DeliveryRow, 'response_body' | 'error'> = {\n id,\n webhook_id: input.webhookId,\n event_id: input.eventId,\n event_type: input.eventType,\n url: input.url,\n method: input.method ?? 'POST',\n headers_json: input.headers ? JSON.stringify(input.headers) : undefined,\n secret: input.secret,\n timeout_ms: input.timeoutMs,\n payload_json: JSON.stringify(input.payload ?? null),\n partition_key: hashPartition(input.webhookId, this.partitionCount),\n status: 'pending',\n attempts: 0,\n created_at: now,\n updated_at: now,\n };\n try {\n await this.engine.insert(this.objectName, row);\n return id;\n } catch (err) {\n // Unique-index collision (dedup race) → look up the winner and\n // return its id. Any other error propagates.\n const winner = await this.engine.findOne(this.objectName, {\n where: { event_id: input.eventId, webhook_id: input.webhookId },\n fields: ['id'],\n });\n if (winner?.id) return winner.id as string;\n throw err;\n }\n }\n\n async claim(opts: ClaimOptions): Promise<WebhookDelivery[]> {\n const now = opts.now ?? Date.now();\n\n // 1. Reap stale in_flight rows — visibility-timeout recovery.\n await this.engine.update(\n this.objectName,\n { status: 'pending', claimed_by: null, claimed_at: null, updated_at: now },\n {\n where: {\n status: 'in_flight',\n claimed_at: { $lt: now - opts.claimTtlMs },\n },\n multi: true,\n },\n );\n\n // 2. Pick candidate ids.\n const partitionFilter = opts.partition\n ? { partition_key: opts.partition.index }\n : {};\n const candidates = await this.engine.find(this.objectName, {\n where: {\n status: 'pending',\n ...partitionFilter,\n // next_retry_at <= now OR null\n $or: [\n { next_retry_at: null },\n { next_retry_at: { $lte: now } },\n ],\n },\n fields: ['id'],\n // No orderBy for portability — drivers handle the natural insert order.\n limit: opts.limit,\n });\n if (candidates.length === 0) return [];\n\n const ids = (candidates as Array<{ id: string }>).map((c) => c.id);\n\n // 3. Atomic claim. WHERE status='pending' rejects any rows another\n // worker swept up between steps 2 and 3.\n await this.engine.update(\n this.objectName,\n {\n status: 'in_flight',\n claimed_by: opts.nodeId,\n claimed_at: now,\n updated_at: now,\n },\n {\n where: { id: { $in: ids }, status: 'pending' },\n multi: true,\n },\n );\n\n // 4. Read back the rows we actually own.\n const claimed = (await this.engine.find(this.objectName, {\n where: {\n id: { $in: ids },\n claimed_by: opts.nodeId,\n claimed_at: now,\n status: 'in_flight',\n },\n })) as DeliveryRow[];\n\n return claimed.map((r) => this.toDelivery(r));\n }\n\n async ack(id: string, result: AckResult): Promise<void> {\n // ObjectQL has no atomic $inc across drivers, so read-then-write.\n // Safe enough: ack is single-writer per row (only the claimer acks).\n const current = (await this.engine.findOne(this.objectName, {\n where: { id },\n fields: ['attempts'],\n })) as { attempts?: number } | null;\n if (!current) return;\n\n const now = Date.now();\n let status: DeliveryStatus;\n let nextRetryAt: number | null;\n let error: string | null;\n\n if (result.success) {\n status = 'success';\n nextRetryAt = null;\n error = null;\n } else if (result.dead) {\n status = 'dead';\n nextRetryAt = null;\n error = result.error ?? null;\n } else {\n status = 'pending';\n nextRetryAt = result.nextRetryAt ?? null;\n error = result.error ?? null;\n }\n\n await this.engine.update(\n this.objectName,\n {\n status,\n attempts: (current.attempts ?? 0) + 1,\n last_attempted_at: now,\n claimed_by: null,\n claimed_at: null,\n response_code: result.httpStatus ?? null,\n response_body: result.responseBody ?? null,\n next_retry_at: nextRetryAt,\n error,\n updated_at: now,\n },\n { where: { id }, multi: false },\n );\n }\n\n async list(filter?: { status?: DeliveryStatus }): Promise<WebhookDelivery[]> {\n const rows = (await this.engine.find(this.objectName, {\n where: filter?.status ? { status: filter.status } : {},\n })) as DeliveryRow[];\n return rows.map((r) => this.toDelivery(r));\n }\n\n async redeliver(id: string): Promise<WebhookDelivery> {\n const current = (await this.engine.findOne(this.objectName, {\n where: { id },\n })) as DeliveryRow | null;\n if (!current) {\n throw new RedeliverError(\n `Delivery row '${id}' not found`,\n 'not_found',\n );\n }\n if (\n current.status !== 'success' &&\n current.status !== 'failed' &&\n current.status !== 'dead'\n ) {\n throw new RedeliverError(\n `Delivery row '${id}' is '${current.status}', expected one of: success, failed, dead`,\n 'not_eligible',\n );\n }\n const now = Date.now();\n // Guarded UPDATE — re-check status server-side so two concurrent\n // redeliver calls cannot both flip the row, and so a dispatcher\n // tick that flipped the row to in_flight between our SELECT and\n // UPDATE cannot be clobbered.\n await this.engine.update(\n this.objectName,\n {\n status: 'pending',\n attempts: 0,\n claimed_by: null,\n claimed_at: null,\n next_retry_at: null,\n last_attempted_at: null,\n response_code: null,\n response_body: null,\n error: null,\n updated_at: now,\n },\n {\n where: {\n id,\n status: { $in: ['success', 'failed', 'dead'] },\n },\n multi: false,\n },\n );\n const after = (await this.engine.findOne(this.objectName, {\n where: { id },\n })) as DeliveryRow | null;\n if (!after || after.status !== 'pending') {\n // Lost the race — another writer flipped the row.\n throw new RedeliverError(\n `Delivery row '${id}' state changed during redeliver`,\n 'not_eligible',\n );\n }\n return this.toDelivery(after);\n }\n\n private toDelivery(r: DeliveryRow): WebhookDelivery {\n return {\n id: r.id,\n webhookId: r.webhook_id,\n eventId: r.event_id,\n eventType: r.event_type,\n url: r.url,\n method: r.method ?? undefined,\n headers: r.headers_json ? JSON.parse(r.headers_json) : undefined,\n secret: r.secret ?? undefined,\n timeoutMs: r.timeout_ms ?? undefined,\n payload: JSON.parse(r.payload_json),\n status: r.status,\n attempts: r.attempts,\n claimedBy: r.claimed_by ?? undefined,\n claimedAt: r.claimed_at ?? undefined,\n nextRetryAt: r.next_retry_at ?? undefined,\n lastAttemptedAt: r.last_attempted_at ?? undefined,\n responseCode: r.response_code ?? undefined,\n responseBody: r.response_body ?? undefined,\n error: r.error ?? undefined,\n createdAt: r.created_at,\n updatedAt: r.updated_at,\n };\n }\n}\n","// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.\n\n/**\n * Webhook outbox contracts.\n *\n * The outbox stores webhook delivery rows that must be POSTed exactly once\n * (modulo at-least-once + receiver-side idempotency). Implementations are\n * pluggable so the same dispatcher can run against an in-memory test store\n * or a SQL-backed production table.\n *\n * See `content/docs/concepts/webhook-delivery.mdx` §3.2 for the full schema.\n */\n\nexport type DeliveryStatus =\n | 'pending'\n | 'in_flight'\n | 'success'\n | 'failed'\n | 'dead';\n\nexport interface WebhookDelivery {\n /** UUID — also doubles as the receiver-side idempotency key. */\n id: string;\n /** FK to sys_webhook.id — opaque to the dispatcher; only used for hashing. */\n webhookId: string;\n /** Origin event id. UNIQUE(event_id, webhook_id) prevents double-enqueue. */\n eventId: string;\n /** Origin event type, e.g. `data.record.created`. */\n eventType: string;\n /** Destination URL (snapshotted on enqueue — config edits don't rewrite live rows). */\n url: string;\n /** HTTP method — defaults to POST. */\n method?: string;\n /** Custom headers configured on the sink. */\n headers?: Record<string, string>;\n /** HMAC-SHA256 secret. If present, signature is added. */\n secret?: string;\n /** Per-request timeout in ms. */\n timeoutMs?: number;\n /** JSON-serialisable body. */\n payload: unknown;\n\n /** Lifecycle state. */\n status: DeliveryStatus;\n /** Number of POST attempts made so far (0 before first attempt). */\n attempts: number;\n /** Node id currently working on this row, when `status = in_flight`. */\n claimedBy?: string;\n /** Wall-clock ms when the row was claimed. */\n claimedAt?: number;\n /** Earliest ms at which this row becomes eligible for the next attempt. */\n nextRetryAt?: number;\n /** Wall-clock ms of the last attempt (success or fail). */\n lastAttemptedAt?: number;\n /** HTTP status code from the most recent attempt. */\n responseCode?: number;\n /** Truncated response body for diagnostics. */\n responseBody?: string;\n /** Last transport / timeout error message. */\n error?: string;\n\n createdAt: number;\n updatedAt: number;\n}\n\nexport interface EnqueueInput {\n webhookId: string;\n eventId: string;\n eventType: string;\n url: string;\n method?: string;\n headers?: Record<string, string>;\n secret?: string;\n timeoutMs?: number;\n payload: unknown;\n}\n\nexport interface ClaimOptions {\n /** Identifier of the node doing the claim (for `claimedBy`). */\n nodeId: string;\n /** Max rows to claim per call. */\n limit: number;\n /**\n * Partition assignment for this worker. Only rows whose\n * `hash(webhookId) mod count === index` are claimed. Omit to claim\n * across all partitions (single-node mode).\n */\n partition?: { index: number; count: number };\n /** Visibility timeout — claimed rows revert to pending after this many ms. */\n claimTtlMs: number;\n /** \"Now\" reference, ms since epoch. Defaults to Date.now(). */\n now?: number;\n}\n\nexport interface AckSuccess {\n success: true;\n httpStatus: number;\n responseBody?: string;\n durationMs: number;\n}\n\nexport interface AckFailure {\n success: false;\n httpStatus?: number;\n responseBody?: string;\n error?: string;\n durationMs: number;\n /** Computed by the dispatcher per the retry schedule, or undefined for dead. */\n nextRetryAt?: number;\n /** Marks the row terminal — no more attempts. */\n dead?: boolean;\n}\n\nexport type AckResult = AckSuccess | AckFailure;\n\n/**\n * Error raised by `IWebhookOutbox.redeliver` when the requested row is\n * either missing or in a non-terminal state. The dispatcher / admin UI\n * surfaces this verbatim to the caller — never throw it for transient\n * conditions (transport errors should bubble as native `Error`).\n */\nexport class RedeliverError extends Error {\n constructor(\n message: string,\n readonly code: 'not_found' | 'not_eligible',\n ) {\n super(message);\n this.name = 'RedeliverError';\n }\n}\n\n/**\n * Pluggable storage backend for delivery rows. Implementations MUST make\n * `claim()` atomic across concurrent callers — that property is the\n * exactly-once guarantee.\n */\nexport interface IWebhookOutbox {\n /**\n * Insert a new delivery row. Implementations MUST treat\n * `(eventId, webhookId)` as unique and silently drop duplicates.\n * Returns the row id (existing or new).\n */\n enqueue(input: EnqueueInput): Promise<string>;\n\n /**\n * Atomically claim up to `limit` rows whose `nextRetryAt <= now` (or\n * null) and matching the partition predicate. Claimed rows MUST be\n * marked `in_flight` so concurrent claimers don't see them.\n */\n claim(opts: ClaimOptions): Promise<WebhookDelivery[]>;\n\n /** Record the outcome of an attempt. */\n ack(id: string, result: AckResult): Promise<void>;\n\n /** Snapshot accessor for tests / admin tooling. */\n list(filter?: { status?: DeliveryStatus }): Promise<WebhookDelivery[]>;\n\n /**\n * Reset a terminal row back to `pending` so the dispatcher will pick\n * it up again on its next tick.\n *\n * - Eligible source states: `success`, `failed`, `dead`.\n * - Rejects `pending` / `in_flight` rows — replaying those would\n * double-deliver because they're either already queued or actively\n * being sent.\n * - Resets `attempts=0` so the retry budget restarts.\n * - Clears `claimed_by`, `claimed_at`, `next_retry_at`, `error`,\n * `response_code`, `response_body`. URL / payload / secret are NOT\n * touched — replay reproduces the original POST byte-for-byte.\n *\n * Throws `RedeliverError` with code `not_found` or `not_eligible`.\n * Returns the post-reset row.\n */\n redeliver(id: string): Promise<WebhookDelivery>;\n}\n","// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.\n\n/**\n * Stable, framework-free partition hash. The dispatcher uses this to\n * assign webhooks to partitions; the in-memory outbox uses the same hash\n * to filter rows in `claim()`. Both call sites MUST agree, which is why\n * this is a single shared helper.\n *\n * Uses a 32-bit FNV-1a variant — fast, no allocations, deterministic.\n */\nexport function hashPartition(key: string, count: number): number {\n if (count <= 0) throw new Error('partition count must be > 0');\n let h = 0x811c9dc5;\n for (let i = 0; i < key.length; i++) {\n h ^= key.charCodeAt(i);\n h = Math.imul(h, 0x01000193);\n }\n return Math.abs(h | 0) % count;\n}\n"],"mappings":";;;;;AAEA,SAAS,kBAAkB;;;ACuHpB,IAAM,iBAAN,cAA6B,MAAM;AAAA,EACtC,YACI,SACS,MACX;AACE,UAAM,OAAO;AAFJ;AAGT,SAAK,OAAO;AAAA,EAChB;AACJ;;;ACvHO,SAAS,cAAc,KAAa,OAAuB;AAC9D,MAAI,SAAS,EAAG,OAAM,IAAI,MAAM,6BAA6B;AAC7D,MAAI,IAAI;AACR,WAAS,IAA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