@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
|
@@ -1,343 +0,0 @@
|
|
|
1
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
}
|
|
7
|
-
function _ts_metadata(k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
}
|
|
10
|
-
function _ts_param(paramIndex, decorator) {
|
|
11
|
-
return function(target, key) {
|
|
12
|
-
decorator(target, key, paramIndex);
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
import { Container } from "../container/container.js";
|
|
16
|
-
import { Inject, Injectable, Optional } from "../container/decorators.js";
|
|
17
|
-
import { DiscoveryService } from "../discovery/discovery.service.js";
|
|
18
|
-
import { resolveErrorReporter } from "../exceptions/reporter.js";
|
|
19
|
-
import { instantiateMany } from "../http/instantiate.js";
|
|
20
|
-
import { RouteManager } from "../http/route.manager.js";
|
|
21
|
-
import { ComponentManager } from "../pipeline/component.manager.js";
|
|
22
|
-
import { shouldFilterCatch } from "../pipeline/decorators.js";
|
|
23
|
-
import { PipelineRunner } from "../pipeline/pipeline-runner.js";
|
|
24
|
-
import { MetadataRegistry } from "../registry/metadata.registry.js";
|
|
25
|
-
import { resolveWsArgs } from "./ws-argument-resolver.js";
|
|
26
|
-
import { buildWsExecutionContext } from "./ws-execution-context.js";
|
|
27
|
-
import { toErrorFrame, WsException } from "./ws-exception.js";
|
|
28
|
-
import { RESERVED_WS_EVENT_PREFIX, WS_GATEWAY_METADATA, WS_RESERVED_METADATA, WS_SERVER, WS_SUBSCRIBE_METADATA } from "./websocket.tokens.js";
|
|
29
|
-
function hasAfterInit(x) {
|
|
30
|
-
return typeof x?.afterInit === 'function';
|
|
31
|
-
}
|
|
32
|
-
function hasHandleConnection(x) {
|
|
33
|
-
return typeof x?.handleConnection === 'function';
|
|
34
|
-
}
|
|
35
|
-
function hasHandleDisconnect(x) {
|
|
36
|
-
return typeof x?.handleDisconnect === 'function';
|
|
37
|
-
}
|
|
38
|
-
function isWsResponse(x) {
|
|
39
|
-
return typeof x === 'object' && x !== null && typeof x.event === 'string';
|
|
40
|
-
}
|
|
41
|
-
export class WsDispatcher {
|
|
42
|
-
container;
|
|
43
|
-
discovery;
|
|
44
|
-
server;
|
|
45
|
-
routeManager;
|
|
46
|
-
gateways = new Map();
|
|
47
|
-
reserved = new Map();
|
|
48
|
-
constructor(container, discovery, server, routeManager){
|
|
49
|
-
this.container = container;
|
|
50
|
-
this.discovery = discovery;
|
|
51
|
-
this.server = server;
|
|
52
|
-
this.routeManager = routeManager;
|
|
53
|
-
}
|
|
54
|
-
/** Paths of every discovered `@WebSocketGateway` — used by transports to register routes. */ get gatewayPaths() {
|
|
55
|
-
return [
|
|
56
|
-
...this.gateways.keys()
|
|
57
|
-
];
|
|
58
|
-
}
|
|
59
|
-
async onApplicationBootstrap() {
|
|
60
|
-
// Reserved-event handlers first: modules claiming a `$…` event
|
|
61
|
-
// (@ReservedWsEvent) receive those frames across every gateway path.
|
|
62
|
-
for (const found of this.discovery.providersWithMeta(WS_RESERVED_METADATA)){
|
|
63
|
-
if (!found.instance) continue;
|
|
64
|
-
const event = found.meta.event;
|
|
65
|
-
if (this.reserved.has(event)) {
|
|
66
|
-
const msg = `[vela] duplicate @ReservedWsEvent('${event}') ` + `(${found.metatype.name}); keeping the first.`;
|
|
67
|
-
if (this.container.getDiagnostics() === 'throw') throw new Error(msg);
|
|
68
|
-
console.warn(msg);
|
|
69
|
-
continue;
|
|
70
|
-
}
|
|
71
|
-
this.reserved.set(event, found.instance);
|
|
72
|
-
}
|
|
73
|
-
for (const found of this.discovery.providersWithMeta(WS_GATEWAY_METADATA)){
|
|
74
|
-
if (!found.instance) continue;
|
|
75
|
-
const gatewayClass = found.metatype;
|
|
76
|
-
const instance = found.instance;
|
|
77
|
-
const entry = this.buildGatewayEntry(gatewayClass, found.meta, instance);
|
|
78
|
-
// Two gateways on the same path (or both defaulting to '') would silently
|
|
79
|
-
// overwrite each other in the routing Map — surface it instead.
|
|
80
|
-
if (this.gateways.has(entry.path)) {
|
|
81
|
-
const msg = `[vela] duplicate @WebSocketGateway path '${entry.path}' ` + `(${gatewayClass.name}); keeping the first. Give each gateway a distinct path.`;
|
|
82
|
-
if (this.container.getDiagnostics() === 'throw') throw new Error(msg);
|
|
83
|
-
console.warn(msg);
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
this.gateways.set(entry.path, entry);
|
|
87
|
-
if (this.server && hasAfterInit(instance)) {
|
|
88
|
-
try {
|
|
89
|
-
await instance.afterInit(this.server);
|
|
90
|
-
} catch (err) {
|
|
91
|
-
this.reportBootstrapError(gatewayClass.name, err);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
/** One `'websocket'` entrypoint per discovered gateway (authoritative). */ collectEntrypoints() {
|
|
97
|
-
return [
|
|
98
|
-
...this.gateways.values()
|
|
99
|
-
].map((entry)=>({
|
|
100
|
-
kind: 'websocket',
|
|
101
|
-
token: entry.gatewayClass,
|
|
102
|
-
instance: entry.instance,
|
|
103
|
-
meta: {
|
|
104
|
-
path: entry.path,
|
|
105
|
-
dispatcher: this
|
|
106
|
-
}
|
|
107
|
-
}));
|
|
108
|
-
}
|
|
109
|
-
async handleOpen(path, client) {
|
|
110
|
-
const entry = this.gateways.get(path);
|
|
111
|
-
if (entry && hasHandleConnection(entry.instance)) {
|
|
112
|
-
await entry.instance.handleConnection(client);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
async handleClose(path, client, _code, _reason) {
|
|
116
|
-
// Reserved handlers drop per-connection state first (isolated per handler)
|
|
117
|
-
// so a throwing gateway handleDisconnect can't leak live subscriptions.
|
|
118
|
-
for (const handler of this.reserved.values()){
|
|
119
|
-
try {
|
|
120
|
-
await handler.handleSocketClose?.(path, client);
|
|
121
|
-
} catch (err) {
|
|
122
|
-
await this.handleError(path, client, err);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
const entry = this.gateways.get(path);
|
|
126
|
-
if (entry && hasHandleDisconnect(entry.instance)) {
|
|
127
|
-
await entry.instance.handleDisconnect(client);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
async handleError(path, _client, err) {
|
|
131
|
-
// Connection-level and reserved-frame (`$…`) throws land here. Route them
|
|
132
|
-
// through the shared reporter so a custom APP_EXCEPTION_HANDLER observes
|
|
133
|
-
// them too — the default reporter console.errors and honors `'silent'`.
|
|
134
|
-
// No client frame is sent for this path, by design: reserved frames own
|
|
135
|
-
// their own client-facing responses, and there is no envelope id to reply to.
|
|
136
|
-
resolveErrorReporter(this.container).report(err, {
|
|
137
|
-
edge: 'ws',
|
|
138
|
-
source: path ? `reserved-frame ${path}` : 'reserved-frame'
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
async dispatchMessage(path, client, raw) {
|
|
142
|
-
const entry = this.gateways.get(path);
|
|
143
|
-
if (!entry) return;
|
|
144
|
-
let message;
|
|
145
|
-
try {
|
|
146
|
-
message = this.parse(raw);
|
|
147
|
-
} catch {
|
|
148
|
-
this.trySend(client, 'exception', {
|
|
149
|
-
message: 'Invalid message'
|
|
150
|
-
});
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
// Reserved namespace: `$…` frames route to @ReservedWsEvent handlers
|
|
154
|
-
// (after app-wide guards) and NEVER reach gateway handlers; an unclaimed
|
|
155
|
-
// reserved event is dropped like any unknown event.
|
|
156
|
-
if (message.event.startsWith(RESERVED_WS_EVENT_PREFIX)) {
|
|
157
|
-
await this.dispatchReserved(path, client, message);
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
const handler = entry.handlers.get(message.event);
|
|
161
|
-
if (!handler) return; // unknown event — ignored (NestJS parity)
|
|
162
|
-
const ctx = buildWsExecutionContext(client, message.data, entry.gatewayClass, handler.methodName, message.event);
|
|
163
|
-
// App-wide global components (APP_* provider tokens + imperative
|
|
164
|
-
// app.useGlobalX()) run first, then controller/handler-tier — mirroring the
|
|
165
|
-
// HTTP HandlerExecutor so global guards/pipes/interceptors/filters protect
|
|
166
|
-
// gateway messages too. Read live so late registrations propagate.
|
|
167
|
-
const globals = this.routeManager?.getGlobalComponents();
|
|
168
|
-
const guards = [
|
|
169
|
-
...instantiateMany(globals?.guards ?? [], this.container),
|
|
170
|
-
...instantiateMany(handler.guards, this.container)
|
|
171
|
-
];
|
|
172
|
-
const pipes = [
|
|
173
|
-
...instantiateMany(globals?.pipes ?? [], this.container),
|
|
174
|
-
...instantiateMany(handler.pipes, this.container)
|
|
175
|
-
];
|
|
176
|
-
const interceptors = [
|
|
177
|
-
...instantiateMany(globals?.interceptors ?? [], this.container),
|
|
178
|
-
...instantiateMany(handler.interceptors, this.container)
|
|
179
|
-
];
|
|
180
|
-
// Handler/controller filters first (closest), then global filters last.
|
|
181
|
-
const filters = [
|
|
182
|
-
...instantiateMany(handler.filters, this.container),
|
|
183
|
-
...instantiateMany(globals?.filters ?? [], this.container)
|
|
184
|
-
];
|
|
185
|
-
try {
|
|
186
|
-
const method = entry.instance[handler.methodName];
|
|
187
|
-
// Guards → args + pipes → interceptor chain → handler, via the shared
|
|
188
|
-
// runner (WS keeps guards-first, unlike HTTP's args-before-guards).
|
|
189
|
-
const result = await PipelineRunner.run({
|
|
190
|
-
context: ctx,
|
|
191
|
-
guards,
|
|
192
|
-
interceptors,
|
|
193
|
-
resolveArgs: ()=>resolveWsArgs(handler.paramMeta, client, message.data, pipes, handler.paramTypes),
|
|
194
|
-
invoke: async (args)=>method.apply(entry.instance, args),
|
|
195
|
-
onGuardReject: ()=>new WsException('Forbidden')
|
|
196
|
-
});
|
|
197
|
-
this.reply(client, message, result);
|
|
198
|
-
} catch (error) {
|
|
199
|
-
const reporter = resolveErrorReporter(this.container);
|
|
200
|
-
const source = `${entry.gatewayClass.name}.${handler.methodName}`;
|
|
201
|
-
// Report FIRST, always — before any exception filter can claim (and thus
|
|
202
|
-
// hide) the error. Rendering is a separate concern (mirrors HandlerExecutor).
|
|
203
|
-
reporter.report(error, {
|
|
204
|
-
edge: 'ws',
|
|
205
|
-
source
|
|
206
|
-
});
|
|
207
|
-
await this.runFilters(client, message, error, filters, ctx, reporter, source);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* Route a reserved (`$…`) frame to its claiming handler. App-wide (`APP_*` /
|
|
212
|
-
* `useGlobalGuards`) guards protect reserved frames exactly like gateway
|
|
213
|
-
* messages — guards-first, WS convention; handler/class-tier components are
|
|
214
|
-
* the claiming module's own concern (e.g. live resolvers run their scoped
|
|
215
|
-
* guards at subscribe).
|
|
216
|
-
*/ async dispatchReserved(path, client, message) {
|
|
217
|
-
const handler = this.reserved.get(message.event);
|
|
218
|
-
if (!handler) return;
|
|
219
|
-
const ctx = buildWsExecutionContext(client, message.data, handler.constructor, 'handleReservedEvent', message.event);
|
|
220
|
-
const globals = this.routeManager?.getGlobalComponents();
|
|
221
|
-
const guards = instantiateMany(globals?.guards ?? [], this.container);
|
|
222
|
-
try {
|
|
223
|
-
for (const guard of guards){
|
|
224
|
-
if (!await guard.canActivate(ctx)) {
|
|
225
|
-
const frame = toErrorFrame(new WsException('Forbidden'), resolveErrorReporter(this.container).catalog);
|
|
226
|
-
this.trySend(client, frame.event, frame.data, message.id);
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
await handler.handleReservedEvent(path, client, message);
|
|
231
|
-
} catch (err) {
|
|
232
|
-
await this.handleError(path, client, err);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
reply(client, message, result) {
|
|
236
|
-
if (result === undefined || result === null) return;
|
|
237
|
-
if (isWsResponse(result)) {
|
|
238
|
-
this.trySend(client, result.event, result.data, message.id);
|
|
239
|
-
} else {
|
|
240
|
-
this.trySend(client, message.event, result, message.id);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
async runFilters(client, message, error, filters, ctx, reporter, source) {
|
|
244
|
-
for (const filter of filters){
|
|
245
|
-
if (shouldFilterCatch(filter, error)) {
|
|
246
|
-
try {
|
|
247
|
-
const handled = await filter.catch(error, ctx);
|
|
248
|
-
if (isWsResponse(handled)) {
|
|
249
|
-
this.trySend(client, handled.event, handled.data, message.id);
|
|
250
|
-
}
|
|
251
|
-
} catch (filterError) {
|
|
252
|
-
// A throwing filter is itself a bug worth reporting — then fall back
|
|
253
|
-
// to the default redacted frame (mirrors HandlerExecutor).
|
|
254
|
-
reporter.report(filterError, {
|
|
255
|
-
edge: 'ws',
|
|
256
|
-
source,
|
|
257
|
-
note: 'exception filter threw'
|
|
258
|
-
});
|
|
259
|
-
const frame = toErrorFrame(error, reporter.catalog);
|
|
260
|
-
this.trySend(client, frame.event, frame.data, message.id);
|
|
261
|
-
}
|
|
262
|
-
return;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
const errorFrame = toErrorFrame(error, reporter.catalog);
|
|
266
|
-
this.trySend(client, errorFrame.event, errorFrame.data, message.id);
|
|
267
|
-
}
|
|
268
|
-
// Outbound sends are best-effort: the socket may have closed mid-dispatch.
|
|
269
|
-
trySend(client, event, data, id) {
|
|
270
|
-
try {
|
|
271
|
-
client.send(event, data, id);
|
|
272
|
-
} catch {
|
|
273
|
-
// socket closed — nothing to do
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
reportBootstrapError(name, err) {
|
|
277
|
-
const mode = this.container.getDiagnostics();
|
|
278
|
-
if (mode === 'throw') throw err;
|
|
279
|
-
if (mode === 'log') console.warn(`[vela] websocket gateway ${name} afterInit failed:`, err);
|
|
280
|
-
}
|
|
281
|
-
parse(raw) {
|
|
282
|
-
const text = typeof raw === 'string' ? raw : new TextDecoder().decode(raw);
|
|
283
|
-
const parsed = JSON.parse(text);
|
|
284
|
-
if (!parsed || typeof parsed !== 'object' || typeof parsed.event !== 'string') {
|
|
285
|
-
throw new Error('Invalid WebSocket message envelope');
|
|
286
|
-
}
|
|
287
|
-
return parsed;
|
|
288
|
-
}
|
|
289
|
-
buildGatewayEntry(gatewayClass, options, instance) {
|
|
290
|
-
const ctor = gatewayClass;
|
|
291
|
-
const subs = MetadataRegistry.getCustomClassMeta(ctor, WS_SUBSCRIBE_METADATA) ?? [];
|
|
292
|
-
const allParams = MetadataRegistry.getParameters(ctor);
|
|
293
|
-
const handlers = new Map();
|
|
294
|
-
for (const { event, methodName } of subs){
|
|
295
|
-
// The `$` namespace belongs to framework modules (@ReservedWsEvent) — an
|
|
296
|
-
// app gateway subscribing to it would never receive the frames anyway.
|
|
297
|
-
if (event.startsWith(RESERVED_WS_EVENT_PREFIX)) {
|
|
298
|
-
const msg = `[vela] @SubscribeMessage('${event}') on ${gatewayClass.name}: the ` + `'${RESERVED_WS_EVENT_PREFIX}' event prefix is reserved for framework modules — skipped.`;
|
|
299
|
-
if (this.container.getDiagnostics() === 'throw') throw new Error(msg);
|
|
300
|
-
console.warn(msg);
|
|
301
|
-
continue;
|
|
302
|
-
}
|
|
303
|
-
const paramMeta = [
|
|
304
|
-
...allParams.get(methodName) ?? []
|
|
305
|
-
].sort((a, b)=>a.index - b.index);
|
|
306
|
-
const paramTypes = Reflect.getMetadata('design:paramtypes', gatewayClass.prototype, methodName);
|
|
307
|
-
handlers.set(event, {
|
|
308
|
-
methodName,
|
|
309
|
-
paramMeta,
|
|
310
|
-
paramTypes,
|
|
311
|
-
guards: ComponentManager.getScopedComponents('guard', ctor, methodName),
|
|
312
|
-
pipes: ComponentManager.getScopedComponents('pipe', ctor, methodName),
|
|
313
|
-
interceptors: ComponentManager.getScopedComponents('interceptor', ctor, methodName),
|
|
314
|
-
// Handler → controller → global, so the closest filter runs first (mirrors HandlerExecutor).
|
|
315
|
-
filters: [
|
|
316
|
-
...ComponentManager.getScopedComponents('filter', ctor, methodName)
|
|
317
|
-
].reverse()
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
return {
|
|
321
|
-
path: options.path ?? '',
|
|
322
|
-
instance,
|
|
323
|
-
gatewayClass,
|
|
324
|
-
handlers
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
WsDispatcher = _ts_decorate([
|
|
329
|
-
Injectable(),
|
|
330
|
-
_ts_param(0, Inject(Container)),
|
|
331
|
-
_ts_param(1, Inject(DiscoveryService)),
|
|
332
|
-
_ts_param(2, Optional()),
|
|
333
|
-
_ts_param(2, Inject(WS_SERVER)),
|
|
334
|
-
_ts_param(3, Optional()),
|
|
335
|
-
_ts_param(3, Inject(RouteManager)),
|
|
336
|
-
_ts_metadata("design:type", Function),
|
|
337
|
-
_ts_metadata("design:paramtypes", [
|
|
338
|
-
typeof Container === "undefined" ? Object : Container,
|
|
339
|
-
typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
|
|
340
|
-
typeof WsServer === "undefined" ? Object : WsServer,
|
|
341
|
-
typeof RouteManager === "undefined" ? Object : RouteManager
|
|
342
|
-
])
|
|
343
|
-
], WsDispatcher);
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { type Catalog } from '@velajs/errors';
|
|
2
|
-
/**
|
|
3
|
-
* WebSocket analogue of `HttpException`. Thrown from guards/pipes/handlers to
|
|
4
|
-
* signal a client-facing error; the dispatcher serializes it to an
|
|
5
|
-
* `{ event: 'exception', data }` frame unless a matching exception filter
|
|
6
|
-
* handles it first.
|
|
7
|
-
*/
|
|
8
|
-
export declare class WsException extends Error {
|
|
9
|
-
private readonly err;
|
|
10
|
-
constructor(err: string | Record<string, unknown>);
|
|
11
|
-
getError(): string | Record<string, unknown>;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Default serialization of an uncaught error into the outbound exception frame.
|
|
15
|
-
*
|
|
16
|
-
* A `WsException` ships its own payload verbatim (string → `{ message }`,
|
|
17
|
-
* object → as-is). Every other error routes through `toErrorBody` — the single
|
|
18
|
-
* wire-redaction seam shared with the HTTP edge — so unbranded/internal errors
|
|
19
|
-
* are redacted to their catalog title and only branded `VelaError`s echo a
|
|
20
|
-
* client-safe `{ code, message, ... }`.
|
|
21
|
-
*/
|
|
22
|
-
export declare function toErrorFrame(error: unknown, catalog?: Catalog<string>): {
|
|
23
|
-
event: 'exception';
|
|
24
|
-
data: unknown;
|
|
25
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { toErrorBody } from "@velajs/errors";
|
|
2
|
-
/**
|
|
3
|
-
* WebSocket analogue of `HttpException`. Thrown from guards/pipes/handlers to
|
|
4
|
-
* signal a client-facing error; the dispatcher serializes it to an
|
|
5
|
-
* `{ event: 'exception', data }` frame unless a matching exception filter
|
|
6
|
-
* handles it first.
|
|
7
|
-
*/ export class WsException extends Error {
|
|
8
|
-
err;
|
|
9
|
-
constructor(err){
|
|
10
|
-
super(typeof err === 'string' ? err : String(err.message ?? 'WsException')), this.err = err;
|
|
11
|
-
this.name = 'WsException';
|
|
12
|
-
}
|
|
13
|
-
getError() {
|
|
14
|
-
return this.err;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Default serialization of an uncaught error into the outbound exception frame.
|
|
19
|
-
*
|
|
20
|
-
* A `WsException` ships its own payload verbatim (string → `{ message }`,
|
|
21
|
-
* object → as-is). Every other error routes through `toErrorBody` — the single
|
|
22
|
-
* wire-redaction seam shared with the HTTP edge — so unbranded/internal errors
|
|
23
|
-
* are redacted to their catalog title and only branded `VelaError`s echo a
|
|
24
|
-
* client-safe `{ code, message, ... }`.
|
|
25
|
-
*/ export function toErrorFrame(error, catalog) {
|
|
26
|
-
if (error instanceof WsException) {
|
|
27
|
-
const e = error.getError();
|
|
28
|
-
return {
|
|
29
|
-
event: 'exception',
|
|
30
|
-
data: typeof e === 'string' ? {
|
|
31
|
-
message: e
|
|
32
|
-
} : e
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
const { body } = toErrorBody(error, {
|
|
36
|
-
catalog
|
|
37
|
-
});
|
|
38
|
-
return {
|
|
39
|
-
event: 'exception',
|
|
40
|
-
data: body.error
|
|
41
|
-
};
|
|
42
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Type } from '../container/types';
|
|
2
|
-
import type { WsClient, WsExecutionContext } from './websocket.types';
|
|
3
|
-
/**
|
|
4
|
-
* WebSocket sibling of `buildExecutionContext` (`http/execution-context.ts`).
|
|
5
|
-
* Guards/pipes/interceptors/filters that read `getClass()`/`getHandler()` or
|
|
6
|
-
* call `switchToWs()` reuse unchanged; the HTTP-only accessors throw rather
|
|
7
|
-
* than fabricate a fake `Request`.
|
|
8
|
-
*/
|
|
9
|
-
export declare function buildWsExecutionContext(client: WsClient, data: unknown, controller: Type, handlerName: string | symbol, pattern: string): WsExecutionContext;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
const HTTP_ON_WS = (accessor)=>()=>{
|
|
2
|
-
throw new Error(`${accessor} called on a WebSocket ExecutionContext. This handler runs over a gateway message, not HTTP — use switchToWs().`);
|
|
3
|
-
};
|
|
4
|
-
/**
|
|
5
|
-
* WebSocket sibling of `buildExecutionContext` (`http/execution-context.ts`).
|
|
6
|
-
* Guards/pipes/interceptors/filters that read `getClass()`/`getHandler()` or
|
|
7
|
-
* call `switchToWs()` reuse unchanged; the HTTP-only accessors throw rather
|
|
8
|
-
* than fabricate a fake `Request`.
|
|
9
|
-
*/ export function buildWsExecutionContext(client, data, controller, handlerName, pattern) {
|
|
10
|
-
const host = {
|
|
11
|
-
getClient: ()=>client,
|
|
12
|
-
getData: ()=>data,
|
|
13
|
-
getPattern: ()=>pattern
|
|
14
|
-
};
|
|
15
|
-
return {
|
|
16
|
-
getType: ()=>'ws',
|
|
17
|
-
getClass: ()=>controller,
|
|
18
|
-
getHandler: ()=>handlerName,
|
|
19
|
-
getContext: HTTP_ON_WS('getContext()'),
|
|
20
|
-
getRequest: HTTP_ON_WS('getRequest()'),
|
|
21
|
-
switchToHttp: HTTP_ON_WS('switchToHttp()'),
|
|
22
|
-
switchToWs: ()=>host
|
|
23
|
-
};
|
|
24
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { SyncDriver } from './ws-sync';
|
|
2
|
-
import type { BroadcastOperator, WsServer } from './websocket.types';
|
|
3
|
-
/**
|
|
4
|
-
* Accumulates `{ rooms, exceptRooms, exceptIds }` across a fluent chain and, on
|
|
5
|
-
* `.emit()`, produces a serializable `BroadcastCommand` handed to the active
|
|
6
|
-
* `SyncDriver`. The driver decides local-vs-remote delivery.
|
|
7
|
-
*/
|
|
8
|
-
export declare class BroadcastOperatorImpl implements BroadcastOperator {
|
|
9
|
-
private readonly driver;
|
|
10
|
-
private readonly rooms;
|
|
11
|
-
private readonly exceptRooms;
|
|
12
|
-
private readonly exceptIds;
|
|
13
|
-
constructor(driver: SyncDriver, rooms?: Set<string>, exceptRooms?: Set<string>, exceptIds?: Set<string>);
|
|
14
|
-
to(room: string): this;
|
|
15
|
-
in(room: string): this;
|
|
16
|
-
except(room: string): this;
|
|
17
|
-
emit(event: string, data?: unknown): void | Promise<void>;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* The `@WebSocketServer()`-injected handle. Server-origin broadcasts never
|
|
21
|
-
* pre-exclude anyone (a client-origin `client.to()` seeds `exceptIds` with the
|
|
22
|
-
* sender — that lives in the transport's client, not here).
|
|
23
|
-
*/
|
|
24
|
-
export declare class WsServerImpl implements WsServer {
|
|
25
|
-
private readonly driver;
|
|
26
|
-
constructor(driver: SyncDriver);
|
|
27
|
-
emit(event: string, data?: unknown): void | Promise<void>;
|
|
28
|
-
to(room: string): BroadcastOperator;
|
|
29
|
-
in(room: string): BroadcastOperator;
|
|
30
|
-
except(room: string): BroadcastOperator;
|
|
31
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Accumulates `{ rooms, exceptRooms, exceptIds }` across a fluent chain and, on
|
|
3
|
-
* `.emit()`, produces a serializable `BroadcastCommand` handed to the active
|
|
4
|
-
* `SyncDriver`. The driver decides local-vs-remote delivery.
|
|
5
|
-
*/ export class BroadcastOperatorImpl {
|
|
6
|
-
driver;
|
|
7
|
-
rooms;
|
|
8
|
-
exceptRooms;
|
|
9
|
-
exceptIds;
|
|
10
|
-
constructor(driver, rooms = new Set(), exceptRooms = new Set(), exceptIds = new Set()){
|
|
11
|
-
this.driver = driver;
|
|
12
|
-
this.rooms = rooms;
|
|
13
|
-
this.exceptRooms = exceptRooms;
|
|
14
|
-
this.exceptIds = exceptIds;
|
|
15
|
-
}
|
|
16
|
-
to(room) {
|
|
17
|
-
this.rooms.add(room);
|
|
18
|
-
return this;
|
|
19
|
-
}
|
|
20
|
-
in(room) {
|
|
21
|
-
return this.to(room);
|
|
22
|
-
}
|
|
23
|
-
except(room) {
|
|
24
|
-
this.exceptRooms.add(room);
|
|
25
|
-
return this;
|
|
26
|
-
}
|
|
27
|
-
emit(event, data) {
|
|
28
|
-
const cmd = {
|
|
29
|
-
rooms: [
|
|
30
|
-
...this.rooms
|
|
31
|
-
],
|
|
32
|
-
exceptRooms: this.exceptRooms.size ? [
|
|
33
|
-
...this.exceptRooms
|
|
34
|
-
] : undefined,
|
|
35
|
-
exceptIds: this.exceptIds.size ? [
|
|
36
|
-
...this.exceptIds
|
|
37
|
-
] : undefined,
|
|
38
|
-
frame: JSON.stringify({
|
|
39
|
-
event,
|
|
40
|
-
data
|
|
41
|
-
})
|
|
42
|
-
};
|
|
43
|
-
return this.driver.dispatch(cmd);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* The `@WebSocketServer()`-injected handle. Server-origin broadcasts never
|
|
48
|
-
* pre-exclude anyone (a client-origin `client.to()` seeds `exceptIds` with the
|
|
49
|
-
* sender — that lives in the transport's client, not here).
|
|
50
|
-
*/ export class WsServerImpl {
|
|
51
|
-
driver;
|
|
52
|
-
constructor(driver){
|
|
53
|
-
this.driver = driver;
|
|
54
|
-
}
|
|
55
|
-
emit(event, data) {
|
|
56
|
-
// Empty `rooms` means GLOBAL.
|
|
57
|
-
return this.driver.dispatch({
|
|
58
|
-
rooms: [],
|
|
59
|
-
frame: JSON.stringify({
|
|
60
|
-
event,
|
|
61
|
-
data
|
|
62
|
-
})
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
to(room) {
|
|
66
|
-
return new BroadcastOperatorImpl(this.driver).to(room);
|
|
67
|
-
}
|
|
68
|
-
in(room) {
|
|
69
|
-
return this.to(room);
|
|
70
|
-
}
|
|
71
|
-
except(room) {
|
|
72
|
-
return new BroadcastOperatorImpl(this.driver).except(room);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import type { BroadcastCommand, WsClient } from './websocket.types';
|
|
2
|
-
/**
|
|
3
|
-
* Owns LOCAL room membership and local fan-out for the connections a single
|
|
4
|
-
* node/isolate holds. The Cloudflare transport backs this with hibernation
|
|
5
|
-
* tags + attachment; node/bun/deno back it with the in-memory implementation
|
|
6
|
-
* below. Always edge-safe (no `node:*`).
|
|
7
|
-
*/
|
|
8
|
-
export interface RoomRegistry {
|
|
9
|
-
/** Register a connection (called on connect) so global broadcasts can reach it. */
|
|
10
|
-
register(client: WsClient): void;
|
|
11
|
-
join(client: WsClient, room: string): void | Promise<void>;
|
|
12
|
-
leave(client: WsClient, room: string): void | Promise<void>;
|
|
13
|
-
/** Remove a connection and all its room memberships (called on disconnect). */
|
|
14
|
-
leaveAll(client: WsClient): void | Promise<void>;
|
|
15
|
-
/** Deliver a command to the sockets THIS node holds, applying every exclusion. */
|
|
16
|
-
deliverLocal(cmd: BroadcastCommand): void | Promise<void>;
|
|
17
|
-
localIdsInRoom(room: string): string[];
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Pluggable cross-instance transport for broadcast commands. `local()` is the
|
|
21
|
-
* zero-config single-instance default; `durableObject()` (Cloudflare) and
|
|
22
|
-
* `redis()` (node) are additive and chosen at the composition root.
|
|
23
|
-
*/
|
|
24
|
-
export interface SyncDriver {
|
|
25
|
-
readonly kind: string;
|
|
26
|
-
/** Wire the local registry so the driver can deliver to locally-held sockets. */
|
|
27
|
-
bind(registry: RoomRegistry): void;
|
|
28
|
-
/** Route a command so every node that may hold a matching socket delivers it. */
|
|
29
|
-
dispatch(cmd: BroadcastCommand): void | Promise<void>;
|
|
30
|
-
countRoom?(room: string): Promise<number>;
|
|
31
|
-
start?(): void | Promise<void>;
|
|
32
|
-
stop?(): void | Promise<void>;
|
|
33
|
-
}
|
|
34
|
-
/** Single-instance default: deliver straight to the local registry, no cross-node hop. */
|
|
35
|
-
export declare function local(): SyncDriver;
|
|
36
|
-
/** In-memory `RoomRegistry` for node/bun/deno and tests. Edge-safe (plain Maps). */
|
|
37
|
-
export declare class InMemoryRoomRegistry implements RoomRegistry {
|
|
38
|
-
private readonly rooms;
|
|
39
|
-
private readonly clientRooms;
|
|
40
|
-
private readonly clients;
|
|
41
|
-
register(client: WsClient): void;
|
|
42
|
-
join(client: WsClient, room: string): void;
|
|
43
|
-
leave(client: WsClient, room: string): void;
|
|
44
|
-
leaveAll(client: WsClient): void;
|
|
45
|
-
localIdsInRoom(room: string): string[];
|
|
46
|
-
deliverLocal(cmd: BroadcastCommand): void;
|
|
47
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/** Single-instance default: deliver straight to the local registry, no cross-node hop. */ export function local() {
|
|
2
|
-
let registry;
|
|
3
|
-
return {
|
|
4
|
-
kind: 'local',
|
|
5
|
-
bind (r) {
|
|
6
|
-
registry = r;
|
|
7
|
-
},
|
|
8
|
-
dispatch (cmd) {
|
|
9
|
-
return registry?.deliverLocal(cmd);
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
/** In-memory `RoomRegistry` for node/bun/deno and tests. Edge-safe (plain Maps). */ export class InMemoryRoomRegistry {
|
|
14
|
-
rooms = new Map();
|
|
15
|
-
clientRooms = new Map();
|
|
16
|
-
clients = new Map();
|
|
17
|
-
register(client) {
|
|
18
|
-
this.clients.set(client.id, client);
|
|
19
|
-
}
|
|
20
|
-
join(client, room) {
|
|
21
|
-
this.register(client);
|
|
22
|
-
let members = this.rooms.get(room);
|
|
23
|
-
if (!members) {
|
|
24
|
-
members = new Set();
|
|
25
|
-
this.rooms.set(room, members);
|
|
26
|
-
}
|
|
27
|
-
members.add(client);
|
|
28
|
-
let joined = this.clientRooms.get(client.id);
|
|
29
|
-
if (!joined) {
|
|
30
|
-
joined = new Set();
|
|
31
|
-
this.clientRooms.set(client.id, joined);
|
|
32
|
-
}
|
|
33
|
-
joined.add(room);
|
|
34
|
-
}
|
|
35
|
-
leave(client, room) {
|
|
36
|
-
const members = this.rooms.get(room);
|
|
37
|
-
members?.delete(client);
|
|
38
|
-
if (members && members.size === 0) this.rooms.delete(room);
|
|
39
|
-
this.clientRooms.get(client.id)?.delete(room);
|
|
40
|
-
}
|
|
41
|
-
leaveAll(client) {
|
|
42
|
-
for (const room of this.clientRooms.get(client.id) ?? []){
|
|
43
|
-
const members = this.rooms.get(room);
|
|
44
|
-
members?.delete(client);
|
|
45
|
-
if (members && members.size === 0) this.rooms.delete(room);
|
|
46
|
-
}
|
|
47
|
-
this.clientRooms.delete(client.id);
|
|
48
|
-
this.clients.delete(client.id);
|
|
49
|
-
}
|
|
50
|
-
localIdsInRoom(room) {
|
|
51
|
-
return [
|
|
52
|
-
...this.rooms.get(room) ?? []
|
|
53
|
-
].map((c)=>c.id);
|
|
54
|
-
}
|
|
55
|
-
deliverLocal(cmd) {
|
|
56
|
-
const excludeIds = new Set(cmd.exceptIds ?? []);
|
|
57
|
-
const excludeRooms = cmd.exceptRooms ?? [];
|
|
58
|
-
// Empty `rooms` => GLOBAL: every registered connection. Otherwise the union
|
|
59
|
-
// of the targeted rooms' members (deduped per connection).
|
|
60
|
-
const candidates = cmd.rooms.length === 0 ? new Set(this.clients.values()) : (()=>{
|
|
61
|
-
const set = new Set();
|
|
62
|
-
for (const room of cmd.rooms){
|
|
63
|
-
for (const client of this.rooms.get(room) ?? [])set.add(client);
|
|
64
|
-
}
|
|
65
|
-
return set;
|
|
66
|
-
})();
|
|
67
|
-
for (const client of candidates){
|
|
68
|
-
if (excludeIds.has(client.id)) continue;
|
|
69
|
-
const joined = this.clientRooms.get(client.id);
|
|
70
|
-
if (excludeRooms.some((room)=>joined?.has(room))) continue;
|
|
71
|
-
client.sendRaw(cmd.frame);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|