@hpcc-js/comms 3.5.1 → 3.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
4
4
  import { scopedLogger, join, promiseTimeout, exists, deepMixin, xml2json, StateObject, Cache, Graph, Subgraph as Subgraph$1, Vertex as Vertex$1, Edge as Edge$1, SAXStackParser, Stack, espTime2Seconds as espTime2Seconds$1, deepMixinT, XMLNode, debounce, Message, Dispatch } from "@hpcc-js/util";
5
- const PKG_NAME = "@hpcc-js/comms", PKG_VERSION = "3.5.0", BUILD_VERSION = "3.6.0", logger$5 = scopedLogger("comms/connection.ts");
5
+ const PKG_NAME = "@hpcc-js/comms", PKG_VERSION = "3.5.2", BUILD_VERSION = "3.6.2", logger$6 = scopedLogger("comms/connection.ts");
6
6
  function instanceOfIOptions(object) {
7
7
  return "baseUrl" in object;
8
8
  }
@@ -48,7 +48,7 @@ function jsonp(opts, action, request = {}, responseType = "json", header) {
48
48
  let url = join(opts.baseUrl, action);
49
49
  url += url.indexOf("?") >= 0 ? "&" : "?", script.src = url + "jsonp=" + callbackName + "&" + serializeRequest(request, opts.encodeRequest), document.body.appendChild(script);
50
50
  const progress = setInterval(function() {
51
- respondedTimeout <= 0 ? clearInterval(progress) : (respondedTimeout -= respondedTick, respondedTimeout <= 0 ? (clearInterval(progress), logger$5.error("Request timeout: " + script.src), doCallback(), reject(Error("Request timeout: " + script.src))) : logger$5.debug("Request pending (" + respondedTimeout / 1e3 + " sec): " + script.src));
51
+ respondedTimeout <= 0 ? clearInterval(progress) : (respondedTimeout -= respondedTick, respondedTimeout <= 0 ? (clearInterval(progress), logger$6.error("Request timeout: " + script.src), doCallback(), reject(Error("Request timeout: " + script.src))) : logger$6.debug("Request pending (" + respondedTimeout / 1e3 + " sec): " + script.src));
52
52
  }, respondedTick);
53
53
  function doCallback() {
54
54
  delete window[callbackName], document.body.removeChild(script);
@@ -581,23 +581,68 @@ class AccountService extends AccountServiceBase {
581
581
  }
582
582
  class CloudServiceBase extends Service {
583
583
  constructor(optsConnection) {
584
- super(optsConnection, "WsCloud", "1");
584
+ super(optsConnection, "WsCloud", "1.02");
585
585
  }
586
586
  GetPODs(request) {
587
- return this._connection.send("GetPODs", request);
587
+ return this._connection.send("GetPODs", request, "json", !1, void 0, "GetPODsResponse");
588
588
  }
589
- Ping(request) {
590
- return this._connection.send("Ping", request);
589
+ GetServices(request) {
590
+ return this._connection.send("GetServices", request, "json", !1, void 0, "GetServicesResponse");
591
591
  }
592
+ Ping(request) {
593
+ return this._connection.send("Ping", request, "json", !1, void 0, "WsCloudPingResponse");
594
+ }
595
+ }
596
+ const logger$5 = scopedLogger("@hpcc-js/comms/services/wsCloud.ts");
597
+ function isGetPODsResponse_v1_02(response) {
598
+ return (response == null ? void 0 : response.Pods) !== void 0;
599
+ }
600
+ function mapPorts(pod) {
601
+ var _a, _b;
602
+ return ((_b = (_a = pod.spec) == null ? void 0 : _a.containers) == null ? void 0 : _b.reduce((prev, curr) => {
603
+ var _a2;
604
+ return (_a2 = curr.ports) == null || _a2.forEach((p) => {
605
+ prev.push({
606
+ ContainerPort: p.containerPort,
607
+ Name: p.name,
608
+ Protocol: p.protocol
609
+ });
610
+ }), prev;
611
+ }, [])) ?? [];
612
+ }
613
+ function mapPods(pods) {
614
+ return pods.filter((pod) => {
615
+ var _a;
616
+ const labels = ((_a = pod == null ? void 0 : pod.metadata) == null ? void 0 : _a.labels) ?? {};
617
+ return labels.hasOwnProperty("app.kubernetes.io/part-of") && labels["app.kubernetes.io/part-of"] === "HPCC-Platform";
618
+ }).map((pod) => {
619
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
620
+ const started = new Date((_a = pod.metadata) == null ? void 0 : _a.creationTimestamp);
621
+ return {
622
+ Name: pod.metadata.name,
623
+ Status: (_b = pod.status) == null ? void 0 : _b.phase,
624
+ CreationTimestamp: started.toISOString(),
625
+ ContainerName: ((_d = (_c = pod.status) == null ? void 0 : _c.containerStatuses) == null ? void 0 : _d.reduce((prev, curr) => (curr.name && prev.push(curr.name), prev), []).join(", ")) ?? "",
626
+ ContainerCount: ((_f = (_e = pod.spec) == null ? void 0 : _e.containers) == null ? void 0 : _f.length) ?? 0,
627
+ ContainerReadyCount: (_h = (_g = pod.status) == null ? void 0 : _g.containerStatuses) == null ? void 0 : _h.reduce((prev, curr) => prev + (curr.ready ? 1 : 0), 0),
628
+ ContainerRestartCount: (_j = (_i = pod.status) == null ? void 0 : _i.containerStatuses) == null ? void 0 : _j.reduce((prev, curr) => prev + curr.restartCount, 0),
629
+ Ports: {
630
+ Port: mapPorts(pod)
631
+ }
632
+ };
633
+ });
592
634
  }
593
635
  class CloudService extends CloudServiceBase {
594
636
  getPODs() {
595
637
  return super.GetPODs({}).then((response) => {
638
+ var _a;
639
+ if (isGetPODsResponse_v1_02(response))
640
+ return ((_a = response.Pods) == null ? void 0 : _a.Pod) ?? [];
596
641
  try {
597
642
  const obj = typeof response.Result == "string" ? JSON.parse(response.Result) : response.Result;
598
- return (obj == null ? void 0 : obj.items) ?? [];
599
- } catch {
600
- return [];
643
+ return mapPods((obj == null ? void 0 : obj.items) ?? []);
644
+ } catch (error) {
645
+ return logger$5.error(`Error parsing V1Pods json '${error instanceof Error ? error.message : String(error)}'`), [];
601
646
  }
602
647
  });
603
648
  }
@@ -970,24 +1015,29 @@ class ElkService extends ElkServiceBase {
970
1015
  var WsLogaccess;
971
1016
  ((WsLogaccess2) => {
972
1017
  ((LogColumnType2) => {
973
- LogColumnType2.global = "global", LogColumnType2.workunits = "workunits", LogColumnType2.components = "components", LogColumnType2.audience = "audience", LogColumnType2.class = "class", LogColumnType2.instance = "instance", LogColumnType2.node = "node", LogColumnType2.message = "message", LogColumnType2.logid = "logid", LogColumnType2.processid = "processid", LogColumnType2.threadid = "threadid", LogColumnType2.timestamp = "timestamp", LogColumnType2.pod = "pod";
1018
+ LogColumnType2.global = "global", LogColumnType2.workunits = "workunits", LogColumnType2.components = "components", LogColumnType2.audience = "audience", LogColumnType2.class = "class", LogColumnType2.instance = "instance", LogColumnType2.node = "node", LogColumnType2.message = "message", LogColumnType2.logid = "logid", LogColumnType2.processid = "processid", LogColumnType2.threadid = "threadid", LogColumnType2.timestamp = "timestamp", LogColumnType2.pod = "pod", LogColumnType2.traceid = "traceid", LogColumnType2.spanid = "spanid";
974
1019
  })(WsLogaccess2.LogColumnType || (WsLogaccess2.LogColumnType = {})), ((LogColumnValueType2) => {
975
- LogColumnValueType2.string = "string", LogColumnValueType2.numeric = "numeric", LogColumnValueType2.datetime = "datetime", LogColumnValueType2.enum = "enum";
1020
+ LogColumnValueType2.string = "string", LogColumnValueType2.numeric = "numeric", LogColumnValueType2.datetime = "datetime", LogColumnValueType2.enum = "enum", LogColumnValueType2.epoch = "epoch";
976
1021
  })(WsLogaccess2.LogColumnValueType || (WsLogaccess2.LogColumnValueType = {})), ((LogAccessType2) => {
977
- LogAccessType2[LogAccessType2.All = 0] = "All", LogAccessType2[LogAccessType2.ByJobID = 1] = "ByJobID", LogAccessType2[LogAccessType2.ByComponent = 2] = "ByComponent", LogAccessType2[LogAccessType2.ByLogType = 3] = "ByLogType", LogAccessType2[LogAccessType2.ByTargetAudience = 4] = "ByTargetAudience", LogAccessType2[LogAccessType2.BySourceInstance = 5] = "BySourceInstance", LogAccessType2[LogAccessType2.BySourceNode = 6] = "BySourceNode", LogAccessType2[LogAccessType2.ByFieldName = 7] = "ByFieldName", LogAccessType2[LogAccessType2.ByPod = 8] = "ByPod";
978
- })(WsLogaccess2.LogAccessType || (WsLogaccess2.LogAccessType = {})), ((LogAccessFilterOperator2) => {
1022
+ LogAccessType2[LogAccessType2.All = 0] = "All", LogAccessType2[LogAccessType2.ByJobID = 1] = "ByJobID", LogAccessType2[LogAccessType2.ByComponent = 2] = "ByComponent", LogAccessType2[LogAccessType2.ByLogType = 3] = "ByLogType", LogAccessType2[LogAccessType2.ByTargetAudience = 4] = "ByTargetAudience", LogAccessType2[LogAccessType2.BySourceInstance = 5] = "BySourceInstance", LogAccessType2[LogAccessType2.BySourceNode = 6] = "BySourceNode", LogAccessType2[LogAccessType2.ByFieldName = 7] = "ByFieldName", LogAccessType2[LogAccessType2.ByPod = 8] = "ByPod", LogAccessType2[LogAccessType2.ByTraceID = 9] = "ByTraceID", LogAccessType2[LogAccessType2.BySpanID = 10] = "BySpanID";
1023
+ })(WsLogaccess2.LogAccessType || (WsLogaccess2.LogAccessType = {})), ((LogAccessStatusCode2) => {
1024
+ LogAccessStatusCode2[LogAccessStatusCode2.Success = 0] = "Success", LogAccessStatusCode2[LogAccessStatusCode2.Warning = 1] = "Warning", LogAccessStatusCode2[LogAccessStatusCode2.Fail = 2] = "Fail";
1025
+ })(WsLogaccess2.LogAccessStatusCode || (WsLogaccess2.LogAccessStatusCode = {})), ((LogAccessFilterOperator2) => {
979
1026
  LogAccessFilterOperator2[LogAccessFilterOperator2.NONE = 0] = "NONE", LogAccessFilterOperator2[LogAccessFilterOperator2.AND = 1] = "AND", LogAccessFilterOperator2[LogAccessFilterOperator2.OR = 2] = "OR";
980
1027
  })(WsLogaccess2.LogAccessFilterOperator || (WsLogaccess2.LogAccessFilterOperator = {})), ((LogSelectColumnMode2) => {
981
1028
  LogSelectColumnMode2[LogSelectColumnMode2.MIN = 0] = "MIN", LogSelectColumnMode2[LogSelectColumnMode2.DEFAULT = 1] = "DEFAULT", LogSelectColumnMode2[LogSelectColumnMode2.ALL = 2] = "ALL", LogSelectColumnMode2[LogSelectColumnMode2.CUSTOM = 3] = "CUSTOM";
982
1029
  })(WsLogaccess2.LogSelectColumnMode || (WsLogaccess2.LogSelectColumnMode = {})), ((SortColumType2) => {
983
- SortColumType2[SortColumType2.ByDate = 0] = "ByDate", SortColumType2[SortColumType2.ByJobID = 1] = "ByJobID", SortColumType2[SortColumType2.ByComponent = 2] = "ByComponent", SortColumType2[SortColumType2.ByLogType = 3] = "ByLogType", SortColumType2[SortColumType2.ByTargetAudience = 4] = "ByTargetAudience", SortColumType2[SortColumType2.BySourceInstance = 5] = "BySourceInstance", SortColumType2[SortColumType2.BySourceNode = 6] = "BySourceNode", SortColumType2[SortColumType2.ByFieldName = 7] = "ByFieldName", SortColumType2[SortColumType2.ByPod = 8] = "ByPod";
1030
+ SortColumType2[SortColumType2.ByDate = 0] = "ByDate", SortColumType2[SortColumType2.ByJobID = 1] = "ByJobID", SortColumType2[SortColumType2.ByComponent = 2] = "ByComponent", SortColumType2[SortColumType2.ByLogType = 3] = "ByLogType", SortColumType2[SortColumType2.ByTargetAudience = 4] = "ByTargetAudience", SortColumType2[SortColumType2.BySourceInstance = 5] = "BySourceInstance", SortColumType2[SortColumType2.BySourceNode = 6] = "BySourceNode", SortColumType2[SortColumType2.ByFieldName = 7] = "ByFieldName", SortColumType2[SortColumType2.ByPod = 8] = "ByPod", SortColumType2[SortColumType2.ByTraceID = 9] = "ByTraceID", SortColumType2[SortColumType2.BySpanID = 10] = "BySpanID";
984
1031
  })(WsLogaccess2.SortColumType || (WsLogaccess2.SortColumType = {})), ((SortDirection2) => {
985
1032
  SortDirection2[SortDirection2.ASC = 0] = "ASC", SortDirection2[SortDirection2.DSC = 1] = "DSC";
986
1033
  })(WsLogaccess2.SortDirection || (WsLogaccess2.SortDirection = {}));
987
1034
  })(WsLogaccess || (WsLogaccess = {}));
988
1035
  class LogaccessServiceBase extends Service {
989
1036
  constructor(optsConnection) {
990
- super(optsConnection, "ws_logaccess", "1.05");
1037
+ super(optsConnection, "ws_logaccess", "1.08");
1038
+ }
1039
+ GetHealthReport(request) {
1040
+ return this._connection.send("GetHealthReport", request, "json", !1, void 0, "GetHealthReportResponse");
991
1041
  }
992
1042
  GetLogAccessInfo(request) {
993
1043
  return this._connection.send("GetLogAccessInfo", request, "json", !1, void 0, "GetLogAccessInfoResponse");
@@ -1643,7 +1693,7 @@ var WsWorkunits;
1643
1693
  })(WsWorkunits || (WsWorkunits = {}));
1644
1694
  class WorkunitsServiceBase extends Service {
1645
1695
  constructor(optsConnection) {
1646
- super(optsConnection, "WsWorkunits", "2");
1696
+ super(optsConnection, "WsWorkunits", "2.02");
1647
1697
  }
1648
1698
  GVCAjaxGraph(request) {
1649
1699
  return this._connection.send("GVCAjaxGraph", request, "json", !1, void 0, "GVCAjaxGraphResponse");
@@ -2095,7 +2145,7 @@ function identity(x) {
2095
2145
  }
2096
2146
  var map = Array.prototype.map, prefixes = ["y", "z", "a", "f", "p", "n", "µ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y"];
2097
2147
  function formatLocale$1(locale2) {
2098
- var group = locale2.grouping === void 0 || locale2.thousands === void 0 ? identity : formatGroup(map.call(locale2.grouping, Number), locale2.thousands + ""), currencyPrefix = locale2.currency === void 0 ? "" : locale2.currency[0] + "", currencySuffix = locale2.currency === void 0 ? "" : locale2.currency[1] + "", decimal = locale2.decimal === void 0 ? "." : locale2.decimal + "", numerals = locale2.numerals === void 0 ? identity : formatNumerals(map.call(locale2.numerals, String)), percent = locale2.percent === void 0 ? "%" : locale2.percent + "", minus = locale2.minus === void 0 ? "-" : locale2.minus + "", nan = locale2.nan === void 0 ? "NaN" : locale2.nan + "";
2148
+ var group = locale2.grouping === void 0 || locale2.thousands === void 0 ? identity : formatGroup(map.call(locale2.grouping, Number), locale2.thousands + ""), currencyPrefix = locale2.currency === void 0 ? "" : locale2.currency[0] + "", currencySuffix = locale2.currency === void 0 ? "" : locale2.currency[1] + "", decimal = locale2.decimal + "", numerals = locale2.numerals === void 0 ? identity : formatNumerals(map.call(locale2.numerals, String)), percent = locale2.percent === void 0 ? "%" : locale2.percent + "", minus = locale2.minus + "", nan = locale2.nan === void 0 ? "NaN" : locale2.nan + "";
2099
2149
  function newFormat(specifier) {
2100
2150
  specifier = formatSpecifier(specifier);
2101
2151
  var fill = specifier.fill, align = specifier.align, sign = specifier.sign, symbol = specifier.symbol, zero = specifier.zero, width = specifier.width, comma = specifier.comma, precision = specifier.precision, trim = specifier.trim, type = specifier.type;
@@ -4097,9 +4147,13 @@ class Workunit extends StateObject {
4097
4147
  case "cost":
4098
4148
  props[scopeProperty.Name] = +scopeProperty.RawValue / 1e6;
4099
4149
  break;
4100
- case "cpu":
4101
- case "skw":
4102
4150
  case "node":
4151
+ props[scopeProperty.Name] = +scopeProperty.RawValue;
4152
+ break;
4153
+ case "skw":
4154
+ props[scopeProperty.Name] = +scopeProperty.RawValue;
4155
+ break;
4156
+ case "cpu":
4103
4157
  case "ppm":
4104
4158
  case "ip":
4105
4159
  case "cy":
@@ -4295,7 +4349,7 @@ class Workunit extends StateObject {
4295
4349
  }
4296
4350
  // WsWorkunits passthroughs ---
4297
4351
  WUQuery(_request = {}) {
4298
- return this.connection.WUQuery({ ..._request, Wuid: this.Wuid }).then((response) => (this.set(response.Workunits.ECLWorkunit[0]), response)).catch((e) => {
4352
+ return this.connection.WUQuery({ ..._request, Wuid: this.Wuid }).then((response) => (response.Workunits.ECLWorkunit.length === 0 ? (this.clearState(this.Wuid), this.set("StateID", WUStateID.NotFound)) : this.set(response.Workunits.ECLWorkunit[0]), response)).catch((e) => {
4299
4353
  if (!e.Exception.some((exception) => exception.Code === 20081 ? (this.clearState(this.Wuid), this.set("StateID", WUStateID.NotFound), !0) : !1))
4300
4354
  throw logger$3.warning(`Unexpected ESP exception: ${e.message}`), e;
4301
4355
  return {};