UNPKG

244 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, '__esModule', { value: true });
4
5function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
7var util = require('@hpcc-js/util');
8var xmldom = require('xmldom');
9var fetch$1 = _interopDefault(require('node-fetch'));
10var safeBuffer = require('safe-buffer');
11var cp = require('child_process');
12var fs = require('fs');
13var os = require('os');
14var path = require('path');
15var tmp = require('tmp');
16
17var PKG_NAME = "@hpcc-js/comms";
18var PKG_VERSION = "2.17.0";
19var BUILD_VERSION = "2.20.0";
20
21/*! *****************************************************************************
22Copyright (c) Microsoft Corporation. All rights reserved.
23Licensed under the Apache License, Version 2.0 (the "License"); you may not use
24this file except in compliance with the License. You may obtain a copy of the
25License at http://www.apache.org/licenses/LICENSE-2.0
26
27THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
28KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
29WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
30MERCHANTABLITY OR NON-INFRINGEMENT.
31
32See the Apache Version 2.0 License for specific language governing permissions
33and limitations under the License.
34***************************************************************************** */
35/* global Reflect, Promise */
36
37var extendStatics = function(d, b) {
38 extendStatics = Object.setPrototypeOf ||
39 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
40 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
41 return extendStatics(d, b);
42};
43
44function __extends(d, b) {
45 extendStatics(d, b);
46 function __() { this.constructor = d; }
47 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
48}
49
50var __assign = function() {
51 __assign = Object.assign || function __assign(t) {
52 for (var s, i = 1, n = arguments.length; i < n; i++) {
53 s = arguments[i];
54 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
55 }
56 return t;
57 };
58 return __assign.apply(this, arguments);
59};
60
61function __awaiter(thisArg, _arguments, P, generator) {
62 return new (P || (P = Promise))(function (resolve, reject) {
63 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
64 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
65 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
66 step((generator = generator.apply(thisArg, _arguments || [])).next());
67 });
68}
69
70function __generator(thisArg, body) {
71 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
72 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
73 function verb(n) { return function (v) { return step([n, v]); }; }
74 function step(op) {
75 if (f) throw new TypeError("Generator is already executing.");
76 while (_) try {
77 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
78 if (y = 0, t) op = [op[0] & 2, t.value];
79 switch (op[0]) {
80 case 0: case 1: t = op; break;
81 case 4: _.label++; return { value: op[1], done: false };
82 case 5: _.label++; y = op[1]; op = [0]; continue;
83 case 7: op = _.ops.pop(); _.trys.pop(); continue;
84 default:
85 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
86 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
87 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
88 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
89 if (t[2]) _.ops.pop();
90 _.trys.pop(); continue;
91 }
92 op = body.call(thisArg, _);
93 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
94 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
95 }
96}
97
98function __spreadArrays() {
99 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
100 for (var r = Array(s), k = 0, i = 0; i < il; i++)
101 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
102 r[k] = a[j];
103 return r;
104}
105
106var logger = util.scopedLogger("comms/connection.ts");
107function instanceOfIOptions(object) {
108 return "baseUrl" in object;
109}
110var DefaultOptions = {
111 type: "post",
112 baseUrl: "",
113 userID: "",
114 password: "",
115 rejectUnauthorized: true,
116 timeoutSecs: 60
117};
118function instanceOfIConnection(object) {
119 return typeof object.opts === "function" &&
120 typeof object.send === "function" &&
121 typeof object.clone === "function";
122}
123// comms ---
124function encode(uriComponent, encodeRequest) {
125 return (encodeRequest === undefined || encodeRequest === true) ? encodeURIComponent(uriComponent) : "" + uriComponent;
126}
127function serializeRequest(obj, encodeRequest, prefix) {
128 if (encodeRequest === void 0) { encodeRequest = true; }
129 if (prefix === void 0) { prefix = ""; }
130 if (prefix) {
131 prefix += ".";
132 }
133 if (typeof obj !== "object") {
134 return encode(obj, encodeRequest);
135 }
136 var str = [];
137 var _loop_1 = function (key) {
138 if (obj.hasOwnProperty(key)) {
139 if (obj[key] instanceof Array) {
140 // Specific to ESP - but no REST standard exists...
141 var includeItemCount_1 = false;
142 obj[key].forEach(function (row, i) {
143 if (typeof row === "object") {
144 includeItemCount_1 = true;
145 str.push(serializeRequest(row, encodeRequest, prefix + encode(key + "." + i, encodeRequest)));
146 }
147 else {
148 str.push(prefix + encode(key + "_i" + i, encodeRequest) + "=" + serializeRequest(row, encodeRequest));
149 }
150 });
151 if (includeItemCount_1) {
152 str.push(prefix + encode(key + ".itemcount", encodeRequest) + "=" + obj[key].length);
153 }
154 }
155 else if (typeof obj[key] === "object") {
156 if (obj[key] && obj[key]["Item"] instanceof Array) { // Specific to ws_machine.GetTargetClusterInfo?
157 str.push(serializeRequest(obj[key]["Item"], encodeRequest, prefix + encode(key, encodeRequest)));
158 str.push(prefix + encode(key + ".itemcount", encodeRequest) + "=" + obj[key]["Item"].length);
159 }
160 else {
161 str.push(serializeRequest(obj[key], encodeRequest, prefix + encode(key, encodeRequest)));
162 }
163 }
164 else if (obj[key] !== undefined) {
165 str.push(prefix + encode(key, encodeRequest) + "=" + encode(obj[key], encodeRequest));
166 }
167 else {
168 str.push(prefix + encode(key, encodeRequest));
169 }
170 }
171 };
172 for (var key in obj) {
173 _loop_1(key);
174 }
175 return str.join("&");
176}
177function deserializeResponse(body) {
178 return JSON.parse(body);
179}
180function jsonp(opts, action, request, responseType, header) {
181 if (request === void 0) { request = {}; }
182 if (responseType === void 0) { responseType = "json"; }
183 if (header) {
184 console.warn("Header attributes ignored for JSONP connections");
185 }
186 return new Promise(function (resolve, reject) {
187 var respondedTimeout = opts.timeoutSecs * 1000;
188 var respondedTick = 5000;
189 var callbackName = "jsonp_callback_" + Math.round(Math.random() * 999999);
190 window[callbackName] = function (response) {
191 respondedTimeout = 0;
192 doCallback();
193 resolve(responseType === "json" && typeof response === "string" ? deserializeResponse(response) : response);
194 };
195 var script = document.createElement("script");
196 var url = util.join(opts.baseUrl, action);
197 url += url.indexOf("?") >= 0 ? "&" : "?";
198 script.src = url + "jsonp=" + callbackName + "&" + serializeRequest(request, opts.encodeRequest);
199 document.body.appendChild(script);
200 var progress = setInterval(function () {
201 if (respondedTimeout <= 0) {
202 clearInterval(progress);
203 }
204 else {
205 respondedTimeout -= respondedTick;
206 if (respondedTimeout <= 0) {
207 clearInterval(progress);
208 logger.error("Request timeout: " + script.src);
209 doCallback();
210 reject(Error("Request timeout: " + script.src));
211 }
212 else {
213 logger.debug("Request pending (" + respondedTimeout / 1000 + " sec): " + script.src);
214 }
215 }
216 }, respondedTick);
217 function doCallback() {
218 delete window[callbackName];
219 document.body.removeChild(script);
220 }
221 });
222}
223function authHeader(opts) {
224 return opts.userID ? { Authorization: "Basic " + btoa(opts.userID + ":" + opts.password) } : {};
225}
226// _omitMap is a workaround for older HPCC-Platform instances without credentials ---
227var _omitMap = {};
228function doFetch(opts, action, requestInit, headersInit, responseType) {
229 headersInit = __assign(__assign({}, authHeader(opts)), headersInit);
230 requestInit = __assign(__assign({ credentials: _omitMap[opts.baseUrl] ? "omit" : "include" }, requestInit), { headers: headersInit });
231 if (opts.rejectUnauthorized === false && fetch["__agent"] && opts.baseUrl.indexOf("https:") === 0) {
232 // NodeJS / node-fetch only ---
233 requestInit["agent"] = fetch["__agent"];
234 }
235 function handleResponse(response) {
236 if (response.ok) {
237 return responseType === "json" ? response.json() : response.text();
238 }
239 throw new Error(response.statusText);
240 }
241 return util.promiseTimeout(opts.timeoutSecs * 1000, fetch(util.join(opts.baseUrl, action), requestInit)
242 .then(handleResponse)
243 .catch(function (e) {
244 // Try again with the opposite credentials mode ---
245 requestInit.credentials = !_omitMap[opts.baseUrl] ? "omit" : "include";
246 return fetch(util.join(opts.baseUrl, action), requestInit)
247 .then(handleResponse)
248 .then(function (responseBody) {
249 _omitMap[opts.baseUrl] = !_omitMap[opts.baseUrl]; // The "opposite" credentials mode is known to work ---
250 return responseBody;
251 });
252 }));
253}
254function post(opts, action, request, responseType, header) {
255 if (responseType === void 0) { responseType = "json"; }
256 return doFetch(opts, action, {
257 method: "post",
258 body: serializeRequest(request, opts.encodeRequest)
259 }, __assign({ "Content-Type": "application/x-www-form-urlencoded" }, header), responseType);
260}
261function get(opts, action, request, responseType, header) {
262 if (responseType === void 0) { responseType = "json"; }
263 return doFetch(opts, action + "?" + serializeRequest(request, opts.encodeRequest), {
264 method: "get"
265 }, __assign({}, header), responseType);
266}
267function send(opts, action, request, responseType, header) {
268 if (responseType === void 0) { responseType = "json"; }
269 var retVal;
270 switch (opts.type) {
271 case "jsonp":
272 retVal = jsonp(opts, action, request, responseType, header);
273 break;
274 case "get":
275 retVal = get(opts, action, request, responseType, header);
276 break;
277 case "post":
278 default:
279 retVal = post(opts, action, request, responseType, header);
280 break;
281 }
282 return retVal;
283}
284var hookedSend = send;
285function hookSend(newSend) {
286 var retVal = hookedSend;
287 if (newSend) {
288 hookedSend = newSend;
289 }
290 return retVal;
291}
292var Connection = /** @class */ (function () {
293 function Connection(opts) {
294 this.opts(opts);
295 }
296 Object.defineProperty(Connection.prototype, "baseUrl", {
297 get: function () { return this._opts.baseUrl; },
298 enumerable: false,
299 configurable: true
300 });
301 Connection.prototype.opts = function (_) {
302 if (arguments.length === 0)
303 return this._opts;
304 this._opts = __assign(__assign({}, DefaultOptions), _);
305 return this;
306 };
307 Connection.prototype.send = function (action, request, responseType, header) {
308 if (responseType === void 0) { responseType = "json"; }
309 if (this._opts.hookSend) {
310 return this._opts.hookSend(this._opts, action, request, responseType, hookedSend, header);
311 }
312 return hookedSend(this._opts, action, request, responseType, header);
313 };
314 Connection.prototype.clone = function () {
315 return new Connection(this.opts());
316 };
317 return Connection;
318}());
319exports.createConnection = function (opts) {
320 return new Connection(opts);
321};
322function setTransportFactory(newFunc) {
323 var retVal = exports.createConnection;
324 exports.createConnection = newFunc;
325 return retVal;
326}
327
328function isArray(arg) {
329 return Object.prototype.toString.call(arg) === "[object Array]";
330}
331var ESPExceptions = /** @class */ (function (_super) {
332 __extends(ESPExceptions, _super);
333 function ESPExceptions(action, request, exceptions) {
334 var _this = _super.call(this, "ESPException: " + exceptions.Source) || this;
335 _this.isESPExceptions = true;
336 _this.action = action;
337 _this.request = request;
338 _this.Source = exceptions.Source;
339 _this.Exception = exceptions.Exception;
340 if (exceptions.Exception.length) {
341 _this.message = exceptions.Exception[0].Code + ": " + exceptions.Exception[0].Message;
342 }
343 return _this;
344 }
345 return ESPExceptions;
346}(Error));
347function isConnection(optsConnection) {
348 return optsConnection.send !== undefined;
349}
350var ESPConnection = /** @class */ (function () {
351 function ESPConnection(optsConnection, service, version) {
352 this._connection = isConnection(optsConnection) ? optsConnection : exports.createConnection(optsConnection);
353 this._service = service;
354 this._version = version;
355 }
356 Object.defineProperty(ESPConnection.prototype, "baseUrl", {
357 get: function () { return this._connection.opts().baseUrl; },
358 enumerable: false,
359 configurable: true
360 });
361 ESPConnection.prototype.service = function (_) {
362 if (_ === void 0)
363 return this._service;
364 this._service = _;
365 return this;
366 };
367 ESPConnection.prototype.version = function (_) {
368 if (_ === void 0)
369 return this._version;
370 this._version = _;
371 return this;
372 };
373 ESPConnection.prototype.toESPStringArray = function (target, arrayName) {
374 if (isArray(target[arrayName])) {
375 for (var i = 0; i < target[arrayName].length; ++i) {
376 target[arrayName + "_i" + i] = target[arrayName][i];
377 }
378 delete target[arrayName];
379 }
380 return target;
381 };
382 ESPConnection.prototype.opts = function (_) {
383 if (_ === void 0)
384 return this._connection.opts();
385 this._connection.opts(_);
386 return this;
387 };
388 ESPConnection.prototype.send = function (action, _request, espResponseType, largeUpload) {
389 if (_request === void 0) { _request = {}; }
390 if (espResponseType === void 0) { espResponseType = "json"; }
391 if (largeUpload === void 0) { largeUpload = false; }
392 var request = __assign(__assign({}, _request), { ver_: this._version });
393 if (largeUpload) {
394 request["upload_"] = true;
395 }
396 var serviceAction;
397 var responseType = "json";
398 switch (espResponseType) {
399 case "text":
400 serviceAction = util.join(this._service, action);
401 responseType = "text";
402 break;
403 case "xsd":
404 serviceAction = util.join(this._service, action + ".xsd");
405 responseType = "text";
406 break;
407 case "json2":
408 serviceAction = util.join(this._service, action + "/json");
409 espResponseType = "json";
410 var actionParts = action.split("/");
411 action = actionParts.pop();
412 break;
413 default:
414 serviceAction = util.join(this._service, action + ".json");
415 }
416 return this._connection.send(serviceAction, request, responseType).then(function (response) {
417 if (espResponseType === "json") {
418 var retVal = void 0;
419 if (response && response.Exceptions) {
420 throw new ESPExceptions(action, request, response.Exceptions);
421 }
422 else if (response) {
423 retVal = response[(action === "WUCDebug" ? "WUDebug" : action) + "Response"];
424 }
425 if (!retVal) {
426 throw new ESPExceptions(action, request, {
427 Source: "ESPConnection.send",
428 Exception: [{ Code: 0, Message: "Missing Response" }]
429 });
430 }
431 return retVal;
432 }
433 return response;
434 }).catch(function (e) {
435 if (e.isESPExceptions) {
436 throw e;
437 }
438 throw new ESPExceptions(action, request, {
439 Source: "ESPConnection.send",
440 Exception: [{ Code: 0, Message: e.message }]
441 });
442 });
443 };
444 ESPConnection.prototype.clone = function () {
445 return new ESPConnection(this._connection.clone(), this._service, this._version);
446 };
447 return ESPConnection;
448}());
449var Service = /** @class */ (function () {
450 function Service(optsConnection, service, version) {
451 this._connection = new ESPConnection(optsConnection, service, version);
452 }
453 Object.defineProperty(Service.prototype, "baseUrl", {
454 get: function () { return this._connection.opts().baseUrl; },
455 enumerable: false,
456 configurable: true
457 });
458 return Service;
459}());
460
461var AccountService = /** @class */ (function () {
462 function AccountService(optsConnection) {
463 this._connection = new ESPConnection(optsConnection, "Ws_Account", "1.03");
464 }
465 AccountService.prototype.connectionOptions = function () {
466 return this._connection.opts();
467 };
468 AccountService.prototype.VerifyUser = function (request) {
469 return this._connection.send("VerifyUser", request);
470 };
471 return AccountService;
472}());
473
474var DFUService = /** @class */ (function (_super) {
475 __extends(DFUService, _super);
476 function DFUService(optsConnection) {
477 return _super.call(this, optsConnection, "WsDfu", "1.5") || this;
478 }
479 DFUService.prototype.DFUQuery = function (request) {
480 return this._connection.send("DFUQuery", request);
481 };
482 DFUService.prototype.DFUInfo = function (request) {
483 return this._connection.send("DFUInfo", request);
484 };
485 return DFUService;
486}(Service));
487
488function jsonToIField(id, item) {
489 var type = typeof item;
490 switch (type) {
491 case "boolean":
492 case "number":
493 case "string":
494 return { id: id, type: type };
495 case "object":
496 if (item.Row instanceof Array) {
497 item = item.Row;
498 }
499 if (item instanceof Array) {
500 return {
501 id: id,
502 type: "dataset",
503 children: jsonToIFieldArr(item[0])
504 };
505 }
506 else if (item instanceof Object) {
507 if (item.Item && item.Item instanceof Array && item.Item.length === 1) {
508 var fieldType = typeof item.Item[0];
509 if (fieldType === "string" || fieldType === "number") {
510 return {
511 id: id,
512 type: "set",
513 fieldType: fieldType
514 };
515 }
516 throw new Error("Unknown field type");
517 }
518 return {
519 id: id,
520 type: "object",
521 fields: jsonToIFieldObj(item)
522 };
523 }
524 // Fall through ---
525 default:
526 throw new Error("Unknown field type");
527 }
528}
529function jsonToIFieldArr(json) {
530 if (json.Row && json.Row instanceof Array) {
531 json = json.Row[0];
532 }
533 var retVal = [];
534 for (var key in json) {
535 retVal.push(jsonToIField(key, json[key]));
536 }
537 return retVal;
538}
539function jsonToIFieldObj(json) {
540 var fields = {};
541 for (var key in json) {
542 fields[key] = jsonToIField(key, json[key]);
543 }
544 return fields;
545}
546var EclService = /** @class */ (function (_super) {
547 __extends(EclService, _super);
548 function EclService(optsConnection) {
549 return _super.call(this, optsConnection, "WsEcl", "0") || this;
550 }
551 EclService.prototype.opts = function () {
552 return this._connection.opts();
553 };
554 EclService.prototype.requestJson = function (querySet, queryId) {
555 // http://192.168.3.22:8002/WsEcl/example/request/query/roxie/peopleaccounts/json?display
556 return this._connection.send("example/request/query/" + querySet + "/" + queryId + "/json", {}, "text").then(function (response) {
557 var requestSchema = JSON.parse(response);
558 for (var key in requestSchema) {
559 return requestSchema[key];
560 }
561 return {};
562 }).then(jsonToIFieldArr);
563 };
564 EclService.prototype.responseJson = function (querySet, queryId) {
565 // http://192.168.3.22:8002/WsEcl/example/response/query/roxie/peopleaccounts/json?display
566 return this._connection.send("example/response/query/" + querySet + "/" + queryId + "/json", {}, "text").then(function (response) {
567 var responseSchema = JSON.parse(response);
568 for (var key in responseSchema) {
569 return responseSchema[key].Results;
570 }
571 return {};
572 }).then(function (resultsJson) {
573 var retVal = {};
574 for (var key in resultsJson) {
575 retVal[key] = jsonToIFieldArr(resultsJson[key]);
576 }
577 return retVal;
578 });
579 };
580 EclService.prototype.submit = function (querySet, queryId, request) {
581 // http://192.168.3.22:8002/WsEcl/submit/query/roxie/peopleaccounts.1/json
582 var action = "submit/query/" + querySet + "/" + queryId;
583 return this._connection.send(action, request, "json2").then(function (response) {
584 if (response.Results && response.Results.Exception) {
585 throw new ESPExceptions(action, request, {
586 Source: "wsEcl.submit",
587 Exception: response.Results.Exception
588 });
589 }
590 return response.Results;
591 });
592 };
593 return EclService;
594}(Service));
595
596function ascending(a, b) {
597 return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
598}
599
600function bisector(compare) {
601 if (compare.length === 1) compare = ascendingComparator(compare);
602 return {
603 left: function(a, x, lo, hi) {
604 if (lo == null) lo = 0;
605 if (hi == null) hi = a.length;
606 while (lo < hi) {
607 var mid = lo + hi >>> 1;
608 if (compare(a[mid], x) < 0) lo = mid + 1;
609 else hi = mid;
610 }
611 return lo;
612 },
613 right: function(a, x, lo, hi) {
614 if (lo == null) lo = 0;
615 if (hi == null) hi = a.length;
616 while (lo < hi) {
617 var mid = lo + hi >>> 1;
618 if (compare(a[mid], x) > 0) hi = mid;
619 else lo = mid + 1;
620 }
621 return lo;
622 }
623 };
624}
625
626function ascendingComparator(f) {
627 return function(d, x) {
628 return ascending(f(d), x);
629 };
630}
631
632var ascendingBisect = bisector(ascending);
633
634function number(x) {
635 return x === null ? NaN : +x;
636}
637
638function d3Max(values, valueof) {
639 var n = values.length,
640 i = -1,
641 value,
642 max;
643
644 if (valueof == null) {
645 while (++i < n) { // Find the first comparable value.
646 if ((value = values[i]) != null && value >= value) {
647 max = value;
648 while (++i < n) { // Compare the remaining values.
649 if ((value = values[i]) != null && value > max) {
650 max = value;
651 }
652 }
653 }
654 }
655 }
656
657 else {
658 while (++i < n) { // Find the first comparable value.
659 if ((value = valueof(values[i], i, values)) != null && value >= value) {
660 max = value;
661 while (++i < n) { // Compare the remaining values.
662 if ((value = valueof(values[i], i, values)) != null && value > max) {
663 max = value;
664 }
665 }
666 }
667 }
668 }
669
670 return max;
671}
672
673function d3Mean(values, valueof) {
674 var n = values.length,
675 m = n,
676 i = -1,
677 value,
678 sum = 0;
679
680 if (valueof == null) {
681 while (++i < n) {
682 if (!isNaN(value = number(values[i]))) sum += value;
683 else --m;
684 }
685 }
686
687 else {
688 while (++i < n) {
689 if (!isNaN(value = number(valueof(values[i], i, values)))) sum += value;
690 else --m;
691 }
692 }
693
694 if (m) return sum / m;
695}
696
697var MachineService = /** @class */ (function () {
698 function MachineService(optsConnection) {
699 this._connection = new ESPConnection(optsConnection, "ws_machine", "1.13");
700 }
701 MachineService.prototype.GetTargetClusterInfo = function (request) {
702 if (request === void 0) { request = {}; }
703 return this._connection.send("GetTargetClusterInfo", request);
704 };
705 MachineService.prototype.GetTargetClusterUsage = function (targetClusters, bypassCachedResult) {
706 if (bypassCachedResult === void 0) { bypassCachedResult = false; }
707 return this._connection.send("GetTargetClusterUsage", {
708 TargetClusters: targetClusters ? { Item: targetClusters } : {},
709 BypassCachedResult: bypassCachedResult
710 }).then(function (response) {
711 return util.exists("TargetClusterUsages.TargetClusterUsage", response) ? response.TargetClusterUsages.TargetClusterUsage : [];
712 });
713 };
714 MachineService.prototype.GetTargetClusterUsageEx = function (targetClusters, bypassCachedResult) {
715 if (bypassCachedResult === void 0) { bypassCachedResult = false; }
716 return this.GetTargetClusterUsage(targetClusters, bypassCachedResult).then(function (response) {
717 return response.filter(function (tcu) { return !!tcu.ComponentUsages; }).map(function (tcu) {
718 var ComponentUsages = tcu.ComponentUsages.ComponentUsage.map(function (cu) {
719 var MachineUsages = (cu.MachineUsages && cu.MachineUsages.MachineUsage ? cu.MachineUsages.MachineUsage : []).map(function (mu) {
720 var DiskUsages = mu.DiskUsages && mu.DiskUsages.DiskUsage ? mu.DiskUsages.DiskUsage.map(function (du) {
721 return __assign(__assign({}, du), { Total: du.InUse + du.Available, PercentUsed: 100 - du.PercentAvailable });
722 }) : [];
723 return {
724 Name: mu.Name,
725 NetAddress: mu.NetAddress,
726 Description: mu.Description,
727 DiskUsages: DiskUsages,
728 mean: d3Mean(DiskUsages.filter(function (du) { return !isNaN(du.PercentUsed); }), function (du) { return du.PercentUsed; }),
729 max: d3Max(DiskUsages.filter(function (du) { return !isNaN(du.PercentUsed); }), function (du) { return du.PercentUsed; })
730 };
731 });
732 return {
733 Type: cu.Type,
734 Name: cu.Name,
735 Description: cu.Description,
736 MachineUsages: MachineUsages,
737 MachineUsagesDescription: MachineUsages.reduce(function (prev, mu) { return prev + (mu.Description || ""); }, ""),
738 mean: d3Mean(MachineUsages.filter(function (mu) { return !isNaN(mu.mean); }), function (mu) { return mu.mean; }),
739 max: d3Max(MachineUsages.filter(function (mu) { return !isNaN(mu.max); }), function (mu) { return mu.max; })
740 };
741 });
742 return {
743 Name: tcu.Name,
744 Description: tcu.Description,
745 ComponentUsages: ComponentUsages,
746 ComponentUsagesDescription: ComponentUsages.reduce(function (prev, cu) { return prev + (cu.MachineUsagesDescription || ""); }, ""),
747 mean: d3Mean(ComponentUsages.filter(function (cu) { return !isNaN(cu.mean); }), function (cu) { return cu.mean; }),
748 max: d3Max(ComponentUsages.filter(function (cu) { return !isNaN(cu.max); }), function (cu) { return cu.max; })
749 };
750 });
751 });
752 };
753 return MachineService;
754}());
755
756var SMCService = /** @class */ (function () {
757 function SMCService(optsConnection) {
758 this._connection = new ESPConnection(optsConnection, "WsSMC", "1.19");
759 }
760 SMCService.prototype.connectionOptions = function () {
761 return this._connection.opts();
762 };
763 SMCService.prototype.Activity = function (request) {
764 return this._connection.send("Activity", request).then(function (response) {
765 return __assign({ Running: {
766 ActiveWorkunit: []
767 } }, response);
768 });
769 };
770 return SMCService;
771}());
772
773var StoreService = /** @class */ (function (_super) {
774 __extends(StoreService, _super);
775 function StoreService(optsConnection) {
776 return _super.call(this, optsConnection, "WsStore", "1") || this;
777 }
778 StoreService.prototype.CreateStore = function (request) {
779 return this._connection.send("Fetch", request);
780 };
781 StoreService.prototype.Delete = function (request) {
782 return this._connection.send("Delete", request).catch(function (e) {
783 if (e.isESPExceptions && e.Exception.some(function (e) { return e.Code === -1; })) {
784 // "Delete" item does not exist ---
785 return {
786 Exceptions: undefined,
787 Success: true
788 };
789 }
790 throw e;
791 });
792 };
793 StoreService.prototype.DeleteNamespace = function (request) {
794 return this._connection.send("DeleteNamespace", request);
795 };
796 StoreService.prototype.Fetch = function (request) {
797 return this._connection.send("Fetch", request).catch(function (e) {
798 if (e.isESPExceptions && e.Exception.some(function (e) { return e.Code === -1; })) {
799 // "Fetch" item does not exist ---
800 return {
801 Exceptions: undefined,
802 Value: undefined
803 };
804 }
805 throw e;
806 });
807 };
808 StoreService.prototype.FetchAll = function (request) {
809 return this._connection.send("FetchAll", request);
810 };
811 StoreService.prototype.FetchKeyMD = function (request) {
812 return this._connection.send("FetchKeyMD", request);
813 };
814 StoreService.prototype.ListKeys = function (request) {
815 return this._connection.send("ListKeys", request);
816 };
817 StoreService.prototype.ListNamespaces = function (request) {
818 return this._connection.send("ListNamespaces", request);
819 };
820 StoreService.prototype.Set = function (request) {
821 return this._connection.send("Set", request);
822 };
823 return StoreService;
824}(Service));
825
826var TopologyService = /** @class */ (function (_super) {
827 __extends(TopologyService, _super);
828 function TopologyService(optsConnection) {
829 return _super.call(this, optsConnection, "WsTopology", "1.25") || this;
830 }
831 TopologyService.prototype.connectionOptions = function () {
832 return this._connection.opts();
833 };
834 TopologyService.prototype.protocol = function () {
835 var parts = this._connection.opts().baseUrl.split("//");
836 return parts[0];
837 };
838 TopologyService.prototype.ip = function () {
839 var parts = this._connection.opts().baseUrl.split("//");
840 var parts2 = parts[1].split(":");
841 return parts2[0];
842 };
843 TopologyService.prototype.TpLogicalClusterQuery = function (request) {
844 if (request === void 0) { request = {}; }
845 return this._connection.send("TpLogicalClusterQuery", request);
846 };
847 TopologyService.prototype.DefaultTpLogicalClusterQuery = function (request) {
848 if (request === void 0) { request = {}; }
849 return this.TpLogicalClusterQuery(request).then(function (response) {
850 if (response.default) {
851 return response.default;
852 }
853 var firstHThor;
854 var first;
855 response.TpLogicalClusters.TpLogicalCluster.some(function (item, idx) {
856 if (idx === 0) {
857 first = item;
858 }
859 if (item.Type === "hthor") {
860 firstHThor = item;
861 return true;
862 }
863 return false;
864 });
865 return firstHThor || first;
866 });
867 };
868 TopologyService.prototype.TpServiceQuery = function (request) {
869 return this._connection.send("TpServiceQuery", request);
870 };
871 TopologyService.prototype.TpTargetClusterQuery = function (request) {
872 return this._connection.send("TpTargetClusterQuery", request);
873 };
874 TopologyService.prototype.TpListTargetClusters = function (request) {
875 return this._connection.send("TpListTargetClusters", request);
876 };
877 return TopologyService;
878}(Service));
879
880(function (WUStateID) {
881 WUStateID[WUStateID["Unknown"] = 0] = "Unknown";
882 WUStateID[WUStateID["Compiled"] = 1] = "Compiled";
883 WUStateID[WUStateID["Running"] = 2] = "Running";
884 WUStateID[WUStateID["Completed"] = 3] = "Completed";
885 WUStateID[WUStateID["Failed"] = 4] = "Failed";
886 WUStateID[WUStateID["Archived"] = 5] = "Archived";
887 WUStateID[WUStateID["Aborting"] = 6] = "Aborting";
888 WUStateID[WUStateID["Aborted"] = 7] = "Aborted";
889 WUStateID[WUStateID["Blocked"] = 8] = "Blocked";
890 WUStateID[WUStateID["Submitted"] = 9] = "Submitted";
891 WUStateID[WUStateID["Scheduled"] = 10] = "Scheduled";
892 WUStateID[WUStateID["Compiling"] = 11] = "Compiling";
893 WUStateID[WUStateID["Wait"] = 12] = "Wait";
894 WUStateID[WUStateID["UploadingFiled"] = 13] = "UploadingFiled";
895 WUStateID[WUStateID["DebugPaused"] = 14] = "DebugPaused";
896 WUStateID[WUStateID["DebugRunning"] = 15] = "DebugRunning";
897 WUStateID[WUStateID["Paused"] = 16] = "Paused";
898 WUStateID[WUStateID["LAST"] = 17] = "LAST";
899 WUStateID[WUStateID["NotFound"] = 999] = "NotFound";
900})(exports.WUStateID || (exports.WUStateID = {}));
901(function (WUUpdate) {
902 var Action;
903 (function (Action) {
904 Action[Action["Unknown"] = 0] = "Unknown";
905 Action[Action["Compile"] = 1] = "Compile";
906 Action[Action["Check"] = 2] = "Check";
907 Action[Action["Run"] = 3] = "Run";
908 Action[Action["ExecuteExisting"] = 4] = "ExecuteExisting";
909 Action[Action["Pause"] = 5] = "Pause";
910 Action[Action["PauseNow"] = 6] = "PauseNow";
911 Action[Action["Resume"] = 7] = "Resume";
912 Action[Action["Debug"] = 8] = "Debug";
913 Action[Action["__size"] = 9] = "__size";
914 })(Action = WUUpdate.Action || (WUUpdate.Action = {}));
915})(exports.WUUpdate || (exports.WUUpdate = {}));
916function isWUQueryECLWorkunit(_) {
917 return _.TotalClusterTime !== undefined;
918}
919function isWUInfoWorkunit(_) {
920 return _.StateEx !== undefined;
921}
922var WorkunitsService = /** @class */ (function (_super) {
923 __extends(WorkunitsService, _super);
924 function WorkunitsService(optsConnection) {
925 return _super.call(this, optsConnection, "WsWorkunits", "1.68") || this;
926 }
927 WorkunitsService.prototype.opts = function () {
928 return this._connection.opts();
929 };
930 WorkunitsService.prototype.connection = function () {
931 return this._connection;
932 };
933 WorkunitsService.prototype.WUQuery = function (request) {
934 if (request === void 0) { request = {}; }
935 return this._connection.send("WUQuery", request).then(function (response) {
936 return util.deepMixin({ Workunits: { ECLWorkunit: [] } }, response);
937 });
938 };
939 WorkunitsService.prototype.WUInfo = function (_request) {
940 var request = __assign({ Wuid: "", TruncateEclTo64k: true, IncludeExceptions: false, IncludeGraphs: false, IncludeSourceFiles: false, IncludeResults: false, IncludeResultsViewNames: false, IncludeVariables: false, IncludeTimers: false, IncludeDebugValues: false, IncludeApplicationValues: false, IncludeWorkflows: false, IncludeXmlSchemas: false, IncludeResourceURLs: false, SuppressResultSchemas: true }, _request);
941 return this._connection.send("WUInfo", request);
942 };
943 WorkunitsService.prototype.WUCreate = function () {
944 return this._connection.send("WUCreate");
945 };
946 WorkunitsService.prototype.WUUpdate = function (request) {
947 return this._connection.send("WUUpdate", request, "json", true);
948 };
949 WorkunitsService.prototype.WUSubmit = function (request) {
950 return this._connection.send("WUSubmit", request);
951 };
952 WorkunitsService.prototype.WUResubmit = function (request) {
953 this._connection.toESPStringArray(request, "Wuids");
954 return this._connection.send("WUResubmit", request);
955 };
956 WorkunitsService.prototype.WUQueryDetails = function (request) {
957 return this._connection.send("WUQueryDetails", request);
958 };
959 WorkunitsService.prototype.WUListQueries = function (request) {
960 return this._connection.send("WUListQueries", request);
961 };
962 WorkunitsService.prototype.WUPushEvent = function (request) {
963 return this._connection.send("WUPushEvent", request);
964 };
965 WorkunitsService.prototype.WUAction = function (request) {
966 request.ActionType = request.WUActionType; // v5.x compatibility
967 return this._connection.send("WUAction", request);
968 };
969 WorkunitsService.prototype.WUGetZAPInfo = function (request) {
970 return this._connection.send("WUGetZAPInfo", request);
971 };
972 WorkunitsService.prototype.WUShowScheduled = function (request) {
973 return this._connection.send("WUShowScheduled", request);
974 };
975 WorkunitsService.prototype.WUQuerySetAliasAction = function (request) {
976 return this._connection.send("WUQuerySetAliasAction", request);
977 };
978 WorkunitsService.prototype.WUQuerySetQueryAction = function (request) {
979 return this._connection.send("WUQuerySetQueryAction", request);
980 };
981 WorkunitsService.prototype.WUPublishWorkunit = function (request) {
982 return this._connection.send("WUPublishWorkunit", request);
983 };
984 WorkunitsService.prototype.WUGetGraph = function (request) {
985 return this._connection.send("WUGetGraph", request);
986 };
987 WorkunitsService.prototype.WUResult = function (request) {
988 return this._connection.send("WUResult", request);
989 };
990 WorkunitsService.prototype.WUQueryGetGraph = function (request) {
991 return this._connection.send("WUQueryGetGraph", request);
992 };
993 WorkunitsService.prototype.WUFile = function (request) {
994 return this._connection.send("WUFile", request, "text");
995 };
996 WorkunitsService.prototype.WUGetStats = function (request) {
997 return this._connection.send("WUGetStats", request);
998 };
999 WorkunitsService.prototype.WUDetailsMeta = function (request) {
1000 if (!this._WUDetailsMetaPromise) {
1001 this._WUDetailsMetaPromise = this._connection.send("WUDetailsMeta", request);
1002 }
1003 return this._WUDetailsMetaPromise;
1004 };
1005 WorkunitsService.prototype.WUDetails = function (request) {
1006 return this._connection.send("WUDetails", request);
1007 };
1008 WorkunitsService.prototype.WUCDebug = function (request) {
1009 return this._connection.send("WUCDebug", request).then(function (response) {
1010 var retVal = util.xml2json(response.Result);
1011 var children = retVal.children();
1012 if (children.length) {
1013 return children[0];
1014 }
1015 return null;
1016 });
1017 };
1018 return WorkunitsService;
1019}(Service));
1020
1021var t0 = new Date,
1022 t1 = new Date;
1023
1024function newInterval(floori, offseti, count, field) {
1025
1026 function interval(date) {
1027 return floori(date = new Date(+date)), date;
1028 }
1029
1030 interval.floor = interval;
1031
1032 interval.ceil = function(date) {
1033 return floori(date = new Date(date - 1)), offseti(date, 1), floori(date), date;
1034 };
1035
1036 interval.round = function(date) {
1037 var d0 = interval(date),
1038 d1 = interval.ceil(date);
1039 return date - d0 < d1 - date ? d0 : d1;
1040 };
1041
1042 interval.offset = function(date, step) {
1043 return offseti(date = new Date(+date), step == null ? 1 : Math.floor(step)), date;
1044 };
1045
1046 interval.range = function(start, stop, step) {
1047 var range = [];
1048 start = interval.ceil(start);
1049 step = step == null ? 1 : Math.floor(step);
1050 if (!(start < stop) || !(step > 0)) return range; // also handles Invalid Date
1051 do range.push(new Date(+start)); while (offseti(start, step), floori(start), start < stop)
1052 return range;
1053 };
1054
1055 interval.filter = function(test) {
1056 return newInterval(function(date) {
1057 if (date >= date) while (floori(date), !test(date)) date.setTime(date - 1);
1058 }, function(date, step) {
1059 if (date >= date) while (--step >= 0) while (offseti(date, 1), !test(date)) {} // eslint-disable-line no-empty
1060 });
1061 };
1062
1063 if (count) {
1064 interval.count = function(start, end) {
1065 t0.setTime(+start), t1.setTime(+end);
1066 floori(t0), floori(t1);
1067 return Math.floor(count(t0, t1));
1068 };
1069
1070 interval.every = function(step) {
1071 step = Math.floor(step);
1072 return !isFinite(step) || !(step > 0) ? null
1073 : !(step > 1) ? interval
1074 : interval.filter(field
1075 ? function(d) { return field(d) % step === 0; }
1076 : function(d) { return interval.count(0, d) % step === 0; });
1077 };
1078 }
1079
1080 return interval;
1081}
1082
1083var millisecond = newInterval(function() {
1084 // noop
1085}, function(date, step) {
1086 date.setTime(+date + step);
1087}, function(start, end) {
1088 return end - start;
1089});
1090
1091// An optimized implementation for this simple case.
1092millisecond.every = function(k) {
1093 k = Math.floor(k);
1094 if (!isFinite(k) || !(k > 0)) return null;
1095 if (!(k > 1)) return millisecond;
1096 return newInterval(function(date) {
1097 date.setTime(Math.floor(date / k) * k);
1098 }, function(date, step) {
1099 date.setTime(+date + step * k);
1100 }, function(start, end) {
1101 return (end - start) / k;
1102 });
1103};
1104
1105var durationSecond = 1e3;
1106var durationMinute = 6e4;
1107var durationHour = 36e5;
1108var durationDay = 864e5;
1109var durationWeek = 6048e5;
1110
1111var second = newInterval(function(date) {
1112 date.setTime(Math.floor(date / durationSecond) * durationSecond);
1113}, function(date, step) {
1114 date.setTime(+date + step * durationSecond);
1115}, function(start, end) {
1116 return (end - start) / durationSecond;
1117}, function(date) {
1118 return date.getUTCSeconds();
1119});
1120
1121var minute = newInterval(function(date) {
1122 date.setTime(Math.floor(date / durationMinute) * durationMinute);
1123}, function(date, step) {
1124 date.setTime(+date + step * durationMinute);
1125}, function(start, end) {
1126 return (end - start) / durationMinute;
1127}, function(date) {
1128 return date.getMinutes();
1129});
1130
1131var hour = newInterval(function(date) {
1132 var offset = date.getTimezoneOffset() * durationMinute % durationHour;
1133 if (offset < 0) offset += durationHour;
1134 date.setTime(Math.floor((+date - offset) / durationHour) * durationHour + offset);
1135}, function(date, step) {
1136 date.setTime(+date + step * durationHour);
1137}, function(start, end) {
1138 return (end - start) / durationHour;
1139}, function(date) {
1140 return date.getHours();
1141});
1142
1143var day = newInterval(function(date) {
1144 date.setHours(0, 0, 0, 0);
1145}, function(date, step) {
1146 date.setDate(date.getDate() + step);
1147}, function(start, end) {
1148 return (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationDay;
1149}, function(date) {
1150 return date.getDate() - 1;
1151});
1152
1153function weekday(i) {
1154 return newInterval(function(date) {
1155 date.setDate(date.getDate() - (date.getDay() + 7 - i) % 7);
1156 date.setHours(0, 0, 0, 0);
1157 }, function(date, step) {
1158 date.setDate(date.getDate() + step * 7);
1159 }, function(start, end) {
1160 return (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationWeek;
1161 });
1162}
1163
1164var sunday = weekday(0);
1165var monday = weekday(1);
1166var tuesday = weekday(2);
1167var wednesday = weekday(3);
1168var thursday = weekday(4);
1169var friday = weekday(5);
1170var saturday = weekday(6);
1171
1172var month = newInterval(function(date) {
1173 date.setDate(1);
1174 date.setHours(0, 0, 0, 0);
1175}, function(date, step) {
1176 date.setMonth(date.getMonth() + step);
1177}, function(start, end) {
1178 return end.getMonth() - start.getMonth() + (end.getFullYear() - start.getFullYear()) * 12;
1179}, function(date) {
1180 return date.getMonth();
1181});
1182
1183var year = newInterval(function(date) {
1184 date.setMonth(0, 1);
1185 date.setHours(0, 0, 0, 0);
1186}, function(date, step) {
1187 date.setFullYear(date.getFullYear() + step);
1188}, function(start, end) {
1189 return end.getFullYear() - start.getFullYear();
1190}, function(date) {
1191 return date.getFullYear();
1192});
1193
1194// An optimized implementation for this simple case.
1195year.every = function(k) {
1196 return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : newInterval(function(date) {
1197 date.setFullYear(Math.floor(date.getFullYear() / k) * k);
1198 date.setMonth(0, 1);
1199 date.setHours(0, 0, 0, 0);
1200 }, function(date, step) {
1201 date.setFullYear(date.getFullYear() + step * k);
1202 });
1203};
1204
1205var utcMinute = newInterval(function(date) {
1206 date.setUTCSeconds(0, 0);
1207}, function(date, step) {
1208 date.setTime(+date + step * durationMinute);
1209}, function(start, end) {
1210 return (end - start) / durationMinute;
1211}, function(date) {
1212 return date.getUTCMinutes();
1213});
1214
1215var utcHour = newInterval(function(date) {
1216 date.setUTCMinutes(0, 0, 0);
1217}, function(date, step) {
1218 date.setTime(+date + step * durationHour);
1219}, function(start, end) {
1220 return (end - start) / durationHour;
1221}, function(date) {
1222 return date.getUTCHours();
1223});
1224
1225var utcDay = newInterval(function(date) {
1226 date.setUTCHours(0, 0, 0, 0);
1227}, function(date, step) {
1228 date.setUTCDate(date.getUTCDate() + step);
1229}, function(start, end) {
1230 return (end - start) / durationDay;
1231}, function(date) {
1232 return date.getUTCDate() - 1;
1233});
1234
1235function utcWeekday(i) {
1236 return newInterval(function(date) {
1237 date.setUTCDate(date.getUTCDate() - (date.getUTCDay() + 7 - i) % 7);
1238 date.setUTCHours(0, 0, 0, 0);
1239 }, function(date, step) {
1240 date.setUTCDate(date.getUTCDate() + step * 7);
1241 }, function(start, end) {
1242 return (end - start) / durationWeek;
1243 });
1244}
1245
1246var utcSunday = utcWeekday(0);
1247var utcMonday = utcWeekday(1);
1248var utcTuesday = utcWeekday(2);
1249var utcWednesday = utcWeekday(3);
1250var utcThursday = utcWeekday(4);
1251var utcFriday = utcWeekday(5);
1252var utcSaturday = utcWeekday(6);
1253
1254var utcMonth = newInterval(function(date) {
1255 date.setUTCDate(1);
1256 date.setUTCHours(0, 0, 0, 0);
1257}, function(date, step) {
1258 date.setUTCMonth(date.getUTCMonth() + step);
1259}, function(start, end) {
1260 return end.getUTCMonth() - start.getUTCMonth() + (end.getUTCFullYear() - start.getUTCFullYear()) * 12;
1261}, function(date) {
1262 return date.getUTCMonth();
1263});
1264
1265var utcYear = newInterval(function(date) {
1266 date.setUTCMonth(0, 1);
1267 date.setUTCHours(0, 0, 0, 0);
1268}, function(date, step) {
1269 date.setUTCFullYear(date.getUTCFullYear() + step);
1270}, function(start, end) {
1271 return end.getUTCFullYear() - start.getUTCFullYear();
1272}, function(date) {
1273 return date.getUTCFullYear();
1274});
1275
1276// An optimized implementation for this simple case.
1277utcYear.every = function(k) {
1278 return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : newInterval(function(date) {
1279 date.setUTCFullYear(Math.floor(date.getUTCFullYear() / k) * k);
1280 date.setUTCMonth(0, 1);
1281 date.setUTCHours(0, 0, 0, 0);
1282 }, function(date, step) {
1283 date.setUTCFullYear(date.getUTCFullYear() + step * k);
1284 });
1285};
1286
1287function localDate(d) {
1288 if (0 <= d.y && d.y < 100) {
1289 var date = new Date(-1, d.m, d.d, d.H, d.M, d.S, d.L);
1290 date.setFullYear(d.y);
1291 return date;
1292 }
1293 return new Date(d.y, d.m, d.d, d.H, d.M, d.S, d.L);
1294}
1295
1296function utcDate(d) {
1297 if (0 <= d.y && d.y < 100) {
1298 var date = new Date(Date.UTC(-1, d.m, d.d, d.H, d.M, d.S, d.L));
1299 date.setUTCFullYear(d.y);
1300 return date;
1301 }
1302 return new Date(Date.UTC(d.y, d.m, d.d, d.H, d.M, d.S, d.L));
1303}
1304
1305function newYear(y) {
1306 return {y: y, m: 0, d: 1, H: 0, M: 0, S: 0, L: 0};
1307}
1308
1309function formatLocale(locale) {
1310 var locale_dateTime = locale.dateTime,
1311 locale_date = locale.date,
1312 locale_time = locale.time,
1313 locale_periods = locale.periods,
1314 locale_weekdays = locale.days,
1315 locale_shortWeekdays = locale.shortDays,
1316 locale_months = locale.months,
1317 locale_shortMonths = locale.shortMonths;
1318
1319 var periodRe = formatRe(locale_periods),
1320 periodLookup = formatLookup(locale_periods),
1321 weekdayRe = formatRe(locale_weekdays),
1322 weekdayLookup = formatLookup(locale_weekdays),
1323 shortWeekdayRe = formatRe(locale_shortWeekdays),
1324 shortWeekdayLookup = formatLookup(locale_shortWeekdays),
1325 monthRe = formatRe(locale_months),
1326 monthLookup = formatLookup(locale_months),
1327 shortMonthRe = formatRe(locale_shortMonths),
1328 shortMonthLookup = formatLookup(locale_shortMonths);
1329
1330 var formats = {
1331 "a": formatShortWeekday,
1332 "A": formatWeekday,
1333 "b": formatShortMonth,
1334 "B": formatMonth,
1335 "c": null,
1336 "d": formatDayOfMonth,
1337 "e": formatDayOfMonth,
1338 "f": formatMicroseconds,
1339 "H": formatHour24,
1340 "I": formatHour12,
1341 "j": formatDayOfYear,
1342 "L": formatMilliseconds,
1343 "m": formatMonthNumber,
1344 "M": formatMinutes,
1345 "p": formatPeriod,
1346 "Q": formatUnixTimestamp,
1347 "s": formatUnixTimestampSeconds,
1348 "S": formatSeconds,
1349 "u": formatWeekdayNumberMonday,
1350 "U": formatWeekNumberSunday,
1351 "V": formatWeekNumberISO,
1352 "w": formatWeekdayNumberSunday,
1353 "W": formatWeekNumberMonday,
1354 "x": null,
1355 "X": null,
1356 "y": formatYear,
1357 "Y": formatFullYear,
1358 "Z": formatZone,
1359 "%": formatLiteralPercent
1360 };
1361
1362 var utcFormats = {
1363 "a": formatUTCShortWeekday,
1364 "A": formatUTCWeekday,
1365 "b": formatUTCShortMonth,
1366 "B": formatUTCMonth,
1367 "c": null,
1368 "d": formatUTCDayOfMonth,
1369 "e": formatUTCDayOfMonth,
1370 "f": formatUTCMicroseconds,
1371 "H": formatUTCHour24,
1372 "I": formatUTCHour12,
1373 "j": formatUTCDayOfYear,
1374 "L": formatUTCMilliseconds,
1375 "m": formatUTCMonthNumber,
1376 "M": formatUTCMinutes,
1377 "p": formatUTCPeriod,
1378 "Q": formatUnixTimestamp,
1379 "s": formatUnixTimestampSeconds,
1380 "S": formatUTCSeconds,
1381 "u": formatUTCWeekdayNumberMonday,
1382 "U": formatUTCWeekNumberSunday,
1383 "V": formatUTCWeekNumberISO,
1384 "w": formatUTCWeekdayNumberSunday,
1385 "W": formatUTCWeekNumberMonday,
1386 "x": null,
1387 "X": null,
1388 "y": formatUTCYear,
1389 "Y": formatUTCFullYear,
1390 "Z": formatUTCZone,
1391 "%": formatLiteralPercent
1392 };
1393
1394 var parses = {
1395 "a": parseShortWeekday,
1396 "A": parseWeekday,
1397 "b": parseShortMonth,
1398 "B": parseMonth,
1399 "c": parseLocaleDateTime,
1400 "d": parseDayOfMonth,
1401 "e": parseDayOfMonth,
1402 "f": parseMicroseconds,
1403 "H": parseHour24,
1404 "I": parseHour24,
1405 "j": parseDayOfYear,
1406 "L": parseMilliseconds,
1407 "m": parseMonthNumber,
1408 "M": parseMinutes,
1409 "p": parsePeriod,
1410 "Q": parseUnixTimestamp,
1411 "s": parseUnixTimestampSeconds,
1412 "S": parseSeconds,
1413 "u": parseWeekdayNumberMonday,
1414 "U": parseWeekNumberSunday,
1415 "V": parseWeekNumberISO,
1416 "w": parseWeekdayNumberSunday,
1417 "W": parseWeekNumberMonday,
1418 "x": parseLocaleDate,
1419 "X": parseLocaleTime,
1420 "y": parseYear,
1421 "Y": parseFullYear,
1422 "Z": parseZone,
1423 "%": parseLiteralPercent
1424 };
1425
1426 // These recursive directive definitions must be deferred.
1427 formats.x = newFormat(locale_date, formats);
1428 formats.X = newFormat(locale_time, formats);
1429 formats.c = newFormat(locale_dateTime, formats);
1430 utcFormats.x = newFormat(locale_date, utcFormats);
1431 utcFormats.X = newFormat(locale_time, utcFormats);
1432 utcFormats.c = newFormat(locale_dateTime, utcFormats);
1433
1434 function newFormat(specifier, formats) {
1435 return function(date) {
1436 var string = [],
1437 i = -1,
1438 j = 0,
1439 n = specifier.length,
1440 c,
1441 pad,
1442 format;
1443
1444 if (!(date instanceof Date)) date = new Date(+date);
1445
1446 while (++i < n) {
1447 if (specifier.charCodeAt(i) === 37) {
1448 string.push(specifier.slice(j, i));
1449 if ((pad = pads[c = specifier.charAt(++i)]) != null) c = specifier.charAt(++i);
1450 else pad = c === "e" ? " " : "0";
1451 if (format = formats[c]) c = format(date, pad);
1452 string.push(c);
1453 j = i + 1;
1454 }
1455 }
1456
1457 string.push(specifier.slice(j, i));
1458 return string.join("");
1459 };
1460 }
1461
1462 function newParse(specifier, newDate) {
1463 return function(string) {
1464 var d = newYear(1900),
1465 i = parseSpecifier(d, specifier, string += "", 0),
1466 week, day$1;
1467 if (i != string.length) return null;
1468
1469 // If a UNIX timestamp is specified, return it.
1470 if ("Q" in d) return new Date(d.Q);
1471
1472 // The am-pm flag is 0 for AM, and 1 for PM.
1473 if ("p" in d) d.H = d.H % 12 + d.p * 12;
1474
1475 // Convert day-of-week and week-of-year to day-of-year.
1476 if ("V" in d) {
1477 if (d.V < 1 || d.V > 53) return null;
1478 if (!("w" in d)) d.w = 1;
1479 if ("Z" in d) {
1480 week = utcDate(newYear(d.y)), day$1 = week.getUTCDay();
1481 week = day$1 > 4 || day$1 === 0 ? utcMonday.ceil(week) : utcMonday(week);
1482 week = utcDay.offset(week, (d.V - 1) * 7);
1483 d.y = week.getUTCFullYear();
1484 d.m = week.getUTCMonth();
1485 d.d = week.getUTCDate() + (d.w + 6) % 7;
1486 } else {
1487 week = newDate(newYear(d.y)), day$1 = week.getDay();
1488 week = day$1 > 4 || day$1 === 0 ? monday.ceil(week) : monday(week);
1489 week = day.offset(week, (d.V - 1) * 7);
1490 d.y = week.getFullYear();
1491 d.m = week.getMonth();
1492 d.d = week.getDate() + (d.w + 6) % 7;
1493 }
1494 } else if ("W" in d || "U" in d) {
1495 if (!("w" in d)) d.w = "u" in d ? d.u % 7 : "W" in d ? 1 : 0;
1496 day$1 = "Z" in d ? utcDate(newYear(d.y)).getUTCDay() : newDate(newYear(d.y)).getDay();
1497 d.m = 0;
1498 d.d = "W" in d ? (d.w + 6) % 7 + d.W * 7 - (day$1 + 5) % 7 : d.w + d.U * 7 - (day$1 + 6) % 7;
1499 }
1500
1501 // If a time zone is specified, all fields are interpreted as UTC and then
1502 // offset according to the specified time zone.
1503 if ("Z" in d) {
1504 d.H += d.Z / 100 | 0;
1505 d.M += d.Z % 100;
1506 return utcDate(d);
1507 }
1508
1509 // Otherwise, all fields are in local time.
1510 return newDate(d);
1511 };
1512 }
1513
1514 function parseSpecifier(d, specifier, string, j) {
1515 var i = 0,
1516 n = specifier.length,
1517 m = string.length,
1518 c,
1519 parse;
1520
1521 while (i < n) {
1522 if (j >= m) return -1;
1523 c = specifier.charCodeAt(i++);
1524 if (c === 37) {
1525 c = specifier.charAt(i++);
1526 parse = parses[c in pads ? specifier.charAt(i++) : c];
1527 if (!parse || ((j = parse(d, string, j)) < 0)) return -1;
1528 } else if (c != string.charCodeAt(j++)) {
1529 return -1;
1530 }
1531 }
1532
1533 return j;
1534 }
1535
1536 function parsePeriod(d, string, i) {
1537 var n = periodRe.exec(string.slice(i));
1538 return n ? (d.p = periodLookup[n[0].toLowerCase()], i + n[0].length) : -1;
1539 }
1540
1541 function parseShortWeekday(d, string, i) {
1542 var n = shortWeekdayRe.exec(string.slice(i));
1543 return n ? (d.w = shortWeekdayLookup[n[0].toLowerCase()], i + n[0].length) : -1;
1544 }
1545
1546 function parseWeekday(d, string, i) {
1547 var n = weekdayRe.exec(string.slice(i));
1548 return n ? (d.w = weekdayLookup[n[0].toLowerCase()], i + n[0].length) : -1;
1549 }
1550
1551 function parseShortMonth(d, string, i) {
1552 var n = shortMonthRe.exec(string.slice(i));
1553 return n ? (d.m = shortMonthLookup[n[0].toLowerCase()], i + n[0].length) : -1;
1554 }
1555
1556 function parseMonth(d, string, i) {
1557 var n = monthRe.exec(string.slice(i));
1558 return n ? (d.m = monthLookup[n[0].toLowerCase()], i + n[0].length) : -1;
1559 }
1560
1561 function parseLocaleDateTime(d, string, i) {
1562 return parseSpecifier(d, locale_dateTime, string, i);
1563 }
1564
1565 function parseLocaleDate(d, string, i) {
1566 return parseSpecifier(d, locale_date, string, i);
1567 }
1568
1569 function parseLocaleTime(d, string, i) {
1570 return parseSpecifier(d, locale_time, string, i);
1571 }
1572
1573 function formatShortWeekday(d) {
1574 return locale_shortWeekdays[d.getDay()];
1575 }
1576
1577 function formatWeekday(d) {
1578 return locale_weekdays[d.getDay()];
1579 }
1580
1581 function formatShortMonth(d) {
1582 return locale_shortMonths[d.getMonth()];
1583 }
1584
1585 function formatMonth(d) {
1586 return locale_months[d.getMonth()];
1587 }
1588
1589 function formatPeriod(d) {
1590 return locale_periods[+(d.getHours() >= 12)];
1591 }
1592
1593 function formatUTCShortWeekday(d) {
1594 return locale_shortWeekdays[d.getUTCDay()];
1595 }
1596
1597 function formatUTCWeekday(d) {
1598 return locale_weekdays[d.getUTCDay()];
1599 }
1600
1601 function formatUTCShortMonth(d) {
1602 return locale_shortMonths[d.getUTCMonth()];
1603 }
1604
1605 function formatUTCMonth(d) {
1606 return locale_months[d.getUTCMonth()];
1607 }
1608
1609 function formatUTCPeriod(d) {
1610 return locale_periods[+(d.getUTCHours() >= 12)];
1611 }
1612
1613 return {
1614 format: function(specifier) {
1615 var f = newFormat(specifier += "", formats);
1616 f.toString = function() { return specifier; };
1617 return f;
1618 },
1619 parse: function(specifier) {
1620 var p = newParse(specifier += "", localDate);
1621 p.toString = function() { return specifier; };
1622 return p;
1623 },
1624 utcFormat: function(specifier) {
1625 var f = newFormat(specifier += "", utcFormats);
1626 f.toString = function() { return specifier; };
1627 return f;
1628 },
1629 utcParse: function(specifier) {
1630 var p = newParse(specifier, utcDate);
1631 p.toString = function() { return specifier; };
1632 return p;
1633 }
1634 };
1635}
1636
1637var pads = {"-": "", "_": " ", "0": "0"},
1638 numberRe = /^\s*\d+/, // note: ignores next directive
1639 percentRe = /^%/,
1640 requoteRe = /[\\^$*+?|[\]().{}]/g;
1641
1642function pad(value, fill, width) {
1643 var sign = value < 0 ? "-" : "",
1644 string = (sign ? -value : value) + "",
1645 length = string.length;
1646 return sign + (length < width ? new Array(width - length + 1).join(fill) + string : string);
1647}
1648
1649function requote(s) {
1650 return s.replace(requoteRe, "\\$&");
1651}
1652
1653function formatRe(names) {
1654 return new RegExp("^(?:" + names.map(requote).join("|") + ")", "i");
1655}
1656
1657function formatLookup(names) {
1658 var map = {}, i = -1, n = names.length;
1659 while (++i < n) map[names[i].toLowerCase()] = i;
1660 return map;
1661}
1662
1663function parseWeekdayNumberSunday(d, string, i) {
1664 var n = numberRe.exec(string.slice(i, i + 1));
1665 return n ? (d.w = +n[0], i + n[0].length) : -1;
1666}
1667
1668function parseWeekdayNumberMonday(d, string, i) {
1669 var n = numberRe.exec(string.slice(i, i + 1));
1670 return n ? (d.u = +n[0], i + n[0].length) : -1;
1671}
1672
1673function parseWeekNumberSunday(d, string, i) {
1674 var n = numberRe.exec(string.slice(i, i + 2));
1675 return n ? (d.U = +n[0], i + n[0].length) : -1;
1676}
1677
1678function parseWeekNumberISO(d, string, i) {
1679 var n = numberRe.exec(string.slice(i, i + 2));
1680 return n ? (d.V = +n[0], i + n[0].length) : -1;
1681}
1682
1683function parseWeekNumberMonday(d, string, i) {
1684 var n = numberRe.exec(string.slice(i, i + 2));
1685 return n ? (d.W = +n[0], i + n[0].length) : -1;
1686}
1687
1688function parseFullYear(d, string, i) {
1689 var n = numberRe.exec(string.slice(i, i + 4));
1690 return n ? (d.y = +n[0], i + n[0].length) : -1;
1691}
1692
1693function parseYear(d, string, i) {
1694 var n = numberRe.exec(string.slice(i, i + 2));
1695 return n ? (d.y = +n[0] + (+n[0] > 68 ? 1900 : 2000), i + n[0].length) : -1;
1696}
1697
1698function parseZone(d, string, i) {
1699 var n = /^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(string.slice(i, i + 6));
1700 return n ? (d.Z = n[1] ? 0 : -(n[2] + (n[3] || "00")), i + n[0].length) : -1;
1701}
1702
1703function parseMonthNumber(d, string, i) {
1704 var n = numberRe.exec(string.slice(i, i + 2));
1705 return n ? (d.m = n[0] - 1, i + n[0].length) : -1;
1706}
1707
1708function parseDayOfMonth(d, string, i) {
1709 var n = numberRe.exec(string.slice(i, i + 2));
1710 return n ? (d.d = +n[0], i + n[0].length) : -1;
1711}
1712
1713function parseDayOfYear(d, string, i) {
1714 var n = numberRe.exec(string.slice(i, i + 3));
1715 return n ? (d.m = 0, d.d = +n[0], i + n[0].length) : -1;
1716}
1717
1718function parseHour24(d, string, i) {
1719 var n = numberRe.exec(string.slice(i, i + 2));
1720 return n ? (d.H = +n[0], i + n[0].length) : -1;
1721}
1722
1723function parseMinutes(d, string, i) {
1724 var n = numberRe.exec(string.slice(i, i + 2));
1725 return n ? (d.M = +n[0], i + n[0].length) : -1;
1726}
1727
1728function parseSeconds(d, string, i) {
1729 var n = numberRe.exec(string.slice(i, i + 2));
1730 return n ? (d.S = +n[0], i + n[0].length) : -1;
1731}
1732
1733function parseMilliseconds(d, string, i) {
1734 var n = numberRe.exec(string.slice(i, i + 3));
1735 return n ? (d.L = +n[0], i + n[0].length) : -1;
1736}
1737
1738function parseMicroseconds(d, string, i) {
1739 var n = numberRe.exec(string.slice(i, i + 6));
1740 return n ? (d.L = Math.floor(n[0] / 1000), i + n[0].length) : -1;
1741}
1742
1743function parseLiteralPercent(d, string, i) {
1744 var n = percentRe.exec(string.slice(i, i + 1));
1745 return n ? i + n[0].length : -1;
1746}
1747
1748function parseUnixTimestamp(d, string, i) {
1749 var n = numberRe.exec(string.slice(i));
1750 return n ? (d.Q = +n[0], i + n[0].length) : -1;
1751}
1752
1753function parseUnixTimestampSeconds(d, string, i) {
1754 var n = numberRe.exec(string.slice(i));
1755 return n ? (d.Q = (+n[0]) * 1000, i + n[0].length) : -1;
1756}
1757
1758function formatDayOfMonth(d, p) {
1759 return pad(d.getDate(), p, 2);
1760}
1761
1762function formatHour24(d, p) {
1763 return pad(d.getHours(), p, 2);
1764}
1765
1766function formatHour12(d, p) {
1767 return pad(d.getHours() % 12 || 12, p, 2);
1768}
1769
1770function formatDayOfYear(d, p) {
1771 return pad(1 + day.count(year(d), d), p, 3);
1772}
1773
1774function formatMilliseconds(d, p) {
1775 return pad(d.getMilliseconds(), p, 3);
1776}
1777
1778function formatMicroseconds(d, p) {
1779 return formatMilliseconds(d, p) + "000";
1780}
1781
1782function formatMonthNumber(d, p) {
1783 return pad(d.getMonth() + 1, p, 2);
1784}
1785
1786function formatMinutes(d, p) {
1787 return pad(d.getMinutes(), p, 2);
1788}
1789
1790function formatSeconds(d, p) {
1791 return pad(d.getSeconds(), p, 2);
1792}
1793
1794function formatWeekdayNumberMonday(d) {
1795 var day = d.getDay();
1796 return day === 0 ? 7 : day;
1797}
1798
1799function formatWeekNumberSunday(d, p) {
1800 return pad(sunday.count(year(d), d), p, 2);
1801}
1802
1803function formatWeekNumberISO(d, p) {
1804 var day = d.getDay();
1805 d = (day >= 4 || day === 0) ? thursday(d) : thursday.ceil(d);
1806 return pad(thursday.count(year(d), d) + (year(d).getDay() === 4), p, 2);
1807}
1808
1809function formatWeekdayNumberSunday(d) {
1810 return d.getDay();
1811}
1812
1813function formatWeekNumberMonday(d, p) {
1814 return pad(monday.count(year(d), d), p, 2);
1815}
1816
1817function formatYear(d, p) {
1818 return pad(d.getFullYear() % 100, p, 2);
1819}
1820
1821function formatFullYear(d, p) {
1822 return pad(d.getFullYear() % 10000, p, 4);
1823}
1824
1825function formatZone(d) {
1826 var z = d.getTimezoneOffset();
1827 return (z > 0 ? "-" : (z *= -1, "+"))
1828 + pad(z / 60 | 0, "0", 2)
1829 + pad(z % 60, "0", 2);
1830}
1831
1832function formatUTCDayOfMonth(d, p) {
1833 return pad(d.getUTCDate(), p, 2);
1834}
1835
1836function formatUTCHour24(d, p) {
1837 return pad(d.getUTCHours(), p, 2);
1838}
1839
1840function formatUTCHour12(d, p) {
1841 return pad(d.getUTCHours() % 12 || 12, p, 2);
1842}
1843
1844function formatUTCDayOfYear(d, p) {
1845 return pad(1 + utcDay.count(utcYear(d), d), p, 3);
1846}
1847
1848function formatUTCMilliseconds(d, p) {
1849 return pad(d.getUTCMilliseconds(), p, 3);
1850}
1851
1852function formatUTCMicroseconds(d, p) {
1853 return formatUTCMilliseconds(d, p) + "000";
1854}
1855
1856function formatUTCMonthNumber(d, p) {
1857 return pad(d.getUTCMonth() + 1, p, 2);
1858}
1859
1860function formatUTCMinutes(d, p) {
1861 return pad(d.getUTCMinutes(), p, 2);
1862}
1863
1864function formatUTCSeconds(d, p) {
1865 return pad(d.getUTCSeconds(), p, 2);
1866}
1867
1868function formatUTCWeekdayNumberMonday(d) {
1869 var dow = d.getUTCDay();
1870 return dow === 0 ? 7 : dow;
1871}
1872
1873function formatUTCWeekNumberSunday(d, p) {
1874 return pad(utcSunday.count(utcYear(d), d), p, 2);
1875}
1876
1877function formatUTCWeekNumberISO(d, p) {
1878 var day = d.getUTCDay();
1879 d = (day >= 4 || day === 0) ? utcThursday(d) : utcThursday.ceil(d);
1880 return pad(utcThursday.count(utcYear(d), d) + (utcYear(d).getUTCDay() === 4), p, 2);
1881}
1882
1883function formatUTCWeekdayNumberSunday(d) {
1884 return d.getUTCDay();
1885}
1886
1887function formatUTCWeekNumberMonday(d, p) {
1888 return pad(utcMonday.count(utcYear(d), d), p, 2);
1889}
1890
1891function formatUTCYear(d, p) {
1892 return pad(d.getUTCFullYear() % 100, p, 2);
1893}
1894
1895function formatUTCFullYear(d, p) {
1896 return pad(d.getUTCFullYear() % 10000, p, 4);
1897}
1898
1899function formatUTCZone() {
1900 return "+0000";
1901}
1902
1903function formatLiteralPercent() {
1904 return "%";
1905}
1906
1907function formatUnixTimestamp(d) {
1908 return +d;
1909}
1910
1911function formatUnixTimestampSeconds(d) {
1912 return Math.floor(+d / 1000);
1913}
1914
1915var locale;
1916var timeFormat;
1917var timeParse;
1918var utcFormat;
1919var utcParse;
1920
1921defaultLocale({
1922 dateTime: "%x, %X",
1923 date: "%-m/%-d/%Y",
1924 time: "%-I:%M:%S %p",
1925 periods: ["AM", "PM"],
1926 days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
1927 shortDays: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
1928 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
1929 shortMonths: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
1930});
1931
1932function defaultLocale(definition) {
1933 locale = formatLocale(definition);
1934 timeFormat = locale.format;
1935 timeParse = locale.parse;
1936 utcFormat = locale.utcFormat;
1937 utcParse = locale.utcParse;
1938 return locale;
1939}
1940
1941var isoSpecifier = "%Y-%m-%dT%H:%M:%S.%LZ";
1942
1943function formatIsoNative(date) {
1944 return date.toISOString();
1945}
1946
1947var formatIso = Date.prototype.toISOString
1948 ? formatIsoNative
1949 : utcFormat(isoSpecifier);
1950
1951function parseIsoNative(string) {
1952 var date = new Date(string);
1953 return isNaN(date) ? null : date;
1954}
1955
1956var parseIso = +new Date("2000-01-01T00:00:00.000Z")
1957 ? parseIsoNative
1958 : utcParse(isoSpecifier);
1959
1960var ECLGraph = /** @class */ (function (_super) {
1961 __extends(ECLGraph, _super);
1962 function ECLGraph(wu, eclGraph, eclTimers) {
1963 var _this = _super.call(this) || this;
1964 _this.wu = wu;
1965 var duration = 0;
1966 for (var _i = 0, eclTimers_1 = eclTimers; _i < eclTimers_1.length; _i++) {
1967 var eclTimer = eclTimers_1[_i];
1968 if (eclTimer.GraphName === eclGraph.Name && !eclTimer.HasSubGraphId) {
1969 duration = Math.round(eclTimer.Seconds * 1000) / 1000;
1970 break;
1971 }
1972 }
1973 _this.set(__assign({ Time: duration }, eclGraph));
1974 return _this;
1975 }
1976 Object.defineProperty(ECLGraph.prototype, "properties", {
1977 get: function () { return this.get(); },
1978 enumerable: false,
1979 configurable: true
1980 });
1981 Object.defineProperty(ECLGraph.prototype, "Name", {
1982 get: function () { return this.get("Name"); },
1983 enumerable: false,
1984 configurable: true
1985 });
1986 Object.defineProperty(ECLGraph.prototype, "Label", {
1987 get: function () { return this.get("Label"); },
1988 enumerable: false,
1989 configurable: true
1990 });
1991 Object.defineProperty(ECLGraph.prototype, "Type", {
1992 get: function () { return this.get("Type"); },
1993 enumerable: false,
1994 configurable: true
1995 });
1996 Object.defineProperty(ECLGraph.prototype, "Complete", {
1997 get: function () { return this.get("Complete"); },
1998 enumerable: false,
1999 configurable: true
2000 });
2001 Object.defineProperty(ECLGraph.prototype, "WhenStarted", {
2002 get: function () { return this.get("WhenStarted"); },
2003 enumerable: false,
2004 configurable: true
2005 });
2006 Object.defineProperty(ECLGraph.prototype, "WhenFinished", {
2007 get: function () { return this.get("WhenFinished"); },
2008 enumerable: false,
2009 configurable: true
2010 });
2011 Object.defineProperty(ECLGraph.prototype, "Time", {
2012 get: function () { return this.get("Time"); },
2013 enumerable: false,
2014 configurable: true
2015 });
2016 Object.defineProperty(ECLGraph.prototype, "Running", {
2017 get: function () { return this.get("Running"); },
2018 enumerable: false,
2019 configurable: true
2020 });
2021 Object.defineProperty(ECLGraph.prototype, "RunningId", {
2022 get: function () { return this.get("RunningId"); },
2023 enumerable: false,
2024 configurable: true
2025 });
2026 Object.defineProperty(ECLGraph.prototype, "Failed", {
2027 get: function () { return this.get("Failed"); },
2028 enumerable: false,
2029 configurable: true
2030 });
2031 ECLGraph.prototype.fetchScopeGraph = function (subgraphID) {
2032 if (subgraphID) {
2033 return this.wu.fetchGraphDetails([subgraphID], ["subgraph"]).then(function (scopes) {
2034 return createGraph(scopes);
2035 });
2036 }
2037 return this.wu.fetchGraphDetails([this.Name], ["graph"]).then(function (scopes) {
2038 return createGraph(scopes);
2039 });
2040 };
2041 return ECLGraph;
2042}(util.StateObject));
2043var GraphCache = /** @class */ (function (_super) {
2044 __extends(GraphCache, _super);
2045 function GraphCache() {
2046 return _super.call(this, function (obj) {
2047 return util.Cache.hash([obj.Name]);
2048 }) || this;
2049 }
2050 return GraphCache;
2051}(util.Cache));
2052function walkXmlJson(node, callback, stack) {
2053 stack = stack || [];
2054 stack.push(node);
2055 callback(node.name, node.$, node.children(), stack);
2056 node.children().forEach(function (childNode) {
2057 walkXmlJson(childNode, callback, stack);
2058 });
2059 stack.pop();
2060}
2061function flattenAtt(nodes) {
2062 var retVal = {};
2063 nodes.forEach(function (node) {
2064 if (node.name === "att") {
2065 retVal[node.$["name"]] = node.$["value"];
2066 }
2067 });
2068 return retVal;
2069}
2070var XGMMLGraph = /** @class */ (function (_super) {
2071 __extends(XGMMLGraph, _super);
2072 function XGMMLGraph() {
2073 return _super !== null && _super.apply(this, arguments) || this;
2074 }
2075 return XGMMLGraph;
2076}(util.Graph));
2077var XGMMLSubgraph = /** @class */ (function (_super) {
2078 __extends(XGMMLSubgraph, _super);
2079 function XGMMLSubgraph() {
2080 return _super !== null && _super.apply(this, arguments) || this;
2081 }
2082 return XGMMLSubgraph;
2083}(util.Subgraph));
2084var XGMMLVertex = /** @class */ (function (_super) {
2085 __extends(XGMMLVertex, _super);
2086 function XGMMLVertex() {
2087 return _super !== null && _super.apply(this, arguments) || this;
2088 }
2089 return XGMMLVertex;
2090}(util.Vertex));
2091var XGMMLEdge = /** @class */ (function (_super) {
2092 __extends(XGMMLEdge, _super);
2093 function XGMMLEdge() {
2094 return _super !== null && _super.apply(this, arguments) || this;
2095 }
2096 return XGMMLEdge;
2097}(util.Edge));
2098function createXGMMLGraph(id, graphs) {
2099 var subgraphs = {};
2100 var vertices = {};
2101 var edges = {};
2102 var graph = new XGMMLGraph(function (item) {
2103 return item._["id"];
2104 });
2105 var stack = [graph.root];
2106 walkXmlJson(graphs, function (tag, attributes, childNodes, _stack) {
2107 var top = stack[stack.length - 1];
2108 switch (tag) {
2109 case "graph":
2110 break;
2111 case "node":
2112 if (childNodes.length && childNodes[0].children().length && childNodes[0].children()[0].name === "graph") {
2113 var subgraph = top.createSubgraph(flattenAtt(childNodes));
2114 stack.push(subgraph);
2115 subgraphs[attributes["id"]] = subgraph;
2116 }
2117 // TODO: Is this really a node when its also a subgraph?
2118 var vertex = top.createVertex(flattenAtt(childNodes));
2119 vertices[attributes["id"]] = vertex;
2120 break;
2121 case "edge":
2122 var edge = top.createEdge(vertices[attributes["source"]], vertices[attributes["target"]], flattenAtt(childNodes));
2123 edges[attributes["id"]] = edge;
2124 break;
2125 }
2126 });
2127 return graph;
2128}
2129var ScopeGraph = /** @class */ (function (_super) {
2130 __extends(ScopeGraph, _super);
2131 function ScopeGraph() {
2132 return _super !== null && _super.apply(this, arguments) || this;
2133 }
2134 return ScopeGraph;
2135}(util.Graph));
2136var ScopeSubgraph = /** @class */ (function (_super) {
2137 __extends(ScopeSubgraph, _super);
2138 function ScopeSubgraph() {
2139 return _super !== null && _super.apply(this, arguments) || this;
2140 }
2141 return ScopeSubgraph;
2142}(util.Subgraph));
2143var ScopeVertex = /** @class */ (function (_super) {
2144 __extends(ScopeVertex, _super);
2145 function ScopeVertex() {
2146 return _super !== null && _super.apply(this, arguments) || this;
2147 }
2148 return ScopeVertex;
2149}(util.Vertex));
2150var ScopeEdge = /** @class */ (function (_super) {
2151 __extends(ScopeEdge, _super);
2152 function ScopeEdge() {
2153 return _super !== null && _super.apply(this, arguments) || this;
2154 }
2155 return ScopeEdge;
2156}(util.Edge));
2157function createGraph(scopes) {
2158 var subgraphs = {};
2159 var edges = {};
2160 var graph;
2161 for (var _i = 0, scopes_1 = scopes; _i < scopes_1.length; _i++) {
2162 var scope = scopes_1[_i];
2163 switch (scope.ScopeType) {
2164 case "graph":
2165 graph = new ScopeGraph(function (item) { return item._.Id; }, scope);
2166 subgraphs[scope.ScopeName] = graph.root;
2167 break;
2168 case "subgraph":
2169 if (!graph) {
2170 graph = new ScopeGraph(function (item) { return item._.Id; }, scope);
2171 subgraphs[scope.ScopeName] = graph.root;
2172 }
2173 var scopeStack = scope.parentScope().split(":");
2174 var scopeParent1 = subgraphs[scope.parentScope()];
2175 while (scopeStack.length && !scopeParent1) {
2176 scopeParent1 = subgraphs[scopeStack.join(":")];
2177 scopeStack.pop();
2178 }
2179 if (!scopeParent1) {
2180 console.log("Missing SG:Parent (" + scope.Id + "): " + scope.parentScope());
2181 }
2182 else {
2183 var parent1 = scopeParent1;
2184 subgraphs[scope.ScopeName] = parent1.createSubgraph(scope);
2185 }
2186 break;
2187 case "activity":
2188 var scopeParent2 = subgraphs[scope.parentScope()];
2189 if (!scopeParent2) {
2190 console.log("Missing A:Parent (" + scope.Id + "): " + scope.parentScope());
2191 }
2192 else {
2193 scopeParent2.createVertex(scope);
2194 }
2195 break;
2196 case "edge":
2197 edges[scope.ScopeName] = scope;
2198 break;
2199 }
2200 }
2201 for (var id in edges) {
2202 var scope = edges[id];
2203 var scopeParent3 = subgraphs[scope.parentScope()];
2204 if (!scopeParent3) {
2205 console.log("Missing E:Parent (" + scope.Id + "): " + scope.parentScope());
2206 }
2207 else {
2208 var parent3 = scopeParent3;
2209 try {
2210 var source = graph.vertex(scope.attr("IdSource").RawValue);
2211 var target = graph.vertex(scope.attr("IdTarget").RawValue);
2212 parent3.createEdge(source, target, scope);
2213 }
2214 catch (e) {
2215 // const sourceIndex = scope.attr("SourceIndex").RawValue;
2216 // const targetIndex = scope.attr("TargetIndex").RawValue;
2217 console.log("Invalid Edge: " + id);
2218 }
2219 }
2220 }
2221 return graph;
2222}
2223
2224var Resource = /** @class */ (function (_super) {
2225 __extends(Resource, _super);
2226 function Resource(wu, url) {
2227 var _this = _super.call(this) || this;
2228 _this.wu = wu;
2229 var cleanedURL = url.split("\\").join("/");
2230 var urlParts = cleanedURL.split("/");
2231 var matchStr = "res/" + _this.wu.Wuid + "/";
2232 var displayPath = "";
2233 var displayName = "";
2234 if (cleanedURL.indexOf(matchStr) === 0) {
2235 displayPath = cleanedURL.substr(matchStr.length);
2236 displayName = urlParts[urlParts.length - 1];
2237 }
2238 _this.set({
2239 URL: url,
2240 DisplayName: displayName,
2241 DisplayPath: displayPath
2242 });
2243 return _this;
2244 }
2245 Object.defineProperty(Resource.prototype, "properties", {
2246 get: function () { return this.get(); },
2247 enumerable: false,
2248 configurable: true
2249 });
2250 Object.defineProperty(Resource.prototype, "URL", {
2251 get: function () { return this.get("URL"); },
2252 enumerable: false,
2253 configurable: true
2254 });
2255 Object.defineProperty(Resource.prototype, "DisplayName", {
2256 get: function () { return this.get("DisplayName"); },
2257 enumerable: false,
2258 configurable: true
2259 });
2260 Object.defineProperty(Resource.prototype, "DisplayPath", {
2261 get: function () { return this.get("DisplayPath"); },
2262 enumerable: false,
2263 configurable: true
2264 });
2265 return Resource;
2266}(util.StateObject));
2267
2268var XSDNode = /** @class */ (function () {
2269 function XSDNode(e) {
2270 this.e = e;
2271 }
2272 XSDNode.prototype.fix = function () {
2273 delete this.e;
2274 };
2275 return XSDNode;
2276}());
2277var XSDXMLNode = /** @class */ (function (_super) {
2278 __extends(XSDXMLNode, _super);
2279 function XSDXMLNode(e) {
2280 var _this = _super.call(this, e) || this;
2281 _this.attrs = {};
2282 _this._children = [];
2283 return _this;
2284 }
2285 XSDXMLNode.prototype.append = function (child) {
2286 this._children.push(child);
2287 if (!this.type) {
2288 this.type = "hpcc:childDataset";
2289 }
2290 };
2291 XSDXMLNode.prototype.fix = function () {
2292 var _a;
2293 this.name = this.e.$["name"];
2294 this.type = this.e.$["type"];
2295 for (var i = this._children.length - 1; i >= 0; --i) {
2296 var row = this._children[i];
2297 if (row.name === "Row" && row.type === undefined) {
2298 (_a = this._children).push.apply(_a, row._children);
2299 this._children.splice(i, 1);
2300 }
2301 }
2302 _super.prototype.fix.call(this);
2303 };
2304 XSDXMLNode.prototype.children = function () {
2305 return this._children;
2306 };
2307 XSDXMLNode.prototype.charWidth = function () {
2308 var retVal = -1;
2309 switch (this.type) {
2310 case "xs:boolean":
2311 retVal = 5;
2312 break;
2313 case "xs:integer":
2314 retVal = 8;
2315 break;
2316 case "xs:nonNegativeInteger":
2317 retVal = 8;
2318 break;
2319 case "xs:double":
2320 retVal = 8;
2321 break;
2322 case "xs:string":
2323 retVal = 32;
2324 break;
2325 default:
2326 var numStr = "0123456789";
2327 var underbarPos = this.type.lastIndexOf("_");
2328 var length_1 = underbarPos > 0 ? underbarPos : this.type.length;
2329 var i = length_1 - 1;
2330 for (; i >= 0; --i) {
2331 if (numStr.indexOf(this.type.charAt(i)) === -1)
2332 break;
2333 }
2334 if (i + 1 < length_1) {
2335 retVal = parseInt(this.type.substring(i + 1, length_1), 10);
2336 }
2337 if (this.type.indexOf("data") === 0) {
2338 retVal *= 2;
2339 }
2340 break;
2341 }
2342 if (retVal < this.name.length)
2343 retVal = this.name.length;
2344 return retVal;
2345 };
2346 return XSDXMLNode;
2347}(XSDNode));
2348var XSDSimpleType = /** @class */ (function (_super) {
2349 __extends(XSDSimpleType, _super);
2350 function XSDSimpleType(e) {
2351 return _super.call(this, e) || this;
2352 }
2353 XSDSimpleType.prototype.append = function (e) {
2354 switch (e.name) {
2355 case "xs:restriction":
2356 this._restricition = e;
2357 break;
2358 case "xs:maxLength":
2359 this._maxLength = e;
2360 break;
2361 }
2362 };
2363 XSDSimpleType.prototype.fix = function () {
2364 this.name = this.e.$["name"];
2365 this.type = this._restricition.$["base"];
2366 this.maxLength = this._maxLength ? +this._maxLength.$["value"] : undefined;
2367 delete this._restricition;
2368 delete this._maxLength;
2369 _super.prototype.fix.call(this);
2370 };
2371 return XSDSimpleType;
2372}(XSDNode));
2373var XSDSchema = /** @class */ (function () {
2374 function XSDSchema() {
2375 this.simpleTypes = {};
2376 }
2377 XSDSchema.prototype.fields = function () {
2378 return this.root.children();
2379 };
2380 return XSDSchema;
2381}());
2382var XSDParser = /** @class */ (function (_super) {
2383 __extends(XSDParser, _super);
2384 function XSDParser() {
2385 var _this = _super !== null && _super.apply(this, arguments) || this;
2386 _this.schema = new XSDSchema();
2387 _this.simpleTypes = {};
2388 _this.xsdStack = new util.Stack();
2389 return _this;
2390 }
2391 XSDParser.prototype.startXMLNode = function (e) {
2392 _super.prototype.startXMLNode.call(this, e);
2393 switch (e.name) {
2394 case "xs:element":
2395 var xsdXMLNode = new XSDXMLNode(e);
2396 if (!this.schema.root) {
2397 this.schema.root = xsdXMLNode;
2398 }
2399 else if (this.xsdStack.depth()) {
2400 this.xsdStack.top().append(xsdXMLNode);
2401 }
2402 this.xsdStack.push(xsdXMLNode);
2403 break;
2404 case "xs:simpleType":
2405 this.simpleType = new XSDSimpleType(e);
2406 break;
2407 }
2408 };
2409 XSDParser.prototype.endXMLNode = function (e) {
2410 switch (e.name) {
2411 case "xs:element":
2412 var xsdXMLNode = this.xsdStack.pop();
2413 xsdXMLNode.fix();
2414 break;
2415 case "xs:simpleType":
2416 this.simpleType.fix();
2417 this.simpleTypes[this.simpleType.name] = this.simpleType;
2418 delete this.simpleType;
2419 break;
2420 case "xs:appinfo":
2421 var xsdXMLNode2 = this.xsdStack.top();
2422 for (var key in e.$) {
2423 xsdXMLNode2.attrs[key] = e.$[key];
2424 }
2425 break;
2426 default:
2427 if (this.simpleType) {
2428 this.simpleType.append(e);
2429 }
2430 }
2431 _super.prototype.endXMLNode.call(this, e);
2432 };
2433 return XSDParser;
2434}(util.SAXStackParser));
2435function parseXSD(xml) {
2436 var saxParser = new XSDParser();
2437 saxParser.parse(xml);
2438 return saxParser.schema;
2439}
2440var XSDParser2 = /** @class */ (function (_super) {
2441 __extends(XSDParser2, _super);
2442 function XSDParser2(rootName) {
2443 var _this = _super.call(this) || this;
2444 _this.schema = new XSDSchema();
2445 _this.simpleTypes = {};
2446 _this.xsdStack = new util.Stack();
2447 _this._rootName = rootName;
2448 return _this;
2449 }
2450 XSDParser2.prototype.startXMLNode = function (e) {
2451 _super.prototype.startXMLNode.call(this, e);
2452 switch (e.name) {
2453 case "xsd:element":
2454 var xsdXMLNode = new XSDXMLNode(e);
2455 if (!this.schema.root && this._rootName === e.$.name) {
2456 this.schema.root = xsdXMLNode;
2457 }
2458 if (this.xsdStack.depth()) {
2459 this.xsdStack.top().append(xsdXMLNode);
2460 }
2461 this.xsdStack.push(xsdXMLNode);
2462 break;
2463 case "xsd:simpleType":
2464 this.simpleType = new XSDSimpleType(e);
2465 break;
2466 }
2467 };
2468 XSDParser2.prototype.endXMLNode = function (e) {
2469 switch (e.name) {
2470 case "xsd:element":
2471 var xsdXMLNode = this.xsdStack.pop();
2472 xsdXMLNode.fix();
2473 break;
2474 }
2475 _super.prototype.endXMLNode.call(this, e);
2476 };
2477 return XSDParser2;
2478}(XSDParser));
2479function parseXSD2(xml, rootName) {
2480 var saxParser = new XSDParser2(rootName);
2481 saxParser.parse(xml);
2482 return saxParser.schema;
2483}
2484
2485var GlobalResultCache = /** @class */ (function (_super) {
2486 __extends(GlobalResultCache, _super);
2487 function GlobalResultCache() {
2488 return _super.call(this, function (obj) {
2489 return obj.BaseUrl + "-" + obj.Wuid + "-" + obj.ResultName;
2490 }) || this;
2491 }
2492 return GlobalResultCache;
2493}(util.Cache));
2494var _results = new GlobalResultCache();
2495var Result = /** @class */ (function (_super) {
2496 __extends(Result, _super);
2497 function Result(optsConnection, wuidOrLogicalFile, eclResultOrResultName, resultViews) {
2498 if (resultViews === void 0) { resultViews = []; }
2499 var _this = _super.call(this) || this;
2500 if (optsConnection instanceof WorkunitsService) {
2501 _this.connection = optsConnection;
2502 }
2503 else {
2504 _this.connection = new WorkunitsService(optsConnection);
2505 }
2506 if (typeof eclResultOrResultName === "undefined") {
2507 _this.set({
2508 LogicalFileName: wuidOrLogicalFile
2509 });
2510 }
2511 else if (typeof eclResultOrResultName === "string") {
2512 _this.set({
2513 Wuid: wuidOrLogicalFile,
2514 ResultName: eclResultOrResultName,
2515 ResultViews: resultViews
2516 });
2517 }
2518 else if (typeof eclResultOrResultName === "number") {
2519 _this.set({
2520 Wuid: wuidOrLogicalFile,
2521 ResultSequence: eclResultOrResultName,
2522 ResultViews: resultViews
2523 });
2524 }
2525 else {
2526 _this.set(__assign({ Wuid: wuidOrLogicalFile, ResultName: eclResultOrResultName.Name, ResultViews: resultViews }, eclResultOrResultName));
2527 }
2528 return _this;
2529 }
2530 Object.defineProperty(Result.prototype, "BaseUrl", {
2531 get: function () { return this.connection.baseUrl; },
2532 enumerable: false,
2533 configurable: true
2534 });
2535 Object.defineProperty(Result.prototype, "properties", {
2536 get: function () { return this.get(); },
2537 enumerable: false,
2538 configurable: true
2539 });
2540 Object.defineProperty(Result.prototype, "Wuid", {
2541 get: function () { return this.get("Wuid"); },
2542 enumerable: false,
2543 configurable: true
2544 });
2545 Object.defineProperty(Result.prototype, "ResultName", {
2546 get: function () { return this.get("ResultName"); },
2547 enumerable: false,
2548 configurable: true
2549 });
2550 Object.defineProperty(Result.prototype, "ResultSequence", {
2551 get: function () { return this.get("ResultSequence"); },
2552 enumerable: false,
2553 configurable: true
2554 });
2555 Object.defineProperty(Result.prototype, "LogicalFileName", {
2556 get: function () { return this.get("LogicalFileName"); },
2557 enumerable: false,
2558 configurable: true
2559 });
2560 Object.defineProperty(Result.prototype, "Name", {
2561 get: function () { return this.get("Name"); },
2562 enumerable: false,
2563 configurable: true
2564 });
2565 Object.defineProperty(Result.prototype, "Sequence", {
2566 get: function () { return this.get("Sequence"); },
2567 enumerable: false,
2568 configurable: true
2569 });
2570 Object.defineProperty(Result.prototype, "Value", {
2571 get: function () { return this.get("Value"); },
2572 enumerable: false,
2573 configurable: true
2574 });
2575 Object.defineProperty(Result.prototype, "Link", {
2576 get: function () { return this.get("Link"); },
2577 enumerable: false,
2578 configurable: true
2579 });
2580 Object.defineProperty(Result.prototype, "FileName", {
2581 get: function () { return this.get("FileName"); },
2582 enumerable: false,
2583 configurable: true
2584 });
2585 Object.defineProperty(Result.prototype, "IsSupplied", {
2586 get: function () { return this.get("IsSupplied"); },
2587 enumerable: false,
2588 configurable: true
2589 });
2590 Object.defineProperty(Result.prototype, "ShowFileContent", {
2591 get: function () { return this.get("ShowFileContent"); },
2592 enumerable: false,
2593 configurable: true
2594 });
2595 Object.defineProperty(Result.prototype, "Total", {
2596 get: function () { return this.get("Total"); },
2597 enumerable: false,
2598 configurable: true
2599 });
2600 Object.defineProperty(Result.prototype, "ECLSchemas", {
2601 get: function () { return this.get("ECLSchemas"); },
2602 enumerable: false,
2603 configurable: true
2604 });
2605 Object.defineProperty(Result.prototype, "NodeGroup", {
2606 get: function () { return this.get("NodeGroup"); },
2607 enumerable: false,
2608 configurable: true
2609 });
2610 Object.defineProperty(Result.prototype, "ResultViews", {
2611 get: function () { return this.get("ResultViews"); },
2612 enumerable: false,
2613 configurable: true
2614 });
2615 Object.defineProperty(Result.prototype, "XmlSchema", {
2616 get: function () { return this.get("XmlSchema"); },
2617 enumerable: false,
2618 configurable: true
2619 });
2620 Result.attach = function (optsConnection, wuid, resultName, state) {
2621 var retVal = _results.get({ BaseUrl: optsConnection.baseUrl, Wuid: wuid, ResultName: resultName }, function () {
2622 return new Result(optsConnection, wuid, resultName);
2623 });
2624 if (state) {
2625 retVal.set(state);
2626 }
2627 return retVal;
2628 };
2629 Result.prototype.isComplete = function () {
2630 return this.Total !== -1;
2631 };
2632 Result.prototype.fetchXMLSchema = function () {
2633 var _this = this;
2634 if (this.xsdSchema) {
2635 return Promise.resolve(this.xsdSchema);
2636 }
2637 return this.WUResult().then(function (response) {
2638 if (util.exists("Result.XmlSchema.xml", response)) {
2639 _this.xsdSchema = parseXSD(response.Result.XmlSchema.xml);
2640 return _this.xsdSchema;
2641 }
2642 return null;
2643 });
2644 };
2645 Result.prototype.refresh = function () {
2646 return __awaiter(this, void 0, void 0, function () {
2647 return __generator(this, function (_a) {
2648 switch (_a.label) {
2649 case 0: return [4 /*yield*/, this.fetchRows(0, 1, true)];
2650 case 1:
2651 _a.sent();
2652 return [2 /*return*/, this];
2653 }
2654 });
2655 });
2656 };
2657 Result.prototype.fetchRows = function (from, count, includeSchema, filter) {
2658 var _this = this;
2659 if (from === void 0) { from = 0; }
2660 if (count === void 0) { count = -1; }
2661 if (includeSchema === void 0) { includeSchema = false; }
2662 if (filter === void 0) { filter = {}; }
2663 return this.WUResult(from, count, !includeSchema, filter).then(function (response) {
2664 var result = response.Result;
2665 delete response.Result; // Do not want it in "set"
2666 _this.set(__assign({}, response));
2667 if (util.exists("XmlSchema.xml", result)) {
2668 _this.xsdSchema = parseXSD(result.XmlSchema.xml);
2669 }
2670 if (util.exists("Row", result)) {
2671 return result.Row;
2672 }
2673 else if (_this.ResultName && util.exists(_this.ResultName, result)) {
2674 return result[_this.ResultName].Row;
2675 }
2676 return [];
2677 });
2678 };
2679 Result.prototype.rootField = function () {
2680 if (!this.xsdSchema)
2681 return null;
2682 return this.xsdSchema.root;
2683 };
2684 Result.prototype.fields = function () {
2685 if (!this.xsdSchema)
2686 return [];
2687 return this.xsdSchema.root.children();
2688 };
2689 Result.prototype.WUResult = function (start, count, suppressXmlSchema, filter) {
2690 if (start === void 0) { start = 0; }
2691 if (count === void 0) { count = 1; }
2692 if (suppressXmlSchema === void 0) { suppressXmlSchema = false; }
2693 if (filter === void 0) { filter = {}; }
2694 var FilterBy = {
2695 NamedValue: {
2696 itemcount: 0
2697 }
2698 };
2699 for (var key in filter) {
2700 FilterBy.NamedValue[FilterBy.NamedValue.itemcount++] = {
2701 Name: key,
2702 Value: filter[key]
2703 };
2704 }
2705 var request = { FilterBy: FilterBy };
2706 if (this.Wuid && this.ResultName !== undefined) {
2707 request.Wuid = this.Wuid;
2708 request.ResultName = this.ResultName;
2709 }
2710 else if (this.Wuid && this.ResultSequence !== undefined) {
2711 request.Wuid = this.Wuid;
2712 request.Sequence = this.ResultSequence;
2713 }
2714 else if (this.LogicalFileName && this.NodeGroup) {
2715 request.LogicalName = this.LogicalFileName;
2716 request.Cluster = this.NodeGroup;
2717 }
2718 else if (this.LogicalFileName) {
2719 request.LogicalName = this.LogicalFileName;
2720 }
2721 request.Start = start;
2722 request.Count = count;
2723 request.SuppressXmlSchema = suppressXmlSchema;
2724 return this.connection.WUResult(request).then(function (response) {
2725 return response;
2726 });
2727 };
2728 return Result;
2729}(util.StateObject));
2730var ResultCache = /** @class */ (function (_super) {
2731 __extends(ResultCache, _super);
2732 function ResultCache() {
2733 return _super.call(this, function (obj) {
2734 return util.Cache.hash([obj.Sequence, obj.Name, obj.FileName]);
2735 }) || this;
2736 }
2737 return ResultCache;
2738}(util.Cache));
2739
2740var Attribute = /** @class */ (function (_super) {
2741 __extends(Attribute, _super);
2742 function Attribute(scope, attribute) {
2743 var _this = _super.call(this) || this;
2744 _this.scope = scope;
2745 _this.set(attribute);
2746 return _this;
2747 }
2748 Object.defineProperty(Attribute.prototype, "properties", {
2749 get: function () { return this.get(); },
2750 enumerable: false,
2751 configurable: true
2752 });
2753 Object.defineProperty(Attribute.prototype, "Name", {
2754 get: function () { return this.get("Name"); },
2755 enumerable: false,
2756 configurable: true
2757 });
2758 Object.defineProperty(Attribute.prototype, "RawValue", {
2759 get: function () { return this.get("RawValue"); },
2760 enumerable: false,
2761 configurable: true
2762 });
2763 Object.defineProperty(Attribute.prototype, "Formatted", {
2764 get: function () { return this.get("Formatted"); },
2765 enumerable: false,
2766 configurable: true
2767 });
2768 Object.defineProperty(Attribute.prototype, "FormattedEnd", {
2769 get: function () { return this.get("FormattedEnd"); },
2770 enumerable: false,
2771 configurable: true
2772 });
2773 Object.defineProperty(Attribute.prototype, "Measure", {
2774 get: function () { return this.get("Measure"); },
2775 enumerable: false,
2776 configurable: true
2777 });
2778 Object.defineProperty(Attribute.prototype, "Creator", {
2779 get: function () { return this.get("Creator"); },
2780 enumerable: false,
2781 configurable: true
2782 });
2783 Object.defineProperty(Attribute.prototype, "CreatorType", {
2784 get: function () { return this.get("CreatorType"); },
2785 enumerable: false,
2786 configurable: true
2787 });
2788 return Attribute;
2789}(util.StateObject));
2790var BaseScope = /** @class */ (function (_super) {
2791 __extends(BaseScope, _super);
2792 function BaseScope(scope) {
2793 var _this = _super.call(this) || this;
2794 _this._attributeMap = {};
2795 _this._children = [];
2796 _this.update(scope);
2797 return _this;
2798 }
2799 Object.defineProperty(BaseScope.prototype, "properties", {
2800 get: function () { return this.get(); },
2801 enumerable: false,
2802 configurable: true
2803 });
2804 Object.defineProperty(BaseScope.prototype, "ScopeName", {
2805 get: function () { return this.get("ScopeName"); },
2806 enumerable: false,
2807 configurable: true
2808 });
2809 Object.defineProperty(BaseScope.prototype, "Id", {
2810 get: function () { return this.get("Id"); },
2811 enumerable: false,
2812 configurable: true
2813 });
2814 Object.defineProperty(BaseScope.prototype, "ScopeType", {
2815 get: function () { return this.get("ScopeType"); },
2816 enumerable: false,
2817 configurable: true
2818 });
2819 Object.defineProperty(BaseScope.prototype, "Properties", {
2820 get: function () { return this.get("Properties", { Property: [] }); },
2821 enumerable: false,
2822 configurable: true
2823 });
2824 Object.defineProperty(BaseScope.prototype, "CAttributes", {
2825 get: function () {
2826 var _this = this;
2827 // Match "started" and time elapsed
2828 var retVal = [];
2829 var timeElapsed = {
2830 start: null,
2831 end: null
2832 };
2833 this.Properties.Property.forEach(function (scopeAttr) {
2834 if (scopeAttr.Measure === "ts" && scopeAttr.Name.indexOf("Started") >= 0) {
2835 timeElapsed.start = scopeAttr;
2836 }
2837 else if (_this.ScopeName && scopeAttr.Measure === "ts" && scopeAttr.Name.indexOf("Finished") >= 0) {
2838 timeElapsed.end = scopeAttr;
2839 }
2840 else {
2841 retVal.push(new Attribute(_this, scopeAttr));
2842 }
2843 });
2844 if (timeElapsed.start && timeElapsed.end) {
2845 // const endTime = parser(timeElapsed.start.Formatted);
2846 // endTime!.setMilliseconds(endTime!.getMilliseconds() + (+timeElapsed.elapsed.RawValue) / 1000000);
2847 // timeElapsed.start.FormattedEnd = formatter(endTime!);
2848 timeElapsed.start.FormattedEnd = timeElapsed.end.Formatted;
2849 retVal.push(new Attribute(this, timeElapsed.start));
2850 }
2851 else if (timeElapsed.start) {
2852 retVal.push(new Attribute(this, timeElapsed.start));
2853 }
2854 else if (timeElapsed.end) {
2855 retVal.push(new Attribute(this, timeElapsed.end)); // Should not happen?
2856 }
2857 return retVal;
2858 },
2859 enumerable: false,
2860 configurable: true
2861 });
2862 BaseScope.prototype.update = function (scope) {
2863 var _this = this;
2864 this.set(scope);
2865 this.CAttributes.forEach(function (attr) {
2866 _this._attributeMap[attr.Name] = attr;
2867 });
2868 this.Properties.Property = [];
2869 for (var key in this._attributeMap) {
2870 if (this._attributeMap.hasOwnProperty(key)) {
2871 this.Properties.Property.push(this._attributeMap[key].properties);
2872 }
2873 }
2874 };
2875 BaseScope.prototype.parentScope = function () {
2876 var scopeParts = this.ScopeName.split(":");
2877 scopeParts.pop();
2878 return scopeParts.join(":");
2879 };
2880 BaseScope.prototype.children = function (_) {
2881 if (!arguments.length)
2882 return this._children;
2883 this._children = _;
2884 return this;
2885 };
2886 BaseScope.prototype.walk = function (visitor) {
2887 if (visitor.start(this))
2888 return true;
2889 for (var _i = 0, _a = this.children(); _i < _a.length; _i++) {
2890 var scope = _a[_i];
2891 if (scope.walk(visitor)) {
2892 return true;
2893 }
2894 }
2895 return visitor.end(this);
2896 };
2897 BaseScope.prototype.formattedAttrs = function () {
2898 var retVal = {};
2899 for (var attr in this._attributeMap) {
2900 retVal[attr] = this._attributeMap[attr].Formatted || this._attributeMap[attr].RawValue;
2901 }
2902 return retVal;
2903 };
2904 BaseScope.prototype.rawAttrs = function () {
2905 var retVal = {};
2906 for (var attr in this._attributeMap) {
2907 retVal[attr] = this._attributeMap[attr].RawValue;
2908 }
2909 return retVal;
2910 };
2911 BaseScope.prototype.hasAttr = function (name) {
2912 return this._attributeMap[name] !== undefined;
2913 };
2914 BaseScope.prototype.attr = function (name) {
2915 return this._attributeMap[name] || new Attribute(this, {
2916 Creator: "",
2917 CreatorType: "",
2918 Formatted: "",
2919 Measure: "",
2920 Name: "",
2921 RawValue: ""
2922 });
2923 };
2924 BaseScope.prototype.attrMeasure = function (name) {
2925 return this._attributeMap[name].Measure;
2926 };
2927 BaseScope.prototype.calcTooltip = function (parentScope) {
2928 var label = "";
2929 var rows = [];
2930 label = this.Id;
2931 rows.push("<tr><td class=\"key\">ID:</td><td class=\"value\">" + this.Id + "</td></tr>");
2932 if (parentScope) {
2933 rows.push("<tr><td class=\"key\">Parent ID:</td><td class=\"value\">" + parentScope.Id + "</td></tr>");
2934 }
2935 rows.push("<tr><td class=\"key\">Scope:</td><td class=\"value\">" + this.ScopeName + "</td></tr>");
2936 var attrs = this.formattedAttrs();
2937 for (var key in attrs) {
2938 if (key === "Label") {
2939 label = attrs[key];
2940 }
2941 else {
2942 rows.push("<tr><td class=\"key\">" + key + "</td><td class=\"value\">" + attrs[key] + "</td></tr>");
2943 }
2944 }
2945 return "<div class=\"eclwatch_WUGraph_Tooltip\" style=\"max-width:480px\">\n <h4 align=\"center\">" + label + "</h4>\n <table>\n " + rows.join("") + "\n </table>\n </div>";
2946 };
2947 return BaseScope;
2948}(util.StateObject));
2949var Scope = /** @class */ (function (_super) {
2950 __extends(Scope, _super);
2951 function Scope(wu, scope) {
2952 var _this = _super.call(this, scope) || this;
2953 _this.wu = wu;
2954 return _this;
2955 }
2956 return Scope;
2957}(BaseScope));
2958
2959var SourceFile = /** @class */ (function (_super) {
2960 __extends(SourceFile, _super);
2961 function SourceFile(optsConnection, wuid, eclSourceFile) {
2962 var _this = _super.call(this) || this;
2963 if (optsConnection instanceof WorkunitsService) {
2964 _this.connection = optsConnection;
2965 }
2966 else {
2967 _this.connection = new WorkunitsService(optsConnection);
2968 }
2969 _this.set(__assign({ Wuid: wuid }, eclSourceFile));
2970 return _this;
2971 }
2972 Object.defineProperty(SourceFile.prototype, "properties", {
2973 get: function () { return this.get(); },
2974 enumerable: false,
2975 configurable: true
2976 });
2977 Object.defineProperty(SourceFile.prototype, "Wuid", {
2978 get: function () { return this.get("Wuid"); },
2979 enumerable: false,
2980 configurable: true
2981 });
2982 Object.defineProperty(SourceFile.prototype, "FileCluster", {
2983 get: function () { return this.get("FileCluster"); },
2984 enumerable: false,
2985 configurable: true
2986 });
2987 Object.defineProperty(SourceFile.prototype, "Name", {
2988 get: function () { return this.get("Name"); },
2989 enumerable: false,
2990 configurable: true
2991 });
2992 Object.defineProperty(SourceFile.prototype, "IsSuperFile", {
2993 get: function () { return this.get("IsSuperFile"); },
2994 enumerable: false,
2995 configurable: true
2996 });
2997 Object.defineProperty(SourceFile.prototype, "Subs", {
2998 get: function () { return this.get("Subs"); },
2999 enumerable: false,
3000 configurable: true
3001 });
3002 Object.defineProperty(SourceFile.prototype, "Count", {
3003 get: function () { return this.get("Count"); },
3004 enumerable: false,
3005 configurable: true
3006 });
3007 Object.defineProperty(SourceFile.prototype, "ECLSourceFiles", {
3008 get: function () { return this.get("ECLSourceFiles"); },
3009 enumerable: false,
3010 configurable: true
3011 });
3012 return SourceFile;
3013}(util.StateObject));
3014
3015var Timer = /** @class */ (function (_super) {
3016 __extends(Timer, _super);
3017 function Timer(optsConnection, wuid, eclTimer) {
3018 var _this = _super.call(this) || this;
3019 if (optsConnection instanceof WorkunitsService) {
3020 _this.connection = optsConnection;
3021 }
3022 else {
3023 _this.connection = new WorkunitsService(optsConnection);
3024 }
3025 var secs = util.espTime2Seconds(eclTimer.Value);
3026 _this.set(__assign({ Wuid: wuid, Seconds: Math.round(secs * 1000) / 1000, HasSubGraphId: eclTimer.SubGraphId !== undefined }, eclTimer));
3027 return _this;
3028 }
3029 Object.defineProperty(Timer.prototype, "properties", {
3030 get: function () { return this.get(); },
3031 enumerable: false,
3032 configurable: true
3033 });
3034 Object.defineProperty(Timer.prototype, "Wuid", {
3035 get: function () { return this.get("Wuid"); },
3036 enumerable: false,
3037 configurable: true
3038 });
3039 Object.defineProperty(Timer.prototype, "Name", {
3040 get: function () { return this.get("Name"); },
3041 enumerable: false,
3042 configurable: true
3043 });
3044 Object.defineProperty(Timer.prototype, "Value", {
3045 get: function () { return this.get("Value"); },
3046 enumerable: false,
3047 configurable: true
3048 });
3049 Object.defineProperty(Timer.prototype, "Seconds", {
3050 get: function () { return this.get("Seconds"); },
3051 enumerable: false,
3052 configurable: true
3053 });
3054 Object.defineProperty(Timer.prototype, "GraphName", {
3055 get: function () { return this.get("GraphName"); },
3056 enumerable: false,
3057 configurable: true
3058 });
3059 Object.defineProperty(Timer.prototype, "SubGraphId", {
3060 get: function () { return this.get("SubGraphId"); },
3061 enumerable: false,
3062 configurable: true
3063 });
3064 Object.defineProperty(Timer.prototype, "HasSubGraphId", {
3065 get: function () { return this.get("HasSubGraphId"); },
3066 enumerable: false,
3067 configurable: true
3068 });
3069 Object.defineProperty(Timer.prototype, "count", {
3070 get: function () { return this.get("count"); },
3071 enumerable: false,
3072 configurable: true
3073 });
3074 return Timer;
3075}(util.StateObject));
3076
3077var formatter = utcFormat("%Y-%m-%dT%H:%M:%S.%LZ");
3078var parser = utcParse("%Y-%m-%dT%H:%M:%S.%LZ");
3079var logger$1 = util.scopedLogger("workunit.ts");
3080var WUStateID = exports.WUStateID;
3081var WorkunitCache = /** @class */ (function (_super) {
3082 __extends(WorkunitCache, _super);
3083 function WorkunitCache() {
3084 return _super.call(this, function (obj) {
3085 return obj.BaseUrl + "-" + obj.Wuid;
3086 }) || this;
3087 }
3088 return WorkunitCache;
3089}(util.Cache));
3090var _workunits = new WorkunitCache();
3091var Workunit = /** @class */ (function (_super) {
3092 __extends(Workunit, _super);
3093 // --- --- ---
3094 function Workunit(optsConnection, wuid) {
3095 var _this = _super.call(this) || this;
3096 _this._debugMode = false;
3097 _this._resultCache = new ResultCache();
3098 _this._graphCache = new GraphCache();
3099 _this.connection = new WorkunitsService(optsConnection);
3100 _this.topologyConnection = new TopologyService(optsConnection);
3101 _this.clearState(wuid);
3102 return _this;
3103 }
3104 Object.defineProperty(Workunit.prototype, "BaseUrl", {
3105 get: function () { return this.connection.baseUrl; },
3106 enumerable: false,
3107 configurable: true
3108 });
3109 Object.defineProperty(Workunit.prototype, "properties", {
3110 // Accessors ---
3111 get: function () { return this.get(); },
3112 enumerable: false,
3113 configurable: true
3114 });
3115 Object.defineProperty(Workunit.prototype, "Wuid", {
3116 get: function () { return this.get("Wuid"); },
3117 enumerable: false,
3118 configurable: true
3119 });
3120 Object.defineProperty(Workunit.prototype, "Owner", {
3121 get: function () { return this.get("Owner", ""); },
3122 enumerable: false,
3123 configurable: true
3124 });
3125 Object.defineProperty(Workunit.prototype, "Cluster", {
3126 get: function () { return this.get("Cluster", ""); },
3127 enumerable: false,
3128 configurable: true
3129 });
3130 Object.defineProperty(Workunit.prototype, "Jobname", {
3131 get: function () { return this.get("Jobname", ""); },
3132 enumerable: false,
3133 configurable: true
3134 });
3135 Object.defineProperty(Workunit.prototype, "Description", {
3136 get: function () { return this.get("Description", ""); },
3137 enumerable: false,
3138 configurable: true
3139 });
3140 Object.defineProperty(Workunit.prototype, "ActionEx", {
3141 get: function () { return this.get("ActionEx", ""); },
3142 enumerable: false,
3143 configurable: true
3144 });
3145 Object.defineProperty(Workunit.prototype, "StateID", {
3146 get: function () { return this.get("StateID", exports.WUStateID.Unknown); },
3147 enumerable: false,
3148 configurable: true
3149 });
3150 Object.defineProperty(Workunit.prototype, "State", {
3151 get: function () { return this.get("State") || exports.WUStateID[this.StateID]; },
3152 enumerable: false,
3153 configurable: true
3154 });
3155 Object.defineProperty(Workunit.prototype, "Protected", {
3156 get: function () { return this.get("Protected", false); },
3157 enumerable: false,
3158 configurable: true
3159 });
3160 Object.defineProperty(Workunit.prototype, "Exceptions", {
3161 get: function () { return this.get("Exceptions", { ECLException: [] }); },
3162 enumerable: false,
3163 configurable: true
3164 });
3165 Object.defineProperty(Workunit.prototype, "ResultViews", {
3166 get: function () { return this.get("ResultViews", []); },
3167 enumerable: false,
3168 configurable: true
3169 });
3170 Object.defineProperty(Workunit.prototype, "ResultCount", {
3171 get: function () { return this.get("ResultCount", 0); },
3172 enumerable: false,
3173 configurable: true
3174 });
3175 Object.defineProperty(Workunit.prototype, "Results", {
3176 get: function () { return this.get("Results", { ECLResult: [] }); },
3177 enumerable: false,
3178 configurable: true
3179 });
3180 Object.defineProperty(Workunit.prototype, "CResults", {
3181 get: function () {
3182 var _this = this;
3183 return this.Results.ECLResult.map(function (eclResult) {
3184 return _this._resultCache.get(eclResult, function () {
3185 return new Result(_this.connection, _this.Wuid, eclResult, _this.ResultViews);
3186 });
3187 });
3188 },
3189 enumerable: false,
3190 configurable: true
3191 });
3192 Object.defineProperty(Workunit.prototype, "SequenceResults", {
3193 get: function () {
3194 var retVal = {};
3195 this.CResults.forEach(function (result) {
3196 retVal[result.Sequence] = result;
3197 });
3198 return retVal;
3199 },
3200 enumerable: false,
3201 configurable: true
3202 });
3203 Object.defineProperty(Workunit.prototype, "Timers", {
3204 get: function () { return this.get("Timers", { ECLTimer: [] }); },
3205 enumerable: false,
3206 configurable: true
3207 });
3208 Object.defineProperty(Workunit.prototype, "CTimers", {
3209 get: function () {
3210 var _this = this;
3211 return this.Timers.ECLTimer.map(function (eclTimer) {
3212 return new Timer(_this.connection, _this.Wuid, eclTimer);
3213 });
3214 },
3215 enumerable: false,
3216 configurable: true
3217 });
3218 Object.defineProperty(Workunit.prototype, "GraphCount", {
3219 get: function () { return this.get("GraphCount", 0); },
3220 enumerable: false,
3221 configurable: true
3222 });
3223 Object.defineProperty(Workunit.prototype, "Graphs", {
3224 get: function () { return this.get("Graphs", { ECLGraph: [] }); },
3225 enumerable: false,
3226 configurable: true
3227 });
3228 Object.defineProperty(Workunit.prototype, "CGraphs", {
3229 get: function () {
3230 var _this = this;
3231 return this.Graphs.ECLGraph.map(function (eclGraph) {
3232 return _this._graphCache.get(eclGraph, function () {
3233 return new ECLGraph(_this, eclGraph, _this.CTimers);
3234 });
3235 });
3236 },
3237 enumerable: false,
3238 configurable: true
3239 });
3240 Object.defineProperty(Workunit.prototype, "ThorLogList", {
3241 get: function () { return this.get("ThorLogList"); },
3242 enumerable: false,
3243 configurable: true
3244 });
3245 Object.defineProperty(Workunit.prototype, "ResourceURLCount", {
3246 get: function () { return this.get("ResourceURLCount", 0); },
3247 enumerable: false,
3248 configurable: true
3249 });
3250 Object.defineProperty(Workunit.prototype, "ResourceURLs", {
3251 get: function () { return this.get("ResourceURLs", { URL: [] }); },
3252 enumerable: false,
3253 configurable: true
3254 });
3255 Object.defineProperty(Workunit.prototype, "CResourceURLs", {
3256 get: function () {
3257 var _this = this;
3258 return this.ResourceURLs.URL.map(function (url) {
3259 return new Resource(_this, url);
3260 });
3261 },
3262 enumerable: false,
3263 configurable: true
3264 });
3265 Object.defineProperty(Workunit.prototype, "TotalClusterTime", {
3266 get: function () { return this.get("TotalClusterTime", ""); },
3267 enumerable: false,
3268 configurable: true
3269 });
3270 Object.defineProperty(Workunit.prototype, "DateTimeScheduled", {
3271 get: function () { return this.get("DateTimeScheduled"); },
3272 enumerable: false,
3273 configurable: true
3274 });
3275 Object.defineProperty(Workunit.prototype, "IsPausing", {
3276 get: function () { return this.get("IsPausing"); },
3277 enumerable: false,
3278 configurable: true
3279 });
3280 Object.defineProperty(Workunit.prototype, "ThorLCR", {
3281 get: function () { return this.get("ThorLCR"); },
3282 enumerable: false,
3283 configurable: true
3284 });
3285 Object.defineProperty(Workunit.prototype, "ApplicationValues", {
3286 get: function () { return this.get("ApplicationValues", { ApplicationValue: [] }); },
3287 enumerable: false,
3288 configurable: true
3289 });
3290 Object.defineProperty(Workunit.prototype, "HasArchiveQuery", {
3291 get: function () { return this.get("HasArchiveQuery"); },
3292 enumerable: false,
3293 configurable: true
3294 });
3295 Object.defineProperty(Workunit.prototype, "StateEx", {
3296 get: function () { return this.get("StateEx"); },
3297 enumerable: false,
3298 configurable: true
3299 });
3300 Object.defineProperty(Workunit.prototype, "PriorityClass", {
3301 get: function () { return this.get("PriorityClass"); },
3302 enumerable: false,
3303 configurable: true
3304 });
3305 Object.defineProperty(Workunit.prototype, "PriorityLevel", {
3306 get: function () { return this.get("PriorityLevel"); },
3307 enumerable: false,
3308 configurable: true
3309 });
3310 Object.defineProperty(Workunit.prototype, "Snapshot", {
3311 get: function () { return this.get("Snapshot"); },
3312 enumerable: false,
3313 configurable: true
3314 });
3315 Object.defineProperty(Workunit.prototype, "ResultLimit", {
3316 get: function () { return this.get("ResultLimit"); },
3317 enumerable: false,
3318 configurable: true
3319 });
3320 Object.defineProperty(Workunit.prototype, "EventSchedule", {
3321 get: function () { return this.get("EventSchedule"); },
3322 enumerable: false,
3323 configurable: true
3324 });
3325 Object.defineProperty(Workunit.prototype, "HaveSubGraphTimings", {
3326 get: function () { return this.get("HaveSubGraphTimings"); },
3327 enumerable: false,
3328 configurable: true
3329 });
3330 Object.defineProperty(Workunit.prototype, "Query", {
3331 get: function () { return this.get("Query"); },
3332 enumerable: false,
3333 configurable: true
3334 });
3335 Object.defineProperty(Workunit.prototype, "HelpersCount", {
3336 get: function () { return this.get("HelpersCount", 0); },
3337 enumerable: false,
3338 configurable: true
3339 });
3340 Object.defineProperty(Workunit.prototype, "Helpers", {
3341 get: function () { return this.get("Helpers", { ECLHelpFile: [] }); },
3342 enumerable: false,
3343 configurable: true
3344 });
3345 Object.defineProperty(Workunit.prototype, "DebugValues", {
3346 get: function () { return this.get("DebugValues"); },
3347 enumerable: false,
3348 configurable: true
3349 });
3350 Object.defineProperty(Workunit.prototype, "AllowedClusters", {
3351 get: function () { return this.get("AllowedClusters"); },
3352 enumerable: false,
3353 configurable: true
3354 });
3355 Object.defineProperty(Workunit.prototype, "ErrorCount", {
3356 get: function () { return this.get("ErrorCount", 0); },
3357 enumerable: false,
3358 configurable: true
3359 });
3360 Object.defineProperty(Workunit.prototype, "WarningCount", {
3361 get: function () { return this.get("WarningCount", 0); },
3362 enumerable: false,
3363 configurable: true
3364 });
3365 Object.defineProperty(Workunit.prototype, "InfoCount", {
3366 get: function () { return this.get("InfoCount", 0); },
3367 enumerable: false,
3368 configurable: true
3369 });
3370 Object.defineProperty(Workunit.prototype, "AlertCount", {
3371 get: function () { return this.get("AlertCount", 0); },
3372 enumerable: false,
3373 configurable: true
3374 });
3375 Object.defineProperty(Workunit.prototype, "SourceFileCount", {
3376 get: function () { return this.get("SourceFileCount", 0); },
3377 enumerable: false,
3378 configurable: true
3379 });
3380 Object.defineProperty(Workunit.prototype, "SourceFiles", {
3381 get: function () { return this.get("SourceFiles", { ECLSourceFile: [] }); },
3382 enumerable: false,
3383 configurable: true
3384 });
3385 Object.defineProperty(Workunit.prototype, "CSourceFiles", {
3386 get: function () {
3387 var _this = this;
3388 return this.SourceFiles.ECLSourceFile.map(function (eclSourceFile) { return new SourceFile(_this.connection, _this.Wuid, eclSourceFile); });
3389 },
3390 enumerable: false,
3391 configurable: true
3392 });
3393 Object.defineProperty(Workunit.prototype, "VariableCount", {
3394 get: function () { return this.get("VariableCount", 0); },
3395 enumerable: false,
3396 configurable: true
3397 });
3398 Object.defineProperty(Workunit.prototype, "Variables", {
3399 get: function () { return this.get("Variables", { ECLResult: [] }); },
3400 enumerable: false,
3401 configurable: true
3402 });
3403 Object.defineProperty(Workunit.prototype, "TimerCount", {
3404 get: function () { return this.get("TimerCount", 0); },
3405 enumerable: false,
3406 configurable: true
3407 });
3408 Object.defineProperty(Workunit.prototype, "HasDebugValue", {
3409 get: function () { return this.get("HasDebugValue"); },
3410 enumerable: false,
3411 configurable: true
3412 });
3413 Object.defineProperty(Workunit.prototype, "ApplicationValueCount", {
3414 get: function () { return this.get("ApplicationValueCount", 0); },
3415 enumerable: false,
3416 configurable: true
3417 });
3418 Object.defineProperty(Workunit.prototype, "XmlParams", {
3419 get: function () { return this.get("XmlParams"); },
3420 enumerable: false,
3421 configurable: true
3422 });
3423 Object.defineProperty(Workunit.prototype, "AccessFlag", {
3424 get: function () { return this.get("AccessFlag"); },
3425 enumerable: false,
3426 configurable: true
3427 });
3428 Object.defineProperty(Workunit.prototype, "ClusterFlag", {
3429 get: function () { return this.get("ClusterFlag"); },
3430 enumerable: false,
3431 configurable: true
3432 });
3433 Object.defineProperty(Workunit.prototype, "ResultViewCount", {
3434 get: function () { return this.get("ResultViewCount", 0); },
3435 enumerable: false,
3436 configurable: true
3437 });
3438 Object.defineProperty(Workunit.prototype, "DebugValueCount", {
3439 get: function () { return this.get("DebugValueCount", 0); },
3440 enumerable: false,
3441 configurable: true
3442 });
3443 Object.defineProperty(Workunit.prototype, "WorkflowCount", {
3444 get: function () { return this.get("WorkflowCount", 0); },
3445 enumerable: false,
3446 configurable: true
3447 });
3448 Object.defineProperty(Workunit.prototype, "Archived", {
3449 get: function () { return this.get("Archived"); },
3450 enumerable: false,
3451 configurable: true
3452 });
3453 Object.defineProperty(Workunit.prototype, "RoxieCluster", {
3454 get: function () { return this.get("RoxieCluster"); },
3455 enumerable: false,
3456 configurable: true
3457 });
3458 Object.defineProperty(Workunit.prototype, "DebugState", {
3459 get: function () { return this.get("DebugState", {}); },
3460 enumerable: false,
3461 configurable: true
3462 });
3463 Object.defineProperty(Workunit.prototype, "Queue", {
3464 get: function () { return this.get("Queue"); },
3465 enumerable: false,
3466 configurable: true
3467 });
3468 Object.defineProperty(Workunit.prototype, "Active", {
3469 get: function () { return this.get("Active"); },
3470 enumerable: false,
3471 configurable: true
3472 });
3473 Object.defineProperty(Workunit.prototype, "Action", {
3474 get: function () { return this.get("Action"); },
3475 enumerable: false,
3476 configurable: true
3477 });
3478 Object.defineProperty(Workunit.prototype, "Scope", {
3479 get: function () { return this.get("Scope"); },
3480 enumerable: false,
3481 configurable: true
3482 });
3483 Object.defineProperty(Workunit.prototype, "AbortBy", {
3484 get: function () { return this.get("AbortBy"); },
3485 enumerable: false,
3486 configurable: true
3487 });
3488 Object.defineProperty(Workunit.prototype, "AbortTime", {
3489 get: function () { return this.get("AbortTime"); },
3490 enumerable: false,
3491 configurable: true
3492 });
3493 Object.defineProperty(Workunit.prototype, "Workflows", {
3494 get: function () { return this.get("Workflows"); },
3495 enumerable: false,
3496 configurable: true
3497 });
3498 Object.defineProperty(Workunit.prototype, "TimingData", {
3499 get: function () { return this.get("TimingData"); },
3500 enumerable: false,
3501 configurable: true
3502 });
3503 Object.defineProperty(Workunit.prototype, "HelpersDesc", {
3504 get: function () { return this.get("HelpersDesc"); },
3505 enumerable: false,
3506 configurable: true
3507 });
3508 Object.defineProperty(Workunit.prototype, "GraphsDesc", {
3509 get: function () { return this.get("GraphsDesc"); },
3510 enumerable: false,
3511 configurable: true
3512 });
3513 Object.defineProperty(Workunit.prototype, "SourceFilesDesc", {
3514 get: function () { return this.get("GraphsDesc"); },
3515 enumerable: false,
3516 configurable: true
3517 });
3518 Object.defineProperty(Workunit.prototype, "ResultsDesc", {
3519 get: function () { return this.get("GraphsDesc"); },
3520 enumerable: false,
3521 configurable: true
3522 });
3523 Object.defineProperty(Workunit.prototype, "VariablesDesc", {
3524 get: function () { return this.get("GraphsDesc"); },
3525 enumerable: false,
3526 configurable: true
3527 });
3528 Object.defineProperty(Workunit.prototype, "TimersDesc", {
3529 get: function () { return this.get("GraphsDesc"); },
3530 enumerable: false,
3531 configurable: true
3532 });
3533 Object.defineProperty(Workunit.prototype, "DebugValuesDesc", {
3534 get: function () { return this.get("GraphsDesc"); },
3535 enumerable: false,
3536 configurable: true
3537 });
3538 Object.defineProperty(Workunit.prototype, "ApplicationValuesDesc", {
3539 get: function () { return this.get("GraphsDesc"); },
3540 enumerable: false,
3541 configurable: true
3542 });
3543 Object.defineProperty(Workunit.prototype, "WorkflowsDesc", {
3544 get: function () { return this.get("GraphsDesc"); },
3545 enumerable: false,
3546 configurable: true
3547 });
3548 // Factories ---
3549 Workunit.create = function (optsConnection) {
3550 var retVal = new Workunit(optsConnection);
3551 return retVal.connection.WUCreate().then(function (response) {
3552 _workunits.set(retVal);
3553 retVal.set(response.Workunit);
3554 return retVal;
3555 });
3556 };
3557 Workunit.attach = function (optsConnection, wuid, state) {
3558 var retVal = _workunits.get({ BaseUrl: optsConnection.baseUrl, Wuid: wuid }, function () {
3559 return new Workunit(optsConnection, wuid);
3560 });
3561 if (state) {
3562 retVal.set(state);
3563 }
3564 return retVal;
3565 };
3566 Workunit.existsLocal = function (baseUrl, wuid) {
3567 return _workunits.has({ BaseUrl: baseUrl, Wuid: wuid });
3568 };
3569 Workunit.submit = function (server, target, ecl) {
3570 return Workunit.create(server).then(function (wu) {
3571 return wu.update({ QueryText: ecl });
3572 }).then(function (wu) {
3573 return wu.submit(target);
3574 });
3575 };
3576 Workunit.query = function (server, opts) {
3577 var wsWorkunits = new WorkunitsService(server);
3578 return wsWorkunits.WUQuery(opts).then(function (response) {
3579 return response.Workunits.ECLWorkunit.map(function (wu) {
3580 return Workunit.attach(server, wu.Wuid, wu);
3581 });
3582 });
3583 };
3584 Workunit.prototype.clearState = function (wuid) {
3585 this.clear({
3586 Wuid: wuid,
3587 StateID: WUStateID.Unknown
3588 });
3589 };
3590 Workunit.prototype.update = function (request) {
3591 var _this = this;
3592 return this.connection.WUUpdate(__assign(__assign({}, request), {
3593 Wuid: this.Wuid,
3594 StateOrig: this.State,
3595 JobnameOrig: this.Jobname,
3596 DescriptionOrig: this.Description,
3597 ProtectedOrig: this.Protected,
3598 ClusterOrig: this.Cluster
3599 })).then(function (response) {
3600 _this.set(response.Workunit);
3601 return _this;
3602 });
3603 };
3604 Workunit.prototype.submit = function (_cluster, action, resultLimit) {
3605 var _this = this;
3606 if (action === void 0) { action = exports.WUUpdate.Action.Run; }
3607 var clusterPromise;
3608 if (_cluster !== void 0) {
3609 clusterPromise = Promise.resolve(_cluster);
3610 }
3611 else {
3612 clusterPromise = this.topologyConnection.DefaultTpLogicalClusterQuery().then(function (response) {
3613 return response.Name;
3614 });
3615 }
3616 this._debugMode = false;
3617 if (action === exports.WUUpdate.Action.Debug) {
3618 action = exports.WUUpdate.Action.Run;
3619 this._debugMode = true;
3620 }
3621 return clusterPromise.then(function (cluster) {
3622 return _this.connection.WUUpdate({
3623 Wuid: _this.Wuid,
3624 Action: action,
3625 ResultLimit: resultLimit,
3626 DebugValues: {
3627 DebugValue: [
3628 {
3629 Name: "Debug",
3630 Value: _this._debugMode ? "1" : ""
3631 }
3632 ]
3633 }
3634 }).then(function (response) {
3635 _this.set(response.Workunit);
3636 _this._submitAction = action;
3637 return _this.connection.WUSubmit({ Wuid: _this.Wuid, Cluster: cluster });
3638 });
3639 }).then(function () {
3640 return _this;
3641 });
3642 };
3643 Workunit.prototype.isComplete = function () {
3644 switch (this.StateID) {
3645 case WUStateID.Compiled:
3646 return this.ActionEx === "compile" || this._submitAction === exports.WUUpdate.Action.Compile;
3647 case WUStateID.Completed:
3648 case WUStateID.Failed:
3649 case WUStateID.Aborted:
3650 case WUStateID.NotFound:
3651 return true;
3652 }
3653 return false;
3654 };
3655 Workunit.prototype.isFailed = function () {
3656 switch (this.StateID) {
3657 case WUStateID.Aborted:
3658 case WUStateID.Failed:
3659 return true;
3660 }
3661 return false;
3662 };
3663 Workunit.prototype.isDeleted = function () {
3664 switch (this.StateID) {
3665 case WUStateID.NotFound:
3666 return true;
3667 }
3668 return false;
3669 };
3670 Workunit.prototype.isDebugging = function () {
3671 switch (this.StateID) {
3672 case WUStateID.DebugPaused:
3673 case WUStateID.DebugRunning:
3674 return true;
3675 }
3676 return this._debugMode;
3677 };
3678 Workunit.prototype.isRunning = function () {
3679 switch (this.StateID) {
3680 case WUStateID.Compiled:
3681 case WUStateID.Running:
3682 case WUStateID.Aborting:
3683 case WUStateID.Blocked:
3684 case WUStateID.DebugPaused:
3685 case WUStateID.DebugRunning:
3686 return true;
3687 }
3688 return false;
3689 };
3690 Workunit.prototype.setToFailed = function () {
3691 return this.WUAction("SetToFailed");
3692 };
3693 Workunit.prototype.pause = function () {
3694 return this.WUAction("Pause");
3695 };
3696 Workunit.prototype.pauseNow = function () {
3697 return this.WUAction("PauseNow");
3698 };
3699 Workunit.prototype.resume = function () {
3700 return this.WUAction("Resume");
3701 };
3702 Workunit.prototype.abort = function () {
3703 return this.WUAction("Abort");
3704 };
3705 Workunit.prototype.delete = function () {
3706 return this.WUAction("Delete");
3707 };
3708 Workunit.prototype.restore = function () {
3709 return this.WUAction("Restore");
3710 };
3711 Workunit.prototype.deschedule = function () {
3712 return this.WUAction("Deschedule");
3713 };
3714 Workunit.prototype.reschedule = function () {
3715 return this.WUAction("Reschedule");
3716 };
3717 Workunit.prototype.resubmit = function () {
3718 var _this = this;
3719 return this.WUResubmit({
3720 CloneWorkunit: false,
3721 ResetWorkflow: false
3722 }).then(function () {
3723 _this.clearState(_this.Wuid);
3724 return _this.refresh().then(function () {
3725 _this._monitor();
3726 return _this;
3727 });
3728 });
3729 };
3730 Workunit.prototype.clone = function () {
3731 var _this = this;
3732 return this.WUResubmit({
3733 CloneWorkunit: true,
3734 ResetWorkflow: false
3735 }).then(function (response) {
3736 return Workunit.attach(_this.connection.connection(), response.WUs.WU[0].WUID)
3737 .refresh();
3738 });
3739 };
3740 Workunit.prototype.refreshState = function () {
3741 return __awaiter(this, void 0, void 0, function () {
3742 return __generator(this, function (_a) {
3743 switch (_a.label) {
3744 case 0: return [4 /*yield*/, this.WUQuery()];
3745 case 1:
3746 _a.sent();
3747 return [2 /*return*/, this];
3748 }
3749 });
3750 });
3751 };
3752 Workunit.prototype.refreshInfo = function () {
3753 return __awaiter(this, void 0, void 0, function () {
3754 return __generator(this, function (_a) {
3755 switch (_a.label) {
3756 case 0: return [4 /*yield*/, this.WUInfo()];
3757 case 1:
3758 _a.sent();
3759 return [2 /*return*/, this];
3760 }
3761 });
3762 });
3763 };
3764 Workunit.prototype.refreshDebug = function () {
3765 return __awaiter(this, void 0, void 0, function () {
3766 return __generator(this, function (_a) {
3767 switch (_a.label) {
3768 case 0: return [4 /*yield*/, this.debugStatus()];
3769 case 1:
3770 _a.sent();
3771 return [2 /*return*/, this];
3772 }
3773 });
3774 });
3775 };
3776 Workunit.prototype.refresh = function (full) {
3777 if (full === void 0) { full = false; }
3778 return __awaiter(this, void 0, void 0, function () {
3779 return __generator(this, function (_a) {
3780 switch (_a.label) {
3781 case 0:
3782 if (!full) return [3 /*break*/, 2];
3783 return [4 /*yield*/, Promise.all([this.refreshInfo(), this.refreshDebug()])];
3784 case 1:
3785 _a.sent();
3786 return [3 /*break*/, 4];
3787 case 2: return [4 /*yield*/, this.refreshState()];
3788 case 3:
3789 _a.sent();
3790 _a.label = 4;
3791 case 4: return [2 /*return*/, this];
3792 }
3793 });
3794 });
3795 };
3796 Workunit.prototype.eclExceptions = function () {
3797 return this.Exceptions.ECLException;
3798 };
3799 Workunit.prototype.fetchArchive = function () {
3800 return this.connection.WUFile({
3801 Wuid: this.Wuid,
3802 Type: "ArchiveQuery"
3803 });
3804 };
3805 Workunit.prototype.fetchECLExceptions = function () {
3806 var _this = this;
3807 return this.WUInfo({ IncludeExceptions: true }).then(function () {
3808 return _this.eclExceptions();
3809 });
3810 };
3811 Workunit.prototype.fetchResults = function () {
3812 var _this = this;
3813 return this.WUInfo({ IncludeResults: true }).then(function () {
3814 return _this.CResults;
3815 });
3816 };
3817 Workunit.prototype.fetchGraphs = function () {
3818 var _this = this;
3819 return this.WUInfo({ IncludeGraphs: true }).then(function () {
3820 return _this.CGraphs;
3821 });
3822 };
3823 Workunit.prototype.fetchDetailsMeta = function (request) {
3824 if (request === void 0) { request = {}; }
3825 return this.WUDetailsMeta(request);
3826 };
3827 Workunit.prototype.fetchDetailsRaw = function (request) {
3828 if (request === void 0) { request = {}; }
3829 return this.WUDetails(request).then(function (response) { return response.Scopes.Scope; });
3830 };
3831 Workunit.prototype.fetchDetailsNormalized = function (request) {
3832 if (request === void 0) { request = {}; }
3833 return Promise.all([this.fetchDetailsMeta(), this.fetchDetailsRaw(request)]).then(function (promises) {
3834 var meta = promises[0];
3835 var scopes = promises[1];
3836 var columns = {
3837 id: {
3838 Measure: "label"
3839 },
3840 name: {
3841 Measure: "label"
3842 },
3843 type: {
3844 Measure: "label"
3845 }
3846 };
3847 var data = [];
3848 for (var _i = 0, scopes_1 = scopes; _i < scopes_1.length; _i++) {
3849 var scope = scopes_1[_i];
3850 var props = {};
3851 if (scope && scope.Id && scope.Properties && scope.Properties.Property) {
3852 for (var key in scope.Properties.Property) {
3853 var scopeProperty = scope.Properties.Property[key];
3854 if (scopeProperty.Measure === "ns") {
3855 scopeProperty.Measure = "s";
3856 }
3857 columns[scopeProperty.Name] = __assign({}, scopeProperty);
3858 delete columns[scopeProperty.Name].RawValue;
3859 delete columns[scopeProperty.Name].Formatted;
3860 switch (scopeProperty.Measure) {
3861 case "bool":
3862 props[scopeProperty.Name] = !!+scopeProperty.RawValue;
3863 break;
3864 case "sz":
3865 props[scopeProperty.Name] = +scopeProperty.RawValue;
3866 break;
3867 case "s":
3868 props[scopeProperty.Name] = +scopeProperty.RawValue / 1000000000;
3869 break;
3870 case "ns":
3871 props[scopeProperty.Name] = +scopeProperty.RawValue;
3872 break;
3873 case "ts":
3874 props[scopeProperty.Name] = new Date(+scopeProperty.RawValue / 1000).toISOString();
3875 break;
3876 case "cnt":
3877 props[scopeProperty.Name] = +scopeProperty.RawValue;
3878 break;
3879 case "cpu":
3880 case "skw":
3881 case "node":
3882 case "ppm":
3883 case "ip":
3884 case "cy":
3885 case "en":
3886 case "txt":
3887 case "id":
3888 case "fname":
3889 default:
3890 props[scopeProperty.Name] = scopeProperty.RawValue;
3891 }
3892 }
3893 data.push(__assign({ id: scope.Id, name: scope.ScopeName, type: scope.ScopeType }, props));
3894 }
3895 }
3896 return {
3897 meta: meta,
3898 columns: columns,
3899 data: data
3900 };
3901 });
3902 };
3903 Workunit.prototype.fetchDetails = function (request) {
3904 var _this = this;
3905 if (request === void 0) { request = {}; }
3906 return this.WUDetails(request).then(function (response) {
3907 return response.Scopes.Scope.map(function (rawScope) {
3908 return new Scope(_this, rawScope);
3909 });
3910 });
3911 };
3912 Workunit.prototype.fetchDetailsHierarchy = function (request) {
3913 var _this = this;
3914 if (request === void 0) { request = {}; }
3915 return this.WUDetails(request).then(function (response) {
3916 var retVal = [];
3917 // Recreate Scope Hierarchy and dedup ---
3918 var scopeMap = {};
3919 response.Scopes.Scope.forEach(function (rawScope) {
3920 if (scopeMap[rawScope.ScopeName]) {
3921 scopeMap[rawScope.ScopeName].update(rawScope);
3922 return null;
3923 }
3924 else {
3925 var scope = new Scope(_this, rawScope);
3926 scopeMap[scope.ScopeName] = scope;
3927 return scope;
3928 }
3929 });
3930 for (var key in scopeMap) {
3931 if (scopeMap.hasOwnProperty(key)) {
3932 var scope = scopeMap[key];
3933 var parentScopeID = scope.parentScope();
3934 if (parentScopeID && scopeMap[parentScopeID]) {
3935 scopeMap[parentScopeID].children().push(scope);
3936 }
3937 else {
3938 retVal.push(scope);
3939 }
3940 }
3941 }
3942 return retVal;
3943 });
3944 };
3945 Workunit.prototype.fetchGraphDetails = function (graphIDs, rootTypes) {
3946 if (graphIDs === void 0) { graphIDs = []; }
3947 return this.fetchDetails({
3948 ScopeFilter: {
3949 MaxDepth: 999999,
3950 Ids: graphIDs,
3951 ScopeTypes: rootTypes
3952 },
3953 NestedFilter: {
3954 Depth: 999999,
3955 ScopeTypes: ["graph", "subgraph", "activity", "edge"]
3956 },
3957 PropertiesToReturn: {
3958 AllStatistics: true,
3959 AllAttributes: true,
3960 AllHints: true,
3961 AllProperties: true,
3962 AllScopes: true
3963 },
3964 ScopeOptions: {
3965 IncludeId: true,
3966 IncludeScope: true,
3967 IncludeScopeType: true
3968 },
3969 PropertyOptions: {
3970 IncludeName: true,
3971 IncludeRawValue: true,
3972 IncludeFormatted: true,
3973 IncludeMeasure: true,
3974 IncludeCreator: false,
3975 IncludeCreatorType: false
3976 }
3977 });
3978 };
3979 Workunit.prototype.fetchScopeGraphs = function (graphIDs) {
3980 if (graphIDs === void 0) { graphIDs = []; }
3981 return this.fetchGraphDetails(graphIDs, ["graph"]).then(function (scopes) {
3982 return createGraph(scopes);
3983 });
3984 };
3985 Workunit.prototype.fetchTimeElapsed = function () {
3986 return this.fetchDetails({
3987 ScopeFilter: {
3988 PropertyFilters: {
3989 PropertyFilter: [{ Name: "TimeElapsed" }]
3990 }
3991 }
3992 }).then(function (scopes) {
3993 var scopeInfo = {};
3994 scopes.forEach(function (scope) {
3995 scopeInfo[scope.ScopeName] = scopeInfo[scope.ScopeName] || {
3996 scope: scope.ScopeName,
3997 start: null,
3998 elapsed: null,
3999 finish: null
4000 };
4001 scope.CAttributes.forEach(function (attr) {
4002 if (attr.Name === "TimeElapsed") {
4003 scopeInfo[scope.ScopeName].elapsed = +attr.RawValue;
4004 }
4005 else if (attr.Measure === "ts" && attr.Name.indexOf("Started") >= 0) {
4006 scopeInfo[scope.ScopeName].start = attr.Formatted;
4007 }
4008 });
4009 });
4010 // Workaround duplicate scope responses
4011 var retVal = [];
4012 for (var key in scopeInfo) {
4013 var scope = scopeInfo[key];
4014 if (scope.start && scope.elapsed) {
4015 var endTime = parser(scope.start);
4016 endTime.setMilliseconds(endTime.getMilliseconds() + scope.elapsed / 1000000);
4017 scope.finish = formatter(endTime);
4018 retVal.push(scope);
4019 }
4020 }
4021 retVal.sort(function (l, r) {
4022 if (l.start < r.start)
4023 return -1;
4024 if (l.start > r.start)
4025 return 1;
4026 return 0;
4027 });
4028 return retVal;
4029 });
4030 };
4031 // Monitoring ---
4032 Workunit.prototype._monitor = function () {
4033 if (this.isComplete()) {
4034 this._monitorTickCount = 0;
4035 return;
4036 }
4037 _super.prototype._monitor.call(this);
4038 };
4039 Workunit.prototype._monitorTimeoutDuraction = function () {
4040 var retVal = _super.prototype._monitorTimeoutDuraction.call(this);
4041 if (this._monitorTickCount <= 1) { // Once
4042 return 1000;
4043 }
4044 else if (this._monitorTickCount <= 3) { // Twice
4045 return 3000;
4046 }
4047 else if (this._monitorTickCount <= 5) { // Twice
4048 return 5000;
4049 }
4050 else if (this._monitorTickCount <= 7) { // Twice
4051 return 10000;
4052 }
4053 return retVal;
4054 };
4055 // Events ---
4056 Workunit.prototype.on = function (eventID, propIDorCallback, callback) {
4057 var _this = this;
4058 if (this.isCallback(propIDorCallback)) {
4059 switch (eventID) {
4060 case "completed":
4061 _super.prototype.on.call(this, "propChanged", "StateID", function (changeInfo) {
4062 if (_this.isComplete()) {
4063 propIDorCallback([changeInfo]);
4064 }
4065 });
4066 break;
4067 case "changed":
4068 _super.prototype.on.call(this, eventID, propIDorCallback);
4069 break;
4070 }
4071 }
4072 else {
4073 switch (eventID) {
4074 case "changed":
4075 _super.prototype.on.call(this, eventID, propIDorCallback, callback);
4076 break;
4077 }
4078 }
4079 this._monitor();
4080 return this;
4081 };
4082 Workunit.prototype.watchUntilComplete = function (callback) {
4083 var _this = this;
4084 return new Promise(function (resolve, _) {
4085 var watchHandle = _this.watch(function (changes) {
4086 if (callback) {
4087 callback(changes);
4088 }
4089 if (_this.isComplete()) {
4090 watchHandle.release();
4091 resolve(_this);
4092 }
4093 });
4094 });
4095 };
4096 Workunit.prototype.watchUntilRunning = function (callback) {
4097 var _this = this;
4098 return new Promise(function (resolve, _) {
4099 var watchHandle = _this.watch(function (changes) {
4100 if (callback) {
4101 callback(changes);
4102 }
4103 if (_this.isComplete() || _this.isRunning()) {
4104 watchHandle.release();
4105 resolve(_this);
4106 }
4107 });
4108 });
4109 };
4110 // WsWorkunits passthroughs ---
4111 Workunit.prototype.WUQuery = function (_request) {
4112 var _this = this;
4113 if (_request === void 0) { _request = {}; }
4114 return this.connection.WUQuery(__assign(__assign({}, _request), { Wuid: this.Wuid })).then(function (response) {
4115 _this.set(response.Workunits.ECLWorkunit[0]);
4116 return response;
4117 }).catch(function (e) {
4118 // deleted ---
4119 var wuMissing = e.Exception.some(function (exception) {
4120 if (exception.Code === 20081) {
4121 _this.clearState(_this.Wuid);
4122 _this.set("StateID", WUStateID.NotFound);
4123 return true;
4124 }
4125 return false;
4126 });
4127 if (!wuMissing) {
4128 logger$1.warning("Unexpected exception: ");
4129 throw e;
4130 }
4131 return {};
4132 });
4133 };
4134 Workunit.prototype.WUCreate = function () {
4135 var _this = this;
4136 return this.connection.WUCreate().then(function (response) {
4137 _this.set(response.Workunit);
4138 _workunits.set(_this);
4139 return response;
4140 });
4141 };
4142 Workunit.prototype.WUInfo = function (_request) {
4143 var _this = this;
4144 if (_request === void 0) { _request = {}; }
4145 var includeResults = _request.IncludeResults || _request.IncludeResultsViewNames;
4146 return this.connection.WUInfo(__assign(__assign({}, _request), { Wuid: this.Wuid, IncludeResults: includeResults, IncludeResultsViewNames: includeResults, SuppressResultSchemas: false })).then(function (response) {
4147 _this.set(response.Workunit);
4148 if (includeResults) {
4149 _this.set({
4150 ResultViews: response.ResultViews
4151 });
4152 }
4153 return response;
4154 }).catch(function (e) {
4155 // deleted ---
4156 var wuMissing = e.Exception.some(function (exception) {
4157 if (exception.Code === 20080) {
4158 _this.clearState(_this.Wuid);
4159 _this.set("StateID", WUStateID.NotFound);
4160 return true;
4161 }
4162 return false;
4163 });
4164 if (!wuMissing) {
4165 logger$1.warning("Unexpected exception: ");
4166 throw e;
4167 }
4168 return {};
4169 });
4170 };
4171 Workunit.prototype.WUResubmit = function (request) {
4172 return this.connection.WUResubmit(util.deepMixinT({}, request, {
4173 Wuids: [this.Wuid]
4174 }));
4175 };
4176 Workunit.prototype.WUDetailsMeta = function (request) {
4177 return this.connection.WUDetailsMeta(request);
4178 };
4179 Workunit.prototype.WUDetails = function (request) {
4180 return this.connection.WUDetails(util.deepMixinT({
4181 ScopeFilter: {
4182 MaxDepth: 9999
4183 },
4184 ScopeOptions: {
4185 IncludeMatchedScopesInResults: true,
4186 IncludeScope: true,
4187 IncludeId: false,
4188 IncludeScopeType: false
4189 },
4190 PropertyOptions: {
4191 IncludeName: true,
4192 IncludeRawValue: false,
4193 IncludeFormatted: true,
4194 IncludeMeasure: true,
4195 IncludeCreator: false,
4196 IncludeCreatorType: false
4197 }
4198 }, request, { WUID: this.Wuid })).then(function (response) {
4199 return util.deepMixinT({
4200 Scopes: {
4201 Scope: []
4202 }
4203 }, response);
4204 });
4205 };
4206 Workunit.prototype.WUAction = function (actionType) {
4207 var _this = this;
4208 return this.connection.WUAction({
4209 Wuids: [this.Wuid],
4210 WUActionType: actionType
4211 }).then(function (response) {
4212 return _this.refresh().then(function () {
4213 _this._monitor();
4214 return response;
4215 });
4216 });
4217 };
4218 Workunit.prototype.publish = function (name) {
4219 return this.connection.WUPublishWorkunit({
4220 Wuid: this.Wuid,
4221 Cluster: this.Cluster,
4222 JobName: name || this.Jobname,
4223 AllowForeignFiles: true,
4224 Activate: true,
4225 Wait: 5000
4226 });
4227 };
4228 Workunit.prototype.WUCDebug = function (command, opts) {
4229 if (opts === void 0) { opts = {}; }
4230 var optsStr = "";
4231 for (var key in opts) {
4232 if (opts.hasOwnProperty(key)) {
4233 optsStr += " " + key + "='" + opts[key] + "'";
4234 }
4235 }
4236 return this.connection.WUCDebug({
4237 Wuid: this.Wuid,
4238 Command: "<debug:" + command + " uid='" + this.Wuid + "'" + optsStr + "/>"
4239 }).then(function (response) {
4240 return response;
4241 });
4242 };
4243 Workunit.prototype.debug = function (command, opts) {
4244 if (!this.isDebugging()) {
4245 return Promise.resolve(new util.XMLNode(command));
4246 }
4247 return this.WUCDebug(command, opts).then(function (response) {
4248 var retVal = response.children(command);
4249 if (retVal.length) {
4250 return retVal[0];
4251 }
4252 return new util.XMLNode(command);
4253 }).catch(function (_) {
4254 logger$1.error(_);
4255 return Promise.resolve(new util.XMLNode(command));
4256 });
4257 };
4258 Workunit.prototype.debugStatus = function () {
4259 var _this = this;
4260 if (!this.isDebugging()) {
4261 return Promise.resolve({
4262 DebugState: { state: "unknown" }
4263 });
4264 }
4265 return this.debug("status").then(function (response) {
4266 var debugState = __assign(__assign({}, _this.DebugState), response.$);
4267 _this.set({
4268 DebugState: debugState
4269 });
4270 return response;
4271 });
4272 };
4273 Workunit.prototype.debugContinue = function (mode) {
4274 if (mode === void 0) { mode = ""; }
4275 return this.debug("continue", {
4276 mode: mode
4277 });
4278 };
4279 Workunit.prototype.debugStep = function (mode) {
4280 return this.debug("step", {
4281 mode: mode
4282 });
4283 };
4284 Workunit.prototype.debugPause = function () {
4285 return this.debug("interrupt");
4286 };
4287 Workunit.prototype.debugQuit = function () {
4288 return this.debug("quit");
4289 };
4290 Workunit.prototype.debugDeleteAllBreakpoints = function () {
4291 return this.debug("delete", {
4292 idx: 0
4293 });
4294 };
4295 Workunit.prototype.debugBreakpointResponseParser = function (rootNode) {
4296 return rootNode.children().map(function (childNode) {
4297 if (childNode.name === "break") {
4298 return childNode.$;
4299 }
4300 });
4301 };
4302 Workunit.prototype.debugBreakpointAdd = function (id, mode, action) {
4303 var _this = this;
4304 return this.debug("breakpoint", {
4305 id: id,
4306 mode: mode,
4307 action: action
4308 }).then(function (rootNode) {
4309 return _this.debugBreakpointResponseParser(rootNode);
4310 });
4311 };
4312 Workunit.prototype.debugBreakpointList = function () {
4313 var _this = this;
4314 return this.debug("list").then(function (rootNode) {
4315 return _this.debugBreakpointResponseParser(rootNode);
4316 });
4317 };
4318 Workunit.prototype.debugGraph = function () {
4319 var _this = this;
4320 if (this._debugAllGraph && this.DebugState["_prevGraphSequenceNum"] === this.DebugState["graphSequenceNum"]) {
4321 return Promise.resolve(this._debugAllGraph);
4322 }
4323 return this.debug("graph", { name: "all" }).then(function (response) {
4324 _this.DebugState["_prevGraphSequenceNum"] = _this.DebugState["graphSequenceNum"];
4325 _this._debugAllGraph = createXGMMLGraph(_this.Wuid, response);
4326 return _this._debugAllGraph;
4327 });
4328 };
4329 Workunit.prototype.debugBreakpointValid = function (path) {
4330 return this.debugGraph().then(function (graph) {
4331 return breakpointLocations(graph, path);
4332 });
4333 };
4334 Workunit.prototype.debugPrint = function (edgeID, startRow, numRows) {
4335 if (startRow === void 0) { startRow = 0; }
4336 if (numRows === void 0) { numRows = 10; }
4337 return this.debug("print", {
4338 edgeID: edgeID,
4339 startRow: startRow,
4340 numRows: numRows
4341 }).then(function (response) {
4342 return response.children().map(function (rowNode) {
4343 var retVal = {};
4344 rowNode.children().forEach(function (cellNode) {
4345 retVal[cellNode.name] = cellNode.content;
4346 });
4347 return retVal;
4348 });
4349 });
4350 };
4351 return Workunit;
4352}(util.StateObject));
4353var ATTR_DEFINITION = "definition";
4354function hasECLDefinition(vertex) {
4355 return vertex._[ATTR_DEFINITION] !== undefined;
4356}
4357function getECLDefinition(vertex) {
4358 var match = /([a-z]:\\(?:[-\w\.\d]+\\)*(?:[-\w\.\d]+)?|(?:\/[\w\.\-]+)+)\((\d*),(\d*)\)/.exec(vertex._[ATTR_DEFINITION]);
4359 if (match) {
4360 var _file = match[1], _row = match[2], _col = match[3];
4361 _file.replace("/./", "/");
4362 return {
4363 id: vertex._["id"],
4364 file: _file,
4365 line: +_row,
4366 column: +_col
4367 };
4368 }
4369 throw new Error("Bad definition: " + vertex._[ATTR_DEFINITION]);
4370}
4371function breakpointLocations(graph, path) {
4372 var retVal = [];
4373 for (var _i = 0, _a = graph.vertices; _i < _a.length; _i++) {
4374 var vertex = _a[_i];
4375 if (hasECLDefinition(vertex)) {
4376 var definition = getECLDefinition(vertex);
4377 if (definition && !path || path === definition.file) {
4378 retVal.push(definition);
4379 }
4380 }
4381 }
4382 return retVal.sort(function (l, r) {
4383 return l.line - r.line;
4384 });
4385}
4386
4387var _activity;
4388var Activity = /** @class */ (function (_super) {
4389 __extends(Activity, _super);
4390 function Activity(optsConnection) {
4391 var _this = _super.call(this) || this;
4392 _this.lazyRefresh = util.debounce(function () { return __awaiter(_this, void 0, void 0, function () {
4393 var response;
4394 return __generator(this, function (_a) {
4395 switch (_a.label) {
4396 case 0: return [4 /*yield*/, this.connection.Activity({})];
4397 case 1:
4398 response = _a.sent();
4399 this.set(response);
4400 return [2 /*return*/, this];
4401 }
4402 });
4403 }); });
4404 if (optsConnection instanceof SMCService) {
4405 _this.connection = optsConnection;
4406 }
4407 else {
4408 _this.connection = new SMCService(optsConnection);
4409 }
4410 _this.clear({});
4411 return _this;
4412 }
4413 Object.defineProperty(Activity.prototype, "properties", {
4414 get: function () { return this.get(); },
4415 enumerable: false,
4416 configurable: true
4417 });
4418 Object.defineProperty(Activity.prototype, "Exceptions", {
4419 get: function () { return this.get("Exceptions"); },
4420 enumerable: false,
4421 configurable: true
4422 });
4423 Object.defineProperty(Activity.prototype, "Build", {
4424 get: function () { return this.get("Build"); },
4425 enumerable: false,
4426 configurable: true
4427 });
4428 Object.defineProperty(Activity.prototype, "ThorClusterList", {
4429 get: function () { return this.get("ThorClusterList"); },
4430 enumerable: false,
4431 configurable: true
4432 });
4433 Object.defineProperty(Activity.prototype, "RoxieClusterList", {
4434 get: function () { return this.get("RoxieClusterList"); },
4435 enumerable: false,
4436 configurable: true
4437 });
4438 Object.defineProperty(Activity.prototype, "HThorClusterList", {
4439 get: function () { return this.get("HThorClusterList"); },
4440 enumerable: false,
4441 configurable: true
4442 });
4443 Object.defineProperty(Activity.prototype, "DFUJobs", {
4444 get: function () { return this.get("DFUJobs"); },
4445 enumerable: false,
4446 configurable: true
4447 });
4448 Object.defineProperty(Activity.prototype, "Running", {
4449 get: function () { return this.get("Running", { ActiveWorkunit: [] }); },
4450 enumerable: false,
4451 configurable: true
4452 });
4453 Object.defineProperty(Activity.prototype, "BannerContent", {
4454 get: function () { return this.get("BannerContent"); },
4455 enumerable: false,
4456 configurable: true
4457 });
4458 Object.defineProperty(Activity.prototype, "BannerColor", {
4459 get: function () { return this.get("BannerColor"); },
4460 enumerable: false,
4461 configurable: true
4462 });
4463 Object.defineProperty(Activity.prototype, "BannerSize", {
4464 get: function () { return this.get("BannerSize"); },
4465 enumerable: false,
4466 configurable: true
4467 });
4468 Object.defineProperty(Activity.prototype, "BannerScroll", {
4469 get: function () { return this.get("BannerScroll"); },
4470 enumerable: false,
4471 configurable: true
4472 });
4473 Object.defineProperty(Activity.prototype, "ChatURL", {
4474 get: function () { return this.get("ChatURL"); },
4475 enumerable: false,
4476 configurable: true
4477 });
4478 Object.defineProperty(Activity.prototype, "ShowBanner", {
4479 get: function () { return this.get("ShowBanner"); },
4480 enumerable: false,
4481 configurable: true
4482 });
4483 Object.defineProperty(Activity.prototype, "ShowChatURL", {
4484 get: function () { return this.get("ShowChatURL"); },
4485 enumerable: false,
4486 configurable: true
4487 });
4488 Object.defineProperty(Activity.prototype, "SortBy", {
4489 get: function () { return this.get("SortBy"); },
4490 enumerable: false,
4491 configurable: true
4492 });
4493 Object.defineProperty(Activity.prototype, "Descending", {
4494 get: function () { return this.get("Descending"); },
4495 enumerable: false,
4496 configurable: true
4497 });
4498 Object.defineProperty(Activity.prototype, "SuperUser", {
4499 get: function () { return this.get("SuperUser"); },
4500 enumerable: false,
4501 configurable: true
4502 });
4503 Object.defineProperty(Activity.prototype, "AccessRight", {
4504 get: function () { return this.get("AccessRight"); },
4505 enumerable: false,
4506 configurable: true
4507 });
4508 Object.defineProperty(Activity.prototype, "ServerJobQueues", {
4509 get: function () { return this.get("ServerJobQueues"); },
4510 enumerable: false,
4511 configurable: true
4512 });
4513 Activity.attach = function (optsConnection, state) {
4514 if (!_activity) {
4515 _activity = new Activity(optsConnection);
4516 }
4517 if (state) {
4518 _activity.set(__assign({}, state));
4519 }
4520 return _activity;
4521 };
4522 Activity.prototype.runningWorkunits = function (clusterName) {
4523 var _this = this;
4524 if (clusterName === void 0) { clusterName = ""; }
4525 return this.Running.ActiveWorkunit.filter(function (awu) { return clusterName === "" || awu.ClusterName === clusterName; }).map(function (awu) { return Workunit.attach(_this.connection.connectionOptions(), awu.Wuid, awu); });
4526 };
4527 Activity.prototype.refresh = function () {
4528 return __awaiter(this, void 0, void 0, function () {
4529 return __generator(this, function (_a) {
4530 return [2 /*return*/, this.lazyRefresh()];
4531 });
4532 });
4533 };
4534 return Activity;
4535}(util.StateObject));
4536
4537var LogicalFileCache = /** @class */ (function (_super) {
4538 __extends(LogicalFileCache, _super);
4539 function LogicalFileCache() {
4540 return _super.call(this, function (obj) {
4541 return obj.BaseUrl + "-" + obj.Cluster + "-" + obj.Name;
4542 }) || this;
4543 }
4544 return LogicalFileCache;
4545}(util.Cache));
4546var _store = new LogicalFileCache();
4547var LogicalFile = /** @class */ (function (_super) {
4548 __extends(LogicalFile, _super);
4549 function LogicalFile(optsConnection, Cluster, Name) {
4550 var _this = _super.call(this) || this;
4551 if (optsConnection instanceof DFUService) {
4552 _this.connection = optsConnection;
4553 }
4554 else {
4555 _this.connection = new DFUService(optsConnection);
4556 }
4557 _this.clear({
4558 Cluster: Cluster,
4559 Name: Name
4560 });
4561 return _this;
4562 }
4563 Object.defineProperty(LogicalFile.prototype, "BaseUrl", {
4564 get: function () { return this.connection.baseUrl; },
4565 enumerable: false,
4566 configurable: true
4567 });
4568 Object.defineProperty(LogicalFile.prototype, "Cluster", {
4569 get: function () { return this.get("Cluster"); },
4570 enumerable: false,
4571 configurable: true
4572 });
4573 Object.defineProperty(LogicalFile.prototype, "Name", {
4574 get: function () { return this.get("Name"); },
4575 enumerable: false,
4576 configurable: true
4577 });
4578 Object.defineProperty(LogicalFile.prototype, "Filename", {
4579 get: function () { return this.get("Filename"); },
4580 enumerable: false,
4581 configurable: true
4582 });
4583 Object.defineProperty(LogicalFile.prototype, "Prefix", {
4584 get: function () { return this.get("Prefix"); },
4585 enumerable: false,
4586 configurable: true
4587 });
4588 Object.defineProperty(LogicalFile.prototype, "NodeGroup", {
4589 get: function () { return this.get("NodeGroup"); },
4590 enumerable: false,
4591 configurable: true
4592 });
4593 Object.defineProperty(LogicalFile.prototype, "NumParts", {
4594 get: function () { return this.get("NumParts"); },
4595 enumerable: false,
4596 configurable: true
4597 });
4598 Object.defineProperty(LogicalFile.prototype, "Description", {
4599 get: function () { return this.get("Description"); },
4600 enumerable: false,
4601 configurable: true
4602 });
4603 Object.defineProperty(LogicalFile.prototype, "Dir", {
4604 get: function () { return this.get("Dir"); },
4605 enumerable: false,
4606 configurable: true
4607 });
4608 Object.defineProperty(LogicalFile.prototype, "PathMask", {
4609 get: function () { return this.get("PathMask"); },
4610 enumerable: false,
4611 configurable: true
4612 });
4613 Object.defineProperty(LogicalFile.prototype, "Filesize", {
4614 get: function () { return this.get("Filesize"); },
4615 enumerable: false,
4616 configurable: true
4617 });
4618 Object.defineProperty(LogicalFile.prototype, "FileSizeInt64", {
4619 get: function () { return this.get("FileSizeInt64"); },
4620 enumerable: false,
4621 configurable: true
4622 });
4623 Object.defineProperty(LogicalFile.prototype, "RecordSize", {
4624 get: function () { return this.get("RecordSize"); },
4625 enumerable: false,
4626 configurable: true
4627 });
4628 Object.defineProperty(LogicalFile.prototype, "RecordCount", {
4629 get: function () { return this.get("RecordCount"); },
4630 enumerable: false,
4631 configurable: true
4632 });
4633 Object.defineProperty(LogicalFile.prototype, "RecordSizeInt64", {
4634 get: function () { return this.get("RecordSizeInt64"); },
4635 enumerable: false,
4636 configurable: true
4637 });
4638 Object.defineProperty(LogicalFile.prototype, "RecordCountInt64", {
4639 get: function () { return this.get("RecordCountInt64"); },
4640 enumerable: false,
4641 configurable: true
4642 });
4643 Object.defineProperty(LogicalFile.prototype, "Wuid", {
4644 get: function () { return this.get("Wuid"); },
4645 enumerable: false,
4646 configurable: true
4647 });
4648 Object.defineProperty(LogicalFile.prototype, "Owner", {
4649 get: function () { return this.get("Owner"); },
4650 enumerable: false,
4651 configurable: true
4652 });
4653 Object.defineProperty(LogicalFile.prototype, "JobName", {
4654 get: function () { return this.get("JobName"); },
4655 enumerable: false,
4656 configurable: true
4657 });
4658 Object.defineProperty(LogicalFile.prototype, "Persistent", {
4659 get: function () { return this.get("Persistent"); },
4660 enumerable: false,
4661 configurable: true
4662 });
4663 Object.defineProperty(LogicalFile.prototype, "Format", {
4664 get: function () { return this.get("Format"); },
4665 enumerable: false,
4666 configurable: true
4667 });
4668 Object.defineProperty(LogicalFile.prototype, "MaxRecordSize", {
4669 get: function () { return this.get("MaxRecordSize"); },
4670 enumerable: false,
4671 configurable: true
4672 });
4673 Object.defineProperty(LogicalFile.prototype, "CsvSeparate", {
4674 get: function () { return this.get("CsvSeparate"); },
4675 enumerable: false,
4676 configurable: true
4677 });
4678 Object.defineProperty(LogicalFile.prototype, "CsvQuote", {
4679 get: function () { return this.get("CsvQuote"); },
4680 enumerable: false,
4681 configurable: true
4682 });
4683 Object.defineProperty(LogicalFile.prototype, "CsvTerminate", {
4684 get: function () { return this.get("CsvTerminate"); },
4685 enumerable: false,
4686 configurable: true
4687 });
4688 Object.defineProperty(LogicalFile.prototype, "CsvEscape", {
4689 get: function () { return this.get("CsvEscape"); },
4690 enumerable: false,
4691 configurable: true
4692 });
4693 Object.defineProperty(LogicalFile.prototype, "Modified", {
4694 get: function () { return this.get("Modified"); },
4695 enumerable: false,
4696 configurable: true
4697 });
4698 Object.defineProperty(LogicalFile.prototype, "Ecl", {
4699 get: function () { return this.get("Ecl"); },
4700 enumerable: false,
4701 configurable: true
4702 });
4703 Object.defineProperty(LogicalFile.prototype, "Stat", {
4704 get: function () { return this.get("Stat"); },
4705 enumerable: false,
4706 configurable: true
4707 });
4708 Object.defineProperty(LogicalFile.prototype, "DFUFilePartsOnClusters", {
4709 get: function () { return this.get("DFUFilePartsOnClusters"); },
4710 enumerable: false,
4711 configurable: true
4712 });
4713 Object.defineProperty(LogicalFile.prototype, "isSuperfile", {
4714 get: function () { return this.get("isSuperfile"); },
4715 enumerable: false,
4716 configurable: true
4717 });
4718 Object.defineProperty(LogicalFile.prototype, "ShowFileContent", {
4719 get: function () { return this.get("ShowFileContent"); },
4720 enumerable: false,
4721 configurable: true
4722 });
4723 Object.defineProperty(LogicalFile.prototype, "subfiles", {
4724 get: function () { return this.get("subfiles"); },
4725 enumerable: false,
4726 configurable: true
4727 });
4728 Object.defineProperty(LogicalFile.prototype, "Superfiles", {
4729 get: function () { return this.get("Superfiles"); },
4730 enumerable: false,
4731 configurable: true
4732 });
4733 Object.defineProperty(LogicalFile.prototype, "ProtectList", {
4734 get: function () { return this.get("ProtectList"); },
4735 enumerable: false,
4736 configurable: true
4737 });
4738 Object.defineProperty(LogicalFile.prototype, "FromRoxieCluster", {
4739 get: function () { return this.get("FromRoxieCluster"); },
4740 enumerable: false,
4741 configurable: true
4742 });
4743 Object.defineProperty(LogicalFile.prototype, "Graphs", {
4744 get: function () { return this.get("Graphs"); },
4745 enumerable: false,
4746 configurable: true
4747 });
4748 Object.defineProperty(LogicalFile.prototype, "UserPermission", {
4749 get: function () { return this.get("UserPermission"); },
4750 enumerable: false,
4751 configurable: true
4752 });
4753 Object.defineProperty(LogicalFile.prototype, "ContentType", {
4754 get: function () { return this.get("ContentType"); },
4755 enumerable: false,
4756 configurable: true
4757 });
4758 Object.defineProperty(LogicalFile.prototype, "CompressedFileSize", {
4759 get: function () { return this.get("CompressedFileSize"); },
4760 enumerable: false,
4761 configurable: true
4762 });
4763 Object.defineProperty(LogicalFile.prototype, "PercentCompressed", {
4764 get: function () { return this.get("PercentCompressed"); },
4765 enumerable: false,
4766 configurable: true
4767 });
4768 Object.defineProperty(LogicalFile.prototype, "IsCompressed", {
4769 get: function () { return this.get("IsCompressed"); },
4770 enumerable: false,
4771 configurable: true
4772 });
4773 Object.defineProperty(LogicalFile.prototype, "BrowseData", {
4774 get: function () { return this.get("BrowseData"); },
4775 enumerable: false,
4776 configurable: true
4777 });
4778 Object.defineProperty(LogicalFile.prototype, "jsonInfo", {
4779 get: function () { return this.get("jsonInfo"); },
4780 enumerable: false,
4781 configurable: true
4782 });
4783 Object.defineProperty(LogicalFile.prototype, "binInfo", {
4784 get: function () { return this.get("binInfo"); },
4785 enumerable: false,
4786 configurable: true
4787 });
4788 Object.defineProperty(LogicalFile.prototype, "PackageID", {
4789 get: function () { return this.get("PackageID"); },
4790 enumerable: false,
4791 configurable: true
4792 });
4793 Object.defineProperty(LogicalFile.prototype, "Partition", {
4794 get: function () { return this.get("Partition"); },
4795 enumerable: false,
4796 configurable: true
4797 });
4798 Object.defineProperty(LogicalFile.prototype, "Blooms", {
4799 get: function () { return this.get("Blooms"); },
4800 enumerable: false,
4801 configurable: true
4802 });
4803 Object.defineProperty(LogicalFile.prototype, "ExpireDays", {
4804 get: function () { return this.get("ExpireDays"); },
4805 enumerable: false,
4806 configurable: true
4807 });
4808 Object.defineProperty(LogicalFile.prototype, "KeyType", {
4809 get: function () { return this.get("KeyType"); },
4810 enumerable: false,
4811 configurable: true
4812 });
4813 Object.defineProperty(LogicalFile.prototype, "properties", {
4814 get: function () { return this.get(); },
4815 enumerable: false,
4816 configurable: true
4817 });
4818 LogicalFile.attach = function (optsConnection, Cluster, Name) {
4819 var retVal = _store.get({ BaseUrl: optsConnection.baseUrl, Cluster: Cluster, Name: Name }, function () {
4820 return new LogicalFile(optsConnection, Cluster, Name);
4821 });
4822 return retVal;
4823 };
4824 LogicalFile.prototype.fetchInfo = function () {
4825 var _this = this;
4826 return this.connection.DFUInfo({ Cluster: this.Cluster, Name: this.Name }).then(function (response) {
4827 _this.set(__assign({ Cluster: _this.Cluster }, response.FileDetail));
4828 return response.FileDetail;
4829 });
4830 };
4831 return LogicalFile;
4832}(util.StateObject));
4833
4834var MachineCache = /** @class */ (function (_super) {
4835 __extends(MachineCache, _super);
4836 function MachineCache() {
4837 return _super.call(this, function (obj) {
4838 return obj.Address;
4839 }) || this;
4840 }
4841 return MachineCache;
4842}(util.Cache));
4843var _machines = new MachineCache();
4844var Machine = /** @class */ (function (_super) {
4845 __extends(Machine, _super);
4846 function Machine(optsConnection) {
4847 var _this = _super.call(this) || this;
4848 if (optsConnection instanceof MachineService) {
4849 _this.connection = optsConnection;
4850 }
4851 else {
4852 _this.connection = new MachineService(optsConnection);
4853 }
4854 return _this;
4855 }
4856 Object.defineProperty(Machine.prototype, "Address", {
4857 get: function () { return this.get("Address"); },
4858 enumerable: false,
4859 configurable: true
4860 });
4861 Object.defineProperty(Machine.prototype, "ConfigAddress", {
4862 get: function () { return this.get("ConfigAddress"); },
4863 enumerable: false,
4864 configurable: true
4865 });
4866 Object.defineProperty(Machine.prototype, "Name", {
4867 get: function () { return this.get("Name"); },
4868 enumerable: false,
4869 configurable: true
4870 });
4871 Object.defineProperty(Machine.prototype, "ProcessType", {
4872 get: function () { return this.get("ProcessType"); },
4873 enumerable: false,
4874 configurable: true
4875 });
4876 Object.defineProperty(Machine.prototype, "DisplayType", {
4877 get: function () { return this.get("DisplayType"); },
4878 enumerable: false,
4879 configurable: true
4880 });
4881 Object.defineProperty(Machine.prototype, "Description", {
4882 get: function () { return this.get("Description"); },
4883 enumerable: false,
4884 configurable: true
4885 });
4886 Object.defineProperty(Machine.prototype, "AgentVersion", {
4887 get: function () { return this.get("AgentVersion"); },
4888 enumerable: false,
4889 configurable: true
4890 });
4891 Object.defineProperty(Machine.prototype, "Contact", {
4892 get: function () { return this.get("Contact"); },
4893 enumerable: false,
4894 configurable: true
4895 });
4896 Object.defineProperty(Machine.prototype, "Location", {
4897 get: function () { return this.get("Location"); },
4898 enumerable: false,
4899 configurable: true
4900 });
4901 Object.defineProperty(Machine.prototype, "UpTime", {
4902 get: function () { return this.get("UpTime"); },
4903 enumerable: false,
4904 configurable: true
4905 });
4906 Object.defineProperty(Machine.prototype, "ComponentName", {
4907 get: function () { return this.get("ComponentName"); },
4908 enumerable: false,
4909 configurable: true
4910 });
4911 Object.defineProperty(Machine.prototype, "ComponentPath", {
4912 get: function () { return this.get("ComponentPath"); },
4913 enumerable: false,
4914 configurable: true
4915 });
4916 Object.defineProperty(Machine.prototype, "RoxieState", {
4917 get: function () { return this.get("RoxieState"); },
4918 enumerable: false,
4919 configurable: true
4920 });
4921 Object.defineProperty(Machine.prototype, "RoxieStateDetails", {
4922 get: function () { return this.get("RoxieStateDetails"); },
4923 enumerable: false,
4924 configurable: true
4925 });
4926 Object.defineProperty(Machine.prototype, "OS", {
4927 get: function () { return this.get("OS"); },
4928 enumerable: false,
4929 configurable: true
4930 });
4931 Object.defineProperty(Machine.prototype, "ProcessNumber", {
4932 get: function () { return this.get("ProcessNumber"); },
4933 enumerable: false,
4934 configurable: true
4935 });
4936 Object.defineProperty(Machine.prototype, "Processors", {
4937 get: function () { return this.get("Processors"); },
4938 enumerable: false,
4939 configurable: true
4940 });
4941 Object.defineProperty(Machine.prototype, "Storage", {
4942 get: function () { return this.get("Storage"); },
4943 enumerable: false,
4944 configurable: true
4945 });
4946 Object.defineProperty(Machine.prototype, "Running", {
4947 get: function () { return this.get("Running"); },
4948 enumerable: false,
4949 configurable: true
4950 });
4951 Object.defineProperty(Machine.prototype, "PhysicalMemory", {
4952 get: function () { return this.get("PhysicalMemory"); },
4953 enumerable: false,
4954 configurable: true
4955 });
4956 Object.defineProperty(Machine.prototype, "VirtualMemory", {
4957 get: function () { return this.get("VirtualMemory"); },
4958 enumerable: false,
4959 configurable: true
4960 });
4961 Object.defineProperty(Machine.prototype, "ComponentInfo", {
4962 get: function () { return this.get("ComponentInfo"); },
4963 enumerable: false,
4964 configurable: true
4965 });
4966 Machine.attach = function (optsConnection, address, state) {
4967 var retVal = _machines.get({ Address: address }, function () {
4968 return new Machine(optsConnection);
4969 });
4970 if (state) {
4971 retVal.set(state);
4972 }
4973 return retVal;
4974 };
4975 return Machine;
4976}(util.StateObject));
4977
4978var QueryCache = /** @class */ (function (_super) {
4979 __extends(QueryCache, _super);
4980 function QueryCache() {
4981 return _super.call(this, function (obj) {
4982 return util.Cache.hash([obj.QueryId, obj.QuerySet]);
4983 }) || this;
4984 }
4985 return QueryCache;
4986}(util.Cache));
4987var _queries = new QueryCache();
4988var Query = /** @class */ (function (_super) {
4989 __extends(Query, _super);
4990 function Query(optsConnection, querySet, queryID, queryDetails) {
4991 var _this = _super.call(this) || this;
4992 if (optsConnection instanceof EclService) {
4993 _this.connection = optsConnection;
4994 // this._topology = new Topology(this.connection.opts());
4995 }
4996 else {
4997 _this.connection = new EclService(optsConnection);
4998 // this._topology = new Topology(optsConnection);
4999 }
5000 _this.set(__assign({ QuerySet: querySet, QueryId: queryID }, queryDetails));
5001 return _this;
5002 }
5003 Object.defineProperty(Query.prototype, "BaseUrl", {
5004 get: function () { return this.connection.baseUrl; },
5005 enumerable: false,
5006 configurable: true
5007 });
5008 Object.defineProperty(Query.prototype, "properties", {
5009 get: function () { return this.get(); },
5010 enumerable: false,
5011 configurable: true
5012 });
5013 Object.defineProperty(Query.prototype, "Exceptions", {
5014 get: function () { return this.get("Exceptions"); },
5015 enumerable: false,
5016 configurable: true
5017 });
5018 Object.defineProperty(Query.prototype, "QueryId", {
5019 get: function () { return this.get("QueryId"); },
5020 enumerable: false,
5021 configurable: true
5022 });
5023 Object.defineProperty(Query.prototype, "QuerySet", {
5024 get: function () { return this.get("QuerySet"); },
5025 enumerable: false,
5026 configurable: true
5027 });
5028 Object.defineProperty(Query.prototype, "QueryName", {
5029 get: function () { return this.get("QueryName"); },
5030 enumerable: false,
5031 configurable: true
5032 });
5033 Object.defineProperty(Query.prototype, "Wuid", {
5034 get: function () { return this.get("Wuid"); },
5035 enumerable: false,
5036 configurable: true
5037 });
5038 Object.defineProperty(Query.prototype, "Dll", {
5039 get: function () { return this.get("Dll"); },
5040 enumerable: false,
5041 configurable: true
5042 });
5043 Object.defineProperty(Query.prototype, "Suspended", {
5044 get: function () { return this.get("Suspended"); },
5045 enumerable: false,
5046 configurable: true
5047 });
5048 Object.defineProperty(Query.prototype, "Activated", {
5049 get: function () { return this.get("Activated"); },
5050 enumerable: false,
5051 configurable: true
5052 });
5053 Object.defineProperty(Query.prototype, "SuspendedBy", {
5054 get: function () { return this.get("SuspendedBy"); },
5055 enumerable: false,
5056 configurable: true
5057 });
5058 Object.defineProperty(Query.prototype, "Clusters", {
5059 get: function () { return this.get("Clusters"); },
5060 enumerable: false,
5061 configurable: true
5062 });
5063 Object.defineProperty(Query.prototype, "PublishedBy", {
5064 get: function () { return this.get("PublishedBy"); },
5065 enumerable: false,
5066 configurable: true
5067 });
5068 Object.defineProperty(Query.prototype, "Comment", {
5069 get: function () { return this.get("Comment"); },
5070 enumerable: false,
5071 configurable: true
5072 });
5073 Object.defineProperty(Query.prototype, "LogicalFiles", {
5074 get: function () { return this.get("LogicalFiles"); },
5075 enumerable: false,
5076 configurable: true
5077 });
5078 Object.defineProperty(Query.prototype, "SuperFiles", {
5079 get: function () { return this.get("SuperFiles"); },
5080 enumerable: false,
5081 configurable: true
5082 });
5083 Object.defineProperty(Query.prototype, "IsLibrary", {
5084 get: function () { return this.get("IsLibrary"); },
5085 enumerable: false,
5086 configurable: true
5087 });
5088 Object.defineProperty(Query.prototype, "Priority", {
5089 get: function () { return this.get("Priority"); },
5090 enumerable: false,
5091 configurable: true
5092 });
5093 Object.defineProperty(Query.prototype, "WUSnapShot", {
5094 get: function () { return this.get("WUSnapShot"); },
5095 enumerable: false,
5096 configurable: true
5097 });
5098 Object.defineProperty(Query.prototype, "CompileTime", {
5099 get: function () { return this.get("CompileTime"); },
5100 enumerable: false,
5101 configurable: true
5102 });
5103 Object.defineProperty(Query.prototype, "LibrariesUsed", {
5104 get: function () { return this.get("LibrariesUsed"); },
5105 enumerable: false,
5106 configurable: true
5107 });
5108 Object.defineProperty(Query.prototype, "CountGraphs", {
5109 get: function () { return this.get("CountGraphs"); },
5110 enumerable: false,
5111 configurable: true
5112 });
5113 Object.defineProperty(Query.prototype, "ResourceURLCount", {
5114 get: function () { return this.get("ResourceURLCount"); },
5115 enumerable: false,
5116 configurable: true
5117 });
5118 Object.defineProperty(Query.prototype, "WsEclAddresses", {
5119 get: function () { return this.get("WsEclAddresses"); },
5120 enumerable: false,
5121 configurable: true
5122 });
5123 Object.defineProperty(Query.prototype, "WUGraphs", {
5124 get: function () { return this.get("WUGraphs"); },
5125 enumerable: false,
5126 configurable: true
5127 });
5128 Object.defineProperty(Query.prototype, "WUTimers", {
5129 get: function () { return this.get("WUTimers"); },
5130 enumerable: false,
5131 configurable: true
5132 });
5133 Query.attach = function (optsConnection, querySet, queryId) {
5134 var retVal = _queries.get({ BaseUrl: optsConnection.baseUrl, QuerySet: querySet, QueryId: queryId }, function () {
5135 return new Query(optsConnection, querySet, queryId);
5136 });
5137 return retVal;
5138 };
5139 Query.prototype.fetchRequestSchema = function () {
5140 return __awaiter(this, void 0, void 0, function () {
5141 var _a;
5142 return __generator(this, function (_b) {
5143 switch (_b.label) {
5144 case 0:
5145 _a = this;
5146 return [4 /*yield*/, this.connection.requestJson(this.QuerySet, this.QueryId)];
5147 case 1:
5148 _a._requestSchema = _b.sent();
5149 return [2 /*return*/];
5150 }
5151 });
5152 });
5153 };
5154 Query.prototype.fetchResponseSchema = function () {
5155 return __awaiter(this, void 0, void 0, function () {
5156 var _a;
5157 return __generator(this, function (_b) {
5158 switch (_b.label) {
5159 case 0:
5160 _a = this;
5161 return [4 /*yield*/, this.connection.responseJson(this.QuerySet, this.QueryId)];
5162 case 1:
5163 _a._responseSchema = _b.sent();
5164 return [2 /*return*/];
5165 }
5166 });
5167 });
5168 };
5169 Query.prototype.fetchSchema = function () {
5170 return __awaiter(this, void 0, void 0, function () {
5171 return __generator(this, function (_a) {
5172 switch (_a.label) {
5173 case 0: return [4 /*yield*/, Promise.all([this.fetchRequestSchema(), this.fetchResponseSchema()])];
5174 case 1:
5175 _a.sent();
5176 return [2 /*return*/];
5177 }
5178 });
5179 });
5180 };
5181 Query.prototype.submit = function (request) {
5182 return this.connection.submit(this.QuerySet, this.QueryId, request).then(function (results) {
5183 for (var key in results) {
5184 results[key] = results[key].Row;
5185 }
5186 return results;
5187 });
5188 };
5189 Query.prototype.refresh = function () {
5190 return __awaiter(this, void 0, void 0, function () {
5191 var _this = this;
5192 return __generator(this, function (_a) {
5193 return [2 /*return*/, this.fetchSchema().then(function (schema) { return _this; })];
5194 });
5195 });
5196 };
5197 Query.prototype.requestFields = function () {
5198 if (!this._requestSchema)
5199 return [];
5200 return this._requestSchema;
5201 };
5202 Query.prototype.responseFields = function () {
5203 if (!this._responseSchema)
5204 return {};
5205 return this._responseSchema;
5206 };
5207 Query.prototype.resultNames = function () {
5208 var retVal = [];
5209 for (var key in this.responseFields()) {
5210 retVal.push(key);
5211 }
5212 return retVal;
5213 };
5214 Query.prototype.resultFields = function (resultName) {
5215 if (!this._responseSchema[resultName])
5216 return [];
5217 return this._responseSchema[resultName];
5218 };
5219 return Query;
5220}(util.StateObject));
5221
5222var StoreCache = /** @class */ (function (_super) {
5223 __extends(StoreCache, _super);
5224 function StoreCache() {
5225 return _super.call(this, function (obj) {
5226 return obj.BaseUrl + "-" + obj.Name + ":" + obj.UserSpecific + "-" + obj.Namespace;
5227 }) || this;
5228 }
5229 return StoreCache;
5230}(util.Cache));
5231var _store$1 = new StoreCache();
5232var ValueChangedMessage = /** @class */ (function (_super) {
5233 __extends(ValueChangedMessage, _super);
5234 function ValueChangedMessage(key, value, oldValue) {
5235 var _this = _super.call(this) || this;
5236 _this.key = key;
5237 _this.value = value;
5238 _this.oldValue = oldValue;
5239 return _this;
5240 }
5241 Object.defineProperty(ValueChangedMessage.prototype, "canConflate", {
5242 get: function () { return true; },
5243 enumerable: false,
5244 configurable: true
5245 });
5246 ValueChangedMessage.prototype.conflate = function (other) {
5247 if (this.key === other.key) {
5248 this.value = other.value;
5249 return true;
5250 }
5251 return false;
5252 };
5253 ValueChangedMessage.prototype.void = function () {
5254 return this.value === this.oldValue;
5255 };
5256 return ValueChangedMessage;
5257}(util.Message));
5258var Store = /** @class */ (function () {
5259 function Store(optsConnection, Name, Namespace, UserSpecific) {
5260 this._dispatch = new util.Dispatch();
5261 this._knownValues = {};
5262 if (optsConnection instanceof StoreService) {
5263 this.connection = optsConnection;
5264 }
5265 else {
5266 this.connection = new StoreService(optsConnection);
5267 }
5268 this.Name = Name;
5269 this.UserSpecific = UserSpecific;
5270 this.Namespace = Namespace;
5271 }
5272 Object.defineProperty(Store.prototype, "BaseUrl", {
5273 get: function () { return this.connection.baseUrl; },
5274 enumerable: false,
5275 configurable: true
5276 });
5277 Store.attach = function (optsConnection, Name, Namespace, UserSpecific) {
5278 if (Name === void 0) { Name = "HPCCApps"; }
5279 if (UserSpecific === void 0) { UserSpecific = true; }
5280 var retVal = _store$1.get({ BaseUrl: optsConnection.baseUrl, Name: Name, UserSpecific: UserSpecific, Namespace: Namespace }, function () {
5281 return new Store(optsConnection, Name, Namespace, UserSpecific);
5282 });
5283 return retVal;
5284 };
5285 Store.prototype.create = function () {
5286 this.connection.CreateStore({ Name: this.Name, UserSpecific: this.UserSpecific, Type: "", Description: "" });
5287 };
5288 Store.prototype.set = function (key, value, broadcast) {
5289 var _this = this;
5290 if (broadcast === void 0) { broadcast = true; }
5291 return this.connection.Set({
5292 StoreName: this.Name,
5293 UserSpecific: this.UserSpecific,
5294 Namespace: this.Namespace,
5295 Key: key,
5296 Value: value
5297 }).then(function (response) {
5298 var oldValue = _this._knownValues[key];
5299 _this._knownValues[key] = value;
5300 if (broadcast) {
5301 _this._dispatch.post(new ValueChangedMessage(key, value, oldValue));
5302 }
5303 }).catch(function (e) {
5304 console.error("Store.set(\"" + key + "\", \"" + value + "\") failed:", e);
5305 });
5306 };
5307 Store.prototype.get = function (key, broadcast) {
5308 var _this = this;
5309 if (broadcast === void 0) { broadcast = true; }
5310 return this.connection.Fetch({
5311 StoreName: this.Name,
5312 UserSpecific: this.UserSpecific,
5313 Namespace: this.Namespace,
5314 Key: key
5315 }).then(function (response) {
5316 var oldValue = _this._knownValues[key];
5317 _this._knownValues[key] = response.Value;
5318 if (broadcast) {
5319 _this._dispatch.post(new ValueChangedMessage(key, response.Value, oldValue));
5320 }
5321 return response.Value;
5322 }).catch(function (e) {
5323 console.error("Store.get(" + key + ") failed:", e);
5324 return undefined;
5325 });
5326 };
5327 Store.prototype.getAll = function (broadcast) {
5328 var _this = this;
5329 if (broadcast === void 0) { broadcast = true; }
5330 return this.connection.FetchAll({
5331 StoreName: this.Name,
5332 UserSpecific: this.UserSpecific,
5333 Namespace: this.Namespace
5334 }).then(function (response) {
5335 var retVal = {};
5336 var deletedValues = _this._knownValues;
5337 _this._knownValues = {};
5338 response.Pairs.Pair.forEach(function (pair) {
5339 var oldValue = _this._knownValues[pair.Key];
5340 _this._knownValues[pair.Key] = pair.Value;
5341 delete deletedValues[pair.Key];
5342 retVal[pair.Key] = pair.Value;
5343 if (broadcast) {
5344 _this._dispatch.post(new ValueChangedMessage(pair.Key, pair.Value, oldValue));
5345 }
5346 });
5347 if (broadcast) {
5348 for (var key in deletedValues) {
5349 _this._dispatch.post(new ValueChangedMessage(key, undefined, deletedValues[key]));
5350 }
5351 }
5352 return retVal;
5353 }).catch(function (e) {
5354 console.error("Store.getAll failed:", e);
5355 return {};
5356 });
5357 };
5358 Store.prototype.delete = function (key, broadcast) {
5359 var _this = this;
5360 if (broadcast === void 0) { broadcast = true; }
5361 return this.connection.Delete({
5362 StoreName: this.Name,
5363 UserSpecific: this.UserSpecific,
5364 Namespace: this.Namespace,
5365 Key: key
5366 }).then(function (response) {
5367 var oldValue = _this._knownValues[key];
5368 delete _this._knownValues[key];
5369 if (broadcast) {
5370 _this._dispatch.post(new ValueChangedMessage(key, undefined, oldValue));
5371 }
5372 }).catch(function (e) {
5373 console.error("Store.delete(" + key + ") failed:", e);
5374 });
5375 };
5376 Store.prototype.monitor = function (callback) {
5377 return this._dispatch.attach(callback);
5378 };
5379 return Store;
5380}());
5381
5382var TargetClusterCache = /** @class */ (function (_super) {
5383 __extends(TargetClusterCache, _super);
5384 function TargetClusterCache() {
5385 return _super.call(this, function (obj) {
5386 return obj.BaseUrl + "-" + obj.Name;
5387 }) || this;
5388 }
5389 return TargetClusterCache;
5390}(util.Cache));
5391var _targetCluster = new TargetClusterCache();
5392var TargetCluster = /** @class */ (function (_super) {
5393 __extends(TargetCluster, _super);
5394 function TargetCluster(optsConnection, name) {
5395 var _this = _super.call(this) || this;
5396 if (optsConnection instanceof TopologyService) {
5397 _this.connection = optsConnection;
5398 _this.machineConnection = new MachineService(optsConnection.connectionOptions());
5399 }
5400 else {
5401 _this.connection = new TopologyService(optsConnection);
5402 _this.machineConnection = new MachineService(optsConnection);
5403 }
5404 _this.clear({
5405 Name: name
5406 });
5407 return _this;
5408 }
5409 Object.defineProperty(TargetCluster.prototype, "BaseUrl", {
5410 get: function () { return this.connection.baseUrl; },
5411 enumerable: false,
5412 configurable: true
5413 });
5414 Object.defineProperty(TargetCluster.prototype, "Name", {
5415 get: function () { return this.get("Name"); },
5416 enumerable: false,
5417 configurable: true
5418 });
5419 Object.defineProperty(TargetCluster.prototype, "Prefix", {
5420 get: function () { return this.get("Prefix"); },
5421 enumerable: false,
5422 configurable: true
5423 });
5424 Object.defineProperty(TargetCluster.prototype, "Type", {
5425 get: function () { return this.get("Type"); },
5426 enumerable: false,
5427 configurable: true
5428 });
5429 Object.defineProperty(TargetCluster.prototype, "IsDefault", {
5430 get: function () { return this.get("IsDefault"); },
5431 enumerable: false,
5432 configurable: true
5433 });
5434 Object.defineProperty(TargetCluster.prototype, "TpClusters", {
5435 get: function () { return this.get("TpClusters"); },
5436 enumerable: false,
5437 configurable: true
5438 });
5439 Object.defineProperty(TargetCluster.prototype, "TpEclCCServers", {
5440 get: function () { return this.get("TpEclCCServers"); },
5441 enumerable: false,
5442 configurable: true
5443 });
5444 Object.defineProperty(TargetCluster.prototype, "TpEclServers", {
5445 get: function () { return this.get("TpEclServers"); },
5446 enumerable: false,
5447 configurable: true
5448 });
5449 Object.defineProperty(TargetCluster.prototype, "TpEclAgents", {
5450 get: function () { return this.get("TpEclAgents"); },
5451 enumerable: false,
5452 configurable: true
5453 });
5454 Object.defineProperty(TargetCluster.prototype, "TpEclSchedulers", {
5455 get: function () { return this.get("TpEclSchedulers"); },
5456 enumerable: false,
5457 configurable: true
5458 });
5459 Object.defineProperty(TargetCluster.prototype, "MachineInfoEx", {
5460 get: function () { return this.get("MachineInfoEx", []); },
5461 enumerable: false,
5462 configurable: true
5463 });
5464 Object.defineProperty(TargetCluster.prototype, "CMachineInfoEx", {
5465 get: function () {
5466 var _this = this;
5467 return this.MachineInfoEx.map(function (machineInfoEx) { return Machine.attach(_this.machineConnection, machineInfoEx.Address, machineInfoEx); });
5468 },
5469 enumerable: false,
5470 configurable: true
5471 });
5472 TargetCluster.attach = function (optsConnection, name, state) {
5473 var retVal = _targetCluster.get({ BaseUrl: optsConnection.baseUrl, Name: name }, function () {
5474 return new TargetCluster(optsConnection, name);
5475 });
5476 if (state) {
5477 retVal.set(__assign({}, state));
5478 }
5479 return retVal;
5480 };
5481 TargetCluster.prototype.fetchMachines = function (request) {
5482 var _this = this;
5483 if (request === void 0) { request = {}; }
5484 return this.machineConnection.GetTargetClusterInfo(__assign({ TargetClusters: {
5485 Item: [this.Type + ":" + this.Name]
5486 } }, request)).then(function (response) {
5487 var retVal = [];
5488 for (var _i = 0, _a = response.TargetClusterInfoList.TargetClusterInfo; _i < _a.length; _i++) {
5489 var machineInfo = _a[_i];
5490 for (var _b = 0, _c = machineInfo.Processes.MachineInfoEx; _b < _c.length; _b++) {
5491 var machineInfoEx = _c[_b];
5492 retVal.push(machineInfoEx);
5493 }
5494 }
5495 _this.set("MachineInfoEx", retVal);
5496 return _this.CMachineInfoEx;
5497 });
5498 };
5499 TargetCluster.prototype.machineStats = function () {
5500 var maxDisk = 0;
5501 var totalFree = 0;
5502 var total = 0;
5503 for (var _i = 0, _a = this.CMachineInfoEx; _i < _a.length; _i++) {
5504 var machine = _a[_i];
5505 for (var _b = 0, _c = machine.Storage.StorageInfo; _b < _c.length; _b++) {
5506 var storageInfo = _c[_b];
5507 totalFree += storageInfo.Available;
5508 total += storageInfo.Total;
5509 var usage = 1 - storageInfo.Available / storageInfo.Total;
5510 if (usage > maxDisk) {
5511 maxDisk = usage;
5512 }
5513 }
5514 }
5515 return {
5516 maxDisk: maxDisk,
5517 meanDisk: 1 - (total ? totalFree / total : 1)
5518 };
5519 };
5520 TargetCluster.prototype.fetchUsage = function () {
5521 return this.machineConnection.GetTargetClusterUsageEx([this.Name]);
5522 };
5523 return TargetCluster;
5524}(util.StateObject));
5525function targetClusters(optsConnection) {
5526 var connection;
5527 if (optsConnection instanceof TopologyService) {
5528 connection = optsConnection;
5529 }
5530 else {
5531 connection = new TopologyService(optsConnection);
5532 }
5533 return connection.TpListTargetClusters({}).then(function (response) {
5534 return response.TargetClusters.TpClusterNameType.map(function (item) { return TargetCluster.attach(optsConnection, item.Name, item); });
5535 });
5536}
5537var _defaultTargetCluster = {};
5538function defaultTargetCluster(optsConnection) {
5539 if (!_defaultTargetCluster[optsConnection.baseUrl]) {
5540 var connection = void 0;
5541 if (optsConnection instanceof TopologyService) {
5542 connection = optsConnection;
5543 }
5544 else {
5545 connection = new TopologyService(optsConnection);
5546 }
5547 _defaultTargetCluster[optsConnection.baseUrl] = connection.TpListTargetClusters({}).then(function (response) {
5548 var firstItem;
5549 var defaultItem;
5550 var hthorItem;
5551 response.TargetClusters.TpClusterNameType.forEach(function (item) {
5552 if (!firstItem) {
5553 firstItem = item;
5554 }
5555 if (!defaultItem && item.IsDefault === true) {
5556 defaultItem = item;
5557 }
5558 if (!hthorItem && item.Type === "hthor") {
5559 hthorItem = item;
5560 }
5561 });
5562 var defItem = defaultItem || hthorItem || firstItem;
5563 return TargetCluster.attach(optsConnection, defItem.Name, defItem);
5564 });
5565 }
5566 return _defaultTargetCluster[optsConnection.baseUrl];
5567}
5568
5569var Topology = /** @class */ (function (_super) {
5570 __extends(Topology, _super);
5571 function Topology(optsConnection) {
5572 var _this = _super.call(this) || this;
5573 if (optsConnection instanceof TopologyService) {
5574 _this.connection = optsConnection;
5575 }
5576 else {
5577 _this.connection = new TopologyService(optsConnection);
5578 }
5579 return _this;
5580 }
5581 Object.defineProperty(Topology.prototype, "properties", {
5582 // Accessors ---
5583 get: function () { return this.get(); },
5584 enumerable: false,
5585 configurable: true
5586 });
5587 Object.defineProperty(Topology.prototype, "TargetClusters", {
5588 get: function () { return this.get("TargetClusters"); },
5589 enumerable: false,
5590 configurable: true
5591 });
5592 Object.defineProperty(Topology.prototype, "CTargetClusters", {
5593 get: function () {
5594 var _this = this;
5595 return this.TargetClusters.map(function (tc) { return TargetCluster.attach(_this.connection, tc.Name, tc); });
5596 },
5597 enumerable: false,
5598 configurable: true
5599 });
5600 Topology.prototype.GetESPServiceBaseURL = function (type) {
5601 var _this = this;
5602 if (type === void 0) { type = ""; }
5603 return this.connection.TpServiceQuery({}).then(function (response) {
5604 var rootProtocol = _this.connection.protocol();
5605 var ip = _this.connection.ip();
5606 var port = rootProtocol === "https:" ? "18002" : "8002";
5607 if (util.exists("ServiceList.TpEspServers.TpEspServer", response)) {
5608 for (var _i = 0, _a = response.ServiceList.TpEspServers.TpEspServer; _i < _a.length; _i++) {
5609 var item = _a[_i];
5610 if (util.exists("TpBindings.TpBinding", item)) {
5611 for (var _b = 0, _c = item.TpBindings.TpBinding; _b < _c.length; _b++) {
5612 var binding = _c[_b];
5613 if (binding.Service === type && binding.Protocol + ":" === rootProtocol) {
5614 port = binding.Port;
5615 }
5616 }
5617 }
5618 }
5619 }
5620 return rootProtocol + "//" + ip + ":" + port + "/";
5621 });
5622 };
5623 Topology.prototype.fetchTargetClusters = function () {
5624 var _this = this;
5625 return this.connection.TpTargetClusterQuery({ Type: "ROOT" }).then(function (response) {
5626 _this.set({
5627 TargetClusters: response.TpTargetClusters.TpTargetCluster
5628 });
5629 return _this.CTargetClusters;
5630 });
5631 };
5632 Topology.prototype.refresh = function () {
5633 return __awaiter(this, void 0, void 0, function () {
5634 return __generator(this, function (_a) {
5635 switch (_a.label) {
5636 case 0: return [4 /*yield*/, this.fetchTargetClusters()];
5637 case 1:
5638 _a.sent();
5639 return [2 /*return*/, this];
5640 }
5641 });
5642 });
5643 };
5644 // Monitoring ---
5645 // Events ---
5646 Topology.prototype.on = function (eventID, propIDorCallback, callback) {
5647 if (this.isCallback(propIDorCallback)) {
5648 switch (eventID) {
5649 case "changed":
5650 _super.prototype.on.call(this, eventID, propIDorCallback);
5651 break;
5652 }
5653 }
5654 else {
5655 switch (eventID) {
5656 case "changed":
5657 _super.prototype.on.call(this, eventID, propIDorCallback, callback);
5658 break;
5659 }
5660 }
5661 this._monitor();
5662 return this;
5663 };
5664 return Topology;
5665}(util.StateObject));
5666
5667var logger$2 = util.scopedLogger("clienttools/eclmeta");
5668var Attr = /** @class */ (function () {
5669 function Attr(xmlAttr) {
5670 this.__attrs = xmlAttr.$;
5671 this.name = xmlAttr.$.name;
5672 }
5673 return Attr;
5674}());
5675var Field = /** @class */ (function () {
5676 function Field(definition, xmlField) {
5677 this.__attrs = xmlField.$;
5678 this.definition = definition;
5679 this.name = xmlField.$.name;
5680 this.type = xmlField.$.type;
5681 }
5682 Object.defineProperty(Field.prototype, "scope", {
5683 get: function () {
5684 return this.definition;
5685 },
5686 enumerable: false,
5687 configurable: true
5688 });
5689 return Field;
5690}());
5691var ECLScope = /** @class */ (function () {
5692 function ECLScope(name, type, sourcePath, xmlDefinitions, line, start, body, end) {
5693 if (line === void 0) { line = 1; }
5694 if (start === void 0) { start = 0; }
5695 if (body === void 0) { body = 0; }
5696 if (end === void 0) { end = Number.MAX_VALUE; }
5697 this.name = name;
5698 this.type = type;
5699 this.sourcePath = path.normalize(sourcePath);
5700 this.line = +line - 1;
5701 this.start = +start;
5702 this.body = +body;
5703 this.end = +end;
5704 this.definitions = this.parseDefinitions(xmlDefinitions);
5705 }
5706 Object.defineProperty(ECLScope.prototype, "scope", {
5707 get: function () {
5708 return this;
5709 },
5710 enumerable: false,
5711 configurable: true
5712 });
5713 ECLScope.prototype.parseDefinitions = function (definitions) {
5714 var _this = this;
5715 if (definitions === void 0) { definitions = []; }
5716 return definitions.map(function (definition) {
5717 var retVal = new Definition(_this.sourcePath, definition);
5718 return retVal;
5719 });
5720 };
5721 ECLScope.prototype.contains = function (charOffset) {
5722 return charOffset >= this.start && charOffset <= this.end;
5723 };
5724 ECLScope.prototype.scopeStackAt = function (charOffset) {
5725 var retVal = [];
5726 if (this.contains(charOffset)) {
5727 retVal.push(this);
5728 this.definitions.forEach(function (def) {
5729 retVal = def.scopeStackAt(charOffset).concat(retVal);
5730 });
5731 }
5732 return retVal;
5733 };
5734 ECLScope.prototype._resolve = function (defs, qualifiedID) {
5735 if (defs === void 0) { defs = []; }
5736 var qualifiedIDParts = qualifiedID.split(".");
5737 var base = qualifiedIDParts.shift();
5738 var retVal = util.find(defs, function (def) {
5739 if (typeof def.name === "string" && typeof base === "string" && def.name.toLowerCase() === base.toLowerCase()) {
5740 return true;
5741 }
5742 return false;
5743 });
5744 if (retVal && retVal.definitions.length && qualifiedIDParts.length) {
5745 return this._resolve(retVal.definitions, qualifiedIDParts.join("."));
5746 }
5747 return retVal;
5748 };
5749 ECLScope.prototype.resolve = function (qualifiedID) {
5750 return this._resolve(this.definitions, qualifiedID);
5751 };
5752 ECLScope.prototype.suggestions = function () {
5753 var _this = this;
5754 return this.definitions.map(function (def) {
5755 return {
5756 name: def.name,
5757 type: _this.type
5758 };
5759 });
5760 };
5761 return ECLScope;
5762}());
5763var Definition = /** @class */ (function (_super) {
5764 __extends(Definition, _super);
5765 function Definition(sourcePath, xmlDefinition) {
5766 var _this = _super.call(this, xmlDefinition.$.name, xmlDefinition.$.type, sourcePath, xmlDefinition.children("Definition"), xmlDefinition.$.line, xmlDefinition.$.start, xmlDefinition.$.body, xmlDefinition.$.end) || this;
5767 _this.__attrs = xmlDefinition.$;
5768 _this.exported = !!xmlDefinition.$.exported;
5769 _this.shared = !!xmlDefinition.$.shared;
5770 _this.fullname = xmlDefinition.$.fullname;
5771 _this.inherittype = xmlDefinition.$.inherittype;
5772 _this.attrs = _this.parseAttrs(xmlDefinition.children("Attr"));
5773 _this.fields = _this.parseFields(xmlDefinition.children("Field"));
5774 return _this;
5775 }
5776 Definition.prototype.parseAttrs = function (attrs) {
5777 if (attrs === void 0) { attrs = []; }
5778 return attrs.map(function (attr) {
5779 var retVal = new Attr(attr);
5780 return retVal;
5781 });
5782 };
5783 Definition.prototype.parseFields = function (fields) {
5784 var _this = this;
5785 if (fields === void 0) { fields = []; }
5786 return fields.map(function (field) {
5787 var retVal = new Field(_this, field);
5788 return retVal;
5789 });
5790 };
5791 Definition.prototype.suggestions = function () {
5792 return _super.prototype.suggestions.call(this).concat(this.fields.map(function (field) {
5793 return {
5794 name: field.name,
5795 type: field.type
5796 };
5797 }));
5798 };
5799 return Definition;
5800}(ECLScope));
5801var Import = /** @class */ (function () {
5802 function Import(xmlImport) {
5803 this.__attrs = xmlImport.$;
5804 this.name = xmlImport.$.name;
5805 this.ref = xmlImport.$.ref;
5806 this.start = xmlImport.$.start;
5807 this.end = xmlImport.$.end;
5808 this.line = xmlImport.$.line;
5809 }
5810 return Import;
5811}());
5812var Source = /** @class */ (function (_super) {
5813 __extends(Source, _super);
5814 function Source(xmlSource) {
5815 var _this = _super.call(this, xmlSource.$.name, "source", xmlSource.$.sourcePath, xmlSource.children("Definition")) || this;
5816 _this.__attrs = xmlSource.$;
5817 var nameParts = xmlSource.$.name.split(".");
5818 nameParts.pop();
5819 var fakeNode = new util.XMLNode("");
5820 fakeNode.appendAttribute("name", "$");
5821 fakeNode.appendAttribute("ref", nameParts.join("."));
5822 _this.imports = __spreadArrays([
5823 new Import(fakeNode)
5824 ], _this.parseImports(xmlSource.children("Import")));
5825 return _this;
5826 }
5827 Source.prototype.parseImports = function (imports) {
5828 if (imports === void 0) { imports = []; }
5829 return imports.map(function (imp) {
5830 var retVal = new Import(imp);
5831 return retVal;
5832 });
5833 };
5834 Source.prototype.resolve = function (qualifiedID, charOffset) {
5835 var retVal;
5836 // Check Inner Scopes ---
5837 if (!retVal && charOffset !== undefined) {
5838 var scopes = this.scopeStackAt(charOffset);
5839 scopes.some(function (scope) {
5840 retVal = scope.resolve(qualifiedID);
5841 return !!retVal;
5842 });
5843 }
5844 // Check Definitions ---
5845 if (!retVal) {
5846 retVal = _super.prototype.resolve.call(this, qualifiedID);
5847 }
5848 return retVal;
5849 };
5850 return Source;
5851}(ECLScope));
5852var isHiddenDirectory = function (source) { return path.basename(source).indexOf(".") === 0; };
5853var isDirectory = function (source) { return fs.lstatSync(source).isDirectory() && !isHiddenDirectory(source); };
5854var isEcl = function (source) { return [".ecl", ".ecllib"].indexOf(path.extname(source).toLowerCase()) >= 0; };
5855var modAttrs = function (source) { return fs.readdirSync(source).map(function (name) { return path.join(source, name); }).filter(function (path) { return isDirectory(path) || isEcl(path); }); };
5856var File = /** @class */ (function (_super) {
5857 __extends(File, _super);
5858 function File(name, sourcePath) {
5859 return _super.call(this, name, "file", sourcePath, []) || this;
5860 }
5861 File.prototype.suggestions = function () {
5862 return [];
5863 };
5864 return File;
5865}(ECLScope));
5866var Folder = /** @class */ (function (_super) {
5867 __extends(Folder, _super);
5868 function Folder(name, sourcePath) {
5869 return _super.call(this, name, "folder", sourcePath, []) || this;
5870 }
5871 Folder.prototype.suggestions = function () {
5872 return modAttrs(this.sourcePath).map(function (folder) {
5873 return {
5874 name: path.basename(folder, ".ecl"),
5875 type: "folder"
5876 };
5877 });
5878 };
5879 return Folder;
5880}(ECLScope));
5881var Workspace = /** @class */ (function () {
5882 function Workspace(workspacePath, eclccPath) {
5883 this._sourceByID = new util.DictionaryNoCase();
5884 this._sourceByPath = new util.Dictionary();
5885 this._test = new util.DictionaryNoCase();
5886 this._workspacePath = workspacePath;
5887 this._eclccPath = eclccPath;
5888 }
5889 Workspace.prototype.refresh = function () {
5890 this.primeWorkspace();
5891 this.primeClientTools();
5892 };
5893 Workspace.prototype.primeClientTools = function () {
5894 var _this = this;
5895 return locateClientTools(this._eclccPath, "", this._workspacePath).then(function (clientTools) {
5896 _this._clientTools = clientTools;
5897 return clientTools.paths();
5898 }).then(function (paths) {
5899 for (var _i = 0, _a = ["ECLCC_ECLLIBRARY_PATH", "ECLCC_PLUGIN_PATH"]; _i < _a.length; _i++) {
5900 var knownFolder = _a[_i];
5901 if (paths[knownFolder] && fs.existsSync(paths[knownFolder])) {
5902 _this.walkChildFolders(paths[knownFolder], paths[knownFolder]);
5903 }
5904 }
5905 return _this;
5906 });
5907 };
5908 Workspace.prototype.primeWorkspace = function () {
5909 if (fs.existsSync(this._workspacePath)) {
5910 this.visitFolder(this._workspacePath, this._workspacePath);
5911 }
5912 };
5913 Workspace.prototype.walkChildFolders = function (folderPath, refPath, force) {
5914 if (force === void 0) { force = false; }
5915 for (var _i = 0, _a = modAttrs(folderPath); _i < _a.length; _i++) {
5916 var child = _a[_i];
5917 if (!isDirectory(child)) {
5918 this.visitFile(child, refPath, force);
5919 }
5920 else {
5921 this.visitFolder(child, refPath, force);
5922 }
5923 }
5924 };
5925 Workspace.prototype.visitFile = function (filePath, refPath, force) {
5926 if (force === void 0) { force = false; }
5927 var filePathInfo = path.parse(filePath);
5928 var pathNoExt = path.join(filePathInfo.dir, filePathInfo.name);
5929 var name = path.relative(refPath, pathNoExt).split(path.sep).join(".");
5930 if (force || !this._test.has(name)) {
5931 this._test.set(name, new File("", filePath));
5932 }
5933 };
5934 Workspace.prototype.visitFolder = function (folderPath, refPath, force) {
5935 if (force === void 0) { force = false; }
5936 var name = path.relative(refPath, folderPath).split(path.sep).join(".");
5937 if (force || !this._test.has(name)) {
5938 this._test.set(name, new Folder(name, folderPath));
5939 this.walkChildFolders(folderPath, refPath, force);
5940 }
5941 };
5942 Workspace.prototype.buildStack = function (parentStack, name, removeDupID) {
5943 var nameStack = name.split(".");
5944 if (removeDupID && parentStack[parentStack.length - 1] === nameStack[0]) {
5945 nameStack.shift();
5946 }
5947 var stack = __spreadArrays(parentStack, nameStack);
5948 var qid = stack.join(".");
5949 return {
5950 stack: stack,
5951 qid: qid
5952 };
5953 };
5954 Workspace.prototype.walkECLScope = function (parentStack, scope) {
5955 var info = this.buildStack(parentStack, scope.name, true);
5956 this._test.set(info.qid, scope);
5957 for (var _i = 0, _a = scope.definitions; _i < _a.length; _i++) {
5958 var def = _a[_i];
5959 this.walkDefinition(info.stack, def);
5960 }
5961 };
5962 Workspace.prototype.walkField = function (parentStack, field) {
5963 var info = this.buildStack(parentStack, field.name, false);
5964 this._test.set(info.qid, field);
5965 };
5966 Workspace.prototype.walkDefinition = function (parentStack, definition) {
5967 var info = this.buildStack(parentStack, definition.name, true);
5968 this.walkECLScope(parentStack, definition);
5969 for (var _i = 0, _a = definition.fields; _i < _a.length; _i++) {
5970 var field = _a[_i];
5971 this.walkField(info.stack, field);
5972 }
5973 };
5974 Workspace.prototype.walkSource = function (source) {
5975 // const dirName = path.dirname(source.sourcePath);
5976 // const relName = path.relative(this._workspacePath, dirName).split(path.sep).join(".");
5977 // const folder = new Folder(relName, dirName);
5978 // this._test.set(folder.name, folder);
5979 this.walkECLScope([], source);
5980 };
5981 Workspace.prototype.parseSources = function (sources) {
5982 if (sources === void 0) { sources = []; }
5983 for (var _i = 0, sources_1 = sources; _i < sources_1.length; _i++) {
5984 var _source = sources_1[_i];
5985 if (_source.$.name) { // Plugins have no name...
5986 var source = new Source(_source);
5987 this._sourceByID.set(source.name, source);
5988 this._sourceByPath.set(source.sourcePath, source);
5989 // If external source like "std.system.ThorLib" then need to backup to "std" and add its folder
5990 if (source.name) {
5991 var sourceNameParts = source.name.split(".");
5992 var depth = sourceNameParts.length;
5993 if (depth > 1) {
5994 var sourcePath = source.sourcePath;
5995 while (depth > 1) {
5996 sourcePath = path.dirname(sourcePath);
5997 --depth;
5998 }
5999 this.visitFolder(sourcePath, path.dirname(sourcePath));
6000 }
6001 }
6002 this.walkSource(source);
6003 }
6004 }
6005 };
6006 Workspace.prototype.parseMetaXML = function (metaXML) {
6007 var metaParser = new MetaParser();
6008 metaParser.parse(metaXML);
6009 this.parseSources(metaParser.sources);
6010 return metaParser.sources.map(function (source) { return path.normalize(source.$.sourcePath); });
6011 };
6012 Workspace.prototype.resolveQualifiedID = function (filePath, qualifiedID, charOffset) {
6013 var retVal;
6014 if (!retVal && this._test.has(qualifiedID)) {
6015 retVal = this._test.get(qualifiedID).scope;
6016 }
6017 if (!retVal && this._sourceByPath.has(filePath)) {
6018 var eclSource = this._sourceByPath.get(filePath);
6019 // Resolve Imports ---
6020 var qualifiedIDParts = qualifiedID.split(".");
6021 for (var _i = 0, _a = eclSource.imports; _i < _a.length; _i++) {
6022 var imp = _a[_i];
6023 if (imp.name.toLowerCase() === qualifiedIDParts[0].toLowerCase()) {
6024 if (imp.ref) {
6025 qualifiedIDParts[0] = imp.ref;
6026 }
6027 else {
6028 qualifiedIDParts.shift();
6029 }
6030 break;
6031 }
6032 }
6033 var realQID = qualifiedIDParts.join(".");
6034 if (!retVal && this._test.has(realQID)) {
6035 retVal = this._test.get(realQID).scope;
6036 }
6037 if (!retVal) {
6038 realQID = __spreadArrays(eclSource.name.split("."), qualifiedIDParts).join(".");
6039 if (this._test.has(realQID)) {
6040 retVal = this._test.get(realQID).scope;
6041 }
6042 }
6043 }
6044 return retVal;
6045 };
6046 Workspace.prototype.resolvePartialID = function (filePath, partialID, charOffset) {
6047 partialID = partialID.toLowerCase();
6048 var partialIDParts = partialID.split(".");
6049 partialIDParts.pop();
6050 var partialIDQualifier = partialIDParts.length === 1 ? partialIDParts[0] : partialIDParts.join(".");
6051 return this.resolveQualifiedID(filePath, partialIDQualifier, charOffset);
6052 };
6053 return Workspace;
6054}());
6055var workspaceCache = new util.Dictionary();
6056function attachWorkspace(_workspacePath, eclccPath) {
6057 var workspacePath = path.normalize(_workspacePath);
6058 if (!workspaceCache.has(workspacePath)) {
6059 var workspace = new Workspace(workspacePath, eclccPath);
6060 workspaceCache.set(workspacePath, workspace);
6061 workspace.refresh();
6062 }
6063 return workspaceCache.get(workspacePath);
6064}
6065function isQualifiedIDChar(lineText, charPos, reverse) {
6066 if (charPos < 0)
6067 return false;
6068 var testChar = lineText.charAt(charPos);
6069 return (reverse ? /[a-zA-Z\d_\.$]/ : /[a-zA-Z\d_]/).test(testChar);
6070}
6071function qualifiedIDBoundary(lineText, charPos, reverse) {
6072 while (isQualifiedIDChar(lineText, charPos, reverse)) {
6073 charPos += reverse ? -1 : 1;
6074 }
6075 return charPos + (reverse ? 1 : -1);
6076}
6077var MetaParser = /** @class */ (function (_super) {
6078 __extends(MetaParser, _super);
6079 function MetaParser() {
6080 var _this = _super !== null && _super.apply(this, arguments) || this;
6081 _this.sources = [];
6082 return _this;
6083 }
6084 MetaParser.prototype.endXMLNode = function (e) {
6085 switch (e.name) {
6086 case "Source":
6087 this.sources.push(e);
6088 break;
6089 }
6090 _super.prototype.endXMLNode.call(this, e);
6091 };
6092 return MetaParser;
6093}(util.SAXStackParser));
6094
6095var logger$3 = util.scopedLogger("clienttools/eclcc");
6096var exeExt = os.type() === "Windows_NT" ? ".exe" : "";
6097var Version = /** @class */ (function () {
6098 function Version(build) {
6099 this.prefix = "";
6100 this.major = 0;
6101 this.minor = 0;
6102 this.patch = 0;
6103 this.postfix = "";
6104 var parts = build.split(" ");
6105 if (parts.length) {
6106 var match = /(?:(\w+)_)?(\d+)\.(\d+)\.(\d+)(?:-(.*))?/.exec(parts[parts.length - 1]);
6107 if (match) {
6108 this.prefix = match[1] || "";
6109 this.major = +match[2] || 0;
6110 this.minor = +match[3] || 0;
6111 this.patch = +match[4] || 0;
6112 this.postfix = match[5] || "";
6113 }
6114 }
6115 }
6116 Version.prototype.parse = function (build) {
6117 };
6118 Version.prototype.exists = function () {
6119 return this.major !== 0 || this.minor !== 0 || this.patch !== 0 || this.postfix !== "";
6120 };
6121 Version.prototype.compare = function (other) {
6122 if (this.major > other.major)
6123 return 1;
6124 if (this.major < other.major)
6125 return -1;
6126 if (this.minor > other.minor)
6127 return 1;
6128 if (this.minor < other.minor)
6129 return -1;
6130 if (this.patch > other.patch)
6131 return 1;
6132 if (this.patch < other.patch)
6133 return -1;
6134 if (this.postfix === "" && other.postfix !== "")
6135 return 1;
6136 return this.postfix.localeCompare(other.postfix);
6137 };
6138 Version.prototype.toString = function () {
6139 return this.prefix + "_" + this.major + "." + this.minor + "." + this.patch + "-" + this.postfix;
6140 };
6141 return Version;
6142}());
6143var ERROR = "error";
6144var WARN = "warning";
6145var Errors = /** @class */ (function () {
6146 function Errors(checked) {
6147 this.errWarn = [];
6148 this.errOther = [];
6149 this._checked = checked;
6150 }
6151 Errors.prototype.checked = function () {
6152 return this._checked;
6153 };
6154 Errors.prototype.all = function () {
6155 return this.errWarn;
6156 };
6157 Errors.prototype.errors = function () {
6158 return this.errWarn.filter(function (e) { return e.severity === ERROR; });
6159 };
6160 Errors.prototype.hasError = function () {
6161 return this.errors().length > 0;
6162 };
6163 Errors.prototype.warnings = function () {
6164 return this.errWarn.filter(function (e) { return e.severity === WARN; });
6165 };
6166 Errors.prototype.hasWarning = function () {
6167 return this.warnings().length > 0;
6168 };
6169 Errors.prototype.info = function () {
6170 return this.errWarn.filter(function (e) { return [ERROR, WARN].indexOf(e.severity) < 0; });
6171 };
6172 Errors.prototype.hasOther = function () {
6173 return this.info().length > 0;
6174 };
6175 Errors.prototype.unknown = function () {
6176 return this.errOther;
6177 };
6178 Errors.prototype.hasUnknown = function () {
6179 return this.unknown().length > 0;
6180 };
6181 return Errors;
6182}());
6183var EclccErrors = /** @class */ (function (_super) {
6184 __extends(EclccErrors, _super);
6185 function EclccErrors(stdErr, checked) {
6186 var _this = _super.call(this, checked) || this;
6187 if (stdErr && stdErr.length) {
6188 for (var _i = 0, _a = stdErr.split(os.EOL); _i < _a.length; _i++) {
6189 var errLine = _a[_i];
6190 var match = /([a-zA-Z]:\\(?:[- \w\.\d]+\\)*(?:[- \w\.\d]+)?|(?:\/[\w\.\-]+)+)\((\d*),(\d*)\) ?: ?(error|warning|info) C(\d*) ?: ?(.*)/.exec(errLine);
6191 if (match) {
6192 var filePath = match[1], row = match[2], _col = match[3], severity = match[4], code = match[5], _msg = match[6];
6193 var line = +row;
6194 var col = +_col;
6195 var msg = code + ": " + _msg;
6196 _this.errWarn.push({ filePath: filePath, line: line, col: col, msg: msg, severity: severity });
6197 continue;
6198 }
6199 match = /(error|warning|info): (.*)/i.exec(errLine);
6200 if (match) {
6201 var severity = match[1], msg = match[2];
6202 _this.errWarn.push({ filePath: "", line: 0, col: 0, msg: msg, severity: severity });
6203 continue;
6204 }
6205 match = /\d error(s?), \d warning(s?)/.exec(errLine);
6206 if (match) {
6207 continue;
6208 }
6209 logger$3.warning("parseECLErrors: Unable to parse \"" + errLine + "\"");
6210 _this.errOther.push(errLine);
6211 }
6212 }
6213 _this._checked = checked;
6214 return _this;
6215 }
6216 return EclccErrors;
6217}(Errors));
6218var EnvchkErrors = /** @class */ (function (_super) {
6219 __extends(EnvchkErrors, _super);
6220 function EnvchkErrors(filePath, stdErr, checked) {
6221 var _this = _super.call(this, checked) || this;
6222 var content = fs.readFileSync(filePath, "utf8");
6223 content = content.replace("\r\n", "\n");
6224 _this._lines = content.split("\n");
6225 if (stdErr && stdErr.length) {
6226 for (var _i = 0, _a = stdErr.split(os.EOL); _i < _a.length; _i++) {
6227 var errLine = _a[_i];
6228 var match = /(Warning|Error) : Path\=(\S*?)(\[\S*\])? Message\=(.*)/.exec(errLine);
6229 if (match) {
6230 var severity = match[1], _path = match[2], _attr = match[3], _msg = match[4];
6231 var msg = _path + " " + (_attr ? _attr : "") + ": " + _msg;
6232 var _b = _this.locate(_path), line = _b[0], col = _b[1];
6233 _this.errWarn.push({ filePath: filePath, line: line, col: col, msg: msg, severity: severity });
6234 continue;
6235 }
6236 if (match) {
6237 continue;
6238 }
6239 logger$3.warning("parseECLErrors: Unable to parse \"" + errLine + "\"");
6240 _this.errOther.push(errLine);
6241 }
6242 }
6243 _this._checked = checked;
6244 return _this;
6245 }
6246 EnvchkErrors.prototype.locate = function (path) {
6247 var pathParts = path.split("/");
6248 if (pathParts.length && pathParts[0] === "") {
6249 pathParts.shift();
6250 }
6251 if (pathParts.length > 0) {
6252 var lineIdx = 0;
6253 for (var _i = 0, _a = this._lines; _i < _a.length; _i++) {
6254 var line = _a[_i];
6255 var testStr = "<" + pathParts[0];
6256 if (line.indexOf(testStr + " ") >= 0 || line.indexOf(testStr + ">") >= 0) {
6257 console.log(lineIdx, testStr);
6258 pathParts.shift();
6259 if (pathParts.length === 0) {
6260 return [lineIdx + 1, line.indexOf(testStr) + 1];
6261 }
6262 }
6263 ++lineIdx;
6264 }
6265 }
6266 return [0, 0];
6267 };
6268 return EnvchkErrors;
6269}(Errors));
6270function walkXmlJson$1(node, callback, stack) {
6271 stack = stack || [];
6272 stack.push(node);
6273 for (var key in node) {
6274 if (node.hasOwnProperty(key)) {
6275 var childNode = node[key];
6276 callback(key, childNode, stack);
6277 if (childNode instanceof Array) {
6278 childNode.forEach(function (child) {
6279 walkXmlJson$1(child, callback, stack);
6280 });
6281 }
6282 else if (typeof childNode === "object") {
6283 walkXmlJson$1(childNode, callback, stack);
6284 }
6285 }
6286 }
6287 stack.pop();
6288}
6289var LocalWorkunit = /** @class */ (function () {
6290 function LocalWorkunit(jsonWU) {
6291 this.jsonWU = jsonWU;
6292 }
6293 LocalWorkunit.prototype.bpGetValidLocations = function (filePath) {
6294 var retVal = [];
6295 if (util.exists("W_LOCAL.Graphs", this.jsonWU)) {
6296 var id_1 = "";
6297 walkXmlJson$1(this.jsonWU.W_LOCAL.Graphs, function (key, item, _stack) {
6298 if (key === "$" && item.id) {
6299 id_1 = item.id;
6300 }
6301 if (key === "$" && item.name === "definition") {
6302 var match = /([a-z,A-Z]:\\(?:[-\w\.\d]+\\)*(?:[-\w\.\d]+)?|(?:\/[\w\.\-]+)+)\((\d*),(\d*)\)/.exec(item.value);
6303 if (match) {
6304 var file = match[1], row = match[2], _col = match[3];
6305 var line = +row;
6306 var col = +_col;
6307 if (filePath === file) {
6308 retVal.push({ file: file, line: line, col: col, id: id_1 });
6309 }
6310 }
6311 }
6312 // console.log(`${key}: ` + JSON.stringify(item));
6313 });
6314 }
6315 return retVal;
6316 };
6317 return LocalWorkunit;
6318}());
6319var ClientTools = /** @class */ (function () {
6320 function ClientTools(eclccPath, cwd, includeFolders, legacyMode, args, version) {
6321 if (includeFolders === void 0) { includeFolders = []; }
6322 if (legacyMode === void 0) { legacyMode = false; }
6323 if (args === void 0) { args = []; }
6324 this._paths = {};
6325 this.eclccPath = eclccPath;
6326 this.binPath = path.dirname(this.eclccPath);
6327 this.envchkPath = path.join(this.binPath, "envchk" + exeExt);
6328 this.cwd = path.normalize(cwd || this.binPath);
6329 this.includeFolders = includeFolders;
6330 this._legacyMode = legacyMode;
6331 this._args = args;
6332 this._version = version;
6333 }
6334 ClientTools.prototype.clone = function (cwd, includeFolders, legacyMode, args) {
6335 if (legacyMode === void 0) { legacyMode = false; }
6336 if (args === void 0) { args = []; }
6337 return new ClientTools(this.eclccPath, cwd, includeFolders, legacyMode, args, this._version);
6338 };
6339 ClientTools.prototype.exists = function (filePath) {
6340 try {
6341 fs.accessSync(filePath);
6342 return true;
6343 }
6344 catch (e) { }
6345 return false;
6346 };
6347 ClientTools.prototype.args = function (additionalItems) {
6348 if (additionalItems === void 0) { additionalItems = []; }
6349 var retVal = __spreadArrays(this._args);
6350 if (this._legacyMode) {
6351 retVal.push("-legacy");
6352 }
6353 return retVal.concat(this.includeFolders.map(function (includePath) {
6354 return "-I" + path.normalize(includePath);
6355 })).concat(additionalItems);
6356 };
6357 ClientTools.prototype.version = function () {
6358 var _this = this;
6359 if (this._version) {
6360 return Promise.resolve(this._version);
6361 }
6362 return this.execFile(this.eclccPath, this.binPath, this.args(["--version"]), "eclcc", "Cannot find " + this.eclccPath).then(function (response) {
6363 _this._version = new Version(response.stdout);
6364 return _this._version;
6365 });
6366 };
6367 ClientTools.prototype.versionSync = function () {
6368 return this._version;
6369 };
6370 ClientTools.prototype.paths = function () {
6371 var _this = this;
6372 return this.execFile(this.eclccPath, this.cwd, this.args(["-showpaths"]), "eclcc", "Cannot find " + this.eclccPath).then(function (response) {
6373 if (response && response.stdout && response.stdout.length) {
6374 var paths = response.stdout.split(/\r?\n/);
6375 for (var _i = 0, paths_1 = paths; _i < paths_1.length; _i++) {
6376 var path_1 = paths_1[_i];
6377 var parts = path_1.split("=");
6378 if (parts.length === 2) {
6379 _this._paths[parts[0]] = parts[1];
6380 }
6381 }
6382 }
6383 return _this._paths;
6384 });
6385 };
6386 ClientTools.prototype.loadXMLDoc = function (filePath, removeOnRead) {
6387 return new Promise(function (resolve, _reject) {
6388 var fileData = fs.readFileSync(filePath, "ascii");
6389 var retVal = util.xml2json(fileData);
6390 if (removeOnRead) {
6391 fs.unlink(filePath, function (err) { });
6392 }
6393 resolve(retVal);
6394 });
6395 };
6396 ClientTools.prototype.createWU = function (filename) {
6397 var _this = this;
6398 var tmpName = tmp.tmpNameSync({ prefix: "eclcc-wu-tmp", postfix: "" });
6399 var args = ["-o" + tmpName, "-wu"].concat([filename]);
6400 return this.execFile(this.eclccPath, this.cwd, this.args(args), "eclcc", "Cannot find " + this.eclccPath).then(function (_response) {
6401 var xmlPath = path.normalize(tmpName + ".xml");
6402 var contentPromise = _this.exists(xmlPath) ? _this.loadXMLDoc(xmlPath, true) : Promise.resolve({});
6403 return contentPromise.then(function (content) {
6404 return new LocalWorkunit(content);
6405 });
6406 });
6407 };
6408 ClientTools.prototype.createArchive = function (filename) {
6409 var args = ["-E"].concat([filename]);
6410 return this.execFile(this.eclccPath, this.cwd, this.args(args), "eclcc", "Cannot find " + this.eclccPath).then(function (response) {
6411 return {
6412 content: response.stdout,
6413 err: new EclccErrors(response.stderr, [])
6414 };
6415 });
6416 };
6417 ClientTools.prototype.attachWorkspace = function () {
6418 return attachWorkspace(this.cwd);
6419 };
6420 ClientTools.prototype.fetchMeta = function (filePath) {
6421 return Promise.all([
6422 attachWorkspace(this.cwd),
6423 this.execFile(this.eclccPath, this.cwd, this.args(["-M", filePath]), "eclcc", "Cannot find " + this.eclccPath)
6424 ]).then(function (_a) {
6425 var metaWorkspace = _a[0], execFileResponse = _a[1];
6426 if (execFileResponse && execFileResponse.stdout && execFileResponse.stdout.length) {
6427 metaWorkspace.parseMetaXML(execFileResponse.stdout);
6428 }
6429 return metaWorkspace;
6430 });
6431 };
6432 ClientTools.prototype.syntaxCheck = function (filePath, args) {
6433 if (args === void 0) { args = ["-syntax"]; }
6434 return Promise.all([
6435 attachWorkspace(this.cwd),
6436 this.execFile(this.eclccPath, this.cwd, this.args(__spreadArrays(args, ["-M", filePath])), "eclcc", "Cannot find " + this.eclccPath)
6437 ]).then(function (_a) {
6438 var metaWorkspace = _a[0], execFileResponse = _a[1];
6439 var checked = [];
6440 if (execFileResponse && execFileResponse.stdout && execFileResponse.stdout.length) {
6441 checked = metaWorkspace.parseMetaXML(execFileResponse.stdout);
6442 }
6443 return new EclccErrors(execFileResponse ? execFileResponse.stderr : "", checked);
6444 });
6445 };
6446 ClientTools.prototype.envCheck = function (filePath, args) {
6447 if (args === void 0) { args = []; }
6448 return Promise.all([
6449 attachWorkspace(this.cwd),
6450 this.execFile(this.envchkPath, this.cwd, this.args(__spreadArrays(args, [filePath])), "envchk", "Cannot find " + this.envchkPath)
6451 ]).then(function (_a) {
6452 var metaWorkspace = _a[0], execFileResponse = _a[1];
6453 return new EnvchkErrors(filePath, execFileResponse ? execFileResponse.stderr : "", []);
6454 });
6455 };
6456 ClientTools.prototype.execFile = function (cmd, cwd, args, _toolName, _notFoundError) {
6457 return new Promise(function (resolve, _reject) {
6458 logger$3.debug(cmd + " " + args.join(" "));
6459 var child = cp.spawn(cmd, args, { cwd: cwd });
6460 var stdOut = "";
6461 var stdErr = "";
6462 child.stdout.on("data", function (data) {
6463 stdOut += data.toString();
6464 });
6465 child.stderr.on("data", function (data) {
6466 stdErr += data.toString();
6467 });
6468 child.on("close", function (_code, _signal) {
6469 resolve({
6470 stdout: stdOut.trim(),
6471 stderr: stdErr.trim()
6472 });
6473 });
6474 });
6475 };
6476 return ClientTools;
6477}());
6478function locateClientToolsInFolder(rootFolder, clientTools) {
6479 if (rootFolder) {
6480 var hpccSystemsFolder_1 = path.join(rootFolder, "HPCCSystems");
6481 if (fs.existsSync(hpccSystemsFolder_1) && fs.statSync(hpccSystemsFolder_1).isDirectory()) {
6482 if (os.type() !== "Windows_NT") {
6483 var eclccPath = path.join(hpccSystemsFolder_1, "bin", "eclcc");
6484 if (fs.existsSync(eclccPath)) {
6485 clientTools.push(new ClientTools(eclccPath));
6486 }
6487 }
6488 fs.readdirSync(hpccSystemsFolder_1).forEach(function (versionFolder) {
6489 var eclccPath = path.join(hpccSystemsFolder_1, versionFolder, "clienttools", "bin", "eclcc" + exeExt);
6490 if (fs.existsSync(eclccPath)) {
6491 var name_1 = path.basename(versionFolder);
6492 var version = new Version(name_1);
6493 if (version.exists()) {
6494 clientTools.push(new ClientTools(eclccPath));
6495 }
6496 }
6497 });
6498 }
6499 }
6500}
6501var allClientToolsCache;
6502function locateAllClientTools() {
6503 if (allClientToolsCache)
6504 return allClientToolsCache;
6505 var clientTools = [];
6506 switch (os.type()) {
6507 case "Windows_NT":
6508 var rootFolder86 = process.env["ProgramFiles(x86)"] || "";
6509 if (rootFolder86) {
6510 locateClientToolsInFolder(rootFolder86, clientTools);
6511 }
6512 var rootFolder = process.env["ProgramFiles"] || "";
6513 if (rootFolder) {
6514 locateClientToolsInFolder(rootFolder, clientTools);
6515 }
6516 if (!rootFolder86 && !rootFolder) {
6517 locateClientToolsInFolder("c:\\Program Files (x86)", clientTools);
6518 }
6519 break;
6520 case "Linux":
6521 case "Darwin":
6522 locateClientToolsInFolder("/opt", clientTools);
6523 break;
6524 }
6525 allClientToolsCache = Promise.all(clientTools.map(function (ct) { return ct.version(); })).then(function () {
6526 clientTools.sort(function (l, r) {
6527 return r.versionSync().compare(l.versionSync());
6528 });
6529 return clientTools;
6530 });
6531 return allClientToolsCache;
6532}
6533var eclccPathMsg = "";
6534function logEclccPath(eclccPath) {
6535 var msg = "Using eclccPath setting: " + eclccPath;
6536 if (eclccPathMsg !== msg) {
6537 logger$3.info(msg);
6538 eclccPathMsg = msg;
6539 }
6540}
6541function locateClientTools(overridePath, build, cwd, includeFolders, legacyMode) {
6542 if (overridePath === void 0) { overridePath = ""; }
6543 if (build === void 0) { build = ""; }
6544 if (cwd === void 0) { cwd = "."; }
6545 if (includeFolders === void 0) { includeFolders = []; }
6546 if (legacyMode === void 0) { legacyMode = false; }
6547 if (overridePath && fs.existsSync(overridePath)) {
6548 logEclccPath(overridePath);
6549 return Promise.resolve(new ClientTools(overridePath, cwd, includeFolders, legacyMode));
6550 }
6551 return locateAllClientTools().then(function (allClientToolsCache2) {
6552 if (!allClientToolsCache2.length) {
6553 throw new Error("Unable to locate ECL Client Tools.");
6554 }
6555 var buildVersion = new Version(build);
6556 var latest;
6557 var bestMajor;
6558 for (var _i = 0, allClientToolsCache2_1 = allClientToolsCache2; _i < allClientToolsCache2_1.length; _i++) {
6559 var ct = allClientToolsCache2_1[_i];
6560 var ctVersion = ct.versionSync();
6561 if (!latest)
6562 latest = ct;
6563 if (!bestMajor && buildVersion.major === ctVersion.major)
6564 bestMajor = ct;
6565 if (buildVersion.major === ctVersion.major && buildVersion.minor === ctVersion.minor)
6566 return ct.clone(cwd, includeFolders, legacyMode);
6567 }
6568 var best = bestMajor || latest;
6569 logEclccPath(best.eclccPath);
6570 return best.clone(cwd, includeFolders, legacyMode);
6571 });
6572}
6573
6574// DOM Parser polyfill ---
6575util.root.DOMParser = xmldom.DOMParser;
6576if (typeof util.root.fetch === "undefined") {
6577 util.root.fetch = fetch$1;
6578 // eslint-disable-next-line @typescript-eslint/no-var-requires
6579 var https = require("https");
6580 util.root.fetch.__agent = new https.Agent({
6581 rejectUnauthorized: false
6582 });
6583}
6584if (typeof util.root.btoa === "undefined") {
6585 util.root.btoa = function (str) {
6586 return safeBuffer.Buffer.from(str || "", "utf8").toString("base64");
6587 };
6588}
6589
6590exports.AccountService = AccountService;
6591exports.Activity = Activity;
6592exports.Attr = Attr;
6593exports.Attribute = Attribute;
6594exports.BUILD_VERSION = BUILD_VERSION;
6595exports.BaseScope = BaseScope;
6596exports.ClientTools = ClientTools;
6597exports.Connection = Connection;
6598exports.DFUService = DFUService;
6599exports.Definition = Definition;
6600exports.ECLGraph = ECLGraph;
6601exports.ECLScope = ECLScope;
6602exports.ESPConnection = ESPConnection;
6603exports.ESPExceptions = ESPExceptions;
6604exports.EclService = EclService;
6605exports.EclccErrors = EclccErrors;
6606exports.EnvchkErrors = EnvchkErrors;
6607exports.Errors = Errors;
6608exports.Field = Field;
6609exports.File = File;
6610exports.Folder = Folder;
6611exports.GlobalResultCache = GlobalResultCache;
6612exports.GraphCache = GraphCache;
6613exports.Import = Import;
6614exports.LocalWorkunit = LocalWorkunit;
6615exports.LogicalFile = LogicalFile;
6616exports.LogicalFileCache = LogicalFileCache;
6617exports.Machine = Machine;
6618exports.MachineCache = MachineCache;
6619exports.MachineService = MachineService;
6620exports.PKG_NAME = PKG_NAME;
6621exports.PKG_VERSION = PKG_VERSION;
6622exports.Query = Query;
6623exports.Resource = Resource;
6624exports.Result = Result;
6625exports.ResultCache = ResultCache;
6626exports.SMCService = SMCService;
6627exports.Scope = Scope;
6628exports.ScopeEdge = ScopeEdge;
6629exports.ScopeGraph = ScopeGraph;
6630exports.ScopeSubgraph = ScopeSubgraph;
6631exports.ScopeVertex = ScopeVertex;
6632exports.Service = Service;
6633exports.Source = Source;
6634exports.SourceFile = SourceFile;
6635exports.Store = Store;
6636exports.StoreCache = StoreCache;
6637exports.StoreService = StoreService;
6638exports.TargetCluster = TargetCluster;
6639exports.TargetClusterCache = TargetClusterCache;
6640exports.Timer = Timer;
6641exports.Topology = Topology;
6642exports.TopologyService = TopologyService;
6643exports.ValueChangedMessage = ValueChangedMessage;
6644exports.Version = Version;
6645exports.Workspace = Workspace;
6646exports.Workunit = Workunit;
6647exports.WorkunitCache = WorkunitCache;
6648exports.WorkunitsService = WorkunitsService;
6649exports.XGMMLEdge = XGMMLEdge;
6650exports.XGMMLGraph = XGMMLGraph;
6651exports.XGMMLSubgraph = XGMMLSubgraph;
6652exports.XGMMLVertex = XGMMLVertex;
6653exports.XSDNode = XSDNode;
6654exports.XSDSchema = XSDSchema;
6655exports.XSDSimpleType = XSDSimpleType;
6656exports.XSDXMLNode = XSDXMLNode;
6657exports.attachWorkspace = attachWorkspace;
6658exports.createGraph = createGraph;
6659exports.createXGMMLGraph = createXGMMLGraph;
6660exports.defaultTargetCluster = defaultTargetCluster;
6661exports.deserializeResponse = deserializeResponse;
6662exports.get = get;
6663exports.hookSend = hookSend;
6664exports.instanceOfIConnection = instanceOfIConnection;
6665exports.instanceOfIOptions = instanceOfIOptions;
6666exports.isArray = isArray;
6667exports.isWUInfoWorkunit = isWUInfoWorkunit;
6668exports.isWUQueryECLWorkunit = isWUQueryECLWorkunit;
6669exports.jsonp = jsonp;
6670exports.locateAllClientTools = locateAllClientTools;
6671exports.locateClientTools = locateClientTools;
6672exports.parseXSD = parseXSD;
6673exports.parseXSD2 = parseXSD2;
6674exports.post = post;
6675exports.qualifiedIDBoundary = qualifiedIDBoundary;
6676exports.send = send;
6677exports.serializeRequest = serializeRequest;
6678exports.setTransportFactory = setTransportFactory;
6679exports.targetClusters = targetClusters;
6680exports.walkXmlJson = walkXmlJson$1;
6681//# sourceMappingURL=index.node.js.map