@hpcc-js/comms 3.15.4 → 3.15.6

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.
Files changed (130) hide show
  1. package/LICENSE +43 -43
  2. package/README.md +50 -50
  3. package/dist/browser/index.js +1 -1
  4. package/dist/browser/index.js.map +1 -1
  5. package/dist/browser/index.umd.cjs +1 -1
  6. package/dist/browser/index.umd.cjs.map +1 -1
  7. package/dist/node/index.cjs +10 -10
  8. package/dist/node/index.cjs.map +4 -4
  9. package/dist/node/index.js +9 -9
  10. package/dist/node/index.js.map +4 -4
  11. package/package.json +7 -7
  12. package/src/__package__.ts +3 -3
  13. package/src/clienttools/eclMeta.ts +506 -506
  14. package/src/clienttools/eclcc.ts +628 -628
  15. package/src/connection.ts +288 -288
  16. package/src/ecl/activity.ts +82 -82
  17. package/src/ecl/dfuWorkunit.ts +363 -363
  18. package/src/ecl/graph.ts +196 -196
  19. package/src/ecl/logicalFile.ts +196 -196
  20. package/src/ecl/machine.ts +63 -63
  21. package/src/ecl/query.ts +265 -265
  22. package/src/ecl/queryGraph.ts +813 -813
  23. package/src/ecl/resource.ts +39 -39
  24. package/src/ecl/result.ts +245 -245
  25. package/src/ecl/scope.ts +188 -188
  26. package/src/ecl/sourceFile.ts +34 -34
  27. package/src/ecl/store.ts +154 -154
  28. package/src/ecl/targetCluster.ts +149 -149
  29. package/src/ecl/timer.ts +42 -42
  30. package/src/ecl/topology.ts +131 -131
  31. package/src/ecl/workunit.ts +1340 -1340
  32. package/src/ecl/xsdParser.ts +267 -267
  33. package/src/espConnection.ts +164 -164
  34. package/src/index.browser.ts +1 -1
  35. package/src/index.common.ts +40 -40
  36. package/src/index.node.ts +48 -48
  37. package/src/pem/trustwave.ts +909 -909
  38. package/src/services/fileSpray.ts +73 -73
  39. package/src/services/wsAccess.ts +8 -8
  40. package/src/services/wsAccount.ts +27 -27
  41. package/src/services/wsCloud.ts +73 -73
  42. package/src/services/wsCodesign.ts +18 -18
  43. package/src/services/wsDFU.ts +34 -34
  44. package/src/services/wsDFUXRef.ts +121 -121
  45. package/src/services/wsDali.ts +8 -8
  46. package/src/services/wsEcl.ts +123 -123
  47. package/src/services/wsElk.ts +8 -8
  48. package/src/services/wsLogaccess.ts +270 -270
  49. package/src/services/wsMachine.ts +89 -89
  50. package/src/services/wsPackageProcess.ts +8 -8
  51. package/src/services/wsResources.ts +8 -8
  52. package/src/services/wsSMC.ts +80 -80
  53. package/src/services/wsSasha.ts +7 -7
  54. package/src/services/wsStore.ts +32 -32
  55. package/src/services/wsTopology.ts +45 -45
  56. package/src/services/wsWorkunits.ts +151 -151
  57. package/src/services/wsdl/FileSpray/v1.23/FileSpray.ts +1008 -1008
  58. package/src/services/wsdl/FileSpray/v1.25/FileSpray.ts +1040 -1040
  59. package/src/services/wsdl/FileSpray/v1.26/FileSpray.ts +929 -929
  60. package/src/services/wsdl/FileSpray/v1.27/FileSpray.ts +930 -930
  61. package/src/services/wsdl/WsCloud/v1/WsCloud.ts +38 -38
  62. package/src/services/wsdl/WsCloud/v1.02/WsCloud.ts +77 -77
  63. package/src/services/wsdl/WsDFUXRef/v1.02/WsDFUXRef.ts +224 -224
  64. package/src/services/wsdl/WsDFUXRef/v1.04/WsDFUXRef.ts +228 -227
  65. package/src/services/wsdl/WsDali/v1.04/WsDali.ts +216 -216
  66. package/src/services/wsdl/WsDali/v1.07/WsDali.ts +72 -72
  67. package/src/services/wsdl/WsDfu/v1.62/WsDfu.ts +1455 -1455
  68. package/src/services/wsdl/WsDfu/v1.63/WsDfu.ts +1465 -1465
  69. package/src/services/wsdl/WsDfu/v1.65/WsDfu.ts +1244 -1244
  70. package/src/services/wsdl/WsDfu/v1.66/WsDfu.ts +1267 -1267
  71. package/src/services/wsdl/WsDfu/v1.67/WsDfu.ts +1268 -1268
  72. package/src/services/wsdl/WsDfu/v1.68/WsDfu.ts +1301 -0
  73. package/src/services/wsdl/WsESDLConfig/v1.5/WsESDLConfig.ts +366 -0
  74. package/src/services/wsdl/WsFileIO/v1.01/WsFileIO.ts +104 -104
  75. package/src/services/wsdl/WsPackageProcess/v1.04/WsPackageProcess.ts +519 -519
  76. package/src/services/wsdl/WsPackageProcess/v1.07/WsPackageProcess.ts +500 -500
  77. package/src/services/wsdl/WsPackageProcess/v1.08/WsPackageProcess.ts +503 -0
  78. package/src/services/wsdl/WsResources/v1.01/WsResources.ts +119 -119
  79. package/src/services/wsdl/WsSMC/v1.24/WsSMC.ts +665 -665
  80. package/src/services/wsdl/WsSMC/v1.27/WsSMC.ts +591 -591
  81. package/src/services/wsdl/WsSMC/v1.28/WsSMC.ts +645 -645
  82. package/src/services/wsdl/WsSMC/v1.29/WsSMC.ts +660 -660
  83. package/src/services/wsdl/WsSasha/v1.01/WsSasha.ts +18 -18
  84. package/src/services/wsdl/WsTopology/v1.31/WsTopology.ts +856 -856
  85. package/src/services/wsdl/WsTopology/v1.32/WsTopology.ts +786 -786
  86. package/src/services/wsdl/WsTopology/v1.33/WsTopology.ts +835 -835
  87. package/src/services/wsdl/WsWorkunits/v1.88/WsWorkunits.ts +2944 -2944
  88. package/src/services/wsdl/WsWorkunits/v1.94/WsWorkunits.ts +3072 -3072
  89. package/src/services/wsdl/WsWorkunits/v1.95/WsWorkunits.ts +3073 -3073
  90. package/src/services/wsdl/WsWorkunits/v1.97/WsWorkunits.ts +3134 -3134
  91. package/src/services/wsdl/WsWorkunits/v1.98/WsWorkunits.ts +3182 -3182
  92. package/src/services/wsdl/WsWorkunits/v1.99/WsWorkunits.ts +3162 -3162
  93. package/src/services/wsdl/WsWorkunits/v2/WsWorkunits.ts +3153 -3153
  94. package/src/services/wsdl/WsWorkunits/v2.02/WsWorkunits.ts +3162 -3162
  95. package/src/services/wsdl/WsWorkunits/v2.03/WsWorkunits.ts +3164 -3164
  96. package/src/services/wsdl/WsWorkunits/v2.04/WsWorkunits.ts +3171 -3171
  97. package/src/services/wsdl/WsWorkunits/v2.05/WsWorkunits.ts +3177 -0
  98. package/src/services/wsdl/ws_access/v1.16/ws_access.ts +1086 -1086
  99. package/src/services/wsdl/ws_access/v1.17/ws_access.ts +1023 -1023
  100. package/src/services/wsdl/ws_account/v1.05/ws_account.ts +111 -111
  101. package/src/services/wsdl/ws_account/v1.06/ws_account.ts +109 -109
  102. package/src/services/wsdl/ws_account/v1.07/ws_account.ts +114 -114
  103. package/src/services/wsdl/ws_codesign/v1.1/ws_codesign.ts +95 -95
  104. package/src/services/wsdl/ws_elk/v1/ws_elk.ts +47 -47
  105. package/src/services/wsdl/ws_logaccess/v1/ws_logaccess.ts +83 -83
  106. package/src/services/wsdl/ws_logaccess/v1.02/ws_logaccess.ts +161 -161
  107. package/src/services/wsdl/ws_logaccess/v1.03/ws_logaccess.ts +190 -190
  108. package/src/services/wsdl/ws_logaccess/v1.04/ws_logaccess.ts +215 -215
  109. package/src/services/wsdl/ws_logaccess/v1.05/ws_logaccess.ts +219 -219
  110. package/src/services/wsdl/ws_logaccess/v1.08/ws_logaccess.ts +267 -267
  111. package/src/services/wsdl/ws_machine/v1.17/ws_machine.ts +567 -567
  112. package/src/services/wsdl/ws_machine/v1.18/ws_machine.ts +497 -497
  113. package/src/services/wsdl/ws_machine/v1.19/ws_machine.ts +497 -497
  114. package/src/services/wsdl/wsstore/v1.02/wsstore.ts +239 -239
  115. package/types/services/wsPackageProcess.d.ts +1 -1
  116. package/types/services/wsWorkunits.d.ts +1 -1
  117. package/types/services/wsdl/FileSpray/v1.27/FileSpray.d.ts +506 -506
  118. package/types/services/wsdl/WsCloud/v1.02/WsCloud.d.ts +18 -18
  119. package/types/services/wsdl/WsDFUXRef/v1.04/WsDFUXRef.d.ts +58 -57
  120. package/types/services/wsdl/WsDali/v1.07/WsDali.d.ts +42 -42
  121. package/types/services/wsdl/WsPackageProcess/{v1.07 → v1.08}/WsPackageProcess.d.ts +121 -118
  122. package/types/services/wsdl/WsSasha/v1.01/WsSasha.d.ts +13 -13
  123. package/types/services/wsdl/WsTopology/v1.33/WsTopology.d.ts +360 -360
  124. package/types/services/wsdl/WsWorkunits/v2.05/WsWorkunits.d.ts +2571 -0
  125. package/types/services/wsdl/ws_access/v1.17/ws_access.d.ts +268 -268
  126. package/types/services/wsdl/ws_account/v1.07/ws_account.d.ts +34 -34
  127. package/types/services/wsdl/ws_codesign/v1.1/ws_codesign.d.ts +22 -22
  128. package/types/services/wsdl/ws_elk/v1/ws_elk.d.ts +12 -12
  129. package/types/services/wsdl/wsstore/v1.02/wsstore.d.ts +61 -61
  130. package/types/services/wsdl/WsWorkunits/v2.04/WsWorkunits.d.ts +0 -2565
