@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/runtime/persist.ts
CHANGED
|
@@ -29,6 +29,8 @@ export type Stored<T> = { found: true, value: T } | { found: false }
|
|
|
29
29
|
// Where a kept signal's value lives: what the request being rendered holds, which the server renders with, none for a store only the browser sees; what the browser holds, and how it keeps a new value.
|
|
30
30
|
export interface Store<T> {
|
|
31
31
|
request?: ((scope: LoadScope) => Stored<T>) | undefined
|
|
32
|
+
// A store kept in the query: each read of it tells the render, which notes the island as reading the address.
|
|
33
|
+
query?: true | undefined
|
|
32
34
|
stored: () => Stored<T>
|
|
33
35
|
save: (value: T) => void
|
|
34
36
|
// A store the server never sees: an island claiming its markup reads the value it rendered with, the kept one applying once it has hydrated.
|
|
@@ -116,7 +118,7 @@ export function keep<T>(store: Store<T>, read: () => T, write: (value: T) => voi
|
|
|
116
118
|
return inBrowser(store, read, write)
|
|
117
119
|
|
|
118
120
|
// Outside a browser build the page is told apart on use, not on creation: a module made before a test registers its DOM keeps its signal then.
|
|
119
|
-
const server = serverSide(store.request, read)
|
|
121
|
+
const server = serverSide(store.request, read, store.query)
|
|
120
122
|
let browser: Persisted<T> | undefined
|
|
121
123
|
const current = () => typeof document === 'undefined' ? server : browser ??= inBrowser(store, read, write)
|
|
122
124
|
|
|
@@ -175,7 +177,7 @@ function inBrowser<T>(store: Store<T>, read: () => T, write: (value: T) => void)
|
|
|
175
177
|
}
|
|
176
178
|
|
|
177
179
|
// The server reads the request being rendered once per request, until a render of it writes the signal.
|
|
178
|
-
function serverSide<T>(request: Store<T>['request'], read: () => T): Persisted<T> {
|
|
180
|
+
function serverSide<T>(request: Store<T>['request'], read: () => T, query?: true): Persisted<T> {
|
|
179
181
|
const fromRequest = new WeakMap<LoadScope, Stored<T>>()
|
|
180
182
|
const written = new WeakSet<LoadScope>()
|
|
181
183
|
|
|
@@ -183,7 +185,13 @@ function serverSide<T>(request: Store<T>['request'], read: () => T): Persisted<T
|
|
|
183
185
|
read: () => {
|
|
184
186
|
const scope = currentRequestScope()
|
|
185
187
|
|
|
186
|
-
if (!scope || !request
|
|
188
|
+
if (!scope || !request)
|
|
189
|
+
return read()
|
|
190
|
+
|
|
191
|
+
if (query)
|
|
192
|
+
scope.read?.()
|
|
193
|
+
|
|
194
|
+
if (written.has(scope))
|
|
187
195
|
return read()
|
|
188
196
|
|
|
189
197
|
let stored = fromRequest.get(scope)
|
package/src/runtime/persisted.ts
CHANGED
|
@@ -14,7 +14,7 @@ interface KeptOptions<T> extends SignalOptions<T> {
|
|
|
14
14
|
values?: readonly T[] | undefined
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
// `persisted
|
|
17
|
+
// `persisted.cookie()`: the value lives in a cookie the server reads too, so pages render with it.
|
|
18
18
|
export interface PersistedCookieOptions<T> extends KeptOptions<T> {
|
|
19
19
|
// How long the cookie is kept after the last write, a year by default: `'30d'`.
|
|
20
20
|
maxAge?: Duration | undefined
|
|
@@ -28,12 +28,6 @@ export interface PersistedStorageOptions<T> extends KeptOptions<T> {
|
|
|
28
28
|
sync?: boolean | undefined
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
// `persisted.query()`, which is `queryParam(name, { default })` since 1.105: the value lives in the URL, the value given standing for the param left out, after the default of a `query` schema naming it.
|
|
32
|
-
export interface PersistedQueryOptions<T> extends KeptOptions<T> {
|
|
33
|
-
// `replace`, the default, takes the current entry's place, throttled; `push` adds an entry, written at once, which Back and Forward step through and the signal follows.
|
|
34
|
-
history?: 'push' | 'replace' | undefined
|
|
35
|
-
}
|
|
36
|
-
|
|
37
31
|
// The signals of a page by storage and name, so islands persisting one name hold one value.
|
|
38
32
|
const sharedSignals = new Map<string, { signal: object, refresh?: (() => void) | undefined }>()
|
|
39
33
|
|
|
@@ -67,31 +61,15 @@ function session<T>(name: string, value: PlainValue<T>, options?: PersistedStora
|
|
|
67
61
|
return keptSignal('session', name, value, options)
|
|
68
62
|
}
|
|
69
63
|
|
|
70
|
-
//
|
|
71
|
-
function query<T = string>(name: string, value: NoInfer<PlainValue<T>>, options?: Omit<PersistedQueryOptions<NoInfer<T>>, 'values'>): Signal<T>
|
|
72
|
-
// `values` types the signal as their union, and the default must be one of them.
|
|
73
|
-
function query<const T extends string | number | boolean>(name: string, value: NoInfer<T>, options: PersistedQueryOptions<T> & { values: readonly T[] }): Signal<T>
|
|
74
|
-
|
|
75
|
-
function query<T>(name: string, value: PlainValue<T>, options?: PersistedQueryOptions<T>): Signal<T> {
|
|
76
|
-
return queryParamOf<T>(name, { default: value, values: options?.values, history: options?.history }, options)
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// `persisted(name, value, options)` is `persisted.cookie(...)`: the cookie is what a bare call kept, and a call names its storage since 1.105.
|
|
64
|
+
// One entry per storage, each named by the call: `persisted.cookie()`, `persisted.local()`, `persisted.session()`; a query param is `queryParam()`.
|
|
80
65
|
interface Persisted {
|
|
81
|
-
/** @deprecated Call `persisted.cookie()`, so the storage is named; `persisted.local()`, `persisted.session()` and `queryParam()` keep a value elsewhere. Removed in 1.108.0; `deprecated-persisted-call` rewrites it. */
|
|
82
|
-
<const T extends string | number | boolean>(name: string, value: NoInfer<T>, options: PersistedCookieOptions<T> & { values: readonly T[] }): Signal<T>
|
|
83
|
-
/** @deprecated Call `persisted.cookie()`, so the storage is named; `persisted.local()`, `persisted.session()` and `queryParam()` keep a value elsewhere. Removed in 1.108.0; `deprecated-persisted-call` rewrites it. */
|
|
84
|
-
<T>(name: string, value: PlainValue<T>, options?: Omit<PersistedCookieOptions<T>, 'values'>): Signal<T>
|
|
85
66
|
cookie: typeof cookie
|
|
86
67
|
local: typeof local
|
|
87
68
|
session: typeof session
|
|
88
|
-
/** @deprecated Call `queryParam(name, { default })`, the one signal of a query param. Removed in 1.108.0; `deprecated-persisted-query` rewrites it. */
|
|
89
|
-
query: typeof query
|
|
90
69
|
}
|
|
91
70
|
|
|
92
71
|
// kept: local, it reads the request's cookie, so it is free only where every call is `persisted.local()` or `persisted.session()`, kept in the browser's storage and read once the page has hydrated.
|
|
93
|
-
|
|
94
|
-
export const persisted: Persisted = /* @__PURE__ */ Object.assign((name: string, value: unknown, options?: PersistedCookieOptions<unknown>) => cookie(name, value as never, options), { cookie, local, session, query })
|
|
72
|
+
export const persisted: Persisted = { cookie, local, session }
|
|
95
73
|
|
|
96
74
|
function keptSignal<T>(storage: Exclude<PersistStorage, 'query'>, name: string, value: PlainValue<T>, options: PersistedCookieOptions<T> | undefined): Signal<T> {
|
|
97
75
|
const id = `${storage}:${name}`
|
|
@@ -137,11 +115,7 @@ export function queryParam<const T extends string | number | boolean>(name: stri
|
|
|
137
115
|
export function queryParam<T = string>(name: string, options: QueryParamOptions<NoInfer<T>> & { default: NoInfer<PlainValue<T>>, values?: undefined }): Signal<T>
|
|
138
116
|
export function queryParam<T = string | undefined>(name: string, options?: QueryHistoryOptions): Signal<T>
|
|
139
117
|
export function queryParam<T>(name: string, options?: QueryParamOptions<T>): Signal<T> {
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
function queryParamOf<T>(name: string, options: QueryParamOptions<T> | undefined, own?: SignalOptions<T>): Signal<T> {
|
|
144
|
-
const [read, write] = createSignal<T>(options?.default as PlainValue<T>, own)
|
|
118
|
+
const [read, write] = createSignal<T>(options?.default as PlainValue<T>)
|
|
145
119
|
const kept = keepParam(name, read, write, options?.default as T | undefined, options?.values, options?.history)
|
|
146
120
|
|
|
147
121
|
return withSetter(kept.read, (next) => {
|
package/src/runtime/presence.ts
CHANGED
|
@@ -61,12 +61,11 @@ function holdConnection(): void {
|
|
|
61
61
|
// The page proves the room and the member as it does any live read, so what a visitor is listed as comes from the server fence that passed it, and the page is rendered per request.
|
|
62
62
|
// A member is any value that crosses as island props do, compared as JSON; a room and its member take at most 256 characters as JSON.
|
|
63
63
|
// kept: request
|
|
64
|
-
export function presence<Member = null>(options?: PresenceOptions<Member>): Presence<Member>
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
const { room, member } = options
|
|
64
|
+
export function presence<Member = null>(options?: PresenceOptions<Member>): Presence<Member> {
|
|
65
|
+
if (options !== undefined && (typeof options !== 'object' || options === null))
|
|
66
|
+
throw new KayError('argument-invalid', 'kay: presence({ room, member, signal }) takes one options object, not the room and member as arguments')
|
|
67
|
+
|
|
68
|
+
const { room, member } = options ?? {}
|
|
70
69
|
const key = JSON.stringify([room ?? pagePath(), member ?? null])
|
|
71
70
|
|
|
72
71
|
if (key.length > MAX_PRESENCE_KEY)
|
|
@@ -93,7 +92,7 @@ export function presence(first?: string | PresenceOptions<unknown>, second?: unk
|
|
|
93
92
|
const end = lasting('presence', presence, () => onCleanup(() => stop(true)), options?.signal)
|
|
94
93
|
|
|
95
94
|
return Object.assign(end, {
|
|
96
|
-
others: () => [...new Set(read().filter(text => text !== own))].map(text => JSON.parse(text) as
|
|
95
|
+
others: () => [...new Set(read().filter(text => text !== own))].map(text => JSON.parse(text) as Member),
|
|
97
96
|
count: () => read().length,
|
|
98
97
|
})
|
|
99
98
|
}
|
|
@@ -3,7 +3,7 @@ import { historyState, navigation, pageKey } from './navigation'
|
|
|
3
3
|
import { pageData } from './page-data'
|
|
4
4
|
import { keep } from './persist'
|
|
5
5
|
import { onCleanup } from './reactive'
|
|
6
|
-
import { addressChanged } from './with-query'
|
|
6
|
+
import { addressChanged, followAddress, followers } from './with-query'
|
|
7
7
|
|
|
8
8
|
// What the server sends of one param of the page's `query` schema, enough to read its text as the schema does without the schema itself.
|
|
9
9
|
export interface ParamRule {
|
|
@@ -35,7 +35,7 @@ export function readParam(rules: QueryRules | undefined, name: string, search: U
|
|
|
35
35
|
return texts[0]
|
|
36
36
|
|
|
37
37
|
if (rule.type === 'array') {
|
|
38
|
-
// A blank text is the empty list, as `
|
|
38
|
+
// A blank text is the empty list, as `queryParam` writes it.
|
|
39
39
|
if (texts.length === 1 && texts[0] === '')
|
|
40
40
|
return []
|
|
41
41
|
|
|
@@ -80,11 +80,11 @@ function fromText(rule: ParamRule, text: string): unknown {
|
|
|
80
80
|
return rule.enum === undefined || rule.enum.includes(value) ? value : REFUSED
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
// The
|
|
84
|
-
const
|
|
83
|
+
// The values set and not yet written to the address, by param, with the fallback each leaves out of it.
|
|
84
|
+
const pending = new Map<string, [value: unknown, fallback: unknown]>()
|
|
85
85
|
|
|
86
86
|
// What `queryParam` reads and keeps, around the signal's own `read`: the server reads the request's param, the browser the page's address once, then each write takes the current history entry's place.
|
|
87
|
-
// A param left out reads as the signal's own value, `fallback` for `
|
|
87
|
+
// A param left out reads as the signal's own value, `fallback` for `queryParam(name, { default: fallback })`, which writing it leaves out too.
|
|
88
88
|
// A value outside `values` reads as the param left out.
|
|
89
89
|
// `history: 'push'` adds an entry for each write instead, which Back and Forward step through, the signal following.
|
|
90
90
|
export function keepParam<T>(name: string, read: () => T, write: (value: T) => void, fallback?: T, values?: readonly unknown[], history?: 'push' | 'replace'): Persisted<T> {
|
|
@@ -93,13 +93,23 @@ export function keepParam<T>(name: string, read: () => T, write: (value: T) => v
|
|
|
93
93
|
|
|
94
94
|
if (typeof document !== 'undefined') {
|
|
95
95
|
const reread = () => {
|
|
96
|
+
// A write still waiting is the signal's own, ahead of the address: it lands on it, and a refresh of the page leaves it be.
|
|
97
|
+
if (pending.has(name))
|
|
98
|
+
return
|
|
99
|
+
|
|
96
100
|
const now = stored()
|
|
97
101
|
|
|
98
|
-
|
|
102
|
+
const next = now.found ? now.value : fallback as T
|
|
103
|
+
|
|
104
|
+
// A list is read afresh from the address: left alone when it holds the same items, so its effects are not told again.
|
|
105
|
+
if (Array.isArray(next) && JSON.stringify(next) === JSON.stringify(read()))
|
|
106
|
+
return
|
|
107
|
+
|
|
108
|
+
write(next)
|
|
99
109
|
}
|
|
100
110
|
|
|
101
|
-
|
|
102
|
-
onCleanup(() =>
|
|
111
|
+
followers.add(reread)
|
|
112
|
+
onCleanup(() => followers.delete(reread))
|
|
103
113
|
|
|
104
114
|
if (push)
|
|
105
115
|
watch()
|
|
@@ -107,6 +117,7 @@ export function keepParam<T>(name: string, read: () => T, write: (value: T) => v
|
|
|
107
117
|
|
|
108
118
|
return keep<T>({
|
|
109
119
|
request: scope => found(scope.param?.(name), values, fallback),
|
|
120
|
+
query: true,
|
|
110
121
|
stored,
|
|
111
122
|
save: value => saveParam(name, value, fallback, push),
|
|
112
123
|
}, read, write)
|
|
@@ -131,7 +142,6 @@ function pageRules(): QueryRules | undefined {
|
|
|
131
142
|
// Every param shares one gap, a throttle with a leading write: one goes through at once, then at most one per 200 ms while values keep coming, the latest ones landing in a single `replaceState`.
|
|
132
143
|
// The page flushes them before it is left or navigated, one found on another page than it was set on is dropped, and a refused write never throws out of `set()`.
|
|
133
144
|
const WRITE_GAP = 200
|
|
134
|
-
const pending = new Map<string, [value: unknown, fallback: unknown]>()
|
|
135
145
|
let timer: ReturnType<typeof setTimeout> | undefined
|
|
136
146
|
let lastWrite = 0
|
|
137
147
|
let retrying = false
|
|
@@ -169,9 +179,7 @@ function traversed(state: unknown): boolean {
|
|
|
169
179
|
retrying = false
|
|
170
180
|
navigation.shown = pageKey(new URL(location.href))
|
|
171
181
|
|
|
172
|
-
|
|
173
|
-
reread()
|
|
174
|
-
|
|
182
|
+
followAddress()
|
|
175
183
|
addressChanged()
|
|
176
184
|
|
|
177
185
|
return true
|
package/src/runtime/reactive.ts
CHANGED
|
@@ -38,6 +38,8 @@ export interface ServerScope {
|
|
|
38
38
|
cookie: (name: string) => string | undefined
|
|
39
39
|
// A query param as the page's `query` schema reads it, for `queryParam` and a persisted signal kept in the query.
|
|
40
40
|
param: (name: string) => unknown
|
|
41
|
+
// Told each time a signal kept in the request reads it, which a render answering for a page built once notes as the island's dependence on the address.
|
|
42
|
+
read?: () => void
|
|
41
43
|
report: (error: unknown) => void
|
|
42
44
|
// The path of the page being rendered, percent-encoded as requested.
|
|
43
45
|
path: string
|
|
@@ -365,7 +367,7 @@ export function currentServerScope(): ServerScope | undefined {
|
|
|
365
367
|
}
|
|
366
368
|
|
|
367
369
|
// What a page's server fence reads of its request while it loads: its cookies, which a persisted signal answers with; a query param is the render's alone.
|
|
368
|
-
export type LoadScope = Pick<ServerScope, 'cookie'> & Partial<Pick<ServerScope, 'param'>>
|
|
370
|
+
export type LoadScope = Pick<ServerScope, 'cookie'> & Partial<Pick<ServerScope, 'param' | 'read'>>
|
|
369
371
|
|
|
370
372
|
let requestCookieScope: (() => LoadScope | undefined) | undefined
|
|
371
373
|
|
package/src/runtime/refuse.ts
CHANGED
|
@@ -10,16 +10,6 @@ export interface DenyOptions<Data = unknown, Field extends string = string> {
|
|
|
10
10
|
data?: Data | undefined
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
// The options of `refuse(message, options)` before 1.105, `refuse(status, { message, errors, data })` since.
|
|
14
|
-
export interface RefuseOptions {
|
|
15
|
-
// An error status, from 400 to 599: 422 when `errors` names fields, else 403.
|
|
16
|
-
status?: number | undefined
|
|
17
|
-
// A message per field, as a schema's.
|
|
18
|
-
errors?: Record<string, string> | undefined
|
|
19
|
-
// What the app reads from the answer.
|
|
20
|
-
data?: unknown
|
|
21
|
-
}
|
|
22
|
-
|
|
23
13
|
// An error carrying this is answered as a refusal rather than a server error: `{ status, message, errors?, data?, retryAfter? }`.
|
|
24
14
|
const REFUSED = Symbol.for('kay.refused')
|
|
25
15
|
|
|
@@ -36,14 +26,10 @@ export class RefusedError extends Error {
|
|
|
36
26
|
|
|
37
27
|
// Throws to stop what a `before` hook guards, with that status (an error one, from 400 to 599) and the `{ message, errors, data }` of `ctx.deny`: an action and every other place answering `Symbol.for('kay.refused')` answers it as it answers `ctx.deny` in an action.
|
|
38
28
|
// kept: free
|
|
39
|
-
export function refuse(status?: number, options
|
|
40
|
-
/** @deprecated `refuse(status, { message, errors, data })`. Removed in 1.108; `deprecated-refuse-call` rewrites it. */
|
|
41
|
-
export function refuse(message?: string, options?: RefuseOptions): never
|
|
42
|
-
export function refuse(first?: number | string, options: { message?: string | undefined, status?: number | undefined, errors?: Partial<Record<string, string>> | undefined, data?: unknown } = {}): never {
|
|
43
|
-
const named = typeof first === 'string'
|
|
29
|
+
export function refuse(status?: number, options: DenyOptions = {}): never {
|
|
44
30
|
const { errors = {}, data } = options
|
|
45
|
-
const code =
|
|
46
|
-
const message =
|
|
31
|
+
const code = status ?? (Object.keys(errors).length > 0 ? 422 : 403)
|
|
32
|
+
const message = options.message ?? 'Refused'
|
|
47
33
|
|
|
48
34
|
if (!Number.isInteger(code) || code < 400 || code > 599)
|
|
49
35
|
throw new KayError('argument-invalid', `kay: refuse() takes an error status, from 400 to 599, not ${code}`)
|
|
@@ -8,15 +8,13 @@ export type MaybePromise<T> = T | Promise<T>
|
|
|
8
8
|
// What every store an app plugs in may have, whatever it keeps: `ping` and `close`, both optional and either may return a promise, so a store with neither costs nothing. Callers only await the result, so `close: () => redis.quit()` fits.
|
|
9
9
|
// `AppStore` extends it too, so a store keeping every kind (`pgData`) pings and closes them all with one method.
|
|
10
10
|
export interface StoreBase {
|
|
11
|
-
// `true` for a store that receives every length as a `Duration` (`'30s'`) where the contract has one: `RateStore.hit`'s window, `KvStore`'s ttl, `SessionStore.set`'s max age, `LiveStore.endAll`'s ttl. A store without it was written before 1.105 and receives milliseconds as a number, which kay keeps handing it until 1.108.
|
|
12
|
-
durations?: true | undefined
|
|
13
11
|
// Rejects, or throws, when the store cannot be reached: `health` runs it beside the app's own `check`, under the same `health.timeout`.
|
|
14
12
|
ping?: (() => unknown) | undefined
|
|
15
13
|
// Stops what the store runs in the background and lets go of its file or connection: the server calls it once when it stops, and `await store.close()` does the same for a store opened in a script or a test. Closing twice is the same as once.
|
|
16
14
|
close?: (() => unknown) | undefined
|
|
17
15
|
}
|
|
18
16
|
|
|
19
|
-
// The milliseconds of a length a store was given as a `Duration
|
|
17
|
+
// The milliseconds of a length a store was given as a `Duration`: what a store of your own reads its window, ttl or max age with. `what` names the argument in the error a bad value throws.
|
|
20
18
|
// kept: free
|
|
21
19
|
export function lengthMs(value: Duration | number, what = 'a store length'): number {
|
|
22
20
|
const ms = typeof value === 'number' ? value : durationMs(value)
|
|
@@ -27,7 +25,7 @@ export function lengthMs(value: Duration | number, what = 'a store length'): num
|
|
|
27
25
|
return ms
|
|
28
26
|
}
|
|
29
27
|
|
|
30
|
-
// What kay hands
|
|
31
|
-
export function lengthFor(
|
|
32
|
-
return
|
|
28
|
+
// What kay hands a store for a length of `ms`: a `Duration`.
|
|
29
|
+
export function lengthFor(ms: number): Duration {
|
|
30
|
+
return `${Math.round(ms)}ms`
|
|
33
31
|
}
|
|
@@ -23,7 +23,7 @@ const POLICY_PARAMS = /;.*/
|
|
|
23
23
|
// A link opting out, or a `rel=nofollow` one such as a sign-out, which may do something once fetched, is followed when clicked, never ahead.
|
|
24
24
|
export function prefetch(url: URL, link: Element): void {
|
|
25
25
|
// The nearest `data-prefetch` decides, so an inner `eager` link stays prefetched under a container saying `false`.
|
|
26
|
-
if (link.closest('[
|
|
26
|
+
if (link.closest('[rel~=nofollow]') || link.closest('[data-prefetch]')?.getAttribute('data-prefetch') === 'false')
|
|
27
27
|
return
|
|
28
28
|
|
|
29
29
|
const key = pageKey(url)
|
package/src/runtime/values.ts
CHANGED
|
@@ -184,12 +184,12 @@ export function componentClass(list: readonly unknown[]): string | undefined {
|
|
|
184
184
|
return classText(list) || undefined
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
// The
|
|
188
|
-
|
|
187
|
+
// The parts a list holds as one object, the rest of its classes joining its root; none when it holds no parts.
|
|
188
|
+
function partsIn(list: readonly unknown[]): Parts | undefined {
|
|
189
189
|
const found = list.filter(isParts)
|
|
190
190
|
|
|
191
191
|
if (found.length === 0)
|
|
192
|
-
return
|
|
192
|
+
return undefined
|
|
193
193
|
|
|
194
194
|
const parts = found.length === 1 ? found[0]! : mergeParts(found)
|
|
195
195
|
const rest = list.filter(item => !isParts(item))
|
|
@@ -197,9 +197,28 @@ export function partsClass(list: readonly unknown[]): unknown {
|
|
|
197
197
|
return rest.length === 0 ? parts : taggedParts({ ...parts, root: [...rest, parts.root] })
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
+
// The `class` of a call that hands parts on: the classes of the list as a string, none once the list holds parts, which carry them as their `root` (see `handParts`).
|
|
201
|
+
export function partsClass(list: readonly unknown[]): string | undefined {
|
|
202
|
+
return list.some(isParts) ? undefined : componentClass(list)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// The `parts` of a call that hands parts on: the parts its list holds, with the rest of its classes at their root, laid over the `written` parts object of the call; none when there are neither.
|
|
206
|
+
export function handParts(list: readonly unknown[], written?: unknown): unknown {
|
|
207
|
+
const own = typeof written === 'object' && written !== null && !Array.isArray(written) ? [taggedParts(Object.fromEntries(Object.entries(written).map(([name, entry]) => [name, entryParts(entry)])))] : []
|
|
208
|
+
const handed = partsIn(list)
|
|
209
|
+
const all = handed === undefined ? own : [...own, handed]
|
|
210
|
+
|
|
211
|
+
return all.length < 2 ? all[0] : mergeParts(all)
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// The entry of a part that is a component is its own parts, as `partClass` reads it from a prop.
|
|
215
|
+
function entryParts(entry: unknown): unknown {
|
|
216
|
+
return typeof entry === 'object' && entry !== null && !Array.isArray(entry) ? taggedParts(entry as Record<string, unknown>) : entry
|
|
217
|
+
}
|
|
218
|
+
|
|
200
219
|
// A part of this component handed to the called one under its name, `{ spinner: ... }`, which joins the entries the call hands it: its value is what the part's classes and the caller's entry make.
|
|
201
220
|
export function partHanded(part: string, list: readonly unknown[]): unknown {
|
|
202
|
-
return taggedParts({ [part]:
|
|
221
|
+
return taggedParts({ [part]: partsIn(list) ?? componentClass(list) })
|
|
203
222
|
}
|
|
204
223
|
|
|
205
224
|
// Whether a part's classes can be listed beside another's: a string, an array, or an object of conditions, which the class normalizer reads inside an array as well.
|
|
@@ -207,7 +226,14 @@ function joinable(value: unknown): boolean {
|
|
|
207
226
|
return typeof value === 'string' || Array.isArray(value) || (typeof value === 'object' && value !== null && !isParts(value))
|
|
208
227
|
}
|
|
209
228
|
|
|
210
|
-
|
|
229
|
+
function mergedEntry(earlier: unknown, entry: unknown): unknown {
|
|
230
|
+
if (joinable(earlier) && joinable(entry))
|
|
231
|
+
return [earlier, entry]
|
|
232
|
+
|
|
233
|
+
return isParts(earlier) && isParts(entry) ? mergeParts([earlier, entry]) : entry ?? earlier
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Several objects of parts as one, a part two of them give joined in order when both are classes, merged the same way when both are the parts of a component, the later one replacing it otherwise.
|
|
211
237
|
function mergeParts(found: readonly Parts[]): Parts {
|
|
212
238
|
const merged: Record<string, unknown> = {}
|
|
213
239
|
|
|
@@ -215,7 +241,7 @@ function mergeParts(found: readonly Parts[]): Parts {
|
|
|
215
241
|
for (const [name, entry] of Object.entries(parts)) {
|
|
216
242
|
const earlier = Object.hasOwn(merged, name) ? merged[name] : undefined
|
|
217
243
|
|
|
218
|
-
merged[name] =
|
|
244
|
+
merged[name] = mergedEntry(earlier, entry)
|
|
219
245
|
}
|
|
220
246
|
}
|
|
221
247
|
|
|
@@ -226,7 +252,7 @@ const PARTS = Symbol.for('kay.parts')
|
|
|
226
252
|
|
|
227
253
|
type Parts = Record<string, unknown> & { readonly [PARTS]?: true }
|
|
228
254
|
|
|
229
|
-
// An object of classes by part name, as a part that is a component hands it: told from a `{ class: condition }` object, which a plain `class` takes.
|
|
255
|
+
// An object of classes by part name, as a part that is a component hands it: told from a `{ class: condition }` object, which a plain `class` takes, inside the list of classes of a call.
|
|
230
256
|
function isParts(value: unknown): value is Parts {
|
|
231
257
|
return typeof value === 'object' && value !== null && (value as Parts)[PARTS] === true
|
|
232
258
|
}
|
|
@@ -235,27 +261,18 @@ function taggedParts(parts: Record<string, unknown>): Parts {
|
|
|
235
261
|
return Object.defineProperty({ ...parts }, PARTS, { value: true })
|
|
236
262
|
}
|
|
237
263
|
|
|
238
|
-
// What a component's `class` and `parts` props give a part, `class` winning: a `class` string, array or object of conditions is the root's, and `parts` holds one entry per part, its own object when that part is a component.
|
|
264
|
+
// What a component's `class` and `parts` props give a part, `class` winning: a `class` string, array or object of conditions is the root's, and `parts` holds one entry per part, its own object when that part is a component.
|
|
239
265
|
export function partClass(props: unknown, part: string): unknown {
|
|
240
|
-
const {
|
|
241
|
-
const
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
return part === 'root' && from === value ? from : undefined
|
|
245
|
-
|
|
246
|
-
const entry = Object.hasOwn(from, part) ? (from as Record<string, unknown>)[part] : undefined
|
|
247
|
-
|
|
248
|
-
return typeof entry === 'object' && entry !== null && !Array.isArray(entry) ? taggedParts(entry as Record<string, unknown>) : entry
|
|
249
|
-
}
|
|
250
|
-
const given = own(value)
|
|
251
|
-
const added = typeof parts === 'object' && parts !== null ? own(parts) : undefined
|
|
266
|
+
const { parts } = (props ?? {}) as { parts?: unknown }
|
|
267
|
+
const entry = typeof parts === 'object' && parts !== null && !Array.isArray(parts) && Object.hasOwn(parts, part) ? (parts as Record<string, unknown>)[part] : undefined
|
|
268
|
+
const added = entryParts(entry)
|
|
269
|
+
const given = part === 'root' ? (props as { class?: unknown } | undefined)?.class : undefined
|
|
252
270
|
|
|
253
|
-
// The `class` entry comes last: a component handing a part on gives its caller's entry as `class` beside the `parts` its own template writes, and the caller has the last word.
|
|
254
271
|
if (given === undefined || added === undefined)
|
|
255
272
|
return added ?? given
|
|
256
273
|
|
|
257
|
-
if (isParts(
|
|
258
|
-
return
|
|
274
|
+
if (isParts(added) && joinable(given))
|
|
275
|
+
return taggedParts({ ...added, root: [added.root, given] })
|
|
259
276
|
|
|
260
277
|
return joinable(given) && joinable(added) ? [added, given] : given
|
|
261
278
|
}
|
|
@@ -21,6 +21,15 @@ export function setCurrentUrl(read: () => URL | undefined): void {
|
|
|
21
21
|
serverUrl = read
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
// The signals kept in the query, each reading its param again from the address when a swap or a traversal changed it under them: a signal made outside a component, which an app shares between its islands, outlives the page that read it first.
|
|
25
|
+
export const followers = new Set<() => void>()
|
|
26
|
+
|
|
27
|
+
// Reads every signal kept in the query again from the address the page was swapped or traversed to.
|
|
28
|
+
export function followAddress(): void {
|
|
29
|
+
for (const reread of followers)
|
|
30
|
+
reread()
|
|
31
|
+
}
|
|
32
|
+
|
|
24
33
|
// Tells the links built by `withQuery` in the browser that the address changed, a swap or a query written in place.
|
|
25
34
|
export function addressChanged(): void {
|
|
26
35
|
if (built !== location.pathname + location.search)
|
|
@@ -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.~-]+)*$/
|