@io-orkes/conductor-javascript 1.2.0-rc.4 → 1.2.0-rc.5
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 +152 -227
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +144 -244
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,249 +1,53 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
6
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
7
|
-
}) : x)(function(x) {
|
|
8
|
-
if (typeof require !== "undefined")
|
|
9
|
-
return require.apply(this, arguments);
|
|
10
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
11
|
-
});
|
|
12
|
-
var __esm = (fn, res) => function __init() {
|
|
13
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
14
|
-
};
|
|
15
|
-
var __commonJS = (cb, mod) => function __require2() {
|
|
16
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
17
|
-
};
|
|
18
|
-
var __export = (target, all) => {
|
|
19
|
-
for (var name in all)
|
|
20
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
21
|
-
};
|
|
22
|
-
var __copyProps = (to, from, except, desc) => {
|
|
23
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
24
|
-
for (let key of __getOwnPropNames(from))
|
|
25
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
26
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
27
|
-
}
|
|
28
|
-
return to;
|
|
29
|
-
};
|
|
30
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
31
|
-
|
|
32
1
|
// src/common/ConductorLogger.ts
|
|
33
|
-
var LOG_LEVELS
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
DefaultLogger = class {
|
|
43
|
-
constructor(config = {}) {
|
|
44
|
-
this.info = (...args) => {
|
|
45
|
-
this.log("INFO", ...args);
|
|
46
|
-
};
|
|
47
|
-
this.debug = (...args) => {
|
|
48
|
-
this.log("DEBUG", ...args);
|
|
49
|
-
};
|
|
50
|
-
this.error = (...args) => {
|
|
51
|
-
this.log("ERROR", ...args);
|
|
52
|
-
};
|
|
53
|
-
const { level, tags = [] } = config;
|
|
54
|
-
this.tags = tags;
|
|
55
|
-
if (level && level in LOG_LEVELS) {
|
|
56
|
-
this.level = LOG_LEVELS[level];
|
|
57
|
-
} else {
|
|
58
|
-
this.level = LOG_LEVELS.INFO;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
log(level, ...args) {
|
|
62
|
-
let resolvedLevel;
|
|
63
|
-
let name = level;
|
|
64
|
-
if (level in LOG_LEVELS) {
|
|
65
|
-
resolvedLevel = LOG_LEVELS[level];
|
|
66
|
-
} else {
|
|
67
|
-
name = "INFO";
|
|
68
|
-
resolvedLevel = LOG_LEVELS.INFO;
|
|
69
|
-
}
|
|
70
|
-
if (resolvedLevel >= this.level) {
|
|
71
|
-
console.log(name, ...this.tags, ...args);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
noopLogger = {
|
|
76
|
-
//eslint-disable-next-line
|
|
77
|
-
debug: (...args) => {
|
|
78
|
-
},
|
|
79
|
-
//eslint-disable-next-line
|
|
80
|
-
info: (...args) => {
|
|
81
|
-
},
|
|
82
|
-
//eslint-disable-next-line
|
|
83
|
-
error: (...args) => {
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
// src/orkes/request/fetchCatchDns/DnsResolver.ts
|
|
90
|
-
import { promises } from "dns";
|
|
91
|
-
var DEFAULT_OPTIONS, dnsResolver;
|
|
92
|
-
var init_DnsResolver = __esm({
|
|
93
|
-
"src/orkes/request/fetchCatchDns/DnsResolver.ts"() {
|
|
94
|
-
"use strict";
|
|
95
|
-
init_ConductorLogger();
|
|
96
|
-
DEFAULT_OPTIONS = {
|
|
97
|
-
logger: noopLogger,
|
|
98
|
-
resolver: promises.resolve4
|
|
99
|
-
};
|
|
100
|
-
dnsResolver = async (host, { resolver = promises.resolve4, logger = console } = DEFAULT_OPTIONS) => {
|
|
101
|
-
try {
|
|
102
|
-
const addresses = await resolver(host);
|
|
103
|
-
if (addresses.length > 0)
|
|
104
|
-
return addresses[0];
|
|
105
|
-
} catch (e) {
|
|
106
|
-
logger.error("Could not resolve host: " + host + " error: " + e);
|
|
107
|
-
}
|
|
108
|
-
return void 0;
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
// src/orkes/request/fetchCatchDns/DnsCache.ts
|
|
114
|
-
var DnsCacheResolver;
|
|
115
|
-
var init_DnsCache = __esm({
|
|
116
|
-
"src/orkes/request/fetchCatchDns/DnsCache.ts"() {
|
|
117
|
-
"use strict";
|
|
118
|
-
init_DnsResolver();
|
|
119
|
-
DnsCacheResolver = class {
|
|
120
|
-
constructor({ initialCache = /* @__PURE__ */ new Map() } = {}) {
|
|
121
|
-
this._cache = /* @__PURE__ */ new Map();
|
|
122
|
-
this._cache = initialCache;
|
|
123
|
-
}
|
|
124
|
-
async resolve(host) {
|
|
125
|
-
const cachedIp = this._cache.get(host);
|
|
126
|
-
if (cachedIp) {
|
|
127
|
-
return cachedIp;
|
|
128
|
-
}
|
|
129
|
-
const ip = await dnsResolver(host);
|
|
130
|
-
if (ip != void 0) {
|
|
131
|
-
this._cache.set(host, ip);
|
|
132
|
-
}
|
|
133
|
-
return ip;
|
|
134
|
-
}
|
|
135
|
-
clearCache() {
|
|
136
|
-
this._cache.clear();
|
|
137
|
-
}
|
|
138
|
-
get cache() {
|
|
139
|
-
return this._cache;
|
|
140
|
-
}
|
|
2
|
+
var LOG_LEVELS = {
|
|
3
|
+
DEBUG: 10,
|
|
4
|
+
INFO: 30,
|
|
5
|
+
ERROR: 60
|
|
6
|
+
};
|
|
7
|
+
var DefaultLogger = class {
|
|
8
|
+
constructor(config = {}) {
|
|
9
|
+
this.info = (...args) => {
|
|
10
|
+
this.log("INFO", ...args);
|
|
141
11
|
};
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
// src/orkes/request/fetchCatchDns/fetchCatchDns.ts
|
|
146
|
-
import { isIP } from "net";
|
|
147
|
-
var isEmpty, toMaybeUrl, DEFAULT_OPTIONS2, fetchCatchDns;
|
|
148
|
-
var init_fetchCatchDns = __esm({
|
|
149
|
-
"src/orkes/request/fetchCatchDns/fetchCatchDns.ts"() {
|
|
150
|
-
"use strict";
|
|
151
|
-
init_DnsCache();
|
|
152
|
-
isEmpty = (value) => {
|
|
153
|
-
return value === void 0 || value.trim().length === 0;
|
|
12
|
+
this.debug = (...args) => {
|
|
13
|
+
this.log("DEBUG", ...args);
|
|
154
14
|
};
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
urlToHit.host = isEmpty(modifiedParams.port) ? `${modifiedParams.host}:${modifiedParams.port}` : modifiedParams.host;
|
|
158
|
-
return urlToHit;
|
|
15
|
+
this.error = (...args) => {
|
|
16
|
+
this.log("ERROR", ...args);
|
|
159
17
|
};
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
headerFactory = (headers) => new Headers(headers || {})
|
|
167
|
-
} = DEFAULT_OPTIONS2) => {
|
|
168
|
-
const fetchWithDns = async (input, options) => {
|
|
169
|
-
const parsedUrl = new URL(input.toString());
|
|
170
|
-
const { hostname, host, port } = parsedUrl;
|
|
171
|
-
if (isIP(hostname)) {
|
|
172
|
-
return await fetch2(input, options);
|
|
173
|
-
}
|
|
174
|
-
const maybeTargetIp = await dnsCache.resolve(hostname);
|
|
175
|
-
if (isEmpty(maybeTargetIp)) {
|
|
176
|
-
return await fetch2(input, options);
|
|
177
|
-
}
|
|
178
|
-
const target = toMaybeUrl(input, {
|
|
179
|
-
...parsedUrl,
|
|
180
|
-
host: maybeTargetIp,
|
|
181
|
-
port
|
|
182
|
-
});
|
|
183
|
-
const headersOverride = headerFactory(options?.headers ?? {});
|
|
184
|
-
if (!headersOverride.has("Host")) {
|
|
185
|
-
headersOverride.set("Host", host);
|
|
186
|
-
}
|
|
187
|
-
const optionsOverride = {
|
|
188
|
-
...options,
|
|
189
|
-
headers: headersOverride
|
|
190
|
-
};
|
|
191
|
-
const res = await fetch2(target.toString(), optionsOverride);
|
|
192
|
-
return res;
|
|
193
|
-
};
|
|
194
|
-
return fetchWithDns;
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
// src/orkes/request/fetchCatchDns/index.ts
|
|
200
|
-
var fetchCatchDns_exports = {};
|
|
201
|
-
__export(fetchCatchDns_exports, {
|
|
202
|
-
DnsCacheResolver: () => DnsCacheResolver,
|
|
203
|
-
fetchCatchDns: () => fetchCatchDns,
|
|
204
|
-
toMaybeUrl: () => toMaybeUrl
|
|
205
|
-
});
|
|
206
|
-
var init_fetchCatchDns2 = __esm({
|
|
207
|
-
"src/orkes/request/fetchCatchDns/index.ts"() {
|
|
208
|
-
"use strict";
|
|
209
|
-
init_DnsCache();
|
|
210
|
-
init_fetchCatchDns();
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
// src/orkes/fetchImplementation.js
|
|
215
|
-
var require_fetchImplementation = __commonJS({
|
|
216
|
-
"src/orkes/fetchImplementation.js"(exports, module) {
|
|
217
|
-
"use strict";
|
|
218
|
-
var fetchCatchDns2 = (init_fetchCatchDns2(), __toCommonJS(fetchCatchDns_exports)).fetchCatchDns;
|
|
219
|
-
var fetchImplementation = fetch;
|
|
220
|
-
var nodeFetchAvailable = false;
|
|
221
|
-
try {
|
|
222
|
-
__require.resolve("node-fetch");
|
|
223
|
-
nodeFetchAvailable = true;
|
|
224
|
-
} catch (e) {
|
|
18
|
+
const { level, tags = [] } = config;
|
|
19
|
+
this.tags = tags;
|
|
20
|
+
if (level && level in LOG_LEVELS) {
|
|
21
|
+
this.level = LOG_LEVELS[level];
|
|
22
|
+
} else {
|
|
23
|
+
this.level = LOG_LEVELS.INFO;
|
|
225
24
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
const fetchCache2 = fetchCatchDns2(nodeFetchWrapper, {
|
|
233
|
-
headerFactory: (headers) => new nodeFetch.Headers(headers || {})
|
|
234
|
-
});
|
|
235
|
-
fetchImplementation = fetchCache2;
|
|
236
|
-
console.log("Using node fetch");
|
|
25
|
+
}
|
|
26
|
+
log(level, ...args) {
|
|
27
|
+
let resolvedLevel;
|
|
28
|
+
let name = level;
|
|
29
|
+
if (level in LOG_LEVELS) {
|
|
30
|
+
resolvedLevel = LOG_LEVELS[level];
|
|
237
31
|
} else {
|
|
238
|
-
|
|
239
|
-
|
|
32
|
+
name = "INFO";
|
|
33
|
+
resolvedLevel = LOG_LEVELS.INFO;
|
|
34
|
+
}
|
|
35
|
+
if (resolvedLevel >= this.level) {
|
|
36
|
+
console.log(name, ...this.tags, ...args);
|
|
240
37
|
}
|
|
241
|
-
module.exports = fetchImplementation;
|
|
242
38
|
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
//
|
|
246
|
-
|
|
39
|
+
};
|
|
40
|
+
var noopLogger = {
|
|
41
|
+
//eslint-disable-next-line
|
|
42
|
+
debug: (...args) => {
|
|
43
|
+
},
|
|
44
|
+
//eslint-disable-next-line
|
|
45
|
+
info: (...args) => {
|
|
46
|
+
},
|
|
47
|
+
//eslint-disable-next-line
|
|
48
|
+
error: (...args) => {
|
|
49
|
+
}
|
|
50
|
+
};
|
|
247
51
|
|
|
248
52
|
// src/common/types.ts
|
|
249
53
|
var TaskType = /* @__PURE__ */ ((TaskType2) => {
|
|
@@ -3564,6 +3368,95 @@ var workflow = (name, tasks) => ({
|
|
|
3564
3368
|
timeoutSeconds: 0
|
|
3565
3369
|
});
|
|
3566
3370
|
|
|
3371
|
+
// src/orkes/request/fetchCatchDns/DnsResolver.ts
|
|
3372
|
+
import { promises } from "dns";
|
|
3373
|
+
var DEFAULT_OPTIONS = {
|
|
3374
|
+
logger: noopLogger,
|
|
3375
|
+
resolver: promises.resolve4
|
|
3376
|
+
};
|
|
3377
|
+
var dnsResolver = async (host, { resolver = promises.resolve4, logger = console } = DEFAULT_OPTIONS) => {
|
|
3378
|
+
try {
|
|
3379
|
+
const addresses = await resolver(host);
|
|
3380
|
+
if (addresses.length > 0)
|
|
3381
|
+
return addresses[0];
|
|
3382
|
+
} catch (e) {
|
|
3383
|
+
logger.error("Could not resolve host: " + host + " error: " + e);
|
|
3384
|
+
}
|
|
3385
|
+
return void 0;
|
|
3386
|
+
};
|
|
3387
|
+
|
|
3388
|
+
// src/orkes/request/fetchCatchDns/DnsCache.ts
|
|
3389
|
+
var DnsCacheResolver = class {
|
|
3390
|
+
constructor({ initialCache = /* @__PURE__ */ new Map() } = {}) {
|
|
3391
|
+
this._cache = /* @__PURE__ */ new Map();
|
|
3392
|
+
this._cache = initialCache;
|
|
3393
|
+
}
|
|
3394
|
+
async resolve(host) {
|
|
3395
|
+
const cachedIp = this._cache.get(host);
|
|
3396
|
+
if (cachedIp) {
|
|
3397
|
+
return cachedIp;
|
|
3398
|
+
}
|
|
3399
|
+
const ip = await dnsResolver(host);
|
|
3400
|
+
if (ip != void 0) {
|
|
3401
|
+
this._cache.set(host, ip);
|
|
3402
|
+
}
|
|
3403
|
+
return ip;
|
|
3404
|
+
}
|
|
3405
|
+
clearCache() {
|
|
3406
|
+
this._cache.clear();
|
|
3407
|
+
}
|
|
3408
|
+
get cache() {
|
|
3409
|
+
return this._cache;
|
|
3410
|
+
}
|
|
3411
|
+
};
|
|
3412
|
+
|
|
3413
|
+
// src/orkes/request/fetchCatchDns/fetchCatchDns.ts
|
|
3414
|
+
import { isIP } from "net";
|
|
3415
|
+
var isEmpty = (value) => {
|
|
3416
|
+
return value === void 0 || value.trim().length === 0;
|
|
3417
|
+
};
|
|
3418
|
+
var toMaybeUrl = (originalUrl, modifiedParams) => {
|
|
3419
|
+
const urlToHit = new URL(originalUrl.toString());
|
|
3420
|
+
urlToHit.host = isEmpty(modifiedParams.port) ? `${modifiedParams.host}:${modifiedParams.port}` : modifiedParams.host;
|
|
3421
|
+
return urlToHit;
|
|
3422
|
+
};
|
|
3423
|
+
var DEFAULT_OPTIONS2 = {
|
|
3424
|
+
dnsCache: new DnsCacheResolver(),
|
|
3425
|
+
headerFactory: (headers) => new Headers(headers || {})
|
|
3426
|
+
};
|
|
3427
|
+
var fetchCatchDns = (fetch3, {
|
|
3428
|
+
dnsCache = new DnsCacheResolver(),
|
|
3429
|
+
headerFactory = (headers) => new Headers(headers || {})
|
|
3430
|
+
} = DEFAULT_OPTIONS2) => {
|
|
3431
|
+
const fetchWithDns = async (input, options) => {
|
|
3432
|
+
const parsedUrl = new URL(input.toString());
|
|
3433
|
+
const { hostname, host, port } = parsedUrl;
|
|
3434
|
+
if (isIP(hostname)) {
|
|
3435
|
+
return await fetch3(input, options);
|
|
3436
|
+
}
|
|
3437
|
+
const maybeTargetIp = await dnsCache.resolve(hostname);
|
|
3438
|
+
if (isEmpty(maybeTargetIp)) {
|
|
3439
|
+
return await fetch3(input, options);
|
|
3440
|
+
}
|
|
3441
|
+
const target = toMaybeUrl(input, {
|
|
3442
|
+
...parsedUrl,
|
|
3443
|
+
host: maybeTargetIp,
|
|
3444
|
+
port
|
|
3445
|
+
});
|
|
3446
|
+
const headersOverride = headerFactory(options?.headers ?? {});
|
|
3447
|
+
if (!headersOverride.has("Host")) {
|
|
3448
|
+
headersOverride.set("Host", host);
|
|
3449
|
+
}
|
|
3450
|
+
const optionsOverride = {
|
|
3451
|
+
...options,
|
|
3452
|
+
headers: headersOverride
|
|
3453
|
+
};
|
|
3454
|
+
const res = await fetch3(target.toString(), optionsOverride);
|
|
3455
|
+
return res;
|
|
3456
|
+
};
|
|
3457
|
+
return fetchWithDns;
|
|
3458
|
+
};
|
|
3459
|
+
|
|
3567
3460
|
// src/orkes/request/request.ts
|
|
3568
3461
|
var isDefined2 = (value) => {
|
|
3569
3462
|
return value !== void 0 && value !== null;
|
|
@@ -3859,16 +3752,23 @@ var baseOrkesConductorClient = (fetchFn, baseRequestHandler = defaultRequestHand
|
|
|
3859
3752
|
};
|
|
3860
3753
|
|
|
3861
3754
|
// src/orkes/OrkesConductorClient.ts
|
|
3862
|
-
|
|
3863
|
-
var
|
|
3755
|
+
import fetch2, { Headers as Headers2 } from "node-fetch";
|
|
3756
|
+
var nodeFetchWrapper = async (input, options = {}) => {
|
|
3757
|
+
const res = await fetch2(input.toString(), options);
|
|
3758
|
+
return res;
|
|
3759
|
+
};
|
|
3760
|
+
var fetchCache = fetchCatchDns(
|
|
3761
|
+
nodeFetchWrapper,
|
|
3762
|
+
{
|
|
3763
|
+
//@ts-ignore
|
|
3764
|
+
headerFactory: (headers) => new Headers2(headers || {})
|
|
3765
|
+
}
|
|
3766
|
+
);
|
|
3767
|
+
var defaultRequestHandler3 = (__request, config, options) => request2(config, options, fetchCache);
|
|
3864
3768
|
var orkesConductorClient = baseOrkesConductorClient(
|
|
3865
|
-
//@ts-ignore
|
|
3866
3769
|
fetchCache,
|
|
3867
3770
|
defaultRequestHandler3
|
|
3868
3771
|
);
|
|
3869
|
-
|
|
3870
|
-
// src/orkes/index.ts
|
|
3871
|
-
init_fetchCatchDns2();
|
|
3872
3772
|
export {
|
|
3873
3773
|
ApiError,
|
|
3874
3774
|
AuthConductorClient,
|