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