@buenojs/bueno 0.8.10 → 0.8.11
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/cache/index.d.ts +187 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/index.js +595 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/cli/bin.d.ts +8 -0
- package/dist/cli/bin.d.ts.map +1 -0
- package/dist/cli/bin.js +9 -9
- package/dist/cli/bin.js.map +1 -0
- package/dist/cli/commands/add-frontend.d.ts +7 -0
- package/dist/cli/commands/add-frontend.d.ts.map +1 -0
- package/dist/cli/commands/add-frontend.js +376 -0
- package/dist/cli/commands/add-frontend.js.map +1 -0
- package/dist/cli/commands/build.d.ts +7 -0
- package/dist/cli/commands/build.d.ts.map +1 -0
- package/dist/cli/commands/build.js +347 -0
- package/dist/cli/commands/build.js.map +1 -0
- package/dist/cli/commands/dev.d.ts +7 -0
- package/dist/cli/commands/dev.d.ts.map +1 -0
- package/dist/cli/commands/dev.js +205 -0
- package/dist/cli/commands/dev.js.map +1 -0
- package/dist/cli/commands/generate.d.ts +7 -0
- package/dist/cli/commands/generate.d.ts.map +1 -0
- package/dist/cli/commands/generate.js +491 -0
- package/dist/cli/commands/generate.js.map +1 -0
- package/dist/cli/commands/help.d.ts +7 -0
- package/dist/cli/commands/help.d.ts.map +1 -0
- package/dist/cli/commands/help.js +51 -0
- package/dist/cli/commands/help.js.map +1 -0
- package/dist/cli/commands/index.d.ts +59 -0
- package/dist/cli/commands/index.d.ts.map +1 -0
- package/dist/cli/commands/index.js +77 -0
- package/dist/cli/commands/index.js.map +1 -0
- package/dist/cli/commands/migration.d.ts +7 -0
- package/dist/cli/commands/migration.d.ts.map +1 -0
- package/dist/cli/commands/migration.js +295 -0
- package/dist/cli/commands/migration.js.map +1 -0
- package/dist/cli/commands/new.d.ts +7 -0
- package/dist/cli/commands/new.d.ts.map +1 -0
- package/dist/cli/commands/new.js +641 -0
- package/dist/cli/commands/new.js.map +1 -0
- package/dist/cli/commands/start.d.ts +7 -0
- package/dist/cli/commands/start.d.ts.map +1 -0
- package/dist/cli/commands/start.js +171 -0
- package/dist/cli/commands/start.js.map +1 -0
- package/dist/cli/core/args.d.ts +61 -0
- package/dist/cli/core/args.d.ts.map +1 -0
- package/dist/cli/core/args.js +224 -0
- package/dist/cli/core/args.js.map +1 -0
- package/dist/cli/core/console.d.ts +135 -0
- package/dist/cli/core/console.d.ts.map +1 -0
- package/dist/cli/core/console.js +268 -0
- package/dist/cli/core/console.js.map +1 -0
- package/dist/cli/core/index.d.ts +10 -0
- package/dist/cli/core/index.d.ts.map +1 -0
- package/dist/cli/core/index.js +10 -0
- package/dist/cli/core/index.js.map +1 -0
- package/dist/cli/core/prompt.d.ts +63 -0
- package/dist/cli/core/prompt.d.ts.map +1 -0
- package/dist/cli/core/prompt.js +338 -0
- package/dist/cli/core/prompt.js.map +1 -0
- package/dist/cli/core/spinner.d.ts +111 -0
- package/dist/cli/core/spinner.d.ts.map +1 -0
- package/dist/cli/core/spinner.js +208 -0
- package/dist/cli/core/spinner.js.map +1 -0
- package/dist/cli/index.d.ts +47 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +127 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/templates/database/index.d.ts +24 -0
- package/dist/cli/templates/database/index.d.ts.map +1 -0
- package/dist/cli/templates/database/index.js +49 -0
- package/dist/cli/templates/database/index.js.map +1 -0
- package/dist/cli/templates/database/mysql.d.ts +6 -0
- package/dist/cli/templates/database/mysql.d.ts.map +1 -0
- package/dist/cli/templates/database/mysql.js +12 -0
- package/dist/cli/templates/database/mysql.js.map +1 -0
- package/dist/cli/templates/database/none.d.ts +8 -0
- package/dist/cli/templates/database/none.d.ts.map +1 -0
- package/dist/cli/templates/database/none.js +14 -0
- package/dist/cli/templates/database/none.js.map +1 -0
- package/dist/cli/templates/database/postgresql.d.ts +6 -0
- package/dist/cli/templates/database/postgresql.d.ts.map +1 -0
- package/dist/cli/templates/database/postgresql.js +12 -0
- package/dist/cli/templates/database/postgresql.js.map +1 -0
- package/dist/cli/templates/database/sqlite.d.ts +6 -0
- package/dist/cli/templates/database/sqlite.d.ts.map +1 -0
- package/dist/cli/templates/database/sqlite.js +12 -0
- package/dist/cli/templates/database/sqlite.js.map +1 -0
- package/dist/cli/templates/deploy.d.ts +41 -0
- package/dist/cli/templates/deploy.d.ts.map +1 -0
- package/dist/cli/templates/deploy.js +278 -0
- package/dist/cli/templates/deploy.js.map +1 -0
- package/dist/cli/templates/docker.d.ts +30 -0
- package/dist/cli/templates/docker.d.ts.map +1 -0
- package/dist/cli/templates/docker.js +298 -0
- package/dist/cli/templates/docker.js.map +1 -0
- package/dist/cli/templates/frontend/index.d.ts +25 -0
- package/dist/cli/templates/frontend/index.d.ts.map +1 -0
- package/dist/cli/templates/frontend/index.js +40 -0
- package/dist/cli/templates/frontend/index.js.map +1 -0
- package/dist/cli/templates/frontend/none.d.ts +8 -0
- package/dist/cli/templates/frontend/none.d.ts.map +1 -0
- package/dist/cli/templates/frontend/none.js +15 -0
- package/dist/cli/templates/frontend/none.js.map +1 -0
- package/dist/cli/templates/frontend/react.d.ts +6 -0
- package/dist/cli/templates/frontend/react.d.ts.map +1 -0
- package/dist/cli/templates/frontend/react.js +139 -0
- package/dist/cli/templates/frontend/react.js.map +1 -0
- package/dist/cli/templates/frontend/solid.d.ts +6 -0
- package/dist/cli/templates/frontend/solid.d.ts.map +1 -0
- package/dist/cli/templates/frontend/solid.js +133 -0
- package/dist/cli/templates/frontend/solid.js.map +1 -0
- package/dist/cli/templates/frontend/svelte.d.ts +6 -0
- package/dist/cli/templates/frontend/svelte.d.ts.map +1 -0
- package/dist/cli/templates/frontend/svelte.js +130 -0
- package/dist/cli/templates/frontend/svelte.js.map +1 -0
- package/dist/cli/templates/frontend/vue.d.ts +6 -0
- package/dist/cli/templates/frontend/vue.d.ts.map +1 -0
- package/dist/cli/templates/frontend/vue.js +129 -0
- package/dist/cli/templates/frontend/vue.js.map +1 -0
- package/dist/cli/templates/generators/index.d.ts +29 -0
- package/dist/cli/templates/generators/index.d.ts.map +1 -0
- package/dist/cli/templates/generators/index.js +308 -0
- package/dist/cli/templates/generators/index.js.map +1 -0
- package/dist/cli/templates/generators/types.d.ts +32 -0
- package/dist/cli/templates/generators/types.d.ts.map +1 -0
- package/dist/cli/templates/generators/types.js +21 -0
- package/dist/cli/templates/generators/types.js.map +1 -0
- package/dist/cli/templates/index.d.ts +12 -0
- package/dist/cli/templates/index.d.ts.map +1 -0
- package/dist/cli/templates/index.js +18 -0
- package/dist/cli/templates/index.js.map +1 -0
- package/dist/cli/templates/project/api.d.ts +6 -0
- package/dist/cli/templates/project/api.d.ts.map +1 -0
- package/dist/cli/templates/project/api.js +79 -0
- package/dist/cli/templates/project/api.js.map +1 -0
- package/dist/cli/templates/project/default.d.ts +6 -0
- package/dist/cli/templates/project/default.d.ts.map +1 -0
- package/dist/cli/templates/project/default.js +136 -0
- package/dist/cli/templates/project/default.js.map +1 -0
- package/dist/cli/templates/project/fullstack.d.ts +14 -0
- package/dist/cli/templates/project/fullstack.d.ts.map +1 -0
- package/dist/cli/templates/project/fullstack.js +19 -0
- package/dist/cli/templates/project/fullstack.js.map +1 -0
- package/dist/cli/templates/project/index.d.ts +26 -0
- package/dist/cli/templates/project/index.d.ts.map +1 -0
- package/dist/cli/templates/project/index.js +60 -0
- package/dist/cli/templates/project/index.js.map +1 -0
- package/dist/cli/templates/project/minimal.d.ts +6 -0
- package/dist/cli/templates/project/minimal.d.ts.map +1 -0
- package/dist/cli/templates/project/minimal.js +43 -0
- package/dist/cli/templates/project/minimal.js.map +1 -0
- package/dist/cli/templates/project/types.d.ts +80 -0
- package/dist/cli/templates/project/types.d.ts.map +1 -0
- package/dist/cli/templates/project/types.js +7 -0
- package/dist/cli/templates/project/types.js.map +1 -0
- package/dist/cli/templates/project/website.d.ts +8 -0
- package/dist/cli/templates/project/website.d.ts.map +1 -0
- package/dist/cli/templates/project/website.js +312 -0
- package/dist/cli/templates/project/website.js.map +1 -0
- package/dist/cli/utils/fs.d.ts +137 -0
- package/dist/cli/utils/fs.d.ts.map +1 -0
- package/dist/cli/utils/fs.js +350 -0
- package/dist/cli/utils/fs.js.map +1 -0
- package/dist/cli/utils/index.d.ts +9 -0
- package/dist/cli/utils/index.d.ts.map +1 -0
- package/dist/cli/utils/index.js +9 -0
- package/dist/cli/utils/index.js.map +1 -0
- package/dist/cli/utils/strings.d.ts +86 -0
- package/dist/cli/utils/strings.d.ts.map +1 -0
- package/dist/cli/utils/strings.js +190 -0
- package/dist/cli/utils/strings.js.map +1 -0
- package/dist/cli/utils/version.d.ts +15 -0
- package/dist/cli/utils/version.d.ts.map +1 -0
- package/dist/cli/utils/version.js +38 -0
- package/dist/cli/utils/version.js.map +1 -0
- package/dist/config/env-validation.d.ts +49 -0
- package/dist/config/env-validation.d.ts.map +1 -0
- package/dist/config/env-validation.js +77 -0
- package/dist/config/env-validation.js.map +1 -0
- package/dist/config/env.d.ts +167 -0
- package/dist/config/env.d.ts.map +1 -0
- package/dist/config/env.js +392 -0
- package/dist/config/env.js.map +1 -0
- package/dist/config/index.d.ts +168 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +329 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/loader.d.ts +81 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +242 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/merge.d.ts +66 -0
- package/dist/config/merge.d.ts.map +1 -0
- package/dist/config/merge.js +226 -0
- package/dist/config/merge.js.map +1 -0
- package/dist/config/types.d.ts +322 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +443 -0
- package/dist/config/types.js.map +1 -0
- package/dist/config/validation.d.ts +100 -0
- package/dist/config/validation.d.ts.map +1 -0
- package/dist/config/validation.js +548 -0
- package/dist/config/validation.js.map +1 -0
- package/dist/container/forward-ref.d.ts +116 -0
- package/dist/container/forward-ref.d.ts.map +1 -0
- package/dist/container/forward-ref.js +105 -0
- package/dist/container/forward-ref.js.map +1 -0
- package/dist/container/index.d.ts +95 -0
- package/dist/container/index.d.ts.map +1 -0
- package/dist/container/index.js.map +1 -0
- package/dist/context/index.d.ts +143 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js.map +1 -0
- package/dist/database/index.d.ts +219 -0
- package/dist/database/index.d.ts.map +1 -0
- package/dist/database/index.js.map +1 -0
- package/dist/database/migrations/index.d.ts +151 -0
- package/dist/database/migrations/index.d.ts.map +1 -0
- package/dist/database/migrations/index.js +258 -0
- package/dist/database/migrations/index.js.map +1 -0
- package/dist/database/orm/builder.d.ts +122 -0
- package/dist/database/orm/builder.d.ts.map +1 -0
- package/dist/database/orm/builder.js +355 -0
- package/dist/database/orm/builder.js.map +1 -0
- package/dist/database/orm/casts/index.d.ts +16 -0
- package/dist/database/orm/casts/index.d.ts.map +1 -0
- package/dist/database/orm/casts/index.js +131 -0
- package/dist/database/orm/casts/index.js.map +1 -0
- package/dist/database/orm/casts/types.d.ts +16 -0
- package/dist/database/orm/casts/types.d.ts.map +1 -0
- package/dist/database/orm/casts/types.js +5 -0
- package/dist/database/orm/casts/types.js.map +1 -0
- package/dist/database/orm/compiler.d.ts +90 -0
- package/dist/database/orm/compiler.d.ts.map +1 -0
- package/dist/database/orm/compiler.js +218 -0
- package/dist/database/orm/compiler.js.map +1 -0
- package/dist/database/orm/hooks/index.d.ts +53 -0
- package/dist/database/orm/hooks/index.d.ts.map +1 -0
- package/dist/database/orm/hooks/index.js +81 -0
- package/dist/database/orm/hooks/index.js.map +1 -0
- package/dist/database/orm/index.d.ts +21 -0
- package/dist/database/orm/index.d.ts.map +1 -0
- package/dist/database/orm/index.js +23 -0
- package/dist/database/orm/index.js.map +1 -0
- package/dist/database/orm/model-registry.d.ts +33 -0
- package/dist/database/orm/model-registry.d.ts.map +1 -0
- package/dist/database/orm/model-registry.js +49 -0
- package/dist/database/orm/model-registry.js.map +1 -0
- package/dist/database/orm/model.d.ts +245 -0
- package/dist/database/orm/model.d.ts.map +1 -0
- package/dist/database/orm/model.js +599 -0
- package/dist/database/orm/model.js.map +1 -0
- package/dist/database/orm/relationships/base.d.ts +69 -0
- package/dist/database/orm/relationships/base.d.ts.map +1 -0
- package/dist/database/orm/relationships/base.js +84 -0
- package/dist/database/orm/relationships/base.js.map +1 -0
- package/dist/database/orm/relationships/belongs-to-many.d.ts +47 -0
- package/dist/database/orm/relationships/belongs-to-many.d.ts.map +1 -0
- package/dist/database/orm/relationships/belongs-to-many.js +136 -0
- package/dist/database/orm/relationships/belongs-to-many.js.map +1 -0
- package/dist/database/orm/relationships/belongs-to.d.ts +17 -0
- package/dist/database/orm/relationships/belongs-to.d.ts.map +1 -0
- package/dist/database/orm/relationships/belongs-to.js +38 -0
- package/dist/database/orm/relationships/belongs-to.js.map +1 -0
- package/dist/database/orm/relationships/has-many.d.ts +14 -0
- package/dist/database/orm/relationships/has-many.d.ts.map +1 -0
- package/dist/database/orm/relationships/has-many.js +35 -0
- package/dist/database/orm/relationships/has-many.js.map +1 -0
- package/dist/database/orm/relationships/has-one.d.ts +14 -0
- package/dist/database/orm/relationships/has-one.d.ts.map +1 -0
- package/dist/database/orm/relationships/has-one.js +32 -0
- package/dist/database/orm/relationships/has-one.js.map +1 -0
- package/dist/database/orm/relationships/index.d.ts +10 -0
- package/dist/database/orm/relationships/index.d.ts.map +1 -0
- package/dist/database/orm/relationships/index.js +9 -0
- package/dist/database/orm/relationships/index.js.map +1 -0
- package/dist/database/orm/scopes/index.d.ts +36 -0
- package/dist/database/orm/scopes/index.d.ts.map +1 -0
- package/dist/database/orm/scopes/index.js +47 -0
- package/dist/database/orm/scopes/index.js.map +1 -0
- package/dist/database/schema/index.d.ts +155 -0
- package/dist/database/schema/index.d.ts.map +1 -0
- package/dist/database/schema/index.js +401 -0
- package/dist/database/schema/index.js.map +1 -0
- package/dist/frontend/api-routes.d.ts +189 -0
- package/dist/frontend/api-routes.d.ts.map +1 -0
- package/dist/frontend/api-routes.js +548 -0
- package/dist/frontend/api-routes.js.map +1 -0
- package/dist/frontend/bundler.d.ts +99 -0
- package/dist/frontend/bundler.d.ts.map +1 -0
- package/dist/frontend/bundler.js +555 -0
- package/dist/frontend/bundler.js.map +1 -0
- package/dist/frontend/console-client.d.ts +11 -0
- package/dist/frontend/console-client.d.ts.map +1 -0
- package/dist/frontend/console-client.js +414 -0
- package/dist/frontend/console-client.js.map +1 -0
- package/dist/frontend/console-stream.d.ts +138 -0
- package/dist/frontend/console-stream.d.ts.map +1 -0
- package/dist/frontend/console-stream.js +535 -0
- package/dist/frontend/console-stream.js.map +1 -0
- package/dist/frontend/dev-server.d.ts +174 -0
- package/dist/frontend/dev-server.d.ts.map +1 -0
- package/dist/frontend/dev-server.js +735 -0
- package/dist/frontend/dev-server.js.map +1 -0
- package/dist/frontend/file-router.d.ts +170 -0
- package/dist/frontend/file-router.d.ts.map +1 -0
- package/dist/frontend/file-router.js +531 -0
- package/dist/frontend/file-router.js.map +1 -0
- package/dist/frontend/frameworks/index.d.ts +41 -0
- package/dist/frontend/frameworks/index.d.ts.map +1 -0
- package/dist/frontend/frameworks/index.js +87 -0
- package/dist/frontend/frameworks/index.js.map +1 -0
- package/dist/frontend/frameworks/react.d.ts +32 -0
- package/dist/frontend/frameworks/react.d.ts.map +1 -0
- package/dist/frontend/frameworks/react.js +66 -0
- package/dist/frontend/frameworks/react.js.map +1 -0
- package/dist/frontend/frameworks/solid.d.ts +42 -0
- package/dist/frontend/frameworks/solid.d.ts.map +1 -0
- package/dist/frontend/frameworks/solid.js +84 -0
- package/dist/frontend/frameworks/solid.js.map +1 -0
- package/dist/frontend/frameworks/svelte.d.ts +57 -0
- package/dist/frontend/frameworks/svelte.d.ts.map +1 -0
- package/dist/frontend/frameworks/svelte.js +90 -0
- package/dist/frontend/frameworks/svelte.js.map +1 -0
- package/dist/frontend/frameworks/vue.d.ts +36 -0
- package/dist/frontend/frameworks/vue.d.ts.map +1 -0
- package/dist/frontend/frameworks/vue.js +72 -0
- package/dist/frontend/frameworks/vue.js.map +1 -0
- package/dist/frontend/hmr-client.d.ts +22 -0
- package/dist/frontend/hmr-client.d.ts.map +1 -0
- package/dist/frontend/hmr-client.js +654 -0
- package/dist/frontend/hmr-client.js.map +1 -0
- package/dist/frontend/hmr.d.ts +185 -0
- package/dist/frontend/hmr.d.ts.map +1 -0
- package/dist/frontend/hmr.js +619 -0
- package/dist/frontend/hmr.js.map +1 -0
- package/dist/frontend/index.d.ts +34 -0
- package/dist/frontend/index.d.ts.map +1 -0
- package/dist/frontend/index.js.map +1 -0
- package/dist/frontend/islands.d.ts +135 -0
- package/dist/frontend/islands.d.ts.map +1 -0
- package/dist/frontend/islands.js +455 -0
- package/dist/frontend/islands.js.map +1 -0
- package/dist/frontend/isr.d.ts +143 -0
- package/dist/frontend/isr.d.ts.map +1 -0
- package/dist/frontend/isr.js +440 -0
- package/dist/frontend/isr.js.map +1 -0
- package/dist/frontend/layout.d.ts +140 -0
- package/dist/frontend/layout.d.ts.map +1 -0
- package/dist/frontend/layout.js +392 -0
- package/dist/frontend/layout.js.map +1 -0
- package/dist/frontend/ssr/react.d.ts +118 -0
- package/dist/frontend/ssr/react.d.ts.map +1 -0
- package/dist/frontend/ssr/react.js +373 -0
- package/dist/frontend/ssr/react.js.map +1 -0
- package/dist/frontend/ssr/solid.d.ts +141 -0
- package/dist/frontend/ssr/solid.d.ts.map +1 -0
- package/dist/frontend/ssr/solid.js +440 -0
- package/dist/frontend/ssr/solid.js.map +1 -0
- package/dist/frontend/ssr/svelte.d.ts +158 -0
- package/dist/frontend/ssr/svelte.d.ts.map +1 -0
- package/dist/frontend/ssr/svelte.js +439 -0
- package/dist/frontend/ssr/svelte.js.map +1 -0
- package/dist/frontend/ssr/vue.d.ts +161 -0
- package/dist/frontend/ssr/vue.d.ts.map +1 -0
- package/dist/frontend/ssr/vue.js +385 -0
- package/dist/frontend/ssr/vue.js.map +1 -0
- package/dist/frontend/ssr.d.ts +147 -0
- package/dist/frontend/ssr.d.ts.map +1 -0
- package/dist/frontend/ssr.js +609 -0
- package/dist/frontend/ssr.js.map +1 -0
- package/dist/frontend/types.d.ts +1902 -0
- package/dist/frontend/types.d.ts.map +1 -0
- package/dist/frontend/types.js +8 -0
- package/dist/frontend/types.js.map +1 -0
- package/dist/graphql/built-in-engine.d.ts +36 -0
- package/dist/graphql/built-in-engine.d.ts.map +1 -0
- package/dist/graphql/built-in-engine.js +443 -0
- package/dist/graphql/built-in-engine.js.map +1 -0
- package/dist/graphql/context-builder.d.ts +44 -0
- package/dist/graphql/context-builder.d.ts.map +1 -0
- package/dist/graphql/context-builder.js +91 -0
- package/dist/graphql/context-builder.js.map +1 -0
- package/dist/graphql/decorators.d.ts +162 -0
- package/dist/graphql/decorators.d.ts.map +1 -0
- package/dist/graphql/decorators.js +291 -0
- package/dist/graphql/decorators.js.map +1 -0
- package/dist/graphql/execution-pipeline.d.ts +67 -0
- package/dist/graphql/execution-pipeline.d.ts.map +1 -0
- package/dist/graphql/execution-pipeline.js +127 -0
- package/dist/graphql/execution-pipeline.js.map +1 -0
- package/dist/graphql/graphql-module.d.ts +70 -0
- package/dist/graphql/graphql-module.d.ts.map +1 -0
- package/dist/graphql/graphql-module.js +442 -0
- package/dist/graphql/graphql-module.js.map +1 -0
- package/dist/graphql/index.d.ts +48 -0
- package/dist/graphql/index.d.ts.map +1 -0
- package/dist/graphql/index.js.map +1 -0
- package/dist/graphql/metadata.d.ts +37 -0
- package/dist/graphql/metadata.d.ts.map +1 -0
- package/dist/graphql/metadata.js +130 -0
- package/dist/graphql/metadata.js.map +1 -0
- package/dist/graphql/schema-builder.d.ts +34 -0
- package/dist/graphql/schema-builder.d.ts.map +1 -0
- package/dist/graphql/schema-builder.js +251 -0
- package/dist/graphql/schema-builder.js.map +1 -0
- package/dist/graphql/subscription-handler.d.ts +47 -0
- package/dist/graphql/subscription-handler.d.ts.map +1 -0
- package/dist/graphql/subscription-handler.js +201 -0
- package/dist/graphql/subscription-handler.js.map +1 -0
- package/dist/graphql/types.d.ts +252 -0
- package/dist/graphql/types.d.ts.map +1 -0
- package/dist/graphql/types.js +28 -0
- package/dist/graphql/types.js.map +1 -0
- package/dist/health/index.d.ts +176 -0
- package/dist/health/index.d.ts.map +1 -0
- package/dist/health/index.js.map +1 -0
- package/dist/i18n/engine.d.ts +105 -0
- package/dist/i18n/engine.d.ts.map +1 -0
- package/dist/i18n/engine.js +248 -0
- package/dist/i18n/engine.js.map +1 -0
- package/dist/i18n/index.d.ts +13 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n/loader.d.ts +79 -0
- package/dist/i18n/loader.d.ts.map +1 -0
- package/dist/i18n/loader.js +192 -0
- package/dist/i18n/loader.js.map +1 -0
- package/dist/i18n/middleware.d.ts +96 -0
- package/dist/i18n/middleware.d.ts.map +1 -0
- package/dist/i18n/middleware.js +126 -0
- package/dist/i18n/middleware.js.map +1 -0
- package/dist/i18n/negotiator.d.ts +84 -0
- package/dist/i18n/negotiator.d.ts.map +1 -0
- package/dist/i18n/negotiator.js +139 -0
- package/dist/i18n/negotiator.js.map +1 -0
- package/dist/i18n/types.d.ts +129 -0
- package/dist/i18n/types.d.ts.map +1 -0
- package/dist/i18n/types.js +8 -0
- package/dist/i18n/types.js.map +1 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js.map +1 -0
- package/dist/jobs/drivers/memory.d.ts +38 -0
- package/dist/jobs/drivers/memory.d.ts.map +1 -0
- package/dist/jobs/drivers/memory.js +246 -0
- package/dist/jobs/drivers/memory.js.map +1 -0
- package/dist/jobs/drivers/redis.d.ts +34 -0
- package/dist/jobs/drivers/redis.d.ts.map +1 -0
- package/dist/jobs/drivers/redis.js +355 -0
- package/dist/jobs/drivers/redis.js.map +1 -0
- package/dist/jobs/index.d.ts +12 -0
- package/dist/jobs/index.d.ts.map +1 -0
- package/dist/jobs/index.js.map +1 -0
- package/dist/jobs/queue.d.ts +93 -0
- package/dist/jobs/queue.d.ts.map +1 -0
- package/dist/jobs/queue.js +233 -0
- package/dist/jobs/queue.js.map +1 -0
- package/dist/jobs/types.d.ts +193 -0
- package/dist/jobs/types.d.ts.map +1 -0
- package/dist/jobs/types.js +8 -0
- package/dist/jobs/types.js.map +1 -0
- package/dist/jobs/worker.d.ts +91 -0
- package/dist/jobs/worker.d.ts.map +1 -0
- package/dist/jobs/worker.js +300 -0
- package/dist/jobs/worker.js.map +1 -0
- package/dist/lock/index.d.ts +141 -0
- package/dist/lock/index.d.ts.map +1 -0
- package/dist/lock/index.js.map +1 -0
- package/dist/logger/index.d.ts +156 -0
- package/dist/logger/index.d.ts.map +1 -0
- package/dist/logger/index.js.map +1 -0
- package/dist/logger/transports/index.d.ts +371 -0
- package/dist/logger/transports/index.d.ts.map +1 -0
- package/dist/logger/transports/index.js +740 -0
- package/dist/logger/transports/index.js.map +1 -0
- package/dist/metrics/index.d.ts +163 -0
- package/dist/metrics/index.d.ts.map +1 -0
- package/dist/metrics/index.js.map +1 -0
- package/dist/middleware/built-in.d.ts +50 -0
- package/dist/middleware/built-in.d.ts.map +1 -0
- package/dist/middleware/built-in.js +220 -0
- package/dist/middleware/built-in.js.map +1 -0
- package/dist/middleware/index.d.ts +40 -0
- package/dist/middleware/index.d.ts.map +1 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/migrations/index.d.ts +48 -0
- package/dist/migrations/index.d.ts.map +1 -0
- package/dist/migrations/index.js +3 -0
- package/dist/migrations/index.js.map +1 -0
- package/dist/modules/filters.d.ts +150 -0
- package/dist/modules/filters.d.ts.map +1 -0
- package/dist/modules/filters.js +338 -0
- package/dist/modules/filters.js.map +1 -0
- package/dist/modules/guards.d.ts +188 -0
- package/dist/modules/guards.d.ts.map +1 -0
- package/dist/modules/guards.js +278 -0
- package/dist/modules/guards.js.map +1 -0
- package/dist/modules/index.d.ts +266 -0
- package/dist/modules/index.d.ts.map +1 -0
- package/dist/modules/index.js.map +1 -0
- package/dist/modules/interceptors.d.ts +242 -0
- package/dist/modules/interceptors.d.ts.map +1 -0
- package/dist/modules/interceptors.js +407 -0
- package/dist/modules/interceptors.js.map +1 -0
- package/dist/modules/lazy.d.ts +187 -0
- package/dist/modules/lazy.d.ts.map +1 -0
- package/dist/modules/lazy.js +305 -0
- package/dist/modules/lazy.js.map +1 -0
- package/dist/modules/lifecycle.d.ts +221 -0
- package/dist/modules/lifecycle.d.ts.map +1 -0
- package/dist/modules/lifecycle.js +314 -0
- package/dist/modules/lifecycle.js.map +1 -0
- package/dist/modules/metadata.d.ts +32 -0
- package/dist/modules/metadata.d.ts.map +1 -0
- package/dist/modules/metadata.js +59 -0
- package/dist/modules/metadata.js.map +1 -0
- package/dist/modules/pipes.d.ts +287 -0
- package/dist/modules/pipes.d.ts.map +1 -0
- package/dist/modules/pipes.js +443 -0
- package/dist/modules/pipes.js.map +1 -0
- package/dist/notification/channels/base.d.ts +32 -0
- package/dist/notification/channels/base.d.ts.map +1 -0
- package/dist/notification/channels/base.js +37 -0
- package/dist/notification/channels/base.js.map +1 -0
- package/dist/notification/channels/email.d.ts +37 -0
- package/dist/notification/channels/email.d.ts.map +1 -0
- package/dist/notification/channels/email.js +85 -0
- package/dist/notification/channels/email.js.map +1 -0
- package/dist/notification/channels/push.d.ts +37 -0
- package/dist/notification/channels/push.d.ts.map +1 -0
- package/dist/notification/channels/push.js +84 -0
- package/dist/notification/channels/push.js.map +1 -0
- package/dist/notification/channels/sms.d.ts +37 -0
- package/dist/notification/channels/sms.d.ts.map +1 -0
- package/dist/notification/channels/sms.js +83 -0
- package/dist/notification/channels/sms.js.map +1 -0
- package/dist/notification/channels/whatsapp.d.ts +37 -0
- package/dist/notification/channels/whatsapp.d.ts.map +1 -0
- package/dist/notification/channels/whatsapp.js +81 -0
- package/dist/notification/channels/whatsapp.js.map +1 -0
- package/dist/notification/index.d.ts +15 -0
- package/dist/notification/index.d.ts.map +1 -0
- package/dist/notification/index.js.map +1 -0
- package/dist/notification/service.d.ts +100 -0
- package/dist/notification/service.d.ts.map +1 -0
- package/dist/notification/service.js +279 -0
- package/dist/notification/service.js.map +1 -0
- package/dist/notification/types.d.ts +253 -0
- package/dist/notification/types.d.ts.map +1 -0
- package/dist/notification/types.js +14 -0
- package/dist/notification/types.js.map +1 -0
- package/dist/observability/__tests__/observability.test.d.ts +2 -0
- package/dist/observability/__tests__/observability.test.d.ts.map +1 -0
- package/dist/observability/__tests__/observability.test.js +404 -0
- package/dist/observability/__tests__/observability.test.js.map +1 -0
- package/dist/observability/breadcrumbs.d.ts +48 -0
- package/dist/observability/breadcrumbs.d.ts.map +1 -0
- package/dist/observability/breadcrumbs.js +97 -0
- package/dist/observability/breadcrumbs.js.map +1 -0
- package/dist/observability/index.d.ts +95 -0
- package/dist/observability/index.d.ts.map +1 -0
- package/dist/observability/index.js.map +1 -0
- package/dist/observability/interceptor.d.ts +19 -0
- package/dist/observability/interceptor.d.ts.map +1 -0
- package/dist/observability/interceptor.js +67 -0
- package/dist/observability/interceptor.js.map +1 -0
- package/dist/observability/service.d.ts +101 -0
- package/dist/observability/service.d.ts.map +1 -0
- package/dist/observability/service.js +249 -0
- package/dist/observability/service.js.map +1 -0
- package/dist/observability/trace.d.ts +21 -0
- package/dist/observability/trace.d.ts.map +1 -0
- package/dist/observability/trace.js +35 -0
- package/dist/observability/trace.js.map +1 -0
- package/dist/observability/types.d.ts +172 -0
- package/dist/observability/types.d.ts.map +1 -0
- package/dist/observability/types.js +8 -0
- package/dist/observability/types.js.map +1 -0
- package/dist/openapi/decorators.d.ts +173 -0
- package/dist/openapi/decorators.d.ts.map +1 -0
- package/dist/openapi/decorators.js +276 -0
- package/dist/openapi/decorators.js.map +1 -0
- package/dist/openapi/document-builder.d.ts +82 -0
- package/dist/openapi/document-builder.d.ts.map +1 -0
- package/dist/openapi/document-builder.js +228 -0
- package/dist/openapi/document-builder.js.map +1 -0
- package/dist/openapi/index.d.ts +48 -0
- package/dist/openapi/index.d.ts.map +1 -0
- package/dist/openapi/index.js.map +1 -0
- package/dist/openapi/metadata.d.ts +36 -0
- package/dist/openapi/metadata.d.ts.map +1 -0
- package/dist/openapi/metadata.js +78 -0
- package/dist/openapi/metadata.js.map +1 -0
- package/dist/openapi/route-scanner.d.ts +34 -0
- package/dist/openapi/route-scanner.d.ts.map +1 -0
- package/dist/openapi/route-scanner.js +174 -0
- package/dist/openapi/route-scanner.js.map +1 -0
- package/dist/openapi/schema-generator.d.ts +53 -0
- package/dist/openapi/schema-generator.d.ts.map +1 -0
- package/dist/openapi/schema-generator.js +236 -0
- package/dist/openapi/schema-generator.js.map +1 -0
- package/dist/openapi/swagger-module.d.ts +57 -0
- package/dist/openapi/swagger-module.d.ts.map +1 -0
- package/dist/openapi/swagger-module.js +143 -0
- package/dist/openapi/swagger-module.js.map +1 -0
- package/dist/openapi/types.d.ts +344 -0
- package/dist/openapi/types.d.ts.map +1 -0
- package/dist/openapi/types.js +7 -0
- package/dist/openapi/types.js.map +1 -0
- package/dist/orm/index.d.ts +10 -0
- package/dist/orm/index.d.ts.map +1 -0
- package/dist/orm/index.js.map +1 -0
- package/dist/router/index.d.ts +73 -0
- package/dist/router/index.d.ts.map +1 -0
- package/dist/router/index.js.map +1 -0
- package/dist/router/linear.d.ts +54 -0
- package/dist/router/linear.d.ts.map +1 -0
- package/dist/router/linear.js +261 -0
- package/dist/router/linear.js.map +1 -0
- package/dist/router/regex.d.ts +49 -0
- package/dist/router/regex.d.ts.map +1 -0
- package/dist/router/regex.js +201 -0
- package/dist/router/regex.js.map +1 -0
- package/dist/router/tree.d.ts +112 -0
- package/dist/router/tree.d.ts.map +1 -0
- package/dist/router/tree.js +360 -0
- package/dist/router/tree.js.map +1 -0
- package/dist/rpc/index.d.ts +321 -0
- package/dist/rpc/index.d.ts.map +1 -0
- package/dist/rpc/index.js.map +1 -0
- package/dist/schema/index.d.ts +10 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/security/index.d.ts +126 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/index.js +309 -0
- package/dist/security/index.js.map +1 -0
- package/dist/ssg/index.d.ts +73 -0
- package/dist/ssg/index.d.ts.map +1 -0
- package/dist/ssg/index.js +464 -0
- package/dist/ssg/index.js.map +1 -0
- package/dist/storage/index.d.ts +99 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +338 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/telemetry/index.d.ts +376 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js.map +1 -0
- package/dist/template/index.d.ts +7 -0
- package/dist/template/index.d.ts.map +1 -0
- package/dist/template/index.js.map +1 -0
- package/dist/templates/engine.d.ts +60 -0
- package/dist/templates/engine.d.ts.map +1 -0
- package/dist/templates/engine.js +177 -0
- package/dist/templates/engine.js.map +1 -0
- package/dist/templates/index.d.ts +9 -0
- package/dist/templates/index.d.ts.map +1 -0
- package/dist/templates/index.js.map +1 -0
- package/dist/templates/loader.d.ts +45 -0
- package/dist/templates/loader.d.ts.map +1 -0
- package/dist/templates/loader.js +274 -0
- package/dist/templates/loader.js.map +1 -0
- package/dist/templates/renderers/markdown.d.ts +46 -0
- package/dist/templates/renderers/markdown.d.ts.map +1 -0
- package/dist/templates/renderers/markdown.js +181 -0
- package/dist/templates/renderers/markdown.js.map +1 -0
- package/dist/templates/renderers/simple.d.ts +35 -0
- package/dist/templates/renderers/simple.d.ts.map +1 -0
- package/dist/templates/renderers/simple.js +245 -0
- package/dist/templates/renderers/simple.js.map +1 -0
- package/dist/templates/types.d.ts +138 -0
- package/dist/templates/types.d.ts.map +1 -0
- package/dist/templates/types.js +8 -0
- package/dist/templates/types.js.map +1 -0
- package/dist/testing/index.d.ts +539 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/types/index.d.ts +116 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js.map +1 -0
- package/dist/validation/index.d.ts +89 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +276 -0
- package/dist/validation/index.js.map +1 -0
- package/dist/validation/schemas.d.ts +283 -0
- package/dist/validation/schemas.d.ts.map +1 -0
- package/dist/validation/schemas.js +407 -0
- package/dist/validation/schemas.js.map +1 -0
- package/dist/websocket/index.d.ts +252 -0
- package/dist/websocket/index.d.ts.map +1 -0
- package/dist/websocket/index.js +749 -0
- package/dist/websocket/index.js.map +1 -0
- package/package.json +3 -3
- package/src/database/migrations/index.ts +8 -0
- package/src/migrations/index.ts +40 -1
- package/src/types/index.ts +1 -1
- package/tsconfig.json +2 -6
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exception Filters System
|
|
3
|
+
*
|
|
4
|
+
* Filters catch exceptions thrown during request processing and transform
|
|
5
|
+
* them into appropriate responses. They act as error boundaries in the
|
|
6
|
+
* request pipeline.
|
|
7
|
+
*
|
|
8
|
+
* Execution Order:
|
|
9
|
+
* Incoming Request → Guards → Pipes → Handler → Filters (if error) → Error Response
|
|
10
|
+
*/
|
|
11
|
+
import type { Context } from "../context";
|
|
12
|
+
import type { Token } from "../types";
|
|
13
|
+
import { BuenoError, NotFoundError, ValidationError } from "../types";
|
|
14
|
+
/**
|
|
15
|
+
* Exception filter interface
|
|
16
|
+
* Filters implement this interface to handle specific exception types
|
|
17
|
+
*/
|
|
18
|
+
export interface ExceptionFilter<T = Error> {
|
|
19
|
+
catch(exception: T, context: Context): Response | Promise<Response>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Filter function type for functional filters
|
|
23
|
+
*/
|
|
24
|
+
export type FilterFn<T = Error> = (exception: T, context: Context) => Response | Promise<Response>;
|
|
25
|
+
/**
|
|
26
|
+
* Filter type - can be a token, instance, or function
|
|
27
|
+
*/
|
|
28
|
+
export type Filter<T = Error> = Token<ExceptionFilter<T>> | ExceptionFilter<T> | FilterFn<T>;
|
|
29
|
+
type Constructor = new (...args: unknown[]) => unknown;
|
|
30
|
+
/**
|
|
31
|
+
* Decorator to apply filters to a controller class or method
|
|
32
|
+
* Filters are executed in order: global → class → method
|
|
33
|
+
*
|
|
34
|
+
* @param filters - Filters to apply
|
|
35
|
+
* @returns ClassDecorator & MethodDecorator
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* @Controller('users')
|
|
40
|
+
* @UseFilters(CustomExceptionFilter) // Applied to all methods
|
|
41
|
+
* class UsersController {
|
|
42
|
+
* @Get(':id')
|
|
43
|
+
* @UseFilters(NotFoundExceptionFilter) // Additional filter for this method
|
|
44
|
+
* getUser() {}
|
|
45
|
+
* }
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare function UseFilters(...filters: Filter[]): MethodDecorator & ClassDecorator;
|
|
49
|
+
/**
|
|
50
|
+
* Decorator to mark a filter as catching a specific exception type
|
|
51
|
+
*
|
|
52
|
+
* @param exceptionType - The exception class to catch
|
|
53
|
+
* @returns ClassDecorator
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* @Catch(ValidationError)
|
|
58
|
+
* @Injectable()
|
|
59
|
+
* class CustomValidationFilter implements ExceptionFilter<ValidationError> {
|
|
60
|
+
* catch(exception: ValidationError, context: Context): Response {
|
|
61
|
+
* return context.status(422).json({
|
|
62
|
+
* error: 'Validation Failed',
|
|
63
|
+
* issues: exception.issues
|
|
64
|
+
* });
|
|
65
|
+
* }
|
|
66
|
+
* }
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare function Catch<T extends Error>(exceptionType: new (...args: never[]) => T): ClassDecorator;
|
|
70
|
+
/**
|
|
71
|
+
* Get class-level filters from a controller
|
|
72
|
+
*/
|
|
73
|
+
export declare function getClassFilters(target: Constructor): Filter[] | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* Get method-level filters from a controller method
|
|
76
|
+
*/
|
|
77
|
+
export declare function getMethodFilters(target: object, propertyKey: string | symbol): Filter[] | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* Get the exception type that a filter catches
|
|
80
|
+
*/
|
|
81
|
+
export declare function getCatchType(filter: Filter): (new (...args: unknown[]) => Error) | undefined;
|
|
82
|
+
/**
|
|
83
|
+
* Check if a filter can handle a specific exception
|
|
84
|
+
*/
|
|
85
|
+
export declare function canHandleException(filter: Filter, exception: Error): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Type guard to check if a value is an ExceptionFilter instance
|
|
88
|
+
*/
|
|
89
|
+
export declare function isExceptionFilter(value: unknown): value is ExceptionFilter;
|
|
90
|
+
/**
|
|
91
|
+
* Type guard to check if a value is a FilterFn
|
|
92
|
+
*/
|
|
93
|
+
export declare function isFilterFn(value: unknown): value is FilterFn;
|
|
94
|
+
/**
|
|
95
|
+
* Execute a filter and return the response
|
|
96
|
+
*/
|
|
97
|
+
export declare function executeFilter(filter: Filter, exception: Error, context: Context, resolveFilter?: (filter: Filter) => ExceptionFilter | null): Promise<Response>;
|
|
98
|
+
/**
|
|
99
|
+
* Options for executing filters
|
|
100
|
+
*/
|
|
101
|
+
export interface ExecuteFiltersOptions {
|
|
102
|
+
globalFilters: Filter[];
|
|
103
|
+
classFilters: Filter[];
|
|
104
|
+
methodFilters: Filter[];
|
|
105
|
+
resolveFilter?: (filter: Filter) => ExceptionFilter | null;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Find and execute the appropriate filter for an exception
|
|
109
|
+
* Filters are checked in order: method → class → global
|
|
110
|
+
* The first filter that can handle the exception is used
|
|
111
|
+
*/
|
|
112
|
+
export declare function findAndExecuteFilter(exception: Error, context: Context, options: ExecuteFiltersOptions): Promise<Response>;
|
|
113
|
+
/**
|
|
114
|
+
* HttpExceptionFilter - Handles BuenoError exceptions
|
|
115
|
+
* Returns appropriate HTTP status codes and error details
|
|
116
|
+
*/
|
|
117
|
+
export declare class HttpExceptionFilter implements ExceptionFilter<BuenoError> {
|
|
118
|
+
catch(exception: BuenoError, context: Context): Response;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* ValidationFilter - Handles ValidationError exceptions
|
|
122
|
+
* Returns validation error details with issues list
|
|
123
|
+
*/
|
|
124
|
+
export declare class ValidationFilter implements ExceptionFilter<ValidationError> {
|
|
125
|
+
catch(exception: ValidationError, context: Context): Response;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* NotFoundFilter - Handles NotFoundError exceptions
|
|
129
|
+
* Returns 404 response with resource not found message
|
|
130
|
+
*/
|
|
131
|
+
export declare class NotFoundFilter implements ExceptionFilter<NotFoundError> {
|
|
132
|
+
catch(exception: NotFoundError, context: Context): Response;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* AllExceptionsFilter - Catch-all filter for any Error
|
|
136
|
+
* This filter handles all unhandled exceptions
|
|
137
|
+
*/
|
|
138
|
+
export declare class AllExceptionsFilter implements ExceptionFilter<Error> {
|
|
139
|
+
catch(exception: Error, context: Context): Response;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Create a default error response when no filter matches
|
|
143
|
+
*/
|
|
144
|
+
export declare function createDefaultErrorResponse(exception: Error, context: Context): Response;
|
|
145
|
+
/**
|
|
146
|
+
* Create an internal error response
|
|
147
|
+
*/
|
|
148
|
+
export declare function createInternalErrorResponse(exception: Error): Response;
|
|
149
|
+
export {};
|
|
150
|
+
//# sourceMappingURL=filters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filters.d.ts","sourceRoot":"","sources":["../../src/modules/filters.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,eAAe,EAA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AAe,CAAC,aAAa,CAAC;IACpE,KAAK,CAAC,SAAS,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,GAAG,QAAQ;CAO3D;AAED;;;GAGG;AACH,qBAAa,mBAAoB,YAAW,eAAe,CAAC,KAAK,CAAC;IACjE,KAAK,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,GAAG,QAAQ;CAmBnD;AAID;;GAEG;AACH,wBAAgB,0BAA0B,CACzC,SAAS,EAAE,KAAK,EAChB,OAAO,EAAE,OAAO,GACd,QAAQ,CAQV;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,KAAK,GAAG,QAAQ,CAetE"}
|
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exception Filters System
|
|
3
|
+
*
|
|
4
|
+
* Filters catch exceptions thrown during request processing and transform
|
|
5
|
+
* them into appropriate responses. They act as error boundaries in the
|
|
6
|
+
* request pipeline.
|
|
7
|
+
*
|
|
8
|
+
* Execution Order:
|
|
9
|
+
* Incoming Request → Guards → Pipes → Handler → Filters (if error) → Error Response
|
|
10
|
+
*/
|
|
11
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
12
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
13
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
14
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
15
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
16
|
+
};
|
|
17
|
+
import { BuenoError, NotFoundError, ValidationError } from "../types";
|
|
18
|
+
// Metadata storage for filters
|
|
19
|
+
const filterMetadataStore = new WeakMap();
|
|
20
|
+
const catchMetadataStore = new WeakMap();
|
|
21
|
+
// Prototype metadata for method decorators
|
|
22
|
+
const filterPrototypeStore = new WeakMap();
|
|
23
|
+
function setFilterMetadata(target, key, value) {
|
|
24
|
+
if (!filterMetadataStore.has(target)) {
|
|
25
|
+
filterMetadataStore.set(target, new Map());
|
|
26
|
+
}
|
|
27
|
+
filterMetadataStore.get(target)?.set(key, value);
|
|
28
|
+
}
|
|
29
|
+
function getFilterMetadata(target, key) {
|
|
30
|
+
return filterMetadataStore.get(target)?.get(key);
|
|
31
|
+
}
|
|
32
|
+
function setFilterPrototypeMetadata(target, key, value) {
|
|
33
|
+
if (!filterPrototypeStore.has(target)) {
|
|
34
|
+
filterPrototypeStore.set(target, new Map());
|
|
35
|
+
}
|
|
36
|
+
filterPrototypeStore.get(target)?.set(key, value);
|
|
37
|
+
}
|
|
38
|
+
function getFilterPrototypeMetadata(target, key) {
|
|
39
|
+
return filterPrototypeStore.get(target)?.get(key);
|
|
40
|
+
}
|
|
41
|
+
// ============= Decorators =============
|
|
42
|
+
/**
|
|
43
|
+
* Decorator to apply filters to a controller class or method
|
|
44
|
+
* Filters are executed in order: global → class → method
|
|
45
|
+
*
|
|
46
|
+
* @param filters - Filters to apply
|
|
47
|
+
* @returns ClassDecorator & MethodDecorator
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* @Controller('users')
|
|
52
|
+
* @UseFilters(CustomExceptionFilter) // Applied to all methods
|
|
53
|
+
* class UsersController {
|
|
54
|
+
* @Get(':id')
|
|
55
|
+
* @UseFilters(NotFoundExceptionFilter) // Additional filter for this method
|
|
56
|
+
* getUser() {}
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export function UseFilters(...filters) {
|
|
61
|
+
const decorator = (target, propertyKey, descriptor) => {
|
|
62
|
+
if (descriptor && propertyKey !== undefined) {
|
|
63
|
+
// Method decorator
|
|
64
|
+
const targetObj = target;
|
|
65
|
+
const existingFilters = getFilterPrototypeMetadata(targetObj, "filters:method") ?? [];
|
|
66
|
+
setFilterPrototypeMetadata(targetObj, "filters:method", [
|
|
67
|
+
...existingFilters,
|
|
68
|
+
...filters,
|
|
69
|
+
]);
|
|
70
|
+
return descriptor;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
// Class decorator
|
|
74
|
+
const targetClass = target;
|
|
75
|
+
const existingFilters = getFilterMetadata(targetClass, "filters:class") ?? [];
|
|
76
|
+
setFilterMetadata(targetClass, "filters:class", [
|
|
77
|
+
...existingFilters,
|
|
78
|
+
...filters,
|
|
79
|
+
]);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
return decorator;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Decorator to mark a filter as catching a specific exception type
|
|
86
|
+
*
|
|
87
|
+
* @param exceptionType - The exception class to catch
|
|
88
|
+
* @returns ClassDecorator
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* @Catch(ValidationError)
|
|
93
|
+
* @Injectable()
|
|
94
|
+
* class CustomValidationFilter implements ExceptionFilter<ValidationError> {
|
|
95
|
+
* catch(exception: ValidationError, context: Context): Response {
|
|
96
|
+
* return context.status(422).json({
|
|
97
|
+
* error: 'Validation Failed',
|
|
98
|
+
* issues: exception.issues
|
|
99
|
+
* });
|
|
100
|
+
* }
|
|
101
|
+
* }
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
export function Catch(exceptionType) {
|
|
105
|
+
const decorator = (target) => {
|
|
106
|
+
catchMetadataStore.set(target, {
|
|
107
|
+
exceptionType: exceptionType,
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
return decorator;
|
|
111
|
+
}
|
|
112
|
+
// ============= Helper Functions =============
|
|
113
|
+
/**
|
|
114
|
+
* Get class-level filters from a controller
|
|
115
|
+
*/
|
|
116
|
+
export function getClassFilters(target) {
|
|
117
|
+
return getFilterMetadata(target, "filters:class");
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Get method-level filters from a controller method
|
|
121
|
+
*/
|
|
122
|
+
export function getMethodFilters(target, propertyKey) {
|
|
123
|
+
// First check method-specific filters
|
|
124
|
+
const methodFilters = getFilterPrototypeMetadata(target, `filters:method:${String(propertyKey)}`);
|
|
125
|
+
if (methodFilters) {
|
|
126
|
+
return methodFilters;
|
|
127
|
+
}
|
|
128
|
+
// Fall back to general method filters
|
|
129
|
+
return getFilterPrototypeMetadata(target, "filters:method");
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Get the exception type that a filter catches
|
|
133
|
+
*/
|
|
134
|
+
export function getCatchType(filter) {
|
|
135
|
+
// If it's a class constructor, check the catch metadata
|
|
136
|
+
if (typeof filter === "function" && filter.prototype !== undefined) {
|
|
137
|
+
const metadata = catchMetadataStore.get(filter);
|
|
138
|
+
return metadata?.exceptionType;
|
|
139
|
+
}
|
|
140
|
+
// If it's an instance, check its constructor
|
|
141
|
+
if (typeof filter === "object" && filter !== null && "catch" in filter) {
|
|
142
|
+
const constructor = filter.constructor;
|
|
143
|
+
const metadata = catchMetadataStore.get(constructor);
|
|
144
|
+
return metadata?.exceptionType;
|
|
145
|
+
}
|
|
146
|
+
return undefined;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Check if a filter can handle a specific exception
|
|
150
|
+
*/
|
|
151
|
+
export function canHandleException(filter, exception) {
|
|
152
|
+
const catchType = getCatchType(filter);
|
|
153
|
+
if (!catchType) {
|
|
154
|
+
// No specific catch type means it handles all exceptions
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
return exception instanceof catchType;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Type guard to check if a value is an ExceptionFilter instance
|
|
161
|
+
*/
|
|
162
|
+
export function isExceptionFilter(value) {
|
|
163
|
+
return (typeof value === "object" &&
|
|
164
|
+
value !== null &&
|
|
165
|
+
"catch" in value &&
|
|
166
|
+
typeof value.catch === "function");
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Type guard to check if a value is a FilterFn
|
|
170
|
+
*/
|
|
171
|
+
export function isFilterFn(value) {
|
|
172
|
+
return typeof value === "function" && value.length === 2;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Execute a filter and return the response
|
|
176
|
+
*/
|
|
177
|
+
export async function executeFilter(filter, exception, context, resolveFilter) {
|
|
178
|
+
let filterInstance = null;
|
|
179
|
+
if (isExceptionFilter(filter)) {
|
|
180
|
+
filterInstance = filter;
|
|
181
|
+
}
|
|
182
|
+
else if (isFilterFn(filter)) {
|
|
183
|
+
// Convert filter function to response
|
|
184
|
+
return filter(exception, context);
|
|
185
|
+
}
|
|
186
|
+
else if (typeof filter === "function") {
|
|
187
|
+
// It's a class constructor - try to resolve from container or instantiate
|
|
188
|
+
if (resolveFilter) {
|
|
189
|
+
filterInstance = resolveFilter(filter);
|
|
190
|
+
}
|
|
191
|
+
if (!filterInstance) {
|
|
192
|
+
// Try to instantiate directly (for simple filters without dependencies)
|
|
193
|
+
try {
|
|
194
|
+
const Constructor = filter;
|
|
195
|
+
filterInstance = new Constructor();
|
|
196
|
+
}
|
|
197
|
+
catch {
|
|
198
|
+
// Cannot instantiate - will fall through to default handling
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
else if (typeof filter === "object" &&
|
|
203
|
+
filter !== null &&
|
|
204
|
+
!isExceptionFilter(filter)) {
|
|
205
|
+
// It's a token - try to resolve
|
|
206
|
+
if (resolveFilter) {
|
|
207
|
+
filterInstance = resolveFilter(filter);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (filterInstance && isExceptionFilter(filterInstance)) {
|
|
211
|
+
return filterInstance.catch(exception, context);
|
|
212
|
+
}
|
|
213
|
+
// Fallback - should not reach here if a catch-all filter is configured
|
|
214
|
+
return createInternalErrorResponse(exception);
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Find and execute the appropriate filter for an exception
|
|
218
|
+
* Filters are checked in order: method → class → global
|
|
219
|
+
* The first filter that can handle the exception is used
|
|
220
|
+
*/
|
|
221
|
+
export async function findAndExecuteFilter(exception, context, options) {
|
|
222
|
+
const { globalFilters, classFilters, methodFilters, resolveFilter } = options;
|
|
223
|
+
// Combine all filters in execution order (method first, then class, then global)
|
|
224
|
+
const allFilters = [...methodFilters, ...classFilters, ...globalFilters];
|
|
225
|
+
// Find the first filter that can handle this exception type
|
|
226
|
+
for (const filter of allFilters) {
|
|
227
|
+
if (canHandleException(filter, exception)) {
|
|
228
|
+
return executeFilter(filter, exception, context, resolveFilter);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
// No specific filter found - use default error response
|
|
232
|
+
return createDefaultErrorResponse(exception, context);
|
|
233
|
+
}
|
|
234
|
+
// ============= Built-in Filters =============
|
|
235
|
+
/**
|
|
236
|
+
* HttpExceptionFilter - Handles BuenoError exceptions
|
|
237
|
+
* Returns appropriate HTTP status codes and error details
|
|
238
|
+
*/
|
|
239
|
+
let HttpExceptionFilter = class HttpExceptionFilter {
|
|
240
|
+
catch(exception, context) {
|
|
241
|
+
return context.status(exception.statusCode).json({
|
|
242
|
+
error: exception.name,
|
|
243
|
+
message: exception.message,
|
|
244
|
+
code: exception.code,
|
|
245
|
+
statusCode: exception.statusCode,
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
HttpExceptionFilter = __decorate([
|
|
250
|
+
Catch(BuenoError)
|
|
251
|
+
], HttpExceptionFilter);
|
|
252
|
+
export { HttpExceptionFilter };
|
|
253
|
+
/**
|
|
254
|
+
* ValidationFilter - Handles ValidationError exceptions
|
|
255
|
+
* Returns validation error details with issues list
|
|
256
|
+
*/
|
|
257
|
+
let ValidationFilter = class ValidationFilter {
|
|
258
|
+
catch(exception, context) {
|
|
259
|
+
return context.status(422).json({
|
|
260
|
+
error: "Validation Failed",
|
|
261
|
+
message: exception.message,
|
|
262
|
+
code: "VALIDATION_ERROR",
|
|
263
|
+
issues: exception.issues,
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
ValidationFilter = __decorate([
|
|
268
|
+
Catch(ValidationError)
|
|
269
|
+
], ValidationFilter);
|
|
270
|
+
export { ValidationFilter };
|
|
271
|
+
/**
|
|
272
|
+
* NotFoundFilter - Handles NotFoundError exceptions
|
|
273
|
+
* Returns 404 response with resource not found message
|
|
274
|
+
*/
|
|
275
|
+
let NotFoundFilter = class NotFoundFilter {
|
|
276
|
+
catch(exception, context) {
|
|
277
|
+
return context.status(404).json({
|
|
278
|
+
error: "Not Found",
|
|
279
|
+
message: exception.message,
|
|
280
|
+
code: "NOT_FOUND",
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
NotFoundFilter = __decorate([
|
|
285
|
+
Catch(NotFoundError)
|
|
286
|
+
], NotFoundFilter);
|
|
287
|
+
export { NotFoundFilter };
|
|
288
|
+
/**
|
|
289
|
+
* AllExceptionsFilter - Catch-all filter for any Error
|
|
290
|
+
* This filter handles all unhandled exceptions
|
|
291
|
+
*/
|
|
292
|
+
export class AllExceptionsFilter {
|
|
293
|
+
catch(exception, context) {
|
|
294
|
+
// Log the error for debugging
|
|
295
|
+
console.error("Unhandled exception:", exception);
|
|
296
|
+
// Check if it's a known error type
|
|
297
|
+
if (exception instanceof BuenoError) {
|
|
298
|
+
return context.status(exception.statusCode).json({
|
|
299
|
+
error: exception.name,
|
|
300
|
+
message: exception.message,
|
|
301
|
+
code: exception.code,
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
// Generic error response
|
|
305
|
+
return context.status(500).json({
|
|
306
|
+
error: "Internal Server Error",
|
|
307
|
+
message: exception.message || "An unexpected error occurred",
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
// ============= Helper Response Functions =============
|
|
312
|
+
/**
|
|
313
|
+
* Create a default error response when no filter matches
|
|
314
|
+
*/
|
|
315
|
+
export function createDefaultErrorResponse(exception, context) {
|
|
316
|
+
// Log the unhandled exception
|
|
317
|
+
console.error("Unhandled exception (no filter matched):", exception);
|
|
318
|
+
return context.status(500).json({
|
|
319
|
+
error: "Internal Server Error",
|
|
320
|
+
message: exception.message || "An unexpected error occurred",
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Create an internal error response
|
|
325
|
+
*/
|
|
326
|
+
export function createInternalErrorResponse(exception) {
|
|
327
|
+
console.error("Internal server error:", exception);
|
|
328
|
+
return new Response(JSON.stringify({
|
|
329
|
+
error: "Internal Server Error",
|
|
330
|
+
message: "An unexpected error occurred",
|
|
331
|
+
}), {
|
|
332
|
+
status: 500,
|
|
333
|
+
headers: {
|
|
334
|
+
"Content-Type": "application/json",
|
|
335
|
+
},
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
//# sourceMappingURL=filters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filters.js","sourceRoot":"","sources":["../../src/modules/filters.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;;;;;;;AAIH,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAwCtE,+BAA+B;AAC/B,MAAM,mBAAmB,GAAG,IAAI,OAAO,EAAqC,CAAC;AAC7E,MAAM,kBAAkB,GAAG,IAAI,OAAO,EAA8B,CAAC;AAErE,2CAA2C;AAC3C,MAAM,oBAAoB,GAAG,IAAI,OAAO,EAAgC,CAAC;AAEzE,SAAS,iBAAiB,CACzB,MAAmB,EACnB,GAAW,EACX,KAAc;IAEd,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,mBAAmB,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;IAC5C,CAAC;IACD,mBAAmB,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,G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D,OAAO,IAAI,QAAQ,CAClB,IAAI,CAAC,SAAS,CAAC;QACd,KAAK,EAAE,uBAAuB;QAC9B,OAAO,EAAE,8BAA8B;KACvC,CAAC,EACF;QACC,MAAM,EAAE,GAAG;QACX,OAAO,EAAE;YACR,cAAc,EAAE,kBAAkB;SAClC;KACD,CACD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Guards System
|
|
3
|
+
*
|
|
4
|
+
* Guards determine whether a request should be allowed to proceed to the handler.
|
|
5
|
+
* They run before interceptors and pipes in the request pipeline.
|
|
6
|
+
*
|
|
7
|
+
* Execution Order:
|
|
8
|
+
* Incoming Request → Guards → Interceptors → Pipes → Handler
|
|
9
|
+
*
|
|
10
|
+
* If any guard returns false, the request is rejected with 403 Forbidden.
|
|
11
|
+
*/
|
|
12
|
+
import type { Token } from "../container";
|
|
13
|
+
import type { Context } from "../context";
|
|
14
|
+
/**
|
|
15
|
+
* Guard interface for authorization checks
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* @Injectable()
|
|
20
|
+
* class AuthGuard implements CanActivate {
|
|
21
|
+
* canActivate(context: Context): boolean {
|
|
22
|
+
* return !!context.request.headers.get('Authorization');
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export interface CanActivate {
|
|
28
|
+
canActivate(context: Context): boolean | Promise<boolean>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Guard function type (for functional guards)
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const authGuard: GuardFn = (context) => {
|
|
36
|
+
* return !!context.request.headers.get('Authorization');
|
|
37
|
+
* };
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export type GuardFn = (context: Context) => boolean | Promise<boolean>;
|
|
41
|
+
/**
|
|
42
|
+
* Guard type - can be:
|
|
43
|
+
* - A token for a guard class registered in the container
|
|
44
|
+
* - A guard class instance
|
|
45
|
+
* - A guard function
|
|
46
|
+
*/
|
|
47
|
+
export type Guard = Token<CanActivate> | CanActivate | GuardFn;
|
|
48
|
+
type Constructor = new (...args: unknown[]) => unknown;
|
|
49
|
+
/**
|
|
50
|
+
* Get guards from a class constructor
|
|
51
|
+
*/
|
|
52
|
+
export declare function getClassGuards(target: Constructor): Guard[] | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Get guards from a method
|
|
55
|
+
*/
|
|
56
|
+
export declare function getMethodGuards(target: object, propertyKey: string | symbol): Guard[] | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Decorator to apply guards to a controller class or method.
|
|
59
|
+
* Guards are executed in the order they are provided.
|
|
60
|
+
*
|
|
61
|
+
* @param guards - Guards to apply
|
|
62
|
+
* @returns ClassDecorator & MethodDecorator
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* // Apply to all methods in controller
|
|
67
|
+
* @Controller('users')
|
|
68
|
+
* @UseGuards(AuthGuard)
|
|
69
|
+
* class UsersController {
|
|
70
|
+
* @Get()
|
|
71
|
+
* getUsers() {} // Protected by AuthGuard
|
|
72
|
+
*
|
|
73
|
+
* @Get(':id')
|
|
74
|
+
* @UseGuards(RolesGuard) // Additional guard
|
|
75
|
+
* getUser() {} // Protected by AuthGuard AND RolesGuard
|
|
76
|
+
* }
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
export declare function UseGuards(...guards: Guard[]): MethodDecorator & ClassDecorator;
|
|
80
|
+
/**
|
|
81
|
+
* AuthGuard - Checks for Authorization header
|
|
82
|
+
*
|
|
83
|
+
* This guard verifies that the request has an Authorization header.
|
|
84
|
+
* It does not validate the token - that should be done by a custom guard.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```typescript
|
|
88
|
+
* @Controller('api')
|
|
89
|
+
* @UseGuards(AuthGuard)
|
|
90
|
+
* class ApiController {
|
|
91
|
+
* @Get('protected')
|
|
92
|
+
* protectedRoute() {} // Requires Authorization header
|
|
93
|
+
* }
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
export declare class AuthGuard implements CanActivate {
|
|
97
|
+
canActivate(context: Context): boolean;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Get required roles from a method
|
|
101
|
+
*/
|
|
102
|
+
export declare function getMethodRoles(target: object, propertyKey: string | symbol): string[] | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* Decorator to specify required roles for a route
|
|
105
|
+
* Must be used in conjunction with RolesGuard
|
|
106
|
+
*
|
|
107
|
+
* @param roles - Required roles
|
|
108
|
+
* @returns MethodDecorator
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* @Controller('admin')
|
|
113
|
+
* @UseGuards(AuthGuard, RolesGuard)
|
|
114
|
+
* class AdminController {
|
|
115
|
+
* @Get('users')
|
|
116
|
+
* @Roles('admin', 'moderator')
|
|
117
|
+
* getUsers() {} // Requires 'admin' or 'moderator' role
|
|
118
|
+
* }
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
export declare function Roles(...roles: string[]): MethodDecorator;
|
|
122
|
+
/**
|
|
123
|
+
* User interface for type safety
|
|
124
|
+
* Applications should extend this interface with their user type
|
|
125
|
+
*/
|
|
126
|
+
export interface User {
|
|
127
|
+
id: string | number;
|
|
128
|
+
roles?: string[];
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Context extension for user data
|
|
132
|
+
* This extends the Context type to include user information
|
|
133
|
+
*/
|
|
134
|
+
declare module "../context" {
|
|
135
|
+
interface Context {
|
|
136
|
+
user?: User;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* RolesGuard - Checks user roles
|
|
141
|
+
*
|
|
142
|
+
* This guard checks if the authenticated user has the required roles.
|
|
143
|
+
* It should be used after AuthGuard in the guard chain.
|
|
144
|
+
*
|
|
145
|
+
* The user object must be set on the context before this guard runs.
|
|
146
|
+
* This is typically done by an authentication middleware or a previous guard.
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```typescript
|
|
150
|
+
* @Controller('admin')
|
|
151
|
+
* @UseGuards(AuthGuard, RolesGuard)
|
|
152
|
+
* class AdminController {
|
|
153
|
+
* @Get('dashboard')
|
|
154
|
+
* @Roles('admin')
|
|
155
|
+
* getDashboard() {} // Requires 'admin' role
|
|
156
|
+
* }
|
|
157
|
+
* ```
|
|
158
|
+
*/
|
|
159
|
+
export declare class RolesGuard implements CanActivate {
|
|
160
|
+
canActivate(context: Context): boolean;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Guard executor options
|
|
164
|
+
*/
|
|
165
|
+
export interface GuardExecutorOptions {
|
|
166
|
+
/** Global guards applied to all routes */
|
|
167
|
+
globalGuards?: Guard[];
|
|
168
|
+
/** Guards from controller class */
|
|
169
|
+
classGuards?: Guard[];
|
|
170
|
+
/** Guards from method */
|
|
171
|
+
methodGuards?: Guard[];
|
|
172
|
+
/** Container for resolving guard instances */
|
|
173
|
+
resolveGuard?: (guard: Guard) => CanActivate | GuardFn | null;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Execute guards in order and return whether the request should proceed
|
|
177
|
+
*
|
|
178
|
+
* @param context - Request context
|
|
179
|
+
* @param options - Guard executor options
|
|
180
|
+
* @returns true if all guards pass, false otherwise
|
|
181
|
+
*/
|
|
182
|
+
export declare function executeGuards(context: Context, options: GuardExecutorOptions): Promise<boolean>;
|
|
183
|
+
/**
|
|
184
|
+
* Create a 403 Forbidden response
|
|
185
|
+
*/
|
|
186
|
+
export declare function createForbiddenResponse(): Response;
|
|
187
|
+
export {};
|
|
188
|
+
//# sourceMappingURL=guards.d.ts.map
|