@hpcc-js/comms 3.12.1 → 3.14.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hpcc-js/comms",
3
- "version": "3.12.1",
3
+ "version": "3.14.0",
4
4
  "description": "hpcc-js - Communications",
5
5
  "type": "module",
6
6
  "main": "./dist/node/index.cjs",
@@ -74,15 +74,13 @@
74
74
  "wsdl-all": "npm-run-all --aggregate-output -c --serial build --parallel wsdl-*"
75
75
  },
76
76
  "dependencies": {
77
- "@hpcc-js/util": "^3.4.3",
77
+ "@hpcc-js/util": "^3.4.4",
78
78
  "@xmldom/xmldom": "0.9.8",
79
- "abort-controller": "3.0.0",
80
- "node-fetch": "3.3.2",
81
- "undici": "7.16.0"
79
+ "undici": "7.18.2"
82
80
  },
83
81
  "devDependencies": {
84
- "@hpcc-js/ddl-shim": "^3.2.2",
85
- "@hpcc-js/esbuild-plugins": "^1.7.0",
82
+ "@hpcc-js/ddl-shim": "^3.2.3",
83
+ "@hpcc-js/esbuild-plugins": "^1.8.0",
86
84
  "@kubernetes/client-node": "1.4.0",
87
85
  "@types/d3-request": "1.0.9",
88
86
  "@types/d3-time-format": "2.3.4",
@@ -112,5 +110,5 @@
112
110
  "esp",
113
111
  "HPCC-Platform"
114
112
  ],
115
- "gitHead": "0289b8552e19395a8da9b70a154821cf70ce42e7"
113
+ "gitHead": "4b76aa36763923096cd3ff7afed75e054ea33197"
116
114
  }
@@ -326,6 +326,7 @@ export class Workunit extends StateObject<UWorkunitState, IWorkunitState> implem
326
326
  get FileAccessCost(): number { return this.get("FileAccessCost"); }
327
327
  get NoAccess(): boolean { return this.get("NoAccess"); }
328
328
  get ECLWUProcessList(): WsWorkunits.ECLWUProcessList { return this.get("ECLWUProcessList"); }
329
+ get CostSavingPotential(): number { return this.get("CostSavingPotential"); }
329
330
 
330
331
  // Factories ---
