astro 5.16.5 → 6.0.0-alpha.1
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/{astro.js → bin/astro.mjs} +7 -8
- package/client.d.ts +19 -45
- package/components/ClientRouter.astro +0 -5
- package/components/Code.astro +2 -2
- package/components/Image.astro +2 -2
- package/components/Picture.astro +1 -1
- package/dist/actions/consts.d.ts +2 -5
- package/dist/actions/consts.js +4 -8
- package/dist/actions/integration.js +2 -4
- package/dist/actions/runtime/client.d.ts +84 -3
- package/dist/actions/runtime/client.js +238 -7
- package/dist/actions/runtime/entrypoints/client.d.ts +7 -0
- package/dist/actions/runtime/entrypoints/client.js +91 -0
- package/dist/actions/runtime/entrypoints/route.d.ts +2 -0
- package/dist/actions/runtime/{route.js → entrypoints/route.js} +1 -1
- package/dist/actions/runtime/entrypoints/server.d.ts +6 -0
- package/dist/actions/runtime/entrypoints/server.js +33 -0
- package/dist/actions/runtime/server.d.ts +11 -29
- package/dist/actions/runtime/server.js +162 -82
- package/dist/actions/runtime/types.d.ts +64 -0
- package/dist/actions/runtime/types.js +0 -0
- package/dist/actions/utils.d.ts +2 -2
- package/dist/actions/utils.js +2 -2
- package/dist/actions/vite-plugin-actions.js +18 -21
- package/dist/assets/build/generate.d.ts +2 -2
- package/dist/assets/build/generate.js +11 -9
- package/dist/assets/build/remote.js +4 -14
- package/dist/assets/endpoint/config.js +2 -2
- package/dist/assets/endpoint/dev.js +7 -6
- package/dist/assets/fonts/config.d.ts +86 -174
- package/dist/assets/fonts/config.js +15 -17
- package/dist/assets/fonts/infra/dev-remote-font-provider-mod-resolver.d.ts +3 -3
- package/dist/assets/fonts/infra/dev-remote-font-provider-mod-resolver.js +4 -4
- package/dist/assets/fonts/types.d.ts +1 -1
- package/dist/assets/fonts/vite-plugin-fonts.js +6 -3
- package/dist/assets/services/sharp.js +5 -6
- package/dist/assets/utils/index.d.ts +0 -6
- package/dist/assets/utils/index.js +0 -9
- package/dist/assets/utils/{transformToPath.d.ts → node.d.ts} +15 -1
- package/dist/assets/utils/{node/emitAsset.js → node.js} +34 -56
- package/dist/assets/vite-plugin-assets.js +9 -14
- package/dist/cli/index.js +0 -2
- package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
- package/dist/cli/preferences/index.js +5 -1
- package/dist/config/index.js +11 -16
- package/dist/container/index.d.ts +0 -1
- package/dist/container/index.js +19 -14
- package/dist/container/pipeline.d.ts +2 -1
- package/dist/container/pipeline.js +4 -11
- package/dist/content/config.d.ts +34 -40
- package/dist/content/config.js +17 -13
- package/dist/content/content-layer.js +14 -21
- package/dist/content/data-store.d.ts +0 -2
- package/dist/content/loaders/errors.d.ts +3 -3
- package/dist/content/loaders/errors.js +5 -2
- package/dist/content/loaders/glob.d.ts +0 -5
- package/dist/content/loaders/glob.js +3 -30
- package/dist/content/loaders/types.d.ts +11 -4
- package/dist/content/mutable-data-store.js +1 -14
- package/dist/content/runtime-assets.d.ts +4 -4
- package/dist/content/runtime-assets.js +4 -7
- package/dist/content/runtime.d.ts +35 -73
- package/dist/content/runtime.js +63 -231
- package/dist/content/server-listeners.js +25 -88
- package/dist/content/types-generator.d.ts +1 -6
- package/dist/content/types-generator.js +87 -156
- package/dist/content/utils.d.ts +47 -412
- package/dist/content/utils.js +88 -203
- package/dist/content/vite-plugin-content-assets.d.ts +12 -4
- package/dist/content/vite-plugin-content-assets.js +100 -56
- package/dist/content/vite-plugin-content-imports.js +10 -8
- package/dist/content/vite-plugin-content-virtual-mod.js +13 -131
- package/dist/core/app/app.d.ts +5 -0
- package/dist/core/app/app.js +13 -0
- package/dist/core/app/base.d.ts +132 -0
- package/dist/core/app/base.js +448 -0
- package/dist/core/app/common.d.ts +6 -2
- package/dist/core/app/common.js +60 -33
- package/dist/core/app/dev/app.d.ts +15 -0
- package/dist/core/app/dev/app.js +86 -0
- package/dist/core/app/dev/pipeline.d.ts +13 -0
- package/dist/core/app/dev/pipeline.js +123 -0
- package/dist/core/app/entrypoint.d.ts +2 -0
- package/dist/core/app/entrypoint.js +15 -0
- package/dist/core/app/index.d.ts +7 -114
- package/dist/core/app/index.js +20 -557
- package/dist/core/app/logging.d.ts +3 -0
- package/dist/core/app/logging.js +11 -0
- package/dist/core/app/manifest.d.ts +9 -0
- package/dist/core/app/manifest.js +107 -0
- package/dist/core/app/middlewares.js +1 -1
- package/dist/core/app/node.d.ts +2 -8
- package/dist/core/app/node.js +8 -9
- package/dist/core/app/pipeline.d.ts +6 -5
- package/dist/core/app/pipeline.js +65 -49
- package/dist/core/app/types.d.ts +58 -22
- package/dist/core/app/validate-forwarded-headers.d.ts +16 -0
- package/dist/core/app/validate-forwarded-headers.js +60 -0
- package/dist/core/base-pipeline.d.ts +22 -14
- package/dist/core/base-pipeline.js +54 -6
- package/dist/core/build/app.d.ts +13 -0
- package/dist/core/build/app.js +38 -0
- package/dist/core/build/common.d.ts +1 -1
- package/dist/core/build/common.js +2 -2
- package/dist/core/build/generate.d.ts +1 -1
- package/dist/core/build/generate.js +95 -204
- package/dist/core/build/graph.js +2 -2
- package/dist/core/build/index.js +11 -19
- package/dist/core/build/internal.d.ts +3 -29
- package/dist/core/build/internal.js +1 -45
- package/dist/core/build/pipeline.d.ts +15 -26
- package/dist/core/build/pipeline.js +106 -170
- package/dist/core/build/plugins/index.d.ts +4 -2
- package/dist/core/build/plugins/index.js +17 -23
- package/dist/core/build/plugins/plugin-analyzer.d.ts +2 -2
- package/dist/core/build/plugins/plugin-analyzer.js +5 -13
- package/dist/core/build/plugins/plugin-component-entry.d.ts +7 -2
- package/dist/core/build/plugins/plugin-component-entry.js +5 -13
- package/dist/core/build/plugins/plugin-css.d.ts +2 -2
- package/dist/core/build/plugins/plugin-css.js +86 -41
- package/dist/core/build/plugins/plugin-internals.d.ts +2 -2
- package/dist/core/build/plugins/plugin-internals.js +24 -18
- package/dist/core/build/plugins/plugin-manifest.d.ts +33 -5
- package/dist/core/build/plugins/plugin-manifest.js +89 -131
- package/dist/core/build/plugins/plugin-middleware.d.ts +2 -2
- package/dist/core/build/plugins/plugin-middleware.js +5 -7
- package/dist/core/build/plugins/plugin-noop.d.ts +3 -0
- package/dist/core/build/plugins/plugin-noop.js +29 -0
- package/dist/core/build/plugins/plugin-prerender.d.ts +2 -2
- package/dist/core/build/plugins/plugin-prerender.js +7 -64
- package/dist/core/build/plugins/plugin-scripts.d.ts +5 -2
- package/dist/core/build/plugins/plugin-scripts.js +5 -13
- package/dist/core/build/plugins/plugin-ssr.d.ts +2 -2
- package/dist/core/build/plugins/plugin-ssr.js +60 -132
- package/dist/core/build/plugins/util.d.ts +1 -25
- package/dist/core/build/plugins/util.js +0 -47
- package/dist/core/build/runtime.d.ts +26 -0
- package/dist/core/build/runtime.js +45 -0
- package/dist/core/build/static-build.d.ts +2 -2
- package/dist/core/build/static-build.js +180 -154
- package/dist/core/build/types.d.ts +1 -2
- package/dist/core/build/util.d.ts +0 -1
- package/dist/core/build/util.js +0 -7
- package/dist/core/compile/compile.d.ts +2 -3
- package/dist/core/compile/compile.js +2 -4
- package/dist/core/config/config.js +2 -2
- package/dist/core/config/index.d.ts +0 -1
- package/dist/core/config/index.js +0 -2
- package/dist/core/config/schemas/base.d.ts +330 -1463
- package/dist/core/config/schemas/base.js +40 -56
- package/dist/core/config/schemas/refined.d.ts +2 -2
- package/dist/core/config/schemas/refined.js +8 -1
- package/dist/core/config/schemas/relative.d.ts +607 -1737
- package/dist/core/config/schemas/relative.js +4 -4
- package/dist/core/config/settings.d.ts +3 -3
- package/dist/core/config/settings.js +5 -6
- package/dist/core/config/validate.js +13 -2
- package/dist/core/config/vite-load.js +12 -3
- package/dist/core/constants.d.ts +12 -0
- package/dist/core/constants.js +22 -1
- package/dist/core/create-vite.d.ts +2 -6
- package/dist/core/create-vite.js +36 -47
- package/dist/core/csp/common.d.ts +1 -1
- package/dist/core/csp/common.js +1 -1
- package/dist/core/csp/config.d.ts +8 -4
- package/dist/core/csp/config.js +1 -1
- package/dist/core/dev/container.js +13 -9
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/dev/restart.js +15 -6
- package/dist/core/errors/dev/runtime.d.ts +6 -0
- package/dist/core/errors/dev/runtime.js +27 -0
- package/dist/core/errors/dev/vite.js +2 -19
- package/dist/core/errors/errors-data.d.ts +85 -57
- package/dist/core/errors/errors-data.js +40 -28
- package/dist/core/errors/errors.d.ts +3 -3
- package/dist/core/errors/errors.js +1 -1
- package/dist/core/errors/overlay.js +1 -1
- package/dist/core/errors/zod-error-map.d.ts +2 -2
- package/dist/core/errors/zod-error-map.js +26 -24
- package/dist/core/messages.d.ts +2 -2
- package/dist/core/messages.js +2 -2
- package/dist/core/middleware/callMiddleware.js +1 -1
- package/dist/core/middleware/defineMiddleware.d.ts +2 -0
- package/dist/core/middleware/defineMiddleware.js +6 -0
- package/dist/core/middleware/index.d.ts +4 -4
- package/dist/core/middleware/index.js +6 -12
- package/dist/core/middleware/sequence.js +4 -4
- package/dist/core/middleware/vite-plugin.d.ts +1 -1
- package/dist/core/middleware/vite-plugin.js +18 -7
- package/dist/core/module-loader/index.d.ts +2 -2
- package/dist/core/module-loader/index.js +1 -1
- package/dist/core/module-loader/{loader.d.ts → runner.d.ts} +6 -17
- package/dist/core/module-loader/{loader.js → runner.js} +3 -0
- package/dist/core/module-loader/vite.d.ts +3 -2
- package/dist/core/module-loader/vite.js +17 -13
- package/dist/core/preview/index.js +20 -5
- package/dist/core/preview/static-preview-server.js +1 -0
- package/dist/core/redirects/component.js +1 -2
- package/dist/core/redirects/index.d.ts +0 -1
- package/dist/core/redirects/index.js +1 -3
- package/dist/core/redirects/render.js +5 -2
- package/dist/core/render/paginate.d.ts +1 -1
- package/dist/core/render/paginate.js +8 -6
- package/dist/core/render/params-and-props.d.ts +2 -0
- package/dist/core/render/params-and-props.js +19 -7
- package/dist/core/render/route-cache.d.ts +3 -3
- package/dist/core/render/route-cache.js +7 -7
- package/dist/core/render-context.d.ts +9 -7
- package/dist/core/render-context.js +46 -47
- package/dist/core/routing/astro-designed-error-pages.js +2 -2
- package/dist/core/routing/default.js +1 -1
- package/dist/core/routing/helpers.d.ts +22 -0
- package/dist/core/routing/helpers.js +25 -0
- package/dist/core/routing/index.d.ts +1 -1
- package/dist/core/routing/index.js +2 -2
- package/dist/core/routing/manifest/create.d.ts +6 -1
- package/dist/core/routing/manifest/create.js +9 -13
- package/dist/core/routing/manifest/generator.d.ts +3 -1
- package/dist/core/routing/params.d.ts +2 -1
- package/dist/core/routing/params.js +8 -8
- package/dist/core/routing/validation.d.ts +1 -2
- package/dist/core/routing/validation.js +2 -18
- package/dist/core/server-islands/endpoint.d.ts +1 -2
- package/dist/core/server-islands/endpoint.js +5 -4
- package/dist/core/server-islands/vite-plugin-server-islands.d.ts +1 -1
- package/dist/core/server-islands/vite-plugin-server-islands.js +89 -44
- package/dist/core/session/vite-plugin.d.ts +6 -0
- package/dist/core/session/vite-plugin.js +53 -0
- package/dist/core/session.d.ts +4 -2
- package/dist/core/session.js +8 -48
- package/dist/core/sync/index.d.ts +2 -5
- package/dist/core/sync/index.js +19 -34
- package/dist/core/util.d.ts +2 -2
- package/dist/core/util.js +3 -3
- package/dist/entrypoints/legacy.d.ts +2 -0
- package/dist/entrypoints/legacy.js +12 -0
- package/dist/entrypoints/prerender.d.ts +4 -0
- package/dist/entrypoints/prerender.js +7 -0
- package/dist/env/env-loader.d.ts +0 -1
- package/dist/env/env-loader.js +4 -17
- package/dist/env/schema.d.ts +21 -251
- package/dist/env/schema.js +6 -3
- package/dist/env/vite-plugin-env.js +3 -2
- package/dist/env/vite-plugin-import-meta-env.js +3 -2
- package/dist/environments.d.ts +3 -0
- package/dist/environments.js +11 -0
- package/dist/events/error.d.ts +2 -2
- package/dist/i18n/index.d.ts +2 -2
- package/dist/i18n/index.js +0 -3
- package/dist/i18n/utils.d.ts +1 -6
- package/dist/i18n/utils.js +1 -63
- package/dist/i18n/vite-plugin-i18n.d.ts +0 -5
- package/dist/i18n/vite-plugin-i18n.js +1 -22
- package/dist/integrations/hooks.d.ts +2 -3
- package/dist/integrations/hooks.js +9 -33
- package/dist/manifest/serialized.d.ts +9 -0
- package/dist/manifest/serialized.js +144 -0
- package/dist/manifest/virtual-module.d.ts +1 -4
- package/dist/manifest/virtual-module.js +77 -80
- package/dist/preferences/index.d.ts +1 -2
- package/dist/prefetch/index.d.ts +0 -10
- package/dist/prefetch/index.js +1 -1
- package/dist/prerender/routing.d.ts +5 -7
- package/dist/prerender/routing.js +6 -17
- package/dist/runtime/server/astro-global.d.ts +2 -2
- package/dist/runtime/server/astro-global.js +86 -24
- package/dist/runtime/server/render/server-islands.js +2 -2
- package/dist/runtime/server/transition.d.ts +1 -0
- package/dist/transitions/events.d.ts +7 -0
- package/dist/transitions/router.js +7 -3
- package/dist/transitions/vite-plugin-transitions.js +1 -4
- package/dist/types/astro.d.ts +10 -8
- package/dist/types/public/common.d.ts +1 -3
- package/dist/types/public/config.d.ts +364 -415
- package/dist/types/public/context.d.ts +21 -52
- package/dist/types/public/index.d.ts +2 -1
- package/dist/types/public/integrations.d.ts +23 -18
- package/dist/types/public/internal.d.ts +3 -18
- package/dist/types/public/preview.d.ts +6 -0
- package/dist/virtual-modules/i18n.d.ts +10 -2
- package/dist/virtual-modules/i18n.js +16 -7
- package/dist/virtual-modules/live-config.d.ts +1 -3
- package/dist/virtual-modules/live-config.js +1 -5
- package/dist/virtual-modules/middleware.d.ts +2 -1
- package/dist/virtual-modules/middleware.js +2 -1
- package/dist/vite-plugin-adapter-config/index.js +3 -2
- package/dist/vite-plugin-app/app.d.ts +47 -0
- package/dist/vite-plugin-app/app.js +410 -0
- package/dist/vite-plugin-app/createAstroServerApp.d.ts +8 -0
- package/dist/vite-plugin-app/createAstroServerApp.js +56 -0
- package/dist/vite-plugin-app/index.d.ts +3 -0
- package/dist/vite-plugin-app/index.js +16 -0
- package/dist/{vite-plugin-astro-server → vite-plugin-app}/pipeline.d.ts +5 -7
- package/dist/vite-plugin-app/pipeline.js +166 -0
- package/dist/vite-plugin-astro/index.js +11 -13
- package/dist/vite-plugin-astro-server/controller.d.ts +1 -1
- package/dist/vite-plugin-astro-server/error.d.ts +3 -4
- package/dist/vite-plugin-astro-server/error.js +2 -5
- package/dist/vite-plugin-astro-server/index.d.ts +1 -2
- package/dist/vite-plugin-astro-server/index.js +6 -4
- package/dist/vite-plugin-astro-server/metadata.js +1 -1
- package/dist/vite-plugin-astro-server/plugin.d.ts +4 -7
- package/dist/vite-plugin-astro-server/plugin.js +53 -96
- package/dist/vite-plugin-astro-server/server-state.d.ts +1 -1
- package/dist/vite-plugin-astro-server/util.d.ts +0 -2
- package/dist/vite-plugin-astro-server/util.js +1 -2
- package/dist/vite-plugin-astro-server/vite.d.ts +2 -2
- package/dist/vite-plugin-astro-server/vite.js +7 -7
- package/dist/vite-plugin-config-alias/index.js +40 -32
- package/dist/vite-plugin-css/index.d.ts +18 -0
- package/dist/vite-plugin-css/index.js +134 -0
- package/dist/vite-plugin-css/util.d.ts +5 -0
- package/dist/vite-plugin-css/util.js +8 -0
- package/dist/vite-plugin-environment/index.d.ts +15 -0
- package/dist/vite-plugin-environment/index.js +77 -0
- package/dist/vite-plugin-head/index.d.ts +1 -2
- package/dist/vite-plugin-head/index.js +42 -58
- package/dist/vite-plugin-hmr-reload/index.js +2 -1
- package/dist/vite-plugin-markdown/index.js +0 -1
- package/dist/vite-plugin-pages/const.d.ts +2 -0
- package/dist/vite-plugin-pages/const.js +6 -0
- package/dist/vite-plugin-pages/index.d.ts +2 -0
- package/dist/vite-plugin-pages/index.js +7 -0
- package/dist/vite-plugin-pages/page.d.ts +7 -0
- package/dist/vite-plugin-pages/page.js +48 -0
- package/dist/vite-plugin-pages/pages.d.ts +8 -0
- package/dist/vite-plugin-pages/pages.js +57 -0
- package/dist/vite-plugin-pages/util.d.ts +8 -0
- package/dist/vite-plugin-pages/util.js +15 -0
- package/dist/vite-plugin-renderers/index.d.ts +9 -0
- package/dist/vite-plugin-renderers/index.js +40 -0
- package/dist/vite-plugin-routes/index.d.ts +14 -0
- package/dist/vite-plugin-routes/index.js +177 -0
- package/dist/vite-plugin-scripts/index.js +2 -6
- package/dist/vite-plugin-scripts/page-ssr.js +3 -2
- package/dist/zod.d.ts +2 -2
- package/dist/zod.js +2 -2
- package/package.json +14 -15
- package/templates/content/module.mjs +9 -63
- package/templates/content/types.d.ts +32 -78
- package/types/actions.d.ts +1 -5
- package/types/content.d.ts +9 -11
- package/types/transitions.d.ts +25 -0
- package/dist/actions/loadActions.d.ts +0 -8
- package/dist/actions/loadActions.js +0 -13
- package/dist/actions/runtime/route.d.ts +0 -2
- package/dist/actions/runtime/shared.d.ts +0 -60
- package/dist/actions/runtime/shared.js +0 -296
- package/dist/actions/runtime/utils.d.ts +0 -31
- package/dist/actions/runtime/utils.js +0 -16
- package/dist/actions/runtime/virtual.d.ts +0 -4
- package/dist/actions/runtime/virtual.js +0 -127
- package/dist/assets/utils/node/emitAsset.d.ts +0 -29
- package/dist/assets/utils/transformToPath.js +0 -32
- package/dist/config/vite-plugin-content-listen.d.ts +0 -17
- package/dist/config/vite-plugin-content-listen.js +0 -26
- package/dist/container/polyfill.d.ts +0 -1
- package/dist/container/polyfill.js +0 -2
- package/dist/core/build/css-asset-name.d.ts +0 -9
- package/dist/core/build/css-asset-name.js +0 -89
- package/dist/core/build/plugin.d.ts +0 -43
- package/dist/core/build/plugin.js +0 -61
- package/dist/core/build/plugins/plugin-actions.d.ts +0 -4
- package/dist/core/build/plugins/plugin-actions.js +0 -16
- package/dist/core/build/plugins/plugin-chunks.d.ts +0 -2
- package/dist/core/build/plugins/plugin-chunks.js +0 -33
- package/dist/core/build/plugins/plugin-pages.d.ts +0 -6
- package/dist/core/build/plugins/plugin-pages.js +0 -66
- package/dist/core/build/plugins/plugin-renderers.d.ts +0 -5
- package/dist/core/build/plugins/plugin-renderers.js +0 -54
- package/dist/core/middleware/loadMiddleware.d.ts +0 -7
- package/dist/core/middleware/loadMiddleware.js +0 -14
- package/dist/core/polyfill.d.ts +0 -5
- package/dist/core/polyfill.js +0 -17
- package/dist/core/redirects/helpers.d.ts +0 -7
- package/dist/core/redirects/helpers.js +0 -10
- package/dist/core/routing/manifest/serialization.d.ts +0 -5
- package/dist/core/routing/manifest/serialization.js +0 -37
- package/dist/prerender/metadata.d.ts +0 -8
- package/dist/prerender/metadata.js +0 -18
- package/dist/vite-plugin-astro-postprocess/index.d.ts +0 -2
- package/dist/vite-plugin-astro-postprocess/index.js +0 -48
- package/dist/vite-plugin-astro-server/css.d.ts +0 -13
- package/dist/vite-plugin-astro-server/css.js +0 -48
- package/dist/vite-plugin-astro-server/pipeline.js +0 -166
- package/dist/vite-plugin-astro-server/request.d.ts +0 -14
- package/dist/vite-plugin-astro-server/request.js +0 -73
- package/dist/vite-plugin-astro-server/route.d.ts +0 -25
- package/dist/vite-plugin-astro-server/route.js +0 -283
- package/dist/vite-plugin-scanner/index.d.ts +0 -10
- package/dist/vite-plugin-scanner/index.js +0 -87
- package/dist/vite-plugin-ssr-manifest/index.d.ts +0 -2
- package/dist/vite-plugin-ssr-manifest/index.js +0 -26
|
@@ -15,21 +15,13 @@ declare module 'astro:content' {
|
|
|
15
15
|
[key: string]: unknown;
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
-
}
|
|
19
18
|
|
|
20
|
-
declare module 'astro:content' {
|
|
21
19
|
type Flatten<T> = T extends { [K: string]: infer U } ? U : never;
|
|
22
20
|
|
|
23
|
-
export type CollectionKey = keyof
|
|
24
|
-
export type CollectionEntry<C extends CollectionKey> = Flatten<
|
|
25
|
-
|
|
26
|
-
export type ContentCollectionKey = keyof ContentEntryMap;
|
|
27
|
-
export type DataCollectionKey = keyof DataEntryMap;
|
|
21
|
+
export type CollectionKey = keyof DataEntryMap;
|
|
22
|
+
export type CollectionEntry<C extends CollectionKey> = Flatten<DataEntryMap[C]>;
|
|
28
23
|
|
|
29
24
|
type AllValuesOf<T> = T extends any ? T[keyof T] : never;
|
|
30
|
-
type ValidContentEntrySlug<C extends keyof ContentEntryMap> = AllValuesOf<
|
|
31
|
-
ContentEntryMap[C]
|
|
32
|
-
>['slug'];
|
|
33
25
|
|
|
34
26
|
export type ReferenceDataEntry<
|
|
35
27
|
C extends CollectionKey,
|
|
@@ -38,41 +30,17 @@ declare module 'astro:content' {
|
|
|
38
30
|
collection: C;
|
|
39
31
|
id: E;
|
|
40
32
|
};
|
|
41
|
-
|
|
42
|
-
C extends keyof ContentEntryMap,
|
|
43
|
-
E extends ValidContentEntrySlug<C> | (string & {}) = string,
|
|
44
|
-
> = {
|
|
45
|
-
collection: C;
|
|
46
|
-
slug: E;
|
|
47
|
-
};
|
|
33
|
+
|
|
48
34
|
export type ReferenceLiveEntry<C extends keyof LiveContentConfig['collections']> = {
|
|
49
35
|
collection: C;
|
|
50
36
|
id: string;
|
|
51
37
|
};
|
|
52
38
|
|
|
53
|
-
|
|
54
|
-
export function getEntryBySlug<
|
|
55
|
-
C extends keyof ContentEntryMap,
|
|
56
|
-
E extends ValidContentEntrySlug<C> | (string & {}),
|
|
57
|
-
>(
|
|
58
|
-
collection: C,
|
|
59
|
-
// Note that this has to accept a regular string too, for SSR
|
|
60
|
-
entrySlug: E,
|
|
61
|
-
): E extends ValidContentEntrySlug<C>
|
|
62
|
-
? Promise<CollectionEntry<C>>
|
|
63
|
-
: Promise<CollectionEntry<C> | undefined>;
|
|
64
|
-
|
|
65
|
-
/** @deprecated Use `getEntry` instead. */
|
|
66
|
-
export function getDataEntryById<C extends keyof DataEntryMap, E extends keyof DataEntryMap[C]>(
|
|
67
|
-
collection: C,
|
|
68
|
-
entryId: E,
|
|
69
|
-
): Promise<CollectionEntry<C>>;
|
|
70
|
-
|
|
71
|
-
export function getCollection<C extends keyof AnyEntryMap, E extends CollectionEntry<C>>(
|
|
39
|
+
export function getCollection<C extends keyof DataEntryMap, E extends CollectionEntry<C>>(
|
|
72
40
|
collection: C,
|
|
73
41
|
filter?: (entry: CollectionEntry<C>) => entry is E,
|
|
74
42
|
): Promise<E[]>;
|
|
75
|
-
export function getCollection<C extends keyof
|
|
43
|
+
export function getCollection<C extends keyof DataEntryMap>(
|
|
76
44
|
collection: C,
|
|
77
45
|
filter?: (entry: CollectionEntry<C>) => unknown,
|
|
78
46
|
): Promise<CollectionEntry<C>[]>;
|
|
@@ -84,14 +52,6 @@ declare module 'astro:content' {
|
|
|
84
52
|
import('astro').LiveDataCollectionResult<LiveLoaderDataType<C>, LiveLoaderErrorType<C>>
|
|
85
53
|
>;
|
|
86
54
|
|
|
87
|
-
export function getEntry<
|
|
88
|
-
C extends keyof ContentEntryMap,
|
|
89
|
-
E extends ValidContentEntrySlug<C> | (string & {}),
|
|
90
|
-
>(
|
|
91
|
-
entry: ReferenceContentEntry<C, E>,
|
|
92
|
-
): E extends ValidContentEntrySlug<C>
|
|
93
|
-
? Promise<CollectionEntry<C>>
|
|
94
|
-
: Promise<CollectionEntry<C> | undefined>;
|
|
95
55
|
export function getEntry<
|
|
96
56
|
C extends keyof DataEntryMap,
|
|
97
57
|
E extends keyof DataEntryMap[C] | (string & {}),
|
|
@@ -100,15 +60,6 @@ declare module 'astro:content' {
|
|
|
100
60
|
): E extends keyof DataEntryMap[C]
|
|
101
61
|
? Promise<DataEntryMap[C][E]>
|
|
102
62
|
: Promise<CollectionEntry<C> | undefined>;
|
|
103
|
-
export function getEntry<
|
|
104
|
-
C extends keyof ContentEntryMap,
|
|
105
|
-
E extends ValidContentEntrySlug<C> | (string & {}),
|
|
106
|
-
>(
|
|
107
|
-
collection: C,
|
|
108
|
-
slug: E,
|
|
109
|
-
): E extends ValidContentEntrySlug<C>
|
|
110
|
-
? Promise<CollectionEntry<C>>
|
|
111
|
-
: Promise<CollectionEntry<C> | undefined>;
|
|
112
63
|
export function getEntry<
|
|
113
64
|
C extends keyof DataEntryMap,
|
|
114
65
|
E extends keyof DataEntryMap[C] | (string & {}),
|
|
@@ -126,47 +77,51 @@ declare module 'astro:content' {
|
|
|
126
77
|
): Promise<import('astro').LiveDataEntryResult<LiveLoaderDataType<C>, LiveLoaderErrorType<C>>>;
|
|
127
78
|
|
|
128
79
|
/** Resolve an array of entry references from the same collection */
|
|
129
|
-
export function getEntries<C extends keyof ContentEntryMap>(
|
|
130
|
-
entries: ReferenceContentEntry<C, ValidContentEntrySlug<C>>[],
|
|
131
|
-
): Promise<CollectionEntry<C>[]>;
|
|
132
80
|
export function getEntries<C extends keyof DataEntryMap>(
|
|
133
81
|
entries: ReferenceDataEntry<C, keyof DataEntryMap[C]>[],
|
|
134
82
|
): Promise<CollectionEntry<C>[]>;
|
|
135
83
|
|
|
136
|
-
export function render<C extends keyof
|
|
137
|
-
entry:
|
|
84
|
+
export function render<C extends keyof DataEntryMap>(
|
|
85
|
+
entry: DataEntryMap[C][string],
|
|
138
86
|
): Promise<RenderResult>;
|
|
139
87
|
|
|
140
|
-
export function reference<
|
|
88
|
+
export function reference<
|
|
89
|
+
C extends
|
|
90
|
+
| keyof DataEntryMap
|
|
91
|
+
// Allow generic `string` to avoid excessive type errors in the config
|
|
92
|
+
// if `dev` is not running to update as you edit.
|
|
93
|
+
// Invalid collection names will be caught at build time.
|
|
94
|
+
| (string & {}),
|
|
95
|
+
>(
|
|
141
96
|
collection: C,
|
|
142
|
-
): import('astro/zod').
|
|
97
|
+
): import('astro/zod').ZodPipe<
|
|
143
98
|
import('astro/zod').ZodString,
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
99
|
+
import('astro/zod').ZodTransform<
|
|
100
|
+
C extends keyof DataEntryMap
|
|
101
|
+
? {
|
|
102
|
+
collection: C;
|
|
103
|
+
id: string;
|
|
104
|
+
}
|
|
105
|
+
: never,
|
|
106
|
+
string
|
|
107
|
+
>
|
|
147
108
|
>;
|
|
148
|
-
// Allow generic `string` to avoid excessive type errors in the config
|
|
149
|
-
// if `dev` is not running to update as you edit.
|
|
150
|
-
// Invalid collection names will be caught at build time.
|
|
151
|
-
export function reference<C extends string>(
|
|
152
|
-
collection: C,
|
|
153
|
-
): import('astro/zod').ZodEffects<import('astro/zod').ZodString, never>;
|
|
154
109
|
|
|
155
110
|
type ReturnTypeOrOriginal<T> = T extends (...args: any[]) => infer R ? R : T;
|
|
156
|
-
type InferEntrySchema<C extends keyof
|
|
111
|
+
type InferEntrySchema<C extends keyof DataEntryMap> = import('astro/zod').infer<
|
|
157
112
|
ReturnTypeOrOriginal<Required<ContentConfig['collections'][C]>['schema']>
|
|
158
113
|
>;
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
114
|
+
type InferLoaderSchema<
|
|
115
|
+
C extends keyof DataEntryMap,
|
|
116
|
+
L = Required<ContentConfig['collections'][C]>['loader'],
|
|
117
|
+
> = L extends { schema: import('astro/zod').ZodSchema }
|
|
118
|
+
? import('astro/zod').infer<Required<ContentConfig['collections'][C]>['loader']['schema']>
|
|
119
|
+
: any;
|
|
163
120
|
|
|
164
121
|
type DataEntryMap = {
|
|
165
122
|
// @@DATA_ENTRY_MAP@@
|
|
166
123
|
};
|
|
167
124
|
|
|
168
|
-
type AnyEntryMap = ContentEntryMap & DataEntryMap;
|
|
169
|
-
|
|
170
125
|
type ExtractLoaderTypes<T> = T extends import('astro/loaders').LiveLoader<
|
|
171
126
|
infer TData,
|
|
172
127
|
infer TEntryFilter,
|
|
@@ -175,7 +130,6 @@ declare module 'astro:content' {
|
|
|
175
130
|
>
|
|
176
131
|
? { data: TData; entryFilter: TEntryFilter; collectionFilter: TCollectionFilter; error: TError }
|
|
177
132
|
: { data: never; entryFilter: never; collectionFilter: never; error: never };
|
|
178
|
-
type ExtractDataType<T> = ExtractLoaderTypes<T>['data'];
|
|
179
133
|
type ExtractEntryFilterType<T> = ExtractLoaderTypes<T>['entryFilter'];
|
|
180
134
|
type ExtractCollectionFilterType<T> = ExtractLoaderTypes<T>['collectionFilter'];
|
|
181
135
|
type ExtractErrorType<T> = ExtractLoaderTypes<T>['error'];
|
package/types/actions.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
1
|
declare module 'astro:actions' {
|
|
2
|
-
export * from 'astro/actions/runtime/server.js';
|
|
3
|
-
|
|
4
|
-
export function getActionPath(
|
|
5
|
-
action: import('astro/actions/runtime/server.js').ActionClient<any, any, any>,
|
|
6
|
-
): string;
|
|
2
|
+
export * from 'astro/actions/runtime/entrypoints/server.js';
|
|
7
3
|
}
|
package/types/content.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare module 'astro:content' {
|
|
2
|
-
|
|
2
|
+
import zod from 'astro/zod';
|
|
3
3
|
export type {
|
|
4
4
|
ImageFunction,
|
|
5
5
|
DataEntry,
|
|
@@ -8,17 +8,15 @@ declare module 'astro:content' {
|
|
|
8
8
|
BaseSchema,
|
|
9
9
|
SchemaContext,
|
|
10
10
|
} from 'astro/content/config';
|
|
11
|
+
export { defineLiveCollection, defineCollection } from 'astro/content/config';
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export function defineCollection<S extends import('astro/content/config').BaseSchema>(
|
|
20
|
-
config: import('astro/content/config').CollectionConfig<S>,
|
|
21
|
-
): import('astro/content/config').CollectionConfig<S>;
|
|
13
|
+
// TODO: remove in Astro 7
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated
|
|
16
|
+
* `import { z } from 'astro:content'` is deprecated and will be removed
|
|
17
|
+
* in Astro 7. Use `import { z } from 'astro/zod'` instead.
|
|
18
|
+
*/
|
|
19
|
+
export const z = zod.z;
|
|
22
20
|
|
|
23
21
|
/** Run `astro dev` or `astro sync` to generate high fidelity types */
|
|
24
22
|
export const getEntryBySlug: (...args: any[]) => any;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
declare module 'astro:transitions' {
|
|
2
|
+
export * from 'astro/virtual-modules/transitions.js';
|
|
3
|
+
export { default as ClientRouter } from 'astro/components/ClientRouter.astro';
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
declare module 'astro:transitions/client' {
|
|
7
|
+
export {
|
|
8
|
+
navigate,
|
|
9
|
+
supportsViewTransitions,
|
|
10
|
+
transitionEnabledOnThisPage,
|
|
11
|
+
} from 'astro/virtual-modules/transitions-router.js';
|
|
12
|
+
export * from 'astro/virtual-modules/transitions-types.js';
|
|
13
|
+
export {
|
|
14
|
+
TRANSITION_BEFORE_PREPARATION,
|
|
15
|
+
isTransitionBeforePreparationEvent,
|
|
16
|
+
TransitionBeforePreparationEvent,
|
|
17
|
+
TRANSITION_AFTER_PREPARATION,
|
|
18
|
+
TRANSITION_BEFORE_SWAP,
|
|
19
|
+
isTransitionBeforeSwapEvent,
|
|
20
|
+
TransitionBeforeSwapEvent,
|
|
21
|
+
TRANSITION_AFTER_SWAP,
|
|
22
|
+
TRANSITION_PAGE_LOAD,
|
|
23
|
+
} from 'astro/virtual-modules/transitions-events.js';
|
|
24
|
+
export { swapFunctions } from 'astro/virtual-modules/transitions-swap-functions.js';
|
|
25
|
+
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { SSRActions } from '../core/app/types.js';
|
|
2
|
-
import type { ModuleLoader } from '../core/module-loader/index.js';
|
|
3
|
-
/**
|
|
4
|
-
* It accepts a module loader and the astro settings, and it attempts to load the middlewares defined in the configuration.
|
|
5
|
-
*
|
|
6
|
-
* If not middlewares were not set, the function returns an empty array.
|
|
7
|
-
*/
|
|
8
|
-
export declare function loadActions(moduleLoader: ModuleLoader): Promise<SSRActions>;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ActionsCantBeLoaded } from "../core/errors/errors-data.js";
|
|
2
|
-
import { AstroError } from "../core/errors/index.js";
|
|
3
|
-
import { ENTRYPOINT_VIRTUAL_MODULE_ID } from "./consts.js";
|
|
4
|
-
async function loadActions(moduleLoader) {
|
|
5
|
-
try {
|
|
6
|
-
return await moduleLoader.import(ENTRYPOINT_VIRTUAL_MODULE_ID);
|
|
7
|
-
} catch (error) {
|
|
8
|
-
throw new AstroError(ActionsCantBeLoaded, { cause: error });
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
export {
|
|
12
|
-
loadActions
|
|
13
|
-
};
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import type { z } from 'zod';
|
|
2
|
-
import { AstroError } from '../../core/errors/errors.js';
|
|
3
|
-
import { appendForwardSlash as _appendForwardSlash } from '../../core/path.js';
|
|
4
|
-
import type { ActionAPIContext as _ActionAPIContext, ErrorInferenceObject, MaybePromise } from './utils.js';
|
|
5
|
-
export type ActionAPIContext = _ActionAPIContext;
|
|
6
|
-
export declare const ACTION_QUERY_PARAMS: {
|
|
7
|
-
actionName: string;
|
|
8
|
-
actionPayload: string;
|
|
9
|
-
};
|
|
10
|
-
export declare const appendForwardSlash: typeof _appendForwardSlash;
|
|
11
|
-
export declare const ACTION_ERROR_CODES: readonly ["BAD_REQUEST", "UNAUTHORIZED", "PAYMENT_REQUIRED", "FORBIDDEN", "NOT_FOUND", "METHOD_NOT_ALLOWED", "NOT_ACCEPTABLE", "PROXY_AUTHENTICATION_REQUIRED", "REQUEST_TIMEOUT", "CONFLICT", "GONE", "LENGTH_REQUIRED", "PRECONDITION_FAILED", "CONTENT_TOO_LARGE", "URI_TOO_LONG", "UNSUPPORTED_MEDIA_TYPE", "RANGE_NOT_SATISFIABLE", "EXPECTATION_FAILED", "MISDIRECTED_REQUEST", "UNPROCESSABLE_CONTENT", "LOCKED", "FAILED_DEPENDENCY", "TOO_EARLY", "UPGRADE_REQUIRED", "PRECONDITION_REQUIRED", "TOO_MANY_REQUESTS", "REQUEST_HEADER_FIELDS_TOO_LARGE", "UNAVAILABLE_FOR_LEGAL_REASONS", "INTERNAL_SERVER_ERROR", "NOT_IMPLEMENTED", "BAD_GATEWAY", "SERVICE_UNAVAILABLE", "GATEWAY_TIMEOUT", "HTTP_VERSION_NOT_SUPPORTED", "VARIANT_ALSO_NEGOTIATES", "INSUFFICIENT_STORAGE", "LOOP_DETECTED", "NETWORK_AUTHENTICATION_REQUIRED"];
|
|
12
|
-
export type ActionErrorCode = (typeof ACTION_ERROR_CODES)[number];
|
|
13
|
-
export declare class ActionError<_T extends ErrorInferenceObject = ErrorInferenceObject> extends Error {
|
|
14
|
-
type: string;
|
|
15
|
-
code: ActionErrorCode;
|
|
16
|
-
status: number;
|
|
17
|
-
constructor(params: {
|
|
18
|
-
message?: string;
|
|
19
|
-
code: ActionErrorCode;
|
|
20
|
-
stack?: string;
|
|
21
|
-
});
|
|
22
|
-
static codeToStatus(code: ActionErrorCode): number;
|
|
23
|
-
static statusToCode(status: number): ActionErrorCode;
|
|
24
|
-
static fromJson(body: any): ActionError<ErrorInferenceObject>;
|
|
25
|
-
}
|
|
26
|
-
export declare function isActionError(error?: unknown): error is ActionError;
|
|
27
|
-
export declare function isInputError<T extends ErrorInferenceObject>(error?: ActionError<T>): error is ActionInputError<T>;
|
|
28
|
-
export declare function isInputError(error?: unknown): error is ActionInputError<ErrorInferenceObject>;
|
|
29
|
-
export type SafeResult<TInput extends ErrorInferenceObject, TOutput> = {
|
|
30
|
-
data: TOutput;
|
|
31
|
-
error: undefined;
|
|
32
|
-
} | {
|
|
33
|
-
data: undefined;
|
|
34
|
-
error: ActionError<TInput>;
|
|
35
|
-
};
|
|
36
|
-
export declare class ActionInputError<T extends ErrorInferenceObject> extends ActionError {
|
|
37
|
-
type: string;
|
|
38
|
-
issues: z.ZodIssue[];
|
|
39
|
-
fields: z.ZodError<T>['formErrors']['fieldErrors'];
|
|
40
|
-
constructor(issues: z.ZodIssue[]);
|
|
41
|
-
}
|
|
42
|
-
export declare function callSafely<TOutput>(handler: () => MaybePromise<TOutput>): Promise<SafeResult<z.ZodType, TOutput>>;
|
|
43
|
-
export declare function getActionQueryString(name: string): string;
|
|
44
|
-
export type SerializedActionResult = {
|
|
45
|
-
type: 'data';
|
|
46
|
-
contentType: 'application/json+devalue';
|
|
47
|
-
status: 200;
|
|
48
|
-
body: string;
|
|
49
|
-
} | {
|
|
50
|
-
type: 'error';
|
|
51
|
-
contentType: 'application/json';
|
|
52
|
-
status: number;
|
|
53
|
-
body: string;
|
|
54
|
-
} | {
|
|
55
|
-
type: 'empty';
|
|
56
|
-
status: 204;
|
|
57
|
-
};
|
|
58
|
-
export declare function serializeActionResult(res: SafeResult<any, any>): SerializedActionResult;
|
|
59
|
-
export declare function deserializeActionResult(res: SerializedActionResult): SafeResult<any, any>;
|
|
60
|
-
export declare function astroCalledServerError(): AstroError;
|
|
@@ -1,296 +0,0 @@
|
|
|
1
|
-
import { parse as devalueParse, stringify as devalueStringify } from "devalue";
|
|
2
|
-
import { REDIRECT_STATUS_CODES } from "../../core/constants.js";
|
|
3
|
-
import { AstroError } from "../../core/errors/errors.js";
|
|
4
|
-
import {
|
|
5
|
-
ActionCalledFromServerError,
|
|
6
|
-
ActionsReturnedInvalidDataError
|
|
7
|
-
} from "../../core/errors/errors-data.js";
|
|
8
|
-
import { appendForwardSlash as _appendForwardSlash } from "../../core/path.js";
|
|
9
|
-
import { ACTION_QUERY_PARAMS as _ACTION_QUERY_PARAMS } from "../consts.js";
|
|
10
|
-
const ACTION_QUERY_PARAMS = _ACTION_QUERY_PARAMS;
|
|
11
|
-
const appendForwardSlash = _appendForwardSlash;
|
|
12
|
-
const ACTION_ERROR_CODES = [
|
|
13
|
-
"BAD_REQUEST",
|
|
14
|
-
"UNAUTHORIZED",
|
|
15
|
-
"PAYMENT_REQUIRED",
|
|
16
|
-
"FORBIDDEN",
|
|
17
|
-
"NOT_FOUND",
|
|
18
|
-
"METHOD_NOT_ALLOWED",
|
|
19
|
-
"NOT_ACCEPTABLE",
|
|
20
|
-
"PROXY_AUTHENTICATION_REQUIRED",
|
|
21
|
-
"REQUEST_TIMEOUT",
|
|
22
|
-
"CONFLICT",
|
|
23
|
-
"GONE",
|
|
24
|
-
"LENGTH_REQUIRED",
|
|
25
|
-
"PRECONDITION_FAILED",
|
|
26
|
-
"CONTENT_TOO_LARGE",
|
|
27
|
-
"URI_TOO_LONG",
|
|
28
|
-
"UNSUPPORTED_MEDIA_TYPE",
|
|
29
|
-
"RANGE_NOT_SATISFIABLE",
|
|
30
|
-
"EXPECTATION_FAILED",
|
|
31
|
-
"MISDIRECTED_REQUEST",
|
|
32
|
-
"UNPROCESSABLE_CONTENT",
|
|
33
|
-
"LOCKED",
|
|
34
|
-
"FAILED_DEPENDENCY",
|
|
35
|
-
"TOO_EARLY",
|
|
36
|
-
"UPGRADE_REQUIRED",
|
|
37
|
-
"PRECONDITION_REQUIRED",
|
|
38
|
-
"TOO_MANY_REQUESTS",
|
|
39
|
-
"REQUEST_HEADER_FIELDS_TOO_LARGE",
|
|
40
|
-
"UNAVAILABLE_FOR_LEGAL_REASONS",
|
|
41
|
-
"INTERNAL_SERVER_ERROR",
|
|
42
|
-
"NOT_IMPLEMENTED",
|
|
43
|
-
"BAD_GATEWAY",
|
|
44
|
-
"SERVICE_UNAVAILABLE",
|
|
45
|
-
"GATEWAY_TIMEOUT",
|
|
46
|
-
"HTTP_VERSION_NOT_SUPPORTED",
|
|
47
|
-
"VARIANT_ALSO_NEGOTIATES",
|
|
48
|
-
"INSUFFICIENT_STORAGE",
|
|
49
|
-
"LOOP_DETECTED",
|
|
50
|
-
"NETWORK_AUTHENTICATION_REQUIRED"
|
|
51
|
-
];
|
|
52
|
-
const codeToStatusMap = {
|
|
53
|
-
// Implemented from IANA HTTP Status Code Registry
|
|
54
|
-
// https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
|
|
55
|
-
BAD_REQUEST: 400,
|
|
56
|
-
UNAUTHORIZED: 401,
|
|
57
|
-
PAYMENT_REQUIRED: 402,
|
|
58
|
-
FORBIDDEN: 403,
|
|
59
|
-
NOT_FOUND: 404,
|
|
60
|
-
METHOD_NOT_ALLOWED: 405,
|
|
61
|
-
NOT_ACCEPTABLE: 406,
|
|
62
|
-
PROXY_AUTHENTICATION_REQUIRED: 407,
|
|
63
|
-
REQUEST_TIMEOUT: 408,
|
|
64
|
-
CONFLICT: 409,
|
|
65
|
-
GONE: 410,
|
|
66
|
-
LENGTH_REQUIRED: 411,
|
|
67
|
-
PRECONDITION_FAILED: 412,
|
|
68
|
-
CONTENT_TOO_LARGE: 413,
|
|
69
|
-
URI_TOO_LONG: 414,
|
|
70
|
-
UNSUPPORTED_MEDIA_TYPE: 415,
|
|
71
|
-
RANGE_NOT_SATISFIABLE: 416,
|
|
72
|
-
EXPECTATION_FAILED: 417,
|
|
73
|
-
MISDIRECTED_REQUEST: 421,
|
|
74
|
-
UNPROCESSABLE_CONTENT: 422,
|
|
75
|
-
LOCKED: 423,
|
|
76
|
-
FAILED_DEPENDENCY: 424,
|
|
77
|
-
TOO_EARLY: 425,
|
|
78
|
-
UPGRADE_REQUIRED: 426,
|
|
79
|
-
PRECONDITION_REQUIRED: 428,
|
|
80
|
-
TOO_MANY_REQUESTS: 429,
|
|
81
|
-
REQUEST_HEADER_FIELDS_TOO_LARGE: 431,
|
|
82
|
-
UNAVAILABLE_FOR_LEGAL_REASONS: 451,
|
|
83
|
-
INTERNAL_SERVER_ERROR: 500,
|
|
84
|
-
NOT_IMPLEMENTED: 501,
|
|
85
|
-
BAD_GATEWAY: 502,
|
|
86
|
-
SERVICE_UNAVAILABLE: 503,
|
|
87
|
-
GATEWAY_TIMEOUT: 504,
|
|
88
|
-
HTTP_VERSION_NOT_SUPPORTED: 505,
|
|
89
|
-
VARIANT_ALSO_NEGOTIATES: 506,
|
|
90
|
-
INSUFFICIENT_STORAGE: 507,
|
|
91
|
-
LOOP_DETECTED: 508,
|
|
92
|
-
NETWORK_AUTHENTICATION_REQUIRED: 511
|
|
93
|
-
};
|
|
94
|
-
const statusToCodeMap = Object.entries(codeToStatusMap).reduce(
|
|
95
|
-
// reverse the key-value pairs
|
|
96
|
-
(acc, [key, value]) => ({ ...acc, [value]: key }),
|
|
97
|
-
{}
|
|
98
|
-
);
|
|
99
|
-
class ActionError extends Error {
|
|
100
|
-
type = "AstroActionError";
|
|
101
|
-
code = "INTERNAL_SERVER_ERROR";
|
|
102
|
-
status = 500;
|
|
103
|
-
constructor(params) {
|
|
104
|
-
super(params.message);
|
|
105
|
-
this.code = params.code;
|
|
106
|
-
this.status = ActionError.codeToStatus(params.code);
|
|
107
|
-
if (params.stack) {
|
|
108
|
-
this.stack = params.stack;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
static codeToStatus(code) {
|
|
112
|
-
return codeToStatusMap[code];
|
|
113
|
-
}
|
|
114
|
-
static statusToCode(status) {
|
|
115
|
-
return statusToCodeMap[status] ?? "INTERNAL_SERVER_ERROR";
|
|
116
|
-
}
|
|
117
|
-
static fromJson(body) {
|
|
118
|
-
if (isInputError(body)) {
|
|
119
|
-
return new ActionInputError(body.issues);
|
|
120
|
-
}
|
|
121
|
-
if (isActionError(body)) {
|
|
122
|
-
return new ActionError(body);
|
|
123
|
-
}
|
|
124
|
-
return new ActionError({
|
|
125
|
-
code: "INTERNAL_SERVER_ERROR"
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
function isActionError(error) {
|
|
130
|
-
return typeof error === "object" && error != null && "type" in error && error.type === "AstroActionError";
|
|
131
|
-
}
|
|
132
|
-
function isInputError(error) {
|
|
133
|
-
return typeof error === "object" && error != null && "type" in error && error.type === "AstroActionInputError" && "issues" in error && Array.isArray(error.issues);
|
|
134
|
-
}
|
|
135
|
-
class ActionInputError extends ActionError {
|
|
136
|
-
type = "AstroActionInputError";
|
|
137
|
-
// We don't expose all ZodError properties.
|
|
138
|
-
// Not all properties will serialize from server to client,
|
|
139
|
-
// and we don't want to import the full ZodError object into the client.
|
|
140
|
-
issues;
|
|
141
|
-
fields;
|
|
142
|
-
constructor(issues) {
|
|
143
|
-
super({
|
|
144
|
-
message: `Failed to validate: ${JSON.stringify(issues, null, 2)}`,
|
|
145
|
-
code: "BAD_REQUEST"
|
|
146
|
-
});
|
|
147
|
-
this.issues = issues;
|
|
148
|
-
this.fields = {};
|
|
149
|
-
for (const issue of issues) {
|
|
150
|
-
if (issue.path.length > 0) {
|
|
151
|
-
const key = issue.path[0].toString();
|
|
152
|
-
this.fields[key] ??= [];
|
|
153
|
-
this.fields[key]?.push(issue.message);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
async function callSafely(handler) {
|
|
159
|
-
try {
|
|
160
|
-
const data = await handler();
|
|
161
|
-
return { data, error: void 0 };
|
|
162
|
-
} catch (e) {
|
|
163
|
-
if (e instanceof ActionError) {
|
|
164
|
-
return { data: void 0, error: e };
|
|
165
|
-
}
|
|
166
|
-
return {
|
|
167
|
-
data: void 0,
|
|
168
|
-
error: new ActionError({
|
|
169
|
-
message: e instanceof Error ? e.message : "Unknown error",
|
|
170
|
-
code: "INTERNAL_SERVER_ERROR"
|
|
171
|
-
})
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
function getActionQueryString(name) {
|
|
176
|
-
const searchParams = new URLSearchParams({ [_ACTION_QUERY_PARAMS.actionName]: name });
|
|
177
|
-
return `?${searchParams.toString()}`;
|
|
178
|
-
}
|
|
179
|
-
function serializeActionResult(res) {
|
|
180
|
-
if (res.error) {
|
|
181
|
-
if (import.meta.env?.DEV) {
|
|
182
|
-
actionResultErrorStack.set(res.error.stack);
|
|
183
|
-
}
|
|
184
|
-
let body2;
|
|
185
|
-
if (res.error instanceof ActionInputError) {
|
|
186
|
-
body2 = {
|
|
187
|
-
type: res.error.type,
|
|
188
|
-
issues: res.error.issues,
|
|
189
|
-
fields: res.error.fields
|
|
190
|
-
};
|
|
191
|
-
} else {
|
|
192
|
-
body2 = {
|
|
193
|
-
...res.error,
|
|
194
|
-
message: res.error.message
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
return {
|
|
198
|
-
type: "error",
|
|
199
|
-
status: res.error.status,
|
|
200
|
-
contentType: "application/json",
|
|
201
|
-
body: JSON.stringify(body2)
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
if (res.data === void 0) {
|
|
205
|
-
return {
|
|
206
|
-
type: "empty",
|
|
207
|
-
status: 204
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
let body;
|
|
211
|
-
try {
|
|
212
|
-
body = devalueStringify(res.data, {
|
|
213
|
-
// Add support for URL objects
|
|
214
|
-
URL: (value) => value instanceof URL && value.href
|
|
215
|
-
});
|
|
216
|
-
} catch (e) {
|
|
217
|
-
let hint = ActionsReturnedInvalidDataError.hint;
|
|
218
|
-
if (res.data instanceof Response) {
|
|
219
|
-
hint = REDIRECT_STATUS_CODES.includes(res.data.status) ? "If you need to redirect when the action succeeds, trigger a redirect where the action is called. See the Actions guide for server and client redirect examples: https://docs.astro.build/en/guides/actions." : "If you need to return a Response object, try using a server endpoint instead. See https://docs.astro.build/en/guides/endpoints/#server-endpoints-api-routes";
|
|
220
|
-
}
|
|
221
|
-
throw new AstroError({
|
|
222
|
-
...ActionsReturnedInvalidDataError,
|
|
223
|
-
message: ActionsReturnedInvalidDataError.message(String(e)),
|
|
224
|
-
hint
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
return {
|
|
228
|
-
type: "data",
|
|
229
|
-
status: 200,
|
|
230
|
-
contentType: "application/json+devalue",
|
|
231
|
-
body
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
function deserializeActionResult(res) {
|
|
235
|
-
if (res.type === "error") {
|
|
236
|
-
let json;
|
|
237
|
-
try {
|
|
238
|
-
json = JSON.parse(res.body);
|
|
239
|
-
} catch {
|
|
240
|
-
return {
|
|
241
|
-
data: void 0,
|
|
242
|
-
error: new ActionError({
|
|
243
|
-
message: res.body,
|
|
244
|
-
code: "INTERNAL_SERVER_ERROR"
|
|
245
|
-
})
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
if (import.meta.env?.PROD) {
|
|
249
|
-
return { error: ActionError.fromJson(json), data: void 0 };
|
|
250
|
-
} else {
|
|
251
|
-
const error = ActionError.fromJson(json);
|
|
252
|
-
error.stack = actionResultErrorStack.get();
|
|
253
|
-
return {
|
|
254
|
-
error,
|
|
255
|
-
data: void 0
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
if (res.type === "empty") {
|
|
260
|
-
return { data: void 0, error: void 0 };
|
|
261
|
-
}
|
|
262
|
-
return {
|
|
263
|
-
data: devalueParse(res.body, {
|
|
264
|
-
URL: (href) => new URL(href)
|
|
265
|
-
}),
|
|
266
|
-
error: void 0
|
|
267
|
-
};
|
|
268
|
-
}
|
|
269
|
-
const actionResultErrorStack = /* @__PURE__ */ function actionResultErrorStackFn() {
|
|
270
|
-
let errorStack;
|
|
271
|
-
return {
|
|
272
|
-
set(stack) {
|
|
273
|
-
errorStack = stack;
|
|
274
|
-
},
|
|
275
|
-
get() {
|
|
276
|
-
return errorStack;
|
|
277
|
-
}
|
|
278
|
-
};
|
|
279
|
-
}();
|
|
280
|
-
function astroCalledServerError() {
|
|
281
|
-
return new AstroError(ActionCalledFromServerError);
|
|
282
|
-
}
|
|
283
|
-
export {
|
|
284
|
-
ACTION_ERROR_CODES,
|
|
285
|
-
ACTION_QUERY_PARAMS,
|
|
286
|
-
ActionError,
|
|
287
|
-
ActionInputError,
|
|
288
|
-
appendForwardSlash,
|
|
289
|
-
astroCalledServerError,
|
|
290
|
-
callSafely,
|
|
291
|
-
deserializeActionResult,
|
|
292
|
-
getActionQueryString,
|
|
293
|
-
isActionError,
|
|
294
|
-
isInputError,
|
|
295
|
-
serializeActionResult
|
|
296
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { APIContext, AstroSharedContext } from '../../types/public/context.js';
|
|
2
|
-
import type { SerializedActionResult } from './shared.js';
|
|
3
|
-
export type ActionPayload = {
|
|
4
|
-
actionResult: SerializedActionResult;
|
|
5
|
-
actionName: string;
|
|
6
|
-
};
|
|
7
|
-
export type Locals = {
|
|
8
|
-
_actionPayload: ActionPayload;
|
|
9
|
-
};
|
|
10
|
-
export declare const ACTION_API_CONTEXT_SYMBOL: unique symbol;
|
|
11
|
-
export declare const formContentTypes: string[];
|
|
12
|
-
export declare function hasContentType(contentType: string, expected: string[]): boolean;
|
|
13
|
-
export type ActionAPIContext = Pick<APIContext, 'rewrite' | 'request' | 'url' | 'isPrerendered' | 'locals' | 'clientAddress' | 'cookies' | 'currentLocale' | 'generator' | 'routePattern' | 'site' | 'params' | 'preferredLocale' | 'preferredLocaleList' | 'originPathname' | 'session' | 'csp'> & {
|
|
14
|
-
/**
|
|
15
|
-
* @deprecated
|
|
16
|
-
* The use of `rewrite` in Actions is deprecated
|
|
17
|
-
*/
|
|
18
|
-
rewrite: AstroSharedContext['rewrite'];
|
|
19
|
-
};
|
|
20
|
-
export type MaybePromise<T> = T | Promise<T>;
|
|
21
|
-
/**
|
|
22
|
-
* Used to preserve the input schema type in the error object.
|
|
23
|
-
* This allows for type inference on the `fields` property
|
|
24
|
-
* when type narrowed to an `ActionInputError`.
|
|
25
|
-
*
|
|
26
|
-
* Example: Action has an input schema of `{ name: z.string() }`.
|
|
27
|
-
* When calling the action and checking `isInputError(result.error)`,
|
|
28
|
-
* `result.error.fields` will be typed with the `name` field.
|
|
29
|
-
*/
|
|
30
|
-
export type ErrorInferenceObject = Record<string, any>;
|
|
31
|
-
export declare function isActionAPIContext(ctx: ActionAPIContext): boolean;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const ACTION_API_CONTEXT_SYMBOL = Symbol.for("astro.actionAPIContext");
|
|
2
|
-
const formContentTypes = ["application/x-www-form-urlencoded", "multipart/form-data"];
|
|
3
|
-
function hasContentType(contentType, expected) {
|
|
4
|
-
const type = contentType.split(";")[0].toLowerCase();
|
|
5
|
-
return expected.some((t) => type === t);
|
|
6
|
-
}
|
|
7
|
-
function isActionAPIContext(ctx) {
|
|
8
|
-
const symbol = Reflect.get(ctx, ACTION_API_CONTEXT_SYMBOL);
|
|
9
|
-
return symbol === true;
|
|
10
|
-
}
|
|
11
|
-
export {
|
|
12
|
-
ACTION_API_CONTEXT_SYMBOL,
|
|
13
|
-
formContentTypes,
|
|
14
|
-
hasContentType,
|
|
15
|
-
isActionAPIContext
|
|
16
|
-
};
|