orval 6.24.0 → 6.26.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.24.0",
3813
+ version: "6.26.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.24.0",
3835
- "@orval/axios": "6.24.0",
3836
- "@orval/core": "6.24.0",
3837
- "@orval/mock": "6.24.0",
3838
- "@orval/query": "6.24.0",
3839
- "@orval/swr": "6.24.0",
3840
- "@orval/zod": "6.24.0",
3867
+ "@orval/angular": "6.26.0",
3868
+ "@orval/axios": "6.26.0",
3869
+ "@orval/core": "6.26.0",
3870
+ "@orval/mock": "6.26.0",
3871
+ "@orval/query": "6.26.0",
3872
+ "@orval/swr": "6.26.0",
3873
+ "@orval/zod": "6.26.0",
3874
+ "@orval/hono": "6.26.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;
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,26 @@ 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)
4192
4227
  },
4193
4228
  swr: {
4194
- ...(_ha = (_ga = outputOptions.override) == null ? void 0 : _ga.swr) != null ? _ha : {}
4229
+ ...(_ia = (_ha = outputOptions.override) == null ? void 0 : _ha.swr) != null ? _ia : {}
4195
4230
  },
4196
4231
  angular: {
4197
- provideIn: (_ka = (_ja = (_ia = outputOptions.override) == null ? void 0 : _ia.angular) == null ? void 0 : _ja.provideIn) != null ? _ka : "root"
4232
+ provideIn: (_la = (_ka = (_ja = outputOptions.override) == null ? void 0 : _ja.angular) == null ? void 0 : _ka.provideIn) != null ? _la : "root"
4198
4233
  },
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
4234
+ useDates: ((_ma = outputOptions.override) == null ? void 0 : _ma.useDates) || false,
4235
+ useDeprecatedOperations: (_oa = (_na = outputOptions.override) == null ? void 0 : _na.useDeprecatedOperations) != null ? _oa : true,
4236
+ useNativeEnums: (_qa = (_pa = outputOptions.override) == null ? void 0 : _pa.useNativeEnums) != null ? _qa : false
4202
4237
  },
4203
- allParamsOptional: (_qa = outputOptions.allParamsOptional) != null ? _qa : false,
4204
- urlEncodeParameters: (_ra = outputOptions.urlEncodeParameters) != null ? _ra : false
4238
+ allParamsOptional: (_ra = outputOptions.allParamsOptional) != null ? _ra : false,
4239
+ urlEncodeParameters: (_sa = outputOptions.urlEncodeParameters) != null ? _sa : false
4205
4240
  },
4206
4241
  hooks: options.hooks ? normalizeHooks(options.hooks) : {}
4207
4242
  };
@@ -4333,6 +4368,11 @@ var normalizeHooks = (hooks) => {
4333
4368
  return acc;
4334
4369
  }, {});
4335
4370
  };
4371
+ var normalizeHonoOptions = (hono2 = {}, workspace) => {
4372
+ return {
4373
+ ...hono2.handlers ? { handlers: import_core7.upath.resolve(workspace, hono2.handlers) } : {}
4374
+ };
4375
+ };
4336
4376
  var normalizeQueryOptions = (queryOptions = {}, outputWorkspace) => {
4337
4377
  if (queryOptions.options) {
4338
4378
  console.warn(
@@ -4372,7 +4412,7 @@ var getDefaultFilesHeader = ({
4372
4412
  title,
4373
4413
  description,
4374
4414
  version
4375
- }) => [
4415
+ } = {}) => [
4376
4416
  `Generated by ${package_default.name} v${package_default.version} \u{1F37A}`,
4377
4417
  `Do not edit manually.`,
4378
4418
  ...title ? [title] : [],
@@ -4535,6 +4575,17 @@ var writeSpecs = async (builder, workspace, options, projectName) => {
4535
4575
  implementationPaths = [indexFile, ...implementationPaths];
4536
4576
  }
4537
4577
  }
4578
+ if (builder.extraFiles.length) {
4579
+ await Promise.all(
4580
+ builder.extraFiles.map(
4581
+ async (file) => import_fs_extra5.default.outputFile(file.path, file.content)
4582
+ )
4583
+ );
4584
+ implementationPaths = [
4585
+ ...implementationPaths,
4586
+ ...builder.extraFiles.map((file) => file.path)
4587
+ ];
4588
+ }
4538
4589
  const paths = [
4539
4590
  ...output.schemas ? [(0, import_core10.getFileInfo)(output.schemas).dirname] : [],
4540
4591
  ...implementationPaths