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,92 @@
|
|
|
1
|
+
import { a as ensureUtc, i as dim, n as cliTitle, r as createSpinner, s as import_picocolors } from "./output-BwlcIYSR.mjs";
|
|
2
|
+
import { _ as me, c as R, g as ge, i as Ee, v as ue, x as q, y as ye } from "./dist-Dayj3gCK.mjs";
|
|
3
|
+
import { r as readProjectConfig } from "./project-TqORyHn8.mjs";
|
|
4
|
+
import { n as PlatformClient, s as getToken } from "./client-snXOjrp1.mjs";
|
|
5
|
+
//#region src/cli/rollback.ts
|
|
6
|
+
async function runRollbackCommand(root, deployId) {
|
|
7
|
+
console.log();
|
|
8
|
+
ge(cliTitle("project rollback"));
|
|
9
|
+
const token = getToken(root);
|
|
10
|
+
if (!token) {
|
|
11
|
+
R.error("Not logged in. Run `void auth login` first.");
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
const linked = readProjectConfig(root);
|
|
15
|
+
if (!linked) {
|
|
16
|
+
R.error("No linked project. Run `void project link` first.");
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
const client = new PlatformClient(token, { root });
|
|
20
|
+
const { deployments, activeDeploymentId } = await client.listDeployments(linked.projectId);
|
|
21
|
+
const candidates = deployments.filter((d) => d.retained && d.status === "live" && d.id !== activeDeploymentId);
|
|
22
|
+
if (candidates.length === 0) {
|
|
23
|
+
R.warn("No retained deployments available for rollback.");
|
|
24
|
+
ye(dim("Deploy more versions to enable rollback."));
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
let targetId;
|
|
28
|
+
if (deployId) {
|
|
29
|
+
if (!candidates.find((d) => d.id === deployId)) {
|
|
30
|
+
R.error(`Deployment ${deployId} is not available for rollback (not retained or not found).`);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
targetId = deployId;
|
|
34
|
+
} else {
|
|
35
|
+
const result = await Ee({
|
|
36
|
+
message: "Select a deployment to roll back to:",
|
|
37
|
+
options: candidates.map((d) => ({
|
|
38
|
+
value: d.id,
|
|
39
|
+
label: `${d.id} ${dim(formatAge(d.deployed_at))}`,
|
|
40
|
+
hint: d.source ? `via ${d.source}` : void 0
|
|
41
|
+
}))
|
|
42
|
+
});
|
|
43
|
+
if (q(result)) {
|
|
44
|
+
me("Rollback cancelled.");
|
|
45
|
+
process.exit(0);
|
|
46
|
+
}
|
|
47
|
+
targetId = result;
|
|
48
|
+
}
|
|
49
|
+
const active = deployments.find((d) => d.id === activeDeploymentId);
|
|
50
|
+
const target = candidates.find((d) => d.id === targetId);
|
|
51
|
+
const currentMigrations = active?.applied_migrations ? JSON.parse(active.applied_migrations) : [];
|
|
52
|
+
const targetMigrations = target.applied_migrations ? JSON.parse(target.applied_migrations) : [];
|
|
53
|
+
const migrationDiff = currentMigrations.filter((m) => !targetMigrations.includes(m));
|
|
54
|
+
if (migrationDiff.length > 0) {
|
|
55
|
+
R.warn(`The current database has ${migrationDiff.length} migration(s) applied after this deployment:`);
|
|
56
|
+
for (const m of migrationDiff) R.message(` ${dim("•")} ${m}`);
|
|
57
|
+
R.message(dim("Rolling back will NOT revert these migrations. The older code will run against the current schema."));
|
|
58
|
+
const proceed = await ue({ message: "Proceed with rollback?" });
|
|
59
|
+
if (q(proceed) || !proceed) {
|
|
60
|
+
me("Rollback cancelled.");
|
|
61
|
+
process.exit(0);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const s = createSpinner();
|
|
65
|
+
s.start("Rolling back...");
|
|
66
|
+
try {
|
|
67
|
+
const result = await client.rollback(linked.projectId, targetId, { allowDestructive: migrationDiff.length > 0 ? migrationDiff : void 0 });
|
|
68
|
+
s.stop("Rollback complete.");
|
|
69
|
+
if (result.ok) R.success(`Rolled back to ${import_picocolors.default.bold(targetId)}`);
|
|
70
|
+
else {
|
|
71
|
+
R.error(result.error ?? "Rollback failed.");
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
} catch (err) {
|
|
75
|
+
s.stop("Rollback failed.");
|
|
76
|
+
R.error(err instanceof Error ? err.message : String(err));
|
|
77
|
+
process.exit(1);
|
|
78
|
+
}
|
|
79
|
+
ye(dim("Traffic is now serving the rolled-back deployment."));
|
|
80
|
+
}
|
|
81
|
+
function formatAge(deployedAt) {
|
|
82
|
+
if (!deployedAt) return "";
|
|
83
|
+
const diffMs = Date.now() - new Date(ensureUtc(deployedAt)).getTime();
|
|
84
|
+
if (diffMs < 6e4) return "just now";
|
|
85
|
+
const minutes = Math.floor(diffMs / 6e4);
|
|
86
|
+
if (minutes < 60) return `${minutes}m ago`;
|
|
87
|
+
const hours = Math.floor(minutes / 60);
|
|
88
|
+
if (hours < 24) return `${hours}h ago`;
|
|
89
|
+
return `${Math.floor(hours / 24)}d ago`;
|
|
90
|
+
}
|
|
91
|
+
//#endregion
|
|
92
|
+
export { runRollbackCommand };
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { a as join, o as relative } from "./pathe.M-eThtNZ-D-kmWkCS.mjs";
|
|
2
|
+
import { mkdirSync, writeFileSync } from "node:fs";
|
|
3
|
+
//#region src/codegen/db-types.ts
|
|
4
|
+
const DRIZZLE_OPERATORS = "sql, eq, ne, gt, gte, lt, lte, and, or, not, desc, asc, like, ilike, notLike, inArray, notInArray, isNull, isNotNull, between, notBetween, exists, notExists, count, sum, avg, min, max";
|
|
5
|
+
/**
|
|
6
|
+
* Generate `.void/db.d.ts` with Drizzle types referencing the user's schema.
|
|
7
|
+
*
|
|
8
|
+
* This is a proper module file (not `declare module`) whose types override
|
|
9
|
+
* the base `void/db` package via a tsconfig `paths` redirect:
|
|
10
|
+
* "void/db": ["./.void/db.d.ts"]
|
|
11
|
+
*
|
|
12
|
+
* Imports reference `void/_db` (internal subpath pointing at the same
|
|
13
|
+
* base module) to avoid circular resolution through the paths redirect.
|
|
14
|
+
*/
|
|
15
|
+
function generateDbDts(outDir, schema, dialect) {
|
|
16
|
+
mkdirSync(outDir, { recursive: true });
|
|
17
|
+
const lines = dialect === "postgresql" ? schema ? [
|
|
18
|
+
"// Auto-generated by void — do not edit",
|
|
19
|
+
"import type { NodePgDatabase } from \"void/_db-pg\";",
|
|
20
|
+
"import type * as schema from \"@schema\";",
|
|
21
|
+
"type Schema = typeof schema;",
|
|
22
|
+
"export declare const db: NodePgDatabase<Schema>;",
|
|
23
|
+
"export declare function createDb(connectionString: string): NodePgDatabase<Schema>;",
|
|
24
|
+
`export { ${DRIZZLE_OPERATORS} } from "void/_db";`,
|
|
25
|
+
"export type { NodePgDatabase } from \"void/_db-pg\";",
|
|
26
|
+
""
|
|
27
|
+
] : [
|
|
28
|
+
"// Auto-generated by void — do not edit",
|
|
29
|
+
"import type { NodePgDatabase } from \"void/_db-pg\";",
|
|
30
|
+
"export declare const db: NodePgDatabase<Record<string, never>>;",
|
|
31
|
+
"export declare function createDb(connectionString: string): NodePgDatabase<Record<string, never>>;",
|
|
32
|
+
`export { ${DRIZZLE_OPERATORS} } from "void/_db";`,
|
|
33
|
+
"export type { NodePgDatabase } from \"void/_db-pg\";",
|
|
34
|
+
""
|
|
35
|
+
] : schema ? [
|
|
36
|
+
"// Auto-generated by void — do not edit",
|
|
37
|
+
"/// <reference types=\"@cloudflare/workers-types\" />",
|
|
38
|
+
"import type { DrizzleD1Database } from \"void/_db\";",
|
|
39
|
+
"import type * as schema from \"@schema\";",
|
|
40
|
+
"type Schema = typeof schema;",
|
|
41
|
+
"export declare const db: DrizzleD1Database<Schema>;",
|
|
42
|
+
"export declare function createDb(d1: D1Database): DrizzleD1Database<Schema>;",
|
|
43
|
+
`export { ${DRIZZLE_OPERATORS} } from "void/_db";`,
|
|
44
|
+
"export type { DrizzleD1Database } from \"void/_db\";",
|
|
45
|
+
""
|
|
46
|
+
] : [
|
|
47
|
+
"// Auto-generated by void — do not edit",
|
|
48
|
+
"/// <reference types=\"@cloudflare/workers-types\" />",
|
|
49
|
+
"import type { DrizzleD1Database } from \"void/_db\";",
|
|
50
|
+
"export declare const db: DrizzleD1Database<Record<string, never>>;",
|
|
51
|
+
"export declare function createDb(d1: D1Database): DrizzleD1Database<Record<string, never>>;",
|
|
52
|
+
`export { ${DRIZZLE_OPERATORS} } from "void/_db";`,
|
|
53
|
+
"export type { DrizzleD1Database } from \"void/_db\";",
|
|
54
|
+
""
|
|
55
|
+
];
|
|
56
|
+
writeFileSync(join(outDir, "db.d.ts"), lines.join("\n"));
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/codegen/queue-types.ts
|
|
60
|
+
/**
|
|
61
|
+
* Generate .void/queues.d.ts content.
|
|
62
|
+
*
|
|
63
|
+
* Augments `void/queues` with a typed `QueueMap` interface
|
|
64
|
+
* so `queues.emails.send(body)` is fully typed from the consumer's
|
|
65
|
+
* `defineQueue<T>` phantom type.
|
|
66
|
+
*/
|
|
67
|
+
function generateQueueTypes(queues, queuesDir, outDir) {
|
|
68
|
+
const lines = [];
|
|
69
|
+
lines.push("// Auto-generated by void — do not edit");
|
|
70
|
+
lines.push("export interface QueueMap {");
|
|
71
|
+
for (const q of queues) {
|
|
72
|
+
const importPath = relative(outDir, `${queuesDir}/${q.filePath}`);
|
|
73
|
+
lines.push(` ${JSON.stringify(q.name)}: Queue<(typeof import(${JSON.stringify(importPath)}))["default"]["__payload"]>;`);
|
|
74
|
+
}
|
|
75
|
+
lines.push("}");
|
|
76
|
+
lines.push("");
|
|
77
|
+
lines.push("export declare const queues: QueueMap;");
|
|
78
|
+
lines.push("");
|
|
79
|
+
return lines.join("\n");
|
|
80
|
+
}
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/codegen/route-types.ts
|
|
83
|
+
/**
|
|
84
|
+
* Generate .void/routes.d.ts content.
|
|
85
|
+
*
|
|
86
|
+
* Uses `typeof import(...)` so TypeScript resolves all types.
|
|
87
|
+
* The codegen generates scaffolding only — never analyzes types itself.
|
|
88
|
+
*/
|
|
89
|
+
function generateRouteTypes(scan, routesDir, outDir, pagesDir) {
|
|
90
|
+
const lines = [];
|
|
91
|
+
lines.push("// Auto-generated by void — do not edit");
|
|
92
|
+
lines.push("export {}");
|
|
93
|
+
lines.push("interface StandardSchemaV1<Input = unknown, Output = Input> {");
|
|
94
|
+
lines.push(" readonly \"~standard\": {");
|
|
95
|
+
lines.push(" readonly version: 1;");
|
|
96
|
+
lines.push(" readonly vendor: string;");
|
|
97
|
+
lines.push(" readonly validate: (value: unknown) => unknown;");
|
|
98
|
+
lines.push(" readonly types?: { readonly input: Input; readonly output: Output } | undefined;");
|
|
99
|
+
lines.push(" };");
|
|
100
|
+
lines.push("}");
|
|
101
|
+
lines.push("declare namespace StandardSchemaV1 {");
|
|
102
|
+
lines.push(" type InferInput<Schema extends StandardSchemaV1> = NonNullable<");
|
|
103
|
+
lines.push(" Schema[\"~standard\"][\"types\"]");
|
|
104
|
+
lines.push(" >[\"input\"];");
|
|
105
|
+
lines.push(" type InferOutput<Schema extends StandardSchemaV1> = NonNullable<");
|
|
106
|
+
lines.push(" Schema[\"~standard\"][\"types\"]");
|
|
107
|
+
lines.push(" >[\"output\"];");
|
|
108
|
+
lines.push("}");
|
|
109
|
+
lines.push("");
|
|
110
|
+
lines.push("type Serialize<T> =");
|
|
111
|
+
lines.push(" T extends Response ? never :");
|
|
112
|
+
lines.push(" T extends Date ? string :");
|
|
113
|
+
lines.push(" T extends bigint ? never :");
|
|
114
|
+
lines.push(" T extends Function ? never :");
|
|
115
|
+
lines.push(" T extends undefined ? never :");
|
|
116
|
+
lines.push(" T extends Array<infer U> ? Array<Serialize<U>> :");
|
|
117
|
+
lines.push(" T extends object ? { [K in keyof T as T[K] extends Function ? never : K]: Serialize<T[K]> } :");
|
|
118
|
+
lines.push(" T;");
|
|
119
|
+
lines.push("");
|
|
120
|
+
lines.push("type ExtractInput<V> = {");
|
|
121
|
+
lines.push(" [K in keyof V as V[K] extends StandardSchemaV1 ? K : never]:");
|
|
122
|
+
lines.push(" V[K] extends StandardSchemaV1 ? StandardSchemaV1.InferInput<V[K]> : never;");
|
|
123
|
+
lines.push("};");
|
|
124
|
+
lines.push("");
|
|
125
|
+
lines.push("type ExtractOutput<S> =");
|
|
126
|
+
lines.push(" S extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<S> : never;");
|
|
127
|
+
lines.push("");
|
|
128
|
+
lines.push("type RouteParams<P extends readonly string[]> =");
|
|
129
|
+
lines.push(" P extends readonly [] ? Record<string, never> : { [K in P[number]]: string };");
|
|
130
|
+
lines.push("");
|
|
131
|
+
lines.push("declare module \"void/routes\" {");
|
|
132
|
+
lines.push(" export interface RouteMap {}");
|
|
133
|
+
lines.push(" export interface WebSocketRouteMap {}");
|
|
134
|
+
lines.push(" export interface PageActionMap {}");
|
|
135
|
+
lines.push("");
|
|
136
|
+
lines.push(" /** Union of known route patterns (keys of the generated RouteMap). */");
|
|
137
|
+
lines.push(" export type RouteName = keyof RouteMap;");
|
|
138
|
+
lines.push("");
|
|
139
|
+
lines.push(" /**");
|
|
140
|
+
lines.push(" * Destination type for rewrites / fallbacks / c.rewrite().");
|
|
141
|
+
lines.push(" *");
|
|
142
|
+
lines.push(" * The `string & {}` branch keeps IDE autocomplete of known routes while");
|
|
143
|
+
lines.push(" * still accepting arbitrary strings (needed for dynamic paths like");
|
|
144
|
+
lines.push(" * `/users/${id}`). When no routes are generated yet, `RouteName` is");
|
|
145
|
+
lines.push(" * `never` and this degenerates to `string & {}`, which is assignable");
|
|
146
|
+
lines.push(" * from any string.");
|
|
147
|
+
lines.push(" */");
|
|
148
|
+
lines.push(" export type RewriteDestination = RouteName | (string & {});");
|
|
149
|
+
lines.push("");
|
|
150
|
+
lines.push(" export type ParseActionUrl<U extends string> = U extends `${infer Base}?${infer Action}` ? {");
|
|
151
|
+
lines.push(" base: Base;");
|
|
152
|
+
lines.push(" action: Action;");
|
|
153
|
+
lines.push(" } : {");
|
|
154
|
+
lines.push(" base: U;");
|
|
155
|
+
lines.push(" action: never;");
|
|
156
|
+
lines.push(" };");
|
|
157
|
+
lines.push("");
|
|
158
|
+
lines.push(" export type ResolveActionBody<U extends string> =");
|
|
159
|
+
lines.push(" ParseActionUrl<U>[\"base\"] extends keyof PageActionMap");
|
|
160
|
+
lines.push(" ? ParseActionUrl<U>[\"action\"] extends never");
|
|
161
|
+
lines.push(" ? PageActionMap[ParseActionUrl<U>[\"base\"]] extends { body: infer B }");
|
|
162
|
+
lines.push(" ? B");
|
|
163
|
+
lines.push(" : Record<string, unknown>");
|
|
164
|
+
lines.push(" : PageActionMap[ParseActionUrl<U>[\"base\"]] extends { actions: infer A }");
|
|
165
|
+
lines.push(" ? ParseActionUrl<U>[\"action\"] extends keyof A");
|
|
166
|
+
lines.push(" ? A[ParseActionUrl<U>[\"action\"]] extends { body: infer B }");
|
|
167
|
+
lines.push(" ? B");
|
|
168
|
+
lines.push(" : Record<string, unknown>");
|
|
169
|
+
lines.push(" : never");
|
|
170
|
+
lines.push(" : never");
|
|
171
|
+
lines.push(" : Record<string, unknown>;");
|
|
172
|
+
lines.push("");
|
|
173
|
+
lines.push(" export type ResolveActionParams<U extends string> =");
|
|
174
|
+
lines.push(" ParseActionUrl<U>[\"base\"] extends keyof PageActionMap");
|
|
175
|
+
lines.push(" ? PageActionMap[ParseActionUrl<U>[\"base\"]] extends { params: infer P }");
|
|
176
|
+
lines.push(" ? P");
|
|
177
|
+
lines.push(" : never");
|
|
178
|
+
lines.push(" : never;");
|
|
179
|
+
lines.push("");
|
|
180
|
+
lines.push(" export type HasActionParams<U extends string> =");
|
|
181
|
+
lines.push(" ResolveActionParams<U> extends Record<string, string> ? true : false;");
|
|
182
|
+
lines.push("");
|
|
183
|
+
lines.push(" export type ActionFormOptions<U extends string> =");
|
|
184
|
+
lines.push(" HasActionParams<U> extends true ? { params: ResolveActionParams<U> } : { params?: never };");
|
|
185
|
+
lines.push("");
|
|
186
|
+
lines.push(" export type ActionUrl =");
|
|
187
|
+
lines.push(" | {");
|
|
188
|
+
lines.push(" [K in keyof PageActionMap]: PageActionMap[K] extends { body: any } ? K : never;");
|
|
189
|
+
lines.push(" }[keyof PageActionMap]");
|
|
190
|
+
lines.push(" | {");
|
|
191
|
+
lines.push(" [K in keyof PageActionMap]: PageActionMap[K] extends { actions: infer A }");
|
|
192
|
+
lines.push(" ? `${K & string}?${keyof A & string}`");
|
|
193
|
+
lines.push(" : never;");
|
|
194
|
+
lines.push(" }[keyof PageActionMap]");
|
|
195
|
+
lines.push("");
|
|
196
|
+
lines.push(" interface RouteMap {");
|
|
197
|
+
for (const route of scan.routes) {
|
|
198
|
+
if (route.methods.length === 0) continue;
|
|
199
|
+
const importPath = relative(outDir, `${routesDir}/${route.filePath}`);
|
|
200
|
+
lines.push(` ${JSON.stringify(route.pattern)}: {`);
|
|
201
|
+
for (const method of route.methods) {
|
|
202
|
+
lines.push(` ${method}: {`);
|
|
203
|
+
lines.push(` input: ExtractInput<(typeof import(${JSON.stringify(importPath)}))["${method}"]["__validators"]>;`);
|
|
204
|
+
lines.push(` output: Serialize<Awaited<(typeof import(${JSON.stringify(importPath)}))["${method}"]["__output"]>>;`);
|
|
205
|
+
lines.push(" };");
|
|
206
|
+
}
|
|
207
|
+
lines.push(" };");
|
|
208
|
+
}
|
|
209
|
+
lines.push(" }");
|
|
210
|
+
lines.push("");
|
|
211
|
+
lines.push(" interface WebSocketRouteMap {");
|
|
212
|
+
for (const route of scan.websockets ?? []) {
|
|
213
|
+
const importPath = relative(outDir, `${routesDir}/${route.filePath}`);
|
|
214
|
+
lines.push(` ${JSON.stringify(route.pattern)}: {`);
|
|
215
|
+
lines.push(` params: RouteParams<${JSON.stringify(route.params)}>;`);
|
|
216
|
+
lines.push(` client: ExtractInput<(typeof import(${JSON.stringify(importPath)}))["default"]["messages"]["client"]>;`);
|
|
217
|
+
lines.push(` server: ExtractOutput<(typeof import(${JSON.stringify(importPath)}))["default"]["messages"]["server"]>;`);
|
|
218
|
+
lines.push(" };");
|
|
219
|
+
}
|
|
220
|
+
lines.push(" }");
|
|
221
|
+
const actionPages = scan.pages.pages.filter((p) => p.methods.includes("action") || p.methods.includes("actions"));
|
|
222
|
+
if (actionPages.length > 0 && pagesDir) {
|
|
223
|
+
lines.push(" interface PageActionMap {");
|
|
224
|
+
for (const page of actionPages) {
|
|
225
|
+
const hasAction = page.methods.includes("action");
|
|
226
|
+
const hasActions = page.methods.includes("actions");
|
|
227
|
+
if (hasAction && hasActions) throw new Error(`pages: Page '${page.pattern}' exports both "action" and "actions". Use one or the other.`);
|
|
228
|
+
lines.push(` ${JSON.stringify(page.pattern)}: {`);
|
|
229
|
+
let importPath = null;
|
|
230
|
+
if (page.serverPath) importPath = relative(outDir, `${pagesDir}/${page.serverPath}`);
|
|
231
|
+
if (hasActions) {
|
|
232
|
+
if (importPath) {
|
|
233
|
+
const actionsImport = `(typeof import(${JSON.stringify(importPath)}))["actions"]`;
|
|
234
|
+
lines.push(` actions: { [K in keyof ${actionsImport}]: {`);
|
|
235
|
+
lines.push(` body: ExtractInput<${actionsImport}[K]["__validators"]> extends { body: infer B } ? B : Record<string, unknown>;`);
|
|
236
|
+
lines.push(" } };");
|
|
237
|
+
}
|
|
238
|
+
} else if (importPath) {
|
|
239
|
+
const importExpr = `(typeof import(${JSON.stringify(importPath)}))["action"]`;
|
|
240
|
+
lines.push(` body: ExtractInput<${importExpr}["__validators"]> extends { body: infer B } ? B : Record<string, unknown>;`);
|
|
241
|
+
} else lines.push(" body: Record<string, unknown>;");
|
|
242
|
+
if (page.params.length > 0) {
|
|
243
|
+
const paramsType = page.params.map((p) => `${p}: string`).join("; ");
|
|
244
|
+
lines.push(` params: { ${paramsType} };`);
|
|
245
|
+
}
|
|
246
|
+
lines.push(" };");
|
|
247
|
+
}
|
|
248
|
+
lines.push(" }");
|
|
249
|
+
}
|
|
250
|
+
lines.push("}");
|
|
251
|
+
lines.push("");
|
|
252
|
+
return { dts: lines.join("\n") };
|
|
253
|
+
}
|
|
254
|
+
//#endregion
|
|
255
|
+
export { generateDbDts as i, generateQueueTypes as n, DRIZZLE_OPERATORS as r, generateRouteTypes as t };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
//#region src/routes-stub.d.ts
|
|
2
|
+
/** Stub interface augmented by the generated .void/routes.d.ts */
|
|
3
|
+
interface RouteMap {}
|
|
4
|
+
/** Stub interface augmented by the generated .void/routes.d.ts */
|
|
5
|
+
interface WebSocketRouteMap {}
|
|
6
|
+
/** Union of known route patterns (keys of the generated RouteMap). */
|
|
7
|
+
type RouteName = keyof RouteMap;
|
|
8
|
+
/**
|
|
9
|
+
* Destination type for rewrites / fallbacks / c.rewrite().
|
|
10
|
+
*
|
|
11
|
+
* The `string & {}` branch keeps IDE autocomplete of known routes while
|
|
12
|
+
* still accepting arbitrary strings (needed for dynamic paths like
|
|
13
|
+
* `/users/${id}`). When no routes are generated yet, `RouteName` is
|
|
14
|
+
* `never` and this degenerates to `string & {}`, which is assignable
|
|
15
|
+
* from any string.
|
|
16
|
+
*/
|
|
17
|
+
type RewriteDestination = RouteName | (string & {});
|
|
18
|
+
/** Stub interface for page action types — augmented by generated routes.d.ts */
|
|
19
|
+
interface PageActionMap {}
|
|
20
|
+
/** Parse "/path?action" into base path and action name */
|
|
21
|
+
type ParseActionUrl<U extends string> = U extends `${infer Base}?${infer Action}` ? {
|
|
22
|
+
base: Base;
|
|
23
|
+
action: Action;
|
|
24
|
+
} : {
|
|
25
|
+
base: U;
|
|
26
|
+
action: never;
|
|
27
|
+
};
|
|
28
|
+
/** Resolve body type for a useForm URL (single action or named action) */
|
|
29
|
+
type ResolveActionBody<U extends string> = ParseActionUrl<U>["base"] extends keyof PageActionMap ? ParseActionUrl<U>["action"] extends never ? PageActionMap[ParseActionUrl<U>["base"]] extends {
|
|
30
|
+
body: infer B;
|
|
31
|
+
} ? B : Record<string, unknown> : PageActionMap[ParseActionUrl<U>["base"]] extends {
|
|
32
|
+
actions: infer A;
|
|
33
|
+
} ? ParseActionUrl<U>["action"] extends keyof A ? A[ParseActionUrl<U>["action"]] extends {
|
|
34
|
+
body: infer B;
|
|
35
|
+
} ? B : Record<string, unknown> : never : never : Record<string, unknown>;
|
|
36
|
+
/** Resolve params type */
|
|
37
|
+
type ResolveActionParams<U extends string> = ParseActionUrl<U>["base"] extends keyof PageActionMap ? PageActionMap[ParseActionUrl<U>["base"]] extends {
|
|
38
|
+
params: infer P;
|
|
39
|
+
} ? P : never : never;
|
|
40
|
+
/** Has params check */
|
|
41
|
+
type HasActionParams<U extends string> = ResolveActionParams<U> extends Record<string, string> ? true : false;
|
|
42
|
+
/** Form options type (requires params for dynamic routes) */
|
|
43
|
+
type ActionFormOptions<U extends string> = HasActionParams<U> extends true ? {
|
|
44
|
+
params: ResolveActionParams<U>;
|
|
45
|
+
} : {
|
|
46
|
+
params?: never;
|
|
47
|
+
};
|
|
48
|
+
/** Valid useForm URLs — single-action pages + "page?name" combos + default actions */
|
|
49
|
+
type ActionUrl = { [K in keyof PageActionMap]: PageActionMap[K] extends {
|
|
50
|
+
body: unknown;
|
|
51
|
+
} ? K : never }[keyof PageActionMap] | { [K in keyof PageActionMap]: PageActionMap[K] extends {
|
|
52
|
+
actions: infer A;
|
|
53
|
+
} ? `${K & string}?${keyof A & string}` : never }[keyof PageActionMap];
|
|
54
|
+
//#endregion
|
|
55
|
+
export { ActionFormOptions, ActionUrl, HasActionParams, PageActionMap, ParseActionUrl, ResolveActionBody, ResolveActionParams, RewriteDestination, RouteMap, RouteName, WebSocketRouteMap };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { a as join, n as dirname } from "./pathe.M-eThtNZ-D-kmWkCS.mjs";
|
|
2
|
+
import { t as collectMigrations } from "./collect-CjeZgz5D.mjs";
|
|
3
|
+
import { existsSync, mkdirSync } from "node:fs";
|
|
4
|
+
import { createHash, createHmac } from "node:crypto";
|
|
5
|
+
//#region src/migrations/runner.ts
|
|
6
|
+
function toBetterSqlite3Error(error) {
|
|
7
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
8
|
+
if (!message.includes("Could not locate the bindings file")) return error instanceof Error ? error : new Error(message);
|
|
9
|
+
return /* @__PURE__ */ new Error("db: better-sqlite3 is installed but its native binding was not built. Add it to your 'onlyBuiltDependencies' and run `pnpm rebuild better-sqlite3`. See https://pnpm.io/settings#onlybuiltdependencies");
|
|
10
|
+
}
|
|
11
|
+
async function openSqliteDatabase(dbPath, options) {
|
|
12
|
+
try {
|
|
13
|
+
const Database = (await import("better-sqlite3")).default;
|
|
14
|
+
return new Database(dbPath, options);
|
|
15
|
+
} catch (error) {
|
|
16
|
+
throw toBetterSqlite3Error(error);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Read the list of applied migrations from the local SQLite database.
|
|
21
|
+
* Returns [] if the DB file or tracking table doesn't exist.
|
|
22
|
+
*/
|
|
23
|
+
async function getAppliedMigrations(dbPath) {
|
|
24
|
+
if (!existsSync(dbPath)) return [];
|
|
25
|
+
const db = await openSqliteDatabase(dbPath, { readonly: true });
|
|
26
|
+
try {
|
|
27
|
+
let tableName = null;
|
|
28
|
+
for (const candidate of ["_void_migrations", "_migrations"]) if (db.prepare(`SELECT name FROM sqlite_master WHERE type='table' AND name='${candidate}'`).get()) {
|
|
29
|
+
tableName = candidate;
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
if (!tableName) return [];
|
|
33
|
+
return db.prepare(`SELECT name, applied_at FROM ${tableName} ORDER BY name`).all();
|
|
34
|
+
} finally {
|
|
35
|
+
db.close();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Compute the miniflare D1 SQLite database path.
|
|
40
|
+
* Miniflare uses a deterministic hash based on the database_id
|
|
41
|
+
* to store local D1 data.
|
|
42
|
+
*/
|
|
43
|
+
function getMiniflareDatabasePath(persistRoot, databaseId) {
|
|
44
|
+
const uniqueKey = "miniflare-D1DatabaseObject";
|
|
45
|
+
const key = createHash("sha256").update(uniqueKey).digest();
|
|
46
|
+
const nameHmac = createHmac("sha256", key).update(databaseId).digest().subarray(0, 16);
|
|
47
|
+
const hmac = createHmac("sha256", key).update(nameHmac).digest().subarray(0, 16);
|
|
48
|
+
return join(persistRoot, "v3", "d1", uniqueKey, `${Buffer.concat([nameHmac, hmac]).toString("hex")}.sqlite`);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* One-time migration: rename legacy `_migrations` table to `_void_migrations`.
|
|
52
|
+
* Copies all rows from the old table to the new one, then drops the old table.
|
|
53
|
+
*
|
|
54
|
+
* Wrapped in an IMMEDIATE transaction + re-checked inside, so two concurrent
|
|
55
|
+
* local runners (e.g. two `vite dev` processes against the same DB file)
|
|
56
|
+
* don't race each other. Without the lock, both could observe `_migrations`
|
|
57
|
+
* exists, both enter the body, and the loser crashes on `SELECT … FROM
|
|
58
|
+
* _migrations` after the winner already dropped it.
|
|
59
|
+
*/
|
|
60
|
+
function upgradeTrackingTable(db) {
|
|
61
|
+
db.transaction(() => {
|
|
62
|
+
if (!db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='_migrations'").get()) return;
|
|
63
|
+
db.exec(`
|
|
64
|
+
CREATE TABLE IF NOT EXISTS _void_migrations (
|
|
65
|
+
name TEXT PRIMARY KEY,
|
|
66
|
+
applied_at TEXT DEFAULT (datetime('now'))
|
|
67
|
+
)
|
|
68
|
+
`);
|
|
69
|
+
db.exec(`INSERT OR IGNORE INTO _void_migrations (name, applied_at) SELECT name, applied_at FROM _migrations`);
|
|
70
|
+
db.exec(`DROP TABLE IF EXISTS _migrations`);
|
|
71
|
+
}).immediate();
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Apply unapplied SQL migrations from the migrations directory.
|
|
75
|
+
* Tracks applied migrations in the `_void_migrations` table.
|
|
76
|
+
*
|
|
77
|
+
* Each .sql file is executed as a single `db.exec()` call — better-sqlite3's
|
|
78
|
+
* `exec` natively handles multi-statement SQL and lets SQLite do the parsing,
|
|
79
|
+
* so semicolons inside string literals, comments, or trigger bodies don't
|
|
80
|
+
* fracture the migration. A naive `split(';')` pre-processor would misparse
|
|
81
|
+
* a statement like `CREATE TABLE t (msg TEXT DEFAULT 'a;b')` into garbage
|
|
82
|
+
* fragments.
|
|
83
|
+
*
|
|
84
|
+
* Concurrent-runner safety: two local `void` processes can race against the
|
|
85
|
+
* same SQLite file. Both can snapshot the applied-set before either writes,
|
|
86
|
+
* and if both decide a migration is pending, the loser would crash on a
|
|
87
|
+
* `table already exists` error. Each per-migration apply therefore runs
|
|
88
|
+
* inside an IMMEDIATE transaction that re-checks the tracking row under the
|
|
89
|
+
* SQLite write lock — the loser sees the winner's insert and skips, instead
|
|
90
|
+
* of re-running the DDL.
|
|
91
|
+
*/
|
|
92
|
+
async function runMigrations(migrationsDir, dbPath) {
|
|
93
|
+
const allMigrations = collectMigrations(migrationsDir);
|
|
94
|
+
if (allMigrations.length === 0) return [];
|
|
95
|
+
mkdirSync(dirname(dbPath), { recursive: true });
|
|
96
|
+
const db = await openSqliteDatabase(dbPath);
|
|
97
|
+
try {
|
|
98
|
+
upgradeTrackingTable(db);
|
|
99
|
+
db.exec(`
|
|
100
|
+
CREATE TABLE IF NOT EXISTS _void_migrations (
|
|
101
|
+
name TEXT PRIMARY KEY,
|
|
102
|
+
applied_at TEXT DEFAULT (datetime('now'))
|
|
103
|
+
)
|
|
104
|
+
`);
|
|
105
|
+
const appliedSet = new Set(db.prepare("SELECT name FROM _void_migrations").all().map((r) => r.name));
|
|
106
|
+
const pending = allMigrations.filter((m) => !appliedSet.has(m.name));
|
|
107
|
+
if (pending.length === 0) return [];
|
|
108
|
+
const insertStmt = db.prepare("INSERT INTO _void_migrations (name) VALUES (?)");
|
|
109
|
+
const checkStmt = db.prepare("SELECT 1 FROM _void_migrations WHERE name = ?");
|
|
110
|
+
const appliedNames = [];
|
|
111
|
+
for (const migration of pending) if (db.transaction(() => {
|
|
112
|
+
if (checkStmt.get(migration.name)) return false;
|
|
113
|
+
db.exec(migration.sql);
|
|
114
|
+
insertStmt.run(migration.name);
|
|
115
|
+
return true;
|
|
116
|
+
}).immediate()) appliedNames.push(migration.name);
|
|
117
|
+
return appliedNames;
|
|
118
|
+
} finally {
|
|
119
|
+
db.close();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
//#endregion
|
|
123
|
+
export { getAppliedMigrations, getMiniflareDatabasePath, openSqliteDatabase, runMigrations };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { t as collectMigrations } from "./collect-CjeZgz5D.mjs";
|
|
2
|
+
//#region src/migrations/runner-pg.ts
|
|
3
|
+
/**
|
|
4
|
+
* Apply unapplied SQL migrations via a connected PostgreSQL client.
|
|
5
|
+
* Each migration runs in its own transaction (BEGIN/COMMIT).
|
|
6
|
+
*/
|
|
7
|
+
async function getPgAppliedMigrations(url) {
|
|
8
|
+
const { Client } = await import("pg");
|
|
9
|
+
const client = new Client({ connectionString: url });
|
|
10
|
+
await client.connect();
|
|
11
|
+
try {
|
|
12
|
+
await client.query(`CREATE TABLE IF NOT EXISTS _void_migrations (name TEXT PRIMARY KEY, applied_at TEXT NOT NULL)`);
|
|
13
|
+
return (await client.query("SELECT name FROM _void_migrations")).rows.map((row) => String(row.name));
|
|
14
|
+
} catch {
|
|
15
|
+
return [];
|
|
16
|
+
} finally {
|
|
17
|
+
await client.end();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
async function applyPgMigrations(client, migrations) {
|
|
21
|
+
if (migrations.length === 0) return [];
|
|
22
|
+
await client.query(`CREATE TABLE IF NOT EXISTS _void_migrations (name TEXT PRIMARY KEY, applied_at TEXT NOT NULL)`);
|
|
23
|
+
const existing = await client.query("SELECT name FROM _void_migrations");
|
|
24
|
+
const appliedSet = new Set(existing.rows.map((row) => String(row.name)));
|
|
25
|
+
const pending = migrations.filter((m) => !appliedSet.has(m.name));
|
|
26
|
+
if (pending.length === 0) return [];
|
|
27
|
+
for (const m of pending) {
|
|
28
|
+
await client.query("BEGIN");
|
|
29
|
+
try {
|
|
30
|
+
await client.query(m.sql);
|
|
31
|
+
await client.query("INSERT INTO _void_migrations (name, applied_at) VALUES ($1, $2)", [m.name, (/* @__PURE__ */ new Date()).toISOString()]);
|
|
32
|
+
await client.query("COMMIT");
|
|
33
|
+
} catch (err) {
|
|
34
|
+
await client.query("ROLLBACK");
|
|
35
|
+
throw err;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return pending.map((m) => m.name);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Apply unapplied SQL migrations to a PostgreSQL database.
|
|
42
|
+
* Each migration runs in its own transaction (BEGIN/COMMIT).
|
|
43
|
+
*/
|
|
44
|
+
async function runPgMigrations(migrationsDir, url) {
|
|
45
|
+
const allMigrations = collectMigrations(migrationsDir);
|
|
46
|
+
if (allMigrations.length === 0) return [];
|
|
47
|
+
const { Client } = await import("pg");
|
|
48
|
+
const client = new Client({ connectionString: url });
|
|
49
|
+
await client.connect();
|
|
50
|
+
try {
|
|
51
|
+
return await applyPgMigrations(client, allMigrations);
|
|
52
|
+
} finally {
|
|
53
|
+
await client.end();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
export { applyPgMigrations, getPgAppliedMigrations, runPgMigrations };
|