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
package/AGENT_PROMPT.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
## Void
|
|
2
|
+
|
|
3
|
+
This project uses [Void](https://void.cloud) — a fullstack Vite plugin + deployment platform for Cloudflare. `voidPlugin()` in `vite.config.ts` gives you file-based API routing on Hono (`routes/`), Inertia-inspired server-rendered pages with co-located loaders/actions (`pages/` + `@void/vue` or `@void/react`), auto-provisioned D1/KV/R2 bindings, first-class Drizzle ORM integration (schema in `db/schema.ts` -> `void/db` Drizzle instance -> typed routes -> typed fetch client), built-in auth, queues, cron jobs, edge caching (ISR), and one-command deploys via `npx void deploy`. For first-time setup, prefer `npx void init`; in an empty directory, install `void` first and let the interactive flow scaffold the starter, add the matching framework adapter, configure project files, handle auth, and link or create the deploy project before the first deploy. In an existing app, `void init` configures Void in place by adding missing Vite scripts and creating or patching `vite.config.*` with `voidPlugin()`. Use `void` and `@void/*` package names in source code and package manifests.
|
|
4
|
+
|
|
5
|
+
Database: define Drizzle tables in `db/schema.ts`, import `db` from `void/db` and tables from `@schema`. Use `void db push` for prototyping, `void db generate` for production migrations. `drizzle-orm` and `drizzle-kit` ship with void (no extra install). Migrations live in `db/migrations/`.
|
|
6
|
+
|
|
7
|
+
Env: declare every env key in `env.ts` at the project root via `defineEnv({ KEY: string(), ... })` from `void/env`. Read values via `import { env } from "void/env"`. Schema validation runs at dev start (warns) and on `void deploy` (hard error on missing prod secrets). Use `VITE_*` prefix for keys that should be exposed to client code.
|
|
8
|
+
|
|
9
|
+
CI/editor prep: run `void prepare` to generate `.void/routes.d.ts`, `.void/db.d.ts`, `.void/queues.d.ts`, `.void/env.d.ts`, and `.void/tsconfig.json` without booting Vite. Run it after `npm install` in CI or a fresh clone before typechecking; `vite dev` and `vite build` regenerate these during normal workflows.
|
|
10
|
+
|
|
11
|
+
Rewrites and redirects: declare static rules in `void.json` under `routing.redirects` / `routing.rewrites` / `routing.fallbacks`, or in a `public/_redirects` file. For dynamic rewrites, call `c.rewrite(path)` in a `defineMiddleware`.
|
|
12
|
+
|
|
13
|
+
Logs: surface app-level errors that should show up under `void project logs --level error` via `import { logger } from "void/log"` and `logger.error(msg, fields?)` (also `.warn` / `.info`). Anything caught and only persisted to your own DB is invisible to Cloudflare Tail; route it through `logger.*` or `console.*` so the platform can see it.
|
|
14
|
+
|
|
15
|
+
Full docs are in `node_modules/void/docs/`. If you have the `void` skill available, use it for a complete API reference covering project structure, routing, pages mode, database, auth, typed fetch, KV, storage, queues, cron jobs, CLI, configuration, and deployment.
|
package/README.md
CHANGED
|
@@ -1,150 +1,89 @@
|
|
|
1
|
-
|
|
2
|
-
====
|
|
1
|
+
# void
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
Vite plugin and CLI for building and deploying apps on Void.
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
* Only 3 invalidations can run at the same time (and other processes may be creating them too)
|
|
8
|
-
* There is no callback for the native AWS SDK, so the API must be polled
|
|
5
|
+
## What It Covers
|
|
9
6
|
|
|
7
|
+
- file-based API routes from `routes/`
|
|
8
|
+
- Pages mode from `pages/`
|
|
9
|
+
- typed Drizzle access via `void/db`
|
|
10
|
+
- `crons/` and `queues/`
|
|
11
|
+
- URL redirects, rewrites, and fallbacks (`void.json` / `public/_redirects`, plus `c.rewrite()` from middleware)
|
|
12
|
+
- binding inference for D1, KV, R2, AI, auth, and queues
|
|
13
|
+
- remote bindings for local development
|
|
14
|
+
- deploy packaging for Void-hosted apps, static sites, and supported meta-frameworks
|
|
10
15
|
|
|
11
|
-
|
|
12
|
-
------------
|
|
16
|
+
## Quick Start
|
|
13
17
|
|
|
14
|
-
|
|
18
|
+
Install the Void CLI:
|
|
15
19
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
AWS_ACCESS_KEY_ID
|
|
20
|
-
AWS_SECRET_ACCESS_KEY
|
|
21
|
-
|
|
22
|
-
You can [export](http://www.cyberciti.biz/faq/linux-unix-shell-export-command/) them in the shell for local testing or permanent use. You can also load them into your environment using a tool like [supervisor](https://www.npmjs.org/package/supervisor) or [foreman](http://ddollar.github.io/foreman/) to load an .env file.
|
|
23
|
-
|
|
24
|
-
Follow your hosting provider's instructions for setting environment variables in production:
|
|
25
|
-
|
|
26
|
-
* [Heroku](https://devcenter.heroku.com/articles/nodejs-support#environment)
|
|
27
|
-
* [AWS Elastic Beanstalk](http://docs.aws.amazon.com/gettingstarted/latest/deploy/envvar.html)
|
|
28
|
-
|
|
29
|
-
Void requires a third environment variable that contains the CloudFront distribution id:
|
|
30
|
-
|
|
31
|
-
DISTRIBUTION_ID
|
|
32
|
-
|
|
33
|
-
__WARNING:__ Do _not_ place your AWS credentials or CloudFront Distribution ID in source control!
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
Usage
|
|
37
|
-
-----
|
|
38
|
-
|
|
39
|
-
Require void at the top of your script.
|
|
40
|
-
|
|
41
|
-
```js
|
|
42
|
-
var Void = require('void');
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
Call the constructor with the `new` keyword.
|
|
46
|
-
|
|
47
|
-
```js
|
|
48
|
-
var v = new Void();
|
|
20
|
+
```bash
|
|
21
|
+
npm install -D void
|
|
49
22
|
```
|
|
50
23
|
|
|
51
|
-
|
|
24
|
+
If you run `void init` in an empty directory, the scaffold flow adds the matching Pages adapter and Vite dependencies for you.
|
|
52
25
|
|
|
26
|
+
Then run `npx void init`. In an empty directory, the full interactive flow can scaffold a starter, configure local project files, log you in, and link or create your Void project so the next step is just `npx void deploy`. In an existing app, it configures Void in place by adding missing Vite scripts and creating or patching `vite.config.*` with `voidPlugin()`.
|
|
53
27
|
|
|
54
|
-
|
|
55
|
-
|
|
28
|
+
```ts
|
|
29
|
+
// vite.config.ts
|
|
30
|
+
import { defineConfig } from 'vite';
|
|
31
|
+
import { voidPlugin } from 'void';
|
|
56
32
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
* __paths:__ Array of path strings to be cleared
|
|
60
|
-
* __dirs:__ Array of directories to be scanned and added to `paths`
|
|
61
|
-
* __poison:__ Array of path strings to be removed from `paths`
|
|
62
|
-
* __maxPaths:__ Max number of paths per invalidation (defaults to 1000)
|
|
63
|
-
* __maxJobs:__ Max number of simultaneous invalidations (defaults to 3)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
Properties
|
|
67
|
-
----------
|
|
68
|
-
|
|
69
|
-
* __queue:__ Queue of invalidations
|
|
70
|
-
* __cloudfront:__ The AWS-SDK object
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
Example
|
|
74
|
-
-------
|
|
75
|
-
|
|
76
|
-
We can change the default `maxPaths` method to see some complex behavior:
|
|
77
|
-
|
|
78
|
-
```js
|
|
79
|
-
var v = new Void({
|
|
80
|
-
paths : [
|
|
81
|
-
'/index.html',
|
|
82
|
-
'/index2.html',
|
|
83
|
-
'/foo/bar.html',
|
|
84
|
-
'/foo2/bar2.html'
|
|
85
|
-
],
|
|
86
|
-
maxPaths : 1
|
|
33
|
+
export default defineConfig({
|
|
34
|
+
plugins: [voidPlugin()],
|
|
87
35
|
});
|
|
88
36
|
```
|
|
89
37
|
|
|
90
|
-
|
|
38
|
+
## Core Surfaces
|
|
91
39
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
[Void:IWZ33][Job:H1C3R] Too many invalidations, retrying in 2 minute(s)
|
|
99
|
-
[Void:IWZ33][Job:H1C3R] Too many invalidations, retrying in 2 minute(s)
|
|
100
|
-
[Void:IWZ33][Job:H1C3R] Too many invalidations, retrying in 2 minute(s)
|
|
101
|
-
[Void:IWZ33][Job:H27NL] In progress, re-checking in 2 minute(s)...
|
|
102
|
-
[Void:IWZ33][Job:JD9ZU] In progress, re-checking in 2 minute(s)...
|
|
103
|
-
[Void:IWZ33][Job:H1C3R] Too many invalidations, retrying in 2 minute(s)
|
|
104
|
-
[Void:IWZ33][Job:H27NL] In progress, re-checking in 2 minute(s)...
|
|
105
|
-
[Void:IWZ33][Job:JD9ZU] In progress, re-checking in 2 minute(s)...
|
|
106
|
-
[Void:IWZ33][Job:H1C3R] Invalidation "I13B9HSQI6RO7J" created. Checking in 10 minute(s)...
|
|
107
|
-
[Void:IWZ33][Job:JD9ZU] Invalidation "I35PDGSFYBCA1X" completed!
|
|
108
|
-
[Void:IWZ33][Job:H27NL] Invalidation "IVBLZ2PCXZL5Q" completed!
|
|
109
|
-
[Void:IWZ33][Job:7BTD7] Invalidation "I3HRQCLJU7OSZ7" created. Checking in 10 minute(s)...
|
|
110
|
-
[Void:IWZ33][Job:H1C3R] Invalidation "I13B9HSQI6RO7J" completed!
|
|
111
|
-
[Void:IWZ33][Job:7BTD7] In progress, re-checking in 2 minute(s)...
|
|
112
|
-
[Void:IWZ33][Job:7BTD7] Invalidation "I3HRQCLJU7OSZ7" completed!
|
|
113
|
-
[Void:IWZ23] All jobs complete!
|
|
114
|
-
```
|
|
40
|
+
- `voidPlugin()` — Vite integration, routing, pages mode, codegen, migrations, packaging
|
|
41
|
+
- `void prepare` — generate `.void` artifacts for CI, editors, and fresh clones
|
|
42
|
+
- `void auth login` — platform auth
|
|
43
|
+
- `void deploy` — build and deploy
|
|
44
|
+
- `void db *` — local DB and migration commands
|
|
45
|
+
- `void project *` — link, status, logs, rollback, delete
|
|
115
46
|
|
|
47
|
+
Runtime helpers include:
|
|
116
48
|
|
|
117
|
-
|
|
118
|
-
|
|
49
|
+
- `defineHandler`
|
|
50
|
+
- `defineMiddleware`
|
|
51
|
+
- `defineScheduled`
|
|
52
|
+
- `defineQueue`
|
|
53
|
+
- `void/db`
|
|
54
|
+
- `void/kv`
|
|
55
|
+
- `void/storage`
|
|
56
|
+
- `void/ai`
|
|
57
|
+
- `void/isr`
|
|
58
|
+
- `void/client`
|
|
59
|
+
- `void/auth`
|
|
119
60
|
|
|
120
|
-
|
|
61
|
+
## Supported App Shapes
|
|
121
62
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
63
|
+
- native Void apps (`routes/`, `pages/`, `middleware/`, `crons/`, `queues/`)
|
|
64
|
+
- supported meta-framework deploy targets:
|
|
65
|
+
- TanStack Start
|
|
66
|
+
- React Router
|
|
67
|
+
- SvelteKit
|
|
68
|
+
- Nuxt
|
|
69
|
+
- Astro
|
|
70
|
+
- static and SPA deploys
|
|
71
|
+
- non-Cloudflare server targets (`node`, `bun`, `deno`)
|
|
126
72
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
```
|
|
130
|
-
$ cd void
|
|
131
|
-
$ mocha
|
|
132
|
-
```
|
|
73
|
+
There is Vinext-specific source in the repo, but it is intentionally on hold and not part of the current public support matrix.
|
|
133
74
|
|
|
134
|
-
|
|
75
|
+
## Database Model
|
|
135
76
|
|
|
77
|
+
`void/db` is Drizzle-first.
|
|
136
78
|
|
|
137
|
-
|
|
138
|
-
|
|
79
|
+
- D1 is the default managed database target
|
|
80
|
+
- framework apps can opt into PostgreSQL mode
|
|
81
|
+
- route types, DB types, and queue types are generated into `.void/*.d.ts`
|
|
139
82
|
|
|
140
|
-
|
|
141
|
-
2. Again… do NOT put your AWS credentials of CloudFront distribution id in source control
|
|
83
|
+
## Documentation
|
|
142
84
|
|
|
85
|
+
Full docs live at [void.cloud/docs](https://void.cloud/docs).
|
|
143
86
|
|
|
144
|
-
|
|
145
|
-
-----
|
|
87
|
+
## License
|
|
146
88
|
|
|
147
|
-
|
|
148
|
-
2. Surface granual `Job` properties in `Void` constructor for more flexibility
|
|
149
|
-
3. `Void` event callbacks
|
|
150
|
-
4. Document `Job` object
|
|
89
|
+
MIT
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
import { BetterAuthOptions, Session, User } from "better-auth";
|
|
3
|
+
import { Context, Env } from "hono";
|
|
4
|
+
|
|
5
|
+
//#region src/runtime/auth.d.ts
|
|
6
|
+
type AuthUser = User;
|
|
7
|
+
type AuthSession = Session;
|
|
8
|
+
interface AuthState {
|
|
9
|
+
session: AuthSession;
|
|
10
|
+
user: AuthUser;
|
|
11
|
+
}
|
|
12
|
+
interface VoidAuthConfigContext {
|
|
13
|
+
defaults: BetterAuthOptions;
|
|
14
|
+
env: Record<string, unknown>;
|
|
15
|
+
dialect: "sqlite" | "postgresql";
|
|
16
|
+
request: Request;
|
|
17
|
+
}
|
|
18
|
+
type VoidAuthConfig = BetterAuthOptions | ((ctx: VoidAuthConfigContext) => BetterAuthOptions);
|
|
19
|
+
/**
|
|
20
|
+
* Shared AsyncLocalStorage that holds the authenticated Better Auth state for the
|
|
21
|
+
* current request.
|
|
22
|
+
*
|
|
23
|
+
* Stored on `globalThis` under a `Symbol.for` key so duplicate module loads
|
|
24
|
+
* (e.g. once by void's bundled runtime and once by Vite's SSR module runner
|
|
25
|
+
* when user code imports from `void/auth`) share a single ALS instance. Without
|
|
26
|
+
* this, the middleware writes to one instance and `getUser()` reads another,
|
|
27
|
+
* always returning null.
|
|
28
|
+
*/
|
|
29
|
+
type AuthContextStore = {
|
|
30
|
+
user: AuthUser | null;
|
|
31
|
+
state: AuthState | null;
|
|
32
|
+
};
|
|
33
|
+
declare const authContext: AsyncLocalStorage<AuthContextStore>;
|
|
34
|
+
declare function defineAuth<T extends VoidAuthConfig>(config: T): T;
|
|
35
|
+
declare function getUser(): AuthUser | null;
|
|
36
|
+
declare function getSession(): AuthState | null;
|
|
37
|
+
declare function requireAuth<E extends Env & {
|
|
38
|
+
Variables: {
|
|
39
|
+
user: AuthUser | null;
|
|
40
|
+
};
|
|
41
|
+
}>(c: Context<E>): AuthUser;
|
|
42
|
+
//#endregion
|
|
43
|
+
export { VoidAuthConfigContext as a, getSession as c, VoidAuthConfig as i, getUser as l, AuthState as n, authContext as o, AuthUser as r, defineAuth as s, AuthSession as t, requireAuth as u };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { c as R } from "./dist-Dayj3gCK.mjs";
|
|
2
|
+
import { n as PlatformClient, s as getToken, u as removeToken } from "./client-snXOjrp1.mjs";
|
|
3
|
+
import { n as runLoginCommand } from "./login-CkcXUiIu.mjs";
|
|
4
|
+
import { execSync } from "node:child_process";
|
|
5
|
+
//#region src/cli/auth-cmd.ts
|
|
6
|
+
async function runAuthCommand(root, args) {
|
|
7
|
+
switch (args.subcommand) {
|
|
8
|
+
case "login": return runLoginCommand(root);
|
|
9
|
+
case "logout":
|
|
10
|
+
if (removeToken(root)) R.success("Logged out.");
|
|
11
|
+
else R.info("Not logged in.");
|
|
12
|
+
return;
|
|
13
|
+
case "whoami": {
|
|
14
|
+
const token = getToken(root);
|
|
15
|
+
if (!token) {
|
|
16
|
+
R.error("Not logged in. Run `void auth login` first.");
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
const user = await new PlatformClient(token, { root }).whoami();
|
|
20
|
+
R.info(`${user.login} (${user.plan})`);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
case "token": {
|
|
24
|
+
if (!getToken(root)) await runLoginCommand(root);
|
|
25
|
+
const token = getToken(root);
|
|
26
|
+
if (!token) {
|
|
27
|
+
R.error("Login failed. Run `void auth login` to try again.");
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
const platform = process.platform;
|
|
31
|
+
const cmd = platform === "darwin" ? "pbcopy" : platform === "win32" ? "clip" : "xclip -selection clipboard";
|
|
32
|
+
try {
|
|
33
|
+
execSync(cmd, { input: token });
|
|
34
|
+
R.success("Token copied to clipboard.");
|
|
35
|
+
} catch {
|
|
36
|
+
R.warn("Could not copy to clipboard. Re-run `void login` to generate a new token.");
|
|
37
|
+
}
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
export { runAuthCommand };
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
//#region src/runtime/auth-migrations.ts
|
|
2
|
+
function quoteIdentifier(name) {
|
|
3
|
+
return `"${name.replaceAll("\"", "\"\"")}"`;
|
|
4
|
+
}
|
|
5
|
+
function quotePragmaArg(name) {
|
|
6
|
+
return `'${name.replaceAll("'", "''")}'`;
|
|
7
|
+
}
|
|
8
|
+
function createIndexName(tableName, fieldName, unique) {
|
|
9
|
+
return `${tableName}_${fieldName}_${unique ? "uidx" : "idx"}`;
|
|
10
|
+
}
|
|
11
|
+
function resolveColumnType(dialect, idStrategy, fieldName, field) {
|
|
12
|
+
const useIdType = fieldName === "id" || field.references?.field === "id";
|
|
13
|
+
if (dialect === "postgresql") {
|
|
14
|
+
if (useIdType) {
|
|
15
|
+
if (fieldName === "id" && idStrategy === "serial") return "integer GENERATED BY DEFAULT AS IDENTITY";
|
|
16
|
+
if (idStrategy === "serial") return "integer";
|
|
17
|
+
if (idStrategy === "uuid") return "uuid";
|
|
18
|
+
return "text";
|
|
19
|
+
}
|
|
20
|
+
if (field.type === "boolean") return "boolean";
|
|
21
|
+
if (field.type === "date") return "timestamptz";
|
|
22
|
+
if (field.type === "number") return field.bigint ? "bigint" : "integer";
|
|
23
|
+
if (field.type === "json" || field.type === "string[]" || field.type === "number[]") return "jsonb";
|
|
24
|
+
return "text";
|
|
25
|
+
}
|
|
26
|
+
if (useIdType) return idStrategy === "serial" ? "INTEGER" : "TEXT";
|
|
27
|
+
if (field.type === "boolean" || field.type === "date" || field.type === "number") return "INTEGER";
|
|
28
|
+
if (field.type === "json" || field.type === "string[]" || field.type === "number[]") return "TEXT";
|
|
29
|
+
return "TEXT";
|
|
30
|
+
}
|
|
31
|
+
function buildColumnDefinition(dialect, schema, fieldName, field, options = {}) {
|
|
32
|
+
const parts = [`${quoteIdentifier(fieldName)} ${resolveColumnType(dialect, schema.idStrategy, fieldName, field)}`];
|
|
33
|
+
if (options.primaryKey) parts.push("PRIMARY KEY");
|
|
34
|
+
if (field.required || options.primaryKey) parts.push("NOT NULL");
|
|
35
|
+
if (field.references) parts.push(`REFERENCES ${quoteIdentifier(field.references.table)}(${quoteIdentifier(field.references.field)}) ON DELETE ${String(field.references.onDelete ?? "cascade").toUpperCase()}`);
|
|
36
|
+
return parts.join(" ");
|
|
37
|
+
}
|
|
38
|
+
function buildCreateTableSql(schema, table) {
|
|
39
|
+
const dialect = schema.dialect;
|
|
40
|
+
const columns = [buildColumnDefinition(dialect, schema, "id", {
|
|
41
|
+
type: schema.idStrategy === "serial" ? "number" : "string",
|
|
42
|
+
required: true,
|
|
43
|
+
unique: false,
|
|
44
|
+
index: false,
|
|
45
|
+
bigint: false
|
|
46
|
+
}, { primaryKey: true }), ...Object.entries(table.fields).map(([fieldName, field]) => buildColumnDefinition(dialect, schema, fieldName, field))];
|
|
47
|
+
return `CREATE TABLE IF NOT EXISTS ${quoteIdentifier(table.name)} (${columns.join(", ")})`;
|
|
48
|
+
}
|
|
49
|
+
function buildAddColumnSql(schema, tableName, fieldName, field) {
|
|
50
|
+
const ifNotExists = schema.dialect === "postgresql" ? " IF NOT EXISTS" : "";
|
|
51
|
+
return `ALTER TABLE ${quoteIdentifier(tableName)} ADD COLUMN${ifNotExists} ${buildColumnDefinition(schema.dialect, schema, fieldName, field)}`;
|
|
52
|
+
}
|
|
53
|
+
function buildCreateIndexSql(tableName, fieldName, unique) {
|
|
54
|
+
return `CREATE ${unique ? "UNIQUE " : ""}INDEX IF NOT EXISTS ${quoteIdentifier(createIndexName(tableName, fieldName, unique))} ON ${quoteIdentifier(tableName)} (${quoteIdentifier(fieldName)})`;
|
|
55
|
+
}
|
|
56
|
+
async function ensureSqliteIndexes(runner, table) {
|
|
57
|
+
const indexRows = await runner.all(`PRAGMA index_list(${quotePragmaArg(table.name)})`);
|
|
58
|
+
const existingIndexes = new Set(indexRows.map((row) => String(row.name)));
|
|
59
|
+
for (const [fieldName, field] of Object.entries(table.fields)) {
|
|
60
|
+
if (!field.index && !field.unique) continue;
|
|
61
|
+
const indexName = createIndexName(table.name, fieldName, field.unique);
|
|
62
|
+
if (existingIndexes.has(indexName)) continue;
|
|
63
|
+
await runner.run(buildCreateIndexSql(table.name, fieldName, field.unique));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
async function ensurePgIndexes(runner, schemaName, table) {
|
|
67
|
+
const indexRows = await runner.all("SELECT indexname FROM pg_indexes WHERE schemaname = $1 AND tablename = $2", [schemaName, table.name]);
|
|
68
|
+
const existingIndexes = new Set(indexRows.map((row) => String(row.indexname)));
|
|
69
|
+
for (const [fieldName, field] of Object.entries(table.fields)) {
|
|
70
|
+
if (!field.index && !field.unique) continue;
|
|
71
|
+
const indexName = createIndexName(table.name, fieldName, field.unique);
|
|
72
|
+
if (existingIndexes.has(indexName)) continue;
|
|
73
|
+
await runner.run(buildCreateIndexSql(table.name, fieldName, field.unique));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
async function applySqliteAuthMigrations(runner, schema) {
|
|
77
|
+
const tableRows = await runner.all("SELECT name FROM sqlite_master WHERE type = 'table'");
|
|
78
|
+
const existingTables = new Set(tableRows.map((row) => String(row.name)));
|
|
79
|
+
for (const table of schema.tables) {
|
|
80
|
+
if (!existingTables.has(table.name)) {
|
|
81
|
+
await runner.run(buildCreateTableSql(schema, table));
|
|
82
|
+
await ensureSqliteIndexes(runner, table);
|
|
83
|
+
existingTables.add(table.name);
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
const columnRows = await runner.all(`PRAGMA table_info(${quotePragmaArg(table.name)})`);
|
|
87
|
+
const existingColumns = new Set(columnRows.map((row) => String(row.name)));
|
|
88
|
+
for (const [fieldName, field] of Object.entries(table.fields)) {
|
|
89
|
+
if (existingColumns.has(fieldName)) continue;
|
|
90
|
+
await runner.run(buildAddColumnSql(schema, table.name, fieldName, field));
|
|
91
|
+
}
|
|
92
|
+
await ensureSqliteIndexes(runner, table);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async function applyPgAuthMigrations(runner, schema) {
|
|
96
|
+
const schemaRows = await runner.all("SELECT current_schema() AS schema");
|
|
97
|
+
const schemaName = String(schemaRows[0]?.schema ?? "public");
|
|
98
|
+
const tableRows = await runner.all("SELECT table_name FROM information_schema.tables WHERE table_schema = $1 AND table_type = 'BASE TABLE'", [schemaName]);
|
|
99
|
+
const existingTables = new Set(tableRows.map((row) => String(row.table_name)));
|
|
100
|
+
for (const table of schema.tables) {
|
|
101
|
+
if (!existingTables.has(table.name)) {
|
|
102
|
+
await runner.run(buildCreateTableSql(schema, table));
|
|
103
|
+
await ensurePgIndexes(runner, schemaName, table);
|
|
104
|
+
existingTables.add(table.name);
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
const columnRows = await runner.all("SELECT column_name FROM information_schema.columns WHERE table_schema = $1 AND table_name = $2", [schemaName, table.name]);
|
|
108
|
+
const existingColumns = new Set(columnRows.map((row) => String(row.column_name)));
|
|
109
|
+
for (const [fieldName, field] of Object.entries(table.fields)) {
|
|
110
|
+
if (existingColumns.has(fieldName)) continue;
|
|
111
|
+
await runner.run(buildAddColumnSql(schema, table.name, fieldName, field));
|
|
112
|
+
}
|
|
113
|
+
await ensurePgIndexes(runner, schemaName, table);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
//#endregion
|
|
117
|
+
export { applySqliteAuthMigrations as n, applyPgAuthMigrations as t };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { i as VoidAuthConfig, n as AuthState } from "./auth-BdsJ0Aff.mjs";
|
|
2
|
+
import { DBFieldAttribute } from "better-auth/db";
|
|
3
|
+
import { BetterAuthOptions, betterAuth } from "better-auth";
|
|
4
|
+
import { Context } from "hono";
|
|
5
|
+
|
|
6
|
+
//#region src/auth/drizzle.d.ts
|
|
7
|
+
type AuthIdStrategy = "serial" | "text" | "uuid";
|
|
8
|
+
interface VoidAuthMigrationField {
|
|
9
|
+
type: DBFieldAttribute["type"];
|
|
10
|
+
required: boolean;
|
|
11
|
+
unique: boolean;
|
|
12
|
+
index: boolean;
|
|
13
|
+
bigint: boolean;
|
|
14
|
+
references?: {
|
|
15
|
+
table: string;
|
|
16
|
+
field: string;
|
|
17
|
+
onDelete?: "no action" | "restrict" | "cascade" | "set null" | "set default";
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
interface VoidAuthMigrationTable {
|
|
21
|
+
name: string;
|
|
22
|
+
order: number;
|
|
23
|
+
fields: Record<string, VoidAuthMigrationField>;
|
|
24
|
+
}
|
|
25
|
+
interface VoidAuthMigrationSchema {
|
|
26
|
+
dialect: "sqlite" | "postgresql";
|
|
27
|
+
idStrategy: AuthIdStrategy;
|
|
28
|
+
tables: ReadonlyArray<VoidAuthMigrationTable>;
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/auth/providers.d.ts
|
|
32
|
+
declare const VOID_SOCIAL_AUTH_PROVIDERS: readonly ["apple", "atlassian", "cognito", "discord", "dropbox", "facebook", "figma", "github", "gitlab", "google", "huggingface", "kakao", "kick", "line", "linear", "linkedin", "microsoft", "naver", "notion", "paybin", "paypal", "polar", "railway", "reddit", "roblox", "salesforce", "slack", "spotify", "tiktok", "twitch", "twitter", "vercel", "vk", "zoom"];
|
|
33
|
+
declare const VOID_EMAIL_AUTH_PROVIDER = "email";
|
|
34
|
+
declare const VOID_AUTH_PROVIDERS: readonly [typeof VOID_EMAIL_AUTH_PROVIDER, ...typeof VOID_SOCIAL_AUTH_PROVIDERS];
|
|
35
|
+
type VoidAuthProvider = (typeof VOID_AUTH_PROVIDERS)[number];
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/runtime/better-auth-shared.d.ts
|
|
38
|
+
type VoidAuthDialect = "sqlite" | "postgresql";
|
|
39
|
+
interface VoidAuthRuntimeOptions {
|
|
40
|
+
dialect: VoidAuthDialect;
|
|
41
|
+
providers: ReadonlyArray<VoidAuthProvider> | null;
|
|
42
|
+
userConfig?: VoidAuthConfig;
|
|
43
|
+
}
|
|
44
|
+
interface VoidAuthEnv extends Record<string, unknown> {
|
|
45
|
+
DB?: D1Database;
|
|
46
|
+
DATABASE_URL?: string;
|
|
47
|
+
HYPERDRIVE?: {
|
|
48
|
+
connectionString?: string;
|
|
49
|
+
};
|
|
50
|
+
BETTER_AUTH_SECRET?: string;
|
|
51
|
+
GITHUB_OAUTH_ID?: string;
|
|
52
|
+
GITHUB_OAUTH_SECRET?: string;
|
|
53
|
+
GOOGLE_OAUTH_ID?: string;
|
|
54
|
+
GOOGLE_OAUTH_SECRET?: string;
|
|
55
|
+
}
|
|
56
|
+
interface VoidAuthRuntimeApi {
|
|
57
|
+
resolveVoidAuthOptions(request: Request, env: VoidAuthEnv, runtime: VoidAuthRuntimeOptions, databaseOverride?: NonNullable<BetterAuthOptions["database"]>, disposeOverride?: () => Promise<void>): Promise<{
|
|
58
|
+
options: BetterAuthOptions;
|
|
59
|
+
dispose(): Promise<void>;
|
|
60
|
+
}>;
|
|
61
|
+
createVoidAuth(request: Request, env: VoidAuthEnv, runtime: VoidAuthRuntimeOptions, databaseOverride?: NonNullable<BetterAuthOptions["database"]>, disposeOverride?: () => Promise<void>): Promise<{
|
|
62
|
+
auth: ReturnType<typeof betterAuth>;
|
|
63
|
+
dispose(): Promise<void>;
|
|
64
|
+
}>;
|
|
65
|
+
resolveVoidAuthState(request: Request, env: VoidAuthEnv, runtime: VoidAuthRuntimeOptions, databaseOverride?: NonNullable<BetterAuthOptions["database"]>, disposeOverride?: () => Promise<void>): Promise<AuthState | null>;
|
|
66
|
+
runVoidAuthMiddleware(c: Context, next: () => Promise<void>, runtime: VoidAuthRuntimeOptions, databaseOverride?: NonNullable<BetterAuthOptions["database"]>, disposeOverride?: () => Promise<void>): Promise<void>;
|
|
67
|
+
handleVoidAuthRequest(c: Context, runtime: VoidAuthRuntimeOptions, databaseOverride?: NonNullable<BetterAuthOptions["database"]>, disposeOverride?: () => Promise<void>): Promise<Response>;
|
|
68
|
+
runVoidAuthMigrations(request: Request, env: VoidAuthEnv, runtime: VoidAuthRuntimeOptions, migrationSchema: VoidAuthMigrationSchema): Promise<void>;
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
export { VoidAuthRuntimeOptions as i, VoidAuthEnv as n, VoidAuthRuntimeApi as r, VoidAuthDialect as t };
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { a as isVoidSocialAuthProvider, r as getVoidAuthProviderEnvNames } from "./providers-B3aMxWzP.mjs";
|
|
2
|
+
import { authContext } from "./runtime/auth.mjs";
|
|
3
|
+
import { betterAuth } from "better-auth";
|
|
4
|
+
//#region src/runtime/better-auth-shared.ts
|
|
5
|
+
function isLocalHost(hostname) {
|
|
6
|
+
return hostname === "localhost" || hostname === "127.0.0.1" || hostname.endsWith(".local");
|
|
7
|
+
}
|
|
8
|
+
function resolveSecret(request, env) {
|
|
9
|
+
const explicit = typeof env.BETTER_AUTH_SECRET === "string" && env.BETTER_AUTH_SECRET.length > 0 ? env.BETTER_AUTH_SECRET : void 0;
|
|
10
|
+
if (explicit) return explicit;
|
|
11
|
+
if (isLocalHost(new URL(request.url).hostname)) return "void-dev-better-auth-secret-1234567890";
|
|
12
|
+
throw new Error("auth: Missing Better Auth secret. Set BETTER_AUTH_SECRET.");
|
|
13
|
+
}
|
|
14
|
+
function readEnvString(env, ...keys) {
|
|
15
|
+
for (const key of keys) {
|
|
16
|
+
const value = env[key];
|
|
17
|
+
if (typeof value === "string" && value.length > 0) return value;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function resolveEmailAndPassword(configuredProviders) {
|
|
21
|
+
if (!configuredProviders || configuredProviders.includes("email")) return { enabled: true };
|
|
22
|
+
}
|
|
23
|
+
function resolveSocialProviderCredentials(env, provider) {
|
|
24
|
+
const envNames = getVoidAuthProviderEnvNames(provider);
|
|
25
|
+
const clientIdKeys = [envNames.clientId];
|
|
26
|
+
const clientSecretKeys = [envNames.clientSecret];
|
|
27
|
+
if (envNames.legacyClientId) clientIdKeys.push(envNames.legacyClientId);
|
|
28
|
+
if (envNames.legacyClientSecret) clientSecretKeys.push(envNames.legacyClientSecret);
|
|
29
|
+
const clientId = readEnvString(env, ...clientIdKeys);
|
|
30
|
+
const clientSecret = readEnvString(env, ...clientSecretKeys);
|
|
31
|
+
if (!clientId || !clientSecret) throw new Error(`auth: Missing credentials for provider '${provider}'. Set ${envNames.clientId} and ${envNames.clientSecret}, or remove '${provider}' from auth.providers.`);
|
|
32
|
+
return {
|
|
33
|
+
clientId,
|
|
34
|
+
clientSecret
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function resolveSocialProviders(env, configuredProviders) {
|
|
38
|
+
if (!configuredProviders) return;
|
|
39
|
+
const providers = {};
|
|
40
|
+
for (const provider of configuredProviders) {
|
|
41
|
+
if (!isVoidSocialAuthProvider(provider)) continue;
|
|
42
|
+
providers[provider] = resolveSocialProviderCredentials(env, provider);
|
|
43
|
+
}
|
|
44
|
+
return Object.keys(providers).length > 0 ? providers : void 0;
|
|
45
|
+
}
|
|
46
|
+
function appendAuthHeaders(target, source) {
|
|
47
|
+
if (!source) return;
|
|
48
|
+
source.forEach((value, key) => {
|
|
49
|
+
if (key.toLowerCase() === "set-cookie") {
|
|
50
|
+
target.append(key, value);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
target.set(key, value);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function resolveUserConfig(userConfig, defaults, request, env, dialect) {
|
|
57
|
+
if (!userConfig) return defaults;
|
|
58
|
+
if (typeof userConfig === "function") return userConfig({
|
|
59
|
+
defaults,
|
|
60
|
+
request,
|
|
61
|
+
env,
|
|
62
|
+
dialect
|
|
63
|
+
});
|
|
64
|
+
return {
|
|
65
|
+
...defaults,
|
|
66
|
+
...userConfig
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function assertRuntimeDialect(runtime, dialect) {
|
|
70
|
+
if (runtime.dialect !== dialect) throw new Error(`auth: Runtime mismatch. Expected ${dialect}, received '${runtime.dialect}'.`);
|
|
71
|
+
}
|
|
72
|
+
function createVoidAuthRuntime(dialect, resolveDatabase, runVoidAuthMigrations) {
|
|
73
|
+
async function resolveVoidAuthOptions(request, env, runtime, databaseOverride, disposeOverride) {
|
|
74
|
+
assertRuntimeDialect(runtime, dialect);
|
|
75
|
+
const { database, dispose } = databaseOverride ? {
|
|
76
|
+
database: databaseOverride,
|
|
77
|
+
dispose: disposeOverride ?? (async () => {})
|
|
78
|
+
} : await resolveDatabase(env);
|
|
79
|
+
const origin = new URL(request.url).origin;
|
|
80
|
+
const emailAndPassword = resolveEmailAndPassword(runtime.providers);
|
|
81
|
+
const socialProviders = resolveSocialProviders(env, runtime.providers);
|
|
82
|
+
const defaults = {
|
|
83
|
+
baseURL: origin,
|
|
84
|
+
basePath: "/api/auth",
|
|
85
|
+
secret: resolveSecret(request, env),
|
|
86
|
+
database,
|
|
87
|
+
...emailAndPassword ? { emailAndPassword } : {},
|
|
88
|
+
...socialProviders ? { socialProviders } : {},
|
|
89
|
+
trustedOrigins: [origin]
|
|
90
|
+
};
|
|
91
|
+
return {
|
|
92
|
+
options: resolveUserConfig(runtime.userConfig, defaults, request, env, dialect),
|
|
93
|
+
dispose
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
async function createVoidAuth(request, env, runtime, databaseOverride, disposeOverride) {
|
|
97
|
+
const { options, dispose } = await resolveVoidAuthOptions(request, env, runtime, databaseOverride, disposeOverride);
|
|
98
|
+
return {
|
|
99
|
+
auth: betterAuth(options),
|
|
100
|
+
dispose
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
async function resolveVoidAuthState(request, env, runtime, databaseOverride, disposeOverride) {
|
|
104
|
+
const { auth, dispose } = await createVoidAuth(request, env, runtime, databaseOverride, disposeOverride);
|
|
105
|
+
try {
|
|
106
|
+
return (await auth.api.getSession({
|
|
107
|
+
headers: request.headers,
|
|
108
|
+
asResponse: false,
|
|
109
|
+
returnHeaders: true
|
|
110
|
+
})).response ?? null;
|
|
111
|
+
} finally {
|
|
112
|
+
await dispose();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
async function runVoidAuthMiddleware(c, next, runtime, databaseOverride, disposeOverride) {
|
|
116
|
+
if (c.req.path.startsWith("/__")) {
|
|
117
|
+
c.set("user", null);
|
|
118
|
+
c.set("session", null);
|
|
119
|
+
return next();
|
|
120
|
+
}
|
|
121
|
+
const { auth, dispose } = await createVoidAuth(c.req.raw, c.env, runtime, databaseOverride, disposeOverride);
|
|
122
|
+
c.set("__voidAuth", auth);
|
|
123
|
+
try {
|
|
124
|
+
const result = await auth.api.getSession({
|
|
125
|
+
headers: c.req.raw.headers,
|
|
126
|
+
asResponse: false,
|
|
127
|
+
returnHeaders: true
|
|
128
|
+
});
|
|
129
|
+
const state = result.response ?? null;
|
|
130
|
+
c.set("user", state?.user ?? null);
|
|
131
|
+
c.set("session", state?.session ?? null);
|
|
132
|
+
await authContext.run({
|
|
133
|
+
user: state?.user ?? null,
|
|
134
|
+
state
|
|
135
|
+
}, async () => {
|
|
136
|
+
await next();
|
|
137
|
+
});
|
|
138
|
+
appendAuthHeaders(c.res.headers, result.headers);
|
|
139
|
+
} finally {
|
|
140
|
+
await dispose();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
async function handleVoidAuthRequest(c, runtime, databaseOverride, disposeOverride) {
|
|
144
|
+
const existingAuth = c.get("__voidAuth");
|
|
145
|
+
if (existingAuth) return existingAuth.handler(c.req.raw);
|
|
146
|
+
const { auth, dispose } = await createVoidAuth(c.req.raw, c.env, runtime, databaseOverride, disposeOverride);
|
|
147
|
+
try {
|
|
148
|
+
return await auth.handler(c.req.raw);
|
|
149
|
+
} finally {
|
|
150
|
+
await dispose();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
resolveVoidAuthOptions,
|
|
155
|
+
createVoidAuth,
|
|
156
|
+
resolveVoidAuthState,
|
|
157
|
+
runVoidAuthMiddleware,
|
|
158
|
+
handleVoidAuthRequest,
|
|
159
|
+
runVoidAuthMigrations
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
//#endregion
|
|
163
|
+
export { createVoidAuthRuntime as t };
|