@@ -1,39 +1,39 @@
1
- import { StateObject } from "@hpcc-js/util";
2
- import { Workunit } from "./workunit.ts";
3
-
4
- export interface ResourceEx {
5
- URL: string;
6
- DisplayName: string;
7
- DisplayPath: string;
8
- }
9
-
10
- export class Resource extends StateObject<ResourceEx, ResourceEx> implements ResourceEx {
11
- protected wu: Workunit;
12
-
13
- get properties(): ResourceEx { return this.get(); }
14
- get URL(): string { return this.get("URL"); }
15
- get DisplayName(): string { return this.get("DisplayName"); }
16
- get DisplayPath(): string { return this.get("DisplayPath"); }
17
-
18
- constructor(wu: Workunit, url: string) {
19
- super();
20
- this.wu = wu;
21
-
22
- const cleanedURL = url.split("\\").join("/");
23
- const urlParts = cleanedURL.split("/");
24
- const matchStr = "res/" + this.wu.Wuid + "/";
25
- let displayPath = "";
26
- let displayName = "";
27
-
28
- if (cleanedURL.indexOf(matchStr) === 0) {
29
- displayPath = cleanedURL.substr(matchStr.length);
30
- displayName = urlParts[urlParts.length - 1];
31
- }
32
-
33
- this.set({
34
- URL: url,
35
- DisplayName: displayName,
36
- DisplayPath: displayPath
37
- });
38
- }
39
- }
1
+ import { StateObject } from "@hpcc-js/util";
2
+ import { Workunit } from "./workunit.ts";
3
+
4
+ export interface ResourceEx {
5
+ URL: string;
6
+ DisplayName: string;
7
+ DisplayPath: string;
8
+ }
9
+
10
+ export class Resource extends StateObject<ResourceEx, ResourceEx> implements ResourceEx {
11
+ protected wu: Workunit;
12
+
13
+ get properties(): ResourceEx { return this.get(); }
14
+ get URL(): string { return this.get("URL"); }
15
+ get DisplayName(): string { return this.get("DisplayName"); }
16
+ get DisplayPath(): string { return this.get("DisplayPath"); }
17
+
18
+ constructor(wu: Workunit, url: string) {
19
+ super();
20
+ this.wu = wu;
21
+
22
+ const cleanedURL = url.split("\\").join("/");
23
+ const urlParts = cleanedURL.split("/");
24
+ const matchStr = "res/" + this.wu.Wuid + "/";
25
+ let displayPath = "";
26
+ let displayName = "";
27
+
28
+ if (cleanedURL.indexOf(matchStr) === 0) {
29
+ displayPath = cleanedURL.substr(matchStr.length);
30
+ displayName = urlParts[urlParts.length - 1];
31
+ }
32
+
33
+ this.set({
34
+ URL: url,
35
+ DisplayName: displayName,
36
+ DisplayPath: displayPath
37
+ });
38
+ }
39
+ }
package/src/ecl/result.ts CHANGED
@@ -1,245 +1,245 @@
1
- import { Cache, exists, StateObject } from "@hpcc-js/util";
2
- import { IConnection, IOptions } from "../connection.ts";
3
- import { WsDfu } from "../services/wsDFU.ts";
4
- import { isECLResult, WorkunitsService, WsWorkunits } from "../services/wsWorkunits.ts";
5
- import { parseXSD, XSDSchema, XSDXMLNode } from "./xsdParser.ts";
6
-
7
- export class GlobalResultCache extends Cache<{ BaseUrl: string, Wuid: string, ResultName: string }, Result> {
8
- constructor() {
9
- super((obj) => {
10
- return `${obj.BaseUrl}-${obj.Wuid}-${obj.ResultName}`;
11
- });
12
- }
13
- }
14
- const _results = new GlobalResultCache();
15
-
16
- export type ResultFilter = { [key: string]: string | number };
17
-
18
- export interface ECLResultEx extends WsWorkunits.ECLResult {
19
- Wuid: string;
20
- ResultName?: string;
21
- ResultSequence?: number;
22
- LogicalFileName?: string;
23
- NodeGroup?: string;
24
- ResultViews: string[];
25
- }
26
-
27
- export interface WUResultResponseEx {
28
-
29
- Exceptions: WsWorkunits.Exceptions;
30
- Wuid: string;
31
- Sequence: WsWorkunits.int;
32
- LogicalName: string;
33
- Cluster: string;
34
- Name: string;
35
- Start: WsWorkunits.long;
36
- Requested: WsWorkunits.int;
37
- Count: WsWorkunits.int;
38
- Total: WsWorkunits.long;
39
- Result: { [key: string]: any[] } & {
40
- XmlSchema?: {
41
- xml: string;
42
- };
43
- };
44
- }
45
-
46
- export type UResulState = ECLResultEx & WsDfu.DFULogicalFile;
47
- export type IResulState = ECLResultEx | WsDfu.DFULogicalFile;
48
- export class Result extends StateObject<UResulState, IResulState> implements ECLResultEx {
49
- protected connection: WorkunitsService;
50
- protected _bypassCache: boolean = false;
51
- get BaseUrl() { return this.connection.baseUrl; }
52
- protected xsdSchema: XSDSchema;
53
-
54
- get properties(): WsWorkunits.ECLResult { return this.get(); }
55
- get Wuid(): string { return this.get("Wuid"); }
56
- get ResultName(): string | undefined { return this.get("ResultName"); }
57
- get ResultSequence(): number | undefined { return this.get("ResultSequence"); }
58
- get LogicalFileName(): string | undefined { return this.get("LogicalFileName"); }
59
- get Name(): string { return this.get("Name"); }
60
- get Sequence(): number { return this.get("Sequence"); }
61
- get Value(): string { return this.get("Value"); }
62
- get Link(): string { return this.get("Link"); }
63
- get FileName(): string { return this.get("FileName"); }
64
- get IsSupplied(): boolean { return this.get("IsSupplied"); }
65
- get ShowFileContent() { return this.get("ShowFileContent"); }
66
- get Total(): number { return this.get("Total"); }
67
- get ECLSchemas(): WsWorkunits.ECLSchemas { return this.get("ECLSchemas"); }
68
- get NodeGroup(): string { return this.get("NodeGroup"); }
69
- get ResultViews(): string[] { return this.get("ResultViews"); }
70
- get XmlSchema(): string { return this.get("XmlSchema"); }
71
-
72
- static attach(optsConnection: IOptions | IConnection | WorkunitsService, wuid: string, name: string);
73
- static attach(optsConnection: IOptions | IConnection | WorkunitsService, wuid: string, sequence: number);
74
- static attach(optsConnection: IOptions | IConnection | WorkunitsService, wuid: string, eclResult: WsWorkunits.ECLResult, resultViews: string[]);
75
- static attach(optsConnection: IOptions | IConnection | WorkunitsService, wuid: string, name_sequence_eclResult?: string | number | WsWorkunits.ECLResult, resultViews?: string[]): Result {
76
- let retVal: Result;
77
- if (Array.isArray(resultViews)) {
78
- retVal = _results.get({ BaseUrl: optsConnection.baseUrl, Wuid: wuid, ResultName: (name_sequence_eclResult as WsWorkunits.ECLResult).Name }, () => {
79
- return new Result(optsConnection, wuid, name_sequence_eclResult as WsWorkunits.ECLResult, resultViews);
80
- });
81
- retVal.set(name_sequence_eclResult as any);
82
- } else if (typeof resultViews === "undefined") {
83
- if (typeof name_sequence_eclResult === "number") {
84
- retVal = _results.get({ BaseUrl: optsConnection.baseUrl, Wuid: wuid, ResultName: "Sequence_" + name_sequence_eclResult }, () => {
85
- return new Result(optsConnection, wuid, name_sequence_eclResult);
86
- });
87
- } else if (typeof name_sequence_eclResult === "string") {
88
- retVal = _results.get({ BaseUrl: optsConnection.baseUrl, Wuid: wuid, ResultName: name_sequence_eclResult }, () => {
89
- return new Result(optsConnection, wuid, name_sequence_eclResult);
90
- });
91
- }
92
- }
93
- return retVal;
94
- }
95
-
96
- static attachLogicalFile(optsConnection: IOptions | IConnection | WorkunitsService, nodeGroup: string, logicalFile: string) {
97
- return _results.get({ BaseUrl: optsConnection.baseUrl, Wuid: nodeGroup, ResultName: logicalFile }, () => {
98
- return new Result(optsConnection, nodeGroup, logicalFile, true);
99
- });
100
- }
101
-
102
- private constructor(optsConnection: IOptions | IConnection | WorkunitsService, wuid: string, name: string);
103
- private constructor(optsConnection: IOptions | IConnection | WorkunitsService, wuid: string, sequence: number);
104
- private constructor(optsConnection: IOptions | IConnection | WorkunitsService, wuid: string, eclResult: WsWorkunits.ECLResult, resultViews: string[]);
105
- private constructor(optsConnection: IOptions | IConnection | WorkunitsService, nodeGroup: string, logicalFile: string, isLogicalFiles: boolean);
106
- private constructor(optsConnection: IOptions | IConnection | WorkunitsService, wuid_NodeGroup: string, name_sequence_eclResult_logicalFile?: string | number | WsWorkunits.ECLResult, resultViews_isLogicalFile?: any[] | boolean) {
107
- super();
108
- if (optsConnection instanceof WorkunitsService) {
109
- this.connection = optsConnection;
110
- } else {
111
- this.connection = new WorkunitsService(optsConnection);
112
- }
113
-
114
- if (typeof resultViews_isLogicalFile === "boolean" && resultViews_isLogicalFile === true) {
115
- this.set({
116
- NodeGroup: wuid_NodeGroup,
117
- LogicalFileName: name_sequence_eclResult_logicalFile
118
- } as ECLResultEx);
119
- } else if (isECLResult(name_sequence_eclResult_logicalFile) && Array.isArray(resultViews_isLogicalFile)) {
120
- this.set({
121
- ...name_sequence_eclResult_logicalFile,
122
- Wuid: wuid_NodeGroup,
123
- ResultName: name_sequence_eclResult_logicalFile.Name,
124
- ResultViews: resultViews_isLogicalFile
125
- } as ECLResultEx);
126
- } else if (typeof resultViews_isLogicalFile === "undefined") {
127
- if (typeof name_sequence_eclResult_logicalFile === "number") {
128
- this.set({
129
- Wuid: wuid_NodeGroup,
130
- ResultSequence: name_sequence_eclResult_logicalFile
131
- } as ECLResultEx);
132
- } else if (typeof name_sequence_eclResult_logicalFile === "string") {
133
- this.set({
134
- Wuid: wuid_NodeGroup,
135
- ResultName: name_sequence_eclResult_logicalFile
136
- } as ECLResultEx);
137
- } else {
138
- console.warn("Unknown Result.attach (1)");
139
- }
140
- } else {
141
- console.warn("Unknown Result.attach (2)");
142
- }
143
- }
144
-
145
- isComplete() {
146
- return this.Total !== -1;
147
- }
148
-
149
- bypassCache(bypass?: boolean): boolean | this {
150
- if (bypass === undefined) return this._bypassCache;
151
- this._bypassCache = bypass;
152
- return this;
153
- }
154
-
155
- private _fetchXMLSchemaPromise: Promise<XSDSchema | null>;
156
- fetchXMLSchema(refresh = false): Promise<XSDSchema | null> {
157
- if (!this._fetchXMLSchemaPromise || refresh) {
158
- this._fetchXMLSchemaPromise = this.WUResult().then(response => {
159
- if (response.Result?.XmlSchema?.xml) {
160
- this.xsdSchema = parseXSD(response.Result.XmlSchema.xml);
161
- return this.xsdSchema;
162
- }
163
- return null;
164
- });
165
- }
166
- return this._fetchXMLSchemaPromise;
167
- }
168
-
169
- async refresh(): Promise<this> {
170
- await this.fetchRows(0, 1, true);
171
- return this;
172
- }
173
-
174
- fetchRows(from: number = 0, count: number = -1, includeSchema: boolean = false, filter: ResultFilter = {}, abortSignal?: AbortSignal, bypassCache?: boolean): Promise<any[]> {
175
- const shouldBypassCache = bypassCache ?? this._bypassCache;
176
- return this.WUResult(from, count, !includeSchema, filter, abortSignal, shouldBypassCache).then((response) => {
177
- const result: any = response.Result;
178
- delete response.Result; // Do not want it in "set"
179
- this.set({
180
- ...response
181
- } as any);
182
- if (exists("XmlSchema.xml", result)) {
183
- this.xsdSchema = parseXSD(result.XmlSchema.xml);
184
- }
185
- if (exists("Row", result)) {
186
- return result.Row;
187
- } else if (this.ResultName && exists(this.ResultName, result)) {
188
- return result[this.ResultName].Row;
189
- }
190
- return [];
191
- });
192
- }
193
-
194
- rootField(): XSDXMLNode | null {
195
- if (!this.xsdSchema) return null;
196
- return this.xsdSchema.root;
197
- }
198
-
199
- fields(): XSDXMLNode[] {
200
- if (!this.xsdSchema) return [];
201
- return this.xsdSchema.root.children();
202
- }
203
-
204
- protected WUResult(start: number = 0, count: number = 1, suppressXmlSchema: boolean = false, filter: { [key: string]: string | number } = {}, abortSignal?: AbortSignal, bypassCache: boolean = false): Promise<WUResultResponseEx> {
205
- const FilterBy = {
206
- NamedValue: {
207
- itemcount: 0
208
- }
209
- };
210
- for (const key in filter) {
211
- FilterBy.NamedValue[FilterBy.NamedValue.itemcount++] = {
212
- Name: key,
213
- Value: filter[key]
214
- };
215
- }
216
- const request: Partial<WsWorkunits.WUResult> = { FilterBy } as any;
217
- if (this.Wuid && this.ResultName !== undefined) {
218
- request.Wuid = this.Wuid;
219
- request.ResultName = this.ResultName;
220
- } else if (this.Wuid && this.ResultSequence !== undefined) {
221
- request.Wuid = this.Wuid;
222
- request.Sequence = this.ResultSequence;
223
- } else if (this.LogicalFileName && this.NodeGroup) {
224
- request.LogicalName = this.LogicalFileName;
225
- request.Cluster = this.NodeGroup;
226
- } else if (this.LogicalFileName) {
227
- request.LogicalName = this.LogicalFileName;
228
- }
229
- request.Start = start;
230
- request.Count = count;
231
- request.SuppressXmlSchema = suppressXmlSchema;
232
- request.BypassCachedResult = bypassCache;
233
- return this.connection.WUResult(request, abortSignal).then((response: unknown) => {
234
- return response as WUResultResponseEx;
235
- });
236
- }
237
- }
238
-
239
- export class ResultCache extends Cache<WsWorkunits.ECLResult, Result> {
240
- constructor() {
241
- super((obj) => {
242
- return Cache.hash([obj.Sequence, obj.Name, obj.Value, obj.FileName]);
243
- });
244
- }
245
- }
1
+ import { Cache, exists, StateObject } from "@hpcc-js/util";
2
+ import { IConnection, IOptions } from "../connection.ts";
3
+ import { WsDfu } from "../services/wsDFU.ts";
4
+ import { isECLResult, WorkunitsService, WsWorkunits } from "../services/wsWorkunits.ts";
5
+ import { parseXSD, XSDSchema, XSDXMLNode } from "./xsdParser.ts";
6
+
7
+ export class GlobalResultCache extends Cache<{ BaseUrl: string, Wuid: string, ResultName: string }, Result> {
8
+ constructor() {
9
+ super((obj) => {
10
+ return `${obj.BaseUrl}-${obj.Wuid}-${obj.ResultName}`;
11
+ });
12
+ }
13
+ }
14
+ const _results = new GlobalResultCache();
15
+
16
+ export type ResultFilter = { [key: string]: string | number };
17
+
18
+ export interface ECLResultEx extends WsWorkunits.ECLResult {
19
+ Wuid: string;
20
+ ResultName?: string;
21
+ ResultSequence?: number;
22
+ LogicalFileName?: string;
23
+ NodeGroup?: string;
24
+ ResultViews: string[];
25
+ }
26
+
27
+ export interface WUResultResponseEx {
28
+
29
+ Exceptions: WsWorkunits.Exceptions;
30
+ Wuid: string;
31
+ Sequence: WsWorkunits.int;
32
+ LogicalName: string;
33
+ Cluster: string;
34
+ Name: string;
35
+ Start: WsWorkunits.long;
36
+ Requested: WsWorkunits.int;
37
+ Count: WsWorkunits.int;
38
+ Total: WsWorkunits.long;
39
+ Result: { [key: string]: any[] } & {
40
+ XmlSchema?: {
41
+ xml: string;
42
+ };
43
+ };
44
+ }
45
+
46
+ export type UResulState = ECLResultEx & WsDfu.DFULogicalFile;
47
+ export type IResulState = ECLResultEx | WsDfu.DFULogicalFile;
48
+ export class Result extends StateObject<UResulState, IResulState> implements ECLResultEx {
49
+ protected connection: WorkunitsService;
50
+ protected _bypassCache: boolean = false;
51
+ get BaseUrl() { return this.connection.baseUrl; }
52
+ protected xsdSchema: XSDSchema;
53
+
54
+ get properties(): WsWorkunits.ECLResult { return this.get(); }
55
+ get Wuid(): string { return this.get("Wuid"); }
56
+ get ResultName(): string | undefined { return this.get("ResultName"); }
57
+ get ResultSequence(): number | undefined { return this.get("ResultSequence"); }
58
+ get LogicalFileName(): string | undefined { return this.get("LogicalFileName"); }
59
+ get Name(): string { return this.get("Name"); }
60
+ get Sequence(): number { return this.get("Sequence"); }
61
+ get Value(): string { return this.get("Value"); }
62
+ get Link(): string { return this.get("Link"); }
63
+ get FileName(): string { return this.get("FileName"); }
64
+ get IsSupplied(): boolean { return this.get("IsSupplied"); }
65
+ get ShowFileContent() { return this.get("ShowFileContent"); }
66
+ get Total(): number { return this.get("Total"); }
67
+ get ECLSchemas(): WsWorkunits.ECLSchemas { return this.get("ECLSchemas"); }
68
+ get NodeGroup(): string { return this.get("NodeGroup"); }
69
+ get ResultViews(): string[] { return this.get("ResultViews"); }
70
+ get XmlSchema(): string { return this.get("XmlSchema"); }
71
+
72
+ static attach(optsConnection: IOptions | IConnection | WorkunitsService, wuid: string, name: string);
73
+ static attach(optsConnection: IOptions | IConnection | WorkunitsService, wuid: string, sequence: number);
74
+ static attach(optsConnection: IOptions | IConnection | WorkunitsService, wuid: string, eclResult: WsWorkunits.ECLResult, resultViews: string[]);
75
+ static attach(optsConnection: IOptions | IConnection | WorkunitsService, wuid: string, name_sequence_eclResult?: string | number | WsWorkunits.ECLResult, resultViews?: string[]): Result {
76
+ let retVal: Result;
77
+ if (Array.isArray(resultViews)) {
78
+ retVal = _results.get({ BaseUrl: optsConnection.baseUrl, Wuid: wuid, ResultName: (name_sequence_eclResult as WsWorkunits.ECLResult).Name }, () => {
79
+ return new Result(optsConnection, wuid, name_sequence_eclResult as WsWorkunits.ECLResult, resultViews);
80
+ });
81
+ retVal.set(name_sequence_eclResult as any);
82
+ } else if (typeof resultViews === "undefined") {
83
+ if (typeof name_sequence_eclResult === "number") {
84
+ retVal = _results.get({ BaseUrl: optsConnection.baseUrl, Wuid: wuid, ResultName: "Sequence_" + name_sequence_eclResult }, () => {
85
+ return new Result(optsConnection, wuid, name_sequence_eclResult);
86
+ });
87
+ } else if (typeof name_sequence_eclResult === "string") {
88
+ retVal = _results.get({ BaseUrl: optsConnection.baseUrl, Wuid: wuid, ResultName: name_sequence_eclResult }, () => {
89
+ return new Result(optsConnection, wuid, name_sequence_eclResult);
90
+ });
91
+ }
92
+ }
93
+ return retVal;
94
+ }
95
+
96
+ static attachLogicalFile(optsConnection: IOptions | IConnection | WorkunitsService, nodeGroup: string, logicalFile: string) {
97
+ return _results.get({ BaseUrl: optsConnection.baseUrl, Wuid: nodeGroup, ResultName: logicalFile }, () => {
98
+ return new Result(optsConnection, nodeGroup, logicalFile, true);
99
+ });
100
+ }
101
+
102
+ private constructor(optsConnection: IOptions | IConnection | WorkunitsService, wuid: string, name: string);
103
+ private constructor(optsConnection: IOptions | IConnection | WorkunitsService, wuid: string, sequence: number);
104
+ private constructor(optsConnection: IOptions | IConnection | WorkunitsService, wuid: string, eclResult: WsWorkunits.ECLResult, resultViews: string[]);
105
+ private constructor(optsConnection: IOptions | IConnection | WorkunitsService, nodeGroup: string, logicalFile: string, isLogicalFiles: boolean);
106
+ private constructor(optsConnection: IOptions | IConnection | WorkunitsService, wuid_NodeGroup: string, name_sequence_eclResult_logicalFile?: string | number | WsWorkunits.ECLResult, resultViews_isLogicalFile?: any[] | boolean) {
107
+ super();
108
+ if (optsConnection instanceof WorkunitsService) {
109
+ this.connection = optsConnection;
110
+ } else {
111
+ this.connection = new WorkunitsService(optsConnection);
112
+ }
113
+
114
+ if (typeof resultViews_isLogicalFile === "boolean" && resultViews_isLogicalFile === true) {
115
+ this.set({
116
+ NodeGroup: wuid_NodeGroup,
117
+ LogicalFileName: name_sequence_eclResult_logicalFile
118
+ } as ECLResultEx);
119
+ } else if (isECLResult(name_sequence_eclResult_logicalFile) && Array.isArray(resultViews_isLogicalFile)) {
120
+ this.set({
121
+ ...name_sequence_eclResult_logicalFile,
122
+ Wuid: wuid_NodeGroup,
123
+ ResultName: name_sequence_eclResult_logicalFile.Name,
124
+ ResultViews: resultViews_isLogicalFile
125
+ } as ECLResultEx);
126
+ } else if (typeof resultViews_isLogicalFile === "undefined") {
127
+ if (typeof name_sequence_eclResult_logicalFile === "number") {
128
+ this.set({
129
+ Wuid: wuid_NodeGroup,
130
+ ResultSequence: name_sequence_eclResult_logicalFile
131
+ } as ECLResultEx);
132
+ } else if (typeof name_sequence_eclResult_logicalFile === "string") {
133
+ this.set({
134
+ Wuid: wuid_NodeGroup,
135
+ ResultName: name_sequence_eclResult_logicalFile
136
+ } as ECLResultEx);
137
+ } else {
138
+ console.warn("Unknown Result.attach (1)");
139
+ }
140
+ } else {
141
+ console.warn("Unknown Result.attach (2)");
142
+ }
143
+ }
144
+
145
+ isComplete() {
146
+ return this.Total !== -1;
147
+ }
148
+
149
+ bypassCache(bypass?: boolean): boolean | this {
150
+ if (bypass === undefined) return this._bypassCache;
151
+ this._bypassCache = bypass;
152
+ return this;
153
+ }
154
+
155
+ private _fetchXMLSchemaPromise: Promise<XSDSchema | null>;
156
+ fetchXMLSchema(refresh = false): Promise<XSDSchema | null> {
157
+ if (!this._fetchXMLSchemaPromise || refresh) {
158
+ this._fetchXMLSchemaPromise = this.WUResult().then(response => {
159
+ if (response.Result?.XmlSchema?.xml) {
160
+ this.xsdSchema = parseXSD(response.Result.XmlSchema.xml);
161
+ return this.xsdSchema;
162
+ }
163
+ return null;
164
+ });
165
+ }
166
+ return this._fetchXMLSchemaPromise;
167
+ }
168
+
169
+ async refresh(): Promise<this> {
170
+ await this.fetchRows(0, 1, true);
171
+ return this;
172
+ }
173
+
174
+ fetchRows(from: number = 0, count: number = -1, includeSchema: boolean = false, filter: ResultFilter = {}, abortSignal?: AbortSignal, bypassCache?: boolean): Promise<any[]> {
175
+ const shouldBypassCache = bypassCache ?? this._bypassCache;
176
+ return this.WUResult(from, count, !includeSchema, filter, abortSignal, shouldBypassCache).then((response) => {
177
+ const result: any = response.Result;
178
+ delete response.Result; // Do not want it in "set"
179
+ this.set({
180
+ ...response
181
+ } as any);
182
+ if (exists("XmlSchema.xml", result)) {
183
+ this.xsdSchema = parseXSD(result.XmlSchema.xml);
184
+ }
185
+ if (exists("Row", result)) {
186
+ return result.Row;
187
+ } else if (this.ResultName && exists(this.ResultName, result)) {
188
+ return result[this.ResultName].Row;
189
+ }
190
+ return [];
191
+ });
192
+ }
193
+
194
+ rootField(): XSDXMLNode | null {
195
+ if (!this.xsdSchema) return null;
196
+ return this.xsdSchema.root;
197
+ }
198
+
199
+ fields(): XSDXMLNode[] {
200
+ if (!this.xsdSchema) return [];
201
+ return this.xsdSchema.root.children();
202
+ }
203
+
204
+ protected WUResult(start: number = 0, count: number = 1, suppressXmlSchema: boolean = false, filter: { [key: string]: string | number } = {}, abortSignal?: AbortSignal, bypassCache: boolean = false): Promise<WUResultResponseEx> {
205
+ const FilterBy = {
206
+ NamedValue: {
207
+ itemcount: 0
208
+ }
209
+ };
210
+ for (const key in filter) {
211
+ FilterBy.NamedValue[FilterBy.NamedValue.itemcount++] = {
212
+ Name: key,
213
+ Value: filter[key]
214
+ };
215
+ }
216
+ const request: Partial<WsWorkunits.WUResult> = { FilterBy } as any;
217
+ if (this.Wuid && this.ResultName !== undefined) {
218
+ request.Wuid = this.Wuid;
219
+ request.ResultName = this.ResultName;
220
+ } else if (this.Wuid && this.ResultSequence !== undefined) {
221
+ request.Wuid = this.Wuid;
222
+ request.Sequence = this.ResultSequence;
223
+ } else if (this.LogicalFileName && this.NodeGroup) {
224
+ request.LogicalName = this.LogicalFileName;
225
+ request.Cluster = this.NodeGroup;
226
+ } else if (this.LogicalFileName) {
227
+ request.LogicalName = this.LogicalFileName;
228
+ }
229
+ request.Start = start;
230
+ request.Count = count;
231
+ request.SuppressXmlSchema = suppressXmlSchema;
232
+ request.BypassCachedResult = bypassCache;
233
+ return this.connection.WUResult(request, abortSignal).then((response: unknown) => {
234
+ return response as WUResultResponseEx;
235
+ });
236
+ }
237
+ }
238
+
239
+ export class ResultCache extends Cache<WsWorkunits.ECLResult, Result> {
240
+ constructor() {
241
+ super((obj) => {
242
+ return Cache.hash([obj.Sequence, obj.Name, obj.Value, obj.FileName]);
243
+ });
244
+ }
245
+ }