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,30 @@
|
|
|
1
|
+
import{createRequire as __atReq}from'node:module';const require=__atReq(import.meta.url);
|
|
2
|
+
var se={INCORRECT_USERNAME_PASSWORD:"390100",SESSION_TOKEN_INVALID:"390104",GONE_SESSION:"390111",SESSION_TOKEN_EXPIRED:"390112",MASTER_TOKEN_EXPIRED:"390114",ID_TOKEN_INVALID:"390195",OAUTH_TOKEN_INVALID:"390303",OAUTH_TOKEN_EXPIRED:"390318"},p={SUCCESS:"090001",ASYNC_ACCEPTED:"333334",SYNTAX:"001003",OBJECT_DOES_NOT_EXIST:"002003",OBJECT_ALREADY_EXISTS:"002002",INVALID_IDENTIFIER:"000904",UNSUPPORTED_FEATURE:"002040",NUMERIC_VALUE_NOT_RECOGNIZED:"100038",BIND_COUNT_MISMATCH:"002049"},h={SUCCESS:"00000",SYNTAX_OR_ACCESS:"42000",TABLE_NOT_FOUND:"42S02",TABLE_EXISTS:"42S01",FEATURE_NOT_SUPPORTED:"0A000",DATA_EXCEPTION:"22018"},m=class extends Error{code;sqlState;position;constructor(t,s,n,a){super(s),this.code=t,this.sqlState=n,this.position=a,this.name="SnowflakeSqlError"}},R=class extends Error{code;status;constructor(t,s,n=200){super(s),this.code=t,this.status=n,this.name="SnowflakeSessionError"}},z=class extends Error{constructor(){super("read_only: this twin was started read-only; omit readOnly to accept writes"),this.name="SnowflakeReadOnlyError"}};function y(e,t){return new m(p.SYNTAX,`SQL compilation error:
|
|
3
|
+
syntax error line 1 at position ${t} unexpected '${e}'.`,h.SYNTAX_OR_ACCESS,t)}function qe(e){return new m(p.SYNTAX,`SQL compilation error:
|
|
4
|
+
'${e}' in SELECT is not a valid group by expression.`,h.SYNTAX_OR_ACCESS)}function me(e,t){return new m(p.NUMERIC_VALUE_NOT_RECOGNIZED,`${e} '${t}' is not recognized`,h.DATA_EXCEPTION)}function M(e){return new m(p.OBJECT_DOES_NOT_EXIST,`SQL compilation error:
|
|
5
|
+
Object '${e}' does not exist or not authorized.`,h.TABLE_NOT_FOUND)}function q(e){return new m(p.OBJECT_ALREADY_EXISTS,`SQL compilation error:
|
|
6
|
+
Object '${e}' already exists.`,h.TABLE_EXISTS)}function ne(e,t){return new m(p.INVALID_IDENTIFIER,`SQL compilation error:
|
|
7
|
+
error line 1 at position ${t}
|
|
8
|
+
invalid identifier '${e}'`,h.SYNTAX_OR_ACCESS,t)}function b(e){return new m(p.UNSUPPORTED_FEATURE,`SQL compilation error:
|
|
9
|
+
Unsupported feature '${e}'. [twin gap] the Snowflake twin does not model this statement; the surface is filed as a todo in snowflake-capabilities.ts.`,h.FEATURE_NOT_SUPPORTED)}function dt(e){return new m(p.UNSUPPORTED_FEATURE,`SQL compilation error:
|
|
10
|
+
Table '${e}' was observed by a connector pull as SHAPE ONLY \u2014 its columns are known, its rows are not. [twin gap] this twin does not pull table contents (snowflake.connector.pull_table_rows); it refuses rather than reporting an empty table it never observed. Write rows through the twin to make its contents known.`,h.FEATURE_NOT_SUPPORTED)}function Re(e,t){return new R(p.UNSUPPORTED_FEATURE,`[twin gap] ${e} ${t} is not a modeled Snowflake operation; the surface is filed as a todo in snowflake-capabilities.ts.`)}function P(e){return{data:e,message:null,code:null,success:!0}}function he(e,t={}){return{data:e instanceof m?{sqlState:e.sqlState,errorCode:e.code,...t}:{...t},message:e.message,code:e.code,success:!1}}import{createHash as sn}from"node:crypto";import{applyTwinWriteAtomic as nn,projectResources as an}from"../../engine/v2/volter_world-core.mjs";var _=new Set(["date","time","timestamp_ntz","timestamp_ltz","timestamp_tz"]),X={SELECT:4096,INSERT:12544,UPDATE:12800,DELETE:13056,DDL:24576};function Ve(){return{databases:[],schemas:[],warehouses:[],tables:[],views:[],createdAt:{}}}var ns=["<>","!=","<=",">=","||","::","(",")",",","*","=","<",">",";",".","+","-","/","%"];function Rt(e){let t=[],s=0;for(;s<e.length;){let n=e[s];if(/\s/.test(n)){s+=1;continue}if(n==="-"&&e[s+1]==="-"){for(;s<e.length&&e[s]!==`
|
|
11
|
+
`;)s+=1;continue}if(n==="/"&&e[s+1]==="*"){let r=e.indexOf("*/",s+2);s=r===-1?e.length:r+2;continue}let a=s+1;if(n==="'"){let r=s+1,i="";for(;;){if(r>=e.length)throw y("'",a);if(e[r]==="'"){if(e[r+1]==="'"){i+="'",r+=2;continue}r+=1;break}if(e[r]==="\\"&&r+1<e.length){i+=e[r+1],r+=2;continue}i+=e[r],r+=1}t.push({kind:"string",text:i,raw:e.slice(s,r),pos:a}),s=r;continue}if(n==='"'){let r=e.indexOf('"',s+1);if(r===-1)throw y('"',a);t.push({kind:"word",text:e.slice(s+1,r),raw:e.slice(s,r+1),pos:a,quoted:!0}),s=r+1;continue}if(n==="?"){t.push({kind:"bind",text:"?",raw:"?",pos:a}),s+=1;continue}if(n===":"&&/[0-9]/.test(e[s+1]??"")){let r=s+1;for(;r<e.length&&/[0-9]/.test(e[r]);)r+=1;t.push({kind:"bind",text:e.slice(s+1,r),raw:e.slice(s,r),pos:a}),s=r;continue}if(/[0-9]/.test(n)){let r=s;for(;r<e.length&&/[0-9]/.test(e[r]);)r+=1;if(e[r]===".")for(r+=1;r<e.length&&/[0-9]/.test(e[r]);)r+=1;t.push({kind:"number",text:e.slice(s,r),raw:e.slice(s,r),pos:a}),s=r;continue}if(/[A-Za-z_$]/.test(n)){let r=s;for(;r<e.length&&/[A-Za-z0-9_$]/.test(e[r]);)r+=1;let i=e.slice(s,r);t.push({kind:"word",text:i.toUpperCase(),raw:i,pos:a}),s=r;continue}let o=ns.find(r=>e.startsWith(r,s));if(!o)throw y(n,a);t.push({kind:"punct",text:o,raw:o,pos:a}),s+=o.length}return t.push({kind:"eof",text:"<EOF>",raw:"",pos:e.length+1}),t}var as=new Set(["SELECT","FROM","WHERE","ORDER","BY","GROUP","HAVING","LIMIT","INSERT","INTO","VALUES","UPDATE","SET","DELETE","CREATE","DROP","USE","SHOW","DESCRIBE","AS","AND","OR","ON","JOIN","UNION","THEN","ELSE","END","WHEN"]),xt=new Set(["SELECT","FROM","WHERE","AND","OR","NOT","ORDER","BY","LIMIT","INSERT","INTO","VALUES","UPDATE","SET","DELETE","CREATE","DROP","TABLE","DATABASE","SCHEMA","WAREHOUSE","USE","SHOW","DESCRIBE","DESC","AS","IS","NULL","LIKE","ASC","IN","IF","EXISTS","OR","REPLACE","ROLE","TABLES","DATABASES","SCHEMAS","WAREHOUSES","GROUP","HAVING","JOIN","INNER","LEFT","RIGHT","FULL","CROSS","LATERAL","ON","UNION","INTERSECT","EXCEPT","MINUS","QUALIFY","WINDOW","OVER","DISTINCT","USING","OUTER","NATURAL","ASOF","CASE","WHEN","THEN","ELSE","END","BETWEEN","VIEW","ALTER","ADD","RENAME","COLUMN","TO","CAST","SECURE","MATERIALIZED","RECURSIVE","WITH"]),ft={LATERAL:"LATERAL",ASOF:"ASOF JOIN",NATURAL:"NATURAL JOIN",UNION:"UNION",INTERSECT:"INTERSECT",EXCEPT:"EXCEPT",MINUS:"MINUS",QUALIFY:"QUALIFY",WINDOW:"WINDOW",OVER:"window function OVER clause",DISTINCT:"SELECT DISTINCT",USING:"USING"};function J(e){let t=e.peek();if(t.kind==="word"&&!t.quoted&&ft[t.text])throw b(ft[t.text])}var Ce=class{toks;i=0;nextBindOrdinal=0;constructor(t){this.toks=t}takeBindOrdinal(){return this.nextBindOrdinal+=1}peek(t=0){return this.toks[Math.min(this.i+t,this.toks.length-1)]}next(){let t=this.peek();return this.i<this.toks.length-1&&(this.i+=1),t}eat(t){let s=this.peek();return(s.kind==="word"||s.kind==="punct")&&s.text===t&&!s.quoted?(this.next(),!0):!1}eatSeq(...t){for(let s=0;s<t.length;s+=1){let n=this.peek(s);if(!((n.kind==="word"||n.kind==="punct")&&n.text===t[s]&&!n.quoted))return!1}for(let s=0;s<t.length;s+=1)this.next();return!0}expect(t){let s=this.peek();if(!this.eat(t))throw y(s.raw||s.text,s.pos);return s}identifier(){let t=this.next();if(t.kind!=="word")throw y(t.raw||t.text,t.pos);return{name:t.quoted?t.text:t.text.toUpperCase(),pos:t.pos}}atEnd(){return this.peek().kind==="eof"||this.peek().kind==="punct"&&this.peek().text===";"&&this.peek(1).kind==="eof"}assertEnd(){if(this.eat(";")&&this.peek().kind==="eof")return;let t=this.peek();if(t.kind!=="eof")throw y(t.raw||t.text,t.pos)}captureParenthesized(){let t=this.peek();if(!(t.kind==="punct"&&t.text==="("))throw y(t.raw||t.text,t.pos);this.next();let s=[],n=1;for(;;){let a=this.peek();if(a.kind==="eof")throw y("<EOF>",a.pos);if(a.kind==="punct"&&a.text==="("&&(n+=1),a.kind==="punct"&&a.text===")"&&(n-=1,n===0))return this.next(),s;s.push(a),this.next()}}};function Ae(e){let t=e[e.length-1];return new Ce([...e,{kind:"eof",text:"<EOF>",raw:"",pos:(t?.pos??0)+1}])}var pt=new Set(["MERGE","COPY","PUT","GET","REMOVE","LIST","CALL","BEGIN","COMMIT","ROLLBACK","GRANT","REVOKE","TRUNCATE","EXPLAIN","WITH","UNDROP","COMMENT","EXECUTE"]),os=16;function Ge(e,t){return ze(e,{...t,text:e.trim(),viewDepth:0})}function ze(e,t){let s=e.trim();if(s==="")throw y("<EOF>",1);let n=/^[A-Za-z_$][A-Za-z0-9_$]*/.exec(s)?.[0]?.toUpperCase();if(n!==void 0&&pt.has(n))throw b(n);let a=new Ce(Rt(s)),o=a.peek();if(o.kind!=="word")throw y(o.raw||o.text,o.pos);if(pt.has(o.text))throw b(o.text);let r={...t,text:s};switch(o.text){case"SELECT":return ye(a,r);case"INSERT":return Ps(a,r);case"UPDATE":return vs(a,r);case"DELETE":return Fs(a,r);case"CREATE":return Bs(a,r);case"DROP":return Vs(a,r);case"ALTER":return Xs(a,r);case"USE":return Gs(a,r);case"SHOW":return en(a,r);case"DESCRIBE":case"DESC":return tn(a,r);default:throw y(o.raw,o.pos)}}function L(e){let t=e.identifier(),s=[t.name];for(;e.eat(".");)s.push(e.identifier().name);return{parts:s,pos:t.pos,text:s.join(".")}}function F(e,t){let s=e.parts,[n,a,o]=s.length===3?[s[0],s[1],s[2]]:s.length===2?[t.database,s[0],s[1]]:[t.database,t.schema,s[0]];if(!n)throw new m(p.OBJECT_DOES_NOT_EXIST,`SQL compilation error:
|
|
12
|
+
Cannot perform SELECT. This session does not have a current database. Call 'USE DATABASE', or use a qualified name.`,h.TABLE_NOT_FOUND);return{database:n,schema:a,name:o,fqn:`${n}.${a}.${o}`}}function oe(e,t){return e.tables.find(s=>s.database===t.database&&s.schema===t.schema&&s.name===t.name)}function Ue(e,t){return e.views.find(s=>s.database===t.database&&s.schema===t.schema&&s.name===t.name)}function kt(e,t){let s=oe(e,t);if(!s)throw M(t.fqn);return s}function De(e,t){let s=kt(e,t);if(!s.rowsKnown)throw dt(t.fqn);return s}function Qe(e,t){return{columns:e.columns.map(s=>({...s,qualifier:t})),rows:e.rows.map(s=>[...s])}}function rs(e,t,s){return{columns:[...e.columns,...t.columns],rows:s}}function is(e,t){return new m(p.INVALID_IDENTIFIER,`SQL compilation error:
|
|
13
|
+
error line 1 at position ${t}
|
|
14
|
+
ambiguous column name '${e}'`,h.SYNTAX_OR_ACCESS,t)}var _t={CURRENT_DATABASE:"database",CURRENT_SCHEMA:"schema",CURRENT_WAREHOUSE:"warehouse",CURRENT_ROLE:"role",CURRENT_USER:"user",CURRENT_ACCOUNT:"account",CURRENT_VERSION:"serverVersion"},ls=new Set(["COUNT","SUM","MIN","MAX","AVG"]),us={UPPER:[1,1],LOWER:[1,1],INITCAP:[1,1],LENGTH:[1,1],LEN:[1,1],TRIM:[1,2],LTRIM:[1,2],RTRIM:[1,2],SUBSTR:[2,3],SUBSTRING:[2,3],CONCAT:[1,-1],REPLACE:[2,3],SPLIT_PART:[3,3],LEFT:[2,2],RIGHT:[2,2],LPAD:[2,3],RPAD:[2,3],POSITION:[2,3],CHARINDEX:[2,3],STARTSWITH:[2,2],ENDSWITH:[2,2],CONTAINS:[2,2],REVERSE:[1,1],REPEAT:[2,2],ABS:[1,1],CEIL:[1,2],CEILING:[1,2],FLOOR:[1,2],ROUND:[1,2],MOD:[2,2],POWER:[2,2],POW:[2,2],SQRT:[1,1],EXP:[1,1],LN:[1,1],LOG:[1,2],SIGN:[1,1],TRUNCATE:[1,2],GREATEST:[1,-1],LEAST:[1,-1],COALESCE:[1,-1],NVL:[2,2],NVL2:[3,3],IFF:[3,3],IFNULL:[2,2],NULLIF:[2,2],ZEROIFNULL:[1,1],NULLIFZERO:[1,1],TO_VARCHAR:[1,1],TO_CHAR:[1,1],TO_NUMBER:[1,3],TO_DECIMAL:[1,3],TO_NUMERIC:[1,3],TO_DOUBLE:[1,1],TO_BOOLEAN:[1,1],TO_DATE:[1,1],TO_TIME:[1,1],TO_TIMESTAMP:[1,1],TO_TIMESTAMP_NTZ:[1,1],TO_TIMESTAMP_LTZ:[1,1],TO_TIMESTAMP_TZ:[1,1],DATE_PART:[2,2],YEAR:[1,1],MONTH:[1,1],DAY:[1,1],DAYOFMONTH:[1,1],HOUR:[1,1],MINUTE:[1,1],SECOND:[1,1],DATEADD:[3,3],DATEDIFF:[3,3],DATE_TRUNC:[2,2],CURRENT_DATE:[0,0],CURRENT_TIMESTAMP:[0,0]};function k(e){return cs(e)}function cs(e){let t=mt(e);for(;;){let s=e.peek();if(!(s.kind==="punct"&&s.text==="||"))return t;e.next(),t={k:"arith",op:"||",left:t,right:mt(e),pos:s.pos}}}function mt(e){let t=ht(e);for(;;){let s=e.peek();if(!(s.kind==="punct"&&(s.text==="+"||s.text==="-")))return t;e.next(),t={k:"arith",op:s.text,left:t,right:ht(e),pos:s.pos}}}function ht(e){let t=Le(e);for(;;){let s=e.peek();if(!(s.kind==="punct"&&(s.text==="*"||s.text==="/"||s.text==="%")))return t;e.next(),t={k:"arith",op:s.text,left:t,right:Le(e),pos:s.pos}}}function Le(e){let t=e.peek();return t.kind==="punct"&&t.text==="-"?(e.next(),Et(e,{k:"arith",op:"-",left:{k:"lit",value:"0",type:"fixed"},right:Le(e),pos:t.pos})):t.kind==="punct"&&t.text==="+"?(e.next(),Le(e)):Et(e,ds(e))}function Et(e,t){let s=t;for(;;){let n=e.peek();if(!(n.kind==="punct"&&n.text==="::"))return s;e.next(),s={k:"cast",arg:s,spec:tt(e),pos:n.pos}}}function ds(e){let t=e.peek();if(t.kind==="punct"&&t.text==="*")return e.next(),{k:"star"};if(t.kind==="number")return e.next(),{k:"lit",value:t.text,type:t.text.includes(".")?"real":"fixed"};if(t.kind==="string")return e.next(),{k:"lit",value:t.text,type:"text"};if(t.kind==="bind")return e.next(),{k:"bind",index:t.text==="?"?e.takeBindOrdinal():Number(t.text),pos:t.pos};if(t.kind==="punct"&&t.text==="("){if(e.peek(1).kind==="word"&&e.peek(1).text==="SELECT"&&!e.peek(1).quoted)return{k:"sub",toks:e.captureParenthesized(),pos:t.pos};e.next();let s=k(e);return e.expect(")"),s}if(t.kind==="word"&&!t.quoted){if(t.text==="NULL")return e.next(),{k:"lit",value:null,type:"text"};if(t.text==="TRUE"||t.text==="FALSE")return e.next(),{k:"lit",value:t.text.toLowerCase(),type:"boolean"};if(t.text==="CASE")return fs(e);if(t.text==="CAST"&&e.peek(1).kind==="punct"&&e.peek(1).text==="("){e.next(),e.next();let s=k(e);e.expect("AS");let n=tt(e);return e.expect(")"),{k:"cast",arg:s,spec:n,pos:t.pos}}if(ls.has(t.text)&&e.peek(1).kind==="punct"&&e.peek(1).text==="("){if(e.next(),e.next(),e.peek().kind==="word"&&e.peek().text==="DISTINCT"&&!e.peek().quoted)throw b(`${t.text}(DISTINCT \u2026)`);let s=k(e);return e.expect(")"),{k:"agg",fn:t.text,arg:s}}if(t.text in _t&&e.peek(1).kind==="punct"&&e.peek(1).text==="(")return e.next(),e.next(),e.expect(")"),{k:"session",fn:t.text};if(e.peek(1).kind==="punct"&&e.peek(1).text==="("){let s=t.text;e.next(),e.next();let n=[];if(!(e.peek().kind==="punct"&&e.peek().text===")"))do n.push(k(e));while(e.eat(","));e.expect(")");let a=us[s];if(!a)throw b(`function ${s}`);if(n.length<a[0]||a[1]!==-1&&n.length>a[1])throw new m(p.SYNTAX,`SQL compilation error:
|
|
15
|
+
error line 1 at position ${t.pos}
|
|
16
|
+
Invalid argument types for function '${s}': wrong number of arguments`,h.SYNTAX_OR_ACCESS,t.pos);return{k:"func",name:s,args:n,pos:t.pos}}if(t.text==="CURRENT_DATE"||t.text==="CURRENT_TIMESTAMP")return e.next(),{k:"func",name:t.text,args:[],pos:t.pos}}if(t.kind==="word"){if(!t.quoted&&as.has(t.text))throw y(t.raw||t.text,t.pos);if(e.peek(1).kind==="punct"&&e.peek(1).text==="."&&e.peek(2).kind==="punct"&&e.peek(2).text==="*")throw b("qualified SELECT <alias>.*");let s=L(e),n=s.parts[s.parts.length-1],a=s.parts.length>=2?s.parts[s.parts.length-2]:void 0;return{k:"col",...a!==void 0?{qualifier:a}:{},name:n,pos:s.pos}}throw y(t.raw||t.text,t.pos)}function fs(e){e.expect("CASE");let t=[];for(;e.eat("WHEN");){let n=re(e);e.expect("THEN"),t.push({when:n,then:k(e)})}if(t.length===0)throw y(e.peek().raw||e.peek().text,e.peek().pos);let s=e.eat("ELSE")?k(e):void 0;return e.expect("END"),{k:"case",whens:t,...s?{otherwise:s}:{}}}function ps(e,t,s){let n=String(e),a=t.bindings?.[n];if(!a)throw new m(p.BIND_COUNT_MISMATCH,`SQL compilation error:
|
|
17
|
+
Bind variable ${n} not set.`,h.SYNTAX_OR_ACCESS,s);return{value:a.value,type:ms(a.type)}}function ms(e){switch(e.toUpperCase()){case"FIXED":return"fixed";case"REAL":return"real";case"BOOLEAN":return"boolean";case"VARIANT":return"variant";case"DATE":return"date";case"TIME":return"time";case"TIMESTAMP_NTZ":return"timestamp_ntz";case"TIMESTAMP_LTZ":return"timestamp_ltz";case"TIMESTAMP_TZ":return"timestamp_tz";default:return"text"}}function re(e){let t=Tt(e);for(;e.eat("OR");)t={k:"or",a:t,b:Tt(e)};return t}function Tt(e){let t=Xe(e);for(;e.eat("AND");)t={k:"and",a:t,b:Xe(e)};return t}function Xe(e){if(e.eat("NOT")){let i=e.peek();return i.kind==="word"&&i.text==="EXISTS"&&!i.quoted?(e.next(),{k:"exists",toks:e.captureParenthesized(),negated:!0,pos:i.pos}):{k:"not",a:Xe(e)}}let t=e.peek();if(t.kind==="word"&&t.text==="EXISTS"&&!t.quoted)return e.next(),{k:"exists",toks:e.captureParenthesized(),negated:!1,pos:t.pos};if(t.kind==="punct"&&t.text==="("&&!(e.peek(1).kind==="word"&&e.peek(1).text==="SELECT"&&!e.peek(1).quoted)){let i=e.captureParenthesized();return re(Ae(i))}let s=k(e);if(e.eat("IS")){let i=e.eat("NOT");return e.expect("NULL"),{k:"null",left:s,negated:i}}let n=e.eat("NOT");if(e.eat("LIKE"))return{k:"like",left:s,right:k(e),negated:n};if(e.eat("BETWEEN")){let i=k(e);return e.expect("AND"),{k:"between",left:s,lo:i,hi:k(e),negated:n}}let a=e.peek();if(e.eat("IN")){if(e.peek(1).kind==="word"&&e.peek(1).text==="SELECT"&&!e.peek(1).quoted)return{k:"in",left:s,toks:e.captureParenthesized(),negated:n,pos:a.pos};e.expect("(");let i=[];do i.push(k(e));while(e.eat(","));return e.expect(")"),{k:"in",left:s,list:i,negated:n,pos:a.pos}}if(n)throw y(e.peek().raw||e.peek().text,e.peek().pos);let o=e.peek(),r=["=","<>","!=","<","<=",">",">="].find(i=>o.kind==="punct"&&o.text===i);if(!r)throw y(o.raw||o.text,o.pos);return e.next(),{k:"cmp",left:s,op:r,right:k(e)}}function ge(e,t,s,n){let a=e;for(;a;){if(a.scope&&a.row){let o=[];if(a.scope.columns.forEach((r,i)=>{r.name===s&&(t!==void 0&&r.qualifier!==t||o.push(i))}),o.length>1)throw is(s,n);if(o.length===1)return{index:o[0],ctx:a}}a=a.outer}}function N(e,t){switch(e.k){case"lit":return{value:e.value,type:e.type};case"bind":return ps(e.index,t.opts,e.pos);case"session":{let s=_t[e.fn],n=t.opts.session[s];return{value:typeof n=="string"&&n!==""?n:null,type:"text"}}case"col":{let s=ge(t,e.qualifier,e.name,e.pos);if(!s)throw ne(e.qualifier?`${e.qualifier}.${e.name}`:e.name,e.pos);let n=s.ctx.scope.columns[s.index];return{value:s.ctx.row[s.index]??null,type:n.type}}case"star":throw y("*",1);case"agg":{if(!t.group)throw y(e.fn,1);return Ms(e,t)}case"case":{for(let s of e.whens)if(W(s.when,t)===!0)return N(s.then,t);return e.otherwise?N(e.otherwise,t):{value:null,type:"text"}}case"cast":return B(N(e.arg,t),e.spec,e.pos);case"func":return Ss(e,t);case"arith":return Ts(e,t);case"sub":{let s=ye(Ae(e.toks),t.opts,t);if(s.rowtype.length!==1)throw new m(p.SYNTAX,`SQL compilation error:
|
|
18
|
+
Subquery in an expression must return exactly one column.`,h.SYNTAX_OR_ACCESS,e.pos);if(s.rowset.length===0)return{value:null,type:s.rowtype[0].type};if(s.rowset.length>1)throw new m(p.SYNTAX,`SQL compilation error:
|
|
19
|
+
Single-row subquery returns more than one row.`,h.SYNTAX_OR_ACCESS,e.pos);return{value:s.rowset[0][0]??null,type:s.rowtype[0].type}}}}function H(e){if(e===null)return null;let t=Number(e);if(!Number.isFinite(t))throw new m(p.NUMERIC_VALUE_NOT_RECOGNIZED,`Numeric value '${e}' is not recognized`,h.DATA_EXCEPTION);return t}function we(e){return e==="fixed"||e==="real"}function ae(e,t,s){if(e.value===null||t.value===null)return null;let n=e,a=t;if(_.has(n.type)&&a.type==="text"?a=B(a,wt(n.type),1):_.has(a.type)&&n.type==="text"&&(n=B(n,wt(a.type),1)),n.value===null||a.value===null)return null;let o=(we(n.type)||_.has(n.type))&&(we(a.type)||_.has(a.type)),[r,i]=o?[ie(n),ie(a)]:[n.value,a.value];switch(s){case"=":return r===i;case"<>":case"!=":return r!==i;case"<":return r<i;case"<=":return r<=i;case">":return r>i;case">=":return r>=i;default:return!1}}function wt(e){return e==="date"?{type:e,declared:"DATE"}:{type:e,scale:9,declared:`${e.toUpperCase()}(9)`}}function ie(e){let t=e.type==="timestamp_tz"?(e.value??"").split(" ")[0]:e.value;return H(t)}function hs(e,t){let s=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/%/g,"[\\s\\S]*").replace(/_/g,"[\\s\\S]");return new RegExp(`^${s}$`).test(e)}function W(e,t){switch(e.k){case"and":{let s=W(e.a,t),n=W(e.b,t);return s===!1||n===!1?!1:s===null||n===null?null:!0}case"or":{let s=W(e.a,t),n=W(e.b,t);return s===!0||n===!0?!0:s===null||n===null?null:!1}case"not":{let s=W(e.a,t);return s===null?null:!s}case"null":{let s=N(e.left,t);return e.negated?s.value!==null:s.value===null}case"like":{let s=N(e.left,t),n=N(e.right,t);if(s.value===null||n.value===null)return null;let a=hs(s.value,n.value);return e.negated?!a:a}case"between":{let s=ae(N(e.left,t),N(e.lo,t),">="),n=ae(N(e.left,t),N(e.hi,t),"<=");return s===!1||n===!1?!!e.negated:s===null||n===null?null:!e.negated}case"in":{let s=N(e.left,t),n=e.toks?Es(e.toks,t,e.pos):(e.list??[]).map(o=>N(o,t)),a=!1;for(let o of n){let r=ae(s,o,"=");if(r===!0)return!e.negated;r===null&&(a=!0)}return a||s.value===null?null:!!e.negated}case"exists":{let n=ye(Ae(e.toks),t.opts,t).rowset.length>0;return e.negated?!n:n}case"cmp":return ae(N(e.left,t),N(e.right,t),e.op)}}function Es(e,t,s){let n=ye(Ae(e),t.opts,t);if(n.rowtype.length!==1)throw new m(p.SYNTAX,`SQL compilation error:
|
|
20
|
+
Subquery in an IN predicate must return exactly one column.`,h.SYNTAX_OR_ACCESS,s);let a=n.rowtype[0].type;return n.rowset.map(o=>({value:o[0]??null,type:a}))}function Ke(e,t){return e===void 0?!0:W(e,t)===!0}function Ts(e,t){let s=N(e.left,t),n=N(e.right,t);if(e.op==="||")return s.value===null||n.value===null?{value:null,type:"text"}:{value:`${Y(s)}${Y(n)}`,type:"text"};if(s.value===null||n.value===null)return{value:null,type:"real"};let a=H(s.value),o=H(n.value),r=s.type==="fixed"&&n.type==="fixed";switch(e.op){case"+":return{value:$(a+o),type:r?"fixed":"real"};case"-":return{value:$(a-o),type:r?"fixed":"real"};case"*":return{value:$(a*o),type:r?"fixed":"real"};case"%":return{value:$(a%o),type:r?"fixed":"real"};case"/":return{value:$(a/o),type:"real"};default:throw y(e.op,e.pos)}}function $(e){if(!Number.isFinite(e))throw new m(p.NUMERIC_VALUE_NOT_RECOGNIZED,`Numeric value '${e}' is not recognized`,h.DATA_EXCEPTION);return String(e)}function Y(e){if(e.value===null)return"";if(e.type==="date")return gs(Number(e.value));if(_.has(e.type)){let{ms:t,offsetMinutes:s}=Ze(e);return e.type==="time"?ys(t):bs(t,s)}return e.value}function ws(e){return e.value===null?null:_.has(e.type)?ie(e):H(e.value)}function Ss(e,t){let s=e.args.map(u=>N(u,t)),n=u=>s[u].value===null?null:Y(s[u]),a=u=>ws(s[u]),o=u=>({value:u,type:"text"}),r=u=>({value:u===null?null:$(Math.trunc(u)),type:"fixed"}),i=u=>({value:u===null?null:$(u),type:"real"}),l=s.some(u=>u.value===null);switch(e.name){case"COALESCE":{for(let u of s)if(u.value!==null)return u;return{value:null,type:s[0].type}}case"NVL":case"IFNULL":return s[0].value!==null?s[0]:s[1];case"NVL2":return s[0].value!==null?s[1]:s[2];case"IFF":{let u=s[0];return u.value!==null&&(u.value==="true"||u.value==="1"||u.value.toLowerCase()==="true")?s[1]:s[2]}case"NULLIF":return ae(s[0],s[1],"=")===!0?{value:null,type:s[0].type}:s[0];case"ZEROIFNULL":return s[0].value===null?{value:"0",type:"fixed"}:s[0];case"NULLIFZERO":return s[0].value!==null&&Number(s[0].value)===0?{value:null,type:s[0].type}:s[0];case"GREATEST":case"LEAST":{if(l)return{value:null,type:s[0].type};let u=s[0];for(let c of s.slice(1))ae(c,u,e.name==="GREATEST"?">":"<")===!0&&(u=c);return u}case"CURRENT_DATE":return{value:String(Math.floor(Date.parse(t.opts.now)/864e5)),type:"date"};case"CURRENT_TIMESTAMP":return{value:ke(Date.parse(t.opts.now),9),type:"timestamp_ltz"};default:break}if(l)return{value:null,type:"text"};switch(e.name){case"UPPER":return o(n(0).toUpperCase());case"LOWER":return o(n(0).toLowerCase());case"INITCAP":return o(n(0).replace(/\w\S*/g,u=>u[0].toUpperCase()+u.slice(1).toLowerCase()));case"LENGTH":case"LEN":return r([...n(0)].length);case"TRIM":return o(We(n(0),s.length>1?n(1):" ",!0,!0));case"LTRIM":return o(We(n(0),s.length>1?n(1):" ",!0,!1));case"RTRIM":return o(We(n(0),s.length>1?n(1):" ",!1,!0));case"SUBSTR":case"SUBSTRING":{let u=[...n(0)],c=a(1),d=c>0?c-1:c<0?Math.max(u.length+c,0):0,E=s.length>2?a(2):u.length;if(E<0)throw new m(p.SYNTAX,`SQL compilation error:
|
|
21
|
+
substring length must not be negative`,h.SYNTAX_OR_ACCESS);return o(u.slice(d,d+E).join(""))}case"CONCAT":return o(s.map(u=>Y(u)).join(""));case"REPLACE":return o(n(0).split(n(1)).join(s.length>2?n(2):""));case"SPLIT_PART":{let u=n(0).split(n(1)),c=a(2),d=c===0?0:c>0?c-1:u.length+c;return o(u[d]??"")}case"LEFT":return o([...n(0)].slice(0,a(1)).join(""));case"RIGHT":{let u=[...n(0)];return o(u.slice(Math.max(u.length-a(1),0)).join(""))}case"LPAD":case"RPAD":{let u=[...n(0)],c=a(1),d=s.length>2?n(2):" ";if(u.length>=c)return o(u.slice(0,c).join(""));if(d==="")return o(u.join(""));let E="";for(;[...E].length<c-u.length;)E+=d;return E=[...E].slice(0,c-u.length).join(""),o(e.name==="LPAD"?E+u.join(""):u.join("")+E)}case"POSITION":case"CHARINDEX":{let u=n(0),c=n(1),d=s.length>2?Math.max(a(2)-1,0):0;return r(c.indexOf(u,d)+1)}case"STARTSWITH":return{value:n(0).startsWith(n(1))?"true":"false",type:"boolean"};case"ENDSWITH":return{value:n(0).endsWith(n(1))?"true":"false",type:"boolean"};case"CONTAINS":return{value:n(0).includes(n(1))?"true":"false",type:"boolean"};case"REVERSE":return o([...n(0)].reverse().join(""));case"REPEAT":return o(a(1)<=0?"":n(0).repeat(a(1)));case"ABS":return{value:$(Math.abs(a(0))),type:s[0].type==="fixed"?"fixed":"real"};case"CEIL":case"CEILING":return xe(a(0),s.length>1?a(1):0,Math.ceil,s[0].type);case"FLOOR":return xe(a(0),s.length>1?a(1):0,Math.floor,s[0].type);case"TRUNCATE":return xe(a(0),s.length>1?a(1):0,Math.trunc,s[0].type);case"ROUND":return xe(a(0),s.length>1?a(1):0,Math.round,s[0].type);case"MOD":return{value:$(a(0)%a(1)),type:s[0].type==="fixed"&&s[1].type==="fixed"?"fixed":"real"};case"POWER":case"POW":return i(Math.pow(a(0),a(1)));case"SQRT":return i(Math.sqrt(a(0)));case"EXP":return i(Math.exp(a(0)));case"LN":return i(Math.log(a(0)));case"LOG":return i(s.length>1?Math.log(a(1))/Math.log(a(0)):Math.log(a(0)));case"SIGN":return r(Math.sign(a(0)));case"TO_VARCHAR":case"TO_CHAR":return o(Y(s[0]));case"TO_NUMBER":case"TO_NUMERIC":case"TO_DECIMAL":return{value:$(Math.round(H(Y(s[0])))),type:"fixed"};case"TO_DOUBLE":return i(H(Y(s[0])));case"TO_BOOLEAN":return B(s[0],{type:"boolean",declared:"BOOLEAN"},e.pos);case"TO_DATE":return B(s[0],{type:"date",declared:"DATE"},e.pos);case"TO_TIME":return B(s[0],{type:"time",scale:9,declared:"TIME(9)"},e.pos);case"TO_TIMESTAMP":case"TO_TIMESTAMP_NTZ":return B(s[0],{type:"timestamp_ntz",scale:9,declared:"TIMESTAMP_NTZ(9)"},e.pos);case"TO_TIMESTAMP_LTZ":return B(s[0],{type:"timestamp_ltz",scale:9,declared:"TIMESTAMP_LTZ(9)"},e.pos);case"TO_TIMESTAMP_TZ":return B(s[0],{type:"timestamp_tz",scale:9,declared:"TIMESTAMP_TZ(9)"},e.pos);case"YEAR":case"MONTH":case"DAY":case"DAYOFMONTH":case"HOUR":case"MINUTE":case"SECOND":return r(gt(e.name==="DAYOFMONTH"?"DAY":e.name,s[0],e.pos));case"DATE_PART":return r(gt(String(n(0)).toUpperCase(),s[1],e.pos));case"DATEADD":return ks(String(n(0)).toUpperCase(),a(1),s[2],e.pos);case"DATEDIFF":return r(_s(String(n(0)).toUpperCase(),s[1],s[2],e.pos));case"DATE_TRUNC":return Cs(String(n(0)).toUpperCase(),s[1],e.pos);default:throw b(`function ${e.name}`)}}function We(e,t,s,n){let a=new Set([...t]),o=0,r=e.length;if(s)for(;o<r&&a.has(e[o]);)o+=1;if(n)for(;r>o&&a.has(e[r-1]);)r-=1;return e.slice(o,r)}function xe(e,t,s,n){let a=Math.pow(10,t),o=s(e*a)/a;return{value:$(o),type:n==="fixed"&&t<=0?"fixed":"real"}}var j=864e5;function ke(e,t){let s=e<0,n=Math.round(Math.abs(e)),a=Math.floor(n/1e3),o=n-a*1e3;if(t===0)return`${s?"-":""}${o>=500?a+1:a}`;let r=t>=3?o*Math.pow(10,t-3):Math.floor(o/Math.pow(10,3-t));return`${s?"-":""}${a}.${String(r).padStart(t,"0")}`}function As(e){return e.scale??9}function gs(e){return new Date(e*j).toISOString().slice(0,10)}function ys(e){let t=new Date(e).toISOString();return e%1e3===0?t.slice(11,19):t.slice(11,23)}function bs(e,t){let s=new Date(e+t*6e4).toISOString().slice(0,23).replace("T"," ");if(t===0)return s;let n=t<0?"-":"+",a=Math.abs(t);return`${s} ${n}${String(Math.floor(a/60)).padStart(2,"0")}:${String(a%60).padStart(2,"0")}`}var Ns=/^(\d{4})-(\d{2})-(\d{2})$/,Os=/^(\d{1,2}):(\d{2})(?::(\d{2})(\.\d+)?)?$/,Is=/^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(\.\d+)?)?\s*(Z|[+-]\d{2}:?\d{2})?$/;function St(e){if(e===void 0||e==="")return 0;let t=e.startsWith(".")?e.slice(1):e;if(/[1-9]/.test(t.slice(3)))throw b("sub-millisecond temporal precision");return Number(`${t}000`.slice(0,3))}function Ct(e,t){let s=e.trim();if(t==="time"){let i=Os.exec(s);if(!i)throw me("Time",e);return{ms:(Number(i[1])*3600+Number(i[2])*60+Number(i[3]??"0"))*1e3+St(i[4]),offsetMinutes:0}}let n=Ns.exec(s);if(n){let i=Date.UTC(Number(n[1]),Number(n[2])-1,Number(n[3]));if(Number.isNaN(i))throw me("Date",e);return At(n,e),{ms:i,offsetMinutes:0}}let a=Is.exec(s);if(!a)throw me(t==="date"?"Date":"Timestamp",e);At(a,e);let o=a[8]===void 0||a[8]==="Z"?0:Rs(a[8]);return{ms:Date.UTC(Number(a[1]),Number(a[2])-1,Number(a[3]),Number(a[4]),Number(a[5]),Number(a[6]??"0"))+St(a[7])-o*6e4,offsetMinutes:o}}function At(e,t){let[s,n,a]=[Number(e[1]),Number(e[2]),Number(e[3])],o=new Date(Date.UTC(s,n-1,a));if(o.getUTCFullYear()!==s||o.getUTCMonth()!==n-1||o.getUTCDate()!==a)throw me("Date",t)}function Rs(e){let t=/^([+-])(\d{2}):?(\d{2})$/.exec(e);return t?(t[1]==="-"?-1:1)*(Number(t[2])*60+Number(t[3])):0}function Ee(e,t,s,n){switch(e){case"date":return String(Math.floor(t/j));case"time":return ke((t%j+j)%j,n);case"timestamp_ntz":case"timestamp_ltz":return ke(t,n);case"timestamp_tz":return`${ke(t,n)} ${s+1440}`;default:return String(t)}}function Ze(e){let t=e.value??"";if(e.type==="date")return{ms:Number(t)*j,offsetMinutes:0};let[s,n]=e.type==="timestamp_tz"?t.split(" "):[t,void 0],a=n===void 0?0:Number(n)-1440,o=(s??"").startsWith("-"),[r,i=""]=(o?(s??"").slice(1):s??"").split("."),l=Number(r||"0")*1e3+Number(`${i}000`.slice(0,3)||"0");return{ms:o?-l:l,offsetMinutes:a}}function B(e,t,s){if(e.value===null)return{value:null,type:t.type};if(_.has(t.type)){let n=As(t);if(_.has(e.type)){let{ms:o,offsetMinutes:r}=Ze(e);return{value:Ee(t.type,o,r,n),type:t.type}}if(we(e.type)){let o=Number(e.value),r=t.type==="date"?o*j:o*1e3;return{value:Ee(t.type,r,0,n),type:t.type}}let a=Ct(e.value,t.type);return{value:Ee(t.type,a.ms,a.offsetMinutes,n),type:t.type}}switch(t.type){case"text":{let n=Y(e);return{value:t.length!==void 0?[...n].slice(0,t.length).join(""):n,type:"text"}}case"fixed":{let n=H(_.has(e.type)?String(ie(e)):e.value),a=t.scale??0;return{value:a>0?n.toFixed(a):$(Math.round(n)),type:"fixed"}}case"real":return{value:$(H(e.value)),type:"real"};case"boolean":{let n=e.value.toLowerCase();if(n==="true"||n==="1")return{value:"true",type:"boolean"};if(n==="false"||n==="0")return{value:"false",type:"boolean"};throw new m(p.NUMERIC_VALUE_NOT_RECOGNIZED,`Boolean value '${e.value}' is not recognized`,h.DATA_EXCEPTION)}case"variant":return{value:e.value,type:"variant"};default:throw b(`CAST to ${t.declared}`)}}var xs={YEAR:"YEAR",Y:"YEAR",YY:"YEAR",YYYY:"YEAR",YEAROFWEEK:"YEAR",MONTH:"MONTH",MM:"MONTH",MON:"MONTH",DAY:"DAY",D:"DAY",DD:"DAY",DAYOFMONTH:"DAY",HOUR:"HOUR",HH:"HOUR",H:"HOUR",MINUTE:"MINUTE",MI:"MINUTE",MIN:"MINUTE",SECOND:"SECOND",S:"SECOND",SEC:"SECOND"};function Se(e,t){if(_.has(e.type))return Ze(e);if(e.type==="text"&&e.value!==null)return Ct(e.value,"timestamp_ntz");throw ne(String(e.value),t)}function $e(e,t){let s=xs[e];if(!s)throw b(`date part ${e}`);return s}function gt(e,t,s){if(t.value===null)return null;let{ms:n,offsetMinutes:a}=Se(t,s),o=new Date(n+a*6e4);switch($e(e,s)){case"YEAR":return o.getUTCFullYear();case"MONTH":return o.getUTCMonth()+1;case"DAY":return o.getUTCDate();case"HOUR":return o.getUTCHours();case"MINUTE":return o.getUTCMinutes();default:return o.getUTCSeconds()}}function ks(e,t,s,n){if(s.value===null)return{value:null,type:s.type};let{ms:a,offsetMinutes:o}=Se(s,n),r=new Date(a);switch($e(e,n)){case"YEAR":r.setUTCFullYear(r.getUTCFullYear()+t);break;case"MONTH":r.setUTCMonth(r.getUTCMonth()+t);break;case"DAY":r.setUTCDate(r.getUTCDate()+t);break;case"HOUR":r.setUTCHours(r.getUTCHours()+t);break;case"MINUTE":r.setUTCMinutes(r.getUTCMinutes()+t);break;default:r.setUTCSeconds(r.getUTCSeconds()+t);break}let i=_.has(s.type)?s.type:"timestamp_ntz";return{value:Ee(i,r.getTime(),o,9),type:i}}function _s(e,t,s,n){if(t.value===null||s.value===null)return null;let a=new Date(Se(t,n).ms),o=new Date(Se(s,n).ms);switch($e(e,n)){case"YEAR":return o.getUTCFullYear()-a.getUTCFullYear();case"MONTH":return(o.getUTCFullYear()-a.getUTCFullYear())*12+(o.getUTCMonth()-a.getUTCMonth());case"DAY":return Math.floor(o.getTime()/j)-Math.floor(a.getTime()/j);case"HOUR":return Math.floor(o.getTime()/36e5)-Math.floor(a.getTime()/36e5);case"MINUTE":return Math.floor(o.getTime()/6e4)-Math.floor(a.getTime()/6e4);default:return Math.floor(o.getTime()/1e3)-Math.floor(a.getTime()/1e3)}}function Cs(e,t,s){if(t.value===null)return{value:null,type:t.type};let{ms:n,offsetMinutes:a}=Se(t,s),o=new Date(n);switch($e(e,s)){case"YEAR":o.setUTCMonth(0,1),o.setUTCHours(0,0,0,0);break;case"MONTH":o.setUTCDate(1),o.setUTCHours(0,0,0,0);break;case"DAY":o.setUTCHours(0,0,0,0);break;case"HOUR":o.setUTCMinutes(0,0,0);break;case"MINUTE":o.setUTCSeconds(0,0);break;default:o.setUTCMilliseconds(0);break}let r=_.has(t.type)?t.type:"timestamp_ntz";return{value:Ee(r,o.getTime(),a,9),type:r}}function Ye(e,t,s){let n=e.peek();if(n.kind==="punct"&&n.text==="("){let l=e.captureParenthesized(),u=ye(Ae(l),t,void 0),c=yt(e)??"";return{columns:u.rowtype.map(d=>({...d,qualifier:c})),rows:u.rowset.map(d=>[...d])}}let a=F(L(e),t.session),o=yt(e),r=Ue(t.catalog,a);if(r&&!oe(t.catalog,a))return Lt(r,o??a.name,t,s);let i=De(t.catalog,a);return Qe(i,o??a.name)}function yt(e){if(e.eat("AS"))return e.identifier().name;let t=e.peek();if(t.kind==="word"&&(t.quoted||!xt.has(t.text)))return e.identifier().name}function Lt(e,t,s,n){if(s.viewDepth>=os)throw new m(p.SYNTAX,`SQL compilation error:
|
|
22
|
+
View '${e.database}.${e.schema}.${e.name}' is defined in terms of itself.`,h.SYNTAX_OR_ACCESS);let a=ze(e.sql,{...s,session:{...s.session,database:e.database,schema:e.schema},viewDepth:s.viewDepth+1});if(e.columns.length>0&&e.columns.length!==a.rowtype.length)throw new m(p.SYNTAX,`SQL compilation error:
|
|
23
|
+
View '${e.name}' declares ${e.columns.length} columns but its body returns ${a.rowtype.length}.`,h.SYNTAX_OR_ACCESS);return{columns:a.rowtype.map((o,r)=>({...o,name:e.columns[r]??o.name,qualifier:t})),rows:a.rowset.map(o=>[...o])}}var Ls=new Set(["INNER","LEFT","RIGHT","FULL","CROSS","JOIN"]);function Us(e,t,s){J(e);let n=Ye(e,t,s);for(;;){J(e);let a=e.peek();if(a.kind==="punct"&&a.text===","){e.next();let l=Ye(e,t,s);n=bt(n,l);continue}if(!(a.kind==="word"&&!a.quoted&&Ls.has(a.text)))return n;let o="INNER";e.eat("INNER")?o="INNER":e.eat("LEFT")?(o="LEFT",e.eat("OUTER")):e.eat("RIGHT")?(o="RIGHT",e.eat("OUTER")):e.eat("FULL")?(o="FULL",e.eat("OUTER")):e.eat("CROSS")&&(o="CROSS"),e.expect("JOIN"),J(e);let r=Ye(e,t,s);if(o==="CROSS"){n=bt(n,r);continue}J(e),e.expect("ON");let i=re(e);n=Ds(n,r,o,i,t,s)}}function bt(e,t){let s=[];for(let n of e.rows)for(let a of t.rows)s.push([...n,...a]);return rs(e,t,s)}function Ds(e,t,s,n,a,o){let r={columns:[...e.columns,...t.columns],rows:[]},i=t.columns.map(()=>null),l=e.columns.map(()=>null),u=[],c=new Set;for(let v of e.rows){let O=!1;t.rows.forEach((pe,f)=>{let g=[...v,...pe];W(n,{scope:r,row:g,opts:a,...o?{outer:o}:{}})===!0&&(O=!0,c.add(f),u.push(g))}),!O&&(s==="LEFT"||s==="FULL")&&u.push([...v,...i])}(s==="RIGHT"||s==="FULL")&&t.rows.forEach((v,O)=>{c.has(O)||u.push([...l,...v])});let d=v=>v.map(O=>({...O,nullable:!0})),E=s==="RIGHT"||s==="FULL"?d(e.columns):e.columns,G=s==="LEFT"||s==="FULL"?d(t.columns):t.columns;return{columns:[...E,...G],rows:u}}function Q(e,t){let s=n=>Q(n,t);switch(e.k){case"col":return t?t(e):`col:${e.qualifier??""}.${e.name}`;case"lit":return`lit:${e.type}:${String(e.value)}`;case"bind":return`bind:${e.index}`;case"star":return"star";case"session":return`session:${e.fn}`;case"agg":return`agg:${e.fn}(${s(e.arg)})`;case"func":return`func:${e.name}(${e.args.map(s).join(",")})`;case"cast":return`cast:${e.spec.declared}(${s(e.arg)})`;case"arith":return`arith:${e.op}(${s(e.left)},${s(e.right)})`;case"case":return`case:[${e.whens.map(n=>`${le(n.when,t)}=>${s(n.then)}`).join(";")}]else:${e.otherwise?s(e.otherwise):""}`;case"sub":return`sub:${e.toks.map(n=>n.text).join(" ")}`}}function le(e,t){let s=n=>Q(n,t);switch(e.k){case"cmp":return`cmp:${e.op}(${s(e.left)},${s(e.right)})`;case"null":return`null:${e.negated}(${s(e.left)})`;case"like":return`like:${e.negated}(${s(e.left)},${s(e.right)})`;case"between":return`between:${e.negated}(${s(e.left)},${s(e.lo)},${s(e.hi)})`;case"in":return`in:${e.negated}(${s(e.left)},[${(e.list??[]).map(s).join(",")}],${(e.toks??[]).map(n=>n.text).join(" ")})`;case"exists":return`exists:${e.negated}(${e.toks.map(n=>n.text).join(" ")})`;case"and":return`and(${le(e.a,t)},${le(e.b,t)})`;case"or":return`or(${le(e.a,t)},${le(e.b,t)})`;case"not":return`not(${le(e.a,t)})`}}function K(e,t){switch(e.k){case"col":t.push(e);return;case"agg":return;case"cast":return K(e.arg,t);case"func":{for(let s of e.args)K(s,t);return}case"arith":{K(e.left,t),K(e.right,t);return}case"case":{for(let s of e.whens)Te(s.when,t),K(s.then,t);e.otherwise&&K(e.otherwise,t);return}default:return}}function x(e,t){switch(e.k){case"col":{if(!ge(t,e.qualifier,e.name,e.pos))throw ne(e.qualifier?`${e.qualifier}.${e.name}`:e.name,e.pos);return}case"agg":return x(e.arg,t);case"cast":return x(e.arg,t);case"func":{for(let s of e.args)x(s,t);return}case"arith":{x(e.left,t),x(e.right,t);return}case"case":{for(let s of e.whens)ee(s.when,t),x(s.then,t);e.otherwise&&x(e.otherwise,t);return}default:return}}function ee(e,t){switch(e.k){case"cmp":x(e.left,t),x(e.right,t);return;case"null":x(e.left,t);return;case"like":x(e.left,t),x(e.right,t);return;case"between":x(e.left,t),x(e.lo,t),x(e.hi,t);return;case"in":x(e.left,t);for(let s of e.list??[])x(s,t);return;case"exists":return;case"and":case"or":ee(e.a,t),ee(e.b,t);return;case"not":ee(e.a,t);return}}function Te(e,t){let s=n=>K(n,t);switch(e.k){case"cmp":s(e.left),s(e.right);return;case"null":s(e.left);return;case"like":s(e.left),s(e.right);return;case"between":s(e.left),s(e.lo),s(e.hi);return;case"in":s(e.left);for(let n of e.list??[])s(n);return;case"exists":return;case"and":case"or":Te(e.a,t),Te(e.b,t);return;case"not":Te(e.a,t);return}}function I(e){switch(e.k){case"agg":return!0;case"func":return e.args.some(I);case"arith":return I(e.left)||I(e.right);case"cast":return I(e.arg);case"case":return e.whens.some(t=>_e(t.when)||I(t.then))||(e.otherwise?I(e.otherwise):!1);default:return!1}}function _e(e){switch(e.k){case"cmp":return I(e.left)||I(e.right);case"null":return I(e.left);case"like":return I(e.left)||I(e.right);case"between":return I(e.left)||I(e.lo)||I(e.hi);case"in":return I(e.left)||(e.list??[]).some(I);case"exists":return!1;case"and":case"or":return _e(e.a)||_e(e.b);case"not":return _e(e.a)}}function ye(e,t,s){e.expect("SELECT"),J(e);let n=[];do{let f=e.peek(),g=k(e),w;if(e.eat("AS"))w=e.identifier().name;else{let U=e.peek();U.kind==="word"&&(U.quoted||!xt.has(U.text))&&(w=e.identifier().name)}n.push({expr:g,...w?{alias:w}:{},label:w??ue(g,f)})}while(e.eat(","));if(!e.eat("FROM")){e.assertEnd();let f={opts:t,...s?{outer:s}:{}},g=n.map(w=>N(w.expr,f));return{rowtype:n.map((w,U)=>Dt(w.label,g[U].type)),rowset:[g.map(w=>w.value)],statementTypeId:X.SELECT,mutated:!1}}let a=Us(e,t,s),o=(f,g)=>({scope:a,row:f,opts:t,...s?{outer:s}:{},...g?{group:g}:{}}),r=e.eat("WHERE")?re(e):void 0;J(e);let i=[];if(e.eatSeq("GROUP","BY"))do{if(e.peek().kind==="number")throw b("GROUP BY <ordinal>");i.push(k(e))}while(e.eat(","));let l=e.eat("HAVING")?re(e):void 0;J(e);let u;if(e.eatSeq("ORDER","BY")){if(e.peek().kind==="number")throw b("ORDER BY <ordinal>");let f=e.peek(),g=k(e),w=e.eat("DESC")?!0:(e.eat("ASC"),!1);if(u={expr:g,pos:f.pos,desc:w},e.peek().kind==="punct"&&e.peek().text===",")throw b("ORDER BY with multiple sort keys")}let c;if(e.eat("LIMIT")){let f=e.next();if(f.kind!=="number"||f.text.startsWith("-"))throw y(f.raw||f.text,f.pos);c=Number(f.text)}J(e),e.assertEnd();let d={scope:a,row:a.columns.map(()=>null),opts:t,...s?{outer:s}:{}};for(let f of n)x(f.expr,d);r&&ee(r,d);for(let f of i)x(f,d);l&&ee(l,d);let E=a.rows.filter(f=>Ke(r,o(f))),G=n.length===1&&n[0].expr.k==="star",v=i.length>0||l!==void 0||n.some(f=>I(f.expr))||u!==void 0&&I(u.expr);if(G&&!v){let f=E.map(w=>({row:w,cells:w}));u&&(Nt(u.expr,a,t,s),f=je(f,w=>N(u.expr,o(w.row)),u.desc));let g=(c===void 0?f:f.slice(0,c)).map(w=>w.cells);return{rowtype:a.columns.map(({qualifier:w,...U})=>({...U})),rowset:g,statementTypeId:X.SELECT,mutated:!1}}if(n.some(f=>f.expr.k==="star"))throw b("SELECT *, <expr>");let O;if(v){let f=A=>{let C=ge(d,A.qualifier,A.name,A.pos);return C?`col#${C.index}`:`col:${A.qualifier??""}.${A.name}`},g=new Set(i.map(A=>Q(A,f))),w=A=>{if(g.has(Q(A,f)))return!0;let C=[];return K(A,C),C.every(Ie=>g.has(Q(Ie,f)))};for(let A of n)if(!(I(A.expr)||w(A.expr)))throw qe(A.label);if(l){let A=[];Te(l,A);for(let C of A)if(!g.has(Q(C,f)))throw qe(C.qualifier?`${C.qualifier}.${C.name}`:C.name)}let U=new Map;if(i.length===0)U.set("",{key:E[0]??[],rows:E});else for(let A of E){let C=i.map(Be=>N(Be,o(A))),Ie=JSON.stringify(C.map(Be=>Be.value)),ct=U.get(Ie);ct?ct.rows.push(A):U.set(Ie,{key:A,rows:[A]})}O=[...U.values()].map(A=>({row:A.key,group:A.rows,cells:n.map(C=>N(C.expr,o(A.key,A.rows)).value)})),l&&(O=O.filter(A=>W(l,o(A.row,A.group))===!0))}else O=E.map(f=>({row:f,cells:n.map(g=>N(g.expr,o(f)).value)}));if(u){let f=u.expr,g=f.k==="col"&&f.qualifier===void 0?n.findIndex(w=>w.label===f.name):n.findIndex(w=>Q(w.expr)===Q(f));if(g>=0){let w=Ut(n[g],O,a,t);O=je(O,U=>({value:U.cells[g]??null,type:w}),u.desc)}else Nt(f,a,t,s),O=je(O,w=>N(f,o(w.row,w.group)),u.desc)}return c!==void 0&&(O=O.slice(0,c)),{rowtype:n.map((f,g)=>$s(f,a,O,g,t)),rowset:O.map(f=>f.cells),statementTypeId:X.SELECT,mutated:!1}}function Nt(e,t,s,n){if(e.k!=="col")return;let a={scope:t,row:t.columns.map(()=>null),opts:s,...n?{outer:n}:{}};if(!ge(a,e.qualifier,e.name,e.pos))throw ne(e.qualifier?`${e.qualifier}.${e.name}`:e.name,e.pos)}function je(e,t,s){return e.map(a=>({u:a,key:t(a)})).sort((a,o)=>{let r=a.key,i=o.key;if(r.value===null&&i.value===null)return 0;if(r.value===null)return s?-1:1;if(i.value===null)return s?1:-1;let u=(we(r.type)||_.has(r.type))&&(we(i.type)||_.has(i.type))?ie(r)-ie(i):r.value<i.value?-1:r.value>i.value?1:0;return s?-u:u}).map(a=>a.u)}function $s(e,t,s,n,a){if(e.expr.k==="col"){let i=ge({scope:t,row:t.rows[0]??t.columns.map(()=>null),opts:a},e.expr.qualifier,e.expr.name,e.expr.pos);if(i){let{qualifier:l,...u}=i.ctx.scope.columns[i.index];return{...u,name:e.alias??u.name}}}let o=Ut(e,s,t,a),r=I(e.expr)?!(e.expr.k==="agg"&&e.expr.fn==="COUNT"):!0;return{...Dt(e.label,o),nullable:r}}function Ut(e,t,s,n){let a=t[0]?.row??s.rows[0]??s.columns.map(()=>null),o=t[0]?.group??[];try{return N(e.expr,{scope:s,row:a,opts:n,group:o}).type}catch{return"text"}}function Ms(e,t){let s=t.group??[],n=i=>({...t,row:i,group:void 0});if(e.fn==="COUNT"&&e.arg.k==="star")return{value:String(s.length),type:"fixed"};let a=s.map(i=>N(e.arg,n(i))).filter(i=>i.value!==null);if(e.fn==="COUNT")return{value:String(a.length),type:"fixed"};let o=a[0]?.type??"fixed";if(a.length===0)return{value:null,type:e.fn==="AVG"?"real":o};if(e.fn==="MIN"||e.fn==="MAX"){let i=a[0];for(let l of a.slice(1))ae(l,i,e.fn==="MIN"?"<":">")===!0&&(i=l);return i}let r=a.map(i=>H(i.value));switch(e.fn){case"SUM":return{value:String(r.reduce((i,l)=>i+l,0)),type:o};case"AVG":return{value:String(r.reduce((i,l)=>i+l,0)/r.length),type:"real"}}return{value:null,type:o}}function ue(e,t){switch(e.k){case"col":return e.name;case"session":return`${e.fn}()`;case"agg":return`${e.fn}(${e.arg.k==="star"?"*":ue(e.arg,t)})`;case"func":return`${e.name}(${e.args.map(s=>ue(s,t)).join(", ")})`;case"cast":return`CAST(${ue(e.arg,t)} AS ${e.spec.declared})`;case"arith":return`${ue(e.left,t)} ${e.op} ${ue(e.right,t)}`;case"lit":return e.value===null?"NULL":e.type==="text"?`'${e.value}'`:e.value;case"bind":return`:${e.index}`;case"case":return"CASE";case"sub":return"(SELECT ...)";case"star":return"*"}}function Dt(e,t){switch(t){case"fixed":return{name:e,type:t,nullable:!1,precision:38,scale:0,declared:"NUMBER(38,0)"};case"real":return{name:e,type:t,nullable:!1,precision:38,scale:6,declared:"FLOAT"};case"boolean":return{name:e,type:t,nullable:!1,declared:"BOOLEAN"};case"date":return{name:e,type:t,nullable:!0,declared:"DATE"};case"time":return{name:e,type:t,nullable:!0,scale:9,declared:"TIME(9)"};case"timestamp_ntz":return{name:e,type:t,nullable:!0,scale:9,precision:0,declared:"TIMESTAMP_NTZ(9)"};case"timestamp_ltz":return{name:e,type:t,nullable:!0,scale:9,precision:0,declared:"TIMESTAMP_LTZ(9)"};case"timestamp_tz":return{name:e,type:t,nullable:!0,scale:9,precision:0,declared:"TIMESTAMP_TZ(9)"};case"variant":return{name:e,type:t,nullable:!0,declared:"VARIANT"};default:return{name:e,type:"text",nullable:!0,length:16777216,declared:"VARCHAR(16777216)"}}}function Je(e,t,s,n){return{rowtype:[{name:e,type:"fixed",nullable:!1,precision:38,scale:0,declared:"NUMBER(38,0)"}],rowset:[[String(t)]],statementTypeId:s,catalog:n,mutated:!0}}function S(e,t){return{rowtype:[{name:"status",type:"text",nullable:!1,length:16777216,declared:"VARCHAR(16777216)"}],rowset:[[e]],statementTypeId:X.DDL,...t?{catalog:t}:{},mutated:t!==void 0}}function Ps(e,t){e.expect("INSERT"),e.expect("INTO");let s=F(L(e),t.session),n=De(t.catalog,s),a=n.columns.map(i=>i.name);if(e.peek().kind==="punct"&&e.peek().text==="("){e.next(),a=[];do{let i=e.identifier();et(n,i.name,i.pos),a.push(i.name)}while(e.eat(","));e.expect(")")}if(e.peek().kind==="word"&&e.peek().text==="SELECT"&&!e.peek().quoted)throw b("INSERT \u2026 SELECT");e.expect("VALUES");let o=[];do{e.expect("(");let i=[];do i.push(N(k(e),{opts:t}));while(e.eat(","));if(e.expect(")"),i.length!==a.length)throw new m(p.SYNTAX,`SQL compilation error:
|
|
24
|
+
Insert value list does not match column list expecting ${a.length} but got ${i.length}`,h.SYNTAX_OR_ACCESS);let l=n.columns.map(()=>null);a.forEach((u,c)=>{l[n.columns.findIndex(d=>d.name===u)]=$t(i[c],n.columns.find(d=>d.name===u))}),o.push(l)}while(e.eat(","));e.assertEnd();let r=Z(t.catalog,{...n,rows:[...n.rows,...o],rowsKnown:!0});return Je("number of rows inserted",o.length,X.INSERT,r)}function et(e,t,s){let n=e.columns.findIndex(a=>a.name===t);if(n===-1)throw ne(t,s);return n}function vs(e,t){e.expect("UPDATE");let s=F(L(e),t.session),n=De(t.catalog,s),a=Qe(n,s.name);e.expect("SET");let o=[];do{let u=e.identifier(),c=et(n,u.name,u.pos);e.expect("="),o.push({idx:c,expr:k(e)})}while(e.eat(","));let r=e.eat("WHERE")?re(e):void 0;e.assertEnd(),r&&ee(r,{scope:a,row:a.columns.map(()=>null),opts:t});let i=0,l=n.rows.map(u=>{let c={scope:a,row:u,opts:t};if(!Ke(r,c))return u;i+=1;let d=[...u];for(let E of o)d[E.idx]=$t(N(E.expr,c),n.columns[E.idx]);return d});return Je("number of rows updated",i,X.UPDATE,Z(t.catalog,{...n,rows:l}))}function Fs(e,t){e.expect("DELETE"),e.expect("FROM");let s=F(L(e),t.session),n=De(t.catalog,s),a=Qe(n,s.name),o=e.eat("WHERE")?re(e):void 0;e.assertEnd(),o&&ee(o,{scope:a,row:a.columns.map(()=>null),opts:t});let r=n.rows.filter(l=>!Ke(o,{scope:a,row:l,opts:t})),i=n.rows.length-r.length;return Je("number of rows deleted",i,X.DELETE,Z(t.catalog,{...n,rows:r}))}function Z(e,t){let s=e.tables.map(n=>n.database===t.database&&n.schema===t.schema&&n.name===t.name?t:n);return{...e,tables:s}}function $t(e,t){if(e.value===null){if(!t.nullable)throw new m("100072","NULL result in a non-nullable column",h.DATA_EXCEPTION);return null}switch(t.type){case"fixed":{let s=H(_.has(e.type)?String(ie(e)):e.value);return String(t.scale&&t.scale>0?s.toFixed(t.scale):Math.round(s))}case"real":return String(H(e.value));case"boolean":{let s=e.value.toLowerCase();if(s==="true"||s==="1")return"true";if(s==="false"||s==="0")return"false";throw new m(p.NUMERIC_VALUE_NOT_RECOGNIZED,`Boolean value '${e.value}' is not recognized`,h.DATA_EXCEPTION)}case"date":case"time":case"timestamp_ntz":case"timestamp_ltz":case"timestamp_tz":return B(e,{type:t.type,...t.scale!==void 0?{scale:t.scale}:{},declared:t.declared},1).value;case"text":return Y(e);default:return e.value}}var Hs={NUMBER:{type:"fixed",precision:38,scale:0},NUMERIC:{type:"fixed",precision:38,scale:0},DECIMAL:{type:"fixed",precision:38,scale:0},INT:{type:"fixed",precision:38,scale:0},INTEGER:{type:"fixed",precision:38,scale:0},BIGINT:{type:"fixed",precision:38,scale:0},SMALLINT:{type:"fixed",precision:38,scale:0},TINYINT:{type:"fixed",precision:38,scale:0},FLOAT:{type:"real"},FLOAT4:{type:"real"},FLOAT8:{type:"real"},DOUBLE:{type:"real"},REAL:{type:"real"},VARCHAR:{type:"text",length:16777216},STRING:{type:"text",length:16777216},TEXT:{type:"text",length:16777216},CHAR:{type:"text",length:1},CHARACTER:{type:"text",length:1},BOOLEAN:{type:"boolean"},VARIANT:{type:"variant"},DATE:{type:"date"},TIME:{type:"time",scale:9},DATETIME:{type:"timestamp_ntz",scale:9,precision:0},TIMESTAMP:{type:"timestamp_ntz",scale:9,precision:0},TIMESTAMP_NTZ:{type:"timestamp_ntz",scale:9,precision:0},TIMESTAMP_LTZ:{type:"timestamp_ltz",scale:9,precision:0},TIMESTAMP_TZ:{type:"timestamp_tz",scale:9,precision:0}};function tt(e){let t=e.next();if(t.kind!=="word")throw y(t.raw||t.text,t.pos);let s=Hs[t.text];if(!s)throw b(`data type ${t.text}`);let n=s.precision,a=s.scale,o=s.length,r=t.text;if(e.peek().kind==="punct"&&e.peek().text==="("){e.next();let i=[];do{let l=e.next();if(l.kind!=="number")throw y(l.raw||l.text,l.pos);i.push(Number(l.text))}while(e.eat(","));e.expect(")"),r=`${t.text}(${i.join(",")})`,s.type==="text"?o=i[0]:_.has(s.type)?a=i[0]??a:(n=i[0],a=i[1]??0)}else s.type==="fixed"?r="NUMBER(38,0)":s.type==="text"?r="VARCHAR(16777216)":s.type==="time"?r="TIME(9)":(s.type==="timestamp_ntz"||s.type==="timestamp_ltz"||s.type==="timestamp_tz")&&(r=`${t.text==="DATETIME"||t.text==="TIMESTAMP"?"TIMESTAMP_NTZ":t.text}(9)`);return{type:s.type,...n!==void 0?{precision:n}:{},...a!==void 0?{scale:a}:{},...o!==void 0?{length:o}:{},declared:r}}function Mt(e){return tt(e)}function Bs(e,t){e.expect("CREATE");let s=e.eatSeq("OR","REPLACE");if(e.peek().kind==="word"&&e.peek().text==="MATERIALIZED"&&!e.peek().quoted)throw b("CREATE MATERIALIZED VIEW");if(e.eat("SECURE")){if(e.peek().kind==="word"&&e.peek().text==="MATERIALIZED"&&!e.peek().quoted)throw b("CREATE MATERIALIZED VIEW");if(!e.eat("VIEW"))throw b(`CREATE SECURE ${e.peek().text}`);return Ot(e,t,s,!0)}if(e.eat("TABLE"))return qs(e,t,s);if(e.eat("VIEW"))return Ot(e,t,s,!1);if(e.eat("DATABASE"))return Ws(e,t,s);if(e.eat("SCHEMA"))return Ys(e,t,s);if(e.eat("WAREHOUSE"))return js(e,t,s);let a=e.peek();throw b(`CREATE ${a.text}`)}function qs(e,t,s){let n=e.eatSeq("IF","NOT","EXISTS"),a=F(L(e),t.session),o=oe(t.catalog,a);e.expect("(");let r=[];do{let c=e.identifier(),d=Mt(e),E=!0;e.eatSeq("NOT","NULL")?E=!1:e.eat("NULL"),r.push({name:c.name,nullable:E,...d})}while(e.eat(","));if(e.expect(")"),e.assertEnd(),o&&!s){if(n)return S(`${a.name} already exists, statement succeeded.`);throw q(a.name)}let i={database:a.database,schema:a.schema,name:a.name,columns:r,rows:[],rowsKnown:!0},l=o?t.catalog.tables.map(c=>c===o?i:c):[...t.catalog.tables,i],u=`table:${a.database}.${a.schema}.${a.name}`;return S(`Table ${a.name} successfully created.`,{...t.catalog,tables:l,createdAt:{...t.catalog.createdAt,[u]:s||!o?t.now:t.catalog.createdAt[u]??t.now}})}function Ot(e,t,s,n){let a=e.eatSeq("IF","NOT","EXISTS"),o=F(L(e),t.session),r=[];if(e.peek().kind==="punct"&&e.peek().text==="("){e.next();do r.push(e.identifier().name);while(e.eat(","));e.expect(")")}let i=e.peek();e.expect("AS");let l=t.text.slice(i.pos-1+i.raw.length),u=l.trim().replace(/;\s*$/,"");if(u==="")throw y("<EOF>",i.pos);let c=/^[A-Za-z_$][A-Za-z0-9_$]*/.exec(u)?.[0]?.toUpperCase()??"";if(c!=="SELECT"&&c!=="WITH")throw y(u.split(/\s/)[0]??u,i.pos+i.raw.length+(l.length-l.trimStart().length));let d=Ue(t.catalog,o);if(d&&!s){if(a)return S(`${o.name} already exists, statement succeeded.`);throw q(o.name)}let E={database:o.database,schema:o.schema,name:o.name,sql:u,secure:n,columns:r},G=ze(u,{...t,session:{...t.session,database:o.database,schema:o.schema},viewDepth:t.viewDepth+1});if(r.length>0&&r.length!==G.rowtype.length)throw new m(p.SYNTAX,`SQL compilation error:
|
|
25
|
+
View definition declares ${r.length} columns but the query returns ${G.rowtype.length}.`,h.SYNTAX_OR_ACCESS);let v=d?t.catalog.views.map(pe=>pe===d?E:pe):[...t.catalog.views,E],O=`view:${o.database}.${o.schema}.${o.name}`;return S(`View ${o.name} successfully created.`,{...t.catalog,views:v,createdAt:{...t.catalog.createdAt,[O]:s||!d?t.now:t.catalog.createdAt[O]??t.now}})}function Ws(e,t,s){let n=e.eatSeq("IF","NOT","EXISTS"),{name:a}=e.identifier();e.assertEnd();let o=t.catalog.databases.includes(a);if(o&&!s){if(n)return S(`${a} already exists, statement succeeded.`);throw q(a)}let r=s&&o?t.catalog.schemas.filter(l=>!l.startsWith(`${a}.`)):t.catalog.schemas,i={...t.catalog,databases:o?t.catalog.databases:[...t.catalog.databases,a],schemas:r.includes(`${a}.PUBLIC`)?r:[...r,`${a}.PUBLIC`],tables:s&&o?t.catalog.tables.filter(l=>l.database!==a):t.catalog.tables,views:s&&o?t.catalog.views.filter(l=>l.database!==a):t.catalog.views,createdAt:{...t.catalog.createdAt,[`database:${a}`]:s||!o?t.now:t.catalog.createdAt[`database:${a}`]??t.now,[`schema:${a}.PUBLIC`]:t.now}};return S(`Database ${a} successfully created.`,i)}function Ys(e,t,s){let n=e.eatSeq("IF","NOT","EXISTS"),a=L(e);e.assertEnd();let o=a.parts.length===2?a.parts[0]:t.session.database,r=a.parts[a.parts.length-1];if(!t.catalog.databases.includes(o))throw M(o);let i=`${o}.${r}`,l=t.catalog.schemas.includes(i);if(l&&!s){if(n)return S(`${r} already exists, statement succeeded.`);throw q(r)}let u={...t.catalog,schemas:l?t.catalog.schemas:[...t.catalog.schemas,i],tables:s&&l?t.catalog.tables.filter(c=>!(c.database===o&&c.schema===r)):t.catalog.tables,views:s&&l?t.catalog.views.filter(c=>!(c.database===o&&c.schema===r)):t.catalog.views,createdAt:{...t.catalog.createdAt,[`schema:${i}`]:s||!l?t.now:t.catalog.createdAt[`schema:${i}`]??t.now}};return S(`Schema ${r} successfully created.`,u)}function js(e,t,s){let n=e.eatSeq("IF","NOT","EXISTS"),{name:a}=e.identifier(),o="X-Small";for(e.eat("WITH");e.peek().kind==="word";){let u=e.identifier();e.expect("=");let c=e.next();u.name==="WAREHOUSE_SIZE"&&(o=c.kind==="string"?c.text:c.raw),e.eat(",")}e.assertEnd();let r=t.catalog.warehouses.find(u=>u.name===a);if(r&&!s){if(n)return S(`${a} already exists, statement succeeded.`);throw q(a)}let i={name:a,size:o,state:"STARTED"},l=r?t.catalog.warehouses.map(u=>u===r?i:u):[...t.catalog.warehouses,i];return S(`Warehouse ${a} successfully created.`,{...t.catalog,warehouses:l,createdAt:{...t.catalog.createdAt,[`warehouse:${a}`]:s||!r?t.now:t.catalog.createdAt[`warehouse:${a}`]??t.now}})}function Xs(e,t){if(e.expect("ALTER"),!e.eat("TABLE"))throw b(`ALTER ${e.peek().text}`);let s=e.eatSeq("IF","EXISTS"),n=F(L(e),t.session),a=oe(t.catalog,n);if(!a){if(s)return S("Statement executed successfully.");throw M(n.fqn)}let o=a;if(e.eatSeq("RENAME","TO")){let r=F(L(e),t.session);if(e.assertEnd(),oe(t.catalog,r))throw q(r.name);let i={...o,database:r.database,schema:r.schema,name:r.name},l=`table:${n.database}.${n.schema}.${n.name}`,u=`table:${r.database}.${r.schema}.${r.name}`,c={...t.catalog.createdAt};return c[l]!==void 0&&(c[u]=c[l],delete c[l]),S("Statement executed successfully.",{...t.catalog,tables:t.catalog.tables.map(d=>d===o?i:d),createdAt:c})}if(e.eatSeq("RENAME","COLUMN")){let r=e.identifier(),i=et(o,r.name,r.pos);e.expect("TO");let l=e.identifier();if(e.assertEnd(),o.columns.some(c=>c.name===l.name))throw q(l.name);let u=o.columns.map((c,d)=>d===i?{...c,name:l.name}:c);return S("Statement executed successfully.",Z(t.catalog,{...o,columns:u}))}if(e.eat("ADD")){e.eat("COLUMN");let r=e.identifier();if(o.columns.some(d=>d.name===r.name))throw q(r.name);let i=Mt(e),l=!0;if(e.eatSeq("NOT","NULL")?l=!1:e.eat("NULL"),e.assertEnd(),!l&&o.rows.length>0)throw new m(p.SYNTAX,`SQL compilation error:
|
|
26
|
+
cannot add NOT NULL column '${r.name}' to a table that already has rows and no DEFAULT.`,h.SYNTAX_OR_ACCESS);let u=[...o.columns,{name:r.name,nullable:l,...i}],c=o.rows.map(d=>[...d,null]);return S("Statement executed successfully.",Z(t.catalog,{...o,columns:u,rows:c}))}if(e.eat("DROP")){e.eat("COLUMN");let r=e.eatSeq("IF","EXISTS"),i=e.identifier();e.assertEnd();let l=o.columns.findIndex(d=>d.name===i.name);if(l===-1){if(r)return S("Statement executed successfully.");throw ne(i.name,i.pos)}if(o.columns.length===1)throw new m(p.SYNTAX,`SQL compilation error:
|
|
27
|
+
cannot drop the only column of a table.`,h.SYNTAX_OR_ACCESS);let u=o.columns.filter((d,E)=>E!==l),c=o.rows.map(d=>d.filter((E,G)=>G!==l));return S("Statement executed successfully.",Z(t.catalog,{...o,columns:u,rows:c}))}if(e.eat("SET")){let r=e.identifier();if(r.name!=="COMMENT")throw b(`ALTER TABLE \u2026 SET ${r.name}`);e.expect("=");let i=e.next();if(i.kind!=="string")throw y(i.raw||i.text,i.pos);return e.assertEnd(),S("Statement executed successfully.",Z(t.catalog,{...o,comment:i.text}))}if(e.eat("UNSET")){let r=e.identifier();if(r.name!=="COMMENT")throw b(`ALTER TABLE \u2026 UNSET ${r.name}`);return e.assertEnd(),S("Statement executed successfully.",Z(t.catalog,{...o,comment:""}))}throw b(`ALTER TABLE \u2026 ${e.peek().text}`)}function Vs(e,t){if(e.expect("DROP"),e.eat("TABLE")){let s=e.eatSeq("IF","EXISTS"),n=F(L(e),t.session);e.assertEnd();let a=oe(t.catalog,n);if(!a){if(s)return S(`Drop statement executed successfully (${n.name} already dropped).`);throw M(n.fqn)}return S(`${n.name} successfully dropped.`,{...t.catalog,tables:t.catalog.tables.filter(o=>o!==a)})}if(e.eat("VIEW")){let s=e.eatSeq("IF","EXISTS"),n=F(L(e),t.session);e.assertEnd();let a=Ue(t.catalog,n);if(!a){if(s)return S(`Drop statement executed successfully (${n.name} already dropped).`);throw M(n.fqn)}return S(`${n.name} successfully dropped.`,{...t.catalog,views:t.catalog.views.filter(o=>o!==a)})}if(e.eat("DATABASE")){let s=e.eatSeq("IF","EXISTS"),{name:n}=e.identifier();if(e.assertEnd(),!t.catalog.databases.includes(n)){if(s)return S(`Drop statement executed successfully (${n} already dropped).`);throw M(n)}return S(`${n} successfully dropped.`,{...t.catalog,databases:t.catalog.databases.filter(a=>a!==n),schemas:t.catalog.schemas.filter(a=>!a.startsWith(`${n}.`)),tables:t.catalog.tables.filter(a=>a.database!==n),views:t.catalog.views.filter(a=>a.database!==n)})}if(e.eat("SCHEMA")){let s=e.eatSeq("IF","EXISTS"),n=L(e);e.assertEnd();let a=n.parts.length===2?n.parts[0]:t.session.database,o=n.parts[n.parts.length-1],r=`${a}.${o}`;if(!t.catalog.schemas.includes(r)){if(s)return S(`Drop statement executed successfully (${o} already dropped).`);throw M(o)}return S(`${o} successfully dropped.`,{...t.catalog,schemas:t.catalog.schemas.filter(i=>i!==r),tables:t.catalog.tables.filter(i=>!(i.database===a&&i.schema===o)),views:t.catalog.views.filter(i=>!(i.database===a&&i.schema===o))})}if(e.eat("WAREHOUSE")){let s=e.eatSeq("IF","EXISTS"),{name:n}=e.identifier();if(e.assertEnd(),!t.catalog.warehouses.some(a=>a.name===n)){if(s)return S(`Drop statement executed successfully (${n} already dropped).`);throw M(n)}return S(`${n} successfully dropped.`,{...t.catalog,warehouses:t.catalog.warehouses.filter(a=>a.name!==n)})}throw b(`DROP ${e.peek().text}`)}function Gs(e,t){e.expect("USE");let s=e.eat("DATABASE")?"database":e.eat("SCHEMA")?"schema":e.eat("WAREHOUSE")?"warehouse":e.eat("ROLE")?"role":"schema",n=L(e);if(e.assertEnd(),s==="database"){if(!t.catalog.databases.includes(n.parts[0]))throw M(n.text);return{...S("Statement executed successfully."),sessionMutation:{database:n.parts[0],schema:"PUBLIC"}}}if(s==="schema"){let a=n.parts.length===2?n.parts[0]:t.session.database,o=n.parts[n.parts.length-1];if(!t.catalog.schemas.includes(`${a}.${o}`))throw M(n.text);return{...S("Statement executed successfully."),sessionMutation:{database:a,schema:o}}}if(s==="warehouse"){if(!t.catalog.warehouses.some(a=>a.name===n.parts[0]))throw M(n.text);return{...S("Statement executed successfully."),sessionMutation:{warehouse:n.parts[0]}}}return{...S("Statement executed successfully."),sessionMutation:{role:n.parts[0]}}}function zs(e){return{name:e,type:"text",nullable:!0,length:16777216,declared:"VARCHAR(16777216)"}}var Qs=["created_on","name","is_default","is_current","origin","owner","comment","options","retention_time","kind"],Ks=["created_on","name","is_default","is_current","database_name","owner","comment","options","retention_time"],Zs=["created_on","name","database_name","schema_name","kind","comment","cluster_by","rows","bytes","owner","retention_time"],Js=["name","state","type","size","min_cluster_count","max_cluster_count","started_clusters","running","queued","is_default","is_current"],It=["name","type","kind","null?","default","primary key","unique key","check","expression","comment"];function en(e,t){e.expect("SHOW");let s=e.next();if(s.kind!=="word")throw y(s.raw||s.text,s.pos);e.assertEnd();let n=t.catalog,a=r=>n.createdAt[r]??null,o=r=>r?"Y":"N";switch(s.text){case"DATABASES":return ce(Qs,[...n.databases].sort().map(r=>[a(`database:${r}`),r,o(!1),o(r===t.session.database),"",null,"","",null,"STANDARD"]));case"SCHEMAS":return ce(Ks,[...n.schemas].filter(r=>t.session.database===""||r.startsWith(`${t.session.database}.`)).sort().map(r=>{let[i,l]=[r.split(".")[0],r.split(".")[1]];return[a(`schema:${r}`),l,o(!1),o(i===t.session.database&&l===t.session.schema),i,null,"","",null]}));case"WAREHOUSES":return ce(Js,[...n.warehouses].sort((r,i)=>r.name<i.name?-1:1).map(r=>[r.name,r.state,"STANDARD",r.size,"1","1",r.state==="STARTED"?"1":"0","0","0",o(!1),o(r.name===t.session.warehouse)]));case"TABLES":{if(t.session.database===""||t.session.schema==="")throw new m(p.OBJECT_DOES_NOT_EXIST,`SQL compilation error:
|
|
28
|
+
Cannot perform SHOW TABLES. This session does not have a current schema. Call 'USE SCHEMA', or use a qualified name.`,h.TABLE_NOT_FOUND);let r=n.tables.filter(i=>i.database===t.session.database&&i.schema===t.session.schema).sort((i,l)=>i.name<l.name?-1:1).map(i=>[a(`table:${i.database}.${i.schema}.${i.name}`),i.name,i.database,i.schema,"TABLE",i.comment??"","",i.rowsKnown?String(i.rows.length):null,null,null,null]);return ce(Zs,r)}default:throw b(`SHOW ${s.text}`)}}function ce(e,t){return{rowtype:e.map(zs),rowset:t,statementTypeId:X.SELECT,mutated:!1}}function tn(e,t){e.next();let s=e.eat("VIEW");s||e.eat("TABLE");let n=F(L(e),t.session);e.assertEnd();let a=Ue(t.catalog,n);if(a&&(s||!oe(t.catalog,n))){let r=Lt(a,n.name,t,void 0).columns;return ce(It,r.map(i=>[i.name,i.declared,"COLUMN",i.nullable?"Y":"N",null,"N","N",null,null,""]))}let o=kt(t.catalog,n);return ce(It,o.columns.map(r=>[r.name,r.declared,"COLUMN",r.nullable?"Y":"N",null,"N","N",null,null,""]))}var nt="snowflake",Me="8.0.0",Pt="PUBLIC";function Ne(e,t=0){return typeof e=="number"?e:t}function T(e,t=""){return typeof e=="string"?e:t}function be(e,t){let s=t.createdAt;typeof s=="string"&&s!==""&&(e.createdAt[t.id]=s)}function V(e){let t=an(nt,e.root),s=Ve(),n=[],a=[],o=new Set,r=new Map;for(let i of t){o.add(i.id),r.set(i.id,Ne(i.rev));let l=i.gone===!0;switch(i.type){case"database":l||(s.databases.push(T(i.name)),be(s,i));break;case"schema":l||(s.schemas.push(`${T(i.db)}.${T(i.name)}`),be(s,i));break;case"warehouse":l||(s.warehouses.push({name:T(i.name),size:T(i.size,"X-Small"),state:T(i.state,"STARTED")}),be(s,i));break;case"table":if(!l){be(s,i);let u=i.rows;s.tables.push({database:T(i.db),schema:T(i.sch),name:T(i.tbl),columns:i.cols??[],rows:u??[],rowsKnown:Array.isArray(u),...typeof i.comment=="string"?{comment:i.comment}:{}})}break;case"view":l||(be(s,i),s.views.push({database:T(i.db),schema:T(i.sch),name:T(i.view),sql:T(i.sql),secure:i.secure===!0,columns:i.cols??[]}));break;case"session":n.push({sessionId:i.id.slice(8),token:T(i.token),masterToken:T(i.masterToken),account:T(i.account),user:T(i.user),role:T(i.role,Pt),database:T(i.db),schema:T(i.sch),warehouse:T(i.wh),closed:i.closed===!0,rev:Ne(i.rev)});break;case"query":a.push({queryId:i.id.slice(6),sessionId:T(i.sessionId),sqlText:T(i.sqlText),status:T(i.status),statementTypeId:Ne(i.statementTypeId),rowtype:i.rowtype??[],rowset:i.rowset??[],errorCode:T(i.errorCode),errorMessage:T(i.errorMessage),sqlState:T(i.sqlState),database:T(i.db),schema:T(i.sch),warehouse:T(i.wh),role:T(i.role),startedAt:T(i.startedAt),endedAt:T(i.endedAt),isAsync:i.isAsync===!0,rev:Ne(i.rev)});break;default:break}}return{catalog:s,sessions:n,queries:a,ids:o,revs:r}}function at(e){return sn("sha256").update(e.join("\0")).digest("hex")}function vt(e){let t=at(e);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20,32)}`}function Ft(e,t,s,n){for(let a=0;a<1e3;a+=1){let o=n([...t,String(a)]);if(!s.has(`${e}:${o}`))return o}throw new Error("snowflake twin: could not mint a free id after 1000 probes")}function on(e){return String(BigInt(`0x${at(e).slice(0,15)}`))}function st(e,t){return`twin-${e}-${at([e,...t]).slice(0,32)}`}async function de(e,t){if(e.readOnly&&t.some(s=>s.sessionScaffolding!==!0))throw new z;for(let s of t)await nn(nt,n=>{let a=n.find(r=>r.type===s.subjectType&&r.id===s.subjectId),o=Ne(a?.rev)+1;return{kind:"write",value:void 0,write:{...s,fields:{...s.fields,rev:o},occurredAt:e.occurredAt}}},e.root)}async function Pe(e,t){let s=V(t),n=e.account.toUpperCase(),a=Ft("session",[n,e.user,t.occurredAt],s.ids,on),o={sessionId:a,token:st("session",[n,e.user,a]),masterToken:st("master",[n,e.user,a]),account:n,user:e.user,role:(e.role??Pt).toUpperCase(),database:(e.database??"").toUpperCase(),schema:(e.schema??(e.database?"PUBLIC":"")).toUpperCase(),warehouse:(e.warehouse??"").toUpperCase(),closed:!1,rev:0};return await de(t,[{subjectType:"session",subjectId:`session:${a}`,operation:"session.login",sessionScaffolding:!0,fields:{token:o.token,masterToken:o.masterToken,account:o.account,user:o.user,role:o.role,db:o.database,sch:o.schema,wh:o.warehouse,closed:!1,startedAt:t.occurredAt}}]),{session:o}}function ot(e,t){return V(t).sessions.find(s=>s.token===e&&!s.closed)}function Ht(e,t){return V(t).sessions.find(s=>s.masterToken===e&&!s.closed)}async function rt(e,t){await de(t,[{subjectType:"session",subjectId:`session:${e.sessionId}`,operation:"session.logout",sessionScaffolding:!0,fields:{closed:!0,endedAt:t.occurredAt}}])}async function Bt(e,t){let s=st("session",[e.account,e.user,e.sessionId,String(e.rev+1)]);return await de(t,[{subjectType:"session",subjectId:`session:${e.sessionId}`,operation:"session.renew",sessionScaffolding:!0,fields:{token:s,renewedAt:t.occurredAt}}]),{...e,token:s}}async function ve(e,t,s,n={}){let a=V(s),o=Ft("query",[e.sessionId,t,s.occurredAt],a.ids,vt),r={account:e.account,user:e.user,role:e.role,database:e.database,schema:e.schema,warehouse:e.warehouse,serverVersion:Me},i,l;try{i=Ge(t,{catalog:a.catalog,session:r,now:s.occurredAt,...n.bindings?{bindings:n.bindings}:{}})}catch(E){if(!(E instanceof m))throw E;l=E}let u=[],c=e;i?.catalog&&u.push(...rn(a.catalog,i.catalog)),i?.sessionMutation&&(c={...e,...i.sessionMutation},u.push({subjectType:"session",subjectId:`session:${e.sessionId}`,operation:"session.context",sessionScaffolding:!0,fields:{db:c.database,sch:c.schema,wh:c.warehouse,role:c.role}}));let d={queryId:o,sessionId:e.sessionId,sqlText:t,status:l?"FAILED_WITH_ERROR":"SUCCESS",statementTypeId:i?.statementTypeId??0,rowtype:i?.rowtype??[],rowset:i?.rowset??[],errorCode:l?.code??"",errorMessage:l?.message??"",sqlState:l?.sqlState??"",database:c.database,schema:c.schema,warehouse:c.warehouse,role:c.role,startedAt:s.occurredAt,endedAt:s.occurredAt,isAsync:n.isAsync===!0,rev:0};if(u.push({subjectType:"query",subjectId:`query:${o}`,operation:l?"query.fail":"query.execute",fields:{sessionId:d.sessionId,sqlText:d.sqlText,status:d.status,statementTypeId:d.statementTypeId,rowtype:d.rowtype,rowset:d.rowset,errorCode:d.errorCode,errorMessage:d.errorMessage,sqlState:d.sqlState,db:d.database,sch:d.schema,wh:d.warehouse,role:d.role,startedAt:d.startedAt,endedAt:d.endedAt,isAsync:d.isAsync}}),s.readOnly){if(i?.mutated)throw new z;if(await de(s,u.filter(E=>E.sessionScaffolding===!0)),l)throw Object.assign(l,{queryId:o});return{query:d,session:c}}if(await de(s,u),l)throw Object.assign(l,{queryId:o});return{query:d,session:c}}function rn(e,t){let s=[],n=l=>({...t.createdAt[l]!==void 0?{createdAt:t.createdAt[l]}:{}});for(let l of t.databases)e.databases.includes(l)||s.push({subjectType:"database",subjectId:`database:${l}`,operation:"database.create",fields:{name:l,gone:!1,...n(`database:${l}`)}});for(let l of e.databases)t.databases.includes(l)||s.push({subjectType:"database",subjectId:`database:${l}`,operation:"database.drop",fields:{name:l,gone:!0}});for(let l of t.schemas)e.schemas.includes(l)||s.push({subjectType:"schema",subjectId:`schema:${l}`,operation:"schema.create",fields:{db:l.split(".")[0],name:l.split(".")[1],gone:!1,...n(`schema:${l}`)}});for(let l of e.schemas)t.schemas.includes(l)||s.push({subjectType:"schema",subjectId:`schema:${l}`,operation:"schema.drop",fields:{db:l.split(".")[0],name:l.split(".")[1],gone:!0}});for(let l of t.warehouses){let u=e.warehouses.find(c=>c.name===l.name);(!u||u.size!==l.size||u.state!==l.state)&&s.push({subjectType:"warehouse",subjectId:`warehouse:${l.name}`,operation:"warehouse.create",fields:{name:l.name,size:l.size,state:l.state,gone:!1,...n(`warehouse:${l.name}`)}})}for(let l of e.warehouses)t.warehouses.some(u=>u.name===l.name)||s.push({subjectType:"warehouse",subjectId:`warehouse:${l.name}`,operation:"warehouse.drop",fields:{name:l.name,size:l.size,state:"SUSPENDED",gone:!0}});let a=l=>`${l.database}.${l.schema}.${l.name}`,o=(l,u)=>JSON.stringify(l.columns)===JSON.stringify(u.columns)&&JSON.stringify(l.rows)===JSON.stringify(u.rows)&&l.rowsKnown===u.rowsKnown&&(l.comment??"")===(u.comment??"");for(let l of t.tables){let u=e.tables.find(c=>a(c)===a(l));(!u||!o(u,l))&&s.push({subjectType:"table",subjectId:`table:${a(l)}`,operation:u?"table.write":"table.create",fields:{db:l.database,sch:l.schema,tbl:l.name,cols:l.columns,gone:!1,...l.rowsKnown?{rows:l.rows}:{},comment:l.comment??"",...n(`table:${a(l)}`)}})}for(let l of e.tables)t.tables.some(u=>a(u)===a(l))||s.push({subjectType:"table",subjectId:`table:${a(l)}`,operation:"table.drop",fields:{db:l.database,sch:l.schema,tbl:l.name,cols:l.columns,rows:[],gone:!0}});let r=l=>`${l.database}.${l.schema}.${l.name}`,i=(l,u)=>l.sql===u.sql&&l.secure===u.secure&&JSON.stringify(l.columns)===JSON.stringify(u.columns);for(let l of t.views){let u=e.views.find(c=>r(c)===r(l));(!u||!i(u,l))&&s.push({subjectType:"view",subjectId:`view:${r(l)}`,operation:u?"view.write":"view.create",fields:{db:l.database,sch:l.schema,view:l.name,sql:l.sql,secure:l.secure,cols:l.columns,gone:!1,...n(`view:${r(l)}`)}})}for(let l of e.views)t.views.some(u=>r(u)===r(l))||s.push({subjectType:"view",subjectId:`view:${r(l)}`,operation:"view.drop",fields:{db:l.database,sch:l.schema,view:l.name,sql:l.sql,secure:l.secure,cols:l.columns,gone:!0}});return s}function fe(e,t){return V(t).queries.find(s=>s.queryId===e)}async function Fe(e,t){await de(t,[{subjectType:"query",subjectId:`query:${e.queryId}`,operation:"query.abort",fields:{status:"ABORTED",endedAt:t.occurredAt}}])}var Wt=14400,Yt=14400,jt=[{name:"CLIENT_SESSION_KEEP_ALIVE",value:!1},{name:"CLIENT_SESSION_KEEP_ALIVE_HEARTBEAT_FREQUENCY",value:3600},{name:"JS_TREAT_INTEGER_AS_BIGINT",value:!1},{name:"QUERY_CONTEXT_CACHE_SIZE",value:5},{name:"TIMESTAMP_OUTPUT_FORMAT",value:"YYYY-MM-DD HH24:MI:SS.FF3 TZHTZM"}],ln="2026-01-01T00:00:00.000Z";function Xt(e,t){let s=e.headers??{},n=Object.keys(s).find(a=>a.toLowerCase()===t.toLowerCase());return n===void 0?void 0:s[n]}function Oe(e){if(!e.body)return{};try{let t=JSON.parse(e.body);return typeof t=="object"&&t!==null?t:{}}catch{return{}}}function D(e){return{...e.root!==void 0?{root:e.root}:{},occurredAt:e.occurredAt??ln,...e.readOnly?{readOnly:!0}:{}}}function Vt(e){return Xt(e,"authorization")?.match(/^Snowflake Token="(.*)"$/)?.[1]}var qt=()=>new R(se.SESSION_TOKEN_INVALID,"Session token is invalid or has been revoked. Authenticate again.",401);async function it(e){let t=new URL(e.path,"http://twin.invalid"),s=t.pathname.replace(/\/+$/,"")||"/",n=s.startsWith("/api/v2/");try{return n?await Nn(e,s,t):await un(e,s,t)}catch(a){if(a instanceof z)return{status:405,body:n?{code:p.UNSUPPORTED_FEATURE,message:a.message,sqlState:h.FEATURE_NOT_SUPPORTED}:he(new R(p.UNSUPPORTED_FEATURE,a.message))};if(a instanceof m){let o=a.queryId;return n?{status:422,body:Kt(a,o)}:{status:200,body:he(a,o?{queryId:o}:{})}}if(a instanceof R)return n?{status:a.status===200?400:a.status,body:{code:a.code,message:a.message,sqlState:h.SYNTAX_OR_ACCESS}}:{status:a.status,body:he(a)};throw a}}async function un(e,t,s){if(t==="/session/v1/login-request"&&e.method==="POST")return cn(e,s);if(t==="/session/token-request"&&e.method==="POST")return dn(e);if(t==="/session"&&e.method==="POST")return fn(e,s);if(t==="/session/heartbeat"&&e.method==="POST")return pn(e);if(t==="/queries/v1/query-request"&&e.method==="POST")return hn(e);if(t==="/queries/v1/abort-request"&&e.method==="POST")return gn(e);if(t==="/telemetry/send"&&e.method==="POST")return mn(e);let n=t.match(/^\/queries\/([^/]+)\/abort-request$/);if(n&&e.method==="POST")return An(e,n[1]);let a=t.match(/^\/queries\/([^/]+)\/result$/);if(a&&e.method==="GET")return wn(e,a[1]);let o=t.match(/^\/monitoring\/queries\/([^/]+)$/);if(o&&e.method==="GET")return Sn(e,o[1]);throw Re(e.method,t)}function te(e){let t=Vt(e);if(!t)throw qt();let s=ot(t,D(e));if(!s)throw qt();return s}async function cn(e,t){let n=Oe(e).data??{},a=typeof n.ACCOUNT_NAME=="string"?n.ACCOUNT_NAME:"",o=typeof n.LOGIN_NAME=="string"?n.LOGIN_NAME:"",r=typeof n.PASSWORD=="string"?n.PASSWORD:"";if(a===""||o===""||r==="")throw new R(se.INCORRECT_USERNAME_PASSWORD,"Incorrect username or password was specified.");if(typeof n.AUTHENTICATOR=="string"&&n.AUTHENTICATOR.toUpperCase()!=="SNOWFLAKE")throw new R(p.UNSUPPORTED_FEATURE,`[twin gap] authenticator '${n.AUTHENTICATOR}' is not modeled by the Snowflake twin; only SNOWFLAKE (username/password) is. The surface is filed as a todo in snowflake-capabilities.ts.`);let i=D(e),l=V(i),u={database:(t.searchParams.get("databaseName")??"").toUpperCase(),schema:(t.searchParams.get("schemaName")??"").toUpperCase(),warehouse:(t.searchParams.get("warehouse")??"").toUpperCase(),role:(t.searchParams.get("roleName")??"").toUpperCase()};if(u.database!==""&&!l.catalog.databases.includes(u.database))throw new R("390201",`The requested database does not exist or not authorized. Database: '${u.database}'`);if(u.warehouse!==""&&!l.catalog.warehouses.some(d=>d.name===u.warehouse))throw new R("390201",`The requested warehouse does not exist or not authorized. Warehouse: '${u.warehouse}'`);if(u.database!==""&&u.schema!==""&&!l.catalog.schemas.includes(`${u.database}.${u.schema}`))throw new R("390201",`The requested schema does not exist or not authorized. Schema: '${u.schema}'`);let{session:c}=await Pe({account:a,user:o,...u.database?{database:u.database}:{},...u.schema?{schema:u.schema}:{},...u.warehouse?{warehouse:u.warehouse}:{},...u.role?{role:u.role}:{}},i);return{status:200,body:P({token:c.token,masterToken:c.masterToken,validityInSeconds:Wt,masterValidityInSeconds:Yt,sessionId:c.sessionId,displayUserName:c.user,serverVersion:Me,firstLogin:!0,healthCheckInterval:45,newClientForUpgrade:null,remMeToken:null,remMeValidityInSeconds:0,sessionInfo:{databaseName:c.database||null,schemaName:c.schema||null,warehouseName:c.warehouse||null,roleName:c.role},parameters:jt})}}async function dn(e){let t=Oe(e);if(t.requestType!=="RENEW")throw new R(p.UNSUPPORTED_FEATURE,`[twin gap] /session/token-request requestType '${String(t.requestType)}' is not modeled by the Snowflake twin; only RENEW is.`);let s=Vt(e);if(!s)throw new R(se.MASTER_TOKEN_EXPIRED,"Master token has expired. The user must authenticate again.",401);let n=Ht(s,D(e));if(!n)throw new R(se.MASTER_TOKEN_EXPIRED,"Master token has expired. The user must authenticate again.",401);let a=await Bt(n,D(e));return{status:200,body:P({sessionToken:a.token,validityInSecondsST:Wt,masterToken:a.masterToken,validityInSecondsMT:Yt,sessionId:a.sessionId})}}async function fn(e,t){if(t.searchParams.get("delete")!=="true")throw Re(e.method,"/session");let s=te(e);return await rt(s,D(e)),{status:200,body:P(null)}}function pn(e){return te(e),{status:200,body:P(null)}}function mn(e){return te(e),{status:200,body:P(null)}}async function hn(e){let t=te(e),s=Oe(e),n=typeof s.sqlText=="string"?s.sqlText:"";if(n.trim()==="")throw new m(p.SYNTAX,`SQL compilation error:
|
|
29
|
+
syntax error line 1 at position 0 unexpected '<EOF>'.`,h.SYNTAX_OR_ACCESS,0);if(s.describeOnly===!0)throw new R(p.UNSUPPORTED_FEATURE,"[twin gap] describeOnly statements are not modeled by the Snowflake twin; the surface is filed as a todo in snowflake-capabilities.ts.");let a=Gt(s.bindings),o=s.asyncExec===!0,{query:r}=await ve(t,n,D(e),{...a?{bindings:a}:{},...o?{isAsync:!0}:{}});return{status:200,body:P(o?Tn(r):zt(r))}}function Gt(e){if(typeof e!="object"||e===null)return;let t={};for(let[s,n]of Object.entries(e)){if(typeof n!="object"||n===null)continue;let a=n;t[s]={type:typeof a.type=="string"?a.type:"TEXT",value:a.value===null||a.value===void 0?null:String(a.value)}}return t}function zt(e){return{parameters:jt,rowtype:e.rowtype.map(En),rowset:e.rowset,total:e.rowset.length,returned:e.rowset.length,queryId:e.queryId,databaseProvider:null,finalDatabaseName:e.database||null,finalSchemaName:e.schema||null,finalWarehouseName:e.warehouse||null,finalRoleName:e.role,numberOfBinds:0,arrayBindSupported:!1,statementTypeId:e.statementTypeId,version:1,sendResultTime:0,queryResultFormat:"json"}}function En(e){return{name:e.name,database:"",schema:"",table:"",nullable:e.nullable,type:e.type,byteLength:e.length??null,length:e.length??null,scale:e.scale??null,precision:e.precision??null}}function Tn(e){return{queryId:e.queryId,getResultUrl:`/queries/${e.queryId}/result`,queryAbortsAfterSecs:300,progressDesc:null,queryContext:{entries:[]}}}function Qt(e,t){let s=fe(t,D(e));if(!s)throw new m(p.OBJECT_DOES_NOT_EXIST,`SQL compilation error:
|
|
30
|
+
Query '${t}' not found.`,h.TABLE_NOT_FOUND);return s}function wn(e,t){te(e);let s=Qt(e,t);return s.status==="FAILED_WITH_ERROR"?{status:200,body:he(new m(s.errorCode,s.errorMessage,s.sqlState),{queryId:t})}:{status:200,body:P(zt(s))}}function Sn(e,t){te(e);let s=fe(t,D(e));return s?{status:200,body:P({queries:[{id:s.queryId,status:s.status,state:s.status,errorCode:s.errorCode||null,errorMessage:s.errorMessage||null,sqlText:s.sqlText,startTime:s.startedAt,endTime:s.endedAt,warehouseName:s.warehouse||null,sessionId:s.sessionId}],...s.status==="FAILED_WITH_ERROR"?{sqlState:s.sqlState}:{}})}:{status:200,body:P({queries:[]})}}async function An(e,t){te(e);let s=Qt(e,t);return await Fe(s,D(e)),{status:200,body:P(null)}}function gn(e){te(e);let t=Oe(e);if(typeof t.requestId!="string"||t.requestId==="")throw new R(p.SYNTAX,"Invalid abort request: requestId is required.");return{status:200,body:P(null)}}function Kt(e,t){return{code:e.code,message:e.message,sqlState:e.sqlState,...t?{statementHandle:t,statementStatusUrl:`/api/v2/statements/${t}`}:{}}}function lt(e){let t=Xt(e,"authorization");if(!t||!/^Bearer\s+\S/.test(t))throw new R(se.SESSION_TOKEN_INVALID,"Unauthorized: a Bearer token is required.",401)}async function yn(e,t){let s=D(e),o=V(s).sessions.find(r=>r.user==="SQLAPI"&&!r.closed)??(s.readOnly?bn():(await Pe({account:"TWIN",user:"SQLAPI"},s)).session);return{...o,database:typeof t.database=="string"?t.database.toUpperCase():o.database,schema:typeof t.schema=="string"?t.schema.toUpperCase():o.schema,warehouse:typeof t.warehouse=="string"?t.warehouse.toUpperCase():o.warehouse,role:typeof t.role=="string"?t.role.toUpperCase():o.role}}function bn(){return{sessionId:"ephemeral",token:"",masterToken:"",account:"TWIN",user:"SQLAPI",role:"PUBLIC",database:"",schema:"",warehouse:"",closed:!1,rev:0}}async function Nn(e,t,s){if(t==="/api/v2/statements"&&e.method==="POST")return On(e,s);let n=t.match(/^\/api\/v2\/statements\/([^/]+)\/cancel$/);if(n&&e.method==="POST")return kn(e,n[1]);let a=t.match(/^\/api\/v2\/statements\/([^/]+)$/);if(a&&e.method==="GET")return xn(e,a[1],s);if(t==="/api/v2/statements"||a||n)return{status:405,body:{code:p.UNSUPPORTED_FEATURE,message:`Method ${e.method} is not allowed on ${t}.`,sqlState:h.FEATURE_NOT_SUPPORTED}};throw Re(e.method,t)}async function On(e,t){lt(e);let s=Oe(e),n=typeof s.statement=="string"?s.statement:"";if(n.trim()==="")return{status:400,body:{code:p.SYNTAX,message:"The request body is missing a non-empty `statement`.",sqlState:h.SYNTAX_OR_ACCESS}};let a=t.searchParams.get("async")==="true",o=await yn(e,s),r=Gt(s.bindings),{query:i}=await ve(o,n,D(e),{...r?{bindings:r}:{},...a?{isAsync:!0}:{}});return a?{status:202,body:{code:p.ASYNC_ACCEPTED,message:"Asynchronous execution in progress. Use provided query id to perform query monitoring and management.",statementHandle:i.queryId,statementStatusUrl:`/api/v2/statements/${i.queryId}`,createdOn:Date.parse(i.startedAt)}}:{status:200,body:Zt(i)}}function Zt(e){return{resultSetMetaData:{numRows:e.rowset.length,format:"jsonv2",rowType:e.rowtype.map(Rn),partitionInfo:[{rowCount:e.rowset.length,uncompressedSize:In(e.rowset)}]},data:e.rowset,code:p.SUCCESS,statementStatusUrl:`/api/v2/statements/${e.queryId}`,sqlState:h.SUCCESS,statementHandle:e.queryId,message:"Statement executed successfully.",createdOn:Date.parse(e.startedAt)}}function In(e){return e.reduce((t,s)=>t+s.reduce((n,a)=>n+(a===null?0:a.length),0),0)}function Rn(e){return{name:e.name,database:"",schema:"",table:"",nullable:e.nullable,type:e.type,byteLength:e.length??null,length:e.length??null,scale:e.scale??null,precision:e.precision??null,collation:null}}function xn(e,t,s){lt(e);let n=fe(t,D(e));if(!n)return{status:404,body:{code:p.OBJECT_DOES_NOT_EXIST,message:`Statement handle '${t}' not found.`,sqlState:h.TABLE_NOT_FOUND,statementHandle:t}};let a=s.searchParams.get("partition");return a!==null&&a!=="0"?{status:422,body:{code:p.OBJECT_DOES_NOT_EXIST,message:`Partition ${a} does not exist for statement '${t}'. This twin serves a single partition.`,sqlState:h.TABLE_NOT_FOUND,statementHandle:t}}:n.status==="FAILED_WITH_ERROR"?{status:422,body:Kt(new m(n.errorCode,n.errorMessage,n.sqlState),t)}:n.status==="ABORTED"?{status:422,body:{code:"000604",message:"SQL execution canceled",sqlState:"57014",statementHandle:t,statementStatusUrl:`/api/v2/statements/${t}`}}:{status:200,body:Zt(n)}}async function kn(e,t){lt(e);let s=fe(t,D(e));return s?(await Fe(s,D(e)),{status:200,body:{code:"000604",message:"Statement canceled",sqlState:"57014",statementHandle:t,statementStatusUrl:`/api/v2/statements/${t}`}}):{status:404,body:{code:p.OBJECT_DOES_NOT_EXIST,message:`Statement handle '${t}' not found.`,sqlState:h.TABLE_NOT_FOUND,statementHandle:t}}}import{serveHttp as zn,statefulTwinManifest as _n}from"../../engine/v2/volter_world-core.mjs";import{worldNow as Cn}from"../../engine/v2/volter_world-core.mjs";function Jt(e={}){let t=e.now??Cn;return async function(n){let a=new URL(n.url);if(n.method==="GET"&&a.pathname.replace(/\/+$/,"")==="/twin")return Response.json(_n({vendor:"snowflake",twinOf:"Snowflake (the snowflake-sdk driver protocol and the SQL API v2)",stores:"databases, schemas, tables and their rows, views, warehouses, sessions and query results, over one deterministic SQL engine",identity:"The driver logs in at POST /session/v1/login-request with any non-empty account, user and password (authenticator SNOWFLAKE) and sends the session token it gets back; the SQL API v2 takes any Authorization: Bearer token."}));try{let o=await it({method:n.method,path:a.pathname+a.search,body:n.method==="GET"||n.method==="HEAD"?void 0:await n.text(),headers:Object.fromEntries(n.headers.entries()),...e.root!==void 0?{root:e.root}:{},...e.readOnly?{readOnly:!0}:{},occurredAt:t()});return Response.json(o.body,{status:o.status,headers:o.headers})}catch(o){let r=`[twin fault] the Snowflake twin failed to handle this request: ${o instanceof Error?o.message:String(o)}`;return a.pathname.startsWith("/api/v2/")?Response.json({code:"000000",message:r,sqlState:"58004"},{status:500}):Response.json({data:null,message:r,code:"000000",success:!1},{status:200})}}}import{assertBudgetGuardIntact as ra,confirmAction as ia,pendingActions as la,syncPull as ua}from"../../engine/v2/volter_world-core.mjs";import{declareRateBudget as Ln,rateBudgetPath as ea,rateBudgetWeight as ta,RateBudget as sa}from"../../engine/v2/volter_world-core.mjs";import{RateBudgetError as ss}from"../../engine/v2/volter_world-core.mjs";var Un="snowflake",es=6e4,ts=60,Dn=300,He={statement:5,other:2},ut={windowMs:es,ceiling:ts,defaultWeight:He.other,maxRetryAfterSeconds:Dn,rules:[{match:"^POST /queries/v1/query-request$",weight:He.statement},{match:"^POST /api/v2/statements$",weight:He.statement}],reason:`Snowflake publishes NO scalar rate limit for the surfaces this pack models. Fetched 2026-08-31: docs.snowflake.com/en/developer-guide/sql-api/reference documents HTTP 429 "Rate limit exceeded" as a possible status for /api/v2/statements but carries no number anywhere on the page; docs.snowflake.com/en/developer-guide/sql-api/index says nothing about rate limits, throttling or 429 at all; docs.snowflake.com/en/developer-guide/sql-api/limits 404s. The published per-minute figures belong to OTHER products and are deliberately not borrowed: the Cortex REST API's limits are per-model AND per-account (readable only by querying the CORTEX_REST_API_RATE_LIMIT_POLICIES account-usage view, so not a transcribable scalar), and Snowpipe Streaming's documented 10 RPS is a different ingestion plane. So \u2014 exactly as for figma/openai/sentry/mistral \u2014 this declaration is NOT a transcription of a vendor figure and must not be read as one: it reproduces the kernel fallback's austerity (60 units / 60s at defaultWeight 2 = 30 calls a minute) and prices the two statement-executing paths at 5 instead of 2, so it is strictly tighter than the fallback on those and identical everywhere else. The binding real-world cost here is warehouse CREDITS rather than a throttle, which is why the statement paths carry the premium. It bounds the 60s AVERAGE and does not pace; the vendor's first 429 / retry-after is converted into a hard stop as the backstop.`};Ln(Un,ut);export{Jt 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,8 @@
|
|
|
1
|
+
@agenttwin/twin-stigg
|
|
2
|
+
|
|
3
|
+
Contains @volter/twin-stigg 0.1.37 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.
|
|
8
|
+
The upstream package declares Apache-2.0 but ships no LICENSE file; LICENSE is the license's standard text.
|