import * as utils from './utils' ; import * as path from 'path' ; export enum ResponseCode { Success = 0 , InternalError = 1 , ProcessTimeout = 2 , Throttled = 3 , InputError = 4 } export type ExceptionInfo = { stack : string ; message : string ; fileName ? : string ; lineNumber ? : number ; columnNumber ? : number ; } ; export type DebugEvent = { eventTime : Date ; logLevel : string ; message : string ; } ; export type DebugInfo = { exception : ExceptionInfo ; events : DebugEvent [ ] ; details : { [ key ] : any ; } ; machineName : string ; } ; export type PerfInfo = { [ perfKey ] : number ; } ; export interface Response { responseCode : ResponseCode ; errorMessage ? : string ; output ? : any ; debugInfo ? : DebugInfo ; perfInfo ? : PerfInfo ; } export class ResponseHelper { private static readonly RESPONSE_SCHEMA : utils . JsonSchema = new utils . JsonSchema ( path . resolve ( path . resolve ( __dirname , '../schema' ) , "response.schema.json" ) ) ; public static parse ( jsonString ) { let response = utils . parseJsonString ( jsonString , this . RESPONSE_SCHEMA ) ; return < Response > ( response ) ; } public static validate ( jsValue ) { return this . RESPONSE_SCHEMA . validate ( jsValue ) ; } }