@shopware/api-gen 1.5.1 → 1.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { g as generate, l as loadSchema, v as validateJson } from './shared/api-gen.DDkIkZIo.mjs';
1
+ export { g as generate, l as loadSchema, v as validateJson } from './shared/api-gen.DwUlbL4g.mjs';
2
2
  import 'node:fs';
3
3
  import 'node:path';
4
4
  import 'ofetch';
@@ -2272,7 +2272,7 @@ function getKeysOfEnumerableProperties(object, compareKeys) {
2272
2272
  * with spacing, indentation, and comma
2273
2273
  * without surrounding punctuation (for example, braces)
2274
2274
  */
2275
- function printIteratorEntries(iterator, config, indentation, depth, refs, printer, separator = ": ") {
2275
+ function printIteratorEntries(iterator, config, indentation, depth, refs, printer, separator = ": ", length) {
2276
2276
  let result = "";
2277
2277
  let width = 0;
2278
2278
  let current = iterator.next();
@@ -2282,7 +2282,7 @@ function printIteratorEntries(iterator, config, indentation, depth, refs, printe
2282
2282
  while (!current.done) {
2283
2283
  result += indentationNext;
2284
2284
  if (width++ === config.maxWidth) {
2285
- result += "…";
2285
+ result += typeof length === "number" ? `…(${length - width + 1})` : "…";
2286
2286
  break;
2287
2287
  }
2288
2288
  const name = printer(current.value[0], config, indentationNext, depth, refs);
@@ -2304,7 +2304,7 @@ function printIteratorEntries(iterator, config, indentation, depth, refs, printe
2304
2304
  * with spacing, indentation, and comma
2305
2305
  * without surrounding punctuation (braces or brackets)
2306
2306
  */
2307
- function printIteratorValues(iterator, config, indentation, depth, refs, printer) {
2307
+ function printIteratorValues(iterator, config, indentation, depth, refs, printer, length) {
2308
2308
  let result = "";
2309
2309
  let width = 0;
2310
2310
  let current = iterator.next();
@@ -2314,7 +2314,7 @@ function printIteratorValues(iterator, config, indentation, depth, refs, printer
2314
2314
  while (!current.done) {
2315
2315
  result += indentationNext;
2316
2316
  if (width++ === config.maxWidth) {
2317
- result += "…";
2317
+ result += typeof length === "number" ? `…(${length - width + 1})` : "…";
2318
2318
  break;
2319
2319
  }
2320
2320
  result += printer(current.value, config, indentationNext, depth, refs);
@@ -2345,7 +2345,7 @@ function printListItems(list, config, indentation, depth, refs, printer) {
2345
2345
  for (let i = 0; i < length; i++) {
2346
2346
  result += indentationNext;
2347
2347
  if (i === config.maxWidth) {
2348
- result += "…";
2348
+ result += `…(${length - i})`;
2349
2349
  break;
2350
2350
  }
2351
2351
  if (isDataView(list) || i in list) {
@@ -2366,17 +2366,22 @@ function printListItems(list, config, indentation, depth, refs, printer) {
2366
2366
  * with spacing, indentation, and comma
2367
2367
  * without surrounding punctuation (for example, braces)
2368
2368
  */
2369
- function printObjectProperties(val, config, indentation, depth, refs, printer) {
2369
+ function printObjectProperties(val, config, indentation, depth, refs, printer, compareKeysOverride = config.compareKeys) {
2370
2370
  let result = "";
2371
- const keys = getKeysOfEnumerableProperties(val, config.compareKeys);
2371
+ const keys = getKeysOfEnumerableProperties(val, compareKeysOverride);
2372
2372
  if (keys.length > 0) {
2373
2373
  result += config.spacingOuter;
2374
2374
  const indentationNext = indentation + config.indent;
2375
2375
  for (let i = 0; i < keys.length; i++) {
2376
+ result += indentationNext;
2377
+ if (i === config.maxWidth) {
2378
+ result += `…(${keys.length - i})`;
2379
+ break;
2380
+ }
2376
2381
  const key = keys[i];
2377
- const name = printer(key, config, indentationNext, depth, refs);
2382
+ const name = !config.quoteKeys && isUnquotableKey(key) ? key : printer(key, config, indentationNext, depth, refs);
2378
2383
  const value = printer(val[key], config, indentationNext, depth, refs);
2379
- result += `${indentationNext + name}: ${value}`;
2384
+ result += `${name}: ${value}`;
2380
2385
  if (i < keys.length - 1) {
2381
2386
  result += `,${config.spacingInner}`;
2382
2387
  } else if (!config.min) {
@@ -2387,6 +2392,12 @@ function printObjectProperties(val, config, indentation, depth, refs, printer) {
2387
2392
  }
2388
2393
  return result;
2389
2394
  }
2395
+ // https://github.com/nodejs/node/blob/61102cdbb3d59155ad5bb4fc9419627a31e63f7a/lib/internal/util/inspect.js#L249
2396
+ // /^[a-zA-Z_][a-zA-Z_0-9]*$/
2397
+ const keyStrRegExp = /^[a-z_]\w*$/i;
2398
+ function isUnquotableKey(key) {
2399
+ return typeof key === "string" && key !== "__proto__" && keyStrRegExp.test(key);
2400
+ }
2390
2401
 
2391
2402
  const asymmetricMatcher = typeof Symbol === "function" && Symbol.for ? Symbol.for("jest.asymmetricMatcher") : 1267621;
2392
2403
  const SPACE$2 = " ";
@@ -2463,7 +2474,7 @@ function printProps(keys, props, config, indentation, depth, refs, printer) {
2463
2474
  return keys.map((key) => {
2464
2475
  const value = props[key];
2465
2476
  // hidden injected value that should not be printed
2466
- if (typeof value === "string" && value[0] === "_" && value.startsWith("__vitest_") && value.match(/__vitest_\d+__/)) {
2477
+ if (typeof value === "string" && value[0] === "_" && value.startsWith("__vitest_") && /__vitest_\d+__/.test(value)) {
2467
2478
  return "";
2468
2479
  }
2469
2480
  let printed = printer(value, config, indentationNext, depth, refs);
@@ -2561,7 +2572,7 @@ const plugin$3 = {
2561
2572
  test: test$3
2562
2573
  };
2563
2574
 
2564
- // SENTINEL constants are from https://github.com/facebook/immutable-js
2575
+ // SENTINEL constants are from https://github.com/immutable-js/immutable-js
2565
2576
  const IS_ITERABLE_SENTINEL = "@@__IMMUTABLE_ITERABLE__@@";
2566
2577
  const IS_LIST_SENTINEL = "@@__IMMUTABLE_LIST__@@";
2567
2578
  const IS_KEYED_SENTINEL = "@@__IMMUTABLE_KEYED__@@";
@@ -2608,7 +2619,9 @@ function printImmutableSeq(val, config, indentation, depth, refs, printer) {
2608
2619
  return printAsLeaf(name);
2609
2620
  }
2610
2621
  if (val[IS_KEYED_SENTINEL]) {
2611
- return `${name + SPACE}{${val._iter || val._object ? printIteratorEntries(val.entries(), config, indentation, depth, refs, printer) : LAZY}}`;
2622
+ return `${name + SPACE}{${
2623
+ // from Immutable collection of entries or from ECMAScript object
2624
+ val._iter || val._object ? printIteratorEntries(val.entries(), config, indentation, depth, refs, printer) : LAZY}}`;
2612
2625
  }
2613
2626
  return `${name + SPACE}[${val._iter || val._array || val._collection || val._iterable ? printIteratorValues(val.values(), config, indentation, depth, refs, printer) : LAZY}]`;
2614
2627
  }
@@ -2991,7 +3004,7 @@ function printError(val) {
2991
3004
  * The first port of call for printing an object, handles most of the
2992
3005
  * data-types in JS.
2993
3006
  */
2994
- function printBasicValue(val, printFunctionName, escapeRegex, escapeString) {
3007
+ function printBasicValue(val, printFunctionName, escapeRegex, escapeString, singleQuote) {
2995
3008
  if (val === true || val === false) {
2996
3009
  return `${val}`;
2997
3010
  }
@@ -3009,10 +3022,15 @@ function printBasicValue(val, printFunctionName, escapeRegex, escapeString) {
3009
3022
  return printBigInt(val);
3010
3023
  }
3011
3024
  if (typeOf === "string") {
3025
+ const q = singleQuote ? "'" : "\"";
3012
3026
  if (escapeString) {
3013
- return `"${val.replaceAll(/"|\\/g, "\\$&")}"`;
3027
+ // escape quote in each case, e.g.
3028
+ // it's me -> 'it\'s me'
3029
+ // say "hi" -> "say \"hi\""
3030
+ const escapePattern = singleQuote ? /['\\]/g : /["\\]/g;
3031
+ return `${q}${val.replaceAll(escapePattern, "\\$&")}${q}`;
3014
3032
  }
3015
- return `"${val}"`;
3033
+ return `${q}${val}${q}`;
3016
3034
  }
3017
3035
  if (typeOf === "function") {
3018
3036
  return printFunction(val, printFunctionName);
@@ -3071,17 +3089,17 @@ function printComplexValue(val, config, indentation, depth, refs, hasCalledToJSO
3071
3089
  return hitMaxDepth ? "[Arguments]" : `${min ? "" : "Arguments "}[${printListItems(val, config, indentation, depth, refs, printer)}]`;
3072
3090
  }
3073
3091
  if (isToStringedArrayType(toStringed)) {
3074
- return hitMaxDepth ? `[${val.constructor.name}]` : `${min ? "" : !config.printBasicPrototype && val.constructor.name === "Array" ? "" : `${val.constructor.name} `}[${printListItems(val, config, indentation, depth, refs, printer)}]`;
3092
+ return hitMaxDepth ? `[${val.constructor.name}]` : `${!config.printBasicPrototype && val.constructor.name === "Array" ? "" : `${val.constructor.name} `}[${printListItems(val, config, indentation, depth, refs, printer)}]`;
3075
3093
  }
3076
3094
  if (toStringed === "[object Map]") {
3077
- return hitMaxDepth ? "[Map]" : `Map {${printIteratorEntries(val.entries(), config, indentation, depth, refs, printer, " => ")}}`;
3095
+ return hitMaxDepth ? "[Map]" : `Map {${printIteratorEntries(val.entries(), config, indentation, depth, refs, printer, " => ", val.size)}}`;
3078
3096
  }
3079
3097
  if (toStringed === "[object Set]") {
3080
- return hitMaxDepth ? "[Set]" : `Set {${printIteratorValues(val.values(), config, indentation, depth, refs, printer)}}`;
3098
+ return hitMaxDepth ? "[Set]" : `Set {${printIteratorValues(val.values(), config, indentation, depth, refs, printer, val.size)}}`;
3081
3099
  }
3082
3100
  // Avoid failure to serialize global window object in jsdom test environment.
3083
3101
  // For example, not even relevant if window is prop of React element.
3084
- return hitMaxDepth || isWindow(val) ? `[${getConstructorName$1(val)}]` : `${min ? "" : !config.printBasicPrototype && getConstructorName$1(val) === "Object" ? "" : `${getConstructorName$1(val)} `}{${printObjectProperties(val, config, indentation, depth, refs, printer)}}`;
3102
+ return hitMaxDepth || isWindow(val) ? `[${getConstructorName$1(val)}]` : `${!config.printBasicPrototype && getConstructorName$1(val) === "Object" ? "" : `${getConstructorName$1(val)} `}{${printObjectProperties(val, config, indentation, depth, refs, printer)}}`;
3085
3103
  }
3086
3104
  const ErrorPlugin = {
3087
3105
  test: (val) => val && val instanceof Error,
@@ -3099,7 +3117,7 @@ const ErrorPlugin = {
3099
3117
  ...rest
3100
3118
  };
3101
3119
  const name = val.name !== "Error" ? val.name : getConstructorName$1(val);
3102
- return hitMaxDepth ? `[${name}]` : `${name} {${printIteratorEntries(Object.entries(entries).values(), config, indentation, depth, refs, printer)}}`;
3120
+ return hitMaxDepth ? `[${name}]` : `${name} {${printObjectProperties(entries, config, indentation, depth, refs, printer, null)}}`;
3103
3121
  }
3104
3122
  };
3105
3123
  function isNewPlugin(plugin) {
@@ -3142,7 +3160,7 @@ function printer(val, config, indentation, depth, refs, hasCalledToJSON) {
3142
3160
  if (plugin !== null) {
3143
3161
  result = printPlugin(plugin, val, config, indentation, depth, refs);
3144
3162
  } else {
3145
- const basicResult = printBasicValue(val, config.printFunctionName, config.escapeRegex, config.escapeString);
3163
+ const basicResult = printBasicValue(val, config.printFunctionName, config.escapeRegex, config.escapeString, config.singleQuote);
3146
3164
  if (basicResult !== null) {
3147
3165
  result = basicResult;
3148
3166
  } else {
@@ -3178,6 +3196,8 @@ const DEFAULT_OPTIONS = {
3178
3196
  highlight: false,
3179
3197
  indent: 2,
3180
3198
  maxDepth: Number.POSITIVE_INFINITY,
3199
+ // Practical default hard-limit to avoid too long string being generated
3200
+ // (Node's limit is buffer.constants.MAX_STRING_LENGTH ~ 512MB)
3181
3201
  maxOutputLength: 1e6,
3182
3202
  maxWidth: Number.POSITIVE_INFINITY,
3183
3203
  min: false,
@@ -3185,7 +3205,11 @@ const DEFAULT_OPTIONS = {
3185
3205
  printBasicPrototype: true,
3186
3206
  printFunctionName: true,
3187
3207
  printShadowRoot: true,
3188
- theme: DEFAULT_THEME
3208
+ theme: DEFAULT_THEME,
3209
+ singleQuote: false,
3210
+ quoteKeys: true,
3211
+ spacingInner: "\n",
3212
+ spacingOuter: "\n"
3189
3213
  };
3190
3214
  function validateOptions(options) {
3191
3215
  for (const key of Object.keys(options)) {
@@ -3239,11 +3263,13 @@ function getConfig(options) {
3239
3263
  maxWidth: options?.maxWidth ?? DEFAULT_OPTIONS.maxWidth,
3240
3264
  min: options?.min ?? DEFAULT_OPTIONS.min,
3241
3265
  plugins: options?.plugins ?? DEFAULT_OPTIONS.plugins,
3242
- printBasicPrototype: options?.printBasicPrototype ?? true,
3266
+ printBasicPrototype: options?.printBasicPrototype ?? !options?.min,
3243
3267
  printFunctionName: getPrintFunctionName(options),
3244
3268
  printShadowRoot: options?.printShadowRoot ?? true,
3245
- spacingInner: options?.min ? " " : "\n",
3246
- spacingOuter: options?.min ? "" : "\n",
3269
+ spacingInner: options?.spacingInner ?? (options?.min ? " " : "\n"),
3270
+ spacingOuter: options?.spacingOuter ?? (options?.min ? "" : "\n"),
3271
+ singleQuote: options?.singleQuote ?? DEFAULT_OPTIONS.singleQuote,
3272
+ quoteKeys: options?.quoteKeys ?? DEFAULT_OPTIONS.quoteKeys,
3247
3273
  maxOutputLength: options?.maxOutputLength ?? DEFAULT_OPTIONS.maxOutputLength,
3248
3274
  _outputLengthPerDepth: []
3249
3275
  };
@@ -3259,18 +3285,17 @@ function createIndent(indent) {
3259
3285
  function format(val, options) {
3260
3286
  if (options) {
3261
3287
  validateOptions(options);
3262
- if (options.plugins) {
3263
- const plugin = findPlugin(options.plugins, val);
3264
- if (plugin !== null) {
3265
- return printPlugin(plugin, val, getConfig(options), "", 0, []);
3266
- }
3267
- }
3268
3288
  }
3269
- const basicResult = printBasicValue(val, getPrintFunctionName(options), getEscapeRegex(options), getEscapeString(options));
3289
+ const config = getConfig(options);
3290
+ const plugin = findPlugin(config.plugins, val);
3291
+ if (plugin !== null) {
3292
+ return printPlugin(plugin, val, config, "", 0, []);
3293
+ }
3294
+ const basicResult = printBasicValue(val, config.printFunctionName, config.escapeRegex, config.escapeString, config.singleQuote);
3270
3295
  if (basicResult !== null) {
3271
3296
  return basicResult;
3272
3297
  }
3273
- return printComplexValue(val, getConfig(options), "", 0, []);
3298
+ return printComplexValue(val, config, "", 0, []);
3274
3299
  }
3275
3300
  const plugins = {
3276
3301
  AsymmetricMatcher: plugin$5,
@@ -8943,6 +8968,7 @@ function eq(a, b, aStack, bStack, customTesters, hasKey) {
8943
8968
  // of `NaN` are equivalent.
8944
8969
  return numA === numB || Number.isNaN(numA) && Number.isNaN(numB);
8945
8970
  }
8971
+ // RegExps are compared by their source patterns and flags.
8946
8972
  case "[object RegExp]": return a.source === b.source && a.flags === b.flags;
8947
8973
  case "[object Temporal.Instant]":
8948
8974
  case "[object Temporal.ZonedDateTime]":
@@ -9055,7 +9081,13 @@ if (!Object.hasOwn(globalThis, MATCHERS_OBJECT)) {
9055
9081
  const matchers = Object.create(null);
9056
9082
  const customEqualityTesters = [];
9057
9083
  const asymmetricMatchers = Object.create(null);
9058
- Object.defineProperty(globalThis, MATCHERS_OBJECT, { get: () => globalState });
9084
+ // `configurable` so that vm pools can strip the accessors from a disposed
9085
+ // context: the getters capture the expect state, which would otherwise keep
9086
+ // the whole test-file world reachable from the leaked context shell
9087
+ Object.defineProperty(globalThis, MATCHERS_OBJECT, {
9088
+ configurable: true,
9089
+ get: () => globalState
9090
+ });
9059
9091
  Object.defineProperty(globalThis, JEST_MATCHERS_OBJECT, {
9060
9092
  configurable: true,
9061
9093
  get: () => ({
@@ -9064,7 +9096,10 @@ if (!Object.hasOwn(globalThis, MATCHERS_OBJECT)) {
9064
9096
  customEqualityTesters
9065
9097
  })
9066
9098
  });
9067
- Object.defineProperty(globalThis, ASYMMETRIC_MATCHERS_OBJECT, { get: () => asymmetricMatchers });
9099
+ Object.defineProperty(globalThis, ASYMMETRIC_MATCHERS_OBJECT, {
9100
+ configurable: true,
9101
+ get: () => asymmetricMatchers
9102
+ });
9068
9103
  }
9069
9104
 
9070
9105
  const KEYS_TO_HANDLE = ["oneOf", "anyOf", "allOf", "not", "$ref"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopware/api-gen",
3
- "version": "1.5.1",
3
+ "version": "1.5.3",
4
4
  "description": "Shopware CLI for API client generation.",
5
5
  "author": "Shopware",
6
6
  "type": "module",
@@ -37,21 +37,23 @@
37
37
  "devDependencies": {
38
38
  "@types/yargs": "17.0.35",
39
39
  "@typescript/native-preview": "7.0.0-dev.20260205.1",
40
- "@vitest/coverage-v8": "4.1.10",
40
+ "@vitest/coverage-v8": "5.0.0",
41
+ "@vitest/expect": "5.0.0",
42
+ "@vitest/utils": "5.0.0",
41
43
  "json5": "2.2.3",
42
44
  "picocolors": "1.1.1",
43
45
  "unbuild": "3.6.1",
44
- "vitest": "4.1.10",
46
+ "vitest": "5.0.0",
45
47
  "tsconfig": "0.0.0"
46
48
  },
47
49
  "dependencies": {
48
50
  "ofetch": "1.5.1",
49
- "openapi-typescript": "7.8.0",
50
- "oxfmt": "0.58.0",
51
+ "openapi-typescript": "7.13.0",
52
+ "oxfmt": "0.65.0",
51
53
  "ts-morph": "27.0.2",
52
54
  "typescript": "5.9.3",
53
55
  "yargs": "18.0.0",
54
- "@shopware/api-client": "1.5.1"
56
+ "@shopware/api-client": "1.7.0"
55
57
  },
56
58
  "scripts": {
57
59
  "build": "unbuild",