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/dist/index.js CHANGED
@@ -3272,6 +3272,7 @@ var mock = __toESM(require("@orval/mock"));
3272
3272
  var import_query = __toESM(require("@orval/query"));
3273
3273
  var import_swr = __toESM(require("@orval/swr"));
3274
3274
  var import_zod = __toESM(require("@orval/zod"));
3275
+ var import_hono = __toESM(require("@orval/hono"));
3275
3276
  var DEFAULT_CLIENT = import_core.OutputClient.AXIOS;
3276
3277
  var getGeneratorClient = (outputClient, output) => {
3277
3278
  const GENERATOR_CLIENT = {
@@ -3282,7 +3283,8 @@ var getGeneratorClient = (outputClient, output) => {
3282
3283
  "svelte-query": (0, import_query.default)({ output, type: "svelte-query" })(),
3283
3284
  "vue-query": (0, import_query.default)({ output, type: "vue-query" })(),
3284
3285
  swr: (0, import_swr.default)()(),
3285
- zod: (0, import_zod.default)()()
3286
+ zod: (0, import_zod.default)()(),
3287
+ hono: (0, import_hono.default)()()
3286
3288
  };
3287
3289
  const generator = (0, import_core.isFunction)(outputClient) ? outputClient(GENERATOR_CLIENT) : GENERATOR_CLIENT[outputClient];
3288
3290
  if (!generator) {
@@ -3326,7 +3328,10 @@ var generateClientHeader = ({
3326
3328
  provideIn,
3327
3329
  hasAwaitedType,
3328
3330
  titles,
3329
- output
3331
+ output,
3332
+ verbOptions,
3333
+ tag,
3334
+ clientImplementation
3330
3335
  }) => {
3331
3336
  const { header } = getGeneratorClient(outputClient, output);
3332
3337
  return {
@@ -3336,7 +3341,11 @@ var generateClientHeader = ({
3336
3341
  isGlobalMutator,
3337
3342
  isMutator,
3338
3343
  provideIn,
3339
- hasAwaitedType
3344
+ hasAwaitedType,
3345
+ output,
3346
+ verbOptions,
3347
+ tag,
3348
+ clientImplementation
3340
3349
  }) : "",
3341
3350
  implementationMock: `export const ${titles.implementationMock} = () => [
3342
3351
  `
@@ -3442,10 +3451,10 @@ var generateOperations = (outputClient = DEFAULT_CLIENT, verbsOptions, options,
3442
3451
  output
3443
3452
  );
3444
3453
  const client = await generatorClient(verbOption, options, outputClient);
3445
- const generatedMock = generateMock2(verbOption, options);
3446
3454
  if (!client.implementation) {
3447
3455
  return acc;
3448
3456
  }
3457
+ const generatedMock = generateMock2(verbOption, options);
3449
3458
  acc[verbOption.operationId] = {
3450
3459
  implementation: verbOption.doc + client.implementation,
3451
3460
  imports: client.imports,
@@ -3466,6 +3475,16 @@ var generateOperations = (outputClient = DEFAULT_CLIENT, verbsOptions, options,
3466
3475
  {}
3467
3476
  );
3468
3477
  };
3478
+ var generateExtraFiles = (outputClient = DEFAULT_CLIENT, verbsOptions, output, context) => {
3479
+ const { extraFiles: generateExtraFiles2 } = getGeneratorClient(
3480
+ outputClient,
3481
+ output
3482
+ );
3483
+ if (!generateExtraFiles2) {
3484
+ return Promise.resolve([]);
3485
+ }
3486
+ return generateExtraFiles2(verbsOptions, output, context);
3487
+ };
3469
3488
 
3470
3489
  // src/api.ts
3471
3490
  var getApiBuilder = async ({
@@ -3495,6 +3514,7 @@ var getApiBuilder = async ({
3495
3514
  input,
3496
3515
  output,
3497
3516
  route,
3517
+ pathRoute,
3498
3518
  context: resolvedContext
3499
3519
  });
3500
3520
  if (output.override.useDeprecatedOperations === false) {
@@ -3544,23 +3564,35 @@ var getApiBuilder = async ({
3544
3564
  },
3545
3565
  output
3546
3566
  );
3567
+ verbsOptions.forEach((verbOption) => {
3568
+ acc.verbOptions[verbOption.operationId] = verbOption;
3569
+ });
3547
3570
  acc.schemas.push(...schemas);
3548
3571
  acc.operations = { ...acc.operations, ...pathOperations };
3549
3572
  return acc;
3550
3573
  },
3551
3574
  {
3552
3575
  operations: {},
3576
+ verbOptions: {},
3553
3577
  schemas: []
3554
3578
  }
3555
3579
  );
3580
+ const extraFiles = await generateExtraFiles(
3581
+ output.client,
3582
+ api.verbOptions,
3583
+ output,
3584
+ context
3585
+ );
3556
3586
  return {
3557
3587
  operations: api.operations,
3558
3588
  schemas: api.schemas,
3589
+ verbOptions: api.verbOptions,
3559
3590
  title: generateClientTitle,
3560
3591
  header: generateClientHeader,
3561
3592
  footer: generateClientFooter,
3562
3593
  imports: generateClientImports,
3563
- importsMock: import_mock.generateMockImports
3594
+ importsMock: import_mock.generateMockImports,
3595
+ extraFiles
3564
3596
  };
3565
3597
  };
3566
3598
 
@@ -3789,7 +3821,7 @@ var import_chalk2 = __toESM(require("chalk"));
3789
3821
  var package_default = {
3790
3822
  name: "orval",
3791
3823
  description: "A swagger client generator for typescript",
3792
- version: "6.25.0",
3824
+ version: "6.27.0",
3793
3825
  license: "MIT",
3794
3826
  files: [
3795
3827
  "dist"
@@ -3818,7 +3850,8 @@ var package_default = {
3818
3850
  "vue-query",
3819
3851
  "vue",
3820
3852
  "swr",
3821
- "zod"
3853
+ "zod",
3854
+ "hono"
3822
3855
  ],
3823
3856
  author: {
3824
3857
  name: "Victor Bury",
@@ -3842,13 +3875,14 @@ var package_default = {
3842
3875
  },
3843
3876
  dependencies: {
3844
3877
  "@apidevtools/swagger-parser": "^10.1.0",
3845
- "@orval/angular": "6.25.0",
3846
- "@orval/axios": "6.25.0",
3847
- "@orval/core": "6.25.0",
3848
- "@orval/mock": "6.25.0",
3849
- "@orval/query": "6.25.0",
3850
- "@orval/swr": "6.25.0",
3851
- "@orval/zod": "6.25.0",
3878
+ "@orval/angular": "6.27.0",
3879
+ "@orval/axios": "6.27.0",
3880
+ "@orval/core": "6.27.0",
3881
+ "@orval/mock": "6.27.0",
3882
+ "@orval/query": "6.27.0",
3883
+ "@orval/swr": "6.27.0",
3884
+ "@orval/zod": "6.27.0",
3885
+ "@orval/hono": "6.27.0",
3852
3886
  ajv: "^8.12.0",
3853
3887
  cac: "^6.7.14",
3854
3888
  chalk: "^4.1.2",
@@ -3858,7 +3892,7 @@ var package_default = {
3858
3892
  "find-up": "5.0.0",
3859
3893
  "fs-extra": "^11.2.0",
3860
3894
  "lodash.uniq": "^4.5.0",
3861
- "openapi3-ts": "4.2.1",
3895
+ "openapi3-ts": "4.2.2",
3862
3896
  "string-argv": "^0.3.2",
3863
3897
  tsconfck: "^2.0.1"
3864
3898
  }
@@ -4076,7 +4110,7 @@ function defineConfig(options) {
4076
4110
  return options;
4077
4111
  }
4078
4112
  var normalizeOptions = async (optionsExport, workspace = process.cwd(), globalOptions = {}) => {
4079
- 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;
4113
+ 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;
4080
4114
  const options = await ((0, import_core7.isFunction)(optionsExport) ? optionsExport() : optionsExport);
4081
4115
  if (!options.input) {
4082
4116
  (0, import_core7.createLogger)().error(import_chalk2.default.red(`Config require an input`));
@@ -4197,25 +4231,35 @@ var normalizeOptions = async (optionsExport, workspace = process.cwd(), globalOp
4197
4231
  ...(_ea = (_da = (_ca = outputOptions.override) == null ? void 0 : _ca.components) == null ? void 0 : _da.requestBodies) != null ? _ea : {}
4198
4232
  }
4199
4233
  },
4234
+ hono: normalizeHonoOptions((_fa = outputOptions.override) == null ? void 0 : _fa.hono, workspace),
4200
4235
  query: {
4201
4236
  useQuery: true,
4202
4237
  useMutation: true,
4203
4238
  signal: true,
4204
4239
  shouldExportMutatorHooks: true,
4205
- ...normalizeQueryOptions((_fa = outputOptions.override) == null ? void 0 : _fa.query, workspace)
4240
+ ...normalizeQueryOptions((_ga = outputOptions.override) == null ? void 0 : _ga.query, workspace)
4241
+ },
4242
+ zod: {
4243
+ strict: {
4244
+ 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,
4245
+ 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,
4246
+ 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,
4247
+ 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,
4248
+ 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
4249
+ }
4206
4250
  },
4207
4251
  swr: {
4208
- ...(_ha = (_ga = outputOptions.override) == null ? void 0 : _ga.swr) != null ? _ha : {}
4252
+ ...(_Ca = (_Ba = outputOptions.override) == null ? void 0 : _Ba.swr) != null ? _Ca : {}
4209
4253
  },
4210
4254
  angular: {
4211
- provideIn: (_ka = (_ja = (_ia = outputOptions.override) == null ? void 0 : _ia.angular) == null ? void 0 : _ja.provideIn) != null ? _ka : "root"
4255
+ provideIn: (_Fa = (_Ea = (_Da = outputOptions.override) == null ? void 0 : _Da.angular) == null ? void 0 : _Ea.provideIn) != null ? _Fa : "root"
4212
4256
  },
4213
- useDates: ((_la = outputOptions.override) == null ? void 0 : _la.useDates) || false,
4214
- useDeprecatedOperations: (_na = (_ma = outputOptions.override) == null ? void 0 : _ma.useDeprecatedOperations) != null ? _na : true,
4215
- useNativeEnums: (_pa = (_oa = outputOptions.override) == null ? void 0 : _oa.useNativeEnums) != null ? _pa : false
4257
+ useDates: ((_Ga = outputOptions.override) == null ? void 0 : _Ga.useDates) || false,
4258
+ useDeprecatedOperations: (_Ia = (_Ha = outputOptions.override) == null ? void 0 : _Ha.useDeprecatedOperations) != null ? _Ia : true,
4259
+ useNativeEnums: (_Ka = (_Ja = outputOptions.override) == null ? void 0 : _Ja.useNativeEnums) != null ? _Ka : false
4216
4260
  },
4217
- allParamsOptional: (_qa = outputOptions.allParamsOptional) != null ? _qa : false,
4218
- urlEncodeParameters: (_ra = outputOptions.urlEncodeParameters) != null ? _ra : false
4261
+ allParamsOptional: (_La = outputOptions.allParamsOptional) != null ? _La : false,
4262
+ urlEncodeParameters: (_Ma = outputOptions.urlEncodeParameters) != null ? _Ma : false
4219
4263
  },
4220
4264
  hooks: options.hooks ? normalizeHooks(options.hooks) : {}
4221
4265
  };
@@ -4280,9 +4324,11 @@ var normalizeOperationsAndTags = (operationsOrTags, workspace) => {
4280
4324
  formUrlEncoded,
4281
4325
  paramsSerializer,
4282
4326
  query: query2,
4327
+ zod: zod2,
4283
4328
  ...rest
4284
4329
  }
4285
4330
  ]) => {
4331
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
4286
4332
  return [
4287
4333
  key,
4288
4334
  {
@@ -4290,6 +4336,17 @@ var normalizeOperationsAndTags = (operationsOrTags, workspace) => {
4290
4336
  ...query2 ? {
4291
4337
  query: normalizeQueryOptions(query2, workspace)
4292
4338
  } : {},
4339
+ ...zod2 ? {
4340
+ zod: {
4341
+ strict: {
4342
+ param: (_b = (_a = zod2.strict) == null ? void 0 : _a.param) != null ? _b : false,
4343
+ query: (_d = (_c = zod2.strict) == null ? void 0 : _c.query) != null ? _d : false,
4344
+ header: (_f = (_e = zod2.strict) == null ? void 0 : _e.header) != null ? _f : false,
4345
+ body: (_h = (_g = zod2.strict) == null ? void 0 : _g.body) != null ? _h : false,
4346
+ response: (_j = (_i = zod2.strict) == null ? void 0 : _i.response) != null ? _j : false
4347
+ }
4348
+ }
4349
+ } : {},
4293
4350
  ...transformer ? { transformer: normalizePath(transformer, workspace) } : {},
4294
4351
  ...mutator ? { mutator: normalizeMutator(workspace, mutator) } : {},
4295
4352
  ...formData ? {
@@ -4347,6 +4404,11 @@ var normalizeHooks = (hooks) => {
4347
4404
  return acc;
4348
4405
  }, {});
4349
4406
  };
4407
+ var normalizeHonoOptions = (hono2 = {}, workspace) => {
4408
+ return {
4409
+ ...hono2.handlers ? { handlers: import_core7.upath.resolve(workspace, hono2.handlers) } : {}
4410
+ };
4411
+ };
4350
4412
  var normalizeQueryOptions = (queryOptions = {}, outputWorkspace) => {
4351
4413
  if (queryOptions.options) {
4352
4414
  console.warn(
@@ -4386,7 +4448,7 @@ var getDefaultFilesHeader = ({
4386
4448
  title,
4387
4449
  description,
4388
4450
  version
4389
- }) => [
4451
+ } = {}) => [
4390
4452
  `Generated by ${package_default.name} v${package_default.version} \u{1F37A}`,
4391
4453
  `Do not edit manually.`,
4392
4454
  ...title ? [title] : [],
@@ -4549,6 +4611,17 @@ var writeSpecs = async (builder, workspace, options, projectName) => {
4549
4611
  implementationPaths = [indexFile, ...implementationPaths];
4550
4612
  }
4551
4613
  }
4614
+ if (builder.extraFiles.length) {
4615
+ await Promise.all(
4616
+ builder.extraFiles.map(
4617
+ async (file) => import_fs_extra5.default.outputFile(file.path, file.content)
4618
+ )
4619
+ );
4620
+ implementationPaths = [
4621
+ ...implementationPaths,
4622
+ ...builder.extraFiles.map((file) => file.path)
4623
+ ];
4624
+ }
4552
4625
  const paths = [
4553
4626
  ...output.schemas ? [(0, import_core10.getFileInfo)(output.schemas).dirname] : [],
4554
4627
  ...implementationPaths