@hpcc-js/comms 3.22.1 → 3.23.1

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/README.md CHANGED
@@ -1,6 +1,72 @@
1
1
  # @hpcc-js/comms
2
2
  This package is part of the mono repository "@hpcc-js" (aka Visualization Framework), for more information including [Quick Start](https://github.com/hpcc-systems/Visualization/wiki/Quick-Start), [Gallery](https://raw.githack.com/hpcc-systems/Visualization/trunk/demos/gallery/gallery.html) and [Tutorials](https://github.com/hpcc-systems/Visualization/wiki/Tutorials), please visit the main page on GitHub: [hpcc-systems/Visualization](https://github.com/hpcc-systems/Visualization).
3
3
 
4
+ ## WsSQL2
5
+
6
+ `SQL2Service` exposes the WsSQL2 operations (`ExecuteQuery`, `ExplainQuery`, `FetchResultSet`, `CloseResultSet`, `LogicalFileMetadata`, `SplitQuery`, and `Ping`) with request and response types in `WsSQL2`.
7
+
8
+ ```ts
9
+ import { SQL2Service } from "@hpcc-js/comms";
10
+
11
+ const sql = new SQL2Service({ baseUrl: "http://localhost:8510" });
12
+ const { CursorId, ResultSetMetadata } = await sql.ExecuteQuery({
13
+ SQLText: "SELECT 1", IncludeResultSetMetadata: true
14
+ });
15
+ try {
16
+ const { RowsJSON, Complete } = await sql.FetchResultSet({ CursorId, RowCount: 100 });
17
+ console.log(ResultSetMetadata, RowsJSON, Complete);
18
+ } finally {
19
+ await sql.CloseResultSet({ CursorId });
20
+ }
21
+ ```
22
+
23
+ To regenerate the WsSQL2 TypeScript bindings from the local WSDL, run `npm run wsdl-sql2` in this package.
24
+ `ExplainQuery` returns `Plan` / `PlanJson`; a fetch may include `RuntimeGraph` / `RuntimeGraphJson` when `ExecuteQuery` requests `IncludeRuntimeGraph`.
25
+
26
+ For small results, `queryRows()` collects rows as objects keyed by column label and closes its statement automatically:
27
+
28
+ ```ts
29
+ import { SQLConnection } from "@hpcc-js/comms";
30
+
31
+ const connection = new SQLConnection({ baseUrl: "http://localhost:8510" });
32
+ try {
33
+ const rows = await connection.queryRows("SELECT id FROM hpcc_scan('example::file')", 100);
34
+ console.log(rows[0]?.id);
35
+ const { Plan } = await connection.explainQuery("SELECT 1");
36
+ const file = await connection.logicalFileMeta("example::file");
37
+ const available = await connection.ping();
38
+ } finally {
39
+ await connection.close();
40
+ }
41
+ ```
42
+
43
+ `queryRows()` preserves native JSON values (including `null`) and rejects missing or duplicate column labels, ignoring case. It holds all rows in memory; use `createStatement()` and `next()` below for large results or early cancellation. `explainQuery()` returns the typed service response, `logicalFileMeta()` returns the file metadata or `undefined`, and `ping()` returns `true` on success (or rejects on failure).
44
+
45
+ For a JDBC-style, forward-only client, use the async `SQLConnection` helper:
46
+
47
+ ```ts
48
+ import { SQLConnection } from "@hpcc-js/comms";
49
+
50
+ const connection = new SQLConnection({ baseUrl: "http://localhost:8510" });
51
+ try {
52
+ const statement = connection.createStatement();
53
+ statement.setFetchSize(100);
54
+ const statements = await connection.splitQuery("SELECT 1; SELECT 2;");
55
+ const result = await statement.executeQuery("SELECT id FROM hpcc_scan('example::file')");
56
+ while (await result.next()) {
57
+ console.log(result.getObject("id"));
58
+ }
59
+ } finally {
60
+ await connection.close();
61
+ }
62
+ ```
63
+
64
+ `executeQuery` prepares SQL and returns metadata and a cursor without executing it. The first `next()` initiates execution; subsequent calls fetch pages on demand until `Complete` is true, including empty intermediate pages. `getObject` accepts a 1-based column index or a case-insensitive label, and `getMetaData()` exposes the WsSQL2 column descriptors. Always `await` `close()` on the result, statement, or connection when finished: it releases any active server cursor. All three support `Symbol.asyncDispose`, so `await using` also closes their owned cursors on scope exit; synchronous disposal cannot wait for the server. `statement.cancel()` or `result.cancel()` closes the cursor immediately, even while a fetch is in progress, and ends that result's iteration. Executing another query on the same statement closes its previous result first. This helper does not implement transactions, parameter binding, or JDBC type conversions.
65
+ `connection.splitQuery(sql)` delegates statement splitting to the server and returns the individual SQL strings (or `[]` for a comment-only script); it does not execute them. Pass each statement to `executeQuery()` separately when running a multi-statement script.
66
+ If `CloseResultSet` fails, the failure is reported and the cursor ID is retained; retry `close()` on the result, statement, or connection to attempt cleanup again.
67
+
68
+ The integration tests in `tests/wsSQL2.spec.ts` run in both the Node and browser test projects. They require ESP at `http://127.0.0.1:8010/` and WsSQL2 at `http://127.0.0.1:8510/`; service-backed tests are skipped when the WsSQL2 ping fails. One test creates a unique 1,000-row logical file, verifies paging and early cursor close, then removes the file and its workunit.
69
+
4
70
  ## Exported Widgets
5
71
  * [Connection](https://raw.githack.com/hpcc-systems/Visualization/trunk/demos/gallery/playground.html?./samples/comms/Connection.js)
6
72
 
@@ -3,7 +3,7 @@ import { Cache as e, Dispatch as t, Edge as n, Graph as r, Message as i, SAXStac
3
3
  var x = Object.defineProperty, __name = (e, t) => x(e, "name", {
4
4
  value: t,
5
5
  configurable: !0
6
- }), te = "@hpcc-js/comms", S = "3.22.1", C = "3.37.1", w = y("comms/connection.ts");
6
+ }), te = "@hpcc-js/comms", S = "3.23.1", C = "3.38.2", w = y("comms/connection.ts");
7
7
  function instanceOfIOptions(e) {
8
8
  return "baseUrl" in e;
9
9
  }
@@ -35,13 +35,23 @@ function serializeRequest(e, t = !0, n = "") {
35
35
  return r.join("&");
36
36
  }
37
37
  function deserializeResponse(e) {
38
- return JSON.parse(e);
38
+ try {
39
+ return JSON.parse(e);
40
+ } catch (e) {
41
+ let t = e instanceof Error ? e.message : String(e);
42
+ throw Object.assign(/* @__PURE__ */ Error(`Error parsing JSON response '${t}'`), { cause: e });
43
+ }
39
44
  }
40
45
  function jsonp(e, t, n = {}, r = "json", i) {
41
46
  return i && console.warn("Header attributes ignored for JSONP connections"), new Promise((i, a) => {
42
47
  let o = e.timeoutSecs * 1e3, s = 5e3, c = "jsonp_callback_" + Math.round(Math.random() * 999999);
43
48
  window[c] = function(e) {
44
- o = 0, doCallback(), i(r === "json" && typeof e == "string" ? deserializeResponse(e) : e);
49
+ o = 0, doCallback();
50
+ try {
51
+ i(r === "json" && typeof e == "string" ? deserializeResponse(e) : e);
52
+ } catch (e) {
53
+ a(e);
54
+ }
45
55
  };
46
56
  let l = document.createElement("script"), u = g(e.baseUrl, t);
47
57
  u += u.indexOf("?") >= 0 ? "&" : "?", l.src = u + "jsonp=" + c + "&" + serializeRequest(n, e.encodeRequest), document.body.appendChild(l);
@@ -253,7 +263,7 @@ var ie = class ESPConnection {
253
263
  })(D ||= {});
254
264
  var FileSprayServiceBase = class extends Service {
255
265
  constructor(e) {
256
- super(e, "FileSpray", "1.29");
266
+ super(e, "FileSpray", "1.30");
257
267
  }
258
268
  AbortDFUWorkunit(e, t) {
259
269
  return this._connection.send("AbortDFUWorkunit", e, "json", !1, t, "AbortDFUWorkunitResponse");
@@ -625,7 +635,8 @@ var CloudService = class extends CloudServiceBase {
625
635
  try {
626
636
  return mapPods((typeof e.Result == "string" ? JSON.parse(e.Result) : e.Result)?.items ?? []);
627
637
  } catch (e) {
628
- return se.error(`Error parsing V1Pods json '${e instanceof Error ? e.message : String(e)}'`), [];
638
+ let t = e instanceof Error ? e.message : String(e), n = Object.assign(/* @__PURE__ */ Error(`Error parsing V1Pods json '${t}'`), { cause: e });
639
+ throw se.error(n.message), n;
629
640
  }
630
641
  });
631
642
  }
@@ -985,14 +996,26 @@ var EclService = class extends Service {
985
996
  }
986
997
  requestJson(e, t) {
987
998
  return this._connection.send(`example/request/query/${e}/${t}/json`, {}, "text").then((e) => {
988
- let t = JSON.parse(e);
999
+ let t;
1000
+ try {
1001
+ t = JSON.parse(e);
1002
+ } catch (e) {
1003
+ let t = e instanceof Error ? e.message : String(e);
1004
+ throw Object.assign(/* @__PURE__ */ Error(`Error parsing WsEcl request JSON '${t}'`), { cause: e });
1005
+ }
989
1006
  for (let e in t) return t[e];
990
1007
  return {};
991
1008
  }).then(jsonToIFieldArr);
992
1009
  }
993
1010
  responseJson(e, t) {
994
1011
  return this._connection.send(`example/response/query/${e}/${t}/json`, {}, "text").then((e) => {
995
- let t = JSON.parse(e);
1012
+ let t;
1013
+ try {
1014
+ t = JSON.parse(e);
1015
+ } catch (e) {
1016
+ let t = e instanceof Error ? e.message : String(e);
1017
+ throw Object.assign(/* @__PURE__ */ Error(`Error parsing WsEcl response JSON '${t}'`), { cause: e });
1018
+ }
996
1019
  for (let e in t) return t[e].Results;
997
1020
  return {};
998
1021
  }).then((e) => {
@@ -1169,18 +1192,16 @@ var LogaccessService = class extends LogaccessServiceBase {
1169
1192
  }] }
1170
1193
  };
1171
1194
  return this.GetLogs(a).then((e) => {
1195
+ let r;
1172
1196
  try {
1173
- let r = JSON.parse(e.LogLines);
1174
- return {
1175
- lines: ge.has(t.RemoteLogManagerType) ? r.lines?.map((e) => this.convertLogLine(n, e)) ?? [] : (pe.warning(`Unknown RemoteLogManagerType: ${t.RemoteLogManagerType}`), []),
1176
- total: e.TotalLogLinesAvailable ?? 1e4
1177
- };
1197
+ r = JSON.parse(e.LogLines);
1178
1198
  } catch (e) {
1179
- pe.error(e.message ?? e);
1199
+ let t = e instanceof Error ? e.message : String(e), n = Object.assign(/* @__PURE__ */ Error(`Error parsing log lines json '${t}'`), { cause: e });
1200
+ throw pe.error(n.message), n;
1180
1201
  }
1181
1202
  return {
1182
- lines: [],
1183
- total: 0
1203
+ lines: ge.has(t.RemoteLogManagerType) ? r.lines?.map((e) => this.convertLogLine(n, e)) ?? [] : (pe.warning(`Unknown RemoteLogManagerType: ${t.RemoteLogManagerType}`), []),
1204
+ total: e.TotalLogLinesAvailable ?? 1e4
1184
1205
  };
1185
1206
  });
1186
1207
  }
@@ -1425,11 +1446,7 @@ function timeInterval(e, t, n, r) {
1425
1446
  }
1426
1447
  }), n && (interval.count = (t, r) => (A.setTime(+t), j.setTime(+r), e(A), e(j), Math.floor(n(A, j))), interval.every = (e) => (e = Math.floor(e), !isFinite(e) || !(e > 0) ? null : e > 1 ? interval.filter(r ? (t) => r(t) % e === 0 : (t) => interval.count(0, t) % e === 0) : interval)), interval;
