adorn-api 1.0.23 → 1.0.24
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/.eslintignore +3 -0
- package/.eslintrc.cjs +30 -0
- package/README.md +375 -531
- package/dist/core/express-adapter.d.ts +27 -0
- package/dist/core/express-adapter.d.ts.map +1 -0
- package/dist/core/express-adapter.js +146 -0
- package/dist/core/express-adapter.js.map +1 -0
- package/dist/core/http-error.d.ts +7 -0
- package/dist/core/http-error.d.ts.map +1 -0
- package/dist/core/http-error.js +14 -0
- package/dist/core/http-error.js.map +1 -0
- package/dist/decorators/controller.decorator.d.ts +2 -0
- package/dist/decorators/controller.decorator.d.ts.map +1 -0
- package/dist/decorators/controller.decorator.js +26 -0
- package/dist/decorators/controller.decorator.js.map +1 -0
- package/dist/decorators/create.decorator.d.ts +8 -0
- package/dist/decorators/create.decorator.d.ts.map +1 -0
- package/dist/decorators/create.decorator.js +67 -0
- package/dist/decorators/create.decorator.js.map +1 -0
- package/dist/decorators/http-method.decorator.d.ts +16 -0
- package/dist/decorators/http-method.decorator.d.ts.map +1 -0
- package/dist/decorators/http-method.decorator.js +117 -0
- package/dist/decorators/http-method.decorator.js.map +1 -0
- package/dist/decorators/http-params.d.ts +17 -0
- package/dist/decorators/http-params.d.ts.map +1 -0
- package/dist/decorators/http-params.js +26 -0
- package/dist/decorators/http-params.js.map +1 -0
- package/dist/decorators/index.d.ts +10 -5
- package/dist/decorators/index.d.ts.map +1 -1
- package/dist/decorators/index.js +14 -0
- package/dist/decorators/index.js.map +1 -0
- package/dist/decorators/list.decorator.d.ts +18 -0
- package/dist/decorators/list.decorator.d.ts.map +1 -0
- package/dist/decorators/list.decorator.js +99 -0
- package/dist/decorators/list.decorator.js.map +1 -0
- package/dist/decorators/middleware.decorator.d.ts +4 -0
- package/dist/decorators/middleware.decorator.d.ts.map +1 -0
- package/dist/decorators/middleware.decorator.js +34 -0
- package/dist/decorators/middleware.decorator.js.map +1 -0
- package/dist/decorators/response.decorator.d.ts +8 -0
- package/dist/decorators/response.decorator.d.ts.map +1 -0
- package/dist/decorators/response.decorator.js +44 -0
- package/dist/decorators/response.decorator.js.map +1 -0
- package/dist/decorators/route-options.d.ts +14 -0
- package/dist/decorators/route-options.d.ts.map +1 -0
- package/dist/decorators/route-options.js +22 -0
- package/dist/decorators/route-options.js.map +1 -0
- package/dist/decorators/schema.decorator.d.ts +82 -0
- package/dist/decorators/schema.decorator.d.ts.map +1 -0
- package/dist/decorators/schema.decorator.js +123 -0
- package/dist/decorators/schema.decorator.js.map +1 -0
- package/dist/decorators/update.decorator.d.ts +8 -0
- package/dist/decorators/update.decorator.d.ts.map +1 -0
- package/dist/decorators/update.decorator.js +63 -0
- package/dist/decorators/update.decorator.js.map +1 -0
- package/dist/index.d.ts +11 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -637
- package/dist/index.js.map +1 -1
- package/dist/metadata/metadata-storage.d.ts +38 -0
- package/dist/metadata/metadata-storage.d.ts.map +1 -0
- package/dist/metadata/metadata-storage.js +102 -0
- package/dist/metadata/metadata-storage.js.map +1 -0
- package/dist/metal-orm-integration/dto-helper.d.ts +5 -0
- package/dist/metal-orm-integration/dto-helper.d.ts.map +1 -0
- package/dist/metal-orm-integration/dto-helper.js +48 -0
- package/dist/metal-orm-integration/dto-helper.js.map +1 -0
- package/dist/metal-orm-integration/dto-response.decorator.d.ts +4 -0
- package/dist/metal-orm-integration/dto-response.decorator.d.ts.map +1 -0
- package/dist/metal-orm-integration/dto-response.decorator.js +69 -0
- package/dist/metal-orm-integration/dto-response.decorator.js.map +1 -0
- package/dist/metal-orm-integration/entity-schema-builder.d.ts +20 -0
- package/dist/metal-orm-integration/entity-schema-builder.d.ts.map +1 -0
- package/dist/metal-orm-integration/entity-schema-builder.js +356 -0
- package/dist/metal-orm-integration/entity-schema-builder.js.map +1 -0
- package/dist/metal-orm-integration/index.d.ts +5 -0
- package/dist/metal-orm-integration/index.d.ts.map +1 -0
- package/dist/metal-orm-integration/index.js +5 -0
- package/dist/metal-orm-integration/index.js.map +1 -0
- package/dist/metal-orm-integration/schema-modifier.d.ts +11 -0
- package/dist/metal-orm-integration/schema-modifier.d.ts.map +1 -0
- package/dist/metal-orm-integration/schema-modifier.js +62 -0
- package/dist/metal-orm-integration/schema-modifier.js.map +1 -0
- package/dist/openapi/index.d.ts +4 -0
- package/dist/openapi/index.d.ts.map +1 -0
- package/dist/openapi/index.js +4 -0
- package/dist/openapi/index.js.map +1 -0
- package/dist/openapi/openapi-generator.d.ts +22 -0
- package/dist/openapi/openapi-generator.d.ts.map +1 -0
- package/dist/openapi/openapi-generator.js +428 -0
- package/dist/openapi/openapi-generator.js.map +1 -0
- package/dist/openapi/swagger-ui.d.ts +11 -0
- package/dist/openapi/swagger-ui.d.ts.map +1 -0
- package/dist/openapi/swagger-ui.js +20 -0
- package/dist/openapi/swagger-ui.js.map +1 -0
- package/dist/openapi/zod-to-openapi.d.ts +4 -0
- package/dist/openapi/zod-to-openapi.d.ts.map +1 -0
- package/dist/openapi/zod-to-openapi.js +184 -0
- package/dist/openapi/zod-to-openapi.js.map +1 -0
- package/dist/types/common.d.ts +4 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/common.js +2 -0
- package/dist/types/common.js.map +1 -0
- package/dist/types/controller.d.ts +14 -0
- package/dist/types/controller.d.ts.map +1 -0
- package/dist/types/controller.js +2 -0
- package/dist/types/controller.js.map +1 -0
- package/dist/types/metadata.d.ts +48 -0
- package/dist/types/metadata.d.ts.map +1 -0
- package/dist/types/metadata.js +2 -0
- package/dist/types/metadata.js.map +1 -0
- package/dist/types/openapi.d.ts +30 -0
- package/dist/types/openapi.d.ts.map +1 -0
- package/dist/types/openapi.js +2 -0
- package/dist/types/openapi.js.map +1 -0
- package/dist/validation/zod-adapter.d.ts +15 -0
- package/dist/validation/zod-adapter.d.ts.map +1 -0
- package/dist/validation/zod-adapter.js +61 -0
- package/dist/validation/zod-adapter.js.map +1 -0
- package/examples/basic/app.ts +15 -0
- package/examples/basic/index.ts +6 -0
- package/examples/basic/user.controller.ts +35 -0
- package/examples/basic/user.dtos.ts +23 -0
- package/examples/metal-orm-sqlite/app.ts +18 -0
- package/examples/metal-orm-sqlite/db.ts +90 -0
- package/examples/metal-orm-sqlite/index.ts +6 -0
- package/examples/metal-orm-sqlite/post.controller.ts +209 -0
- package/examples/metal-orm-sqlite/post.dtos.ts +78 -0
- package/examples/metal-orm-sqlite/post.entity.ts +24 -0
- package/examples/metal-orm-sqlite/user.controller.helpers.ts +305 -0
- package/examples/metal-orm-sqlite/user.controller.ts +231 -0
- package/examples/metal-orm-sqlite/user.dtos.ts +88 -0
- package/examples/metal-orm-sqlite/user.entity.ts +21 -0
- package/examples/metal-orm-sqlite-music/album.controller.ts +278 -0
- package/examples/metal-orm-sqlite-music/album.dtos.ts +85 -0
- package/examples/metal-orm-sqlite-music/album.entity.ts +28 -0
- package/examples/metal-orm-sqlite-music/app.ts +19 -0
- package/examples/metal-orm-sqlite-music/artist.controller.ts +272 -0
- package/examples/metal-orm-sqlite-music/artist.dtos.ts +68 -0
- package/examples/metal-orm-sqlite-music/artist.entity.ts +27 -0
- package/examples/metal-orm-sqlite-music/db.ts +148 -0
- package/examples/metal-orm-sqlite-music/index.ts +6 -0
- package/examples/metal-orm-sqlite-music/track.controller.ts +221 -0
- package/examples/metal-orm-sqlite-music/track.dtos.ts +82 -0
- package/examples/metal-orm-sqlite-music/track.entity.ts +27 -0
- package/examples/openapi/health.controller.ts +11 -0
- package/examples/openapi/health.dto.ts +7 -0
- package/examples/openapi/index.ts +12 -0
- package/examples/restful/app.ts +15 -0
- package/examples/restful/index.ts +9 -0
- package/examples/restful/task.controller.ts +118 -0
- package/examples/restful/task.dtos.ts +66 -0
- package/examples/restful/task.store.ts +95 -0
- package/examples/tsconfig.json +8 -0
- package/examples/utils/start-server.ts +56 -0
- package/package.json +33 -97
- package/scripts/run-example.js +29 -0
- package/src/adapter/express.ts +589 -0
- package/src/adapter/metal-orm/convention-overrides.ts +115 -0
- package/src/adapter/metal-orm/crud-dtos.ts +141 -0
- package/src/adapter/metal-orm/dto.ts +20 -0
- package/src/adapter/metal-orm/error-dtos.ts +51 -0
- package/src/adapter/metal-orm/field-builder.ts +185 -0
- package/src/adapter/metal-orm/filters.ts +52 -0
- package/src/adapter/metal-orm/index.ts +66 -0
- package/src/adapter/metal-orm/paged-dtos.ts +94 -0
- package/src/adapter/metal-orm/pagination.ts +28 -0
- package/src/adapter/metal-orm/types.ts +250 -0
- package/src/adapter/metal-orm/utils.ts +36 -0
- package/src/adapter/metal-orm.test.ts +439 -0
- package/src/core/__tests__/coerce.test.ts +39 -0
- package/src/core/__tests__/dto-compose.test.ts +68 -0
- package/src/core/__tests__/schema-builder.test.ts +82 -0
- package/src/core/coerce.ts +190 -0
- package/src/core/decorators.ts +645 -0
- package/src/core/errors.ts +55 -0
- package/src/core/metadata.ts +110 -0
- package/src/core/openapi.ts +282 -0
- package/src/core/schema-builder.ts +287 -0
- package/src/core/schema.ts +400 -0
- package/src/core/types.ts +14 -0
- package/src/e2e/http-error.e2e.test.ts +52 -0
- package/src/e2e/sqlite-metal-orm.e2e.test.ts +174 -0
- package/src/e2e/sqlite.e2e.test.ts +126 -0
- package/src/index.ts +8 -0
- package/tsconfig.eslint.json +7 -0
- package/tsconfig.json +18 -0
- package/vitest.config.ts +8 -0
- package/dist/adapter/express/auth.d.ts +0 -13
- package/dist/adapter/express/auth.d.ts.map +0 -1
- package/dist/adapter/express/bootstrap.d.ts +0 -40
- package/dist/adapter/express/bootstrap.d.ts.map +0 -1
- package/dist/adapter/express/coercion.d.ts +0 -102
- package/dist/adapter/express/coercion.d.ts.map +0 -1
- package/dist/adapter/express/index.d.ts +0 -6
- package/dist/adapter/express/index.d.ts.map +0 -1
- package/dist/adapter/express/merge.d.ts +0 -45
- package/dist/adapter/express/merge.d.ts.map +0 -1
- package/dist/adapter/express/openapi.d.ts +0 -66
- package/dist/adapter/express/openapi.d.ts.map +0 -1
- package/dist/adapter/express/router.d.ts +0 -10
- package/dist/adapter/express/router.d.ts.map +0 -1
- package/dist/adapter/express/swagger.d.ts +0 -18
- package/dist/adapter/express/swagger.d.ts.map +0 -1
- package/dist/adapter/express/types.d.ts +0 -110
- package/dist/adapter/express/types.d.ts.map +0 -1
- package/dist/adapter/express/validation.d.ts +0 -27
- package/dist/adapter/express/validation.d.ts.map +0 -1
- package/dist/cli/progress.d.ts +0 -124
- package/dist/cli/progress.d.ts.map +0 -1
- package/dist/cli.cjs +0 -4622
- package/dist/cli.cjs.map +0 -1
- package/dist/cli.d.ts +0 -3
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -4603
- package/dist/cli.js.map +0 -1
- package/dist/compiler/analyze/index.d.ts +0 -5
- package/dist/compiler/analyze/index.d.ts.map +0 -1
- package/dist/compiler/analyze/scanControllers.d.ts +0 -88
- package/dist/compiler/analyze/scanControllers.d.ts.map +0 -1
- package/dist/compiler/cache/isStale.d.ts +0 -46
- package/dist/compiler/cache/isStale.d.ts.map +0 -1
- package/dist/compiler/cache/loadArtifacts.d.ts +0 -149
- package/dist/compiler/cache/loadArtifacts.d.ts.map +0 -1
- package/dist/compiler/cache/schema.d.ts +0 -32
- package/dist/compiler/cache/schema.d.ts.map +0 -1
- package/dist/compiler/cache/writeCache.d.ts +0 -14
- package/dist/compiler/cache/writeCache.d.ts.map +0 -1
- package/dist/compiler/gems.d.ts +0 -75
- package/dist/compiler/gems.d.ts.map +0 -1
- package/dist/compiler/generator/index.d.ts +0 -7
- package/dist/compiler/generator/index.d.ts.map +0 -1
- package/dist/compiler/generator/manifest.d.ts +0 -23
- package/dist/compiler/generator/manifest.d.ts.map +0 -1
- package/dist/compiler/generator/openapi.d.ts +0 -118
- package/dist/compiler/generator/openapi.d.ts.map +0 -1
- package/dist/compiler/graph/builder.d.ts +0 -24
- package/dist/compiler/graph/builder.d.ts.map +0 -1
- package/dist/compiler/graph/index.d.ts +0 -7
- package/dist/compiler/graph/index.d.ts.map +0 -1
- package/dist/compiler/graph/schemaGraph.d.ts +0 -67
- package/dist/compiler/graph/schemaGraph.d.ts.map +0 -1
- package/dist/compiler/graph/types.d.ts +0 -203
- package/dist/compiler/graph/types.d.ts.map +0 -1
- package/dist/compiler/index.d.ts +0 -12
- package/dist/compiler/index.d.ts.map +0 -1
- package/dist/compiler/ir/index.d.ts +0 -7
- package/dist/compiler/ir/index.d.ts.map +0 -1
- package/dist/compiler/ir/pipeline.d.ts +0 -82
- package/dist/compiler/ir/pipeline.d.ts.map +0 -1
- package/dist/compiler/ir/stages.d.ts +0 -40
- package/dist/compiler/ir/stages.d.ts.map +0 -1
- package/dist/compiler/ir/visitor.d.ts +0 -98
- package/dist/compiler/ir/visitor.d.ts.map +0 -1
- package/dist/compiler/manifest/emit.d.ts +0 -21
- package/dist/compiler/manifest/emit.d.ts.map +0 -1
- package/dist/compiler/manifest/format.d.ts +0 -119
- package/dist/compiler/manifest/format.d.ts.map +0 -1
- package/dist/compiler/manifest/index.d.ts +0 -6
- package/dist/compiler/manifest/index.d.ts.map +0 -1
- package/dist/compiler/runner/createProgram.d.ts +0 -24
- package/dist/compiler/runner/createProgram.d.ts.map +0 -1
- package/dist/compiler/runner/index.d.ts +0 -5
- package/dist/compiler/runner/index.d.ts.map +0 -1
- package/dist/compiler/schema/extractAnnotations.d.ts +0 -57
- package/dist/compiler/schema/extractAnnotations.d.ts.map +0 -1
- package/dist/compiler/schema/index.d.ts +0 -10
- package/dist/compiler/schema/index.d.ts.map +0 -1
- package/dist/compiler/schema/intersectionHandler.d.ts +0 -44
- package/dist/compiler/schema/intersectionHandler.d.ts.map +0 -1
- package/dist/compiler/schema/objectHandler.d.ts +0 -146
- package/dist/compiler/schema/objectHandler.d.ts.map +0 -1
- package/dist/compiler/schema/openapi.d.ts +0 -71
- package/dist/compiler/schema/openapi.d.ts.map +0 -1
- package/dist/compiler/schema/parameters.d.ts +0 -90
- package/dist/compiler/schema/parameters.d.ts.map +0 -1
- package/dist/compiler/schema/partitioner.d.ts +0 -85
- package/dist/compiler/schema/partitioner.d.ts.map +0 -1
- package/dist/compiler/schema/primitives.d.ts +0 -68
- package/dist/compiler/schema/primitives.d.ts.map +0 -1
- package/dist/compiler/schema/queryBuilderAnalyzer.d.ts +0 -95
- package/dist/compiler/schema/queryBuilderAnalyzer.d.ts.map +0 -1
- package/dist/compiler/schema/queryBuilderSchemaBuilder.d.ts +0 -13
- package/dist/compiler/schema/queryBuilderSchemaBuilder.d.ts.map +0 -1
- package/dist/compiler/schema/serviceCallAnalyzer.d.ts +0 -102
- package/dist/compiler/schema/serviceCallAnalyzer.d.ts.map +0 -1
- package/dist/compiler/schema/splitOpenapi.d.ts +0 -46
- package/dist/compiler/schema/splitOpenapi.d.ts.map +0 -1
- package/dist/compiler/schema/typeToJsonSchema.d.ts +0 -26
- package/dist/compiler/schema/typeToJsonSchema.d.ts.map +0 -1
- package/dist/compiler/schema/types.d.ts +0 -70
- package/dist/compiler/schema/types.d.ts.map +0 -1
- package/dist/compiler/schema/unionHandler.d.ts +0 -70
- package/dist/compiler/schema/unionHandler.d.ts.map +0 -1
- package/dist/compiler/transform/dedup.d.ts +0 -35
- package/dist/compiler/transform/dedup.d.ts.map +0 -1
- package/dist/compiler/transform/flatten.d.ts +0 -50
- package/dist/compiler/transform/flatten.d.ts.map +0 -1
- package/dist/compiler/transform/index.d.ts +0 -7
- package/dist/compiler/transform/index.d.ts.map +0 -1
- package/dist/compiler/transform/inline.d.ts +0 -46
- package/dist/compiler/transform/inline.d.ts.map +0 -1
- package/dist/compiler/validation/emitPrecompiledValidators.d.ts +0 -62
- package/dist/compiler/validation/emitPrecompiledValidators.d.ts.map +0 -1
- package/dist/compiler/validation/index.d.ts +0 -5
- package/dist/compiler/validation/index.d.ts.map +0 -1
- package/dist/decorators/Auth.d.ts +0 -22
- package/dist/decorators/Auth.d.ts.map +0 -1
- package/dist/decorators/Controller.d.ts +0 -17
- package/dist/decorators/Controller.d.ts.map +0 -1
- package/dist/decorators/Public.d.ts +0 -15
- package/dist/decorators/Public.d.ts.map +0 -1
- package/dist/decorators/Use.d.ts +0 -23
- package/dist/decorators/Use.d.ts.map +0 -1
- package/dist/decorators/methods.d.ts +0 -26
- package/dist/decorators/methods.d.ts.map +0 -1
- package/dist/express.cjs +0 -1186
- package/dist/express.cjs.map +0 -1
- package/dist/express.d.ts +0 -8
- package/dist/express.d.ts.map +0 -1
- package/dist/express.js +0 -1150
- package/dist/express.js.map +0 -1
- package/dist/http.d.ts +0 -33
- package/dist/http.d.ts.map +0 -1
- package/dist/index.cjs +0 -724
- package/dist/index.cjs.map +0 -1
- package/dist/metal/applyListQuery.d.ts +0 -100
- package/dist/metal/applyListQuery.d.ts.map +0 -1
- package/dist/metal/index.cjs +0 -278
- package/dist/metal/index.cjs.map +0 -1
- package/dist/metal/index.d.ts +0 -15
- package/dist/metal/index.d.ts.map +0 -1
- package/dist/metal/index.js +0 -243
- package/dist/metal/index.js.map +0 -1
- package/dist/metal/listQuery.d.ts +0 -26
- package/dist/metal/listQuery.d.ts.map +0 -1
- package/dist/metal/queryOptions.d.ts +0 -16
- package/dist/metal/queryOptions.d.ts.map +0 -1
- package/dist/metal/readMetalBag.d.ts +0 -69
- package/dist/metal/readMetalBag.d.ts.map +0 -1
- package/dist/metal/registerMetalEntities.d.ts +0 -26
- package/dist/metal/registerMetalEntities.d.ts.map +0 -1
- package/dist/metal/schemaFromEntity.d.ts +0 -41
- package/dist/metal/schemaFromEntity.d.ts.map +0 -1
- package/dist/metal/searchWhere.d.ts +0 -97
- package/dist/metal/searchWhere.d.ts.map +0 -1
- package/dist/metal/symbolMetadata.d.ts +0 -8
- package/dist/metal/symbolMetadata.d.ts.map +0 -1
- package/dist/runtime/auth/runtime.d.ts +0 -183
- package/dist/runtime/auth/runtime.d.ts.map +0 -1
- package/dist/runtime/metadata/bucket.d.ts +0 -2
- package/dist/runtime/metadata/bucket.d.ts.map +0 -1
- package/dist/runtime/metadata/key.d.ts +0 -2
- package/dist/runtime/metadata/key.d.ts.map +0 -1
- package/dist/runtime/metadata/read.d.ts +0 -2
- package/dist/runtime/metadata/read.d.ts.map +0 -1
- package/dist/runtime/metadata/types.d.ts +0 -95
- package/dist/runtime/metadata/types.d.ts.map +0 -1
- package/dist/runtime/polyfill.d.ts +0 -2
- package/dist/runtime/polyfill.d.ts.map +0 -1
- package/dist/runtime/upload.d.ts +0 -44
- package/dist/runtime/upload.d.ts.map +0 -1
- package/dist/runtime/validation/ajv.d.ts +0 -120
- package/dist/runtime/validation/ajv.d.ts.map +0 -1
- package/dist/runtime/validation/index.d.ts +0 -11
- package/dist/runtime/validation/index.d.ts.map +0 -1
- package/dist/schema/decorators.d.ts +0 -37
- package/dist/schema/decorators.d.ts.map +0 -1
- package/dist/schema/index.cjs +0 -214
- package/dist/schema/index.cjs.map +0 -1
- package/dist/schema/index.d.ts +0 -2
- package/dist/schema/index.d.ts.map +0 -1
- package/dist/schema/index.js +0 -163
- package/dist/schema/index.js.map +0 -1
- package/dist/scripts/adorn-example.cjs +0 -404
- package/dist/scripts/adorn-example.cjs.map +0 -1
- package/dist/utils/operationId.d.ts +0 -2
- package/dist/utils/operationId.d.ts.map +0 -1
- package/dist/utils/path.d.ts +0 -2
- package/dist/utils/path.d.ts.map +0 -1
- package/dist/utils/port.d.ts +0 -9
- package/dist/utils/port.d.ts.map +0 -1
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { metadataStorage } from "../metadata/metadata-storage.js";
|
|
2
|
+
import { SchemaModifier } from "../metal-orm-integration/schema-modifier.js";
|
|
3
|
+
const pendingListRoutes = new Map();
|
|
4
|
+
export function attachPendingListRoutesToController(controllerClass) {
|
|
5
|
+
pendingListRoutes.forEach((route, method) => {
|
|
6
|
+
pendingListRoutes.delete(method);
|
|
7
|
+
const pendingMiddlewares = metadataStorage.getPendingMiddlewares(method);
|
|
8
|
+
route.middlewares.push(...pendingMiddlewares);
|
|
9
|
+
metadataStorage.clearPendingMiddlewares(method);
|
|
10
|
+
const pendingGuards = metadataStorage.getPendingGuards(method);
|
|
11
|
+
route.guards.push(...pendingGuards);
|
|
12
|
+
metadataStorage.clearPendingGuards(method);
|
|
13
|
+
const pendingParams = metadataStorage.getPendingParameters(method);
|
|
14
|
+
if (pendingParams.length > 0) {
|
|
15
|
+
route.parameters = pendingParams.map((p, index) => ({
|
|
16
|
+
name: p.name,
|
|
17
|
+
type: p.type,
|
|
18
|
+
index,
|
|
19
|
+
schema: p.schema,
|
|
20
|
+
required: p.type === "params" || p.type === "body",
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
metadataStorage.clearPendingParameters(method);
|
|
24
|
+
metadataStorage.addRoute(controllerClass, route);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function parseListOptions(pathOrOptions, options) {
|
|
28
|
+
let path = "";
|
|
29
|
+
let opts;
|
|
30
|
+
if (typeof pathOrOptions === "string") {
|
|
31
|
+
path = pathOrOptions;
|
|
32
|
+
opts = options;
|
|
33
|
+
}
|
|
34
|
+
else if (typeof pathOrOptions === "object") {
|
|
35
|
+
opts = pathOrOptions;
|
|
36
|
+
}
|
|
37
|
+
return { path, options: opts };
|
|
38
|
+
}
|
|
39
|
+
export function List(pathOrOptions, options) {
|
|
40
|
+
return function (_originalMethod, _context) {
|
|
41
|
+
if (_context.kind !== "method")
|
|
42
|
+
return;
|
|
43
|
+
const methodName = String(_context.name);
|
|
44
|
+
const parsed = parseListOptions(pathOrOptions, options);
|
|
45
|
+
let schema;
|
|
46
|
+
// Only generate schema from SchemaModifier at decoration time
|
|
47
|
+
// Entity-based schemas will be generated by OpenApiGenerator after bootstrapEntities
|
|
48
|
+
if (parsed.options?.schema) {
|
|
49
|
+
if (parsed.options.schema instanceof SchemaModifier) {
|
|
50
|
+
schema = parsed.options.schema.toOpenApi();
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
schema = parsed.options.schema;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const route = {
|
|
57
|
+
path: parsed.path,
|
|
58
|
+
method: "GET",
|
|
59
|
+
handlerName: methodName,
|
|
60
|
+
middlewares: [],
|
|
61
|
+
guards: [],
|
|
62
|
+
parameters: [],
|
|
63
|
+
entity: parsed.options?.entity,
|
|
64
|
+
schema,
|
|
65
|
+
isArray: true,
|
|
66
|
+
includeRelations: parsed.options?.includeRelations,
|
|
67
|
+
relationsDepth: parsed.options?.relationsDepth,
|
|
68
|
+
};
|
|
69
|
+
pendingListRoutes.set(_originalMethod, route);
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export function createListHelper(entity) {
|
|
73
|
+
return {
|
|
74
|
+
omit: (...fields) => new SchemaModifier(entity).omit(...fields),
|
|
75
|
+
only: (...fields) => new SchemaModifier(entity).only(...fields),
|
|
76
|
+
include: (...relations) => {
|
|
77
|
+
const modifier = new SchemaModifier(entity);
|
|
78
|
+
const schema = modifier.toOpenApi();
|
|
79
|
+
if (!schema.properties)
|
|
80
|
+
return schema;
|
|
81
|
+
schema.properties = {
|
|
82
|
+
...schema.properties,
|
|
83
|
+
...Object.fromEntries(relations.map((rel) => [
|
|
84
|
+
rel,
|
|
85
|
+
{
|
|
86
|
+
type: "array",
|
|
87
|
+
items: {
|
|
88
|
+
$ref: `#/components/schemas/${rel.charAt(0).toUpperCase() + rel.slice(1)}`,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
])),
|
|
92
|
+
};
|
|
93
|
+
return schema;
|
|
94
|
+
},
|
|
95
|
+
addComputed: (name, valueSchema) => new SchemaModifier(entity).addComputed(name, valueSchema),
|
|
96
|
+
rename: (mapping) => new SchemaModifier(entity).rename(mapping),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=list.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.decorator.js","sourceRoot":"","sources":["../../src/decorators/list.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAA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M,CAAC;QAChB,CAAC;QACD,WAAW,EAAE,CAAC,IAAY,EAAE,WAAgB,EAAE,EAAE,CAC9C,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC;QAC3D,MAAM,EAAE,CAAC,OAA+B,EAAE,EAAE,CAC1C,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;KAC7C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { MiddlewareFunction } from '../types/controller.js';
|
|
2
|
+
export declare function Use(...middlewares: MiddlewareFunction[]): (target: Function | Function, context: ClassDecoratorContext | ClassMethodDecoratorContext) => void;
|
|
3
|
+
export declare function Guard(...guards: Function[]): (target: Function | Function, context: ClassDecoratorContext | ClassMethodDecoratorContext) => void;
|
|
4
|
+
//# sourceMappingURL=middleware.decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/middleware.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAGjE,wBAAgB,GAAG,CAAC,GAAG,WAAW,EAAE,kBAAkB,EAAE,IAEpD,QAAQ,QAAQ,GAAG,QAAQ,EAC3B,SAAS,qBAAqB,GAAG,2BAA2B,KAC3D,IAAI,CAeR;AAED,wBAAgB,KAAK,CAAC,GAAG,MAAM,EAAE,QAAQ,EAAE,IAEvC,QAAQ,QAAQ,GAAG,QAAQ,EAC3B,SAAS,qBAAqB,GAAG,2BAA2B,KAC3D,IAAI,CAeR"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { metadataStorage } from '../metadata/metadata-storage.js';
|
|
2
|
+
export function Use(...middlewares) {
|
|
3
|
+
return function (target, context) {
|
|
4
|
+
if (context.kind === 'class') {
|
|
5
|
+
const controllerMeta = metadataStorage.getController(target);
|
|
6
|
+
if (controllerMeta) {
|
|
7
|
+
controllerMeta.middlewares.push(...middlewares);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
else if (context.kind === 'method') {
|
|
11
|
+
const methodFunction = target;
|
|
12
|
+
middlewares.forEach((mw) => {
|
|
13
|
+
metadataStorage.addPendingMiddleware(methodFunction, mw);
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export function Guard(...guards) {
|
|
19
|
+
return function (target, context) {
|
|
20
|
+
if (context.kind === 'class') {
|
|
21
|
+
const controllerMeta = metadataStorage.getController(target);
|
|
22
|
+
if (controllerMeta) {
|
|
23
|
+
controllerMeta.guards.push(...guards);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
else if (context.kind === 'method') {
|
|
27
|
+
const methodFunction = target;
|
|
28
|
+
guards.forEach((g) => {
|
|
29
|
+
metadataStorage.addPendingGuard(methodFunction, g);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=middleware.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.decorator.js","sourceRoot":"","sources":["../../src/decorators/middleware.decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE,MAAM,UAAU,GAAG,CAAC,GAAG,WAAiC;IACtD,OAAO,UACL,MAA2B,EAC3B,OAA4D;QAE5D,IAAI,OAAO,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC7B,MAAM,cAAc,GAAG,eAAe,CAAC,aAAa,CAAC,MAAkB,CAAC,CAAC;YACzE,IAAI,cAAc,EAAE,CAAC;gBACnB,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC;YAClD,CAAC;QACH,CAAC;aAAM,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACrC,MAAM,cAAc,GAAG,MAAkB,CAAC;YAC1C,WAAW,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE;gBACzB,eAAe,CAAC,oBAAoB,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;YAC3D,CAAC,CAAC,CAAC;QACL,CAAC;IAGH,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,GAAG,MAAkB;IACzC,OAAO,UACL,MAA2B,EAC3B,OAA4D;QAE5D,IAAI,OAAO,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC7B,MAAM,cAAc,GAAG,eAAe,CAAC,aAAa,CAAC,MAAkB,CAAC,CAAC;YACzE,IAAI,cAAc,EAAE,CAAC;gBACnB,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC;YACxC,CAAC;QACH,CAAC;aAAM,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACrC,MAAM,cAAc,GAAG,MAAkB,CAAC;YAC1C,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;gBACnB,eAAe,CAAC,eAAe,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC;YACrD,CAAC,CAAC,CAAC;QACL,CAAC;IAGH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function attachPendingResponsesToController(controllerClass: Function): void;
|
|
2
|
+
export declare function Response(status?: number, description?: string, schema?: any): (originalMethod: Function, context: ClassMethodDecoratorContext & {
|
|
3
|
+
kind: "method";
|
|
4
|
+
}) => void;
|
|
5
|
+
export declare function Header(name: string, value: string): (_originalMethod: Function, context: ClassMethodDecoratorContext & {
|
|
6
|
+
kind: "method";
|
|
7
|
+
}) => void;
|
|
8
|
+
//# sourceMappingURL=response.decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/response.decorator.ts"],"names":[],"mappings":"AAKA,wBAAgB,kCAAkC,CAChD,eAAe,EAAE,QAAQ,GACxB,IAAI,CAaN;AAED,wBAAgB,QAAQ,CACtB,MAAM,GAAE,MAAY,EACpB,WAAW,CAAC,EAAE,MAAM,EACpB,MAAM,CAAC,EAAE,GAAG,IAGV,gBAAgB,QAAQ,EACxB,SAAS,2BAA2B,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,KACxD,IAAI,CAUR;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,IAE9C,iBAAiB,QAAQ,EACzB,SAAS,2BAA2B,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,KACxD,IAAI,CAoBR"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { metadataStorage } from "../metadata/metadata-storage.js";
|
|
2
|
+
const pendingResponses = new Map();
|
|
3
|
+
export function attachPendingResponsesToController(controllerClass) {
|
|
4
|
+
pendingResponses.forEach((response, method) => {
|
|
5
|
+
pendingResponses.delete(method);
|
|
6
|
+
const routes = metadataStorage.getRoutes(controllerClass);
|
|
7
|
+
const route = routes?.find((r) => r.handlerName === String(method.name));
|
|
8
|
+
if (route) {
|
|
9
|
+
route.response = response;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
export function Response(status = 200, description, schema) {
|
|
14
|
+
return function (originalMethod, context) {
|
|
15
|
+
if (context.kind === "method") {
|
|
16
|
+
const response = {
|
|
17
|
+
status,
|
|
18
|
+
description,
|
|
19
|
+
schema,
|
|
20
|
+
};
|
|
21
|
+
pendingResponses.set(originalMethod, response);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export function Header(name, value) {
|
|
26
|
+
return function (_originalMethod, context) {
|
|
27
|
+
if (context.kind === "method") {
|
|
28
|
+
const methodName = String(context.name);
|
|
29
|
+
const controllerClass = context.constructor;
|
|
30
|
+
const routes = metadataStorage.getRoutes(controllerClass);
|
|
31
|
+
const route = routes?.find((r) => r.handlerName === methodName);
|
|
32
|
+
if (route) {
|
|
33
|
+
if (!route.middlewares) {
|
|
34
|
+
route.middlewares = [];
|
|
35
|
+
}
|
|
36
|
+
route.middlewares.push((_req, res, next) => {
|
|
37
|
+
res.setHeader(name, value);
|
|
38
|
+
next();
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=response.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response.decorator.js","sourceRoot":"","sources":["../../src/decorators/response.decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAA8B,CAAC;AAE/D,MAAM,UAAU,kCAAkC,CAChD,eAAyB;IAEzB,gBAAgB,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE;QAC5C,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAEhC,MAAM,MAAM,GAAG,eAAe,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;QAC1D,MAAM,KAAK,GAAG,MAAM,EAAE,IAAI,CACxB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,KAAK,MAAM,CAAE,MAAc,CAAC,IAAI,CAAC,CACtD,CAAC;QAEF,IAAI,KAAK,EAAE,CAAC;YACV,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAC5B,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,QAAQ,CACtB,SAAiB,GAAG,EACpB,WAAoB,EACpB,MAAY;IAEZ,OAAO,UACL,cAAwB,EACxB,OAAyD;QAEzD,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC9B,MAAM,QAAQ,GAAqB;gBACjC,MAAM;gBACN,WAAW;gBACX,MAAM;aACP,CAAC;YACF,gBAAgB,CAAC,GAAG,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;QACjD,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,IAAY,EAAE,KAAa;IAChD,OAAO,UACL,eAAyB,EACzB,OAAyD;QAEzD,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC9B,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACxC,MAAM,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;YAC5C,MAAM,MAAM,GAAG,eAAe,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;YAE1D,MAAM,KAAK,GAAG,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,KAAK,UAAU,CAAC,CAAC;YAEhE,IAAI,KAAK,EAAE,CAAC;gBACV,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;oBACvB,KAAK,CAAC,WAAW,GAAG,EAAE,CAAC;gBACzB,CAAC;gBAED,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,IAAS,EAAE,GAAQ,EAAE,IAAS,EAAE,EAAE;oBACxD,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;oBAC3B,IAAI,EAAE,CAAC;gBACT,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { RouteMetadata } from '../types/metadata.js';
|
|
3
|
+
export interface RouteOptions {
|
|
4
|
+
summary?: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
tags?: string[];
|
|
7
|
+
middlewares?: Function[];
|
|
8
|
+
guards?: Function[];
|
|
9
|
+
params?: z.ZodType<any>;
|
|
10
|
+
body?: z.ZodType<any>;
|
|
11
|
+
query?: z.ZodType<any>;
|
|
12
|
+
}
|
|
13
|
+
export declare function enhanceRouteMetadata(route: RouteMetadata, options?: RouteOptions): RouteMetadata;
|
|
14
|
+
//# sourceMappingURL=route-options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-options.d.ts","sourceRoot":"","sources":["../../src/decorators/route-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,WAAW,CAAC,EAAE,QAAQ,EAAE,CAAC;IACzB,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC;IAGpB,MAAM,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACxB,IAAI,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACtB,KAAK,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;CACxB;AAED,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,aAAa,EACpB,OAAO,CAAC,EAAE,YAAY,GACrB,aAAa,CAsBf"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export function enhanceRouteMetadata(route, options) {
|
|
2
|
+
if (!options)
|
|
3
|
+
return route;
|
|
4
|
+
const enhanced = {
|
|
5
|
+
...route,
|
|
6
|
+
summary: options.summary ?? route.summary,
|
|
7
|
+
description: options.description ?? route.description,
|
|
8
|
+
tags: options.tags ?? route.tags,
|
|
9
|
+
middlewares: [...route.middlewares, ...(options.middlewares ?? [])],
|
|
10
|
+
guards: [...route.guards, ...(options.guards ?? [])],
|
|
11
|
+
};
|
|
12
|
+
// Store schemas for later processing
|
|
13
|
+
if (options.params || options.body || options.query) {
|
|
14
|
+
enhanced.schemas = {
|
|
15
|
+
params: options.params,
|
|
16
|
+
body: options.body,
|
|
17
|
+
query: options.query,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
return enhanced;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=route-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-options.js","sourceRoot":"","sources":["../../src/decorators/route-options.ts"],"names":[],"mappings":"AAgBA,MAAM,UAAU,oBAAoB,CAClC,KAAoB,EACpB,OAAsB;IAEtB,IAAI,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IAE3B,MAAM,QAAQ,GAAkB;QAC9B,GAAG,KAAK;QACR,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO;QACzC,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,KAAK,CAAC,WAAW;QACrD,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI;QAChC,WAAW,EAAE,CAAC,GAAG,KAAK,CAAC,WAAW,EAAE,GAAG,CAAC,OAAO,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC;QACnE,MAAM,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;KACrD,CAAC;IAEF,qCAAqC;IACrC,IAAI,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QACpD,QAAQ,CAAC,OAAO,GAAG;YACjB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,KAAK,EAAE,OAAO,CAAC,KAAK;SACrB,CAAC;IACJ,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Validates request body against a Zod schema and injects validated data
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* const CreateUserSchema = z.object({ name: z.string(), email: z.string().email() });
|
|
8
|
+
*
|
|
9
|
+
* @Post()
|
|
10
|
+
* @Body(CreateUserSchema)
|
|
11
|
+
* createUser(body: z.infer<typeof CreateUserSchema>) {
|
|
12
|
+
* return { id: 1, ...body };
|
|
13
|
+
* }
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function Body<T extends z.ZodType<any>>(schema: T): (target: Function, context: ClassMethodDecoratorContext) => void;
|
|
17
|
+
/**
|
|
18
|
+
* Validates route params against a Zod schema and injects validated data
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* const IdParamsSchema = z.object({ id: z.string().uuid() });
|
|
23
|
+
*
|
|
24
|
+
* @Get('/:id')
|
|
25
|
+
* @Params(IdParamsSchema)
|
|
26
|
+
* getById(params: z.infer<typeof IdParamsSchema>) {
|
|
27
|
+
* return { id: params.id };
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function Params<T extends z.ZodType<any>>(schema: T): (target: Function, context: ClassMethodDecoratorContext) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Validates query parameters against a Zod schema and injects validated data
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* const PaginationSchema = z.object({
|
|
38
|
+
* page: z.coerce.number().default(1),
|
|
39
|
+
* limit: z.coerce.number().default(10)
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* @Get()
|
|
43
|
+
* @Query(PaginationSchema)
|
|
44
|
+
* list(query: z.infer<typeof PaginationSchema>) {
|
|
45
|
+
* return { page: query.page, limit: query.limit };
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare function Query<T extends z.ZodType<any>>(schema: T): (target: Function, context: ClassMethodDecoratorContext) => void;
|
|
50
|
+
/**
|
|
51
|
+
* Configuration for the Schema decorator
|
|
52
|
+
*/
|
|
53
|
+
export interface SchemaOptions<P extends z.ZodType<any> = z.ZodType<any>, B extends z.ZodType<any> = z.ZodType<any>, Q extends z.ZodType<any> = z.ZodType<any>> {
|
|
54
|
+
params?: P;
|
|
55
|
+
body?: B;
|
|
56
|
+
query?: Q;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Combined schema decorator - validates multiple sources and injects as single object
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* @Put('/:id')
|
|
64
|
+
* @Schema({
|
|
65
|
+
* params: z.object({ id: z.string() }),
|
|
66
|
+
* body: z.object({ name: z.string() })
|
|
67
|
+
* })
|
|
68
|
+
* update(input: { params: { id: string }, body: { name: string } }) {
|
|
69
|
+
* return { id: input.params.id, name: input.body.name };
|
|
70
|
+
* }
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export declare function Schema<P extends z.ZodType<any>, B extends z.ZodType<any>, Q extends z.ZodType<any>>(options: SchemaOptions<P, B, Q>): (target: Function, context: ClassMethodDecoratorContext) => void;
|
|
74
|
+
/**
|
|
75
|
+
* Type helper for Schema decorator input
|
|
76
|
+
*/
|
|
77
|
+
export type SchemaInput<T extends SchemaOptions> = {
|
|
78
|
+
params: T['params'] extends z.ZodType<any> ? z.infer<T['params']> : undefined;
|
|
79
|
+
body: T['body'] extends z.ZodType<any> ? z.infer<T['body']> : undefined;
|
|
80
|
+
query: T['query'] extends z.ZodType<any> ? z.infer<T['query']> : undefined;
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=schema.decorator.d.ts.map
|
|
@@ -0,0 +1 @@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C,EACxB,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EACxB,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAC1B,OAAO,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,IAEzB,QAAQ,QAAQ,EAChB,SAAS,2BAA2B,KACrC,IAAI,CAgCV;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,aAAa,IAAI;IAC/C,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,GAAG,SAAS,CAAC;IAC9E,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC;IACxE,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;CAC9E,CAAC"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { metadataStorage } from '../metadata/metadata-storage.js';
|
|
2
|
+
import { createZodValidationMiddleware } from '../validation/zod-adapter.js';
|
|
3
|
+
/**
|
|
4
|
+
* Validates request body against a Zod schema and injects validated data
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const CreateUserSchema = z.object({ name: z.string(), email: z.string().email() });
|
|
9
|
+
*
|
|
10
|
+
* @Post()
|
|
11
|
+
* @Body(CreateUserSchema)
|
|
12
|
+
* createUser(body: z.infer<typeof CreateUserSchema>) {
|
|
13
|
+
* return { id: 1, ...body };
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export function Body(schema) {
|
|
18
|
+
return function (target, context) {
|
|
19
|
+
if (context.kind !== 'method')
|
|
20
|
+
return;
|
|
21
|
+
// Add validation middleware
|
|
22
|
+
metadataStorage.addPendingMiddleware(target, createZodValidationMiddleware('body', schema));
|
|
23
|
+
// Register parameter for injection
|
|
24
|
+
metadataStorage.addPendingParameter(target, {
|
|
25
|
+
name: 'body',
|
|
26
|
+
type: 'body',
|
|
27
|
+
schema,
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Validates route params against a Zod schema and injects validated data
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* const IdParamsSchema = z.object({ id: z.string().uuid() });
|
|
37
|
+
*
|
|
38
|
+
* @Get('/:id')
|
|
39
|
+
* @Params(IdParamsSchema)
|
|
40
|
+
* getById(params: z.infer<typeof IdParamsSchema>) {
|
|
41
|
+
* return { id: params.id };
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export function Params(schema) {
|
|
46
|
+
return function (target, context) {
|
|
47
|
+
if (context.kind !== 'method')
|
|
48
|
+
return;
|
|
49
|
+
metadataStorage.addPendingMiddleware(target, createZodValidationMiddleware('params', schema));
|
|
50
|
+
metadataStorage.addPendingParameter(target, {
|
|
51
|
+
name: 'params',
|
|
52
|
+
type: 'params',
|
|
53
|
+
schema,
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Validates query parameters against a Zod schema and injects validated data
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* const PaginationSchema = z.object({
|
|
63
|
+
* page: z.coerce.number().default(1),
|
|
64
|
+
* limit: z.coerce.number().default(10)
|
|
65
|
+
* });
|
|
66
|
+
*
|
|
67
|
+
* @Get()
|
|
68
|
+
* @Query(PaginationSchema)
|
|
69
|
+
* list(query: z.infer<typeof PaginationSchema>) {
|
|
70
|
+
* return { page: query.page, limit: query.limit };
|
|
71
|
+
* }
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export function Query(schema) {
|
|
75
|
+
return function (target, context) {
|
|
76
|
+
if (context.kind !== 'method')
|
|
77
|
+
return;
|
|
78
|
+
metadataStorage.addPendingMiddleware(target, createZodValidationMiddleware('query', schema));
|
|
79
|
+
metadataStorage.addPendingParameter(target, {
|
|
80
|
+
name: 'query',
|
|
81
|
+
type: 'query',
|
|
82
|
+
schema,
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Combined schema decorator - validates multiple sources and injects as single object
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```ts
|
|
91
|
+
* @Put('/:id')
|
|
92
|
+
* @Schema({
|
|
93
|
+
* params: z.object({ id: z.string() }),
|
|
94
|
+
* body: z.object({ name: z.string() })
|
|
95
|
+
* })
|
|
96
|
+
* update(input: { params: { id: string }, body: { name: string } }) {
|
|
97
|
+
* return { id: input.params.id, name: input.body.name };
|
|
98
|
+
* }
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
export function Schema(options) {
|
|
102
|
+
return function (target, context) {
|
|
103
|
+
if (context.kind !== 'method')
|
|
104
|
+
return;
|
|
105
|
+
// Add validation middlewares for each schema
|
|
106
|
+
if (options.params) {
|
|
107
|
+
metadataStorage.addPendingMiddleware(target, createZodValidationMiddleware('params', options.params));
|
|
108
|
+
}
|
|
109
|
+
if (options.body) {
|
|
110
|
+
metadataStorage.addPendingMiddleware(target, createZodValidationMiddleware('body', options.body));
|
|
111
|
+
}
|
|
112
|
+
if (options.query) {
|
|
113
|
+
metadataStorage.addPendingMiddleware(target, createZodValidationMiddleware('query', options.query));
|
|
114
|
+
}
|
|
115
|
+
// Register combined parameter
|
|
116
|
+
metadataStorage.addPendingParameter(target, {
|
|
117
|
+
name: 'input',
|
|
118
|
+
type: 'combined',
|
|
119
|
+
schema: options,
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=schema.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.decorator.js","sourceRoot":"","sources":["../../src/decorators/schema.decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAE7E;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,IAAI,CAA2B,MAAS;IACpD,OAAO,UACH,MAAgB,EAChB,OAAoC;QAEpC,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO;QAEtC,4BAA4B;QAC5B,eAAe,CAAC,oBAAoB,CAChC,MAAM,EACN,6BAA6B,CAAC,MAAM,EAAE,MAAM,CAAC,CAChD,CAAC;QAEF,mCAAmC;QACnC,eAAe,CAAC,mBAAmB,CAAC,MAAM,EAAE;YACxC,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,MAAM;YACZ,MAAM;SACT,CAAC,CAAC;IACP,CAAC,CAAC;AACN,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,MAAM,CAA2B,MAAS;IACtD,OAAO,UACH,MAAgB,EAChB,OAAoC;QAEpC,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO;QAEtC,eAAe,CAAC,oBAAoB,CAChC,MAAM,EACN,6BAA6B,CAAC,QAAQ,EAAE,MAAM,CAAC,CAClD,CAAC;QAEF,eAAe,CAAC,mBAAmB,CAAC,MAAM,EAAE;YACxC,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,QAAQ;YACd,MAAM;SACT,CAAC,CAAC;IACP,CAAC,CAAC;AACN,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG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|
1
|
+
type UpdateOptions = {
|
|
2
|
+
entity?: any;
|
|
3
|
+
schema?: any;
|
|
4
|
+
};
|
|
5
|
+
export declare function attachPendingUpdateRoutesToController(controllerClass: Function): void;
|
|
6
|
+
export declare function Update(pathOrOptions?: string | UpdateOptions, options?: UpdateOptions): (_originalMethod: Function, _context: ClassMethodDecoratorContext) => void;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=update.decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/update.decorator.ts"],"names":[],"mappings":"AAGA,KAAK,aAAa,GAAG;IACnB,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,MAAM,CAAC,EAAE,GAAG,CAAC;CACd,CAAC;AAIF,wBAAgB,qCAAqC,CACnD,eAAe,EAAE,QAAQ,GACxB,IAAI,CA0BN;AAmBD,wBAAgB,MAAM,CACpB,aAAa,CAAC,EAAE,MAAM,GAAG,aAAa,EACtC,OAAO,CAAC,EAAE,aAAa,IAGrB,iBAAiB,QAAQ,EACzB,UAAU,2BAA2B,KACpC,IAAI,CA2BR"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { metadataStorage } from "../metadata/metadata-storage.js";
|
|
2
|
+
const pendingUpdateRoutes = new Map();
|
|
3
|
+
export function attachPendingUpdateRoutesToController(controllerClass) {
|
|
4
|
+
pendingUpdateRoutes.forEach((route, method) => {
|
|
5
|
+
pendingUpdateRoutes.delete(method);
|
|
6
|
+
const pendingMiddlewares = metadataStorage.getPendingMiddlewares(method);
|
|
7
|
+
route.middlewares.push(...pendingMiddlewares);
|
|
8
|
+
metadataStorage.clearPendingMiddlewares(method);
|
|
9
|
+
const pendingGuards = metadataStorage.getPendingGuards(method);
|
|
10
|
+
route.guards.push(...pendingGuards);
|
|
11
|
+
metadataStorage.clearPendingGuards(method);
|
|
12
|
+
const pendingParams = metadataStorage.getPendingParameters(method);
|
|
13
|
+
if (pendingParams.length > 0) {
|
|
14
|
+
route.parameters = pendingParams.map((p, index) => ({
|
|
15
|
+
name: p.name,
|
|
16
|
+
type: p.type,
|
|
17
|
+
index,
|
|
18
|
+
schema: p.schema,
|
|
19
|
+
required: p.type === "params" || p.type === "body",
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
22
|
+
metadataStorage.clearPendingParameters(method);
|
|
23
|
+
metadataStorage.addRoute(controllerClass, route);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
function parseUpdateOptions(pathOrOptions, options) {
|
|
27
|
+
let path = "";
|
|
28
|
+
let opts;
|
|
29
|
+
if (typeof pathOrOptions === "string") {
|
|
30
|
+
path = pathOrOptions;
|
|
31
|
+
opts = options;
|
|
32
|
+
}
|
|
33
|
+
else if (typeof pathOrOptions === "object") {
|
|
34
|
+
opts = pathOrOptions;
|
|
35
|
+
}
|
|
36
|
+
return { path, options: opts };
|
|
37
|
+
}
|
|
38
|
+
export function Update(pathOrOptions, options) {
|
|
39
|
+
return function (_originalMethod, _context) {
|
|
40
|
+
if (_context.kind !== "method")
|
|
41
|
+
return;
|
|
42
|
+
const methodName = String(_context.name);
|
|
43
|
+
const parsed = parseUpdateOptions(pathOrOptions, options);
|
|
44
|
+
let schema;
|
|
45
|
+
// Store schema only if explicitly provided
|
|
46
|
+
// Entity-based schemas will be generated by OpenApiGenerator after bootstrapEntities
|
|
47
|
+
if (parsed.options?.schema) {
|
|
48
|
+
schema = parsed.options.schema;
|
|
49
|
+
}
|
|
50
|
+
const route = {
|
|
51
|
+
path: parsed.path,
|
|
52
|
+
method: "PUT",
|
|
53
|
+
handlerName: methodName,
|
|
54
|
+
middlewares: [],
|
|
55
|
+
guards: [],
|
|
56
|
+
parameters: [],
|
|
57
|
+
entity: parsed.options?.entity,
|
|
58
|
+
schema,
|
|
59
|
+
};
|
|
60
|
+
pendingUpdateRoutes.set(_originalMethod, route);
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
//# sourceM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,MAAM;YAC9B,MAAM;SACP,CAAC;QAEF,mBAAmB,CAAC,GAAG,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;IAClD,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export * from "./
|
|
7
|
-
export
|
|
8
|
-
export {
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export {
|
|
12
|
-
export { isPortAvailable, findProcessOnPort, killProcess, waitForPort } from "./utils/port.js";
|
|
13
|
-
export type { ProcessInfo } from "./utils/port.js";
|
|
1
|
+
export * from "./decorators/index.js";
|
|
2
|
+
export { ExpressAdapter, HttpError, isHttpError, } from "./core/express-adapter.js";
|
|
3
|
+
export { metadataStorage } from "./metadata/metadata-storage.js";
|
|
4
|
+
export * from "./types/controller.js";
|
|
5
|
+
export * from "./types/metadata.js";
|
|
6
|
+
export * from "./types/openapi.js";
|
|
7
|
+
export * from "./types/common.js";
|
|
8
|
+
export { OpenApiGenerator } from "./openapi/openapi-generator.js";
|
|
9
|
+
export { setupSwaggerUi, type SwaggerUiOptions } from "./openapi/swagger-ui.js";
|
|
10
|
+
export * from "./metal-orm-integration/index.js";
|
|
11
|
+
export { createZodValidationMiddleware, formatZodErrors, type InferSchema, } from "./validation/zod-adapter.js";
|
|
14
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,uBAAuB,CAAC;AAGtC,OAAO,EACL,cAAc,EACd,SAAS,EACT,WAAW,GACZ,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAGjE,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAGlC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,KAAK,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAGhF,cAAc,kCAAkC,CAAC;AAGjD,OAAO,EACL,6BAA6B,EAC7B,eAAe,EACf,KAAK,WAAW,GACjB,MAAM,6BAA6B,CAAC"}
|