@vite-hub/webhooks 0.8.0 → 0.9.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/dist/database.js +2 -5
- package/dist/index.js +2 -2
- package/dist/{members-BlmSjaxd.js → members-D2BRslXn.js} +1 -1
- package/dist/operations.js +1 -10
- package/dist/{runtime-DdEp3SVl.js → runtime-DOmUU6zG.js} +0 -1
- package/dist/runtime.js +1 -1
- package/dist/vite.js +0 -5
- package/package.json +4 -3
package/dist/database.js
CHANGED
|
@@ -42,9 +42,7 @@ const webhookDeliveries = sqliteTable("vitehub_webhook_deliveries", {
|
|
|
42
42
|
const webhookEndpoints = sqliteTable("vitehub_webhook_endpoints", {
|
|
43
43
|
id: text("id").primaryKey(),
|
|
44
44
|
owner: text("owner").notNull(),
|
|
45
|
-
/** The name of the owner that people read, such as `Ana Ruiz`. */
|
|
46
45
|
ownerName: text("owner_name"),
|
|
47
|
-
/** The verified email of the owner at connect time, not proof of their current identity. */
|
|
48
46
|
ownerEmail: text("owner_email"),
|
|
49
47
|
name: text("name").notNull(),
|
|
50
48
|
address: text("address").notNull().default(""),
|
|
@@ -53,7 +51,6 @@ const webhookEndpoints = sqliteTable("vitehub_webhook_endpoints", {
|
|
|
53
51
|
host: text("host"),
|
|
54
52
|
sealed: text("sealed"),
|
|
55
53
|
disabledAt: integer("disabled_at"),
|
|
56
|
-
/** Who disabled it, such as the name of an admin. */
|
|
57
54
|
disabledBy: text("disabled_by"),
|
|
58
55
|
createdAt: integer("created_at").notNull(),
|
|
59
56
|
updatedAt: integer("updated_at").notNull()
|
|
@@ -231,7 +228,7 @@ function createDrizzleWebhookStore(database) {
|
|
|
231
228
|
lastError: null,
|
|
232
229
|
sentAt: now,
|
|
233
230
|
updatedAt: now
|
|
234
|
-
}).where(and(eq(t.id, claim.id), eq(t.state, "sending"), eq(t.attempts, claim.attempts)));
|
|
231
|
+
}).where(and(eq(t.id, claim.id), eq(t.revision, claim.revision), eq(t.state, "sending"), eq(t.attempts, claim.attempts)));
|
|
235
232
|
}),
|
|
236
233
|
failed: (claim, result, now, dead) => guarded("mark a failed attempt", async () => {
|
|
237
234
|
const next = dead ? sql`'dead'` : sql`CASE WHEN ${t.key} IS NOT NULL AND EXISTS (SELECT 1 FROM vitehub_webhook_deliveries AS newer WHERE newer.webhook = ${t.webhook} AND newer.key = ${t.key} AND newer.state = 'pending') THEN 'cancelled' ELSE 'pending' END`;
|
|
@@ -240,7 +237,7 @@ function createDrizzleWebhookStore(database) {
|
|
|
240
237
|
lastStatus: result.status,
|
|
241
238
|
lastError: result.error,
|
|
242
239
|
updatedAt: now
|
|
243
|
-
}).where(and(eq(t.id, claim.id), eq(t.state, "sending"), eq(t.attempts, claim.attempts))).returning({ state: t.state });
|
|
240
|
+
}).where(and(eq(t.id, claim.id), eq(t.revision, claim.revision), eq(t.state, "sending"), eq(t.attempts, claim.attempts))).returning({ state: t.state });
|
|
244
241
|
if (row?.state === "cancelled") await db().update(t).set({ count: sql`${t.count} + ${claim.count}` }).where(and(eq(t.webhook, claim.webhook), eq(t.key, claim.key ?? ""), eq(t.state, "pending")));
|
|
245
242
|
return row?.state;
|
|
246
243
|
}),
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { F as unsealWebhooksText, M as sealWebhooksText, O as checkWebhookUrl, x as sendDynamicWebhook, y as requireMemberEndpoints } from "./runtime-
|
|
1
|
+
import { F as unsealWebhooksText, M as sealWebhooksText, O as checkWebhookUrl, x as sendDynamicWebhook, y as requireMemberEndpoints } from "./runtime-DOmUU6zG.js";
|
|
2
2
|
import { n as defineWebhook } from "./queue-name-0OM5djKH.js";
|
|
3
|
-
import { a as getMemberDeliveryState, c as listMemberEndpoints, d as removeMemberEndpoint, f as removeMemberEndpoints, i as getMemberDelivery, l as memberEndpointHosts, n as disableMemberEndpoint, o as getMemberEndpoint, p as sendToMemberEndpoint, r as enableMemberEndpoint, s as listMemberDeliveries, t as createMemberEndpoint } from "./members-
|
|
3
|
+
import { a as getMemberDeliveryState, c as listMemberEndpoints, d as removeMemberEndpoint, f as removeMemberEndpoints, i as getMemberDelivery, l as memberEndpointHosts, n as disableMemberEndpoint, o as getMemberEndpoint, p as sendToMemberEndpoint, r as enableMemberEndpoint, s as listMemberDeliveries, t as createMemberEndpoint } from "./members-D2BRslXn.js";
|
|
4
4
|
import { t as webhooksErrors } from "./errors-Dx-ml10b.js";
|
|
5
5
|
// src/pairing.ts
|
|
6
6
|
/** How long a pairing code works: 10 minutes. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as webhooksErrors } from "./errors-Dx-ml10b.js";
|
|
2
|
-
import { A as memberBodyLabel, M as sealWebhooksText, N as sealedMemberBodyPrefix, O as checkWebhookUrl, P as unsealEndpoint, _ as pruneWebhookDeliveries, c as inspectDelivery, i as deliverMemberDelivery, j as sealEndpoint, k as outsideHosts, n as createDeliveryId, y as requireMemberEndpoints } from "./runtime-
|
|
2
|
+
import { A as memberBodyLabel, M as sealWebhooksText, N as sealedMemberBodyPrefix, O as checkWebhookUrl, P as unsealEndpoint, _ as pruneWebhookDeliveries, c as inspectDelivery, i as deliverMemberDelivery, j as sealEndpoint, k as outsideHosts, n as createDeliveryId, y as requireMemberEndpoints } from "./runtime-DOmUU6zG.js";
|
|
3
3
|
// \0rolldown/runtime.js
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __exportAll = (all, no_symbols) => {
|
package/dist/operations.js
CHANGED
|
@@ -511,7 +511,7 @@ function operationInputJsonSchema(operation) {
|
|
|
511
511
|
}
|
|
512
512
|
// src/operations.ts
|
|
513
513
|
const runtime = () => import("./runtime.js");
|
|
514
|
-
const members = () => import("./members-
|
|
514
|
+
const members = () => import("./members-D2BRslXn.js").then((n) => n.u);
|
|
515
515
|
const statuses = {
|
|
516
516
|
WEBHOOKS_BODY_INVALID: 400,
|
|
517
517
|
WEBHOOKS_DATABASE_MISSING: 409,
|
|
@@ -545,10 +545,6 @@ async function unwrap(run) {
|
|
|
545
545
|
if (result[0]) throw failure(result[0]);
|
|
546
546
|
return result[1];
|
|
547
547
|
}
|
|
548
|
-
/**
|
|
549
|
-
* Access to the Webhooks section of the Console decides. Most operations never read the signed-in user. Those with
|
|
550
|
-
* `user: true` do: a member delivery goes out again only for the member who owns its endpoint.
|
|
551
|
-
*/
|
|
552
548
|
function defineWebhooksOperation(definition, options = {}) {
|
|
553
549
|
return defineOperation({
|
|
554
550
|
...definition,
|
|
@@ -560,10 +556,6 @@ function defineWebhooksOperation(definition, options = {}) {
|
|
|
560
556
|
...options.user ? {} : { user: false }
|
|
561
557
|
});
|
|
562
558
|
}
|
|
563
|
-
/**
|
|
564
|
-
* The caller of a member action. A call that the ViteHub Console signs names a Console account, which is not an app
|
|
565
|
-
* user, so only its email can match the owner. Any other call names an app user by id.
|
|
566
|
-
*/
|
|
567
559
|
async function memberCaller(context) {
|
|
568
560
|
const { request, user } = context;
|
|
569
561
|
if (!user || context.access.via === "cli" || context.surface === "cli") return void 0;
|
|
@@ -584,7 +576,6 @@ function endpointChange(endpoint) {
|
|
|
584
576
|
disabledBy: endpoint.disabledBy
|
|
585
577
|
};
|
|
586
578
|
}
|
|
587
|
-
/** The name that the Console shows for the person who disabled an endpoint. */
|
|
588
579
|
function personLabel(context) {
|
|
589
580
|
const { user } = context;
|
|
590
581
|
if (!user) return context.surface === "cli" ? "the CLI" : "an admin";
|
|
@@ -791,7 +791,6 @@ function inspectDelivery(delivery) {
|
|
|
791
791
|
body: null
|
|
792
792
|
};
|
|
793
793
|
}
|
|
794
|
-
/** The member endpoint of a member delivery, when `caller` owns it. Throws the error that the action returns. */
|
|
795
794
|
async function ownedMemberEndpoint(installed, delivery, options) {
|
|
796
795
|
const id = delivery.webhook.slice(1);
|
|
797
796
|
const endpoint = await installed.endpoints?.find(id);
|
package/dist/runtime.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { t as webhooksQueueName } from "./queue-name-0OM5djKH.js";
|
|
2
|
-
import { C as wake, D as webhookTimeoutMs, E as webhookTestEvent, S as testWebhook, T as webhookPruneBatch, _ as pruneWebhookDeliveries, a as deliverWebhookWake, b as selectDefaultDatabase, c as inspectDelivery, d as listPendingWebhookDeliveries, f as listWebhookDeliveries, g as postDelivery, h as ownsMemberEndpoint, i as deliverMemberDelivery, l as installWebhooks, m as memberWebhookPrefix, n as createDeliveryId, o as flushWebhookDelivery, p as listWebhooks, r as deliverMemberClaim, s as getWebhookDelivery, t as cancelWebhookDelivery, u as installedWebhooks, v as redeliverWebhookDelivery, w as webhookMaxAttempts, x as sendDynamicWebhook, y as requireMemberEndpoints } from "./runtime-
|
|
2
|
+
import { C as wake, D as webhookTimeoutMs, E as webhookTestEvent, S as testWebhook, T as webhookPruneBatch, _ as pruneWebhookDeliveries, a as deliverWebhookWake, b as selectDefaultDatabase, c as inspectDelivery, d as listPendingWebhookDeliveries, f as listWebhookDeliveries, g as postDelivery, h as ownsMemberEndpoint, i as deliverMemberDelivery, l as installWebhooks, m as memberWebhookPrefix, n as createDeliveryId, o as flushWebhookDelivery, p as listWebhooks, r as deliverMemberClaim, s as getWebhookDelivery, t as cancelWebhookDelivery, u as installedWebhooks, v as redeliverWebhookDelivery, w as webhookMaxAttempts, x as sendDynamicWebhook, y as requireMemberEndpoints } from "./runtime-DOmUU6zG.js";
|
|
3
3
|
export { cancelWebhookDelivery, createDeliveryId, deliverMemberClaim, deliverMemberDelivery, deliverWebhookWake, flushWebhookDelivery, getWebhookDelivery, inspectDelivery, installWebhooks, installedWebhooks, listPendingWebhookDeliveries, listWebhookDeliveries, listWebhooks, memberWebhookPrefix, ownsMemberEndpoint, postDelivery, pruneWebhookDeliveries, redeliverWebhookDelivery, requireMemberEndpoints, selectDefaultDatabase, sendDynamicWebhook, testWebhook, wake, webhookMaxAttempts, webhookPruneBatch, webhookTestEvent, webhookTimeoutMs, webhooksQueueName };
|
package/dist/vite.js
CHANGED
|
@@ -184,16 +184,11 @@ function objectProperties(object) {
|
|
|
184
184
|
value: unwrapExpression(node.value)
|
|
185
185
|
});
|
|
186
186
|
}
|
|
187
|
-
/** The value of a template literal without substitutions. */
|
|
188
187
|
function staticTemplate(node) {
|
|
189
188
|
if (node.expressions.length) return dynamic;
|
|
190
189
|
return node.quasis[0]?.value.cooked ?? dynamic;
|
|
191
190
|
}
|
|
192
191
|
const escapePattern = /\\(u\{[^}]*\}?|u[\s\S]{0,4}|x[\s\S]{0,2}|0\d|[\s\S])/g;
|
|
193
|
-
/**
|
|
194
|
-
* True when a string literal has an escape that strict mode code rejects. The parser recovers from some bad escapes
|
|
195
|
-
* and accepts legacy octal escapes, so the scanner checks them again.
|
|
196
|
-
*/
|
|
197
192
|
function hasInvalidEscape(raw) {
|
|
198
193
|
for (const [, escape = ""] of raw.matchAll(escapePattern)) if (escape.startsWith("u{")) {
|
|
199
194
|
const code = escape.slice(2, -1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vite-hub/webhooks",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Send ViteHub events to an outside URL: signed, retried, and debounced on every host.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"debounce",
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@standard-schema/spec": "^1.1.0",
|
|
58
58
|
"@valibot/to-json-schema": "^1.8.0",
|
|
59
|
-
"@vite-hub/env": "0.
|
|
60
|
-
"@vite-hub/runtime": "0.
|
|
59
|
+
"@vite-hub/env": "0.9.0",
|
|
60
|
+
"@vite-hub/runtime": "0.9.0",
|
|
61
61
|
"valibot": "^1.5.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
"@types/node": "^24.19.2",
|
|
66
66
|
"@vite-hub/internal": "0.0.1",
|
|
67
67
|
"drizzle-orm": "1.0.0-rc.6",
|
|
68
|
+
"fast-check": "^4.11.0",
|
|
68
69
|
"nitro": "^3.0.261103-rc",
|
|
69
70
|
"publint": "^0.3.25",
|
|
70
71
|
"typescript": "^6.0.3",
|