@hey-api/openapi-ts 0.93.1 → 0.94.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.
@@ -1,6 +1,6 @@
1
1
  import { createRequire } from "node:module";
2
2
  import { StructureModel, detectInteractiveSession, fromRef, isNode, isRef, isSymbol, loadConfigFile, log, nodeBrand, ref, refs } from "@hey-api/codegen-core";
3
- import { ConfigError, OperationPath, OperationStrategy, applyNaming, childContext, createOperationKey, createSchemaProcessor, createSchemaWalker, deduplicateSchema, definePluginConfig, dependencyFactory, ensureDirSync, escapeComment, findTsConfigPath, getInput, getLogs, getParser, hasOperationDataRequired, hasParameterGroupObjectRequired, loadTsConfig, mappers, operationPagination, operationResponsesMap, parseUrl, pathToJsonPointer, pathToName, refToName, resolveSource, satisfies, statusCodeToGroup, toCase, valueToObject } from "@hey-api/shared";
3
+ import { ConfigError, OperationPath, OperationStrategy, applyNaming, childContext, createOperationKey, createSchemaProcessor, createSchemaWalker, deduplicateSchema, definePluginConfig, dependencyFactory, ensureDirSync, escapeComment, findTsConfigPath, getInput, getLogs, getParser, hasOperationDataRequired, hasParameterGroupObjectRequired, loadTsConfig, mappers, operationPagination, operationResponsesMap, outputHeaderToPrefix, parseUrl, pathToJsonPointer, pathToName, refToName, resolveSource, satisfies, statusCodeToGroup, toCase, valueToObject } from "@hey-api/shared";
4
4
  import colors from "ansi-colors";
5
5
  import path from "node:path";
6
6
  import { fileURLToPath } from "node:url";
