@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.
Files changed (279) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +315 -0
  3. package/bin/xtandard-webhooks.mjs +3 -0
  4. package/dist/basic-BIW3Rvuz.cjs +199 -0
  5. package/dist/basic-BIW3Rvuz.cjs.map +1 -0
  6. package/dist/basic-DKk0Xfuu.mjs +176 -0
  7. package/dist/basic-DKk0Xfuu.mjs.map +1 -0
  8. package/dist/chunk-D7D4PA-g.mjs +13 -0
  9. package/dist/cli.cjs +655 -0
  10. package/dist/cli.cjs.map +1 -0
  11. package/dist/cli.d.cts +42 -0
  12. package/dist/cli.d.mts +42 -0
  13. package/dist/cli.mjs +653 -0
  14. package/dist/cli.mjs.map +1 -0
  15. package/dist/contract-8h-Azxa5.d.cts +71 -0
  16. package/dist/contract-9XpcwcCn.mjs +22 -0
  17. package/dist/contract-9XpcwcCn.mjs.map +1 -0
  18. package/dist/contract-B2d5dNU3.cjs +33 -0
  19. package/dist/contract-B2d5dNU3.cjs.map +1 -0
  20. package/dist/contract-BEhDcd_5.mjs +28 -0
  21. package/dist/contract-BEhDcd_5.mjs.map +1 -0
  22. package/dist/contract-Bf1qguwt.cjs +57 -0
  23. package/dist/contract-Bf1qguwt.cjs.map +1 -0
  24. package/dist/contract-Bnb3fgRJ.d.cts +177 -0
  25. package/dist/contract-C2r2Xzwp.d.mts +46 -0
  26. package/dist/contract-CiPskNvS.d.cts +46 -0
  27. package/dist/contract-DhQ4JjGG.d.mts +71 -0
  28. package/dist/contract-T1kcZNdG.d.mts +177 -0
  29. package/dist/contract-lETlIuXo.d.cts +30 -0
  30. package/dist/contract-lETlIuXo.d.mts +30 -0
  31. package/dist/core-CMpnmI5Q.mjs +1605 -0
  32. package/dist/core-CMpnmI5Q.mjs.map +1 -0
  33. package/dist/core-DT4ppWh8.d.mts +502 -0
  34. package/dist/core-KJawHjFF.d.cts +502 -0
  35. package/dist/core-ZGhH6Vs2.cjs +1790 -0
  36. package/dist/core-ZGhH6Vs2.cjs.map +1 -0
  37. package/dist/core.cjs +8 -0
  38. package/dist/core.d.cts +2 -0
  39. package/dist/core.d.mts +2 -0
  40. package/dist/core.mjs +2 -0
  41. package/dist/create-fetch-handler-BIdk9P30.mjs +1724 -0
  42. package/dist/create-fetch-handler-BIdk9P30.mjs.map +1 -0
  43. package/dist/create-fetch-handler-CmooujQo.cjs +1771 -0
  44. package/dist/create-fetch-handler-CmooujQo.cjs.map +1 -0
  45. package/dist/create-fetch-handler-Dlkhustu.d.cts +162 -0
  46. package/dist/create-fetch-handler-jy3hy5nZ.d.mts +162 -0
  47. package/dist/dispatcher-B0xTEHt1.cjs +212 -0
  48. package/dist/dispatcher-B0xTEHt1.cjs.map +1 -0
  49. package/dist/dispatcher-Coubwrka.mjs +196 -0
  50. package/dist/dispatcher-Coubwrka.mjs.map +1 -0
  51. package/dist/entry-auth-basic.cjs +5 -0
  52. package/dist/entry-auth-basic.d.cts +83 -0
  53. package/dist/entry-auth-basic.d.mts +83 -0
  54. package/dist/entry-auth-basic.mjs +2 -0
  55. package/dist/entry-auth-delegated.cjs +28 -0
  56. package/dist/entry-auth-delegated.cjs.map +1 -0
  57. package/dist/entry-auth-delegated.d.cts +36 -0
  58. package/dist/entry-auth-delegated.d.mts +36 -0
  59. package/dist/entry-auth-delegated.mjs +27 -0
  60. package/dist/entry-auth-delegated.mjs.map +1 -0
  61. package/dist/entry-auth-none.cjs +4 -0
  62. package/dist/entry-auth-none.d.cts +25 -0
  63. package/dist/entry-auth-none.d.mts +25 -0
  64. package/dist/entry-auth-none.mjs +2 -0
  65. package/dist/entry-authorization-delegated.cjs +27 -0
  66. package/dist/entry-authorization-delegated.cjs.map +1 -0
  67. package/dist/entry-authorization-delegated.d.cts +31 -0
  68. package/dist/entry-authorization-delegated.d.mts +31 -0
  69. package/dist/entry-authorization-delegated.mjs +26 -0
  70. package/dist/entry-authorization-delegated.mjs.map +1 -0
  71. package/dist/entry-authorization-none.cjs +3 -0
  72. package/dist/entry-authorization-none.d.cts +18 -0
  73. package/dist/entry-authorization-none.d.mts +18 -0
  74. package/dist/entry-authorization-none.mjs +2 -0
  75. package/dist/entry-authorization-roles.cjs +6 -0
  76. package/dist/entry-authorization-roles.d.cts +65 -0
  77. package/dist/entry-authorization-roles.d.mts +65 -0
  78. package/dist/entry-authorization-roles.mjs +2 -0
  79. package/dist/entry-bun.cjs +24 -0
  80. package/dist/entry-bun.cjs.map +1 -0
  81. package/dist/entry-bun.d.cts +8 -0
  82. package/dist/entry-bun.d.mts +8 -0
  83. package/dist/entry-bun.mjs +23 -0
  84. package/dist/entry-bun.mjs.map +1 -0
  85. package/dist/entry-drizzle-mysql.cjs +20 -0
  86. package/dist/entry-drizzle-mysql.cjs.map +1 -0
  87. package/dist/entry-drizzle-mysql.d.cts +27 -0
  88. package/dist/entry-drizzle-mysql.d.mts +27 -0
  89. package/dist/entry-drizzle-mysql.mjs +19 -0
  90. package/dist/entry-drizzle-mysql.mjs.map +1 -0
  91. package/dist/entry-drizzle-pg.cjs +21 -0
  92. package/dist/entry-drizzle-pg.cjs.map +1 -0
  93. package/dist/entry-drizzle-pg.d.cts +26 -0
  94. package/dist/entry-drizzle-pg.d.mts +26 -0
  95. package/dist/entry-drizzle-pg.mjs +20 -0
  96. package/dist/entry-drizzle-pg.mjs.map +1 -0
  97. package/dist/entry-drizzle-sqlite.cjs +21 -0
  98. package/dist/entry-drizzle-sqlite.cjs.map +1 -0
  99. package/dist/entry-drizzle-sqlite.d.cts +23 -0
  100. package/dist/entry-drizzle-sqlite.d.mts +23 -0
  101. package/dist/entry-drizzle-sqlite.mjs +20 -0
  102. package/dist/entry-drizzle-sqlite.mjs.map +1 -0
  103. package/dist/entry-elysia.cjs +125 -0
  104. package/dist/entry-elysia.cjs.map +1 -0
  105. package/dist/entry-elysia.d.cts +1017 -0
  106. package/dist/entry-elysia.d.mts +1017 -0
  107. package/dist/entry-elysia.mjs +123 -0
  108. package/dist/entry-elysia.mjs.map +1 -0
  109. package/dist/entry-express.cjs +57 -0
  110. package/dist/entry-express.cjs.map +1 -0
  111. package/dist/entry-express.d.cts +15 -0
  112. package/dist/entry-express.d.mts +15 -0
  113. package/dist/entry-express.mjs +56 -0
  114. package/dist/entry-express.mjs.map +1 -0
  115. package/dist/entry-hono.cjs +35 -0
  116. package/dist/entry-hono.cjs.map +1 -0
  117. package/dist/entry-hono.d.cts +16 -0
  118. package/dist/entry-hono.d.mts +16 -0
  119. package/dist/entry-hono.mjs +34 -0
  120. package/dist/entry-hono.mjs.map +1 -0
  121. package/dist/entry-hooks-log.cjs +22 -0
  122. package/dist/entry-hooks-log.cjs.map +1 -0
  123. package/dist/entry-hooks-log.d.cts +23 -0
  124. package/dist/entry-hooks-log.d.mts +23 -0
  125. package/dist/entry-hooks-log.mjs +21 -0
  126. package/dist/entry-hooks-log.mjs.map +1 -0
  127. package/dist/entry-storage-cloudflare-kv.cjs +47 -0
  128. package/dist/entry-storage-cloudflare-kv.cjs.map +1 -0
  129. package/dist/entry-storage-cloudflare-kv.d.cts +42 -0
  130. package/dist/entry-storage-cloudflare-kv.d.mts +42 -0
  131. package/dist/entry-storage-cloudflare-kv.mjs +46 -0
  132. package/dist/entry-storage-cloudflare-kv.mjs.map +1 -0
  133. package/dist/entry-storage-drizzle.cjs +78 -0
  134. package/dist/entry-storage-drizzle.cjs.map +1 -0
  135. package/dist/entry-storage-drizzle.d.cts +30 -0
  136. package/dist/entry-storage-drizzle.d.mts +30 -0
  137. package/dist/entry-storage-drizzle.mjs +77 -0
  138. package/dist/entry-storage-drizzle.mjs.map +1 -0
  139. package/dist/entry-storage-file.cjs +4 -0
  140. package/dist/entry-storage-file.d.cts +30 -0
  141. package/dist/entry-storage-file.d.mts +30 -0
  142. package/dist/entry-storage-file.mjs +2 -0
  143. package/dist/entry-storage-libsql.cjs +3 -0
  144. package/dist/entry-storage-libsql.d.cts +48 -0
  145. package/dist/entry-storage-libsql.d.mts +48 -0
  146. package/dist/entry-storage-libsql.mjs +2 -0
  147. package/dist/entry-storage-memory.cjs +3 -0
  148. package/dist/entry-storage-memory.d.cts +2 -0
  149. package/dist/entry-storage-memory.d.mts +2 -0
  150. package/dist/entry-storage-memory.mjs +2 -0
  151. package/dist/entry-storage-mongodb.cjs +3 -0
  152. package/dist/entry-storage-mongodb.d.cts +55 -0
  153. package/dist/entry-storage-mongodb.d.mts +55 -0
  154. package/dist/entry-storage-mongodb.mjs +2 -0
  155. package/dist/entry-storage-postgres.cjs +3 -0
  156. package/dist/entry-storage-postgres.d.cts +62 -0
  157. package/dist/entry-storage-postgres.d.mts +62 -0
  158. package/dist/entry-storage-postgres.mjs +2 -0
  159. package/dist/entry-storage-redis.cjs +4 -0
  160. package/dist/entry-storage-redis.d.cts +77 -0
  161. package/dist/entry-storage-redis.d.mts +77 -0
  162. package/dist/entry-storage-redis.mjs +2 -0
  163. package/dist/entry-storage-sqlite.cjs +3 -0
  164. package/dist/entry-storage-sqlite.d.cts +36 -0
  165. package/dist/entry-storage-sqlite.d.mts +36 -0
  166. package/dist/entry-storage-sqlite.mjs +2 -0
  167. package/dist/entry-storage-unstorage.cjs +42 -0
  168. package/dist/entry-storage-unstorage.cjs.map +1 -0
  169. package/dist/entry-storage-unstorage.d.cts +29 -0
  170. package/dist/entry-storage-unstorage.d.mts +29 -0
  171. package/dist/entry-storage-unstorage.mjs +41 -0
  172. package/dist/entry-storage-unstorage.mjs.map +1 -0
  173. package/dist/file-COBYZA4Q.cjs +148 -0
  174. package/dist/file-COBYZA4Q.cjs.map +1 -0
  175. package/dist/file-fi02eFHk.mjs +131 -0
  176. package/dist/file-fi02eFHk.mjs.map +1 -0
  177. package/dist/index.cjs +123 -0
  178. package/dist/index.cjs.map +1 -0
  179. package/dist/index.d.cts +368 -0
  180. package/dist/index.d.mts +366 -0
  181. package/dist/index.mjs +61 -0
  182. package/dist/index.mjs.map +1 -0
  183. package/dist/keys-Byyj4quQ.mjs +111 -0
  184. package/dist/keys-Byyj4quQ.mjs.map +1 -0
  185. package/dist/keys-FiKpaVHX.cjs +302 -0
  186. package/dist/keys-FiKpaVHX.cjs.map +1 -0
  187. package/dist/libsql-bpVi0bXN.mjs +113 -0
  188. package/dist/libsql-bpVi0bXN.mjs.map +1 -0
  189. package/dist/libsql-pPJEo1e4.cjs +124 -0
  190. package/dist/libsql-pPJEo1e4.cjs.map +1 -0
  191. package/dist/memory-8Ef-PL5a.cjs +137 -0
  192. package/dist/memory-8Ef-PL5a.cjs.map +1 -0
  193. package/dist/memory-BMsSSwqn.mjs +127 -0
  194. package/dist/memory-BMsSSwqn.mjs.map +1 -0
  195. package/dist/memory-FnMJWCmB.d.cts +28 -0
  196. package/dist/memory-qIvANEs_.d.mts +28 -0
  197. package/dist/mongodb-Cy8yo0uk.cjs +108 -0
  198. package/dist/mongodb-Cy8yo0uk.cjs.map +1 -0
  199. package/dist/mongodb-Ddaq9mml.mjs +97 -0
  200. package/dist/mongodb-Ddaq9mml.mjs.map +1 -0
  201. package/dist/none-BnZtaGNJ.mjs +23 -0
  202. package/dist/none-BnZtaGNJ.mjs.map +1 -0
  203. package/dist/none-CAsxCOWN.cjs +49 -0
  204. package/dist/none-CAsxCOWN.cjs.map +1 -0
  205. package/dist/none-CZVrfnmF.cjs +33 -0
  206. package/dist/none-CZVrfnmF.cjs.map +1 -0
  207. package/dist/none-GhVIoh_s.mjs +33 -0
  208. package/dist/none-GhVIoh_s.mjs.map +1 -0
  209. package/dist/postgres-C8WbchFa.cjs +134 -0
  210. package/dist/postgres-C8WbchFa.cjs.map +1 -0
  211. package/dist/postgres-c3pAhmhr.mjs +123 -0
  212. package/dist/postgres-c3pAhmhr.mjs.map +1 -0
  213. package/dist/react.css +1 -0
  214. package/dist/react.js +31465 -0
  215. package/dist/receiver.cjs +43 -0
  216. package/dist/receiver.cjs.map +1 -0
  217. package/dist/receiver.d.cts +36 -0
  218. package/dist/receiver.d.mts +36 -0
  219. package/dist/receiver.mjs +40 -0
  220. package/dist/receiver.mjs.map +1 -0
  221. package/dist/redis-CFJkuSgB.cjs +270 -0
  222. package/dist/redis-CFJkuSgB.cjs.map +1 -0
  223. package/dist/redis-CvLi0KF7.mjs +254 -0
  224. package/dist/redis-CvLi0KF7.mjs.map +1 -0
  225. package/dist/roles-D0G9XqBq.cjs +128 -0
  226. package/dist/roles-D0G9XqBq.cjs.map +1 -0
  227. package/dist/roles-vp361lTk.mjs +99 -0
  228. package/dist/roles-vp361lTk.mjs.map +1 -0
  229. package/dist/schema-mo__wv4P.d.cts +233 -0
  230. package/dist/schema-mo__wv4P.d.mts +233 -0
  231. package/dist/schema.cjs +13 -0
  232. package/dist/schema.cjs.map +1 -0
  233. package/dist/schema.d.cts +2 -0
  234. package/dist/schema.d.mts +2 -0
  235. package/dist/schema.mjs +11 -0
  236. package/dist/schema.mjs.map +1 -0
  237. package/dist/signing.cjs +162 -0
  238. package/dist/signing.cjs.map +1 -0
  239. package/dist/signing.d.cts +73 -0
  240. package/dist/signing.d.mts +73 -0
  241. package/dist/signing.mjs +156 -0
  242. package/dist/signing.mjs.map +1 -0
  243. package/dist/sqlite-Cmqnrjes.mjs +67 -0
  244. package/dist/sqlite-Cmqnrjes.mjs.map +1 -0
  245. package/dist/sqlite-Dcufk0x3.cjs +78 -0
  246. package/dist/sqlite-Dcufk0x3.cjs.map +1 -0
  247. package/dist/table-Ce3Tzwqs.d.cts +11 -0
  248. package/dist/table-Ce3Tzwqs.d.mts +11 -0
  249. package/dist/testing.cjs +134 -0
  250. package/dist/testing.cjs.map +1 -0
  251. package/dist/testing.d.cts +80 -0
  252. package/dist/testing.d.mts +80 -0
  253. package/dist/testing.mjs +131 -0
  254. package/dist/testing.mjs.map +1 -0
  255. package/dist/types-react/react.d.ts +98 -0
  256. package/dist/types-react/schema.d.ts +229 -0
  257. package/dist/types-react/ui/App.d.ts +22 -0
  258. package/dist/types-react/ui/api.d.ts +97 -0
  259. package/dist/types-react/ui/components/JsonCodeEditor.d.ts +12 -0
  260. package/dist/types-react/ui/components/ThemeToggle.d.ts +2 -0
  261. package/dist/types-react/ui/components/Toast.d.ts +16 -0
  262. package/dist/types-react/ui/components/primitives.d.ts +50 -0
  263. package/dist/types-react/ui/components/ui-bits.d.ts +22 -0
  264. package/dist/types-react/ui/components/webhook-bits.d.ts +51 -0
  265. package/dist/types-react/ui/lib/format.d.ts +39 -0
  266. package/dist/types-react/ui/lib/nav-guard.d.ts +20 -0
  267. package/dist/types-react/ui/lib/utils.d.ts +3 -0
  268. package/dist/types-react/ui/theme.d.ts +12 -0
  269. package/dist/types-react/ui/types.d.ts +80 -0
  270. package/dist/types-react/ui/views/AuditView.d.ts +6 -0
  271. package/dist/types-react/ui/views/DeliveriesView.d.ts +12 -0
  272. package/dist/types-react/ui/views/EndpointsView.d.ts +11 -0
  273. package/dist/types-react/ui/views/EventTypesView.d.ts +11 -0
  274. package/dist/types-react/ui/views/MessagesView.d.ts +10 -0
  275. package/dist/types-react/ui/views/OverviewView.d.ts +12 -0
  276. package/dist/ui/assets/index-B0eoQX2U.css +1 -0
  277. package/dist/ui/assets/index-S5t_CLOe.js +209 -0
  278. package/dist/ui/index.html +14 -0
  279. package/package.json +487 -0
