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