@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,172 +1,172 @@
1
- import { join } from "@hpcc-js/util";
2
- import { createConnection, IConnection, IOptions, ResponseType } from "./connection";
3
-
4
- export type ESPResponseType = ResponseType | "json2" | "xsd";
5
-
6
- export function isArray(arg: any) {
7
- return Object.prototype.toString.call(arg) === "[object Array]";
8
- }
9
-
10
- export interface Exception {
11
- Code: number;
12
- Message: string;
13
- }
14
-
15
- export interface Exceptions {
16
- Source: string;
17
- Exception: Exception[];
18
- }
19
-
20
- export class ESPExceptions extends Error implements Exceptions {
21
- isESPExceptions = true;
22
- action: string;
23
- request: string;
24
- Source: string;
25
- Exception: Exception[];
26
-
27
- constructor(action: string, request: any, exceptions: Exceptions) {
28
- super("ESPException: " + exceptions.Source);
29
- this.action = action;
30
- this.request = request;
31
- this.Source = exceptions.Source;
32
- this.Exception = exceptions.Exception;
33
- if (exceptions.Exception.length) {
34
- this.message = `${exceptions.Exception[0].Code}: ${exceptions.Exception[0].Message}`;
35
- } else {
36
- this.message = "";
37
- }
38
- }
39
- }
40
-
41
- export function isExceptions(err: any): err is Exceptions {
42
- return err instanceof ESPExceptions || (err.isESPExceptions && Array.isArray(err.Exception));
43
- }
44
-
45
- function isConnection(optsConnection: IOptions | IConnection): optsConnection is IConnection {
46
- return (optsConnection as IConnection).send !== undefined;
47
- }
48
-
49
- export class ESPConnection implements IConnection {
50
- private _connection: IConnection;
51
- get baseUrl() { return this._connection.opts().baseUrl; }
52
- private _service: string;
53
- private _version: string;
54
-
55
- constructor(optsConnection: IOptions | IConnection, service: string, version: string) {
56
- this._connection = isConnection(optsConnection) ? optsConnection : createConnection(optsConnection);
57
- this._service = service;
58
- this._version = version;
59
- }
60
-
61
- service(): string;
62
- service(_: string): ESPConnection;
63
- service(_?: string): string | ESPConnection {
64
- if (_ === void 0) return this._service;
65
- this._service = _;
66
- return this;
67
- }
68
-
69
- version(): string;
70
- version(_: string): ESPConnection;
71
- version(_?: string): string | ESPConnection {
72
- if (_ === void 0) return this._version;
73
- this._version = _;
74
- return this;
75
- }
76
-
77
- toESPStringArray(target: any, arrayName: string): any {
78
- if (isArray(target[arrayName])) {
79
- for (let i = 0; i < target[arrayName].length; ++i) {
80
- target[arrayName + "_i" + i] = target[arrayName][i];
81
- }
82
- delete target[arrayName];
83
- }
84
- return target;
85
- }
86
-
87
- // IConnection ---
88
- opts(_: Partial<IOptions>): this;
89
- opts(): IOptions;
90
- opts(_?: Partial<IOptions>): this | IOptions {
91
- if (_ === void 0) return this._connection.opts();
92
- this._connection.opts(_);
93
- return this;
94
- }
95
-
96
- send(action: string, _request: any = {}, espResponseType: ESPResponseType = "json", largeUpload: boolean = false, abortSignal?: AbortSignal, espResponseField?: string): Promise<any> {
97
- const request = { ..._request, ...{ ver_: this._version } };
98
- if (largeUpload) {
99
- request["upload_"] = true;
100
- }
101
- if (abortSignal) {
102
- request["abortSignal_"] = abortSignal;
103
- }
104
- let serviceAction: string;
105
- let responseType: ResponseType = "json";
106
- switch (espResponseType) {
107
- case "text":
108
- serviceAction = join(this._service, action);
109
- responseType = "text";
110
- break;
111
- case "xsd":
112
- serviceAction = join(this._service, action + ".xsd");
113
- responseType = "text";
114
- break;
115
- case "json2":
116
- serviceAction = join(this._service, action + "/json");
117
- espResponseType = "json";
118
- const actionParts = action.split("/");
119
- action = actionParts.pop()!;
120
- break;
121
- default:
122
- serviceAction = join(this._service, action + ".json");
123
- }
124
- return this._connection.send(serviceAction, request, responseType).then((response) => {
125
- if (espResponseType === "json") {
126
- let retVal;
127
- if (response && response.Exceptions) {
128
- throw new ESPExceptions(action, request, response.Exceptions);
129
- } else if (response) {
130
- retVal = response[espResponseField || (action + "Response")];
131
- }
132
- if (!retVal) {
133
- throw new ESPExceptions(action, request, {
134
- Source: "ESPConnection.send",
135
- Exception: [{ Code: 0, Message: "Missing Response" }]
136
- });
137
- }
138
- return retVal;
139
- }
140
- return response;
141
- }).catch(e => {
142
- if (e.isESPExceptions) {
143
- throw e;
144
- }
145
- throw new ESPExceptions(action, request, {
146
- Source: "ESPConnection.send",
147
- Exception: [{ Code: 0, Message: e.message }]
148
- });
149
- });
150
- }
151
-
152
- clone() {
153
- return new ESPConnection(this._connection.clone(), this._service, this._version);
154
- }
155
- }
156
-
157
- export class Service {
158
- protected _connection: ESPConnection;
159
- get baseUrl() { return this._connection.opts().baseUrl; }
160
-
161
- constructor(optsConnection: IOptions | IConnection, service: string, version: string) {
162
- this._connection = new ESPConnection(optsConnection, service, version);
163
- }
164
-
165
- opts() {
166
- return this._connection.opts();
167
- }
168
-
169
- connection(): ESPConnection {
170
- return this._connection.clone();
171
- }
172
- }
1
+ import { join } from "@hpcc-js/util";
2
+ import { createConnection, IConnection, IOptions, ResponseType } from "./connection";
3
+
4
+ export type ESPResponseType = ResponseType | "json2" | "xsd";
5
+
6
+ export function isArray(arg: any) {
7
+ return Object.prototype.toString.call(arg) === "[object Array]";
8
+ }
9
+
10
+ export interface Exception {
11
+ Code: number;
12
+ Message: string;
13
+ }
14
+
15
+ export interface Exceptions {
16
+ Source: string;
17
+ Exception: Exception[];
18
+ }
19
+
20
+ export class ESPExceptions extends Error implements Exceptions {
21
+ isESPExceptions = true;
22
+ action: string;
23
+ request: string;
24
+ Source: string;
25
+ Exception: Exception[];
26
+
27
+ constructor(action: string, request: any, exceptions: Exceptions) {
28
+ super("ESPException: " + exceptions.Source);
29
+ this.action = action;
30
+ this.request = request;
31
+ this.Source = exceptions.Source;
32
+ this.Exception = exceptions.Exception;
33
+ if (exceptions.Exception.length) {
34
+ this.message = `${exceptions.Exception[0].Code}: ${exceptions.Exception[0].Message}`;
35
+ } else {
36
+ this.message = "";
37
+ }
38
+ }
39
+ }
40
+
41
+ export function isExceptions(err: any): err is Exceptions {
42
+ return err instanceof ESPExceptions || (err.isESPExceptions && Array.isArray(err.Exception));
43
+ }
44
+
45
+ function isConnection(optsConnection: IOptions | IConnection): optsConnection is IConnection {
46
+ return (optsConnection as IConnection).send !== undefined;
47
+ }
48
+
49
+ export class ESPConnection implements IConnection {
50
+ private _connection: IConnection;
51
+ get baseUrl() { return this._connection.opts().baseUrl; }
52
+ private _service: string;
53
+ private _version: string;
54
+
55
+ constructor(optsConnection: IOptions | IConnection, service: string, version: string) {
56
+ this._connection = isConnection(optsConnection) ? optsConnection : createConnection(optsConnection);
57
+ this._service = service;
58
+ this._version = version;
59
+ }
60
+
61
+ service(): string;
62
+ service(_: string): ESPConnection;
63
+ service(_?: string): string | ESPConnection {
64
+ if (_ === void 0) return this._service;
65
+ this._service = _;
66
+ return this;
67
+ }
68
+
69
+ version(): string;
70
+ version(_: string): ESPConnection;
71
+ version(_?: string): string | ESPConnection {
72
+ if (_ === void 0) return this._version;
73
+ this._version = _;
74
+ return this;
75
+ }
76
+
77
+ toESPStringArray(target: any, arrayName: string): any {
78
+ if (isArray(target[arrayName])) {
79
+ for (let i = 0; i < target[arrayName].length; ++i) {
80
+ target[arrayName + "_i" + i] = target[arrayName][i];
81
+ }
82
+ delete target[arrayName];
83
+ }
84
+ return target;
85
+ }
86
+
87
+ // IConnection ---
88
+ opts(_: Partial<IOptions>): this;
89
+ opts(): IOptions;
90
+ opts(_?: Partial<IOptions>): this | IOptions {
91
+ if (_ === void 0) return this._connection.opts();
92
+ this._connection.opts(_);
93
+ return this;
94
+ }
95
+
96
+ send(action: string, _request: any = {}, espResponseType: ESPResponseType = "json", largeUpload: boolean = false, abortSignal?: AbortSignal, espResponseField?: string): Promise<any> {
97
+ const request = { ..._request, ...{ ver_: this._version } };
98
+ if (largeUpload) {
99
+ request["upload_"] = true;
100
+ }
101
+ if (abortSignal) {
102
+ request["abortSignal_"] = abortSignal;
103
+ }
104
+ let serviceAction: string;
105
+ let responseType: ResponseType = "json";
106
+ switch (espResponseType) {
107
+ case "text":
108
+ serviceAction = join(this._service, action);
109
+ responseType = "text";
110
+ break;
111
+ case "xsd":
112
+ serviceAction = join(this._service, action + ".xsd");
113
+ responseType = "text";
114
+ break;
115
+ case "json2":
116
+ serviceAction = join(this._service, action + "/json");
117
+ espResponseType = "json";
118
+ const actionParts = action.split("/");
119
+ action = actionParts.pop()!;
120
+ break;
121
+ default:
122
+ serviceAction = join(this._service, action + ".json");
123
+ }
124
+ return this._connection.send(serviceAction, request, responseType).then((response) => {
125
+ if (espResponseType === "json") {
126
+ let retVal;
127
+ if (response && response.Exceptions) {
128
+ throw new ESPExceptions(action, request, response.Exceptions);
129
+ } else if (response) {
130
+ retVal = response[espResponseField || (action + "Response")];
131
+ }
132
+ if (!retVal) {
133
+ throw new ESPExceptions(action, request, {
134
+ Source: "ESPConnection.send",
135
+ Exception: [{ Code: 0, Message: "Missing Response" }]
136
+ });
137
+ }
138
+ return retVal;
139
+ }
140
+ return response;
141
+ }).catch(e => {
142
+ if (e.isESPExceptions) {
143
+ throw e;
144
+ }
145
+ throw new ESPExceptions(action, request, {
146
+ Source: "ESPConnection.send",
147
+ Exception: [{ Code: 0, Message: e.message }]
148
+ });
149
+ });
150
+ }
151
+
152
+ clone() {
153
+ return new ESPConnection(this._connection.clone(), this._service, this._version);
154
+ }
155
+ }
156
+
157
+ export class Service {
158
+ protected _connection: ESPConnection;
159
+ get baseUrl() { return this._connection.opts().baseUrl; }
160
+
161
+ constructor(optsConnection: IOptions | IConnection, service: string, version: string) {
162
+ this._connection = new ESPConnection(optsConnection, service, version);
163
+ }
164
+
165
+ opts() {
166
+ return this._connection.opts();
167
+ }
168
+
169
+ connection(): ESPConnection {
170
+ return this._connection.clone();
171
+ }
172
+ }
@@ -1,41 +1,41 @@
1
- export * from "./__package__";
2
-
3
- export * from "./services/fileSpray";
4
- export * from "./services/wsAccess";
5
- export * from "./services/wsAccount";
6
- export * from "./services/wsCloud";
7
- export * from "./services/wsCodesign";
8
- export * from "./services/wsDali";
9
- export * from "./services/wsDFU";
10
- export * from "./services/wsDFUXRef";
11
- export * from "./services/wsEcl";
12
- export * from "./services/wsElk";
13
- export * from "./services/wsLogaccess";
14
- export * from "./services/wsMachine";
15
- export * from "./services/wsPackageProcess";
16
- export * from "./services/wsResources";
17
- export * from "./services/wsSasha";
18
- export * from "./services/wsSMC";
19
- export * from "./services/wsStore";
20
- export * from "./services/wsTopology";
21
- export * from "./services/wsWorkunits";
22
-
23
- export * from "./ecl/activity";
24
- export * from "./ecl/graph";
25
- export * from "./ecl/logicalFile";
26
- export * from "./ecl/machine";
27
- export * from "./ecl/query";
28
- export * from "./ecl/resource";
29
- export * from "./ecl/result";
30
- export * from "./ecl/scope";
31
- export * from "./ecl/sourceFile";
32
- export * from "./ecl/store";
33
- export * from "./ecl/timer";
34
- export * from "./ecl/topology";
35
- export * from "./ecl/targetCluster";
36
- export * from "./ecl/dfuWorkunit";
37
- export * from "./ecl/workunit";
38
- export * from "./ecl/xsdParser";
39
-
40
- export * from "./connection";
41
- export * from "./espConnection";
1
+ export * from "./__package__";
2
+
3
+ export * from "./services/fileSpray";
4
+ export * from "./services/wsAccess";
5
+ export * from "./services/wsAccount";
6
+ export * from "./services/wsCloud";
7
+ export * from "./services/wsCodesign";
8
+ export * from "./services/wsDali";
9
+ export * from "./services/wsDFU";
10
+ export * from "./services/wsDFUXRef";
11
+ export * from "./services/wsEcl";
12
+ export * from "./services/wsElk";
13
+ export * from "./services/wsLogaccess";
14
+ export * from "./services/wsMachine";
15
+ export * from "./services/wsPackageProcess";
16
+ export * from "./services/wsResources";
17
+ export * from "./services/wsSasha";
18
+ export * from "./services/wsSMC";
19
+ export * from "./services/wsStore";
20
+ export * from "./services/wsTopology";
21
+ export * from "./services/wsWorkunits";
22
+
23
+ export * from "./ecl/activity";
24
+ export * from "./ecl/graph";
25
+ export * from "./ecl/logicalFile";
26
+ export * from "./ecl/machine";
27
+ export * from "./ecl/query";
28
+ export * from "./ecl/resource";
29
+ export * from "./ecl/result";
30
+ export * from "./ecl/scope";
31
+ export * from "./ecl/sourceFile";
32
+ export * from "./ecl/store";
33
+ export * from "./ecl/timer";
34
+ export * from "./ecl/topology";
35
+ export * from "./ecl/targetCluster";
36
+ export * from "./ecl/dfuWorkunit";
37
+ export * from "./ecl/workunit";
38
+ export * from "./ecl/xsdParser";
39
+
40
+ export * from "./connection";
41
+ export * from "./espConnection";
package/src/index.node.ts CHANGED
@@ -1,68 +1,68 @@
1
- // DOM Parser polyfill ---
2
- import { root } from "@hpcc-js/util";
3
- import { DOMParser } from "@xmldom/xmldom";
4
- root.DOMParser = DOMParser;
5
-
6
- // fetch polyfill ---
7
- import fetch from "node-fetch";
8
- import * as https from "https";
9
- import { Agent, setGlobalDispatcher } from "undici";
10
-
11
- if (typeof root.fetch === "undefined") {
12
- // NodeJS < v18 ---
13
- root.fetch = fetch;
14
- root.fetch.__rejectUnauthorizedAgent = new https.Agent({
15
- rejectUnauthorized: false
16
- });
17
- } else {
18
- // NodeJS >= v18 ---
19
- root.fetch.__defaultAgent = new Agent();
20
- root.fetch.__rejectUnauthorizedAgent = new Agent({
21
- connect: {
22
- rejectUnauthorized: false
23
- }
24
- });
25
- root.fetch.__setGlobalDispatcher = setGlobalDispatcher;
26
- }
27
-
28
- // AbortController polyfill ---
29
- import AbortController from "abort-controller";
30
- if (typeof root.AbortController === "undefined") {
31
- root.AbortController = AbortController;
32
- }
33
-
34
- import { trustwave } from "./pem/trustwave";
35
-
36
- let globalCA = "";
37
- if (https.globalAgent.options.ca !== undefined) {
38
- if (Array.isArray(https.globalAgent.options.ca) && https.globalAgent.options.ca.length) {
39
- if (typeof https.globalAgent.options.ca[0] === "string") {
40
- globalCA = https.globalAgent.options.ca.join("\n");
41
- } else if (https.globalAgent.options.ca[0] instanceof Buffer) {
42
- globalCA = https.globalAgent.options.ca.map(row => row.toString()).join("\n");
43
- }
44
- } else if (typeof https.globalAgent.options.ca === "string") {
45
- globalCA = https.globalAgent.options.ca;
46
- } else if (https.globalAgent.options.ca instanceof Buffer) {
47
- globalCA = https.globalAgent.options.ca.toString();
48
- }
49
- globalCA += "\n";
50
- }
51
-
52
- root.fetch.__trustwaveAgent = new https.Agent({
53
- ca: globalCA + trustwave
54
- });
55
-
56
- // btoa polyfill ---
57
- import { Buffer } from "safe-buffer";
58
- if (typeof root.btoa === "undefined") {
59
- root.btoa = function (str: string) {
60
- return Buffer.from(str || "", "utf8").toString("base64");
61
- };
62
- }
63
-
64
- export * from "./index-common";
65
-
66
- // Client Tools ---
67
- export * from "./clienttools/eclcc";
68
- export * from "./clienttools/eclMeta";
1
+ // DOM Parser polyfill ---
2
+ import { root } from "@hpcc-js/util";
3
+ import { DOMParser } from "@xmldom/xmldom";
4
+ root.DOMParser = DOMParser;
5
+
6
+ // fetch polyfill ---
7
+ import fetch from "node-fetch";
8
+ import * as https from "https";
9
+ import { Agent, setGlobalDispatcher } from "undici";
10
+
11
+ if (typeof root.fetch === "undefined") {
12
+ // NodeJS < v18 ---
13
+ root.fetch = fetch;
14
+ root.fetch.__rejectUnauthorizedAgent = new https.Agent({
15
+ rejectUnauthorized: false
16
+ });
17
+ } else {
18
+ // NodeJS >= v18 ---
19
+ root.fetch.__defaultAgent = new Agent();
20
+ root.fetch.__rejectUnauthorizedAgent = new Agent({
21
+ connect: {
22
+ rejectUnauthorized: false
23
+ }
24
+ });
25
+ root.fetch.__setGlobalDispatcher = setGlobalDispatcher;
26
+ }
27
+
28
+ // AbortController polyfill ---
29
+ import AbortController from "abort-controller";
30
+ if (typeof root.AbortController === "undefined") {
31
+ root.AbortController = AbortController;
32
+ }
33
+
34
+ import { trustwave } from "./pem/trustwave";
35
+
36
+ let globalCA = "";
37
+ if (https.globalAgent.options.ca !== undefined) {
38
+ if (Array.isArray(https.globalAgent.options.ca) && https.globalAgent.options.ca.length) {
39
+ if (typeof https.globalAgent.options.ca[0] === "string") {
40
+ globalCA = https.globalAgent.options.ca.join("\n");
41
+ } else if (https.globalAgent.options.ca[0] instanceof Buffer) {
42
+ globalCA = https.globalAgent.options.ca.map(row => row.toString()).join("\n");
43
+ }
44
+ } else if (typeof https.globalAgent.options.ca === "string") {
45
+ globalCA = https.globalAgent.options.ca;
46
+ } else if (https.globalAgent.options.ca instanceof Buffer) {
47
+ globalCA = https.globalAgent.options.ca.toString();
48
+ }
49
+ globalCA += "\n";
50
+ }
51
+
52
+ root.fetch.__trustwaveAgent = new https.Agent({
53
+ ca: globalCA + trustwave
54
+ });
55
+
56
+ // btoa polyfill ---
57
+ import { Buffer } from "safe-buffer";
58
+ if (typeof root.btoa === "undefined") {
59
+ root.btoa = function (str: string) {
60
+ return Buffer.from(str || "", "utf8").toString("base64");
61
+ };
62
+ }
63
+
64
+ export * from "./index-common";
65
+
66
+ // Client Tools ---
67
+ export * from "./clienttools/eclcc";
68
+ export * from "./clienttools/eclMeta";
package/src/index.ts CHANGED
@@ -1,3 +1,3 @@
1
- import "whatwg-fetch";
2
-
3
- export * from "./index-common";
1
+ import "whatwg-fetch";
2
+
3
+ export * from "./index-common";