orval 6.25.0 → 6.27.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.
package/README.md CHANGED
@@ -26,3 +26,4 @@ You can find below some samples
26
26
  - [react app with swr](https://github.com/anymaniax/orval/tree/master/samples/react-app-with-swr)
27
27
  - [nx fastify react](https://github.com/anymaniax/orval/tree/master/samples/nx-fastify-react)
28
28
  - [angular app](https://github.com/anymaniax/orval/tree/master/samples/angular-app)
29
+ - [hono](https://github.com/anymaniax/orval/tree/master/samples/hono)
package/dist/bin/orval.js CHANGED
@@ -3261,6 +3261,7 @@ var mock = __toESM(require("@orval/mock"));
3261
3261
  var import_query = __toESM(require("@orval/query"));
3262
3262
  var import_swr = __toESM(require("@orval/swr"));
3263
3263
  var import_zod = __toESM(require("@orval/zod"));
3264
+ var import_hono = __toESM(require("@orval/hono"));
3264
3265
  var DEFAULT_CLIENT = import_core.OutputClient.AXIOS;
3265
3266
  var getGeneratorClient = (outputClient, output) => {
3266
3267
  const GENERATOR_CLIENT = {
@@ -3271,7 +3272,8 @@ var getGeneratorClient = (outputClient, output) => {
3271
3272
  "svelte-query": (0, import_query.default)({ output, type: "svelte-query" })(),
3272
3273
  "vue-query": (0, import_query.default)({ output, type: "vue-query" })(),
3273
3274
  swr: (0, import_swr.default)()(),
3274
- zod: (0, import_zod.default)()()
3275
+ zod: (0, import_zod.default)()(),
3276
+ hono: (0, import_hono.default)()()
3275
3277
  };
3276
3278
  const generator = (0, import_core.isFunction)(outputClient) ? outputClient(GENERATOR_CLIENT) : GENERATOR_CLIENT[outputClient];
3277
3279
  if (!generator) {
@@ -3315,7 +3317,10 @@ var generateClientHeader = ({
3315
3317
  provideIn,
3316
3318
  hasAwaitedType,
3317
3319
  titles,
3318
- output
3320
+ output,
3321
+ verbOptions,
3322
+ tag,
3323
+ clientImplementation
3319
3324
  }) => {
3320
3325
  const { header } = getGeneratorClient(outputClient, output);
3321
3326
  return {
@@ -3325,7 +3330,11 @@ var generateClientHeader = ({
3325
3330
  isGlobalMutator,
3326
3331
  isMutator,
3327
3332
  provideIn,
3328
- hasAwaitedType
3333
+ hasAwaitedType,
3334
+ output,
3335
+ verbOptions,
3336
+ tag,
3337
+ clientImplementation
3329
3338
  }) : "",
3330
3339
  implementationMock: `export const ${titles.implementationMock} = () => [
3331
3340
  `
@@ -3431,10 +3440,10 @@ var generateOperations = (outputClient = DEFAULT_CLIENT, verbsOptions, options,
3431
3440
  output
3432
3441
  );
3433
3442
  const client = await generatorClient(verbOption, options, outputClient);
3434
- const generatedMock = generateMock2(verbOption, options);
3435
3443
  if (!client.implementation) {
3436
3444
  return acc;
3437
3445
  }
3446
+ const generatedMock = generateMock2(verbOption, options);
3438
3447
  acc[verbOption.operationId] = {
3439
3448
  implementation: verbOption.doc + client.implementation,
3440
3449
  imports: client.imports,
@@ -3455,6 +3464,16 @@ var generateOperations = (outputClient = DEFAULT_CLIENT, verbsOptions, options,
3455
3464
  {}
3456
3465
  );
3457
3466
  };
3467
+ var generateExtraFiles = (outputClient = DEFAULT_CLIENT, verbsOptions, output, context) => {
3468
+ const { extraFiles: generateExtraFiles2 } = getGeneratorClient(
3469
+ outputClient,
3470
+ output
3471
+ );
3472
+ if (!generateExtraFiles2) {
3473
+ return Promise.resolve([]);
3474
+ }
3475
+ return generateExtraFiles2(verbsOptions, output, context);
3476
+ };
3458
3477
 
3459
3478
  // src/api.ts
3460
3479
  var getApiBuilder = async ({
@@ -3484,6 +3503,7 @@ var getApiBuilder = async ({
3484
3503
  input,
3485
3504
  output,
3486
3505
  route,
3506
+ pathRoute,
3487
3507
  context: resolvedContext
3488
3508
  });
3489
3509
  if (output.override.useDeprecatedOperations === false) {
@@ -3533,23 +3553,35 @@ var getApiBuilder = async ({
3533
3553
  },
3534
3554
  output
3535
3555
  );
3556
+ verbsOptions.forEach((verbOption) => {
3557
+ acc.verbOptions[verbOption.operationId] = verbOption;
3558
+ });
3536
3559
  acc.schemas.push(...schemas);
3537
3560
  acc.operations = { ...acc.operations, ...pathOperations };
3538
3561
  return acc;
3539
3562
  },
3540
3563
  {
3541
3564
  operations: {},
3565
+ verbOptions: {},
3542
3566
  schemas: []
3543
3567
  }
3544
3568
  );
3569
+ const extraFiles = await generateExtraFiles(
3570
+ output.client,
3571
+ api.verbOptions,
3572
+ output,
3573
+ context
3574
+ );
3545
3575
  return {
3546
3576
  operations: api.operations,
3547
3577
  schemas: api.schemas,
3578
+ verbOptions: api.verbOptions,
3548
3579
  title: generateClientTitle,
3549
3580
  header: generateClientHeader,
3550
3581
  footer: generateClientFooter,
3551
3582
  imports: generateClientImports,
3552
- importsMock: import_mock.generateMockImports
3583
+ importsMock: import_mock.generateMockImports,
3584
+ extraFiles
3553
3585
  };
3554
3586
  };
3555
3587
 
@@ -3778,7 +3810,7 @@ var import_chalk2 = __toESM(require("chalk"));
3778
3810
  var package_default = {
3779
3811
  name: "orval",
3780
3812
  description: "A swagger client generator for typescript",
3781
- version: "6.25.0",
3813
+ version: "6.27.0",
3782
3814
  license: "MIT",
3783
3815
  files: [
3784
3816
  "dist"
@@ -3807,7 +3839,8 @@ var package_default = {
3807
3839
  "vue-query",
3808
3840
  "vue",
3809
3841
  "swr",
3810
- "zod"
3842
+ "zod",
3843
+ "hono"
3811
3844
  ],
3812
3845
  author: {
3813
3846
  name: "Victor Bury",
@@ -3831,13 +3864,14 @@ var package_default = {
3831
3864
  },
3832
3865
  dependencies: {
3833
3866
  "@apidevtools/swagger-parser": "^10.1.0",
3834
- "@orval/angular": "6.25.0",
3835
- "@orval/axios": "6.25.0",
3836
- "@orval/core": "6.25.0",
3837
- "@orval/mock": "6.25.0",
3838
- "@orval/query": "6.25.0",
3839
- "@orval/swr": "6.25.0",
3840
- "@orval/zod": "6.25.0",
3867
+ "@orval/angular": "6.27.0",
3868
+ "@orval/axios": "6.27.0",
3869
+ "@orval/core": "6.27.0",
3870
+ "@orval/mock": "6.27.0",
3871
+ "@orval/query": "6.27.0",
3872
+ "@orval/swr": "6.27.0",
3873
+ "@orval/zod": "6.27.0",
3874
+ "@orval/hono": "6.27.0",
3841
3875
  ajv: "^8.12.0",
3842
3876
  cac: "^6.7.14",
3843
3877
  chalk: "^4.1.2",
@@ -3847,7 +3881,7 @@ var package_default = {
3847
3881
  "find-up": "5.0.0",
3848
3882
  "fs-extra": "^11.2.0",
3849
3883
  "lodash.uniq": "^4.5.0",
3850
- "openapi3-ts": "4.2.1",
3884
+ "openapi3-ts": "4.2.2",
3851
3885
  "string-argv": "^0.3.2",
3852
3886
  tsconfck: "^2.0.1"
3853
3887
  }
@@ -4062,7 +4096,7 @@ var loadTsconfig = async (tsconfig, workspace = process.cwd()) => {
4062
4096
 
4063
4097
  // src/utils/options.ts
4064
4098
  var normalizeOptions = async (optionsExport, workspace = process.cwd(), globalOptions = {}) => {
4065
- 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, _la, _ma, _na, _oa, _pa, _qa, _ra;
4099
+ 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, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za, _Aa, _Ba, _Ca, _Da, _Ea, _Fa, _Ga, _Ha, _Ia, _Ja, _Ka, _La, _Ma;
4066
4100
  const options = await ((0, import_core7.isFunction)(optionsExport) ? optionsExport() : optionsExport);
4067
4101
  if (!options.input) {
4068
4102
  (0, import_core7.createLogger)().error(import_chalk2.default.red(`Config require an input`));
@@ -4183,25 +4217,35 @@ var normalizeOptions = async (optionsExport, workspace = process.cwd(), globalOp
4183
4217
  ...(_ea = (_da = (_ca = outputOptions.override) == null ? void 0 : _ca.components) == null ? void 0 : _da.requestBodies) != null ? _ea : {}
4184
4218
  }
4185
4219
  },
4220
+ hono: normalizeHonoOptions((_fa = outputOptions.override) == null ? void 0 : _fa.hono, workspace),
4186
4221
  query: {
4187
4222
  useQuery: true,
4188
4223
  useMutation: true,
4189
4224
  signal: true,
4190
4225
  shouldExportMutatorHooks: true,
4191
- ...normalizeQueryOptions((_fa = outputOptions.override) == null ? void 0 : _fa.query, workspace)
4226
+ ...normalizeQueryOptions((_ga = outputOptions.override) == null ? void 0 : _ga.query, workspace)
4227
+ },
4228
+ zod: {
4229
+ strict: {
4230
+ param: (_ka = (_ja = (_ia = (_ha = outputOptions.override) == null ? void 0 : _ha.zod) == null ? void 0 : _ia.strict) == null ? void 0 : _ja.param) != null ? _ka : false,
4231
+ query: (_oa = (_na = (_ma = (_la = outputOptions.override) == null ? void 0 : _la.zod) == null ? void 0 : _ma.strict) == null ? void 0 : _na.query) != null ? _oa : false,
4232
+ header: (_sa = (_ra = (_qa = (_pa = outputOptions.override) == null ? void 0 : _pa.zod) == null ? void 0 : _qa.strict) == null ? void 0 : _ra.header) != null ? _sa : false,
4233
+ body: (_wa = (_va = (_ua = (_ta = outputOptions.override) == null ? void 0 : _ta.zod) == null ? void 0 : _ua.strict) == null ? void 0 : _va.body) != null ? _wa : false,
4234
+ response: (_Aa = (_za = (_ya = (_xa = outputOptions.override) == null ? void 0 : _xa.zod) == null ? void 0 : _ya.strict) == null ? void 0 : _za.response) != null ? _Aa : false
4235
+ }
4192
4236
  },
4193
4237
  swr: {
4194
- ...(_ha = (_ga = outputOptions.override) == null ? void 0 : _ga.swr) != null ? _ha : {}
4238
+ ...(_Ca = (_Ba = outputOptions.override) == null ? void 0 : _Ba.swr) != null ? _Ca : {}
4195
4239
  },
4196
4240
  angular: {
4197
- provideIn: (_ka = (_ja = (_ia = outputOptions.override) == null ? void 0 : _ia.angular) == null ? void 0 : _ja.provideIn) != null ? _ka : "root"
4241
+ provideIn: (_Fa = (_Ea = (_Da = outputOptions.override) == null ? void 0 : _Da.angular) == null ? void 0 : _Ea.provideIn) != null ? _Fa : "root"
4198
4242
  },
4199
- useDates: ((_la = outputOptions.override) == null ? void 0 : _la.useDates) || false,
4200
- useDeprecatedOperations: (_na = (_ma = outputOptions.override) == null ? void 0 : _ma.useDeprecatedOperations) != null ? _na : true,
4201
- useNativeEnums: (_pa = (_oa = outputOptions.override) == null ? void 0 : _oa.useNativeEnums) != null ? _pa : false
4243
+ useDates: ((_Ga = outputOptions.override) == null ? void 0 : _Ga.useDates) || false,
4244
+ useDeprecatedOperations: (_Ia = (_Ha = outputOptions.override) == null ? void 0 : _Ha.useDeprecatedOperations) != null ? _Ia : true,
4245
+ useNativeEnums: (_Ka = (_Ja = outputOptions.override) == null ? void 0 : _Ja.useNativeEnums) != null ? _Ka : false
4202
4246
  },
4203
- allParamsOptional: (_qa = outputOptions.allParamsOptional) != null ? _qa : false,
4204
- urlEncodeParameters: (_ra = outputOptions.urlEncodeParameters) != null ? _ra : false
4247
+ allParamsOptional: (_La = outputOptions.allParamsOptional) != null ? _La : false,
4248
+ urlEncodeParameters: (_Ma = outputOptions.urlEncodeParameters) != null ? _Ma : false
4205
4249
  },
4206
4250
  hooks: options.hooks ? normalizeHooks(options.hooks) : {}
4207
4251
  };
@@ -4266,9 +4310,11 @@ var normalizeOperationsAndTags = (operationsOrTags, workspace) => {
4266
4310
  formUrlEncoded,
4267
4311
  paramsSerializer,
4268
4312
  query: query2,
4313
+ zod: zod2,
4269
4314
  ...rest
4270
4315
  }
4271
4316
  ]) => {
4317
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
4272
4318
  return [
4273
4319
  key,
4274
4320
  {
@@ -4276,6 +4322,17 @@ var normalizeOperationsAndTags = (operationsOrTags, workspace) => {
4276
4322
  ...query2 ? {
4277
4323
  query: normalizeQueryOptions(query2, workspace)
4278
4324
  } : {},
4325
+ ...zod2 ? {
4326
+ zod: {
4327
+ strict: {
4328
+ param: (_b = (_a = zod2.strict) == null ? void 0 : _a.param) != null ? _b : false,
4329
+ query: (_d = (_c = zod2.strict) == null ? void 0 : _c.query) != null ? _d : false,
4330
+ header: (_f = (_e = zod2.strict) == null ? void 0 : _e.header) != null ? _f : false,
4331
+ body: (_h = (_g = zod2.strict) == null ? void 0 : _g.body) != null ? _h : false,
4332
+ response: (_j = (_i = zod2.strict) == null ? void 0 : _i.response) != null ? _j : false
4333
+ }
4334
+ }
4335
+ } : {},
4279
4336
  ...transformer ? { transformer: normalizePath(transformer, workspace) } : {},
4280
4337
  ...mutator ? { mutator: normalizeMutator(workspace, mutator) } : {},
4281
4338
  ...formData ? {
@@ -4333,6 +4390,11 @@ var normalizeHooks = (hooks) => {
4333
4390
  return acc;
4334
4391
  }, {});
4335
4392
  };
4393
+ var normalizeHonoOptions = (hono2 = {}, workspace) => {
4394
+ return {
4395
+ ...hono2.handlers ? { handlers: import_core7.upath.resolve(workspace, hono2.handlers) } : {}
4396
+ };
4397
+ };
4336
4398
  var normalizeQueryOptions = (queryOptions = {}, outputWorkspace) => {
4337
4399
  if (queryOptions.options) {
4338
4400
  console.warn(
@@ -4372,7 +4434,7 @@ var getDefaultFilesHeader = ({
4372
4434
  title,
4373
4435
  description,
4374
4436
  version
4375
- }) => [
4437
+ } = {}) => [
4376
4438
  `Generated by ${package_default.name} v${package_default.version} \u{1F37A}`,
4377
4439
  `Do not edit manually.`,
4378
4440
  ...title ? [title] : [],
@@ -4535,6 +4597,17 @@ var writeSpecs = async (builder, workspace, options, projectName) => {
4535
4597
  implementationPaths = [indexFile, ...implementationPaths];
4536
4598
  }
4537
4599
  }
4600
+ if (builder.extraFiles.length) {
4601
+ await Promise.all(
4602
+ builder.extraFiles.map(
4603
+ async (file) => import_fs_extra5.default.outputFile(file.path, file.content)
4604
+ )
4605
+ );
4606
+ implementationPaths = [
4607
+ ...implementationPaths,
4608
+ ...builder.extraFiles.map((file) => file.path)
4609
+ ];
4610
+ }
4538
4611
  const paths = [
4539
4612
  ...output.schemas ? [(0, import_core10.getFileInfo)(output.schemas).dirname] : [],
4540
4613
  ...implementationPaths