@shopware/api-gen 1.1.4 → 1.2.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 +26 -5
- package/dist/cli.mjs +745 -271
- package/package.json +6 -6
package/dist/cli.mjs
CHANGED
|
@@ -24,7 +24,7 @@ const __filename = __cjs_url__.fileURLToPath(import.meta.url);
|
|
|
24
24
|
const __dirname = __cjs_path__.dirname(__filename);
|
|
25
25
|
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
26
26
|
const name$1 = "@shopware/api-gen";
|
|
27
|
-
const version$2 = "1.1
|
|
27
|
+
const version$2 = "1.2.1";
|
|
28
28
|
const description$1 = "Shopware CLI for API client generation.";
|
|
29
29
|
const author = "Shopware";
|
|
30
30
|
const type$1 = "module";
|
|
@@ -66,18 +66,18 @@ const devDependencies$1 = {
|
|
|
66
66
|
"@biomejs/biome": "1.8.3",
|
|
67
67
|
"@types/prettier": "3.0.0",
|
|
68
68
|
"@types/yargs": "17.0.33",
|
|
69
|
-
"@vitest/coverage-v8": "
|
|
69
|
+
"@vitest/coverage-v8": "3.0.5",
|
|
70
70
|
json5: "2.2.3",
|
|
71
71
|
picocolors: "1.0.1",
|
|
72
72
|
tsconfig: "workspace:*",
|
|
73
73
|
unbuild: "2.0.0",
|
|
74
|
-
vitest: "
|
|
74
|
+
vitest: "3.0.5"
|
|
75
75
|
};
|
|
76
76
|
const dependencies = {
|
|
77
77
|
"@shopware/api-client": "workspace:*",
|
|
78
78
|
ofetch: "1.4.1",
|
|
79
|
-
"openapi-typescript": "7.
|
|
80
|
-
prettier: "3.
|
|
79
|
+
"openapi-typescript": "7.5.2",
|
|
80
|
+
prettier: "3.5.1",
|
|
81
81
|
"ts-morph": "24.0.0",
|
|
82
82
|
yargs: "17.7.2"
|
|
83
83
|
};
|
|
@@ -101,7 +101,7 @@ const packageJson$1 = {
|
|
|
101
101
|
|
|
102
102
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
103
103
|
|
|
104
|
-
function getDefaultExportFromCjs$
|
|
104
|
+
function getDefaultExportFromCjs$2 (x) {
|
|
105
105
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
106
106
|
}
|
|
107
107
|
|
|
@@ -197771,7 +197771,7 @@ ${e.message}`;
|
|
|
197771
197771
|
} (typescript));
|
|
197772
197772
|
|
|
197773
197773
|
var typescriptExports = typescript.exports;
|
|
197774
|
-
const ts = /*@__PURE__*/getDefaultExportFromCjs$
|
|
197774
|
+
const ts = /*@__PURE__*/getDefaultExportFromCjs$2(typescriptExports);
|
|
197775
197775
|
|
|
197776
197776
|
var main$1 = {exports: {}};
|
|
197777
197777
|
|
|
@@ -199779,118 +199779,10 @@ picocolors.exports = createColors();
|
|
|
199779
199779
|
picocolors.exports.createColors = createColors;
|
|
199780
199780
|
|
|
199781
199781
|
var picocolorsExports = picocolors.exports;
|
|
199782
|
-
const c = /*@__PURE__*/getDefaultExportFromCjs$
|
|
199783
|
-
|
|
199784
|
-
const API_GEN_CONFIG_FILENAME = "api-gen.config.json";
|
|
199785
|
-
async function loadApiGenConfig(params = {}) {
|
|
199786
|
-
try {
|
|
199787
|
-
const config = await readFileSync(API_GEN_CONFIG_FILENAME, {
|
|
199788
|
-
// TODO: use c12 library for that
|
|
199789
|
-
// name: "api-gen", // file should be "api-gen.config.json"
|
|
199790
|
-
encoding: "utf-8"
|
|
199791
|
-
});
|
|
199792
|
-
return lib.parse(config);
|
|
199793
|
-
} catch (error) {
|
|
199794
|
-
if (!params.silent) {
|
|
199795
|
-
console.error(
|
|
199796
|
-
c.red(
|
|
199797
|
-
`Error while parsing config file ${API_GEN_CONFIG_FILENAME}. Check whether the file is correct JSON file.
|
|
199798
|
-
`
|
|
199799
|
-
),
|
|
199800
|
-
error
|
|
199801
|
-
);
|
|
199802
|
-
}
|
|
199803
|
-
return null;
|
|
199804
|
-
}
|
|
199805
|
-
}
|
|
199806
|
-
function isURL(str) {
|
|
199807
|
-
return str.startsWith("http");
|
|
199808
|
-
}
|
|
199809
|
-
async function loadJsonOverrides({
|
|
199810
|
-
path,
|
|
199811
|
-
apiType
|
|
199812
|
-
}) {
|
|
199813
|
-
const localPath = `./api-types/${apiType}ApiSchema.overrides.json`;
|
|
199814
|
-
const fallbackPath = existsSync(localPath) ? localPath : `https://raw.githubusercontent.com/shopware/frontends/main/packages/api-client/api-types/${apiType}ApiSchema.overrides.json`;
|
|
199815
|
-
const pathToResolve = path || fallbackPath;
|
|
199816
|
-
console.log("Loading overrides from:", pathToResolve);
|
|
199817
|
-
try {
|
|
199818
|
-
if (isURL(pathToResolve)) {
|
|
199819
|
-
const response = await ofetch(pathToResolve, {
|
|
199820
|
-
responseType: "json",
|
|
199821
|
-
parseResponse: lib.parse
|
|
199822
|
-
});
|
|
199823
|
-
return response;
|
|
199824
|
-
}
|
|
199825
|
-
const jsonOverridesFile = await readFileSync(pathToResolve, {
|
|
199826
|
-
encoding: "utf-8"
|
|
199827
|
-
});
|
|
199828
|
-
const content = lib.parse(jsonOverridesFile);
|
|
199829
|
-
return content;
|
|
199830
|
-
} catch (error) {
|
|
199831
|
-
console.warn(
|
|
199832
|
-
c.yellow(
|
|
199833
|
-
`Problem with resolving overrides "patches" at address ${pathToResolve}. Check whether you configuret it properly in your ${API_GEN_CONFIG_FILENAME}
|
|
199834
|
-
`
|
|
199835
|
-
),
|
|
199836
|
-
error
|
|
199837
|
-
);
|
|
199838
|
-
}
|
|
199839
|
-
}
|
|
199840
|
-
function displayPatchingSummary({
|
|
199841
|
-
todosToFix,
|
|
199842
|
-
outdatedPatches,
|
|
199843
|
-
alreadyApliedPatches,
|
|
199844
|
-
errors
|
|
199845
|
-
}) {
|
|
199846
|
-
if (!errors?.length && todosToFix.length) {
|
|
199847
|
-
console.log(c.yellow("Warnings to fix in the schema:"));
|
|
199848
|
-
for (const todo of todosToFix) {
|
|
199849
|
-
console.log(`${c.yellow("WARNING")}: ${todo[0]}`);
|
|
199850
|
-
console.log("Diff:\n", todo[1], "\n\n");
|
|
199851
|
-
}
|
|
199852
|
-
}
|
|
199853
|
-
if (errors?.length) {
|
|
199854
|
-
console.log(c.red("Errors found:"));
|
|
199855
|
-
for (const error of errors) {
|
|
199856
|
-
console.log(`
|
|
199857
|
-
<==== ${c.red("ERROR")}:
|
|
199858
|
-
${error}
|
|
199859
|
-
====>
|
|
199860
|
-
|
|
199861
|
-
`);
|
|
199862
|
-
}
|
|
199863
|
-
}
|
|
199864
|
-
if (outdatedPatches.length) {
|
|
199865
|
-
console.log(c.yellow("Info: Outdated patches:"));
|
|
199866
|
-
console.log(
|
|
199867
|
-
c.gray(
|
|
199868
|
-
"No action needed. Patches are already applied. You can remove them from the overrides file to clean it up."
|
|
199869
|
-
)
|
|
199870
|
-
);
|
|
199871
|
-
for (const todo of outdatedPatches) {
|
|
199872
|
-
console.log(`${todo[0]}`);
|
|
199873
|
-
console.log("Patch to remove:\n", todo[1], "\n\n");
|
|
199874
|
-
}
|
|
199875
|
-
}
|
|
199876
|
-
console.log("\n\n===== Summary =====");
|
|
199877
|
-
if (alreadyApliedPatches) {
|
|
199878
|
-
console.log(
|
|
199879
|
-
c.gray(
|
|
199880
|
-
` \u2714\uFE0F Already fixed patches: ${c.bold(alreadyApliedPatches)} They can be removed now from the overrides file.`
|
|
199881
|
-
)
|
|
199882
|
-
);
|
|
199883
|
-
}
|
|
199884
|
-
const formatColor = todosToFix.length ? c.yellow : c.green;
|
|
199885
|
-
console.log(
|
|
199886
|
-
formatColor(
|
|
199887
|
-
`We've found ${c.bold(todosToFix.length)} warning(s) in the schema.${todosToFix.length ? " Apply patches to fix them in the original schema." : ""}`
|
|
199888
|
-
)
|
|
199889
|
-
);
|
|
199890
|
-
}
|
|
199782
|
+
const c = /*@__PURE__*/getDefaultExportFromCjs$2(picocolorsExports);
|
|
199891
199783
|
|
|
199892
199784
|
// src/index.ts
|
|
199893
|
-
var f
|
|
199785
|
+
var f = {
|
|
199894
199786
|
reset: [0, 0],
|
|
199895
199787
|
bold: [1, 22, "\x1B[22m\x1B[1m"],
|
|
199896
199788
|
dim: [2, 22, "\x1B[22m\x1B[2m"],
|
|
@@ -199932,7 +199824,7 @@ var f$1 = {
|
|
|
199932
199824
|
bgMagentaBright: [105, 49],
|
|
199933
199825
|
bgCyanBright: [106, 49],
|
|
199934
199826
|
bgWhiteBright: [107, 49]
|
|
199935
|
-
}, h = Object.entries(f
|
|
199827
|
+
}, h = Object.entries(f);
|
|
199936
199828
|
function a(n) {
|
|
199937
199829
|
return String(n);
|
|
199938
199830
|
}
|
|
@@ -199967,8 +199859,22 @@ function p(n = !1) {
|
|
|
199967
199859
|
return u;
|
|
199968
199860
|
}
|
|
199969
199861
|
|
|
199970
|
-
|
|
199971
|
-
|
|
199862
|
+
var s = p();
|
|
199863
|
+
|
|
199864
|
+
function _mergeNamespaces(n, m) {
|
|
199865
|
+
m.forEach(function (e) {
|
|
199866
|
+
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
|
|
199867
|
+
if (k !== 'default' && !(k in n)) {
|
|
199868
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
199869
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
199870
|
+
enumerable: true,
|
|
199871
|
+
get: function () { return e[k]; }
|
|
199872
|
+
});
|
|
199873
|
+
}
|
|
199874
|
+
});
|
|
199875
|
+
});
|
|
199876
|
+
return Object.freeze(n);
|
|
199877
|
+
}
|
|
199972
199878
|
|
|
199973
199879
|
function getKeysOfEnumerableProperties(object, compareKeys) {
|
|
199974
199880
|
const rawKeys = Object.keys(object);
|
|
@@ -200247,7 +200153,7 @@ function testNode(val) {
|
|
|
200247
200153
|
}
|
|
200248
200154
|
const test$3 = (val) => {
|
|
200249
200155
|
var _a;
|
|
200250
|
-
return ((_a = val == null ?
|
|
200156
|
+
return ((_a = val == null ? undefined : val.constructor) == null ? undefined : _a.name) && testNode(val);
|
|
200251
200157
|
};
|
|
200252
200158
|
function nodeIsText(node) {
|
|
200253
200159
|
return node.nodeType === TEXT_NODE;
|
|
@@ -200331,7 +200237,7 @@ function getRecordEntries(val) {
|
|
|
200331
200237
|
const key = val._keys[i++];
|
|
200332
200238
|
return { done: false, value: [key, val.get(key)] };
|
|
200333
200239
|
}
|
|
200334
|
-
return { done: true, value:
|
|
200240
|
+
return { done: true, value: undefined };
|
|
200335
200241
|
}
|
|
200336
200242
|
};
|
|
200337
200243
|
}
|
|
@@ -200434,6 +200340,313 @@ const serialize$2 = (val, config, indentation, depth, refs, printer) => {
|
|
|
200434
200340
|
const test$2 = (val) => val && (val[IS_ITERABLE_SENTINEL] === true || val[IS_RECORD_SENTINEL] === true);
|
|
200435
200341
|
const plugin$2 = { serialize: serialize$2, test: test$2 };
|
|
200436
200342
|
|
|
200343
|
+
function getDefaultExportFromCjs$1 (x) {
|
|
200344
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
200345
|
+
}
|
|
200346
|
+
|
|
200347
|
+
var reactIs$1 = {exports: {}};
|
|
200348
|
+
|
|
200349
|
+
var reactIs_production = {};
|
|
200350
|
+
|
|
200351
|
+
/**
|
|
200352
|
+
* @license React
|
|
200353
|
+
* react-is.production.js
|
|
200354
|
+
*
|
|
200355
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
200356
|
+
*
|
|
200357
|
+
* This source code is licensed under the MIT license found in the
|
|
200358
|
+
* LICENSE file in the root directory of this source tree.
|
|
200359
|
+
*/
|
|
200360
|
+
|
|
200361
|
+
var hasRequiredReactIs_production;
|
|
200362
|
+
|
|
200363
|
+
function requireReactIs_production () {
|
|
200364
|
+
if (hasRequiredReactIs_production) return reactIs_production;
|
|
200365
|
+
hasRequiredReactIs_production = 1;
|
|
200366
|
+
var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
|
|
200367
|
+
REACT_PORTAL_TYPE = Symbol.for("react.portal"),
|
|
200368
|
+
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
|
|
200369
|
+
REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
|
|
200370
|
+
REACT_PROFILER_TYPE = Symbol.for("react.profiler");
|
|
200371
|
+
var REACT_CONSUMER_TYPE = Symbol.for("react.consumer"),
|
|
200372
|
+
REACT_CONTEXT_TYPE = Symbol.for("react.context"),
|
|
200373
|
+
REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
|
|
200374
|
+
REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
|
|
200375
|
+
REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"),
|
|
200376
|
+
REACT_MEMO_TYPE = Symbol.for("react.memo"),
|
|
200377
|
+
REACT_LAZY_TYPE = Symbol.for("react.lazy"),
|
|
200378
|
+
REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen"),
|
|
200379
|
+
REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference");
|
|
200380
|
+
function typeOf(object) {
|
|
200381
|
+
if ("object" === typeof object && null !== object) {
|
|
200382
|
+
var $$typeof = object.$$typeof;
|
|
200383
|
+
switch ($$typeof) {
|
|
200384
|
+
case REACT_ELEMENT_TYPE:
|
|
200385
|
+
switch (((object = object.type), object)) {
|
|
200386
|
+
case REACT_FRAGMENT_TYPE:
|
|
200387
|
+
case REACT_PROFILER_TYPE:
|
|
200388
|
+
case REACT_STRICT_MODE_TYPE:
|
|
200389
|
+
case REACT_SUSPENSE_TYPE:
|
|
200390
|
+
case REACT_SUSPENSE_LIST_TYPE:
|
|
200391
|
+
return object;
|
|
200392
|
+
default:
|
|
200393
|
+
switch (((object = object && object.$$typeof), object)) {
|
|
200394
|
+
case REACT_CONTEXT_TYPE:
|
|
200395
|
+
case REACT_FORWARD_REF_TYPE:
|
|
200396
|
+
case REACT_LAZY_TYPE:
|
|
200397
|
+
case REACT_MEMO_TYPE:
|
|
200398
|
+
return object;
|
|
200399
|
+
case REACT_CONSUMER_TYPE:
|
|
200400
|
+
return object;
|
|
200401
|
+
default:
|
|
200402
|
+
return $$typeof;
|
|
200403
|
+
}
|
|
200404
|
+
}
|
|
200405
|
+
case REACT_PORTAL_TYPE:
|
|
200406
|
+
return $$typeof;
|
|
200407
|
+
}
|
|
200408
|
+
}
|
|
200409
|
+
}
|
|
200410
|
+
reactIs_production.ContextConsumer = REACT_CONSUMER_TYPE;
|
|
200411
|
+
reactIs_production.ContextProvider = REACT_CONTEXT_TYPE;
|
|
200412
|
+
reactIs_production.Element = REACT_ELEMENT_TYPE;
|
|
200413
|
+
reactIs_production.ForwardRef = REACT_FORWARD_REF_TYPE;
|
|
200414
|
+
reactIs_production.Fragment = REACT_FRAGMENT_TYPE;
|
|
200415
|
+
reactIs_production.Lazy = REACT_LAZY_TYPE;
|
|
200416
|
+
reactIs_production.Memo = REACT_MEMO_TYPE;
|
|
200417
|
+
reactIs_production.Portal = REACT_PORTAL_TYPE;
|
|
200418
|
+
reactIs_production.Profiler = REACT_PROFILER_TYPE;
|
|
200419
|
+
reactIs_production.StrictMode = REACT_STRICT_MODE_TYPE;
|
|
200420
|
+
reactIs_production.Suspense = REACT_SUSPENSE_TYPE;
|
|
200421
|
+
reactIs_production.SuspenseList = REACT_SUSPENSE_LIST_TYPE;
|
|
200422
|
+
reactIs_production.isContextConsumer = function (object) {
|
|
200423
|
+
return typeOf(object) === REACT_CONSUMER_TYPE;
|
|
200424
|
+
};
|
|
200425
|
+
reactIs_production.isContextProvider = function (object) {
|
|
200426
|
+
return typeOf(object) === REACT_CONTEXT_TYPE;
|
|
200427
|
+
};
|
|
200428
|
+
reactIs_production.isElement = function (object) {
|
|
200429
|
+
return (
|
|
200430
|
+
"object" === typeof object &&
|
|
200431
|
+
null !== object &&
|
|
200432
|
+
object.$$typeof === REACT_ELEMENT_TYPE
|
|
200433
|
+
);
|
|
200434
|
+
};
|
|
200435
|
+
reactIs_production.isForwardRef = function (object) {
|
|
200436
|
+
return typeOf(object) === REACT_FORWARD_REF_TYPE;
|
|
200437
|
+
};
|
|
200438
|
+
reactIs_production.isFragment = function (object) {
|
|
200439
|
+
return typeOf(object) === REACT_FRAGMENT_TYPE;
|
|
200440
|
+
};
|
|
200441
|
+
reactIs_production.isLazy = function (object) {
|
|
200442
|
+
return typeOf(object) === REACT_LAZY_TYPE;
|
|
200443
|
+
};
|
|
200444
|
+
reactIs_production.isMemo = function (object) {
|
|
200445
|
+
return typeOf(object) === REACT_MEMO_TYPE;
|
|
200446
|
+
};
|
|
200447
|
+
reactIs_production.isPortal = function (object) {
|
|
200448
|
+
return typeOf(object) === REACT_PORTAL_TYPE;
|
|
200449
|
+
};
|
|
200450
|
+
reactIs_production.isProfiler = function (object) {
|
|
200451
|
+
return typeOf(object) === REACT_PROFILER_TYPE;
|
|
200452
|
+
};
|
|
200453
|
+
reactIs_production.isStrictMode = function (object) {
|
|
200454
|
+
return typeOf(object) === REACT_STRICT_MODE_TYPE;
|
|
200455
|
+
};
|
|
200456
|
+
reactIs_production.isSuspense = function (object) {
|
|
200457
|
+
return typeOf(object) === REACT_SUSPENSE_TYPE;
|
|
200458
|
+
};
|
|
200459
|
+
reactIs_production.isSuspenseList = function (object) {
|
|
200460
|
+
return typeOf(object) === REACT_SUSPENSE_LIST_TYPE;
|
|
200461
|
+
};
|
|
200462
|
+
reactIs_production.isValidElementType = function (type) {
|
|
200463
|
+
return "string" === typeof type ||
|
|
200464
|
+
"function" === typeof type ||
|
|
200465
|
+
type === REACT_FRAGMENT_TYPE ||
|
|
200466
|
+
type === REACT_PROFILER_TYPE ||
|
|
200467
|
+
type === REACT_STRICT_MODE_TYPE ||
|
|
200468
|
+
type === REACT_SUSPENSE_TYPE ||
|
|
200469
|
+
type === REACT_SUSPENSE_LIST_TYPE ||
|
|
200470
|
+
type === REACT_OFFSCREEN_TYPE ||
|
|
200471
|
+
("object" === typeof type &&
|
|
200472
|
+
null !== type &&
|
|
200473
|
+
(type.$$typeof === REACT_LAZY_TYPE ||
|
|
200474
|
+
type.$$typeof === REACT_MEMO_TYPE ||
|
|
200475
|
+
type.$$typeof === REACT_CONTEXT_TYPE ||
|
|
200476
|
+
type.$$typeof === REACT_CONSUMER_TYPE ||
|
|
200477
|
+
type.$$typeof === REACT_FORWARD_REF_TYPE ||
|
|
200478
|
+
type.$$typeof === REACT_CLIENT_REFERENCE ||
|
|
200479
|
+
undefined !== type.getModuleId))
|
|
200480
|
+
? true
|
|
200481
|
+
: false;
|
|
200482
|
+
};
|
|
200483
|
+
reactIs_production.typeOf = typeOf;
|
|
200484
|
+
return reactIs_production;
|
|
200485
|
+
}
|
|
200486
|
+
|
|
200487
|
+
var reactIs_development$1 = {};
|
|
200488
|
+
|
|
200489
|
+
/**
|
|
200490
|
+
* @license React
|
|
200491
|
+
* react-is.development.js
|
|
200492
|
+
*
|
|
200493
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
200494
|
+
*
|
|
200495
|
+
* This source code is licensed under the MIT license found in the
|
|
200496
|
+
* LICENSE file in the root directory of this source tree.
|
|
200497
|
+
*/
|
|
200498
|
+
|
|
200499
|
+
var hasRequiredReactIs_development$1;
|
|
200500
|
+
|
|
200501
|
+
function requireReactIs_development$1 () {
|
|
200502
|
+
if (hasRequiredReactIs_development$1) return reactIs_development$1;
|
|
200503
|
+
hasRequiredReactIs_development$1 = 1;
|
|
200504
|
+
"production" !== process.env.NODE_ENV &&
|
|
200505
|
+
(function () {
|
|
200506
|
+
function typeOf(object) {
|
|
200507
|
+
if ("object" === typeof object && null !== object) {
|
|
200508
|
+
var $$typeof = object.$$typeof;
|
|
200509
|
+
switch ($$typeof) {
|
|
200510
|
+
case REACT_ELEMENT_TYPE:
|
|
200511
|
+
switch (((object = object.type), object)) {
|
|
200512
|
+
case REACT_FRAGMENT_TYPE:
|
|
200513
|
+
case REACT_PROFILER_TYPE:
|
|
200514
|
+
case REACT_STRICT_MODE_TYPE:
|
|
200515
|
+
case REACT_SUSPENSE_TYPE:
|
|
200516
|
+
case REACT_SUSPENSE_LIST_TYPE:
|
|
200517
|
+
return object;
|
|
200518
|
+
default:
|
|
200519
|
+
switch (((object = object && object.$$typeof), object)) {
|
|
200520
|
+
case REACT_CONTEXT_TYPE:
|
|
200521
|
+
case REACT_FORWARD_REF_TYPE:
|
|
200522
|
+
case REACT_LAZY_TYPE:
|
|
200523
|
+
case REACT_MEMO_TYPE:
|
|
200524
|
+
return object;
|
|
200525
|
+
case REACT_CONSUMER_TYPE:
|
|
200526
|
+
return object;
|
|
200527
|
+
default:
|
|
200528
|
+
return $$typeof;
|
|
200529
|
+
}
|
|
200530
|
+
}
|
|
200531
|
+
case REACT_PORTAL_TYPE:
|
|
200532
|
+
return $$typeof;
|
|
200533
|
+
}
|
|
200534
|
+
}
|
|
200535
|
+
}
|
|
200536
|
+
var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
|
|
200537
|
+
REACT_PORTAL_TYPE = Symbol.for("react.portal"),
|
|
200538
|
+
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
|
|
200539
|
+
REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
|
|
200540
|
+
REACT_PROFILER_TYPE = Symbol.for("react.profiler");
|
|
200541
|
+
var REACT_CONSUMER_TYPE = Symbol.for("react.consumer"),
|
|
200542
|
+
REACT_CONTEXT_TYPE = Symbol.for("react.context"),
|
|
200543
|
+
REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
|
|
200544
|
+
REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
|
|
200545
|
+
REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"),
|
|
200546
|
+
REACT_MEMO_TYPE = Symbol.for("react.memo"),
|
|
200547
|
+
REACT_LAZY_TYPE = Symbol.for("react.lazy"),
|
|
200548
|
+
REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen"),
|
|
200549
|
+
REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference");
|
|
200550
|
+
reactIs_development$1.ContextConsumer = REACT_CONSUMER_TYPE;
|
|
200551
|
+
reactIs_development$1.ContextProvider = REACT_CONTEXT_TYPE;
|
|
200552
|
+
reactIs_development$1.Element = REACT_ELEMENT_TYPE;
|
|
200553
|
+
reactIs_development$1.ForwardRef = REACT_FORWARD_REF_TYPE;
|
|
200554
|
+
reactIs_development$1.Fragment = REACT_FRAGMENT_TYPE;
|
|
200555
|
+
reactIs_development$1.Lazy = REACT_LAZY_TYPE;
|
|
200556
|
+
reactIs_development$1.Memo = REACT_MEMO_TYPE;
|
|
200557
|
+
reactIs_development$1.Portal = REACT_PORTAL_TYPE;
|
|
200558
|
+
reactIs_development$1.Profiler = REACT_PROFILER_TYPE;
|
|
200559
|
+
reactIs_development$1.StrictMode = REACT_STRICT_MODE_TYPE;
|
|
200560
|
+
reactIs_development$1.Suspense = REACT_SUSPENSE_TYPE;
|
|
200561
|
+
reactIs_development$1.SuspenseList = REACT_SUSPENSE_LIST_TYPE;
|
|
200562
|
+
reactIs_development$1.isContextConsumer = function (object) {
|
|
200563
|
+
return typeOf(object) === REACT_CONSUMER_TYPE;
|
|
200564
|
+
};
|
|
200565
|
+
reactIs_development$1.isContextProvider = function (object) {
|
|
200566
|
+
return typeOf(object) === REACT_CONTEXT_TYPE;
|
|
200567
|
+
};
|
|
200568
|
+
reactIs_development$1.isElement = function (object) {
|
|
200569
|
+
return (
|
|
200570
|
+
"object" === typeof object &&
|
|
200571
|
+
null !== object &&
|
|
200572
|
+
object.$$typeof === REACT_ELEMENT_TYPE
|
|
200573
|
+
);
|
|
200574
|
+
};
|
|
200575
|
+
reactIs_development$1.isForwardRef = function (object) {
|
|
200576
|
+
return typeOf(object) === REACT_FORWARD_REF_TYPE;
|
|
200577
|
+
};
|
|
200578
|
+
reactIs_development$1.isFragment = function (object) {
|
|
200579
|
+
return typeOf(object) === REACT_FRAGMENT_TYPE;
|
|
200580
|
+
};
|
|
200581
|
+
reactIs_development$1.isLazy = function (object) {
|
|
200582
|
+
return typeOf(object) === REACT_LAZY_TYPE;
|
|
200583
|
+
};
|
|
200584
|
+
reactIs_development$1.isMemo = function (object) {
|
|
200585
|
+
return typeOf(object) === REACT_MEMO_TYPE;
|
|
200586
|
+
};
|
|
200587
|
+
reactIs_development$1.isPortal = function (object) {
|
|
200588
|
+
return typeOf(object) === REACT_PORTAL_TYPE;
|
|
200589
|
+
};
|
|
200590
|
+
reactIs_development$1.isProfiler = function (object) {
|
|
200591
|
+
return typeOf(object) === REACT_PROFILER_TYPE;
|
|
200592
|
+
};
|
|
200593
|
+
reactIs_development$1.isStrictMode = function (object) {
|
|
200594
|
+
return typeOf(object) === REACT_STRICT_MODE_TYPE;
|
|
200595
|
+
};
|
|
200596
|
+
reactIs_development$1.isSuspense = function (object) {
|
|
200597
|
+
return typeOf(object) === REACT_SUSPENSE_TYPE;
|
|
200598
|
+
};
|
|
200599
|
+
reactIs_development$1.isSuspenseList = function (object) {
|
|
200600
|
+
return typeOf(object) === REACT_SUSPENSE_LIST_TYPE;
|
|
200601
|
+
};
|
|
200602
|
+
reactIs_development$1.isValidElementType = function (type) {
|
|
200603
|
+
return "string" === typeof type ||
|
|
200604
|
+
"function" === typeof type ||
|
|
200605
|
+
type === REACT_FRAGMENT_TYPE ||
|
|
200606
|
+
type === REACT_PROFILER_TYPE ||
|
|
200607
|
+
type === REACT_STRICT_MODE_TYPE ||
|
|
200608
|
+
type === REACT_SUSPENSE_TYPE ||
|
|
200609
|
+
type === REACT_SUSPENSE_LIST_TYPE ||
|
|
200610
|
+
type === REACT_OFFSCREEN_TYPE ||
|
|
200611
|
+
("object" === typeof type &&
|
|
200612
|
+
null !== type &&
|
|
200613
|
+
(type.$$typeof === REACT_LAZY_TYPE ||
|
|
200614
|
+
type.$$typeof === REACT_MEMO_TYPE ||
|
|
200615
|
+
type.$$typeof === REACT_CONTEXT_TYPE ||
|
|
200616
|
+
type.$$typeof === REACT_CONSUMER_TYPE ||
|
|
200617
|
+
type.$$typeof === REACT_FORWARD_REF_TYPE ||
|
|
200618
|
+
type.$$typeof === REACT_CLIENT_REFERENCE ||
|
|
200619
|
+
undefined !== type.getModuleId))
|
|
200620
|
+
? true
|
|
200621
|
+
: false;
|
|
200622
|
+
};
|
|
200623
|
+
reactIs_development$1.typeOf = typeOf;
|
|
200624
|
+
})();
|
|
200625
|
+
return reactIs_development$1;
|
|
200626
|
+
}
|
|
200627
|
+
|
|
200628
|
+
var hasRequiredReactIs$1;
|
|
200629
|
+
|
|
200630
|
+
function requireReactIs$1 () {
|
|
200631
|
+
if (hasRequiredReactIs$1) return reactIs$1.exports;
|
|
200632
|
+
hasRequiredReactIs$1 = 1;
|
|
200633
|
+
|
|
200634
|
+
if (process.env.NODE_ENV === 'production') {
|
|
200635
|
+
reactIs$1.exports = requireReactIs_production();
|
|
200636
|
+
} else {
|
|
200637
|
+
reactIs$1.exports = requireReactIs_development$1();
|
|
200638
|
+
}
|
|
200639
|
+
return reactIs$1.exports;
|
|
200640
|
+
}
|
|
200641
|
+
|
|
200642
|
+
var reactIsExports$1 = /*@__PURE__*/ requireReactIs$1();
|
|
200643
|
+
var index$1 = /*@__PURE__*/getDefaultExportFromCjs$1(reactIsExports$1);
|
|
200644
|
+
|
|
200645
|
+
var ReactIs19 = /*#__PURE__*/_mergeNamespaces({
|
|
200646
|
+
__proto__: null,
|
|
200647
|
+
default: index$1
|
|
200648
|
+
}, [reactIsExports$1]);
|
|
200649
|
+
|
|
200437
200650
|
var reactIs = {exports: {}};
|
|
200438
200651
|
|
|
200439
200652
|
var reactIs_production_min = {};
|
|
@@ -200455,9 +200668,9 @@ function requireReactIs_production_min () {
|
|
|
200455
200668
|
hasRequiredReactIs_production_min = 1;
|
|
200456
200669
|
var b=Symbol.for("react.element"),c=Symbol.for("react.portal"),d=Symbol.for("react.fragment"),e=Symbol.for("react.strict_mode"),f=Symbol.for("react.profiler"),g=Symbol.for("react.provider"),h=Symbol.for("react.context"),k=Symbol.for("react.server_context"),l=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),n=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),q=Symbol.for("react.lazy"),t=Symbol.for("react.offscreen"),u;u=Symbol.for("react.module.reference");
|
|
200457
200670
|
function v(a){if("object"===typeof a&&null!==a){var r=a.$$typeof;switch(r){case b:switch(a=a.type,a){case d:case f:case e:case m:case n:return a;default:switch(a=a&&a.$$typeof,a){case k:case h:case l:case q:case p:case g:return a;default:return r}}case c:return r}}}reactIs_production_min.ContextConsumer=h;reactIs_production_min.ContextProvider=g;reactIs_production_min.Element=b;reactIs_production_min.ForwardRef=l;reactIs_production_min.Fragment=d;reactIs_production_min.Lazy=q;reactIs_production_min.Memo=p;reactIs_production_min.Portal=c;reactIs_production_min.Profiler=f;reactIs_production_min.StrictMode=e;reactIs_production_min.Suspense=m;
|
|
200458
|
-
reactIs_production_min.SuspenseList=n;reactIs_production_min.isAsyncMode=function(){return
|
|
200671
|
+
reactIs_production_min.SuspenseList=n;reactIs_production_min.isAsyncMode=function(){return false};reactIs_production_min.isConcurrentMode=function(){return false};reactIs_production_min.isContextConsumer=function(a){return v(a)===h};reactIs_production_min.isContextProvider=function(a){return v(a)===g};reactIs_production_min.isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===b};reactIs_production_min.isForwardRef=function(a){return v(a)===l};reactIs_production_min.isFragment=function(a){return v(a)===d};reactIs_production_min.isLazy=function(a){return v(a)===q};reactIs_production_min.isMemo=function(a){return v(a)===p};
|
|
200459
200672
|
reactIs_production_min.isPortal=function(a){return v(a)===c};reactIs_production_min.isProfiler=function(a){return v(a)===f};reactIs_production_min.isStrictMode=function(a){return v(a)===e};reactIs_production_min.isSuspense=function(a){return v(a)===m};reactIs_production_min.isSuspenseList=function(a){return v(a)===n};
|
|
200460
|
-
reactIs_production_min.isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===d||a===f||a===e||a===m||a===n||a===t||"object"===typeof a&&null!==a&&(a.$$typeof===q||a.$$typeof===p||a.$$typeof===g||a.$$typeof===h||a.$$typeof===l||a.$$typeof===u||
|
|
200673
|
+
reactIs_production_min.isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===d||a===f||a===e||a===m||a===n||a===t||"object"===typeof a&&null!==a&&(a.$$typeof===q||a.$$typeof===p||a.$$typeof===g||a.$$typeof===h||a.$$typeof===l||a.$$typeof===u||undefined!==a.getModuleId)?true:false};reactIs_production_min.typeOf=v;
|
|
200461
200674
|
return reactIs_production_min;
|
|
200462
200675
|
}
|
|
200463
200676
|
|
|
@@ -200705,7 +200918,33 @@ function requireReactIs () {
|
|
|
200705
200918
|
}
|
|
200706
200919
|
|
|
200707
200920
|
var reactIsExports = requireReactIs();
|
|
200921
|
+
var index = /*@__PURE__*/getDefaultExportFromCjs$1(reactIsExports);
|
|
200708
200922
|
|
|
200923
|
+
var ReactIs18 = /*#__PURE__*/_mergeNamespaces({
|
|
200924
|
+
__proto__: null,
|
|
200925
|
+
default: index
|
|
200926
|
+
}, [reactIsExports]);
|
|
200927
|
+
|
|
200928
|
+
const reactIsMethods = [
|
|
200929
|
+
"isAsyncMode",
|
|
200930
|
+
"isConcurrentMode",
|
|
200931
|
+
"isContextConsumer",
|
|
200932
|
+
"isContextProvider",
|
|
200933
|
+
"isElement",
|
|
200934
|
+
"isForwardRef",
|
|
200935
|
+
"isFragment",
|
|
200936
|
+
"isLazy",
|
|
200937
|
+
"isMemo",
|
|
200938
|
+
"isPortal",
|
|
200939
|
+
"isProfiler",
|
|
200940
|
+
"isStrictMode",
|
|
200941
|
+
"isSuspense",
|
|
200942
|
+
"isSuspenseList",
|
|
200943
|
+
"isValidElementType"
|
|
200944
|
+
];
|
|
200945
|
+
const ReactIs = Object.fromEntries(
|
|
200946
|
+
reactIsMethods.map((m) => [m, (v) => ReactIs18[m](v) || ReactIs19[m](v)])
|
|
200947
|
+
);
|
|
200709
200948
|
function getChildren(arg, children = []) {
|
|
200710
200949
|
if (Array.isArray(arg)) {
|
|
200711
200950
|
for (const item of arg) {
|
|
@@ -200724,27 +200963,27 @@ function getType$1(element) {
|
|
|
200724
200963
|
if (typeof type === "function") {
|
|
200725
200964
|
return type.displayName || type.name || "Unknown";
|
|
200726
200965
|
}
|
|
200727
|
-
if (
|
|
200966
|
+
if (ReactIs.isFragment(element)) {
|
|
200728
200967
|
return "React.Fragment";
|
|
200729
200968
|
}
|
|
200730
|
-
if (
|
|
200969
|
+
if (ReactIs.isSuspense(element)) {
|
|
200731
200970
|
return "React.Suspense";
|
|
200732
200971
|
}
|
|
200733
200972
|
if (typeof type === "object" && type !== null) {
|
|
200734
|
-
if (
|
|
200973
|
+
if (ReactIs.isContextProvider(element)) {
|
|
200735
200974
|
return "Context.Provider";
|
|
200736
200975
|
}
|
|
200737
|
-
if (
|
|
200976
|
+
if (ReactIs.isContextConsumer(element)) {
|
|
200738
200977
|
return "Context.Consumer";
|
|
200739
200978
|
}
|
|
200740
|
-
if (
|
|
200979
|
+
if (ReactIs.isForwardRef(element)) {
|
|
200741
200980
|
if (type.displayName) {
|
|
200742
200981
|
return type.displayName;
|
|
200743
200982
|
}
|
|
200744
200983
|
const functionName = type.render.displayName || type.render.name || "";
|
|
200745
200984
|
return functionName === "" ? "ForwardRef" : `ForwardRef(${functionName})`;
|
|
200746
200985
|
}
|
|
200747
|
-
if (
|
|
200986
|
+
if (ReactIs.isMemo(element)) {
|
|
200748
200987
|
const functionName = type.displayName || type.type.displayName || type.type.name || "";
|
|
200749
200988
|
return functionName === "" ? "Memo" : `Memo(${functionName})`;
|
|
200750
200989
|
}
|
|
@@ -200753,7 +200992,7 @@ function getType$1(element) {
|
|
|
200753
200992
|
}
|
|
200754
200993
|
function getPropKeys$1(element) {
|
|
200755
200994
|
const { props } = element;
|
|
200756
|
-
return Object.keys(props).filter((key) => key !== "children" && props[key] !==
|
|
200995
|
+
return Object.keys(props).filter((key) => key !== "children" && props[key] !== undefined).sort();
|
|
200757
200996
|
}
|
|
200758
200997
|
const serialize$1 = (element, config, indentation, depth, refs, printer) => ++depth > config.maxDepth ? printElementAsLeaf(getType$1(element), config) : printElement(
|
|
200759
200998
|
getType$1(element),
|
|
@@ -200777,13 +201016,13 @@ const serialize$1 = (element, config, indentation, depth, refs, printer) => ++de
|
|
|
200777
201016
|
config,
|
|
200778
201017
|
indentation
|
|
200779
201018
|
);
|
|
200780
|
-
const test$1 = (val) => val != null &&
|
|
201019
|
+
const test$1 = (val) => val != null && ReactIs.isElement(val);
|
|
200781
201020
|
const plugin$1 = { serialize: serialize$1, test: test$1 };
|
|
200782
201021
|
|
|
200783
201022
|
const testSymbol = typeof Symbol === "function" && Symbol.for ? Symbol.for("react.test.json") : 245830487;
|
|
200784
201023
|
function getPropKeys(object) {
|
|
200785
201024
|
const { props } = object;
|
|
200786
|
-
return props ? Object.keys(props).filter((key) => props[key] !==
|
|
201025
|
+
return props ? Object.keys(props).filter((key) => props[key] !== undefined).sort() : [];
|
|
200787
201026
|
}
|
|
200788
201027
|
const serialize = (object, config, indentation, depth, refs, printer) => ++depth > config.maxDepth ? printElementAsLeaf(object.type, config) : printElement(
|
|
200789
201028
|
object.type,
|
|
@@ -200854,7 +201093,7 @@ function printBasicValue(val, printFunctionName, escapeRegex, escapeString) {
|
|
|
200854
201093
|
if (val === true || val === false) {
|
|
200855
201094
|
return `${val}`;
|
|
200856
201095
|
}
|
|
200857
|
-
if (val ===
|
|
201096
|
+
if (val === undefined) {
|
|
200858
201097
|
return "undefined";
|
|
200859
201098
|
}
|
|
200860
201099
|
if (val === null) {
|
|
@@ -200964,6 +201203,32 @@ function printComplexValue(val, config, indentation, depth, refs, hasCalledToJSO
|
|
|
200964
201203
|
printer
|
|
200965
201204
|
)}}`;
|
|
200966
201205
|
}
|
|
201206
|
+
const ErrorPlugin = {
|
|
201207
|
+
test: (val) => val && val instanceof Error,
|
|
201208
|
+
serialize(val, config, indentation, depth, refs, printer2) {
|
|
201209
|
+
if (refs.includes(val)) {
|
|
201210
|
+
return "[Circular]";
|
|
201211
|
+
}
|
|
201212
|
+
refs = [...refs, val];
|
|
201213
|
+
const hitMaxDepth = ++depth > config.maxDepth;
|
|
201214
|
+
const { message, cause, ...rest } = val;
|
|
201215
|
+
const entries = {
|
|
201216
|
+
message,
|
|
201217
|
+
...typeof cause !== "undefined" ? { cause } : {},
|
|
201218
|
+
...val instanceof AggregateError ? { errors: val.errors } : {},
|
|
201219
|
+
...rest
|
|
201220
|
+
};
|
|
201221
|
+
const name = val.name !== "Error" ? val.name : getConstructorName$1(val);
|
|
201222
|
+
return hitMaxDepth ? `[${name}]` : `${name} {${printIteratorEntries(
|
|
201223
|
+
Object.entries(entries).values(),
|
|
201224
|
+
config,
|
|
201225
|
+
indentation,
|
|
201226
|
+
depth,
|
|
201227
|
+
refs,
|
|
201228
|
+
printer2
|
|
201229
|
+
)}}`;
|
|
201230
|
+
}
|
|
201231
|
+
};
|
|
200967
201232
|
function isNewPlugin(plugin) {
|
|
200968
201233
|
return plugin.serialize != null;
|
|
200969
201234
|
}
|
|
@@ -201040,7 +201305,7 @@ const DEFAULT_THEME = {
|
|
|
201040
201305
|
const DEFAULT_THEME_KEYS = Object.keys(DEFAULT_THEME);
|
|
201041
201306
|
const DEFAULT_OPTIONS = {
|
|
201042
201307
|
callToJSON: true,
|
|
201043
|
-
compareKeys:
|
|
201308
|
+
compareKeys: undefined,
|
|
201044
201309
|
escapeRegex: false,
|
|
201045
201310
|
escapeString: true,
|
|
201046
201311
|
highlight: false,
|
|
@@ -201059,7 +201324,7 @@ function validateOptions(options) {
|
|
|
201059
201324
|
throw new Error(`pretty-format: Unknown option "${key}".`);
|
|
201060
201325
|
}
|
|
201061
201326
|
}
|
|
201062
|
-
if (options.min && options.indent !==
|
|
201327
|
+
if (options.min && options.indent !== undefined && options.indent !== 0) {
|
|
201063
201328
|
throw new Error(
|
|
201064
201329
|
'pretty-format: Options "min" and "indent" cannot be used together.'
|
|
201065
201330
|
);
|
|
@@ -201068,7 +201333,7 @@ function validateOptions(options) {
|
|
|
201068
201333
|
function getColorsHighlight() {
|
|
201069
201334
|
return DEFAULT_THEME_KEYS.reduce((colors, key) => {
|
|
201070
201335
|
const value = DEFAULT_THEME[key];
|
|
201071
|
-
const color = value &&
|
|
201336
|
+
const color = value && s[value];
|
|
201072
201337
|
if (color && typeof color.close === "string" && typeof color.open === "string") {
|
|
201073
201338
|
colors[key] = color;
|
|
201074
201339
|
} else {
|
|
@@ -201086,30 +201351,30 @@ function getColorsEmpty() {
|
|
|
201086
201351
|
}, /* @__PURE__ */ Object.create(null));
|
|
201087
201352
|
}
|
|
201088
201353
|
function getPrintFunctionName(options) {
|
|
201089
|
-
return (options == null ?
|
|
201354
|
+
return (options == null ? undefined : options.printFunctionName) ?? DEFAULT_OPTIONS.printFunctionName;
|
|
201090
201355
|
}
|
|
201091
201356
|
function getEscapeRegex(options) {
|
|
201092
|
-
return (options == null ?
|
|
201357
|
+
return (options == null ? undefined : options.escapeRegex) ?? DEFAULT_OPTIONS.escapeRegex;
|
|
201093
201358
|
}
|
|
201094
201359
|
function getEscapeString(options) {
|
|
201095
|
-
return (options == null ?
|
|
201360
|
+
return (options == null ? undefined : options.escapeString) ?? DEFAULT_OPTIONS.escapeString;
|
|
201096
201361
|
}
|
|
201097
201362
|
function getConfig(options) {
|
|
201098
201363
|
return {
|
|
201099
|
-
callToJSON: (options == null ?
|
|
201100
|
-
colors: (options == null ?
|
|
201101
|
-
compareKeys: typeof (options == null ?
|
|
201364
|
+
callToJSON: (options == null ? undefined : options.callToJSON) ?? DEFAULT_OPTIONS.callToJSON,
|
|
201365
|
+
colors: (options == null ? undefined : options.highlight) ? getColorsHighlight() : getColorsEmpty(),
|
|
201366
|
+
compareKeys: typeof (options == null ? undefined : options.compareKeys) === "function" || (options == null ? undefined : options.compareKeys) === null ? options.compareKeys : DEFAULT_OPTIONS.compareKeys,
|
|
201102
201367
|
escapeRegex: getEscapeRegex(options),
|
|
201103
201368
|
escapeString: getEscapeString(options),
|
|
201104
|
-
indent: (options == null ?
|
|
201105
|
-
maxDepth: (options == null ?
|
|
201106
|
-
maxWidth: (options == null ?
|
|
201107
|
-
min: (options == null ?
|
|
201108
|
-
plugins: (options == null ?
|
|
201109
|
-
printBasicPrototype: (options == null ?
|
|
201369
|
+
indent: (options == null ? undefined : options.min) ? "" : createIndent((options == null ? undefined : options.indent) ?? DEFAULT_OPTIONS.indent),
|
|
201370
|
+
maxDepth: (options == null ? undefined : options.maxDepth) ?? DEFAULT_OPTIONS.maxDepth,
|
|
201371
|
+
maxWidth: (options == null ? undefined : options.maxWidth) ?? DEFAULT_OPTIONS.maxWidth,
|
|
201372
|
+
min: (options == null ? undefined : options.min) ?? DEFAULT_OPTIONS.min,
|
|
201373
|
+
plugins: (options == null ? undefined : options.plugins) ?? DEFAULT_OPTIONS.plugins,
|
|
201374
|
+
printBasicPrototype: (options == null ? undefined : options.printBasicPrototype) ?? true,
|
|
201110
201375
|
printFunctionName: getPrintFunctionName(options),
|
|
201111
|
-
spacingInner: (options == null ?
|
|
201112
|
-
spacingOuter: (options == null ?
|
|
201376
|
+
spacingInner: (options == null ? undefined : options.min) ? " " : "\n",
|
|
201377
|
+
spacingOuter: (options == null ? undefined : options.min) ? "" : "\n"
|
|
201113
201378
|
};
|
|
201114
201379
|
}
|
|
201115
201380
|
function createIndent(indent) {
|
|
@@ -201142,7 +201407,8 @@ const plugins = {
|
|
|
201142
201407
|
DOMElement: plugin$3,
|
|
201143
201408
|
Immutable: plugin$2,
|
|
201144
201409
|
ReactElement: plugin$1,
|
|
201145
|
-
ReactTestComponent: plugin
|
|
201410
|
+
ReactTestComponent: plugin,
|
|
201411
|
+
Error: ErrorPlugin
|
|
201146
201412
|
};
|
|
201147
201413
|
|
|
201148
201414
|
let getPromiseValue$1 = () => 'Promise{…}';
|
|
@@ -202224,30 +202490,31 @@ const DIFF_TRUNCATE_THRESHOLD_DEFAULT = 0;
|
|
|
202224
202490
|
function getDefaultOptions() {
|
|
202225
202491
|
return {
|
|
202226
202492
|
aAnnotation: "Expected",
|
|
202227
|
-
aColor:
|
|
202493
|
+
aColor: s.green,
|
|
202228
202494
|
aIndicator: "-",
|
|
202229
202495
|
bAnnotation: "Received",
|
|
202230
|
-
bColor:
|
|
202496
|
+
bColor: s.red,
|
|
202231
202497
|
bIndicator: "+",
|
|
202232
|
-
changeColor:
|
|
202498
|
+
changeColor: s.inverse,
|
|
202233
202499
|
changeLineTrailingSpaceColor: noColor,
|
|
202234
|
-
commonColor:
|
|
202500
|
+
commonColor: s.dim,
|
|
202235
202501
|
commonIndicator: " ",
|
|
202236
202502
|
commonLineTrailingSpaceColor: noColor,
|
|
202237
|
-
compareKeys:
|
|
202503
|
+
compareKeys: undefined,
|
|
202238
202504
|
contextLines: DIFF_CONTEXT_DEFAULT,
|
|
202239
202505
|
emptyFirstOrLastLinePlaceholder: "",
|
|
202240
202506
|
expand: true,
|
|
202241
202507
|
includeChangeCounts: false,
|
|
202242
202508
|
omitAnnotationLines: false,
|
|
202243
|
-
patchColor:
|
|
202509
|
+
patchColor: s.yellow,
|
|
202510
|
+
printBasicPrototype: false,
|
|
202244
202511
|
truncateThreshold: DIFF_TRUNCATE_THRESHOLD_DEFAULT,
|
|
202245
202512
|
truncateAnnotation: "... Diff result is truncated",
|
|
202246
202513
|
truncateAnnotationColor: noColor
|
|
202247
202514
|
};
|
|
202248
202515
|
}
|
|
202249
202516
|
function getCompareKeys(compareKeys) {
|
|
202250
|
-
return compareKeys && typeof compareKeys === "function" ? compareKeys :
|
|
202517
|
+
return compareKeys && typeof compareKeys === "function" ? compareKeys : undefined;
|
|
202251
202518
|
}
|
|
202252
202519
|
function getContextLines(contextLines) {
|
|
202253
202520
|
return typeof contextLines === "number" && Number.isSafeInteger(contextLines) && contextLines >= 0 ? contextLines : DIFF_CONTEXT_DEFAULT;
|
|
@@ -202364,9 +202631,9 @@ function diffLinesUnified2(aLinesDisplay, bLinesDisplay, aLinesCompare, bLinesCo
|
|
|
202364
202631
|
return printDiffLines(diffs, truncated, normalizeDiffOptions(options));
|
|
202365
202632
|
}
|
|
202366
202633
|
function diffLinesRaw(aLines, bLines, options) {
|
|
202367
|
-
const truncate = (options == null ?
|
|
202634
|
+
const truncate = (options == null ? undefined : options.truncateThreshold) ?? false;
|
|
202368
202635
|
const truncateThreshold = Math.max(
|
|
202369
|
-
Math.floor((options == null ?
|
|
202636
|
+
Math.floor((options == null ? undefined : options.truncateThreshold) ?? 0),
|
|
202370
202637
|
0
|
|
202371
202638
|
);
|
|
202372
202639
|
const aLength = truncate ? Math.min(aLines.length, truncateThreshold) : aLines.length;
|
|
@@ -202398,7 +202665,7 @@ function diffLinesRaw(aLines, bLines, options) {
|
|
|
202398
202665
|
}
|
|
202399
202666
|
|
|
202400
202667
|
function getType(value) {
|
|
202401
|
-
if (value ===
|
|
202668
|
+
if (value === undefined) {
|
|
202402
202669
|
return "undefined";
|
|
202403
202670
|
} else if (value === null) {
|
|
202404
202671
|
return "null";
|
|
@@ -202451,14 +202718,15 @@ const PLUGINS = [
|
|
|
202451
202718
|
DOMElement,
|
|
202452
202719
|
DOMCollection,
|
|
202453
202720
|
Immutable,
|
|
202454
|
-
AsymmetricMatcher
|
|
202721
|
+
AsymmetricMatcher,
|
|
202722
|
+
plugins.Error
|
|
202455
202723
|
];
|
|
202456
202724
|
const FORMAT_OPTIONS = {
|
|
202457
202725
|
plugins: PLUGINS
|
|
202458
202726
|
};
|
|
202459
202727
|
const FALLBACK_FORMAT_OPTIONS = {
|
|
202460
202728
|
callToJSON: false,
|
|
202461
|
-
maxDepth:
|
|
202729
|
+
maxDepth: 8,
|
|
202462
202730
|
plugins: PLUGINS
|
|
202463
202731
|
};
|
|
202464
202732
|
function diff(a, b, options) {
|
|
@@ -202470,19 +202738,25 @@ function diff(a, b, options) {
|
|
|
202470
202738
|
let omitDifference = false;
|
|
202471
202739
|
if (aType === "object" && typeof a.asymmetricMatch === "function") {
|
|
202472
202740
|
if (a.$$typeof !== Symbol.for("jest.asymmetricMatcher")) {
|
|
202473
|
-
return
|
|
202741
|
+
return undefined;
|
|
202474
202742
|
}
|
|
202475
202743
|
if (typeof a.getExpectedType !== "function") {
|
|
202476
|
-
return
|
|
202744
|
+
return undefined;
|
|
202477
202745
|
}
|
|
202478
202746
|
expectedType = a.getExpectedType();
|
|
202479
202747
|
omitDifference = expectedType === "string";
|
|
202480
202748
|
}
|
|
202481
202749
|
if (expectedType !== getType(b)) {
|
|
202750
|
+
let truncate2 = function(s) {
|
|
202751
|
+
return s.length <= MAX_LENGTH ? s : `${s.slice(0, MAX_LENGTH)}...`;
|
|
202752
|
+
};
|
|
202482
202753
|
const { aAnnotation, aColor, aIndicator, bAnnotation, bColor, bIndicator } = normalizeDiffOptions(options);
|
|
202483
202754
|
const formatOptions = getFormatOptions(FALLBACK_FORMAT_OPTIONS, options);
|
|
202484
|
-
|
|
202485
|
-
|
|
202755
|
+
let aDisplay = format(a, formatOptions);
|
|
202756
|
+
let bDisplay = format(b, formatOptions);
|
|
202757
|
+
const MAX_LENGTH = 1e5;
|
|
202758
|
+
aDisplay = truncate2(aDisplay);
|
|
202759
|
+
bDisplay = truncate2(bDisplay);
|
|
202486
202760
|
const aDiff = `${aColor(`${aIndicator} ${aAnnotation}:`)}
|
|
202487
202761
|
${aDisplay}`;
|
|
202488
202762
|
const bDiff = `${bColor(`${bIndicator} ${bAnnotation}:`)}
|
|
@@ -202492,7 +202766,7 @@ ${bDisplay}`;
|
|
|
202492
202766
|
${bDiff}`;
|
|
202493
202767
|
}
|
|
202494
202768
|
if (omitDifference) {
|
|
202495
|
-
return
|
|
202769
|
+
return undefined;
|
|
202496
202770
|
}
|
|
202497
202771
|
switch (aType) {
|
|
202498
202772
|
case "string":
|
|
@@ -202529,7 +202803,7 @@ function compareObjects(a, b, options) {
|
|
|
202529
202803
|
hasThrown = true;
|
|
202530
202804
|
}
|
|
202531
202805
|
const noDiffMessage = getCommonMessage(NO_DIFF_MESSAGE, options);
|
|
202532
|
-
if (difference ===
|
|
202806
|
+
if (difference === undefined || difference === noDiffMessage) {
|
|
202533
202807
|
const formatOptions = getFormatOptions(FALLBACK_FORMAT_OPTIONS, options);
|
|
202534
202808
|
difference = getObjectsDifference(a, b, formatOptions, options);
|
|
202535
202809
|
if (difference !== noDiffMessage && !hasThrown) {
|
|
@@ -202544,10 +202818,11 @@ ${difference}`;
|
|
|
202544
202818
|
return difference;
|
|
202545
202819
|
}
|
|
202546
202820
|
function getFormatOptions(formatOptions, options) {
|
|
202547
|
-
const { compareKeys } = normalizeDiffOptions(options);
|
|
202821
|
+
const { compareKeys, printBasicPrototype } = normalizeDiffOptions(options);
|
|
202548
202822
|
return {
|
|
202549
202823
|
...formatOptions,
|
|
202550
|
-
compareKeys
|
|
202824
|
+
compareKeys,
|
|
202825
|
+
printBasicPrototype
|
|
202551
202826
|
};
|
|
202552
202827
|
}
|
|
202553
202828
|
function getObjectsDifference(a, b, formatOptions, options) {
|
|
@@ -206617,11 +206892,11 @@ const ASYMMETRIC_MATCHERS_OBJECT = Symbol.for(
|
|
|
206617
206892
|
"asymmetric-matchers-object"
|
|
206618
206893
|
);
|
|
206619
206894
|
|
|
206620
|
-
|
|
206621
|
-
|
|
206622
|
-
|
|
206623
|
-
|
|
206624
|
-
|
|
206895
|
+
s.green;
|
|
206896
|
+
s.red;
|
|
206897
|
+
s.inverse;
|
|
206898
|
+
s.bold;
|
|
206899
|
+
s.dim;
|
|
206625
206900
|
|
|
206626
206901
|
function equals(a, b, customTesters, strictCheck) {
|
|
206627
206902
|
customTesters = customTesters || [];
|
|
@@ -206634,7 +206909,7 @@ function asymmetricMatch(a, b) {
|
|
|
206634
206909
|
const asymmetricA = isAsymmetric(a);
|
|
206635
206910
|
const asymmetricB = isAsymmetric(b);
|
|
206636
206911
|
if (asymmetricA && asymmetricB) {
|
|
206637
|
-
return
|
|
206912
|
+
return undefined;
|
|
206638
206913
|
}
|
|
206639
206914
|
if (asymmetricA) {
|
|
206640
206915
|
return a.asymmetricMatch(b);
|
|
@@ -206646,7 +206921,7 @@ function asymmetricMatch(a, b) {
|
|
|
206646
206921
|
function eq(a, b, aStack, bStack, customTesters, hasKey2) {
|
|
206647
206922
|
let result = true;
|
|
206648
206923
|
const asymmetricResult = asymmetricMatch(a, b);
|
|
206649
|
-
if (asymmetricResult !==
|
|
206924
|
+
if (asymmetricResult !== undefined) {
|
|
206650
206925
|
return asymmetricResult;
|
|
206651
206926
|
}
|
|
206652
206927
|
const testerContext = { equals };
|
|
@@ -206657,13 +206932,10 @@ function eq(a, b, aStack, bStack, customTesters, hasKey2) {
|
|
|
206657
206932
|
b,
|
|
206658
206933
|
customTesters
|
|
206659
206934
|
);
|
|
206660
|
-
if (customTesterResult !==
|
|
206935
|
+
if (customTesterResult !== undefined) {
|
|
206661
206936
|
return customTesterResult;
|
|
206662
206937
|
}
|
|
206663
206938
|
}
|
|
206664
|
-
if (a instanceof Error && b instanceof Error) {
|
|
206665
|
-
return a.message === b.message;
|
|
206666
|
-
}
|
|
206667
206939
|
if (typeof URL === "function" && a instanceof URL && b instanceof URL) {
|
|
206668
206940
|
return a.href === b.href;
|
|
206669
206941
|
}
|
|
@@ -206716,6 +206988,14 @@ function eq(a, b, aStack, bStack, customTesters, hasKey2) {
|
|
|
206716
206988
|
if (className === "[object Array]" && a.length !== b.length) {
|
|
206717
206989
|
return false;
|
|
206718
206990
|
}
|
|
206991
|
+
if (a instanceof Error && b instanceof Error) {
|
|
206992
|
+
try {
|
|
206993
|
+
return isErrorEqual(a, b, aStack, bStack, customTesters, hasKey2);
|
|
206994
|
+
} finally {
|
|
206995
|
+
aStack.pop();
|
|
206996
|
+
bStack.pop();
|
|
206997
|
+
}
|
|
206998
|
+
}
|
|
206719
206999
|
const aKeys = keys(a, hasKey2);
|
|
206720
207000
|
let key;
|
|
206721
207001
|
let size = aKeys.length;
|
|
@@ -206733,6 +207013,17 @@ function eq(a, b, aStack, bStack, customTesters, hasKey2) {
|
|
|
206733
207013
|
bStack.pop();
|
|
206734
207014
|
return result;
|
|
206735
207015
|
}
|
|
207016
|
+
function isErrorEqual(a, b, aStack, bStack, customTesters, hasKey2) {
|
|
207017
|
+
let result = Object.getPrototypeOf(a) === Object.getPrototypeOf(b) && a.name === b.name && a.message === b.message;
|
|
207018
|
+
if (typeof b.cause !== "undefined") {
|
|
207019
|
+
result && (result = eq(a.cause, b.cause, aStack, bStack, customTesters, hasKey2));
|
|
207020
|
+
}
|
|
207021
|
+
if (a instanceof AggregateError && b instanceof AggregateError) {
|
|
207022
|
+
result && (result = eq(a.errors, b.errors, aStack, bStack, customTesters, hasKey2));
|
|
207023
|
+
}
|
|
207024
|
+
result && (result = eq({ ...a }, { ...b }, aStack, bStack, customTesters, hasKey2));
|
|
207025
|
+
return result;
|
|
207026
|
+
}
|
|
206736
207027
|
function keys(obj, hasKey2) {
|
|
206737
207028
|
const keys2 = [];
|
|
206738
207029
|
for (const key in obj) {
|
|
@@ -206747,7 +207038,7 @@ function keys(obj, hasKey2) {
|
|
|
206747
207038
|
);
|
|
206748
207039
|
}
|
|
206749
207040
|
function hasDefinedKey(obj, key) {
|
|
206750
|
-
return hasKey(obj, key) && obj[key] !==
|
|
207041
|
+
return hasKey(obj, key) && obj[key] !== undefined;
|
|
206751
207042
|
}
|
|
206752
207043
|
function hasKey(obj, key) {
|
|
206753
207044
|
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
@@ -206763,7 +207054,7 @@ if (!Object.prototype.hasOwnProperty.call(globalThis, MATCHERS_OBJECT)) {
|
|
|
206763
207054
|
const globalState = /* @__PURE__ */ new WeakMap();
|
|
206764
207055
|
const matchers = /* @__PURE__ */ Object.create(null);
|
|
206765
207056
|
const customEqualityTesters = [];
|
|
206766
|
-
const
|
|
207057
|
+
const asymmetricMatchers = /* @__PURE__ */ Object.create(null);
|
|
206767
207058
|
Object.defineProperty(globalThis, MATCHERS_OBJECT, {
|
|
206768
207059
|
get: () => globalState
|
|
206769
207060
|
});
|
|
@@ -206776,7 +207067,7 @@ if (!Object.prototype.hasOwnProperty.call(globalThis, MATCHERS_OBJECT)) {
|
|
|
206776
207067
|
})
|
|
206777
207068
|
});
|
|
206778
207069
|
Object.defineProperty(globalThis, ASYMMETRIC_MATCHERS_OBJECT, {
|
|
206779
|
-
get: () =>
|
|
207070
|
+
get: () => asymmetricMatchers
|
|
206780
207071
|
});
|
|
206781
207072
|
}
|
|
206782
207073
|
|
|
@@ -206853,115 +207144,116 @@ function patchJsonSchema({
|
|
|
206853
207144
|
openApiSchema,
|
|
206854
207145
|
jsonOverrides
|
|
206855
207146
|
}) {
|
|
207147
|
+
var _a;
|
|
206856
207148
|
const patchedSchema = lib.parse(lib.stringify(openApiSchema));
|
|
207149
|
+
patchedSchema.components ?? (patchedSchema.components = {});
|
|
207150
|
+
(_a = patchedSchema.components).schemas ?? (_a.schemas = {});
|
|
207151
|
+
patchedSchema.paths ?? (patchedSchema.paths = {});
|
|
206857
207152
|
let alreadyApliedPatches = 0;
|
|
206858
207153
|
const outdatedPatches = [];
|
|
206859
207154
|
let appliedPatches = 0;
|
|
206860
207155
|
const todosToFix = [];
|
|
206861
207156
|
const schemaPaths = [];
|
|
206862
|
-
|
|
207157
|
+
function _applyPatches(initialObject, schemaName, overridePatches, originalSchema) {
|
|
207158
|
+
let patchedObject = initialObject;
|
|
207159
|
+
const patches = Array.isArray(overridePatches) ? overridePatches : [overridePatches];
|
|
207160
|
+
for (const patch of patches) {
|
|
207161
|
+
patchedObject = extendedDefu(patch, patchedObject);
|
|
207162
|
+
}
|
|
207163
|
+
const matchResult = equals(patchedObject, originalSchema);
|
|
207164
|
+
if (matchResult) {
|
|
207165
|
+
outdatedPatches.push([
|
|
207166
|
+
`${c.gray(
|
|
207167
|
+
`
|
|
207168
|
+
${c.bold("Info")}: Patch for ${c.bold(schemaName)} is already applied in schema. You can remove it from overrides.`
|
|
207169
|
+
)}`,
|
|
207170
|
+
c.red(lib.stringify(patches))
|
|
207171
|
+
]);
|
|
207172
|
+
alreadyApliedPatches++;
|
|
207173
|
+
} else {
|
|
207174
|
+
appliedPatches++;
|
|
207175
|
+
todosToFix.push([
|
|
207176
|
+
`Patch for "${c.cyan(schemaName)}" is missing in schema.
|
|
207177
|
+
Patched object:
|
|
207178
|
+
${c.cyan(
|
|
207179
|
+
lib.stringify(patchedObject)
|
|
207180
|
+
)}`,
|
|
207181
|
+
diff(patchedObject, originalSchema, {
|
|
207182
|
+
aColor: c.green,
|
|
207183
|
+
bColor: c.red
|
|
207184
|
+
}) || ""
|
|
207185
|
+
]);
|
|
207186
|
+
}
|
|
207187
|
+
return patchedObject;
|
|
207188
|
+
}
|
|
207189
|
+
function _applyPathPatches(pathName, httpMethod, overridePatches) {
|
|
207190
|
+
var _a2, _b;
|
|
207191
|
+
(_a2 = patchedSchema.paths)[pathName] ?? (_a2[pathName] = {});
|
|
207192
|
+
(_b = patchedSchema.paths[pathName])[httpMethod] ?? (_b[httpMethod] = {});
|
|
207193
|
+
patchedSchema.paths[pathName][httpMethod] = _applyPatches(
|
|
207194
|
+
patchedSchema.paths[pathName][httpMethod],
|
|
207195
|
+
`${pathName} ${httpMethod}`,
|
|
207196
|
+
overridePatches,
|
|
207197
|
+
openApiSchema.paths?.[pathName]?.[httpMethod]
|
|
207198
|
+
);
|
|
207199
|
+
}
|
|
207200
|
+
function _applyComponentsPatches(pathName, overridePatches) {
|
|
207201
|
+
var _a2;
|
|
207202
|
+
(_a2 = patchedSchema.components.schemas)[pathName] ?? (_a2[pathName] = {});
|
|
207203
|
+
patchedSchema.components.schemas[pathName] = _applyPatches(
|
|
207204
|
+
patchedSchema.components.schemas[pathName],
|
|
207205
|
+
pathName,
|
|
207206
|
+
overridePatches,
|
|
207207
|
+
openApiSchema.components?.schemas?.[pathName]
|
|
207208
|
+
);
|
|
207209
|
+
}
|
|
207210
|
+
for (const schemaName of Object.keys(
|
|
206863
207211
|
openApiSchema.components?.schemas || {}
|
|
206864
207212
|
)) {
|
|
206865
207213
|
if (jsonOverrides?.components?.[schemaName]) {
|
|
206866
207214
|
const overridePatches = jsonOverrides?.components[schemaName];
|
|
206867
|
-
|
|
206868
|
-
for (const patch of patches) {
|
|
206869
|
-
const mergedPatch = extendedDefu(patch, schema);
|
|
206870
|
-
patchedSchema.components.schemas[schemaName] = extendedDefu(
|
|
206871
|
-
patch,
|
|
206872
|
-
patchedSchema.components.schemas[schemaName]
|
|
206873
|
-
);
|
|
206874
|
-
appliedPatches++;
|
|
206875
|
-
const matchResult = equals(mergedPatch, schema);
|
|
206876
|
-
if (matchResult) {
|
|
206877
|
-
outdatedPatches.push([
|
|
206878
|
-
`${c.gray(
|
|
206879
|
-
`
|
|
206880
|
-
${c.bold("Info")}: Patch for ${c.bold(schemaName)} is already applied in schema. You can remove it from overrides.`
|
|
206881
|
-
)}`,
|
|
206882
|
-
c.red(lib.stringify(patch))
|
|
206883
|
-
]);
|
|
206884
|
-
alreadyApliedPatches++;
|
|
206885
|
-
} else {
|
|
206886
|
-
todosToFix.push([
|
|
206887
|
-
`Patch for ${c.cyan(
|
|
206888
|
-
c.bold(schemaName)
|
|
206889
|
-
)} is missing in schema.
|
|
206890
|
-
Patch:
|
|
206891
|
-
${c.cyan(
|
|
206892
|
-
lib.stringify(patch)
|
|
206893
|
-
)}`,
|
|
206894
|
-
diff(mergedPatch, schema, {
|
|
206895
|
-
aColor: c.green,
|
|
206896
|
-
bColor: c.red
|
|
206897
|
-
}) || ""
|
|
206898
|
-
]);
|
|
206899
|
-
}
|
|
206900
|
-
}
|
|
207215
|
+
_applyComponentsPatches(schemaName, overridePatches);
|
|
206901
207216
|
}
|
|
206902
207217
|
}
|
|
206903
|
-
for (const [schemaName,
|
|
207218
|
+
for (const [schemaName, patches] of Object.entries(
|
|
206904
207219
|
jsonOverrides?.components || {}
|
|
206905
207220
|
)) {
|
|
206906
207221
|
if (!openApiSchema.components?.schemas?.[schemaName]) {
|
|
206907
|
-
|
|
206908
|
-
|
|
206909
|
-
|
|
206910
|
-
|
|
206911
|
-
|
|
207222
|
+
_applyComponentsPatches(schemaName, patches);
|
|
207223
|
+
}
|
|
207224
|
+
}
|
|
207225
|
+
for (const [pathName, methodObject] of Object.entries(
|
|
207226
|
+
jsonOverrides?.paths || {}
|
|
207227
|
+
)) {
|
|
207228
|
+
for (const [httpMethod, overridePatches] of Object.entries(
|
|
207229
|
+
methodObject || {}
|
|
207230
|
+
)) {
|
|
207231
|
+
if (!openApiSchema.paths?.[pathName]?.[httpMethod]) {
|
|
207232
|
+
_applyPathPatches(
|
|
207233
|
+
pathName,
|
|
207234
|
+
httpMethod,
|
|
207235
|
+
overridePatches
|
|
206912
207236
|
);
|
|
206913
|
-
appliedPatches++;
|
|
206914
207237
|
}
|
|
206915
207238
|
}
|
|
206916
207239
|
}
|
|
206917
207240
|
for (const [pathName, pathObject] of Object.entries(
|
|
206918
207241
|
openApiSchema?.paths || {}
|
|
206919
207242
|
)) {
|
|
206920
|
-
for (const
|
|
207243
|
+
for (const httpMethod of Object.keys(pathObject)) {
|
|
207244
|
+
if (!(httpMethod in pathObject))
|
|
207245
|
+
continue;
|
|
206921
207246
|
schemaPaths.push({
|
|
206922
207247
|
path: pathName,
|
|
206923
207248
|
method: httpMethod.toUpperCase()
|
|
206924
207249
|
});
|
|
206925
207250
|
if (jsonOverrides?.paths?.[pathName]?.[httpMethod]) {
|
|
206926
207251
|
const overridePatches = jsonOverrides?.paths[pathName][httpMethod];
|
|
206927
|
-
|
|
206928
|
-
|
|
206929
|
-
|
|
206930
|
-
|
|
206931
|
-
|
|
206932
|
-
);
|
|
206933
|
-
patchedSchema.paths[pathName][httpMethod] = extendedDefu(
|
|
206934
|
-
patch,
|
|
206935
|
-
patchedSchema.paths[pathName][httpMethod]
|
|
206936
|
-
);
|
|
206937
|
-
appliedPatches++;
|
|
206938
|
-
const matchResult = equals(mergedPatch, singlePath[1]);
|
|
206939
|
-
if (matchResult) {
|
|
206940
|
-
outdatedPatches.push([
|
|
206941
|
-
`${c.gray(
|
|
206942
|
-
`
|
|
206943
|
-
${c.bold("Info")}: Patch for "${c.bold(pathName)} ${c.bold(httpMethod)}" is already applied in schema. You can remove it from overrides.`
|
|
206944
|
-
)}`,
|
|
206945
|
-
c.red(lib.stringify(patch))
|
|
206946
|
-
]);
|
|
206947
|
-
alreadyApliedPatches++;
|
|
206948
|
-
} else {
|
|
206949
|
-
todosToFix.push([
|
|
206950
|
-
`Patch for ${c.cyan(
|
|
206951
|
-
c.bold(pathName)
|
|
206952
|
-
)} ${httpMethod} is missing in schema.
|
|
206953
|
-
Patch:
|
|
206954
|
-
${c.cyan(
|
|
206955
|
-
lib.stringify(patch)
|
|
206956
|
-
)}`,
|
|
206957
|
-
diff(mergedPatch, singlePath[1], {
|
|
206958
|
-
aColor: c.green,
|
|
206959
|
-
bColor: c.red
|
|
206960
|
-
}) || "",
|
|
206961
|
-
"\n\n"
|
|
206962
|
-
]);
|
|
206963
|
-
}
|
|
206964
|
-
}
|
|
207252
|
+
_applyPathPatches(
|
|
207253
|
+
pathName,
|
|
207254
|
+
httpMethod,
|
|
207255
|
+
overridePatches
|
|
207256
|
+
);
|
|
206965
207257
|
}
|
|
206966
207258
|
const requestBody = patchedSchema.paths[pathName][httpMethod].requestBody;
|
|
206967
207259
|
if (requestBody) {
|
|
@@ -206979,6 +207271,138 @@ ${c.cyan(
|
|
|
206979
207271
|
};
|
|
206980
207272
|
}
|
|
206981
207273
|
|
|
207274
|
+
const API_GEN_CONFIG_FILENAME = "api-gen.config.json";
|
|
207275
|
+
async function loadApiGenConfig(params = {}) {
|
|
207276
|
+
try {
|
|
207277
|
+
const config = await readFileSync(API_GEN_CONFIG_FILENAME, {
|
|
207278
|
+
// TODO: use c12 library for that
|
|
207279
|
+
// name: "api-gen", // file should be "api-gen.config.json"
|
|
207280
|
+
encoding: "utf-8"
|
|
207281
|
+
});
|
|
207282
|
+
return lib.parse(config);
|
|
207283
|
+
} catch (error) {
|
|
207284
|
+
if (!params.silent) {
|
|
207285
|
+
console.error(
|
|
207286
|
+
c.red(
|
|
207287
|
+
`Error while parsing config file ${API_GEN_CONFIG_FILENAME}. Check whether the file is correct JSON file.
|
|
207288
|
+
`
|
|
207289
|
+
),
|
|
207290
|
+
error
|
|
207291
|
+
);
|
|
207292
|
+
}
|
|
207293
|
+
return null;
|
|
207294
|
+
}
|
|
207295
|
+
}
|
|
207296
|
+
function isURL(str) {
|
|
207297
|
+
return str.startsWith("http");
|
|
207298
|
+
}
|
|
207299
|
+
async function resolveSinglePath(pathToResolve) {
|
|
207300
|
+
try {
|
|
207301
|
+
if (isURL(pathToResolve)) {
|
|
207302
|
+
const response = await ofetch(pathToResolve, {
|
|
207303
|
+
responseType: "json",
|
|
207304
|
+
parseResponse: lib.parse
|
|
207305
|
+
});
|
|
207306
|
+
return response;
|
|
207307
|
+
}
|
|
207308
|
+
const jsonOverridesFile = await readFileSync(pathToResolve, {
|
|
207309
|
+
encoding: "utf-8"
|
|
207310
|
+
});
|
|
207311
|
+
return lib.parse(jsonOverridesFile);
|
|
207312
|
+
} catch (error) {
|
|
207313
|
+
console.warn(
|
|
207314
|
+
c.yellow(
|
|
207315
|
+
`Problem with resolving overrides "patches" at address ${pathToResolve}. Check whether you configured it properly in your ${API_GEN_CONFIG_FILENAME}
|
|
207316
|
+
`
|
|
207317
|
+
),
|
|
207318
|
+
error
|
|
207319
|
+
);
|
|
207320
|
+
return {};
|
|
207321
|
+
}
|
|
207322
|
+
}
|
|
207323
|
+
async function loadJsonOverrides({
|
|
207324
|
+
paths,
|
|
207325
|
+
apiType
|
|
207326
|
+
}) {
|
|
207327
|
+
const localPath = `./api-types/${apiType}ApiSchema.overrides.json`;
|
|
207328
|
+
const fallbackPath = existsSync(localPath) ? localPath : `https://raw.githubusercontent.com/shopware/frontends/main/packages/api-client/api-types/${apiType}ApiSchema.overrides.json`;
|
|
207329
|
+
const patchesToResolve = Array.isArray(paths) ? paths : paths ? [paths] : [];
|
|
207330
|
+
if (!patchesToResolve?.length) {
|
|
207331
|
+
patchesToResolve.push(fallbackPath);
|
|
207332
|
+
}
|
|
207333
|
+
console.log("Loading overrides from:", patchesToResolve);
|
|
207334
|
+
try {
|
|
207335
|
+
const results = await Promise.allSettled(
|
|
207336
|
+
patchesToResolve.map(resolveSinglePath)
|
|
207337
|
+
);
|
|
207338
|
+
return extendedDefu(
|
|
207339
|
+
{},
|
|
207340
|
+
...results.filter((result) => result.status === "fulfilled").map((result) => result.value)
|
|
207341
|
+
);
|
|
207342
|
+
} catch (error) {
|
|
207343
|
+
console.warn(
|
|
207344
|
+
c.yellow(
|
|
207345
|
+
`Problem with resolving overrides "patches". Check whether you configured it properly in your ${API_GEN_CONFIG_FILENAME}
|
|
207346
|
+
`
|
|
207347
|
+
),
|
|
207348
|
+
error
|
|
207349
|
+
);
|
|
207350
|
+
return {};
|
|
207351
|
+
}
|
|
207352
|
+
}
|
|
207353
|
+
function displayPatchingSummary({
|
|
207354
|
+
todosToFix,
|
|
207355
|
+
outdatedPatches,
|
|
207356
|
+
alreadyApliedPatches,
|
|
207357
|
+
errors,
|
|
207358
|
+
displayPatchedLogs
|
|
207359
|
+
}) {
|
|
207360
|
+
if (displayPatchedLogs && !errors?.length && todosToFix.length) {
|
|
207361
|
+
console.log(c.yellow("Warnings to fix in the schema:"));
|
|
207362
|
+
for (const todo of todosToFix) {
|
|
207363
|
+
console.log(`${c.yellow("WARNING")}: ${todo[0]}`);
|
|
207364
|
+
console.log("Diff:\n", todo[1], "\n\n");
|
|
207365
|
+
}
|
|
207366
|
+
}
|
|
207367
|
+
if (errors?.length) {
|
|
207368
|
+
console.log(c.red("Errors found:"));
|
|
207369
|
+
for (const error of errors) {
|
|
207370
|
+
console.log(`
|
|
207371
|
+
<==== ${c.red("ERROR")}:
|
|
207372
|
+
${error}
|
|
207373
|
+
====>
|
|
207374
|
+
|
|
207375
|
+
`);
|
|
207376
|
+
}
|
|
207377
|
+
}
|
|
207378
|
+
if (outdatedPatches.length) {
|
|
207379
|
+
console.log(c.yellow("Info: Outdated patches:"));
|
|
207380
|
+
console.log(
|
|
207381
|
+
c.gray(
|
|
207382
|
+
"No action needed. Patches are already applied. You can remove them from the overrides file to clean it up."
|
|
207383
|
+
)
|
|
207384
|
+
);
|
|
207385
|
+
for (const todo of outdatedPatches) {
|
|
207386
|
+
console.log(`${todo[0]}`);
|
|
207387
|
+
console.log("Patch to remove:\n", todo[1], "\n\n");
|
|
207388
|
+
}
|
|
207389
|
+
}
|
|
207390
|
+
console.log("\n\n===== Summary =====");
|
|
207391
|
+
if (alreadyApliedPatches) {
|
|
207392
|
+
console.log(
|
|
207393
|
+
c.gray(
|
|
207394
|
+
` \u2714\uFE0F Already fixed patches: ${c.bold(alreadyApliedPatches)} They can be removed now from the overrides file.`
|
|
207395
|
+
)
|
|
207396
|
+
);
|
|
207397
|
+
}
|
|
207398
|
+
const formatColor = todosToFix.length ? c.yellow : c.green;
|
|
207399
|
+
console.log(
|
|
207400
|
+
formatColor(
|
|
207401
|
+
`We've found ${c.bold(todosToFix.length)} warning(s) in the schema.${todosToFix.length ? " Apply patches to fix them in the original schema." : ""}`
|
|
207402
|
+
)
|
|
207403
|
+
);
|
|
207404
|
+
}
|
|
207405
|
+
|
|
206982
207406
|
async function generateFile(filepath, operationsMap, existingTypes, schemasMap, options) {
|
|
206983
207407
|
const project = await prepareFileContent({
|
|
206984
207408
|
filepath,
|
|
@@ -207615,9 +208039,23 @@ async function generate(args) {
|
|
|
207615
208039
|
// we allow to not have the config file in this command
|
|
207616
208040
|
});
|
|
207617
208041
|
const jsonOverrides = await loadJsonOverrides({
|
|
207618
|
-
|
|
208042
|
+
paths: configJSON?.patches,
|
|
207619
208043
|
apiType: args.apiType
|
|
207620
208044
|
});
|
|
208045
|
+
if (args.debug) {
|
|
208046
|
+
const overridesFilePath = join(
|
|
208047
|
+
args.cwd,
|
|
208048
|
+
"api-types",
|
|
208049
|
+
`${args.apiType}ApiTypes.overrides-result.json`
|
|
208050
|
+
);
|
|
208051
|
+
writeFileSync(
|
|
208052
|
+
overridesFilePath,
|
|
208053
|
+
lib.stringify(jsonOverrides, null, 2)
|
|
208054
|
+
);
|
|
208055
|
+
console.log(
|
|
208056
|
+
`[DEBUG] Check the overrides result in: ${c.bold(overridesFilePath)} file.`
|
|
208057
|
+
);
|
|
208058
|
+
}
|
|
207621
208059
|
const {
|
|
207622
208060
|
patchedSchema,
|
|
207623
208061
|
todosToFix,
|
|
@@ -207632,7 +208070,8 @@ async function generate(args) {
|
|
|
207632
208070
|
displayPatchingSummary({
|
|
207633
208071
|
todosToFix,
|
|
207634
208072
|
outdatedPatches,
|
|
207635
|
-
alreadyApliedPatches
|
|
208073
|
+
alreadyApliedPatches,
|
|
208074
|
+
displayPatchedLogs: args.logPatches
|
|
207636
208075
|
});
|
|
207637
208076
|
if (args.debug) {
|
|
207638
208077
|
const patchedSchemaFilename = inputFilename.replace(
|
|
@@ -207647,6 +208086,9 @@ async function generate(args) {
|
|
|
207647
208086
|
writeFileSync(patchedSchemaPath, lib.stringify(patchedSchema), {
|
|
207648
208087
|
encoding: "utf-8"
|
|
207649
208088
|
});
|
|
208089
|
+
console.log(
|
|
208090
|
+
`[DEBUG] Check the patched schema in: ${c.bold(patchedSchemaPath)} file.`
|
|
208091
|
+
);
|
|
207650
208092
|
}
|
|
207651
208093
|
const astSchema = await openapiTS(patchedSchema, {
|
|
207652
208094
|
version: +(process.env.OPENAPI_VERSION || 3),
|
|
@@ -207727,6 +208169,7 @@ async function generate(args) {
|
|
|
207727
208169
|
writeFileSync(fullOutputFilePath, schema, {
|
|
207728
208170
|
encoding: "utf-8"
|
|
207729
208171
|
});
|
|
208172
|
+
console.log(`[DEBUG]: Debug Schema saved to ${fullOutputFilePath}`);
|
|
207730
208173
|
schema = await format$1(schema, {
|
|
207731
208174
|
// semi: false,
|
|
207732
208175
|
parser: "typescript"
|
|
@@ -207761,6 +208204,9 @@ async function generate(args) {
|
|
|
207761
208204
|
writeFileSync(fullOutputFilePath, schema, {
|
|
207762
208205
|
encoding: "utf-8"
|
|
207763
208206
|
});
|
|
208207
|
+
console.log(
|
|
208208
|
+
`[DEBUG] Check the generated schema in: ${c.bold(fullOutputFilePath)} file.`
|
|
208209
|
+
);
|
|
207764
208210
|
}
|
|
207765
208211
|
const overridesFilepath = join(
|
|
207766
208212
|
args.cwd,
|
|
@@ -207921,6 +208367,10 @@ Check whether the .env file is created.
|
|
|
207921
208367
|
});
|
|
207922
208368
|
const content = formatted.trim();
|
|
207923
208369
|
const dir = args.cwd;
|
|
208370
|
+
const apiTypesDir = join(dir, "api-types");
|
|
208371
|
+
if (!existsSync(apiTypesDir)) {
|
|
208372
|
+
mkdirSync(apiTypesDir);
|
|
208373
|
+
}
|
|
207924
208374
|
const filePath = join("api-types", outputFilename);
|
|
207925
208375
|
writeFileSync(join(dir, filePath), content, {
|
|
207926
208376
|
encoding: "utf-8"
|
|
@@ -208093,9 +208543,20 @@ async function validateJson(args) {
|
|
|
208093
208543
|
}
|
|
208094
208544
|
const errors = [];
|
|
208095
208545
|
const jsonOverrides = await loadJsonOverrides({
|
|
208096
|
-
|
|
208546
|
+
paths: configJSON.patches,
|
|
208097
208547
|
apiType: args.apiType
|
|
208098
208548
|
});
|
|
208549
|
+
if (args.debug) {
|
|
208550
|
+
const overridesFilePath = join(
|
|
208551
|
+
args.cwd,
|
|
208552
|
+
"api-types",
|
|
208553
|
+
`${args.apiType}ApiTypes.overrides-result.json`
|
|
208554
|
+
);
|
|
208555
|
+
writeFileSync(overridesFilePath, lib.stringify(jsonOverrides, null, 2));
|
|
208556
|
+
console.log(
|
|
208557
|
+
`[DEBUG] Check the overrides result in: ${c.bold(overridesFilePath)} file.`
|
|
208558
|
+
);
|
|
208559
|
+
}
|
|
208099
208560
|
for (const [schemaName, schema] of Object.entries(
|
|
208100
208561
|
fileContentAsJson.components?.schemas || {}
|
|
208101
208562
|
)) {
|
|
@@ -208175,7 +208636,8 @@ async function validateJson(args) {
|
|
|
208175
208636
|
todosToFix,
|
|
208176
208637
|
errors,
|
|
208177
208638
|
outdatedPatches,
|
|
208178
|
-
alreadyApliedPatches
|
|
208639
|
+
alreadyApliedPatches,
|
|
208640
|
+
displayPatchedLogs: args.logPatches
|
|
208179
208641
|
});
|
|
208180
208642
|
console.log(
|
|
208181
208643
|
endpointsMissingInSchema > 0 ? c.red("\u274C") : c.green("\u2714\uFE0F"),
|
|
@@ -208225,6 +208687,10 @@ yargs(hideBin(process.argv)).scriptName("@shopware/api-gen").usage("$0 [args]").
|
|
|
208225
208687
|
type: "boolean",
|
|
208226
208688
|
default: false,
|
|
208227
208689
|
describe: "show debug information and generate intermediate files"
|
|
208690
|
+
}).option("logPatches", {
|
|
208691
|
+
type: "boolean",
|
|
208692
|
+
default: false,
|
|
208693
|
+
describe: "show patched logs"
|
|
208228
208694
|
}).help();
|
|
208229
208695
|
},
|
|
208230
208696
|
async (args) => generate(args)
|
|
@@ -208253,6 +208719,14 @@ yargs(hideBin(process.argv)).scriptName("@shopware/api-gen").usage("$0 [args]").
|
|
|
208253
208719
|
}).positional("filename", {
|
|
208254
208720
|
type: "string",
|
|
208255
208721
|
describe: "name of the schema json file. The default (based on apiType parameter) is 'storeApiSchema.json' or 'adminApiSchema.json'"
|
|
208722
|
+
}).option("logPatches", {
|
|
208723
|
+
type: "boolean",
|
|
208724
|
+
default: false,
|
|
208725
|
+
describe: "show patched logs"
|
|
208726
|
+
}).positional("debug", {
|
|
208727
|
+
type: "boolean",
|
|
208728
|
+
default: false,
|
|
208729
|
+
describe: "show debug information and generate intermediate files"
|
|
208256
208730
|
}).help();
|
|
208257
208731
|
},
|
|
208258
208732
|
async (args) => validateJson(args)
|