tapimo 0.0.2 → 0.2.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/README.md +38 -16
- package/dist/ApiKey.d.ts +14 -11
- package/dist/ApiKey.d.ts.map +1 -1
- package/dist/ApiKey.js +11 -12
- package/dist/ApiKey.js.map +1 -1
- package/dist/ApiKeys.d.ts +207 -0
- package/dist/ApiKeys.d.ts.map +1 -0
- package/dist/ApiKeys.js +282 -0
- package/dist/ApiKeys.js.map +1 -0
- package/dist/App.d.ts +6771 -3819
- package/dist/App.d.ts.map +1 -1
- package/dist/App.js +145 -317
- package/dist/App.js.map +1 -1
- package/dist/Handler.d.ts +86 -0
- package/dist/Handler.d.ts.map +1 -0
- package/dist/Handler.js +83 -0
- package/dist/Handler.js.map +1 -0
- package/dist/Scope.d.ts +14 -4
- package/dist/Scope.d.ts.map +1 -1
- package/dist/Scope.js +16 -4
- package/dist/Scope.js.map +1 -1
- package/dist/Webhooks.d.ts +5 -7
- package/dist/Webhooks.d.ts.map +1 -1
- package/dist/Webhooks.js +11 -4
- package/dist/Webhooks.js.map +1 -1
- package/dist/admin/Access.d.ts +1 -3
- package/dist/admin/Access.d.ts.map +1 -1
- package/dist/admin/Access.js +1 -3
- package/dist/admin/Access.js.map +1 -1
- package/dist/admin/App.d.ts +167 -205
- package/dist/admin/App.d.ts.map +1 -1
- package/dist/admin/App.js +2 -4
- package/dist/admin/App.js.map +1 -1
- package/dist/admin/apps/api-keys.d.ts +105 -5
- package/dist/admin/apps/api-keys.d.ts.map +1 -1
- package/dist/admin/apps/api-keys.js +75 -9
- package/dist/admin/apps/api-keys.js.map +1 -1
- package/dist/admin/apps/scopes.d.ts +6 -0
- package/dist/admin/apps/scopes.d.ts.map +1 -1
- package/dist/admin/apps/verified-tokens.d.ts +35 -149
- package/dist/admin/apps/verified-tokens.d.ts.map +1 -1
- package/dist/admin/apps/verified-tokens.js +18 -39
- package/dist/admin/apps/verified-tokens.js.map +1 -1
- package/dist/admin/ui.generated.d.ts +1 -1
- package/dist/admin/ui.generated.js +1 -1
- package/dist/apps/data/App.d.ts +19176 -0
- package/dist/apps/data/App.d.ts.map +1 -0
- package/dist/apps/data/App.js +236 -0
- package/dist/apps/data/App.js.map +1 -0
- package/dist/apps/data/index.d.ts +3 -0
- package/dist/apps/data/index.d.ts.map +1 -0
- package/dist/apps/data/index.js +3 -0
- package/dist/apps/data/index.js.map +1 -0
- package/dist/apps/{activities.d.ts → data/routes/activities.d.ts} +32 -32
- package/dist/apps/{activities.d.ts.map → data/routes/activities.d.ts.map} +1 -1
- package/dist/apps/{activities.js → data/routes/activities.js} +13 -13
- package/dist/apps/data/routes/activities.js.map +1 -0
- package/dist/apps/{addresses.d.ts → data/routes/addresses.d.ts} +22 -22
- package/dist/apps/{addresses.d.ts.map → data/routes/addresses.d.ts.map} +1 -1
- package/dist/apps/{addresses.js → data/routes/addresses.js} +5 -5
- package/dist/apps/data/routes/addresses.js.map +1 -0
- package/dist/apps/{balances.d.ts → data/routes/balances.d.ts} +49 -49
- package/dist/apps/data/routes/balances.d.ts.map +1 -0
- package/dist/apps/{balances.js → data/routes/balances.js} +42 -11
- package/dist/apps/data/routes/balances.js.map +1 -0
- package/dist/apps/{blocks.d.ts → data/routes/blocks.d.ts} +47 -47
- package/dist/apps/data/routes/blocks.d.ts.map +1 -0
- package/dist/apps/{blocks.js → data/routes/blocks.js} +13 -13
- package/dist/apps/data/routes/blocks.js.map +1 -0
- package/dist/apps/{coingecko.d.ts → data/routes/coingecko.d.ts} +183 -183
- package/dist/apps/data/routes/coingecko.d.ts.map +1 -0
- package/dist/apps/{coingecko.js → data/routes/coingecko.js} +13 -13
- package/dist/apps/data/routes/coingecko.js.map +1 -0
- package/dist/apps/{exchanges.d.ts → data/routes/exchanges.d.ts} +460 -460
- package/dist/apps/data/routes/exchanges.d.ts.map +1 -0
- package/dist/apps/{exchanges.js → data/routes/exchanges.js} +19 -19
- package/dist/apps/data/routes/exchanges.js.map +1 -0
- package/dist/apps/{fee-amm.d.ts → data/routes/fee-amm.d.ts} +94 -94
- package/dist/apps/data/routes/fee-amm.d.ts.map +1 -0
- package/dist/apps/{fee-amm.js → data/routes/fee-amm.js} +17 -17
- package/dist/apps/data/routes/fee-amm.js.map +1 -0
- package/dist/apps/{indexer.d.ts → data/routes/indexer.d.ts} +4 -4
- package/dist/apps/data/routes/indexer.d.ts.map +1 -0
- package/dist/apps/{indexer.js → data/routes/indexer.js} +13 -9
- package/dist/apps/data/routes/indexer.js.map +1 -0
- package/dist/apps/{receipts.d.ts → data/routes/receipts.d.ts} +6 -6
- package/dist/apps/data/routes/receipts.d.ts.map +1 -0
- package/dist/apps/{receipts.js → data/routes/receipts.js} +12 -12
- package/dist/apps/data/routes/receipts.js.map +1 -0
- package/dist/apps/{rpc.d.ts → data/routes/rpc.d.ts} +4 -4
- package/dist/apps/data/routes/rpc.d.ts.map +1 -0
- package/dist/apps/{rpc.js → data/routes/rpc.js} +6 -6
- package/dist/apps/data/routes/rpc.js.map +1 -0
- package/dist/apps/{tokenlist.d.ts → data/routes/tokenlist.d.ts} +4 -4
- package/dist/apps/data/routes/tokenlist.d.ts.map +1 -0
- package/dist/apps/{tokenlist.js → data/routes/tokenlist.js} +8 -8
- package/dist/apps/data/routes/tokenlist.js.map +1 -0
- package/dist/apps/{tokens.d.ts → data/routes/tokens.d.ts} +11 -11
- package/dist/apps/data/routes/tokens.d.ts.map +1 -0
- package/dist/apps/{tokens.js → data/routes/tokens.js} +19 -19
- package/dist/apps/data/routes/tokens.js.map +1 -0
- package/dist/apps/{transactions.d.ts → data/routes/transactions.d.ts} +288 -288
- package/dist/apps/data/routes/transactions.d.ts.map +1 -0
- package/dist/apps/{transactions.js → data/routes/transactions.js} +13 -13
- package/dist/apps/data/routes/transactions.js.map +1 -0
- package/dist/apps/{transfers.d.ts → data/routes/transfers.d.ts} +35 -35
- package/dist/apps/data/routes/transfers.d.ts.map +1 -0
- package/dist/apps/{transfers.js → data/routes/transfers.js} +13 -13
- package/dist/apps/data/routes/transfers.js.map +1 -0
- package/dist/apps/{verified-tokens.d.ts → data/routes/verified-tokens.d.ts} +42 -42
- package/dist/apps/data/routes/verified-tokens.d.ts.map +1 -0
- package/dist/apps/{verified-tokens.js → data/routes/verified-tokens.js} +9 -9
- package/dist/apps/data/routes/verified-tokens.js.map +1 -0
- package/dist/apps/{webhooks.d.ts → data/routes/webhooks.d.ts} +66 -63
- package/dist/apps/{webhooks.d.ts.map → data/routes/webhooks.d.ts.map} +1 -1
- package/dist/apps/{webhooks.js → data/routes/webhooks.js} +67 -59
- package/dist/apps/data/routes/webhooks.js.map +1 -0
- package/dist/apps/docs/App.d.ts +27 -0
- package/dist/apps/docs/App.d.ts.map +1 -0
- package/dist/apps/docs/App.js +122 -0
- package/dist/apps/docs/App.js.map +1 -0
- package/dist/{internal/OpenApi.fonts.d.ts → apps/docs/fonts.d.ts} +1 -1
- package/dist/apps/docs/fonts.d.ts.map +1 -0
- package/dist/{internal/OpenApi.fonts.js → apps/docs/fonts.js} +1 -1
- package/dist/apps/docs/fonts.js.map +1 -0
- package/dist/apps/docs/index.d.ts +2 -0
- package/dist/apps/docs/index.d.ts.map +1 -0
- package/dist/apps/docs/index.js +2 -0
- package/dist/apps/docs/index.js.map +1 -0
- package/dist/{internal/OpenApi.logo.d.ts → apps/docs/logo.d.ts} +1 -1
- package/dist/apps/docs/logo.d.ts.map +1 -0
- package/dist/{internal/OpenApi.logo.js → apps/docs/logo.js} +1 -1
- package/dist/apps/docs/logo.js.map +1 -0
- package/dist/apps/index.d.ts +4 -0
- package/dist/apps/index.d.ts.map +1 -0
- package/dist/apps/index.js +4 -0
- package/dist/apps/index.js.map +1 -0
- package/dist/apps/metadata.d.ts +7 -0
- package/dist/apps/metadata.d.ts.map +1 -0
- package/dist/apps/metadata.js +15 -0
- package/dist/apps/metadata.js.map +1 -0
- package/dist/apps/platform/App.d.ts +2985 -0
- package/dist/apps/platform/App.d.ts.map +1 -0
- package/dist/apps/platform/App.js +74 -0
- package/dist/apps/platform/App.js.map +1 -0
- package/dist/apps/platform/index.d.ts +2 -0
- package/dist/apps/platform/index.d.ts.map +1 -0
- package/dist/apps/platform/index.js +2 -0
- package/dist/apps/platform/index.js.map +1 -0
- package/dist/apps/platform/routes/api-keys.d.ts +681 -0
- package/dist/apps/platform/routes/api-keys.d.ts.map +1 -0
- package/dist/apps/platform/routes/api-keys.js +328 -0
- package/dist/apps/platform/routes/api-keys.js.map +1 -0
- package/dist/apps/platform/routes/invitations.d.ts +733 -0
- package/dist/apps/platform/routes/invitations.d.ts.map +1 -0
- package/dist/apps/platform/routes/invitations.js +413 -0
- package/dist/apps/platform/routes/invitations.js.map +1 -0
- package/dist/apps/platform/routes/me.d.ts +95 -0
- package/dist/apps/platform/routes/me.d.ts.map +1 -0
- package/dist/apps/platform/routes/me.js +81 -0
- package/dist/apps/platform/routes/me.js.map +1 -0
- package/dist/apps/platform/routes/members.d.ts +554 -0
- package/dist/apps/platform/routes/members.d.ts.map +1 -0
- package/dist/apps/platform/routes/members.js +251 -0
- package/dist/apps/platform/routes/members.js.map +1 -0
- package/dist/apps/platform/routes/orgs.d.ts +582 -0
- package/dist/apps/platform/routes/orgs.d.ts.map +1 -0
- package/dist/apps/platform/routes/orgs.js +265 -0
- package/dist/apps/platform/routes/orgs.js.map +1 -0
- package/dist/apps/platform/routes/projects.d.ts +740 -0
- package/dist/apps/platform/routes/projects.d.ts.map +1 -0
- package/dist/apps/platform/routes/projects.js +286 -0
- package/dist/apps/platform/routes/projects.js.map +1 -0
- package/dist/apps/relay/App.d.ts +41 -0
- package/dist/apps/relay/App.d.ts.map +1 -0
- package/dist/apps/relay/App.js +103 -0
- package/dist/apps/relay/App.js.map +1 -0
- package/dist/apps/relay/Sponsorships.d.ts +107 -0
- package/dist/apps/relay/Sponsorships.d.ts.map +1 -0
- package/dist/apps/relay/Sponsorships.js +193 -0
- package/dist/apps/relay/Sponsorships.js.map +1 -0
- package/dist/apps/relay/index.d.ts +3 -0
- package/dist/apps/relay/index.d.ts.map +1 -0
- package/dist/apps/relay/index.js +3 -0
- package/dist/apps/relay/index.js.map +1 -0
- package/dist/{Cli.d.ts → cli/Cli.d.ts} +13 -2
- package/dist/cli/Cli.d.ts.map +1 -0
- package/dist/cli/Cli.js +19 -0
- package/dist/cli/Cli.js.map +1 -0
- package/dist/cli/bin.d.ts +3 -0
- package/dist/cli/bin.d.ts.map +1 -0
- package/dist/cli/bin.js +4 -0
- package/dist/cli/bin.js.map +1 -0
- package/dist/cli/commands/admin.d.ts +15 -0
- package/dist/cli/commands/admin.d.ts.map +1 -0
- package/dist/cli/commands/admin.js +60 -0
- package/dist/cli/commands/admin.js.map +1 -0
- package/dist/cloudflare.d.ts +7 -0
- package/dist/cloudflare.d.ts.map +1 -1
- package/dist/cloudflare.js +9 -0
- package/dist/cloudflare.js.map +1 -1
- package/dist/db/Db.d.ts +113 -0
- package/dist/db/Db.d.ts.map +1 -0
- package/dist/db/Db.js +402 -0
- package/dist/db/Db.js.map +1 -0
- package/dist/db/Schema.d.ts +168 -0
- package/dist/db/Schema.d.ts.map +1 -0
- package/dist/db/Schema.js +229 -0
- package/dist/db/Schema.js.map +1 -0
- package/dist/db/tables/invitations.d.ts +84 -0
- package/dist/db/tables/invitations.d.ts.map +1 -0
- package/dist/db/tables/invitations.js +165 -0
- package/dist/db/tables/invitations.js.map +1 -0
- package/dist/db/tables/memberships.d.ts +108 -0
- package/dist/db/tables/memberships.d.ts.map +1 -0
- package/dist/db/tables/memberships.js +153 -0
- package/dist/db/tables/memberships.js.map +1 -0
- package/dist/db/tables/organizations.d.ts +123 -0
- package/dist/db/tables/organizations.d.ts.map +1 -0
- package/dist/db/tables/organizations.js +170 -0
- package/dist/db/tables/organizations.js.map +1 -0
- package/dist/db/tables/projects.d.ts +65 -0
- package/dist/db/tables/projects.d.ts.map +1 -0
- package/dist/db/tables/projects.js +75 -0
- package/dist/db/tables/projects.js.map +1 -0
- package/dist/db/tables/sponsoredTransactions.d.ts +120 -0
- package/dist/db/tables/sponsoredTransactions.d.ts.map +1 -0
- package/dist/db/tables/sponsoredTransactions.js +161 -0
- package/dist/db/tables/sponsoredTransactions.js.map +1 -0
- package/dist/db/tables/users.d.ts +48 -0
- package/dist/db/tables/users.d.ts.map +1 -0
- package/dist/db/tables/users.js +65 -0
- package/dist/db/tables/users.js.map +1 -0
- package/dist/db/tables/verifiedTokens.d.ts +53 -0
- package/dist/db/tables/verifiedTokens.d.ts.map +1 -0
- package/dist/db/tables/verifiedTokens.js +74 -0
- package/dist/db/tables/verifiedTokens.js.map +1 -0
- package/dist/db/tables/webhookDeliveries.d.ts +71 -0
- package/dist/db/tables/webhookDeliveries.d.ts.map +1 -0
- package/dist/db/tables/webhookDeliveries.js +119 -0
- package/dist/db/tables/webhookDeliveries.js.map +1 -0
- package/dist/db/tables/webhookSubscriptions.d.ts +158 -0
- package/dist/db/tables/webhookSubscriptions.d.ts.map +1 -0
- package/dist/db/tables/webhookSubscriptions.js +272 -0
- package/dist/db/tables/webhookSubscriptions.js.map +1 -0
- package/dist/handlers/internal/executionError.d.ts +25 -0
- package/dist/handlers/internal/executionError.d.ts.map +1 -0
- package/dist/handlers/internal/executionError.js +186 -0
- package/dist/handlers/internal/executionError.js.map +1 -0
- package/dist/handlers/internal/multisig.d.ts +233 -0
- package/dist/handlers/internal/multisig.d.ts.map +1 -0
- package/dist/handlers/internal/multisig.js +542 -0
- package/dist/handlers/internal/multisig.js.map +1 -0
- package/dist/handlers/internal/requestListener.d.ts +124 -0
- package/dist/handlers/internal/requestListener.d.ts.map +1 -0
- package/dist/handlers/internal/requestListener.js +173 -0
- package/dist/handlers/internal/requestListener.js.map +1 -0
- package/dist/handlers/internal/sponsorship.d.ts +113 -0
- package/dist/handlers/internal/sponsorship.d.ts.map +1 -0
- package/dist/handlers/internal/sponsorship.js +128 -0
- package/dist/handlers/internal/sponsorship.js.map +1 -0
- package/dist/handlers/internal/types.d.ts +284 -0
- package/dist/handlers/internal/types.d.ts.map +1 -0
- package/dist/handlers/internal/types.js +2 -0
- package/dist/handlers/internal/types.js.map +1 -0
- package/dist/handlers/internal/utils.d.ts +34 -0
- package/dist/handlers/internal/utils.d.ts.map +1 -0
- package/dist/handlers/internal/utils.js +131 -0
- package/dist/handlers/internal/utils.js.map +1 -0
- package/dist/handlers/relay.d.ts +123 -0
- package/dist/handlers/relay.d.ts.map +1 -0
- package/dist/handlers/relay.js +1278 -0
- package/dist/handlers/relay.js.map +1 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/internal/Auth.d.ts +224 -16
- package/dist/internal/Auth.d.ts.map +1 -1
- package/dist/internal/Auth.js +572 -33
- package/dist/internal/Auth.js.map +1 -1
- package/dist/internal/Log.d.ts +7 -3
- package/dist/internal/Log.d.ts.map +1 -1
- package/dist/internal/Log.js +4 -0
- package/dist/internal/Log.js.map +1 -1
- package/dist/internal/OpenApi.d.ts +0 -19
- package/dist/internal/OpenApi.d.ts.map +1 -1
- package/dist/internal/OpenApi.js +0 -57
- package/dist/internal/OpenApi.js.map +1 -1
- package/dist/internal/RpcSchema.d.ts +10 -0
- package/dist/internal/RpcSchema.d.ts.map +1 -0
- package/dist/internal/RpcSchema.js +2 -0
- package/dist/internal/RpcSchema.js.map +1 -0
- package/dist/internal/Store.d.ts +49 -4
- package/dist/internal/Store.d.ts.map +1 -1
- package/dist/internal/Store.js +81 -5
- package/dist/internal/Store.js.map +1 -1
- package/dist/internal/VerifiedTokens.d.ts +15 -34
- package/dist/internal/VerifiedTokens.d.ts.map +1 -1
- package/dist/internal/VerifiedTokens.js +115 -159
- package/dist/internal/VerifiedTokens.js.map +1 -1
- package/dist/internal/Viem.d.ts +84 -0
- package/dist/internal/Viem.d.ts.map +1 -1
- package/dist/internal/Webhooks.d.ts +50 -36
- package/dist/internal/Webhooks.d.ts.map +1 -1
- package/dist/internal/Webhooks.js +92 -205
- package/dist/internal/Webhooks.js.map +1 -1
- package/package.json +37 -6
- package/src/ApiKey.test.ts +3 -3
- package/src/ApiKey.ts +11 -12
- package/src/ApiKeys.test.ts +278 -0
- package/src/ApiKeys.ts +358 -0
- package/src/App.test-d.ts +1 -1
- package/src/App.test.ts +40508 -19083
- package/src/App.ts +239 -416
- package/src/Client.test-d.ts +307 -16
- package/src/Handler.ts +154 -0
- package/src/Scope.ts +17 -4
- package/src/Webhooks.test.ts +8 -7
- package/src/Webhooks.ts +13 -7
- package/src/admin/Access.ts +1 -3
- package/src/admin/App.ts +19 -24
- package/src/admin/apps/api-keys.test.ts +70 -18
- package/src/admin/apps/api-keys.ts +92 -9
- package/src/admin/apps/scopes.test.ts +8 -0
- package/src/admin/apps/verified-tokens.test.ts +3 -30
- package/src/admin/apps/verified-tokens.ts +18 -37
- package/src/admin/ui.generated.ts +1 -1
- package/src/apps/composition.test.ts +66 -0
- package/src/apps/data/App.ts +295 -0
- package/src/apps/data/index.ts +2 -0
- package/src/apps/{activities.test.ts → data/routes/activities.test.ts} +3 -3
- package/src/apps/{activities.ts → data/routes/activities.ts} +15 -15
- package/src/apps/{addresses.ts → data/routes/addresses.ts} +6 -6
- package/src/apps/{balances.test.ts → data/routes/balances.test.ts} +6 -5
- package/src/apps/{balances.ts → data/routes/balances.ts} +46 -12
- package/src/apps/{blocks.test.ts → data/routes/blocks.test.ts} +4 -4
- package/src/apps/{blocks.ts → data/routes/blocks.ts} +14 -14
- package/src/apps/{coingecko.test.ts → data/routes/coingecko.test.ts} +2 -2
- package/src/apps/{coingecko.ts → data/routes/coingecko.ts} +14 -14
- package/src/apps/{exchanges.test.ts → data/routes/exchanges.test.ts} +2 -2
- package/src/apps/{exchanges.ts → data/routes/exchanges.ts} +20 -20
- package/src/apps/{fee-amm.test.ts → data/routes/fee-amm.test.ts} +3 -3
- package/src/apps/{fee-amm.ts → data/routes/fee-amm.ts} +18 -18
- package/src/apps/{indexer.test.ts → data/routes/indexer.test.ts} +27 -6
- package/src/apps/{indexer.ts → data/routes/indexer.ts} +13 -10
- package/src/apps/{receipts.test.ts → data/routes/receipts.test.ts} +4 -4
- package/src/apps/{receipts.ts → data/routes/receipts.ts} +13 -13
- package/src/apps/{rpc.test.ts → data/routes/rpc.test.ts} +142 -13
- package/src/apps/{rpc.ts → data/routes/rpc.ts} +7 -7
- package/src/apps/{tokenlist.test.ts → data/routes/tokenlist.test.ts} +8 -10
- package/src/apps/{tokenlist.ts → data/routes/tokenlist.ts} +9 -9
- package/src/apps/{tokens.test.ts → data/routes/tokens.test.ts} +6 -5
- package/src/apps/{tokens.ts → data/routes/tokens.ts} +20 -20
- package/src/apps/{transactions.test.ts → data/routes/transactions.test.ts} +4 -4
- package/src/apps/{transactions.ts → data/routes/transactions.ts} +15 -15
- package/src/apps/{transfers.test.ts → data/routes/transfers.test.ts} +3 -3
- package/src/apps/{transfers.ts → data/routes/transfers.ts} +15 -15
- package/src/apps/{verified-tokens.test.ts → data/routes/verified-tokens.test.ts} +27 -15
- package/src/apps/{verified-tokens.ts → data/routes/verified-tokens.ts} +10 -10
- package/src/apps/{webhooks.test.ts → data/routes/webhooks.test.ts} +137 -150
- package/src/apps/{webhooks.ts → data/routes/webhooks.ts} +83 -81
- package/src/apps/docs/App.ts +136 -0
- package/src/apps/docs/index.ts +1 -0
- package/src/apps/index.ts +3 -0
- package/src/apps/metadata.ts +23 -0
- package/src/apps/platform/App.ts +130 -0
- package/src/apps/platform/index.ts +1 -0
- package/src/apps/platform/routes/api-keys.test.ts +330 -0
- package/src/apps/platform/routes/api-keys.ts +427 -0
- package/src/apps/platform/routes/invitations.test.ts +361 -0
- package/src/apps/platform/routes/invitations.ts +519 -0
- package/src/apps/platform/routes/me.test.ts +121 -0
- package/src/apps/platform/routes/me.ts +106 -0
- package/src/apps/platform/routes/members.test.ts +195 -0
- package/src/apps/platform/routes/members.ts +313 -0
- package/src/apps/platform/routes/orgs.test.ts +313 -0
- package/src/apps/platform/routes/orgs.ts +343 -0
- package/src/apps/platform/routes/projects.test.ts +181 -0
- package/src/apps/platform/routes/projects.ts +367 -0
- package/src/apps/relay/App.test.ts +484 -0
- package/src/apps/relay/App.ts +128 -0
- package/src/apps/relay/Sponsorships.test.ts +375 -0
- package/src/apps/relay/Sponsorships.ts +305 -0
- package/src/apps/relay/index.ts +2 -0
- package/src/{Cli.test.ts → cli/Cli.test.ts} +10 -9
- package/src/{Cli.ts → cli/Cli.ts} +16 -9
- package/src/cli/bin.ts +4 -0
- package/src/cli/commands/admin.test.ts +71 -0
- package/src/cli/commands/admin.ts +60 -0
- package/src/cloudflare.ts +10 -0
- package/src/db/Db.test.ts +84 -0
- package/src/db/Db.ts +542 -0
- package/src/db/Schema.ts +301 -0
- package/src/db/tables/invitations.ts +198 -0
- package/src/db/tables/memberships.ts +208 -0
- package/src/db/tables/organizations.test.ts +160 -0
- package/src/db/tables/organizations.ts +232 -0
- package/src/db/tables/projects.ts +107 -0
- package/src/db/tables/sponsoredTransactions.test.ts +218 -0
- package/src/db/tables/sponsoredTransactions.ts +236 -0
- package/src/db/tables/users.ts +85 -0
- package/src/db/tables/verifiedTokens.ts +111 -0
- package/src/db/tables/webhookDeliveries.ts +159 -0
- package/src/db/tables/webhookSubscriptions.ts +358 -0
- package/src/handlers/internal/executionError.ts +207 -0
- package/src/handlers/internal/multisig.test.ts +818 -0
- package/src/handlers/internal/multisig.ts +823 -0
- package/src/handlers/internal/requestListener.ts +273 -0
- package/src/handlers/internal/sponsorship.ts +245 -0
- package/src/handlers/internal/types.ts +378 -0
- package/src/handlers/internal/utils.ts +153 -0
- package/src/handlers/relay.test.ts +2035 -0
- package/src/handlers/relay.ts +1623 -0
- package/src/index.ts +4 -2
- package/src/internal/Auth.test.ts +337 -21
- package/src/internal/Auth.ts +783 -44
- package/src/internal/Cursor.test.ts +3 -2
- package/src/internal/Log.test.ts +1 -1
- package/src/internal/Log.ts +11 -3
- package/src/internal/MetricSink.ts +1 -1
- package/src/internal/OpenApi.ts +0 -59
- package/src/internal/RateLimit.test.ts +1 -1
- package/src/internal/RpcSchema.ts +10 -0
- package/src/internal/Store.test.ts +150 -10
- package/src/internal/Store.ts +136 -11
- package/src/internal/Tidx.local.test.ts +1 -1
- package/src/internal/VerifiedTokens.test.ts +99 -115
- package/src/internal/VerifiedTokens.ts +123 -175
- package/src/internal/WebhookDestination.test.ts +1 -1
- package/src/internal/Webhooks.test.ts +111 -111
- package/src/internal/Webhooks.ts +103 -221
- package/dist/ApiKeySource.d.ts +0 -166
- package/dist/ApiKeySource.d.ts.map +0 -1
- package/dist/ApiKeySource.js +0 -234
- package/dist/ApiKeySource.js.map +0 -1
- package/dist/Cli.d.ts.map +0 -1
- package/dist/Cli.js +0 -13
- package/dist/Cli.js.map +0 -1
- package/dist/apps/activities.js.map +0 -1
- package/dist/apps/addresses.js.map +0 -1
- package/dist/apps/balances.d.ts.map +0 -1
- package/dist/apps/balances.js.map +0 -1
- package/dist/apps/blocks.d.ts.map +0 -1
- package/dist/apps/blocks.js.map +0 -1
- package/dist/apps/coingecko.d.ts.map +0 -1
- package/dist/apps/coingecko.js.map +0 -1
- package/dist/apps/exchanges.d.ts.map +0 -1
- package/dist/apps/exchanges.js.map +0 -1
- package/dist/apps/fee-amm.d.ts.map +0 -1
- package/dist/apps/fee-amm.js.map +0 -1
- package/dist/apps/indexer.d.ts.map +0 -1
- package/dist/apps/indexer.js.map +0 -1
- package/dist/apps/receipts.d.ts.map +0 -1
- package/dist/apps/receipts.js.map +0 -1
- package/dist/apps/rpc.d.ts.map +0 -1
- package/dist/apps/rpc.js.map +0 -1
- package/dist/apps/tokenlist.d.ts.map +0 -1
- package/dist/apps/tokenlist.js.map +0 -1
- package/dist/apps/tokens.d.ts.map +0 -1
- package/dist/apps/tokens.js.map +0 -1
- package/dist/apps/transactions.d.ts.map +0 -1
- package/dist/apps/transactions.js.map +0 -1
- package/dist/apps/transfers.d.ts.map +0 -1
- package/dist/apps/transfers.js.map +0 -1
- package/dist/apps/verified-tokens.d.ts.map +0 -1
- package/dist/apps/verified-tokens.js.map +0 -1
- package/dist/apps/webhooks.js.map +0 -1
- package/dist/internal/OpenApi.fonts.d.ts.map +0 -1
- package/dist/internal/OpenApi.fonts.js.map +0 -1
- package/dist/internal/OpenApi.logo.d.ts.map +0 -1
- package/dist/internal/OpenApi.logo.js.map +0 -1
- package/seeds/31318/icons/0x20c0000000000000000000000000000000000000.svg +0 -1
- package/seeds/31318/icons/0x20c0000000000000000000000000000000000001.svg +0 -1
- package/seeds/31318/icons/0x20c0000000000000000000000000000000000002.svg +0 -1
- package/seeds/31318/icons/0x20c0000000000000000000000000000000000003.svg +0 -1
- package/seeds/31318/verified-tokens.json +0 -30
- package/seeds/4217/icons/0x20c0000000000000000000000000000000000000.svg +0 -25
- package/seeds/4217/icons/0x20c000000000000000000000048c8f36df1c9a4a.svg +0 -1
- package/seeds/4217/icons/0x20c0000000000000000000000520792dcccccccc.svg +0 -1
- package/seeds/4217/icons/0x20c0000000000000000000000a6da882d075a4c3.svg +0 -4
- package/seeds/4217/icons/0x20c000000000000000000000111111111e910f0f.svg +0 -30
- package/seeds/4217/icons/0x20c00000000000000000000014f22ca97301eb73.svg +0 -1
- package/seeds/4217/icons/0x20c0000000000000000000001621e21f71cf12fb.svg +0 -1
- package/seeds/4217/icons/0x20c0000000000000000000002f52d5cc21a3207b.svg +0 -1
- package/seeds/4217/icons/0x20c0000000000000000000003158081efd85bfc2.svg +0 -11
- package/seeds/4217/icons/0x20c0000000000000000000003554d28269e0f3c2.svg +0 -1
- package/seeds/4217/icons/0x20c000000000000000000000383a23bacb546ab9.svg +0 -1
- package/seeds/4217/icons/0x20c00000000000000000000042109aef2f8b28e1.png +0 -0
- package/seeds/4217/icons/0x20c0000000000000000000005c0bac7cef389a11.svg +0 -1
- package/seeds/4217/icons/0x20c0000000000000000000006fd9a167923ba194.png +0 -0
- package/seeds/4217/icons/0x20c0000000000000000000007f7ba549dd0251b9.svg +0 -1
- package/seeds/4217/icons/0x20c0000000000000000000008191667423f70e67.svg +0 -5
- package/seeds/4217/icons/0x20c0000000000000000000008ee4fcff88888888.svg +0 -1
- package/seeds/4217/icons/0x20c0000000000000000000009a4a4b17e0dc6651.svg +0 -1
- package/seeds/4217/icons/0x20c000000000000000000000ab02d39df30bd17e.svg +0 -1
- package/seeds/4217/icons/0x20c000000000000000000000ae247a1130450f09.svg +0 -1
- package/seeds/4217/icons/0x20c000000000000000000000aeed2ec36a54d0e5.svg +0 -1
- package/seeds/4217/icons/0x20c000000000000000000000b9537d11c60e8b50.svg +0 -1
- package/seeds/4217/icons/0x20c000000000000000000000bd95bfb69fbe6ce3.svg +0 -1
- package/seeds/4217/icons/0x20c000000000000000000000c412ec89d0c08be5.svg +0 -1
- package/seeds/4217/icons/0x20c000000000000000000000f047dd7018e50367.png +0 -0
- package/seeds/4217/verified-tokens.json +0 -177
- package/seeds/42431/icons/0x20c0000000000000000000000000000000000000.svg +0 -25
- package/seeds/42431/icons/0x20c0000000000000000000000000000000000001.svg +0 -1
- package/seeds/42431/icons/0x20c0000000000000000000000000000000000002.svg +0 -1
- package/seeds/42431/icons/0x20c0000000000000000000000000000000000003.svg +0 -1
- package/seeds/42431/icons/0x20c0000000000000000000009e8d7eb59b783726.svg +0 -1
- package/seeds/42431/icons/0x20c000000000000000000000d72572838bbee59c.svg +0 -1
- package/seeds/42431/verified-tokens.json +0 -44
- package/seeds/openrpc/README.md +0 -27
- package/seeds/openrpc/execution-apis.json +0 -8989
- package/src/ApiKeySource.test-d.ts +0 -11
- package/src/ApiKeySource.test.ts +0 -295
- package/src/ApiKeySource.ts +0 -303
- /package/src/{internal/OpenApi.fonts.ts → apps/docs/fonts.ts} +0 -0
- /package/src/{internal/OpenApi.logo.ts → apps/docs/logo.ts} +0 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import type { Selectable } from 'kysely'
|
|
2
|
+
|
|
3
|
+
import type * as Webhooks from '../../internal/Webhooks.js'
|
|
4
|
+
import type * as Db from '../Db.js'
|
|
5
|
+
import type * as db_Schema from '../Schema.js'
|
|
6
|
+
|
|
7
|
+
/** Columns of the `webhook_deliveries` table, derived from `Schema.WebhookDelivery`. */
|
|
8
|
+
export type Table = db_Schema.WebhookDelivery
|
|
9
|
+
|
|
10
|
+
/** A stored webhook-delivery row. */
|
|
11
|
+
export type Record = Selectable<Table>
|
|
12
|
+
|
|
13
|
+
/** Maps a stored row to the domain delivery (null columns → absent fields). */
|
|
14
|
+
export function toDelivery(row: Record): Webhooks.Delivery {
|
|
15
|
+
return {
|
|
16
|
+
attempt: row.attempt,
|
|
17
|
+
createdAt: row.createdAt,
|
|
18
|
+
envelope: row.envelope,
|
|
19
|
+
...(row.error === null ? {} : { error: row.error }),
|
|
20
|
+
eventId: row.eventId,
|
|
21
|
+
id: row.id,
|
|
22
|
+
requestUrl: row.requestUrl,
|
|
23
|
+
...(row.responseMs === null ? {} : { responseMs: row.responseMs }),
|
|
24
|
+
...(row.responseStatus === null ? {} : { responseStatus: row.responseStatus }),
|
|
25
|
+
status: row.status,
|
|
26
|
+
subscriptionId: row.subscriptionId,
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Inserts a delivery row from its domain value.
|
|
32
|
+
*
|
|
33
|
+
* @param db - The database.
|
|
34
|
+
* @param delivery - The delivery to insert.
|
|
35
|
+
* @param expiresAt - Retention deadline (ISO); the row is invisible past it.
|
|
36
|
+
*/
|
|
37
|
+
export async function insert(
|
|
38
|
+
db: Db.Db,
|
|
39
|
+
delivery: Webhooks.Delivery,
|
|
40
|
+
expiresAt: string,
|
|
41
|
+
): Promise<void> {
|
|
42
|
+
await db.kysely
|
|
43
|
+
.insertInto('webhook_deliveries')
|
|
44
|
+
.values({
|
|
45
|
+
attempt: delivery.attempt,
|
|
46
|
+
createdAt: delivery.createdAt,
|
|
47
|
+
envelope: delivery.envelope,
|
|
48
|
+
error: delivery.error ?? null,
|
|
49
|
+
eventId: delivery.eventId,
|
|
50
|
+
expiresAt,
|
|
51
|
+
id: delivery.id,
|
|
52
|
+
requestUrl: delivery.requestUrl,
|
|
53
|
+
responseMs: delivery.responseMs ?? null,
|
|
54
|
+
responseStatus: delivery.responseStatus ?? null,
|
|
55
|
+
status: delivery.status,
|
|
56
|
+
subscriptionId: delivery.subscriptionId,
|
|
57
|
+
})
|
|
58
|
+
.execute()
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Lists a subscription's unexpired deliveries, newest first, with keyset
|
|
63
|
+
* paging (`id < cursor` — ids embed a zero-padded timestamp, so lexical order
|
|
64
|
+
* is chronological).
|
|
65
|
+
*
|
|
66
|
+
* @param db - The database.
|
|
67
|
+
* @param subscriptionId - The owning subscription id (`wh_…`).
|
|
68
|
+
* @param options - Paging options plus the retention timestamp.
|
|
69
|
+
* @returns The deliveries.
|
|
70
|
+
*/
|
|
71
|
+
export async function list(
|
|
72
|
+
db: Db.Db,
|
|
73
|
+
subscriptionId: string,
|
|
74
|
+
options: list.Options,
|
|
75
|
+
): Promise<Webhooks.Delivery[]> {
|
|
76
|
+
let query = db.kysely
|
|
77
|
+
.selectFrom('webhook_deliveries')
|
|
78
|
+
.selectAll()
|
|
79
|
+
.where('subscriptionId', '=', subscriptionId)
|
|
80
|
+
.where('expiresAt', '>', options.now)
|
|
81
|
+
.orderBy('id', 'desc')
|
|
82
|
+
if (options.cursor) query = query.where('id', '<', options.cursor)
|
|
83
|
+
if (options.offset) query = query.offset(options.offset)
|
|
84
|
+
if (options.limit !== undefined) query = query.limit(options.limit)
|
|
85
|
+
return (await query.execute()).map(toDelivery)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export declare namespace list {
|
|
89
|
+
/** Options for {@link list}. */
|
|
90
|
+
type Options = {
|
|
91
|
+
/** Return deliveries whose id sorts before this one (older entries). */
|
|
92
|
+
cursor?: string | undefined
|
|
93
|
+
/** Maximum deliveries to return. */
|
|
94
|
+
limit?: number | undefined
|
|
95
|
+
/** ISO timestamp retention is evaluated against. */
|
|
96
|
+
now: string
|
|
97
|
+
/** Rows to skip from the head (positional pagination; exclusive with `cursor`). */
|
|
98
|
+
offset?: number | undefined
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Counts a subscription's unexpired deliveries.
|
|
104
|
+
*
|
|
105
|
+
* @param db - The database.
|
|
106
|
+
* @param subscriptionId - The owning subscription id (`wh_…`).
|
|
107
|
+
* @param now - ISO timestamp retention is evaluated against.
|
|
108
|
+
* @returns The count.
|
|
109
|
+
*/
|
|
110
|
+
export async function count(db: Db.Db, subscriptionId: string, now: string): Promise<number> {
|
|
111
|
+
const row = await db.kysely
|
|
112
|
+
.selectFrom('webhook_deliveries')
|
|
113
|
+
.select((eb) => eb.fn.countAll().as('count'))
|
|
114
|
+
.where('subscriptionId', '=', subscriptionId)
|
|
115
|
+
.where('expiresAt', '>', now)
|
|
116
|
+
.executeTakeFirstOrThrow()
|
|
117
|
+
return Number(row.count)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Reads a single unexpired delivery scoped to its subscription.
|
|
122
|
+
*
|
|
123
|
+
* @param db - The database.
|
|
124
|
+
* @param subscriptionId - The owning subscription id (`wh_…`).
|
|
125
|
+
* @param deliveryId - The delivery id (`whd_…`).
|
|
126
|
+
* @param now - ISO timestamp retention is evaluated against.
|
|
127
|
+
* @returns The delivery, or `null` when absent.
|
|
128
|
+
*/
|
|
129
|
+
export async function get(
|
|
130
|
+
db: Db.Db,
|
|
131
|
+
subscriptionId: string,
|
|
132
|
+
deliveryId: string,
|
|
133
|
+
now: string,
|
|
134
|
+
): Promise<Webhooks.Delivery | null> {
|
|
135
|
+
const row = await db.kysely
|
|
136
|
+
.selectFrom('webhook_deliveries')
|
|
137
|
+
.selectAll()
|
|
138
|
+
.where('subscriptionId', '=', subscriptionId)
|
|
139
|
+
.where('id', '=', deliveryId)
|
|
140
|
+
.where('expiresAt', '>', now)
|
|
141
|
+
.executeTakeFirst()
|
|
142
|
+
return row ? toDelivery(row) : null
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Deletes deliveries past their retention deadline. Called best-effort from
|
|
147
|
+
* the poller tick.
|
|
148
|
+
*
|
|
149
|
+
* @param db - The database.
|
|
150
|
+
* @param now - ISO timestamp retention is evaluated against.
|
|
151
|
+
* @returns The number of rows deleted.
|
|
152
|
+
*/
|
|
153
|
+
export async function pruneExpired(db: Db.Db, now: string): Promise<number> {
|
|
154
|
+
const result = await db.kysely
|
|
155
|
+
.deleteFrom('webhook_deliveries')
|
|
156
|
+
.where('expiresAt', '<=', now)
|
|
157
|
+
.executeTakeFirst()
|
|
158
|
+
return Number(result.numDeletedRows)
|
|
159
|
+
}
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
import type { ExpressionBuilder, Selectable } from 'kysely'
|
|
2
|
+
import { sql } from 'kysely'
|
|
3
|
+
|
|
4
|
+
import type * as Webhooks from '../../internal/Webhooks.js'
|
|
5
|
+
import type * as Db from '../Db.js'
|
|
6
|
+
import type * as db_Schema from '../Schema.js'
|
|
7
|
+
|
|
8
|
+
/** Columns of the `webhook_subscriptions` table, derived from `Schema.WebhookSubscription`. */
|
|
9
|
+
export type Table = db_Schema.WebhookSubscription
|
|
10
|
+
|
|
11
|
+
/** A stored webhook-subscription row. */
|
|
12
|
+
export type Record = Selectable<Table>
|
|
13
|
+
|
|
14
|
+
/** Maps an owner union to its stored `ownerId` column value. */
|
|
15
|
+
export function ownerId(owner: Webhooks.Owner): string {
|
|
16
|
+
return owner.type === 'api_key' ? owner.orgId : owner.payer
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Maps a stored row to the domain subscription (null columns → absent fields). */
|
|
20
|
+
export function toSubscription(row: Record): Webhooks.Subscription {
|
|
21
|
+
return {
|
|
22
|
+
chainId: row.chainId,
|
|
23
|
+
...(row.context === null ? {} : { context: row.context }),
|
|
24
|
+
createdAt: row.createdAt,
|
|
25
|
+
destination: row.destination,
|
|
26
|
+
eventType: row.eventType,
|
|
27
|
+
...(row.expiresAt === null ? {} : { expiresAt: row.expiresAt }),
|
|
28
|
+
failureCount: row.failureCount,
|
|
29
|
+
filters: row.filters,
|
|
30
|
+
id: row.id,
|
|
31
|
+
...(row.lastDeliveryAt === null ? {} : { lastDeliveryAt: row.lastDeliveryAt }),
|
|
32
|
+
owner:
|
|
33
|
+
row.ownerType === 'api_key'
|
|
34
|
+
? { orgId: row.ownerId, type: 'api_key' }
|
|
35
|
+
: { payer: row.ownerId, type: 'mpp' },
|
|
36
|
+
secret: row.secret,
|
|
37
|
+
status: row.status,
|
|
38
|
+
updatedAt: row.updatedAt,
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Inserts a subscription row from its domain value.
|
|
44
|
+
*
|
|
45
|
+
* @param db - The database.
|
|
46
|
+
* @param subscription - The subscription to insert.
|
|
47
|
+
*/
|
|
48
|
+
export async function insert(db: Db.Db, subscription: Webhooks.Subscription): Promise<void> {
|
|
49
|
+
await db.kysely
|
|
50
|
+
.insertInto('webhook_subscriptions')
|
|
51
|
+
.values({
|
|
52
|
+
chainId: subscription.chainId,
|
|
53
|
+
context: subscription.context ?? null,
|
|
54
|
+
createdAt: subscription.createdAt,
|
|
55
|
+
destination: subscription.destination,
|
|
56
|
+
eventType: subscription.eventType,
|
|
57
|
+
expiresAt: subscription.expiresAt ?? null,
|
|
58
|
+
failureCount: subscription.failureCount,
|
|
59
|
+
filters: subscription.filters,
|
|
60
|
+
id: subscription.id,
|
|
61
|
+
lastDeliveryAt: subscription.lastDeliveryAt ?? null,
|
|
62
|
+
ownerId: ownerId(subscription.owner),
|
|
63
|
+
ownerType: subscription.owner.type,
|
|
64
|
+
pollerCursor: null,
|
|
65
|
+
secret: subscription.secret,
|
|
66
|
+
status: subscription.status,
|
|
67
|
+
updatedAt: subscription.updatedAt,
|
|
68
|
+
})
|
|
69
|
+
.execute()
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Reads an owner's subscription by id; expired rows never match (query-time
|
|
74
|
+
* expiry, same read semantics as the old store TTL).
|
|
75
|
+
*
|
|
76
|
+
* @param db - The database.
|
|
77
|
+
* @param owner - The authenticated owner.
|
|
78
|
+
* @param id - The subscription id (`wh_…`).
|
|
79
|
+
* @param now - ISO timestamp expiry is evaluated against.
|
|
80
|
+
* @returns The subscription, or `null` when absent (or not the owner's).
|
|
81
|
+
*/
|
|
82
|
+
export async function get(
|
|
83
|
+
db: Db.Db,
|
|
84
|
+
owner: Webhooks.Owner,
|
|
85
|
+
id: string,
|
|
86
|
+
now: string,
|
|
87
|
+
): Promise<Webhooks.Subscription | null> {
|
|
88
|
+
const row = await db.kysely
|
|
89
|
+
.selectFrom('webhook_subscriptions')
|
|
90
|
+
.selectAll()
|
|
91
|
+
.where('id', '=', id)
|
|
92
|
+
.where('ownerType', '=', owner.type)
|
|
93
|
+
.where('ownerId', '=', ownerId(owner))
|
|
94
|
+
.where(live(now))
|
|
95
|
+
.executeTakeFirst()
|
|
96
|
+
return row ? toSubscription(row) : null
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Lists an owner's live subscriptions, newest first, with keyset paging
|
|
101
|
+
* (`id < cursor` — ids embed a zero-padded timestamp, so lexical order is
|
|
102
|
+
* chronological).
|
|
103
|
+
*
|
|
104
|
+
* @param db - The database.
|
|
105
|
+
* @param owner - The authenticated owner.
|
|
106
|
+
* @param options - Paging options plus the expiry timestamp.
|
|
107
|
+
* @returns The subscriptions.
|
|
108
|
+
*/
|
|
109
|
+
export async function list(
|
|
110
|
+
db: Db.Db,
|
|
111
|
+
owner: Webhooks.Owner,
|
|
112
|
+
options: list.Options,
|
|
113
|
+
): Promise<Webhooks.Subscription[]> {
|
|
114
|
+
let query = db.kysely
|
|
115
|
+
.selectFrom('webhook_subscriptions')
|
|
116
|
+
.selectAll()
|
|
117
|
+
.where('ownerType', '=', owner.type)
|
|
118
|
+
.where('ownerId', '=', ownerId(owner))
|
|
119
|
+
.where(live(options.now))
|
|
120
|
+
.orderBy('id', 'desc')
|
|
121
|
+
if (options.cursor) query = query.where('id', '<', options.cursor)
|
|
122
|
+
if (options.offset) query = query.offset(options.offset)
|
|
123
|
+
if (options.limit !== undefined) query = query.limit(options.limit)
|
|
124
|
+
return (await query.execute()).map(toSubscription)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export declare namespace list {
|
|
128
|
+
/** Options for {@link list}. */
|
|
129
|
+
type Options = {
|
|
130
|
+
/** Return subscriptions older than this id (keyset paging, newest first). */
|
|
131
|
+
cursor?: string | undefined
|
|
132
|
+
/** Maximum subscriptions to return. */
|
|
133
|
+
limit?: number | undefined
|
|
134
|
+
/** ISO timestamp expiry is evaluated against. */
|
|
135
|
+
now: string
|
|
136
|
+
/** Rows to skip from the head (positional pagination; exclusive with `cursor`). */
|
|
137
|
+
offset?: number | undefined
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Counts an owner's live subscriptions.
|
|
143
|
+
*
|
|
144
|
+
* @param db - The database.
|
|
145
|
+
* @param owner - The authenticated owner.
|
|
146
|
+
* @param now - ISO timestamp expiry is evaluated against.
|
|
147
|
+
* @returns The count.
|
|
148
|
+
*/
|
|
149
|
+
export async function count(db: Db.Db, owner: Webhooks.Owner, now: string): Promise<number> {
|
|
150
|
+
const row = await db.kysely
|
|
151
|
+
.selectFrom('webhook_subscriptions')
|
|
152
|
+
.select((eb) => eb.fn.countAll().as('count'))
|
|
153
|
+
.where('ownerType', '=', owner.type)
|
|
154
|
+
.where('ownerId', '=', ownerId(owner))
|
|
155
|
+
.where(live(now))
|
|
156
|
+
.executeTakeFirstOrThrow()
|
|
157
|
+
return Number(row.count)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Applies a column patch to a subscription. Only the provided columns are
|
|
162
|
+
* written; `context: null` clears the stored context.
|
|
163
|
+
*
|
|
164
|
+
* @param db - The database.
|
|
165
|
+
* @param id - The subscription id (`wh_…`).
|
|
166
|
+
* @param set - The columns to write.
|
|
167
|
+
* @returns The updated row's subscription, or `undefined` when absent.
|
|
168
|
+
*/
|
|
169
|
+
export async function update(
|
|
170
|
+
db: Db.Db,
|
|
171
|
+
id: string,
|
|
172
|
+
set: update.Set,
|
|
173
|
+
): Promise<Webhooks.Subscription | undefined> {
|
|
174
|
+
const row = await db.kysely
|
|
175
|
+
.updateTable('webhook_subscriptions')
|
|
176
|
+
.set(set)
|
|
177
|
+
.where('id', '=', id)
|
|
178
|
+
.returningAll()
|
|
179
|
+
.executeTakeFirst()
|
|
180
|
+
return row ? toSubscription(row) : undefined
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export declare namespace update {
|
|
184
|
+
/** Columns writable by a subscription patch. */
|
|
185
|
+
type Set = {
|
|
186
|
+
/** New human context; null clears it. */
|
|
187
|
+
context?: Webhooks.Context | null | undefined
|
|
188
|
+
/** New delivery destination. */
|
|
189
|
+
destination?: Webhooks.Destination | undefined
|
|
190
|
+
/** New filter predicates. */
|
|
191
|
+
filters?: Webhooks.Subscription['filters'] | undefined
|
|
192
|
+
/** New lifecycle status. */
|
|
193
|
+
status?: Webhooks.Status | undefined
|
|
194
|
+
/** Mutation timestamp (ISO). */
|
|
195
|
+
updatedAt: string
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Deletes an owner's live subscription; delivery rows cascade via the FK.
|
|
201
|
+
*
|
|
202
|
+
* @param db - The database.
|
|
203
|
+
* @param owner - The authenticated owner.
|
|
204
|
+
* @param id - The subscription id (`wh_…`).
|
|
205
|
+
* @param now - ISO timestamp expiry is evaluated against.
|
|
206
|
+
* @returns Whether a row was deleted.
|
|
207
|
+
*/
|
|
208
|
+
export async function remove(
|
|
209
|
+
db: Db.Db,
|
|
210
|
+
owner: Webhooks.Owner,
|
|
211
|
+
id: string,
|
|
212
|
+
now: string,
|
|
213
|
+
): Promise<boolean> {
|
|
214
|
+
const result = await db.kysely
|
|
215
|
+
.deleteFrom('webhook_subscriptions')
|
|
216
|
+
.where('id', '=', id)
|
|
217
|
+
.where('ownerType', '=', owner.type)
|
|
218
|
+
.where('ownerId', '=', ownerId(owner))
|
|
219
|
+
.where(live(now))
|
|
220
|
+
.executeTakeFirst()
|
|
221
|
+
return result.numDeletedRows > 0n
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Lists live `active` subscriptions for a `(chainId, eventType)` stream — the
|
|
226
|
+
* poller's per-stream lookup, served by the partial status index.
|
|
227
|
+
*
|
|
228
|
+
* @param db - The database.
|
|
229
|
+
* @param chainId - Chain the stream belongs to.
|
|
230
|
+
* @param eventType - Event type of the stream.
|
|
231
|
+
* @param now - ISO timestamp expiry is evaluated against.
|
|
232
|
+
* @returns The subscriptions, in id (chronological) order.
|
|
233
|
+
*/
|
|
234
|
+
export async function listActive(
|
|
235
|
+
db: Db.Db,
|
|
236
|
+
chainId: number,
|
|
237
|
+
eventType: Webhooks.EventType,
|
|
238
|
+
now: string,
|
|
239
|
+
): Promise<Webhooks.Subscription[]> {
|
|
240
|
+
const rows = await db.kysely
|
|
241
|
+
.selectFrom('webhook_subscriptions')
|
|
242
|
+
.selectAll()
|
|
243
|
+
.where('chainId', '=', chainId)
|
|
244
|
+
.where('eventType', '=', eventType)
|
|
245
|
+
.where('status', '=', 'active')
|
|
246
|
+
.where(live(now))
|
|
247
|
+
.orderBy('id')
|
|
248
|
+
.execute()
|
|
249
|
+
return rows.map(toSubscription)
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Reads a subscription's poller cursor.
|
|
254
|
+
*
|
|
255
|
+
* @param db - The database.
|
|
256
|
+
* @param id - The subscription id (`wh_…`).
|
|
257
|
+
* @returns The cursor, or `null` when unset (or the row is absent).
|
|
258
|
+
*/
|
|
259
|
+
export async function getCursor(db: Db.Db, id: string): Promise<string | null> {
|
|
260
|
+
const row = await db.kysely
|
|
261
|
+
.selectFrom('webhook_subscriptions')
|
|
262
|
+
.select('pollerCursor')
|
|
263
|
+
.where('id', '=', id)
|
|
264
|
+
.executeTakeFirst()
|
|
265
|
+
return row?.pollerCursor ?? null
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Writes a subscription's poller cursor. Deliberately does not touch
|
|
270
|
+
* `updatedAt` — the cursor advances every tick and is not a user mutation.
|
|
271
|
+
*
|
|
272
|
+
* @param db - The database.
|
|
273
|
+
* @param id - The subscription id (`wh_…`).
|
|
274
|
+
* @param cursor - The keyset cursor to store.
|
|
275
|
+
*/
|
|
276
|
+
export async function setCursor(db: Db.Db, id: string, cursor: string): Promise<void> {
|
|
277
|
+
await db.kysely
|
|
278
|
+
.updateTable('webhook_subscriptions')
|
|
279
|
+
.set({ pollerCursor: cursor })
|
|
280
|
+
.where('id', '=', id)
|
|
281
|
+
.execute()
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Records a successful delivery: resets the consecutive-failure counter and
|
|
286
|
+
* stamps `lastDeliveryAt`.
|
|
287
|
+
*
|
|
288
|
+
* @param db - The database.
|
|
289
|
+
* @param id - The subscription id (`wh_…`).
|
|
290
|
+
* @param now - Delivery timestamp (ISO).
|
|
291
|
+
* @returns The updated subscription, or `undefined` when the row is absent.
|
|
292
|
+
*/
|
|
293
|
+
export async function recordSuccess(
|
|
294
|
+
db: Db.Db,
|
|
295
|
+
id: string,
|
|
296
|
+
now: string,
|
|
297
|
+
): Promise<Webhooks.Subscription | undefined> {
|
|
298
|
+
const row = await db.kysely
|
|
299
|
+
.updateTable('webhook_subscriptions')
|
|
300
|
+
.set({ failureCount: 0, lastDeliveryAt: now, updatedAt: now })
|
|
301
|
+
.where('id', '=', id)
|
|
302
|
+
.returningAll()
|
|
303
|
+
.executeTakeFirst()
|
|
304
|
+
return row ? toSubscription(row) : undefined
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Records a failed delivery: atomically increments the consecutive-failure
|
|
309
|
+
* counter and disables the subscription once it reaches `maxFailures` (raw
|
|
310
|
+
* fragments use storage column names — they bypass the camelCase mapping).
|
|
311
|
+
*
|
|
312
|
+
* @param db - The database.
|
|
313
|
+
* @param id - The subscription id (`wh_…`).
|
|
314
|
+
* @param maxFailures - Consecutive failures before auto-disabling.
|
|
315
|
+
* @param now - Failure timestamp (ISO).
|
|
316
|
+
* @returns The updated subscription, or `undefined` when the row is absent.
|
|
317
|
+
*/
|
|
318
|
+
export async function recordFailure(
|
|
319
|
+
db: Db.Db,
|
|
320
|
+
id: string,
|
|
321
|
+
maxFailures: number,
|
|
322
|
+
now: string,
|
|
323
|
+
): Promise<Webhooks.Subscription | undefined> {
|
|
324
|
+
const row = await db.kysely
|
|
325
|
+
.updateTable('webhook_subscriptions')
|
|
326
|
+
.set({
|
|
327
|
+
failureCount: sql`failure_count + 1`,
|
|
328
|
+
status: sql`CASE WHEN failure_count + 1 >= ${maxFailures} THEN 'disabled' ELSE status END`,
|
|
329
|
+
updatedAt: now,
|
|
330
|
+
})
|
|
331
|
+
.where('id', '=', id)
|
|
332
|
+
.returningAll()
|
|
333
|
+
.executeTakeFirst()
|
|
334
|
+
return row ? toSubscription(row) : undefined
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Deletes expired subscriptions (their delivery rows cascade). Called
|
|
339
|
+
* best-effort from the poller tick.
|
|
340
|
+
*
|
|
341
|
+
* @param db - The database.
|
|
342
|
+
* @param now - ISO timestamp expiry is evaluated against.
|
|
343
|
+
* @returns The number of rows deleted.
|
|
344
|
+
*/
|
|
345
|
+
export async function pruneExpired(db: Db.Db, now: string): Promise<number> {
|
|
346
|
+
const result = await db.kysely
|
|
347
|
+
.deleteFrom('webhook_subscriptions')
|
|
348
|
+
.where('expiresAt', 'is not', null)
|
|
349
|
+
.where('expiresAt', '<=', now)
|
|
350
|
+
.executeTakeFirst()
|
|
351
|
+
return Number(result.numDeletedRows)
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/** Live-row predicate: no expiry, or expiry strictly in the future. */
|
|
355
|
+
function live(now: string) {
|
|
356
|
+
return (eb: ExpressionBuilder<Db.Database, 'webhook_subscriptions'>) =>
|
|
357
|
+
eb.or([eb('expiresAt', 'is', null), eb('expiresAt', '>', now)])
|
|
358
|
+
}
|