@@ -0,0 +1,46 @@
1
+ import { n as Principal } from "./contract-lETlIuXo.cjs";
2
+
3
+ //#region src/authorization/contract.d.ts
4
+ /** The full set of authorizable actions. */
5
+ type WebhooksAction = "application:read" | "application:create" | "application:update" | "application:delete" | "event-type:read" | "event-type:create" | "event-type:update" | "event-type:delete" | "endpoint:read" | "endpoint:create" | "endpoint:update" | "endpoint:delete" | "endpoint:rotate-secret" | "endpoint:read-secret" | "message:read" | "message:publish" | "delivery:read" | "delivery:retry" | "audit:read";
6
+ /** The resource an action targets. */
7
+ type WebhooksResource = {
8
+ type: "application";
9
+ applicationKey: string;
10
+ } | {
11
+ type: "event-type";
12
+ name: string;
13
+ } | {
14
+ type: "endpoint";
15
+ applicationKey: string;
16
+ endpointId: string;
17
+ } | {
18
+ type: "message";
19
+ applicationKey: string;
20
+ messageId?: string;
21
+ } | {
22
+ type: "delivery";
23
+ applicationKey: string;
24
+ deliveryId?: string;
25
+ } | {
26
+ type: "audit";
27
+ applicationKey?: string;
28
+ };
29
+ /** Input passed to {@link AuthorizationProvider.authorize}. */
30
+ interface AuthorizeInput {
31
+ principal: Principal | null;
32
+ action: WebhooksAction;
33
+ resource: WebhooksResource;
34
+ request: Request;
35
+ }
36
+ /** Decides whether an action is permitted. */
37
+ interface AuthorizationProvider {
38
+ authorize(input: AuthorizeInput): Promise<boolean>;
39
+ }
40
+ /** Actions that mutate state — blocked in readonly mode. */
41
+ declare const MUTATING_ACTIONS: ReadonlySet<WebhooksAction>;
42
+ /** True if the action mutates state. */
43
+ declare const isMutatingAction: (action: WebhooksAction) => boolean;
44
+ //#endregion
45
+ export { WebhooksResource as a, WebhooksAction as i, AuthorizeInput as n, isMutatingAction as o, MUTATING_ACTIONS as r, AuthorizationProvider as t };
46
+ //# sourceMappingURL=contract-CiPskNvS.d.cts.map
@@ -0,0 +1,71 @@
1
+ import { o as Delivery } from "./schema-mo__wv4P.mjs";
2
+
3
+ //#region src/storage/contract.d.ts
4
+ /** The minimal key/value contract every storage backend must satisfy. */
5
+ interface WebhooksStorage {
6
+ /** Read a value, or `null` if absent. */
7
+ getItem<T>(key: string): Promise<T | null>;
8
+ /** Write a value (overwriting any existing). */
9
+ setItem<T>(key: string, value: T): Promise<void>;
10
+ /** Delete a key (no-op if absent). */
11
+ removeItem(key: string): Promise<void>;
12
+ /** List all keys beginning with `prefix`. */
13
+ getKeys(prefix: string): Promise<string[]>;
14
+ }
15
+ /** A storage change event delivered to {@link WatchableWebhooksStorage.watch} callbacks. */
16
+ interface StorageChangeEvent {
17
+ type: "update" | "remove";
18
+ key: string;
19
+ }
20
+ /** Storage that can push change notifications (e.g. Redis pub/sub, fs.watch). */
21
+ interface WatchableWebhooksStorage extends WebhooksStorage {
22
+ /**
23
+ * Subscribe to changes under `prefix`. Resolves to an unsubscribe function.
24
+ */
25
+ watch(prefix: string, callback: (event: StorageChangeEvent) => void): Promise<() => void>;
26
+ }
27
+ /** Storage that supports atomic multi-key transactions. */
28
+ interface TransactionalWebhooksStorage extends WebhooksStorage {
29
+ transaction<T>(callback: (tx: WebhooksStorage) => Promise<T>): Promise<T>;
30
+ }
31
+ /** Storage that supports optimistic concurrency via compare-and-swap. */
32
+ interface CompareAndSwapWebhooksStorage extends WebhooksStorage {
33
+ compareAndSwap<T>(input: {
34
+ key: string;
35
+ expected: T | null;
36
+ next: T;
37
+ }): Promise<boolean>;
38
+ }
39
+ /**
40
+ * Storage that can natively claim due deliveries (sorted-set / `SKIP LOCKED`
41
+ * class backends). When present, the dispatcher delegates claiming entirely to
42
+ * the adapter instead of scanning the generic due index.
43
+ *
44
+ * The claim contract: atomically transition each returned delivery to
45
+ * `status: "delivering"` with `leaseUntil = now + leaseMs`, reposition its due
46
+ * entry at the lease expiry (so a crashed claimer's work re-surfaces), and
47
+ * never return the same delivery to two concurrent claimers.
48
+ */
49
+ interface DeliveryQueueStorage extends WebhooksStorage {
50
+ claimDue(input: {
51
+ now: string;
52
+ limit: number;
53
+ leaseMs: number;
54
+ }): Promise<Delivery[]>;
55
+ }
56
+ /** Runtime feature-detection: does this storage implement `watch`? */
57
+ declare function isWatchable(storage: WebhooksStorage): storage is WatchableWebhooksStorage;
58
+ /** Runtime feature-detection: does this storage implement `transaction`? */
59
+ declare function isTransactional(storage: WebhooksStorage): storage is TransactionalWebhooksStorage;
60
+ /** Runtime feature-detection: does this storage implement `compareAndSwap`? */
61
+ declare function isCompareAndSwap(storage: WebhooksStorage): storage is CompareAndSwapWebhooksStorage;
62
+ /** Runtime feature-detection: does this storage implement `claimDue`? */
63
+ declare function hasDeliveryQueue(storage: WebhooksStorage): storage is DeliveryQueueStorage;
64
+ /**
65
+ * Helper for adapters whose subpath requires an optional peer dependency. Throws
66
+ * a clear, actionable error when the peer is missing.
67
+ */
68
+ declare function requirePeer(name: string, subpath: string): never;
69
+ //#endregion
70
+ export { WatchableWebhooksStorage as a, isCompareAndSwap as c, requirePeer as d, TransactionalWebhooksStorage as i, isTransactional as l, DeliveryQueueStorage as n, WebhooksStorage as o, StorageChangeEvent as r, hasDeliveryQueue as s, CompareAndSwapWebhooksStorage as t, isWatchable as u };
71
+ //# sourceMappingURL=contract-DhQ4JjGG.d.mts.map
@@ -0,0 +1,177 @@
1
+ import { a as AuditEntry, f as EventType, l as Endpoint, m as Message, n as Application, o as Delivery, p as JsonValue, s as DeliveryAttempt, t as Actor } from "./schema-mo__wv4P.mjs";
2
+
3
+ //#region src/hooks/contract.d.ts
4
+ /**
5
+ * Event delivered to {@link WebhooksHooks.before} — the *proposed* mutation,
6
+ * before it commits. Throw from the handler to deny it.
7
+ */
8
+ type BeforeEvent = {
9
+ type: "application.create" | "application.update";
10
+ application: Application;
11
+ actor: Actor | null;
12
+ } | {
13
+ type: "application.delete";
14
+ applicationKey: string;
15
+ actor: Actor | null;
16
+ } | {
17
+ type: "event-type.upsert";
18
+ eventType: EventType;
19
+ actor: Actor | null;
20
+ } | {
21
+ type: "event-type.delete";
22
+ name: string;
23
+ actor: Actor | null;
24
+ } | {
25
+ type: "endpoint.create" | "endpoint.update";
26
+ applicationKey: string;
27
+ endpoint: Endpoint;
28
+ actor: Actor | null;
29
+ } | {
30
+ type: "endpoint.delete" | "endpoint.rotate-secret" | "endpoint.disable" | "endpoint.enable";
31
+ applicationKey: string;
32
+ endpointId: string;
33
+ actor: Actor | null;
34
+ } | {
35
+ /** The host's approval/quota gate for the publish hot path. */type: "message.publish";
36
+ applicationKey: string;
37
+ eventType: string;
38
+ payload: JsonValue;
39
+ idempotencyKey?: string;
40
+ actor: Actor | null;
41
+ } | {
42
+ type: "delivery.retry";
43
+ applicationKey: string;
44
+ deliveryId: string;
45
+ actor: Actor | null;
46
+ } | {
47
+ type: "endpoint.recover";
48
+ applicationKey: string;
49
+ endpointId: string;
50
+ since: string;
51
+ actor: Actor | null;
52
+ };
53
+ /**
54
+ * Event delivered to {@link WebhooksHooks.after} — the *committed* mutation.
55
+ * Carries the resulting state in full: for destructive events this is the last
56
+ * chance to offload the payload before it is gone from storage.
57
+ */
58
+ type AfterEvent = {
59
+ type: "application.created" | "application.updated";
60
+ application: Application;
61
+ at: string;
62
+ } | {
63
+ /** Carries the deleted application — everything under it is already gone. */type: "application.deleted";
64
+ applicationKey: string;
65
+ application: Application;
66
+ at: string;
67
+ } | {
68
+ type: "event-type.upserted";
69
+ eventType: EventType;
70
+ at: string;
71
+ } | {
72
+ type: "event-type.deleted";
73
+ name: string;
74
+ eventType: EventType;
75
+ at: string;
76
+ } | {
77
+ type: "endpoint.created" | "endpoint.updated" | "endpoint.deleted" | "endpoint.secret-rotated" | "endpoint.disabled" | "endpoint.enabled" /** Disabled by the failure policy, not an operator (see dispatcher `autoDisable`). */ | "endpoint.auto-disabled";
78
+ applicationKey: string;
79
+ endpoint: Endpoint;
80
+ at: string;
81
+ } | {
82
+ type: "message.published";
83
+ applicationKey: string;
84
+ message: Message;
85
+ deliveryIds: string[];
86
+ at: string;
87
+ } | {
88
+ type: "delivery.succeeded";
89
+ applicationKey: string;
90
+ delivery: Delivery;
91
+ attempt: DeliveryAttempt;
92
+ at: string;
93
+ } | {
94
+ /** Dead-letter offload point: the retry schedule is exhausted. */type: "delivery.exhausted";
95
+ applicationKey: string;
96
+ delivery: Delivery;
97
+ attempts: DeliveryAttempt[];
98
+ at: string;
99
+ } | {
100
+ /** Messages removed by retention. Carries the **full messages** — offload now or lose them. */type: "message.pruned";
101
+ applicationKey: string;
102
+ messages: Message[];
103
+ at: string;
104
+ } | {
105
+ /** Audit entries removed by retention (oldest-first). */type: "audit.pruned";
106
+ applicationKey?: string;
107
+ entries: AuditEntry[];
108
+ at: string;
109
+ };
110
+ /** The discriminant strings of {@link BeforeEvent} / {@link AfterEvent}. */
111
+ type BeforeEventType = BeforeEvent["type"];
112
+ type AfterEventType = AfterEvent["type"];
113
+ /**
114
+ * Thrown from a {@link WebhooksHooks.before} handler to **deny** a mutation with
115
+ * a clean HTTP status (default `403`). Any thrown error denies the mutation,
116
+ * but a plain `Error` maps to `500` at the API layer (treated as an unexpected
117
+ * bug); throw this to signal a deliberate policy rejection (`403`, or a custom
118
+ * `status` such as `409`/`422`).
119
+ *
120
+ * @example
121
+ * ```ts
122
+ * before(event) {
123
+ * if (event.type === "message.publish" && overQuota(event.applicationKey)) {
124
+ * throw new HookDeniedError("Monthly webhook quota exceeded.", { status: 429 });
125
+ * }
126
+ * }
127
+ * ```
128
+ */
129
+ declare class HookDeniedError extends Error {
130
+ /** HTTP status the API layer should respond with. Default `403`. */
131
+ readonly status: number;
132
+ constructor(message: string, options?: {
133
+ status?: number;
134
+ cause?: unknown;
135
+ });
136
+ }
137
+ /**
138
+ * A control-plane hook. Implement `before`, `after`, or both. Pass one — or an
139
+ * array — to {@link ../core.createWebhooksCore} via `hooks`.
140
+ */
141
+ interface WebhooksHooks {
142
+ /**
143
+ * Runs before a mutation commits. **Throw to deny** (the error propagates to
144
+ * the caller; its message is the reason). Return/resolve to allow. Must not
145
+ * mutate the event payload.
146
+ */
147
+ before?(event: BeforeEvent): void | Promise<void>;
148
+ /**
149
+ * Runs after a mutation commits. For side effects only. Errors are isolated
150
+ * and reported via `onHookError` — they never fail the (already committed)
151
+ * operation.
152
+ */
153
+ after?(event: AfterEvent): void | Promise<void>;
154
+ }
155
+ /** Accepts a single hook, an array, or nothing. */
156
+ type WebhooksHooksInput = WebhooksHooks | readonly WebhooksHooks[] | undefined;
157
+ /** Reports an error thrown by an `after` hook. */
158
+ type HookErrorReporter = (error: unknown, event: AfterEvent) => void;
159
+ /** Normalize the `hooks` option into a flat array (empty when unset). */
160
+ declare function normalizeHooks(input: WebhooksHooksInput): WebhooksHooks[];
161
+ /**
162
+ * Run every `before` hook sequentially, in order. The first hook to throw
163
+ * aborts: the error propagates to the caller (denying the mutation) and no
164
+ * later hook runs. A no-op when there are no `before` hooks.
165
+ */
166
+ declare function runBefore(hooks: WebhooksHooks[], event: BeforeEvent): Promise<void>;
167
+ /**
168
+ * Run every `after` hook, isolating failures. The mutation has already
169
+ * committed, so a throwing hook must not fail the operation — its error is
170
+ * routed to `onError` and swallowed. Remaining hooks still run.
171
+ */
172
+ declare function runAfter(hooks: WebhooksHooks[], event: AfterEvent, onError: HookErrorReporter): Promise<void>;
173
+ /** Default `after`-hook error reporter: warn, but never throw. */
174
+ declare const defaultHookErrorReporter: HookErrorReporter;
175
+ //#endregion
176
+ export { HookDeniedError as a, WebhooksHooksInput as c, runAfter as d, runBefore as f, BeforeEventType as i, defaultHookErrorReporter as l, AfterEventType as n, HookErrorReporter as o, BeforeEvent as r, WebhooksHooks as s, AfterEvent as t, normalizeHooks as u };
177
+ //# sourceMappingURL=contract-T1kcZNdG.d.mts.map
@@ -0,0 +1,30 @@
1
+ //#region src/auth/contract.d.ts
2
+ /**
3
+ * Authentication contract. Answers: "Who is this request from?"
4
+ *
5
+ * `@xtandard/webhooks` ships `none`/`basic`/`delegated` implementations, but any
6
+ * object satisfying {@link AuthProvider} works — bring your own.
7
+ *
8
+ * @module
9
+ */
10
+ /** An authenticated identity. */
11
+ interface Principal {
12
+ id: string;
13
+ email?: string;
14
+ name?: string;
15
+ roles?: string[];
16
+ metadata?: unknown;
17
+ }
18
+ /** Authenticates an incoming web-standard {@link Request}. */
19
+ interface AuthProvider {
20
+ /** Resolve the principal, or `null` if the request is unauthenticated. */
21
+ authenticate(request: Request): Promise<Principal | null>;
22
+ /**
23
+ * Optional: build a `Response` that prompts for credentials (e.g. a 401 with a
24
+ * `WWW-Authenticate` header). When omitted, the server returns a plain 401.
25
+ */
26
+ challenge?(request: Request): Response | undefined;
27
+ }
28
+ //#endregion
29
+ export { Principal as n, AuthProvider as t };
30
+ //# sourceMappingURL=contract-lETlIuXo.d.cts.map
@@ -0,0 +1,30 @@
1
+ //#region src/auth/contract.d.ts
2
+ /**
3
+ * Authentication contract. Answers: "Who is this request from?"
4
+ *
5
+ * `@xtandard/webhooks` ships `none`/`basic`/`delegated` implementations, but any
6
+ * object satisfying {@link AuthProvider} works — bring your own.
7
+ *
8
+ * @module
9
+ */
10
+ /** An authenticated identity. */
11
+ interface Principal {
12
+ id: string;
13
+ email?: string;
14
+ name?: string;
15
+ roles?: string[];
16
+ metadata?: unknown;
17
+ }
18
+ /** Authenticates an incoming web-standard {@link Request}. */
19
+ interface AuthProvider {
20
+ /** Resolve the principal, or `null` if the request is unauthenticated. */
21
+ authenticate(request: Request): Promise<Principal | null>;
22
+ /**
23
+ * Optional: build a `Response` that prompts for credentials (e.g. a 401 with a
24
+ * `WWW-Authenticate` header). When omitted, the server returns a plain 401.
25
+ */
26
+ challenge?(request: Request): Response | undefined;
27
+ }
28
+ //#endregion
29
+ export { Principal as n, AuthProvider as t };
30
+ //# sourceMappingURL=contract-lETlIuXo.d.mts.map