tapimo 0.0.0 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +119 -0
- package/dist/ApiKey.d.ts +65 -0
- package/dist/ApiKey.d.ts.map +1 -0
- package/dist/ApiKey.js +105 -0
- package/dist/ApiKey.js.map +1 -0
- package/dist/ApiKeySource.d.ts +166 -0
- package/dist/ApiKeySource.d.ts.map +1 -0
- package/dist/ApiKeySource.js +234 -0
- package/dist/ApiKeySource.js.map +1 -0
- package/dist/App.d.ts +19317 -0
- package/dist/App.d.ts.map +1 -0
- package/dist/App.js +612 -0
- package/dist/App.js.map +1 -0
- package/dist/Assets.d.ts +44 -0
- package/dist/Assets.d.ts.map +1 -0
- package/dist/Assets.js +23 -0
- package/dist/Assets.js.map +1 -0
- package/dist/Auth.d.ts +2 -0
- package/dist/Auth.d.ts.map +1 -0
- package/dist/Auth.js +2 -0
- package/dist/Auth.js.map +1 -0
- package/dist/Cli.d.ts +21 -0
- package/dist/Cli.d.ts.map +1 -0
- package/dist/Cli.js +13 -0
- package/dist/Cli.js.map +1 -0
- package/dist/Client.d.ts +20 -0
- package/dist/Client.d.ts.map +1 -0
- package/dist/Client.js +24 -0
- package/dist/Client.js.map +1 -0
- package/dist/Metrics.d.ts +70 -0
- package/dist/Metrics.d.ts.map +1 -0
- package/dist/Metrics.js +91 -0
- package/dist/Metrics.js.map +1 -0
- package/dist/Scope.d.ts +35 -0
- package/dist/Scope.d.ts.map +1 -0
- package/dist/Scope.js +38 -0
- package/dist/Scope.js.map +1 -0
- package/dist/Webhooks.d.ts +79 -0
- package/dist/Webhooks.d.ts.map +1 -0
- package/dist/Webhooks.js +107 -0
- package/dist/Webhooks.js.map +1 -0
- package/dist/admin/Access.d.ts +41 -0
- package/dist/admin/Access.d.ts.map +1 -0
- package/dist/admin/Access.js +75 -0
- package/dist/admin/Access.js.map +1 -0
- package/dist/admin/App.d.ts +1221 -0
- package/dist/admin/App.d.ts.map +1 -0
- package/dist/admin/App.js +113 -0
- package/dist/admin/App.js.map +1 -0
- package/dist/admin/apps/api-keys.d.ts +209 -0
- package/dist/admin/apps/api-keys.d.ts.map +1 -0
- package/dist/admin/apps/api-keys.js +129 -0
- package/dist/admin/apps/api-keys.js.map +1 -0
- package/dist/admin/apps/scopes.d.ts +46 -0
- package/dist/admin/apps/scopes.d.ts.map +1 -0
- package/dist/admin/apps/scopes.js +41 -0
- package/dist/admin/apps/scopes.js.map +1 -0
- package/dist/admin/apps/verified-tokens.d.ts +1206 -0
- package/dist/admin/apps/verified-tokens.d.ts.map +1 -0
- package/dist/admin/apps/verified-tokens.js +485 -0
- package/dist/admin/apps/verified-tokens.js.map +1 -0
- package/dist/admin/index.d.ts +3 -0
- package/dist/admin/index.d.ts.map +1 -0
- package/dist/admin/index.js +3 -0
- package/dist/admin/index.js.map +1 -0
- package/dist/admin/ui.generated.d.ts +11 -0
- package/dist/admin/ui.generated.d.ts.map +1 -0
- package/dist/admin/ui.generated.js +43 -0
- package/dist/admin/ui.generated.js.map +1 -0
- package/dist/apps/activities.d.ts +18725 -0
- package/dist/apps/activities.d.ts.map +1 -0
- package/dist/apps/activities.js +3138 -0
- package/dist/apps/activities.js.map +1 -0
- package/dist/apps/addresses.d.ts +3662 -0
- package/dist/apps/addresses.d.ts.map +1 -0
- package/dist/apps/addresses.js +22 -0
- package/dist/apps/addresses.js.map +1 -0
- package/dist/apps/balances.d.ts +342 -0
- package/dist/apps/balances.d.ts.map +1 -0
- package/dist/apps/balances.js +393 -0
- package/dist/apps/balances.js.map +1 -0
- package/dist/apps/blocks.d.ts +931 -0
- package/dist/apps/blocks.d.ts.map +1 -0
- package/dist/apps/blocks.js +689 -0
- package/dist/apps/blocks.js.map +1 -0
- package/dist/apps/coingecko.d.ts +1053 -0
- package/dist/apps/coingecko.d.ts.map +1 -0
- package/dist/apps/coingecko.js +1015 -0
- package/dist/apps/coingecko.js.map +1 -0
- package/dist/apps/exchanges.d.ts +3000 -0
- package/dist/apps/exchanges.d.ts.map +1 -0
- package/dist/apps/exchanges.js +3570 -0
- package/dist/apps/exchanges.js.map +1 -0
- package/dist/apps/fee-amm.d.ts +640 -0
- package/dist/apps/fee-amm.d.ts.map +1 -0
- package/dist/apps/fee-amm.js +815 -0
- package/dist/apps/fee-amm.js.map +1 -0
- package/dist/apps/indexer.d.ts +116 -0
- package/dist/apps/indexer.d.ts.map +1 -0
- package/dist/apps/indexer.js +270 -0
- package/dist/apps/indexer.js.map +1 -0
- package/dist/apps/receipts.d.ts +1438 -0
- package/dist/apps/receipts.d.ts.map +1 -0
- package/dist/apps/receipts.js +874 -0
- package/dist/apps/receipts.js.map +1 -0
- package/dist/apps/rpc.d.ts +173 -0
- package/dist/apps/rpc.d.ts.map +1 -0
- package/dist/apps/rpc.js +191 -0
- package/dist/apps/rpc.js.map +1 -0
- package/dist/apps/tokenlist.d.ts +192 -0
- package/dist/apps/tokenlist.d.ts.map +1 -0
- package/dist/apps/tokenlist.js +153 -0
- package/dist/apps/tokenlist.js.map +1 -0
- package/dist/apps/tokens.d.ts +2246 -0
- package/dist/apps/tokens.d.ts.map +1 -0
- package/dist/apps/tokens.js +1789 -0
- package/dist/apps/tokens.js.map +1 -0
- package/dist/apps/transactions.d.ts +2327 -0
- package/dist/apps/transactions.d.ts.map +1 -0
- package/dist/apps/transactions.js +975 -0
- package/dist/apps/transactions.js.map +1 -0
- package/dist/apps/transfers.d.ts +589 -0
- package/dist/apps/transfers.d.ts.map +1 -0
- package/dist/apps/transfers.js +769 -0
- package/dist/apps/transfers.js.map +1 -0
- package/dist/apps/verified-tokens.d.ts +544 -0
- package/dist/apps/verified-tokens.d.ts.map +1 -0
- package/dist/apps/verified-tokens.js +234 -0
- package/dist/apps/verified-tokens.js.map +1 -0
- package/dist/apps/webhooks.d.ts +7684 -0
- package/dist/apps/webhooks.d.ts.map +1 -0
- package/dist/apps/webhooks.js +2112 -0
- package/dist/apps/webhooks.js.map +1 -0
- package/dist/cloudflare.d.ts +32 -0
- package/dist/cloudflare.d.ts.map +1 -0
- package/dist/cloudflare.js +45 -0
- package/dist/cloudflare.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/Auth.d.ts +298 -0
- package/dist/internal/Auth.d.ts.map +1 -0
- package/dist/internal/Auth.js +618 -0
- package/dist/internal/Auth.js.map +1 -0
- package/dist/internal/Cache.d.ts +74 -0
- package/dist/internal/Cache.d.ts.map +1 -0
- package/dist/internal/Cache.js +215 -0
- package/dist/internal/Cache.js.map +1 -0
- package/dist/internal/Cursor.d.ts +79 -0
- package/dist/internal/Cursor.d.ts.map +1 -0
- package/dist/internal/Cursor.js +116 -0
- package/dist/internal/Cursor.js.map +1 -0
- package/dist/internal/EdgeCache.d.ts +59 -0
- package/dist/internal/EdgeCache.d.ts.map +1 -0
- package/dist/internal/EdgeCache.js +174 -0
- package/dist/internal/EdgeCache.js.map +1 -0
- package/dist/internal/Log.d.ts +104 -0
- package/dist/internal/Log.d.ts.map +1 -0
- package/dist/internal/Log.js +118 -0
- package/dist/internal/Log.js.map +1 -0
- package/dist/internal/MetricSink.d.ts +65 -0
- package/dist/internal/MetricSink.d.ts.map +1 -0
- package/dist/internal/MetricSink.js +146 -0
- package/dist/internal/MetricSink.js.map +1 -0
- package/dist/internal/Mpp.d.ts +71 -0
- package/dist/internal/Mpp.d.ts.map +1 -0
- package/dist/internal/Mpp.js +105 -0
- package/dist/internal/Mpp.js.map +1 -0
- package/dist/internal/OpenApi.d.ts +313 -0
- package/dist/internal/OpenApi.d.ts.map +1 -0
- package/dist/internal/OpenApi.fonts.d.ts +2 -0
- package/dist/internal/OpenApi.fonts.d.ts.map +1 -0
- package/dist/internal/OpenApi.fonts.js +39 -0
- package/dist/internal/OpenApi.fonts.js.map +1 -0
- package/dist/internal/OpenApi.js +335 -0
- package/dist/internal/OpenApi.js.map +1 -0
- package/dist/internal/OpenApi.logo.d.ts +6 -0
- package/dist/internal/OpenApi.logo.d.ts.map +1 -0
- package/dist/internal/OpenApi.logo.js +19 -0
- package/dist/internal/OpenApi.logo.js.map +1 -0
- package/dist/internal/Path.d.ts +5 -0
- package/dist/internal/Path.d.ts.map +1 -0
- package/dist/internal/Path.js +16 -0
- package/dist/internal/Path.js.map +1 -0
- package/dist/internal/RateLimit.d.ts +60 -0
- package/dist/internal/RateLimit.d.ts.map +1 -0
- package/dist/internal/RateLimit.js +48 -0
- package/dist/internal/RateLimit.js.map +1 -0
- package/dist/internal/Response.d.ts +132 -0
- package/dist/internal/Response.d.ts.map +1 -0
- package/dist/internal/Response.js +72 -0
- package/dist/internal/Response.js.map +1 -0
- package/dist/internal/Schema.d.ts +257 -0
- package/dist/internal/Schema.d.ts.map +1 -0
- package/dist/internal/Schema.js +360 -0
- package/dist/internal/Schema.js.map +1 -0
- package/dist/internal/Store.d.ts +204 -0
- package/dist/internal/Store.d.ts.map +1 -0
- package/dist/internal/Store.js +291 -0
- package/dist/internal/Store.js.map +1 -0
- package/dist/internal/Tidx.d.ts +120 -0
- package/dist/internal/Tidx.d.ts.map +1 -0
- package/dist/internal/Tidx.js +156 -0
- package/dist/internal/Tidx.js.map +1 -0
- package/dist/internal/Timing.d.ts +22 -0
- package/dist/internal/Timing.d.ts.map +1 -0
- package/dist/internal/Timing.js +32 -0
- package/dist/internal/Timing.js.map +1 -0
- package/dist/internal/Ttl.d.ts +25 -0
- package/dist/internal/Ttl.d.ts.map +1 -0
- package/dist/internal/Ttl.js +49 -0
- package/dist/internal/Ttl.js.map +1 -0
- package/dist/internal/Value.d.ts +47 -0
- package/dist/internal/Value.d.ts.map +1 -0
- package/dist/internal/Value.js +122 -0
- package/dist/internal/Value.js.map +1 -0
- package/dist/internal/VerifiedTokens.d.ts +228 -0
- package/dist/internal/VerifiedTokens.d.ts.map +1 -0
- package/dist/internal/VerifiedTokens.js +450 -0
- package/dist/internal/VerifiedTokens.js.map +1 -0
- package/dist/internal/Viem.d.ts +2082 -0
- package/dist/internal/Viem.d.ts.map +1 -0
- package/dist/internal/Viem.js +63 -0
- package/dist/internal/Viem.js.map +1 -0
- package/dist/internal/WebhookDestination.d.ts +198 -0
- package/dist/internal/WebhookDestination.d.ts.map +1 -0
- package/dist/internal/WebhookDestination.js +170 -0
- package/dist/internal/WebhookDestination.js.map +1 -0
- package/dist/internal/Webhooks.d.ts +433 -0
- package/dist/internal/Webhooks.d.ts.map +1 -0
- package/dist/internal/Webhooks.js +489 -0
- package/dist/internal/Webhooks.js.map +1 -0
- package/dist/internal/webhookDestinations/betterStack.d.ts +26 -0
- package/dist/internal/webhookDestinations/betterStack.d.ts.map +1 -0
- package/dist/internal/webhookDestinations/betterStack.js +76 -0
- package/dist/internal/webhookDestinations/betterStack.js.map +1 -0
- package/dist/internal/webhookDestinations/slack.d.ts +59 -0
- package/dist/internal/webhookDestinations/slack.d.ts.map +1 -0
- package/dist/internal/webhookDestinations/slack.js +422 -0
- package/dist/internal/webhookDestinations/slack.js.map +1 -0
- package/dist/internal/webhookDestinations/url.d.ts +17 -0
- package/dist/internal/webhookDestinations/url.d.ts.map +1 -0
- package/dist/internal/webhookDestinations/url.js +130 -0
- package/dist/internal/webhookDestinations/url.js.map +1 -0
- package/dist/openrpc.json +5302 -0
- package/package.json +46 -4
- package/seeds/31318/icons/0x20c0000000000000000000000000000000000000.svg +1 -0
- package/seeds/31318/icons/0x20c0000000000000000000000000000000000001.svg +1 -0
- package/seeds/31318/icons/0x20c0000000000000000000000000000000000002.svg +1 -0
- package/seeds/31318/icons/0x20c0000000000000000000000000000000000003.svg +1 -0
- package/seeds/31318/verified-tokens.json +30 -0
- package/seeds/4217/icons/0x20c0000000000000000000000000000000000000.svg +25 -0
- package/seeds/4217/icons/0x20c000000000000000000000048c8f36df1c9a4a.svg +1 -0
- package/seeds/4217/icons/0x20c0000000000000000000000520792dcccccccc.svg +1 -0
- package/seeds/4217/icons/0x20c0000000000000000000000a6da882d075a4c3.svg +4 -0
- package/seeds/4217/icons/0x20c000000000000000000000111111111e910f0f.svg +30 -0
- package/seeds/4217/icons/0x20c00000000000000000000014f22ca97301eb73.svg +1 -0
- package/seeds/4217/icons/0x20c0000000000000000000001621e21f71cf12fb.svg +1 -0
- package/seeds/4217/icons/0x20c0000000000000000000002f52d5cc21a3207b.svg +1 -0
- package/seeds/4217/icons/0x20c0000000000000000000003158081efd85bfc2.svg +11 -0
- package/seeds/4217/icons/0x20c0000000000000000000003554d28269e0f3c2.svg +1 -0
- package/seeds/4217/icons/0x20c000000000000000000000383a23bacb546ab9.svg +1 -0
- package/seeds/4217/icons/0x20c00000000000000000000042109aef2f8b28e1.png +0 -0
- package/seeds/4217/icons/0x20c0000000000000000000005c0bac7cef389a11.svg +1 -0
- package/seeds/4217/icons/0x20c0000000000000000000006fd9a167923ba194.png +0 -0
- package/seeds/4217/icons/0x20c0000000000000000000007f7ba549dd0251b9.svg +1 -0
- package/seeds/4217/icons/0x20c0000000000000000000008191667423f70e67.svg +5 -0
- package/seeds/4217/icons/0x20c0000000000000000000008ee4fcff88888888.svg +1 -0
- package/seeds/4217/icons/0x20c0000000000000000000009a4a4b17e0dc6651.svg +1 -0
- package/seeds/4217/icons/0x20c000000000000000000000ab02d39df30bd17e.svg +1 -0
- package/seeds/4217/icons/0x20c000000000000000000000ae247a1130450f09.svg +1 -0
- package/seeds/4217/icons/0x20c000000000000000000000aeed2ec36a54d0e5.svg +1 -0
- package/seeds/4217/icons/0x20c000000000000000000000b9537d11c60e8b50.svg +1 -0
- package/seeds/4217/icons/0x20c000000000000000000000bd95bfb69fbe6ce3.svg +1 -0
- package/seeds/4217/icons/0x20c000000000000000000000c412ec89d0c08be5.svg +1 -0
- package/seeds/4217/icons/0x20c000000000000000000000f047dd7018e50367.png +0 -0
- package/seeds/4217/verified-tokens.json +177 -0
- package/seeds/42431/icons/0x20c0000000000000000000000000000000000000.svg +25 -0
- package/seeds/42431/icons/0x20c0000000000000000000000000000000000001.svg +1 -0
- package/seeds/42431/icons/0x20c0000000000000000000000000000000000002.svg +1 -0
- package/seeds/42431/icons/0x20c0000000000000000000000000000000000003.svg +1 -0
- package/seeds/42431/icons/0x20c0000000000000000000009e8d7eb59b783726.svg +1 -0
- package/seeds/42431/icons/0x20c000000000000000000000d72572838bbee59c.svg +1 -0
- package/seeds/42431/verified-tokens.json +44 -0
- package/seeds/openrpc/README.md +27 -0
- package/seeds/openrpc/execution-apis.json +8989 -0
- package/src/ApiKey.test.ts +91 -0
- package/src/ApiKey.ts +122 -0
- package/src/ApiKeySource.test-d.ts +11 -0
- package/src/ApiKeySource.test.ts +295 -0
- package/src/ApiKeySource.ts +303 -0
- package/src/App.test-d.ts +38 -0
- package/src/App.test.ts +65927 -0
- package/src/App.ts +855 -0
- package/src/Assets.ts +58 -0
- package/src/Auth.ts +1 -0
- package/src/Cli.test.ts +81 -0
- package/src/Cli.ts +38 -0
- package/src/Client.test-d.ts +1438 -0
- package/src/Client.test.ts +134 -0
- package/src/Client.ts +45 -0
- package/src/Metrics.ts +154 -0
- package/src/Scope.ts +50 -0
- package/src/Webhooks.test.ts +49 -0
- package/src/Webhooks.ts +172 -0
- package/src/admin/Access.test.ts +130 -0
- package/src/admin/Access.ts +87 -0
- package/src/admin/App.test.ts +225 -0
- package/src/admin/App.ts +216 -0
- package/src/admin/apps/api-keys.test.ts +156 -0
- package/src/admin/apps/api-keys.ts +157 -0
- package/src/admin/apps/scopes.test.ts +52 -0
- package/src/admin/apps/scopes.ts +47 -0
- package/src/admin/apps/verified-tokens.test.ts +415 -0
- package/src/admin/apps/verified-tokens.ts +566 -0
- package/src/admin/index.ts +2 -0
- package/src/admin/ui/plugin.ts +135 -0
- package/src/admin/ui/src/components/Checkbox.tsx +22 -0
- package/src/admin/ui/src/components/Dialog.tsx +32 -0
- package/src/admin/ui/src/components/MobileProfile.tsx +31 -0
- package/src/admin/ui/src/components/Page.tsx +53 -0
- package/src/admin/ui/src/components/TempoLogo.tsx +37 -0
- package/src/admin/ui/src/fonts/Pilat-Demi.woff2 +0 -0
- package/src/admin/ui/src/fonts/Pilat-Regular.woff2 +0 -0
- package/src/admin/ui/src/lib/api-keys.ts +63 -0
- package/src/admin/ui/src/lib/client.ts +15 -0
- package/src/admin/ui/src/lib/config.ts +57 -0
- package/src/admin/ui/src/lib/query-client.ts +26 -0
- package/src/admin/ui/src/lib/scopes.ts +25 -0
- package/src/admin/ui/src/lib/verified-tokens.ts +89 -0
- package/src/admin/ui/src/lib/wagmi.ts +18 -0
- package/src/admin/ui/src/routeTree.gen.ts +104 -0
- package/src/admin/ui/src/router.tsx +25 -0
- package/src/admin/ui/src/routes/__root.tsx +219 -0
- package/src/admin/ui/src/routes/api-keys.tsx +329 -0
- package/src/admin/ui/src/routes/index.tsx +7 -0
- package/src/admin/ui/src/routes/verified-tokens.tsx +331 -0
- package/src/admin/ui/src/styles.css +20 -0
- package/src/admin/ui/tsconfig.json +16 -0
- package/src/admin/ui/vite.config.ts +29 -0
- package/src/admin/ui.generated.ts +60 -0
- package/src/apps/activities.test.ts +1020 -0
- package/src/apps/activities.ts +3934 -0
- package/src/apps/addresses.ts +24 -0
- package/src/apps/balances.test.ts +274 -0
- package/src/apps/balances.ts +533 -0
- package/src/apps/blocks.test.ts +385 -0
- package/src/apps/blocks.ts +896 -0
- package/src/apps/coingecko.test.ts +218 -0
- package/src/apps/coingecko.ts +1383 -0
- package/src/apps/exchanges.test.ts +958 -0
- package/src/apps/exchanges.ts +4773 -0
- package/src/apps/fee-amm.test.ts +321 -0
- package/src/apps/fee-amm.ts +1121 -0
- package/src/apps/indexer.test.ts +153 -0
- package/src/apps/indexer.ts +330 -0
- package/src/apps/receipts.test.ts +285 -0
- package/src/apps/receipts.ts +1193 -0
- package/src/apps/rpc.test.ts +302 -0
- package/src/apps/rpc.ts +222 -0
- package/src/apps/tokenlist.test.ts +80 -0
- package/src/apps/tokenlist.ts +207 -0
- package/src/apps/tokens.test.ts +1062 -0
- package/src/apps/tokens.ts +2292 -0
- package/src/apps/transactions.test.ts +408 -0
- package/src/apps/transactions.ts +1363 -0
- package/src/apps/transfers.test.ts +371 -0
- package/src/apps/transfers.ts +1116 -0
- package/src/apps/verified-tokens.test.ts +114 -0
- package/src/apps/verified-tokens.ts +295 -0
- package/src/apps/webhooks.test.ts +1937 -0
- package/src/apps/webhooks.ts +2926 -0
- package/src/cloudflare.ts +55 -0
- package/src/index.ts +15 -0
- package/src/internal/Auth.test.ts +980 -0
- package/src/internal/Auth.ts +1012 -0
- package/src/internal/Cache.test.ts +240 -0
- package/src/internal/Cache.ts +262 -0
- package/src/internal/Cursor.test.ts +100 -0
- package/src/internal/Cursor.ts +149 -0
- package/src/internal/EdgeCache.test.ts +234 -0
- package/src/internal/EdgeCache.ts +224 -0
- package/src/internal/Errors.ts +14 -0
- package/src/internal/Log.test.ts +244 -0
- package/src/internal/Log.ts +216 -0
- package/src/internal/MetricSink.ts +220 -0
- package/src/internal/Mpp.test.ts +64 -0
- package/src/internal/Mpp.ts +141 -0
- package/src/internal/OpenApi.fonts.ts +38 -0
- package/src/internal/OpenApi.logo.ts +18 -0
- package/src/internal/OpenApi.ts +488 -0
- package/src/internal/Path.test.ts +14 -0
- package/src/internal/Path.ts +15 -0
- package/src/internal/RateLimit.test.ts +93 -0
- package/src/internal/RateLimit.ts +93 -0
- package/src/internal/Response.ts +131 -0
- package/src/internal/Schema.test.ts +34 -0
- package/src/internal/Schema.ts +523 -0
- package/src/internal/Store.test.ts +545 -0
- package/src/internal/Store.ts +526 -0
- package/src/internal/Tidx.local.test.ts +33 -0
- package/src/internal/Tidx.test.ts +294 -0
- package/src/internal/Tidx.ts +238 -0
- package/src/internal/Timing.test.ts +22 -0
- package/src/internal/Timing.ts +62 -0
- package/src/internal/Ttl.test.ts +18 -0
- package/src/internal/Ttl.ts +59 -0
- package/src/internal/Value.ts +114 -0
- package/src/internal/VerifiedTokens.test.ts +333 -0
- package/src/internal/VerifiedTokens.ts +645 -0
- package/src/internal/Viem.test.ts +115 -0
- package/src/internal/Viem.ts +165 -0
- package/src/internal/WebhookDestination.test.ts +648 -0
- package/src/internal/WebhookDestination.ts +331 -0
- package/src/internal/Webhooks.test.ts +668 -0
- package/src/internal/Webhooks.ts +940 -0
- package/src/internal/webhookDestinations/betterStack.ts +91 -0
- package/src/internal/webhookDestinations/slack.ts +496 -0
- package/src/internal/webhookDestinations/url.ts +128 -0
- package/src/openrpc.json +5302 -0
|
@@ -0,0 +1,545 @@
|
|
|
1
|
+
import { Store } from 'cadent'
|
|
2
|
+
|
|
3
|
+
describe('from', () => {
|
|
4
|
+
const ops = {
|
|
5
|
+
async delete() {},
|
|
6
|
+
async get() {
|
|
7
|
+
return null
|
|
8
|
+
},
|
|
9
|
+
async list() {
|
|
10
|
+
return { keys: [] }
|
|
11
|
+
},
|
|
12
|
+
async put() {},
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
test('defaults to a state store when type is omitted', () => {
|
|
16
|
+
expect(Store.from(ops).type).toMatchInlineSnapshot(`"state"`)
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
test('opts into a cache store with type: cache', () => {
|
|
20
|
+
expect(Store.from({ ...ops, type: 'cache' }).type).toMatchInlineSnapshot(`"cache"`)
|
|
21
|
+
})
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
describe('increment', () => {
|
|
25
|
+
test('falls back to a get + put read-modify-write without a native counter', async () => {
|
|
26
|
+
const cells = new Map<string, string>()
|
|
27
|
+
const store = Store.from({
|
|
28
|
+
async delete(key) {
|
|
29
|
+
cells.delete(key)
|
|
30
|
+
},
|
|
31
|
+
async get(key) {
|
|
32
|
+
return cells.get(key) ?? null
|
|
33
|
+
},
|
|
34
|
+
async list() {
|
|
35
|
+
return { keys: [] }
|
|
36
|
+
},
|
|
37
|
+
async put(key, value) {
|
|
38
|
+
cells.set(key, value)
|
|
39
|
+
},
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
expect(await Store.increment(store, 'counter')).toMatchInlineSnapshot(`1`)
|
|
43
|
+
expect(await Store.increment(store, 'counter')).toMatchInlineSnapshot(`2`)
|
|
44
|
+
expect(cells.get('counter')).toMatchInlineSnapshot(`"2"`)
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
test('prefers the store-native counter when implemented', async () => {
|
|
48
|
+
const calls: { key: string; options: Store.Store.PutOptions | undefined }[] = []
|
|
49
|
+
const store = Store.from({
|
|
50
|
+
...Store.memory(),
|
|
51
|
+
async increment(key, options) {
|
|
52
|
+
calls.push({ key, options })
|
|
53
|
+
return 7
|
|
54
|
+
},
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
expect(await Store.increment(store, 'counter', { ttl: 30_000 })).toMatchInlineSnapshot(`7`)
|
|
58
|
+
expect(calls).toMatchInlineSnapshot(`
|
|
59
|
+
[
|
|
60
|
+
{
|
|
61
|
+
"key": "counter",
|
|
62
|
+
"options": {
|
|
63
|
+
"ttl": 30000,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
]
|
|
67
|
+
`)
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
describe('memory', () => {
|
|
72
|
+
test('treats expired entries as absent', async () => {
|
|
73
|
+
const store = Store.memory()
|
|
74
|
+
|
|
75
|
+
await store.put('short', 'soon-gone', { ttl: 10 })
|
|
76
|
+
await store.put('long', 'sticks-around', { ttl: 60_000 })
|
|
77
|
+
await new Promise((resolve) => setTimeout(resolve, 25))
|
|
78
|
+
|
|
79
|
+
expect(await store.get('short')).toMatchInlineSnapshot(`null`)
|
|
80
|
+
expect(await store.list()).toMatchInlineSnapshot(`
|
|
81
|
+
{
|
|
82
|
+
"keys": [
|
|
83
|
+
{
|
|
84
|
+
"name": "long",
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
}
|
|
88
|
+
`)
|
|
89
|
+
expect(await store.get('long')).toMatchInlineSnapshot(`"sticks-around"`)
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
test('reads, writes, deletes, and lists string values', async () => {
|
|
93
|
+
const store = Store.memory({
|
|
94
|
+
entries: [
|
|
95
|
+
['other:1', 'ignored'],
|
|
96
|
+
['secret:1', 'alpha'],
|
|
97
|
+
],
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
await store.put('secret:2', 'beta')
|
|
101
|
+
await store.delete('other:1')
|
|
102
|
+
|
|
103
|
+
expect(await store.get('other:1')).toMatchInlineSnapshot(`null`)
|
|
104
|
+
expect(await store.list({ prefix: 'secret:' })).toMatchInlineSnapshot(`
|
|
105
|
+
{
|
|
106
|
+
"keys": [
|
|
107
|
+
{
|
|
108
|
+
"name": "secret:1",
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"name": "secret:2",
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
}
|
|
115
|
+
`)
|
|
116
|
+
expect(await store.get('missing')).toMatchInlineSnapshot(`null`)
|
|
117
|
+
expect(await store.get('secret:1')).toMatchInlineSnapshot(`"alpha"`)
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
test('increments counters and restarts expired ones at 1', async () => {
|
|
121
|
+
const store = Store.memory()
|
|
122
|
+
|
|
123
|
+
expect(await Store.increment(store, 'counter', { ttl: 10 })).toMatchInlineSnapshot(`1`)
|
|
124
|
+
expect(await Store.increment(store, 'counter', { ttl: 10 })).toMatchInlineSnapshot(`2`)
|
|
125
|
+
await new Promise((resolve) => setTimeout(resolve, 25))
|
|
126
|
+
|
|
127
|
+
expect(await Store.increment(store, 'counter', { ttl: 10 })).toMatchInlineSnapshot(`1`)
|
|
128
|
+
})
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
describe('cloudflareKv', () => {
|
|
132
|
+
test('adapts a Cloudflare Workers KV namespace', async () => {
|
|
133
|
+
const cells = new Map<string, string>([
|
|
134
|
+
['other:1', 'ignored'],
|
|
135
|
+
['secret:1', 'alpha'],
|
|
136
|
+
])
|
|
137
|
+
const writes: unknown[] = []
|
|
138
|
+
const namespace = {
|
|
139
|
+
async delete(key) {
|
|
140
|
+
cells.delete(key)
|
|
141
|
+
},
|
|
142
|
+
async get(key) {
|
|
143
|
+
return cells.get(key) ?? null
|
|
144
|
+
},
|
|
145
|
+
async list(options = {}) {
|
|
146
|
+
return {
|
|
147
|
+
keys: Array.from(cells.keys())
|
|
148
|
+
.filter((key) => !options.prefix || key.startsWith(options.prefix))
|
|
149
|
+
.sort()
|
|
150
|
+
.map((name) => ({ name })),
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
async put(key, value, options) {
|
|
154
|
+
writes.push({ key, options, value })
|
|
155
|
+
cells.set(key, value)
|
|
156
|
+
},
|
|
157
|
+
} satisfies Store.cloudflareKv.Namespace
|
|
158
|
+
const store = Store.cloudflareKv(namespace)
|
|
159
|
+
|
|
160
|
+
await store.put('secret:2', 'beta', { ttl: 60_500 })
|
|
161
|
+
await store.delete('other:1')
|
|
162
|
+
|
|
163
|
+
expect(writes).toMatchInlineSnapshot(`
|
|
164
|
+
[
|
|
165
|
+
{
|
|
166
|
+
"key": "secret:2",
|
|
167
|
+
"options": {
|
|
168
|
+
"expirationTtl": 61,
|
|
169
|
+
},
|
|
170
|
+
"value": "beta",
|
|
171
|
+
},
|
|
172
|
+
]
|
|
173
|
+
`)
|
|
174
|
+
expect(await store.get('other:1')).toMatchInlineSnapshot(`null`)
|
|
175
|
+
expect(await store.list({ prefix: 'secret:' })).toMatchInlineSnapshot(`
|
|
176
|
+
{
|
|
177
|
+
"keys": [
|
|
178
|
+
{
|
|
179
|
+
"name": "secret:1",
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
"name": "secret:2",
|
|
183
|
+
},
|
|
184
|
+
],
|
|
185
|
+
}
|
|
186
|
+
`)
|
|
187
|
+
await expect(
|
|
188
|
+
store.put('short', 'nope', { ttl: 10 }),
|
|
189
|
+
).rejects.toThrowErrorMatchingInlineSnapshot(
|
|
190
|
+
`[RangeError: Cloudflare KV expirationTtl must be at least 60 seconds]`,
|
|
191
|
+
)
|
|
192
|
+
})
|
|
193
|
+
})
|
|
194
|
+
|
|
195
|
+
describe('durableObject', () => {
|
|
196
|
+
test('adapts a Durable Object namespace without caching stubs', async () => {
|
|
197
|
+
const calls: string[] = []
|
|
198
|
+
const backing = Store.memory({
|
|
199
|
+
entries: [['secret:1', 'alpha']],
|
|
200
|
+
})
|
|
201
|
+
const namespace = {
|
|
202
|
+
getByName(name) {
|
|
203
|
+
calls.push(name)
|
|
204
|
+
// The stub contract requires a native `increment` (our DO class
|
|
205
|
+
// implements it); derive one for the in-memory fake.
|
|
206
|
+
return {
|
|
207
|
+
...backing,
|
|
208
|
+
increment: (key, options) => Store.increment(backing, key, options),
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
} satisfies Store.durableObject.Namespace
|
|
212
|
+
const store = Store.durableObject(namespace, { name: 'tempo-api' })
|
|
213
|
+
|
|
214
|
+
await store.put('secret:2', 'beta')
|
|
215
|
+
expect(await store.get('secret:1')).toMatchInlineSnapshot(`"alpha"`)
|
|
216
|
+
expect(await store.list({ prefix: 'secret:' })).toMatchInlineSnapshot(`
|
|
217
|
+
{
|
|
218
|
+
"keys": [
|
|
219
|
+
{
|
|
220
|
+
"name": "secret:1",
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
"name": "secret:2",
|
|
224
|
+
},
|
|
225
|
+
],
|
|
226
|
+
}
|
|
227
|
+
`)
|
|
228
|
+
await store.delete('secret:1')
|
|
229
|
+
|
|
230
|
+
expect(calls).toMatchInlineSnapshot(`
|
|
231
|
+
[
|
|
232
|
+
"tempo-api",
|
|
233
|
+
"tempo-api",
|
|
234
|
+
"tempo-api",
|
|
235
|
+
"tempo-api",
|
|
236
|
+
]
|
|
237
|
+
`)
|
|
238
|
+
})
|
|
239
|
+
|
|
240
|
+
test('shards keys across objects with a name resolver', async () => {
|
|
241
|
+
const calls: { method: string; name: string }[] = []
|
|
242
|
+
const objects = new Map<string, Store.State>()
|
|
243
|
+
const namespace = {
|
|
244
|
+
getByName(name) {
|
|
245
|
+
const backing = objects.get(name) ?? Store.memory()
|
|
246
|
+
objects.set(name, backing)
|
|
247
|
+
const stub = {
|
|
248
|
+
delete: (key) => backing.delete(key),
|
|
249
|
+
get: (key) => backing.get(key),
|
|
250
|
+
increment: (key, options) => Store.increment(backing, key, options),
|
|
251
|
+
list: (options) => backing.list(options),
|
|
252
|
+
put: (key, value, options) => backing.put(key, value, options),
|
|
253
|
+
} satisfies Store.durableObject.Stub
|
|
254
|
+
return new Proxy(stub, {
|
|
255
|
+
get(target, method: string) {
|
|
256
|
+
calls.push({ method, name })
|
|
257
|
+
return target[method as keyof Store.durableObject.Stub]
|
|
258
|
+
},
|
|
259
|
+
})
|
|
260
|
+
},
|
|
261
|
+
} satisfies Store.durableObject.Namespace
|
|
262
|
+
const store = Store.durableObject(namespace, { name: (key) => `tempo-api:${key}` })
|
|
263
|
+
|
|
264
|
+
expect(await Store.increment(store, 'ratelimit:a')).toMatchInlineSnapshot(`1`)
|
|
265
|
+
expect(await Store.increment(store, 'ratelimit:a')).toMatchInlineSnapshot(`2`)
|
|
266
|
+
expect(await Store.increment(store, 'ratelimit:b')).toMatchInlineSnapshot(`1`)
|
|
267
|
+
|
|
268
|
+
expect(calls).toMatchInlineSnapshot(`
|
|
269
|
+
[
|
|
270
|
+
{
|
|
271
|
+
"method": "increment",
|
|
272
|
+
"name": "tempo-api:ratelimit:a",
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
"method": "increment",
|
|
276
|
+
"name": "tempo-api:ratelimit:a",
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
"method": "increment",
|
|
280
|
+
"name": "tempo-api:ratelimit:b",
|
|
281
|
+
},
|
|
282
|
+
]
|
|
283
|
+
`)
|
|
284
|
+
await expect(store.list()).rejects.toThrowErrorMatchingInlineSnapshot(
|
|
285
|
+
`[TypeError: cannot list a sharded Durable Object store]`,
|
|
286
|
+
)
|
|
287
|
+
})
|
|
288
|
+
|
|
289
|
+
test('retries a retryable stub error once on a fresh stub', async () => {
|
|
290
|
+
let stubs = 0
|
|
291
|
+
let failures = 1
|
|
292
|
+
const backing = Store.memory()
|
|
293
|
+
const namespace = {
|
|
294
|
+
getByName() {
|
|
295
|
+
stubs += 1
|
|
296
|
+
return {
|
|
297
|
+
...backing,
|
|
298
|
+
increment: (key, options) => {
|
|
299
|
+
if (failures > 0) {
|
|
300
|
+
failures -= 1
|
|
301
|
+
throw Object.assign(new Error('Network connection lost.'), { retryable: true })
|
|
302
|
+
}
|
|
303
|
+
return Store.increment(backing, key, options)
|
|
304
|
+
},
|
|
305
|
+
}
|
|
306
|
+
},
|
|
307
|
+
} satisfies Store.durableObject.Namespace
|
|
308
|
+
const store = Store.durableObject(namespace, { name: 'tempo-api' })
|
|
309
|
+
|
|
310
|
+
expect(await Store.increment(store, 'counter')).toMatchInlineSnapshot(`1`)
|
|
311
|
+
// One stub per attempt: a stub that threw is disconnected.
|
|
312
|
+
expect(stubs).toMatchInlineSnapshot(`2`)
|
|
313
|
+
})
|
|
314
|
+
|
|
315
|
+
test('propagates a retryable stub error when the retry also fails', async () => {
|
|
316
|
+
let attempts = 0
|
|
317
|
+
const namespace = {
|
|
318
|
+
getByName() {
|
|
319
|
+
return {
|
|
320
|
+
...Store.memory(),
|
|
321
|
+
increment: () => {
|
|
322
|
+
attempts += 1
|
|
323
|
+
throw Object.assign(new Error('Network connection lost.'), { retryable: true })
|
|
324
|
+
},
|
|
325
|
+
}
|
|
326
|
+
},
|
|
327
|
+
} satisfies Store.durableObject.Namespace
|
|
328
|
+
const store = Store.durableObject(namespace, { name: 'tempo-api' })
|
|
329
|
+
|
|
330
|
+
await expect(Store.increment(store, 'counter')).rejects.toThrowErrorMatchingInlineSnapshot(
|
|
331
|
+
`[Error: Network connection lost.]`,
|
|
332
|
+
)
|
|
333
|
+
expect(attempts).toMatchInlineSnapshot(`2`)
|
|
334
|
+
})
|
|
335
|
+
|
|
336
|
+
test('does not retry non-retryable or overloaded stub errors', async () => {
|
|
337
|
+
let attempts = 0
|
|
338
|
+
const namespaceFor = (error: Error) =>
|
|
339
|
+
({
|
|
340
|
+
getByName() {
|
|
341
|
+
return {
|
|
342
|
+
...Store.memory(),
|
|
343
|
+
increment: () => {
|
|
344
|
+
attempts += 1
|
|
345
|
+
throw error
|
|
346
|
+
},
|
|
347
|
+
}
|
|
348
|
+
},
|
|
349
|
+
}) satisfies Store.durableObject.Namespace
|
|
350
|
+
|
|
351
|
+
const plain = Store.durableObject(namespaceFor(new Error('boom')), { name: 'tempo-api' })
|
|
352
|
+
await expect(Store.increment(plain, 'counter')).rejects.toThrowErrorMatchingInlineSnapshot(
|
|
353
|
+
`[Error: boom]`,
|
|
354
|
+
)
|
|
355
|
+
expect(attempts).toMatchInlineSnapshot(`1`)
|
|
356
|
+
|
|
357
|
+
attempts = 0
|
|
358
|
+
const overloaded = Store.durableObject(
|
|
359
|
+
namespaceFor(
|
|
360
|
+
Object.assign(new Error('Durable Object is overloaded.'), {
|
|
361
|
+
overloaded: true,
|
|
362
|
+
retryable: true,
|
|
363
|
+
}),
|
|
364
|
+
),
|
|
365
|
+
{ name: 'tempo-api' },
|
|
366
|
+
)
|
|
367
|
+
await expect(Store.increment(overloaded, 'counter')).rejects.toThrowErrorMatchingInlineSnapshot(
|
|
368
|
+
`[Error: Durable Object is overloaded.]`,
|
|
369
|
+
)
|
|
370
|
+
expect(attempts).toMatchInlineSnapshot(`1`)
|
|
371
|
+
})
|
|
372
|
+
|
|
373
|
+
test('defers missing namespace failures until an operation is attempted', async () => {
|
|
374
|
+
const store = Store.durableObject(undefined as unknown as Store.durableObject.Namespace, {
|
|
375
|
+
name: 'tempo-api',
|
|
376
|
+
})
|
|
377
|
+
|
|
378
|
+
expect(store.type).toMatchInlineSnapshot(`"state"`)
|
|
379
|
+
await expect(store.get('key')).rejects.toThrowErrorMatchingInlineSnapshot(
|
|
380
|
+
`[TypeError: Cannot read properties of undefined (reading 'get')]`,
|
|
381
|
+
)
|
|
382
|
+
})
|
|
383
|
+
|
|
384
|
+
test('adapts Durable Object storage and lazily removes expired entries', async () => {
|
|
385
|
+
const storage = durableObjectStorage()
|
|
386
|
+
const store = Store.durableObject(storage)
|
|
387
|
+
|
|
388
|
+
await store.put('secret:1', 'alpha', { ttl: 10 })
|
|
389
|
+
await store.put('secret:2', 'beta', { ttl: 60_000 })
|
|
390
|
+
await store.put('other:1', 'ignored')
|
|
391
|
+
await new Promise((resolve) => setTimeout(resolve, 25))
|
|
392
|
+
|
|
393
|
+
expect(await store.get('secret:1')).toMatchInlineSnapshot(`null`)
|
|
394
|
+
expect(await store.get('secret:2')).toMatchInlineSnapshot(`"beta"`)
|
|
395
|
+
expect(await store.list({ prefix: 'secret:' })).toMatchInlineSnapshot(`
|
|
396
|
+
{
|
|
397
|
+
"keys": [
|
|
398
|
+
{
|
|
399
|
+
"name": "secret:2",
|
|
400
|
+
},
|
|
401
|
+
],
|
|
402
|
+
}
|
|
403
|
+
`)
|
|
404
|
+
expect(storage.cells.has('secret:1')).toMatchInlineSnapshot(`false`)
|
|
405
|
+
})
|
|
406
|
+
})
|
|
407
|
+
|
|
408
|
+
describe('memoize', () => {
|
|
409
|
+
test('coalesces concurrent cache misses for the same key', async () => {
|
|
410
|
+
const store = Store.memory()
|
|
411
|
+
const pending = deferred<void>()
|
|
412
|
+
let calls = 0
|
|
413
|
+
|
|
414
|
+
const requests = [1, 2, 3].map(() =>
|
|
415
|
+
Store.memoize(
|
|
416
|
+
async () => {
|
|
417
|
+
calls += 1
|
|
418
|
+
await pending.promise
|
|
419
|
+
return { value: 'fresh' }
|
|
420
|
+
},
|
|
421
|
+
{ key: 'memo:test', store, ttl: 60_000 },
|
|
422
|
+
),
|
|
423
|
+
)
|
|
424
|
+
|
|
425
|
+
await Promise.resolve()
|
|
426
|
+
pending.resolve()
|
|
427
|
+
|
|
428
|
+
const values = await Promise.all(requests)
|
|
429
|
+
|
|
430
|
+
expect(calls).toMatchInlineSnapshot(`1`)
|
|
431
|
+
expect(JSON.parse((await store.get('memo:test')) ?? 'null')).toMatchInlineSnapshot(`
|
|
432
|
+
{
|
|
433
|
+
"value": "fresh",
|
|
434
|
+
}
|
|
435
|
+
`)
|
|
436
|
+
expect(values).toMatchInlineSnapshot(`
|
|
437
|
+
[
|
|
438
|
+
{
|
|
439
|
+
"value": "fresh",
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
"value": "fresh",
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
"value": "fresh",
|
|
446
|
+
},
|
|
447
|
+
]
|
|
448
|
+
`)
|
|
449
|
+
})
|
|
450
|
+
|
|
451
|
+
test('returns cached JSON values until the entry expires', async () => {
|
|
452
|
+
const store = Store.memory()
|
|
453
|
+
let calls = 0
|
|
454
|
+
|
|
455
|
+
const first = await Store.memoize(async () => ({ value: ++calls }), {
|
|
456
|
+
key: 'memo:test',
|
|
457
|
+
store,
|
|
458
|
+
ttl: 10,
|
|
459
|
+
})
|
|
460
|
+
const second = await Store.memoize(async () => ({ value: ++calls }), {
|
|
461
|
+
key: 'memo:test',
|
|
462
|
+
store,
|
|
463
|
+
ttl: 10,
|
|
464
|
+
})
|
|
465
|
+
|
|
466
|
+
await new Promise((resolve) => setTimeout(resolve, 25))
|
|
467
|
+
|
|
468
|
+
const third = await Store.memoize(async () => ({ value: ++calls }), {
|
|
469
|
+
key: 'memo:test',
|
|
470
|
+
store,
|
|
471
|
+
ttl: 10,
|
|
472
|
+
})
|
|
473
|
+
|
|
474
|
+
expect(calls).toMatchInlineSnapshot(`2`)
|
|
475
|
+
expect(first).toMatchInlineSnapshot(`
|
|
476
|
+
{
|
|
477
|
+
"value": 1,
|
|
478
|
+
}
|
|
479
|
+
`)
|
|
480
|
+
expect(second).toMatchInlineSnapshot(`
|
|
481
|
+
{
|
|
482
|
+
"value": 1,
|
|
483
|
+
}
|
|
484
|
+
`)
|
|
485
|
+
expect(third).toMatchInlineSnapshot(`
|
|
486
|
+
{
|
|
487
|
+
"value": 2,
|
|
488
|
+
}
|
|
489
|
+
`)
|
|
490
|
+
})
|
|
491
|
+
|
|
492
|
+
test('refreshes corrupt cache entries', async () => {
|
|
493
|
+
const store = Store.memory({ entries: [['memo:test', 'not-json']] })
|
|
494
|
+
|
|
495
|
+
const value = await Store.memoize(async () => ({ value: 'fresh' }), {
|
|
496
|
+
key: 'memo:test',
|
|
497
|
+
store,
|
|
498
|
+
ttl: 60_000,
|
|
499
|
+
})
|
|
500
|
+
|
|
501
|
+
expect(value).toMatchInlineSnapshot(`
|
|
502
|
+
{
|
|
503
|
+
"value": "fresh",
|
|
504
|
+
}
|
|
505
|
+
`)
|
|
506
|
+
expect(JSON.parse((await store.get('memo:test')) ?? 'null')).toMatchInlineSnapshot(`
|
|
507
|
+
{
|
|
508
|
+
"value": "fresh",
|
|
509
|
+
}
|
|
510
|
+
`)
|
|
511
|
+
})
|
|
512
|
+
})
|
|
513
|
+
|
|
514
|
+
function deferred<value>() {
|
|
515
|
+
let reject!: (cause?: unknown) => void
|
|
516
|
+
let resolve!: (value: PromiseLike<value> | value) => void
|
|
517
|
+
const promise = new Promise<value>((resolve_, reject_) => {
|
|
518
|
+
reject = reject_
|
|
519
|
+
resolve = resolve_
|
|
520
|
+
})
|
|
521
|
+
return { promise, reject, resolve }
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
function durableObjectStorage(): Store.durableObject.Storage & { cells: Map<string, unknown> } {
|
|
525
|
+
const cells = new Map<string, unknown>()
|
|
526
|
+
|
|
527
|
+
return {
|
|
528
|
+
cells,
|
|
529
|
+
async delete(key) {
|
|
530
|
+
return cells.delete(key)
|
|
531
|
+
},
|
|
532
|
+
async get<value = unknown>(key: string) {
|
|
533
|
+
return cells.get(key) as undefined | value
|
|
534
|
+
},
|
|
535
|
+
async list<value = unknown>(options: { prefix?: string | undefined } = {}) {
|
|
536
|
+
const entries = Array.from(cells.entries()).filter(
|
|
537
|
+
([key]) => !options.prefix || key.startsWith(options.prefix),
|
|
538
|
+
)
|
|
539
|
+
return new Map(entries) as Map<string, value>
|
|
540
|
+
},
|
|
541
|
+
async put(key, value) {
|
|
542
|
+
cells.set(key, value)
|
|
543
|
+
},
|
|
544
|
+
}
|
|
545
|
+
}
|