@hpcc-js/comms 2.102.0 → 2.102.2

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