@hpcc-js/comms 2.88.1 → 2.90.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/dist/index.es6.js +937 -125
- package/dist/index.es6.js.map +1 -1
- package/dist/index.js +930 -114
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/index.node.js +930 -114
- package/dist/index.node.js.map +1 -1
- package/dist/index.node.min.js +1 -1
- package/dist/index.node.min.js.map +1 -1
- package/lib-es6/__package__.js +2 -2
- package/lib-es6/ecl/query.js +68 -0
- package/lib-es6/ecl/query.js.map +1 -1
- package/lib-es6/ecl/queryGraph.js +759 -0
- package/lib-es6/ecl/queryGraph.js.map +1 -0
- package/lib-es6/ecl/workunit.js +121 -112
- package/lib-es6/ecl/workunit.js.map +1 -1
- package/package.json +2 -2
- package/src/__package__.ts +2 -2
- package/src/ecl/query.ts +66 -1
- package/src/ecl/queryGraph.ts +809 -0
- package/src/ecl/workunit.ts +130 -116
- package/types/__package__.d.ts +2 -2
- package/types/ecl/query.d.ts +12 -1
- package/types/ecl/query.d.ts.map +1 -1
- package/types/ecl/queryGraph.d.ts +101 -0
- package/types/ecl/queryGraph.d.ts.map +1 -0
- package/types/ecl/workunit.d.ts +17 -3
- package/types/ecl/workunit.d.ts.map +1 -1
- package/types-3.4/__package__.d.ts +2 -2
- package/types-3.4/ecl/query.d.ts +12 -1
- package/types-3.4/ecl/queryGraph.d.ts +101 -0
- package/types-3.4/ecl/workunit.d.ts +17 -3
package/src/ecl/query.ts
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import { Cache, StateObject, scopedLogger } from "@hpcc-js/util";
|
|
2
|
+
import { format as d3Format } from "d3-format";
|
|
2
3
|
import { IConnection, IOptions } from "../connection";
|
|
3
4
|
import { EclService, IWsEclRequest, IWsEclResponse, IWsEclResult } from "../services/wsEcl";
|
|
4
|
-
import { WorkunitsService, WUQueryDetails } from "../services/wsWorkunits";
|
|
5
|
+
import { WorkunitsService, WUDetails, WUQueryDetails, WUDetailsMeta } from "../services/wsWorkunits";
|
|
5
6
|
import { Topology } from "./topology";
|
|
7
|
+
import { Workunit, IScope } from "./workunit";
|
|
8
|
+
import { QueryGraph } from "./queryGraph";
|
|
9
|
+
|
|
10
|
+
export { QueryGraph };
|
|
6
11
|
|
|
7
12
|
const logger = scopedLogger("@hpcc-js/comms/ecl/query.ts");
|
|
8
13
|
|
|
14
|
+
const siFormatter = d3Format("~s");
|
|
15
|
+
|
|
16
|
+
function isNumber(n) {
|
|
17
|
+
return !isNaN(parseFloat(n)) && !isNaN(n - 0);
|
|
18
|
+
}
|
|
9
19
|
export interface QueryEx extends WUQueryDetails.Response {
|
|
10
20
|
BaseUrl: string;
|
|
11
21
|
}
|
|
@@ -134,6 +144,61 @@ export class Query extends StateObject<QueryEx, QueryEx> implements QueryEx {
|
|
|
134
144
|
return this.wsWorkunitsService.WUQueryGetSummaryStats({ Target: this.QuerySet, QueryId: this.QueryId });
|
|
135
145
|
}
|
|
136
146
|
|
|
147
|
+
fetchGraph(GraphName: string = "", SubGraphId: string = ""): Promise<QueryGraph> {
|
|
148
|
+
return this.wsWorkunitsService.WUQueryGetGraph({ Target: this.QuerySet, QueryId: this.QueryId, GraphName, SubGraphId }).then(response => {
|
|
149
|
+
const graph = new QueryGraph();
|
|
150
|
+
let first = true;
|
|
151
|
+
for (const graphItem of response?.Graphs?.ECLGraphEx || []) {
|
|
152
|
+
if (first) {
|
|
153
|
+
graph.load(graphItem.Graph);
|
|
154
|
+
first = false;
|
|
155
|
+
} else {
|
|
156
|
+
graph.merge(graphItem.Graph);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return graph;
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
fetchDetailsNormalized(request: Partial<WUDetails.Request> = {}): Promise<{ meta: WUDetailsMeta.Response | undefined, columns: { [id: string]: any } | undefined, data: IScope[] | undefined }> {
|
|
164
|
+
const wu = Workunit.attach(this.wsWorkunitsService, this.Wuid);
|
|
165
|
+
if (wu) {
|
|
166
|
+
return Promise.all([this.fetchGraph(), wu.fetchDetailsMeta(), wu.fetchDetailsRaw(request)]).then(promises => {
|
|
167
|
+
const graph = promises[0];
|
|
168
|
+
const meta = promises[1];
|
|
169
|
+
const metrics: WUDetails.Scope[] = promises[2];
|
|
170
|
+
const data = metrics.map(metric => {
|
|
171
|
+
if (metric.Id[0] === "a" || metric.Id[0] === "e") {
|
|
172
|
+
const item = graph.idx[metric.Id.substring(1)];
|
|
173
|
+
for (const key in item) {
|
|
174
|
+
if (key.charAt(0) !== "_" && key.charAt(0) === key.charAt(0).toUpperCase() && (typeof item[key] === "string" || typeof item[key] === "number" || typeof item[key] === "boolean")) {
|
|
175
|
+
|
|
176
|
+
if (!metric.Properties.Property.some(row => row.Name === key)) {
|
|
177
|
+
const isNum = isNumber(item[key]);
|
|
178
|
+
let rawValue = isNum ? parseFloat(item[key]) : item[key];
|
|
179
|
+
let formatted = item[key];
|
|
180
|
+
if (key.indexOf("Time") >= 0) {
|
|
181
|
+
rawValue = rawValue / 1000000000;
|
|
182
|
+
formatted = siFormatter(rawValue) + "s";
|
|
183
|
+
}
|
|
184
|
+
metric.Properties.Property.push({
|
|
185
|
+
Name: key,
|
|
186
|
+
RawValue: rawValue,
|
|
187
|
+
Formatted: formatted
|
|
188
|
+
} as WUDetails.Property);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return metric;
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
return wu.normalizeDetails(meta, data);
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
return Promise.resolve({ meta: undefined, columns: undefined, data: undefined });
|
|
200
|
+
}
|
|
201
|
+
|
|
137
202
|
async submit(request: object): Promise<Array<{ [key: string]: object[] }>> {
|
|
138
203
|
const wsEclService = await this.wsEclService();
|
|
139
204
|
try {
|