1427
1448
  }
1428
- var Se = 6e4, M = Se * 60 * 24, Ce = M * 7;
1429
- M * 30, M * 365;
1430
- //#endregion
1431
- //#region ../../node_modules/d3-time/src/day.js
1432
- var we = timeInterval((e) => e.setHours(0, 0, 0, 0), (e, t) => e.setDate(e.getDate() + t), (e, t) => (t - e - (t.getTimezoneOffset() - e.getTimezoneOffset()) * Se) / M, (e) => e.getDate() - 1);
1449
+ var Se = 6e4, M = Se * 60 * 24, Ce = M * 7, we = timeInterval((e) => e.setHours(0, 0, 0, 0), (e, t) => e.setDate(e.getDate() + t), (e, t) => (t - e - (t.getTimezoneOffset() - e.getTimezoneOffset()) * Se) / M, (e) => e.getDate() - 1);
1433
1450
  we.range;
1434
1451
  var Te = timeInterval((e) => {
1435
1452
  e.setUTCHours(0, 0, 0, 0);
@@ -2147,7 +2164,32 @@ var SMCService = class extends SMCServiceBase {
2147
2164
  return t;
2148
2165
  });
2149
2166
  }
2150
- }, storeServiceBase = class extends Service {
2167
+ }, SQL2ServiceBase = class extends Service {
2168
+ constructor(e) {
2169
+ super(e, "WsSQL2", "1.01");
2170
+ }
2171
+ CloseResultSet(e, t) {
2172
+ return this._connection.send("CloseResultSet", e, "json", !1, t, "CloseResultSetResponse");
2173
+ }
2174
+ ExecuteQuery(e, t) {
2175
+ return this._connection.send("ExecuteQuery", e, "json", !1, t, "ExecuteQueryResponse");
2176
+ }
2177
+ ExplainQuery(e, t) {
2178
+ return this._connection.send("ExplainQuery", e, "json", !1, t, "ExplainQueryResponse");
2179
+ }
2180
+ FetchResultSet(e, t) {
2181
+ return this._connection.send("FetchResultSet", e, "json", !1, t, "FetchResultSetResponse");
2182
+ }
2183
+ LogicalFileMetadata(e, t) {
2184
+ return this._connection.send("LogicalFileMetadata", e, "json", !1, t, "LogicalFileMetadataResponse");
2185
+ }
2186
+ Ping(e, t) {
2187
+ return this._connection.send("Ping", e, "json", !1, t, "WsSQL2PingResponse");
2188
+ }
2189
+ SplitQuery(e, t) {
2190
+ return this._connection.send("SplitQuery", e, "json", !1, t, "SplitQueryResponse");
2191
+ }
2192
+ }, SQL2Service = class extends SQL2ServiceBase {}, storeServiceBase = class extends Service {
2151
2193
  constructor(e) {
2152
2194
  super(e, "wsstore", "1.02");
2153
2195
  }
@@ -4329,11 +4371,7 @@ var q = y("workunit.ts"), WorkunitCache = class extends e {
4329
4371
  });
