UNPKG

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