import { switchMap, filter } from 'rxjs/operators'; import { DeadLetterOptions } from '@azure/service-bus'; import { SbContext } from '@pebula/attribus'; export const completeMessage = () => switchMap( async (ctx: T) => { await ctx.getMessage().complete(); return ctx; }); export const abandonMessage = (propertiesToModify?: { [key: string]: any; }) => switchMap( async (ctx: T) => { await ctx.getMessage().abandon(propertiesToModify); return ctx; }); export const deferMessage = (propertiesToModify?: { [key: string]: any; }) => switchMap( async (ctx: T) => { await ctx.getMessage().defer(propertiesToModify); return ctx; }); export const deadLetter = (options?: DeadLetterOptions) => switchMap( async (ctx: T) => { await ctx.getMessage().deadLetter(options); return ctx; }); const alwaysBlock = filter( () => false ); export const block = () => alwaysBlock;