@nsshunt/stsfhirclient 1.0.18 → 1.0.20
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/stsfhirclient.mjs +2400 -189
- package/dist/stsfhirclient.mjs.map +1 -1
- package/dist/stsfhirclient.umd.js +2374 -163
- package/dist/stsfhirclient.umd.js.map +1 -1
- package/package.json +4 -4
- package/types/FhirClient.d.ts.map +1 -1
- package/types/stsfhircontrollertestcasesdirect.d.ts.map +1 -1
package/dist/stsfhirclient.mjs
CHANGED
|
@@ -8,46 +8,1919 @@ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot
|
|
|
8
8
|
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
9
9
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
10
10
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
11
|
-
var
|
|
12
|
-
import https from "node:https";
|
|
11
|
+
var _options2, _DUMMY_USER, _invokeMethods, _maxRetries, _sleepDuration, _NoRetryStatusCodes, _stsfhirapiroot, _agentManager2, _LogDebugMessage, _LogErrorMessage, _HandleError, _InvokeResourceAPI, _TestMode, ___InvokeResourceAPI;
|
|
13
12
|
import axios from "axios";
|
|
14
13
|
import { Sleep } from "@nsshunt/stsutils";
|
|
14
|
+
import https from "node:https";
|
|
15
15
|
var byteToHex = [];
|
|
16
16
|
for (var i = 0; i < 256; ++i) {
|
|
17
17
|
byteToHex.push((i + 256).toString(16).slice(1));
|
|
18
18
|
}
|
|
19
|
-
function unsafeStringify(arr, offset = 0) {
|
|
20
|
-
return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
|
|
19
|
+
function unsafeStringify(arr, offset = 0) {
|
|
20
|
+
return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
|
|
21
|
+
}
|
|
22
|
+
var getRandomValues;
|
|
23
|
+
var rnds8 = new Uint8Array(16);
|
|
24
|
+
function rng() {
|
|
25
|
+
if (!getRandomValues) {
|
|
26
|
+
getRandomValues = typeof crypto !== "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|
27
|
+
if (!getRandomValues) {
|
|
28
|
+
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return getRandomValues(rnds8);
|
|
32
|
+
}
|
|
33
|
+
var randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
34
|
+
const native = {
|
|
35
|
+
randomUUID
|
|
36
|
+
};
|
|
37
|
+
function v4(options, buf, offset) {
|
|
38
|
+
if (native.randomUUID && !buf && !options) {
|
|
39
|
+
return native.randomUUID();
|
|
40
|
+
}
|
|
41
|
+
options = options || {};
|
|
42
|
+
var rnds = options.random || (options.rng || rng)();
|
|
43
|
+
rnds[6] = rnds[6] & 15 | 64;
|
|
44
|
+
rnds[8] = rnds[8] & 63 | 128;
|
|
45
|
+
return unsafeStringify(rnds);
|
|
46
|
+
}
|
|
47
|
+
const isNode = Object.prototype.toString.call(typeof process !== "undefined" ? process : 0) === "[object process]";
|
|
48
|
+
function getDefaultExportFromCjs(x) {
|
|
49
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
50
|
+
}
|
|
51
|
+
function getAugmentedNamespace(n) {
|
|
52
|
+
if (n.__esModule) return n;
|
|
53
|
+
var f = n.default;
|
|
54
|
+
if (typeof f == "function") {
|
|
55
|
+
var a = function a2() {
|
|
56
|
+
if (this instanceof a2) {
|
|
57
|
+
return Reflect.construct(f, arguments, this.constructor);
|
|
58
|
+
}
|
|
59
|
+
return f.apply(this, arguments);
|
|
60
|
+
};
|
|
61
|
+
a.prototype = f.prototype;
|
|
62
|
+
} else a = {};
|
|
63
|
+
Object.defineProperty(a, "__esModule", { value: true });
|
|
64
|
+
Object.keys(n).forEach(function(k) {
|
|
65
|
+
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
66
|
+
Object.defineProperty(a, k, d.get ? d : {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function() {
|
|
69
|
+
return n[k];
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
return a;
|
|
74
|
+
}
|
|
75
|
+
var ansiStyles$3 = { exports: {} };
|
|
76
|
+
var colorName$1;
|
|
77
|
+
var hasRequiredColorName$1;
|
|
78
|
+
function requireColorName$1() {
|
|
79
|
+
if (hasRequiredColorName$1) return colorName$1;
|
|
80
|
+
hasRequiredColorName$1 = 1;
|
|
81
|
+
colorName$1 = {
|
|
82
|
+
"aliceblue": [240, 248, 255],
|
|
83
|
+
"antiquewhite": [250, 235, 215],
|
|
84
|
+
"aqua": [0, 255, 255],
|
|
85
|
+
"aquamarine": [127, 255, 212],
|
|
86
|
+
"azure": [240, 255, 255],
|
|
87
|
+
"beige": [245, 245, 220],
|
|
88
|
+
"bisque": [255, 228, 196],
|
|
89
|
+
"black": [0, 0, 0],
|
|
90
|
+
"blanchedalmond": [255, 235, 205],
|
|
91
|
+
"blue": [0, 0, 255],
|
|
92
|
+
"blueviolet": [138, 43, 226],
|
|
93
|
+
"brown": [165, 42, 42],
|
|
94
|
+
"burlywood": [222, 184, 135],
|
|
95
|
+
"cadetblue": [95, 158, 160],
|
|
96
|
+
"chartreuse": [127, 255, 0],
|
|
97
|
+
"chocolate": [210, 105, 30],
|
|
98
|
+
"coral": [255, 127, 80],
|
|
99
|
+
"cornflowerblue": [100, 149, 237],
|
|
100
|
+
"cornsilk": [255, 248, 220],
|
|
101
|
+
"crimson": [220, 20, 60],
|
|
102
|
+
"cyan": [0, 255, 255],
|
|
103
|
+
"darkblue": [0, 0, 139],
|
|
104
|
+
"darkcyan": [0, 139, 139],
|
|
105
|
+
"darkgoldenrod": [184, 134, 11],
|
|
106
|
+
"darkgray": [169, 169, 169],
|
|
107
|
+
"darkgreen": [0, 100, 0],
|
|
108
|
+
"darkgrey": [169, 169, 169],
|
|
109
|
+
"darkkhaki": [189, 183, 107],
|
|
110
|
+
"darkmagenta": [139, 0, 139],
|
|
111
|
+
"darkolivegreen": [85, 107, 47],
|
|
112
|
+
"darkorange": [255, 140, 0],
|
|
113
|
+
"darkorchid": [153, 50, 204],
|
|
114
|
+
"darkred": [139, 0, 0],
|
|
115
|
+
"darksalmon": [233, 150, 122],
|
|
116
|
+
"darkseagreen": [143, 188, 143],
|
|
117
|
+
"darkslateblue": [72, 61, 139],
|
|
118
|
+
"darkslategray": [47, 79, 79],
|
|
119
|
+
"darkslategrey": [47, 79, 79],
|
|
120
|
+
"darkturquoise": [0, 206, 209],
|
|
121
|
+
"darkviolet": [148, 0, 211],
|
|
122
|
+
"deeppink": [255, 20, 147],
|
|
123
|
+
"deepskyblue": [0, 191, 255],
|
|
124
|
+
"dimgray": [105, 105, 105],
|
|
125
|
+
"dimgrey": [105, 105, 105],
|
|
126
|
+
"dodgerblue": [30, 144, 255],
|
|
127
|
+
"firebrick": [178, 34, 34],
|
|
128
|
+
"floralwhite": [255, 250, 240],
|
|
129
|
+
"forestgreen": [34, 139, 34],
|
|
130
|
+
"fuchsia": [255, 0, 255],
|
|
131
|
+
"gainsboro": [220, 220, 220],
|
|
132
|
+
"ghostwhite": [248, 248, 255],
|
|
133
|
+
"gold": [255, 215, 0],
|
|
134
|
+
"goldenrod": [218, 165, 32],
|
|
135
|
+
"gray": [128, 128, 128],
|
|
136
|
+
"green": [0, 128, 0],
|
|
137
|
+
"greenyellow": [173, 255, 47],
|
|
138
|
+
"grey": [128, 128, 128],
|
|
139
|
+
"honeydew": [240, 255, 240],
|
|
140
|
+
"hotpink": [255, 105, 180],
|
|
141
|
+
"indianred": [205, 92, 92],
|
|
142
|
+
"indigo": [75, 0, 130],
|
|
143
|
+
"ivory": [255, 255, 240],
|
|
144
|
+
"khaki": [240, 230, 140],
|
|
145
|
+
"lavender": [230, 230, 250],
|
|
146
|
+
"lavenderblush": [255, 240, 245],
|
|
147
|
+
"lawngreen": [124, 252, 0],
|
|
148
|
+
"lemonchiffon": [255, 250, 205],
|
|
149
|
+
"lightblue": [173, 216, 230],
|
|
150
|
+
"lightcoral": [240, 128, 128],
|
|
151
|
+
"lightcyan": [224, 255, 255],
|
|
152
|
+
"lightgoldenrodyellow": [250, 250, 210],
|
|
153
|
+
"lightgray": [211, 211, 211],
|
|
154
|
+
"lightgreen": [144, 238, 144],
|
|
155
|
+
"lightgrey": [211, 211, 211],
|
|
156
|
+
"lightpink": [255, 182, 193],
|
|
157
|
+
"lightsalmon": [255, 160, 122],
|
|
158
|
+
"lightseagreen": [32, 178, 170],
|
|
159
|
+
"lightskyblue": [135, 206, 250],
|
|
160
|
+
"lightslategray": [119, 136, 153],
|
|
161
|
+
"lightslategrey": [119, 136, 153],
|
|
162
|
+
"lightsteelblue": [176, 196, 222],
|
|
163
|
+
"lightyellow": [255, 255, 224],
|
|
164
|
+
"lime": [0, 255, 0],
|
|
165
|
+
"limegreen": [50, 205, 50],
|
|
166
|
+
"linen": [250, 240, 230],
|
|
167
|
+
"magenta": [255, 0, 255],
|
|
168
|
+
"maroon": [128, 0, 0],
|
|
169
|
+
"mediumaquamarine": [102, 205, 170],
|
|
170
|
+
"mediumblue": [0, 0, 205],
|
|
171
|
+
"mediumorchid": [186, 85, 211],
|
|
172
|
+
"mediumpurple": [147, 112, 219],
|
|
173
|
+
"mediumseagreen": [60, 179, 113],
|
|
174
|
+
"mediumslateblue": [123, 104, 238],
|
|
175
|
+
"mediumspringgreen": [0, 250, 154],
|
|
176
|
+
"mediumturquoise": [72, 209, 204],
|
|
177
|
+
"mediumvioletred": [199, 21, 133],
|
|
178
|
+
"midnightblue": [25, 25, 112],
|
|
179
|
+
"mintcream": [245, 255, 250],
|
|
180
|
+
"mistyrose": [255, 228, 225],
|
|
181
|
+
"moccasin": [255, 228, 181],
|
|
182
|
+
"navajowhite": [255, 222, 173],
|
|
183
|
+
"navy": [0, 0, 128],
|
|
184
|
+
"oldlace": [253, 245, 230],
|
|
185
|
+
"olive": [128, 128, 0],
|
|
186
|
+
"olivedrab": [107, 142, 35],
|
|
187
|
+
"orange": [255, 165, 0],
|
|
188
|
+
"orangered": [255, 69, 0],
|
|
189
|
+
"orchid": [218, 112, 214],
|
|
190
|
+
"palegoldenrod": [238, 232, 170],
|
|
191
|
+
"palegreen": [152, 251, 152],
|
|
192
|
+
"paleturquoise": [175, 238, 238],
|
|
193
|
+
"palevioletred": [219, 112, 147],
|
|
194
|
+
"papayawhip": [255, 239, 213],
|
|
195
|
+
"peachpuff": [255, 218, 185],
|
|
196
|
+
"peru": [205, 133, 63],
|
|
197
|
+
"pink": [255, 192, 203],
|
|
198
|
+
"plum": [221, 160, 221],
|
|
199
|
+
"powderblue": [176, 224, 230],
|
|
200
|
+
"purple": [128, 0, 128],
|
|
201
|
+
"rebeccapurple": [102, 51, 153],
|
|
202
|
+
"red": [255, 0, 0],
|
|
203
|
+
"rosybrown": [188, 143, 143],
|
|
204
|
+
"royalblue": [65, 105, 225],
|
|
205
|
+
"saddlebrown": [139, 69, 19],
|
|
206
|
+
"salmon": [250, 128, 114],
|
|
207
|
+
"sandybrown": [244, 164, 96],
|
|
208
|
+
"seagreen": [46, 139, 87],
|
|
209
|
+
"seashell": [255, 245, 238],
|
|
210
|
+
"sienna": [160, 82, 45],
|
|
211
|
+
"silver": [192, 192, 192],
|
|
212
|
+
"skyblue": [135, 206, 235],
|
|
213
|
+
"slateblue": [106, 90, 205],
|
|
214
|
+
"slategray": [112, 128, 144],
|
|
215
|
+
"slategrey": [112, 128, 144],
|
|
216
|
+
"snow": [255, 250, 250],
|
|
217
|
+
"springgreen": [0, 255, 127],
|
|
218
|
+
"steelblue": [70, 130, 180],
|
|
219
|
+
"tan": [210, 180, 140],
|
|
220
|
+
"teal": [0, 128, 128],
|
|
221
|
+
"thistle": [216, 191, 216],
|
|
222
|
+
"tomato": [255, 99, 71],
|
|
223
|
+
"turquoise": [64, 224, 208],
|
|
224
|
+
"violet": [238, 130, 238],
|
|
225
|
+
"wheat": [245, 222, 179],
|
|
226
|
+
"white": [255, 255, 255],
|
|
227
|
+
"whitesmoke": [245, 245, 245],
|
|
228
|
+
"yellow": [255, 255, 0],
|
|
229
|
+
"yellowgreen": [154, 205, 50]
|
|
230
|
+
};
|
|
231
|
+
return colorName$1;
|
|
232
|
+
}
|
|
233
|
+
var conversions$1;
|
|
234
|
+
var hasRequiredConversions$1;
|
|
235
|
+
function requireConversions$1() {
|
|
236
|
+
if (hasRequiredConversions$1) return conversions$1;
|
|
237
|
+
hasRequiredConversions$1 = 1;
|
|
238
|
+
const cssKeywords = requireColorName$1();
|
|
239
|
+
const reverseKeywords = {};
|
|
240
|
+
for (const key of Object.keys(cssKeywords)) {
|
|
241
|
+
reverseKeywords[cssKeywords[key]] = key;
|
|
242
|
+
}
|
|
243
|
+
const convert = {
|
|
244
|
+
rgb: { channels: 3, labels: "rgb" },
|
|
245
|
+
hsl: { channels: 3, labels: "hsl" },
|
|
246
|
+
hsv: { channels: 3, labels: "hsv" },
|
|
247
|
+
hwb: { channels: 3, labels: "hwb" },
|
|
248
|
+
cmyk: { channels: 4, labels: "cmyk" },
|
|
249
|
+
xyz: { channels: 3, labels: "xyz" },
|
|
250
|
+
lab: { channels: 3, labels: "lab" },
|
|
251
|
+
lch: { channels: 3, labels: "lch" },
|
|
252
|
+
hex: { channels: 1, labels: ["hex"] },
|
|
253
|
+
keyword: { channels: 1, labels: ["keyword"] },
|
|
254
|
+
ansi16: { channels: 1, labels: ["ansi16"] },
|
|
255
|
+
ansi256: { channels: 1, labels: ["ansi256"] },
|
|
256
|
+
hcg: { channels: 3, labels: ["h", "c", "g"] },
|
|
257
|
+
apple: { channels: 3, labels: ["r16", "g16", "b16"] },
|
|
258
|
+
gray: { channels: 1, labels: ["gray"] }
|
|
259
|
+
};
|
|
260
|
+
conversions$1 = convert;
|
|
261
|
+
for (const model of Object.keys(convert)) {
|
|
262
|
+
if (!("channels" in convert[model])) {
|
|
263
|
+
throw new Error("missing channels property: " + model);
|
|
264
|
+
}
|
|
265
|
+
if (!("labels" in convert[model])) {
|
|
266
|
+
throw new Error("missing channel labels property: " + model);
|
|
267
|
+
}
|
|
268
|
+
if (convert[model].labels.length !== convert[model].channels) {
|
|
269
|
+
throw new Error("channel and label counts mismatch: " + model);
|
|
270
|
+
}
|
|
271
|
+
const { channels, labels } = convert[model];
|
|
272
|
+
delete convert[model].channels;
|
|
273
|
+
delete convert[model].labels;
|
|
274
|
+
Object.defineProperty(convert[model], "channels", { value: channels });
|
|
275
|
+
Object.defineProperty(convert[model], "labels", { value: labels });
|
|
276
|
+
}
|
|
277
|
+
convert.rgb.hsl = function(rgb) {
|
|
278
|
+
const r = rgb[0] / 255;
|
|
279
|
+
const g = rgb[1] / 255;
|
|
280
|
+
const b = rgb[2] / 255;
|
|
281
|
+
const min = Math.min(r, g, b);
|
|
282
|
+
const max = Math.max(r, g, b);
|
|
283
|
+
const delta = max - min;
|
|
284
|
+
let h;
|
|
285
|
+
let s;
|
|
286
|
+
if (max === min) {
|
|
287
|
+
h = 0;
|
|
288
|
+
} else if (r === max) {
|
|
289
|
+
h = (g - b) / delta;
|
|
290
|
+
} else if (g === max) {
|
|
291
|
+
h = 2 + (b - r) / delta;
|
|
292
|
+
} else if (b === max) {
|
|
293
|
+
h = 4 + (r - g) / delta;
|
|
294
|
+
}
|
|
295
|
+
h = Math.min(h * 60, 360);
|
|
296
|
+
if (h < 0) {
|
|
297
|
+
h += 360;
|
|
298
|
+
}
|
|
299
|
+
const l = (min + max) / 2;
|
|
300
|
+
if (max === min) {
|
|
301
|
+
s = 0;
|
|
302
|
+
} else if (l <= 0.5) {
|
|
303
|
+
s = delta / (max + min);
|
|
304
|
+
} else {
|
|
305
|
+
s = delta / (2 - max - min);
|
|
306
|
+
}
|
|
307
|
+
return [h, s * 100, l * 100];
|
|
308
|
+
};
|
|
309
|
+
convert.rgb.hsv = function(rgb) {
|
|
310
|
+
let rdif;
|
|
311
|
+
let gdif;
|
|
312
|
+
let bdif;
|
|
313
|
+
let h;
|
|
314
|
+
let s;
|
|
315
|
+
const r = rgb[0] / 255;
|
|
316
|
+
const g = rgb[1] / 255;
|
|
317
|
+
const b = rgb[2] / 255;
|
|
318
|
+
const v = Math.max(r, g, b);
|
|
319
|
+
const diff = v - Math.min(r, g, b);
|
|
320
|
+
const diffc = function(c) {
|
|
321
|
+
return (v - c) / 6 / diff + 1 / 2;
|
|
322
|
+
};
|
|
323
|
+
if (diff === 0) {
|
|
324
|
+
h = 0;
|
|
325
|
+
s = 0;
|
|
326
|
+
} else {
|
|
327
|
+
s = diff / v;
|
|
328
|
+
rdif = diffc(r);
|
|
329
|
+
gdif = diffc(g);
|
|
330
|
+
bdif = diffc(b);
|
|
331
|
+
if (r === v) {
|
|
332
|
+
h = bdif - gdif;
|
|
333
|
+
} else if (g === v) {
|
|
334
|
+
h = 1 / 3 + rdif - bdif;
|
|
335
|
+
} else if (b === v) {
|
|
336
|
+
h = 2 / 3 + gdif - rdif;
|
|
337
|
+
}
|
|
338
|
+
if (h < 0) {
|
|
339
|
+
h += 1;
|
|
340
|
+
} else if (h > 1) {
|
|
341
|
+
h -= 1;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
return [
|
|
345
|
+
h * 360,
|
|
346
|
+
s * 100,
|
|
347
|
+
v * 100
|
|
348
|
+
];
|
|
349
|
+
};
|
|
350
|
+
convert.rgb.hwb = function(rgb) {
|
|
351
|
+
const r = rgb[0];
|
|
352
|
+
const g = rgb[1];
|
|
353
|
+
let b = rgb[2];
|
|
354
|
+
const h = convert.rgb.hsl(rgb)[0];
|
|
355
|
+
const w = 1 / 255 * Math.min(r, Math.min(g, b));
|
|
356
|
+
b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
|
|
357
|
+
return [h, w * 100, b * 100];
|
|
358
|
+
};
|
|
359
|
+
convert.rgb.cmyk = function(rgb) {
|
|
360
|
+
const r = rgb[0] / 255;
|
|
361
|
+
const g = rgb[1] / 255;
|
|
362
|
+
const b = rgb[2] / 255;
|
|
363
|
+
const k = Math.min(1 - r, 1 - g, 1 - b);
|
|
364
|
+
const c = (1 - r - k) / (1 - k) || 0;
|
|
365
|
+
const m = (1 - g - k) / (1 - k) || 0;
|
|
366
|
+
const y = (1 - b - k) / (1 - k) || 0;
|
|
367
|
+
return [c * 100, m * 100, y * 100, k * 100];
|
|
368
|
+
};
|
|
369
|
+
function comparativeDistance(x, y) {
|
|
370
|
+
return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;
|
|
371
|
+
}
|
|
372
|
+
convert.rgb.keyword = function(rgb) {
|
|
373
|
+
const reversed = reverseKeywords[rgb];
|
|
374
|
+
if (reversed) {
|
|
375
|
+
return reversed;
|
|
376
|
+
}
|
|
377
|
+
let currentClosestDistance = Infinity;
|
|
378
|
+
let currentClosestKeyword;
|
|
379
|
+
for (const keyword of Object.keys(cssKeywords)) {
|
|
380
|
+
const value = cssKeywords[keyword];
|
|
381
|
+
const distance = comparativeDistance(rgb, value);
|
|
382
|
+
if (distance < currentClosestDistance) {
|
|
383
|
+
currentClosestDistance = distance;
|
|
384
|
+
currentClosestKeyword = keyword;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
return currentClosestKeyword;
|
|
388
|
+
};
|
|
389
|
+
convert.keyword.rgb = function(keyword) {
|
|
390
|
+
return cssKeywords[keyword];
|
|
391
|
+
};
|
|
392
|
+
convert.rgb.xyz = function(rgb) {
|
|
393
|
+
let r = rgb[0] / 255;
|
|
394
|
+
let g = rgb[1] / 255;
|
|
395
|
+
let b = rgb[2] / 255;
|
|
396
|
+
r = r > 0.04045 ? ((r + 0.055) / 1.055) ** 2.4 : r / 12.92;
|
|
397
|
+
g = g > 0.04045 ? ((g + 0.055) / 1.055) ** 2.4 : g / 12.92;
|
|
398
|
+
b = b > 0.04045 ? ((b + 0.055) / 1.055) ** 2.4 : b / 12.92;
|
|
399
|
+
const x = r * 0.4124 + g * 0.3576 + b * 0.1805;
|
|
400
|
+
const y = r * 0.2126 + g * 0.7152 + b * 0.0722;
|
|
401
|
+
const z = r * 0.0193 + g * 0.1192 + b * 0.9505;
|
|
402
|
+
return [x * 100, y * 100, z * 100];
|
|
403
|
+
};
|
|
404
|
+
convert.rgb.lab = function(rgb) {
|
|
405
|
+
const xyz = convert.rgb.xyz(rgb);
|
|
406
|
+
let x = xyz[0];
|
|
407
|
+
let y = xyz[1];
|
|
408
|
+
let z = xyz[2];
|
|
409
|
+
x /= 95.047;
|
|
410
|
+
y /= 100;
|
|
411
|
+
z /= 108.883;
|
|
412
|
+
x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
|
|
413
|
+
y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
|
|
414
|
+
z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
|
|
415
|
+
const l = 116 * y - 16;
|
|
416
|
+
const a = 500 * (x - y);
|
|
417
|
+
const b = 200 * (y - z);
|
|
418
|
+
return [l, a, b];
|
|
419
|
+
};
|
|
420
|
+
convert.hsl.rgb = function(hsl) {
|
|
421
|
+
const h = hsl[0] / 360;
|
|
422
|
+
const s = hsl[1] / 100;
|
|
423
|
+
const l = hsl[2] / 100;
|
|
424
|
+
let t2;
|
|
425
|
+
let t3;
|
|
426
|
+
let val;
|
|
427
|
+
if (s === 0) {
|
|
428
|
+
val = l * 255;
|
|
429
|
+
return [val, val, val];
|
|
430
|
+
}
|
|
431
|
+
if (l < 0.5) {
|
|
432
|
+
t2 = l * (1 + s);
|
|
433
|
+
} else {
|
|
434
|
+
t2 = l + s - l * s;
|
|
435
|
+
}
|
|
436
|
+
const t1 = 2 * l - t2;
|
|
437
|
+
const rgb = [0, 0, 0];
|
|
438
|
+
for (let i = 0; i < 3; i++) {
|
|
439
|
+
t3 = h + 1 / 3 * -(i - 1);
|
|
440
|
+
if (t3 < 0) {
|
|
441
|
+
t3++;
|
|
442
|
+
}
|
|
443
|
+
if (t3 > 1) {
|
|
444
|
+
t3--;
|
|
445
|
+
}
|
|
446
|
+
if (6 * t3 < 1) {
|
|
447
|
+
val = t1 + (t2 - t1) * 6 * t3;
|
|
448
|
+
} else if (2 * t3 < 1) {
|
|
449
|
+
val = t2;
|
|
450
|
+
} else if (3 * t3 < 2) {
|
|
451
|
+
val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
|
|
452
|
+
} else {
|
|
453
|
+
val = t1;
|
|
454
|
+
}
|
|
455
|
+
rgb[i] = val * 255;
|
|
456
|
+
}
|
|
457
|
+
return rgb;
|
|
458
|
+
};
|
|
459
|
+
convert.hsl.hsv = function(hsl) {
|
|
460
|
+
const h = hsl[0];
|
|
461
|
+
let s = hsl[1] / 100;
|
|
462
|
+
let l = hsl[2] / 100;
|
|
463
|
+
let smin = s;
|
|
464
|
+
const lmin = Math.max(l, 0.01);
|
|
465
|
+
l *= 2;
|
|
466
|
+
s *= l <= 1 ? l : 2 - l;
|
|
467
|
+
smin *= lmin <= 1 ? lmin : 2 - lmin;
|
|
468
|
+
const v = (l + s) / 2;
|
|
469
|
+
const sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
|
|
470
|
+
return [h, sv * 100, v * 100];
|
|
471
|
+
};
|
|
472
|
+
convert.hsv.rgb = function(hsv) {
|
|
473
|
+
const h = hsv[0] / 60;
|
|
474
|
+
const s = hsv[1] / 100;
|
|
475
|
+
let v = hsv[2] / 100;
|
|
476
|
+
const hi = Math.floor(h) % 6;
|
|
477
|
+
const f = h - Math.floor(h);
|
|
478
|
+
const p = 255 * v * (1 - s);
|
|
479
|
+
const q = 255 * v * (1 - s * f);
|
|
480
|
+
const t = 255 * v * (1 - s * (1 - f));
|
|
481
|
+
v *= 255;
|
|
482
|
+
switch (hi) {
|
|
483
|
+
case 0:
|
|
484
|
+
return [v, t, p];
|
|
485
|
+
case 1:
|
|
486
|
+
return [q, v, p];
|
|
487
|
+
case 2:
|
|
488
|
+
return [p, v, t];
|
|
489
|
+
case 3:
|
|
490
|
+
return [p, q, v];
|
|
491
|
+
case 4:
|
|
492
|
+
return [t, p, v];
|
|
493
|
+
case 5:
|
|
494
|
+
return [v, p, q];
|
|
495
|
+
}
|
|
496
|
+
};
|
|
497
|
+
convert.hsv.hsl = function(hsv) {
|
|
498
|
+
const h = hsv[0];
|
|
499
|
+
const s = hsv[1] / 100;
|
|
500
|
+
const v = hsv[2] / 100;
|
|
501
|
+
const vmin = Math.max(v, 0.01);
|
|
502
|
+
let sl;
|
|
503
|
+
let l;
|
|
504
|
+
l = (2 - s) * v;
|
|
505
|
+
const lmin = (2 - s) * vmin;
|
|
506
|
+
sl = s * vmin;
|
|
507
|
+
sl /= lmin <= 1 ? lmin : 2 - lmin;
|
|
508
|
+
sl = sl || 0;
|
|
509
|
+
l /= 2;
|
|
510
|
+
return [h, sl * 100, l * 100];
|
|
511
|
+
};
|
|
512
|
+
convert.hwb.rgb = function(hwb) {
|
|
513
|
+
const h = hwb[0] / 360;
|
|
514
|
+
let wh = hwb[1] / 100;
|
|
515
|
+
let bl = hwb[2] / 100;
|
|
516
|
+
const ratio = wh + bl;
|
|
517
|
+
let f;
|
|
518
|
+
if (ratio > 1) {
|
|
519
|
+
wh /= ratio;
|
|
520
|
+
bl /= ratio;
|
|
521
|
+
}
|
|
522
|
+
const i = Math.floor(6 * h);
|
|
523
|
+
const v = 1 - bl;
|
|
524
|
+
f = 6 * h - i;
|
|
525
|
+
if ((i & 1) !== 0) {
|
|
526
|
+
f = 1 - f;
|
|
527
|
+
}
|
|
528
|
+
const n = wh + f * (v - wh);
|
|
529
|
+
let r;
|
|
530
|
+
let g;
|
|
531
|
+
let b;
|
|
532
|
+
switch (i) {
|
|
533
|
+
default:
|
|
534
|
+
case 6:
|
|
535
|
+
case 0:
|
|
536
|
+
r = v;
|
|
537
|
+
g = n;
|
|
538
|
+
b = wh;
|
|
539
|
+
break;
|
|
540
|
+
case 1:
|
|
541
|
+
r = n;
|
|
542
|
+
g = v;
|
|
543
|
+
b = wh;
|
|
544
|
+
break;
|
|
545
|
+
case 2:
|
|
546
|
+
r = wh;
|
|
547
|
+
g = v;
|
|
548
|
+
b = n;
|
|
549
|
+
break;
|
|
550
|
+
case 3:
|
|
551
|
+
r = wh;
|
|
552
|
+
g = n;
|
|
553
|
+
b = v;
|
|
554
|
+
break;
|
|
555
|
+
case 4:
|
|
556
|
+
r = n;
|
|
557
|
+
g = wh;
|
|
558
|
+
b = v;
|
|
559
|
+
break;
|
|
560
|
+
case 5:
|
|
561
|
+
r = v;
|
|
562
|
+
g = wh;
|
|
563
|
+
b = n;
|
|
564
|
+
break;
|
|
565
|
+
}
|
|
566
|
+
return [r * 255, g * 255, b * 255];
|
|
567
|
+
};
|
|
568
|
+
convert.cmyk.rgb = function(cmyk) {
|
|
569
|
+
const c = cmyk[0] / 100;
|
|
570
|
+
const m = cmyk[1] / 100;
|
|
571
|
+
const y = cmyk[2] / 100;
|
|
572
|
+
const k = cmyk[3] / 100;
|
|
573
|
+
const r = 1 - Math.min(1, c * (1 - k) + k);
|
|
574
|
+
const g = 1 - Math.min(1, m * (1 - k) + k);
|
|
575
|
+
const b = 1 - Math.min(1, y * (1 - k) + k);
|
|
576
|
+
return [r * 255, g * 255, b * 255];
|
|
577
|
+
};
|
|
578
|
+
convert.xyz.rgb = function(xyz) {
|
|
579
|
+
const x = xyz[0] / 100;
|
|
580
|
+
const y = xyz[1] / 100;
|
|
581
|
+
const z = xyz[2] / 100;
|
|
582
|
+
let r;
|
|
583
|
+
let g;
|
|
584
|
+
let b;
|
|
585
|
+
r = x * 3.2406 + y * -1.5372 + z * -0.4986;
|
|
586
|
+
g = x * -0.9689 + y * 1.8758 + z * 0.0415;
|
|
587
|
+
b = x * 0.0557 + y * -0.204 + z * 1.057;
|
|
588
|
+
r = r > 31308e-7 ? 1.055 * r ** (1 / 2.4) - 0.055 : r * 12.92;
|
|
589
|
+
g = g > 31308e-7 ? 1.055 * g ** (1 / 2.4) - 0.055 : g * 12.92;
|
|
590
|
+
b = b > 31308e-7 ? 1.055 * b ** (1 / 2.4) - 0.055 : b * 12.92;
|
|
591
|
+
r = Math.min(Math.max(0, r), 1);
|
|
592
|
+
g = Math.min(Math.max(0, g), 1);
|
|
593
|
+
b = Math.min(Math.max(0, b), 1);
|
|
594
|
+
return [r * 255, g * 255, b * 255];
|
|
595
|
+
};
|
|
596
|
+
convert.xyz.lab = function(xyz) {
|
|
597
|
+
let x = xyz[0];
|
|
598
|
+
let y = xyz[1];
|
|
599
|
+
let z = xyz[2];
|
|
600
|
+
x /= 95.047;
|
|
601
|
+
y /= 100;
|
|
602
|
+
z /= 108.883;
|
|
603
|
+
x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
|
|
604
|
+
y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
|
|
605
|
+
z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
|
|
606
|
+
const l = 116 * y - 16;
|
|
607
|
+
const a = 500 * (x - y);
|
|
608
|
+
const b = 200 * (y - z);
|
|
609
|
+
return [l, a, b];
|
|
610
|
+
};
|
|
611
|
+
convert.lab.xyz = function(lab) {
|
|
612
|
+
const l = lab[0];
|
|
613
|
+
const a = lab[1];
|
|
614
|
+
const b = lab[2];
|
|
615
|
+
let x;
|
|
616
|
+
let y;
|
|
617
|
+
let z;
|
|
618
|
+
y = (l + 16) / 116;
|
|
619
|
+
x = a / 500 + y;
|
|
620
|
+
z = y - b / 200;
|
|
621
|
+
const y2 = y ** 3;
|
|
622
|
+
const x2 = x ** 3;
|
|
623
|
+
const z2 = z ** 3;
|
|
624
|
+
y = y2 > 8856e-6 ? y2 : (y - 16 / 116) / 7.787;
|
|
625
|
+
x = x2 > 8856e-6 ? x2 : (x - 16 / 116) / 7.787;
|
|
626
|
+
z = z2 > 8856e-6 ? z2 : (z - 16 / 116) / 7.787;
|
|
627
|
+
x *= 95.047;
|
|
628
|
+
y *= 100;
|
|
629
|
+
z *= 108.883;
|
|
630
|
+
return [x, y, z];
|
|
631
|
+
};
|
|
632
|
+
convert.lab.lch = function(lab) {
|
|
633
|
+
const l = lab[0];
|
|
634
|
+
const a = lab[1];
|
|
635
|
+
const b = lab[2];
|
|
636
|
+
let h;
|
|
637
|
+
const hr = Math.atan2(b, a);
|
|
638
|
+
h = hr * 360 / 2 / Math.PI;
|
|
639
|
+
if (h < 0) {
|
|
640
|
+
h += 360;
|
|
641
|
+
}
|
|
642
|
+
const c = Math.sqrt(a * a + b * b);
|
|
643
|
+
return [l, c, h];
|
|
644
|
+
};
|
|
645
|
+
convert.lch.lab = function(lch) {
|
|
646
|
+
const l = lch[0];
|
|
647
|
+
const c = lch[1];
|
|
648
|
+
const h = lch[2];
|
|
649
|
+
const hr = h / 360 * 2 * Math.PI;
|
|
650
|
+
const a = c * Math.cos(hr);
|
|
651
|
+
const b = c * Math.sin(hr);
|
|
652
|
+
return [l, a, b];
|
|
653
|
+
};
|
|
654
|
+
convert.rgb.ansi16 = function(args, saturation = null) {
|
|
655
|
+
const [r, g, b] = args;
|
|
656
|
+
let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation;
|
|
657
|
+
value = Math.round(value / 50);
|
|
658
|
+
if (value === 0) {
|
|
659
|
+
return 30;
|
|
660
|
+
}
|
|
661
|
+
let ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
|
|
662
|
+
if (value === 2) {
|
|
663
|
+
ansi += 60;
|
|
664
|
+
}
|
|
665
|
+
return ansi;
|
|
666
|
+
};
|
|
667
|
+
convert.hsv.ansi16 = function(args) {
|
|
668
|
+
return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
|
|
669
|
+
};
|
|
670
|
+
convert.rgb.ansi256 = function(args) {
|
|
671
|
+
const r = args[0];
|
|
672
|
+
const g = args[1];
|
|
673
|
+
const b = args[2];
|
|
674
|
+
if (r === g && g === b) {
|
|
675
|
+
if (r < 8) {
|
|
676
|
+
return 16;
|
|
677
|
+
}
|
|
678
|
+
if (r > 248) {
|
|
679
|
+
return 231;
|
|
680
|
+
}
|
|
681
|
+
return Math.round((r - 8) / 247 * 24) + 232;
|
|
682
|
+
}
|
|
683
|
+
const ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
|
|
684
|
+
return ansi;
|
|
685
|
+
};
|
|
686
|
+
convert.ansi16.rgb = function(args) {
|
|
687
|
+
let color = args % 10;
|
|
688
|
+
if (color === 0 || color === 7) {
|
|
689
|
+
if (args > 50) {
|
|
690
|
+
color += 3.5;
|
|
691
|
+
}
|
|
692
|
+
color = color / 10.5 * 255;
|
|
693
|
+
return [color, color, color];
|
|
694
|
+
}
|
|
695
|
+
const mult = (~~(args > 50) + 1) * 0.5;
|
|
696
|
+
const r = (color & 1) * mult * 255;
|
|
697
|
+
const g = (color >> 1 & 1) * mult * 255;
|
|
698
|
+
const b = (color >> 2 & 1) * mult * 255;
|
|
699
|
+
return [r, g, b];
|
|
700
|
+
};
|
|
701
|
+
convert.ansi256.rgb = function(args) {
|
|
702
|
+
if (args >= 232) {
|
|
703
|
+
const c = (args - 232) * 10 + 8;
|
|
704
|
+
return [c, c, c];
|
|
705
|
+
}
|
|
706
|
+
args -= 16;
|
|
707
|
+
let rem;
|
|
708
|
+
const r = Math.floor(args / 36) / 5 * 255;
|
|
709
|
+
const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
|
|
710
|
+
const b = rem % 6 / 5 * 255;
|
|
711
|
+
return [r, g, b];
|
|
712
|
+
};
|
|
713
|
+
convert.rgb.hex = function(args) {
|
|
714
|
+
const integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255);
|
|
715
|
+
const string = integer.toString(16).toUpperCase();
|
|
716
|
+
return "000000".substring(string.length) + string;
|
|
717
|
+
};
|
|
718
|
+
convert.hex.rgb = function(args) {
|
|
719
|
+
const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
|
|
720
|
+
if (!match) {
|
|
721
|
+
return [0, 0, 0];
|
|
722
|
+
}
|
|
723
|
+
let colorString = match[0];
|
|
724
|
+
if (match[0].length === 3) {
|
|
725
|
+
colorString = colorString.split("").map((char) => {
|
|
726
|
+
return char + char;
|
|
727
|
+
}).join("");
|
|
728
|
+
}
|
|
729
|
+
const integer = parseInt(colorString, 16);
|
|
730
|
+
const r = integer >> 16 & 255;
|
|
731
|
+
const g = integer >> 8 & 255;
|
|
732
|
+
const b = integer & 255;
|
|
733
|
+
return [r, g, b];
|
|
734
|
+
};
|
|
735
|
+
convert.rgb.hcg = function(rgb) {
|
|
736
|
+
const r = rgb[0] / 255;
|
|
737
|
+
const g = rgb[1] / 255;
|
|
738
|
+
const b = rgb[2] / 255;
|
|
739
|
+
const max = Math.max(Math.max(r, g), b);
|
|
740
|
+
const min = Math.min(Math.min(r, g), b);
|
|
741
|
+
const chroma = max - min;
|
|
742
|
+
let grayscale;
|
|
743
|
+
let hue;
|
|
744
|
+
if (chroma < 1) {
|
|
745
|
+
grayscale = min / (1 - chroma);
|
|
746
|
+
} else {
|
|
747
|
+
grayscale = 0;
|
|
748
|
+
}
|
|
749
|
+
if (chroma <= 0) {
|
|
750
|
+
hue = 0;
|
|
751
|
+
} else if (max === r) {
|
|
752
|
+
hue = (g - b) / chroma % 6;
|
|
753
|
+
} else if (max === g) {
|
|
754
|
+
hue = 2 + (b - r) / chroma;
|
|
755
|
+
} else {
|
|
756
|
+
hue = 4 + (r - g) / chroma;
|
|
757
|
+
}
|
|
758
|
+
hue /= 6;
|
|
759
|
+
hue %= 1;
|
|
760
|
+
return [hue * 360, chroma * 100, grayscale * 100];
|
|
761
|
+
};
|
|
762
|
+
convert.hsl.hcg = function(hsl) {
|
|
763
|
+
const s = hsl[1] / 100;
|
|
764
|
+
const l = hsl[2] / 100;
|
|
765
|
+
const c = l < 0.5 ? 2 * s * l : 2 * s * (1 - l);
|
|
766
|
+
let f = 0;
|
|
767
|
+
if (c < 1) {
|
|
768
|
+
f = (l - 0.5 * c) / (1 - c);
|
|
769
|
+
}
|
|
770
|
+
return [hsl[0], c * 100, f * 100];
|
|
771
|
+
};
|
|
772
|
+
convert.hsv.hcg = function(hsv) {
|
|
773
|
+
const s = hsv[1] / 100;
|
|
774
|
+
const v = hsv[2] / 100;
|
|
775
|
+
const c = s * v;
|
|
776
|
+
let f = 0;
|
|
777
|
+
if (c < 1) {
|
|
778
|
+
f = (v - c) / (1 - c);
|
|
779
|
+
}
|
|
780
|
+
return [hsv[0], c * 100, f * 100];
|
|
781
|
+
};
|
|
782
|
+
convert.hcg.rgb = function(hcg) {
|
|
783
|
+
const h = hcg[0] / 360;
|
|
784
|
+
const c = hcg[1] / 100;
|
|
785
|
+
const g = hcg[2] / 100;
|
|
786
|
+
if (c === 0) {
|
|
787
|
+
return [g * 255, g * 255, g * 255];
|
|
788
|
+
}
|
|
789
|
+
const pure = [0, 0, 0];
|
|
790
|
+
const hi = h % 1 * 6;
|
|
791
|
+
const v = hi % 1;
|
|
792
|
+
const w = 1 - v;
|
|
793
|
+
let mg = 0;
|
|
794
|
+
switch (Math.floor(hi)) {
|
|
795
|
+
case 0:
|
|
796
|
+
pure[0] = 1;
|
|
797
|
+
pure[1] = v;
|
|
798
|
+
pure[2] = 0;
|
|
799
|
+
break;
|
|
800
|
+
case 1:
|
|
801
|
+
pure[0] = w;
|
|
802
|
+
pure[1] = 1;
|
|
803
|
+
pure[2] = 0;
|
|
804
|
+
break;
|
|
805
|
+
case 2:
|
|
806
|
+
pure[0] = 0;
|
|
807
|
+
pure[1] = 1;
|
|
808
|
+
pure[2] = v;
|
|
809
|
+
break;
|
|
810
|
+
case 3:
|
|
811
|
+
pure[0] = 0;
|
|
812
|
+
pure[1] = w;
|
|
813
|
+
pure[2] = 1;
|
|
814
|
+
break;
|
|
815
|
+
case 4:
|
|
816
|
+
pure[0] = v;
|
|
817
|
+
pure[1] = 0;
|
|
818
|
+
pure[2] = 1;
|
|
819
|
+
break;
|
|
820
|
+
default:
|
|
821
|
+
pure[0] = 1;
|
|
822
|
+
pure[1] = 0;
|
|
823
|
+
pure[2] = w;
|
|
824
|
+
}
|
|
825
|
+
mg = (1 - c) * g;
|
|
826
|
+
return [
|
|
827
|
+
(c * pure[0] + mg) * 255,
|
|
828
|
+
(c * pure[1] + mg) * 255,
|
|
829
|
+
(c * pure[2] + mg) * 255
|
|
830
|
+
];
|
|
831
|
+
};
|
|
832
|
+
convert.hcg.hsv = function(hcg) {
|
|
833
|
+
const c = hcg[1] / 100;
|
|
834
|
+
const g = hcg[2] / 100;
|
|
835
|
+
const v = c + g * (1 - c);
|
|
836
|
+
let f = 0;
|
|
837
|
+
if (v > 0) {
|
|
838
|
+
f = c / v;
|
|
839
|
+
}
|
|
840
|
+
return [hcg[0], f * 100, v * 100];
|
|
841
|
+
};
|
|
842
|
+
convert.hcg.hsl = function(hcg) {
|
|
843
|
+
const c = hcg[1] / 100;
|
|
844
|
+
const g = hcg[2] / 100;
|
|
845
|
+
const l = g * (1 - c) + 0.5 * c;
|
|
846
|
+
let s = 0;
|
|
847
|
+
if (l > 0 && l < 0.5) {
|
|
848
|
+
s = c / (2 * l);
|
|
849
|
+
} else if (l >= 0.5 && l < 1) {
|
|
850
|
+
s = c / (2 * (1 - l));
|
|
851
|
+
}
|
|
852
|
+
return [hcg[0], s * 100, l * 100];
|
|
853
|
+
};
|
|
854
|
+
convert.hcg.hwb = function(hcg) {
|
|
855
|
+
const c = hcg[1] / 100;
|
|
856
|
+
const g = hcg[2] / 100;
|
|
857
|
+
const v = c + g * (1 - c);
|
|
858
|
+
return [hcg[0], (v - c) * 100, (1 - v) * 100];
|
|
859
|
+
};
|
|
860
|
+
convert.hwb.hcg = function(hwb) {
|
|
861
|
+
const w = hwb[1] / 100;
|
|
862
|
+
const b = hwb[2] / 100;
|
|
863
|
+
const v = 1 - b;
|
|
864
|
+
const c = v - w;
|
|
865
|
+
let g = 0;
|
|
866
|
+
if (c < 1) {
|
|
867
|
+
g = (v - c) / (1 - c);
|
|
868
|
+
}
|
|
869
|
+
return [hwb[0], c * 100, g * 100];
|
|
870
|
+
};
|
|
871
|
+
convert.apple.rgb = function(apple) {
|
|
872
|
+
return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
|
|
873
|
+
};
|
|
874
|
+
convert.rgb.apple = function(rgb) {
|
|
875
|
+
return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
|
|
876
|
+
};
|
|
877
|
+
convert.gray.rgb = function(args) {
|
|
878
|
+
return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
|
|
879
|
+
};
|
|
880
|
+
convert.gray.hsl = function(args) {
|
|
881
|
+
return [0, 0, args[0]];
|
|
882
|
+
};
|
|
883
|
+
convert.gray.hsv = convert.gray.hsl;
|
|
884
|
+
convert.gray.hwb = function(gray) {
|
|
885
|
+
return [0, 100, gray[0]];
|
|
886
|
+
};
|
|
887
|
+
convert.gray.cmyk = function(gray) {
|
|
888
|
+
return [0, 0, 0, gray[0]];
|
|
889
|
+
};
|
|
890
|
+
convert.gray.lab = function(gray) {
|
|
891
|
+
return [gray[0], 0, 0];
|
|
892
|
+
};
|
|
893
|
+
convert.gray.hex = function(gray) {
|
|
894
|
+
const val = Math.round(gray[0] / 100 * 255) & 255;
|
|
895
|
+
const integer = (val << 16) + (val << 8) + val;
|
|
896
|
+
const string = integer.toString(16).toUpperCase();
|
|
897
|
+
return "000000".substring(string.length) + string;
|
|
898
|
+
};
|
|
899
|
+
convert.rgb.gray = function(rgb) {
|
|
900
|
+
const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
|
|
901
|
+
return [val / 255 * 100];
|
|
902
|
+
};
|
|
903
|
+
return conversions$1;
|
|
904
|
+
}
|
|
905
|
+
var route$1;
|
|
906
|
+
var hasRequiredRoute$1;
|
|
907
|
+
function requireRoute$1() {
|
|
908
|
+
if (hasRequiredRoute$1) return route$1;
|
|
909
|
+
hasRequiredRoute$1 = 1;
|
|
910
|
+
const conversions2 = requireConversions$1();
|
|
911
|
+
function buildGraph() {
|
|
912
|
+
const graph = {};
|
|
913
|
+
const models = Object.keys(conversions2);
|
|
914
|
+
for (let len = models.length, i = 0; i < len; i++) {
|
|
915
|
+
graph[models[i]] = {
|
|
916
|
+
// http://jsperf.com/1-vs-infinity
|
|
917
|
+
// micro-opt, but this is simple.
|
|
918
|
+
distance: -1,
|
|
919
|
+
parent: null
|
|
920
|
+
};
|
|
921
|
+
}
|
|
922
|
+
return graph;
|
|
923
|
+
}
|
|
924
|
+
function deriveBFS(fromModel) {
|
|
925
|
+
const graph = buildGraph();
|
|
926
|
+
const queue = [fromModel];
|
|
927
|
+
graph[fromModel].distance = 0;
|
|
928
|
+
while (queue.length) {
|
|
929
|
+
const current = queue.pop();
|
|
930
|
+
const adjacents = Object.keys(conversions2[current]);
|
|
931
|
+
for (let len = adjacents.length, i = 0; i < len; i++) {
|
|
932
|
+
const adjacent = adjacents[i];
|
|
933
|
+
const node = graph[adjacent];
|
|
934
|
+
if (node.distance === -1) {
|
|
935
|
+
node.distance = graph[current].distance + 1;
|
|
936
|
+
node.parent = current;
|
|
937
|
+
queue.unshift(adjacent);
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
return graph;
|
|
942
|
+
}
|
|
943
|
+
function link(from, to) {
|
|
944
|
+
return function(args) {
|
|
945
|
+
return to(from(args));
|
|
946
|
+
};
|
|
947
|
+
}
|
|
948
|
+
function wrapConversion(toModel, graph) {
|
|
949
|
+
const path2 = [graph[toModel].parent, toModel];
|
|
950
|
+
let fn = conversions2[graph[toModel].parent][toModel];
|
|
951
|
+
let cur = graph[toModel].parent;
|
|
952
|
+
while (graph[cur].parent) {
|
|
953
|
+
path2.unshift(graph[cur].parent);
|
|
954
|
+
fn = link(conversions2[graph[cur].parent][cur], fn);
|
|
955
|
+
cur = graph[cur].parent;
|
|
956
|
+
}
|
|
957
|
+
fn.conversion = path2;
|
|
958
|
+
return fn;
|
|
959
|
+
}
|
|
960
|
+
route$1 = function(fromModel) {
|
|
961
|
+
const graph = deriveBFS(fromModel);
|
|
962
|
+
const conversion = {};
|
|
963
|
+
const models = Object.keys(graph);
|
|
964
|
+
for (let len = models.length, i = 0; i < len; i++) {
|
|
965
|
+
const toModel = models[i];
|
|
966
|
+
const node = graph[toModel];
|
|
967
|
+
if (node.parent === null) {
|
|
968
|
+
continue;
|
|
969
|
+
}
|
|
970
|
+
conversion[toModel] = wrapConversion(toModel, graph);
|
|
971
|
+
}
|
|
972
|
+
return conversion;
|
|
973
|
+
};
|
|
974
|
+
return route$1;
|
|
975
|
+
}
|
|
976
|
+
var colorConvert$1;
|
|
977
|
+
var hasRequiredColorConvert$1;
|
|
978
|
+
function requireColorConvert$1() {
|
|
979
|
+
if (hasRequiredColorConvert$1) return colorConvert$1;
|
|
980
|
+
hasRequiredColorConvert$1 = 1;
|
|
981
|
+
const conversions2 = requireConversions$1();
|
|
982
|
+
const route2 = requireRoute$1();
|
|
983
|
+
const convert = {};
|
|
984
|
+
const models = Object.keys(conversions2);
|
|
985
|
+
function wrapRaw(fn) {
|
|
986
|
+
const wrappedFn = function(...args) {
|
|
987
|
+
const arg0 = args[0];
|
|
988
|
+
if (arg0 === void 0 || arg0 === null) {
|
|
989
|
+
return arg0;
|
|
990
|
+
}
|
|
991
|
+
if (arg0.length > 1) {
|
|
992
|
+
args = arg0;
|
|
993
|
+
}
|
|
994
|
+
return fn(args);
|
|
995
|
+
};
|
|
996
|
+
if ("conversion" in fn) {
|
|
997
|
+
wrappedFn.conversion = fn.conversion;
|
|
998
|
+
}
|
|
999
|
+
return wrappedFn;
|
|
1000
|
+
}
|
|
1001
|
+
function wrapRounded(fn) {
|
|
1002
|
+
const wrappedFn = function(...args) {
|
|
1003
|
+
const arg0 = args[0];
|
|
1004
|
+
if (arg0 === void 0 || arg0 === null) {
|
|
1005
|
+
return arg0;
|
|
1006
|
+
}
|
|
1007
|
+
if (arg0.length > 1) {
|
|
1008
|
+
args = arg0;
|
|
1009
|
+
}
|
|
1010
|
+
const result = fn(args);
|
|
1011
|
+
if (typeof result === "object") {
|
|
1012
|
+
for (let len = result.length, i = 0; i < len; i++) {
|
|
1013
|
+
result[i] = Math.round(result[i]);
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
return result;
|
|
1017
|
+
};
|
|
1018
|
+
if ("conversion" in fn) {
|
|
1019
|
+
wrappedFn.conversion = fn.conversion;
|
|
1020
|
+
}
|
|
1021
|
+
return wrappedFn;
|
|
1022
|
+
}
|
|
1023
|
+
models.forEach((fromModel) => {
|
|
1024
|
+
convert[fromModel] = {};
|
|
1025
|
+
Object.defineProperty(convert[fromModel], "channels", { value: conversions2[fromModel].channels });
|
|
1026
|
+
Object.defineProperty(convert[fromModel], "labels", { value: conversions2[fromModel].labels });
|
|
1027
|
+
const routes = route2(fromModel);
|
|
1028
|
+
const routeModels = Object.keys(routes);
|
|
1029
|
+
routeModels.forEach((toModel) => {
|
|
1030
|
+
const fn = routes[toModel];
|
|
1031
|
+
convert[fromModel][toModel] = wrapRounded(fn);
|
|
1032
|
+
convert[fromModel][toModel].raw = wrapRaw(fn);
|
|
1033
|
+
});
|
|
1034
|
+
});
|
|
1035
|
+
colorConvert$1 = convert;
|
|
1036
|
+
return colorConvert$1;
|
|
1037
|
+
}
|
|
1038
|
+
ansiStyles$3.exports;
|
|
1039
|
+
(function(module) {
|
|
1040
|
+
const wrapAnsi16 = (fn, offset) => (...args) => {
|
|
1041
|
+
const code = fn(...args);
|
|
1042
|
+
return `\x1B[${code + offset}m`;
|
|
1043
|
+
};
|
|
1044
|
+
const wrapAnsi256 = (fn, offset) => (...args) => {
|
|
1045
|
+
const code = fn(...args);
|
|
1046
|
+
return `\x1B[${38 + offset};5;${code}m`;
|
|
1047
|
+
};
|
|
1048
|
+
const wrapAnsi16m = (fn, offset) => (...args) => {
|
|
1049
|
+
const rgb = fn(...args);
|
|
1050
|
+
return `\x1B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
|
|
1051
|
+
};
|
|
1052
|
+
const ansi2ansi = (n) => n;
|
|
1053
|
+
const rgb2rgb = (r, g, b) => [r, g, b];
|
|
1054
|
+
const setLazyProperty = (object, property, get) => {
|
|
1055
|
+
Object.defineProperty(object, property, {
|
|
1056
|
+
get: () => {
|
|
1057
|
+
const value = get();
|
|
1058
|
+
Object.defineProperty(object, property, {
|
|
1059
|
+
value,
|
|
1060
|
+
enumerable: true,
|
|
1061
|
+
configurable: true
|
|
1062
|
+
});
|
|
1063
|
+
return value;
|
|
1064
|
+
},
|
|
1065
|
+
enumerable: true,
|
|
1066
|
+
configurable: true
|
|
1067
|
+
});
|
|
1068
|
+
};
|
|
1069
|
+
let colorConvert2;
|
|
1070
|
+
const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
|
|
1071
|
+
if (colorConvert2 === void 0) {
|
|
1072
|
+
colorConvert2 = requireColorConvert$1();
|
|
1073
|
+
}
|
|
1074
|
+
const offset = isBackground ? 10 : 0;
|
|
1075
|
+
const styles2 = {};
|
|
1076
|
+
for (const [sourceSpace, suite] of Object.entries(colorConvert2)) {
|
|
1077
|
+
const name2 = sourceSpace === "ansi16" ? "ansi" : sourceSpace;
|
|
1078
|
+
if (sourceSpace === targetSpace) {
|
|
1079
|
+
styles2[name2] = wrap(identity, offset);
|
|
1080
|
+
} else if (typeof suite === "object") {
|
|
1081
|
+
styles2[name2] = wrap(suite[targetSpace], offset);
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
return styles2;
|
|
1085
|
+
};
|
|
1086
|
+
function assembleStyles() {
|
|
1087
|
+
const codes = /* @__PURE__ */ new Map();
|
|
1088
|
+
const styles2 = {
|
|
1089
|
+
modifier: {
|
|
1090
|
+
reset: [0, 0],
|
|
1091
|
+
// 21 isn't widely supported and 22 does the same thing
|
|
1092
|
+
bold: [1, 22],
|
|
1093
|
+
dim: [2, 22],
|
|
1094
|
+
italic: [3, 23],
|
|
1095
|
+
underline: [4, 24],
|
|
1096
|
+
inverse: [7, 27],
|
|
1097
|
+
hidden: [8, 28],
|
|
1098
|
+
strikethrough: [9, 29]
|
|
1099
|
+
},
|
|
1100
|
+
color: {
|
|
1101
|
+
black: [30, 39],
|
|
1102
|
+
red: [31, 39],
|
|
1103
|
+
green: [32, 39],
|
|
1104
|
+
yellow: [33, 39],
|
|
1105
|
+
blue: [34, 39],
|
|
1106
|
+
magenta: [35, 39],
|
|
1107
|
+
cyan: [36, 39],
|
|
1108
|
+
white: [37, 39],
|
|
1109
|
+
// Bright color
|
|
1110
|
+
blackBright: [90, 39],
|
|
1111
|
+
redBright: [91, 39],
|
|
1112
|
+
greenBright: [92, 39],
|
|
1113
|
+
yellowBright: [93, 39],
|
|
1114
|
+
blueBright: [94, 39],
|
|
1115
|
+
magentaBright: [95, 39],
|
|
1116
|
+
cyanBright: [96, 39],
|
|
1117
|
+
whiteBright: [97, 39]
|
|
1118
|
+
},
|
|
1119
|
+
bgColor: {
|
|
1120
|
+
bgBlack: [40, 49],
|
|
1121
|
+
bgRed: [41, 49],
|
|
1122
|
+
bgGreen: [42, 49],
|
|
1123
|
+
bgYellow: [43, 49],
|
|
1124
|
+
bgBlue: [44, 49],
|
|
1125
|
+
bgMagenta: [45, 49],
|
|
1126
|
+
bgCyan: [46, 49],
|
|
1127
|
+
bgWhite: [47, 49],
|
|
1128
|
+
// Bright color
|
|
1129
|
+
bgBlackBright: [100, 49],
|
|
1130
|
+
bgRedBright: [101, 49],
|
|
1131
|
+
bgGreenBright: [102, 49],
|
|
1132
|
+
bgYellowBright: [103, 49],
|
|
1133
|
+
bgBlueBright: [104, 49],
|
|
1134
|
+
bgMagentaBright: [105, 49],
|
|
1135
|
+
bgCyanBright: [106, 49],
|
|
1136
|
+
bgWhiteBright: [107, 49]
|
|
1137
|
+
}
|
|
1138
|
+
};
|
|
1139
|
+
styles2.color.gray = styles2.color.blackBright;
|
|
1140
|
+
styles2.bgColor.bgGray = styles2.bgColor.bgBlackBright;
|
|
1141
|
+
styles2.color.grey = styles2.color.blackBright;
|
|
1142
|
+
styles2.bgColor.bgGrey = styles2.bgColor.bgBlackBright;
|
|
1143
|
+
for (const [groupName, group] of Object.entries(styles2)) {
|
|
1144
|
+
for (const [styleName, style] of Object.entries(group)) {
|
|
1145
|
+
styles2[styleName] = {
|
|
1146
|
+
open: `\x1B[${style[0]}m`,
|
|
1147
|
+
close: `\x1B[${style[1]}m`
|
|
1148
|
+
};
|
|
1149
|
+
group[styleName] = styles2[styleName];
|
|
1150
|
+
codes.set(style[0], style[1]);
|
|
1151
|
+
}
|
|
1152
|
+
Object.defineProperty(styles2, groupName, {
|
|
1153
|
+
value: group,
|
|
1154
|
+
enumerable: false
|
|
1155
|
+
});
|
|
1156
|
+
}
|
|
1157
|
+
Object.defineProperty(styles2, "codes", {
|
|
1158
|
+
value: codes,
|
|
1159
|
+
enumerable: false
|
|
1160
|
+
});
|
|
1161
|
+
styles2.color.close = "\x1B[39m";
|
|
1162
|
+
styles2.bgColor.close = "\x1B[49m";
|
|
1163
|
+
setLazyProperty(styles2.color, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, false));
|
|
1164
|
+
setLazyProperty(styles2.color, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, false));
|
|
1165
|
+
setLazyProperty(styles2.color, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, false));
|
|
1166
|
+
setLazyProperty(styles2.bgColor, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, true));
|
|
1167
|
+
setLazyProperty(styles2.bgColor, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, true));
|
|
1168
|
+
setLazyProperty(styles2.bgColor, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, true));
|
|
1169
|
+
return styles2;
|
|
1170
|
+
}
|
|
1171
|
+
Object.defineProperty(module, "exports", {
|
|
1172
|
+
enumerable: true,
|
|
1173
|
+
get: assembleStyles
|
|
1174
|
+
});
|
|
1175
|
+
})(ansiStyles$3);
|
|
1176
|
+
var ansiStylesExports$1 = ansiStyles$3.exports;
|
|
1177
|
+
var browser$2 = {
|
|
1178
|
+
stdout: false,
|
|
1179
|
+
stderr: false
|
|
1180
|
+
};
|
|
1181
|
+
const stringReplaceAll$3 = (string, substring, replacer) => {
|
|
1182
|
+
let index = string.indexOf(substring);
|
|
1183
|
+
if (index === -1) {
|
|
1184
|
+
return string;
|
|
1185
|
+
}
|
|
1186
|
+
const substringLength = substring.length;
|
|
1187
|
+
let endIndex = 0;
|
|
1188
|
+
let returnValue = "";
|
|
1189
|
+
do {
|
|
1190
|
+
returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
|
|
1191
|
+
endIndex = index + substringLength;
|
|
1192
|
+
index = string.indexOf(substring, endIndex);
|
|
1193
|
+
} while (index !== -1);
|
|
1194
|
+
returnValue += string.substr(endIndex);
|
|
1195
|
+
return returnValue;
|
|
1196
|
+
};
|
|
1197
|
+
const stringEncaseCRLFWithFirstIndex$3 = (string, prefix, postfix, index) => {
|
|
1198
|
+
let endIndex = 0;
|
|
1199
|
+
let returnValue = "";
|
|
1200
|
+
do {
|
|
1201
|
+
const gotCR = string[index - 1] === "\r";
|
|
1202
|
+
returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
|
|
1203
|
+
endIndex = index + 1;
|
|
1204
|
+
index = string.indexOf("\n", endIndex);
|
|
1205
|
+
} while (index !== -1);
|
|
1206
|
+
returnValue += string.substr(endIndex);
|
|
1207
|
+
return returnValue;
|
|
1208
|
+
};
|
|
1209
|
+
var util$1 = {
|
|
1210
|
+
stringReplaceAll: stringReplaceAll$3,
|
|
1211
|
+
stringEncaseCRLFWithFirstIndex: stringEncaseCRLFWithFirstIndex$3
|
|
1212
|
+
};
|
|
1213
|
+
var templates$1;
|
|
1214
|
+
var hasRequiredTemplates$1;
|
|
1215
|
+
function requireTemplates$1() {
|
|
1216
|
+
if (hasRequiredTemplates$1) return templates$1;
|
|
1217
|
+
hasRequiredTemplates$1 = 1;
|
|
1218
|
+
const TEMPLATE_REGEX = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
|
|
1219
|
+
const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
|
|
1220
|
+
const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
|
|
1221
|
+
const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
|
|
1222
|
+
const ESCAPES = /* @__PURE__ */ new Map([
|
|
1223
|
+
["n", "\n"],
|
|
1224
|
+
["r", "\r"],
|
|
1225
|
+
["t", " "],
|
|
1226
|
+
["b", "\b"],
|
|
1227
|
+
["f", "\f"],
|
|
1228
|
+
["v", "\v"],
|
|
1229
|
+
["0", "\0"],
|
|
1230
|
+
["\\", "\\"],
|
|
1231
|
+
["e", "\x1B"],
|
|
1232
|
+
["a", "\x07"]
|
|
1233
|
+
]);
|
|
1234
|
+
function unescape(c) {
|
|
1235
|
+
const u = c[0] === "u";
|
|
1236
|
+
const bracket = c[1] === "{";
|
|
1237
|
+
if (u && !bracket && c.length === 5 || c[0] === "x" && c.length === 3) {
|
|
1238
|
+
return String.fromCharCode(parseInt(c.slice(1), 16));
|
|
1239
|
+
}
|
|
1240
|
+
if (u && bracket) {
|
|
1241
|
+
return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
|
|
1242
|
+
}
|
|
1243
|
+
return ESCAPES.get(c) || c;
|
|
1244
|
+
}
|
|
1245
|
+
function parseArguments(name2, arguments_) {
|
|
1246
|
+
const results = [];
|
|
1247
|
+
const chunks = arguments_.trim().split(/\s*,\s*/g);
|
|
1248
|
+
let matches;
|
|
1249
|
+
for (const chunk of chunks) {
|
|
1250
|
+
const number = Number(chunk);
|
|
1251
|
+
if (!Number.isNaN(number)) {
|
|
1252
|
+
results.push(number);
|
|
1253
|
+
} else if (matches = chunk.match(STRING_REGEX)) {
|
|
1254
|
+
results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape(escape) : character));
|
|
1255
|
+
} else {
|
|
1256
|
+
throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name2}')`);
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
return results;
|
|
1260
|
+
}
|
|
1261
|
+
function parseStyle(style) {
|
|
1262
|
+
STYLE_REGEX.lastIndex = 0;
|
|
1263
|
+
const results = [];
|
|
1264
|
+
let matches;
|
|
1265
|
+
while ((matches = STYLE_REGEX.exec(style)) !== null) {
|
|
1266
|
+
const name2 = matches[1];
|
|
1267
|
+
if (matches[2]) {
|
|
1268
|
+
const args = parseArguments(name2, matches[2]);
|
|
1269
|
+
results.push([name2].concat(args));
|
|
1270
|
+
} else {
|
|
1271
|
+
results.push([name2]);
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
return results;
|
|
1275
|
+
}
|
|
1276
|
+
function buildStyle(chalk2, styles2) {
|
|
1277
|
+
const enabled = {};
|
|
1278
|
+
for (const layer of styles2) {
|
|
1279
|
+
for (const style of layer.styles) {
|
|
1280
|
+
enabled[style[0]] = layer.inverse ? null : style.slice(1);
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
let current = chalk2;
|
|
1284
|
+
for (const [styleName, styles3] of Object.entries(enabled)) {
|
|
1285
|
+
if (!Array.isArray(styles3)) {
|
|
1286
|
+
continue;
|
|
1287
|
+
}
|
|
1288
|
+
if (!(styleName in current)) {
|
|
1289
|
+
throw new Error(`Unknown Chalk style: ${styleName}`);
|
|
1290
|
+
}
|
|
1291
|
+
current = styles3.length > 0 ? current[styleName](...styles3) : current[styleName];
|
|
1292
|
+
}
|
|
1293
|
+
return current;
|
|
1294
|
+
}
|
|
1295
|
+
templates$1 = (chalk2, temporary) => {
|
|
1296
|
+
const styles2 = [];
|
|
1297
|
+
const chunks = [];
|
|
1298
|
+
let chunk = [];
|
|
1299
|
+
temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
|
|
1300
|
+
if (escapeCharacter) {
|
|
1301
|
+
chunk.push(unescape(escapeCharacter));
|
|
1302
|
+
} else if (style) {
|
|
1303
|
+
const string = chunk.join("");
|
|
1304
|
+
chunk = [];
|
|
1305
|
+
chunks.push(styles2.length === 0 ? string : buildStyle(chalk2, styles2)(string));
|
|
1306
|
+
styles2.push({ inverse, styles: parseStyle(style) });
|
|
1307
|
+
} else if (close) {
|
|
1308
|
+
if (styles2.length === 0) {
|
|
1309
|
+
throw new Error("Found extraneous } in Chalk template literal");
|
|
1310
|
+
}
|
|
1311
|
+
chunks.push(buildStyle(chalk2, styles2)(chunk.join("")));
|
|
1312
|
+
chunk = [];
|
|
1313
|
+
styles2.pop();
|
|
1314
|
+
} else {
|
|
1315
|
+
chunk.push(character);
|
|
1316
|
+
}
|
|
1317
|
+
});
|
|
1318
|
+
chunks.push(chunk.join(""));
|
|
1319
|
+
if (styles2.length > 0) {
|
|
1320
|
+
const errMessage = `Chalk template literal is missing ${styles2.length} closing bracket${styles2.length === 1 ? "" : "s"} (\`}\`)`;
|
|
1321
|
+
throw new Error(errMessage);
|
|
1322
|
+
}
|
|
1323
|
+
return chunks.join("");
|
|
1324
|
+
};
|
|
1325
|
+
return templates$1;
|
|
1326
|
+
}
|
|
1327
|
+
const ansiStyles$2 = ansiStylesExports$1;
|
|
1328
|
+
const { stdout: stdoutColor$1, stderr: stderrColor$1 } = browser$2;
|
|
1329
|
+
const {
|
|
1330
|
+
stringReplaceAll: stringReplaceAll$2,
|
|
1331
|
+
stringEncaseCRLFWithFirstIndex: stringEncaseCRLFWithFirstIndex$2
|
|
1332
|
+
} = util$1;
|
|
1333
|
+
const { isArray: isArray$1 } = Array;
|
|
1334
|
+
const levelMapping$1 = [
|
|
1335
|
+
"ansi",
|
|
1336
|
+
"ansi",
|
|
1337
|
+
"ansi256",
|
|
1338
|
+
"ansi16m"
|
|
1339
|
+
];
|
|
1340
|
+
const styles$1 = /* @__PURE__ */ Object.create(null);
|
|
1341
|
+
const applyOptions$1 = (object, options = {}) => {
|
|
1342
|
+
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
|
1343
|
+
throw new Error("The `level` option should be an integer from 0 to 3");
|
|
1344
|
+
}
|
|
1345
|
+
const colorLevel = stdoutColor$1 ? stdoutColor$1.level : 0;
|
|
1346
|
+
object.level = options.level === void 0 ? colorLevel : options.level;
|
|
1347
|
+
};
|
|
1348
|
+
let ChalkClass$1 = class ChalkClass {
|
|
1349
|
+
constructor(options) {
|
|
1350
|
+
return chalkFactory$1(options);
|
|
1351
|
+
}
|
|
1352
|
+
};
|
|
1353
|
+
const chalkFactory$1 = (options) => {
|
|
1354
|
+
const chalk2 = {};
|
|
1355
|
+
applyOptions$1(chalk2, options);
|
|
1356
|
+
chalk2.template = (...arguments_) => chalkTag$1(chalk2.template, ...arguments_);
|
|
1357
|
+
Object.setPrototypeOf(chalk2, Chalk$1.prototype);
|
|
1358
|
+
Object.setPrototypeOf(chalk2.template, chalk2);
|
|
1359
|
+
chalk2.template.constructor = () => {
|
|
1360
|
+
throw new Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.");
|
|
1361
|
+
};
|
|
1362
|
+
chalk2.template.Instance = ChalkClass$1;
|
|
1363
|
+
return chalk2.template;
|
|
1364
|
+
};
|
|
1365
|
+
function Chalk$1(options) {
|
|
1366
|
+
return chalkFactory$1(options);
|
|
1367
|
+
}
|
|
1368
|
+
for (const [styleName, style] of Object.entries(ansiStyles$2)) {
|
|
1369
|
+
styles$1[styleName] = {
|
|
1370
|
+
get() {
|
|
1371
|
+
const builder = createBuilder$1(this, createStyler$1(style.open, style.close, this._styler), this._isEmpty);
|
|
1372
|
+
Object.defineProperty(this, styleName, { value: builder });
|
|
1373
|
+
return builder;
|
|
1374
|
+
}
|
|
1375
|
+
};
|
|
1376
|
+
}
|
|
1377
|
+
styles$1.visible = {
|
|
1378
|
+
get() {
|
|
1379
|
+
const builder = createBuilder$1(this, this._styler, true);
|
|
1380
|
+
Object.defineProperty(this, "visible", { value: builder });
|
|
1381
|
+
return builder;
|
|
1382
|
+
}
|
|
1383
|
+
};
|
|
1384
|
+
const usedModels$1 = ["rgb", "hex", "keyword", "hsl", "hsv", "hwb", "ansi", "ansi256"];
|
|
1385
|
+
for (const model of usedModels$1) {
|
|
1386
|
+
styles$1[model] = {
|
|
1387
|
+
get() {
|
|
1388
|
+
const { level } = this;
|
|
1389
|
+
return function(...arguments_) {
|
|
1390
|
+
const styler = createStyler$1(ansiStyles$2.color[levelMapping$1[level]][model](...arguments_), ansiStyles$2.color.close, this._styler);
|
|
1391
|
+
return createBuilder$1(this, styler, this._isEmpty);
|
|
1392
|
+
};
|
|
1393
|
+
}
|
|
1394
|
+
};
|
|
1395
|
+
}
|
|
1396
|
+
for (const model of usedModels$1) {
|
|
1397
|
+
const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
|
|
1398
|
+
styles$1[bgModel] = {
|
|
1399
|
+
get() {
|
|
1400
|
+
const { level } = this;
|
|
1401
|
+
return function(...arguments_) {
|
|
1402
|
+
const styler = createStyler$1(ansiStyles$2.bgColor[levelMapping$1[level]][model](...arguments_), ansiStyles$2.bgColor.close, this._styler);
|
|
1403
|
+
return createBuilder$1(this, styler, this._isEmpty);
|
|
1404
|
+
};
|
|
1405
|
+
}
|
|
1406
|
+
};
|
|
1407
|
+
}
|
|
1408
|
+
const proto$1 = Object.defineProperties(() => {
|
|
1409
|
+
}, {
|
|
1410
|
+
...styles$1,
|
|
1411
|
+
level: {
|
|
1412
|
+
enumerable: true,
|
|
1413
|
+
get() {
|
|
1414
|
+
return this._generator.level;
|
|
1415
|
+
},
|
|
1416
|
+
set(level) {
|
|
1417
|
+
this._generator.level = level;
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
});
|
|
1421
|
+
const createStyler$1 = (open, close, parent) => {
|
|
1422
|
+
let openAll;
|
|
1423
|
+
let closeAll;
|
|
1424
|
+
if (parent === void 0) {
|
|
1425
|
+
openAll = open;
|
|
1426
|
+
closeAll = close;
|
|
1427
|
+
} else {
|
|
1428
|
+
openAll = parent.openAll + open;
|
|
1429
|
+
closeAll = close + parent.closeAll;
|
|
1430
|
+
}
|
|
1431
|
+
return {
|
|
1432
|
+
open,
|
|
1433
|
+
close,
|
|
1434
|
+
openAll,
|
|
1435
|
+
closeAll,
|
|
1436
|
+
parent
|
|
1437
|
+
};
|
|
1438
|
+
};
|
|
1439
|
+
const createBuilder$1 = (self, _styler, _isEmpty) => {
|
|
1440
|
+
const builder = (...arguments_) => {
|
|
1441
|
+
if (isArray$1(arguments_[0]) && isArray$1(arguments_[0].raw)) {
|
|
1442
|
+
return applyStyle$1(builder, chalkTag$1(builder, ...arguments_));
|
|
1443
|
+
}
|
|
1444
|
+
return applyStyle$1(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
|
|
1445
|
+
};
|
|
1446
|
+
Object.setPrototypeOf(builder, proto$1);
|
|
1447
|
+
builder._generator = self;
|
|
1448
|
+
builder._styler = _styler;
|
|
1449
|
+
builder._isEmpty = _isEmpty;
|
|
1450
|
+
return builder;
|
|
1451
|
+
};
|
|
1452
|
+
const applyStyle$1 = (self, string) => {
|
|
1453
|
+
if (self.level <= 0 || !string) {
|
|
1454
|
+
return self._isEmpty ? "" : string;
|
|
1455
|
+
}
|
|
1456
|
+
let styler = self._styler;
|
|
1457
|
+
if (styler === void 0) {
|
|
1458
|
+
return string;
|
|
1459
|
+
}
|
|
1460
|
+
const { openAll, closeAll } = styler;
|
|
1461
|
+
if (string.indexOf("\x1B") !== -1) {
|
|
1462
|
+
while (styler !== void 0) {
|
|
1463
|
+
string = stringReplaceAll$2(string, styler.close, styler.open);
|
|
1464
|
+
styler = styler.parent;
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
const lfIndex = string.indexOf("\n");
|
|
1468
|
+
if (lfIndex !== -1) {
|
|
1469
|
+
string = stringEncaseCRLFWithFirstIndex$2(string, closeAll, openAll, lfIndex);
|
|
1470
|
+
}
|
|
1471
|
+
return openAll + string + closeAll;
|
|
1472
|
+
};
|
|
1473
|
+
let template$1;
|
|
1474
|
+
const chalkTag$1 = (chalk2, ...strings) => {
|
|
1475
|
+
const [firstString] = strings;
|
|
1476
|
+
if (!isArray$1(firstString) || !isArray$1(firstString.raw)) {
|
|
1477
|
+
return strings.join(" ");
|
|
1478
|
+
}
|
|
1479
|
+
const arguments_ = strings.slice(1);
|
|
1480
|
+
const parts = [firstString.raw[0]];
|
|
1481
|
+
for (let i = 1; i < firstString.length; i++) {
|
|
1482
|
+
parts.push(
|
|
1483
|
+
String(arguments_[i - 1]).replace(/[{}\\]/g, "\\$&"),
|
|
1484
|
+
String(firstString.raw[i])
|
|
1485
|
+
);
|
|
1486
|
+
}
|
|
1487
|
+
if (template$1 === void 0) {
|
|
1488
|
+
template$1 = requireTemplates$1();
|
|
1489
|
+
}
|
|
1490
|
+
return template$1(chalk2, parts.join(""));
|
|
1491
|
+
};
|
|
1492
|
+
Object.defineProperties(Chalk$1.prototype, styles$1);
|
|
1493
|
+
const chalk$1 = Chalk$1();
|
|
1494
|
+
chalk$1.supportsColor = stdoutColor$1;
|
|
1495
|
+
chalk$1.stderr = Chalk$1({ level: stderrColor$1 ? stderrColor$1.level : 0 });
|
|
1496
|
+
chalk$1.stderr.supportsColor = stderrColor$1;
|
|
1497
|
+
var source = chalk$1;
|
|
1498
|
+
const chalk$2 = /* @__PURE__ */ getDefaultExportFromCjs(source);
|
|
1499
|
+
var StatusCodes;
|
|
1500
|
+
(function(StatusCodes2) {
|
|
1501
|
+
StatusCodes2[StatusCodes2["CONTINUE"] = 100] = "CONTINUE";
|
|
1502
|
+
StatusCodes2[StatusCodes2["SWITCHING_PROTOCOLS"] = 101] = "SWITCHING_PROTOCOLS";
|
|
1503
|
+
StatusCodes2[StatusCodes2["PROCESSING"] = 102] = "PROCESSING";
|
|
1504
|
+
StatusCodes2[StatusCodes2["EARLY_HINTS"] = 103] = "EARLY_HINTS";
|
|
1505
|
+
StatusCodes2[StatusCodes2["OK"] = 200] = "OK";
|
|
1506
|
+
StatusCodes2[StatusCodes2["CREATED"] = 201] = "CREATED";
|
|
1507
|
+
StatusCodes2[StatusCodes2["ACCEPTED"] = 202] = "ACCEPTED";
|
|
1508
|
+
StatusCodes2[StatusCodes2["NON_AUTHORITATIVE_INFORMATION"] = 203] = "NON_AUTHORITATIVE_INFORMATION";
|
|
1509
|
+
StatusCodes2[StatusCodes2["NO_CONTENT"] = 204] = "NO_CONTENT";
|
|
1510
|
+
StatusCodes2[StatusCodes2["RESET_CONTENT"] = 205] = "RESET_CONTENT";
|
|
1511
|
+
StatusCodes2[StatusCodes2["PARTIAL_CONTENT"] = 206] = "PARTIAL_CONTENT";
|
|
1512
|
+
StatusCodes2[StatusCodes2["MULTI_STATUS"] = 207] = "MULTI_STATUS";
|
|
1513
|
+
StatusCodes2[StatusCodes2["MULTIPLE_CHOICES"] = 300] = "MULTIPLE_CHOICES";
|
|
1514
|
+
StatusCodes2[StatusCodes2["MOVED_PERMANENTLY"] = 301] = "MOVED_PERMANENTLY";
|
|
1515
|
+
StatusCodes2[StatusCodes2["MOVED_TEMPORARILY"] = 302] = "MOVED_TEMPORARILY";
|
|
1516
|
+
StatusCodes2[StatusCodes2["SEE_OTHER"] = 303] = "SEE_OTHER";
|
|
1517
|
+
StatusCodes2[StatusCodes2["NOT_MODIFIED"] = 304] = "NOT_MODIFIED";
|
|
1518
|
+
StatusCodes2[StatusCodes2["USE_PROXY"] = 305] = "USE_PROXY";
|
|
1519
|
+
StatusCodes2[StatusCodes2["TEMPORARY_REDIRECT"] = 307] = "TEMPORARY_REDIRECT";
|
|
1520
|
+
StatusCodes2[StatusCodes2["PERMANENT_REDIRECT"] = 308] = "PERMANENT_REDIRECT";
|
|
1521
|
+
StatusCodes2[StatusCodes2["BAD_REQUEST"] = 400] = "BAD_REQUEST";
|
|
1522
|
+
StatusCodes2[StatusCodes2["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
|
|
1523
|
+
StatusCodes2[StatusCodes2["PAYMENT_REQUIRED"] = 402] = "PAYMENT_REQUIRED";
|
|
1524
|
+
StatusCodes2[StatusCodes2["FORBIDDEN"] = 403] = "FORBIDDEN";
|
|
1525
|
+
StatusCodes2[StatusCodes2["NOT_FOUND"] = 404] = "NOT_FOUND";
|
|
1526
|
+
StatusCodes2[StatusCodes2["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
|
|
1527
|
+
StatusCodes2[StatusCodes2["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
|
|
1528
|
+
StatusCodes2[StatusCodes2["PROXY_AUTHENTICATION_REQUIRED"] = 407] = "PROXY_AUTHENTICATION_REQUIRED";
|
|
1529
|
+
StatusCodes2[StatusCodes2["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
|
|
1530
|
+
StatusCodes2[StatusCodes2["CONFLICT"] = 409] = "CONFLICT";
|
|
1531
|
+
StatusCodes2[StatusCodes2["GONE"] = 410] = "GONE";
|
|
1532
|
+
StatusCodes2[StatusCodes2["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED";
|
|
1533
|
+
StatusCodes2[StatusCodes2["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
|
|
1534
|
+
StatusCodes2[StatusCodes2["REQUEST_TOO_LONG"] = 413] = "REQUEST_TOO_LONG";
|
|
1535
|
+
StatusCodes2[StatusCodes2["REQUEST_URI_TOO_LONG"] = 414] = "REQUEST_URI_TOO_LONG";
|
|
1536
|
+
StatusCodes2[StatusCodes2["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
|
|
1537
|
+
StatusCodes2[StatusCodes2["REQUESTED_RANGE_NOT_SATISFIABLE"] = 416] = "REQUESTED_RANGE_NOT_SATISFIABLE";
|
|
1538
|
+
StatusCodes2[StatusCodes2["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
|
|
1539
|
+
StatusCodes2[StatusCodes2["IM_A_TEAPOT"] = 418] = "IM_A_TEAPOT";
|
|
1540
|
+
StatusCodes2[StatusCodes2["INSUFFICIENT_SPACE_ON_RESOURCE"] = 419] = "INSUFFICIENT_SPACE_ON_RESOURCE";
|
|
1541
|
+
StatusCodes2[StatusCodes2["METHOD_FAILURE"] = 420] = "METHOD_FAILURE";
|
|
1542
|
+
StatusCodes2[StatusCodes2["MISDIRECTED_REQUEST"] = 421] = "MISDIRECTED_REQUEST";
|
|
1543
|
+
StatusCodes2[StatusCodes2["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
|
|
1544
|
+
StatusCodes2[StatusCodes2["LOCKED"] = 423] = "LOCKED";
|
|
1545
|
+
StatusCodes2[StatusCodes2["FAILED_DEPENDENCY"] = 424] = "FAILED_DEPENDENCY";
|
|
1546
|
+
StatusCodes2[StatusCodes2["UPGRADE_REQUIRED"] = 426] = "UPGRADE_REQUIRED";
|
|
1547
|
+
StatusCodes2[StatusCodes2["PRECONDITION_REQUIRED"] = 428] = "PRECONDITION_REQUIRED";
|
|
1548
|
+
StatusCodes2[StatusCodes2["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
|
|
1549
|
+
StatusCodes2[StatusCodes2["REQUEST_HEADER_FIELDS_TOO_LARGE"] = 431] = "REQUEST_HEADER_FIELDS_TOO_LARGE";
|
|
1550
|
+
StatusCodes2[StatusCodes2["UNAVAILABLE_FOR_LEGAL_REASONS"] = 451] = "UNAVAILABLE_FOR_LEGAL_REASONS";
|
|
1551
|
+
StatusCodes2[StatusCodes2["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
|
|
1552
|
+
StatusCodes2[StatusCodes2["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
|
|
1553
|
+
StatusCodes2[StatusCodes2["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
|
|
1554
|
+
StatusCodes2[StatusCodes2["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
|
|
1555
|
+
StatusCodes2[StatusCodes2["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
|
|
1556
|
+
StatusCodes2[StatusCodes2["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
|
|
1557
|
+
StatusCodes2[StatusCodes2["INSUFFICIENT_STORAGE"] = 507] = "INSUFFICIENT_STORAGE";
|
|
1558
|
+
StatusCodes2[StatusCodes2["NETWORK_AUTHENTICATION_REQUIRED"] = 511] = "NETWORK_AUTHENTICATION_REQUIRED";
|
|
1559
|
+
})(StatusCodes || (StatusCodes = {}));
|
|
1560
|
+
const http = {};
|
|
1561
|
+
const fs$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1562
|
+
__proto__: null,
|
|
1563
|
+
default: http
|
|
1564
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
1565
|
+
var main$1 = { exports: {} };
|
|
1566
|
+
const require$$3 = /* @__PURE__ */ getAugmentedNamespace(fs$1);
|
|
1567
|
+
const name = "dotenv";
|
|
1568
|
+
const version$1 = "16.4.5";
|
|
1569
|
+
const description = "Loads environment variables from .env file";
|
|
1570
|
+
const main = "lib/main.js";
|
|
1571
|
+
const types = "lib/main.d.ts";
|
|
1572
|
+
const exports = {
|
|
1573
|
+
".": {
|
|
1574
|
+
types: "./lib/main.d.ts",
|
|
1575
|
+
require: "./lib/main.js",
|
|
1576
|
+
"default": "./lib/main.js"
|
|
1577
|
+
},
|
|
1578
|
+
"./config": "./config.js",
|
|
1579
|
+
"./config.js": "./config.js",
|
|
1580
|
+
"./lib/env-options": "./lib/env-options.js",
|
|
1581
|
+
"./lib/env-options.js": "./lib/env-options.js",
|
|
1582
|
+
"./lib/cli-options": "./lib/cli-options.js",
|
|
1583
|
+
"./lib/cli-options.js": "./lib/cli-options.js",
|
|
1584
|
+
"./package.json": "./package.json"
|
|
1585
|
+
};
|
|
1586
|
+
const scripts = {
|
|
1587
|
+
"dts-check": "tsc --project tests/types/tsconfig.json",
|
|
1588
|
+
lint: "standard",
|
|
1589
|
+
"lint-readme": "standard-markdown",
|
|
1590
|
+
pretest: "npm run lint && npm run dts-check",
|
|
1591
|
+
test: "tap tests/*.js --100 -Rspec",
|
|
1592
|
+
"test:coverage": "tap --coverage-report=lcov",
|
|
1593
|
+
prerelease: "npm test",
|
|
1594
|
+
release: "standard-version"
|
|
1595
|
+
};
|
|
1596
|
+
const repository = {
|
|
1597
|
+
type: "git",
|
|
1598
|
+
url: "git://github.com/motdotla/dotenv.git"
|
|
1599
|
+
};
|
|
1600
|
+
const funding = "https://dotenvx.com";
|
|
1601
|
+
const keywords = [
|
|
1602
|
+
"dotenv",
|
|
1603
|
+
"env",
|
|
1604
|
+
".env",
|
|
1605
|
+
"environment",
|
|
1606
|
+
"variables",
|
|
1607
|
+
"config",
|
|
1608
|
+
"settings"
|
|
1609
|
+
];
|
|
1610
|
+
const readmeFilename = "README.md";
|
|
1611
|
+
const license = "BSD-2-Clause";
|
|
1612
|
+
const devDependencies = {
|
|
1613
|
+
"@definitelytyped/dtslint": "^0.0.133",
|
|
1614
|
+
"@types/node": "^18.11.3",
|
|
1615
|
+
decache: "^4.6.1",
|
|
1616
|
+
sinon: "^14.0.1",
|
|
1617
|
+
standard: "^17.0.0",
|
|
1618
|
+
"standard-markdown": "^7.1.0",
|
|
1619
|
+
"standard-version": "^9.5.0",
|
|
1620
|
+
tap: "^16.3.0",
|
|
1621
|
+
tar: "^6.1.11",
|
|
1622
|
+
typescript: "^4.8.4"
|
|
1623
|
+
};
|
|
1624
|
+
const engines = {
|
|
1625
|
+
node: ">=12"
|
|
1626
|
+
};
|
|
1627
|
+
const browser$1 = {
|
|
1628
|
+
fs: false
|
|
1629
|
+
};
|
|
1630
|
+
const require$$4 = {
|
|
1631
|
+
name,
|
|
1632
|
+
version: version$1,
|
|
1633
|
+
description,
|
|
1634
|
+
main,
|
|
1635
|
+
types,
|
|
1636
|
+
exports,
|
|
1637
|
+
scripts,
|
|
1638
|
+
repository,
|
|
1639
|
+
funding,
|
|
1640
|
+
keywords,
|
|
1641
|
+
readmeFilename,
|
|
1642
|
+
license,
|
|
1643
|
+
devDependencies,
|
|
1644
|
+
engines,
|
|
1645
|
+
browser: browser$1
|
|
1646
|
+
};
|
|
1647
|
+
const fs = require$$3;
|
|
1648
|
+
const path = require$$3;
|
|
1649
|
+
const os = require$$3;
|
|
1650
|
+
const crypto$1 = require$$3;
|
|
1651
|
+
const packageJson = require$$4;
|
|
1652
|
+
const version = packageJson.version;
|
|
1653
|
+
const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
|
|
1654
|
+
function parse(src) {
|
|
1655
|
+
const obj = {};
|
|
1656
|
+
let lines = src.toString();
|
|
1657
|
+
lines = lines.replace(/\r\n?/mg, "\n");
|
|
1658
|
+
let match;
|
|
1659
|
+
while ((match = LINE.exec(lines)) != null) {
|
|
1660
|
+
const key = match[1];
|
|
1661
|
+
let value = match[2] || "";
|
|
1662
|
+
value = value.trim();
|
|
1663
|
+
const maybeQuote = value[0];
|
|
1664
|
+
value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
|
|
1665
|
+
if (maybeQuote === '"') {
|
|
1666
|
+
value = value.replace(/\\n/g, "\n");
|
|
1667
|
+
value = value.replace(/\\r/g, "\r");
|
|
1668
|
+
}
|
|
1669
|
+
obj[key] = value;
|
|
1670
|
+
}
|
|
1671
|
+
return obj;
|
|
1672
|
+
}
|
|
1673
|
+
function _parseVault(options) {
|
|
1674
|
+
const vaultPath = _vaultPath(options);
|
|
1675
|
+
const result = DotenvModule.configDotenv({ path: vaultPath });
|
|
1676
|
+
if (!result.parsed) {
|
|
1677
|
+
const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
|
|
1678
|
+
err.code = "MISSING_DATA";
|
|
1679
|
+
throw err;
|
|
1680
|
+
}
|
|
1681
|
+
const keys = _dotenvKey(options).split(",");
|
|
1682
|
+
const length = keys.length;
|
|
1683
|
+
let decrypted;
|
|
1684
|
+
for (let i = 0; i < length; i++) {
|
|
1685
|
+
try {
|
|
1686
|
+
const key = keys[i].trim();
|
|
1687
|
+
const attrs = _instructions(result, key);
|
|
1688
|
+
decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
|
|
1689
|
+
break;
|
|
1690
|
+
} catch (error) {
|
|
1691
|
+
if (i + 1 >= length) {
|
|
1692
|
+
throw error;
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
return DotenvModule.parse(decrypted);
|
|
21
1697
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
1698
|
+
function _log(message) {
|
|
1699
|
+
console.log(`[dotenv@${version}][INFO] ${message}`);
|
|
1700
|
+
}
|
|
1701
|
+
function _warn(message) {
|
|
1702
|
+
console.log(`[dotenv@${version}][WARN] ${message}`);
|
|
1703
|
+
}
|
|
1704
|
+
function _debug(message) {
|
|
1705
|
+
console.log(`[dotenv@${version}][DEBUG] ${message}`);
|
|
1706
|
+
}
|
|
1707
|
+
function _dotenvKey(options) {
|
|
1708
|
+
if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
|
|
1709
|
+
return options.DOTENV_KEY;
|
|
1710
|
+
}
|
|
1711
|
+
if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
|
|
1712
|
+
return process.env.DOTENV_KEY;
|
|
1713
|
+
}
|
|
1714
|
+
return "";
|
|
1715
|
+
}
|
|
1716
|
+
function _instructions(result, dotenvKey) {
|
|
1717
|
+
let uri;
|
|
1718
|
+
try {
|
|
1719
|
+
uri = new URL(dotenvKey);
|
|
1720
|
+
} catch (error) {
|
|
1721
|
+
if (error.code === "ERR_INVALID_URL") {
|
|
1722
|
+
const err = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
|
|
1723
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
1724
|
+
throw err;
|
|
29
1725
|
}
|
|
1726
|
+
throw error;
|
|
30
1727
|
}
|
|
31
|
-
|
|
1728
|
+
const key = uri.password;
|
|
1729
|
+
if (!key) {
|
|
1730
|
+
const err = new Error("INVALID_DOTENV_KEY: Missing key part");
|
|
1731
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
1732
|
+
throw err;
|
|
1733
|
+
}
|
|
1734
|
+
const environment = uri.searchParams.get("environment");
|
|
1735
|
+
if (!environment) {
|
|
1736
|
+
const err = new Error("INVALID_DOTENV_KEY: Missing environment part");
|
|
1737
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
1738
|
+
throw err;
|
|
1739
|
+
}
|
|
1740
|
+
const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
|
|
1741
|
+
const ciphertext = result.parsed[environmentKey];
|
|
1742
|
+
if (!ciphertext) {
|
|
1743
|
+
const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
|
|
1744
|
+
err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
|
|
1745
|
+
throw err;
|
|
1746
|
+
}
|
|
1747
|
+
return { ciphertext, key };
|
|
32
1748
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
1749
|
+
function _vaultPath(options) {
|
|
1750
|
+
let possibleVaultPath = null;
|
|
1751
|
+
if (options && options.path && options.path.length > 0) {
|
|
1752
|
+
if (Array.isArray(options.path)) {
|
|
1753
|
+
for (const filepath of options.path) {
|
|
1754
|
+
if (fs.existsSync(filepath)) {
|
|
1755
|
+
possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
|
|
1756
|
+
}
|
|
1757
|
+
}
|
|
1758
|
+
} else {
|
|
1759
|
+
possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
|
|
1760
|
+
}
|
|
1761
|
+
} else {
|
|
1762
|
+
possibleVaultPath = path.resolve(process.cwd(), ".env.vault");
|
|
40
1763
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return unsafeStringify(rnds);
|
|
1764
|
+
if (fs.existsSync(possibleVaultPath)) {
|
|
1765
|
+
return possibleVaultPath;
|
|
1766
|
+
}
|
|
1767
|
+
return null;
|
|
46
1768
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
1769
|
+
function _resolveHome(envPath) {
|
|
1770
|
+
return envPath[0] === "~" ? path.join(os.homedir(), envPath.slice(1)) : envPath;
|
|
1771
|
+
}
|
|
1772
|
+
function _configVault(options) {
|
|
1773
|
+
_log("Loading env from encrypted .env.vault");
|
|
1774
|
+
const parsed = DotenvModule._parseVault(options);
|
|
1775
|
+
let processEnv = process.env;
|
|
1776
|
+
if (options && options.processEnv != null) {
|
|
1777
|
+
processEnv = options.processEnv;
|
|
1778
|
+
}
|
|
1779
|
+
DotenvModule.populate(processEnv, parsed, options);
|
|
1780
|
+
return { parsed };
|
|
1781
|
+
}
|
|
1782
|
+
function configDotenv(options) {
|
|
1783
|
+
const dotenvPath = path.resolve(process.cwd(), ".env");
|
|
1784
|
+
let encoding = "utf8";
|
|
1785
|
+
const debug = Boolean(options && options.debug);
|
|
1786
|
+
if (options && options.encoding) {
|
|
1787
|
+
encoding = options.encoding;
|
|
1788
|
+
} else {
|
|
1789
|
+
if (debug) {
|
|
1790
|
+
_debug("No encoding is specified. UTF-8 is used by default");
|
|
1791
|
+
}
|
|
1792
|
+
}
|
|
1793
|
+
let optionPaths = [dotenvPath];
|
|
1794
|
+
if (options && options.path) {
|
|
1795
|
+
if (!Array.isArray(options.path)) {
|
|
1796
|
+
optionPaths = [_resolveHome(options.path)];
|
|
1797
|
+
} else {
|
|
1798
|
+
optionPaths = [];
|
|
1799
|
+
for (const filepath of options.path) {
|
|
1800
|
+
optionPaths.push(_resolveHome(filepath));
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
let lastError;
|
|
1805
|
+
const parsedAll = {};
|
|
1806
|
+
for (const path2 of optionPaths) {
|
|
1807
|
+
try {
|
|
1808
|
+
const parsed = DotenvModule.parse(fs.readFileSync(path2, { encoding }));
|
|
1809
|
+
DotenvModule.populate(parsedAll, parsed, options);
|
|
1810
|
+
} catch (e) {
|
|
1811
|
+
if (debug) {
|
|
1812
|
+
_debug(`Failed to load ${path2} ${e.message}`);
|
|
1813
|
+
}
|
|
1814
|
+
lastError = e;
|
|
1815
|
+
}
|
|
1816
|
+
}
|
|
1817
|
+
let processEnv = process.env;
|
|
1818
|
+
if (options && options.processEnv != null) {
|
|
1819
|
+
processEnv = options.processEnv;
|
|
1820
|
+
}
|
|
1821
|
+
DotenvModule.populate(processEnv, parsedAll, options);
|
|
1822
|
+
if (lastError) {
|
|
1823
|
+
return { parsed: parsedAll, error: lastError };
|
|
1824
|
+
} else {
|
|
1825
|
+
return { parsed: parsedAll };
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1828
|
+
function config(options) {
|
|
1829
|
+
if (_dotenvKey(options).length === 0) {
|
|
1830
|
+
return DotenvModule.configDotenv(options);
|
|
1831
|
+
}
|
|
1832
|
+
const vaultPath = _vaultPath(options);
|
|
1833
|
+
if (!vaultPath) {
|
|
1834
|
+
_warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
|
|
1835
|
+
return DotenvModule.configDotenv(options);
|
|
1836
|
+
}
|
|
1837
|
+
return DotenvModule._configVault(options);
|
|
1838
|
+
}
|
|
1839
|
+
function decrypt(encrypted, keyStr) {
|
|
1840
|
+
const key = Buffer.from(keyStr.slice(-64), "hex");
|
|
1841
|
+
let ciphertext = Buffer.from(encrypted, "base64");
|
|
1842
|
+
const nonce = ciphertext.subarray(0, 12);
|
|
1843
|
+
const authTag = ciphertext.subarray(-16);
|
|
1844
|
+
ciphertext = ciphertext.subarray(12, -16);
|
|
1845
|
+
try {
|
|
1846
|
+
const aesgcm = crypto$1.createDecipheriv("aes-256-gcm", key, nonce);
|
|
1847
|
+
aesgcm.setAuthTag(authTag);
|
|
1848
|
+
return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
|
|
1849
|
+
} catch (error) {
|
|
1850
|
+
const isRange = error instanceof RangeError;
|
|
1851
|
+
const invalidKeyLength = error.message === "Invalid key length";
|
|
1852
|
+
const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
|
|
1853
|
+
if (isRange || invalidKeyLength) {
|
|
1854
|
+
const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
|
|
1855
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
1856
|
+
throw err;
|
|
1857
|
+
} else if (decryptionFailed) {
|
|
1858
|
+
const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
|
|
1859
|
+
err.code = "DECRYPTION_FAILED";
|
|
1860
|
+
throw err;
|
|
1861
|
+
} else {
|
|
1862
|
+
throw error;
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1866
|
+
function populate(processEnv, parsed, options = {}) {
|
|
1867
|
+
const debug = Boolean(options && options.debug);
|
|
1868
|
+
const override = Boolean(options && options.override);
|
|
1869
|
+
if (typeof parsed !== "object") {
|
|
1870
|
+
const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
|
|
1871
|
+
err.code = "OBJECT_REQUIRED";
|
|
1872
|
+
throw err;
|
|
1873
|
+
}
|
|
1874
|
+
for (const key of Object.keys(parsed)) {
|
|
1875
|
+
if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
|
|
1876
|
+
if (override === true) {
|
|
1877
|
+
processEnv[key] = parsed[key];
|
|
1878
|
+
}
|
|
1879
|
+
if (debug) {
|
|
1880
|
+
if (override === true) {
|
|
1881
|
+
_debug(`"${key}" is already defined and WAS overwritten`);
|
|
1882
|
+
} else {
|
|
1883
|
+
_debug(`"${key}" is already defined and was NOT overwritten`);
|
|
1884
|
+
}
|
|
1885
|
+
}
|
|
1886
|
+
} else {
|
|
1887
|
+
processEnv[key] = parsed[key];
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
50
1890
|
}
|
|
1891
|
+
const DotenvModule = {
|
|
1892
|
+
configDotenv,
|
|
1893
|
+
_configVault,
|
|
1894
|
+
_parseVault,
|
|
1895
|
+
config,
|
|
1896
|
+
decrypt,
|
|
1897
|
+
parse,
|
|
1898
|
+
populate
|
|
1899
|
+
};
|
|
1900
|
+
main$1.exports.configDotenv = DotenvModule.configDotenv;
|
|
1901
|
+
main$1.exports._configVault = DotenvModule._configVault;
|
|
1902
|
+
main$1.exports._parseVault = DotenvModule._parseVault;
|
|
1903
|
+
var config_1 = main$1.exports.config = DotenvModule.config;
|
|
1904
|
+
main$1.exports.decrypt = DotenvModule.decrypt;
|
|
1905
|
+
main$1.exports.parse = DotenvModule.parse;
|
|
1906
|
+
main$1.exports.populate = DotenvModule.populate;
|
|
1907
|
+
main$1.exports = DotenvModule;
|
|
1908
|
+
var __typeError2 = (msg) => {
|
|
1909
|
+
throw TypeError(msg);
|
|
1910
|
+
};
|
|
1911
|
+
var __accessCheck2 = (obj, member, msg) => member.has(obj) || __typeError2("Cannot " + msg);
|
|
1912
|
+
var __privateGet2 = (obj, member, getter) => (__accessCheck2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
1913
|
+
var __privateAdd2 = (obj, member, value) => member.has(obj) ? __typeError2("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1914
|
+
var __privateSet2 = (obj, member, value, setter) => (__accessCheck2(obj, member, "write to private field"), member.set(obj, value), value);
|
|
1915
|
+
var __privateWrapper = (obj, member, setter, getter) => ({
|
|
1916
|
+
set _(value) {
|
|
1917
|
+
__privateSet2(obj, member, value);
|
|
1918
|
+
},
|
|
1919
|
+
get _() {
|
|
1920
|
+
return __privateGet2(obj, member, getter);
|
|
1921
|
+
}
|
|
1922
|
+
});
|
|
1923
|
+
var _options, _httpAgent, _httpsAgent, _agentResetInterval, _requestCount, _SetupResetInterval, _GetAgentOptions, _url, _method, _headers, _data, _agentManager, _timeout, _withCredentials;
|
|
51
1924
|
var ansiStyles$1 = { exports: {} };
|
|
52
1925
|
var colorName;
|
|
53
1926
|
var hasRequiredColorName;
|
|
@@ -922,15 +2795,15 @@ function requireRoute() {
|
|
|
922
2795
|
};
|
|
923
2796
|
}
|
|
924
2797
|
function wrapConversion(toModel, graph) {
|
|
925
|
-
const
|
|
2798
|
+
const path2 = [graph[toModel].parent, toModel];
|
|
926
2799
|
let fn = conversions2[graph[toModel].parent][toModel];
|
|
927
2800
|
let cur = graph[toModel].parent;
|
|
928
2801
|
while (graph[cur].parent) {
|
|
929
|
-
|
|
2802
|
+
path2.unshift(graph[cur].parent);
|
|
930
2803
|
fn = link(conversions2[graph[cur].parent][cur], fn);
|
|
931
2804
|
cur = graph[cur].parent;
|
|
932
2805
|
}
|
|
933
|
-
fn.conversion =
|
|
2806
|
+
fn.conversion = path2;
|
|
934
2807
|
return fn;
|
|
935
2808
|
}
|
|
936
2809
|
route = function(fromModel) {
|
|
@@ -1050,11 +2923,11 @@ ansiStyles$1.exports;
|
|
|
1050
2923
|
const offset = isBackground ? 10 : 0;
|
|
1051
2924
|
const styles2 = {};
|
|
1052
2925
|
for (const [sourceSpace, suite] of Object.entries(colorConvert2)) {
|
|
1053
|
-
const
|
|
2926
|
+
const name2 = sourceSpace === "ansi16" ? "ansi" : sourceSpace;
|
|
1054
2927
|
if (sourceSpace === targetSpace) {
|
|
1055
|
-
styles2[
|
|
2928
|
+
styles2[name2] = wrap(identity, offset);
|
|
1056
2929
|
} else if (typeof suite === "object") {
|
|
1057
|
-
styles2[
|
|
2930
|
+
styles2[name2] = wrap(suite[targetSpace], offset);
|
|
1058
2931
|
}
|
|
1059
2932
|
}
|
|
1060
2933
|
return styles2;
|
|
@@ -1218,7 +3091,7 @@ function requireTemplates() {
|
|
|
1218
3091
|
}
|
|
1219
3092
|
return ESCAPES.get(c) || c;
|
|
1220
3093
|
}
|
|
1221
|
-
function parseArguments(
|
|
3094
|
+
function parseArguments(name2, arguments_) {
|
|
1222
3095
|
const results = [];
|
|
1223
3096
|
const chunks = arguments_.trim().split(/\s*,\s*/g);
|
|
1224
3097
|
let matches;
|
|
@@ -1229,7 +3102,7 @@ function requireTemplates() {
|
|
|
1229
3102
|
} else if (matches = chunk.match(STRING_REGEX)) {
|
|
1230
3103
|
results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape(escape) : character));
|
|
1231
3104
|
} else {
|
|
1232
|
-
throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${
|
|
3105
|
+
throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name2}')`);
|
|
1233
3106
|
}
|
|
1234
3107
|
}
|
|
1235
3108
|
return results;
|
|
@@ -1239,12 +3112,12 @@ function requireTemplates() {
|
|
|
1239
3112
|
const results = [];
|
|
1240
3113
|
let matches;
|
|
1241
3114
|
while ((matches = STYLE_REGEX.exec(style)) !== null) {
|
|
1242
|
-
const
|
|
3115
|
+
const name2 = matches[1];
|
|
1243
3116
|
if (matches[2]) {
|
|
1244
|
-
const args = parseArguments(
|
|
1245
|
-
results.push([
|
|
3117
|
+
const args = parseArguments(name2, matches[2]);
|
|
3118
|
+
results.push([name2].concat(args));
|
|
1246
3119
|
} else {
|
|
1247
|
-
results.push([
|
|
3120
|
+
results.push([name2]);
|
|
1248
3121
|
}
|
|
1249
3122
|
}
|
|
1250
3123
|
return results;
|
|
@@ -1321,7 +3194,7 @@ const applyOptions = (object, options = {}) => {
|
|
|
1321
3194
|
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
|
1322
3195
|
object.level = options.level === void 0 ? colorLevel : options.level;
|
|
1323
3196
|
};
|
|
1324
|
-
class
|
|
3197
|
+
class ChalkClass2 {
|
|
1325
3198
|
constructor(options) {
|
|
1326
3199
|
return chalkFactory(options);
|
|
1327
3200
|
}
|
|
@@ -1335,7 +3208,7 @@ const chalkFactory = (options) => {
|
|
|
1335
3208
|
chalk2.template.constructor = () => {
|
|
1336
3209
|
throw new Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.");
|
|
1337
3210
|
};
|
|
1338
|
-
chalk2.template.Instance =
|
|
3211
|
+
chalk2.template.Instance = ChalkClass2;
|
|
1339
3212
|
return chalk2.template;
|
|
1340
3213
|
};
|
|
1341
3214
|
function Chalk(options) {
|
|
@@ -1470,76 +3343,438 @@ const chalk = Chalk();
|
|
|
1470
3343
|
chalk.supportsColor = stdoutColor;
|
|
1471
3344
|
chalk.stderr = Chalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
1472
3345
|
chalk.stderr.supportsColor = stderrColor;
|
|
1473
|
-
|
|
1474
|
-
const
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
3346
|
+
const { accessSync, constants, readFileSync } = fs$1;
|
|
3347
|
+
const envOptions = {};
|
|
3348
|
+
function SetupConfig(envOptions2, logger) {
|
|
3349
|
+
const envfile = process.env.STSENVFILE === void 0 ? "/.env" : process.env.STSENVFILE;
|
|
3350
|
+
config_1({ path: envfile });
|
|
3351
|
+
const defconfig = {
|
|
3352
|
+
// Node runtime environment
|
|
3353
|
+
isProduction: process.env.NODE_ENV === void 0 ? false : process.env.NODE_ENV === "production" ? true : false,
|
|
3354
|
+
isTest: process.env.NODE_ENV === void 0 ? false : process.env.NODE_ENV === "test" ? true : false,
|
|
3355
|
+
dbuser: process.env.DB_USER === void 0 ? "postgres" : process.env.DB_USER,
|
|
3356
|
+
dbpassword: process.env.DB_PASSWORD === void 0 ? "postgres" : process.env.DB_PASSWORD,
|
|
3357
|
+
dbpasswordfile: process.env.DB_PASSWORD_FILE,
|
|
3358
|
+
dbhost: process.env.DB_HOST === void 0 ? "localhost:5432" : process.env.DB_HOST,
|
|
3359
|
+
database: process.env.DB_DATABASE === void 0 ? "stsrestmsdb01" : process.env.DB_DATABASE,
|
|
3360
|
+
databaseUrl: process.env.DATABASE_URL,
|
|
3361
|
+
connectionString: "",
|
|
3362
|
+
defaultDatabaseConnectionString: "",
|
|
3363
|
+
STSServerType: process.env.STS_SERVER_TYPE === void 0 ? "EXPRESS_TLS" : process.env.STS_SERVER_TYPE,
|
|
3364
|
+
logToFile: process.env.LOG_TO_FILE === void 0 ? false : process.env.LOG_TO_FILE === "true" ? true : false,
|
|
3365
|
+
logFilePath: process.env.LOG_FILE_PATH === void 0 ? "/var/lib/sts" : process.env.LOG_FILE_PATH,
|
|
3366
|
+
logFileFormat: process.env.LOG_FILE_FORMAT === void 0 ? "csv" : process.env.LOG_FILE_FORMAT,
|
|
3367
|
+
poolSize: process.env.POOL_SIZE === void 0 ? 500 : parseInt(process.env.POOL_SIZE),
|
|
3368
|
+
useCPUs: process.env.MAX_CPU === void 0 ? -1 : parseFloat(process.env.MAX_CPU),
|
|
3369
|
+
respawnOnFail: process.env.RESPAWN === void 0 ? true : process.env.RESPAWN === "true" ? true : false,
|
|
3370
|
+
defaultDatabaseEntries: process.env.DEFAULT_DB_ENTRIES === void 0 ? 1e4 : parseInt(process.env.DEFAULT_DB_ENTRIES),
|
|
3371
|
+
useRedisDatabaseCache: process.env.USE_REDIS_DATABASE_CACHE === void 0 ? false : process.env.USE_REDIS_DATABASE_CACHE === "true" ? true : false,
|
|
3372
|
+
useSocketIoRedisAdaptor: process.env.USE_SOCKET_IO_REDIS_ADAPTOR === void 0 ? false : process.env.USE_SOCKET_IO_REDIS_ADAPTOR === "true" ? true : false,
|
|
3373
|
+
socketIoRedisAdaptorUrl: process.env.SOCKET_IO_REDIS_ADAPTOR_URL === void 0 ? "redis://localhost:6379" : process.env.SOCKET_IO_REDIS_ADAPTOR_URL,
|
|
3374
|
+
useRedisInstrumentationTransport: process.env.USE_REDIS_INSTRUMENTATION_TRANSPORT === void 0 ? false : process.env.USE_REDIS_INSTRUMENTATION_TRANSPORT === "true" ? true : false,
|
|
3375
|
+
redisInstrumentationTransportUrl: process.env.REDIS_INSTRUMENTATION_TRANSPORT_URL === void 0 ? "redis://localhost:6379" : process.env.REDIS_INSTRUMENTATION_TRANSPORT_URL,
|
|
3376
|
+
redisDatabaseCacheEndFlush: process.env.REDIS_DATABASE_CACHE_END_FLUSH === void 0 ? false : process.env.REDIS_DATABASE_CACHE_END_FLUSH === "true" ? true : false,
|
|
3377
|
+
redisDatabaseCacheUrl: process.env.REDIS_DATABASE_CACHE_URL === void 0 ? "redis://localhost:6379" : process.env.REDIS_DATABASE_CACHE_URL,
|
|
3378
|
+
defaultDatabaseMinExtraDataSize: process.env.DEFAULT_DATABASE_MIN_EXTRA_DATA_SIZE === void 0 ? 0 : parseInt(process.env.DEFAULT_DATABASE_MIN_EXTRA_DATA_SIZE),
|
|
3379
|
+
defaultDatabaseMaxExtraDataSize: process.env.DEFAULT_DATABASE_MAX_EXTRA_DATA_SIZE === void 0 ? 2e3 : parseInt(process.env.DEFAULT_DATABASE_MAX_EXTRA_DATA_SIZE),
|
|
3380
|
+
rest01endpoint: process.env.REST01_ENDPOINT === void 0 ? "https://localhost" : process.env.REST01_ENDPOINT,
|
|
3381
|
+
rest01hostport: process.env.REST01_HOST_PORT === void 0 ? "3003" : process.env.REST01_HOST_PORT,
|
|
3382
|
+
rest01port: process.env.REST01_PORT === void 0 ? "3003" : process.env.REST01_PORT,
|
|
3383
|
+
rest01apiroot: process.env.REST01_APIROOT === void 0 ? "/stsrest01/v1" : process.env.REST01_APIROOT,
|
|
3384
|
+
rest01prometheussupport: process.env.REST01_PROM_SUPPORT === void 0 ? true : process.env.REST01_PROM_SUPPORT === "true" ? true : false,
|
|
3385
|
+
rest01prometheusclusterport: process.env.REST01_PROM_CLUSTER_PORT === void 0 ? "3013" : process.env.REST01_PROM_CLUSTER_PORT,
|
|
3386
|
+
rest01servicename: process.env.REST01_SERVICE_NAME === void 0 ? "STSRest01" : process.env.REST01_SERVICE_NAME,
|
|
3387
|
+
rest01serviceversion: process.env.REST01_SERVICE_VERSION === void 0 ? "1.0.0" : process.env.REST01_SERVICE_VERSION,
|
|
3388
|
+
stsfhirendpoint: process.env.STSFHIR_ENDPOINT === void 0 ? "https://localhost" : process.env.STSFHIR_ENDPOINT,
|
|
3389
|
+
stsfhirhostport: process.env.STSFHIR_HOST_PORT === void 0 ? "3005" : process.env.STSFHIR_HOST_PORT,
|
|
3390
|
+
stsfhirport: process.env.STSFHIR_PORT === void 0 ? "3005" : process.env.STSFHIR_PORT,
|
|
3391
|
+
stsfhirapiroot: process.env.STSFHIR_APIROOT === void 0 ? "/stsfhir/r5" : process.env.STSFHIR_APIROOT,
|
|
3392
|
+
stsfhirprometheussupport: process.env.STSFHIR_PROM_SUPPORT === void 0 ? true : process.env.STSFHIR_PROM_SUPPORT === "true" ? true : false,
|
|
3393
|
+
stsfhirprometheusclusterport: process.env.STSFHIR_PROM_CLUSTER_PORT === void 0 ? "3015" : process.env.STSFHIR_PROM_CLUSTER_PORT,
|
|
3394
|
+
stsfhirservicename: process.env.STSFHIR_SERVICE_NAME === void 0 ? "STSFHIR" : process.env.STSFHIR_SERVICE_NAME,
|
|
3395
|
+
stsfhirserviceversion: process.env.STSFHIR_SERVICE_VERSION === void 0 ? "1.0.0" : process.env.STSFHIR_SERVICE_VERSION,
|
|
3396
|
+
imendpoint: process.env.IM_ENDPOINT === void 0 ? "https://localhost" : process.env.IM_ENDPOINT,
|
|
3397
|
+
imhostport: process.env.IM_HOST_PORT === void 0 ? "3001" : process.env.IM_HOST_PORT,
|
|
3398
|
+
import: process.env.IM_PORT === void 0 ? "3001" : process.env.IM_PORT,
|
|
3399
|
+
imapiroot: process.env.IM_APIROOT === void 0 ? "/stsinstrumentmanager/v1" : process.env.IM_APIROOT,
|
|
3400
|
+
imprometheussupport: process.env.IM_PROM_SUPPORT === void 0 ? true : process.env.IM_PROM_SUPPORT === "true" ? true : false,
|
|
3401
|
+
imprometheusclusterport: process.env.IM_PROM_CLUSTER_PORT === void 0 ? "3011" : process.env.IM_PROM_CLUSTER_PORT,
|
|
3402
|
+
imservicename: process.env.IM_SERVICE_NAME === void 0 ? "STSInstrumentManager" : process.env.IM_SERVICE_NAME,
|
|
3403
|
+
imserviceversion: process.env.IM_SERVICE_VERSION === void 0 ? "1.0.0" : process.env.IM_SERVICE_VERSION,
|
|
3404
|
+
imRedisKeepAliveProcessorUrl: process.env.IM_REDIS_KEEP_ALIVE_PROCESSOR_URL === void 0 ? "redis://localhost:6379" : process.env.IM_REDIS_KEEP_ALIVE_PROCESSOR_URL,
|
|
3405
|
+
imRedisMessageProcessorUrl: process.env.IM_REDIS_MESSAGE_PROCESSOR_URL === void 0 ? "redis://localhost:6379" : process.env.IM_REDIS_MESSAGE_PROCESSOR_URL,
|
|
3406
|
+
asendpoint: process.env.AS_ENDPOINT === void 0 ? "https://localhost" : process.env.AS_ENDPOINT,
|
|
3407
|
+
ashostport: process.env.AS_HOST_PORT === void 0 ? "3002" : process.env.AS_HOST_PORT,
|
|
3408
|
+
asport: process.env.AS_PORT === void 0 ? "3002" : process.env.AS_PORT,
|
|
3409
|
+
asapiroot: process.env.AS_API_ROOT === void 0 ? "/stsauth/v1.0" : process.env.AS_API_ROOT,
|
|
3410
|
+
asoauthapiroot: process.env.AS_OAUTH_API_ROOT === void 0 ? "/oauth2/v2.0" : process.env.AS_OAUTH_API_ROOT,
|
|
3411
|
+
asadminapiroot: process.env.AS_ADMIN_API_ROOT === void 0 ? "/admin/v1.0" : process.env.AS_ADMIN_API_ROOT,
|
|
3412
|
+
asprometheussupport: process.env.AS_PROM_SUPPORT === void 0 ? true : process.env.AS_PROM_SUPPORT === "true" ? true : false,
|
|
3413
|
+
asprometheusclusterport: process.env.AS_PROM_CLUSTER_PORT === void 0 ? "3012" : process.env.AS_PROM_CLUSTER_PORT,
|
|
3414
|
+
asservicename: process.env.AS_SERVICE_NAME === void 0 ? "STSAuth" : process.env.AS_SERVICE_NAME,
|
|
3415
|
+
asserviceversion: process.env.AS_SERVICE_VERSION === void 0 ? "1.0.0" : process.env.AS_SERVICE_VERSION,
|
|
3416
|
+
asjwksjsonpath: process.env.AS_JWKS_JSON_PATH === void 0 ? "/.well-known/jwks.json" : process.env.AS_JWKS_JSON_PATH,
|
|
3417
|
+
asjwkskeyrotationtime: process.env.AS_JWKS_KEY_ROTATION_TIME === void 0 ? 86400 : parseInt(process.env.AS_JWKS_KEY_ROTATION_TIME),
|
|
3418
|
+
asjwkskeypurgetimeoffset: process.env.AS_JWKS_KEY_PURGE_TIME_OFFSET === void 0 ? 300 : parseInt(process.env.AS_JWKS_KEY_PURGE_TIME_OFFSET),
|
|
3419
|
+
asjwkskeycount: process.env.AS_JWKS_KEY_COUNT === void 0 ? 4 : parseInt(process.env.AS_JWKS_KEY_COUNT),
|
|
3420
|
+
asaccesstokenexpire: process.env.AS_ACCESS_TOKEN_EXPIRE === void 0 ? 43200 : parseInt(process.env.AS_ACCESS_TOKEN_EXPIRE),
|
|
3421
|
+
authorizeendpoint: process.env.AUTHORIZE_ENDPOINT === void 0 ? "https://localhost" : process.env.AUTHORIZE_ENDPOINT,
|
|
3422
|
+
authorizeport: process.env.AUTHORIZE_PORT === void 0 ? "3010" : process.env.AUTHORIZE_PORT,
|
|
3423
|
+
authorizeapiroot: process.env.AUTHORIZE_API_ROOT === void 0 ? "/stsa" : process.env.AUTHORIZE_API_ROOT,
|
|
3424
|
+
authorizeapi: process.env.AUTHORIZE_API === void 0 ? "/authorize" : process.env.AUTHORIZE_API,
|
|
3425
|
+
brokerendpoint: process.env.BROKER_ENDPOINT === void 0 ? "https://localhost" : process.env.BROKER_ENDPOINT,
|
|
3426
|
+
brokerhostport: process.env.BROKER_HOST_PORT === void 0 ? "3006" : process.env.BROKER_HOST_PORT,
|
|
3427
|
+
brokerport: process.env.BROKER_PORT === void 0 ? "3006" : process.env.BROKER_PORT,
|
|
3428
|
+
brokerapiroot: process.env.BROKER_APIROOT === void 0 ? "/stsbroker/v1.0" : process.env.BROKER_APIROOT,
|
|
3429
|
+
brokerprometheussupport: process.env.BROKER_PROM_SUPPORT === void 0 ? true : process.env.BROKER_PROM_SUPPORT === "true" ? true : false,
|
|
3430
|
+
brokerprometheusclusterport: process.env.BROKER_PROM_CLUSTER_PORT === void 0 ? "3016" : process.env.BROKER_PROM_CLUSTER_PORT,
|
|
3431
|
+
brokerservicename: process.env.BROKER_SERVICE_NAME === void 0 ? "STSBroker" : process.env.BROKER_SERVICE_NAME,
|
|
3432
|
+
brokerserviceversion: process.env.BROKER_SERVICE_VERSION === void 0 ? "1.0.0" : process.env.BROKER_SERVICE_VERSION,
|
|
3433
|
+
trnendpoint: process.env.TRN_ENDPOINT === void 0 ? "https://localhost" : process.env.TRN_ENDPOINT,
|
|
3434
|
+
trnhostport: process.env.TRN_HOST_PORT === void 0 ? "3007" : process.env.TRN_HOST_PORT,
|
|
3435
|
+
trnport: process.env.TRN_PORT === void 0 ? "3007" : process.env.TRN_PORT,
|
|
3436
|
+
trnapiroot: process.env.TRN_APIROOT === void 0 ? "/ststrn/v1.0" : process.env.TRN_APIROOT,
|
|
3437
|
+
trnprometheussupport: process.env.TRN_PROM_SUPPORT === void 0 ? true : process.env.TRN_PROM_SUPPORT === "true" ? true : false,
|
|
3438
|
+
trnprometheusclusterport: process.env.TRN_PROM_CLUSTER_PORT === void 0 ? "3017" : process.env.TRN_PROM_CLUSTER_PORT,
|
|
3439
|
+
trnservicename: process.env.TRN_SERVICE_NAME === void 0 ? "STSTestRunnerNode" : process.env.TRN_SERVICE_NAME,
|
|
3440
|
+
trnserviceversion: process.env.TRN_SERVICE_VERSION === void 0 ? "1.0.0" : process.env.TRN_SERVICE_VERSION,
|
|
3441
|
+
trnautostartdelay: process.env.TRN_AUTO_START_DELAY === void 0 ? 0 : parseInt(process.env.TRN_AUTO_START_DELAY),
|
|
3442
|
+
trnautostartconfig: process.env.TRN_AUTO_START_CONFIG === void 0 ? "" : process.env.TRN_AUTO_START_CONFIG,
|
|
3443
|
+
trnRedisMessageProcessorUrl: process.env.TRN_REDIS_MESSAGE_PROCESSOR_URL === void 0 ? "redis://localhost:6379" : process.env.TRN_REDIS_MESSAGE_PROCESSOR_URL,
|
|
3444
|
+
lambdaendpoint: process.env.LAMBDA_ENDPOINT === void 0 ? "https://localhost" : process.env.LAMBDA_ENDPOINT,
|
|
3445
|
+
lambdahostport: process.env.LAMBDA_HOST_PORT === void 0 ? "3009" : process.env.LAMBDA_HOST_PORT,
|
|
3446
|
+
lambdaport: process.env.LAMBDA_PORT === void 0 ? "3009" : process.env.LAMBDA_PORT,
|
|
3447
|
+
lambdaapiroot: process.env.LAMBDA_APIROOT === void 0 ? "/stslambda/v1.0" : process.env.LAMBDA_APIROOT,
|
|
3448
|
+
lambdaprometheussupport: process.env.LAMBDA_PROM_SUPPORT === void 0 ? true : process.env.LAMBDA_PROM_SUPPORT === "true" ? true : false,
|
|
3449
|
+
lambdaprometheusclusterport: process.env.LAMBDA_PROM_CLUSTER_PORT === void 0 ? "3019" : process.env.LAMBDA_PROM_CLUSTER_PORT,
|
|
3450
|
+
lambdaservicename: process.env.LAMBDA_SERVICE_NAME === void 0 ? "STSLambda" : process.env.LAMBDA_SERVICE_NAME,
|
|
3451
|
+
lambdaserviceversion: process.env.LAMBDA_SERVICE_VERSION === void 0 ? "1.0.0" : process.env.LAMBDA_SERVICE_VERSION,
|
|
3452
|
+
publishinterval: process.env.PUBLISH_INTERVAL === void 0 ? 1e3 : parseInt(process.env.PUBLISH_INTERVAL),
|
|
3453
|
+
publishtimeout: process.env.PUBLISH_TIMEOUT === void 0 ? 750 : parseInt(process.env.PUBLISH_TIMEOUT),
|
|
3454
|
+
transport: process.env.TRANSPORT === void 0 ? "RESTAPI" : process.env.TRANSPORT,
|
|
3455
|
+
useSecureCookies: process.env.USE_SECURE_COOKIES === void 0 ? false : process.env.USE_SECURE_COOKIES === "true" ? true : false,
|
|
3456
|
+
keepAlive: process.env.KEEP_ALIVE === void 0 ? true : process.env.KEEP_ALIVE === "true" ? true : false,
|
|
3457
|
+
maxSockets: process.env.MAX_SOCKETS === void 0 ? 10 : parseInt(process.env.MAX_SOCKETS),
|
|
3458
|
+
maxTotalSockets: process.env.MAX_TOTAL_SOCKETS === void 0 ? 20 : parseInt(process.env.MAX_TOTAL_SOCKETS),
|
|
3459
|
+
maxFreeSockets: process.env.MAX_FREE_SOCKETS === void 0 ? 256 : parseInt(process.env.MAX_FREE_SOCKETS),
|
|
3460
|
+
timeout: process.env.TIMEOUT === void 0 ? 1e4 : parseInt(process.env.TIMEOUT),
|
|
3461
|
+
maxPayloadSize: process.env.MAX_PAYLOAD_SIZE === void 0 ? "50mb" : process.env.MAX_PAYLOAD_SIZE,
|
|
3462
|
+
instrumentationObservationInterval: process.env.INSTRUMENTATION_OBSERVATION_INTERVAL === void 0 ? 1e3 : parseInt(process.env.INSTRUMENTATION_OBSERVATION_INTERVAL),
|
|
3463
|
+
instrumentationTimeWindow: process.env.INSTRUMENTATION_TIME_WINDOW === void 0 ? 600 : parseInt(process.env.INSTRUMENTATION_TIME_WINDOW),
|
|
3464
|
+
authJWTAccessTokenTimeout: process.env.AUTH_JWT_ACCESS_TOKEN_TIMEOUT === void 0 ? 600 : parseInt(process.env.AUTH_JWT_ACCESS_TOKEN_TIMEOUT),
|
|
3465
|
+
authJWTRefreshTokenTimeout: process.env.AUTH_JWT_REFRESH_TOKEN_TIMEOUT === void 0 ? 3600 * 24 : parseInt(process.env.AUTH_JWT_REFRESH_TOKEN_TIMEOUT),
|
|
3466
|
+
authCookieTimeout: process.env.AUTH_COOKIE_TIMEOUT === void 0 ? 3600 * 24 : parseInt(process.env.AUTH_COOKIE_TIMEOUT),
|
|
3467
|
+
masterProcessExitTime: process.env.MASTER_PROCESS_EXIT_TIME === void 0 ? 500 : parseInt(process.env.MASTER_PROCESS_EXIT_TIME),
|
|
3468
|
+
childProcessExitTime: process.env.CHILD_PROCESS_EXIT_TIME === void 0 ? 500 : parseInt(process.env.CHILD_PROCESS_EXIT_TIME),
|
|
3469
|
+
systemInformationInterval: process.env.SYSTEM_INFORMATION_INTERVAL === void 0 ? 1e3 : parseInt(process.env.SYSTEM_INFORMATION_INTERVAL),
|
|
3470
|
+
ignoresocketio: process.env.IGNORE_SOCKETIO === void 0 ? true : process.env.IGNORE_SOCKETIO === "true" ? true : false,
|
|
3471
|
+
httpsserverkeypath: process.env.HTTPS_SERVER_KEY_PATH === void 0 ? "/var/lib/sts/stsglobalresources/keys/server.key" : process.env.HTTPS_SERVER_KEY_PATH,
|
|
3472
|
+
httpsservercertpath: process.env.HTTPS_SERVER_CERT_PATH === void 0 ? "/var/lib/sts/stsglobalresources/keys/server.cert" : process.env.HTTPS_SERVER_CERT_PATH,
|
|
3473
|
+
tsjwkskeys: process.env.TS_JWKS_KEYS === void 0 ? 3 : parseInt(process.env.TS_JWKS_KEYS),
|
|
3474
|
+
jwksAuthConfigCache: process.env.JWKS_AUTH_CONFIG_CACHE === void 0 ? true : process.env.JWKS_AUTH_CONFIG_CACHE === "true" ? true : false,
|
|
3475
|
+
jwksAuthConfigCacheMaxEntries: process.env.JWKS_AUTH_CONFIG_CACHE_MAX_ENTRIES === void 0 ? 5 : parseInt(process.env.JWKS_AUTH_CONFIG_CACHE_MAX_ENTRIES),
|
|
3476
|
+
jwksAuthConfigCacheMaxAge: process.env.JWKS_AUTH_CONFIG_CACHE_MAX_AGE === void 0 ? 6e5 : parseInt(process.env.JWKS_AUTH_CONFIG_CACHE_MAX_AGE),
|
|
3477
|
+
jwksAuthConfigRateLimit: process.env.JWKS_AUTH_CONFIG_RATE_LIMIT === void 0 ? true : process.env.JWKS_AUTH_CONFIG_RATE_LIMIT === "true" ? true : false,
|
|
3478
|
+
jwksAuthConfigRateLimitRequestsPerMinute: process.env.JWKS_AUTH_CONFIG_RATE_LIMIT_REQUESTS_PER_MINUTE === void 0 ? 10 : parseInt(process.env.JWKS_AUTH_CONFIG_RATE_LIMIT_REQUESTS_PER_MINUTE),
|
|
3479
|
+
jwksAuthConfigTimeout: process.env.JWKS_AUTH_CONFIG_TIMEOUT === void 0 ? 3e4 : parseInt(process.env.JWKS_AUTH_CONFIG_TIMEOUT),
|
|
3480
|
+
influxDB_APIToken: process.env.INFLUXDB_API_TOKEN === void 0 ? "password" : process.env.INFLUXDB_API_TOKEN,
|
|
3481
|
+
influxDB_APITokenFile: process.env.INFLUXDB_API_TOKEN_FILE,
|
|
3482
|
+
influxDB_Url: process.env.INFLUXDB_URL === void 0 ? "http://localhost:8086" : process.env.INFLUXDB_URL,
|
|
3483
|
+
influxDB_Org: process.env.INFLUXDB_ORG === void 0 ? "my-org" : process.env.INFLUXDB_ORG,
|
|
3484
|
+
influxDB_Bucket: process.env.INFLUXDB_BUCKET === void 0 ? "TestBucket01" : process.env.INFLUXDB_BUCKET,
|
|
3485
|
+
influxDB_keepAlive: process.env.INFLUXDB_KEEP_ALIVE === void 0 ? true : process.env.INFLUXDB_KEEP_ALIVE === "true" ? true : false,
|
|
3486
|
+
influxDB_maxSockets: process.env.INFLUXDB_MAX_SOCKETS === void 0 ? 10 : parseInt(process.env.INFLUXDB_MAX_SOCKETS),
|
|
3487
|
+
influxDB_maxTotalSockets: process.env.INFLUXDB_MAX_TOTAL_SOCKETS === void 0 ? 20 : parseInt(process.env.INFLUXDB_MAX_TOTAL_SOCKETS),
|
|
3488
|
+
influxDB_maxFreeSockets: process.env.INFLUXDB_MAX_FREE_SOCKETS === void 0 ? 256 : parseInt(process.env.INFLUXDB_MAX_FREE_SOCKETS),
|
|
3489
|
+
influxDB_timeout: process.env.INFLUXDB_TIMEOUT === void 0 ? 1e4 : parseInt(process.env.INFLUXDB_TIMEOUT),
|
|
3490
|
+
influxDB_rejectUnauthorized: process.env.INFLUXDB_REJECT_UNAUTHORIZED === void 0 ? true : process.env.INFLUXDB_REJECT_UNAUTHORIZED === "true" ? true : false,
|
|
3491
|
+
influxDB_writeDataPointFlushTimeout: process.env.INFLUXDB_WRITE_DATA_POINT_FLUSH_TIMEOUT === void 0 ? 1e3 : parseInt(process.env.INFLUXDB_WRITE_DATA_POINT_FLUSH_TIMEOUT),
|
|
3492
|
+
kafka_clientId: process.env.KAFKA_CLIENT_ID === void 0 ? "myclient" : process.env.KAFKA_CLIENT_ID,
|
|
3493
|
+
kafka_brokers: process.env.KAFKA_BROKERS === void 0 ? "localhost:9092" : process.env.KAFKA_BROKERS,
|
|
3494
|
+
kafka_admin_timeout: process.env.KAFKA_ADMIN_TIMEOUT === void 0 ? 5e3 : parseInt(process.env.KAFKA_ADMIN_TIMEOUT),
|
|
3495
|
+
kafka_connection_timeout: process.env.KAFKA_CONNECTION_TIMEOUT === void 0 ? 5e3 : parseInt(process.env.KAFKA_CONNECTION_TIMEOUT),
|
|
3496
|
+
kafka_request_timeout: process.env.KAFKA_REQUEST_TIMEOUT === void 0 ? 5e3 : parseInt(process.env.KAFKA_REQUEST_TIMEOUT),
|
|
3497
|
+
kafka_log_level: process.env.KAFKA_LOG_LEVEL === void 0 ? "nothing" : process.env.KAFKA_LOG_LEVEL,
|
|
3498
|
+
kafka_keep_alive: process.env.KAFKA_KEEP_ALIVE === void 0 ? 3e4 : parseInt(process.env.KAFKA_KEEP_ALIVE),
|
|
3499
|
+
kafka_use_ssl: process.env.KAFKA_USE_SSL === void 0 ? false : process.env.KAFKA_USE_SSL === "true" ? true : false,
|
|
3500
|
+
kafka_ssl_rejectUnauthorized: process.env.KAFKA_SSL_REJECT_UNAUTHORIZED === void 0 ? true : process.env.KAFKA_SSL_REJECT_UNAUTHORIZED === "true" ? true : false,
|
|
3501
|
+
kafka_ssl_cafile: process.env.KAFKA_SSL_CAFILE === void 0 ? "/my/custom/ca.crt" : process.env.KAFKA_SSL_CAFILE,
|
|
3502
|
+
kafka_ssl_keyfile: process.env.KAFKA_SSL_KEYFILE === void 0 ? "/my/custom/client-key.pem" : process.env.KAFKA_SSL_KEYFILE,
|
|
3503
|
+
kafka_ssl_certfile: process.env.KAFKA_SSL_CERTFILE === void 0 ? "/my/custom/client-cert.pem" : process.env.KAFKA_SSL_CERTFILE,
|
|
3504
|
+
kafka_consume_from_beginning: process.env.KAFKA_CONSUME_FROM_BEGINNING === void 0 ? true : process.env.KAFKA_CONSUME_FROM_BEGINNING === "true" ? true : false,
|
|
3505
|
+
observabilityPublishMode: process.env.OBSERVABILITY_PUBLISH_MODE === void 0 ? "PROXY" : process.env.OBSERVABILITY_PUBLISH_MODE,
|
|
3506
|
+
stsUiTermObservabilityConsumptionMode: process.env.STSUITERM_OBSERVABILITY_CONSUMPTION_MODE === void 0 ? "PROXY" : process.env.STSUITERM_OBSERVABILITY_CONSUMPTION_MODE
|
|
3507
|
+
};
|
|
3508
|
+
const ReadFile = (passwordFile) => {
|
|
3509
|
+
try {
|
|
3510
|
+
accessSync(passwordFile, constants.R_OK);
|
|
3511
|
+
const data = readFileSync(passwordFile, "utf8");
|
|
3512
|
+
if (logger) ;
|
|
3513
|
+
return data;
|
|
3514
|
+
} catch (err) {
|
|
3515
|
+
return "";
|
|
3516
|
+
}
|
|
3517
|
+
};
|
|
3518
|
+
const fileconfig = [
|
|
3519
|
+
{ fileprop: "dbpasswordfile", prop: "dbpassword" },
|
|
3520
|
+
// JWKS secret file processing
|
|
3521
|
+
{ fileprop: "tsjwksstorepathfile", prop: "tsjwksstorepath" },
|
|
3522
|
+
// InfluxDB file processing
|
|
3523
|
+
{ fileprop: "influxDB_APITokenFile", prop: "influxDB_APIToken" }
|
|
3524
|
+
];
|
|
3525
|
+
fileconfig.forEach((v) => {
|
|
3526
|
+
if (defconfig[v.fileprop] !== void 0) {
|
|
3527
|
+
defconfig[v.prop] = ReadFile(defconfig[v.fileprop]);
|
|
3528
|
+
}
|
|
3529
|
+
});
|
|
3530
|
+
for (const [key, val] of Object.entries(defconfig)) {
|
|
3531
|
+
envOptions2[key] = val;
|
|
3532
|
+
}
|
|
3533
|
+
}
|
|
3534
|
+
function $SetupOptions(envOptions2) {
|
|
3535
|
+
SetupConfig(envOptions2);
|
|
3536
|
+
const options = envOptions2;
|
|
3537
|
+
if (options.dbhost) {
|
|
3538
|
+
const hosts = options.dbhost.split(",");
|
|
3539
|
+
envOptions2.connectionString = hosts.map((host) => {
|
|
3540
|
+
return `postgresql://${options.dbuser}:${options.dbpassword}@${host}/${options.database}`;
|
|
3541
|
+
}).join(",");
|
|
3542
|
+
envOptions2.defaultDatabaseConnectionString = hosts.map((host) => {
|
|
3543
|
+
return `postgresql://${options.dbuser}:${options.dbpassword}@${host}/postgres`;
|
|
3544
|
+
}).join(",");
|
|
3545
|
+
}
|
|
3546
|
+
}
|
|
3547
|
+
const envOptionsHandler = {
|
|
3548
|
+
get(target, prop, receiver) {
|
|
3549
|
+
if (Object.keys(target).length === 0) {
|
|
3550
|
+
$SetupOptions(target);
|
|
3551
|
+
}
|
|
3552
|
+
return Reflect.get(target, prop, receiver);
|
|
3553
|
+
}
|
|
3554
|
+
};
|
|
3555
|
+
const goptions = new Proxy(envOptions, envOptionsHandler);
|
|
3556
|
+
class AgentManager {
|
|
3557
|
+
constructor(agentManagerOptions) {
|
|
3558
|
+
__privateAdd2(this, _options);
|
|
3559
|
+
__privateAdd2(this, _httpAgent, null);
|
|
3560
|
+
__privateAdd2(this, _httpsAgent, null);
|
|
3561
|
+
__privateAdd2(this, _agentResetInterval, null);
|
|
3562
|
+
__privateAdd2(this, _requestCount, 0);
|
|
3563
|
+
__privateAdd2(this, _SetupResetInterval, () => {
|
|
3564
|
+
if (__privateGet2(this, _options).agentResetInterval && __privateGet2(this, _options).agentResetInterval > 0) {
|
|
3565
|
+
__privateSet2(this, _agentResetInterval, setTimeout(() => {
|
|
3566
|
+
this.ResetAgent();
|
|
3567
|
+
__privateGet2(this, _SetupResetInterval).call(this);
|
|
3568
|
+
}, __privateGet2(this, _options).agentResetInterval).unref());
|
|
3569
|
+
}
|
|
3570
|
+
});
|
|
3571
|
+
__privateAdd2(this, _GetAgentOptions, (https2) => {
|
|
3572
|
+
let options;
|
|
3573
|
+
if (__privateGet2(this, _options).agentOptions) {
|
|
3574
|
+
options = {
|
|
3575
|
+
keepAlive: __privateGet2(this, _options).agentOptions.keepAlive,
|
|
3576
|
+
maxSockets: __privateGet2(this, _options).agentOptions.maxSockets,
|
|
3577
|
+
maxTotalSockets: __privateGet2(this, _options).agentOptions.maxTotalSockets,
|
|
3578
|
+
maxFreeSockets: __privateGet2(this, _options).agentOptions.maxFreeSockets,
|
|
3579
|
+
timeout: __privateGet2(this, _options).agentOptions.timeout
|
|
3580
|
+
//@@ config
|
|
3581
|
+
};
|
|
3582
|
+
if (https2 === true) {
|
|
3583
|
+
options.rejectUnauthorized = __privateGet2(this, _options).agentOptions.rejectUnauthorized;
|
|
3584
|
+
}
|
|
3585
|
+
} else {
|
|
3586
|
+
options = {
|
|
3587
|
+
keepAlive: process.env.NODE_ENV === "test" ? false : goptions.keepAlive,
|
|
3588
|
+
maxSockets: goptions.maxSockets,
|
|
3589
|
+
maxTotalSockets: goptions.maxTotalSockets,
|
|
3590
|
+
maxFreeSockets: goptions.maxFreeSockets,
|
|
3591
|
+
timeout: 3e4
|
|
3592
|
+
//@@ config
|
|
3593
|
+
};
|
|
3594
|
+
if (https2 === true) {
|
|
3595
|
+
options.rejectUnauthorized = goptions.isProduction;
|
|
3596
|
+
}
|
|
3597
|
+
}
|
|
3598
|
+
return options;
|
|
3599
|
+
});
|
|
3600
|
+
__privateSet2(this, _options, agentManagerOptions);
|
|
3601
|
+
if (__privateGet2(this, _options).agentResetInterval) {
|
|
3602
|
+
__privateGet2(this, _SetupResetInterval).call(this);
|
|
3603
|
+
}
|
|
3604
|
+
}
|
|
3605
|
+
get agentResetInterval() {
|
|
3606
|
+
return __privateGet2(this, _options).agentResetInterval;
|
|
3607
|
+
}
|
|
3608
|
+
set agentResetInterval(val) {
|
|
3609
|
+
if (__privateGet2(this, _agentResetInterval)) {
|
|
3610
|
+
clearTimeout(__privateGet2(this, _agentResetInterval));
|
|
3611
|
+
}
|
|
3612
|
+
__privateGet2(this, _options).agentResetInterval = val;
|
|
3613
|
+
__privateGet2(this, _SetupResetInterval).call(this);
|
|
3614
|
+
}
|
|
3615
|
+
get agentResetCount() {
|
|
3616
|
+
return __privateGet2(this, _options).agentResetCount;
|
|
3617
|
+
}
|
|
3618
|
+
set agentResetCount(val) {
|
|
3619
|
+
__privateGet2(this, _options).agentResetCount = val;
|
|
3620
|
+
}
|
|
3621
|
+
IncRequestCount() {
|
|
3622
|
+
__privateWrapper(this, _requestCount)._++;
|
|
3623
|
+
if (__privateGet2(this, _options).agentResetCount) {
|
|
3624
|
+
if (__privateGet2(this, _requestCount) % __privateGet2(this, _options).agentResetCount === 0) {
|
|
3625
|
+
this.ResetAgent();
|
|
3626
|
+
}
|
|
3627
|
+
}
|
|
3628
|
+
}
|
|
3629
|
+
IsHttps(protocol) {
|
|
3630
|
+
if (protocol.toLowerCase().startsWith("https:")) {
|
|
3631
|
+
return true;
|
|
3632
|
+
}
|
|
3633
|
+
return false;
|
|
3634
|
+
}
|
|
3635
|
+
GetAgent(protocol) {
|
|
3636
|
+
if (protocol.toLowerCase().startsWith("https:")) {
|
|
3637
|
+
if (__privateGet2(this, _httpsAgent) === null) {
|
|
3638
|
+
__privateSet2(this, _httpsAgent, new https.Agent(__privateGet2(this, _GetAgentOptions).call(this, true)));
|
|
3639
|
+
}
|
|
3640
|
+
return __privateGet2(this, _httpsAgent);
|
|
3641
|
+
} else if (protocol.toLowerCase().startsWith("http:")) {
|
|
3642
|
+
if (__privateGet2(this, _httpAgent) === null) {
|
|
3643
|
+
__privateSet2(this, _httpAgent, new http.Agent(__privateGet2(this, _GetAgentOptions).call(this, false)));
|
|
3644
|
+
}
|
|
3645
|
+
return __privateGet2(this, _httpAgent);
|
|
3646
|
+
} else {
|
|
3647
|
+
return null;
|
|
3648
|
+
}
|
|
3649
|
+
}
|
|
3650
|
+
ResetAgent() {
|
|
3651
|
+
__privateSet2(this, _httpAgent, null);
|
|
3652
|
+
__privateSet2(this, _httpsAgent, null);
|
|
3653
|
+
}
|
|
3654
|
+
/*
|
|
3655
|
+
url
|
|
3656
|
+
,method: 'post'
|
|
3657
|
+
,data: payload
|
|
3658
|
+
,headers: headers
|
|
3659
|
+
,httpsAgent: this.#agentManager.GetAgent(url)
|
|
3660
|
+
*/
|
|
3661
|
+
/*
|
|
3662
|
+
postgresContainer = await new GenericContainer("postgres")
|
|
3663
|
+
.withExposedPorts(5432)
|
|
3664
|
+
.withEnvironment({
|
|
3665
|
+
POSTGRES_PASSWORD: "postgres",
|
|
3666
|
+
//UV_THREADPOOL_SIZE: "64"
|
|
3667
|
+
})
|
|
3668
|
+
.withCommand(['-c', 'max_connections=20'])
|
|
3669
|
+
.start();
|
|
3670
|
+
*/
|
|
3671
|
+
Terminate() {
|
|
3672
|
+
if (__privateGet2(this, _agentResetInterval)) {
|
|
3673
|
+
clearTimeout(__privateGet2(this, _agentResetInterval));
|
|
3674
|
+
__privateSet2(this, _agentResetInterval, null);
|
|
3675
|
+
}
|
|
3676
|
+
if (__privateGet2(this, _httpAgent)) {
|
|
3677
|
+
__privateGet2(this, _httpAgent).destroy();
|
|
3678
|
+
__privateSet2(this, _httpAgent, null);
|
|
3679
|
+
}
|
|
3680
|
+
if (__privateGet2(this, _httpsAgent)) {
|
|
3681
|
+
__privateGet2(this, _httpsAgent).destroy();
|
|
3682
|
+
__privateSet2(this, _httpsAgent, null);
|
|
3683
|
+
}
|
|
3684
|
+
}
|
|
3685
|
+
}
|
|
3686
|
+
_options = /* @__PURE__ */ new WeakMap();
|
|
3687
|
+
_httpAgent = /* @__PURE__ */ new WeakMap();
|
|
3688
|
+
_httpsAgent = /* @__PURE__ */ new WeakMap();
|
|
3689
|
+
_agentResetInterval = /* @__PURE__ */ new WeakMap();
|
|
3690
|
+
_requestCount = /* @__PURE__ */ new WeakMap();
|
|
3691
|
+
_SetupResetInterval = /* @__PURE__ */ new WeakMap();
|
|
3692
|
+
_GetAgentOptions = /* @__PURE__ */ new WeakMap();
|
|
3693
|
+
class STSAxiosConfig {
|
|
3694
|
+
constructor(url, method, headers, timeout) {
|
|
3695
|
+
__privateAdd2(this, _url);
|
|
3696
|
+
__privateAdd2(this, _method);
|
|
3697
|
+
__privateAdd2(this, _headers);
|
|
3698
|
+
__privateAdd2(this, _data);
|
|
3699
|
+
__privateAdd2(this, _agentManager);
|
|
3700
|
+
__privateAdd2(this, _timeout);
|
|
3701
|
+
__privateAdd2(this, _withCredentials);
|
|
3702
|
+
__privateSet2(this, _url, url);
|
|
3703
|
+
__privateSet2(this, _method, method);
|
|
3704
|
+
if (headers !== void 0) {
|
|
3705
|
+
__privateSet2(this, _headers, headers);
|
|
3706
|
+
}
|
|
3707
|
+
if (timeout !== void 0) {
|
|
3708
|
+
__privateSet2(this, _timeout, timeout);
|
|
3709
|
+
}
|
|
3710
|
+
}
|
|
3711
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3712
|
+
withData(data) {
|
|
3713
|
+
__privateSet2(this, _data, data);
|
|
3714
|
+
return this;
|
|
3715
|
+
}
|
|
3716
|
+
// 'Content-Type': 'application/json'
|
|
3717
|
+
withHeaders(headers) {
|
|
3718
|
+
__privateSet2(this, _headers, headers);
|
|
3719
|
+
return this;
|
|
3720
|
+
}
|
|
3721
|
+
withDefaultHeaders() {
|
|
3722
|
+
__privateSet2(this, _headers, {
|
|
3723
|
+
"Content-Type": "application/json"
|
|
3724
|
+
});
|
|
3725
|
+
return this;
|
|
3726
|
+
}
|
|
3727
|
+
withCredentials() {
|
|
3728
|
+
__privateSet2(this, _withCredentials, true);
|
|
3729
|
+
return this;
|
|
3730
|
+
}
|
|
3731
|
+
withTimeout(timeout) {
|
|
3732
|
+
__privateSet2(this, _timeout, timeout);
|
|
3733
|
+
return this;
|
|
3734
|
+
}
|
|
3735
|
+
withAgentManager(agentManager) {
|
|
3736
|
+
__privateSet2(this, _agentManager, agentManager);
|
|
3737
|
+
return this;
|
|
3738
|
+
}
|
|
3739
|
+
get config() {
|
|
3740
|
+
const retVal = {
|
|
3741
|
+
url: __privateGet2(this, _url),
|
|
3742
|
+
method: __privateGet2(this, _method)
|
|
3743
|
+
};
|
|
3744
|
+
if (__privateGet2(this, _headers)) {
|
|
3745
|
+
retVal.headers = __privateGet2(this, _headers);
|
|
3746
|
+
}
|
|
3747
|
+
if (__privateGet2(this, _agentManager) !== void 0) {
|
|
3748
|
+
if (__privateGet2(this, _agentManager).IsHttps(__privateGet2(this, _url))) {
|
|
3749
|
+
retVal.httpsAgent = __privateGet2(this, _agentManager).GetAgent(__privateGet2(this, _url));
|
|
3750
|
+
} else {
|
|
3751
|
+
retVal.httpAgent = __privateGet2(this, _agentManager).GetAgent(__privateGet2(this, _url));
|
|
3752
|
+
}
|
|
3753
|
+
}
|
|
3754
|
+
if (__privateGet2(this, _data) !== void 0) {
|
|
3755
|
+
retVal.data = __privateGet2(this, _data);
|
|
3756
|
+
}
|
|
3757
|
+
if (__privateGet2(this, _timeout) !== void 0) {
|
|
3758
|
+
retVal.timeout = __privateGet2(this, _timeout);
|
|
3759
|
+
}
|
|
3760
|
+
if (__privateGet2(this, _withCredentials) !== void 0 && __privateGet2(this, _withCredentials) === true) {
|
|
3761
|
+
retVal.withCredentials = true;
|
|
3762
|
+
}
|
|
3763
|
+
return retVal;
|
|
3764
|
+
}
|
|
3765
|
+
}
|
|
3766
|
+
_url = /* @__PURE__ */ new WeakMap();
|
|
3767
|
+
_method = /* @__PURE__ */ new WeakMap();
|
|
3768
|
+
_headers = /* @__PURE__ */ new WeakMap();
|
|
3769
|
+
_data = /* @__PURE__ */ new WeakMap();
|
|
3770
|
+
_agentManager = /* @__PURE__ */ new WeakMap();
|
|
3771
|
+
_timeout = /* @__PURE__ */ new WeakMap();
|
|
3772
|
+
_withCredentials = /* @__PURE__ */ new WeakMap();
|
|
1536
3773
|
class FhirClient {
|
|
1537
|
-
// Default value
|
|
1538
3774
|
constructor(options) {
|
|
1539
|
-
__privateAdd(this,
|
|
3775
|
+
__privateAdd(this, _options2);
|
|
1540
3776
|
__privateAdd(this, _DUMMY_USER, "USR_user01@stsmda.com.au");
|
|
1541
3777
|
//@@ needs to come from headers ??
|
|
1542
|
-
__privateAdd(this, _httpsAgent, null);
|
|
1543
3778
|
__privateAdd(this, _invokeMethods, {});
|
|
1544
3779
|
__privateAdd(this, _maxRetries, 5);
|
|
1545
3780
|
__privateAdd(this, _sleepDuration, [50, 100, 200, 500, 1e3, 2e3, 5e3]);
|
|
@@ -1548,55 +3783,40 @@ class FhirClient {
|
|
|
1548
3783
|
StatusCodes.CONFLICT
|
|
1549
3784
|
]);
|
|
1550
3785
|
__privateAdd(this, _stsfhirapiroot, "/stsfhir/r5");
|
|
3786
|
+
// Default value
|
|
3787
|
+
__privateAdd(this, _agentManager2, null);
|
|
1551
3788
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1552
3789
|
__privateAdd(this, _LogDebugMessage, (message) => {
|
|
1553
|
-
__privateGet(this,
|
|
3790
|
+
__privateGet(this, _options2).logger.debug(message);
|
|
1554
3791
|
});
|
|
1555
3792
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1556
3793
|
__privateAdd(this, _LogErrorMessage, (message) => {
|
|
1557
|
-
__privateGet(this,
|
|
1558
|
-
});
|
|
1559
|
-
__privateAdd(this, _GetHttpsAgent, () => {
|
|
1560
|
-
if (__privateGet(this, _httpsAgent) === null) {
|
|
1561
|
-
if (__privateGet(this, _options).agentOptions) {
|
|
1562
|
-
__privateSet(this, _httpsAgent, new https.Agent({
|
|
1563
|
-
keepAlive: __privateGet(this, _options).agentOptions.keepAlive,
|
|
1564
|
-
maxSockets: __privateGet(this, _options).agentOptions.maxSockets,
|
|
1565
|
-
maxTotalSockets: __privateGet(this, _options).agentOptions.maxTotalSockets,
|
|
1566
|
-
maxFreeSockets: __privateGet(this, _options).agentOptions.maxFreeSockets,
|
|
1567
|
-
timeout: __privateGet(this, _options).agentOptions.timeout,
|
|
1568
|
-
rejectUnauthorized: __privateGet(this, _options).agentOptions.rejectUnauthorized
|
|
1569
|
-
}));
|
|
1570
|
-
} else {
|
|
1571
|
-
__privateSet(this, _httpsAgent, new https.Agent());
|
|
1572
|
-
}
|
|
1573
|
-
}
|
|
1574
|
-
return __privateGet(this, _httpsAgent);
|
|
3794
|
+
__privateGet(this, _options2).logger.error(message);
|
|
1575
3795
|
});
|
|
1576
3796
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1577
3797
|
__privateAdd(this, _HandleError, (error) => {
|
|
1578
|
-
__privateGet(this, _LogDebugMessage).call(this, chalk$
|
|
3798
|
+
__privateGet(this, _LogDebugMessage).call(this, chalk$2.red(`HandleError(): Error: [${error}]`));
|
|
1579
3799
|
let responseCode = 500;
|
|
1580
3800
|
if (axios.isAxiosError(error)) {
|
|
1581
3801
|
const axiosError = error;
|
|
1582
3802
|
if (axiosError.response) {
|
|
1583
3803
|
responseCode = axiosError.response.status;
|
|
1584
|
-
__privateGet(this, _LogDebugMessage).call(this, chalk$
|
|
3804
|
+
__privateGet(this, _LogDebugMessage).call(this, chalk$2.red(`AXIOS Error Response.Status = [${axiosError.response.status}]`));
|
|
1585
3805
|
if (axiosError.response.headers) {
|
|
1586
|
-
__privateGet(this, _LogErrorMessage).call(this, chalk$
|
|
3806
|
+
__privateGet(this, _LogErrorMessage).call(this, chalk$2.red(` headers: [${JSON.stringify(axiosError.response.headers)}]`));
|
|
1587
3807
|
}
|
|
1588
3808
|
if (axiosError.response.data) {
|
|
1589
|
-
__privateGet(this, _LogErrorMessage).call(this, chalk$
|
|
3809
|
+
__privateGet(this, _LogErrorMessage).call(this, chalk$2.red(` data: [${JSON.stringify(axiosError.response.data)}]`));
|
|
1590
3810
|
}
|
|
1591
3811
|
try {
|
|
1592
3812
|
if (axiosError.response.config) {
|
|
1593
|
-
__privateGet(this, _LogErrorMessage).call(this, chalk$
|
|
3813
|
+
__privateGet(this, _LogErrorMessage).call(this, chalk$2.red(` config: [${JSON.stringify(axiosError.response.config)}]`));
|
|
1594
3814
|
}
|
|
1595
3815
|
} catch (innererror) {
|
|
1596
|
-
__privateGet(this, _LogErrorMessage).call(this, chalk$
|
|
3816
|
+
__privateGet(this, _LogErrorMessage).call(this, chalk$2.red(` could not get response config, error: [${innererror}]`));
|
|
1597
3817
|
}
|
|
1598
3818
|
} else {
|
|
1599
|
-
__privateGet(this, _LogDebugMessage).call(this, chalk$
|
|
3819
|
+
__privateGet(this, _LogDebugMessage).call(this, chalk$2.red(`AXIOS Error = [${axiosError}]`));
|
|
1600
3820
|
}
|
|
1601
3821
|
}
|
|
1602
3822
|
return responseCode;
|
|
@@ -1617,19 +3837,19 @@ class FhirClient {
|
|
|
1617
3837
|
const metadataRecord = __privateGet(this, _invokeMethods)[id2];
|
|
1618
3838
|
let performRetry = false;
|
|
1619
3839
|
const returnData = await __privateGet(this, ___InvokeResourceAPI).call(this, metadataRecord, (statusCode, error) => {
|
|
1620
|
-
console.error(chalk$
|
|
3840
|
+
console.error(chalk$2.red(`#InvokeResourceAPI(): Error: [${error}], Attempt: [${metadataRecord.retries + 1}]`));
|
|
1621
3841
|
const noRetryIndex = __privateGet(this, _NoRetryStatusCodes).indexOf(statusCode);
|
|
1622
3842
|
if (noRetryIndex === -1) {
|
|
1623
3843
|
if (statusCode === StatusCodes.UNAUTHORIZED) {
|
|
1624
|
-
console.error(chalk$
|
|
1625
|
-
__privateGet(this,
|
|
1626
|
-
if (__privateGet(this,
|
|
1627
|
-
__privateGet(this,
|
|
3844
|
+
console.error(chalk$2.red(`#InvokeResourceAPI(): Authentication error, resetting access_token (to null).`));
|
|
3845
|
+
__privateGet(this, _options2).ResetAccessToken();
|
|
3846
|
+
if (__privateGet(this, _options2).clientTelemetryEvents) {
|
|
3847
|
+
__privateGet(this, _options2).clientTelemetryEvents.AuthenticationErrorInc();
|
|
1628
3848
|
}
|
|
1629
3849
|
}
|
|
1630
|
-
if (isNode) {
|
|
1631
|
-
console.error(chalk$
|
|
1632
|
-
|
|
3850
|
+
if (isNode && __privateGet(this, _agentManager2)) {
|
|
3851
|
+
console.error(chalk$2.red(`#InvokeResourceAPI(): Resetting https agent (to null).`));
|
|
3852
|
+
__privateGet(this, _agentManager2).ResetAgent();
|
|
1633
3853
|
}
|
|
1634
3854
|
performRetry = true;
|
|
1635
3855
|
}
|
|
@@ -1650,8 +3870,8 @@ class FhirClient {
|
|
|
1650
3870
|
console.log(`Sleeping: [${__privateGet(this, _sleepDuration)[__privateGet(this, _invokeMethods)[id].retries]}]`);
|
|
1651
3871
|
await Sleep(__privateGet(this, _sleepDuration)[__privateGet(this, _invokeMethods)[id].retries]);
|
|
1652
3872
|
__privateGet(this, _invokeMethods)[id].retries++;
|
|
1653
|
-
if (__privateGet(this,
|
|
1654
|
-
__privateGet(this,
|
|
3873
|
+
if (__privateGet(this, _options2).clientTelemetryEvents) {
|
|
3874
|
+
__privateGet(this, _options2).clientTelemetryEvents.RetryInc();
|
|
1655
3875
|
}
|
|
1656
3876
|
}
|
|
1657
3877
|
}
|
|
@@ -1682,32 +3902,21 @@ class FhirClient {
|
|
|
1682
3902
|
__privateAdd(this, ___InvokeResourceAPI, async (metaData, errorCb) => {
|
|
1683
3903
|
try {
|
|
1684
3904
|
const { url, httpVerb, domainResource, filters } = metaData;
|
|
1685
|
-
if (__privateGet(this,
|
|
3905
|
+
if (__privateGet(this, _options2).testingMode) {
|
|
1686
3906
|
if (__privateGet(this, _TestMode).call(this, metaData, errorCb)) {
|
|
1687
3907
|
return null;
|
|
1688
3908
|
}
|
|
1689
3909
|
}
|
|
1690
|
-
const accessToken = await __privateGet(this,
|
|
1691
|
-
const
|
|
3910
|
+
const accessToken = await __privateGet(this, _options2).GetAccessToken();
|
|
3911
|
+
const requestConfig = new STSAxiosConfig(url, httpVerb).withHeaders({
|
|
1692
3912
|
"Content-Type": "application/json",
|
|
1693
3913
|
"Authorization": `Bearer ${accessToken}`,
|
|
1694
3914
|
"x-sts_user_id": __privateGet(this, _DUMMY_USER)
|
|
1695
|
-
};
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
method: httpVerb,
|
|
1699
|
-
headers
|
|
1700
|
-
};
|
|
1701
|
-
if (isNode) {
|
|
1702
|
-
requestConfig.httpsAgent = __privateGet(this, _GetHttpsAgent).call(this);
|
|
1703
|
-
}
|
|
1704
|
-
if (filters) {
|
|
1705
|
-
requestConfig.data = filters;
|
|
1706
|
-
} else if (domainResource) {
|
|
1707
|
-
requestConfig.data = domainResource;
|
|
3915
|
+
}).withData(filters ? filters : domainResource ? domainResource : void 0);
|
|
3916
|
+
if (isNode && __privateGet(this, _agentManager2)) {
|
|
3917
|
+
requestConfig.withAgentManager(__privateGet(this, _agentManager2));
|
|
1708
3918
|
}
|
|
1709
|
-
|
|
1710
|
-
return retVal;
|
|
3919
|
+
return await axios(requestConfig.config);
|
|
1711
3920
|
} catch (error) {
|
|
1712
3921
|
const responseCode = __privateGet(this, _HandleError).call(this, error);
|
|
1713
3922
|
errorCb(responseCode, error);
|
|
@@ -1715,7 +3924,7 @@ class FhirClient {
|
|
|
1715
3924
|
}
|
|
1716
3925
|
});
|
|
1717
3926
|
__publicField(this, "GetResource", async (resource, id, filters, errorCb) => {
|
|
1718
|
-
const url = `${__privateGet(this,
|
|
3927
|
+
const url = `${__privateGet(this, _options2).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}/${id}`;
|
|
1719
3928
|
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "get", null, filters, errorCb);
|
|
1720
3929
|
if (response) {
|
|
1721
3930
|
return response.data;
|
|
@@ -1724,7 +3933,7 @@ class FhirClient {
|
|
|
1724
3933
|
}
|
|
1725
3934
|
});
|
|
1726
3935
|
__publicField(this, "GetResources", async (resource, filters, errorCb) => {
|
|
1727
|
-
const url = `${__privateGet(this,
|
|
3936
|
+
const url = `${__privateGet(this, _options2).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
|
|
1728
3937
|
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "get", null, filters, errorCb);
|
|
1729
3938
|
if (response) {
|
|
1730
3939
|
return response.data;
|
|
@@ -1733,7 +3942,7 @@ class FhirClient {
|
|
|
1733
3942
|
}
|
|
1734
3943
|
});
|
|
1735
3944
|
__publicField(this, "CreateResource", async (resource, domainResource, errorCb) => {
|
|
1736
|
-
const url = `${__privateGet(this,
|
|
3945
|
+
const url = `${__privateGet(this, _options2).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
|
|
1737
3946
|
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "post", domainResource, null, errorCb);
|
|
1738
3947
|
if (response) {
|
|
1739
3948
|
if (response.status === StatusCodes.CREATED) {
|
|
@@ -1747,7 +3956,7 @@ class FhirClient {
|
|
|
1747
3956
|
}
|
|
1748
3957
|
});
|
|
1749
3958
|
__publicField(this, "UpdateResource", async (resource, domainResource, errorCb) => {
|
|
1750
|
-
const url = `${__privateGet(this,
|
|
3959
|
+
const url = `${__privateGet(this, _options2).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}/${domainResource.id}`;
|
|
1751
3960
|
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "put", domainResource, null, errorCb);
|
|
1752
3961
|
if (response) {
|
|
1753
3962
|
return response.data;
|
|
@@ -1756,7 +3965,7 @@ class FhirClient {
|
|
|
1756
3965
|
}
|
|
1757
3966
|
});
|
|
1758
3967
|
__publicField(this, "UpdateResources", async (resource, domainResources, errorCb) => {
|
|
1759
|
-
const url = `${__privateGet(this,
|
|
3968
|
+
const url = `${__privateGet(this, _options2).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
|
|
1760
3969
|
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "put", domainResources, null, errorCb);
|
|
1761
3970
|
if (response) {
|
|
1762
3971
|
return response.data;
|
|
@@ -1765,7 +3974,7 @@ class FhirClient {
|
|
|
1765
3974
|
}
|
|
1766
3975
|
});
|
|
1767
3976
|
__publicField(this, "PatchResource", async (resource, domainResource, errorCb) => {
|
|
1768
|
-
const url = `${__privateGet(this,
|
|
3977
|
+
const url = `${__privateGet(this, _options2).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}/${domainResource.id}`;
|
|
1769
3978
|
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "patch", domainResource, null, errorCb);
|
|
1770
3979
|
if (response) {
|
|
1771
3980
|
return response.data;
|
|
@@ -1774,7 +3983,7 @@ class FhirClient {
|
|
|
1774
3983
|
}
|
|
1775
3984
|
});
|
|
1776
3985
|
__publicField(this, "PatchResources", async (resource, domainResources, errorCb) => {
|
|
1777
|
-
const url = `${__privateGet(this,
|
|
3986
|
+
const url = `${__privateGet(this, _options2).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
|
|
1778
3987
|
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "patch", domainResources, null, errorCb);
|
|
1779
3988
|
if (response) {
|
|
1780
3989
|
return response.data;
|
|
@@ -1783,7 +3992,7 @@ class FhirClient {
|
|
|
1783
3992
|
}
|
|
1784
3993
|
});
|
|
1785
3994
|
__publicField(this, "DeleteResource", async (resource, id, errorCb) => {
|
|
1786
|
-
const url = `${__privateGet(this,
|
|
3995
|
+
const url = `${__privateGet(this, _options2).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}/${id}`;
|
|
1787
3996
|
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "delete", null, null, errorCb);
|
|
1788
3997
|
if (response) {
|
|
1789
3998
|
return response.data;
|
|
@@ -1792,7 +4001,7 @@ class FhirClient {
|
|
|
1792
4001
|
}
|
|
1793
4002
|
});
|
|
1794
4003
|
__publicField(this, "DeleteResources", async (resource, domainResources, errorCb) => {
|
|
1795
|
-
const url = `${__privateGet(this,
|
|
4004
|
+
const url = `${__privateGet(this, _options2).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
|
|
1796
4005
|
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "delete", domainResources, null, errorCb);
|
|
1797
4006
|
if (response) {
|
|
1798
4007
|
return response.data;
|
|
@@ -1801,45 +4010,47 @@ class FhirClient {
|
|
|
1801
4010
|
}
|
|
1802
4011
|
});
|
|
1803
4012
|
__publicField(this, "GetLatency", async () => {
|
|
1804
|
-
const url = `${__privateGet(this,
|
|
4013
|
+
const url = `${__privateGet(this, _options2).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/latency`;
|
|
1805
4014
|
try {
|
|
1806
|
-
const
|
|
4015
|
+
const requestConfig = new STSAxiosConfig(url, "get", {
|
|
1807
4016
|
"Content-Type": "application/json"
|
|
1808
|
-
};
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
method: "get",
|
|
1812
|
-
headers
|
|
1813
|
-
};
|
|
1814
|
-
if (isNode) {
|
|
1815
|
-
requestConfig.httpsAgent = __privateGet(this, _GetHttpsAgent).call(this);
|
|
4017
|
+
});
|
|
4018
|
+
if (isNode && __privateGet(this, _agentManager2)) {
|
|
4019
|
+
requestConfig.withAgentManager(__privateGet(this, _agentManager2));
|
|
1816
4020
|
}
|
|
1817
|
-
|
|
1818
|
-
return retVal;
|
|
4021
|
+
return await axios(requestConfig.config);
|
|
1819
4022
|
} catch (error) {
|
|
1820
4023
|
__privateGet(this, _HandleError).call(this, error);
|
|
1821
4024
|
}
|
|
1822
4025
|
});
|
|
1823
|
-
__privateSet(this,
|
|
1824
|
-
if (__privateGet(this,
|
|
1825
|
-
__privateSet(this, _stsfhirapiroot, __privateGet(this,
|
|
4026
|
+
__privateSet(this, _options2, options);
|
|
4027
|
+
if (__privateGet(this, _options2).stsfhirapiroot !== void 0) {
|
|
4028
|
+
__privateSet(this, _stsfhirapiroot, __privateGet(this, _options2).stsfhirapiroot);
|
|
4029
|
+
}
|
|
4030
|
+
if (isNode) {
|
|
4031
|
+
if (__privateGet(this, _options2).agentOptions) {
|
|
4032
|
+
__privateSet(this, _agentManager2, new AgentManager({
|
|
4033
|
+
agentOptions: __privateGet(this, _options2).agentOptions
|
|
4034
|
+
}));
|
|
4035
|
+
} else {
|
|
4036
|
+
__privateSet(this, _agentManager2, new AgentManager({}));
|
|
4037
|
+
}
|
|
1826
4038
|
}
|
|
1827
4039
|
}
|
|
1828
4040
|
get options() {
|
|
1829
|
-
return __privateGet(this,
|
|
4041
|
+
return __privateGet(this, _options2);
|
|
1830
4042
|
}
|
|
1831
4043
|
}
|
|
1832
|
-
|
|
4044
|
+
_options2 = new WeakMap();
|
|
1833
4045
|
_DUMMY_USER = new WeakMap();
|
|
1834
|
-
_httpsAgent = new WeakMap();
|
|
1835
4046
|
_invokeMethods = new WeakMap();
|
|
1836
4047
|
_maxRetries = new WeakMap();
|
|
1837
4048
|
_sleepDuration = new WeakMap();
|
|
1838
4049
|
_NoRetryStatusCodes = new WeakMap();
|
|
1839
4050
|
_stsfhirapiroot = new WeakMap();
|
|
4051
|
+
_agentManager2 = new WeakMap();
|
|
1840
4052
|
_LogDebugMessage = new WeakMap();
|
|
1841
4053
|
_LogErrorMessage = new WeakMap();
|
|
1842
|
-
_GetHttpsAgent = new WeakMap();
|
|
1843
4054
|
_HandleError = new WeakMap();
|
|
1844
4055
|
_InvokeResourceAPI = new WeakMap();
|
|
1845
4056
|
_TestMode = new WeakMap();
|