@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TSchema } from 'elysia'
|
|
2
2
|
import type { ActionsConfig } from '../config'
|
|
3
|
-
import type { ActionDone, ActionFailed, ActionHookContext, ActionHooks, ActionRun, ServerAction } from '../runtime/action'
|
|
3
|
+
import type { ActionContext, ActionDone, ActionFailed, ActionHookContext, ActionHooks, ActionRun, ServerAction } from '../runtime/action'
|
|
4
4
|
import type { ErrorShape } from '../runtime/api-error'
|
|
5
5
|
import type { BeforeHook, Hook } from './hooks'
|
|
6
6
|
import { resolveProtection } from '../runtime/action-protection'
|
|
@@ -31,30 +31,30 @@ export function hasHooks(lists: ActionHookLists): boolean {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
// The `context` of an action's hooks: the action's own, read through it as it is lazy, with who asks.
|
|
34
|
-
async function contextOf(
|
|
34
|
+
async function contextOf(ctx: ActionContext): Promise<ActionHookContext> {
|
|
35
35
|
const { ip, userAgent, userId } = await hookContext()
|
|
36
36
|
|
|
37
37
|
return Object.create(ctx, { ip: { value: ip, enumerable: true }, userAgent: { value: userAgent, enumerable: true }, userId: { value: userId, enumerable: true } }) as ActionHookContext
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
// The `beforeRun` hooks of a run: the refusal when one stops it.
|
|
41
|
-
export async function refusedBeforeRun(lists: ActionHookLists, event: ActionRun): Promise<(ErrorShape & { retryAfter?: number | undefined }) | undefined> {
|
|
41
|
+
export async function refusedBeforeRun(lists: ActionHookLists, event: ActionRun, ctx: ActionContext): Promise<(ErrorShape & { retryAfter?: number | undefined }) | undefined> {
|
|
42
42
|
if (lists.before.length === 0)
|
|
43
43
|
return undefined
|
|
44
44
|
|
|
45
|
-
const answer = await decide('actions.beforeRun', lists.before, event, await contextOf(
|
|
45
|
+
const answer = await decide('actions.beforeRun', lists.before, event, await contextOf(ctx))
|
|
46
46
|
|
|
47
47
|
return 'refused' in answer ? answer.refused : undefined
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
export async function tellSuccess(lists: ActionHookLists, event: ActionRun, result: unknown): Promise<void> {
|
|
50
|
+
export async function tellSuccess(lists: ActionHookLists, event: ActionRun, ctx: ActionContext, result: unknown): Promise<void> {
|
|
51
51
|
if (lists.success.length > 0)
|
|
52
|
-
await dispatch('actions.onSuccess', lists.success, { ...event, result }, { context: await contextOf(
|
|
52
|
+
await dispatch('actions.onSuccess', lists.success, { ...event, result }, { context: await contextOf(ctx) })
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
export async function tellError(lists: ActionHookLists, event: ActionRun, failure: Pick<ActionFailed, 'status' | 'message' | 'errors' | 'data' | 'error'>): Promise<void> {
|
|
55
|
+
export async function tellError(lists: ActionHookLists, event: ActionRun, ctx: ActionContext, failure: Pick<ActionFailed, 'status' | 'message' | 'errors' | 'data' | 'error'>): Promise<void> {
|
|
56
56
|
if (lists.error.length > 0)
|
|
57
|
-
await dispatch('actions.onError', lists.error, { ...event, ...failure }, { context: await contextOf(
|
|
57
|
+
await dispatch('actions.onError', lists.error, { ...event, ...failure }, { context: await contextOf(ctx) })
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
// The action as one app serves it, with the app's `actions` defaults laid under its own options key by key: a check the action names replaces the app's, `messages` merge one level, and `protect: false` keeps the app's checks out (its `maxSize` and `messages` still apply). The action itself is left as declared, so two apps in one process (a test site after another) each read their own defaults.
|
package/src/server/actions.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { Elysia, TSchema } from 'elysia'
|
|
|
3
3
|
import type { Server } from 'elysia/universal'
|
|
4
4
|
import type { ActionsConfig } from '../config'
|
|
5
5
|
import type { GuardContext, Locals, RouteParams } from '../runtime'
|
|
6
|
-
import type { ActionContext, ActionRun,
|
|
6
|
+
import type { ActionContext, ActionRun, RateKeyContext, ServerAction } from '../runtime/action'
|
|
7
7
|
import type { Locale } from '../runtime/i18n'
|
|
8
8
|
import type { LocaleState } from '../runtime/locale-state'
|
|
9
9
|
import type { ActionHookLists } from './action-hooks'
|
|
@@ -21,7 +21,7 @@ import type { ToolOutputs } from './tool-outputs'
|
|
|
21
21
|
import type { Source } from './validate'
|
|
22
22
|
import { relative } from 'node:path'
|
|
23
23
|
import { KayError } from '../compiler/errors'
|
|
24
|
-
import { decodeCall,
|
|
24
|
+
import { decodeCall, FORM_CALL, FORM_FIELD, honeypotField, isAction, isFailure, protectionFields, STAMP_FIELD } from '../runtime/action'
|
|
25
25
|
import { joinBase } from '../runtime/base'
|
|
26
26
|
import { escapeAttribute } from '../runtime/escape'
|
|
27
27
|
import { localeState, runInLocale } from '../runtime/locale-state'
|
|
@@ -602,14 +602,13 @@ async function runAction(action: ServerAction<TSchema, unknown>, context: { body
|
|
|
602
602
|
status = code
|
|
603
603
|
},
|
|
604
604
|
...actionStoppers(request),
|
|
605
|
-
fail: <Data>(code: number, data?: Data, errors?: FieldErrors) => failure(code, data as Data, errors),
|
|
606
605
|
}
|
|
607
606
|
|
|
608
607
|
const { lists } = named
|
|
609
|
-
const run: ActionRun = { action: named.name, file: named.file, input: context.body
|
|
608
|
+
const run: ActionRun = { action: named.name, file: named.file, input: context.body }
|
|
610
609
|
|
|
611
610
|
try {
|
|
612
|
-
const stopping = await refusedBeforeRun(lists, run)
|
|
611
|
+
const stopping = await refusedBeforeRun(lists, run, ctx)
|
|
613
612
|
|
|
614
613
|
if (stopping !== undefined) {
|
|
615
614
|
if (stopping.retryAfter !== undefined)
|
|
@@ -630,9 +629,9 @@ async function runAction(action: ServerAction<TSchema, unknown>, context: { body
|
|
|
630
629
|
// What `ctx.once` loaded before the handler changed things is stale for the page rendered again after a failure.
|
|
631
630
|
forgetOnces(request)
|
|
632
631
|
|
|
633
|
-
// A
|
|
632
|
+
// A library's failed result, such as kayjs-auth's, returned as it is: its status and `data` refuse the call, a string `data` being the form's message.
|
|
634
633
|
if (isFailure(result)) {
|
|
635
|
-
await tellError(lists, run, { status: result.status, message: typeof result.data === 'string' ? result.data : result.errors?.[''] ?? '', errors: result.errors ?? {}, data: result.data, error: undefined })
|
|
634
|
+
await tellError(lists, run, ctx, { status: result.status, message: typeof result.data === 'string' ? result.data : result.errors?.[''] ?? '', errors: result.errors ?? {}, data: result.data, error: undefined })
|
|
636
635
|
|
|
637
636
|
return await failed(request, headers, jar.cookies, { action: action.url, status: result.status, values: submittedValues(context.body), errors: { ...typeof result.data === 'string' ? { '': result.data } : {}, ...result.errors }, data: result.data }, context.server, back)
|
|
638
637
|
}
|
|
@@ -642,7 +641,7 @@ async function runAction(action: ServerAction<TSchema, unknown>, context: { body
|
|
|
642
641
|
const answer = isAsyncIterable(result) ? await (streams ? started : lastOf)(gathering(result, invalidated, askedKeys(request)), requestSignal(request)) : result
|
|
643
642
|
|
|
644
643
|
await countGoneThrough(action, request, context.server, options)
|
|
645
|
-
await tellSuccess(lists, run, answer)
|
|
644
|
+
await tellSuccess(lists, run, ctx, answer)
|
|
646
645
|
|
|
647
646
|
// A stream names its keys on its end event, as the handler goes on invalidating until then.
|
|
648
647
|
invalidatedHeader(invalidated, headers, isCall(request) && !streams)
|
|
@@ -655,11 +654,11 @@ async function runAction(action: ServerAction<TSchema, unknown>, context: { body
|
|
|
655
654
|
// Sent on after it went through, as to a thank-you page.
|
|
656
655
|
if (error instanceof Redirect) {
|
|
657
656
|
await countGoneThrough(action, request, context.server, options)
|
|
658
|
-
await tellSuccess(lists, run, undefined)
|
|
657
|
+
await tellSuccess(lists, run, ctx, undefined)
|
|
659
658
|
}
|
|
660
659
|
|
|
661
660
|
if (error instanceof Denied || error instanceof NotFound)
|
|
662
|
-
await tellError(lists, run, { status: error instanceof Denied ? error.status : 404, message: error instanceof Denied ? error.message : 'Not Found', errors: {}, data: undefined, error })
|
|
661
|
+
await tellError(lists, run, ctx, { status: error instanceof Denied ? error.status : 404, message: error instanceof Denied ? error.message : 'Not Found', errors: {}, data: undefined, error })
|
|
663
662
|
|
|
664
663
|
if (error instanceof Redirect || error instanceof Denied || error instanceof NotFound)
|
|
665
664
|
return stopped(error, request, state, options)
|
|
@@ -672,7 +671,7 @@ async function runAction(action: ServerAction<TSchema, unknown>, context: { body
|
|
|
672
671
|
|
|
673
672
|
// A library's limit, such as kayjs-ai's, answers like the action's own rate limit.
|
|
674
673
|
if (refused !== undefined) {
|
|
675
|
-
await tellError(lists, run, { status: refused.status, message: refused.message, errors: refused.errors, data: refused.data, error })
|
|
674
|
+
await tellError(lists, run, ctx, { status: refused.status, message: refused.message, errors: refused.errors, data: refused.data, error })
|
|
676
675
|
|
|
677
676
|
if (refused.retryAfter !== undefined)
|
|
678
677
|
headers.set('retry-after', String(refused.retryAfter))
|
|
@@ -682,7 +681,7 @@ async function runAction(action: ServerAction<TSchema, unknown>, context: { body
|
|
|
682
681
|
|
|
683
682
|
// A mistake, or a service the handler relies on gone down: logged as any server error, and told the visitor beside the form they keep, as a refusal is.
|
|
684
683
|
reportServerError(error, request, options.onError)
|
|
685
|
-
await tellError(lists, run, { status: 500, message: 'Internal server error', errors: {}, data: undefined, error })
|
|
684
|
+
await tellError(lists, run, ctx, { status: 500, message: 'Internal server error', errors: {}, data: undefined, error })
|
|
686
685
|
|
|
687
686
|
return failed(request, headers, jar.cookies, { action: action.url, status: 500, values: submittedValues(context.body), errors: { '': await serverErrorMessage(action, error, ctx, request, options.onError) } }, context.server, back)
|
|
688
687
|
}
|
|
@@ -719,7 +718,7 @@ async function countGoneThrough(action: ServerAction<TSchema, unknown>, request:
|
|
|
719
718
|
}
|
|
720
719
|
}
|
|
721
720
|
|
|
722
|
-
// A call gets the result; a plain form post goes back to the page it came from, which reads the result through `
|
|
721
|
+
// A call gets the result; a plain form post goes back to the page it came from, which reads the result through `data()`.
|
|
723
722
|
function succeeded(action: ServerAction<TSchema, unknown>, request: Request, jar: CookieJar, headers: Headers, result: unknown, status: number, base = ''): Response {
|
|
724
723
|
if (!isCall(request))
|
|
725
724
|
writeSuccess(jar.cookies, { action: action.url, succeeded: true, data: result, page: new URL(backTo(request, base), 'http://kay').pathname }, overHttps(request), base)
|
|
@@ -791,7 +790,7 @@ async function failed(request: Request, headers: Headers, cookies: CookieMap, fl
|
|
|
791
790
|
headers.set('content-type', 'application/json')
|
|
792
791
|
headers.set(FAILURE_HEADER, '1')
|
|
793
792
|
|
|
794
|
-
return new Response(encodeOrExplain({ errors: flash.errors, data: flash.data }, `what ${flash.action} passed to ctx.
|
|
793
|
+
return new Response(encodeOrExplain({ errors: flash.errors, data: flash.data }, `what ${flash.action} passed to ctx.deny`), { status: flash.status, headers })
|
|
795
794
|
}
|
|
796
795
|
|
|
797
796
|
// The page renders as for a visit, through the app, its guards and hooks included, and the failure reaches `form.failed()` in memory, so all the visitor typed comes back whatever its length.
|
|
@@ -22,7 +22,7 @@ export interface ApiModule {
|
|
|
22
22
|
mount: string
|
|
23
23
|
// The `_guard.ts` files of its directory and above, outermost first.
|
|
24
24
|
guards: ApiGuard[]
|
|
25
|
-
// No guard is asked of it on a site with `
|
|
25
|
+
// No guard is asked of it on a site with `guards.default` closed: it sets `api({ guards: false })`, or a library serves it.
|
|
26
26
|
open?: true | undefined
|
|
27
27
|
// The extension whose `api` directory holds it, whose `ExtensionApp` a module exporting a function is called with.
|
|
28
28
|
extension?: string | undefined
|
|
@@ -46,9 +46,8 @@ export const REFERENCE_PATH = `${API_PREFIX}/reference`
|
|
|
46
46
|
export function apiPathOf(value: string | undefined): string {
|
|
47
47
|
return value === undefined ? API_PREFIX : servedPath(value, 'endpoints.api')
|
|
48
48
|
}
|
|
49
|
-
// Where `mcp` serves the app's tools
|
|
49
|
+
// Where `mcp` serves the app's tools.
|
|
50
50
|
export const MCP_PATH = '/_kay/mcp'
|
|
51
|
-
export const FORMER_MCP_PATH = '/mcp'
|
|
52
51
|
// Where an MCP client finds how to sign in, which the endpoint's 401 points to.
|
|
53
52
|
export const RESOURCE_METADATA = '/.well-known/oauth-protected-resource'
|
|
54
53
|
const SERVED_PATH = /^\/[\w.~-]+(?:\/[\w.~-]+)*$/
|
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',
|