adorn-api 1.0.3 → 1.0.5
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/README.md +766 -51
- package/dist/adapter/express/bootstrap.d.ts +24 -0
- package/dist/adapter/express/bootstrap.d.ts.map +1 -0
- package/dist/adapter/express/index.d.ts +41 -0
- package/dist/adapter/express/index.d.ts.map +1 -0
- package/dist/adapter/express/merge.d.ts +28 -0
- package/dist/adapter/express/merge.d.ts.map +1 -0
- package/dist/cli.cjs +1571 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +1552 -2
- package/dist/cli.js.map +1 -1
- package/dist/compiler/analyze/scanControllers.d.ts +35 -0
- package/dist/compiler/analyze/scanControllers.d.ts.map +1 -0
- package/dist/compiler/cache/isStale.d.ts +20 -0
- package/dist/compiler/cache/isStale.d.ts.map +1 -0
- package/dist/compiler/cache/loadArtifacts.d.ts +113 -0
- package/dist/compiler/cache/loadArtifacts.d.ts.map +1 -0
- package/dist/compiler/cache/schema.d.ts +18 -0
- package/dist/compiler/cache/schema.d.ts.map +1 -0
- package/dist/compiler/cache/writeCache.d.ts +8 -0
- package/dist/compiler/cache/writeCache.d.ts.map +1 -0
- package/dist/compiler/manifest/emit.d.ts +7 -0
- package/dist/compiler/manifest/emit.d.ts.map +1 -0
- package/dist/compiler/manifest/format.d.ts +76 -0
- package/dist/compiler/manifest/format.d.ts.map +1 -0
- package/dist/compiler/runner/createProgram.d.ts +8 -0
- package/dist/compiler/runner/createProgram.d.ts.map +1 -0
- package/dist/compiler/schema/extractAnnotations.d.ts +10 -0
- package/dist/compiler/schema/extractAnnotations.d.ts.map +1 -0
- package/dist/compiler/schema/openapi.d.ts +19 -0
- package/dist/compiler/schema/openapi.d.ts.map +1 -0
- package/dist/compiler/schema/typeToJsonSchema.d.ts +49 -0
- package/dist/compiler/schema/typeToJsonSchema.d.ts.map +1 -0
- package/dist/compiler/validation/emitPrecompiledValidators.d.ts +46 -0
- package/dist/compiler/validation/emitPrecompiledValidators.d.ts.map +1 -0
- package/dist/decorators/Auth.d.ts +5 -0
- package/dist/decorators/Auth.d.ts.map +1 -0
- package/dist/decorators/Controller.d.ts +2 -0
- package/dist/decorators/Controller.d.ts.map +1 -0
- package/dist/decorators/Public.d.ts +2 -0
- package/dist/decorators/Public.d.ts.map +1 -0
- package/dist/decorators/Use.d.ts +5 -0
- package/dist/decorators/Use.d.ts.map +1 -0
- package/dist/decorators/index.d.ts +5 -6
- package/dist/decorators/index.d.ts.map +1 -1
- package/dist/decorators/methods.d.ts +5 -145
- package/dist/decorators/methods.d.ts.map +1 -1
- package/dist/express.cjs +775 -0
- package/dist/express.cjs.map +1 -0
- package/dist/express.d.ts +6 -1
- package/dist/express.d.ts.map +1 -1
- package/dist/express.js +738 -1
- package/dist/express.js.map +1 -1
- package/dist/http.d.ts +29 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/index.cjs +573 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +12 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +490 -26
- package/dist/index.js.map +1 -1
- package/dist/metal/index.cjs +219 -0
- package/dist/metal/index.cjs.map +1 -0
- package/dist/metal/index.d.ts +6 -0
- package/dist/metal/index.d.ts.map +1 -0
- package/dist/metal/index.js +188 -0
- package/dist/metal/index.js.map +1 -0
- package/dist/metal/readMetalBag.d.ts +33 -0
- package/dist/metal/readMetalBag.d.ts.map +1 -0
- package/dist/metal/registerMetalEntities.d.ts +6 -0
- package/dist/metal/registerMetalEntities.d.ts.map +1 -0
- package/dist/metal/schemaFromEntity.d.ts +11 -0
- package/dist/metal/schemaFromEntity.d.ts.map +1 -0
- package/dist/metal/symbolMetadata.d.ts +2 -0
- package/dist/metal/symbolMetadata.d.ts.map +1 -0
- package/dist/runtime/auth/runtime.d.ts +34 -0
- package/dist/runtime/auth/runtime.d.ts.map +1 -0
- package/dist/runtime/metadata/bucket.d.ts +3 -0
- package/dist/runtime/metadata/bucket.d.ts.map +1 -0
- package/dist/runtime/metadata/key.d.ts +2 -0
- package/dist/runtime/metadata/key.d.ts.map +1 -0
- package/dist/runtime/metadata/read.d.ts +3 -0
- package/dist/runtime/metadata/read.d.ts.map +1 -0
- package/dist/runtime/metadata/types.d.ts +21 -0
- package/dist/runtime/metadata/types.d.ts.map +1 -0
- package/dist/runtime/polyfill.d.ts +2 -0
- package/dist/runtime/polyfill.d.ts.map +1 -0
- package/dist/runtime/upload.d.ts +7 -0
- package/dist/runtime/upload.d.ts.map +1 -0
- package/dist/runtime/validation/ajv.d.ts +20 -0
- package/dist/runtime/validation/ajv.d.ts.map +1 -0
- package/dist/runtime/validation/index.d.ts +2 -0
- package/dist/runtime/validation/index.d.ts.map +1 -0
- package/dist/schema/decorators.d.ts +37 -0
- package/dist/schema/decorators.d.ts.map +1 -0
- package/dist/schema/index.cjs +214 -0
- package/dist/schema/index.cjs.map +1 -0
- package/dist/schema/index.d.ts +2 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +163 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/scripts/adorn-example.cjs +148 -0
- package/dist/scripts/adorn-example.cjs.map +1 -0
- package/dist/utils/operationId.d.ts +2 -0
- package/dist/utils/operationId.d.ts.map +1 -0
- package/dist/utils/path.d.ts +2 -0
- package/dist/utils/path.d.ts.map +1 -0
- package/package.json +92 -57
- package/dist/adapters/express/createApp.d.ts +0 -158
- package/dist/adapters/express/createApp.d.ts.map +0 -1
- package/dist/adapters/express/createApp.js +0 -141
- package/dist/adapters/express/createApp.js.map +0 -1
- package/dist/adapters/express/index.d.ts +0 -7
- package/dist/adapters/express/index.d.ts.map +0 -1
- package/dist/adapters/express/index.js +0 -7
- package/dist/adapters/express/index.js.map +0 -1
- package/dist/adapters/express/middleware/errorHandler.d.ts +0 -194
- package/dist/adapters/express/middleware/errorHandler.d.ts.map +0 -1
- package/dist/adapters/express/middleware/errorHandler.js +0 -167
- package/dist/adapters/express/middleware/errorHandler.js.map +0 -1
- package/dist/adapters/express/middleware/requestContext.d.ts +0 -2
- package/dist/adapters/express/middleware/requestContext.d.ts.map +0 -1
- package/dist/adapters/express/middleware/requestContext.js +0 -3
- package/dist/adapters/express/middleware/requestContext.js.map +0 -1
- package/dist/adapters/express/router.d.ts +0 -10
- package/dist/adapters/express/router.d.ts.map +0 -1
- package/dist/adapters/express/router.js +0 -105
- package/dist/adapters/express/router.js.map +0 -1
- package/dist/adapters/express/swagger/index.d.ts +0 -2
- package/dist/adapters/express/swagger/index.d.ts.map +0 -1
- package/dist/adapters/express/swagger/index.js +0 -2
- package/dist/adapters/express/swagger/index.js.map +0 -1
- package/dist/adapters/express/swagger/serve.d.ts +0 -12
- package/dist/adapters/express/swagger/serve.d.ts.map +0 -1
- package/dist/adapters/express/swagger/serve.js +0 -72
- package/dist/adapters/express/swagger/serve.js.map +0 -1
- package/dist/adapters/express/transport/request.d.ts +0 -4
- package/dist/adapters/express/transport/request.d.ts.map +0 -1
- package/dist/adapters/express/transport/request.js +0 -12
- package/dist/adapters/express/transport/request.js.map +0 -1
- package/dist/adapters/express/transport/response.d.ts +0 -5
- package/dist/adapters/express/transport/response.d.ts.map +0 -1
- package/dist/adapters/express/transport/response.js +0 -36
- package/dist/adapters/express/transport/response.js.map +0 -1
- package/dist/cli/commands/dev.d.ts +0 -2
- package/dist/cli/commands/dev.d.ts.map +0 -1
- package/dist/cli/commands/dev.js +0 -3
- package/dist/cli/commands/dev.js.map +0 -1
- package/dist/cli/commands/gen.d.ts +0 -2
- package/dist/cli/commands/gen.d.ts.map +0 -1
- package/dist/cli/commands/gen.js +0 -3
- package/dist/cli/commands/gen.js.map +0 -1
- package/dist/cli/main.d.ts +0 -2
- package/dist/cli/main.d.ts.map +0 -1
- package/dist/cli/main.js +0 -3
- package/dist/cli/main.js.map +0 -1
- package/dist/compiler/config/defaults.d.ts +0 -2
- package/dist/compiler/config/defaults.d.ts.map +0 -1
- package/dist/compiler/config/defaults.js +0 -3
- package/dist/compiler/config/defaults.js.map +0 -1
- package/dist/compiler/config/loadConfig.d.ts +0 -2
- package/dist/compiler/config/loadConfig.d.ts.map +0 -1
- package/dist/compiler/config/loadConfig.js +0 -3
- package/dist/compiler/config/loadConfig.js.map +0 -1
- package/dist/compiler/diagnostics/errors.d.ts +0 -2
- package/dist/compiler/diagnostics/errors.d.ts.map +0 -1
- package/dist/compiler/diagnostics/errors.js +0 -3
- package/dist/compiler/diagnostics/errors.js.map +0 -1
- package/dist/compiler/emit/openapi.d.ts +0 -2
- package/dist/compiler/emit/openapi.d.ts.map +0 -1
- package/dist/compiler/emit/openapi.js +0 -3
- package/dist/compiler/emit/openapi.js.map +0 -1
- package/dist/compiler/emit/routes.d.ts +0 -2
- package/dist/compiler/emit/routes.d.ts.map +0 -1
- package/dist/compiler/emit/routes.js +0 -3
- package/dist/compiler/emit/routes.js.map +0 -1
- package/dist/compiler/program/loadTsProgram.d.ts +0 -2
- package/dist/compiler/program/loadTsProgram.d.ts.map +0 -1
- package/dist/compiler/program/loadTsProgram.js +0 -3
- package/dist/compiler/program/loadTsProgram.js.map +0 -1
- package/dist/compiler/scan/actions.d.ts +0 -2
- package/dist/compiler/scan/actions.d.ts.map +0 -1
- package/dist/compiler/scan/actions.js +0 -3
- package/dist/compiler/scan/actions.js.map +0 -1
- package/dist/compiler/scan/controllers.d.ts +0 -2
- package/dist/compiler/scan/controllers.d.ts.map +0 -1
- package/dist/compiler/scan/controllers.js +0 -3
- package/dist/compiler/scan/controllers.js.map +0 -1
- package/dist/compiler/scan/types.d.ts +0 -2
- package/dist/compiler/scan/types.d.ts.map +0 -1
- package/dist/compiler/scan/types.js +0 -3
- package/dist/compiler/scan/types.js.map +0 -1
- package/dist/contracts/context.d.ts +0 -10
- package/dist/contracts/context.d.ts.map +0 -1
- package/dist/contracts/context.js +0 -2
- package/dist/contracts/context.js.map +0 -1
- package/dist/contracts/errors.d.ts +0 -22
- package/dist/contracts/errors.d.ts.map +0 -1
- package/dist/contracts/errors.js +0 -2
- package/dist/contracts/errors.js.map +0 -1
- package/dist/contracts/http.d.ts +0 -2
- package/dist/contracts/http.d.ts.map +0 -1
- package/dist/contracts/http.js +0 -3
- package/dist/contracts/http.js.map +0 -1
- package/dist/contracts/middleware.d.ts +0 -2
- package/dist/contracts/middleware.d.ts.map +0 -1
- package/dist/contracts/middleware.js +0 -3
- package/dist/contracts/middleware.js.map +0 -1
- package/dist/contracts/openapi-v3.d.ts +0 -538
- package/dist/contracts/openapi-v3.d.ts.map +0 -1
- package/dist/contracts/openapi-v3.js +0 -2
- package/dist/contracts/openapi-v3.js.map +0 -1
- package/dist/contracts/openapi.d.ts +0 -2
- package/dist/contracts/openapi.d.ts.map +0 -1
- package/dist/contracts/openapi.js +0 -2
- package/dist/contracts/openapi.js.map +0 -1
- package/dist/contracts/reply.d.ts +0 -119
- package/dist/contracts/reply.d.ts.map +0 -1
- package/dist/contracts/reply.js +0 -43
- package/dist/contracts/reply.js.map +0 -1
- package/dist/contracts/response-types.d.ts +0 -40
- package/dist/contracts/response-types.d.ts.map +0 -1
- package/dist/contracts/response-types.js +0 -2
- package/dist/contracts/response-types.js.map +0 -1
- package/dist/contracts/responses.d.ts +0 -98
- package/dist/contracts/responses.d.ts.map +0 -1
- package/dist/contracts/responses.js +0 -2
- package/dist/contracts/responses.js.map +0 -1
- package/dist/contracts/route-options.d.ts +0 -155
- package/dist/contracts/route-options.d.ts.map +0 -1
- package/dist/contracts/route-options.js +0 -2
- package/dist/contracts/route-options.js.map +0 -1
- package/dist/contracts/route-typing.d.ts +0 -25
- package/dist/contracts/route-typing.d.ts.map +0 -1
- package/dist/contracts/route-typing.js +0 -2
- package/dist/contracts/route-typing.js.map +0 -1
- package/dist/contracts/validator.d.ts +0 -146
- package/dist/contracts/validator.d.ts.map +0 -1
- package/dist/contracts/validator.js +0 -2
- package/dist/contracts/validator.js.map +0 -1
- package/dist/core/binding/binder.d.ts +0 -74
- package/dist/core/binding/binder.d.ts.map +0 -1
- package/dist/core/binding/binder.js +0 -161
- package/dist/core/binding/binder.js.map +0 -1
- package/dist/core/binding/coerce/arrays.d.ts +0 -7
- package/dist/core/binding/coerce/arrays.d.ts.map +0 -1
- package/dist/core/binding/coerce/arrays.js +0 -28
- package/dist/core/binding/coerce/arrays.js.map +0 -1
- package/dist/core/binding/coerce/csv.d.ts +0 -2
- package/dist/core/binding/coerce/csv.d.ts.map +0 -1
- package/dist/core/binding/coerce/csv.js +0 -7
- package/dist/core/binding/coerce/csv.js.map +0 -1
- package/dist/core/binding/coerce/objects.d.ts +0 -2
- package/dist/core/binding/coerce/objects.d.ts.map +0 -1
- package/dist/core/binding/coerce/objects.js +0 -3
- package/dist/core/binding/coerce/objects.js.map +0 -1
- package/dist/core/binding/coerce/primitives.d.ts +0 -70
- package/dist/core/binding/coerce/primitives.d.ts.map +0 -1
- package/dist/core/binding/coerce/primitives.js +0 -88
- package/dist/core/binding/coerce/primitives.js.map +0 -1
- package/dist/core/binding/index.d.ts +0 -2
- package/dist/core/binding/index.d.ts.map +0 -1
- package/dist/core/binding/index.js +0 -2
- package/dist/core/binding/index.js.map +0 -1
- package/dist/core/binding/rules/inferFromHttpMethod.d.ts +0 -6
- package/dist/core/binding/rules/inferFromHttpMethod.d.ts.map +0 -1
- package/dist/core/binding/rules/inferFromHttpMethod.js +0 -11
- package/dist/core/binding/rules/inferFromHttpMethod.js.map +0 -1
- package/dist/core/binding/rules/inferFromPath.d.ts +0 -2
- package/dist/core/binding/rules/inferFromPath.d.ts.map +0 -1
- package/dist/core/binding/rules/inferFromPath.js +0 -9
- package/dist/core/binding/rules/inferFromPath.js.map +0 -1
- package/dist/core/binding/rules/wrappers.d.ts +0 -2
- package/dist/core/binding/rules/wrappers.d.ts.map +0 -1
- package/dist/core/binding/rules/wrappers.js +0 -3
- package/dist/core/binding/rules/wrappers.js.map +0 -1
- package/dist/core/errors/http-error.d.ts +0 -63
- package/dist/core/errors/http-error.d.ts.map +0 -1
- package/dist/core/errors/http-error.js +0 -71
- package/dist/core/errors/http-error.js.map +0 -1
- package/dist/core/errors/index.d.ts +0 -4
- package/dist/core/errors/index.d.ts.map +0 -1
- package/dist/core/errors/index.js +0 -4
- package/dist/core/errors/index.js.map +0 -1
- package/dist/core/errors/problem.d.ts +0 -3
- package/dist/core/errors/problem.d.ts.map +0 -1
- package/dist/core/errors/problem.js +0 -33
- package/dist/core/errors/problem.js.map +0 -1
- package/dist/core/errors/validation-error.d.ts +0 -73
- package/dist/core/errors/validation-error.d.ts.map +0 -1
- package/dist/core/errors/validation-error.js +0 -82
- package/dist/core/errors/validation-error.js.map +0 -1
- package/dist/core/openapi/buildOpenApi.d.ts +0 -79
- package/dist/core/openapi/buildOpenApi.d.ts.map +0 -1
- package/dist/core/openapi/buildOpenApi.js +0 -196
- package/dist/core/openapi/buildOpenApi.js.map +0 -1
- package/dist/core/openapi/index.d.ts +0 -2
- package/dist/core/openapi/index.d.ts.map +0 -1
- package/dist/core/openapi/index.js +0 -2
- package/dist/core/openapi/index.js.map +0 -1
- package/dist/core/openapi/schema/formats.d.ts +0 -2
- package/dist/core/openapi/schema/formats.d.ts.map +0 -1
- package/dist/core/openapi/schema/formats.js +0 -3
- package/dist/core/openapi/schema/formats.js.map +0 -1
- package/dist/core/openapi/schema/registry.d.ts +0 -9
- package/dist/core/openapi/schema/registry.d.ts.map +0 -1
- package/dist/core/openapi/schema/registry.js +0 -21
- package/dist/core/openapi/schema/registry.js.map +0 -1
- package/dist/core/openapi/schema/schemaModel.d.ts +0 -2
- package/dist/core/openapi/schema/schemaModel.d.ts.map +0 -1
- package/dist/core/openapi/schema/schemaModel.js +0 -3
- package/dist/core/openapi/schema/schemaModel.js.map +0 -1
- package/dist/core/openapi/schema/schemaRegistry.d.ts +0 -2
- package/dist/core/openapi/schema/schemaRegistry.d.ts.map +0 -1
- package/dist/core/openapi/schema/schemaRegistry.js +0 -3
- package/dist/core/openapi/schema/schemaRegistry.js.map +0 -1
- package/dist/core/openapi/schema/toOpenApi.d.ts +0 -4
- package/dist/core/openapi/schema/toOpenApi.d.ts.map +0 -1
- package/dist/core/openapi/schema/toOpenApi.js +0 -82
- package/dist/core/openapi/schema/toOpenApi.js.map +0 -1
- package/dist/core/pipeline/compose.d.ts +0 -2
- package/dist/core/pipeline/compose.d.ts.map +0 -1
- package/dist/core/pipeline/compose.js +0 -3
- package/dist/core/pipeline/compose.js.map +0 -1
- package/dist/core/pipeline/errorMap.d.ts +0 -2
- package/dist/core/pipeline/errorMap.d.ts.map +0 -1
- package/dist/core/pipeline/errorMap.js +0 -3
- package/dist/core/pipeline/errorMap.js.map +0 -1
- package/dist/core/pipeline/invoke.d.ts +0 -2
- package/dist/core/pipeline/invoke.d.ts.map +0 -1
- package/dist/core/pipeline/invoke.js +0 -3
- package/dist/core/pipeline/invoke.js.map +0 -1
- package/dist/core/pipeline/result.d.ts +0 -2
- package/dist/core/pipeline/result.d.ts.map +0 -1
- package/dist/core/pipeline/result.js +0 -3
- package/dist/core/pipeline/result.js.map +0 -1
- package/dist/core/registry/buildRegistry.d.ts +0 -3
- package/dist/core/registry/buildRegistry.d.ts.map +0 -1
- package/dist/core/registry/buildRegistry.js +0 -105
- package/dist/core/registry/buildRegistry.js.map +0 -1
- package/dist/core/registry/conflicts.d.ts +0 -6
- package/dist/core/registry/conflicts.d.ts.map +0 -1
- package/dist/core/registry/conflicts.js +0 -21
- package/dist/core/registry/conflicts.js.map +0 -1
- package/dist/core/registry/index.d.ts +0 -5
- package/dist/core/registry/index.d.ts.map +0 -1
- package/dist/core/registry/index.js +0 -5
- package/dist/core/registry/index.js.map +0 -1
- package/dist/core/registry/normalize.d.ts +0 -3
- package/dist/core/registry/normalize.d.ts.map +0 -1
- package/dist/core/registry/normalize.js +0 -24
- package/dist/core/registry/normalize.js.map +0 -1
- package/dist/core/registry/types.d.ts +0 -225
- package/dist/core/registry/types.d.ts.map +0 -1
- package/dist/core/registry/types.js +0 -2
- package/dist/core/registry/types.js.map +0 -1
- package/dist/core/reply/index.d.ts +0 -3
- package/dist/core/reply/index.d.ts.map +0 -1
- package/dist/core/reply/index.js +0 -3
- package/dist/core/reply/index.js.map +0 -1
- package/dist/core/reply/reply.d.ts +0 -102
- package/dist/core/reply/reply.d.ts.map +0 -1
- package/dist/core/reply/reply.js +0 -105
- package/dist/core/reply/reply.js.map +0 -1
- package/dist/core/reply/typed.d.ts +0 -161
- package/dist/core/reply/typed.d.ts.map +0 -1
- package/dist/core/reply/typed.js +0 -154
- package/dist/core/reply/typed.js.map +0 -1
- package/dist/core/responses/helpers.d.ts +0 -10
- package/dist/core/responses/helpers.d.ts.map +0 -1
- package/dist/core/responses/helpers.js +0 -8
- package/dist/core/responses/helpers.js.map +0 -1
- package/dist/core/responses/index.d.ts +0 -4
- package/dist/core/responses/index.d.ts.map +0 -1
- package/dist/core/responses/index.js +0 -4
- package/dist/core/responses/index.js.map +0 -1
- package/dist/core/responses/normalize.d.ts +0 -3
- package/dist/core/responses/normalize.d.ts.map +0 -1
- package/dist/core/responses/normalize.js +0 -33
- package/dist/core/responses/normalize.js.map +0 -1
- package/dist/core/responses/pickStatus.d.ts +0 -3
- package/dist/core/responses/pickStatus.d.ts.map +0 -1
- package/dist/core/responses/pickStatus.js +0 -27
- package/dist/core/responses/pickStatus.js.map +0 -1
- package/dist/core/route/defineRoute.d.ts +0 -74
- package/dist/core/route/defineRoute.d.ts.map +0 -1
- package/dist/core/route/defineRoute.js +0 -59
- package/dist/core/route/defineRoute.js.map +0 -1
- package/dist/core/route/index.d.ts +0 -2
- package/dist/core/route/index.d.ts.map +0 -1
- package/dist/core/route/index.js +0 -2
- package/dist/core/route/index.js.map +0 -1
- package/dist/core/serialization/json.d.ts +0 -2
- package/dist/core/serialization/json.d.ts.map +0 -1
- package/dist/core/serialization/json.js +0 -3
- package/dist/core/serialization/json.js.map +0 -1
- package/dist/core/typing/path-params.d.ts +0 -2
- package/dist/core/typing/path-params.d.ts.map +0 -1
- package/dist/core/typing/path-params.js +0 -2
- package/dist/core/typing/path-params.js.map +0 -1
- package/dist/decorators/binding.d.ts +0 -9
- package/dist/decorators/binding.d.ts.map +0 -1
- package/dist/decorators/binding.js +0 -18
- package/dist/decorators/binding.js.map +0 -1
- package/dist/decorators/controller.d.ts +0 -6
- package/dist/decorators/controller.d.ts.map +0 -1
- package/dist/decorators/controller.js +0 -26
- package/dist/decorators/controller.js.map +0 -1
- package/dist/decorators/db.d.ts +0 -2
- package/dist/decorators/db.d.ts.map +0 -1
- package/dist/decorators/db.js +0 -3
- package/dist/decorators/db.js.map +0 -1
- package/dist/decorators/docs.d.ts +0 -8
- package/dist/decorators/docs.d.ts.map +0 -1
- package/dist/decorators/docs.js +0 -46
- package/dist/decorators/docs.js.map +0 -1
- package/dist/decorators/index.js +0 -7
- package/dist/decorators/index.js.map +0 -1
- package/dist/decorators/methods.js +0 -170
- package/dist/decorators/methods.js.map +0 -1
- package/dist/decorators/middleware.d.ts +0 -2
- package/dist/decorators/middleware.d.ts.map +0 -1
- package/dist/decorators/middleware.js +0 -3
- package/dist/decorators/middleware.js.map +0 -1
- package/dist/decorators/responses.d.ts +0 -7
- package/dist/decorators/responses.d.ts.map +0 -1
- package/dist/decorators/responses.js +0 -44
- package/dist/decorators/responses.js.map +0 -1
- package/dist/decorators/security.d.ts +0 -8
- package/dist/decorators/security.d.ts.map +0 -1
- package/dist/decorators/security.js +0 -39
- package/dist/decorators/security.js.map +0 -1
- package/dist/integrations/metal-orm/index.d.ts +0 -2
- package/dist/integrations/metal-orm/index.d.ts.map +0 -1
- package/dist/integrations/metal-orm/index.js +0 -2
- package/dist/integrations/metal-orm/index.js.map +0 -1
- package/dist/integrations/metal-orm/pagination/executePaged.d.ts +0 -2
- package/dist/integrations/metal-orm/pagination/executePaged.d.ts.map +0 -1
- package/dist/integrations/metal-orm/pagination/executePaged.js +0 -3
- package/dist/integrations/metal-orm/pagination/executePaged.js.map +0 -1
- package/dist/integrations/metal-orm/pagination/page.d.ts +0 -2
- package/dist/integrations/metal-orm/pagination/page.d.ts.map +0 -1
- package/dist/integrations/metal-orm/pagination/page.js +0 -3
- package/dist/integrations/metal-orm/pagination/page.js.map +0 -1
- package/dist/integrations/metal-orm/query/filters.d.ts +0 -2
- package/dist/integrations/metal-orm/query/filters.d.ts.map +0 -1
- package/dist/integrations/metal-orm/query/filters.js +0 -3
- package/dist/integrations/metal-orm/query/filters.js.map +0 -1
- package/dist/integrations/metal-orm/query/search.d.ts +0 -2
- package/dist/integrations/metal-orm/query/search.d.ts.map +0 -1
- package/dist/integrations/metal-orm/query/search.js +0 -3
- package/dist/integrations/metal-orm/query/search.js.map +0 -1
- package/dist/integrations/metal-orm/query/sort.d.ts +0 -2
- package/dist/integrations/metal-orm/query/sort.d.ts.map +0 -1
- package/dist/integrations/metal-orm/query/sort.js +0 -3
- package/dist/integrations/metal-orm/query/sort.js.map +0 -1
- package/dist/integrations/metal-orm/save-graph/helpers.d.ts +0 -2
- package/dist/integrations/metal-orm/save-graph/helpers.d.ts.map +0 -1
- package/dist/integrations/metal-orm/save-graph/helpers.js +0 -3
- package/dist/integrations/metal-orm/save-graph/helpers.js.map +0 -1
- package/dist/integrations/metal-orm/save-graph/types.d.ts +0 -2
- package/dist/integrations/metal-orm/save-graph/types.d.ts.map +0 -1
- package/dist/integrations/metal-orm/save-graph/types.js +0 -3
- package/dist/integrations/metal-orm/save-graph/types.js.map +0 -1
- package/dist/integrations/metal-orm/schema/column-map.d.ts +0 -96
- package/dist/integrations/metal-orm/schema/column-map.d.ts.map +0 -1
- package/dist/integrations/metal-orm/schema/column-map.js +0 -207
- package/dist/integrations/metal-orm/schema/column-map.js.map +0 -1
- package/dist/integrations/metal-orm/schema/ddl.d.ts +0 -2
- package/dist/integrations/metal-orm/schema/ddl.d.ts.map +0 -1
- package/dist/integrations/metal-orm/schema/ddl.js +0 -3
- package/dist/integrations/metal-orm/schema/ddl.js.map +0 -1
- package/dist/integrations/metal-orm/schema/dto.d.ts +0 -7
- package/dist/integrations/metal-orm/schema/dto.d.ts.map +0 -1
- package/dist/integrations/metal-orm/schema/dto.js +0 -34
- package/dist/integrations/metal-orm/schema/dto.js.map +0 -1
- package/dist/integrations/metal-orm/schema/entity.d.ts +0 -99
- package/dist/integrations/metal-orm/schema/entity.d.ts.map +0 -1
- package/dist/integrations/metal-orm/schema/entity.js +0 -99
- package/dist/integrations/metal-orm/schema/entity.js.map +0 -1
- package/dist/integrations/metal-orm/schema/filters.d.ts +0 -11
- package/dist/integrations/metal-orm/schema/filters.d.ts.map +0 -1
- package/dist/integrations/metal-orm/schema/filters.js +0 -21
- package/dist/integrations/metal-orm/schema/filters.js.map +0 -1
- package/dist/integrations/metal-orm/schema/index.d.ts +0 -5
- package/dist/integrations/metal-orm/schema/index.d.ts.map +0 -1
- package/dist/integrations/metal-orm/schema/index.js +0 -5
- package/dist/integrations/metal-orm/schema/index.js.map +0 -1
- package/dist/integrations/metal-orm/schema/openapi/entityToSchema.d.ts +0 -2
- package/dist/integrations/metal-orm/schema/openapi/entityToSchema.d.ts.map +0 -1
- package/dist/integrations/metal-orm/schema/openapi/entityToSchema.js +0 -3
- package/dist/integrations/metal-orm/schema/openapi/entityToSchema.js.map +0 -1
- package/dist/integrations/metal-orm/schema/openapi/tableDefToSchema.d.ts +0 -2
- package/dist/integrations/metal-orm/schema/openapi/tableDefToSchema.d.ts.map +0 -1
- package/dist/integrations/metal-orm/schema/openapi/tableDefToSchema.js +0 -3
- package/dist/integrations/metal-orm/schema/openapi/tableDefToSchema.js.map +0 -1
- package/dist/integrations/metal-orm/schema/sqlite.d.ts +0 -2
- package/dist/integrations/metal-orm/schema/sqlite.d.ts.map +0 -1
- package/dist/integrations/metal-orm/schema/sqlite.js +0 -3
- package/dist/integrations/metal-orm/schema/sqlite.js.map +0 -1
- package/dist/integrations/metal-orm/schema/tabledef.d.ts +0 -4
- package/dist/integrations/metal-orm/schema/tabledef.d.ts.map +0 -1
- package/dist/integrations/metal-orm/schema/tabledef.js +0 -10
- package/dist/integrations/metal-orm/schema/tabledef.js.map +0 -1
- package/dist/integrations/metal-orm/schema/types.d.ts +0 -7
- package/dist/integrations/metal-orm/schema/types.d.ts.map +0 -1
- package/dist/integrations/metal-orm/schema/types.js +0 -2
- package/dist/integrations/metal-orm/schema/types.js.map +0 -1
- package/dist/integrations/metal-orm/serialization/entitySerializer.d.ts +0 -2
- package/dist/integrations/metal-orm/serialization/entitySerializer.d.ts.map +0 -1
- package/dist/integrations/metal-orm/serialization/entitySerializer.js +0 -3
- package/dist/integrations/metal-orm/serialization/entitySerializer.js.map +0 -1
- package/dist/integrations/metal-orm/serialization/relationPolicy.d.ts +0 -2
- package/dist/integrations/metal-orm/serialization/relationPolicy.d.ts.map +0 -1
- package/dist/integrations/metal-orm/serialization/relationPolicy.js +0 -3
- package/dist/integrations/metal-orm/serialization/relationPolicy.js.map +0 -1
- package/dist/integrations/metal-orm/session/context.d.ts +0 -2
- package/dist/integrations/metal-orm/session/context.d.ts.map +0 -1
- package/dist/integrations/metal-orm/session/context.js +0 -3
- package/dist/integrations/metal-orm/session/context.js.map +0 -1
- package/dist/integrations/metal-orm/session/middleware.d.ts +0 -2
- package/dist/integrations/metal-orm/session/middleware.d.ts.map +0 -1
- package/dist/integrations/metal-orm/session/middleware.js +0 -3
- package/dist/integrations/metal-orm/session/middleware.js.map +0 -1
- package/dist/integrations/metal-orm/session/transaction.d.ts +0 -2
- package/dist/integrations/metal-orm/session/transaction.d.ts.map +0 -1
- package/dist/integrations/metal-orm/session/transaction.js +0 -3
- package/dist/integrations/metal-orm/session/transaction.js.map +0 -1
- package/dist/integrations/metal-orm/testing/setupSchema.d.ts +0 -2
- package/dist/integrations/metal-orm/testing/setupSchema.d.ts.map +0 -1
- package/dist/integrations/metal-orm/testing/setupSchema.js +0 -3
- package/dist/integrations/metal-orm/testing/setupSchema.js.map +0 -1
- package/dist/integrations/metal-orm/testing/sqliteMemory.d.ts +0 -2
- package/dist/integrations/metal-orm/testing/sqliteMemory.d.ts.map +0 -1
- package/dist/integrations/metal-orm/testing/sqliteMemory.js +0 -3
- package/dist/integrations/metal-orm/testing/sqliteMemory.js.map +0 -1
- package/dist/metadata/bag.d.ts +0 -18
- package/dist/metadata/bag.d.ts.map +0 -1
- package/dist/metadata/bag.js +0 -39
- package/dist/metadata/bag.js.map +0 -1
- package/dist/metadata/index.d.ts +0 -4
- package/dist/metadata/index.d.ts.map +0 -1
- package/dist/metadata/index.js +0 -4
- package/dist/metadata/index.js.map +0 -1
- package/dist/metadata/keys.d.ts +0 -254
- package/dist/metadata/keys.d.ts.map +0 -1
- package/dist/metadata/keys.js +0 -23
- package/dist/metadata/keys.js.map +0 -1
- package/dist/metadata/merge.d.ts +0 -9
- package/dist/metadata/merge.d.ts.map +0 -1
- package/dist/metadata/merge.js +0 -30
- package/dist/metadata/merge.js.map +0 -1
- package/dist/metal-orm.d.ts +0 -2
- package/dist/metal-orm.d.ts.map +0 -1
- package/dist/metal-orm.js +0 -2
- package/dist/metal-orm.js.map +0 -1
- package/dist/validation/native/index.d.ts +0 -3
- package/dist/validation/native/index.d.ts.map +0 -1
- package/dist/validation/native/index.js +0 -3
- package/dist/validation/native/index.js.map +0 -1
- package/dist/validation/native/ir.d.ts +0 -38
- package/dist/validation/native/ir.d.ts.map +0 -1
- package/dist/validation/native/ir.js +0 -2
- package/dist/validation/native/ir.js.map +0 -1
- package/dist/validation/native/schema.d.ts +0 -63
- package/dist/validation/native/schema.d.ts.map +0 -1
- package/dist/validation/native/schema.js +0 -271
- package/dist/validation/native/schema.js.map +0 -1
- package/dist/validation/native/validator.d.ts +0 -21
- package/dist/validation/native/validator.d.ts.map +0 -1
- package/dist/validation/native/validator.js +0 -48
- package/dist/validation/native/validator.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"polyfill.d.ts","sourceRoot":"","sources":["../../src/runtime/polyfill.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,cAAc,eAA2B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../src/runtime/upload.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC;CAC/B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import Ajv from "ajv";
|
|
2
|
+
export interface ValidationError {
|
|
3
|
+
path: string;
|
|
4
|
+
message: string;
|
|
5
|
+
keyword: string;
|
|
6
|
+
params: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
export interface ValidationResult {
|
|
9
|
+
valid: boolean;
|
|
10
|
+
errors: ValidationError[] | null;
|
|
11
|
+
}
|
|
12
|
+
export declare class ValidationErrorResponse extends Error {
|
|
13
|
+
statusCode: number;
|
|
14
|
+
errors: ValidationError[];
|
|
15
|
+
constructor(statusCode: number, errors: ValidationError[]);
|
|
16
|
+
}
|
|
17
|
+
export declare function createValidator(): Ajv.Ajv;
|
|
18
|
+
export declare function validateData(ajv: ReturnType<typeof createValidator>, data: unknown, schema: Record<string, unknown>, dataPath?: string): ValidationResult;
|
|
19
|
+
export declare function formatValidationErrors(errors: ValidationError[]): Record<string, unknown>;
|
|
20
|
+
//# sourceMappingURL=ajv.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ajv.d.ts","sourceRoot":"","sources":["../../../src/runtime/validation/ajv.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AAItB,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,eAAe,EAAE,GAAG,IAAI,CAAC;CAClC;AAED,qBAAa,uBAAwB,SAAQ,KAAK;IAEvC,UAAU,EAAE,MAAM;IAClB,MAAM,EAAE,eAAe,EAAE;gBADzB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,eAAe,EAAE;CAKnC;AAED,wBAAgB,eAAe,YAa9B;AAED,wBAAgB,YAAY,CAC1B,GAAG,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,EACvC,IAAI,EAAE,OAAO,EACb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,QAAQ,GAAE,MAAY,GACrB,gBAAgB,CAgBlB;AAgBD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAezF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/validation/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
declare const ADORN_META: unique symbol;
|
|
2
|
+
interface SchemaFrag {
|
|
3
|
+
[key: string]: unknown;
|
|
4
|
+
}
|
|
5
|
+
interface SchemaMetadata {
|
|
6
|
+
schema: {
|
|
7
|
+
props: Record<string, SchemaFrag[]>;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
type PropertyDecorator = (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => void;
|
|
11
|
+
export declare function Schema(frag: SchemaFrag): PropertyDecorator;
|
|
12
|
+
export declare function Min(n: number): PropertyDecorator;
|
|
13
|
+
export declare function Max(n: number): PropertyDecorator;
|
|
14
|
+
export declare function ExclusiveMin(n: number): PropertyDecorator;
|
|
15
|
+
export declare function ExclusiveMax(n: number): PropertyDecorator;
|
|
16
|
+
export declare function MinLength(n: number): PropertyDecorator;
|
|
17
|
+
export declare function MaxLength(n: number): PropertyDecorator;
|
|
18
|
+
export declare function Pattern(re: RegExp | string): PropertyDecorator;
|
|
19
|
+
export declare function Format(fmt: string): PropertyDecorator;
|
|
20
|
+
export declare function MinItems(n: number): PropertyDecorator;
|
|
21
|
+
export declare function MaxItems(n: number): PropertyDecorator;
|
|
22
|
+
export declare function MinProperties(n: number): PropertyDecorator;
|
|
23
|
+
export declare function MaxProperties(n: number): PropertyDecorator;
|
|
24
|
+
export declare function MultipleOf(n: number): PropertyDecorator;
|
|
25
|
+
export declare function Example(value: unknown): PropertyDecorator;
|
|
26
|
+
export declare function Examples(values: unknown[]): PropertyDecorator;
|
|
27
|
+
export declare function Description(desc: string): PropertyDecorator;
|
|
28
|
+
export declare function Enum<T extends string | number>(vals: T[]): PropertyDecorator;
|
|
29
|
+
export declare function Const<T>(val: T): PropertyDecorator;
|
|
30
|
+
export declare function Default<T>(val: T): PropertyDecorator;
|
|
31
|
+
export declare function AdditionalProperties(value: boolean | Record<string, unknown>): PropertyDecorator;
|
|
32
|
+
export declare function Closed(): PropertyDecorator;
|
|
33
|
+
export declare function ClosedUnevaluated(): PropertyDecorator;
|
|
34
|
+
export declare function Union(mode: "anyOf" | "oneOf" | "allOf"): ClassDecorator;
|
|
35
|
+
export { ADORN_META };
|
|
36
|
+
export type { SchemaFrag, SchemaMetadata };
|
|
37
|
+
//# sourceMappingURL=decorators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../src/schema/decorators.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,UAAU,eAAmC,CAAC;AAEpD,UAAU,UAAU;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,UAAU,cAAc;IACtB,MAAM,EAAE;QACN,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;KACrC,CAAC;CACH;AAmBD,KAAK,iBAAiB,GA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,CAI3D;AAED,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,iBAAiB,CAI5E;AAED,wBAAgB,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,iBAAiB,CAIlD;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,iBAAiB,CAIpD;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,iBAAiB,CAIhG;AAED,wBAAgB,MAAM,IAAI,iBAAiB,CAI1C;AAED,wBAAgB,iBAAiB,IAAI,iBAAiB,CAIrD;AAED,wBAAgB,KAAK,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,cAAc,CAOvE;AAED,OAAO,EAAE,UAAU,EAAE,CAAC;AACtB,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/schema/index.ts
|
|
21
|
+
var schema_exports = {};
|
|
22
|
+
__export(schema_exports, {
|
|
23
|
+
ADORN_META: () => ADORN_META,
|
|
24
|
+
AdditionalProperties: () => AdditionalProperties,
|
|
25
|
+
Closed: () => Closed,
|
|
26
|
+
ClosedUnevaluated: () => ClosedUnevaluated,
|
|
27
|
+
Const: () => Const,
|
|
28
|
+
Default: () => Default,
|
|
29
|
+
Description: () => Description,
|
|
30
|
+
Enum: () => Enum,
|
|
31
|
+
Example: () => Example,
|
|
32
|
+
Examples: () => Examples,
|
|
33
|
+
ExclusiveMax: () => ExclusiveMax,
|
|
34
|
+
ExclusiveMin: () => ExclusiveMin,
|
|
35
|
+
Format: () => Format,
|
|
36
|
+
Max: () => Max,
|
|
37
|
+
MaxItems: () => MaxItems,
|
|
38
|
+
MaxLength: () => MaxLength,
|
|
39
|
+
MaxProperties: () => MaxProperties,
|
|
40
|
+
Min: () => Min,
|
|
41
|
+
MinItems: () => MinItems,
|
|
42
|
+
MinLength: () => MinLength,
|
|
43
|
+
MinProperties: () => MinProperties,
|
|
44
|
+
MultipleOf: () => MultipleOf,
|
|
45
|
+
Pattern: () => Pattern,
|
|
46
|
+
Schema: () => Schema,
|
|
47
|
+
Union: () => Union
|
|
48
|
+
});
|
|
49
|
+
module.exports = __toCommonJS(schema_exports);
|
|
50
|
+
|
|
51
|
+
// src/schema/decorators.ts
|
|
52
|
+
var ADORN_META = /* @__PURE__ */ Symbol.for("adorn-api.metadata");
|
|
53
|
+
function getOrCreateMetadata(metadata) {
|
|
54
|
+
const meta = metadata[ADORN_META] ??= {};
|
|
55
|
+
meta.schema ??= { props: {} };
|
|
56
|
+
return meta;
|
|
57
|
+
}
|
|
58
|
+
function pushSchemaFrag(target, propertyKey, metadata, frag) {
|
|
59
|
+
const meta = getOrCreateMetadata(metadata);
|
|
60
|
+
const props = meta.schema.props;
|
|
61
|
+
(props[propertyKey] ??= []).push(frag);
|
|
62
|
+
}
|
|
63
|
+
function Schema(frag) {
|
|
64
|
+
return function(target, propertyKey) {
|
|
65
|
+
pushSchemaFrag(target, propertyKey, {}, frag);
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function Min(n) {
|
|
69
|
+
return function(target, propertyKey) {
|
|
70
|
+
pushSchemaFrag(target, propertyKey, {}, { minimum: n });
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function Max(n) {
|
|
74
|
+
return function(target, propertyKey) {
|
|
75
|
+
pushSchemaFrag(target, propertyKey, {}, { maximum: n });
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function ExclusiveMin(n) {
|
|
79
|
+
return function(target, propertyKey) {
|
|
80
|
+
pushSchemaFrag(target, propertyKey, {}, { exclusiveMinimum: n });
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function ExclusiveMax(n) {
|
|
84
|
+
return function(target, propertyKey) {
|
|
85
|
+
pushSchemaFrag(target, propertyKey, {}, { exclusiveMaximum: n });
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function MinLength(n) {
|
|
89
|
+
return function(target, propertyKey) {
|
|
90
|
+
pushSchemaFrag(target, propertyKey, {}, { minLength: n });
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function MaxLength(n) {
|
|
94
|
+
return function(target, propertyKey) {
|
|
95
|
+
pushSchemaFrag(target, propertyKey, {}, { maxLength: n });
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function Pattern(re) {
|
|
99
|
+
return function(target, propertyKey) {
|
|
100
|
+
pushSchemaFrag(target, propertyKey, {}, { pattern: typeof re === "string" ? re : re.source });
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function Format(fmt) {
|
|
104
|
+
return function(target, propertyKey) {
|
|
105
|
+
pushSchemaFrag(target, propertyKey, {}, { format: fmt });
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function MinItems(n) {
|
|
109
|
+
return function(target, propertyKey) {
|
|
110
|
+
pushSchemaFrag(target, propertyKey, {}, { minItems: n });
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function MaxItems(n) {
|
|
114
|
+
return function(target, propertyKey) {
|
|
115
|
+
pushSchemaFrag(target, propertyKey, {}, { maxItems: n });
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function MinProperties(n) {
|
|
119
|
+
return function(target, propertyKey) {
|
|
120
|
+
pushSchemaFrag(target, propertyKey, {}, { minProperties: n });
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function MaxProperties(n) {
|
|
124
|
+
return function(target, propertyKey) {
|
|
125
|
+
pushSchemaFrag(target, propertyKey, {}, { maxProperties: n });
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function MultipleOf(n) {
|
|
129
|
+
return function(target, propertyKey) {
|
|
130
|
+
pushSchemaFrag(target, propertyKey, {}, { multipleOf: n });
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
function Example(value) {
|
|
134
|
+
return function(target, propertyKey) {
|
|
135
|
+
pushSchemaFrag(target, propertyKey, {}, { example: value });
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function Examples(values) {
|
|
139
|
+
return function(target, propertyKey) {
|
|
140
|
+
pushSchemaFrag(target, propertyKey, {}, { examples: values });
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function Description(desc) {
|
|
144
|
+
return function(target, propertyKey) {
|
|
145
|
+
pushSchemaFrag(target, propertyKey, {}, { description: desc });
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
function Enum(vals) {
|
|
149
|
+
return function(target, propertyKey) {
|
|
150
|
+
pushSchemaFrag(target, propertyKey, {}, { enum: vals });
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
function Const(val) {
|
|
154
|
+
return function(target, propertyKey) {
|
|
155
|
+
pushSchemaFrag(target, propertyKey, {}, { const: val });
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
function Default(val) {
|
|
159
|
+
return function(target, propertyKey) {
|
|
160
|
+
pushSchemaFrag(target, propertyKey, {}, { default: val });
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
function AdditionalProperties(value) {
|
|
164
|
+
return function(target, propertyKey) {
|
|
165
|
+
pushSchemaFrag(target, propertyKey, {}, { additionalProperties: value });
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
function Closed() {
|
|
169
|
+
return function(target, propertyKey) {
|
|
170
|
+
pushSchemaFrag(target, propertyKey, {}, { additionalProperties: false });
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
function ClosedUnevaluated() {
|
|
174
|
+
return function(target, propertyKey) {
|
|
175
|
+
pushSchemaFrag(target, propertyKey, {}, { unevaluatedProperties: false });
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
function Union(mode) {
|
|
179
|
+
return function(target) {
|
|
180
|
+
target[ADORN_META] = target[ADORN_META] ?? {};
|
|
181
|
+
const meta = target[ADORN_META];
|
|
182
|
+
meta.schema = meta.schema ?? { props: {} };
|
|
183
|
+
meta.schema.unionMode = mode;
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
187
|
+
0 && (module.exports = {
|
|
188
|
+
ADORN_META,
|
|
189
|
+
AdditionalProperties,
|
|
190
|
+
Closed,
|
|
191
|
+
ClosedUnevaluated,
|
|
192
|
+
Const,
|
|
193
|
+
Default,
|
|
194
|
+
Description,
|
|
195
|
+
Enum,
|
|
196
|
+
Example,
|
|
197
|
+
Examples,
|
|
198
|
+
ExclusiveMax,
|
|
199
|
+
ExclusiveMin,
|
|
200
|
+
Format,
|
|
201
|
+
Max,
|
|
202
|
+
MaxItems,
|
|
203
|
+
MaxLength,
|
|
204
|
+
MaxProperties,
|
|
205
|
+
Min,
|
|
206
|
+
MinItems,
|
|
207
|
+
MinLength,
|
|
208
|
+
MinProperties,
|
|
209
|
+
MultipleOf,
|
|
210
|
+
Pattern,
|
|
211
|
+
Schema,
|
|
212
|
+
Union
|
|
213
|
+
});
|
|
214
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/schema/index.ts","../../src/schema/decorators.ts"],"sourcesContent":["export * from \"./decorators.js\";\n","const ADORN_META = Symbol.for(\"adorn-api.metadata\");\n\ninterface SchemaFrag {\n [key: string]: unknown;\n}\n\ninterface SchemaMetadata {\n schema: {\n props: Record<string, SchemaFrag[]>;\n };\n}\n\nfunction getOrCreateMetadata(metadata: Record<PropertyKey, unknown>): SchemaMetadata {\n const meta = (metadata[ADORN_META] ??= {}) as SchemaMetadata;\n meta.schema ??= { props: {} };\n return meta;\n}\n\nfunction pushSchemaFrag(\n target: Object,\n propertyKey: string | symbol,\n metadata: Record<PropertyKey, unknown>,\n frag: SchemaFrag\n): void {\n const meta = getOrCreateMetadata(metadata);\n const props = meta.schema.props;\n (props[propertyKey as string] ??= []).push(frag);\n}\n\ntype PropertyDecorator = (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => void;\n\nexport function Schema(frag: SchemaFrag): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, frag);\n };\n}\n\nexport function Min(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { minimum: n });\n };\n}\n\nexport function Max(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { maximum: n });\n };\n}\n\nexport function ExclusiveMin(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { exclusiveMinimum: n });\n };\n}\n\nexport function ExclusiveMax(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { exclusiveMaximum: n });\n };\n}\n\nexport function MinLength(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { minLength: n });\n };\n}\n\nexport function MaxLength(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { maxLength: n });\n };\n}\n\nexport function Pattern(re: RegExp | string): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { pattern: typeof re === \"string\" ? re : re.source });\n };\n}\n\nexport function Format(fmt: string): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { format: fmt });\n };\n}\n\nexport function MinItems(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { minItems: n });\n };\n}\n\nexport function MaxItems(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { maxItems: n });\n };\n}\n\nexport function MinProperties(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { minProperties: n });\n };\n}\n\nexport function MaxProperties(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { maxProperties: n });\n };\n}\n\nexport function MultipleOf(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { multipleOf: n });\n };\n}\n\nexport function Example(value: unknown): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { example: value });\n };\n}\n\nexport function Examples(values: unknown[]): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { examples: values });\n };\n}\n\nexport function Description(desc: string): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { description: desc });\n };\n}\n\nexport function Enum<T extends string | number>(vals: T[]): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { enum: vals });\n };\n}\n\nexport function Const<T>(val: T): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { const: val });\n };\n}\n\nexport function Default<T>(val: T): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { default: val });\n };\n}\n\nexport function AdditionalProperties(value: boolean | Record<string, unknown>): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { additionalProperties: value });\n };\n}\n\nexport function Closed(): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { additionalProperties: false });\n };\n}\n\nexport function ClosedUnevaluated(): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { unevaluatedProperties: false });\n };\n}\n\nexport function Union(mode: \"anyOf\" | \"oneOf\" | \"allOf\"): ClassDecorator {\n return function (target: Function): void {\n (target as any)[ADORN_META] = (target as any)[ADORN_META] ?? {};\n const meta = (target as any)[ADORN_META] as SchemaMetadata;\n meta.schema = meta.schema ?? { props: {} };\n (meta.schema as any).unionMode = mode;\n };\n}\n\nexport { ADORN_META };\nexport type { SchemaFrag, SchemaMetadata };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAM,aAAa,uBAAO,IAAI,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zC,IAAC,KAAK,OAAe,YAAY;AAAA,EACnC;AACF;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
// src/schema/decorators.ts
|
|
2
|
+
var ADORN_META = /* @__PURE__ */ Symbol.for("adorn-api.metadata");
|
|
3
|
+
function getOrCreateMetadata(metadata) {
|
|
4
|
+
const meta = metadata[ADORN_META] ??= {};
|
|
5
|
+
meta.schema ??= { props: {} };
|
|
6
|
+
return meta;
|
|
7
|
+
}
|
|
8
|
+
function pushSchemaFrag(target, propertyKey, metadata, frag) {
|
|
9
|
+
const meta = getOrCreateMetadata(metadata);
|
|
10
|
+
const props = meta.schema.props;
|
|
11
|
+
(props[propertyKey] ??= []).push(frag);
|
|
12
|
+
}
|
|
13
|
+
function Schema(frag) {
|
|
14
|
+
return function(target, propertyKey) {
|
|
15
|
+
pushSchemaFrag(target, propertyKey, {}, frag);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function Min(n) {
|
|
19
|
+
return function(target, propertyKey) {
|
|
20
|
+
pushSchemaFrag(target, propertyKey, {}, { minimum: n });
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function Max(n) {
|
|
24
|
+
return function(target, propertyKey) {
|
|
25
|
+
pushSchemaFrag(target, propertyKey, {}, { maximum: n });
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function ExclusiveMin(n) {
|
|
29
|
+
return function(target, propertyKey) {
|
|
30
|
+
pushSchemaFrag(target, propertyKey, {}, { exclusiveMinimum: n });
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function ExclusiveMax(n) {
|
|
34
|
+
return function(target, propertyKey) {
|
|
35
|
+
pushSchemaFrag(target, propertyKey, {}, { exclusiveMaximum: n });
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function MinLength(n) {
|
|
39
|
+
return function(target, propertyKey) {
|
|
40
|
+
pushSchemaFrag(target, propertyKey, {}, { minLength: n });
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function MaxLength(n) {
|
|
44
|
+
return function(target, propertyKey) {
|
|
45
|
+
pushSchemaFrag(target, propertyKey, {}, { maxLength: n });
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function Pattern(re) {
|
|
49
|
+
return function(target, propertyKey) {
|
|
50
|
+
pushSchemaFrag(target, propertyKey, {}, { pattern: typeof re === "string" ? re : re.source });
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function Format(fmt) {
|
|
54
|
+
return function(target, propertyKey) {
|
|
55
|
+
pushSchemaFrag(target, propertyKey, {}, { format: fmt });
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function MinItems(n) {
|
|
59
|
+
return function(target, propertyKey) {
|
|
60
|
+
pushSchemaFrag(target, propertyKey, {}, { minItems: n });
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function MaxItems(n) {
|
|
64
|
+
return function(target, propertyKey) {
|
|
65
|
+
pushSchemaFrag(target, propertyKey, {}, { maxItems: n });
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function MinProperties(n) {
|
|
69
|
+
return function(target, propertyKey) {
|
|
70
|
+
pushSchemaFrag(target, propertyKey, {}, { minProperties: n });
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function MaxProperties(n) {
|
|
74
|
+
return function(target, propertyKey) {
|
|
75
|
+
pushSchemaFrag(target, propertyKey, {}, { maxProperties: n });
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function MultipleOf(n) {
|
|
79
|
+
return function(target, propertyKey) {
|
|
80
|
+
pushSchemaFrag(target, propertyKey, {}, { multipleOf: n });
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function Example(value) {
|
|
84
|
+
return function(target, propertyKey) {
|
|
85
|
+
pushSchemaFrag(target, propertyKey, {}, { example: value });
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function Examples(values) {
|
|
89
|
+
return function(target, propertyKey) {
|
|
90
|
+
pushSchemaFrag(target, propertyKey, {}, { examples: values });
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function Description(desc) {
|
|
94
|
+
return function(target, propertyKey) {
|
|
95
|
+
pushSchemaFrag(target, propertyKey, {}, { description: desc });
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function Enum(vals) {
|
|
99
|
+
return function(target, propertyKey) {
|
|
100
|
+
pushSchemaFrag(target, propertyKey, {}, { enum: vals });
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function Const(val) {
|
|
104
|
+
return function(target, propertyKey) {
|
|
105
|
+
pushSchemaFrag(target, propertyKey, {}, { const: val });
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function Default(val) {
|
|
109
|
+
return function(target, propertyKey) {
|
|
110
|
+
pushSchemaFrag(target, propertyKey, {}, { default: val });
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function AdditionalProperties(value) {
|
|
114
|
+
return function(target, propertyKey) {
|
|
115
|
+
pushSchemaFrag(target, propertyKey, {}, { additionalProperties: value });
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function Closed() {
|
|
119
|
+
return function(target, propertyKey) {
|
|
120
|
+
pushSchemaFrag(target, propertyKey, {}, { additionalProperties: false });
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function ClosedUnevaluated() {
|
|
124
|
+
return function(target, propertyKey) {
|
|
125
|
+
pushSchemaFrag(target, propertyKey, {}, { unevaluatedProperties: false });
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function Union(mode) {
|
|
129
|
+
return function(target) {
|
|
130
|
+
target[ADORN_META] = target[ADORN_META] ?? {};
|
|
131
|
+
const meta = target[ADORN_META];
|
|
132
|
+
meta.schema = meta.schema ?? { props: {} };
|
|
133
|
+
meta.schema.unionMode = mode;
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
export {
|
|
137
|
+
ADORN_META,
|
|
138
|
+
AdditionalProperties,
|
|
139
|
+
Closed,
|
|
140
|
+
ClosedUnevaluated,
|
|
141
|
+
Const,
|
|
142
|
+
Default,
|
|
143
|
+
Description,
|
|
144
|
+
Enum,
|
|
145
|
+
Example,
|
|
146
|
+
Examples,
|
|
147
|
+
ExclusiveMax,
|
|
148
|
+
ExclusiveMin,
|
|
149
|
+
Format,
|
|
150
|
+
Max,
|
|
151
|
+
MaxItems,
|
|
152
|
+
MaxLength,
|
|
153
|
+
MaxProperties,
|
|
154
|
+
Min,
|
|
155
|
+
MinItems,
|
|
156
|
+
MinLength,
|
|
157
|
+
MinProperties,
|
|
158
|
+
MultipleOf,
|
|
159
|
+
Pattern,
|
|
160
|
+
Schema,
|
|
161
|
+
Union
|
|
162
|
+
};
|
|
163
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/schema/decorators.ts"],"sourcesContent":["const ADORN_META = Symbol.for(\"adorn-api.metadata\");\n\ninterface SchemaFrag {\n [key: string]: unknown;\n}\n\ninterface SchemaMetadata {\n schema: {\n props: Record<string, SchemaFrag[]>;\n };\n}\n\nfunction getOrCreateMetadata(metadata: Record<PropertyKey, unknown>): SchemaMetadata {\n const meta = (metadata[ADORN_META] ??= {}) as SchemaMetadata;\n meta.schema ??= { props: {} };\n return meta;\n}\n\nfunction pushSchemaFrag(\n target: Object,\n propertyKey: string | symbol,\n metadata: Record<PropertyKey, unknown>,\n frag: SchemaFrag\n): void {\n const meta = getOrCreateMetadata(metadata);\n const props = meta.schema.props;\n (props[propertyKey as string] ??= []).push(frag);\n}\n\ntype PropertyDecorator = (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => void;\n\nexport function Schema(frag: SchemaFrag): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, frag);\n };\n}\n\nexport function Min(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { minimum: n });\n };\n}\n\nexport function Max(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { maximum: n });\n };\n}\n\nexport function ExclusiveMin(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { exclusiveMinimum: n });\n };\n}\n\nexport function ExclusiveMax(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { exclusiveMaximum: n });\n };\n}\n\nexport function MinLength(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { minLength: n });\n };\n}\n\nexport function MaxLength(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { maxLength: n });\n };\n}\n\nexport function Pattern(re: RegExp | string): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { pattern: typeof re === \"string\" ? re : re.source });\n };\n}\n\nexport function Format(fmt: string): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { format: fmt });\n };\n}\n\nexport function MinItems(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { minItems: n });\n };\n}\n\nexport function MaxItems(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { maxItems: n });\n };\n}\n\nexport function MinProperties(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { minProperties: n });\n };\n}\n\nexport function MaxProperties(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { maxProperties: n });\n };\n}\n\nexport function MultipleOf(n: number): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { multipleOf: n });\n };\n}\n\nexport function Example(value: unknown): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { example: value });\n };\n}\n\nexport function Examples(values: unknown[]): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { examples: values });\n };\n}\n\nexport function Description(desc: string): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { description: desc });\n };\n}\n\nexport function Enum<T extends string | number>(vals: T[]): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { enum: vals });\n };\n}\n\nexport function Const<T>(val: T): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { const: val });\n };\n}\n\nexport function Default<T>(val: T): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { default: val });\n };\n}\n\nexport function AdditionalProperties(value: boolean | Record<string, unknown>): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { additionalProperties: value });\n };\n}\n\nexport function Closed(): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { additionalProperties: false });\n };\n}\n\nexport function ClosedUnevaluated(): PropertyDecorator {\n return function (target: Object, propertyKey: string | symbol): void {\n pushSchemaFrag(target, propertyKey, {}, { unevaluatedProperties: false });\n };\n}\n\nexport function Union(mode: \"anyOf\" | \"oneOf\" | \"allOf\"): ClassDecorator {\n return function (target: Function): void {\n (target as any)[ADORN_META] = (target as any)[ADORN_META] ?? {};\n const meta = (target as any)[ADORN_META] as SchemaMetadata;\n meta.schema = meta.schema ?? { props: {} };\n (meta.schema as any).unionMode = mode;\n };\n}\n\nexport { ADORN_META };\nexport type { SchemaFrag, SchemaMetadata };\n"],"mappings":";AAAA,IAAM,aAAa,uBAAO,IAAI,oBAAoB;AAYlD,SAAS,oBAAoB,UAAwD;AACnF,QAAM,OAAQ,SAAS,UAAU,MAAM,CAAC;AACxC,OAAK,WAAW,EAAE,OAAO,CAAC,EAAE;AAC5B,SAAO;AACT;AAEA,SAAS,eACP,QACA,aACA,UACA,MACM;AACN,QAAM,OAAO,oBAAoB,QAAQ;AACzC,QAAM,QAAQ,KAAK,OAAO;AAC1B,GAAC,MAAM,WAAqB,MAAM,CAAC,GAAG,KAAK,IAAI;AACjD;AAIO,SAAS,OAAO,MAAqC;AAC1D,SAAO,SAAU,QAAgB,aAAoC;AACnE,mBAAe,QAAQ,aAAa,CAAC,GAAG,IAAI;AAAA,EAC9C;AACF;AAEO,SAAS,IAAI,GAA8B;AAChD,SAAO,SAAU,QAAgB,aAAoC;AACnE,mBAAe,QAAQ,aAAa,CAAC,GAAG,EAAE,SAAS,EAAE,CAAC;AAAA,EACxD;AACF;AAEO,SAAS,IAAI,GAA8B;AAChD,SAAO,SAAU,QAAgB,aAAoC;AACnE,mBAAe,QAAQ,aAAa,CAAC,GAAG,EAAE,SAAS,EAAE,CAAC;AAAA,EACxD;AACF;AAEO,SAAS,aAAa,GAA8B;AACzD,SAAO,SAAU,QAAgB,aAAoC;AACnE,mBAAe,QAAQ,aAAa,CAAC,GAAG,EAAE,kBAAkB,EAAE,CAAC;AAAA,EACjE;AACF;AAEO,SAAS,aAAa,GAA8B;AACzD,SAAO,SAAU,QAAgB,aAAoC;AACnE,mBAAe,QAAQ,aAAa,CAAC,GAAG,EAAE,kBAAkB,EAAE,CAAC;AAAA,EACjE;AACF;AAEO,SAAS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AAG,EAAE,uBAAuB,MAAM,CAAC;AAAA,EAC1E;AACF;AAEO,SAAS,MAAM,MAAmD;AACvE,SAAO,SAAU,QAAwB;AACvC,IAAC,OAAe,UAAU,IAAK,OAAe,UAAU,KAAK,CAAC;AAC9D,UAAM,OAAQ,OAAe,UAAU;AACvC,SAAK,SAAS,KAAK,UAAU,EAAE,OAAO,CAAC,EAAE;AACzC,IAAC,KAAK,OAAe,YAAY;AAAA,EACnC;AACF;","names":[]}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
+
mod
|
|
24
|
+
));
|
|
25
|
+
|
|
26
|
+
// scripts/adorn-example.ts
|
|
27
|
+
var import_child_process = require("child_process");
|
|
28
|
+
var import_path = require("path");
|
|
29
|
+
var import_fs = require("fs");
|
|
30
|
+
var import_node_process = __toESM(require("process"), 1);
|
|
31
|
+
var __filename = import_node_process.default.cwd() + "/index.js";
|
|
32
|
+
var __dirname = (0, import_path.dirname)(__filename);
|
|
33
|
+
function isWindows() {
|
|
34
|
+
return import_node_process.default.platform === "win32";
|
|
35
|
+
}
|
|
36
|
+
function runCommand(command, cwd) {
|
|
37
|
+
const shell = isWindows() ? "cmd.exe" : "/bin/bash";
|
|
38
|
+
(0, import_child_process.execSync)(command, { cwd, stdio: "inherit", shell });
|
|
39
|
+
}
|
|
40
|
+
function spawnCommand(args, cwd) {
|
|
41
|
+
return new Promise((resolve, reject) => {
|
|
42
|
+
const cmd = isWindows() ? "npm.cmd" : "npm";
|
|
43
|
+
const child = (0, import_child_process.spawn)(cmd, args, {
|
|
44
|
+
cwd,
|
|
45
|
+
stdio: "inherit",
|
|
46
|
+
shell: isWindows()
|
|
47
|
+
});
|
|
48
|
+
child.on("error", reject);
|
|
49
|
+
resolve(child);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function getExamples() {
|
|
53
|
+
const examplesDir = (0, import_path.join)(__dirname, "..", "examples");
|
|
54
|
+
if (!(0, import_fs.existsSync)(examplesDir)) return [];
|
|
55
|
+
return (0, import_fs.readdirSync)(examplesDir).filter((name) => {
|
|
56
|
+
const path = (0, import_path.join)(examplesDir, name);
|
|
57
|
+
return (0, import_fs.statSync)(path).isDirectory();
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
function printHelp() {
|
|
61
|
+
console.log(`
|
|
62
|
+
Usage: npx adorn-example <example-name>
|
|
63
|
+
|
|
64
|
+
Run an adorn-api example with automatic dependency installation.
|
|
65
|
+
|
|
66
|
+
Examples:
|
|
67
|
+
npx adorn-example blog-platform
|
|
68
|
+
npx adorn-example task-manager
|
|
69
|
+
npx adorn-example basic
|
|
70
|
+
|
|
71
|
+
Available examples:
|
|
72
|
+
${getExamples().map((e) => ` - ${e}`).join("\n")}
|
|
73
|
+
|
|
74
|
+
Options:
|
|
75
|
+
-h, --help Show this help message
|
|
76
|
+
-l, --list List all available examples
|
|
77
|
+
|
|
78
|
+
From the adorn-api project root, you can also use:
|
|
79
|
+
npm run example <example-name>
|
|
80
|
+
`);
|
|
81
|
+
}
|
|
82
|
+
async function main() {
|
|
83
|
+
const args = import_node_process.default.argv.slice(2);
|
|
84
|
+
if (args.includes("-h") || args.includes("--help")) {
|
|
85
|
+
printHelp();
|
|
86
|
+
import_node_process.default.exit(0);
|
|
87
|
+
}
|
|
88
|
+
if (args.includes("-l") || args.includes("--list")) {
|
|
89
|
+
console.log("Available examples:");
|
|
90
|
+
getExamples().forEach((ex) => console.log(` - ${ex}`));
|
|
91
|
+
import_node_process.default.exit(0);
|
|
92
|
+
}
|
|
93
|
+
const example = args[0] || "basic";
|
|
94
|
+
const examplePath = (0, import_path.join)(__dirname, "..", "examples", example);
|
|
95
|
+
if (!(0, import_fs.existsSync)(examplePath)) {
|
|
96
|
+
console.error(`
|
|
97
|
+
\u274C Example "${example}" not found.
|
|
98
|
+
`);
|
|
99
|
+
console.log("Available examples:");
|
|
100
|
+
getExamples().forEach((ex) => console.log(` - ${ex}`));
|
|
101
|
+
import_node_process.default.exit(1);
|
|
102
|
+
}
|
|
103
|
+
console.log(`
|
|
104
|
+
\u{1F680} Running "${example}" example...
|
|
105
|
+
`);
|
|
106
|
+
let child = null;
|
|
107
|
+
try {
|
|
108
|
+
const nodeModulesPath = (0, import_path.join)(examplePath, "node_modules");
|
|
109
|
+
const nodeModulesExists = (0, import_fs.existsSync)(nodeModulesPath);
|
|
110
|
+
if (!nodeModulesExists) {
|
|
111
|
+
console.log("\u{1F4E6} Installing dependencies...");
|
|
112
|
+
runCommand("npm install", examplePath);
|
|
113
|
+
}
|
|
114
|
+
console.log("\u{1F4E6} Building artifacts...");
|
|
115
|
+
runCommand("npm run build", examplePath);
|
|
116
|
+
console.log("\u{1F310} Starting server...\n");
|
|
117
|
+
console.log("Press Ctrl+C to stop\n");
|
|
118
|
+
child = await spawnCommand(["run", "dev"], examplePath);
|
|
119
|
+
import_node_process.default.on("SIGINT", () => {
|
|
120
|
+
if (child) child.kill("SIGINT");
|
|
121
|
+
});
|
|
122
|
+
import_node_process.default.on("SIGTERM", () => {
|
|
123
|
+
if (child) child.kill("SIGTERM");
|
|
124
|
+
});
|
|
125
|
+
await new Promise((resolve, reject) => {
|
|
126
|
+
if (!child) {
|
|
127
|
+
reject(new Error("Child process not started"));
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
child.on("exit", (code) => {
|
|
131
|
+
if (code === 0 || code === null) {
|
|
132
|
+
resolve();
|
|
133
|
+
} else {
|
|
134
|
+
reject(new Error(`Process exited with code ${code}`));
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
child.on("error", reject);
|
|
138
|
+
});
|
|
139
|
+
} catch (err) {
|
|
140
|
+
if (err.code !== "SIGINT" && err.code !== "SIGTERM") {
|
|
141
|
+
console.error(`
|
|
142
|
+
\u274C Error: ${err.message}`);
|
|
143
|
+
import_node_process.default.exit(1);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
main();
|
|
148
|
+
//# sourceMappingURL=adorn-example.cjs.map
|