orval 6.20.0 → 6.21.0

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.
File without changes
package/dist/bin/orval.js CHANGED
@@ -29,6 +29,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
29
29
  // ../../node_modules/lodash.omit/index.js
30
30
  var require_lodash = __commonJS({
31
31
  "../../node_modules/lodash.omit/index.js"(exports2, module2) {
32
+ "use strict";
32
33
  var LARGE_ARRAY_SIZE = 200;
33
34
  var HASH_UNDEFINED = "__lodash_hash_undefined__";
34
35
  var INFINITY = 1 / 0;
@@ -3252,13 +3253,13 @@ var import_lodash = __toESM(require_lodash());
3252
3253
 
3253
3254
  // src/api.ts
3254
3255
  var import_core2 = require("@orval/core");
3255
- var import_msw2 = require("@orval/msw");
3256
+ var import_mock = require("@orval/mock");
3256
3257
 
3257
3258
  // src/client.ts
3258
3259
  var import_angular = __toESM(require("@orval/angular"));
3259
3260
  var import_axios = __toESM(require("@orval/axios"));
3260
3261
  var import_core = require("@orval/core");
3261
- var import_msw = require("@orval/msw");
3262
+ var mock = __toESM(require("@orval/mock"));
3262
3263
  var import_query = __toESM(require("@orval/query"));
3263
3264
  var import_swr = __toESM(require("@orval/swr"));
3264
3265
  var import_zod = __toESM(require("@orval/zod"));
@@ -3326,7 +3327,7 @@ var generateClientHeader = ({
3326
3327
  provideIn,
3327
3328
  hasAwaitedType
3328
3329
  }) : "",
3329
- implementationMSW: `export const ${titles.implementationMSW} = () => [
3330
+ implementationMock: `export const ${titles.implementationMock} = () => [
3330
3331
  `
3331
3332
  };
3332
3333
  };
@@ -3341,7 +3342,7 @@ var generateClientFooter = ({
3341
3342
  if (!footer) {
3342
3343
  return {
3343
3344
  implementation: "",
3344
- implementationMSW: `]
3345
+ implementationMock: `]
3345
3346
  `
3346
3347
  };
3347
3348
  }
@@ -3372,7 +3373,7 @@ var generateClientFooter = ({
3372
3373
  }
3373
3374
  return {
3374
3375
  implementation,
3375
- implementationMSW: `]
3376
+ implementationMock: `]
3376
3377
  `
3377
3378
  };
3378
3379
  };
@@ -3385,22 +3386,22 @@ var generateClientTitle = ({
3385
3386
  if (!generatorTitle) {
3386
3387
  return {
3387
3388
  implementation: "",
3388
- implementationMSW: `get${(0, import_core.pascal)(title)}MSW`
3389
+ implementationMock: `get${(0, import_core.pascal)(title)}Mock`
3389
3390
  };
3390
3391
  }
3391
3392
  if (customTitleFunc) {
3392
3393
  const customTitle = customTitleFunc(title);
3393
3394
  return {
3394
3395
  implementation: generatorTitle(customTitle),
3395
- implementationMSW: `get${(0, import_core.pascal)(customTitle)}MSW`
3396
+ implementationMock: `get${(0, import_core.pascal)(customTitle)}Mock`
3396
3397
  };
3397
3398
  }
3398
3399
  return {
3399
3400
  implementation: generatorTitle(title),
3400
- implementationMSW: `get${(0, import_core.pascal)(title)}MSW`
3401
+ implementationMock: `get${(0, import_core.pascal)(title)}Mock`
3401
3402
  };
3402
3403
  };
3403
- var generateMock = (verbOption, options) => {
3404
+ var generateMock2 = (verbOption, options) => {
3404
3405
  if (!options.mock) {
3405
3406
  return {
3406
3407
  implementation: {
@@ -3413,7 +3414,7 @@ var generateMock = (verbOption, options) => {
3413
3414
  if ((0, import_core.isFunction)(options.mock)) {
3414
3415
  return options.mock(verbOption, options);
3415
3416
  }
3416
- return (0, import_msw.generateMSW)(verbOption, options);
3417
+ return mock.generateMock(verbOption, options);
3417
3418
  };
3418
3419
  var generateOperations = (outputClient = DEFAULT_CLIENT, verbsOptions, options) => {
3419
3420
  return (0, import_core.asyncReduce)(
@@ -3421,15 +3422,15 @@ var generateOperations = (outputClient = DEFAULT_CLIENT, verbsOptions, options)
3421
3422
  async (acc, verbOption) => {
3422
3423
  const { client: generatorClient } = getGeneratorClient(outputClient);
3423
3424
  const client = await generatorClient(verbOption, options, outputClient);
3424
- const msw = generateMock(verbOption, options);
3425
+ const generatedMock = generateMock2(verbOption, options);
3425
3426
  if (!client.implementation) {
3426
3427
  return acc;
3427
3428
  }
3428
3429
  acc[verbOption.operationId] = {
3429
3430
  implementation: verbOption.doc + client.implementation,
3430
3431
  imports: client.imports,
3431
- implementationMSW: msw.implementation,
3432
- importsMSW: msw.imports,
3432
+ implementationMock: generatedMock.implementation,
3433
+ importsMock: generatedMock.imports,
3433
3434
  tags: verbOption.tags,
3434
3435
  mutator: verbOption.mutator,
3435
3436
  clientMutators: client.mutators,
@@ -3515,7 +3516,7 @@ var getApiBuilder = async ({
3515
3516
  pathRoute,
3516
3517
  override: output.override,
3517
3518
  context: resolvedContext,
3518
- mock: !!output.mock,
3519
+ mock: output.mock,
3519
3520
  output: output.target
3520
3521
  }
3521
3522
  );
@@ -3535,7 +3536,7 @@ var getApiBuilder = async ({
3535
3536
  header: generateClientHeader,
3536
3537
  footer: generateClientFooter,
3537
3538
  imports: generateClientImports,
3538
- importsMock: import_msw2.generateMSWImports
3539
+ importsMock: import_mock.generateMockImports
3539
3540
  };
3540
3541
  };
3541
3542
 
@@ -3755,13 +3756,14 @@ var importSpecs = async (workspace, options) => {
3755
3756
 
3756
3757
  // src/utils/options.ts
3757
3758
  var import_core7 = require("@orval/core");
3759
+ var import_mock2 = require("@orval/mock");
3758
3760
  var import_chalk2 = __toESM(require("chalk"));
3759
3761
 
3760
3762
  // package.json
3761
3763
  var package_default = {
3762
3764
  name: "orval",
3763
3765
  description: "A swagger client generator for typescript",
3764
- version: "6.20.0",
3766
+ version: "6.21.0",
3765
3767
  license: "MIT",
3766
3768
  files: [
3767
3769
  "dist"
@@ -3813,13 +3815,13 @@ var package_default = {
3813
3815
  },
3814
3816
  dependencies: {
3815
3817
  "@apidevtools/swagger-parser": "^10.1.0",
3816
- "@orval/angular": "6.20.0",
3817
- "@orval/axios": "6.20.0",
3818
- "@orval/core": "6.20.0",
3819
- "@orval/msw": "6.20.0",
3820
- "@orval/query": "6.20.0",
3821
- "@orval/swr": "6.20.0",
3822
- "@orval/zod": "6.20.0",
3818
+ "@orval/angular": "6.21.0",
3819
+ "@orval/axios": "6.21.0",
3820
+ "@orval/core": "6.21.0",
3821
+ "@orval/mock": "6.21.0",
3822
+ "@orval/query": "6.21.0",
3823
+ "@orval/swr": "6.21.0",
3824
+ "@orval/zod": "6.21.0",
3823
3825
  ajv: "^8.12.0",
3824
3826
  cac: "^6.7.14",
3825
3827
  chalk: "^4.1.2",
@@ -3827,7 +3829,7 @@ var package_default = {
3827
3829
  enquirer: "^2.4.1",
3828
3830
  execa: "^5.1.1",
3829
3831
  "find-up": "5.0.0",
3830
- "fs-extra": "^10.1.0",
3832
+ "fs-extra": "^11.1.1",
3831
3833
  "lodash.uniq": "^4.5.0",
3832
3834
  "openapi-types": "^12.1.3",
3833
3835
  "openapi3-ts": "^3.2.0",
@@ -4045,7 +4047,7 @@ var loadTsconfig = async (tsconfig, workspace = process.cwd()) => {
4045
4047
 
4046
4048
  // src/utils/options.ts
4047
4049
  var normalizeOptions = async (optionsExport, workspace = process.cwd(), globalOptions = {}) => {
4048
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja;
4050
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka;
4049
4051
  const options = await ((0, import_core7.isFunction)(optionsExport) ? optionsExport() : optionsExport);
4050
4052
  if (!options.input) {
4051
4053
  (0, import_core7.createLogger)().error(import_chalk2.default.red(`Config require an input`));
@@ -4061,7 +4063,7 @@ var normalizeOptions = async (optionsExport, workspace = process.cwd(), globalOp
4061
4063
  outputOptions.workspace || "",
4062
4064
  workspace
4063
4065
  );
4064
- const { clean, prettier, client, mode, mock, tslint } = globalOptions;
4066
+ const { clean, prettier, client, mode, tslint } = globalOptions;
4065
4067
  const tsconfig = await loadTsconfig(
4066
4068
  outputOptions.tsconfig || globalOptions.tsconfig,
4067
4069
  workspace
@@ -4070,20 +4072,31 @@ var normalizeOptions = async (optionsExport, workspace = process.cwd(), globalOp
4070
4072
  outputOptions.packageJson || globalOptions.packageJson,
4071
4073
  workspace
4072
4074
  );
4075
+ let mock2 = (_a = outputOptions.mock) != null ? _a : globalOptions.mock;
4076
+ if (typeof mock2 === "boolean" && mock2) {
4077
+ mock2 = import_mock2.DEFAULT_MOCK_OPTIONS;
4078
+ } else if (!mock2) {
4079
+ mock2 = void 0;
4080
+ } else {
4081
+ mock2 = {
4082
+ ...import_mock2.DEFAULT_MOCK_OPTIONS,
4083
+ ...mock2
4084
+ };
4085
+ }
4073
4086
  const normalizedOptions = {
4074
4087
  input: {
4075
4088
  target: globalOptions.input ? normalizePathOrUrl(globalOptions.input, process.cwd()) : normalizePathOrUrl(inputOptions.target, workspace),
4076
4089
  validation: inputOptions.validation || false,
4077
4090
  override: {
4078
4091
  transformer: normalizePath(
4079
- (_a = inputOptions.override) == null ? void 0 : _a.transformer,
4092
+ (_b = inputOptions.override) == null ? void 0 : _b.transformer,
4080
4093
  workspace
4081
4094
  )
4082
4095
  },
4083
- converterOptions: (_b = inputOptions.converterOptions) != null ? _b : {},
4096
+ converterOptions: (_c = inputOptions.converterOptions) != null ? _c : {},
4084
4097
  parserOptions: (0, import_core7.mergeDeep)(
4085
4098
  parserDefaultOptions,
4086
- (_c = inputOptions.parserOptions) != null ? _c : {}
4099
+ (_d = inputOptions.parserOptions) != null ? _d : {}
4087
4100
  ),
4088
4101
  filters: inputOptions.filters
4089
4102
  },
@@ -4091,82 +4104,83 @@ var normalizeOptions = async (optionsExport, workspace = process.cwd(), globalOp
4091
4104
  target: globalOptions.output ? normalizePath(globalOptions.output, process.cwd()) : normalizePath(outputOptions.target, outputWorkspace),
4092
4105
  schemas: normalizePath(outputOptions.schemas, outputWorkspace),
4093
4106
  workspace: outputOptions.workspace ? outputWorkspace : void 0,
4094
- client: (_e = (_d = outputOptions.client) != null ? _d : client) != null ? _e : import_core7.OutputClient.AXIOS_FUNCTIONS,
4095
- mode: normalizeOutputMode((_f = outputOptions.mode) != null ? _f : mode),
4096
- mock: (_h = (_g = outputOptions.mock) != null ? _g : mock) != null ? _h : false,
4097
- clean: (_j = (_i = outputOptions.clean) != null ? _i : clean) != null ? _j : false,
4098
- prettier: (_l = (_k = outputOptions.prettier) != null ? _k : prettier) != null ? _l : false,
4099
- tslint: (_n = (_m = outputOptions.tslint) != null ? _m : tslint) != null ? _n : false,
4107
+ client: (_f = (_e = outputOptions.client) != null ? _e : client) != null ? _f : import_core7.OutputClient.AXIOS_FUNCTIONS,
4108
+ mode: normalizeOutputMode((_g = outputOptions.mode) != null ? _g : mode),
4109
+ mock: mock2,
4110
+ clean: (_i = (_h = outputOptions.clean) != null ? _h : clean) != null ? _i : false,
4111
+ prettier: (_k = (_j = outputOptions.prettier) != null ? _j : prettier) != null ? _k : false,
4112
+ tslint: (_m = (_l = outputOptions.tslint) != null ? _l : tslint) != null ? _m : false,
4100
4113
  tsconfig,
4101
4114
  packageJson,
4102
- headers: (_o = outputOptions.headers) != null ? _o : false,
4103
- indexFiles: (_p = outputOptions.indexFiles) != null ? _p : true,
4115
+ headers: (_n = outputOptions.headers) != null ? _n : false,
4116
+ indexFiles: (_o = outputOptions.indexFiles) != null ? _o : true,
4104
4117
  baseUrl: outputOptions.baseUrl,
4105
4118
  override: {
4106
4119
  ...outputOptions.override,
4107
4120
  mock: {
4108
- arrayMin: (_s = (_r = (_q = outputOptions.override) == null ? void 0 : _q.mock) == null ? void 0 : _r.arrayMin) != null ? _s : 1,
4109
- arrayMax: (_v = (_u = (_t = outputOptions.override) == null ? void 0 : _t.mock) == null ? void 0 : _u.arrayMax) != null ? _v : 10,
4110
- ...(_x = (_w = outputOptions.override) == null ? void 0 : _w.mock) != null ? _x : {}
4121
+ arrayMin: (_r = (_q = (_p = outputOptions.override) == null ? void 0 : _p.mock) == null ? void 0 : _q.arrayMin) != null ? _r : 1,
4122
+ arrayMax: (_u = (_t = (_s = outputOptions.override) == null ? void 0 : _s.mock) == null ? void 0 : _t.arrayMax) != null ? _u : 10,
4123
+ ...(_w = (_v = outputOptions.override) == null ? void 0 : _v.mock) != null ? _w : {}
4111
4124
  },
4112
4125
  operations: normalizeOperationsAndTags(
4113
- (_z = (_y = outputOptions.override) == null ? void 0 : _y.operations) != null ? _z : {},
4126
+ (_y = (_x = outputOptions.override) == null ? void 0 : _x.operations) != null ? _y : {},
4114
4127
  outputWorkspace
4115
4128
  ),
4116
4129
  tags: normalizeOperationsAndTags(
4117
- (_B = (_A = outputOptions.override) == null ? void 0 : _A.tags) != null ? _B : {},
4130
+ (_A = (_z = outputOptions.override) == null ? void 0 : _z.tags) != null ? _A : {},
4118
4131
  outputWorkspace
4119
4132
  ),
4120
4133
  mutator: normalizeMutator(
4121
4134
  outputWorkspace,
4122
- (_C = outputOptions.override) == null ? void 0 : _C.mutator
4135
+ (_B = outputOptions.override) == null ? void 0 : _B.mutator
4123
4136
  ),
4124
- formData: (_G = !(0, import_core7.isBoolean)((_D = outputOptions.override) == null ? void 0 : _D.formData) ? normalizeMutator(
4137
+ formData: (_F = !(0, import_core7.isBoolean)((_C = outputOptions.override) == null ? void 0 : _C.formData) ? normalizeMutator(
4125
4138
  outputWorkspace,
4126
- (_E = outputOptions.override) == null ? void 0 : _E.formData
4127
- ) : (_F = outputOptions.override) == null ? void 0 : _F.formData) != null ? _G : true,
4128
- formUrlEncoded: (_K = !(0, import_core7.isBoolean)((_H = outputOptions.override) == null ? void 0 : _H.formUrlEncoded) ? normalizeMutator(
4139
+ (_D = outputOptions.override) == null ? void 0 : _D.formData
4140
+ ) : (_E = outputOptions.override) == null ? void 0 : _E.formData) != null ? _F : true,
4141
+ formUrlEncoded: (_J = !(0, import_core7.isBoolean)((_G = outputOptions.override) == null ? void 0 : _G.formUrlEncoded) ? normalizeMutator(
4129
4142
  outputWorkspace,
4130
- (_I = outputOptions.override) == null ? void 0 : _I.formUrlEncoded
4131
- ) : (_J = outputOptions.override) == null ? void 0 : _J.formUrlEncoded) != null ? _K : true,
4143
+ (_H = outputOptions.override) == null ? void 0 : _H.formUrlEncoded
4144
+ ) : (_I = outputOptions.override) == null ? void 0 : _I.formUrlEncoded) != null ? _J : true,
4132
4145
  paramsSerializer: normalizeMutator(
4133
4146
  outputWorkspace,
4134
- (_L = outputOptions.override) == null ? void 0 : _L.paramsSerializer
4147
+ (_K = outputOptions.override) == null ? void 0 : _K.paramsSerializer
4135
4148
  ),
4136
- header: ((_M = outputOptions.override) == null ? void 0 : _M.header) === false ? false : (0, import_core7.isFunction)((_N = outputOptions.override) == null ? void 0 : _N.header) ? (_O = outputOptions.override) == null ? void 0 : _O.header : getDefaultFilesHeader,
4137
- requestOptions: (_Q = (_P = outputOptions.override) == null ? void 0 : _P.requestOptions) != null ? _Q : true,
4149
+ header: ((_L = outputOptions.override) == null ? void 0 : _L.header) === false ? false : (0, import_core7.isFunction)((_M = outputOptions.override) == null ? void 0 : _M.header) ? (_N = outputOptions.override) == null ? void 0 : _N.header : getDefaultFilesHeader,
4150
+ requestOptions: (_P = (_O = outputOptions.override) == null ? void 0 : _O.requestOptions) != null ? _P : true,
4138
4151
  components: {
4139
4152
  schemas: {
4140
4153
  suffix: import_core7.RefComponentSuffix.schemas,
4141
- ...(_T = (_S = (_R = outputOptions.override) == null ? void 0 : _R.components) == null ? void 0 : _S.schemas) != null ? _T : {}
4154
+ ...(_S = (_R = (_Q = outputOptions.override) == null ? void 0 : _Q.components) == null ? void 0 : _R.schemas) != null ? _S : {}
4142
4155
  },
4143
4156
  responses: {
4144
4157
  suffix: import_core7.RefComponentSuffix.responses,
4145
- ...(_W = (_V = (_U = outputOptions.override) == null ? void 0 : _U.components) == null ? void 0 : _V.responses) != null ? _W : {}
4158
+ ...(_V = (_U = (_T = outputOptions.override) == null ? void 0 : _T.components) == null ? void 0 : _U.responses) != null ? _V : {}
4146
4159
  },
4147
4160
  parameters: {
4148
4161
  suffix: import_core7.RefComponentSuffix.parameters,
4149
- ...(_Z = (_Y = (_X = outputOptions.override) == null ? void 0 : _X.components) == null ? void 0 : _Y.parameters) != null ? _Z : {}
4162
+ ...(_Y = (_X = (_W = outputOptions.override) == null ? void 0 : _W.components) == null ? void 0 : _X.parameters) != null ? _Y : {}
4150
4163
  },
4151
4164
  requestBodies: {
4152
4165
  suffix: import_core7.RefComponentSuffix.requestBodies,
4153
- ...(_aa = (_$ = (__ = outputOptions.override) == null ? void 0 : __.components) == null ? void 0 : _$.requestBodies) != null ? _aa : {}
4166
+ ...(_$ = (__ = (_Z = outputOptions.override) == null ? void 0 : _Z.components) == null ? void 0 : __.requestBodies) != null ? _$ : {}
4154
4167
  }
4155
4168
  },
4156
4169
  query: {
4157
4170
  useQuery: true,
4158
4171
  useMutation: true,
4159
4172
  signal: true,
4160
- ...normalizeQueryOptions((_ba = outputOptions.override) == null ? void 0 : _ba.query, workspace)
4173
+ ...normalizeQueryOptions((_aa = outputOptions.override) == null ? void 0 : _aa.query, workspace)
4161
4174
  },
4162
4175
  swr: {
4163
- ...(_da = (_ca = outputOptions.override) == null ? void 0 : _ca.swr) != null ? _da : {}
4176
+ ...(_ca = (_ba = outputOptions.override) == null ? void 0 : _ba.swr) != null ? _ca : {}
4164
4177
  },
4165
4178
  angular: {
4166
- provideIn: (_ga = (_fa = (_ea = outputOptions.override) == null ? void 0 : _ea.angular) == null ? void 0 : _fa.provideIn) != null ? _ga : "root"
4179
+ provideIn: (_fa = (_ea = (_da = outputOptions.override) == null ? void 0 : _da.angular) == null ? void 0 : _ea.provideIn) != null ? _fa : "root"
4167
4180
  },
4168
- useDates: ((_ha = outputOptions.override) == null ? void 0 : _ha.useDates) || false,
4169
- useDeprecatedOperations: (_ja = (_ia = outputOptions.override) == null ? void 0 : _ia.useDeprecatedOperations) != null ? _ja : true
4181
+ useDates: ((_ga = outputOptions.override) == null ? void 0 : _ga.useDates) || false,
4182
+ useDeprecatedOperations: (_ia = (_ha = outputOptions.override) == null ? void 0 : _ha.useDeprecatedOperations) != null ? _ia : true,
4183
+ useNativeEnums: (_ka = (_ja = outputOptions.override) == null ? void 0 : _ja.useNativeEnums) != null ? _ka : false
4170
4184
  }
4171
4185
  },
4172
4186
  hooks: options.hooks ? normalizeHooks(options.hooks) : {}
@@ -4445,7 +4459,9 @@ var writeSpecs = async (builder, workspace, options, projectName) => {
4445
4459
  }
4446
4460
  if (output.workspace) {
4447
4461
  const workspacePath = output.workspace;
4448
- let imports = implementationPaths.filter((path) => !path.endsWith(".msw.ts")).map(
4462
+ let imports = implementationPaths.filter(
4463
+ (path) => !output.mock || !path.endsWith(`.${(0, import_core10.getMockFileExtensionByTypeName)(output.mock)}.ts`)
4464
+ ).map(
4449
4465
  (path) => import_core10.upath.relativeSafe(
4450
4466
  workspacePath,
4451
4467
  (0, import_core10.getFileInfo)(path).pathWithoutExtension
package/dist/index.js CHANGED
@@ -33,6 +33,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
33
33
  // ../../node_modules/lodash.omit/index.js
34
34
  var require_lodash = __commonJS({
35
35
  "../../node_modules/lodash.omit/index.js"(exports, module2) {
36
+ "use strict";
36
37
  var LARGE_ARRAY_SIZE = 200;
37
38
  var HASH_UNDEFINED = "__lodash_hash_undefined__";
38
39
  var INFINITY = 1 / 0;
@@ -3263,13 +3264,13 @@ var import_lodash = __toESM(require_lodash());
3263
3264
 
3264
3265
  // src/api.ts
3265
3266
  var import_core2 = require("@orval/core");
3266
- var import_msw2 = require("@orval/msw");
3267
+ var import_mock = require("@orval/mock");
3267
3268
 
3268
3269
  // src/client.ts
3269
3270
  var import_angular = __toESM(require("@orval/angular"));
3270
3271
  var import_axios = __toESM(require("@orval/axios"));
3271
3272
  var import_core = require("@orval/core");
3272
- var import_msw = require("@orval/msw");
3273
+ var mock = __toESM(require("@orval/mock"));
3273
3274
  var import_query = __toESM(require("@orval/query"));
3274
3275
  var import_swr = __toESM(require("@orval/swr"));
3275
3276
  var import_zod = __toESM(require("@orval/zod"));
@@ -3337,7 +3338,7 @@ var generateClientHeader = ({
3337
3338
  provideIn,
3338
3339
  hasAwaitedType
3339
3340
  }) : "",
3340
- implementationMSW: `export const ${titles.implementationMSW} = () => [
3341
+ implementationMock: `export const ${titles.implementationMock} = () => [
3341
3342
  `
3342
3343
  };
3343
3344
  };
@@ -3352,7 +3353,7 @@ var generateClientFooter = ({
3352
3353
  if (!footer) {
3353
3354
  return {
3354
3355
  implementation: "",
3355
- implementationMSW: `]
3356
+ implementationMock: `]
3356
3357
  `
3357
3358
  };
3358
3359
  }
@@ -3383,7 +3384,7 @@ var generateClientFooter = ({
3383
3384
  }
3384
3385
  return {
3385
3386
  implementation,
3386
- implementationMSW: `]
3387
+ implementationMock: `]
3387
3388
  `
3388
3389
  };
3389
3390
  };
@@ -3396,22 +3397,22 @@ var generateClientTitle = ({
3396
3397
  if (!generatorTitle) {
3397
3398
  return {
3398
3399
  implementation: "",
3399
- implementationMSW: `get${(0, import_core.pascal)(title)}MSW`
3400
+ implementationMock: `get${(0, import_core.pascal)(title)}Mock`
3400
3401
  };
3401
3402
  }
3402
3403
  if (customTitleFunc) {
3403
3404
  const customTitle = customTitleFunc(title);
3404
3405
  return {
3405
3406
  implementation: generatorTitle(customTitle),
3406
- implementationMSW: `get${(0, import_core.pascal)(customTitle)}MSW`
3407
+ implementationMock: `get${(0, import_core.pascal)(customTitle)}Mock`
3407
3408
  };
3408
3409
  }
3409
3410
  return {
3410
3411
  implementation: generatorTitle(title),
3411
- implementationMSW: `get${(0, import_core.pascal)(title)}MSW`
3412
+ implementationMock: `get${(0, import_core.pascal)(title)}Mock`
3412
3413
  };
3413
3414
  };
3414
- var generateMock = (verbOption, options) => {
3415
+ var generateMock2 = (verbOption, options) => {
3415
3416
  if (!options.mock) {
3416
3417
  return {
3417
3418
  implementation: {
@@ -3424,7 +3425,7 @@ var generateMock = (verbOption, options) => {
3424
3425
  if ((0, import_core.isFunction)(options.mock)) {
3425
3426
  return options.mock(verbOption, options);
3426
3427
  }
3427
- return (0, import_msw.generateMSW)(verbOption, options);
3428
+ return mock.generateMock(verbOption, options);
3428
3429
  };
3429
3430
  var generateOperations = (outputClient = DEFAULT_CLIENT, verbsOptions, options) => {
3430
3431
  return (0, import_core.asyncReduce)(
@@ -3432,15 +3433,15 @@ var generateOperations = (outputClient = DEFAULT_CLIENT, verbsOptions, options)
3432
3433
  async (acc, verbOption) => {
3433
3434
  const { client: generatorClient } = getGeneratorClient(outputClient);
3434
3435
  const client = await generatorClient(verbOption, options, outputClient);
3435
- const msw = generateMock(verbOption, options);
3436
+ const generatedMock = generateMock2(verbOption, options);
3436
3437
  if (!client.implementation) {
3437
3438
  return acc;
3438
3439
  }
3439
3440
  acc[verbOption.operationId] = {
3440
3441
  implementation: verbOption.doc + client.implementation,
3441
3442
  imports: client.imports,
3442
- implementationMSW: msw.implementation,
3443
- importsMSW: msw.imports,
3443
+ implementationMock: generatedMock.implementation,
3444
+ importsMock: generatedMock.imports,
3444
3445
  tags: verbOption.tags,
3445
3446
  mutator: verbOption.mutator,
3446
3447
  clientMutators: client.mutators,
@@ -3526,7 +3527,7 @@ var getApiBuilder = async ({
3526
3527
  pathRoute,
3527
3528
  override: output.override,
3528
3529
  context: resolvedContext,
3529
- mock: !!output.mock,
3530
+ mock: output.mock,
3530
3531
  output: output.target
3531
3532
  }
3532
3533
  );
@@ -3546,7 +3547,7 @@ var getApiBuilder = async ({
3546
3547
  header: generateClientHeader,
3547
3548
  footer: generateClientFooter,
3548
3549
  imports: generateClientImports,
3549
- importsMock: import_msw2.generateMSWImports
3550
+ importsMock: import_mock.generateMockImports
3550
3551
  };
3551
3552
  };
3552
3553
 
@@ -3766,13 +3767,14 @@ var importSpecs = async (workspace, options) => {
3766
3767
 
3767
3768
  // src/utils/options.ts
3768
3769
  var import_core7 = require("@orval/core");
3770
+ var import_mock2 = require("@orval/mock");
3769
3771
  var import_chalk2 = __toESM(require("chalk"));
3770
3772
 
3771
3773
  // package.json
3772
3774
  var package_default = {
3773
3775
  name: "orval",
3774
3776
  description: "A swagger client generator for typescript",
3775
- version: "6.20.0",
3777
+ version: "6.21.0",
3776
3778
  license: "MIT",
3777
3779
  files: [
3778
3780
  "dist"
@@ -3824,13 +3826,13 @@ var package_default = {
3824
3826
  },
3825
3827
  dependencies: {
3826
3828
  "@apidevtools/swagger-parser": "^10.1.0",
3827
- "@orval/angular": "6.20.0",
3828
- "@orval/axios": "6.20.0",
3829
- "@orval/core": "6.20.0",
3830
- "@orval/msw": "6.20.0",
3831
- "@orval/query": "6.20.0",
3832
- "@orval/swr": "6.20.0",
3833
- "@orval/zod": "6.20.0",
3829
+ "@orval/angular": "6.21.0",
3830
+ "@orval/axios": "6.21.0",
3831
+ "@orval/core": "6.21.0",
3832
+ "@orval/mock": "6.21.0",
3833
+ "@orval/query": "6.21.0",
3834
+ "@orval/swr": "6.21.0",
3835
+ "@orval/zod": "6.21.0",
3834
3836
  ajv: "^8.12.0",
3835
3837
  cac: "^6.7.14",
3836
3838
  chalk: "^4.1.2",
@@ -3838,7 +3840,7 @@ var package_default = {
3838
3840
  enquirer: "^2.4.1",
3839
3841
  execa: "^5.1.1",
3840
3842
  "find-up": "5.0.0",
3841
- "fs-extra": "^10.1.0",
3843
+ "fs-extra": "^11.1.1",
3842
3844
  "lodash.uniq": "^4.5.0",
3843
3845
  "openapi-types": "^12.1.3",
3844
3846
  "openapi3-ts": "^3.2.0",
@@ -4059,7 +4061,7 @@ function defineConfig(options) {
4059
4061
  return options;
4060
4062
  }
4061
4063
  var normalizeOptions = async (optionsExport, workspace = process.cwd(), globalOptions = {}) => {
4062
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja;
4064
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka;
4063
4065
  const options = await ((0, import_core7.isFunction)(optionsExport) ? optionsExport() : optionsExport);
4064
4066
  if (!options.input) {
4065
4067
  (0, import_core7.createLogger)().error(import_chalk2.default.red(`Config require an input`));
@@ -4075,7 +4077,7 @@ var normalizeOptions = async (optionsExport, workspace = process.cwd(), globalOp
4075
4077
  outputOptions.workspace || "",
4076
4078
  workspace
4077
4079
  );
4078
- const { clean, prettier, client, mode, mock, tslint } = globalOptions;
4080
+ const { clean, prettier, client, mode, tslint } = globalOptions;
4079
4081
  const tsconfig = await loadTsconfig(
4080
4082
  outputOptions.tsconfig || globalOptions.tsconfig,
4081
4083
  workspace
@@ -4084,20 +4086,31 @@ var normalizeOptions = async (optionsExport, workspace = process.cwd(), globalOp
4084
4086
  outputOptions.packageJson || globalOptions.packageJson,
4085
4087
  workspace
4086
4088
  );
4089
+ let mock2 = (_a = outputOptions.mock) != null ? _a : globalOptions.mock;
4090
+ if (typeof mock2 === "boolean" && mock2) {
4091
+ mock2 = import_mock2.DEFAULT_MOCK_OPTIONS;
4092
+ } else if (!mock2) {
4093
+ mock2 = void 0;
4094
+ } else {
4095
+ mock2 = {
4096
+ ...import_mock2.DEFAULT_MOCK_OPTIONS,
4097
+ ...mock2
4098
+ };
4099
+ }
4087
4100
  const normalizedOptions = {
4088
4101
  input: {
4089
4102
  target: globalOptions.input ? normalizePathOrUrl(globalOptions.input, process.cwd()) : normalizePathOrUrl(inputOptions.target, workspace),
4090
4103
  validation: inputOptions.validation || false,
4091
4104
  override: {
4092
4105
  transformer: normalizePath(
4093
- (_a = inputOptions.override) == null ? void 0 : _a.transformer,
4106
+ (_b = inputOptions.override) == null ? void 0 : _b.transformer,
4094
4107
  workspace
4095
4108
  )
4096
4109
  },
4097
- converterOptions: (_b = inputOptions.converterOptions) != null ? _b : {},
4110
+ converterOptions: (_c = inputOptions.converterOptions) != null ? _c : {},
4098
4111
  parserOptions: (0, import_core7.mergeDeep)(
4099
4112
  parserDefaultOptions,
4100
- (_c = inputOptions.parserOptions) != null ? _c : {}
4113
+ (_d = inputOptions.parserOptions) != null ? _d : {}
4101
4114
  ),
4102
4115
  filters: inputOptions.filters
4103
4116
  },
@@ -4105,82 +4118,83 @@ var normalizeOptions = async (optionsExport, workspace = process.cwd(), globalOp
4105
4118
  target: globalOptions.output ? normalizePath(globalOptions.output, process.cwd()) : normalizePath(outputOptions.target, outputWorkspace),
4106
4119
  schemas: normalizePath(outputOptions.schemas, outputWorkspace),
4107
4120
  workspace: outputOptions.workspace ? outputWorkspace : void 0,
4108
- client: (_e = (_d = outputOptions.client) != null ? _d : client) != null ? _e : import_core7.OutputClient.AXIOS_FUNCTIONS,
4109
- mode: normalizeOutputMode((_f = outputOptions.mode) != null ? _f : mode),
4110
- mock: (_h = (_g = outputOptions.mock) != null ? _g : mock) != null ? _h : false,
4111
- clean: (_j = (_i = outputOptions.clean) != null ? _i : clean) != null ? _j : false,
4112
- prettier: (_l = (_k = outputOptions.prettier) != null ? _k : prettier) != null ? _l : false,
4113
- tslint: (_n = (_m = outputOptions.tslint) != null ? _m : tslint) != null ? _n : false,
4121
+ client: (_f = (_e = outputOptions.client) != null ? _e : client) != null ? _f : import_core7.OutputClient.AXIOS_FUNCTIONS,
4122
+ mode: normalizeOutputMode((_g = outputOptions.mode) != null ? _g : mode),
4123
+ mock: mock2,
4124
+ clean: (_i = (_h = outputOptions.clean) != null ? _h : clean) != null ? _i : false,
4125
+ prettier: (_k = (_j = outputOptions.prettier) != null ? _j : prettier) != null ? _k : false,
4126
+ tslint: (_m = (_l = outputOptions.tslint) != null ? _l : tslint) != null ? _m : false,
4114
4127
  tsconfig,
4115
4128
  packageJson,
4116
- headers: (_o = outputOptions.headers) != null ? _o : false,
4117
- indexFiles: (_p = outputOptions.indexFiles) != null ? _p : true,
4129
+ headers: (_n = outputOptions.headers) != null ? _n : false,
4130
+ indexFiles: (_o = outputOptions.indexFiles) != null ? _o : true,
4118
4131
  baseUrl: outputOptions.baseUrl,
4119
4132
  override: {
4120
4133
  ...outputOptions.override,
4121
4134
  mock: {
4122
- arrayMin: (_s = (_r = (_q = outputOptions.override) == null ? void 0 : _q.mock) == null ? void 0 : _r.arrayMin) != null ? _s : 1,
4123
- arrayMax: (_v = (_u = (_t = outputOptions.override) == null ? void 0 : _t.mock) == null ? void 0 : _u.arrayMax) != null ? _v : 10,
4124
- ...(_x = (_w = outputOptions.override) == null ? void 0 : _w.mock) != null ? _x : {}
4135
+ arrayMin: (_r = (_q = (_p = outputOptions.override) == null ? void 0 : _p.mock) == null ? void 0 : _q.arrayMin) != null ? _r : 1,
4136
+ arrayMax: (_u = (_t = (_s = outputOptions.override) == null ? void 0 : _s.mock) == null ? void 0 : _t.arrayMax) != null ? _u : 10,
4137
+ ...(_w = (_v = outputOptions.override) == null ? void 0 : _v.mock) != null ? _w : {}
4125
4138
  },
4126
4139
  operations: normalizeOperationsAndTags(
4127
- (_z = (_y = outputOptions.override) == null ? void 0 : _y.operations) != null ? _z : {},
4140
+ (_y = (_x = outputOptions.override) == null ? void 0 : _x.operations) != null ? _y : {},
4128
4141
  outputWorkspace
4129
4142
  ),
4130
4143
  tags: normalizeOperationsAndTags(
4131
- (_B = (_A = outputOptions.override) == null ? void 0 : _A.tags) != null ? _B : {},
4144
+ (_A = (_z = outputOptions.override) == null ? void 0 : _z.tags) != null ? _A : {},
4132
4145
  outputWorkspace
4133
4146
  ),
4134
4147
  mutator: normalizeMutator(
4135
4148
  outputWorkspace,
4136
- (_C = outputOptions.override) == null ? void 0 : _C.mutator
4149
+ (_B = outputOptions.override) == null ? void 0 : _B.mutator
4137
4150
  ),
4138
- formData: (_G = !(0, import_core7.isBoolean)((_D = outputOptions.override) == null ? void 0 : _D.formData) ? normalizeMutator(
4151
+ formData: (_F = !(0, import_core7.isBoolean)((_C = outputOptions.override) == null ? void 0 : _C.formData) ? normalizeMutator(
4139
4152
  outputWorkspace,
4140
- (_E = outputOptions.override) == null ? void 0 : _E.formData
4141
- ) : (_F = outputOptions.override) == null ? void 0 : _F.formData) != null ? _G : true,
4142
- formUrlEncoded: (_K = !(0, import_core7.isBoolean)((_H = outputOptions.override) == null ? void 0 : _H.formUrlEncoded) ? normalizeMutator(
4153
+ (_D = outputOptions.override) == null ? void 0 : _D.formData
4154
+ ) : (_E = outputOptions.override) == null ? void 0 : _E.formData) != null ? _F : true,
4155
+ formUrlEncoded: (_J = !(0, import_core7.isBoolean)((_G = outputOptions.override) == null ? void 0 : _G.formUrlEncoded) ? normalizeMutator(
4143
4156
  outputWorkspace,
4144
- (_I = outputOptions.override) == null ? void 0 : _I.formUrlEncoded
4145
- ) : (_J = outputOptions.override) == null ? void 0 : _J.formUrlEncoded) != null ? _K : true,
4157
+ (_H = outputOptions.override) == null ? void 0 : _H.formUrlEncoded
4158
+ ) : (_I = outputOptions.override) == null ? void 0 : _I.formUrlEncoded) != null ? _J : true,
4146
4159
  paramsSerializer: normalizeMutator(
4147
4160
  outputWorkspace,
4148
- (_L = outputOptions.override) == null ? void 0 : _L.paramsSerializer
4161
+ (_K = outputOptions.override) == null ? void 0 : _K.paramsSerializer
4149
4162
  ),
4150
- header: ((_M = outputOptions.override) == null ? void 0 : _M.header) === false ? false : (0, import_core7.isFunction)((_N = outputOptions.override) == null ? void 0 : _N.header) ? (_O = outputOptions.override) == null ? void 0 : _O.header : getDefaultFilesHeader,
4151
- requestOptions: (_Q = (_P = outputOptions.override) == null ? void 0 : _P.requestOptions) != null ? _Q : true,
4163
+ header: ((_L = outputOptions.override) == null ? void 0 : _L.header) === false ? false : (0, import_core7.isFunction)((_M = outputOptions.override) == null ? void 0 : _M.header) ? (_N = outputOptions.override) == null ? void 0 : _N.header : getDefaultFilesHeader,
4164
+ requestOptions: (_P = (_O = outputOptions.override) == null ? void 0 : _O.requestOptions) != null ? _P : true,
4152
4165
  components: {
4153
4166
  schemas: {
4154
4167
  suffix: import_core7.RefComponentSuffix.schemas,
4155
- ...(_T = (_S = (_R = outputOptions.override) == null ? void 0 : _R.components) == null ? void 0 : _S.schemas) != null ? _T : {}
4168
+ ...(_S = (_R = (_Q = outputOptions.override) == null ? void 0 : _Q.components) == null ? void 0 : _R.schemas) != null ? _S : {}
4156
4169
  },
4157
4170
  responses: {
4158
4171
  suffix: import_core7.RefComponentSuffix.responses,
4159
- ...(_W = (_V = (_U = outputOptions.override) == null ? void 0 : _U.components) == null ? void 0 : _V.responses) != null ? _W : {}
4172
+ ...(_V = (_U = (_T = outputOptions.override) == null ? void 0 : _T.components) == null ? void 0 : _U.responses) != null ? _V : {}
4160
4173
  },
4161
4174
  parameters: {
4162
4175
  suffix: import_core7.RefComponentSuffix.parameters,
4163
- ...(_Z = (_Y = (_X = outputOptions.override) == null ? void 0 : _X.components) == null ? void 0 : _Y.parameters) != null ? _Z : {}
4176
+ ...(_Y = (_X = (_W = outputOptions.override) == null ? void 0 : _W.components) == null ? void 0 : _X.parameters) != null ? _Y : {}
4164
4177
  },
4165
4178
  requestBodies: {
4166
4179
  suffix: import_core7.RefComponentSuffix.requestBodies,
4167
- ...(_aa = (_$ = (__ = outputOptions.override) == null ? void 0 : __.components) == null ? void 0 : _$.requestBodies) != null ? _aa : {}
4180
+ ...(_$ = (__ = (_Z = outputOptions.override) == null ? void 0 : _Z.components) == null ? void 0 : __.requestBodies) != null ? _$ : {}
4168
4181
  }
4169
4182
  },
4170
4183
  query: {
4171
4184
  useQuery: true,
4172
4185
  useMutation: true,
4173
4186
  signal: true,
4174
- ...normalizeQueryOptions((_ba = outputOptions.override) == null ? void 0 : _ba.query, workspace)
4187
+ ...normalizeQueryOptions((_aa = outputOptions.override) == null ? void 0 : _aa.query, workspace)
4175
4188
  },
4176
4189
  swr: {
4177
- ...(_da = (_ca = outputOptions.override) == null ? void 0 : _ca.swr) != null ? _da : {}
4190
+ ...(_ca = (_ba = outputOptions.override) == null ? void 0 : _ba.swr) != null ? _ca : {}
4178
4191
  },
4179
4192
  angular: {
4180
- provideIn: (_ga = (_fa = (_ea = outputOptions.override) == null ? void 0 : _ea.angular) == null ? void 0 : _fa.provideIn) != null ? _ga : "root"
4193
+ provideIn: (_fa = (_ea = (_da = outputOptions.override) == null ? void 0 : _da.angular) == null ? void 0 : _ea.provideIn) != null ? _fa : "root"
4181
4194
  },
4182
- useDates: ((_ha = outputOptions.override) == null ? void 0 : _ha.useDates) || false,
4183
- useDeprecatedOperations: (_ja = (_ia = outputOptions.override) == null ? void 0 : _ia.useDeprecatedOperations) != null ? _ja : true
4195
+ useDates: ((_ga = outputOptions.override) == null ? void 0 : _ga.useDates) || false,
4196
+ useDeprecatedOperations: (_ia = (_ha = outputOptions.override) == null ? void 0 : _ha.useDeprecatedOperations) != null ? _ia : true,
4197
+ useNativeEnums: (_ka = (_ja = outputOptions.override) == null ? void 0 : _ja.useNativeEnums) != null ? _ka : false
4184
4198
  }
4185
4199
  },
4186
4200
  hooks: options.hooks ? normalizeHooks(options.hooks) : {}
@@ -4459,7 +4473,9 @@ var writeSpecs = async (builder, workspace, options, projectName) => {
4459
4473
  }
4460
4474
  if (output.workspace) {
4461
4475
  const workspacePath = output.workspace;
4462
- let imports = implementationPaths.filter((path) => !path.endsWith(".msw.ts")).map(
4476
+ let imports = implementationPaths.filter(
4477
+ (path) => !output.mock || !path.endsWith(`.${(0, import_core10.getMockFileExtensionByTypeName)(output.mock)}.ts`)
4478
+ ).map(
4463
4479
  (path) => import_core10.upath.relativeSafe(
4464
4480
  workspacePath,
4465
4481
  (0, import_core10.getFileInfo)(path).pathWithoutExtension
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "orval",
3
3
  "description": "A swagger client generator for typescript",
4
- "version": "6.20.0",
4
+ "version": "6.21.0",
5
5
  "license": "MIT",
6
6
  "files": [
7
7
  "dist"
@@ -53,13 +53,13 @@
53
53
  },
54
54
  "dependencies": {
55
55
  "@apidevtools/swagger-parser": "^10.1.0",
56
- "@orval/angular": "6.20.0",
57
- "@orval/axios": "6.20.0",
58
- "@orval/core": "6.20.0",
59
- "@orval/msw": "6.20.0",
60
- "@orval/query": "6.20.0",
61
- "@orval/swr": "6.20.0",
62
- "@orval/zod": "6.20.0",
56
+ "@orval/angular": "6.21.0",
57
+ "@orval/axios": "6.21.0",
58
+ "@orval/core": "6.21.0",
59
+ "@orval/mock": "6.21.0",
60
+ "@orval/query": "6.21.0",
61
+ "@orval/swr": "6.21.0",
62
+ "@orval/zod": "6.21.0",
63
63
  "ajv": "^8.12.0",
64
64
  "cac": "^6.7.14",
65
65
  "chalk": "^4.1.2",
@@ -67,7 +67,7 @@
67
67
  "enquirer": "^2.4.1",
68
68
  "execa": "^5.1.1",
69
69
  "find-up": "5.0.0",
70
- "fs-extra": "^10.1.0",
70
+ "fs-extra": "^11.1.1",
71
71
  "lodash.uniq": "^4.5.0",
72
72
  "openapi-types": "^12.1.3",
73
73
  "openapi3-ts": "^3.2.0",