@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,55 @@
1
+ import { o as WebhooksStorage } from "./contract-8h-Azxa5.cjs";
2
+ import { MongoClient } from "mongodb";
3
+
4
+ //#region src/storage/mongodb.d.ts
5
+ /** Options for {@link createMongoStorage}. */
6
+ interface MongoStorageOptions {
7
+ /** A pre-constructed (optionally pre-connected) mongodb `MongoClient`. */
8
+ client?: MongoClient;
9
+ /**
10
+ * Connection string (e.g. `mongodb://localhost:27017`). When no `client` is
11
+ * given, a `MongoClient` is created lazily on first use via a dynamic
12
+ * `import("mongodb")`.
13
+ */
14
+ url?: string;
15
+ /** Database name. Defaults to `"xtandard_webhooks"`. */
16
+ dbName?: string;
17
+ /** Collection name. Defaults to `"webhooks_kv"`. */
18
+ collectionName?: string;
19
+ }
20
+ /**
21
+ * A {@link WebhooksStorage} backed by MongoDB, plus a `close()` method that
22
+ * disconnects the client — but only the one this adapter created. A client you
23
+ * passed in is left for you to manage.
24
+ *
25
+ * Note: `watch` is deliberately absent (see the module docs); this is a plain
26
+ * {@link WebhooksStorage}, not a {@link import("./contract.ts").WatchableWebhooksStorage}.
27
+ */
28
+ interface MongoWebhooksStorage extends WebhooksStorage {
29
+ /** Disconnect the underlying client if this adapter created it. No-op otherwise. */
30
+ close(): Promise<void>;
31
+ }
32
+ /**
33
+ * Create a MongoDB-backed {@link MongoWebhooksStorage}. Connection is lazy: the
34
+ * client is created/connected on the first storage operation and reused
35
+ * thereafter, guarded by a single connection promise so concurrent calls connect
36
+ * once.
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * import { createMongoStorage } from "@xtandard/webhooks/storage/mongodb";
41
+ *
42
+ * const storage = createMongoStorage({
43
+ * url: process.env.MONGODB_URL ?? "mongodb://localhost:27017",
44
+ * dbName: "myapp",
45
+ * collectionName: "webhooks_kv",
46
+ * });
47
+ *
48
+ * // Disconnect when the process exits:
49
+ * // process.on("SIGTERM", () => storage.close());
50
+ * ```
51
+ */
52
+ declare function createMongoStorage(options: MongoStorageOptions): MongoWebhooksStorage;
53
+ //#endregion
54
+ export { MongoStorageOptions, MongoWebhooksStorage, createMongoStorage };
55
+ //# sourceMappingURL=entry-storage-mongodb.d.cts.map
@@ -0,0 +1,55 @@
1
+ import { o as WebhooksStorage } from "./contract-DhQ4JjGG.mjs";
2
+ import { MongoClient } from "mongodb";
3
+
4
+ //#region src/storage/mongodb.d.ts
5
+ /** Options for {@link createMongoStorage}. */
6
+ interface MongoStorageOptions {
7
+ /** A pre-constructed (optionally pre-connected) mongodb `MongoClient`. */
8
+ client?: MongoClient;
9
+ /**
10
+ * Connection string (e.g. `mongodb://localhost:27017`). When no `client` is
11
+ * given, a `MongoClient` is created lazily on first use via a dynamic
12
+ * `import("mongodb")`.
13
+ */
14
+ url?: string;
15
+ /** Database name. Defaults to `"xtandard_webhooks"`. */
16
+ dbName?: string;
17
+ /** Collection name. Defaults to `"webhooks_kv"`. */
18
+ collectionName?: string;
19
+ }
20
+ /**
21
+ * A {@link WebhooksStorage} backed by MongoDB, plus a `close()` method that
22
+ * disconnects the client — but only the one this adapter created. A client you
23
+ * passed in is left for you to manage.
24
+ *
25
+ * Note: `watch` is deliberately absent (see the module docs); this is a plain
26
+ * {@link WebhooksStorage}, not a {@link import("./contract.ts").WatchableWebhooksStorage}.
27
+ */
28
+ interface MongoWebhooksStorage extends WebhooksStorage {
29
+ /** Disconnect the underlying client if this adapter created it. No-op otherwise. */
30
+ close(): Promise<void>;
31
+ }
32
+ /**
33
+ * Create a MongoDB-backed {@link MongoWebhooksStorage}. Connection is lazy: the
34
+ * client is created/connected on the first storage operation and reused
35
+ * thereafter, guarded by a single connection promise so concurrent calls connect
36
+ * once.
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * import { createMongoStorage } from "@xtandard/webhooks/storage/mongodb";
41
+ *
42
+ * const storage = createMongoStorage({
43
+ * url: process.env.MONGODB_URL ?? "mongodb://localhost:27017",
44
+ * dbName: "myapp",
45
+ * collectionName: "webhooks_kv",
46
+ * });
47
+ *
48
+ * // Disconnect when the process exits:
49
+ * // process.on("SIGTERM", () => storage.close());
50
+ * ```
51
+ */
52
+ declare function createMongoStorage(options: MongoStorageOptions): MongoWebhooksStorage;
53
+ //#endregion
54
+ export { MongoStorageOptions, MongoWebhooksStorage, createMongoStorage };
55
+ //# sourceMappingURL=entry-storage-mongodb.d.mts.map
@@ -0,0 +1,2 @@
1
+ import { t as createMongoStorage } from "./mongodb-Ddaq9mml.mjs";
2
+ export { createMongoStorage };
@@ -0,0 +1,3 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_postgres = require("./postgres-C8WbchFa.cjs");
3
+ exports.createPostgresStorage = require_postgres.createPostgresStorage;
@@ -0,0 +1,62 @@
1
+ import { o as WebhooksStorage } from "./contract-8h-Azxa5.cjs";
2
+
3
+ //#region src/storage/postgres.d.ts
4
+ /**
5
+ * Minimal structural view of a SQL client. Both `pg`'s `Pool`/`Client` and
6
+ * `@electric-sql/pglite`'s `PGlite` satisfy this shape.
7
+ */
8
+ interface SqlClient {
9
+ query(text: string, params?: unknown[]): Promise<{
10
+ rows: Array<Record<string, unknown>>;
11
+ }>;
12
+ }
13
+ /** Options for {@link createPostgresStorage}. */
14
+ interface PostgresStorageOptions {
15
+ /**
16
+ * A pre-built client exposing `query(text, params?) => Promise<{ rows }>`.
17
+ * Both a `pg` `Pool`/`Client` and `@electric-sql/pglite` satisfy this.
18
+ */
19
+ client?: SqlClient;
20
+ /**
21
+ * Connection string used to lazily create a `pg` `Pool` (via dynamic import)
22
+ * when no `client` is supplied.
23
+ */
24
+ connectionString?: string;
25
+ /** Alias for {@link PostgresStorageOptions.connectionString}. */
26
+ url?: string;
27
+ /** Table name (default `"xtandard_webhooks"`). Must be a safe SQL identifier. */
28
+ table?: string;
29
+ }
30
+ /**
31
+ * A {@link WebhooksStorage} backed by Postgres, plus a `close()` method that
32
+ * ends the underlying pool — but only the one this adapter created. A client
33
+ * you passed in is left for you to manage.
34
+ */
35
+ interface PostgresWebhooksStorage extends WebhooksStorage {
36
+ /** End the underlying pool if this adapter created it. No-op otherwise. */
37
+ close(): Promise<void>;
38
+ }
39
+ /**
40
+ * Create a Postgres-backed {@link PostgresWebhooksStorage}. The table is created
41
+ * lazily on first use; connection (when using `connectionString`/`url`) is also
42
+ * lazy — the `pg` `Pool` is imported and constructed on the first operation and
43
+ * reused thereafter.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * import { createPostgresStorage } from "@xtandard/webhooks/storage/postgres";
48
+ *
49
+ * // Via connection string (lazy `pg` Pool):
50
+ * const storage = createPostgresStorage({
51
+ * connectionString: process.env.DATABASE_URL,
52
+ * });
53
+ *
54
+ * // Or with a pre-built pg Pool / PGlite client:
55
+ * // import { PGlite } from "@electric-sql/pglite";
56
+ * // const storage = createPostgresStorage({ client: new PGlite() });
57
+ * ```
58
+ */
59
+ declare function createPostgresStorage(options: PostgresStorageOptions): PostgresWebhooksStorage;
60
+ //#endregion
61
+ export { PostgresStorageOptions, PostgresWebhooksStorage, SqlClient, createPostgresStorage };
62
+ //# sourceMappingURL=entry-storage-postgres.d.cts.map
@@ -0,0 +1,62 @@
1
+ import { o as WebhooksStorage } from "./contract-DhQ4JjGG.mjs";
2
+
3
+ //#region src/storage/postgres.d.ts
4
+ /**
5
+ * Minimal structural view of a SQL client. Both `pg`'s `Pool`/`Client` and
6
+ * `@electric-sql/pglite`'s `PGlite` satisfy this shape.
7
+ */
8
+ interface SqlClient {
9
+ query(text: string, params?: unknown[]): Promise<{
10
+ rows: Array<Record<string, unknown>>;
11
+ }>;
12
+ }
13
+ /** Options for {@link createPostgresStorage}. */
14
+ interface PostgresStorageOptions {
15
+ /**
16
+ * A pre-built client exposing `query(text, params?) => Promise<{ rows }>`.
17
+ * Both a `pg` `Pool`/`Client` and `@electric-sql/pglite` satisfy this.
18
+ */
19
+ client?: SqlClient;
20
+ /**
21
+ * Connection string used to lazily create a `pg` `Pool` (via dynamic import)
22
+ * when no `client` is supplied.
23
+ */
24
+ connectionString?: string;
25
+ /** Alias for {@link PostgresStorageOptions.connectionString}. */
26
+ url?: string;
27
+ /** Table name (default `"xtandard_webhooks"`). Must be a safe SQL identifier. */
28
+ table?: string;
29
+ }
30
+ /**
31
+ * A {@link WebhooksStorage} backed by Postgres, plus a `close()` method that
32
+ * ends the underlying pool — but only the one this adapter created. A client
33
+ * you passed in is left for you to manage.
34
+ */
35
+ interface PostgresWebhooksStorage extends WebhooksStorage {
36
+ /** End the underlying pool if this adapter created it. No-op otherwise. */
37
+ close(): Promise<void>;
38
+ }
39
+ /**
40
+ * Create a Postgres-backed {@link PostgresWebhooksStorage}. The table is created
41
+ * lazily on first use; connection (when using `connectionString`/`url`) is also
42
+ * lazy — the `pg` `Pool` is imported and constructed on the first operation and
43
+ * reused thereafter.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * import { createPostgresStorage } from "@xtandard/webhooks/storage/postgres";
48
+ *
49
+ * // Via connection string (lazy `pg` Pool):
50
+ * const storage = createPostgresStorage({
51
+ * connectionString: process.env.DATABASE_URL,
52
+ * });
53
+ *
54
+ * // Or with a pre-built pg Pool / PGlite client:
55
+ * // import { PGlite } from "@electric-sql/pglite";
56
+ * // const storage = createPostgresStorage({ client: new PGlite() });
57
+ * ```
58
+ */
59
+ declare function createPostgresStorage(options: PostgresStorageOptions): PostgresWebhooksStorage;
60
+ //#endregion
61
+ export { PostgresStorageOptions, PostgresWebhooksStorage, SqlClient, createPostgresStorage };
62
+ //# sourceMappingURL=entry-storage-postgres.d.mts.map
@@ -0,0 +1,2 @@
1
+ import { t as createPostgresStorage } from "./postgres-c3pAhmhr.mjs";
2
+ export { createPostgresStorage };
@@ -0,0 +1,4 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_redis = require("./redis-CFJkuSgB.cjs");
3
+ exports.createRedisJSONStorage = require_redis.createRedisJSONStorage;
4
+ exports.createRedisStorage = require_redis.createRedisStorage;
@@ -0,0 +1,77 @@
1
+ import { a as WatchableWebhooksStorage, n as DeliveryQueueStorage } from "./contract-8h-Azxa5.cjs";
2
+ import { RedisClientType } from "redis";
3
+
4
+ //#region src/storage/redis.d.ts
5
+ /** Options for {@link createRedisStorage}. */
6
+ interface RedisStorageOptions {
7
+ /** Connection URL (e.g. `redis://localhost:6379`). Used when no `client` is given. */
8
+ url?: string;
9
+ /** A pre-constructed (optionally pre-connected) node-redis client. */
10
+ client?: RedisClientType;
11
+ /** Optional key namespace prepended to every key, joined with `:`. */
12
+ prefix?: string;
13
+ /**
14
+ * Called on client `error` events (connection drops, reconnect failures).
15
+ * A handler is always attached internally so a downed Redis never crashes the
16
+ * process via an unhandled `error` event — this just lets you observe/log them.
17
+ */
18
+ onError?: (error: unknown) => void;
19
+ }
20
+ /**
21
+ * A {@link WatchableWebhooksStorage} + {@link DeliveryQueueStorage} backed by
22
+ * Redis, plus a `close()` method that disconnects the client — but only the one
23
+ * this adapter created. A client you passed in is left for you to manage.
24
+ */
25
+ interface RedisWebhooksStorage extends WatchableWebhooksStorage, DeliveryQueueStorage {
26
+ /** Disconnect the underlying client if this adapter created it. No-op otherwise. */
27
+ close(): Promise<void>;
28
+ }
29
+ /**
30
+ * Create a Redis-backed {@link RedisWebhooksStorage}. Connection is lazy: the
31
+ * client is created/connected on the first storage operation and reused
32
+ * thereafter, guarded by a single connection promise so concurrent calls connect
33
+ * once.
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * import { createRedisStorage } from "@xtandard/webhooks/storage/redis";
38
+ *
39
+ * const storage = createRedisStorage({
40
+ * url: process.env.REDIS_URL ?? "redis://localhost:6379",
41
+ * prefix: "myapp:webhooks",
42
+ * onError: (err) => console.error("[webhooks/redis]", err),
43
+ * });
44
+ *
45
+ * // Disconnect when the process exits:
46
+ * // process.on("SIGTERM", () => storage.close());
47
+ * ```
48
+ */
49
+ declare function createRedisStorage(options: RedisStorageOptions): RedisWebhooksStorage;
50
+ /**
51
+ * Create a Redis-backed {@link RedisWebhooksStorage} that stores values as native
52
+ * **RedisJSON** documents (`JSON.SET`/`JSON.GET`) instead of strings — making
53
+ * the stored records queryable with JSONPath (`JSON.GET key $.status`) and
54
+ * indexable with RediSearch, while the webhooks system behaves identically.
55
+ *
56
+ * Requires the JSON module on the server (built into Redis 8; Redis Stack; or
57
+ * `redisjson` loaded). Same options and semantics as {@link createRedisStorage},
58
+ * including lazy connection, `SCAN`-based `getKeys`, keyspace-notification
59
+ * `watch`, and the native due-queue `claimDue`. **Do not point it at keys
60
+ * written by `createRedisStorage`** (or vice versa) — the underlying types
61
+ * differ and Redis answers `WRONGTYPE`.
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * import { createRedisJSONStorage } from "@xtandard/webhooks/storage/redis";
66
+ *
67
+ * const storage = createRedisJSONStorage({
68
+ * url: process.env.REDIS_URL ?? "redis://localhost:6379",
69
+ * prefix: "myapp:webhooks",
70
+ * });
71
+ * // Then, in redis-cli: JSON.GET myapp:webhooks:whk/acme/deliveries/dlv_1 $.status
72
+ * ```
73
+ */
74
+ declare function createRedisJSONStorage(options: RedisStorageOptions): RedisWebhooksStorage;
75
+ //#endregion
76
+ export { RedisStorageOptions, RedisWebhooksStorage, createRedisJSONStorage, createRedisStorage };
77
+ //# sourceMappingURL=entry-storage-redis.d.cts.map
@@ -0,0 +1,77 @@
1
+ import { a as WatchableWebhooksStorage, n as DeliveryQueueStorage } from "./contract-DhQ4JjGG.mjs";
2
+ import { RedisClientType } from "redis";
3
+
4
+ //#region src/storage/redis.d.ts
5
+ /** Options for {@link createRedisStorage}. */
6
+ interface RedisStorageOptions {
7
+ /** Connection URL (e.g. `redis://localhost:6379`). Used when no `client` is given. */
8
+ url?: string;
9
+ /** A pre-constructed (optionally pre-connected) node-redis client. */
10
+ client?: RedisClientType;
11
+ /** Optional key namespace prepended to every key, joined with `:`. */
12
+ prefix?: string;
13
+ /**
14
+ * Called on client `error` events (connection drops, reconnect failures).
15
+ * A handler is always attached internally so a downed Redis never crashes the
16
+ * process via an unhandled `error` event — this just lets you observe/log them.
17
+ */
18
+ onError?: (error: unknown) => void;
19
+ }
20
+ /**
21
+ * A {@link WatchableWebhooksStorage} + {@link DeliveryQueueStorage} backed by
22
+ * Redis, plus a `close()` method that disconnects the client — but only the one
23
+ * this adapter created. A client you passed in is left for you to manage.
24
+ */
25
+ interface RedisWebhooksStorage extends WatchableWebhooksStorage, DeliveryQueueStorage {
26
+ /** Disconnect the underlying client if this adapter created it. No-op otherwise. */
27
+ close(): Promise<void>;
28
+ }
29
+ /**
30
+ * Create a Redis-backed {@link RedisWebhooksStorage}. Connection is lazy: the
31
+ * client is created/connected on the first storage operation and reused
32
+ * thereafter, guarded by a single connection promise so concurrent calls connect
33
+ * once.
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * import { createRedisStorage } from "@xtandard/webhooks/storage/redis";
38
+ *
39
+ * const storage = createRedisStorage({
40
+ * url: process.env.REDIS_URL ?? "redis://localhost:6379",
41
+ * prefix: "myapp:webhooks",
42
+ * onError: (err) => console.error("[webhooks/redis]", err),
43
+ * });
44
+ *
45
+ * // Disconnect when the process exits:
46
+ * // process.on("SIGTERM", () => storage.close());
47
+ * ```
48
+ */
49
+ declare function createRedisStorage(options: RedisStorageOptions): RedisWebhooksStorage;
50
+ /**
51
+ * Create a Redis-backed {@link RedisWebhooksStorage} that stores values as native
52
+ * **RedisJSON** documents (`JSON.SET`/`JSON.GET`) instead of strings — making
53
+ * the stored records queryable with JSONPath (`JSON.GET key $.status`) and
54
+ * indexable with RediSearch, while the webhooks system behaves identically.
55
+ *
56
+ * Requires the JSON module on the server (built into Redis 8; Redis Stack; or
57
+ * `redisjson` loaded). Same options and semantics as {@link createRedisStorage},
58
+ * including lazy connection, `SCAN`-based `getKeys`, keyspace-notification
59
+ * `watch`, and the native due-queue `claimDue`. **Do not point it at keys
60
+ * written by `createRedisStorage`** (or vice versa) — the underlying types
61
+ * differ and Redis answers `WRONGTYPE`.
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * import { createRedisJSONStorage } from "@xtandard/webhooks/storage/redis";
66
+ *
67
+ * const storage = createRedisJSONStorage({
68
+ * url: process.env.REDIS_URL ?? "redis://localhost:6379",
69
+ * prefix: "myapp:webhooks",
70
+ * });
71
+ * // Then, in redis-cli: JSON.GET myapp:webhooks:whk/acme/deliveries/dlv_1 $.status
72
+ * ```
73
+ */
74
+ declare function createRedisJSONStorage(options: RedisStorageOptions): RedisWebhooksStorage;
75
+ //#endregion
76
+ export { RedisStorageOptions, RedisWebhooksStorage, createRedisJSONStorage, createRedisStorage };
77
+ //# sourceMappingURL=entry-storage-redis.d.mts.map
@@ -0,0 +1,2 @@
1
+ import { n as createRedisStorage, t as createRedisJSONStorage } from "./redis-CvLi0KF7.mjs";
2
+ export { createRedisJSONStorage, createRedisStorage };
@@ -0,0 +1,3 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_sqlite = require("./sqlite-Dcufk0x3.cjs");
3
+ exports.createSqliteStorage = require_sqlite.createSqliteStorage;
@@ -0,0 +1,36 @@
1
+ import { o as WebhooksStorage } from "./contract-8h-Azxa5.cjs";
2
+ import { Database } from "bun:sqlite";
3
+
4
+ //#region src/storage/sqlite.d.ts
5
+ /** Options for {@link createSqliteStorage}. */
6
+ interface SqliteStorageOptions {
7
+ /** File path for the database. Default `":memory:"`. Ignored when `database` is given. */
8
+ path?: string;
9
+ /** An existing `bun:sqlite` Database instance to use instead of opening one. */
10
+ database?: Database;
11
+ /** Table name (default `"xtandard_webhooks"`). Validated as a safe identifier. */
12
+ table?: string;
13
+ }
14
+ /** A {@link WebhooksStorage} backed by SQLite, plus `close()`. */
15
+ interface SqliteWebhooksStorage extends WebhooksStorage {
16
+ /** Close the database if this adapter opened it; no-op for a borrowed instance. */
17
+ close(): void;
18
+ }
19
+ /**
20
+ * Create a SQLite-backed storage. Requires the Bun runtime (`bun:sqlite`).
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * import { createSqliteStorage } from "@xtandard/webhooks/storage/sqlite";
25
+ *
26
+ * // File-backed (persists across restarts):
27
+ * const storage = createSqliteStorage({ path: "./webhooks.sqlite" });
28
+ *
29
+ * // In-memory (reset each run, useful for tests):
30
+ * // const storage = createSqliteStorage({ path: ":memory:" });
31
+ * ```
32
+ */
33
+ declare function createSqliteStorage(options?: SqliteStorageOptions): SqliteWebhooksStorage;
34
+ //#endregion
35
+ export { SqliteStorageOptions, SqliteWebhooksStorage, createSqliteStorage };
36
+ //# sourceMappingURL=entry-storage-sqlite.d.cts.map
@@ -0,0 +1,36 @@
1
+ import { o as WebhooksStorage } from "./contract-DhQ4JjGG.mjs";
2
+ import { Database } from "bun:sqlite";
3
+
4
+ //#region src/storage/sqlite.d.ts
5
+ /** Options for {@link createSqliteStorage}. */
6
+ interface SqliteStorageOptions {
7
+ /** File path for the database. Default `":memory:"`. Ignored when `database` is given. */
8
+ path?: string;
9
+ /** An existing `bun:sqlite` Database instance to use instead of opening one. */
10
+ database?: Database;
11
+ /** Table name (default `"xtandard_webhooks"`). Validated as a safe identifier. */
12
+ table?: string;
13
+ }
14
+ /** A {@link WebhooksStorage} backed by SQLite, plus `close()`. */
15
+ interface SqliteWebhooksStorage extends WebhooksStorage {
16
+ /** Close the database if this adapter opened it; no-op for a borrowed instance. */
17
+ close(): void;
18
+ }
19
+ /**
20
+ * Create a SQLite-backed storage. Requires the Bun runtime (`bun:sqlite`).
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * import { createSqliteStorage } from "@xtandard/webhooks/storage/sqlite";
25
+ *
26
+ * // File-backed (persists across restarts):
27
+ * const storage = createSqliteStorage({ path: "./webhooks.sqlite" });
28
+ *
29
+ * // In-memory (reset each run, useful for tests):
30
+ * // const storage = createSqliteStorage({ path: ":memory:" });
31
+ * ```
32
+ */
33
+ declare function createSqliteStorage(options?: SqliteStorageOptions): SqliteWebhooksStorage;
34
+ //#endregion
35
+ export { SqliteStorageOptions, SqliteWebhooksStorage, createSqliteStorage };
36
+ //# sourceMappingURL=entry-storage-sqlite.d.mts.map
@@ -0,0 +1,2 @@
1
+ import { t as createSqliteStorage } from "./sqlite-Cmqnrjes.mjs";
2
+ export { createSqliteStorage };
@@ -0,0 +1,42 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/storage/unstorage.ts
3
+ /** Convert an unstorage `:`-separated key back to the `/`-separated form. */
4
+ const fromUnstorageKey = (key) => key.replace(/:/g, "/");
5
+ /**
6
+ * Create a {@link WebhooksStorage} backed by an unstorage `Storage` instance.
7
+ * unstorage auto-serializes/deserializes JSON values, so values round-trip
8
+ * structurally; missing keys read back as `null`.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import { createUnstorageStorage } from "@xtandard/webhooks/storage/unstorage";
13
+ * import { createStorage } from "unstorage";
14
+ * import fsDriver from "unstorage/drivers/fs";
15
+ *
16
+ * const storage = createUnstorageStorage({
17
+ * storage: createStorage({ driver: fsDriver({ base: "./data/webhooks" }) }),
18
+ * });
19
+ * ```
20
+ */
21
+ function createUnstorageStorage(options) {
22
+ const { storage } = options;
23
+ return {
24
+ async getItem(key) {
25
+ const value = await storage.getItem(key);
26
+ return value === void 0 ? null : value;
27
+ },
28
+ async setItem(key, value) {
29
+ await storage.setItem(key, value);
30
+ },
31
+ async removeItem(key) {
32
+ await storage.removeItem(key);
33
+ },
34
+ async getKeys(prefix) {
35
+ return (await storage.getKeys(prefix)).map(fromUnstorageKey).filter((key) => key.startsWith(prefix));
36
+ }
37
+ };
38
+ }
39
+ //#endregion
40
+ exports.createUnstorageStorage = createUnstorageStorage;
41
+
42
+ //# sourceMappingURL=entry-storage-unstorage.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entry-storage-unstorage.cjs","names":[],"sources":["../src/storage/unstorage.ts"],"sourcesContent":["/**\n * Adapter that wraps an [unstorage](https://unstorage.unjs.io) `Storage`\n * instance as a {@link WebhooksStorage}. The caller constructs and configures\n * their own unstorage instance (with whatever driver they like) and passes it in\n * — we never import `unstorage` at runtime, only its type. `unstorage` therefore\n * remains an optional peer dependency.\n *\n * unstorage normalizes key separators to `:` internally. We write `/`-style keys\n * (which unstorage accepts), but its `getKeys(base)` returns `:`-separated keys.\n * This adapter converts those back to `/` so callers always see the keys they\n * wrote.\n *\n * @module\n */\n\nimport type { Storage } from \"unstorage\";\nimport type { WebhooksStorage } from \"./contract.ts\";\n\n/** Options for {@link createUnstorageStorage}. */\nexport interface UnstorageStorageOptions {\n /** A pre-constructed unstorage `Storage` instance (any driver). */\n storage: Storage;\n}\n\n/** Convert an unstorage `:`-separated key back to the `/`-separated form. */\nconst fromUnstorageKey = (key: string): string => key.replace(/:/g, \"/\");\n\n/**\n * Create a {@link WebhooksStorage} backed by an unstorage `Storage` instance.\n * unstorage auto-serializes/deserializes JSON values, so values round-trip\n * structurally; missing keys read back as `null`.\n *\n * @example\n * ```ts\n * import { createUnstorageStorage } from \"@xtandard/webhooks/storage/unstorage\";\n * import { createStorage } from \"unstorage\";\n * import fsDriver from \"unstorage/drivers/fs\";\n *\n * const storage = createUnstorageStorage({\n * storage: createStorage({ driver: fsDriver({ base: \"./data/webhooks\" }) }),\n * });\n * ```\n */\nexport function createUnstorageStorage(options: UnstorageStorageOptions): WebhooksStorage {\n const { storage } = options;\n\n return {\n async getItem<T>(key: string): Promise<T | null> {\n const value = await storage.getItem<T>(key);\n return value === undefined ? null : value;\n },\n\n async setItem<T>(key: string, value: T): Promise<void> {\n // unstorage's setItem rejects `undefined`; the contract never stores it.\n await storage.setItem(key, value as NonNullable<T>);\n },\n\n async removeItem(key: string): Promise<void> {\n await storage.removeItem(key);\n },\n\n async getKeys(prefix: string): Promise<string[]> {\n // unstorage's getKeys takes a base and returns matching keys with `:`\n // separators; convert them back so callers get their original `/` keys.\n const keys = await storage.getKeys(prefix);\n return keys.map(fromUnstorageKey).filter((key) => key.startsWith(prefix));\n },\n } satisfies WebhooksStorage;\n}\n"],"mappings":";;;AAyBA,MAAM,oBAAoB,QAAwB,IAAI,QAAQ,MAAM,GAAG;;;;;;;;;;;;;;;;;AAkBvE,SAAgB,uBAAuB,SAAmD;CACxF,MAAM,EAAE,YAAY;CAEpB,OAAO;EACL,MAAM,QAAW,KAAgC;GAC/C,MAAM,QAAQ,MAAM,QAAQ,QAAW,GAAG;GAC1C,OAAO,UAAU,KAAA,IAAY,OAAO;EACtC;EAEA,MAAM,QAAW,KAAa,OAAyB;GAErD,MAAM,QAAQ,QAAQ,KAAK,KAAuB;EACpD;EAEA,MAAM,WAAW,KAA4B;GAC3C,MAAM,QAAQ,WAAW,GAAG;EAC9B;EAEA,MAAM,QAAQ,QAAmC;GAI/C,QAAO,MADY,QAAQ,QAAQ,MAAM,GAC7B,IAAI,gBAAgB,EAAE,QAAQ,QAAQ,IAAI,WAAW,MAAM,CAAC;EAC1E;CACF;AACF"}
@@ -0,0 +1,29 @@
1
+ import { o as WebhooksStorage } from "./contract-8h-Azxa5.cjs";
2
+ import { Storage } from "unstorage";
3
+
4
+ //#region src/storage/unstorage.d.ts
5
+ /** Options for {@link createUnstorageStorage}. */
6
+ interface UnstorageStorageOptions {
7
+ /** A pre-constructed unstorage `Storage` instance (any driver). */
8
+ storage: Storage;
9
+ }
10
+ /**
11
+ * Create a {@link WebhooksStorage} backed by an unstorage `Storage` instance.
12
+ * unstorage auto-serializes/deserializes JSON values, so values round-trip
13
+ * structurally; missing keys read back as `null`.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * import { createUnstorageStorage } from "@xtandard/webhooks/storage/unstorage";
18
+ * import { createStorage } from "unstorage";
19
+ * import fsDriver from "unstorage/drivers/fs";
20
+ *
21
+ * const storage = createUnstorageStorage({
22
+ * storage: createStorage({ driver: fsDriver({ base: "./data/webhooks" }) }),
23
+ * });
24
+ * ```
25
+ */
26
+ declare function createUnstorageStorage(options: UnstorageStorageOptions): WebhooksStorage;
27
+ //#endregion
28
+ export { UnstorageStorageOptions, createUnstorageStorage };
29
+ //# sourceMappingURL=entry-storage-unstorage.d.cts.map
@@ -0,0 +1,29 @@
1
+ import { o as WebhooksStorage } from "./contract-DhQ4JjGG.mjs";
2
+ import { Storage } from "unstorage";
3
+
4
+ //#region src/storage/unstorage.d.ts
5
+ /** Options for {@link createUnstorageStorage}. */
6
+ interface UnstorageStorageOptions {
7
+ /** A pre-constructed unstorage `Storage` instance (any driver). */
8
+ storage: Storage;
9
+ }
10
+ /**
11
+ * Create a {@link WebhooksStorage} backed by an unstorage `Storage` instance.
12
+ * unstorage auto-serializes/deserializes JSON values, so values round-trip
13
+ * structurally; missing keys read back as `null`.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * import { createUnstorageStorage } from "@xtandard/webhooks/storage/unstorage";
18
+ * import { createStorage } from "unstorage";
19
+ * import fsDriver from "unstorage/drivers/fs";
20
+ *
21
+ * const storage = createUnstorageStorage({
22
+ * storage: createStorage({ driver: fsDriver({ base: "./data/webhooks" }) }),
23
+ * });
24
+ * ```
25
+ */
26
+ declare function createUnstorageStorage(options: UnstorageStorageOptions): WebhooksStorage;
27
+ //#endregion
28
+ export { UnstorageStorageOptions, createUnstorageStorage };
29
+ //# sourceMappingURL=entry-storage-unstorage.d.mts.map
@@ -0,0 +1,41 @@
1
+ //#region src/storage/unstorage.ts
2
+ /** Convert an unstorage `:`-separated key back to the `/`-separated form. */
3
+ const fromUnstorageKey = (key) => key.replace(/:/g, "/");
4
+ /**
5
+ * Create a {@link WebhooksStorage} backed by an unstorage `Storage` instance.
6
+ * unstorage auto-serializes/deserializes JSON values, so values round-trip
7
+ * structurally; missing keys read back as `null`.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * import { createUnstorageStorage } from "@xtandard/webhooks/storage/unstorage";
12
+ * import { createStorage } from "unstorage";
13
+ * import fsDriver from "unstorage/drivers/fs";
14
+ *
15
+ * const storage = createUnstorageStorage({
16
+ * storage: createStorage({ driver: fsDriver({ base: "./data/webhooks" }) }),
17
+ * });
18
+ * ```
19
+ */
20
+ function createUnstorageStorage(options) {
21
+ const { storage } = options;
22
+ return {
23
+ async getItem(key) {
24
+ const value = await storage.getItem(key);
25
+ return value === void 0 ? null : value;
26
+ },
27
+ async setItem(key, value) {
28
+ await storage.setItem(key, value);
29
+ },
30
+ async removeItem(key) {
31
+ await storage.removeItem(key);
32
+ },
33
+ async getKeys(prefix) {
34
+ return (await storage.getKeys(prefix)).map(fromUnstorageKey).filter((key) => key.startsWith(prefix));
35
+ }
36
+ };
37
+ }
38
+ //#endregion
39
+ export { createUnstorageStorage };
40
+
41
+ //# sourceMappingURL=entry-storage-unstorage.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entry-storage-unstorage.mjs","names":[],"sources":["../src/storage/unstorage.ts"],"sourcesContent":["/**\n * Adapter that wraps an [unstorage](https://unstorage.unjs.io) `Storage`\n * instance as a {@link WebhooksStorage}. The caller constructs and configures\n * their own unstorage instance (with whatever driver they like) and passes it in\n * — we never import `unstorage` at runtime, only its type. `unstorage` therefore\n * remains an optional peer dependency.\n *\n * unstorage normalizes key separators to `:` internally. We write `/`-style keys\n * (which unstorage accepts), but its `getKeys(base)` returns `:`-separated keys.\n * This adapter converts those back to `/` so callers always see the keys they\n * wrote.\n *\n * @module\n */\n\nimport type { Storage } from \"unstorage\";\nimport type { WebhooksStorage } from \"./contract.ts\";\n\n/** Options for {@link createUnstorageStorage}. */\nexport interface UnstorageStorageOptions {\n /** A pre-constructed unstorage `Storage` instance (any driver). */\n storage: Storage;\n}\n\n/** Convert an unstorage `:`-separated key back to the `/`-separated form. */\nconst fromUnstorageKey = (key: string): string => key.replace(/:/g, \"/\");\n\n/**\n * Create a {@link WebhooksStorage} backed by an unstorage `Storage` instance.\n * unstorage auto-serializes/deserializes JSON values, so values round-trip\n * structurally; missing keys read back as `null`.\n *\n * @example\n * ```ts\n * import { createUnstorageStorage } from \"@xtandard/webhooks/storage/unstorage\";\n * import { createStorage } from \"unstorage\";\n * import fsDriver from \"unstorage/drivers/fs\";\n *\n * const storage = createUnstorageStorage({\n * storage: createStorage({ driver: fsDriver({ base: \"./data/webhooks\" }) }),\n * });\n * ```\n */\nexport function createUnstorageStorage(options: UnstorageStorageOptions): WebhooksStorage {\n const { storage } = options;\n\n return {\n async getItem<T>(key: string): Promise<T | null> {\n const value = await storage.getItem<T>(key);\n return value === undefined ? null : value;\n },\n\n async setItem<T>(key: string, value: T): Promise<void> {\n // unstorage's setItem rejects `undefined`; the contract never stores it.\n await storage.setItem(key, value as NonNullable<T>);\n },\n\n async removeItem(key: string): Promise<void> {\n await storage.removeItem(key);\n },\n\n async getKeys(prefix: string): Promise<string[]> {\n // unstorage's getKeys takes a base and returns matching keys with `:`\n // separators; convert them back so callers get their original `/` keys.\n const keys = await storage.getKeys(prefix);\n return keys.map(fromUnstorageKey).filter((key) => key.startsWith(prefix));\n },\n } satisfies WebhooksStorage;\n}\n"],"mappings":";;AAyBA,MAAM,oBAAoB,QAAwB,IAAI,QAAQ,MAAM,GAAG;;;;;;;;;;;;;;;;;AAkBvE,SAAgB,uBAAuB,SAAmD;CACxF,MAAM,EAAE,YAAY;CAEpB,OAAO;EACL,MAAM,QAAW,KAAgC;GAC/C,MAAM,QAAQ,MAAM,QAAQ,QAAW,GAAG;GAC1C,OAAO,UAAU,KAAA,IAAY,OAAO;EACtC;EAEA,MAAM,QAAW,KAAa,OAAyB;GAErD,MAAM,QAAQ,QAAQ,KAAK,KAAuB;EACpD;EAEA,MAAM,WAAW,KAA4B;GAC3C,MAAM,QAAQ,WAAW,GAAG;EAC9B;EAEA,MAAM,QAAQ,QAAmC;GAI/C,QAAO,MADY,QAAQ,QAAQ,MAAM,GAC7B,IAAI,gBAAgB,EAAE,QAAQ,QAAQ,IAAI,WAAW,MAAM,CAAC;EAC1E;CACF;AACF"}