UNPKG

245 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.13.15";
19var BUILD_VERSION = "2.15.19";
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 default:
2126 }
2127 });
2128 return graph;
2129}
2130var ScopeGraph = /** @class */ (function (_super) {
2131 __extends(ScopeGraph, _super);
2132 function ScopeGraph() {
2133 return _super !== null && _super.apply(this, arguments) || this;
2134 }
2135 return ScopeGraph;
2136}(util.Graph));
2137var ScopeSubgraph = /** @class */ (function (_super) {
2138 __extends(ScopeSubgraph, _super);
2139 function ScopeSubgraph() {
2140 return _super !== null && _super.apply(this, arguments) || this;
2141 }
2142 return ScopeSubgraph;
2143}(util.Subgraph));
2144var ScopeVertex = /** @class */ (function (_super) {
2145 __extends(ScopeVertex, _super);
2146 function ScopeVertex() {
2147 return _super !== null && _super.apply(this, arguments) || this;
2148 }
2149 return ScopeVertex;
2150}(util.Vertex));
2151var ScopeEdge = /** @class */ (function (_super) {
2152 __extends(ScopeEdge, _super);
2153 function ScopeEdge() {
2154 return _super !== null && _super.apply(this, arguments) || this;
2155 }
2156 return ScopeEdge;
2157}(util.Edge));
2158function createGraph(scopes) {
2159 var subgraphs = {};
2160 var edges = {};
2161 var graph;
2162 for (var _i = 0, scopes_1 = scopes; _i < scopes_1.length; _i++) {
2163 var scope = scopes_1[_i];
2164 switch (scope.ScopeType) {
2165 case "graph":
2166 graph = new ScopeGraph(function (item) { return item._.Id; }, scope);
2167 subgraphs[scope.ScopeName] = graph.root;
2168 break;
2169 case "subgraph":
2170 if (!graph) {
2171 graph = new ScopeGraph(function (item) { return item._.Id; }, scope);
2172 subgraphs[scope.ScopeName] = graph.root;
2173 }
2174 var scopeStack = scope.parentScope().split(":");
2175 var scopeParent1 = subgraphs[scope.parentScope()];
2176 while (scopeStack.length && !scopeParent1) {
2177 scopeParent1 = subgraphs[scopeStack.join(":")];
2178 scopeStack.pop();
2179 }
2180 if (!scopeParent1) {
2181 console.log("Missing SG:Parent (" + scope.Id + "): " + scope.parentScope());
2182 }
2183 else {
2184 var parent1 = scopeParent1;
2185 subgraphs[scope.ScopeName] = parent1.createSubgraph(scope);
2186 }
2187 break;
2188 case "activity":
2189 var scopeParent2 = subgraphs[scope.parentScope()];
2190 if (!scopeParent2) {
2191 console.log("Missing A:Parent (" + scope.Id + "): " + scope.parentScope());
2192 }
2193 else {
2194 scopeParent2.createVertex(scope);
2195 }
2196 break;
2197 case "edge":
2198 edges[scope.ScopeName] = scope;
2199 break;
2200 }
2201 }
2202 for (var id in edges) {
2203 var scope = edges[id];
2204 var scopeParent3 = subgraphs[scope.parentScope()];
2205 if (!scopeParent3) {
2206 console.log("Missing E:Parent (" + scope.Id + "): " + scope.parentScope());
2207 }
2208 else {
2209 var parent3 = scopeParent3;
2210 try {
2211 var source = graph.vertex(scope.attr("IdSource").RawValue);
2212 var target = graph.vertex(scope.attr("IdTarget").RawValue);
2213 parent3.createEdge(source, target, scope);
2214 }
2215 catch (e) {
2216 // const sourceIndex = scope.attr("SourceIndex").RawValue;
2217 // const targetIndex = scope.attr("TargetIndex").RawValue;
2218 console.log("Invalid Edge: " + id);
2219 }
2220 }
2221 }
2222 return graph;
2223}
2224
2225var Resource = /** @class */ (function (_super) {
2226 __extends(Resource, _super);
2227 function Resource(wu, url) {
2228 var _this = _super.call(this) || this;
2229 _this.wu = wu;
2230 var cleanedURL = url.split("\\").join("/");
2231 var urlParts = cleanedURL.split("/");
2232 var matchStr = "res/" + _this.wu.Wuid + "/";
2233 var displayPath = "";
2234 var displayName = "";
2235 if (cleanedURL.indexOf(matchStr) === 0) {
2236 displayPath = cleanedURL.substr(matchStr.length);
2237 displayName = urlParts[urlParts.length - 1];
2238 }
2239 _this.set({
2240 URL: url,
2241 DisplayName: displayName,
2242 DisplayPath: displayPath
2243 });
2244 return _this;
2245 }
2246 Object.defineProperty(Resource.prototype, "properties", {
2247 get: function () { return this.get(); },
2248 enumerable: false,
2249 configurable: true
2250 });
2251 Object.defineProperty(Resource.prototype, "URL", {
2252 get: function () { return this.get("URL"); },
2253 enumerable: false,
2254 configurable: true
2255 });
2256 Object.defineProperty(Resource.prototype, "DisplayName", {
2257 get: function () { return this.get("DisplayName"); },
2258 enumerable: false,
2259 configurable: true
2260 });
2261 Object.defineProperty(Resource.prototype, "DisplayPath", {
2262 get: function () { return this.get("DisplayPath"); },
2263 enumerable: false,
2264 configurable: true
2265 });
2266 return Resource;
2267}(util.StateObject));
2268
2269var XSDNode = /** @class */ (function () {
2270 function XSDNode(e) {
2271 this.e = e;
2272 }
2273 XSDNode.prototype.fix = function () {
2274 delete this.e;
2275 };
2276 return XSDNode;
2277}());
2278var XSDXMLNode = /** @class */ (function (_super) {
2279 __extends(XSDXMLNode, _super);
2280 function XSDXMLNode(e) {
2281 var _this = _super.call(this, e) || this;
2282 _this.attrs = {};
2283 _this._children = [];
2284 return _this;
2285 }
2286 XSDXMLNode.prototype.append = function (child) {
2287 this._children.push(child);
2288 if (!this.type) {
2289 this.type = "hpcc:childDataset";
2290 }
2291 };
2292 XSDXMLNode.prototype.fix = function () {
2293 var _a;
2294 this.name = this.e.$["name"];
2295 this.type = this.e.$["type"];
2296 for (var i = this._children.length - 1; i >= 0; --i) {
2297 var row = this._children[i];
2298 if (row.name === "Row" && row.type === undefined) {
2299 (_a = this._children).push.apply(_a, row._children);
2300 this._children.splice(i, 1);
2301 }
2302 }
2303 _super.prototype.fix.call(this);
2304 };
2305 XSDXMLNode.prototype.children = function () {
2306 return this._children;
2307 };
2308 XSDXMLNode.prototype.charWidth = function () {
2309 var retVal = -1;
2310 switch (this.type) {
2311 case "xs:boolean":
2312 retVal = 5;
2313 break;
2314 case "xs:integer":
2315 retVal = 8;
2316 break;
2317 case "xs:nonNegativeInteger":
2318 retVal = 8;
2319 break;
2320 case "xs:double":
2321 retVal = 8;
2322 break;
2323 case "xs:string":
2324 retVal = 32;
2325 break;
2326 default:
2327 var numStr = "0123456789";
2328 var underbarPos = this.type.lastIndexOf("_");
2329 var length_1 = underbarPos > 0 ? underbarPos : this.type.length;
2330 var i = length_1 - 1;
2331 for (; i >= 0; --i) {
2332 if (numStr.indexOf(this.type.charAt(i)) === -1)
2333 break;
2334 }
2335 if (i + 1 < length_1) {
2336 retVal = parseInt(this.type.substring(i + 1, length_1), 10);
2337 }
2338 if (this.type.indexOf("data") === 0) {
2339 retVal *= 2;
2340 }
2341 break;
2342 }
2343 if (retVal < this.name.length)
2344 retVal = this.name.length;
2345 return retVal;
2346 };
2347 return XSDXMLNode;
2348}(XSDNode));
2349var XSDSimpleType = /** @class */ (function (_super) {
2350 __extends(XSDSimpleType, _super);
2351 function XSDSimpleType(e) {
2352 return _super.call(this, e) || this;
2353 }
2354 XSDSimpleType.prototype.append = function (e) {
2355 switch (e.name) {
2356 case "xs:restriction":
2357 this._restricition = e;
2358 break;
2359 case "xs:maxLength":
2360 this._maxLength = e;
2361 break;
2362 default:
2363 }
2364 };
2365 XSDSimpleType.prototype.fix = function () {
2366 this.name = this.e.$["name"];
2367 this.type = this._restricition.$["base"];
2368 this.maxLength = this._maxLength ? +this._maxLength.$["value"] : undefined;
2369 delete this._restricition;
2370 delete this._maxLength;
2371 _super.prototype.fix.call(this);
2372 };
2373 return XSDSimpleType;
2374}(XSDNode));
2375var XSDSchema = /** @class */ (function () {
2376 function XSDSchema() {
2377 this.simpleTypes = {};
2378 }
2379 XSDSchema.prototype.fields = function () {
2380 return this.root.children();
2381 };
2382 return XSDSchema;
2383}());
2384var XSDParser = /** @class */ (function (_super) {
2385 __extends(XSDParser, _super);
2386 function XSDParser() {
2387 var _this = _super !== null && _super.apply(this, arguments) || this;
2388 _this.schema = new XSDSchema();
2389 _this.simpleTypes = {};
2390 _this.xsdStack = new util.Stack();
2391 return _this;
2392 }
2393 XSDParser.prototype.startXMLNode = function (e) {
2394 _super.prototype.startXMLNode.call(this, e);
2395 switch (e.name) {
2396 case "xs:element":
2397 var xsdXMLNode = new XSDXMLNode(e);
2398 if (!this.schema.root) {
2399 this.schema.root = xsdXMLNode;
2400 }
2401 else if (this.xsdStack.depth()) {
2402 this.xsdStack.top().append(xsdXMLNode);
2403 }
2404 this.xsdStack.push(xsdXMLNode);
2405 break;
2406 case "xs:simpleType":
2407 this.simpleType = new XSDSimpleType(e);
2408 break;
2409 default:
2410 break;
2411 }
2412 };
2413 XSDParser.prototype.endXMLNode = function (e) {
2414 switch (e.name) {
2415 case "xs:element":
2416 var xsdXMLNode = this.xsdStack.pop();
2417 xsdXMLNode.fix();
2418 break;
2419 case "xs:simpleType":
2420 this.simpleType.fix();
2421 this.simpleTypes[this.simpleType.name] = this.simpleType;
2422 delete this.simpleType;
2423 break;
2424 case "xs:appinfo":
2425 var xsdXMLNode2 = this.xsdStack.top();
2426 for (var key in e.$) {
2427 xsdXMLNode2.attrs[key] = e.$[key];
2428 }
2429 break;
2430 default:
2431 if (this.simpleType) {
2432 this.simpleType.append(e);
2433 }
2434 }
2435 _super.prototype.endXMLNode.call(this, e);
2436 };
2437 return XSDParser;
2438}(util.SAXStackParser));
2439function parseXSD(xml) {
2440 var saxParser = new XSDParser();
2441 saxParser.parse(xml);
2442 return saxParser.schema;
2443}
2444var XSDParser2 = /** @class */ (function (_super) {
2445 __extends(XSDParser2, _super);
2446 function XSDParser2(rootName) {
2447 var _this = _super.call(this) || this;
2448 _this.schema = new XSDSchema();
2449 _this.simpleTypes = {};
2450 _this.xsdStack = new util.Stack();
2451 _this._rootName = rootName;
2452 return _this;
2453 }
2454 XSDParser2.prototype.startXMLNode = function (e) {
2455 _super.prototype.startXMLNode.call(this, e);
2456 switch (e.name) {
2457 case "xsd:element":
2458 var xsdXMLNode = new XSDXMLNode(e);
2459 if (!this.schema.root && this._rootName === e.$.name) {
2460 this.schema.root = xsdXMLNode;
2461 }
2462 if (this.xsdStack.depth()) {
2463 this.xsdStack.top().append(xsdXMLNode);
2464 }
2465 this.xsdStack.push(xsdXMLNode);
2466 break;
2467 case "xsd:simpleType":
2468 this.simpleType = new XSDSimpleType(e);
2469 break;
2470 default:
2471 break;
2472 }
2473 };
2474 XSDParser2.prototype.endXMLNode = function (e) {
2475 switch (e.name) {
2476 case "xsd:element":
2477 var xsdXMLNode = this.xsdStack.pop();
2478 xsdXMLNode.fix();
2479 break;
2480 case "xsd:simpleType":
2481 break;
2482 default:
2483 break;
2484 }
2485 _super.prototype.endXMLNode.call(this, e);
2486 };
2487 return XSDParser2;
2488}(XSDParser));
2489function parseXSD2(xml, rootName) {
2490 var saxParser = new XSDParser2(rootName);
2491 saxParser.parse(xml);
2492 return saxParser.schema;
2493}
2494
2495var GlobalResultCache = /** @class */ (function (_super) {
2496 __extends(GlobalResultCache, _super);
2497 function GlobalResultCache() {
2498 return _super.call(this, function (obj) {
2499 return obj.BaseUrl + "-" + obj.Wuid + "-" + obj.ResultName;
2500 }) || this;
2501 }
2502 return GlobalResultCache;
2503}(util.Cache));
2504var _results = new GlobalResultCache();
2505var Result = /** @class */ (function (_super) {
2506 __extends(Result, _super);
2507 function Result(optsConnection, wuidOrLogicalFile, eclResultOrResultName, resultViews) {
2508 if (resultViews === void 0) { resultViews = []; }
2509 var _this = _super.call(this) || this;
2510 if (optsConnection instanceof WorkunitsService) {
2511 _this.connection = optsConnection;
2512 }
2513 else {
2514 _this.connection = new WorkunitsService(optsConnection);
2515 }
2516 if (typeof eclResultOrResultName === "undefined") {
2517 _this.set({
2518 LogicalFileName: wuidOrLogicalFile
2519 });
2520 }
2521 else if (typeof eclResultOrResultName === "string") {
2522 _this.set({
2523 Wuid: wuidOrLogicalFile,
2524 ResultName: eclResultOrResultName,
2525 ResultViews: resultViews
2526 });
2527 }
2528 else if (typeof eclResultOrResultName === "number") {
2529 _this.set({
2530 Wuid: wuidOrLogicalFile,
2531 ResultSequence: eclResultOrResultName,
2532 ResultViews: resultViews
2533 });
2534 }
2535 else {
2536 _this.set(__assign({ Wuid: wuidOrLogicalFile, ResultName: eclResultOrResultName.Name, ResultViews: resultViews }, eclResultOrResultName));
2537 }
2538 return _this;
2539 }
2540 Object.defineProperty(Result.prototype, "BaseUrl", {
2541 get: function () { return this.connection.baseUrl; },
2542 enumerable: false,
2543 configurable: true
2544 });
2545 Object.defineProperty(Result.prototype, "properties", {
2546 get: function () { return this.get(); },
2547 enumerable: false,
2548 configurable: true
2549 });
2550 Object.defineProperty(Result.prototype, "Wuid", {
2551 get: function () { return this.get("Wuid"); },
2552 enumerable: false,
2553 configurable: true
2554 });
2555 Object.defineProperty(Result.prototype, "ResultName", {
2556 get: function () { return this.get("ResultName"); },
2557 enumerable: false,
2558 configurable: true
2559 });
2560 Object.defineProperty(Result.prototype, "ResultSequence", {
2561 get: function () { return this.get("ResultSequence"); },
2562 enumerable: false,
2563 configurable: true
2564 });
2565 Object.defineProperty(Result.prototype, "LogicalFileName", {
2566 get: function () { return this.get("LogicalFileName"); },
2567 enumerable: false,
2568 configurable: true
2569 });
2570 Object.defineProperty(Result.prototype, "Name", {
2571 get: function () { return this.get("Name"); },
2572 enumerable: false,
2573 configurable: true
2574 });
2575 Object.defineProperty(Result.prototype, "Sequence", {
2576 get: function () { return this.get("Sequence"); },
2577 enumerable: false,
2578 configurable: true
2579 });
2580 Object.defineProperty(Result.prototype, "Value", {
2581 get: function () { return this.get("Value"); },
2582 enumerable: false,
2583 configurable: true
2584 });
2585 Object.defineProperty(Result.prototype, "Link", {
2586 get: function () { return this.get("Link"); },
2587 enumerable: false,
2588 configurable: true
2589 });
2590 Object.defineProperty(Result.prototype, "FileName", {
2591 get: function () { return this.get("FileName"); },
2592 enumerable: false,
2593 configurable: true
2594 });
2595 Object.defineProperty(Result.prototype, "IsSupplied", {
2596 get: function () { return this.get("IsSupplied"); },
2597 enumerable: false,
2598 configurable: true
2599 });
2600 Object.defineProperty(Result.prototype, "ShowFileContent", {
2601 get: function () { return this.get("ShowFileContent"); },
2602 enumerable: false,
2603 configurable: true
2604 });
2605 Object.defineProperty(Result.prototype, "Total", {
2606 get: function () { return this.get("Total"); },
2607 enumerable: false,
2608 configurable: true
2609 });
2610 Object.defineProperty(Result.prototype, "ECLSchemas", {
2611 get: function () { return this.get("ECLSchemas"); },
2612 enumerable: false,
2613 configurable: true
2614 });
2615 Object.defineProperty(Result.prototype, "NodeGroup", {
2616 get: function () { return this.get("NodeGroup"); },
2617 enumerable: false,
2618 configurable: true
2619 });
2620 Object.defineProperty(Result.prototype, "ResultViews", {
2621 get: function () { return this.get("ResultViews"); },
2622 enumerable: false,
2623 configurable: true
2624 });
2625 Object.defineProperty(Result.prototype, "XmlSchema", {
2626 get: function () { return this.get("XmlSchema"); },
2627 enumerable: false,
2628 configurable: true
2629 });
2630 Result.attach = function (optsConnection, wuid, resultName, state) {
2631 var retVal = _results.get({ BaseUrl: optsConnection.baseUrl, Wuid: wuid, ResultName: resultName }, function () {
2632 return new Result(optsConnection, wuid, resultName);
2633 });
2634 if (state) {
2635 retVal.set(state);
2636 }
2637 return retVal;
2638 };
2639 Result.prototype.isComplete = function () {
2640 return this.Total !== -1;
2641 };
2642 Result.prototype.fetchXMLSchema = function () {
2643 var _this = this;
2644 if (this.xsdSchema) {
2645 return Promise.resolve(this.xsdSchema);
2646 }
2647 return this.WUResult().then(function (response) {
2648 if (util.exists("Result.XmlSchema.xml", response)) {
2649 _this.xsdSchema = parseXSD(response.Result.XmlSchema.xml);
2650 return _this.xsdSchema;
2651 }
2652 return null;
2653 });
2654 };
2655 Result.prototype.refresh = function () {
2656 return __awaiter(this, void 0, void 0, function () {
2657 return __generator(this, function (_a) {
2658 switch (_a.label) {
2659 case 0: return [4 /*yield*/, this.fetchRows(0, 1, true)];
2660 case 1:
2661 _a.sent();
2662 return [2 /*return*/, this];
2663 }
2664 });
2665 });
2666 };
2667 Result.prototype.fetchRows = function (from, count, includeSchema, filter) {
2668 var _this = this;
2669 if (from === void 0) { from = 0; }
2670 if (count === void 0) { count = -1; }
2671 if (includeSchema === void 0) { includeSchema = false; }
2672 if (filter === void 0) { filter = {}; }
2673 return this.WUResult(from, count, !includeSchema, filter).then(function (response) {
2674 var result = response.Result;
2675 delete response.Result; // Do not want it in "set"
2676 _this.set(__assign({}, response));
2677 if (util.exists("XmlSchema.xml", result)) {
2678 _this.xsdSchema = parseXSD(result.XmlSchema.xml);
2679 }
2680 if (util.exists("Row", result)) {
2681 return result.Row;
2682 }
2683 else if (_this.ResultName && util.exists(_this.ResultName, result)) {
2684 return result[_this.ResultName].Row;
2685 }
2686 return [];
2687 });
2688 };
2689 Result.prototype.rootField = function () {
2690 if (!this.xsdSchema)
2691 return null;
2692 return this.xsdSchema.root;
2693 };
2694 Result.prototype.fields = function () {
2695 if (!this.xsdSchema)
2696 return [];
2697 return this.xsdSchema.root.children();
2698 };
2699 Result.prototype.WUResult = function (start, count, suppressXmlSchema, filter) {
2700 if (start === void 0) { start = 0; }
2701 if (count === void 0) { count = 1; }
2702 if (suppressXmlSchema === void 0) { suppressXmlSchema = false; }
2703 if (filter === void 0) { filter = {}; }
2704 var FilterBy = {
2705 NamedValue: {
2706 itemcount: 0
2707 }
2708 };
2709 for (var key in filter) {
2710 FilterBy.NamedValue[FilterBy.NamedValue.itemcount++] = {
2711 Name: key,
2712 Value: filter[key]
2713 };
2714 }
2715 var request = { FilterBy: FilterBy };
2716 if (this.Wuid && this.ResultName !== undefined) {
2717 request.Wuid = this.Wuid;
2718 request.ResultName = this.ResultName;
2719 }
2720 else if (this.Wuid && this.ResultSequence !== undefined) {
2721 request.Wuid = this.Wuid;
2722 request.Sequence = this.ResultSequence;
2723 }
2724 else if (this.LogicalFileName && this.NodeGroup) {
2725 request.LogicalName = this.LogicalFileName;
2726 request.Cluster = this.NodeGroup;
2727 }
2728 else if (this.LogicalFileName) {
2729 request.LogicalName = this.LogicalFileName;
2730 }
2731 request.Start = start;
2732 request.Count = count;
2733 request.SuppressXmlSchema = suppressXmlSchema;
2734 return this.connection.WUResult(request).then(function (response) {
2735 return response;
2736 });
2737 };
2738 return Result;
2739}(util.StateObject));
2740var ResultCache = /** @class */ (function (_super) {
2741 __extends(ResultCache, _super);
2742 function ResultCache() {
2743 return _super.call(this, function (obj) {
2744 return util.Cache.hash([obj.Sequence, obj.Name, obj.FileName]);
2745 }) || this;
2746 }
2747 return ResultCache;
2748}(util.Cache));
2749
2750var Attribute = /** @class */ (function (_super) {
2751 __extends(Attribute, _super);
2752 function Attribute(scope, attribute) {
2753 var _this = _super.call(this) || this;
2754 _this.scope = scope;
2755 _this.set(attribute);
2756 return _this;
2757 }
2758 Object.defineProperty(Attribute.prototype, "properties", {
2759 get: function () { return this.get(); },
2760 enumerable: false,
2761 configurable: true
2762 });
2763 Object.defineProperty(Attribute.prototype, "Name", {
2764 get: function () { return this.get("Name"); },
2765 enumerable: false,
2766 configurable: true
2767 });
2768 Object.defineProperty(Attribute.prototype, "RawValue", {
2769 get: function () { return this.get("RawValue"); },
2770 enumerable: false,
2771 configurable: true
2772 });
2773 Object.defineProperty(Attribute.prototype, "Formatted", {
2774 get: function () { return this.get("Formatted"); },
2775 enumerable: false,
2776 configurable: true
2777 });
2778 Object.defineProperty(Attribute.prototype, "FormattedEnd", {
2779 get: function () { return this.get("FormattedEnd"); },
2780 enumerable: false,
2781 configurable: true
2782 });
2783 Object.defineProperty(Attribute.prototype, "Measure", {
2784 get: function () { return this.get("Measure"); },
2785 enumerable: false,
2786 configurable: true
2787 });
2788 Object.defineProperty(Attribute.prototype, "Creator", {
2789 get: function () { return this.get("Creator"); },
2790 enumerable: false,
2791 configurable: true
2792 });
2793 Object.defineProperty(Attribute.prototype, "CreatorType", {
2794 get: function () { return this.get("CreatorType"); },
2795 enumerable: false,
2796 configurable: true
2797 });
2798 return Attribute;
2799}(util.StateObject));
2800var BaseScope = /** @class */ (function (_super) {
2801 __extends(BaseScope, _super);
2802 function BaseScope(scope) {
2803 var _this = _super.call(this) || this;
2804 _this._attributeMap = {};
2805 _this._children = [];
2806 _this.update(scope);
2807 return _this;
2808 }
2809 Object.defineProperty(BaseScope.prototype, "properties", {
2810 get: function () { return this.get(); },
2811 enumerable: false,
2812 configurable: true
2813 });
2814 Object.defineProperty(BaseScope.prototype, "ScopeName", {
2815 get: function () { return this.get("ScopeName"); },
2816 enumerable: false,
2817 configurable: true
2818 });
2819 Object.defineProperty(BaseScope.prototype, "Id", {
2820 get: function () { return this.get("Id"); },
2821 enumerable: false,
2822 configurable: true
2823 });
2824 Object.defineProperty(BaseScope.prototype, "ScopeType", {
2825 get: function () { return this.get("ScopeType"); },
2826 enumerable: false,
2827 configurable: true
2828 });
2829 Object.defineProperty(BaseScope.prototype, "Properties", {
2830 get: function () { return this.get("Properties", { Property: [] }); },
2831 enumerable: false,
2832 configurable: true
2833 });
2834 Object.defineProperty(BaseScope.prototype, "CAttributes", {
2835 get: function () {
2836 var _this = this;
2837 // Match "started" and time elapsed
2838 var retVal = [];
2839 var timeElapsed = {
2840 start: null,
2841 end: null
2842 };
2843 this.Properties.Property.forEach(function (scopeAttr) {
2844 if (scopeAttr.Measure === "ts" && scopeAttr.Name.indexOf("Started") >= 0) {
2845 timeElapsed.start = scopeAttr;
2846 }
2847 else if (_this.ScopeName && scopeAttr.Measure === "ts" && scopeAttr.Name.indexOf("Finished") >= 0) {
2848 timeElapsed.end = scopeAttr;
2849 }
2850 else {
2851 retVal.push(new Attribute(_this, scopeAttr));
2852 }
2853 });
2854 if (timeElapsed.start && timeElapsed.end) {
2855 // const endTime = parser(timeElapsed.start.Formatted);
2856 // endTime!.setMilliseconds(endTime!.getMilliseconds() + (+timeElapsed.elapsed.RawValue) / 1000000);
2857 // timeElapsed.start.FormattedEnd = formatter(endTime!);
2858 timeElapsed.start.FormattedEnd = timeElapsed.end.Formatted;
2859 retVal.push(new Attribute(this, timeElapsed.start));
2860 }
2861 else if (timeElapsed.start) {
2862 retVal.push(new Attribute(this, timeElapsed.start));
2863 }
2864 else if (timeElapsed.end) {
2865 retVal.push(new Attribute(this, timeElapsed.end)); // Should not happen?
2866 }
2867 return retVal;
2868 },
2869 enumerable: false,
2870 configurable: true
2871 });
2872 BaseScope.prototype.update = function (scope) {
2873 var _this = this;
2874 this.set(scope);
2875 this.CAttributes.forEach(function (attr) {
2876 _this._attributeMap[attr.Name] = attr;
2877 });
2878 this.Properties.Property = [];
2879 for (var key in this._attributeMap) {
2880 if (this._attributeMap.hasOwnProperty(key)) {
2881 this.Properties.Property.push(this._attributeMap[key].properties);
2882 }
2883 }
2884 };
2885 BaseScope.prototype.parentScope = function () {
2886 var scopeParts = this.ScopeName.split(":");
2887 scopeParts.pop();
2888 return scopeParts.join(":");
2889 };
2890 BaseScope.prototype.children = function (_) {
2891 if (!arguments.length)
2892 return this._children;
2893 this._children = _;
2894 return this;
2895 };
2896 BaseScope.prototype.walk = function (visitor) {
2897 if (visitor.start(this))
2898 return true;
2899 for (var _i = 0, _a = this.children(); _i < _a.length; _i++) {
2900 var scope = _a[_i];
2901 if (scope.walk(visitor)) {
2902 return true;
2903 }
2904 }
2905 return visitor.end(this);
2906 };
2907 BaseScope.prototype.formattedAttrs = function () {
2908 var retVal = {};
2909 for (var attr in this._attributeMap) {
2910 retVal[attr] = this._attributeMap[attr].Formatted || this._attributeMap[attr].RawValue;
2911 }
2912 return retVal;
2913 };
2914 BaseScope.prototype.rawAttrs = function () {
2915 var retVal = {};
2916 for (var attr in this._attributeMap) {
2917 retVal[attr] = this._attributeMap[attr].RawValue;
2918 }
2919 return retVal;
2920 };
2921 BaseScope.prototype.hasAttr = function (name) {
2922 return this._attributeMap[name] !== undefined;
2923 };
2924 BaseScope.prototype.attr = function (name) {
2925 return this._attributeMap[name] || new Attribute(this, {
2926 Creator: "",
2927 CreatorType: "",
2928 Formatted: "",
2929 Measure: "",
2930 Name: "",
2931 RawValue: ""
2932 });
2933 };
2934 BaseScope.prototype.attrMeasure = function (name) {
2935 return this._attributeMap[name].Measure;
2936 };
2937 BaseScope.prototype.calcTooltip = function (parentScope) {
2938 var label = "";
2939 var rows = [];
2940 label = this.Id;
2941 rows.push("<tr><td class=\"key\">ID:</td><td class=\"value\">" + this.Id + "</td></tr>");
2942 if (parentScope) {
2943 rows.push("<tr><td class=\"key\">Parent ID:</td><td class=\"value\">" + parentScope.Id + "</td></tr>");
2944 }
2945 rows.push("<tr><td class=\"key\">Scope:</td><td class=\"value\">" + this.ScopeName + "</td></tr>");
2946 var attrs = this.formattedAttrs();
2947 for (var key in attrs) {
2948 if (key === "Label") {
2949 label = attrs[key];
2950 }
2951 else {
2952 rows.push("<tr><td class=\"key\">" + key + "</td><td class=\"value\">" + attrs[key] + "</td></tr>");
2953 }
2954 }
2955 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>";
2956 };
2957 return BaseScope;
2958}(util.StateObject));
2959var Scope = /** @class */ (function (_super) {
2960 __extends(Scope, _super);
2961 function Scope(wu, scope) {
2962 var _this = _super.call(this, scope) || this;
2963 _this.wu = wu;
2964 return _this;
2965 }
2966 return Scope;
2967}(BaseScope));
2968
2969var SourceFile = /** @class */ (function (_super) {
2970 __extends(SourceFile, _super);
2971 function SourceFile(optsConnection, wuid, eclSourceFile) {
2972 var _this = _super.call(this) || this;
2973 if (optsConnection instanceof WorkunitsService) {
2974 _this.connection = optsConnection;
2975 }
2976 else {
2977 _this.connection = new WorkunitsService(optsConnection);
2978 }
2979 _this.set(__assign({ Wuid: wuid }, eclSourceFile));
2980 return _this;
2981 }
2982 Object.defineProperty(SourceFile.prototype, "properties", {
2983 get: function () { return this.get(); },
2984 enumerable: false,
2985 configurable: true
2986 });
2987 Object.defineProperty(SourceFile.prototype, "Wuid", {
2988 get: function () { return this.get("Wuid"); },
2989 enumerable: false,
2990 configurable: true
2991 });
2992 Object.defineProperty(SourceFile.prototype, "FileCluster", {
2993 get: function () { return this.get("FileCluster"); },
2994 enumerable: false,
2995 configurable: true
2996 });
2997 Object.defineProperty(SourceFile.prototype, "Name", {
2998 get: function () { return this.get("Name"); },
2999 enumerable: false,
3000 configurable: true
3001 });
3002 Object.defineProperty(SourceFile.prototype, "IsSuperFile", {
3003 get: function () { return this.get("IsSuperFile"); },
3004 enumerable: false,
3005 configurable: true
3006 });
3007 Object.defineProperty(SourceFile.prototype, "Subs", {
3008 get: function () { return this.get("Subs"); },
3009 enumerable: false,
3010 configurable: true
3011 });
3012 Object.defineProperty(SourceFile.prototype, "Count", {
3013 get: function () { return this.get("Count"); },
3014 enumerable: false,
3015 configurable: true
3016 });
3017 Object.defineProperty(SourceFile.prototype, "ECLSourceFiles", {
3018 get: function () { return this.get("ECLSourceFiles"); },
3019 enumerable: false,
3020 configurable: true
3021 });
3022 return SourceFile;
3023}(util.StateObject));
3024
3025var Timer = /** @class */ (function (_super) {
3026 __extends(Timer, _super);
3027 function Timer(optsConnection, wuid, eclTimer) {
3028 var _this = _super.call(this) || this;
3029 if (optsConnection instanceof WorkunitsService) {
3030 _this.connection = optsConnection;
3031 }
3032 else {
3033 _this.connection = new WorkunitsService(optsConnection);
3034 }
3035 var secs = util.espTime2Seconds(eclTimer.Value);
3036 _this.set(__assign({ Wuid: wuid, Seconds: Math.round(secs * 1000) / 1000, HasSubGraphId: eclTimer.SubGraphId !== undefined }, eclTimer));
3037 return _this;
3038 }
3039 Object.defineProperty(Timer.prototype, "properties", {
3040 get: function () { return this.get(); },
3041 enumerable: false,
3042 configurable: true
3043 });
3044 Object.defineProperty(Timer.prototype, "Wuid", {
3045 get: function () { return this.get("Wuid"); },
3046 enumerable: false,
3047 configurable: true
3048 });
3049 Object.defineProperty(Timer.prototype, "Name", {
3050 get: function () { return this.get("Name"); },
3051 enumerable: false,
3052 configurable: true
3053 });
3054 Object.defineProperty(Timer.prototype, "Value", {
3055 get: function () { return this.get("Value"); },
3056 enumerable: false,
3057 configurable: true
3058 });
3059 Object.defineProperty(Timer.prototype, "Seconds", {
3060 get: function () { return this.get("Seconds"); },
3061 enumerable: false,
3062 configurable: true
3063 });
3064 Object.defineProperty(Timer.prototype, "GraphName", {
3065 get: function () { return this.get("GraphName"); },
3066 enumerable: false,
3067 configurable: true
3068 });
3069 Object.defineProperty(Timer.prototype, "SubGraphId", {
3070 get: function () { return this.get("SubGraphId"); },
3071 enumerable: false,
3072 configurable: true
3073 });
3074 Object.defineProperty(Timer.prototype, "HasSubGraphId", {
3075 get: function () { return this.get("HasSubGraphId"); },
3076 enumerable: false,
3077 configurable: true
3078 });
3079 Object.defineProperty(Timer.prototype, "count", {
3080 get: function () { return this.get("count"); },
3081 enumerable: false,
3082 configurable: true
3083 });
3084 return Timer;
3085}(util.StateObject));
3086
3087var formatter = utcFormat("%Y-%m-%dT%H:%M:%S.%LZ");
3088var parser = utcParse("%Y-%m-%dT%H:%M:%S.%LZ");
3089var logger$1 = util.scopedLogger("workunit.ts");
3090var WUStateID = exports.WUStateID;
3091var WorkunitCache = /** @class */ (function (_super) {
3092 __extends(WorkunitCache, _super);
3093 function WorkunitCache() {
3094 return _super.call(this, function (obj) {
3095 return obj.BaseUrl + "-" + obj.Wuid;
3096 }) || this;
3097 }
3098 return WorkunitCache;
3099}(util.Cache));
3100var _workunits = new WorkunitCache();
3101var Workunit = /** @class */ (function (_super) {
3102 __extends(Workunit, _super);
3103 // --- --- ---
3104 function Workunit(optsConnection, wuid) {
3105 var _this = _super.call(this) || this;
3106 _this._debugMode = false;
3107 _this._resultCache = new ResultCache();
3108 _this._graphCache = new GraphCache();
3109 _this.connection = new WorkunitsService(optsConnection);
3110 _this.topologyConnection = new TopologyService(optsConnection);
3111 _this.clearState(wuid);
3112 return _this;
3113 }
3114 Object.defineProperty(Workunit.prototype, "BaseUrl", {
3115 get: function () { return this.connection.baseUrl; },
3116 enumerable: false,
3117 configurable: true
3118 });
3119 Object.defineProperty(Workunit.prototype, "properties", {
3120 // Accessors ---
3121 get: function () { return this.get(); },
3122 enumerable: false,
3123 configurable: true
3124 });
3125 Object.defineProperty(Workunit.prototype, "Wuid", {
3126 get: function () { return this.get("Wuid"); },
3127 enumerable: false,
3128 configurable: true
3129 });
3130 Object.defineProperty(Workunit.prototype, "Owner", {
3131 get: function () { return this.get("Owner", ""); },
3132 enumerable: false,
3133 configurable: true
3134 });
3135 Object.defineProperty(Workunit.prototype, "Cluster", {
3136 get: function () { return this.get("Cluster", ""); },
3137 enumerable: false,
3138 configurable: true
3139 });
3140 Object.defineProperty(Workunit.prototype, "Jobname", {
3141 get: function () { return this.get("Jobname", ""); },
3142 enumerable: false,
3143 configurable: true
3144 });
3145 Object.defineProperty(Workunit.prototype, "Description", {
3146 get: function () { return this.get("Description", ""); },
3147 enumerable: false,
3148 configurable: true
3149 });
3150 Object.defineProperty(Workunit.prototype, "ActionEx", {
3151 get: function () { return this.get("ActionEx", ""); },
3152 enumerable: false,
3153 configurable: true
3154 });
3155 Object.defineProperty(Workunit.prototype, "StateID", {
3156 get: function () { return this.get("StateID", exports.WUStateID.Unknown); },
3157 enumerable: false,
3158 configurable: true
3159 });
3160 Object.defineProperty(Workunit.prototype, "State", {
3161 get: function () { return this.get("State") || exports.WUStateID[this.StateID]; },
3162 enumerable: false,
3163 configurable: true
3164 });
3165 Object.defineProperty(Workunit.prototype, "Protected", {
3166 get: function () { return this.get("Protected", false); },
3167 enumerable: false,
3168 configurable: true
3169 });
3170 Object.defineProperty(Workunit.prototype, "Exceptions", {
3171 get: function () { return this.get("Exceptions", { ECLException: [] }); },
3172 enumerable: false,
3173 configurable: true
3174 });
3175 Object.defineProperty(Workunit.prototype, "ResultViews", {
3176 get: function () { return this.get("ResultViews", []); },
3177 enumerable: false,
3178 configurable: true
3179 });
3180 Object.defineProperty(Workunit.prototype, "ResultCount", {
3181 get: function () { return this.get("ResultCount", 0); },
3182 enumerable: false,
3183 configurable: true
3184 });
3185 Object.defineProperty(Workunit.prototype, "Results", {
3186 get: function () { return this.get("Results", { ECLResult: [] }); },
3187 enumerable: false,
3188 configurable: true
3189 });
3190 Object.defineProperty(Workunit.prototype, "CResults", {
3191 get: function () {
3192 var _this = this;
3193 return this.Results.ECLResult.map(function (eclResult) {
3194 return _this._resultCache.get(eclResult, function () {
3195 return new Result(_this.connection, _this.Wuid, eclResult, _this.ResultViews);
3196 });
3197 });
3198 },
3199 enumerable: false,
3200 configurable: true
3201 });
3202 Object.defineProperty(Workunit.prototype, "SequenceResults", {
3203 get: function () {
3204 var retVal = {};
3205 this.CResults.forEach(function (result) {
3206 retVal[result.Sequence] = result;
3207 });
3208 return retVal;
3209 },
3210 enumerable: false,
3211 configurable: true
3212 });
3213 Object.defineProperty(Workunit.prototype, "Timers", {
3214 get: function () { return this.get("Timers", { ECLTimer: [] }); },
3215 enumerable: false,
3216 configurable: true
3217 });
3218 Object.defineProperty(Workunit.prototype, "CTimers", {
3219 get: function () {
3220 var _this = this;
3221 return this.Timers.ECLTimer.map(function (eclTimer) {
3222 return new Timer(_this.connection, _this.Wuid, eclTimer);
3223 });
3224 },
3225 enumerable: false,
3226 configurable: true
3227 });
3228 Object.defineProperty(Workunit.prototype, "GraphCount", {
3229 get: function () { return this.get("GraphCount", 0); },
3230 enumerable: false,
3231 configurable: true
3232 });
3233 Object.defineProperty(Workunit.prototype, "Graphs", {
3234 get: function () { return this.get("Graphs", { ECLGraph: [] }); },
3235 enumerable: false,
3236 configurable: true
3237 });
3238 Object.defineProperty(Workunit.prototype, "CGraphs", {
3239 get: function () {
3240 var _this = this;
3241 return this.Graphs.ECLGraph.map(function (eclGraph) {
3242 return _this._graphCache.get(eclGraph, function () {
3243 return new ECLGraph(_this, eclGraph, _this.CTimers);
3244 });
3245 });
3246 },
3247 enumerable: false,
3248 configurable: true
3249 });
3250 Object.defineProperty(Workunit.prototype, "ThorLogList", {
3251 get: function () { return this.get("ThorLogList"); },
3252 enumerable: false,
3253 configurable: true
3254 });
3255 Object.defineProperty(Workunit.prototype, "ResourceURLCount", {
3256 get: function () { return this.get("ResourceURLCount", 0); },
3257 enumerable: false,
3258 configurable: true
3259 });
3260 Object.defineProperty(Workunit.prototype, "ResourceURLs", {
3261 get: function () { return this.get("ResourceURLs", { URL: [] }); },
3262 enumerable: false,
3263 configurable: true
3264 });
3265 Object.defineProperty(Workunit.prototype, "CResourceURLs", {
3266 get: function () {
3267 var _this = this;
3268 return this.ResourceURLs.URL.map(function (url) {
3269 return new Resource(_this, url);
3270 });
3271 },
3272 enumerable: false,
3273 configurable: true
3274 });
3275 Object.defineProperty(Workunit.prototype, "TotalClusterTime", {
3276 get: function () { return this.get("TotalClusterTime", ""); },
3277 enumerable: false,
3278 configurable: true
3279 });
3280 Object.defineProperty(Workunit.prototype, "DateTimeScheduled", {
3281 get: function () { return this.get("DateTimeScheduled"); },
3282 enumerable: false,
3283 configurable: true
3284 });
3285 Object.defineProperty(Workunit.prototype, "IsPausing", {
3286 get: function () { return this.get("IsPausing"); },
3287 enumerable: false,
3288 configurable: true
3289 });
3290 Object.defineProperty(Workunit.prototype, "ThorLCR", {
3291 get: function () { return this.get("ThorLCR"); },
3292 enumerable: false,
3293 configurable: true
3294 });
3295 Object.defineProperty(Workunit.prototype, "ApplicationValues", {
3296 get: function () { return this.get("ApplicationValues", { ApplicationValue: [] }); },
3297 enumerable: false,
3298 configurable: true
3299 });
3300 Object.defineProperty(Workunit.prototype, "HasArchiveQuery", {
3301 get: function () { return this.get("HasArchiveQuery"); },
3302 enumerable: false,
3303 configurable: true
3304 });
3305 Object.defineProperty(Workunit.prototype, "StateEx", {
3306 get: function () { return this.get("StateEx"); },
3307 enumerable: false,
3308 configurable: true
3309 });
3310 Object.defineProperty(Workunit.prototype, "PriorityClass", {
3311 get: function () { return this.get("PriorityClass"); },
3312 enumerable: false,
3313 configurable: true
3314 });
3315 Object.defineProperty(Workunit.prototype, "PriorityLevel", {
3316 get: function () { return this.get("PriorityLevel"); },
3317 enumerable: false,
3318 configurable: true
3319 });
3320 Object.defineProperty(Workunit.prototype, "Snapshot", {
3321 get: function () { return this.get("Snapshot"); },
3322 enumerable: false,
3323 configurable: true
3324 });
3325 Object.defineProperty(Workunit.prototype, "ResultLimit", {
3326 get: function () { return this.get("ResultLimit"); },
3327 enumerable: false,
3328 configurable: true
3329 });
3330 Object.defineProperty(Workunit.prototype, "EventSchedule", {
3331 get: function () { return this.get("EventSchedule"); },
3332 enumerable: false,
3333 configurable: true
3334 });
3335 Object.defineProperty(Workunit.prototype, "HaveSubGraphTimings", {
3336 get: function () { return this.get("HaveSubGraphTimings"); },
3337 enumerable: false,
3338 configurable: true
3339 });
3340 Object.defineProperty(Workunit.prototype, "Query", {
3341 get: function () { return this.get("Query"); },
3342 enumerable: false,
3343 configurable: true
3344 });
3345 Object.defineProperty(Workunit.prototype, "HelpersCount", {
3346 get: function () { return this.get("HelpersCount", 0); },
3347 enumerable: false,
3348 configurable: true
3349 });
3350 Object.defineProperty(Workunit.prototype, "Helpers", {
3351 get: function () { return this.get("Helpers", { ECLHelpFile: [] }); },
3352 enumerable: false,
3353 configurable: true
3354 });
3355 Object.defineProperty(Workunit.prototype, "DebugValues", {
3356 get: function () { return this.get("DebugValues"); },
3357 enumerable: false,
3358 configurable: true
3359 });
3360 Object.defineProperty(Workunit.prototype, "AllowedClusters", {
3361 get: function () { return this.get("AllowedClusters"); },
3362 enumerable: false,
3363 configurable: true
3364 });
3365 Object.defineProperty(Workunit.prototype, "ErrorCount", {
3366 get: function () { return this.get("ErrorCount", 0); },
3367 enumerable: false,
3368 configurable: true
3369 });
3370 Object.defineProperty(Workunit.prototype, "WarningCount", {
3371 get: function () { return this.get("WarningCount", 0); },
3372 enumerable: false,
3373 configurable: true
3374 });
3375 Object.defineProperty(Workunit.prototype, "InfoCount", {
3376 get: function () { return this.get("InfoCount", 0); },
3377 enumerable: false,
3378 configurable: true
3379 });
3380 Object.defineProperty(Workunit.prototype, "AlertCount", {
3381 get: function () { return this.get("AlertCount", 0); },
3382 enumerable: false,
3383 configurable: true
3384 });
3385 Object.defineProperty(Workunit.prototype, "SourceFileCount", {
3386 get: function () { return this.get("SourceFileCount", 0); },
3387 enumerable: false,
3388 configurable: true
3389 });
3390 Object.defineProperty(Workunit.prototype, "SourceFiles", {
3391 get: function () { return this.get("SourceFiles", { ECLSourceFile: [] }); },
3392 enumerable: false,
3393 configurable: true
3394 });
3395 Object.defineProperty(Workunit.prototype, "CSourceFiles", {
3396 get: function () {
3397 var _this = this;
3398 return this.SourceFiles.ECLSourceFile.map(function (eclSourceFile) { return new SourceFile(_this.connection, _this.Wuid, eclSourceFile); });
3399 },
3400 enumerable: false,
3401 configurable: true
3402 });
3403 Object.defineProperty(Workunit.prototype, "VariableCount", {
3404 get: function () { return this.get("VariableCount", 0); },
3405 enumerable: false,
3406 configurable: true
3407 });
3408 Object.defineProperty(Workunit.prototype, "Variables", {
3409 get: function () { return this.get("Variables", { ECLResult: [] }); },
3410 enumerable: false,
3411 configurable: true
3412 });
3413 Object.defineProperty(Workunit.prototype, "TimerCount", {
3414 get: function () { return this.get("TimerCount", 0); },
3415 enumerable: false,
3416 configurable: true
3417 });
3418 Object.defineProperty(Workunit.prototype, "HasDebugValue", {
3419 get: function () { return this.get("HasDebugValue"); },
3420 enumerable: false,
3421 configurable: true
3422 });
3423 Object.defineProperty(Workunit.prototype, "ApplicationValueCount", {
3424 get: function () { return this.get("ApplicationValueCount", 0); },
3425 enumerable: false,
3426 configurable: true
3427 });
3428 Object.defineProperty(Workunit.prototype, "XmlParams", {
3429 get: function () { return this.get("XmlParams"); },
3430 enumerable: false,
3431 configurable: true
3432 });
3433 Object.defineProperty(Workunit.prototype, "AccessFlag", {
3434 get: function () { return this.get("AccessFlag"); },
3435 enumerable: false,
3436 configurable: true
3437 });
3438 Object.defineProperty(Workunit.prototype, "ClusterFlag", {
3439 get: function () { return this.get("ClusterFlag"); },
3440 enumerable: false,
3441 configurable: true
3442 });
3443 Object.defineProperty(Workunit.prototype, "ResultViewCount", {
3444 get: function () { return this.get("ResultViewCount", 0); },
3445 enumerable: false,
3446 configurable: true
3447 });
3448 Object.defineProperty(Workunit.prototype, "DebugValueCount", {
3449 get: function () { return this.get("DebugValueCount", 0); },
3450 enumerable: false,
3451 configurable: true
3452 });
3453 Object.defineProperty(Workunit.prototype, "WorkflowCount", {
3454 get: function () { return this.get("WorkflowCount", 0); },
3455 enumerable: false,
3456 configurable: true
3457 });
3458 Object.defineProperty(Workunit.prototype, "Archived", {
3459 get: function () { return this.get("Archived"); },
3460 enumerable: false,
3461 configurable: true
3462 });
3463 Object.defineProperty(Workunit.prototype, "RoxieCluster", {
3464 get: function () { return this.get("RoxieCluster"); },
3465 enumerable: false,
3466 configurable: true
3467 });
3468 Object.defineProperty(Workunit.prototype, "DebugState", {
3469 get: function () { return this.get("DebugState", {}); },
3470 enumerable: false,
3471 configurable: true
3472 });
3473 Object.defineProperty(Workunit.prototype, "Queue", {
3474 get: function () { return this.get("Queue"); },
3475 enumerable: false,
3476 configurable: true
3477 });
3478 Object.defineProperty(Workunit.prototype, "Active", {
3479 get: function () { return this.get("Active"); },
3480 enumerable: false,
3481 configurable: true
3482 });
3483 Object.defineProperty(Workunit.prototype, "Action", {
3484 get: function () { return this.get("Action"); },
3485 enumerable: false,
3486 configurable: true
3487 });
3488 Object.defineProperty(Workunit.prototype, "Scope", {
3489 get: function () { return this.get("Scope"); },
3490 enumerable: false,
3491 configurable: true
3492 });
3493 Object.defineProperty(Workunit.prototype, "AbortBy", {
3494 get: function () { return this.get("AbortBy"); },
3495 enumerable: false,
3496 configurable: true
3497 });
3498 Object.defineProperty(Workunit.prototype, "AbortTime", {
3499 get: function () { return this.get("AbortTime"); },
3500 enumerable: false,
3501 configurable: true
3502 });
3503 Object.defineProperty(Workunit.prototype, "Workflows", {
3504 get: function () { return this.get("Workflows"); },
3505 enumerable: false,
3506 configurable: true
3507 });
3508 Object.defineProperty(Workunit.prototype, "TimingData", {
3509 get: function () { return this.get("TimingData"); },
3510 enumerable: false,
3511 configurable: true
3512 });
3513 Object.defineProperty(Workunit.prototype, "HelpersDesc", {
3514 get: function () { return this.get("HelpersDesc"); },
3515 enumerable: false,
3516 configurable: true
3517 });
3518 Object.defineProperty(Workunit.prototype, "GraphsDesc", {
3519 get: function () { return this.get("GraphsDesc"); },
3520 enumerable: false,
3521 configurable: true
3522 });
3523 Object.defineProperty(Workunit.prototype, "SourceFilesDesc", {
3524 get: function () { return this.get("GraphsDesc"); },
3525 enumerable: false,
3526 configurable: true
3527 });
3528 Object.defineProperty(Workunit.prototype, "ResultsDesc", {
3529 get: function () { return this.get("GraphsDesc"); },
3530 enumerable: false,
3531 configurable: true
3532 });
3533 Object.defineProperty(Workunit.prototype, "VariablesDesc", {
3534 get: function () { return this.get("GraphsDesc"); },
3535 enumerable: false,
3536 configurable: true
3537 });
3538 Object.defineProperty(Workunit.prototype, "TimersDesc", {
3539 get: function () { return this.get("GraphsDesc"); },
3540 enumerable: false,
3541 configurable: true
3542 });
3543 Object.defineProperty(Workunit.prototype, "DebugValuesDesc", {
3544 get: function () { return this.get("GraphsDesc"); },
3545 enumerable: false,
3546 configurable: true
3547 });
3548 Object.defineProperty(Workunit.prototype, "ApplicationValuesDesc", {
3549 get: function () { return this.get("GraphsDesc"); },
3550 enumerable: false,
3551 configurable: true
3552 });
3553 Object.defineProperty(Workunit.prototype, "WorkflowsDesc", {
3554 get: function () { return this.get("GraphsDesc"); },
3555 enumerable: false,
3556 configurable: true
3557 });
3558 // Factories ---
3559 Workunit.create = function (optsConnection) {
3560 var retVal = new Workunit(optsConnection);
3561 return retVal.connection.WUCreate().then(function (response) {
3562 _workunits.set(retVal);
3563 retVal.set(response.Workunit);
3564 return retVal;
3565 });
3566 };
3567 Workunit.attach = function (optsConnection, wuid, state) {
3568 var retVal = _workunits.get({ BaseUrl: optsConnection.baseUrl, Wuid: wuid }, function () {
3569 return new Workunit(optsConnection, wuid);
3570 });
3571 if (state) {
3572 retVal.set(state);
3573 }
3574 return retVal;
3575 };
3576 Workunit.existsLocal = function (baseUrl, wuid) {
3577 return _workunits.has({ BaseUrl: baseUrl, Wuid: wuid });
3578 };
3579 Workunit.submit = function (server, target, ecl) {
3580 return Workunit.create(server).then(function (wu) {
3581 return wu.update({ QueryText: ecl });
3582 }).then(function (wu) {
3583 return wu.submit(target);
3584 });
3585 };
3586 Workunit.query = function (server, opts) {
3587 var wsWorkunits = new WorkunitsService(server);
3588 return wsWorkunits.WUQuery(opts).then(function (response) {
3589 return response.Workunits.ECLWorkunit.map(function (wu) {
3590 return Workunit.attach(server, wu.Wuid, wu);
3591 });
3592 });
3593 };
3594 Workunit.prototype.clearState = function (wuid) {
3595 this.clear({
3596 Wuid: wuid,
3597 StateID: WUStateID.Unknown
3598 });
3599 };
3600 Workunit.prototype.update = function (request) {
3601 var _this = this;
3602 return this.connection.WUUpdate(__assign(__assign({}, request), {
3603 Wuid: this.Wuid,
3604 StateOrig: this.State,
3605 JobnameOrig: this.Jobname,
3606 DescriptionOrig: this.Description,
3607 ProtectedOrig: this.Protected,
3608 ClusterOrig: this.Cluster
3609 })).then(function (response) {
3610 _this.set(response.Workunit);
3611 return _this;
3612 });
3613 };
3614 Workunit.prototype.submit = function (_cluster, action, resultLimit) {
3615 var _this = this;
3616 if (action === void 0) { action = exports.WUUpdate.Action.Run; }
3617 var clusterPromise;
3618 if (_cluster !== void 0) {
3619 clusterPromise = Promise.resolve(_cluster);
3620 }
3621 else {
3622 clusterPromise = this.topologyConnection.DefaultTpLogicalClusterQuery().then(function (response) {
3623 return response.Name;
3624 });
3625 }
3626 this._debugMode = false;
3627 if (action === exports.WUUpdate.Action.Debug) {
3628 action = exports.WUUpdate.Action.Run;
3629 this._debugMode = true;
3630 }
3631 return clusterPromise.then(function (cluster) {
3632 return _this.connection.WUUpdate({
3633 Wuid: _this.Wuid,
3634 Action: action,
3635 ResultLimit: resultLimit,
3636 DebugValues: {
3637 DebugValue: [
3638 {
3639 Name: "Debug",
3640 Value: _this._debugMode ? "1" : ""
3641 }
3642 ]
3643 }
3644 }).then(function (response) {
3645 _this.set(response.Workunit);
3646 _this._submitAction = action;
3647 return _this.connection.WUSubmit({ Wuid: _this.Wuid, Cluster: cluster });
3648 });
3649 }).then(function () {
3650 return _this;
3651 });
3652 };
3653 Workunit.prototype.isComplete = function () {
3654 switch (this.StateID) {
3655 case WUStateID.Compiled:
3656 return this.ActionEx === "compile" || this._submitAction === exports.WUUpdate.Action.Compile;
3657 case WUStateID.Completed:
3658 case WUStateID.Failed:
3659 case WUStateID.Aborted:
3660 case WUStateID.NotFound:
3661 return true;
3662 default:
3663 }
3664 return false;
3665 };
3666 Workunit.prototype.isFailed = function () {
3667 switch (this.StateID) {
3668 case WUStateID.Aborted:
3669 case WUStateID.Failed:
3670 return true;
3671 default:
3672 }
3673 return false;
3674 };
3675 Workunit.prototype.isDeleted = function () {
3676 switch (this.StateID) {
3677 case WUStateID.NotFound:
3678 return true;
3679 default:
3680 }
3681 return false;
3682 };
3683 Workunit.prototype.isDebugging = function () {
3684 switch (this.StateID) {
3685 case WUStateID.DebugPaused:
3686 case WUStateID.DebugRunning:
3687 return true;
3688 default:
3689 }
3690 return this._debugMode;
3691 };
3692 Workunit.prototype.isRunning = function () {
3693 switch (this.StateID) {
3694 case WUStateID.Compiled:
3695 case WUStateID.Running:
3696 case WUStateID.Aborting:
3697 case WUStateID.Blocked:
3698 case WUStateID.DebugPaused:
3699 case WUStateID.DebugRunning:
3700 return true;
3701 default:
3702 }
3703 return false;
3704 };
3705 Workunit.prototype.setToFailed = function () {
3706 return this.WUAction("SetToFailed");
3707 };
3708 Workunit.prototype.pause = function () {
3709 return this.WUAction("Pause");
3710 };
3711 Workunit.prototype.pauseNow = function () {
3712 return this.WUAction("PauseNow");
3713 };
3714 Workunit.prototype.resume = function () {
3715 return this.WUAction("Resume");
3716 };
3717 Workunit.prototype.abort = function () {
3718 return this.WUAction("Abort");
3719 };
3720 Workunit.prototype.delete = function () {
3721 return this.WUAction("Delete");
3722 };
3723 Workunit.prototype.restore = function () {
3724 return this.WUAction("Restore");
3725 };
3726 Workunit.prototype.deschedule = function () {
3727 return this.WUAction("Deschedule");
3728 };
3729 Workunit.prototype.reschedule = function () {
3730 return this.WUAction("Reschedule");
3731 };
3732 Workunit.prototype.resubmit = function () {
3733 var _this = this;
3734 return this.WUResubmit({
3735 CloneWorkunit: false,
3736 ResetWorkflow: false
3737 }).then(function () {
3738 _this.clearState(_this.Wuid);
3739 return _this.refresh().then(function () {
3740 _this._monitor();
3741 return _this;
3742 });
3743 });
3744 };
3745 Workunit.prototype.clone = function () {
3746 var _this = this;
3747 return this.WUResubmit({
3748 CloneWorkunit: true,
3749 ResetWorkflow: false
3750 }).then(function (response) {
3751 return Workunit.attach(_this.connection.connection(), response.WUs.WU[0].WUID)
3752 .refresh();
3753 });
3754 };
3755 Workunit.prototype.refreshState = function () {
3756 return __awaiter(this, void 0, void 0, function () {
3757 return __generator(this, function (_a) {
3758 switch (_a.label) {
3759 case 0: return [4 /*yield*/, this.WUQuery()];
3760 case 1:
3761 _a.sent();
3762 return [2 /*return*/, this];
3763 }
3764 });
3765 });
3766 };
3767 Workunit.prototype.refreshInfo = function () {
3768 return __awaiter(this, void 0, void 0, function () {
3769 return __generator(this, function (_a) {
3770 switch (_a.label) {
3771 case 0: return [4 /*yield*/, this.WUInfo()];
3772 case 1:
3773 _a.sent();
3774 return [2 /*return*/, this];
3775 }
3776 });
3777 });
3778 };
3779 Workunit.prototype.refreshDebug = function () {
3780 return __awaiter(this, void 0, void 0, function () {
3781 return __generator(this, function (_a) {
3782 switch (_a.label) {
3783 case 0: return [4 /*yield*/, this.debugStatus()];
3784 case 1:
3785 _a.sent();
3786 return [2 /*return*/, this];
3787 }
3788 });
3789 });
3790 };
3791 Workunit.prototype.refresh = function (full) {
3792 if (full === void 0) { full = false; }
3793 return __awaiter(this, void 0, void 0, function () {
3794 return __generator(this, function (_a) {
3795 switch (_a.label) {
3796 case 0:
3797 if (!full) return [3 /*break*/, 2];
3798 return [4 /*yield*/, Promise.all([this.refreshInfo(), this.refreshDebug()])];
3799 case 1:
3800 _a.sent();
3801 return [3 /*break*/, 4];
3802 case 2: return [4 /*yield*/, this.refreshState()];
3803 case 3:
3804 _a.sent();
3805 _a.label = 4;
3806 case 4: return [2 /*return*/, this];
3807 }
3808 });
3809 });
3810 };
3811 Workunit.prototype.eclExceptions = function () {
3812 return this.Exceptions.ECLException;
3813 };
3814 Workunit.prototype.fetchArchive = function () {
3815 return this.connection.WUFile({
3816 Wuid: this.Wuid,
3817 Type: "ArchiveQuery"
3818 });
3819 };
3820 Workunit.prototype.fetchECLExceptions = function () {
3821 var _this = this;
3822 return this.WUInfo({ IncludeExceptions: true }).then(function () {
3823 return _this.eclExceptions();
3824 });
3825 };
3826 Workunit.prototype.fetchResults = function () {
3827 var _this = this;
3828 return this.WUInfo({ IncludeResults: true }).then(function () {
3829 return _this.CResults;
3830 });
3831 };
3832 Workunit.prototype.fetchGraphs = function () {
3833 var _this = this;
3834 return this.WUInfo({ IncludeGraphs: true }).then(function () {
3835 return _this.CGraphs;
3836 });
3837 };
3838 Workunit.prototype.fetchDetailsMeta = function (request) {
3839 if (request === void 0) { request = {}; }
3840 return this.WUDetailsMeta(request);
3841 };
3842 Workunit.prototype.fetchDetailsRaw = function (request) {
3843 if (request === void 0) { request = {}; }
3844 return this.WUDetails(request).then(function (response) { return response.Scopes.Scope; });
3845 };
3846 Workunit.prototype.fetchDetailsNormalized = function (request) {
3847 if (request === void 0) { request = {}; }
3848 return Promise.all([this.fetchDetailsMeta(), this.fetchDetailsRaw(request)]).then(function (promises) {
3849 var meta = promises[0];
3850 var scopes = promises[1];
3851 var columns = {
3852 id: {
3853 Measure: "label"
3854 },
3855 name: {
3856 Measure: "label"
3857 },
3858 type: {
3859 Measure: "label"
3860 }
3861 };
3862 var data = [];
3863 for (var _i = 0, scopes_1 = scopes; _i < scopes_1.length; _i++) {
3864 var scope = scopes_1[_i];
3865 var props = {};
3866 if (scope && scope.Id && scope.Properties && scope.Properties.Property) {
3867 for (var key in scope.Properties.Property) {
3868 var scopeProperty = scope.Properties.Property[key];
3869 if (scopeProperty.Measure === "ns") {
3870 scopeProperty.Measure = "s";
3871 }
3872 columns[scopeProperty.Name] = __assign({}, scopeProperty);
3873 delete columns[scopeProperty.Name].RawValue;
3874 delete columns[scopeProperty.Name].Formatted;
3875 switch (scopeProperty.Measure) {
3876 case "bool":
3877 props[scopeProperty.Name] = !!+scopeProperty.RawValue;
3878 break;
3879 case "sz":
3880 props[scopeProperty.Name] = +scopeProperty.RawValue;
3881 break;
3882 case "s":
3883 props[scopeProperty.Name] = +scopeProperty.RawValue / 1000000000;
3884 break;
3885 case "ns":
3886 props[scopeProperty.Name] = +scopeProperty.RawValue;
3887 break;
3888 case "ts":
3889 props[scopeProperty.Name] = new Date(+scopeProperty.RawValue / 1000).toISOString();
3890 break;
3891 case "cnt":
3892 props[scopeProperty.Name] = +scopeProperty.RawValue;
3893 break;
3894 case "cpu":
3895 case "skw":
3896 case "node":
3897 case "ppm":
3898 case "ip":
3899 case "cy":
3900 case "en":
3901 case "txt":
3902 case "id":
3903 case "fname":
3904 default:
3905 props[scopeProperty.Name] = scopeProperty.RawValue;
3906 }
3907 }
3908 data.push(__assign({ id: scope.Id, name: scope.ScopeName, type: scope.ScopeType }, props));
3909 }
3910 }
3911 return {
3912 meta: meta,
3913 columns: columns,
3914 data: data
3915 };
3916 });
3917 };
3918 Workunit.prototype.fetchDetails = function (request) {
3919 var _this = this;
3920 if (request === void 0) { request = {}; }
3921 return this.WUDetails(request).then(function (response) {
3922 return response.Scopes.Scope.map(function (rawScope) {
3923 return new Scope(_this, rawScope);
3924 });
3925 });
3926 };
3927 Workunit.prototype.fetchDetailsHierarchy = function (request) {
3928 var _this = this;
3929 if (request === void 0) { request = {}; }
3930 return this.WUDetails(request).then(function (response) {
3931 var retVal = [];
3932 // Recreate Scope Hierarchy and dedup ---
3933 var scopeMap = {};
3934 response.Scopes.Scope.forEach(function (rawScope) {
3935 if (scopeMap[rawScope.ScopeName]) {
3936 scopeMap[rawScope.ScopeName].update(rawScope);
3937 return null;
3938 }
3939 else {
3940 var scope = new Scope(_this, rawScope);
3941 scopeMap[scope.ScopeName] = scope;
3942 return scope;
3943 }
3944 });
3945 for (var key in scopeMap) {
3946 if (scopeMap.hasOwnProperty(key)) {
3947 var scope = scopeMap[key];
3948 var parentScopeID = scope.parentScope();
3949 if (parentScopeID && scopeMap[parentScopeID]) {
3950 scopeMap[parentScopeID].children().push(scope);
3951 }
3952 else {
3953 retVal.push(scope);
3954 }
3955 }
3956 }
3957 return retVal;
3958 });
3959 };
3960 Workunit.prototype.fetchGraphDetails = function (graphIDs, rootTypes) {
3961 if (graphIDs === void 0) { graphIDs = []; }
3962 return this.fetchDetails({
3963 ScopeFilter: {
3964 MaxDepth: 999999,
3965 Ids: graphIDs,
3966 ScopeTypes: rootTypes
3967 },
3968 NestedFilter: {
3969 Depth: 999999,
3970 ScopeTypes: ["graph", "subgraph", "activity", "edge"]
3971 },
3972 PropertiesToReturn: {
3973 AllStatistics: true,
3974 AllAttributes: true,
3975 AllHints: true,
3976 AllProperties: true,
3977 AllScopes: true
3978 },
3979 ScopeOptions: {
3980 IncludeId: true,
3981 IncludeScope: true,
3982 IncludeScopeType: true
3983 },
3984 PropertyOptions: {
3985 IncludeName: true,
3986 IncludeRawValue: true,
3987 IncludeFormatted: true,
3988 IncludeMeasure: true,
3989 IncludeCreator: false,
3990 IncludeCreatorType: false
3991 }
3992 });
3993 };
3994 Workunit.prototype.fetchScopeGraphs = function (graphIDs) {
3995 if (graphIDs === void 0) { graphIDs = []; }
3996 return this.fetchGraphDetails(graphIDs, ["graph"]).then(function (scopes) {
3997 return createGraph(scopes);
3998 });
3999 };
4000 Workunit.prototype.fetchTimeElapsed = function () {
4001 return this.fetchDetails({
4002 ScopeFilter: {
4003 PropertyFilters: {
4004 PropertyFilter: [{ Name: "TimeElapsed" }]
4005 }
4006 }
4007 }).then(function (scopes) {
4008 var scopeInfo = {};
4009 scopes.forEach(function (scope) {
4010 scopeInfo[scope.ScopeName] = scopeInfo[scope.ScopeName] || {
4011 scope: scope.ScopeName,
4012 start: null,
4013 elapsed: null,
4014 finish: null
4015 };
4016 scope.CAttributes.forEach(function (attr) {
4017 if (attr.Name === "TimeElapsed") {
4018 scopeInfo[scope.ScopeName].elapsed = +attr.RawValue;
4019 }
4020 else if (attr.Measure === "ts" && attr.Name.indexOf("Started") >= 0) {
4021 scopeInfo[scope.ScopeName].start = attr.Formatted;
4022 }
4023 });
4024 });
4025 // Workaround duplicate scope responses
4026 var retVal = [];
4027 for (var key in scopeInfo) {
4028 var scope = scopeInfo[key];
4029 if (scope.start && scope.elapsed) {
4030 var endTime = parser(scope.start);
4031 endTime.setMilliseconds(endTime.getMilliseconds() + scope.elapsed / 1000000);
4032 scope.finish = formatter(endTime);
4033 retVal.push(scope);
4034 }
4035 }
4036 retVal.sort(function (l, r) {
4037 if (l.start < r.start)
4038 return -1;
4039 if (l.start > r.start)
4040 return 1;
4041 return 0;
4042 });
4043 return retVal;
4044 });
4045 };
4046 // Monitoring ---
4047 Workunit.prototype._monitor = function () {
4048 if (this.isComplete()) {
4049 this._monitorTickCount = 0;
4050 return;
4051 }
4052 _super.prototype._monitor.call(this);
4053 };
4054 Workunit.prototype._monitorTimeoutDuraction = function () {
4055 var retVal = _super.prototype._monitorTimeoutDuraction.call(this);
4056 if (this._monitorTickCount <= 1) { // Once
4057 return 1000;
4058 }
4059 else if (this._monitorTickCount <= 3) { // Twice
4060 return 3000;
4061 }
4062 else if (this._monitorTickCount <= 5) { // Twice
4063 return 5000;
4064 }
4065 else if (this._monitorTickCount <= 7) { // Twice
4066 return 10000;
4067 }
4068 return retVal;
4069 };
4070 // Events ---
4071 Workunit.prototype.on = function (eventID, propIDorCallback, callback) {
4072 var _this = this;
4073 if (this.isCallback(propIDorCallback)) {
4074 switch (eventID) {
4075 case "completed":
4076 _super.prototype.on.call(this, "propChanged", "StateID", function (changeInfo) {
4077 if (_this.isComplete()) {
4078 propIDorCallback([changeInfo]);
4079 }
4080 });
4081 break;
4082 case "changed":
4083 _super.prototype.on.call(this, eventID, propIDorCallback);
4084 break;
4085 default:
4086 }
4087 }
4088 else {
4089 switch (eventID) {
4090 case "changed":
4091 _super.prototype.on.call(this, eventID, propIDorCallback, callback);
4092 break;
4093 default:
4094 }
4095 }
4096 this._monitor();
4097 return this;
4098 };
4099 Workunit.prototype.watchUntilComplete = function (callback) {
4100 var _this = this;
4101 return new Promise(function (resolve, _) {
4102 var watchHandle = _this.watch(function (changes) {
4103 if (callback) {
4104 callback(changes);
4105 }
4106 if (_this.isComplete()) {
4107 watchHandle.release();
4108 resolve(_this);
4109 }
4110 });
4111 });
4112 };
4113 Workunit.prototype.watchUntilRunning = function (callback) {
4114 var _this = this;
4115 return new Promise(function (resolve, _) {
4116 var watchHandle = _this.watch(function (changes) {
4117 if (callback) {
4118 callback(changes);
4119 }
4120 if (_this.isComplete() || _this.isRunning()) {
4121 watchHandle.release();
4122 resolve(_this);
4123 }
4124 });
4125 });
4126 };
4127 // WsWorkunits passthroughs ---
4128 Workunit.prototype.WUQuery = function (_request) {
4129 var _this = this;
4130 if (_request === void 0) { _request = {}; }
4131 return this.connection.WUQuery(__assign(__assign({}, _request), { Wuid: this.Wuid })).then(function (response) {
4132 _this.set(response.Workunits.ECLWorkunit[0]);
4133 return response;
4134 }).catch(function (e) {
4135 // deleted ---
4136 var wuMissing = e.Exception.some(function (exception) {
4137 if (exception.Code === 20081) {
4138 _this.clearState(_this.Wuid);
4139 _this.set("StateID", WUStateID.NotFound);
4140 return true;
4141 }
4142 return false;
4143 });
4144 if (!wuMissing) {
4145 logger$1.warning("Unexpected exception: ");
4146 throw e;
4147 }
4148 return {};
4149 });
4150 };
4151 Workunit.prototype.WUCreate = function () {
4152 var _this = this;
4153 return this.connection.WUCreate().then(function (response) {
4154 _this.set(response.Workunit);
4155 _workunits.set(_this);
4156 return response;
4157 });
4158 };
4159 Workunit.prototype.WUInfo = function (_request) {
4160 var _this = this;
4161 if (_request === void 0) { _request = {}; }
4162 var includeResults = _request.IncludeResults || _request.IncludeResultsViewNames;
4163 return this.connection.WUInfo(__assign(__assign({}, _request), { Wuid: this.Wuid, IncludeResults: includeResults, IncludeResultsViewNames: includeResults, SuppressResultSchemas: false })).then(function (response) {
4164 _this.set(response.Workunit);
4165 if (includeResults) {
4166 _this.set({
4167 ResultViews: response.ResultViews
4168 });
4169 }
4170 return response;
4171 }).catch(function (e) {
4172 // deleted ---
4173 var wuMissing = e.Exception.some(function (exception) {
4174 if (exception.Code === 20080) {
4175 _this.clearState(_this.Wuid);
4176 _this.set("StateID", WUStateID.NotFound);
4177 return true;
4178 }
4179 return false;
4180 });
4181 if (!wuMissing) {
4182 logger$1.warning("Unexpected exception: ");
4183 throw e;
4184 }
4185 return {};
4186 });
4187 };
4188 Workunit.prototype.WUResubmit = function (request) {
4189 return this.connection.WUResubmit(util.deepMixinT({}, request, {
4190 Wuids: [this.Wuid]
4191 }));
4192 };
4193 Workunit.prototype.WUDetailsMeta = function (request) {
4194 return this.connection.WUDetailsMeta(request);
4195 };
4196 Workunit.prototype.WUDetails = function (request) {
4197 return this.connection.WUDetails(util.deepMixinT({
4198 ScopeFilter: {
4199 MaxDepth: 9999
4200 },
4201 ScopeOptions: {
4202 IncludeMatchedScopesInResults: true,
4203 IncludeScope: true,
4204 IncludeId: false,
4205 IncludeScopeType: false
4206 },
4207 PropertyOptions: {
4208 IncludeName: true,
4209 IncludeRawValue: false,
4210 IncludeFormatted: true,
4211 IncludeMeasure: true,
4212 IncludeCreator: false,
4213 IncludeCreatorType: false
4214 }
4215 }, request, { WUID: this.Wuid })).then(function (response) {
4216 return util.deepMixinT({
4217 Scopes: {
4218 Scope: []
4219 }
4220 }, response);
4221 });
4222 };
4223 Workunit.prototype.WUAction = function (actionType) {
4224 var _this = this;
4225 return this.connection.WUAction({
4226 Wuids: [this.Wuid],
4227 WUActionType: actionType
4228 }).then(function (response) {
4229 return _this.refresh().then(function () {
4230 _this._monitor();
4231 return response;
4232 });
4233 });
4234 };
4235 Workunit.prototype.publish = function (name) {
4236 return this.connection.WUPublishWorkunit({
4237 Wuid: this.Wuid,
4238 Cluster: this.Cluster,
4239 JobName: name || this.Jobname,
4240 AllowForeignFiles: true,
4241 Activate: true,
4242 Wait: 5000
4243 });
4244 };
4245 Workunit.prototype.WUCDebug = function (command, opts) {
4246 if (opts === void 0) { opts = {}; }
4247 var optsStr = "";
4248 for (var key in opts) {
4249 if (opts.hasOwnProperty(key)) {
4250 optsStr += " " + key + "='" + opts[key] + "'";
4251 }
4252 }
4253 return this.connection.WUCDebug({
4254 Wuid: this.Wuid,
4255 Command: "<debug:" + command + " uid='" + this.Wuid + "'" + optsStr + "/>"
4256 }).then(function (response) {
4257 return response;
4258 });
4259 };
4260 Workunit.prototype.debug = function (command, opts) {
4261 if (!this.isDebugging()) {
4262 return Promise.resolve(new util.XMLNode(command));
4263 }
4264 return this.WUCDebug(command, opts).then(function (response) {
4265 var retVal = response.children(command);
4266 if (retVal.length) {
4267 return retVal[0];
4268 }
4269 return new util.XMLNode(command);
4270 }).catch(function (_) {
4271 logger$1.error(_);
4272 return Promise.resolve(new util.XMLNode(command));
4273 });
4274 };
4275 Workunit.prototype.debugStatus = function () {
4276 var _this = this;
4277 if (!this.isDebugging()) {
4278 return Promise.resolve({
4279 DebugState: { state: "unknown" }
4280 });
4281 }
4282 return this.debug("status").then(function (response) {
4283 var debugState = __assign(__assign({}, _this.DebugState), response.$);
4284 _this.set({
4285 DebugState: debugState
4286 });
4287 return response;
4288 });
4289 };
4290 Workunit.prototype.debugContinue = function (mode) {
4291 if (mode === void 0) { mode = ""; }
4292 return this.debug("continue", {
4293 mode: mode
4294 });
4295 };
4296 Workunit.prototype.debugStep = function (mode) {
4297 return this.debug("step", {
4298 mode: mode
4299 });
4300 };
4301 Workunit.prototype.debugPause = function () {
4302 return this.debug("interrupt");
4303 };
4304 Workunit.prototype.debugQuit = function () {
4305 return this.debug("quit");
4306 };
4307 Workunit.prototype.debugDeleteAllBreakpoints = function () {
4308 return this.debug("delete", {
4309 idx: 0
4310 });
4311 };
4312 Workunit.prototype.debugBreakpointResponseParser = function (rootNode) {
4313 return rootNode.children().map(function (childNode) {
4314 if (childNode.name === "break") {
4315 return childNode.$;
4316 }
4317 });
4318 };
4319 Workunit.prototype.debugBreakpointAdd = function (id, mode, action) {
4320 var _this = this;
4321 return this.debug("breakpoint", {
4322 id: id,
4323 mode: mode,
4324 action: action
4325 }).then(function (rootNode) {
4326 return _this.debugBreakpointResponseParser(rootNode);
4327 });
4328 };
4329 Workunit.prototype.debugBreakpointList = function () {
4330 var _this = this;
4331 return this.debug("list").then(function (rootNode) {
4332 return _this.debugBreakpointResponseParser(rootNode);
4333 });
4334 };
4335 Workunit.prototype.debugGraph = function () {
4336 var _this = this;
4337 if (this._debugAllGraph && this.DebugState["_prevGraphSequenceNum"] === this.DebugState["graphSequenceNum"]) {
4338 return Promise.resolve(this._debugAllGraph);
4339 }
4340 return this.debug("graph", { name: "all" }).then(function (response) {
4341 _this.DebugState["_prevGraphSequenceNum"] = _this.DebugState["graphSequenceNum"];
4342 _this._debugAllGraph = createXGMMLGraph(_this.Wuid, response);
4343 return _this._debugAllGraph;
4344 });
4345 };
4346 Workunit.prototype.debugBreakpointValid = function (path) {
4347 return this.debugGraph().then(function (graph) {
4348 return breakpointLocations(graph, path);
4349 });
4350 };
4351 Workunit.prototype.debugPrint = function (edgeID, startRow, numRows) {
4352 if (startRow === void 0) { startRow = 0; }
4353 if (numRows === void 0) { numRows = 10; }
4354 return this.debug("print", {
4355 edgeID: edgeID,
4356 startRow: startRow,
4357 numRows: numRows
4358 }).then(function (response) {
4359 return response.children().map(function (rowNode) {
4360 var retVal = {};
4361 rowNode.children().forEach(function (cellNode) {
4362 retVal[cellNode.name] = cellNode.content;
4363 });
4364 return retVal;
4365 });
4366 });
4367 };
4368 return Workunit;
4369}(util.StateObject));
4370var ATTR_DEFINITION = "definition";
4371function hasECLDefinition(vertex) {
4372 return vertex._[ATTR_DEFINITION] !== undefined;
4373}
4374function getECLDefinition(vertex) {
4375 var match = /([a-z]:\\(?:[-\w\.\d]+\\)*(?:[-\w\.\d]+)?|(?:\/[\w\.\-]+)+)\((\d*),(\d*)\)/.exec(vertex._[ATTR_DEFINITION]);
4376 if (match) {
4377 var _file = match[1], _row = match[2], _col = match[3];
4378 _file.replace("/./", "/");
4379 return {
4380 id: vertex._["id"],
4381 file: _file,
4382 line: +_row,
4383 column: +_col
4384 };
4385 }
4386 throw new Error("Bad definition: " + vertex._[ATTR_DEFINITION]);
4387}
4388function breakpointLocations(graph, path) {
4389 var retVal = [];
4390 for (var _i = 0, _a = graph.vertices; _i < _a.length; _i++) {
4391 var vertex = _a[_i];
4392 if (hasECLDefinition(vertex)) {
4393 var definition = getECLDefinition(vertex);
4394 if (definition && !path || path === definition.file) {
4395 retVal.push(definition);
4396 }
4397 }
4398 }
4399 return retVal.sort(function (l, r) {
4400 return l.line - r.line;
4401 });
4402}
4403
4404var _activity;
4405var Activity = /** @class */ (function (_super) {
4406 __extends(Activity, _super);
4407 function Activity(optsConnection) {
4408 var _this = _super.call(this) || this;
4409 _this.lazyRefresh = util.debounce(function () { return __awaiter(_this, void 0, void 0, function () {
4410 var response;
4411 return __generator(this, function (_a) {
4412 switch (_a.label) {
4413 case 0: return [4 /*yield*/, this.connection.Activity({})];
4414 case 1:
4415 response = _a.sent();
4416 this.set(response);
4417 return [2 /*return*/, this];
4418 }
4419 });
4420 }); });
4421 if (optsConnection instanceof SMCService) {
4422 _this.connection = optsConnection;
4423 }
4424 else {
4425 _this.connection = new SMCService(optsConnection);
4426 }
4427 _this.clear({});
4428 return _this;
4429 }
4430 Object.defineProperty(Activity.prototype, "properties", {
4431 get: function () { return this.get(); },
4432 enumerable: false,
4433 configurable: true
4434 });
4435 Object.defineProperty(Activity.prototype, "Exceptions", {
4436 get: function () { return this.get("Exceptions"); },
4437 enumerable: false,
4438 configurable: true
4439 });
4440 Object.defineProperty(Activity.prototype, "Build", {
4441 get: function () { return this.get("Build"); },
4442 enumerable: false,
4443 configurable: true
4444 });
4445 Object.defineProperty(Activity.prototype, "ThorClusterList", {
4446 get: function () { return this.get("ThorClusterList"); },
4447 enumerable: false,
4448 configurable: true
4449 });
4450 Object.defineProperty(Activity.prototype, "RoxieClusterList", {
4451 get: function () { return this.get("RoxieClusterList"); },
4452 enumerable: false,
4453 configurable: true
4454 });
4455 Object.defineProperty(Activity.prototype, "HThorClusterList", {
4456 get: function () { return this.get("HThorClusterList"); },
4457 enumerable: false,
4458 configurable: true
4459 });
4460 Object.defineProperty(Activity.prototype, "DFUJobs", {
4461 get: function () { return this.get("DFUJobs"); },
4462 enumerable: false,
4463 configurable: true
4464 });
4465 Object.defineProperty(Activity.prototype, "Running", {
4466 get: function () { return this.get("Running", { ActiveWorkunit: [] }); },
4467 enumerable: false,
4468 configurable: true
4469 });
4470 Object.defineProperty(Activity.prototype, "BannerContent", {
4471 get: function () { return this.get("BannerContent"); },
4472 enumerable: false,
4473 configurable: true
4474 });
4475 Object.defineProperty(Activity.prototype, "BannerColor", {
4476 get: function () { return this.get("BannerColor"); },
4477 enumerable: false,
4478 configurable: true
4479 });
4480 Object.defineProperty(Activity.prototype, "BannerSize", {
4481 get: function () { return this.get("BannerSize"); },
4482 enumerable: false,
4483 configurable: true
4484 });
4485 Object.defineProperty(Activity.prototype, "BannerScroll", {
4486 get: function () { return this.get("BannerScroll"); },
4487 enumerable: false,
4488 configurable: true
4489 });
4490 Object.defineProperty(Activity.prototype, "ChatURL", {
4491 get: function () { return this.get("ChatURL"); },
4492 enumerable: false,
4493 configurable: true
4494 });
4495 Object.defineProperty(Activity.prototype, "ShowBanner", {
4496 get: function () { return this.get("ShowBanner"); },
4497 enumerable: false,
4498 configurable: true
4499 });
4500 Object.defineProperty(Activity.prototype, "ShowChatURL", {
4501 get: function () { return this.get("ShowChatURL"); },
4502 enumerable: false,
4503 configurable: true
4504 });
4505 Object.defineProperty(Activity.prototype, "SortBy", {
4506 get: function () { return this.get("SortBy"); },
4507 enumerable: false,
4508 configurable: true
4509 });
4510 Object.defineProperty(Activity.prototype, "Descending", {
4511 get: function () { return this.get("Descending"); },
4512 enumerable: false,
4513 configurable: true
4514 });
4515 Object.defineProperty(Activity.prototype, "SuperUser", {
4516 get: function () { return this.get("SuperUser"); },
4517 enumerable: false,
4518 configurable: true
4519 });
4520 Object.defineProperty(Activity.prototype, "AccessRight", {
4521 get: function () { return this.get("AccessRight"); },
4522 enumerable: false,
4523 configurable: true
4524 });
4525 Object.defineProperty(Activity.prototype, "ServerJobQueues", {
4526 get: function () { return this.get("ServerJobQueues"); },
4527 enumerable: false,
4528 configurable: true
4529 });
4530 Activity.attach = function (optsConnection, state) {
4531 if (!_activity) {
4532 _activity = new Activity(optsConnection);
4533 }
4534 if (state) {
4535 _activity.set(__assign({}, state));
4536 }
4537 return _activity;
4538 };
4539 Activity.prototype.runningWorkunits = function (clusterName) {
4540 var _this = this;
4541 if (clusterName === void 0) { clusterName = ""; }
4542 return this.Running.ActiveWorkunit.filter(function (awu) { return clusterName === "" || awu.ClusterName === clusterName; }).map(function (awu) { return Workunit.attach(_this.connection.connectionOptions(), awu.Wuid, awu); });
4543 };
4544 Activity.prototype.refresh = function () {
4545 return __awaiter(this, void 0, void 0, function () {
4546 return __generator(this, function (_a) {
4547 return [2 /*return*/, this.lazyRefresh()];
4548 });
4549 });
4550 };
4551 return Activity;
4552}(util.StateObject));
4553
4554var LogicalFileCache = /** @class */ (function (_super) {
4555 __extends(LogicalFileCache, _super);
4556 function LogicalFileCache() {
4557 return _super.call(this, function (obj) {
4558 return obj.BaseUrl + "-" + obj.Cluster + "-" + obj.Name;
4559 }) || this;
4560 }
4561 return LogicalFileCache;
4562}(util.Cache));
4563var _store = new LogicalFileCache();
4564var LogicalFile = /** @class */ (function (_super) {
4565 __extends(LogicalFile, _super);
4566 function LogicalFile(optsConnection, Cluster, Name) {
4567 var _this = _super.call(this) || this;
4568 if (optsConnection instanceof DFUService) {
4569 _this.connection = optsConnection;
4570 }
4571 else {
4572 _this.connection = new DFUService(optsConnection);
4573 }
4574 _this.clear({
4575 Cluster: Cluster,
4576 Name: Name
4577 });
4578 return _this;
4579 }
4580 Object.defineProperty(LogicalFile.prototype, "BaseUrl", {
4581 get: function () { return this.connection.baseUrl; },
4582 enumerable: false,
4583 configurable: true
4584 });
4585 Object.defineProperty(LogicalFile.prototype, "Cluster", {
4586 get: function () { return this.get("Cluster"); },
4587 enumerable: false,
4588 configurable: true
4589 });
4590 Object.defineProperty(LogicalFile.prototype, "Name", {
4591 get: function () { return this.get("Name"); },
4592 enumerable: false,
4593 configurable: true
4594 });
4595 Object.defineProperty(LogicalFile.prototype, "Filename", {
4596 get: function () { return this.get("Filename"); },
4597 enumerable: false,
4598 configurable: true
4599 });
4600 Object.defineProperty(LogicalFile.prototype, "Prefix", {
4601 get: function () { return this.get("Prefix"); },
4602 enumerable: false,
4603 configurable: true
4604 });
4605 Object.defineProperty(LogicalFile.prototype, "NodeGroup", {
4606 get: function () { return this.get("NodeGroup"); },
4607 enumerable: false,
4608 configurable: true
4609 });
4610 Object.defineProperty(LogicalFile.prototype, "NumParts", {
4611 get: function () { return this.get("NumParts"); },
4612 enumerable: false,
4613 configurable: true
4614 });
4615 Object.defineProperty(LogicalFile.prototype, "Description", {
4616 get: function () { return this.get("Description"); },
4617 enumerable: false,
4618 configurable: true
4619 });
4620 Object.defineProperty(LogicalFile.prototype, "Dir", {
4621 get: function () { return this.get("Dir"); },
4622 enumerable: false,
4623 configurable: true
4624 });
4625 Object.defineProperty(LogicalFile.prototype, "PathMask", {
4626 get: function () { return this.get("PathMask"); },
4627 enumerable: false,
4628 configurable: true
4629 });
4630 Object.defineProperty(LogicalFile.prototype, "Filesize", {
4631 get: function () { return this.get("Filesize"); },
4632 enumerable: false,
4633 configurable: true
4634 });
4635 Object.defineProperty(LogicalFile.prototype, "FileSizeInt64", {
4636 get: function () { return this.get("FileSizeInt64"); },
4637 enumerable: false,
4638 configurable: true
4639 });
4640 Object.defineProperty(LogicalFile.prototype, "RecordSize", {
4641 get: function () { return this.get("RecordSize"); },
4642 enumerable: false,
4643 configurable: true
4644 });
4645 Object.defineProperty(LogicalFile.prototype, "RecordCount", {
4646 get: function () { return this.get("RecordCount"); },
4647 enumerable: false,
4648 configurable: true
4649 });
4650 Object.defineProperty(LogicalFile.prototype, "RecordSizeInt64", {
4651 get: function () { return this.get("RecordSizeInt64"); },
4652 enumerable: false,
4653 configurable: true
4654 });
4655 Object.defineProperty(LogicalFile.prototype, "RecordCountInt64", {
4656 get: function () { return this.get("RecordCountInt64"); },
4657 enumerable: false,
4658 configurable: true
4659 });
4660 Object.defineProperty(LogicalFile.prototype, "Wuid", {
4661 get: function () { return this.get("Wuid"); },
4662 enumerable: false,
4663 configurable: true
4664 });
4665 Object.defineProperty(LogicalFile.prototype, "Owner", {
4666 get: function () { return this.get("Owner"); },
4667 enumerable: false,
4668 configurable: true
4669 });
4670 Object.defineProperty(LogicalFile.prototype, "JobName", {
4671 get: function () { return this.get("JobName"); },
4672 enumerable: false,
4673 configurable: true
4674 });
4675 Object.defineProperty(LogicalFile.prototype, "Persistent", {
4676 get: function () { return this.get("Persistent"); },
4677 enumerable: false,
4678 configurable: true
4679 });
4680 Object.defineProperty(LogicalFile.prototype, "Format", {
4681 get: function () { return this.get("Format"); },
4682 enumerable: false,
4683 configurable: true
4684 });
4685 Object.defineProperty(LogicalFile.prototype, "MaxRecordSize", {
4686 get: function () { return this.get("MaxRecordSize"); },
4687 enumerable: false,
4688 configurable: true
4689 });
4690 Object.defineProperty(LogicalFile.prototype, "CsvSeparate", {
4691 get: function () { return this.get("CsvSeparate"); },
4692 enumerable: false,
4693 configurable: true
4694 });
4695 Object.defineProperty(LogicalFile.prototype, "CsvQuote", {
4696 get: function () { return this.get("CsvQuote"); },
4697 enumerable: false,
4698 configurable: true
4699 });
4700 Object.defineProperty(LogicalFile.prototype, "CsvTerminate", {
4701 get: function () { return this.get("CsvTerminate"); },
4702 enumerable: false,
4703 configurable: true
4704 });
4705 Object.defineProperty(LogicalFile.prototype, "CsvEscape", {
4706 get: function () { return this.get("CsvEscape"); },
4707 enumerable: false,
4708 configurable: true
4709 });
4710 Object.defineProperty(LogicalFile.prototype, "Modified", {
4711 get: function () { return this.get("Modified"); },
4712 enumerable: false,
4713 configurable: true
4714 });
4715 Object.defineProperty(LogicalFile.prototype, "Ecl", {
4716 get: function () { return this.get("Ecl"); },
4717 enumerable: false,
4718 configurable: true
4719 });
4720 Object.defineProperty(LogicalFile.prototype, "Stat", {
4721 get: function () { return this.get("Stat"); },
4722 enumerable: false,
4723 configurable: true
4724 });
4725 Object.defineProperty(LogicalFile.prototype, "DFUFilePartsOnClusters", {
4726 get: function () { return this.get("DFUFilePartsOnClusters"); },
4727 enumerable: false,
4728 configurable: true
4729 });
4730 Object.defineProperty(LogicalFile.prototype, "isSuperfile", {
4731 get: function () { return this.get("isSuperfile"); },
4732 enumerable: false,
4733 configurable: true
4734 });
4735 Object.defineProperty(LogicalFile.prototype, "ShowFileContent", {
4736 get: function () { return this.get("ShowFileContent"); },
4737 enumerable: false,
4738 configurable: true
4739 });
4740 Object.defineProperty(LogicalFile.prototype, "subfiles", {
4741 get: function () { return this.get("subfiles"); },
4742 enumerable: false,
4743 configurable: true
4744 });
4745 Object.defineProperty(LogicalFile.prototype, "Superfiles", {
4746 get: function () { return this.get("Superfiles"); },
4747 enumerable: false,
4748 configurable: true
4749 });
4750 Object.defineProperty(LogicalFile.prototype, "ProtectList", {
4751 get: function () { return this.get("ProtectList"); },
4752 enumerable: false,
4753 configurable: true
4754 });
4755 Object.defineProperty(LogicalFile.prototype, "FromRoxieCluster", {
4756 get: function () { return this.get("FromRoxieCluster"); },
4757 enumerable: false,
4758 configurable: true
4759 });
4760 Object.defineProperty(LogicalFile.prototype, "Graphs", {
4761 get: function () { return this.get("Graphs"); },
4762 enumerable: false,
4763 configurable: true
4764 });
4765 Object.defineProperty(LogicalFile.prototype, "UserPermission", {
4766 get: function () { return this.get("UserPermission"); },
4767 enumerable: false,
4768 configurable: true
4769 });
4770 Object.defineProperty(LogicalFile.prototype, "ContentType", {
4771 get: function () { return this.get("ContentType"); },
4772 enumerable: false,
4773 configurable: true
4774 });
4775 Object.defineProperty(LogicalFile.prototype, "CompressedFileSize", {
4776 get: function () { return this.get("CompressedFileSize"); },
4777 enumerable: false,
4778 configurable: true
4779 });
4780 Object.defineProperty(LogicalFile.prototype, "PercentCompressed", {
4781 get: function () { return this.get("PercentCompressed"); },
4782 enumerable: false,
4783 configurable: true
4784 });
4785 Object.defineProperty(LogicalFile.prototype, "IsCompressed", {
4786 get: function () { return this.get("IsCompressed"); },
4787 enumerable: false,
4788 configurable: true
4789 });
4790 Object.defineProperty(LogicalFile.prototype, "BrowseData", {
4791 get: function () { return this.get("BrowseData"); },
4792 enumerable: false,
4793 configurable: true
4794 });
4795 Object.defineProperty(LogicalFile.prototype, "jsonInfo", {
4796 get: function () { return this.get("jsonInfo"); },
4797 enumerable: false,
4798 configurable: true
4799 });
4800 Object.defineProperty(LogicalFile.prototype, "binInfo", {
4801 get: function () { return this.get("binInfo"); },
4802 enumerable: false,
4803 configurable: true
4804 });
4805 Object.defineProperty(LogicalFile.prototype, "PackageID", {
4806 get: function () { return this.get("PackageID"); },
4807 enumerable: false,
4808 configurable: true
4809 });
4810 Object.defineProperty(LogicalFile.prototype, "Partition", {
4811 get: function () { return this.get("Partition"); },
4812 enumerable: false,
4813 configurable: true
4814 });
4815 Object.defineProperty(LogicalFile.prototype, "Blooms", {
4816 get: function () { return this.get("Blooms"); },
4817 enumerable: false,
4818 configurable: true
4819 });
4820 Object.defineProperty(LogicalFile.prototype, "ExpireDays", {
4821 get: function () { return this.get("ExpireDays"); },
4822 enumerable: false,
4823 configurable: true
4824 });
4825 Object.defineProperty(LogicalFile.prototype, "KeyType", {
4826 get: function () { return this.get("KeyType"); },
4827 enumerable: false,
4828 configurable: true
4829 });
4830 Object.defineProperty(LogicalFile.prototype, "properties", {
4831 get: function () { return this.get(); },
4832 enumerable: false,
4833 configurable: true
4834 });
4835 LogicalFile.attach = function (optsConnection, Cluster, Name) {
4836 var retVal = _store.get({ BaseUrl: optsConnection.baseUrl, Cluster: Cluster, Name: Name }, function () {
4837 return new LogicalFile(optsConnection, Cluster, Name);
4838 });
4839 return retVal;
4840 };
4841 LogicalFile.prototype.fetchInfo = function () {
4842 var _this = this;
4843 return this.connection.DFUInfo({ Cluster: this.Cluster, Name: this.Name }).then(function (response) {
4844 _this.set(__assign({ Cluster: _this.Cluster }, response.FileDetail));
4845 return response.FileDetail;
4846 });
4847 };
4848 return LogicalFile;
4849}(util.StateObject));
4850
4851var MachineCache = /** @class */ (function (_super) {
4852 __extends(MachineCache, _super);
4853 function MachineCache() {
4854 return _super.call(this, function (obj) {
4855 return obj.Address;
4856 }) || this;
4857 }
4858 return MachineCache;
4859}(util.Cache));
4860var _machines = new MachineCache();
4861var Machine = /** @class */ (function (_super) {
4862 __extends(Machine, _super);
4863 function Machine(optsConnection) {
4864 var _this = _super.call(this) || this;
4865 if (optsConnection instanceof MachineService) {
4866 _this.connection = optsConnection;
4867 }
4868 else {
4869 _this.connection = new MachineService(optsConnection);
4870 }
4871 return _this;
4872 }
4873 Object.defineProperty(Machine.prototype, "Address", {
4874 get: function () { return this.get("Address"); },
4875 enumerable: false,
4876 configurable: true
4877 });
4878 Object.defineProperty(Machine.prototype, "ConfigAddress", {
4879 get: function () { return this.get("ConfigAddress"); },
4880 enumerable: false,
4881 configurable: true
4882 });
4883 Object.defineProperty(Machine.prototype, "Name", {
4884 get: function () { return this.get("Name"); },
4885 enumerable: false,
4886 configurable: true
4887 });
4888 Object.defineProperty(Machine.prototype, "ProcessType", {
4889 get: function () { return this.get("ProcessType"); },
4890 enumerable: false,
4891 configurable: true
4892 });
4893 Object.defineProperty(Machine.prototype, "DisplayType", {
4894 get: function () { return this.get("DisplayType"); },
4895 enumerable: false,
4896 configurable: true
4897 });
4898 Object.defineProperty(Machine.prototype, "Description", {
4899 get: function () { return this.get("Description"); },
4900 enumerable: false,
4901 configurable: true
4902 });
4903 Object.defineProperty(Machine.prototype, "AgentVersion", {
4904 get: function () { return this.get("AgentVersion"); },
4905 enumerable: false,
4906 configurable: true
4907 });
4908 Object.defineProperty(Machine.prototype, "Contact", {
4909 get: function () { return this.get("Contact"); },
4910 enumerable: false,
4911 configurable: true
4912 });
4913 Object.defineProperty(Machine.prototype, "Location", {
4914 get: function () { return this.get("Location"); },
4915 enumerable: false,
4916 configurable: true
4917 });
4918 Object.defineProperty(Machine.prototype, "UpTime", {
4919 get: function () { return this.get("UpTime"); },
4920 enumerable: false,
4921 configurable: true
4922 });
4923 Object.defineProperty(Machine.prototype, "ComponentName", {
4924 get: function () { return this.get("ComponentName"); },
4925 enumerable: false,
4926 configurable: true
4927 });
4928 Object.defineProperty(Machine.prototype, "ComponentPath", {
4929 get: function () { return this.get("ComponentPath"); },
4930 enumerable: false,
4931 configurable: true
4932 });
4933 Object.defineProperty(Machine.prototype, "RoxieState", {
4934 get: function () { return this.get("RoxieState"); },
4935 enumerable: false,
4936 configurable: true
4937 });
4938 Object.defineProperty(Machine.prototype, "RoxieStateDetails", {
4939 get: function () { return this.get("RoxieStateDetails"); },
4940 enumerable: false,
4941 configurable: true
4942 });
4943 Object.defineProperty(Machine.prototype, "OS", {
4944 get: function () { return this.get("OS"); },
4945 enumerable: false,
4946 configurable: true
4947 });
4948 Object.defineProperty(Machine.prototype, "ProcessNumber", {
4949 get: function () { return this.get("ProcessNumber"); },
4950 enumerable: false,
4951 configurable: true
4952 });
4953 Object.defineProperty(Machine.prototype, "Processors", {
4954 get: function () { return this.get("Processors"); },
4955 enumerable: false,
4956 configurable: true
4957 });
4958 Object.defineProperty(Machine.prototype, "Storage", {
4959 get: function () { return this.get("Storage"); },
4960 enumerable: false,
4961 configurable: true
4962 });
4963 Object.defineProperty(Machine.prototype, "Running", {
4964 get: function () { return this.get("Running"); },
4965 enumerable: false,
4966 configurable: true
4967 });
4968 Object.defineProperty(Machine.prototype, "PhysicalMemory", {
4969 get: function () { return this.get("PhysicalMemory"); },
4970 enumerable: false,
4971 configurable: true
4972 });
4973 Object.defineProperty(Machine.prototype, "VirtualMemory", {
4974 get: function () { return this.get("VirtualMemory"); },
4975 enumerable: false,
4976 configurable: true
4977 });
4978 Object.defineProperty(Machine.prototype, "ComponentInfo", {
4979 get: function () { return this.get("ComponentInfo"); },
4980 enumerable: false,
4981 configurable: true
4982 });
4983 Machine.attach = function (optsConnection, address, state) {
4984 var retVal = _machines.get({ Address: address }, function () {
4985 return new Machine(optsConnection);
4986 });
4987 if (state) {
4988 retVal.set(state);
4989 }
4990 return retVal;
4991 };
4992 return Machine;
4993}(util.StateObject));
4994
4995var QueryCache = /** @class */ (function (_super) {
4996 __extends(QueryCache, _super);
4997 function QueryCache() {
4998 return _super.call(this, function (obj) {
4999 return util.Cache.hash([obj.QueryId, obj.QuerySet]);
5000 }) || this;
5001 }
5002 return QueryCache;
5003}(util.Cache));
5004var _queries = new QueryCache();
5005var Query = /** @class */ (function (_super) {
5006 __extends(Query, _super);
5007 function Query(optsConnection, querySet, queryID, queryDetails) {
5008 var _this = _super.call(this) || this;
5009 if (optsConnection instanceof EclService) {
5010 _this.connection = optsConnection;
5011 // this._topology = new Topology(this.connection.opts());
5012 }
5013 else {
5014 _this.connection = new EclService(optsConnection);
5015 // this._topology = new Topology(optsConnection);
5016 }
5017 _this.set(__assign({ QuerySet: querySet, QueryId: queryID }, queryDetails));
5018 return _this;
5019 }
5020 Object.defineProperty(Query.prototype, "BaseUrl", {
5021 get: function () { return this.connection.baseUrl; },
5022 enumerable: false,
5023 configurable: true
5024 });
5025 Object.defineProperty(Query.prototype, "properties", {
5026 get: function () { return this.get(); },
5027 enumerable: false,
5028 configurable: true
5029 });
5030 Object.defineProperty(Query.prototype, "Exceptions", {
5031 get: function () { return this.get("Exceptions"); },
5032 enumerable: false,
5033 configurable: true
5034 });
5035 Object.defineProperty(Query.prototype, "QueryId", {
5036 get: function () { return this.get("QueryId"); },
5037 enumerable: false,
5038 configurable: true
5039 });
5040 Object.defineProperty(Query.prototype, "QuerySet", {
5041 get: function () { return this.get("QuerySet"); },
5042 enumerable: false,
5043 configurable: true
5044 });
5045 Object.defineProperty(Query.prototype, "QueryName", {
5046 get: function () { return this.get("QueryName"); },
5047 enumerable: false,
5048 configurable: true
5049 });
5050 Object.defineProperty(Query.prototype, "Wuid", {
5051 get: function () { return this.get("Wuid"); },
5052 enumerable: false,
5053 configurable: true
5054 });
5055 Object.defineProperty(Query.prototype, "Dll", {
5056 get: function () { return this.get("Dll"); },
5057 enumerable: false,
5058 configurable: true
5059 });
5060 Object.defineProperty(Query.prototype, "Suspended", {
5061 get: function () { return this.get("Suspended"); },
5062 enumerable: false,
5063 configurable: true
5064 });
5065 Object.defineProperty(Query.prototype, "Activated", {
5066 get: function () { return this.get("Activated"); },
5067 enumerable: false,
5068 configurable: true
5069 });
5070 Object.defineProperty(Query.prototype, "SuspendedBy", {
5071 get: function () { return this.get("SuspendedBy"); },
5072 enumerable: false,
5073 configurable: true
5074 });
5075 Object.defineProperty(Query.prototype, "Clusters", {
5076 get: function () { return this.get("Clusters"); },
5077 enumerable: false,
5078 configurable: true
5079 });
5080 Object.defineProperty(Query.prototype, "PublishedBy", {
5081 get: function () { return this.get("PublishedBy"); },
5082 enumerable: false,
5083 configurable: true
5084 });
5085 Object.defineProperty(Query.prototype, "Comment", {
5086 get: function () { return this.get("Comment"); },
5087 enumerable: false,
5088 configurable: true
5089 });
5090 Object.defineProperty(Query.prototype, "LogicalFiles", {
5091 get: function () { return this.get("LogicalFiles"); },
5092 enumerable: false,
5093 configurable: true
5094 });
5095 Object.defineProperty(Query.prototype, "SuperFiles", {
5096 get: function () { return this.get("SuperFiles"); },
5097 enumerable: false,
5098 configurable: true
5099 });
5100 Object.defineProperty(Query.prototype, "IsLibrary", {
5101 get: function () { return this.get("IsLibrary"); },
5102 enumerable: false,
5103 configurable: true
5104 });
5105 Object.defineProperty(Query.prototype, "Priority", {
5106 get: function () { return this.get("Priority"); },
5107 enumerable: false,
5108 configurable: true
5109 });
5110 Object.defineProperty(Query.prototype, "WUSnapShot", {
5111 get: function () { return this.get("WUSnapShot"); },
5112 enumerable: false,
5113 configurable: true
5114 });
5115 Object.defineProperty(Query.prototype, "CompileTime", {
5116 get: function () { return this.get("CompileTime"); },
5117 enumerable: false,
5118 configurable: true
5119 });
5120 Object.defineProperty(Query.prototype, "LibrariesUsed", {
5121 get: function () { return this.get("LibrariesUsed"); },
5122 enumerable: false,
5123 configurable: true
5124 });
5125 Object.defineProperty(Query.prototype, "CountGraphs", {
5126 get: function () { return this.get("CountGraphs"); },
5127 enumerable: false,
5128 configurable: true
5129 });
5130 Object.defineProperty(Query.prototype, "ResourceURLCount", {
5131 get: function () { return this.get("ResourceURLCount"); },
5132 enumerable: false,
5133 configurable: true
5134 });
5135 Object.defineProperty(Query.prototype, "WsEclAddresses", {
5136 get: function () { return this.get("WsEclAddresses"); },
5137 enumerable: false,
5138 configurable: true
5139 });
5140 Object.defineProperty(Query.prototype, "WUGraphs", {
5141 get: function () { return this.get("WUGraphs"); },
5142 enumerable: false,
5143 configurable: true
5144 });
5145 Object.defineProperty(Query.prototype, "WUTimers", {
5146 get: function () { return this.get("WUTimers"); },
5147 enumerable: false,
5148 configurable: true
5149 });
5150 Query.attach = function (optsConnection, querySet, queryId) {
5151 var retVal = _queries.get({ BaseUrl: optsConnection.baseUrl, QuerySet: querySet, QueryId: queryId }, function () {
5152 return new Query(optsConnection, querySet, queryId);
5153 });
5154 return retVal;
5155 };
5156 Query.prototype.fetchRequestSchema = function () {
5157 return __awaiter(this, void 0, void 0, function () {
5158 var _a;
5159 return __generator(this, function (_b) {
5160 switch (_b.label) {
5161 case 0:
5162 _a = this;
5163 return [4 /*yield*/, this.connection.requestJson(this.QuerySet, this.QueryId)];
5164 case 1:
5165 _a._requestSchema = _b.sent();
5166 return [2 /*return*/];
5167 }
5168 });
5169 });
5170 };
5171 Query.prototype.fetchResponseSchema = function () {
5172 return __awaiter(this, void 0, void 0, function () {
5173 var _a;
5174 return __generator(this, function (_b) {
5175 switch (_b.label) {
5176 case 0:
5177 _a = this;
5178 return [4 /*yield*/, this.connection.responseJson(this.QuerySet, this.QueryId)];
5179 case 1:
5180 _a._responseSchema = _b.sent();
5181 return [2 /*return*/];
5182 }
5183 });
5184 });
5185 };
5186 Query.prototype.fetchSchema = function () {
5187 return __awaiter(this, void 0, void 0, function () {
5188 return __generator(this, function (_a) {
5189 switch (_a.label) {
5190 case 0: return [4 /*yield*/, Promise.all([this.fetchRequestSchema(), this.fetchResponseSchema()])];
5191 case 1:
5192 _a.sent();
5193 return [2 /*return*/];
5194 }
5195 });
5196 });
5197 };
5198 Query.prototype.submit = function (request) {
5199 return this.connection.submit(this.QuerySet, this.QueryId, request).then(function (results) {
5200 for (var key in results) {
5201 results[key] = results[key].Row;
5202 }
5203 return results;
5204 });
5205 };
5206 Query.prototype.refresh = function () {
5207 return __awaiter(this, void 0, void 0, function () {
5208 var _this = this;
5209 return __generator(this, function (_a) {
5210 return [2 /*return*/, this.fetchSchema().then(function (schema) { return _this; })];
5211 });
5212 });
5213 };
5214 Query.prototype.requestFields = function () {
5215 if (!this._requestSchema)
5216 return [];
5217 return this._requestSchema;
5218 };
5219 Query.prototype.responseFields = function () {
5220 if (!this._responseSchema)
5221 return {};
5222 return this._responseSchema;
5223 };
5224 Query.prototype.resultNames = function () {
5225 var retVal = [];
5226 for (var key in this.responseFields()) {
5227 retVal.push(key);
5228 }
5229 return retVal;
5230 };
5231 Query.prototype.resultFields = function (resultName) {
5232 if (!this._responseSchema[resultName])
5233 return [];
5234 return this._responseSchema[resultName];
5235 };
5236 return Query;
5237}(util.StateObject));
5238
5239var StoreCache = /** @class */ (function (_super) {
5240 __extends(StoreCache, _super);
5241 function StoreCache() {
5242 return _super.call(this, function (obj) {
5243 return obj.BaseUrl + "-" + obj.Name + ":" + obj.UserSpecific + "-" + obj.Namespace;
5244 }) || this;
5245 }
5246 return StoreCache;
5247}(util.Cache));
5248var _store$1 = new StoreCache();
5249var ValueChangedMessage = /** @class */ (function (_super) {
5250 __extends(ValueChangedMessage, _super);
5251 function ValueChangedMessage(key, value, oldValue) {
5252 var _this = _super.call(this) || this;
5253 _this.key = key;
5254 _this.value = value;
5255 _this.oldValue = oldValue;
5256 return _this;
5257 }
5258 Object.defineProperty(ValueChangedMessage.prototype, "canConflate", {
5259 get: function () { return true; },
5260 enumerable: false,
5261 configurable: true
5262 });
5263 ValueChangedMessage.prototype.conflate = function (other) {
5264 if (this.key === other.key) {
5265 this.value = other.value;
5266 return true;
5267 }
5268 return false;
5269 };
5270 ValueChangedMessage.prototype.void = function () {
5271 return this.value === this.oldValue;
5272 };
5273 return ValueChangedMessage;
5274}(util.Message));
5275var Store = /** @class */ (function () {
5276 function Store(optsConnection, Name, Namespace, UserSpecific) {
5277 this._dispatch = new util.Dispatch();
5278 this._knownValues = {};
5279 if (optsConnection instanceof StoreService) {
5280 this.connection = optsConnection;
5281 }
5282 else {
5283 this.connection = new StoreService(optsConnection);
5284 }
5285 this.Name = Name;
5286 this.UserSpecific = UserSpecific;
5287 this.Namespace = Namespace;
5288 }
5289 Object.defineProperty(Store.prototype, "BaseUrl", {
5290 get: function () { return this.connection.baseUrl; },
5291 enumerable: false,
5292 configurable: true
5293 });
5294 Store.attach = function (optsConnection, Name, Namespace, UserSpecific) {
5295 if (Name === void 0) { Name = "HPCCApps"; }
5296 if (UserSpecific === void 0) { UserSpecific = true; }
5297 var retVal = _store$1.get({ BaseUrl: optsConnection.baseUrl, Name: Name, UserSpecific: UserSpecific, Namespace: Namespace }, function () {
5298 return new Store(optsConnection, Name, Namespace, UserSpecific);
5299 });
5300 return retVal;
5301 };
5302 Store.prototype.create = function () {
5303 this.connection.CreateStore({ Name: this.Name, UserSpecific: this.UserSpecific, Type: "", Description: "" });
5304 };
5305 Store.prototype.set = function (key, value, broadcast) {
5306 var _this = this;
5307 if (broadcast === void 0) { broadcast = true; }
5308 return this.connection.Set({
5309 StoreName: this.Name,
5310 UserSpecific: this.UserSpecific,
5311 Namespace: this.Namespace,
5312 Key: key,
5313 Value: value
5314 }).then(function (response) {
5315 var oldValue = _this._knownValues[key];
5316 _this._knownValues[key] = value;
5317 if (broadcast) {
5318 _this._dispatch.post(new ValueChangedMessage(key, value, oldValue));
5319 }
5320 }).catch(function (e) {
5321 console.error("Store.set(\"" + key + "\", \"" + value + "\") failed:", e);
5322 });
5323 };
5324 Store.prototype.get = function (key, broadcast) {
5325 var _this = this;
5326 if (broadcast === void 0) { broadcast = true; }
5327 return this.connection.Fetch({
5328 StoreName: this.Name,
5329 UserSpecific: this.UserSpecific,
5330 Namespace: this.Namespace,
5331 Key: key
5332 }).then(function (response) {
5333 var oldValue = _this._knownValues[key];
5334 _this._knownValues[key] = response.Value;
5335 if (broadcast) {
5336 _this._dispatch.post(new ValueChangedMessage(key, response.Value, oldValue));
5337 }
5338 return response.Value;
5339 }).catch(function (e) {
5340 console.error("Store.get(" + key + ") failed:", e);
5341 return undefined;
5342 });
5343 };
5344 Store.prototype.getAll = function (broadcast) {
5345 var _this = this;
5346 if (broadcast === void 0) { broadcast = true; }
5347 return this.connection.FetchAll({
5348 StoreName: this.Name,
5349 UserSpecific: this.UserSpecific,
5350 Namespace: this.Namespace
5351 }).then(function (response) {
5352 var retVal = {};
5353 var deletedValues = _this._knownValues;
5354 _this._knownValues = {};
5355 response.Pairs.Pair.forEach(function (pair) {
5356 var oldValue = _this._knownValues[pair.Key];
5357 _this._knownValues[pair.Key] = pair.Value;
5358 delete deletedValues[pair.Key];
5359 retVal[pair.Key] = pair.Value;
5360 if (broadcast) {
5361 _this._dispatch.post(new ValueChangedMessage(pair.Key, pair.Value, oldValue));
5362 }
5363 });
5364 if (broadcast) {
5365 for (var key in deletedValues) {
5366 _this._dispatch.post(new ValueChangedMessage(key, undefined, deletedValues[key]));
5367 }
5368 }
5369 return retVal;
5370 }).catch(function (e) {
5371 console.error("Store.getAll failed:", e);
5372 return {};
5373 });
5374 };
5375 Store.prototype.delete = function (key, broadcast) {
5376 var _this = this;
5377 if (broadcast === void 0) { broadcast = true; }
5378 return this.connection.Delete({
5379 StoreName: this.Name,
5380 UserSpecific: this.UserSpecific,
5381 Namespace: this.Namespace,
5382 Key: key
5383 }).then(function (response) {
5384 var oldValue = _this._knownValues[key];
5385 delete _this._knownValues[key];
5386 if (broadcast) {
5387 _this._dispatch.post(new ValueChangedMessage(key, undefined, oldValue));
5388 }
5389 }).catch(function (e) {
5390 console.error("Store.delete(" + key + ") failed:", e);
5391 });
5392 };
5393 Store.prototype.monitor = function (callback) {
5394 return this._dispatch.attach(callback);
5395 };
5396 return Store;
5397}());
5398
5399var TargetClusterCache = /** @class */ (function (_super) {
5400 __extends(TargetClusterCache, _super);
5401 function TargetClusterCache() {
5402 return _super.call(this, function (obj) {
5403 return obj.BaseUrl + "-" + obj.Name;
5404 }) || this;
5405 }
5406 return TargetClusterCache;
5407}(util.Cache));
5408var _targetCluster = new TargetClusterCache();
5409var TargetCluster = /** @class */ (function (_super) {
5410 __extends(TargetCluster, _super);
5411 function TargetCluster(optsConnection, name) {
5412 var _this = _super.call(this) || this;
5413 if (optsConnection instanceof TopologyService) {
5414 _this.connection = optsConnection;
5415 _this.machineConnection = new MachineService(optsConnection.connectionOptions());
5416 }
5417 else {
5418 _this.connection = new TopologyService(optsConnection);
5419 _this.machineConnection = new MachineService(optsConnection);
5420 }
5421 _this.clear({
5422 Name: name
5423 });
5424 return _this;
5425 }
5426 Object.defineProperty(TargetCluster.prototype, "BaseUrl", {
5427 get: function () { return this.connection.baseUrl; },
5428 enumerable: false,
5429 configurable: true
5430 });
5431 Object.defineProperty(TargetCluster.prototype, "Name", {
5432 get: function () { return this.get("Name"); },
5433 enumerable: false,
5434 configurable: true
5435 });
5436 Object.defineProperty(TargetCluster.prototype, "Prefix", {
5437 get: function () { return this.get("Prefix"); },
5438 enumerable: false,
5439 configurable: true
5440 });
5441 Object.defineProperty(TargetCluster.prototype, "Type", {
5442 get: function () { return this.get("Type"); },
5443 enumerable: false,
5444 configurable: true
5445 });
5446 Object.defineProperty(TargetCluster.prototype, "IsDefault", {
5447 get: function () { return this.get("IsDefault"); },
5448 enumerable: false,
5449 configurable: true
5450 });
5451 Object.defineProperty(TargetCluster.prototype, "TpClusters", {
5452 get: function () { return this.get("TpClusters"); },
5453 enumerable: false,
5454 configurable: true
5455 });
5456 Object.defineProperty(TargetCluster.prototype, "TpEclCCServers", {
5457 get: function () { return this.get("TpEclCCServers"); },
5458 enumerable: false,
5459 configurable: true
5460 });
5461 Object.defineProperty(TargetCluster.prototype, "TpEclServers", {
5462 get: function () { return this.get("TpEclServers"); },
5463 enumerable: false,
5464 configurable: true
5465 });
5466 Object.defineProperty(TargetCluster.prototype, "TpEclAgents", {
5467 get: function () { return this.get("TpEclAgents"); },
5468 enumerable: false,
5469 configurable: true
5470 });
5471 Object.defineProperty(TargetCluster.prototype, "TpEclSchedulers", {
5472 get: function () { return this.get("TpEclSchedulers"); },
5473 enumerable: false,
5474 configurable: true
5475 });
5476 Object.defineProperty(TargetCluster.prototype, "MachineInfoEx", {
5477 get: function () { return this.get("MachineInfoEx", []); },
5478 enumerable: false,
5479 configurable: true
5480 });
5481 Object.defineProperty(TargetCluster.prototype, "CMachineInfoEx", {
5482 get: function () {
5483 var _this = this;
5484 return this.MachineInfoEx.map(function (machineInfoEx) { return Machine.attach(_this.machineConnection, machineInfoEx.Address, machineInfoEx); });
5485 },
5486 enumerable: false,
5487 configurable: true
5488 });
5489 TargetCluster.attach = function (optsConnection, name, state) {
5490 var retVal = _targetCluster.get({ BaseUrl: optsConnection.baseUrl, Name: name }, function () {
5491 return new TargetCluster(optsConnection, name);
5492 });
5493 if (state) {
5494 retVal.set(__assign({}, state));
5495 }
5496 return retVal;
5497 };
5498 TargetCluster.prototype.fetchMachines = function (request) {
5499 var _this = this;
5500 if (request === void 0) { request = {}; }
5501 return this.machineConnection.GetTargetClusterInfo(__assign({ TargetClusters: {
5502 Item: [this.Type + ":" + this.Name]
5503 } }, request)).then(function (response) {
5504 var retVal = [];
5505 for (var _i = 0, _a = response.TargetClusterInfoList.TargetClusterInfo; _i < _a.length; _i++) {
5506 var machineInfo = _a[_i];
5507 for (var _b = 0, _c = machineInfo.Processes.MachineInfoEx; _b < _c.length; _b++) {
5508 var machineInfoEx = _c[_b];
5509 retVal.push(machineInfoEx);
5510 }
5511 }
5512 _this.set("MachineInfoEx", retVal);
5513 return _this.CMachineInfoEx;
5514 });
5515 };
5516 TargetCluster.prototype.machineStats = function () {
5517 var maxDisk = 0;
5518 var totalFree = 0;
5519 var total = 0;
5520 for (var _i = 0, _a = this.CMachineInfoEx; _i < _a.length; _i++) {
5521 var machine = _a[_i];
5522 for (var _b = 0, _c = machine.Storage.StorageInfo; _b < _c.length; _b++) {
5523 var storageInfo = _c[_b];
5524 totalFree += storageInfo.Available;
5525 total += storageInfo.Total;
5526 var usage = 1 - storageInfo.Available / storageInfo.Total;
5527 if (usage > maxDisk) {
5528 maxDisk = usage;
5529 }
5530 }
5531 }
5532 return {
5533 maxDisk: maxDisk,
5534 meanDisk: 1 - (total ? totalFree / total : 1)
5535 };
5536 };
5537 TargetCluster.prototype.fetchUsage = function () {
5538 return this.machineConnection.GetTargetClusterUsageEx([this.Name]);
5539 };
5540 return TargetCluster;
5541}(util.StateObject));
5542function targetClusters(optsConnection) {
5543 var connection;
5544 if (optsConnection instanceof TopologyService) {
5545 connection = optsConnection;
5546 }
5547 else {
5548 connection = new TopologyService(optsConnection);
5549 }
5550 return connection.TpListTargetClusters({}).then(function (response) {
5551 return response.TargetClusters.TpClusterNameType.map(function (item) { return TargetCluster.attach(optsConnection, item.Name, item); });
5552 });
5553}
5554var _defaultTargetCluster = {};
5555function defaultTargetCluster(optsConnection) {
5556 if (!_defaultTargetCluster[optsConnection.baseUrl]) {
5557 var connection = void 0;
5558 if (optsConnection instanceof TopologyService) {
5559 connection = optsConnection;
5560 }
5561 else {
5562 connection = new TopologyService(optsConnection);
5563 }
5564 _defaultTargetCluster[optsConnection.baseUrl] = connection.TpListTargetClusters({}).then(function (response) {
5565 var firstItem;
5566 var defaultItem;
5567 var hthorItem;
5568 response.TargetClusters.TpClusterNameType.forEach(function (item) {
5569 if (!firstItem) {
5570 firstItem = item;
5571 }
5572 if (!defaultItem && item.IsDefault === true) {
5573 defaultItem = item;
5574 }
5575 if (!hthorItem && item.Type === "hthor") {
5576 hthorItem = item;
5577 }
5578 });
5579 var defItem = defaultItem || hthorItem || firstItem;
5580 return TargetCluster.attach(optsConnection, defItem.Name, defItem);
5581 });
5582 }
5583 return _defaultTargetCluster[optsConnection.baseUrl];
5584}
5585
5586var Topology = /** @class */ (function (_super) {
5587 __extends(Topology, _super);
5588 function Topology(optsConnection) {
5589 var _this = _super.call(this) || this;
5590 if (optsConnection instanceof TopologyService) {
5591 _this.connection = optsConnection;
5592 }
5593 else {
5594 _this.connection = new TopologyService(optsConnection);
5595 }
5596 return _this;
5597 }
5598 Object.defineProperty(Topology.prototype, "properties", {
5599 // Accessors ---
5600 get: function () { return this.get(); },
5601 enumerable: false,
5602 configurable: true
5603 });
5604 Object.defineProperty(Topology.prototype, "TargetClusters", {
5605 get: function () { return this.get("TargetClusters"); },
5606 enumerable: false,
5607 configurable: true
5608 });
5609 Object.defineProperty(Topology.prototype, "CTargetClusters", {
5610 get: function () {
5611 var _this = this;
5612 return this.TargetClusters.map(function (tc) { return TargetCluster.attach(_this.connection, tc.Name, tc); });
5613 },
5614 enumerable: false,
5615 configurable: true
5616 });
5617 Topology.prototype.GetESPServiceBaseURL = function (type) {
5618 var _this = this;
5619 if (type === void 0) { type = ""; }
5620 return this.connection.TpServiceQuery({}).then(function (response) {
5621 var rootProtocol = _this.connection.protocol();
5622 var ip = _this.connection.ip();
5623 var port = rootProtocol === "https:" ? "18002" : "8002";
5624 if (util.exists("ServiceList.TpEspServers.TpEspServer", response)) {
5625 for (var _i = 0, _a = response.ServiceList.TpEspServers.TpEspServer; _i < _a.length; _i++) {
5626 var item = _a[_i];
5627 if (util.exists("TpBindings.TpBinding", item)) {
5628 for (var _b = 0, _c = item.TpBindings.TpBinding; _b < _c.length; _b++) {
5629 var binding = _c[_b];
5630 if (binding.Service === type && binding.Protocol + ":" === rootProtocol) {
5631 port = binding.Port;
5632 }
5633 }
5634 }
5635 }
5636 }
5637 return rootProtocol + "//" + ip + ":" + port + "/";
5638 });
5639 };
5640 Topology.prototype.fetchTargetClusters = function () {
5641 var _this = this;
5642 return this.connection.TpTargetClusterQuery({ Type: "ROOT" }).then(function (response) {
5643 _this.set({
5644 TargetClusters: response.TpTargetClusters.TpTargetCluster
5645 });
5646 return _this.CTargetClusters;
5647 });
5648 };
5649 Topology.prototype.refresh = function () {
5650 return __awaiter(this, void 0, void 0, function () {
5651 return __generator(this, function (_a) {
5652 switch (_a.label) {
5653 case 0: return [4 /*yield*/, this.fetchTargetClusters()];
5654 case 1:
5655 _a.sent();
5656 return [2 /*return*/, this];
5657 }
5658 });
5659 });
5660 };
5661 // Monitoring ---
5662 // Events ---
5663 Topology.prototype.on = function (eventID, propIDorCallback, callback) {
5664 if (this.isCallback(propIDorCallback)) {
5665 switch (eventID) {
5666 case "changed":
5667 _super.prototype.on.call(this, eventID, propIDorCallback);
5668 break;
5669 default:
5670 }
5671 }
5672 else {
5673 switch (eventID) {
5674 case "changed":
5675 _super.prototype.on.call(this, eventID, propIDorCallback, callback);
5676 break;
5677 default:
5678 }
5679 }
5680 this._monitor();
5681 return this;
5682 };
5683 return Topology;
5684}(util.StateObject));
5685
5686var logger$2 = util.scopedLogger("clienttools/eclmeta");
5687var Attr = /** @class */ (function () {
5688 function Attr(xmlAttr) {
5689 this.__attrs = xmlAttr.$;
5690 this.name = xmlAttr.$.name;
5691 }
5692 return Attr;
5693}());
5694var Field = /** @class */ (function () {
5695 function Field(definition, xmlField) {
5696 this.__attrs = xmlField.$;
5697 this.definition = definition;
5698 this.name = xmlField.$.name;
5699 this.type = xmlField.$.type;
5700 }
5701 Object.defineProperty(Field.prototype, "scope", {
5702 get: function () {
5703 return this.definition;
5704 },
5705 enumerable: false,
5706 configurable: true
5707 });
5708 return Field;
5709}());
5710var ECLScope = /** @class */ (function () {
5711 function ECLScope(name, type, sourcePath, xmlDefinitions, line, start, body, end) {
5712 if (line === void 0) { line = 1; }
5713 if (start === void 0) { start = 0; }
5714 if (body === void 0) { body = 0; }
5715 if (end === void 0) { end = Number.MAX_VALUE; }
5716 this.name = name;
5717 this.type = type;
5718 this.sourcePath = path.normalize(sourcePath);
5719 this.line = +line - 1;
5720 this.start = +start;
5721 this.body = +body;
5722 this.end = +end;
5723 this.definitions = this.parseDefinitions(xmlDefinitions);
5724 }
5725 Object.defineProperty(ECLScope.prototype, "scope", {
5726 get: function () {
5727 return this;
5728 },
5729 enumerable: false,
5730 configurable: true
5731 });
5732 ECLScope.prototype.parseDefinitions = function (definitions) {
5733 var _this = this;
5734 if (definitions === void 0) { definitions = []; }
5735 return definitions.map(function (definition) {
5736 var retVal = new Definition(_this.sourcePath, definition);
5737 return retVal;
5738 });
5739 };
5740 ECLScope.prototype.contains = function (charOffset) {
5741 return charOffset >= this.start && charOffset <= this.end;
5742 };
5743 ECLScope.prototype.scopeStackAt = function (charOffset) {
5744 var retVal = [];
5745 if (this.contains(charOffset)) {
5746 retVal.push(this);
5747 this.definitions.forEach(function (def) {
5748 retVal = def.scopeStackAt(charOffset).concat(retVal);
5749 });
5750 }
5751 return retVal;
5752 };
5753 ECLScope.prototype._resolve = function (defs, qualifiedID) {
5754 if (defs === void 0) { defs = []; }
5755 var qualifiedIDParts = qualifiedID.split(".");
5756 var base = qualifiedIDParts.shift();
5757 var retVal = util.find(defs, function (def) {
5758 if (typeof def.name === "string" && typeof base === "string" && def.name.toLowerCase() === base.toLowerCase()) {
5759 return true;
5760 }
5761 return false;
5762 });
5763 if (retVal && retVal.definitions.length && qualifiedIDParts.length) {
5764 return this._resolve(retVal.definitions, qualifiedIDParts.join("."));
5765 }
5766 return retVal;
5767 };
5768 ECLScope.prototype.resolve = function (qualifiedID) {
5769 return this._resolve(this.definitions, qualifiedID);
5770 };
5771 ECLScope.prototype.suggestions = function () {
5772 var _this = this;
5773 return this.definitions.map(function (def) {
5774 return {
5775 name: def.name,
5776 type: _this.type
5777 };
5778 });
5779 };
5780 return ECLScope;
5781}());
5782var Definition = /** @class */ (function (_super) {
5783 __extends(Definition, _super);
5784 function Definition(sourcePath, xmlDefinition) {
5785 var _this = _super.call(this, xmlDefinition.$.name, xmlDefinition.$.type, sourcePath, xmlDefinition.children("Definition"), xmlDefinition.$.line, xmlDefinition.$.start, xmlDefinition.$.body, xmlDefinition.$.end) || this;
5786 _this.__attrs = xmlDefinition.$;
5787 _this.exported = !!xmlDefinition.$.exported;
5788 _this.shared = !!xmlDefinition.$.shared;
5789 _this.fullname = xmlDefinition.$.fullname;
5790 _this.inherittype = xmlDefinition.$.inherittype;
5791 _this.attrs = _this.parseAttrs(xmlDefinition.children("Attr"));
5792 _this.fields = _this.parseFields(xmlDefinition.children("Field"));
5793 return _this;
5794 }
5795 Definition.prototype.parseAttrs = function (attrs) {
5796 if (attrs === void 0) { attrs = []; }
5797 return attrs.map(function (attr) {
5798 var retVal = new Attr(attr);
5799 return retVal;
5800 });
5801 };
5802 Definition.prototype.parseFields = function (fields) {
5803 var _this = this;
5804 if (fields === void 0) { fields = []; }
5805 return fields.map(function (field) {
5806 var retVal = new Field(_this, field);
5807 return retVal;
5808 });
5809 };
5810 Definition.prototype.suggestions = function () {
5811 return _super.prototype.suggestions.call(this).concat(this.fields.map(function (field) {
5812 return {
5813 name: field.name,
5814 type: field.type
5815 };
5816 }));
5817 };
5818 return Definition;
5819}(ECLScope));
5820var Import = /** @class */ (function () {
5821 function Import(xmlImport) {
5822 this.__attrs = xmlImport.$;
5823 this.name = xmlImport.$.name;
5824 this.ref = xmlImport.$.ref;
5825 this.start = xmlImport.$.start;
5826 this.end = xmlImport.$.end;
5827 this.line = xmlImport.$.line;
5828 }
5829 return Import;
5830}());
5831var Source = /** @class */ (function (_super) {
5832 __extends(Source, _super);
5833 function Source(xmlSource) {
5834 var _this = _super.call(this, xmlSource.$.name, "source", xmlSource.$.sourcePath, xmlSource.children("Definition")) || this;
5835 _this.__attrs = xmlSource.$;
5836 var nameParts = xmlSource.$.name.split(".");
5837 nameParts.pop();
5838 var fakeNode = new util.XMLNode("");
5839 fakeNode.appendAttribute("name", "$");
5840 fakeNode.appendAttribute("ref", nameParts.join("."));
5841 _this.imports = __spreadArrays([
5842 new Import(fakeNode)
5843 ], _this.parseImports(xmlSource.children("Import")));
5844 return _this;
5845 }
5846 Source.prototype.parseImports = function (imports) {
5847 if (imports === void 0) { imports = []; }
5848 return imports.map(function (imp) {
5849 var retVal = new Import(imp);
5850 return retVal;
5851 });
5852 };
5853 Source.prototype.resolve = function (qualifiedID, charOffset) {
5854 var retVal;
5855 // Check Inner Scopes ---
5856 if (!retVal && charOffset !== undefined) {
5857 var scopes = this.scopeStackAt(charOffset);
5858 scopes.some(function (scope) {
5859 retVal = scope.resolve(qualifiedID);
5860 return !!retVal;
5861 });
5862 }
5863 // Check Definitions ---
5864 if (!retVal) {
5865 retVal = _super.prototype.resolve.call(this, qualifiedID);
5866 }
5867 return retVal;
5868 };
5869 return Source;
5870}(ECLScope));
5871var isHiddenDirectory = function (source) { return path.basename(source).indexOf(".") === 0; };
5872var isDirectory = function (source) { return fs.lstatSync(source).isDirectory() && !isHiddenDirectory(source); };
5873var isEcl = function (source) { return [".ecl", ".ecllib"].indexOf(path.extname(source).toLowerCase()) >= 0; };
5874var modAttrs = function (source) { return fs.readdirSync(source).map(function (name) { return path.join(source, name); }).filter(function (path) { return isDirectory(path) || isEcl(path); }); };
5875var File = /** @class */ (function (_super) {
5876 __extends(File, _super);
5877 function File(name, sourcePath) {
5878 return _super.call(this, name, "file", sourcePath, []) || this;
5879 }
5880 File.prototype.suggestions = function () {
5881 return [];
5882 };
5883 return File;
5884}(ECLScope));
5885var Folder = /** @class */ (function (_super) {
5886 __extends(Folder, _super);
5887 function Folder(name, sourcePath) {
5888 return _super.call(this, name, "folder", sourcePath, []) || this;
5889 }
5890 Folder.prototype.suggestions = function () {
5891 return modAttrs(this.sourcePath).map(function (folder) {
5892 return {
5893 name: path.basename(folder, ".ecl"),
5894 type: "folder"
5895 };
5896 });
5897 };
5898 return Folder;
5899}(ECLScope));
5900var Workspace = /** @class */ (function () {
5901 function Workspace(workspacePath, eclccPath) {
5902 this._sourceByID = new util.DictionaryNoCase();
5903 this._sourceByPath = new util.Dictionary();
5904 this._test = new util.DictionaryNoCase();
5905 this._workspacePath = workspacePath;
5906 this._eclccPath = eclccPath;
5907 }
5908 Workspace.prototype.refresh = function () {
5909 this.primeWorkspace();
5910 this.primeClientTools();
5911 };
5912 Workspace.prototype.primeClientTools = function () {
5913 var _this = this;
5914 return locateClientTools(this._eclccPath, "", this._workspacePath).then(function (clientTools) {
5915 _this._clientTools = clientTools;
5916 return clientTools.paths();
5917 }).then(function (paths) {
5918 for (var _i = 0, _a = ["ECLCC_ECLLIBRARY_PATH", "ECLCC_PLUGIN_PATH"]; _i < _a.length; _i++) {
5919 var knownFolder = _a[_i];
5920 if (paths[knownFolder] && fs.existsSync(paths[knownFolder])) {
5921 _this.walkChildFolders(paths[knownFolder], paths[knownFolder]);
5922 }
5923 }
5924 return _this;
5925 });
5926 };
5927 Workspace.prototype.primeWorkspace = function () {
5928 if (fs.existsSync(this._workspacePath)) {
5929 this.visitFolder(this._workspacePath, this._workspacePath);
5930 }
5931 };
5932 Workspace.prototype.walkChildFolders = function (folderPath, refPath, force) {
5933 if (force === void 0) { force = false; }
5934 for (var _i = 0, _a = modAttrs(folderPath); _i < _a.length; _i++) {
5935 var child = _a[_i];
5936 if (!isDirectory(child)) {
5937 this.visitFile(child, refPath, force);
5938 }
5939 else {
5940 this.visitFolder(child, refPath, force);
5941 }
5942 }
5943 };
5944 Workspace.prototype.visitFile = function (filePath, refPath, force) {
5945 if (force === void 0) { force = false; }
5946 var filePathInfo = path.parse(filePath);
5947 var pathNoExt = path.join(filePathInfo.dir, filePathInfo.name);
5948 var name = path.relative(refPath, pathNoExt).split(path.sep).join(".");
5949 if (force || !this._test.has(name)) {
5950 this._test.set(name, new File("", filePath));
5951 }
5952 };
5953 Workspace.prototype.visitFolder = function (folderPath, refPath, force) {
5954 if (force === void 0) { force = false; }
5955 var name = path.relative(refPath, folderPath).split(path.sep).join(".");
5956 if (force || !this._test.has(name)) {
5957 this._test.set(name, new Folder(name, folderPath));
5958 this.walkChildFolders(folderPath, refPath, force);
5959 }
5960 };
5961 Workspace.prototype.buildStack = function (parentStack, name, removeDupID) {
5962 var nameStack = name.split(".");
5963 if (removeDupID && parentStack[parentStack.length - 1] === nameStack[0]) {
5964 nameStack.shift();
5965 }
5966 var stack = __spreadArrays(parentStack, nameStack);
5967 var qid = stack.join(".");
5968 return {
5969 stack: stack,
5970 qid: qid
5971 };
5972 };
5973 Workspace.prototype.walkECLScope = function (parentStack, scope) {
5974 var info = this.buildStack(parentStack, scope.name, true);
5975 this._test.set(info.qid, scope);
5976 for (var _i = 0, _a = scope.definitions; _i < _a.length; _i++) {
5977 var def = _a[_i];
5978 this.walkDefinition(info.stack, def);
5979 }
5980 };
5981 Workspace.prototype.walkField = function (parentStack, field) {
5982 var info = this.buildStack(parentStack, field.name, false);
5983 this._test.set(info.qid, field);
5984 };
5985 Workspace.prototype.walkDefinition = function (parentStack, definition) {
5986 var info = this.buildStack(parentStack, definition.name, true);
5987 this.walkECLScope(parentStack, definition);
5988 for (var _i = 0, _a = definition.fields; _i < _a.length; _i++) {
5989 var field = _a[_i];
5990 this.walkField(info.stack, field);
5991 }
5992 };
5993 Workspace.prototype.walkSource = function (source) {
5994 // const dirName = path.dirname(source.sourcePath);
5995 // const relName = path.relative(this._workspacePath, dirName).split(path.sep).join(".");
5996 // const folder = new Folder(relName, dirName);
5997 // this._test.set(folder.name, folder);
5998 this.walkECLScope([], source);
5999 };
6000 Workspace.prototype.parseSources = function (sources) {
6001 if (sources === void 0) { sources = []; }
6002 for (var _i = 0, sources_1 = sources; _i < sources_1.length; _i++) {
6003 var _source = sources_1[_i];
6004 if (_source.$.name) { // Plugins have no name...
6005 var source = new Source(_source);
6006 this._sourceByID.set(source.name, source);
6007 this._sourceByPath.set(source.sourcePath, source);
6008 // If external source like "std.system.ThorLib" then need to backup to "std" and add its folder
6009 if (source.name) {
6010 var sourceNameParts = source.name.split(".");
6011 var depth = sourceNameParts.length;
6012 if (depth > 1) {
6013 var sourcePath = source.sourcePath;
6014 while (depth > 1) {
6015 sourcePath = path.dirname(sourcePath);
6016 --depth;
6017 }
6018 this.visitFolder(sourcePath, path.dirname(sourcePath));
6019 }
6020 }
6021 this.walkSource(source);
6022 }
6023 }
6024 };
6025 Workspace.prototype.parseMetaXML = function (metaXML) {
6026 var metaParser = new MetaParser();
6027 metaParser.parse(metaXML);
6028 this.parseSources(metaParser.sources);
6029 return metaParser.sources.map(function (source) { return path.normalize(source.$.sourcePath); });
6030 };
6031 Workspace.prototype.resolveQualifiedID = function (filePath, qualifiedID, charOffset) {
6032 var retVal;
6033 if (!retVal && this._test.has(qualifiedID)) {
6034 retVal = this._test.get(qualifiedID).scope;
6035 }
6036 if (!retVal && this._sourceByPath.has(filePath)) {
6037 var eclSource = this._sourceByPath.get(filePath);
6038 // Resolve Imports ---
6039 var qualifiedIDParts = qualifiedID.split(".");
6040 for (var _i = 0, _a = eclSource.imports; _i < _a.length; _i++) {
6041 var imp = _a[_i];
6042 if (imp.name.toLowerCase() === qualifiedIDParts[0].toLowerCase()) {
6043 if (imp.ref) {
6044 qualifiedIDParts[0] = imp.ref;
6045 }
6046 else {
6047 qualifiedIDParts.shift();
6048 }
6049 break;
6050 }
6051 }
6052 var realQID = qualifiedIDParts.join(".");
6053 if (!retVal && this._test.has(realQID)) {
6054 retVal = this._test.get(realQID).scope;
6055 }
6056 if (!retVal) {
6057 realQID = __spreadArrays(eclSource.name.split("."), qualifiedIDParts).join(".");
6058 if (this._test.has(realQID)) {
6059 retVal = this._test.get(realQID).scope;
6060 }
6061 }
6062 }
6063 return retVal;
6064 };
6065 Workspace.prototype.resolvePartialID = function (filePath, partialID, charOffset) {
6066 partialID = partialID.toLowerCase();
6067 var partialIDParts = partialID.split(".");
6068 partialIDParts.pop();
6069 var partialIDQualifier = partialIDParts.length === 1 ? partialIDParts[0] : partialIDParts.join(".");
6070 return this.resolveQualifiedID(filePath, partialIDQualifier, charOffset);
6071 };
6072 return Workspace;
6073}());
6074var workspaceCache = new util.Dictionary();
6075function attachWorkspace(_workspacePath, eclccPath) {
6076 var workspacePath = path.normalize(_workspacePath);
6077 if (!workspaceCache.has(workspacePath)) {
6078 var workspace = new Workspace(workspacePath, eclccPath);
6079 workspaceCache.set(workspacePath, workspace);
6080 workspace.refresh();
6081 }
6082 return workspaceCache.get(workspacePath);
6083}
6084function isQualifiedIDChar(lineText, charPos, reverse) {
6085 if (charPos < 0)
6086 return false;
6087 var testChar = lineText.charAt(charPos);
6088 return (reverse ? /[a-zA-Z\d_\.$]/ : /[a-zA-Z\d_]/).test(testChar);
6089}
6090function qualifiedIDBoundary(lineText, charPos, reverse) {
6091 while (isQualifiedIDChar(lineText, charPos, reverse)) {
6092 charPos += reverse ? -1 : 1;
6093 }
6094 return charPos + (reverse ? 1 : -1);
6095}
6096var MetaParser = /** @class */ (function (_super) {
6097 __extends(MetaParser, _super);
6098 function MetaParser() {
6099 var _this = _super !== null && _super.apply(this, arguments) || this;
6100 _this.sources = [];
6101 return _this;
6102 }
6103 MetaParser.prototype.endXMLNode = function (e) {
6104 switch (e.name) {
6105 case "Source":
6106 this.sources.push(e);
6107 break;
6108 default:
6109 break;
6110 }
6111 _super.prototype.endXMLNode.call(this, e);
6112 };
6113 return MetaParser;
6114}(util.SAXStackParser));
6115
6116var logger$3 = util.scopedLogger("clienttools/eclcc");
6117var exeExt = os.type() === "Windows_NT" ? ".exe" : "";
6118var Version = /** @class */ (function () {
6119 function Version(build) {
6120 this.prefix = "";
6121 this.major = 0;
6122 this.minor = 0;
6123 this.patch = 0;
6124 this.postfix = "";
6125 var parts = build.split(" ");
6126 if (parts.length) {
6127 var match = /(?:(\w+)_)?(\d+)\.(\d+)\.(\d+)(?:-(.*))?/.exec(parts[parts.length - 1]);
6128 if (match) {
6129 this.prefix = match[1] || "";
6130 this.major = +match[2] || 0;
6131 this.minor = +match[3] || 0;
6132 this.patch = +match[4] || 0;
6133 this.postfix = match[5] || "";
6134 }
6135 }
6136 }
6137 Version.prototype.parse = function (build) {
6138 };
6139 Version.prototype.exists = function () {
6140 return this.major !== 0 || this.minor !== 0 || this.patch !== 0 || this.postfix !== "";
6141 };
6142 Version.prototype.compare = function (other) {
6143 if (this.major > other.major)
6144 return 1;
6145 if (this.major < other.major)
6146 return -1;
6147 if (this.minor > other.minor)
6148 return 1;
6149 if (this.minor < other.minor)
6150 return -1;
6151 if (this.patch > other.patch)
6152 return 1;
6153 if (this.patch < other.patch)
6154 return -1;
6155 if (this.postfix === "" && other.postfix !== "")
6156 return 1;
6157 return this.postfix.localeCompare(other.postfix);
6158 };
6159 Version.prototype.toString = function () {
6160 return this.prefix + "_" + this.major + "." + this.minor + "." + this.patch + "-" + this.postfix;
6161 };
6162 return Version;
6163}());
6164var ERROR = "error";
6165var WARN = "warning";
6166var Errors = /** @class */ (function () {
6167 function Errors(checked) {
6168 this.errWarn = [];
6169 this.errOther = [];
6170 this._checked = checked;
6171 }
6172 Errors.prototype.checked = function () {
6173 return this._checked;
6174 };
6175 Errors.prototype.all = function () {
6176 return this.errWarn;
6177 };
6178 Errors.prototype.errors = function () {
6179 return this.errWarn.filter(function (e) { return e.severity === ERROR; });
6180 };
6181 Errors.prototype.hasError = function () {
6182 return this.errors().length > 0;
6183 };
6184 Errors.prototype.warnings = function () {
6185 return this.errWarn.filter(function (e) { return e.severity === WARN; });
6186 };
6187 Errors.prototype.hasWarning = function () {
6188 return this.warnings().length > 0;
6189 };
6190 Errors.prototype.info = function () {
6191 return this.errWarn.filter(function (e) { return [ERROR, WARN].indexOf(e.severity) < 0; });
6192 };
6193 Errors.prototype.hasOther = function () {
6194 return this.info().length > 0;
6195 };
6196 Errors.prototype.unknown = function () {
6197 return this.errOther;
6198 };
6199 Errors.prototype.hasUnknown = function () {
6200 return this.unknown().length > 0;
6201 };
6202 return Errors;
6203}());
6204var EclccErrors = /** @class */ (function (_super) {
6205 __extends(EclccErrors, _super);
6206 function EclccErrors(stdErr, checked) {
6207 var _this = _super.call(this, checked) || this;
6208 if (stdErr && stdErr.length) {
6209 for (var _i = 0, _a = stdErr.split(os.EOL); _i < _a.length; _i++) {
6210 var errLine = _a[_i];
6211 var match = /([a-zA-Z]:\\(?:[- \w\.\d]+\\)*(?:[- \w\.\d]+)?|(?:\/[\w\.\-]+)+)\((\d*),(\d*)\) ?: ?(error|warning|info) C(\d*) ?: ?(.*)/.exec(errLine);
6212 if (match) {
6213 var filePath = match[1], row = match[2], _col = match[3], severity = match[4], code = match[5], _msg = match[6];
6214 var line = +row;
6215 var col = +_col;
6216 var msg = code + ": " + _msg;
6217 _this.errWarn.push({ filePath: filePath, line: line, col: col, msg: msg, severity: severity });
6218 continue;
6219 }
6220 match = /(error|warning|info): (.*)/i.exec(errLine);
6221 if (match) {
6222 var severity = match[1], msg = match[2];
6223 _this.errWarn.push({ filePath: "", line: 0, col: 0, msg: msg, severity: severity });
6224 continue;
6225 }
6226 match = /\d error(s?), \d warning(s?)/.exec(errLine);
6227 if (match) {
6228 continue;
6229 }
6230 logger$3.warning("parseECLErrors: Unable to parse \"" + errLine + "\"");
6231 _this.errOther.push(errLine);
6232 }
6233 }
6234 _this._checked = checked;
6235 return _this;
6236 }
6237 return EclccErrors;
6238}(Errors));
6239var EnvchkErrors = /** @class */ (function (_super) {
6240 __extends(EnvchkErrors, _super);
6241 function EnvchkErrors(filePath, stdErr, checked) {
6242 var _this = _super.call(this, checked) || this;
6243 var content = fs.readFileSync(filePath, "utf8");
6244 content = content.replace("\r\n", "\n");
6245 _this._lines = content.split("\n");
6246 if (stdErr && stdErr.length) {
6247 for (var _i = 0, _a = stdErr.split(os.EOL); _i < _a.length; _i++) {
6248 var errLine = _a[_i];
6249 var match = /(Warning|Error) : Path\=(\S*?)(\[\S*\])? Message\=(.*)/.exec(errLine);
6250 if (match) {
6251 var severity = match[1], _path = match[2], _attr = match[3], _msg = match[4];
6252 var msg = _path + " " + (_attr ? _attr : "") + ": " + _msg;
6253 var _b = _this.locate(_path), line = _b[0], col = _b[1];
6254 _this.errWarn.push({ filePath: filePath, line: line, col: col, msg: msg, severity: severity });
6255 continue;
6256 }
6257 if (match) {
6258 continue;
6259 }
6260 logger$3.warning("parseECLErrors: Unable to parse \"" + errLine + "\"");
6261 _this.errOther.push(errLine);
6262 }
6263 }
6264 _this._checked = checked;
6265 return _this;
6266 }
6267 EnvchkErrors.prototype.locate = function (path) {
6268 var pathParts = path.split("/");
6269 if (pathParts.length && pathParts[0] === "") {
6270 pathParts.shift();
6271 }
6272 if (pathParts.length > 0) {
6273 var lineIdx = 0;
6274 for (var _i = 0, _a = this._lines; _i < _a.length; _i++) {
6275 var line = _a[_i];
6276 var testStr = "<" + pathParts[0];
6277 if (line.indexOf(testStr + " ") >= 0 || line.indexOf(testStr + ">") >= 0) {
6278 console.log(lineIdx, testStr);
6279 pathParts.shift();
6280 if (pathParts.length === 0) {
6281 return [lineIdx + 1, line.indexOf(testStr) + 1];
6282 }
6283 }
6284 ++lineIdx;
6285 }
6286 }
6287 return [0, 0];
6288 };
6289 return EnvchkErrors;
6290}(Errors));
6291function walkXmlJson$1(node, callback, stack) {
6292 stack = stack || [];
6293 stack.push(node);
6294 for (var key in node) {
6295 if (node.hasOwnProperty(key)) {
6296 var childNode = node[key];
6297 callback(key, childNode, stack);
6298 if (childNode instanceof Array) {
6299 childNode.forEach(function (child) {
6300 walkXmlJson$1(child, callback, stack);
6301 });
6302 }
6303 else if (typeof childNode === "object") {
6304 walkXmlJson$1(childNode, callback, stack);
6305 }
6306 }
6307 }
6308 stack.pop();
6309}
6310var LocalWorkunit = /** @class */ (function () {
6311 function LocalWorkunit(jsonWU) {
6312 this.jsonWU = jsonWU;
6313 }
6314 LocalWorkunit.prototype.bpGetValidLocations = function (filePath) {
6315 var retVal = [];
6316 if (util.exists("W_LOCAL.Graphs", this.jsonWU)) {
6317 var id_1 = "";
6318 walkXmlJson$1(this.jsonWU.W_LOCAL.Graphs, function (key, item, _stack) {
6319 if (key === "$" && item.id) {
6320 id_1 = item.id;
6321 }
6322 if (key === "$" && item.name === "definition") {
6323 var match = /([a-z,A-Z]:\\(?:[-\w\.\d]+\\)*(?:[-\w\.\d]+)?|(?:\/[\w\.\-]+)+)\((\d*),(\d*)\)/.exec(item.value);
6324 if (match) {
6325 var file = match[1], row = match[2], _col = match[3];
6326 var line = +row;
6327 var col = +_col;
6328 if (filePath === file) {
6329 retVal.push({ file: file, line: line, col: col, id: id_1 });
6330 }
6331 }
6332 }
6333 // console.log(`${key}: ` + JSON.stringify(item));
6334 });
6335 }
6336 return retVal;
6337 };
6338 return LocalWorkunit;
6339}());
6340var ClientTools = /** @class */ (function () {
6341 function ClientTools(eclccPath, cwd, includeFolders, legacyMode, args, version) {
6342 if (includeFolders === void 0) { includeFolders = []; }
6343 if (legacyMode === void 0) { legacyMode = false; }
6344 if (args === void 0) { args = []; }
6345 this._paths = {};
6346 this.eclccPath = eclccPath;
6347 this.binPath = path.dirname(this.eclccPath);
6348 this.envchkPath = path.join(this.binPath, "envchk" + exeExt);
6349 this.cwd = path.normalize(cwd || this.binPath);
6350 this.includeFolders = includeFolders;
6351 this._legacyMode = legacyMode;
6352 this._args = args;
6353 this._version = version;
6354 }
6355 ClientTools.prototype.clone = function (cwd, includeFolders, legacyMode, args) {
6356 if (legacyMode === void 0) { legacyMode = false; }
6357 if (args === void 0) { args = []; }
6358 return new ClientTools(this.eclccPath, cwd, includeFolders, legacyMode, args, this._version);
6359 };
6360 ClientTools.prototype.exists = function (filePath) {
6361 try {
6362 fs.accessSync(filePath);
6363 return true;
6364 }
6365 catch (e) { }
6366 return false;
6367 };
6368 ClientTools.prototype.args = function (additionalItems) {
6369 if (additionalItems === void 0) { additionalItems = []; }
6370 var retVal = __spreadArrays(this._args);
6371 if (this._legacyMode) {
6372 retVal.push("-legacy");
6373 }
6374 return retVal.concat(this.includeFolders.map(function (includePath) {
6375 return "-I" + path.normalize(includePath);
6376 })).concat(additionalItems);
6377 };
6378 ClientTools.prototype.version = function () {
6379 var _this = this;
6380 if (this._version) {
6381 return Promise.resolve(this._version);
6382 }
6383 return this.execFile(this.eclccPath, this.binPath, this.args(["--version"]), "eclcc", "Cannot find " + this.eclccPath).then(function (response) {
6384 _this._version = new Version(response.stdout);
6385 return _this._version;
6386 });
6387 };
6388 ClientTools.prototype.versionSync = function () {
6389 return this._version;
6390 };
6391 ClientTools.prototype.paths = function () {
6392 var _this = this;
6393 return this.execFile(this.eclccPath, this.cwd, this.args(["-showpaths"]), "eclcc", "Cannot find " + this.eclccPath).then(function (response) {
6394 if (response && response.stdout && response.stdout.length) {
6395 var paths = response.stdout.split(/\r?\n/);
6396 for (var _i = 0, paths_1 = paths; _i < paths_1.length; _i++) {
6397 var path_1 = paths_1[_i];
6398 var parts = path_1.split("=");
6399 if (parts.length === 2) {
6400 _this._paths[parts[0]] = parts[1];
6401 }
6402 }
6403 }
6404 return _this._paths;
6405 });
6406 };
6407 ClientTools.prototype.loadXMLDoc = function (filePath, removeOnRead) {
6408 return new Promise(function (resolve, _reject) {
6409 var fileData = fs.readFileSync(filePath, "ascii");
6410 var retVal = util.xml2json(fileData);
6411 if (removeOnRead) {
6412 fs.unlink(filePath, function (err) { });
6413 }
6414 resolve(retVal);
6415 });
6416 };
6417 ClientTools.prototype.createWU = function (filename) {
6418 var _this = this;
6419 var tmpName = tmp.tmpNameSync({ prefix: "eclcc-wu-tmp", postfix: "" });
6420 var args = ["-o" + tmpName, "-wu"].concat([filename]);
6421 return this.execFile(this.eclccPath, this.cwd, this.args(args), "eclcc", "Cannot find " + this.eclccPath).then(function (_response) {
6422 var xmlPath = path.normalize(tmpName + ".xml");
6423 var contentPromise = _this.exists(xmlPath) ? _this.loadXMLDoc(xmlPath, true) : Promise.resolve({});
6424 return contentPromise.then(function (content) {
6425 return new LocalWorkunit(content);
6426 });
6427 });
6428 };
6429 ClientTools.prototype.createArchive = function (filename) {
6430 var args = ["-E"].concat([filename]);
6431 return this.execFile(this.eclccPath, this.cwd, this.args(args), "eclcc", "Cannot find " + this.eclccPath).then(function (response) {
6432 return {
6433 content: response.stdout,
6434 err: new EclccErrors(response.stderr, [])
6435 };
6436 });
6437 };
6438 ClientTools.prototype.attachWorkspace = function () {
6439 return attachWorkspace(this.cwd);
6440 };
6441 ClientTools.prototype.fetchMeta = function (filePath) {
6442 return Promise.all([
6443 attachWorkspace(this.cwd),
6444 this.execFile(this.eclccPath, this.cwd, this.args(["-M", filePath]), "eclcc", "Cannot find " + this.eclccPath)
6445 ]).then(function (_a) {
6446 var metaWorkspace = _a[0], execFileResponse = _a[1];
6447 if (execFileResponse && execFileResponse.stdout && execFileResponse.stdout.length) {
6448 metaWorkspace.parseMetaXML(execFileResponse.stdout);
6449 }
6450 return metaWorkspace;
6451 });
6452 };
6453 ClientTools.prototype.syntaxCheck = function (filePath, args) {
6454 if (args === void 0) { args = ["-syntax"]; }
6455 return Promise.all([
6456 attachWorkspace(this.cwd),
6457 this.execFile(this.eclccPath, this.cwd, this.args(__spreadArrays(args, ["-M", filePath])), "eclcc", "Cannot find " + this.eclccPath)
6458 ]).then(function (_a) {
6459 var metaWorkspace = _a[0], execFileResponse = _a[1];
6460 var checked = [];
6461 if (execFileResponse && execFileResponse.stdout && execFileResponse.stdout.length) {
6462 checked = metaWorkspace.parseMetaXML(execFileResponse.stdout);
6463 }
6464 return new EclccErrors(execFileResponse ? execFileResponse.stderr : "", checked);
6465 });
6466 };
6467 ClientTools.prototype.envCheck = function (filePath, args) {
6468 if (args === void 0) { args = []; }
6469 return Promise.all([
6470 attachWorkspace(this.cwd),
6471 this.execFile(this.envchkPath, this.cwd, this.args(__spreadArrays(args, [filePath])), "envchk", "Cannot find " + this.envchkPath)
6472 ]).then(function (_a) {
6473 var metaWorkspace = _a[0], execFileResponse = _a[1];
6474 return new EnvchkErrors(filePath, execFileResponse ? execFileResponse.stderr : "", []);
6475 });
6476 };
6477 ClientTools.prototype.execFile = function (cmd, cwd, args, _toolName, _notFoundError) {
6478 return new Promise(function (resolve, _reject) {
6479 logger$3.debug(cmd + " " + args.join(" "));
6480 var child = cp.spawn(cmd, args, { cwd: cwd });
6481 var stdOut = "";
6482 var stdErr = "";
6483 child.stdout.on("data", function (data) {
6484 stdOut += data.toString();
6485 });
6486 child.stderr.on("data", function (data) {
6487 stdErr += data.toString();
6488 });
6489 child.on("close", function (_code, _signal) {
6490 resolve({
6491 stdout: stdOut.trim(),
6492 stderr: stdErr.trim()
6493 });
6494 });
6495 });
6496 };
6497 return ClientTools;
6498}());
6499function locateClientToolsInFolder(rootFolder, clientTools) {
6500 if (rootFolder) {
6501 var hpccSystemsFolder_1 = path.join(rootFolder, "HPCCSystems");
6502 if (fs.existsSync(hpccSystemsFolder_1) && fs.statSync(hpccSystemsFolder_1).isDirectory()) {
6503 if (os.type() !== "Windows_NT") {
6504 var eclccPath = path.join(hpccSystemsFolder_1, "bin", "eclcc");
6505 if (fs.existsSync(eclccPath)) {
6506 clientTools.push(new ClientTools(eclccPath));
6507 }
6508 }
6509 fs.readdirSync(hpccSystemsFolder_1).forEach(function (versionFolder) {
6510 var eclccPath = path.join(hpccSystemsFolder_1, versionFolder, "clienttools", "bin", "eclcc" + exeExt);
6511 if (fs.existsSync(eclccPath)) {
6512 var name_1 = path.basename(versionFolder);
6513 var version = new Version(name_1);
6514 if (version.exists()) {
6515 clientTools.push(new ClientTools(eclccPath));
6516 }
6517 }
6518 });
6519 }
6520 }
6521}
6522var allClientToolsCache;
6523function locateAllClientTools() {
6524 if (allClientToolsCache)
6525 return allClientToolsCache;
6526 var clientTools = [];
6527 switch (os.type()) {
6528 case "Windows_NT":
6529 var rootFolder86 = process.env["ProgramFiles(x86)"] || "";
6530 if (rootFolder86) {
6531 locateClientToolsInFolder(rootFolder86, clientTools);
6532 }
6533 var rootFolder = process.env["ProgramFiles"] || "";
6534 if (rootFolder) {
6535 locateClientToolsInFolder(rootFolder, clientTools);
6536 }
6537 if (!rootFolder86 && !rootFolder) {
6538 locateClientToolsInFolder("c:\\Program Files (x86)", clientTools);
6539 }
6540 break;
6541 case "Linux":
6542 case "Darwin":
6543 locateClientToolsInFolder("/opt", clientTools);
6544 break;
6545 default:
6546 break;
6547 }
6548 allClientToolsCache = Promise.all(clientTools.map(function (ct) { return ct.version(); })).then(function () {
6549 clientTools.sort(function (l, r) {
6550 return r.versionSync().compare(l.versionSync());
6551 });
6552 return clientTools;
6553 });
6554 return allClientToolsCache;
6555}
6556var eclccPathMsg = "";
6557function logEclccPath(eclccPath) {
6558 var msg = "Using eclccPath setting: " + eclccPath;
6559 if (eclccPathMsg !== msg) {
6560 logger$3.info(msg);
6561 eclccPathMsg = msg;
6562 }
6563}
6564function locateClientTools(overridePath, build, cwd, includeFolders, legacyMode) {
6565 if (overridePath === void 0) { overridePath = ""; }
6566 if (build === void 0) { build = ""; }
6567 if (cwd === void 0) { cwd = "."; }
6568 if (includeFolders === void 0) { includeFolders = []; }
6569 if (legacyMode === void 0) { legacyMode = false; }
6570 if (overridePath && fs.existsSync(overridePath)) {
6571 logEclccPath(overridePath);
6572 return Promise.resolve(new ClientTools(overridePath, cwd, includeFolders, legacyMode));
6573 }
6574 return locateAllClientTools().then(function (allClientToolsCache2) {
6575 if (!allClientToolsCache2.length) {
6576 throw new Error("Unable to locate ECL Client Tools.");
6577 }
6578 var buildVersion = new Version(build);
6579 var latest;
6580 var bestMajor;
6581 for (var _i = 0, allClientToolsCache2_1 = allClientToolsCache2; _i < allClientToolsCache2_1.length; _i++) {
6582 var ct = allClientToolsCache2_1[_i];
6583 var ctVersion = ct.versionSync();
6584 if (!latest)
6585 latest = ct;
6586 if (!bestMajor && buildVersion.major === ctVersion.major)
6587 bestMajor = ct;
6588 if (buildVersion.major === ctVersion.major && buildVersion.minor === ctVersion.minor)
6589 return ct.clone(cwd, includeFolders, legacyMode);
6590 }
6591 var best = bestMajor || latest;
6592 logEclccPath(best.eclccPath);
6593 return best.clone(cwd, includeFolders, legacyMode);
6594 });
6595}
6596
6597// tslint:disable: no-require-imports
6598util.root.DOMParser = xmldom.DOMParser;
6599if (typeof util.root.fetch === "undefined") {
6600 util.root.fetch = fetch$1;
6601 // tslint:disable-next-line: no-var-requires
6602 var https = require("https");
6603 util.root.fetch.__agent = new https.Agent({
6604 rejectUnauthorized: false
6605 });
6606}
6607if (typeof util.root.btoa === "undefined") {
6608 util.root.btoa = function (str) {
6609 return safeBuffer.Buffer.from(str || "", "utf8").toString("base64");
6610 };
6611}
6612
6613exports.AccountService = AccountService;
6614exports.Activity = Activity;
6615exports.Attr = Attr;
6616exports.Attribute = Attribute;
6617exports.BUILD_VERSION = BUILD_VERSION;
6618exports.BaseScope = BaseScope;
6619exports.ClientTools = ClientTools;
6620exports.Connection = Connection;
6621exports.DFUService = DFUService;
6622exports.Definition = Definition;
6623exports.ECLGraph = ECLGraph;
6624exports.ECLScope = ECLScope;
6625exports.ESPConnection = ESPConnection;
6626exports.ESPExceptions = ESPExceptions;
6627exports.EclService = EclService;
6628exports.EclccErrors = EclccErrors;
6629exports.EnvchkErrors = EnvchkErrors;
6630exports.Errors = Errors;
6631exports.Field = Field;
6632exports.File = File;
6633exports.Folder = Folder;
6634exports.GlobalResultCache = GlobalResultCache;
6635exports.GraphCache = GraphCache;
6636exports.Import = Import;
6637exports.LocalWorkunit = LocalWorkunit;
6638exports.LogicalFile = LogicalFile;
6639exports.LogicalFileCache = LogicalFileCache;
6640exports.Machine = Machine;
6641exports.MachineCache = MachineCache;
6642exports.MachineService = MachineService;
6643exports.PKG_NAME = PKG_NAME;
6644exports.PKG_VERSION = PKG_VERSION;
6645exports.Query = Query;
6646exports.Resource = Resource;
6647exports.Result = Result;
6648exports.ResultCache = ResultCache;
6649exports.SMCService = SMCService;
6650exports.Scope = Scope;
6651exports.ScopeEdge = ScopeEdge;
6652exports.ScopeGraph = ScopeGraph;
6653exports.ScopeSubgraph = ScopeSubgraph;
6654exports.ScopeVertex = ScopeVertex;
6655exports.Service = Service;
6656exports.Source = Source;
6657exports.SourceFile = SourceFile;
6658exports.Store = Store;
6659exports.StoreCache = StoreCache;
6660exports.StoreService = StoreService;
6661exports.TargetCluster = TargetCluster;
6662exports.TargetClusterCache = TargetClusterCache;
6663exports.Timer = Timer;
6664exports.Topology = Topology;
6665exports.TopologyService = TopologyService;
6666exports.ValueChangedMessage = ValueChangedMessage;
6667exports.Version = Version;
6668exports.Workspace = Workspace;
6669exports.Workunit = Workunit;
6670exports.WorkunitCache = WorkunitCache;
6671exports.WorkunitsService = WorkunitsService;
6672exports.XGMMLEdge = XGMMLEdge;
6673exports.XGMMLGraph = XGMMLGraph;
6674exports.XGMMLSubgraph = XGMMLSubgraph;
6675exports.XGMMLVertex = XGMMLVertex;
6676exports.XSDNode = XSDNode;
6677exports.XSDSchema = XSDSchema;
6678exports.XSDSimpleType = XSDSimpleType;
6679exports.XSDXMLNode = XSDXMLNode;
6680exports.attachWorkspace = attachWorkspace;
6681exports.createGraph = createGraph;
6682exports.createXGMMLGraph = createXGMMLGraph;
6683exports.defaultTargetCluster = defaultTargetCluster;
6684exports.deserializeResponse = deserializeResponse;
6685exports.get = get;
6686exports.hookSend = hookSend;
6687exports.instanceOfIConnection = instanceOfIConnection;
6688exports.instanceOfIOptions = instanceOfIOptions;
6689exports.isArray = isArray;
6690exports.isWUInfoWorkunit = isWUInfoWorkunit;
6691exports.isWUQueryECLWorkunit = isWUQueryECLWorkunit;
6692exports.jsonp = jsonp;
6693exports.locateAllClientTools = locateAllClientTools;
6694exports.locateClientTools = locateClientTools;
6695exports.parseXSD = parseXSD;
6696exports.parseXSD2 = parseXSD2;
6697exports.post = post;
6698exports.qualifiedIDBoundary = qualifiedIDBoundary;
6699exports.send = send;
6700exports.serializeRequest = serializeRequest;
6701exports.setTransportFactory = setTransportFactory;
6702exports.targetClusters = targetClusters;
6703exports.walkXmlJson = walkXmlJson$1;
6704//# sourceMappingURL=index.node.js.map