UNPKG

@mbc-cqrs-serverless/core

Version:
31 lines 1.69 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DataSyncHandler = void 0; require("reflect-metadata"); const constants_1 = require("./constants"); /** * Marks a class as a DataSyncHandler for the specified command table. * * @param commandTableName - The raw table name as passed to `CommandModule.register({ tableName })`. * Do NOT use the fully-qualified table name (e.g. "dev-my-table-command"). * Pass the same raw value as in the `register()` call (e.g. "my-table"). * A wrong name silently prevents handler discovery with no error or warning. * * Recommended usage: prefer `CommandModule.register({ dataSyncHandlers: [MyHandler] })` as the * primary registration path. Use this decorator only when auto-discovery across modules is needed. * Mixing both paths for the same handler class causes duplicate registration (guarded by * CommandService which logs a warning and deduplicates). * * **Minification warning:** The async (Step Functions) execution path identifies handlers by * `constructor.name` at runtime. If you bundle with esbuild, webpack + terser, or any minifier, * you MUST enable class-name preservation (e.g. `keepNames: true` in esbuild, * `keep_classnames: true` in terser). Without it, class names are mangled and the `SYNC_DATA` * state cannot locate handlers, causing `SyncDataHandler empty!` errors for every command. */ const DataSyncHandler = (commandTableName) => { return (target) => { Reflect.defineMetadata(constants_1.DATA_SYNC_HANDLER_METADATA, commandTableName, target); }; }; exports.DataSyncHandler = DataSyncHandler; //# sourceMappingURL=data-sync-handler.decorator.js.map