@relaybus/nestjs 0.2.0 → 0.3.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/README.md +181 -33
- package/dist/index.cjs +307 -66
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +189 -34
- package/dist/index.d.ts +189 -34
- package/dist/index.js +306 -69
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/event-consumer.decorator.ts","../src/subscribe.decorator.ts","../src/handler-explorer.ts","../src/module-options.ts","../src/relay-bus-health.ts","../src/relay-bus-lifecycle.ts","../src/relay-bus.module.ts"],"names":["describeCatalog","consume","ConfigurationError","RelayBusHandlerExplorer","Injectable","DiscoveryService","MetadataScanner","RelayBus","ConfigurableModuleBuilder","RelayBusHealth","systemClock","Inject","RelayBusLifecycle","RelayBusModule","Module","DiscoveryModule","Logger"],"mappings":";;;;;;;;;;;;;;;;AAkDA,IAAM,2BAAA,mBAA8B,MAAA,CAAO,GAAA,CAAI,gCAAgC,CAAA;AAiDxE,SAAS,cACd,OAAA,EACA;AAAA,EACE,MAAA;AAAA,EACA,GAAG;AACL,CAAA,GAEI,EAAC,EACW;AAChB,EAAA,MAAM,EAAE,IAAA,EAAK,GAAIA,oBAAA,CAAgB,OAAO,CAAA;AACxC,EAAA,MAAM,eAAA,GACJ,WAAW,MAAA,GACP,MAAA,GACAC,aAAQ,OAAA,EAAS,EAAE,MAAA,EAA8C,CAAA,CAAE,OAAA;AACzE,EAAA,OAAO,CAAC,MAAA,KAAW;AACjB,IAAA,MAAM,WACH,OAAA,CAAQ,cAAA,CAAe,2BAAA,EAA6B,MAAM,KACjB,EAAC;AAC7C,IAAA,IAAI,SAAS,IAAA,CAAK,CAAC,aAAa,QAAA,CAAS,OAAA,KAAY,OAAO,CAAA,EAAG;AAC7D,MAAA,MAAM,IAAIC,uBAAA;AAAA,Q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AAA;AAAA,QACT,MAAA,EAAQ,CAAC,uBAAuB,CAAA;AAAA,QAChC,UAAA,EAAY,CAAC,OAAA,KACX,IAAIA,aAAAA,CAAS,EAAE,GAAG,OAAA,EAAS,MAAA,EAAQ,IAAIS,aAAA,CAAO,UAAU,GAAG;AAAA,OAC/D;AAAA,MACAb,+BAAA;AAAA,MACAS,yBAAA;AAAA,MACAH;AAAA,KACF;AAAA,IACA,OAAA,EAAS,CAACF,aAAAA,EAAUE,sBAAc;AAAA,GACnC;AAAA,CAAA,EACYI,sBAAA,CAAA","file":"index.cjs","sourcesContent":["import 'reflect-metadata';\nimport {\n ConfigurationError,\n consume,\n describeCatalog,\n type Catalog,\n type CatalogEntry,\n type CatalogEventSelection,\n type EventOf,\n type HandlerContext,\n type SubscribeOptions,\n} from '@relaybus/core';\n\n/**\n * Options of {@link EventConsumer}: the core {@link SubscribeOptions} applied to\n * every handler of the class, except `id`, which is always\n * `${ClassName}.on${EventName}`, and optionally the events the class consumes.\n */\nexport type EventConsumerOptions<\n TCatalog extends Catalog = Catalog,\n TName extends keyof TCatalog = keyof TCatalog,\n> = Omit<SubscribeOptions, 'id'> & CatalogEventSelection<TName>;\n\n/** What one `@EventConsumer` decorator recorded on a class. */\nexport interface EventConsumerMetadata {\n readonly catalog: Catalog;\n /** Subscribe options applied to every handler of the class. */\n readonly options: Omit<SubscribeOptions, 'id'>;\n /**\n * Entries named by `options.events`, whose methods are all required;\n * undefined when the class consumes whichever handler methods it defines.\n */\n readonly selectedEntries: readonly CatalogEntry[] | undefined;\n}\n\n/**\n * A class whose instances have a handler method for each of the named catalog\n * events. The event parameter is checked strictly; the context is typed\n * `HandlerContext<never>` so a method may declare any transaction type.\n */\nexport type EventConsumerClass<\n TCatalog extends Catalog,\n TName extends keyof TCatalog,\n> = abstract new (...args: never[]) => {\n readonly [TKey in TName & string as `on${TKey}`]: (\n event: EventOf<TCatalog[TKey]>,\n context: HandlerContext<never>,\n ) => unknown;\n};\n\nconst EVENT_CONSUMER_METADATA_KEY = Symbol.for('relaybus.nestjs.event-consumer');\n\n/**\n * Subscribes a provider class to the events of a catalog: its\n * `on${EventName}` methods are registered when the module initialises, under\n * the stable id `${ClassName}.on${EventName}`, with `this` bound to the\n * provider instance.\n *\n * - Without `events`, every handler method the class defines is registered; a\n * class that defines none fails the boot, which catches misspelled names.\n * `implements HandlersOf<typeof Catalog>` makes the compiler require all of them.\n * - With `events`, exactly the methods of those events are registered (methods\n * of other events are ignored), and a class missing one of them fails to\n * compile and fails the boot. This is how a service consumes its part of a\n * catalog shared between services.\n *\n * `catalogs: [consume(Catalog, { events })]` in the module options makes the\n * application fail to boot if no provider handles a consumed event. Works next\n * to `@Subscribe` in the same class (give a method that carries both a\n * distinct `@Subscribe` id). The provider must be a singleton. Declarations\n * are inherited; a subclass that declares the same catalog again replaces the\n * inherited declaration of that catalog, and declaring one catalog twice on\n * the same class throws a {@link ConfigurationError}.\n *\n * ```ts\n * @Injectable()\n * @EventConsumer(OrderEvents, { events: ['OrderPlaced'], transactional: true })\n * export class BillingHandlers {\n * onOrderPlaced(event: EventOf<typeof OrderPlaced>) {}\n * }\n * ```\n */\nexport function EventConsumer<TCatalog extends Catalog>(\n catalog: TCatalog,\n options?: Omit<SubscribeOptions, 'id'> & { readonly events?: undefined },\n): ClassDecorator;\nexport function EventConsumer<TCatalog extends Catalog, const TName extends keyof TCatalog>(\n catalog: TCatalog,\n options: Omit<SubscribeOptions, 'id'> & { readonly events: readonly TName[] },\n): (target: EventConsumerClass<TCatalog, TName>) => void;\n/**\n * With options whose `events` are not statically known (a variable typed\n * {@link EventConsumerOptions}), the selection is checked when the module\n * initialises instead of at compile time.\n */\nexport function EventConsumer<TCatalog extends Catalog>(\n catalog: TCatalog,\n options: EventConsumerOptions<TCatalog>,\n): ClassDecorator;\nexport function EventConsumer(\n catalog: Catalog,\n {\n events,\n ...options\n }: Omit<SubscribeOptions, 'id'> & {\n readonly events?: readonly PropertyKey[] | undefined;\n } = {},\n): ClassDecorator {\n const { name } = describeCatalog(catalog);\n const selectedEntries =\n events === undefined\n ? undefined\n : consume(catalog, { events: events as readonly (keyof Catalog)[] }).entries;\n return (target) => {\n const existing =\n (Reflect.getOwnMetadata(EVENT_CONSUMER_METADATA_KEY, target) as\n EventConsumerMetadata[] | undefined) ?? [];\n if (existing.some((metadata) => metadata.catalog === catalog)) {\n throw new ConfigurationError(\n `@EventConsumer(${name ?? 'catalog'}) is declared twice on ${target.name}; ` +\n `merge the declarations into one`,\n );\n }\n Reflect.defineMetadata(\n EVENT_CONSUMER_METADATA_KEY,\n [...existing, { catalog, options, selectedEntries }],\n target,\n );\n };\n}\n\n/**\n * Reads the `@EventConsumer` declarations of a class and of its ancestors,\n * ancestors first, each in declaration order. When a class and an ancestor\n * both declare a catalog, the declaration nearest to the class wins.\n */\nexport function readEventConsumerMetadata(target: object): readonly EventConsumerMetadata[] {\n const lineage: object[] = [];\n for (let current = target; current !== Function.prototype;) {\n lineage.unshift(current);\n current = Object.getPrototypeOf(current) as object;\n }\n const byCatalog = new Map<Catalog, EventConsumerMetadata>();\n for (const type of lineage) {\n const own =\n (Reflect.getOwnMetadata(EVENT_CONSUMER_METADATA_KEY, type) as\n EventConsumerMetadata[] | undefined) ?? [];\n for (const metadata of own) {\n byCatalog.set(metadata.catalog, metadata);\n }\n }\n return [...byCatalog.values()];\n}\n","import 'reflect-metadata';\nimport type { EventClass, EventEnvelope, HandlerContext, SubscribeOptions } from '@relaybus/core';\n\n/**\n * Options of {@link Subscribe}: the core {@link SubscribeOptions}, except that\n * `id` is optional and defaults to `ClassName.methodName`.\n */\nexport type SubscribeDecoratorOptions = Omit<SubscribeOptions, 'id'> & {\n /**\n * Stable id of the handler. Deliveries are recorded under it, so renaming it\n * (or the class or method it is derived from) orphans pending deliveries.\n * Default: `${ClassName}.${methodName}`. Required when one method carries\n * several `@Subscribe` decorators.\n */\n readonly id?: string;\n};\n\n/** What one `@Subscribe` decorator recorded on a method. */\nexport interface SubscribeMetadata {\n readonly event: EventClass<unknown> | string;\n readonly options: SubscribeDecoratorOptions;\n}\n\nconst SUBSCRIBE_METADATA_KEY = Symbol.for('relaybus.nestjs.subscribe');\n\ntype HandlerMethod<TPayload> = (\n event: EventEnvelope<TPayload>,\n context: HandlerContext<never>,\n) => unknown;\n\ntype SubscribeDecorator<TPayload> = <TMethod extends HandlerMethod<TPayload>>(\n target: object,\n propertyKey: string | symbol,\n descriptor: TypedPropertyDescriptor<TMethod>,\n) => void;\n\n/**\n * Subscribes a provider method to an event class or type. The method is\n * registered with `bus.subscribe` when the module initialises, with `this`\n * bound to the provider instance, and receives `(envelope, context)`.\n *\n * The provider must be a singleton (default scope) and belong to any module of\n * the application. The decorator name differs from `@nestjs/event-emitter`'s\n * `@OnEvent` so both can be used in one application.\n *\n * ```ts\n * @Injectable()\n * export class ShippingHandlers {\n * @Subscribe(OrderPlaced, { transactional: true })\n * async onOrderPlaced(event: EventEnvelope<{ orderId: string }>, context: HandlerContext) {}\n * }\n * ```\n */\nexport function Subscribe<TPayload>(\n event: EventClass<TPayload>,\n options?: SubscribeDecoratorOptions,\n): SubscribeDecorator<TPayload>;\nexport function Subscribe(\n eventType: string,\n options?: SubscribeDecoratorOptions,\n): SubscribeDecorator<never>;\nexport function Subscribe(\n event: EventClass<unknown> | string,\n options: SubscribeDecoratorOptions = {},\n): (target: object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => void {\n return (target, propertyKey) => {\n // Keyed by (prototype, property) rather than stored on the method function, so a\n // decorator that later replaces the method does not drop the subscription.\n const existing =\n (Reflect.getOwnMetadata(SUBSCRIBE_METADATA_KEY, target, propertyKey) as\n SubscribeMetadata[] | undefined) ?? [];\n Reflect.defineMetadata(\n SUBSCRIBE_METADATA_KEY,\n [...existing, { event, options }],\n target,\n propertyKey,\n );\n };\n}\n\n/**\n * Reads the `@Subscribe` declarations of a method, in declaration order. The\n * prototype chain is searched, so a subclass inherits the declarations of the\n * nearest ancestor that declares them.\n */\nexport function readSubscribeMetadata(\n prototype: object,\n propertyKey: string | symbol,\n): readonly SubscribeMetadata[] {\n return (\n (Reflect.getMetadata(SUBSCRIBE_METADATA_KEY, prototype, propertyKey) as\n SubscribeMetadata[] | undefined) ?? []\n );\n}\n","import { Inject, Injectable, type OnModuleInit } from '@nestjs/common';\nimport { DiscoveryService, MetadataScanner } from '@nestjs/core';\nimport type { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper.js';\nimport {\n ConfigurationError,\n RelayBus,\n describeCatalog,\n type CatalogEntry,\n type EventHandler,\n} from '@relaybus/core';\nimport { readEventConsumerMetadata } from './event-consumer.decorator.js';\nimport { readSubscribeMetadata, type SubscribeMetadata } from './subscribe.decorator.js';\n\ninterface SubscribedMethod {\n readonly methodName: string;\n readonly declarations: readonly SubscribeMetadata[];\n}\n\n/**\n * Finds every `@Subscribe` method and every `@EventConsumer` class among the\n * singleton providers of the application and registers them on the bus before\n * the bus starts. Providers that are request-scoped or transient, directly or\n * through a dependency, and use either decorator fail the boot. A request-scoped provider whose\n * token is neither a class nor an instance carrying the decorated prototype\n * (for example a string-token factory) cannot be inspected and is skipped.\n */\n@Injectable()\nexport class RelayBusHandlerExplorer implements OnModuleInit {\n constructor(\n @Inject(DiscoveryService) private readonly discovery: DiscoveryService,\n @Inject(MetadataScanner) private readonly metadataScanner: MetadataScanner,\n @Inject(RelayBus) private readonly bus: RelayBus,\n ) {}\n\n onModuleInit(): void {\n const registeredBy = new Map<string, string>();\n const visited = new Map<object, Set<string>>();\n const consumers = new WeakSet<object>();\n for (const wrapper of this.discovery.getProviders()) {\n if (wrapper.isTransient || !wrapper.isDependencyTreeStatic()) {\n this.assertNoHandlers(wrapper);\n continue;\n }\n const instance = wrapper.instance as unknown;\n if (typeof instance !== 'object' || instance === null) {\n continue;\n }\n const prototype = Object.getPrototypeOf(instance) as object | null;\n if (prototype === null) {\n continue;\n }\n const className = instance.constructor.name;\n for (const { methodName, declarations } of this.subscribedMethods(prototype)) {\n // A `useExisting` alias exposes the same instance under another token.\n const seen = visited.get(instance) ?? new Set<string>();\n visited.set(instance, seen);\n if (seen.has(methodName)) {\n continue;\n }\n seen.add(methodName);\n const method = (instance as Record<string, unknown>)[methodName] as (\n ...args: Parameters<EventHandler>\n ) => unknown;\n const location = `${className}.${methodName}`;\n for (const { event, options } of declarations) {\n const id = options.id ?? location;\n const previous = registeredBy.get(id);\n if (previous !== undefined) {\n throw new ConfigurationError(\n `Handler id '${id}' is used by both ${previous} and ${location}; ` +\n `pass a unique { id } to @Subscribe`,\n );\n }\n registeredBy.set(id, location);\n // Core resolves both classes and type strings; the overloads cannot express the union.\n this.bus.subscribe(\n event as never,\n (envelope, context) => method.call(instance, envelope, context),\n { ...options, id },\n );\n }\n }\n if (!consumers.has(instance)) {\n consumers.add(instance);\n this.registerEventConsumers(instance, className, registeredBy);\n }\n }\n }\n\n private registerEventConsumers(\n instance: object,\n className: string,\n registeredBy: Map<string, string>,\n ): void {\n const lookup = instance as Record<string, unknown>;\n for (const { catalog, options, selectedEntries } of readEventConsumerMetadata(\n instance.constructor,\n )) {\n const { name, entries } = describeCatalog(catalog);\n const label = name ?? 'catalog';\n const handlers = selectedEntries ?? entries.filter((entry) => isMethod(lookup, entry));\n const missing = handlers.filter((entry) => !isMethod(lookup, entry));\n if (missing.length > 0) {\n throw new ConfigurationError(\n `${className} uses @EventConsumer(${label}) but lacks the handler methods of events ` +\n `it consumes: ${missing.map((entry) => entry.handlerName).join(', ')}`,\n );\n }\n if (handlers.length === 0) {\n throw new ConfigurationError(\n `${className} uses @EventConsumer(${label}) but defines none of its handler ` +\n `methods (${entries.map((entry) => entry.handlerName).join(', ')})`,\n );\n }\n for (const entry of handlers) {\n const id = `${className}.${entry.handlerName}`;\n const previous = registeredBy.get(id);\n if (previous !== undefined) {\n throw new ConfigurationError(\n `Handler id '${id}' of @EventConsumer(${label}) is already used by ${previous}; ` +\n `give the @Subscribe a unique { id } or drop it`,\n );\n }\n registeredBy.set(id, `${className}.${entry.handlerName}`);\n const method = lookup[entry.handlerName] as (...args: Parameters<EventHandler>) => unknown;\n this.bus.subscribe(\n entry.eventClass as never,\n (envelope, context) => method.call(instance, envelope, context),\n { ...options, id },\n );\n }\n }\n }\n\n private subscribedMethods(prototype: object): SubscribedMethod[] {\n const methods: SubscribedMethod[] = [];\n for (const methodName of this.metadataScanner.getAllMethodNames(prototype)) {\n const declarations = readSubscribeMetadata(prototype, methodName);\n if (declarations.length > 0) {\n methods.push({ methodName, declarations });\n }\n }\n return methods;\n }\n\n /**\n * Request-scoped and transient wrappers have no usable instance (a factory\n * wrapper has none at all), so the decorated prototype is taken from the\n * provider class, or from the provider token for factories when it is a class.\n */\n private assertNoHandlers(wrapper: InstanceWrapper): void {\n const type = (wrapper.isFactory ? wrapper.token : wrapper.metatype) as unknown;\n if (typeof type === 'function' && readEventConsumerMetadata(type).length > 0) {\n throw new ConfigurationError(\n `${type.name} uses @EventConsumer but its provider is request-scoped or transient ` +\n `(directly or through a dependency); handlers must be singleton providers`,\n );\n }\n const prototype = typeof type === 'function' ? (type.prototype as object) : null;\n const [first] = prototype === null ? [] : this.subscribedMethods(prototype);\n if (first !== undefined) {\n throw new ConfigurationError(\n `${(prototype as { constructor: { name: string } }).constructor.name}.${first.methodName} ` +\n `uses @Subscribe but its provider is request-scoped or transient ` +\n `(directly or through a dependency); handlers must be singleton providers`,\n );\n }\n }\n}\n\nfunction isMethod(instance: Record<string, unknown>, entry: CatalogEntry): boolean {\n return typeof instance[entry.handlerName] === 'function';\n}\n","import { ConfigurableModuleBuilder } from '@nestjs/common';\nimport type { RelayBusOptions } from '@relaybus/core';\n\n/**\n * Options of {@link RelayBusModule}: everything {@link RelayBusOptions} accepts\n * except `logger`, which is always a Nest `Logger` with context `RelayBus`\n * (configure it with `app.useLogger`). Only `store` is required.\n */\nexport type RelayBusModuleOptions<TTransaction = unknown> = Omit<\n RelayBusOptions<TTransaction>,\n 'logger'\n>;\n\n/** Module-level extras accepted next to the options by `forRoot` and `forRootAsync`. */\nexport interface RelayBusModuleExtras {\n /** Make `RelayBus` and `RelayBusHealth` injectable everywhere. Default true. */\n readonly isGlobal?: boolean;\n}\n\n/** Implemented by classes passed as `useClass` / `useExisting` to `forRootAsync`. */\nexport interface RelayBusModuleOptionsFactory {\n create(): Promise<RelayBusModuleOptions> | RelayBusModuleOptions;\n}\n\nexport const {\n ConfigurableModuleClass: RelayBusConfigurableModule,\n MODULE_OPTIONS_TOKEN: RELAYBUS_MODULE_OPTIONS,\n} = new ConfigurableModuleBuilder<RelayBusModuleOptions>()\n .setClassMethodName('forRoot')\n .setExtras<RelayBusModuleExtras>({ isGlobal: true }, (definition, extras) => ({\n ...definition,\n global: extras.isGlobal === true,\n }))\n .build();\n","import { Inject, Injectable } from '@nestjs/common';\nimport { RelayBus, systemClock, type EventStoreStatistics } from '@relaybus/core';\nimport { RELAYBUS_MODULE_OPTIONS, type RelayBusModuleOptions } from './module-options.js';\n\n/** Result of {@link RelayBusHealth.check}. */\nexport interface RelayBusHealthReport {\n /**\n * `down` when the bus is not running, a transport reports itself not ready\n * (dead Kafka consumer, disconnected RabbitMQ) or the store cannot be queried.\n */\n readonly status: 'up' | 'down';\n readonly running: boolean;\n /** `bus.isReady()`: running and every transport ready. */\n readonly ready: boolean;\n /** Number of registered handlers and routes. */\n readonly handlers: number;\n /** Delivery counts; absent when the bus is not running or the store failed. */\n readonly statistics?: EventStoreStatistics;\n /** Milliseconds the oldest due delivery has waited; 0 when nothing is due. */\n readonly lagMilliseconds?: number;\n /** Message of the store error, when the statistics query failed. */\n readonly error?: string;\n}\n\n/**\n * Health probe of the bus without a dependency on `@nestjs/terminus`. Wrap\n * {@link check} in a terminus indicator (see the README). The lag is measured\n * with the `clock` given to the module options (the system clock by default),\n * the same clock the bus uses.\n */\n@Injectable()\nexport class RelayBusHealth {\n constructor(\n @Inject(RelayBus) private readonly bus: RelayBus,\n @Inject(RELAYBUS_MODULE_OPTIONS) private readonly options: RelayBusModuleOptions,\n ) {}\n\n async check(): Promise<RelayBusHealthReport> {\n const running = this.bus.isRunning;\n const ready = this.bus.isReady();\n const handlers = this.bus.handlers().length;\n if (!running) {\n return { status: 'down', running, ready, handlers };\n }\n try {\n const statistics = await this.bus.statistics();\n const clock = this.options.clock ?? systemClock;\n const lagMilliseconds =\n statistics.oldestDueAt === null\n ? 0\n : Math.max(0, clock.now().getTime() - statistics.oldestDueAt.getTime());\n return {\n status: ready ? 'up' : 'down',\n running,\n ready,\n handlers,\n statistics,\n lagMilliseconds,\n };\n } catch (error) {\n return {\n status: 'down',\n running,\n ready,\n handlers,\n error: error instanceof Error ? error.message : String(error),\n };\n }\n }\n}\n","import {\n Inject,\n Injectable,\n type BeforeApplicationShutdown,\n type OnApplicationBootstrap,\n} from '@nestjs/common';\nimport { RelayBus } from '@relaybus/core';\n\n/**\n * Starts the bus once every handler is registered and the application has\n * bootstrapped, and stops it (draining running handlers) on shutdown. A start\n * failure rejects the hook, so the application does not boot.\n */\n@Injectable()\nexport class RelayBusLifecycle implements OnApplicationBootstrap, BeforeApplicationShutdown {\n constructor(@Inject(RelayBus) private readonly bus: RelayBus) {}\n\n async onApplicationBootstrap(): Promise<void> {\n await this.bus.start();\n }\n\n async beforeApplicationShutdown(): Promise<void> {\n await this.bus.stop();\n }\n}\n","import { Logger, Module } from '@nestjs/common';\nimport { DiscoveryModule } from '@nestjs/core';\nimport { RelayBus } from '@relaybus/core';\nimport { RelayBusHandlerExplorer } from './handler-explorer.js';\nimport {\n RELAYBUS_MODULE_OPTIONS,\n RelayBusConfigurableModule,\n type RelayBusModuleOptions,\n} from './module-options.js';\nimport { RelayBusHealth } from './relay-bus-health.js';\nimport { RelayBusLifecycle } from './relay-bus-lifecycle.js';\n\n/**\n * Registers one {@link RelayBus} for the application, discovers `@Subscribe`\n * handlers in every module, starts the bus after bootstrap and stops it on\n * shutdown. Global unless `isGlobal: false`.\n *\n * ```ts\n * RelayBusModule.forRoot({ store: new PostgresEventStore({ pool }), source: 'orders' })\n * ```\n */\n@Module({\n imports: [DiscoveryModule],\n providers: [\n {\n provide: RelayBus,\n inject: [RELAYBUS_MODULE_OPTIONS],\n useFactory: (options: RelayBusModuleOptions) =>\n new RelayBus({ ...options, logger: new Logger('RelayBus') }),\n },\n RelayBusHandlerExplorer,\n RelayBusLifecycle,\n RelayBusHealth,\n ],\n exports: [RelayBus, RelayBusHealth],\n})\nexport class RelayBusModule extends RelayBusConfigurableModule {}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/relay-bus-catalog-consumer.decorator.ts","../src/relay-bus-feature-contract.ts","../src/relay-bus-registry.ts","../src/relay-bus-consumer.decorator.ts","../src/handler-explorer.ts","../src/module-options.ts","../src/relay-bus-health.ts","../src/relay-bus-lifecycle.ts","../src/relay-bus-feature.module.ts","../src/relay-bus-transaction-host.ts","../src/relay-bus.module.ts","../src/relay-bus-transaction.decorator.ts"],"names":["describeCatalog","consume","ConfigurationError","produce","RelayBusHandlerExplorer","Injectable","DiscoveryService","MetadataScanner","RelayBus","ModulesContainer","ConfigurableModuleBuilder","RelayBusHealth","systemClock","Inject","RelayBusLifecycle","RelayBusFeatureModule","Module","RelayBusTransactionHost","TransactionRequiredError","RelayBusModule","DiscoveryModule","Logger"],"mappings":";;;;;;;;;;;;;;;;AAkDA,IAAM,2BAAA,mBAA8B,MAAA,CAAO,GAAA,CAAI,gCAAgC,CAAA;AAoDxE,SAAS,wBACd,OAAA,EACA;AAAA,EACE,MAAA;AAAA,EACA,GAAG;AACL,CAAA,GAEI,EAAC,EACW;AAChB,EAAA,MAAM,EAAE,IAAA,EAAK,GAAIA,oBAAA,CAAgB,OAAO,CAAA;AACxC,EAAA,MAAM,eAAA,GACJ,WAAW,MAAA,GACP,MAAA,GACAC,aAAQ,OAAA,EAAS,EAAE,MAAA,EAA8C,CAAA,CAAE,OAAA;AACzE,EAAA,OAAO,CAAC,MAAA,KAAW;AACjB,IAAA,MAAM,WACH,OAAA,CAAQ,cAAA,CAAe,2BAAA,EAA6B,MAAM,KACP,EAAC;AACvD,IAAA,IAAI,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CAAM,IAAA,EAAM,IAAI,CAAC,CAAA;AAAA,IACzD,CAAA;AACA,IAAA,MAAA,CAAO,eAAe,aAAA,EAAe,MAAA,EAAQ,EAAE,KAAA,EAAO,QAAA,CAAS,MAAM,CAAA;AAErE,IAAA,KAAA,MAAW,GAAA,IAAO,OAAA,CAAQ,kBAAA,CAAmB,QAAQ,CAAA,EAAG;AACtD,MAAA,OAAA,CAAQ,eAAe,GAAA,EAAK,OAAA,CAAQ,eAAe,GAAA,EAAK,QAAQ,GAAG,aAAa,CAAA;AAAA,IAClF;AACA,IAAA,UAAA,CAAW,KAAA,GAAQ,aAAA;AAAA,EACrB,CAAA;AACF","file":"index.cjs","sourcesContent":["import 'reflect-metadata';\nimport {\n ConfigurationError,\n consume,\n describeCatalog,\n type Catalog,\n type CatalogEntry,\n type CatalogEventSelection,\n type EventOf,\n type HandlerContext,\n type SubscribeOptions,\n} from '@relaybus/core';\n\n/**\n * Options of {@link RelayBusCatalogConsumer}: the core {@link SubscribeOptions} applied to\n * every handler of the class, except `id`, which is always\n * `${ClassName}.on${EventName}`, and optionally the events the class consumes.\n */\nexport type RelayBusCatalogConsumerOptions<\n TCatalog extends Catalog = Catalog,\n TName extends keyof TCatalog = keyof TCatalog,\n> = Omit<SubscribeOptions, 'id'> & CatalogEventSelection<TName>;\n\n/** What one `@RelayBusCatalogConsumer` decorator recorded on a class. */\nexport interface RelayBusCatalogConsumerMetadata {\n readonly catalog: Catalog;\n /** Subscribe options applied to every handler of the class. */\n readonly options: Omit<SubscribeOptions, 'id'>;\n /**\n * Entries named by `options.events`, whose methods are all required;\n * undefined when the class consumes whichever handler methods it defines.\n */\n readonly selectedEntries: readonly CatalogEntry[] | undefined;\n}\n\n/**\n * A class whose instances have a handler method for each of the named catalog\n * events. The event parameter is checked strictly; the context is typed\n * `HandlerContext<never>` so a method may declare any transaction type.\n */\nexport type RelayBusCatalogConsumerClass<\n TCatalog extends Catalog,\n TName extends keyof TCatalog,\n> = abstract new (...args: never[]) => {\n readonly [TKey in TName & string as `on${TKey}`]: (\n event: EventOf<TCatalog[TKey]>,\n context: HandlerContext<never>,\n ) => unknown;\n};\n\nconst EVENT_CONSUMER_METADATA_KEY = Symbol.for('relaybus.nestjs.event-consumer');\n\n/**\n * Subscribes a provider class to the events of a catalog: its\n * `on${EventName}` methods are registered when the module initialises, under\n * the stable id `${ClassName}.on${EventName}`, with `this` bound to the\n * provider instance.\n *\n * - Without `events`, every handler method the class defines is registered; a\n * class that defines none fails the boot, which catches misspelled names.\n * `implements HandlersOf<typeof Catalog>` makes the compiler require all of them.\n * - With `events`, exactly the methods of those events are registered (methods\n * of other events are ignored), and a class missing one of them fails to\n * compile and fails the boot. This is how a service consumes its part of a\n * catalog shared between services.\n *\n * `catalogs: [consume(Catalog, { events })]` in the module options makes the\n * application fail to boot if no provider handles a consumed event. Works next\n * to `@RelayBusConsumer` in the same class (give a method that carries both a\n * distinct `@RelayBusConsumer` id). The provider must be a singleton. Declarations\n * are inherited; a subclass that declares the same catalog again replaces the\n * inherited declaration of that catalog, and declaring one catalog twice on\n * the same class throws a {@link ConfigurationError}.\n *\n * ```ts\n * @Injectable()\n * @RelayBusCatalogConsumer(OrderEvents, { events: ['OrderPlaced'], transactional: true })\n * export class BillingHandlers {\n * onOrderPlaced(event: EventOf<typeof OrderPlaced>) {}\n * }\n * ```\n */\nexport function RelayBusCatalogConsumer<TCatalog extends Catalog>(\n catalog: TCatalog,\n options?: Omit<SubscribeOptions, 'id'> & { readonly events?: undefined },\n): ClassDecorator;\nexport function RelayBusCatalogConsumer<\n TCatalog extends Catalog,\n const TName extends keyof TCatalog,\n>(\n catalog: TCatalog,\n options: Omit<SubscribeOptions, 'id'> & { readonly events: readonly TName[] },\n): (target: RelayBusCatalogConsumerClass<TCatalog, TName>) => void;\n/**\n * With options whose `events` are not statically known (a variable typed\n * {@link RelayBusCatalogConsumerOptions}), the selection is checked when the module\n * initialises instead of at compile time.\n */\nexport function RelayBusCatalogConsumer<TCatalog extends Catalog>(\n catalog: TCatalog,\n options: RelayBusCatalogConsumerOptions<TCatalog>,\n): ClassDecorator;\nexport function RelayBusCatalogConsumer(\n catalog: Catalog,\n {\n events,\n ...options\n }: Omit<SubscribeOptions, 'id'> & {\n readonly events?: readonly PropertyKey[] | undefined;\n } = {},\n): ClassDecorator {\n const { name } = describeCatalog(catalog);\n const selectedEntries =\n events === undefined\n ? undefined\n : consume(catalog, { events: events as readonly (keyof Catalog)[] }).entries;\n return (target) => {\n const existing =\n (Reflect.getOwnMetadata(EVENT_CONSUMER_METADATA_KEY, target) as\n RelayBusCatalogConsumerMetadata[] | undefined) ?? [];\n if (existing.some((metadata) => metadata.catalog === catalog)) {\n throw new ConfigurationError(\n `@RelayBusCatalogConsumer(${name ?? 'catalog'}) is declared twice on ${target.name}; ` +\n `merge the declarations into one`,\n );\n }\n Reflect.defineMetadata(\n EVENT_CONSUMER_METADATA_KEY,\n [...existing, { catalog, options, selectedEntries }],\n target,\n );\n };\n}\n\n/**\n * @deprecated Renamed to {@link RelayBusCatalogConsumer}, which behaves identically; this alias is\n * removed in 1.0.0.\n */\nexport const EventConsumer: typeof RelayBusCatalogConsumer = RelayBusCatalogConsumer;\n\n/** @deprecated Renamed to {@link RelayBusCatalogConsumerOptions}; this alias is removed in 1.0.0. */\nexport type EventConsumerOptions<\n TCatalog extends Catalog = Catalog,\n TName extends keyof TCatalog = keyof TCatalog,\n> = RelayBusCatalogConsumerOptions<TCatalog, TName>;\n\n/** @deprecated Renamed to {@link RelayBusCatalogConsumerMetadata}; this alias is removed in 1.0.0. */\nexport type EventConsumerMetadata = RelayBusCatalogConsumerMetadata;\n\n/** @deprecated Renamed to {@link RelayBusCatalogConsumerClass}; this alias is removed in 1.0.0. */\nexport type EventConsumerClass<\n TCatalog extends Catalog,\n TName extends keyof TCatalog,\n> = RelayBusCatalogConsumerClass<TCatalog, TName>;\n\n/**\n * Reads the `@RelayBusCatalogConsumer` declarations of a class and of its ancestors,\n * ancestors first, each in declaration order. When a class and an ancestor\n * both declare a catalog, the declaration nearest to the class wins.\n */\nexport function readCatalogConsumerMetadata(\n target: object,\n): readonly RelayBusCatalogConsumerMetadata[] {\n const lineage: object[] = [];\n for (let current = target; current !== Function.prototype;) {\n lineage.unshift(current);\n current = Object.getPrototypeOf(current) as object;\n }\n const byCatalog = new Map<Catalog, RelayBusCatalogConsumerMetadata>();\n for (const type of lineage) {\n const own =\n (Reflect.getOwnMetadata(EVENT_CONSUMER_METADATA_KEY, type) as\n RelayBusCatalogConsumerMetadata[] | undefined) ?? [];\n for (const metadata of own) {\n byCatalog.set(metadata.catalog, metadata);\n }\n }\n return [...byCatalog.values()];\n}\n","import {\n ConfigurationError,\n consume,\n describeCatalog,\n produce,\n type Catalog,\n type CatalogDeclaration,\n type CatalogRole,\n} from '@relaybus/core';\n\n/**\n * What one feature module consumes and produces, given to `RelayBusModule.forFeature`. Each item is\n * a whole catalog or a `consume(...)` / `produce(...)` declaration of some of its events.\n */\nexport interface RelayBusFeatureOptions {\n /** Events the importing module handles: each needs a `@RelayBusConsumer` method (or a catalog consumer) among its providers. */\n readonly consumes?: readonly (Catalog | CatalogDeclaration)[];\n /** Events the importing module publishes for other services: each needs a route to a transport. */\n readonly produces?: readonly (Catalog | CatalogDeclaration)[];\n}\n\n/** One event of a feature contract, named for error messages. */\nexport type ContractEvent = {\n /** `Catalog.EventName`. */\n readonly label: string;\n readonly type: string;\n};\n\n/**\n * The contract of the module that imports `RelayBusModule.forFeature(...)`, checked when the\n * application initialises.\n */\nexport class RelayBusFeatureContract {\n readonly consumes: readonly ContractEvent[];\n readonly produces: readonly ContractEvent[];\n\n /** @throws ConfigurationError for a `produce(...)` in `consumes`, a `consume(...)` in `produces`, or something that is not a catalog. */\n constructor(options: RelayBusFeatureOptions) {\n this.consumes = contractEvents(options.consumes ?? [], 'consume');\n this.produces = contractEvents(options.produces ?? [], 'produce');\n }\n}\n\nfunction contractEvents(\n items: readonly (Catalog | CatalogDeclaration)[],\n role: CatalogRole,\n): ContractEvent[] {\n return items.flatMap((item) => {\n const declaration = isDeclaration(item)\n ? item\n : role === 'consume'\n ? consume(item)\n : produce(item);\n const name = describeCatalog(declaration.catalog).name ?? 'catalog';\n if (declaration.role !== role) {\n throw new ConfigurationError(\n `RelayBusModule.forFeature ${role}s takes catalogs and ${role}(...) declarations, ` +\n `received ${declaration.role}(${name})`,\n );\n }\n return declaration.entries.map((entry) => ({\n label: `${name}.${entry.name}`,\n type: entry.eventClass.type,\n }));\n });\n}\n\nfunction isDeclaration(item: Catalog | CatalogDeclaration): item is CatalogDeclaration {\n return typeof item['role'] === 'string' && Array.isArray(item['entries']);\n}\n","import { ConfigurationError, type RelayBus } from '@relaybus/core';\n\n/**\n * Buses of the applications that are running in this process, so `@RelayBusTransaction()` finds\n * its bus without the class injecting it. A module registers its bus when it initialises and\n * removes it after the application shut down.\n */\nconst runningBuses = new Set<RelayBus>();\n\n/** Provider instances of a running application with the bus of that application. */\nconst busOfInstance = new WeakMap<object, RelayBus>();\n\nexport function registerBus(bus: RelayBus): void {\n runningBuses.add(bus);\n}\n\nexport function unregisterBus(bus: RelayBus): void {\n runningBuses.delete(bus);\n}\n\n/** Ties a provider instance to the bus of its application, which wins when several applications run. */\nexport function bindInstance(instance: object, bus: RelayBus): void {\n busOfInstance.set(instance, bus);\n}\n\n/**\n * The bus a `@RelayBusTransaction()` method of `instance` uses: the bus of the instance's\n * application, else the only running bus.\n *\n * @throws ConfigurationError when no RelayBusModule runs, its application was closed, or several\n * applications run and `instance` is not a provider of any of them.\n */\nexport function resolveBus(instance: unknown, method: string): RelayBus {\n const bound =\n typeof instance === 'object' && instance !== null ? busOfInstance.get(instance) : undefined;\n if (bound !== undefined) {\n if (!runningBuses.has(bound)) {\n throw new ConfigurationError(\n `@RelayBusTransaction() ${method} was called after its application shut down`,\n );\n }\n return bound;\n }\n const [only, ...others] = runningBuses;\n if (only === undefined) {\n throw new ConfigurationError(\n `@RelayBusTransaction() ${method} found no running RelayBusModule: import RelayBusModule.forRoot(...) ` +\n `and call the method after the application initialised (app.init() or app.listen())`,\n );\n }\n if (others.length > 0) {\n throw new ConfigurationError(\n `@RelayBusTransaction() ${method} cannot tell which of ${runningBuses.size} running applications ` +\n `it belongs to; call it on a singleton provider of one of them`,\n );\n }\n return only;\n}\n","import 'reflect-metadata';\nimport type { EventClass, EventEnvelope, HandlerContext, SubscribeOptions } from '@relaybus/core';\n\n/**\n * Options of {@link RelayBusConsumer}: the core {@link SubscribeOptions}, except that\n * `id` is optional and defaults to `ClassName.methodName`.\n */\nexport type RelayBusConsumerOptions = Omit<SubscribeOptions, 'id'> & {\n /**\n * Stable id of the handler. Deliveries are recorded under it, so renaming it\n * (or the class or method it is derived from) orphans pending deliveries.\n * Default: `${ClassName}.${methodName}`. Required when one method carries\n * several `@RelayBusConsumer` decorators.\n */\n readonly id?: string;\n};\n\n/** What one `@RelayBusConsumer` decorator recorded on a method. */\nexport interface RelayBusConsumerMetadata {\n readonly event: EventClass<unknown> | string;\n readonly options: RelayBusConsumerOptions;\n}\n\n/** @deprecated Renamed to {@link RelayBusConsumerOptions}; this alias is removed in 1.0.0. */\nexport type SubscribeDecoratorOptions = RelayBusConsumerOptions;\n\n/** @deprecated Renamed to {@link RelayBusConsumerMetadata}; this alias is removed in 1.0.0. */\nexport type SubscribeMetadata = RelayBusConsumerMetadata;\n\nconst SUBSCRIBE_METADATA_KEY = Symbol.for('relaybus.nestjs.subscribe');\n\ntype HandlerMethod<TPayload> = (\n event: EventEnvelope<TPayload>,\n context: HandlerContext<never>,\n) => unknown;\n\ntype HandlerDecorator<TPayload> = <TMethod extends HandlerMethod<TPayload>>(\n target: object,\n propertyKey: string | symbol,\n descriptor: TypedPropertyDescriptor<TMethod>,\n) => void;\n\n/**\n * Subscribes a provider method to an event class or type. The method is\n * registered with `bus.subscribe` when the module initialises, with `this`\n * bound to the provider instance, and receives `(envelope, context)`.\n *\n * The provider must be a singleton (default scope) and belong to any module of\n * the application. The decorator name differs from `@nestjs/event-emitter`'s\n * `@OnEvent` so both can be used in one application.\n *\n * ```ts\n * @Injectable()\n * export class ShippingHandlers {\n * @RelayBusConsumer(OrderPlaced, { transactional: true })\n * async onOrderPlaced(event: EventEnvelope<{ orderId: string }>, context: HandlerContext) {}\n * }\n * ```\n */\nexport function RelayBusConsumer<TPayload>(\n event: EventClass<TPayload>,\n options?: RelayBusConsumerOptions,\n): HandlerDecorator<TPayload>;\nexport function RelayBusConsumer(\n eventType: string,\n options?: RelayBusConsumerOptions,\n): HandlerDecorator<never>;\nexport function RelayBusConsumer(\n event: EventClass<unknown> | string,\n options: RelayBusConsumerOptions = {},\n): (target: object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => void {\n return (target, propertyKey) => {\n // Keyed by (prototype, property) rather than stored on the method function, so a\n // decorator that later replaces the method does not drop the subscription.\n const existing =\n (Reflect.getOwnMetadata(SUBSCRIBE_METADATA_KEY, target, propertyKey) as\n RelayBusConsumerMetadata[] | undefined) ?? [];\n Reflect.defineMetadata(\n SUBSCRIBE_METADATA_KEY,\n [...existing, { event, options }],\n target,\n propertyKey,\n );\n };\n}\n\n/**\n * @deprecated Renamed to {@link RelayBusConsumer}, which behaves identically; this alias is\n * removed in 1.0.0.\n */\nexport const Subscribe: typeof RelayBusConsumer = RelayBusConsumer;\n\n/**\n * Reads the `@RelayBusConsumer` declarations of a method, in declaration order. The\n * prototype chain is searched, so a subclass inherits the declarations of the\n * nearest ancestor that declares them.\n */\nexport function readConsumerMetadata(\n prototype: object,\n propertyKey: string | symbol,\n): readonly RelayBusConsumerMetadata[] {\n return (\n (Reflect.getMetadata(SUBSCRIBE_METADATA_KEY, prototype, propertyKey) as\n RelayBusConsumerMetadata[] | undefined) ?? []\n );\n}\n","import { Inject, Injectable, type OnModuleInit } from '@nestjs/common';\nimport { DiscoveryService, MetadataScanner, ModulesContainer } from '@nestjs/core';\nimport type { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper.js';\nimport type { Module } from '@nestjs/core/injector/module.js';\nimport {\n ConfigurationError,\n RelayBus,\n describeCatalog,\n type CatalogEntry,\n type EventHandler,\n} from '@relaybus/core';\nimport { readCatalogConsumerMetadata } from './relay-bus-catalog-consumer.decorator.js';\nimport { RelayBusFeatureContract } from './relay-bus-feature-contract.js';\nimport { bindInstance } from './relay-bus-registry.js';\nimport {\n readConsumerMetadata,\n type RelayBusConsumerMetadata,\n} from './relay-bus-consumer.decorator.js';\n\n/** What one discovery pass has registered so far. */\ntype Discovery = {\n /** Where each handler id was registered, to report duplicates. */\n readonly registeredBy: Map<string, string>;\n /** Methods already registered per instance: a `useExisting` alias shows an instance twice. */\n readonly visited: Map<object, Set<string>>;\n readonly consumers: WeakSet<object>;\n /** Event types the providers of each module consume, for the `forFeature` contracts. */\n readonly consumedByModule: Map<Module | undefined, Set<string>>;\n};\n\ninterface SubscribedMethod {\n readonly methodName: string;\n readonly declarations: readonly RelayBusConsumerMetadata[];\n}\n\n/**\n * Finds every `@RelayBusConsumer` method and every `@RelayBusCatalogConsumer` class among the\n * singleton providers of the application and registers them on the bus before\n * the bus starts. Providers that are request-scoped or transient, directly or\n * through a dependency, and use either decorator fail the boot. A request-scoped provider whose\n * token is neither a class nor an instance carrying the decorated prototype\n * (for example a string-token factory) cannot be inspected and is skipped.\n */\n@Injectable()\nexport class RelayBusHandlerExplorer implements OnModuleInit {\n constructor(\n @Inject(DiscoveryService) private readonly discovery: DiscoveryService,\n @Inject(MetadataScanner) private readonly metadataScanner: MetadataScanner,\n @Inject(RelayBus) private readonly bus: RelayBus,\n @Inject(ModulesContainer) private readonly modules: ModulesContainer,\n ) {}\n\n onModuleInit(): void {\n const discovery: Discovery = {\n registeredBy: new Map<string, string>(),\n visited: new Map<object, Set<string>>(),\n consumers: new WeakSet<object>(),\n consumedByModule: new Map<Module | undefined, Set<string>>(),\n };\n for (const wrapper of this.discovery.getProviders()) {\n this.registerProvider(wrapper, discovery);\n }\n this.assertModuleContracts(discovery.consumedByModule);\n }\n\n /** Checks the `RelayBusModule.forFeature` contract of every module that imports one. */\n private assertModuleContracts(consumedByModule: Map<Module | undefined, Set<string>>): void {\n const routed = new Set(\n this.bus\n .handlers()\n .filter((handler) => handler.forwardsToTransport)\n .map((handler) => handler.eventType),\n );\n const violations: string[] = [];\n for (const wrapper of this.discovery.getProviders()) {\n const contract = wrapper.instance as unknown;\n if (!(contract instanceof RelayBusFeatureContract)) {\n continue;\n }\n for (const module of this.importersOf(wrapper.host)) {\n // Every module has a set: Nest registers the module class as one of its providers.\n const consumed = consumedByModule.get(module)!;\n for (const event of contract.consumes.filter(({ type }) => !consumed.has(type))) {\n violations.push(`${module.name}: ${event.label} (${event.type}) has no consumer`);\n }\n for (const event of contract.produces.filter(({ type }) => !routed.has(type))) {\n violations.push(\n `${module.name}: ${event.label} (${event.type}) has no route to a transport`,\n );\n }\n }\n }\n if (violations.length > 0) {\n throw new ConfigurationError(\n `[RelayBusHandlerExplorer](assertModuleContracts) ${violations.join('; ')}`,\n );\n }\n }\n\n private importersOf(contractModule: Module | undefined): Module[] {\n // A provider always has a host module; `has(undefined)` is false for the type's sake.\n return [...this.modules.values()].filter((module) => module.imports.has(contractModule!));\n }\n\n /** Records the event types the provider of `wrapper` consumes under the provider's module. */\n private recordConsumedTypes(\n wrapper: InstanceWrapper,\n { instance, discovery }: { readonly instance: object; readonly discovery: Discovery },\n ): void {\n const types = discovery.consumedByModule.get(wrapper.host) ?? new Set<string>();\n discovery.consumedByModule.set(wrapper.host, types);\n const lookup = instance as Record<string, unknown>;\n for (const { declarations } of this.subscribedMethods(\n Object.getPrototypeOf(instance) as object,\n )) {\n for (const { event } of declarations) {\n types.add(typeof event === 'string' ? event : event.type);\n }\n }\n for (const { catalog, selectedEntries } of readCatalogConsumerMetadata(instance.constructor)) {\n const entries =\n selectedEntries ??\n describeCatalog(catalog).entries.filter((entry) => isMethod(lookup, entry));\n for (const entry of entries) {\n types.add(entry.eventClass.type);\n }\n }\n }\n\n private registerProvider(wrapper: InstanceWrapper, discovery: Discovery): void {\n if (wrapper.isTransient || !wrapper.isDependencyTreeStatic()) {\n this.assertNoHandlers(wrapper);\n return;\n }\n const instance = wrapper.instance as unknown;\n if (typeof instance !== 'object' || instance === null) {\n return;\n }\n const prototype = Object.getPrototypeOf(instance) as object | null;\n if (prototype === null) {\n return;\n }\n bindInstance(instance, this.bus);\n this.recordConsumedTypes(wrapper, { instance, discovery });\n const className = instance.constructor.name;\n for (const subscribed of this.subscribedMethods(prototype)) {\n this.registerSubscribedMethod(instance, { subscribedMethod: subscribed, discovery });\n }\n if (!discovery.consumers.has(instance)) {\n discovery.consumers.add(instance);\n this.registerEventConsumers(instance, { className, registeredBy: discovery.registeredBy });\n }\n }\n\n private registerSubscribedMethod(\n instance: object,\n {\n subscribedMethod: { methodName, declarations },\n discovery: { registeredBy, visited },\n }: { readonly subscribedMethod: SubscribedMethod; readonly discovery: Discovery },\n ): void {\n // A `useExisting` alias exposes the same instance under another token.\n const seen = visited.get(instance) ?? new Set<string>();\n visited.set(instance, seen);\n if (seen.has(methodName)) {\n return;\n }\n seen.add(methodName);\n const method = (instance as Record<string, unknown>)[methodName] as (\n ...args: Parameters<EventHandler>\n ) => unknown;\n const location = `${instance.constructor.name}.${methodName}`;\n for (const { event, options } of declarations) {\n const id = options.id ?? location;\n const previous = registeredBy.get(id);\n if (previous !== undefined) {\n throw new ConfigurationError(\n `Handler id '${id}' is used by both ${previous} and ${location}; ` +\n `pass a unique { id } to @RelayBusConsumer`,\n );\n }\n registeredBy.set(id, location);\n // Core resolves both classes and type strings; the overloads cannot express the union.\n this.bus.subscribe(\n event as never,\n (envelope, context) => method.call(instance, envelope, context),\n { ...options, id },\n );\n }\n }\n\n private registerEventConsumers(\n instance: object,\n {\n className,\n registeredBy,\n }: { readonly className: string; readonly registeredBy: Map<string, string> },\n ): void {\n const lookup = instance as Record<string, unknown>;\n for (const { catalog, options, selectedEntries } of readCatalogConsumerMetadata(\n instance.constructor,\n )) {\n const { name, entries } = describeCatalog(catalog);\n const label = name ?? 'catalog';\n const handlers = this.catalogHandlers(lookup, {\n className,\n label,\n entries,\n selected: selectedEntries,\n });\n for (const entry of handlers) {\n const id = `${className}.${entry.handlerName}`;\n const previous = registeredBy.get(id);\n if (previous !== undefined) {\n throw new ConfigurationError(\n `Handler id '${id}' of @RelayBusCatalogConsumer(${label}) is already used by ${previous}; ` +\n `give the @RelayBusConsumer a unique { id } or drop it`,\n );\n }\n registeredBy.set(id, `${className}.${entry.handlerName}`);\n const method = lookup[entry.handlerName] as (...args: Parameters<EventHandler>) => unknown;\n this.bus.subscribe(\n entry.eventClass as never,\n (envelope, context) => method.call(instance, envelope, context),\n { ...options, id },\n );\n }\n }\n }\n\n /** The catalog entries `lookup` handles: the selected ones, else every entry it has a method for. */\n private catalogHandlers(\n lookup: Record<string, unknown>,\n {\n className,\n label,\n entries,\n selected,\n }: {\n readonly className: string;\n readonly label: string;\n readonly entries: readonly CatalogEntry[];\n readonly selected: readonly CatalogEntry[] | undefined;\n },\n ): readonly CatalogEntry[] {\n const handlers = selected ?? entries.filter((entry) => isMethod(lookup, entry));\n const missing = handlers.filter((entry) => !isMethod(lookup, entry));\n if (missing.length > 0) {\n throw new ConfigurationError(\n `${className} uses @RelayBusCatalogConsumer(${label}) but lacks the handler methods of events ` +\n `it consumes: ${missing.map((entry) => entry.handlerName).join(', ')}`,\n );\n }\n if (handlers.length === 0) {\n throw new ConfigurationError(\n `${className} uses @RelayBusCatalogConsumer(${label}) but defines none of its handler ` +\n `methods (${entries.map((entry) => entry.handlerName).join(', ')})`,\n );\n }\n return handlers;\n }\n\n private subscribedMethods(prototype: object): SubscribedMethod[] {\n const methods: SubscribedMethod[] = [];\n for (const methodName of this.metadataScanner.getAllMethodNames(prototype)) {\n const declarations = readConsumerMetadata(prototype, methodName);\n if (declarations.length > 0) {\n methods.push({ methodName, declarations });\n }\n }\n return methods;\n }\n\n /**\n * Request-scoped and transient wrappers have no usable instance (a factory\n * wrapper has none at all), so the decorated prototype is taken from the\n * provider class, or from the provider token for factories when it is a class.\n */\n private assertNoHandlers(wrapper: InstanceWrapper): void {\n const type = (wrapper.isFactory ? wrapper.token : wrapper.metatype) as unknown;\n if (typeof type === 'function' && readCatalogConsumerMetadata(type).length > 0) {\n throw new ConfigurationError(\n `${type.name} uses @RelayBusCatalogConsumer but its provider is request-scoped or transient ` +\n `(directly or through a dependency); handlers must be singleton providers`,\n );\n }\n const prototype = typeof type === 'function' ? (type.prototype as object) : null;\n const [first] = prototype === null ? [] : this.subscribedMethods(prototype);\n if (first !== undefined) {\n throw new ConfigurationError(\n `${(prototype as { constructor: { name: string } }).constructor.name}.${first.methodName} ` +\n `uses @RelayBusConsumer but its provider is request-scoped or transient ` +\n `(directly or through a dependency); handlers must be singleton providers`,\n );\n }\n }\n}\n\nfunction isMethod(instance: Record<string, unknown>, entry: CatalogEntry): boolean {\n return typeof instance[entry.handlerName] === 'function';\n}\n","import { ConfigurableModuleBuilder } from '@nestjs/common';\nimport type { RelayBusOptions } from '@relaybus/core';\n\n/**\n * Options of {@link RelayBusModule}: everything {@link RelayBusOptions} accepts\n * except `logger`, which is always a Nest `Logger` with context `RelayBus`\n * (configure it with `app.useLogger`). Only `store` is required.\n */\nexport type RelayBusModuleOptions<TTransaction = unknown> = Omit<\n RelayBusOptions<TTransaction>,\n 'logger'\n>;\n\n/** Module-level extras accepted next to the options by `forRoot` and `forRootAsync`. */\nexport interface RelayBusModuleExtras {\n /** Make `RelayBus` and `RelayBusHealth` injectable everywhere. Default true. */\n readonly isGlobal?: boolean;\n}\n\n/** Implemented by classes passed as `useClass` / `useExisting` to `forRootAsync`. */\nexport interface RelayBusModuleOptionsFactory {\n create(): Promise<RelayBusModuleOptions> | RelayBusModuleOptions;\n}\n\nexport const {\n ConfigurableModuleClass: RelayBusConfigurableModule,\n MODULE_OPTIONS_TOKEN: RELAYBUS_MODULE_OPTIONS,\n} = new ConfigurableModuleBuilder<RelayBusModuleOptions>()\n .setClassMethodName('forRoot')\n .setExtras<RelayBusModuleExtras>({ isGlobal: true }, (definition, extras) => ({\n ...definition,\n global: extras.isGlobal === true,\n }))\n .build();\n","import { Inject, Injectable } from '@nestjs/common';\nimport { RelayBus, systemClock, type EventStoreStatistics } from '@relaybus/core';\nimport { RELAYBUS_MODULE_OPTIONS, type RelayBusModuleOptions } from './module-options.js';\n\n/** Result of {@link RelayBusHealth.check}. */\nexport interface RelayBusHealthReport {\n /**\n * `down` when the bus is not running, a transport reports itself not ready\n * (dead Kafka consumer, disconnected RabbitMQ) or the store cannot be queried.\n */\n readonly status: 'up' | 'down';\n readonly running: boolean;\n /** `bus.isReady()`: running and every transport ready. */\n readonly ready: boolean;\n /** Number of registered handlers and routes. */\n readonly handlers: number;\n /** Delivery counts; absent when the bus is not running or the store failed. */\n readonly statistics?: EventStoreStatistics;\n /** Milliseconds the oldest due delivery has waited; 0 when nothing is due. */\n readonly lagMilliseconds?: number;\n /** Message of the store error, when the statistics query failed. */\n readonly error?: string;\n}\n\n/**\n * Health probe of the bus without a dependency on `@nestjs/terminus`. Wrap\n * {@link check} in a terminus indicator (see the README). The lag is measured\n * with the `clock` given to the module options (the system clock by default),\n * the same clock the bus uses.\n */\n@Injectable()\nexport class RelayBusHealth {\n constructor(\n @Inject(RelayBus) private readonly bus: RelayBus,\n @Inject(RELAYBUS_MODULE_OPTIONS) private readonly options: RelayBusModuleOptions,\n ) {}\n\n async check(): Promise<RelayBusHealthReport> {\n const running = this.bus.isRunning;\n const ready = this.bus.isReady();\n const handlers = this.bus.handlers().length;\n if (!running) {\n return { status: 'down', running, ready, handlers };\n }\n try {\n const statistics = await this.bus.statistics();\n const clock = this.options.clock ?? systemClock;\n const lagMilliseconds =\n statistics.oldestDueAt === null\n ? 0\n : Math.max(0, clock.now().getTime() - statistics.oldestDueAt.getTime());\n return {\n status: ready ? 'up' : 'down',\n running,\n ready,\n handlers,\n statistics,\n lagMilliseconds,\n };\n } catch (error) {\n return {\n status: 'down',\n running,\n ready,\n handlers,\n error: error instanceof Error ? error.message : String(error),\n };\n }\n }\n}\n","import {\n Inject,\n Injectable,\n type BeforeApplicationShutdown,\n type OnApplicationBootstrap,\n type OnApplicationShutdown,\n type OnModuleInit,\n} from '@nestjs/common';\nimport { RelayBus } from '@relaybus/core';\nimport { registerBus, unregisterBus } from './relay-bus-registry.js';\n\n/**\n * Starts the bus once every handler is registered and the application has\n * bootstrapped, and stops it (draining running handlers, within `dispatcher.shutdownTimeout`) on\n * shutdown: `bus.stop()` resolves at that deadline at the latest, so a hung query or broker cannot\n * hold `app.close()` until the platform kills the process. A start\n * failure rejects the hook, so the application does not boot. `@RelayBusTransaction()`\n * methods find the bus from module initialisation until the application has shut down.\n */\n@Injectable()\nexport class RelayBusLifecycle\n implements OnModuleInit, OnApplicationBootstrap, BeforeApplicationShutdown, OnApplicationShutdown\n{\n constructor(@Inject(RelayBus) private readonly bus: RelayBus) {}\n\n onModuleInit(): void {\n registerBus(this.bus);\n }\n\n async onApplicationBootstrap(): Promise<void> {\n await this.bus.start();\n }\n\n async beforeApplicationShutdown(): Promise<void> {\n await this.bus.stop();\n }\n\n /** After the bus stopped, so handlers still draining at shutdown can open transactions. */\n onApplicationShutdown(): void {\n unregisterBus(this.bus);\n }\n}\n","import { Module } from '@nestjs/common';\n\n/**\n * Carries the contract of `RelayBusModule.forFeature(...)` into the module that imports it. The\n * contract is checked against that module's providers when the application initialises.\n */\n@Module({})\nexport class RelayBusFeatureModule {}\n","import { Inject, Injectable } from '@nestjs/common';\nimport { RelayBus, TransactionRequiredError } from '@relaybus/core';\n\n/**\n * Hands repositories the transaction of the enclosing `@RelayBusTransaction()` method (or\n * `bus.transaction`, transactional handler, `transactionResolver`), typed as the store's\n * transaction handle: `PoolClient` for `pg`, a Kysely `Transaction`, a TypeORM `EntityManager`,\n * a Prisma transaction client, a MongoDB `ClientSession`.\n *\n * ```ts\n * @Injectable()\n * export class OrderRepository {\n * constructor(private readonly transactions: RelayBusTransactionHost<PoolClient>) {}\n *\n * async insert(orderId: string): Promise<void> {\n * await this.transactions.current().query('INSERT INTO orders (id) VALUES ($1)', [orderId]);\n * }\n * }\n * ```\n */\n@Injectable()\nexport class RelayBusTransactionHost<TTransaction = unknown> {\n constructor(@Inject(RelayBus) private readonly bus: RelayBus<TTransaction>) {}\n\n /**\n * The active transaction.\n *\n * @throws TransactionRequiredError when the caller runs outside every transaction.\n */\n current(): TTransaction {\n const transaction = this.bus.currentTransaction();\n if (transaction === undefined) {\n throw new TransactionRequiredError(\n 'No relaybus transaction is active: call the repository from a @RelayBusTransaction() method or inside bus.transaction()',\n );\n }\n return transaction;\n }\n\n /** The active transaction, or undefined outside every transaction. */\n find(): TTransaction | undefined {\n return this.bus.currentTransaction();\n }\n}\n","import { Logger, Module, type DynamicModule } from '@nestjs/common';\nimport { DiscoveryModule } from '@nestjs/core';\nimport { RelayBus } from '@relaybus/core';\nimport { RelayBusHandlerExplorer } from './handler-explorer.js';\nimport {\n RELAYBUS_MODULE_OPTIONS,\n RelayBusConfigurableModule,\n type RelayBusModuleOptions,\n} from './module-options.js';\nimport {\n RelayBusFeatureContract,\n type RelayBusFeatureOptions,\n} from './relay-bus-feature-contract.js';\nimport { RelayBusFeatureModule } from './relay-bus-feature.module.js';\nimport { RelayBusHealth } from './relay-bus-health.js';\nimport { RelayBusLifecycle } from './relay-bus-lifecycle.js';\nimport { RelayBusTransactionHost } from './relay-bus-transaction-host.js';\n\n/**\n * Registers one {@link RelayBus} for the application, discovers `@RelayBusConsumer` and `@RelayBusCatalogConsumer`\n * handlers in every module, runs `@RelayBusTransaction()` methods on the bus, starts the bus after bootstrap and stops it on\n * shutdown. Global unless `isGlobal: false`.\n *\n * ```ts\n * RelayBusModule.forRoot({ store: new PostgresEventStore({ pool }), source: 'orders' })\n * ```\n */\n@Module({\n imports: [DiscoveryModule],\n providers: [\n {\n provide: RelayBus,\n inject: [RELAYBUS_MODULE_OPTIONS],\n useFactory: (options: RelayBusModuleOptions) =>\n new RelayBus({ ...options, logger: new Logger('RelayBus') }),\n },\n RelayBusHandlerExplorer,\n RelayBusLifecycle,\n RelayBusHealth,\n RelayBusTransactionHost,\n ],\n exports: [RelayBus, RelayBusHealth, RelayBusTransactionHost],\n})\nexport class RelayBusModule extends RelayBusConfigurableModule {\n /**\n * The relaybus contract of a feature module: import it in the module whose providers consume\n * and produce the events. When the application initialises, every consumed event needs a\n * `@RelayBusConsumer` method (or a `@RelayBusCatalogConsumer` class) among the providers of\n * that module, spread over any classes and method names, and every produced event needs a\n * route to a transport; otherwise the application fails to start naming the module and each\n * missing event. Needs `RelayBusModule.forRoot` in the application.\n *\n * ```ts\n * @Module({\n * imports: [RelayBusModule.forFeature({ consumes: [OrderEvents], produces: [produce(BillingEvents)] })],\n * providers: [OrderPlacedHandlers, OrderCancelledHandlers],\n * })\n * export class BillingModule {}\n * ```\n *\n * @throws ConfigurationError for a `produce(...)` in `consumes` or a `consume(...)` in `produces`.\n */\n static forFeature(options: RelayBusFeatureOptions): DynamicModule {\n return {\n module: RelayBusFeatureModule,\n providers: [\n { provide: RelayBusFeatureContract, useValue: new RelayBusFeatureContract(options) },\n ],\n };\n }\n}\n","import 'reflect-metadata';\nimport { resolveBus } from './relay-bus-registry.js';\n\n/** The compile error a `@RelayBusTransaction()` on a method that does not return a Promise reads. */\nexport type RelayBusTransactionNeedsAsyncMethod =\n '@RelayBusTransaction() needs a method that returns a Promise: make the method async';\n\n/**\n * Accepts the descriptor of a method that returns a Promise; any other method fails to compile\n * with {@link RelayBusTransactionNeedsAsyncMethod} in the message.\n */\nexport type AsyncMethodDescriptor<TMethod> = TypedPropertyDescriptor<TMethod> &\n (TMethod extends (...args: never[]) => PromiseLike<unknown>\n ? unknown\n : RelayBusTransactionNeedsAsyncMethod);\n\n/** What `@RelayBusTransaction()` returns: a method decorator for async methods only. */\nexport type RelayBusTransactionDecorator = <TMethod extends (...args: never[]) => unknown>(\n target: object,\n propertyKey: string | symbol,\n descriptor: AsyncMethodDescriptor<TMethod>,\n) => void;\n\ntype AsyncMethod = (this: unknown, ...args: unknown[]) => Promise<unknown>;\n\n/**\n * Runs the method in a relaybus transaction: `bus.publish(...)` inside it, and in everything it\n * awaits, joins the transaction without passing `{ transaction }`, and a repository reads it with\n * `bus.currentTransaction()` or {@link RelayBusTransactionHost}. The transaction commits when the\n * method resolves and rolls back when it rejects; it is held to the bus `transactionTimeout`.\n *\n * - The method itself is replaced, so `this.other()` calls of decorated methods are transactional\n * too, unlike interceptor-based decorators.\n * - A decorated method called while a transaction is active (another decorated method,\n * `bus.transaction`, a transactional handler, or the `transactionResolver`, for example\n * `@nestjs-cls/transactional`) joins it instead of opening a second one.\n * - The bus is the one of the application's `RelayBusModule`; the class does not inject it.\n * - Only methods that return a Promise compile.\n *\n * ```ts\n * @Injectable()\n * export class OrderService {\n * @RelayBusTransaction()\n * async place(orderId: string): Promise<void> {\n * await this.orders.insert(orderId);\n * await this.bus.publish(new OrderPlaced({ orderId }));\n * }\n * }\n * ```\n */\nexport function RelayBusTransaction(): RelayBusTransactionDecorator {\n // eslint-disable-next-line relaybus/max-two-params -- TypeScript calls a method decorator with three arguments\n return (target, propertyKey, descriptor) => {\n const original = descriptor.value as unknown as AsyncMethod;\n const label = `${target.constructor.name}.${String(propertyKey)}`;\n const transactional: AsyncMethod = async function (this: unknown, ...args: unknown[]) {\n const bus = resolveBus(this, label);\n if (bus.currentTransaction() !== undefined) {\n return original.apply(this, args);\n }\n return bus.transaction(() => original.apply(this, args));\n };\n Object.defineProperty(transactional, 'name', { value: original.name });\n // Decorators applied before this one (route, guard, interceptor metadata) keep their metadata.\n for (const key of Reflect.getOwnMetadataKeys(original)) {\n Reflect.defineMetadata(key, Reflect.getOwnMetadata(key, original), transactional);\n }\n descriptor.value = transactional as never;\n };\n}\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { Catalog, SubscribeOptions, EventOf, HandlerContext, CatalogEventSelection, CatalogEntry, RelayBus, RelayBusOptions, EventStoreStatistics, EventClass, EventEnvelope } from '@relaybus/core';
|
|
1
|
+
import { Catalog, SubscribeOptions, EventOf, HandlerContext, CatalogEventSelection, CatalogEntry, RelayBus, RelayBusOptions, EventStoreStatistics, CatalogDeclaration, EventClass, EventEnvelope } from '@relaybus/core';
|
|
2
2
|
export { RelayBus } from '@relaybus/core';
|
|
3
3
|
import * as _nestjs_common from '@nestjs/common';
|
|
4
|
-
import { OnModuleInit, OnApplicationBootstrap, BeforeApplicationShutdown } from '@nestjs/common';
|
|
5
|
-
import { DiscoveryService, MetadataScanner } from '@nestjs/core';
|
|
4
|
+
import { OnModuleInit, OnApplicationBootstrap, BeforeApplicationShutdown, OnApplicationShutdown, DynamicModule } from '@nestjs/common';
|
|
5
|
+
import { DiscoveryService, MetadataScanner, ModulesContainer } from '@nestjs/core';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Options of {@link
|
|
8
|
+
* Options of {@link RelayBusCatalogConsumer}: the core {@link SubscribeOptions} applied to
|
|
9
9
|
* every handler of the class, except `id`, which is always
|
|
10
10
|
* `${ClassName}.on${EventName}`, and optionally the events the class consumes.
|
|
11
11
|
*/
|
|
12
|
-
type
|
|
13
|
-
/** What one `@
|
|
14
|
-
interface
|
|
12
|
+
type RelayBusCatalogConsumerOptions<TCatalog extends Catalog = Catalog, TName extends keyof TCatalog = keyof TCatalog> = Omit<SubscribeOptions, 'id'> & CatalogEventSelection<TName>;
|
|
13
|
+
/** What one `@RelayBusCatalogConsumer` decorator recorded on a class. */
|
|
14
|
+
interface RelayBusCatalogConsumerMetadata {
|
|
15
15
|
readonly catalog: Catalog;
|
|
16
16
|
/** Subscribe options applied to every handler of the class. */
|
|
17
17
|
readonly options: Omit<SubscribeOptions, 'id'>;
|
|
@@ -26,7 +26,7 @@ interface EventConsumerMetadata {
|
|
|
26
26
|
* events. The event parameter is checked strictly; the context is typed
|
|
27
27
|
* `HandlerContext<never>` so a method may declare any transaction type.
|
|
28
28
|
*/
|
|
29
|
-
type
|
|
29
|
+
type RelayBusCatalogConsumerClass<TCatalog extends Catalog, TName extends keyof TCatalog> = abstract new (...args: never[]) => {
|
|
30
30
|
readonly [TKey in TName & string as `on${TKey}`]: (event: EventOf<TCatalog[TKey]>, context: HandlerContext<never>) => unknown;
|
|
31
31
|
};
|
|
32
32
|
/**
|
|
@@ -45,35 +45,46 @@ type EventConsumerClass<TCatalog extends Catalog, TName extends keyof TCatalog>
|
|
|
45
45
|
*
|
|
46
46
|
* `catalogs: [consume(Catalog, { events })]` in the module options makes the
|
|
47
47
|
* application fail to boot if no provider handles a consumed event. Works next
|
|
48
|
-
* to `@
|
|
49
|
-
* distinct `@
|
|
48
|
+
* to `@RelayBusConsumer` in the same class (give a method that carries both a
|
|
49
|
+
* distinct `@RelayBusConsumer` id). The provider must be a singleton. Declarations
|
|
50
50
|
* are inherited; a subclass that declares the same catalog again replaces the
|
|
51
51
|
* inherited declaration of that catalog, and declaring one catalog twice on
|
|
52
52
|
* the same class throws a {@link ConfigurationError}.
|
|
53
53
|
*
|
|
54
54
|
* ```ts
|
|
55
55
|
* @Injectable()
|
|
56
|
-
* @
|
|
56
|
+
* @RelayBusCatalogConsumer(OrderEvents, { events: ['OrderPlaced'], transactional: true })
|
|
57
57
|
* export class BillingHandlers {
|
|
58
58
|
* onOrderPlaced(event: EventOf<typeof OrderPlaced>) {}
|
|
59
59
|
* }
|
|
60
60
|
* ```
|
|
61
61
|
*/
|
|
62
|
-
declare function
|
|
62
|
+
declare function RelayBusCatalogConsumer<TCatalog extends Catalog>(catalog: TCatalog, options?: Omit<SubscribeOptions, 'id'> & {
|
|
63
63
|
readonly events?: undefined;
|
|
64
64
|
}): ClassDecorator;
|
|
65
|
-
declare function
|
|
65
|
+
declare function RelayBusCatalogConsumer<TCatalog extends Catalog, const TName extends keyof TCatalog>(catalog: TCatalog, options: Omit<SubscribeOptions, 'id'> & {
|
|
66
66
|
readonly events: readonly TName[];
|
|
67
|
-
}): (target:
|
|
67
|
+
}): (target: RelayBusCatalogConsumerClass<TCatalog, TName>) => void;
|
|
68
68
|
/**
|
|
69
69
|
* With options whose `events` are not statically known (a variable typed
|
|
70
|
-
* {@link
|
|
70
|
+
* {@link RelayBusCatalogConsumerOptions}), the selection is checked when the module
|
|
71
71
|
* initialises instead of at compile time.
|
|
72
72
|
*/
|
|
73
|
-
declare function
|
|
73
|
+
declare function RelayBusCatalogConsumer<TCatalog extends Catalog>(catalog: TCatalog, options: RelayBusCatalogConsumerOptions<TCatalog>): ClassDecorator;
|
|
74
|
+
/**
|
|
75
|
+
* @deprecated Renamed to {@link RelayBusCatalogConsumer}, which behaves identically; this alias is
|
|
76
|
+
* removed in 1.0.0.
|
|
77
|
+
*/
|
|
78
|
+
declare const EventConsumer: typeof RelayBusCatalogConsumer;
|
|
79
|
+
/** @deprecated Renamed to {@link RelayBusCatalogConsumerOptions}; this alias is removed in 1.0.0. */
|
|
80
|
+
type EventConsumerOptions<TCatalog extends Catalog = Catalog, TName extends keyof TCatalog = keyof TCatalog> = RelayBusCatalogConsumerOptions<TCatalog, TName>;
|
|
81
|
+
/** @deprecated Renamed to {@link RelayBusCatalogConsumerMetadata}; this alias is removed in 1.0.0. */
|
|
82
|
+
type EventConsumerMetadata = RelayBusCatalogConsumerMetadata;
|
|
83
|
+
/** @deprecated Renamed to {@link RelayBusCatalogConsumerClass}; this alias is removed in 1.0.0. */
|
|
84
|
+
type EventConsumerClass<TCatalog extends Catalog, TName extends keyof TCatalog> = RelayBusCatalogConsumerClass<TCatalog, TName>;
|
|
74
85
|
|
|
75
86
|
/**
|
|
76
|
-
* Finds every `@
|
|
87
|
+
* Finds every `@RelayBusConsumer` method and every `@RelayBusCatalogConsumer` class among the
|
|
77
88
|
* singleton providers of the application and registers them on the bus before
|
|
78
89
|
* the bus starts. Providers that are request-scoped or transient, directly or
|
|
79
90
|
* through a dependency, and use either decorator fail the boot. A request-scoped provider whose
|
|
@@ -84,9 +95,19 @@ declare class RelayBusHandlerExplorer implements OnModuleInit {
|
|
|
84
95
|
private readonly discovery;
|
|
85
96
|
private readonly metadataScanner;
|
|
86
97
|
private readonly bus;
|
|
87
|
-
|
|
98
|
+
private readonly modules;
|
|
99
|
+
constructor(discovery: DiscoveryService, metadataScanner: MetadataScanner, bus: RelayBus, modules: ModulesContainer);
|
|
88
100
|
onModuleInit(): void;
|
|
101
|
+
/** Checks the `RelayBusModule.forFeature` contract of every module that imports one. */
|
|
102
|
+
private assertModuleContracts;
|
|
103
|
+
private importersOf;
|
|
104
|
+
/** Records the event types the provider of `wrapper` consumes under the provider's module. */
|
|
105
|
+
private recordConsumedTypes;
|
|
106
|
+
private registerProvider;
|
|
107
|
+
private registerSubscribedMethod;
|
|
89
108
|
private registerEventConsumers;
|
|
109
|
+
/** The catalog entries `lookup` handles: the selected ones, else every entry it has a method for. */
|
|
110
|
+
private catalogHandlers;
|
|
90
111
|
private subscribedMethods;
|
|
91
112
|
/**
|
|
92
113
|
* Request-scoped and transient wrappers have no usable instance (a factory
|
|
@@ -147,19 +168,52 @@ declare class RelayBusHealth {
|
|
|
147
168
|
|
|
148
169
|
/**
|
|
149
170
|
* Starts the bus once every handler is registered and the application has
|
|
150
|
-
* bootstrapped, and stops it (draining running handlers
|
|
151
|
-
*
|
|
171
|
+
* bootstrapped, and stops it (draining running handlers, within `dispatcher.shutdownTimeout`) on
|
|
172
|
+
* shutdown: `bus.stop()` resolves at that deadline at the latest, so a hung query or broker cannot
|
|
173
|
+
* hold `app.close()` until the platform kills the process. A start
|
|
174
|
+
* failure rejects the hook, so the application does not boot. `@RelayBusTransaction()`
|
|
175
|
+
* methods find the bus from module initialisation until the application has shut down.
|
|
152
176
|
*/
|
|
153
|
-
declare class RelayBusLifecycle implements OnApplicationBootstrap, BeforeApplicationShutdown {
|
|
177
|
+
declare class RelayBusLifecycle implements OnModuleInit, OnApplicationBootstrap, BeforeApplicationShutdown, OnApplicationShutdown {
|
|
154
178
|
private readonly bus;
|
|
155
179
|
constructor(bus: RelayBus);
|
|
180
|
+
onModuleInit(): void;
|
|
156
181
|
onApplicationBootstrap(): Promise<void>;
|
|
157
182
|
beforeApplicationShutdown(): Promise<void>;
|
|
183
|
+
/** After the bus stopped, so handlers still draining at shutdown can open transactions. */
|
|
184
|
+
onApplicationShutdown(): void;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* What one feature module consumes and produces, given to `RelayBusModule.forFeature`. Each item is
|
|
189
|
+
* a whole catalog or a `consume(...)` / `produce(...)` declaration of some of its events.
|
|
190
|
+
*/
|
|
191
|
+
interface RelayBusFeatureOptions {
|
|
192
|
+
/** Events the importing module handles: each needs a `@RelayBusConsumer` method (or a catalog consumer) among its providers. */
|
|
193
|
+
readonly consumes?: readonly (Catalog | CatalogDeclaration)[];
|
|
194
|
+
/** Events the importing module publishes for other services: each needs a route to a transport. */
|
|
195
|
+
readonly produces?: readonly (Catalog | CatalogDeclaration)[];
|
|
196
|
+
}
|
|
197
|
+
/** One event of a feature contract, named for error messages. */
|
|
198
|
+
type ContractEvent = {
|
|
199
|
+
/** `Catalog.EventName`. */
|
|
200
|
+
readonly label: string;
|
|
201
|
+
readonly type: string;
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
* The contract of the module that imports `RelayBusModule.forFeature(...)`, checked when the
|
|
205
|
+
* application initialises.
|
|
206
|
+
*/
|
|
207
|
+
declare class RelayBusFeatureContract {
|
|
208
|
+
readonly consumes: readonly ContractEvent[];
|
|
209
|
+
readonly produces: readonly ContractEvent[];
|
|
210
|
+
/** @throws ConfigurationError for a `produce(...)` in `consumes`, a `consume(...)` in `produces`, or something that is not a catalog. */
|
|
211
|
+
constructor(options: RelayBusFeatureOptions);
|
|
158
212
|
}
|
|
159
213
|
|
|
160
214
|
/**
|
|
161
|
-
* Registers one {@link RelayBus} for the application, discovers `@
|
|
162
|
-
* handlers in every module, starts the bus after bootstrap and stops it on
|
|
215
|
+
* Registers one {@link RelayBus} for the application, discovers `@RelayBusConsumer` and `@RelayBusCatalogConsumer`
|
|
216
|
+
* handlers in every module, runs `@RelayBusTransaction()` methods on the bus, starts the bus after bootstrap and stops it on
|
|
163
217
|
* shutdown. Global unless `isGlobal: false`.
|
|
164
218
|
*
|
|
165
219
|
* ```ts
|
|
@@ -167,28 +221,124 @@ declare class RelayBusLifecycle implements OnApplicationBootstrap, BeforeApplica
|
|
|
167
221
|
* ```
|
|
168
222
|
*/
|
|
169
223
|
declare class RelayBusModule extends RelayBusConfigurableModule {
|
|
224
|
+
/**
|
|
225
|
+
* The relaybus contract of a feature module: import it in the module whose providers consume
|
|
226
|
+
* and produce the events. When the application initialises, every consumed event needs a
|
|
227
|
+
* `@RelayBusConsumer` method (or a `@RelayBusCatalogConsumer` class) among the providers of
|
|
228
|
+
* that module, spread over any classes and method names, and every produced event needs a
|
|
229
|
+
* route to a transport; otherwise the application fails to start naming the module and each
|
|
230
|
+
* missing event. Needs `RelayBusModule.forRoot` in the application.
|
|
231
|
+
*
|
|
232
|
+
* ```ts
|
|
233
|
+
* @Module({
|
|
234
|
+
* imports: [RelayBusModule.forFeature({ consumes: [OrderEvents], produces: [produce(BillingEvents)] })],
|
|
235
|
+
* providers: [OrderPlacedHandlers, OrderCancelledHandlers],
|
|
236
|
+
* })
|
|
237
|
+
* export class BillingModule {}
|
|
238
|
+
* ```
|
|
239
|
+
*
|
|
240
|
+
* @throws ConfigurationError for a `produce(...)` in `consumes` or a `consume(...)` in `produces`.
|
|
241
|
+
*/
|
|
242
|
+
static forFeature(options: RelayBusFeatureOptions): DynamicModule;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Carries the contract of `RelayBusModule.forFeature(...)` into the module that imports it. The
|
|
247
|
+
* contract is checked against that module's providers when the application initialises.
|
|
248
|
+
*/
|
|
249
|
+
declare class RelayBusFeatureModule {
|
|
170
250
|
}
|
|
171
251
|
|
|
172
252
|
/**
|
|
173
|
-
*
|
|
253
|
+
* Hands repositories the transaction of the enclosing `@RelayBusTransaction()` method (or
|
|
254
|
+
* `bus.transaction`, transactional handler, `transactionResolver`), typed as the store's
|
|
255
|
+
* transaction handle: `PoolClient` for `pg`, a Kysely `Transaction`, a TypeORM `EntityManager`,
|
|
256
|
+
* a Prisma transaction client, a MongoDB `ClientSession`.
|
|
257
|
+
*
|
|
258
|
+
* ```ts
|
|
259
|
+
* @Injectable()
|
|
260
|
+
* export class OrderRepository {
|
|
261
|
+
* constructor(private readonly transactions: RelayBusTransactionHost<PoolClient>) {}
|
|
262
|
+
*
|
|
263
|
+
* async insert(orderId: string): Promise<void> {
|
|
264
|
+
* await this.transactions.current().query('INSERT INTO orders (id) VALUES ($1)', [orderId]);
|
|
265
|
+
* }
|
|
266
|
+
* }
|
|
267
|
+
* ```
|
|
268
|
+
*/
|
|
269
|
+
declare class RelayBusTransactionHost<TTransaction = unknown> {
|
|
270
|
+
private readonly bus;
|
|
271
|
+
constructor(bus: RelayBus<TTransaction>);
|
|
272
|
+
/**
|
|
273
|
+
* The active transaction.
|
|
274
|
+
*
|
|
275
|
+
* @throws TransactionRequiredError when the caller runs outside every transaction.
|
|
276
|
+
*/
|
|
277
|
+
current(): TTransaction;
|
|
278
|
+
/** The active transaction, or undefined outside every transaction. */
|
|
279
|
+
find(): TTransaction | undefined;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/** The compile error a `@RelayBusTransaction()` on a method that does not return a Promise reads. */
|
|
283
|
+
type RelayBusTransactionNeedsAsyncMethod = '@RelayBusTransaction() needs a method that returns a Promise: make the method async';
|
|
284
|
+
/**
|
|
285
|
+
* Accepts the descriptor of a method that returns a Promise; any other method fails to compile
|
|
286
|
+
* with {@link RelayBusTransactionNeedsAsyncMethod} in the message.
|
|
287
|
+
*/
|
|
288
|
+
type AsyncMethodDescriptor<TMethod> = TypedPropertyDescriptor<TMethod> & (TMethod extends (...args: never[]) => PromiseLike<unknown> ? unknown : RelayBusTransactionNeedsAsyncMethod);
|
|
289
|
+
/** What `@RelayBusTransaction()` returns: a method decorator for async methods only. */
|
|
290
|
+
type RelayBusTransactionDecorator = <TMethod extends (...args: never[]) => unknown>(target: object, propertyKey: string | symbol, descriptor: AsyncMethodDescriptor<TMethod>) => void;
|
|
291
|
+
/**
|
|
292
|
+
* Runs the method in a relaybus transaction: `bus.publish(...)` inside it, and in everything it
|
|
293
|
+
* awaits, joins the transaction without passing `{ transaction }`, and a repository reads it with
|
|
294
|
+
* `bus.currentTransaction()` or {@link RelayBusTransactionHost}. The transaction commits when the
|
|
295
|
+
* method resolves and rolls back when it rejects; it is held to the bus `transactionTimeout`.
|
|
296
|
+
*
|
|
297
|
+
* - The method itself is replaced, so `this.other()` calls of decorated methods are transactional
|
|
298
|
+
* too, unlike interceptor-based decorators.
|
|
299
|
+
* - A decorated method called while a transaction is active (another decorated method,
|
|
300
|
+
* `bus.transaction`, a transactional handler, or the `transactionResolver`, for example
|
|
301
|
+
* `@nestjs-cls/transactional`) joins it instead of opening a second one.
|
|
302
|
+
* - The bus is the one of the application's `RelayBusModule`; the class does not inject it.
|
|
303
|
+
* - Only methods that return a Promise compile.
|
|
304
|
+
*
|
|
305
|
+
* ```ts
|
|
306
|
+
* @Injectable()
|
|
307
|
+
* export class OrderService {
|
|
308
|
+
* @RelayBusTransaction()
|
|
309
|
+
* async place(orderId: string): Promise<void> {
|
|
310
|
+
* await this.orders.insert(orderId);
|
|
311
|
+
* await this.bus.publish(new OrderPlaced({ orderId }));
|
|
312
|
+
* }
|
|
313
|
+
* }
|
|
314
|
+
* ```
|
|
315
|
+
*/
|
|
316
|
+
declare function RelayBusTransaction(): RelayBusTransactionDecorator;
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Options of {@link RelayBusConsumer}: the core {@link SubscribeOptions}, except that
|
|
174
320
|
* `id` is optional and defaults to `ClassName.methodName`.
|
|
175
321
|
*/
|
|
176
|
-
type
|
|
322
|
+
type RelayBusConsumerOptions = Omit<SubscribeOptions, 'id'> & {
|
|
177
323
|
/**
|
|
178
324
|
* Stable id of the handler. Deliveries are recorded under it, so renaming it
|
|
179
325
|
* (or the class or method it is derived from) orphans pending deliveries.
|
|
180
326
|
* Default: `${ClassName}.${methodName}`. Required when one method carries
|
|
181
|
-
* several `@
|
|
327
|
+
* several `@RelayBusConsumer` decorators.
|
|
182
328
|
*/
|
|
183
329
|
readonly id?: string;
|
|
184
330
|
};
|
|
185
|
-
/** What one `@
|
|
186
|
-
interface
|
|
331
|
+
/** What one `@RelayBusConsumer` decorator recorded on a method. */
|
|
332
|
+
interface RelayBusConsumerMetadata {
|
|
187
333
|
readonly event: EventClass<unknown> | string;
|
|
188
|
-
readonly options:
|
|
334
|
+
readonly options: RelayBusConsumerOptions;
|
|
189
335
|
}
|
|
336
|
+
/** @deprecated Renamed to {@link RelayBusConsumerOptions}; this alias is removed in 1.0.0. */
|
|
337
|
+
type SubscribeDecoratorOptions = RelayBusConsumerOptions;
|
|
338
|
+
/** @deprecated Renamed to {@link RelayBusConsumerMetadata}; this alias is removed in 1.0.0. */
|
|
339
|
+
type SubscribeMetadata = RelayBusConsumerMetadata;
|
|
190
340
|
type HandlerMethod<TPayload> = (event: EventEnvelope<TPayload>, context: HandlerContext<never>) => unknown;
|
|
191
|
-
type
|
|
341
|
+
type HandlerDecorator<TPayload> = <TMethod extends HandlerMethod<TPayload>>(target: object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<TMethod>) => void;
|
|
192
342
|
/**
|
|
193
343
|
* Subscribes a provider method to an event class or type. The method is
|
|
194
344
|
* registered with `bus.subscribe` when the module initialises, with `this`
|
|
@@ -201,12 +351,17 @@ type SubscribeDecorator<TPayload> = <TMethod extends HandlerMethod<TPayload>>(ta
|
|
|
201
351
|
* ```ts
|
|
202
352
|
* @Injectable()
|
|
203
353
|
* export class ShippingHandlers {
|
|
204
|
-
* @
|
|
354
|
+
* @RelayBusConsumer(OrderPlaced, { transactional: true })
|
|
205
355
|
* async onOrderPlaced(event: EventEnvelope<{ orderId: string }>, context: HandlerContext) {}
|
|
206
356
|
* }
|
|
207
357
|
* ```
|
|
208
358
|
*/
|
|
209
|
-
declare function
|
|
210
|
-
declare function
|
|
359
|
+
declare function RelayBusConsumer<TPayload>(event: EventClass<TPayload>, options?: RelayBusConsumerOptions): HandlerDecorator<TPayload>;
|
|
360
|
+
declare function RelayBusConsumer(eventType: string, options?: RelayBusConsumerOptions): HandlerDecorator<never>;
|
|
361
|
+
/**
|
|
362
|
+
* @deprecated Renamed to {@link RelayBusConsumer}, which behaves identically; this alias is
|
|
363
|
+
* removed in 1.0.0.
|
|
364
|
+
*/
|
|
365
|
+
declare const Subscribe: typeof RelayBusConsumer;
|
|
211
366
|
|
|
212
|
-
export { EventConsumer, type EventConsumerClass, type EventConsumerMetadata, type EventConsumerOptions, RelayBusHandlerExplorer, RelayBusHealth, type RelayBusHealthReport, RelayBusLifecycle, RelayBusModule, type RelayBusModuleExtras, type RelayBusModuleOptions, type RelayBusModuleOptionsFactory, Subscribe, type SubscribeDecoratorOptions, type SubscribeMetadata };
|
|
367
|
+
export { type AsyncMethodDescriptor, type ContractEvent, EventConsumer, type EventConsumerClass, type EventConsumerMetadata, type EventConsumerOptions, RelayBusCatalogConsumer, type RelayBusCatalogConsumerClass, type RelayBusCatalogConsumerMetadata, type RelayBusCatalogConsumerOptions, RelayBusConsumer, type RelayBusConsumerMetadata, type RelayBusConsumerOptions, RelayBusFeatureContract, RelayBusFeatureModule, type RelayBusFeatureOptions, RelayBusHandlerExplorer, RelayBusHealth, type RelayBusHealthReport, RelayBusLifecycle, RelayBusModule, type RelayBusModuleExtras, type RelayBusModuleOptions, type RelayBusModuleOptionsFactory, RelayBusTransaction, type RelayBusTransactionDecorator, RelayBusTransactionHost, type RelayBusTransactionNeedsAsyncMethod, Subscribe, type SubscribeDecoratorOptions, type SubscribeMetadata };
|