@vite-hub/webhooks 0.3.1 → 0.4.1

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/README.md CHANGED
@@ -21,6 +21,7 @@ export default defineWebhook({
21
21
  | `secret` | The name of the server variable that holds the signing secret. |
22
22
  | `signature` | `"github"` (default) sends `x-hub-signature-256: sha256=<hex>`. `"stripe"` sends `stripe-signature: t=<time>,v1=<hex>`. `verifyWebhook()` from `@vite-hub/env` checks both. |
23
23
  | `debounce` | Optional. Waits this long after the last send, then delivers once. A duration such as `"30 minutes"` or `"10s"`, at most 24 hours, the longest delay of Cloudflare Queues. |
24
+ | `events` | Optional. Events that ViteHub sends by itself: `"invocation.failed"`, `"workflow.failed"`, and `"schedule.failed"`. See [Failure alerts](#failure-alerts). |
24
25
 
25
26
  The file name is the webhook name: lowercase letters, digits, and dashes. The app needs `queue` and `database` in `vitehub()`, with a SQLite Default Database such as libSQL or D1. Without them, the build fails with `WEBHOOKS_QUEUE_OFF` or `WEBHOOKS_DATABASE_OFF`. Run `vitehub database generate` and `vitehub database migrate` to add the table.
26
27
 
@@ -52,6 +53,23 @@ The receiver gets a `POST` with the JSON body and these headers:
52
53
  | `x-vitehub-delivery` | The delivery id. It stays the same for every retry, so the receiver can drop a duplicate. |
53
54
  | `x-vitehub-events` | How many sends the debounce collapsed into this delivery |
54
55
 
56
+ ## Failure alerts
57
+
58
+ A webhook that lists `events` gets each failed run without a `sendWebhook()` call:
59
+
60
+ ```ts [server/webhooks/alerts.ts]
61
+ import { defineWebhook } from "@vite-hub/webhooks"
62
+
63
+ export default defineWebhook({
64
+ url: "ALERTS_WEBHOOK_URL",
65
+ secret: "ALERTS_WEBHOOK_SECRET",
66
+ events: ["invocation.failed", "workflow.failed", "schedule.failed"],
67
+ debounce: "10 minutes",
68
+ })
69
+ ```
70
+
71
+ Agent, Workflow, and Schedule send the event when a run fails with no retry left. The body has the `event`, the Agent, Workflow, or Schedule name, the run or Invocation id, `error: { message, code? }`, `failedAt`, and `text`, one line that a Slack incoming webhook shows as the message. With `debounce`, failures of the same Agent, Workflow, or Schedule collapse into one delivery. The run must execute in a process that loads the app's Webhooks. Standalone cron entries, including Vercel and Netlify cron functions, and Vercel Workflow DevKit (`native`) runs do not send these events.
72
+
55
73
  ## How a delivery works
56
74
 
57
75
  1. `sendWebhook()` stores the delivery in the `vitehub_webhook_deliveries` table of the Default Database, then sends a wake job to the internal `vitehub-webhooks` Queue with the debounce as its delay.
package/dist/database.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as webhooksErrors } from "./errors-DtL3aUWW.js";
1
+ import { t as webhooksErrors } from "./errors-1y5fWGlX.js";
2
2
  import { t as webhooksTableNames } from "./table-names-DVvicXhh.js";
3
3
  import { and, asc, desc, eq, lt, or, sql } from "drizzle-orm";
4
4
  import { index, integer, sqliteTable, text, uniqueIndex } from "drizzle-orm/sqlite-core";
@@ -9,11 +9,11 @@ const webhooksErrors = /*#__PURE__*/ defineErrors({
9
9
  },
10
10
  WEBHOOKS_DEBOUNCE_TOO_LONG: {
11
11
  why: ({ debounce }) => `The debounce ${debounce} is longer than 24 hours. Cloudflare Queues delays a message at most 24 hours, and a webhook must work on every host.`,
12
- fix: "Set `debounce` to 24 hours or less, such as `\"30 minutes\"`."
12
+ fix: "Set `debounce` to 24 hours or less, such as `\"30m\"` or `\"1d\"`."
13
13
  },
14
14
  WEBHOOKS_DEFINITION_INVALID: {
15
15
  why: ({ message }) => message,
16
- fix: "Default-export `defineWebhook({ url: \"T3_WEBHOOK_URL\", secret: \"T3_WEBHOOK_SECRET\" })` from each file of `server/webhooks/`. `url` and `secret` are names of server variables, `signature` is `\"github\"` or `\"stripe\"`, and `debounce` is a duration such as `\"30 minutes\"`."
16
+ fix: "Default-export `defineWebhook({ url: \"T3_WEBHOOK_URL\", secret: \"T3_WEBHOOK_SECRET\" })` from each file of `server/webhooks/`. `url` and `secret` are names of server variables, `signature` is `\"github\"` or `\"stripe\"`, `debounce` is a duration such as `\"30m\"`, and `events` lists `\"invocation.failed\"`, `\"workflow.failed\"`, or `\"schedule.failed\"`."
17
17
  },
18
18
  WEBHOOKS_FILE_INVALID: {
19
19
  why: ({ message }) => message,
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as WebhookDefinition, D as SendWebhookErrorCode, E as defineWebhook, O as WebhookDeliveryErrorCode, T as WebhookSignature, r as SendWebhookResult, w as WebhookOptions } from "./runtime-B6NDYh0C.js";
1
+ import { A as WebhookDeliveryErrorCode, D as WebhookSignature, E as WebhookOptions, O as defineWebhook, T as WebhookEvent, i as WebhookEventBody, k as SendWebhookErrorCode, r as SendWebhookResult, w as WebhookDefinition } from "./runtime-mqwMGfyX.js";
2
2
  import { Result } from "@vite-hub/runtime";
3
3
  //#region src/index.d.ts
4
4
  /** The webhooks of `server/webhooks/`. The generated `.vitehub/webhooks.d.ts` adds one key for each file. */
@@ -32,4 +32,4 @@ export interface SendWebhookOptions {
32
32
  */
33
33
  export declare function sendWebhook<TName extends WebhookName>(name: TName, body: unknown, options: SendWebhookOptions): Promise<Result<SendWebhookResult, SendWebhookErrorCode>>;
34
34
  //#endregion
35
- export { type SendWebhookErrorCode, type SendWebhookResult, type WebhookDefinition, type WebhookDeliveryErrorCode, type WebhookOptions, type WebhookSignature, defineWebhook };
35
+ export { type SendWebhookErrorCode, type SendWebhookResult, type WebhookDefinition, type WebhookDeliveryErrorCode, type WebhookEvent, type WebhookEventBody, type WebhookOptions, type WebhookSignature, defineWebhook };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as defineWebhook, f as sendDynamicWebhook } from "./runtime-BHBBgm1D.js";
1
+ import { _ as defineWebhook, f as sendDynamicWebhook } from "./runtime-DVBMk9vu.js";
2
2
  //#region src/index.ts
3
3
  /**
4
4
  * Sends `body` as JSON to the webhook `name` of `server/webhooks/<name>.ts`, signed with its secret, and returns
@@ -39,6 +39,11 @@ interface OperationContext {
39
39
  surface: "console" | "cli" | "mcp" | "agent";
40
40
  /** Set by the host from generated build identity, never from request input or runtime NODE_ENV. */
41
41
  development?: boolean;
42
+ /**
43
+ * The project root of a development server, for operations that read build files, such as `bundle.report`. Hosts set
44
+ * it only with `development`, so a deployed server never reads project files through it.
45
+ */
46
+ projectRoot?: string;
42
47
  env?: Record<string, unknown>;
43
48
  waitUntil?: (task: Promise<unknown>) => void;
44
49
  request?: Request;
@@ -1,4 +1,4 @@
1
- import { t as AnyOperation } from "./operations-D4A1Fcgf.js";
1
+ import { t as AnyOperation } from "./operations-7ycAhDCw.js";
2
2
  //#region src/operations.d.ts
3
3
  /**
4
4
  * The `webhooks.*` operations. The Console, `vitehub webhooks`, and MCP run them on the app's operation RPC, `POST
@@ -1,4 +1,4 @@
1
- import { t as webhooksErrors } from "./errors-DtL3aUWW.js";
1
+ import { t as webhooksErrors } from "./errors-1y5fWGlX.js";
2
2
  import { t as isRecordOrFunction } from "./object-BJb1W_q5.js";
3
3
  import * as v from "valibot";
4
4
  //#region ../../node_modules/.pnpm/nostics@1.4.0/node_modules/nostics/dist/index.mjs
@@ -275,7 +275,7 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
275
275
  },
276
276
  INTERNAL_R0004: {
277
277
  ...dynamicError,
278
- fix: "Set a larger `maxResponseBytes` on the HTTP request, such as the `fetch()` Source options, or ask the server for a smaller response."
278
+ fix: "Set a larger `maxResponseBytes` on the HTTP request, such as the `url()` Source options, or ask the server for a smaller response."
279
279
  },
280
280
  INTERNAL_R0005: {
281
281
  ...dynamicError,
@@ -321,6 +321,10 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
321
321
  why: ({ variable }) => `[vitehub] ${variable} must be the 43-character private key that \`vitehub secret console-key\` prints, and its name 1 to 64 of A-Z, 0-9, and _.`,
322
322
  fix: "Set the variable that the message names to the private key that `vitehub secret console-key` prints, and name it `VITEHUB_CONSOLE_PRIVATE_KEY_<NAME>` with A-Z, 0-9, and _ in `<NAME>`."
323
323
  },
324
+ INTERNAL_DEV_SERVER_NOT_FOUND: {
325
+ why: ({ command }) => `[vitehub] No dev server of this project is running, and --url is not set, so \`vitehub ${command}\` has no app to call.`,
326
+ fix: "Start the dev server of this project, such as with `pnpm dev`, or pass --url with the app URL, such as --url http://localhost:3000."
327
+ },
324
328
  INTERNAL_FORGE_NOT_INSTALLED: {
325
329
  why: ({ feature }) => `${feature} needs @vite-hub/forge, and the app did not install it.`,
326
330
  fix: "Install Forge in your app with `pnpm add @vite-hub/forge`, then build again."
@@ -1,6 +1,8 @@
1
- import { t as webhooksErrors } from "./errors-DtL3aUWW.js";
1
+ import { t as webhooksErrors } from "./errors-1y5fWGlX.js";
2
2
  import { signWebhook } from "@vite-hub/env";
3
+ import { onRunFailed, runFailedEventNames } from "@vite-hub/runtime/internal/run-failed";
3
4
  import { getViteHubTestMode } from "@vite-hub/runtime/internal/test-mode";
5
+ import { parseDuration } from "@vite-hub/runtime";
4
6
  //#region ../internal/src/runtime/cloudflare-env-lookup.ts
5
7
  /** The key of the AsyncLocalStorage store on `globalThis`. Every bundled copy of this module shares the store. */
6
8
  const activeEnvStorageKey = Symbol.for("vitehub.cloudflare.env-storage");
@@ -18,37 +20,17 @@ function getActiveCloudflareEnv() {
18
20
  //#endregion
19
21
  //#region src/define.ts
20
22
  const definitionBrand = Symbol.for("vitehub.webhooks.definition");
21
- const durationUnits = {
22
- ms: 1,
23
- millisecond: 1,
24
- milliseconds: 1,
25
- s: 1e3,
26
- sec: 1e3,
27
- second: 1e3,
28
- seconds: 1e3,
29
- m: 6e4,
30
- min: 6e4,
31
- mins: 6e4,
32
- minute: 6e4,
33
- minutes: 6e4,
34
- h: 36e5,
35
- hour: 36e5,
36
- hours: 36e5
37
- };
38
- /** Milliseconds of a duration such as `"30 minutes"`, `"10s"`, or a number of milliseconds. */
39
- function parseDuration(value) {
40
- if (typeof value === "number") return Number.isFinite(value) && value >= 0 ? value : void 0;
41
- const match = /^(\d+(?:\.\d+)?)\s*([a-z]+)$/i.exec(value.trim());
42
- const unit = match && durationUnits[match[2].toLowerCase()];
43
- return unit ? Number(match[1]) * unit : void 0;
44
- }
45
23
  const variableName = /^[A-Z_][A-Z0-9_]*$/i;
24
+ function isWebhookEvent(value) {
25
+ return runFailedEventNames.some((name) => name === value);
26
+ }
46
27
  function invalid(message) {
47
28
  return webhooksErrors.WEBHOOKS_DEFINITION_INVALID({ message: `[vitehub] ${message}` });
48
29
  }
49
30
  /**
50
31
  * Defines a webhook: where ViteHub sends events, how it signs them, and how long it waits to collapse them. Default-export
51
- * it from `server/webhooks/<name>.ts`, then call `sendWebhook("<name>", body)` from server code.
32
+ * it from `server/webhooks/<name>.ts`, then call `sendWebhook("<name>", body)` from server code, or list `events` that
33
+ * ViteHub sends by itself.
52
34
  *
53
35
  * ```ts [server/webhooks/t3.ts]
54
36
  * import { defineWebhook } from "@vite-hub/webhooks"
@@ -56,7 +38,7 @@ function invalid(message) {
56
38
  * export default defineWebhook({
57
39
  * url: "T3_WEBHOOK_URL",
58
40
  * secret: "T3_WEBHOOK_SECRET",
59
- * debounce: "30 minutes",
41
+ * debounce: "30m",
60
42
  * })
61
43
  * ```
62
44
  */
@@ -67,14 +49,22 @@ function defineWebhook(options) {
67
49
  }
68
50
  const signature = options.signature ?? "github";
69
51
  if (signature !== "github" && signature !== "stripe") throw invalid(`\`signature\` must be "github" or "stripe", not ${JSON.stringify(signature)}.`);
70
- const debounceMs = options.debounce === void 0 ? 0 : parseDuration(options.debounce);
71
- if (debounceMs === void 0) throw invalid(`\`debounce\` must be a duration such as "30 minutes" or "10s", not ${JSON.stringify(options.debounce)}.`);
52
+ const debounceMs = options.debounce === void 0 ? 0 : parseDuration(options.debounce, "debounce");
72
53
  if (debounceMs > 864e5) throw webhooksErrors.WEBHOOKS_DEBOUNCE_TOO_LONG({ debounce: JSON.stringify(options.debounce) });
54
+ const listed = options.events ?? [];
55
+ if (!Array.isArray(listed)) throw invalid(`\`events\` must be a list such as ["workflow.failed"], not ${JSON.stringify(listed)}.`);
56
+ const items = listed;
57
+ const events = /* @__PURE__ */ new Set();
58
+ for (const event of items) {
59
+ if (!isWebhookEvent(event)) throw invalid(`\`events\` lists ${JSON.stringify(event)}. Use ${runFailedEventNames.map((name) => JSON.stringify(name)).join(", ")}.`);
60
+ events.add(event);
61
+ }
73
62
  return Object.defineProperty({
74
63
  url: options.url,
75
64
  secret: options.secret,
76
65
  signature,
77
- debounceMs
66
+ debounceMs,
67
+ events: [...events]
78
68
  }, definitionBrand, { value: true });
79
69
  }
80
70
  function isWebhookDefinition(value) {
@@ -110,8 +100,41 @@ function installWebhooks(options) {
110
100
  wake: options.wake
111
101
  };
112
102
  Reflect.set(globalThis, installedKey, installed);
103
+ if (!Reflect.get(globalThis, listenerKey)) Reflect.set(globalThis, listenerKey, onRunFailed(sendRunFailed));
113
104
  return installed;
114
105
  }
106
+ const listenerKey = Symbol.for("vitehub.webhooks.runFailedListener");
107
+ /** The Agent, Workflow, or Schedule that failed: the key that collapses repeated failures of it while a debounce waits. */
108
+ function failedSubject(event) {
109
+ if (event.event === "invocation.failed") return event.agent ?? event.invocationId;
110
+ return event.event === "workflow.failed" ? event.workflow : event.schedule;
111
+ }
112
+ function toWebhookEventBody(event) {
113
+ const subject = event.event === "invocation.failed" ? `The Agent Invocation ${event.invocationId}${event.agent ? ` of ${JSON.stringify(event.agent)}` : ""}` : event.event === "workflow.failed" ? `The Workflow run ${event.runId} of ${JSON.stringify(event.workflow)}` : `The Schedule run ${event.runId} of ${JSON.stringify(event.schedule)}`;
114
+ return {
115
+ ...event,
116
+ text: `${subject} failed: ${event.error.message}`
117
+ };
118
+ }
119
+ /**
120
+ * Sends a failed run to each webhook that lists its event. With a debounce, failures of the same Agent, Workflow, or
121
+ * Schedule collapse into one delivery that holds the last failure, and `x-vitehub-events` counts them.
122
+ */
123
+ async function sendRunFailed(event) {
124
+ const installed = installedWebhooks();
125
+ if (!installed) return;
126
+ const body = toWebhookEventBody(event);
127
+ for (const [name, definition] of installed.webhooks) {
128
+ if (!definition.events.includes(event.event)) continue;
129
+ const key = definition.debounceMs > 0 ? `${event.event}:${failedSubject(event)}` : null;
130
+ const [error] = await enqueue(name, body, {
131
+ event: event.event,
132
+ key,
133
+ delayMs: definition.debounceMs
134
+ });
135
+ if (error) console.error(`[vitehub] The webhook ${name} did not store the ${event.event} event.`, error);
136
+ }
137
+ }
115
138
  function requireInstalled() {
116
139
  const installed = installedWebhooks();
117
140
  if (!installed) throw webhooksErrors.WEBHOOKS_NOT_INSTALLED();
@@ -171,7 +194,7 @@ async function wake(installed, delivery, delayMs) {
171
194
  const [error] = await installed.wake({
172
195
  id: delivery.id,
173
196
  revision: delivery.revision
174
- }, { delaySeconds: Math.ceil(Math.max(0, delayMs) / 1e3) });
197
+ }, { delay: `${Math.ceil(Math.max(0, delayMs) / 1e3)}s` });
175
198
  return error === void 0 ? void 0 : webhooksErrors.WEBHOOKS_WAKE_FAILED({
176
199
  webhook: delivery.webhook,
177
200
  cause: error
@@ -374,6 +397,7 @@ function listWebhooks() {
374
397
  secret: definition.secret,
375
398
  signature: definition.signature,
376
399
  debounceMs: definition.debounceMs,
400
+ events: definition.events,
377
401
  urlSet: url !== void 0,
378
402
  secretSet: readString(env, definition.secret) !== void 0,
379
403
  host: url !== void 0 && URL.canParse(url) ? new URL(url).host || null : null
@@ -1,5 +1,6 @@
1
1
  import { a as WebhookDeliveryStore, r as WebhookDelivery, s as WebhooksDatabase, t as ListWebhookDeliveriesOptions } from "./database-COdjz9Vi.js";
2
- import { Result } from "@vite-hub/runtime";
2
+ import { RunFailedEvent, RunFailedEventName } from "@vite-hub/runtime/internal/run-failed";
3
+ import { Duration, Result } from "@vite-hub/runtime";
3
4
  //#region src/errors.d.ts
4
5
  /** The codes that `sendWebhook()` returns. Definition errors throw instead. */
5
6
  type SendWebhookErrorCode = "WEBHOOKS_BODY_INVALID" | "WEBHOOKS_DATABASE_MISSING" | "WEBHOOKS_SECRET_UNSET" | "WEBHOOKS_STORE_FAILED" | "WEBHOOKS_URL_INVALID" | "WEBHOOKS_URL_UNSET" | "WEBHOOKS_WAKE_FAILED";
@@ -9,6 +10,11 @@ type WebhookDeliveryErrorCode = "WEBHOOKS_DATABASE_MISSING" | "WEBHOOKS_DELIVERY
9
10
  //#region src/define.d.ts
10
11
  /** How a delivery is signed. Both use HMAC-SHA256 of the raw body with the secret. */
11
12
  type WebhookSignature = "github" | "stripe";
13
+ /**
14
+ * An event that ViteHub sends by itself, with no `sendWebhook()` call: an Agent Invocation, a Workflow run, or a Schedule
15
+ * run that ended in failure with no retry left.
16
+ */
17
+ type WebhookEvent = RunFailedEventName;
12
18
  /** What `defineWebhook()` accepts. */
13
19
  interface WebhookOptions {
14
20
  /**
@@ -24,11 +30,16 @@ interface WebhookOptions {
24
30
  */
25
31
  signature?: WebhookSignature;
26
32
  /**
27
- * Wait this long after the last send before one delivery, such as `"30 minutes"`. Each send in the window replaces the
28
- * body and restarts the wait. Sends with the same `key` collapse, and the key defaults to the webhook name. At most 24
29
- * hours. Without it, each send is delivered at once.
33
+ * Wait this long after the last send before one delivery, such as `"30m"`. Each send in the window replaces the body
34
+ * and restarts the wait. Sends with the same `key` collapse, and the key defaults to the webhook name. At most `"1d"`.
35
+ * Without it, each send is delivered at once.
36
+ */
37
+ debounce?: Duration;
38
+ /**
39
+ * Events that ViteHub sends to this webhook by itself: `"invocation.failed"`, `"workflow.failed"`, and
40
+ * `"schedule.failed"`. Each is sent once, when the run ends in failure with no retry left.
30
41
  */
31
- debounce?: string | number;
42
+ events?: readonly WebhookEvent[];
32
43
  }
33
44
  /** A webhook of `server/webhooks/<name>.ts`. */
34
45
  interface WebhookDefinition {
@@ -37,10 +48,13 @@ interface WebhookDefinition {
37
48
  readonly signature: WebhookSignature;
38
49
  /** The debounce in milliseconds. `0` delivers each send at once. */
39
50
  readonly debounceMs: number;
51
+ /** The events that ViteHub sends to this webhook by itself. */
52
+ readonly events: readonly WebhookEvent[];
40
53
  }
41
54
  /**
42
55
  * Defines a webhook: where ViteHub sends events, how it signs them, and how long it waits to collapse them. Default-export
43
- * it from `server/webhooks/<name>.ts`, then call `sendWebhook("<name>", body)` from server code.
56
+ * it from `server/webhooks/<name>.ts`, then call `sendWebhook("<name>", body)` from server code, or list `events` that
57
+ * ViteHub sends by itself.
44
58
  *
45
59
  * ```ts [server/webhooks/t3.ts]
46
60
  * import { defineWebhook } from "@vite-hub/webhooks"
@@ -48,7 +62,7 @@ interface WebhookDefinition {
48
62
  * export default defineWebhook({
49
63
  * url: "T3_WEBHOOK_URL",
50
64
  * secret: "T3_WEBHOOK_SECRET",
51
- * debounce: "30 minutes",
65
+ * debounce: "30m",
52
66
  * })
53
67
  * ```
54
68
  */
@@ -66,7 +80,7 @@ interface WebhookWake {
66
80
  }
67
81
  /** Sends a wake to the `vitehub-webhooks` Queue. `dynamicQueue.send()` of `@vite-hub/queue` fits. */
68
82
  type WebhookWakeSender = (wake: WebhookWake, options: {
69
- delaySeconds: number;
83
+ delay: Duration;
70
84
  }) => Promise<readonly [unknown, unknown]>;
71
85
  /** What the generated server code of a ViteHub app passes. */
72
86
  interface InstallWebhooksOptions {
@@ -91,6 +105,8 @@ interface WebhookInfo {
91
105
  secret: string;
92
106
  signature: WebhookSignature;
93
107
  debounceMs: number;
108
+ /** The events that ViteHub sends to this webhook by itself. */
109
+ events: readonly WebhookEvent[];
94
110
  /** Whether this server has a value for `url` and for `secret`. */
95
111
  urlSet: boolean;
96
112
  secretSet: boolean;
@@ -109,6 +125,13 @@ declare function installedWebhooks(): InstalledWebhooks | undefined;
109
125
  * server code of a ViteHub app calls it when the server starts. A test calls it with its own store and wake sender.
110
126
  */
111
127
  declare function installWebhooks(options: InstallWebhooksOptions): InstalledWebhooks;
128
+ /**
129
+ * The body of an event that ViteHub sends by itself, such as `workflow.failed`. `text` is one line that a person reads,
130
+ * so a Slack incoming webhook shows it as the message.
131
+ */
132
+ type WebhookEventBody = RunFailedEvent & {
133
+ text: string;
134
+ };
112
135
  /**
113
136
  * The Database that keeps the deliveries: the one that `useDatabase()` of `@vite-hub/database/runtime/registry` returns
114
137
  * without a name. That is the Database that `vitehub database generate` adds the table to: `default`, else the only one.
@@ -158,4 +181,4 @@ declare function cancelWebhookDelivery(id: string): Promise<Result<WebhookDelive
158
181
  */
159
182
  declare function redeliverWebhookDelivery(id: string): Promise<Result<SendWebhookResult, WebhookDeliveryErrorCode>>;
160
183
  //#endregion
161
- export { WebhookDefinition as C, SendWebhookErrorCode as D, defineWebhook as E, WebhookDeliveryErrorCode as O, webhookTimeoutMs as S, WebhookSignature as T, selectDefaultDatabase as _, WebhookWake as a, webhookMaxAttempts as b, deliverWebhookWake as c, installWebhooks as d, installedWebhooks as f, redeliverWebhookDelivery as g, listWebhooks as h, WebhookInfo as i, flushWebhookDelivery as l, listWebhookDeliveries as m, InstalledWebhooks as n, WebhookWakeSender as o, listPendingWebhookDeliveries as p, SendWebhookResult as r, cancelWebhookDelivery as s, InstallWebhooksOptions as t, getWebhookDelivery as u, sendDynamicWebhook as v, WebhookOptions as w, webhookTestEvent as x, testWebhook as y };
184
+ export { WebhookDeliveryErrorCode as A, webhookTimeoutMs as C, WebhookSignature as D, WebhookOptions as E, defineWebhook as O, webhookTestEvent as S, WebhookEvent as T, redeliverWebhookDelivery as _, WebhookInfo as a, testWebhook as b, cancelWebhookDelivery as c, getWebhookDelivery as d, installWebhooks as f, listWebhooks as g, listWebhookDeliveries as h, WebhookEventBody as i, SendWebhookErrorCode as k, deliverWebhookWake as l, listPendingWebhookDeliveries as m, InstalledWebhooks as n, WebhookWake as o, installedWebhooks as p, SendWebhookResult as r, WebhookWakeSender as s, InstallWebhooksOptions as t, flushWebhookDelivery as u, selectDefaultDatabase as v, WebhookDefinition as w, webhookMaxAttempts as x, sendDynamicWebhook as y };
package/dist/runtime.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { S as webhookTimeoutMs, _ as selectDefaultDatabase, a as WebhookWake, b as webhookMaxAttempts, c as deliverWebhookWake, d as installWebhooks, f as installedWebhooks, g as redeliverWebhookDelivery, h as listWebhooks, i as WebhookInfo, l as flushWebhookDelivery, m as listWebhookDeliveries, n as InstalledWebhooks, o as WebhookWakeSender, p as listPendingWebhookDeliveries, r as SendWebhookResult, s as cancelWebhookDelivery, t as InstallWebhooksOptions, u as getWebhookDelivery, v as sendDynamicWebhook, x as webhookTestEvent, y as testWebhook } from "./runtime-B6NDYh0C.js";
1
+ import { C as webhookTimeoutMs, S as webhookTestEvent, _ as redeliverWebhookDelivery, a as WebhookInfo, b as testWebhook, c as cancelWebhookDelivery, d as getWebhookDelivery, f as installWebhooks, g as listWebhooks, h as listWebhookDeliveries, i as WebhookEventBody, l as deliverWebhookWake, m as listPendingWebhookDeliveries, n as InstalledWebhooks, o as WebhookWake, p as installedWebhooks, r as SendWebhookResult, s as WebhookWakeSender, t as InstallWebhooksOptions, u as flushWebhookDelivery, v as selectDefaultDatabase, x as webhookMaxAttempts, y as sendDynamicWebhook } from "./runtime-mqwMGfyX.js";
2
2
  import { t as webhooksQueueName } from "./queue-name-CGeTSHId.js";
3
- export { InstallWebhooksOptions, InstalledWebhooks, SendWebhookResult, WebhookInfo, WebhookWake, WebhookWakeSender, cancelWebhookDelivery, deliverWebhookWake, flushWebhookDelivery, getWebhookDelivery, installWebhooks, installedWebhooks, listPendingWebhookDeliveries, listWebhookDeliveries, listWebhooks, redeliverWebhookDelivery, selectDefaultDatabase, sendDynamicWebhook, testWebhook, webhookMaxAttempts, webhookTestEvent, webhookTimeoutMs, webhooksQueueName };
3
+ export { InstallWebhooksOptions, InstalledWebhooks, SendWebhookResult, WebhookEventBody, WebhookInfo, WebhookWake, WebhookWakeSender, cancelWebhookDelivery, deliverWebhookWake, flushWebhookDelivery, getWebhookDelivery, installWebhooks, installedWebhooks, listPendingWebhookDeliveries, listWebhookDeliveries, listWebhooks, redeliverWebhookDelivery, selectDefaultDatabase, sendDynamicWebhook, testWebhook, webhookMaxAttempts, webhookTestEvent, webhookTimeoutMs, webhooksQueueName };
package/dist/runtime.js CHANGED
@@ -1,3 +1,3 @@
1
- import { a as installWebhooks, c as listWebhookDeliveries, d as selectDefaultDatabase, f as sendDynamicWebhook, g as webhookTimeoutMs, h as webhookTestEvent, i as getWebhookDelivery, l as listWebhooks, m as webhookMaxAttempts, n as deliverWebhookWake, o as installedWebhooks, p as testWebhook, r as flushWebhookDelivery, s as listPendingWebhookDeliveries, t as cancelWebhookDelivery, u as redeliverWebhookDelivery } from "./runtime-BHBBgm1D.js";
1
+ import { a as installWebhooks, c as listWebhookDeliveries, d as selectDefaultDatabase, f as sendDynamicWebhook, g as webhookTimeoutMs, h as webhookTestEvent, i as getWebhookDelivery, l as listWebhooks, m as webhookMaxAttempts, n as deliverWebhookWake, o as installedWebhooks, p as testWebhook, r as flushWebhookDelivery, s as listPendingWebhookDeliveries, t as cancelWebhookDelivery, u as redeliverWebhookDelivery } from "./runtime-DVBMk9vu.js";
2
2
  import { t as webhooksQueueName } from "./queue-name-RURp9SQf.js";
3
3
  export { cancelWebhookDelivery, deliverWebhookWake, flushWebhookDelivery, getWebhookDelivery, installWebhooks, installedWebhooks, listPendingWebhookDeliveries, listWebhookDeliveries, listWebhooks, redeliverWebhookDelivery, selectDefaultDatabase, sendDynamicWebhook, testWebhook, webhookMaxAttempts, webhookTestEvent, webhookTimeoutMs, webhooksQueueName };
package/dist/vite.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as webhooksQueueName } from "./queue-name-CGeTSHId.js";
2
- import { n as OperationContributions } from "./operations-D4A1Fcgf.js";
2
+ import { n as OperationContributions } from "./operations-7ycAhDCw.js";
3
3
  import { Plugin } from "vite";
4
4
  //#region ../internal/src/console.d.ts
5
5
  /** Lists discovered Definitions in a sidebar and shows the selected Definition's fields. */
package/dist/vite.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as webhooksErrors } from "./errors-DtL3aUWW.js";
1
+ import { t as webhooksErrors } from "./errors-1y5fWGlX.js";
2
2
  import { t as webhooksQueueName } from "./queue-name-RURp9SQf.js";
3
3
  import { t as webhooksTableNames } from "./table-names-DVvicXhh.js";
4
4
  import { t as isRecordOrFunction } from "./object-BJb1W_q5.js";
@@ -208,7 +208,7 @@ function renderWebhooksQueue(imports) {
208
208
  "import \"./registry.mjs\"",
209
209
  "",
210
210
  "// A slow receiver must not hold back the deliveries of other webhooks.",
211
- "export default defineQueue(job => deliverWebhookWake(job.payload), { concurrency: 4 })",
211
+ "export default defineQueue({ handler: ({ payload }) => deliverWebhookWake(payload), concurrency: 4 })",
212
212
  ""
213
213
  ].join("\n");
214
214
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vite-hub/webhooks",
3
- "version": "0.3.1",
3
+ "version": "0.4.1",
4
4
  "description": "Send ViteHub events to an outside URL: signed, retried, and debounced on every host.",
5
5
  "keywords": [
6
6
  "debounce",
@@ -55,8 +55,8 @@
55
55
  },
56
56
  "dependencies": {
57
57
  "@standard-schema/spec": "^1.1.0",
58
- "@vite-hub/env": "0.3.1",
59
- "@vite-hub/runtime": "0.3.1",
58
+ "@vite-hub/env": "0.4.1",
59
+ "@vite-hub/runtime": "0.4.1",
60
60
  "valibot": "^1.5.0"
61
61
  },
62
62
  "devDependencies": {
@@ -82,7 +82,7 @@
82
82
  }
83
83
  },
84
84
  "engines": {
85
- "node": ">=22.18.0"
85
+ "node": ">=24.15.0"
86
86
  },
87
87
  "scripts": {
88
88
  "build": "vp pack",