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