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
package/src/internal/Webhooks.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { nanoid } from 'nanoid'
|
|
2
2
|
import { Hash, Hex } from 'ox'
|
|
3
3
|
|
|
4
|
-
import type * as app_Webhooks from '../apps/webhooks.js'
|
|
4
|
+
import type * as app_Webhooks from '../apps/data/routes/webhooks.js'
|
|
5
|
+
import type * as Db from '../db/Db.js'
|
|
6
|
+
import * as WebhookDeliveries from '../db/tables/webhookDeliveries.js'
|
|
7
|
+
import * as WebhookSubscriptions from '../db/tables/webhookSubscriptions.js'
|
|
5
8
|
import type * as Metrics from '../Metrics.js'
|
|
6
9
|
import * as MetricSink from './MetricSink.js'
|
|
7
|
-
import * as Store from './Store.js'
|
|
8
10
|
import * as WebhookDestination from './WebhookDestination.js'
|
|
9
11
|
|
|
10
12
|
// The destination layer lives in `./WebhookDestination.js`. Re-export only the
|
|
@@ -159,22 +161,24 @@ export type Delivery = {
|
|
|
159
161
|
|
|
160
162
|
/**
|
|
161
163
|
* Creates a subscription, validating its URL and (optionally) enforcing a
|
|
162
|
-
* per-owner cap, then persists it
|
|
164
|
+
* per-owner cap, then persists it. The cap check stays best-effort (count then
|
|
165
|
+
* insert, non-transactional) — parity with the old store behavior.
|
|
163
166
|
*/
|
|
164
167
|
export async function createSubscription(
|
|
165
|
-
|
|
168
|
+
db: Db.Db,
|
|
166
169
|
input: CreateInput,
|
|
167
170
|
options: createSubscription.Options = {},
|
|
168
171
|
): Promise<Subscription> {
|
|
169
172
|
WebhookDestination.assertDestination(input.destination)
|
|
170
173
|
|
|
174
|
+
const now = (options.now ?? (() => new Date()))()
|
|
175
|
+
const iso = now.toISOString()
|
|
176
|
+
|
|
171
177
|
if (options.maxPerOwner !== undefined) {
|
|
172
|
-
const existing = await
|
|
173
|
-
if (existing
|
|
178
|
+
const existing = await WebhookSubscriptions.count(db, input.owner, iso)
|
|
179
|
+
if (existing >= options.maxPerOwner) throw new LimitExceededError(options.maxPerOwner)
|
|
174
180
|
}
|
|
175
181
|
|
|
176
|
-
const now = (options.now ?? (() => new Date()))()
|
|
177
|
-
const iso = now.toISOString()
|
|
178
182
|
const subscription: Subscription = {
|
|
179
183
|
chainId: input.chainId,
|
|
180
184
|
...(input.context === undefined ? {} : { context: input.context }),
|
|
@@ -193,7 +197,7 @@ export async function createSubscription(
|
|
|
193
197
|
: { expiresAt: new Date(now.getTime() + input.ttl).toISOString() }),
|
|
194
198
|
}
|
|
195
199
|
|
|
196
|
-
await
|
|
200
|
+
await WebhookSubscriptions.insert(db, subscription)
|
|
197
201
|
return subscription
|
|
198
202
|
}
|
|
199
203
|
|
|
@@ -209,39 +213,23 @@ export declare namespace createSubscription {
|
|
|
209
213
|
|
|
210
214
|
/** Reads a single subscription scoped to its owner. Returns null when absent. */
|
|
211
215
|
export async function getSubscription(
|
|
212
|
-
|
|
216
|
+
db: Db.Db,
|
|
213
217
|
owner: Owner,
|
|
214
218
|
id: string,
|
|
215
219
|
): Promise<Subscription | null> {
|
|
216
|
-
return
|
|
220
|
+
return WebhookSubscriptions.get(db, owner, id, new Date().toISOString())
|
|
217
221
|
}
|
|
218
222
|
|
|
219
223
|
/**
|
|
220
224
|
* Lists an owner's subscriptions, newest first, with optional keyset paging.
|
|
221
|
-
* Subscription ids embed a timestamp, so lexical
|
|
225
|
+
* Subscription ids embed a timestamp, so lexical id order is chronological.
|
|
222
226
|
*/
|
|
223
227
|
export async function listSubscriptions(
|
|
224
|
-
|
|
228
|
+
db: Db.Db,
|
|
225
229
|
owner: Owner,
|
|
226
230
|
options: listSubscriptions.Options = {},
|
|
227
231
|
): Promise<Subscription[]> {
|
|
228
|
-
|
|
229
|
-
const { keys } = await store.list({ prefix })
|
|
230
|
-
|
|
231
|
-
// Newest first: ids sort chronologically ascending, so reverse for descending.
|
|
232
|
-
let names = keys
|
|
233
|
-
.map((key) => key.name)
|
|
234
|
-
.sort()
|
|
235
|
-
.reverse()
|
|
236
|
-
if (options.cursor) names = names.filter((name) => name < `${prefix}${options.cursor}`)
|
|
237
|
-
if (options.offset) names = names.slice(options.offset)
|
|
238
|
-
if (options.limit !== undefined) names = names.slice(0, options.limit)
|
|
239
|
-
|
|
240
|
-
// Hydrate the page in parallel: the reads are independent, and a serial
|
|
241
|
-
// loop costs one store round trip per row (an N+1 against the production
|
|
242
|
-
// Durable Object).
|
|
243
|
-
const subscriptions = await Promise.all(names.map((name) => readSubscription(store, name)))
|
|
244
|
-
return subscriptions.filter((subscription) => subscription !== null)
|
|
232
|
+
return WebhookSubscriptions.list(db, owner, { ...options, now: new Date().toISOString() })
|
|
245
233
|
}
|
|
246
234
|
|
|
247
235
|
export declare namespace listSubscriptions {
|
|
@@ -257,47 +245,41 @@ export declare namespace listSubscriptions {
|
|
|
257
245
|
}
|
|
258
246
|
|
|
259
247
|
/**
|
|
260
|
-
* Counts an owner's subscriptions
|
|
261
|
-
* prefix (no row hydration), so it's a single store `list` — exact and cheap,
|
|
248
|
+
* Counts an owner's subscriptions — a single indexed count, exact and cheap,
|
|
262
249
|
* since the per-owner set is bounded by `maxPerOwner`. Feeds the opt-in
|
|
263
250
|
* `meta.totalCount` on `GET /webhooks`.
|
|
264
251
|
*/
|
|
265
|
-
export async function countSubscriptions(
|
|
266
|
-
|
|
267
|
-
return keys.length
|
|
252
|
+
export async function countSubscriptions(db: Db.Db, owner: Owner): Promise<number> {
|
|
253
|
+
return WebhookSubscriptions.count(db, owner, new Date().toISOString())
|
|
268
254
|
}
|
|
269
255
|
|
|
270
256
|
/**
|
|
271
|
-
* Patches an owner's subscription, re-validating the URL when changed
|
|
272
|
-
*
|
|
257
|
+
* Patches an owner's subscription, re-validating the URL when changed.
|
|
258
|
+
* Returns null when absent. The status column drives the poller's partial
|
|
259
|
+
* index, so no secondary-index maintenance is needed.
|
|
273
260
|
*/
|
|
274
261
|
export async function updateSubscription(
|
|
275
|
-
|
|
262
|
+
db: Db.Db,
|
|
276
263
|
owner: Owner,
|
|
277
264
|
id: string,
|
|
278
265
|
patch: PatchInput,
|
|
279
266
|
options: updateSubscription.Options = {},
|
|
280
267
|
): Promise<Subscription | null> {
|
|
281
|
-
const current = await getSubscription(
|
|
268
|
+
const current = await getSubscription(db, owner, id)
|
|
282
269
|
if (!current) return null
|
|
283
270
|
|
|
284
271
|
if (patch.destination !== undefined) WebhookDestination.assertDestination(patch.destination)
|
|
285
272
|
|
|
286
273
|
const now = (options.now ?? (() => new Date()))()
|
|
287
|
-
const next
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
...(patch.context === undefined
|
|
291
|
-
? {}
|
|
292
|
-
: { context: patch.context === null ? undefined : patch.context }),
|
|
274
|
+
const next = await WebhookSubscriptions.update(db, id, {
|
|
275
|
+
// `context: null` clears it (stored as a null column; drops from reads).
|
|
276
|
+
...(patch.context === undefined ? {} : { context: patch.context }),
|
|
293
277
|
...(patch.destination === undefined ? {} : { destination: patch.destination }),
|
|
294
278
|
...(patch.filters === undefined ? {} : { filters: patch.filters }),
|
|
295
279
|
...(patch.status === undefined ? {} : { status: patch.status }),
|
|
296
280
|
updatedAt: now.toISOString(),
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
await writeSubscription(store, next)
|
|
300
|
-
return next
|
|
281
|
+
})
|
|
282
|
+
return next ?? null
|
|
301
283
|
}
|
|
302
284
|
|
|
303
285
|
export declare namespace updateSubscription {
|
|
@@ -308,61 +290,51 @@ export declare namespace updateSubscription {
|
|
|
308
290
|
}
|
|
309
291
|
}
|
|
310
292
|
|
|
311
|
-
/** Deletes an owner's subscription
|
|
312
|
-
export async function deleteSubscription(
|
|
313
|
-
|
|
314
|
-
owner: Owner,
|
|
315
|
-
id: string,
|
|
316
|
-
): Promise<boolean> {
|
|
317
|
-
const current = await getSubscription(store, owner, id)
|
|
318
|
-
if (!current) return false
|
|
319
|
-
|
|
320
|
-
await store.delete(subscriptionKey(owner, id))
|
|
321
|
-
await store.delete(activeKey(current.chainId, current.eventType, id))
|
|
322
|
-
await store.delete(cursorKey(id))
|
|
323
|
-
|
|
324
|
-
// Drop the delivery log so a deleted subscription leaves no orphaned rows.
|
|
325
|
-
const { keys } = await store.list({ prefix: deliveryPrefix(id) })
|
|
326
|
-
for (const { name } of keys) await store.delete(name)
|
|
327
|
-
return true
|
|
293
|
+
/** Deletes an owner's subscription; its delivery rows cascade via the FK. */
|
|
294
|
+
export async function deleteSubscription(db: Db.Db, owner: Owner, id: string): Promise<boolean> {
|
|
295
|
+
return WebhookSubscriptions.remove(db, owner, id, new Date().toISOString())
|
|
328
296
|
}
|
|
329
297
|
|
|
330
298
|
/**
|
|
331
299
|
* Lists active subscriptions for a `(chainId, eventType)` stream. Used by the
|
|
332
|
-
* poller;
|
|
300
|
+
* poller; one indexed query (the partial status index replaces the old
|
|
301
|
+
* secondary key space).
|
|
333
302
|
*/
|
|
334
303
|
export async function listActive(
|
|
335
|
-
|
|
304
|
+
db: Db.Db,
|
|
336
305
|
chainId: number,
|
|
337
306
|
eventType: EventType,
|
|
338
307
|
): Promise<Subscription[]> {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
const subscriptions: Subscription[] = []
|
|
342
|
-
for (const { name } of keys) {
|
|
343
|
-
const subKey = await store.get(name)
|
|
344
|
-
if (!subKey) continue
|
|
345
|
-
const subscription = await readSubscription(store, subKey)
|
|
346
|
-
if (subscription) subscriptions.push(subscription)
|
|
347
|
-
}
|
|
348
|
-
return subscriptions
|
|
308
|
+
return WebhookSubscriptions.listActive(db, chainId, eventType, new Date().toISOString())
|
|
349
309
|
}
|
|
350
310
|
|
|
351
311
|
/** Reads a subscription's keyset cursor. Returns null when unset. */
|
|
352
|
-
export async function getCursor(
|
|
353
|
-
|
|
354
|
-
subscriptionId: string,
|
|
355
|
-
): Promise<string | null> {
|
|
356
|
-
return store.get(cursorKey(subscriptionId))
|
|
312
|
+
export async function getCursor(db: Db.Db, subscriptionId: string): Promise<string | null> {
|
|
313
|
+
return WebhookSubscriptions.getCursor(db, subscriptionId)
|
|
357
314
|
}
|
|
358
315
|
|
|
359
316
|
/** Writes a subscription's keyset cursor. */
|
|
360
|
-
export async function setCursor(
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
317
|
+
export async function setCursor(db: Db.Db, subscriptionId: string, cursor: string): Promise<void> {
|
|
318
|
+
await WebhookSubscriptions.setCursor(db, subscriptionId, cursor)
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Deletes expired MPP-owned subscriptions (delivery rows cascade) and
|
|
323
|
+
* deliveries past retention. Reads already filter expiry at query time — this
|
|
324
|
+
* is the janitor reclaiming space, called best-effort per poller tick.
|
|
325
|
+
*/
|
|
326
|
+
export async function pruneExpired(db: Db.Db, options: pruneExpired.Options = {}): Promise<void> {
|
|
327
|
+
const iso = (options.now ?? (() => new Date()))().toISOString()
|
|
328
|
+
await WebhookDeliveries.pruneExpired(db, iso)
|
|
329
|
+
await WebhookSubscriptions.pruneExpired(db, iso)
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
export declare namespace pruneExpired {
|
|
333
|
+
/** Options for {@link pruneExpired}. */
|
|
334
|
+
type Options = {
|
|
335
|
+
/** Clock used for expiry evaluation; injectable for tests. */
|
|
336
|
+
now?: (() => Date) | undefined
|
|
337
|
+
}
|
|
366
338
|
}
|
|
367
339
|
|
|
368
340
|
/**
|
|
@@ -373,14 +345,16 @@ export const deliveryRetentionMs = 7 * 24 * 60 * 60 * 1_000
|
|
|
373
345
|
|
|
374
346
|
/** Records one delivery-log row (stateful, owner-agnostic; scoped per subscription). */
|
|
375
347
|
export async function recordDelivery(
|
|
376
|
-
|
|
348
|
+
db: Db.Db,
|
|
377
349
|
delivery: Delivery,
|
|
378
350
|
options: recordDelivery.Options = {},
|
|
379
351
|
): Promise<void> {
|
|
380
352
|
const ttl = options.ttl ?? deliveryRetentionMs
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
353
|
+
// The retention deadline replaces the old store TTL: reads filter on it at
|
|
354
|
+
// query time and the poller prunes past it. Anchored to write time (not the
|
|
355
|
+
// row's `createdAt`, which tests pin) — exactly like the old `put` TTL.
|
|
356
|
+
const expiresAt = new Date(Date.now() + ttl).toISOString()
|
|
357
|
+
await WebhookDeliveries.insert(db, delivery, expiresAt)
|
|
384
358
|
}
|
|
385
359
|
|
|
386
360
|
export declare namespace recordDelivery {
|
|
@@ -396,27 +370,11 @@ export declare namespace recordDelivery {
|
|
|
396
370
|
* paging. Delivery ids embed a timestamp, so lexical key order is chronological.
|
|
397
371
|
*/
|
|
398
372
|
export async function listDeliveries(
|
|
399
|
-
|
|
373
|
+
db: Db.Db,
|
|
400
374
|
subscriptionId: string,
|
|
401
375
|
options: listDeliveries.Options = {},
|
|
402
376
|
): Promise<Delivery[]> {
|
|
403
|
-
|
|
404
|
-
const { keys } = await store.list({ prefix })
|
|
405
|
-
|
|
406
|
-
// Newest first: ids sort chronologically ascending, so reverse for descending.
|
|
407
|
-
let names = keys
|
|
408
|
-
.map((key) => key.name)
|
|
409
|
-
.sort()
|
|
410
|
-
.reverse()
|
|
411
|
-
if (options.cursor) names = names.filter((name) => name < `${prefix}${options.cursor}`)
|
|
412
|
-
if (options.offset) names = names.slice(options.offset)
|
|
413
|
-
if (options.limit !== undefined) names = names.slice(0, options.limit)
|
|
414
|
-
|
|
415
|
-
// Hydrate the page in parallel: the reads are independent, and a serial
|
|
416
|
-
// loop costs one store round trip per row (an N+1 against the production
|
|
417
|
-
// Durable Object).
|
|
418
|
-
const deliveries = await Promise.all(names.map((name) => readDelivery(store, name)))
|
|
419
|
-
return deliveries.filter((delivery) => delivery !== null)
|
|
377
|
+
return WebhookDeliveries.list(db, subscriptionId, { ...options, now: new Date().toISOString() })
|
|
420
378
|
}
|
|
421
379
|
|
|
422
380
|
export declare namespace listDeliveries {
|
|
@@ -432,23 +390,21 @@ export declare namespace listDeliveries {
|
|
|
432
390
|
}
|
|
433
391
|
|
|
434
392
|
/**
|
|
435
|
-
* Counts a subscription's delivery-log entries
|
|
436
|
-
*
|
|
437
|
-
* exact, and bounded by the delivery retention TTL. Feeds the opt-in
|
|
393
|
+
* Counts a subscription's delivery-log entries — a single indexed count,
|
|
394
|
+
* exact, and bounded by the delivery retention window. Feeds the opt-in
|
|
438
395
|
* `meta.totalCount` on `GET /webhooks/:id/deliveries`.
|
|
439
396
|
*/
|
|
440
|
-
export async function countDeliveries(
|
|
441
|
-
|
|
442
|
-
return keys.length
|
|
397
|
+
export async function countDeliveries(db: Db.Db, subscriptionId: string): Promise<number> {
|
|
398
|
+
return WebhookDeliveries.count(db, subscriptionId, new Date().toISOString())
|
|
443
399
|
}
|
|
444
400
|
|
|
445
401
|
/** Loads a single delivery-log row (`null` when absent), scoped to its subscription. */
|
|
446
402
|
export async function getDelivery(
|
|
447
|
-
|
|
403
|
+
db: Db.Db,
|
|
448
404
|
subscriptionId: string,
|
|
449
405
|
deliveryId: string,
|
|
450
406
|
): Promise<Delivery | null> {
|
|
451
|
-
return
|
|
407
|
+
return WebhookDeliveries.get(db, subscriptionId, deliveryId, new Date().toISOString())
|
|
452
408
|
}
|
|
453
409
|
|
|
454
410
|
/**
|
|
@@ -459,23 +415,20 @@ export const maxFailures = 10
|
|
|
459
415
|
|
|
460
416
|
/**
|
|
461
417
|
* Records a successful delivery: resets the consecutive-failure counter and
|
|
462
|
-
* stamps `lastDeliveryAt`.
|
|
463
|
-
*
|
|
418
|
+
* stamps `lastDeliveryAt`. A column-targeted update, so a concurrent patch is
|
|
419
|
+
* never clobbered by the stale copy carried through the delivery queue.
|
|
464
420
|
*/
|
|
465
421
|
export async function recordSuccess(
|
|
466
|
-
|
|
422
|
+
db: Db.Db,
|
|
467
423
|
subscription: Subscription,
|
|
468
424
|
options: recordSuccess.Options = {},
|
|
469
425
|
): Promise<Subscription> {
|
|
470
426
|
const now = (options.now ?? (() => new Date()))()
|
|
471
|
-
const
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
}
|
|
477
|
-
await writeSubscription(store, next)
|
|
478
|
-
return next
|
|
427
|
+
const iso = now.toISOString()
|
|
428
|
+
const next = await WebhookSubscriptions.recordSuccess(db, subscription.id, iso)
|
|
429
|
+
// A concurrently deleted subscription is not resurrected; return the
|
|
430
|
+
// optimistic next state so the caller still observes the outcome.
|
|
431
|
+
return next ?? { ...subscription, failureCount: 0, lastDeliveryAt: iso, updatedAt: iso }
|
|
479
432
|
}
|
|
480
433
|
|
|
481
434
|
export declare namespace recordSuccess {
|
|
@@ -487,27 +440,30 @@ export declare namespace recordSuccess {
|
|
|
487
440
|
}
|
|
488
441
|
|
|
489
442
|
/**
|
|
490
|
-
* Records a failed delivery: increments the consecutive-failure
|
|
491
|
-
* once it reaches `maxFailures`, sets `status: 'disabled'` so the
|
|
492
|
-
* drops out of the poller's
|
|
493
|
-
* updated subscription.
|
|
443
|
+
* Records a failed delivery: atomically increments the consecutive-failure
|
|
444
|
+
* counter and, once it reaches `maxFailures`, sets `status: 'disabled'` so the
|
|
445
|
+
* subscription drops out of the poller's partial index (surfaced via the API).
|
|
446
|
+
* Returns the updated subscription.
|
|
494
447
|
*/
|
|
495
448
|
export async function recordFailure(
|
|
496
|
-
|
|
449
|
+
db: Db.Db,
|
|
497
450
|
subscription: Subscription,
|
|
498
451
|
options: recordFailure.Options = {},
|
|
499
452
|
): Promise<Subscription> {
|
|
500
453
|
const now = (options.now ?? (() => new Date()))()
|
|
454
|
+
const iso = now.toISOString()
|
|
455
|
+
const max = options.maxFailures ?? maxFailures
|
|
456
|
+
const next = await WebhookSubscriptions.recordFailure(db, subscription.id, max, iso)
|
|
457
|
+
if (next) return next
|
|
458
|
+
// A concurrently deleted subscription is not resurrected; return the
|
|
459
|
+
// optimistic next state so the caller still observes the outcome.
|
|
501
460
|
const failureCount = subscription.failureCount + 1
|
|
502
|
-
|
|
503
|
-
const next: Subscription = {
|
|
461
|
+
return {
|
|
504
462
|
...subscription,
|
|
505
463
|
failureCount,
|
|
506
|
-
...(
|
|
507
|
-
updatedAt:
|
|
464
|
+
...(failureCount >= max ? { status: 'disabled' as const } : {}),
|
|
465
|
+
updatedAt: iso,
|
|
508
466
|
}
|
|
509
|
-
await writeSubscription(store, next)
|
|
510
|
-
return next
|
|
511
467
|
}
|
|
512
468
|
|
|
513
469
|
export declare namespace recordFailure {
|
|
@@ -527,7 +483,7 @@ export declare namespace recordFailure {
|
|
|
527
483
|
* point shared by the Cloudflare Queue consumer and the self-host inline path.
|
|
528
484
|
*/
|
|
529
485
|
export async function deliverAndRecord(
|
|
530
|
-
|
|
486
|
+
db: Db.Db,
|
|
531
487
|
subscription: Subscription,
|
|
532
488
|
envelope: Envelope,
|
|
533
489
|
options: deliverAndRecord.Options = {},
|
|
@@ -540,8 +496,8 @@ export async function deliverAndRecord(
|
|
|
540
496
|
...(options.fetch === undefined ? {} : { fetch: options.fetch }),
|
|
541
497
|
...(options.timeoutMs === undefined ? {} : { timeoutMs: options.timeoutMs }),
|
|
542
498
|
})
|
|
543
|
-
if (result.ok) await recordSuccess(
|
|
544
|
-
else await recordFailure(
|
|
499
|
+
if (result.ok) await recordSuccess(db, subscription, options)
|
|
500
|
+
else await recordFailure(db, subscription, options)
|
|
545
501
|
|
|
546
502
|
// Emit a `webhook:delivery` metric. recordSuccess/recordFailure are immutable
|
|
547
503
|
// (they spread into a new record), so `subscription.failureCount` here is still
|
|
@@ -563,7 +519,7 @@ export async function deliverAndRecord(
|
|
|
563
519
|
// the delivery outcome the caller (Queue consumer / inline path) acts on.
|
|
564
520
|
try {
|
|
565
521
|
await recordDelivery(
|
|
566
|
-
|
|
522
|
+
db,
|
|
567
523
|
buildDelivery({ attempt, envelope, result, subscription }, options),
|
|
568
524
|
options.deliveryRetentionMs === undefined ? {} : { ttl: options.deliveryRetentionMs },
|
|
569
525
|
)
|
|
@@ -741,7 +697,7 @@ export declare namespace buildPingEnvelope {
|
|
|
741
697
|
* delivery log.
|
|
742
698
|
*/
|
|
743
699
|
export async function ping(
|
|
744
|
-
|
|
700
|
+
db: Db.Db,
|
|
745
701
|
subscription: Subscription,
|
|
746
702
|
options: ping.Options = {},
|
|
747
703
|
): Promise<ping.Result> {
|
|
@@ -761,7 +717,7 @@ export async function ping(
|
|
|
761
717
|
const delivery = buildDelivery({ attempt: 1, envelope, result, subscription }, { now })
|
|
762
718
|
try {
|
|
763
719
|
await recordDelivery(
|
|
764
|
-
|
|
720
|
+
db,
|
|
765
721
|
delivery,
|
|
766
722
|
options.deliveryRetentionMs === undefined ? {} : { ttl: options.deliveryRetentionMs },
|
|
767
723
|
)
|
|
@@ -797,80 +753,6 @@ export declare namespace ping {
|
|
|
797
753
|
}
|
|
798
754
|
}
|
|
799
755
|
|
|
800
|
-
function ownerKey(owner: Owner): string {
|
|
801
|
-
return owner.type === 'api_key'
|
|
802
|
-
? `api_key:${encodeURIComponent(owner.orgId)}`
|
|
803
|
-
: `mpp:${encodeURIComponent(owner.payer)}`
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
function subscriptionPrefix(owner: Owner): string {
|
|
807
|
-
return `webhook:sub:${ownerKey(owner)}:`
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
function subscriptionKey(owner: Owner, id: string): string {
|
|
811
|
-
return `${subscriptionPrefix(owner)}${id}`
|
|
812
|
-
}
|
|
813
|
-
|
|
814
|
-
function cursorKey(subscriptionId: string): string {
|
|
815
|
-
return `webhook:cursor:${subscriptionId}`
|
|
816
|
-
}
|
|
817
|
-
|
|
818
|
-
function deliveryPrefix(subscriptionId: string): string {
|
|
819
|
-
return `webhook:delivery:${subscriptionId}:`
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
function deliveryKey(subscriptionId: string, deliveryId: string): string {
|
|
823
|
-
return `${deliveryPrefix(subscriptionId)}${deliveryId}`
|
|
824
|
-
}
|
|
825
|
-
|
|
826
|
-
function activePrefix(chainId: number, eventType: EventType): string {
|
|
827
|
-
return `webhook:active:${chainId}:${eventType}:`
|
|
828
|
-
}
|
|
829
|
-
|
|
830
|
-
function activeKey(chainId: number, eventType: EventType, id: string): string {
|
|
831
|
-
return `${activePrefix(chainId, eventType)}${id}`
|
|
832
|
-
}
|
|
833
|
-
|
|
834
|
-
async function readSubscription(store: Store.State, key: string): Promise<Subscription | null> {
|
|
835
|
-
const raw = await store.get(key)
|
|
836
|
-
if (!raw) return null
|
|
837
|
-
try {
|
|
838
|
-
return JSON.parse(raw) as Subscription
|
|
839
|
-
} catch {
|
|
840
|
-
// Corrupt entries are treated as absent.
|
|
841
|
-
return null
|
|
842
|
-
}
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
async function readDelivery(store: Store.State, key: string): Promise<Delivery | null> {
|
|
846
|
-
const raw = await store.get(key)
|
|
847
|
-
if (!raw) return null
|
|
848
|
-
try {
|
|
849
|
-
return JSON.parse(raw) as Delivery
|
|
850
|
-
} catch {
|
|
851
|
-
// Corrupt entries are treated as absent.
|
|
852
|
-
return null
|
|
853
|
-
}
|
|
854
|
-
}
|
|
855
|
-
|
|
856
|
-
async function writeSubscription(store: Store.State, subscription: Subscription): Promise<void> {
|
|
857
|
-
const ttl = ttlFor(subscription)
|
|
858
|
-
const key = subscriptionKey(subscription.owner, subscription.id)
|
|
859
|
-
await store.put(key, JSON.stringify(subscription), { ttl })
|
|
860
|
-
|
|
861
|
-
// Mirror status into the poller's secondary index: only `active`
|
|
862
|
-
// subscriptions are polled. The index value is the subscription's storage key
|
|
863
|
-
// so the poller can hydrate without knowing the owner.
|
|
864
|
-
const indexKey = activeKey(subscription.chainId, subscription.eventType, subscription.id)
|
|
865
|
-
if (subscription.status === 'active') await store.put(indexKey, key, { ttl })
|
|
866
|
-
else await store.delete(indexKey)
|
|
867
|
-
}
|
|
868
|
-
|
|
869
|
-
function ttlFor(subscription: Subscription): number | undefined {
|
|
870
|
-
if (!subscription.expiresAt) return undefined
|
|
871
|
-
return Math.max(1, new Date(subscription.expiresAt).getTime() - Date.now())
|
|
872
|
-
}
|
|
873
|
-
|
|
874
756
|
function generateId(now: Date): string {
|
|
875
757
|
// Zero-pad the epoch-ms so ids sort chronologically by string comparison
|
|
876
758
|
// (mirroring delivery ids), letting listSubscriptions page newest-first; 15
|