331
332
  static create(optsConnection: IOptions | IConnection): Promise<Workunit> {
package/src/index.node.ts CHANGED
@@ -3,38 +3,22 @@ import { root } from "@hpcc-js/util";
3
3
  import { DOMParser } from "@xmldom/xmldom";
4
4
  root.DOMParser = DOMParser;
5
5
 
6
- // fetch polyfill ---
7
- import fetch, { Headers, Request, Response, } from "node-fetch";
8
-
6
+ // fetch setup for Node.js ---
9
7
  import * as https from "node:https";
10
8
  import { Buffer } from "node:buffer";
11
9
  import { Agent, setGlobalDispatcher } from "undici";
12
10
 
13
- if (typeof root.fetch === "undefined") {
14
- // NodeJS < v18 ---
15
- root.fetch = fetch;
16
- root.Headers = Headers;
17
- root.Request = Request;
18
- root.Response = Response;
19
- root.fetch.__rejectUnauthorizedAgent = new https.Agent({
20
- rejectUnauthorized: false
21
- });
22
- } else {
23
- // NodeJS >= v18 ---
24
- root.fetch.__defaultAgent = new Agent();
25
- root.fetch.__rejectUnauthorizedAgent = new Agent({
26
- connect: {
27
- rejectUnauthorized: false
28
- }
29
- });
30
- root.fetch.__setGlobalDispatcher = setGlobalDispatcher;
31
- }
32
-
33
- // AbortController polyfill ---
34
- import AbortController from "abort-controller";
35
- if (typeof root.AbortController === "undefined") {
36
- root.AbortController = AbortController;
11
+ // NodeJS >= v18 has native fetch ---
12
+ if (root.fetch === undefined) {
13
+ throw new Error("@hpcc-js/comms requires Node.js >= 18.0.0 for native fetch support");
37
14
  }
15
+ root.fetch.__defaultAgent = new Agent();
16
+ root.fetch.__rejectUnauthorizedAgent = new Agent({
17
+ connect: {
18
+ rejectUnauthorized: false
19
+ }
20
+ });
21
+ root.fetch.__setGlobalDispatcher = setGlobalDispatcher;
38
22
 
39
23
  import { trustwave } from "./pem/trustwave.ts";
40
24
 
@@ -1,10 +1,25 @@
1
- import { SMCServiceBase, WsSMC } from "./wsdl/WsSMC/v1.28/WsSMC.ts";
1
+ import { timeParse } from "d3-time-format";
2
+ import { SMCServiceBase, WsSMC } from "./wsdl/WsSMC/v1.29/WsSMC.ts";
2
3
  import { IOptions } from "../connection.ts";
3
4
 
4
5
  export {
5
6
  WsSMC
6
7
  };
7
8
 
9
+ const dateParser = timeParse("%Y%m%d%H");
10
+
11
+ function isNumeric(value: any): boolean {
12
+ return typeof value === "number" || (typeof value === "string" && value.trim() !== "" && !isNaN(+value));
13
+ }
14
+
15
+ export interface NormalisedGlobalMetric {
16
+ Category: string;
17
+ Start: Date;
18
+ End: Date;
19
+ dimensions: { [key: string]: any };
20
+ stats: { [key: string]: any };
21
+ }
22
+
8
23
  export class SMCService extends SMCServiceBase {
9
24
 
10
25
  connectionOptions(): IOptions {
@@ -21,4 +36,45 @@ export class SMCService extends SMCServiceBase {
21
36
  };
22
37
  });
23
38
  }
39
+
40
+ protected parseGlobalMetric(name: string, value: any): any {
41
+ // Known Prefixes: Cost, Critical, Definition, Disk, Distribute, Ecl, Enum, Id, Interface, Is, Library, Load, Match, Meta, Num, Original, Output, Patch, Per, Persist, Predicted, Record, Section, Service, Signed, Size, Source, Spill, Target, Time, Updated, When
42
+ if (name.startsWith("Cost")) {
43
+ return +value / 1000000;
44
+ } else if (name.startsWith("Date")) {
45
+ return dateParser(value);
46
+ } else if (name.startsWith("Num")) {
47
+ return +value;
48
+ } else if (name.startsWith("Time")) {
49
+ return +value / 1000000000;
50
+ } else if (name.startsWith("When")) {
51
+ return new Date(+value / 1000).toISOString();
52
+ } else if (isNumeric(value)) {
53
+ return +value;
54
+ }
55
+ return value;
56
+ }
57
+
58
+ GetNormalisedGlobalMetrics(request: Partial<WsSMC.GetGlobalMetrics>): Promise<NormalisedGlobalMetric[]> {
59
+ return super.GetGlobalMetrics(request).then(response => {
60
+ const retVal: NormalisedGlobalMetric[] = [];
61
+ for (const metric of response?.GlobalMetrics?.GlobalMetric || []) {
62
+ const row: NormalisedGlobalMetric = {
63
+ Category: metric.Category,
64
+ Start: this.parseGlobalMetric("Date", metric.DateTimeRange?.Start),
65
+ End: this.parseGlobalMetric("Date", metric.DateTimeRange?.End),
66
+ dimensions: {},
67
+ stats: {}
68
+ };
69
+ for (const dimension of metric.Dimensions?.Dimension || []) {
70
+ row.dimensions[dimension.Name] = dimension.Value;
71
+ }
72
+ for (const stat of metric.Stats?.Stat || []) {
73
+ row.stats[stat.Name] = this.parseGlobalMetric(stat.Name, stat.Value);
74
+ }
75
+ retVal.push(row);
76
+ }
77
+ return retVal;
78
+ });
79
+ }
24
80
  }
@@ -1,5 +1,5 @@
1
1
  import { deepMixin, xml2json, XMLNode } from "@hpcc-js/util";
2
- import { WsWorkunits, WorkunitsServiceBase } from "./wsdl/WsWorkunits/v2.02/WsWorkunits.ts";
2
+ import { WsWorkunits, WorkunitsServiceBase } from "./wsdl/WsWorkunits/v2.03/WsWorkunits.ts";
3
3
  import { IConnection, IOptions } from "../connection.ts";
4
4
 
5
5
  export {