@hpcc-js/comms
Version:
hpcc-js - Communications
1 lines • 112 kB
JavaScript
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var util=require("@hpcc-js/util"),fs=require("fs"),path=require("path"),cp=require("child_process"),os=require("os"),tmp=require("tmp"),xmldom=require("xmldom"),fetch$1=_interopDefault(require("node-fetch")),safeBuffer=require("safe-buffer"),extendStatics=function(e,t){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function __extends(e,t){function n(){this.constructor=e}extendStatics(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var __assign=function(){return(__assign=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function __awaiter(i,u,s,a){return new(s||(s=Promise))(function(e,t){function n(e){try{o(a.next(e))}catch(e){t(e)}}function r(e){try{o(a.throw(e))}catch(e){t(e)}}function o(t){t.done?e(t.value):new s(function(e){e(t.value)}).then(n,r)}o((a=a.apply(i,u||[])).next())})}function __generator(n,r){var o,i,u,e,s={label:0,sent:function(){if(1&u[0])throw u[1];return u[1]},trys:[],ops:[]};return e={next:t(0),throw:t(1),return:t(2)},"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(t){return function(e){return function(t){if(o)throw new TypeError("Generator is already executing.");for(;s;)try{if(o=1,i&&(u=2&t[0]?i.return:t[0]?i.throw||((u=i.return)&&u.call(i),0):i.next)&&!(u=u.call(i,t[1])).done)return u;switch(i=0,u&&(t=[2&t[0],u.value]),t[0]){case 0:case 1:u=t;break;case 4:return s.label++,{value:t[1],done:!1};case 5:s.label++,i=t[1],t=[0];continue;case 7:t=s.ops.pop(),s.trys.pop();continue;default:if(!(u=0<(u=s.trys).length&&u[u.length-1])&&(6===t[0]||2===t[0])){s=0;continue}if(3===t[0]&&(!u||t[1]>u[0]&&t[1]<u[3])){s.label=t[1];break}if(6===t[0]&&s.label<u[1]){s.label=u[1],u=t;break}if(u&&s.label<u[2]){s.label=u[2],s.ops.push(t);break}u[2]&&s.ops.pop(),s.trys.pop();continue}t=r.call(n,s)}catch(e){t=[6,e],i=0}finally{o=u=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,e])}}}var logger=util.scopedLogger("comms/connection.ts"),DefaultOptions={type:"post",baseUrl:"",userID:"",password:"",rejectUnauthorized:!1,timeoutSecs:60};function serializeRequest(e,o){if(void 0===o&&(o=""),o&&(o+="."),"object"!=typeof e)return encodeURIComponent(e);var i=[],t=function(n){if(e.hasOwnProperty(n))if(e[n]instanceof Array){var r=!1;e[n].forEach(function(e,t){"object"==typeof e?(r=!0,i.push(serializeRequest(e,o+encodeURIComponent(n+"."+t)))):i.push(o+encodeURIComponent(n+"_i"+t)+"="+serializeRequest(e))}),r&&i.push(o+encodeURIComponent(n+".itemcount")+"="+e[n].length)}else"object"==typeof e[n]?e[n]&&e[n].Item instanceof Array?(i.push(serializeRequest(e[n].Item,o+encodeURIComponent(n))),i.push(o+encodeURIComponent(n+".itemcount")+"="+e[n].Item.length)):i.push(serializeRequest(e[n],o+encodeURIComponent(n))):void 0!==e[n]?i.push(o+encodeURIComponent(n)+"="+encodeURIComponent(e[n])):i.push(o+encodeURIComponent(n))};for(var n in e)t(n);return i.join("&")}function deserializeResponse(e){return JSON.parse(e)}function jsonp(a,c,p,l){return void 0===p&&(p={}),void 0===l&&(l="json"),new Promise(function(t,e){var n=1e3*a.timeoutSecs,r="jsonp_callback_"+Math.round(999999*Math.random());window[r]=function(e){n=0,s(),t("json"===l&&"string"==typeof e?deserializeResponse(e):e)};var o=document.createElement("script"),i=util.join(a.baseUrl,c);i+=0<=i.indexOf("?")?"&":"?",o.src=i+"jsonp="+r+"&"+serializeRequest(p),document.body.appendChild(o);var u=setInterval(function(){n<=0?clearInterval(u):(n-=5e3)<=0?(clearInterval(u),logger.error("Request timeout: "+o.src),s(),e(Error("Request timeout: "+o.src))):logger.debug("Request pending ("+n/1e3+" sec): "+o.src)},5e3);function s(){delete window[r],document.body.removeChild(o)}})}function authHeader(e){return e.userID?{Authorization:"Basic "+btoa(e.userID+":"+e.password)}:{}}var _omitMap={};function doFetch(t,n,r,e,o){function i(e){if(e.ok)return"json"===o?e.json():e.text();throw new Error(e.statusText)}return e=__assign({},authHeader(t),e),r=__assign({credentials:_omitMap[t.baseUrl]?"omit":"include"},r,{headers:e}),util.promiseTimeout(1e3*t.timeoutSecs,fetch(util.join(t.baseUrl,n),r).then(i).catch(function(e){return r.credentials=_omitMap[t.baseUrl]?"include":"omit",fetch(util.join(t.baseUrl,n),r).then(i).then(function(e){return _omitMap[t.baseUrl]=!_omitMap[t.baseUrl],e})}))}function post(e,t,n,r){return void 0===r&&(r="json"),doFetch(e,t,{method:"post",body:serializeRequest(n)},{"Content-Type":"application/x-www-form-urlencoded"},r)}function get(e,t,n,r){return void 0===r&&(r="json"),doFetch(e,t+"?"+serializeRequest(n),{method:"get"},{},r)}function send(e,t,n,r){var o;switch(void 0===r&&(r="json"),e.type){case"jsonp":o=jsonp(e,t,n,r);break;case"get":o=get(e,t,n,r);break;case"post":default:o=post(e,t,n,r)}return o}var hookedSend=send;function hookSend(e){var t=hookedSend;return e&&(hookedSend=e),t}var Connection=function(){function e(e){this.opts(e)}return e.prototype.opts=function(e){return 0===arguments.length?this._opts:(this._opts=__assign({},DefaultOptions,e),this)},e.prototype.send=function(e,t,n){return void 0===n&&(n="json"),hookedSend(this._opts,e,t,n)},e.prototype.clone=function(){return new e(this.opts())},e}();function setTransportFactory(e){var t=exports.createConnection;return exports.createConnection=e,t}function isArray(e){return"[object Array]"===Object.prototype.toString.call(e)}exports.createConnection=function(e){return new Connection(e)};var ESPExceptions=function(o){function e(e,t,n){var r=o.call(this,"ESPException: "+n.Source)||this;return r.isESPExceptions=!0,r.action=e,r.request=t,r.Source=n.Source,r.Exception=n.Exception,n.Exception.length&&(r.message=n.Exception[0].Code+": "+n.Exception[0].Message),r}return __extends(e,o),e}(Error);function isConnection(e){return void 0!==e.send}var ESPConnection=function(){function e(e,t,n){this._connection=isConnection(e)?e:exports.createConnection(e),this._service=t,this._version=n}return e.prototype.service=function(e){return void 0===e?this._service:(this._service=e,this)},e.prototype.version=function(e){return void 0===e?this._version:(this._version=e,this)},e.prototype.toESPStringArray=function(e,t){if(isArray(e[t])){for(var n=0;n<e[t].length;++n)e[t+"_i"+n]=e[t][n];delete e[t]}return e},e.prototype.opts=function(e){return void 0===e?this._connection.opts():(this._connection.opts(e),this)},e.prototype.send=function(n,e,r,t){void 0===e&&(e={}),void 0===r&&(r="json"),void 0===t&&(t=!1);var o,i=__assign({},e,{ver_:this._version});t&&(i.upload_=!0);var u="json";switch(r){case"text":o=util.join(this._service,n),u="text";break;case"xsd":o=util.join(this._service,n+".xsd"),u="text";break;case"json2":o=util.join(this._service,n+"/json"),r="json",n=n.split("/").pop();break;default:o=util.join(this._service,n+".json")}return this._connection.send(o,i,u).then(function(e){if("json"!==r)return e;var t=void 0;if(e&&e.Exceptions)throw new ESPExceptions(n,i,e.Exceptions);if(e&&(t=e[("WUCDebug"===n?"WUDebug":n)+"Response"]),!t)throw new ESPExceptions(n,i,{Source:"ESPConnection.send",Exception:[{Code:0,Message:"Missing Response"}]});return t}).catch(function(e){if(e.isESPExceptions)throw e;throw new ESPExceptions(n,i,{Source:"ESPConnection.send",Exception:[{Code:0,Message:e.message}]})})},e.prototype.clone=function(){return new e(this._connection.clone(),this._service,this._version)},e}(),AccountService=function(){function e(e){this._connection=new ESPConnection(e,"Ws_Account","1.03")}return e.prototype.connectionOptions=function(){return this._connection.opts()},e.prototype.VerifyUser=function(e){return this._connection.send("VerifyUser",e)},e}(),DFUService=function(){function e(e){this._connection=new ESPConnection(e,"WsDFU","1.35")}return e.prototype.DFUQuery=function(e){return this._connection.send("DFUQuery",e)},e}();function jsonToIField(e,t){var n=typeof t;switch(n){case"boolean":case"number":case"string":return{id:e,type:n};case"object":if(t.Row instanceof Array&&(t=t.Row),t instanceof Array)return{id:e,type:"dataset",children:jsonToIFieldArr(t[0])};default:throw new Error("Unknown field type")}}function jsonToIFieldArr(e){e.Row&&e.Row instanceof Array&&(e=e.Row[0]);var t=[];for(var n in e)t.push(jsonToIField(n,e[n]));return t}var EclService=function(){function e(e){this._connection=new ESPConnection(e,"WsEcl","0")}return e.prototype.opts=function(){return this._connection.opts()},e.prototype.requestJson=function(e,t){return this._connection.send("example/request/query/"+e+"/"+t+"/json",{},"text").then(function(e){var t=JSON.parse(e);for(var n in t)return t[n];return{}}).then(jsonToIFieldArr)},e.prototype.responseJson=function(e,t){return this._connection.send("example/response/query/"+e+"/"+t+"/json",{},"text").then(function(e){var t=JSON.parse(e);for(var n in t)return t[n].Results;return{}}).then(function(e){var t={};for(var n in e)t[n]=jsonToIFieldArr(e[n]);return t})},e.prototype.submit=function(e,t,n){var r="submit/query/"+e+"/"+t;return this._connection.send(r,n,"json2").then(function(e){if(e.Results&&e.Results.Exception)throw new ESPExceptions(r,n,{Source:"wsEcl.submit",Exception:e.Results.Exception});return e.Results})},e}(),MachineService=function(){function e(e){this._connection=new ESPConnection(e,"ws_machine","1.13")}return e.prototype.GetTargetClusterInfo=function(e){return void 0===e&&(e={}),this._connection.send("GetTargetClusterInfo",e)},e}(),SMCService=function(){function e(e){this._connection=new ESPConnection(e,"WsSMC","1.19")}return e.prototype.connectionOptions=function(){return this._connection.opts()},e.prototype.Activity=function(e){return this._connection.send("Activity",e).then(function(e){return __assign({Running:{ActiveWorkunit:[]}},e)})},e}(),TopologyService=function(){function e(e){this._connection=new ESPConnection(e,"WsTopology","1.25")}return e.prototype.connectionOptions=function(){return this._connection.opts()},e.prototype.protocol=function(){return this._connection.opts().baseUrl.split("//")[0]},e.prototype.ip=function(){return this._connection.opts().baseUrl.split("//")[1].split(":")[0]},e.prototype.TpLogicalClusterQuery=function(e){return void 0===e&&(e={}),this._connection.send("TpLogicalClusterQuery",e)},e.prototype.DefaultTpLogicalClusterQuery=function(e){return void 0===e&&(e={}),this.TpLogicalClusterQuery(e).then(function(e){return e.default?e.default:(e.TpLogicalClusters.TpLogicalCluster.some(function(e,t){return 0===t&&(r=e),"hthor"===e.Type&&(n=e,!0)}),n||r);var n,r})},e.prototype.TpServiceQuery=function(e){return this._connection.send("TpServiceQuery",e)},e.prototype.TpTargetClusterQuery=function(e){return this._connection.send("TpTargetClusterQuery",e)},e}();function isWUQueryECLWorkunit(e){return void 0!==e.TotalClusterTime}function isWUInfoWorkunit(e){return void 0!==e.StateEx}!function(e){e[e.Unknown=0]="Unknown",e[e.Compiled=1]="Compiled",e[e.Running=2]="Running",e[e.Completed=3]="Completed",e[e.Failed=4]="Failed",e[e.Archived=5]="Archived",e[e.Aborting=6]="Aborting",e[e.Aborted=7]="Aborted",e[e.Blocked=8]="Blocked",e[e.Submitted=9]="Submitted",e[e.Scheduled=10]="Scheduled",e[e.Compiling=11]="Compiling",e[e.Wait=12]="Wait",e[e.UploadingFiled=13]="UploadingFiled",e[e.DebugPaused=14]="DebugPaused",e[e.DebugRunning=15]="DebugRunning",e[e.Paused=16]="Paused",e[e.LAST=17]="LAST",e[e.NotFound=999]="NotFound"}(exports.WUStateID||(exports.WUStateID={})),function(e){var t;(t=e.Action||(e.Action={}))[t.Unknown=0]="Unknown",t[t.Compile=1]="Compile",t[t.Check=2]="Check",t[t.Run=3]="Run",t[t.ExecuteExisting=4]="ExecuteExisting",t[t.Pause=5]="Pause",t[t.PauseNow=6]="PauseNow",t[t.Resume=7]="Resume",t[t.Debug=8]="Debug",t[t.__size=9]="__size"}(exports.WUUpdate||(exports.WUUpdate={}));var WorkunitsService=function(){function e(e){this._connection=new ESPConnection(e,"WsWorkunits","1.68")}return e.prototype.opts=function(){return this._connection.opts()},e.prototype.connection=function(){return this._connection},e.prototype.WUQuery=function(e){return void 0===e&&(e={}),this._connection.send("WUQuery",e).then(function(e){return util.deepMixin({Workunits:{ECLWorkunit:[]}},e)})},e.prototype.WUInfo=function(e){var t=__assign({Wuid:"",TruncateEclTo64k:!0,IncludeExceptions:!1,IncludeGraphs:!1,IncludeSourceFiles:!1,IncludeResults:!1,IncludeResultsViewNames:!1,IncludeVariables:!1,IncludeTimers:!1,IncludeDebugValues:!1,IncludeApplicationValues:!1,IncludeWorkflows:!1,IncludeXmlSchemas:!1,IncludeResourceURLs:!1,SuppressResultSchemas:!0},e);return this._connection.send("WUInfo",t)},e.prototype.WUCreate=function(){return this._connection.send("WUCreate")},e.prototype.WUUpdate=function(e){return this._connection.send("WUUpdate",e,"json",!0)},e.prototype.WUSubmit=function(e){return this._connection.send("WUSubmit",e)},e.prototype.WUResubmit=function(e){return this._connection.toESPStringArray(e,"Wuids"),this._connection.send("WUResubmit",e)},e.prototype.WUQueryDetails=function(e){return this._connection.send("WUQueryDetails",e)},e.prototype.WUListQueries=function(e){return this._connection.send("WUListQueries",e)},e.prototype.WUPushEvent=function(e){return this._connection.send("WUPushEvent",e)},e.prototype.WUAction=function(e){return e.ActionType=e.WUActionType,this._connection.send("WUAction",e)},e.prototype.WUGetZAPInfo=function(e){return this._connection.send("WUGetZAPInfo",e)},e.prototype.WUShowScheduled=function(e){return this._connection.send("WUShowScheduled",e)},e.prototype.WUQuerySetAliasAction=function(e){return this._connection.send("WUQuerySetAliasAction",e)},e.prototype.WUQuerySetQueryAction=function(e){return this._connection.send("WUQuerySetQueryAction",e)},e.prototype.WUPublishWorkunit=function(e){return this._connection.send("WUPublishWorkunit",e)},e.prototype.WUGetGraph=function(e){return this._connection.send("WUGetGraph",e)},e.prototype.WUResult=function(e){return this._connection.send("WUResult",e)},e.prototype.WUQueryGetGraph=function(e){return this._connection.send("WUQueryGetGraph",e)},e.prototype.WUFile=function(e){return this._connection.send("WUFile",e,"text")},e.prototype.WUGetStats=function(e){return this._connection.send("WUGetStats",e)},e.prototype.WUDetailsMeta=function(e){return this._WUDetailsMetaPromise||(this._WUDetailsMetaPromise=this._connection.send("WUDetailsMeta",e)),this._WUDetailsMetaPromise},e.prototype.WUDetails=function(e){return this._connection.send("WUDetails",e)},e.prototype.WUCDebug=function(e){return this._connection.send("WUCDebug",e).then(function(e){var t=util.xml2json(e.Result).children();return t.length?t[0]:null})},e}(),t0=new Date,t1=new Date;function newInterval(o,i,n,r){function u(e){return o(e=new Date(+e)),e}return(u.floor=u).ceil=function(e){return o(e=new Date(e-1)),i(e,1),o(e),e},u.round=function(e){var t=u(e),n=u.ceil(e);return e-t<n-e?t:n},u.offset=function(e,t){return i(e=new Date(+e),null==t?1:Math.floor(t)),e},u.range=function(e,t,n){var r=[];if(e=u.ceil(e),n=null==n?1:Math.floor(n),!(e<t&&0<n))return r;for(;r.push(new Date(+e)),i(e,n),o(e),e<t;);return r},u.filter=function(n){return newInterval(function(e){if(e<=e)for(;o(e),!n(e);)e.setTime(e-1)},function(e,t){if(e<=e)for(;0<=--t;)for(;i(e,1),!n(e););})},n&&(u.count=function(e,t){return t0.setTime(+e),t1.setTime(+t),o(t0),o(t1),Math.floor(n(t0,t1))},u.every=function(t){return t=Math.floor(t),isFinite(t)&&0<t?1<t?u.filter(r?function(e){return r(e)%t==0}:function(e){return u.count(0,e)%t==0}):u:null}),u}var millisecond=newInterval(function(){},function(e,t){e.setTime(+e+t)},function(e,t){return t-e});millisecond.every=function(n){return n=Math.floor(n),isFinite(n)&&0<n?1<n?newInterval(function(e){e.setTime(Math.floor(e/n)*n)},function(e,t){e.setTime(+e+t*n)},function(e,t){return(t-e)/n}):millisecond:null};var durationSecond=1e3,durationMinute=6e4,durationHour=36e5,durationDay=864e5,durationWeek=6048e5,second=newInterval(function(e){e.setTime(Math.floor(e/durationSecond)*durationSecond)},function(e,t){e.setTime(+e+t*durationSecond)},function(e,t){return(t-e)/durationSecond},function(e){return e.getUTCSeconds()}),minute=newInterval(function(e){e.setTime(Math.floor(e/durationMinute)*durationMinute)},function(e,t){e.setTime(+e+t*durationMinute)},function(e,t){return(t-e)/durationMinute},function(e){return e.getMinutes()}),hour=newInterval(function(e){var t=e.getTimezoneOffset()*durationMinute%durationHour;t<0&&(t+=durationHour),e.setTime(Math.floor((+e-t)/durationHour)*durationHour+t)},function(e,t){e.setTime(+e+t*durationHour)},function(e,t){return(t-e)/durationHour},function(e){return e.getHours()}),day=newInterval(function(e){e.setHours(0,0,0,0)},function(e,t){e.setDate(e.getDate()+t)},function(e,t){return(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*durationMinute)/durationDay},function(e){return e.getDate()-1});function weekday(t){return newInterval(function(e){e.setDate(e.getDate()-(e.getDay()+7-t)%7),e.setHours(0,0,0,0)},function(e,t){e.setDate(e.getDate()+7*t)},function(e,t){return(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*durationMinute)/durationWeek})}var sunday=weekday(0),monday=weekday(1),tuesday=weekday(2),wednesday=weekday(3),thursday=weekday(4),friday=weekday(5),saturday=weekday(6),sundays=sunday.range,mondays=monday.range,thursdays=thursday.range,month=newInterval(function(e){e.setDate(1),e.setHours(0,0,0,0)},function(e,t){e.setMonth(e.getMonth()+t)},function(e,t){return t.getMonth()-e.getMonth()+12*(t.getFullYear()-e.getFullYear())},function(e){return e.getMonth()}),year=newInterval(function(e){e.setMonth(0,1),e.setHours(0,0,0,0)},function(e,t){e.setFullYear(e.getFullYear()+t)},function(e,t){return t.getFullYear()-e.getFullYear()},function(e){return e.getFullYear()});year.every=function(n){return isFinite(n=Math.floor(n))&&0<n?newInterval(function(e){e.setFullYear(Math.floor(e.getFullYear()/n)*n),e.setMonth(0,1),e.setHours(0,0,0,0)},function(e,t){e.setFullYear(e.getFullYear()+t*n)}):null};var utcMinute=newInterval(function(e){e.setUTCSeconds(0,0)},function(e,t){e.setTime(+e+t*durationMinute)},function(e,t){return(t-e)/durationMinute},function(e){return e.getUTCMinutes()}),utcHour=newInterval(function(e){e.setUTCMinutes(0,0,0)},function(e,t){e.setTime(+e+t*durationHour)},function(e,t){return(t-e)/durationHour},function(e){return e.getUTCHours()}),utcDay=newInterval(function(e){e.setUTCHours(0,0,0,0)},function(e,t){e.setUTCDate(e.getUTCDate()+t)},function(e,t){return(t-e)/durationDay},function(e){return e.getUTCDate()-1});function utcWeekday(t){return newInterval(function(e){e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-t)%7),e.setUTCHours(0,0,0,0)},function(e,t){e.setUTCDate(e.getUTCDate()+7*t)},function(e,t){return(t-e)/durationWeek})}var utcSunday=utcWeekday(0),utcMonday=utcWeekday(1),utcTuesday=utcWeekday(2),utcWednesday=utcWeekday(3),utcThursday=utcWeekday(4),utcFriday=utcWeekday(5),utcSaturday=utcWeekday(6),utcSundays=utcSunday.range,utcMondays=utcMonday.range,utcThursdays=utcThursday.range,utcMonth=newInterval(function(e){e.setUTCDate(1),e.setUTCHours(0,0,0,0)},function(e,t){e.setUTCMonth(e.getUTCMonth()+t)},function(e,t){return t.getUTCMonth()-e.getUTCMonth()+12*(t.getUTCFullYear()-e.getUTCFullYear())},function(e){return e.getUTCMonth()}),utcYear=newInterval(function(e){e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},function(e,t){e.setUTCFullYear(e.getUTCFullYear()+t)},function(e,t){return t.getUTCFullYear()-e.getUTCFullYear()},function(e){return e.getUTCFullYear()});function localDate(e){if(0<=e.y&&e.y<100){var t=new Date(-1,e.m,e.d,e.H,e.M,e.S,e.L);return t.setFullYear(e.y),t}return new Date(e.y,e.m,e.d,e.H,e.M,e.S,e.L)}function utcDate(e){if(0<=e.y&&e.y<100){var t=new Date(Date.UTC(-1,e.m,e.d,e.H,e.M,e.S,e.L));return t.setUTCFullYear(e.y),t}return new Date(Date.UTC(e.y,e.m,e.d,e.H,e.M,e.S,e.L))}function newYear(e){return{y:e,m:0,d:1,H:0,M:0,S:0,L:0}}function formatLocale(e){var r=e.dateTime,o=e.date,i=e.time,t=e.periods,n=e.days,u=e.shortDays,s=e.months,a=e.shortMonths,c=formatRe(t),p=formatLookup(t),l=formatRe(n),f=formatLookup(n),h=formatRe(u),d=formatLookup(u),g=formatRe(s),y=formatLookup(s),m=formatRe(a),b=formatLookup(a),v={a:function(e){return u[e.getDay()]},A:function(e){return n[e.getDay()]},b:function(e){return a[e.getMonth()]},B:function(e){return s[e.getMonth()]},c:null,d:formatDayOfMonth,e:formatDayOfMonth,f:formatMicroseconds,H:formatHour24,I:formatHour12,j:formatDayOfYear,L:formatMilliseconds,m:formatMonthNumber,M:formatMinutes,p:function(e){return t[+(12<=e.getHours())]},Q:formatUnixTimestamp,s:formatUnixTimestampSeconds,S:formatSeconds,u:formatWeekdayNumberMonday,U:formatWeekNumberSunday,V:formatWeekNumberISO,w:formatWeekdayNumberSunday,W:formatWeekNumberMonday,x:null,X:null,y:formatYear,Y:formatFullYear,Z:formatZone,"%":formatLiteralPercent},S={a:function(e){return u[e.getUTCDay()]},A:function(e){return n[e.getUTCDay()]},b:function(e){return a[e.getUTCMonth()]},B:function(e){return s[e.getUTCMonth()]},c:null,d:formatUTCDayOfMonth,e:formatUTCDayOfMonth,f:formatUTCMicroseconds,H:formatUTCHour24,I:formatUTCHour12,j:formatUTCDayOfYear,L:formatUTCMilliseconds,m:formatUTCMonthNumber,M:formatUTCMinutes,p:function(e){return t[+(12<=e.getUTCHours())]},Q:formatUnixTimestamp,s:formatUnixTimestampSeconds,S:formatUTCSeconds,u:formatUTCWeekdayNumberMonday,U:formatUTCWeekNumberSunday,V:formatUTCWeekNumberISO,w:formatUTCWeekdayNumberSunday,W:formatUTCWeekNumberMonday,x:null,X:null,y:formatUTCYear,Y:formatUTCFullYear,Z:formatUTCZone,"%":formatLiteralPercent},C={a:function(e,t,n){var r=h.exec(t.slice(n));return r?(e.w=d[r[0].toLowerCase()],n+r[0].length):-1},A:function(e,t,n){var r=l.exec(t.slice(n));return r?(e.w=f[r[0].toLowerCase()],n+r[0].length):-1},b:function(e,t,n){var r=m.exec(t.slice(n));return r?(e.m=b[r[0].toLowerCase()],n+r[0].length):-1},B:function(e,t,n){var r=g.exec(t.slice(n));return r?(e.m=y[r[0].toLowerCase()],n+r[0].length):-1},c:function(e,t,n){return w(e,r,t,n)},d:parseDayOfMonth,e:parseDayOfMonth,f:parseMicroseconds,H:parseHour24,I:parseHour24,j:parseDayOfYear,L:parseMilliseconds,m:parseMonthNumber,M:parseMinutes,p:function(e,t,n){var r=c.exec(t.slice(n));return r?(e.p=p[r[0].toLowerCase()],n+r[0].length):-1},Q:parseUnixTimestamp,s:parseUnixTimestampSeconds,S:parseSeconds,u:parseWeekdayNumberMonday,U:parseWeekNumberSunday,V:parseWeekNumberISO,w:parseWeekdayNumberSunday,W:parseWeekNumberMonday,x:function(e,t,n){return w(e,o,t,n)},X:function(e,t,n){return w(e,i,t,n)},y:parseYear,Y:parseFullYear,Z:parseZone,"%":parseLiteralPercent};function _(a,c){return function(e){var t,n,r,o=[],i=-1,u=0,s=a.length;for(e instanceof Date||(e=new Date(+e));++i<s;)37===a.charCodeAt(i)&&(o.push(a.slice(u,i)),null!=(n=pads[t=a.charAt(++i)])?t=a.charAt(++i):n="e"===t?" ":"0",(r=c[t])&&(t=r(e,n)),o.push(t),u=i+1);return o.push(a.slice(u,i)),o.join("")}}function P(o,i){return function(e){var t,n,r=newYear(1900);if(w(r,o,e+="",0)!=e.length)return null;if("Q"in r)return new Date(r.Q);if("p"in r&&(r.H=r.H%12+12*r.p),"V"in r){if(r.V<1||53<r.V)return null;"w"in r||(r.w=1),r.d="Z"in r?(t=4<(n=(t=utcDate(newYear(r.y))).getUTCDay())||0===n?utcMonday.ceil(t):utcMonday(t),t=utcDay.offset(t,7*(r.V-1)),r.y=t.getUTCFullYear(),r.m=t.getUTCMonth(),t.getUTCDate()+(r.w+6)%7):(t=4<(n=(t=i(newYear(r.y))).getDay())||0===n?monday.ceil(t):monday(t),t=day.offset(t,7*(r.V-1)),r.y=t.getFullYear(),r.m=t.getMonth(),t.getDate()+(r.w+6)%7)}else("W"in r||"U"in r)&&("w"in r||(r.w="u"in r?r.u%7:"W"in r?1:0),n="Z"in r?utcDate(newYear(r.y)).getUTCDay():i(newYear(r.y)).getDay(),r.m=0,r.d="W"in r?(r.w+6)%7+7*r.W-(n+5)%7:r.w+7*r.U-(n+6)%7);return"Z"in r?(r.H+=r.Z/100|0,r.M+=r.Z%100,utcDate(r)):i(r)}}function w(e,t,n,r){for(var o,i,u=0,s=t.length,a=n.length;u<s;){if(a<=r)return-1;if(37===(o=t.charCodeAt(u++))){if(o=t.charAt(u++),!(i=C[o in pads?t.charAt(u++):o])||(r=i(e,n,r))<0)return-1}else if(o!=n.charCodeAt(r++))return-1}return r}return v.x=_(o,v),v.X=_(i,v),v.c=_(r,v),S.x=_(o,S),S.X=_(i,S),S.c=_(r,S),{format:function(e){var t=_(e+="",v);return t.toString=function(){return e},t},parse:function(e){var t=P(e+="",localDate);return t.toString=function(){return e},t},utcFormat:function(e){var t=_(e+="",S);return t.toString=function(){return e},t},utcParse:function(e){var t=P(e,utcDate);return t.toString=function(){return e},t}}}utcYear.every=function(n){return isFinite(n=Math.floor(n))&&0<n?newInterval(function(e){e.setUTCFullYear(Math.floor(e.getUTCFullYear()/n)*n),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},function(e,t){e.setUTCFullYear(e.getUTCFullYear()+t*n)}):null};var locale,timeFormat,timeParse,utcFormat,utcParse,pads={"-":"",_:" ",0:"0"},numberRe=/^\s*\d+/,percentRe=/^%/,requoteRe=/[\\^$*+?|[\]().{}]/g;function pad(e,t,n){var r=e<0?"-":"",o=(r?-e:e)+"",i=o.length;return r+(i<n?new Array(n-i+1).join(t)+o:o)}function requote(e){return e.replace(requoteRe,"\\$&")}function formatRe(e){return new RegExp("^(?:"+e.map(requote).join("|")+")","i")}function formatLookup(e){for(var t={},n=-1,r=e.length;++n<r;)t[e[n].toLowerCase()]=n;return t}function parseWeekdayNumberSunday(e,t,n){var r=numberRe.exec(t.slice(n,n+1));return r?(e.w=+r[0],n+r[0].length):-1}function parseWeekdayNumberMonday(e,t,n){var r=numberRe.exec(t.slice(n,n+1));return r?(e.u=+r[0],n+r[0].length):-1}function parseWeekNumberSunday(e,t,n){var r=numberRe.exec(t.slice(n,n+2));return r?(e.U=+r[0],n+r[0].length):-1}function parseWeekNumberISO(e,t,n){var r=numberRe.exec(t.slice(n,n+2));return r?(e.V=+r[0],n+r[0].length):-1}function parseWeekNumberMonday(e,t,n){var r=numberRe.exec(t.slice(n,n+2));return r?(e.W=+r[0],n+r[0].length):-1}function parseFullYear(e,t,n){var r=numberRe.exec(t.slice(n,n+4));return r?(e.y=+r[0],n+r[0].length):-1}function parseYear(e,t,n){var r=numberRe.exec(t.slice(n,n+2));return r?(e.y=+r[0]+(68<+r[0]?1900:2e3),n+r[0].length):-1}function parseZone(e,t,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(n,n+6));return r?(e.Z=r[1]?0:-(r[2]+(r[3]||"00")),n+r[0].length):-1}function parseMonthNumber(e,t,n){var r=numberRe.exec(t.slice(n,n+2));return r?(e.m=r[0]-1,n+r[0].length):-1}function parseDayOfMonth(e,t,n){var r=numberRe.exec(t.slice(n,n+2));return r?(e.d=+r[0],n+r[0].length):-1}function parseDayOfYear(e,t,n){var r=numberRe.exec(t.slice(n,n+3));return r?(e.m=0,e.d=+r[0],n+r[0].length):-1}function parseHour24(e,t,n){var r=numberRe.exec(t.slice(n,n+2));return r?(e.H=+r[0],n+r[0].length):-1}function parseMinutes(e,t,n){var r=numberRe.exec(t.slice(n,n+2));return r?(e.M=+r[0],n+r[0].length):-1}function parseSeconds(e,t,n){var r=numberRe.exec(t.slice(n,n+2));return r?(e.S=+r[0],n+r[0].length):-1}function parseMilliseconds(e,t,n){var r=numberRe.exec(t.slice(n,n+3));return r?(e.L=+r[0],n+r[0].length):-1}function parseMicroseconds(e,t,n){var r=numberRe.exec(t.slice(n,n+6));return r?(e.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function parseLiteralPercent(e,t,n){var r=percentRe.exec(t.slice(n,n+1));return r?n+r[0].length:-1}function parseUnixTimestamp(e,t,n){var r=numberRe.exec(t.slice(n));return r?(e.Q=+r[0],n+r[0].length):-1}function parseUnixTimestampSeconds(e,t,n){var r=numberRe.exec(t.slice(n));return r?(e.Q=1e3*+r[0],n+r[0].length):-1}function formatDayOfMonth(e,t){return pad(e.getDate(),t,2)}function formatHour24(e,t){return pad(e.getHours(),t,2)}function formatHour12(e,t){return pad(e.getHours()%12||12,t,2)}function formatDayOfYear(e,t){return pad(1+day.count(year(e),e),t,3)}function formatMilliseconds(e,t){return pad(e.getMilliseconds(),t,3)}function formatMicroseconds(e,t){return formatMilliseconds(e,t)+"000"}function formatMonthNumber(e,t){return pad(e.getMonth()+1,t,2)}function formatMinutes(e,t){return pad(e.getMinutes(),t,2)}function formatSeconds(e,t){return pad(e.getSeconds(),t,2)}function formatWeekdayNumberMonday(e){var t=e.getDay();return 0===t?7:t}function formatWeekNumberSunday(e,t){return pad(sunday.count(year(e),e),t,2)}function formatWeekNumberISO(e,t){var n=e.getDay();return e=4<=n||0===n?thursday(e):thursday.ceil(e),pad(thursday.count(year(e),e)+(4===year(e).getDay()),t,2)}function formatWeekdayNumberSunday(e){return e.getDay()}function formatWeekNumberMonday(e,t){return pad(monday.count(year(e),e),t,2)}function formatYear(e,t){return pad(e.getFullYear()%100,t,2)}function formatFullYear(e,t){return pad(e.getFullYear()%1e4,t,4)}function formatZone(e){var t=e.getTimezoneOffset();return(0<t?"-":(t*=-1,"+"))+pad(t/60|0,"0",2)+pad(t%60,"0",2)}function formatUTCDayOfMonth(e,t){return pad(e.getUTCDate(),t,2)}function formatUTCHour24(e,t){return pad(e.getUTCHours(),t,2)}function formatUTCHour12(e,t){return pad(e.getUTCHours()%12||12,t,2)}function formatUTCDayOfYear(e,t){return pad(1+utcDay.count(utcYear(e),e),t,3)}function formatUTCMilliseconds(e,t){return pad(e.getUTCMilliseconds(),t,3)}function formatUTCMicroseconds(e,t){return formatUTCMilliseconds(e,t)+"000"}function formatUTCMonthNumber(e,t){return pad(e.getUTCMonth()+1,t,2)}function formatUTCMinutes(e,t){return pad(e.getUTCMinutes(),t,2)}function formatUTCSeconds(e,t){return pad(e.getUTCSeconds(),t,2)}function formatUTCWeekdayNumberMonday(e){var t=e.getUTCDay();return 0===t?7:t}function formatUTCWeekNumberSunday(e,t){return pad(utcSunday.count(utcYear(e),e),t,2)}function formatUTCWeekNumberISO(e,t){var n=e.getUTCDay();return e=4<=n||0===n?utcThursday(e):utcThursday.ceil(e),pad(utcThursday.count(utcYear(e),e)+(4===utcYear(e).getUTCDay()),t,2)}function formatUTCWeekdayNumberSunday(e){return e.getUTCDay()}function formatUTCWeekNumberMonday(e,t){return pad(utcMonday.count(utcYear(e),e),t,2)}function formatUTCYear(e,t){return pad(e.getUTCFullYear()%100,t,2)}function formatUTCFullYear(e,t){return pad(e.getUTCFullYear()%1e4,t,4)}function formatUTCZone(){return"+0000"}function formatLiteralPercent(){return"%"}function formatUnixTimestamp(e){return+e}function formatUnixTimestampSeconds(e){return Math.floor(+e/1e3)}function defaultLocale(e){return locale=formatLocale(e),timeFormat=locale.format,timeParse=locale.parse,utcFormat=locale.utcFormat,utcParse=locale.utcParse,locale}defaultLocale({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});var isoSpecifier="%Y-%m-%dT%H:%M:%S.%LZ";function formatIsoNative(e){return e.toISOString()}var formatIso=Date.prototype.toISOString?formatIsoNative:utcFormat(isoSpecifier);function parseIsoNative(e){var t=new Date(e);return isNaN(t)?null:t}var parseIso=+new Date("2000-01-01T00:00:00.000Z")?parseIsoNative:utcParse(isoSpecifier),ECLGraph=function(a){function e(e,t,n){var r=a.call(this)||this;r.wu=e;for(var o=0,i=0,u=n;i<u.length;i++){var s=u[i];if(s.GraphName===t.Name&&!s.HasSubGraphId){o=Math.round(1e3*s.Seconds)/1e3;break}}return r.set(__assign({Time:o},t)),r}return __extends(e,a),Object.defineProperty(e.prototype,"properties",{get:function(){return this.get()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Name",{get:function(){return this.get("Name")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Label",{get:function(){return this.get("Label")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Type",{get:function(){return this.get("Type")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Complete",{get:function(){return this.get("Complete")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"WhenStarted",{get:function(){return this.get("WhenStarted")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"WhenFinished",{get:function(){return this.get("WhenFinished")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Time",{get:function(){return this.get("Time")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Running",{get:function(){return this.get("Running")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"RunningId",{get:function(){return this.get("RunningId")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Failed",{get:function(){return this.get("Failed")},enumerable:!0,configurable:!0}),e.prototype.fetchScopeGraph=function(e){return e?this.wu.fetchGraphDetails([e],["subgraph"]).then(function(e){return createGraph(e)}):this.wu.fetchGraphDetails([this.Name],["graph"]).then(function(e){return createGraph(e)})},e}(util.StateObject),GraphCache=function(e){function t(){return e.call(this,function(e){return util.Cache.hash([e.Name])})||this}return __extends(t,e),t}(util.Cache);function walkXmlJson(e,t,n){(n=n||[]).push(e),t(e.name,e.$,e.children(),n),e.children().forEach(function(e){walkXmlJson(e,t,n)}),n.pop()}function flattenAtt(e){var t={};return e.forEach(function(e){"att"===e.name&&(t[e.$.name]=e.$.value)}),t}var XGMMLGraph=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t}(util.Graph),XGMMLSubgraph=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t}(util.Subgraph),XGMMLVertex=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t}(util.Vertex),XGMMLEdge=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t}(util.Edge);function createXGMMLGraph(e,t){var a={},c={},p={},n=new XGMMLGraph(function(e){return e._.id}),l=[n.root];return walkXmlJson(t,function(e,t,n,r){var o=l[l.length-1];switch(e){case"graph":break;case"node":if(n.length&&n[0].children().length&&"graph"===n[0].children()[0].name){var i=o.createSubgraph(flattenAtt(n));l.push(i),a[t.id]=i}var u=o.createVertex(flattenAtt(n));c[t.id]=u;break;case"edge":var s=o.createEdge(c[t.source],c[t.target],flattenAtt(n));p[t.id]=s}}),n}var ScopeGraph=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t}(util.Graph),ScopeSubgraph=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t}(util.Subgraph),ScopeVertex=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t}(util.Vertex),ScopeEdge=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t}(util.Edge);function createGraph(e){for(var t,n={},r={},o=0,i=e;o<i.length;o++){switch((l=i[o]).ScopeType){case"graph":t=new ScopeGraph(function(e){return e._.Id},l),n[l.ScopeName]=t.root;break;case"subgraph":t||(t=new ScopeGraph(function(e){return e._.Id},l),n[l.ScopeName]=t.root);for(var u=l.parentScope().split(":"),s=n[l.parentScope()];u.length&&!s;)s=n[u.join(":")],u.pop();if(s){var a=s;n[l.ScopeName]=a.createSubgraph(l)}else console.log("Missing SG:Parent ("+l.Id+"): "+l.parentScope());break;case"activity":var c=n[l.parentScope()];c?c.createVertex(l):console.log("Missing A:Parent ("+l.Id+"): "+l.parentScope());break;case"edge":r[l.ScopeName]=l}}for(var p in r){var l,f=n[(l=r[p]).parentScope()];if(f){var h=f;try{var d=t.vertex(l.attr("IdSource").RawValue),g=t.vertex(l.attr("IdTarget").RawValue);h.createEdge(d,g,l)}catch(e){console.log("Invalid Edge: "+p)}}else console.log("Missing E:Parent ("+l.Id+"): "+l.parentScope())}return t}var Resource=function(a){function e(e,t){var n=a.call(this)||this;n.wu=e;var r=t.split("\\").join("/"),o=r.split("/"),i="res/"+n.wu.Wuid+"/",u="",s="";return 0===r.indexOf(i)&&(u=r.substr(i.length),s=o[o.length-1]),n.set({URL:t,DisplayName:s,DisplayPath:u}),n}return __extends(e,a),Object.defineProperty(e.prototype,"properties",{get:function(){return this.get()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"URL",{get:function(){return this.get("URL")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"DisplayName",{get:function(){return this.get("DisplayName")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"DisplayPath",{get:function(){return this.get("DisplayPath")},enumerable:!0,configurable:!0}),e}(util.StateObject),XSDNode=function(){function e(e){this.e=e}return e.prototype.fix=function(){delete this.e},e}(),XSDXMLNode=function(r){function e(e){var t=r.call(this,e)||this;return t.attrs={},t._children=[],t}return __extends(e,r),e.prototype.append=function(e){this._children.push(e),this.type||(this.type="hpcc:childDataset")},e.prototype.fix=function(){var e;this.name=this.e.$.name,this.type=this.e.$.type;for(var t=this._children.length-1;0<=t;--t){var n=this._children[t];"Row"===n.name&&void 0===n.type&&((e=this._children).push.apply(e,n._children),this._children.splice(t,1))}r.prototype.fix.call(this)},e.prototype.children=function(){return this._children},e.prototype.charWidth=function(){var e=-1;switch(this.type){case"xs:boolean":e=5;break;case"xs:integer":case"xs:nonNegativeInteger":case"xs:double":e=8;break;case"xs:string":e=32;break;default:for(var t=this.type.lastIndexOf("_"),n=0<t?t:this.type.length,r=n-1;0<=r&&-1!=="0123456789".indexOf(this.type.charAt(r));--r);r+1<n&&(e=parseInt(this.type.substring(r+1,n),10)),0===this.type.indexOf("data")&&(e*=2)}return e<this.name.length&&(e=this.name.length),e},e}(XSDNode),XSDSimpleType=function(t){function e(e){return t.call(this,e)||this}return __extends(e,t),e.prototype.append=function(e){switch(e.name){case"xs:restriction":this._restricition=e;break;case"xs:maxLength":this._maxLength=e}},e.prototype.fix=function(){this.name=this.e.$.name,this.type=this._restricition.$.base,this.maxLength=this._maxLength?+this._maxLength.$.value:void 0,delete this._restricition,delete this._maxLength,t.prototype.fix.call(this)},e}(XSDNode),XSDSchema=function(){function e(){this.simpleTypes={}}return e.prototype.fields=function(){return this.root.children()},e}(),XSDParser=function(r){function e(){var e=null!==r&&r.apply(this,arguments)||this;return e.schema=new XSDSchema,e.simpleTypes={},e.xsdStack=new util.Stack,e}return __extends(e,r),e.prototype.startXMLNode=function(e){switch(r.prototype.startXMLNode.call(this,e),e.name){case"xs:element":var t=new XSDXMLNode(e);this.schema.root?this.xsdStack.depth()&&this.xsdStack.top().append(t):this.schema.root=t,this.xsdStack.push(t);break;case"xs:simpleType":this.simpleType=new XSDSimpleType(e)}},e.prototype.endXMLNode=function(e){switch(e.name){case"xs:element":this.xsdStack.pop().fix();break;case"xs:simpleType":this.simpleType.fix(),this.simpleTypes[this.simpleType.name]=this.simpleType,delete this.simpleType;break;case"xs:appinfo":var t=this.xsdStack.top();for(var n in e.$)t.attrs[n]=e.$[n];break;default:this.simpleType&&this.simpleType.append(e)}r.prototype.endXMLNode.call(this,e)},e}(util.SAXStackParser);function parseXSD(e){var t=new XSDParser;return t.parse(e),t.schema}var XSDParser2=function(n){function e(e){var t=n.call(this)||this;return t.schema=new XSDSchema,t.simpleTypes={},t.xsdStack=new util.Stack,t._rootName=e,t}return __extends(e,n),e.prototype.startXMLNode=function(e){switch(n.prototype.startXMLNode.call(this,e),e.name){case"xsd:element":var t=new XSDXMLNode(e);this.schema.root||this._rootName!==e.$.name||(this.schema.root=t),this.xsdStack.depth()&&this.xsdStack.top().append(t),this.xsdStack.push(t);break;case"xsd:simpleType":this.simpleType=new XSDSimpleType(e)}},e.prototype.endXMLNode=function(e){switch(e.name){case"xsd:element":this.xsdStack.pop().fix()}n.prototype.endXMLNode.call(this,e)},e}(XSDParser);function parseXSD2(e,t){var n=new XSDParser2(t);return n.parse(e),n.schema}var _activity,GlobalResultCache=function(e){function t(){return e.call(this,function(e){return e.Wuid+"/"+e.ResultName})||this}return __extends(t,e),t}(util.Cache),_results=new GlobalResultCache,Result=function(i){function u(e,t,n,r){void 0===r&&(r=[]);var o=i.call(this)||this;return o.connection=e instanceof WorkunitsService?e:new WorkunitsService(e),void 0===n?o.set({LogicalFileName:t}):"string"==typeof n?o.set({Wuid:t,ResultName:n,ResultViews:r}):"number"==typeof n?o.set({Wuid:t,ResultSequence:n,ResultViews:r}):o.set(__assign({Wuid:t,ResultName:n.Name,ResultViews:r},n)),o}return __extends(u,i),Object.defineProperty(u.prototype,"properties",{get:function(){return this.get()},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"Wuid",{get:function(){return this.get("Wuid")},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"ResultName",{get:function(){return this.get("ResultName")},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"ResultSequence",{get:function(){return this.get("ResultSequence")},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"LogicalFileName",{get:function(){return this.get("LogicalFileName")},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"Name",{get:function(){return this.get("Name")},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"Sequence",{get:function(){return this.get("Sequence")},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"Value",{get:function(){return this.get("Value")},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"Link",{get:function(){return this.get("Link")},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"FileName",{get:function(){return this.get("FileName")},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"IsSupplied",{get:function(){return this.get("IsSupplied")},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"ShowFileContent",{get:function(){return this.get("ShowFileContent")},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"Total",{get:function(){return this.get("Total")},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"ECLSchemas",{get:function(){return this.get("ECLSchemas")},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"NodeGroup",{get:function(){return this.get("NodeGroup")},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"ResultViews",{get:function(){return this.get("ResultViews")},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"XmlSchema",{get:function(){return this.get("XmlSchema")},enumerable:!0,configurable:!0}),u.attach=function(e,t,n,r){var o=_results.get({Wuid:t,ResultName:n},function(){return new u(e,t,n)});return r&&o.set(r),o},u.prototype.isComplete=function(){return-1!==this.Total},u.prototype.fetchXMLSchema=function(){var t=this;return this.xsdSchema?Promise.resolve(this.xsdSchema):this.WUResult().then(function(e){return util.exists("Result.XmlSchema.xml",e)?(t.xsdSchema=parseXSD(e.Result.XmlSchema.xml),t.xsdSchema):null})},u.prototype.refresh=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,this.fetchRows(0,1,!0)];case 1:return e.sent(),[2,this]}})})},u.prototype.fetchRows=function(e,t,n,r){var o=this;return void 0===e&&(e=0),void 0===t&&(t=-1),void 0===n&&(n=!1),void 0===r&&(r={}),this.WUResult(e,t,!n,r).then(function(e){var t=e.Result;return delete e.Result,o.set(__assign({},e)),util.exists("XmlSchema.xml",t)&&(o.xsdSchema=parseXSD(t.XmlSchema.xml)),util.exists("Row",t)?t.Row:o.ResultName&&util.exists(o.ResultName,t)?t[o.ResultName].Row:[]})},u.prototype.rootField=function(){return this.xsdSchema?this.xsdSchema.root:null},u.prototype.fields=function(){return this.xsdSchema?this.xsdSchema.root.children():[]},u.prototype.WUResult=function(e,t,n,r){void 0===e&&(e=0),void 0===t&&(t=1),void 0===n&&(n=!1),void 0===r&&(r={});var o={NamedValue:{itemcount:0}};for(var i in r)o.NamedValue[o.NamedValue.itemcount++]={Name:i,Value:r[i]};var u={FilterBy:o};return this.Wuid&&void 0!==this.ResultName?(u.Wuid=this.Wuid,u.ResultName=this.ResultName):this.Wuid&&void 0!==this.ResultSequence?(u.Wuid=this.Wuid,u.Sequence=this.ResultSequence):this.LogicalFileName&&this.NodeGroup?(u.LogicalName=this.LogicalFileName,u.Cluster=this.NodeGroup):this.LogicalFileName&&(u.LogicalName=this.LogicalFileName),u.Start=e,u.Count=t,u.SuppressXmlSchema=n,this.connection.WUResult(u).then(function(e){return e})},u}(util.StateObject),ResultCache=function(e){function t(){return e.call(this,function(e){return util.Cache.hash([e.Sequence,e.Name,e.FileName])})||this}return __extends(t,e),t}(util.Cache),Attribute=function(r){function e(e,t){var n=r.call(this)||this;return n.scope=e,n.set(t),n}return __extends(e,r),Object.defineProperty(e.prototype,"properties",{get:function(){return this.get()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Name",{get:function(){return this.get("Name")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"RawValue",{get:function(){return this.get("RawValue")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Formatted",{get:function(){return this.get("Formatted")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"FormattedEnd",{get:function(){return this.get("FormattedEnd")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Measure",{get:function(){return this.get("Measure")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Creator",{get:function(){return this.get("Creator")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"CreatorType",{get:function(){return this.get("CreatorType")},enumerable:!0,configurable:!0}),e}(util.StateObject),BaseScope=function(n){function e(e){var t=n.call(this)||this;return t._attributeMap={},t._children=[],t.update(e),t}return __extends(e,n),Object.defineProperty(e.prototype,"properties",{get:function(){return this.get()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"ScopeName",{get:function(){return this.get("ScopeName")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Id",{get:function(){return this.get("Id")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"ScopeType",{get:function(){return this.get("ScopeType")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Properties",{get:function(){return this.get("Properties",{Property:[]})},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"CAttributes",{get:function(){var t=this,n=[],r={start:null,end:null};return this.Properties.Property.forEach(function(e){"ts"===e.Measure&&0<=e.Name.indexOf("Started")?r.start=e:t.ScopeName&&"ts"===e.Measure&&0<=e.Name.indexOf("Finished")?r.end=e:n.push(new Attribute(t,e))}),r.start&&r.end?(r.start.FormattedEnd=r.end.Formatted,n.push(new Attribute(this,r.start))):r.start?n.push(new Attribute(this,r.start)):r.end&&n.push(new Attribute(this,r.end)),n},enumerable:!0,configurable:!0}),e.prototype.update=function(e){var t=this;for(var n in this.set(e),this.CAttributes.forEach(function(e){t._attributeMap[e.Name]=e}),this.Properties.Property=[],this._attributeMap)this._attributeMap.hasOwnProperty(n)&&this.Properties.Property.push(this._attributeMap[n].properties)},e.prototype.parentScope=function(){var e=this.ScopeName.split(":");return e.pop(),e.join(":")},e.prototype.children=function(e){return arguments.length?(this._children=e,this):this._children},e.prototype.walk=function(e){if(e.start(this))return!0;for(var t=0,n=this.children();t<n.length;t++){if(n[t].walk(e))return!0}return e.end(this)},e.prototype.formattedAttrs=function(){var e={};for(var t in this._attributeMap)e[t]=this._attributeMap[t].Formatted||this._attributeMap[t].RawValue;return e},e.prototype.rawAttrs=function(){var e={};for(var t in this._attributeMap)e[t]=this._attributeMap[t].RawValue;return e},e.prototype.hasAttr=function(e){return void 0!==this._attributeMap[e]},e.prototype.attr=function(e){return this._attributeMap[e]||new Attribute(this,{Creator:"",CreatorType:"",Formatted:"",Measure:"",Name:"",RawValue:""})},e.prototype.attrMeasure=function(e){return this._attributeMap[e].Measure},e.prototype.calcTooltip=function(e){var t="",n=[];t=this.Id,n.push('<tr><td class="key">ID:</td><td class="value">'+this.Id+"</td></tr>"),e&&n.push('<tr><td class="key">Parent ID:</td><td class="value">'+e.Id+"</td></tr>"),n.push('<tr><td class="key">Scope:</td><td class="value">'+this.ScopeName+"</td></tr>");var r=this.formattedAttrs();for(var o in r)"Label"===o?t=r[o]:n.push('<tr><td class="key">'+o+'</td><td class="value">'+r[o]+"</td></tr>");return'<div class="eclwatch_WUGraph_Tooltip" style="max-width:480px">\n <h4 align="center">'+t+"</h4>\n <table>\n "+n.join("")+"\n </table>\n </div>"},e}(util.StateObject),Scope=function(r){function e(e,t){var n=r.call(this,t)||this;return n.wu=e,n}return __extends(e,r),e}(BaseScope),SourceFile=function(o){function e(e,t,n){var r=o.call(this)||this;return r.connection=e instanceof WorkunitsService?e:new WorkunitsService(e),r.set(__assign({Wuid:t},n)),r}return __extends(e,o),Object.defineProperty(e.prototype,"properties",{get:function(){return this.get()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Wuid",{get:function(){return this.get("Wuid")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"FileCluster",{get:function(){return this.get("FileCluster")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Name",{get:function(){return this.get("Name")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"IsSuperFile",{get:function(){return this.get("IsSuperFile")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Subs",{get:function(){return this.get("Subs")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Count",{get:function(){return this.get("Count")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"ECLSourceFiles",{get:function(){return this.get("ECLSourceFiles")},enumera