4330
4372
  }
4331
4373
  _monitor() {
4332
- if (this.isComplete()) {
4333
- this._monitorTickCount = 0;
4334
- return;
4335
- }
4336
- super._monitor();
4374
+ this.isComplete() ? this._monitorTickCount = 0 : super._monitor();
4337
4375
  }
4338
4376
  _monitorTimeoutDuration() {
4339
4377
  let e = super._monitorTimeoutDuration();
@@ -5755,6 +5793,280 @@ var QueryCache = class extends e {
5755
5793
  resultFields(e) {
5756
5794
  return this._responseSchema[e] ? this._responseSchema[e] : [];
5757
5795
  }
5796
+ }, SQLCleanupError = class extends Error {
5797
+ cause;
5798
+ cleanupErrors;
5799
+ constructor(e, t, n) {
5800
+ super(e), this.cause = t, this.cleanupErrors = n;
5801
+ }
5802
+ };
5803
+ function checkExceptions(e) {
5804
+ if (e.Exceptions) throw Error(e.Exceptions.Exception?.map((e) => e.Message ?? e.Code).join("; ") || "WsSQL2 request failed");
5805
+ }
5806
+ function rowsFrom(e) {
5807
+ if (typeof e.RowsJSON != "string") throw Error("WsSQL2 response is missing RowsJSON");
5808
+ let t;
5809
+ try {
5810
+ t = JSON.parse(e.RowsJSON);
5811
+ } catch (e) {
5812
+ let t = e instanceof Error ? e.message : String(e);
5813
+ throw Object.assign(/* @__PURE__ */ Error(`Error parsing WsSQL2 Rows JSON '${t}'`), { cause: e });
5814
+ }
5815
+ if (!Array.isArray(t) || !t.every((e) => Array.isArray(e))) throw Error("WsSQL2 Rows must be an array of arrays");
5816
+ return t;
5817
+ }
5818
+ var SQLConnection = class {
5819
+ service;
5820
+ statements = /* @__PURE__ */ new Set();
5821
+ closed = !1;
5822
+ closing;
5823
+ constructor(e) {
5824
+ this.service = e instanceof SQL2Service ? e : new SQL2Service(e);
5825
+ }
5826
+ createStatement() {
5827
+ this.checkOpen();
5828
+ let e = new SQLStatement(this.service, () => this.statements.delete(e));
5829
+ return this.statements.add(e), e;
5830
+ }
5831
+ async queryRows(e, t) {
5832
+ let n = this.createStatement(), r = [];
5833
+ try {
5834
+ t !== void 0 && n.setFetchSize(t);
5835
+ let i = await n.executeQuery(e);
5836
+ for (; await i.next();) r.push(i.getRow());
5837
+ } catch (e) {
5838
+ try {
5839
+ await n.close();
5840
+ } catch (t) {
5841
+ throw new SQLCleanupError("Failed to query rows and close statement", e, [t]);
5842
+ }
5843
+ throw e;
5844
+ }
5845
+ return await n.close(), r;
5846
+ }
5847
+ async explainQuery(e) {
5848
+ if (this.checkOpen(), !e.trim()) throw Error("SQL text is required");
5849
+ let t = await this.service.ExplainQuery({ SQLText: e });
5850
+ return checkExceptions(t), t;
5851
+ }
5852
+ async logicalFileMeta(e) {
5853
+ if (this.checkOpen(), !e.trim()) throw Error("Logical file name is required");
5854
+ let t = await this.service.LogicalFileMetadata({ LogicalName: e });
5855
+ return checkExceptions(t), t.LogicalFileMetadata;
5856
+ }
5857
+ async ping() {
5858
+ return this.checkOpen(), await this.service.Ping({}), !0;
5859
+ }
5860
+ async splitQuery(e) {
5861
+ if (this.checkOpen(), !e.trim()) return [];
5862
+ let t = await this.service.SplitQuery({ SQLText: e });
5863
+ checkExceptions(t);
5864
+ let n = t.Statements?.Statement ?? [];
5865
+ if (!Array.isArray(n) || !n.every((e) => typeof e == "string")) throw Error("WsSQL2 response has invalid Statements");
5866
+ return n;
5867
+ }
5868
+ close() {
5869
+ return this.closing || (this.closed = !0, this.closing = (async () => {
5870
+ let e = (await Promise.allSettled([...this.statements].map((e) => e.close()))).filter((e) => e.status === "rejected").map((e) => e.reason);
5871
+ if (e.length) throw new SQLCleanupError("Failed to close SQL statements", e[0], e);
5872
+ })(), this.closing.then(() => {
5873
+ this.closing = void 0;
5874
+ }, () => {
5875
+ this.closing = void 0;
5876
+ })), this.closing;
5877
+ }
5878
+ [Symbol.asyncDispose]() {
5879
+ return this.close();
5880
+ }
5881
+ checkOpen() {
5882
+ if (this.closed) throw Error("SQL connection is closed");
5883
+ }
5884
+ }, SQLStatement = class {
5885
+ service;
5886
+ onClose;
5887
+ result;
5888
+ closed = !1;
5889
+ fetchSize = 0;
5890
+ executing;
5891
+ closing;
5892
+ constructor(e, t) {
5893
+ this.service = e, this.onClose = t;
5894
+ }
5895
+ setFetchSize(e) {
5896
+ if (this.checkOpen(), !Number.isSafeInteger(e) || e < 0) throw RangeError("Fetch size must be a non-negative integer");
5897
+ this.fetchSize = e;
5898
+ }
5899
+ cancel() {
5900
+ return this.checkOpen(), this.executing ? this.executing.then((e) => e.cancel()) : this.result?.cancel() ?? Promise.resolve();
5901
+ }
5902
+ executeQuery(e) {
5903
+ if (this.checkOpen(), this.executing) throw Error("SQL statement is already executing");
5904
+ if (!e.trim()) throw Error("SQL text is required");
5905
+ return this.execute(e);
5906
+ }
5907
+ async execute(e) {
5908
+ let t = this.runQuery(e);
5909
+ this.executing = t;
5910
+ try {
5911
+ return await t;
5912
+ } finally {
5913
+ this.executing = void 0;
5914
+ }
5915
+ }
5916
+ async runQuery(e) {
5917
+ if (await this.result?.close(), this.result = void 0, this.closed) throw Error("SQL statement is closed");
5918
+ let t = await this.service.ExecuteQuery({
5919
+ SQLText: e,
5920
+ IncludeResultSetMetadata: !0
5921
+ }), n = t.ResultSetMetadata?.Column, r = t.CursorId ? new SQLResultSet(this.service, n ?? [], t.CursorId, this.fetchSize) : void 0;
5922
+ this.result = r;
5923
+ try {
5924
+ if (checkExceptions(t), !t.CursorId) throw Error("WsSQL2 response is missing CursorId");
5925
+ if (!n) throw Error("WsSQL2 response is missing result-set metadata");
5926
+ if (this.closed) throw Error("SQL statement is closed");
5927
+ return r;
5928
+ } catch (e) {
5929
+ if (r) try {
5930
+ await r.close();
5931
+ } catch (t) {
5932
+ throw new SQLCleanupError("Failed to parse result and close cursor", e, [t]);
5933
+ }
5934
+ throw e;
5935
+ }
5936
+ }
5937
+ close() {
5938
+ return this.closing || (this.closed = !0, this.closing = (async () => {
5939
+ if (this.executing) try {
5940
+ await this.executing;
5941
+ } catch {}
5942
+ await this.result?.close(), this.onClose();
5943
+ })(), this.closing.then(() => {
5944
+ this.closing = void 0;
5945
+ }, () => {
5946
+ this.closing = void 0;
5947
+ })), this.closing;
5948
+ }
5949
+ [Symbol.asyncDispose]() {
5950
+ return this.close();
5951
+ }
5952
+ checkOpen() {
5953
+ if (this.closed) throw Error("SQL statement is closed");
5954
+ }
5955
+ }, SQLResultSet = class {
5956
+ service;
5957
+ columns;
5958
+ cursor;
5959
+ fetchSize;
5960
+ index = -1;
5961
+ row;
5962
+ wasNullValue = !1;
5963
+ closed = !1;
5964
+ advancing;
5965
+ closing;
5966
+ constructor(e, t, n, r) {
5967
+ this.service = e, this.columns = t, this.cursor = n, this.fetchSize = r;
5968
+ }
5969
+ rows = [];
5970
+ complete = !1;
5971
+ getMetaData() {
5972
+ return this.checkOpen(), this.columns;
5973
+ }
5974
+ findColumn(e) {
5975
+ this.checkOpen();
5976
+ let t = this.columns.findIndex((t) => t.ColumnLabel?.toLowerCase() === e.toLowerCase());
5977
+ if (t < 0) throw Error(`Unknown SQL column: ${e}`);
5978
+ return t + 1;
5979
+ }
5980
+ next() {
5981
+ if (this.checkOpen(), this.advancing) throw Error("SQL result set is already fetching");
5982
+ return this.advance();
5983
+ }
5984
+ async advance() {
5985
+ let e = this.advancePage();
5986
+ this.advancing = e;
5987
+ try {
5988
+ return await e;
5989
+ } finally {
5990
+ this.advancing = void 0;
5991
+ }
5992
+ }
5993
+ async advancePage() {
5994
+ this.row = void 0;
5995
+ try {
5996
+ for (; ++this.index >= this.rows.length;) {
5997
+ if (this.checkOpen(), this.complete) return !1;
5998
+ let e = await this.service.FetchResultSet({
5999
+ CursorId: this.cursor,
6000
+ RowCount: this.fetchSize
6001
+ });
6002
+ if (checkExceptions(e), typeof e.Complete != "boolean") throw Error("WsSQL2 fetch response is missing Complete");
6003
+ let t = rowsFrom(e);
6004
+ this.checkOpen(), this.complete = e.Complete, this.complete && (this.cursor = void 0), this.rows = t, this.index = -1;
6005
+ }
6006
+ this.checkOpen();
6007
+ let e = this.rows[this.index];
6008
+ if (e.length !== this.columns.length) throw Error("WsSQL2 row width does not match result metadata");
6009
+ return this.row = e, !0;
6010
+ } catch (e) {
6011
+ this.closed = !0;
6012
+ try {
6013
+ await this.close();
6014
+ } catch (t) {
6015
+ throw new SQLCleanupError("Failed to read result and close cursor", e, [t]);
6016
+ }
6017
+ throw e;
6018
+ }
6019
+ }
6020
+ getObject(e) {
6021
+ if (this.checkOpen(), !this.row) throw Error("SQL result set is not positioned on a row");
6022
+ let t = typeof e == "string" ? this.findColumn(e) : e;
6023
+ if (!Number.isInteger(t) || t < 1 || t > this.columns.length) throw RangeError(`SQL column index out of range: ${t}`);
6024
+ let n = this.row[t - 1];
6025
+ return this.wasNullValue = n === null, n;
6026
+ }
6027
+ getString(e) {
6028
+ let t = this.getObject(e);
6029
+ return t === null ? null : String(t);
6030
+ }
6031
+ getRow() {
6032
+ this.checkOpen();
6033
+ let e = this.row;
6034
+ if (!e) throw Error("SQL result set is not positioned on a row");
6035
+ let t = Object.create(null), n = /* @__PURE__ */ new Set();
6036
+ return this.columns.forEach((r, i) => {
6037
+ let a = r.ColumnLabel;
6038
+ if (!a) throw Error("WsSQL2 column is missing a label");
6039
+ if (n.has(a.toLowerCase())) throw Error(`Duplicate SQL column label: ${a}`);
6040
+ n.add(a.toLowerCase()), t[a] = e[i];
6041
+ }), t;
6042
+ }
6043
+ wasNull() {
6044
+ return this.checkOpen(), this.wasNullValue;
6045
+ }
6046
+ close() {
6047
+ return this.closing || (this.closed = !0, this.closing = (async () => {
6048
+ await this.closeCursor();
6049
+ })(), this.closing.then(() => {
6050
+ this.closing = void 0;
6051
+ }, () => {
6052
+ this.closing = void 0;
6053
+ })), this.closing;
6054
+ }
6055
+ [Symbol.asyncDispose]() {
6056
+ return this.close();
6057
+ }
6058
+ cancel() {
6059
+ return this.close();
6060
+ }
6061
+ async closeCursor() {
6062
+ if (this.cursor) {
6063
+ let e = this.cursor;
6064
+ checkExceptions(await this.service.CloseResultSet({ CursorId: e })), this.cursor = void 0;
6065
+ }
6066
+ }
6067
+ checkOpen() {
6068
+ if (this.closed) throw Error("SQL result set is closed");
6069
+ }
5758
6070
  }, StoreCache = class extends e {
5759
6071
  constructor() {
5760
6072
  super((e) => `${e.BaseUrl}-${e.Name}:${e.UserSpecific}-${e.Namespace}`);
@@ -6052,6 +6364,15 @@ var QueryCache = class extends e {
6052
6364
  get KbPerSec() {
6053
6365
  return this.get("KbPerSec");
6054
6366
  }
6367
+ get SubTaskCount() {
6368
+ return this.get("SubTaskCount");
6369
+ }
6370
+ get SubTasksFinished() {
6371
+ return this.get("SubTasksFinished");
6372
+ }
6373
+ get SubTasksFailed() {
6374
+ return this.get("SubTasksFailed");
6375
+ }
6055
6376
  static create(e, t) {
6056
6377
  let n = new DFUWorkunit(e);
6057
6378
  return n.connection.CreateDFUWorkunit({ DFUServerQueue: t }).then((e) => (Et.set(n), n.set(e.result), n));
@@ -6132,11 +6453,7 @@ var QueryCache = class extends e {
6132
6453
  return this.DFUWUFile();
6133
6454
  }
6134
6455
  _monitor() {
6135
- if (this.isComplete()) {
6136
- this._monitorTickCount = 0;
6137
- return;
6138
- }
6139
- super._monitor();
6456
+ this.isComplete() ? this._monitorTickCount = 0 : super._monitor();
6140
6457
  }
6141
6458
  _monitorTimeoutDuration() {
6142
6459
  let e = super._monitorTimeoutDuration();
@@ -6202,6 +6519,6 @@ var QueryCache = class extends e {
6202
6519
  }
6203
6520
  };
6204
6521
  //#endregion
6205
- export { AccessService, AccountService, lt as Activity, Attribute, C as BUILD_VERSION, BaseScope, CloudService, CodesignService, re as Connection, le as DFUArrayActions, de as DFUChangeProtection, fe as DFUChangeRestriction, ue as DFUDefFileFormat, DFUService, Dt as DFUWorkunit, DFUWorkunitCache, DFUXRefService, DaliService, ECLGraph, ie as ESPConnection, ESPExceptions, EclService, ElkService, D as FileSpray, FileSprayService, ae as FileSprayStates, GlobalResultCache, GraphCache, me as LogType, LogaccessService, ft as LogicalFile, LogicalFileCache, mt as Machine, MachineCache, MachineService, te as PKG_NAME, S as PKG_VERSION, PackageProcessService, nt as PropertyType, St as Query, yt as QueryGraph, rt as RelatedProperty, Resource, ResourcesService, Xe as Result, ResultCache, SMCService, SashaService, Scope, ScopeEdge, ScopeGraph, ScopeSubgraph, ScopeVertex, Service, SourceFile, wt as Store, StoreCache, StoreService, he as TargetAudience, Y as TargetCluster, TargetClusterCache, Timer, vt as Topology, TopologyCache, TopologyService, ValueChangedMessage, H as WUStateID, U as WUUpdate, ot as Workunit, WorkunitCache, WorkunitsService, WorkunitsServiceEx, oe as WsAccess, ce as WsCodesign, O as WsDfu, k as WsLogaccess, He as WsSMC, xe as WsSasha, We as WsTopology, V as WsWorkunits, XGMMLEdge, XGMMLGraph, XGMMLSubgraph, XGMMLVertex, XSDNode, XSDSchema, XSDSimpleType, XSDXMLNode, createConnection, createGraph, createXGMMLGraph, defaultTargetCluster, deserializeResponse, get, hookSend, instanceOfIConnection, instanceOfIOptions, isArray, isECLResult, isExceptions, isWUInfoWorkunit, isWUQueryECLWorkunit, jsonp, parseXSD, parseXSD2, post, send, serializeRequest, setTransportFactory, splitMetric, targetClusters };
6522
+ export { AccessService, AccountService, lt as Activity, Attribute, C as BUILD_VERSION, BaseScope, CloudService, CodesignService, re as Connection, le as DFUArrayActions, de as DFUChangeProtection, fe as DFUChangeRestriction, ue as DFUDefFileFormat, DFUService, Dt as DFUWorkunit, DFUWorkunitCache, DFUXRefService, DaliService, ECLGraph, ie as ESPConnection, ESPExceptions, EclService, ElkService, D as FileSpray, FileSprayService, ae as FileSprayStates, GlobalResultCache, GraphCache, me as LogType, LogaccessService, ft as LogicalFile, LogicalFileCache, mt as Machine, MachineCache, MachineService, te as PKG_NAME, S as PKG_VERSION, PackageProcessService, nt as PropertyType, St as Query, yt as QueryGraph, rt as RelatedProperty, Resource, ResourcesService, Xe as Result, ResultCache, SMCService, SQL2Service, SQLCleanupError, SQLConnection, SQLResultSet, SQLStatement, SashaService, Scope, ScopeEdge, ScopeGraph, ScopeSubgraph, ScopeVertex, Service, SourceFile, wt as Store, StoreCache, StoreService, he as TargetAudience, Y as TargetCluster, TargetClusterCache, Timer, vt as Topology, TopologyCache, TopologyService, ValueChangedMessage, H as WUStateID, U as WUUpdate, ot as Workunit, WorkunitCache, WorkunitsService, WorkunitsServiceEx, oe as WsAccess, ce as WsCodesign, O as WsDfu, k as WsLogaccess, He as WsSMC, xe as WsSasha, We as WsTopology, V as WsWorkunits, XGMMLEdge, XGMMLGraph, XGMMLSubgraph, XGMMLVertex, XSDNode, XSDSchema, XSDSimpleType, XSDXMLNode, createConnection, createGraph, createXGMMLGraph, defaultTargetCluster, deserializeResponse, get, hookSend, instanceOfIConnection, instanceOfIOptions, isArray, isECLResult, isExceptions, isWUInfoWorkunit, isWUQueryECLWorkunit, jsonp, parseXSD, parseXSD2, post, send, serializeRequest, setTransportFactory, splitMetric, targetClusters };
6206
6523
 
6207
6524
  //# sourceMappingURL=index.js.map