@@ -723,24 +723,51 @@ const regexp = {
723
723
  //#region src/ts-dsl/utils/keywords.ts
724
724
  const browserGlobals = [
725
725
  "document",
726
+ "fetch",
726
727
  "history",
727
728
  "location",
728
729
  "navigator",
729
- "window"
730
+ "window",
731
+ "AbortController",
732
+ "AbortSignal",
733
+ "Blob",
734
+ "CustomEvent",
735
+ "Event",
736
+ "EventTarget",
737
+ "File",
738
+ "FileList",
739
+ "FileReader",
740
+ "FormData",
741
+ "Headers",
742
+ "Request",
743
+ "Response",
744
+ "TextDecoder",
745
+ "TextEncoder",
746
+ "URL",
747
+ "URLSearchParams"
730
748
  ];
731
749
  const javaScriptGlobals = [
732
750
  "console",
733
751
  "Array",
752
+ "ArrayBuffer",
753
+ "BigInt",
754
+ "Boolean",
755
+ "DataView",
734
756
  "Date",
735
757
  "Error",
736
758
  "Function",
737
759
  "JSON",
738
760
  "Map",
739
761
  "Math",
762
+ "Number",
740
763
  "Object",
741
764
  "Promise",
765
+ "Proxy",
766
+ "Reflect",
742
767
  "RegExp",
743
768
  "Set",
769
+ "String",
770
+ "Symbol",
744
771
  "WeakMap",
745
772
  "WeakSet"
746
773
  ];
@@ -797,8 +824,13 @@ const javaScriptKeywords = [
797
824
  "yield"
798
825
  ];
799
826
  const nodeGlobals = [
827
+ "__dirname",
828
+ "__filename",
829
+ "exports",
800
830
  "global",
831
+ "module",
801
832
  "process",
833
+ "require",
802
834
  "Buffer"
803
835
  ];
804
836
  const typeScriptKeywords = [
@@ -887,21 +919,26 @@ const safePropName = (name) => {
887
919
  if (regexp.typeScriptIdentifier.test(name)) return new IdTsDsl(name);
888
920
  return new LiteralTsDsl(name);
889
921
  };
922
+ const validTypeScriptChar = /^[\u200c\u200d\p{ID_Continue}]$/u;
890
923
  const safeName = (name, reserved$1) => {
891
924
  let sanitized = "";
892
925
  let index;
893
926
  const first = name[0] ?? "";
894
927
  regexp.illegalStartCharacters.lastIndex = 0;
895
- if (regexp.illegalStartCharacters.test(first)) {
928
+ if (regexp.illegalStartCharacters.test(first)) if (validTypeScriptChar.test(first)) {
896
929
  sanitized += "_";
897
930
  index = 0;
898
931
  } else {
932
+ sanitized += "_";
933
+ index = 1;
934
+ }
935
+ else {
899
936
  sanitized += first;
900
937
  index = 1;
901
938
  }
902
939
  while (index < name.length) {
903
940
  const char = name[index] ?? "";
904
- sanitized += /^[\u200c\u200d\p{ID_Continue}]$/u.test(char) ? char : "_";
941
+ sanitized += validTypeScriptChar.test(char) ? char : "_";
905
942
  index += 1;
906
943
  }
907
944
  if (reserved$1["~values"].has(sanitized)) sanitized = `${sanitized}_`;
@@ -5241,7 +5278,7 @@ const handler$11 = ({ plugin }) => {
5241
5278
 
5242
5279
  //#endregion
5243
5280
  //#region src/plugins/@angular/common/config.ts
5244
- const defaultConfig$23 = {
5281
+ const defaultConfig$24 = {
5245
5282
  config: {
5246
5283
  comments: true,
5247
5284
  includeInEntry: false
@@ -5257,7 +5294,7 @@ const defaultConfig$23 = {
5257
5294
  /**
5258
5295
  * Type helper for `@angular/common` plugin, returns {@link Plugin.Config} object
5259
5296
  */
5260
- const defineConfig$23 = definePluginConfig(defaultConfig$23);
5297
+ const defineConfig$24 = definePluginConfig(defaultConfig$24);
5261
5298
 
5262
5299
  //#endregion
5263
5300
  //#region src/plugins/@faker-js/faker/api.ts
@@ -5268,7 +5305,7 @@ var Api$4 = class {
5268
5305
 
5269
5306
  //#endregion
5270
5307
  //#region src/plugins/@faker-js/faker/config.ts
5271
- const defaultConfig$22 = {
5308
+ const defaultConfig$23 = {
5272
5309
  api: new Api$4(),
5273
5310
  config: {
5274
5311
  case: "camelCase",
@@ -5292,7 +5329,7 @@ const defaultConfig$22 = {
5292
5329
  /**
5293
5330
  * Type helper for Faker plugin, returns {@link Plugin.Config} object
5294
5331
  */
5295
- const defineConfig$22 = definePluginConfig(defaultConfig$22);
5332
+ const defineConfig$23 = definePluginConfig(defaultConfig$23);
5296
5333
 
5297
5334
  //#endregion
5298
5335
  //#region src/plugins/@hey-api/client-core/config.ts
@@ -5311,13 +5348,10 @@ const clientDefaultMeta = {
5311
5348
  const __filename = fileURLToPath(import.meta.url);
5312
5349
  const __dirname = path.dirname(__filename);
5313
5350
  /**
5314
- * Dev mode: 'src' appears after 'dist' (or dist doesn't exist), and 'generate' follows 'src'
5351
+ * Dev mode: determined by OPENAPI_TS_DEV_MODE environment variable
5315
5352
  */
5316
5353
  function isDevMode() {
5317
- const normalized = __dirname.split(path.sep);
5318
- const srcIndex = normalized.lastIndexOf("src");
5319
- const distIndex = normalized.lastIndexOf("dist");
5320
- return srcIndex !== -1 && srcIndex > distIndex && srcIndex === normalized.length - 2 && normalized[srcIndex + 1] === "generate";
5354
+ return process.env.OPENAPI_TS_DEV_MODE === "true" || process.env.OPENAPI_TS_DEV_MODE === "1";
5321
5355
  }
5322
5356
  /**
5323
5357
  * Returns paths to client bundle files based on execution context
@@ -5337,16 +5371,6 @@ function getClientBundlePaths(pluginName) {
5337
5371
  };
5338
5372
  }
5339
5373
  /**
5340
- * Converts an {@link OutputHeader} value to a string prefix for file content.
5341
- * Returns an empty string when the header is null, undefined, or a function
5342
- * (functions require a render context which is not available for bundled files).
5343
- */
5344
- function outputHeaderToPrefix(header) {
5345
- if (header == null || typeof header === "function") return "";
5346
- const content = (typeof header === "string" ? header.split(/\r?\n/) : header.flatMap((line) => line.split(/\r?\n/))).join("\n");
5347
- return content ? `${content}\n\n` : "";
5348
- }
5349
- /**
5350
5374
  * Returns absolute path to the client folder. This is hard-coded for now.
5351
5375
  */
5352
5376
  function clientFolderAbsolutePath(config) {
@@ -5405,7 +5429,7 @@ function replaceImports({ filePath, header, isDevMode: isDevMode$1, meta, rename
5405
5429
  function generateClientBundle({ header, meta, outputPath, plugin, project }) {
5406
5430
  const renamed = /* @__PURE__ */ new Map();
5407
5431
  const devMode = isDevMode();
5408
- const headerPrefix = outputHeaderToPrefix(header);
5432
+ const headerPrefix = outputHeaderToPrefix(header, project);
5409
5433
  if (plugin.name.startsWith("@hey-api/client-")) {
5410
5434
  const { clientPath, corePath } = getClientBundlePaths(plugin.name);
5411
5435
  const coreOutputPath = path.resolve(outputPath, "core");
@@ -5499,7 +5523,7 @@ const createClient = ({ plugin }) => {
5499
5523
  if ("throwOnError" in plugin.config && plugin.config.throwOnError) defaultVals.prop("throwOnError", $.literal(true));
5500
5524
  const createConfigParameters = [$(symbolCreateConfig).call(defaultVals.hasProps() ? defaultVals : void 0).generic(symbolClientOptions)];
5501
5525
  const symbolClient = plugin.symbol("client", { meta: { category: "client" } });
5502
- const statement = $.const(symbolClient).export().assign($(symbolCreateClient).$if(symbolCreateClientConfig, (c, s) => c.call($.await($(s).call(...createConfigParameters))), (c) => c.call(...createConfigParameters)));
5526
+ const statement = $.const(symbolClient).export().assign($(symbolCreateClient).$if(symbolCreateClientConfig, (c, s) => c.call($(s).call(...createConfigParameters)), (c) => c.call(...createConfigParameters)));
5503
5527
  plugin.node(statement);
5504
5528
  };
5505
5529
 
@@ -5528,7 +5552,7 @@ const createClientConfigType = ({ plugin }) => {
5528
5552
  "You may want to initialize your client this way instead of calling",
5529
5553
  "`setConfig()`. This is useful for example if you're using Next.js",
5530
5554
  "to ensure your client always has the correct values."
5531
- ]).generic("T", (g) => g.extends(symbolDefaultClientOptions).default(symbolClientOptions)).type($.type.func().param("override", (p) => p.optional().type($.type(symbolConfig).generic($.type.and(symbolDefaultClientOptions, "T")))).returns($.type.or($.type(symbolConfig).generic($.type.and($.type("Required").generic(symbolDefaultClientOptions), "T")), $.type("Promise").generic($.type(symbolConfig).generic($.type.and($.type("Required").generic(symbolDefaultClientOptions), "T"))))));
5555
+ ]).generic("T", (g) => g.extends(symbolDefaultClientOptions).default(symbolClientOptions)).type($.type.func().param("override", (p) => p.optional().type($.type(symbolConfig).generic($.type.and(symbolDefaultClientOptions, "T")))).returns($.type(symbolConfig).generic($.type.and($.type("Required").generic(symbolDefaultClientOptions), "T"))));
5532
5556
  plugin.node(typeCreateClientConfig);
5533
5557
  };
5534
5558
 
@@ -5541,7 +5565,7 @@ const clientPluginHandler = ({ plugin }) => {
5541
5565
 
5542
5566
  //#endregion
5543
5567
  //#region src/plugins/@hey-api/client-angular/config.ts
5544
- const defaultConfig$21 = {
5568
+ const defaultConfig$22 = {
5545
5569
  ...clientDefaultMeta,
5546
5570
  config: {
5547
5571
  ...clientDefaultConfig,
@@ -5553,11 +5577,11 @@ const defaultConfig$21 = {
5553
5577
  /**
5554
5578
  * Type helper for `@hey-api/client-angular` plugin, returns {@link Plugin.Config} object
5555
5579
  */
5556
- const defineConfig$21 = definePluginConfig(defaultConfig$21);
5580
+ const defineConfig$22 = definePluginConfig(defaultConfig$22);
5557
5581
 
5558
5582
  //#endregion
5559
5583
  //#region src/plugins/@hey-api/client-axios/config.ts
5560
- const defaultConfig$20 = {
5584
+ const defaultConfig$21 = {
5561
5585
  ...clientDefaultMeta,
5562
5586
  config: {
5563
5587
  ...clientDefaultConfig,
@@ -5569,11 +5593,11 @@ const defaultConfig$20 = {
5569
5593
  /**
5570
5594
  * Type helper for `@hey-api/client-axios` plugin, returns {@link Plugin.Config} object
5571
5595
  */
5572
- const defineConfig$20 = definePluginConfig(defaultConfig$20);
5596
+ const defineConfig$21 = definePluginConfig(defaultConfig$21);
5573
5597
 
5574
5598
  //#endregion
5575
5599
  //#region src/plugins/@hey-api/client-fetch/config.ts
5576
- const defaultConfig$19 = {
5600
+ const defaultConfig$20 = {
5577
5601
  ...clientDefaultMeta,
5578
5602
  config: {
5579
5603
  ...clientDefaultConfig,
@@ -5585,11 +5609,11 @@ const defaultConfig$19 = {
5585
5609
  /**
5586
5610
  * Type helper for `@hey-api/client-fetch` plugin, returns {@link Plugin.Config} object
5587
5611
  */
5588
- const defineConfig$19 = definePluginConfig(defaultConfig$19);
5612
+ const defineConfig$20 = definePluginConfig(defaultConfig$20);
5589
5613
 
5590
5614
  //#endregion
5591
5615
  //#region src/plugins/@hey-api/client-ky/config.ts
5592
- const defaultConfig$18 = {
5616
+ const defaultConfig$19 = {
5593
5617
  ...clientDefaultMeta,
5594
5618
  config: {
5595
5619
  ...clientDefaultConfig,
@@ -5601,11 +5625,11 @@ const defaultConfig$18 = {
5601
5625
  /**
5602
5626
  * Type helper for `@hey-api/client-ky` plugin, returns {@link Plugin.Config} object
5603
5627
  */
5604
- const defineConfig$18 = definePluginConfig(defaultConfig$18);
5628
+ const defineConfig$19 = definePluginConfig(defaultConfig$19);
5605
5629
 
5606
5630
  //#endregion
5607
5631
  //#region src/plugins/@hey-api/client-next/config.ts
5608
- const defaultConfig$17 = {
5632
+ const defaultConfig$18 = {
5609
5633
  ...clientDefaultMeta,
5610
5634
  config: {
5611
5635
  ...clientDefaultConfig,
@@ -5617,11 +5641,11 @@ const defaultConfig$17 = {
5617
5641
  /**
5618
5642
  * Type helper for `@hey-api/client-next` plugin, returns {@link Plugin.Config} object
5619
5643
  */
5620
- const defineConfig$17 = definePluginConfig(defaultConfig$17);
5644
+ const defineConfig$18 = definePluginConfig(defaultConfig$18);
5621
5645
 
5622
5646
  //#endregion
5623
5647
  //#region src/plugins/@hey-api/client-nuxt/config.ts
5624
- const defaultConfig$16 = {
5648
+ const defaultConfig$17 = {
5625
5649
  ...clientDefaultMeta,
5626
5650
  config: clientDefaultConfig,
5627
5651
  handler: clientPluginHandler,
@@ -5630,11 +5654,11 @@ const defaultConfig$16 = {
5630
5654
  /**
5631
5655
  * Type helper for `@hey-api/client-nuxt` plugin, returns {@link Plugin.Config} object
5632
5656
  */
5633
- const defineConfig$16 = definePluginConfig(defaultConfig$16);
5657
+ const defineConfig$17 = definePluginConfig(defaultConfig$17);
5634
5658
 
5635
5659
  //#endregion
5636
5660
  //#region src/plugins/@hey-api/client-ofetch/config.ts
5637
- const defaultConfig$15 = {
5661
+ const defaultConfig$16 = {
5638
5662
  ...clientDefaultMeta,
5639
5663
  config: {
5640
5664
  ...clientDefaultConfig,
@@ -5646,7 +5670,7 @@ const defaultConfig$15 = {
5646
5670
  /**
5647
5671
  * Type helper for `@hey-api/client-ofetch` plugin, returns {@link Plugin.Config} object
5648
5672
  */
5649
- const defineConfig$15 = definePluginConfig(defaultConfig$15);
5673
+ const defineConfig$16 = definePluginConfig(defaultConfig$16);
5650
5674
 
5651
5675
  //#endregion
5652
5676
  //#region src/plugins/@hey-api/schemas/plugin.ts
@@ -5904,7 +5928,7 @@ const handler$10 = ({ plugin }) => {
5904
5928
 
5905
5929
  //#endregion
5906
5930
  //#region src/plugins/@hey-api/schemas/config.ts
5907
- const defaultConfig$14 = {
5931
+ const defaultConfig$15 = {
5908
5932
  config: {
5909
5933
  includeInEntry: false,
5910
5934
  nameBuilder: (name) => `${name}Schema`,
@@ -5916,7 +5940,7 @@ const defaultConfig$14 = {
5916
5940
  /**
5917
5941
  * Type helper for `@hey-api/schemas` plugin, returns {@link Plugin.Config} object
5918
5942
  */
5919
- const defineConfig$14 = definePluginConfig(defaultConfig$14);
5943
+ const defineConfig$15 = definePluginConfig(defaultConfig$15);
5920
5944
 
5921
5945
  //#endregion
5922
5946
  //#region src/plugins/@hey-api/sdk/examples/config.ts
@@ -6212,7 +6236,7 @@ const handler$9 = (args) => handlerV1$2(args);
6212
6236
 
6213
6237
  //#endregion
6214
6238
  //#region src/plugins/@hey-api/sdk/config.ts
6215
- const defaultConfig$13 = {
6239
+ const defaultConfig$14 = {
6216
6240
  config: {
6217
6241
  auth: true,
6218
6242
  client: true,
@@ -6255,7 +6279,7 @@ const defaultConfig$13 = {
6255
6279
  /**
6256
6280
  * Type helper for `@hey-api/sdk` plugin, returns {@link Plugin.Config} object
6257
6281
  */
6258
- const defineConfig$13 = definePluginConfig(defaultConfig$13);
6282
+ const defineConfig$14 = definePluginConfig(defaultConfig$14);
6259
6283
 
6260
6284
  //#endregion
6261
6285
  //#region src/plugins/@hey-api/transformers/expressions.ts
@@ -6439,7 +6463,7 @@ const handler$8 = ({ plugin }) => {
6439
6463
 
6440
6464
  //#endregion
6441
6465
  //#region src/plugins/@hey-api/transformers/config.ts
6442
- const defaultConfig$12 = {
6466
+ const defaultConfig$13 = {
6443
6467
  config: {
6444
6468
  bigInt: true,
6445
6469
  dates: true,
@@ -6460,7 +6484,7 @@ const defaultConfig$12 = {
6460
6484
  /**
6461
6485
  * Type helper for `@hey-api/transformers`, returns {@link Plugin.Config} object
6462
6486
  */
6463
- const defineConfig$12 = definePluginConfig(defaultConfig$12);
6487
+ const defineConfig$13 = definePluginConfig(defaultConfig$13);
6464
6488
 
6465
6489
  //#endregion
6466
6490
  //#region src/plugins/@hey-api/typescript/shared/clientOptions.ts
@@ -6571,7 +6595,7 @@ const exportType = ({ plugin, schema, state, type }) => {
6571
6595
  tags: fromRef(state.tags),
6572
6596
  tool: "typescript"
6573
6597
  } });
6574
- const node$1 = $.type.alias(symbol$1).export().$if(plugin.config.comments && createSchemaComment(schema), (t, v) => t.doc(v)).type($.type(symbol$1).idx($.type(symbol$1).typeofType().keyof()).typeofType());
6598
+ const node$1 = $.type.alias(symbol$1).export().$if(plugin.config.comments && createSchemaComment(schema), (t, v) => t.doc(v)).type($.type(symbolObject).idx($.type(symbolObject).typeofType().keyof()).typeofType());
6575
6599
  plugin.node(node$1);
6576
6600
  return;
6577
6601
  } else if (plugin.config.enums.mode === "typescript" || plugin.config.enums.mode === "typescript-const") {
@@ -7235,7 +7259,7 @@ const handler$7 = (args) => handlerV1$1(args);
7235
7259
 
7236
7260
  //#endregion
7237
7261
  //#region src/plugins/@hey-api/typescript/config.ts
7238
- const defaultConfig$11 = {
7262
+ const defaultConfig$12 = {
7239
7263
  api: new Api$3(),
7240
7264
  config: {
7241
7265
  case: "PascalCase",
@@ -7322,7 +7346,7 @@ const defaultConfig$11 = {
7322
7346
  /**
7323
7347
  * Type helper for `@hey-api/typescript` plugin, returns {@link Plugin.Config} object
7324
7348
  */
7325
- const defineConfig$11 = definePluginConfig(defaultConfig$11);
7349
+ const defineConfig$12 = definePluginConfig(defaultConfig$12);
7326
7350
 
7327
7351
  //#endregion
7328
7352
  //#region src/plugins/@pinia/colada/meta.ts
@@ -7540,7 +7564,13 @@ const createQueryOptions$1 = ({ operation, plugin }) => {
7540
7564
  tool: plugin.name
7541
7565
  } });
7542
7566
  const symbolDefineQueryOptions = plugin.external(`${plugin.name}.defineQueryOptions`);
7543
- const statement = $.const(symbolQueryOptionsFn).export().$if(plugin.config.comments && createOperationComment(operation), (c, v) => c.doc(v)).assign($(symbolDefineQueryOptions).call($.func().param(optionsParamName$2, (p) => p.required(isRequiredOptions).type(typeData)).do($.return(queryOpts))));
7567
+ const statement = $.const(symbolQueryOptionsFn).export().$if(plugin.config.comments && createOperationComment(operation), (c, v) => c.doc(v)).assign($(symbolDefineQueryOptions).call($.func().param(optionsParamName$2, (p) => p.required(isRequiredOptions).type(typeData)).do($.return(queryOpts))).generics(typeData, useTypeResponse$1({
7568
+ operation,
7569
+ plugin
7570
+ }), useTypeError$1({
7571
+ operation,
7572
+ plugin
7573
+ })));
7544
7574
  plugin.node(statement);
7545
7575
  };
7546
7576
 
@@ -7608,7 +7638,7 @@ const handler$6 = (args) => handlerV0(args);
7608
7638
 
7609
7639
  //#endregion
7610
7640
  //#region src/plugins/@pinia/colada/config.ts
7611
- const defaultConfig$10 = {
7641
+ const defaultConfig$11 = {
7612
7642
  config: {
7613
7643
  case: "camelCase",
7614
7644
  comments: true,
@@ -7651,7 +7681,7 @@ const defaultConfig$10 = {
7651
7681
  /**
7652
7682
  * Type helper for `@pinia/colada` plugin, returns {@link Plugin.Config} object
7653
7683
  */
7654
- const defineConfig$10 = definePluginConfig(defaultConfig$10);
7684
+ const defineConfig$11 = definePluginConfig(defaultConfig$11);
7655
7685
 
7656
7686
  //#endregion
7657
7687
  //#region src/plugins/@tanstack/query-core/shared/useType.ts
@@ -7877,7 +7907,7 @@ const createMutationOptions = ({ operation, plugin }) => {
7877
7907
  role: "mutationOptions",
7878
7908
  tool: plugin.name
7879
7909
  } });
7880
- const statement = $.const(symbolMutationOptions).export().$if(plugin.config.comments && createOperationComment(operation), (c, v) => c.doc(v)).assign($.func().param("options", (p) => p.optional().type($.type("Partial").generic(typeData))).returns(mutationType).do($.const(mutationOptionsFn).type(mutationType).assign($.object().pretty().prop("mutationFn", $.func().async().param(fnOptions$1).do(...statements)).$if(handleMeta(plugin, operation, "mutationOptions"), (c, v) => c.prop("meta", v))), $(mutationOptionsFn).return()));
7910
+ const statement = $.const(symbolMutationOptions).export(plugin.config.mutationOptions.exported).$if(plugin.config.comments && createOperationComment(operation), (c, v) => c.doc(v)).assign($.func().param("options", (p) => p.optional().type($.type("Partial").generic(typeData))).returns(mutationType).do($.const(mutationOptionsFn).type(mutationType).assign($.object().pretty().prop("mutationFn", $.func().async().param(fnOptions$1).do(...statements)).$if(handleMeta(plugin, operation, "mutationOptions"), (c, v) => c.prop("meta", v))), $(mutationOptionsFn).return()));
7881
7911
  plugin.node(statement);
7882
7912
  };
7883
7913
 
@@ -7937,6 +7967,38 @@ const createQueryOptions = ({ operation, plugin }) => {
7937
7967
  plugin.node(statement);
7938
7968
  };
7939
7969
 
7970
+ //#endregion
7971
+ //#region src/plugins/@tanstack/query-core/v5/useMutation.ts
7972
+ const mutationOptionsParamName = "mutationOptions";
7973
+ const createUseMutation = ({ operation, plugin }) => {
7974
+ if (!("useMutation" in plugin.config)) return;
7975
+ const symbolUseMutationFn = plugin.symbol(applyNaming(operation.id, plugin.config.useMutation));
7976
+ const symbolUseMutation = plugin.external(`${plugin.name}.useMutation`);
7977
+ const typeData = useTypeData({
7978
+ operation,
7979
+ plugin
7980
+ });
7981
+ const symbolMutationOptionsType = plugin.external(`${plugin.name}.MutationOptions`);
7982
+ const mutationType = $.type(symbolMutationOptionsType).generic(useTypeResponse({
7983
+ operation,
7984
+ plugin
7985
+ })).generic(useTypeError({
7986
+ operation,
7987
+ plugin
7988
+ })).generic(typeData);
7989
+ const symbolMutationOptionsFn = plugin.referenceSymbol({
7990
+ category: "hook",
7991
+ resource: "operation",
7992
+ resourceId: operation.id,
7993
+ role: "mutationOptions",
7994
+ tool: plugin.name
7995
+ });
7996
+ const func = $.func().param(mutationOptionsParamName, (p) => p.optional().type($.type("Partial").generic($.type("Omit", (t) => t.generics(mutationType, $.type.literal("mutationFn"))))));
7997
+ func.do($(symbolUseMutation).call($.object().spread($(symbolMutationOptionsFn).call()).spread(mutationOptionsParamName)).return());
7998
+ const statement = $.const(symbolUseMutationFn).export().$if(plugin.config.comments && createOperationComment(operation), (c, v) => c.doc(v)).assign(func);
7999
+ plugin.node(statement);
8000
+ };
8001
+
7940
8002
  //#endregion
7941
8003
  //#region src/plugins/@tanstack/query-core/v5/useQuery.ts
7942
8004
  const optionsParamName = "options";
@@ -8006,6 +8068,13 @@ const handlerV5 = ({ plugin }) => {
8006
8068
  resource: `${plugin.name}.queryOptions`
8007
8069
  }
8008
8070
  });
8071
+ plugin.symbol("useMutation", {
8072
+ external: plugin.name,
8073
+ meta: {
8074
+ category: "external",
8075
+ resource: `${plugin.name}.useMutation`
8076
+ }
8077
+ });
8009
8078
  plugin.symbol("useQuery", {
8010
8079
  external: plugin.name,
8011
8080
  meta: {
@@ -8041,6 +8110,10 @@ const handlerV5 = ({ plugin }) => {
8041
8110
  operation,
8042
8111
  plugin
8043
8112
  });
8113
+ if ("useMutation" in plugin.config && plugin.config.useMutation.enabled) createUseMutation({
8114
+ operation,
8115
+ plugin
8116
+ });
8044
8117
  }
8045
8118
  }, { order: "declarations" });
8046
8119
  };
@@ -8051,7 +8124,7 @@ const handler$5 = (args) => handlerV5(args);
8051
8124
 
8052
8125
  //#endregion
8053
8126
  //#region src/plugins/@tanstack/angular-query-experimental/config.ts
8054
- const defaultConfig$9 = {
8127
+ const defaultConfig$10 = {
8055
8128
  config: {
8056
8129
  case: "camelCase",
8057
8130
  comments: true,
@@ -8084,6 +8157,7 @@ const defaultConfig$9 = {
8084
8157
  defaultValue: {
8085
8158
  case: plugin.config.case ?? "camelCase",
8086
8159
  enabled: true,
8160
+ exported: true,
8087
8161
  name: "{{name}}Mutation"
8088
8162
  },
8089
8163
  mappers,
@@ -8114,6 +8188,132 @@ const defaultConfig$9 = {
8114
8188
  /**
8115
8189
  * Type helper for `@tanstack/angular-query-experimental` plugin, returns {@link Plugin.Config} object
8116
8190
  */
8191
+ const defineConfig$10 = definePluginConfig(defaultConfig$10);
8192
+
8193
+ //#endregion
8194
+ //#region src/plugins/@tanstack/preact-query/config.ts
8195
+ const defaultConfig$9 = {
8196
+ config: {
8197
+ case: "camelCase",
8198
+ comments: true,
8199
+ includeInEntry: false
8200
+ },
8201
+ dependencies: ["@hey-api/sdk", "@hey-api/typescript"],
8202
+ handler: handler$5,
8203
+ name: "@tanstack/preact-query",
8204
+ resolveConfig: (plugin, context) => {
8205
+ plugin.config.infiniteQueryKeys = context.valueToObject({
8206
+ defaultValue: {
8207
+ case: plugin.config.case ?? "camelCase",
8208
+ enabled: true,
8209
+ name: "{{name}}InfiniteQueryKey",
8210
+ tags: false
8211
+ },
8212
+ mappers,
8213
+ value: plugin.config.infiniteQueryKeys
8214
+ });
8215
+ plugin.config.infiniteQueryOptions = context.valueToObject({
8216
+ defaultValue: {
8217
+ case: plugin.config.case ?? "camelCase",
8218
+ enabled: true,
8219
+ name: "{{name}}InfiniteOptions"
8220
+ },
8221
+ mappers,
8222
+ value: plugin.config.infiniteQueryOptions
8223
+ });
8224
+ plugin.config.mutationOptions = context.valueToObject({
8225
+ defaultValue: {
8226
+ case: plugin.config.case ?? "camelCase",
8227
+ enabled: true,
8228
+ exported: true,
8229
+ name: "{{name}}Mutation"
8230
+ },
8231
+ mappers,
8232
+ value: plugin.config.mutationOptions
8233
+ });
8234
+ plugin.config.queryKeys = context.valueToObject({
8235
+ defaultValue: {
8236
+ case: plugin.config.case ?? "camelCase",
8237
+ enabled: true,
8238
+ name: "{{name}}QueryKey",
8239
+ tags: false
8240
+ },
8241
+ mappers,
8242
+ value: plugin.config.queryKeys
8243
+ });
8244
+ plugin.config.queryOptions = context.valueToObject({
8245
+ defaultValue: {
8246
+ case: plugin.config.case ?? "camelCase",
8247
+ enabled: true,
8248
+ exported: true,
8249
+ name: "{{name}}Options"
8250
+ },
8251
+ mappers,
8252
+ value: plugin.config.queryOptions
8253
+ });
8254
+ plugin.config.useMutation = context.valueToObject({
8255
+ defaultValue: {
8256
+ case: plugin.config.case ?? "camelCase",
8257
+ enabled: false,
8258
+ name: "use{{name}}Mutation"
8259
+ },
8260
+ mappers: {
8261
+ boolean: (enabled) => ({ enabled }),
8262
+ function: (name) => ({
8263
+ enabled: true,
8264
+ name
8265
+ }),
8266
+ object: (fields) => ({
8267
+ enabled: true,
8268
+ ...fields
8269
+ }),
8270
+ string: (name) => ({
8271
+ enabled: true,
8272
+ name
8273
+ })
8274
+ },
8275
+ value: plugin.config.useMutation
8276
+ });
8277
+ plugin.config.useQuery = context.valueToObject({
8278
+ defaultValue: {
8279
+ case: plugin.config.case ?? "camelCase",
8280
+ enabled: false,
8281
+ name: "use{{name}}Query"
8282
+ },
8283
+ mappers: {
8284
+ boolean: (enabled) => ({ enabled }),
8285
+ function: (name) => ({
8286
+ enabled: true,
8287
+ name
8288
+ }),
8289
+ object: (fields) => ({
8290
+ enabled: true,
8291
+ ...fields
8292
+ }),
8293
+ string: (name) => ({
8294
+ enabled: true,
8295
+ name
8296
+ })
8297
+ },
8298
+ value: plugin.config.useQuery
8299
+ });
8300
+ if (plugin.config.useMutation.enabled) {
8301
+ if (!plugin.config.mutationOptions.enabled) {
8302
+ plugin.config.mutationOptions.enabled = true;
8303
+ plugin.config.mutationOptions.exported = false;
8304
+ }
8305
+ }
8306
+ if (plugin.config.useQuery.enabled) {
8307
+ if (!plugin.config.queryOptions.enabled) {
8308
+ plugin.config.queryOptions.enabled = true;
8309
+ plugin.config.queryOptions.exported = false;
8310
+ }
8311
+ }
8312
+ }
8313
+ };
8314
+ /**
8315
+ * Type helper for `@tanstack/preact-query` plugin, returns {@link Plugin.Config} object
8316
+ */
8117
8317
  const defineConfig$9 = definePluginConfig(defaultConfig$9);
8118
8318
 
8119
8319
  //#endregion
@@ -8151,6 +8351,7 @@ const defaultConfig$8 = {
8151
8351
  defaultValue: {
8152
8352
  case: plugin.config.case ?? "camelCase",
8153
8353
  enabled: true,
8354
+ exported: true,
8154
8355
  name: "{{name}}Mutation"
8155
8356
  },
8156
8357
  mappers,
@@ -8176,6 +8377,29 @@ const defaultConfig$8 = {
8176
8377
  mappers,
8177
8378
  value: plugin.config.queryOptions
8178
8379
  });
8380
+ plugin.config.useMutation = context.valueToObject({
8381
+ defaultValue: {
8382
+ case: plugin.config.case ?? "camelCase",
8383
+ enabled: false,
8384
+ name: "use{{name}}Mutation"
8385
+ },
8386
+ mappers: {
8387
+ boolean: (enabled) => ({ enabled }),
8388
+ function: (name) => ({
8389
+ enabled: true,
8390
+ name
8391
+ }),
8392
+ object: (fields) => ({
8393
+ enabled: true,
8394
+ ...fields
8395
+ }),
8396
+ string: (name) => ({
8397
+ enabled: true,
8398
+ name
8399
+ })
8400
+ },
8401
+ value: plugin.config.useMutation
8402
+ });
8179
8403
  plugin.config.useQuery = context.valueToObject({
8180
8404
  defaultValue: {
8181
8405
  case: plugin.config.case ?? "camelCase",
@@ -8199,6 +8423,12 @@ const defaultConfig$8 = {
8199
8423
  },
8200
8424
  value: plugin.config.useQuery
8201
8425
  });
8426
+ if (plugin.config.useMutation.enabled) {
8427
+ if (!plugin.config.mutationOptions.enabled) {
8428
+ plugin.config.mutationOptions.enabled = true;
8429
+ plugin.config.mutationOptions.exported = false;
8430
+ }
8431
+ }
8202
8432
  if (plugin.config.useQuery.enabled) {
8203
8433
  if (!plugin.config.queryOptions.enabled) {
8204
8434
  plugin.config.queryOptions.enabled = true;
@@ -8247,6 +8477,7 @@ const defaultConfig$7 = {
8247
8477
  defaultValue: {
8248
8478
  case: plugin.config.case ?? "camelCase",
8249
8479
  enabled: true,
8480
+ exported: true,
8250
8481
  name: "{{name}}Mutation"
8251
8482
  },
8252
8483
  mappers,
@@ -8314,6 +8545,7 @@ const defaultConfig$6 = {
8314
8545
  defaultValue: {
8315
8546
  case: plugin.config.case ?? "camelCase",
8316
8547
  enabled: true,
8548
+ exported: true,
8317
8549
  name: "{{name}}Mutation"
8318
8550
  },
8319
8551
  mappers,
@@ -8381,6 +8613,7 @@ const defaultConfig$5 = {
8381
8613
  defaultValue: {
8382
8614
  case: plugin.config.case ?? "camelCase",
8383
8615
  enabled: true,
8616
+ exported: true,
8384
8617
  name: "{{name}}Mutation"
8385
8618
  },
8386
8619
  mappers,
@@ -10368,14 +10601,21 @@ function createVisitor$3(config) {
10368
10601
  };
10369
10602
  },
10370
10603
  postProcess(result, schema, ctx$1) {
10371
- if (ctx$1.plugin.config.metadata && schema.description) {
10372
- const metadataExpr = $(ctx$1.plugin.external("valibot.v")).attr(identifiers$1.actions.metadata).call($.object().prop("description", $.literal(schema.description)));
10373
- return {
10374
- meta: result.meta,
10375
- pipes: [...result.pipes, metadataExpr]
10376
- };
10377
- }
10378
- return result;
10604
+ const metadata = ctx$1.plugin.config.metadata;
10605
+ if (!metadata) return result;
10606
+ const node = $.object();
10607
+ if (typeof metadata === "function") metadata({
10608
+ $,
10609
+ node,
10610
+ schema
10611
+ });
10612
+ else if (schema.description) node.prop("description", $.literal(schema.description));
10613
+ if (node.isEmpty) return result;
10614
+ const metadataExpr = $(ctx$1.plugin.external("valibot.v")).attr(identifiers$1.actions.metadata).call(node);
10615
+ return {
10616
+ meta: result.meta,
10617
+ pipes: [...result.pipes, metadataExpr]
10618
+ };
10379
10619
  },
10380
10620
  reference($ref, schema, ctx$1) {
10381
10621
  const v = ctx$1.plugin.external("valibot.v");
@@ -10490,10 +10730,10 @@ function createVisitor$3(config) {
10490
10730
  //#region src/plugins/valibot/v1/processor.ts
10491
10731
  function createProcessor$3(plugin) {
10492
10732
  const processor = createSchemaProcessor();
10493
- const hooks = [plugin.config["~hooks"]?.schemas, plugin.context.config.parser.hooks.schemas];
10733
+ const extractorHooks = [plugin.config["~hooks"]?.schemas?.shouldExtract, plugin.context.config.parser.hooks.schemas?.shouldExtract];
10494
10734
  function extractor(ctx$1) {
10495
10735
  if (processor.hasEmitted(ctx$1.path)) return ctx$1.schema;
10496
- for (const hook of hooks) if (hook?.shouldExtract?.(ctx$1)) {
10736
+ for (const hook of extractorHooks) if (hook?.(ctx$1)) {
10497
10737
  process$1({
10498
10738
  namingAnchor: processor.context.anchor,
10499
10739
  tags: processor.context.tags,
@@ -11708,14 +11948,21 @@ function createVisitor$2(config) {
11708
11948
  };
11709
11949
  },
11710
11950
  postProcess(result, schema, ctx$1) {
11711
- if (ctx$1.plugin.config.metadata && schema.description) {
11712
- const z = ctx$1.plugin.external("zod.z");
11713
- return {
11714
- ...result,
11715
- expression: { expression: result.expression.expression.attr(identifiers.register).call($(z).attr(identifiers.globalRegistry), $.object().pretty().prop("description", $.literal(schema.description))) }
11716
- };
11717
- }
11718
- return result;
11951
+ const metadata = ctx$1.plugin.config.metadata;
11952
+ if (!metadata) return result;
11953
+ const node = $.object();
11954
+ if (typeof metadata === "function") metadata({
11955
+ $,
11956
+ node,
11957
+ schema
11958
+ });
11959
+ else if (schema.description) node.pretty().prop("description", $.literal(schema.description));
11960
+ if (node.isEmpty) return result;
11961
+ const z = ctx$1.plugin.external("zod.z");
11962
+ return {
11963
+ ...result,
11964
+ expression: { expression: result.expression.expression.attr(identifiers.register).call($(z).attr(identifiers.globalRegistry), node) }
11965
+ };
11719
11966
  },
11720
11967
  reference($ref, schema, ctx$1) {
11721
11968
  const z = ctx$1.plugin.external("zod.z");
@@ -13431,14 +13678,21 @@ function createVisitor(config) {
13431
13678
  };
13432
13679
  },
13433
13680
  postProcess(result, schema, ctx$1) {
13434
- if (ctx$1.plugin.config.metadata && schema.description) {
13435
- const z = ctx$1.plugin.external("zod.z");
13436
- return {
13437
- ...result,
13438
- expression: { expression: result.expression.expression.attr(identifiers.register).call($(z).attr(identifiers.globalRegistry), $.object().pretty().prop("description", $.literal(schema.description))) }
13439
- };
13440
- }
13441
- return result;
13681
+ const metadata = ctx$1.plugin.config.metadata;
13682
+ if (!metadata) return result;
13683
+ const node = $.object();
13684
+ if (typeof metadata === "function") metadata({
13685
+ $,
13686
+ node,
13687
+ schema
13688
+ });
13689
+ else if (schema.description) node.pretty().prop("description", $.literal(schema.description));
13690
+ if (node.isEmpty) return result;
13691
+ const z = ctx$1.plugin.external("zod.z");
13692
+ return {
13693
+ ...result,
13694
+ expression: { expression: result.expression.expression.attr(identifiers.register).call($(z).attr(identifiers.globalRegistry), node) }
13695
+ };
13442
13696
  },
13443
13697
  reference($ref, schema, ctx$1) {
13444
13698
  const z = ctx$1.plugin.external("zod.z");
@@ -13919,21 +14173,22 @@ const defineConfig = definePluginConfig(defaultConfig);
13919
14173
  //#endregion
13920
14174
  //#region src/plugins/config.ts
13921
14175
  const defaultPluginConfigs = {
13922
- "@angular/common": defaultConfig$23,
13923
- "@faker-js/faker": defaultConfig$22,
13924
- "@hey-api/client-angular": defaultConfig$21,
13925
- "@hey-api/client-axios": defaultConfig$20,
13926
- "@hey-api/client-fetch": defaultConfig$19,
13927
- "@hey-api/client-ky": defaultConfig$18,
13928
- "@hey-api/client-next": defaultConfig$17,
13929
- "@hey-api/client-nuxt": defaultConfig$16,
13930
- "@hey-api/client-ofetch": defaultConfig$15,
13931
- "@hey-api/schemas": defaultConfig$14,
13932
- "@hey-api/sdk": defaultConfig$13,
13933
- "@hey-api/transformers": defaultConfig$12,
13934
- "@hey-api/typescript": defaultConfig$11,
13935
- "@pinia/colada": defaultConfig$10,
13936
- "@tanstack/angular-query-experimental": defaultConfig$9,
14176
+ "@angular/common": defaultConfig$24,
14177
+ "@faker-js/faker": defaultConfig$23,
14178
+ "@hey-api/client-angular": defaultConfig$22,
14179
+ "@hey-api/client-axios": defaultConfig$21,
14180
+ "@hey-api/client-fetch": defaultConfig$20,
14181
+ "@hey-api/client-ky": defaultConfig$19,
14182
+ "@hey-api/client-next": defaultConfig$18,
14183
+ "@hey-api/client-nuxt": defaultConfig$17,
14184
+ "@hey-api/client-ofetch": defaultConfig$16,
14185
+ "@hey-api/schemas": defaultConfig$15,
14186
+ "@hey-api/sdk": defaultConfig$14,
14187
+ "@hey-api/transformers": defaultConfig$13,
14188
+ "@hey-api/typescript": defaultConfig$12,
14189
+ "@pinia/colada": defaultConfig$11,
14190
+ "@tanstack/angular-query-experimental": defaultConfig$10,
14191
+ "@tanstack/preact-query": defaultConfig$9,
13937
14192
  "@tanstack/react-query": defaultConfig$8,
13938
14193
  "@tanstack/solid-query": defaultConfig$7,
13939
14194
  "@tanstack/svelte-query": defaultConfig$6,
@@ -13977,12 +14232,12 @@ function getPluginsConfig({ dependencies, userPlugins, userPluginsConfig }) {
13977
14232
  pluginByTag: (tag, props = {}) => {
13978
14233
  const { defaultPlugin: defaultPlugin$1, errorMessage } = props;
13979
14234
  for (const userPlugin$1 of userPlugins) {
13980
- const defaultConfig$24 = defaultPluginConfigs[userPlugin$1] || userPluginsConfig[userPlugin$1];
13981
- if (defaultConfig$24 && defaultConfig$24.tags?.includes(tag) && userPlugin$1 !== name) return userPlugin$1;
14235
+ const defaultConfig$25 = defaultPluginConfigs[userPlugin$1] || userPluginsConfig[userPlugin$1];
14236
+ if (defaultConfig$25 && defaultConfig$25.tags?.includes(tag) && userPlugin$1 !== name) return userPlugin$1;
13982
14237
  }
13983
14238
  if (defaultPlugin$1) {
13984
- const defaultConfig$24 = defaultPluginConfigs[defaultPlugin$1] || userPluginsConfig[defaultPlugin$1];
13985
- if (defaultConfig$24 && defaultConfig$24.tags?.includes(tag) && defaultPlugin$1 !== name) return defaultPlugin$1;
14239
+ const defaultConfig$25 = defaultPluginConfigs[defaultPlugin$1] || userPluginsConfig[defaultPlugin$1];
14240
+ if (defaultConfig$25 && defaultConfig$25.tags?.includes(tag) && defaultPlugin$1 !== name) return defaultPlugin$1;
13986
14241
  }
13987
14242
  throw new Error(errorMessage || `missing plugin - no plugin with tag "${tag}" found`);
13988
14243
  },
@@ -14124,4 +14379,4 @@ async function resolveJobs({ logger, userConfigs }) {
14124
14379
 
14125
14380
  //#endregion
14126
14381
  export { postProcessors as _, clientDefaultConfig as a, TypeScriptRenderer as c, reserved as d, keywords as f, getTypedConfig as g, getClientPlugin as h, generateClientBundle as i, TsDslContext as l, TsDsl as m, defaultPlugins as n, clientDefaultMeta as o, regexp as p, clientPluginHandler as r, $ as s, resolveJobs as t, ctx as u };
14127
- //# sourceMappingURL=init-CuDouDN2.mjs.map
14382
+ //# sourceMappingURL=init-PHWYaLgi.mjs.map