UNPKG

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