import { utc as moment, Moment } from 'moment'; import { Environment } from './environment'; export enum ProductModuleCodeRunStatus { Complete = 'complete', Failed = 'failed', InProgress = 'in_progress', } export interface NetworkProductModuleCodeRun { product_module_code_run_id: string; product_module_id: string; product_module_definition_id: string; triggered_by: { type: string; id: string; owner_id: string; }; created_at: string; completed_at: string; status: ProductModuleCodeRunStatus; environment: Environment; function_name: string; policy_id?: string; } export interface ProductModuleCodeRun { productModuleCodeRunId: string; productModuleId: string; productModuleDefinitionId: string; triggeredBy: { type: string; id: string; ownerId: string; }; createdAt: Moment; completedAt?: Moment; status: ProductModuleCodeRunStatus; environment: Environment; functionName: string; } export const productModuleCodeRunFromNetwork = (networkCodeRun: NetworkProductModuleCodeRun): ProductModuleCodeRun => { return { productModuleCodeRunId: networkCodeRun.product_module_code_run_id, productModuleId: networkCodeRun.product_module_id, productModuleDefinitionId: networkCodeRun.product_module_definition_id, triggeredBy: { type: networkCodeRun.triggered_by.type, id: networkCodeRun.triggered_by.id, ownerId: networkCodeRun.triggered_by.owner_id, }, createdAt: moment(networkCodeRun.created_at), completedAt: moment(networkCodeRun.completed_at), status: networkCodeRun.status, environment: networkCodeRun.environment, functionName: networkCodeRun.function_name, }; };