@kayjs/kay 1.108.0 → 1.110.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 +2093 -3774
- 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-library-conventions.md +1 -1
- package/llms/components.md +5 -5
- package/llms/deprecated-lints.md +2 -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 +4 -2
- package/llms/island-sources.md +1 -1
- package/llms/islands-state-to-ids.md +2 -2
- package/llms/islands.md +8 -4
- package/llms/lints.md +1 -1
- package/llms/live-values.md +4 -4
- 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 +7 -7
- package/llms/navigation.md +4 -2
- 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/templates-elements-slots-snippets.md +2 -2
- 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 +64 -74
- package/llms/upgrading.md +92 -70
- package/llms/whats-new.md +24 -0
- package/llms.txt +5 -6
- package/package.json +6 -10
- package/src/build/route-sizes.ts +2 -3
- package/src/build/variants.ts +132 -18
- 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/env-types.ts +1 -1
- 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 +6 -7
- package/src/check/schema-builders.ts +125 -26
- package/src/check/shadow-types.ts +0 -86
- package/src/commands/check.ts +2 -2
- package/src/commands/env.ts +25 -3
- package/src/commands/upgrade.ts +2 -1
- package/src/compiler/allow-comments.ts +38 -2
- package/src/compiler/ast.ts +21 -19
- package/src/compiler/browser.ts +2 -14
- package/src/compiler/class-items.ts +16 -0
- package/src/compiler/codegen.ts +10 -10
- package/src/compiler/deprecated-library.ts +0 -12
- package/src/compiler/deprecated-lints-1-106.ts +2 -2
- 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 +83 -0
- package/src/compiler/helper-imports.ts +2 -2
- package/src/compiler/image-attributes.ts +1 -3
- package/src/compiler/index.ts +23 -23
- package/src/compiler/island-arguments.ts +17 -95
- package/src/compiler/island-cause.ts +7 -7
- package/src/compiler/island-declaration.ts +2 -8
- package/src/compiler/island-lints.ts +19 -0
- package/src/compiler/island-marker.ts +3 -3
- package/src/compiler/island-problems.ts +25 -0
- package/src/compiler/items.ts +12 -0
- package/src/compiler/jsx-class.ts +1 -25
- package/src/compiler/jsx.ts +7 -6
- package/src/compiler/kay-exports.ts +0 -2
- package/src/compiler/link-flags.ts +9 -38
- package/src/compiler/lints.ts +10 -18
- package/src/compiler/markup.ts +33 -41
- 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/removed-lints.ts +90 -0
- package/src/compiler/rewrite.ts +3 -18
- package/src/compiler/script-server.ts +8 -3
- package/src/compiler/signal-from-prop.ts +141 -0
- package/src/compiler/template-reads.ts +16 -0
- 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 +25 -13
- package/src/runtime/client.ts +7 -11
- 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/image.ts +2 -19
- package/src/runtime/index.ts +3 -3
- package/src/runtime/island.server.ts +56 -13
- 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/navigate.ts +9 -0
- package/src/runtime/navigation-state.ts +0 -12
- package/src/runtime/navigation.ts +5 -1
- package/src/runtime/page-swap.ts +8 -8
- 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/swap-flight.ts +10 -10
- package/src/runtime/swap-kept.ts +69 -29
- package/src/runtime/swap-morph.ts +49 -9
- package/src/runtime/text-hash.ts +17 -0
- package/src/runtime/uid.server.ts +6 -4
- package/src/runtime/values.ts +52 -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 +9 -7
- package/src/server/render.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/build/variants.d.ts +9 -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/schema-builders.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/commands/upgrade.d.ts.map +1 -1
- package/types/compiler/allow-comments.d.ts +2 -0
- package/types/compiler/allow-comments.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-1-106.d.ts +2 -2
- package/types/compiler/deprecated-lints-1-106.d.ts.map +1 -1
- package/types/compiler/deprecated-lints.d.ts +2 -553
- 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 +10 -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 +7 -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 +17 -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/items.d.ts +1 -0
- package/types/compiler/items.d.ts.map +1 -1
- package/types/compiler/jsx-class.d.ts +1 -2
- package/types/compiler/jsx-class.d.ts.map +1 -1
- package/types/compiler/jsx.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 +21 -566
- 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/removed-lints.d.ts +3 -0
- package/types/compiler/removed-lints.d.ts.map +1 -0
- package/types/compiler/script-server.d.ts.map +1 -1
- package/types/compiler/signal-from-prop.d.ts +4 -0
- package/types/compiler/signal-from-prop.d.ts.map +1 -0
- package/types/compiler/template-reads.d.ts +1 -0
- package/types/compiler/template-reads.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 +14 -11
- package/types/runtime/checks.d.ts.map +1 -1
- package/types/runtime/client.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/image.d.ts.map +1 -1
- package/types/runtime/index.d.ts +3 -3
- package/types/runtime/index.d.ts.map +1 -1
- package/types/runtime/island.server.d.ts +2 -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/navigate.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/navigation.d.ts +2 -0
- package/types/runtime/navigation.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/swap-flight.d.ts +1 -1
- package/types/runtime/swap-flight.d.ts.map +1 -1
- package/types/runtime/swap-kept.d.ts.map +1 -1
- package/types/runtime/swap-morph.d.ts.map +1 -1
- package/types/runtime/text-hash.d.ts +2 -0
- package/types/runtime/text-hash.d.ts.map +1 -0
- package/types/runtime/uid.server.d.ts.map +1 -1
- package/types/runtime/values.d.ts +6 -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/render-document.d.ts +1 -1
- package/types/server/render-document.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,185 +0,0 @@
|
|
|
1
|
-
import type { CheckDiagnostic, CheckOptions } from '.'
|
|
2
|
-
import type { Node, NodeOfType } from '../compiler/estree'
|
|
3
|
-
import type { LintName } from '../compiler/lints'
|
|
4
|
-
import type { Edit, Found } from './renamed-exports'
|
|
5
|
-
import { lintLevel } from '../compiler/lints'
|
|
6
|
-
import { importsOf, walk } from './ast'
|
|
7
|
-
import { scan } from './renamed-exports'
|
|
8
|
-
|
|
9
|
-
const FROM_KAY = (source: string) => source === 'kay' || source === 'kay/library' || source === '@kayjs/kay' || source === '@kayjs/kay/library'
|
|
10
|
-
const NEEDLE = /\b(?:deny|fail|refuse)\(/
|
|
11
|
-
const COMMENT = /\/[*/]/
|
|
12
|
-
const BEFORE_VALUE = /(?:\breturn|=>|\?)\s*$/
|
|
13
|
-
const BEFORE_COLON = /:\s*$/
|
|
14
|
-
const LAST_STATEMENT = /[^;{}\n]*$/
|
|
15
|
-
const CASE_LABEL = /^\s*(?:case\b|default\b)/
|
|
16
|
-
|
|
17
|
-
type Call = NodeOfType<'CallExpression'>
|
|
18
|
-
type Part = [key: string, text: string]
|
|
19
|
-
|
|
20
|
-
const isText = (node: Node | undefined): boolean => node?.type === 'TemplateLiteral' || (node?.type === 'Literal' && typeof node.value === 'string')
|
|
21
|
-
const isUndefined = (node: Node | undefined): boolean => node?.type === 'Identifier' && node.name === 'undefined'
|
|
22
|
-
|
|
23
|
-
// `{ message: 'x', data }`, a part written as its key when the text is that name.
|
|
24
|
-
function objectOf(parts: Part[]): string {
|
|
25
|
-
return `{ ${parts.map(([key, text]) => key === text ? key : `${key}: ${text}`).join(', ')} }`
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// The edit swapping the arguments from `first` on for the object, or none when a comment sits between them, which the swap would drop.
|
|
29
|
-
function swapArguments(text: string, base: number, call: Call, first: number, parts: Part[]): Edit[] | null {
|
|
30
|
-
const from = call.arguments[first]!
|
|
31
|
-
|
|
32
|
-
if (COMMENT.test(text.slice(from.start, call.end)))
|
|
33
|
-
return null
|
|
34
|
-
|
|
35
|
-
return [{ start: base + from.start, end: base + call.end - 1, text: objectOf(parts) }]
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// `ctx.deny(status, 'message', data)`, `ctx.deny(status, { message, data })` since 1.105: a refusal takes the one `{ message, errors, data }` everywhere, as `refuse(status, options)` does.
|
|
39
|
-
// Found on a call of `deny`, bare or read off a name, whose status is a literal from 400 to 599 and whose second argument is a text.
|
|
40
|
-
function denyCalls({ parsed, report }: Found): void {
|
|
41
|
-
for (const { ast, base, text } of parsed) {
|
|
42
|
-
walk(ast, (node) => {
|
|
43
|
-
if (node.type !== 'CallExpression' || !isDeny(node.callee) || node.arguments.length < 2 || node.arguments.length > 3 || !isErrorStatus(node.arguments[0]) || !isText(node.arguments[1]) || node.arguments.some(argument => argument.type === 'SpreadElement'))
|
|
44
|
-
return
|
|
45
|
-
|
|
46
|
-
const [, message, data] = node.arguments as [Node, Node, Node | undefined]
|
|
47
|
-
const parts: Part[] = [['message', text.slice(message.start, message.end)]]
|
|
48
|
-
|
|
49
|
-
if (data !== undefined && !isUndefined(data))
|
|
50
|
-
parts.push(['data', text.slice(data.start, data.end)])
|
|
51
|
-
|
|
52
|
-
// With `data`, an action fails the post as `ctx.fail` did instead of stopping with plain text, so that call is left to the app.
|
|
53
|
-
report(base + node.start, base + node.end, '`deny(status, message, data)` is `deny(status, { message, data })` since 1.105', 'write the message and the data in one object', data === undefined || isUndefined(data) ? swapArguments(text, base, node, 1, parts) : null)
|
|
54
|
-
})
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Whether a value is read from the call: after `return`, an arrow or a `?`, or a `:` closing a ternary, not a `case` or a label.
|
|
59
|
-
function isReturned(before: string): boolean {
|
|
60
|
-
if (BEFORE_VALUE.test(before))
|
|
61
|
-
return true
|
|
62
|
-
|
|
63
|
-
return BEFORE_COLON.test(before) && !CASE_LABEL.test(LAST_STATEMENT.exec(before)?.[0] ?? '') && (LAST_STATEMENT.exec(before)?.[0] ?? '').includes('?')
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function isDeny(callee: Node): boolean {
|
|
67
|
-
return (callee.type === 'Identifier' && callee.name === 'deny') || (callee.type === 'MemberExpression' && !callee.computed && callee.property.type === 'Identifier' && callee.property.name === 'deny')
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function isErrorStatus(node: Node | undefined): boolean {
|
|
71
|
-
return node?.type === 'Literal' && typeof node.value === 'number' && node.value >= 400 && node.value <= 599
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// `return ctx.fail(status, data, errors)`, `return ctx.deny(status, { data, errors })` since 1.105: an action refuses as a guard and a page do. A text `data` is the form's message and is written as the `message`, and a call with neither data nor errors is left, as `deny(status)` stops with plain text.
|
|
75
|
-
// Found on `ctx.fail` of a handler's `ctx`; the fix is made where the call is returned, as `deny` throws and `fail` did not.
|
|
76
|
-
function failCalls({ parsed, report }: Found): void {
|
|
77
|
-
for (const { ast, base, text } of parsed) {
|
|
78
|
-
walk(ast, (node) => {
|
|
79
|
-
if (node.type !== 'CallExpression' || node.callee.type !== 'MemberExpression' || node.callee.computed || node.callee.object.type !== 'Identifier' || node.callee.object.name !== 'ctx' || node.callee.property.type !== 'Identifier' || node.callee.property.name !== 'fail' || node.arguments.length === 0)
|
|
80
|
-
return
|
|
81
|
-
|
|
82
|
-
const [status, data, errors] = node.arguments
|
|
83
|
-
const parts: Part[] = []
|
|
84
|
-
|
|
85
|
-
if (data !== undefined && !isUndefined(data))
|
|
86
|
-
parts.push([isText(data) ? 'message' : 'data', text.slice(data.start, data.end)])
|
|
87
|
-
|
|
88
|
-
if (errors !== undefined && !isUndefined(errors))
|
|
89
|
-
parts.push(['errors', text.slice(errors.start, errors.end)])
|
|
90
|
-
|
|
91
|
-
const returned = isReturned(text.slice(0, node.start))
|
|
92
|
-
const plain = node.arguments.length <= 3 && node.arguments.every(argument => argument.type !== 'SpreadElement') && status !== undefined && !COMMENT.test(text.slice(status.start, node.end))
|
|
93
|
-
const property = node.callee.property
|
|
94
|
-
const edits: Edit[] = [{ start: base + property.start, end: base + property.end, text: 'deny' }]
|
|
95
|
-
|
|
96
|
-
if (parts.length > 0)
|
|
97
|
-
edits.push({ start: base + status!.end, end: base + node.end - 1, text: `, ${objectOf(parts)}` })
|
|
98
|
-
|
|
99
|
-
report(base + node.start, base + node.end, '`ctx.fail(status, data, errors)` is `ctx.deny(status, { data, errors })` since 1.105', 'write `ctx.deny` with the data and the errors in one object', returned && plain && parts.length > 0 ? edits : null)
|
|
100
|
-
})
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// `refuse('message', { status, errors, data })`, `refuse(status, { message, errors, data })` since 1.105.
|
|
105
|
-
// Found on a call of `refuse` imported from `kay`, whose first argument is a text; the fix is made when the options are an object written in the call and the status is known.
|
|
106
|
-
function refuseCalls({ parsed, report }: Found): void {
|
|
107
|
-
for (const { ast, base, text } of parsed) {
|
|
108
|
-
const { locals, namespaces } = importsOf(ast, FROM_KAY, 'refuse')
|
|
109
|
-
|
|
110
|
-
if (locals.size === 0 && namespaces.size === 0)
|
|
111
|
-
continue
|
|
112
|
-
|
|
113
|
-
walk(ast, (node) => {
|
|
114
|
-
const named = node.type === 'CallExpression' && (node.callee.type === 'Identifier' ? locals.has(node.callee.name) : node.callee.type === 'MemberExpression' && !node.callee.computed && node.callee.object.type === 'Identifier' && namespaces.has(node.callee.object.name) && node.callee.property.type === 'Identifier' && node.callee.property.name === 'refuse')
|
|
115
|
-
|
|
116
|
-
if (!named || node.type !== 'CallExpression' || !isText(node.arguments[0]) || node.arguments.length > 2)
|
|
117
|
-
return
|
|
118
|
-
|
|
119
|
-
report(base + node.start, base + node.end, '`refuse(message, { status, errors, data })` is `refuse(status, { message, errors, data })` since 1.105', 'write the status first and the message in the options', refuseEdits(text, base, node))
|
|
120
|
-
})
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function fieldsOf(errors: Node): 'none' | 'named' | 'unknown' {
|
|
125
|
-
if (errors.type !== 'ObjectExpression')
|
|
126
|
-
return 'unknown'
|
|
127
|
-
|
|
128
|
-
if (errors.properties.some(property => property.type === 'SpreadElement'))
|
|
129
|
-
return 'unknown'
|
|
130
|
-
|
|
131
|
-
return errors.properties.length > 0 ? 'named' : 'none'
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function refuseEdits(text: string, base: number, call: Call): Edit[] | null {
|
|
135
|
-
const [message, options] = call.arguments as [Node, Node | undefined]
|
|
136
|
-
const parts: Part[] = [['message', text.slice(message.start, message.end)]]
|
|
137
|
-
let status: string | undefined
|
|
138
|
-
// Without a status, `errors` naming fields is a 422, which only an object written in the call can be told to name some.
|
|
139
|
-
let fields: 'none' | 'named' | 'unknown' = 'none'
|
|
140
|
-
|
|
141
|
-
if (options !== undefined) {
|
|
142
|
-
if (options.type !== 'ObjectExpression' || COMMENT.test(text.slice(options.start, options.end)))
|
|
143
|
-
return null
|
|
144
|
-
|
|
145
|
-
for (const property of options.properties) {
|
|
146
|
-
if (property.type !== 'Property' || property.computed || property.kind !== 'init' || property.method || property.key.type !== 'Identifier')
|
|
147
|
-
return null
|
|
148
|
-
|
|
149
|
-
const { name } = property.key
|
|
150
|
-
const value = text.slice(property.value.start, property.value.end)
|
|
151
|
-
|
|
152
|
-
if (name === 'status') {
|
|
153
|
-
status = value
|
|
154
|
-
}
|
|
155
|
-
else if (name === 'data') {
|
|
156
|
-
parts.push([name, value])
|
|
157
|
-
}
|
|
158
|
-
else if (name === 'errors') {
|
|
159
|
-
parts.push([name, value])
|
|
160
|
-
fields = fieldsOf(property.value)
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
return null
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
if (status === undefined && fields === 'unknown')
|
|
169
|
-
return null
|
|
170
|
-
|
|
171
|
-
return [{ start: base + message.start, end: base + (options ?? message).end, text: `${status ?? (fields === 'named' ? '422' : '403')}, ${objectOf(parts)}` }]
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
const SCANS: [LintName, (found: Found) => void][] = [
|
|
175
|
-
['deprecated-deny-call', denyCalls],
|
|
176
|
-
['deprecated-ctx-fail', failCalls],
|
|
177
|
-
['deprecated-refuse-call', refuseCalls],
|
|
178
|
-
]
|
|
179
|
-
|
|
180
|
-
// The three spellings of a refusal before 1.105, found in the TypeScript files and `.kay` files of the project as `kay check` reads no types: a call through a name it cannot follow is not found.
|
|
181
|
-
export async function refusalCalls(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
|
|
182
|
-
const found = await Promise.all(SCANS.filter(([lint]) => lintLevel(lint, options.lints) !== 'allow').map(async ([lint, visit]) => scan(root, options, lint, NEEDLE, visit)))
|
|
183
|
-
|
|
184
|
-
return found.flat()
|
|
185
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import type { CheckDiagnostic, CheckOptions } from '.'
|
|
2
|
-
import type { Edit } from './renamed-exports'
|
|
3
|
-
import { basename } from 'node:path'
|
|
4
|
-
import { RETIRED_LINTS } from '../compiler/deprecated-allow'
|
|
5
|
-
import { lintLevel } from '../compiler/lints'
|
|
6
|
-
import { constBindings, exportedObject, keyName } from '../compiler/object-literal'
|
|
7
|
-
import { scan } from './renamed-exports'
|
|
8
|
-
|
|
9
|
-
const NEEDLE = /uncaught-await/
|
|
10
|
-
|
|
11
|
-
// A `lints: { 'uncaught-await': ... }` entry in kay.config.ts: the lint is gone since 1.105, so the entry sets nothing. The fix deletes the entry with its line.
|
|
12
|
-
export async function retiredLintLevels(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
|
|
13
|
-
if (lintLevel('deprecated-uncaught-await', options.lints) === 'allow')
|
|
14
|
-
return []
|
|
15
|
-
|
|
16
|
-
return scan(root, options, 'deprecated-uncaught-await', NEEDLE, ({ file, parsed, report }) => {
|
|
17
|
-
if (basename(file) !== 'kay.config.ts')
|
|
18
|
-
return
|
|
19
|
-
|
|
20
|
-
for (const { ast, base, text } of parsed) {
|
|
21
|
-
const lints = exportedObject(ast, constBindings(ast))?.properties.find(property => property.type === 'Property' && !property.computed && keyName(property) === 'lints')
|
|
22
|
-
|
|
23
|
-
if (lints?.type !== 'Property' || lints.value.type !== 'ObjectExpression')
|
|
24
|
-
continue
|
|
25
|
-
|
|
26
|
-
for (const property of lints.value.properties) {
|
|
27
|
-
const name = property.type === 'Property' && !property.computed ? keyName(property) : undefined
|
|
28
|
-
|
|
29
|
-
if (property.type !== 'Property' || name === undefined || !RETIRED_LINTS.has(name))
|
|
30
|
-
continue
|
|
31
|
-
|
|
32
|
-
// The entry with its comma, and the line it leaves empty.
|
|
33
|
-
let start = property.start
|
|
34
|
-
let end = property.end
|
|
35
|
-
|
|
36
|
-
while (start > 0 && (text[start - 1] === ' ' || text[start - 1] === '\t'))
|
|
37
|
-
start--
|
|
38
|
-
|
|
39
|
-
if (text[end] === ',')
|
|
40
|
-
end++
|
|
41
|
-
|
|
42
|
-
const alone = (start === 0 || text[start - 1] === '\n') && text[end] === '\n'
|
|
43
|
-
const edits: Edit[] = [{ start: base + start, end: base + (alone ? end + 1 : end), text: '' }]
|
|
44
|
-
|
|
45
|
-
report(base + property.start, base + property.end, `\`lints\` names \`${name}\`, a lint that is gone since 1.105`, 'an `await` with no `catch` renders an alert, so there is nothing to set: remove the entry', edits)
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
})
|
|
49
|
-
}
|
package/src/check/route-keys.ts
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import type { CheckDiagnostic, CheckOptions } from '.'
|
|
2
|
-
import type { NodeOfType } from '../compiler/estree'
|
|
3
|
-
import type { Property } from './regroup'
|
|
4
|
-
import type { Edit } from './renamed-exports'
|
|
5
|
-
import { lintLevel } from '../compiler/lints'
|
|
6
|
-
import { configObjects, propertiesOf, propertyOf } from './config-objects'
|
|
7
|
-
import { nameOf } from './regroup'
|
|
8
|
-
import { scan } from './renamed-exports'
|
|
9
|
-
|
|
10
|
-
type ObjectExpression = NodeOfType<'ObjectExpression'>
|
|
11
|
-
|
|
12
|
-
const NEEDLE = /\b(?:apiPrefix|referencePath|openapi|mcp|health|metrics|jobs)\b/
|
|
13
|
-
const PUNCTUATION = /^[\s,]*$/
|
|
14
|
-
const BAGS = ['openapi', 'mcp', 'health', 'metrics', 'jobs'] as const
|
|
15
|
-
const OPS_BAGS = ['health', 'metrics', 'jobs']
|
|
16
|
-
|
|
17
|
-
// One old key: the bag holding it, its name, the property, and the `endpoints` key it is.
|
|
18
|
-
interface Old {
|
|
19
|
-
bag: ObjectExpression
|
|
20
|
-
from: string
|
|
21
|
-
property: Property
|
|
22
|
-
to: string
|
|
23
|
-
// `openapi.referencePath`, which is `reference: { path }` and no key of `endpoints`.
|
|
24
|
-
reference: boolean
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// The edits that remove some properties of an object, or undefined where a comment would go with them: each takes its own span up to the next property, the last one that and the comma before it, and an object left empty is `{}`.
|
|
28
|
-
function removals(object: ObjectExpression, gone: ReadonlySet<Property>, text: string): Edit[] | undefined {
|
|
29
|
-
const { properties } = object
|
|
30
|
-
const edits: Edit[] = []
|
|
31
|
-
|
|
32
|
-
if (properties.every(property => property.type === 'Property' && gone.has(property))) {
|
|
33
|
-
const gaps = properties.map((property, index) => text.slice(index === 0 ? object.start + 1 : properties[index - 1]!.end, property.start)).concat(text.slice(properties.at(-1)!.end, object.end - 1))
|
|
34
|
-
|
|
35
|
-
return gaps.every(gap => PUNCTUATION.test(gap)) ? [{ start: object.start, end: object.end, text: '{}' }] : undefined
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
for (const [index, property] of properties.entries()) {
|
|
39
|
-
if (property.type !== 'Property' || !gone.has(property))
|
|
40
|
-
continue
|
|
41
|
-
|
|
42
|
-
const next = properties[index + 1]
|
|
43
|
-
const previous = properties[index - 1]
|
|
44
|
-
const alone = previous === undefined || (previous.type === 'Property' && gone.has(previous))
|
|
45
|
-
const [start, end] = next === undefined ? [alone ? property.start : previous.end, property.end] : [property.start, next.start]
|
|
46
|
-
const gap = next !== undefined ? text.slice(property.end, next.start) : text.slice(start, property.start)
|
|
47
|
-
|
|
48
|
-
if (!PUNCTUATION.test(gap))
|
|
49
|
-
return undefined
|
|
50
|
-
|
|
51
|
-
edits.push({ start, end, text: '' })
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return edits
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// The keys that name where a feature is served, which are keys of `endpoints` since 1.105: `serve.apiPrefix` is `endpoints.api`, the `path` of `openapi`, `mcp`, `health`, `metrics` and `jobs` is `endpoints.openapi`, `.mcp`, `.health`, `.metrics` and `.jobs`, and `openapi.referencePath` is `openapi.reference: { path }`.
|
|
58
|
-
// The fix, from the first report of an object, writes the paths in a new `endpoints` and removes them where they were, and offers none where the object spreads, holds a computed key or an `endpoints` already, a bag is bound outside it, or a comment would be lost.
|
|
59
|
-
export async function routeKeys(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
|
|
60
|
-
if (lintLevel('deprecated-route-keys', options.lints) === 'allow')
|
|
61
|
-
return []
|
|
62
|
-
|
|
63
|
-
return scan(root, options, 'deprecated-route-keys', NEEDLE, ({ file, parsed, report }) => {
|
|
64
|
-
for (const { ast, base, text } of parsed) {
|
|
65
|
-
for (const { object, call } of configObjects(file, ast)) {
|
|
66
|
-
// The options of a call are moved into `config` by `deprecated-pages-options` first.
|
|
67
|
-
if (call !== undefined)
|
|
68
|
-
continue
|
|
69
|
-
|
|
70
|
-
const olds: Old[] = []
|
|
71
|
-
const holders: Property[] = []
|
|
72
|
-
const inline = (property: Property | undefined): ObjectExpression | undefined => property?.value.type === 'ObjectExpression' ? property.value : undefined
|
|
73
|
-
const bagsOf = (owner: ObjectExpression, names: readonly string[], within?: Property): void => {
|
|
74
|
-
for (const name of names) {
|
|
75
|
-
for (const property of propertiesOf(owner, name)) {
|
|
76
|
-
const bag = inline(property)
|
|
77
|
-
|
|
78
|
-
for (const key of bag === undefined ? [] : propertiesOf(bag, 'path')) {
|
|
79
|
-
holders.push(within ?? property)
|
|
80
|
-
olds.push({ bag: bag!, from: name, property: key, to: name, reference: false })
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
for (const key of bag === undefined || name !== 'openapi' ? [] : propertiesOf(bag, 'referencePath'))
|
|
84
|
-
olds.push({ bag: bag!, from: name, property: key, to: 'reference', reference: true })
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
bagsOf(object, BAGS)
|
|
90
|
-
|
|
91
|
-
const opsProperty = propertyOf(object, 'ops')
|
|
92
|
-
const ops = inline(opsProperty)
|
|
93
|
-
|
|
94
|
-
if (ops !== undefined)
|
|
95
|
-
bagsOf(ops, OPS_BAGS, opsProperty)
|
|
96
|
-
|
|
97
|
-
for (const serve of propertiesOf(object, 'serve')) {
|
|
98
|
-
const bag = inline(serve)
|
|
99
|
-
|
|
100
|
-
for (const key of bag === undefined ? [] : propertiesOf(bag, 'apiPrefix')) {
|
|
101
|
-
holders.push(serve)
|
|
102
|
-
olds.push({ bag: bag!, from: 'serve', property: key, to: 'api', reference: false })
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (olds.length === 0)
|
|
107
|
-
continue
|
|
108
|
-
|
|
109
|
-
const fix = fixOf(object, olds, holders, text, base)
|
|
110
|
-
|
|
111
|
-
for (const [index, old] of olds.entries()) {
|
|
112
|
-
report(base + old.property.start, base + old.property.end, old.reference ? '`openapi.referencePath` is `openapi.reference: { path }` since 1.105' : `\`${old.from}.${nameOf(old.property)}\` is \`endpoints.${old.to}\` since 1.105`, old.reference ? 'write `reference: { path }`' : `write the path in \`endpoints: { ${old.to} }\``, index === 0 ? fix : null)
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
})
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function fixOf(object: ObjectExpression, olds: Old[], holders: Property[], text: string, base: number): Edit[] | null {
|
|
120
|
-
if (object.properties.some(property => property.type !== 'Property' || property.computed) || propertiesOf(object, 'endpoints').length > 0)
|
|
121
|
-
return null
|
|
122
|
-
|
|
123
|
-
const edits: Edit[] = []
|
|
124
|
-
const paths = new Map<string, string>()
|
|
125
|
-
|
|
126
|
-
for (const old of olds) {
|
|
127
|
-
if (old.property.kind !== 'init' || old.property.method || old.bag.properties.some(property => property.type !== 'Property' || property.computed))
|
|
128
|
-
return null
|
|
129
|
-
|
|
130
|
-
if (old.reference) {
|
|
131
|
-
const reference = propertiesOf(old.bag, 'reference')[0]
|
|
132
|
-
|
|
133
|
-
if (reference?.value.type !== 'Literal' || reference.value.value !== true)
|
|
134
|
-
return null
|
|
135
|
-
|
|
136
|
-
edits.push({ start: reference.value.start, end: reference.value.end, text: `{ path: ${text.slice(old.property.value.start, old.property.value.end)} }` })
|
|
137
|
-
|
|
138
|
-
continue
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
if (paths.has(old.to))
|
|
142
|
-
return null
|
|
143
|
-
|
|
144
|
-
paths.set(old.to, text.slice(old.property.value.start, old.property.value.end))
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
for (const [bag, gone] of Map.groupBy(olds, old => old.bag)) {
|
|
148
|
-
const removed = removals(bag, new Set(gone.map(old => old.property)), text)
|
|
149
|
-
|
|
150
|
-
if (removed === undefined)
|
|
151
|
-
return null
|
|
152
|
-
|
|
153
|
-
edits.push(...removed)
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
if (paths.size > 0) {
|
|
157
|
-
const first = holders.toSorted((a, b) => a.start - b.start)[0]!
|
|
158
|
-
const lineStart = text.lastIndexOf('\n', first.start - 1) + 1
|
|
159
|
-
const indent = text.slice(lineStart, first.start)
|
|
160
|
-
const written = `endpoints: { ${[...paths].map(([name, value]) => `${name}: ${value}`).join(', ')} }`
|
|
161
|
-
|
|
162
|
-
edits.push({ start: first.start, end: first.start, text: indent !== '' && PUNCTUATION.test(indent) ? `${written},\n${indent}` : `${written}, ` })
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
return edits.map(edit => ({ ...edit, start: base + edit.start, end: base + edit.end }))
|
|
166
|
-
}
|
package/src/check/secret-keys.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import type { CheckDiagnostic, CheckOptions } from '.'
|
|
2
|
-
import type { Property } from './regroup'
|
|
3
|
-
import type { Edit } from './renamed-exports'
|
|
4
|
-
import { lintLevel } from '../compiler/lints'
|
|
5
|
-
import { configObjects, propertiesOf } from './config-objects'
|
|
6
|
-
import { regrouped } from './regroup'
|
|
7
|
-
import { scan } from './renamed-exports'
|
|
8
|
-
|
|
9
|
-
const NEEDLE = /\b(?:key|mcpKey|proxyKey)\b/
|
|
10
|
-
const TEST_KEYS = { mcpKey: 'mcp: { token }', proxyKey: 'proxy: { key: { header, secret } }' }
|
|
11
|
-
|
|
12
|
-
// The `key` of `mcp`, which is `token` since 1.105, and the string `key` of `proxy`, which names its header as `{ header }`, in the config; and the `mcpKey` and `proxyKey` options of `testSite()`, which are `config: { mcp: { token } }` and `config: { proxy: { key: { header, secret } } }`.
|
|
13
|
-
// The fix renames `mcp.key`, except for `false`, which has no token, and wraps the header of `proxy.key`, where the object is written in place; the options of `testSite()` move into a `config`, `proxyKey` only where the app's config names the header it travels in, and a `config` already written is left as it is.
|
|
14
|
-
export async function secretKeys(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
|
|
15
|
-
if (lintLevel('deprecated-secret-keys', options.lints) === 'allow')
|
|
16
|
-
return []
|
|
17
|
-
|
|
18
|
-
return scan(root, options, 'deprecated-secret-keys', NEEDLE, ({ file, parsed, report }) => {
|
|
19
|
-
for (const { ast, base, text } of parsed) {
|
|
20
|
-
for (const { object, call } of configObjects(file, ast)) {
|
|
21
|
-
if (call === 'testSite') {
|
|
22
|
-
const header = options.proxyHeader
|
|
23
|
-
const shaped = (name: string, value: string) => name === 'mcpKey' ? `{ token: ${value} }` : `{ key: { header: '${header}', secret: ${value} } }`
|
|
24
|
-
const moves = regrouped(object, text, name => testGroup(name, header), false, shaped)
|
|
25
|
-
|
|
26
|
-
for (const [name, written] of Object.entries(TEST_KEYS)) {
|
|
27
|
-
for (const property of propertiesOf(object, name))
|
|
28
|
-
report(base + property.start, base + property.end, `\`${name}\` of \`testSite()\` is \`${written}\` in \`config\` since 1.105`, `write \`config: { ${written} }\``, name === 'mcpKey' || header !== undefined ? moves ?? null : null)
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (call !== undefined)
|
|
33
|
-
continue
|
|
34
|
-
|
|
35
|
-
const groupOf = (name: string): Property | undefined => propertiesOf(object, name).find(property => property.value.type === 'ObjectExpression')
|
|
36
|
-
const mcp = groupOf('mcp')
|
|
37
|
-
const proxy = groupOf('proxy')
|
|
38
|
-
|
|
39
|
-
for (const [group, name] of [[mcp, 'mcp'], [proxy, 'proxy']] as const) {
|
|
40
|
-
if (group === undefined || group.value.type !== 'ObjectExpression')
|
|
41
|
-
continue
|
|
42
|
-
|
|
43
|
-
const inner = group.value
|
|
44
|
-
const spread = inner.properties.some(property => property.type !== 'Property')
|
|
45
|
-
|
|
46
|
-
for (const property of propertiesOf(inner, 'key')) {
|
|
47
|
-
const value = property.value
|
|
48
|
-
|
|
49
|
-
// The form of since 1.105.
|
|
50
|
-
if (name === 'proxy' && value.type === 'ObjectExpression')
|
|
51
|
-
continue
|
|
52
|
-
|
|
53
|
-
const edits = fixOf(name, property, text, base, spread, value.type === 'Literal' && value.value === false, propertiesOf(inner, 'token').length > 0)
|
|
54
|
-
|
|
55
|
-
report(base + property.start, base + property.end, name === 'mcp' ? '`mcp.key` is `mcp.token` since 1.105' : '`proxy.key` names its header as `{ header }` since 1.105', name === 'mcp' ? 'write `token`' : 'write `key: { header }`, with the key as `secret` when it is not in KAY_PROXY_KEY', edits)
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
})
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Where a `testSite()` option moves to in its `config`, `proxyKey` only once the header it travels in is known.
|
|
64
|
-
function testGroup(name: string, header: string | undefined): [string, string] | undefined {
|
|
65
|
-
if (name === 'mcpKey')
|
|
66
|
-
return ['config', 'mcp']
|
|
67
|
-
|
|
68
|
-
return name === 'proxyKey' && header !== undefined ? ['config', 'proxy'] : undefined
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function fixOf(group: 'mcp' | 'proxy', property: Property, text: string, base: number, spread: boolean, off: boolean, taken: boolean): Edit[] | null {
|
|
72
|
-
if (spread || property.kind !== 'init' || property.method)
|
|
73
|
-
return null
|
|
74
|
-
|
|
75
|
-
if (group === 'mcp') {
|
|
76
|
-
if (off || taken)
|
|
77
|
-
return null
|
|
78
|
-
|
|
79
|
-
return [property.shorthand ? { start: base + property.start, end: base + property.end, text: 'token: key' } : { start: base + property.key.start, end: base + property.key.end, text: 'token' }]
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return [{ start: base + property.start, end: base + property.end, text: property.shorthand ? 'key: { header: key }' : `key: { header: ${text.slice(property.value.start, property.value.end)} }` }]
|
|
83
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import type { CheckDiagnostic, CheckOptions } from '.'
|
|
2
|
-
import type { Node } from '../compiler/estree'
|
|
3
|
-
import { lintLevel } from '../compiler/lints'
|
|
4
|
-
import { importedName, walk } from './ast'
|
|
5
|
-
import { scan } from './renamed-exports'
|
|
6
|
-
|
|
7
|
-
const OLD_FRAME = /\.(?:send|publish)\([\s\S]*?JSON\.stringify\(/
|
|
8
|
-
const HANDLERS = new Set(['open', 'message', 'close'])
|
|
9
|
-
|
|
10
|
-
// `ws.send(JSON.stringify(value))` in a handler of an `api()` module's `.ws()` route: every frame is JSON since 1.105, so the text sent here would reach the client as a string holding JSON.
|
|
11
|
-
// Found on the first parameter of an `open`, `message` or `close` handler written in the options of a `.ws()` chained from the `api` a file imports from `kay/server`.
|
|
12
|
-
export async function socketFrames(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
|
|
13
|
-
if (lintLevel('deprecated-socket-frames', options.lints) === 'allow')
|
|
14
|
-
return []
|
|
15
|
-
|
|
16
|
-
return scan(root, options, 'deprecated-socket-frames', OLD_FRAME, ({ parsed, report }) => {
|
|
17
|
-
for (const { ast, base, text } of parsed) {
|
|
18
|
-
const apis = new Set<string>()
|
|
19
|
-
|
|
20
|
-
for (const statement of ast.body) {
|
|
21
|
-
if (statement.type !== 'ImportDeclaration' || statement.source.value !== 'kay/server')
|
|
22
|
-
continue
|
|
23
|
-
|
|
24
|
-
for (const specifier of statement.specifiers) {
|
|
25
|
-
if (specifier.type === 'ImportSpecifier' && importedName(specifier) === 'api')
|
|
26
|
-
apis.add(specifier.local.name)
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (apis.size === 0)
|
|
31
|
-
continue
|
|
32
|
-
|
|
33
|
-
walk(ast, (node) => {
|
|
34
|
-
if (node.type !== 'CallExpression' || !isWsOfApi(node, apis))
|
|
35
|
-
return
|
|
36
|
-
|
|
37
|
-
const hooks = node.arguments[1]
|
|
38
|
-
|
|
39
|
-
if (hooks?.type !== 'ObjectExpression')
|
|
40
|
-
return
|
|
41
|
-
|
|
42
|
-
for (const property of hooks.properties) {
|
|
43
|
-
if (property.type !== 'Property' || property.computed || property.key.type !== 'Identifier' || !HANDLERS.has(property.key.name))
|
|
44
|
-
continue
|
|
45
|
-
|
|
46
|
-
const handler = property.value
|
|
47
|
-
|
|
48
|
-
if (handler.type !== 'FunctionExpression' && handler.type !== 'ArrowFunctionExpression')
|
|
49
|
-
continue
|
|
50
|
-
|
|
51
|
-
const [first] = handler.params
|
|
52
|
-
|
|
53
|
-
if (first?.type !== 'Identifier')
|
|
54
|
-
continue
|
|
55
|
-
|
|
56
|
-
if (handler.body === null)
|
|
57
|
-
continue
|
|
58
|
-
|
|
59
|
-
walk(handler.body, (inner) => {
|
|
60
|
-
const sent = framed(inner, first.name)
|
|
61
|
-
|
|
62
|
-
if (sent)
|
|
63
|
-
report(base + inner.start, base + inner.end, '`ws.send(JSON.stringify(value))` sends a string holding JSON since 1.105, as every frame is JSON; the old form works until 1.108', 'send the value itself', [{ start: base + sent.start, end: base + sent.end, text: text.slice(sent.argument.start, sent.argument.end) }])
|
|
64
|
-
})
|
|
65
|
-
}
|
|
66
|
-
})
|
|
67
|
-
}
|
|
68
|
-
})
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// A `.ws()` call whose callee chain starts at a call of `api`.
|
|
72
|
-
function isWsOfApi(node: Node & { type: 'CallExpression' }, apis: Set<string>): boolean {
|
|
73
|
-
if (node.callee.type !== 'MemberExpression' || node.callee.computed || node.callee.property.type !== 'Identifier' || node.callee.property.name !== 'ws')
|
|
74
|
-
return false
|
|
75
|
-
|
|
76
|
-
let current: Node = node.callee.object
|
|
77
|
-
|
|
78
|
-
while (current.type === 'CallExpression') {
|
|
79
|
-
if (current.callee.type === 'Identifier')
|
|
80
|
-
return apis.has(current.callee.name)
|
|
81
|
-
|
|
82
|
-
if (current.callee.type !== 'MemberExpression')
|
|
83
|
-
return false
|
|
84
|
-
|
|
85
|
-
current = current.callee.object
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return false
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// `<name>.send(JSON.stringify(argument))` or `<name>.publish(topic, JSON.stringify(argument))`, a compress flag allowed: the whole inner call and the argument.
|
|
92
|
-
function framed(node: Node, name: string): { start: number, end: number, argument: Node } | undefined {
|
|
93
|
-
if (node.type !== 'CallExpression' || node.callee.type !== 'MemberExpression' || node.callee.computed || node.callee.object.type !== 'Identifier' || node.callee.object.name !== name || node.callee.property.type !== 'Identifier' || (node.callee.property.name !== 'send' && node.callee.property.name !== 'publish'))
|
|
94
|
-
return undefined
|
|
95
|
-
|
|
96
|
-
const inner = node.arguments[node.callee.property.name === 'publish' ? 1 : 0]
|
|
97
|
-
|
|
98
|
-
if (inner?.type !== 'CallExpression' || inner.callee.type !== 'MemberExpression' || inner.callee.object.type !== 'Identifier' || inner.callee.object.name !== 'JSON' || inner.callee.property.type !== 'Identifier' || inner.callee.property.name !== 'stringify' || inner.arguments.length !== 1 || inner.arguments[0]!.type === 'SpreadElement')
|
|
99
|
-
return undefined
|
|
100
|
-
|
|
101
|
-
return { start: inner.start, end: inner.end, argument: inner.arguments[0]! }
|
|
102
|
-
}
|