Clear final M0 bugs on master (T-5 verified, T-12, T-15, T-17)

This commit is contained in:
Boki 2026-11-27 16:42:43 -05:00
parent ade0a3ef1d
commit 2ea7316af6
7 changed files with 148 additions and 17 deletions

View file

@ -44,11 +44,21 @@ export function Operation(
if (!constructor.__operations) {
constructor.__operations = [];
}
constructor.__operations.push({
name,
method: String(methodName),
batch: options?.batch,
});
const methodKey = String(methodName);
const existing = constructor.__operations.find(
op => op.name === name && op.method === methodKey
);
if (existing) {
if (options?.batch !== undefined && existing.batch === undefined) {
existing.batch = options.batch;
}
} else {
constructor.__operations.push({
name,
method: methodKey,
batch: options?.batch,
});
}
return descriptor;
};
@ -82,11 +92,17 @@ export function QueueSchedule(
if (!constructor.__schedules) {
constructor.__schedules = [];
}
constructor.__schedules.push({
operation: String(methodName),
cronPattern,
...options,
});
const operationKey = String(methodName);
const existingSchedule = constructor.__schedules.find(
s => s.operation === operationKey && s.cronPattern === cronPattern
);
if (!existingSchedule) {
constructor.__schedules.push({
operation: operationKey,
cronPattern,
...options,
});
}
return descriptor;
};

View file

@ -267,6 +267,26 @@ describe('Handler Decorators', () => {
expect(constructor.__schedules[1]).toMatchObject({ cronPattern: '0 0 * * *' });
expect(constructor.__schedules[2]).toMatchObject({ cronPattern: '0 0 * * 0' });
});
it('should not register duplicate operation metadata when @Operation and @ScheduledOperation are both applied (T-17)', () => {
class DeduplicatedHandler {
@Operation('sync-all-exchanges')
@ScheduledOperation('sync-all-exchanges', '0 0 * * 0', {
priority: 10,
batch: { enabled: true, size: 25 },
})
async syncAllExchanges() {}
}
const constructor = DeduplicatedHandler as any;
expect(constructor.__operations).toHaveLength(1);
expect(constructor.__operations[0]).toEqual({
name: 'sync-all-exchanges',
method: 'syncAllExchanges',
batch: { enabled: true, size: 25 },
});
expect(constructor.__schedules).toHaveLength(1);
});
});
describe('decorator composition', () => {