@cumulus/message
Version:
Utilities for building and parsing Cumulus messages
124 lines • 4.06 kB
TypeScript
import { Message } from '@cumulus/types';
import { ApiPdr } from '@cumulus/types/api/pdrs';
interface PDR {
name: string;
PANSent: boolean;
PANmessage: string;
}
interface MessageWithOptionalPayloadPdr extends Message.CumulusMessage {
payload: {
pdr?: PDR;
failed?: unknown[];
running?: unknown[];
completed?: unknown[];
};
}
interface PdrStats {
processing: number;
completed: number;
failed: number;
total: number;
}
/**
* Get the PDR object from a workflow message, if any.
*
* @param {MessageWithOptionalPayloadPdr} message - A workflow message object
* @returns {undefined|Object} The PDR object
*
* @alias module:PDRs
*/
export declare const getMessagePdr: (message: MessageWithOptionalPayloadPdr) => PDR | undefined;
/**
* Determine if message has a PDR.
*
* @param {MessageWithOptionalPayloadPdr} message - A workflow message object
* @returns {boolean} true if message has a PDR
*
* @alias module:PDRs
*/
export declare const messageHasPdr: (message: MessageWithOptionalPayloadPdr) => boolean;
/**
* Get the PAN sent status from a workflow message, if any.
*
* @param {MessageWithOptionalPayloadPdr} message - A workflow message
* @returns {boolean} The PAN sent status
*
* @alias module:PDRs
*/
export declare const getMessagePdrPANSent: (message: MessageWithOptionalPayloadPdr) => boolean;
/**
* Get the PAN message status from a workflow message, if any.
*
* @param {MessageWithOptionalPayloadPdr} message - A workflow message
* @returns {string} The PAN message
*
* @alias module:PDRs
*/
export declare const getMessagePdrPANMessage: (message: MessageWithOptionalPayloadPdr) => string;
/**
* Get the PDR name from a workflow message, if any.
*
* @param {MessageWithOptionalPayloadPdr} message - A workflow message
* @returns {string} The PDR name
*
* @alias module:PDRs
*/
export declare const getMessagePdrName: (message: MessageWithOptionalPayloadPdr) => string | undefined;
/**
* Get the number of running executions for a PDR, if any.
*
* @param {MessageWithOptionalPayloadPdr} message - A workflow message
* @returns {number} Number of running executions
*
* @alias module:PDRs
*/
export declare const getMessagePdrRunningExecutions: (message: MessageWithOptionalPayloadPdr) => number;
/**
* Get the number of completed executions for a PDR, if any.
*
* @param {MessageWithOptionalPayloadPdr} message - A workflow message
* @returns {number} Number of completed executions
*
* @alias module:PDRs
*/
export declare const getMessagePdrCompletedExecutions: (message: MessageWithOptionalPayloadPdr) => number;
/**
* Get the number of failed executions for a PDR, if any.
*
* @param {MessageWithOptionalPayloadPdr} message - A workflow message
* @returns {number} Number of failed executions
*
* @alias module:PDRs
*/
export declare const getMessagePdrFailedExecutions: (message: MessageWithOptionalPayloadPdr) => number;
/**
* Get the PDR stats from a workflow message, if any.
*
* @param {MessageWithOptionalPayloadPdr} message - A workflow message
* @returns {PdrStats}
* Object tracking the status of executions triggered by the PDR
*
* @alias module:PDRs
*/
export declare const getMessagePdrStats: (message: MessageWithOptionalPayloadPdr) => PdrStats;
/**
* Get the percent completion of PDR executions
*
* @param {PdrStats} stats - Stats tracking PDR executions
* @returns {number} Percent completion of PDR executions
*
* @alias module:PDRs
*/
export declare const getPdrPercentCompletion: (stats: PdrStats) => number;
/**
* Generate a PDR record for the API from the message.
*
* @param {MessageWithOptionalPayloadPdr} message - A workflow message object
* @param {string} [updatedAt] - Optional updated timestamp to apply to record
* @returns {ApiPdr} An PDR API record
*
* @alias module:Executions
*/
export declare const generatePdrApiRecordFromMessage: (message: MessageWithOptionalPayloadPdr, updatedAt?: number) => ApiPdr | undefined;
export {};
//# sourceMappingURL=PDRs.d.ts.map