@velajs/vela 1.19.0 → 1.19.1
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/CHANGELOG.md +22 -14
- package/dist/configurable-module.builder-5FGMaXG6.js +91 -0
- package/dist/configurable-module.builder-5FGMaXG6.js.map +1 -0
- package/dist/container-BqUHID4l.js +645 -0
- package/dist/container-BqUHID4l.js.map +1 -0
- package/dist/cron-matcher-C9qv5OUA.js +113 -0
- package/dist/cron-matcher-C9qv5OUA.js.map +1 -0
- package/dist/decorate-GcSMAbKn.js +528 -0
- package/dist/decorate-GcSMAbKn.js.map +1 -0
- package/dist/decorators-C8YBFCIk.js +53 -0
- package/dist/decorators-C8YBFCIk.js.map +1 -0
- package/dist/define-module-NOyOZNXD.js +235 -0
- package/dist/define-module-NOyOZNXD.js.map +1 -0
- package/dist/discovery.service-BYm95SSD.js +368 -0
- package/dist/discovery.service-BYm95SSD.js.map +1 -0
- package/dist/discovery.service-Cpf1QcZ5.d.ts +648 -0
- package/dist/i18n/index.d.ts +138 -10
- package/dist/i18n/index.js +270 -8
- package/dist/i18n/index.js.map +1 -0
- package/dist/index-D72EQfcC.d.ts +430 -0
- package/dist/index-DhShDLCM.d.ts +2310 -0
- package/dist/index.d.ts +6 -70
- package/dist/index.js +14 -76
- package/dist/internal.d.ts +13 -17
- package/dist/internal.js +6 -19
- package/dist/live/index.d.ts +2 -12
- package/dist/live/index.js +826 -16
- package/dist/live/index.js.map +1 -0
- package/dist/metadata.registry-D1od8ZBt.d.ts +842 -0
- package/dist/plugin-ByBlVOve.js +1387 -0
- package/dist/plugin-ByBlVOve.js.map +1 -0
- package/dist/queue/index.d.ts +247 -10
- package/dist/queue/index.js +384 -12
- package/dist/queue/index.js.map +1 -0
- package/dist/request-context-C3nCGJNd.js +26 -0
- package/dist/request-context-C3nCGJNd.js.map +1 -0
- package/dist/route.manager-DRAZ5X04.js +991 -0
- package/dist/route.manager-DRAZ5X04.js.map +1 -0
- package/dist/schedule-node/index.d.ts +32 -3
- package/dist/schedule-node/index.js +97 -3
- package/dist/schedule-node/index.js.map +1 -0
- package/dist/schedule.registry-DVm7Jp5w.d.ts +55 -0
- package/dist/seeder/index.d.ts +75 -5
- package/dist/seeder/index.js +105 -4
- package/dist/seeder/index.js.map +1 -0
- package/dist/signed-url-CMmi0SIb.js +56 -0
- package/dist/signed-url-CMmi0SIb.js.map +1 -0
- package/dist/signed-url-DKhgja4U.d.ts +16 -0
- package/dist/src-eb5CI6Xn.js +2151 -0
- package/dist/src-eb5CI6Xn.js.map +1 -0
- package/dist/storage/index.d.ts +57 -4
- package/dist/storage/index.js +22 -5
- package/dist/storage/index.js.map +1 -0
- package/dist/streaming/index.d.ts +2 -2
- package/dist/streaming/index.js +2 -1
- package/dist/websocket/index.d.ts +3 -12
- package/dist/websocket/index.js +2 -16
- package/dist/websocket-DXmB-MWJ.js +697 -0
- package/dist/websocket-DXmB-MWJ.js.map +1 -0
- package/dist/websocket-node/index.d.ts +108 -6
- package/dist/websocket-node/index.js +228 -6
- package/dist/websocket-node/index.js.map +1 -0
- package/package.json +66 -53
- package/dist/__tests__/workers/entry.d.ts +0 -9
- package/dist/__tests__/workers-als/entry-als.d.ts +0 -9
- package/dist/application.d.ts +0 -104
- package/dist/application.js +0 -364
- package/dist/cache/cache.decorators.d.ts +0 -2
- package/dist/cache/cache.decorators.js +0 -4
- package/dist/cache/cache.interceptor.d.ts +0 -9
- package/dist/cache/cache.interceptor.js +0 -60
- package/dist/cache/cache.module.d.ts +0 -7
- package/dist/cache/cache.module.js +0 -58
- package/dist/cache/cache.service.d.ts +0 -9
- package/dist/cache/cache.service.js +0 -42
- package/dist/cache/cache.store.d.ts +0 -12
- package/dist/cache/cache.store.js +0 -51
- package/dist/cache/cache.tokens.d.ts +0 -6
- package/dist/cache/cache.tokens.js +0 -5
- package/dist/cache/cache.types.d.ts +0 -41
- package/dist/cache/cache.types.js +0 -1
- package/dist/cache/index.d.ts +0 -8
- package/dist/cache/index.js +0 -7
- package/dist/cache/tiered-cache.store.d.ts +0 -19
- package/dist/cache/tiered-cache.store.js +0 -40
- package/dist/config/config.module.d.ts +0 -19
- package/dist/config/config.module.js +0 -98
- package/dist/config/config.service.d.ts +0 -20
- package/dist/config/config.service.js +0 -43
- package/dist/config/config.store.d.ts +0 -46
- package/dist/config/config.store.js +0 -119
- package/dist/config/config.tokens.d.ts +0 -13
- package/dist/config/config.tokens.js +0 -14
- package/dist/config/config.types.d.ts +0 -41
- package/dist/config/config.types.js +0 -4
- package/dist/config/index.d.ts +0 -7
- package/dist/config/index.js +0 -5
- package/dist/config/register-as.d.ts +0 -52
- package/dist/config/register-as.js +0 -39
- package/dist/constants.d.ts +0 -44
- package/dist/constants.js +0 -46
- package/dist/container/container.d.ts +0 -154
- package/dist/container/container.js +0 -849
- package/dist/container/decorators.d.ts +0 -17
- package/dist/container/decorators.js +0 -57
- package/dist/container/disposable.d.ts +0 -5
- package/dist/container/disposable.js +0 -33
- package/dist/container/index.d.ts +0 -6
- package/dist/container/index.js +0 -5
- package/dist/container/mixin.d.ts +0 -24
- package/dist/container/mixin.js +0 -26
- package/dist/container/module-ref.d.ts +0 -21
- package/dist/container/module-ref.js +0 -48
- package/dist/container/types.d.ts +0 -154
- package/dist/container/types.js +0 -49
- package/dist/cors/cors.module.d.ts +0 -7
- package/dist/cors/cors.module.js +0 -37
- package/dist/cors/cors.tokens.d.ts +0 -3
- package/dist/cors/cors.tokens.js +0 -2
- package/dist/cors/cors.types.d.ts +0 -8
- package/dist/cors/cors.types.js +0 -1
- package/dist/cors/index.d.ts +0 -3
- package/dist/cors/index.js +0 -2
- package/dist/crypto/signed-url.d.ts +0 -12
- package/dist/crypto/signed-url.js +0 -60
- package/dist/discovery/discoverable.decorator.d.ts +0 -38
- package/dist/discovery/discoverable.decorator.js +0 -42
- package/dist/discovery/discovery.service.d.ts +0 -102
- package/dist/discovery/discovery.service.js +0 -177
- package/dist/discovery/index.d.ts +0 -2
- package/dist/discovery/index.js +0 -2
- package/dist/entrypoint/entrypoint.registry.d.ts +0 -42
- package/dist/entrypoint/entrypoint.registry.js +0 -112
- package/dist/entrypoint/entrypoint.types.d.ts +0 -41
- package/dist/entrypoint/entrypoint.types.js +0 -3
- package/dist/entrypoint/execution-context.d.ts +0 -15
- package/dist/entrypoint/execution-context.js +0 -21
- package/dist/entrypoint/execution-scope.d.ts +0 -21
- package/dist/entrypoint/execution-scope.js +0 -28
- package/dist/entrypoint/index.d.ts +0 -4
- package/dist/entrypoint/index.js +0 -4
- package/dist/errors/http-exception.d.ts +0 -63
- package/dist/errors/http-exception.js +0 -142
- package/dist/errors/index.d.ts +0 -1
- package/dist/errors/index.js +0 -1
- package/dist/event-emitter/event-emitter.decorators.d.ts +0 -1
- package/dist/event-emitter/event-emitter.decorators.js +0 -10
- package/dist/event-emitter/event-emitter.module.d.ts +0 -2
- package/dist/event-emitter/event-emitter.module.js +0 -23
- package/dist/event-emitter/event-emitter.service.d.ts +0 -13
- package/dist/event-emitter/event-emitter.service.js +0 -127
- package/dist/event-emitter/event-emitter.subscriber.d.ts +0 -9
- package/dist/event-emitter/event-emitter.subscriber.js +0 -45
- package/dist/event-emitter/event-emitter.tokens.d.ts +0 -1
- package/dist/event-emitter/event-emitter.tokens.js +0 -1
- package/dist/event-emitter/event-emitter.types.d.ts +0 -5
- package/dist/event-emitter/event-emitter.types.js +0 -1
- package/dist/event-emitter/index.d.ts +0 -6
- package/dist/event-emitter/index.js +0 -5
- package/dist/exceptions/errors.module.d.ts +0 -40
- package/dist/exceptions/errors.module.js +0 -46
- package/dist/exceptions/exception-handler.d.ts +0 -56
- package/dist/exceptions/exception-handler.js +0 -17
- package/dist/exceptions/index.d.ts +0 -6
- package/dist/exceptions/index.js +0 -3
- package/dist/exceptions/reporter.d.ts +0 -21
- package/dist/exceptions/reporter.js +0 -70
- package/dist/factory/adapter.d.ts +0 -36
- package/dist/factory/adapter.js +0 -18
- package/dist/factory/bootstrap.d.ts +0 -23
- package/dist/factory/bootstrap.js +0 -110
- package/dist/factory.d.ts +0 -16
- package/dist/factory.js +0 -36
- package/dist/fetch/fetch.module.d.ts +0 -7
- package/dist/fetch/fetch.module.js +0 -31
- package/dist/fetch/fetch.service.d.ts +0 -24
- package/dist/fetch/fetch.service.js +0 -145
- package/dist/fetch/fetch.types.d.ts +0 -24
- package/dist/fetch/fetch.types.js +0 -1
- package/dist/fetch/index.d.ts +0 -3
- package/dist/fetch/index.js +0 -2
- package/dist/health/health.http.d.ts +0 -14
- package/dist/health/health.http.js +0 -75
- package/dist/health/health.indicator.d.ts +0 -9
- package/dist/health/health.indicator.js +0 -32
- package/dist/health/health.module.d.ts +0 -2
- package/dist/health/health.module.js +0 -26
- package/dist/health/health.service.d.ts +0 -7
- package/dist/health/health.service.js +0 -69
- package/dist/health/health.types.d.ts +0 -15
- package/dist/health/health.types.js +0 -1
- package/dist/health/index.d.ts +0 -6
- package/dist/health/index.js +0 -4
- package/dist/http/ambient.d.ts +0 -17
- package/dist/http/ambient.js +0 -44
- package/dist/http/argument-resolver.d.ts +0 -10
- package/dist/http/argument-resolver.js +0 -89
- package/dist/http/decorators.d.ts +0 -198
- package/dist/http/decorators.js +0 -321
- package/dist/http/execution-context.d.ts +0 -8
- package/dist/http/execution-context.js +0 -35
- package/dist/http/handler-executor.d.ts +0 -20
- package/dist/http/handler-executor.js +0 -133
- package/dist/http/index.d.ts +0 -12
- package/dist/http/index.js +0 -7
- package/dist/http/instantiate.d.ts +0 -4
- package/dist/http/instantiate.js +0 -45
- package/dist/http/lazy-param.decorator.d.ts +0 -37
- package/dist/http/lazy-param.decorator.js +0 -117
- package/dist/http/request-container.d.ts +0 -16
- package/dist/http/request-container.js +0 -19
- package/dist/http/request-context.d.ts +0 -13
- package/dist/http/request-context.js +0 -22
- package/dist/http/response-mapper.d.ts +0 -8
- package/dist/http/response-mapper.js +0 -42
- package/dist/http/route-contributor.d.ts +0 -68
- package/dist/http/route-contributor.js +0 -22
- package/dist/http/route-map.d.ts +0 -30
- package/dist/http/route-map.js +0 -27
- package/dist/http/route.manager.d.ts +0 -92
- package/dist/http/route.manager.js +0 -481
- package/dist/http/types.d.ts +0 -37
- package/dist/http/types.js +0 -1
- package/dist/http/url/index.d.ts +0 -4
- package/dist/http/url/index.js +0 -3
- package/dist/http/url/signed-url.guard.d.ts +0 -27
- package/dist/http/url/signed-url.guard.js +0 -62
- package/dist/http/url/signing-secret.d.ts +0 -20
- package/dist/http/url/signing-secret.js +0 -24
- package/dist/http/url/url-generator.service.d.ts +0 -52
- package/dist/http/url/url-generator.service.js +0 -104
- package/dist/i18n/deep-merge.d.ts +0 -2
- package/dist/i18n/deep-merge.js +0 -15
- package/dist/i18n/i18n.middleware.d.ts +0 -15
- package/dist/i18n/i18n.middleware.js +0 -94
- package/dist/i18n/i18n.module.d.ts +0 -13
- package/dist/i18n/i18n.module.js +0 -69
- package/dist/i18n/i18n.options.d.ts +0 -30
- package/dist/i18n/i18n.options.js +0 -16
- package/dist/i18n/i18n.service.d.ts +0 -20
- package/dist/i18n/i18n.service.js +0 -49
- package/dist/i18n/i18n.tokens.d.ts +0 -6
- package/dist/i18n/i18n.tokens.js +0 -3
- package/dist/i18n/i18n.types.d.ts +0 -6
- package/dist/i18n/i18n.types.js +0 -1
- package/dist/i18n/message-loader.service.d.ts +0 -21
- package/dist/i18n/message-loader.service.js +0 -90
- package/dist/i18n/message-registry.d.ts +0 -16
- package/dist/i18n/message-registry.js +0 -49
- package/dist/lifecycle/index.d.ts +0 -20
- package/dist/lifecycle/index.js +0 -15
- package/dist/live/live.cursor.d.ts +0 -22
- package/dist/live/live.cursor.js +0 -56
- package/dist/live/live.decorators.d.ts +0 -32
- package/dist/live/live.decorators.js +0 -46
- package/dist/live/live.delta.d.ts +0 -15
- package/dist/live/live.delta.js +0 -51
- package/dist/live/live.engine.d.ts +0 -88
- package/dist/live/live.engine.js +0 -471
- package/dist/live/live.invalidation.d.ts +0 -45
- package/dist/live/live.invalidation.js +0 -99
- package/dist/live/live.module.d.ts +0 -28
- package/dist/live/live.module.js +0 -87
- package/dist/live/live.tokens.d.ts +0 -9
- package/dist/live/live.tokens.js +0 -8
- package/dist/live/live.types.d.ts +0 -138
- package/dist/live/live.types.js +0 -1
- package/dist/live/presence.d.ts +0 -44
- package/dist/live/presence.js +0 -130
- package/dist/metadata.d.ts +0 -10
- package/dist/metadata.js +0 -20
- package/dist/module/configurable-module.builder.d.ts +0 -56
- package/dist/module/configurable-module.builder.js +0 -84
- package/dist/module/configurable-module.types.d.ts +0 -93
- package/dist/module/configurable-module.types.js +0 -5
- package/dist/module/decorators.d.ts +0 -10
- package/dist/module/decorators.js +0 -47
- package/dist/module/define-module.d.ts +0 -112
- package/dist/module/define-module.js +0 -232
- package/dist/module/graph.d.ts +0 -10
- package/dist/module/graph.js +0 -35
- package/dist/module/index.d.ts +0 -10
- package/dist/module/index.js +0 -7
- package/dist/module/lazy-modules.d.ts +0 -82
- package/dist/module/lazy-modules.js +0 -231
- package/dist/module/lazy-provider.d.ts +0 -65
- package/dist/module/lazy-provider.js +0 -111
- package/dist/module/middleware.d.ts +0 -30
- package/dist/module/middleware.js +0 -67
- package/dist/module/module-loader.d.ts +0 -58
- package/dist/module/module-loader.js +0 -484
- package/dist/module/stable-hash.d.ts +0 -15
- package/dist/module/stable-hash.js +0 -52
- package/dist/module/types.d.ts +0 -1
- package/dist/module/types.js +0 -1
- package/dist/openapi/decorators.d.ts +0 -34
- package/dist/openapi/decorators.js +0 -66
- package/dist/openapi/document.d.ts +0 -3
- package/dist/openapi/document.js +0 -316
- package/dist/openapi/index.d.ts +0 -7
- package/dist/openapi/index.js +0 -6
- package/dist/openapi/redoc-ui.d.ts +0 -1
- package/dist/openapi/redoc-ui.js +0 -19
- package/dist/openapi/scalar-ui.d.ts +0 -1
- package/dist/openapi/scalar-ui.js +0 -19
- package/dist/openapi/swagger-ui.d.ts +0 -1
- package/dist/openapi/swagger-ui.js +0 -23
- package/dist/openapi/types.d.ts +0 -182
- package/dist/openapi/types.js +0 -4
- package/dist/openapi/zod-to-json-schema.d.ts +0 -4
- package/dist/openapi/zod-to-json-schema.js +0 -57
- package/dist/pipeline/app-providers.d.ts +0 -10
- package/dist/pipeline/app-providers.js +0 -43
- package/dist/pipeline/component.manager.d.ts +0 -25
- package/dist/pipeline/component.manager.js +0 -66
- package/dist/pipeline/decorators.d.ts +0 -10
- package/dist/pipeline/decorators.js +0 -42
- package/dist/pipeline/index.d.ts +0 -12
- package/dist/pipeline/index.js +0 -7
- package/dist/pipeline/pipeline-runner.d.ts +0 -31
- package/dist/pipeline/pipeline-runner.js +0 -40
- package/dist/pipeline/pipes.d.ts +0 -48
- package/dist/pipeline/pipes.js +0 -104
- package/dist/pipeline/reflector.d.ts +0 -86
- package/dist/pipeline/reflector.js +0 -121
- package/dist/pipeline/scoped-components.d.ts +0 -26
- package/dist/pipeline/scoped-components.js +0 -27
- package/dist/pipeline/tokens.d.ts +0 -57
- package/dist/pipeline/tokens.js +0 -47
- package/dist/pipeline/types.d.ts +0 -64
- package/dist/pipeline/types.js +0 -1
- package/dist/plugin/plugin.d.ts +0 -31
- package/dist/plugin/plugin.js +0 -111
- package/dist/queue/inline.driver.d.ts +0 -30
- package/dist/queue/inline.driver.js +0 -58
- package/dist/queue/queue.binding.d.ts +0 -23
- package/dist/queue/queue.binding.js +0 -60
- package/dist/queue/queue.client.d.ts +0 -20
- package/dist/queue/queue.client.js +0 -33
- package/dist/queue/queue.decorators.d.ts +0 -23
- package/dist/queue/queue.decorators.js +0 -46
- package/dist/queue/queue.dispatch.d.ts +0 -36
- package/dist/queue/queue.dispatch.js +0 -109
- package/dist/queue/queue.module.d.ts +0 -32
- package/dist/queue/queue.module.js +0 -80
- package/dist/queue/queue.tokens.d.ts +0 -21
- package/dist/queue/queue.tokens.js +0 -34
- package/dist/queue/queue.types.d.ts +0 -61
- package/dist/queue/queue.types.js +0 -4
- package/dist/registry/index.d.ts +0 -2
- package/dist/registry/index.js +0 -1
- package/dist/registry/metadata.registry.d.ts +0 -73
- package/dist/registry/metadata.registry.js +0 -357
- package/dist/registry/paths.d.ts +0 -3
- package/dist/registry/paths.js +0 -15
- package/dist/registry/types.d.ts +0 -116
- package/dist/registry/types.js +0 -1
- package/dist/registry/util.d.ts +0 -3
- package/dist/registry/util.js +0 -8
- package/dist/schedule/cron-matcher.d.ts +0 -2
- package/dist/schedule/cron-matcher.js +0 -62
- package/dist/schedule/index.d.ts +0 -8
- package/dist/schedule/index.js +0 -5
- package/dist/schedule/schedule.decorators.d.ts +0 -2
- package/dist/schedule/schedule.decorators.js +0 -18
- package/dist/schedule/schedule.module.d.ts +0 -9
- package/dist/schedule/schedule.module.js +0 -28
- package/dist/schedule/schedule.registry.d.ts +0 -23
- package/dist/schedule/schedule.registry.js +0 -63
- package/dist/schedule/schedule.tokens.d.ts +0 -2
- package/dist/schedule/schedule.tokens.js +0 -2
- package/dist/schedule/schedule.types.d.ts +0 -8
- package/dist/schedule/schedule.types.js +0 -1
- package/dist/schedule-node/schedule-node.module.d.ts +0 -9
- package/dist/schedule-node/schedule-node.module.js +0 -28
- package/dist/schedule-node/schedule.executor.d.ts +0 -19
- package/dist/schedule-node/schedule.executor.js +0 -112
- package/dist/seeder/seeder.decorator.d.ts +0 -7
- package/dist/seeder/seeder.decorator.js +0 -15
- package/dist/seeder/seeder.module.d.ts +0 -16
- package/dist/seeder/seeder.module.js +0 -44
- package/dist/seeder/seeder.registry.d.ts +0 -23
- package/dist/seeder/seeder.registry.js +0 -83
- package/dist/seeder/seeder.tokens.d.ts +0 -2
- package/dist/seeder/seeder.tokens.js +0 -1
- package/dist/seeder/seeder.types.d.ts +0 -20
- package/dist/seeder/seeder.types.js +0 -1
- package/dist/serialization/index.d.ts +0 -2
- package/dist/serialization/index.js +0 -2
- package/dist/serialization/serialize.decorator.d.ts +0 -6
- package/dist/serialization/serialize.decorator.js +0 -7
- package/dist/serialization/serializer.interceptor.d.ts +0 -4
- package/dist/serialization/serializer.interceptor.js +0 -16
- package/dist/services/index.d.ts +0 -2
- package/dist/services/index.js +0 -1
- package/dist/services/logger.d.ts +0 -59
- package/dist/services/logger.js +0 -159
- package/dist/storage/path-template.d.ts +0 -9
- package/dist/storage/path-template.js +0 -20
- package/dist/storage/storage.types.d.ts +0 -41
- package/dist/storage/storage.types.js +0 -5
- package/dist/throttler/index.d.ts +0 -6
- package/dist/throttler/index.js +0 -5
- package/dist/throttler/throttler.decorators.d.ts +0 -3
- package/dist/throttler/throttler.decorators.js +0 -4
- package/dist/throttler/throttler.guard.d.ts +0 -9
- package/dist/throttler/throttler.guard.js +0 -72
- package/dist/throttler/throttler.module.d.ts +0 -7
- package/dist/throttler/throttler.module.js +0 -41
- package/dist/throttler/throttler.storage.d.ts +0 -10
- package/dist/throttler/throttler.storage.js +0 -44
- package/dist/throttler/throttler.tokens.d.ts +0 -6
- package/dist/throttler/throttler.tokens.js +0 -5
- package/dist/throttler/throttler.types.d.ts +0 -25
- package/dist/throttler/throttler.types.js +0 -1
- package/dist/validation/create-zod-dto.d.ts +0 -13
- package/dist/validation/create-zod-dto.js +0 -18
- package/dist/validation/index.d.ts +0 -3
- package/dist/validation/index.js +0 -2
- package/dist/validation/validation.pipe.d.ts +0 -4
- package/dist/validation/validation.pipe.js +0 -19
- package/dist/websocket/websocket.decorators.d.ts +0 -47
- package/dist/websocket/websocket.decorators.js +0 -80
- package/dist/websocket/websocket.module.d.ts +0 -35
- package/dist/websocket/websocket.module.js +0 -63
- package/dist/websocket/websocket.tokens.d.ts +0 -30
- package/dist/websocket/websocket.tokens.js +0 -27
- package/dist/websocket/websocket.types.d.ts +0 -102
- package/dist/websocket/websocket.types.js +0 -4
- package/dist/websocket/ws-argument-resolver.d.ts +0 -13
- package/dist/websocket/ws-argument-resolver.js +0 -40
- package/dist/websocket/ws-dispatcher.d.ts +0 -54
- package/dist/websocket/ws-dispatcher.js +0 -343
- package/dist/websocket/ws-exception.d.ts +0 -25
- package/dist/websocket/ws-exception.js +0 -42
- package/dist/websocket/ws-execution-context.d.ts +0 -9
- package/dist/websocket/ws-execution-context.js +0 -24
- package/dist/websocket/ws-server.d.ts +0 -31
- package/dist/websocket/ws-server.js +0 -74
- package/dist/websocket/ws-sync.d.ts +0 -47
- package/dist/websocket/ws-sync.js +0 -74
- package/dist/websocket-node/node-ws-client.d.ts +0 -24
- package/dist/websocket-node/node-ws-client.js +0 -49
- package/dist/websocket-node/redis-live.d.ts +0 -24
- package/dist/websocket-node/redis-live.js +0 -57
- package/dist/websocket-node/redis-sync.d.ts +0 -33
- package/dist/websocket-node/redis-sync.js +0 -56
- package/dist/websocket-node/register-gateways.d.ts +0 -20
- package/dist/websocket-node/register-gateways.js +0 -61
|
@@ -0,0 +1,2310 @@
|
|
|
1
|
+
import { a as OnApplicationBootstrap, i as BeforeApplicationShutdown } from "./schedule.registry-DVm7Jp5w.js";
|
|
2
|
+
import { A as NestInterceptor, B as InferTokens, D as ExceptionFilter, E as CanActivate, F as Constructor, H as InjectableOptions, J as ProviderOptions, M as PipeTransform, N as WsArgumentsHost, O as ExecutionContext, P as Container, R as ForwardRef, S as PipeType, T as CallHandler, U as InjectionToken, X as Token, Z as Type, d as ComponentTypeMap, f as DynamicModule, i as DiscoveryService, j as NestMiddleware, l as ComponentInstance, u as ComponentType, v as ModuleImport, w as ArgumentMetadata, x as ParameterMetadata } from "./discovery.service-Cpf1QcZ5.js";
|
|
3
|
+
import { A as CreateOpenApiDocumentOptions, D as ApiDocMetadata, E as VelaApplication, L as OpenApiPathItem, M as JsonSchema, N as OpenApiDocument, S as BootstrapOptions, U as ControllerOptions, V as RouteManager, X as ContributesEntrypoints, Z as Entrypoint, k as ApiResponseOptions, nt as ExceptionHandler, tt as ErrorReportContext } from "./metadata.registry-D1od8ZBt.js";
|
|
4
|
+
import { CORE_CATALOG as CORE_CATALOG$1, Catalog, Catalog as Catalog$1, ErrorBodyResult, ErrorBodyResult as ErrorBodyResult$1, ErrorCatalogEntry, VelaError, VelaErrorOptions, composeCatalogs as composeCatalogs$1, defineErrorCatalog, isVelaError as isVelaError$1, toErrorBody as toErrorBody$1 } from "@velajs/errors";
|
|
5
|
+
import { Context, Hono, MiddlewareHandler } from "hono";
|
|
6
|
+
import { env, getRuntimeKey } from "hono/adapter";
|
|
7
|
+
//#region src/factory/adapter.d.ts
|
|
8
|
+
/** The framework's resolved world, handed to adapter hooks. */
|
|
9
|
+
interface AdapterContext {
|
|
10
|
+
app: VelaApplication;
|
|
11
|
+
container: Container;
|
|
12
|
+
routeManager: RouteManager;
|
|
13
|
+
discovery: DiscoveryService;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The contract a runtime binding implements to plug a platform into a Vela
|
|
17
|
+
* app — what `@velajs/cloudflare` (bindings + Durable Object WebSocket) and
|
|
18
|
+
* the Node/Bun WebSocket transport do, made first-class:
|
|
19
|
+
*
|
|
20
|
+
* ```ts
|
|
21
|
+
* const app = await VelaFactory.create(AppModule, {
|
|
22
|
+
* adapters: [cloudflareAdapter({ bindings })],
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* - `requestMiddleware` is prepended to the global middleware chain (runs
|
|
27
|
+
* before consumer middleware — e.g. capture `c.env` for binding services).
|
|
28
|
+
* - `onBootstrap` runs after DI + lifecycle hooks, with `app.entrypoints`
|
|
29
|
+
* available, BEFORE routes are built — register platform services here.
|
|
30
|
+
* - `onRoutesBuilt` runs after the Hono app exists — mount platform routes
|
|
31
|
+
* (WebSocket upgrades, health endpoints) here via `ctx.app.getHonoApp()`.
|
|
32
|
+
*/
|
|
33
|
+
interface RuntimeAdapter {
|
|
34
|
+
name: string;
|
|
35
|
+
requestMiddleware?: MiddlewareHandler[];
|
|
36
|
+
onBootstrap?(ctx: AdapterContext): void | Promise<void>;
|
|
37
|
+
onRoutesBuilt?(ctx: AdapterContext): void | Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/factory.d.ts
|
|
41
|
+
interface VelaCreateOptions extends BootstrapOptions {
|
|
42
|
+
/**
|
|
43
|
+
* Runtime adapters binding this app to a platform (Cloudflare bindings,
|
|
44
|
+
* WebSocket transports, …). Their `requestMiddleware` is prepended to the
|
|
45
|
+
* global middleware chain; `onBootstrap`/`onRoutesBuilt` hooks run around
|
|
46
|
+
* route building. See {@link RuntimeAdapter}.
|
|
47
|
+
*/
|
|
48
|
+
adapters?: RuntimeAdapter[];
|
|
49
|
+
}
|
|
50
|
+
declare const VelaFactory: {
|
|
51
|
+
create(rootModule: Type, options?: VelaCreateOptions): Promise<VelaApplication>;
|
|
52
|
+
};
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/openapi/document.d.ts
|
|
55
|
+
declare function createOpenApiDocument(rootModule: Type, options?: CreateOpenApiDocumentOptions): OpenApiDocument;
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/openapi/decorators.d.ts
|
|
58
|
+
/**
|
|
59
|
+
* Attach OpenAPI documentation to a route handler (or controller).
|
|
60
|
+
*
|
|
61
|
+
* ```ts
|
|
62
|
+
* @Get('/:id')
|
|
63
|
+
* @ApiDoc({ summary: 'Get a user', description: '...', operationId: 'getUser' })
|
|
64
|
+
* findOne(@Param('id') id: string) { ... }
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
declare function ApiDoc(metadata: ApiDocMetadata): MethodDecorator & ClassDecorator;
|
|
68
|
+
/**
|
|
69
|
+
* Attach OpenAPI tags to a controller or handler. Handler-level tags merge
|
|
70
|
+
* with controller-level tags; duplicates are de-duplicated in the output.
|
|
71
|
+
*/
|
|
72
|
+
declare function ApiTags(...tags: string[]): MethodDecorator & ClassDecorator;
|
|
73
|
+
/**
|
|
74
|
+
* Document a response for a given status code. Stackable: apply multiple
|
|
75
|
+
* times on the same handler to declare different statuses.
|
|
76
|
+
*
|
|
77
|
+
* ```ts
|
|
78
|
+
* @Get('/:id')
|
|
79
|
+
* @ApiResponse(200, { description: 'Found', schema: UserDto })
|
|
80
|
+
* @ApiResponse(404, { description: 'Not found', schema: ErrorDto })
|
|
81
|
+
* findOne() { ... }
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
declare function ApiResponse(status: number | string, options: ApiResponseOptions): MethodDecorator;
|
|
85
|
+
//#endregion
|
|
86
|
+
//#region src/openapi/zod-to-json-schema.d.ts
|
|
87
|
+
declare function zodToJsonSchema(schema: unknown): JsonSchema;
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/container/decorators.d.ts
|
|
90
|
+
declare function Injectable(options?: InjectableOptions): ClassDecorator;
|
|
91
|
+
declare function Optional(): ParameterDecorator;
|
|
92
|
+
declare function Inject(token: Token | ForwardRef): ParameterDecorator;
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region src/container/mixin.d.ts
|
|
95
|
+
/**
|
|
96
|
+
* Creates a reusable injectable mixin class from a base class.
|
|
97
|
+
* Applies @Injectable() so the returned class can be registered as a provider.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```ts
|
|
101
|
+
* function RoleGuardMixin(role: string) {
|
|
102
|
+
* class MixedRoleGuard implements CanActivate {
|
|
103
|
+
* canActivate(ctx: ExecutionContext) {
|
|
104
|
+
* return ctx.getRequest().headers.get('x-role') === role;
|
|
105
|
+
* }
|
|
106
|
+
* }
|
|
107
|
+
* return mixin(MixedRoleGuard);
|
|
108
|
+
* }
|
|
109
|
+
*
|
|
110
|
+
* const AdminGuard = RoleGuardMixin('admin');
|
|
111
|
+
*
|
|
112
|
+
* @UseGuards(AdminGuard)
|
|
113
|
+
* @Get('/admin')
|
|
114
|
+
* adminOnly() { ... }
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
declare function mixin<T>(mixinClass: Type<T>): Type<T>;
|
|
118
|
+
//#endregion
|
|
119
|
+
//#region src/http/decorators.d.ts
|
|
120
|
+
/**
|
|
121
|
+
* Marks a class as a controller.
|
|
122
|
+
* Accepts a path string or an options object with `path` and `version`.
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```ts
|
|
126
|
+
* @Controller('/users')
|
|
127
|
+
* @Controller({ path: '/users', version: 1 })
|
|
128
|
+
* @Controller({ path: '/users', version: [1, 2] })
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
declare function Controller(pathOrOptions?: string | ControllerOptions): ClassDecorator;
|
|
132
|
+
/**
|
|
133
|
+
* Override the version for a specific route method.
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```ts
|
|
137
|
+
* @Controller({ prefix: '/users', version: 1 })
|
|
138
|
+
* class UserController {
|
|
139
|
+
* @Get()
|
|
140
|
+
* listV1() { ... } // GET /v1/users
|
|
141
|
+
*
|
|
142
|
+
* @Version(2)
|
|
143
|
+
* @Get()
|
|
144
|
+
* listV2() { ... } // GET /v2/users
|
|
145
|
+
* }
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
declare function Version(version: number | number[]): MethodDecorator;
|
|
149
|
+
/** Per-route options for the HTTP method decorators (`@Get`, `@Post`, …). */
|
|
150
|
+
interface RouteOptions {
|
|
151
|
+
/**
|
|
152
|
+
* A stable, human-readable name for this route. Enables URL generation
|
|
153
|
+
* (`UrlGeneratorService.urlFor(name, …)`), surfaces on `app.describeRoutes()`,
|
|
154
|
+
* and — when set — becomes the OpenAPI `operationId`.
|
|
155
|
+
*/
|
|
156
|
+
name?: string;
|
|
157
|
+
}
|
|
158
|
+
declare const Get: (path?: string, options?: RouteOptions) => MethodDecorator;
|
|
159
|
+
declare const Post: (path?: string, options?: RouteOptions) => MethodDecorator;
|
|
160
|
+
declare const Put: (path?: string, options?: RouteOptions) => MethodDecorator;
|
|
161
|
+
declare const Patch: (path?: string, options?: RouteOptions) => MethodDecorator;
|
|
162
|
+
declare const Delete: (path?: string, options?: RouteOptions) => MethodDecorator;
|
|
163
|
+
declare const Options: (path?: string, options?: RouteOptions) => MethodDecorator;
|
|
164
|
+
declare const Head: (path?: string, options?: RouteOptions) => MethodDecorator;
|
|
165
|
+
declare const All: (path?: string, options?: RouteOptions) => MethodDecorator;
|
|
166
|
+
declare const Sse: (path?: string, options?: RouteOptions) => MethodDecorator;
|
|
167
|
+
declare const Param: (nameOrPipe?: string | PipeType, ...pipes: PipeType[]) => ParameterDecorator;
|
|
168
|
+
declare const Query: (nameOrPipe?: string | PipeType, ...pipes: PipeType[]) => ParameterDecorator;
|
|
169
|
+
declare const Body: (nameOrPipe?: string | PipeType, ...pipes: PipeType[]) => ParameterDecorator;
|
|
170
|
+
declare const Headers$1: (nameOrPipe?: string | PipeType, ...pipes: PipeType[]) => ParameterDecorator;
|
|
171
|
+
declare const Req: (nameOrPipe?: string | PipeType, ...pipes: PipeType[]) => ParameterDecorator;
|
|
172
|
+
/**
|
|
173
|
+
* Injects the Hono `Context` as the response handle.
|
|
174
|
+
* In Hono, request and response state are unified in the `Context` object,
|
|
175
|
+
* so `@Res()` and `@Req()` both return it.
|
|
176
|
+
*
|
|
177
|
+
* Use `c.header()`, `c.setCookie()`, `c.redirect()`, etc. for response control.
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* ```ts
|
|
181
|
+
* @Get('/set-cookie')
|
|
182
|
+
* handle(@Res() c: Context) {
|
|
183
|
+
* c.setCookie('session', 'abc123', { httpOnly: true });
|
|
184
|
+
* return { ok: true };
|
|
185
|
+
* }
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
declare const Res: (nameOrPipe?: string | PipeType, ...pipes: PipeType[]) => ParameterDecorator;
|
|
189
|
+
declare const Ip: (nameOrPipe?: string | PipeType, ...pipes: PipeType[]) => ParameterDecorator;
|
|
190
|
+
declare const Cookie: (nameOrPipe?: string | PipeType, ...pipes: PipeType[]) => ParameterDecorator;
|
|
191
|
+
/**
|
|
192
|
+
* Injects all cookies as a `Record<string, string>`, or a single cookie value by name.
|
|
193
|
+
*
|
|
194
|
+
* - `@Cookie()` — all cookies as an object
|
|
195
|
+
* - `@Cookie('token')` — the value of the `token` cookie
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* ```ts
|
|
199
|
+
* @Get('/me')
|
|
200
|
+
* handle(@Cookie('session') session: string) { ... }
|
|
201
|
+
* ```
|
|
202
|
+
*/
|
|
203
|
+
declare const Cookies: (nameOrPipe?: string | PipeType, ...pipes: PipeType[]) => ParameterDecorator;
|
|
204
|
+
/**
|
|
205
|
+
* Injects the raw request body as a `Uint8Array`.
|
|
206
|
+
* Useful for webhook HMAC verification (Stripe, GitHub, etc.) where you
|
|
207
|
+
* need the raw bytes before any JSON parsing.
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* ```ts
|
|
211
|
+
* @Post('/webhook')
|
|
212
|
+
* async handle(@RawBody() body: Uint8Array) {
|
|
213
|
+
* const sig = new TextDecoder().decode(body);
|
|
214
|
+
* // verify HMAC...
|
|
215
|
+
* }
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
218
|
+
declare function RawBody(): ParameterDecorator;
|
|
219
|
+
/**
|
|
220
|
+
* Factory for creating custom parameter decorators.
|
|
221
|
+
*
|
|
222
|
+
* @example
|
|
223
|
+
* ```ts
|
|
224
|
+
* const CurrentUser = createParamDecorator(
|
|
225
|
+
* (data: unknown, ctx: ExecutionContext) => {
|
|
226
|
+
* const req = ctx.getRequest();
|
|
227
|
+
* return req.headers.get('x-user-id');
|
|
228
|
+
* }
|
|
229
|
+
* );
|
|
230
|
+
*
|
|
231
|
+
* // Usage:
|
|
232
|
+
* @Get()
|
|
233
|
+
* handle(@CurrentUser() userId: string) { ... }
|
|
234
|
+
*
|
|
235
|
+
* // With data argument:
|
|
236
|
+
* const Header = createParamDecorator(
|
|
237
|
+
* (data: string, ctx: ExecutionContext) => {
|
|
238
|
+
* return ctx.getRequest().headers.get(data);
|
|
239
|
+
* }
|
|
240
|
+
* );
|
|
241
|
+
*
|
|
242
|
+
* @Get()
|
|
243
|
+
* handle(@Header('x-request-id') requestId: string) { ... }
|
|
244
|
+
* ```
|
|
245
|
+
*/
|
|
246
|
+
declare function createParamDecorator<TData = unknown>(factory: (data: TData, ctx: ExecutionContext) => unknown): (data?: TData, ...pipes: PipeType[]) => ParameterDecorator;
|
|
247
|
+
/**
|
|
248
|
+
* Override the HTTP status code for a handler's response.
|
|
249
|
+
*
|
|
250
|
+
* @example
|
|
251
|
+
* ```ts
|
|
252
|
+
* @Post()
|
|
253
|
+
* @HttpCode(201)
|
|
254
|
+
* create(@Body() data: CreateDto) { return data; }
|
|
255
|
+
* ```
|
|
256
|
+
*/
|
|
257
|
+
declare function HttpCode(statusCode: number): MethodDecorator;
|
|
258
|
+
/**
|
|
259
|
+
* Set a response header declaratively.
|
|
260
|
+
* Can be applied multiple times to set multiple headers.
|
|
261
|
+
*
|
|
262
|
+
* @example
|
|
263
|
+
* ```ts
|
|
264
|
+
* @Get()
|
|
265
|
+
* @Header('Cache-Control', 'no-cache')
|
|
266
|
+
* @Header('X-Custom', 'value')
|
|
267
|
+
* handle() { return { ok: true }; }
|
|
268
|
+
* ```
|
|
269
|
+
*/
|
|
270
|
+
declare function Header(name: string, value: string): MethodDecorator;
|
|
271
|
+
/**
|
|
272
|
+
* Redirect to another URL. The handler's return value can override the URL.
|
|
273
|
+
*
|
|
274
|
+
* @example
|
|
275
|
+
* ```ts
|
|
276
|
+
* @Get('/old')
|
|
277
|
+
* @Redirect('/new', 301)
|
|
278
|
+
* handleOld() {}
|
|
279
|
+
*
|
|
280
|
+
* // Dynamic redirect — return { url, statusCode? } to override
|
|
281
|
+
* @Get('/go')
|
|
282
|
+
* @Redirect('/default')
|
|
283
|
+
* handleGo(@Query('to') to?: string) {
|
|
284
|
+
* if (to) return { url: to };
|
|
285
|
+
* }
|
|
286
|
+
* ```
|
|
287
|
+
*/
|
|
288
|
+
declare function Redirect(url: string, statusCode?: number): MethodDecorator;
|
|
289
|
+
/**
|
|
290
|
+
* Composes multiple decorators into one. Applies them in order (top to bottom),
|
|
291
|
+
* matching how stacked decorators behave when written separately.
|
|
292
|
+
*
|
|
293
|
+
* @example
|
|
294
|
+
* ```ts
|
|
295
|
+
* const Auth = (...roles: string[]) => applyDecorators(
|
|
296
|
+
* UseGuards(JwtGuard, RolesGuard),
|
|
297
|
+
* SetMetadata('roles', roles),
|
|
298
|
+
* );
|
|
299
|
+
*
|
|
300
|
+
* @Auth('admin')
|
|
301
|
+
* @Get('/admin')
|
|
302
|
+
* handle() { ... }
|
|
303
|
+
* ```
|
|
304
|
+
*/
|
|
305
|
+
type ComposedDecorator = <T>(target: T, propertyKey?: string | symbol, descriptor?: PropertyDescriptor | number) => void;
|
|
306
|
+
declare function applyDecorators(...decorators: Array<ClassDecorator | MethodDecorator | PropertyDecorator | ParameterDecorator>): ComposedDecorator;
|
|
307
|
+
//#endregion
|
|
308
|
+
//#region src/http/lazy-param.decorator.d.ts
|
|
309
|
+
/**
|
|
310
|
+
* Factory for parameter decorators whose value materializes lazily — the
|
|
311
|
+
* factory does not run during argument extraction; it runs the first time
|
|
312
|
+
* the handler reads a property on the resolved value.
|
|
313
|
+
*
|
|
314
|
+
* Why this exists: vela's argument resolver runs *before* guards
|
|
315
|
+
* (handler-executor order: extract args → guards → handler). A custom
|
|
316
|
+
* `createParamDecorator` factory that depends on guard-populated state
|
|
317
|
+
* (e.g. a value a guard places into `REQUEST_CONTEXT`) therefore observes
|
|
318
|
+
* an empty slot. `createLazyParamDecorator` defers factory execution to
|
|
319
|
+
* first property access on the proxied result, by which point guards have
|
|
320
|
+
* run and the slot is populated.
|
|
321
|
+
*
|
|
322
|
+
* The proxy explicitly short-circuits `prop === 'then'` so `await value`
|
|
323
|
+
* does not consider the proxy a thenable, which would otherwise trigger
|
|
324
|
+
* eager resolution. This single invariant is what makes the helper safe to
|
|
325
|
+
* pass through `async` boundaries without surprise.
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
* ```ts
|
|
329
|
+
* const CurrentUser = createLazyParamDecorator(
|
|
330
|
+
* (_data: unknown, ctx: ExecutionContext) => {
|
|
331
|
+
* const reqCtx = ctx.getContext().get('container').resolve(REQUEST_CONTEXT);
|
|
332
|
+
* return reqCtx.get('user'); // populated by AuthGuard
|
|
333
|
+
* },
|
|
334
|
+
* );
|
|
335
|
+
*
|
|
336
|
+
* @UseGuards(AuthGuard)
|
|
337
|
+
* @Get('/me')
|
|
338
|
+
* me(@CurrentUser() user: User) {
|
|
339
|
+
* return { id: user.id }; // factory runs here, after AuthGuard
|
|
340
|
+
* }
|
|
341
|
+
* ```
|
|
342
|
+
*/
|
|
343
|
+
declare function createLazyParamDecorator<TData = unknown>(factory: (data: TData, ctx: ExecutionContext) => unknown): (data?: TData, ...pipes: PipeType[]) => ParameterDecorator;
|
|
344
|
+
//#endregion
|
|
345
|
+
//#region src/http/route-map.d.ts
|
|
346
|
+
/**
|
|
347
|
+
* Augmentable map of route name → its path params. Users opt in to type-safe
|
|
348
|
+
* URL generation by augmenting this interface — no build step, no codegen:
|
|
349
|
+
*
|
|
350
|
+
* ```ts
|
|
351
|
+
* declare module '@velajs/vela' {
|
|
352
|
+
* interface VelaRouteMap {
|
|
353
|
+
* 'users.index': Record<string, never>;
|
|
354
|
+
* 'users.show': { id: string };
|
|
355
|
+
* }
|
|
356
|
+
* }
|
|
357
|
+
* ```
|
|
358
|
+
*
|
|
359
|
+
* Until augmented it stays empty, so `RouteName` falls back to `string` and
|
|
360
|
+
* `RouteParams<N>` to a loose `Record<string, string> | undefined` — untyped
|
|
361
|
+
* callers keep working unchanged.
|
|
362
|
+
*/
|
|
363
|
+
interface VelaRouteMap {}
|
|
364
|
+
/**
|
|
365
|
+
* Every valid route name. Falls back to `string` when `VelaRouteMap` has not
|
|
366
|
+
* been augmented, so `urlFor`/`signedUrl` accept any name in an untyped app.
|
|
367
|
+
*/
|
|
368
|
+
type RouteName = keyof VelaRouteMap extends never ? string : Extract<keyof VelaRouteMap, string>;
|
|
369
|
+
/**
|
|
370
|
+
* The params object required to build a named route's URL. When `VelaRouteMap`
|
|
371
|
+
* is augmented, resolves to the declared params shape for `N`; otherwise a
|
|
372
|
+
* loose `Record<string, string> | undefined`.
|
|
373
|
+
*/
|
|
374
|
+
type RouteParams<N extends RouteName> = N extends keyof VelaRouteMap ? VelaRouteMap[N] : Record<string, string> | undefined;
|
|
375
|
+
//#endregion
|
|
376
|
+
//#region src/http/url/url-generator.service.d.ts
|
|
377
|
+
/** Value accepted for a path param or query entry. */
|
|
378
|
+
type UrlParamValue = string | number | boolean;
|
|
379
|
+
/** Extra options for {@link UrlGeneratorService.urlFor}. */
|
|
380
|
+
interface UrlForOptions {
|
|
381
|
+
/** Additional query-string entries merged after any leftover params. */
|
|
382
|
+
query?: Record<string, UrlParamValue>;
|
|
383
|
+
}
|
|
384
|
+
/** Options for {@link UrlGeneratorService.signedUrl}. */
|
|
385
|
+
interface SignedUrlGenerateOptions {
|
|
386
|
+
/** Time-to-live in seconds; enforced on verification via the `expires` param. */
|
|
387
|
+
expiresIn?: number;
|
|
388
|
+
/** Override the signing secret (else the `URL_SIGNING_SECRET` token / `CONFIG_ENV`). */
|
|
389
|
+
secret?: string;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Builds URLs for named routes (Laravel-flavoured `route()` ergonomics).
|
|
393
|
+
*
|
|
394
|
+
* Route descriptions are read LAZILY from the {@link RouteManager} on first use
|
|
395
|
+
* — post-build, so composition (global prefix + version + controller prefix) is
|
|
396
|
+
* already baked into each path — and it never instantiates controllers, so it
|
|
397
|
+
* plays nicely with lazy modules. Registered as an app-level singleton by
|
|
398
|
+
* `bootstrap`, so it is injectable anywhere.
|
|
399
|
+
*/
|
|
400
|
+
declare class UrlGeneratorService {
|
|
401
|
+
private readonly routeManager;
|
|
402
|
+
private readonly secretToken?;
|
|
403
|
+
private readonly env;
|
|
404
|
+
private routeMap;
|
|
405
|
+
constructor(routeManager: RouteManager, secretToken?: string | undefined, env?: Record<string, unknown>);
|
|
406
|
+
/**
|
|
407
|
+
* Build the path for a named route, filling `:param` placeholders from
|
|
408
|
+
* `params`. Params that don't match a placeholder become query-string
|
|
409
|
+
* entries; `opts.query` is merged after them.
|
|
410
|
+
*
|
|
411
|
+
* @throws if no route carries `name`, or a required `:param` is missing.
|
|
412
|
+
*/
|
|
413
|
+
urlFor<N extends RouteName>(name: N, params?: RouteParams<N>, opts?: UrlForOptions): string;
|
|
414
|
+
/**
|
|
415
|
+
* Build a named-route URL and HMAC-sign it (path + query). The secret comes
|
|
416
|
+
* from `options.secret`, else the {@link URL_SIGNING_SECRET} token, else
|
|
417
|
+
* `CONFIG_ENV`; a descriptive error is thrown when none is available.
|
|
418
|
+
*/
|
|
419
|
+
signedUrl<N extends RouteName>(name: N, params?: RouteParams<N>, options?: SignedUrlGenerateOptions): Promise<string>;
|
|
420
|
+
/**
|
|
421
|
+
* Lazily index named route descriptions. Rebuilt while empty (routes may not
|
|
422
|
+
* be built yet), cached once populated.
|
|
423
|
+
*/
|
|
424
|
+
private routes;
|
|
425
|
+
}
|
|
426
|
+
//#endregion
|
|
427
|
+
//#region src/http/url/signed-url.guard.d.ts
|
|
428
|
+
/**
|
|
429
|
+
* Verifies the HMAC signature (and `expires`) of the incoming request URL,
|
|
430
|
+
* using the same secret source as {@link UrlGeneratorService.signedUrl}: the
|
|
431
|
+
* {@link URL_SIGNING_SECRET} token, else `CONFIG_ENV`. Throws
|
|
432
|
+
* `ForbiddenException` (403) when the signature is missing, tampered, or
|
|
433
|
+
* expired. Registered app-wide by `bootstrap`; apply it per-route with
|
|
434
|
+
* {@link SignedUrl}.
|
|
435
|
+
*/
|
|
436
|
+
declare class SignedUrlGuard implements CanActivate {
|
|
437
|
+
private readonly secretToken?;
|
|
438
|
+
private readonly env;
|
|
439
|
+
constructor(secretToken?: string | undefined, env?: Record<string, unknown>);
|
|
440
|
+
canActivate(context: ExecutionContext): Promise<boolean>;
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Guards a route with {@link SignedUrlGuard} — the request must carry a valid,
|
|
444
|
+
* unexpired HMAC signature (produced by `UrlGeneratorService.signedUrl`).
|
|
445
|
+
*
|
|
446
|
+
* ```ts
|
|
447
|
+
* @Get('download', { name: 'file.download' })
|
|
448
|
+
* @SignedUrl()
|
|
449
|
+
* download() { ... }
|
|
450
|
+
* ```
|
|
451
|
+
*/
|
|
452
|
+
declare function SignedUrl(): ReturnType<typeof applyDecorators>;
|
|
453
|
+
//#endregion
|
|
454
|
+
//#region src/http/url/signing-secret.d.ts
|
|
455
|
+
/**
|
|
456
|
+
* Optional DI token holding the HMAC secret used to sign / verify URLs. Provide
|
|
457
|
+
* it globally (e.g. from a platform adapter or a `@Global` module) so both
|
|
458
|
+
* {@link UrlGeneratorService} and the signed-URL guard can read it:
|
|
459
|
+
*
|
|
460
|
+
* ```ts
|
|
461
|
+
* { provide: URL_SIGNING_SECRET, useValue: env.URL_SIGNING_SECRET }
|
|
462
|
+
* ```
|
|
463
|
+
*/
|
|
464
|
+
declare const URL_SIGNING_SECRET: InjectionToken<string>;
|
|
465
|
+
//#endregion
|
|
466
|
+
//#region src/http/request-context.d.ts
|
|
467
|
+
interface RequestContext {
|
|
468
|
+
readonly id: string;
|
|
469
|
+
readonly receivedAt: Date;
|
|
470
|
+
readonly request: Request;
|
|
471
|
+
readonly hono: Context;
|
|
472
|
+
set<T>(key: string | symbol, value: T): void;
|
|
473
|
+
get<T>(key: string | symbol): T | undefined;
|
|
474
|
+
has(key: string | symbol): boolean;
|
|
475
|
+
}
|
|
476
|
+
declare const REQUEST_CONTEXT: InjectionToken<RequestContext>;
|
|
477
|
+
//#endregion
|
|
478
|
+
//#region src/http/ambient.d.ts
|
|
479
|
+
/**
|
|
480
|
+
* Returns Hono's `contextStorage()` middleware. Register it as the FIRST global
|
|
481
|
+
* middleware so `getCurrentContainer()` works everywhere downstream. When using
|
|
482
|
+
* `VelaFactory.create(module, { ambientContainer: true })` this is wired
|
|
483
|
+
* automatically — call this only for manual/raw Hono setups.
|
|
484
|
+
*/
|
|
485
|
+
declare function enableAmbientContainer(): MiddlewareHandler;
|
|
486
|
+
/**
|
|
487
|
+
* The current request's DI container. Throws with actionable guidance if
|
|
488
|
+
* ambient access isn't enabled or this runs outside a request.
|
|
489
|
+
*/
|
|
490
|
+
declare function getCurrentContainer(): Container;
|
|
491
|
+
/** The current request's {@link RequestContext} (via the ambient container). */
|
|
492
|
+
declare function getCurrentRequestContext(): RequestContext;
|
|
493
|
+
//#endregion
|
|
494
|
+
//#region src/http/request-container.d.ts
|
|
495
|
+
/**
|
|
496
|
+
* Returns the request-scoped child container for the current request.
|
|
497
|
+
*
|
|
498
|
+
* `@Inject(Container)` resolves the ROOT container (request children share the
|
|
499
|
+
* provider map and never rebind `Container`), so module authors who need
|
|
500
|
+
* request-scoped resolution from inside a handler, param-decorator factory, or
|
|
501
|
+
* scoped middleware must read the child seeded by RouteManager instead. The
|
|
502
|
+
* child is created before guards, pipes, params, and handlers run, so it is
|
|
503
|
+
* always present on the Vela request path.
|
|
504
|
+
*
|
|
505
|
+
* Throws outside a Vela-managed request rather than materializing an orphan
|
|
506
|
+
* child (mirrors the REQUEST_CONTEXT fail-fast).
|
|
507
|
+
*/
|
|
508
|
+
declare function getRequestContainer(c: Context): Container;
|
|
509
|
+
//#endregion
|
|
510
|
+
//#region src/services/logger.d.ts
|
|
511
|
+
declare const LogLevel: {
|
|
512
|
+
readonly VERBOSE: 0;
|
|
513
|
+
readonly DEBUG: 1;
|
|
514
|
+
readonly LOG: 2;
|
|
515
|
+
readonly WARN: 3;
|
|
516
|
+
readonly ERROR: 4;
|
|
517
|
+
readonly SILENT: 5;
|
|
518
|
+
};
|
|
519
|
+
type LogLevel = (typeof LogLevel)[keyof typeof LogLevel];
|
|
520
|
+
interface LoggerService {
|
|
521
|
+
log(message: unknown, ...optionalParams: unknown[]): void;
|
|
522
|
+
error(message: unknown, ...optionalParams: unknown[]): void;
|
|
523
|
+
warn(message: unknown, ...optionalParams: unknown[]): void;
|
|
524
|
+
debug?(message: unknown, ...optionalParams: unknown[]): void;
|
|
525
|
+
verbose?(message: unknown, ...optionalParams: unknown[]): void;
|
|
526
|
+
}
|
|
527
|
+
type ContextProvider = () => Record<string, unknown>;
|
|
528
|
+
type LoggerLevelName = 'LOG' | 'ERROR' | 'WARN' | 'DEBUG' | 'VERBOSE';
|
|
529
|
+
type Writer = (level: LoggerLevelName, line: string, ...rest: unknown[]) => void;
|
|
530
|
+
declare class Logger implements LoggerService {
|
|
531
|
+
static level: LogLevel;
|
|
532
|
+
private static globalLogger;
|
|
533
|
+
private static globalContextProviders;
|
|
534
|
+
private static globalWriter;
|
|
535
|
+
private context?;
|
|
536
|
+
private instanceContextProviders;
|
|
537
|
+
private instanceWriter?;
|
|
538
|
+
static setLogLevel(level: LogLevel): void;
|
|
539
|
+
static overrideLogger(logger: LoggerService | false): void;
|
|
540
|
+
/** Register a context provider run on every log line from every logger. */
|
|
541
|
+
static addContextProvider(provider: ContextProvider): void;
|
|
542
|
+
/** Remove all registered global context providers. */
|
|
543
|
+
static clearContextProviders(): void;
|
|
544
|
+
/** Replace the default console writer. Useful on edge runtimes that have
|
|
545
|
+
* a different output sink (e.g. `env.LOGS.writeDataPoint` on Workers). */
|
|
546
|
+
static setWriter(writer: Writer): void;
|
|
547
|
+
/** Restore the default console-based writer. */
|
|
548
|
+
static resetWriter(): void;
|
|
549
|
+
constructor(context?: string);
|
|
550
|
+
setContext(context: string): void;
|
|
551
|
+
/** Add a context provider that runs only for THIS logger instance.
|
|
552
|
+
* Children created via extend() inherit these providers by copy. */
|
|
553
|
+
addContextProvider(provider: ContextProvider): this;
|
|
554
|
+
/** Override the writer for this logger (and any extend() children). */
|
|
555
|
+
setWriter(writer: Writer): this;
|
|
556
|
+
/** Create a child logger with a nested namespace. Context becomes
|
|
557
|
+
* `parent:child`; instance-level providers and writers are inherited
|
|
558
|
+
* by copy so later mutations on either logger stay isolated. */
|
|
559
|
+
extend(namespace: string): Logger;
|
|
560
|
+
log(message: unknown, ...optionalParams: unknown[]): void;
|
|
561
|
+
error(message: unknown, ...optionalParams: unknown[]): void;
|
|
562
|
+
warn(message: unknown, ...optionalParams: unknown[]): void;
|
|
563
|
+
debug(message: unknown, ...optionalParams: unknown[]): void;
|
|
564
|
+
verbose(message: unknown, ...optionalParams: unknown[]): void;
|
|
565
|
+
private emit;
|
|
566
|
+
private formatMessage;
|
|
567
|
+
private collectContext;
|
|
568
|
+
private formatContextObj;
|
|
569
|
+
}
|
|
570
|
+
//#endregion
|
|
571
|
+
//#region src/config/register-as.d.ts
|
|
572
|
+
/**
|
|
573
|
+
* The result of {@link registerAs}: a namespaced config factory plus the DI
|
|
574
|
+
* token it is provided under.
|
|
575
|
+
*/
|
|
576
|
+
interface ConfigNamespace<TKey extends string = string, TEnv = Record<string, unknown>, TConfig extends object = object> {
|
|
577
|
+
/** Injection token for this namespace's resolved config (`Symbol.for('vela:config:<ns>')`). */
|
|
578
|
+
readonly KEY: InjectionToken<TConfig>;
|
|
579
|
+
/** The namespace name (e.g. `'database'`). */
|
|
580
|
+
readonly namespace: TKey;
|
|
581
|
+
/** Factory receiving the ambient env and returning the namespace config. */
|
|
582
|
+
readonly factory: (env: TEnv) => TConfig;
|
|
583
|
+
/** Provider registration injecting {@link CONFIG_ENV} — spread into a module's providers. */
|
|
584
|
+
asProvider(): ProviderOptions<TConfig>;
|
|
585
|
+
}
|
|
586
|
+
/** Any config namespace — structural typing for the module `load` list. */
|
|
587
|
+
type AnyConfigNamespace = ConfigNamespace<string, any, object>;
|
|
588
|
+
/**
|
|
589
|
+
* Create a namespaced configuration factory (NestJS `registerAs` parity).
|
|
590
|
+
*
|
|
591
|
+
* The `KEY` is minted with `Symbol.for` so it keeps a stable identity across
|
|
592
|
+
* module re-evaluation (HMR / repeated imports) — a fresh `InjectionToken`
|
|
593
|
+
* would mint a new identity each eval and break dedup. It is typed as
|
|
594
|
+
* `InjectionToken<TConfig>` purely for injection-site DX.
|
|
595
|
+
*
|
|
596
|
+
* @example
|
|
597
|
+
* ```ts
|
|
598
|
+
* export const dbConfig = registerAs('database', (env: Env) => ({
|
|
599
|
+
* url: env.DATABASE_URL,
|
|
600
|
+
* pool: 10,
|
|
601
|
+
* }));
|
|
602
|
+
* // ConfigModule.forRoot({ load: [dbConfig] });
|
|
603
|
+
* // cfg.get('database.url'); // via ConfigService
|
|
604
|
+
* // constructor(@Inject(dbConfig.KEY) db: InferConfigType<typeof dbConfig>) {}
|
|
605
|
+
* ```
|
|
606
|
+
*/
|
|
607
|
+
declare function registerAs<TKey extends string, TEnv, TConfig extends object>(namespace: TKey, factory: (env: TEnv) => TConfig): ConfigNamespace<TKey, TEnv, TConfig>;
|
|
608
|
+
/**
|
|
609
|
+
* Extract a namespace's config shape from a {@link registerAs} result.
|
|
610
|
+
*
|
|
611
|
+
* @example `type Db = InferConfigType<typeof dbConfig>` → `{ url: string; pool: number }`
|
|
612
|
+
*/
|
|
613
|
+
type InferConfigType<T> = T extends ConfigNamespace<string, any, infer C> ? C : never;
|
|
614
|
+
/**
|
|
615
|
+
* Zero-codegen typed config shape from a tuple of namespaces — pass as the
|
|
616
|
+
* `ConfigService` generic to type dot-notation reads.
|
|
617
|
+
*
|
|
618
|
+
* @example `ConfigService<ConfigType<[typeof dbConfig, typeof mailConfig]>>`
|
|
619
|
+
*/
|
|
620
|
+
type ConfigType<L extends readonly AnyConfigNamespace[]> = { [N in L[number] as N['namespace']]: InferConfigType<N>; };
|
|
621
|
+
//#endregion
|
|
622
|
+
//#region src/config/config.types.d.ts
|
|
623
|
+
/**
|
|
624
|
+
* A schema for validating the fully-merged config. Kept structural so zod stays
|
|
625
|
+
* an OPTIONAL peer — a zod schema (has `.parse`) or a plain function both work;
|
|
626
|
+
* core never imports zod. Throwing rejects the config.
|
|
627
|
+
*/
|
|
628
|
+
type ConfigSchema = ((config: Record<string, unknown>) => unknown) | {
|
|
629
|
+
parse: (config: unknown) => unknown;
|
|
630
|
+
};
|
|
631
|
+
/**
|
|
632
|
+
* Options for {@link ConfigModule}.
|
|
633
|
+
*
|
|
634
|
+
* NOTE: `load` and `validateSchema` are **`forRoot`-only** — they are read
|
|
635
|
+
* structurally from the call-time options bag. On the `forRootAsync` path the
|
|
636
|
+
* options come from a DI-resolved factory, so only the flat `config` record is
|
|
637
|
+
* supported there (async namespaces are out of scope; declare them via
|
|
638
|
+
* `forRoot`).
|
|
639
|
+
*/
|
|
640
|
+
interface ConfigModuleOptions<T extends Record<string, unknown> = Record<string, unknown>> {
|
|
641
|
+
/** Flat config record — the pre-namespace `config` path (still supported). */
|
|
642
|
+
config?: T;
|
|
643
|
+
/** Config namespaces created via `registerAs()`, merged under their namespace name. `forRoot`-only. */
|
|
644
|
+
load?: AnyConfigNamespace[];
|
|
645
|
+
/** Eager validator for the flat `config` record; runs at `forRoot()` call time. */
|
|
646
|
+
validate?: (config: T) => T;
|
|
647
|
+
/** Schema validating the MERGED config (flat + namespaces); runs lazily on first read. `forRoot`-only. */
|
|
648
|
+
validateSchema?: ConfigSchema;
|
|
649
|
+
isGlobal?: boolean;
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* All valid dot-notation paths of a config object type.
|
|
653
|
+
* @example `ConfigPath<{ database: { url: string } }>` → `'database' | 'database.url'`
|
|
654
|
+
*/
|
|
655
|
+
type ConfigPath<T> = { [K in keyof T & string]: T[K] extends Record<string, unknown> ? K | `${K}.${ConfigPath<T[K]>}` : K; }[keyof T & string];
|
|
656
|
+
/**
|
|
657
|
+
* The value type at a dot-notation path.
|
|
658
|
+
* @example `ConfigPathValue<{ database: { url: string } }, 'database.url'>` → `string`
|
|
659
|
+
*/
|
|
660
|
+
type ConfigPathValue<T, P extends string> = P extends `${infer K}.${infer Rest}` ? K extends keyof T ? T[K] extends Record<string, unknown> ? ConfigPathValue<T[K], Rest> : never : never : P extends keyof T ? T[P] : never;
|
|
661
|
+
//#endregion
|
|
662
|
+
//#region src/config/config.module.d.ts
|
|
663
|
+
declare const ConfigurableModuleClass$6: ConfigurableModuleClassType<ConfigModuleOptions<Record<string, unknown>>, "forRoot", "create", {
|
|
664
|
+
isGlobal?: boolean;
|
|
665
|
+
}>;
|
|
666
|
+
declare class ConfigModule extends ConfigurableModuleClass$6 {
|
|
667
|
+
/**
|
|
668
|
+
* Preserve (a) per-call generic inference over the flat config record and
|
|
669
|
+
* (b) the eager-validation contract: `validate` runs at call time so bad
|
|
670
|
+
* config fails fast, then is stripped so the derived `CONFIG_OPTIONS`
|
|
671
|
+
* provider is a passthrough (no double validation). `validateSchema` (the
|
|
672
|
+
* merged-config schema) is deferred to first read — its input needs env.
|
|
673
|
+
*/
|
|
674
|
+
static forRoot<T extends Record<string, unknown>>(options?: ConfigModuleOptions<T> & {
|
|
675
|
+
isGlobal?: boolean;
|
|
676
|
+
key?: string;
|
|
677
|
+
}): DynamicModule;
|
|
678
|
+
}
|
|
679
|
+
//#endregion
|
|
680
|
+
//#region src/config/config.store.d.ts
|
|
681
|
+
/**
|
|
682
|
+
* Singleton source of truth for merged configuration.
|
|
683
|
+
*
|
|
684
|
+
* Holds the flat `config` record plus a `namespace → KEY` map. Namespaces are
|
|
685
|
+
* resolved LAZILY — the KEY is pulled from the container on the first read of
|
|
686
|
+
* that namespace and cached — so the store never forces namespace factories to
|
|
687
|
+
* materialize at construction. Resolution uses the synchronous container seam
|
|
688
|
+
* (`resolve`), which stays compatible with lazy modules.
|
|
689
|
+
*
|
|
690
|
+
* The merged shape is `{ ...config, [ns]: value }` — a namespace shadows a flat
|
|
691
|
+
* key of the same name.
|
|
692
|
+
*
|
|
693
|
+
* Constructed via a factory provider in {@link ConfigModule} so it can close
|
|
694
|
+
* over the `load` list and `validateSchema` without extra tokens.
|
|
695
|
+
*/
|
|
696
|
+
declare class ConfigStore {
|
|
697
|
+
private readonly container;
|
|
698
|
+
private readonly config;
|
|
699
|
+
private readonly validateSchema?;
|
|
700
|
+
private readonly namespaceKeys;
|
|
701
|
+
private readonly cache;
|
|
702
|
+
private validated;
|
|
703
|
+
private validationError;
|
|
704
|
+
constructor(container: Pick<Container, 'resolve'>, config?: Record<string, unknown>, namespaces?: ReadonlyArray<AnyConfigNamespace>, validateSchema?: ConfigSchema | undefined);
|
|
705
|
+
/** Read a value by dot-notation path; `undefined` if absent. */
|
|
706
|
+
get(path: string): unknown;
|
|
707
|
+
/** Read a value by dot-notation path; throws if absent. */
|
|
708
|
+
getOrThrow(path: string): unknown;
|
|
709
|
+
/** Whether a dot-notation path resolves to a defined value. */
|
|
710
|
+
has(path: string): boolean;
|
|
711
|
+
/** The full merged config object (flat record + resolved namespaces). */
|
|
712
|
+
all(): Record<string, unknown>;
|
|
713
|
+
private read;
|
|
714
|
+
/** Resolve a namespace's KEY through the container on first use, then cache. */
|
|
715
|
+
private resolveNamespace;
|
|
716
|
+
private merged;
|
|
717
|
+
/**
|
|
718
|
+
* Validate the merged config once, on first read. Deferred (not at bootstrap)
|
|
719
|
+
* because the merged shape needs namespace factories — and their env — which
|
|
720
|
+
* are only available after bootstrap on edge runtimes.
|
|
721
|
+
*/
|
|
722
|
+
private ensureValidated;
|
|
723
|
+
}
|
|
724
|
+
//#endregion
|
|
725
|
+
//#region src/config/config.service.d.ts
|
|
726
|
+
/**
|
|
727
|
+
* Typed, dot-notation reads over the merged config. Stays a singleton (NestJS
|
|
728
|
+
* parity); delegates to the {@link ConfigStore}. Pass `ConfigType<[...]>` as the
|
|
729
|
+
* generic to type namespaced paths (`cfg.get('database.url')` → `string`).
|
|
730
|
+
*/
|
|
731
|
+
declare class ConfigService<T extends Record<string, unknown> = Record<string, unknown>> {
|
|
732
|
+
private readonly store;
|
|
733
|
+
constructor(store: ConfigStore);
|
|
734
|
+
/** Read a config value; `undefined` when absent, or the supplied default. */
|
|
735
|
+
get<P extends ConfigPath<T>>(path: P): ConfigPathValue<T, P> | undefined;
|
|
736
|
+
get<P extends ConfigPath<T>>(path: P, defaultValue: ConfigPathValue<T, P>): ConfigPathValue<T, P>;
|
|
737
|
+
/** Read a config value; throws when the path is absent. */
|
|
738
|
+
getOrThrow<P extends ConfigPath<T>>(path: P): ConfigPathValue<T, P>;
|
|
739
|
+
/** Whether a config path resolves to a defined value. */
|
|
740
|
+
has<P extends ConfigPath<T>>(path: P): boolean;
|
|
741
|
+
/** The full merged config object (flat record + resolved namespaces). */
|
|
742
|
+
getAll(): T;
|
|
743
|
+
}
|
|
744
|
+
//#endregion
|
|
745
|
+
//#region src/config/config.tokens.d.ts
|
|
746
|
+
declare const CONFIG_OPTIONS: InjectionToken<Record<string, unknown>>;
|
|
747
|
+
/**
|
|
748
|
+
* Ambient environment record consumed by config-namespace factories
|
|
749
|
+
* (`registerAs`). It is the multi-runtime substitute for stratal's
|
|
750
|
+
* Cloudflare-specific `env` token: core never touches `process.env`.
|
|
751
|
+
*
|
|
752
|
+
* The token self-provides `{}` by default (so factories resolve even with no
|
|
753
|
+
* platform binding), and stays OVERRIDABLE — a platform adapter
|
|
754
|
+
* (`@velajs/cloudflare`) or a future `./config-node` subpath provides a global
|
|
755
|
+
* `CONFIG_ENV` and that registration wins over the default.
|
|
756
|
+
*/
|
|
757
|
+
declare const CONFIG_ENV: InjectionToken<Record<string, unknown>>;
|
|
758
|
+
//#endregion
|
|
759
|
+
//#region src/fetch/fetch.types.d.ts
|
|
760
|
+
interface HttpModuleOptions {
|
|
761
|
+
/** Base URL prepended to all requests. */
|
|
762
|
+
baseURL?: string;
|
|
763
|
+
/** Default headers sent with every request. */
|
|
764
|
+
headers?: Record<string, string>;
|
|
765
|
+
/** Default timeout in milliseconds (uses AbortSignal.timeout). */
|
|
766
|
+
timeout?: number;
|
|
767
|
+
}
|
|
768
|
+
interface RequestConfig {
|
|
769
|
+
headers?: Record<string, string>;
|
|
770
|
+
params?: Record<string, string | number | boolean>;
|
|
771
|
+
timeout?: number;
|
|
772
|
+
}
|
|
773
|
+
interface HttpRequestConfig extends RequestConfig {
|
|
774
|
+
method: string;
|
|
775
|
+
url: string;
|
|
776
|
+
body?: unknown;
|
|
777
|
+
}
|
|
778
|
+
interface HttpResponse<T = unknown> {
|
|
779
|
+
data: T;
|
|
780
|
+
status: number;
|
|
781
|
+
statusText: string;
|
|
782
|
+
headers: Headers;
|
|
783
|
+
}
|
|
784
|
+
//#endregion
|
|
785
|
+
//#region src/fetch/fetch.module.d.ts
|
|
786
|
+
declare const ConfigurableModuleClass$5: ConfigurableModuleClassType<HttpModuleOptions, "forRoot", "create", {
|
|
787
|
+
isGlobal?: boolean;
|
|
788
|
+
}>;
|
|
789
|
+
declare class HttpModule extends ConfigurableModuleClass$5 {}
|
|
790
|
+
//#endregion
|
|
791
|
+
//#region src/fetch/fetch.service.d.ts
|
|
792
|
+
declare const HTTP_MODULE_OPTIONS: InjectionToken<HttpModuleOptions>;
|
|
793
|
+
declare class HttpRequestException extends Error {
|
|
794
|
+
readonly status: number;
|
|
795
|
+
readonly statusText: string;
|
|
796
|
+
readonly response: Response;
|
|
797
|
+
constructor(status: number, statusText: string, response: Response);
|
|
798
|
+
}
|
|
799
|
+
declare class HttpService {
|
|
800
|
+
private readonly baseURL;
|
|
801
|
+
private readonly defaultHeaders;
|
|
802
|
+
private readonly defaultTimeout;
|
|
803
|
+
constructor(options: HttpModuleOptions);
|
|
804
|
+
get<T = unknown>(url: string, config?: RequestConfig): Promise<HttpResponse<T>>;
|
|
805
|
+
post<T = unknown>(url: string, body?: unknown, config?: RequestConfig): Promise<HttpResponse<T>>;
|
|
806
|
+
put<T = unknown>(url: string, body?: unknown, config?: RequestConfig): Promise<HttpResponse<T>>;
|
|
807
|
+
patch<T = unknown>(url: string, body?: unknown, config?: RequestConfig): Promise<HttpResponse<T>>;
|
|
808
|
+
delete<T = unknown>(url: string, config?: RequestConfig): Promise<HttpResponse<T>>;
|
|
809
|
+
head(url: string, config?: RequestConfig): Promise<HttpResponse<void>>;
|
|
810
|
+
request<T = unknown>(config: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
811
|
+
private buildUrl;
|
|
812
|
+
private parseBody;
|
|
813
|
+
}
|
|
814
|
+
//#endregion
|
|
815
|
+
//#region src/cors/cors.types.d.ts
|
|
816
|
+
interface CorsOptions {
|
|
817
|
+
origin?: string | string[] | ((origin: string) => string | undefined | null);
|
|
818
|
+
allowMethods?: string[];
|
|
819
|
+
allowHeaders?: string[];
|
|
820
|
+
exposeHeaders?: string[];
|
|
821
|
+
credentials?: boolean;
|
|
822
|
+
maxAge?: number;
|
|
823
|
+
}
|
|
824
|
+
//#endregion
|
|
825
|
+
//#region src/cors/cors.module.d.ts
|
|
826
|
+
declare const ConfigurableModuleClass$4: ConfigurableModuleClassType<CorsOptions, "forRoot", "create", {
|
|
827
|
+
isGlobal?: boolean;
|
|
828
|
+
}>;
|
|
829
|
+
declare class CorsModule extends ConfigurableModuleClass$4 {}
|
|
830
|
+
//#endregion
|
|
831
|
+
//#region src/cors/cors.tokens.d.ts
|
|
832
|
+
declare const CORS_OPTIONS: InjectionToken<CorsOptions>;
|
|
833
|
+
//#endregion
|
|
834
|
+
//#region src/cache/cache.types.d.ts
|
|
835
|
+
/** A value that may be returned synchronously or as a promise. */
|
|
836
|
+
type Awaitable<T> = T | Promise<T>;
|
|
837
|
+
interface CacheModuleOptions {
|
|
838
|
+
ttl?: number;
|
|
839
|
+
max?: number;
|
|
840
|
+
isGlobal?: boolean;
|
|
841
|
+
/**
|
|
842
|
+
* Custom SYNC backing store (replaces the default in-memory store). For async
|
|
843
|
+
* (KV/tiered) caching use {@link AsyncCacheStore} + `TieredCacheStore`
|
|
844
|
+
* programmatically — the interceptor/CacheService path is synchronous.
|
|
845
|
+
*/
|
|
846
|
+
store?: CacheStore;
|
|
847
|
+
}
|
|
848
|
+
/**
|
|
849
|
+
* Synchronous cache backing store. This is the original, stable contract used by
|
|
850
|
+
* `CacheService` and `CacheInterceptor` — unchanged.
|
|
851
|
+
*/
|
|
852
|
+
interface CacheStore {
|
|
853
|
+
get<T = unknown>(key: string): T | undefined;
|
|
854
|
+
set<T = unknown>(key: string, value: T, ttl?: number): void;
|
|
855
|
+
del(key: string): void;
|
|
856
|
+
clear(): void;
|
|
857
|
+
}
|
|
858
|
+
/**
|
|
859
|
+
* Asynchronous cache backing store (additive). Implemented by remote/tiered
|
|
860
|
+
* stores (`TieredCacheStore`, and `KVCacheStore` in `@velajs/cloudflare`) where
|
|
861
|
+
* reads/writes are inherently async. Use it programmatically — inject the store
|
|
862
|
+
* under your own token — rather than as the synchronous `CACHE_MANAGER`.
|
|
863
|
+
*/
|
|
864
|
+
interface AsyncCacheStore {
|
|
865
|
+
get<T = unknown>(key: string): Promise<T | undefined>;
|
|
866
|
+
set<T = unknown>(key: string, value: T, ttl?: number): Promise<void>;
|
|
867
|
+
del(key: string): Promise<void>;
|
|
868
|
+
clear(): Promise<void>;
|
|
869
|
+
}
|
|
870
|
+
/** A store that may be sync or async (used to compose tiers). */
|
|
871
|
+
type AnyCacheStore = CacheStore | AsyncCacheStore;
|
|
872
|
+
interface CacheEntry<T = unknown> {
|
|
873
|
+
value: T;
|
|
874
|
+
expiresAt: number;
|
|
875
|
+
}
|
|
876
|
+
//#endregion
|
|
877
|
+
//#region src/cache/cache.module.d.ts
|
|
878
|
+
declare const ConfigurableModuleClass$3: ConfigurableModuleClassType<CacheModuleOptions, "forRoot", "create", {
|
|
879
|
+
isGlobal: boolean;
|
|
880
|
+
}>;
|
|
881
|
+
declare class CacheModule extends ConfigurableModuleClass$3 {}
|
|
882
|
+
//#endregion
|
|
883
|
+
//#region src/cache/cache.service.d.ts
|
|
884
|
+
declare class CacheService {
|
|
885
|
+
private store;
|
|
886
|
+
constructor(store: CacheStore);
|
|
887
|
+
get<T = unknown>(key: string): T | undefined;
|
|
888
|
+
set<T = unknown>(key: string, value: T, ttl?: number): void;
|
|
889
|
+
del(key: string): void;
|
|
890
|
+
clear(): void;
|
|
891
|
+
}
|
|
892
|
+
//#endregion
|
|
893
|
+
//#region src/cache/cache.interceptor.d.ts
|
|
894
|
+
declare class CacheInterceptor implements NestInterceptor {
|
|
895
|
+
private cacheStore;
|
|
896
|
+
private options;
|
|
897
|
+
private reflector;
|
|
898
|
+
constructor(cacheStore: CacheStore, options: CacheModuleOptions);
|
|
899
|
+
intercept(context: ExecutionContext, next: CallHandler): Promise<unknown>;
|
|
900
|
+
}
|
|
901
|
+
//#endregion
|
|
902
|
+
//#region src/cache/cache.store.d.ts
|
|
903
|
+
declare class MemoryCacheStore implements CacheStore {
|
|
904
|
+
private store;
|
|
905
|
+
private defaultTtl;
|
|
906
|
+
private max;
|
|
907
|
+
constructor(ttl?: number, max?: number);
|
|
908
|
+
get<T = unknown>(key: string): T | undefined;
|
|
909
|
+
set<T = unknown>(key: string, value: T, ttl?: number): void;
|
|
910
|
+
del(key: string): void;
|
|
911
|
+
clear(): void;
|
|
912
|
+
private evict;
|
|
913
|
+
}
|
|
914
|
+
//#endregion
|
|
915
|
+
//#region src/cache/tiered-cache.store.d.ts
|
|
916
|
+
/**
|
|
917
|
+
* Composes an ordered list of cache tiers (fastest first, e.g. in-memory L1 →
|
|
918
|
+
* KV L2). Tiers may be sync ({@link CacheStore}) or async ({@link AsyncCacheStore}) —
|
|
919
|
+
* results are awaited uniformly. Reads are read-through: the first tier with a
|
|
920
|
+
* hit wins, and nearer tiers that missed are backfilled. Writes/deletes/clears
|
|
921
|
+
* fan out to all tiers. Always async ({@link AsyncCacheStore}).
|
|
922
|
+
*
|
|
923
|
+
* Runtime-agnostic — the concrete tiers (memory here, KV in `@velajs/cloudflare`)
|
|
924
|
+
* live wherever fits.
|
|
925
|
+
*/
|
|
926
|
+
declare class TieredCacheStore implements AsyncCacheStore {
|
|
927
|
+
private readonly tiers;
|
|
928
|
+
constructor(tiers: AnyCacheStore[]);
|
|
929
|
+
get<T = unknown>(key: string): Promise<T | undefined>;
|
|
930
|
+
set<T = unknown>(key: string, value: T, ttl?: number): Promise<void>;
|
|
931
|
+
del(key: string): Promise<void>;
|
|
932
|
+
clear(): Promise<void>;
|
|
933
|
+
}
|
|
934
|
+
//#endregion
|
|
935
|
+
//#region src/cache/cache.decorators.d.ts
|
|
936
|
+
declare const CacheKey: (key: string) => (target: object, propertyKey?: string | symbol) => void;
|
|
937
|
+
declare const CacheTTL: (seconds: number) => (target: object, propertyKey?: string | symbol) => void;
|
|
938
|
+
//#endregion
|
|
939
|
+
//#region src/cache/cache.tokens.d.ts
|
|
940
|
+
declare const CACHE_MANAGER: InjectionToken<CacheStore>;
|
|
941
|
+
declare const CACHE_MODULE_OPTIONS: InjectionToken<CacheModuleOptions>;
|
|
942
|
+
declare const CACHE_KEY_METADATA = "vela:cache-key";
|
|
943
|
+
declare const CACHE_TTL_METADATA = "vela:cache-ttl";
|
|
944
|
+
//#endregion
|
|
945
|
+
//#region src/event-emitter/event-emitter.module.d.ts
|
|
946
|
+
declare class EventEmitterModule {}
|
|
947
|
+
//#endregion
|
|
948
|
+
//#region src/event-emitter/event-emitter.types.d.ts
|
|
949
|
+
type EventHandler = (...args: unknown[]) => void | Promise<void>;
|
|
950
|
+
interface OnEventMetadata {
|
|
951
|
+
event: string;
|
|
952
|
+
methodName: string;
|
|
953
|
+
}
|
|
954
|
+
//#endregion
|
|
955
|
+
//#region src/event-emitter/event-emitter.service.d.ts
|
|
956
|
+
declare class EventEmitter {
|
|
957
|
+
private exactListeners;
|
|
958
|
+
private exactOnceListeners;
|
|
959
|
+
private wildcardListeners;
|
|
960
|
+
on(event: string, handler: EventHandler): this;
|
|
961
|
+
once(event: string, handler: EventHandler): this;
|
|
962
|
+
off(event: string, handler: EventHandler): this;
|
|
963
|
+
emit(event: string, ...args: unknown[]): Promise<void>;
|
|
964
|
+
removeAllListeners(event?: string): this;
|
|
965
|
+
listenerCount(event: string): number;
|
|
966
|
+
private getOrCreateWildcard;
|
|
967
|
+
}
|
|
968
|
+
//#endregion
|
|
969
|
+
//#region src/event-emitter/event-emitter.subscriber.d.ts
|
|
970
|
+
declare class EventEmitterSubscriber implements OnApplicationBootstrap {
|
|
971
|
+
private readonly discovery;
|
|
972
|
+
private emitter;
|
|
973
|
+
constructor(discovery: DiscoveryService, emitter: EventEmitter);
|
|
974
|
+
onApplicationBootstrap(): void;
|
|
975
|
+
}
|
|
976
|
+
//#endregion
|
|
977
|
+
//#region src/event-emitter/event-emitter.decorators.d.ts
|
|
978
|
+
declare function OnEvent(event: string): MethodDecorator;
|
|
979
|
+
//#endregion
|
|
980
|
+
//#region src/event-emitter/event-emitter.tokens.d.ts
|
|
981
|
+
declare const ON_EVENT_METADATA = "vela:on-event";
|
|
982
|
+
//#endregion
|
|
983
|
+
//#region src/schedule/schedule.module.d.ts
|
|
984
|
+
/**
|
|
985
|
+
* Zero-config module (Tier C): providers live on the `@Module` bag; the
|
|
986
|
+
* `forRoot()` static is NestJS-parity sugar returning the bare dynamic module
|
|
987
|
+
* (default key — repeated calls dedup).
|
|
988
|
+
*/
|
|
989
|
+
declare class ScheduleModule {
|
|
990
|
+
static forRoot(): DynamicModule;
|
|
991
|
+
}
|
|
992
|
+
//#endregion
|
|
993
|
+
//#region src/schedule/schedule.decorators.d.ts
|
|
994
|
+
declare function Cron(expression: string): MethodDecorator;
|
|
995
|
+
declare function Interval(ms: number): MethodDecorator;
|
|
996
|
+
//#endregion
|
|
997
|
+
//#region src/schedule/schedule.tokens.d.ts
|
|
998
|
+
declare const CRON_METADATA = "vela:cron";
|
|
999
|
+
declare const INTERVAL_METADATA = "vela:interval";
|
|
1000
|
+
//#endregion
|
|
1001
|
+
//#region src/schedule/schedule.types.d.ts
|
|
1002
|
+
interface CronMetadata {
|
|
1003
|
+
expression: string;
|
|
1004
|
+
methodName: string;
|
|
1005
|
+
}
|
|
1006
|
+
interface IntervalMetadata {
|
|
1007
|
+
ms: number;
|
|
1008
|
+
methodName: string;
|
|
1009
|
+
}
|
|
1010
|
+
//#endregion
|
|
1011
|
+
//#region src/schedule/cron-matcher.d.ts
|
|
1012
|
+
type CronMatcher = (date: Date) => boolean;
|
|
1013
|
+
declare function parseCron(expression: string): CronMatcher | null;
|
|
1014
|
+
//#endregion
|
|
1015
|
+
//#region src/websocket/websocket.types.d.ts
|
|
1016
|
+
/** The JSON envelope carried over the raw WebSocket. `id` is an optional client correlation id echoed on the reply. */
|
|
1017
|
+
interface WsMessage<T = unknown> {
|
|
1018
|
+
id?: string;
|
|
1019
|
+
event: string;
|
|
1020
|
+
data?: T;
|
|
1021
|
+
}
|
|
1022
|
+
/** A handler's structured reply. Returning one frames `{ event, data }` back to the sender. */
|
|
1023
|
+
interface WsResponse<T = unknown> {
|
|
1024
|
+
event: string;
|
|
1025
|
+
data: T;
|
|
1026
|
+
}
|
|
1027
|
+
/**
|
|
1028
|
+
* A single connected socket, normalized across runtimes. Per-connection state
|
|
1029
|
+
* lives in `data`; mutations to `data`/room membership are persisted by
|
|
1030
|
+
* `commit()` (on Cloudflare this writes the hibernation attachment).
|
|
1031
|
+
*/
|
|
1032
|
+
interface WsClient<TData = Record<string, unknown>> {
|
|
1033
|
+
readonly id: string;
|
|
1034
|
+
readonly rooms: ReadonlySet<string>;
|
|
1035
|
+
data: TData;
|
|
1036
|
+
/** Frame and send `{ event, data }` (optionally correlated by `id`) to this socket. */
|
|
1037
|
+
send(event: string, data?: unknown, id?: string): void;
|
|
1038
|
+
/** Send an already-serialized string. Escape hatch for custom framing. */
|
|
1039
|
+
sendRaw(payload: string): void;
|
|
1040
|
+
join(room: string): void | Promise<void>;
|
|
1041
|
+
leave(room: string): void | Promise<void>;
|
|
1042
|
+
/** Persist `data`/room mutations made during a handler. */
|
|
1043
|
+
commit(): void | Promise<void>;
|
|
1044
|
+
close(code?: number, reason?: string): void;
|
|
1045
|
+
/** The native socket (`WSContext` on node/bun/deno, `WebSocket` in a Cloudflare DO). */
|
|
1046
|
+
readonly raw: unknown;
|
|
1047
|
+
}
|
|
1048
|
+
/** Fluent broadcast builder. Terminal `.emit()` produces a `BroadcastCommand`. */
|
|
1049
|
+
interface BroadcastOperator {
|
|
1050
|
+
to(room: string): BroadcastOperator;
|
|
1051
|
+
in(room: string): BroadcastOperator;
|
|
1052
|
+
except(room: string): BroadcastOperator;
|
|
1053
|
+
emit(event: string, data?: unknown): void | Promise<void>;
|
|
1054
|
+
}
|
|
1055
|
+
/** The server handle injected via `@WebSocketServer()`. Server-origin broadcasts never exclude anyone. */
|
|
1056
|
+
interface WsServer {
|
|
1057
|
+
emit(event: string, data?: unknown): void | Promise<void>;
|
|
1058
|
+
to(room: string): BroadcastOperator;
|
|
1059
|
+
in(room: string): BroadcastOperator;
|
|
1060
|
+
except(room: string): BroadcastOperator;
|
|
1061
|
+
}
|
|
1062
|
+
/** An `ExecutionContext` whose transport is a WebSocket gateway. `switchToWs()` is guaranteed present. */
|
|
1063
|
+
interface WsExecutionContext extends ExecutionContext {
|
|
1064
|
+
switchToWs(): WsArgumentsHost;
|
|
1065
|
+
}
|
|
1066
|
+
interface OnGatewayInit {
|
|
1067
|
+
afterInit(server: WsServer): void | Promise<void>;
|
|
1068
|
+
}
|
|
1069
|
+
interface OnGatewayConnection {
|
|
1070
|
+
handleConnection(client: WsClient): void | Promise<void>;
|
|
1071
|
+
}
|
|
1072
|
+
interface OnGatewayDisconnect {
|
|
1073
|
+
handleDisconnect(client: WsClient): void | Promise<void>;
|
|
1074
|
+
}
|
|
1075
|
+
interface WebSocketGatewayOptions {
|
|
1076
|
+
/** Route path the upgrade is served on (e.g. `/rooms/:id/ws`). */
|
|
1077
|
+
path?: string;
|
|
1078
|
+
/** Cloudflare Durable Object binding name that hosts this gateway's sockets. */
|
|
1079
|
+
binding?: string;
|
|
1080
|
+
}
|
|
1081
|
+
/** Stored per `@SubscribeMessage` — a flat class-level list, mirroring `@OnEvent`. */
|
|
1082
|
+
interface SubscribeMessageMetadata {
|
|
1083
|
+
event: string;
|
|
1084
|
+
methodName: string;
|
|
1085
|
+
}
|
|
1086
|
+
/** Class-level meta written by `@ReservedWsEvent(event)`. */
|
|
1087
|
+
interface ReservedWsEventMetadata {
|
|
1088
|
+
/** The reserved (`$`-prefixed) envelope event this provider handles. */
|
|
1089
|
+
event: string;
|
|
1090
|
+
}
|
|
1091
|
+
/**
|
|
1092
|
+
* A provider claiming a reserved (`$`-prefixed) envelope event across EVERY
|
|
1093
|
+
* gateway path. Discovered by `WsDispatcher` at bootstrap via the
|
|
1094
|
+
* `@ReservedWsEvent` decorator; inbound frames for the event route here
|
|
1095
|
+
* (after app-wide guards), never to gateways. `handleSocketClose` fires for
|
|
1096
|
+
* every closing socket so the handler can drop per-connection state.
|
|
1097
|
+
*/
|
|
1098
|
+
interface ReservedWsEventHandler {
|
|
1099
|
+
handleReservedEvent(path: string, client: WsClient, message: WsMessage): void | Promise<void>;
|
|
1100
|
+
handleSocketClose?(path: string, client: WsClient): void | Promise<void>;
|
|
1101
|
+
}
|
|
1102
|
+
/**
|
|
1103
|
+
* A fully serializable broadcast instruction. Crosses isolate / Durable-Object /
|
|
1104
|
+
* Redis boundaries as JSON, so every sync driver speaks the same command.
|
|
1105
|
+
*/
|
|
1106
|
+
interface BroadcastCommand {
|
|
1107
|
+
/** Target rooms. An empty array means GLOBAL (every connection). */
|
|
1108
|
+
rooms: string[];
|
|
1109
|
+
exceptRooms?: string[];
|
|
1110
|
+
exceptIds?: string[];
|
|
1111
|
+
/** The exact bytes written to each socket: `JSON.stringify({ event, data })`. */
|
|
1112
|
+
frame: string;
|
|
1113
|
+
/** Origin instance/DO id — lets pub/sub drivers drop their own echo. */
|
|
1114
|
+
origin?: string;
|
|
1115
|
+
}
|
|
1116
|
+
//#endregion
|
|
1117
|
+
//#region src/websocket/websocket.decorators.d.ts
|
|
1118
|
+
/**
|
|
1119
|
+
* Marks a class as a WebSocket gateway. Mirrors `@Controller` for the socket
|
|
1120
|
+
* transport: registers the class as an injectable singleton and stores its
|
|
1121
|
+
* routing options (`path`, Cloudflare `binding`).
|
|
1122
|
+
*
|
|
1123
|
+
* @example
|
|
1124
|
+
* ```ts
|
|
1125
|
+
* @WebSocketGateway({ path: '/rooms/:id/ws', binding: 'CHAT_ROOM' })
|
|
1126
|
+
* class ChatGateway {}
|
|
1127
|
+
* ```
|
|
1128
|
+
*/
|
|
1129
|
+
declare function WebSocketGateway(options?: WebSocketGatewayOptions): ClassDecorator;
|
|
1130
|
+
/**
|
|
1131
|
+
* Binds a gateway method to an inbound event. Stackable — one class-level list,
|
|
1132
|
+
* exactly like `@OnEvent` (`event-emitter.decorators.ts`).
|
|
1133
|
+
*/
|
|
1134
|
+
declare function SubscribeMessage(event: string): MethodDecorator;
|
|
1135
|
+
/**
|
|
1136
|
+
* Claims a reserved (`$`-prefixed) envelope event for a framework-module
|
|
1137
|
+
* provider (see `ReservedWsEventHandler`). Reserved frames route to the
|
|
1138
|
+
* decorated provider across every gateway path — gateways themselves may not
|
|
1139
|
+
* subscribe to `$…` events. Stack with `@Injectable()` like `@Processor`.
|
|
1140
|
+
*
|
|
1141
|
+
* @example
|
|
1142
|
+
* ```ts
|
|
1143
|
+
* @ReservedWsEvent('$live')
|
|
1144
|
+
* @Injectable()
|
|
1145
|
+
* class LiveEngine implements ReservedWsEventHandler { … }
|
|
1146
|
+
* ```
|
|
1147
|
+
*/
|
|
1148
|
+
declare function ReservedWsEvent(event: string): ClassDecorator;
|
|
1149
|
+
/** Injects the inbound message payload (the envelope's `data`) into a handler parameter. */
|
|
1150
|
+
declare const MessageBody: () => ParameterDecorator;
|
|
1151
|
+
/** Injects the connected socket (`WsClient`) into a handler parameter. */
|
|
1152
|
+
declare const ConnectedSocket: () => ParameterDecorator;
|
|
1153
|
+
/**
|
|
1154
|
+
* Injects the gateway server handle (`WsServer`). Constructor injection only —
|
|
1155
|
+
* the container has no property-injection pass, so this is sugar for
|
|
1156
|
+
* `@Inject(WS_SERVER)` on a constructor parameter.
|
|
1157
|
+
*
|
|
1158
|
+
* @example
|
|
1159
|
+
* ```ts
|
|
1160
|
+
* constructor(@WebSocketServer() private server: WsServer) {}
|
|
1161
|
+
* ```
|
|
1162
|
+
*/
|
|
1163
|
+
declare function WebSocketServer(): ParameterDecorator;
|
|
1164
|
+
//#endregion
|
|
1165
|
+
//#region src/websocket/ws-sync.d.ts
|
|
1166
|
+
/**
|
|
1167
|
+
* Owns LOCAL room membership and local fan-out for the connections a single
|
|
1168
|
+
* node/isolate holds. The Cloudflare transport backs this with hibernation
|
|
1169
|
+
* tags + attachment; node/bun/deno back it with the in-memory implementation
|
|
1170
|
+
* below. Always edge-safe (no `node:*`).
|
|
1171
|
+
*/
|
|
1172
|
+
interface RoomRegistry {
|
|
1173
|
+
/** Register a connection (called on connect) so global broadcasts can reach it. */
|
|
1174
|
+
register(client: WsClient): void;
|
|
1175
|
+
join(client: WsClient, room: string): void | Promise<void>;
|
|
1176
|
+
leave(client: WsClient, room: string): void | Promise<void>;
|
|
1177
|
+
/** Remove a connection and all its room memberships (called on disconnect). */
|
|
1178
|
+
leaveAll(client: WsClient): void | Promise<void>;
|
|
1179
|
+
/** Deliver a command to the sockets THIS node holds, applying every exclusion. */
|
|
1180
|
+
deliverLocal(cmd: BroadcastCommand): void | Promise<void>;
|
|
1181
|
+
localIdsInRoom(room: string): string[];
|
|
1182
|
+
}
|
|
1183
|
+
/**
|
|
1184
|
+
* Pluggable cross-instance transport for broadcast commands. `local()` is the
|
|
1185
|
+
* zero-config single-instance default; `durableObject()` (Cloudflare) and
|
|
1186
|
+
* `redis()` (node) are additive and chosen at the composition root.
|
|
1187
|
+
*/
|
|
1188
|
+
interface SyncDriver {
|
|
1189
|
+
readonly kind: string;
|
|
1190
|
+
/** Wire the local registry so the driver can deliver to locally-held sockets. */
|
|
1191
|
+
bind(registry: RoomRegistry): void;
|
|
1192
|
+
/** Route a command so every node that may hold a matching socket delivers it. */
|
|
1193
|
+
dispatch(cmd: BroadcastCommand): void | Promise<void>;
|
|
1194
|
+
countRoom?(room: string): Promise<number>;
|
|
1195
|
+
start?(): void | Promise<void>;
|
|
1196
|
+
stop?(): void | Promise<void>;
|
|
1197
|
+
}
|
|
1198
|
+
/** Single-instance default: deliver straight to the local registry, no cross-node hop. */
|
|
1199
|
+
declare function local(): SyncDriver;
|
|
1200
|
+
/** In-memory `RoomRegistry` for node/bun/deno and tests. Edge-safe (plain Maps). */
|
|
1201
|
+
declare class InMemoryRoomRegistry implements RoomRegistry {
|
|
1202
|
+
private readonly rooms;
|
|
1203
|
+
private readonly clientRooms;
|
|
1204
|
+
private readonly clients;
|
|
1205
|
+
register(client: WsClient): void;
|
|
1206
|
+
join(client: WsClient, room: string): void;
|
|
1207
|
+
leave(client: WsClient, room: string): void;
|
|
1208
|
+
leaveAll(client: WsClient): void;
|
|
1209
|
+
localIdsInRoom(room: string): string[];
|
|
1210
|
+
deliverLocal(cmd: BroadcastCommand): void;
|
|
1211
|
+
}
|
|
1212
|
+
//#endregion
|
|
1213
|
+
//#region src/websocket/websocket.module.d.ts
|
|
1214
|
+
interface WebSocketModuleOptions {
|
|
1215
|
+
/**
|
|
1216
|
+
* Cross-instance sync driver. Defaults to `local()` (single instance). Use
|
|
1217
|
+
* `durableObject()` from `@velajs/cloudflare` or `redis()` from
|
|
1218
|
+
* `@velajs/vela/websocket-node` for horizontal scale.
|
|
1219
|
+
*/
|
|
1220
|
+
sync?: SyncDriver;
|
|
1221
|
+
/**
|
|
1222
|
+
* Local room registry the transport reads/writes. Defaults to the in-memory
|
|
1223
|
+
* implementation (node/bun/deno); the Cloudflare transport supplies its own.
|
|
1224
|
+
*/
|
|
1225
|
+
registry?: RoomRegistry;
|
|
1226
|
+
}
|
|
1227
|
+
/**
|
|
1228
|
+
* Registers the WebSocket gateway machinery: the message dispatcher (discovers
|
|
1229
|
+
* `@WebSocketGateway` classes via DiscoveryService at bootstrap), the room
|
|
1230
|
+
* registry, the sync driver, and the `@WebSocketServer()`-injected server
|
|
1231
|
+
* handle.
|
|
1232
|
+
*
|
|
1233
|
+
* Construction lives in chained provider factories — registry → driver
|
|
1234
|
+
* (bound to THAT registry) → server — so the single shared registry instance
|
|
1235
|
+
* is preserved and everything materializes at bootstrap's eager
|
|
1236
|
+
* instantiation, before any lifecycle hook or message dispatch.
|
|
1237
|
+
*
|
|
1238
|
+
* The instance key derives from the sync driver kind: two `forRoot()` calls
|
|
1239
|
+
* with the same driver kind dedup (HMR-idempotent); pass an explicit `key`
|
|
1240
|
+
* to run multiple same-kind instances side by side.
|
|
1241
|
+
*/
|
|
1242
|
+
declare const ConfigurableModuleClass$2: ConfigurableModuleClassType<WebSocketModuleOptions, "forRoot", "create", {
|
|
1243
|
+
isGlobal?: boolean;
|
|
1244
|
+
}>;
|
|
1245
|
+
declare class WebSocketModule extends ConfigurableModuleClass$2 {}
|
|
1246
|
+
//#endregion
|
|
1247
|
+
//#region src/websocket/ws-dispatcher.d.ts
|
|
1248
|
+
/** Metadata carried by each `'websocket'` entrypoint a transport consumes. */
|
|
1249
|
+
interface WsEntrypointMeta {
|
|
1250
|
+
/** The gateway's route path (from `@WebSocketGateway({ path })`). */
|
|
1251
|
+
path: string;
|
|
1252
|
+
/** The dispatcher that routes frames for this gateway. */
|
|
1253
|
+
dispatcher: WsDispatcher;
|
|
1254
|
+
}
|
|
1255
|
+
/**
|
|
1256
|
+
* Discovers `@WebSocketGateway` classes at bootstrap (via `DiscoveryService`)
|
|
1257
|
+
* and routes inbound messages to `@SubscribeMessage` handlers. Transports read
|
|
1258
|
+
* the gateways from `app.entrypoints.ofKind('websocket')` (this dispatcher
|
|
1259
|
+
* contributes them) and call `handleOpen`, `dispatchMessage`, `handleClose`,
|
|
1260
|
+
* and `handleError`; the guard → pipe → interceptor → filter pipeline
|
|
1261
|
+
* (including `APP_*` global components) runs through the shared
|
|
1262
|
+
* `PipelineRunner`.
|
|
1263
|
+
*/
|
|
1264
|
+
declare class WsDispatcher implements OnApplicationBootstrap, ContributesEntrypoints {
|
|
1265
|
+
private readonly container;
|
|
1266
|
+
private readonly discovery;
|
|
1267
|
+
private readonly server?;
|
|
1268
|
+
private readonly routeManager?;
|
|
1269
|
+
private readonly gateways;
|
|
1270
|
+
private readonly reserved;
|
|
1271
|
+
constructor(container: Container, discovery: DiscoveryService, server?: WsServer | undefined, routeManager?: RouteManager | undefined);
|
|
1272
|
+
/** Paths of every discovered `@WebSocketGateway` — used by transports to register routes. */
|
|
1273
|
+
get gatewayPaths(): string[];
|
|
1274
|
+
onApplicationBootstrap(): Promise<void>;
|
|
1275
|
+
/** One `'websocket'` entrypoint per discovered gateway (authoritative). */
|
|
1276
|
+
collectEntrypoints(): Entrypoint<WsEntrypointMeta>[];
|
|
1277
|
+
handleOpen(path: string, client: WsClient): Promise<void>;
|
|
1278
|
+
handleClose(path: string, client: WsClient, _code: number, _reason: string): Promise<void>;
|
|
1279
|
+
handleError(path: string, _client: WsClient, err: unknown): Promise<void>;
|
|
1280
|
+
dispatchMessage(path: string, client: WsClient, raw: string | ArrayBuffer): Promise<void>;
|
|
1281
|
+
/**
|
|
1282
|
+
* Route a reserved (`$…`) frame to its claiming handler. App-wide (`APP_*` /
|
|
1283
|
+
* `useGlobalGuards`) guards protect reserved frames exactly like gateway
|
|
1284
|
+
* messages — guards-first, WS convention; handler/class-tier components are
|
|
1285
|
+
* the claiming module's own concern (e.g. live resolvers run their scoped
|
|
1286
|
+
* guards at subscribe).
|
|
1287
|
+
*/
|
|
1288
|
+
private dispatchReserved;
|
|
1289
|
+
private reply;
|
|
1290
|
+
private runFilters;
|
|
1291
|
+
private trySend;
|
|
1292
|
+
private reportBootstrapError;
|
|
1293
|
+
private parse;
|
|
1294
|
+
private buildGatewayEntry;
|
|
1295
|
+
}
|
|
1296
|
+
//#endregion
|
|
1297
|
+
//#region src/websocket/ws-server.d.ts
|
|
1298
|
+
/**
|
|
1299
|
+
* Accumulates `{ rooms, exceptRooms, exceptIds }` across a fluent chain and, on
|
|
1300
|
+
* `.emit()`, produces a serializable `BroadcastCommand` handed to the active
|
|
1301
|
+
* `SyncDriver`. The driver decides local-vs-remote delivery.
|
|
1302
|
+
*/
|
|
1303
|
+
declare class BroadcastOperatorImpl implements BroadcastOperator {
|
|
1304
|
+
private readonly driver;
|
|
1305
|
+
private readonly rooms;
|
|
1306
|
+
private readonly exceptRooms;
|
|
1307
|
+
private readonly exceptIds;
|
|
1308
|
+
constructor(driver: SyncDriver, rooms?: Set<string>, exceptRooms?: Set<string>, exceptIds?: Set<string>);
|
|
1309
|
+
to(room: string): this;
|
|
1310
|
+
in(room: string): this;
|
|
1311
|
+
except(room: string): this;
|
|
1312
|
+
emit(event: string, data?: unknown): void | Promise<void>;
|
|
1313
|
+
}
|
|
1314
|
+
/**
|
|
1315
|
+
* The `@WebSocketServer()`-injected handle. Server-origin broadcasts never
|
|
1316
|
+
* pre-exclude anyone (a client-origin `client.to()` seeds `exceptIds` with the
|
|
1317
|
+
* sender — that lives in the transport's client, not here).
|
|
1318
|
+
*/
|
|
1319
|
+
declare class WsServerImpl implements WsServer {
|
|
1320
|
+
private readonly driver;
|
|
1321
|
+
constructor(driver: SyncDriver);
|
|
1322
|
+
emit(event: string, data?: unknown): void | Promise<void>;
|
|
1323
|
+
to(room: string): BroadcastOperator;
|
|
1324
|
+
in(room: string): BroadcastOperator;
|
|
1325
|
+
except(room: string): BroadcastOperator;
|
|
1326
|
+
}
|
|
1327
|
+
//#endregion
|
|
1328
|
+
//#region src/websocket/ws-execution-context.d.ts
|
|
1329
|
+
/**
|
|
1330
|
+
* WebSocket sibling of `buildExecutionContext` (`http/execution-context.ts`).
|
|
1331
|
+
* Guards/pipes/interceptors/filters that read `getClass()`/`getHandler()` or
|
|
1332
|
+
* call `switchToWs()` reuse unchanged; the HTTP-only accessors throw rather
|
|
1333
|
+
* than fabricate a fake `Request`.
|
|
1334
|
+
*/
|
|
1335
|
+
declare function buildWsExecutionContext(client: WsClient, data: unknown, controller: Type, handlerName: string | symbol, pattern: string): WsExecutionContext;
|
|
1336
|
+
//#endregion
|
|
1337
|
+
//#region src/websocket/ws-exception.d.ts
|
|
1338
|
+
/**
|
|
1339
|
+
* WebSocket analogue of `HttpException`. Thrown from guards/pipes/handlers to
|
|
1340
|
+
* signal a client-facing error; the dispatcher serializes it to an
|
|
1341
|
+
* `{ event: 'exception', data }` frame unless a matching exception filter
|
|
1342
|
+
* handles it first.
|
|
1343
|
+
*/
|
|
1344
|
+
declare class WsException extends Error {
|
|
1345
|
+
private readonly err;
|
|
1346
|
+
constructor(err: string | Record<string, unknown>);
|
|
1347
|
+
getError(): string | Record<string, unknown>;
|
|
1348
|
+
}
|
|
1349
|
+
/**
|
|
1350
|
+
* Default serialization of an uncaught error into the outbound exception frame.
|
|
1351
|
+
*
|
|
1352
|
+
* A `WsException` ships its own payload verbatim (string → `{ message }`,
|
|
1353
|
+
* object → as-is). Every other error routes through `toErrorBody` — the single
|
|
1354
|
+
* wire-redaction seam shared with the HTTP edge — so unbranded/internal errors
|
|
1355
|
+
* are redacted to their catalog title and only branded `VelaError`s echo a
|
|
1356
|
+
* client-safe `{ code, message, ... }`.
|
|
1357
|
+
*/
|
|
1358
|
+
declare function toErrorFrame(error: unknown, catalog?: Catalog<string>): {
|
|
1359
|
+
event: 'exception';
|
|
1360
|
+
data: unknown;
|
|
1361
|
+
};
|
|
1362
|
+
//#endregion
|
|
1363
|
+
//#region src/websocket/ws-argument-resolver.d.ts
|
|
1364
|
+
/**
|
|
1365
|
+
* Builds handler arguments for a gateway message. WS sibling of the HTTP
|
|
1366
|
+
* `ArgumentResolver`, but sourced from the envelope (`data`) and the socket
|
|
1367
|
+
* (`client`) instead of the Hono `Context`.
|
|
1368
|
+
*
|
|
1369
|
+
* With no parameter decorators the handler receives `(client, data)` — the
|
|
1370
|
+
* NestJS gateway convention. Pipes run only over `@MessageBody()` values, where
|
|
1371
|
+
* validation/transformation is meaningful.
|
|
1372
|
+
*/
|
|
1373
|
+
declare function resolveWsArgs(paramMeta: ParameterMetadata[], client: WsClient, data: unknown, pipes: PipeTransform[], paramTypes?: unknown[]): Promise<unknown[]>;
|
|
1374
|
+
//#endregion
|
|
1375
|
+
//#region src/websocket/websocket.tokens.d.ts
|
|
1376
|
+
declare const WS_GATEWAY_METADATA = "vela:ws-gateway";
|
|
1377
|
+
declare const WS_SUBSCRIBE_METADATA = "vela:ws-subscribe";
|
|
1378
|
+
declare const WS_RESERVED_METADATA = "vela:ws-reserved";
|
|
1379
|
+
/**
|
|
1380
|
+
* Event names starting with this prefix are RESERVED for framework modules
|
|
1381
|
+
* (`$live`, …): app gateways may not subscribe to them, and inbound frames
|
|
1382
|
+
* carrying them route to `@ReservedWsEvent` handlers instead of gateways.
|
|
1383
|
+
*/
|
|
1384
|
+
declare const RESERVED_WS_EVENT_PREFIX = "$";
|
|
1385
|
+
declare const WsParamType: {
|
|
1386
|
+
readonly SOCKET: 'ws_socket';
|
|
1387
|
+
readonly BODY: 'ws_body';
|
|
1388
|
+
readonly SERVER: 'ws_server';
|
|
1389
|
+
};
|
|
1390
|
+
type WsParamType = (typeof WsParamType)[keyof typeof WsParamType];
|
|
1391
|
+
/**
|
|
1392
|
+
* The connected gateway server handle. Injected into gateways/controllers via
|
|
1393
|
+
* `@WebSocketServer()` (constructor injection only — the container has no
|
|
1394
|
+
* property-injection pass) or `@Inject(WS_SERVER)`.
|
|
1395
|
+
*/
|
|
1396
|
+
declare const WS_SERVER: InjectionToken<WsServer>;
|
|
1397
|
+
/** The active cross-instance sync driver (`local()` by default). */
|
|
1398
|
+
declare const WS_SYNC_DRIVER: InjectionToken<SyncDriver>;
|
|
1399
|
+
/** The local room-membership registry a transport reads/writes. */
|
|
1400
|
+
declare const WS_ROOM_REGISTRY: InjectionToken<RoomRegistry>;
|
|
1401
|
+
declare const WS_MODULE_OPTIONS: InjectionToken<WebSocketModuleOptions>;
|
|
1402
|
+
//#endregion
|
|
1403
|
+
//#region src/health/health.module.d.ts
|
|
1404
|
+
declare class HealthModule {}
|
|
1405
|
+
//#endregion
|
|
1406
|
+
//#region src/health/health.types.d.ts
|
|
1407
|
+
type HealthCheckStatus = 'ok' | 'error' | 'shutting_down';
|
|
1408
|
+
interface HealthIndicatorResult {
|
|
1409
|
+
[key: string]: {
|
|
1410
|
+
status: 'up' | 'down';
|
|
1411
|
+
[key: string]: unknown;
|
|
1412
|
+
};
|
|
1413
|
+
}
|
|
1414
|
+
interface HealthCheckResult {
|
|
1415
|
+
status: HealthCheckStatus;
|
|
1416
|
+
info: HealthIndicatorResult;
|
|
1417
|
+
error: HealthIndicatorResult;
|
|
1418
|
+
details: HealthIndicatorResult;
|
|
1419
|
+
}
|
|
1420
|
+
type HealthIndicatorFunction = () => Promise<HealthIndicatorResult>;
|
|
1421
|
+
type ResponseCheckCallback = (response: Response) => boolean | Promise<boolean>;
|
|
1422
|
+
//#endregion
|
|
1423
|
+
//#region src/health/health.service.d.ts
|
|
1424
|
+
declare class HealthCheckService implements BeforeApplicationShutdown {
|
|
1425
|
+
private isShuttingDown;
|
|
1426
|
+
beforeApplicationShutdown(): void;
|
|
1427
|
+
check(indicators: HealthIndicatorFunction[]): Promise<HealthCheckResult>;
|
|
1428
|
+
}
|
|
1429
|
+
//#endregion
|
|
1430
|
+
//#region src/health/health.indicator.d.ts
|
|
1431
|
+
interface HealthIndicatorBuilder {
|
|
1432
|
+
up(data?: Record<string, unknown>): HealthIndicatorResult;
|
|
1433
|
+
down(data?: Record<string, unknown>): HealthIndicatorResult;
|
|
1434
|
+
}
|
|
1435
|
+
declare class HealthIndicatorService {
|
|
1436
|
+
check(key: string): HealthIndicatorBuilder;
|
|
1437
|
+
}
|
|
1438
|
+
//#endregion
|
|
1439
|
+
//#region src/health/health.http.d.ts
|
|
1440
|
+
interface HttpPingOptions {
|
|
1441
|
+
method?: string;
|
|
1442
|
+
headers?: Record<string, string>;
|
|
1443
|
+
timeout?: number;
|
|
1444
|
+
expectedStatus?: number;
|
|
1445
|
+
}
|
|
1446
|
+
declare class HttpHealthIndicator {
|
|
1447
|
+
private indicator;
|
|
1448
|
+
constructor(indicator: HealthIndicatorService);
|
|
1449
|
+
pingCheck(key: string, url: string, options?: HttpPingOptions): Promise<HealthIndicatorResult>;
|
|
1450
|
+
responseCheck(key: string, url: string, callback: ResponseCheckCallback, options?: HttpPingOptions): Promise<HealthIndicatorResult>;
|
|
1451
|
+
}
|
|
1452
|
+
//#endregion
|
|
1453
|
+
//#region src/throttler/throttler.types.d.ts
|
|
1454
|
+
interface ThrottleConfig {
|
|
1455
|
+
limit: number;
|
|
1456
|
+
ttl: number;
|
|
1457
|
+
}
|
|
1458
|
+
interface ThrottlerStorageRecord {
|
|
1459
|
+
count: number;
|
|
1460
|
+
ttlMs: number;
|
|
1461
|
+
}
|
|
1462
|
+
interface ThrottlerStore {
|
|
1463
|
+
increment(key: string, ttlMs: number): ThrottlerStorageRecord | Promise<ThrottlerStorageRecord>;
|
|
1464
|
+
reset(key: string): void | Promise<void>;
|
|
1465
|
+
}
|
|
1466
|
+
interface RateLimitInfo {
|
|
1467
|
+
limit: number;
|
|
1468
|
+
remaining: number;
|
|
1469
|
+
reset: number;
|
|
1470
|
+
}
|
|
1471
|
+
interface ThrottlerModuleOptions extends ThrottleConfig {
|
|
1472
|
+
storage?: ThrottlerStore;
|
|
1473
|
+
getTracker?: (request: Request) => string;
|
|
1474
|
+
generateKey?: (tracker: string, context: {
|
|
1475
|
+
className: string;
|
|
1476
|
+
handlerName: string;
|
|
1477
|
+
}) => string;
|
|
1478
|
+
}
|
|
1479
|
+
//#endregion
|
|
1480
|
+
//#region src/throttler/throttler.module.d.ts
|
|
1481
|
+
declare const ConfigurableModuleClass$1: ConfigurableModuleClassType<ThrottlerModuleOptions, "forRoot", "create", {
|
|
1482
|
+
isGlobal?: boolean;
|
|
1483
|
+
}>;
|
|
1484
|
+
declare class ThrottlerModule extends ConfigurableModuleClass$1 {}
|
|
1485
|
+
//#endregion
|
|
1486
|
+
//#region src/throttler/throttler.guard.d.ts
|
|
1487
|
+
declare class ThrottlerGuard implements CanActivate {
|
|
1488
|
+
private options;
|
|
1489
|
+
private storage;
|
|
1490
|
+
private reflector;
|
|
1491
|
+
constructor(options: ThrottlerModuleOptions, storage: ThrottlerStore);
|
|
1492
|
+
canActivate(context: ExecutionContext): Promise<boolean>;
|
|
1493
|
+
}
|
|
1494
|
+
//#endregion
|
|
1495
|
+
//#region src/throttler/throttler.storage.d.ts
|
|
1496
|
+
declare class ThrottlerStorage implements ThrottlerStore {
|
|
1497
|
+
private current;
|
|
1498
|
+
private previous;
|
|
1499
|
+
private lastSwap;
|
|
1500
|
+
private readonly swapIntervalMs;
|
|
1501
|
+
increment(key: string, ttlMs: number): ThrottlerStorageRecord;
|
|
1502
|
+
reset(key: string): void;
|
|
1503
|
+
private maybeSwap;
|
|
1504
|
+
}
|
|
1505
|
+
//#endregion
|
|
1506
|
+
//#region src/throttler/throttler.decorators.d.ts
|
|
1507
|
+
declare const Throttle: (config: ThrottleConfig) => (target: object, propertyKey?: string | symbol) => void;
|
|
1508
|
+
declare const SkipThrottle: () => (target: object, propertyKey?: string | symbol) => void;
|
|
1509
|
+
//#endregion
|
|
1510
|
+
//#region src/throttler/throttler.tokens.d.ts
|
|
1511
|
+
declare const THROTTLER_OPTIONS: InjectionToken<ThrottlerModuleOptions>;
|
|
1512
|
+
declare const THROTTLER_STORAGE: InjectionToken<ThrottlerStore>;
|
|
1513
|
+
declare const THROTTLE_METADATA = "vela:throttle";
|
|
1514
|
+
declare const SKIP_THROTTLE_METADATA = "vela:skip-throttle";
|
|
1515
|
+
//#endregion
|
|
1516
|
+
//#region src/module/stable-hash.d.ts
|
|
1517
|
+
/**
|
|
1518
|
+
* Deterministic, sync, edge-safe hash for module-instance discrimination.
|
|
1519
|
+
*
|
|
1520
|
+
* Walks values (objects/arrays/primitives/functions/class instances) into a
|
|
1521
|
+
* sorted, source-fingerprinting JSON string, then runs FNV-1a (32-bit) for a
|
|
1522
|
+
* compact 8-hex-char output.
|
|
1523
|
+
*
|
|
1524
|
+
* Functions and class instances are tolerated — they become `__fn:source` or
|
|
1525
|
+
* `__cls:ClassName` markers. Two distinct closures with the same source code
|
|
1526
|
+
* collide; module authors who care about that should pass an explicit `key`.
|
|
1527
|
+
*
|
|
1528
|
+
* Not cryptographic. Sufficient for discriminating module instances within
|
|
1529
|
+
* an app.
|
|
1530
|
+
*/
|
|
1531
|
+
declare function stableHash(value: unknown): string;
|
|
1532
|
+
//#endregion
|
|
1533
|
+
//#region src/module/configurable-module.types.d.ts
|
|
1534
|
+
/**
|
|
1535
|
+
* Arbitrary extra keys a module accepts alongside its options bag (e.g.
|
|
1536
|
+
* `isGlobal`). Kept separate from the options type so the extras-transform can
|
|
1537
|
+
* reshape the generated {@link DynamicModule} without polluting `Opts`.
|
|
1538
|
+
*/
|
|
1539
|
+
type ConfigurableModuleExtras = Record<string, unknown>;
|
|
1540
|
+
/**
|
|
1541
|
+
* Reshape the generated definition based on the resolved extras. Runs after the
|
|
1542
|
+
* options provider + `key` are computed; the return value is the final
|
|
1543
|
+
* `DynamicModule`. Mirrors NestJS's `extras` transform.
|
|
1544
|
+
*/
|
|
1545
|
+
type ConfigurableModuleExtrasTransform<E extends ConfigurableModuleExtras> = (definition: DynamicModule, extras: E) => DynamicModule;
|
|
1546
|
+
/**
|
|
1547
|
+
* The contract a `useClass`/`useExisting` async-options factory must satisfy:
|
|
1548
|
+
* a single method (default name `create`) returning the module options.
|
|
1549
|
+
*/
|
|
1550
|
+
type ConfigurableModuleOptionsFactory<Opts, MethodName extends string> = { [K in MethodName]: () => Opts | Promise<Opts>; };
|
|
1551
|
+
/**
|
|
1552
|
+
* Async configuration accepted by the generated `<method>Async` static.
|
|
1553
|
+
*
|
|
1554
|
+
* Superset of `AsyncModuleOptions` (`registry/types.ts`): adds NestJS's
|
|
1555
|
+
* `useClass`/`useExisting` while preserving the headline `const Inject` tuple
|
|
1556
|
+
* inference for `useFactory` params (no `as const` needed at the call site).
|
|
1557
|
+
*/
|
|
1558
|
+
interface ConfigurableModuleAsyncOptions<Opts, MethodName extends string = 'create', Inject extends readonly Token<unknown>[] = readonly Token<unknown>[]> {
|
|
1559
|
+
imports?: ModuleImport[];
|
|
1560
|
+
inject?: Inject;
|
|
1561
|
+
useFactory?: (...args: InferTokens<Inject>) => Opts | Promise<Opts>;
|
|
1562
|
+
useClass?: Type<ConfigurableModuleOptionsFactory<Opts, MethodName>>;
|
|
1563
|
+
useExisting?: Token<ConfigurableModuleOptionsFactory<Opts, MethodName>>;
|
|
1564
|
+
/** Explicit instance discriminator (see {@link DynamicModule.key}). */
|
|
1565
|
+
key?: string;
|
|
1566
|
+
}
|
|
1567
|
+
interface ConfigurableModuleBuilderOptions {
|
|
1568
|
+
/** Names the generated base class + the auto-minted options token, and feeds diagnostics. */
|
|
1569
|
+
moduleName?: string;
|
|
1570
|
+
/**
|
|
1571
|
+
* Reuse an existing options token instead of minting one. **Critical for
|
|
1572
|
+
* migrations** so the module's public token keeps its identity.
|
|
1573
|
+
*/
|
|
1574
|
+
optionsInjectionToken?: InjectionToken<unknown>;
|
|
1575
|
+
}
|
|
1576
|
+
/**
|
|
1577
|
+
* The generated base class type, carrying dynamically-named `<method>` and
|
|
1578
|
+
* `<method>Async` statics. A module does `class Foo extends ConfigurableModuleClass {}`
|
|
1579
|
+
* and gets `Foo.forRoot(...)` / `Foo.forRootAsync(...)` for free.
|
|
1580
|
+
*/
|
|
1581
|
+
type ConfigurableModuleClassType<Opts, MethodKey extends string, FactoryMethodKey extends string, Extras extends ConfigurableModuleExtras> = (new () => object) & Record<MethodKey, (options: Opts & Partial<Extras> & {
|
|
1582
|
+
key?: string;
|
|
1583
|
+
}) => DynamicModule> & Record<`${MethodKey}Async`, <const Inject extends readonly Token<unknown>[]>(options: ConfigurableModuleAsyncOptions<Opts, FactoryMethodKey, Inject> & Partial<Extras> & {
|
|
1584
|
+
key?: string;
|
|
1585
|
+
}) => DynamicModule>;
|
|
1586
|
+
interface ConfigurableModuleHost<Opts, MethodKey extends string = 'forRoot', FactoryMethodKey extends string = 'create', Extras extends ConfigurableModuleExtras = {
|
|
1587
|
+
isGlobal?: boolean;
|
|
1588
|
+
}> {
|
|
1589
|
+
/** Base class to `extends`. */
|
|
1590
|
+
ConfigurableModuleClass: ConfigurableModuleClassType<Opts, MethodKey, FactoryMethodKey, Extras>;
|
|
1591
|
+
/** The options token — inject it into derived providers (`inject: [MODULE_OPTIONS_TOKEN]`). */
|
|
1592
|
+
MODULE_OPTIONS_TOKEN: InjectionToken<Opts>;
|
|
1593
|
+
/** Type-only helper: the shape accepted by the sync `<method>` static. */
|
|
1594
|
+
OPTIONS_TYPE: Opts & Partial<Extras> & {
|
|
1595
|
+
key?: string;
|
|
1596
|
+
};
|
|
1597
|
+
/** Type-only helper: the shape accepted by the `<method>Async` static. */
|
|
1598
|
+
ASYNC_OPTIONS_TYPE: ConfigurableModuleAsyncOptions<Opts, FactoryMethodKey> & Partial<Extras> & {
|
|
1599
|
+
key?: string;
|
|
1600
|
+
};
|
|
1601
|
+
}
|
|
1602
|
+
/**
|
|
1603
|
+
* Low-level engine spec (see `defineConfigurableModule`). Used for the cases a
|
|
1604
|
+
* class-mixin can't express — notably runtime-generated module classes whose
|
|
1605
|
+
* providers depend on a call-time argument (e.g. Cloudflare binding modules).
|
|
1606
|
+
*/
|
|
1607
|
+
interface DefineConfigurableModuleSpec<Args> {
|
|
1608
|
+
/** The module class to reference in `{ module }`. */
|
|
1609
|
+
module: Type;
|
|
1610
|
+
/** Static method name to generate (e.g. `forRoot`). */
|
|
1611
|
+
methodName?: string;
|
|
1612
|
+
/** Derive the instance `key` from the call args. */
|
|
1613
|
+
keyFrom: (args: Args) => string;
|
|
1614
|
+
/** Build the provider list from the call args. */
|
|
1615
|
+
providers: (args: Args) => DynamicModule['providers'];
|
|
1616
|
+
/** Optional exports (usually prefer declaring these on `@Module`). */
|
|
1617
|
+
exports?: DynamicModule['exports'];
|
|
1618
|
+
/** Optional imports. */
|
|
1619
|
+
imports?: (args: Args) => DynamicModule['imports'];
|
|
1620
|
+
/** Mark the produced module global. */
|
|
1621
|
+
global?: boolean;
|
|
1622
|
+
}
|
|
1623
|
+
//#endregion
|
|
1624
|
+
//#region src/module/configurable-module.builder.d.ts
|
|
1625
|
+
/**
|
|
1626
|
+
* Blessed key-derivation helper for hand-written `forRoot` statics: the one
|
|
1627
|
+
* documented way to derive a `DynamicModule.key` from an options bag so
|
|
1628
|
+
* identical configurations dedup (HMR-idempotent) and distinct ones coexist.
|
|
1629
|
+
* Alias of {@link stableHash} with a module-authoring name.
|
|
1630
|
+
*/
|
|
1631
|
+
declare const moduleKey: (options: unknown) => string;
|
|
1632
|
+
/**
|
|
1633
|
+
* NestJS-parity builder that generates `forRoot`/`forRootAsync` (and `key`,
|
|
1634
|
+
* `global`, factory-param inference) from a tiny spec — so a module is just its
|
|
1635
|
+
* tokens + options type + service + a `@Module({...})` bag, while vela keeps its
|
|
1636
|
+
* encapsulation (`exports`/visibility) and multi-instance `key` dedup.
|
|
1637
|
+
*
|
|
1638
|
+
* Since 1.11 this is a thin adapter over {@link defineModule} — the single
|
|
1639
|
+
* authoring engine. Prefer `defineModule` for new modules: it additionally
|
|
1640
|
+
* supports contributions (providers/controllers/imports/exports/global
|
|
1641
|
+
* components) computed as functions of the options.
|
|
1642
|
+
*
|
|
1643
|
+
* @example
|
|
1644
|
+
* ```ts
|
|
1645
|
+
* const { ConfigurableModuleClass, MODULE_OPTIONS_TOKEN } =
|
|
1646
|
+
* new ConfigurableModuleBuilder<FooOptions>({ moduleName: 'Foo' }).build();
|
|
1647
|
+
*
|
|
1648
|
+
* @Module({
|
|
1649
|
+
* providers: [FooService], // derived providers inject MODULE_OPTIONS_TOKEN
|
|
1650
|
+
* exports: [FooService],
|
|
1651
|
+
* })
|
|
1652
|
+
* export class FooModule extends ConfigurableModuleClass {}
|
|
1653
|
+
* ```
|
|
1654
|
+
*/
|
|
1655
|
+
declare class ConfigurableModuleBuilder<Opts, MethodKey extends string = 'forRoot', FactoryMethodKey extends string = 'create', Extras extends ConfigurableModuleExtras = {
|
|
1656
|
+
isGlobal?: boolean;
|
|
1657
|
+
}> {
|
|
1658
|
+
private readonly options;
|
|
1659
|
+
private classMethodName;
|
|
1660
|
+
private factoryMethodName;
|
|
1661
|
+
private extrasDefaults;
|
|
1662
|
+
private extrasTransform;
|
|
1663
|
+
constructor(options?: ConfigurableModuleBuilderOptions);
|
|
1664
|
+
/** Declare extra call-site keys (e.g. `isGlobal`) + how they reshape the definition. */
|
|
1665
|
+
setExtras<NewExtras extends ConfigurableModuleExtras>(defaults: NewExtras, transform: ConfigurableModuleExtrasTransform<NewExtras>): ConfigurableModuleBuilder<Opts, MethodKey, FactoryMethodKey, NewExtras>;
|
|
1666
|
+
/** Rename the sync static (default `forRoot`); the async static becomes `<name>Async`. */
|
|
1667
|
+
setClassMethodName<NewMethodKey extends string>(name: NewMethodKey): ConfigurableModuleBuilder<Opts, NewMethodKey, FactoryMethodKey, Extras>;
|
|
1668
|
+
/** Rename the method a `useClass`/`useExisting` options factory must implement (default `create`). */
|
|
1669
|
+
setFactoryMethodName<NewFactoryMethodKey extends string>(name: NewFactoryMethodKey): ConfigurableModuleBuilder<Opts, MethodKey, NewFactoryMethodKey, Extras>;
|
|
1670
|
+
build(): ConfigurableModuleHost<Opts, MethodKey, FactoryMethodKey, Extras>;
|
|
1671
|
+
}
|
|
1672
|
+
/**
|
|
1673
|
+
* Lower-level engine for cases a class-mixin can't express — chiefly a
|
|
1674
|
+
* runtime-generated module class whose providers depend on a call-time arg
|
|
1675
|
+
* (Cloudflare binding modules). Returns an object with a single static named by
|
|
1676
|
+
* `spec.methodName` (default `forRoot`).
|
|
1677
|
+
*/
|
|
1678
|
+
declare function defineConfigurableModule<Args>(spec: DefineConfigurableModuleSpec<Args>): Record<string, (args: Args) => DynamicModule>;
|
|
1679
|
+
//#endregion
|
|
1680
|
+
//#region src/module/define-module.d.ts
|
|
1681
|
+
/** The `global:` slot's component groups, lowered to `APP_*` registrations. */
|
|
1682
|
+
interface GlobalComponentSlot {
|
|
1683
|
+
guards?: Array<Type | ComponentInstance>;
|
|
1684
|
+
pipes?: Array<Type | ComponentInstance>;
|
|
1685
|
+
interceptors?: Array<Type | ComponentInstance>;
|
|
1686
|
+
filters?: Array<Type | ComponentInstance>;
|
|
1687
|
+
middleware?: Array<Type | ComponentInstance>;
|
|
1688
|
+
}
|
|
1689
|
+
/** What a module instance contributes, computed from its call-time options. */
|
|
1690
|
+
interface ModuleContributions {
|
|
1691
|
+
providers?: Array<Type | ProviderOptions>;
|
|
1692
|
+
controllers?: Type[];
|
|
1693
|
+
imports?: ModuleImport[];
|
|
1694
|
+
exports?: Array<Type | InjectionToken>;
|
|
1695
|
+
/**
|
|
1696
|
+
* Standardized global-component registration — the one idiom replacing both
|
|
1697
|
+
* the `@Module({ providers: [{ provide: APP_GUARD, useExisting: X }] })`
|
|
1698
|
+
* pattern and the conditional-push-into-forRoot pattern. Class entries are
|
|
1699
|
+
* registered as providers and wired via `useExisting`; instances via `useValue`.
|
|
1700
|
+
*/
|
|
1701
|
+
global?: GlobalComponentSlot;
|
|
1702
|
+
}
|
|
1703
|
+
interface ModuleSetupContext<Opts> {
|
|
1704
|
+
/** The options token — derived providers do `inject: [OPTIONS]`. */
|
|
1705
|
+
readonly OPTIONS: InjectionToken<Opts>;
|
|
1706
|
+
/**
|
|
1707
|
+
* Structural options known at call time. For `forRoot` this is the full
|
|
1708
|
+
* bag; for `forRootAsync` it is only the structural fields passed alongside
|
|
1709
|
+
* the factory (the DI-resolved options exist only at resolution time —
|
|
1710
|
+
* read them through `OPTIONS`, never here).
|
|
1711
|
+
*/
|
|
1712
|
+
readonly options: Partial<Opts>;
|
|
1713
|
+
/** The instance key in effect (for deriving per-instance token names). */
|
|
1714
|
+
readonly key: string;
|
|
1715
|
+
}
|
|
1716
|
+
interface DefineModuleSpec<Opts, Extras extends ConfigurableModuleExtras = {
|
|
1717
|
+
isGlobal?: boolean;
|
|
1718
|
+
}, MethodKey extends string = 'forRoot', FactoryMethodKey extends string = 'create'> {
|
|
1719
|
+
/** Names the generated base class, the minted options token, and diagnostics. */
|
|
1720
|
+
name: string;
|
|
1721
|
+
/**
|
|
1722
|
+
* Reuse an existing options token instead of minting one — critical for
|
|
1723
|
+
* migrations so the module's public token keeps its identity.
|
|
1724
|
+
*/
|
|
1725
|
+
optionsToken?: InjectionToken<Opts>;
|
|
1726
|
+
/**
|
|
1727
|
+
* Structural contributions as a function of the call-time options. Runs at
|
|
1728
|
+
* `forRoot`/`forRootAsync` call time, once per module instance.
|
|
1729
|
+
*/
|
|
1730
|
+
setup?: (ctx: ModuleSetupContext<Opts>) => ModuleContributions;
|
|
1731
|
+
/**
|
|
1732
|
+
* Dedup key from the structural options. Defaults to `stableHash(options)`.
|
|
1733
|
+
* Modules whose options carry stateful instances (drivers, registries)
|
|
1734
|
+
* should derive from the stable identifying subset — or document that
|
|
1735
|
+
* callers pass an explicit `key` for multi-instance setups.
|
|
1736
|
+
*/
|
|
1737
|
+
key?: (options: Partial<Opts>) => string;
|
|
1738
|
+
/** Call-site extras defaults (default `{ isGlobal: false }`). */
|
|
1739
|
+
extras?: Extras;
|
|
1740
|
+
/** Reshape the definition from resolved extras (default: `isGlobal` → `global: true`). */
|
|
1741
|
+
transform?: ConfigurableModuleExtrasTransform<Extras>;
|
|
1742
|
+
/** Rename the sync static (default `forRoot`); the async static becomes `<name>Async`. */
|
|
1743
|
+
methodName?: MethodKey;
|
|
1744
|
+
/** Method a `useClass`/`useExisting` options factory must implement (default `create`). */
|
|
1745
|
+
factoryMethodName?: FactoryMethodKey;
|
|
1746
|
+
/**
|
|
1747
|
+
* Default every generated module instance to deferred (first-use)
|
|
1748
|
+
* materialization. Call sites can also opt in per instance by passing
|
|
1749
|
+
* `lazy: true` alongside the options (recognized like `isGlobal`).
|
|
1750
|
+
* See MODULE_AUTHORING.md "Lazy modules".
|
|
1751
|
+
*/
|
|
1752
|
+
lazy?: boolean;
|
|
1753
|
+
}
|
|
1754
|
+
/**
|
|
1755
|
+
* The one blessed module-authoring engine. Generates `forRoot` AND
|
|
1756
|
+
* `forRootAsync` statics with: `stableHash` key derivation (multi-instance
|
|
1757
|
+
* dedup that survives HMR), typed `inject` tuple inference on the async
|
|
1758
|
+
* factory, an `isGlobal` extra, and — the piece `ConfigurableModuleBuilder`
|
|
1759
|
+
* could not express — providers/controllers/imports/exports/global components
|
|
1760
|
+
* computed **as functions of the options**.
|
|
1761
|
+
*
|
|
1762
|
+
* ```ts
|
|
1763
|
+
* const { ConfigurableModuleClass, MODULE_OPTIONS_TOKEN } = defineModule<CorsOptions>({
|
|
1764
|
+
* name: 'Cors',
|
|
1765
|
+
* setup: ({ OPTIONS }) => ({
|
|
1766
|
+
* providers: [{
|
|
1767
|
+
* provide: APP_MIDDLEWARE,
|
|
1768
|
+
* useFactory: (o: CorsOptions) => buildCorsMiddleware(o),
|
|
1769
|
+
* inject: [OPTIONS],
|
|
1770
|
+
* }],
|
|
1771
|
+
* exports: [OPTIONS],
|
|
1772
|
+
* }),
|
|
1773
|
+
* });
|
|
1774
|
+
* export class CorsModule extends ConfigurableModuleClass {}
|
|
1775
|
+
* ```
|
|
1776
|
+
*
|
|
1777
|
+
* `ConfigurableModuleBuilder` remains supported (NestJS parity) and is a thin
|
|
1778
|
+
* adapter over this engine.
|
|
1779
|
+
*/
|
|
1780
|
+
declare function defineModule<Opts, Extras extends ConfigurableModuleExtras = {
|
|
1781
|
+
isGlobal?: boolean;
|
|
1782
|
+
}, MethodKey extends string = 'forRoot', FactoryMethodKey extends string = 'create'>(spec: DefineModuleSpec<Opts, Extras, MethodKey, FactoryMethodKey>): ConfigurableModuleHost<Opts, MethodKey, FactoryMethodKey, Extras>;
|
|
1783
|
+
/**
|
|
1784
|
+
* Lower `useFactory`/`useClass`/`useExisting` async options into provider
|
|
1785
|
+
* registrations. Structural fields from the call site merge UNDER the resolved
|
|
1786
|
+
* options (`{ ...structural, ...resolved }`) so sync-declared fields act as
|
|
1787
|
+
* defaults and the factory stays authoritative.
|
|
1788
|
+
*/
|
|
1789
|
+
declare function buildAsyncOptionsProviders<Opts>(optionsToken: Token, factoryMethodName: string, async: Pick<ConfigurableModuleAsyncOptions<Opts>, 'inject' | 'useFactory' | 'useClass' | 'useExisting'>, structural?: Record<string, unknown>): Array<ProviderOptions>;
|
|
1790
|
+
//#endregion
|
|
1791
|
+
//#region src/module/lazy-provider.d.ts
|
|
1792
|
+
interface LazyProviderSpec<T, Inject extends readonly Token<unknown>[]> {
|
|
1793
|
+
/** Token under which the memoized thunk `() => T` is provided. */
|
|
1794
|
+
provide: Token<() => T>;
|
|
1795
|
+
inject?: Inject;
|
|
1796
|
+
useFactory: (...deps: InferTokens<Inject>) => T;
|
|
1797
|
+
/** Memoize the first call's result (default true). */
|
|
1798
|
+
memoize?: boolean;
|
|
1799
|
+
}
|
|
1800
|
+
/**
|
|
1801
|
+
* Provide a zero-arg thunk `() => T` whose factory runs on FIRST CALL, not at
|
|
1802
|
+
* provider construction — for values that don't exist yet when the module
|
|
1803
|
+
* graph is built (Cloudflare bindings are only live at request time).
|
|
1804
|
+
*
|
|
1805
|
+
* The shared primitive replacing the hand-rolled
|
|
1806
|
+
* `useFactory: (...deps) => () => build(...deps)` closure that auth and
|
|
1807
|
+
* storage each copy-pasted.
|
|
1808
|
+
*
|
|
1809
|
+
* ```ts
|
|
1810
|
+
* lazyProvider({
|
|
1811
|
+
* provide: STORAGE_DRIVER_BUILDER,
|
|
1812
|
+
* inject: [MODULE_OPTIONS_TOKEN],
|
|
1813
|
+
* useFactory: (options) => options.driver(),
|
|
1814
|
+
* })
|
|
1815
|
+
* ```
|
|
1816
|
+
*/
|
|
1817
|
+
declare function lazyProvider<T, const Inject extends readonly Token<unknown>[] = readonly Token<unknown>[]>(spec: LazyProviderSpec<T, Inject>): ProviderOptions;
|
|
1818
|
+
/**
|
|
1819
|
+
* The one idiom for registering an app-wide component from a module's
|
|
1820
|
+
* providers. Returns registrations to spread:
|
|
1821
|
+
*
|
|
1822
|
+
* ```ts
|
|
1823
|
+
* providers: [MyService, ...provideGlobal('guard', AuthGuard)]
|
|
1824
|
+
* ```
|
|
1825
|
+
*
|
|
1826
|
+
* Class components are registered as providers and wired via `useExisting`
|
|
1827
|
+
* (so DI constructs them with their dependencies); instances via `useValue`.
|
|
1828
|
+
* Inside `defineModule`, prefer the equivalent `global:` contribution slot.
|
|
1829
|
+
*/
|
|
1830
|
+
declare function provideGlobal(kind: ComponentType, component: Type | object): Array<Type | ProviderOptions>;
|
|
1831
|
+
/**
|
|
1832
|
+
* A first-class side-effect-only module: contributes providers/exports without
|
|
1833
|
+
* being a configurable module — the supported form of the "empty marker
|
|
1834
|
+
* module" trick (i18n's `registerMessages`). Content-derived `key` makes
|
|
1835
|
+
* identical contributions dedup (HMR-idempotent) while distinct ones coexist.
|
|
1836
|
+
*
|
|
1837
|
+
* ```ts
|
|
1838
|
+
* export function registerMessages(messages: Messages): DynamicModule {
|
|
1839
|
+
* return sideEffectModule('I18nMessages', {
|
|
1840
|
+
* providers: [{ provide: I18N_MESSAGES, useValue: messages }],
|
|
1841
|
+
* exports: [I18N_MESSAGES],
|
|
1842
|
+
* });
|
|
1843
|
+
* }
|
|
1844
|
+
* ```
|
|
1845
|
+
*/
|
|
1846
|
+
declare function sideEffectModule(name: string, contributions?: Omit<ModuleContributions, 'global'> & {
|
|
1847
|
+
key?: string;
|
|
1848
|
+
}): DynamicModule;
|
|
1849
|
+
/**
|
|
1850
|
+
* Blessed token-minting convention: always an `InjectionToken` (never a raw
|
|
1851
|
+
* string), named for diagnostics. Namespace it `'<pkg>:<area>:<thing>'`.
|
|
1852
|
+
*/
|
|
1853
|
+
declare function moduleToken<T>(name: string): InjectionToken<T>;
|
|
1854
|
+
//#endregion
|
|
1855
|
+
//#region src/entrypoint/execution-scope.d.ts
|
|
1856
|
+
/**
|
|
1857
|
+
* Run one unit of non-HTTP work (a queue batch, a scheduled tick, an RPC
|
|
1858
|
+
* call) inside a fresh request-scoped child container — the non-HTTP
|
|
1859
|
+
* equivalent of the per-request child the HTTP pipeline creates:
|
|
1860
|
+
*
|
|
1861
|
+
* ```ts
|
|
1862
|
+
* await runInEntrypointScope(app.getContainer(), async (scope) => {
|
|
1863
|
+
* const consumer = scope.resolve(ep.token);
|
|
1864
|
+
* await consumer.process(batch);
|
|
1865
|
+
* });
|
|
1866
|
+
* ```
|
|
1867
|
+
*
|
|
1868
|
+
* Request-scoped providers (and singletons bubbled to request scope) resolve
|
|
1869
|
+
* per invocation instead of leaking one boot-time instance across every
|
|
1870
|
+
* dispatch; the child's request-scoped disposables are disposed (LIFO) when
|
|
1871
|
+
* `fn` settles — success or failure. `REQUEST_CONTEXT` is deliberately NOT
|
|
1872
|
+
* seeded: it is an HTTP primitive, and resolving it here keeps throwing its
|
|
1873
|
+
* explicit misuse error.
|
|
1874
|
+
*/
|
|
1875
|
+
declare function runInEntrypointScope<T>(container: Container, fn: (scope: Container) => T | Promise<T>): Promise<T>;
|
|
1876
|
+
//#endregion
|
|
1877
|
+
//#region src/entrypoint/execution-context.d.ts
|
|
1878
|
+
/** ExecutionContext flavor handed to components around entrypoint dispatch. */
|
|
1879
|
+
interface EntrypointExecutionContext extends ExecutionContext {
|
|
1880
|
+
/** The dispatch payload (queue batch, scheduled event, …). */
|
|
1881
|
+
getPayload<T = unknown>(): T;
|
|
1882
|
+
}
|
|
1883
|
+
/**
|
|
1884
|
+
* Entrypoint sibling of `buildExecutionContext` (HTTP) and
|
|
1885
|
+
* `buildWsExecutionContext`: lets guards/interceptors/filters written against
|
|
1886
|
+
* `getClass()`/`getHandler()`/`getType()` run unchanged around queue batches,
|
|
1887
|
+
* scheduled ticks, and any custom entrypoint kind. Transport-specific
|
|
1888
|
+
* accessors throw rather than fabricate fakes.
|
|
1889
|
+
*/
|
|
1890
|
+
declare function buildEntrypointExecutionContext(kind: string, targetClass: Type, handlerName: string | symbol, payload: unknown): EntrypointExecutionContext;
|
|
1891
|
+
//#endregion
|
|
1892
|
+
//#region src/http/route-contributor.d.ts
|
|
1893
|
+
/**
|
|
1894
|
+
* Context passed to {@link RouteContributor.buildRoutes} for each controller
|
|
1895
|
+
* the contributor claims. The contributor receives the framework's resolved
|
|
1896
|
+
* view of the world so generated routes behave identically to hand-written
|
|
1897
|
+
* ones: same global prefix, same global guard instances, same path joining.
|
|
1898
|
+
*/
|
|
1899
|
+
interface RouteContributorContext {
|
|
1900
|
+
/** The claimed controller class. */
|
|
1901
|
+
controller: Type;
|
|
1902
|
+
/** Controller-level prefix as registered with `@Controller(...)`. */
|
|
1903
|
+
controllerPrefix: string;
|
|
1904
|
+
/** The metadata value (under `claimsMetaKey`) that claimed this controller. */
|
|
1905
|
+
meta: unknown;
|
|
1906
|
+
/** Application-wide path prefix (e.g. `/api`), already normalized. */
|
|
1907
|
+
globalPrefix: string;
|
|
1908
|
+
/** Global guard instances, pre-resolved from the root container. */
|
|
1909
|
+
globalGuards: CanActivate[];
|
|
1910
|
+
/** The app's root container — resolve controller/services from here. */
|
|
1911
|
+
container: Container;
|
|
1912
|
+
/** Path joiner used by the framework — handles slash normalization. */
|
|
1913
|
+
joinPaths: (...parts: string[]) => string;
|
|
1914
|
+
}
|
|
1915
|
+
/** Context for {@link RouteContributor.buildOpenApiPaths}. */
|
|
1916
|
+
interface RouteContributorOpenApiContext {
|
|
1917
|
+
controller: Type;
|
|
1918
|
+
meta: unknown;
|
|
1919
|
+
/** Application-wide path prefix (e.g. `/api`), already normalized. */
|
|
1920
|
+
globalPrefix: string;
|
|
1921
|
+
/** Controller-level prefix as registered with `@Controller(...)`. */
|
|
1922
|
+
controllerPrefix: string;
|
|
1923
|
+
}
|
|
1924
|
+
/**
|
|
1925
|
+
* A route generator that claims controllers by class-level metadata and
|
|
1926
|
+
* mounts routes for them — the public extension point behind `@Crud()` (and
|
|
1927
|
+
* any future metadata-driven route generator: storage HTTP surfaces, admin
|
|
1928
|
+
* panels, RPC bridges).
|
|
1929
|
+
*
|
|
1930
|
+
* Register once at import time (`registerRouteContributor`); the framework
|
|
1931
|
+
* consults contributors during `RouteManager.build` — AFTER all explicit
|
|
1932
|
+
* `@Get`/`@Post` routes, so generated `/:id` catch-alls never shadow custom
|
|
1933
|
+
* routes — and during OpenAPI document generation.
|
|
1934
|
+
*
|
|
1935
|
+
* This contract exists instead of dynamic `import()` because esbuild leaves
|
|
1936
|
+
* `await import(variable)` as a runtime import Cloudflare Workers cannot
|
|
1937
|
+
* resolve.
|
|
1938
|
+
*/
|
|
1939
|
+
interface RouteContributor {
|
|
1940
|
+
/** Stable identifier; re-registering the same id overwrites (HMR-friendly). */
|
|
1941
|
+
id: string;
|
|
1942
|
+
/** Class-level metadata key whose presence claims a controller. */
|
|
1943
|
+
claimsMetaKey: string;
|
|
1944
|
+
buildRoutes(app: Hono, ctx: RouteContributorContext): void | Promise<void>;
|
|
1945
|
+
buildOpenApiPaths?(ctx: RouteContributorOpenApiContext): Record<string, OpenApiPathItem>;
|
|
1946
|
+
}
|
|
1947
|
+
/** Register a contributor. Last registration per `id` wins. */
|
|
1948
|
+
declare function registerRouteContributor(contributor: RouteContributor): void;
|
|
1949
|
+
/** All registered contributors (registration order). */
|
|
1950
|
+
declare function getRouteContributors(): RouteContributor[];
|
|
1951
|
+
//#endregion
|
|
1952
|
+
//#region src/pipeline/pipeline-runner.d.ts
|
|
1953
|
+
interface PipelineRunOptions {
|
|
1954
|
+
context: ExecutionContext;
|
|
1955
|
+
/** Pre-merged (global ++ scoped), pre-instantiated. */
|
|
1956
|
+
guards: CanActivate[];
|
|
1957
|
+
interceptors: NestInterceptor[];
|
|
1958
|
+
/** Extract handler arguments (pipes already bound inside the closure). */
|
|
1959
|
+
resolveArgs: () => Promise<unknown[]>;
|
|
1960
|
+
/** Call the actual handler. */
|
|
1961
|
+
invoke: (args: unknown[]) => Promise<unknown>;
|
|
1962
|
+
/**
|
|
1963
|
+
* HTTP runs argument extraction + pipes BEFORE guards (a deliberate vela
|
|
1964
|
+
* deviation — see handler-executor); WebSocket runs guards first. Default
|
|
1965
|
+
* false (guards first).
|
|
1966
|
+
*/
|
|
1967
|
+
argsBeforeGuards?: boolean;
|
|
1968
|
+
/** Error thrown when a guard rejects (default `ForbiddenException`). */
|
|
1969
|
+
onGuardReject?: () => Error;
|
|
1970
|
+
}
|
|
1971
|
+
/**
|
|
1972
|
+
* The transport-agnostic guard → pipe → interceptor execution core shared by
|
|
1973
|
+
* the HTTP `HandlerExecutor` and the WebSocket `WsDispatcher` (and any future
|
|
1974
|
+
* entrypoint dispatcher: queue consumers, scheduled jobs, …). Exception
|
|
1975
|
+
* FILTERS stay with the caller — their terminal behavior is transport-specific
|
|
1976
|
+
* (HTTP maps to a Response, WS sends an error frame).
|
|
1977
|
+
*/
|
|
1978
|
+
declare class PipelineRunner {
|
|
1979
|
+
static run(options: PipelineRunOptions): Promise<unknown>;
|
|
1980
|
+
/** Interceptor onion — innermost is the core handler. */
|
|
1981
|
+
static chainInterceptors(interceptors: NestInterceptor[], context: ExecutionContext, coreHandler: () => Promise<unknown>): Promise<unknown>;
|
|
1982
|
+
}
|
|
1983
|
+
//#endregion
|
|
1984
|
+
//#region src/pipeline/scoped-components.d.ts
|
|
1985
|
+
interface ResolvedComponentMap {
|
|
1986
|
+
guard: CanActivate;
|
|
1987
|
+
pipe: PipeTransform;
|
|
1988
|
+
interceptor: NestInterceptor;
|
|
1989
|
+
filter: ExceptionFilter;
|
|
1990
|
+
middleware: NestMiddleware;
|
|
1991
|
+
}
|
|
1992
|
+
/**
|
|
1993
|
+
* Public seam for custom dispatchers: the `@UseGuards`/`@UsePipes`/
|
|
1994
|
+
* `@UseInterceptors`/`@UseFilters` components scoped to a handler (class-level
|
|
1995
|
+
* then method-level, declaration order), resolved to instances through the
|
|
1996
|
+
* given container (classes constructed with DI; instances passed through).
|
|
1997
|
+
*
|
|
1998
|
+
* Order is preserved exactly as declared — conventions stay with the CALLER:
|
|
1999
|
+
* filters run closest-first, so dispatchers reverse them
|
|
2000
|
+
* (`resolveScopedComponents('filter', ...).reverse()`), and app-wide `APP_*`
|
|
2001
|
+
* components are a separate, transport-specific decision.
|
|
2002
|
+
*
|
|
2003
|
+
* Promoted to the public API by the QueueModule work (the "openness proof"):
|
|
2004
|
+
* it was the one capability custom entrypoint dispatchers needed that only
|
|
2005
|
+
* the internal `ComponentManager` provided.
|
|
2006
|
+
*/
|
|
2007
|
+
declare function resolveScopedComponents<T extends ComponentType>(type: T, targetClass: Constructor, methodName: string | symbol, container: Container): ResolvedComponentMap[T][];
|
|
2008
|
+
//#endregion
|
|
2009
|
+
//#region src/pipeline/decorators.d.ts
|
|
2010
|
+
declare function UseMiddleware(...middleware: ComponentTypeMap['middleware'][]): (target: object, propertyKey?: string | symbol) => void;
|
|
2011
|
+
declare function UseGuards(...guards: ComponentTypeMap['guard'][]): (target: object, propertyKey?: string | symbol) => void;
|
|
2012
|
+
declare function UsePipes(...pipes: ComponentTypeMap['pipe'][]): (target: object, propertyKey?: string | symbol) => void;
|
|
2013
|
+
declare function UseInterceptors(...interceptors: ComponentTypeMap['interceptor'][]): (target: object, propertyKey?: string | symbol) => void;
|
|
2014
|
+
declare function UseFilters(...filters: ComponentTypeMap['filter'][]): (target: object, propertyKey?: string | symbol) => void;
|
|
2015
|
+
declare function Catch(...exceptions: Type<Error>[]): ClassDecorator;
|
|
2016
|
+
declare function getCatchTypes(filter: unknown): Type<Error>[];
|
|
2017
|
+
declare function shouldFilterCatch(filter: unknown, exception: unknown): boolean;
|
|
2018
|
+
//#endregion
|
|
2019
|
+
//#region src/pipeline/reflector.d.ts
|
|
2020
|
+
interface CreateDecoratorOptions {
|
|
2021
|
+
key?: string;
|
|
2022
|
+
}
|
|
2023
|
+
interface ReflectableDecorator<TParam> {
|
|
2024
|
+
(value: TParam): ClassDecorator & MethodDecorator;
|
|
2025
|
+
KEY: string;
|
|
2026
|
+
}
|
|
2027
|
+
/**
|
|
2028
|
+
* Decorator that attaches custom metadata to a class or method.
|
|
2029
|
+
* Read via Reflector in guards/interceptors.
|
|
2030
|
+
*
|
|
2031
|
+
* @example
|
|
2032
|
+
* ```ts
|
|
2033
|
+
* const Roles = (...roles: string[]) => SetMetadata('roles', roles);
|
|
2034
|
+
*
|
|
2035
|
+
* @Controller('/admin')
|
|
2036
|
+
* @Roles('admin')
|
|
2037
|
+
* class AdminController { ... }
|
|
2038
|
+
* ```
|
|
2039
|
+
*/
|
|
2040
|
+
declare function SetMetadata<V = unknown>(key: string, value: V): (target: object, propertyKey?: string | symbol) => void;
|
|
2041
|
+
/**
|
|
2042
|
+
* Reads custom metadata set by @SetMetadata().
|
|
2043
|
+
* Use in guards/interceptors via ExecutionContext.
|
|
2044
|
+
*
|
|
2045
|
+
* @example
|
|
2046
|
+
* ```ts
|
|
2047
|
+
* class RolesGuard implements CanActivate {
|
|
2048
|
+
* private reflector = new Reflector();
|
|
2049
|
+
*
|
|
2050
|
+
* canActivate(context: ExecutionContext): boolean {
|
|
2051
|
+
* const roles = this.reflector.get<string[]>('roles', context);
|
|
2052
|
+
* if (!roles) return true;
|
|
2053
|
+
* const user = ...; // extract from request
|
|
2054
|
+
* return roles.some(r => user.roles.includes(r));
|
|
2055
|
+
* }
|
|
2056
|
+
* }
|
|
2057
|
+
* ```
|
|
2058
|
+
*/
|
|
2059
|
+
declare class Reflector {
|
|
2060
|
+
/**
|
|
2061
|
+
* Create a type-safe decorator that sets metadata with a typed key.
|
|
2062
|
+
*
|
|
2063
|
+
* @example
|
|
2064
|
+
* ```ts
|
|
2065
|
+
* const Roles = Reflector.createDecorator<string[]>();
|
|
2066
|
+
* // Roles(['admin']) — class or method decorator
|
|
2067
|
+
* // reflector.get(Roles, context) — typed as string[] | undefined
|
|
2068
|
+
* ```
|
|
2069
|
+
*/
|
|
2070
|
+
static createDecorator<TParam = unknown>(options?: CreateDecoratorOptions): ReflectableDecorator<TParam>;
|
|
2071
|
+
private resolveKey;
|
|
2072
|
+
/**
|
|
2073
|
+
* Get metadata value from handler first, then class.
|
|
2074
|
+
* Handler-level metadata takes priority over class-level.
|
|
2075
|
+
*/
|
|
2076
|
+
get<T = unknown>(key: string | ReflectableDecorator<T>, context: ExecutionContext): T | undefined;
|
|
2077
|
+
/**
|
|
2078
|
+
* Get metadata only from the handler (method) level.
|
|
2079
|
+
*/
|
|
2080
|
+
getHandler<T = unknown>(key: string | ReflectableDecorator<T>, context: ExecutionContext): T | undefined;
|
|
2081
|
+
/**
|
|
2082
|
+
* Get metadata only from the class level.
|
|
2083
|
+
*/
|
|
2084
|
+
getClass<T = unknown>(key: string | ReflectableDecorator<T>, context: Pick<ExecutionContext, 'getClass'>): T | undefined;
|
|
2085
|
+
/**
|
|
2086
|
+
* Get all metadata values for a key from both handler and class.
|
|
2087
|
+
* Returns [handlerValue, classValue] (either may be undefined).
|
|
2088
|
+
*/
|
|
2089
|
+
getAll<T = unknown>(key: string | ReflectableDecorator<T>, context: ExecutionContext): [T | undefined, T | undefined];
|
|
2090
|
+
/**
|
|
2091
|
+
* Returns handler value if defined, else class value, else undefined.
|
|
2092
|
+
* First defined value wins.
|
|
2093
|
+
*/
|
|
2094
|
+
getAllAndOverride<T = unknown>(key: string | ReflectableDecorator<T>, context: ExecutionContext): T | undefined;
|
|
2095
|
+
/**
|
|
2096
|
+
* Collects handler + class values, filters undefineds.
|
|
2097
|
+
* - 0 values → []
|
|
2098
|
+
* - 1 value → return it
|
|
2099
|
+
* - Arrays → concatenate
|
|
2100
|
+
* - Objects → Object.assign({}, ...values)
|
|
2101
|
+
* - Otherwise → wrap in array
|
|
2102
|
+
*/
|
|
2103
|
+
getAllAndMerge<T = unknown>(key: string | ReflectableDecorator<T>, context: ExecutionContext): T | T[];
|
|
2104
|
+
}
|
|
2105
|
+
//#endregion
|
|
2106
|
+
//#region src/pipeline/pipes.d.ts
|
|
2107
|
+
declare class ParseIntPipe implements PipeTransform<string, number> {
|
|
2108
|
+
transform(value: string, metadata: ArgumentMetadata): number;
|
|
2109
|
+
}
|
|
2110
|
+
declare class ParseFloatPipe implements PipeTransform<string, number> {
|
|
2111
|
+
transform(value: string, metadata: ArgumentMetadata): number;
|
|
2112
|
+
}
|
|
2113
|
+
declare class ParseBoolPipe implements PipeTransform<string, boolean> {
|
|
2114
|
+
transform(value: string, metadata: ArgumentMetadata): boolean;
|
|
2115
|
+
}
|
|
2116
|
+
declare class DefaultValuePipe<T = unknown> implements PipeTransform<T | undefined, T> {
|
|
2117
|
+
private readonly defaultValue;
|
|
2118
|
+
constructor(defaultValue: T);
|
|
2119
|
+
transform(value: T | undefined, _metadata: ArgumentMetadata): T;
|
|
2120
|
+
}
|
|
2121
|
+
declare class RequiredPipe implements PipeTransform {
|
|
2122
|
+
transform(value: unknown, metadata: ArgumentMetadata): unknown;
|
|
2123
|
+
}
|
|
2124
|
+
declare class ZodValidationPipe implements PipeTransform {
|
|
2125
|
+
private readonly schema;
|
|
2126
|
+
constructor(schema: {
|
|
2127
|
+
parse(data: unknown): unknown;
|
|
2128
|
+
});
|
|
2129
|
+
transform(value: unknown, _metadata: ArgumentMetadata): unknown;
|
|
2130
|
+
}
|
|
2131
|
+
interface ParseUUIDPipeOptions {
|
|
2132
|
+
version?: '3' | '4' | '5';
|
|
2133
|
+
}
|
|
2134
|
+
declare class ParseUUIDPipe implements PipeTransform<string, string> {
|
|
2135
|
+
private readonly options?;
|
|
2136
|
+
constructor(options?: ParseUUIDPipeOptions | undefined);
|
|
2137
|
+
transform(value: string, metadata: ArgumentMetadata): string;
|
|
2138
|
+
}
|
|
2139
|
+
declare class ParseEnumPipe<T extends Record<string, string | number>> implements PipeTransform<string, T[keyof T]> {
|
|
2140
|
+
private readonly allowedValues;
|
|
2141
|
+
private readonly valuesLabel;
|
|
2142
|
+
constructor(enumType: T);
|
|
2143
|
+
transform(value: string, metadata: ArgumentMetadata): T[keyof T];
|
|
2144
|
+
}
|
|
2145
|
+
interface ParseArrayPipeOptions {
|
|
2146
|
+
separator?: string;
|
|
2147
|
+
optional?: boolean;
|
|
2148
|
+
}
|
|
2149
|
+
declare class ParseArrayPipe implements PipeTransform {
|
|
2150
|
+
private readonly options?;
|
|
2151
|
+
constructor(options?: ParseArrayPipeOptions | undefined);
|
|
2152
|
+
transform(value: unknown, metadata: ArgumentMetadata): unknown[];
|
|
2153
|
+
}
|
|
2154
|
+
//#endregion
|
|
2155
|
+
//#region src/errors/http-exception.d.ts
|
|
2156
|
+
type ExceptionResponse = string | Record<string, unknown>;
|
|
2157
|
+
declare class HttpException extends Error {
|
|
2158
|
+
readonly statusCode: number;
|
|
2159
|
+
private readonly _response;
|
|
2160
|
+
constructor(response: ExceptionResponse, statusCode: number);
|
|
2161
|
+
getStatus(): number;
|
|
2162
|
+
getResponse(): Record<string, unknown>;
|
|
2163
|
+
getRawResponse(): ExceptionResponse;
|
|
2164
|
+
}
|
|
2165
|
+
declare class BadRequestException extends HttpException {
|
|
2166
|
+
constructor(message?: ExceptionResponse);
|
|
2167
|
+
}
|
|
2168
|
+
declare class UnauthorizedException extends HttpException {
|
|
2169
|
+
constructor(message?: ExceptionResponse);
|
|
2170
|
+
}
|
|
2171
|
+
declare class ForbiddenException extends HttpException {
|
|
2172
|
+
constructor(message?: ExceptionResponse);
|
|
2173
|
+
}
|
|
2174
|
+
declare class NotFoundException extends HttpException {
|
|
2175
|
+
constructor(message?: ExceptionResponse);
|
|
2176
|
+
}
|
|
2177
|
+
declare class MethodNotAllowedException extends HttpException {
|
|
2178
|
+
constructor(message?: ExceptionResponse);
|
|
2179
|
+
}
|
|
2180
|
+
declare class NotAcceptableException extends HttpException {
|
|
2181
|
+
constructor(message?: ExceptionResponse);
|
|
2182
|
+
}
|
|
2183
|
+
declare class RequestTimeoutException extends HttpException {
|
|
2184
|
+
constructor(message?: ExceptionResponse);
|
|
2185
|
+
}
|
|
2186
|
+
declare class ConflictException extends HttpException {
|
|
2187
|
+
constructor(message?: ExceptionResponse);
|
|
2188
|
+
}
|
|
2189
|
+
declare class GoneException extends HttpException {
|
|
2190
|
+
constructor(message?: ExceptionResponse);
|
|
2191
|
+
}
|
|
2192
|
+
declare class PayloadTooLargeException extends HttpException {
|
|
2193
|
+
constructor(message?: ExceptionResponse);
|
|
2194
|
+
}
|
|
2195
|
+
declare class UnsupportedMediaTypeException extends HttpException {
|
|
2196
|
+
constructor(message?: ExceptionResponse);
|
|
2197
|
+
}
|
|
2198
|
+
declare class UnprocessableEntityException extends HttpException {
|
|
2199
|
+
constructor(message?: ExceptionResponse);
|
|
2200
|
+
}
|
|
2201
|
+
declare class TooManyRequestsException extends HttpException {
|
|
2202
|
+
constructor(message?: ExceptionResponse);
|
|
2203
|
+
}
|
|
2204
|
+
declare class InternalServerErrorException extends HttpException {
|
|
2205
|
+
constructor(message?: ExceptionResponse);
|
|
2206
|
+
}
|
|
2207
|
+
declare class NotImplementedException extends HttpException {
|
|
2208
|
+
constructor(message?: ExceptionResponse);
|
|
2209
|
+
}
|
|
2210
|
+
declare class BadGatewayException extends HttpException {
|
|
2211
|
+
constructor(message?: ExceptionResponse);
|
|
2212
|
+
}
|
|
2213
|
+
declare class ServiceUnavailableException extends HttpException {
|
|
2214
|
+
constructor(message?: ExceptionResponse);
|
|
2215
|
+
}
|
|
2216
|
+
declare class GatewayTimeoutException extends HttpException {
|
|
2217
|
+
constructor(message?: ExceptionResponse);
|
|
2218
|
+
}
|
|
2219
|
+
//#endregion
|
|
2220
|
+
//#region src/exceptions/errors.module.d.ts
|
|
2221
|
+
/**
|
|
2222
|
+
* Options for {@link ErrorsModule.forRoot}. Both fields are optional — an empty
|
|
2223
|
+
* `forRoot()` provides just the core catalog (`CORE_CATALOG`) and no custom
|
|
2224
|
+
* handler, which is the framework default anyway.
|
|
2225
|
+
*/
|
|
2226
|
+
interface ErrorsModuleOptions {
|
|
2227
|
+
/**
|
|
2228
|
+
* App-specific catalogs composed **onto** `CORE_CATALOG` via
|
|
2229
|
+
* {@link composeCatalogs}. Composition is eager (at `forRoot` call time), so a
|
|
2230
|
+
* duplicate code across two catalogs fails fast with `duplicate error code`.
|
|
2231
|
+
*/
|
|
2232
|
+
catalogs?: Catalog<string>[];
|
|
2233
|
+
/**
|
|
2234
|
+
* The application-wide {@link ExceptionHandler}. A class is wired with
|
|
2235
|
+
* `useClass` (constructed through DI); a plain handler object with `useValue`.
|
|
2236
|
+
*/
|
|
2237
|
+
handler?: Type<ExceptionHandler> | ExceptionHandler;
|
|
2238
|
+
}
|
|
2239
|
+
declare const ConfigurableModuleClass: ConfigurableModuleClassType<ErrorsModuleOptions, "forRoot", "create", {
|
|
2240
|
+
isGlobal?: boolean;
|
|
2241
|
+
}>;
|
|
2242
|
+
/**
|
|
2243
|
+
* Registers the application-wide error surface: the composed
|
|
2244
|
+
* {@link ERROR_CATALOG} that every transport edge redacts against, and an
|
|
2245
|
+
* optional {@link APP_EXCEPTION_HANDLER}. The imperative sibling is
|
|
2246
|
+
* `app.useGlobalExceptionHandler(handler)`.
|
|
2247
|
+
*
|
|
2248
|
+
* ```ts
|
|
2249
|
+
* @Module({
|
|
2250
|
+
* imports: [ErrorsModule.forRoot({ catalogs: [ordersCatalog], handler: SentryHandler })],
|
|
2251
|
+
* })
|
|
2252
|
+
* class AppModule {}
|
|
2253
|
+
* ```
|
|
2254
|
+
*/
|
|
2255
|
+
declare class ErrorsModule extends ConfigurableModuleClass {}
|
|
2256
|
+
//#endregion
|
|
2257
|
+
//#region src/exceptions/reporter.d.ts
|
|
2258
|
+
/**
|
|
2259
|
+
* The resolved reporting facade every transport edge (HTTP, WS, live, queue,
|
|
2260
|
+
* schedule) uses. `report` is fire-and-forget and fully contained — a broken
|
|
2261
|
+
* or throwing handler can never mask the original error. `render` gives a
|
|
2262
|
+
* handler the chance to override the client-bound response.
|
|
2263
|
+
*/
|
|
2264
|
+
interface ErrorReporter {
|
|
2265
|
+
catalog: Catalog<string>;
|
|
2266
|
+
report(error: unknown, ctx: ErrorReportContext): void;
|
|
2267
|
+
render(error: unknown, executionCtx: unknown): Response | ErrorBodyResult | undefined;
|
|
2268
|
+
}
|
|
2269
|
+
/**
|
|
2270
|
+
* Build an {@link ErrorReporter} from a container. Reads the optional
|
|
2271
|
+
* {@link APP_EXCEPTION_HANDLER} and {@link ERROR_CATALOG} providers; with
|
|
2272
|
+
* neither registered the reporter logs (unless diagnostics is `'silent'`) and
|
|
2273
|
+
* exposes the core catalog.
|
|
2274
|
+
*/
|
|
2275
|
+
declare const resolveErrorReporter: (container: Container) => ErrorReporter;
|
|
2276
|
+
//#endregion
|
|
2277
|
+
//#region src/validation/create-zod-dto.d.ts
|
|
2278
|
+
interface ZodLikeSchema {
|
|
2279
|
+
parse(data: unknown): unknown;
|
|
2280
|
+
}
|
|
2281
|
+
type InferOutput<T extends ZodLikeSchema> = ReturnType<T['parse']>;
|
|
2282
|
+
interface CreateZodDtoOptions {
|
|
2283
|
+
/** Override the generated class name (useful for debugging and OpenAPI). */
|
|
2284
|
+
name?: string;
|
|
2285
|
+
}
|
|
2286
|
+
declare function createZodDto<T extends ZodLikeSchema>(schema: T, options?: CreateZodDtoOptions): {
|
|
2287
|
+
new (initial?: InferOutput<T>): InferOutput<T>;
|
|
2288
|
+
schema: T;
|
|
2289
|
+
};
|
|
2290
|
+
//#endregion
|
|
2291
|
+
//#region src/validation/validation.pipe.d.ts
|
|
2292
|
+
declare class ValidationPipe implements PipeTransform {
|
|
2293
|
+
transform(value: unknown, metadata: ArgumentMetadata): unknown;
|
|
2294
|
+
}
|
|
2295
|
+
//#endregion
|
|
2296
|
+
//#region src/serialization/serialize.decorator.d.ts
|
|
2297
|
+
declare const SERIALIZE_METADATA = "vela:serialize";
|
|
2298
|
+
declare function Serialize(dto: {
|
|
2299
|
+
schema: {
|
|
2300
|
+
parse(data: unknown): unknown;
|
|
2301
|
+
};
|
|
2302
|
+
}): MethodDecorator;
|
|
2303
|
+
//#endregion
|
|
2304
|
+
//#region src/serialization/serializer.interceptor.d.ts
|
|
2305
|
+
declare class SerializerInterceptor implements NestInterceptor {
|
|
2306
|
+
intercept(context: ExecutionContext, next: CallHandler): Promise<unknown>;
|
|
2307
|
+
}
|
|
2308
|
+
//#endregion
|
|
2309
|
+
export { CreateDecoratorOptions as $, Sse as $i, WebSocketGatewayOptions as $n, ConfigModuleOptions as $r, ThrottlerGuard as $t, InternalServerErrorException as A, All as Ai, WsServerImpl as An, CacheService as Ar, ModuleContributions as At, UnprocessableEntityException as B, HttpCode as Bi, MessageBody as Bn, CorsOptions as Br, ConfigurableModuleExtras as Bt, BadGatewayException as C, SignedUrlGenerateOptions as Ci, WS_SYNC_DRIVER as Cn, CACHE_MODULE_OPTIONS as Cr, LazyProviderSpec as Ct, GatewayTimeoutException as D, RouteParams as Di, toErrorFrame as Dn, TieredCacheStore as Dr, sideEffectModule as Dt, ForbiddenException as E, RouteName as Ei, WsException as En, CacheTTL as Er, provideGlobal as Et, PayloadTooLargeException as F, Delete as Fi, InMemoryRoomRegistry as Fn, CacheEntry as Fr, defineConfigurableModule as Ft, ParseBoolPipe as G, Post as Gi, BroadcastCommand as Gn, HttpModuleOptions as Gr, stableHash as Gt, DefaultValuePipe as H, Options as Hi, SubscribeMessage as Hn, HttpRequestException as Hr, ConfigurableModuleHost as Ht, RequestTimeoutException as I, Get as Ii, RoomRegistry as In, CacheModuleOptions as Ir, moduleKey as It, ParseIntPipe as J, RawBody as Ji, OnGatewayDisconnect as Jn, CONFIG_ENV as Jr, THROTTLER_STORAGE as Jt, ParseEnumPipe as K, Put as Ki, BroadcastOperator as Kn, HttpRequestConfig as Kr, SKIP_THROTTLE_METADATA as Kt, ServiceUnavailableException as L, Head as Li, SyncDriver as Ln, CacheStore as Lr, ConfigurableModuleAsyncOptions as Lt, NotAcceptableException as M, Controller as Mi, WsEntrypointMeta as Mn, AnyCacheStore as Mr, buildAsyncOptionsProviders as Mt, NotFoundException as N, Cookie as Ni, WebSocketModule as Nn, AsyncCacheStore as Nr, defineModule as Nt, GoneException as O, VelaRouteMap as Oi, buildWsExecutionContext as On, MemoryCacheStore as Or, DefineModuleSpec as Ot, NotImplementedException as P, Cookies as Pi, WebSocketModuleOptions as Pn, Awaitable as Pr, ConfigurableModuleBuilder as Pt, ZodValidationPipe as Q, RouteOptions as Qi, SubscribeMessageMetadata as Qn, ConfigModule as Qr, ThrottlerStorage as Qt, TooManyRequestsException as R, Header as Ri, local as Rn, CORS_OPTIONS as Rr, ConfigurableModuleBuilderOptions as Rt, ErrorsModuleOptions as S, SignedUrlGuard as Si, WS_SUBSCRIBE_METADATA as Sn, CACHE_MANAGER as Sr, runInEntrypointScope as St, ConflictException as T, UrlGeneratorService as Ti, resolveWsArgs as Tn, CacheKey as Tr, moduleToken as Tt, ParseArrayPipe as U, Param as Ui, WebSocketGateway as Un, HttpService as Ur, ConfigurableModuleOptionsFactory as Ut, UnsupportedMediaTypeException as V, Ip as Vi, ReservedWsEvent as Vn, HTTP_MODULE_OPTIONS as Vr, ConfigurableModuleExtrasTransform as Vt, ParseArrayPipeOptions as W, Patch as Wi, WebSocketServer as Wn, HttpModule as Wr, DefineConfigurableModuleSpec as Wt, ParseUUIDPipeOptions as X, Req as Xi, ReservedWsEventHandler as Xn, ConfigService as Xr, SkipThrottle as Xt, ParseUUIDPipe as Y, Redirect as Yi, OnGatewayInit as Yn, CONFIG_OPTIONS as Yr, THROTTLE_METADATA as Yt, RequiredPipe as Z, Res as Zi, ReservedWsEventMetadata as Zn, ConfigStore as Zr, Throttle as Zt, CreateZodDtoOptions as _, getCurrentRequestContext as _i, WS_GATEWAY_METADATA as _n, EventEmitter as _r, RouteContributorOpenApiContext as _t, VelaError as a, Injectable as aa, ConfigType as ai, ThrottlerStore as an, CronMatcher as ar, UseGuards as at, resolveErrorReporter as b, URL_SIGNING_SECRET as bi, WS_ROOM_REGISTRY as bn, EventEmitterModule as br, EntrypointExecutionContext as bt, defineErrorCatalog as c, ApiDoc as ca, ContextProvider as ci, HealthIndicatorService as cn, IntervalMetadata as cr, UsePipes as ct, isVelaError$1 as d, createOpenApiDocument as da, LoggerLevelName as di, HealthCheckStatus as dn, Cron as dr, ResolvedComponentMap as dt, Version as ea, ConfigPath as ei, ThrottlerModule as en, WsClient as er, ReflectableDecorator as et, toErrorBody$1 as f, VelaCreateOptions as fa, LoggerService as fi, HealthIndicatorFunction as fn, Interval as fr, resolveScopedComponents as ft, ValidationPipe as g, getCurrentContainer as gi, RESERVED_WS_EVENT_PREFIX as gn, EventEmitterSubscriber as gr, RouteContributorContext as gt, Serialize as h, RuntimeAdapter as ha, enableAmbientContainer as hi, HealthModule as hn, OnEvent as hr, RouteContributor as ht, ErrorCatalogEntry as i, Inject as ia, ConfigNamespace as ii, ThrottlerStorageRecord as in, WsServer as ir, UseFilters as it, MethodNotAllowedException as j, Body as ji, WsDispatcher as jn, CacheModule as jr, ModuleSetupContext as jt, HttpException as k, createLazyParamDecorator as ki, BroadcastOperatorImpl as kn, CacheInterceptor as kr, GlobalComponentSlot as kt, env as l, ApiResponse as la, LogLevel as li, HealthCheckService as ln, CRON_METADATA as lr, getCatchTypes as lt, SERIALIZE_METADATA as m, AdapterContext as ma, getRequestContainer as mi, ResponseCheckCallback as mn, ON_EVENT_METADATA as mr, PipelineRunner as mt, Catalog$1 as n, createParamDecorator as na, ConfigSchema as ni, ThrottleConfig as nn, WsMessage as nr, SetMetadata as nt, VelaErrorOptions as o, Optional as oa, InferConfigType as oi, HttpHealthIndicator as on, parseCron as or, UseInterceptors as ot, SerializerInterceptor as p, VelaFactory as pa, Writer as pi, HealthIndicatorResult as pn, ScheduleModule as pr, PipelineRunOptions as pt, ParseFloatPipe as q, Query as qi, OnGatewayConnection as qn, HttpResponse as qr, THROTTLER_OPTIONS as qt, ErrorBodyResult$1 as r, mixin as ra, AnyConfigNamespace as ri, ThrottlerModuleOptions as rn, WsResponse as rr, Catch as rt, composeCatalogs$1 as s, zodToJsonSchema as sa, registerAs as si, HttpPingOptions as sn, CronMetadata as sr, UseMiddleware as st, CORE_CATALOG$1 as t, applyDecorators as ta, ConfigPathValue as ti, RateLimitInfo as tn, WsExecutionContext as tr, Reflector as tt, getRuntimeKey as u, ApiTags as ua, Logger as ui, HealthCheckResult as un, INTERVAL_METADATA as ur, shouldFilterCatch as ut, createZodDto as v, REQUEST_CONTEXT as vi, WS_MODULE_OPTIONS as vn, EventHandler as vr, getRouteContributors as vt, BadRequestException as w, UrlForOptions as wi, WsParamType as wn, CACHE_TTL_METADATA as wr, lazyProvider as wt, ErrorsModule as x, SignedUrl as xi, WS_SERVER as xn, CACHE_KEY_METADATA as xr, buildEntrypointExecutionContext as xt, ErrorReporter as y, RequestContext as yi, WS_RESERVED_METADATA as yn, OnEventMetadata as yr, registerRouteContributor as yt, UnauthorizedException as z, Headers$1 as zi, ConnectedSocket as zn, CorsModule as zr, ConfigurableModuleClassType as zt };
|
|
2310
|
+
//# sourceMappingURL=index-DhShDLCM.d.ts.map
|