@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,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,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,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,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,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"}
|