@nsshunt/stsfhirclient 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/stsfhirclient.mjs +4568 -5
- package/dist/stsfhirclient.mjs.map +1 -1
- package/dist/stsfhirclient.umd.js +1151 -17762
- package/dist/stsfhirclient.umd.js.map +1 -1
- package/package.json +1 -1
- package/types/FhirClient.d.ts +5 -0
- package/types/FhirClient.d.ts.map +1 -1
- package/dist/index-B52iT9cz.mjs +0 -19793
- package/dist/index-B52iT9cz.mjs.map +0 -1
- package/dist/magic-string.es-D_WyNd_G.mjs +0 -1390
- package/dist/magic-string.es-D_WyNd_G.mjs.map +0 -1
package/dist/stsfhirclient.mjs
CHANGED
|
@@ -1,8 +1,4571 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __typeError = (msg) => {
|
|
3
|
+
throw TypeError(msg);
|
|
4
|
+
};
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
8
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
9
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
10
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
11
|
+
var _options, _DUMMY_USER, _httpsAgent, _invokeMethods, _maxRetries, _sleepDuration, _NoRetryStatusCodes, _LogDebugMessage, _LogErrorMessage, _GetHttpsAgent, _HandleError, _InvokeResourceAPI, _TestMode, ___InvokeResourceAPI, _testHelper, _endpoint, _fhirClient, _accesssToken, _options2, _clientId, _clientSecret, _GetAccessToken, _LogDebugMessage2, _LogErrorMessage2, _HandleError2, _GetPersonRecord, _GetPersonRecordBatch, _testHelper2, _authUtilsNode;
|
|
12
|
+
import https from "node:https";
|
|
13
|
+
import axios from "axios";
|
|
14
|
+
import { Sleep, defaultLogger } from "@nsshunt/stsutils";
|
|
15
|
+
import { Gauge } from "@nsshunt/stsobservability";
|
|
16
|
+
import { expect } from "vitest";
|
|
17
|
+
var IFhirPersistenceType = /* @__PURE__ */ ((IFhirPersistenceType2) => {
|
|
18
|
+
IFhirPersistenceType2["postgresResources"] = "postgresResources";
|
|
19
|
+
IFhirPersistenceType2["postgresResourcesEntities"] = "postgresResourcesEntities";
|
|
20
|
+
IFhirPersistenceType2["redisJson"] = "redisJson";
|
|
21
|
+
IFhirPersistenceType2["ioredisJson"] = "ioredisJson";
|
|
22
|
+
return IFhirPersistenceType2;
|
|
23
|
+
})(IFhirPersistenceType || {});
|
|
24
|
+
var byteToHex = [];
|
|
25
|
+
for (var i = 0; i < 256; ++i) {
|
|
26
|
+
byteToHex.push((i + 256).toString(16).slice(1));
|
|
27
|
+
}
|
|
28
|
+
function unsafeStringify(arr, offset = 0) {
|
|
29
|
+
return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
|
|
30
|
+
}
|
|
31
|
+
var getRandomValues;
|
|
32
|
+
var rnds8 = new Uint8Array(16);
|
|
33
|
+
function rng() {
|
|
34
|
+
if (!getRandomValues) {
|
|
35
|
+
getRandomValues = typeof crypto !== "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|
36
|
+
if (!getRandomValues) {
|
|
37
|
+
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return getRandomValues(rnds8);
|
|
41
|
+
}
|
|
42
|
+
var randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
43
|
+
const native = {
|
|
44
|
+
randomUUID
|
|
45
|
+
};
|
|
46
|
+
function v4(options, buf, offset) {
|
|
47
|
+
if (native.randomUUID && !buf && !options) {
|
|
48
|
+
return native.randomUUID();
|
|
49
|
+
}
|
|
50
|
+
options = options || {};
|
|
51
|
+
var rnds = options.random || (options.rng || rng)();
|
|
52
|
+
rnds[6] = rnds[6] & 15 | 64;
|
|
53
|
+
rnds[8] = rnds[8] & 63 | 128;
|
|
54
|
+
return unsafeStringify(rnds);
|
|
55
|
+
}
|
|
56
|
+
const isNode = Object.prototype.toString.call(typeof process !== "undefined" ? process : 0) === "[object process]";
|
|
57
|
+
function getDefaultExportFromCjs(x) {
|
|
58
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
59
|
+
}
|
|
60
|
+
function getAugmentedNamespace(n) {
|
|
61
|
+
if (n.__esModule) return n;
|
|
62
|
+
var f = n.default;
|
|
63
|
+
if (typeof f == "function") {
|
|
64
|
+
var a = function a2() {
|
|
65
|
+
if (this instanceof a2) {
|
|
66
|
+
return Reflect.construct(f, arguments, this.constructor);
|
|
67
|
+
}
|
|
68
|
+
return f.apply(this, arguments);
|
|
69
|
+
};
|
|
70
|
+
a.prototype = f.prototype;
|
|
71
|
+
} else a = {};
|
|
72
|
+
Object.defineProperty(a, "__esModule", { value: true });
|
|
73
|
+
Object.keys(n).forEach(function(k) {
|
|
74
|
+
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
75
|
+
Object.defineProperty(a, k, d.get ? d : {
|
|
76
|
+
enumerable: true,
|
|
77
|
+
get: function() {
|
|
78
|
+
return n[k];
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
return a;
|
|
83
|
+
}
|
|
84
|
+
var main$1 = { exports: {} };
|
|
85
|
+
const __viteBrowserExternal$1 = {};
|
|
86
|
+
const __viteBrowserExternal$2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
87
|
+
__proto__: null,
|
|
88
|
+
default: __viteBrowserExternal$1
|
|
89
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
90
|
+
const require$$3 = /* @__PURE__ */ getAugmentedNamespace(__viteBrowserExternal$2);
|
|
91
|
+
const name = "dotenv";
|
|
92
|
+
const version$1 = "16.4.5";
|
|
93
|
+
const description = "Loads environment variables from .env file";
|
|
94
|
+
const main = "lib/main.js";
|
|
95
|
+
const types = "lib/main.d.ts";
|
|
96
|
+
const exports = {
|
|
97
|
+
".": {
|
|
98
|
+
types: "./lib/main.d.ts",
|
|
99
|
+
require: "./lib/main.js",
|
|
100
|
+
"default": "./lib/main.js"
|
|
101
|
+
},
|
|
102
|
+
"./config": "./config.js",
|
|
103
|
+
"./config.js": "./config.js",
|
|
104
|
+
"./lib/env-options": "./lib/env-options.js",
|
|
105
|
+
"./lib/env-options.js": "./lib/env-options.js",
|
|
106
|
+
"./lib/cli-options": "./lib/cli-options.js",
|
|
107
|
+
"./lib/cli-options.js": "./lib/cli-options.js",
|
|
108
|
+
"./package.json": "./package.json"
|
|
109
|
+
};
|
|
110
|
+
const scripts = {
|
|
111
|
+
"dts-check": "tsc --project tests/types/tsconfig.json",
|
|
112
|
+
lint: "standard",
|
|
113
|
+
"lint-readme": "standard-markdown",
|
|
114
|
+
pretest: "npm run lint && npm run dts-check",
|
|
115
|
+
test: "tap tests/*.js --100 -Rspec",
|
|
116
|
+
"test:coverage": "tap --coverage-report=lcov",
|
|
117
|
+
prerelease: "npm test",
|
|
118
|
+
release: "standard-version"
|
|
119
|
+
};
|
|
120
|
+
const repository = {
|
|
121
|
+
type: "git",
|
|
122
|
+
url: "git://github.com/motdotla/dotenv.git"
|
|
123
|
+
};
|
|
124
|
+
const funding = "https://dotenvx.com";
|
|
125
|
+
const keywords = [
|
|
126
|
+
"dotenv",
|
|
127
|
+
"env",
|
|
128
|
+
".env",
|
|
129
|
+
"environment",
|
|
130
|
+
"variables",
|
|
131
|
+
"config",
|
|
132
|
+
"settings"
|
|
133
|
+
];
|
|
134
|
+
const readmeFilename = "README.md";
|
|
135
|
+
const license = "BSD-2-Clause";
|
|
136
|
+
const devDependencies = {
|
|
137
|
+
"@definitelytyped/dtslint": "^0.0.133",
|
|
138
|
+
"@types/node": "^18.11.3",
|
|
139
|
+
decache: "^4.6.1",
|
|
140
|
+
sinon: "^14.0.1",
|
|
141
|
+
standard: "^17.0.0",
|
|
142
|
+
"standard-markdown": "^7.1.0",
|
|
143
|
+
"standard-version": "^9.5.0",
|
|
144
|
+
tap: "^16.3.0",
|
|
145
|
+
tar: "^6.1.11",
|
|
146
|
+
typescript: "^4.8.4"
|
|
147
|
+
};
|
|
148
|
+
const engines = {
|
|
149
|
+
node: ">=12"
|
|
150
|
+
};
|
|
151
|
+
const browser$2 = {
|
|
152
|
+
fs: false
|
|
153
|
+
};
|
|
154
|
+
const require$$4 = {
|
|
155
|
+
name,
|
|
156
|
+
version: version$1,
|
|
157
|
+
description,
|
|
158
|
+
main,
|
|
159
|
+
types,
|
|
160
|
+
exports,
|
|
161
|
+
scripts,
|
|
162
|
+
repository,
|
|
163
|
+
funding,
|
|
164
|
+
keywords,
|
|
165
|
+
readmeFilename,
|
|
166
|
+
license,
|
|
167
|
+
devDependencies,
|
|
168
|
+
engines,
|
|
169
|
+
browser: browser$2
|
|
170
|
+
};
|
|
171
|
+
const fs$1 = require$$3;
|
|
172
|
+
const path = require$$3;
|
|
173
|
+
const os = require$$3;
|
|
174
|
+
const crypto$1 = require$$3;
|
|
175
|
+
const packageJson = require$$4;
|
|
176
|
+
const version = packageJson.version;
|
|
177
|
+
const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
|
|
178
|
+
function parse(src) {
|
|
179
|
+
const obj = {};
|
|
180
|
+
let lines = src.toString();
|
|
181
|
+
lines = lines.replace(/\r\n?/mg, "\n");
|
|
182
|
+
let match;
|
|
183
|
+
while ((match = LINE.exec(lines)) != null) {
|
|
184
|
+
const key = match[1];
|
|
185
|
+
let value = match[2] || "";
|
|
186
|
+
value = value.trim();
|
|
187
|
+
const maybeQuote = value[0];
|
|
188
|
+
value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
|
|
189
|
+
if (maybeQuote === '"') {
|
|
190
|
+
value = value.replace(/\\n/g, "\n");
|
|
191
|
+
value = value.replace(/\\r/g, "\r");
|
|
192
|
+
}
|
|
193
|
+
obj[key] = value;
|
|
194
|
+
}
|
|
195
|
+
return obj;
|
|
196
|
+
}
|
|
197
|
+
function _parseVault(options) {
|
|
198
|
+
const vaultPath = _vaultPath(options);
|
|
199
|
+
const result = DotenvModule.configDotenv({ path: vaultPath });
|
|
200
|
+
if (!result.parsed) {
|
|
201
|
+
const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
|
|
202
|
+
err.code = "MISSING_DATA";
|
|
203
|
+
throw err;
|
|
204
|
+
}
|
|
205
|
+
const keys = _dotenvKey(options).split(",");
|
|
206
|
+
const length = keys.length;
|
|
207
|
+
let decrypted;
|
|
208
|
+
for (let i = 0; i < length; i++) {
|
|
209
|
+
try {
|
|
210
|
+
const key = keys[i].trim();
|
|
211
|
+
const attrs = _instructions(result, key);
|
|
212
|
+
decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
|
|
213
|
+
break;
|
|
214
|
+
} catch (error) {
|
|
215
|
+
if (i + 1 >= length) {
|
|
216
|
+
throw error;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return DotenvModule.parse(decrypted);
|
|
221
|
+
}
|
|
222
|
+
function _log(message) {
|
|
223
|
+
console.log(`[dotenv@${version}][INFO] ${message}`);
|
|
224
|
+
}
|
|
225
|
+
function _warn(message) {
|
|
226
|
+
console.log(`[dotenv@${version}][WARN] ${message}`);
|
|
227
|
+
}
|
|
228
|
+
function _debug(message) {
|
|
229
|
+
console.log(`[dotenv@${version}][DEBUG] ${message}`);
|
|
230
|
+
}
|
|
231
|
+
function _dotenvKey(options) {
|
|
232
|
+
if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
|
|
233
|
+
return options.DOTENV_KEY;
|
|
234
|
+
}
|
|
235
|
+
if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
|
|
236
|
+
return process.env.DOTENV_KEY;
|
|
237
|
+
}
|
|
238
|
+
return "";
|
|
239
|
+
}
|
|
240
|
+
function _instructions(result, dotenvKey) {
|
|
241
|
+
let uri;
|
|
242
|
+
try {
|
|
243
|
+
uri = new URL(dotenvKey);
|
|
244
|
+
} catch (error) {
|
|
245
|
+
if (error.code === "ERR_INVALID_URL") {
|
|
246
|
+
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");
|
|
247
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
248
|
+
throw err;
|
|
249
|
+
}
|
|
250
|
+
throw error;
|
|
251
|
+
}
|
|
252
|
+
const key = uri.password;
|
|
253
|
+
if (!key) {
|
|
254
|
+
const err = new Error("INVALID_DOTENV_KEY: Missing key part");
|
|
255
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
256
|
+
throw err;
|
|
257
|
+
}
|
|
258
|
+
const environment = uri.searchParams.get("environment");
|
|
259
|
+
if (!environment) {
|
|
260
|
+
const err = new Error("INVALID_DOTENV_KEY: Missing environment part");
|
|
261
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
262
|
+
throw err;
|
|
263
|
+
}
|
|
264
|
+
const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
|
|
265
|
+
const ciphertext = result.parsed[environmentKey];
|
|
266
|
+
if (!ciphertext) {
|
|
267
|
+
const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
|
|
268
|
+
err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
|
|
269
|
+
throw err;
|
|
270
|
+
}
|
|
271
|
+
return { ciphertext, key };
|
|
272
|
+
}
|
|
273
|
+
function _vaultPath(options) {
|
|
274
|
+
let possibleVaultPath = null;
|
|
275
|
+
if (options && options.path && options.path.length > 0) {
|
|
276
|
+
if (Array.isArray(options.path)) {
|
|
277
|
+
for (const filepath of options.path) {
|
|
278
|
+
if (fs$1.existsSync(filepath)) {
|
|
279
|
+
possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
} else {
|
|
283
|
+
possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
|
|
284
|
+
}
|
|
285
|
+
} else {
|
|
286
|
+
possibleVaultPath = path.resolve(process.cwd(), ".env.vault");
|
|
287
|
+
}
|
|
288
|
+
if (fs$1.existsSync(possibleVaultPath)) {
|
|
289
|
+
return possibleVaultPath;
|
|
290
|
+
}
|
|
291
|
+
return null;
|
|
292
|
+
}
|
|
293
|
+
function _resolveHome(envPath) {
|
|
294
|
+
return envPath[0] === "~" ? path.join(os.homedir(), envPath.slice(1)) : envPath;
|
|
295
|
+
}
|
|
296
|
+
function _configVault(options) {
|
|
297
|
+
_log("Loading env from encrypted .env.vault");
|
|
298
|
+
const parsed = DotenvModule._parseVault(options);
|
|
299
|
+
let processEnv = process.env;
|
|
300
|
+
if (options && options.processEnv != null) {
|
|
301
|
+
processEnv = options.processEnv;
|
|
302
|
+
}
|
|
303
|
+
DotenvModule.populate(processEnv, parsed, options);
|
|
304
|
+
return { parsed };
|
|
305
|
+
}
|
|
306
|
+
function configDotenv(options) {
|
|
307
|
+
const dotenvPath = path.resolve(process.cwd(), ".env");
|
|
308
|
+
let encoding = "utf8";
|
|
309
|
+
const debug = Boolean(options && options.debug);
|
|
310
|
+
if (options && options.encoding) {
|
|
311
|
+
encoding = options.encoding;
|
|
312
|
+
} else {
|
|
313
|
+
if (debug) {
|
|
314
|
+
_debug("No encoding is specified. UTF-8 is used by default");
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
let optionPaths = [dotenvPath];
|
|
318
|
+
if (options && options.path) {
|
|
319
|
+
if (!Array.isArray(options.path)) {
|
|
320
|
+
optionPaths = [_resolveHome(options.path)];
|
|
321
|
+
} else {
|
|
322
|
+
optionPaths = [];
|
|
323
|
+
for (const filepath of options.path) {
|
|
324
|
+
optionPaths.push(_resolveHome(filepath));
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
let lastError;
|
|
329
|
+
const parsedAll = {};
|
|
330
|
+
for (const path2 of optionPaths) {
|
|
331
|
+
try {
|
|
332
|
+
const parsed = DotenvModule.parse(fs$1.readFileSync(path2, { encoding }));
|
|
333
|
+
DotenvModule.populate(parsedAll, parsed, options);
|
|
334
|
+
} catch (e) {
|
|
335
|
+
if (debug) {
|
|
336
|
+
_debug(`Failed to load ${path2} ${e.message}`);
|
|
337
|
+
}
|
|
338
|
+
lastError = e;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
let processEnv = process.env;
|
|
342
|
+
if (options && options.processEnv != null) {
|
|
343
|
+
processEnv = options.processEnv;
|
|
344
|
+
}
|
|
345
|
+
DotenvModule.populate(processEnv, parsedAll, options);
|
|
346
|
+
if (lastError) {
|
|
347
|
+
return { parsed: parsedAll, error: lastError };
|
|
348
|
+
} else {
|
|
349
|
+
return { parsed: parsedAll };
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
function config(options) {
|
|
353
|
+
if (_dotenvKey(options).length === 0) {
|
|
354
|
+
return DotenvModule.configDotenv(options);
|
|
355
|
+
}
|
|
356
|
+
const vaultPath = _vaultPath(options);
|
|
357
|
+
if (!vaultPath) {
|
|
358
|
+
_warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
|
|
359
|
+
return DotenvModule.configDotenv(options);
|
|
360
|
+
}
|
|
361
|
+
return DotenvModule._configVault(options);
|
|
362
|
+
}
|
|
363
|
+
function decrypt(encrypted, keyStr) {
|
|
364
|
+
const key = Buffer.from(keyStr.slice(-64), "hex");
|
|
365
|
+
let ciphertext = Buffer.from(encrypted, "base64");
|
|
366
|
+
const nonce = ciphertext.subarray(0, 12);
|
|
367
|
+
const authTag = ciphertext.subarray(-16);
|
|
368
|
+
ciphertext = ciphertext.subarray(12, -16);
|
|
369
|
+
try {
|
|
370
|
+
const aesgcm = crypto$1.createDecipheriv("aes-256-gcm", key, nonce);
|
|
371
|
+
aesgcm.setAuthTag(authTag);
|
|
372
|
+
return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
|
|
373
|
+
} catch (error) {
|
|
374
|
+
const isRange = error instanceof RangeError;
|
|
375
|
+
const invalidKeyLength = error.message === "Invalid key length";
|
|
376
|
+
const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
|
|
377
|
+
if (isRange || invalidKeyLength) {
|
|
378
|
+
const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
|
|
379
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
380
|
+
throw err;
|
|
381
|
+
} else if (decryptionFailed) {
|
|
382
|
+
const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
|
|
383
|
+
err.code = "DECRYPTION_FAILED";
|
|
384
|
+
throw err;
|
|
385
|
+
} else {
|
|
386
|
+
throw error;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
function populate(processEnv, parsed, options = {}) {
|
|
391
|
+
const debug = Boolean(options && options.debug);
|
|
392
|
+
const override = Boolean(options && options.override);
|
|
393
|
+
if (typeof parsed !== "object") {
|
|
394
|
+
const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
|
|
395
|
+
err.code = "OBJECT_REQUIRED";
|
|
396
|
+
throw err;
|
|
397
|
+
}
|
|
398
|
+
for (const key of Object.keys(parsed)) {
|
|
399
|
+
if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
|
|
400
|
+
if (override === true) {
|
|
401
|
+
processEnv[key] = parsed[key];
|
|
402
|
+
}
|
|
403
|
+
if (debug) {
|
|
404
|
+
if (override === true) {
|
|
405
|
+
_debug(`"${key}" is already defined and WAS overwritten`);
|
|
406
|
+
} else {
|
|
407
|
+
_debug(`"${key}" is already defined and was NOT overwritten`);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
} else {
|
|
411
|
+
processEnv[key] = parsed[key];
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
const DotenvModule = {
|
|
416
|
+
configDotenv,
|
|
417
|
+
_configVault,
|
|
418
|
+
_parseVault,
|
|
419
|
+
config,
|
|
420
|
+
decrypt,
|
|
421
|
+
parse,
|
|
422
|
+
populate
|
|
423
|
+
};
|
|
424
|
+
main$1.exports.configDotenv = DotenvModule.configDotenv;
|
|
425
|
+
main$1.exports._configVault = DotenvModule._configVault;
|
|
426
|
+
main$1.exports._parseVault = DotenvModule._parseVault;
|
|
427
|
+
var config_1 = main$1.exports.config = DotenvModule.config;
|
|
428
|
+
main$1.exports.decrypt = DotenvModule.decrypt;
|
|
429
|
+
main$1.exports.parse = DotenvModule.parse;
|
|
430
|
+
main$1.exports.populate = DotenvModule.populate;
|
|
431
|
+
main$1.exports = DotenvModule;
|
|
432
|
+
const __viteBrowserExternal = {};
|
|
433
|
+
const fs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
434
|
+
__proto__: null,
|
|
435
|
+
default: __viteBrowserExternal
|
|
436
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
437
|
+
var ansiStyles$1$1 = { exports: {} };
|
|
438
|
+
var colorName$1;
|
|
439
|
+
var hasRequiredColorName$1;
|
|
440
|
+
function requireColorName$1() {
|
|
441
|
+
if (hasRequiredColorName$1) return colorName$1;
|
|
442
|
+
hasRequiredColorName$1 = 1;
|
|
443
|
+
colorName$1 = {
|
|
444
|
+
"aliceblue": [240, 248, 255],
|
|
445
|
+
"antiquewhite": [250, 235, 215],
|
|
446
|
+
"aqua": [0, 255, 255],
|
|
447
|
+
"aquamarine": [127, 255, 212],
|
|
448
|
+
"azure": [240, 255, 255],
|
|
449
|
+
"beige": [245, 245, 220],
|
|
450
|
+
"bisque": [255, 228, 196],
|
|
451
|
+
"black": [0, 0, 0],
|
|
452
|
+
"blanchedalmond": [255, 235, 205],
|
|
453
|
+
"blue": [0, 0, 255],
|
|
454
|
+
"blueviolet": [138, 43, 226],
|
|
455
|
+
"brown": [165, 42, 42],
|
|
456
|
+
"burlywood": [222, 184, 135],
|
|
457
|
+
"cadetblue": [95, 158, 160],
|
|
458
|
+
"chartreuse": [127, 255, 0],
|
|
459
|
+
"chocolate": [210, 105, 30],
|
|
460
|
+
"coral": [255, 127, 80],
|
|
461
|
+
"cornflowerblue": [100, 149, 237],
|
|
462
|
+
"cornsilk": [255, 248, 220],
|
|
463
|
+
"crimson": [220, 20, 60],
|
|
464
|
+
"cyan": [0, 255, 255],
|
|
465
|
+
"darkblue": [0, 0, 139],
|
|
466
|
+
"darkcyan": [0, 139, 139],
|
|
467
|
+
"darkgoldenrod": [184, 134, 11],
|
|
468
|
+
"darkgray": [169, 169, 169],
|
|
469
|
+
"darkgreen": [0, 100, 0],
|
|
470
|
+
"darkgrey": [169, 169, 169],
|
|
471
|
+
"darkkhaki": [189, 183, 107],
|
|
472
|
+
"darkmagenta": [139, 0, 139],
|
|
473
|
+
"darkolivegreen": [85, 107, 47],
|
|
474
|
+
"darkorange": [255, 140, 0],
|
|
475
|
+
"darkorchid": [153, 50, 204],
|
|
476
|
+
"darkred": [139, 0, 0],
|
|
477
|
+
"darksalmon": [233, 150, 122],
|
|
478
|
+
"darkseagreen": [143, 188, 143],
|
|
479
|
+
"darkslateblue": [72, 61, 139],
|
|
480
|
+
"darkslategray": [47, 79, 79],
|
|
481
|
+
"darkslategrey": [47, 79, 79],
|
|
482
|
+
"darkturquoise": [0, 206, 209],
|
|
483
|
+
"darkviolet": [148, 0, 211],
|
|
484
|
+
"deeppink": [255, 20, 147],
|
|
485
|
+
"deepskyblue": [0, 191, 255],
|
|
486
|
+
"dimgray": [105, 105, 105],
|
|
487
|
+
"dimgrey": [105, 105, 105],
|
|
488
|
+
"dodgerblue": [30, 144, 255],
|
|
489
|
+
"firebrick": [178, 34, 34],
|
|
490
|
+
"floralwhite": [255, 250, 240],
|
|
491
|
+
"forestgreen": [34, 139, 34],
|
|
492
|
+
"fuchsia": [255, 0, 255],
|
|
493
|
+
"gainsboro": [220, 220, 220],
|
|
494
|
+
"ghostwhite": [248, 248, 255],
|
|
495
|
+
"gold": [255, 215, 0],
|
|
496
|
+
"goldenrod": [218, 165, 32],
|
|
497
|
+
"gray": [128, 128, 128],
|
|
498
|
+
"green": [0, 128, 0],
|
|
499
|
+
"greenyellow": [173, 255, 47],
|
|
500
|
+
"grey": [128, 128, 128],
|
|
501
|
+
"honeydew": [240, 255, 240],
|
|
502
|
+
"hotpink": [255, 105, 180],
|
|
503
|
+
"indianred": [205, 92, 92],
|
|
504
|
+
"indigo": [75, 0, 130],
|
|
505
|
+
"ivory": [255, 255, 240],
|
|
506
|
+
"khaki": [240, 230, 140],
|
|
507
|
+
"lavender": [230, 230, 250],
|
|
508
|
+
"lavenderblush": [255, 240, 245],
|
|
509
|
+
"lawngreen": [124, 252, 0],
|
|
510
|
+
"lemonchiffon": [255, 250, 205],
|
|
511
|
+
"lightblue": [173, 216, 230],
|
|
512
|
+
"lightcoral": [240, 128, 128],
|
|
513
|
+
"lightcyan": [224, 255, 255],
|
|
514
|
+
"lightgoldenrodyellow": [250, 250, 210],
|
|
515
|
+
"lightgray": [211, 211, 211],
|
|
516
|
+
"lightgreen": [144, 238, 144],
|
|
517
|
+
"lightgrey": [211, 211, 211],
|
|
518
|
+
"lightpink": [255, 182, 193],
|
|
519
|
+
"lightsalmon": [255, 160, 122],
|
|
520
|
+
"lightseagreen": [32, 178, 170],
|
|
521
|
+
"lightskyblue": [135, 206, 250],
|
|
522
|
+
"lightslategray": [119, 136, 153],
|
|
523
|
+
"lightslategrey": [119, 136, 153],
|
|
524
|
+
"lightsteelblue": [176, 196, 222],
|
|
525
|
+
"lightyellow": [255, 255, 224],
|
|
526
|
+
"lime": [0, 255, 0],
|
|
527
|
+
"limegreen": [50, 205, 50],
|
|
528
|
+
"linen": [250, 240, 230],
|
|
529
|
+
"magenta": [255, 0, 255],
|
|
530
|
+
"maroon": [128, 0, 0],
|
|
531
|
+
"mediumaquamarine": [102, 205, 170],
|
|
532
|
+
"mediumblue": [0, 0, 205],
|
|
533
|
+
"mediumorchid": [186, 85, 211],
|
|
534
|
+
"mediumpurple": [147, 112, 219],
|
|
535
|
+
"mediumseagreen": [60, 179, 113],
|
|
536
|
+
"mediumslateblue": [123, 104, 238],
|
|
537
|
+
"mediumspringgreen": [0, 250, 154],
|
|
538
|
+
"mediumturquoise": [72, 209, 204],
|
|
539
|
+
"mediumvioletred": [199, 21, 133],
|
|
540
|
+
"midnightblue": [25, 25, 112],
|
|
541
|
+
"mintcream": [245, 255, 250],
|
|
542
|
+
"mistyrose": [255, 228, 225],
|
|
543
|
+
"moccasin": [255, 228, 181],
|
|
544
|
+
"navajowhite": [255, 222, 173],
|
|
545
|
+
"navy": [0, 0, 128],
|
|
546
|
+
"oldlace": [253, 245, 230],
|
|
547
|
+
"olive": [128, 128, 0],
|
|
548
|
+
"olivedrab": [107, 142, 35],
|
|
549
|
+
"orange": [255, 165, 0],
|
|
550
|
+
"orangered": [255, 69, 0],
|
|
551
|
+
"orchid": [218, 112, 214],
|
|
552
|
+
"palegoldenrod": [238, 232, 170],
|
|
553
|
+
"palegreen": [152, 251, 152],
|
|
554
|
+
"paleturquoise": [175, 238, 238],
|
|
555
|
+
"palevioletred": [219, 112, 147],
|
|
556
|
+
"papayawhip": [255, 239, 213],
|
|
557
|
+
"peachpuff": [255, 218, 185],
|
|
558
|
+
"peru": [205, 133, 63],
|
|
559
|
+
"pink": [255, 192, 203],
|
|
560
|
+
"plum": [221, 160, 221],
|
|
561
|
+
"powderblue": [176, 224, 230],
|
|
562
|
+
"purple": [128, 0, 128],
|
|
563
|
+
"rebeccapurple": [102, 51, 153],
|
|
564
|
+
"red": [255, 0, 0],
|
|
565
|
+
"rosybrown": [188, 143, 143],
|
|
566
|
+
"royalblue": [65, 105, 225],
|
|
567
|
+
"saddlebrown": [139, 69, 19],
|
|
568
|
+
"salmon": [250, 128, 114],
|
|
569
|
+
"sandybrown": [244, 164, 96],
|
|
570
|
+
"seagreen": [46, 139, 87],
|
|
571
|
+
"seashell": [255, 245, 238],
|
|
572
|
+
"sienna": [160, 82, 45],
|
|
573
|
+
"silver": [192, 192, 192],
|
|
574
|
+
"skyblue": [135, 206, 235],
|
|
575
|
+
"slateblue": [106, 90, 205],
|
|
576
|
+
"slategray": [112, 128, 144],
|
|
577
|
+
"slategrey": [112, 128, 144],
|
|
578
|
+
"snow": [255, 250, 250],
|
|
579
|
+
"springgreen": [0, 255, 127],
|
|
580
|
+
"steelblue": [70, 130, 180],
|
|
581
|
+
"tan": [210, 180, 140],
|
|
582
|
+
"teal": [0, 128, 128],
|
|
583
|
+
"thistle": [216, 191, 216],
|
|
584
|
+
"tomato": [255, 99, 71],
|
|
585
|
+
"turquoise": [64, 224, 208],
|
|
586
|
+
"violet": [238, 130, 238],
|
|
587
|
+
"wheat": [245, 222, 179],
|
|
588
|
+
"white": [255, 255, 255],
|
|
589
|
+
"whitesmoke": [245, 245, 245],
|
|
590
|
+
"yellow": [255, 255, 0],
|
|
591
|
+
"yellowgreen": [154, 205, 50]
|
|
592
|
+
};
|
|
593
|
+
return colorName$1;
|
|
594
|
+
}
|
|
595
|
+
var conversions$1;
|
|
596
|
+
var hasRequiredConversions$1;
|
|
597
|
+
function requireConversions$1() {
|
|
598
|
+
if (hasRequiredConversions$1) return conversions$1;
|
|
599
|
+
hasRequiredConversions$1 = 1;
|
|
600
|
+
const cssKeywords = requireColorName$1();
|
|
601
|
+
const reverseKeywords = {};
|
|
602
|
+
for (const key of Object.keys(cssKeywords)) {
|
|
603
|
+
reverseKeywords[cssKeywords[key]] = key;
|
|
604
|
+
}
|
|
605
|
+
const convert = {
|
|
606
|
+
rgb: { channels: 3, labels: "rgb" },
|
|
607
|
+
hsl: { channels: 3, labels: "hsl" },
|
|
608
|
+
hsv: { channels: 3, labels: "hsv" },
|
|
609
|
+
hwb: { channels: 3, labels: "hwb" },
|
|
610
|
+
cmyk: { channels: 4, labels: "cmyk" },
|
|
611
|
+
xyz: { channels: 3, labels: "xyz" },
|
|
612
|
+
lab: { channels: 3, labels: "lab" },
|
|
613
|
+
lch: { channels: 3, labels: "lch" },
|
|
614
|
+
hex: { channels: 1, labels: ["hex"] },
|
|
615
|
+
keyword: { channels: 1, labels: ["keyword"] },
|
|
616
|
+
ansi16: { channels: 1, labels: ["ansi16"] },
|
|
617
|
+
ansi256: { channels: 1, labels: ["ansi256"] },
|
|
618
|
+
hcg: { channels: 3, labels: ["h", "c", "g"] },
|
|
619
|
+
apple: { channels: 3, labels: ["r16", "g16", "b16"] },
|
|
620
|
+
gray: { channels: 1, labels: ["gray"] }
|
|
621
|
+
};
|
|
622
|
+
conversions$1 = convert;
|
|
623
|
+
for (const model of Object.keys(convert)) {
|
|
624
|
+
if (!("channels" in convert[model])) {
|
|
625
|
+
throw new Error("missing channels property: " + model);
|
|
626
|
+
}
|
|
627
|
+
if (!("labels" in convert[model])) {
|
|
628
|
+
throw new Error("missing channel labels property: " + model);
|
|
629
|
+
}
|
|
630
|
+
if (convert[model].labels.length !== convert[model].channels) {
|
|
631
|
+
throw new Error("channel and label counts mismatch: " + model);
|
|
632
|
+
}
|
|
633
|
+
const { channels, labels } = convert[model];
|
|
634
|
+
delete convert[model].channels;
|
|
635
|
+
delete convert[model].labels;
|
|
636
|
+
Object.defineProperty(convert[model], "channels", { value: channels });
|
|
637
|
+
Object.defineProperty(convert[model], "labels", { value: labels });
|
|
638
|
+
}
|
|
639
|
+
convert.rgb.hsl = function(rgb) {
|
|
640
|
+
const r = rgb[0] / 255;
|
|
641
|
+
const g = rgb[1] / 255;
|
|
642
|
+
const b = rgb[2] / 255;
|
|
643
|
+
const min = Math.min(r, g, b);
|
|
644
|
+
const max = Math.max(r, g, b);
|
|
645
|
+
const delta = max - min;
|
|
646
|
+
let h;
|
|
647
|
+
let s;
|
|
648
|
+
if (max === min) {
|
|
649
|
+
h = 0;
|
|
650
|
+
} else if (r === max) {
|
|
651
|
+
h = (g - b) / delta;
|
|
652
|
+
} else if (g === max) {
|
|
653
|
+
h = 2 + (b - r) / delta;
|
|
654
|
+
} else if (b === max) {
|
|
655
|
+
h = 4 + (r - g) / delta;
|
|
656
|
+
}
|
|
657
|
+
h = Math.min(h * 60, 360);
|
|
658
|
+
if (h < 0) {
|
|
659
|
+
h += 360;
|
|
660
|
+
}
|
|
661
|
+
const l = (min + max) / 2;
|
|
662
|
+
if (max === min) {
|
|
663
|
+
s = 0;
|
|
664
|
+
} else if (l <= 0.5) {
|
|
665
|
+
s = delta / (max + min);
|
|
666
|
+
} else {
|
|
667
|
+
s = delta / (2 - max - min);
|
|
668
|
+
}
|
|
669
|
+
return [h, s * 100, l * 100];
|
|
670
|
+
};
|
|
671
|
+
convert.rgb.hsv = function(rgb) {
|
|
672
|
+
let rdif;
|
|
673
|
+
let gdif;
|
|
674
|
+
let bdif;
|
|
675
|
+
let h;
|
|
676
|
+
let s;
|
|
677
|
+
const r = rgb[0] / 255;
|
|
678
|
+
const g = rgb[1] / 255;
|
|
679
|
+
const b = rgb[2] / 255;
|
|
680
|
+
const v = Math.max(r, g, b);
|
|
681
|
+
const diff = v - Math.min(r, g, b);
|
|
682
|
+
const diffc = function(c) {
|
|
683
|
+
return (v - c) / 6 / diff + 1 / 2;
|
|
684
|
+
};
|
|
685
|
+
if (diff === 0) {
|
|
686
|
+
h = 0;
|
|
687
|
+
s = 0;
|
|
688
|
+
} else {
|
|
689
|
+
s = diff / v;
|
|
690
|
+
rdif = diffc(r);
|
|
691
|
+
gdif = diffc(g);
|
|
692
|
+
bdif = diffc(b);
|
|
693
|
+
if (r === v) {
|
|
694
|
+
h = bdif - gdif;
|
|
695
|
+
} else if (g === v) {
|
|
696
|
+
h = 1 / 3 + rdif - bdif;
|
|
697
|
+
} else if (b === v) {
|
|
698
|
+
h = 2 / 3 + gdif - rdif;
|
|
699
|
+
}
|
|
700
|
+
if (h < 0) {
|
|
701
|
+
h += 1;
|
|
702
|
+
} else if (h > 1) {
|
|
703
|
+
h -= 1;
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
return [
|
|
707
|
+
h * 360,
|
|
708
|
+
s * 100,
|
|
709
|
+
v * 100
|
|
710
|
+
];
|
|
711
|
+
};
|
|
712
|
+
convert.rgb.hwb = function(rgb) {
|
|
713
|
+
const r = rgb[0];
|
|
714
|
+
const g = rgb[1];
|
|
715
|
+
let b = rgb[2];
|
|
716
|
+
const h = convert.rgb.hsl(rgb)[0];
|
|
717
|
+
const w = 1 / 255 * Math.min(r, Math.min(g, b));
|
|
718
|
+
b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
|
|
719
|
+
return [h, w * 100, b * 100];
|
|
720
|
+
};
|
|
721
|
+
convert.rgb.cmyk = function(rgb) {
|
|
722
|
+
const r = rgb[0] / 255;
|
|
723
|
+
const g = rgb[1] / 255;
|
|
724
|
+
const b = rgb[2] / 255;
|
|
725
|
+
const k = Math.min(1 - r, 1 - g, 1 - b);
|
|
726
|
+
const c = (1 - r - k) / (1 - k) || 0;
|
|
727
|
+
const m = (1 - g - k) / (1 - k) || 0;
|
|
728
|
+
const y = (1 - b - k) / (1 - k) || 0;
|
|
729
|
+
return [c * 100, m * 100, y * 100, k * 100];
|
|
730
|
+
};
|
|
731
|
+
function comparativeDistance(x, y) {
|
|
732
|
+
return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;
|
|
733
|
+
}
|
|
734
|
+
convert.rgb.keyword = function(rgb) {
|
|
735
|
+
const reversed = reverseKeywords[rgb];
|
|
736
|
+
if (reversed) {
|
|
737
|
+
return reversed;
|
|
738
|
+
}
|
|
739
|
+
let currentClosestDistance = Infinity;
|
|
740
|
+
let currentClosestKeyword;
|
|
741
|
+
for (const keyword of Object.keys(cssKeywords)) {
|
|
742
|
+
const value = cssKeywords[keyword];
|
|
743
|
+
const distance = comparativeDistance(rgb, value);
|
|
744
|
+
if (distance < currentClosestDistance) {
|
|
745
|
+
currentClosestDistance = distance;
|
|
746
|
+
currentClosestKeyword = keyword;
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
return currentClosestKeyword;
|
|
750
|
+
};
|
|
751
|
+
convert.keyword.rgb = function(keyword) {
|
|
752
|
+
return cssKeywords[keyword];
|
|
753
|
+
};
|
|
754
|
+
convert.rgb.xyz = function(rgb) {
|
|
755
|
+
let r = rgb[0] / 255;
|
|
756
|
+
let g = rgb[1] / 255;
|
|
757
|
+
let b = rgb[2] / 255;
|
|
758
|
+
r = r > 0.04045 ? ((r + 0.055) / 1.055) ** 2.4 : r / 12.92;
|
|
759
|
+
g = g > 0.04045 ? ((g + 0.055) / 1.055) ** 2.4 : g / 12.92;
|
|
760
|
+
b = b > 0.04045 ? ((b + 0.055) / 1.055) ** 2.4 : b / 12.92;
|
|
761
|
+
const x = r * 0.4124 + g * 0.3576 + b * 0.1805;
|
|
762
|
+
const y = r * 0.2126 + g * 0.7152 + b * 0.0722;
|
|
763
|
+
const z = r * 0.0193 + g * 0.1192 + b * 0.9505;
|
|
764
|
+
return [x * 100, y * 100, z * 100];
|
|
765
|
+
};
|
|
766
|
+
convert.rgb.lab = function(rgb) {
|
|
767
|
+
const xyz = convert.rgb.xyz(rgb);
|
|
768
|
+
let x = xyz[0];
|
|
769
|
+
let y = xyz[1];
|
|
770
|
+
let z = xyz[2];
|
|
771
|
+
x /= 95.047;
|
|
772
|
+
y /= 100;
|
|
773
|
+
z /= 108.883;
|
|
774
|
+
x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
|
|
775
|
+
y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
|
|
776
|
+
z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
|
|
777
|
+
const l = 116 * y - 16;
|
|
778
|
+
const a = 500 * (x - y);
|
|
779
|
+
const b = 200 * (y - z);
|
|
780
|
+
return [l, a, b];
|
|
781
|
+
};
|
|
782
|
+
convert.hsl.rgb = function(hsl) {
|
|
783
|
+
const h = hsl[0] / 360;
|
|
784
|
+
const s = hsl[1] / 100;
|
|
785
|
+
const l = hsl[2] / 100;
|
|
786
|
+
let t2;
|
|
787
|
+
let t3;
|
|
788
|
+
let val;
|
|
789
|
+
if (s === 0) {
|
|
790
|
+
val = l * 255;
|
|
791
|
+
return [val, val, val];
|
|
792
|
+
}
|
|
793
|
+
if (l < 0.5) {
|
|
794
|
+
t2 = l * (1 + s);
|
|
795
|
+
} else {
|
|
796
|
+
t2 = l + s - l * s;
|
|
797
|
+
}
|
|
798
|
+
const t1 = 2 * l - t2;
|
|
799
|
+
const rgb = [0, 0, 0];
|
|
800
|
+
for (let i = 0; i < 3; i++) {
|
|
801
|
+
t3 = h + 1 / 3 * -(i - 1);
|
|
802
|
+
if (t3 < 0) {
|
|
803
|
+
t3++;
|
|
804
|
+
}
|
|
805
|
+
if (t3 > 1) {
|
|
806
|
+
t3--;
|
|
807
|
+
}
|
|
808
|
+
if (6 * t3 < 1) {
|
|
809
|
+
val = t1 + (t2 - t1) * 6 * t3;
|
|
810
|
+
} else if (2 * t3 < 1) {
|
|
811
|
+
val = t2;
|
|
812
|
+
} else if (3 * t3 < 2) {
|
|
813
|
+
val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
|
|
814
|
+
} else {
|
|
815
|
+
val = t1;
|
|
816
|
+
}
|
|
817
|
+
rgb[i] = val * 255;
|
|
818
|
+
}
|
|
819
|
+
return rgb;
|
|
820
|
+
};
|
|
821
|
+
convert.hsl.hsv = function(hsl) {
|
|
822
|
+
const h = hsl[0];
|
|
823
|
+
let s = hsl[1] / 100;
|
|
824
|
+
let l = hsl[2] / 100;
|
|
825
|
+
let smin = s;
|
|
826
|
+
const lmin = Math.max(l, 0.01);
|
|
827
|
+
l *= 2;
|
|
828
|
+
s *= l <= 1 ? l : 2 - l;
|
|
829
|
+
smin *= lmin <= 1 ? lmin : 2 - lmin;
|
|
830
|
+
const v = (l + s) / 2;
|
|
831
|
+
const sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
|
|
832
|
+
return [h, sv * 100, v * 100];
|
|
833
|
+
};
|
|
834
|
+
convert.hsv.rgb = function(hsv) {
|
|
835
|
+
const h = hsv[0] / 60;
|
|
836
|
+
const s = hsv[1] / 100;
|
|
837
|
+
let v = hsv[2] / 100;
|
|
838
|
+
const hi = Math.floor(h) % 6;
|
|
839
|
+
const f = h - Math.floor(h);
|
|
840
|
+
const p = 255 * v * (1 - s);
|
|
841
|
+
const q = 255 * v * (1 - s * f);
|
|
842
|
+
const t = 255 * v * (1 - s * (1 - f));
|
|
843
|
+
v *= 255;
|
|
844
|
+
switch (hi) {
|
|
845
|
+
case 0:
|
|
846
|
+
return [v, t, p];
|
|
847
|
+
case 1:
|
|
848
|
+
return [q, v, p];
|
|
849
|
+
case 2:
|
|
850
|
+
return [p, v, t];
|
|
851
|
+
case 3:
|
|
852
|
+
return [p, q, v];
|
|
853
|
+
case 4:
|
|
854
|
+
return [t, p, v];
|
|
855
|
+
case 5:
|
|
856
|
+
return [v, p, q];
|
|
857
|
+
}
|
|
858
|
+
};
|
|
859
|
+
convert.hsv.hsl = function(hsv) {
|
|
860
|
+
const h = hsv[0];
|
|
861
|
+
const s = hsv[1] / 100;
|
|
862
|
+
const v = hsv[2] / 100;
|
|
863
|
+
const vmin = Math.max(v, 0.01);
|
|
864
|
+
let sl;
|
|
865
|
+
let l;
|
|
866
|
+
l = (2 - s) * v;
|
|
867
|
+
const lmin = (2 - s) * vmin;
|
|
868
|
+
sl = s * vmin;
|
|
869
|
+
sl /= lmin <= 1 ? lmin : 2 - lmin;
|
|
870
|
+
sl = sl || 0;
|
|
871
|
+
l /= 2;
|
|
872
|
+
return [h, sl * 100, l * 100];
|
|
873
|
+
};
|
|
874
|
+
convert.hwb.rgb = function(hwb) {
|
|
875
|
+
const h = hwb[0] / 360;
|
|
876
|
+
let wh = hwb[1] / 100;
|
|
877
|
+
let bl = hwb[2] / 100;
|
|
878
|
+
const ratio = wh + bl;
|
|
879
|
+
let f;
|
|
880
|
+
if (ratio > 1) {
|
|
881
|
+
wh /= ratio;
|
|
882
|
+
bl /= ratio;
|
|
883
|
+
}
|
|
884
|
+
const i = Math.floor(6 * h);
|
|
885
|
+
const v = 1 - bl;
|
|
886
|
+
f = 6 * h - i;
|
|
887
|
+
if ((i & 1) !== 0) {
|
|
888
|
+
f = 1 - f;
|
|
889
|
+
}
|
|
890
|
+
const n = wh + f * (v - wh);
|
|
891
|
+
let r;
|
|
892
|
+
let g;
|
|
893
|
+
let b;
|
|
894
|
+
switch (i) {
|
|
895
|
+
default:
|
|
896
|
+
case 6:
|
|
897
|
+
case 0:
|
|
898
|
+
r = v;
|
|
899
|
+
g = n;
|
|
900
|
+
b = wh;
|
|
901
|
+
break;
|
|
902
|
+
case 1:
|
|
903
|
+
r = n;
|
|
904
|
+
g = v;
|
|
905
|
+
b = wh;
|
|
906
|
+
break;
|
|
907
|
+
case 2:
|
|
908
|
+
r = wh;
|
|
909
|
+
g = v;
|
|
910
|
+
b = n;
|
|
911
|
+
break;
|
|
912
|
+
case 3:
|
|
913
|
+
r = wh;
|
|
914
|
+
g = n;
|
|
915
|
+
b = v;
|
|
916
|
+
break;
|
|
917
|
+
case 4:
|
|
918
|
+
r = n;
|
|
919
|
+
g = wh;
|
|
920
|
+
b = v;
|
|
921
|
+
break;
|
|
922
|
+
case 5:
|
|
923
|
+
r = v;
|
|
924
|
+
g = wh;
|
|
925
|
+
b = n;
|
|
926
|
+
break;
|
|
927
|
+
}
|
|
928
|
+
return [r * 255, g * 255, b * 255];
|
|
929
|
+
};
|
|
930
|
+
convert.cmyk.rgb = function(cmyk) {
|
|
931
|
+
const c = cmyk[0] / 100;
|
|
932
|
+
const m = cmyk[1] / 100;
|
|
933
|
+
const y = cmyk[2] / 100;
|
|
934
|
+
const k = cmyk[3] / 100;
|
|
935
|
+
const r = 1 - Math.min(1, c * (1 - k) + k);
|
|
936
|
+
const g = 1 - Math.min(1, m * (1 - k) + k);
|
|
937
|
+
const b = 1 - Math.min(1, y * (1 - k) + k);
|
|
938
|
+
return [r * 255, g * 255, b * 255];
|
|
939
|
+
};
|
|
940
|
+
convert.xyz.rgb = function(xyz) {
|
|
941
|
+
const x = xyz[0] / 100;
|
|
942
|
+
const y = xyz[1] / 100;
|
|
943
|
+
const z = xyz[2] / 100;
|
|
944
|
+
let r;
|
|
945
|
+
let g;
|
|
946
|
+
let b;
|
|
947
|
+
r = x * 3.2406 + y * -1.5372 + z * -0.4986;
|
|
948
|
+
g = x * -0.9689 + y * 1.8758 + z * 0.0415;
|
|
949
|
+
b = x * 0.0557 + y * -0.204 + z * 1.057;
|
|
950
|
+
r = r > 31308e-7 ? 1.055 * r ** (1 / 2.4) - 0.055 : r * 12.92;
|
|
951
|
+
g = g > 31308e-7 ? 1.055 * g ** (1 / 2.4) - 0.055 : g * 12.92;
|
|
952
|
+
b = b > 31308e-7 ? 1.055 * b ** (1 / 2.4) - 0.055 : b * 12.92;
|
|
953
|
+
r = Math.min(Math.max(0, r), 1);
|
|
954
|
+
g = Math.min(Math.max(0, g), 1);
|
|
955
|
+
b = Math.min(Math.max(0, b), 1);
|
|
956
|
+
return [r * 255, g * 255, b * 255];
|
|
957
|
+
};
|
|
958
|
+
convert.xyz.lab = function(xyz) {
|
|
959
|
+
let x = xyz[0];
|
|
960
|
+
let y = xyz[1];
|
|
961
|
+
let z = xyz[2];
|
|
962
|
+
x /= 95.047;
|
|
963
|
+
y /= 100;
|
|
964
|
+
z /= 108.883;
|
|
965
|
+
x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
|
|
966
|
+
y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
|
|
967
|
+
z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
|
|
968
|
+
const l = 116 * y - 16;
|
|
969
|
+
const a = 500 * (x - y);
|
|
970
|
+
const b = 200 * (y - z);
|
|
971
|
+
return [l, a, b];
|
|
972
|
+
};
|
|
973
|
+
convert.lab.xyz = function(lab) {
|
|
974
|
+
const l = lab[0];
|
|
975
|
+
const a = lab[1];
|
|
976
|
+
const b = lab[2];
|
|
977
|
+
let x;
|
|
978
|
+
let y;
|
|
979
|
+
let z;
|
|
980
|
+
y = (l + 16) / 116;
|
|
981
|
+
x = a / 500 + y;
|
|
982
|
+
z = y - b / 200;
|
|
983
|
+
const y2 = y ** 3;
|
|
984
|
+
const x2 = x ** 3;
|
|
985
|
+
const z2 = z ** 3;
|
|
986
|
+
y = y2 > 8856e-6 ? y2 : (y - 16 / 116) / 7.787;
|
|
987
|
+
x = x2 > 8856e-6 ? x2 : (x - 16 / 116) / 7.787;
|
|
988
|
+
z = z2 > 8856e-6 ? z2 : (z - 16 / 116) / 7.787;
|
|
989
|
+
x *= 95.047;
|
|
990
|
+
y *= 100;
|
|
991
|
+
z *= 108.883;
|
|
992
|
+
return [x, y, z];
|
|
993
|
+
};
|
|
994
|
+
convert.lab.lch = function(lab) {
|
|
995
|
+
const l = lab[0];
|
|
996
|
+
const a = lab[1];
|
|
997
|
+
const b = lab[2];
|
|
998
|
+
let h;
|
|
999
|
+
const hr = Math.atan2(b, a);
|
|
1000
|
+
h = hr * 360 / 2 / Math.PI;
|
|
1001
|
+
if (h < 0) {
|
|
1002
|
+
h += 360;
|
|
1003
|
+
}
|
|
1004
|
+
const c = Math.sqrt(a * a + b * b);
|
|
1005
|
+
return [l, c, h];
|
|
1006
|
+
};
|
|
1007
|
+
convert.lch.lab = function(lch) {
|
|
1008
|
+
const l = lch[0];
|
|
1009
|
+
const c = lch[1];
|
|
1010
|
+
const h = lch[2];
|
|
1011
|
+
const hr = h / 360 * 2 * Math.PI;
|
|
1012
|
+
const a = c * Math.cos(hr);
|
|
1013
|
+
const b = c * Math.sin(hr);
|
|
1014
|
+
return [l, a, b];
|
|
1015
|
+
};
|
|
1016
|
+
convert.rgb.ansi16 = function(args, saturation = null) {
|
|
1017
|
+
const [r, g, b] = args;
|
|
1018
|
+
let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation;
|
|
1019
|
+
value = Math.round(value / 50);
|
|
1020
|
+
if (value === 0) {
|
|
1021
|
+
return 30;
|
|
1022
|
+
}
|
|
1023
|
+
let ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
|
|
1024
|
+
if (value === 2) {
|
|
1025
|
+
ansi += 60;
|
|
1026
|
+
}
|
|
1027
|
+
return ansi;
|
|
1028
|
+
};
|
|
1029
|
+
convert.hsv.ansi16 = function(args) {
|
|
1030
|
+
return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
|
|
1031
|
+
};
|
|
1032
|
+
convert.rgb.ansi256 = function(args) {
|
|
1033
|
+
const r = args[0];
|
|
1034
|
+
const g = args[1];
|
|
1035
|
+
const b = args[2];
|
|
1036
|
+
if (r === g && g === b) {
|
|
1037
|
+
if (r < 8) {
|
|
1038
|
+
return 16;
|
|
1039
|
+
}
|
|
1040
|
+
if (r > 248) {
|
|
1041
|
+
return 231;
|
|
1042
|
+
}
|
|
1043
|
+
return Math.round((r - 8) / 247 * 24) + 232;
|
|
1044
|
+
}
|
|
1045
|
+
const ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
|
|
1046
|
+
return ansi;
|
|
1047
|
+
};
|
|
1048
|
+
convert.ansi16.rgb = function(args) {
|
|
1049
|
+
let color = args % 10;
|
|
1050
|
+
if (color === 0 || color === 7) {
|
|
1051
|
+
if (args > 50) {
|
|
1052
|
+
color += 3.5;
|
|
1053
|
+
}
|
|
1054
|
+
color = color / 10.5 * 255;
|
|
1055
|
+
return [color, color, color];
|
|
1056
|
+
}
|
|
1057
|
+
const mult = (~~(args > 50) + 1) * 0.5;
|
|
1058
|
+
const r = (color & 1) * mult * 255;
|
|
1059
|
+
const g = (color >> 1 & 1) * mult * 255;
|
|
1060
|
+
const b = (color >> 2 & 1) * mult * 255;
|
|
1061
|
+
return [r, g, b];
|
|
1062
|
+
};
|
|
1063
|
+
convert.ansi256.rgb = function(args) {
|
|
1064
|
+
if (args >= 232) {
|
|
1065
|
+
const c = (args - 232) * 10 + 8;
|
|
1066
|
+
return [c, c, c];
|
|
1067
|
+
}
|
|
1068
|
+
args -= 16;
|
|
1069
|
+
let rem;
|
|
1070
|
+
const r = Math.floor(args / 36) / 5 * 255;
|
|
1071
|
+
const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
|
|
1072
|
+
const b = rem % 6 / 5 * 255;
|
|
1073
|
+
return [r, g, b];
|
|
1074
|
+
};
|
|
1075
|
+
convert.rgb.hex = function(args) {
|
|
1076
|
+
const integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255);
|
|
1077
|
+
const string = integer.toString(16).toUpperCase();
|
|
1078
|
+
return "000000".substring(string.length) + string;
|
|
1079
|
+
};
|
|
1080
|
+
convert.hex.rgb = function(args) {
|
|
1081
|
+
const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
|
|
1082
|
+
if (!match) {
|
|
1083
|
+
return [0, 0, 0];
|
|
1084
|
+
}
|
|
1085
|
+
let colorString = match[0];
|
|
1086
|
+
if (match[0].length === 3) {
|
|
1087
|
+
colorString = colorString.split("").map((char) => {
|
|
1088
|
+
return char + char;
|
|
1089
|
+
}).join("");
|
|
1090
|
+
}
|
|
1091
|
+
const integer = parseInt(colorString, 16);
|
|
1092
|
+
const r = integer >> 16 & 255;
|
|
1093
|
+
const g = integer >> 8 & 255;
|
|
1094
|
+
const b = integer & 255;
|
|
1095
|
+
return [r, g, b];
|
|
1096
|
+
};
|
|
1097
|
+
convert.rgb.hcg = function(rgb) {
|
|
1098
|
+
const r = rgb[0] / 255;
|
|
1099
|
+
const g = rgb[1] / 255;
|
|
1100
|
+
const b = rgb[2] / 255;
|
|
1101
|
+
const max = Math.max(Math.max(r, g), b);
|
|
1102
|
+
const min = Math.min(Math.min(r, g), b);
|
|
1103
|
+
const chroma = max - min;
|
|
1104
|
+
let grayscale;
|
|
1105
|
+
let hue;
|
|
1106
|
+
if (chroma < 1) {
|
|
1107
|
+
grayscale = min / (1 - chroma);
|
|
1108
|
+
} else {
|
|
1109
|
+
grayscale = 0;
|
|
1110
|
+
}
|
|
1111
|
+
if (chroma <= 0) {
|
|
1112
|
+
hue = 0;
|
|
1113
|
+
} else if (max === r) {
|
|
1114
|
+
hue = (g - b) / chroma % 6;
|
|
1115
|
+
} else if (max === g) {
|
|
1116
|
+
hue = 2 + (b - r) / chroma;
|
|
1117
|
+
} else {
|
|
1118
|
+
hue = 4 + (r - g) / chroma;
|
|
1119
|
+
}
|
|
1120
|
+
hue /= 6;
|
|
1121
|
+
hue %= 1;
|
|
1122
|
+
return [hue * 360, chroma * 100, grayscale * 100];
|
|
1123
|
+
};
|
|
1124
|
+
convert.hsl.hcg = function(hsl) {
|
|
1125
|
+
const s = hsl[1] / 100;
|
|
1126
|
+
const l = hsl[2] / 100;
|
|
1127
|
+
const c = l < 0.5 ? 2 * s * l : 2 * s * (1 - l);
|
|
1128
|
+
let f = 0;
|
|
1129
|
+
if (c < 1) {
|
|
1130
|
+
f = (l - 0.5 * c) / (1 - c);
|
|
1131
|
+
}
|
|
1132
|
+
return [hsl[0], c * 100, f * 100];
|
|
1133
|
+
};
|
|
1134
|
+
convert.hsv.hcg = function(hsv) {
|
|
1135
|
+
const s = hsv[1] / 100;
|
|
1136
|
+
const v = hsv[2] / 100;
|
|
1137
|
+
const c = s * v;
|
|
1138
|
+
let f = 0;
|
|
1139
|
+
if (c < 1) {
|
|
1140
|
+
f = (v - c) / (1 - c);
|
|
1141
|
+
}
|
|
1142
|
+
return [hsv[0], c * 100, f * 100];
|
|
1143
|
+
};
|
|
1144
|
+
convert.hcg.rgb = function(hcg) {
|
|
1145
|
+
const h = hcg[0] / 360;
|
|
1146
|
+
const c = hcg[1] / 100;
|
|
1147
|
+
const g = hcg[2] / 100;
|
|
1148
|
+
if (c === 0) {
|
|
1149
|
+
return [g * 255, g * 255, g * 255];
|
|
1150
|
+
}
|
|
1151
|
+
const pure = [0, 0, 0];
|
|
1152
|
+
const hi = h % 1 * 6;
|
|
1153
|
+
const v = hi % 1;
|
|
1154
|
+
const w = 1 - v;
|
|
1155
|
+
let mg = 0;
|
|
1156
|
+
switch (Math.floor(hi)) {
|
|
1157
|
+
case 0:
|
|
1158
|
+
pure[0] = 1;
|
|
1159
|
+
pure[1] = v;
|
|
1160
|
+
pure[2] = 0;
|
|
1161
|
+
break;
|
|
1162
|
+
case 1:
|
|
1163
|
+
pure[0] = w;
|
|
1164
|
+
pure[1] = 1;
|
|
1165
|
+
pure[2] = 0;
|
|
1166
|
+
break;
|
|
1167
|
+
case 2:
|
|
1168
|
+
pure[0] = 0;
|
|
1169
|
+
pure[1] = 1;
|
|
1170
|
+
pure[2] = v;
|
|
1171
|
+
break;
|
|
1172
|
+
case 3:
|
|
1173
|
+
pure[0] = 0;
|
|
1174
|
+
pure[1] = w;
|
|
1175
|
+
pure[2] = 1;
|
|
1176
|
+
break;
|
|
1177
|
+
case 4:
|
|
1178
|
+
pure[0] = v;
|
|
1179
|
+
pure[1] = 0;
|
|
1180
|
+
pure[2] = 1;
|
|
1181
|
+
break;
|
|
1182
|
+
default:
|
|
1183
|
+
pure[0] = 1;
|
|
1184
|
+
pure[1] = 0;
|
|
1185
|
+
pure[2] = w;
|
|
1186
|
+
}
|
|
1187
|
+
mg = (1 - c) * g;
|
|
1188
|
+
return [
|
|
1189
|
+
(c * pure[0] + mg) * 255,
|
|
1190
|
+
(c * pure[1] + mg) * 255,
|
|
1191
|
+
(c * pure[2] + mg) * 255
|
|
1192
|
+
];
|
|
1193
|
+
};
|
|
1194
|
+
convert.hcg.hsv = function(hcg) {
|
|
1195
|
+
const c = hcg[1] / 100;
|
|
1196
|
+
const g = hcg[2] / 100;
|
|
1197
|
+
const v = c + g * (1 - c);
|
|
1198
|
+
let f = 0;
|
|
1199
|
+
if (v > 0) {
|
|
1200
|
+
f = c / v;
|
|
1201
|
+
}
|
|
1202
|
+
return [hcg[0], f * 100, v * 100];
|
|
1203
|
+
};
|
|
1204
|
+
convert.hcg.hsl = function(hcg) {
|
|
1205
|
+
const c = hcg[1] / 100;
|
|
1206
|
+
const g = hcg[2] / 100;
|
|
1207
|
+
const l = g * (1 - c) + 0.5 * c;
|
|
1208
|
+
let s = 0;
|
|
1209
|
+
if (l > 0 && l < 0.5) {
|
|
1210
|
+
s = c / (2 * l);
|
|
1211
|
+
} else if (l >= 0.5 && l < 1) {
|
|
1212
|
+
s = c / (2 * (1 - l));
|
|
1213
|
+
}
|
|
1214
|
+
return [hcg[0], s * 100, l * 100];
|
|
1215
|
+
};
|
|
1216
|
+
convert.hcg.hwb = function(hcg) {
|
|
1217
|
+
const c = hcg[1] / 100;
|
|
1218
|
+
const g = hcg[2] / 100;
|
|
1219
|
+
const v = c + g * (1 - c);
|
|
1220
|
+
return [hcg[0], (v - c) * 100, (1 - v) * 100];
|
|
1221
|
+
};
|
|
1222
|
+
convert.hwb.hcg = function(hwb) {
|
|
1223
|
+
const w = hwb[1] / 100;
|
|
1224
|
+
const b = hwb[2] / 100;
|
|
1225
|
+
const v = 1 - b;
|
|
1226
|
+
const c = v - w;
|
|
1227
|
+
let g = 0;
|
|
1228
|
+
if (c < 1) {
|
|
1229
|
+
g = (v - c) / (1 - c);
|
|
1230
|
+
}
|
|
1231
|
+
return [hwb[0], c * 100, g * 100];
|
|
1232
|
+
};
|
|
1233
|
+
convert.apple.rgb = function(apple) {
|
|
1234
|
+
return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
|
|
1235
|
+
};
|
|
1236
|
+
convert.rgb.apple = function(rgb) {
|
|
1237
|
+
return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
|
|
1238
|
+
};
|
|
1239
|
+
convert.gray.rgb = function(args) {
|
|
1240
|
+
return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
|
|
1241
|
+
};
|
|
1242
|
+
convert.gray.hsl = function(args) {
|
|
1243
|
+
return [0, 0, args[0]];
|
|
1244
|
+
};
|
|
1245
|
+
convert.gray.hsv = convert.gray.hsl;
|
|
1246
|
+
convert.gray.hwb = function(gray) {
|
|
1247
|
+
return [0, 100, gray[0]];
|
|
1248
|
+
};
|
|
1249
|
+
convert.gray.cmyk = function(gray) {
|
|
1250
|
+
return [0, 0, 0, gray[0]];
|
|
1251
|
+
};
|
|
1252
|
+
convert.gray.lab = function(gray) {
|
|
1253
|
+
return [gray[0], 0, 0];
|
|
1254
|
+
};
|
|
1255
|
+
convert.gray.hex = function(gray) {
|
|
1256
|
+
const val = Math.round(gray[0] / 100 * 255) & 255;
|
|
1257
|
+
const integer = (val << 16) + (val << 8) + val;
|
|
1258
|
+
const string = integer.toString(16).toUpperCase();
|
|
1259
|
+
return "000000".substring(string.length) + string;
|
|
1260
|
+
};
|
|
1261
|
+
convert.rgb.gray = function(rgb) {
|
|
1262
|
+
const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
|
|
1263
|
+
return [val / 255 * 100];
|
|
1264
|
+
};
|
|
1265
|
+
return conversions$1;
|
|
1266
|
+
}
|
|
1267
|
+
var route$1;
|
|
1268
|
+
var hasRequiredRoute$1;
|
|
1269
|
+
function requireRoute$1() {
|
|
1270
|
+
if (hasRequiredRoute$1) return route$1;
|
|
1271
|
+
hasRequiredRoute$1 = 1;
|
|
1272
|
+
const conversions2 = requireConversions$1();
|
|
1273
|
+
function buildGraph() {
|
|
1274
|
+
const graph = {};
|
|
1275
|
+
const models = Object.keys(conversions2);
|
|
1276
|
+
for (let len = models.length, i = 0; i < len; i++) {
|
|
1277
|
+
graph[models[i]] = {
|
|
1278
|
+
// http://jsperf.com/1-vs-infinity
|
|
1279
|
+
// micro-opt, but this is simple.
|
|
1280
|
+
distance: -1,
|
|
1281
|
+
parent: null
|
|
1282
|
+
};
|
|
1283
|
+
}
|
|
1284
|
+
return graph;
|
|
1285
|
+
}
|
|
1286
|
+
function deriveBFS(fromModel) {
|
|
1287
|
+
const graph = buildGraph();
|
|
1288
|
+
const queue = [fromModel];
|
|
1289
|
+
graph[fromModel].distance = 0;
|
|
1290
|
+
while (queue.length) {
|
|
1291
|
+
const current = queue.pop();
|
|
1292
|
+
const adjacents = Object.keys(conversions2[current]);
|
|
1293
|
+
for (let len = adjacents.length, i = 0; i < len; i++) {
|
|
1294
|
+
const adjacent = adjacents[i];
|
|
1295
|
+
const node = graph[adjacent];
|
|
1296
|
+
if (node.distance === -1) {
|
|
1297
|
+
node.distance = graph[current].distance + 1;
|
|
1298
|
+
node.parent = current;
|
|
1299
|
+
queue.unshift(adjacent);
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
return graph;
|
|
1304
|
+
}
|
|
1305
|
+
function link(from, to) {
|
|
1306
|
+
return function(args) {
|
|
1307
|
+
return to(from(args));
|
|
1308
|
+
};
|
|
1309
|
+
}
|
|
1310
|
+
function wrapConversion(toModel, graph) {
|
|
1311
|
+
const path2 = [graph[toModel].parent, toModel];
|
|
1312
|
+
let fn = conversions2[graph[toModel].parent][toModel];
|
|
1313
|
+
let cur = graph[toModel].parent;
|
|
1314
|
+
while (graph[cur].parent) {
|
|
1315
|
+
path2.unshift(graph[cur].parent);
|
|
1316
|
+
fn = link(conversions2[graph[cur].parent][cur], fn);
|
|
1317
|
+
cur = graph[cur].parent;
|
|
1318
|
+
}
|
|
1319
|
+
fn.conversion = path2;
|
|
1320
|
+
return fn;
|
|
1321
|
+
}
|
|
1322
|
+
route$1 = function(fromModel) {
|
|
1323
|
+
const graph = deriveBFS(fromModel);
|
|
1324
|
+
const conversion = {};
|
|
1325
|
+
const models = Object.keys(graph);
|
|
1326
|
+
for (let len = models.length, i = 0; i < len; i++) {
|
|
1327
|
+
const toModel = models[i];
|
|
1328
|
+
const node = graph[toModel];
|
|
1329
|
+
if (node.parent === null) {
|
|
1330
|
+
continue;
|
|
1331
|
+
}
|
|
1332
|
+
conversion[toModel] = wrapConversion(toModel, graph);
|
|
1333
|
+
}
|
|
1334
|
+
return conversion;
|
|
1335
|
+
};
|
|
1336
|
+
return route$1;
|
|
1337
|
+
}
|
|
1338
|
+
var colorConvert$1;
|
|
1339
|
+
var hasRequiredColorConvert$1;
|
|
1340
|
+
function requireColorConvert$1() {
|
|
1341
|
+
if (hasRequiredColorConvert$1) return colorConvert$1;
|
|
1342
|
+
hasRequiredColorConvert$1 = 1;
|
|
1343
|
+
const conversions2 = requireConversions$1();
|
|
1344
|
+
const route2 = requireRoute$1();
|
|
1345
|
+
const convert = {};
|
|
1346
|
+
const models = Object.keys(conversions2);
|
|
1347
|
+
function wrapRaw(fn) {
|
|
1348
|
+
const wrappedFn = function(...args) {
|
|
1349
|
+
const arg0 = args[0];
|
|
1350
|
+
if (arg0 === void 0 || arg0 === null) {
|
|
1351
|
+
return arg0;
|
|
1352
|
+
}
|
|
1353
|
+
if (arg0.length > 1) {
|
|
1354
|
+
args = arg0;
|
|
1355
|
+
}
|
|
1356
|
+
return fn(args);
|
|
1357
|
+
};
|
|
1358
|
+
if ("conversion" in fn) {
|
|
1359
|
+
wrappedFn.conversion = fn.conversion;
|
|
1360
|
+
}
|
|
1361
|
+
return wrappedFn;
|
|
1362
|
+
}
|
|
1363
|
+
function wrapRounded(fn) {
|
|
1364
|
+
const wrappedFn = function(...args) {
|
|
1365
|
+
const arg0 = args[0];
|
|
1366
|
+
if (arg0 === void 0 || arg0 === null) {
|
|
1367
|
+
return arg0;
|
|
1368
|
+
}
|
|
1369
|
+
if (arg0.length > 1) {
|
|
1370
|
+
args = arg0;
|
|
1371
|
+
}
|
|
1372
|
+
const result = fn(args);
|
|
1373
|
+
if (typeof result === "object") {
|
|
1374
|
+
for (let len = result.length, i = 0; i < len; i++) {
|
|
1375
|
+
result[i] = Math.round(result[i]);
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
return result;
|
|
1379
|
+
};
|
|
1380
|
+
if ("conversion" in fn) {
|
|
1381
|
+
wrappedFn.conversion = fn.conversion;
|
|
1382
|
+
}
|
|
1383
|
+
return wrappedFn;
|
|
1384
|
+
}
|
|
1385
|
+
models.forEach((fromModel) => {
|
|
1386
|
+
convert[fromModel] = {};
|
|
1387
|
+
Object.defineProperty(convert[fromModel], "channels", { value: conversions2[fromModel].channels });
|
|
1388
|
+
Object.defineProperty(convert[fromModel], "labels", { value: conversions2[fromModel].labels });
|
|
1389
|
+
const routes = route2(fromModel);
|
|
1390
|
+
const routeModels = Object.keys(routes);
|
|
1391
|
+
routeModels.forEach((toModel) => {
|
|
1392
|
+
const fn = routes[toModel];
|
|
1393
|
+
convert[fromModel][toModel] = wrapRounded(fn);
|
|
1394
|
+
convert[fromModel][toModel].raw = wrapRaw(fn);
|
|
1395
|
+
});
|
|
1396
|
+
});
|
|
1397
|
+
colorConvert$1 = convert;
|
|
1398
|
+
return colorConvert$1;
|
|
1399
|
+
}
|
|
1400
|
+
ansiStyles$1$1.exports;
|
|
1401
|
+
(function(module) {
|
|
1402
|
+
const wrapAnsi16 = (fn, offset) => (...args) => {
|
|
1403
|
+
const code = fn(...args);
|
|
1404
|
+
return `\x1B[${code + offset}m`;
|
|
1405
|
+
};
|
|
1406
|
+
const wrapAnsi256 = (fn, offset) => (...args) => {
|
|
1407
|
+
const code = fn(...args);
|
|
1408
|
+
return `\x1B[${38 + offset};5;${code}m`;
|
|
1409
|
+
};
|
|
1410
|
+
const wrapAnsi16m = (fn, offset) => (...args) => {
|
|
1411
|
+
const rgb = fn(...args);
|
|
1412
|
+
return `\x1B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
|
|
1413
|
+
};
|
|
1414
|
+
const ansi2ansi = (n) => n;
|
|
1415
|
+
const rgb2rgb = (r, g, b) => [r, g, b];
|
|
1416
|
+
const setLazyProperty = (object, property, get) => {
|
|
1417
|
+
Object.defineProperty(object, property, {
|
|
1418
|
+
get: () => {
|
|
1419
|
+
const value = get();
|
|
1420
|
+
Object.defineProperty(object, property, {
|
|
1421
|
+
value,
|
|
1422
|
+
enumerable: true,
|
|
1423
|
+
configurable: true
|
|
1424
|
+
});
|
|
1425
|
+
return value;
|
|
1426
|
+
},
|
|
1427
|
+
enumerable: true,
|
|
1428
|
+
configurable: true
|
|
1429
|
+
});
|
|
1430
|
+
};
|
|
1431
|
+
let colorConvert2;
|
|
1432
|
+
const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
|
|
1433
|
+
if (colorConvert2 === void 0) {
|
|
1434
|
+
colorConvert2 = requireColorConvert$1();
|
|
1435
|
+
}
|
|
1436
|
+
const offset = isBackground ? 10 : 0;
|
|
1437
|
+
const styles2 = {};
|
|
1438
|
+
for (const [sourceSpace, suite] of Object.entries(colorConvert2)) {
|
|
1439
|
+
const name2 = sourceSpace === "ansi16" ? "ansi" : sourceSpace;
|
|
1440
|
+
if (sourceSpace === targetSpace) {
|
|
1441
|
+
styles2[name2] = wrap(identity, offset);
|
|
1442
|
+
} else if (typeof suite === "object") {
|
|
1443
|
+
styles2[name2] = wrap(suite[targetSpace], offset);
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
return styles2;
|
|
1447
|
+
};
|
|
1448
|
+
function assembleStyles() {
|
|
1449
|
+
const codes = /* @__PURE__ */ new Map();
|
|
1450
|
+
const styles2 = {
|
|
1451
|
+
modifier: {
|
|
1452
|
+
reset: [0, 0],
|
|
1453
|
+
// 21 isn't widely supported and 22 does the same thing
|
|
1454
|
+
bold: [1, 22],
|
|
1455
|
+
dim: [2, 22],
|
|
1456
|
+
italic: [3, 23],
|
|
1457
|
+
underline: [4, 24],
|
|
1458
|
+
inverse: [7, 27],
|
|
1459
|
+
hidden: [8, 28],
|
|
1460
|
+
strikethrough: [9, 29]
|
|
1461
|
+
},
|
|
1462
|
+
color: {
|
|
1463
|
+
black: [30, 39],
|
|
1464
|
+
red: [31, 39],
|
|
1465
|
+
green: [32, 39],
|
|
1466
|
+
yellow: [33, 39],
|
|
1467
|
+
blue: [34, 39],
|
|
1468
|
+
magenta: [35, 39],
|
|
1469
|
+
cyan: [36, 39],
|
|
1470
|
+
white: [37, 39],
|
|
1471
|
+
// Bright color
|
|
1472
|
+
blackBright: [90, 39],
|
|
1473
|
+
redBright: [91, 39],
|
|
1474
|
+
greenBright: [92, 39],
|
|
1475
|
+
yellowBright: [93, 39],
|
|
1476
|
+
blueBright: [94, 39],
|
|
1477
|
+
magentaBright: [95, 39],
|
|
1478
|
+
cyanBright: [96, 39],
|
|
1479
|
+
whiteBright: [97, 39]
|
|
1480
|
+
},
|
|
1481
|
+
bgColor: {
|
|
1482
|
+
bgBlack: [40, 49],
|
|
1483
|
+
bgRed: [41, 49],
|
|
1484
|
+
bgGreen: [42, 49],
|
|
1485
|
+
bgYellow: [43, 49],
|
|
1486
|
+
bgBlue: [44, 49],
|
|
1487
|
+
bgMagenta: [45, 49],
|
|
1488
|
+
bgCyan: [46, 49],
|
|
1489
|
+
bgWhite: [47, 49],
|
|
1490
|
+
// Bright color
|
|
1491
|
+
bgBlackBright: [100, 49],
|
|
1492
|
+
bgRedBright: [101, 49],
|
|
1493
|
+
bgGreenBright: [102, 49],
|
|
1494
|
+
bgYellowBright: [103, 49],
|
|
1495
|
+
bgBlueBright: [104, 49],
|
|
1496
|
+
bgMagentaBright: [105, 49],
|
|
1497
|
+
bgCyanBright: [106, 49],
|
|
1498
|
+
bgWhiteBright: [107, 49]
|
|
1499
|
+
}
|
|
1500
|
+
};
|
|
1501
|
+
styles2.color.gray = styles2.color.blackBright;
|
|
1502
|
+
styles2.bgColor.bgGray = styles2.bgColor.bgBlackBright;
|
|
1503
|
+
styles2.color.grey = styles2.color.blackBright;
|
|
1504
|
+
styles2.bgColor.bgGrey = styles2.bgColor.bgBlackBright;
|
|
1505
|
+
for (const [groupName, group] of Object.entries(styles2)) {
|
|
1506
|
+
for (const [styleName, style] of Object.entries(group)) {
|
|
1507
|
+
styles2[styleName] = {
|
|
1508
|
+
open: `\x1B[${style[0]}m`,
|
|
1509
|
+
close: `\x1B[${style[1]}m`
|
|
1510
|
+
};
|
|
1511
|
+
group[styleName] = styles2[styleName];
|
|
1512
|
+
codes.set(style[0], style[1]);
|
|
1513
|
+
}
|
|
1514
|
+
Object.defineProperty(styles2, groupName, {
|
|
1515
|
+
value: group,
|
|
1516
|
+
enumerable: false
|
|
1517
|
+
});
|
|
1518
|
+
}
|
|
1519
|
+
Object.defineProperty(styles2, "codes", {
|
|
1520
|
+
value: codes,
|
|
1521
|
+
enumerable: false
|
|
1522
|
+
});
|
|
1523
|
+
styles2.color.close = "\x1B[39m";
|
|
1524
|
+
styles2.bgColor.close = "\x1B[49m";
|
|
1525
|
+
setLazyProperty(styles2.color, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, false));
|
|
1526
|
+
setLazyProperty(styles2.color, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, false));
|
|
1527
|
+
setLazyProperty(styles2.color, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, false));
|
|
1528
|
+
setLazyProperty(styles2.bgColor, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, true));
|
|
1529
|
+
setLazyProperty(styles2.bgColor, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, true));
|
|
1530
|
+
setLazyProperty(styles2.bgColor, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, true));
|
|
1531
|
+
return styles2;
|
|
1532
|
+
}
|
|
1533
|
+
Object.defineProperty(module, "exports", {
|
|
1534
|
+
enumerable: true,
|
|
1535
|
+
get: assembleStyles
|
|
1536
|
+
});
|
|
1537
|
+
})(ansiStyles$1$1);
|
|
1538
|
+
var ansiStylesExports$1 = ansiStyles$1$1.exports;
|
|
1539
|
+
var browser$1 = {
|
|
1540
|
+
stdout: false,
|
|
1541
|
+
stderr: false
|
|
1542
|
+
};
|
|
1543
|
+
const stringReplaceAll$1$1 = (string, substring, replacer) => {
|
|
1544
|
+
let index = string.indexOf(substring);
|
|
1545
|
+
if (index === -1) {
|
|
1546
|
+
return string;
|
|
1547
|
+
}
|
|
1548
|
+
const substringLength = substring.length;
|
|
1549
|
+
let endIndex = 0;
|
|
1550
|
+
let returnValue = "";
|
|
1551
|
+
do {
|
|
1552
|
+
returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
|
|
1553
|
+
endIndex = index + substringLength;
|
|
1554
|
+
index = string.indexOf(substring, endIndex);
|
|
1555
|
+
} while (index !== -1);
|
|
1556
|
+
returnValue += string.substr(endIndex);
|
|
1557
|
+
return returnValue;
|
|
1558
|
+
};
|
|
1559
|
+
const stringEncaseCRLFWithFirstIndex$1$1 = (string, prefix, postfix, index) => {
|
|
1560
|
+
let endIndex = 0;
|
|
1561
|
+
let returnValue = "";
|
|
1562
|
+
do {
|
|
1563
|
+
const gotCR = string[index - 1] === "\r";
|
|
1564
|
+
returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
|
|
1565
|
+
endIndex = index + 1;
|
|
1566
|
+
index = string.indexOf("\n", endIndex);
|
|
1567
|
+
} while (index !== -1);
|
|
1568
|
+
returnValue += string.substr(endIndex);
|
|
1569
|
+
return returnValue;
|
|
1570
|
+
};
|
|
1571
|
+
var util$1 = {
|
|
1572
|
+
stringReplaceAll: stringReplaceAll$1$1,
|
|
1573
|
+
stringEncaseCRLFWithFirstIndex: stringEncaseCRLFWithFirstIndex$1$1
|
|
1574
|
+
};
|
|
1575
|
+
var templates$1;
|
|
1576
|
+
var hasRequiredTemplates$1;
|
|
1577
|
+
function requireTemplates$1() {
|
|
1578
|
+
if (hasRequiredTemplates$1) return templates$1;
|
|
1579
|
+
hasRequiredTemplates$1 = 1;
|
|
1580
|
+
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;
|
|
1581
|
+
const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
|
|
1582
|
+
const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
|
|
1583
|
+
const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
|
|
1584
|
+
const ESCAPES = /* @__PURE__ */ new Map([
|
|
1585
|
+
["n", "\n"],
|
|
1586
|
+
["r", "\r"],
|
|
1587
|
+
["t", " "],
|
|
1588
|
+
["b", "\b"],
|
|
1589
|
+
["f", "\f"],
|
|
1590
|
+
["v", "\v"],
|
|
1591
|
+
["0", "\0"],
|
|
1592
|
+
["\\", "\\"],
|
|
1593
|
+
["e", "\x1B"],
|
|
1594
|
+
["a", "\x07"]
|
|
1595
|
+
]);
|
|
1596
|
+
function unescape(c) {
|
|
1597
|
+
const u = c[0] === "u";
|
|
1598
|
+
const bracket = c[1] === "{";
|
|
1599
|
+
if (u && !bracket && c.length === 5 || c[0] === "x" && c.length === 3) {
|
|
1600
|
+
return String.fromCharCode(parseInt(c.slice(1), 16));
|
|
1601
|
+
}
|
|
1602
|
+
if (u && bracket) {
|
|
1603
|
+
return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
|
|
1604
|
+
}
|
|
1605
|
+
return ESCAPES.get(c) || c;
|
|
1606
|
+
}
|
|
1607
|
+
function parseArguments(name2, arguments_) {
|
|
1608
|
+
const results = [];
|
|
1609
|
+
const chunks = arguments_.trim().split(/\s*,\s*/g);
|
|
1610
|
+
let matches;
|
|
1611
|
+
for (const chunk of chunks) {
|
|
1612
|
+
const number = Number(chunk);
|
|
1613
|
+
if (!Number.isNaN(number)) {
|
|
1614
|
+
results.push(number);
|
|
1615
|
+
} else if (matches = chunk.match(STRING_REGEX)) {
|
|
1616
|
+
results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape(escape) : character));
|
|
1617
|
+
} else {
|
|
1618
|
+
throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name2}')`);
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
return results;
|
|
1622
|
+
}
|
|
1623
|
+
function parseStyle(style) {
|
|
1624
|
+
STYLE_REGEX.lastIndex = 0;
|
|
1625
|
+
const results = [];
|
|
1626
|
+
let matches;
|
|
1627
|
+
while ((matches = STYLE_REGEX.exec(style)) !== null) {
|
|
1628
|
+
const name2 = matches[1];
|
|
1629
|
+
if (matches[2]) {
|
|
1630
|
+
const args = parseArguments(name2, matches[2]);
|
|
1631
|
+
results.push([name2].concat(args));
|
|
1632
|
+
} else {
|
|
1633
|
+
results.push([name2]);
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1636
|
+
return results;
|
|
1637
|
+
}
|
|
1638
|
+
function buildStyle(chalk2, styles2) {
|
|
1639
|
+
const enabled = {};
|
|
1640
|
+
for (const layer of styles2) {
|
|
1641
|
+
for (const style of layer.styles) {
|
|
1642
|
+
enabled[style[0]] = layer.inverse ? null : style.slice(1);
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
let current = chalk2;
|
|
1646
|
+
for (const [styleName, styles3] of Object.entries(enabled)) {
|
|
1647
|
+
if (!Array.isArray(styles3)) {
|
|
1648
|
+
continue;
|
|
1649
|
+
}
|
|
1650
|
+
if (!(styleName in current)) {
|
|
1651
|
+
throw new Error(`Unknown Chalk style: ${styleName}`);
|
|
1652
|
+
}
|
|
1653
|
+
current = styles3.length > 0 ? current[styleName](...styles3) : current[styleName];
|
|
1654
|
+
}
|
|
1655
|
+
return current;
|
|
1656
|
+
}
|
|
1657
|
+
templates$1 = (chalk2, temporary) => {
|
|
1658
|
+
const styles2 = [];
|
|
1659
|
+
const chunks = [];
|
|
1660
|
+
let chunk = [];
|
|
1661
|
+
temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
|
|
1662
|
+
if (escapeCharacter) {
|
|
1663
|
+
chunk.push(unescape(escapeCharacter));
|
|
1664
|
+
} else if (style) {
|
|
1665
|
+
const string = chunk.join("");
|
|
1666
|
+
chunk = [];
|
|
1667
|
+
chunks.push(styles2.length === 0 ? string : buildStyle(chalk2, styles2)(string));
|
|
1668
|
+
styles2.push({ inverse, styles: parseStyle(style) });
|
|
1669
|
+
} else if (close) {
|
|
1670
|
+
if (styles2.length === 0) {
|
|
1671
|
+
throw new Error("Found extraneous } in Chalk template literal");
|
|
1672
|
+
}
|
|
1673
|
+
chunks.push(buildStyle(chalk2, styles2)(chunk.join("")));
|
|
1674
|
+
chunk = [];
|
|
1675
|
+
styles2.pop();
|
|
1676
|
+
} else {
|
|
1677
|
+
chunk.push(character);
|
|
1678
|
+
}
|
|
1679
|
+
});
|
|
1680
|
+
chunks.push(chunk.join(""));
|
|
1681
|
+
if (styles2.length > 0) {
|
|
1682
|
+
const errMessage = `Chalk template literal is missing ${styles2.length} closing bracket${styles2.length === 1 ? "" : "s"} (\`}\`)`;
|
|
1683
|
+
throw new Error(errMessage);
|
|
1684
|
+
}
|
|
1685
|
+
return chunks.join("");
|
|
1686
|
+
};
|
|
1687
|
+
return templates$1;
|
|
1688
|
+
}
|
|
1689
|
+
const ansiStyles$2 = ansiStylesExports$1;
|
|
1690
|
+
const { stdout: stdoutColor$1, stderr: stderrColor$1 } = browser$1;
|
|
1691
|
+
const {
|
|
1692
|
+
stringReplaceAll: stringReplaceAll$2,
|
|
1693
|
+
stringEncaseCRLFWithFirstIndex: stringEncaseCRLFWithFirstIndex$2
|
|
1694
|
+
} = util$1;
|
|
1695
|
+
const { isArray: isArray$1 } = Array;
|
|
1696
|
+
const levelMapping$1 = [
|
|
1697
|
+
"ansi",
|
|
1698
|
+
"ansi",
|
|
1699
|
+
"ansi256",
|
|
1700
|
+
"ansi16m"
|
|
1701
|
+
];
|
|
1702
|
+
const styles$1 = /* @__PURE__ */ Object.create(null);
|
|
1703
|
+
const applyOptions$1 = (object, options = {}) => {
|
|
1704
|
+
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
|
1705
|
+
throw new Error("The `level` option should be an integer from 0 to 3");
|
|
1706
|
+
}
|
|
1707
|
+
const colorLevel = stdoutColor$1 ? stdoutColor$1.level : 0;
|
|
1708
|
+
object.level = options.level === void 0 ? colorLevel : options.level;
|
|
1709
|
+
};
|
|
1710
|
+
let ChalkClass$1 = class ChalkClass {
|
|
1711
|
+
constructor(options) {
|
|
1712
|
+
return chalkFactory$1(options);
|
|
1713
|
+
}
|
|
1714
|
+
};
|
|
1715
|
+
const chalkFactory$1 = (options) => {
|
|
1716
|
+
const chalk2 = {};
|
|
1717
|
+
applyOptions$1(chalk2, options);
|
|
1718
|
+
chalk2.template = (...arguments_) => chalkTag$1(chalk2.template, ...arguments_);
|
|
1719
|
+
Object.setPrototypeOf(chalk2, Chalk$1.prototype);
|
|
1720
|
+
Object.setPrototypeOf(chalk2.template, chalk2);
|
|
1721
|
+
chalk2.template.constructor = () => {
|
|
1722
|
+
throw new Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.");
|
|
1723
|
+
};
|
|
1724
|
+
chalk2.template.Instance = ChalkClass$1;
|
|
1725
|
+
return chalk2.template;
|
|
1726
|
+
};
|
|
1727
|
+
function Chalk$1(options) {
|
|
1728
|
+
return chalkFactory$1(options);
|
|
1729
|
+
}
|
|
1730
|
+
for (const [styleName, style] of Object.entries(ansiStyles$2)) {
|
|
1731
|
+
styles$1[styleName] = {
|
|
1732
|
+
get() {
|
|
1733
|
+
const builder = createBuilder$1(this, createStyler$1(style.open, style.close, this._styler), this._isEmpty);
|
|
1734
|
+
Object.defineProperty(this, styleName, { value: builder });
|
|
1735
|
+
return builder;
|
|
1736
|
+
}
|
|
1737
|
+
};
|
|
1738
|
+
}
|
|
1739
|
+
styles$1.visible = {
|
|
1740
|
+
get() {
|
|
1741
|
+
const builder = createBuilder$1(this, this._styler, true);
|
|
1742
|
+
Object.defineProperty(this, "visible", { value: builder });
|
|
1743
|
+
return builder;
|
|
1744
|
+
}
|
|
1745
|
+
};
|
|
1746
|
+
const usedModels$1 = ["rgb", "hex", "keyword", "hsl", "hsv", "hwb", "ansi", "ansi256"];
|
|
1747
|
+
for (const model of usedModels$1) {
|
|
1748
|
+
styles$1[model] = {
|
|
1749
|
+
get() {
|
|
1750
|
+
const { level } = this;
|
|
1751
|
+
return function(...arguments_) {
|
|
1752
|
+
const styler = createStyler$1(ansiStyles$2.color[levelMapping$1[level]][model](...arguments_), ansiStyles$2.color.close, this._styler);
|
|
1753
|
+
return createBuilder$1(this, styler, this._isEmpty);
|
|
1754
|
+
};
|
|
1755
|
+
}
|
|
1756
|
+
};
|
|
1757
|
+
}
|
|
1758
|
+
for (const model of usedModels$1) {
|
|
1759
|
+
const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
|
|
1760
|
+
styles$1[bgModel] = {
|
|
1761
|
+
get() {
|
|
1762
|
+
const { level } = this;
|
|
1763
|
+
return function(...arguments_) {
|
|
1764
|
+
const styler = createStyler$1(ansiStyles$2.bgColor[levelMapping$1[level]][model](...arguments_), ansiStyles$2.bgColor.close, this._styler);
|
|
1765
|
+
return createBuilder$1(this, styler, this._isEmpty);
|
|
1766
|
+
};
|
|
1767
|
+
}
|
|
1768
|
+
};
|
|
1769
|
+
}
|
|
1770
|
+
const proto$1 = Object.defineProperties(() => {
|
|
1771
|
+
}, {
|
|
1772
|
+
...styles$1,
|
|
1773
|
+
level: {
|
|
1774
|
+
enumerable: true,
|
|
1775
|
+
get() {
|
|
1776
|
+
return this._generator.level;
|
|
1777
|
+
},
|
|
1778
|
+
set(level) {
|
|
1779
|
+
this._generator.level = level;
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
});
|
|
1783
|
+
const createStyler$1 = (open, close, parent) => {
|
|
1784
|
+
let openAll;
|
|
1785
|
+
let closeAll;
|
|
1786
|
+
if (parent === void 0) {
|
|
1787
|
+
openAll = open;
|
|
1788
|
+
closeAll = close;
|
|
1789
|
+
} else {
|
|
1790
|
+
openAll = parent.openAll + open;
|
|
1791
|
+
closeAll = close + parent.closeAll;
|
|
1792
|
+
}
|
|
1793
|
+
return {
|
|
1794
|
+
open,
|
|
1795
|
+
close,
|
|
1796
|
+
openAll,
|
|
1797
|
+
closeAll,
|
|
1798
|
+
parent
|
|
1799
|
+
};
|
|
1800
|
+
};
|
|
1801
|
+
const createBuilder$1 = (self, _styler, _isEmpty) => {
|
|
1802
|
+
const builder = (...arguments_) => {
|
|
1803
|
+
if (isArray$1(arguments_[0]) && isArray$1(arguments_[0].raw)) {
|
|
1804
|
+
return applyStyle$1(builder, chalkTag$1(builder, ...arguments_));
|
|
1805
|
+
}
|
|
1806
|
+
return applyStyle$1(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
|
|
1807
|
+
};
|
|
1808
|
+
Object.setPrototypeOf(builder, proto$1);
|
|
1809
|
+
builder._generator = self;
|
|
1810
|
+
builder._styler = _styler;
|
|
1811
|
+
builder._isEmpty = _isEmpty;
|
|
1812
|
+
return builder;
|
|
1813
|
+
};
|
|
1814
|
+
const applyStyle$1 = (self, string) => {
|
|
1815
|
+
if (self.level <= 0 || !string) {
|
|
1816
|
+
return self._isEmpty ? "" : string;
|
|
1817
|
+
}
|
|
1818
|
+
let styler = self._styler;
|
|
1819
|
+
if (styler === void 0) {
|
|
1820
|
+
return string;
|
|
1821
|
+
}
|
|
1822
|
+
const { openAll, closeAll } = styler;
|
|
1823
|
+
if (string.indexOf("\x1B") !== -1) {
|
|
1824
|
+
while (styler !== void 0) {
|
|
1825
|
+
string = stringReplaceAll$2(string, styler.close, styler.open);
|
|
1826
|
+
styler = styler.parent;
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
const lfIndex = string.indexOf("\n");
|
|
1830
|
+
if (lfIndex !== -1) {
|
|
1831
|
+
string = stringEncaseCRLFWithFirstIndex$2(string, closeAll, openAll, lfIndex);
|
|
1832
|
+
}
|
|
1833
|
+
return openAll + string + closeAll;
|
|
1834
|
+
};
|
|
1835
|
+
let template$1;
|
|
1836
|
+
const chalkTag$1 = (chalk2, ...strings) => {
|
|
1837
|
+
const [firstString] = strings;
|
|
1838
|
+
if (!isArray$1(firstString) || !isArray$1(firstString.raw)) {
|
|
1839
|
+
return strings.join(" ");
|
|
1840
|
+
}
|
|
1841
|
+
const arguments_ = strings.slice(1);
|
|
1842
|
+
const parts = [firstString.raw[0]];
|
|
1843
|
+
for (let i = 1; i < firstString.length; i++) {
|
|
1844
|
+
parts.push(
|
|
1845
|
+
String(arguments_[i - 1]).replace(/[{}\\]/g, "\\$&"),
|
|
1846
|
+
String(firstString.raw[i])
|
|
1847
|
+
);
|
|
1848
|
+
}
|
|
1849
|
+
if (template$1 === void 0) {
|
|
1850
|
+
template$1 = requireTemplates$1();
|
|
1851
|
+
}
|
|
1852
|
+
return template$1(chalk2, parts.join(""));
|
|
1853
|
+
};
|
|
1854
|
+
Object.defineProperties(Chalk$1.prototype, styles$1);
|
|
1855
|
+
const chalk$2 = Chalk$1();
|
|
1856
|
+
chalk$2.supportsColor = stdoutColor$1;
|
|
1857
|
+
chalk$2.stderr = Chalk$1({ level: stderrColor$1 ? stderrColor$1.level : 0 });
|
|
1858
|
+
chalk$2.stderr.supportsColor = stderrColor$1;
|
|
1859
|
+
const { accessSync, constants, readFileSync } = fs;
|
|
1860
|
+
const envOptions = {};
|
|
1861
|
+
function SetupConfig(envOptions2, logger) {
|
|
1862
|
+
const envfile = process.env.STSENVFILE === void 0 ? "/.env" : process.env.STSENVFILE;
|
|
1863
|
+
config_1({ path: envfile });
|
|
1864
|
+
const defconfig = {
|
|
1865
|
+
// Node runtime environment
|
|
1866
|
+
isProduction: process.env.NODE_ENV === void 0 ? false : process.env.NODE_ENV === "production" ? true : false,
|
|
1867
|
+
isTest: process.env.NODE_ENV === void 0 ? false : process.env.NODE_ENV === "test" ? true : false,
|
|
1868
|
+
dbuser: process.env.DB_USER === void 0 ? "postgres" : process.env.DB_USER,
|
|
1869
|
+
dbpassword: process.env.DB_PASSWORD === void 0 ? "postgres" : process.env.DB_PASSWORD,
|
|
1870
|
+
dbpasswordfile: process.env.DB_PASSWORD_FILE,
|
|
1871
|
+
dbhost: process.env.DB_HOST === void 0 ? "localhost:5432" : process.env.DB_HOST,
|
|
1872
|
+
database: process.env.DB_DATABASE === void 0 ? "stsrestmsdb01" : process.env.DB_DATABASE,
|
|
1873
|
+
databaseUrl: process.env.DATABASE_URL,
|
|
1874
|
+
connectionString: "",
|
|
1875
|
+
defaultDatabaseConnectionString: "",
|
|
1876
|
+
logToFile: process.env.LOG_TO_FILE === void 0 ? false : process.env.LOG_TO_FILE === "true" ? true : false,
|
|
1877
|
+
logFilePath: process.env.LOG_FILE_PATH === void 0 ? "/var/lib/sts" : process.env.LOG_FILE_PATH,
|
|
1878
|
+
logFileFormat: process.env.LOG_FILE_FORMAT === void 0 ? "csv" : process.env.LOG_FILE_FORMAT,
|
|
1879
|
+
poolSize: process.env.POOL_SIZE === void 0 ? 500 : parseInt(process.env.POOL_SIZE),
|
|
1880
|
+
useCPUs: process.env.MAX_CPU === void 0 ? -1 : parseFloat(process.env.MAX_CPU),
|
|
1881
|
+
respawnOnFail: process.env.RESPAWN === void 0 ? true : process.env.RESPAWN === "true" ? true : false,
|
|
1882
|
+
defaultDatabaseEntries: process.env.DEFAULT_DB_ENTRIES === void 0 ? 1e4 : parseInt(process.env.DEFAULT_DB_ENTRIES),
|
|
1883
|
+
useRedisDatabaseCache: process.env.USE_REDIS_DATABASE_CACHE === void 0 ? false : process.env.USE_REDIS_DATABASE_CACHE === "true" ? true : false,
|
|
1884
|
+
useSocketIoRedisAdaptor: process.env.USE_SOCKET_IO_REDIS_ADAPTOR === void 0 ? false : process.env.USE_SOCKET_IO_REDIS_ADAPTOR === "true" ? true : false,
|
|
1885
|
+
socketIoRedisAdaptorUrl: process.env.SOCKET_IO_REDIS_ADAPTOR_URL === void 0 ? "redis://localhost:6379" : process.env.SOCKET_IO_REDIS_ADAPTOR_URL,
|
|
1886
|
+
useRedisInstrumentationTransport: process.env.USE_REDIS_INSTRUMENTATION_TRANSPORT === void 0 ? false : process.env.USE_REDIS_INSTRUMENTATION_TRANSPORT === "true" ? true : false,
|
|
1887
|
+
redisInstrumentationTransportUrl: process.env.REDIS_INSTRUMENTATION_TRANSPORT_URL === void 0 ? "redis://localhost:6379" : process.env.REDIS_INSTRUMENTATION_TRANSPORT_URL,
|
|
1888
|
+
redisDatabaseCacheEndFlush: process.env.REDIS_DATABASE_CACHE_END_FLUSH === void 0 ? false : process.env.REDIS_DATABASE_CACHE_END_FLUSH === "true" ? true : false,
|
|
1889
|
+
redisDatabaseCacheUrl: process.env.REDIS_DATABASE_CACHE_URL === void 0 ? "redis://localhost:6379" : process.env.REDIS_DATABASE_CACHE_URL,
|
|
1890
|
+
defaultDatabaseMinExtraDataSize: process.env.DEFAULT_DATABASE_MIN_EXTRA_DATA_SIZE === void 0 ? 0 : parseInt(process.env.DEFAULT_DATABASE_MIN_EXTRA_DATA_SIZE),
|
|
1891
|
+
defaultDatabaseMaxExtraDataSize: process.env.DEFAULT_DATABASE_MAX_EXTRA_DATA_SIZE === void 0 ? 2e3 : parseInt(process.env.DEFAULT_DATABASE_MAX_EXTRA_DATA_SIZE),
|
|
1892
|
+
rest01endpoint: process.env.REST01_ENDPOINT === void 0 ? "https://localhost" : process.env.REST01_ENDPOINT,
|
|
1893
|
+
rest01hostport: process.env.REST01_HOST_PORT === void 0 ? "3003" : process.env.REST01_HOST_PORT,
|
|
1894
|
+
rest01port: process.env.REST01_PORT === void 0 ? "3003" : process.env.REST01_PORT,
|
|
1895
|
+
rest01apiroot: process.env.REST01_APIROOT === void 0 ? "/stsrest01/v1" : process.env.REST01_APIROOT,
|
|
1896
|
+
rest01prometheussupport: process.env.REST01_PROM_SUPPORT === void 0 ? true : process.env.REST01_PROM_SUPPORT === "true" ? true : false,
|
|
1897
|
+
rest01prometheusclusterport: process.env.REST01_PROM_CLUSTER_PORT === void 0 ? "3013" : process.env.REST01_PROM_CLUSTER_PORT,
|
|
1898
|
+
rest01servicename: process.env.REST01_SERVICE_NAME === void 0 ? "STSRest01" : process.env.REST01_SERVICE_NAME,
|
|
1899
|
+
rest01serviceversion: process.env.REST01_SERVICE_VERSION === void 0 ? "1.0.0" : process.env.REST01_SERVICE_VERSION,
|
|
1900
|
+
stsfhirendpoint: process.env.STSFHIR_ENDPOINT === void 0 ? "https://localhost" : process.env.STSFHIR_ENDPOINT,
|
|
1901
|
+
stsfhirhostport: process.env.STSFHIR_HOST_PORT === void 0 ? "3005" : process.env.STSFHIR_HOST_PORT,
|
|
1902
|
+
stsfhirport: process.env.STSFHIR_PORT === void 0 ? "3005" : process.env.STSFHIR_PORT,
|
|
1903
|
+
stsfhirapiroot: process.env.STSFHIR_APIROOT === void 0 ? "/stsfhir/r5" : process.env.STSFHIR_APIROOT,
|
|
1904
|
+
stsfhirprometheussupport: process.env.STSFHIR_PROM_SUPPORT === void 0 ? true : process.env.STSFHIR_PROM_SUPPORT === "true" ? true : false,
|
|
1905
|
+
stsfhirprometheusclusterport: process.env.STSFHIR_PROM_CLUSTER_PORT === void 0 ? "3015" : process.env.STSFHIR_PROM_CLUSTER_PORT,
|
|
1906
|
+
stsfhirservicename: process.env.STSFHIR_SERVICE_NAME === void 0 ? "STSFHIR" : process.env.STSFHIR_SERVICE_NAME,
|
|
1907
|
+
stsfhirserviceversion: process.env.STSFHIR_SERVICE_VERSION === void 0 ? "1.0.0" : process.env.STSFHIR_SERVICE_VERSION,
|
|
1908
|
+
imendpoint: process.env.IM_ENDPOINT === void 0 ? "https://localhost" : process.env.IM_ENDPOINT,
|
|
1909
|
+
imhostport: process.env.IM_HOST_PORT === void 0 ? "3001" : process.env.IM_HOST_PORT,
|
|
1910
|
+
import: process.env.IM_PORT === void 0 ? "3001" : process.env.IM_PORT,
|
|
1911
|
+
imapiroot: process.env.IM_APIROOT === void 0 ? "/stsinstrumentmanager/v1" : process.env.IM_APIROOT,
|
|
1912
|
+
imprometheussupport: process.env.IM_PROM_SUPPORT === void 0 ? true : process.env.IM_PROM_SUPPORT === "true" ? true : false,
|
|
1913
|
+
imprometheusclusterport: process.env.IM_PROM_CLUSTER_PORT === void 0 ? "3011" : process.env.IM_PROM_CLUSTER_PORT,
|
|
1914
|
+
imservicename: process.env.IM_SERVICE_NAME === void 0 ? "STSInstrumentManager" : process.env.IM_SERVICE_NAME,
|
|
1915
|
+
imserviceversion: process.env.IM_SERVICE_VERSION === void 0 ? "1.0.0" : process.env.IM_SERVICE_VERSION,
|
|
1916
|
+
imRedisKeepAliveProcessorUrl: process.env.IM_REDIS_KEEP_ALIVE_PROCESSOR_URL === void 0 ? "redis://localhost:6379" : process.env.IM_REDIS_KEEP_ALIVE_PROCESSOR_URL,
|
|
1917
|
+
imRedisMessageProcessorUrl: process.env.IM_REDIS_MESSAGE_PROCESSOR_URL === void 0 ? "redis://localhost:6379" : process.env.IM_REDIS_MESSAGE_PROCESSOR_URL,
|
|
1918
|
+
asendpoint: process.env.AS_ENDPOINT === void 0 ? "https://localhost" : process.env.AS_ENDPOINT,
|
|
1919
|
+
ashostport: process.env.AS_HOST_PORT === void 0 ? "3002" : process.env.AS_HOST_PORT,
|
|
1920
|
+
asport: process.env.AS_PORT === void 0 ? "3002" : process.env.AS_PORT,
|
|
1921
|
+
asapiroot: process.env.AS_API_ROOT === void 0 ? "/stsauth/v1.0" : process.env.AS_API_ROOT,
|
|
1922
|
+
asoauthapiroot: process.env.AS_OAUTH_API_ROOT === void 0 ? "/oauth2/v2.0" : process.env.AS_OAUTH_API_ROOT,
|
|
1923
|
+
asadminapiroot: process.env.AS_ADMIN_API_ROOT === void 0 ? "/admin/v1.0" : process.env.AS_ADMIN_API_ROOT,
|
|
1924
|
+
asprometheussupport: process.env.AS_PROM_SUPPORT === void 0 ? true : process.env.AS_PROM_SUPPORT === "true" ? true : false,
|
|
1925
|
+
asprometheusclusterport: process.env.AS_PROM_CLUSTER_PORT === void 0 ? "3012" : process.env.AS_PROM_CLUSTER_PORT,
|
|
1926
|
+
asservicename: process.env.AS_SERVICE_NAME === void 0 ? "STSAuth" : process.env.AS_SERVICE_NAME,
|
|
1927
|
+
asserviceversion: process.env.AS_SERVICE_VERSION === void 0 ? "1.0.0" : process.env.AS_SERVICE_VERSION,
|
|
1928
|
+
asjwksjsonpath: process.env.AS_JWKS_JSON_PATH === void 0 ? "/.well-known/jwks.json" : process.env.AS_JWKS_JSON_PATH,
|
|
1929
|
+
asjwkskeyrotationtime: process.env.AS_JWKS_KEY_ROTATION_TIME === void 0 ? 86400 : parseInt(process.env.AS_JWKS_KEY_ROTATION_TIME),
|
|
1930
|
+
asjwkskeypurgetimeoffset: process.env.AS_JWKS_KEY_PURGE_TIME_OFFSET === void 0 ? 300 : parseInt(process.env.AS_JWKS_KEY_PURGE_TIME_OFFSET),
|
|
1931
|
+
asjwkskeycount: process.env.AS_JWKS_KEY_COUNT === void 0 ? 4 : parseInt(process.env.AS_JWKS_KEY_COUNT),
|
|
1932
|
+
asaccesstokenexpire: process.env.AS_ACCESS_TOKEN_EXPIRE === void 0 ? 43200 : parseInt(process.env.AS_ACCESS_TOKEN_EXPIRE),
|
|
1933
|
+
authorizeendpoint: process.env.AUTHORIZE_ENDPOINT === void 0 ? "https://localhost" : process.env.AUTHORIZE_ENDPOINT,
|
|
1934
|
+
authorizeport: process.env.AUTHORIZE_PORT === void 0 ? "3010" : process.env.AUTHORIZE_PORT,
|
|
1935
|
+
authorizeapiroot: process.env.AUTHORIZE_API_ROOT === void 0 ? "/stsa" : process.env.AUTHORIZE_API_ROOT,
|
|
1936
|
+
authorizeapi: process.env.AUTHORIZE_API === void 0 ? "/authorize" : process.env.AUTHORIZE_API,
|
|
1937
|
+
brokerendpoint: process.env.BROKER_ENDPOINT === void 0 ? "https://localhost" : process.env.BROKER_ENDPOINT,
|
|
1938
|
+
brokerhostport: process.env.BROKER_HOST_PORT === void 0 ? "3006" : process.env.BROKER_HOST_PORT,
|
|
1939
|
+
brokerport: process.env.BROKER_PORT === void 0 ? "3006" : process.env.BROKER_PORT,
|
|
1940
|
+
brokerapiroot: process.env.BROKER_APIROOT === void 0 ? "/stsbroker/v1.0" : process.env.BROKER_APIROOT,
|
|
1941
|
+
brokerprometheussupport: process.env.BROKER_PROM_SUPPORT === void 0 ? true : process.env.BROKER_PROM_SUPPORT === "true" ? true : false,
|
|
1942
|
+
brokerprometheusclusterport: process.env.BROKER_PROM_CLUSTER_PORT === void 0 ? "3016" : process.env.BROKER_PROM_CLUSTER_PORT,
|
|
1943
|
+
brokerservicename: process.env.BROKER_SERVICE_NAME === void 0 ? "STSBroker" : process.env.BROKER_SERVICE_NAME,
|
|
1944
|
+
brokerserviceversion: process.env.BROKER_SERVICE_VERSION === void 0 ? "1.0.0" : process.env.BROKER_SERVICE_VERSION,
|
|
1945
|
+
trnendpoint: process.env.TRN_ENDPOINT === void 0 ? "https://localhost" : process.env.TRN_ENDPOINT,
|
|
1946
|
+
trnhostport: process.env.TRN_HOST_PORT === void 0 ? "3007" : process.env.TRN_HOST_PORT,
|
|
1947
|
+
trnport: process.env.TRN_PORT === void 0 ? "3007" : process.env.TRN_PORT,
|
|
1948
|
+
trnapiroot: process.env.TRN_APIROOT === void 0 ? "/ststrn/v1.0" : process.env.TRN_APIROOT,
|
|
1949
|
+
trnprometheussupport: process.env.TRN_PROM_SUPPORT === void 0 ? true : process.env.TRN_PROM_SUPPORT === "true" ? true : false,
|
|
1950
|
+
trnprometheusclusterport: process.env.TRN_PROM_CLUSTER_PORT === void 0 ? "3017" : process.env.TRN_PROM_CLUSTER_PORT,
|
|
1951
|
+
trnservicename: process.env.TRN_SERVICE_NAME === void 0 ? "STSTestRunnerNode" : process.env.TRN_SERVICE_NAME,
|
|
1952
|
+
trnserviceversion: process.env.TRN_SERVICE_VERSION === void 0 ? "1.0.0" : process.env.TRN_SERVICE_VERSION,
|
|
1953
|
+
trnautostartdelay: process.env.TRN_AUTO_START_DELAY === void 0 ? 0 : parseInt(process.env.TRN_AUTO_START_DELAY),
|
|
1954
|
+
trnautostartconfig: process.env.TRN_AUTO_START_CONFIG === void 0 ? "" : process.env.TRN_AUTO_START_CONFIG,
|
|
1955
|
+
trnRedisMessageProcessorUrl: process.env.TRN_REDIS_MESSAGE_PROCESSOR_URL === void 0 ? "redis://localhost:6379" : process.env.TRN_REDIS_MESSAGE_PROCESSOR_URL,
|
|
1956
|
+
lambdaendpoint: process.env.LAMBDA_ENDPOINT === void 0 ? "https://localhost" : process.env.LAMBDA_ENDPOINT,
|
|
1957
|
+
lambdahostport: process.env.LAMBDA_HOST_PORT === void 0 ? "3009" : process.env.LAMBDA_HOST_PORT,
|
|
1958
|
+
lambdaport: process.env.LAMBDA_PORT === void 0 ? "3009" : process.env.LAMBDA_PORT,
|
|
1959
|
+
lambdaapiroot: process.env.LAMBDA_APIROOT === void 0 ? "/stslambda/v1.0" : process.env.LAMBDA_APIROOT,
|
|
1960
|
+
lambdaprometheussupport: process.env.LAMBDA_PROM_SUPPORT === void 0 ? true : process.env.LAMBDA_PROM_SUPPORT === "true" ? true : false,
|
|
1961
|
+
lambdaprometheusclusterport: process.env.LAMBDA_PROM_CLUSTER_PORT === void 0 ? "3019" : process.env.LAMBDA_PROM_CLUSTER_PORT,
|
|
1962
|
+
lambdaservicename: process.env.LAMBDA_SERVICE_NAME === void 0 ? "STSLambda" : process.env.LAMBDA_SERVICE_NAME,
|
|
1963
|
+
lambdaserviceversion: process.env.LAMBDA_SERVICE_VERSION === void 0 ? "1.0.0" : process.env.LAMBDA_SERVICE_VERSION,
|
|
1964
|
+
publishinterval: process.env.PUBLISH_INTERVAL === void 0 ? 1e3 : parseInt(process.env.PUBLISH_INTERVAL),
|
|
1965
|
+
publishtimeout: process.env.PUBLISH_TIMEOUT === void 0 ? 750 : parseInt(process.env.PUBLISH_TIMEOUT),
|
|
1966
|
+
transport: process.env.TRANSPORT === void 0 ? "RESTAPI" : process.env.TRANSPORT,
|
|
1967
|
+
useSecureCookies: process.env.USE_SECURE_COOKIES === void 0 ? false : process.env.USE_SECURE_COOKIES === "true" ? true : false,
|
|
1968
|
+
keepAlive: process.env.KEEP_ALIVE === void 0 ? true : process.env.KEEP_ALIVE === "true" ? true : false,
|
|
1969
|
+
maxSockets: process.env.MAX_SOCKETS === void 0 ? 10 : parseInt(process.env.MAX_SOCKETS),
|
|
1970
|
+
maxTotalSockets: process.env.MAX_TOTAL_SOCKETS === void 0 ? 20 : parseInt(process.env.MAX_TOTAL_SOCKETS),
|
|
1971
|
+
maxFreeSockets: process.env.MAX_FREE_SOCKETS === void 0 ? 256 : parseInt(process.env.MAX_FREE_SOCKETS),
|
|
1972
|
+
timeout: process.env.TIMEOUT === void 0 ? 1e4 : parseInt(process.env.TIMEOUT),
|
|
1973
|
+
maxPayloadSize: process.env.MAX_PAYLOAD_SIZE === void 0 ? "50mb" : process.env.MAX_PAYLOAD_SIZE,
|
|
1974
|
+
instrumentationObservationInterval: process.env.INSTRUMENTATION_OBSERVATION_INTERVAL === void 0 ? 1e3 : parseInt(process.env.INSTRUMENTATION_OBSERVATION_INTERVAL),
|
|
1975
|
+
instrumentationTimeWindow: process.env.INSTRUMENTATION_TIME_WINDOW === void 0 ? 600 : parseInt(process.env.INSTRUMENTATION_TIME_WINDOW),
|
|
1976
|
+
authJWTAccessTokenTimeout: process.env.AUTH_JWT_ACCESS_TOKEN_TIMEOUT === void 0 ? 600 : parseInt(process.env.AUTH_JWT_ACCESS_TOKEN_TIMEOUT),
|
|
1977
|
+
authJWTRefreshTokenTimeout: process.env.AUTH_JWT_REFRESH_TOKEN_TIMEOUT === void 0 ? 3600 * 24 : parseInt(process.env.AUTH_JWT_REFRESH_TOKEN_TIMEOUT),
|
|
1978
|
+
authCookieTimeout: process.env.AUTH_COOKIE_TIMEOUT === void 0 ? 3600 * 24 : parseInt(process.env.AUTH_COOKIE_TIMEOUT),
|
|
1979
|
+
masterProcessExitTime: process.env.MASTER_PROCESS_EXIT_TIME === void 0 ? 500 : parseInt(process.env.MASTER_PROCESS_EXIT_TIME),
|
|
1980
|
+
childProcessExitTime: process.env.CHILD_PROCESS_EXIT_TIME === void 0 ? 500 : parseInt(process.env.CHILD_PROCESS_EXIT_TIME),
|
|
1981
|
+
systemInformationInterval: process.env.SYSTEM_INFORMATION_INTERVAL === void 0 ? 1e3 : parseInt(process.env.SYSTEM_INFORMATION_INTERVAL),
|
|
1982
|
+
ignoresocketio: process.env.IGNORE_SOCKETIO === void 0 ? true : process.env.IGNORE_SOCKETIO === "true" ? true : false,
|
|
1983
|
+
httpsserverkeypath: process.env.HTTPS_SERVER_KEY_PATH === void 0 ? "/var/lib/sts/stsglobalresources/keys/server.key" : process.env.HTTPS_SERVER_KEY_PATH,
|
|
1984
|
+
httpsservercertpath: process.env.HTTPS_SERVER_CERT_PATH === void 0 ? "/var/lib/sts/stsglobalresources/keys/server.cert" : process.env.HTTPS_SERVER_CERT_PATH,
|
|
1985
|
+
tsjwkskeys: process.env.TS_JWKS_KEYS === void 0 ? 3 : parseInt(process.env.TS_JWKS_KEYS),
|
|
1986
|
+
jwksAuthConfigCache: process.env.JWKS_AUTH_CONFIG_CACHE === void 0 ? true : process.env.JWKS_AUTH_CONFIG_CACHE === "true" ? true : false,
|
|
1987
|
+
jwksAuthConfigCacheMaxEntries: process.env.JWKS_AUTH_CONFIG_CACHE_MAX_ENTRIES === void 0 ? 5 : parseInt(process.env.JWKS_AUTH_CONFIG_CACHE_MAX_ENTRIES),
|
|
1988
|
+
jwksAuthConfigCacheMaxAge: process.env.JWKS_AUTH_CONFIG_CACHE_MAX_AGE === void 0 ? 6e5 : parseInt(process.env.JWKS_AUTH_CONFIG_CACHE_MAX_AGE),
|
|
1989
|
+
jwksAuthConfigRateLimit: process.env.JWKS_AUTH_CONFIG_RATE_LIMIT === void 0 ? true : process.env.JWKS_AUTH_CONFIG_RATE_LIMIT === "true" ? true : false,
|
|
1990
|
+
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),
|
|
1991
|
+
jwksAuthConfigTimeout: process.env.JWKS_AUTH_CONFIG_TIMEOUT === void 0 ? 3e4 : parseInt(process.env.JWKS_AUTH_CONFIG_TIMEOUT),
|
|
1992
|
+
influxDB_APIToken: process.env.INFLUXDB_API_TOKEN === void 0 ? "password" : process.env.INFLUXDB_API_TOKEN,
|
|
1993
|
+
influxDB_APITokenFile: process.env.INFLUXDB_API_TOKEN_FILE,
|
|
1994
|
+
influxDB_Url: process.env.INFLUXDB_URL === void 0 ? "http://localhost:8086" : process.env.INFLUXDB_URL,
|
|
1995
|
+
influxDB_Org: process.env.INFLUXDB_ORG === void 0 ? "my-org" : process.env.INFLUXDB_ORG,
|
|
1996
|
+
influxDB_Bucket: process.env.INFLUXDB_BUCKET === void 0 ? "TestBucket01" : process.env.INFLUXDB_BUCKET,
|
|
1997
|
+
influxDB_keepAlive: process.env.INFLUXDB_KEEP_ALIVE === void 0 ? true : process.env.INFLUXDB_KEEP_ALIVE === "true" ? true : false,
|
|
1998
|
+
influxDB_maxSockets: process.env.INFLUXDB_MAX_SOCKETS === void 0 ? 10 : parseInt(process.env.INFLUXDB_MAX_SOCKETS),
|
|
1999
|
+
influxDB_maxTotalSockets: process.env.INFLUXDB_MAX_TOTAL_SOCKETS === void 0 ? 20 : parseInt(process.env.INFLUXDB_MAX_TOTAL_SOCKETS),
|
|
2000
|
+
influxDB_maxFreeSockets: process.env.INFLUXDB_MAX_FREE_SOCKETS === void 0 ? 256 : parseInt(process.env.INFLUXDB_MAX_FREE_SOCKETS),
|
|
2001
|
+
influxDB_timeout: process.env.INFLUXDB_TIMEOUT === void 0 ? 1e4 : parseInt(process.env.INFLUXDB_TIMEOUT),
|
|
2002
|
+
influxDB_rejectUnauthorized: process.env.INFLUXDB_REJECT_UNAUTHORIZED === void 0 ? true : process.env.INFLUXDB_REJECT_UNAUTHORIZED === "true" ? true : false,
|
|
2003
|
+
influxDB_writeDataPointFlushTimeout: process.env.INFLUXDB_WRITE_DATA_POINT_FLUSH_TIMEOUT === void 0 ? 1e3 : parseInt(process.env.INFLUXDB_WRITE_DATA_POINT_FLUSH_TIMEOUT),
|
|
2004
|
+
kafka_clientId: process.env.KAFKA_CLIENT_ID === void 0 ? "myclient" : process.env.KAFKA_CLIENT_ID,
|
|
2005
|
+
kafka_brokers: process.env.KAFKA_BROKERS === void 0 ? "localhost:9092" : process.env.KAFKA_BROKERS,
|
|
2006
|
+
kafka_admin_timeout: process.env.KAFKA_ADMIN_TIMEOUT === void 0 ? 5e3 : parseInt(process.env.KAFKA_ADMIN_TIMEOUT),
|
|
2007
|
+
kafka_connection_timeout: process.env.KAFKA_CONNECTION_TIMEOUT === void 0 ? 5e3 : parseInt(process.env.KAFKA_CONNECTION_TIMEOUT),
|
|
2008
|
+
kafka_request_timeout: process.env.KAFKA_REQUEST_TIMEOUT === void 0 ? 5e3 : parseInt(process.env.KAFKA_REQUEST_TIMEOUT),
|
|
2009
|
+
kafka_log_level: process.env.KAFKA_LOG_LEVEL === void 0 ? "nothing" : process.env.KAFKA_LOG_LEVEL,
|
|
2010
|
+
kafka_keep_alive: process.env.KAFKA_KEEP_ALIVE === void 0 ? 3e4 : parseInt(process.env.KAFKA_KEEP_ALIVE),
|
|
2011
|
+
kafka_use_ssl: process.env.KAFKA_USE_SSL === void 0 ? false : process.env.KAFKA_USE_SSL === "true" ? true : false,
|
|
2012
|
+
kafka_ssl_rejectUnauthorized: process.env.KAFKA_SSL_REJECT_UNAUTHORIZED === void 0 ? true : process.env.KAFKA_SSL_REJECT_UNAUTHORIZED === "true" ? true : false,
|
|
2013
|
+
kafka_ssl_cafile: process.env.KAFKA_SSL_CAFILE === void 0 ? "/my/custom/ca.crt" : process.env.KAFKA_SSL_CAFILE,
|
|
2014
|
+
kafka_ssl_keyfile: process.env.KAFKA_SSL_KEYFILE === void 0 ? "/my/custom/client-key.pem" : process.env.KAFKA_SSL_KEYFILE,
|
|
2015
|
+
kafka_ssl_certfile: process.env.KAFKA_SSL_CERTFILE === void 0 ? "/my/custom/client-cert.pem" : process.env.KAFKA_SSL_CERTFILE,
|
|
2016
|
+
kafka_consume_from_beginning: process.env.KAFKA_CONSUME_FROM_BEGINNING === void 0 ? true : process.env.KAFKA_CONSUME_FROM_BEGINNING === "true" ? true : false,
|
|
2017
|
+
observabilityPublishMode: process.env.OBSERVABILITY_PUBLISH_MODE === void 0 ? "PROXY" : process.env.OBSERVABILITY_PUBLISH_MODE,
|
|
2018
|
+
stsUiTermObservabilityConsumptionMode: process.env.STSUITERM_OBSERVABILITY_CONSUMPTION_MODE === void 0 ? "PROXY" : process.env.STSUITERM_OBSERVABILITY_CONSUMPTION_MODE
|
|
2019
|
+
};
|
|
2020
|
+
const ReadFile = (passwordFile) => {
|
|
2021
|
+
try {
|
|
2022
|
+
accessSync(passwordFile, constants.R_OK);
|
|
2023
|
+
const data = readFileSync(passwordFile, "utf8");
|
|
2024
|
+
if (logger) ;
|
|
2025
|
+
return data;
|
|
2026
|
+
} catch (err) {
|
|
2027
|
+
return "";
|
|
2028
|
+
}
|
|
2029
|
+
};
|
|
2030
|
+
const fileconfig = [
|
|
2031
|
+
{ fileprop: "dbpasswordfile", prop: "dbpassword" },
|
|
2032
|
+
// JWKS secret file processing
|
|
2033
|
+
{ fileprop: "tsjwksstorepathfile", prop: "tsjwksstorepath" },
|
|
2034
|
+
// InfluxDB file processing
|
|
2035
|
+
{ fileprop: "influxDB_APITokenFile", prop: "influxDB_APIToken" }
|
|
2036
|
+
];
|
|
2037
|
+
fileconfig.forEach((v) => {
|
|
2038
|
+
if (defconfig[v.fileprop] !== void 0) {
|
|
2039
|
+
defconfig[v.prop] = ReadFile(defconfig[v.fileprop]);
|
|
2040
|
+
}
|
|
2041
|
+
});
|
|
2042
|
+
for (const [key, val] of Object.entries(defconfig)) {
|
|
2043
|
+
envOptions2[key] = val;
|
|
2044
|
+
}
|
|
2045
|
+
}
|
|
2046
|
+
function $SetupOptions(envOptions2) {
|
|
2047
|
+
SetupConfig(envOptions2);
|
|
2048
|
+
const options = envOptions2;
|
|
2049
|
+
if (options.dbhost) {
|
|
2050
|
+
const hosts = options.dbhost.split(",");
|
|
2051
|
+
envOptions2.connectionString = hosts.map((host) => {
|
|
2052
|
+
return `postgresql://${options.dbuser}:${options.dbpassword}@${host}/${options.database}`;
|
|
2053
|
+
}).join(",");
|
|
2054
|
+
envOptions2.defaultDatabaseConnectionString = hosts.map((host) => {
|
|
2055
|
+
return `postgresql://${options.dbuser}:${options.dbpassword}@${host}/postgres`;
|
|
2056
|
+
}).join(",");
|
|
2057
|
+
}
|
|
2058
|
+
}
|
|
2059
|
+
const envOptionsHandler = {
|
|
2060
|
+
get(target, prop, receiver) {
|
|
2061
|
+
if (Object.keys(target).length === 0) {
|
|
2062
|
+
$SetupOptions(target);
|
|
2063
|
+
}
|
|
2064
|
+
return Reflect.get(target, prop, receiver);
|
|
2065
|
+
}
|
|
2066
|
+
};
|
|
2067
|
+
const goptions = new Proxy(envOptions, envOptionsHandler);
|
|
2068
|
+
var ansiStyles$1 = { exports: {} };
|
|
2069
|
+
var colorName;
|
|
2070
|
+
var hasRequiredColorName;
|
|
2071
|
+
function requireColorName() {
|
|
2072
|
+
if (hasRequiredColorName) return colorName;
|
|
2073
|
+
hasRequiredColorName = 1;
|
|
2074
|
+
colorName = {
|
|
2075
|
+
"aliceblue": [240, 248, 255],
|
|
2076
|
+
"antiquewhite": [250, 235, 215],
|
|
2077
|
+
"aqua": [0, 255, 255],
|
|
2078
|
+
"aquamarine": [127, 255, 212],
|
|
2079
|
+
"azure": [240, 255, 255],
|
|
2080
|
+
"beige": [245, 245, 220],
|
|
2081
|
+
"bisque": [255, 228, 196],
|
|
2082
|
+
"black": [0, 0, 0],
|
|
2083
|
+
"blanchedalmond": [255, 235, 205],
|
|
2084
|
+
"blue": [0, 0, 255],
|
|
2085
|
+
"blueviolet": [138, 43, 226],
|
|
2086
|
+
"brown": [165, 42, 42],
|
|
2087
|
+
"burlywood": [222, 184, 135],
|
|
2088
|
+
"cadetblue": [95, 158, 160],
|
|
2089
|
+
"chartreuse": [127, 255, 0],
|
|
2090
|
+
"chocolate": [210, 105, 30],
|
|
2091
|
+
"coral": [255, 127, 80],
|
|
2092
|
+
"cornflowerblue": [100, 149, 237],
|
|
2093
|
+
"cornsilk": [255, 248, 220],
|
|
2094
|
+
"crimson": [220, 20, 60],
|
|
2095
|
+
"cyan": [0, 255, 255],
|
|
2096
|
+
"darkblue": [0, 0, 139],
|
|
2097
|
+
"darkcyan": [0, 139, 139],
|
|
2098
|
+
"darkgoldenrod": [184, 134, 11],
|
|
2099
|
+
"darkgray": [169, 169, 169],
|
|
2100
|
+
"darkgreen": [0, 100, 0],
|
|
2101
|
+
"darkgrey": [169, 169, 169],
|
|
2102
|
+
"darkkhaki": [189, 183, 107],
|
|
2103
|
+
"darkmagenta": [139, 0, 139],
|
|
2104
|
+
"darkolivegreen": [85, 107, 47],
|
|
2105
|
+
"darkorange": [255, 140, 0],
|
|
2106
|
+
"darkorchid": [153, 50, 204],
|
|
2107
|
+
"darkred": [139, 0, 0],
|
|
2108
|
+
"darksalmon": [233, 150, 122],
|
|
2109
|
+
"darkseagreen": [143, 188, 143],
|
|
2110
|
+
"darkslateblue": [72, 61, 139],
|
|
2111
|
+
"darkslategray": [47, 79, 79],
|
|
2112
|
+
"darkslategrey": [47, 79, 79],
|
|
2113
|
+
"darkturquoise": [0, 206, 209],
|
|
2114
|
+
"darkviolet": [148, 0, 211],
|
|
2115
|
+
"deeppink": [255, 20, 147],
|
|
2116
|
+
"deepskyblue": [0, 191, 255],
|
|
2117
|
+
"dimgray": [105, 105, 105],
|
|
2118
|
+
"dimgrey": [105, 105, 105],
|
|
2119
|
+
"dodgerblue": [30, 144, 255],
|
|
2120
|
+
"firebrick": [178, 34, 34],
|
|
2121
|
+
"floralwhite": [255, 250, 240],
|
|
2122
|
+
"forestgreen": [34, 139, 34],
|
|
2123
|
+
"fuchsia": [255, 0, 255],
|
|
2124
|
+
"gainsboro": [220, 220, 220],
|
|
2125
|
+
"ghostwhite": [248, 248, 255],
|
|
2126
|
+
"gold": [255, 215, 0],
|
|
2127
|
+
"goldenrod": [218, 165, 32],
|
|
2128
|
+
"gray": [128, 128, 128],
|
|
2129
|
+
"green": [0, 128, 0],
|
|
2130
|
+
"greenyellow": [173, 255, 47],
|
|
2131
|
+
"grey": [128, 128, 128],
|
|
2132
|
+
"honeydew": [240, 255, 240],
|
|
2133
|
+
"hotpink": [255, 105, 180],
|
|
2134
|
+
"indianred": [205, 92, 92],
|
|
2135
|
+
"indigo": [75, 0, 130],
|
|
2136
|
+
"ivory": [255, 255, 240],
|
|
2137
|
+
"khaki": [240, 230, 140],
|
|
2138
|
+
"lavender": [230, 230, 250],
|
|
2139
|
+
"lavenderblush": [255, 240, 245],
|
|
2140
|
+
"lawngreen": [124, 252, 0],
|
|
2141
|
+
"lemonchiffon": [255, 250, 205],
|
|
2142
|
+
"lightblue": [173, 216, 230],
|
|
2143
|
+
"lightcoral": [240, 128, 128],
|
|
2144
|
+
"lightcyan": [224, 255, 255],
|
|
2145
|
+
"lightgoldenrodyellow": [250, 250, 210],
|
|
2146
|
+
"lightgray": [211, 211, 211],
|
|
2147
|
+
"lightgreen": [144, 238, 144],
|
|
2148
|
+
"lightgrey": [211, 211, 211],
|
|
2149
|
+
"lightpink": [255, 182, 193],
|
|
2150
|
+
"lightsalmon": [255, 160, 122],
|
|
2151
|
+
"lightseagreen": [32, 178, 170],
|
|
2152
|
+
"lightskyblue": [135, 206, 250],
|
|
2153
|
+
"lightslategray": [119, 136, 153],
|
|
2154
|
+
"lightslategrey": [119, 136, 153],
|
|
2155
|
+
"lightsteelblue": [176, 196, 222],
|
|
2156
|
+
"lightyellow": [255, 255, 224],
|
|
2157
|
+
"lime": [0, 255, 0],
|
|
2158
|
+
"limegreen": [50, 205, 50],
|
|
2159
|
+
"linen": [250, 240, 230],
|
|
2160
|
+
"magenta": [255, 0, 255],
|
|
2161
|
+
"maroon": [128, 0, 0],
|
|
2162
|
+
"mediumaquamarine": [102, 205, 170],
|
|
2163
|
+
"mediumblue": [0, 0, 205],
|
|
2164
|
+
"mediumorchid": [186, 85, 211],
|
|
2165
|
+
"mediumpurple": [147, 112, 219],
|
|
2166
|
+
"mediumseagreen": [60, 179, 113],
|
|
2167
|
+
"mediumslateblue": [123, 104, 238],
|
|
2168
|
+
"mediumspringgreen": [0, 250, 154],
|
|
2169
|
+
"mediumturquoise": [72, 209, 204],
|
|
2170
|
+
"mediumvioletred": [199, 21, 133],
|
|
2171
|
+
"midnightblue": [25, 25, 112],
|
|
2172
|
+
"mintcream": [245, 255, 250],
|
|
2173
|
+
"mistyrose": [255, 228, 225],
|
|
2174
|
+
"moccasin": [255, 228, 181],
|
|
2175
|
+
"navajowhite": [255, 222, 173],
|
|
2176
|
+
"navy": [0, 0, 128],
|
|
2177
|
+
"oldlace": [253, 245, 230],
|
|
2178
|
+
"olive": [128, 128, 0],
|
|
2179
|
+
"olivedrab": [107, 142, 35],
|
|
2180
|
+
"orange": [255, 165, 0],
|
|
2181
|
+
"orangered": [255, 69, 0],
|
|
2182
|
+
"orchid": [218, 112, 214],
|
|
2183
|
+
"palegoldenrod": [238, 232, 170],
|
|
2184
|
+
"palegreen": [152, 251, 152],
|
|
2185
|
+
"paleturquoise": [175, 238, 238],
|
|
2186
|
+
"palevioletred": [219, 112, 147],
|
|
2187
|
+
"papayawhip": [255, 239, 213],
|
|
2188
|
+
"peachpuff": [255, 218, 185],
|
|
2189
|
+
"peru": [205, 133, 63],
|
|
2190
|
+
"pink": [255, 192, 203],
|
|
2191
|
+
"plum": [221, 160, 221],
|
|
2192
|
+
"powderblue": [176, 224, 230],
|
|
2193
|
+
"purple": [128, 0, 128],
|
|
2194
|
+
"rebeccapurple": [102, 51, 153],
|
|
2195
|
+
"red": [255, 0, 0],
|
|
2196
|
+
"rosybrown": [188, 143, 143],
|
|
2197
|
+
"royalblue": [65, 105, 225],
|
|
2198
|
+
"saddlebrown": [139, 69, 19],
|
|
2199
|
+
"salmon": [250, 128, 114],
|
|
2200
|
+
"sandybrown": [244, 164, 96],
|
|
2201
|
+
"seagreen": [46, 139, 87],
|
|
2202
|
+
"seashell": [255, 245, 238],
|
|
2203
|
+
"sienna": [160, 82, 45],
|
|
2204
|
+
"silver": [192, 192, 192],
|
|
2205
|
+
"skyblue": [135, 206, 235],
|
|
2206
|
+
"slateblue": [106, 90, 205],
|
|
2207
|
+
"slategray": [112, 128, 144],
|
|
2208
|
+
"slategrey": [112, 128, 144],
|
|
2209
|
+
"snow": [255, 250, 250],
|
|
2210
|
+
"springgreen": [0, 255, 127],
|
|
2211
|
+
"steelblue": [70, 130, 180],
|
|
2212
|
+
"tan": [210, 180, 140],
|
|
2213
|
+
"teal": [0, 128, 128],
|
|
2214
|
+
"thistle": [216, 191, 216],
|
|
2215
|
+
"tomato": [255, 99, 71],
|
|
2216
|
+
"turquoise": [64, 224, 208],
|
|
2217
|
+
"violet": [238, 130, 238],
|
|
2218
|
+
"wheat": [245, 222, 179],
|
|
2219
|
+
"white": [255, 255, 255],
|
|
2220
|
+
"whitesmoke": [245, 245, 245],
|
|
2221
|
+
"yellow": [255, 255, 0],
|
|
2222
|
+
"yellowgreen": [154, 205, 50]
|
|
2223
|
+
};
|
|
2224
|
+
return colorName;
|
|
2225
|
+
}
|
|
2226
|
+
var conversions;
|
|
2227
|
+
var hasRequiredConversions;
|
|
2228
|
+
function requireConversions() {
|
|
2229
|
+
if (hasRequiredConversions) return conversions;
|
|
2230
|
+
hasRequiredConversions = 1;
|
|
2231
|
+
const cssKeywords = requireColorName();
|
|
2232
|
+
const reverseKeywords = {};
|
|
2233
|
+
for (const key of Object.keys(cssKeywords)) {
|
|
2234
|
+
reverseKeywords[cssKeywords[key]] = key;
|
|
2235
|
+
}
|
|
2236
|
+
const convert = {
|
|
2237
|
+
rgb: { channels: 3, labels: "rgb" },
|
|
2238
|
+
hsl: { channels: 3, labels: "hsl" },
|
|
2239
|
+
hsv: { channels: 3, labels: "hsv" },
|
|
2240
|
+
hwb: { channels: 3, labels: "hwb" },
|
|
2241
|
+
cmyk: { channels: 4, labels: "cmyk" },
|
|
2242
|
+
xyz: { channels: 3, labels: "xyz" },
|
|
2243
|
+
lab: { channels: 3, labels: "lab" },
|
|
2244
|
+
lch: { channels: 3, labels: "lch" },
|
|
2245
|
+
hex: { channels: 1, labels: ["hex"] },
|
|
2246
|
+
keyword: { channels: 1, labels: ["keyword"] },
|
|
2247
|
+
ansi16: { channels: 1, labels: ["ansi16"] },
|
|
2248
|
+
ansi256: { channels: 1, labels: ["ansi256"] },
|
|
2249
|
+
hcg: { channels: 3, labels: ["h", "c", "g"] },
|
|
2250
|
+
apple: { channels: 3, labels: ["r16", "g16", "b16"] },
|
|
2251
|
+
gray: { channels: 1, labels: ["gray"] }
|
|
2252
|
+
};
|
|
2253
|
+
conversions = convert;
|
|
2254
|
+
for (const model of Object.keys(convert)) {
|
|
2255
|
+
if (!("channels" in convert[model])) {
|
|
2256
|
+
throw new Error("missing channels property: " + model);
|
|
2257
|
+
}
|
|
2258
|
+
if (!("labels" in convert[model])) {
|
|
2259
|
+
throw new Error("missing channel labels property: " + model);
|
|
2260
|
+
}
|
|
2261
|
+
if (convert[model].labels.length !== convert[model].channels) {
|
|
2262
|
+
throw new Error("channel and label counts mismatch: " + model);
|
|
2263
|
+
}
|
|
2264
|
+
const { channels, labels } = convert[model];
|
|
2265
|
+
delete convert[model].channels;
|
|
2266
|
+
delete convert[model].labels;
|
|
2267
|
+
Object.defineProperty(convert[model], "channels", { value: channels });
|
|
2268
|
+
Object.defineProperty(convert[model], "labels", { value: labels });
|
|
2269
|
+
}
|
|
2270
|
+
convert.rgb.hsl = function(rgb) {
|
|
2271
|
+
const r = rgb[0] / 255;
|
|
2272
|
+
const g = rgb[1] / 255;
|
|
2273
|
+
const b = rgb[2] / 255;
|
|
2274
|
+
const min = Math.min(r, g, b);
|
|
2275
|
+
const max = Math.max(r, g, b);
|
|
2276
|
+
const delta = max - min;
|
|
2277
|
+
let h;
|
|
2278
|
+
let s;
|
|
2279
|
+
if (max === min) {
|
|
2280
|
+
h = 0;
|
|
2281
|
+
} else if (r === max) {
|
|
2282
|
+
h = (g - b) / delta;
|
|
2283
|
+
} else if (g === max) {
|
|
2284
|
+
h = 2 + (b - r) / delta;
|
|
2285
|
+
} else if (b === max) {
|
|
2286
|
+
h = 4 + (r - g) / delta;
|
|
2287
|
+
}
|
|
2288
|
+
h = Math.min(h * 60, 360);
|
|
2289
|
+
if (h < 0) {
|
|
2290
|
+
h += 360;
|
|
2291
|
+
}
|
|
2292
|
+
const l = (min + max) / 2;
|
|
2293
|
+
if (max === min) {
|
|
2294
|
+
s = 0;
|
|
2295
|
+
} else if (l <= 0.5) {
|
|
2296
|
+
s = delta / (max + min);
|
|
2297
|
+
} else {
|
|
2298
|
+
s = delta / (2 - max - min);
|
|
2299
|
+
}
|
|
2300
|
+
return [h, s * 100, l * 100];
|
|
2301
|
+
};
|
|
2302
|
+
convert.rgb.hsv = function(rgb) {
|
|
2303
|
+
let rdif;
|
|
2304
|
+
let gdif;
|
|
2305
|
+
let bdif;
|
|
2306
|
+
let h;
|
|
2307
|
+
let s;
|
|
2308
|
+
const r = rgb[0] / 255;
|
|
2309
|
+
const g = rgb[1] / 255;
|
|
2310
|
+
const b = rgb[2] / 255;
|
|
2311
|
+
const v = Math.max(r, g, b);
|
|
2312
|
+
const diff = v - Math.min(r, g, b);
|
|
2313
|
+
const diffc = function(c) {
|
|
2314
|
+
return (v - c) / 6 / diff + 1 / 2;
|
|
2315
|
+
};
|
|
2316
|
+
if (diff === 0) {
|
|
2317
|
+
h = 0;
|
|
2318
|
+
s = 0;
|
|
2319
|
+
} else {
|
|
2320
|
+
s = diff / v;
|
|
2321
|
+
rdif = diffc(r);
|
|
2322
|
+
gdif = diffc(g);
|
|
2323
|
+
bdif = diffc(b);
|
|
2324
|
+
if (r === v) {
|
|
2325
|
+
h = bdif - gdif;
|
|
2326
|
+
} else if (g === v) {
|
|
2327
|
+
h = 1 / 3 + rdif - bdif;
|
|
2328
|
+
} else if (b === v) {
|
|
2329
|
+
h = 2 / 3 + gdif - rdif;
|
|
2330
|
+
}
|
|
2331
|
+
if (h < 0) {
|
|
2332
|
+
h += 1;
|
|
2333
|
+
} else if (h > 1) {
|
|
2334
|
+
h -= 1;
|
|
2335
|
+
}
|
|
2336
|
+
}
|
|
2337
|
+
return [
|
|
2338
|
+
h * 360,
|
|
2339
|
+
s * 100,
|
|
2340
|
+
v * 100
|
|
2341
|
+
];
|
|
2342
|
+
};
|
|
2343
|
+
convert.rgb.hwb = function(rgb) {
|
|
2344
|
+
const r = rgb[0];
|
|
2345
|
+
const g = rgb[1];
|
|
2346
|
+
let b = rgb[2];
|
|
2347
|
+
const h = convert.rgb.hsl(rgb)[0];
|
|
2348
|
+
const w = 1 / 255 * Math.min(r, Math.min(g, b));
|
|
2349
|
+
b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
|
|
2350
|
+
return [h, w * 100, b * 100];
|
|
2351
|
+
};
|
|
2352
|
+
convert.rgb.cmyk = function(rgb) {
|
|
2353
|
+
const r = rgb[0] / 255;
|
|
2354
|
+
const g = rgb[1] / 255;
|
|
2355
|
+
const b = rgb[2] / 255;
|
|
2356
|
+
const k = Math.min(1 - r, 1 - g, 1 - b);
|
|
2357
|
+
const c = (1 - r - k) / (1 - k) || 0;
|
|
2358
|
+
const m = (1 - g - k) / (1 - k) || 0;
|
|
2359
|
+
const y = (1 - b - k) / (1 - k) || 0;
|
|
2360
|
+
return [c * 100, m * 100, y * 100, k * 100];
|
|
2361
|
+
};
|
|
2362
|
+
function comparativeDistance(x, y) {
|
|
2363
|
+
return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;
|
|
2364
|
+
}
|
|
2365
|
+
convert.rgb.keyword = function(rgb) {
|
|
2366
|
+
const reversed = reverseKeywords[rgb];
|
|
2367
|
+
if (reversed) {
|
|
2368
|
+
return reversed;
|
|
2369
|
+
}
|
|
2370
|
+
let currentClosestDistance = Infinity;
|
|
2371
|
+
let currentClosestKeyword;
|
|
2372
|
+
for (const keyword of Object.keys(cssKeywords)) {
|
|
2373
|
+
const value = cssKeywords[keyword];
|
|
2374
|
+
const distance = comparativeDistance(rgb, value);
|
|
2375
|
+
if (distance < currentClosestDistance) {
|
|
2376
|
+
currentClosestDistance = distance;
|
|
2377
|
+
currentClosestKeyword = keyword;
|
|
2378
|
+
}
|
|
2379
|
+
}
|
|
2380
|
+
return currentClosestKeyword;
|
|
2381
|
+
};
|
|
2382
|
+
convert.keyword.rgb = function(keyword) {
|
|
2383
|
+
return cssKeywords[keyword];
|
|
2384
|
+
};
|
|
2385
|
+
convert.rgb.xyz = function(rgb) {
|
|
2386
|
+
let r = rgb[0] / 255;
|
|
2387
|
+
let g = rgb[1] / 255;
|
|
2388
|
+
let b = rgb[2] / 255;
|
|
2389
|
+
r = r > 0.04045 ? ((r + 0.055) / 1.055) ** 2.4 : r / 12.92;
|
|
2390
|
+
g = g > 0.04045 ? ((g + 0.055) / 1.055) ** 2.4 : g / 12.92;
|
|
2391
|
+
b = b > 0.04045 ? ((b + 0.055) / 1.055) ** 2.4 : b / 12.92;
|
|
2392
|
+
const x = r * 0.4124 + g * 0.3576 + b * 0.1805;
|
|
2393
|
+
const y = r * 0.2126 + g * 0.7152 + b * 0.0722;
|
|
2394
|
+
const z = r * 0.0193 + g * 0.1192 + b * 0.9505;
|
|
2395
|
+
return [x * 100, y * 100, z * 100];
|
|
2396
|
+
};
|
|
2397
|
+
convert.rgb.lab = function(rgb) {
|
|
2398
|
+
const xyz = convert.rgb.xyz(rgb);
|
|
2399
|
+
let x = xyz[0];
|
|
2400
|
+
let y = xyz[1];
|
|
2401
|
+
let z = xyz[2];
|
|
2402
|
+
x /= 95.047;
|
|
2403
|
+
y /= 100;
|
|
2404
|
+
z /= 108.883;
|
|
2405
|
+
x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
|
|
2406
|
+
y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
|
|
2407
|
+
z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
|
|
2408
|
+
const l = 116 * y - 16;
|
|
2409
|
+
const a = 500 * (x - y);
|
|
2410
|
+
const b = 200 * (y - z);
|
|
2411
|
+
return [l, a, b];
|
|
2412
|
+
};
|
|
2413
|
+
convert.hsl.rgb = function(hsl) {
|
|
2414
|
+
const h = hsl[0] / 360;
|
|
2415
|
+
const s = hsl[1] / 100;
|
|
2416
|
+
const l = hsl[2] / 100;
|
|
2417
|
+
let t2;
|
|
2418
|
+
let t3;
|
|
2419
|
+
let val;
|
|
2420
|
+
if (s === 0) {
|
|
2421
|
+
val = l * 255;
|
|
2422
|
+
return [val, val, val];
|
|
2423
|
+
}
|
|
2424
|
+
if (l < 0.5) {
|
|
2425
|
+
t2 = l * (1 + s);
|
|
2426
|
+
} else {
|
|
2427
|
+
t2 = l + s - l * s;
|
|
2428
|
+
}
|
|
2429
|
+
const t1 = 2 * l - t2;
|
|
2430
|
+
const rgb = [0, 0, 0];
|
|
2431
|
+
for (let i = 0; i < 3; i++) {
|
|
2432
|
+
t3 = h + 1 / 3 * -(i - 1);
|
|
2433
|
+
if (t3 < 0) {
|
|
2434
|
+
t3++;
|
|
2435
|
+
}
|
|
2436
|
+
if (t3 > 1) {
|
|
2437
|
+
t3--;
|
|
2438
|
+
}
|
|
2439
|
+
if (6 * t3 < 1) {
|
|
2440
|
+
val = t1 + (t2 - t1) * 6 * t3;
|
|
2441
|
+
} else if (2 * t3 < 1) {
|
|
2442
|
+
val = t2;
|
|
2443
|
+
} else if (3 * t3 < 2) {
|
|
2444
|
+
val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
|
|
2445
|
+
} else {
|
|
2446
|
+
val = t1;
|
|
2447
|
+
}
|
|
2448
|
+
rgb[i] = val * 255;
|
|
2449
|
+
}
|
|
2450
|
+
return rgb;
|
|
2451
|
+
};
|
|
2452
|
+
convert.hsl.hsv = function(hsl) {
|
|
2453
|
+
const h = hsl[0];
|
|
2454
|
+
let s = hsl[1] / 100;
|
|
2455
|
+
let l = hsl[2] / 100;
|
|
2456
|
+
let smin = s;
|
|
2457
|
+
const lmin = Math.max(l, 0.01);
|
|
2458
|
+
l *= 2;
|
|
2459
|
+
s *= l <= 1 ? l : 2 - l;
|
|
2460
|
+
smin *= lmin <= 1 ? lmin : 2 - lmin;
|
|
2461
|
+
const v = (l + s) / 2;
|
|
2462
|
+
const sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
|
|
2463
|
+
return [h, sv * 100, v * 100];
|
|
2464
|
+
};
|
|
2465
|
+
convert.hsv.rgb = function(hsv) {
|
|
2466
|
+
const h = hsv[0] / 60;
|
|
2467
|
+
const s = hsv[1] / 100;
|
|
2468
|
+
let v = hsv[2] / 100;
|
|
2469
|
+
const hi = Math.floor(h) % 6;
|
|
2470
|
+
const f = h - Math.floor(h);
|
|
2471
|
+
const p = 255 * v * (1 - s);
|
|
2472
|
+
const q = 255 * v * (1 - s * f);
|
|
2473
|
+
const t = 255 * v * (1 - s * (1 - f));
|
|
2474
|
+
v *= 255;
|
|
2475
|
+
switch (hi) {
|
|
2476
|
+
case 0:
|
|
2477
|
+
return [v, t, p];
|
|
2478
|
+
case 1:
|
|
2479
|
+
return [q, v, p];
|
|
2480
|
+
case 2:
|
|
2481
|
+
return [p, v, t];
|
|
2482
|
+
case 3:
|
|
2483
|
+
return [p, q, v];
|
|
2484
|
+
case 4:
|
|
2485
|
+
return [t, p, v];
|
|
2486
|
+
case 5:
|
|
2487
|
+
return [v, p, q];
|
|
2488
|
+
}
|
|
2489
|
+
};
|
|
2490
|
+
convert.hsv.hsl = function(hsv) {
|
|
2491
|
+
const h = hsv[0];
|
|
2492
|
+
const s = hsv[1] / 100;
|
|
2493
|
+
const v = hsv[2] / 100;
|
|
2494
|
+
const vmin = Math.max(v, 0.01);
|
|
2495
|
+
let sl;
|
|
2496
|
+
let l;
|
|
2497
|
+
l = (2 - s) * v;
|
|
2498
|
+
const lmin = (2 - s) * vmin;
|
|
2499
|
+
sl = s * vmin;
|
|
2500
|
+
sl /= lmin <= 1 ? lmin : 2 - lmin;
|
|
2501
|
+
sl = sl || 0;
|
|
2502
|
+
l /= 2;
|
|
2503
|
+
return [h, sl * 100, l * 100];
|
|
2504
|
+
};
|
|
2505
|
+
convert.hwb.rgb = function(hwb) {
|
|
2506
|
+
const h = hwb[0] / 360;
|
|
2507
|
+
let wh = hwb[1] / 100;
|
|
2508
|
+
let bl = hwb[2] / 100;
|
|
2509
|
+
const ratio = wh + bl;
|
|
2510
|
+
let f;
|
|
2511
|
+
if (ratio > 1) {
|
|
2512
|
+
wh /= ratio;
|
|
2513
|
+
bl /= ratio;
|
|
2514
|
+
}
|
|
2515
|
+
const i = Math.floor(6 * h);
|
|
2516
|
+
const v = 1 - bl;
|
|
2517
|
+
f = 6 * h - i;
|
|
2518
|
+
if ((i & 1) !== 0) {
|
|
2519
|
+
f = 1 - f;
|
|
2520
|
+
}
|
|
2521
|
+
const n = wh + f * (v - wh);
|
|
2522
|
+
let r;
|
|
2523
|
+
let g;
|
|
2524
|
+
let b;
|
|
2525
|
+
switch (i) {
|
|
2526
|
+
default:
|
|
2527
|
+
case 6:
|
|
2528
|
+
case 0:
|
|
2529
|
+
r = v;
|
|
2530
|
+
g = n;
|
|
2531
|
+
b = wh;
|
|
2532
|
+
break;
|
|
2533
|
+
case 1:
|
|
2534
|
+
r = n;
|
|
2535
|
+
g = v;
|
|
2536
|
+
b = wh;
|
|
2537
|
+
break;
|
|
2538
|
+
case 2:
|
|
2539
|
+
r = wh;
|
|
2540
|
+
g = v;
|
|
2541
|
+
b = n;
|
|
2542
|
+
break;
|
|
2543
|
+
case 3:
|
|
2544
|
+
r = wh;
|
|
2545
|
+
g = n;
|
|
2546
|
+
b = v;
|
|
2547
|
+
break;
|
|
2548
|
+
case 4:
|
|
2549
|
+
r = n;
|
|
2550
|
+
g = wh;
|
|
2551
|
+
b = v;
|
|
2552
|
+
break;
|
|
2553
|
+
case 5:
|
|
2554
|
+
r = v;
|
|
2555
|
+
g = wh;
|
|
2556
|
+
b = n;
|
|
2557
|
+
break;
|
|
2558
|
+
}
|
|
2559
|
+
return [r * 255, g * 255, b * 255];
|
|
2560
|
+
};
|
|
2561
|
+
convert.cmyk.rgb = function(cmyk) {
|
|
2562
|
+
const c = cmyk[0] / 100;
|
|
2563
|
+
const m = cmyk[1] / 100;
|
|
2564
|
+
const y = cmyk[2] / 100;
|
|
2565
|
+
const k = cmyk[3] / 100;
|
|
2566
|
+
const r = 1 - Math.min(1, c * (1 - k) + k);
|
|
2567
|
+
const g = 1 - Math.min(1, m * (1 - k) + k);
|
|
2568
|
+
const b = 1 - Math.min(1, y * (1 - k) + k);
|
|
2569
|
+
return [r * 255, g * 255, b * 255];
|
|
2570
|
+
};
|
|
2571
|
+
convert.xyz.rgb = function(xyz) {
|
|
2572
|
+
const x = xyz[0] / 100;
|
|
2573
|
+
const y = xyz[1] / 100;
|
|
2574
|
+
const z = xyz[2] / 100;
|
|
2575
|
+
let r;
|
|
2576
|
+
let g;
|
|
2577
|
+
let b;
|
|
2578
|
+
r = x * 3.2406 + y * -1.5372 + z * -0.4986;
|
|
2579
|
+
g = x * -0.9689 + y * 1.8758 + z * 0.0415;
|
|
2580
|
+
b = x * 0.0557 + y * -0.204 + z * 1.057;
|
|
2581
|
+
r = r > 31308e-7 ? 1.055 * r ** (1 / 2.4) - 0.055 : r * 12.92;
|
|
2582
|
+
g = g > 31308e-7 ? 1.055 * g ** (1 / 2.4) - 0.055 : g * 12.92;
|
|
2583
|
+
b = b > 31308e-7 ? 1.055 * b ** (1 / 2.4) - 0.055 : b * 12.92;
|
|
2584
|
+
r = Math.min(Math.max(0, r), 1);
|
|
2585
|
+
g = Math.min(Math.max(0, g), 1);
|
|
2586
|
+
b = Math.min(Math.max(0, b), 1);
|
|
2587
|
+
return [r * 255, g * 255, b * 255];
|
|
2588
|
+
};
|
|
2589
|
+
convert.xyz.lab = function(xyz) {
|
|
2590
|
+
let x = xyz[0];
|
|
2591
|
+
let y = xyz[1];
|
|
2592
|
+
let z = xyz[2];
|
|
2593
|
+
x /= 95.047;
|
|
2594
|
+
y /= 100;
|
|
2595
|
+
z /= 108.883;
|
|
2596
|
+
x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
|
|
2597
|
+
y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
|
|
2598
|
+
z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
|
|
2599
|
+
const l = 116 * y - 16;
|
|
2600
|
+
const a = 500 * (x - y);
|
|
2601
|
+
const b = 200 * (y - z);
|
|
2602
|
+
return [l, a, b];
|
|
2603
|
+
};
|
|
2604
|
+
convert.lab.xyz = function(lab) {
|
|
2605
|
+
const l = lab[0];
|
|
2606
|
+
const a = lab[1];
|
|
2607
|
+
const b = lab[2];
|
|
2608
|
+
let x;
|
|
2609
|
+
let y;
|
|
2610
|
+
let z;
|
|
2611
|
+
y = (l + 16) / 116;
|
|
2612
|
+
x = a / 500 + y;
|
|
2613
|
+
z = y - b / 200;
|
|
2614
|
+
const y2 = y ** 3;
|
|
2615
|
+
const x2 = x ** 3;
|
|
2616
|
+
const z2 = z ** 3;
|
|
2617
|
+
y = y2 > 8856e-6 ? y2 : (y - 16 / 116) / 7.787;
|
|
2618
|
+
x = x2 > 8856e-6 ? x2 : (x - 16 / 116) / 7.787;
|
|
2619
|
+
z = z2 > 8856e-6 ? z2 : (z - 16 / 116) / 7.787;
|
|
2620
|
+
x *= 95.047;
|
|
2621
|
+
y *= 100;
|
|
2622
|
+
z *= 108.883;
|
|
2623
|
+
return [x, y, z];
|
|
2624
|
+
};
|
|
2625
|
+
convert.lab.lch = function(lab) {
|
|
2626
|
+
const l = lab[0];
|
|
2627
|
+
const a = lab[1];
|
|
2628
|
+
const b = lab[2];
|
|
2629
|
+
let h;
|
|
2630
|
+
const hr = Math.atan2(b, a);
|
|
2631
|
+
h = hr * 360 / 2 / Math.PI;
|
|
2632
|
+
if (h < 0) {
|
|
2633
|
+
h += 360;
|
|
2634
|
+
}
|
|
2635
|
+
const c = Math.sqrt(a * a + b * b);
|
|
2636
|
+
return [l, c, h];
|
|
2637
|
+
};
|
|
2638
|
+
convert.lch.lab = function(lch) {
|
|
2639
|
+
const l = lch[0];
|
|
2640
|
+
const c = lch[1];
|
|
2641
|
+
const h = lch[2];
|
|
2642
|
+
const hr = h / 360 * 2 * Math.PI;
|
|
2643
|
+
const a = c * Math.cos(hr);
|
|
2644
|
+
const b = c * Math.sin(hr);
|
|
2645
|
+
return [l, a, b];
|
|
2646
|
+
};
|
|
2647
|
+
convert.rgb.ansi16 = function(args, saturation = null) {
|
|
2648
|
+
const [r, g, b] = args;
|
|
2649
|
+
let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation;
|
|
2650
|
+
value = Math.round(value / 50);
|
|
2651
|
+
if (value === 0) {
|
|
2652
|
+
return 30;
|
|
2653
|
+
}
|
|
2654
|
+
let ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
|
|
2655
|
+
if (value === 2) {
|
|
2656
|
+
ansi += 60;
|
|
2657
|
+
}
|
|
2658
|
+
return ansi;
|
|
2659
|
+
};
|
|
2660
|
+
convert.hsv.ansi16 = function(args) {
|
|
2661
|
+
return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
|
|
2662
|
+
};
|
|
2663
|
+
convert.rgb.ansi256 = function(args) {
|
|
2664
|
+
const r = args[0];
|
|
2665
|
+
const g = args[1];
|
|
2666
|
+
const b = args[2];
|
|
2667
|
+
if (r === g && g === b) {
|
|
2668
|
+
if (r < 8) {
|
|
2669
|
+
return 16;
|
|
2670
|
+
}
|
|
2671
|
+
if (r > 248) {
|
|
2672
|
+
return 231;
|
|
2673
|
+
}
|
|
2674
|
+
return Math.round((r - 8) / 247 * 24) + 232;
|
|
2675
|
+
}
|
|
2676
|
+
const ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
|
|
2677
|
+
return ansi;
|
|
2678
|
+
};
|
|
2679
|
+
convert.ansi16.rgb = function(args) {
|
|
2680
|
+
let color = args % 10;
|
|
2681
|
+
if (color === 0 || color === 7) {
|
|
2682
|
+
if (args > 50) {
|
|
2683
|
+
color += 3.5;
|
|
2684
|
+
}
|
|
2685
|
+
color = color / 10.5 * 255;
|
|
2686
|
+
return [color, color, color];
|
|
2687
|
+
}
|
|
2688
|
+
const mult = (~~(args > 50) + 1) * 0.5;
|
|
2689
|
+
const r = (color & 1) * mult * 255;
|
|
2690
|
+
const g = (color >> 1 & 1) * mult * 255;
|
|
2691
|
+
const b = (color >> 2 & 1) * mult * 255;
|
|
2692
|
+
return [r, g, b];
|
|
2693
|
+
};
|
|
2694
|
+
convert.ansi256.rgb = function(args) {
|
|
2695
|
+
if (args >= 232) {
|
|
2696
|
+
const c = (args - 232) * 10 + 8;
|
|
2697
|
+
return [c, c, c];
|
|
2698
|
+
}
|
|
2699
|
+
args -= 16;
|
|
2700
|
+
let rem;
|
|
2701
|
+
const r = Math.floor(args / 36) / 5 * 255;
|
|
2702
|
+
const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
|
|
2703
|
+
const b = rem % 6 / 5 * 255;
|
|
2704
|
+
return [r, g, b];
|
|
2705
|
+
};
|
|
2706
|
+
convert.rgb.hex = function(args) {
|
|
2707
|
+
const integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255);
|
|
2708
|
+
const string = integer.toString(16).toUpperCase();
|
|
2709
|
+
return "000000".substring(string.length) + string;
|
|
2710
|
+
};
|
|
2711
|
+
convert.hex.rgb = function(args) {
|
|
2712
|
+
const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
|
|
2713
|
+
if (!match) {
|
|
2714
|
+
return [0, 0, 0];
|
|
2715
|
+
}
|
|
2716
|
+
let colorString = match[0];
|
|
2717
|
+
if (match[0].length === 3) {
|
|
2718
|
+
colorString = colorString.split("").map((char) => {
|
|
2719
|
+
return char + char;
|
|
2720
|
+
}).join("");
|
|
2721
|
+
}
|
|
2722
|
+
const integer = parseInt(colorString, 16);
|
|
2723
|
+
const r = integer >> 16 & 255;
|
|
2724
|
+
const g = integer >> 8 & 255;
|
|
2725
|
+
const b = integer & 255;
|
|
2726
|
+
return [r, g, b];
|
|
2727
|
+
};
|
|
2728
|
+
convert.rgb.hcg = function(rgb) {
|
|
2729
|
+
const r = rgb[0] / 255;
|
|
2730
|
+
const g = rgb[1] / 255;
|
|
2731
|
+
const b = rgb[2] / 255;
|
|
2732
|
+
const max = Math.max(Math.max(r, g), b);
|
|
2733
|
+
const min = Math.min(Math.min(r, g), b);
|
|
2734
|
+
const chroma = max - min;
|
|
2735
|
+
let grayscale;
|
|
2736
|
+
let hue;
|
|
2737
|
+
if (chroma < 1) {
|
|
2738
|
+
grayscale = min / (1 - chroma);
|
|
2739
|
+
} else {
|
|
2740
|
+
grayscale = 0;
|
|
2741
|
+
}
|
|
2742
|
+
if (chroma <= 0) {
|
|
2743
|
+
hue = 0;
|
|
2744
|
+
} else if (max === r) {
|
|
2745
|
+
hue = (g - b) / chroma % 6;
|
|
2746
|
+
} else if (max === g) {
|
|
2747
|
+
hue = 2 + (b - r) / chroma;
|
|
2748
|
+
} else {
|
|
2749
|
+
hue = 4 + (r - g) / chroma;
|
|
2750
|
+
}
|
|
2751
|
+
hue /= 6;
|
|
2752
|
+
hue %= 1;
|
|
2753
|
+
return [hue * 360, chroma * 100, grayscale * 100];
|
|
2754
|
+
};
|
|
2755
|
+
convert.hsl.hcg = function(hsl) {
|
|
2756
|
+
const s = hsl[1] / 100;
|
|
2757
|
+
const l = hsl[2] / 100;
|
|
2758
|
+
const c = l < 0.5 ? 2 * s * l : 2 * s * (1 - l);
|
|
2759
|
+
let f = 0;
|
|
2760
|
+
if (c < 1) {
|
|
2761
|
+
f = (l - 0.5 * c) / (1 - c);
|
|
2762
|
+
}
|
|
2763
|
+
return [hsl[0], c * 100, f * 100];
|
|
2764
|
+
};
|
|
2765
|
+
convert.hsv.hcg = function(hsv) {
|
|
2766
|
+
const s = hsv[1] / 100;
|
|
2767
|
+
const v = hsv[2] / 100;
|
|
2768
|
+
const c = s * v;
|
|
2769
|
+
let f = 0;
|
|
2770
|
+
if (c < 1) {
|
|
2771
|
+
f = (v - c) / (1 - c);
|
|
2772
|
+
}
|
|
2773
|
+
return [hsv[0], c * 100, f * 100];
|
|
2774
|
+
};
|
|
2775
|
+
convert.hcg.rgb = function(hcg) {
|
|
2776
|
+
const h = hcg[0] / 360;
|
|
2777
|
+
const c = hcg[1] / 100;
|
|
2778
|
+
const g = hcg[2] / 100;
|
|
2779
|
+
if (c === 0) {
|
|
2780
|
+
return [g * 255, g * 255, g * 255];
|
|
2781
|
+
}
|
|
2782
|
+
const pure = [0, 0, 0];
|
|
2783
|
+
const hi = h % 1 * 6;
|
|
2784
|
+
const v = hi % 1;
|
|
2785
|
+
const w = 1 - v;
|
|
2786
|
+
let mg = 0;
|
|
2787
|
+
switch (Math.floor(hi)) {
|
|
2788
|
+
case 0:
|
|
2789
|
+
pure[0] = 1;
|
|
2790
|
+
pure[1] = v;
|
|
2791
|
+
pure[2] = 0;
|
|
2792
|
+
break;
|
|
2793
|
+
case 1:
|
|
2794
|
+
pure[0] = w;
|
|
2795
|
+
pure[1] = 1;
|
|
2796
|
+
pure[2] = 0;
|
|
2797
|
+
break;
|
|
2798
|
+
case 2:
|
|
2799
|
+
pure[0] = 0;
|
|
2800
|
+
pure[1] = 1;
|
|
2801
|
+
pure[2] = v;
|
|
2802
|
+
break;
|
|
2803
|
+
case 3:
|
|
2804
|
+
pure[0] = 0;
|
|
2805
|
+
pure[1] = w;
|
|
2806
|
+
pure[2] = 1;
|
|
2807
|
+
break;
|
|
2808
|
+
case 4:
|
|
2809
|
+
pure[0] = v;
|
|
2810
|
+
pure[1] = 0;
|
|
2811
|
+
pure[2] = 1;
|
|
2812
|
+
break;
|
|
2813
|
+
default:
|
|
2814
|
+
pure[0] = 1;
|
|
2815
|
+
pure[1] = 0;
|
|
2816
|
+
pure[2] = w;
|
|
2817
|
+
}
|
|
2818
|
+
mg = (1 - c) * g;
|
|
2819
|
+
return [
|
|
2820
|
+
(c * pure[0] + mg) * 255,
|
|
2821
|
+
(c * pure[1] + mg) * 255,
|
|
2822
|
+
(c * pure[2] + mg) * 255
|
|
2823
|
+
];
|
|
2824
|
+
};
|
|
2825
|
+
convert.hcg.hsv = function(hcg) {
|
|
2826
|
+
const c = hcg[1] / 100;
|
|
2827
|
+
const g = hcg[2] / 100;
|
|
2828
|
+
const v = c + g * (1 - c);
|
|
2829
|
+
let f = 0;
|
|
2830
|
+
if (v > 0) {
|
|
2831
|
+
f = c / v;
|
|
2832
|
+
}
|
|
2833
|
+
return [hcg[0], f * 100, v * 100];
|
|
2834
|
+
};
|
|
2835
|
+
convert.hcg.hsl = function(hcg) {
|
|
2836
|
+
const c = hcg[1] / 100;
|
|
2837
|
+
const g = hcg[2] / 100;
|
|
2838
|
+
const l = g * (1 - c) + 0.5 * c;
|
|
2839
|
+
let s = 0;
|
|
2840
|
+
if (l > 0 && l < 0.5) {
|
|
2841
|
+
s = c / (2 * l);
|
|
2842
|
+
} else if (l >= 0.5 && l < 1) {
|
|
2843
|
+
s = c / (2 * (1 - l));
|
|
2844
|
+
}
|
|
2845
|
+
return [hcg[0], s * 100, l * 100];
|
|
2846
|
+
};
|
|
2847
|
+
convert.hcg.hwb = function(hcg) {
|
|
2848
|
+
const c = hcg[1] / 100;
|
|
2849
|
+
const g = hcg[2] / 100;
|
|
2850
|
+
const v = c + g * (1 - c);
|
|
2851
|
+
return [hcg[0], (v - c) * 100, (1 - v) * 100];
|
|
2852
|
+
};
|
|
2853
|
+
convert.hwb.hcg = function(hwb) {
|
|
2854
|
+
const w = hwb[1] / 100;
|
|
2855
|
+
const b = hwb[2] / 100;
|
|
2856
|
+
const v = 1 - b;
|
|
2857
|
+
const c = v - w;
|
|
2858
|
+
let g = 0;
|
|
2859
|
+
if (c < 1) {
|
|
2860
|
+
g = (v - c) / (1 - c);
|
|
2861
|
+
}
|
|
2862
|
+
return [hwb[0], c * 100, g * 100];
|
|
2863
|
+
};
|
|
2864
|
+
convert.apple.rgb = function(apple) {
|
|
2865
|
+
return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
|
|
2866
|
+
};
|
|
2867
|
+
convert.rgb.apple = function(rgb) {
|
|
2868
|
+
return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
|
|
2869
|
+
};
|
|
2870
|
+
convert.gray.rgb = function(args) {
|
|
2871
|
+
return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
|
|
2872
|
+
};
|
|
2873
|
+
convert.gray.hsl = function(args) {
|
|
2874
|
+
return [0, 0, args[0]];
|
|
2875
|
+
};
|
|
2876
|
+
convert.gray.hsv = convert.gray.hsl;
|
|
2877
|
+
convert.gray.hwb = function(gray) {
|
|
2878
|
+
return [0, 100, gray[0]];
|
|
2879
|
+
};
|
|
2880
|
+
convert.gray.cmyk = function(gray) {
|
|
2881
|
+
return [0, 0, 0, gray[0]];
|
|
2882
|
+
};
|
|
2883
|
+
convert.gray.lab = function(gray) {
|
|
2884
|
+
return [gray[0], 0, 0];
|
|
2885
|
+
};
|
|
2886
|
+
convert.gray.hex = function(gray) {
|
|
2887
|
+
const val = Math.round(gray[0] / 100 * 255) & 255;
|
|
2888
|
+
const integer = (val << 16) + (val << 8) + val;
|
|
2889
|
+
const string = integer.toString(16).toUpperCase();
|
|
2890
|
+
return "000000".substring(string.length) + string;
|
|
2891
|
+
};
|
|
2892
|
+
convert.rgb.gray = function(rgb) {
|
|
2893
|
+
const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
|
|
2894
|
+
return [val / 255 * 100];
|
|
2895
|
+
};
|
|
2896
|
+
return conversions;
|
|
2897
|
+
}
|
|
2898
|
+
var route;
|
|
2899
|
+
var hasRequiredRoute;
|
|
2900
|
+
function requireRoute() {
|
|
2901
|
+
if (hasRequiredRoute) return route;
|
|
2902
|
+
hasRequiredRoute = 1;
|
|
2903
|
+
const conversions2 = requireConversions();
|
|
2904
|
+
function buildGraph() {
|
|
2905
|
+
const graph = {};
|
|
2906
|
+
const models = Object.keys(conversions2);
|
|
2907
|
+
for (let len = models.length, i = 0; i < len; i++) {
|
|
2908
|
+
graph[models[i]] = {
|
|
2909
|
+
// http://jsperf.com/1-vs-infinity
|
|
2910
|
+
// micro-opt, but this is simple.
|
|
2911
|
+
distance: -1,
|
|
2912
|
+
parent: null
|
|
2913
|
+
};
|
|
2914
|
+
}
|
|
2915
|
+
return graph;
|
|
2916
|
+
}
|
|
2917
|
+
function deriveBFS(fromModel) {
|
|
2918
|
+
const graph = buildGraph();
|
|
2919
|
+
const queue = [fromModel];
|
|
2920
|
+
graph[fromModel].distance = 0;
|
|
2921
|
+
while (queue.length) {
|
|
2922
|
+
const current = queue.pop();
|
|
2923
|
+
const adjacents = Object.keys(conversions2[current]);
|
|
2924
|
+
for (let len = adjacents.length, i = 0; i < len; i++) {
|
|
2925
|
+
const adjacent = adjacents[i];
|
|
2926
|
+
const node = graph[adjacent];
|
|
2927
|
+
if (node.distance === -1) {
|
|
2928
|
+
node.distance = graph[current].distance + 1;
|
|
2929
|
+
node.parent = current;
|
|
2930
|
+
queue.unshift(adjacent);
|
|
2931
|
+
}
|
|
2932
|
+
}
|
|
2933
|
+
}
|
|
2934
|
+
return graph;
|
|
2935
|
+
}
|
|
2936
|
+
function link(from, to) {
|
|
2937
|
+
return function(args) {
|
|
2938
|
+
return to(from(args));
|
|
2939
|
+
};
|
|
2940
|
+
}
|
|
2941
|
+
function wrapConversion(toModel, graph) {
|
|
2942
|
+
const path2 = [graph[toModel].parent, toModel];
|
|
2943
|
+
let fn = conversions2[graph[toModel].parent][toModel];
|
|
2944
|
+
let cur = graph[toModel].parent;
|
|
2945
|
+
while (graph[cur].parent) {
|
|
2946
|
+
path2.unshift(graph[cur].parent);
|
|
2947
|
+
fn = link(conversions2[graph[cur].parent][cur], fn);
|
|
2948
|
+
cur = graph[cur].parent;
|
|
2949
|
+
}
|
|
2950
|
+
fn.conversion = path2;
|
|
2951
|
+
return fn;
|
|
2952
|
+
}
|
|
2953
|
+
route = function(fromModel) {
|
|
2954
|
+
const graph = deriveBFS(fromModel);
|
|
2955
|
+
const conversion = {};
|
|
2956
|
+
const models = Object.keys(graph);
|
|
2957
|
+
for (let len = models.length, i = 0; i < len; i++) {
|
|
2958
|
+
const toModel = models[i];
|
|
2959
|
+
const node = graph[toModel];
|
|
2960
|
+
if (node.parent === null) {
|
|
2961
|
+
continue;
|
|
2962
|
+
}
|
|
2963
|
+
conversion[toModel] = wrapConversion(toModel, graph);
|
|
2964
|
+
}
|
|
2965
|
+
return conversion;
|
|
2966
|
+
};
|
|
2967
|
+
return route;
|
|
2968
|
+
}
|
|
2969
|
+
var colorConvert;
|
|
2970
|
+
var hasRequiredColorConvert;
|
|
2971
|
+
function requireColorConvert() {
|
|
2972
|
+
if (hasRequiredColorConvert) return colorConvert;
|
|
2973
|
+
hasRequiredColorConvert = 1;
|
|
2974
|
+
const conversions2 = requireConversions();
|
|
2975
|
+
const route2 = requireRoute();
|
|
2976
|
+
const convert = {};
|
|
2977
|
+
const models = Object.keys(conversions2);
|
|
2978
|
+
function wrapRaw(fn) {
|
|
2979
|
+
const wrappedFn = function(...args) {
|
|
2980
|
+
const arg0 = args[0];
|
|
2981
|
+
if (arg0 === void 0 || arg0 === null) {
|
|
2982
|
+
return arg0;
|
|
2983
|
+
}
|
|
2984
|
+
if (arg0.length > 1) {
|
|
2985
|
+
args = arg0;
|
|
2986
|
+
}
|
|
2987
|
+
return fn(args);
|
|
2988
|
+
};
|
|
2989
|
+
if ("conversion" in fn) {
|
|
2990
|
+
wrappedFn.conversion = fn.conversion;
|
|
2991
|
+
}
|
|
2992
|
+
return wrappedFn;
|
|
2993
|
+
}
|
|
2994
|
+
function wrapRounded(fn) {
|
|
2995
|
+
const wrappedFn = function(...args) {
|
|
2996
|
+
const arg0 = args[0];
|
|
2997
|
+
if (arg0 === void 0 || arg0 === null) {
|
|
2998
|
+
return arg0;
|
|
2999
|
+
}
|
|
3000
|
+
if (arg0.length > 1) {
|
|
3001
|
+
args = arg0;
|
|
3002
|
+
}
|
|
3003
|
+
const result = fn(args);
|
|
3004
|
+
if (typeof result === "object") {
|
|
3005
|
+
for (let len = result.length, i = 0; i < len; i++) {
|
|
3006
|
+
result[i] = Math.round(result[i]);
|
|
3007
|
+
}
|
|
3008
|
+
}
|
|
3009
|
+
return result;
|
|
3010
|
+
};
|
|
3011
|
+
if ("conversion" in fn) {
|
|
3012
|
+
wrappedFn.conversion = fn.conversion;
|
|
3013
|
+
}
|
|
3014
|
+
return wrappedFn;
|
|
3015
|
+
}
|
|
3016
|
+
models.forEach((fromModel) => {
|
|
3017
|
+
convert[fromModel] = {};
|
|
3018
|
+
Object.defineProperty(convert[fromModel], "channels", { value: conversions2[fromModel].channels });
|
|
3019
|
+
Object.defineProperty(convert[fromModel], "labels", { value: conversions2[fromModel].labels });
|
|
3020
|
+
const routes = route2(fromModel);
|
|
3021
|
+
const routeModels = Object.keys(routes);
|
|
3022
|
+
routeModels.forEach((toModel) => {
|
|
3023
|
+
const fn = routes[toModel];
|
|
3024
|
+
convert[fromModel][toModel] = wrapRounded(fn);
|
|
3025
|
+
convert[fromModel][toModel].raw = wrapRaw(fn);
|
|
3026
|
+
});
|
|
3027
|
+
});
|
|
3028
|
+
colorConvert = convert;
|
|
3029
|
+
return colorConvert;
|
|
3030
|
+
}
|
|
3031
|
+
ansiStyles$1.exports;
|
|
3032
|
+
(function(module) {
|
|
3033
|
+
const wrapAnsi16 = (fn, offset) => (...args) => {
|
|
3034
|
+
const code = fn(...args);
|
|
3035
|
+
return `\x1B[${code + offset}m`;
|
|
3036
|
+
};
|
|
3037
|
+
const wrapAnsi256 = (fn, offset) => (...args) => {
|
|
3038
|
+
const code = fn(...args);
|
|
3039
|
+
return `\x1B[${38 + offset};5;${code}m`;
|
|
3040
|
+
};
|
|
3041
|
+
const wrapAnsi16m = (fn, offset) => (...args) => {
|
|
3042
|
+
const rgb = fn(...args);
|
|
3043
|
+
return `\x1B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
|
|
3044
|
+
};
|
|
3045
|
+
const ansi2ansi = (n) => n;
|
|
3046
|
+
const rgb2rgb = (r, g, b) => [r, g, b];
|
|
3047
|
+
const setLazyProperty = (object, property, get) => {
|
|
3048
|
+
Object.defineProperty(object, property, {
|
|
3049
|
+
get: () => {
|
|
3050
|
+
const value = get();
|
|
3051
|
+
Object.defineProperty(object, property, {
|
|
3052
|
+
value,
|
|
3053
|
+
enumerable: true,
|
|
3054
|
+
configurable: true
|
|
3055
|
+
});
|
|
3056
|
+
return value;
|
|
3057
|
+
},
|
|
3058
|
+
enumerable: true,
|
|
3059
|
+
configurable: true
|
|
3060
|
+
});
|
|
3061
|
+
};
|
|
3062
|
+
let colorConvert2;
|
|
3063
|
+
const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
|
|
3064
|
+
if (colorConvert2 === void 0) {
|
|
3065
|
+
colorConvert2 = requireColorConvert();
|
|
3066
|
+
}
|
|
3067
|
+
const offset = isBackground ? 10 : 0;
|
|
3068
|
+
const styles2 = {};
|
|
3069
|
+
for (const [sourceSpace, suite] of Object.entries(colorConvert2)) {
|
|
3070
|
+
const name2 = sourceSpace === "ansi16" ? "ansi" : sourceSpace;
|
|
3071
|
+
if (sourceSpace === targetSpace) {
|
|
3072
|
+
styles2[name2] = wrap(identity, offset);
|
|
3073
|
+
} else if (typeof suite === "object") {
|
|
3074
|
+
styles2[name2] = wrap(suite[targetSpace], offset);
|
|
3075
|
+
}
|
|
3076
|
+
}
|
|
3077
|
+
return styles2;
|
|
3078
|
+
};
|
|
3079
|
+
function assembleStyles() {
|
|
3080
|
+
const codes = /* @__PURE__ */ new Map();
|
|
3081
|
+
const styles2 = {
|
|
3082
|
+
modifier: {
|
|
3083
|
+
reset: [0, 0],
|
|
3084
|
+
// 21 isn't widely supported and 22 does the same thing
|
|
3085
|
+
bold: [1, 22],
|
|
3086
|
+
dim: [2, 22],
|
|
3087
|
+
italic: [3, 23],
|
|
3088
|
+
underline: [4, 24],
|
|
3089
|
+
inverse: [7, 27],
|
|
3090
|
+
hidden: [8, 28],
|
|
3091
|
+
strikethrough: [9, 29]
|
|
3092
|
+
},
|
|
3093
|
+
color: {
|
|
3094
|
+
black: [30, 39],
|
|
3095
|
+
red: [31, 39],
|
|
3096
|
+
green: [32, 39],
|
|
3097
|
+
yellow: [33, 39],
|
|
3098
|
+
blue: [34, 39],
|
|
3099
|
+
magenta: [35, 39],
|
|
3100
|
+
cyan: [36, 39],
|
|
3101
|
+
white: [37, 39],
|
|
3102
|
+
// Bright color
|
|
3103
|
+
blackBright: [90, 39],
|
|
3104
|
+
redBright: [91, 39],
|
|
3105
|
+
greenBright: [92, 39],
|
|
3106
|
+
yellowBright: [93, 39],
|
|
3107
|
+
blueBright: [94, 39],
|
|
3108
|
+
magentaBright: [95, 39],
|
|
3109
|
+
cyanBright: [96, 39],
|
|
3110
|
+
whiteBright: [97, 39]
|
|
3111
|
+
},
|
|
3112
|
+
bgColor: {
|
|
3113
|
+
bgBlack: [40, 49],
|
|
3114
|
+
bgRed: [41, 49],
|
|
3115
|
+
bgGreen: [42, 49],
|
|
3116
|
+
bgYellow: [43, 49],
|
|
3117
|
+
bgBlue: [44, 49],
|
|
3118
|
+
bgMagenta: [45, 49],
|
|
3119
|
+
bgCyan: [46, 49],
|
|
3120
|
+
bgWhite: [47, 49],
|
|
3121
|
+
// Bright color
|
|
3122
|
+
bgBlackBright: [100, 49],
|
|
3123
|
+
bgRedBright: [101, 49],
|
|
3124
|
+
bgGreenBright: [102, 49],
|
|
3125
|
+
bgYellowBright: [103, 49],
|
|
3126
|
+
bgBlueBright: [104, 49],
|
|
3127
|
+
bgMagentaBright: [105, 49],
|
|
3128
|
+
bgCyanBright: [106, 49],
|
|
3129
|
+
bgWhiteBright: [107, 49]
|
|
3130
|
+
}
|
|
3131
|
+
};
|
|
3132
|
+
styles2.color.gray = styles2.color.blackBright;
|
|
3133
|
+
styles2.bgColor.bgGray = styles2.bgColor.bgBlackBright;
|
|
3134
|
+
styles2.color.grey = styles2.color.blackBright;
|
|
3135
|
+
styles2.bgColor.bgGrey = styles2.bgColor.bgBlackBright;
|
|
3136
|
+
for (const [groupName, group] of Object.entries(styles2)) {
|
|
3137
|
+
for (const [styleName, style] of Object.entries(group)) {
|
|
3138
|
+
styles2[styleName] = {
|
|
3139
|
+
open: `\x1B[${style[0]}m`,
|
|
3140
|
+
close: `\x1B[${style[1]}m`
|
|
3141
|
+
};
|
|
3142
|
+
group[styleName] = styles2[styleName];
|
|
3143
|
+
codes.set(style[0], style[1]);
|
|
3144
|
+
}
|
|
3145
|
+
Object.defineProperty(styles2, groupName, {
|
|
3146
|
+
value: group,
|
|
3147
|
+
enumerable: false
|
|
3148
|
+
});
|
|
3149
|
+
}
|
|
3150
|
+
Object.defineProperty(styles2, "codes", {
|
|
3151
|
+
value: codes,
|
|
3152
|
+
enumerable: false
|
|
3153
|
+
});
|
|
3154
|
+
styles2.color.close = "\x1B[39m";
|
|
3155
|
+
styles2.bgColor.close = "\x1B[49m";
|
|
3156
|
+
setLazyProperty(styles2.color, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, false));
|
|
3157
|
+
setLazyProperty(styles2.color, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, false));
|
|
3158
|
+
setLazyProperty(styles2.color, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, false));
|
|
3159
|
+
setLazyProperty(styles2.bgColor, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, true));
|
|
3160
|
+
setLazyProperty(styles2.bgColor, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, true));
|
|
3161
|
+
setLazyProperty(styles2.bgColor, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, true));
|
|
3162
|
+
return styles2;
|
|
3163
|
+
}
|
|
3164
|
+
Object.defineProperty(module, "exports", {
|
|
3165
|
+
enumerable: true,
|
|
3166
|
+
get: assembleStyles
|
|
3167
|
+
});
|
|
3168
|
+
})(ansiStyles$1);
|
|
3169
|
+
var ansiStylesExports = ansiStyles$1.exports;
|
|
3170
|
+
var browser = {
|
|
3171
|
+
stdout: false,
|
|
3172
|
+
stderr: false
|
|
3173
|
+
};
|
|
3174
|
+
const stringReplaceAll$1 = (string, substring, replacer) => {
|
|
3175
|
+
let index = string.indexOf(substring);
|
|
3176
|
+
if (index === -1) {
|
|
3177
|
+
return string;
|
|
3178
|
+
}
|
|
3179
|
+
const substringLength = substring.length;
|
|
3180
|
+
let endIndex = 0;
|
|
3181
|
+
let returnValue = "";
|
|
3182
|
+
do {
|
|
3183
|
+
returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
|
|
3184
|
+
endIndex = index + substringLength;
|
|
3185
|
+
index = string.indexOf(substring, endIndex);
|
|
3186
|
+
} while (index !== -1);
|
|
3187
|
+
returnValue += string.substr(endIndex);
|
|
3188
|
+
return returnValue;
|
|
3189
|
+
};
|
|
3190
|
+
const stringEncaseCRLFWithFirstIndex$1 = (string, prefix, postfix, index) => {
|
|
3191
|
+
let endIndex = 0;
|
|
3192
|
+
let returnValue = "";
|
|
3193
|
+
do {
|
|
3194
|
+
const gotCR = string[index - 1] === "\r";
|
|
3195
|
+
returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
|
|
3196
|
+
endIndex = index + 1;
|
|
3197
|
+
index = string.indexOf("\n", endIndex);
|
|
3198
|
+
} while (index !== -1);
|
|
3199
|
+
returnValue += string.substr(endIndex);
|
|
3200
|
+
return returnValue;
|
|
3201
|
+
};
|
|
3202
|
+
var util = {
|
|
3203
|
+
stringReplaceAll: stringReplaceAll$1,
|
|
3204
|
+
stringEncaseCRLFWithFirstIndex: stringEncaseCRLFWithFirstIndex$1
|
|
3205
|
+
};
|
|
3206
|
+
var templates;
|
|
3207
|
+
var hasRequiredTemplates;
|
|
3208
|
+
function requireTemplates() {
|
|
3209
|
+
if (hasRequiredTemplates) return templates;
|
|
3210
|
+
hasRequiredTemplates = 1;
|
|
3211
|
+
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;
|
|
3212
|
+
const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
|
|
3213
|
+
const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
|
|
3214
|
+
const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
|
|
3215
|
+
const ESCAPES = /* @__PURE__ */ new Map([
|
|
3216
|
+
["n", "\n"],
|
|
3217
|
+
["r", "\r"],
|
|
3218
|
+
["t", " "],
|
|
3219
|
+
["b", "\b"],
|
|
3220
|
+
["f", "\f"],
|
|
3221
|
+
["v", "\v"],
|
|
3222
|
+
["0", "\0"],
|
|
3223
|
+
["\\", "\\"],
|
|
3224
|
+
["e", "\x1B"],
|
|
3225
|
+
["a", "\x07"]
|
|
3226
|
+
]);
|
|
3227
|
+
function unescape(c) {
|
|
3228
|
+
const u = c[0] === "u";
|
|
3229
|
+
const bracket = c[1] === "{";
|
|
3230
|
+
if (u && !bracket && c.length === 5 || c[0] === "x" && c.length === 3) {
|
|
3231
|
+
return String.fromCharCode(parseInt(c.slice(1), 16));
|
|
3232
|
+
}
|
|
3233
|
+
if (u && bracket) {
|
|
3234
|
+
return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
|
|
3235
|
+
}
|
|
3236
|
+
return ESCAPES.get(c) || c;
|
|
3237
|
+
}
|
|
3238
|
+
function parseArguments(name2, arguments_) {
|
|
3239
|
+
const results = [];
|
|
3240
|
+
const chunks = arguments_.trim().split(/\s*,\s*/g);
|
|
3241
|
+
let matches;
|
|
3242
|
+
for (const chunk of chunks) {
|
|
3243
|
+
const number = Number(chunk);
|
|
3244
|
+
if (!Number.isNaN(number)) {
|
|
3245
|
+
results.push(number);
|
|
3246
|
+
} else if (matches = chunk.match(STRING_REGEX)) {
|
|
3247
|
+
results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape(escape) : character));
|
|
3248
|
+
} else {
|
|
3249
|
+
throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name2}')`);
|
|
3250
|
+
}
|
|
3251
|
+
}
|
|
3252
|
+
return results;
|
|
3253
|
+
}
|
|
3254
|
+
function parseStyle(style) {
|
|
3255
|
+
STYLE_REGEX.lastIndex = 0;
|
|
3256
|
+
const results = [];
|
|
3257
|
+
let matches;
|
|
3258
|
+
while ((matches = STYLE_REGEX.exec(style)) !== null) {
|
|
3259
|
+
const name2 = matches[1];
|
|
3260
|
+
if (matches[2]) {
|
|
3261
|
+
const args = parseArguments(name2, matches[2]);
|
|
3262
|
+
results.push([name2].concat(args));
|
|
3263
|
+
} else {
|
|
3264
|
+
results.push([name2]);
|
|
3265
|
+
}
|
|
3266
|
+
}
|
|
3267
|
+
return results;
|
|
3268
|
+
}
|
|
3269
|
+
function buildStyle(chalk2, styles2) {
|
|
3270
|
+
const enabled = {};
|
|
3271
|
+
for (const layer of styles2) {
|
|
3272
|
+
for (const style of layer.styles) {
|
|
3273
|
+
enabled[style[0]] = layer.inverse ? null : style.slice(1);
|
|
3274
|
+
}
|
|
3275
|
+
}
|
|
3276
|
+
let current = chalk2;
|
|
3277
|
+
for (const [styleName, styles3] of Object.entries(enabled)) {
|
|
3278
|
+
if (!Array.isArray(styles3)) {
|
|
3279
|
+
continue;
|
|
3280
|
+
}
|
|
3281
|
+
if (!(styleName in current)) {
|
|
3282
|
+
throw new Error(`Unknown Chalk style: ${styleName}`);
|
|
3283
|
+
}
|
|
3284
|
+
current = styles3.length > 0 ? current[styleName](...styles3) : current[styleName];
|
|
3285
|
+
}
|
|
3286
|
+
return current;
|
|
3287
|
+
}
|
|
3288
|
+
templates = (chalk2, temporary) => {
|
|
3289
|
+
const styles2 = [];
|
|
3290
|
+
const chunks = [];
|
|
3291
|
+
let chunk = [];
|
|
3292
|
+
temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
|
|
3293
|
+
if (escapeCharacter) {
|
|
3294
|
+
chunk.push(unescape(escapeCharacter));
|
|
3295
|
+
} else if (style) {
|
|
3296
|
+
const string = chunk.join("");
|
|
3297
|
+
chunk = [];
|
|
3298
|
+
chunks.push(styles2.length === 0 ? string : buildStyle(chalk2, styles2)(string));
|
|
3299
|
+
styles2.push({ inverse, styles: parseStyle(style) });
|
|
3300
|
+
} else if (close) {
|
|
3301
|
+
if (styles2.length === 0) {
|
|
3302
|
+
throw new Error("Found extraneous } in Chalk template literal");
|
|
3303
|
+
}
|
|
3304
|
+
chunks.push(buildStyle(chalk2, styles2)(chunk.join("")));
|
|
3305
|
+
chunk = [];
|
|
3306
|
+
styles2.pop();
|
|
3307
|
+
} else {
|
|
3308
|
+
chunk.push(character);
|
|
3309
|
+
}
|
|
3310
|
+
});
|
|
3311
|
+
chunks.push(chunk.join(""));
|
|
3312
|
+
if (styles2.length > 0) {
|
|
3313
|
+
const errMessage = `Chalk template literal is missing ${styles2.length} closing bracket${styles2.length === 1 ? "" : "s"} (\`}\`)`;
|
|
3314
|
+
throw new Error(errMessage);
|
|
3315
|
+
}
|
|
3316
|
+
return chunks.join("");
|
|
3317
|
+
};
|
|
3318
|
+
return templates;
|
|
3319
|
+
}
|
|
3320
|
+
const ansiStyles = ansiStylesExports;
|
|
3321
|
+
const { stdout: stdoutColor, stderr: stderrColor } = browser;
|
|
3322
|
+
const {
|
|
3323
|
+
stringReplaceAll,
|
|
3324
|
+
stringEncaseCRLFWithFirstIndex
|
|
3325
|
+
} = util;
|
|
3326
|
+
const { isArray } = Array;
|
|
3327
|
+
const levelMapping = [
|
|
3328
|
+
"ansi",
|
|
3329
|
+
"ansi",
|
|
3330
|
+
"ansi256",
|
|
3331
|
+
"ansi16m"
|
|
3332
|
+
];
|
|
3333
|
+
const styles = /* @__PURE__ */ Object.create(null);
|
|
3334
|
+
const applyOptions = (object, options = {}) => {
|
|
3335
|
+
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
|
3336
|
+
throw new Error("The `level` option should be an integer from 0 to 3");
|
|
3337
|
+
}
|
|
3338
|
+
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
|
3339
|
+
object.level = options.level === void 0 ? colorLevel : options.level;
|
|
3340
|
+
};
|
|
3341
|
+
class ChalkClass2 {
|
|
3342
|
+
constructor(options) {
|
|
3343
|
+
return chalkFactory(options);
|
|
3344
|
+
}
|
|
3345
|
+
}
|
|
3346
|
+
const chalkFactory = (options) => {
|
|
3347
|
+
const chalk2 = {};
|
|
3348
|
+
applyOptions(chalk2, options);
|
|
3349
|
+
chalk2.template = (...arguments_) => chalkTag(chalk2.template, ...arguments_);
|
|
3350
|
+
Object.setPrototypeOf(chalk2, Chalk.prototype);
|
|
3351
|
+
Object.setPrototypeOf(chalk2.template, chalk2);
|
|
3352
|
+
chalk2.template.constructor = () => {
|
|
3353
|
+
throw new Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.");
|
|
3354
|
+
};
|
|
3355
|
+
chalk2.template.Instance = ChalkClass2;
|
|
3356
|
+
return chalk2.template;
|
|
3357
|
+
};
|
|
3358
|
+
function Chalk(options) {
|
|
3359
|
+
return chalkFactory(options);
|
|
3360
|
+
}
|
|
3361
|
+
for (const [styleName, style] of Object.entries(ansiStyles)) {
|
|
3362
|
+
styles[styleName] = {
|
|
3363
|
+
get() {
|
|
3364
|
+
const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
|
|
3365
|
+
Object.defineProperty(this, styleName, { value: builder });
|
|
3366
|
+
return builder;
|
|
3367
|
+
}
|
|
3368
|
+
};
|
|
3369
|
+
}
|
|
3370
|
+
styles.visible = {
|
|
3371
|
+
get() {
|
|
3372
|
+
const builder = createBuilder(this, this._styler, true);
|
|
3373
|
+
Object.defineProperty(this, "visible", { value: builder });
|
|
3374
|
+
return builder;
|
|
3375
|
+
}
|
|
3376
|
+
};
|
|
3377
|
+
const usedModels = ["rgb", "hex", "keyword", "hsl", "hsv", "hwb", "ansi", "ansi256"];
|
|
3378
|
+
for (const model of usedModels) {
|
|
3379
|
+
styles[model] = {
|
|
3380
|
+
get() {
|
|
3381
|
+
const { level } = this;
|
|
3382
|
+
return function(...arguments_) {
|
|
3383
|
+
const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler);
|
|
3384
|
+
return createBuilder(this, styler, this._isEmpty);
|
|
3385
|
+
};
|
|
3386
|
+
}
|
|
3387
|
+
};
|
|
3388
|
+
}
|
|
3389
|
+
for (const model of usedModels) {
|
|
3390
|
+
const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
|
|
3391
|
+
styles[bgModel] = {
|
|
3392
|
+
get() {
|
|
3393
|
+
const { level } = this;
|
|
3394
|
+
return function(...arguments_) {
|
|
3395
|
+
const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler);
|
|
3396
|
+
return createBuilder(this, styler, this._isEmpty);
|
|
3397
|
+
};
|
|
3398
|
+
}
|
|
3399
|
+
};
|
|
3400
|
+
}
|
|
3401
|
+
const proto = Object.defineProperties(() => {
|
|
3402
|
+
}, {
|
|
3403
|
+
...styles,
|
|
3404
|
+
level: {
|
|
3405
|
+
enumerable: true,
|
|
3406
|
+
get() {
|
|
3407
|
+
return this._generator.level;
|
|
3408
|
+
},
|
|
3409
|
+
set(level) {
|
|
3410
|
+
this._generator.level = level;
|
|
3411
|
+
}
|
|
3412
|
+
}
|
|
3413
|
+
});
|
|
3414
|
+
const createStyler = (open, close, parent) => {
|
|
3415
|
+
let openAll;
|
|
3416
|
+
let closeAll;
|
|
3417
|
+
if (parent === void 0) {
|
|
3418
|
+
openAll = open;
|
|
3419
|
+
closeAll = close;
|
|
3420
|
+
} else {
|
|
3421
|
+
openAll = parent.openAll + open;
|
|
3422
|
+
closeAll = close + parent.closeAll;
|
|
3423
|
+
}
|
|
3424
|
+
return {
|
|
3425
|
+
open,
|
|
3426
|
+
close,
|
|
3427
|
+
openAll,
|
|
3428
|
+
closeAll,
|
|
3429
|
+
parent
|
|
3430
|
+
};
|
|
3431
|
+
};
|
|
3432
|
+
const createBuilder = (self, _styler, _isEmpty) => {
|
|
3433
|
+
const builder = (...arguments_) => {
|
|
3434
|
+
if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
|
|
3435
|
+
return applyStyle(builder, chalkTag(builder, ...arguments_));
|
|
3436
|
+
}
|
|
3437
|
+
return applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
|
|
3438
|
+
};
|
|
3439
|
+
Object.setPrototypeOf(builder, proto);
|
|
3440
|
+
builder._generator = self;
|
|
3441
|
+
builder._styler = _styler;
|
|
3442
|
+
builder._isEmpty = _isEmpty;
|
|
3443
|
+
return builder;
|
|
3444
|
+
};
|
|
3445
|
+
const applyStyle = (self, string) => {
|
|
3446
|
+
if (self.level <= 0 || !string) {
|
|
3447
|
+
return self._isEmpty ? "" : string;
|
|
3448
|
+
}
|
|
3449
|
+
let styler = self._styler;
|
|
3450
|
+
if (styler === void 0) {
|
|
3451
|
+
return string;
|
|
3452
|
+
}
|
|
3453
|
+
const { openAll, closeAll } = styler;
|
|
3454
|
+
if (string.indexOf("\x1B") !== -1) {
|
|
3455
|
+
while (styler !== void 0) {
|
|
3456
|
+
string = stringReplaceAll(string, styler.close, styler.open);
|
|
3457
|
+
styler = styler.parent;
|
|
3458
|
+
}
|
|
3459
|
+
}
|
|
3460
|
+
const lfIndex = string.indexOf("\n");
|
|
3461
|
+
if (lfIndex !== -1) {
|
|
3462
|
+
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
|
3463
|
+
}
|
|
3464
|
+
return openAll + string + closeAll;
|
|
3465
|
+
};
|
|
3466
|
+
let template;
|
|
3467
|
+
const chalkTag = (chalk2, ...strings) => {
|
|
3468
|
+
const [firstString] = strings;
|
|
3469
|
+
if (!isArray(firstString) || !isArray(firstString.raw)) {
|
|
3470
|
+
return strings.join(" ");
|
|
3471
|
+
}
|
|
3472
|
+
const arguments_ = strings.slice(1);
|
|
3473
|
+
const parts = [firstString.raw[0]];
|
|
3474
|
+
for (let i = 1; i < firstString.length; i++) {
|
|
3475
|
+
parts.push(
|
|
3476
|
+
String(arguments_[i - 1]).replace(/[{}\\]/g, "\\$&"),
|
|
3477
|
+
String(firstString.raw[i])
|
|
3478
|
+
);
|
|
3479
|
+
}
|
|
3480
|
+
if (template === void 0) {
|
|
3481
|
+
template = requireTemplates();
|
|
3482
|
+
}
|
|
3483
|
+
return template(chalk2, parts.join(""));
|
|
3484
|
+
};
|
|
3485
|
+
Object.defineProperties(Chalk.prototype, styles);
|
|
3486
|
+
const chalk = Chalk();
|
|
3487
|
+
chalk.supportsColor = stdoutColor;
|
|
3488
|
+
chalk.stderr = Chalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
3489
|
+
chalk.stderr.supportsColor = stderrColor;
|
|
3490
|
+
var source = chalk;
|
|
3491
|
+
const chalk$1 = /* @__PURE__ */ getDefaultExportFromCjs(source);
|
|
3492
|
+
var StatusCodes;
|
|
3493
|
+
(function(StatusCodes2) {
|
|
3494
|
+
StatusCodes2[StatusCodes2["CONTINUE"] = 100] = "CONTINUE";
|
|
3495
|
+
StatusCodes2[StatusCodes2["SWITCHING_PROTOCOLS"] = 101] = "SWITCHING_PROTOCOLS";
|
|
3496
|
+
StatusCodes2[StatusCodes2["PROCESSING"] = 102] = "PROCESSING";
|
|
3497
|
+
StatusCodes2[StatusCodes2["EARLY_HINTS"] = 103] = "EARLY_HINTS";
|
|
3498
|
+
StatusCodes2[StatusCodes2["OK"] = 200] = "OK";
|
|
3499
|
+
StatusCodes2[StatusCodes2["CREATED"] = 201] = "CREATED";
|
|
3500
|
+
StatusCodes2[StatusCodes2["ACCEPTED"] = 202] = "ACCEPTED";
|
|
3501
|
+
StatusCodes2[StatusCodes2["NON_AUTHORITATIVE_INFORMATION"] = 203] = "NON_AUTHORITATIVE_INFORMATION";
|
|
3502
|
+
StatusCodes2[StatusCodes2["NO_CONTENT"] = 204] = "NO_CONTENT";
|
|
3503
|
+
StatusCodes2[StatusCodes2["RESET_CONTENT"] = 205] = "RESET_CONTENT";
|
|
3504
|
+
StatusCodes2[StatusCodes2["PARTIAL_CONTENT"] = 206] = "PARTIAL_CONTENT";
|
|
3505
|
+
StatusCodes2[StatusCodes2["MULTI_STATUS"] = 207] = "MULTI_STATUS";
|
|
3506
|
+
StatusCodes2[StatusCodes2["MULTIPLE_CHOICES"] = 300] = "MULTIPLE_CHOICES";
|
|
3507
|
+
StatusCodes2[StatusCodes2["MOVED_PERMANENTLY"] = 301] = "MOVED_PERMANENTLY";
|
|
3508
|
+
StatusCodes2[StatusCodes2["MOVED_TEMPORARILY"] = 302] = "MOVED_TEMPORARILY";
|
|
3509
|
+
StatusCodes2[StatusCodes2["SEE_OTHER"] = 303] = "SEE_OTHER";
|
|
3510
|
+
StatusCodes2[StatusCodes2["NOT_MODIFIED"] = 304] = "NOT_MODIFIED";
|
|
3511
|
+
StatusCodes2[StatusCodes2["USE_PROXY"] = 305] = "USE_PROXY";
|
|
3512
|
+
StatusCodes2[StatusCodes2["TEMPORARY_REDIRECT"] = 307] = "TEMPORARY_REDIRECT";
|
|
3513
|
+
StatusCodes2[StatusCodes2["PERMANENT_REDIRECT"] = 308] = "PERMANENT_REDIRECT";
|
|
3514
|
+
StatusCodes2[StatusCodes2["BAD_REQUEST"] = 400] = "BAD_REQUEST";
|
|
3515
|
+
StatusCodes2[StatusCodes2["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
|
|
3516
|
+
StatusCodes2[StatusCodes2["PAYMENT_REQUIRED"] = 402] = "PAYMENT_REQUIRED";
|
|
3517
|
+
StatusCodes2[StatusCodes2["FORBIDDEN"] = 403] = "FORBIDDEN";
|
|
3518
|
+
StatusCodes2[StatusCodes2["NOT_FOUND"] = 404] = "NOT_FOUND";
|
|
3519
|
+
StatusCodes2[StatusCodes2["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
|
|
3520
|
+
StatusCodes2[StatusCodes2["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
|
|
3521
|
+
StatusCodes2[StatusCodes2["PROXY_AUTHENTICATION_REQUIRED"] = 407] = "PROXY_AUTHENTICATION_REQUIRED";
|
|
3522
|
+
StatusCodes2[StatusCodes2["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
|
|
3523
|
+
StatusCodes2[StatusCodes2["CONFLICT"] = 409] = "CONFLICT";
|
|
3524
|
+
StatusCodes2[StatusCodes2["GONE"] = 410] = "GONE";
|
|
3525
|
+
StatusCodes2[StatusCodes2["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED";
|
|
3526
|
+
StatusCodes2[StatusCodes2["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
|
|
3527
|
+
StatusCodes2[StatusCodes2["REQUEST_TOO_LONG"] = 413] = "REQUEST_TOO_LONG";
|
|
3528
|
+
StatusCodes2[StatusCodes2["REQUEST_URI_TOO_LONG"] = 414] = "REQUEST_URI_TOO_LONG";
|
|
3529
|
+
StatusCodes2[StatusCodes2["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
|
|
3530
|
+
StatusCodes2[StatusCodes2["REQUESTED_RANGE_NOT_SATISFIABLE"] = 416] = "REQUESTED_RANGE_NOT_SATISFIABLE";
|
|
3531
|
+
StatusCodes2[StatusCodes2["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
|
|
3532
|
+
StatusCodes2[StatusCodes2["IM_A_TEAPOT"] = 418] = "IM_A_TEAPOT";
|
|
3533
|
+
StatusCodes2[StatusCodes2["INSUFFICIENT_SPACE_ON_RESOURCE"] = 419] = "INSUFFICIENT_SPACE_ON_RESOURCE";
|
|
3534
|
+
StatusCodes2[StatusCodes2["METHOD_FAILURE"] = 420] = "METHOD_FAILURE";
|
|
3535
|
+
StatusCodes2[StatusCodes2["MISDIRECTED_REQUEST"] = 421] = "MISDIRECTED_REQUEST";
|
|
3536
|
+
StatusCodes2[StatusCodes2["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
|
|
3537
|
+
StatusCodes2[StatusCodes2["LOCKED"] = 423] = "LOCKED";
|
|
3538
|
+
StatusCodes2[StatusCodes2["FAILED_DEPENDENCY"] = 424] = "FAILED_DEPENDENCY";
|
|
3539
|
+
StatusCodes2[StatusCodes2["UPGRADE_REQUIRED"] = 426] = "UPGRADE_REQUIRED";
|
|
3540
|
+
StatusCodes2[StatusCodes2["PRECONDITION_REQUIRED"] = 428] = "PRECONDITION_REQUIRED";
|
|
3541
|
+
StatusCodes2[StatusCodes2["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
|
|
3542
|
+
StatusCodes2[StatusCodes2["REQUEST_HEADER_FIELDS_TOO_LARGE"] = 431] = "REQUEST_HEADER_FIELDS_TOO_LARGE";
|
|
3543
|
+
StatusCodes2[StatusCodes2["UNAVAILABLE_FOR_LEGAL_REASONS"] = 451] = "UNAVAILABLE_FOR_LEGAL_REASONS";
|
|
3544
|
+
StatusCodes2[StatusCodes2["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
|
|
3545
|
+
StatusCodes2[StatusCodes2["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
|
|
3546
|
+
StatusCodes2[StatusCodes2["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
|
|
3547
|
+
StatusCodes2[StatusCodes2["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
|
|
3548
|
+
StatusCodes2[StatusCodes2["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
|
|
3549
|
+
StatusCodes2[StatusCodes2["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
|
|
3550
|
+
StatusCodes2[StatusCodes2["INSUFFICIENT_STORAGE"] = 507] = "INSUFFICIENT_STORAGE";
|
|
3551
|
+
StatusCodes2[StatusCodes2["NETWORK_AUTHENTICATION_REQUIRED"] = 511] = "NETWORK_AUTHENTICATION_REQUIRED";
|
|
3552
|
+
})(StatusCodes || (StatusCodes = {}));
|
|
3553
|
+
class FhirClient {
|
|
3554
|
+
constructor(options) {
|
|
3555
|
+
__privateAdd(this, _options);
|
|
3556
|
+
__privateAdd(this, _DUMMY_USER, "USR_user01@stsmda.com.au");
|
|
3557
|
+
//@@ needs to come from headers ??
|
|
3558
|
+
__privateAdd(this, _httpsAgent, null);
|
|
3559
|
+
__privateAdd(this, _invokeMethods, {});
|
|
3560
|
+
__privateAdd(this, _maxRetries, 5);
|
|
3561
|
+
__privateAdd(this, _sleepDuration, [50, 100, 200, 500, 1e3, 2e3, 5e3]);
|
|
3562
|
+
__privateAdd(this, _NoRetryStatusCodes, [
|
|
3563
|
+
StatusCodes.NOT_FOUND,
|
|
3564
|
+
StatusCodes.CONFLICT
|
|
3565
|
+
]);
|
|
3566
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3567
|
+
__privateAdd(this, _LogDebugMessage, (message) => {
|
|
3568
|
+
__privateGet(this, _options).logger.debug(message);
|
|
3569
|
+
});
|
|
3570
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3571
|
+
__privateAdd(this, _LogErrorMessage, (message) => {
|
|
3572
|
+
__privateGet(this, _options).logger.error(message);
|
|
3573
|
+
});
|
|
3574
|
+
__privateAdd(this, _GetHttpsAgent, () => {
|
|
3575
|
+
if (__privateGet(this, _httpsAgent) === null) {
|
|
3576
|
+
__privateSet(this, _httpsAgent, new https.Agent({
|
|
3577
|
+
keepAlive: goptions.keepAlive,
|
|
3578
|
+
maxSockets: goptions.maxSockets,
|
|
3579
|
+
maxTotalSockets: goptions.maxTotalSockets,
|
|
3580
|
+
maxFreeSockets: goptions.maxFreeSockets,
|
|
3581
|
+
timeout: goptions.timeout,
|
|
3582
|
+
rejectUnauthorized: false
|
|
3583
|
+
}));
|
|
3584
|
+
}
|
|
3585
|
+
return __privateGet(this, _httpsAgent);
|
|
3586
|
+
});
|
|
3587
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3588
|
+
__privateAdd(this, _HandleError, (error) => {
|
|
3589
|
+
__privateGet(this, _LogDebugMessage).call(this, chalk$1.red(`HandleError(): Error: [${error}]`));
|
|
3590
|
+
let responseCode = 500;
|
|
3591
|
+
if (axios.isAxiosError(error)) {
|
|
3592
|
+
const axiosError = error;
|
|
3593
|
+
if (axiosError.response) {
|
|
3594
|
+
responseCode = axiosError.response.status;
|
|
3595
|
+
__privateGet(this, _LogDebugMessage).call(this, chalk$1.red(`AXIOS Error Response.Status = [${axiosError.response.status}]`));
|
|
3596
|
+
if (axiosError.response.headers) {
|
|
3597
|
+
__privateGet(this, _LogErrorMessage).call(this, chalk$1.red(` headers: [${JSON.stringify(axiosError.response.headers)}]`));
|
|
3598
|
+
}
|
|
3599
|
+
if (axiosError.response.data) {
|
|
3600
|
+
__privateGet(this, _LogErrorMessage).call(this, chalk$1.red(` data: [${JSON.stringify(axiosError.response.data)}]`));
|
|
3601
|
+
}
|
|
3602
|
+
try {
|
|
3603
|
+
if (axiosError.response.config) {
|
|
3604
|
+
__privateGet(this, _LogErrorMessage).call(this, chalk$1.red(` config: [${JSON.stringify(axiosError.response.config)}]`));
|
|
3605
|
+
}
|
|
3606
|
+
} catch (innererror) {
|
|
3607
|
+
__privateGet(this, _LogErrorMessage).call(this, chalk$1.red(` could not get response config, error: [${innererror}]`));
|
|
3608
|
+
}
|
|
3609
|
+
} else {
|
|
3610
|
+
__privateGet(this, _LogDebugMessage).call(this, chalk$1.red(`AXIOS Error = [${axiosError}]`));
|
|
3611
|
+
}
|
|
3612
|
+
}
|
|
3613
|
+
return responseCode;
|
|
3614
|
+
});
|
|
3615
|
+
__privateAdd(this, _InvokeResourceAPI, async (url, httpVerb, domainResource, filters, errorCb) => {
|
|
3616
|
+
const id = v4();
|
|
3617
|
+
__privateGet(this, _invokeMethods)[id] = {
|
|
3618
|
+
id,
|
|
3619
|
+
retries: 0,
|
|
3620
|
+
testFailIndexBefore: 1,
|
|
3621
|
+
url,
|
|
3622
|
+
httpVerb,
|
|
3623
|
+
domainResource,
|
|
3624
|
+
filters,
|
|
3625
|
+
errorCb
|
|
3626
|
+
};
|
|
3627
|
+
const InvokeAPI = async (id2) => {
|
|
3628
|
+
const metadataRecord = __privateGet(this, _invokeMethods)[id2];
|
|
3629
|
+
let performRetry = false;
|
|
3630
|
+
const returnData = await __privateGet(this, ___InvokeResourceAPI).call(this, metadataRecord, (statusCode, error) => {
|
|
3631
|
+
console.error(chalk$1.red(`#InvokeResourceAPI(): Error: [${error}], Attempt: [${metadataRecord.retries + 1}]`));
|
|
3632
|
+
const noRetryIndex = __privateGet(this, _NoRetryStatusCodes).indexOf(statusCode);
|
|
3633
|
+
if (noRetryIndex === -1) {
|
|
3634
|
+
if (statusCode === StatusCodes.UNAUTHORIZED) {
|
|
3635
|
+
console.error(chalk$1.red(`#InvokeResourceAPI(): Authentication error, resetting access_token (to null).`));
|
|
3636
|
+
__privateGet(this, _options).ResetAccessToken();
|
|
3637
|
+
if (__privateGet(this, _options).publishInstrumentController) {
|
|
3638
|
+
__privateGet(this, _options).publishInstrumentController.UpdateInstrument(Gauge.AUTHENTICATION_ERROR_COUNT_GAUGE, {
|
|
3639
|
+
Inc: 1
|
|
3640
|
+
});
|
|
3641
|
+
}
|
|
3642
|
+
if (__privateGet(this, _options).clientTelemetryEvents) {
|
|
3643
|
+
__privateGet(this, _options).clientTelemetryEvents.AuthenticationErrorInc();
|
|
3644
|
+
}
|
|
3645
|
+
}
|
|
3646
|
+
if (isNode) {
|
|
3647
|
+
console.error(chalk$1.red(`#InvokeResourceAPI(): Resetting https agent (to null).`));
|
|
3648
|
+
__privateSet(this, _httpsAgent, null);
|
|
3649
|
+
}
|
|
3650
|
+
performRetry = true;
|
|
3651
|
+
}
|
|
3652
|
+
});
|
|
3653
|
+
return {
|
|
3654
|
+
response: returnData,
|
|
3655
|
+
retry: performRetry
|
|
3656
|
+
};
|
|
3657
|
+
};
|
|
3658
|
+
let retVal = null;
|
|
3659
|
+
while (__privateGet(this, _invokeMethods)[id].retries < __privateGet(this, _maxRetries)) {
|
|
3660
|
+
retVal = await InvokeAPI(id);
|
|
3661
|
+
if (retVal.retry === false) {
|
|
3662
|
+
delete __privateGet(this, _invokeMethods)[id];
|
|
3663
|
+
break;
|
|
3664
|
+
} else {
|
|
3665
|
+
console.log(`Going to retry. Current attempts: [${__privateGet(this, _invokeMethods)[id].retries + 1}]`);
|
|
3666
|
+
console.log(`Sleeping: [${__privateGet(this, _sleepDuration)[__privateGet(this, _invokeMethods)[id].retries]}]`);
|
|
3667
|
+
await Sleep(__privateGet(this, _sleepDuration)[__privateGet(this, _invokeMethods)[id].retries]);
|
|
3668
|
+
__privateGet(this, _invokeMethods)[id].retries++;
|
|
3669
|
+
if (__privateGet(this, _options).publishInstrumentController) {
|
|
3670
|
+
__privateGet(this, _options).publishInstrumentController.UpdateInstrument(Gauge.RETRY_COUNT_GAUGE, {
|
|
3671
|
+
Inc: 1
|
|
3672
|
+
});
|
|
3673
|
+
}
|
|
3674
|
+
if (__privateGet(this, _options).clientTelemetryEvents) {
|
|
3675
|
+
__privateGet(this, _options).clientTelemetryEvents.RetryInc();
|
|
3676
|
+
}
|
|
3677
|
+
}
|
|
3678
|
+
}
|
|
3679
|
+
if (retVal) {
|
|
3680
|
+
if (retVal.retry === true) {
|
|
3681
|
+
errorCb(new Error(`#InvokeResourceAPI(): Max retries exceeded. Max Retries: [${__privateGet(this, _invokeMethods)[id].retries}]`));
|
|
3682
|
+
delete __privateGet(this, _invokeMethods)[id];
|
|
3683
|
+
return null;
|
|
3684
|
+
} else {
|
|
3685
|
+
return retVal.response;
|
|
3686
|
+
}
|
|
3687
|
+
} else {
|
|
3688
|
+
return null;
|
|
3689
|
+
}
|
|
3690
|
+
});
|
|
3691
|
+
__privateAdd(this, _TestMode, (metaData, errorCb) => {
|
|
3692
|
+
const { id, url, httpVerb, filters, retries } = metaData;
|
|
3693
|
+
if (retries < 1) {
|
|
3694
|
+
errorCb(401, new Error(`Testing Error Only. Error Code: [401], Message ID: [${id}, url: [${url}], httpVerb: [${httpVerb}], filters: [${filters}], Retries: [${retries}]`));
|
|
3695
|
+
return true;
|
|
3696
|
+
}
|
|
3697
|
+
if (retries < 2) {
|
|
3698
|
+
errorCb(500, new Error(`Testing Error Only. Error Code: [500], Message ID: [${id}, url: [${url}], httpVerb: [${httpVerb}], filters: [${filters}], Retries: [${retries}]`));
|
|
3699
|
+
return true;
|
|
3700
|
+
}
|
|
3701
|
+
return false;
|
|
3702
|
+
});
|
|
3703
|
+
__privateAdd(this, ___InvokeResourceAPI, async (metaData, errorCb) => {
|
|
3704
|
+
try {
|
|
3705
|
+
const { url, httpVerb, domainResource, filters } = metaData;
|
|
3706
|
+
if (__privateGet(this, _options).testingMode) {
|
|
3707
|
+
if (__privateGet(this, _TestMode).call(this, metaData, errorCb)) {
|
|
3708
|
+
return null;
|
|
3709
|
+
}
|
|
3710
|
+
}
|
|
3711
|
+
const accessToken = await __privateGet(this, _options).GetAccessToken();
|
|
3712
|
+
const headers = {
|
|
3713
|
+
"Content-Type": "application/json",
|
|
3714
|
+
"Authorization": `Bearer ${accessToken}`,
|
|
3715
|
+
"x-sts_user_id": __privateGet(this, _DUMMY_USER)
|
|
3716
|
+
};
|
|
3717
|
+
const requestConfig = {
|
|
3718
|
+
url,
|
|
3719
|
+
method: httpVerb,
|
|
3720
|
+
headers
|
|
3721
|
+
};
|
|
3722
|
+
if (isNode) {
|
|
3723
|
+
requestConfig.httpsAgent = __privateGet(this, _GetHttpsAgent).call(this);
|
|
3724
|
+
}
|
|
3725
|
+
if (filters) {
|
|
3726
|
+
requestConfig.data = filters;
|
|
3727
|
+
} else if (domainResource) {
|
|
3728
|
+
requestConfig.data = domainResource;
|
|
3729
|
+
}
|
|
3730
|
+
const retVal = await axios(requestConfig);
|
|
3731
|
+
return retVal;
|
|
3732
|
+
} catch (error) {
|
|
3733
|
+
const responseCode = __privateGet(this, _HandleError).call(this, error);
|
|
3734
|
+
errorCb(responseCode, error);
|
|
3735
|
+
return null;
|
|
3736
|
+
}
|
|
3737
|
+
});
|
|
3738
|
+
__publicField(this, "GetResource", async (resource, id, filters, errorCb) => {
|
|
3739
|
+
const url = `${__privateGet(this, _options).fhirEndpoint}${goptions.stsfhirapiroot}/${resource}/${id}`;
|
|
3740
|
+
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "get", null, filters, errorCb);
|
|
3741
|
+
if (response) {
|
|
3742
|
+
return response.data;
|
|
3743
|
+
} else {
|
|
3744
|
+
return null;
|
|
3745
|
+
}
|
|
3746
|
+
});
|
|
3747
|
+
__publicField(this, "GetResources", async (resource, filters, errorCb) => {
|
|
3748
|
+
const url = `${__privateGet(this, _options).fhirEndpoint}${goptions.stsfhirapiroot}/${resource}`;
|
|
3749
|
+
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "get", null, filters, errorCb);
|
|
3750
|
+
if (response) {
|
|
3751
|
+
return response.data;
|
|
3752
|
+
} else {
|
|
3753
|
+
return null;
|
|
3754
|
+
}
|
|
3755
|
+
});
|
|
3756
|
+
__publicField(this, "CreateResource", async (resource, domainResource, errorCb) => {
|
|
3757
|
+
const url = `${__privateGet(this, _options).fhirEndpoint}${goptions.stsfhirapiroot}/${resource}`;
|
|
3758
|
+
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "post", domainResource, null, errorCb);
|
|
3759
|
+
if (response) {
|
|
3760
|
+
if (response.status === StatusCodes.CREATED) {
|
|
3761
|
+
return response.data;
|
|
3762
|
+
} else {
|
|
3763
|
+
errorCb(new Error(`CreateResource(): Invalid response status code: [${response.status}] expected: [${StatusCodes.CREATED}]`));
|
|
3764
|
+
return null;
|
|
3765
|
+
}
|
|
3766
|
+
} else {
|
|
3767
|
+
return null;
|
|
3768
|
+
}
|
|
3769
|
+
});
|
|
3770
|
+
__publicField(this, "UpdateResource", async (resource, domainResource, errorCb) => {
|
|
3771
|
+
const url = `${__privateGet(this, _options).fhirEndpoint}${goptions.stsfhirapiroot}/${resource}/${domainResource.id}`;
|
|
3772
|
+
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "put", domainResource, null, errorCb);
|
|
3773
|
+
if (response) {
|
|
3774
|
+
return response.data;
|
|
3775
|
+
} else {
|
|
3776
|
+
return null;
|
|
3777
|
+
}
|
|
3778
|
+
});
|
|
3779
|
+
__publicField(this, "UpdateResources", async (resource, domainResources, errorCb) => {
|
|
3780
|
+
const url = `${__privateGet(this, _options).fhirEndpoint}${goptions.stsfhirapiroot}/${resource}`;
|
|
3781
|
+
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "put", domainResources, null, errorCb);
|
|
3782
|
+
if (response) {
|
|
3783
|
+
return response.data;
|
|
3784
|
+
} else {
|
|
3785
|
+
return null;
|
|
3786
|
+
}
|
|
3787
|
+
});
|
|
3788
|
+
__publicField(this, "PatchResource", async (resource, domainResource, errorCb) => {
|
|
3789
|
+
const url = `${__privateGet(this, _options).fhirEndpoint}${goptions.stsfhirapiroot}/${resource}/${domainResource.id}`;
|
|
3790
|
+
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "patch", domainResource, null, errorCb);
|
|
3791
|
+
if (response) {
|
|
3792
|
+
return response.data;
|
|
3793
|
+
} else {
|
|
3794
|
+
return null;
|
|
3795
|
+
}
|
|
3796
|
+
});
|
|
3797
|
+
__publicField(this, "PatchResources", async (resource, domainResources, errorCb) => {
|
|
3798
|
+
const url = `${__privateGet(this, _options).fhirEndpoint}${goptions.stsfhirapiroot}/${resource}`;
|
|
3799
|
+
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "patch", domainResources, null, errorCb);
|
|
3800
|
+
if (response) {
|
|
3801
|
+
return response.data;
|
|
3802
|
+
} else {
|
|
3803
|
+
return null;
|
|
3804
|
+
}
|
|
3805
|
+
});
|
|
3806
|
+
__publicField(this, "DeleteResource", async (resource, id, errorCb) => {
|
|
3807
|
+
const url = `${__privateGet(this, _options).fhirEndpoint}${goptions.stsfhirapiroot}/${resource}/${id}`;
|
|
3808
|
+
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "delete", null, null, errorCb);
|
|
3809
|
+
if (response) {
|
|
3810
|
+
return response.data;
|
|
3811
|
+
} else {
|
|
3812
|
+
return null;
|
|
3813
|
+
}
|
|
3814
|
+
});
|
|
3815
|
+
__publicField(this, "DeleteResources", async (resource, domainResources, errorCb) => {
|
|
3816
|
+
const url = `${__privateGet(this, _options).fhirEndpoint}${goptions.stsfhirapiroot}/${resource}`;
|
|
3817
|
+
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "delete", domainResources, null, errorCb);
|
|
3818
|
+
if (response) {
|
|
3819
|
+
return response.data;
|
|
3820
|
+
} else {
|
|
3821
|
+
return null;
|
|
3822
|
+
}
|
|
3823
|
+
});
|
|
3824
|
+
__publicField(this, "GetLatency", async () => {
|
|
3825
|
+
const url = `${__privateGet(this, _options).fhirEndpoint}${goptions.stsfhirapiroot}/latency`;
|
|
3826
|
+
try {
|
|
3827
|
+
const headers = {
|
|
3828
|
+
"Content-Type": "application/json"
|
|
3829
|
+
};
|
|
3830
|
+
const requestConfig = {
|
|
3831
|
+
url,
|
|
3832
|
+
method: "get",
|
|
3833
|
+
headers
|
|
3834
|
+
};
|
|
3835
|
+
if (isNode) {
|
|
3836
|
+
requestConfig.httpsAgent = __privateGet(this, _GetHttpsAgent).call(this);
|
|
3837
|
+
}
|
|
3838
|
+
const retVal = await axios(requestConfig);
|
|
3839
|
+
return retVal;
|
|
3840
|
+
} catch (error) {
|
|
3841
|
+
__privateGet(this, _HandleError).call(this, error);
|
|
3842
|
+
}
|
|
3843
|
+
});
|
|
3844
|
+
__privateSet(this, _options, options);
|
|
3845
|
+
}
|
|
3846
|
+
get options() {
|
|
3847
|
+
return __privateGet(this, _options);
|
|
3848
|
+
}
|
|
3849
|
+
}
|
|
3850
|
+
_options = new WeakMap();
|
|
3851
|
+
_DUMMY_USER = new WeakMap();
|
|
3852
|
+
_httpsAgent = new WeakMap();
|
|
3853
|
+
_invokeMethods = new WeakMap();
|
|
3854
|
+
_maxRetries = new WeakMap();
|
|
3855
|
+
_sleepDuration = new WeakMap();
|
|
3856
|
+
_NoRetryStatusCodes = new WeakMap();
|
|
3857
|
+
_LogDebugMessage = new WeakMap();
|
|
3858
|
+
_LogErrorMessage = new WeakMap();
|
|
3859
|
+
_GetHttpsAgent = new WeakMap();
|
|
3860
|
+
_HandleError = new WeakMap();
|
|
3861
|
+
_InvokeResourceAPI = new WeakMap();
|
|
3862
|
+
_TestMode = new WeakMap();
|
|
3863
|
+
___InvokeResourceAPI = new WeakMap();
|
|
3864
|
+
class STSFhirControllerTestCasesClient {
|
|
3865
|
+
// ststestrunnernode password
|
|
3866
|
+
constructor(options) {
|
|
3867
|
+
__privateAdd(this, _testHelper);
|
|
3868
|
+
__privateAdd(this, _endpoint, `https://localhost:${goptions.stsfhirport}`);
|
|
3869
|
+
__privateAdd(this, _fhirClient);
|
|
3870
|
+
__privateAdd(this, _accesssToken, null);
|
|
3871
|
+
__privateAdd(this, _options2);
|
|
3872
|
+
__privateAdd(this, _clientId, "36615b3a-b71b-49af-a68b-4180daed7a5a");
|
|
3873
|
+
// ststestrunnernode
|
|
3874
|
+
__privateAdd(this, _clientSecret, "7fbbf116-0537-424b-904f-d8d0a62adf9e");
|
|
3875
|
+
__privateAdd(this, _GetAccessToken, async () => {
|
|
3876
|
+
if (!__privateGet(this, _accesssToken)) {
|
|
3877
|
+
const api = "api://fb6513e4-16fe-4931-bed8-33b82b404a14";
|
|
3878
|
+
const resource = "Person";
|
|
3879
|
+
const stsFhirApiPrefix = "stsfhir5";
|
|
3880
|
+
const scopes = `${api}/${resource}.${stsFhirApiPrefix}:Create${resource} ${api}/${resource}.${stsFhirApiPrefix}:Get${resource}s ${api}/${resource}.${stsFhirApiPrefix}:Update${resource}s ${api}/${resource}.${stsFhirApiPrefix}:Patch${resource}s ${api}/${resource}.${stsFhirApiPrefix}:Delete${resource}s ${api}/${resource}/*.${stsFhirApiPrefix}:Get${resource} ${api}/${resource}/*.${stsFhirApiPrefix}:Update${resource} ${api}/${resource}/*.${stsFhirApiPrefix}:Patch${resource} ${api}/${resource}/*.${stsFhirApiPrefix}:Delete${resource}`.split(" ").sort().join(" ");
|
|
3881
|
+
__privateSet(this, _accesssToken, await __privateGet(this, _options2).authUtilsNode.GetAPITokenFromAuthServerUsingScope({
|
|
3882
|
+
clientId: __privateGet(this, _clientId),
|
|
3883
|
+
authClientSecret: __privateGet(this, _clientSecret),
|
|
3884
|
+
scope: scopes,
|
|
3885
|
+
endPoint: __privateGet(this, _testHelper).authEndpoint
|
|
3886
|
+
}, (error) => __privateGet(this, _LogErrorMessage2).call(this, error)));
|
|
3887
|
+
await __privateGet(this, _options2).authUtilsNode.ValidateJWT(__privateGet(this, _accesssToken), "api://fb6513e4-16fe-4931-bed8-33b82b404a14", __privateGet(this, _testHelper).authEndpoint);
|
|
3888
|
+
}
|
|
3889
|
+
return __privateGet(this, _accesssToken);
|
|
3890
|
+
});
|
|
3891
|
+
__privateAdd(this, _LogDebugMessage2, (message) => {
|
|
3892
|
+
defaultLogger.debug(message);
|
|
3893
|
+
});
|
|
3894
|
+
__privateAdd(this, _LogErrorMessage2, (message) => {
|
|
3895
|
+
defaultLogger.error(message);
|
|
3896
|
+
});
|
|
3897
|
+
__privateAdd(this, _HandleError2, (error) => {
|
|
3898
|
+
__privateGet(this, _LogDebugMessage2).call(this, chalk$1.red(`HandleError(): Error: [${error}]`));
|
|
3899
|
+
});
|
|
3900
|
+
__privateAdd(this, _GetPersonRecord, (prefix, index) => {
|
|
3901
|
+
const id = `${prefix}${v4()}`;
|
|
3902
|
+
const personRecord = {
|
|
3903
|
+
id,
|
|
3904
|
+
_resourceType: "Person",
|
|
3905
|
+
name: [
|
|
3906
|
+
{
|
|
3907
|
+
family: `family ${index}`,
|
|
3908
|
+
given: [`given ${index}`],
|
|
3909
|
+
use: `usual`
|
|
3910
|
+
}
|
|
3911
|
+
],
|
|
3912
|
+
text: {
|
|
3913
|
+
div: `New Record ${index}`,
|
|
3914
|
+
status: "generated"
|
|
3915
|
+
}
|
|
3916
|
+
};
|
|
3917
|
+
return personRecord;
|
|
3918
|
+
});
|
|
3919
|
+
__privateAdd(this, _GetPersonRecordBatch, (prefix, iterations) => {
|
|
3920
|
+
const persons = [];
|
|
3921
|
+
for (let i = 0; i < iterations; i++) {
|
|
3922
|
+
persons.push(__privateGet(this, _GetPersonRecord).call(this, prefix, i));
|
|
3923
|
+
}
|
|
3924
|
+
return persons;
|
|
3925
|
+
});
|
|
3926
|
+
__publicField(this, "TestGetLatency", async () => {
|
|
3927
|
+
expect.assertions(1);
|
|
3928
|
+
try {
|
|
3929
|
+
const retVal = await __privateGet(this, _fhirClient).GetLatency();
|
|
3930
|
+
if (retVal) {
|
|
3931
|
+
expect(retVal.status).toEqual(200);
|
|
3932
|
+
}
|
|
3933
|
+
} catch (error) {
|
|
3934
|
+
__privateGet(this, _HandleError2).call(this, error);
|
|
3935
|
+
}
|
|
3936
|
+
});
|
|
3937
|
+
__publicField(this, "TestGetAccessToken", async () => {
|
|
3938
|
+
expect.assertions(1);
|
|
3939
|
+
try {
|
|
3940
|
+
const retVal = await __privateGet(this, _GetAccessToken).call(this);
|
|
3941
|
+
expect(retVal).not.toBeNull();
|
|
3942
|
+
} catch (error) {
|
|
3943
|
+
__privateGet(this, _HandleError2).call(this, error);
|
|
3944
|
+
}
|
|
3945
|
+
});
|
|
3946
|
+
__publicField(this, "CheckDuplicateErrorHandling", async () => {
|
|
3947
|
+
expect.assertions(2);
|
|
3948
|
+
const personRecord = __privateGet(this, _GetPersonRecord).call(this, "", 1);
|
|
3949
|
+
const retVal = await __privateGet(this, _fhirClient).CreateResource("Person", personRecord, (error) => {
|
|
3950
|
+
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(POST /stsresource): ${error}`));
|
|
3951
|
+
});
|
|
3952
|
+
expect(retVal).toMatchObject(personRecord);
|
|
3953
|
+
const retVal2 = await __privateGet(this, _fhirClient).CreateResource("Person", personRecord, (error) => {
|
|
3954
|
+
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(POST /stsresource): ${error}`));
|
|
3955
|
+
});
|
|
3956
|
+
expect(retVal2).toBeNull();
|
|
3957
|
+
});
|
|
3958
|
+
__publicField(this, "PostResources", async () => {
|
|
3959
|
+
const iterations = 10;
|
|
3960
|
+
expect.assertions(iterations);
|
|
3961
|
+
for (let i = 0; i < iterations; i++) {
|
|
3962
|
+
const personRecord = __privateGet(this, _GetPersonRecord).call(this, "", i);
|
|
3963
|
+
const retVal = await __privateGet(this, _fhirClient).CreateResource("Person", personRecord, (error) => {
|
|
3964
|
+
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(POST /stsresource): ${error}`));
|
|
3965
|
+
});
|
|
3966
|
+
expect(retVal).toMatchObject(personRecord);
|
|
3967
|
+
}
|
|
3968
|
+
});
|
|
3969
|
+
__publicField(this, "StandardCRUDOperations", async () => {
|
|
3970
|
+
expect.assertions(8);
|
|
3971
|
+
let personRecord = __privateGet(this, _GetPersonRecord).call(this, "", 1);
|
|
3972
|
+
let retVal = await __privateGet(this, _fhirClient).CreateResource("Person", personRecord, (error) => {
|
|
3973
|
+
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(PostResource): ${error}`));
|
|
3974
|
+
});
|
|
3975
|
+
expect(retVal).toMatchObject(personRecord);
|
|
3976
|
+
const retVal2 = await __privateGet(this, _fhirClient).CreateResource("Person", personRecord, (error) => {
|
|
3977
|
+
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(POST /stsresource): ${error}`));
|
|
3978
|
+
});
|
|
3979
|
+
expect(retVal2).toBeNull();
|
|
3980
|
+
personRecord.text.div = "user01 put updated at " + (/* @__PURE__ */ new Date()).toString();
|
|
3981
|
+
retVal = await __privateGet(this, _fhirClient).UpdateResource("Person", personRecord, (error) => {
|
|
3982
|
+
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(PutResource): ${error}`));
|
|
3983
|
+
});
|
|
3984
|
+
expect(retVal).toMatchObject(personRecord);
|
|
3985
|
+
const patchPersonRecord = {
|
|
3986
|
+
id: personRecord.id,
|
|
3987
|
+
text: {
|
|
3988
|
+
div: "user01 patched at " + (/* @__PURE__ */ new Date()).toString(),
|
|
3989
|
+
status: "generated"
|
|
3990
|
+
}
|
|
3991
|
+
};
|
|
3992
|
+
retVal = await __privateGet(this, _fhirClient).PatchResource("Person", patchPersonRecord, (error) => {
|
|
3993
|
+
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(PatchResource): ${error}`));
|
|
3994
|
+
});
|
|
3995
|
+
personRecord = Object.assign({}, personRecord, patchPersonRecord);
|
|
3996
|
+
expect(retVal).toMatchObject(personRecord);
|
|
3997
|
+
retVal = await __privateGet(this, _fhirClient).GetResource("Person", personRecord.id, null, (error) => {
|
|
3998
|
+
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(GetResource): ${error}`));
|
|
3999
|
+
});
|
|
4000
|
+
expect(retVal).toMatchObject(personRecord);
|
|
4001
|
+
retVal = await __privateGet(this, _fhirClient).GetResource("Person", "willnotfind", null, (error) => {
|
|
4002
|
+
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(GetResource will not find): ${error}`));
|
|
4003
|
+
});
|
|
4004
|
+
expect(retVal).toBeNull();
|
|
4005
|
+
retVal = await __privateGet(this, _fhirClient).DeleteResource("Person", personRecord.id, (error) => {
|
|
4006
|
+
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(DeleteResource): ${error}`));
|
|
4007
|
+
});
|
|
4008
|
+
expect(retVal).toMatchObject(personRecord);
|
|
4009
|
+
retVal = await __privateGet(this, _fhirClient).GetResource("Person", personRecord.id, null, (error) => {
|
|
4010
|
+
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(GetResource after delete): ${error}`));
|
|
4011
|
+
});
|
|
4012
|
+
expect(retVal).toBeNull();
|
|
4013
|
+
});
|
|
4014
|
+
__publicField(this, "PostAndQuery", async () => {
|
|
4015
|
+
const iterations = 10;
|
|
4016
|
+
const personPrefix = `_${v4().replaceAll("-", "_")}_`;
|
|
4017
|
+
expect.assertions(3 + 2 * iterations);
|
|
4018
|
+
for (let i = 0; i < iterations; i++) {
|
|
4019
|
+
const personRecord = __privateGet(this, _GetPersonRecord).call(this, `${personPrefix}s1_`, i);
|
|
4020
|
+
const retVal2 = await __privateGet(this, _fhirClient).CreateResource("Person", personRecord, (error) => {
|
|
4021
|
+
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(POST /stsresource and query using filter): ${error}`));
|
|
4022
|
+
});
|
|
4023
|
+
expect(retVal2).toMatchObject(personRecord);
|
|
4024
|
+
}
|
|
4025
|
+
for (let i = 0; i < iterations; i++) {
|
|
4026
|
+
const personRecord = __privateGet(this, _GetPersonRecord).call(this, `${personPrefix}s2_`, i);
|
|
4027
|
+
const retVal2 = await __privateGet(this, _fhirClient).CreateResource("Person", personRecord, (error) => {
|
|
4028
|
+
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(POST /stsresource and query using filter): ${error}`));
|
|
4029
|
+
});
|
|
4030
|
+
expect(retVal2).toMatchObject(personRecord);
|
|
4031
|
+
}
|
|
4032
|
+
let retVal = await __privateGet(this, _fhirClient).GetResources("Person", [`${personPrefix}`], (error) => {
|
|
4033
|
+
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(POST /stsresource and query using filter): ${error}`));
|
|
4034
|
+
});
|
|
4035
|
+
if (retVal) {
|
|
4036
|
+
expect(retVal.length).toEqual(iterations * 2);
|
|
4037
|
+
}
|
|
4038
|
+
retVal = await __privateGet(this, _fhirClient).GetResources("Person", [`${personPrefix}s1_`], (error) => {
|
|
4039
|
+
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(POST /stsresource and query using filter): ${error}`));
|
|
4040
|
+
});
|
|
4041
|
+
if (retVal) {
|
|
4042
|
+
expect(retVal.length).toEqual(iterations);
|
|
4043
|
+
}
|
|
4044
|
+
retVal = await __privateGet(this, _fhirClient).GetResources("Person", [`${personPrefix}s2_`, `${personPrefix}s1_`], (error) => {
|
|
4045
|
+
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(POST /stsresource and query using filter): ${error}`));
|
|
4046
|
+
});
|
|
4047
|
+
if (retVal) {
|
|
4048
|
+
expect(retVal.length).toEqual(iterations * 2);
|
|
4049
|
+
}
|
|
4050
|
+
});
|
|
4051
|
+
__publicField(this, "BatchMethods", async () => {
|
|
4052
|
+
const iterations = 10;
|
|
4053
|
+
const personPrefix = `_${v4().replaceAll("-", "_")}_`;
|
|
4054
|
+
expect.assertions(11);
|
|
4055
|
+
const personRecords = __privateGet(this, _GetPersonRecordBatch).call(this, `${personPrefix}`, 10);
|
|
4056
|
+
let stepMessage = `Resource list after put (batch create) resources`;
|
|
4057
|
+
let retVal = await __privateGet(this, _fhirClient).UpdateResources("Person", personRecords, (error) => {
|
|
4058
|
+
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(${stepMessage}): ${error}`));
|
|
4059
|
+
});
|
|
4060
|
+
if (retVal) {
|
|
4061
|
+
expect(retVal.length).toEqual(iterations);
|
|
4062
|
+
expect(retVal).toMatchObject(personRecords);
|
|
4063
|
+
}
|
|
4064
|
+
for (let i = 0; i < iterations; i++) {
|
|
4065
|
+
personRecords[i].text = {
|
|
4066
|
+
div: `user${i} updated at ` + (/* @__PURE__ */ new Date()).toString(),
|
|
4067
|
+
status: "extensions"
|
|
4068
|
+
};
|
|
4069
|
+
}
|
|
4070
|
+
stepMessage = `Resource list after put (update) resources`;
|
|
4071
|
+
retVal = await __privateGet(this, _fhirClient).UpdateResources("Person", personRecords, (error) => {
|
|
4072
|
+
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(${stepMessage}): ${error}`));
|
|
4073
|
+
});
|
|
4074
|
+
if (retVal) {
|
|
4075
|
+
expect(retVal.length).toEqual(iterations);
|
|
4076
|
+
expect(retVal).toMatchObject(personRecords);
|
|
4077
|
+
}
|
|
4078
|
+
const patchRecords = [];
|
|
4079
|
+
for (let i = 0; i < iterations; i++) {
|
|
4080
|
+
const updateTextObject = {
|
|
4081
|
+
div: `user${i} patched at ` + (/* @__PURE__ */ new Date()).toString(),
|
|
4082
|
+
status: "extensions"
|
|
4083
|
+
};
|
|
4084
|
+
patchRecords.push({
|
|
4085
|
+
id: personRecords[i].id,
|
|
4086
|
+
text: updateTextObject
|
|
4087
|
+
});
|
|
4088
|
+
personRecords[i].text = updateTextObject;
|
|
4089
|
+
}
|
|
4090
|
+
stepMessage = `Resource list after patch resources`;
|
|
4091
|
+
retVal = await __privateGet(this, _fhirClient).PatchResources("Person", patchRecords, (error) => {
|
|
4092
|
+
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(${stepMessage}): ${error}`));
|
|
4093
|
+
});
|
|
4094
|
+
if (retVal) {
|
|
4095
|
+
expect(retVal.length).toEqual(iterations);
|
|
4096
|
+
expect(retVal).toMatchObject(personRecords);
|
|
4097
|
+
}
|
|
4098
|
+
stepMessage = `Resource list before deleted resources`;
|
|
4099
|
+
retVal = await __privateGet(this, _fhirClient).GetResources("Person", [`${personPrefix}`], (error) => {
|
|
4100
|
+
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(${stepMessage}): ${error}`));
|
|
4101
|
+
});
|
|
4102
|
+
if (retVal) {
|
|
4103
|
+
expect(retVal.length).toEqual(iterations);
|
|
4104
|
+
}
|
|
4105
|
+
const remainingPersonRecords = personRecords.splice(5);
|
|
4106
|
+
stepMessage = `Resource list of deleted resources`;
|
|
4107
|
+
retVal = await __privateGet(this, _fhirClient).DeleteResources("Person", personRecords, (error) => {
|
|
4108
|
+
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(${stepMessage}): ${error}`));
|
|
4109
|
+
});
|
|
4110
|
+
if (retVal) {
|
|
4111
|
+
expect(retVal.length).toEqual(5);
|
|
4112
|
+
retVal.sort((a, b) => a.id.localeCompare(b.id));
|
|
4113
|
+
personRecords.sort((a, b) => a.id.localeCompare(b.id));
|
|
4114
|
+
expect(retVal).toMatchObject(personRecords);
|
|
4115
|
+
}
|
|
4116
|
+
stepMessage = `Resource list after partial deletes`;
|
|
4117
|
+
retVal = await __privateGet(this, _fhirClient).GetResources("Person", [`${personPrefix}`], (error) => {
|
|
4118
|
+
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(${stepMessage}): ${error}`));
|
|
4119
|
+
});
|
|
4120
|
+
if (retVal) {
|
|
4121
|
+
expect(retVal.length).toEqual(5);
|
|
4122
|
+
retVal.sort((a, b) => a.id.localeCompare(b.id));
|
|
4123
|
+
remainingPersonRecords.sort((a, b) => a.id.localeCompare(b.id));
|
|
4124
|
+
expect(retVal).toMatchObject(remainingPersonRecords);
|
|
4125
|
+
}
|
|
4126
|
+
});
|
|
4127
|
+
__privateSet(this, _options2, options);
|
|
4128
|
+
__privateSet(this, _testHelper, options.testHelper);
|
|
4129
|
+
__privateSet(this, _fhirClient, new FhirClient({
|
|
4130
|
+
fhirEndpoint: __privateGet(this, _endpoint),
|
|
4131
|
+
logger: defaultLogger,
|
|
4132
|
+
publishInstrumentController: null,
|
|
4133
|
+
// options.stsApp.InstrumentController,
|
|
4134
|
+
testingMode: true,
|
|
4135
|
+
GetAccessToken: () => {
|
|
4136
|
+
return __privateGet(this, _GetAccessToken).call(this);
|
|
4137
|
+
},
|
|
4138
|
+
ResetAccessToken: () => {
|
|
4139
|
+
__privateSet(this, _accesssToken, null);
|
|
4140
|
+
}
|
|
4141
|
+
}));
|
|
4142
|
+
}
|
|
4143
|
+
}
|
|
4144
|
+
_testHelper = new WeakMap();
|
|
4145
|
+
_endpoint = new WeakMap();
|
|
4146
|
+
_fhirClient = new WeakMap();
|
|
4147
|
+
_accesssToken = new WeakMap();
|
|
4148
|
+
_options2 = new WeakMap();
|
|
4149
|
+
_clientId = new WeakMap();
|
|
4150
|
+
_clientSecret = new WeakMap();
|
|
4151
|
+
_GetAccessToken = new WeakMap();
|
|
4152
|
+
_LogDebugMessage2 = new WeakMap();
|
|
4153
|
+
_LogErrorMessage2 = new WeakMap();
|
|
4154
|
+
_HandleError2 = new WeakMap();
|
|
4155
|
+
_GetPersonRecord = new WeakMap();
|
|
4156
|
+
_GetPersonRecordBatch = new WeakMap();
|
|
4157
|
+
class STSFhirControllerTestCasesDirect {
|
|
4158
|
+
constructor(options) {
|
|
4159
|
+
__publicField(this, "timeoutVal", 5e3);
|
|
4160
|
+
__privateAdd(this, _testHelper2);
|
|
4161
|
+
__privateAdd(this, _authUtilsNode);
|
|
4162
|
+
__publicField(this, "endpoint", "https://localhost");
|
|
4163
|
+
__publicField(this, "DUMMY_USER", "USR_user01@stsmda.com.au");
|
|
4164
|
+
__publicField(this, "LogDebugMessage", (message) => {
|
|
4165
|
+
defaultLogger.debug(message);
|
|
4166
|
+
});
|
|
4167
|
+
__publicField(this, "LogErrorMessage", (message) => {
|
|
4168
|
+
defaultLogger.error(message);
|
|
4169
|
+
});
|
|
4170
|
+
__publicField(this, "HandleError", (error) => {
|
|
4171
|
+
this.LogDebugMessage(chalk$1.red(`HandleError(): Error: [${error}]`));
|
|
4172
|
+
let responseCode = 500;
|
|
4173
|
+
if (axios.isAxiosError(error)) {
|
|
4174
|
+
const axiosError = error;
|
|
4175
|
+
if (axiosError.response) {
|
|
4176
|
+
responseCode = axiosError.response.status;
|
|
4177
|
+
this.LogDebugMessage(chalk$1.red(`AXIOS Error Response.Status = [${axiosError.response.status}]`));
|
|
4178
|
+
if (axiosError.response.headers) {
|
|
4179
|
+
this.LogErrorMessage(chalk$1.red(` headers: [${JSON.stringify(axiosError.response.headers)}]`));
|
|
4180
|
+
}
|
|
4181
|
+
if (axiosError.response.data) {
|
|
4182
|
+
this.LogErrorMessage(chalk$1.red(` data: [${JSON.stringify(axiosError.response.data)}]`));
|
|
4183
|
+
}
|
|
4184
|
+
try {
|
|
4185
|
+
if (axiosError.response.config) {
|
|
4186
|
+
this.LogErrorMessage(chalk$1.red(` config: [${JSON.stringify(axiosError.response.config)}]`));
|
|
4187
|
+
}
|
|
4188
|
+
} catch (innererror) {
|
|
4189
|
+
this.LogErrorMessage(chalk$1.red(` could not get response config, error: [${innererror}]`));
|
|
4190
|
+
}
|
|
4191
|
+
} else {
|
|
4192
|
+
this.LogDebugMessage(chalk$1.red(`AXIOS Error = [${axiosError}]`));
|
|
4193
|
+
}
|
|
4194
|
+
}
|
|
4195
|
+
return responseCode;
|
|
4196
|
+
});
|
|
4197
|
+
__publicField(this, "GetAccessToken", async () => {
|
|
4198
|
+
const api = "api://fb6513e4-16fe-4931-bed8-33b82b404a14";
|
|
4199
|
+
const resource = "Person";
|
|
4200
|
+
const stsFhirApiPrefix = "stsfhir5";
|
|
4201
|
+
const scopes = `${api}/${resource}.${stsFhirApiPrefix}:Create${resource} ${api}/${resource}.${stsFhirApiPrefix}:Get${resource}s ${api}/${resource}.${stsFhirApiPrefix}:Update${resource}s ${api}/${resource}.${stsFhirApiPrefix}:Patch${resource}s ${api}/${resource}.${stsFhirApiPrefix}:Delete${resource}s ${api}/${resource}/*.${stsFhirApiPrefix}:Get${resource} ${api}/${resource}/*.${stsFhirApiPrefix}:Update${resource} ${api}/${resource}/*.${stsFhirApiPrefix}:Patch${resource} ${api}/${resource}/*.${stsFhirApiPrefix}:Delete${resource}`.split(" ").sort().join(" ");
|
|
4202
|
+
return await __privateGet(this, _authUtilsNode).GetAPITokenFromAuthServerUsingScope({
|
|
4203
|
+
clientId: "36615b3a-b71b-49af-a68b-4180daed7a5a",
|
|
4204
|
+
// ststestrunnernode
|
|
4205
|
+
authClientSecret: "7fbbf116-0537-424b-904f-d8d0a62adf9e",
|
|
4206
|
+
// ststestrunnernode password
|
|
4207
|
+
scope: scopes,
|
|
4208
|
+
endPoint: __privateGet(this, _testHelper2).authEndpoint
|
|
4209
|
+
}, (error) => this.LogErrorMessage(error));
|
|
4210
|
+
});
|
|
4211
|
+
__publicField(this, "__UpdateGeneric", async (url, httpVerb, accesss_token, domainResource, filters, errorCb) => {
|
|
4212
|
+
try {
|
|
4213
|
+
const headers = {
|
|
4214
|
+
"Content-Type": "application/json",
|
|
4215
|
+
"Authorization": "Bearer " + accesss_token,
|
|
4216
|
+
"x-sts_user_id": this.DUMMY_USER
|
|
4217
|
+
};
|
|
4218
|
+
const requestConfig = {
|
|
4219
|
+
url,
|
|
4220
|
+
method: httpVerb,
|
|
4221
|
+
headers,
|
|
4222
|
+
httpsAgent: __privateGet(this, _testHelper2).getHttpsAgent
|
|
4223
|
+
};
|
|
4224
|
+
if (filters) {
|
|
4225
|
+
requestConfig.data = filters;
|
|
4226
|
+
} else if (domainResource) {
|
|
4227
|
+
requestConfig.data = domainResource;
|
|
4228
|
+
}
|
|
4229
|
+
const retVal = await axios(requestConfig);
|
|
4230
|
+
return retVal;
|
|
4231
|
+
} catch (error) {
|
|
4232
|
+
this.HandleError(error);
|
|
4233
|
+
errorCb(error);
|
|
4234
|
+
return null;
|
|
4235
|
+
}
|
|
4236
|
+
});
|
|
4237
|
+
__publicField(this, "__UpdateResource", async (url, httpVerb, accesss_token, domainResource, filters, errorCb) => {
|
|
4238
|
+
return this.__UpdateGeneric(url, httpVerb, accesss_token, domainResource, filters, errorCb);
|
|
4239
|
+
});
|
|
4240
|
+
__publicField(this, "PostResource", async (accesss_token, resource, domainResource, errorCb) => {
|
|
4241
|
+
const url = `${this.endpoint}:${goptions.stsfhirport}${goptions.stsfhirapiroot}/${resource}`;
|
|
4242
|
+
return this.__UpdateResource(url, "post", accesss_token, domainResource, null, errorCb);
|
|
4243
|
+
});
|
|
4244
|
+
__publicField(this, "PutResource", async (accesss_token, resource, domainResource, errorCb) => {
|
|
4245
|
+
const url = `${this.endpoint}:${goptions.stsfhirport}${goptions.stsfhirapiroot}/${resource}/${domainResource.id}`;
|
|
4246
|
+
return this.__UpdateResource(url, "put", accesss_token, domainResource, null, errorCb);
|
|
4247
|
+
});
|
|
4248
|
+
__publicField(this, "PutResources", async (accesss_token, resource, domainResources, errorCb) => {
|
|
4249
|
+
const url = `${this.endpoint}:${goptions.stsfhirport}${goptions.stsfhirapiroot}/${resource}`;
|
|
4250
|
+
return this.__UpdateResource(url, "put", accesss_token, domainResources, null, errorCb);
|
|
4251
|
+
});
|
|
4252
|
+
__publicField(this, "PatchResource", async (accesss_token, resource, domainResource, errorCb) => {
|
|
4253
|
+
const url = `${this.endpoint}:${goptions.stsfhirport}${goptions.stsfhirapiroot}/${resource}/${domainResource.id}`;
|
|
4254
|
+
return this.__UpdateResource(url, "patch", accesss_token, domainResource, null, errorCb);
|
|
4255
|
+
});
|
|
4256
|
+
__publicField(this, "PatchResources", async (accesss_token, resource, domainResources, errorCb) => {
|
|
4257
|
+
const url = `${this.endpoint}:${goptions.stsfhirport}${goptions.stsfhirapiroot}/${resource}`;
|
|
4258
|
+
return this.__UpdateResource(url, "patch", accesss_token, domainResources, null, errorCb);
|
|
4259
|
+
});
|
|
4260
|
+
__publicField(this, "GetResource", async (accesss_token, resource, id, filters, errorCb) => {
|
|
4261
|
+
const url = `${this.endpoint}:${goptions.stsfhirport}${goptions.stsfhirapiroot}/${resource}/${id}`;
|
|
4262
|
+
return this.__UpdateResource(url, "get", accesss_token, null, filters, errorCb);
|
|
4263
|
+
});
|
|
4264
|
+
__publicField(this, "DeleteResource", async (accesss_token, resource, id, errorCb) => {
|
|
4265
|
+
const url = `${this.endpoint}:${goptions.stsfhirport}${goptions.stsfhirapiroot}/${resource}/${id}`;
|
|
4266
|
+
return this.__UpdateResource(url, "delete", accesss_token, null, null, errorCb);
|
|
4267
|
+
});
|
|
4268
|
+
__publicField(this, "DeleteResources", async (accesss_token, resource, domainResources, errorCb) => {
|
|
4269
|
+
const url = `${this.endpoint}:${goptions.stsfhirport}${goptions.stsfhirapiroot}/${resource}`;
|
|
4270
|
+
return this.__UpdateResource(url, "delete", accesss_token, domainResources, null, errorCb);
|
|
4271
|
+
});
|
|
4272
|
+
__publicField(this, "GetResources", async (accesss_token, resource, filters, errorCb) => {
|
|
4273
|
+
const url = `${this.endpoint}:${goptions.stsfhirport}${goptions.stsfhirapiroot}/${resource}`;
|
|
4274
|
+
return this.__UpdateResource(url, "get", accesss_token, null, filters, errorCb);
|
|
4275
|
+
});
|
|
4276
|
+
__publicField(this, "CheckResourceMetaData", (response, status, checkData) => {
|
|
4277
|
+
expect(response.status).toEqual(status);
|
|
4278
|
+
const returnData = response.data;
|
|
4279
|
+
expect(returnData).toMatchObject(checkData);
|
|
4280
|
+
});
|
|
4281
|
+
__publicField(this, "GetPersonRecord", (prefix, index) => {
|
|
4282
|
+
const id = `${prefix}${v4()}`;
|
|
4283
|
+
const personRecord = {
|
|
4284
|
+
id,
|
|
4285
|
+
_resourceType: "Person",
|
|
4286
|
+
name: [
|
|
4287
|
+
{
|
|
4288
|
+
family: `family ${index}`,
|
|
4289
|
+
given: [`given ${index}`],
|
|
4290
|
+
use: `usual`
|
|
4291
|
+
}
|
|
4292
|
+
],
|
|
4293
|
+
text: {
|
|
4294
|
+
div: `New Record ${index}`,
|
|
4295
|
+
status: "generated"
|
|
4296
|
+
}
|
|
4297
|
+
};
|
|
4298
|
+
return personRecord;
|
|
4299
|
+
});
|
|
4300
|
+
__publicField(this, "GetPersonRecordBatch", (prefix, iterations) => {
|
|
4301
|
+
const persons = [];
|
|
4302
|
+
for (let i = 0; i < iterations; i++) {
|
|
4303
|
+
persons.push(this.GetPersonRecord(prefix, i));
|
|
4304
|
+
}
|
|
4305
|
+
return persons;
|
|
4306
|
+
});
|
|
4307
|
+
__publicField(this, "TestGetLatency", async () => {
|
|
4308
|
+
expect.assertions(1);
|
|
4309
|
+
const url = `${this.endpoint}:${goptions.stsfhirport}${goptions.stsfhirapiroot}/latency`;
|
|
4310
|
+
try {
|
|
4311
|
+
const headers = {
|
|
4312
|
+
"Content-Type": "application/json"
|
|
4313
|
+
};
|
|
4314
|
+
const retVal = await axios({
|
|
4315
|
+
url,
|
|
4316
|
+
method: "get",
|
|
4317
|
+
headers,
|
|
4318
|
+
httpsAgent: __privateGet(this, _testHelper2).getHttpsAgent
|
|
4319
|
+
});
|
|
4320
|
+
expect(retVal.status).toEqual(200);
|
|
4321
|
+
} catch (error) {
|
|
4322
|
+
this.HandleError(error);
|
|
4323
|
+
}
|
|
4324
|
+
});
|
|
4325
|
+
__publicField(this, "GetAPITokenFromAuthServer", async () => {
|
|
4326
|
+
expect.assertions(1);
|
|
4327
|
+
const accesss_token = await this.GetAccessToken();
|
|
4328
|
+
await __privateGet(this, _authUtilsNode).ValidateJWT(accesss_token, "api://fb6513e4-16fe-4931-bed8-33b82b404a14", __privateGet(this, _testHelper2).authEndpoint);
|
|
4329
|
+
await Sleep(200);
|
|
4330
|
+
console.log(chalk$1.rgb(255, 204, 255)(`Access Token: [${accesss_token}]`));
|
|
4331
|
+
console.log(chalk$1.rgb(255, 204, 255)(`Access Token Size: [${accesss_token.length}]`));
|
|
4332
|
+
expect(1).toEqual(1);
|
|
4333
|
+
});
|
|
4334
|
+
__publicField(this, "CheckDuplicateErrorHandling", async () => {
|
|
4335
|
+
expect.assertions(4);
|
|
4336
|
+
const accesss_token = await this.GetAccessToken();
|
|
4337
|
+
expect(accesss_token).not.toEqual("");
|
|
4338
|
+
const personRecord = this.GetPersonRecord("", 1);
|
|
4339
|
+
const retVal = await this.PostResource(accesss_token, "Person", personRecord, (error) => {
|
|
4340
|
+
this.LogErrorMessage(chalk$1.red(`test(POST /stsresource): ${error}`));
|
|
4341
|
+
});
|
|
4342
|
+
if (retVal) {
|
|
4343
|
+
this.CheckResourceMetaData(retVal, 201, personRecord);
|
|
4344
|
+
}
|
|
4345
|
+
const retVal2 = await this.PostResource(accesss_token, "Person", personRecord, (error) => {
|
|
4346
|
+
this.LogErrorMessage(chalk$1.red(`test(POST /stsresource): ${error}`));
|
|
4347
|
+
});
|
|
4348
|
+
expect(retVal2).toBeNull();
|
|
4349
|
+
});
|
|
4350
|
+
__publicField(this, "PostResources", async () => {
|
|
4351
|
+
const iterations = 10;
|
|
4352
|
+
expect.assertions(1 + 2 * iterations);
|
|
4353
|
+
const accesss_token = await this.GetAccessToken();
|
|
4354
|
+
expect(accesss_token).not.toEqual("");
|
|
4355
|
+
for (let i = 0; i < iterations; i++) {
|
|
4356
|
+
const personRecord = this.GetPersonRecord("", i);
|
|
4357
|
+
const retVal = await this.PostResource(accesss_token, "Person", personRecord, (error) => {
|
|
4358
|
+
this.LogErrorMessage(chalk$1.red(`test(POST /stsresource): ${error}`));
|
|
4359
|
+
});
|
|
4360
|
+
if (retVal) {
|
|
4361
|
+
this.CheckResourceMetaData(retVal, 201, personRecord);
|
|
4362
|
+
}
|
|
4363
|
+
}
|
|
4364
|
+
});
|
|
4365
|
+
__publicField(this, "StandardCRUDOperations", async () => {
|
|
4366
|
+
expect.assertions(15);
|
|
4367
|
+
const accesss_token = await this.GetAccessToken();
|
|
4368
|
+
expect(accesss_token).not.toEqual("");
|
|
4369
|
+
let personRecord = this.GetPersonRecord("", 1);
|
|
4370
|
+
let retVal = await this.PostResource(accesss_token, "Person", personRecord, (error) => {
|
|
4371
|
+
this.LogErrorMessage(chalk$1.red(`test(PostResource): ${error}`));
|
|
4372
|
+
});
|
|
4373
|
+
if (retVal) {
|
|
4374
|
+
this.CheckResourceMetaData(retVal, 201, personRecord);
|
|
4375
|
+
}
|
|
4376
|
+
retVal = await this.PostResource(accesss_token, "Person", personRecord, (error) => {
|
|
4377
|
+
this.LogErrorMessage(chalk$1.red(`test(PostResource duplicate): ${error}`));
|
|
4378
|
+
const responseCode = this.HandleError(error);
|
|
4379
|
+
expect(responseCode).toEqual(StatusCodes.CONFLICT);
|
|
4380
|
+
});
|
|
4381
|
+
expect(retVal).toBeNull();
|
|
4382
|
+
personRecord.text.div = "user01 put updated at " + (/* @__PURE__ */ new Date()).toString();
|
|
4383
|
+
retVal = await this.PutResource(accesss_token, "Person", personRecord, (error) => {
|
|
4384
|
+
this.LogErrorMessage(chalk$1.red(`test(PutResource): ${error}`));
|
|
4385
|
+
});
|
|
4386
|
+
if (retVal) {
|
|
4387
|
+
this.CheckResourceMetaData(retVal, 200, personRecord);
|
|
4388
|
+
}
|
|
4389
|
+
const patchPersonRecord = {
|
|
4390
|
+
id: personRecord.id,
|
|
4391
|
+
text: {
|
|
4392
|
+
div: "user01 patched at " + (/* @__PURE__ */ new Date()).toString(),
|
|
4393
|
+
status: "generated"
|
|
4394
|
+
}
|
|
4395
|
+
};
|
|
4396
|
+
retVal = await this.PatchResource(accesss_token, "Person", patchPersonRecord, (error) => {
|
|
4397
|
+
this.LogErrorMessage(chalk$1.red(`test(PatchResource): ${error}`));
|
|
4398
|
+
});
|
|
4399
|
+
personRecord = Object.assign({}, personRecord, patchPersonRecord);
|
|
4400
|
+
if (retVal) {
|
|
4401
|
+
this.CheckResourceMetaData(retVal, 200, personRecord);
|
|
4402
|
+
}
|
|
4403
|
+
retVal = await this.GetResource(accesss_token, "Person", personRecord.id, null, (error) => {
|
|
4404
|
+
this.LogErrorMessage(chalk$1.red(`test(GetResource): ${error}`));
|
|
4405
|
+
});
|
|
4406
|
+
if (retVal) {
|
|
4407
|
+
this.CheckResourceMetaData(retVal, 200, personRecord);
|
|
4408
|
+
}
|
|
4409
|
+
retVal = await this.GetResource(accesss_token, "Person", "willnotfind", null, (error) => {
|
|
4410
|
+
this.LogErrorMessage(chalk$1.red(`test(GetResource will not find): ${error}`));
|
|
4411
|
+
});
|
|
4412
|
+
expect(retVal).toBeNull();
|
|
4413
|
+
retVal = await this.DeleteResource(accesss_token, "Person", personRecord.id, (error) => {
|
|
4414
|
+
this.LogErrorMessage(chalk$1.red(`test(DeleteResource): ${error}`));
|
|
4415
|
+
});
|
|
4416
|
+
if (retVal) {
|
|
4417
|
+
this.CheckResourceMetaData(retVal, 200, personRecord);
|
|
4418
|
+
}
|
|
4419
|
+
retVal = await this.GetResource(accesss_token, "Person", personRecord.id, null, (error) => {
|
|
4420
|
+
this.LogErrorMessage(chalk$1.red(`test(GetResource after delete): ${error}`));
|
|
4421
|
+
});
|
|
4422
|
+
expect(retVal).toBeNull();
|
|
4423
|
+
});
|
|
4424
|
+
__publicField(this, "PostAndQuery", async () => {
|
|
4425
|
+
const iterations = 10;
|
|
4426
|
+
const personPrefix = `_${v4().replaceAll("-", "_")}_`;
|
|
4427
|
+
expect.assertions(4 + 4 * iterations);
|
|
4428
|
+
const accesss_token = await this.GetAccessToken();
|
|
4429
|
+
expect(accesss_token).not.toEqual("");
|
|
4430
|
+
for (let i = 0; i < iterations; i++) {
|
|
4431
|
+
const personRecord = this.GetPersonRecord(`${personPrefix}s1_`, i);
|
|
4432
|
+
const retVal2 = await this.PostResource(accesss_token, "Person", personRecord, (error) => {
|
|
4433
|
+
this.LogErrorMessage(chalk$1.red(`test(POST /stsresource and query using filter): ${error}`));
|
|
4434
|
+
});
|
|
4435
|
+
if (retVal2) {
|
|
4436
|
+
this.CheckResourceMetaData(retVal2, 201, personRecord);
|
|
4437
|
+
}
|
|
4438
|
+
}
|
|
4439
|
+
for (let i = 0; i < iterations; i++) {
|
|
4440
|
+
const personRecord = this.GetPersonRecord(`${personPrefix}s2_`, i);
|
|
4441
|
+
const retVal2 = await this.PostResource(accesss_token, "Person", personRecord, (error) => {
|
|
4442
|
+
this.LogErrorMessage(chalk$1.red(`test(POST /stsresource and query using filter): ${error}`));
|
|
4443
|
+
});
|
|
4444
|
+
if (retVal2) {
|
|
4445
|
+
this.CheckResourceMetaData(retVal2, 201, personRecord);
|
|
4446
|
+
}
|
|
4447
|
+
}
|
|
4448
|
+
let retVal = await this.GetResources(accesss_token, "Person", [`${personPrefix}`], (error) => {
|
|
4449
|
+
this.LogErrorMessage(chalk$1.red(`test(POST /stsresource and query using filter): ${error}`));
|
|
4450
|
+
});
|
|
4451
|
+
if (retVal) {
|
|
4452
|
+
console.log(retVal.data);
|
|
4453
|
+
expect(retVal.data.length).toEqual(iterations * 2);
|
|
4454
|
+
}
|
|
4455
|
+
retVal = await this.GetResources(accesss_token, "Person", [`${personPrefix}s1_`], (error) => {
|
|
4456
|
+
this.LogErrorMessage(chalk$1.red(`test(POST /stsresource and query using filter): ${error}`));
|
|
4457
|
+
});
|
|
4458
|
+
if (retVal) {
|
|
4459
|
+
console.log(retVal.data);
|
|
4460
|
+
expect(retVal.data.length).toEqual(iterations);
|
|
4461
|
+
}
|
|
4462
|
+
retVal = await this.GetResources(accesss_token, "Person", [`${personPrefix}s2_`, `${personPrefix}s1_`], (error) => {
|
|
4463
|
+
this.LogErrorMessage(chalk$1.red(`test(POST /stsresource and query using filter): ${error}`));
|
|
4464
|
+
});
|
|
4465
|
+
if (retVal) {
|
|
4466
|
+
console.log(retVal.data);
|
|
4467
|
+
expect(retVal.data.length).toEqual(iterations * 2);
|
|
4468
|
+
}
|
|
4469
|
+
});
|
|
4470
|
+
__publicField(this, "BatchMethods", async () => {
|
|
4471
|
+
const iterations = 10;
|
|
4472
|
+
const personPrefix = `_${v4().replaceAll("-", "_")}_`;
|
|
4473
|
+
expect.assertions(15);
|
|
4474
|
+
const accesss_token = await this.GetAccessToken();
|
|
4475
|
+
expect(accesss_token).not.toEqual("");
|
|
4476
|
+
const personRecords = this.GetPersonRecordBatch(`${personPrefix}`, 10);
|
|
4477
|
+
let stepMessage = `Resource list after put (batch create) resources`;
|
|
4478
|
+
let retVal = await this.PutResources(accesss_token, "Person", personRecords, (error) => {
|
|
4479
|
+
this.LogErrorMessage(chalk$1.red(`test(${stepMessage}): ${error}`));
|
|
4480
|
+
});
|
|
4481
|
+
if (retVal) {
|
|
4482
|
+
console.log(chalk$1.yellow(stepMessage));
|
|
4483
|
+
console.log(retVal.data);
|
|
4484
|
+
expect(retVal.status).toEqual(StatusCodes.OK);
|
|
4485
|
+
expect(retVal.data.length).toEqual(iterations);
|
|
4486
|
+
expect(retVal.data).toMatchObject(personRecords);
|
|
4487
|
+
}
|
|
4488
|
+
for (let i = 0; i < iterations; i++) {
|
|
4489
|
+
personRecords[i].text = {
|
|
4490
|
+
div: `user${i} updated at ` + (/* @__PURE__ */ new Date()).toString(),
|
|
4491
|
+
status: "extensions"
|
|
4492
|
+
};
|
|
4493
|
+
}
|
|
4494
|
+
stepMessage = `Resource list after put (update) resources`;
|
|
4495
|
+
retVal = await this.PutResources(accesss_token, "Person", personRecords, (error) => {
|
|
4496
|
+
this.LogErrorMessage(chalk$1.red(`test(${stepMessage}): ${error}`));
|
|
4497
|
+
});
|
|
4498
|
+
if (retVal) {
|
|
4499
|
+
console.log(chalk$1.yellow(stepMessage));
|
|
4500
|
+
console.log(retVal.data);
|
|
4501
|
+
expect(retVal.status).toEqual(StatusCodes.OK);
|
|
4502
|
+
expect(retVal.data.length).toEqual(iterations);
|
|
4503
|
+
expect(retVal.data).toMatchObject(personRecords);
|
|
4504
|
+
}
|
|
4505
|
+
const patchRecords = [];
|
|
4506
|
+
for (let i = 0; i < iterations; i++) {
|
|
4507
|
+
const updateTextObject = {
|
|
4508
|
+
div: `user${i} patched at ` + (/* @__PURE__ */ new Date()).toString(),
|
|
4509
|
+
status: "extensions"
|
|
4510
|
+
};
|
|
4511
|
+
patchRecords.push({
|
|
4512
|
+
id: personRecords[i].id,
|
|
4513
|
+
text: updateTextObject
|
|
4514
|
+
});
|
|
4515
|
+
personRecords[i].text = updateTextObject;
|
|
4516
|
+
}
|
|
4517
|
+
stepMessage = `Resource list after patch resources`;
|
|
4518
|
+
retVal = await this.PatchResources(accesss_token, "Person", patchRecords, (error) => {
|
|
4519
|
+
this.LogErrorMessage(chalk$1.red(`test(${stepMessage}): ${error}`));
|
|
4520
|
+
});
|
|
4521
|
+
if (retVal) {
|
|
4522
|
+
console.log(chalk$1.yellow(stepMessage));
|
|
4523
|
+
console.log(retVal.data);
|
|
4524
|
+
expect(retVal.status).toEqual(StatusCodes.OK);
|
|
4525
|
+
expect(retVal.data.length).toEqual(iterations);
|
|
4526
|
+
expect(retVal.data).toMatchObject(personRecords);
|
|
4527
|
+
}
|
|
4528
|
+
stepMessage = `Resource list before deleted resources`;
|
|
4529
|
+
retVal = await this.GetResources(accesss_token, "Person", [`${personPrefix}`], (error) => {
|
|
4530
|
+
this.LogErrorMessage(chalk$1.red(`test(${stepMessage}): ${error}`));
|
|
4531
|
+
});
|
|
4532
|
+
if (retVal) {
|
|
4533
|
+
console.log(chalk$1.yellow(stepMessage));
|
|
4534
|
+
console.log(retVal.data);
|
|
4535
|
+
expect(retVal.data.length).toEqual(iterations);
|
|
4536
|
+
}
|
|
4537
|
+
personRecords.splice(5);
|
|
4538
|
+
stepMessage = `Resource list of deleted resources`;
|
|
4539
|
+
retVal = await this.DeleteResources(accesss_token, "Person", personRecords, (error) => {
|
|
4540
|
+
this.LogErrorMessage(chalk$1.red(`test(${stepMessage}): ${error}`));
|
|
4541
|
+
});
|
|
4542
|
+
if (retVal) {
|
|
4543
|
+
console.log(chalk$1.yellow(stepMessage));
|
|
4544
|
+
console.log(retVal.data);
|
|
4545
|
+
expect(retVal.status).toEqual(StatusCodes.OK);
|
|
4546
|
+
expect(retVal.data.length).toEqual(5);
|
|
4547
|
+
expect(retVal.data).toMatchObject(personRecords);
|
|
4548
|
+
}
|
|
4549
|
+
stepMessage = `Resource list after partial deletes`;
|
|
4550
|
+
retVal = await this.GetResources(accesss_token, "Person", [`${personPrefix}`], (error) => {
|
|
4551
|
+
this.LogErrorMessage(chalk$1.red(`test(${stepMessage}): ${error}`));
|
|
4552
|
+
});
|
|
4553
|
+
if (retVal) {
|
|
4554
|
+
console.log(chalk$1.yellow(stepMessage));
|
|
4555
|
+
console.log(retVal.data);
|
|
4556
|
+
expect(retVal.data.length).toEqual(5);
|
|
4557
|
+
}
|
|
4558
|
+
});
|
|
4559
|
+
__privateSet(this, _testHelper2, options.testHelper);
|
|
4560
|
+
__privateSet(this, _authUtilsNode, options.authUtilsNode);
|
|
4561
|
+
}
|
|
4562
|
+
}
|
|
4563
|
+
_testHelper2 = new WeakMap();
|
|
4564
|
+
_authUtilsNode = new WeakMap();
|
|
2
4565
|
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4566
|
+
FhirClient,
|
|
4567
|
+
IFhirPersistenceType,
|
|
4568
|
+
STSFhirControllerTestCasesClient,
|
|
4569
|
+
STSFhirControllerTestCasesDirect
|
|
7
4570
|
};
|
|
8
4571
|
//# sourceMappingURL=stsfhirclient.mjs.map
|