@xtandard/webhooks 0.1.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/LICENSE +21 -0
- package/README.md +315 -0
- package/bin/xtandard-webhooks.mjs +3 -0
- package/dist/basic-BIW3Rvuz.cjs +199 -0
- package/dist/basic-BIW3Rvuz.cjs.map +1 -0
- package/dist/basic-DKk0Xfuu.mjs +176 -0
- package/dist/basic-DKk0Xfuu.mjs.map +1 -0
- package/dist/chunk-D7D4PA-g.mjs +13 -0
- package/dist/cli.cjs +655 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.cts +42 -0
- package/dist/cli.d.mts +42 -0
- package/dist/cli.mjs +653 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/contract-8h-Azxa5.d.cts +71 -0
- package/dist/contract-9XpcwcCn.mjs +22 -0
- package/dist/contract-9XpcwcCn.mjs.map +1 -0
- package/dist/contract-B2d5dNU3.cjs +33 -0
- package/dist/contract-B2d5dNU3.cjs.map +1 -0
- package/dist/contract-BEhDcd_5.mjs +28 -0
- package/dist/contract-BEhDcd_5.mjs.map +1 -0
- package/dist/contract-Bf1qguwt.cjs +57 -0
- package/dist/contract-Bf1qguwt.cjs.map +1 -0
- package/dist/contract-Bnb3fgRJ.d.cts +177 -0
- package/dist/contract-C2r2Xzwp.d.mts +46 -0
- package/dist/contract-CiPskNvS.d.cts +46 -0
- package/dist/contract-DhQ4JjGG.d.mts +71 -0
- package/dist/contract-T1kcZNdG.d.mts +177 -0
- package/dist/contract-lETlIuXo.d.cts +30 -0
- package/dist/contract-lETlIuXo.d.mts +30 -0
- package/dist/core-CMpnmI5Q.mjs +1605 -0
- package/dist/core-CMpnmI5Q.mjs.map +1 -0
- package/dist/core-DT4ppWh8.d.mts +502 -0
- package/dist/core-KJawHjFF.d.cts +502 -0
- package/dist/core-ZGhH6Vs2.cjs +1790 -0
- package/dist/core-ZGhH6Vs2.cjs.map +1 -0
- package/dist/core.cjs +8 -0
- package/dist/core.d.cts +2 -0
- package/dist/core.d.mts +2 -0
- package/dist/core.mjs +2 -0
- package/dist/create-fetch-handler-BIdk9P30.mjs +1724 -0
- package/dist/create-fetch-handler-BIdk9P30.mjs.map +1 -0
- package/dist/create-fetch-handler-CmooujQo.cjs +1771 -0
- package/dist/create-fetch-handler-CmooujQo.cjs.map +1 -0
- package/dist/create-fetch-handler-Dlkhustu.d.cts +162 -0
- package/dist/create-fetch-handler-jy3hy5nZ.d.mts +162 -0
- package/dist/dispatcher-B0xTEHt1.cjs +212 -0
- package/dist/dispatcher-B0xTEHt1.cjs.map +1 -0
- package/dist/dispatcher-Coubwrka.mjs +196 -0
- package/dist/dispatcher-Coubwrka.mjs.map +1 -0
- package/dist/entry-auth-basic.cjs +5 -0
- package/dist/entry-auth-basic.d.cts +83 -0
- package/dist/entry-auth-basic.d.mts +83 -0
- package/dist/entry-auth-basic.mjs +2 -0
- package/dist/entry-auth-delegated.cjs +28 -0
- package/dist/entry-auth-delegated.cjs.map +1 -0
- package/dist/entry-auth-delegated.d.cts +36 -0
- package/dist/entry-auth-delegated.d.mts +36 -0
- package/dist/entry-auth-delegated.mjs +27 -0
- package/dist/entry-auth-delegated.mjs.map +1 -0
- package/dist/entry-auth-none.cjs +4 -0
- package/dist/entry-auth-none.d.cts +25 -0
- package/dist/entry-auth-none.d.mts +25 -0
- package/dist/entry-auth-none.mjs +2 -0
- package/dist/entry-authorization-delegated.cjs +27 -0
- package/dist/entry-authorization-delegated.cjs.map +1 -0
- package/dist/entry-authorization-delegated.d.cts +31 -0
- package/dist/entry-authorization-delegated.d.mts +31 -0
- package/dist/entry-authorization-delegated.mjs +26 -0
- package/dist/entry-authorization-delegated.mjs.map +1 -0
- package/dist/entry-authorization-none.cjs +3 -0
- package/dist/entry-authorization-none.d.cts +18 -0
- package/dist/entry-authorization-none.d.mts +18 -0
- package/dist/entry-authorization-none.mjs +2 -0
- package/dist/entry-authorization-roles.cjs +6 -0
- package/dist/entry-authorization-roles.d.cts +65 -0
- package/dist/entry-authorization-roles.d.mts +65 -0
- package/dist/entry-authorization-roles.mjs +2 -0
- package/dist/entry-bun.cjs +24 -0
- package/dist/entry-bun.cjs.map +1 -0
- package/dist/entry-bun.d.cts +8 -0
- package/dist/entry-bun.d.mts +8 -0
- package/dist/entry-bun.mjs +23 -0
- package/dist/entry-bun.mjs.map +1 -0
- package/dist/entry-drizzle-mysql.cjs +20 -0
- package/dist/entry-drizzle-mysql.cjs.map +1 -0
- package/dist/entry-drizzle-mysql.d.cts +27 -0
- package/dist/entry-drizzle-mysql.d.mts +27 -0
- package/dist/entry-drizzle-mysql.mjs +19 -0
- package/dist/entry-drizzle-mysql.mjs.map +1 -0
- package/dist/entry-drizzle-pg.cjs +21 -0
- package/dist/entry-drizzle-pg.cjs.map +1 -0
- package/dist/entry-drizzle-pg.d.cts +26 -0
- package/dist/entry-drizzle-pg.d.mts +26 -0
- package/dist/entry-drizzle-pg.mjs +20 -0
- package/dist/entry-drizzle-pg.mjs.map +1 -0
- package/dist/entry-drizzle-sqlite.cjs +21 -0
- package/dist/entry-drizzle-sqlite.cjs.map +1 -0
- package/dist/entry-drizzle-sqlite.d.cts +23 -0
- package/dist/entry-drizzle-sqlite.d.mts +23 -0
- package/dist/entry-drizzle-sqlite.mjs +20 -0
- package/dist/entry-drizzle-sqlite.mjs.map +1 -0
- package/dist/entry-elysia.cjs +125 -0
- package/dist/entry-elysia.cjs.map +1 -0
- package/dist/entry-elysia.d.cts +1017 -0
- package/dist/entry-elysia.d.mts +1017 -0
- package/dist/entry-elysia.mjs +123 -0
- package/dist/entry-elysia.mjs.map +1 -0
- package/dist/entry-express.cjs +57 -0
- package/dist/entry-express.cjs.map +1 -0
- package/dist/entry-express.d.cts +15 -0
- package/dist/entry-express.d.mts +15 -0
- package/dist/entry-express.mjs +56 -0
- package/dist/entry-express.mjs.map +1 -0
- package/dist/entry-hono.cjs +35 -0
- package/dist/entry-hono.cjs.map +1 -0
- package/dist/entry-hono.d.cts +16 -0
- package/dist/entry-hono.d.mts +16 -0
- package/dist/entry-hono.mjs +34 -0
- package/dist/entry-hono.mjs.map +1 -0
- package/dist/entry-hooks-log.cjs +22 -0
- package/dist/entry-hooks-log.cjs.map +1 -0
- package/dist/entry-hooks-log.d.cts +23 -0
- package/dist/entry-hooks-log.d.mts +23 -0
- package/dist/entry-hooks-log.mjs +21 -0
- package/dist/entry-hooks-log.mjs.map +1 -0
- package/dist/entry-storage-cloudflare-kv.cjs +47 -0
- package/dist/entry-storage-cloudflare-kv.cjs.map +1 -0
- package/dist/entry-storage-cloudflare-kv.d.cts +42 -0
- package/dist/entry-storage-cloudflare-kv.d.mts +42 -0
- package/dist/entry-storage-cloudflare-kv.mjs +46 -0
- package/dist/entry-storage-cloudflare-kv.mjs.map +1 -0
- package/dist/entry-storage-drizzle.cjs +78 -0
- package/dist/entry-storage-drizzle.cjs.map +1 -0
- package/dist/entry-storage-drizzle.d.cts +30 -0
- package/dist/entry-storage-drizzle.d.mts +30 -0
- package/dist/entry-storage-drizzle.mjs +77 -0
- package/dist/entry-storage-drizzle.mjs.map +1 -0
- package/dist/entry-storage-file.cjs +4 -0
- package/dist/entry-storage-file.d.cts +30 -0
- package/dist/entry-storage-file.d.mts +30 -0
- package/dist/entry-storage-file.mjs +2 -0
- package/dist/entry-storage-libsql.cjs +3 -0
- package/dist/entry-storage-libsql.d.cts +48 -0
- package/dist/entry-storage-libsql.d.mts +48 -0
- package/dist/entry-storage-libsql.mjs +2 -0
- package/dist/entry-storage-memory.cjs +3 -0
- package/dist/entry-storage-memory.d.cts +2 -0
- package/dist/entry-storage-memory.d.mts +2 -0
- package/dist/entry-storage-memory.mjs +2 -0
- package/dist/entry-storage-mongodb.cjs +3 -0
- package/dist/entry-storage-mongodb.d.cts +55 -0
- package/dist/entry-storage-mongodb.d.mts +55 -0
- package/dist/entry-storage-mongodb.mjs +2 -0
- package/dist/entry-storage-postgres.cjs +3 -0
- package/dist/entry-storage-postgres.d.cts +62 -0
- package/dist/entry-storage-postgres.d.mts +62 -0
- package/dist/entry-storage-postgres.mjs +2 -0
- package/dist/entry-storage-redis.cjs +4 -0
- package/dist/entry-storage-redis.d.cts +77 -0
- package/dist/entry-storage-redis.d.mts +77 -0
- package/dist/entry-storage-redis.mjs +2 -0
- package/dist/entry-storage-sqlite.cjs +3 -0
- package/dist/entry-storage-sqlite.d.cts +36 -0
- package/dist/entry-storage-sqlite.d.mts +36 -0
- package/dist/entry-storage-sqlite.mjs +2 -0
- package/dist/entry-storage-unstorage.cjs +42 -0
- package/dist/entry-storage-unstorage.cjs.map +1 -0
- package/dist/entry-storage-unstorage.d.cts +29 -0
- package/dist/entry-storage-unstorage.d.mts +29 -0
- package/dist/entry-storage-unstorage.mjs +41 -0
- package/dist/entry-storage-unstorage.mjs.map +1 -0
- package/dist/file-COBYZA4Q.cjs +148 -0
- package/dist/file-COBYZA4Q.cjs.map +1 -0
- package/dist/file-fi02eFHk.mjs +131 -0
- package/dist/file-fi02eFHk.mjs.map +1 -0
- package/dist/index.cjs +123 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +368 -0
- package/dist/index.d.mts +366 -0
- package/dist/index.mjs +61 -0
- package/dist/index.mjs.map +1 -0
- package/dist/keys-Byyj4quQ.mjs +111 -0
- package/dist/keys-Byyj4quQ.mjs.map +1 -0
- package/dist/keys-FiKpaVHX.cjs +302 -0
- package/dist/keys-FiKpaVHX.cjs.map +1 -0
- package/dist/libsql-bpVi0bXN.mjs +113 -0
- package/dist/libsql-bpVi0bXN.mjs.map +1 -0
- package/dist/libsql-pPJEo1e4.cjs +124 -0
- package/dist/libsql-pPJEo1e4.cjs.map +1 -0
- package/dist/memory-8Ef-PL5a.cjs +137 -0
- package/dist/memory-8Ef-PL5a.cjs.map +1 -0
- package/dist/memory-BMsSSwqn.mjs +127 -0
- package/dist/memory-BMsSSwqn.mjs.map +1 -0
- package/dist/memory-FnMJWCmB.d.cts +28 -0
- package/dist/memory-qIvANEs_.d.mts +28 -0
- package/dist/mongodb-Cy8yo0uk.cjs +108 -0
- package/dist/mongodb-Cy8yo0uk.cjs.map +1 -0
- package/dist/mongodb-Ddaq9mml.mjs +97 -0
- package/dist/mongodb-Ddaq9mml.mjs.map +1 -0
- package/dist/none-BnZtaGNJ.mjs +23 -0
- package/dist/none-BnZtaGNJ.mjs.map +1 -0
- package/dist/none-CAsxCOWN.cjs +49 -0
- package/dist/none-CAsxCOWN.cjs.map +1 -0
- package/dist/none-CZVrfnmF.cjs +33 -0
- package/dist/none-CZVrfnmF.cjs.map +1 -0
- package/dist/none-GhVIoh_s.mjs +33 -0
- package/dist/none-GhVIoh_s.mjs.map +1 -0
- package/dist/postgres-C8WbchFa.cjs +134 -0
- package/dist/postgres-C8WbchFa.cjs.map +1 -0
- package/dist/postgres-c3pAhmhr.mjs +123 -0
- package/dist/postgres-c3pAhmhr.mjs.map +1 -0
- package/dist/react.css +1 -0
- package/dist/react.js +31465 -0
- package/dist/receiver.cjs +43 -0
- package/dist/receiver.cjs.map +1 -0
- package/dist/receiver.d.cts +36 -0
- package/dist/receiver.d.mts +36 -0
- package/dist/receiver.mjs +40 -0
- package/dist/receiver.mjs.map +1 -0
- package/dist/redis-CFJkuSgB.cjs +270 -0
- package/dist/redis-CFJkuSgB.cjs.map +1 -0
- package/dist/redis-CvLi0KF7.mjs +254 -0
- package/dist/redis-CvLi0KF7.mjs.map +1 -0
- package/dist/roles-D0G9XqBq.cjs +128 -0
- package/dist/roles-D0G9XqBq.cjs.map +1 -0
- package/dist/roles-vp361lTk.mjs +99 -0
- package/dist/roles-vp361lTk.mjs.map +1 -0
- package/dist/schema-mo__wv4P.d.cts +233 -0
- package/dist/schema-mo__wv4P.d.mts +233 -0
- package/dist/schema.cjs +13 -0
- package/dist/schema.cjs.map +1 -0
- package/dist/schema.d.cts +2 -0
- package/dist/schema.d.mts +2 -0
- package/dist/schema.mjs +11 -0
- package/dist/schema.mjs.map +1 -0
- package/dist/signing.cjs +162 -0
- package/dist/signing.cjs.map +1 -0
- package/dist/signing.d.cts +73 -0
- package/dist/signing.d.mts +73 -0
- package/dist/signing.mjs +156 -0
- package/dist/signing.mjs.map +1 -0
- package/dist/sqlite-Cmqnrjes.mjs +67 -0
- package/dist/sqlite-Cmqnrjes.mjs.map +1 -0
- package/dist/sqlite-Dcufk0x3.cjs +78 -0
- package/dist/sqlite-Dcufk0x3.cjs.map +1 -0
- package/dist/table-Ce3Tzwqs.d.cts +11 -0
- package/dist/table-Ce3Tzwqs.d.mts +11 -0
- package/dist/testing.cjs +134 -0
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.cts +80 -0
- package/dist/testing.d.mts +80 -0
- package/dist/testing.mjs +131 -0
- package/dist/testing.mjs.map +1 -0
- package/dist/types-react/react.d.ts +98 -0
- package/dist/types-react/schema.d.ts +229 -0
- package/dist/types-react/ui/App.d.ts +22 -0
- package/dist/types-react/ui/api.d.ts +97 -0
- package/dist/types-react/ui/components/JsonCodeEditor.d.ts +12 -0
- package/dist/types-react/ui/components/ThemeToggle.d.ts +2 -0
- package/dist/types-react/ui/components/Toast.d.ts +16 -0
- package/dist/types-react/ui/components/primitives.d.ts +50 -0
- package/dist/types-react/ui/components/ui-bits.d.ts +22 -0
- package/dist/types-react/ui/components/webhook-bits.d.ts +51 -0
- package/dist/types-react/ui/lib/format.d.ts +39 -0
- package/dist/types-react/ui/lib/nav-guard.d.ts +20 -0
- package/dist/types-react/ui/lib/utils.d.ts +3 -0
- package/dist/types-react/ui/theme.d.ts +12 -0
- package/dist/types-react/ui/types.d.ts +80 -0
- package/dist/types-react/ui/views/AuditView.d.ts +6 -0
- package/dist/types-react/ui/views/DeliveriesView.d.ts +12 -0
- package/dist/types-react/ui/views/EndpointsView.d.ts +11 -0
- package/dist/types-react/ui/views/EventTypesView.d.ts +11 -0
- package/dist/types-react/ui/views/MessagesView.d.ts +10 -0
- package/dist/types-react/ui/views/OverviewView.d.ts +12 -0
- package/dist/ui/assets/index-B0eoQX2U.css +1 -0
- package/dist/ui/assets/index-S5t_CLOe.js +209 -0
- package/dist/ui/index.html +14 -0
- package/package.json +487 -0
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
//#region src/schema.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Core type definitions for `@xtandard/webhooks`.
|
|
4
|
+
*
|
|
5
|
+
* This module is **types only** — no runtime code beyond tiny guards and the
|
|
6
|
+
* schema-version constant, no dependencies. It is safe to import from the
|
|
7
|
+
* publish hot path and the receiver. Runtime validation (which pulls in
|
|
8
|
+
* `valibot`) lives in {@link ./validation}.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
/** JSON-serializable value, used for payloads, metadata, and event-type schemas. */
|
|
13
|
+
type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
14
|
+
[key: string]: JsonValue;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* A duration for configuration options: either milliseconds as a number, or a
|
|
18
|
+
* human-friendly string such as `"5s"`, `"30m"`, `"2h"`, `"5d"`. Parsed by
|
|
19
|
+
* {@link ./duration.durationToMs}.
|
|
20
|
+
*/
|
|
21
|
+
type WebhookDuration = number | `${number}${"ms" | "s" | "m" | "h" | "d"}`;
|
|
22
|
+
/** Identity captured on audit records and passed by callers of audited mutations. */
|
|
23
|
+
interface Actor {
|
|
24
|
+
id: string;
|
|
25
|
+
email?: string;
|
|
26
|
+
name?: string;
|
|
27
|
+
}
|
|
28
|
+
/** Current schema version for stored records. */
|
|
29
|
+
declare const SCHEMA_VERSION: 1;
|
|
30
|
+
/**
|
|
31
|
+
* An application is the unit of tenancy — typically one of *your* customers.
|
|
32
|
+
* Endpoints, messages, and deliveries are all scoped to an application, and a
|
|
33
|
+
* portal token grants access to exactly one application.
|
|
34
|
+
*/
|
|
35
|
+
interface Application {
|
|
36
|
+
/** Unique key. Allowed characters: `a-z A-Z 0-9 . _ -`. */
|
|
37
|
+
key: string;
|
|
38
|
+
/** Optional human-friendly name shown in the UI. */
|
|
39
|
+
name?: string;
|
|
40
|
+
/** Arbitrary host-defined metadata. */
|
|
41
|
+
metadata?: JsonValue;
|
|
42
|
+
/** ISO-8601 creation timestamp, server-stamped. */
|
|
43
|
+
createdAt?: string;
|
|
44
|
+
/** ISO-8601 last-update timestamp, server-stamped. */
|
|
45
|
+
updatedAt?: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* A named kind of event in the **global** catalog (shared by all applications),
|
|
49
|
+
* e.g. `"invoice.paid"`. Endpoints subscribe to event types by name.
|
|
50
|
+
*/
|
|
51
|
+
interface EventType {
|
|
52
|
+
/** Unique dot-delimited name, e.g. `"invoice.paid"`. Allowed: `a-z A-Z 0-9 . _ -`. */
|
|
53
|
+
name: string;
|
|
54
|
+
/** Optional description shown in the UI and the public catalog. */
|
|
55
|
+
description?: string;
|
|
56
|
+
/** Optional UI grouping label (e.g. `"Billing"`). Purely presentational. */
|
|
57
|
+
groupName?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Optional JSON Schema describing the payload. Documentation by default;
|
|
60
|
+
* enforced only when the core is configured with a `payloadValidator`.
|
|
61
|
+
*/
|
|
62
|
+
schema?: JsonValue;
|
|
63
|
+
/** Deprecated event types are flagged in the UI but still deliverable. */
|
|
64
|
+
deprecated?: boolean;
|
|
65
|
+
/** ISO-8601 creation timestamp, server-stamped. */
|
|
66
|
+
createdAt?: string;
|
|
67
|
+
/** ISO-8601 last-update timestamp, server-stamped. */
|
|
68
|
+
updatedAt?: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* A signing secret attached to an endpoint. Secrets are `whsec_` + base64 per
|
|
72
|
+
* the Standard Webhooks spec. Rotation keeps the previous secret verifiable
|
|
73
|
+
* until `expiresAt` (the grace window); expired secrets are pruned lazily.
|
|
74
|
+
*/
|
|
75
|
+
interface EndpointSecret {
|
|
76
|
+
/** `"whsec_"` + base64-encoded random key material. */
|
|
77
|
+
secret: string;
|
|
78
|
+
/** ISO-8601 creation timestamp. */
|
|
79
|
+
createdAt: string;
|
|
80
|
+
/** Set when superseded by rotation; the secret stops signing after this instant. */
|
|
81
|
+
expiresAt?: string;
|
|
82
|
+
}
|
|
83
|
+
/** Why an endpoint is disabled: by an operator, or by the auto-disable policy. */
|
|
84
|
+
type EndpointDisabledReason = "manual" | "auto";
|
|
85
|
+
/**
|
|
86
|
+
* A customer-registered URL that receives deliveries for one application.
|
|
87
|
+
*/
|
|
88
|
+
interface Endpoint {
|
|
89
|
+
/** `"ep_"` + 22-char base62, server-generated. */
|
|
90
|
+
id: string;
|
|
91
|
+
/** Destination URL. `https` is enforced by default (`allowInsecureUrls` for dev). */
|
|
92
|
+
url: string;
|
|
93
|
+
/** Optional description shown in the UI. */
|
|
94
|
+
description?: string;
|
|
95
|
+
/**
|
|
96
|
+
* Event type names this endpoint subscribes to. Empty or absent = receives
|
|
97
|
+
* **all** event types.
|
|
98
|
+
*/
|
|
99
|
+
eventTypes?: string[];
|
|
100
|
+
/** Disabled endpoints receive no deliveries (pending ones are held, not failed). */
|
|
101
|
+
disabled?: boolean;
|
|
102
|
+
/** Who/what disabled it — an operator (`"manual"`) or the failure policy (`"auto"`). */
|
|
103
|
+
disabledReason?: EndpointDisabledReason;
|
|
104
|
+
/** Static extra headers merged into every delivery request. */
|
|
105
|
+
headers?: Record<string, string>;
|
|
106
|
+
/** Signing secrets. `[0]` is current; extras are still-verifiable rotation grace. */
|
|
107
|
+
secrets: EndpointSecret[];
|
|
108
|
+
/** Arbitrary host-defined metadata. */
|
|
109
|
+
metadata?: JsonValue;
|
|
110
|
+
/** ISO-8601 creation timestamp, server-stamped. */
|
|
111
|
+
createdAt?: string;
|
|
112
|
+
/** ISO-8601 last-update timestamp, server-stamped. */
|
|
113
|
+
updatedAt?: string;
|
|
114
|
+
/**
|
|
115
|
+
* Start of the current unbroken failure streak (any successful delivery
|
|
116
|
+
* clears it). Drives the auto-disable policy.
|
|
117
|
+
*/
|
|
118
|
+
firstFailingAt?: string | null;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* A published event for one application. The message is the receiver-facing
|
|
122
|
+
* unit: its id is the `webhook-id` header (stable across retries — receivers
|
|
123
|
+
* dedupe on it), and its payload is the `data` of the wire envelope.
|
|
124
|
+
*/
|
|
125
|
+
interface Message {
|
|
126
|
+
/** `"msg_"` + 22-char base62, server-generated. Sent as `webhook-id`. */
|
|
127
|
+
id: string;
|
|
128
|
+
/** Event type name (usually from the global catalog). */
|
|
129
|
+
eventType: string;
|
|
130
|
+
/** The `data` of the wire envelope. */
|
|
131
|
+
payload: JsonValue;
|
|
132
|
+
/** ISO-8601 event-occurred time (defaults to publish time). Sent in the envelope. */
|
|
133
|
+
timestamp: string;
|
|
134
|
+
/** Optional caller-supplied dedupe key; same key within retention returns the same message. */
|
|
135
|
+
idempotencyKey?: string;
|
|
136
|
+
/**
|
|
137
|
+
* The wire envelope serialized **once at publish time** so the signed bytes
|
|
138
|
+
* are identical across every retry of every delivery.
|
|
139
|
+
*/
|
|
140
|
+
envelope: string;
|
|
141
|
+
/** ISO-8601 creation timestamp, server-stamped. */
|
|
142
|
+
createdAt: string;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Delivery lifecycle. `"failed"` means the retry schedule is exhausted — the
|
|
146
|
+
* dead-letter state. A manual retry moves a failed delivery back to `"pending"`.
|
|
147
|
+
*/
|
|
148
|
+
type DeliveryStatus = "pending" | "delivering" | "succeeded" | "failed";
|
|
149
|
+
/** Guard: has this delivery reached a terminal state? */
|
|
150
|
+
declare function isTerminalDeliveryStatus(status: DeliveryStatus): boolean;
|
|
151
|
+
/**
|
|
152
|
+
* One message × one endpoint. Created at publish time (fan-out) and driven to
|
|
153
|
+
* a terminal state by the dispatcher.
|
|
154
|
+
*/
|
|
155
|
+
interface Delivery {
|
|
156
|
+
/** `"dlv_"` + 22-char base62, server-generated. */
|
|
157
|
+
id: string;
|
|
158
|
+
/** The application this delivery belongs to (deliveries cross the dispatcher denormalized). */
|
|
159
|
+
applicationKey: string;
|
|
160
|
+
messageId: string;
|
|
161
|
+
endpointId: string;
|
|
162
|
+
status: DeliveryStatus;
|
|
163
|
+
/** Number of attempts made so far. */
|
|
164
|
+
attemptCount: number;
|
|
165
|
+
/** When the next attempt is due. `null` once terminal. */
|
|
166
|
+
nextAttemptAt?: string | null;
|
|
167
|
+
/** Dispatcher claim expiry; an expired lease makes the delivery reclaimable. */
|
|
168
|
+
leaseUntil?: string | null;
|
|
169
|
+
/**
|
|
170
|
+
* How the *next* attempt should be recorded: set to `"manual"` by
|
|
171
|
+
* retry/recover so the resulting attempt is attributed correctly, then
|
|
172
|
+
* cleared. Absent = `"schedule"`.
|
|
173
|
+
*/
|
|
174
|
+
pendingTrigger?: AttemptTrigger;
|
|
175
|
+
/** ISO-8601 creation timestamp. */
|
|
176
|
+
createdAt: string;
|
|
177
|
+
/** ISO-8601 last-transition timestamp. */
|
|
178
|
+
updatedAt: string;
|
|
179
|
+
}
|
|
180
|
+
/** What initiated a delivery attempt. */
|
|
181
|
+
type AttemptTrigger = "schedule" | "manual" | "test";
|
|
182
|
+
/** The recorded outcome of a single HTTP delivery attempt. */
|
|
183
|
+
interface DeliveryAttempt {
|
|
184
|
+
/** `"atp_"` + 22-char base62, server-generated. */
|
|
185
|
+
id: string;
|
|
186
|
+
deliveryId: string;
|
|
187
|
+
/** 1-based attempt ordinal within the delivery. */
|
|
188
|
+
attemptNumber: number;
|
|
189
|
+
/** ISO-8601 timestamp of the attempt. */
|
|
190
|
+
at: string;
|
|
191
|
+
/** Wall-clock duration of the HTTP round trip. */
|
|
192
|
+
durationMs: number;
|
|
193
|
+
/** True when the receiver answered 2xx. */
|
|
194
|
+
ok: boolean;
|
|
195
|
+
/** HTTP status code; absent on network error or timeout. */
|
|
196
|
+
httpStatus?: number;
|
|
197
|
+
/** Truncated error message on network error/timeout. */
|
|
198
|
+
error?: string;
|
|
199
|
+
/** Truncated response body (default cap 4096 chars). */
|
|
200
|
+
responseBody?: string;
|
|
201
|
+
/** What initiated this attempt. */
|
|
202
|
+
trigger: AttemptTrigger;
|
|
203
|
+
}
|
|
204
|
+
/** Actions recorded in the control-plane audit log. */
|
|
205
|
+
type AuditAction = "application.create" | "application.update" | "application.delete" | "event-type.create" | "event-type.update" | "event-type.delete" | "endpoint.create" | "endpoint.update" | "endpoint.delete" | "endpoint.rotate-secret" | "endpoint.disable" | "endpoint.enable" | "delivery.retry" | "endpoint.recover";
|
|
206
|
+
/**
|
|
207
|
+
* A single control-plane audit record. Publishes are deliberately *not*
|
|
208
|
+
* audited — they are data-plane traffic, and the message log is their record.
|
|
209
|
+
*/
|
|
210
|
+
interface AuditEntry {
|
|
211
|
+
action: AuditAction;
|
|
212
|
+
/** ISO-8601 timestamp. */
|
|
213
|
+
at: string;
|
|
214
|
+
by?: Actor | null;
|
|
215
|
+
/** The application the action was scoped to (absent for global event types). */
|
|
216
|
+
applicationKey?: string;
|
|
217
|
+
/** Endpoint id / event type name / delivery id the action targeted. */
|
|
218
|
+
subjectId?: string;
|
|
219
|
+
message?: string;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* The wire envelope receivers get — the Standard Webhooks recommended shape.
|
|
223
|
+
* `type` is the event type name, `timestamp` the event-occurred time, and
|
|
224
|
+
* `data` the published payload.
|
|
225
|
+
*/
|
|
226
|
+
interface WebhookEnvelope {
|
|
227
|
+
type: string;
|
|
228
|
+
timestamp: string;
|
|
229
|
+
data: JsonValue;
|
|
230
|
+
}
|
|
231
|
+
//#endregion
|
|
232
|
+
export { WebhookEnvelope as _, AuditEntry as a, DeliveryStatus as c, EndpointSecret as d, EventType as f, WebhookDuration as g, SCHEMA_VERSION as h, AuditAction as i, Endpoint as l, Message as m, Application as n, Delivery as o, JsonValue as p, AttemptTrigger as r, DeliveryAttempt as s, Actor as t, EndpointDisabledReason as u, isTerminalDeliveryStatus as v };
|
|
233
|
+
//# sourceMappingURL=schema-mo__wv4P.d.cts.map
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
//#region src/schema.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Core type definitions for `@xtandard/webhooks`.
|
|
4
|
+
*
|
|
5
|
+
* This module is **types only** — no runtime code beyond tiny guards and the
|
|
6
|
+
* schema-version constant, no dependencies. It is safe to import from the
|
|
7
|
+
* publish hot path and the receiver. Runtime validation (which pulls in
|
|
8
|
+
* `valibot`) lives in {@link ./validation}.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
/** JSON-serializable value, used for payloads, metadata, and event-type schemas. */
|
|
13
|
+
type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
14
|
+
[key: string]: JsonValue;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* A duration for configuration options: either milliseconds as a number, or a
|
|
18
|
+
* human-friendly string such as `"5s"`, `"30m"`, `"2h"`, `"5d"`. Parsed by
|
|
19
|
+
* {@link ./duration.durationToMs}.
|
|
20
|
+
*/
|
|
21
|
+
type WebhookDuration = number | `${number}${"ms" | "s" | "m" | "h" | "d"}`;
|
|
22
|
+
/** Identity captured on audit records and passed by callers of audited mutations. */
|
|
23
|
+
interface Actor {
|
|
24
|
+
id: string;
|
|
25
|
+
email?: string;
|
|
26
|
+
name?: string;
|
|
27
|
+
}
|
|
28
|
+
/** Current schema version for stored records. */
|
|
29
|
+
declare const SCHEMA_VERSION: 1;
|
|
30
|
+
/**
|
|
31
|
+
* An application is the unit of tenancy — typically one of *your* customers.
|
|
32
|
+
* Endpoints, messages, and deliveries are all scoped to an application, and a
|
|
33
|
+
* portal token grants access to exactly one application.
|
|
34
|
+
*/
|
|
35
|
+
interface Application {
|
|
36
|
+
/** Unique key. Allowed characters: `a-z A-Z 0-9 . _ -`. */
|
|
37
|
+
key: string;
|
|
38
|
+
/** Optional human-friendly name shown in the UI. */
|
|
39
|
+
name?: string;
|
|
40
|
+
/** Arbitrary host-defined metadata. */
|
|
41
|
+
metadata?: JsonValue;
|
|
42
|
+
/** ISO-8601 creation timestamp, server-stamped. */
|
|
43
|
+
createdAt?: string;
|
|
44
|
+
/** ISO-8601 last-update timestamp, server-stamped. */
|
|
45
|
+
updatedAt?: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* A named kind of event in the **global** catalog (shared by all applications),
|
|
49
|
+
* e.g. `"invoice.paid"`. Endpoints subscribe to event types by name.
|
|
50
|
+
*/
|
|
51
|
+
interface EventType {
|
|
52
|
+
/** Unique dot-delimited name, e.g. `"invoice.paid"`. Allowed: `a-z A-Z 0-9 . _ -`. */
|
|
53
|
+
name: string;
|
|
54
|
+
/** Optional description shown in the UI and the public catalog. */
|
|
55
|
+
description?: string;
|
|
56
|
+
/** Optional UI grouping label (e.g. `"Billing"`). Purely presentational. */
|
|
57
|
+
groupName?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Optional JSON Schema describing the payload. Documentation by default;
|
|
60
|
+
* enforced only when the core is configured with a `payloadValidator`.
|
|
61
|
+
*/
|
|
62
|
+
schema?: JsonValue;
|
|
63
|
+
/** Deprecated event types are flagged in the UI but still deliverable. */
|
|
64
|
+
deprecated?: boolean;
|
|
65
|
+
/** ISO-8601 creation timestamp, server-stamped. */
|
|
66
|
+
createdAt?: string;
|
|
67
|
+
/** ISO-8601 last-update timestamp, server-stamped. */
|
|
68
|
+
updatedAt?: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* A signing secret attached to an endpoint. Secrets are `whsec_` + base64 per
|
|
72
|
+
* the Standard Webhooks spec. Rotation keeps the previous secret verifiable
|
|
73
|
+
* until `expiresAt` (the grace window); expired secrets are pruned lazily.
|
|
74
|
+
*/
|
|
75
|
+
interface EndpointSecret {
|
|
76
|
+
/** `"whsec_"` + base64-encoded random key material. */
|
|
77
|
+
secret: string;
|
|
78
|
+
/** ISO-8601 creation timestamp. */
|
|
79
|
+
createdAt: string;
|
|
80
|
+
/** Set when superseded by rotation; the secret stops signing after this instant. */
|
|
81
|
+
expiresAt?: string;
|
|
82
|
+
}
|
|
83
|
+
/** Why an endpoint is disabled: by an operator, or by the auto-disable policy. */
|
|
84
|
+
type EndpointDisabledReason = "manual" | "auto";
|
|
85
|
+
/**
|
|
86
|
+
* A customer-registered URL that receives deliveries for one application.
|
|
87
|
+
*/
|
|
88
|
+
interface Endpoint {
|
|
89
|
+
/** `"ep_"` + 22-char base62, server-generated. */
|
|
90
|
+
id: string;
|
|
91
|
+
/** Destination URL. `https` is enforced by default (`allowInsecureUrls` for dev). */
|
|
92
|
+
url: string;
|
|
93
|
+
/** Optional description shown in the UI. */
|
|
94
|
+
description?: string;
|
|
95
|
+
/**
|
|
96
|
+
* Event type names this endpoint subscribes to. Empty or absent = receives
|
|
97
|
+
* **all** event types.
|
|
98
|
+
*/
|
|
99
|
+
eventTypes?: string[];
|
|
100
|
+
/** Disabled endpoints receive no deliveries (pending ones are held, not failed). */
|
|
101
|
+
disabled?: boolean;
|
|
102
|
+
/** Who/what disabled it — an operator (`"manual"`) or the failure policy (`"auto"`). */
|
|
103
|
+
disabledReason?: EndpointDisabledReason;
|
|
104
|
+
/** Static extra headers merged into every delivery request. */
|
|
105
|
+
headers?: Record<string, string>;
|
|
106
|
+
/** Signing secrets. `[0]` is current; extras are still-verifiable rotation grace. */
|
|
107
|
+
secrets: EndpointSecret[];
|
|
108
|
+
/** Arbitrary host-defined metadata. */
|
|
109
|
+
metadata?: JsonValue;
|
|
110
|
+
/** ISO-8601 creation timestamp, server-stamped. */
|
|
111
|
+
createdAt?: string;
|
|
112
|
+
/** ISO-8601 last-update timestamp, server-stamped. */
|
|
113
|
+
updatedAt?: string;
|
|
114
|
+
/**
|
|
115
|
+
* Start of the current unbroken failure streak (any successful delivery
|
|
116
|
+
* clears it). Drives the auto-disable policy.
|
|
117
|
+
*/
|
|
118
|
+
firstFailingAt?: string | null;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* A published event for one application. The message is the receiver-facing
|
|
122
|
+
* unit: its id is the `webhook-id` header (stable across retries — receivers
|
|
123
|
+
* dedupe on it), and its payload is the `data` of the wire envelope.
|
|
124
|
+
*/
|
|
125
|
+
interface Message {
|
|
126
|
+
/** `"msg_"` + 22-char base62, server-generated. Sent as `webhook-id`. */
|
|
127
|
+
id: string;
|
|
128
|
+
/** Event type name (usually from the global catalog). */
|
|
129
|
+
eventType: string;
|
|
130
|
+
/** The `data` of the wire envelope. */
|
|
131
|
+
payload: JsonValue;
|
|
132
|
+
/** ISO-8601 event-occurred time (defaults to publish time). Sent in the envelope. */
|
|
133
|
+
timestamp: string;
|
|
134
|
+
/** Optional caller-supplied dedupe key; same key within retention returns the same message. */
|
|
135
|
+
idempotencyKey?: string;
|
|
136
|
+
/**
|
|
137
|
+
* The wire envelope serialized **once at publish time** so the signed bytes
|
|
138
|
+
* are identical across every retry of every delivery.
|
|
139
|
+
*/
|
|
140
|
+
envelope: string;
|
|
141
|
+
/** ISO-8601 creation timestamp, server-stamped. */
|
|
142
|
+
createdAt: string;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Delivery lifecycle. `"failed"` means the retry schedule is exhausted — the
|
|
146
|
+
* dead-letter state. A manual retry moves a failed delivery back to `"pending"`.
|
|
147
|
+
*/
|
|
148
|
+
type DeliveryStatus = "pending" | "delivering" | "succeeded" | "failed";
|
|
149
|
+
/** Guard: has this delivery reached a terminal state? */
|
|
150
|
+
declare function isTerminalDeliveryStatus(status: DeliveryStatus): boolean;
|
|
151
|
+
/**
|
|
152
|
+
* One message × one endpoint. Created at publish time (fan-out) and driven to
|
|
153
|
+
* a terminal state by the dispatcher.
|
|
154
|
+
*/
|
|
155
|
+
interface Delivery {
|
|
156
|
+
/** `"dlv_"` + 22-char base62, server-generated. */
|
|
157
|
+
id: string;
|
|
158
|
+
/** The application this delivery belongs to (deliveries cross the dispatcher denormalized). */
|
|
159
|
+
applicationKey: string;
|
|
160
|
+
messageId: string;
|
|
161
|
+
endpointId: string;
|
|
162
|
+
status: DeliveryStatus;
|
|
163
|
+
/** Number of attempts made so far. */
|
|
164
|
+
attemptCount: number;
|
|
165
|
+
/** When the next attempt is due. `null` once terminal. */
|
|
166
|
+
nextAttemptAt?: string | null;
|
|
167
|
+
/** Dispatcher claim expiry; an expired lease makes the delivery reclaimable. */
|
|
168
|
+
leaseUntil?: string | null;
|
|
169
|
+
/**
|
|
170
|
+
* How the *next* attempt should be recorded: set to `"manual"` by
|
|
171
|
+
* retry/recover so the resulting attempt is attributed correctly, then
|
|
172
|
+
* cleared. Absent = `"schedule"`.
|
|
173
|
+
*/
|
|
174
|
+
pendingTrigger?: AttemptTrigger;
|
|
175
|
+
/** ISO-8601 creation timestamp. */
|
|
176
|
+
createdAt: string;
|
|
177
|
+
/** ISO-8601 last-transition timestamp. */
|
|
178
|
+
updatedAt: string;
|
|
179
|
+
}
|
|
180
|
+
/** What initiated a delivery attempt. */
|
|
181
|
+
type AttemptTrigger = "schedule" | "manual" | "test";
|
|
182
|
+
/** The recorded outcome of a single HTTP delivery attempt. */
|
|
183
|
+
interface DeliveryAttempt {
|
|
184
|
+
/** `"atp_"` + 22-char base62, server-generated. */
|
|
185
|
+
id: string;
|
|
186
|
+
deliveryId: string;
|
|
187
|
+
/** 1-based attempt ordinal within the delivery. */
|
|
188
|
+
attemptNumber: number;
|
|
189
|
+
/** ISO-8601 timestamp of the attempt. */
|
|
190
|
+
at: string;
|
|
191
|
+
/** Wall-clock duration of the HTTP round trip. */
|
|
192
|
+
durationMs: number;
|
|
193
|
+
/** True when the receiver answered 2xx. */
|
|
194
|
+
ok: boolean;
|
|
195
|
+
/** HTTP status code; absent on network error or timeout. */
|
|
196
|
+
httpStatus?: number;
|
|
197
|
+
/** Truncated error message on network error/timeout. */
|
|
198
|
+
error?: string;
|
|
199
|
+
/** Truncated response body (default cap 4096 chars). */
|
|
200
|
+
responseBody?: string;
|
|
201
|
+
/** What initiated this attempt. */
|
|
202
|
+
trigger: AttemptTrigger;
|
|
203
|
+
}
|
|
204
|
+
/** Actions recorded in the control-plane audit log. */
|
|
205
|
+
type AuditAction = "application.create" | "application.update" | "application.delete" | "event-type.create" | "event-type.update" | "event-type.delete" | "endpoint.create" | "endpoint.update" | "endpoint.delete" | "endpoint.rotate-secret" | "endpoint.disable" | "endpoint.enable" | "delivery.retry" | "endpoint.recover";
|
|
206
|
+
/**
|
|
207
|
+
* A single control-plane audit record. Publishes are deliberately *not*
|
|
208
|
+
* audited — they are data-plane traffic, and the message log is their record.
|
|
209
|
+
*/
|
|
210
|
+
interface AuditEntry {
|
|
211
|
+
action: AuditAction;
|
|
212
|
+
/** ISO-8601 timestamp. */
|
|
213
|
+
at: string;
|
|
214
|
+
by?: Actor | null;
|
|
215
|
+
/** The application the action was scoped to (absent for global event types). */
|
|
216
|
+
applicationKey?: string;
|
|
217
|
+
/** Endpoint id / event type name / delivery id the action targeted. */
|
|
218
|
+
subjectId?: string;
|
|
219
|
+
message?: string;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* The wire envelope receivers get — the Standard Webhooks recommended shape.
|
|
223
|
+
* `type` is the event type name, `timestamp` the event-occurred time, and
|
|
224
|
+
* `data` the published payload.
|
|
225
|
+
*/
|
|
226
|
+
interface WebhookEnvelope {
|
|
227
|
+
type: string;
|
|
228
|
+
timestamp: string;
|
|
229
|
+
data: JsonValue;
|
|
230
|
+
}
|
|
231
|
+
//#endregion
|
|
232
|
+
export { WebhookEnvelope as _, AuditEntry as a, DeliveryStatus as c, EndpointSecret as d, EventType as f, WebhookDuration as g, SCHEMA_VERSION as h, AuditAction as i, Endpoint as l, Message as m, Application as n, Delivery as o, JsonValue as p, AttemptTrigger as r, DeliveryAttempt as s, Actor as t, EndpointDisabledReason as u, isTerminalDeliveryStatus as v };
|
|
233
|
+
//# sourceMappingURL=schema-mo__wv4P.d.mts.map
|
package/dist/schema.cjs
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/schema.ts
|
|
3
|
+
/** Current schema version for stored records. */
|
|
4
|
+
const SCHEMA_VERSION = 1;
|
|
5
|
+
/** Guard: has this delivery reached a terminal state? */
|
|
6
|
+
function isTerminalDeliveryStatus(status) {
|
|
7
|
+
return status === "succeeded" || status === "failed";
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
exports.SCHEMA_VERSION = SCHEMA_VERSION;
|
|
11
|
+
exports.isTerminalDeliveryStatus = isTerminalDeliveryStatus;
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=schema.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.cjs","names":[],"sources":["../src/schema.ts"],"sourcesContent":["/**\n * Core type definitions for `@xtandard/webhooks`.\n *\n * This module is **types only** — no runtime code beyond tiny guards and the\n * schema-version constant, no dependencies. It is safe to import from the\n * publish hot path and the receiver. Runtime validation (which pulls in\n * `valibot`) lives in {@link ./validation}.\n *\n * @module\n */\n\n/** JSON-serializable value, used for payloads, metadata, and event-type schemas. */\nexport type JsonValue =\n | string\n | number\n | boolean\n | null\n | JsonValue[]\n | { [key: string]: JsonValue };\n\n/**\n * A duration for configuration options: either milliseconds as a number, or a\n * human-friendly string such as `\"5s\"`, `\"30m\"`, `\"2h\"`, `\"5d\"`. Parsed by\n * {@link ./duration.durationToMs}.\n */\nexport type WebhookDuration = number | `${number}${\"ms\" | \"s\" | \"m\" | \"h\" | \"d\"}`;\n\n/** Identity captured on audit records and passed by callers of audited mutations. */\nexport interface Actor {\n id: string;\n email?: string;\n name?: string;\n}\n\n/** Current schema version for stored records. */\nexport const SCHEMA_VERSION = 1 as const;\n\n/**\n * An application is the unit of tenancy — typically one of *your* customers.\n * Endpoints, messages, and deliveries are all scoped to an application, and a\n * portal token grants access to exactly one application.\n */\nexport interface Application {\n /** Unique key. Allowed characters: `a-z A-Z 0-9 . _ -`. */\n key: string;\n /** Optional human-friendly name shown in the UI. */\n name?: string;\n /** Arbitrary host-defined metadata. */\n metadata?: JsonValue;\n /** ISO-8601 creation timestamp, server-stamped. */\n createdAt?: string;\n /** ISO-8601 last-update timestamp, server-stamped. */\n updatedAt?: string;\n}\n\n/**\n * A named kind of event in the **global** catalog (shared by all applications),\n * e.g. `\"invoice.paid\"`. Endpoints subscribe to event types by name.\n */\nexport interface EventType {\n /** Unique dot-delimited name, e.g. `\"invoice.paid\"`. Allowed: `a-z A-Z 0-9 . _ -`. */\n name: string;\n /** Optional description shown in the UI and the public catalog. */\n description?: string;\n /** Optional UI grouping label (e.g. `\"Billing\"`). Purely presentational. */\n groupName?: string;\n /**\n * Optional JSON Schema describing the payload. Documentation by default;\n * enforced only when the core is configured with a `payloadValidator`.\n */\n schema?: JsonValue;\n /** Deprecated event types are flagged in the UI but still deliverable. */\n deprecated?: boolean;\n /** ISO-8601 creation timestamp, server-stamped. */\n createdAt?: string;\n /** ISO-8601 last-update timestamp, server-stamped. */\n updatedAt?: string;\n}\n\n/**\n * A signing secret attached to an endpoint. Secrets are `whsec_` + base64 per\n * the Standard Webhooks spec. Rotation keeps the previous secret verifiable\n * until `expiresAt` (the grace window); expired secrets are pruned lazily.\n */\nexport interface EndpointSecret {\n /** `\"whsec_\"` + base64-encoded random key material. */\n secret: string;\n /** ISO-8601 creation timestamp. */\n createdAt: string;\n /** Set when superseded by rotation; the secret stops signing after this instant. */\n expiresAt?: string;\n}\n\n/** Why an endpoint is disabled: by an operator, or by the auto-disable policy. */\nexport type EndpointDisabledReason = \"manual\" | \"auto\";\n\n/**\n * A customer-registered URL that receives deliveries for one application.\n */\nexport interface Endpoint {\n /** `\"ep_\"` + 22-char base62, server-generated. */\n id: string;\n /** Destination URL. `https` is enforced by default (`allowInsecureUrls` for dev). */\n url: string;\n /** Optional description shown in the UI. */\n description?: string;\n /**\n * Event type names this endpoint subscribes to. Empty or absent = receives\n * **all** event types.\n */\n eventTypes?: string[];\n /** Disabled endpoints receive no deliveries (pending ones are held, not failed). */\n disabled?: boolean;\n /** Who/what disabled it — an operator (`\"manual\"`) or the failure policy (`\"auto\"`). */\n disabledReason?: EndpointDisabledReason;\n /** Static extra headers merged into every delivery request. */\n headers?: Record<string, string>;\n /** Signing secrets. `[0]` is current; extras are still-verifiable rotation grace. */\n secrets: EndpointSecret[];\n /** Arbitrary host-defined metadata. */\n metadata?: JsonValue;\n /** ISO-8601 creation timestamp, server-stamped. */\n createdAt?: string;\n /** ISO-8601 last-update timestamp, server-stamped. */\n updatedAt?: string;\n /**\n * Start of the current unbroken failure streak (any successful delivery\n * clears it). Drives the auto-disable policy.\n */\n firstFailingAt?: string | null;\n}\n\n/**\n * A published event for one application. The message is the receiver-facing\n * unit: its id is the `webhook-id` header (stable across retries — receivers\n * dedupe on it), and its payload is the `data` of the wire envelope.\n */\nexport interface Message {\n /** `\"msg_\"` + 22-char base62, server-generated. Sent as `webhook-id`. */\n id: string;\n /** Event type name (usually from the global catalog). */\n eventType: string;\n /** The `data` of the wire envelope. */\n payload: JsonValue;\n /** ISO-8601 event-occurred time (defaults to publish time). Sent in the envelope. */\n timestamp: string;\n /** Optional caller-supplied dedupe key; same key within retention returns the same message. */\n idempotencyKey?: string;\n /**\n * The wire envelope serialized **once at publish time** so the signed bytes\n * are identical across every retry of every delivery.\n */\n envelope: string;\n /** ISO-8601 creation timestamp, server-stamped. */\n createdAt: string;\n}\n\n/**\n * Delivery lifecycle. `\"failed\"` means the retry schedule is exhausted — the\n * dead-letter state. A manual retry moves a failed delivery back to `\"pending\"`.\n */\nexport type DeliveryStatus = \"pending\" | \"delivering\" | \"succeeded\" | \"failed\";\n\n/** Guard: has this delivery reached a terminal state? */\nexport function isTerminalDeliveryStatus(status: DeliveryStatus): boolean {\n return status === \"succeeded\" || status === \"failed\";\n}\n\n/**\n * One message × one endpoint. Created at publish time (fan-out) and driven to\n * a terminal state by the dispatcher.\n */\nexport interface Delivery {\n /** `\"dlv_\"` + 22-char base62, server-generated. */\n id: string;\n /** The application this delivery belongs to (deliveries cross the dispatcher denormalized). */\n applicationKey: string;\n messageId: string;\n endpointId: string;\n status: DeliveryStatus;\n /** Number of attempts made so far. */\n attemptCount: number;\n /** When the next attempt is due. `null` once terminal. */\n nextAttemptAt?: string | null;\n /** Dispatcher claim expiry; an expired lease makes the delivery reclaimable. */\n leaseUntil?: string | null;\n /**\n * How the *next* attempt should be recorded: set to `\"manual\"` by\n * retry/recover so the resulting attempt is attributed correctly, then\n * cleared. Absent = `\"schedule\"`.\n */\n pendingTrigger?: AttemptTrigger;\n /** ISO-8601 creation timestamp. */\n createdAt: string;\n /** ISO-8601 last-transition timestamp. */\n updatedAt: string;\n}\n\n/** What initiated a delivery attempt. */\nexport type AttemptTrigger = \"schedule\" | \"manual\" | \"test\";\n\n/** The recorded outcome of a single HTTP delivery attempt. */\nexport interface DeliveryAttempt {\n /** `\"atp_\"` + 22-char base62, server-generated. */\n id: string;\n deliveryId: string;\n /** 1-based attempt ordinal within the delivery. */\n attemptNumber: number;\n /** ISO-8601 timestamp of the attempt. */\n at: string;\n /** Wall-clock duration of the HTTP round trip. */\n durationMs: number;\n /** True when the receiver answered 2xx. */\n ok: boolean;\n /** HTTP status code; absent on network error or timeout. */\n httpStatus?: number;\n /** Truncated error message on network error/timeout. */\n error?: string;\n /** Truncated response body (default cap 4096 chars). */\n responseBody?: string;\n /** What initiated this attempt. */\n trigger: AttemptTrigger;\n}\n\n/** Actions recorded in the control-plane audit log. */\nexport type AuditAction =\n | \"application.create\"\n | \"application.update\"\n | \"application.delete\"\n | \"event-type.create\"\n | \"event-type.update\"\n | \"event-type.delete\"\n | \"endpoint.create\"\n | \"endpoint.update\"\n | \"endpoint.delete\"\n | \"endpoint.rotate-secret\"\n | \"endpoint.disable\"\n | \"endpoint.enable\"\n | \"delivery.retry\"\n | \"endpoint.recover\";\n\n/**\n * A single control-plane audit record. Publishes are deliberately *not*\n * audited — they are data-plane traffic, and the message log is their record.\n */\nexport interface AuditEntry {\n action: AuditAction;\n /** ISO-8601 timestamp. */\n at: string;\n by?: Actor | null;\n /** The application the action was scoped to (absent for global event types). */\n applicationKey?: string;\n /** Endpoint id / event type name / delivery id the action targeted. */\n subjectId?: string;\n message?: string;\n}\n\n/**\n * The wire envelope receivers get — the Standard Webhooks recommended shape.\n * `type` is the event type name, `timestamp` the event-occurred time, and\n * `data` the published payload.\n */\nexport interface WebhookEnvelope {\n type: string;\n timestamp: string;\n data: JsonValue;\n}\n"],"mappings":";;;AAmCA,MAAa,iBAAiB;;AAiI9B,SAAgB,yBAAyB,QAAiC;CACxE,OAAO,WAAW,eAAe,WAAW;AAC9C"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { _ as WebhookEnvelope, a as AuditEntry, c as DeliveryStatus, d as EndpointSecret, f as EventType, g as WebhookDuration, h as SCHEMA_VERSION, i as AuditAction, l as Endpoint, m as Message, n as Application, o as Delivery, p as JsonValue, r as AttemptTrigger, s as DeliveryAttempt, t as Actor, u as EndpointDisabledReason, v as isTerminalDeliveryStatus } from "./schema-mo__wv4P.cjs";
|
|
2
|
+
export { Actor, Application, AttemptTrigger, AuditAction, AuditEntry, Delivery, DeliveryAttempt, DeliveryStatus, Endpoint, EndpointDisabledReason, EndpointSecret, EventType, JsonValue, Message, SCHEMA_VERSION, WebhookDuration, WebhookEnvelope, isTerminalDeliveryStatus };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { _ as WebhookEnvelope, a as AuditEntry, c as DeliveryStatus, d as EndpointSecret, f as EventType, g as WebhookDuration, h as SCHEMA_VERSION, i as AuditAction, l as Endpoint, m as Message, n as Application, o as Delivery, p as JsonValue, r as AttemptTrigger, s as DeliveryAttempt, t as Actor, u as EndpointDisabledReason, v as isTerminalDeliveryStatus } from "./schema-mo__wv4P.mjs";
|
|
2
|
+
export { Actor, Application, AttemptTrigger, AuditAction, AuditEntry, Delivery, DeliveryAttempt, DeliveryStatus, Endpoint, EndpointDisabledReason, EndpointSecret, EventType, JsonValue, Message, SCHEMA_VERSION, WebhookDuration, WebhookEnvelope, isTerminalDeliveryStatus };
|
package/dist/schema.mjs
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/schema.ts
|
|
2
|
+
/** Current schema version for stored records. */
|
|
3
|
+
const SCHEMA_VERSION = 1;
|
|
4
|
+
/** Guard: has this delivery reached a terminal state? */
|
|
5
|
+
function isTerminalDeliveryStatus(status) {
|
|
6
|
+
return status === "succeeded" || status === "failed";
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { SCHEMA_VERSION, isTerminalDeliveryStatus };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=schema.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.mjs","names":[],"sources":["../src/schema.ts"],"sourcesContent":["/**\n * Core type definitions for `@xtandard/webhooks`.\n *\n * This module is **types only** — no runtime code beyond tiny guards and the\n * schema-version constant, no dependencies. It is safe to import from the\n * publish hot path and the receiver. Runtime validation (which pulls in\n * `valibot`) lives in {@link ./validation}.\n *\n * @module\n */\n\n/** JSON-serializable value, used for payloads, metadata, and event-type schemas. */\nexport type JsonValue =\n | string\n | number\n | boolean\n | null\n | JsonValue[]\n | { [key: string]: JsonValue };\n\n/**\n * A duration for configuration options: either milliseconds as a number, or a\n * human-friendly string such as `\"5s\"`, `\"30m\"`, `\"2h\"`, `\"5d\"`. Parsed by\n * {@link ./duration.durationToMs}.\n */\nexport type WebhookDuration = number | `${number}${\"ms\" | \"s\" | \"m\" | \"h\" | \"d\"}`;\n\n/** Identity captured on audit records and passed by callers of audited mutations. */\nexport interface Actor {\n id: string;\n email?: string;\n name?: string;\n}\n\n/** Current schema version for stored records. */\nexport const SCHEMA_VERSION = 1 as const;\n\n/**\n * An application is the unit of tenancy — typically one of *your* customers.\n * Endpoints, messages, and deliveries are all scoped to an application, and a\n * portal token grants access to exactly one application.\n */\nexport interface Application {\n /** Unique key. Allowed characters: `a-z A-Z 0-9 . _ -`. */\n key: string;\n /** Optional human-friendly name shown in the UI. */\n name?: string;\n /** Arbitrary host-defined metadata. */\n metadata?: JsonValue;\n /** ISO-8601 creation timestamp, server-stamped. */\n createdAt?: string;\n /** ISO-8601 last-update timestamp, server-stamped. */\n updatedAt?: string;\n}\n\n/**\n * A named kind of event in the **global** catalog (shared by all applications),\n * e.g. `\"invoice.paid\"`. Endpoints subscribe to event types by name.\n */\nexport interface EventType {\n /** Unique dot-delimited name, e.g. `\"invoice.paid\"`. Allowed: `a-z A-Z 0-9 . _ -`. */\n name: string;\n /** Optional description shown in the UI and the public catalog. */\n description?: string;\n /** Optional UI grouping label (e.g. `\"Billing\"`). Purely presentational. */\n groupName?: string;\n /**\n * Optional JSON Schema describing the payload. Documentation by default;\n * enforced only when the core is configured with a `payloadValidator`.\n */\n schema?: JsonValue;\n /** Deprecated event types are flagged in the UI but still deliverable. */\n deprecated?: boolean;\n /** ISO-8601 creation timestamp, server-stamped. */\n createdAt?: string;\n /** ISO-8601 last-update timestamp, server-stamped. */\n updatedAt?: string;\n}\n\n/**\n * A signing secret attached to an endpoint. Secrets are `whsec_` + base64 per\n * the Standard Webhooks spec. Rotation keeps the previous secret verifiable\n * until `expiresAt` (the grace window); expired secrets are pruned lazily.\n */\nexport interface EndpointSecret {\n /** `\"whsec_\"` + base64-encoded random key material. */\n secret: string;\n /** ISO-8601 creation timestamp. */\n createdAt: string;\n /** Set when superseded by rotation; the secret stops signing after this instant. */\n expiresAt?: string;\n}\n\n/** Why an endpoint is disabled: by an operator, or by the auto-disable policy. */\nexport type EndpointDisabledReason = \"manual\" | \"auto\";\n\n/**\n * A customer-registered URL that receives deliveries for one application.\n */\nexport interface Endpoint {\n /** `\"ep_\"` + 22-char base62, server-generated. */\n id: string;\n /** Destination URL. `https` is enforced by default (`allowInsecureUrls` for dev). */\n url: string;\n /** Optional description shown in the UI. */\n description?: string;\n /**\n * Event type names this endpoint subscribes to. Empty or absent = receives\n * **all** event types.\n */\n eventTypes?: string[];\n /** Disabled endpoints receive no deliveries (pending ones are held, not failed). */\n disabled?: boolean;\n /** Who/what disabled it — an operator (`\"manual\"`) or the failure policy (`\"auto\"`). */\n disabledReason?: EndpointDisabledReason;\n /** Static extra headers merged into every delivery request. */\n headers?: Record<string, string>;\n /** Signing secrets. `[0]` is current; extras are still-verifiable rotation grace. */\n secrets: EndpointSecret[];\n /** Arbitrary host-defined metadata. */\n metadata?: JsonValue;\n /** ISO-8601 creation timestamp, server-stamped. */\n createdAt?: string;\n /** ISO-8601 last-update timestamp, server-stamped. */\n updatedAt?: string;\n /**\n * Start of the current unbroken failure streak (any successful delivery\n * clears it). Drives the auto-disable policy.\n */\n firstFailingAt?: string | null;\n}\n\n/**\n * A published event for one application. The message is the receiver-facing\n * unit: its id is the `webhook-id` header (stable across retries — receivers\n * dedupe on it), and its payload is the `data` of the wire envelope.\n */\nexport interface Message {\n /** `\"msg_\"` + 22-char base62, server-generated. Sent as `webhook-id`. */\n id: string;\n /** Event type name (usually from the global catalog). */\n eventType: string;\n /** The `data` of the wire envelope. */\n payload: JsonValue;\n /** ISO-8601 event-occurred time (defaults to publish time). Sent in the envelope. */\n timestamp: string;\n /** Optional caller-supplied dedupe key; same key within retention returns the same message. */\n idempotencyKey?: string;\n /**\n * The wire envelope serialized **once at publish time** so the signed bytes\n * are identical across every retry of every delivery.\n */\n envelope: string;\n /** ISO-8601 creation timestamp, server-stamped. */\n createdAt: string;\n}\n\n/**\n * Delivery lifecycle. `\"failed\"` means the retry schedule is exhausted — the\n * dead-letter state. A manual retry moves a failed delivery back to `\"pending\"`.\n */\nexport type DeliveryStatus = \"pending\" | \"delivering\" | \"succeeded\" | \"failed\";\n\n/** Guard: has this delivery reached a terminal state? */\nexport function isTerminalDeliveryStatus(status: DeliveryStatus): boolean {\n return status === \"succeeded\" || status === \"failed\";\n}\n\n/**\n * One message × one endpoint. Created at publish time (fan-out) and driven to\n * a terminal state by the dispatcher.\n */\nexport interface Delivery {\n /** `\"dlv_\"` + 22-char base62, server-generated. */\n id: string;\n /** The application this delivery belongs to (deliveries cross the dispatcher denormalized). */\n applicationKey: string;\n messageId: string;\n endpointId: string;\n status: DeliveryStatus;\n /** Number of attempts made so far. */\n attemptCount: number;\n /** When the next attempt is due. `null` once terminal. */\n nextAttemptAt?: string | null;\n /** Dispatcher claim expiry; an expired lease makes the delivery reclaimable. */\n leaseUntil?: string | null;\n /**\n * How the *next* attempt should be recorded: set to `\"manual\"` by\n * retry/recover so the resulting attempt is attributed correctly, then\n * cleared. Absent = `\"schedule\"`.\n */\n pendingTrigger?: AttemptTrigger;\n /** ISO-8601 creation timestamp. */\n createdAt: string;\n /** ISO-8601 last-transition timestamp. */\n updatedAt: string;\n}\n\n/** What initiated a delivery attempt. */\nexport type AttemptTrigger = \"schedule\" | \"manual\" | \"test\";\n\n/** The recorded outcome of a single HTTP delivery attempt. */\nexport interface DeliveryAttempt {\n /** `\"atp_\"` + 22-char base62, server-generated. */\n id: string;\n deliveryId: string;\n /** 1-based attempt ordinal within the delivery. */\n attemptNumber: number;\n /** ISO-8601 timestamp of the attempt. */\n at: string;\n /** Wall-clock duration of the HTTP round trip. */\n durationMs: number;\n /** True when the receiver answered 2xx. */\n ok: boolean;\n /** HTTP status code; absent on network error or timeout. */\n httpStatus?: number;\n /** Truncated error message on network error/timeout. */\n error?: string;\n /** Truncated response body (default cap 4096 chars). */\n responseBody?: string;\n /** What initiated this attempt. */\n trigger: AttemptTrigger;\n}\n\n/** Actions recorded in the control-plane audit log. */\nexport type AuditAction =\n | \"application.create\"\n | \"application.update\"\n | \"application.delete\"\n | \"event-type.create\"\n | \"event-type.update\"\n | \"event-type.delete\"\n | \"endpoint.create\"\n | \"endpoint.update\"\n | \"endpoint.delete\"\n | \"endpoint.rotate-secret\"\n | \"endpoint.disable\"\n | \"endpoint.enable\"\n | \"delivery.retry\"\n | \"endpoint.recover\";\n\n/**\n * A single control-plane audit record. Publishes are deliberately *not*\n * audited — they are data-plane traffic, and the message log is their record.\n */\nexport interface AuditEntry {\n action: AuditAction;\n /** ISO-8601 timestamp. */\n at: string;\n by?: Actor | null;\n /** The application the action was scoped to (absent for global event types). */\n applicationKey?: string;\n /** Endpoint id / event type name / delivery id the action targeted. */\n subjectId?: string;\n message?: string;\n}\n\n/**\n * The wire envelope receivers get — the Standard Webhooks recommended shape.\n * `type` is the event type name, `timestamp` the event-occurred time, and\n * `data` the published payload.\n */\nexport interface WebhookEnvelope {\n type: string;\n timestamp: string;\n data: JsonValue;\n}\n"],"mappings":";;AAmCA,MAAa,iBAAiB;;AAiI9B,SAAgB,yBAAyB,QAAiC;CACxE,OAAO,WAAW,eAAe,WAAW;AAC9C"}
|