@kayjs/kay 1.107.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 +1875 -3815
- package/editors/zed/extension.toml +2 -2
- package/llms/action-protection.md +1 -1
- package/llms/actions-from-islands.md +5 -5
- 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-libraries.md +1 -1
- package/llms/component-library-conventions.md +1 -1
- package/llms/components.md +4 -4
- package/llms/deprecated-lints.md +1 -7
- 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 +5 -3
- 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 +92 -58
- package/llms/whats-new-archive.md +36 -1
- package/llms/whats-new.md +18 -39
- package/llms.txt +6 -7
- package/package.json +6 -10
- package/src/build/client.ts +7 -6
- package/src/build/icon-slots.ts +140 -0
- package/src/build/libraries.ts +24 -2
- package/src/build/plugin.ts +10 -0
- package/src/build/route-sizes.ts +2 -3
- package/src/build/runtime-chunk.ts +2 -2
- package/src/build/source-files.ts +8 -3
- package/src/build/variants.ts +90 -1
- 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 +4 -9
- package/src/check/renamed-packages.ts +3 -63
- package/src/check/shadow-types.ts +4 -104
- 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/dead-code.ts +22 -0
- package/src/compiler/deprecated-library.ts +0 -12
- package/src/compiler/deprecated-lints.ts +4 -505
- package/src/compiler/deprecated-ui-props.ts +5 -5
- package/src/compiler/dom-property.ts +23 -0
- package/src/compiler/dom.ts +15 -15
- 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/package-names.ts +1 -1
- package/src/runtime/action-call.ts +39 -335
- 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 +332 -0
- 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/client.d.ts +1 -1
- package/types/build/client.d.ts.map +1 -1
- package/types/build/icon-slots.d.ts +7 -0
- package/types/build/icon-slots.d.ts.map +1 -0
- package/types/build/libraries.d.ts +2 -0
- package/types/build/libraries.d.ts.map +1 -1
- package/types/build/plugin.d.ts +1 -0
- package/types/build/plugin.d.ts.map +1 -1
- package/types/build/route-sizes.d.ts.map +1 -1
- package/types/build/source-files.d.ts.map +1 -1
- package/types/build/variants.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/renamed-packages.d.ts +0 -3
- package/types/check/renamed-packages.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/dead-code.d.ts +9 -0
- package/types/compiler/dead-code.d.ts.map +1 -0
- package/types/compiler/deprecated-library.d.ts.map +1 -1
- package/types/compiler/deprecated-lints.d.ts +0 -560
- 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/dom-property.d.ts +9 -0
- package/types/compiler/dom-property.d.ts.map +1 -0
- package/types/compiler/dom.d.ts +1 -0
- package/types/compiler/dom.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 -572
- 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 +23 -0
- package/types/runtime/action-run.d.ts.map +1 -0
- 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/app-stages.ts
CHANGED
|
@@ -35,7 +35,7 @@ import { kayLog } from '../runtime/log'
|
|
|
35
35
|
import { BUILD_HEADER, DRAFT_ROUTE } from '../runtime/swap'
|
|
36
36
|
import { registerActionRoutes } from './actions'
|
|
37
37
|
import { serveApi } from './api'
|
|
38
|
-
import { apiPathOf,
|
|
38
|
+
import { apiPathOf, mcpInstructions, mcpRateLimit, RESOURCE_METADATA, sharedGuards } from './api-modules'
|
|
39
39
|
import { hookLifecycle, hookRequests } from './app-hooks'
|
|
40
40
|
import { rebaseCss, rebaseRedirects } from './base'
|
|
41
41
|
import { DEFAULT_BODY_LIMIT, limitBodies, mountLimits } from './body'
|
|
@@ -66,7 +66,7 @@ import { liveConnections, serveLive } from './live'
|
|
|
66
66
|
import { warnOfLocalFiles } from './local-files'
|
|
67
67
|
import { announceStart, loggerOf, logRequests, pathOf, requestRefusalLogger, useLogger } from './log'
|
|
68
68
|
import { mcpBodyLimit, receiveDispatched, serveMcp, serveToolCallsThrough } from './mcp'
|
|
69
|
-
import {
|
|
69
|
+
import { METRICS_PATH, metricsOf, serveMetrics } from './metrics'
|
|
70
70
|
import { newTabStyles } from './new-tab'
|
|
71
71
|
import { countMissing, knowRedirects } from './not-found'
|
|
72
72
|
import { INSTALL_OFFER, serveServiceWorker } from './offline'
|
|
@@ -178,15 +178,10 @@ interface BootInput {
|
|
|
178
178
|
late: LateApp
|
|
179
179
|
mcpAt: string | undefined
|
|
180
180
|
mcpKey: string | false | undefined
|
|
181
|
-
// What `
|
|
181
|
+
// What `guards.default` came to once the routes were scanned.
|
|
182
182
|
required: GuardRequirement
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
-
// The paths a request for the MCP endpoint may come in at: its own, and the former one while it redirects.
|
|
186
|
-
function mcpEndpoints(at: string | undefined, former: Claim | undefined, served: ServedPaths): string[] {
|
|
187
|
-
return [...at === undefined ? [] : [at], ...former !== undefined && served.holds(former) ? [former.path] : []]
|
|
188
|
-
}
|
|
189
|
-
|
|
190
185
|
// What every stage shares, worked out from the setup before the first hook.
|
|
191
186
|
export function bootOf(input: BootInput) {
|
|
192
187
|
const { env, project: { config: options }, setup: { client, scripts, styles, locales } } = input
|
|
@@ -199,10 +194,6 @@ export function bootOf(input: BootInput) {
|
|
|
199
194
|
// Offered, so an app file at the path keeps it; only a running server counts, as `kay dev` restarts on every change and an export serves nothing.
|
|
200
195
|
const metricsConfig = env.serving ? metricsOf(options.ops?.metrics) : undefined
|
|
201
196
|
const metrics: Claim | undefined = metricsConfig && { path: options.endpoints?.metrics ?? METRICS_PATH, owner: 'the metrics route', kind: 'kay' }
|
|
202
|
-
// Where the MCP endpoint was served before 1.105, answered in place until 2.0 by an app that did not move it, unless an app file serves something there.
|
|
203
|
-
const formerMcp: Claim | undefined = input.mcpAt !== undefined && options.endpoints?.mcp === undefined ? { path: FORMER_MCP_PATH, owner: '`mcp`', kind: 'kay', method: 'ALL' } : undefined
|
|
204
|
-
// Where the metrics were served before 1.105, answered as well until 1.108 by an app that did not move them, unless an app file serves something there.
|
|
205
|
-
const formerMetrics: Claim | undefined = metrics && options.endpoints?.metrics === undefined ? { path: FORMER_METRICS_PATH, owner: 'the metrics route', kind: 'kay' } : undefined
|
|
206
197
|
// Offered, so an app file at the path keeps it; the check is served once every claim is in, and only where it still holds the path.
|
|
207
198
|
const health: Claim | undefined = options.ops?.health === false ? undefined : { path: options.endpoints?.health ?? HEALTH_PATH, owner: 'the health check', kind: 'kay' }
|
|
208
199
|
const log = loggerOf(options.ops?.observe?.log, env.production)
|
|
@@ -222,9 +213,6 @@ export function bootOf(input: BootInput) {
|
|
|
222
213
|
lifecycle: { draining: false },
|
|
223
214
|
hasPreview: options.preview !== undefined && options.preview !== false,
|
|
224
215
|
metrics,
|
|
225
|
-
formerMetrics,
|
|
226
|
-
// Where the MCP endpoint was served before 1.105, answered as the endpoint is until 2.0 by an app that did not move it, unless an app file serves something there.
|
|
227
|
-
formerMcp,
|
|
228
216
|
health,
|
|
229
217
|
registered,
|
|
230
218
|
// Maps a browser's stack back to the source, for the error reports and the dev tool.
|
|
@@ -270,9 +258,8 @@ export function knowPages({ app, env, options, setup: { matchers }, routes, tabl
|
|
|
270
258
|
}
|
|
271
259
|
|
|
272
260
|
// Only a kept page reads the count, so a build keeping none registers no hook for it.
|
|
273
|
-
export function keptPageWrites({ app, setup: { client }, mcpAt
|
|
274
|
-
|
|
275
|
-
const own = () => [...mcpAt === undefined ? [] : [mcpAt], ...formerMcp !== undefined && served.holds(formerMcp) ? [formerMcp.path] : []]
|
|
261
|
+
export function keptPageWrites({ app, setup: { client }, mcpAt }: Boot): Writes {
|
|
262
|
+
const own = () => mcpAt === undefined ? [] : [mcpAt]
|
|
276
263
|
|
|
277
264
|
return [...client.pages.values()].some(page => page.kept === true) ? countWrites(app, own) : NO_WRITES
|
|
278
265
|
}
|
|
@@ -310,7 +297,7 @@ function hostsToAnswer(setting: SecurityConfig | boolean | undefined, site: stri
|
|
|
310
297
|
|
|
311
298
|
// Who the request is from and whether it may come, as the steps of `receive`: the proxy it came through, the server's own mark, the proxy key, the dev hosts, the hosts; then the security headers on every answer.
|
|
312
299
|
// The steps run in kay's pipeline, which Elysia's first `onRequest` hook hands every request to while the routes are not on kay's table.
|
|
313
|
-
export function trustRequests({ app, kay, env, options, project, served, security, filePaths, setup, mcpAt, mcpKey, metrics,
|
|
300
|
+
export function trustRequests({ app, kay, env, options, project, served, security, filePaths, setup, mcpAt, mcpKey, metrics, log, health }: Boot): void {
|
|
314
301
|
const { receive } = kay.pipeline.phases
|
|
315
302
|
|
|
316
303
|
setRequestIdHeader(options.ops?.observe?.requestIdHeader)
|
|
@@ -321,7 +308,7 @@ export function trustRequests({ app, kay, env, options, project, served, securit
|
|
|
321
308
|
receiveInternal(request)
|
|
322
309
|
})
|
|
323
310
|
|
|
324
|
-
const key = requireProxyKey(checkProxy(options.proxy), { root: setup.source.runtimeRoot(project.root), dev: env.dev, exported: env.exported, base: env.base, health: health?.path, endpoint: mcpKey === undefined ? undefined : () =>
|
|
311
|
+
const key = requireProxyKey(checkProxy(options.proxy), { root: setup.source.runtimeRoot(project.root), dev: env.dev, exported: env.exported, base: env.base, health: health?.path, endpoint: mcpKey === undefined ? undefined : () => mcpAt === undefined ? [] : [mcpAt], metrics: () => metrics !== undefined && served.holds(metrics) ? [metrics.path] : [], logRefused: requestRefusalLogger(log), security })
|
|
325
312
|
const foreign = refuseForeignHosts(setup.site, security)
|
|
326
313
|
const hosts = hostsToAnswer(options.security, setup.site, env)
|
|
327
314
|
|
|
@@ -407,7 +394,7 @@ export function identifyRequests({ app, env, setup: { client } }: Boot): void {
|
|
|
407
394
|
}
|
|
408
395
|
|
|
409
396
|
// kay's endpoints answered ahead of the extensions: the health check, the metrics and the public env, with the jobs page's path claimed. Returns the jobs page, served after the extensions whose values its guard reads.
|
|
410
|
-
export function kayEndpoints({ app, env, options, project, setup, served, lifecycle, health, metrics,
|
|
397
|
+
export function kayEndpoints({ app, env, options, project, setup, served, lifecycle, health, metrics, security }: Boot, publicModules: string[]) {
|
|
411
398
|
if (health) {
|
|
412
399
|
served.offer(health)
|
|
413
400
|
// Before the extension servers, whose hooks it answers ahead of; it answers only where the claims, known once all are in, leave it the path.
|
|
@@ -423,10 +410,7 @@ export function kayEndpoints({ app, env, options, project, setup, served, lifecy
|
|
|
423
410
|
if (metrics) {
|
|
424
411
|
served.offer(metrics)
|
|
425
412
|
|
|
426
|
-
|
|
427
|
-
served.offer(formerMetrics)
|
|
428
|
-
|
|
429
|
-
serveMetrics(app, { root: setup.source.runtimeRoot(project.root), path: metrics.path, base: env.base, proxy: checkProxy(options.proxy), token: metricsOf(options.ops?.metrics)?.token, health: health?.path, holds: () => served.holds(metrics), former: formerMetrics && { path: formerMetrics.path, holds: () => served.holds(formerMetrics) }, connections: liveConnections })
|
|
413
|
+
serveMetrics(app, { root: setup.source.runtimeRoot(project.root), path: metrics.path, base: env.base, proxy: checkProxy(options.proxy), token: metricsOf(options.ops?.metrics)?.token, health: health?.path, holds: () => served.holds(metrics), connections: liveConnections })
|
|
430
414
|
}
|
|
431
415
|
|
|
432
416
|
if (options.publicEnv)
|
|
@@ -591,7 +575,7 @@ type Served = Awaited<ReturnType<typeof appRoutes>>
|
|
|
591
575
|
// The rules a redirect added while the site runs is checked against, the API's claims and the body limits of every route. Returns where the OpenAPI document and the MCP metadata go.
|
|
592
576
|
// Not async, as the closures the runtime redirects keep past the app would hold an async function's parameters, the app among them.
|
|
593
577
|
export function limitBodiesAndClaimApi(boot: Boot, { actionLimits, api, endpointLimits }: Served, servers: unknown[]) {
|
|
594
|
-
const { app, env, options, served, setup: { client }, table, hasPreview, mcpAt
|
|
578
|
+
const { app, env, options, served, setup: { client }, table, hasPreview, mcpAt } = boot
|
|
595
579
|
// Claimed before kay's own files, which give way to them.
|
|
596
580
|
const openapi = openApiSettings(options.openapi)
|
|
597
581
|
const apiAt = apiPathOf(options.endpoints?.api)
|
|
@@ -618,15 +602,13 @@ export function limitBodiesAndClaimApi(boot: Boot, { actionLimits, api, endpoint
|
|
|
618
602
|
}
|
|
619
603
|
}
|
|
620
604
|
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
limitBodies(app, options.limits?.body ?? DEFAULT_BODY_LIMIT, new Map([...actionLimits, ...hasPreview ? [[DRAFT_ROUTE, DRAFT_BODY_LIMIT] as const] : [], ...mcpAt === undefined ? [] : [[mcpAt, mcpBodyLimit] as const], ...formerAt === undefined ? [] : [[formerAt, mcpBodyLimit] as const]]), mountLimits(api.limits, options.extensions, options.limits?.byPath, servers), [...api.routeLimits, ...endpointLimits])
|
|
605
|
+
limitBodies(app, options.limits?.body ?? DEFAULT_BODY_LIMIT, new Map([...actionLimits, ...hasPreview ? [[DRAFT_ROUTE, DRAFT_BODY_LIMIT] as const] : [], ...mcpAt === undefined ? [] : [[mcpAt, mcpBodyLimit] as const]]), mountLimits(api.limits, options.extensions, options.limits?.byPath, servers), [...api.routeLimits, ...endpointLimits])
|
|
624
606
|
|
|
625
|
-
return { openapi, apiAt, servesOpenApi, metadataPaths
|
|
607
|
+
return { openapi, apiAt, servesOpenApi, metadataPaths }
|
|
626
608
|
}
|
|
627
609
|
|
|
628
610
|
// The OpenAPI document and the MCP endpoint, registered last before the pages.
|
|
629
|
-
export async function apiDocuments(boot: Boot, { toolActions, apiModules, api }: Served, actionOptions: ActionOptions, { openapi, apiAt, servesOpenApi, metadataPaths
|
|
611
|
+
export async function apiDocuments(boot: Boot, { toolActions, apiModules, api }: Served, actionOptions: ActionOptions, { openapi, apiAt, servesOpenApi, metadataPaths }: ReturnType<typeof limitBodiesAndClaimApi>): Promise<void> {
|
|
630
612
|
const { app, env, options, required, setup: { locales }, project: { paths }, mcpAt, mcpKey } = boot
|
|
631
613
|
|
|
632
614
|
// The actions that opted in to being tools are in the document beside the routes, and the MCP endpoint reads its tools from it.
|
|
@@ -642,7 +624,7 @@ export async function apiDocuments(boot: Boot, { toolActions, apiModules, api }:
|
|
|
642
624
|
serveOpenApi(app, document, openapi, await covering(false), actionOptions, apiAt, options.endpoints?.openapi)
|
|
643
625
|
|
|
644
626
|
if (mcpAt !== undefined && document) {
|
|
645
|
-
serveMcp(app, document, { title: (document.info as { title: string }).title, version: (document.info as { version: string }).version, base: env.base, guards: await covering(true), actions: actionOptions, metadataPaths, path: mcpAt,
|
|
627
|
+
serveMcp(app, document, { title: (document.info as { title: string }).title, version: (document.info as { version: string }).version, base: env.base, guards: await covering(true), actions: actionOptions, metadataPaths, path: mcpAt, rateLimit: mcpRateLimit(options.mcp), instructions: mcpInstructions(options.mcp), key: mcpKey, dev: env.dev, outputs: actionOptions.toolOutputs })
|
|
646
628
|
}
|
|
647
629
|
}
|
|
648
630
|
|
|
@@ -665,7 +647,7 @@ export function reports({ app, options, setup: { i18n, site, collections }, hasP
|
|
|
665
647
|
// The paths the config names resolve where the server runs, and development serves WebP, so a page's first load does not wait on AVIF encoding.
|
|
666
648
|
// What `images.resolve` runs behind: the `guards` given, none when they are `false`, and a refusal when the app gave none, as every feature reading private files closes.
|
|
667
649
|
function imageGuard(images: NonNullable<KayConfig['assets']>['images']): Guard | undefined {
|
|
668
|
-
const given = images?.guards
|
|
650
|
+
const given = images?.guards
|
|
669
651
|
|
|
670
652
|
if (given === false)
|
|
671
653
|
return undefined
|
package/src/server/app.ts
CHANGED
|
@@ -12,6 +12,7 @@ import type { Scanned } from './setup'
|
|
|
12
12
|
import { join } from 'node:path'
|
|
13
13
|
import { Elysia } from 'elysia'
|
|
14
14
|
import { KayError } from '../compiler/errors'
|
|
15
|
+
import { CONFIG_KEYS } from '../config-shape'
|
|
15
16
|
import { refuseFeedsWithoutSite } from '../content/server'
|
|
16
17
|
import { mcpInstructions, mcpPath, mcpRateLimit } from './api-modules'
|
|
17
18
|
import { actionOptionsOf, apiDocuments, appRoutes, bootOf, bootWarnings, buildFiles, compressAnswers, files, hookLifecycleOf, hookRequestsOf, identifyRequests, kayEndpoints, keptPageWrites, knowPages, lateApp, limitBodiesAndClaimApi, logAnswers, pageRoutes, reports, rewriteAnswers, serveDevRoutes, serverMode, siteFiles, stopOnSignals, trustRequests, useExtensions } from './app-stages'
|
|
@@ -38,8 +39,8 @@ import { ServedPaths } from './served-paths'
|
|
|
38
39
|
import { setupPages } from './setup'
|
|
39
40
|
import { projectSource } from './source'
|
|
40
41
|
|
|
41
|
-
// The options of `pages()` and `testSite()`: `config` holds what wins over the project's `kay.config.ts`, key by key, one bag level deep.
|
|
42
|
-
export interface PagesOptions
|
|
42
|
+
// The options of `pages()` and `testSite()`: `config` holds what wins over the project's `kay.config.ts`, key by key, one bag level deep.
|
|
43
|
+
export interface PagesOptions {
|
|
43
44
|
// Config laid over the project's `kay.config.ts`, as `kay.config.ts` writes it: `pages({ config: { client: { navigation: false } } })`.
|
|
44
45
|
config?: ConfigInput | undefined
|
|
45
46
|
// Project root: island ids and `.kay/` output are relative to it. Defaults to the working directory.
|
|
@@ -50,9 +51,13 @@ export interface PagesOptions extends ConfigInput {
|
|
|
50
51
|
prebuilt?: boolean | undefined
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
// The options with the keys of `config` laid
|
|
54
|
-
export function flatOptions<Options extends PagesOptions>(options: Options): Omit<Options, 'config'> {
|
|
54
|
+
// The options with the keys of `config` laid at one level beside the others, so what reads the options sees the config's keys together. A config key written beside `root` is refused.
|
|
55
|
+
export function flatOptions<Options extends PagesOptions>(options: Options): Omit<Options, 'config'> & ConfigInput {
|
|
55
56
|
const { config, ...rest } = options
|
|
57
|
+
const beside = Object.keys(rest).filter(key => CONFIG_KEYS.has(key))
|
|
58
|
+
|
|
59
|
+
if (beside.length > 0)
|
|
60
|
+
throw new KayError('config-invalid', `kay: the options have config keys beside \`root\`: ${beside.map(key => `\`${key}\``).join(', ')}; write them in \`config\``)
|
|
56
61
|
|
|
57
62
|
return config === undefined ? rest : { ...rest, ...Object.fromEntries(Object.entries(config).filter(([, value]) => value !== undefined)) }
|
|
58
63
|
}
|
|
@@ -182,7 +187,7 @@ export async function pagesApp(project: Project<ServedOptions>, loadClient: () =
|
|
|
182
187
|
const setup = await setupPages(project, loadClient, false, late.spell, scanned => refuseScanned(project, scanned), exported)
|
|
183
188
|
const { served, table, publicServed, redirects, mcpAt } = setup.claimed
|
|
184
189
|
|
|
185
|
-
// The API modules are read here, as an unset `
|
|
190
|
+
// The API modules are read here, as an unset `guards.default` comes to what the app's own routes, endpoints and API modules guard.
|
|
186
191
|
const required = guardRequirement(requiredBy(options), setup.routes, setup.endpoints, await setup.api)
|
|
187
192
|
const routes = await servedRoutes(setup.routes, setup.claimed.routes, required)
|
|
188
193
|
const app = new Elysia({ name: 'kay/pages', seed: root })
|
package/src/server/auth-mails.ts
CHANGED
|
@@ -21,8 +21,6 @@ export interface AuthMailData {
|
|
|
21
21
|
locale: string
|
|
22
22
|
// How long the mail's link and its code work, for the ones it carries, as durations: `{ link: '24h', code: '10m' }`. `lifetime(duration, locale)` words them.
|
|
23
23
|
ttl?: { link?: Duration, code?: Duration } | undefined
|
|
24
|
-
/** @deprecated Written `ttl`; `deprecated-ttl-names` rewrites it. Removed in 1.108. */
|
|
25
|
-
maxAge?: { link?: Duration, code?: Duration } | undefined
|
|
26
24
|
}
|
|
27
25
|
|
|
28
26
|
const LINK = 'https://example.com/auth?token=sample'
|
package/src/server/env-state.ts
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import { existsSync, readFileSync, statSync } from 'node:fs'
|
|
2
|
-
import { dirname, join } from 'node:path'
|
|
1
|
+
import { existsSync, readFileSync, realpathSync, statSync } from 'node:fs'
|
|
2
|
+
import { dirname, join, sep } from 'node:path'
|
|
3
3
|
|
|
4
4
|
// What the environment loader and the commands that run without it share, apart from `./env` so `kay check` and the editor load no Elysia.
|
|
5
5
|
// On the global object, so a copy of kay the app loads beside the CLI's sees it too.
|
|
6
6
|
const BUILDING = Symbol.for('kay.building')
|
|
7
|
+
const LISTED = Symbol.for('kay.envListed')
|
|
7
8
|
|
|
8
9
|
// `kay build` renders pages, and `kay check` reads content and messages, without the server's environment: from then on a variable missing or refused fails the page reading it rather than the module declaring it.
|
|
9
10
|
export function buildingWithoutEnv(): void {
|
|
10
|
-
|
|
11
|
+
const holder = globalThis as { [BUILDING]?: boolean, [LISTED]?: DeclaredEnv[] }
|
|
12
|
+
|
|
13
|
+
holder[BUILDING] = true
|
|
14
|
+
// The calls of `defineEnv` from here on are kept, so a module the config imports, which `kay env` cannot import again, still lists.
|
|
15
|
+
holder[LISTED] ??= []
|
|
11
16
|
}
|
|
12
17
|
|
|
13
18
|
const LOADING = Symbol.for('kay.loading')
|
|
@@ -22,9 +27,10 @@ export function loading(): boolean {
|
|
|
22
27
|
return (globalThis as { [LOADING]?: boolean })[LOADING] === true
|
|
23
28
|
}
|
|
24
29
|
|
|
25
|
-
const LISTED = Symbol.for('kay.envListed')
|
|
26
30
|
// The caller's file in a stack frame such as `at /app/src/env.ts:3:20` or `at env (file:///app/src/env.ts:3:20)`.
|
|
27
31
|
const FRAME_FILE = /^at (?:.*? \()?(?:file:\/\/)?(\/[^():]+):\d+:\d+\)?$/
|
|
32
|
+
// A module imported under a query to read it again is the file before it.
|
|
33
|
+
const QUERY = /\?.*$/
|
|
28
34
|
// A library of kay declares its variables for the app that builds it, so the app's module is the one to list them under.
|
|
29
35
|
const KAY_LIBRARY = /^@kayjs\/(?!kay(?:\/|$))/
|
|
30
36
|
const libraries = new Map<string, boolean>()
|
|
@@ -38,13 +44,11 @@ export interface DeclaredEnv {
|
|
|
38
44
|
file?: string | undefined
|
|
39
45
|
}
|
|
40
46
|
|
|
41
|
-
// `kay env`
|
|
47
|
+
// Every call of `defineEnv` since a command began building without the environment, the config's own imports included, as `kay env` cannot import a module the config already loaded again. The listing takes the calls of its project and reads the modules calling `defineEnv` that are left.
|
|
42
48
|
export function listingEnv(): DeclaredEnv[] {
|
|
43
|
-
const
|
|
49
|
+
const holder = globalThis as { [LISTED]?: DeclaredEnv[] }
|
|
44
50
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return found
|
|
51
|
+
return holder[LISTED] ??= []
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
export function recordEnv(schema: EnvSchemaRecord, declaredBy: (...args: never[]) => unknown): void {
|
|
@@ -56,6 +60,32 @@ export function recordEnv(schema: EnvSchemaRecord, declaredBy: (...args: never[]
|
|
|
56
60
|
found.push({ schema, file: callerFile(declaredBy) })
|
|
57
61
|
}
|
|
58
62
|
|
|
63
|
+
function realOf(path: string): string {
|
|
64
|
+
try {
|
|
65
|
+
return realpathSync(path)
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return path
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// A module read again declares afresh: what it declared before is dropped, whatever the stack of each load. A folder drops every module under it, a path through a link matches the file it leads to, and a file that no longer loads or exists is dropped all the same.
|
|
73
|
+
export function forgetEnvCalls(path: string): void {
|
|
74
|
+
const found = (globalThis as { [LISTED]?: DeclaredEnv[] })[LISTED]
|
|
75
|
+
|
|
76
|
+
if (found === undefined)
|
|
77
|
+
return
|
|
78
|
+
|
|
79
|
+
const target = realOf(path.replace(QUERY, ''))
|
|
80
|
+
|
|
81
|
+
for (let index = found.length - 1; index >= 0; index--) {
|
|
82
|
+
const file = found[index]!.file
|
|
83
|
+
|
|
84
|
+
if (file !== undefined && (realOf(file) === target || realOf(file).startsWith(`${target}${sep}`)))
|
|
85
|
+
found.splice(index, 1)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
59
89
|
// The file that called `declaredBy`, a library of kay's call counted as its caller's: the frames above `declaredBy` are left out, so the first one left is whoever called it.
|
|
60
90
|
export function callerFile(declaredBy: (...args: never[]) => unknown): string | undefined {
|
|
61
91
|
const holder: { stack?: string } = {}
|
|
@@ -64,7 +94,7 @@ export function callerFile(declaredBy: (...args: never[]) => unknown): string |
|
|
|
64
94
|
|
|
65
95
|
const files = (holder.stack ?? '').split('\n').map(line => FRAME_FILE.exec(line.trim())?.[1])
|
|
66
96
|
|
|
67
|
-
return files.find(file => file !== undefined && !inLibrary(file))
|
|
97
|
+
return files.find(file => file !== undefined && !inLibrary(file))?.replace(QUERY, '')
|
|
68
98
|
}
|
|
69
99
|
|
|
70
100
|
// Whether `file` belongs to a package of kay's libraries, by the name in the nearest package.json.
|
package/src/server/flash.ts
CHANGED
|
@@ -48,7 +48,7 @@ export function handedOverFlash(request: Request): Flash | undefined {
|
|
|
48
48
|
return id === null ? undefined : handedOver.get(id)
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
// The page the browser goes back to reads it through `
|
|
51
|
+
// The page the browser goes back to reads it through `data()`, unless it cannot be carried there.
|
|
52
52
|
export function writeSuccess(cookies: CookieMap, success: SuccessFlash, secure = false, base = ''): void {
|
|
53
53
|
const refusal = setFlash(cookies, success, secure, base)
|
|
54
54
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// What a start does with a route no guard covers: `true` refuses every page, layout with actions, endpoint and API module of the app, `'routes'` only its pages, endpoints and API modules, `false` none.
|
|
2
2
|
export type GuardRequirement = boolean | 'routes'
|
|
3
3
|
|
|
4
|
-
// What `guards: { default }` says of the app's routes, `'closed'`
|
|
5
|
-
export function requiredBy(config: { guards?: { default?: 'open' | 'closed' | undefined } | undefined
|
|
4
|
+
// What `guards: { default }` says of the app's routes, `'closed'` refusing every route no guard covers and `'open'` none. Undefined leaves it to what the routes guard.
|
|
5
|
+
export function requiredBy(config: { guards?: { default?: 'open' | 'closed' | undefined } | undefined }): boolean | undefined {
|
|
6
6
|
const given = config.guards?.default
|
|
7
7
|
|
|
8
|
-
return given === undefined ?
|
|
8
|
+
return given === undefined ? undefined : given === 'closed'
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
interface Access {
|
|
@@ -13,7 +13,7 @@ interface Access {
|
|
|
13
13
|
guards: readonly unknown[]
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
// What `
|
|
16
|
+
// What `guards.default` comes to once the routes are scanned: a setting is taken as it is, and an unset one refuses the routes no guard covers on a site that guards some of its own, which a site with no guard at all (a brochure) leaves open.
|
|
17
17
|
// Guards a library mounts on its own routes say nothing of the app's: those routes are `open`, and only the app's own guarded routes mark a site that has started to guard.
|
|
18
18
|
export function guardRequirement(configured: boolean | undefined, ...routes: Iterable<Access>[]): GuardRequirement {
|
|
19
19
|
if (configured !== undefined)
|
package/src/server/image.ts
CHANGED
|
@@ -732,10 +732,10 @@ export function sourceFile(whole: string, options: ImageRouteOptions): { path: s
|
|
|
732
732
|
}
|
|
733
733
|
|
|
734
734
|
// `images.maxDensity`, `images.widths`, `images.aspects`, `images.remote`, `images.placeholder` and whether `images.resolve` is set, checked and set for every image this process renders, served or prerendered; `inlineStyles` is whether the site's CSP lets an element carry a `style` attribute. Returns the density.
|
|
735
|
-
export async function applyImageConfig(images: { maxDensity?: number | undefined, widths?: number[] | undefined, aspects?: string[] | undefined, remote?: { hosts?: string[] | undefined } | undefined, placeholder?: boolean | undefined, resolve?: unknown, guards?: unknown
|
|
735
|
+
export async function applyImageConfig(images: { maxDensity?: number | undefined, widths?: number[] | undefined, aspects?: string[] | undefined, remote?: { hosts?: string[] | undefined } | undefined, placeholder?: boolean | undefined, resolve?: unknown, guards?: unknown } | undefined, inlineStyles = true): Promise<number> {
|
|
736
736
|
const maxDensity = images?.maxDensity ?? DEFAULT_MAX_DENSITY
|
|
737
737
|
|
|
738
|
-
if (
|
|
738
|
+
if (images?.guards !== undefined && images?.resolve === undefined)
|
|
739
739
|
throw new KayError('image-invalid', 'kay: images.guards admits the images images.resolve looks up, and images.resolve is not set')
|
|
740
740
|
|
|
741
741
|
if (!(maxDensity >= 1))
|
package/src/server/index.ts
CHANGED
|
@@ -53,8 +53,6 @@ export { shutdown } from './lifecycle'
|
|
|
53
53
|
export type { LogEntry, Logger, MessageEntry, RequestEntry } from './log'
|
|
54
54
|
export type { ToolCall } from './mcp'
|
|
55
55
|
export { toolCall } from './mcp'
|
|
56
|
-
export type { RateLimit, RateLimitRefusal } from './moved-exports'
|
|
57
|
-
export { s, sqliteCache } from './moved-exports'
|
|
58
56
|
export type { Inbox, Notification, NotificationRow, NotificationStore, NotifyOptions, StoredNotification } from './notifications'
|
|
59
57
|
export { memoryNotifications, notifications, notify, sqliteNotifications } from './notifications'
|
|
60
58
|
export type { PageHook, RenderedPage } from './page-hook'
|
|
@@ -22,11 +22,11 @@ export interface JobContext<Progress = unknown> {
|
|
|
22
22
|
locale: Locale
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
// The context of a run as the handler is handed it
|
|
26
|
-
export function runContext<Progress>(signal: AbortSignal, job: JobRef<Progress>, log: Log): JobContext<Progress>
|
|
25
|
+
// The context of a run as the handler is handed it.
|
|
26
|
+
export function runContext<Progress>(signal: AbortSignal, job: JobRef<Progress>, log: Log): JobContext<Progress> {
|
|
27
27
|
// `Locale` is the app's registered locales where the app declares them, which `siteDefaultLocale()`'s string is not.
|
|
28
28
|
// eslint-disable-next-line ts/no-unnecessary-type-assertion
|
|
29
|
-
return
|
|
29
|
+
return { signal, job, log, locale: siteDefaultLocale() as Locale }
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
// What a run that outlasted its `timeout` fails with, in milliseconds below a second.
|
package/src/server/jobs-page.ts
CHANGED
|
@@ -30,7 +30,7 @@ export function jobsPageOf(setting: JobsConfig | undefined, at?: string): JobsPa
|
|
|
30
30
|
return undefined
|
|
31
31
|
|
|
32
32
|
const object = typeof setting === 'object' && setting !== null
|
|
33
|
-
const given = object ?
|
|
33
|
+
const given = object ? setting.guards as unknown : undefined
|
|
34
34
|
|
|
35
35
|
if (given !== undefined && given !== false && !isGuardOption(given))
|
|
36
36
|
throw new KayError('config-invalid', 'kay: `jobs.guards` takes a guard function, a list of them, `{ load }` returning one, or `false`, such as `jobs: { guards: ctx => ctx.locals.auth.admin.require() }`')
|
package/src/server/jobs.ts
CHANGED
|
@@ -133,12 +133,8 @@ export type ScheduleCron<Cron extends string = string> = { cron: Cron & CronSche
|
|
|
133
133
|
export function schedule<const Every extends Duration>(options: ScheduleEvery<Every>, jobs: Jobs): KayPlugin
|
|
134
134
|
export function schedule<const Cron extends string>(options: ScheduleCron<Cron>, jobs: Jobs): KayPlugin
|
|
135
135
|
export function schedule<const Table extends Record<string, Jobs>>(table: Table & { readonly [Key in keyof Table & string]: WhenOf<Key> }, options?: ScheduleOptions): KayPlugin
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
/** @deprecated `schedule({ cron }, job)` or `schedule({ every }, job)`. Removed in 1.108; `deprecated-schedule-call` rewrites it. */
|
|
139
|
-
export function schedule<const Cron extends string>(cron: Cron & CronSchedule<Cron>, jobs: Jobs, options?: ScheduleOptions): KayPlugin
|
|
140
|
-
export function schedule(first: Duration | string | Record<string, Jobs> | ScheduleEvery | ScheduleCron, second?: Jobs | ScheduleOptions, third?: ScheduleOptions) {
|
|
141
|
-
const { entries, options } = scheduled(first, second, third)
|
|
136
|
+
export function schedule(first: Record<string, Jobs> | ScheduleEvery | ScheduleCron, second?: Jobs | ScheduleOptions) {
|
|
137
|
+
const { entries, options } = scheduled(first, second)
|
|
142
138
|
|
|
143
139
|
if ('tz' in options)
|
|
144
140
|
throw new KayError('config-invalid', 'kay: schedule takes timeZone, not tz, which 1.102 dropped')
|
|
@@ -164,10 +160,10 @@ export function schedule(first: Duration | string | Record<string, Jobs> | Sched
|
|
|
164
160
|
return kayPlugin(plugins.length === 1 ? plugins[0]! : plugins.reduce((app, plugin) => app.use(plugin), new Elysia()))
|
|
165
161
|
}
|
|
166
162
|
|
|
167
|
-
// The schedules and the options of a call, whichever of its
|
|
168
|
-
function scheduled(first: unknown, second: unknown
|
|
163
|
+
// The schedules and the options of a call, whichever of its two shapes it is: an options object with `every` or `cron` and the jobs, or a table of schedules to jobs and its options.
|
|
164
|
+
function scheduled(first: unknown, second: unknown): { entries: (readonly [Duration | string, Jobs])[], options: ScheduleOptions } {
|
|
169
165
|
if (typeof first !== 'object' || first === null)
|
|
170
|
-
|
|
166
|
+
throw new KayError('config-invalid', 'kay: schedule takes `{ every }`, `{ cron }` or a table of schedules to jobs')
|
|
171
167
|
|
|
172
168
|
if (!('every' in first || 'cron' in first))
|
|
173
169
|
return { entries: Object.entries(first as Record<string, Jobs>), options: second as ScheduleOptions | undefined ?? {} }
|
|
@@ -51,10 +51,8 @@ export const KAY_EXPORTS: Record<string, 'free' | 'request' | 'local'> = {
|
|
|
51
51
|
mount: 'free',
|
|
52
52
|
navigate: 'free',
|
|
53
53
|
navigation: 'free',
|
|
54
|
-
onBeforeNavigate: 'free',
|
|
55
54
|
onCleanup: 'free',
|
|
56
55
|
onMount: 'free',
|
|
57
|
-
onNavigate: 'free',
|
|
58
56
|
online: 'free',
|
|
59
57
|
optimistic: 'free',
|
|
60
58
|
pageVisible: 'free',
|
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 => {
|