import { SingleNodeClient } from "../clients/singleNodeClient" ; import type { IClient } from "../models/IClient" ; import type { IMessage } from "../models/IMessage" ; import { promote } from "./promote" ; import { reattach } from "./reattach" ; param client param messageId returns export async function retry ( client , messageId ) { const localClient = typeof client === "string" ? new SingleNodeClient ( client ) : client ; const metadata = await localClient . messageMetadata ( messageId ) ; if ( ! metadata ) { throw new Error ( "The message does not exist." ) ; } if ( metadata . shouldPromote ) { return promote ( client , messageId ) ; } else if ( metadata . shouldReattach ) { return reattach ( client , messageId ) ; } throw new Error ( "The message should not be promoted or reattached." ) ; }