@io-orkes/conductor-javascript 1.2.0-rc.2 → 1.2.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +227 -141
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +244 -133
- package/dist/index.mjs.map +1 -1
- package/package.json +16 -2
package/dist/index.js
CHANGED
|
@@ -5,6 +5,12 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __esm = (fn, res) => function __init() {
|
|
9
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
+
};
|
|
11
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
12
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
13
|
+
};
|
|
8
14
|
var __export = (target, all) => {
|
|
9
15
|
for (var name in all)
|
|
10
16
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -27,6 +33,219 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
33
|
));
|
|
28
34
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
35
|
|
|
36
|
+
// src/common/ConductorLogger.ts
|
|
37
|
+
var LOG_LEVELS, DefaultLogger, noopLogger;
|
|
38
|
+
var init_ConductorLogger = __esm({
|
|
39
|
+
"src/common/ConductorLogger.ts"() {
|
|
40
|
+
"use strict";
|
|
41
|
+
LOG_LEVELS = {
|
|
42
|
+
DEBUG: 10,
|
|
43
|
+
INFO: 30,
|
|
44
|
+
ERROR: 60
|
|
45
|
+
};
|
|
46
|
+
DefaultLogger = class {
|
|
47
|
+
constructor(config = {}) {
|
|
48
|
+
this.info = (...args) => {
|
|
49
|
+
this.log("INFO", ...args);
|
|
50
|
+
};
|
|
51
|
+
this.debug = (...args) => {
|
|
52
|
+
this.log("DEBUG", ...args);
|
|
53
|
+
};
|
|
54
|
+
this.error = (...args) => {
|
|
55
|
+
this.log("ERROR", ...args);
|
|
56
|
+
};
|
|
57
|
+
const { level, tags = [] } = config;
|
|
58
|
+
this.tags = tags;
|
|
59
|
+
if (level && level in LOG_LEVELS) {
|
|
60
|
+
this.level = LOG_LEVELS[level];
|
|
61
|
+
} else {
|
|
62
|
+
this.level = LOG_LEVELS.INFO;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
log(level, ...args) {
|
|
66
|
+
let resolvedLevel;
|
|
67
|
+
let name = level;
|
|
68
|
+
if (level in LOG_LEVELS) {
|
|
69
|
+
resolvedLevel = LOG_LEVELS[level];
|
|
70
|
+
} else {
|
|
71
|
+
name = "INFO";
|
|
72
|
+
resolvedLevel = LOG_LEVELS.INFO;
|
|
73
|
+
}
|
|
74
|
+
if (resolvedLevel >= this.level) {
|
|
75
|
+
console.log(name, ...this.tags, ...args);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
noopLogger = {
|
|
80
|
+
//eslint-disable-next-line
|
|
81
|
+
debug: (...args) => {
|
|
82
|
+
},
|
|
83
|
+
//eslint-disable-next-line
|
|
84
|
+
info: (...args) => {
|
|
85
|
+
},
|
|
86
|
+
//eslint-disable-next-line
|
|
87
|
+
error: (...args) => {
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// src/orkes/request/fetchCatchDns/DnsResolver.ts
|
|
94
|
+
var import_dns, DEFAULT_OPTIONS, dnsResolver;
|
|
95
|
+
var init_DnsResolver = __esm({
|
|
96
|
+
"src/orkes/request/fetchCatchDns/DnsResolver.ts"() {
|
|
97
|
+
"use strict";
|
|
98
|
+
import_dns = require("dns");
|
|
99
|
+
init_ConductorLogger();
|
|
100
|
+
DEFAULT_OPTIONS = {
|
|
101
|
+
logger: noopLogger,
|
|
102
|
+
resolver: import_dns.promises.resolve4
|
|
103
|
+
};
|
|
104
|
+
dnsResolver = async (host, { resolver = import_dns.promises.resolve4, logger = console } = DEFAULT_OPTIONS) => {
|
|
105
|
+
try {
|
|
106
|
+
const addresses = await resolver(host);
|
|
107
|
+
if (addresses.length > 0)
|
|
108
|
+
return addresses[0];
|
|
109
|
+
} catch (e) {
|
|
110
|
+
logger.error("Could not resolve host: " + host + " error: " + e);
|
|
111
|
+
}
|
|
112
|
+
return void 0;
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
// src/orkes/request/fetchCatchDns/DnsCache.ts
|
|
118
|
+
var DnsCacheResolver;
|
|
119
|
+
var init_DnsCache = __esm({
|
|
120
|
+
"src/orkes/request/fetchCatchDns/DnsCache.ts"() {
|
|
121
|
+
"use strict";
|
|
122
|
+
init_DnsResolver();
|
|
123
|
+
DnsCacheResolver = class {
|
|
124
|
+
constructor({ initialCache = /* @__PURE__ */ new Map() } = {}) {
|
|
125
|
+
this._cache = /* @__PURE__ */ new Map();
|
|
126
|
+
this._cache = initialCache;
|
|
127
|
+
}
|
|
128
|
+
async resolve(host) {
|
|
129
|
+
const cachedIp = this._cache.get(host);
|
|
130
|
+
if (cachedIp) {
|
|
131
|
+
return cachedIp;
|
|
132
|
+
}
|
|
133
|
+
const ip = await dnsResolver(host);
|
|
134
|
+
if (ip != void 0) {
|
|
135
|
+
this._cache.set(host, ip);
|
|
136
|
+
}
|
|
137
|
+
return ip;
|
|
138
|
+
}
|
|
139
|
+
clearCache() {
|
|
140
|
+
this._cache.clear();
|
|
141
|
+
}
|
|
142
|
+
get cache() {
|
|
143
|
+
return this._cache;
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
// src/orkes/request/fetchCatchDns/fetchCatchDns.ts
|
|
150
|
+
var import_net, isEmpty, toMaybeUrl, DEFAULT_OPTIONS2, fetchCatchDns;
|
|
151
|
+
var init_fetchCatchDns = __esm({
|
|
152
|
+
"src/orkes/request/fetchCatchDns/fetchCatchDns.ts"() {
|
|
153
|
+
"use strict";
|
|
154
|
+
import_net = require("net");
|
|
155
|
+
init_DnsCache();
|
|
156
|
+
isEmpty = (value) => {
|
|
157
|
+
return value === void 0 || value.trim().length === 0;
|
|
158
|
+
};
|
|
159
|
+
toMaybeUrl = (originalUrl, modifiedParams) => {
|
|
160
|
+
const urlToHit = new URL(originalUrl.toString());
|
|
161
|
+
urlToHit.host = isEmpty(modifiedParams.port) ? `${modifiedParams.host}:${modifiedParams.port}` : modifiedParams.host;
|
|
162
|
+
return urlToHit;
|
|
163
|
+
};
|
|
164
|
+
DEFAULT_OPTIONS2 = {
|
|
165
|
+
dnsCache: new DnsCacheResolver(),
|
|
166
|
+
headerFactory: (headers) => new Headers(headers || {})
|
|
167
|
+
};
|
|
168
|
+
fetchCatchDns = (fetch2, {
|
|
169
|
+
dnsCache = new DnsCacheResolver(),
|
|
170
|
+
headerFactory = (headers) => new Headers(headers || {})
|
|
171
|
+
} = DEFAULT_OPTIONS2) => {
|
|
172
|
+
const fetchWithDns = async (input, options) => {
|
|
173
|
+
const parsedUrl = new URL(input.toString());
|
|
174
|
+
const { hostname, host, port } = parsedUrl;
|
|
175
|
+
if ((0, import_net.isIP)(hostname)) {
|
|
176
|
+
return await fetch2(input, options);
|
|
177
|
+
}
|
|
178
|
+
const maybeTargetIp = await dnsCache.resolve(hostname);
|
|
179
|
+
if (isEmpty(maybeTargetIp)) {
|
|
180
|
+
return await fetch2(input, options);
|
|
181
|
+
}
|
|
182
|
+
const target = toMaybeUrl(input, {
|
|
183
|
+
...parsedUrl,
|
|
184
|
+
host: maybeTargetIp,
|
|
185
|
+
port
|
|
186
|
+
});
|
|
187
|
+
const headersOverride = headerFactory(options?.headers ?? {});
|
|
188
|
+
if (!headersOverride.has("Host")) {
|
|
189
|
+
headersOverride.set("Host", host);
|
|
190
|
+
}
|
|
191
|
+
const optionsOverride = {
|
|
192
|
+
...options,
|
|
193
|
+
headers: headersOverride
|
|
194
|
+
};
|
|
195
|
+
const res = await fetch2(target.toString(), optionsOverride);
|
|
196
|
+
return res;
|
|
197
|
+
};
|
|
198
|
+
return fetchWithDns;
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
// src/orkes/request/fetchCatchDns/index.ts
|
|
204
|
+
var fetchCatchDns_exports = {};
|
|
205
|
+
__export(fetchCatchDns_exports, {
|
|
206
|
+
DnsCacheResolver: () => DnsCacheResolver,
|
|
207
|
+
fetchCatchDns: () => fetchCatchDns,
|
|
208
|
+
toMaybeUrl: () => toMaybeUrl
|
|
209
|
+
});
|
|
210
|
+
var init_fetchCatchDns2 = __esm({
|
|
211
|
+
"src/orkes/request/fetchCatchDns/index.ts"() {
|
|
212
|
+
"use strict";
|
|
213
|
+
init_DnsCache();
|
|
214
|
+
init_fetchCatchDns();
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
// src/orkes/fetchImplementation.js
|
|
219
|
+
var require_fetchImplementation = __commonJS({
|
|
220
|
+
"src/orkes/fetchImplementation.js"(exports, module2) {
|
|
221
|
+
"use strict";
|
|
222
|
+
var fetchCatchDns2 = (init_fetchCatchDns2(), __toCommonJS(fetchCatchDns_exports)).fetchCatchDns;
|
|
223
|
+
var fetchImplementation = fetch;
|
|
224
|
+
var nodeFetchAvailable = false;
|
|
225
|
+
try {
|
|
226
|
+
require.resolve("node-fetch");
|
|
227
|
+
nodeFetchAvailable = true;
|
|
228
|
+
} catch (e) {
|
|
229
|
+
}
|
|
230
|
+
if (nodeFetchAvailable) {
|
|
231
|
+
const nodeFetch = require("node-fetch");
|
|
232
|
+
const nodeFetchWrapper = async (input, options = {}) => {
|
|
233
|
+
const res = await fetch(input.toString(), options);
|
|
234
|
+
return res;
|
|
235
|
+
};
|
|
236
|
+
const fetchCache2 = fetchCatchDns2(nodeFetchWrapper, {
|
|
237
|
+
headerFactory: (headers) => new nodeFetch.Headers(headers || {})
|
|
238
|
+
});
|
|
239
|
+
fetchImplementation = fetchCache2;
|
|
240
|
+
console.log("Using node fetch");
|
|
241
|
+
} else {
|
|
242
|
+
fetchImplementation = fetchCatchDns2(fetch);
|
|
243
|
+
console.log("Using native fetch");
|
|
244
|
+
}
|
|
245
|
+
module2.exports = fetchImplementation;
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
|
|
30
249
|
// index.ts
|
|
31
250
|
var conductor_javascript_exports = {};
|
|
32
251
|
__export(conductor_javascript_exports, {
|
|
@@ -99,56 +318,8 @@ __export(conductor_javascript_exports, {
|
|
|
99
318
|
});
|
|
100
319
|
module.exports = __toCommonJS(conductor_javascript_exports);
|
|
101
320
|
|
|
102
|
-
// src/common/
|
|
103
|
-
|
|
104
|
-
DEBUG: 10,
|
|
105
|
-
INFO: 30,
|
|
106
|
-
ERROR: 60
|
|
107
|
-
};
|
|
108
|
-
var DefaultLogger = class {
|
|
109
|
-
constructor(config = {}) {
|
|
110
|
-
this.info = (...args) => {
|
|
111
|
-
this.log("INFO", ...args);
|
|
112
|
-
};
|
|
113
|
-
this.debug = (...args) => {
|
|
114
|
-
this.log("DEBUG", ...args);
|
|
115
|
-
};
|
|
116
|
-
this.error = (...args) => {
|
|
117
|
-
this.log("ERROR", ...args);
|
|
118
|
-
};
|
|
119
|
-
const { level, tags = [] } = config;
|
|
120
|
-
this.tags = tags;
|
|
121
|
-
if (level && level in LOG_LEVELS) {
|
|
122
|
-
this.level = LOG_LEVELS[level];
|
|
123
|
-
} else {
|
|
124
|
-
this.level = LOG_LEVELS.INFO;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
log(level, ...args) {
|
|
128
|
-
let resolvedLevel;
|
|
129
|
-
let name = level;
|
|
130
|
-
if (level in LOG_LEVELS) {
|
|
131
|
-
resolvedLevel = LOG_LEVELS[level];
|
|
132
|
-
} else {
|
|
133
|
-
name = "INFO";
|
|
134
|
-
resolvedLevel = LOG_LEVELS.INFO;
|
|
135
|
-
}
|
|
136
|
-
if (resolvedLevel >= this.level) {
|
|
137
|
-
console.log(name, ...this.tags, ...args);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
var noopLogger = {
|
|
142
|
-
//eslint-disable-next-line
|
|
143
|
-
debug: (...args) => {
|
|
144
|
-
},
|
|
145
|
-
//eslint-disable-next-line
|
|
146
|
-
info: (...args) => {
|
|
147
|
-
},
|
|
148
|
-
//eslint-disable-next-line
|
|
149
|
-
error: (...args) => {
|
|
150
|
-
}
|
|
151
|
-
};
|
|
321
|
+
// src/common/index.ts
|
|
322
|
+
init_ConductorLogger();
|
|
152
323
|
|
|
153
324
|
// src/common/types.ts
|
|
154
325
|
var TaskType = /* @__PURE__ */ ((TaskType2) => {
|
|
@@ -3469,95 +3640,6 @@ var workflow = (name, tasks) => ({
|
|
|
3469
3640
|
timeoutSeconds: 0
|
|
3470
3641
|
});
|
|
3471
3642
|
|
|
3472
|
-
// src/orkes/request/fetchCatchDns/DnsResolver.ts
|
|
3473
|
-
var import_dns = require("dns");
|
|
3474
|
-
var DEFAULT_OPTIONS = {
|
|
3475
|
-
logger: noopLogger,
|
|
3476
|
-
resolver: import_dns.promises.resolve4
|
|
3477
|
-
};
|
|
3478
|
-
var dnsResolver = async (host, { resolver = import_dns.promises.resolve4, logger = console } = DEFAULT_OPTIONS) => {
|
|
3479
|
-
try {
|
|
3480
|
-
const addresses = await resolver(host);
|
|
3481
|
-
if (addresses.length > 0)
|
|
3482
|
-
return addresses[0];
|
|
3483
|
-
} catch (e) {
|
|
3484
|
-
logger.error("Could not resolve host: " + host + " error: " + e);
|
|
3485
|
-
}
|
|
3486
|
-
return void 0;
|
|
3487
|
-
};
|
|
3488
|
-
|
|
3489
|
-
// src/orkes/request/fetchCatchDns/DnsCache.ts
|
|
3490
|
-
var DnsCacheResolver = class {
|
|
3491
|
-
constructor({ initialCache = /* @__PURE__ */ new Map() } = {}) {
|
|
3492
|
-
this._cache = /* @__PURE__ */ new Map();
|
|
3493
|
-
this._cache = initialCache;
|
|
3494
|
-
}
|
|
3495
|
-
async resolve(host) {
|
|
3496
|
-
const cachedIp = this._cache.get(host);
|
|
3497
|
-
if (cachedIp) {
|
|
3498
|
-
return cachedIp;
|
|
3499
|
-
}
|
|
3500
|
-
const ip = await dnsResolver(host);
|
|
3501
|
-
if (ip != void 0) {
|
|
3502
|
-
this._cache.set(host, ip);
|
|
3503
|
-
}
|
|
3504
|
-
return ip;
|
|
3505
|
-
}
|
|
3506
|
-
clearCache() {
|
|
3507
|
-
this._cache.clear();
|
|
3508
|
-
}
|
|
3509
|
-
get cache() {
|
|
3510
|
-
return this._cache;
|
|
3511
|
-
}
|
|
3512
|
-
};
|
|
3513
|
-
|
|
3514
|
-
// src/orkes/request/fetchCatchDns/fetchCatchDns.ts
|
|
3515
|
-
var import_net = require("net");
|
|
3516
|
-
var isEmpty = (value) => {
|
|
3517
|
-
return value === void 0 || value.trim().length === 0;
|
|
3518
|
-
};
|
|
3519
|
-
var toMaybeUrl = (originalUrl, modifiedParams) => {
|
|
3520
|
-
const urlToHit = new URL(originalUrl.toString());
|
|
3521
|
-
urlToHit.host = isEmpty(modifiedParams.port) ? `${modifiedParams.host}:${modifiedParams.port}` : modifiedParams.host;
|
|
3522
|
-
return urlToHit;
|
|
3523
|
-
};
|
|
3524
|
-
var DEFAULT_OPTIONS2 = {
|
|
3525
|
-
dnsCache: new DnsCacheResolver(),
|
|
3526
|
-
headerFactory: (headers) => new Headers(headers || {})
|
|
3527
|
-
};
|
|
3528
|
-
var fetchCatchDns = (fetch2, {
|
|
3529
|
-
dnsCache = new DnsCacheResolver(),
|
|
3530
|
-
headerFactory = (headers) => new Headers(headers || {})
|
|
3531
|
-
} = DEFAULT_OPTIONS2) => {
|
|
3532
|
-
const fetchWithDns = async (input, options) => {
|
|
3533
|
-
const parsedUrl = new URL(input.toString());
|
|
3534
|
-
const { hostname, host, port } = parsedUrl;
|
|
3535
|
-
if ((0, import_net.isIP)(hostname)) {
|
|
3536
|
-
return await fetch2(input, options);
|
|
3537
|
-
}
|
|
3538
|
-
const maybeTargetIp = await dnsCache.resolve(hostname);
|
|
3539
|
-
if (isEmpty(maybeTargetIp)) {
|
|
3540
|
-
return await fetch2(input, options);
|
|
3541
|
-
}
|
|
3542
|
-
const target = toMaybeUrl(input, {
|
|
3543
|
-
...parsedUrl,
|
|
3544
|
-
host: maybeTargetIp,
|
|
3545
|
-
port
|
|
3546
|
-
});
|
|
3547
|
-
const headersOverride = headerFactory(options?.headers ?? {});
|
|
3548
|
-
if (!headersOverride.has("Host")) {
|
|
3549
|
-
headersOverride.set("Host", host);
|
|
3550
|
-
}
|
|
3551
|
-
const optionsOverride = {
|
|
3552
|
-
...options,
|
|
3553
|
-
headers: headersOverride
|
|
3554
|
-
};
|
|
3555
|
-
const res = await fetch2(target.toString(), optionsOverride);
|
|
3556
|
-
return res;
|
|
3557
|
-
};
|
|
3558
|
-
return fetchWithDns;
|
|
3559
|
-
};
|
|
3560
|
-
|
|
3561
3643
|
// src/orkes/request/request.ts
|
|
3562
3644
|
var isDefined2 = (value) => {
|
|
3563
3645
|
return value !== void 0 && value !== null;
|
|
@@ -3853,12 +3935,16 @@ var baseOrkesConductorClient = (fetchFn, baseRequestHandler = defaultRequestHand
|
|
|
3853
3935
|
};
|
|
3854
3936
|
|
|
3855
3937
|
// src/orkes/OrkesConductorClient.ts
|
|
3856
|
-
var fetchCache =
|
|
3857
|
-
var defaultRequestHandler3 = (__request, config, options) => request2(config, options,
|
|
3938
|
+
var fetchCache = require_fetchImplementation();
|
|
3939
|
+
var defaultRequestHandler3 = (__request, config, options) => request2(config, options, fetch);
|
|
3858
3940
|
var orkesConductorClient = baseOrkesConductorClient(
|
|
3941
|
+
//@ts-ignore
|
|
3859
3942
|
fetchCache,
|
|
3860
3943
|
defaultRequestHandler3
|
|
3861
3944
|
);
|
|
3945
|
+
|
|
3946
|
+
// src/orkes/index.ts
|
|
3947
|
+
init_fetchCatchDns2();
|
|
3862
3948
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3863
3949
|
0 && (module.exports = {
|
|
3864
3950
|
ApiError,
|