void 0.1.6 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENT_PROMPT.md +15 -0
- package/README.md +62 -123
- package/dist/auth-BdsJ0Aff.d.mts +43 -0
- package/dist/auth-cmd-Dx8oPKZC.mjs +43 -0
- package/dist/auth-migrations-BAtAck2g.mjs +117 -0
- package/dist/better-auth-shared-C9_GHSkR.d.mts +71 -0
- package/dist/better-auth-shared-CdYmQGry.mjs +163 -0
- package/dist/cache-W82I8ihI.mjs +47 -0
- package/dist/cancel-deploy-BOBTqqh0.mjs +59 -0
- package/dist/cf-access-Dee5cXxL.mjs +22 -0
- package/dist/chunk-DJd-R1mw.mjs +34 -0
- package/dist/cli/cli.d.mts +1 -0
- package/dist/cli/cli.mjs +1807 -0
- package/dist/client-snXOjrp1.mjs +565 -0
- package/dist/collect-CjeZgz5D.mjs +55 -0
- package/dist/config-BIa9HwVX.mjs +573 -0
- package/dist/config-BzM9Dy7T.mjs +37 -0
- package/dist/config-CvHtTM0q.mjs +30 -0
- package/dist/create-project-BIA15W7z.mjs +90 -0
- package/dist/db-DsRoMcfN.mjs +895 -0
- package/dist/defer-DcxEsVH1.mjs +49 -0
- package/dist/delete-DAP6yDc7.mjs +64 -0
- package/dist/deploy-BPKblFx6.mjs +2424 -0
- package/dist/discover-B7FkXBLB.mjs +40 -0
- package/dist/dist-DUyXJLkq.mjs +2667 -0
- package/dist/dist-Dayj3gCK.mjs +1287 -0
- package/dist/domain-BGofcQ6I.mjs +79 -0
- package/dist/dotenv-DwO4ti0Z.mjs +173 -0
- package/dist/drizzle-NnudE_UN.mjs +232 -0
- package/dist/env-CyG3tvU0.mjs +301 -0
- package/dist/env-helpers-Dr9Y7RnE.d.mts +52 -0
- package/dist/env-raw-BDL4TvdN.mjs +32 -0
- package/dist/env-types-DknSA4SO.mjs +64 -0
- package/dist/env-validation-DJKjR_8q.mjs +163 -0
- package/dist/fetch-error-BQ8sZ5Nd.mjs +266 -0
- package/dist/fetch-error-CVZ5CGA-.d.mts +20 -0
- package/dist/gen-U0Ktr4Zd.mjs +761 -0
- package/dist/handler-B0ds0OHJ.d.mts +269 -0
- package/dist/head-P-egrtFE.d.mts +45 -0
- package/dist/headers-DCXc7mDs.mjs +279 -0
- package/dist/index.d.mts +32 -0
- package/dist/index.mjs +4695 -0
- package/dist/init-C7wS5iGP.mjs +2625 -0
- package/dist/link-p2R6NbgN.mjs +49 -0
- package/dist/list-Bfel-QLc.mjs +113 -0
- package/dist/log-DXdqnmhF.mjs +26 -0
- package/dist/login-CkcXUiIu.mjs +72 -0
- package/dist/logs-DmkrRvx6.mjs +98 -0
- package/dist/magic-string.es-D6g9UnIy.mjs +1011 -0
- package/dist/mcp-CaQzfeUi.mjs +373 -0
- package/dist/node-DDfXj10V.mjs +54 -0
- package/dist/output-BwlcIYSR.mjs +139 -0
- package/dist/pages/client.d.mts +198 -0
- package/dist/pages/client.mjs +980 -0
- package/dist/pages/head-client.d.mts +15 -0
- package/dist/pages/head-client.mjs +90 -0
- package/dist/pages/head.d.mts +2 -0
- package/dist/pages/head.mjs +112 -0
- package/dist/pages/index.d.mts +38 -0
- package/dist/pages/index.mjs +76 -0
- package/dist/pages/islands-plugin.d.mts +50 -0
- package/dist/pages/islands-plugin.mjs +195 -0
- package/dist/pages/prefetch.d.mts +31 -0
- package/dist/pages/prefetch.mjs +90 -0
- package/dist/pages/protocol.d.mts +3 -0
- package/dist/pages/protocol.mjs +193 -0
- package/dist/pages/serialize.d.mts +10 -0
- package/dist/pages/serialize.mjs +14 -0
- package/dist/pathe.M-eThtNZ-D-kmWkCS.mjs +150 -0
- package/dist/plugin-inference-oZ6Ybu2_.mjs +2447 -0
- package/dist/prepare-BAtWufvm.mjs +99 -0
- package/dist/preset-D4I73kT4.mjs +221 -0
- package/dist/project-TqORyHn8.mjs +72 -0
- package/dist/project-cmd-B7lQp3F3.mjs +67 -0
- package/dist/project-slug-CKam8lF9.mjs +11 -0
- package/dist/project-tsconfig-DfkESbDL.mjs +63 -0
- package/dist/protocol-BWzXs2A2.d.mts +34 -0
- package/dist/providers-B3aMxWzP.mjs +67 -0
- package/dist/resolve-project-Br5BR03U.mjs +29 -0
- package/dist/rollback-gyC59l7U.mjs +92 -0
- package/dist/route-types-DReF1gUY.mjs +255 -0
- package/dist/routes-stub.d.mts +55 -0
- package/dist/routes-stub.mjs +1 -0
- package/dist/runner-6Ep3fNQu.mjs +123 -0
- package/dist/runner-pg-D0wWHYnr.mjs +57 -0
- package/dist/runtime/ai.d.mts +127 -0
- package/dist/runtime/ai.mjs +348 -0
- package/dist/runtime/auth-client-react.d.mts +8 -0
- package/dist/runtime/auth-client-react.mjs +6 -0
- package/dist/runtime/auth-client-solid.d.mts +8 -0
- package/dist/runtime/auth-client-solid.mjs +6 -0
- package/dist/runtime/auth-client-svelte.d.mts +8 -0
- package/dist/runtime/auth-client-svelte.mjs +6 -0
- package/dist/runtime/auth-client-vue.d.mts +8 -0
- package/dist/runtime/auth-client-vue.mjs +6 -0
- package/dist/runtime/auth-client.d.mts +8 -0
- package/dist/runtime/auth-client.mjs +6 -0
- package/dist/runtime/auth.d.mts +2 -0
- package/dist/runtime/auth.mjs +22 -0
- package/dist/runtime/better-auth-pg.d.mts +11 -0
- package/dist/runtime/better-auth-pg.mjs +51 -0
- package/dist/runtime/better-auth.d.mts +11 -0
- package/dist/runtime/better-auth.mjs +33 -0
- package/dist/runtime/client.d.mts +6 -0
- package/dist/runtime/client.mjs +5 -0
- package/dist/runtime/db-pg.d.mts +2 -0
- package/dist/runtime/db-pg.mjs +1 -0
- package/dist/runtime/db.d.mts +17 -0
- package/dist/runtime/db.mjs +30 -0
- package/dist/runtime/drizzle-arktype.d.mts +1 -0
- package/dist/runtime/drizzle-arktype.mjs +2 -0
- package/dist/runtime/drizzle-valibot.d.mts +1 -0
- package/dist/runtime/drizzle-valibot.mjs +2 -0
- package/dist/runtime/drizzle-zod.d.mts +1 -0
- package/dist/runtime/drizzle-zod.mjs +2 -0
- package/dist/runtime/env-helpers.d.mts +2 -0
- package/dist/runtime/env-helpers.mjs +173 -0
- package/dist/runtime/env-public-client.d.mts +22 -0
- package/dist/runtime/env-public-client.mjs +54 -0
- package/dist/runtime/env-public.d.mts +143 -0
- package/dist/runtime/env-public.mjs +366 -0
- package/dist/runtime/env.d.mts +13 -0
- package/dist/runtime/env.mjs +51 -0
- package/dist/runtime/fetch-stream.d.mts +51 -0
- package/dist/runtime/fetch-stream.mjs +81 -0
- package/dist/runtime/fetch.d.mts +59 -0
- package/dist/runtime/fetch.mjs +18 -0
- package/dist/runtime/handler.d.mts +3 -0
- package/dist/runtime/handler.mjs +85 -0
- package/dist/runtime/isr.d.mts +26 -0
- package/dist/runtime/isr.mjs +43 -0
- package/dist/runtime/kv.d.mts +48 -0
- package/dist/runtime/kv.mjs +106 -0
- package/dist/runtime/log.d.mts +24 -0
- package/dist/runtime/log.mjs +31 -0
- package/dist/runtime/migration-handler-pg.d.mts +6 -0
- package/dist/runtime/migration-handler-pg.mjs +85 -0
- package/dist/runtime/migration-handler.d.mts +19 -0
- package/dist/runtime/migration-handler.mjs +92 -0
- package/dist/runtime/queues.d.mts +7 -0
- package/dist/runtime/queues.mjs +8 -0
- package/dist/runtime/remote/binding-handler.d.mts +15 -0
- package/dist/runtime/remote/binding-handler.mjs +208 -0
- package/dist/runtime/remote/index.d.mts +8 -0
- package/dist/runtime/remote/index.mjs +461 -0
- package/dist/runtime/response.d.mts +14 -0
- package/dist/runtime/response.mjs +30 -0
- package/dist/runtime/sandbox.d.mts +17 -0
- package/dist/runtime/sandbox.mjs +19 -0
- package/dist/runtime/schema-d1.d.mts +1 -0
- package/dist/runtime/schema-d1.mjs +2 -0
- package/dist/runtime/schema-pg.d.mts +1 -0
- package/dist/runtime/schema-pg.mjs +2 -0
- package/dist/runtime/seed.d.mts +30 -0
- package/dist/runtime/seed.mjs +6 -0
- package/dist/runtime/storage.d.mts +7 -0
- package/dist/runtime/storage.mjs +14 -0
- package/dist/runtime/validator.d.mts +2 -0
- package/dist/runtime/validator.mjs +72 -0
- package/dist/runtime/ws-server.d.mts +26 -0
- package/dist/runtime/ws-server.mjs +296 -0
- package/dist/runtime/ws.d.mts +123 -0
- package/dist/runtime/ws.mjs +103 -0
- package/dist/scan-Ba4hFwlH.mjs +324 -0
- package/dist/scan-C6HMEIdW.mjs +318 -0
- package/dist/secret-CeRSukgM.mjs +109 -0
- package/dist/skills-ipldjlKE.mjs +62 -0
- package/dist/standard-schema-9CRjx-uR.d.mts +42 -0
- package/dist/subcommand-prompt-BKjuNAPb.mjs +349 -0
- package/dist/sveltekit.d.mts +20 -0
- package/dist/sveltekit.mjs +61 -0
- package/dist/types-mHOEwpW4.d.mts +57 -0
- package/dist/validate-CaMavMxu.mjs +146 -0
- package/dist/yarn-pnp-BFqMV_bl.mjs +196 -0
- package/getting-started-prompt.txt +26 -0
- package/package.json +322 -30
- package/schema.json +364 -0
- package/skills/migrate-vite-cloudflare-to-void/SKILL.md +175 -0
- package/skills/void/SKILL.md +75 -0
- package/skills/void/command/void.md +7 -0
- package/skills/void/docs/guide/ai.md +235 -0
- package/skills/void/docs/guide/app-types.md +103 -0
- package/skills/void/docs/guide/auth.md +257 -0
- package/skills/void/docs/guide/database/d1.md +106 -0
- package/skills/void/docs/guide/database/postgresql.md +106 -0
- package/skills/void/docs/guide/database.md +418 -0
- package/skills/void/docs/guide/deployment.md +98 -0
- package/skills/void/docs/guide/edge/headers.md +79 -0
- package/skills/void/docs/guide/edge/prerendering.md +83 -0
- package/skills/void/docs/guide/edge/redirects.md +116 -0
- package/skills/void/docs/guide/edge/revalidation.md +131 -0
- package/skills/void/docs/guide/edge/rewrites.md +354 -0
- package/skills/void/docs/guide/edge/static-assets.md +72 -0
- package/skills/void/docs/guide/env-vars.md +298 -0
- package/skills/void/docs/guide/index.md +80 -0
- package/skills/void/docs/guide/jobs.md +91 -0
- package/skills/void/docs/guide/kv.md +107 -0
- package/skills/void/docs/guide/pages-routing/actions-and-forms.md +419 -0
- package/skills/void/docs/guide/pages-routing/head.md +130 -0
- package/skills/void/docs/guide/pages-routing/islands.md +405 -0
- package/skills/void/docs/guide/pages-routing/layouts.md +362 -0
- package/skills/void/docs/guide/pages-routing/loaders.md +267 -0
- package/skills/void/docs/guide/pages-routing/markdown.md +625 -0
- package/skills/void/docs/guide/pages-routing/overview.md +236 -0
- package/skills/void/docs/guide/pages-routing/view-transitions.md +140 -0
- package/skills/void/docs/guide/queues.md +140 -0
- package/skills/void/docs/guide/quickstart.md +233 -0
- package/skills/void/docs/guide/remote-dev.md +67 -0
- package/skills/void/docs/guide/sandboxes.md +82 -0
- package/skills/void/docs/guide/server-routing.md +246 -0
- package/skills/void/docs/guide/ssg.md +74 -0
- package/skills/void/docs/guide/ssr.md +105 -0
- package/skills/void/docs/guide/storage.md +67 -0
- package/skills/void/docs/guide/type-safety.md +179 -0
- package/skills/void/docs/guide/typed-fetch.md +113 -0
- package/skills/void/docs/guide/websockets.md +190 -0
- package/skills/void/docs/index.md +48 -0
- package/skills/void/docs/integrations/agents.md +84 -0
- package/skills/void/docs/integrations/cloudflare.md +284 -0
- package/skills/void/docs/integrations/frameworks/analog.md +182 -0
- package/skills/void/docs/integrations/frameworks/astro.md +197 -0
- package/skills/void/docs/integrations/frameworks/nuxt.md +164 -0
- package/skills/void/docs/integrations/frameworks/overview.md +136 -0
- package/skills/void/docs/integrations/frameworks/react-router.md +137 -0
- package/skills/void/docs/integrations/frameworks/sveltekit.md +191 -0
- package/skills/void/docs/integrations/frameworks/tanstack-start.md +140 -0
- package/skills/void/docs/integrations/hono.md +97 -0
- package/skills/void/docs/integrations/nodejs-bun-deno.md +210 -0
- package/skills/void/docs/node_modules/@iconify/vue/README.md +408 -0
- package/skills/void/docs/node_modules/@iconify/vue/offline/readme.md +5 -0
- package/skills/void/docs/node_modules/@voidzero-dev/vitepress-theme/README.md +103 -0
- package/skills/void/docs/node_modules/oxc-minify/README.md +78 -0
- package/skills/void/docs/node_modules/reka-ui/README.md +80 -0
- package/skills/void/docs/node_modules/vitepress/README.md +28 -0
- package/skills/void/docs/node_modules/vitepress/template/api-examples.md +49 -0
- package/skills/void/docs/node_modules/vitepress/template/index.md +28 -0
- package/skills/void/docs/node_modules/vitepress/template/markdown-examples.md +85 -0
- package/skills/void/docs/node_modules/vitepress-plugin-group-icons/README.md +101 -0
- package/skills/void/docs/node_modules/void/AGENTS.md +204 -0
- package/skills/void/docs/node_modules/void/AGENT_PROMPT.md +15 -0
- package/skills/void/docs/node_modules/void/README.md +89 -0
- package/skills/void/docs/node_modules/void/node_modules/@clack/prompts/CHANGELOG.md +591 -0
- package/skills/void/docs/node_modules/void/node_modules/@clack/prompts/README.md +375 -0
- package/skills/void/docs/node_modules/void/node_modules/@cloudflare/sandbox/README.md +174 -0
- package/skills/void/docs/node_modules/void/node_modules/@cloudflare/vite-plugin/README.md +37 -0
- package/skills/void/docs/node_modules/void/node_modules/@cloudflare/workers-types/README.md +135 -0
- package/skills/void/docs/node_modules/void/node_modules/@electric-sql/pglite/README.md +189 -0
- package/skills/void/docs/node_modules/void/node_modules/@hono/oauth-providers/CHANGELOG.md +143 -0
- package/skills/void/docs/node_modules/void/node_modules/@hono/oauth-providers/README.md +1272 -0
- package/skills/void/docs/node_modules/void/node_modules/@napi-rs/keyring/README.md +19 -0
- package/skills/void/docs/node_modules/void/node_modules/@types/better-sqlite3/README.md +15 -0
- package/skills/void/docs/node_modules/void/node_modules/@types/node/README.md +15 -0
- package/skills/void/docs/node_modules/void/node_modules/@types/pg/README.md +15 -0
- package/skills/void/docs/node_modules/void/node_modules/@typescript/native-preview/README.md +22 -0
- package/skills/void/docs/node_modules/void/node_modules/@typescript/native-preview/vendor/vscode-jsonrpc/README.md +69 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/README.md +152 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/@shikijs/engine-javascript/README.md +9 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/@shikijs/transformers/README.md +9 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/@types/node/README.md +15 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/gray-matter/CHANGELOG.md +24 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/gray-matter/README.md +565 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-exit/README.md +124 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-it-anchor/README.md +600 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-it-attrs/README.md +386 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-it-container/README.md +95 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-it-emoji/README.md +101 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/pathe/README.md +73 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/shiki/README.md +15 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/tinyglobby/README.md +25 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/tsdown/README.md +55 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite/LICENSE.md +2230 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite/README.md +20 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vue/README.md +58 -0
- package/skills/void/docs/node_modules/void/node_modules/arktype/README.md +165 -0
- package/skills/void/docs/node_modules/void/node_modules/better-auth/LICENSE.md +20 -0
- package/skills/void/docs/node_modules/void/node_modules/better-auth/README.md +32 -0
- package/skills/void/docs/node_modules/void/node_modules/better-sqlite3/README.md +99 -0
- package/skills/void/docs/node_modules/void/node_modules/blake3-jit/README.md +108 -0
- package/skills/void/docs/node_modules/void/node_modules/drizzle-arktype/README.md +51 -0
- package/skills/void/docs/node_modules/void/node_modules/drizzle-kit/README.md +79 -0
- package/skills/void/docs/node_modules/void/node_modules/drizzle-orm/README.md +44 -0
- package/skills/void/docs/node_modules/void/node_modules/drizzle-valibot/README.md +51 -0
- package/skills/void/docs/node_modules/void/node_modules/drizzle-zod/README.md +65 -0
- package/skills/void/docs/node_modules/void/node_modules/es-module-lexer/README.md +390 -0
- package/skills/void/docs/node_modules/void/node_modules/estree-walker/README.md +48 -0
- package/skills/void/docs/node_modules/void/node_modules/hono/README.md +85 -0
- package/skills/void/docs/node_modules/void/node_modules/ignore/README.md +452 -0
- package/skills/void/docs/node_modules/void/node_modules/jsonc-parser/CHANGELOG.md +76 -0
- package/{LICENSE → skills/void/docs/node_modules/void/node_modules/jsonc-parser/LICENSE.md} +21 -21
- package/skills/void/docs/node_modules/void/node_modules/jsonc-parser/README.md +364 -0
- package/skills/void/docs/node_modules/void/node_modules/jsonc-parser/SECURITY.md +41 -0
- package/skills/void/docs/node_modules/void/node_modules/magic-string/README.md +325 -0
- package/skills/void/docs/node_modules/void/node_modules/ofetch/README.md +398 -0
- package/skills/void/docs/node_modules/void/node_modules/pathe/README.md +73 -0
- package/skills/void/docs/node_modules/void/node_modules/pg/README.md +95 -0
- package/skills/void/docs/node_modules/void/node_modules/pglite-server/LICENSE.md +21 -0
- package/skills/void/docs/node_modules/void/node_modules/pglite-server/README.md +135 -0
- package/skills/void/docs/node_modules/void/node_modules/picocolors/README.md +21 -0
- package/skills/void/docs/node_modules/void/node_modules/tinyglobby/README.md +25 -0
- package/skills/void/docs/node_modules/void/node_modules/tsdown/README.md +55 -0
- package/skills/void/docs/node_modules/void/node_modules/valibot/LICENSE.md +9 -0
- package/skills/void/docs/node_modules/void/node_modules/valibot/README.md +94 -0
- package/skills/void/docs/node_modules/void/node_modules/vite/LICENSE.md +2230 -0
- package/skills/void/docs/node_modules/void/node_modules/vite/README.md +20 -0
- package/skills/void/docs/node_modules/void/node_modules/wrangler/README.md +63 -0
- package/skills/void/docs/node_modules/void/node_modules/zod/README.md +191 -0
- package/skills/void/docs/node_modules/void/skills/migrate-vite-cloudflare-to-void/SKILL.md +175 -0
- package/skills/void/docs/node_modules/void/skills/void/SKILL.md +75 -0
- package/skills/void/docs/node_modules/void/skills/void/command/void.md +7 -0
- package/skills/void/docs/reference/api.md +917 -0
- package/skills/void/docs/reference/cli.md +561 -0
- package/skills/void/docs/reference/config.md +408 -0
- package/skills/void/docs/reference/resource-inference.md +149 -0
- package/skills/void/docs/reference/structure.md +176 -0
- package/.npmignore +0 -29
- package/.travis.yml +0 -9
- package/favicon.ico +0 -0
- package/index.js +0 -14
- package/lib/Job.js +0 -150
- package/lib/Void.js +0 -99
- package/lib/scan.js +0 -19
- package/test/credentials.js +0 -20
- package/test/job.js +0 -64
- package/test/static/dir1/test6.html +0 -0
- package/test/static/dir2/test7.html +0 -0
- package/test/static/dir2/test8.html +0 -0
- package/test/static/dir2/test9.html +0 -0
- package/test/static/test1.html +0 -0
- package/test/static/test2.html +0 -0
- package/test/static/test3.html +0 -0
- package/test/void.js +0 -31
- /package/{test/static/dir1/test4.html → skills/void/docs/integrations/auth-providers.md} +0 -0
- /package/{test/static/dir1/test5.html → skills/void/docs/integrations/payment-processors.md} +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { n as applySqliteAuthMigrations } from "../auth-migrations-BAtAck2g.mjs";
|
|
2
|
+
import { t as createVoidAuthRuntime } from "../better-auth-shared-CdYmQGry.mjs";
|
|
3
|
+
//#region src/runtime/better-auth.ts
|
|
4
|
+
async function resolveDatabase(env) {
|
|
5
|
+
if (!env.DB) throw new Error("auth: Better Auth requires the \"DB\" D1 binding for sqlite apps.");
|
|
6
|
+
return {
|
|
7
|
+
database: env.DB,
|
|
8
|
+
async dispose() {}
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
async function runSqliteAuthMigrations(_request, env, runtime, migrationSchema) {
|
|
12
|
+
if (!migrationSchema) throw new Error("auth: Migration schema is unavailable.");
|
|
13
|
+
if (runtime.dialect !== "sqlite") throw new Error(`auth: Runtime mismatch. Expected sqlite, received '${runtime.dialect}'.`);
|
|
14
|
+
if (migrationSchema.dialect !== "sqlite") throw new Error(`auth: Runtime mismatch. Expected sqlite, received '${migrationSchema.dialect}'.`);
|
|
15
|
+
if (!env.DB) throw new Error("auth: Better Auth requires the \"DB\" D1 binding for sqlite apps.");
|
|
16
|
+
await applySqliteAuthMigrations({
|
|
17
|
+
async all(sql) {
|
|
18
|
+
return (await env.DB.prepare(sql).all()).results ?? [];
|
|
19
|
+
},
|
|
20
|
+
async run(sql) {
|
|
21
|
+
await env.DB.prepare(sql).run();
|
|
22
|
+
}
|
|
23
|
+
}, migrationSchema);
|
|
24
|
+
}
|
|
25
|
+
const runtime = createVoidAuthRuntime("sqlite", resolveDatabase, runSqliteAuthMigrations);
|
|
26
|
+
const resolveVoidAuthOptions = runtime.resolveVoidAuthOptions;
|
|
27
|
+
const createVoidAuth = runtime.createVoidAuth;
|
|
28
|
+
const resolveVoidAuthState = runtime.resolveVoidAuthState;
|
|
29
|
+
const runVoidAuthMiddleware = runtime.runVoidAuthMiddleware;
|
|
30
|
+
const handleVoidAuthRequest = runtime.handleVoidAuthRequest;
|
|
31
|
+
const runVoidAuthMigrations = runtime.runVoidAuthMigrations;
|
|
32
|
+
//#endregion
|
|
33
|
+
export { createVoidAuth, handleVoidAuthRequest, resolveVoidAuthOptions, resolveVoidAuthState, runVoidAuthMiddleware, runVoidAuthMigrations };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { n as AuthState, r as AuthUser, t as AuthSession } from "../auth-BdsJ0Aff.mjs";
|
|
2
|
+
import { auth, createAuthClient } from "./auth-client.mjs";
|
|
3
|
+
import { t as FetchError } from "../fetch-error-CVZ5CGA-.mjs";
|
|
4
|
+
import { fetch } from "./fetch.mjs";
|
|
5
|
+
import { fetchStream } from "./fetch-stream.mjs";
|
|
6
|
+
export { type AuthSession, type AuthState, type AuthUser, FetchError, FetchError as StreamError, auth, createAuthClient, fetch, fetchStream };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { t as FetchError } from "../fetch-error-BQ8sZ5Nd.mjs";
|
|
2
|
+
import { fetch } from "./fetch.mjs";
|
|
3
|
+
import { fetchStream } from "./fetch-stream.mjs";
|
|
4
|
+
import { auth, createAuthClient } from "./auth-client.mjs";
|
|
5
|
+
export { FetchError, FetchError as StreamError, auth, createAuthClient, fetch, fetchStream };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DrizzleD1Database, DrizzleD1Database as DrizzleD1Database$1 } from "drizzle-orm/d1";
|
|
2
|
+
import { and, asc, avg, between, count, desc, eq, exists, gt, gte, ilike, inArray, isNotNull, isNull, like, lt, lte, max, min, ne, not, notBetween, notExists, notInArray, notLike, or, sql, sum } from "drizzle-orm";
|
|
3
|
+
|
|
4
|
+
//#region src/runtime/db.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Create a Drizzle D1 instance from a custom D1 binding.
|
|
7
|
+
* Use this when you have multiple D1 databases or need a non-default binding.
|
|
8
|
+
*/
|
|
9
|
+
declare function createDb(d1: D1Database): DrizzleD1Database$1;
|
|
10
|
+
/**
|
|
11
|
+
* Default Drizzle D1 instance — resolves the `DB` binding from the runtime
|
|
12
|
+
* environment. When the Void plugin is active, this is replaced with a
|
|
13
|
+
* schema-aware instance via virtual module.
|
|
14
|
+
*/
|
|
15
|
+
declare const db: DrizzleD1Database$1;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { type DrizzleD1Database, and, asc, avg, between, count, createDb, db, desc, eq, exists, gt, gte, ilike, inArray, isNotNull, isNull, like, lt, lte, max, min, ne, not, notBetween, notExists, notInArray, notLike, or, sql, sum };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { requireRuntimeBinding } from "./env.mjs";
|
|
2
|
+
import { drizzle } from "drizzle-orm/d1";
|
|
3
|
+
import { and, asc, avg, between, count, desc, eq, exists, gt, gte, ilike, inArray, isNotNull, isNull, like, lt, lte, max, min, ne, not, notBetween, notExists, notInArray, notLike, or, sql, sum } from "drizzle-orm";
|
|
4
|
+
//#region src/runtime/db.ts
|
|
5
|
+
/**
|
|
6
|
+
* void/db — Drizzle-powered database access.
|
|
7
|
+
*
|
|
8
|
+
* At build time, the Void plugin intercepts this import and serves a
|
|
9
|
+
* virtual module that auto-wires the D1 binding with the user's schema.
|
|
10
|
+
* This stub exists for the published npm package and type declarations.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Create a Drizzle D1 instance from a custom D1 binding.
|
|
14
|
+
* Use this when you have multiple D1 databases or need a non-default binding.
|
|
15
|
+
*/
|
|
16
|
+
function createDb(d1) {
|
|
17
|
+
return drizzle(d1);
|
|
18
|
+
}
|
|
19
|
+
let _instance;
|
|
20
|
+
/**
|
|
21
|
+
* Default Drizzle D1 instance — resolves the `DB` binding from the runtime
|
|
22
|
+
* environment. When the Void plugin is active, this is replaced with a
|
|
23
|
+
* schema-aware instance via virtual module.
|
|
24
|
+
*/
|
|
25
|
+
const db = new Proxy({}, { get(_, prop) {
|
|
26
|
+
_instance ??= drizzle(requireRuntimeBinding("DB"));
|
|
27
|
+
return Reflect.get(_instance, prop);
|
|
28
|
+
} });
|
|
29
|
+
//#endregion
|
|
30
|
+
export { and, asc, avg, between, count, createDb, db, desc, eq, exists, gt, gte, ilike, inArray, isNotNull, isNull, like, lt, lte, max, min, ne, not, notBetween, notExists, notInArray, notLike, or, sql, sum };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "drizzle-arktype";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "drizzle-valibot";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "drizzle-zod";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as getSecretOverride, c as oneOf, i as email, l as string, n as SECRET_OVERRIDE_SYMBOL, o as json, r as boolean, s as number, t as EnvSchema, u as url } from "../env-helpers-Dr9Y7RnE.mjs";
|
|
2
|
+
export { EnvSchema, SECRET_OVERRIDE_SYMBOL, boolean, email, getSecretOverride, json, number, oneOf, string, url };
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
//#region src/runtime/env-helpers.ts
|
|
2
|
+
/**
|
|
3
|
+
* Marker property read by the mask helpers. Present only on built-in
|
|
4
|
+
* schema builders; third-party Standard Schema validators fall back to the
|
|
5
|
+
* name/value heuristic (documented in `docs/guide/env-vars.md`).
|
|
6
|
+
*/
|
|
7
|
+
const SECRET_OVERRIDE_SYMBOL = Symbol.for("void.env.secretOverride");
|
|
8
|
+
/**
|
|
9
|
+
* Pull the explicit `.secret()` / `.public()` flag off a Standard Schema
|
|
10
|
+
* validator, if it was authored through our built-in helpers. Returns
|
|
11
|
+
* `undefined` for third-party validators (valibot, zod, arktype, …) —
|
|
12
|
+
* they are redacted purely via the heuristic.
|
|
13
|
+
*/
|
|
14
|
+
function getSecretOverride(validator) {
|
|
15
|
+
if (!validator || typeof validator !== "object") return;
|
|
16
|
+
return validator[SECRET_OVERRIDE_SYMBOL];
|
|
17
|
+
}
|
|
18
|
+
function build(parse, state) {
|
|
19
|
+
const schema = {
|
|
20
|
+
"~standard": {
|
|
21
|
+
version: 1,
|
|
22
|
+
vendor: "void",
|
|
23
|
+
validate(value) {
|
|
24
|
+
if (value === void 0 || value === null || value === "") {
|
|
25
|
+
if (state.defaultValue !== void 0) return { value: state.defaultValue };
|
|
26
|
+
if (state.optional) return { value: void 0 };
|
|
27
|
+
return { issues: [{ message: "Required" }] };
|
|
28
|
+
}
|
|
29
|
+
const result = parse(typeof value === "string" ? value : String(value));
|
|
30
|
+
if (result.ok) return { value: result.value };
|
|
31
|
+
return { issues: [{ message: result.message }] };
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
optional() {
|
|
35
|
+
return build(parse, {
|
|
36
|
+
optional: true,
|
|
37
|
+
defaultValue: state.defaultValue,
|
|
38
|
+
secretOverride: state.secretOverride
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
default(value) {
|
|
42
|
+
return build(parse, {
|
|
43
|
+
optional: false,
|
|
44
|
+
defaultValue: value,
|
|
45
|
+
secretOverride: state.secretOverride
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
secret() {
|
|
49
|
+
return build(parse, {
|
|
50
|
+
...state,
|
|
51
|
+
secretOverride: "secret"
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
public() {
|
|
55
|
+
return build(parse, {
|
|
56
|
+
...state,
|
|
57
|
+
secretOverride: "public"
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
Object.defineProperty(schema, SECRET_OVERRIDE_SYMBOL, {
|
|
62
|
+
value: state.secretOverride,
|
|
63
|
+
enumerable: false,
|
|
64
|
+
configurable: true
|
|
65
|
+
});
|
|
66
|
+
return schema;
|
|
67
|
+
}
|
|
68
|
+
const empty = () => ({
|
|
69
|
+
optional: false,
|
|
70
|
+
defaultValue: void 0,
|
|
71
|
+
secretOverride: void 0
|
|
72
|
+
});
|
|
73
|
+
/** Required string env value. */
|
|
74
|
+
function string() {
|
|
75
|
+
return build((raw) => ({
|
|
76
|
+
ok: true,
|
|
77
|
+
value: raw
|
|
78
|
+
}), empty());
|
|
79
|
+
}
|
|
80
|
+
/** Numeric env value. Parses with `Number(raw)`; rejects NaN. */
|
|
81
|
+
function number() {
|
|
82
|
+
return build((raw) => {
|
|
83
|
+
const n = Number(raw);
|
|
84
|
+
if (Number.isNaN(n)) return {
|
|
85
|
+
ok: false,
|
|
86
|
+
message: `Expected a number, got "${raw}"`
|
|
87
|
+
};
|
|
88
|
+
return {
|
|
89
|
+
ok: true,
|
|
90
|
+
value: n
|
|
91
|
+
};
|
|
92
|
+
}, empty());
|
|
93
|
+
}
|
|
94
|
+
/** Boolean env value. Accepts "true"/"false"/"1"/"0" (case-insensitive). */
|
|
95
|
+
function boolean() {
|
|
96
|
+
return build((raw) => {
|
|
97
|
+
const lc = raw.toLowerCase();
|
|
98
|
+
if (lc === "true" || lc === "1") return {
|
|
99
|
+
ok: true,
|
|
100
|
+
value: true
|
|
101
|
+
};
|
|
102
|
+
if (lc === "false" || lc === "0") return {
|
|
103
|
+
ok: true,
|
|
104
|
+
value: false
|
|
105
|
+
};
|
|
106
|
+
return {
|
|
107
|
+
ok: false,
|
|
108
|
+
message: `Expected boolean (true/false/1/0), got "${raw}"`
|
|
109
|
+
};
|
|
110
|
+
}, empty());
|
|
111
|
+
}
|
|
112
|
+
/** URL string — validated via `new URL(raw)`. */
|
|
113
|
+
function url() {
|
|
114
|
+
return build((raw) => {
|
|
115
|
+
try {
|
|
116
|
+
new URL(raw);
|
|
117
|
+
return {
|
|
118
|
+
ok: true,
|
|
119
|
+
value: raw
|
|
120
|
+
};
|
|
121
|
+
} catch {
|
|
122
|
+
return {
|
|
123
|
+
ok: false,
|
|
124
|
+
message: `Expected a valid URL, got "${raw}"`
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
}, empty());
|
|
128
|
+
}
|
|
129
|
+
const EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
130
|
+
/** Email string — basic shape validation. */
|
|
131
|
+
function email() {
|
|
132
|
+
return build((raw) => {
|
|
133
|
+
if (!EMAIL_RE.test(raw)) return {
|
|
134
|
+
ok: false,
|
|
135
|
+
message: `Expected a valid email, got "${raw}"`
|
|
136
|
+
};
|
|
137
|
+
return {
|
|
138
|
+
ok: true,
|
|
139
|
+
value: raw
|
|
140
|
+
};
|
|
141
|
+
}, empty());
|
|
142
|
+
}
|
|
143
|
+
/** One of a fixed set of literal string values. */
|
|
144
|
+
function oneOf(values) {
|
|
145
|
+
return build((raw) => {
|
|
146
|
+
if (values.includes(raw)) return {
|
|
147
|
+
ok: true,
|
|
148
|
+
value: raw
|
|
149
|
+
};
|
|
150
|
+
return {
|
|
151
|
+
ok: false,
|
|
152
|
+
message: `Expected one of ${values.join(", ")}, got "${raw}"`
|
|
153
|
+
};
|
|
154
|
+
}, empty());
|
|
155
|
+
}
|
|
156
|
+
/** JSON-parsed env value. Specify `T` to type the parsed result. */
|
|
157
|
+
function json() {
|
|
158
|
+
return build((raw) => {
|
|
159
|
+
try {
|
|
160
|
+
return {
|
|
161
|
+
ok: true,
|
|
162
|
+
value: JSON.parse(raw)
|
|
163
|
+
};
|
|
164
|
+
} catch (e) {
|
|
165
|
+
return {
|
|
166
|
+
ok: false,
|
|
167
|
+
message: `Invalid JSON: ${e.message}`
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
}, empty());
|
|
171
|
+
}
|
|
172
|
+
//#endregion
|
|
173
|
+
export { SECRET_OVERRIDE_SYMBOL, boolean, email, getSecretOverride, json, number, oneOf, string, url };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { c as oneOf, i as email, l as string, o as json, r as boolean, s as number, t as EnvSchema, u as url } from "../env-helpers-Dr9Y7RnE.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/runtime/env-public-client.d.ts
|
|
4
|
+
declare const env: Record<string, unknown>;
|
|
5
|
+
/**
|
|
6
|
+
* In client builds `defineEnv` is a no-op identity function — schema
|
|
7
|
+
* registration only happens server-side. We still return the `env` proxy so
|
|
8
|
+
* t3-style `export const env = defineEnv({...})` keeps working in shared
|
|
9
|
+
* modules.
|
|
10
|
+
*/
|
|
11
|
+
declare function defineEnv<S>(_schema: S): typeof env;
|
|
12
|
+
declare class EnvValidationError extends Error {
|
|
13
|
+
readonly key: string;
|
|
14
|
+
readonly issues: ReadonlyArray<{
|
|
15
|
+
message: string;
|
|
16
|
+
}>;
|
|
17
|
+
constructor(key: string, issues: ReadonlyArray<{
|
|
18
|
+
message: string;
|
|
19
|
+
}>);
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { type EnvSchema, EnvValidationError, boolean, defineEnv, email, env, json, number, oneOf, string, url };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { boolean, email, json, number, oneOf, string, url } from "./env-helpers.mjs";
|
|
2
|
+
//#region src/runtime/env-public-client.ts
|
|
3
|
+
function getClientEnv() {
|
|
4
|
+
return import.meta.env;
|
|
5
|
+
}
|
|
6
|
+
function readClientKey(key) {
|
|
7
|
+
const meta = getClientEnv();
|
|
8
|
+
if (meta && key in meta) return meta[key];
|
|
9
|
+
throw new Error(`env: Key '${key}' is not exposed to the client. Vite only injects keys matching the configured envPrefix (default: VITE_*). Either rename the key in env.ts to match envPrefix, or move this access to a server module.`);
|
|
10
|
+
}
|
|
11
|
+
const env = new Proxy({}, {
|
|
12
|
+
get(_target, key) {
|
|
13
|
+
if (typeof key === "symbol") return;
|
|
14
|
+
return readClientKey(String(key));
|
|
15
|
+
},
|
|
16
|
+
has(_target, key) {
|
|
17
|
+
if (typeof key !== "string") return false;
|
|
18
|
+
const meta = getClientEnv();
|
|
19
|
+
return meta ? key in meta : false;
|
|
20
|
+
},
|
|
21
|
+
ownKeys() {
|
|
22
|
+
const meta = getClientEnv();
|
|
23
|
+
return meta ? Object.keys(meta) : [];
|
|
24
|
+
},
|
|
25
|
+
getOwnPropertyDescriptor(_target, key) {
|
|
26
|
+
if (typeof key !== "string") return;
|
|
27
|
+
const meta = getClientEnv();
|
|
28
|
+
if (!meta || !(key in meta)) return;
|
|
29
|
+
return {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
configurable: true,
|
|
32
|
+
value: meta[key]
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
/**
|
|
37
|
+
* In client builds `defineEnv` is a no-op identity function — schema
|
|
38
|
+
* registration only happens server-side. We still return the `env` proxy so
|
|
39
|
+
* t3-style `export const env = defineEnv({...})` keeps working in shared
|
|
40
|
+
* modules.
|
|
41
|
+
*/
|
|
42
|
+
function defineEnv(_schema) {
|
|
43
|
+
return env;
|
|
44
|
+
}
|
|
45
|
+
var EnvValidationError = class extends Error {
|
|
46
|
+
constructor(key, issues) {
|
|
47
|
+
super(`Invalid env "${key}": ${issues.map((i) => i.message).join(", ")}`);
|
|
48
|
+
this.key = key;
|
|
49
|
+
this.issues = issues;
|
|
50
|
+
this.name = "EnvValidationError";
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
//#endregion
|
|
54
|
+
export { EnvValidationError, boolean, defineEnv, email, env, json, number, oneOf, string, url };
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/// <reference types="@cloudflare/workers-types" />
|
|
2
|
+
import { t as StandardSchemaV1 } from "../standard-schema-9CRjx-uR.mjs";
|
|
3
|
+
import { c as oneOf, i as email, l as string, o as json, r as boolean, s as number, t as EnvSchema, u as url } from "../env-helpers-Dr9Y7RnE.mjs";
|
|
4
|
+
import * as _$_cloudflare_sandbox0 from "@cloudflare/sandbox";
|
|
5
|
+
|
|
6
|
+
//#region src/runtime/env-public.d.ts
|
|
7
|
+
interface AnyValidator extends StandardSchemaV1<unknown, unknown> {}
|
|
8
|
+
type AnySchema = Record<string, AnyValidator>;
|
|
9
|
+
/**
|
|
10
|
+
* Type-only stub for the validated env shape. Augmented by the generated
|
|
11
|
+
* `.void/env.d.ts` so `env.X` is typed per the user's schema. Includes an
|
|
12
|
+
* index signature so untyped property access returns `unknown` (rather than
|
|
13
|
+
* a hard error) for bindings and keys not declared in the schema.
|
|
14
|
+
*/
|
|
15
|
+
interface ValidatedEnv {
|
|
16
|
+
readonly [key: string]: unknown;
|
|
17
|
+
}
|
|
18
|
+
type InferEnv<S extends AnySchema> = { readonly [K in keyof S]: StandardSchemaV1.InferOutput<S[K]> };
|
|
19
|
+
/**
|
|
20
|
+
* Register an env schema and return the typed `env` proxy.
|
|
21
|
+
*
|
|
22
|
+
* Calling `defineEnv` is the only required step — Void auto-discovers
|
|
23
|
+
* `env.ts` at project root, imports it, and uses the schema for runtime
|
|
24
|
+
* validation, type generation, and deploy-time secret checks.
|
|
25
|
+
*
|
|
26
|
+
* The return value is identical to the `env` export from `void/env`.
|
|
27
|
+
* Re-export it from your `env.ts` if you prefer the explicit
|
|
28
|
+
* `import { env } from "~/env"` pattern.
|
|
29
|
+
*/
|
|
30
|
+
declare function defineEnv<S extends AnySchema>(schema: S): InferEnv<S>;
|
|
31
|
+
/**
|
|
32
|
+
* Internal: validate the entire schema against the worker's actual env on
|
|
33
|
+
* the first request per isolate. Catches bad remote-secret values and
|
|
34
|
+
* post-deploy drift that the deploy CLI can't see (it only knows secret
|
|
35
|
+
* names, not their values).
|
|
36
|
+
*
|
|
37
|
+
* Spliced into the generated worker entry by `compileWorkerEntry`. Cached
|
|
38
|
+
* after the first call so subsequent requests pay no cost.
|
|
39
|
+
*
|
|
40
|
+
* Async lifecycle: this function awaits any async Standard Schema
|
|
41
|
+
* validators (zod `refine`, arktype async narrows, etc.) and seeds the
|
|
42
|
+
* per-key cache with the resolved values. Subsequent reads via `env.X`
|
|
43
|
+
* hit the sync cache — async work only happens here, at boot. If a user
|
|
44
|
+
* accesses `env.X` for a key with an async validator *before* this
|
|
45
|
+
* function has run (e.g. during module-top-level code), the proxy will
|
|
46
|
+
* throw with guidance pointing back to this boot-time pre-validation.
|
|
47
|
+
*/
|
|
48
|
+
declare function _validateEnvOnce(envValues: unknown): Promise<void>;
|
|
49
|
+
/** Internal: framework-only access to the registered schema (for plugin/CLI). */
|
|
50
|
+
declare function _getRegisteredSchema(): AnySchema | null;
|
|
51
|
+
/**
|
|
52
|
+
* Internal: returns `true` once `defineEnv()` has been called at least once,
|
|
53
|
+
* regardless of whether the caller passed an empty schema. Gives tooling a
|
|
54
|
+
* reliable signal — `_getRegisteredSchema()` alone can't distinguish
|
|
55
|
+
* `defineEnv({})` (an intentional empty schema) from "never called".
|
|
56
|
+
*/
|
|
57
|
+
declare function _hasRegisteredSchema(): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Internal: extract `.default(value)` values from the registered schema as
|
|
60
|
+
* stringified env values. Used by the plugin and deploy CLI to seed worker
|
|
61
|
+
* `vars` so `c.env.X` and `process.env.X` see the same fallback that the
|
|
62
|
+
* typed `env.X` proxy returns.
|
|
63
|
+
*
|
|
64
|
+
* Detection is schema-agnostic: probe each validator with `undefined` and,
|
|
65
|
+
* if it succeeds with a non-undefined value, that value is the default.
|
|
66
|
+
* Works for our built-in `.default(...)` helpers and for any Standard
|
|
67
|
+
* Schema validator with intrinsic default behaviour. Async validators are
|
|
68
|
+
* skipped (we can't get a sync default).
|
|
69
|
+
*
|
|
70
|
+
* Keys with no default — required keys, plain `.optional()` — are omitted
|
|
71
|
+
* from the result so they don't shadow user `.env*` entries with empty
|
|
72
|
+
* strings.
|
|
73
|
+
*/
|
|
74
|
+
declare function _getSchemaDefaults(): Record<string, string>;
|
|
75
|
+
declare class EnvValidationError extends Error {
|
|
76
|
+
readonly key: string;
|
|
77
|
+
readonly issues: ReadonlyArray<StandardSchemaV1.Issue>;
|
|
78
|
+
constructor(key: string, issues: ReadonlyArray<StandardSchemaV1.Issue>);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Typed env proxy. Reads from the runtime env, validating declared keys
|
|
82
|
+
* on first access and passing through bindings / unknown keys unchanged.
|
|
83
|
+
*
|
|
84
|
+
* Sync-only: the `get` trap must be synchronous, so validators that return
|
|
85
|
+
* a `Promise` cannot be awaited here. For async Standard Schema validators,
|
|
86
|
+
* `_validateEnvOnce()` pre-resolves them at worker boot and seeds the
|
|
87
|
+
* per-env cache; property reads then serve the cached value synchronously.
|
|
88
|
+
* If an async validator is encountered here without a prior pre-validation,
|
|
89
|
+
* the trap throws with guidance on how to resolve it.
|
|
90
|
+
*/
|
|
91
|
+
declare const env: ValidatedEnv;
|
|
92
|
+
/** Aggregate report from validating an entire env object against the schema. */
|
|
93
|
+
interface EnvValidationReport {
|
|
94
|
+
valid: boolean;
|
|
95
|
+
missing: Array<string>;
|
|
96
|
+
invalid: Array<{
|
|
97
|
+
key: string;
|
|
98
|
+
messages: Array<string>;
|
|
99
|
+
}>;
|
|
100
|
+
/**
|
|
101
|
+
* Resolved values for keys that validated successfully. Used to seed the
|
|
102
|
+
* per-env cache after async pre-validation so sync `env.X` reads hit the
|
|
103
|
+
* cache.
|
|
104
|
+
*/
|
|
105
|
+
values: Map<string, unknown>;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Validate an env record (e.g. merged `.env*` + remote secret list) against
|
|
109
|
+
* the registered schema. Used by the dev plugin (warnings), the deploy CLI
|
|
110
|
+
* (hard error), and `_validateEnvOnce` at worker boot.
|
|
111
|
+
*
|
|
112
|
+
* Async: awaits any validators that return a `Promise` (zod async refines,
|
|
113
|
+
* arktype narrows, etc.). Callers already run in async contexts.
|
|
114
|
+
*/
|
|
115
|
+
declare function validateAllEnv(envValues: Record<string, unknown>): Promise<EnvValidationReport>;
|
|
116
|
+
declare global {
|
|
117
|
+
namespace Cloudflare {
|
|
118
|
+
interface Env {
|
|
119
|
+
DB: D1Database;
|
|
120
|
+
KV: KVNamespace;
|
|
121
|
+
STORAGE: R2Bucket;
|
|
122
|
+
AI: Ai;
|
|
123
|
+
SANDBOX: DurableObjectNamespace<_$_cloudflare_sandbox0.Sandbox>;
|
|
124
|
+
/** @internal Service binding to proxy worker (AI, revalidation, future features) */
|
|
125
|
+
__VOID_PROXY?: Fetcher;
|
|
126
|
+
/** @internal Custom proxy URL override */
|
|
127
|
+
__VOID_PROXY_URL?: string;
|
|
128
|
+
/** @internal Auth token for HTTP proxy (local dev) */
|
|
129
|
+
__VOID_TOKEN?: string;
|
|
130
|
+
/** @internal Project ID for HTTP proxy (local dev) */
|
|
131
|
+
__VOID_PROJECT_ID?: string;
|
|
132
|
+
/** @internal Staging environment flag */
|
|
133
|
+
__VOID_STAGING?: string;
|
|
134
|
+
/** @internal Project ID (service binding path) */
|
|
135
|
+
__PROJECT_ID?: string;
|
|
136
|
+
/** @internal Proxy token (service binding path) */
|
|
137
|
+
__VOID_PROXY_TOKEN?: string;
|
|
138
|
+
[key: `QUEUE_${string}`]: Queue<unknown> | undefined;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
//#endregion
|
|
143
|
+
export { type EnvSchema, EnvValidationError, EnvValidationReport, ValidatedEnv, _getRegisteredSchema, _getSchemaDefaults, _hasRegisteredSchema, _validateEnvOnce, boolean, defineEnv, email, env, json, number, oneOf, string, url, validateAllEnv };
|