@io-orkes/conductor-javascript 1.2.0-rc.3 → 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 -221
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +144 -238
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,243 +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
|
-
}
|
|
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);
|
|
74
11
|
};
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
debug: (...args) => {
|
|
78
|
-
},
|
|
79
|
-
//eslint-disable-next-line
|
|
80
|
-
info: (...args) => {
|
|
81
|
-
},
|
|
82
|
-
//eslint-disable-next-line
|
|
83
|
-
error: (...args) => {
|
|
84
|
-
}
|
|
12
|
+
this.debug = (...args) => {
|
|
13
|
+
this.log("DEBUG", ...args);
|
|
85
14
|
};
|
|
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
|
|
15
|
+
this.error = (...args) => {
|
|
16
|
+
this.log("ERROR", ...args);
|
|
99
17
|
};
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
-
}
|
|
141
|
-
};
|
|
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;
|
|
154
|
-
};
|
|
155
|
-
toMaybeUrl = (originalUrl, modifiedParams) => {
|
|
156
|
-
const urlToHit = new URL(originalUrl.toString());
|
|
157
|
-
urlToHit.host = isEmpty(modifiedParams.port) ? `${modifiedParams.host}:${modifiedParams.port}` : modifiedParams.host;
|
|
158
|
-
return urlToHit;
|
|
159
|
-
};
|
|
160
|
-
DEFAULT_OPTIONS2 = {
|
|
161
|
-
dnsCache: new DnsCacheResolver(),
|
|
162
|
-
headerFactory: (headers) => new Headers(headers || {})
|
|
163
|
-
};
|
|
164
|
-
fetchCatchDns = (fetch2, {
|
|
165
|
-
dnsCache = new DnsCacheResolver(),
|
|
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();
|
|
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;
|
|
24
|
+
}
|
|
211
25
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
"use strict";
|
|
218
|
-
var fetchCatchDns2 = (init_fetchCatchDns2(), __toCommonJS(fetchCatchDns_exports)).fetchCatchDns;
|
|
219
|
-
var fetchImplementation = fetch;
|
|
220
|
-
var nodeFetch = __require("node-fetch");
|
|
221
|
-
if (nodeFetch) {
|
|
222
|
-
const nodeFetchWrapper = async (input, options = {}) => {
|
|
223
|
-
const res = await fetch(input.toString(), options);
|
|
224
|
-
return res;
|
|
225
|
-
};
|
|
226
|
-
const fetchCache2 = fetchCatchDns2(nodeFetchWrapper, {
|
|
227
|
-
headerFactory: (headers) => new nodeFetch.Headers(headers || {})
|
|
228
|
-
});
|
|
229
|
-
fetchImplementation = fetchCache2;
|
|
230
|
-
console.log("Using node fetch");
|
|
26
|
+
log(level, ...args) {
|
|
27
|
+
let resolvedLevel;
|
|
28
|
+
let name = level;
|
|
29
|
+
if (level in LOG_LEVELS) {
|
|
30
|
+
resolvedLevel = LOG_LEVELS[level];
|
|
231
31
|
} else {
|
|
232
|
-
|
|
233
|
-
|
|
32
|
+
name = "INFO";
|
|
33
|
+
resolvedLevel = LOG_LEVELS.INFO;
|
|
34
|
+
}
|
|
35
|
+
if (resolvedLevel >= this.level) {
|
|
36
|
+
console.log(name, ...this.tags, ...args);
|
|
234
37
|
}
|
|
235
|
-
module.exports = fetchImplementation;
|
|
236
38
|
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
//
|
|
240
|
-
|
|
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
|
+
};
|
|
241
51
|
|
|
242
52
|
// src/common/types.ts
|
|
243
53
|
var TaskType = /* @__PURE__ */ ((TaskType2) => {
|
|
@@ -3558,6 +3368,95 @@ var workflow = (name, tasks) => ({
|
|
|
3558
3368
|
timeoutSeconds: 0
|
|
3559
3369
|
});
|
|
3560
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
|
+
|
|
3561
3460
|
// src/orkes/request/request.ts
|
|
3562
3461
|
var isDefined2 = (value) => {
|
|
3563
3462
|
return value !== void 0 && value !== null;
|
|
@@ -3853,16 +3752,23 @@ var baseOrkesConductorClient = (fetchFn, baseRequestHandler = defaultRequestHand
|
|
|
3853
3752
|
};
|
|
3854
3753
|
|
|
3855
3754
|
// src/orkes/OrkesConductorClient.ts
|
|
3856
|
-
|
|
3857
|
-
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);
|
|
3858
3768
|
var orkesConductorClient = baseOrkesConductorClient(
|
|
3859
|
-
//@ts-ignore
|
|
3860
3769
|
fetchCache,
|
|
3861
3770
|
defaultRequestHandler3
|
|
3862
3771
|
);
|
|
3863
|
-
|
|
3864
|
-
// src/orkes/index.ts
|
|
3865
|
-
init_fetchCatchDns2();
|
|
3866
3772
|
export {
|
|
3867
3773
|
ApiError,
|
|
3868
3774
|
AuthConductorClient,
|