@objectstack/plugin-webhooks 7.5.0 → 7.6.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.
- package/.turbo/turbo-build.log +20 -32
- package/CHANGELOG.md +49 -0
- package/dist/chunk-HWFTXTTI.js +138 -0
- package/dist/chunk-HWFTXTTI.js.map +1 -0
- package/dist/chunk-KPKLAXNA.cjs +138 -0
- package/dist/chunk-KPKLAXNA.cjs.map +1 -0
- package/dist/index.cjs +62 -616
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +41 -325
- package/dist/index.d.ts +41 -325
- package/dist/index.js +52 -606
- package/dist/index.js.map +1 -1
- package/dist/schema.cjs +2 -6
- package/dist/schema.cjs.map +1 -1
- package/dist/schema.d.cts +5 -4764
- package/dist/schema.d.ts +5 -4764
- package/dist/schema.js +3 -7
- package/package.json +4 -11
- package/src/auto-enqueuer.test.ts +83 -116
- package/src/auto-enqueuer.ts +38 -27
- package/src/index.ts +13 -40
- package/src/schema.ts +11 -16
- package/src/webhook-outbox-plugin.ts +80 -296
- package/tsup.config.ts +1 -1
- package/dist/chunk-7HS5DLU2.js +0 -319
- package/dist/chunk-7HS5DLU2.js.map +0 -1
- package/dist/chunk-HF7CCDPB.cjs +0 -256
- package/dist/chunk-HF7CCDPB.cjs.map +0 -1
- package/dist/chunk-KNGLLSSP.js +0 -256
- package/dist/chunk-KNGLLSSP.js.map +0 -1
- package/dist/chunk-TDSI7UHY.cjs +0 -319
- package/dist/chunk-TDSI7UHY.cjs.map +0 -1
- package/dist/outbox-CIn7LSyB.d.cts +0 -155
- package/dist/outbox-CIn7LSyB.d.ts +0 -155
- package/dist/sql-outbox.cjs +0 -8
- package/dist/sql-outbox.cjs.map +0 -1
- package/dist/sql-outbox.d.cts +0 -55
- package/dist/sql-outbox.d.ts +0 -55
- package/dist/sql-outbox.js +0 -8
- package/dist/sql-outbox.js.map +0 -1
- package/src/dispatcher.test.ts +0 -324
- package/src/dispatcher.ts +0 -218
- package/src/http-sender.ts +0 -187
- package/src/memory-outbox.test.ts +0 -86
- package/src/memory-outbox.ts +0 -155
- package/src/outbox.ts +0 -175
- package/src/partition.ts +0 -19
- package/src/retention.test.ts +0 -116
- package/src/retention.ts +0 -144
- package/src/sql-outbox.test.ts +0 -490
- package/src/sql-outbox.ts +0 -343
- package/src/sys-webhook-delivery.object.ts +0 -224
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/framework/framework/packages/plugins/plugin-webhooks/dist/chunk-HF7CCDPB.cjs","../src/sql-outbox.ts","../src/outbox.ts","../src/partition.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACA;ACFA,gCAA2B;ADI3B;AACA;AEkHO,IAAM,eAAA,EAAN,MAAA,QAA6B,MAAM;AAAA,EACtC,WAAA,CACI,OAAA,EACS,IAAA,EACX;AACE,IAAA,KAAA,CAAM,OAAO,CAAA;AAFJ,IAAA,IAAA,CAAA,KAAA,EAAA,IAAA;AAGT,IAAA,IAAA,CAAK,KAAA,EAAO,gBAAA;AAAA,EAChB;AACJ,CAAA;AFlHA;AACA;AGNO,SAAS,aAAA,CAAc,GAAA,EAAa,KAAA,EAAuB;AAC9D,EAAA,GAAA,CAAI,MAAA,GAAS,CAAA,EAAG,MAAM,IAAI,KAAA,CAAM,6BAA6B,CAAA;AAC7D,EAAA,IAAI,EAAA,EAAI,UAAA;AACR,EAAA,IAAA,CAAA,IAAS,EAAA,EAAI,CAAA,EAAG,EAAA,EAAI,GAAA,CAAI,MAAA,EAAQ,CAAA,EAAA,EAAK;AACjC,IAAA,EAAA,GAAK,GAAA,CAAI,UAAA,CAAW,CAAC,CAAA;AACrB,IAAA,EAAA,EAAI,IAAA,CAAK,IAAA,CAAK,CAAA,EAAG,QAAU,CAAA;AAAA,EAC/B;AACA,EAAA,OAAO,IAAA,CAAK,GAAA,CAAI,EAAA,EAAI,CAAC,EAAA,EAAI,KAAA;AAC7B;AHQ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AAA,CAAE,MAAA;AAAA,MACV,QAAA,EAAU,CAAA,CAAE,QAAA;AAAA,MACZ,SAAA,mBAAW,CAAA,CAAE,UAAA,UAAc,KAAA,GAAA;AAAA,MAC3B,SAAA,mBAAW,CAAA,CAAE,UAAA,UAAc,KAAA,GAAA;AAAA,MAC3B,WAAA,mBAAa,CAAA,CAAE,aAAA,UAAiB,KAAA,GAAA;AAAA,MAChC,eAAA,mBAAiB,CAAA,CAAE,iBAAA,UAAqB,KAAA,GAAA;AAAA,MACxC,YAAA,mBAAc,CAAA,CAAE,aAAA,UAAiB,KAAA,GAAA;AAAA,MACjC,YAAA,mBAAc,CAAA,CAAE,aAAA,UAAiB,KAAA,GAAA;AAAA,MACjC,KAAA,mBAAO,CAAA,CAAE,KAAA,UAAS,KAAA,GAAA;AAAA,MAClB,SAAA,EAAW,CAAA,CAAE,UAAA;AAAA,MACb,SAAA,EAAW,CAAA,CAAE;AAAA,IACjB,CAAA;AAAA,EACJ;AACJ,CAAA;AD7FA;AACA;AACE;AACA;AACA;AACF,4HAAC","file":"/home/runner/work/framework/framework/packages/plugins/plugin-webhooks/dist/chunk-HF7CCDPB.cjs","sourcesContent":[null,"// 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"]}
|
package/dist/chunk-KNGLLSSP.js
DELETED
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SYS_WEBHOOK_DELIVERY
|
|
3
|
-
} from "./chunk-7HS5DLU2.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-KNGLLSSP.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,IAAI,GAAG,IAAI,IAAI,QAAQ,KAAK;AACjC,SAAK,IAAI,WAAW,CAAC;AACrB,QAAI,KAAK,KAAK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