@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.mjs
CHANGED
|
@@ -1,53 +1,249 @@
|
|
|
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
|
+
|
|
1
32
|
// src/common/ConductorLogger.ts
|
|
2
|
-
var LOG_LEVELS
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
this.log("INFO", ...args);
|
|
33
|
+
var LOG_LEVELS, DefaultLogger, noopLogger;
|
|
34
|
+
var init_ConductorLogger = __esm({
|
|
35
|
+
"src/common/ConductorLogger.ts"() {
|
|
36
|
+
"use strict";
|
|
37
|
+
LOG_LEVELS = {
|
|
38
|
+
DEBUG: 10,
|
|
39
|
+
INFO: 30,
|
|
40
|
+
ERROR: 60
|
|
11
41
|
};
|
|
12
|
-
|
|
13
|
-
|
|
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
|
+
}
|
|
14
74
|
};
|
|
15
|
-
|
|
16
|
-
|
|
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
|
+
}
|
|
17
85
|
};
|
|
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
|
-
}
|
|
25
86
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
+
}
|
|
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();
|
|
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) {
|
|
34
225
|
}
|
|
35
|
-
if (
|
|
36
|
-
|
|
226
|
+
if (nodeFetchAvailable) {
|
|
227
|
+
const nodeFetch = __require("node-fetch");
|
|
228
|
+
const nodeFetchWrapper = async (input, options = {}) => {
|
|
229
|
+
const res = await fetch(input.toString(), options);
|
|
230
|
+
return res;
|
|
231
|
+
};
|
|
232
|
+
const fetchCache2 = fetchCatchDns2(nodeFetchWrapper, {
|
|
233
|
+
headerFactory: (headers) => new nodeFetch.Headers(headers || {})
|
|
234
|
+
});
|
|
235
|
+
fetchImplementation = fetchCache2;
|
|
236
|
+
console.log("Using node fetch");
|
|
237
|
+
} else {
|
|
238
|
+
fetchImplementation = fetchCatchDns2(fetch);
|
|
239
|
+
console.log("Using native fetch");
|
|
37
240
|
}
|
|
241
|
+
module.exports = fetchImplementation;
|
|
38
242
|
}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
},
|
|
44
|
-
//eslint-disable-next-line
|
|
45
|
-
info: (...args) => {
|
|
46
|
-
},
|
|
47
|
-
//eslint-disable-next-line
|
|
48
|
-
error: (...args) => {
|
|
49
|
-
}
|
|
50
|
-
};
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
// src/common/index.ts
|
|
246
|
+
init_ConductorLogger();
|
|
51
247
|
|
|
52
248
|
// src/common/types.ts
|
|
53
249
|
var TaskType = /* @__PURE__ */ ((TaskType2) => {
|
|
@@ -3368,95 +3564,6 @@ var workflow = (name, tasks) => ({
|
|
|
3368
3564
|
timeoutSeconds: 0
|
|
3369
3565
|
});
|
|
3370
3566
|
|
|
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 = (fetch2, {
|
|
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 fetch2(input, options);
|
|
3436
|
-
}
|
|
3437
|
-
const maybeTargetIp = await dnsCache.resolve(hostname);
|
|
3438
|
-
if (isEmpty(maybeTargetIp)) {
|
|
3439
|
-
return await fetch2(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 fetch2(target.toString(), optionsOverride);
|
|
3455
|
-
return res;
|
|
3456
|
-
};
|
|
3457
|
-
return fetchWithDns;
|
|
3458
|
-
};
|
|
3459
|
-
|
|
3460
3567
|
// src/orkes/request/request.ts
|
|
3461
3568
|
var isDefined2 = (value) => {
|
|
3462
3569
|
return value !== void 0 && value !== null;
|
|
@@ -3752,12 +3859,16 @@ var baseOrkesConductorClient = (fetchFn, baseRequestHandler = defaultRequestHand
|
|
|
3752
3859
|
};
|
|
3753
3860
|
|
|
3754
3861
|
// src/orkes/OrkesConductorClient.ts
|
|
3755
|
-
var fetchCache =
|
|
3756
|
-
var defaultRequestHandler3 = (__request, config, options) => request2(config, options,
|
|
3862
|
+
var fetchCache = require_fetchImplementation();
|
|
3863
|
+
var defaultRequestHandler3 = (__request, config, options) => request2(config, options, fetch);
|
|
3757
3864
|
var orkesConductorClient = baseOrkesConductorClient(
|
|
3865
|
+
//@ts-ignore
|
|
3758
3866
|
fetchCache,
|
|
3759
3867
|
defaultRequestHandler3
|
|
3760
3868
|
);
|
|
3869
|
+
|
|
3870
|
+
// src/orkes/index.ts
|
|
3871
|
+
init_fetchCatchDns2();
|
|
3761
3872
|
export {
|
|
3762
3873
|
ApiError,
|
|
3763
3874
|
AuthConductorClient,
|