agenttwin 0.3.21 → 0.3.22
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/dist/api.js +2113 -609
- package/dist/dashboard/assets/dashboard/agent-home.css +7 -7
- package/dist/dashboard/assets/dashboard/bay-morning.webp +0 -0
- package/dist/dashboard/assets/dashboard/golden-gate-afternoon.webp +0 -0
- package/dist/dashboard/assets/dashboard/golden-gate-portrait.webp +0 -0
- package/dist/dashboard/assets/dashboard/moonlit-coast.webp +0 -0
- package/dist/dashboard/assets/next/static/chunks/5663-403316746afad10e.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/dashboard/{page-9c11295678539a5f.js → page-0e0392368e0a891e.js} +1 -1
- package/dist/dashboard/assets/next/static/chunks/app/docs/[[...slug]]/page-4981ea4966b19e3e.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/onboarding/page-dd4ac0f5f36e6bfa.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/v2/dashboard/{page-34574448d210c775.js → page-de0fe6d84be21e6a.js} +1 -1
- package/dist/dashboard/assets/next/static/chunks/app/v2/onboarding/page-360cbffc57981f6b.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/v2/{page-07c8054d57c9089b.js → page-3e86fffabfa87d88.js} +1 -1
- package/dist/dashboard/assets/next/static/chunks/{webpack-40324749d289e4a5.js → webpack-be6e526fd530c797.js} +1 -1
- package/dist/dashboard/assets/next/static/css/{42045de5f39b50ca.css → 37d81e1d2804cc5f.css} +1 -1
- package/dist/dashboard/assets/next/static/css/69ec1bae997c3bb0.css +1 -0
- package/dist/dashboard/assets/next/static/css/ad85402a1595e56e.css +1 -0
- package/dist/dashboard/assets/next/static/css/{4bbe78c2fe206b92.css → da981fb878a02b8c.css} +1 -1
- package/dist/dashboard/assets/next/static/media/bay-morning.82669113.webp +0 -0
- package/dist/dashboard/assets/next/static/media/golden-gate-afternoon.0aa49492.webp +0 -0
- package/dist/dashboard/assets/next/static/media/golden-gate-portrait.89fc667a.webp +0 -0
- package/dist/dashboard/assets/next/static/media/moonlit-coast.09739ef4.webp +0 -0
- package/dist/dashboard/index.html +2 -2
- package/dist/engine.js +6385 -4973
- package/dist/gateway.js +2194 -604
- package/dist/twins/catalog.json +6020 -0
- package/dist/twins/engine/v2/THIRD-PARTY.txt +25 -0
- package/dist/twins/engine/v2/chunks/2CHBP57N.mjs +8 -0
- package/dist/twins/engine/v2/chunks/4CPL6MPF.mjs +30 -0
- package/dist/twins/engine/v2/chunks/OYLYKZGD.mjs +2 -0
- package/dist/twins/engine/v2/chunks/SQSP35HM.mjs +38 -0
- package/dist/twins/engine/v2/chunks/YSJQQVUM.mjs +2 -0
- package/dist/twins/engine/v2/react-dom_client.mjs +272 -0
- package/dist/twins/engine/v2/react-dom_server.mjs +263 -0
- package/dist/twins/engine/v2/react.mjs +2 -0
- package/dist/twins/engine/v2/react_jsx-runtime.mjs +31 -0
- package/dist/twins/engine/v2/volter_world-core.mjs +195 -0
- package/dist/twins/engine/v2/volter_world-core_app-route.mjs +2 -0
- package/dist/twins/engine/v2/volter_world-core_network-policy.mjs +2 -0
- package/dist/twins/engine/v3/THIRD-PARTY.txt +65 -0
- package/dist/twins/engine/v3/chunks/2CHBP57N.mjs +8 -0
- package/dist/twins/engine/v3/chunks/2YSSPA5O.mjs +65 -0
- package/dist/twins/engine/v3/chunks/5PWRY4UK.mjs +154 -0
- package/dist/twins/engine/v3/chunks/7XRKSFFJ.mjs +2 -0
- package/dist/twins/engine/v3/chunks/AWOWH2H5.mjs +2 -0
- package/dist/twins/engine/v3/chunks/C46M5U3Q.mjs +2 -0
- package/dist/twins/engine/v3/chunks/MFH2VZPP.mjs +2 -0
- package/dist/twins/engine/v3/chunks/MWCO5UV3.mjs +2 -0
- package/dist/twins/engine/v3/chunks/N5BL5RDF.mjs +313 -0
- package/dist/twins/engine/v3/chunks/O7HGPMXG.mjs +2 -0
- package/dist/twins/engine/v3/chunks/OYLYKZGD.mjs +2 -0
- package/dist/twins/engine/v3/chunks/PLB7HTON.mjs +8 -0
- package/dist/twins/engine/v3/chunks/TY4LDBVH.mjs +7 -0
- package/dist/twins/engine/v3/chunks/VDIRUSCM.mjs +2 -0
- package/dist/twins/engine/v3/chunks/WGUCFQK6.mjs +2 -0
- package/dist/twins/engine/v3/chunks/WPATONSC.mjs +2 -0
- package/dist/twins/engine/v3/react_jsx-runtime.mjs +2 -0
- package/dist/twins/engine/v3/volter_world-core.mjs +2 -0
- package/dist/twins/engine/v3/volter_world-ui.mjs +559 -0
- package/dist/twins/packs/ahrefs/LICENSE +202 -0
- package/dist/twins/packs/ahrefs/NOTICE +7 -0
- package/dist/twins/packs/ahrefs/index.mjs +2 -0
- package/dist/twins/packs/ai-gateway/LICENSE +202 -0
- package/dist/twins/packs/ai-gateway/NOTICE +7 -0
- package/dist/twins/packs/ai-gateway/index.mjs +14 -0
- package/dist/twins/packs/airtable/LICENSE +202 -0
- package/dist/twins/packs/airtable/NOTICE +7 -0
- package/dist/twins/packs/airtable/index.mjs +2 -0
- package/dist/twins/packs/algolia/LICENSE +202 -0
- package/dist/twins/packs/algolia/NOTICE +7 -0
- package/dist/twins/packs/algolia/index.mjs +2 -0
- package/dist/twins/packs/ambientcg/LICENSE +202 -0
- package/dist/twins/packs/ambientcg/NOTICE +7 -0
- package/dist/twins/packs/ambientcg/index.mjs +2 -0
- package/dist/twins/packs/anthropic/LICENSE +202 -0
- package/dist/twins/packs/anthropic/NOTICE +7 -0
- package/dist/twins/packs/anthropic/index.mjs +18 -0
- package/dist/twins/packs/assemblyai/LICENSE +202 -0
- package/dist/twins/packs/assemblyai/NOTICE +7 -0
- package/dist/twins/packs/assemblyai/index.mjs +11 -0
- package/dist/twins/packs/aws/LICENSE +202 -0
- package/dist/twins/packs/aws/NOTICE +7 -0
- package/dist/twins/packs/aws/index.mjs +2 -0
- package/dist/twins/packs/azure/LICENSE +202 -0
- package/dist/twins/packs/azure/NOTICE +7 -0
- package/dist/twins/packs/azure/index.mjs +38 -0
- package/dist/twins/packs/azureformrecognizer/LICENSE +202 -0
- package/dist/twins/packs/azureformrecognizer/NOTICE +7 -0
- package/dist/twins/packs/azureformrecognizer/index.mjs +3 -0
- package/dist/twins/packs/bitly/LICENSE +202 -0
- package/dist/twins/packs/bitly/NOTICE +7 -0
- package/dist/twins/packs/bitly/index.mjs +2 -0
- package/dist/twins/packs/bluesky/LICENSE +202 -0
- package/dist/twins/packs/bluesky/NOTICE +7 -0
- package/dist/twins/packs/bluesky/index.mjs +30 -0
- package/dist/twins/packs/calcom/LICENSE +202 -0
- package/dist/twins/packs/calcom/NOTICE +7 -0
- package/dist/twins/packs/calcom/index.mjs +2 -0
- package/dist/twins/packs/clerk/LICENSE +202 -0
- package/dist/twins/packs/clerk/NOTICE +7 -0
- package/dist/twins/packs/clerk/index.mjs +5 -0
- package/dist/twins/packs/cloudflare/LICENSE +202 -0
- package/dist/twins/packs/cloudflare/NOTICE +7 -0
- package/dist/twins/packs/cloudflare/index.mjs +79 -0
- package/dist/twins/packs/cohere/LICENSE +202 -0
- package/dist/twins/packs/cohere/NOTICE +7 -0
- package/dist/twins/packs/cohere/index.mjs +2 -0
- package/dist/twins/packs/datadog/LICENSE +202 -0
- package/dist/twins/packs/datadog/NOTICE +7 -0
- package/dist/twins/packs/datadog/index.mjs +3 -0
- package/dist/twins/packs/deepinfra/LICENSE +202 -0
- package/dist/twins/packs/deepinfra/NOTICE +7 -0
- package/dist/twins/packs/deepinfra/index.mjs +13 -0
- package/dist/twins/packs/deepseek/LICENSE +202 -0
- package/dist/twins/packs/deepseek/NOTICE +7 -0
- package/dist/twins/packs/deepseek/index.mjs +12 -0
- package/dist/twins/packs/discord/LICENSE +202 -0
- package/dist/twins/packs/discord/NOTICE +7 -0
- package/dist/twins/packs/discord/index.mjs +2 -0
- package/dist/twins/packs/duckduckgo/LICENSE +202 -0
- package/dist/twins/packs/duckduckgo/NOTICE +7 -0
- package/dist/twins/packs/duckduckgo/index.mjs +532 -0
- package/dist/twins/packs/dynadot/LICENSE +202 -0
- package/dist/twins/packs/dynadot/NOTICE +7 -0
- package/dist/twins/packs/dynadot/index.mjs +2 -0
- package/dist/twins/packs/e2b/LICENSE +202 -0
- package/dist/twins/packs/e2b/NOTICE +7 -0
- package/dist/twins/packs/e2b/index.mjs +2 -0
- package/dist/twins/packs/elevenlabs/LICENSE +202 -0
- package/dist/twins/packs/elevenlabs/NOTICE +7 -0
- package/dist/twins/packs/elevenlabs/index.mjs +4 -0
- package/dist/twins/packs/expo/LICENSE +202 -0
- package/dist/twins/packs/expo/NOTICE +7 -0
- package/dist/twins/packs/expo/index.mjs +2 -0
- package/dist/twins/packs/fal/LICENSE +202 -0
- package/dist/twins/packs/fal/NOTICE +7 -0
- package/dist/twins/packs/fal/index.mjs +2 -0
- package/dist/twins/packs/figma/LICENSE +202 -0
- package/dist/twins/packs/figma/NOTICE +7 -0
- package/dist/twins/packs/figma/index.mjs +2 -0
- package/dist/twins/packs/firecrawl/LICENSE +202 -0
- package/dist/twins/packs/firecrawl/NOTICE +7 -0
- package/dist/twins/packs/firecrawl/index.mjs +9 -0
- package/dist/twins/packs/fireworks/LICENSE +202 -0
- package/dist/twins/packs/fireworks/NOTICE +7 -0
- package/dist/twins/packs/fireworks/index.mjs +13 -0
- package/dist/twins/packs/fly/LICENSE +202 -0
- package/dist/twins/packs/fly/NOTICE +7 -0
- package/dist/twins/packs/fly/index.mjs +2 -0
- package/dist/twins/packs/gcs/LICENSE +202 -0
- package/dist/twins/packs/gcs/NOTICE +7 -0
- package/dist/twins/packs/gcs/index.mjs +8 -0
- package/dist/twins/packs/gemini/LICENSE +202 -0
- package/dist/twins/packs/gemini/NOTICE +7 -0
- package/dist/twins/packs/gemini/index.mjs +7 -0
- package/dist/twins/packs/github/LICENSE +202 -0
- package/dist/twins/packs/github/NOTICE +7 -0
- package/dist/twins/packs/github/index.mjs +75153 -0
- package/dist/twins/packs/googleads/LICENSE +202 -0
- package/dist/twins/packs/googleads/NOTICE +7 -0
- package/dist/twins/packs/googleads/index.mjs +3 -0
- package/dist/twins/packs/googlemaps/LICENSE +202 -0
- package/dist/twins/packs/googlemaps/NOTICE +7 -0
- package/dist/twins/packs/googlemaps/index.mjs +2 -0
- package/dist/twins/packs/googleoauth/LICENSE +202 -0
- package/dist/twins/packs/googleoauth/NOTICE +7 -0
- package/dist/twins/packs/googleoauth/index.mjs +2 -0
- package/dist/twins/packs/hackernews/LICENSE +202 -0
- package/dist/twins/packs/hackernews/NOTICE +7 -0
- package/dist/twins/packs/hackernews/index.mjs +35 -0
- package/dist/twins/packs/huggingface/LICENSE +202 -0
- package/dist/twins/packs/huggingface/NOTICE +7 -0
- package/dist/twins/packs/huggingface/index.mjs +9 -0
- package/dist/twins/packs/inngest/LICENSE +202 -0
- package/dist/twins/packs/inngest/NOTICE +7 -0
- package/dist/twins/packs/inngest/index.mjs +2 -0
- package/dist/twins/packs/instagram/LICENSE +202 -0
- package/dist/twins/packs/instagram/NOTICE +7 -0
- package/dist/twins/packs/instagram/index.mjs +2 -0
- package/dist/twins/packs/jira/LICENSE +202 -0
- package/dist/twins/packs/jira/NOTICE +7 -0
- package/dist/twins/packs/jira/index.mjs +2 -0
- package/dist/twins/packs/langfuse/LICENSE +202 -0
- package/dist/twins/packs/langfuse/NOTICE +7 -0
- package/dist/twins/packs/langfuse/index.mjs +2 -0
- package/dist/twins/packs/linear/LICENSE +202 -0
- package/dist/twins/packs/linear/NOTICE +7 -0
- package/dist/twins/packs/linear/index.mjs +52866 -0
- package/dist/twins/packs/linkedin/LICENSE +202 -0
- package/dist/twins/packs/linkedin/NOTICE +7 -0
- package/dist/twins/packs/linkedin/index.mjs +78 -0
- package/dist/twins/packs/livekit/LICENSE +202 -0
- package/dist/twins/packs/livekit/NOTICE +7 -0
- package/dist/twins/packs/livekit/index.mjs +2 -0
- package/dist/twins/packs/mailgun/LICENSE +202 -0
- package/dist/twins/packs/mailgun/NOTICE +7 -0
- package/dist/twins/packs/mailgun/index.mjs +13 -0
- package/dist/twins/packs/mapbox/LICENSE +202 -0
- package/dist/twins/packs/mapbox/NOTICE +7 -0
- package/dist/twins/packs/mapbox/index.mjs +2 -0
- package/dist/twins/packs/merge/LICENSE +202 -0
- package/dist/twins/packs/merge/NOTICE +7 -0
- package/dist/twins/packs/merge/index.mjs +4 -0
- package/dist/twins/packs/mistral/LICENSE +202 -0
- package/dist/twins/packs/mistral/NOTICE +7 -0
- package/dist/twins/packs/mistral/index.mjs +6 -0
- package/dist/twins/packs/mixpanel/LICENSE +202 -0
- package/dist/twins/packs/mixpanel/NOTICE +8 -0
- package/dist/twins/packs/mixpanel/index.mjs +2 -0
- package/dist/twins/packs/mongodb/LICENSE +202 -0
- package/dist/twins/packs/mongodb/NOTICE +7 -0
- package/dist/twins/packs/mongodb/index.mjs +8 -0
- package/dist/twins/packs/moonshot/LICENSE +202 -0
- package/dist/twins/packs/moonshot/NOTICE +7 -0
- package/dist/twins/packs/moonshot/index.mjs +18 -0
- package/dist/twins/packs/notion/LICENSE +202 -0
- package/dist/twins/packs/notion/NOTICE +7 -0
- package/dist/twins/packs/notion/index.mjs +2 -0
- package/dist/twins/packs/npm-registry/LICENSE +202 -0
- package/dist/twins/packs/npm-registry/NOTICE +7 -0
- package/dist/twins/packs/npm-registry/index.mjs +2 -0
- package/dist/twins/packs/oa-treasury/LICENSE +202 -0
- package/dist/twins/packs/oa-treasury/NOTICE +8 -0
- package/dist/twins/packs/oa-treasury/index.mjs +16 -0
- package/dist/twins/packs/openai/LICENSE +202 -0
- package/dist/twins/packs/openai/NOTICE +7 -0
- package/dist/twins/packs/openai/index.mjs +3473 -0
- package/dist/twins/packs/openrouter/LICENSE +202 -0
- package/dist/twins/packs/openrouter/NOTICE +7 -0
- package/dist/twins/packs/openrouter/index.mjs +2 -0
- package/dist/twins/packs/openweather/LICENSE +202 -0
- package/dist/twins/packs/openweather/NOTICE +7 -0
- package/dist/twins/packs/openweather/index.mjs +2 -0
- package/dist/twins/packs/paypal/LICENSE +202 -0
- package/dist/twins/packs/paypal/NOTICE +7 -0
- package/dist/twins/packs/paypal/index.mjs +51 -0
- package/dist/twins/packs/pinecone/LICENSE +202 -0
- package/dist/twins/packs/pinecone/NOTICE +7 -0
- package/dist/twins/packs/pinecone/index.mjs +2 -0
- package/dist/twins/packs/plain/LICENSE +202 -0
- package/dist/twins/packs/plain/NOTICE +8 -0
- package/dist/twins/packs/plain/index.mjs +18426 -0
- package/dist/twins/packs/planetscale/LICENSE +202 -0
- package/dist/twins/packs/planetscale/NOTICE +7 -0
- package/dist/twins/packs/planetscale/index.mjs +18 -0
- package/dist/twins/packs/polar/LICENSE +202 -0
- package/dist/twins/packs/polar/NOTICE +7 -0
- package/dist/twins/packs/polar/index.mjs +2 -0
- package/dist/twins/packs/polyhaven/LICENSE +202 -0
- package/dist/twins/packs/polyhaven/NOTICE +7 -0
- package/dist/twins/packs/polyhaven/index.mjs +3 -0
- package/dist/twins/packs/postmark/LICENSE +202 -0
- package/dist/twins/packs/postmark/NOTICE +7 -0
- package/dist/twins/packs/postmark/index.mjs +12 -0
- package/dist/twins/packs/reddit/LICENSE +202 -0
- package/dist/twins/packs/reddit/NOTICE +7 -0
- package/dist/twins/packs/reddit/index.mjs +324 -0
- package/dist/twins/packs/redis/LICENSE +202 -0
- package/dist/twins/packs/redis/NOTICE +7 -0
- package/dist/twins/packs/redis/index.mjs +2 -0
- package/dist/twins/packs/replicate/LICENSE +202 -0
- package/dist/twins/packs/replicate/NOTICE +7 -0
- package/dist/twins/packs/replicate/index.mjs +2 -0
- package/dist/twins/packs/resend/LICENSE +202 -0
- package/dist/twins/packs/resend/NOTICE +7 -0
- package/dist/twins/packs/resend/index.mjs +139 -0
- package/dist/twins/packs/runhuman/LICENSE +202 -0
- package/dist/twins/packs/runhuman/NOTICE +7 -0
- package/dist/twins/packs/runhuman/index.mjs +3 -0
- package/dist/twins/packs/scrapecreators/LICENSE +202 -0
- package/dist/twins/packs/scrapecreators/NOTICE +7 -0
- package/dist/twins/packs/scrapecreators/index.mjs +2 -0
- package/dist/twins/packs/segment/LICENSE +202 -0
- package/dist/twins/packs/segment/NOTICE +8 -0
- package/dist/twins/packs/segment/index.mjs +2 -0
- package/dist/twins/packs/sendblue/LICENSE +202 -0
- package/dist/twins/packs/sendblue/NOTICE +7 -0
- package/dist/twins/packs/sendblue/index.mjs +2 -0
- package/dist/twins/packs/sendgrid/LICENSE +202 -0
- package/dist/twins/packs/sendgrid/NOTICE +8 -0
- package/dist/twins/packs/sendgrid/index.mjs +4 -0
- package/dist/twins/packs/sentry/LICENSE +202 -0
- package/dist/twins/packs/sentry/NOTICE +7 -0
- package/dist/twins/packs/sentry/index.mjs +5 -0
- package/dist/twins/packs/sigstore/LICENSE +202 -0
- package/dist/twins/packs/sigstore/NOTICE +7 -0
- package/dist/twins/packs/sigstore/index.mjs +12 -0
- package/dist/twins/packs/slack/LICENSE +202 -0
- package/dist/twins/packs/slack/NOTICE +7 -0
- package/dist/twins/packs/slack/index.mjs +66 -0
- package/dist/twins/packs/smtp/LICENSE +202 -0
- package/dist/twins/packs/smtp/NOTICE +7 -0
- package/dist/twins/packs/smtp/index.mjs +3 -0
- package/dist/twins/packs/snowflake/LICENSE +202 -0
- package/dist/twins/packs/snowflake/NOTICE +8 -0
- package/dist/twins/packs/snowflake/index.mjs +30 -0
- package/dist/twins/packs/stigg/LICENSE +202 -0
- package/dist/twins/packs/stigg/NOTICE +8 -0
- package/dist/twins/packs/stigg/index.mjs +22194 -0
- package/dist/twins/packs/stream/LICENSE +202 -0
- package/dist/twins/packs/stream/NOTICE +7 -0
- package/dist/twins/packs/stream/index.mjs +2 -0
- package/dist/twins/packs/stripe/LICENSE +202 -0
- package/dist/twins/packs/stripe/NOTICE +7 -0
- package/dist/twins/packs/stripe/index.mjs +211 -0
- package/dist/twins/packs/supabase/LICENSE +202 -0
- package/dist/twins/packs/supabase/NOTICE +7 -0
- package/dist/twins/packs/supabase/index.mjs +2 -0
- package/dist/twins/packs/supermemory/LICENSE +202 -0
- package/dist/twins/packs/supermemory/NOTICE +7 -0
- package/dist/twins/packs/supermemory/index.mjs +2 -0
- package/dist/twins/packs/svix/LICENSE +202 -0
- package/dist/twins/packs/svix/NOTICE +7 -0
- package/dist/twins/packs/svix/index.mjs +2 -0
- package/dist/twins/packs/tavily/LICENSE +202 -0
- package/dist/twins/packs/tavily/NOTICE +7 -0
- package/dist/twins/packs/tavily/index.mjs +2 -0
- package/dist/twins/packs/telegram/LICENSE +202 -0
- package/dist/twins/packs/telegram/NOTICE +7 -0
- package/dist/twins/packs/telegram/index.mjs +11 -0
- package/dist/twins/packs/temporal/LICENSE +202 -0
- package/dist/twins/packs/temporal/NOTICE +7 -0
- package/dist/twins/packs/temporal/index.mjs +44 -0
- package/dist/twins/packs/tiktok/LICENSE +202 -0
- package/dist/twins/packs/tiktok/NOTICE +7 -0
- package/dist/twins/packs/tiktok/index.mjs +2 -0
- package/dist/twins/packs/tinybird/LICENSE +202 -0
- package/dist/twins/packs/tinybird/NOTICE +7 -0
- package/dist/twins/packs/tinybird/index.mjs +50 -0
- package/dist/twins/packs/togetherai/LICENSE +202 -0
- package/dist/twins/packs/togetherai/NOTICE +7 -0
- package/dist/twins/packs/togetherai/index.mjs +11 -0
- package/dist/twins/packs/tremendous/LICENSE +202 -0
- package/dist/twins/packs/tremendous/NOTICE +7 -0
- package/dist/twins/packs/tremendous/index.mjs +2 -0
- package/dist/twins/packs/tripo/LICENSE +202 -0
- package/dist/twins/packs/tripo/NOTICE +7 -0
- package/dist/twins/packs/tripo/index.mjs +9 -0
- package/dist/twins/packs/tunnel/LICENSE +202 -0
- package/dist/twins/packs/tunnel/NOTICE +7 -0
- package/dist/twins/packs/tunnel/index.mjs +2 -0
- package/dist/twins/packs/twelvelabs/LICENSE +202 -0
- package/dist/twins/packs/twelvelabs/NOTICE +7 -0
- package/dist/twins/packs/twelvelabs/index.mjs +5 -0
- package/dist/twins/packs/twilio/LICENSE +202 -0
- package/dist/twins/packs/twilio/NOTICE +7 -0
- package/dist/twins/packs/twilio/index.mjs +2 -0
- package/dist/twins/packs/twitch/LICENSE +202 -0
- package/dist/twins/packs/twitch/NOTICE +7 -0
- package/dist/twins/packs/twitch/index.mjs +68 -0
- package/dist/twins/packs/upstash/LICENSE +202 -0
- package/dist/twins/packs/upstash/NOTICE +7 -0
- package/dist/twins/packs/upstash/index.mjs +14 -0
- package/dist/twins/packs/upstashvector/LICENSE +202 -0
- package/dist/twins/packs/upstashvector/NOTICE +7 -0
- package/dist/twins/packs/upstashvector/index.mjs +3 -0
- package/dist/twins/packs/vercel/LICENSE +202 -0
- package/dist/twins/packs/vercel/NOTICE +7 -0
- package/dist/twins/packs/vercel/index.mjs +10 -0
- package/dist/twins/packs/veriff/LICENSE +202 -0
- package/dist/twins/packs/veriff/NOTICE +7 -0
- package/dist/twins/packs/veriff/index.mjs +2 -0
- package/dist/twins/packs/vgauth/LICENSE +202 -0
- package/dist/twins/packs/vgauth/NOTICE +7 -0
- package/dist/twins/packs/vgauth/index.mjs +2 -0
- package/dist/twins/packs/vital/LICENSE +202 -0
- package/dist/twins/packs/vital/NOTICE +7 -0
- package/dist/twins/packs/vital/index.mjs +2 -0
- package/dist/twins/packs/volteridentity/LICENSE +202 -0
- package/dist/twins/packs/volteridentity/NOTICE +7 -0
- package/dist/twins/packs/volteridentity/index.mjs +2 -0
- package/dist/twins/packs/webrisk/LICENSE +202 -0
- package/dist/twins/packs/webrisk/NOTICE +7 -0
- package/dist/twins/packs/webrisk/index.mjs +2 -0
- package/dist/twins/packs/worldlabs/LICENSE +202 -0
- package/dist/twins/packs/worldlabs/NOTICE +7 -0
- package/dist/twins/packs/worldlabs/index.mjs +2 -0
- package/dist/twins/packs/x/LICENSE +202 -0
- package/dist/twins/packs/x/NOTICE +7 -0
- package/dist/twins/packs/x/index.mjs +63 -0
- package/dist/twins/packs/xai/LICENSE +202 -0
- package/dist/twins/packs/xai/NOTICE +7 -0
- package/dist/twins/packs/xai/index.mjs +4 -0
- package/dist/twins/packs/xidentity/LICENSE +202 -0
- package/dist/twins/packs/xidentity/NOTICE +8 -0
- package/dist/twins/packs/xidentity/index.mjs +209 -0
- package/dist/twins/packs/youtube/LICENSE +202 -0
- package/dist/twins/packs/youtube/NOTICE +7 -0
- package/dist/twins/packs/youtube/index.mjs +5 -0
- package/dist/worker.js +442 -18
- package/dist/world-host.js +928 -91
- package/package.json +5 -4
- package/dist/dashboard/assets/dashboard/bay-morning.png +0 -0
- package/dist/dashboard/assets/dashboard/golden-gate-afternoon.png +0 -0
- package/dist/dashboard/assets/dashboard/golden-gate-portrait.png +0 -0
- package/dist/dashboard/assets/dashboard/moonlit-coast.png +0 -0
- package/dist/dashboard/assets/next/static/chunks/2868-424d32cfc8ae81c9.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/docs/[[...slug]]/page-f9fca2c08f779fa0.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/onboarding/page-bc480c9258e5cc4d.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/v2/onboarding/page-f04c0b236abaead3.js +0 -1
- package/dist/dashboard/assets/next/static/css/4af3c8ca0da0f48b.css +0 -1
- package/dist/dashboard/assets/next/static/css/6b8edde77e493a51.css +0 -1
- package/dist/dashboard/assets/next/static/media/bay-morning.1a9f358c.png +0 -0
- package/dist/dashboard/assets/next/static/media/golden-gate-afternoon.3e7cea58.png +0 -0
- package/dist/dashboard/assets/next/static/media/golden-gate-portrait.7941528f.png +0 -0
- package/dist/dashboard/assets/next/static/media/moonlit-coast.bbe901a1.png +0 -0
- /package/dist/dashboard/assets/next/static/{5ub3D2yzS8DE7w2qZd1nv → 8f121VqXS9LLPMmYd1SRn}/_buildManifest.js +0 -0
- /package/dist/dashboard/assets/next/static/{5ub3D2yzS8DE7w2qZd1nv → 8f121VqXS9LLPMmYd1SRn}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{createRequire as __atReq}from'node:module';const require=__atReq(import.meta.url);
|
|
2
|
+
import{applyTwinWrite as Ye,projectResources as Ke,worldNow as Xe}from"../../engine/v2/volter_world-core.mjs";import{nodeBuiltin as Me}from"../../engine/v2/volter_world-core.mjs";function He(){return Me("node:crypto")}var oe=["page.created","page.properties_updated","page.content_updated","page.moved","page.deleted","page.undeleted","page.locked","page.unlocked","database.created","database.schema_updated","database.content_updated","database.moved","database.deleted","database.undeleted","data_source.created","data_source.schema_updated","data_source.content_updated","data_source.deleted","comment.created","comment.updated","comment.deleted"];function we(e,r){return`sha256=${He().createHmac("sha256",r).update(e,"utf8").digest("hex")}`}function ie(e){let r=JSON.stringify(e.event);return{body:r,headers:{"content-type":"application/json","x-notion-signature":we(r,e.verificationToken)}}}var xe=["prop","if","concat","length","round","floor","ceil","abs","max","min","empty","not","and","or","toNumber","format","contains","lower","upper"];function Se(e){let r=[],t=0;for(;t<e.length;){let n=e[t];if(/\s/.test(n)){t+=1;continue}if(n==='"'||n==="'"){let i=n,a="";for(t+=1;t<e.length&&e[t]!==i;){if(e[t]==="\\"&&t+1<e.length){a+=e[t+1],t+=2;continue}a+=e[t],t+=1}if(t>=e.length)return{ok:!1,message:"unterminated string literal"};t+=1,r.push({k:"str",v:a});continue}if(/[0-9]/.test(n)){let i="";for(;t<e.length&&/[0-9.]/.test(e[t]);)i+=e[t],t+=1;r.push({k:"num",v:i});continue}if(/[A-Za-z_]/.test(n)){let i="";for(;t<e.length&&/[A-Za-z0-9_]/.test(e[t]);)i+=e[t],t+=1;r.push({k:"id",v:i});continue}let o=e.slice(t,t+2);if(["==","!=",">=","<=","&&","||"].includes(o)){r.push({k:"op",v:o}),t+=2;continue}if("+-*/%><!".includes(n)){r.push({k:"op",v:n}),t+=1;continue}if("(),".includes(n)){r.push({k:"punc",v:n}),t+=1;continue}return{ok:!1,message:`unexpected character \`${n}\``}}return{ok:!0,toks:r}}function Te(e){let r=0,t=()=>e[r],n=null,o=()=>{let f=e[r];if(!f)return n="unexpected end of expression",null;if(f.k==="num")return r+=1,{t:"lit",v:Number(f.v)};if(f.k==="str")return r+=1,{t:"lit",v:f.v};if(f.k==="op"&&(f.v==="-"||f.v==="!")){r+=1;let m=o();return m?{t:"un",op:f.v,e:m}:null}if(f.k==="punc"&&f.v==="("){r+=1;let m=a(0);return m?t()?.v!==")"?(n="missing `)`",null):(r+=1,m):null}if(f.k==="id"){if(r+=1,f.v==="true"||f.v==="false")return{t:"lit",v:f.v==="true"};if(t()?.k==="punc"&&t().v==="("){r+=1;let m=[];if(!(t()?.k==="punc"&&t().v===")"))for(;;){let h=a(0);if(!h)return null;if(m.push(h),t()?.k==="punc"&&t().v===","){r+=1;continue}break}return t()?.v!==")"?(n=`missing \`)\` after ${f.v}(`,null):(r+=1,xe.includes(f.v)?{t:"call",name:f.v,args:m}:(n=`\`${f.v}()\` is not a formula function this twin evaluates`,null))}return n=`\`${f.v}\` is not a value \u2014 reference a property with prop("${f.v}")`,null}return n=`unexpected token \`${f.v}\``,null},i={"||":1,"&&":2,"==":3,"!=":3,">":4,"<":4,">=":4,"<=":4,"+":5,"-":5,"*":6,"/":6,"%":6};function a(f){let m=o();if(!m)return null;for(;;){let h=t();if(!h||h.k!=="op"||i[h.v]===void 0||i[h.v]<f)break;let S=h.v;r+=1;let u=a(i[S]+1);if(!u)return null;m={t:"bin",op:S,l:m,r:u}}return m}let s=a(0);return s?r!==e.length?{ok:!1,message:`unexpected trailing \`${e[r].v}\``}:{ok:!0,node:s}:{ok:!1,message:n??"could not parse expression"}}function ae(e){let r=Se(e);if(!r.ok)return{ok:!1,message:r.message};if(r.toks.length===0)return{ok:!1,message:"expression is empty"};let t=Te(r.toks);return t.ok?{ok:!0}:{ok:!1,message:t.message}}var x=e=>typeof e=="number"?e:typeof e=="boolean"?e?1:0:Number(e??0)||0,j=e=>e==null?"":String(e);function H(e,r){switch(e.t){case"lit":return e.v;case"un":{let t=H(e.e,r);return e.op==="-"?-x(t):!t}case"bin":{let t=H(e.l,r),n=H(e.r,r);switch(e.op){case"+":return typeof t=="string"||typeof n=="string"?j(t)+j(n):x(t)+x(n);case"-":return x(t)-x(n);case"*":return x(t)*x(n);case"/":return x(n)===0?null:x(t)/x(n);case"%":return x(n)===0?null:x(t)%x(n);case"==":return t===n;case"!=":return t!==n;case">":return x(t)>x(n);case"<":return x(t)<x(n);case">=":return x(t)>=x(n);case"<=":return x(t)<=x(n);case"&&":return!!t&&!!n;case"||":return!!t||!!n;default:return null}}case"call":{let t=e.args,n=o=>t[o]?H(t[o],r):null;switch(e.name){case"prop":return r(j(n(0)));case"if":return n(0)?n(1):n(2);case"concat":return t.map((o,i)=>j(n(i))).join("");case"length":return j(n(0)).length;case"round":return Math.round(x(n(0)));case"floor":return Math.floor(x(n(0)));case"ceil":return Math.ceil(x(n(0)));case"abs":return Math.abs(x(n(0)));case"max":return Math.max(...t.map((o,i)=>x(n(i))));case"min":return Math.min(...t.map((o,i)=>x(n(i))));case"empty":{let o=n(0);return o==null||o===""||Array.isArray(o)&&o.length===0}case"not":return!n(0);case"and":return!!n(0)&&!!n(1);case"or":return!!n(0)||!!n(1);case"toNumber":{let o=Number(j(n(0)));return Number.isFinite(o)?o:null}case"format":return j(n(0));case"contains":return j(n(0)).includes(j(n(1)));case"lower":return j(n(0)).toLowerCase();case"upper":return j(n(0)).toUpperCase();default:return null}}}}function se(e,r){let t=Se(e);if(!t.ok)return{type:"string",value:null};let n=Te(t.toks);if(!n.ok)return{type:"string",value:null};let o=H(n.node,r);return typeof o=="number"?Number.isFinite(o)?{type:"number",value:o}:{type:"number",value:null}:typeof o=="boolean"?{type:"boolean",value:o}:o==null?{type:"string",value:null}:{type:"string",value:j(o)}}var ee=["count","count_values","empty","not_empty","unique","show_unique","show_original","sum","average","median","min","max","range","percent_empty","percent_not_empty"],Je=e=>e==null||e===""||Array.isArray(e)&&e.length===0;function le(e,r,t){let n=r.filter(a=>!Je(a)),o=n.map(a=>typeof a=="number"?a:Number(a)).filter(a=>Number.isFinite(a)),i=a=>({type:"number",number:a,function:e});switch(e){case"count":return i(t);case"count_values":return i(n.length);case"empty":return i(r.length-n.length);case"not_empty":return i(n.length);case"unique":return i(new Set(n.map(a=>JSON.stringify(a))).size);case"percent_empty":return i(r.length===0?0:(r.length-n.length)/r.length*100);case"percent_not_empty":return i(r.length===0?0:n.length/r.length*100);case"sum":return i(o.reduce((a,s)=>a+s,0));case"average":return i(o.length?o.reduce((a,s)=>a+s,0)/o.length:null);case"median":{if(!o.length)return i(null);let a=[...o].sort((f,m)=>f-m),s=Math.floor(a.length/2);return i(a.length%2?a[s]:(a[s-1]+a[s])/2)}case"min":return i(o.length?Math.min(...o):null);case"max":return i(o.length?Math.max(...o):null);case"range":return i(o.length?Math.max(...o)-Math.min(...o):null);case"show_unique":{let a=new Set,s=[];for(let f of n){let m=JSON.stringify(f);a.has(m)||(a.add(m),s.push(f))}return{type:"array",array:s,function:e}}default:return{type:"array",array:r,function:e}}}var Pe="notion";var de=["2022-06-28","2025-09-03"],W="2025-09-03";function M(e){return I(`data_source:${e}`)}function U(e,r,t,n){return{status:e,body:{object:"error",status:e,code:r,message:t,request_id:"req_twin"},...n?{headers:n}:{}}}var w=e=>U(404,"object_not_found",e),_=e=>U(400,"validation_error",e);function I(e){let r=n=>{let o=(2166136261^n)>>>0;for(let i=0;i<e.length;i+=1)o^=e.charCodeAt(i),o=Math.imul(o,16777619)>>>0;return o.toString(16).padStart(8,"0")},t=`${r(1)}${r(2)}${r(3)}${r(4)}`;return`${t.slice(0,8)}-${t.slice(8,12)}-4${t.slice(13,16)}-8${t.slice(17,20)}-${t.slice(20,32)}`}function J(e,r){return I(`${e}:${O(e,r).length+1}`)}function N(e){let r=e.replace(/-/g,"");return/^[0-9a-fA-F]{32}$/.test(r)?`${r.slice(0,8)}-${r.slice(8,12)}-${r.slice(12,16)}-${r.slice(16,20)}-${r.slice(20)}`.toLowerCase():e}function O(e,r){return Ke(Pe,r).filter(t=>t.type===e)}function k(e,r,t){return O(e,t).find(n=>n.id===r)}async function E(e,r,t,n,o){await Ye(Pe,{operation:`set.${e}`,subjectType:e,subjectId:r,fields:t,...o?{occurredAt:o}:{},actor:{kind:"agent"}},n)}function Ze(e){if(!e)return{ok:!0,value:{}};try{let r=JSON.parse(e);return r&&typeof r=="object"&&!Array.isArray(r)?{ok:!0,value:r}:{ok:!1}}catch{return{ok:!1}}}var De={bold:!1,italic:!1,strikethrough:!1,underline:!1,code:!1,color:"default"},Ne=["default","gray","brown","orange","yellow","green","blue","purple","pink","red"],Be=new Set([...Ne,...Ne.filter(e=>e!=="default").map(e=>`${e}_background`)]);function Ue(e){return[{type:"text",text:{content:e,link:null},annotations:{...De},plain_text:e,href:null}]}function L(e){return Array.isArray(e)?e.map(r=>String(r?.plain_text??r?.text?.content??"")).join(""):""}function Qe(e){let r=e??{};if(typeof r!="object"||Array.isArray(r))return{ok:!1,message:"annotations should be an object."};for(let t of["bold","italic","strikethrough","underline","code"])if(r[t]!==void 0&&typeof r[t]!="boolean")return{ok:!1,message:`annotations.${t} should be a boolean, instead was \`${JSON.stringify(r[t])}\`.`};return r.color!==void 0&&!Be.has(String(r.color))?{ok:!1,message:`annotations.color should be one of the Notion colors, instead was \`${JSON.stringify(r.color)}\`.`}:{ok:!0,value:{...De,...r}}}function et(e,r){if(!e||typeof e!="object"||Array.isArray(e))return{ok:!1,message:`a rich text item should be an object, instead was \`${JSON.stringify(e??null)}\`.`};let t=Qe(e.annotations);if(!t.ok)return t;let n=t.value,o=typeof e.type=="string"?e.type:e.mention?"mention":e.equation?"equation":"text";if(o==="equation"){let f=e.equation?.expression;return typeof f!="string"?{ok:!1,message:"equation.expression should be a string."}:{ok:!0,value:{type:"equation",equation:{expression:f},annotations:n,plain_text:f,href:null}}}if(o==="mention"){let f=e.mention??{},m=String(f.type??"");if(m==="date"){let h=f.date?.start;if(typeof h!="string")return{ok:!1,message:"mention.date.start should be an ISO 8601 string."};let S={start:h,end:f.date?.end??null,time_zone:f.date?.time_zone??null};return{ok:!0,value:{type:"mention",mention:{type:"date",date:S},annotations:n,plain_text:S.end?`${h} \u2192 ${S.end}`:h,href:null}}}if(m==="user"||m==="page"||m==="database"){let h=f[m]?.id;if(typeof h!="string")return{ok:!1,message:`mention.${m}.id should be a string.`};let S=r?.(m,h)??h;return{ok:!0,value:{type:"mention",mention:{type:m,[m]:{id:h}},annotations:n,plain_text:S,href:m==="user"?null:`https://www.notion.so/${h.replace(/-/g,"")}`}}}return{ok:!1,message:`mention.type \`"${m}"\` is not one of the mention types this twin models (user, page, database, date).`}}let i=e.text?.content;if(typeof i!="string")return{ok:!1,message:`text.content should be a string, instead was \`${JSON.stringify(i??null)}\`.`};let a=e.text?.link??null,s=a&&typeof a=="object"?a.url:null;return a!==null&&typeof s!="string"?{ok:!1,message:"text.link should be null or an object with a `url` string."}:{ok:!0,value:{type:"text",text:{content:i,link:s?{url:s}:null},annotations:n,plain_text:i,href:s??null}}}function Y(e){return(r,t)=>{let n=N(t);if(r==="user"){for(let i of[$,te])if(i.id===n)return i.name;let o=k("user",n,e);return o&&String(o.name??"")||null}if(r==="page"){let o=k("page",n,e);if(!o)return null;let i=o.properties??{};for(let a of Object.values(i))if(a?.type==="title")return L(a.title)||null;return null}if(r==="database"){let o=k("database",n,e);return o&&L(o.title)||null}return null}}function R(e,r,t){if(!Array.isArray(e))return{ok:!1,message:`body failed validation: ${r} should be an array, instead was \`${JSON.stringify(e??null)}\`.`};let n=[];for(let o=0;o<e.length;o++){let i=et(e[o],t);if(!i.ok)return{ok:!1,message:`body failed validation: ${r}[${o}] \u2014 ${i.message}`};n.push(i.value)}return{ok:!0,value:n}}var tt="9f1e5c2a-0000-4000-8000-5f3b1d2c4e60",$={object:"user",id:"0e9539cd-1b1b-4bc7-bd0a-1f2f5d1f6a30",name:"Twin Integration",avatar_url:null,type:"bot",bot:{owner:{type:"workspace",workspace:!0},workspace_name:"Twin Workspace"}},te={object:"user",id:"d40e767c-d7af-4b18-a86d-55c61f1e39a4",name:"Ada Twin",avatar_url:null,type:"person",person:{email:"ada@notion.twin"}};function nt(e){let r={object:"user",id:e.id,name:e.name??null,avatar_url:e.avatar_url??null,type:e.userType??"person"};return r.type==="person"?r.person={email:e.email??null}:r.bot=e.bot??{owner:{type:"workspace",workspace:!0},workspace_name:"Twin Workspace"},r}function Oe(e){let r=new Set([$.id,te.id]),t=O("user",e).map(nt).filter(n=>!r.has(String(n.id)));return[$,te,...t]}function F(e,r=!1){return e.parentType==="database_id"?r?{type:"data_source_id",data_source_id:M(String(e.parentId)),database_id:e.parentId}:{type:"database_id",database_id:e.parentId}:e.parentType==="page_id"?{type:"page_id",page_id:e.parentId}:e.parentType==="block_id"?{type:"block_id",block_id:e.parentId}:{type:"workspace",workspace:!0}}function q(e,r=!1){let t=e.archived===!0;return{object:"page",id:e.id,created_time:e.created_time,last_edited_time:e.last_edited_time,created_by:{object:"user",id:$.id},last_edited_by:{object:"user",id:$.id},cover:e.cover??null,icon:e.icon??null,parent:F(e,r),archived:t,in_trash:t,properties:e.properties??{},url:`https://www.notion.so/${String(e.id).replace(/-/g,"")}`,public_url:null}}function rt(e){return{object:"webhook",id:e.id,url:e.url,event_types:e.event_types??[],active:e.active!==!1,created_time:e.created_time}}function Ie(e){let r=e.archived===!0;return{object:"data_source",id:M(String(e.id)),created_time:e.created_time,last_edited_time:e.last_edited_time,name:L(e.title),description:e.description??[],icon:e.icon??null,properties:e.properties??{},parent:{type:"database_id",database_id:e.id},database_parent:F(e,!0),archived:r,in_trash:r}}function K(e,r=!1){let t=e.archived===!0;return{object:"database",id:e.id,created_time:e.created_time,last_edited_time:e.last_edited_time,created_by:{object:"user",id:$.id},last_edited_by:{object:"user",id:$.id},title:e.title??[],description:e.description??[],icon:e.icon??null,cover:e.cover??null,...r?{data_sources:[{id:M(String(e.id)),name:L(e.title)}]}:{properties:e.properties??{}},parent:F(e,r),url:`https://www.notion.so/${String(e.id).replace(/-/g,"")}`,public_url:null,archived:t,in_trash:t,is_inline:e.is_inline??!1}}function G(e){let r=e.archived===!0;return{object:"block",id:e.id,parent:F(e),created_time:e.created_time,last_edited_time:e.last_edited_time,created_by:{object:"user",id:$.id},last_edited_by:{object:"user",id:$.id},has_children:e.has_children===!0,archived:r,in_trash:r,type:e.blockType,[e.blockType]:e.payload??{}}}function $e(e){return{object:"comment",id:e.id,parent:F(e),discussion_id:e.discussion_id,created_time:e.created_time,last_edited_time:e.last_edited_time,created_by:{object:"user",id:$.id},rich_text:e.rich_text??[]}}function ge(e){let r=e.properties??{};for(let t of Object.values(r)){let n=t;if(n?.type==="title")return L(n.title)}return""}function X(e,r){let t=100;if(r.page_size!==void 0&&r.page_size!==null){let a=Number(r.page_size);if(!Number.isInteger(a)||a<1||a>100)return{error:_(`body failed validation: body.page_size should be an integer in [1, 100], instead was \`${String(r.page_size)}\`.`)};t=a}let n=0;if(r.start_cursor!==void 0&&r.start_cursor!==null){if(typeof r.start_cursor!="string")return{error:_("The start_cursor provided is invalid.")};let a=e.findIndex(s=>s.id===N(r.start_cursor));if(a<0)return{error:_(`The start_cursor provided is invalid: ${r.start_cursor}`)};n=a}let o=e.slice(n,n+t),i=e[n+t];return{page:o,next:i?String(i.id):null}}function V(e,r,t){return{status:200,body:{object:"list",results:e,next_cursor:r,has_more:r!==null,type:t,[t]:{}}}}function ce(e,r){return O("block",r).filter(t=>t.parentId===e&&t.archived!==!0).sort((t,n)=>(Number(t.order)||0)-(Number(n.order)||0))}function ot(e,r){let t=O("block",r).filter(n=>n.parentId===e);return t.length===0?1:Math.max(...t.map(n=>Number(n.order)||0))+1}function it(e,r){return{object:"block",id:e.id,parent:F(e),created_time:e.created_time,last_edited_time:e.last_edited_time,created_by:{object:"user",id:$.id},last_edited_by:{object:"user",id:$.id},has_children:ce(String(e.id),r).length>0,archived:e.archived===!0,in_trash:e.archived===!0,type:"child_page",child_page:{title:ge(e)}}}var ne=["paragraph","heading_1","heading_2","heading_3","bulleted_list_item","numbered_list_item","to_do","toggle","quote","callout","code","divider","image","video","audio","file","pdf","bookmark","embed","link_to_page","equation","table","table_row","column_list","column","breadcrumb","table_of_contents","synced_block","template"],Le=new Set(["paragraph","heading_1","heading_2","heading_3","bulleted_list_item","numbered_list_item","to_do","toggle","quote","callout","code","template"]),at=new Set(["image","video","audio","file","pdf"]),st=new Set([...Le,"table_of_contents"]);function he(e,r){let t=typeof e?.type=="string"?e.type:e?.external?"external":e?.file?"file":null;if(t==="external"){let n=e.external?.url;return typeof n!="string"||n.length===0?{ok:!1,message:`${r}.external.url should be a non-empty string.`}:{ok:!0,value:{type:"external",external:{url:n}}}}if(t==="file"){let n=e.file?.url;if(typeof n!="string"||n.length===0)return{ok:!1,message:`${r}.file.url should be a non-empty string.`};let o=typeof e.file?.expiry_time=="string"?e.file.expiry_time:"2100-01-01T00:00:00.000Z";return{ok:!0,value:{type:"file",file:{url:n,expiry_time:o}}}}return{ok:!1,message:`${r} should define \`external\` or \`file\`.`}}function ze(e,r,t){if(!ne.includes(e))return{ok:!1,message:`body failed validation: block type \`"${e}"\` is not one of the block types this twin models (${ne.join(", ")}).`};if(e==="divider"||e==="breadcrumb"||e==="column_list"||e==="column")return{ok:!0,payload:{}};let n={...r??{}};if(Le.has(e)){let o=R(n.rich_text,`body.${e}.rich_text`,t);if(!o.ok)return{ok:!1,message:o.message};n.rich_text=o.value}if(st.has(e)){if(n.color!==void 0&&!Be.has(String(n.color)))return{ok:!1,message:`body failed validation: body.${e}.color should be one of the Notion colors, instead was \`${JSON.stringify(n.color)}\`.`};n.color=n.color??"default"}if(at.has(e)){let o=he(n,`body.${e}`);if(!o.ok)return{ok:!1,message:`body failed validation: ${o.message}`};let i=R(n.caption??[],`body.${e}.caption`,t);if(!i.ok)return{ok:!1,message:i.message};let a={...o.value,caption:i.value};return e==="file"&&typeof n.name=="string"&&(a.name=n.name),{ok:!0,payload:a}}if(e==="bookmark"||e==="embed"){if(typeof n.url!="string"||n.url.length===0)return{ok:!1,message:`body failed validation: body.${e}.url should be a non-empty string.`};let o=R(n.caption??[],`body.${e}.caption`,t);return o.ok?{ok:!0,payload:{url:n.url,caption:o.value}}:{ok:!1,message:o.message}}if(e==="equation")return typeof n.expression!="string"||n.expression.length===0?{ok:!1,message:"body failed validation: body.equation.expression should be a non-empty string."}:{ok:!0,payload:{expression:n.expression}};if(e==="link_to_page"){let o=typeof n.type=="string"?n.type:n.page_id?"page_id":n.database_id?"database_id":null;if(o!=="page_id"&&o!=="database_id")return{ok:!1,message:"body failed validation: body.link_to_page should define `page_id` or `database_id`."};let i=n[o];return typeof i!="string"?{ok:!1,message:`body failed validation: body.link_to_page.${o} should be a string.`}:{ok:!0,payload:{type:o,[o]:N(i)}}}if(e==="synced_block"){let o=n.synced_from??null;if(o===null)return{ok:!0,payload:{synced_from:null}};let i=o?.block_id;return typeof i!="string"?{ok:!1,message:"body failed validation: body.synced_block.synced_from should be null or define `block_id`."}:{ok:!0,payload:{synced_from:{type:"block_id",block_id:N(i)}}}}if(e==="table"){let o=n.table_width;return typeof o!="number"||!Number.isInteger(o)||o<1?{ok:!1,message:"body failed validation: body.table.table_width should be a positive integer."}:{ok:!0,payload:{table_width:o,has_column_header:n.has_column_header===!0,has_row_header:n.has_row_header===!0}}}if(e==="table_row"){let o=n.cells;if(!Array.isArray(o))return{ok:!1,message:"body failed validation: body.table_row.cells should be an array of rich-text arrays."};let i=[];for(let a=0;a<o.length;a++){let s=R(o[a],`body.table_row.cells[${a}]`,t);if(!s.ok)return{ok:!1,message:s.message};i.push(s.value)}return{ok:!0,payload:{cells:i}}}if(e==="to_do"&&(n.checked=n.checked===!0),e==="code"&&(n.language=n.language??"plain text"),e==="callout"&&n.icon!==void 0&&n.icon!==null){let o=lt(n.icon,"body.callout.icon");if(!o.ok)return{ok:!1,message:`body failed validation: ${o.message}`};n.icon=o.value}return{ok:!0,payload:n}}function lt(e,r){if(e==null)return{ok:!0,value:null};let t=e;return(typeof t.type=="string"?t.type:t.emoji?"emoji":null)==="emoji"?typeof t.emoji!="string"||t.emoji.length===0?{ok:!1,message:`${r}.emoji should be a non-empty string.`}:{ok:!0,value:{type:"emoji",emoji:t.emoji}}:he(t,r)}var ye=["title","rich_text","number","checkbox","select","multi_select","url","email","date","status","people","phone_number","files","relation","created_time","last_edited_time","created_by","last_edited_by","unique_id","formula","rollup","button","verification"],ut=new Set(["created_time","last_edited_time","created_by","last_edited_by","unique_id","formula","rollup","button","verification"]);async function B(e,r,t,n,o,i){let a=O("webhook",n).filter(s=>s.active!==!1);for(let s of a){let f=Array.isArray(s.event_types)?s.event_types:[];if(f.length&&!f.includes(e))continue;let m=O("webhook_delivery",n).length+1,h=I(`webhook_delivery:${m}`),S={id:h,timestamp:i,workspace_id:tt,workspace_name:"Twin Workspace",subscription_id:String(s.id),integration_id:$.id,type:e,authors:[{id:$.id,type:"bot"}],attempt_number:1,entity:r,...t?{data:t}:{}},u=ie({event:S,verificationToken:String(s.verification_token)});await E("webhook_delivery",h,{subscriptionId:s.id,url:s.url,eventType:e,body:u.body,headers:u.headers,delivered_at:i},n,o)}}function ue(e,r){let t={};for(let[n,o]of Object.entries(e??{})){let i=o,a=r?r[n]:void 0;if(r&&!a)return{ok:!1,message:`${n} is not a property that exists.`};let s=a?.type??dt(i);if(!s)return{ok:!1,message:`body failed validation: body.properties.${n} is not a recognized property value.`};if(ut.has(String(s)))return{ok:!1,message:`${n} is not a property that can be updated.`};let f=ct(n,String(s),i,a);if(!f)return{ok:!1,message:`${n} is expected to be ${s}.`};t[n]=f}return{ok:!0,properties:t}}function dt(e){for(let r of ye)if(e&&Object.prototype.hasOwnProperty.call(e,r))return r;return null}function Ee(e,r,t){return(e?.[r]?.options??[]).find(o=>String(o?.name)===t)}function ct(e,r,t,n){let o=I(`prop:${e}:${r}`).slice(0,8),i=t?.[r];switch(r){case"title":case"rich_text":{let a=R(i,r);return a.ok?{id:o,type:r,[r]:a.value}:null}case"number":return i!=null&&typeof i!="number"?null:{id:o,type:"number",number:i??null};case"checkbox":return typeof i!="boolean"?null:{id:o,type:"checkbox",checkbox:i};case"select":case"status":{if(i===null)return{id:o,type:r,[r]:null};let a=i?.name;if(typeof a!="string")return null;let s=Ee(n,r,a);return r==="status"&&n&&!s?null:{id:o,type:r,[r]:{id:I(`opt:${a}`),name:a,color:s?.color??"default"}}}case"multi_select":return!Array.isArray(i)||i.some(a=>typeof a?.name!="string")?null:{id:o,type:r,multi_select:i.map(a=>{let s=Ee(n,"multi_select",String(a.name));return{id:I(`opt:${a.name}`),name:String(a.name),color:s?.color??"default"}})};case"url":case"email":return i!=null&&typeof i!="string"?null:{id:o,type:r,[r]:i??null};case"date":return i===null?{id:o,type:"date",date:null}:typeof i?.start!="string"?null:{id:o,type:"date",date:{start:i.start,end:i.end??null,time_zone:i.time_zone??null}};case"people":return Array.isArray(i)?{id:o,type:"people",people:i.map(a=>({object:"user",id:String(a?.id)}))}:null;case"phone_number":return i!=null&&typeof i!="string"?null:{id:o,type:r,phone_number:i??null};case"files":{if(!Array.isArray(i))return null;let a=[];for(let s of i){let f=he(s,"files");if(!f.ok)return null;a.push({name:typeof s?.name=="string"?s.name:"",...f.value})}return{id:o,type:r,files:a}}case"relation":return!Array.isArray(i)||i.some(a=>typeof a?.id!="string")?null:{id:o,type:r,relation:i.map(a=>({id:N(String(a.id))})),has_more:!1};default:return null}}function pt(e,r){let t={},n={title:[],rich_text:[],number:null,checkbox:!1,select:null,status:null,multi_select:[],url:null,email:null,date:null,people:[],phone_number:null,files:[],relation:[]};for(let[o,i]of Object.entries(e??{})){let a=String(i.type),s=I(`prop:${o}:${a}`).slice(0,8),f=r?ft(a,i,r):void 0;if(f!==void 0){t[o]={id:s,type:a,...f};continue}let m={id:s,type:a,[a]:n[a]??null};a==="relation"&&(m.has_more=!1),t[o]=m}return t}function ft(e,r,t){switch(e){case"created_time":return{created_time:t.created_time};case"last_edited_time":return{last_edited_time:t.last_edited_time};case"created_by":return{created_by:{object:"user",id:$.id}};case"last_edited_by":return{last_edited_by:{object:"user",id:$.id}};case"unique_id":{let n=r.unique_id?.prefix;return{unique_id:{prefix:typeof n=="string"&&n?n:null,number:t.uniqueNumber}}}case"button":return{button:{}};case"verification":return{verification:null};case"formula":case"rollup":return;default:return}}async function Ae(e,r,t,n,o,i,a){if(r)for(let[s,f]of Object.entries(r)){let m=f.relation??{};if(String(f.type)!=="relation"||m.type!=="dual_property")continue;let h=m.dual_property?.synced_property_name;if(typeof h!="string")continue;let S=l=>(l?.[s]?.relation??[]).map(c=>String(c.id)),u=new Set(S(n)),T=new Set(S(t)),P=[...u].filter(l=>!T.has(l)),d=[...T].filter(l=>!u.has(l));for(let l of[...P,...d]){let c=k("page",l,o);if(!c)continue;let p={...c.properties??{}},y=(p[h]?.relation??[]).map(b=>String(b.id)).filter(b=>b!==e);P.includes(l)&&y.push(e),p[h]={id:I(`prop:${h}:relation`).slice(0,8),type:"relation",relation:y.map(b=>({id:b})),has_more:!1},await E("page",l,{properties:p,last_edited_time:a},o,i)}}}function je(e,r){let t={...e};for(let[n,o]of Object.entries(r??{})){let i=o,a=t[n];if(i===null){if(!a)return{ok:!1,message:`${n} is not a property that exists.`};if(a.type==="title")return{ok:!1,message:"Cannot remove the `title` property."};delete t[n];continue}if(!i||typeof i!="object"||Array.isArray(i))return{ok:!1,message:`body failed validation: body.properties.${n} should be an object or null.`};if(!a){let m=qe(i);if(!m)return{ok:!1,message:`body failed validation: body.properties.${n} is not a recognized property configuration.`};if(m==="title")return{ok:!1,message:"Cannot add a second `title` property."};let h=pe(m,i[m]);if(!h.ok)return{ok:!1,message:h.message};t[n]={id:I(`prop:${n}:${m}`).slice(0,8),name:n,type:m,[m]:h.value};continue}let s=String(a.type),f={...a};if(typeof i.name=="string"&&(f.name=i.name),i[s]!==void 0){let m=pe(s,i[s]);if(!m.ok)return{ok:!1,message:m.message};f[s]=m.value}if(typeof i.name=="string"&&i.name!==n){if(t[i.name])return{ok:!1,message:`${i.name} is already a property that exists.`};delete t[n],t[i.name]=f}else t[n]=f}return Object.values(t).some(n=>n.type==="title")?{ok:!0,schema:t}:{ok:!1,message:"exactly one property must be of type `title`."}}function pe(e,r){let t=r??{};if(e==="select"||e==="multi_select"||e==="status"){let n=t.options;if(n===void 0)return{ok:!0,value:{options:[]}};if(!Array.isArray(n))return{ok:!1,message:`body failed validation: ${e}.options should be an array.`};let o=new Set,i=[];for(let a of n){let s=a?.name;if(typeof s!="string"||s.length===0)return{ok:!1,message:`body failed validation: ${e}.options[].name should be a non-empty string.`};if(o.has(s))return{ok:!1,message:`body failed validation: ${e}.options contains the duplicate name \`${s}\`.`};o.add(s);let f=a.color;if(f!==void 0&&!mt.has(String(f)))return{ok:!1,message:`body failed validation: ${e}.options[].color should be one of the Notion option colors, instead was \`${JSON.stringify(f)}\`.`};i.push({id:I(`opt:${s}`),name:s,color:f??"default",...typeof a.description=="string"?{description:a.description}:{}})}if(e==="status"){let a=Array.isArray(t.groups)?t.groups:[];return{ok:!0,value:{options:i,groups:a.map(s=>({id:I(`grp:${s?.name}`),name:String(s?.name??""),color:s?.color??"default",option_ids:Array.isArray(s?.option_ids)?s.option_ids:[]}))}}}return{ok:!0,value:{options:i}}}if(e==="relation"){let n=t.database_id;if(typeof n!="string")return{ok:!1,message:"body failed validation: relation.database_id should be a string."};if((typeof t.type=="string"?t.type:t.dual_property?"dual_property":"single_property")==="dual_property"){let i=t.dual_property?.synced_property_name;return typeof i!="string"||i.length===0?{ok:!1,message:"body failed validation: relation.dual_property.synced_property_name should be a non-empty string."}:{ok:!0,value:{database_id:N(n),type:"dual_property",dual_property:{synced_property_name:i,synced_property_id:I(`prop:${i}:relation`).slice(0,8)}}}}return{ok:!0,value:{database_id:N(n),type:"single_property",single_property:{}}}}if(e==="formula"){let n=t.expression;if(typeof n!="string")return{ok:!1,message:"body failed validation: formula.expression should be a string."};let o=ae(n);return o.ok?{ok:!0,value:{expression:n}}:{ok:!1,message:`body failed validation: formula.expression \u2014 ${o.message}.`}}if(e==="rollup"){let n=t.relation_property_name,o=t.rollup_property_name,i=t.function;return typeof n!="string"||typeof o!="string"?{ok:!1,message:"body failed validation: rollup should define `relation_property_name` and `rollup_property_name`."}:ee.includes(String(i))?{ok:!0,value:{relation_property_name:n,rollup_property_name:o,function:String(i)}}:{ok:!1,message:`body failed validation: rollup.function \`${String(i)}\` is not one of the aggregations this twin computes (${ee.join(", ")}).`}}if(e==="number"){let n=t.format;return n!==void 0&&typeof n!="string"?{ok:!1,message:"body failed validation: number.format should be a string."}:{ok:!0,value:{format:n??"number"}}}return{ok:!0,value:t}}var mt=new Set(["default","gray","brown","orange","yellow","green","blue","purple","pink","red"]);function gt(e){let r={},t=0;for(let[n,o]of Object.entries(e??{})){let i=qe(o);if(!i)return{ok:!1,message:`body failed validation: body.properties.${n} is not a recognized property configuration.`};i==="title"&&(t+=1);let a=pe(i,o[i]);if(!a.ok)return{ok:!1,message:a.message};r[n]={id:I(`prop:${n}:${i}`).slice(0,8),name:n,type:i,[i]:a.value}}return t!==1?{ok:!1,message:"body failed validation: exactly one property must be of type `title`."}:{ok:!0,schema:r}}function qe(e){for(let r of ye)if(e&&Object.prototype.hasOwnProperty.call(e,r))return r;return null}function Z(e,r){if(e.parentType!=="database_id")return e;let n=k("database",String(e.parentId),r)?.properties??{},o={};for(let[i,a]of Object.entries(n)){let s=String(a.type),f=I(`prop:${i}:${s}`).slice(0,8);if(s==="rollup"){let m=a.rollup??{},h=(e.properties??{})[String(m.relation_property_name)]?.relation??[],S=[];for(let u of h){let T=k("page",String(u.id),r);T&&S.push(Q(T,String(m.rollup_property_name)))}o[i]={id:f,type:"rollup",rollup:le(String(m.function),S,h.length)};continue}if(s==="formula"){let m=String((a.formula??{}).expression??""),h=se(m,S=>{let u={...e.properties??{},...o},T=u[S];return T?T.type==="rollup"?T.rollup?.number??T.rollup?.array??null:Q({properties:u},S):null});o[i]={id:f,type:"formula",formula:{type:h.type,[h.type]:h.value}}}}return Object.keys(o).length?{...e,properties:{...e.properties??{},...o}}:e}function Q(e,r){let t=(e.properties??{})[r];if(t)switch(t.type){case"title":return L(t.title);case"rich_text":return L(t.rich_text);case"number":return t.number;case"checkbox":return t.checkbox;case"select":return t.select?.name??null;case"status":return t.status?.name??null;case"multi_select":return(t.multi_select??[]).map(n=>n.name);case"url":case"email":return t[t.type]??null;case"date":return t.date?.start??null;default:return}}function fe(e,r){if(Array.isArray(r?.and)){let s=r.and.map(f=>fe(e,f));return s.includes(null)?null:s.every(Boolean)}if(Array.isArray(r?.or)){let s=r.or.map(f=>fe(e,f));return s.includes(null)?null:s.some(Boolean)}let t=r?.property;if(typeof t!="string")return null;let n=ye.find(s=>Object.prototype.hasOwnProperty.call(r,s));if(!n)return null;let o=r[n],i=Q(e,t);if(i===void 0)return null;if(n==="checkbox")return typeof o?.equals=="boolean"?i===o.equals:typeof o?.does_not_equal=="boolean"?i!==o.does_not_equal:null;if(n==="number")return typeof o?.equals=="number"?i===o.equals:typeof o?.greater_than=="number"?typeof i=="number"&&i>o.greater_than:typeof o?.less_than=="number"?typeof i=="number"&&i<o.less_than:o?.is_empty===!0?i===null:o?.is_not_empty===!0?i!==null:null;if(n==="multi_select"||n==="people"){let s=Array.isArray(i)?i:[];return typeof o?.contains=="string"?s.includes(o.contains):typeof o?.does_not_contain=="string"?!s.includes(o.does_not_contain):null}let a=i===null?null:String(i);return typeof o?.equals=="string"?a===o.equals:typeof o?.does_not_equal=="string"?a!==o.does_not_equal:typeof o?.contains=="string"?a!==null&&a.includes(o.contains):typeof o?.does_not_contain=="string"?a===null||!a.includes(o.does_not_contain):typeof o?.starts_with=="string"?a!==null&&a.startsWith(o.starts_with):o?.is_empty===!0?a===null||a==="":o?.is_not_empty===!0?a!==null&&a!=="":null}function ht(e,r){if(r==null)return{ok:!0,rows:e};if(!Array.isArray(r))return{ok:!1,message:"body failed validation: body.sorts should be an array."};let t=[...e];for(let n=r.length-1;n>=0;n-=1){let o=r[n],i=o?.direction==="descending"?-1:1;if(typeof o?.timestamp=="string"){if(o.timestamp!=="created_time"&&o.timestamp!=="last_edited_time")return{ok:!1,message:`body failed validation: body.sorts[${n}].timestamp should be \`"created_time"\` or \`"last_edited_time"\`.`};let s=String(o.timestamp);t.sort((f,m)=>i*String(f[s]??"").localeCompare(String(m[s]??"")));continue}if(typeof o?.property!="string")return{ok:!1,message:`body failed validation: body.sorts[${n}] should define \`property\` or \`timestamp\`.`};let a=o.property;t.sort((s,f)=>{let m=Q(s,a),h=Q(f,a);return typeof m=="number"&&typeof h=="number"?i*(m-h):i*String(m??"").localeCompare(String(h??""))})}return{ok:!0,rows:t}}var Ce=new Map;function yt(e,r,t){let n=`${t??"-"}|${(r??"").slice(0,19)}`,o=(Ce.get(n)??0)+1;return Ce.set(n,o),o<=e}async function be(e){let{method:r,root:t,occurredAt:n}=e,o=e.readOnly??!1,i=r!=="GET"&&r!=="HEAD",a=n??Xe(),s;try{s=new URL(e.path,"http://twin.local")}catch{return U(400,"invalid_request_url",`Invalid request URL: ${e.path}`)}if(!/^Bearer\s+(\S+)$/i.exec(e.authorization??"")?.[1])return U(401,"unauthorized","API token is invalid.");let m=e.notionVersion;if(m===void 0||m==="")return _("Notion-Version header failed validation: Notion-Version header should be defined, instead was `undefined`.");if(!de.includes(m))return _(`Notion-Version header failed validation: Notion-Version "${m}" is not one of the versions this twin models (${de.join(", ")}).`);let h=m===W;if(e.rateLimitPerSecond!==void 0&&!yt(e.rateLimitPerSecond,n,t))return U(429,"rate_limited","You have been rate limited. Please try again in a few minutes.",{"retry-after":"1"});let S=s.pathname.replace(/^\/+|\/+$/g,"").split("/").filter(Boolean);if(S[0]!=="v1")return U(400,"invalid_request_url",`Invalid request URL: ${s.pathname}`);let u=S.slice(1),T=s.searchParams,P=Ze(e.body);if(!P.ok)return U(400,"invalid_json","Error parsing JSON body.");let d=P.value;if(o&&i)return U(405,"restricted_resource","This twin was started read-only; omit readOnly to accept writes.");if(u[0]==="_twin"&&u[1]==="webhooks"){if(r==="POST"&&u.length===2){let l=d.url;if(typeof l!="string"||l.length===0)return _("body failed validation: body.url should be a non-empty string.");let c=d.event_types;if(c!==void 0){if(!Array.isArray(c))return _("body failed validation: body.event_types should be an array.");let v=c.find(z=>!oe.includes(z));if(v)return _(`body failed validation: \`${v}\` is not a Notion webhook event type.`)}let p=O("webhook",t).length+1,g=I(`webhook:${p}`),y=`secret_${I(`webhook-token:${p}`).replace(/-/g,"")}`;await E("webhook",g,{url:l,verification_token:y,event_types:Array.isArray(c)?c:[],active:!0,created_time:a},t,n);let b=I(`webhook_delivery:handshake:${p}`);return await E("webhook_delivery",b,{subscriptionId:g,url:l,eventType:"verification",body:JSON.stringify({verification_token:y}),headers:{"content-type":"application/json"},delivered_at:a},t,n),{status:200,body:{object:"webhook",id:g,url:l,verification_token:y,event_types:Array.isArray(c)?c:[],active:!0}}}if(r==="GET"&&u.length===2)return{status:200,body:{object:"list",results:O("webhook",t).map(rt),has_more:!1,next_cursor:null,type:"webhook"}};if(r==="GET"&&u.length===4&&u[3]==="deliveries"){let l=N(u[2]);return k("webhook",l,t)?{status:200,body:{object:"list",results:O("webhook_delivery",t).filter(p=>p.subscriptionId===l).map(p=>({id:p.id,url:p.url,type:p.eventType,body:p.body,headers:p.headers,delivered_at:p.delivered_at})),has_more:!1,next_cursor:null,type:"webhook_delivery"}}:w(`Could not find webhook with ID: ${u[2]}.`)}if(r==="DELETE"&&u.length===3){let l=N(u[2]);return k("webhook",l,t)?(await E("webhook",l,{active:!1},t,n),{status:200,body:{object:"webhook",id:l,active:!1}}):w(`Could not find webhook with ID: ${u[2]}.`)}}if(u[0]==="_twin"&&u[1]==="shared_pages"&&r==="POST"&&u.length===2){let l=typeof d.title=="string"&&d.title.length>0?d.title:null;if(!l)return _("body failed validation: body.title should be a non-empty string.");let c=ue({title:{title:[{text:{content:l}}]}},null);if(!c.ok)return _(c.message);let p=J("page",t);return await E("page",p,{parentType:"workspace",parentId:null,properties:c.properties,icon:d.icon??null,cover:d.cover??null,archived:!1,created_time:a,last_edited_time:a},t,n),{status:200,body:q(k("page",p,t),h)}}if(u[0]==="users"){if(r==="GET"&&u.length===1){let l=X(Oe(t),{start_cursor:T.get("start_cursor")??void 0,page_size:T.get("page_size")??void 0});return"error"in l?l.error:V(l.page,l.next,"user")}if(r==="GET"&&u.length===2&&u[1]==="me")return{status:200,body:$};if(r==="GET"&&u.length===2){let l=N(u[1]),c=Oe(t).find(p=>p.id===l);return c?{status:200,body:c}:w(`Could not find user with ID: ${u[1]}.`)}}if(r==="POST"&&u[0]==="search"&&u.length===1){let l=d.filter?.value;if(l!==void 0&&l!=="page"&&l!=="database")return _('body failed validation: body.filter.value should be `"page"` or `"database"`.');let c=typeof d.query=="string"?d.query.toLowerCase():null,p=[];l!=="database"&&p.push(...O("page",t).filter(b=>b.archived!==!0).map(b=>({...q(Z(b,t),h),_key:ge(b)}))),l!=="page"&&p.push(...O("database",t).filter(b=>b.archived!==!0).map(b=>({...K(b,h),_key:L(b.title)}))),c!==null&&(p=p.filter(b=>String(b._key??"").toLowerCase().includes(c))),p.sort((b,v)=>String(b.last_edited_time).localeCompare(String(v.last_edited_time))||String(b.id).localeCompare(String(v.id))),d.sort?.direction==="descending"&&p.reverse();let g=p.map(({_key:b,...v})=>v),y=X(g,{start_cursor:d.start_cursor,page_size:d.page_size});return"error"in y?y.error:V(y.page,y.next,"page_or_database")}if(u[0]==="pages"){if(r==="POST"&&u.length===1){let l=d.parent;if(!l||typeof l!="object")return _("body failed validation: body.parent should be defined.");let c=typeof l.data_source_id=="string"?N(l.data_source_id):null;if(c&&!h)return _(`body failed validation: parent.data_source_id requires Notion-Version ${W}.`);let p=c?O("database",t).find(A=>M(String(A.id))===c):void 0;if(c&&!p)return w(`Could not find data source with ID: ${l.data_source_id}.`);let g=p?String(p.id):typeof l.database_id=="string"?N(l.database_id):null,y=typeof l.page_id=="string"?N(l.page_id):null;if(!g&&!y)return _("body failed validation: body.parent should define `database_id` or `page_id`.");let b=null;if(g){let A=k("database",g,t);if(!A)return w(`Could not find database with ID: ${l.database_id}.`);b=A.properties??{}}else if(!k("page",y,t))return w(`Could not find page with ID: ${l.page_id}.`);let v=ue(d.properties??{},b);if(!v.ok)return _(v.message);let z=g?O("page",t).filter(A=>A.parentId===g).length+1:1,D=b?{...pt(b,{created_time:a,last_edited_time:a,uniqueNumber:z}),...v.properties}:v.properties;if(!b){if(!Object.values(D).some(re=>re.type==="title"))return _("body failed validation: body.properties should define a `title` property for a page with a page parent.");let A=Object.entries(D).find(([,re])=>re.type!=="title");if(A)return _(`${A[0]} is not a property that exists. A page with a page parent accepts only a \`title\` property.`)}let C=J("page",t);if(await E("page",C,{parentType:g?"database_id":"page_id",parentId:g??y,properties:D,icon:d.icon??null,cover:d.cover??null,archived:!1,created_time:a,last_edited_time:a},t,n),Array.isArray(d.children)&&d.children.length>0){let A=await me(C,d.children,t,n,a);if("error"in A)return A.error}return await Ae(C,b,{},D,t,n,a),await B("page.created",{id:C,type:"page"},{parent:F(k("page",C,t))},t,n,a),{status:200,body:q(Z(k("page",C,t),t),h)}}if(u.length>=2){let l=N(u[1]),c=k("page",l,t);if(r==="GET"&&u.length===4&&u[2]==="properties"){if(!c)return w(`Could not find page with ID: ${u[1]}.`);let p=decodeURIComponent(u[3]),g=Object.entries(c.properties??{}).find(([,b])=>b.id===p);if(!g)return w(`Could not find property with ID: ${u[3]}.`);let y=g[1];return y.type==="title"||y.type==="rich_text"||y.type==="people"?{status:200,body:{object:"list",results:(y[y.type]??[]).map(v=>({object:"property_item",id:y.id,type:y.type,[y.type]:v})),next_cursor:null,has_more:!1,type:"property_item",property_item:{id:y.id,type:y.type,[y.type]:{},next_url:null}}}:{status:200,body:{object:"property_item",id:y.id,type:y.type,[y.type]:y[y.type]}}}if(r==="GET"&&u.length===2)return c?{status:200,body:q(Z(c,t),h)}:w(`Could not find page with ID: ${u[1]}.`);if(r==="PATCH"&&u.length===2){if(!c)return w(`Could not find page with ID: ${u[1]}.`);let p={last_edited_time:a};if(d.properties!==void 0){let b=c.parentType==="database_id"?k("database",String(c.parentId),t)?.properties??{}:null,v=ue(d.properties,b);if(!v.ok)return _(v.message);p.properties={...c.properties??{},...v.properties}}let g=p.properties??c.properties??{},y={};for(let[b,v]of Object.entries(g))v.type==="last_edited_time"&&(y[b]={...v,last_edited_time:a});if(Object.keys(y).length&&(p.properties={...g,...y}),d.archived!==void 0||d.in_trash!==void 0){let b=d.archived??d.in_trash;if(typeof b!="boolean")return _("body failed validation: body.archived should be a boolean.");p.archived=b}if(d.icon!==void 0&&(p.icon=d.icon),d.cover!==void 0&&(p.cover=d.cover),Object.keys(p).length===1)return _("body failed validation: body should define at least one updatable field.");if(await E("page",l,p,t,n),p.properties){let b=c.parentType==="database_id"?k("database",String(c.parentId),t)?.properties??{}:null;await Ae(l,b,c.properties??{},p.properties,t,n,a),await B("page.properties_updated",{id:l,type:"page"},{updated_properties:Object.keys(d.properties??{})},t,n,a)}return p.archived!==void 0&&await B(p.archived?"page.deleted":"page.undeleted",{id:l,type:"page"},void 0,t,n,a),{status:200,body:q(Z(k("page",l,t),t),h)}}}}if(u[0]==="data_sources"){if(!h)return w(`Cannot ${r} ${s.pathname} \u2014 /v1/data_sources requires Notion-Version ${W}.`);let l=u.length>=2?N(u[1]):"",c=O("database",t).find(p=>M(String(p.id))===l);if(r==="GET"&&u.length===2)return c?{status:200,body:Ie(c)}:w(`Could not find data source with ID: ${u[1]}.`);if(r==="PATCH"&&u.length===2){if(!c)return w(`Could not find data source with ID: ${u[1]}.`);let p={last_edited_time:a};if(d.name!==void 0){let g=R(Array.isArray(d.name)?d.name:Ue(String(d.name)),"body.name",Y(t));if(!g.ok)return _(g.message);p.title=g.value}if(d.properties!==void 0){let g=je(c.properties??{},d.properties);if(!g.ok)return _(g.message);p.properties=g.schema}return Object.keys(p).length===1?_("body failed validation: body should define at least one updatable field."):(await E("database",String(c.id),p,t,n),p.properties&&await B("data_source.schema_updated",{id:l,type:"data_source"},{updated_properties:Object.keys(d.properties??{})},t,n,a),{status:200,body:Ie(k("database",String(c.id),t))})}if(r==="POST"&&u.length===3&&u[2]==="query")return c?Re(String(c.id),d,t,h):w(`Could not find data source with ID: ${u[1]}.`)}if(u[0]==="databases"){if(r==="POST"&&u.length===1){let l=d.parent,c=typeof l?.page_id=="string"?N(l.page_id):null;if(!c)return _("body failed validation: body.parent should define `page_id`.");if(!k("page",c,t))return w(`Could not find page with ID: ${l.page_id}.`);if(h&&d.properties!==void 0)return _(`body failed validation: from ${W} the schema goes in body.initial_data_source.properties, not body.properties.`);if(!h&&d.initial_data_source!==void 0)return _(`body failed validation: body.initial_data_source requires Notion-Version ${W}.`);let p=h?d.initial_data_source?.properties:d.properties;if(h&&p==null)return _("body failed validation: body.initial_data_source.properties is required.");let g=gt(p??{});if(!g.ok)return _(g.message);let y=Array.isArray(d.title)?R(d.title,"body.title"):{ok:!0,value:[]};if(!y.ok)return _(y.message);let b=y.value,v=J("database",t);return await E("database",v,{parentType:"page_id",parentId:c,title:b,description:Array.isArray(d.description)?d.description:[],properties:g.schema,icon:d.icon??null,cover:d.cover??null,is_inline:d.is_inline===!0,archived:!1,created_time:a,last_edited_time:a},t,n),await B("database.created",{id:v,type:"database"},void 0,t,n,a),{status:200,body:K(k("database",v,t),h)}}if(u.length>=2){let l=N(u[1]),c=k("database",l,t);if(r==="GET"&&u.length===2)return c?{status:200,body:K(c,h)}:w(`Could not find database with ID: ${u[1]}.`);if(r==="PATCH"&&u.length===2){if(!c)return w(`Could not find database with ID: ${u[1]}.`);let p={last_edited_time:a};if(d.title!==void 0){let g=R(d.title,"body.title",Y(t));if(!g.ok)return _(g.message);p.title=g.value}if(d.description!==void 0){let g=R(d.description,"body.description",Y(t));if(!g.ok)return _(g.message);p.description=g.value}if(d.archived!==void 0||d.in_trash!==void 0){let g=d.archived??d.in_trash;if(typeof g!="boolean")return _("body failed validation: body.archived should be a boolean.");p.archived=g}if(d.icon!==void 0&&(p.icon=d.icon),d.cover!==void 0&&(p.cover=d.cover),d.properties!==void 0){let g=je(c.properties??{},d.properties);if(!g.ok)return _(g.message);p.properties=g.schema}return Object.keys(p).length===1?_("body failed validation: body should define at least one updatable field."):(await E("database",l,p,t,n),p.properties&&await B("database.schema_updated",{id:l,type:"database"},{updated_properties:Object.keys(d.properties??{})},t,n,a),p.archived!==void 0&&await B(p.archived?"database.deleted":"database.undeleted",{id:l,type:"database"},void 0,t,n,a),{status:200,body:K(k("database",l,t),h)})}if(r==="POST"&&u.length===3&&u[2]==="query")return c?h?w(`Cannot POST ${s.pathname} \u2014 from ${W} query the data source instead: POST /v1/data_sources/${M(l)}/query.`):Re(l,d,t,h):w(`Could not find database with ID: ${u[1]}.`)}}if(u[0]==="blocks"&&u.length>=2){let l=N(u[1]),c=k("block",l,t),p=c?void 0:k("page",l,t);if(r==="GET"&&u.length===3&&u[2]==="children"){if(!c&&!p)return w(`Could not find block with ID: ${u[1]}.`);let g=ce(l,t).map(G),y=X(g,{start_cursor:T.get("start_cursor")??void 0,page_size:T.get("page_size")??void 0});return"error"in y?y.error:V(y.page,y.next,"block")}if(r==="PATCH"&&u.length===3&&u[2]==="children"){if(!c&&!p)return w(`Could not find block with ID: ${u[1]}.`);if(!Array.isArray(d.children)||d.children.length===0)return _("body failed validation: body.children should be a non-empty array.");let g=await me(l,d.children,t,n,a);if("error"in g)return g.error;c&&await E("block",l,{has_children:!0,last_edited_time:a},t,n);let y=bt(l,t);return y&&await B("page.content_updated",{id:y,type:"page"},{updated_blocks:g.created.map(b=>({id:b.id,type:"block"}))},t,n,a),V(g.created.map(G),null,"block")}if(u.length===2){if(r==="GET")return c?{status:200,body:G(c)}:p?{status:200,body:it(p,t)}:w(`Could not find block with ID: ${u[1]}.`);if(r==="PATCH"){if(!c)return w(`Could not find block with ID: ${u[1]}.`);let g=Object.keys(d).find(b=>ne.includes(b)&&b!==c.blockType);if(g)return _(`body failed validation: block is of type ${c.blockType}; it cannot be updated with a ${g} payload.`);let y={last_edited_time:a};if(d[String(c.blockType)]!==void 0){let b=ze(String(c.blockType),d[String(c.blockType)],Y(t));if(!b.ok)return _(b.message);y.payload={...c.payload??{},...b.payload}}if(d.archived!==void 0||d.in_trash!==void 0){let b=d.archived??d.in_trash;if(typeof b!="boolean")return _("body failed validation: body.archived should be a boolean.");y.archived=b}return Object.keys(y).length===1?_("body failed validation: body should define the block type payload or `archived`."):(await E("block",l,y,t,n),{status:200,body:G(k("block",l,t))})}if(r==="DELETE"){if(!c)return w(`Could not find block with ID: ${u[1]}.`);if(c.archived!==!0){await E("block",l,{archived:!0,last_edited_time:a},t,n);let g=String(c.parentId);ce(g,t).length===0&&k("block",g,t)&&await E("block",g,{has_children:!1,last_edited_time:a},t,n)}return{status:200,body:G(k("block",l,t))}}}}if(u[0]==="comments"&&u.length===1){if(r==="GET"){let l=T.get("block_id");if(!l)return _("path failed validation: path.block_id should be defined.");let c=N(l);if(!k("page",c,t)&&!k("block",c,t))return w(`Could not find block with ID: ${l}.`);let p=O("comment",t).filter(y=>y.parentId===c).sort((y,b)=>String(y.created_time).localeCompare(String(b.created_time))||String(y.id).localeCompare(String(b.id))).map($e),g=X(p,{start_cursor:T.get("start_cursor")??void 0,page_size:T.get("page_size")??void 0});return"error"in g?g.error:V(g.page,g.next,"comment")}if(r==="POST"){let l=d.rich_text;if(!Array.isArray(l)||l.length===0)return _("body failed validation: body.rich_text should be a non-empty array.");let c=R(l,"body.rich_text");if(!c.ok)return _(c.message);let p=d.parent,g=typeof d.discussion_id=="string"?d.discussion_id:null,y=typeof p?.page_id=="string"?N(p.page_id):null,b=typeof p?.block_id=="string"?N(p.block_id):null;if(!y&&!b&&!g)return _("body failed validation: body should define `parent.page_id`, `parent.block_id` or `discussion_id`.");if(y&&!k("page",y,t))return w(`Could not find page with ID: ${p.page_id}.`);if(b&&!k("block",b,t))return w(`Could not find block with ID: ${p.block_id}.`);let v=y??b,z=y?"page_id":"block_id";if(g&&!v){let C=O("comment",t).find(A=>A.discussion_id===g);if(!C)return w(`Could not find discussion with ID: ${g}.`);v=String(C.parentId),z=String(C.parentType)}let D=J("comment",t);return await E("comment",D,{parentType:z,parentId:v,discussion_id:g??I(`discussion:${D}`),rich_text:c.value,created_time:a,last_edited_time:a},t,n),await B("comment.created",{id:D,type:"comment"},{parent:{type:z,[z]:v}},t,n,a),{status:200,body:$e(k("comment",D,t))}}}return U(404,"object_not_found",`Cannot ${r} ${s.pathname} \u2014 this operation is not modeled by the Notion twin.`)}function Re(e,r,t,n){let o=O("page",t).filter(s=>s.parentId===e&&s.parentType==="database_id"&&s.archived!==!0);if(r.filter!==void 0&&r.filter!==null){if(typeof r.filter!="object")return _("body failed validation: body.filter should be an object.");let s=[];for(let f of o){let m=fe(f,r.filter);if(m===null)return _(`body failed validation: body.filter is not a filter this twin models: ${JSON.stringify(r.filter)}`);m&&s.push(f)}o=s}o.sort((s,f)=>String(s.created_time).localeCompare(String(f.created_time))||String(s.id).localeCompare(String(f.id)));let i=ht(o,r.sorts);if(!i.ok)return _(i.message);let a=X(i.rows.map(s=>q(Z(s,t),n)),{start_cursor:r.start_cursor,page_size:r.page_size});return"error"in a?a.error:V(a.page,a.next,"page_or_database")}function bt(e,r){if(k("page",e,r))return e;let t=k("block",e,r);for(let n=0;t&&n<=O("block",r).length;n+=1){let o=String(t.parentId);if(t.parentType==="page_id")return k("page",o,r)?o:null;t=k("block",o,r)}return null}async function me(e,r,t,n,o){let i=[],a=Y(t),f=k("page",e,t)!==void 0?"page_id":"block_id";for(let m of r){let h=String(m?.type??""),S=m[h]??{},u=ze(h,S,a);if(!u.ok)return{error:_(u.message)};let T=Array.isArray(S.children)?S.children:[];if(h==="table"){let d=Number(u.payload.table_width);if(T.length===0)return{error:_("body failed validation: body.table should define `children` \u2014 a table is created with its rows.")};for(let l of T){if(String(l?.type??"")!=="table_row")return{error:_("body failed validation: every child of a table should be a `table_row`.")};let c=l.table_row?.cells;if(!Array.isArray(c)||c.length!==d)return{error:_(`body failed validation: each table_row should have exactly ${d} cells (table_width), instead had ${Array.isArray(c)?c.length:0}.`)}}}if(h==="column_list"&&(T.length<2||T.some(d=>String(d?.type??"")!=="column")))return{error:_("body failed validation: body.column_list should define `children` \u2014 at least two `column` blocks.")};delete u.payload.children;let P=J("block",t);if(await E("block",P,{parentType:f,parentId:e,blockType:h,payload:u.payload,order:ot(e,t),has_children:T.length>0,archived:!1,created_time:o,last_edited_time:o},t,n),T.length>0){let d=await me(P,T,t,n,o);if("error"in d)return d}i.push(k("block",P,t))}return{created:i}}import{serveHttp as jt}from"../../engine/v2/volter_world-core.mjs";import{createTwinFetchFromHandler as _t,statefulTwinManifest as kt}from"../../engine/v2/volter_world-core.mjs";function _e(e){return _t(be,{root:e.root,readOnly:e.readOnly,manifest:kt({vendor:"notion",twinOf:"the Notion API",stores:"pages, databases, blocks and their property values"}),handlerOptions:{...e.rateLimitPerSecond!==void 0?{rateLimitPerSecond:e.rateLimitPerSecond}:{}},extras:r=>{let t=r.headers.get("notion-version"),n=r.headers.get("authorization");return{...t?{notionVersion:t}:{},...n?{authorization:n}:{}}},responseHeaders:{"request-id":"req_twin"}})}import{confirmAction as Vt,pendingActions as Mt,syncPull as Ht}from"../../engine/v2/volter_world-core.mjs";import{assertBudgetGuardIntact as Bt,declareRateBudget as vt,rateBudgetPath as Ut,rateBudgetWeight as Lt,RateBudget as zt,RateBudgetError as qt}from"../../engine/v2/volter_world-core.mjs";import{RateBudgetError as Ve}from"../../engine/v2/volter_world-core.mjs";var wt="notion",Fe=6e4,We=150,Ge=300,ke={blockChildren:2,other:1},ve={windowMs:Fe,ceiling:We,defaultWeight:ke.other,maxRetryAfterSeconds:Ge,rules:[{match:"^blocks\\.children\\.list$",weight:ke.blockChildren}],reason:"Notion documents an average of 3 requests/second per integration (429 + Retry-After over it). 150 weighted units / 60s is 2.5 req/s, so the 60s AVERAGE stays under the vendor's; it does not pace, so an intra-second burst can still reach the vendor first and is caught by the 429 cooldown. blocks.children.list costs 2 because it is the recursive, cursor-paginated fan-out a depth or pagination bug turns into hundreds of calls \u2014 a judgement call, not a published cost."};vt(wt,ve);import{bundleClient as Xt,fileResponse as Zt,filePathOf as Qt}from"../../engine/v2/volter_world-core.mjs";import{serveHttp as tn}from"../../engine/v2/volter_world-core.mjs";var rn=Object.freeze({section:"pages",objectId:""});export{_e as createTwinFetch};
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
@agenttwin/twin-npm-registry
|
|
2
|
+
|
|
3
|
+
Contains @volter/twin-npm-registry 3.0.2 by Volter (https://github.com/volter-ai),
|
|
4
|
+
licensed under the Apache License, Version 2.0 (see LICENSE).
|
|
5
|
+
|
|
6
|
+
Modified by AgentTwin: bundled and minified into one file; only code reachable from the pack's
|
|
7
|
+
fetch factory is included; shared modules are imported from the AgentTwin twin engine.
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{createRequire as __atReq}from'node:module';const require=__atReq(import.meta.url);
|
|
2
|
+
var ke=Object.defineProperty;var _e=(e,t)=>{for(var s in t)ke(e,s,{get:t[s],enumerable:!0})};import{packOf as Xe,registerPack as Ze}from"../../engine/v3/volter_world-core.mjs";var K={package:{},user:{},org:{}};var B={vendor:"npm-registry",service:"npm-registry",body:{json:"always"},cors:{origin:"*",methods:"GET, HEAD",headers:"accept"},ids:{template:"{uuid}"},time:"iso",error:{error:"{message}"},defaultKind:"registry",readOnly:{status:403,message:"This registry was started read-only; writes are refused."},malformedBody:{status:400,message:"Invalid JSON"},notFound:{status:404,message:"Not found"},list:{style:"envelope",envelope:{objects:"{data}"},limit:{param:"size",default:20,max:250}},deleted:{},origin:{placeholder:"https://registry.npmjs.org"},rateBudget:{reason:"npm publishes no per-minute allowance for registry.npmjs.org (https://docs.npmjs.com/policies/open-source-terms admits the APIs it documents and states no limit); with none documented the window holds a loop to the platform's fallback, 30 calls a minute.",windowMs:6e4,ceiling:30,defaultWeight:1,maxRetryAfterSeconds:60},doors:[{id:"appCredentials",method:"POST",path:"/_twin/app-credentials",note:"the publish token an application holds (a World user's), as the runtime issues it"},{id:"users",method:"POST",path:"/_twin/users",note:"a user (npmjs.com's sign-up page), with a publish token for it"},{id:"orgs",method:"POST",path:"/_twin/orgs",note:`an organization (npmjs.com's "create an organization" page), its owner a user the World holds`}],discovery:{twinOf:"the npm registry (registry.npmjs.org): install, one version by number or tag, provenance attestations, dist-tags, search and publish",stores:"package documents with embedded versions and tarball blobs, users, orgs and tokens (by their sha512, never as issued)",identity:"Send `Authorization: Bearer <token>` (a token from POST /_twin/users or POST /_twin/app-credentials) or Basic credentials; anonymous requests read public packages."},resources:{package:{idPrefix:"",idAs:"name",key:"{name}",...K.package,refresh:{get:"pacote.packument",known:!0,blobs:[{path:"versions.*.dist.tarball",key:"tarball{pathname}"},{path:"versions.*.dist.attestations.url",key:"attestation{pathname}"}]}},user:{idPrefix:"",...K.user,refresh:{none:"Users are account setup through npmjs.com; no user enumeration or profile read is served by the demanded registry surface."}},org:{idPrefix:"",...K.org,refresh:{none:"Organizations are account setup through npmjs.com; no organization read is served by the demanded registry surface."}},_serial:{idPrefix:"",ids:"{n}"}},unmodeled:["stars.exec","libnpmhook.stream","libnpmhook.add","libnpmhook.rm","libnpmhook.find","libnpmhook.update","verify-signatures.setKeys","arborist.getReport","arborist.getReport_2","npm-profile.paginate","npm-profile.createToken","npm-profile.removeToken","npm-profile.get","npm-profile.set","libnpmorg.rm","libnpmorg.stream","libnpmorg.set","libnpmaccess.getPackages","libnpmteam.stream","libnpmteam.create","libnpmaccess.setAccess","libnpmaccess.getCollaborators","dist-tag.add","dist-tag.remove","libnpmaccess.getVisibility","ping.call","libnpmteam.destroy","libnpmaccess.removePermissions","libnpmaccess.setPermissions","libnpmteam.rm","libnpmteam.stream_2","libnpmteam.add","libnpmaccess.getPackages_2","npm-profile.loginCouch","npm-profile.putCouch","logout.exec","npm-profile.webAuthCheckLogin","npm-profile.webAuth","get-identity.call","libnpmpublish.unpublish","libnpmpublish.unpublish_2","libnpmpublish.unpublish_3"],descriptor:{protocol:"3",transport:"rest",archetype:"crud",bin:"world-npm-registry",resources:["package","user","org"],specSource:"the registry calls npm 10.9.8 makes (spec/client-ops.json, provenance in spec/SOURCE.md), and npm/registry's docs",description:"npm registry twin \u2014 install (full and abbreviated documents, tarballs with sha1 and sha512), one version by number or tag, publish (with provenance checked) and its attestations, dist-tag ls and search with its qualifiers.",adoption:{envStems:["NPM"],tools:[{package:"npm",usage:"build"}]},hosts:[{host:"registry.npmjs.org"}],credentialDoor:{path:"/_twin/app-credentials",body:{},fill:{NODE_AUTH_TOKEN:"token",NPM_TOKEN:"token"}},endpointEnv:{name:"NPM_CONFIG_REGISTRY",note:"npm and bun read the registry from npm_config_registry (and .npmrc's `registry`)."}}};var U={generatedBy:"scripts/derive-pack.ts",spec:"client-ops.json",format:"client",version:"npm 10.9.8",resources:[{name:"package",schema:"package",fields:[{name:"_id",type:"string",nullable:!1},{name:"_rev",type:"string",nullable:!1},{name:"_attachments",type:"object",nullable:!1},{name:"name",type:"string",nullable:!1},{name:"dist-tags",type:"object",nullable:!1},{name:"time",type:"object",nullable:!1},{name:"versions",type:"object",nullable:!1},{name:"maintainers",type:"array",nullable:!1},{name:"readme",type:"string",nullable:!1},{name:"description",type:"string",nullable:!1},{name:"author",type:"object",nullable:!1},{name:"bugs",type:"string",nullable:!1},{name:"contributors",type:"array",nullable:!1},{name:"homepage",type:"string",nullable:!1},{name:"keywords",type:"array",nullable:!1},{name:"license",type:"string",nullable:!1},{name:"readmeFilename",type:"string",nullable:!1},{name:"repository",type:"object",nullable:!1},{name:"modified",type:"string",nullable:!1}],stateCandidates:[],expandable:[]},{name:"version",schema:"version",fields:[{name:"name",type:"string",nullable:!1},{name:"version",type:"string",nullable:!1},{name:"dist",type:"object",nullable:!1},{name:"_id",type:"string",nullable:!1},{name:"_nodeVersion",type:"string",nullable:!1},{name:"_npmUser",type:"object",nullable:!1},{name:"_npmVersion",type:"string",nullable:!1},{name:"_from",type:"string",nullable:!1},{name:"_shasum",type:"string",nullable:!1},{name:"_hasShrinkwrap",type:"boolean",nullable:!1},{name:"maintainers",type:"array",nullable:!1},{name:"description",type:"string",nullable:!1},{name:"dependencies",type:"object",nullable:!1},{name:"optionalDependencies",type:"object",nullable:!1},{name:"devDependencies",type:"object",nullable:!1},{name:"peerDependencies",type:"object",nullable:!1},{name:"peerDependenciesMeta",type:"object",nullable:!1},{name:"bundleDependencies",type:"array",nullable:!1},{name:"bin",type:"object",nullable:!1},{name:"directories",type:"object",nullable:!1},{name:"engines",type:"object",nullable:!1},{name:"scripts",type:"object",nullable:!1},{name:"main",type:"string",nullable:!1},{name:"author",type:"object",nullable:!1},{name:"keywords",type:"array",nullable:!1},{name:"homepage",type:"string",nullable:!1},{name:"repository",type:"object",nullable:!1},{name:"license",type:"string",nullable:!1},{name:"readme",type:"string",nullable:!1},{name:"deprecated",type:"string",nullable:!1}],stateCandidates:[],expandable:[]}],operations:[{id:"stars.exec",family:"stars",method:"get",path:"/-/_view/starredByUser",pathParams:[],query:[{name:"key",type:"string",required:!1}],body:[],bodyEncoding:"none",successStatus:200,class:"action"},{id:"pacote.manifest",family:"pacote",method:"get",path:"/-/npm/v1/attestations/{spec}",pathParams:["spec"],query:[],body:[],bodyEncoding:"none",successStatus:200,class:"action"},{id:"libnpmhook.stream",family:"libnpmhook",method:"get",path:"/-/npm/v1/hooks",pathParams:[],query:[],body:[],bodyEncoding:"none",successStatus:200,class:"action"},{id:"libnpmhook.add",family:"libnpmhook",method:"post",path:"/-/npm/v1/hooks/hook",pathParams:[],query:[],body:[{name:"endpoint",type:"string",required:!1},{name:"name",type:"string",required:!1},{name:"secret",type:"string",required:!1},{name:"type",type:"string",required:!1}],bodyEncoding:"json",successStatus:200,class:"action"},{id:"libnpmhook.rm",family:"libnpmhook",method:"delete",path:"/-/npm/v1/hooks/hook/{id}",pathParams:["id"],query:[],body:[],bodyEncoding:"none",successStatus:200,class:"action"},{id:"libnpmhook.find",family:"libnpmhook",method:"get",path:"/-/npm/v1/hooks/hook/{id}",pathParams:["id"],query:[],body:[],bodyEncoding:"none",successStatus:200,class:"action"},{id:"libnpmhook.update",family:"libnpmhook",method:"put",path:"/-/npm/v1/hooks/hook/{id}",pathParams:["id"],query:[],body:[{name:"endpoint",type:"string",required:!1},{name:"secret",type:"string",required:!1}],bodyEncoding:"json",successStatus:200,class:"action"},{id:"verify-signatures.setKeys",family:"verify-signatures",method:"get",path:"/-/npm/v1/keys",pathParams:[],query:[],body:[],bodyEncoding:"none",successStatus:200,class:"action"},{id:"arborist.getReport",family:"arborist",method:"post",path:"/-/npm/v1/security/advisories/bulk",pathParams:[],query:[],body:[],bodyEncoding:"json",successStatus:200,class:"action"},{id:"arborist.getReport_2",family:"arborist",method:"post",path:"/-/npm/v1/security/audits/quick",pathParams:[],query:[],body:[],bodyEncoding:"json",successStatus:200,class:"action"},{id:"npm-profile.paginate",family:"npm-profile",method:"get",path:"/-/npm/v1/tokens",pathParams:[],query:[],body:[],bodyEncoding:"none",successStatus:200,class:"action"},{id:"npm-profile.createToken",family:"npm-profile",method:"post",path:"/-/npm/v1/tokens",pathParams:[],query:[],body:[{name:"cidr_whitelist",type:"string",required:!1},{name:"password",type:"string",required:!1},{name:"readonly",type:"string",required:!1}],bodyEncoding:"json",successStatus:200,class:"action"},{id:"npm-profile.removeToken",family:"npm-profile",method:"delete",path:"/-/npm/v1/tokens/token/{tokenKey}",pathParams:["tokenKey"],query:[],body:[],bodyEncoding:"none",successStatus:200,class:"action"},{id:"npm-profile.get",family:"npm-profile",method:"get",path:"/-/npm/v1/user",pathParams:[],query:[],body:[],bodyEncoding:"none",successStatus:200,class:"action"},{id:"npm-profile.set",family:"npm-profile",method:"post",path:"/-/npm/v1/user",pathParams:[],query:[],body:[],bodyEncoding:"json",successStatus:200,class:"action"},{id:"libnpmorg.rm",family:"libnpmorg",method:"delete",path:"/-/org/{org}/user",pathParams:["org"],query:[],body:[{name:"user",type:"string",required:!1}],bodyEncoding:"json",successStatus:200,class:"action"},{id:"libnpmorg.stream",family:"libnpmorg",method:"get",path:"/-/org/{org}/user",pathParams:["org"],query:[],body:[],bodyEncoding:"none",successStatus:200,class:"action"},{id:"libnpmorg.set",family:"libnpmorg",method:"put",path:"/-/org/{org}/user",pathParams:["org"],query:[],body:[{name:"role",type:"string",required:!1},{name:"user",type:"string",required:!1}],bodyEncoding:"json",successStatus:200,class:"action"},{id:"libnpmaccess.getPackages",family:"libnpmaccess",method:"get",path:"/-/org/{scope}/package",pathParams:["scope"],query:[],body:[],bodyEncoding:"none",successStatus:200,class:"action"},{id:"libnpmteam.stream",family:"libnpmteam",method:"get",path:"/-/org/{scope}/team",pathParams:["scope"],query:[],body:[],bodyEncoding:"none",successStatus:200,class:"action"},{id:"libnpmteam.create",family:"libnpmteam",method:"put",path:"/-/org/{scope}/team",pathParams:["scope"],query:[],body:[{name:"description",type:"string",required:!1},{name:"name",type:"string",required:!1}],bodyEncoding:"json",successStatus:200,class:"action"},{id:"libnpmaccess.setAccess",family:"libnpmaccess",method:"post",path:"/-/package/{spec_escapedName}/access",pathParams:["spec_escapedName"],query:[],body:[{name:"access",type:"string",required:!1}],bodyEncoding:"json",successStatus:200,class:"action"},{id:"libnpmaccess.getCollaborators",family:"libnpmaccess",method:"get",path:"/-/package/{spec_escapedName}/collaborators",pathParams:["spec_escapedName"],query:[],body:[],bodyEncoding:"none",successStatus:200,class:"action"},{id:"dist-tag.fetchTags",family:"dist-tag",method:"get",path:"/-/package/{spec_escapedName}/dist-tags",pathParams:["spec_escapedName"],query:[],body:[],bodyEncoding:"none",successStatus:200,class:"action"},{id:"dist-tag.add",family:"dist-tag",method:"put",path:"/-/package/{spec_escapedName}/dist-tags/{t}",pathParams:["spec_escapedName","t"],query:[],body:[],bodyEncoding:"json",successStatus:200,class:"action"},{id:"dist-tag.remove",family:"dist-tag",method:"delete",path:"/-/package/{spec_escapedName}/dist-tags/{tag}",pathParams:["spec_escapedName","tag"],query:[],body:[],bodyEncoding:"none",successStatus:200,class:"action"},{id:"libnpmaccess.getVisibility",family:"libnpmaccess",method:"get",path:"/-/package/{spec_escapedName}/visibility",pathParams:["spec_escapedName"],query:[],body:[],bodyEncoding:"none",successStatus:200,class:"action"},{id:"ping.call",family:"ping",method:"get",path:"/-/ping",pathParams:[],query:[],body:[],bodyEncoding:"none",successStatus:200,class:"action"},{id:"libnpmteam.destroy",family:"libnpmteam",method:"delete",path:"/-/team/{scope}/{team}",pathParams:["scope","team"],query:[],body:[],bodyEncoding:"none",successStatus:200,class:"action"},{id:"libnpmaccess.removePermissions",family:"libnpmaccess",method:"delete",path:"/-/team/{scope}/{team}/package",pathParams:["scope","team"],query:[],body:[{name:"package",type:"string",required:!1}],bodyEncoding:"json",successStatus:200,class:"action"},{id:"libnpmaccess.setPermissions",family:"libnpmaccess",method:"put",path:"/-/team/{scope}/{team}/package",pathParams:["scope","team"],query:[],body:[{name:"package",type:"string",required:!1},{name:"permissions",type:"string",required:!1}],bodyEncoding:"json",successStatus:200,class:"action"},{id:"libnpmteam.rm",family:"libnpmteam",method:"delete",path:"/-/team/{scope}/{team}/user",pathParams:["scope","team"],query:[],body:[{name:"user",type:"string",required:!1}],bodyEncoding:"json",successStatus:200,class:"action"},{id:"libnpmteam.stream_2",family:"libnpmteam",method:"get",path:"/-/team/{scope}/{team}/user",pathParams:["scope","team"],query:[],body:[],bodyEncoding:"none",successStatus:200,class:"action"},{id:"libnpmteam.add",family:"libnpmteam",method:"put",path:"/-/team/{scope}/{team}/user",pathParams:["scope","team"],query:[],body:[{name:"user",type:"string",required:!1}],bodyEncoding:"json",successStatus:200,class:"action"},{id:"libnpmaccess.getPackages_2",family:"libnpmaccess",method:"get",path:"/-/user/{scope}/package",pathParams:["scope"],query:[],body:[],bodyEncoding:"none",successStatus:200,class:"action"},{id:"npm-profile.loginCouch",family:"npm-profile",method:"get",path:"/-/user/org.couchdb.user:{username}",pathParams:["username"],query:[{name:"write",type:"string",required:!1}],body:[],bodyEncoding:"none",successStatus:200,class:"action"},{id:"npm-profile.putCouch",family:"npm-profile",method:"put",path:"/-/user/org.couchdb.user:{username}",pathParams:["username"],query:[],body:[],bodyEncoding:"json",successStatus:200,class:"action"},{id:"logout.exec",family:"logout",method:"delete",path:"/-/user/token/{auth}",pathParams:["auth"],query:[],body:[],bodyEncoding:"none",successStatus:200,class:"action"},{id:"npm-profile.webAuthCheckLogin",family:"npm-profile",method:"get",path:"/-/v1/done",pathParams:[],query:[],body:[],bodyEncoding:"none",successStatus:200,class:"action"},{id:"npm-profile.webAuth",family:"npm-profile",method:"post",path:"/-/v1/login",pathParams:[],query:[],body:[],bodyEncoding:"json",successStatus:200,class:"action"},{id:"libnpmsearch.searchStream",family:"libnpmsearch",method:"get",path:"/-/v1/search",pathParams:[],query:[],body:[],bodyEncoding:"none",successStatus:200,class:"action"},{id:"get-identity.call",family:"get-identity",method:"get",path:"/-/whoami",pathParams:[],query:[],body:[],bodyEncoding:"none",successStatus:200,class:"action"},{id:"pacote.tarballFromResolved",family:"pacote",method:"get",path:"/{name}/-/{tarball}",pathParams:["name","tarball"],query:[],body:[],bodyEncoding:"none",successStatus:200,class:"action"},{id:"registry.version",family:"registry",method:"get",path:"/{name}/{version}",pathParams:["name","version"],query:[],body:[],bodyEncoding:"none",successStatus:200,class:"action"},{id:"libnpmpublish.publish",family:"libnpmpublish",method:"put",path:"/{spec_escapedName}",pathParams:["spec_escapedName"],query:[],body:[],bodyEncoding:"json",successStatus:200,class:"action"},{id:"libnpmpublish.unpublish",family:"libnpmpublish",method:"delete",path:"/{spec_escapedName}/-/{tarball}/-rev/{_rev}",pathParams:["spec_escapedName","tarball","_rev"],query:[],body:[],bodyEncoding:"none",successStatus:200,class:"action"},{id:"libnpmpublish.unpublish_2",family:"libnpmpublish",method:"delete",path:"/{spec_escapedName}/-rev/{pkg__rev}",pathParams:["spec_escapedName","pkg__rev"],query:[],body:[],bodyEncoding:"none",successStatus:200,class:"action"},{id:"libnpmpublish.unpublish_3",family:"libnpmpublish",method:"put",path:"/{spec_escapedName}/-rev/{pkg__rev}",pathParams:["spec_escapedName","pkg__rev"],query:[],body:[{name:"_id",type:"string",required:!1},{name:"_rev",type:"string",required:!1},{name:"maintainers",type:"string",required:!1}],bodyEncoding:"json",successStatus:200,class:"action"},{id:"pacote.packument",family:"pacote",method:"get",path:"/{this_spec_escapedName}",pathParams:["this_spec_escapedName"],query:[{name:"write",type:"string",required:!1}],body:[],bodyEncoding:"none",successStatus:200,class:"retrieve",answers:{resource:"package",list:!1},resource:"package"}]};import{createPackFetch as Qe}from"../../engine/v3/volter_world-core.mjs";function je(e){let t=new URL(e.url),s=/^\/(@[^/]+)\/([^/]+)(\/.*)?$/.exec(t.pathname),a=/^\/-\/package\/(@[^/]+)\/([^/]+)(\/.*)$/.exec(t.pathname);if(/%2f/i.test(t.pathname.split("/")[1]??""))return e;if(a)t.pathname=`/-/package/${a[1]}%2f${a[2]}${a[3]}`;else if(s&&!s[2].startsWith("-"))t.pathname=`/${s[1]}%2f${s[2]}${s[3]??""}`;else return e;let r=e.method!=="GET"&&e.method!=="HEAD";return new Request(t,{method:e.method,headers:e.headers,...r?{body:e.body,duplex:"half"}:{}})}async function x(e,t){return t(je(e.call.request))}var V={};_e(V,{appCredentials:()=>Ge,orgs:()=>Me,users:()=>ze});import{passwordHash as ie}from"../../engine/v3/volter_world-core.mjs";import{certificateOf as Ee,digest as Pe,passwordHash as qe,verifyAttestationBundle as Ae,verifyWith as $e}from"../../engine/v3/volter_world-core.mjs";var Y="https://registry.npmjs.org",h="package",A="user",D="org",R="_token",v=(e,t)=>Response.json({error:t},{status:e}),j=()=>v(404,"Not found"),Q=(e=200)=>Response.json({ok:!0},{status:e}),E=e=>decodeURIComponent(e??""),N=e=>e.startsWith("@")&&e.includes("/")?e.slice(1,e.indexOf("/")):void 0,z=(e,t)=>`${e.includes("/")?e.slice(e.indexOf("/")+1):e}-${t}.tgz`,X=(e,t)=>`${Y}/${e}/-/${z(e,t)}`,M=(e,t)=>`tarball/${e}/-/${t}`,G=(e,t)=>e.crypto.digest("sha512",t,"hex");function Z(e){let t=e.call.request.headers.get("authorization")??"",s=/^Bearer\s+(.+)$/i.exec(t)?.[1]?.trim();return s?Ne(e,s):Re(e,t)}function Ne(e,t){let s=e.row(R,G(e,t)),a=s?e.row(A,String(s.user)):void 0;return s&&a&&(!s.expires||String(s.expires)>e.occurredAt)?{user:a,readonly:s.readonly===!0,token:s}:void 0}function Re(e,t){let s=/^Basic\s+(.+)$/i.exec(t)?.[1]?.trim();if(s){let a="";try{a=atob(s)}catch{return}let r=a.indexOf(":"),n=r>0?e.row(A,a.slice(0,r)):void 0;return n&&n._password===qe(String(n.name),a.slice(r+1))?{user:n,readonly:!1}:void 0}}function ee(e){let t=Z(e);return t?t.readonly?v(403,"This token is read-only: it authenticates GET and HEAD requests only."):t:v(401,"You must be logged in to publish packages.")}var Oe=e=>e?.roster??{};function L(e,t,s,a){if(a)return(a.maintainers??[]).some(n=>n.name===t.name)||J(e,t,s);let r=N(s);return r?r===t.name||J(e,t,s):!0}function J(e,t,s){let a=N(s);return a!==void 0&&Oe(e.row(D,a))[String(t.name)]!==void 0}function q(e,t,s){return s._access!=="restricted"||Te(e,t,s)}function Te(e,t,s){let a=Z(e);return a!==void 0&&L(e,a.user,t,s)}var te=(e,t)=>Object.values(e.row(h,t)?.versions??{}),Ce=["name","version","deprecated","dependencies","acceptDependencies","optionalDependencies","devDependencies","bundleDependencies","peerDependencies","peerDependenciesMeta","bin","directories","dist","engines","_hasShrinkwrap","hasInstallScript","funding","cpu","os"];function I(e,t,s){let a=e.own(t),{_access:r,...n}=a;if(!s)return n;let c=n.versions??{};return{name:n.name,modified:n.time?.modified,"dist-tags":n["dist-tags"],versions:Object.fromEntries(Object.entries(c).map(([m,g])=>[m,Object.fromEntries(Ce.filter(o=>g[o]!==void 0).map(o=>[o,g[o]]))]))}}var se=e=>(e.call.request.headers.get("accept")??"").includes("application/vnd.npm.install-v1+json"),Fe=(e,t,s)=>({token:s??"[REDACTED]",key:e,cidr_whitelist:t.cidr_whitelist??null,readonly:t.readonly===!0,created:t.created,updated:t.updated});async function ae(e,t,s,a,r){let n=e.crypto.uuidFrom(await e.secret(`npm-token:${t}:${await De(e,"token")}:${e.occurredAt}`)),c=G(e,n),m={user:t,readonly:s,cidr_whitelist:a,...r?{expires:r}:{},created:e.occurredAt,updated:e.occurredAt};return await e.record(R,m,c),Fe(c,m,n)}var W=(e,t)=>`attestation/-/npm/v1/attestations/${e}@${t}`,Ke="https://slsa.dev/provenance/v1",ne=(e,t)=>`${e}-${t}.sigstore`,re=(e,t)=>`${Y}/-/npm/v1/attestations/${e.replace("/","%2f")}@${t}`,Be=(e,t)=>Buffer.concat([Buffer.from(`DSSEv1 ${Buffer.byteLength(e)} ${e} ${t.length} `),t]),Ue=e=>{let t=e.repository;return(typeof t=="string"?t:typeof t?.url=="string"?String(t.url):"").replace(/^git\+/,"").replace(/\.git$/,"").replace(/\/$/,"")};async function oe(e,t,s,a,r,n){let c=d=>v(422,`Error verifying sigstore provenance bundle: ${d}`),m;try{m=JSON.parse(n)}catch{return c("the bundle is not JSON")}if(!m||typeof m!="object"||Array.isArray(m))return c("the bundle is not an object");let g=m.dsseEnvelope??{},o=Buffer.from(String(g.payload??""),"base64"),p;try{p=JSON.parse(o.toString("utf8"))}catch{return c("No dsseEnvelope with payload found in sigstore bundle")}if(!p||typeof p!="object"||Array.isArray(p))return c("the statement is not an object");let b=Array.isArray(p.subject)?p.subject:[];if(b.length!==1||!b[0]||typeof b[0]!="object")return c("Found more than one subject in the sigstore bundle payload");let u=`pkg:npm/${t.replace("@","%40")}@${s}`;if(b[0].name!==u)return c("the provenance subject is not this package and version");let k=Pe("sha512",a);if(b[0].digest?.sha512!==k)return c(`the provenance subject's digest is not the tarball's (${t}@${s})`);let w=m.verificationMaterial??{},_=String(w.x509CertificateChain?.certificates?.[0]?.rawBytes??w.certificate?.rawBytes??""),l=Ee(new Uint8Array(Buffer.from(_,"base64")));if(!l)return c("the bundle carries no signing certificate");let y=await(await e.vendorFetch("https://fulcio.sigstore.dev/api/v2/trustBundle")).json();if(!(y.chains??[]).flatMap(d=>d.certificates??[]).some(d=>l.issuedBy(d)))return c("the signing certificate is not issued by Fulcio");let P=(y.chains??[]).flatMap(d=>d.certificates??[]),T=await(await e.vendorFetch("https://rekor.sigstore.dev/api/v1/log/publicKey")).text();try{await Ae(m,{certificates:P,logKeys:[T]})}catch(d){return c(String(d))}let C=String(g.signatures?.[0]?.sig??"");if(!$e(l.publicKey.pem,Be(String(g.payloadType??""),o),C))return c("the envelope's signature does not verify under the signing certificate");let F=/URI:(https:\/\/github\.com\/[^/]+\/[^/]+)\//.exec(l.subjectAltName??"")?.[1]??"",i=Ue(r);return i!==F?c(`Failed to validate repository information: package.json: "repository.url" is "${i}", expected to match "${F}" from provenance`):{predicateType:String(p.predicateType??Ke),bundle:m}}var De=async(e,t)=>Number(await e.issue("_serial"));var O=e=>Response.json({error:e},{status:400}),ce=e=>e.body&&typeof e.body=="object"&&!Array.isArray(e.body)?e.body:{};async function ze(e){let t=ce(e),s=typeof t.name=="string"?t.name:"";if(!/^[a-z0-9][a-z0-9._-]*$/.test(s)||typeof t.email!="string"||typeof t.password!="string")return O("name (lowercase, url-safe), email and password are required");if(e.row(A,s))return O(`the user ${s} exists`);await e.write(A,s,{name:s,email:t.email,_password:ie(s,t.password),created:e.occurredAt,updated:e.occurredAt},"user.create");let a=await ae(e,s,!1,null,typeof t.expires=="string"?t.expires:void 0);return Response.json({user:s,token:a.token},{status:201})}async function Me(e){let t=ce(e),s=typeof t.name=="string"?t.name:"";return!/^[a-z0-9][a-z0-9._-]*$/.test(s)||typeof t.owner!="string"?O("name (lowercase, url-safe) and owner are required"):e.row(A,t.owner)?e.row(D,s)||e.row(A,s)?O(`the scope @${s} is taken`):(await e.write(D,s,{name:s,roster:{[t.owner]:"owner"},created:e.occurredAt},"org.create"),Response.json({org:s,owner:t.owner},{status:201})):O(`no such user: ${t.owner}`)}async function Ge(e){let t="world";e.row(A,t)||await e.write(A,t,{name:t,email:"world@world.test",_password:ie(t,await e.secret("npm-world-password")),created:e.occurredAt,updated:e.occurredAt},"user.create");let s=e.crypto.uuidFrom(await e.secret(`npm-app-token:${t}`)),a=G(e,s),r=e.rowsRaw(R,{withDeleted:!0}).find(n=>n.id===a);return r?.deleted===!0?Response.json({error:"the application token was revoked"},{status:409}):(r||await e.record(R,{user:t,readonly:!1,cidr_whitelist:null,created:e.occurredAt,updated:e.occurredAt},a),Response.json({token:s},{status:201}))}async function pe(e){let t=E(e.call.params.spec_escapedName),s=e.row(h,t);return!s||!q(e,t,s)?j():Response.json(e.own(s)["dist-tags"]??{})}var We=e=>e.body&&typeof e.body=="object"&&!Array.isArray(e.body)?e.body:{};function Le(e){let t=Buffer.from(e,"base64");return t.length||!e?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):void 0}async function le(e){let t=ee(e);if(t instanceof Response)return t;let s=E(e.call.params.spec_escapedName),a=We(e),r=e.row(h,s);if(!L(e,t.user,s,r))return v(403,`You do not have permission to publish "${s}". Are you logged in as the correct user?`);let n=a._attachments??{},c=a.versions??{};if(Object.keys(n).length===0)return v(400,"A publish attaches each version's tarball.");if(typeof a.name=="string"&&a.name!==s)return v(400,`The package's name "${a.name}" is not the name it is published at, "${s}".`);let m=new Set(te(e,s).map(i=>String(i.version))),g=Object.keys(c);if(g.length===0)return v(400,"A publish names at least one version.");let o=g.find(i=>m.has(i));if(o)return v(403,`You cannot publish over the previously published versions: ${o}.`);let p=new Map;for(let i of g){let d=`${s}-${i}.tgz`,S=n[d]??n[z(s,i)],f=typeof S?.data=="string"?Le(S.data):void 0;if(!f)return v(400,`The tarball for ${s}@${i} is not attached (${d}).`);if(S.length!==void 0&&Number(S.length)!==f.byteLength)return v(400,`The tarball for ${s}@${i} is ${f.byteLength} bytes; the attachment says ${String(S.length)}.`);p.set(i,f)}let b=new Map;for(let[i,d]of p){let S=n[ne(s,i)],f=S&&typeof S.data=="string"?await oe(e,s,i,d,c[i],S.data):void 0;if(f instanceof Response)return f;f&&b.set(i,f)}let u={name:t.user.name,email:t.user.email},k=r?.maintainers??[u],w={...r?.time??{created:e.occurredAt},modified:e.occurredAt},_={...r?.versions??{}};for(let[i,d]of p){let S=z(s,i);await e.blobs.put(M(s,S),d);let f=b.get(i),we={tarball:X(s,i),shasum:e.crypto.digest("sha1",d,"hex"),integrity:`sha512-${e.crypto.digest("sha512",d,"base64")}`,...f?{attestations:{url:re(s,i),provenance:{predicateType:f.predicateType}}}:{}};f&&await e.blobs.put(W(s,i),new TextEncoder().encode(JSON.stringify({attestations:[f]})));let{_attachments:et,...ve}=c[i];_[i]={...ve,name:s,version:i,_id:`${s}@${i}`,dist:we,_npmUser:u,maintainers:k},w[i]=e.occurredAt}let l=r?._access??(N(s)&&a.access!=="public"?"restricted":"public"),y={...r?.["dist-tags"]??{},...a["dist-tags"]??{}},P=r?I(e,r,!1):{},T=Number(String(r?._rev??"0").split("-")[0])+1,C=_[g.at(-1)]??{},F=Object.fromEntries(["author","bugs","contributors","description","homepage","keywords","license","readmeFilename","repository"].filter(i=>C[i]!==void 0).map(i=>[i,C[i]]));return await e.write(h,s,{...P,...F,_id:s,_rev:`${T}-${e.crypto.digest("md5",`${s}:${T}`,"hex")}`,name:s,readme:a.readme??r?.readme??"","dist-tags":y,versions:_,maintainers:k,time:w,_attachments:{},_access:l},"libnpmpublish.publish"),Q()}var $=e=>String(e??"").toLowerCase(),me=e=>e&&typeof e=="object"?e:typeof e=="string"&&e?{name:e}:void 0,de=e=>typeof e=="string"?e:e&&typeof e.url=="string"?String(e.url):void 0;function He(e,t){let s=new Set(t.map($)),a=e.split(",").map(n=>n.trim()).filter(Boolean);if(a.some(n=>n.startsWith("-")&&s.has($(n.slice(1)))))return!1;let r=a.filter(n=>!n.startsWith("-"));return r.length===0||r.some(n=>n.split("+").every(c=>s.has($(c))))}async function ue(e){let t=Math.min(250,Math.max(1,Number(e.params.size??20)||20)),s=Math.max(0,Number(e.params.from??0)||0),a=String(e.params.text??"").split(/\s+/).filter(Boolean),r=a.map(o=>/^([a-z-]+):(.+)$/.exec(o)).filter(o=>o!==null).map(o=>({key:o[1],value:o[2]})),n=a.filter(o=>!/^[a-z-]+:.+$/.test(o)).map($),m=e.rowsRaw(h).filter(o=>q(e,String(o.name),o)).map(o=>{let p=String(o["dist-tags"]?.latest??""),b=e.own(o).versions?.[p];return{p:o,version:p,latest:b,manifest:b??{}}}).filter(({p:o,version:p,latest:b,manifest:u})=>{let k=String(o.name),w=(Array.isArray(u.keywords)?u.keywords:[]).map(String),_=Number(p.split(".")[0])<1;for(let{key:l,value:y}of r)if(l==="author"&&![me(u.author)?.name,b?._npmUser?.name].some(P=>$(P)===$(y))||l==="maintainer"&&!(o.maintainers??[]).some(P=>$(P.name)===$(y))||l==="scope"&&N(k)!==y.replace(/^@/,"")||l==="keywords"&&!He(y,w)||l==="not"&&y==="unstable"&&_||l==="is"&&y==="unstable"&&!_||l==="is"&&y==="insecure")return!1;return n.every(l=>[k,String(o.description??""),...w].some(y=>$(y).includes(l)))}).sort((o,p)=>String(o.p.name).localeCompare(String(p.p.name))),g=m.slice(s,s+t).map(({p:o,version:p,latest:b,manifest:u})=>{let k=String(o.name),w=b?._npmUser,_=me(u.author),l=de(u.repository),y=de(u.bugs);return{package:{name:k,scope:N(k)??"unscoped",version:p,description:o.description??u.description??"",keywords:Array.isArray(u.keywords)?u.keywords:[],date:o.time?.[p]??o.time?.modified,links:{npm:`https://www.npmjs.com/package/${k}`,...typeof u.homepage=="string"?{homepage:u.homepage}:{},...l?{repository:l}:{},...y?{bugs:y}:{}},..._?{author:_}:{},...w?{publisher:{username:w.name,email:w.email}}:{},maintainers:(o.maintainers??[]).map(P=>({username:P.name,email:P.email}))},score:{final:1,detail:{quality:1,popularity:1,maintenance:1}},searchScore:1}});return Response.json({objects:g,total:m.length,time:e.occurredAt})}async function ye(e){let t=E(e.call.params.this_spec_escapedName),s=e.row(h,t);if(!s||!q(e,t,s))return j();let a=se(e);return Response.json(I(e,s,a),{headers:{"content-type":a?"application/vnd.npm.install-v1+json":"application/json"}})}async function be(e){let t=E(e.call.params.name),s=e.row(h,t);if(!s||!q(e,t,s))return j();let a=await e.blobs.get(M(t,E(e.call.params.tarball)));return a?e.raw(new Uint8Array(a).buffer,{headers:{"content-type":"application/octet-stream"}}):j()}async function fe(e){let t=decodeURIComponent(String(e.call.params.spec??"")),s=t.lastIndexOf("@"),a=s>0?t.slice(0,s):t,r=e.row(h,a);if(!r||!q(e,a,r))return j();let n=await e.blobs.get(W(a,t.slice(s+1)));return n?e.raw(new Uint8Array(n).buffer,{headers:{"content-type":"application/json"}}):j()}async function he(e){let t=E(e.call.params.name),s=e.row(h,t);if(!s||!q(e,t,s))return j();let a=E(e.call.params.version),r=(s["dist-tags"]??{})[a]??a,n=e.own(s).versions?.[String(r)];return n?Response.json(n):j()}var ge={"dist-tag.fetchTags":pe,"libnpmpublish.publish":le,"libnpmsearch.searchStream":ue,"pacote.manifest":fe,"pacote.packument":ye,"pacote.tarballFromResolved":be,"registry.version":he};function H(e={}){return Qe({manifest:B,surface:U,handlers:ge,doors:V,around:x},e)}import{serveHttp as jt}from"../../engine/v3/volter_world-core.mjs";var Rt=Ze(Xe(B,U));export{H as createTwinFetch};
|