@kayjs/kay 1.108.0 → 1.109.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/dist/eslint.js +1790 -3751
- package/editors/zed/extension.toml +2 -2
- package/llms/action-protection.md +1 -1
- package/llms/actions-from-islands.md +4 -4
- package/llms/actions-refused-fields.md +4 -4
- package/llms/api-from-islands.md +6 -6
- package/llms/browser-only.md +2 -2
- package/llms/cdn-caching.md +1 -1
- package/llms/checks.md +1 -1
- package/llms/code-lints.md +1 -2
- package/llms/component-library-conventions.md +1 -1
- package/llms/components.md +4 -4
- package/llms/deprecated-lints.md +1 -6
- package/llms/effects.md +1 -1
- package/llms/errors.md +2 -2
- package/llms/events.md +1 -1
- package/llms/guards.md +1 -1
- package/llms/head.md +1 -1
- package/llms/hooks.md +2 -2
- package/llms/images.md +1 -1
- package/llms/island-and-form-lints.md +2 -1
- package/llms/island-sources.md +1 -1
- package/llms/islands-state-to-ids.md +2 -2
- package/llms/islands.md +4 -2
- package/llms/lints.md +1 -1
- package/llms/live-values.md +3 -3
- package/llms/local-collections.md +1 -1
- package/llms/locales.md +1 -1
- package/llms/mcp.md +2 -2
- package/llms/metrics.md +1 -1
- package/llms/navigation-from-code.md +6 -6
- package/llms/prerendering.md +1 -0
- package/llms/production.md +2 -2
- package/llms/project-new-and-add.md +1 -1
- package/llms/project.md +4 -4
- package/llms/proxy-and-security.md +1 -1
- package/llms/queues.md +1 -1
- package/llms/rate-limits.md +4 -4
- package/llms/rendering.md +1 -1
- package/llms/server-islands.md +2 -2
- package/llms/server.md +1 -1
- package/llms/stores.md +1 -1
- package/llms/styles-and-assets.md +1 -1
- package/llms/testing-mount.md +49 -0
- package/llms/testing.md +4 -45
- package/llms/upgrading-1-105-config.md +13 -13
- package/llms/upgrading-archive.md +42 -82
- package/llms/upgrading.md +91 -63
- package/llms/whats-new.md +9 -0
- package/llms.txt +5 -6
- package/package.json +6 -10
- package/src/build/route-sizes.ts +2 -3
- package/src/check/browser-global-reads.ts +2 -2
- package/src/check/config-objects.ts +1 -1
- package/src/check/diagnose.ts +0 -22
- package/src/check/export-homes.ts +1 -1
- package/src/check/guards.ts +3 -3
- package/src/check/index.ts +2 -7
- package/src/check/moved-keys.ts +1 -1
- package/src/check/project.ts +3 -8
- package/src/check/shadow-types.ts +0 -86
- package/src/commands/check.ts +2 -2
- package/src/commands/env.ts +25 -3
- package/src/compiler/ast.ts +18 -16
- package/src/compiler/browser.ts +2 -14
- package/src/compiler/class-items.ts +16 -0
- package/src/compiler/codegen.ts +8 -8
- package/src/compiler/deprecated-library.ts +0 -12
- package/src/compiler/deprecated-lints.ts +3 -495
- package/src/compiler/deprecated-ui-props.ts +5 -5
- package/src/compiler/errors.ts +2 -2
- package/src/compiler/fence-checks.ts +2 -121
- package/src/compiler/hand-parts.ts +55 -0
- package/src/compiler/helper-imports.ts +2 -2
- package/src/compiler/image-attributes.ts +1 -3
- package/src/compiler/index.ts +20 -21
- package/src/compiler/island-arguments.ts +8 -95
- package/src/compiler/island-cause.ts +7 -7
- package/src/compiler/island-declaration.ts +2 -8
- package/src/compiler/island-lints.ts +12 -0
- package/src/compiler/island-marker.ts +3 -3
- package/src/compiler/island-problems.ts +25 -0
- package/src/compiler/jsx-class.ts +1 -25
- package/src/compiler/jsx.ts +2 -2
- package/src/compiler/kay-exports.ts +0 -2
- package/src/compiler/link-flags.ts +9 -38
- package/src/compiler/lints.ts +7 -14
- package/src/compiler/markup.ts +23 -26
- package/src/compiler/module-signals.ts +2 -2
- package/src/compiler/names.ts +1 -1
- package/src/compiler/page-settings.ts +11 -0
- package/src/compiler/parser.ts +6 -8
- package/src/compiler/plan.ts +1 -3
- package/src/compiler/rewrite.ts +3 -18
- package/src/compiler/script-server.ts +8 -3
- package/src/compiler/validate.ts +3 -8
- package/src/config-loader.ts +14 -4
- package/src/config-resolve.ts +18 -142
- package/src/config-shape.ts +44 -34
- package/src/config.ts +10 -114
- package/src/dev/preload.ts +4 -1
- package/src/lsp/server.ts +4 -0
- package/src/migrate/markup.ts +4 -1
- package/src/runtime/action-call.ts +0 -8
- package/src/runtime/action-encode.ts +26 -0
- package/src/runtime/action-error.ts +3 -11
- package/src/runtime/action-protection.ts +2 -2
- package/src/runtime/action-run.ts +2 -27
- package/src/runtime/action-shared.ts +14 -37
- package/src/runtime/action-stream.ts +0 -1
- package/src/runtime/action.ts +1 -1
- package/src/runtime/call-result.ts +2 -10
- package/src/runtime/checks.ts +11 -11
- package/src/runtime/client.ts +2 -2
- package/src/runtime/core.ts +5 -23
- package/src/runtime/dom.ts +1 -1
- package/src/runtime/html.ts +1 -1
- package/src/runtime/i18n.client.ts +1 -4
- package/src/runtime/i18n.server.ts +1 -4
- package/src/runtime/i18n.ts +3 -3
- package/src/runtime/index.ts +2 -2
- package/src/runtime/island.server.ts +18 -5
- package/src/runtime/live-resource.server.ts +0 -1
- package/src/runtime/live-value.server.ts +2 -2
- package/src/runtime/live-value.shared.ts +7 -20
- package/src/runtime/live.ts +1 -12
- package/src/runtime/local-types.ts +1 -11
- package/src/runtime/local.ts +4 -14
- package/src/runtime/navigate-api.ts +2 -5
- package/src/runtime/navigation-state.ts +0 -12
- package/src/runtime/page-swap.ts +6 -6
- package/src/runtime/persist.ts +11 -3
- package/src/runtime/persisted.ts +4 -30
- package/src/runtime/presence.ts +6 -7
- package/src/runtime/query-param.ts +20 -12
- package/src/runtime/reactive.ts +3 -1
- package/src/runtime/refuse.ts +3 -17
- package/src/runtime/store-base.ts +4 -6
- package/src/runtime/swap-fetch.ts +1 -1
- package/src/runtime/values.ts +40 -23
- package/src/runtime/with-query.ts +9 -0
- package/src/server/action-hooks.ts +8 -8
- package/src/server/actions.ts +13 -14
- package/src/server/api-modules.ts +2 -3
- package/src/server/app-stages.ts +15 -33
- package/src/server/app.ts +10 -5
- package/src/server/auth-mails.ts +0 -2
- package/src/server/env-state.ts +40 -10
- package/src/server/flash.ts +1 -1
- package/src/server/guard-requirement.ts +4 -4
- package/src/server/image.ts +2 -2
- package/src/server/index.ts +0 -2
- package/src/server/job-context.ts +3 -3
- package/src/server/jobs-page.ts +1 -1
- package/src/server/jobs.ts +5 -9
- package/src/server/kept-exports.ts +0 -2
- package/src/server/kv.ts +11 -14
- package/src/server/library.ts +1 -3
- package/src/server/live.ts +2 -2
- package/src/server/mcp.ts +3 -9
- package/src/server/metrics.ts +2 -4
- package/src/server/page-settings.ts +10 -19
- package/src/server/prerender.ts +19 -2
- package/src/server/protection.ts +15 -18
- package/src/server/queue.ts +3 -6
- package/src/server/rate-limit.ts +0 -3
- package/src/server/render-document.ts +1 -1
- package/src/server/routes.ts +7 -3
- package/src/server/scope.ts +3 -2
- package/src/server/session.ts +5 -6
- package/src/server/setup.ts +1 -1
- package/src/server/signals.ts +17 -7
- package/src/server/signed.ts +1 -3
- package/src/server/source.ts +20 -4
- package/src/server/speculation.ts +1 -1
- package/src/server/storage.ts +3 -8
- package/src/server/validate.ts +1 -1
- package/src/server/vitals.ts +1 -3
- package/src/server/work-scope.ts +2 -4
- package/src/server/work.ts +1 -1
- package/src/server/workflow.ts +1 -1
- package/src/test/index.ts +2 -1
- package/src/test/site-actions.ts +16 -6
- package/src/test/site-keys.ts +10 -15
- package/src/test/site-socket.ts +1 -2
- package/src/test/site-types.ts +0 -8
- package/types/build/route-sizes.d.ts.map +1 -1
- package/types/check/diagnose.d.ts.map +1 -1
- package/types/check/index.d.ts +1 -2
- package/types/check/index.d.ts.map +1 -1
- package/types/check/project.d.ts.map +1 -1
- package/types/check/shadow-types.d.ts.map +1 -1
- package/types/commands/env.d.ts.map +1 -1
- package/types/compiler/ast.d.ts +1 -2
- package/types/compiler/ast.d.ts.map +1 -1
- package/types/compiler/browser.d.ts.map +1 -1
- package/types/compiler/class-items.d.ts +7 -0
- package/types/compiler/class-items.d.ts.map +1 -0
- package/types/compiler/deprecated-library.d.ts.map +1 -1
- package/types/compiler/deprecated-lints.d.ts +0 -551
- package/types/compiler/deprecated-lints.d.ts.map +1 -1
- package/types/compiler/deprecated-ui-props.d.ts +1 -8
- package/types/compiler/deprecated-ui-props.d.ts.map +1 -1
- package/types/compiler/errors.d.ts +2 -2
- package/types/compiler/errors.d.ts.map +1 -1
- package/types/compiler/fence-checks.d.ts +0 -1
- package/types/compiler/fence-checks.d.ts.map +1 -1
- package/types/compiler/hand-parts.d.ts +7 -0
- package/types/compiler/hand-parts.d.ts.map +1 -0
- package/types/compiler/image-attributes.d.ts +0 -1
- package/types/compiler/image-attributes.d.ts.map +1 -1
- package/types/compiler/index.d.ts.map +1 -1
- package/types/compiler/island-arguments.d.ts +2 -11
- package/types/compiler/island-arguments.d.ts.map +1 -1
- package/types/compiler/island-cause.d.ts +1 -1
- package/types/compiler/island-cause.d.ts.map +1 -1
- package/types/compiler/island-declaration.d.ts +1 -3
- package/types/compiler/island-declaration.d.ts.map +1 -1
- package/types/compiler/island-lints.d.ts +10 -0
- package/types/compiler/island-lints.d.ts.map +1 -0
- package/types/compiler/island-problems.d.ts +7 -0
- package/types/compiler/island-problems.d.ts.map +1 -0
- package/types/compiler/jsx-class.d.ts +1 -2
- package/types/compiler/jsx-class.d.ts.map +1 -1
- package/types/compiler/kay-exports.d.ts.map +1 -1
- package/types/compiler/link-flags.d.ts +0 -6
- package/types/compiler/link-flags.d.ts.map +1 -1
- package/types/compiler/lints.d.ts +11 -563
- package/types/compiler/lints.d.ts.map +1 -1
- package/types/compiler/markup.d.ts +1 -1
- package/types/compiler/markup.d.ts.map +1 -1
- package/types/compiler/module-signals.d.ts.map +1 -1
- package/types/compiler/names.d.ts.map +1 -1
- package/types/compiler/page-settings.d.ts +4 -0
- package/types/compiler/page-settings.d.ts.map +1 -1
- package/types/compiler/parser.d.ts.map +1 -1
- package/types/compiler/plan.d.ts.map +1 -1
- package/types/compiler/script-server.d.ts.map +1 -1
- package/types/compiler/validate.d.ts.map +1 -1
- package/types/config-loader.d.ts.map +1 -1
- package/types/config-resolve.d.ts.map +1 -1
- package/types/config-shape.d.ts +1 -1
- package/types/config-shape.d.ts.map +1 -1
- package/types/config.d.ts +5 -105
- package/types/config.d.ts.map +1 -1
- package/types/dev/preload.d.ts.map +1 -1
- package/types/lsp/server.d.ts.map +1 -1
- package/types/migrate/markup.d.ts.map +1 -1
- package/types/runtime/action-call.d.ts.map +1 -1
- package/types/runtime/action-encode.d.ts +1 -0
- package/types/runtime/action-encode.d.ts.map +1 -1
- package/types/runtime/action-error.d.ts +1 -2
- package/types/runtime/action-error.d.ts.map +1 -1
- package/types/runtime/action-run.d.ts.map +1 -1
- package/types/runtime/action-shared.d.ts +1 -27
- package/types/runtime/action-shared.d.ts.map +1 -1
- package/types/runtime/action-stream.d.ts.map +1 -1
- package/types/runtime/action.d.ts +1 -1
- package/types/runtime/action.d.ts.map +1 -1
- package/types/runtime/call-result.d.ts +0 -10
- package/types/runtime/call-result.d.ts.map +1 -1
- package/types/runtime/checks.d.ts +6 -9
- package/types/runtime/checks.d.ts.map +1 -1
- package/types/runtime/core.d.ts +2 -20
- package/types/runtime/core.d.ts.map +1 -1
- package/types/runtime/dom.d.ts +1 -1
- package/types/runtime/dom.d.ts.map +1 -1
- package/types/runtime/html.d.ts +1 -1
- package/types/runtime/html.d.ts.map +1 -1
- package/types/runtime/i18n.client.d.ts +0 -1
- package/types/runtime/i18n.client.d.ts.map +1 -1
- package/types/runtime/i18n.d.ts +1 -1
- package/types/runtime/i18n.d.ts.map +1 -1
- package/types/runtime/i18n.server.d.ts +0 -1
- package/types/runtime/i18n.server.d.ts.map +1 -1
- package/types/runtime/index.d.ts +2 -2
- package/types/runtime/index.d.ts.map +1 -1
- package/types/runtime/island.server.d.ts +1 -0
- package/types/runtime/island.server.d.ts.map +1 -1
- package/types/runtime/live-resource.server.d.ts.map +1 -1
- package/types/runtime/live-value.shared.d.ts +7 -15
- package/types/runtime/live-value.shared.d.ts.map +1 -1
- package/types/runtime/live.d.ts +0 -11
- package/types/runtime/live.d.ts.map +1 -1
- package/types/runtime/local-types.d.ts +0 -14
- package/types/runtime/local-types.d.ts.map +1 -1
- package/types/runtime/navigate-api.d.ts +0 -4
- package/types/runtime/navigate-api.d.ts.map +1 -1
- package/types/runtime/navigation-state.d.ts +0 -4
- package/types/runtime/navigation-state.d.ts.map +1 -1
- package/types/runtime/page-swap.d.ts.map +1 -1
- package/types/runtime/persist.d.ts +1 -0
- package/types/runtime/persist.d.ts.map +1 -1
- package/types/runtime/persisted.d.ts +0 -15
- package/types/runtime/persisted.d.ts.map +1 -1
- package/types/runtime/presence.d.ts +0 -2
- package/types/runtime/presence.d.ts.map +1 -1
- package/types/runtime/query-param.d.ts.map +1 -1
- package/types/runtime/reactive.d.ts +2 -1
- package/types/runtime/reactive.d.ts.map +1 -1
- package/types/runtime/refuse.d.ts +0 -7
- package/types/runtime/refuse.d.ts.map +1 -1
- package/types/runtime/store-base.d.ts +1 -2
- package/types/runtime/store-base.d.ts.map +1 -1
- package/types/runtime/values.d.ts +2 -1
- package/types/runtime/values.d.ts.map +1 -1
- package/types/runtime/with-query.d.ts +2 -0
- package/types/runtime/with-query.d.ts.map +1 -1
- package/types/server/action-hooks.d.ts +4 -4
- package/types/server/action-hooks.d.ts.map +1 -1
- package/types/server/actions.d.ts.map +1 -1
- package/types/server/api-modules.d.ts +0 -1
- package/types/server/api-modules.d.ts.map +1 -1
- package/types/server/app-stages.d.ts +5 -13
- package/types/server/app-stages.d.ts.map +1 -1
- package/types/server/app.d.ts +3 -8
- package/types/server/app.d.ts.map +1 -1
- package/types/server/auth-mails.d.ts +0 -5
- package/types/server/auth-mails.d.ts.map +1 -1
- package/types/server/env-state.d.ts +1 -0
- package/types/server/env-state.d.ts.map +1 -1
- package/types/server/guard-requirement.d.ts +0 -1
- package/types/server/guard-requirement.d.ts.map +1 -1
- package/types/server/image.d.ts +0 -1
- package/types/server/image.d.ts.map +1 -1
- package/types/server/index.d.ts +0 -2
- package/types/server/index.d.ts.map +1 -1
- package/types/server/job-context.d.ts +1 -1
- package/types/server/job-context.d.ts.map +1 -1
- package/types/server/jobs.d.ts +0 -4
- package/types/server/jobs.d.ts.map +1 -1
- package/types/server/kept-exports.d.ts.map +1 -1
- package/types/server/kv.d.ts +4 -4
- package/types/server/kv.d.ts.map +1 -1
- package/types/server/library.d.ts +1 -3
- package/types/server/library.d.ts.map +1 -1
- package/types/server/mcp.d.ts +0 -1
- package/types/server/mcp.d.ts.map +1 -1
- package/types/server/metrics.d.ts +0 -5
- package/types/server/metrics.d.ts.map +1 -1
- package/types/server/page-settings.d.ts +3 -3
- package/types/server/page-settings.d.ts.map +1 -1
- package/types/server/prerender.d.ts.map +1 -1
- package/types/server/protection.d.ts +6 -6
- package/types/server/protection.d.ts.map +1 -1
- package/types/server/queue.d.ts +1 -3
- package/types/server/queue.d.ts.map +1 -1
- package/types/server/rate-limit.d.ts +0 -2
- package/types/server/rate-limit.d.ts.map +1 -1
- package/types/server/routes.d.ts +1 -1
- package/types/server/routes.d.ts.map +1 -1
- package/types/server/scope.d.ts.map +1 -1
- package/types/server/session.d.ts +1 -1
- package/types/server/session.d.ts.map +1 -1
- package/types/server/signals.d.ts.map +1 -1
- package/types/server/signed.d.ts +0 -2
- package/types/server/signed.d.ts.map +1 -1
- package/types/server/source.d.ts +1 -1
- package/types/server/source.d.ts.map +1 -1
- package/types/server/storage.d.ts +0 -4
- package/types/server/storage.d.ts.map +1 -1
- package/types/server/vitals.d.ts +0 -1
- package/types/server/vitals.d.ts.map +1 -1
- package/types/server/work-scope.d.ts +0 -2
- package/types/server/work-scope.d.ts.map +1 -1
- package/types/server/workflow.d.ts +1 -1
- package/types/server/workflow.d.ts.map +1 -1
- package/types/test/index.d.ts.map +1 -1
- package/types/test/site-actions.d.ts +1 -1
- package/types/test/site-actions.d.ts.map +1 -1
- package/types/test/site-keys.d.ts +1 -1
- package/types/test/site-keys.d.ts.map +1 -1
- package/types/test/site-socket.d.ts +1 -1
- package/types/test/site-socket.d.ts.map +1 -1
- package/types/test/site-types.d.ts +0 -8
- package/types/test/site-types.d.ts.map +1 -1
- package/llms/deprecated-lints-1-105-libraries.md +0 -32
- package/llms/deprecated-lints-1-105.md +0 -58
- package/src/check/action-readers.ts +0 -115
- package/src/check/action-type.ts +0 -44
- package/src/check/ai-language.ts +0 -56
- package/src/check/app-hooks.ts +0 -90
- package/src/check/auth-methods.ts +0 -85
- package/src/check/auth-rate-limits.ts +0 -99
- package/src/check/call-result.ts +0 -242
- package/src/check/client-keys.ts +0 -10
- package/src/check/cms-options.ts +0 -81
- package/src/check/config-groups.ts +0 -22
- package/src/check/config-switches.ts +0 -38
- package/src/check/context-import.ts +0 -51
- package/src/check/env-files.ts +0 -31
- package/src/check/format-duration.ts +0 -75
- package/src/check/guard-options.ts +0 -58
- package/src/check/handler-events.ts +0 -149
- package/src/check/hook-context.ts +0 -94
- package/src/check/hook-names.ts +0 -104
- package/src/check/i18n-keys.ts +0 -50
- package/src/check/images-keys.ts +0 -54
- package/src/check/job-shapes.ts +0 -273
- package/src/check/link-flag-tests.ts +0 -130
- package/src/check/live-api.ts +0 -137
- package/src/check/mail-api.ts +0 -67
- package/src/check/one-state-api.ts +0 -357
- package/src/check/pages-options.ts +0 -35
- package/src/check/rate-enforce.ts +0 -53
- package/src/check/refusal-calls.ts +0 -185
- package/src/check/retired-lints.ts +0 -49
- package/src/check/route-keys.ts +0 -166
- package/src/check/secret-keys.ts +0 -83
- package/src/check/socket-frames.ts +0 -102
- package/src/check/source-readers.ts +0 -257
- package/src/check/store-ms.ts +0 -72
- package/src/check/store-names.ts +0 -88
- package/src/check/test-helpers.ts +0 -98
- package/src/check/ttl-names.ts +0 -142
- package/src/compiler/deprecated-ai-labels.ts +0 -97
- package/src/compiler/deprecated-ai-links.ts +0 -63
- package/src/compiler/deprecated-allow.ts +0 -50
- package/src/compiler/deprecated-auth-lints.ts +0 -14
- package/src/compiler/deprecated-auth-signed.ts +0 -29
- package/src/compiler/deprecated-children.ts +0 -66
- package/src/compiler/deprecated-image.ts +0 -116
- package/src/compiler/deprecated-island.ts +0 -155
- package/src/compiler/deprecated-lints-1-105.ts +0 -41
- package/src/compiler/deprecated-page.ts +0 -125
- package/src/compiler/deprecated-parts.ts +0 -22
- package/src/compiler/deprecated-typed-lints.ts +0 -23
- package/src/compiler/deprecated-ui-callbacks.ts +0 -66
- package/src/compiler/deprecated-ui-input.ts +0 -97
- package/src/compiler/deprecated-ui-items.ts +0 -47
- package/src/compiler/old-parts.ts +0 -84
- package/src/runtime/mount.compat.ts +0 -8
- package/src/server/moved-exports.ts +0 -17
- package/types/check/action-readers.d.ts +0 -3
- package/types/check/action-readers.d.ts.map +0 -1
- package/types/check/action-type.d.ts +0 -3
- package/types/check/action-type.d.ts.map +0 -1
- package/types/check/ai-language.d.ts +0 -3
- package/types/check/ai-language.d.ts.map +0 -1
- package/types/check/app-hooks.d.ts +0 -3
- package/types/check/app-hooks.d.ts.map +0 -1
- package/types/check/auth-methods.d.ts +0 -3
- package/types/check/auth-methods.d.ts.map +0 -1
- package/types/check/auth-rate-limits.d.ts +0 -3
- package/types/check/auth-rate-limits.d.ts.map +0 -1
- package/types/check/call-result.d.ts +0 -7
- package/types/check/call-result.d.ts.map +0 -1
- package/types/check/client-keys.d.ts +0 -3
- package/types/check/client-keys.d.ts.map +0 -1
- package/types/check/cms-options.d.ts +0 -3
- package/types/check/cms-options.d.ts.map +0 -1
- package/types/check/config-groups.d.ts +0 -3
- package/types/check/config-groups.d.ts.map +0 -1
- package/types/check/config-switches.d.ts +0 -3
- package/types/check/config-switches.d.ts.map +0 -1
- package/types/check/context-import.d.ts +0 -3
- package/types/check/context-import.d.ts.map +0 -1
- package/types/check/env-files.d.ts +0 -3
- package/types/check/env-files.d.ts.map +0 -1
- package/types/check/format-duration.d.ts +0 -5
- package/types/check/format-duration.d.ts.map +0 -1
- package/types/check/guard-options.d.ts +0 -3
- package/types/check/guard-options.d.ts.map +0 -1
- package/types/check/handler-events.d.ts +0 -9
- package/types/check/handler-events.d.ts.map +0 -1
- package/types/check/hook-context.d.ts +0 -3
- package/types/check/hook-context.d.ts.map +0 -1
- package/types/check/hook-names.d.ts +0 -3
- package/types/check/hook-names.d.ts.map +0 -1
- package/types/check/i18n-keys.d.ts +0 -3
- package/types/check/i18n-keys.d.ts.map +0 -1
- package/types/check/images-keys.d.ts +0 -3
- package/types/check/images-keys.d.ts.map +0 -1
- package/types/check/job-shapes.d.ts +0 -6
- package/types/check/job-shapes.d.ts.map +0 -1
- package/types/check/link-flag-tests.d.ts +0 -4
- package/types/check/link-flag-tests.d.ts.map +0 -1
- package/types/check/live-api.d.ts +0 -3
- package/types/check/live-api.d.ts.map +0 -1
- package/types/check/mail-api.d.ts +0 -3
- package/types/check/mail-api.d.ts.map +0 -1
- package/types/check/one-state-api.d.ts +0 -9
- package/types/check/one-state-api.d.ts.map +0 -1
- package/types/check/pages-options.d.ts +0 -3
- package/types/check/pages-options.d.ts.map +0 -1
- package/types/check/rate-enforce.d.ts +0 -3
- package/types/check/rate-enforce.d.ts.map +0 -1
- package/types/check/refusal-calls.d.ts +0 -3
- package/types/check/refusal-calls.d.ts.map +0 -1
- package/types/check/retired-lints.d.ts +0 -3
- package/types/check/retired-lints.d.ts.map +0 -1
- package/types/check/route-keys.d.ts +0 -3
- package/types/check/route-keys.d.ts.map +0 -1
- package/types/check/secret-keys.d.ts +0 -3
- package/types/check/secret-keys.d.ts.map +0 -1
- package/types/check/socket-frames.d.ts +0 -3
- package/types/check/socket-frames.d.ts.map +0 -1
- package/types/check/source-readers.d.ts +0 -3
- package/types/check/source-readers.d.ts.map +0 -1
- package/types/check/store-ms.d.ts +0 -3
- package/types/check/store-ms.d.ts.map +0 -1
- package/types/check/store-names.d.ts +0 -3
- package/types/check/store-names.d.ts.map +0 -1
- package/types/check/test-helpers.d.ts +0 -3
- package/types/check/test-helpers.d.ts.map +0 -1
- package/types/check/ttl-names.d.ts +0 -3
- package/types/check/ttl-names.d.ts.map +0 -1
- package/types/compiler/deprecated-ai-labels.d.ts +0 -5
- package/types/compiler/deprecated-ai-labels.d.ts.map +0 -1
- package/types/compiler/deprecated-ai-links.d.ts +0 -5
- package/types/compiler/deprecated-ai-links.d.ts.map +0 -1
- package/types/compiler/deprecated-allow.d.ts +0 -5
- package/types/compiler/deprecated-allow.d.ts.map +0 -1
- package/types/compiler/deprecated-auth-lints.d.ts +0 -12
- package/types/compiler/deprecated-auth-lints.d.ts.map +0 -1
- package/types/compiler/deprecated-auth-signed.d.ts +0 -5
- package/types/compiler/deprecated-auth-signed.d.ts.map +0 -1
- package/types/compiler/deprecated-children.d.ts +0 -4
- package/types/compiler/deprecated-children.d.ts.map +0 -1
- package/types/compiler/deprecated-image.d.ts +0 -5
- package/types/compiler/deprecated-image.d.ts.map +0 -1
- package/types/compiler/deprecated-island.d.ts +0 -9
- package/types/compiler/deprecated-island.d.ts.map +0 -1
- package/types/compiler/deprecated-lints-1-105.d.ts +0 -39
- package/types/compiler/deprecated-lints-1-105.d.ts.map +0 -1
- package/types/compiler/deprecated-page.d.ts +0 -4
- package/types/compiler/deprecated-page.d.ts.map +0 -1
- package/types/compiler/deprecated-parts.d.ts +0 -3
- package/types/compiler/deprecated-parts.d.ts.map +0 -1
- package/types/compiler/deprecated-typed-lints.d.ts +0 -21
- package/types/compiler/deprecated-typed-lints.d.ts.map +0 -1
- package/types/compiler/deprecated-ui-callbacks.d.ts +0 -5
- package/types/compiler/deprecated-ui-callbacks.d.ts.map +0 -1
- package/types/compiler/deprecated-ui-input.d.ts +0 -5
- package/types/compiler/deprecated-ui-input.d.ts.map +0 -1
- package/types/compiler/deprecated-ui-items.d.ts +0 -5
- package/types/compiler/deprecated-ui-items.d.ts.map +0 -1
- package/types/compiler/old-parts.d.ts +0 -9
- package/types/compiler/old-parts.d.ts.map +0 -1
- package/types/runtime/mount.compat.d.ts +0 -7
- package/types/runtime/mount.compat.d.ts.map +0 -1
- package/types/server/moved-exports.d.ts +0 -12
- package/types/server/moved-exports.d.ts.map +0 -1
package/src/server/kv.ts
CHANGED
|
@@ -10,26 +10,23 @@ import { inMemory } from './memory-mark'
|
|
|
10
10
|
import { onReload } from './reload'
|
|
11
11
|
|
|
12
12
|
// What a library or an app keeps that is a value under a key and nothing else: a flag with an end, a marker, a document fetched once.
|
|
13
|
-
// A key holds a string; `ttl` is how long it lives from the write, and a key written without one lives until it is deleted. It is a `Duration
|
|
13
|
+
// A key holds a string; `ttl` is how long it lives from the write, and a key written without one lives until it is deleted. It is a `Duration`.
|
|
14
14
|
export interface KvStore extends StoreBase {
|
|
15
15
|
get: (key: string) => MaybePromise<string | undefined>
|
|
16
|
-
|
|
17
|
-
// eslint-disable-next-line ts/method-signature-style -- method syntax keeps a store written with `number` assignable (bivariance)
|
|
18
|
-
set(key: string, value: string, ttl?: Duration | number): MaybePromise<void>
|
|
16
|
+
set: (key: string, value: string, ttl?: Duration) => MaybePromise<void>
|
|
19
17
|
// Resolves with whether there was a live value.
|
|
20
18
|
delete: (key: string) => MaybePromise<boolean>
|
|
21
19
|
// Takes the key for `ttl` when no live value holds it: true for the one call that took it, however many processes ask at once.
|
|
22
|
-
|
|
23
|
-
once(key: string, ttl: Duration | number): MaybePromise<boolean>
|
|
20
|
+
once: (key: string, ttl: Duration) => MaybePromise<boolean>
|
|
24
21
|
}
|
|
25
22
|
|
|
26
23
|
// A `KvStore` under one namespace, which every key is written under so two users of the store never meet.
|
|
27
24
|
export interface Kv {
|
|
28
25
|
get: (key: string) => Promise<string | undefined>
|
|
29
|
-
// `ttl` is a `Duration
|
|
30
|
-
set: (key: string, value: string, ttl?: Duration
|
|
26
|
+
// `ttl` is a `Duration`.
|
|
27
|
+
set: (key: string, value: string, ttl?: Duration) => Promise<void>
|
|
31
28
|
delete: (key: string) => Promise<boolean>
|
|
32
|
-
once: (key: string, ttl: Duration
|
|
29
|
+
once: (key: string, ttl: Duration) => Promise<boolean>
|
|
33
30
|
}
|
|
34
31
|
|
|
35
32
|
const SWEEP_EVERY = 500
|
|
@@ -47,7 +44,7 @@ export function memoryKv(max?: number): KvStore {
|
|
|
47
44
|
|
|
48
45
|
return entry !== undefined && (entry.until === undefined || entry.until > now) ? entry : undefined
|
|
49
46
|
}
|
|
50
|
-
const write = (key: string, value: string, ttl: Duration |
|
|
47
|
+
const write = (key: string, value: string, ttl: Duration | undefined, now: number) => {
|
|
51
48
|
const ttlMs = ttl === undefined ? undefined : lengthMs(ttl, 'a kv ttl')
|
|
52
49
|
|
|
53
50
|
if (++writes % SWEEP_EVERY === 0) {
|
|
@@ -125,7 +122,7 @@ function openKv(path: string) {
|
|
|
125
122
|
return {
|
|
126
123
|
close: () => db.close(),
|
|
127
124
|
get: (key: string) => select.get(key, Date.now())?.value,
|
|
128
|
-
set(key: string, value: string, ttl?: Duration
|
|
125
|
+
set(key: string, value: string, ttl?: Duration) {
|
|
129
126
|
const now = Date.now()
|
|
130
127
|
|
|
131
128
|
sweeping(now)
|
|
@@ -136,7 +133,7 @@ function openKv(path: string) {
|
|
|
136
133
|
|
|
137
134
|
return row !== null && (row.expires_at === null || row.expires_at > Date.now())
|
|
138
135
|
},
|
|
139
|
-
once(key: string, ttl: Duration
|
|
136
|
+
once(key: string, ttl: Duration) {
|
|
140
137
|
const now = Date.now()
|
|
141
138
|
|
|
142
139
|
sweeping(now)
|
|
@@ -205,13 +202,13 @@ export function kv(namespace: string, store?: KvStore): Kv {
|
|
|
205
202
|
set: async (key, value, ttl) => {
|
|
206
203
|
const used = kept()
|
|
207
204
|
|
|
208
|
-
return used.set(keyed(key), value, ttl === undefined ? undefined : lengthFor(
|
|
205
|
+
return used.set(keyed(key), value, ttl === undefined ? undefined : lengthFor(lengthMs(ttl, 'a kv ttl')))
|
|
209
206
|
},
|
|
210
207
|
delete: async key => kept().delete(keyed(key)),
|
|
211
208
|
once: async (key, ttl) => {
|
|
212
209
|
const used = kept()
|
|
213
210
|
|
|
214
|
-
return used.once(keyed(key), lengthFor(
|
|
211
|
+
return used.once(keyed(key), lengthFor(lengthMs(ttl, 'a kv ttl')))
|
|
215
212
|
},
|
|
216
213
|
}
|
|
217
214
|
}
|
package/src/server/library.ts
CHANGED
|
@@ -38,7 +38,7 @@ export { escapeHtml } from '../runtime/escape'
|
|
|
38
38
|
export { IMPORTED } from '../runtime/image'
|
|
39
39
|
export { siteLocales } from '../runtime/locale-state'
|
|
40
40
|
export { delayAfter, LISTENED_IDLE_MS, MAX_IDLE_MS, pollClock } from '../runtime/poll-backoff'
|
|
41
|
-
export type { DenyOptions
|
|
41
|
+
export type { DenyOptions } from '../runtime/refuse'
|
|
42
42
|
export { refuse } from '../runtime/refuse'
|
|
43
43
|
export { safeCode } from '../runtime/safe-code'
|
|
44
44
|
export { isUrlAttribute, UNSAFE_ATTRIBUTE, UNSAFE_TAGS } from '../runtime/sanitize'
|
|
@@ -50,8 +50,6 @@ export { openSqlite } from '../runtime/sqlite.server'
|
|
|
50
50
|
export { parseEvents } from '../runtime/sse'
|
|
51
51
|
export type { MaybePromise } from '../runtime/store-base'
|
|
52
52
|
export { lengthMs } from '../runtime/store-base'
|
|
53
|
-
/** @deprecated Import `defineContext` from `kay/server`; `deprecated-context-import` rewrites it. Removed in 1.108. */
|
|
54
|
-
export { defineContext } from '../runtime/template-context'
|
|
55
53
|
export type { ContextDefinition } from '../runtime/template-context'
|
|
56
54
|
export { acceptedLocales, matchLocale, validLocale } from './accept-language'
|
|
57
55
|
export { APP_SQLITE_FILE, appDatabase, defaultSqliteFile } from './app-database'
|
package/src/server/live.ts
CHANGED
|
@@ -84,7 +84,7 @@ const stamped = new Set<string>()
|
|
|
84
84
|
// The tags each followed key's value names, kept here as memory may drop the value that knew them: an invalidation of one still reaches the pages following the key.
|
|
85
85
|
const tagged = new Map<string, readonly string[]>()
|
|
86
86
|
// The last invalidation time of each key a page followed, which a connection sends first: the declaration gives 0 to a key never invalidated.
|
|
87
|
-
const stamps = (live as (initial: (key: string) => number, id: string, name: string) => { set: (
|
|
87
|
+
const stamps = (live as (initial: (key: string) => number, id: string, name: string) => { set: (value: number, options: { key: string }) => void, delete: (key: string) => void })((): number => 0, CACHE_LIVE_ID, 'cache')
|
|
88
88
|
|
|
89
89
|
// Runs the render of a request, loads included, so the cached values it reads with `live: true` are the page's to follow.
|
|
90
90
|
// Who is signed in is asked only for a render that reads a value of each user: the first render of a chain does not know it will, so it runs without, and `missed` is called when it read one, for the render to run again with the user resolved. A chain that read one is resolved before its renders from then on.
|
|
@@ -382,7 +382,7 @@ onKeysInvalidated((matches) => {
|
|
|
382
382
|
for (const key of stamped) {
|
|
383
383
|
if (matches(key) || tagged.get(key)?.some(matches) === true) {
|
|
384
384
|
lastStamp = at
|
|
385
|
-
stamps.set(
|
|
385
|
+
stamps.set(at, { key })
|
|
386
386
|
into?.add(key)
|
|
387
387
|
}
|
|
388
388
|
}
|
package/src/server/mcp.ts
CHANGED
|
@@ -401,10 +401,8 @@ export interface McpOptions {
|
|
|
401
401
|
actions: ActionOptions
|
|
402
402
|
// The sign-in metadata paths kay serves: one the app serves itself is left out.
|
|
403
403
|
metadataPaths: string[]
|
|
404
|
-
// Where the endpoint is served, `/mcp` by default.
|
|
404
|
+
// Where the endpoint is served, `/_kay/mcp` by default.
|
|
405
405
|
path: string
|
|
406
|
-
// The path before 1.105, answered as `path` is until 2.0, for an app that did not move the endpoint and serves nothing there.
|
|
407
|
-
former?: string | undefined
|
|
408
406
|
// The requests a client may send it in a window, or undefined for no limit.
|
|
409
407
|
rateLimit: RateWindowMs | undefined
|
|
410
408
|
// Sent as `instructions` of `initialize`, from `mcp.instructions`.
|
|
@@ -568,7 +566,7 @@ function serveResourceMetadata(app: Elysia, name: string, paths: string[], endpo
|
|
|
568
566
|
}
|
|
569
567
|
}
|
|
570
568
|
|
|
571
|
-
// Serves the tools of `document` at its path over Streamable HTTP: one JSON-RPC message per POST, answered with JSON
|
|
569
|
+
// Serves the tools of `document` at its path over Streamable HTTP: one JSON-RPC message per POST, answered with JSON.
|
|
572
570
|
export function serveMcp(app: Elysia, document: Schema, options: McpOptions): void {
|
|
573
571
|
const calls = new AsyncLocalStorage<CallContext>()
|
|
574
572
|
const build = () => {
|
|
@@ -645,10 +643,6 @@ export function serveMcp(app: Elysia, document: Schema, options: McpOptions): vo
|
|
|
645
643
|
app.get(options.path, notAllowed)
|
|
646
644
|
app.delete(options.path, notAllowed)
|
|
647
645
|
|
|
648
|
-
// Only the POST is taken at the former path, so a catch-all or parameter route of the app keeps its GET and DELETE.
|
|
649
|
-
if (options.former !== undefined)
|
|
650
|
-
app.post(options.former, answer, { parse: 'none' })
|
|
651
|
-
|
|
652
646
|
serveResourceMetadata(app, options.title, options.metadataPaths, options.path)
|
|
653
647
|
}
|
|
654
648
|
|
|
@@ -662,7 +656,7 @@ export interface LibraryTool {
|
|
|
662
656
|
// The `label` of the action's `tool`, the words a library shows a visitor for a call to it.
|
|
663
657
|
label?: string | undefined
|
|
664
658
|
// Runs the action as the visitor `request` came from, the one being answered unless given, through the whole app: its guards, validation and rate limits apply as on a form post, while the honeypot, minimum time and proof of work, which only a person filling in a form passes, are skipped.
|
|
665
|
-
// A request a browser sent from another site is refused, as
|
|
659
|
+
// A request a browser sent from another site is refused, as the MCP endpoint refuses it, since it carries the visitor's cookies whatever its method.
|
|
666
660
|
// A call made once the answer is sent, from a reply streaming on, passes the request it captured while it was answered.
|
|
667
661
|
call: (args: Record<string, unknown>, request?: Request) => Promise<ToolResult>
|
|
668
662
|
}
|
package/src/server/metrics.ts
CHANGED
|
@@ -11,8 +11,6 @@ import { sameText } from './seal'
|
|
|
11
11
|
import { checkSecret, readSecret, secretSource, verifying } from './secret'
|
|
12
12
|
|
|
13
13
|
export const METRICS_PATH = '/_kay/metrics'
|
|
14
|
-
// Where the metrics were served before 1.105, which answers as well until 1.108 while `endpoints.metrics` is not set.
|
|
15
|
-
export const FORMER_METRICS_PATH = '/metrics'
|
|
16
14
|
const TOKEN_VARIABLE = 'KAY_METRICS_TOKEN'
|
|
17
15
|
// Seconds, the Prometheus client libraries' default buckets.
|
|
18
16
|
const BUCKETS = [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10]
|
|
@@ -82,7 +80,7 @@ function labelled(value: string): string {
|
|
|
82
80
|
}
|
|
83
81
|
|
|
84
82
|
// Counts the requests the server answered and writes them, with the jobs, the cache and the open connections, as the Prometheus text format.
|
|
85
|
-
export function serveMetrics(app: Elysia, options: { root: string, path: string, base: string, proxy: ProxyConfig | undefined, token?: MetricsConfig['token'], health: string | undefined, holds: () => boolean,
|
|
83
|
+
export function serveMetrics(app: Elysia, options: { root: string, path: string, base: string, proxy: ProxyConfig | undefined, token?: MetricsConfig['token'], health: string | undefined, holds: () => boolean, connections: () => number }): void {
|
|
86
84
|
const started = Date.now()
|
|
87
85
|
const token = configuredToken(options.token, options.root)
|
|
88
86
|
const requests = new Map<string, number>()
|
|
@@ -97,7 +95,7 @@ export function serveMetrics(app: Elysia, options: { root: string, path: string,
|
|
|
97
95
|
// A trailing slash is the same route, as Elysia routes it, and the path is read with or without the base a proxy keeps.
|
|
98
96
|
const at = (route: string, holds: () => boolean): boolean => holds() && [pathname, routerPath(pathname, options.base)].some(path => path === route || path === `${route}/`)
|
|
99
97
|
|
|
100
|
-
return at(options.path, options.holds)
|
|
98
|
+
return at(options.path, options.holds)
|
|
101
99
|
}
|
|
102
100
|
|
|
103
101
|
const lines = (): string => {
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import type { Collection } from '../content'
|
|
2
|
-
import type { PageSettings } from '../runtime'
|
|
2
|
+
import type { PageSeo, PageSettings } from '../runtime'
|
|
3
3
|
import { KayError } from '../compiler/errors'
|
|
4
4
|
import { SEO_SETTINGS } from '../compiler/page-settings'
|
|
5
5
|
import { isRouteOf } from '../content/claims'
|
|
6
6
|
import { registeredCollections } from '../content/edit-registry'
|
|
7
7
|
import { durationSeconds } from '../runtime/duration'
|
|
8
8
|
|
|
9
|
-
// A setting of a page module: its key of `export const page`, those of `seo` read from there
|
|
10
|
-
export function pageSetting(module: object, name: keyof PageSettings): unknown {
|
|
9
|
+
// A setting of a page module: its key of `export const page`, those of `seo` read from there.
|
|
10
|
+
export function pageSetting(module: object, name: keyof PageSettings | keyof PageSeo): unknown {
|
|
11
11
|
const page = (module as { page?: PageSettings }).page
|
|
12
12
|
|
|
13
|
-
return SEO_SETTINGS.includes(name) ? (
|
|
13
|
+
return SEO_SETTINGS.includes(name) ? (page?.seo as Record<string, unknown> | undefined)?.[name] : page?.[name as keyof PageSettings]
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
// A text of a page's `seo` group, as it is written.
|
|
@@ -61,7 +61,7 @@ function cacheOf(file: string, cache: NonNullable<PageSettings['cache']>): { ttl
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
// A setting along a route's modules, layouts outermost first and the page last: the innermost that sets it wins, so a page may undo what its layouts say.
|
|
64
|
-
export function chainSetting(modules: object[], name: keyof PageSettings): unknown {
|
|
64
|
+
export function chainSetting(modules: object[], name: keyof PageSettings | keyof PageSeo): unknown {
|
|
65
65
|
for (let index = modules.length - 1; index >= 0; index--) {
|
|
66
66
|
const value = pageSetting(modules[index]!, name)
|
|
67
67
|
|
|
@@ -72,25 +72,16 @@ export function chainSetting(modules: object[], name: keyof PageSettings): unkno
|
|
|
72
72
|
return undefined
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
// A page's lifetime and `cache-control` along its route: the `cache` of the innermost module that sets one
|
|
75
|
+
// A page's lifetime and `cache-control` along its route: the `cache` of the innermost module that sets one.
|
|
76
76
|
export function chainCache(file: string, modules: object[]): { ttl: unknown, cacheControl: unknown } {
|
|
77
|
-
let ttl: unknown
|
|
78
|
-
let cacheControl: unknown
|
|
79
|
-
|
|
80
77
|
for (let index = modules.length - 1; index >= 0; index--) {
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
if (page?.cache !== undefined) {
|
|
84
|
-
const given = cacheOf(file, page.cache)
|
|
85
|
-
|
|
86
|
-
return { ttl: ttl ?? given.ttl, cacheControl: cacheControl ?? given.cacheControl }
|
|
87
|
-
}
|
|
78
|
+
const cache = (modules[index] as { page?: PageSettings }).page?.cache
|
|
88
79
|
|
|
89
|
-
|
|
90
|
-
|
|
80
|
+
if (cache !== undefined)
|
|
81
|
+
return cacheOf(file, cache)
|
|
91
82
|
}
|
|
92
83
|
|
|
93
|
-
return { ttl, cacheControl }
|
|
84
|
+
return { ttl: undefined, cacheControl: undefined }
|
|
94
85
|
}
|
|
95
86
|
|
|
96
87
|
interface PageRoute {
|
package/src/server/prerender.ts
CHANGED
|
@@ -46,6 +46,23 @@ import { setupPages } from './setup'
|
|
|
46
46
|
import { STAMP_HOLE } from './stamp'
|
|
47
47
|
|
|
48
48
|
const PARTS = new Intl.ListFormat('en-GB')
|
|
49
|
+
// An island the render marked as reading the query, whose markup is the default query's.
|
|
50
|
+
const QUERY_ISLAND = /<slot data-component="[^"]*" data-props=(?:"[^"]*"|'[^']*')[^>]*? data-query[ >]/g
|
|
51
|
+
|
|
52
|
+
// What the page reads with `live: true` in its own render, which the build runs once.
|
|
53
|
+
function warnUnfollowed(path: string, keys: string[] | undefined): void {
|
|
54
|
+
if (keys !== undefined)
|
|
55
|
+
kayLog('warn', `${path} reads ${keys.slice(0, 5).map(key => `'${key}'`).join(', ')}${keys.length > 5 ? ' and more' : ''} with \`live: true\` in its own render, which the build runs once: what the page shows of it itself goes stale and only its server islands follow, so drop \`prerender\` from \`export const page\` if the page shows it`)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// A page kept on its own reads no query, so only one asked for can hold such an island.
|
|
59
|
+
function warnQueryIslands(path: string, html: string, auto: boolean): void {
|
|
60
|
+
const count = auto ? 0 : [...html.matchAll(QUERY_ISLAND)].length
|
|
61
|
+
|
|
62
|
+
if (count > 0)
|
|
63
|
+
kayLog('warn', `${path} holds ${count === 1 ? 'an island' : `${count} islands`} reading a query param, drawn here at the default query: the browser draws ${count === 1 ? 'it' : 'them'} again when the page is opened with a query, so the markup before that, and with no JavaScript, is the default's`)
|
|
64
|
+
}
|
|
65
|
+
|
|
49
66
|
const LINE_BREAK = /[\r\n]/
|
|
50
67
|
const KAY_IMPORT = /\bfrom\s+['"]([^'"]+\.kay)['"]/g
|
|
51
68
|
// The pages of a route rendering at once: a render waiting on a database, a CMS or a file lets the next ones run, while each page is still judged and written in turn, as one at a time would. Bounded, so the build holds no more pages than this.
|
|
@@ -390,8 +407,8 @@ export async function prerenderPages(project: Project, client: ClientBuild, opti
|
|
|
390
407
|
if (islands.includes('defer') && client.entry === undefined)
|
|
391
408
|
throw new KayError('export-server-render', `kay: it defers a server island, which kay's browser entry fetches, and with no island and \`navigation: false\` the build has none; mark it \`server\` to render it inline instead`)
|
|
392
409
|
|
|
393
|
-
|
|
394
|
-
|
|
410
|
+
warnUnfollowed(copy.path, unfollowed?.keys)
|
|
411
|
+
warnQueryIslands(copy.path, html, auto)
|
|
395
412
|
|
|
396
413
|
const name = `${copy.key === '/' ? 'index' : copy.key.slice(1)}.html`
|
|
397
414
|
const taken = reserved.get(name) ?? paths.get(name)
|
package/src/server/protection.ts
CHANGED
|
@@ -239,7 +239,7 @@ export function sqliteRates(path: string): SyncRates {
|
|
|
239
239
|
}
|
|
240
240
|
|
|
241
241
|
// Answered at once, as a store reading SQLite needs no promise.
|
|
242
|
-
export interface SyncRates { hit: (key: string, window: Duration
|
|
242
|
+
export interface SyncRates { hit: (key: string, window: Duration, weight?: number) => RateWindow, peek: (key: string) => RateWindow | undefined, refund: (key: string, resetAt: number) => void, reset: (key: string) => void }
|
|
243
243
|
type OpenRates = SyncRates & { close: () => void }
|
|
244
244
|
|
|
245
245
|
function openRates(path: string): OpenRates {
|
|
@@ -312,7 +312,7 @@ export interface Limiter {
|
|
|
312
312
|
peek: (key: string) => Promise<RateWindow | undefined>
|
|
313
313
|
// Forgets the window under `key`. A store with no `reset` has the count taken off with a hit of the negative weight, which leaves an empty window open.
|
|
314
314
|
reset: (key: string) => Promise<void>
|
|
315
|
-
// Counts an attempt under `key` and answers the seconds to wait once the count is past `max`, else undefined; it answers and refuses nothing. Not `rateLimit().
|
|
315
|
+
// Counts an attempt under `key` and answers the seconds to wait once the count is past `max`, else undefined; it answers and refuses nothing. Not `rateLimit().check(ctx)`, which takes a guard's context and denies with 429.
|
|
316
316
|
enforce: (key: string, weight?: number) => Promise<number | undefined>
|
|
317
317
|
// Takes back one attempt `hit` counted in the window closing at `resetAt`; false when the store has no `refund`.
|
|
318
318
|
refund: (key: string, resetAt: number) => Promise<boolean>
|
|
@@ -349,7 +349,7 @@ export function makeLimiter({ name, max, ms, store: given, failure, memory }: {
|
|
|
349
349
|
return standIn.rates
|
|
350
350
|
}
|
|
351
351
|
const keyed = (key: string) => `${name}\n${key}`
|
|
352
|
-
const hitIn = async (used: RateStore, key: string, weight?: number) => used.hit(keyed(key), lengthFor(
|
|
352
|
+
const hitIn = async (used: RateStore, key: string, weight?: number) => used.hit(keyed(key), lengthFor(ms), weight)
|
|
353
353
|
|
|
354
354
|
const peek = async (key: string): Promise<RateWindow | undefined> => {
|
|
355
355
|
const used = store()
|
|
@@ -357,7 +357,7 @@ export function makeLimiter({ name, max, ms, store: given, failure, memory }: {
|
|
|
357
357
|
if (used.peek)
|
|
358
358
|
return used.peek(keyed(key))
|
|
359
359
|
|
|
360
|
-
const window = await used.hit(keyed(key), lengthFor(
|
|
360
|
+
const window = await used.hit(keyed(key), lengthFor(ms), 0)
|
|
361
361
|
|
|
362
362
|
return window.count > 0 ? window : undefined
|
|
363
363
|
}
|
|
@@ -381,10 +381,10 @@ export function makeLimiter({ name, max, ms, store: given, failure, memory }: {
|
|
|
381
381
|
return
|
|
382
382
|
|
|
383
383
|
// The window may have closed between the two calls, which a hit of minus the count would open at a negative count.
|
|
384
|
-
const left = await used.hit(keyed(key), lengthFor(
|
|
384
|
+
const left = await used.hit(keyed(key), lengthFor(ms), -window.count)
|
|
385
385
|
|
|
386
386
|
if (left.count < 0)
|
|
387
|
-
await used.hit(keyed(key), lengthFor(
|
|
387
|
+
await used.hit(keyed(key), lengthFor(ms), -left.count)
|
|
388
388
|
},
|
|
389
389
|
enforce: async (key, weight) => waitFor(await hitIn(store(), key, weight), max),
|
|
390
390
|
refund: async (key, resetAt) => {
|
|
@@ -715,7 +715,7 @@ export function ratesFor(name: string, given?: RateStore): RateStore {
|
|
|
715
715
|
|
|
716
716
|
// What a store falls back on, answering at once.
|
|
717
717
|
export interface FallbackMemory {
|
|
718
|
-
hit: (key: string,
|
|
718
|
+
hit: (key: string, window: Duration, weight?: number) => RateWindow
|
|
719
719
|
peek: (key: string) => RateWindow | undefined
|
|
720
720
|
refund?: ((key: string, resetAt: number) => void) | undefined
|
|
721
721
|
reset?: ((key: string) => void) | undefined
|
|
@@ -730,7 +730,7 @@ export function ratesFallingBack<Store extends RateStore>(name: string, store: S
|
|
|
730
730
|
|
|
731
731
|
// Each method is read off the store on each call, so one replaced on it later, as a test spies on it, is the one called.
|
|
732
732
|
return {
|
|
733
|
-
hit: async (key, window, weight) => answered(name, store, (...args: [string, Duration
|
|
733
|
+
hit: async (key, window, weight) => answered(name, store, (...args: [string, Duration, number | undefined]): ReturnType<RateStore['hit']> => store.hit(...args), [key, lengthFor(lengthMs(window)), weight], () => memory.hit(key, lengthFor(lengthMs(window)), weight)),
|
|
734
734
|
...peek && { peek: async key => answered(name, store, store.peek ?? peek, [key], () => memory.peek(key)) },
|
|
735
735
|
// Taken back in memory too, where the attempt was counted if the store failed then; memory only takes it off a window closing at that same `resetAt`.
|
|
736
736
|
...refund && { refund: async (key, resetAt) => {
|
|
@@ -854,15 +854,12 @@ export function rateKey(address: string): string {
|
|
|
854
854
|
return `${groups.slice(0, 4).map(group => group.replace(LEADING_ZEROS, '')).join(':')}::/64`
|
|
855
855
|
}
|
|
856
856
|
|
|
857
|
-
// `true` is one proxy in front
|
|
858
|
-
function proxyOf(setting: ProxyConfig |
|
|
857
|
+
// `true` is one proxy in front, the short form of `{ hops: 1 }`.
|
|
858
|
+
function proxyOf(setting: ProxyConfig | boolean | undefined): ProxyConfig | undefined {
|
|
859
859
|
if (setting === false)
|
|
860
860
|
return undefined
|
|
861
861
|
|
|
862
|
-
|
|
863
|
-
return { hops: 1 }
|
|
864
|
-
|
|
865
|
-
return typeof setting === 'number' ? { hops: setting } : setting
|
|
862
|
+
return setting === true ? { hops: 1 } : setting
|
|
866
863
|
}
|
|
867
864
|
|
|
868
865
|
// The server that received `request`, once the app read it.
|
|
@@ -871,7 +868,7 @@ export function requestServer(request: Request): Server<unknown> | undefined {
|
|
|
871
868
|
}
|
|
872
869
|
|
|
873
870
|
// Refuses a `proxy` setting that names no proxy, so the boot can before any build starts.
|
|
874
|
-
export function checkProxy(setting: ProxyConfig |
|
|
871
|
+
export function checkProxy(setting: ProxyConfig | boolean | undefined): ProxyConfig | undefined {
|
|
875
872
|
const proxy = proxyOf(setting)
|
|
876
873
|
|
|
877
874
|
if (!proxy)
|
|
@@ -904,7 +901,7 @@ export function checkProxy(setting: ProxyConfig | number | boolean | undefined):
|
|
|
904
901
|
|
|
905
902
|
// Records the app's proxy settings on each request it gets, for `clientAddress` to read them wherever it is called from.
|
|
906
903
|
// In production a `proxy` left out is one proxy in front, read from private addresses only: a server there is behind one far more often than it faces visitors, and `false` says it is not.
|
|
907
|
-
export function trustProxy(setting: ProxyConfig |
|
|
904
|
+
export function trustProxy(setting: ProxyConfig | boolean | undefined): ReceiveStep {
|
|
908
905
|
const proxy = checkProxy(setting) ?? (setting === undefined && process.env.NODE_ENV === 'production' ? INFERRED_PROXY : undefined)
|
|
909
906
|
|
|
910
907
|
return (request, server) => {
|
|
@@ -921,12 +918,12 @@ export function trustProxy(setting: ProxyConfig | number | boolean | undefined):
|
|
|
921
918
|
|
|
922
919
|
// The socket's address, unless it is a proxy on this machine or network the app's `proxy` setting trusts: then the client's address as that proxy passed it on.
|
|
923
920
|
// `proxy` stands in for the app's setting, for a plain Elysia app that `pages()` does not serve.
|
|
924
|
-
export function clientAddress(request: Request, server: Server<unknown> | null | undefined, setting?: ProxyConfig |
|
|
921
|
+
export function clientAddress(request: Request, server: Server<unknown> | null | undefined, setting?: ProxyConfig | boolean): string {
|
|
925
922
|
return knownAddress(request, server, setting) ?? 'unknown'
|
|
926
923
|
}
|
|
927
924
|
|
|
928
925
|
// `clientAddress`, or undefined for a request with no socket address and none a trusted proxy forwarded, which `clientAddress` counts as the one client `unknown`.
|
|
929
|
-
export function knownAddress(request: Request, server: Server<unknown> | null | undefined, setting?: ProxyConfig |
|
|
926
|
+
export function knownAddress(request: Request, server: Server<unknown> | null | undefined, setting?: ProxyConfig | boolean): string | undefined {
|
|
930
927
|
const proxy = proxyOf(setting)
|
|
931
928
|
const record = recordOf(request)
|
|
932
929
|
const address = rewrittenAddress(request) ?? (server ?? record?.server)?.requestIP(request)?.address
|
package/src/server/queue.ts
CHANGED
|
@@ -113,8 +113,6 @@ export interface QueueOptions<Payload> {
|
|
|
113
113
|
concurrency?: number | undefined
|
|
114
114
|
// How long a run may take: past it, the run counts as failed, its signal aborts and its worker is freed, and another process takes a job its dead process held as lost. 10 minutes by default, the name a schedule's limit has too.
|
|
115
115
|
timeout?: Duration | undefined
|
|
116
|
-
/** @deprecated `timeout`, the one name of a job's time limit. Removed in 1.108; `deprecated-job-options` rewrites it. */
|
|
117
|
-
lostAfter?: Duration | undefined
|
|
118
116
|
// `false` runs nothing: the queue starts no worker, so a job needing an optional service is switched by its setting, `enabled: url !== undefined`, as a schedule is. A job enqueued meanwhile waits in the store for a process that runs the queue.
|
|
119
117
|
enabled?: boolean | undefined
|
|
120
118
|
// The longest an idle queue waits between looks at the store, 10 seconds by default.
|
|
@@ -468,17 +466,16 @@ export function defaultJobStore(): JobStore {
|
|
|
468
466
|
// A queue of jobs the server runs in the background, each surviving a restart: `enqueue` from an action, `app.use(queue)` in the server to run them.
|
|
469
467
|
// A run that throws is retried later, waiting `backoff` then twice as long each time, until `attempts` runs failed: it is then kept as failed, logged and handed to `onError`.
|
|
470
468
|
export function queue<Payload, Progress = unknown>(name: string, handler: (payload: Payload, ctx: JobContext<Progress>) => unknown, options: QueueOptions<Payload> = {}): Queue<Payload, Progress> {
|
|
471
|
-
|
|
472
|
-
return jobQueue<Payload, Progress>(name, (payload, ctx) => (handler as (payload: Payload, ctx: JobContext<Progress>, job: JobRef<Progress>) => unknown)(payload, ctx, ctx.job), options).queued
|
|
469
|
+
return jobQueue<Payload, Progress>(name, handler, options).queued
|
|
473
470
|
}
|
|
474
471
|
|
|
475
472
|
const REMOVED_OPTIONS = { onFailed: '`onError`, which also gets `id` and `attempts`', keepFailed: '`failedTtl`' }
|
|
476
473
|
|
|
477
474
|
// `queue` for `workflow`: its handler also gets the hold of its run, and the admin it returns is what the workflow wakes its own queue and attaches its calls with.
|
|
478
|
-
export function jobQueue<Payload, Progress = unknown>(name: string, handler: (payload: Payload, ctx: JobContext<Progress
|
|
475
|
+
export function jobQueue<Payload, Progress = unknown>(name: string, handler: (payload: Payload, ctx: JobContext<Progress>, run: RunHold) => unknown, options: QueueOptions<Payload> = {}, kind: 'queue' | 'workflow' = 'queue'): { queued: Queue<Payload, Progress>, admin: QueueAdmin } {
|
|
479
476
|
const attempts = options.attempts ?? DEFAULT_ATTEMPTS
|
|
480
477
|
const backoff = durationSeconds(options.backoff ?? DEFAULT_BACKOFF, `queue('${name}')'s backoff`) * 1000
|
|
481
|
-
const lostAfter = durationSeconds(options.timeout ??
|
|
478
|
+
const lostAfter = durationSeconds(options.timeout ?? DEFAULT_LOST_AFTER, `queue('${name}')'s timeout`) * 1000
|
|
482
479
|
const concurrency = options.concurrency ?? 1
|
|
483
480
|
const idlePoll = durationSeconds(options.idlePoll ?? DEFAULT_IDLE_POLL, `queue('${name}')'s idlePoll`) * 1000
|
|
484
481
|
const keepFailed = options.failedTtl === false ? undefined : durationSeconds(options.failedTtl ?? DEFAULT_KEEP_FAILED, `queue('${name}')'s failedTtl`) * 1000
|
package/src/server/rate-limit.ts
CHANGED
|
@@ -16,8 +16,6 @@ export interface RateLimiter extends RateLimit {
|
|
|
16
16
|
count: (from: Request | string, server?: Server<unknown> | null, weight?: number) => Promise<RateWindow & { wait: number | undefined }>
|
|
17
17
|
// For a guard: takes its `ctx`, counts the request under the limit's `key` or the client's address and, once over the limit, sets `Retry-After` and denies with 429, `message` (a text or a function of the seconds to wait) in place of kay's.
|
|
18
18
|
check: (ctx: Pick<GuardContext, 'request' | 'headers' | 'deny' | 'locale' | 'cookies' | 'locals'>, message?: string | ((wait: number) => string)) => Promise<void>
|
|
19
|
-
/** @deprecated `check(ctx, message?)`, as `limiter().enforce(key)` counts under a key and refuses nothing. Removed in 1.108; `deprecated-rate-enforce` rewrites it. */
|
|
20
|
-
enforce: (ctx: Pick<GuardContext, 'request' | 'headers' | 'deny' | 'locale' | 'cookies' | 'locals'>, message?: string | ((wait: number) => string)) => Promise<void>
|
|
21
19
|
}
|
|
22
20
|
|
|
23
21
|
// A limit for a guard, an API route or a library, counted as an action's `rateLimit` is: `max` attempts from one client every `window`, under `name`, which limits sharing it count together.
|
|
@@ -53,7 +51,6 @@ export function rateLimit(name: string, limit: RateLimit): RateLimiter {
|
|
|
53
51
|
...limit,
|
|
54
52
|
count,
|
|
55
53
|
hit: async (from, server, weight) => (await count(from, server, weight)).wait,
|
|
56
|
-
enforce: async (ctx, message) => limiter.check(ctx, message),
|
|
57
54
|
check: async (ctx, message) => {
|
|
58
55
|
const { request } = ctx
|
|
59
56
|
const key = await actionKey(name, limiter, request, clientAddress(request, undefined), () => ({ request, locale: ctx.locale, cookies: ctx.cookies, locals: ctx.locals }))
|
|
@@ -163,7 +163,7 @@ function outcomeScript(outcome: Outcome | null): string {
|
|
|
163
163
|
text = encodeValue(outcome.succeeded ? outcome : { ...outcome, values: {} })
|
|
164
164
|
}
|
|
165
165
|
catch (error) {
|
|
166
|
-
kayLog('warn', `what ${outcome.action} ${outcome.succeeded ? 'returned' : 'passed to ctx.
|
|
166
|
+
kayLog('warn', `what ${outcome.action} ${outcome.succeeded ? 'returned' : 'passed to ctx.deny'} cannot reach the page's islands: ${unsendable(error) ?? String(error)}`)
|
|
167
167
|
|
|
168
168
|
return ''
|
|
169
169
|
}
|
package/src/server/routes.ts
CHANGED
|
@@ -74,7 +74,7 @@ export interface Route {
|
|
|
74
74
|
special: SpecialPages
|
|
75
75
|
// `_guard.ts` files covering the page and its actions, outermost first.
|
|
76
76
|
guards: GuardFile[]
|
|
77
|
-
// No guard is asked of it on a site with `
|
|
77
|
+
// No guard is asked of it on a site with `guards.default` closed: it sets `guards: false`, or a library serves it.
|
|
78
78
|
open?: true | undefined
|
|
79
79
|
// The extension giving the editor serves it: one of its own screens, which renders no editor over it in edit mode.
|
|
80
80
|
editorOwn?: true | undefined
|
|
@@ -240,12 +240,13 @@ export function servedPaths(routes: Route[]): Set<string> {
|
|
|
240
240
|
return new Set(routes.flatMap(route => patternShapes(route.pattern)))
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
-
// Every file the reach walk meets while scanning the routes
|
|
243
|
+
// Every file the reach walk meets while scanning the routes, the fallback pages and the endpoints, with what it reads of each, for `kay build` to record.
|
|
244
244
|
export async function contextReadsOf(routesDir: string, mounts: RouteMount[]): Promise<ContextReads> {
|
|
245
245
|
const reads: ContextReads = { keys: new Map(), edges: new Map(), recorded: false }
|
|
246
246
|
|
|
247
247
|
await scanRoutes(routesDir, mounts, reads)
|
|
248
248
|
await specialPagesOf(routeTrees(routesDir, mounts), '', reads)
|
|
249
|
+
await scanEndpoints(routesDir, mounts, reads)
|
|
249
250
|
|
|
250
251
|
return reads
|
|
251
252
|
}
|
|
@@ -299,7 +300,10 @@ export async function scanRoutes(routesDir: string, mounts: RouteMount[] = [], r
|
|
|
299
300
|
}
|
|
300
301
|
|
|
301
302
|
// The app's endpoint files, then each mounted library's that the app has none of at the same path.
|
|
302
|
-
|
|
303
|
+
// Their guards place the special pages' layouts, so what the pages reach is open first, as a lookup of special pages opens it.
|
|
304
|
+
export async function scanEndpoints(routesDir: string, mounts: RouteMount[] = [], reads?: ContextReads): Promise<Endpoint[]> {
|
|
305
|
+
await openReaches(mounts, reads, false)
|
|
306
|
+
|
|
303
307
|
const trees = routeTrees(routesDir, mounts)
|
|
304
308
|
const endpoints: Endpoint[] = []
|
|
305
309
|
const read: LayoutsRead = new Map()
|
package/src/server/scope.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { LoadScope, ServerScope } from '../runtime/reactive'
|
|
|
4
4
|
import { AsyncLocalStorage } from 'node:async_hooks'
|
|
5
5
|
import { setRequestOutcome } from '../runtime/action'
|
|
6
6
|
import { setEndedEntryNote } from '../runtime/ended-entry'
|
|
7
|
+
import { noteQuery } from '../runtime/island.server'
|
|
7
8
|
import { readParam } from '../runtime/query-param'
|
|
8
9
|
import { setRequestCookieScope, setServerScope } from '../runtime/reactive'
|
|
9
10
|
import { setCurrentUrl } from '../runtime/with-query'
|
|
@@ -51,7 +52,7 @@ export function inServerScope<T>(request: Request, report: (error: unknown) => v
|
|
|
51
52
|
|
|
52
53
|
const url = requestUrl(request)
|
|
53
54
|
|
|
54
|
-
return store.run({ request, values: new WeakMap(), cookie, param: name => readParam(rules, name, url.searchParams), report, path: url.pathname }, run)
|
|
55
|
+
return store.run({ request, values: new WeakMap(), cookie, param: name => readParam(rules, name, url.searchParams), read: noteQuery, report, path: url.pathname }, run)
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
// The request the render being run answers.
|
|
@@ -63,7 +64,7 @@ const outcomes = new AsyncLocalStorage<() => Outcome | null>()
|
|
|
63
64
|
|
|
64
65
|
setRequestOutcome(() => outcomes.getStore()?.())
|
|
65
66
|
|
|
66
|
-
// Answers a request whose form post, if any, `read` gives: an action's `form.failed()` and `
|
|
67
|
+
// Answers a request whose form post, if any, `read` gives: an action's `form.failed()` and `data()` read it in its loads and templates alike.
|
|
67
68
|
export function withOutcome<T>(read: () => Outcome | null, run: () => T): T {
|
|
68
69
|
return outcomes.run(read, run)
|
|
69
70
|
}
|
package/src/server/session.ts
CHANGED
|
@@ -41,9 +41,8 @@ export type DeletableSessionStore = SessionStore & { deleteWhere: (match: Sessio
|
|
|
41
41
|
// Where sessions live when the cookie only carries their id; each method may answer synchronously or with a promise.
|
|
42
42
|
export interface SessionStore extends StoreBase {
|
|
43
43
|
get: (id: string) => MaybePromise<SessionData | undefined>
|
|
44
|
-
// Past `maxAge` the store may forget the session: a `Duration
|
|
45
|
-
|
|
46
|
-
set(id: string, data: SessionData, maxAge: Duration | number): MaybePromise<void>
|
|
44
|
+
// Past `maxAge` the store may forget the session: a `Duration`; `lengthMs(maxAge)` from `kay` reads it.
|
|
45
|
+
set: (id: string, data: SessionData, maxAge: Duration) => MaybePromise<void>
|
|
47
46
|
delete: (id: string) => MaybePromise<void>
|
|
48
47
|
// Deletes every session whose data `match` returns true for, such as a person's once they asked to be erased or their password changed, resolving with how many went.
|
|
49
48
|
deleteWhere?: ((match: (data: SessionData) => boolean) => MaybePromise<number>) | undefined
|
|
@@ -422,7 +421,7 @@ class RequestSession<Data extends object> implements Session<Data> {
|
|
|
422
421
|
|
|
423
422
|
if (store) {
|
|
424
423
|
this.id ??= nodeCrypto().randomBytes(32).toString('base64url')
|
|
425
|
-
await store.set(this.id, this.data, lengthFor(
|
|
424
|
+
await store.set(this.id, this.data, lengthFor(maxAge * 1000))
|
|
426
425
|
sealed = { id: this.id, issued: now, started, ...this.own }
|
|
427
426
|
}
|
|
428
427
|
|
|
@@ -526,8 +525,8 @@ function opened(value: string, keys: Buffer[], name: string): { sealed: Sealed,
|
|
|
526
525
|
}
|
|
527
526
|
}
|
|
528
527
|
|
|
529
|
-
// The `maxAge` a store is given, a `Duration
|
|
530
|
-
function storeMs(maxAge: Duration
|
|
528
|
+
// The `maxAge` a store is given, a `Duration`: one that is not would store a session that never expires, or none.
|
|
529
|
+
function storeMs(maxAge: Duration): number {
|
|
531
530
|
return lengthMs(maxAge, 'a session store\'s maxAge')
|
|
532
531
|
}
|
|
533
532
|
|
package/src/server/setup.ts
CHANGED
|
@@ -126,7 +126,7 @@ async function setupWith<Claimed>(project: Project, loadClient: () => Promise<Cl
|
|
|
126
126
|
|
|
127
127
|
await source.prepare(root, config.librarySettings, mode.prebuilt ? paths.output : undefined)
|
|
128
128
|
// Scanned beside the routes, which the refusals before the build need.
|
|
129
|
-
const scanning = Promise.all([publicFiles(paths.public), source.endpoints(
|
|
129
|
+
const scanning = Promise.all([publicFiles(paths.public), source.endpoints(project, mounts)])
|
|
130
130
|
|
|
131
131
|
void Promise.allSettled([scanning])
|
|
132
132
|
|
package/src/server/signals.ts
CHANGED
|
@@ -71,6 +71,12 @@ export class Denied {
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
// The text form `deny(403, 'text')` went in 1.109: a string where the options go is a mistake to name, not a refusal with no message.
|
|
75
|
+
function refuseText(options: unknown): void {
|
|
76
|
+
if (typeof options === 'string')
|
|
77
|
+
throw new KayError('argument-invalid', 'kay: ctx.deny takes a status and `{ message, errors, data }`: write `ctx.deny(403, { message: \'text\' })`')
|
|
78
|
+
}
|
|
79
|
+
|
|
74
80
|
// What `ctx.redirect`, `ctx.notFound` and `ctx.deny` do in every kind of context: a read is redirected with 302, a post with 303.
|
|
75
81
|
export function stoppers(request: Request): Pick<RequestContext, 'redirect' | 'notFound' | 'deny'> {
|
|
76
82
|
const status = request.method === 'GET' || request.method === 'HEAD' ? 302 : 303
|
|
@@ -82,24 +88,28 @@ export function stoppers(request: Request): Pick<RequestContext, 'redirect' | 'n
|
|
|
82
88
|
notFound: () => {
|
|
83
89
|
throw new NotFound()
|
|
84
90
|
},
|
|
85
|
-
deny: (code
|
|
86
|
-
|
|
91
|
+
deny: (code?: number, options?: DenyOptions<ErrorData>) => {
|
|
92
|
+
refuseText(options)
|
|
93
|
+
|
|
94
|
+
throw new Denied(code ?? 403, options?.message, options?.data, options?.errors as Record<string, string> | undefined)
|
|
87
95
|
},
|
|
88
96
|
}
|
|
89
97
|
}
|
|
90
98
|
|
|
91
|
-
// `ctx.deny(status, { message, errors, data })` in an action fails the post
|
|
99
|
+
// `ctx.deny(status, { message, errors, data })` in an action fails the post, a form re-rendered with the message, the fields and `data`, a call throwing an `ActionError`. A deny with no options stops as a guard's does.
|
|
92
100
|
export function actionStoppers(request: Request): Pick<RequestContext, 'redirect' | 'notFound' | 'deny'> {
|
|
93
101
|
const { deny: stop, ...rest } = stoppers(request)
|
|
94
102
|
|
|
95
|
-
const deny = (status = 403, second?:
|
|
96
|
-
|
|
97
|
-
return stop(status, second as string, data)
|
|
103
|
+
const deny = (status = 403, second?: DenyOptions<ErrorData>): never => {
|
|
104
|
+
refuseText(second)
|
|
98
105
|
|
|
99
106
|
if (second === undefined || ((second.message === undefined || second.message === '') && second.data === undefined && Object.keys(second.errors ?? {}).length === 0))
|
|
100
107
|
return stop(status)
|
|
101
108
|
|
|
102
|
-
|
|
109
|
+
if (!Number.isInteger(status) || status < 400 || status > 599)
|
|
110
|
+
throw new KayError('argument-invalid', `kay: ctx.deny takes an error status, from 400 to 599, not ${status}`)
|
|
111
|
+
|
|
112
|
+
// A text `data` with no `message` is the form's message; one with only data or fields has none.
|
|
103
113
|
throw new RefusedError({ status, message: second.message ?? (typeof second.data === 'string' ? second.data : ''), errors: (second.errors ?? {}) as Record<string, string>, data: second.data })
|
|
104
114
|
}
|
|
105
115
|
|