@shopware/api-gen 1.4.0 → 1.5.1
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/README.md +23 -32
- package/dist/cli.mjs +27939 -25499
- package/dist/index.d.mts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.mjs +3 -3
- package/dist/shared/{api-gen.BWZPGkRz.mjs → api-gen.DDkIkZIo.mjs} +1054 -1561
- package/package.json +14 -15
|
@@ -1,654 +1,16 @@
|
|
|
1
1
|
import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
|
|
2
2
|
import { resolve, join, dirname } from 'node:path';
|
|
3
|
+
import { ofetch } from 'ofetch';
|
|
3
4
|
import openapiTS, { transformSchemaObjectWithComposition, astToString } from 'openapi-typescript';
|
|
4
5
|
import ts from 'typescript';
|
|
5
|
-
import { ofetch } from 'ofetch';
|
|
6
|
-
import { format as format$1 } from 'prettier';
|
|
7
6
|
import { Project } from 'ts-morph';
|
|
8
7
|
import require$$0 from 'fs';
|
|
9
8
|
import require$$1 from 'path';
|
|
10
9
|
import require$$2 from 'os';
|
|
11
10
|
import require$$3 from 'crypto';
|
|
11
|
+
import { format as format$1 } from 'oxfmt';
|
|
12
12
|
import { createAdminAPIClient, createAPIClient } from '@shopware/api-client';
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
// -- Unbuild CommonJS Shims --
|
|
17
|
-
import __cjs_url__ from 'url';
|
|
18
|
-
import __cjs_path__ from 'path';
|
|
19
|
-
import __cjs_mod__ from 'module';
|
|
20
|
-
const __filename = __cjs_url__.fileURLToPath(import.meta.url);
|
|
21
|
-
const __dirname = __cjs_path__.dirname(__filename);
|
|
22
|
-
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
23
|
-
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
24
|
-
|
|
25
|
-
function getDefaultExportFromCjs$2 (x) {
|
|
26
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function getAugmentedNamespace(n) {
|
|
30
|
-
if (n.__esModule) return n;
|
|
31
|
-
var f = n.default;
|
|
32
|
-
if (typeof f == "function") {
|
|
33
|
-
var a = function a () {
|
|
34
|
-
if (this instanceof a) {
|
|
35
|
-
return Reflect.construct(f, arguments, this.constructor);
|
|
36
|
-
}
|
|
37
|
-
return f.apply(this, arguments);
|
|
38
|
-
};
|
|
39
|
-
a.prototype = f.prototype;
|
|
40
|
-
} else a = {};
|
|
41
|
-
Object.defineProperty(a, '__esModule', {value: true});
|
|
42
|
-
Object.keys(n).forEach(function (k) {
|
|
43
|
-
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
44
|
-
Object.defineProperty(a, k, d.get ? d : {
|
|
45
|
-
enumerable: true,
|
|
46
|
-
get: function () {
|
|
47
|
-
return n[k];
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
return a;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
var main$1 = {exports: {}};
|
|
55
|
-
|
|
56
|
-
const name = "dotenv";
|
|
57
|
-
const version$1 = "17.2.3";
|
|
58
|
-
const description = "Loads environment variables from .env file";
|
|
59
|
-
const main = "lib/main.js";
|
|
60
|
-
const types = "lib/main.d.ts";
|
|
61
|
-
const exports = {
|
|
62
|
-
".": {
|
|
63
|
-
types: "./lib/main.d.ts",
|
|
64
|
-
require: "./lib/main.js",
|
|
65
|
-
"default": "./lib/main.js"
|
|
66
|
-
},
|
|
67
|
-
"./config": "./config.js",
|
|
68
|
-
"./config.js": "./config.js",
|
|
69
|
-
"./lib/env-options": "./lib/env-options.js",
|
|
70
|
-
"./lib/env-options.js": "./lib/env-options.js",
|
|
71
|
-
"./lib/cli-options": "./lib/cli-options.js",
|
|
72
|
-
"./lib/cli-options.js": "./lib/cli-options.js",
|
|
73
|
-
"./package.json": "./package.json"
|
|
74
|
-
};
|
|
75
|
-
const scripts = {
|
|
76
|
-
"dts-check": "tsc --project tests/types/tsconfig.json",
|
|
77
|
-
lint: "standard",
|
|
78
|
-
pretest: "npm run lint && npm run dts-check",
|
|
79
|
-
test: "tap run tests/**/*.js --allow-empty-coverage --disable-coverage --timeout=60000",
|
|
80
|
-
"test:coverage": "tap run tests/**/*.js --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",
|
|
81
|
-
prerelease: "npm test",
|
|
82
|
-
release: "standard-version"
|
|
83
|
-
};
|
|
84
|
-
const repository = {
|
|
85
|
-
type: "git",
|
|
86
|
-
url: "git://github.com/motdotla/dotenv.git"
|
|
87
|
-
};
|
|
88
|
-
const homepage = "https://github.com/motdotla/dotenv#readme";
|
|
89
|
-
const funding = "https://dotenvx.com";
|
|
90
|
-
const keywords = [
|
|
91
|
-
"dotenv",
|
|
92
|
-
"env",
|
|
93
|
-
".env",
|
|
94
|
-
"environment",
|
|
95
|
-
"variables",
|
|
96
|
-
"config",
|
|
97
|
-
"settings"
|
|
98
|
-
];
|
|
99
|
-
const readmeFilename = "README.md";
|
|
100
|
-
const license = "BSD-2-Clause";
|
|
101
|
-
const devDependencies = {
|
|
102
|
-
"@types/node": "^18.11.3",
|
|
103
|
-
decache: "^4.6.2",
|
|
104
|
-
sinon: "^14.0.1",
|
|
105
|
-
standard: "^17.0.0",
|
|
106
|
-
"standard-version": "^9.5.0",
|
|
107
|
-
tap: "^19.2.0",
|
|
108
|
-
typescript: "^4.8.4"
|
|
109
|
-
};
|
|
110
|
-
const engines = {
|
|
111
|
-
node: ">=12"
|
|
112
|
-
};
|
|
113
|
-
const browser = {
|
|
114
|
-
fs: false
|
|
115
|
-
};
|
|
116
|
-
const _package = {
|
|
117
|
-
name: name,
|
|
118
|
-
version: version$1,
|
|
119
|
-
description: description,
|
|
120
|
-
main: main,
|
|
121
|
-
types: types,
|
|
122
|
-
exports: exports,
|
|
123
|
-
scripts: scripts,
|
|
124
|
-
repository: repository,
|
|
125
|
-
homepage: homepage,
|
|
126
|
-
funding: funding,
|
|
127
|
-
keywords: keywords,
|
|
128
|
-
readmeFilename: readmeFilename,
|
|
129
|
-
license: license,
|
|
130
|
-
devDependencies: devDependencies,
|
|
131
|
-
engines: engines,
|
|
132
|
-
browser: browser
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
const _package$1 = {
|
|
136
|
-
__proto__: null,
|
|
137
|
-
browser: browser,
|
|
138
|
-
default: _package,
|
|
139
|
-
description: description,
|
|
140
|
-
devDependencies: devDependencies,
|
|
141
|
-
engines: engines,
|
|
142
|
-
exports: exports,
|
|
143
|
-
funding: funding,
|
|
144
|
-
homepage: homepage,
|
|
145
|
-
keywords: keywords,
|
|
146
|
-
license: license,
|
|
147
|
-
main: main,
|
|
148
|
-
name: name,
|
|
149
|
-
readmeFilename: readmeFilename,
|
|
150
|
-
repository: repository,
|
|
151
|
-
scripts: scripts,
|
|
152
|
-
types: types,
|
|
153
|
-
version: version$1
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
const require$$4 = /*@__PURE__*/getAugmentedNamespace(_package$1);
|
|
157
|
-
|
|
158
|
-
const fs = require$$0;
|
|
159
|
-
const path = require$$1;
|
|
160
|
-
const os = require$$2;
|
|
161
|
-
const crypto = require$$3;
|
|
162
|
-
const packageJson = require$$4;
|
|
163
|
-
|
|
164
|
-
const version = packageJson.version;
|
|
165
|
-
|
|
166
|
-
// Array of tips to display randomly
|
|
167
|
-
const TIPS = [
|
|
168
|
-
'🔐 encrypt with Dotenvx: https://dotenvx.com',
|
|
169
|
-
'🔐 prevent committing .env to code: https://dotenvx.com/precommit',
|
|
170
|
-
'🔐 prevent building .env in docker: https://dotenvx.com/prebuild',
|
|
171
|
-
'📡 add observability to secrets: https://dotenvx.com/ops',
|
|
172
|
-
'👥 sync secrets across teammates & machines: https://dotenvx.com/ops',
|
|
173
|
-
'🗂️ backup and recover secrets: https://dotenvx.com/ops',
|
|
174
|
-
'✅ audit secrets and track compliance: https://dotenvx.com/ops',
|
|
175
|
-
'🔄 add secrets lifecycle management: https://dotenvx.com/ops',
|
|
176
|
-
'🔑 add access controls to secrets: https://dotenvx.com/ops',
|
|
177
|
-
'🛠️ run anywhere with `dotenvx run -- yourcommand`',
|
|
178
|
-
'⚙️ specify custom .env file path with { path: \'/custom/path/.env\' }',
|
|
179
|
-
'⚙️ enable debug logging with { debug: true }',
|
|
180
|
-
'⚙️ override existing env vars with { override: true }',
|
|
181
|
-
'⚙️ suppress all logs with { quiet: true }',
|
|
182
|
-
'⚙️ write to custom object with { processEnv: myObject }',
|
|
183
|
-
'⚙️ load multiple .env files with { path: [\'.env.local\', \'.env\'] }'
|
|
184
|
-
];
|
|
185
|
-
|
|
186
|
-
// Get a random tip from the tips array
|
|
187
|
-
function _getRandomTip () {
|
|
188
|
-
return TIPS[Math.floor(Math.random() * TIPS.length)]
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
function parseBoolean (value) {
|
|
192
|
-
if (typeof value === 'string') {
|
|
193
|
-
return !['false', '0', 'no', 'off', ''].includes(value.toLowerCase())
|
|
194
|
-
}
|
|
195
|
-
return Boolean(value)
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
function supportsAnsi () {
|
|
199
|
-
return process.stdout.isTTY // && process.env.TERM !== 'dumb'
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
function dim (text) {
|
|
203
|
-
return supportsAnsi() ? `\x1b[2m${text}\x1b[0m` : text
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
|
|
207
|
-
|
|
208
|
-
// Parse src into an Object
|
|
209
|
-
function parse$1 (src) {
|
|
210
|
-
const obj = {};
|
|
211
|
-
|
|
212
|
-
// Convert buffer to string
|
|
213
|
-
let lines = src.toString();
|
|
214
|
-
|
|
215
|
-
// Convert line breaks to same format
|
|
216
|
-
lines = lines.replace(/\r\n?/mg, '\n');
|
|
217
|
-
|
|
218
|
-
let match;
|
|
219
|
-
while ((match = LINE.exec(lines)) != null) {
|
|
220
|
-
const key = match[1];
|
|
221
|
-
|
|
222
|
-
// Default undefined or null to empty string
|
|
223
|
-
let value = (match[2] || '');
|
|
224
|
-
|
|
225
|
-
// Remove whitespace
|
|
226
|
-
value = value.trim();
|
|
227
|
-
|
|
228
|
-
// Check if double quoted
|
|
229
|
-
const maybeQuote = value[0];
|
|
230
|
-
|
|
231
|
-
// Remove surrounding quotes
|
|
232
|
-
value = value.replace(/^(['"`])([\s\S]*)\1$/mg, '$2');
|
|
233
|
-
|
|
234
|
-
// Expand newlines if double quoted
|
|
235
|
-
if (maybeQuote === '"') {
|
|
236
|
-
value = value.replace(/\\n/g, '\n');
|
|
237
|
-
value = value.replace(/\\r/g, '\r');
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
// Add to object
|
|
241
|
-
obj[key] = value;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
return obj
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
function _parseVault (options) {
|
|
248
|
-
options = options || {};
|
|
249
|
-
|
|
250
|
-
const vaultPath = _vaultPath(options);
|
|
251
|
-
options.path = vaultPath; // parse .env.vault
|
|
252
|
-
const result = DotenvModule.configDotenv(options);
|
|
253
|
-
if (!result.parsed) {
|
|
254
|
-
const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
|
|
255
|
-
err.code = 'MISSING_DATA';
|
|
256
|
-
throw err
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
// handle scenario for comma separated keys - for use with key rotation
|
|
260
|
-
// example: DOTENV_KEY="dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=prod,dotenv://:key_7890@dotenvx.com/vault/.env.vault?environment=prod"
|
|
261
|
-
const keys = _dotenvKey(options).split(',');
|
|
262
|
-
const length = keys.length;
|
|
263
|
-
|
|
264
|
-
let decrypted;
|
|
265
|
-
for (let i = 0; i < length; i++) {
|
|
266
|
-
try {
|
|
267
|
-
// Get full key
|
|
268
|
-
const key = keys[i].trim();
|
|
269
|
-
|
|
270
|
-
// Get instructions for decrypt
|
|
271
|
-
const attrs = _instructions(result, key);
|
|
272
|
-
|
|
273
|
-
// Decrypt
|
|
274
|
-
decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
|
|
275
|
-
|
|
276
|
-
break
|
|
277
|
-
} catch (error) {
|
|
278
|
-
// last key
|
|
279
|
-
if (i + 1 >= length) {
|
|
280
|
-
throw error
|
|
281
|
-
}
|
|
282
|
-
// try next key
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
// Parse decrypted .env string
|
|
287
|
-
return DotenvModule.parse(decrypted)
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
function _warn (message) {
|
|
291
|
-
console.error(`[dotenv@${version}][WARN] ${message}`);
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
function _debug (message) {
|
|
295
|
-
console.log(`[dotenv@${version}][DEBUG] ${message}`);
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
function _log (message) {
|
|
299
|
-
console.log(`[dotenv@${version}] ${message}`);
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
function _dotenvKey (options) {
|
|
303
|
-
// prioritize developer directly setting options.DOTENV_KEY
|
|
304
|
-
if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
|
|
305
|
-
return options.DOTENV_KEY
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
// secondary infra already contains a DOTENV_KEY environment variable
|
|
309
|
-
if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
|
|
310
|
-
return process.env.DOTENV_KEY
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
// fallback to empty string
|
|
314
|
-
return ''
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
function _instructions (result, dotenvKey) {
|
|
318
|
-
// Parse DOTENV_KEY. Format is a URI
|
|
319
|
-
let uri;
|
|
320
|
-
try {
|
|
321
|
-
uri = new URL(dotenvKey);
|
|
322
|
-
} catch (error) {
|
|
323
|
-
if (error.code === 'ERR_INVALID_URL') {
|
|
324
|
-
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');
|
|
325
|
-
err.code = 'INVALID_DOTENV_KEY';
|
|
326
|
-
throw err
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
throw error
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
// Get decrypt key
|
|
333
|
-
const key = uri.password;
|
|
334
|
-
if (!key) {
|
|
335
|
-
const err = new Error('INVALID_DOTENV_KEY: Missing key part');
|
|
336
|
-
err.code = 'INVALID_DOTENV_KEY';
|
|
337
|
-
throw err
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
// Get environment
|
|
341
|
-
const environment = uri.searchParams.get('environment');
|
|
342
|
-
if (!environment) {
|
|
343
|
-
const err = new Error('INVALID_DOTENV_KEY: Missing environment part');
|
|
344
|
-
err.code = 'INVALID_DOTENV_KEY';
|
|
345
|
-
throw err
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
// Get ciphertext payload
|
|
349
|
-
const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
|
|
350
|
-
const ciphertext = result.parsed[environmentKey]; // DOTENV_VAULT_PRODUCTION
|
|
351
|
-
if (!ciphertext) {
|
|
352
|
-
const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
|
|
353
|
-
err.code = 'NOT_FOUND_DOTENV_ENVIRONMENT';
|
|
354
|
-
throw err
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
return { ciphertext, key }
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
function _vaultPath (options) {
|
|
361
|
-
let possibleVaultPath = null;
|
|
362
|
-
|
|
363
|
-
if (options && options.path && options.path.length > 0) {
|
|
364
|
-
if (Array.isArray(options.path)) {
|
|
365
|
-
for (const filepath of options.path) {
|
|
366
|
-
if (fs.existsSync(filepath)) {
|
|
367
|
-
possibleVaultPath = filepath.endsWith('.vault') ? filepath : `${filepath}.vault`;
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
} else {
|
|
371
|
-
possibleVaultPath = options.path.endsWith('.vault') ? options.path : `${options.path}.vault`;
|
|
372
|
-
}
|
|
373
|
-
} else {
|
|
374
|
-
possibleVaultPath = path.resolve(process.cwd(), '.env.vault');
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
if (fs.existsSync(possibleVaultPath)) {
|
|
378
|
-
return possibleVaultPath
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
return null
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
function _resolveHome (envPath) {
|
|
385
|
-
return envPath[0] === '~' ? path.join(os.homedir(), envPath.slice(1)) : envPath
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
function _configVault (options) {
|
|
389
|
-
const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || (options && options.debug));
|
|
390
|
-
const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || (options && options.quiet));
|
|
391
|
-
|
|
392
|
-
if (debug || !quiet) {
|
|
393
|
-
_log('Loading env from encrypted .env.vault');
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
const parsed = DotenvModule._parseVault(options);
|
|
397
|
-
|
|
398
|
-
let processEnv = process.env;
|
|
399
|
-
if (options && options.processEnv != null) {
|
|
400
|
-
processEnv = options.processEnv;
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
DotenvModule.populate(processEnv, parsed, options);
|
|
404
|
-
|
|
405
|
-
return { parsed }
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
function configDotenv (options) {
|
|
409
|
-
const dotenvPath = path.resolve(process.cwd(), '.env');
|
|
410
|
-
let encoding = 'utf8';
|
|
411
|
-
let processEnv = process.env;
|
|
412
|
-
if (options && options.processEnv != null) {
|
|
413
|
-
processEnv = options.processEnv;
|
|
414
|
-
}
|
|
415
|
-
let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || (options && options.debug));
|
|
416
|
-
let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || (options && options.quiet));
|
|
417
|
-
|
|
418
|
-
if (options && options.encoding) {
|
|
419
|
-
encoding = options.encoding;
|
|
420
|
-
} else {
|
|
421
|
-
if (debug) {
|
|
422
|
-
_debug('No encoding is specified. UTF-8 is used by default');
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
let optionPaths = [dotenvPath]; // default, look for .env
|
|
427
|
-
if (options && options.path) {
|
|
428
|
-
if (!Array.isArray(options.path)) {
|
|
429
|
-
optionPaths = [_resolveHome(options.path)];
|
|
430
|
-
} else {
|
|
431
|
-
optionPaths = []; // reset default
|
|
432
|
-
for (const filepath of options.path) {
|
|
433
|
-
optionPaths.push(_resolveHome(filepath));
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
// Build the parsed data in a temporary object (because we need to return it). Once we have the final
|
|
439
|
-
// parsed data, we will combine it with process.env (or options.processEnv if provided).
|
|
440
|
-
let lastError;
|
|
441
|
-
const parsedAll = {};
|
|
442
|
-
for (const path of optionPaths) {
|
|
443
|
-
try {
|
|
444
|
-
// Specifying an encoding returns a string instead of a buffer
|
|
445
|
-
const parsed = DotenvModule.parse(fs.readFileSync(path, { encoding }));
|
|
446
|
-
|
|
447
|
-
DotenvModule.populate(parsedAll, parsed, options);
|
|
448
|
-
} catch (e) {
|
|
449
|
-
if (debug) {
|
|
450
|
-
_debug(`Failed to load ${path} ${e.message}`);
|
|
451
|
-
}
|
|
452
|
-
lastError = e;
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
const populated = DotenvModule.populate(processEnv, parsedAll, options);
|
|
457
|
-
|
|
458
|
-
// handle user settings DOTENV_CONFIG_ options inside .env file(s)
|
|
459
|
-
debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug);
|
|
460
|
-
quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet);
|
|
461
|
-
|
|
462
|
-
if (debug || !quiet) {
|
|
463
|
-
const keysCount = Object.keys(populated).length;
|
|
464
|
-
const shortPaths = [];
|
|
465
|
-
for (const filePath of optionPaths) {
|
|
466
|
-
try {
|
|
467
|
-
const relative = path.relative(process.cwd(), filePath);
|
|
468
|
-
shortPaths.push(relative);
|
|
469
|
-
} catch (e) {
|
|
470
|
-
if (debug) {
|
|
471
|
-
_debug(`Failed to load ${filePath} ${e.message}`);
|
|
472
|
-
}
|
|
473
|
-
lastError = e;
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
_log(`injecting env (${keysCount}) from ${shortPaths.join(',')} ${dim(`-- tip: ${_getRandomTip()}`)}`);
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
if (lastError) {
|
|
481
|
-
return { parsed: parsedAll, error: lastError }
|
|
482
|
-
} else {
|
|
483
|
-
return { parsed: parsedAll }
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
// Populates process.env from .env file
|
|
488
|
-
function config$1 (options) {
|
|
489
|
-
// fallback to original dotenv if DOTENV_KEY is not set
|
|
490
|
-
if (_dotenvKey(options).length === 0) {
|
|
491
|
-
return DotenvModule.configDotenv(options)
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
const vaultPath = _vaultPath(options);
|
|
495
|
-
|
|
496
|
-
// dotenvKey exists but .env.vault file does not exist
|
|
497
|
-
if (!vaultPath) {
|
|
498
|
-
_warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
|
|
499
|
-
|
|
500
|
-
return DotenvModule.configDotenv(options)
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
return DotenvModule._configVault(options)
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
function decrypt (encrypted, keyStr) {
|
|
507
|
-
const key = Buffer.from(keyStr.slice(-64), 'hex');
|
|
508
|
-
let ciphertext = Buffer.from(encrypted, 'base64');
|
|
509
|
-
|
|
510
|
-
const nonce = ciphertext.subarray(0, 12);
|
|
511
|
-
const authTag = ciphertext.subarray(-16);
|
|
512
|
-
ciphertext = ciphertext.subarray(12, -16);
|
|
513
|
-
|
|
514
|
-
try {
|
|
515
|
-
const aesgcm = crypto.createDecipheriv('aes-256-gcm', key, nonce);
|
|
516
|
-
aesgcm.setAuthTag(authTag);
|
|
517
|
-
return `${aesgcm.update(ciphertext)}${aesgcm.final()}`
|
|
518
|
-
} catch (error) {
|
|
519
|
-
const isRange = error instanceof RangeError;
|
|
520
|
-
const invalidKeyLength = error.message === 'Invalid key length';
|
|
521
|
-
const decryptionFailed = error.message === 'Unsupported state or unable to authenticate data';
|
|
522
|
-
|
|
523
|
-
if (isRange || invalidKeyLength) {
|
|
524
|
-
const err = new Error('INVALID_DOTENV_KEY: It must be 64 characters long (or more)');
|
|
525
|
-
err.code = 'INVALID_DOTENV_KEY';
|
|
526
|
-
throw err
|
|
527
|
-
} else if (decryptionFailed) {
|
|
528
|
-
const err = new Error('DECRYPTION_FAILED: Please check your DOTENV_KEY');
|
|
529
|
-
err.code = 'DECRYPTION_FAILED';
|
|
530
|
-
throw err
|
|
531
|
-
} else {
|
|
532
|
-
throw error
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
// Populate process.env with parsed values
|
|
538
|
-
function populate (processEnv, parsed, options = {}) {
|
|
539
|
-
const debug = Boolean(options && options.debug);
|
|
540
|
-
const override = Boolean(options && options.override);
|
|
541
|
-
const populated = {};
|
|
542
|
-
|
|
543
|
-
if (typeof parsed !== 'object') {
|
|
544
|
-
const err = new Error('OBJECT_REQUIRED: Please check the processEnv argument being passed to populate');
|
|
545
|
-
err.code = 'OBJECT_REQUIRED';
|
|
546
|
-
throw err
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
// Set process.env
|
|
550
|
-
for (const key of Object.keys(parsed)) {
|
|
551
|
-
if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
|
|
552
|
-
if (override === true) {
|
|
553
|
-
processEnv[key] = parsed[key];
|
|
554
|
-
populated[key] = parsed[key];
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
if (debug) {
|
|
558
|
-
if (override === true) {
|
|
559
|
-
_debug(`"${key}" is already defined and WAS overwritten`);
|
|
560
|
-
} else {
|
|
561
|
-
_debug(`"${key}" is already defined and was NOT overwritten`);
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
} else {
|
|
565
|
-
processEnv[key] = parsed[key];
|
|
566
|
-
populated[key] = parsed[key];
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
return populated
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
const DotenvModule = {
|
|
574
|
-
configDotenv,
|
|
575
|
-
_configVault,
|
|
576
|
-
_parseVault,
|
|
577
|
-
config: config$1,
|
|
578
|
-
decrypt,
|
|
579
|
-
parse: parse$1,
|
|
580
|
-
populate
|
|
581
|
-
};
|
|
582
|
-
|
|
583
|
-
main$1.exports.configDotenv = DotenvModule.configDotenv;
|
|
584
|
-
main$1.exports._configVault = DotenvModule._configVault;
|
|
585
|
-
main$1.exports._parseVault = DotenvModule._parseVault;
|
|
586
|
-
main$1.exports.config = DotenvModule.config;
|
|
587
|
-
main$1.exports.decrypt = DotenvModule.decrypt;
|
|
588
|
-
main$1.exports.parse = DotenvModule.parse;
|
|
589
|
-
main$1.exports.populate = DotenvModule.populate;
|
|
590
|
-
|
|
591
|
-
main$1.exports = DotenvModule;
|
|
592
|
-
|
|
593
|
-
var mainExports = main$1.exports;
|
|
594
|
-
|
|
595
|
-
// ../config.js accepts options via environment variables
|
|
596
|
-
const options = {};
|
|
597
|
-
|
|
598
|
-
if (process.env.DOTENV_CONFIG_ENCODING != null) {
|
|
599
|
-
options.encoding = process.env.DOTENV_CONFIG_ENCODING;
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
if (process.env.DOTENV_CONFIG_PATH != null) {
|
|
603
|
-
options.path = process.env.DOTENV_CONFIG_PATH;
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
if (process.env.DOTENV_CONFIG_QUIET != null) {
|
|
607
|
-
options.quiet = process.env.DOTENV_CONFIG_QUIET;
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
if (process.env.DOTENV_CONFIG_DEBUG != null) {
|
|
611
|
-
options.debug = process.env.DOTENV_CONFIG_DEBUG;
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
if (process.env.DOTENV_CONFIG_OVERRIDE != null) {
|
|
615
|
-
options.override = process.env.DOTENV_CONFIG_OVERRIDE;
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
if (process.env.DOTENV_CONFIG_DOTENV_KEY != null) {
|
|
619
|
-
options.DOTENV_KEY = process.env.DOTENV_CONFIG_DOTENV_KEY;
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
var envOptions = options;
|
|
623
|
-
|
|
624
|
-
const re = /^dotenv_config_(encoding|path|quiet|debug|override|DOTENV_KEY)=(.+)$/;
|
|
625
|
-
|
|
626
|
-
var cliOptions = function optionMatcher (args) {
|
|
627
|
-
const options = args.reduce(function (acc, cur) {
|
|
628
|
-
const matches = cur.match(re);
|
|
629
|
-
if (matches) {
|
|
630
|
-
acc[matches[1]] = matches[2];
|
|
631
|
-
}
|
|
632
|
-
return acc
|
|
633
|
-
}, {});
|
|
634
|
-
|
|
635
|
-
if (!('quiet' in options)) {
|
|
636
|
-
options.quiet = 'true';
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
return options
|
|
640
|
-
};
|
|
641
|
-
|
|
642
|
-
(function () {
|
|
643
|
-
mainExports.config(
|
|
644
|
-
Object.assign(
|
|
645
|
-
{},
|
|
646
|
-
envOptions,
|
|
647
|
-
cliOptions(process.argv)
|
|
648
|
-
)
|
|
649
|
-
);
|
|
650
|
-
})();
|
|
651
|
-
|
|
652
14
|
// This is a generated file. Do not edit.
|
|
653
15
|
var Space_Separator = /[\u1680\u2000-\u200A\u202F\u205F\u3000]/;
|
|
654
16
|
var ID_Start = /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/;
|
|
@@ -2074,87 +1436,672 @@ const JSON5 = {
|
|
|
2074
1436
|
|
|
2075
1437
|
var lib = JSON5;
|
|
2076
1438
|
|
|
1439
|
+
function getDefaultExportFromCjs$2 (x) {
|
|
1440
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
function getAugmentedNamespace(n) {
|
|
1444
|
+
if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n;
|
|
1445
|
+
var f = n.default;
|
|
1446
|
+
if (typeof f == "function") {
|
|
1447
|
+
var a = function a () {
|
|
1448
|
+
var isInstance = false;
|
|
1449
|
+
try {
|
|
1450
|
+
isInstance = this instanceof a;
|
|
1451
|
+
} catch {}
|
|
1452
|
+
if (isInstance) {
|
|
1453
|
+
return Reflect.construct(f, arguments, this.constructor);
|
|
1454
|
+
}
|
|
1455
|
+
return f.apply(this, arguments);
|
|
1456
|
+
};
|
|
1457
|
+
a.prototype = f.prototype;
|
|
1458
|
+
} else a = {};
|
|
1459
|
+
Object.defineProperty(a, '__esModule', {value: true});
|
|
1460
|
+
Object.keys(n).forEach(function (k) {
|
|
1461
|
+
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
1462
|
+
Object.defineProperty(a, k, d.get ? d : {
|
|
1463
|
+
enumerable: true,
|
|
1464
|
+
get: function () {
|
|
1465
|
+
return n[k];
|
|
1466
|
+
}
|
|
1467
|
+
});
|
|
1468
|
+
});
|
|
1469
|
+
return a;
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
var config$1 = {};
|
|
1473
|
+
|
|
1474
|
+
var main = {exports: {}};
|
|
1475
|
+
|
|
1476
|
+
var hasRequiredMain;
|
|
1477
|
+
|
|
1478
|
+
function requireMain () {
|
|
1479
|
+
if (hasRequiredMain) return main.exports;
|
|
1480
|
+
hasRequiredMain = 1;
|
|
1481
|
+
const fs = require$$0;
|
|
1482
|
+
const path = require$$1;
|
|
1483
|
+
const os = require$$2;
|
|
1484
|
+
const crypto = require$$3;
|
|
1485
|
+
|
|
1486
|
+
// Array of tips to display randomly
|
|
1487
|
+
const TIPS = [
|
|
1488
|
+
'◈ encrypted .env [www.dotenvx.com]',
|
|
1489
|
+
'◈ secrets for agents [www.dotenvx.com]',
|
|
1490
|
+
'⌁ auth for agents [www.vestauth.com]',
|
|
1491
|
+
'⌘ custom filepath { path: \'/custom/path/.env\' }',
|
|
1492
|
+
'⌘ enable debugging { debug: true }',
|
|
1493
|
+
'⌘ override existing { override: true }',
|
|
1494
|
+
'⌘ suppress logs { quiet: true }',
|
|
1495
|
+
'⌘ multiple files { path: [\'.env.local\', \'.env\'] }'
|
|
1496
|
+
];
|
|
1497
|
+
|
|
1498
|
+
// Get a random tip from the tips array
|
|
1499
|
+
function _getRandomTip () {
|
|
1500
|
+
return TIPS[Math.floor(Math.random() * TIPS.length)]
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
function parseBoolean (value) {
|
|
1504
|
+
if (typeof value === 'string') {
|
|
1505
|
+
return !['false', '0', 'no', 'off', ''].includes(value.toLowerCase())
|
|
1506
|
+
}
|
|
1507
|
+
return Boolean(value)
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1510
|
+
function supportsAnsi () {
|
|
1511
|
+
return process.stdout.isTTY // && process.env.TERM !== 'dumb'
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1514
|
+
function dim (text) {
|
|
1515
|
+
return supportsAnsi() ? `\x1b[2m${text}\x1b[0m` : text
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1518
|
+
const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
|
|
1519
|
+
|
|
1520
|
+
// Parse src into an Object
|
|
1521
|
+
function parse (src) {
|
|
1522
|
+
const obj = {};
|
|
1523
|
+
|
|
1524
|
+
// Convert buffer to string
|
|
1525
|
+
let lines = src.toString();
|
|
1526
|
+
|
|
1527
|
+
// Convert line breaks to same format
|
|
1528
|
+
lines = lines.replace(/\r\n?/mg, '\n');
|
|
1529
|
+
|
|
1530
|
+
let match;
|
|
1531
|
+
while ((match = LINE.exec(lines)) != null) {
|
|
1532
|
+
const key = match[1];
|
|
1533
|
+
|
|
1534
|
+
// Default undefined or null to empty string
|
|
1535
|
+
let value = (match[2] || '');
|
|
1536
|
+
|
|
1537
|
+
// Remove whitespace
|
|
1538
|
+
value = value.trim();
|
|
1539
|
+
|
|
1540
|
+
// Check if double quoted
|
|
1541
|
+
const maybeQuote = value[0];
|
|
1542
|
+
|
|
1543
|
+
// Remove surrounding quotes
|
|
1544
|
+
value = value.replace(/^(['"`])([\s\S]*)\1$/mg, '$2');
|
|
1545
|
+
|
|
1546
|
+
// Expand newlines if double quoted
|
|
1547
|
+
if (maybeQuote === '"') {
|
|
1548
|
+
value = value.replace(/\\n/g, '\n');
|
|
1549
|
+
value = value.replace(/\\r/g, '\r');
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1552
|
+
// Add to object
|
|
1553
|
+
obj[key] = value;
|
|
1554
|
+
}
|
|
1555
|
+
|
|
1556
|
+
return obj
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
function _parseVault (options) {
|
|
1560
|
+
options = options || {};
|
|
1561
|
+
|
|
1562
|
+
const vaultPath = _vaultPath(options);
|
|
1563
|
+
options.path = vaultPath; // parse .env.vault
|
|
1564
|
+
const result = DotenvModule.configDotenv(options);
|
|
1565
|
+
if (!result.parsed) {
|
|
1566
|
+
const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
|
|
1567
|
+
err.code = 'MISSING_DATA';
|
|
1568
|
+
throw err
|
|
1569
|
+
}
|
|
1570
|
+
|
|
1571
|
+
// handle scenario for comma separated keys - for use with key rotation
|
|
1572
|
+
// example: DOTENV_KEY="dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=prod,dotenv://:key_7890@dotenvx.com/vault/.env.vault?environment=prod"
|
|
1573
|
+
const keys = _dotenvKey(options).split(',');
|
|
1574
|
+
const length = keys.length;
|
|
1575
|
+
|
|
1576
|
+
let decrypted;
|
|
1577
|
+
for (let i = 0; i < length; i++) {
|
|
1578
|
+
try {
|
|
1579
|
+
// Get full key
|
|
1580
|
+
const key = keys[i].trim();
|
|
1581
|
+
|
|
1582
|
+
// Get instructions for decrypt
|
|
1583
|
+
const attrs = _instructions(result, key);
|
|
1584
|
+
|
|
1585
|
+
// Decrypt
|
|
1586
|
+
decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
|
|
1587
|
+
|
|
1588
|
+
break
|
|
1589
|
+
} catch (error) {
|
|
1590
|
+
// last key
|
|
1591
|
+
if (i + 1 >= length) {
|
|
1592
|
+
throw error
|
|
1593
|
+
}
|
|
1594
|
+
// try next key
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
// Parse decrypted .env string
|
|
1599
|
+
return DotenvModule.parse(decrypted)
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1602
|
+
function _warn (message) {
|
|
1603
|
+
console.error(`⚠ ${message}`);
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
function _debug (message) {
|
|
1607
|
+
console.log(`┆ ${message}`);
|
|
1608
|
+
}
|
|
1609
|
+
|
|
1610
|
+
function _log (message) {
|
|
1611
|
+
console.log(`◇ ${message}`);
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1614
|
+
function _dotenvKey (options) {
|
|
1615
|
+
// prioritize developer directly setting options.DOTENV_KEY
|
|
1616
|
+
if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
|
|
1617
|
+
return options.DOTENV_KEY
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
// secondary infra already contains a DOTENV_KEY environment variable
|
|
1621
|
+
if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
|
|
1622
|
+
return process.env.DOTENV_KEY
|
|
1623
|
+
}
|
|
1624
|
+
|
|
1625
|
+
// fallback to empty string
|
|
1626
|
+
return ''
|
|
1627
|
+
}
|
|
1628
|
+
|
|
1629
|
+
function _instructions (result, dotenvKey) {
|
|
1630
|
+
// Parse DOTENV_KEY. Format is a URI
|
|
1631
|
+
let uri;
|
|
1632
|
+
try {
|
|
1633
|
+
uri = new URL(dotenvKey);
|
|
1634
|
+
} catch (error) {
|
|
1635
|
+
if (error.code === 'ERR_INVALID_URL') {
|
|
1636
|
+
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');
|
|
1637
|
+
err.code = 'INVALID_DOTENV_KEY';
|
|
1638
|
+
throw err
|
|
1639
|
+
}
|
|
1640
|
+
|
|
1641
|
+
throw error
|
|
1642
|
+
}
|
|
1643
|
+
|
|
1644
|
+
// Get decrypt key
|
|
1645
|
+
const key = uri.password;
|
|
1646
|
+
if (!key) {
|
|
1647
|
+
const err = new Error('INVALID_DOTENV_KEY: Missing key part');
|
|
1648
|
+
err.code = 'INVALID_DOTENV_KEY';
|
|
1649
|
+
throw err
|
|
1650
|
+
}
|
|
1651
|
+
|
|
1652
|
+
// Get environment
|
|
1653
|
+
const environment = uri.searchParams.get('environment');
|
|
1654
|
+
if (!environment) {
|
|
1655
|
+
const err = new Error('INVALID_DOTENV_KEY: Missing environment part');
|
|
1656
|
+
err.code = 'INVALID_DOTENV_KEY';
|
|
1657
|
+
throw err
|
|
1658
|
+
}
|
|
1659
|
+
|
|
1660
|
+
// Get ciphertext payload
|
|
1661
|
+
const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
|
|
1662
|
+
const ciphertext = result.parsed[environmentKey]; // DOTENV_VAULT_PRODUCTION
|
|
1663
|
+
if (!ciphertext) {
|
|
1664
|
+
const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
|
|
1665
|
+
err.code = 'NOT_FOUND_DOTENV_ENVIRONMENT';
|
|
1666
|
+
throw err
|
|
1667
|
+
}
|
|
1668
|
+
|
|
1669
|
+
return { ciphertext, key }
|
|
1670
|
+
}
|
|
1671
|
+
|
|
1672
|
+
function _vaultPath (options) {
|
|
1673
|
+
let possibleVaultPath = null;
|
|
1674
|
+
|
|
1675
|
+
if (options && options.path && options.path.length > 0) {
|
|
1676
|
+
if (Array.isArray(options.path)) {
|
|
1677
|
+
for (const filepath of options.path) {
|
|
1678
|
+
if (fs.existsSync(filepath)) {
|
|
1679
|
+
possibleVaultPath = filepath.endsWith('.vault') ? filepath : `${filepath}.vault`;
|
|
1680
|
+
}
|
|
1681
|
+
}
|
|
1682
|
+
} else {
|
|
1683
|
+
possibleVaultPath = options.path.endsWith('.vault') ? options.path : `${options.path}.vault`;
|
|
1684
|
+
}
|
|
1685
|
+
} else {
|
|
1686
|
+
possibleVaultPath = path.resolve(process.cwd(), '.env.vault');
|
|
1687
|
+
}
|
|
1688
|
+
|
|
1689
|
+
if (fs.existsSync(possibleVaultPath)) {
|
|
1690
|
+
return possibleVaultPath
|
|
1691
|
+
}
|
|
1692
|
+
|
|
1693
|
+
return null
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1696
|
+
function _resolveHome (envPath) {
|
|
1697
|
+
return envPath[0] === '~' ? path.join(os.homedir(), envPath.slice(1)) : envPath
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1700
|
+
function _configVault (options) {
|
|
1701
|
+
const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || (options && options.debug));
|
|
1702
|
+
const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || (options && options.quiet));
|
|
1703
|
+
|
|
1704
|
+
if (debug || !quiet) {
|
|
1705
|
+
_log('loading env from encrypted .env.vault');
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1708
|
+
const parsed = DotenvModule._parseVault(options);
|
|
1709
|
+
|
|
1710
|
+
let processEnv = process.env;
|
|
1711
|
+
if (options && options.processEnv != null) {
|
|
1712
|
+
processEnv = options.processEnv;
|
|
1713
|
+
}
|
|
1714
|
+
|
|
1715
|
+
DotenvModule.populate(processEnv, parsed, options);
|
|
1716
|
+
|
|
1717
|
+
return { parsed }
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1720
|
+
function configDotenv (options) {
|
|
1721
|
+
const dotenvPath = path.resolve(process.cwd(), '.env');
|
|
1722
|
+
let encoding = 'utf8';
|
|
1723
|
+
let processEnv = process.env;
|
|
1724
|
+
if (options && options.processEnv != null) {
|
|
1725
|
+
processEnv = options.processEnv;
|
|
1726
|
+
}
|
|
1727
|
+
let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || (options && options.debug));
|
|
1728
|
+
let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || (options && options.quiet));
|
|
1729
|
+
|
|
1730
|
+
if (options && options.encoding) {
|
|
1731
|
+
encoding = options.encoding;
|
|
1732
|
+
} else {
|
|
1733
|
+
if (debug) {
|
|
1734
|
+
_debug('no encoding is specified (UTF-8 is used by default)');
|
|
1735
|
+
}
|
|
1736
|
+
}
|
|
1737
|
+
|
|
1738
|
+
let optionPaths = [dotenvPath]; // default, look for .env
|
|
1739
|
+
if (options && options.path) {
|
|
1740
|
+
if (!Array.isArray(options.path)) {
|
|
1741
|
+
optionPaths = [_resolveHome(options.path)];
|
|
1742
|
+
} else {
|
|
1743
|
+
optionPaths = []; // reset default
|
|
1744
|
+
for (const filepath of options.path) {
|
|
1745
|
+
optionPaths.push(_resolveHome(filepath));
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
// Build the parsed data in a temporary object (because we need to return it). Once we have the final
|
|
1751
|
+
// parsed data, we will combine it with process.env (or options.processEnv if provided).
|
|
1752
|
+
let lastError;
|
|
1753
|
+
const parsedAll = {};
|
|
1754
|
+
for (const path of optionPaths) {
|
|
1755
|
+
try {
|
|
1756
|
+
// Specifying an encoding returns a string instead of a buffer
|
|
1757
|
+
const parsed = DotenvModule.parse(fs.readFileSync(path, { encoding }));
|
|
1758
|
+
|
|
1759
|
+
DotenvModule.populate(parsedAll, parsed, options);
|
|
1760
|
+
} catch (e) {
|
|
1761
|
+
if (debug) {
|
|
1762
|
+
_debug(`failed to load ${path} ${e.message}`);
|
|
1763
|
+
}
|
|
1764
|
+
lastError = e;
|
|
1765
|
+
}
|
|
1766
|
+
}
|
|
1767
|
+
|
|
1768
|
+
const populated = DotenvModule.populate(processEnv, parsedAll, options);
|
|
1769
|
+
|
|
1770
|
+
// handle user settings DOTENV_CONFIG_ options inside .env file(s)
|
|
1771
|
+
debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug);
|
|
1772
|
+
quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet);
|
|
1773
|
+
|
|
1774
|
+
if (debug || !quiet) {
|
|
1775
|
+
const keysCount = Object.keys(populated).length;
|
|
1776
|
+
const shortPaths = [];
|
|
1777
|
+
for (const filePath of optionPaths) {
|
|
1778
|
+
try {
|
|
1779
|
+
const relative = path.relative(process.cwd(), filePath);
|
|
1780
|
+
shortPaths.push(relative);
|
|
1781
|
+
} catch (e) {
|
|
1782
|
+
if (debug) {
|
|
1783
|
+
_debug(`failed to load ${filePath} ${e.message}`);
|
|
1784
|
+
}
|
|
1785
|
+
lastError = e;
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1788
|
+
|
|
1789
|
+
_log(`injected env (${keysCount}) from ${shortPaths.join(',')} ${dim(`// tip: ${_getRandomTip()}`)}`);
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1792
|
+
if (lastError) {
|
|
1793
|
+
return { parsed: parsedAll, error: lastError }
|
|
1794
|
+
} else {
|
|
1795
|
+
return { parsed: parsedAll }
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1798
|
+
|
|
1799
|
+
// Populates process.env from .env file
|
|
1800
|
+
function config (options) {
|
|
1801
|
+
// fallback to original dotenv if DOTENV_KEY is not set
|
|
1802
|
+
if (_dotenvKey(options).length === 0) {
|
|
1803
|
+
return DotenvModule.configDotenv(options)
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1806
|
+
const vaultPath = _vaultPath(options);
|
|
1807
|
+
|
|
1808
|
+
// dotenvKey exists but .env.vault file does not exist
|
|
1809
|
+
if (!vaultPath) {
|
|
1810
|
+
_warn(`you set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}`);
|
|
1811
|
+
|
|
1812
|
+
return DotenvModule.configDotenv(options)
|
|
1813
|
+
}
|
|
1814
|
+
|
|
1815
|
+
return DotenvModule._configVault(options)
|
|
1816
|
+
}
|
|
1817
|
+
|
|
1818
|
+
function decrypt (encrypted, keyStr) {
|
|
1819
|
+
const key = Buffer.from(keyStr.slice(-64), 'hex');
|
|
1820
|
+
let ciphertext = Buffer.from(encrypted, 'base64');
|
|
1821
|
+
|
|
1822
|
+
const nonce = ciphertext.subarray(0, 12);
|
|
1823
|
+
const authTag = ciphertext.subarray(-16);
|
|
1824
|
+
ciphertext = ciphertext.subarray(12, -16);
|
|
1825
|
+
|
|
1826
|
+
try {
|
|
1827
|
+
const aesgcm = crypto.createDecipheriv('aes-256-gcm', key, nonce);
|
|
1828
|
+
aesgcm.setAuthTag(authTag);
|
|
1829
|
+
return `${aesgcm.update(ciphertext)}${aesgcm.final()}`
|
|
1830
|
+
} catch (error) {
|
|
1831
|
+
const isRange = error instanceof RangeError;
|
|
1832
|
+
const invalidKeyLength = error.message === 'Invalid key length';
|
|
1833
|
+
const decryptionFailed = error.message === 'Unsupported state or unable to authenticate data';
|
|
1834
|
+
|
|
1835
|
+
if (isRange || invalidKeyLength) {
|
|
1836
|
+
const err = new Error('INVALID_DOTENV_KEY: It must be 64 characters long (or more)');
|
|
1837
|
+
err.code = 'INVALID_DOTENV_KEY';
|
|
1838
|
+
throw err
|
|
1839
|
+
} else if (decryptionFailed) {
|
|
1840
|
+
const err = new Error('DECRYPTION_FAILED: Please check your DOTENV_KEY');
|
|
1841
|
+
err.code = 'DECRYPTION_FAILED';
|
|
1842
|
+
throw err
|
|
1843
|
+
} else {
|
|
1844
|
+
throw error
|
|
1845
|
+
}
|
|
1846
|
+
}
|
|
1847
|
+
}
|
|
1848
|
+
|
|
1849
|
+
// Populate process.env with parsed values
|
|
1850
|
+
function populate (processEnv, parsed, options = {}) {
|
|
1851
|
+
const debug = Boolean(options && options.debug);
|
|
1852
|
+
const override = Boolean(options && options.override);
|
|
1853
|
+
const populated = {};
|
|
1854
|
+
|
|
1855
|
+
if (typeof parsed !== 'object') {
|
|
1856
|
+
const err = new Error('OBJECT_REQUIRED: Please check the processEnv argument being passed to populate');
|
|
1857
|
+
err.code = 'OBJECT_REQUIRED';
|
|
1858
|
+
throw err
|
|
1859
|
+
}
|
|
1860
|
+
|
|
1861
|
+
// Set process.env
|
|
1862
|
+
for (const key of Object.keys(parsed)) {
|
|
1863
|
+
if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
|
|
1864
|
+
if (override === true) {
|
|
1865
|
+
processEnv[key] = parsed[key];
|
|
1866
|
+
populated[key] = parsed[key];
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1869
|
+
if (debug) {
|
|
1870
|
+
if (override === true) {
|
|
1871
|
+
_debug(`"${key}" is already defined and WAS overwritten`);
|
|
1872
|
+
} else {
|
|
1873
|
+
_debug(`"${key}" is already defined and was NOT overwritten`);
|
|
1874
|
+
}
|
|
1875
|
+
}
|
|
1876
|
+
} else {
|
|
1877
|
+
processEnv[key] = parsed[key];
|
|
1878
|
+
populated[key] = parsed[key];
|
|
1879
|
+
}
|
|
1880
|
+
}
|
|
1881
|
+
|
|
1882
|
+
return populated
|
|
1883
|
+
}
|
|
1884
|
+
|
|
1885
|
+
const DotenvModule = {
|
|
1886
|
+
configDotenv,
|
|
1887
|
+
_configVault,
|
|
1888
|
+
_parseVault,
|
|
1889
|
+
config,
|
|
1890
|
+
decrypt,
|
|
1891
|
+
parse,
|
|
1892
|
+
populate
|
|
1893
|
+
};
|
|
1894
|
+
|
|
1895
|
+
main.exports.configDotenv = DotenvModule.configDotenv;
|
|
1896
|
+
main.exports._configVault = DotenvModule._configVault;
|
|
1897
|
+
main.exports._parseVault = DotenvModule._parseVault;
|
|
1898
|
+
main.exports.config = DotenvModule.config;
|
|
1899
|
+
main.exports.decrypt = DotenvModule.decrypt;
|
|
1900
|
+
main.exports.parse = DotenvModule.parse;
|
|
1901
|
+
main.exports.populate = DotenvModule.populate;
|
|
1902
|
+
|
|
1903
|
+
main.exports = DotenvModule;
|
|
1904
|
+
return main.exports;
|
|
1905
|
+
}
|
|
1906
|
+
|
|
1907
|
+
var envOptions;
|
|
1908
|
+
var hasRequiredEnvOptions;
|
|
1909
|
+
|
|
1910
|
+
function requireEnvOptions () {
|
|
1911
|
+
if (hasRequiredEnvOptions) return envOptions;
|
|
1912
|
+
hasRequiredEnvOptions = 1;
|
|
1913
|
+
// ../config.js accepts options via environment variables
|
|
1914
|
+
const options = {};
|
|
1915
|
+
|
|
1916
|
+
if (process.env.DOTENV_CONFIG_ENCODING != null) {
|
|
1917
|
+
options.encoding = process.env.DOTENV_CONFIG_ENCODING;
|
|
1918
|
+
}
|
|
1919
|
+
|
|
1920
|
+
if (process.env.DOTENV_CONFIG_PATH != null) {
|
|
1921
|
+
options.path = process.env.DOTENV_CONFIG_PATH;
|
|
1922
|
+
}
|
|
1923
|
+
|
|
1924
|
+
if (process.env.DOTENV_CONFIG_QUIET != null) {
|
|
1925
|
+
options.quiet = process.env.DOTENV_CONFIG_QUIET;
|
|
1926
|
+
}
|
|
1927
|
+
|
|
1928
|
+
if (process.env.DOTENV_CONFIG_DEBUG != null) {
|
|
1929
|
+
options.debug = process.env.DOTENV_CONFIG_DEBUG;
|
|
1930
|
+
}
|
|
1931
|
+
|
|
1932
|
+
if (process.env.DOTENV_CONFIG_OVERRIDE != null) {
|
|
1933
|
+
options.override = process.env.DOTENV_CONFIG_OVERRIDE;
|
|
1934
|
+
}
|
|
1935
|
+
|
|
1936
|
+
if (process.env.DOTENV_CONFIG_DOTENV_KEY != null) {
|
|
1937
|
+
options.DOTENV_KEY = process.env.DOTENV_CONFIG_DOTENV_KEY;
|
|
1938
|
+
}
|
|
1939
|
+
|
|
1940
|
+
envOptions = options;
|
|
1941
|
+
return envOptions;
|
|
1942
|
+
}
|
|
1943
|
+
|
|
1944
|
+
var cliOptions;
|
|
1945
|
+
var hasRequiredCliOptions;
|
|
1946
|
+
|
|
1947
|
+
function requireCliOptions () {
|
|
1948
|
+
if (hasRequiredCliOptions) return cliOptions;
|
|
1949
|
+
hasRequiredCliOptions = 1;
|
|
1950
|
+
const re = /^dotenv_config_(encoding|path|quiet|debug|override|DOTENV_KEY)=(.+)$/;
|
|
1951
|
+
|
|
1952
|
+
cliOptions = function optionMatcher (args) {
|
|
1953
|
+
const options = args.reduce(function (acc, cur) {
|
|
1954
|
+
const matches = cur.match(re);
|
|
1955
|
+
if (matches) {
|
|
1956
|
+
acc[matches[1]] = matches[2];
|
|
1957
|
+
}
|
|
1958
|
+
return acc
|
|
1959
|
+
}, {});
|
|
1960
|
+
|
|
1961
|
+
if (!('quiet' in options)) {
|
|
1962
|
+
options.quiet = 'true';
|
|
1963
|
+
}
|
|
1964
|
+
|
|
1965
|
+
return options
|
|
1966
|
+
};
|
|
1967
|
+
return cliOptions;
|
|
1968
|
+
}
|
|
1969
|
+
|
|
1970
|
+
var hasRequiredConfig;
|
|
1971
|
+
|
|
1972
|
+
function requireConfig () {
|
|
1973
|
+
if (hasRequiredConfig) return config$1;
|
|
1974
|
+
hasRequiredConfig = 1;
|
|
1975
|
+
(function () {
|
|
1976
|
+
requireMain().config(
|
|
1977
|
+
Object.assign(
|
|
1978
|
+
{},
|
|
1979
|
+
requireEnvOptions(),
|
|
1980
|
+
requireCliOptions()(process.argv)
|
|
1981
|
+
)
|
|
1982
|
+
);
|
|
1983
|
+
})();
|
|
1984
|
+
return config$1;
|
|
1985
|
+
}
|
|
1986
|
+
|
|
1987
|
+
requireConfig();
|
|
1988
|
+
|
|
2077
1989
|
var picocolors = {exports: {}};
|
|
2078
1990
|
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
1991
|
+
var hasRequiredPicocolors;
|
|
1992
|
+
|
|
1993
|
+
function requirePicocolors () {
|
|
1994
|
+
if (hasRequiredPicocolors) return picocolors.exports;
|
|
1995
|
+
hasRequiredPicocolors = 1;
|
|
1996
|
+
let p = process || {}, argv = p.argv || [], env = p.env || {};
|
|
1997
|
+
let isColorSupported =
|
|
1998
|
+
!(!!env.NO_COLOR || argv.includes("--no-color")) &&
|
|
1999
|
+
(!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || ((p.stdout || {}).isTTY && env.TERM !== "dumb") || !!env.CI);
|
|
2000
|
+
|
|
2001
|
+
let formatter = (open, close, replace = open) =>
|
|
2002
|
+
input => {
|
|
2003
|
+
let string = "" + input, index = string.indexOf(close, open.length);
|
|
2004
|
+
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close
|
|
2005
|
+
};
|
|
2083
2006
|
|
|
2084
|
-
let
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2007
|
+
let replaceClose = (string, close, replace, index) => {
|
|
2008
|
+
let result = "", cursor = 0;
|
|
2009
|
+
do {
|
|
2010
|
+
result += string.substring(cursor, index) + replace;
|
|
2011
|
+
cursor = index + close.length;
|
|
2012
|
+
index = string.indexOf(close, cursor);
|
|
2013
|
+
} while (~index)
|
|
2014
|
+
return result + string.substring(cursor)
|
|
2088
2015
|
};
|
|
2089
2016
|
|
|
2090
|
-
let
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2017
|
+
let createColors = (enabled = isColorSupported) => {
|
|
2018
|
+
let f = enabled ? formatter : () => String;
|
|
2019
|
+
return {
|
|
2020
|
+
isColorSupported: enabled,
|
|
2021
|
+
reset: f("\x1b[0m", "\x1b[0m"),
|
|
2022
|
+
bold: f("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
|
|
2023
|
+
dim: f("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
|
|
2024
|
+
italic: f("\x1b[3m", "\x1b[23m"),
|
|
2025
|
+
underline: f("\x1b[4m", "\x1b[24m"),
|
|
2026
|
+
inverse: f("\x1b[7m", "\x1b[27m"),
|
|
2027
|
+
hidden: f("\x1b[8m", "\x1b[28m"),
|
|
2028
|
+
strikethrough: f("\x1b[9m", "\x1b[29m"),
|
|
2029
|
+
|
|
2030
|
+
black: f("\x1b[30m", "\x1b[39m"),
|
|
2031
|
+
red: f("\x1b[31m", "\x1b[39m"),
|
|
2032
|
+
green: f("\x1b[32m", "\x1b[39m"),
|
|
2033
|
+
yellow: f("\x1b[33m", "\x1b[39m"),
|
|
2034
|
+
blue: f("\x1b[34m", "\x1b[39m"),
|
|
2035
|
+
magenta: f("\x1b[35m", "\x1b[39m"),
|
|
2036
|
+
cyan: f("\x1b[36m", "\x1b[39m"),
|
|
2037
|
+
white: f("\x1b[37m", "\x1b[39m"),
|
|
2038
|
+
gray: f("\x1b[90m", "\x1b[39m"),
|
|
2039
|
+
|
|
2040
|
+
bgBlack: f("\x1b[40m", "\x1b[49m"),
|
|
2041
|
+
bgRed: f("\x1b[41m", "\x1b[49m"),
|
|
2042
|
+
bgGreen: f("\x1b[42m", "\x1b[49m"),
|
|
2043
|
+
bgYellow: f("\x1b[43m", "\x1b[49m"),
|
|
2044
|
+
bgBlue: f("\x1b[44m", "\x1b[49m"),
|
|
2045
|
+
bgMagenta: f("\x1b[45m", "\x1b[49m"),
|
|
2046
|
+
bgCyan: f("\x1b[46m", "\x1b[49m"),
|
|
2047
|
+
bgWhite: f("\x1b[47m", "\x1b[49m"),
|
|
2048
|
+
|
|
2049
|
+
blackBright: f("\x1b[90m", "\x1b[39m"),
|
|
2050
|
+
redBright: f("\x1b[91m", "\x1b[39m"),
|
|
2051
|
+
greenBright: f("\x1b[92m", "\x1b[39m"),
|
|
2052
|
+
yellowBright: f("\x1b[93m", "\x1b[39m"),
|
|
2053
|
+
blueBright: f("\x1b[94m", "\x1b[39m"),
|
|
2054
|
+
magentaBright: f("\x1b[95m", "\x1b[39m"),
|
|
2055
|
+
cyanBright: f("\x1b[96m", "\x1b[39m"),
|
|
2056
|
+
whiteBright: f("\x1b[97m", "\x1b[39m"),
|
|
2057
|
+
|
|
2058
|
+
bgBlackBright: f("\x1b[100m", "\x1b[49m"),
|
|
2059
|
+
bgRedBright: f("\x1b[101m", "\x1b[49m"),
|
|
2060
|
+
bgGreenBright: f("\x1b[102m", "\x1b[49m"),
|
|
2061
|
+
bgYellowBright: f("\x1b[103m", "\x1b[49m"),
|
|
2062
|
+
bgBlueBright: f("\x1b[104m", "\x1b[49m"),
|
|
2063
|
+
bgMagentaBright: f("\x1b[105m", "\x1b[49m"),
|
|
2064
|
+
bgCyanBright: f("\x1b[106m", "\x1b[49m"),
|
|
2065
|
+
bgWhiteBright: f("\x1b[107m", "\x1b[49m"),
|
|
2066
|
+
}
|
|
2067
|
+
};
|
|
2099
2068
|
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
return
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
dim: f("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
|
|
2107
|
-
italic: f("\x1b[3m", "\x1b[23m"),
|
|
2108
|
-
underline: f("\x1b[4m", "\x1b[24m"),
|
|
2109
|
-
inverse: f("\x1b[7m", "\x1b[27m"),
|
|
2110
|
-
hidden: f("\x1b[8m", "\x1b[28m"),
|
|
2111
|
-
strikethrough: f("\x1b[9m", "\x1b[29m"),
|
|
2112
|
-
|
|
2113
|
-
black: f("\x1b[30m", "\x1b[39m"),
|
|
2114
|
-
red: f("\x1b[31m", "\x1b[39m"),
|
|
2115
|
-
green: f("\x1b[32m", "\x1b[39m"),
|
|
2116
|
-
yellow: f("\x1b[33m", "\x1b[39m"),
|
|
2117
|
-
blue: f("\x1b[34m", "\x1b[39m"),
|
|
2118
|
-
magenta: f("\x1b[35m", "\x1b[39m"),
|
|
2119
|
-
cyan: f("\x1b[36m", "\x1b[39m"),
|
|
2120
|
-
white: f("\x1b[37m", "\x1b[39m"),
|
|
2121
|
-
gray: f("\x1b[90m", "\x1b[39m"),
|
|
2122
|
-
|
|
2123
|
-
bgBlack: f("\x1b[40m", "\x1b[49m"),
|
|
2124
|
-
bgRed: f("\x1b[41m", "\x1b[49m"),
|
|
2125
|
-
bgGreen: f("\x1b[42m", "\x1b[49m"),
|
|
2126
|
-
bgYellow: f("\x1b[43m", "\x1b[49m"),
|
|
2127
|
-
bgBlue: f("\x1b[44m", "\x1b[49m"),
|
|
2128
|
-
bgMagenta: f("\x1b[45m", "\x1b[49m"),
|
|
2129
|
-
bgCyan: f("\x1b[46m", "\x1b[49m"),
|
|
2130
|
-
bgWhite: f("\x1b[47m", "\x1b[49m"),
|
|
2131
|
-
|
|
2132
|
-
blackBright: f("\x1b[90m", "\x1b[39m"),
|
|
2133
|
-
redBright: f("\x1b[91m", "\x1b[39m"),
|
|
2134
|
-
greenBright: f("\x1b[92m", "\x1b[39m"),
|
|
2135
|
-
yellowBright: f("\x1b[93m", "\x1b[39m"),
|
|
2136
|
-
blueBright: f("\x1b[94m", "\x1b[39m"),
|
|
2137
|
-
magentaBright: f("\x1b[95m", "\x1b[39m"),
|
|
2138
|
-
cyanBright: f("\x1b[96m", "\x1b[39m"),
|
|
2139
|
-
whiteBright: f("\x1b[97m", "\x1b[39m"),
|
|
2140
|
-
|
|
2141
|
-
bgBlackBright: f("\x1b[100m", "\x1b[49m"),
|
|
2142
|
-
bgRedBright: f("\x1b[101m", "\x1b[49m"),
|
|
2143
|
-
bgGreenBright: f("\x1b[102m", "\x1b[49m"),
|
|
2144
|
-
bgYellowBright: f("\x1b[103m", "\x1b[49m"),
|
|
2145
|
-
bgBlueBright: f("\x1b[104m", "\x1b[49m"),
|
|
2146
|
-
bgMagentaBright: f("\x1b[105m", "\x1b[49m"),
|
|
2147
|
-
bgCyanBright: f("\x1b[106m", "\x1b[49m"),
|
|
2148
|
-
bgWhiteBright: f("\x1b[107m", "\x1b[49m"),
|
|
2149
|
-
}
|
|
2150
|
-
};
|
|
2151
|
-
|
|
2152
|
-
picocolors.exports = createColors();
|
|
2153
|
-
picocolors.exports.createColors = createColors;
|
|
2154
|
-
|
|
2155
|
-
var picocolorsExports = picocolors.exports;
|
|
2069
|
+
picocolors.exports = createColors();
|
|
2070
|
+
picocolors.exports.createColors = createColors;
|
|
2071
|
+
return picocolors.exports;
|
|
2072
|
+
}
|
|
2073
|
+
|
|
2074
|
+
var picocolorsExports = /*@__PURE__*/ requirePicocolors();
|
|
2156
2075
|
const c = /*@__PURE__*/getDefaultExportFromCjs$2(picocolorsExports);
|
|
2157
2076
|
|
|
2077
|
+
const formatConfig = {
|
|
2078
|
+
arrowParens: "always",
|
|
2079
|
+
bracketSameLine: false,
|
|
2080
|
+
bracketSpacing: true,
|
|
2081
|
+
endOfLine: "lf",
|
|
2082
|
+
printWidth: 80,
|
|
2083
|
+
quoteProps: "as-needed",
|
|
2084
|
+
semi: true,
|
|
2085
|
+
singleQuote: false,
|
|
2086
|
+
tabWidth: 2,
|
|
2087
|
+
trailingComma: "all",
|
|
2088
|
+
useTabs: false
|
|
2089
|
+
};
|
|
2090
|
+
async function formatSource(fileName, sourceText, options) {
|
|
2091
|
+
const result = await format$1(fileName, sourceText, {
|
|
2092
|
+
...formatConfig,
|
|
2093
|
+
...options
|
|
2094
|
+
});
|
|
2095
|
+
if (result.errors.length) {
|
|
2096
|
+
const messages = result.errors.map((error) => error.message).filter(Boolean).join("\n");
|
|
2097
|
+
throw new Error(
|
|
2098
|
+
`Could not format ${fileName}${messages ? `:
|
|
2099
|
+
${messages}` : ""}`
|
|
2100
|
+
);
|
|
2101
|
+
}
|
|
2102
|
+
return result.code;
|
|
2103
|
+
}
|
|
2104
|
+
|
|
2158
2105
|
function isPlainObject$1(value) {
|
|
2159
2106
|
if (value === null || typeof value !== "object") {
|
|
2160
2107
|
return false;
|
|
@@ -2176,8 +2123,8 @@ function _defu(baseObject, defaults, namespace = ".", merger) {
|
|
|
2176
2123
|
if (!isPlainObject$1(defaults)) {
|
|
2177
2124
|
return _defu(baseObject, {}, namespace, merger);
|
|
2178
2125
|
}
|
|
2179
|
-
const object =
|
|
2180
|
-
for (const key
|
|
2126
|
+
const object = { ...defaults };
|
|
2127
|
+
for (const key of Object.keys(baseObject)) {
|
|
2181
2128
|
if (key === "__proto__" || key === "constructor") {
|
|
2182
2129
|
continue;
|
|
2183
2130
|
}
|
|
@@ -2212,7 +2159,7 @@ function createDefu(merger) {
|
|
|
2212
2159
|
const defu = createDefu();
|
|
2213
2160
|
|
|
2214
2161
|
// src/index.ts
|
|
2215
|
-
var
|
|
2162
|
+
var b = {
|
|
2216
2163
|
reset: [0, 0],
|
|
2217
2164
|
bold: [1, 22, "\x1B[22m\x1B[1m"],
|
|
2218
2165
|
dim: [2, 22, "\x1B[22m\x1B[2m"],
|
|
@@ -2254,44 +2201,46 @@ var f = {
|
|
|
2254
2201
|
bgMagentaBright: [105, 49],
|
|
2255
2202
|
bgCyanBright: [106, 49],
|
|
2256
2203
|
bgWhiteBright: [107, 49]
|
|
2257
|
-
}
|
|
2258
|
-
function
|
|
2259
|
-
return String(
|
|
2260
|
-
}
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
function
|
|
2264
|
-
let e = typeof process != "undefined" ? process : void 0,
|
|
2265
|
-
return !("NO_COLOR" in
|
|
2266
|
-
}
|
|
2267
|
-
function
|
|
2268
|
-
let
|
|
2269
|
-
let
|
|
2204
|
+
};
|
|
2205
|
+
function i(e) {
|
|
2206
|
+
return String(e);
|
|
2207
|
+
}
|
|
2208
|
+
i.open = "";
|
|
2209
|
+
i.close = "";
|
|
2210
|
+
function B() {
|
|
2211
|
+
let e = typeof process != "undefined" ? process : void 0, r = (e == null ? void 0 : e.env) || {}, a = r.FORCE_TTY !== "false", l = (e == null ? void 0 : e.argv) || [];
|
|
2212
|
+
return !("NO_COLOR" in r || l.includes("--no-color")) && ("FORCE_COLOR" in r || l.includes("--color") || (e == null ? void 0 : e.platform) === "win32" || a && r.TERM !== "dumb" || "CI" in r) || typeof window != "undefined" && !!window.chrome;
|
|
2213
|
+
}
|
|
2214
|
+
function C({ force: e } = {}) {
|
|
2215
|
+
let r = e || B(), a = (t, o, u, n) => {
|
|
2216
|
+
let g = "", s = 0;
|
|
2270
2217
|
do
|
|
2271
|
-
|
|
2272
|
-
while (~
|
|
2273
|
-
return
|
|
2274
|
-
},
|
|
2275
|
-
let
|
|
2276
|
-
let s = String(
|
|
2277
|
-
return ~
|
|
2218
|
+
g += t.substring(s, n) + u, s = n + o.length, n = t.indexOf(o, s);
|
|
2219
|
+
while (~n);
|
|
2220
|
+
return g + t.substring(s);
|
|
2221
|
+
}, l = (t, o, u = t) => {
|
|
2222
|
+
let n = (g) => {
|
|
2223
|
+
let s = String(g), h = s.indexOf(o, t.length);
|
|
2224
|
+
return ~h ? t + a(s, o, u, h) + o : t + s + o;
|
|
2278
2225
|
};
|
|
2279
|
-
return
|
|
2280
|
-
},
|
|
2281
|
-
isColorSupported:
|
|
2282
|
-
},
|
|
2283
|
-
for (let
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
}
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2226
|
+
return n.open = t, n.close = o, n;
|
|
2227
|
+
}, c = {
|
|
2228
|
+
isColorSupported: r
|
|
2229
|
+
}, f = (t) => `\x1B[${t}m`;
|
|
2230
|
+
for (let t in b) {
|
|
2231
|
+
let o = b[t];
|
|
2232
|
+
c[t] = r ? l(
|
|
2233
|
+
f(o[0]),
|
|
2234
|
+
f(o[1]),
|
|
2235
|
+
o[2]
|
|
2236
|
+
) : i;
|
|
2237
|
+
}
|
|
2238
|
+
return c;
|
|
2239
|
+
}
|
|
2240
|
+
var d = C();
|
|
2241
|
+
var y = d;
|
|
2242
|
+
|
|
2243
|
+
function _mergeNamespaces$1(n, m) {
|
|
2295
2244
|
m.forEach(function (e) {
|
|
2296
2245
|
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
|
|
2297
2246
|
if (k !== 'default' && !(k in n)) {
|
|
@@ -2513,6 +2462,10 @@ function printProps(keys, props, config, indentation, depth, refs, printer) {
|
|
|
2513
2462
|
const colors = config.colors;
|
|
2514
2463
|
return keys.map((key) => {
|
|
2515
2464
|
const value = props[key];
|
|
2465
|
+
// hidden injected value that should not be printed
|
|
2466
|
+
if (typeof value === "string" && value[0] === "_" && value.startsWith("__vitest_") && value.match(/__vitest_\d+__/)) {
|
|
2467
|
+
return "";
|
|
2468
|
+
}
|
|
2516
2469
|
let printed = printer(value, config, indentationNext, depth, refs);
|
|
2517
2470
|
if (typeof value !== "string") {
|
|
2518
2471
|
if (printed.includes("\n")) {
|
|
@@ -2527,6 +2480,12 @@ function printProps(keys, props, config, indentation, depth, refs, printer) {
|
|
|
2527
2480
|
function printChildren(children, config, indentation, depth, refs, printer) {
|
|
2528
2481
|
return children.map((child) => config.spacingOuter + indentation + (typeof child === "string" ? printText(child, config) : printer(child, config, indentation, depth, refs))).join("");
|
|
2529
2482
|
}
|
|
2483
|
+
function printShadowRoot(children, config, indentation, depth, refs, printer) {
|
|
2484
|
+
if (config.printShadowRoot === false) {
|
|
2485
|
+
return "";
|
|
2486
|
+
}
|
|
2487
|
+
return [`${config.spacingOuter + indentation}#shadow-root`, printChildren(children, config, indentation + config.indent, depth, refs, printer)].join("");
|
|
2488
|
+
}
|
|
2530
2489
|
function printText(text, config) {
|
|
2531
2490
|
const contentColor = config.colors.content;
|
|
2532
2491
|
return contentColor.open + escapeHTML(text) + contentColor.close;
|
|
@@ -2566,10 +2525,7 @@ function testNode(val) {
|
|
|
2566
2525
|
const isCustomElement = typeof tagName === "string" && tagName.includes("-") || testHasAttribute(val);
|
|
2567
2526
|
return nodeType === ELEMENT_NODE && (ELEMENT_REGEXP.test(constructorName) || isCustomElement) || nodeType === TEXT_NODE && constructorName === "Text" || nodeType === COMMENT_NODE && constructorName === "Comment" || nodeType === FRAGMENT_NODE && constructorName === "DocumentFragment";
|
|
2568
2527
|
}
|
|
2569
|
-
const test$3 = (val) =>
|
|
2570
|
-
var _val$constructor;
|
|
2571
|
-
return (val === null || val === void 0 || (_val$constructor = val.constructor) === null || _val$constructor === void 0 ? void 0 : _val$constructor.name) && testNode(val);
|
|
2572
|
-
};
|
|
2528
|
+
const test$3 = (val) => val?.constructor?.name && testNode(val);
|
|
2573
2529
|
function nodeIsText(node) {
|
|
2574
2530
|
return node.nodeType === TEXT_NODE;
|
|
2575
2531
|
}
|
|
@@ -2579,7 +2535,7 @@ function nodeIsComment(node) {
|
|
|
2579
2535
|
function nodeIsFragment(node) {
|
|
2580
2536
|
return node.nodeType === FRAGMENT_NODE;
|
|
2581
2537
|
}
|
|
2582
|
-
|
|
2538
|
+
function serializeDOM(node, config, indentation, depth, refs, printer, filterNode) {
|
|
2583
2539
|
if (nodeIsText(node)) {
|
|
2584
2540
|
return printText(node.data, config);
|
|
2585
2541
|
}
|
|
@@ -2590,11 +2546,16 @@ const serialize$3 = (node, config, indentation, depth, refs, printer) => {
|
|
|
2590
2546
|
if (++depth > config.maxDepth) {
|
|
2591
2547
|
return printElementAsLeaf(type, config);
|
|
2592
2548
|
}
|
|
2549
|
+
const children = Array.prototype.slice.call(node.childNodes || node.children);
|
|
2550
|
+
const shadowChildren = nodeIsFragment(node) || !node.shadowRoot ? [] : Array.prototype.slice.call(node.shadowRoot.children);
|
|
2551
|
+
const resolvedChildren = children;
|
|
2552
|
+
const resolvedShadowChildren = shadowChildren;
|
|
2593
2553
|
return printElement(type, printProps(nodeIsFragment(node) ? [] : Array.from(node.attributes, (attr) => attr.name).sort(), nodeIsFragment(node) ? {} : [...node.attributes].reduce((props, attribute) => {
|
|
2594
2554
|
props[attribute.name] = attribute.value;
|
|
2595
2555
|
return props;
|
|
2596
|
-
}, {}), config, indentation + config.indent, depth, refs, printer),
|
|
2597
|
-
}
|
|
2556
|
+
}, {}), config, indentation + config.indent, depth, refs, printer), (resolvedShadowChildren.length > 0 ? printShadowRoot(resolvedShadowChildren, config, indentation + config.indent, depth, refs, printer) : "") + printChildren(resolvedChildren, config, indentation + config.indent, depth, refs, printer), config, indentation);
|
|
2557
|
+
}
|
|
2558
|
+
const serialize$3 = (node, config, indentation, depth, refs, printer) => serializeDOM(node, config, indentation, depth, refs, printer);
|
|
2598
2559
|
const plugin$3 = {
|
|
2599
2560
|
serialize: serialize$3,
|
|
2600
2561
|
test: test$3
|
|
@@ -2681,8 +2642,8 @@ const plugin$2 = {
|
|
|
2681
2642
|
test: test$2
|
|
2682
2643
|
};
|
|
2683
2644
|
|
|
2684
|
-
function getDefaultExportFromCjs$1
|
|
2685
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x,
|
|
2645
|
+
function getDefaultExportFromCjs$1(x) {
|
|
2646
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
2686
2647
|
}
|
|
2687
2648
|
|
|
2688
2649
|
var reactIs$1 = {exports: {}};
|
|
@@ -2708,8 +2669,8 @@ function requireReactIs_production () {
|
|
|
2708
2669
|
REACT_PORTAL_TYPE = Symbol.for("react.portal"),
|
|
2709
2670
|
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
|
|
2710
2671
|
REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
|
|
2711
|
-
REACT_PROFILER_TYPE = Symbol.for("react.profiler")
|
|
2712
|
-
|
|
2672
|
+
REACT_PROFILER_TYPE = Symbol.for("react.profiler"),
|
|
2673
|
+
REACT_CONSUMER_TYPE = Symbol.for("react.consumer"),
|
|
2713
2674
|
REACT_CONTEXT_TYPE = Symbol.for("react.context"),
|
|
2714
2675
|
REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
|
|
2715
2676
|
REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
|
|
@@ -2825,157 +2786,14 @@ function requireReactIs_production () {
|
|
|
2825
2786
|
return reactIs_production;
|
|
2826
2787
|
}
|
|
2827
2788
|
|
|
2828
|
-
var reactIs_development$1 = {};
|
|
2829
|
-
|
|
2830
|
-
/**
|
|
2831
|
-
* @license React
|
|
2832
|
-
* react-is.development.js
|
|
2833
|
-
*
|
|
2834
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2835
|
-
*
|
|
2836
|
-
* This source code is licensed under the MIT license found in the
|
|
2837
|
-
* LICENSE file in the root directory of this source tree.
|
|
2838
|
-
*/
|
|
2839
|
-
|
|
2840
|
-
var hasRequiredReactIs_development$1;
|
|
2841
|
-
|
|
2842
|
-
function requireReactIs_development$1 () {
|
|
2843
|
-
if (hasRequiredReactIs_development$1) return reactIs_development$1;
|
|
2844
|
-
hasRequiredReactIs_development$1 = 1;
|
|
2845
|
-
"production" !== process.env.NODE_ENV &&
|
|
2846
|
-
(function () {
|
|
2847
|
-
function typeOf(object) {
|
|
2848
|
-
if ("object" === typeof object && null !== object) {
|
|
2849
|
-
var $$typeof = object.$$typeof;
|
|
2850
|
-
switch ($$typeof) {
|
|
2851
|
-
case REACT_ELEMENT_TYPE:
|
|
2852
|
-
switch (((object = object.type), object)) {
|
|
2853
|
-
case REACT_FRAGMENT_TYPE:
|
|
2854
|
-
case REACT_PROFILER_TYPE:
|
|
2855
|
-
case REACT_STRICT_MODE_TYPE:
|
|
2856
|
-
case REACT_SUSPENSE_TYPE:
|
|
2857
|
-
case REACT_SUSPENSE_LIST_TYPE:
|
|
2858
|
-
case REACT_VIEW_TRANSITION_TYPE:
|
|
2859
|
-
return object;
|
|
2860
|
-
default:
|
|
2861
|
-
switch (((object = object && object.$$typeof), object)) {
|
|
2862
|
-
case REACT_CONTEXT_TYPE:
|
|
2863
|
-
case REACT_FORWARD_REF_TYPE:
|
|
2864
|
-
case REACT_LAZY_TYPE:
|
|
2865
|
-
case REACT_MEMO_TYPE:
|
|
2866
|
-
return object;
|
|
2867
|
-
case REACT_CONSUMER_TYPE:
|
|
2868
|
-
return object;
|
|
2869
|
-
default:
|
|
2870
|
-
return $$typeof;
|
|
2871
|
-
}
|
|
2872
|
-
}
|
|
2873
|
-
case REACT_PORTAL_TYPE:
|
|
2874
|
-
return $$typeof;
|
|
2875
|
-
}
|
|
2876
|
-
}
|
|
2877
|
-
}
|
|
2878
|
-
var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
|
|
2879
|
-
REACT_PORTAL_TYPE = Symbol.for("react.portal"),
|
|
2880
|
-
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
|
|
2881
|
-
REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
|
|
2882
|
-
REACT_PROFILER_TYPE = Symbol.for("react.profiler");
|
|
2883
|
-
var REACT_CONSUMER_TYPE = Symbol.for("react.consumer"),
|
|
2884
|
-
REACT_CONTEXT_TYPE = Symbol.for("react.context"),
|
|
2885
|
-
REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
|
|
2886
|
-
REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
|
|
2887
|
-
REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"),
|
|
2888
|
-
REACT_MEMO_TYPE = Symbol.for("react.memo"),
|
|
2889
|
-
REACT_LAZY_TYPE = Symbol.for("react.lazy"),
|
|
2890
|
-
REACT_VIEW_TRANSITION_TYPE = Symbol.for("react.view_transition"),
|
|
2891
|
-
REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference");
|
|
2892
|
-
reactIs_development$1.ContextConsumer = REACT_CONSUMER_TYPE;
|
|
2893
|
-
reactIs_development$1.ContextProvider = REACT_CONTEXT_TYPE;
|
|
2894
|
-
reactIs_development$1.Element = REACT_ELEMENT_TYPE;
|
|
2895
|
-
reactIs_development$1.ForwardRef = REACT_FORWARD_REF_TYPE;
|
|
2896
|
-
reactIs_development$1.Fragment = REACT_FRAGMENT_TYPE;
|
|
2897
|
-
reactIs_development$1.Lazy = REACT_LAZY_TYPE;
|
|
2898
|
-
reactIs_development$1.Memo = REACT_MEMO_TYPE;
|
|
2899
|
-
reactIs_development$1.Portal = REACT_PORTAL_TYPE;
|
|
2900
|
-
reactIs_development$1.Profiler = REACT_PROFILER_TYPE;
|
|
2901
|
-
reactIs_development$1.StrictMode = REACT_STRICT_MODE_TYPE;
|
|
2902
|
-
reactIs_development$1.Suspense = REACT_SUSPENSE_TYPE;
|
|
2903
|
-
reactIs_development$1.SuspenseList = REACT_SUSPENSE_LIST_TYPE;
|
|
2904
|
-
reactIs_development$1.isContextConsumer = function (object) {
|
|
2905
|
-
return typeOf(object) === REACT_CONSUMER_TYPE;
|
|
2906
|
-
};
|
|
2907
|
-
reactIs_development$1.isContextProvider = function (object) {
|
|
2908
|
-
return typeOf(object) === REACT_CONTEXT_TYPE;
|
|
2909
|
-
};
|
|
2910
|
-
reactIs_development$1.isElement = function (object) {
|
|
2911
|
-
return (
|
|
2912
|
-
"object" === typeof object &&
|
|
2913
|
-
null !== object &&
|
|
2914
|
-
object.$$typeof === REACT_ELEMENT_TYPE
|
|
2915
|
-
);
|
|
2916
|
-
};
|
|
2917
|
-
reactIs_development$1.isForwardRef = function (object) {
|
|
2918
|
-
return typeOf(object) === REACT_FORWARD_REF_TYPE;
|
|
2919
|
-
};
|
|
2920
|
-
reactIs_development$1.isFragment = function (object) {
|
|
2921
|
-
return typeOf(object) === REACT_FRAGMENT_TYPE;
|
|
2922
|
-
};
|
|
2923
|
-
reactIs_development$1.isLazy = function (object) {
|
|
2924
|
-
return typeOf(object) === REACT_LAZY_TYPE;
|
|
2925
|
-
};
|
|
2926
|
-
reactIs_development$1.isMemo = function (object) {
|
|
2927
|
-
return typeOf(object) === REACT_MEMO_TYPE;
|
|
2928
|
-
};
|
|
2929
|
-
reactIs_development$1.isPortal = function (object) {
|
|
2930
|
-
return typeOf(object) === REACT_PORTAL_TYPE;
|
|
2931
|
-
};
|
|
2932
|
-
reactIs_development$1.isProfiler = function (object) {
|
|
2933
|
-
return typeOf(object) === REACT_PROFILER_TYPE;
|
|
2934
|
-
};
|
|
2935
|
-
reactIs_development$1.isStrictMode = function (object) {
|
|
2936
|
-
return typeOf(object) === REACT_STRICT_MODE_TYPE;
|
|
2937
|
-
};
|
|
2938
|
-
reactIs_development$1.isSuspense = function (object) {
|
|
2939
|
-
return typeOf(object) === REACT_SUSPENSE_TYPE;
|
|
2940
|
-
};
|
|
2941
|
-
reactIs_development$1.isSuspenseList = function (object) {
|
|
2942
|
-
return typeOf(object) === REACT_SUSPENSE_LIST_TYPE;
|
|
2943
|
-
};
|
|
2944
|
-
reactIs_development$1.isValidElementType = function (type) {
|
|
2945
|
-
return "string" === typeof type ||
|
|
2946
|
-
"function" === typeof type ||
|
|
2947
|
-
type === REACT_FRAGMENT_TYPE ||
|
|
2948
|
-
type === REACT_PROFILER_TYPE ||
|
|
2949
|
-
type === REACT_STRICT_MODE_TYPE ||
|
|
2950
|
-
type === REACT_SUSPENSE_TYPE ||
|
|
2951
|
-
type === REACT_SUSPENSE_LIST_TYPE ||
|
|
2952
|
-
("object" === typeof type &&
|
|
2953
|
-
null !== type &&
|
|
2954
|
-
(type.$$typeof === REACT_LAZY_TYPE ||
|
|
2955
|
-
type.$$typeof === REACT_MEMO_TYPE ||
|
|
2956
|
-
type.$$typeof === REACT_CONTEXT_TYPE ||
|
|
2957
|
-
type.$$typeof === REACT_CONSUMER_TYPE ||
|
|
2958
|
-
type.$$typeof === REACT_FORWARD_REF_TYPE ||
|
|
2959
|
-
type.$$typeof === REACT_CLIENT_REFERENCE ||
|
|
2960
|
-
void 0 !== type.getModuleId))
|
|
2961
|
-
? true
|
|
2962
|
-
: false;
|
|
2963
|
-
};
|
|
2964
|
-
reactIs_development$1.typeOf = typeOf;
|
|
2965
|
-
})();
|
|
2966
|
-
return reactIs_development$1;
|
|
2967
|
-
}
|
|
2968
|
-
|
|
2969
2789
|
var hasRequiredReactIs$1;
|
|
2970
2790
|
|
|
2971
2791
|
function requireReactIs$1 () {
|
|
2972
2792
|
if (hasRequiredReactIs$1) return reactIs$1.exports;
|
|
2973
2793
|
hasRequiredReactIs$1 = 1;
|
|
2974
2794
|
|
|
2975
|
-
|
|
2795
|
+
{
|
|
2976
2796
|
reactIs$1.exports = requireReactIs_production();
|
|
2977
|
-
} else {
|
|
2978
|
-
reactIs$1.exports = requireReactIs_development$1();
|
|
2979
2797
|
}
|
|
2980
2798
|
return reactIs$1.exports;
|
|
2981
2799
|
}
|
|
@@ -2983,7 +2801,7 @@ function requireReactIs$1 () {
|
|
|
2983
2801
|
var reactIsExports$1 = requireReactIs$1();
|
|
2984
2802
|
var index$1 = /*@__PURE__*/getDefaultExportFromCjs$1(reactIsExports$1);
|
|
2985
2803
|
|
|
2986
|
-
var ReactIs19 = /*#__PURE__*/_mergeNamespaces({
|
|
2804
|
+
var ReactIs19 = /*#__PURE__*/_mergeNamespaces$1({
|
|
2987
2805
|
__proto__: null,
|
|
2988
2806
|
default: index$1
|
|
2989
2807
|
}, [reactIsExports$1]);
|
|
@@ -3015,245 +2833,14 @@ var b=Symbol.for("react.element"),c=Symbol.for("react.portal"),d=Symbol.for("rea
|
|
|
3015
2833
|
return reactIs_production_min;
|
|
3016
2834
|
}
|
|
3017
2835
|
|
|
3018
|
-
var reactIs_development = {};
|
|
3019
|
-
|
|
3020
|
-
/**
|
|
3021
|
-
* @license React
|
|
3022
|
-
* react-is.development.js
|
|
3023
|
-
*
|
|
3024
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3025
|
-
*
|
|
3026
|
-
* This source code is licensed under the MIT license found in the
|
|
3027
|
-
* LICENSE file in the root directory of this source tree.
|
|
3028
|
-
*/
|
|
3029
|
-
|
|
3030
|
-
var hasRequiredReactIs_development;
|
|
3031
|
-
|
|
3032
|
-
function requireReactIs_development () {
|
|
3033
|
-
if (hasRequiredReactIs_development) return reactIs_development;
|
|
3034
|
-
hasRequiredReactIs_development = 1;
|
|
3035
|
-
|
|
3036
|
-
if (process.env.NODE_ENV !== "production") {
|
|
3037
|
-
(function() {
|
|
3038
|
-
|
|
3039
|
-
// ATTENTION
|
|
3040
|
-
// When adding new symbols to this file,
|
|
3041
|
-
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
|
|
3042
|
-
// The Symbol used to tag the ReactElement-like types.
|
|
3043
|
-
var REACT_ELEMENT_TYPE = Symbol.for('react.element');
|
|
3044
|
-
var REACT_PORTAL_TYPE = Symbol.for('react.portal');
|
|
3045
|
-
var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
|
|
3046
|
-
var REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');
|
|
3047
|
-
var REACT_PROFILER_TYPE = Symbol.for('react.profiler');
|
|
3048
|
-
var REACT_PROVIDER_TYPE = Symbol.for('react.provider');
|
|
3049
|
-
var REACT_CONTEXT_TYPE = Symbol.for('react.context');
|
|
3050
|
-
var REACT_SERVER_CONTEXT_TYPE = Symbol.for('react.server_context');
|
|
3051
|
-
var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
|
|
3052
|
-
var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
|
|
3053
|
-
var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
|
|
3054
|
-
var REACT_MEMO_TYPE = Symbol.for('react.memo');
|
|
3055
|
-
var REACT_LAZY_TYPE = Symbol.for('react.lazy');
|
|
3056
|
-
var REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen');
|
|
3057
|
-
|
|
3058
|
-
// -----------------------------------------------------------------------------
|
|
3059
|
-
|
|
3060
|
-
var enableScopeAPI = false; // Experimental Create Event Handle API.
|
|
3061
|
-
var enableCacheElement = false;
|
|
3062
|
-
var enableTransitionTracing = false; // No known bugs, but needs performance testing
|
|
3063
|
-
|
|
3064
|
-
var enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber
|
|
3065
|
-
// stuff. Intended to enable React core members to more easily debug scheduling
|
|
3066
|
-
// issues in DEV builds.
|
|
3067
|
-
|
|
3068
|
-
var enableDebugTracing = false; // Track which Fiber(s) schedule render work.
|
|
3069
|
-
|
|
3070
|
-
var REACT_MODULE_REFERENCE;
|
|
3071
|
-
|
|
3072
|
-
{
|
|
3073
|
-
REACT_MODULE_REFERENCE = Symbol.for('react.module.reference');
|
|
3074
|
-
}
|
|
3075
|
-
|
|
3076
|
-
function isValidElementType(type) {
|
|
3077
|
-
if (typeof type === 'string' || typeof type === 'function') {
|
|
3078
|
-
return true;
|
|
3079
|
-
} // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing ) {
|
|
3083
|
-
return true;
|
|
3084
|
-
}
|
|
3085
|
-
|
|
3086
|
-
if (typeof type === 'object' && type !== null) {
|
|
3087
|
-
if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object
|
|
3088
|
-
// types supported by any Flight configuration anywhere since
|
|
3089
|
-
// we don't know which Flight build this will end up being used
|
|
3090
|
-
// with.
|
|
3091
|
-
type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== undefined) {
|
|
3092
|
-
return true;
|
|
3093
|
-
}
|
|
3094
|
-
}
|
|
3095
|
-
|
|
3096
|
-
return false;
|
|
3097
|
-
}
|
|
3098
|
-
|
|
3099
|
-
function typeOf(object) {
|
|
3100
|
-
if (typeof object === 'object' && object !== null) {
|
|
3101
|
-
var $$typeof = object.$$typeof;
|
|
3102
|
-
|
|
3103
|
-
switch ($$typeof) {
|
|
3104
|
-
case REACT_ELEMENT_TYPE:
|
|
3105
|
-
var type = object.type;
|
|
3106
|
-
|
|
3107
|
-
switch (type) {
|
|
3108
|
-
case REACT_FRAGMENT_TYPE:
|
|
3109
|
-
case REACT_PROFILER_TYPE:
|
|
3110
|
-
case REACT_STRICT_MODE_TYPE:
|
|
3111
|
-
case REACT_SUSPENSE_TYPE:
|
|
3112
|
-
case REACT_SUSPENSE_LIST_TYPE:
|
|
3113
|
-
return type;
|
|
3114
|
-
|
|
3115
|
-
default:
|
|
3116
|
-
var $$typeofType = type && type.$$typeof;
|
|
3117
|
-
|
|
3118
|
-
switch ($$typeofType) {
|
|
3119
|
-
case REACT_SERVER_CONTEXT_TYPE:
|
|
3120
|
-
case REACT_CONTEXT_TYPE:
|
|
3121
|
-
case REACT_FORWARD_REF_TYPE:
|
|
3122
|
-
case REACT_LAZY_TYPE:
|
|
3123
|
-
case REACT_MEMO_TYPE:
|
|
3124
|
-
case REACT_PROVIDER_TYPE:
|
|
3125
|
-
return $$typeofType;
|
|
3126
|
-
|
|
3127
|
-
default:
|
|
3128
|
-
return $$typeof;
|
|
3129
|
-
}
|
|
3130
|
-
|
|
3131
|
-
}
|
|
3132
|
-
|
|
3133
|
-
case REACT_PORTAL_TYPE:
|
|
3134
|
-
return $$typeof;
|
|
3135
|
-
}
|
|
3136
|
-
}
|
|
3137
|
-
|
|
3138
|
-
return undefined;
|
|
3139
|
-
}
|
|
3140
|
-
var ContextConsumer = REACT_CONTEXT_TYPE;
|
|
3141
|
-
var ContextProvider = REACT_PROVIDER_TYPE;
|
|
3142
|
-
var Element = REACT_ELEMENT_TYPE;
|
|
3143
|
-
var ForwardRef = REACT_FORWARD_REF_TYPE;
|
|
3144
|
-
var Fragment = REACT_FRAGMENT_TYPE;
|
|
3145
|
-
var Lazy = REACT_LAZY_TYPE;
|
|
3146
|
-
var Memo = REACT_MEMO_TYPE;
|
|
3147
|
-
var Portal = REACT_PORTAL_TYPE;
|
|
3148
|
-
var Profiler = REACT_PROFILER_TYPE;
|
|
3149
|
-
var StrictMode = REACT_STRICT_MODE_TYPE;
|
|
3150
|
-
var Suspense = REACT_SUSPENSE_TYPE;
|
|
3151
|
-
var SuspenseList = REACT_SUSPENSE_LIST_TYPE;
|
|
3152
|
-
var hasWarnedAboutDeprecatedIsAsyncMode = false;
|
|
3153
|
-
var hasWarnedAboutDeprecatedIsConcurrentMode = false; // AsyncMode should be deprecated
|
|
3154
|
-
|
|
3155
|
-
function isAsyncMode(object) {
|
|
3156
|
-
{
|
|
3157
|
-
if (!hasWarnedAboutDeprecatedIsAsyncMode) {
|
|
3158
|
-
hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
|
|
3159
|
-
|
|
3160
|
-
console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 18+.');
|
|
3161
|
-
}
|
|
3162
|
-
}
|
|
3163
|
-
|
|
3164
|
-
return false;
|
|
3165
|
-
}
|
|
3166
|
-
function isConcurrentMode(object) {
|
|
3167
|
-
{
|
|
3168
|
-
if (!hasWarnedAboutDeprecatedIsConcurrentMode) {
|
|
3169
|
-
hasWarnedAboutDeprecatedIsConcurrentMode = true; // Using console['warn'] to evade Babel and ESLint
|
|
3170
|
-
|
|
3171
|
-
console['warn']('The ReactIs.isConcurrentMode() alias has been deprecated, ' + 'and will be removed in React 18+.');
|
|
3172
|
-
}
|
|
3173
|
-
}
|
|
3174
|
-
|
|
3175
|
-
return false;
|
|
3176
|
-
}
|
|
3177
|
-
function isContextConsumer(object) {
|
|
3178
|
-
return typeOf(object) === REACT_CONTEXT_TYPE;
|
|
3179
|
-
}
|
|
3180
|
-
function isContextProvider(object) {
|
|
3181
|
-
return typeOf(object) === REACT_PROVIDER_TYPE;
|
|
3182
|
-
}
|
|
3183
|
-
function isElement(object) {
|
|
3184
|
-
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
3185
|
-
}
|
|
3186
|
-
function isForwardRef(object) {
|
|
3187
|
-
return typeOf(object) === REACT_FORWARD_REF_TYPE;
|
|
3188
|
-
}
|
|
3189
|
-
function isFragment(object) {
|
|
3190
|
-
return typeOf(object) === REACT_FRAGMENT_TYPE;
|
|
3191
|
-
}
|
|
3192
|
-
function isLazy(object) {
|
|
3193
|
-
return typeOf(object) === REACT_LAZY_TYPE;
|
|
3194
|
-
}
|
|
3195
|
-
function isMemo(object) {
|
|
3196
|
-
return typeOf(object) === REACT_MEMO_TYPE;
|
|
3197
|
-
}
|
|
3198
|
-
function isPortal(object) {
|
|
3199
|
-
return typeOf(object) === REACT_PORTAL_TYPE;
|
|
3200
|
-
}
|
|
3201
|
-
function isProfiler(object) {
|
|
3202
|
-
return typeOf(object) === REACT_PROFILER_TYPE;
|
|
3203
|
-
}
|
|
3204
|
-
function isStrictMode(object) {
|
|
3205
|
-
return typeOf(object) === REACT_STRICT_MODE_TYPE;
|
|
3206
|
-
}
|
|
3207
|
-
function isSuspense(object) {
|
|
3208
|
-
return typeOf(object) === REACT_SUSPENSE_TYPE;
|
|
3209
|
-
}
|
|
3210
|
-
function isSuspenseList(object) {
|
|
3211
|
-
return typeOf(object) === REACT_SUSPENSE_LIST_TYPE;
|
|
3212
|
-
}
|
|
3213
|
-
|
|
3214
|
-
reactIs_development.ContextConsumer = ContextConsumer;
|
|
3215
|
-
reactIs_development.ContextProvider = ContextProvider;
|
|
3216
|
-
reactIs_development.Element = Element;
|
|
3217
|
-
reactIs_development.ForwardRef = ForwardRef;
|
|
3218
|
-
reactIs_development.Fragment = Fragment;
|
|
3219
|
-
reactIs_development.Lazy = Lazy;
|
|
3220
|
-
reactIs_development.Memo = Memo;
|
|
3221
|
-
reactIs_development.Portal = Portal;
|
|
3222
|
-
reactIs_development.Profiler = Profiler;
|
|
3223
|
-
reactIs_development.StrictMode = StrictMode;
|
|
3224
|
-
reactIs_development.Suspense = Suspense;
|
|
3225
|
-
reactIs_development.SuspenseList = SuspenseList;
|
|
3226
|
-
reactIs_development.isAsyncMode = isAsyncMode;
|
|
3227
|
-
reactIs_development.isConcurrentMode = isConcurrentMode;
|
|
3228
|
-
reactIs_development.isContextConsumer = isContextConsumer;
|
|
3229
|
-
reactIs_development.isContextProvider = isContextProvider;
|
|
3230
|
-
reactIs_development.isElement = isElement;
|
|
3231
|
-
reactIs_development.isForwardRef = isForwardRef;
|
|
3232
|
-
reactIs_development.isFragment = isFragment;
|
|
3233
|
-
reactIs_development.isLazy = isLazy;
|
|
3234
|
-
reactIs_development.isMemo = isMemo;
|
|
3235
|
-
reactIs_development.isPortal = isPortal;
|
|
3236
|
-
reactIs_development.isProfiler = isProfiler;
|
|
3237
|
-
reactIs_development.isStrictMode = isStrictMode;
|
|
3238
|
-
reactIs_development.isSuspense = isSuspense;
|
|
3239
|
-
reactIs_development.isSuspenseList = isSuspenseList;
|
|
3240
|
-
reactIs_development.isValidElementType = isValidElementType;
|
|
3241
|
-
reactIs_development.typeOf = typeOf;
|
|
3242
|
-
})();
|
|
3243
|
-
}
|
|
3244
|
-
return reactIs_development;
|
|
3245
|
-
}
|
|
3246
|
-
|
|
3247
2836
|
var hasRequiredReactIs;
|
|
3248
2837
|
|
|
3249
2838
|
function requireReactIs () {
|
|
3250
2839
|
if (hasRequiredReactIs) return reactIs.exports;
|
|
3251
2840
|
hasRequiredReactIs = 1;
|
|
3252
2841
|
|
|
3253
|
-
|
|
2842
|
+
{
|
|
3254
2843
|
reactIs.exports = requireReactIs_production_min();
|
|
3255
|
-
} else {
|
|
3256
|
-
reactIs.exports = requireReactIs_development();
|
|
3257
2844
|
}
|
|
3258
2845
|
return reactIs.exports;
|
|
3259
2846
|
}
|
|
@@ -3261,7 +2848,7 @@ function requireReactIs () {
|
|
|
3261
2848
|
var reactIsExports = requireReactIs();
|
|
3262
2849
|
var index = /*@__PURE__*/getDefaultExportFromCjs$1(reactIsExports);
|
|
3263
2850
|
|
|
3264
|
-
var ReactIs18 = /*#__PURE__*/_mergeNamespaces({
|
|
2851
|
+
var ReactIs18 = /*#__PURE__*/_mergeNamespaces$1({
|
|
3265
2852
|
__proto__: null,
|
|
3266
2853
|
default: index
|
|
3267
2854
|
}, [reactIsExports]);
|
|
@@ -3504,7 +3091,7 @@ const ErrorPlugin = {
|
|
|
3504
3091
|
}
|
|
3505
3092
|
refs = [...refs, val];
|
|
3506
3093
|
const hitMaxDepth = ++depth > config.maxDepth;
|
|
3507
|
-
const { message, cause
|
|
3094
|
+
const { message, cause, ...rest } = val;
|
|
3508
3095
|
const entries = {
|
|
3509
3096
|
message,
|
|
3510
3097
|
...typeof cause !== "undefined" ? { cause } : {},
|
|
@@ -3550,15 +3137,30 @@ function findPlugin(plugins, val) {
|
|
|
3550
3137
|
return null;
|
|
3551
3138
|
}
|
|
3552
3139
|
function printer(val, config, indentation, depth, refs, hasCalledToJSON) {
|
|
3140
|
+
let result;
|
|
3553
3141
|
const plugin = findPlugin(config.plugins, val);
|
|
3554
3142
|
if (plugin !== null) {
|
|
3555
|
-
|
|
3143
|
+
result = printPlugin(plugin, val, config, indentation, depth, refs);
|
|
3144
|
+
} else {
|
|
3145
|
+
const basicResult = printBasicValue(val, config.printFunctionName, config.escapeRegex, config.escapeString);
|
|
3146
|
+
if (basicResult !== null) {
|
|
3147
|
+
result = basicResult;
|
|
3148
|
+
} else {
|
|
3149
|
+
result = printComplexValue(val, config, indentation, depth, refs, hasCalledToJSON);
|
|
3150
|
+
}
|
|
3556
3151
|
}
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3152
|
+
// Per-depth output budget (inspired by Node's util.inspect).
|
|
3153
|
+
// Each depth level tracks output independently, so nested results
|
|
3154
|
+
// don't inflate a single counter (which would undercount by ~Nx for
|
|
3155
|
+
// N levels of nesting). Nodes at the same depth produce disjoint spans
|
|
3156
|
+
// in the output string, so each bucket accurately reflects output at
|
|
3157
|
+
// that level. Total output is bounded by maxDepth × maxOutputLength.
|
|
3158
|
+
config._outputLengthPerDepth[depth] ??= 0;
|
|
3159
|
+
config._outputLengthPerDepth[depth] += result.length;
|
|
3160
|
+
if (config._outputLengthPerDepth[depth] > config.maxOutputLength) {
|
|
3161
|
+
config.maxDepth = 0;
|
|
3560
3162
|
}
|
|
3561
|
-
return
|
|
3163
|
+
return result;
|
|
3562
3164
|
}
|
|
3563
3165
|
const DEFAULT_THEME = {
|
|
3564
3166
|
comment: "gray",
|
|
@@ -3576,16 +3178,18 @@ const DEFAULT_OPTIONS = {
|
|
|
3576
3178
|
highlight: false,
|
|
3577
3179
|
indent: 2,
|
|
3578
3180
|
maxDepth: Number.POSITIVE_INFINITY,
|
|
3181
|
+
maxOutputLength: 1e6,
|
|
3579
3182
|
maxWidth: Number.POSITIVE_INFINITY,
|
|
3580
3183
|
min: false,
|
|
3581
3184
|
plugins: [],
|
|
3582
3185
|
printBasicPrototype: true,
|
|
3583
3186
|
printFunctionName: true,
|
|
3187
|
+
printShadowRoot: true,
|
|
3584
3188
|
theme: DEFAULT_THEME
|
|
3585
3189
|
};
|
|
3586
3190
|
function validateOptions(options) {
|
|
3587
3191
|
for (const key of Object.keys(options)) {
|
|
3588
|
-
if (!Object.
|
|
3192
|
+
if (!Object.hasOwn(DEFAULT_OPTIONS, key)) {
|
|
3589
3193
|
throw new Error(`pretty-format: Unknown option "${key}".`);
|
|
3590
3194
|
}
|
|
3591
3195
|
}
|
|
@@ -3596,7 +3200,7 @@ function validateOptions(options) {
|
|
|
3596
3200
|
function getColorsHighlight() {
|
|
3597
3201
|
return DEFAULT_THEME_KEYS.reduce((colors, key) => {
|
|
3598
3202
|
const value = DEFAULT_THEME[key];
|
|
3599
|
-
const color = value &&
|
|
3203
|
+
const color = value && y[value];
|
|
3600
3204
|
if (color && typeof color.close === "string" && typeof color.open === "string") {
|
|
3601
3205
|
colors[key] = color;
|
|
3602
3206
|
} else {
|
|
@@ -3615,30 +3219,33 @@ function getColorsEmpty() {
|
|
|
3615
3219
|
}, Object.create(null));
|
|
3616
3220
|
}
|
|
3617
3221
|
function getPrintFunctionName(options) {
|
|
3618
|
-
return
|
|
3222
|
+
return options?.printFunctionName ?? DEFAULT_OPTIONS.printFunctionName;
|
|
3619
3223
|
}
|
|
3620
3224
|
function getEscapeRegex(options) {
|
|
3621
|
-
return
|
|
3225
|
+
return options?.escapeRegex ?? DEFAULT_OPTIONS.escapeRegex;
|
|
3622
3226
|
}
|
|
3623
3227
|
function getEscapeString(options) {
|
|
3624
|
-
return
|
|
3228
|
+
return options?.escapeString ?? DEFAULT_OPTIONS.escapeString;
|
|
3625
3229
|
}
|
|
3626
3230
|
function getConfig(options) {
|
|
3627
3231
|
return {
|
|
3628
|
-
callToJSON:
|
|
3629
|
-
colors:
|
|
3630
|
-
compareKeys: typeof
|
|
3232
|
+
callToJSON: options?.callToJSON ?? DEFAULT_OPTIONS.callToJSON,
|
|
3233
|
+
colors: options?.highlight ? getColorsHighlight() : getColorsEmpty(),
|
|
3234
|
+
compareKeys: typeof options?.compareKeys === "function" || options?.compareKeys === null ? options.compareKeys : DEFAULT_OPTIONS.compareKeys,
|
|
3631
3235
|
escapeRegex: getEscapeRegex(options),
|
|
3632
3236
|
escapeString: getEscapeString(options),
|
|
3633
|
-
indent:
|
|
3634
|
-
maxDepth:
|
|
3635
|
-
maxWidth:
|
|
3636
|
-
min:
|
|
3637
|
-
plugins:
|
|
3638
|
-
printBasicPrototype:
|
|
3237
|
+
indent: options?.min ? "" : createIndent(options?.indent ?? DEFAULT_OPTIONS.indent),
|
|
3238
|
+
maxDepth: options?.maxDepth ?? DEFAULT_OPTIONS.maxDepth,
|
|
3239
|
+
maxWidth: options?.maxWidth ?? DEFAULT_OPTIONS.maxWidth,
|
|
3240
|
+
min: options?.min ?? DEFAULT_OPTIONS.min,
|
|
3241
|
+
plugins: options?.plugins ?? DEFAULT_OPTIONS.plugins,
|
|
3242
|
+
printBasicPrototype: options?.printBasicPrototype ?? true,
|
|
3639
3243
|
printFunctionName: getPrintFunctionName(options),
|
|
3640
|
-
|
|
3641
|
-
|
|
3244
|
+
printShadowRoot: options?.printShadowRoot ?? true,
|
|
3245
|
+
spacingInner: options?.min ? " " : "\n",
|
|
3246
|
+
spacingOuter: options?.min ? "" : "\n",
|
|
3247
|
+
maxOutputLength: options?.maxOutputLength ?? DEFAULT_OPTIONS.maxOutputLength,
|
|
3248
|
+
_outputLengthPerDepth: []
|
|
3642
3249
|
};
|
|
3643
3250
|
}
|
|
3644
3251
|
function createIndent(indent) {
|
|
@@ -3675,10 +3282,6 @@ const plugins = {
|
|
|
3675
3282
|
Error: ErrorPlugin
|
|
3676
3283
|
};
|
|
3677
3284
|
|
|
3678
|
-
function getDefaultExportFromCjs (x) {
|
|
3679
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
3680
|
-
}
|
|
3681
|
-
|
|
3682
3285
|
/**
|
|
3683
3286
|
* Diff Match and Patch
|
|
3684
3287
|
* Copyright 2018 The diff-match-patch Authors.
|
|
@@ -3743,6 +3346,10 @@ class Diff {
|
|
|
3743
3346
|
const NO_DIFF_MESSAGE = "Compared values have no visual difference.";
|
|
3744
3347
|
const SIMILAR_MESSAGE = "Compared values serialize to the same structure.\n" + "Printing internal object structure without calling `toJSON` instead.";
|
|
3745
3348
|
|
|
3349
|
+
function getDefaultExportFromCjs(x) {
|
|
3350
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
3351
|
+
}
|
|
3352
|
+
|
|
3746
3353
|
var build = {};
|
|
3747
3354
|
|
|
3748
3355
|
var hasRequiredBuild;
|
|
@@ -4550,7 +4157,7 @@ function requireBuild () {
|
|
|
4550
4157
|
return build;
|
|
4551
4158
|
}
|
|
4552
4159
|
|
|
4553
|
-
var buildExports = requireBuild();
|
|
4160
|
+
var buildExports = /*@__PURE__*/ requireBuild();
|
|
4554
4161
|
var diffSequences = /*@__PURE__*/getDefaultExportFromCjs(buildExports);
|
|
4555
4162
|
|
|
4556
4163
|
function formatTrailingSpaces(line, trailingSpaceFormatter) {
|
|
@@ -4738,14 +4345,14 @@ const DIFF_TRUNCATE_THRESHOLD_DEFAULT = 0;
|
|
|
4738
4345
|
function getDefaultOptions() {
|
|
4739
4346
|
return {
|
|
4740
4347
|
aAnnotation: "Expected",
|
|
4741
|
-
aColor:
|
|
4348
|
+
aColor: y.green,
|
|
4742
4349
|
aIndicator: "-",
|
|
4743
4350
|
bAnnotation: "Received",
|
|
4744
|
-
bColor:
|
|
4351
|
+
bColor: y.red,
|
|
4745
4352
|
bIndicator: "+",
|
|
4746
|
-
changeColor:
|
|
4353
|
+
changeColor: y.inverse,
|
|
4747
4354
|
changeLineTrailingSpaceColor: noColor,
|
|
4748
|
-
commonColor:
|
|
4355
|
+
commonColor: y.dim,
|
|
4749
4356
|
commonIndicator: " ",
|
|
4750
4357
|
commonLineTrailingSpaceColor: noColor,
|
|
4751
4358
|
compareKeys: undefined,
|
|
@@ -4754,7 +4361,7 @@ function getDefaultOptions() {
|
|
|
4754
4361
|
expand: false,
|
|
4755
4362
|
includeChangeCounts: false,
|
|
4756
4363
|
omitAnnotationLines: false,
|
|
4757
|
-
patchColor:
|
|
4364
|
+
patchColor: y.yellow,
|
|
4758
4365
|
printBasicPrototype: false,
|
|
4759
4366
|
truncateThreshold: DIFF_TRUNCATE_THRESHOLD_DEFAULT,
|
|
4760
4367
|
truncateAnnotation: "... Diff result is truncated",
|
|
@@ -4871,8 +4478,8 @@ function diffLinesUnified2(aLinesDisplay, bLinesDisplay, aLinesCompare, bLinesCo
|
|
|
4871
4478
|
}
|
|
4872
4479
|
// Compare two arrays of strings line-by-line.
|
|
4873
4480
|
function diffLinesRaw(aLines, bLines, options) {
|
|
4874
|
-
const truncate =
|
|
4875
|
-
const truncateThreshold = Math.max(Math.floor(
|
|
4481
|
+
const truncate = options?.truncateThreshold ?? false;
|
|
4482
|
+
const truncateThreshold = Math.max(Math.floor(options?.truncateThreshold ?? 0), 0);
|
|
4876
4483
|
const aLength = truncate ? Math.min(aLines.length, truncateThreshold) : aLines.length;
|
|
4877
4484
|
const bLength = truncate ? Math.min(bLines.length, truncateThreshold) : bLines.length;
|
|
4878
4485
|
const truncated = aLength !== aLines.length || bLength !== bLines.length;
|
|
@@ -4963,6 +4570,7 @@ const FALLBACK_FORMAT_OPTIONS = {
|
|
|
4963
4570
|
maxDepth: 8,
|
|
4964
4571
|
plugins: PLUGINS
|
|
4965
4572
|
};
|
|
4573
|
+
const DEFAULT_MEMORIZE = (_, v) => v;
|
|
4966
4574
|
// Generate a string that will highlight the difference between two values
|
|
4967
4575
|
// with green and red. (similar to how github does code diffing)
|
|
4968
4576
|
/**
|
|
@@ -4971,7 +4579,7 @@ const FALLBACK_FORMAT_OPTIONS = {
|
|
|
4971
4579
|
* @param options Diff options
|
|
4972
4580
|
* @returns {string | null} a string diff
|
|
4973
4581
|
*/
|
|
4974
|
-
function diff(a, b, options) {
|
|
4582
|
+
function diff(a, b, options, memorize = DEFAULT_MEMORIZE) {
|
|
4975
4583
|
if (Object.is(a, b)) {
|
|
4976
4584
|
return "";
|
|
4977
4585
|
}
|
|
@@ -5005,10 +4613,10 @@ function diff(a, b, options) {
|
|
|
5005
4613
|
function truncate(s) {
|
|
5006
4614
|
return s.length <= MAX_LENGTH ? s : `${s.slice(0, MAX_LENGTH)}...`;
|
|
5007
4615
|
}
|
|
5008
|
-
aDisplay = truncate(aDisplay);
|
|
5009
|
-
bDisplay = truncate(bDisplay);
|
|
5010
|
-
const aDiff = `${aColor(`${aIndicator} ${aAnnotation}:`)}
|
|
5011
|
-
const bDiff = `${bColor(`${bIndicator} ${bAnnotation}:`)}
|
|
4616
|
+
aDisplay = memorize("expected", truncate(aDisplay));
|
|
4617
|
+
bDisplay = memorize("actual", truncate(bDisplay));
|
|
4618
|
+
const aDiff = `${aColor(`${aIndicator} ${aAnnotation}:`)}\n${aDisplay}`;
|
|
4619
|
+
const bDiff = `${bColor(`${bIndicator} ${bAnnotation}:`)}\n${bDisplay}`;
|
|
5012
4620
|
return `${aDiff}\n\n${bDiff}`;
|
|
5013
4621
|
}
|
|
5014
4622
|
if (omitDifference) {
|
|
@@ -5017,15 +4625,15 @@ function diff(a, b, options) {
|
|
|
5017
4625
|
switch (aType) {
|
|
5018
4626
|
case "string": return diffLinesUnified(a.split("\n"), b.split("\n"), options);
|
|
5019
4627
|
case "boolean":
|
|
5020
|
-
case "number": return comparePrimitive(a, b, options);
|
|
5021
|
-
case "map": return compareObjects(sortMap(a), sortMap(b), options);
|
|
5022
|
-
case "set": return compareObjects(sortSet(a), sortSet(b), options);
|
|
5023
|
-
default: return compareObjects(a, b, options);
|
|
4628
|
+
case "number": return comparePrimitive(a, b, options, memorize);
|
|
4629
|
+
case "map": return compareObjects(sortMap(a), sortMap(b), options, memorize);
|
|
4630
|
+
case "set": return compareObjects(sortSet(a), sortSet(b), options, memorize);
|
|
4631
|
+
default: return compareObjects(a, b, options, memorize);
|
|
5024
4632
|
}
|
|
5025
4633
|
}
|
|
5026
|
-
function comparePrimitive(a, b, options) {
|
|
5027
|
-
const aFormat = format(a, FORMAT_OPTIONS);
|
|
5028
|
-
const bFormat = format(b, FORMAT_OPTIONS);
|
|
4634
|
+
function comparePrimitive(a, b, options, memorize = DEFAULT_MEMORIZE) {
|
|
4635
|
+
const aFormat = memorize("expected", format(a, FORMAT_OPTIONS));
|
|
4636
|
+
const bFormat = memorize("actual", format(b, FORMAT_OPTIONS));
|
|
5029
4637
|
return aFormat === bFormat ? "" : diffLinesUnified(aFormat.split("\n"), bFormat.split("\n"), options);
|
|
5030
4638
|
}
|
|
5031
4639
|
function sortMap(map) {
|
|
@@ -5034,12 +4642,12 @@ function sortMap(map) {
|
|
|
5034
4642
|
function sortSet(set) {
|
|
5035
4643
|
return new Set(Array.from(set.values()).sort());
|
|
5036
4644
|
}
|
|
5037
|
-
function compareObjects(a, b, options) {
|
|
4645
|
+
function compareObjects(a, b, options, memorize = DEFAULT_MEMORIZE) {
|
|
5038
4646
|
let difference;
|
|
5039
4647
|
let hasThrown = false;
|
|
5040
4648
|
try {
|
|
5041
4649
|
const formatOptions = getFormatOptions(FORMAT_OPTIONS, options);
|
|
5042
|
-
difference = getObjectsDifference(a, b, formatOptions, options);
|
|
4650
|
+
difference = getObjectsDifference(a, b, formatOptions, options, memorize);
|
|
5043
4651
|
} catch {
|
|
5044
4652
|
hasThrown = true;
|
|
5045
4653
|
}
|
|
@@ -5048,7 +4656,7 @@ function compareObjects(a, b, options) {
|
|
|
5048
4656
|
// without calling `toJSON`. It's also possible that toJSON might throw.
|
|
5049
4657
|
if (difference === undefined || difference === noDiffMessage) {
|
|
5050
4658
|
const formatOptions = getFormatOptions(FALLBACK_FORMAT_OPTIONS, options);
|
|
5051
|
-
difference = getObjectsDifference(a, b, formatOptions, options);
|
|
4659
|
+
difference = getObjectsDifference(a, b, formatOptions, options, memorize);
|
|
5052
4660
|
if (difference !== noDiffMessage && !hasThrown) {
|
|
5053
4661
|
difference = `${getCommonMessage(SIMILAR_MESSAGE, options)}\n\n${difference}`;
|
|
5054
4662
|
}
|
|
@@ -5064,7 +4672,7 @@ function getFormatOptions(formatOptions, options) {
|
|
|
5064
4672
|
maxDepth: maxDepth ?? formatOptions.maxDepth
|
|
5065
4673
|
};
|
|
5066
4674
|
}
|
|
5067
|
-
function getObjectsDifference(a, b, formatOptions, options) {
|
|
4675
|
+
function getObjectsDifference(a, b, formatOptions, options, memorize = DEFAULT_MEMORIZE) {
|
|
5068
4676
|
const formatOptionsZeroIndent = {
|
|
5069
4677
|
...formatOptions,
|
|
5070
4678
|
indent: 0
|
|
@@ -5074,28 +4682,20 @@ function getObjectsDifference(a, b, formatOptions, options) {
|
|
|
5074
4682
|
if (aCompare === bCompare) {
|
|
5075
4683
|
return getCommonMessage(NO_DIFF_MESSAGE, options);
|
|
5076
4684
|
} else {
|
|
5077
|
-
const aDisplay = format(a, formatOptions);
|
|
5078
|
-
const bDisplay = format(b, formatOptions);
|
|
4685
|
+
const aDisplay = memorize("expected", format(a, formatOptions));
|
|
4686
|
+
const bDisplay = memorize("actual", format(b, formatOptions));
|
|
5079
4687
|
return diffLinesUnified2(aDisplay.split("\n"), bDisplay.split("\n"), aCompare.split("\n"), bCompare.split("\n"), options);
|
|
5080
4688
|
}
|
|
5081
4689
|
}
|
|
5082
4690
|
|
|
5083
4691
|
var __defProp = Object.defineProperty;
|
|
5084
|
-
var
|
|
4692
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5085
4693
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5086
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
5087
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
5088
|
-
};
|
|
5089
4694
|
var __export = (target, all) => {
|
|
5090
4695
|
for (var name in all)
|
|
5091
4696
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5092
4697
|
};
|
|
5093
|
-
|
|
5094
|
-
// (disabled):util
|
|
5095
|
-
var require_util = __commonJS({
|
|
5096
|
-
"(disabled):util"() {
|
|
5097
|
-
}
|
|
5098
|
-
});
|
|
4698
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5099
4699
|
|
|
5100
4700
|
// lib/chai/utils/index.js
|
|
5101
4701
|
var utils_exports = {};
|
|
@@ -5107,6 +4707,7 @@ __export(utils_exports, {
|
|
|
5107
4707
|
checkError: () => check_error_exports,
|
|
5108
4708
|
compareByInspect: () => compareByInspect,
|
|
5109
4709
|
eql: () => deep_eql_default,
|
|
4710
|
+
events: () => events,
|
|
5110
4711
|
expectTypes: () => expectTypes,
|
|
5111
4712
|
flag: () => flag,
|
|
5112
4713
|
getActual: () => getActual,
|
|
@@ -5234,19 +4835,10 @@ __name(type, "type");
|
|
|
5234
4835
|
|
|
5235
4836
|
// node_modules/assertion-error/index.js
|
|
5236
4837
|
var canElideFrames = "captureStackTrace" in Error;
|
|
5237
|
-
var
|
|
5238
|
-
static {
|
|
5239
|
-
__name(this, "AssertionError");
|
|
5240
|
-
}
|
|
5241
|
-
message;
|
|
5242
|
-
get name() {
|
|
5243
|
-
return "AssertionError";
|
|
5244
|
-
}
|
|
5245
|
-
get ok() {
|
|
5246
|
-
return false;
|
|
5247
|
-
}
|
|
4838
|
+
var _AssertionError = class _AssertionError extends Error {
|
|
5248
4839
|
constructor(message = "Unspecified AssertionError", props, ssf) {
|
|
5249
4840
|
super(message);
|
|
4841
|
+
__publicField(this, "message");
|
|
5250
4842
|
this.message = message;
|
|
5251
4843
|
if (canElideFrames) {
|
|
5252
4844
|
Error.captureStackTrace(this, ssf || _AssertionError);
|
|
@@ -5257,6 +4849,12 @@ var AssertionError = class _AssertionError extends Error {
|
|
|
5257
4849
|
}
|
|
5258
4850
|
}
|
|
5259
4851
|
}
|
|
4852
|
+
get name() {
|
|
4853
|
+
return "AssertionError";
|
|
4854
|
+
}
|
|
4855
|
+
get ok() {
|
|
4856
|
+
return false;
|
|
4857
|
+
}
|
|
5260
4858
|
toJSON(stack) {
|
|
5261
4859
|
return {
|
|
5262
4860
|
...this,
|
|
@@ -5267,6 +4865,8 @@ var AssertionError = class _AssertionError extends Error {
|
|
|
5267
4865
|
};
|
|
5268
4866
|
}
|
|
5269
4867
|
};
|
|
4868
|
+
__name(_AssertionError, "AssertionError");
|
|
4869
|
+
var AssertionError = _AssertionError;
|
|
5270
4870
|
|
|
5271
4871
|
// lib/chai/utils/expectTypes.js
|
|
5272
4872
|
function expectTypes(obj, types) {
|
|
@@ -5555,10 +5155,8 @@ function mapToEntries(map) {
|
|
|
5555
5155
|
}
|
|
5556
5156
|
__name(mapToEntries, "mapToEntries");
|
|
5557
5157
|
function inspectMap(map, options) {
|
|
5558
|
-
|
|
5559
|
-
if (size <= 0) {
|
|
5158
|
+
if (map.size === 0)
|
|
5560
5159
|
return "Map{}";
|
|
5561
|
-
}
|
|
5562
5160
|
options.truncate -= 7;
|
|
5563
5161
|
return `Map{ ${inspectList(mapToEntries(map), options, inspectMapEntry)} }`;
|
|
5564
5162
|
}
|
|
@@ -5630,9 +5228,8 @@ var escapeCharacters = {
|
|
|
5630
5228
|
"\\": "\\\\"
|
|
5631
5229
|
};
|
|
5632
5230
|
var hex = 16;
|
|
5633
|
-
var unicodeLength = 4;
|
|
5634
5231
|
function escape(char) {
|
|
5635
|
-
return escapeCharacters[char] || `\\u${`0000${char.charCodeAt(0).toString(hex)}`.slice(-
|
|
5232
|
+
return escapeCharacters[char] || `\\u${`0000${char.charCodeAt(0).toString(hex)}`.slice(-4)}`;
|
|
5636
5233
|
}
|
|
5637
5234
|
__name(escape, "escape");
|
|
5638
5235
|
function inspectString(string, options) {
|
|
@@ -5654,19 +5251,6 @@ __name(inspectSymbol, "inspectSymbol");
|
|
|
5654
5251
|
|
|
5655
5252
|
// node_modules/loupe/lib/promise.js
|
|
5656
5253
|
var getPromiseValue = /* @__PURE__ */ __name(() => "Promise{\u2026}", "getPromiseValue");
|
|
5657
|
-
try {
|
|
5658
|
-
const { getPromiseDetails, kPending, kRejected } = process.binding("util");
|
|
5659
|
-
if (Array.isArray(getPromiseDetails(Promise.resolve()))) {
|
|
5660
|
-
getPromiseValue = /* @__PURE__ */ __name((value, options) => {
|
|
5661
|
-
const [state, innerValue] = getPromiseDetails(value);
|
|
5662
|
-
if (state === kPending) {
|
|
5663
|
-
return "Promise{<pending>}";
|
|
5664
|
-
}
|
|
5665
|
-
return `Promise${state === kRejected ? "!" : ""}{${options.inspect(innerValue, options)}}`;
|
|
5666
|
-
}, "getPromiseValue");
|
|
5667
|
-
}
|
|
5668
|
-
} catch (notNode) {
|
|
5669
|
-
}
|
|
5670
5254
|
var promise_default = getPromiseValue;
|
|
5671
5255
|
|
|
5672
5256
|
// node_modules/loupe/lib/object.js
|
|
@@ -5763,10 +5347,21 @@ function inspectAttribute([key, value], options) {
|
|
|
5763
5347
|
return `${options.stylize(String(key), "yellow")}=${options.stylize(`"${value}"`, "string")}`;
|
|
5764
5348
|
}
|
|
5765
5349
|
__name(inspectAttribute, "inspectAttribute");
|
|
5766
|
-
function
|
|
5767
|
-
return inspectList(collection, options,
|
|
5350
|
+
function inspectNodeCollection(collection, options) {
|
|
5351
|
+
return inspectList(collection, options, inspectNode, "\n");
|
|
5352
|
+
}
|
|
5353
|
+
__name(inspectNodeCollection, "inspectNodeCollection");
|
|
5354
|
+
function inspectNode(node, options) {
|
|
5355
|
+
switch (node.nodeType) {
|
|
5356
|
+
case 1:
|
|
5357
|
+
return inspectHTML(node, options);
|
|
5358
|
+
case 3:
|
|
5359
|
+
return options.inspect(node.data, options);
|
|
5360
|
+
default:
|
|
5361
|
+
return options.inspect(node, options);
|
|
5362
|
+
}
|
|
5768
5363
|
}
|
|
5769
|
-
__name(
|
|
5364
|
+
__name(inspectNode, "inspectNode");
|
|
5770
5365
|
function inspectHTML(element, options) {
|
|
5771
5366
|
const properties = element.getAttributeNames();
|
|
5772
5367
|
const name = element.tagName.toLowerCase();
|
|
@@ -5781,7 +5376,7 @@ function inspectHTML(element, options) {
|
|
|
5781
5376
|
}
|
|
5782
5377
|
options.truncate -= propertyContents.length;
|
|
5783
5378
|
const truncate2 = options.truncate;
|
|
5784
|
-
let children =
|
|
5379
|
+
let children = inspectNodeCollection(element.children, options);
|
|
5785
5380
|
if (children && children.length > truncate2) {
|
|
5786
5381
|
children = `${truncator}(${element.children.length})`;
|
|
5787
5382
|
}
|
|
@@ -5791,14 +5386,8 @@ __name(inspectHTML, "inspectHTML");
|
|
|
5791
5386
|
|
|
5792
5387
|
// node_modules/loupe/lib/index.js
|
|
5793
5388
|
var symbolsSupported = typeof Symbol === "function" && typeof Symbol.for === "function";
|
|
5794
|
-
var chaiInspect = symbolsSupported ? Symbol.for("chai/inspect") : "@@chai/inspect";
|
|
5795
|
-
var nodeInspect =
|
|
5796
|
-
try {
|
|
5797
|
-
const nodeUtil = require_util();
|
|
5798
|
-
nodeInspect = nodeUtil.inspect ? nodeUtil.inspect.custom : false;
|
|
5799
|
-
} catch (noNodeInspect) {
|
|
5800
|
-
nodeInspect = false;
|
|
5801
|
-
}
|
|
5389
|
+
var chaiInspect = symbolsSupported ? /* @__PURE__ */ Symbol.for("chai/inspect") : "@@chai/inspect";
|
|
5390
|
+
var nodeInspect = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
|
|
5802
5391
|
var constructorMap = /* @__PURE__ */ new WeakMap();
|
|
5803
5392
|
var stringTagMap = {};
|
|
5804
5393
|
var baseTypesMap = {
|
|
@@ -5840,15 +5429,15 @@ var baseTypesMap = {
|
|
|
5840
5429
|
DataView: /* @__PURE__ */ __name(() => "", "DataView"),
|
|
5841
5430
|
ArrayBuffer: /* @__PURE__ */ __name(() => "", "ArrayBuffer"),
|
|
5842
5431
|
Error: inspectObject2,
|
|
5843
|
-
HTMLCollection:
|
|
5844
|
-
NodeList:
|
|
5432
|
+
HTMLCollection: inspectNodeCollection,
|
|
5433
|
+
NodeList: inspectNodeCollection
|
|
5845
5434
|
};
|
|
5846
|
-
var inspectCustom = /* @__PURE__ */ __name((value, options, type3) => {
|
|
5435
|
+
var inspectCustom = /* @__PURE__ */ __name((value, options, type3, inspectFn) => {
|
|
5847
5436
|
if (chaiInspect in value && typeof value[chaiInspect] === "function") {
|
|
5848
5437
|
return value[chaiInspect](options);
|
|
5849
5438
|
}
|
|
5850
|
-
if (nodeInspect
|
|
5851
|
-
return value[nodeInspect](options.depth, options);
|
|
5439
|
+
if (nodeInspect in value && typeof value[nodeInspect] === "function") {
|
|
5440
|
+
return value[nodeInspect](options.depth, options, inspectFn);
|
|
5852
5441
|
}
|
|
5853
5442
|
if ("inspect" in value && typeof value.inspect === "function") {
|
|
5854
5443
|
return value.inspect(options.depth, options);
|
|
@@ -5873,7 +5462,7 @@ function inspect(value, opts = {}) {
|
|
|
5873
5462
|
return baseTypesMap[type3](value, options);
|
|
5874
5463
|
}
|
|
5875
5464
|
if (customInspect && value) {
|
|
5876
|
-
const output = inspectCustom(value, options, type3);
|
|
5465
|
+
const output = inspectCustom(value, options, type3, inspect);
|
|
5877
5466
|
if (output) {
|
|
5878
5467
|
if (typeof output === "string")
|
|
5879
5468
|
return output;
|
|
@@ -6463,12 +6052,7 @@ function getPathInfo(obj, path) {
|
|
|
6463
6052
|
__name(getPathInfo, "getPathInfo");
|
|
6464
6053
|
|
|
6465
6054
|
// lib/chai/assertion.js
|
|
6466
|
-
var
|
|
6467
|
-
static {
|
|
6468
|
-
__name(this, "Assertion");
|
|
6469
|
-
}
|
|
6470
|
-
/** @type {{}} */
|
|
6471
|
-
__flags = {};
|
|
6055
|
+
var _Assertion = class _Assertion {
|
|
6472
6056
|
/**
|
|
6473
6057
|
* Creates object for chaining.
|
|
6474
6058
|
* `Assertion` objects contain metadata in the form of flags. Three flags can
|
|
@@ -6505,6 +6089,8 @@ var Assertion = class _Assertion {
|
|
|
6505
6089
|
* @param {boolean} [lockSsfi] (optional) whether or not the ssfi flag is locked
|
|
6506
6090
|
*/
|
|
6507
6091
|
constructor(obj, msg, ssfi, lockSsfi) {
|
|
6092
|
+
/** @type {{}} */
|
|
6093
|
+
__publicField(this, "__flags", {});
|
|
6508
6094
|
flag(this, "ssfi", ssfi || _Assertion);
|
|
6509
6095
|
flag(this, "lockSsfi", lockSsfi);
|
|
6510
6096
|
flag(this, "object", obj);
|
|
@@ -6640,6 +6226,20 @@ var Assertion = class _Assertion {
|
|
|
6640
6226
|
flag(this, "object", val);
|
|
6641
6227
|
}
|
|
6642
6228
|
};
|
|
6229
|
+
__name(_Assertion, "Assertion");
|
|
6230
|
+
var Assertion = _Assertion;
|
|
6231
|
+
|
|
6232
|
+
// lib/chai/utils/events.js
|
|
6233
|
+
var events = new EventTarget();
|
|
6234
|
+
var _PluginEvent = class _PluginEvent extends Event {
|
|
6235
|
+
constructor(type3, name, fn) {
|
|
6236
|
+
super(type3);
|
|
6237
|
+
this.name = String(name);
|
|
6238
|
+
this.fn = fn;
|
|
6239
|
+
}
|
|
6240
|
+
};
|
|
6241
|
+
__name(_PluginEvent, "PluginEvent");
|
|
6242
|
+
var PluginEvent = _PluginEvent;
|
|
6643
6243
|
|
|
6644
6244
|
// lib/chai/utils/isProxyEnabled.js
|
|
6645
6245
|
function isProxyEnabled() {
|
|
@@ -6664,6 +6264,7 @@ function addProperty(ctx, name, getter) {
|
|
|
6664
6264
|
}, "propertyGetter"),
|
|
6665
6265
|
configurable: true
|
|
6666
6266
|
});
|
|
6267
|
+
events.dispatchEvent(new PluginEvent("addProperty", name, getter));
|
|
6667
6268
|
}
|
|
6668
6269
|
__name(addProperty, "addProperty");
|
|
6669
6270
|
|
|
@@ -6793,6 +6394,7 @@ function addMethod(ctx, name, method) {
|
|
|
6793
6394
|
}, "methodWrapper");
|
|
6794
6395
|
addLengthGuard(methodWrapper, name, false);
|
|
6795
6396
|
ctx[name] = proxify(methodWrapper, name);
|
|
6397
|
+
events.dispatchEvent(new PluginEvent("addMethod", name, method));
|
|
6796
6398
|
}
|
|
6797
6399
|
__name(addMethod, "addMethod");
|
|
6798
6400
|
|
|
@@ -6859,6 +6461,14 @@ var excludeNames = Object.getOwnPropertyNames(testFn).filter(function(name) {
|
|
|
6859
6461
|
});
|
|
6860
6462
|
var call = Function.prototype.call;
|
|
6861
6463
|
var apply = Function.prototype.apply;
|
|
6464
|
+
var _PluginAddChainableMethodEvent = class _PluginAddChainableMethodEvent extends PluginEvent {
|
|
6465
|
+
constructor(type3, name, fn, chainingBehavior) {
|
|
6466
|
+
super(type3, name, fn);
|
|
6467
|
+
this.chainingBehavior = chainingBehavior;
|
|
6468
|
+
}
|
|
6469
|
+
};
|
|
6470
|
+
__name(_PluginAddChainableMethodEvent, "PluginAddChainableMethodEvent");
|
|
6471
|
+
var PluginAddChainableMethodEvent = _PluginAddChainableMethodEvent;
|
|
6862
6472
|
function addChainableMethod(ctx, name, method, chainingBehavior) {
|
|
6863
6473
|
if (typeof chainingBehavior !== "function") {
|
|
6864
6474
|
chainingBehavior = /* @__PURE__ */ __name(function() {
|
|
@@ -6908,6 +6518,14 @@ function addChainableMethod(ctx, name, method, chainingBehavior) {
|
|
|
6908
6518
|
}, "chainableMethodGetter"),
|
|
6909
6519
|
configurable: true
|
|
6910
6520
|
});
|
|
6521
|
+
events.dispatchEvent(
|
|
6522
|
+
new PluginAddChainableMethodEvent(
|
|
6523
|
+
"addChainableMethod",
|
|
6524
|
+
name,
|
|
6525
|
+
method,
|
|
6526
|
+
chainingBehavior
|
|
6527
|
+
)
|
|
6528
|
+
);
|
|
6911
6529
|
}
|
|
6912
6530
|
__name(addChainableMethod, "addChainableMethod");
|
|
6913
6531
|
|
|
@@ -8029,7 +7647,7 @@ function closeTo(expected, delta, msg) {
|
|
|
8029
7647
|
);
|
|
8030
7648
|
}
|
|
8031
7649
|
new Assertion(expected, flagMsg, ssfi, true).is.numeric;
|
|
8032
|
-
const abs = /* @__PURE__ */ __name((x) => x <
|
|
7650
|
+
const abs = /* @__PURE__ */ __name((x) => x < 0 ? -x : x, "abs");
|
|
8033
7651
|
const strip = /* @__PURE__ */ __name((number) => parseFloat(parseFloat(number).toPrecision(12)), "strip");
|
|
8034
7652
|
this.assert(
|
|
8035
7653
|
strip(abs(obj - expected)) <= delta,
|
|
@@ -9230,257 +8848,17 @@ function use(fn) {
|
|
|
9230
8848
|
return exports;
|
|
9231
8849
|
}
|
|
9232
8850
|
__name(use, "use");
|
|
9233
|
-
/*!
|
|
9234
|
-
* Chai - flag utility
|
|
9235
|
-
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
9236
|
-
* MIT Licensed
|
|
9237
|
-
*/
|
|
9238
|
-
/*!
|
|
9239
|
-
* Chai - test utility
|
|
9240
|
-
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
9241
|
-
* MIT Licensed
|
|
9242
|
-
*/
|
|
9243
|
-
/*!
|
|
9244
|
-
* Chai - expectTypes utility
|
|
9245
|
-
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
9246
|
-
* MIT Licensed
|
|
9247
|
-
*/
|
|
9248
|
-
/*!
|
|
9249
|
-
* Chai - getActual utility
|
|
9250
|
-
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
9251
|
-
* MIT Licensed
|
|
9252
|
-
*/
|
|
9253
|
-
/*!
|
|
9254
|
-
* Chai - message composition utility
|
|
9255
|
-
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
9256
|
-
* MIT Licensed
|
|
9257
|
-
*/
|
|
9258
|
-
/*!
|
|
9259
|
-
* Chai - transferFlags utility
|
|
9260
|
-
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
9261
|
-
* MIT Licensed
|
|
9262
|
-
*/
|
|
9263
|
-
/*!
|
|
9264
|
-
* chai
|
|
9265
|
-
* http://chaijs.com
|
|
9266
|
-
* Copyright(c) 2011-2014 Jake Luer <jake@alogicalparadox.com>
|
|
9267
|
-
* MIT Licensed
|
|
9268
|
-
*/
|
|
9269
|
-
/*!
|
|
9270
|
-
* Chai - isProxyEnabled helper
|
|
9271
|
-
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
9272
|
-
* MIT Licensed
|
|
9273
|
-
*/
|
|
9274
|
-
/*!
|
|
9275
|
-
* Chai - addProperty utility
|
|
9276
|
-
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
9277
|
-
* MIT Licensed
|
|
9278
|
-
*/
|
|
9279
|
-
/*!
|
|
9280
|
-
* Chai - addLengthGuard utility
|
|
9281
|
-
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
9282
|
-
* MIT Licensed
|
|
9283
|
-
*/
|
|
9284
|
-
/*!
|
|
9285
|
-
* Chai - getProperties utility
|
|
9286
|
-
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
9287
|
-
* MIT Licensed
|
|
9288
|
-
*/
|
|
9289
|
-
/*!
|
|
9290
|
-
* Chai - proxify utility
|
|
9291
|
-
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
9292
|
-
* MIT Licensed
|
|
9293
|
-
*/
|
|
9294
|
-
/*!
|
|
9295
|
-
* Chai - addMethod utility
|
|
9296
|
-
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
9297
|
-
* MIT Licensed
|
|
9298
|
-
*/
|
|
9299
|
-
/*!
|
|
9300
|
-
* Chai - overwriteProperty utility
|
|
9301
|
-
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
9302
|
-
* MIT Licensed
|
|
9303
|
-
*/
|
|
9304
|
-
/*!
|
|
9305
|
-
* Chai - overwriteMethod utility
|
|
9306
|
-
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
9307
|
-
* MIT Licensed
|
|
9308
|
-
*/
|
|
9309
|
-
/*!
|
|
9310
|
-
* Chai - addChainingMethod utility
|
|
9311
|
-
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
9312
|
-
* MIT Licensed
|
|
9313
|
-
*/
|
|
9314
|
-
/*!
|
|
9315
|
-
* Chai - overwriteChainableMethod utility
|
|
9316
|
-
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
9317
|
-
* MIT Licensed
|
|
9318
|
-
*/
|
|
9319
|
-
/*!
|
|
9320
|
-
* Chai - compareByInspect utility
|
|
9321
|
-
* Copyright(c) 2011-2016 Jake Luer <jake@alogicalparadox.com>
|
|
9322
|
-
* MIT Licensed
|
|
9323
|
-
*/
|
|
9324
|
-
/*!
|
|
9325
|
-
* Chai - getOwnEnumerablePropertySymbols utility
|
|
9326
|
-
* Copyright(c) 2011-2016 Jake Luer <jake@alogicalparadox.com>
|
|
9327
|
-
* MIT Licensed
|
|
9328
|
-
*/
|
|
9329
|
-
/*!
|
|
9330
|
-
* Chai - getOwnEnumerableProperties utility
|
|
9331
|
-
* Copyright(c) 2011-2016 Jake Luer <jake@alogicalparadox.com>
|
|
9332
|
-
* MIT Licensed
|
|
9333
|
-
*/
|
|
9334
|
-
/*!
|
|
9335
|
-
* Chai - isNaN utility
|
|
9336
|
-
* Copyright(c) 2012-2015 Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
|
|
9337
|
-
* MIT Licensed
|
|
9338
|
-
*/
|
|
9339
|
-
/*!
|
|
9340
|
-
* chai
|
|
9341
|
-
* Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>
|
|
9342
|
-
* MIT Licensed
|
|
9343
|
-
*/
|
|
9344
|
-
/*!
|
|
9345
|
-
* chai
|
|
9346
|
-
* Copyright(c) 2011-2014 Jake Luer <jake@alogicalparadox.com>
|
|
9347
|
-
* MIT Licensed
|
|
9348
|
-
*/
|
|
9349
|
-
/*! Bundled license information:
|
|
9350
|
-
|
|
9351
|
-
deep-eql/index.js:
|
|
9352
|
-
(*!
|
|
9353
|
-
* deep-eql
|
|
9354
|
-
* Copyright(c) 2013 Jake Luer <jake@alogicalparadox.com>
|
|
9355
|
-
* MIT Licensed
|
|
9356
|
-
*)
|
|
9357
|
-
(*!
|
|
9358
|
-
* Check to see if the MemoizeMap has recorded a result of the two operands
|
|
9359
|
-
*
|
|
9360
|
-
* @param {Mixed} leftHandOperand
|
|
9361
|
-
* @param {Mixed} rightHandOperand
|
|
9362
|
-
* @param {MemoizeMap} memoizeMap
|
|
9363
|
-
* @returns {Boolean|null} result
|
|
9364
|
-
*)
|
|
9365
|
-
(*!
|
|
9366
|
-
* Set the result of the equality into the MemoizeMap
|
|
9367
|
-
*
|
|
9368
|
-
* @param {Mixed} leftHandOperand
|
|
9369
|
-
* @param {Mixed} rightHandOperand
|
|
9370
|
-
* @param {MemoizeMap} memoizeMap
|
|
9371
|
-
* @param {Boolean} result
|
|
9372
|
-
*)
|
|
9373
|
-
(*!
|
|
9374
|
-
* Primary Export
|
|
9375
|
-
*)
|
|
9376
|
-
(*!
|
|
9377
|
-
* The main logic of the `deepEqual` function.
|
|
9378
|
-
*
|
|
9379
|
-
* @param {Mixed} leftHandOperand
|
|
9380
|
-
* @param {Mixed} rightHandOperand
|
|
9381
|
-
* @param {Object} [options] (optional) Additional options
|
|
9382
|
-
* @param {Array} [options.comparator] (optional) Override default algorithm, determining custom equality.
|
|
9383
|
-
* @param {Array} [options.memoize] (optional) Provide a custom memoization object which will cache the results of
|
|
9384
|
-
complex objects for a speed boost. By passing `false` you can disable memoization, but this will cause circular
|
|
9385
|
-
references to blow the stack.
|
|
9386
|
-
* @return {Boolean} equal match
|
|
9387
|
-
*)
|
|
9388
|
-
(*!
|
|
9389
|
-
* Compare two Regular Expressions for equality.
|
|
9390
|
-
*
|
|
9391
|
-
* @param {RegExp} leftHandOperand
|
|
9392
|
-
* @param {RegExp} rightHandOperand
|
|
9393
|
-
* @return {Boolean} result
|
|
9394
|
-
*)
|
|
9395
|
-
(*!
|
|
9396
|
-
* Compare two Sets/Maps for equality. Faster than other equality functions.
|
|
9397
|
-
*
|
|
9398
|
-
* @param {Set} leftHandOperand
|
|
9399
|
-
* @param {Set} rightHandOperand
|
|
9400
|
-
* @param {Object} [options] (Optional)
|
|
9401
|
-
* @return {Boolean} result
|
|
9402
|
-
*)
|
|
9403
|
-
(*!
|
|
9404
|
-
* Simple equality for flat iterable objects such as Arrays, TypedArrays or Node.js buffers.
|
|
9405
|
-
*
|
|
9406
|
-
* @param {Iterable} leftHandOperand
|
|
9407
|
-
* @param {Iterable} rightHandOperand
|
|
9408
|
-
* @param {Object} [options] (Optional)
|
|
9409
|
-
* @return {Boolean} result
|
|
9410
|
-
*)
|
|
9411
|
-
(*!
|
|
9412
|
-
* Simple equality for generator objects such as those returned by generator functions.
|
|
9413
|
-
*
|
|
9414
|
-
* @param {Iterable} leftHandOperand
|
|
9415
|
-
* @param {Iterable} rightHandOperand
|
|
9416
|
-
* @param {Object} [options] (Optional)
|
|
9417
|
-
* @return {Boolean} result
|
|
9418
|
-
*)
|
|
9419
|
-
(*!
|
|
9420
|
-
* Determine if the given object has an @@iterator function.
|
|
9421
|
-
*
|
|
9422
|
-
* @param {Object} target
|
|
9423
|
-
* @return {Boolean} `true` if the object has an @@iterator function.
|
|
9424
|
-
*)
|
|
9425
|
-
(*!
|
|
9426
|
-
* Gets all iterator entries from the given Object. If the Object has no @@iterator function, returns an empty array.
|
|
9427
|
-
* This will consume the iterator - which could have side effects depending on the @@iterator implementation.
|
|
9428
|
-
*
|
|
9429
|
-
* @param {Object} target
|
|
9430
|
-
* @returns {Array} an array of entries from the @@iterator function
|
|
9431
|
-
*)
|
|
9432
|
-
(*!
|
|
9433
|
-
* Gets all entries from a Generator. This will consume the generator - which could have side effects.
|
|
9434
|
-
*
|
|
9435
|
-
* @param {Generator} target
|
|
9436
|
-
* @returns {Array} an array of entries from the Generator.
|
|
9437
|
-
*)
|
|
9438
|
-
(*!
|
|
9439
|
-
* Gets all own and inherited enumerable keys from a target.
|
|
9440
|
-
*
|
|
9441
|
-
* @param {Object} target
|
|
9442
|
-
* @returns {Array} an array of own and inherited enumerable keys from the target.
|
|
9443
|
-
*)
|
|
9444
|
-
(*!
|
|
9445
|
-
* Determines if two objects have matching values, given a set of keys. Defers to deepEqual for the equality check of
|
|
9446
|
-
* each key. If any value of the given key is not equal, the function will return false (early).
|
|
9447
|
-
*
|
|
9448
|
-
* @param {Mixed} leftHandOperand
|
|
9449
|
-
* @param {Mixed} rightHandOperand
|
|
9450
|
-
* @param {Array} keys An array of keys to compare the values of leftHandOperand and rightHandOperand against
|
|
9451
|
-
* @param {Object} [options] (Optional)
|
|
9452
|
-
* @return {Boolean} result
|
|
9453
|
-
*)
|
|
9454
|
-
(*!
|
|
9455
|
-
* Recursively check the equality of two Objects. Once basic sameness has been established it will defer to `deepEqual`
|
|
9456
|
-
* for each enumerable key in the object.
|
|
9457
|
-
*
|
|
9458
|
-
* @param {Mixed} leftHandOperand
|
|
9459
|
-
* @param {Mixed} rightHandOperand
|
|
9460
|
-
* @param {Object} [options] (Optional)
|
|
9461
|
-
* @return {Boolean} result
|
|
9462
|
-
*)
|
|
9463
|
-
(*!
|
|
9464
|
-
* Returns true if the argument is a primitive.
|
|
9465
|
-
*
|
|
9466
|
-
* This intentionally returns true for all objects that can be compared by reference,
|
|
9467
|
-
* including functions and symbols.
|
|
9468
|
-
*
|
|
9469
|
-
* @param {Mixed} value
|
|
9470
|
-
* @return {Boolean} result
|
|
9471
|
-
*)
|
|
9472
|
-
*/
|
|
9473
8851
|
|
|
9474
8852
|
const MATCHERS_OBJECT = Symbol.for("matchers-object");
|
|
9475
8853
|
const JEST_MATCHERS_OBJECT = Symbol.for("$$jest-matchers-object");
|
|
9476
8854
|
const GLOBAL_EXPECT = Symbol.for("expect-global");
|
|
9477
8855
|
const ASYMMETRIC_MATCHERS_OBJECT = Symbol.for("asymmetric-matchers-object");
|
|
9478
8856
|
|
|
9479
|
-
|
|
9480
|
-
|
|
9481
|
-
|
|
9482
|
-
|
|
9483
|
-
|
|
8857
|
+
y.green;
|
|
8858
|
+
y.red;
|
|
8859
|
+
y.inverse;
|
|
8860
|
+
y.bold;
|
|
8861
|
+
y.dim;
|
|
9484
8862
|
|
|
9485
8863
|
// Extracted out of jasmine 2.5.2
|
|
9486
8864
|
function equals(a, b, customTesters, strictCheck) {
|
|
@@ -9490,24 +8868,36 @@ function equals(a, b, customTesters, strictCheck) {
|
|
|
9490
8868
|
function isAsymmetric(obj) {
|
|
9491
8869
|
return !!obj && typeof obj === "object" && "asymmetricMatch" in obj && isA("Function", obj.asymmetricMatch);
|
|
9492
8870
|
}
|
|
9493
|
-
function asymmetricMatch(a, b) {
|
|
8871
|
+
function asymmetricMatch(a, b, customTesters) {
|
|
9494
8872
|
const asymmetricA = isAsymmetric(a);
|
|
9495
8873
|
const asymmetricB = isAsymmetric(b);
|
|
9496
8874
|
if (asymmetricA && asymmetricB) {
|
|
9497
8875
|
return undefined;
|
|
9498
8876
|
}
|
|
9499
8877
|
if (asymmetricA) {
|
|
9500
|
-
return a.asymmetricMatch(b);
|
|
8878
|
+
return a.asymmetricMatch(b, customTesters);
|
|
9501
8879
|
}
|
|
9502
8880
|
if (asymmetricB) {
|
|
9503
|
-
return b.asymmetricMatch(a);
|
|
8881
|
+
return b.asymmetricMatch(a, customTesters);
|
|
8882
|
+
}
|
|
8883
|
+
}
|
|
8884
|
+
// https://github.com/jestjs/jest/blob/905bcbced3d40cdf7aadc4cdf6fb731c4bb3dbe3/packages/expect-utils/src/utils.ts#L509
|
|
8885
|
+
function isError(value) {
|
|
8886
|
+
if (typeof Error.isError === "function") {
|
|
8887
|
+
return Error.isError(value);
|
|
8888
|
+
}
|
|
8889
|
+
switch (Object.prototype.toString.call(value)) {
|
|
8890
|
+
case "[object Error]":
|
|
8891
|
+
case "[object Exception]":
|
|
8892
|
+
case "[object DOMException]": return true;
|
|
8893
|
+
default: return value instanceof Error;
|
|
9504
8894
|
}
|
|
9505
8895
|
}
|
|
9506
8896
|
// Equality function lovingly adapted from isEqual in
|
|
9507
8897
|
// [Underscore](http://underscorejs.org)
|
|
9508
8898
|
function eq(a, b, aStack, bStack, customTesters, hasKey) {
|
|
9509
8899
|
let result = true;
|
|
9510
|
-
const asymmetricResult = asymmetricMatch(a, b);
|
|
8900
|
+
const asymmetricResult = asymmetricMatch(a, b, customTesters);
|
|
9511
8901
|
if (asymmetricResult !== undefined) {
|
|
9512
8902
|
return asymmetricResult;
|
|
9513
8903
|
}
|
|
@@ -9591,7 +8981,7 @@ function eq(a, b, aStack, bStack, customTesters, hasKey) {
|
|
|
9591
8981
|
if (className === "[object Array]" && a.length !== b.length) {
|
|
9592
8982
|
return false;
|
|
9593
8983
|
}
|
|
9594
|
-
if (a
|
|
8984
|
+
if (isError(a) && isError(b)) {
|
|
9595
8985
|
try {
|
|
9596
8986
|
return isErrorEqual(a, b, aStack, bStack, customTesters, hasKey);
|
|
9597
8987
|
} finally {
|
|
@@ -9625,17 +9015,17 @@ function isErrorEqual(a, b, aStack, bStack, customTesters, hasKey) {
|
|
|
9625
9015
|
// - [[Prototype]] of objects are compared using the === operator.
|
|
9626
9016
|
// - Only enumerable "own" properties are considered.
|
|
9627
9017
|
// - Error names, messages, causes, and errors are always compared, even if these are not enumerable properties. errors is also compared.
|
|
9628
|
-
let result = Object.
|
|
9018
|
+
let result = Object.prototype.toString.call(a) === Object.prototype.toString.call(b) && a.name === b.name && a.message === b.message;
|
|
9629
9019
|
// check Error.cause asymmetrically
|
|
9630
9020
|
if (typeof b.cause !== "undefined") {
|
|
9631
|
-
result
|
|
9021
|
+
result &&= eq(a.cause, b.cause, aStack, bStack, customTesters, hasKey);
|
|
9632
9022
|
}
|
|
9633
9023
|
// AggregateError.errors
|
|
9634
9024
|
if (a instanceof AggregateError && b instanceof AggregateError) {
|
|
9635
|
-
result
|
|
9025
|
+
result &&= eq(a.errors, b.errors, aStack, bStack, customTesters, hasKey);
|
|
9636
9026
|
}
|
|
9637
9027
|
// spread to compare enumerable properties
|
|
9638
|
-
result
|
|
9028
|
+
result &&= eq({ ...a }, { ...b }, aStack, bStack, customTesters, hasKey);
|
|
9639
9029
|
return result;
|
|
9640
9030
|
}
|
|
9641
9031
|
function keys(obj, hasKey) {
|
|
@@ -9651,7 +9041,7 @@ function hasDefinedKey(obj, key) {
|
|
|
9651
9041
|
return hasKey$1(obj, key) && obj[key] !== undefined;
|
|
9652
9042
|
}
|
|
9653
9043
|
function hasKey$1(obj, key) {
|
|
9654
|
-
return Object.
|
|
9044
|
+
return Object.hasOwn(obj, key);
|
|
9655
9045
|
}
|
|
9656
9046
|
function isA(typeName, value) {
|
|
9657
9047
|
return Object.prototype.toString.apply(value) === `[object ${typeName}]`;
|
|
@@ -9660,7 +9050,7 @@ function isDomNode(obj) {
|
|
|
9660
9050
|
return obj !== null && typeof obj === "object" && "nodeType" in obj && typeof obj.nodeType === "number" && "nodeName" in obj && typeof obj.nodeName === "string" && "isEqualNode" in obj && typeof obj.isEqualNode === "function";
|
|
9661
9051
|
}
|
|
9662
9052
|
|
|
9663
|
-
if (!Object.
|
|
9053
|
+
if (!Object.hasOwn(globalThis, MATCHERS_OBJECT)) {
|
|
9664
9054
|
const globalState = new WeakMap();
|
|
9665
9055
|
const matchers = Object.create(null);
|
|
9666
9056
|
const customEqualityTesters = [];
|
|
@@ -9717,11 +9107,10 @@ function patchJsonSchema({
|
|
|
9717
9107
|
openApiSchema,
|
|
9718
9108
|
jsonOverrides
|
|
9719
9109
|
}) {
|
|
9720
|
-
var _a;
|
|
9721
9110
|
const patchedSchema = lib.parse(lib.stringify(openApiSchema));
|
|
9722
|
-
patchedSchema.components
|
|
9723
|
-
|
|
9724
|
-
patchedSchema.paths
|
|
9111
|
+
patchedSchema.components ??= {};
|
|
9112
|
+
patchedSchema.components.schemas ??= {};
|
|
9113
|
+
patchedSchema.paths ??= {};
|
|
9725
9114
|
let alreadyApliedPatches = 0;
|
|
9726
9115
|
const outdatedPatches = [];
|
|
9727
9116
|
let appliedPatches = 0;
|
|
@@ -9760,9 +9149,8 @@ ${c.cyan(
|
|
|
9760
9149
|
return patchedObject;
|
|
9761
9150
|
}
|
|
9762
9151
|
function _applyPathPatches(pathName, httpMethod, overridePatches) {
|
|
9763
|
-
|
|
9764
|
-
|
|
9765
|
-
(_b = patchedSchema.paths[pathName])[httpMethod] ?? (_b[httpMethod] = {});
|
|
9152
|
+
patchedSchema.paths[pathName] ??= {};
|
|
9153
|
+
patchedSchema.paths[pathName][httpMethod] ??= {};
|
|
9766
9154
|
patchedSchema.paths[pathName][httpMethod] = _applyPatches(
|
|
9767
9155
|
patchedSchema.paths[pathName][httpMethod],
|
|
9768
9156
|
`${pathName} ${httpMethod}`,
|
|
@@ -9771,8 +9159,7 @@ ${c.cyan(
|
|
|
9771
9159
|
);
|
|
9772
9160
|
}
|
|
9773
9161
|
function _applyComponentsPatches(pathName, overridePatches) {
|
|
9774
|
-
|
|
9775
|
-
(_a2 = patchedSchema.components.schemas)[pathName] ?? (_a2[pathName] = {});
|
|
9162
|
+
patchedSchema.components.schemas[pathName] ??= {};
|
|
9776
9163
|
patchedSchema.components.schemas[pathName] = _applyPatches(
|
|
9777
9164
|
patchedSchema.components.schemas[pathName],
|
|
9778
9165
|
pathName,
|
|
@@ -10279,9 +9666,7 @@ async function prepareFileContent({
|
|
|
10279
9666
|
*/
|
|
10280
9667
|
`;
|
|
10281
9668
|
x += sourceFile.getFullText();
|
|
10282
|
-
const formatted = await
|
|
10283
|
-
parser: "typescript"
|
|
10284
|
-
});
|
|
9669
|
+
const formatted = await formatSource(filepath, x);
|
|
10285
9670
|
sourceFile.replaceWithText(formatted);
|
|
10286
9671
|
return project;
|
|
10287
9672
|
}
|
|
@@ -10695,6 +10080,8 @@ function transformOpenApiTypes(schema) {
|
|
|
10695
10080
|
return [operationsMap, componentsMap, existingTypes, parametersMap];
|
|
10696
10081
|
}
|
|
10697
10082
|
|
|
10083
|
+
const customFieldsTypes = `type CustomFields = { [key: string]: CustomFieldValue };
|
|
10084
|
+
type CustomFieldValue = null | string | string[] | number | boolean | CustomFieldValue[] | { [key: string]: CustomFieldValue };`;
|
|
10698
10085
|
async function generate(args) {
|
|
10699
10086
|
const inputFilename = args.filename ? args.filename : `${args.apiType}ApiSchema.json`;
|
|
10700
10087
|
try {
|
|
@@ -10792,6 +10179,7 @@ async function generate(args) {
|
|
|
10792
10179
|
*/
|
|
10793
10180
|
inject: `
|
|
10794
10181
|
type GenericRecord = never | null | string | string[] | number | { [key: string]: GenericRecord };
|
|
10182
|
+
${customFieldsTypes}
|
|
10795
10183
|
`,
|
|
10796
10184
|
transform(schemaObject, metadata) {
|
|
10797
10185
|
if (!schemaObject) {
|
|
@@ -10825,7 +10213,7 @@ async function generate(args) {
|
|
|
10825
10213
|
const { translated: _, ...propertiesWithoutTranslated } = schemaObject.properties;
|
|
10826
10214
|
schemaObject.properties = propertiesWithoutTranslated;
|
|
10827
10215
|
} else {
|
|
10828
|
-
schemaObject.required
|
|
10216
|
+
schemaObject.required ??= [];
|
|
10829
10217
|
schemaObject.required.push("translated");
|
|
10830
10218
|
schemaObject.properties.translated = extendedDefu(
|
|
10831
10219
|
{
|
|
@@ -10847,21 +10235,18 @@ async function generate(args) {
|
|
|
10847
10235
|
}
|
|
10848
10236
|
});
|
|
10849
10237
|
}
|
|
10850
|
-
return runTransformations(schemaObject);
|
|
10238
|
+
return runTransformations(schemaObject, metadata);
|
|
10851
10239
|
}
|
|
10852
10240
|
});
|
|
10853
10241
|
schema = astToString(astSchema);
|
|
10242
|
+
schema = normalizeCustomFieldsTypes(schema);
|
|
10854
10243
|
schema = schema.replace(/@description /g, "");
|
|
10855
10244
|
if (args.debug) {
|
|
10856
10245
|
writeFileSync(fullOutputFilePath, schema, {
|
|
10857
10246
|
encoding: "utf-8"
|
|
10858
10247
|
});
|
|
10859
10248
|
console.log(`[DEBUG]: Debug Schema saved to ${fullOutputFilePath}`);
|
|
10860
|
-
schema = await
|
|
10861
|
-
// semi: false,
|
|
10862
|
-
parser: "typescript"
|
|
10863
|
-
// plugins: [tsParser],
|
|
10864
|
-
});
|
|
10249
|
+
schema = await formatSource(fullOutputFilePath, schema);
|
|
10865
10250
|
schema = schema.trim();
|
|
10866
10251
|
}
|
|
10867
10252
|
processedSchemaAst = transformOpenApiTypes(schema);
|
|
@@ -10883,6 +10268,7 @@ async function generate(args) {
|
|
|
10883
10268
|
`https://raw.githubusercontent.com/shopware/frontends/main/packages/api-client/api-types/${args.apiType}ApiTypes.d.ts`
|
|
10884
10269
|
);
|
|
10885
10270
|
}
|
|
10271
|
+
schema = normalizeCustomFieldsTypes(schema);
|
|
10886
10272
|
processedSchemaAst = transformSchemaTypes(schema);
|
|
10887
10273
|
}
|
|
10888
10274
|
if (typeof schema === "string") {
|
|
@@ -10941,12 +10327,24 @@ async function generate(args) {
|
|
|
10941
10327
|
process.exit(1);
|
|
10942
10328
|
}
|
|
10943
10329
|
}
|
|
10944
|
-
function runTransformations(schemaObject) {
|
|
10330
|
+
function runTransformations(schemaObject, metadata) {
|
|
10331
|
+
const constLiteralType = createConstLiteralType(schemaObject);
|
|
10332
|
+
if (constLiteralType) {
|
|
10333
|
+
return constLiteralType;
|
|
10334
|
+
}
|
|
10945
10335
|
if (schemaObject.format === "binary") {
|
|
10946
10336
|
return ts.factory.createTypeReferenceNode(
|
|
10947
10337
|
ts.factory.createIdentifier("Blob")
|
|
10948
10338
|
);
|
|
10949
10339
|
}
|
|
10340
|
+
if (isCustomFieldsSchema(metadata)) {
|
|
10341
|
+
return ts.factory.createUnionTypeNode([
|
|
10342
|
+
ts.factory.createTypeReferenceNode(
|
|
10343
|
+
ts.factory.createIdentifier("CustomFields")
|
|
10344
|
+
),
|
|
10345
|
+
ts.factory.createLiteralTypeNode(ts.factory.createNull())
|
|
10346
|
+
]);
|
|
10347
|
+
}
|
|
10950
10348
|
if (
|
|
10951
10349
|
// for object types
|
|
10952
10350
|
schemaObject.type === "object" && // without properties, items, anyOf, allOf
|
|
@@ -10958,20 +10356,85 @@ function runTransformations(schemaObject) {
|
|
|
10958
10356
|
}
|
|
10959
10357
|
return void 0;
|
|
10960
10358
|
}
|
|
10359
|
+
function createConstLiteralType(schemaObject) {
|
|
10360
|
+
if (!("const" in schemaObject)) {
|
|
10361
|
+
return void 0;
|
|
10362
|
+
}
|
|
10363
|
+
const constValue = schemaObject.const;
|
|
10364
|
+
if (hasSchemaType(schemaObject, "string")) {
|
|
10365
|
+
return ts.factory.createLiteralTypeNode(
|
|
10366
|
+
ts.factory.createStringLiteral(String(constValue))
|
|
10367
|
+
);
|
|
10368
|
+
}
|
|
10369
|
+
if (constValue === null) {
|
|
10370
|
+
return ts.factory.createLiteralTypeNode(ts.factory.createNull());
|
|
10371
|
+
}
|
|
10372
|
+
if (typeof constValue === "string") {
|
|
10373
|
+
return ts.factory.createLiteralTypeNode(
|
|
10374
|
+
ts.factory.createStringLiteral(constValue)
|
|
10375
|
+
);
|
|
10376
|
+
}
|
|
10377
|
+
if (typeof constValue === "number" && Number.isFinite(constValue)) {
|
|
10378
|
+
const numericLiteral = ts.factory.createNumericLiteral(
|
|
10379
|
+
Math.abs(constValue)
|
|
10380
|
+
);
|
|
10381
|
+
return ts.factory.createLiteralTypeNode(
|
|
10382
|
+
constValue < 0 ? ts.factory.createPrefixUnaryExpression(
|
|
10383
|
+
ts.SyntaxKind.MinusToken,
|
|
10384
|
+
numericLiteral
|
|
10385
|
+
) : numericLiteral
|
|
10386
|
+
);
|
|
10387
|
+
}
|
|
10388
|
+
if (typeof constValue === "boolean") {
|
|
10389
|
+
return ts.factory.createLiteralTypeNode(
|
|
10390
|
+
constValue ? ts.factory.createTrue() : ts.factory.createFalse()
|
|
10391
|
+
);
|
|
10392
|
+
}
|
|
10393
|
+
return void 0;
|
|
10394
|
+
}
|
|
10395
|
+
function hasSchemaType(schemaObject, type) {
|
|
10396
|
+
return Array.isArray(schemaObject.type) ? schemaObject.type.includes(type) : schemaObject.type === type;
|
|
10397
|
+
}
|
|
10398
|
+
function isCustomFieldsSchema(metadata) {
|
|
10399
|
+
const path = Array.isArray(metadata?.path) ? metadata.path.join("/") : metadata?.path;
|
|
10400
|
+
return typeof path === "string" && (path.endsWith("/customFields") || path.endsWith(".customFields") || path.includes("/properties/customFields"));
|
|
10401
|
+
}
|
|
10402
|
+
function normalizeCustomFieldsTypes(schema) {
|
|
10403
|
+
const normalizedSchema = schema.replace(
|
|
10404
|
+
/\bcustomFields\?: GenericRecord;/g,
|
|
10405
|
+
"customFields?: CustomFields | null;"
|
|
10406
|
+
).replace(
|
|
10407
|
+
/\bcustomFields\?: string;/g,
|
|
10408
|
+
"customFields?: CustomFields | null;"
|
|
10409
|
+
);
|
|
10410
|
+
if (normalizedSchema.includes("type CustomFields =")) {
|
|
10411
|
+
return normalizedSchema;
|
|
10412
|
+
}
|
|
10413
|
+
return normalizedSchema.replace(
|
|
10414
|
+
/(type GenericRecord =[\s\S]*?\{ \[key: string\]: GenericRecord \};)/,
|
|
10415
|
+
`$1
|
|
10416
|
+
${customFieldsTypes}`
|
|
10417
|
+
);
|
|
10418
|
+
}
|
|
10961
10419
|
|
|
10962
10420
|
let adminApiClient;
|
|
10963
10421
|
let storeApiClient;
|
|
10964
10422
|
function getAdminApiClient() {
|
|
10965
10423
|
if (!adminApiClient) {
|
|
10424
|
+
const credentials = process.env.SHOPWARE_ADMIN_CLIENT_SECRET ? {
|
|
10425
|
+
grant_type: "client_credentials",
|
|
10426
|
+
client_id: process.env.SHOPWARE_ADMIN_CLIENT_ID || "",
|
|
10427
|
+
client_secret: process.env.SHOPWARE_ADMIN_CLIENT_SECRET
|
|
10428
|
+
} : {
|
|
10429
|
+
grant_type: "password",
|
|
10430
|
+
client_id: "administration",
|
|
10431
|
+
scope: "write",
|
|
10432
|
+
username: process.env.SHOPWARE_ADMIN_USERNAME || "",
|
|
10433
|
+
password: process.env.SHOPWARE_ADMIN_PASSWORD || ""
|
|
10434
|
+
};
|
|
10966
10435
|
adminApiClient = createAdminAPIClient({
|
|
10967
10436
|
baseURL: `${process.env.OPENAPI_JSON_URL}/api`,
|
|
10968
|
-
credentials
|
|
10969
|
-
grant_type: "password",
|
|
10970
|
-
client_id: "administration",
|
|
10971
|
-
scopes: "write",
|
|
10972
|
-
username: process.env.SHOPWARE_ADMIN_USERNAME || "",
|
|
10973
|
-
password: process.env.SHOPWARE_ADMIN_PASSWORD || ""
|
|
10974
|
-
}
|
|
10437
|
+
credentials
|
|
10975
10438
|
});
|
|
10976
10439
|
}
|
|
10977
10440
|
return adminApiClient;
|
|
@@ -10986,6 +10449,29 @@ function getStoreApiClient() {
|
|
|
10986
10449
|
return storeApiClient;
|
|
10987
10450
|
}
|
|
10988
10451
|
|
|
10452
|
+
function validateAdminEnvVars(env) {
|
|
10453
|
+
const hasClientSecret = !!env.SHOPWARE_ADMIN_CLIENT_SECRET?.trim();
|
|
10454
|
+
const hasClientId = !!env.SHOPWARE_ADMIN_CLIENT_ID?.trim();
|
|
10455
|
+
if (hasClientSecret || hasClientId) {
|
|
10456
|
+
const missing2 = [];
|
|
10457
|
+
if (!hasClientId) {
|
|
10458
|
+
missing2.push("SHOPWARE_ADMIN_CLIENT_ID");
|
|
10459
|
+
}
|
|
10460
|
+
if (!hasClientSecret) {
|
|
10461
|
+
missing2.push("SHOPWARE_ADMIN_CLIENT_SECRET");
|
|
10462
|
+
}
|
|
10463
|
+
return missing2;
|
|
10464
|
+
}
|
|
10465
|
+
const missing = [];
|
|
10466
|
+
if (!env.SHOPWARE_ADMIN_USERNAME) {
|
|
10467
|
+
missing.push("SHOPWARE_ADMIN_USERNAME");
|
|
10468
|
+
}
|
|
10469
|
+
if (!env.SHOPWARE_ADMIN_PASSWORD) {
|
|
10470
|
+
missing.push("SHOPWARE_ADMIN_PASSWORD");
|
|
10471
|
+
}
|
|
10472
|
+
return missing;
|
|
10473
|
+
}
|
|
10474
|
+
|
|
10989
10475
|
const SCHEMA_ENDPOINT = "_info/openapi3.json";
|
|
10990
10476
|
const STORE_API_ENDPOINT = `/store-api/${SCHEMA_ENDPOINT}`;
|
|
10991
10477
|
const ADMIN_API_ENDPOINT = `/api/${SCHEMA_ENDPOINT}`;
|
|
@@ -10999,16 +10485,7 @@ async function loadSchema(args) {
|
|
|
10999
10485
|
const isAdminApi = args.apiType === "admin";
|
|
11000
10486
|
const outputFilename = args.filename ? args.filename : `${args.apiType}ApiSchema.json`;
|
|
11001
10487
|
const OPENAPI_JSON_URL = process.env.OPENAPI_JSON_URL;
|
|
11002
|
-
const
|
|
11003
|
-
if (isAdminApi) {
|
|
11004
|
-
requiredEnvVars.push("SHOPWARE_ADMIN_USERNAME");
|
|
11005
|
-
requiredEnvVars.push("SHOPWARE_ADMIN_PASSWORD");
|
|
11006
|
-
} else {
|
|
11007
|
-
requiredEnvVars.push("OPENAPI_ACCESS_KEY");
|
|
11008
|
-
}
|
|
11009
|
-
const missingEnvVars = requiredEnvVars.filter(
|
|
11010
|
-
(envVar) => !process.env[envVar]
|
|
11011
|
-
);
|
|
10488
|
+
const missingEnvVars = isAdminApi ? validateAdminEnvVars(process.env) : process.env.OPENAPI_ACCESS_KEY ? [] : ["OPENAPI_ACCESS_KEY"];
|
|
11012
10489
|
try {
|
|
11013
10490
|
if (missingEnvVars.length || !OPENAPI_JSON_URL) {
|
|
11014
10491
|
console.error(
|
|
@@ -11049,10 +10526,10 @@ Check whether the .env file is created.
|
|
|
11049
10526
|
);
|
|
11050
10527
|
apiJSON = result.data;
|
|
11051
10528
|
}
|
|
11052
|
-
const formatted = await
|
|
11053
|
-
|
|
11054
|
-
|
|
11055
|
-
|
|
10529
|
+
const formatted = await formatSource(
|
|
10530
|
+
outputFilename,
|
|
10531
|
+
JSON.stringify(apiJSON, null, 2)
|
|
10532
|
+
);
|
|
11056
10533
|
const content = formatted.trim();
|
|
11057
10534
|
const dir = args.cwd;
|
|
11058
10535
|
const apiTypesDir = join(dir, "api-types");
|
|
@@ -11146,24 +10623,29 @@ function snakeCase(str) {
|
|
|
11146
10623
|
}
|
|
11147
10624
|
|
|
11148
10625
|
const componentsApiAliasRule = (componentName, body) => {
|
|
11149
|
-
const
|
|
10626
|
+
const properEnumAliasDefinition = {
|
|
11150
10627
|
type: "string",
|
|
11151
10628
|
enum: [snakeCase(componentName)]
|
|
11152
10629
|
};
|
|
10630
|
+
const properConstAliasDefinition = {
|
|
10631
|
+
type: "string",
|
|
10632
|
+
const: snakeCase(componentName)
|
|
10633
|
+
};
|
|
11153
10634
|
const bodyValue = body?.properties?.apiAlias;
|
|
11154
10635
|
if (!bodyValue) {
|
|
11155
10636
|
return null;
|
|
11156
10637
|
}
|
|
11157
|
-
const result = equals(
|
|
10638
|
+
const result = equals(properEnumAliasDefinition, bodyValue) || equals(properConstAliasDefinition, bodyValue);
|
|
11158
10639
|
if (!result) {
|
|
11159
10640
|
let additionalMessage = "";
|
|
11160
|
-
const
|
|
11161
|
-
if (
|
|
11162
|
-
additionalMessage = `It's also possible, that the schema component name is not correct and apiApias is proper. In that case schema component name should be ${c.bold(pascalCase(
|
|
10641
|
+
const bodyLiteralValue = getStringLiteralValue(bodyValue);
|
|
10642
|
+
if (bodyLiteralValue && properEnumAliasDefinition.enum[0] !== bodyLiteralValue) {
|
|
10643
|
+
additionalMessage = `It's also possible, that the schema component name is not correct and apiApias is proper. In that case schema component name should be ${c.bold(pascalCase(bodyLiteralValue))}. Confirm proper solution with the source code.`;
|
|
11163
10644
|
}
|
|
10645
|
+
const expectedAliasDefinition = "const" in bodyValue ? properConstAliasDefinition : properEnumAliasDefinition;
|
|
11164
10646
|
return `Component ${c.bold(componentName)} has invalid ${c.bold("apiAlias")} definition. Diff:
|
|
11165
10647
|
${diff(
|
|
11166
|
-
|
|
10648
|
+
expectedAliasDefinition,
|
|
11167
10649
|
bodyValue,
|
|
11168
10650
|
{
|
|
11169
10651
|
aColor: c.green,
|
|
@@ -11177,6 +10659,17 @@ ${additionalMessage}` : ""}`;
|
|
|
11177
10659
|
}
|
|
11178
10660
|
return null;
|
|
11179
10661
|
};
|
|
10662
|
+
function getStringLiteralValue(bodyValue) {
|
|
10663
|
+
const enumValue = bodyValue?.enum?.[0];
|
|
10664
|
+
if (typeof enumValue === "string") {
|
|
10665
|
+
return enumValue;
|
|
10666
|
+
}
|
|
10667
|
+
const constValue = bodyValue?.const;
|
|
10668
|
+
if (typeof constValue === "string") {
|
|
10669
|
+
return constValue;
|
|
10670
|
+
}
|
|
10671
|
+
return void 0;
|
|
10672
|
+
}
|
|
11180
10673
|
|
|
11181
10674
|
const validationRules = {
|
|
11182
10675
|
COMPONENTS_API_ALIAS: componentsApiAliasRule
|
|
@@ -11353,4 +10846,4 @@ async function validateJson(args) {
|
|
|
11353
10846
|
}
|
|
11354
10847
|
}
|
|
11355
10848
|
|
|
11356
|
-
export { getAugmentedNamespace as a,
|
|
10849
|
+
export { getAugmentedNamespace as a, formatSource as f, generate as g, loadSchema as l, validateJson as v };
|