@orval/query 6.30.2 → 7.0.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
@@ -1592,7 +1592,7 @@ __export(src_exports, {
1592
1592
  getVueQueryDependencies: () => getVueQueryDependencies
1593
1593
  });
1594
1594
  module.exports = __toCommonJS(src_exports);
1595
- var import_core2 = require("@orval/core");
1595
+ var import_core3 = require("@orval/core");
1596
1596
  var import_lodash = __toESM(require("lodash.omitby"));
1597
1597
 
1598
1598
  // src/utils.ts
@@ -1672,18 +1672,9 @@ var wrapRouteParameters = (route, prepend, append) => route.replaceAll(import_co
1672
1672
  var makeRouteSafe = (route) => wrapRouteParameters(route, "encodeURIComponent(String(", "))");
1673
1673
  var isVue = (client) => import_core.OutputClient.VUE_QUERY === client;
1674
1674
 
1675
- // src/index.ts
1676
- var REACT_DEPENDENCIES = [
1677
- {
1678
- exports: [
1679
- {
1680
- name: "useCallback",
1681
- values: true
1682
- }
1683
- ],
1684
- dependency: "react"
1685
- }
1686
- ];
1675
+ // src/client.ts
1676
+ var import_core2 = require("@orval/core");
1677
+ var import_fetch = require("@orval/fetch");
1687
1678
  var AXIOS_DEPENDENCIES = [
1688
1679
  {
1689
1680
  exports: [
@@ -1700,6 +1691,230 @@ var AXIOS_DEPENDENCIES = [
1700
1691
  dependency: "axios"
1701
1692
  }
1702
1693
  ];
1694
+ var generateQueryRequestFunction = (verbOptions, options, isVue3) => {
1695
+ if (options.context.output.httpClient === import_core2.OutputHttpClient.AXIOS) {
1696
+ return generateAxiosRequestFunction(verbOptions, options, isVue3);
1697
+ } else {
1698
+ return (0, import_fetch.generateRequestFunction)(verbOptions, options);
1699
+ }
1700
+ };
1701
+ var generateAxiosRequestFunction = ({
1702
+ headers,
1703
+ queryParams,
1704
+ operationName,
1705
+ response,
1706
+ mutator,
1707
+ body,
1708
+ props: _props,
1709
+ verb,
1710
+ formData,
1711
+ formUrlEncoded,
1712
+ override,
1713
+ paramsSerializer
1714
+ }, { route: _route, context }, isVue3) => {
1715
+ var _a, _b, _c;
1716
+ let props = _props;
1717
+ let route = _route;
1718
+ if (isVue3) {
1719
+ props = vueWrapTypeWithMaybeRef(_props);
1720
+ }
1721
+ if ((_a = context.output) == null ? void 0 : _a.urlEncodeParameters) {
1722
+ route = makeRouteSafe(route);
1723
+ }
1724
+ const isRequestOptions = override.requestOptions !== false;
1725
+ const isFormData = override.formData !== false;
1726
+ const isFormUrlEncoded = override.formUrlEncoded !== false;
1727
+ const hasSignal = !!override.query.signal;
1728
+ const isExactOptionalPropertyTypes = !!((_c = (_b = context.output.tsconfig) == null ? void 0 : _b.compilerOptions) == null ? void 0 : _c.exactOptionalPropertyTypes);
1729
+ const isBodyVerb = import_core2.VERBS_WITH_BODY.includes(verb);
1730
+ const bodyForm = (0, import_core2.generateFormDataAndUrlEncodedFunction)({
1731
+ formData,
1732
+ formUrlEncoded,
1733
+ body,
1734
+ isFormData,
1735
+ isFormUrlEncoded
1736
+ });
1737
+ if (mutator) {
1738
+ const mutatorConfig = (0, import_core2.generateMutatorConfig)({
1739
+ route,
1740
+ body,
1741
+ headers,
1742
+ queryParams,
1743
+ response,
1744
+ verb,
1745
+ isFormData,
1746
+ isFormUrlEncoded,
1747
+ isBodyVerb,
1748
+ hasSignal,
1749
+ isExactOptionalPropertyTypes,
1750
+ isVue: isVue3
1751
+ });
1752
+ let bodyDefinition = body.definition.replace("[]", "\\[\\]");
1753
+ let propsImplementation = (mutator == null ? void 0 : mutator.bodyTypeName) && body.definition ? (0, import_core2.toObjectString)(props, "implementation").replace(
1754
+ new RegExp(`(\\w*):\\s?${bodyDefinition}`),
1755
+ `$1: ${mutator.bodyTypeName}<${body.definition}>`
1756
+ ) : (0, import_core2.toObjectString)(props, "implementation");
1757
+ const requestOptions = isRequestOptions ? (0, import_core2.generateMutatorRequestOptions)(
1758
+ override.requestOptions,
1759
+ mutator.hasSecondArg
1760
+ ) : "";
1761
+ if (mutator.isHook) {
1762
+ return `${override.query.shouldExportMutatorHooks ? "export " : ""}const use${(0, import_core2.pascal)(operationName)}Hook = () => {
1763
+ const ${operationName} = ${mutator.name}<${response.definition.success || "unknown"}>();
1764
+
1765
+ return useCallback((
1766
+ ${propsImplementation}
1767
+ ${isRequestOptions && mutator.hasSecondArg ? `options${context.output.optionsParamRequired ? "" : "?"}: SecondParameter<ReturnType<typeof ${mutator.name}>>,` : ""}${!isBodyVerb && hasSignal ? "signal?: AbortSignal\n" : ""}) => {${bodyForm}
1768
+ return ${operationName}(
1769
+ ${mutatorConfig},
1770
+ ${requestOptions});
1771
+ }, [${operationName}])
1772
+ }
1773
+ `;
1774
+ }
1775
+ return `${override.query.shouldExportHttpClient ? "export " : ""}const ${operationName} = (
1776
+ ${propsImplementation}
1777
+ ${isRequestOptions && mutator.hasSecondArg ? `options${context.output.optionsParamRequired ? "" : "?"}: SecondParameter<typeof ${mutator.name}>,` : ""}${!isBodyVerb && hasSignal ? "signal?: AbortSignal\n" : ""}) => {
1778
+ ${isVue3 ? vueUnRefParams(props) : ""}
1779
+ ${bodyForm}
1780
+ return ${mutator.name}<${response.definition.success || "unknown"}>(
1781
+ ${mutatorConfig},
1782
+ ${requestOptions});
1783
+ }
1784
+ `;
1785
+ }
1786
+ const isSyntheticDefaultImportsAllowed = (0, import_core2.isSyntheticDefaultImportsAllow)(
1787
+ context.output.tsconfig
1788
+ );
1789
+ const options = (0, import_core2.generateOptions)({
1790
+ route,
1791
+ body,
1792
+ headers,
1793
+ queryParams,
1794
+ response,
1795
+ verb,
1796
+ requestOptions: override == null ? void 0 : override.requestOptions,
1797
+ isFormData,
1798
+ isFormUrlEncoded,
1799
+ paramsSerializer,
1800
+ paramsSerializerOptions: override == null ? void 0 : override.paramsSerializerOptions,
1801
+ isExactOptionalPropertyTypes,
1802
+ hasSignal,
1803
+ isVue: isVue3
1804
+ });
1805
+ const optionsArgs = generateRequestOptionsArguments({
1806
+ isRequestOptions,
1807
+ hasSignal
1808
+ });
1809
+ const queryProps = (0, import_core2.toObjectString)(props, "implementation");
1810
+ const httpRequestFunctionImplementation = `export const ${operationName} = (
1811
+ ${queryProps} ${optionsArgs} ): Promise<AxiosResponse<${response.definition.success || "unknown"}>> => {${bodyForm}
1812
+ ${isVue3 ? vueUnRefParams(props) : ""}
1813
+ return axios${!isSyntheticDefaultImportsAllowed ? ".default" : ""}.${verb}(${options});
1814
+ }
1815
+ `;
1816
+ return httpRequestFunctionImplementation;
1817
+ };
1818
+ var generateRequestOptionsArguments = ({
1819
+ isRequestOptions,
1820
+ hasSignal
1821
+ }) => {
1822
+ if (isRequestOptions) {
1823
+ return "options?: AxiosRequestConfig\n";
1824
+ }
1825
+ return hasSignal ? "signal?: AbortSignal\n" : "";
1826
+ };
1827
+ var getQueryArgumentsRequestType = (httpClient, mutator) => {
1828
+ if (!mutator) {
1829
+ return httpClient === import_core2.OutputHttpClient.AXIOS ? `axios?: AxiosRequestConfig` : "fetch?: RequestInit";
1830
+ }
1831
+ if (mutator.hasSecondArg && !mutator.isHook) {
1832
+ return `request?: SecondParameter<typeof ${mutator.name}>`;
1833
+ }
1834
+ if (mutator.hasSecondArg && mutator.isHook) {
1835
+ return `request?: SecondParameter<ReturnType<typeof ${mutator.name}>>`;
1836
+ }
1837
+ return "";
1838
+ };
1839
+ var getQueryOptions = ({
1840
+ isRequestOptions,
1841
+ mutator,
1842
+ isExactOptionalPropertyTypes,
1843
+ hasSignal,
1844
+ httpClient
1845
+ }) => {
1846
+ if (!mutator && isRequestOptions) {
1847
+ const options = httpClient === import_core2.OutputHttpClient.AXIOS ? "axiosOptions" : "fetchOptions";
1848
+ if (!hasSignal) {
1849
+ return options;
1850
+ }
1851
+ return `{ ${isExactOptionalPropertyTypes ? "...(signal ? { signal } : {})" : "signal"}, ...${options} }`;
1852
+ }
1853
+ if ((mutator == null ? void 0 : mutator.hasSecondArg) && isRequestOptions) {
1854
+ if (!hasSignal) {
1855
+ return "requestOptions";
1856
+ }
1857
+ return httpClient === import_core2.OutputHttpClient.AXIOS ? "requestOptions, signal" : "{ signal, ...requestOptions }";
1858
+ }
1859
+ if (hasSignal) {
1860
+ return "signal";
1861
+ }
1862
+ return "";
1863
+ };
1864
+ var getHookOptions = ({
1865
+ isRequestOptions,
1866
+ httpClient,
1867
+ mutator
1868
+ }) => {
1869
+ if (!isRequestOptions) {
1870
+ return "";
1871
+ }
1872
+ let value = "const {query: queryOptions";
1873
+ if (!mutator) {
1874
+ const options = httpClient === import_core2.OutputHttpClient.AXIOS ? ", axios: axiosOptions" : ", fetch: fetchOptions";
1875
+ value += options;
1876
+ }
1877
+ if (mutator == null ? void 0 : mutator.hasSecondArg) {
1878
+ value += ", request: requestOptions";
1879
+ }
1880
+ value += "} = options ?? {};";
1881
+ return value;
1882
+ };
1883
+ var getQueryErrorType = (operationName, response, httpClient, mutator) => {
1884
+ if (mutator) {
1885
+ return mutator.hasErrorType ? `${mutator.default ? (0, import_core2.pascal)(operationName) : ""}ErrorType<${response.definition.errors || "unknown"}>` : response.definition.errors || "unknown";
1886
+ } else {
1887
+ const errorType = httpClient === import_core2.OutputHttpClient.AXIOS ? "AxiosError" : "Promise";
1888
+ return `${errorType}<${response.definition.errors || "unknown"}>`;
1889
+ }
1890
+ };
1891
+ var getHooksOptionImplementation = (isRequestOptions, httpClient, mutator) => {
1892
+ const options = httpClient === import_core2.OutputHttpClient.AXIOS ? ", axios: axiosOptions" : ", fetch: fetchOptions";
1893
+ return isRequestOptions ? `const {mutation: mutationOptions${!mutator ? options : (mutator == null ? void 0 : mutator.hasSecondArg) ? ", request: requestOptions" : ""}} = options ?? {};` : "";
1894
+ };
1895
+ var getMutationRequestArgs = (isRequestOptions, httpClient, mutator) => {
1896
+ const options = httpClient === import_core2.OutputHttpClient.AXIOS ? "axiosOptions" : "fetchOptions";
1897
+ return isRequestOptions ? !mutator ? options : (mutator == null ? void 0 : mutator.hasSecondArg) ? "requestOptions" : "" : "";
1898
+ };
1899
+ var getHttpFunctionQueryProps = (isVue3, httpClient, queryProperties) => {
1900
+ if (isVue3 && httpClient === import_core2.OutputHttpClient.FETCH && queryProperties) {
1901
+ return `unref(${queryProperties})`;
1902
+ }
1903
+ return queryProperties;
1904
+ };
1905
+
1906
+ // src/index.ts
1907
+ var REACT_DEPENDENCIES = [
1908
+ {
1909
+ exports: [
1910
+ {
1911
+ name: "useCallback",
1912
+ values: true
1913
+ }
1914
+ ],
1915
+ dependency: "react"
1916
+ }
1917
+ ];
1703
1918
  var PARAMS_SERIALIZER_DEPENDENCIES = [
1704
1919
  {
1705
1920
  exports: [
@@ -1762,10 +1977,10 @@ var isSvelteQueryV3 = (packageJson) => {
1762
1977
  const hasVueQueryV4 = (_f = (_d = packageJson == null ? void 0 : packageJson.dependencies) == null ? void 0 : _d["@tanstack/svelte-query"]) != null ? _f : (_e = packageJson == null ? void 0 : packageJson.devDependencies) == null ? void 0 : _e["@tanstack/svelte-query"];
1763
1978
  return !!hasVueQuery && !hasVueQueryV4;
1764
1979
  };
1765
- var getSvelteQueryDependencies = (hasGlobalMutator, hasParamsSerializerOptions, packageJson) => {
1980
+ var getSvelteQueryDependencies = (hasGlobalMutator, hasParamsSerializerOptions, packageJson, httpClient) => {
1766
1981
  const hasSvelteQueryV3 = isSvelteQueryV3(packageJson);
1767
1982
  return [
1768
- ...!hasGlobalMutator ? AXIOS_DEPENDENCIES : [],
1983
+ ...!hasGlobalMutator && httpClient === import_core3.OutputHttpClient.AXIOS ? AXIOS_DEPENDENCIES : [],
1769
1984
  ...hasParamsSerializerOptions ? PARAMS_SERIALIZER_DEPENDENCIES : [],
1770
1985
  ...hasSvelteQueryV3 ? SVELTE_QUERY_DEPENDENCIES_V3 : SVELTE_QUERY_DEPENDENCIES
1771
1986
  ];
@@ -1799,6 +2014,8 @@ var REACT_QUERY_DEPENDENCIES = [
1799
2014
  { name: "useSuspenseInfiniteQuery", values: true },
1800
2015
  { name: "useMutation", values: true },
1801
2016
  { name: "UseQueryOptions" },
2017
+ { name: "DefinedInitialDataOptions" },
2018
+ { name: "UndefinedInitialDataOptions" },
1802
2019
  { name: "UseSuspenseQueryOptions" },
1803
2020
  { name: "UseInfiniteQueryOptions" },
1804
2021
  { name: "UseSuspenseInfiniteQueryOptions" },
@@ -1806,8 +2023,10 @@ var REACT_QUERY_DEPENDENCIES = [
1806
2023
  { name: "QueryFunction" },
1807
2024
  { name: "MutationFunction" },
1808
2025
  { name: "UseQueryResult" },
2026
+ { name: "DefinedUseQueryResult" },
1809
2027
  { name: "UseSuspenseQueryResult" },
1810
2028
  { name: "UseInfiniteQueryResult" },
2029
+ { name: "DefinedUseInfiniteQueryResult" },
1811
2030
  { name: "UseSuspenseInfiniteQueryResult" },
1812
2031
  { name: "QueryKey" },
1813
2032
  { name: "QueryClient" },
@@ -1817,13 +2036,13 @@ var REACT_QUERY_DEPENDENCIES = [
1817
2036
  dependency: "@tanstack/react-query"
1818
2037
  }
1819
2038
  ];
1820
- var getReactQueryDependencies = (hasGlobalMutator, hasParamsSerializerOptions, packageJson) => {
2039
+ var getReactQueryDependencies = (hasGlobalMutator, hasParamsSerializerOptions, packageJson, httpClient) => {
1821
2040
  var _a, _b, _c, _d, _e, _f;
1822
2041
  const hasReactQuery = (_c = (_a = packageJson == null ? void 0 : packageJson.dependencies) == null ? void 0 : _a["react-query"]) != null ? _c : (_b = packageJson == null ? void 0 : packageJson.devDependencies) == null ? void 0 : _b["react-query"];
1823
2042
  const hasReactQueryV4 = (_f = (_d = packageJson == null ? void 0 : packageJson.dependencies) == null ? void 0 : _d["@tanstack/react-query"]) != null ? _f : (_e = packageJson == null ? void 0 : packageJson.devDependencies) == null ? void 0 : _e["@tanstack/react-query"];
1824
2043
  return [
1825
2044
  ...hasGlobalMutator ? REACT_DEPENDENCIES : [],
1826
- ...!hasGlobalMutator ? AXIOS_DEPENDENCIES : [],
2045
+ ...!hasGlobalMutator && httpClient === import_core3.OutputHttpClient.AXIOS ? AXIOS_DEPENDENCIES : [],
1827
2046
  ...hasParamsSerializerOptions ? PARAMS_SERIALIZER_DEPENDENCIES : [],
1828
2047
  ...hasReactQuery && !hasReactQueryV4 ? REACT_QUERY_DEPENDENCIES_V3 : REACT_QUERY_DEPENDENCIES
1829
2048
  ];
@@ -1897,10 +2116,10 @@ var isVueQueryV3 = (packageJson) => {
1897
2116
  const hasVueQueryV4 = (_f = (_d = packageJson == null ? void 0 : packageJson.dependencies) == null ? void 0 : _d["@tanstack/vue-query"]) != null ? _f : (_e = packageJson == null ? void 0 : packageJson.devDependencies) == null ? void 0 : _e["@tanstack/vue-query"];
1898
2117
  return !!hasVueQuery && !hasVueQueryV4;
1899
2118
  };
1900
- var getVueQueryDependencies = (hasGlobalMutator, hasParamsSerializerOptions, packageJson) => {
2119
+ var getVueQueryDependencies = (hasGlobalMutator, hasParamsSerializerOptions, packageJson, httpClient) => {
1901
2120
  const hasVueQueryV3 = isVueQueryV3(packageJson);
1902
2121
  return [
1903
- ...!hasGlobalMutator ? AXIOS_DEPENDENCIES : [],
2122
+ ...!hasGlobalMutator && httpClient === import_core3.OutputHttpClient.AXIOS ? AXIOS_DEPENDENCIES : [],
1904
2123
  ...hasParamsSerializerOptions ? PARAMS_SERIALIZER_DEPENDENCIES : [],
1905
2124
  ...hasVueQueryV3 ? VUE_QUERY_DEPENDENCIES_V3 : VUE_QUERY_DEPENDENCIES
1906
2125
  ];
@@ -1911,7 +2130,7 @@ var isQueryV5 = (packageJson, queryClient) => {
1911
2130
  return false;
1912
2131
  }
1913
2132
  const withoutRc = version.split("-")[0];
1914
- return (0, import_core2.compareVersions)(withoutRc, "5.0.0");
2133
+ return (0, import_core3.compareVersions)(withoutRc, "5.0.0");
1915
2134
  };
1916
2135
  var getPackageByQueryClient = (packageJson, queryClient) => {
1917
2136
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
@@ -1927,131 +2146,6 @@ var getPackageByQueryClient = (packageJson, queryClient) => {
1927
2146
  }
1928
2147
  }
1929
2148
  };
1930
- var generateRequestOptionsArguments = ({
1931
- isRequestOptions,
1932
- hasSignal
1933
- }) => {
1934
- if (isRequestOptions) {
1935
- return "options?: AxiosRequestConfig\n";
1936
- }
1937
- return hasSignal ? "signal?: AbortSignal\n" : "";
1938
- };
1939
- var generateQueryRequestFunction = ({
1940
- headers,
1941
- queryParams,
1942
- operationName,
1943
- response,
1944
- mutator,
1945
- body,
1946
- props: _props,
1947
- verb,
1948
- formData,
1949
- formUrlEncoded,
1950
- paramsSerializer,
1951
- override
1952
- }, { route: _route, context }, outputClient, output) => {
1953
- var _a, _b;
1954
- let props = _props;
1955
- let route = _route;
1956
- if (isVue(outputClient)) {
1957
- props = vueWrapTypeWithMaybeRef(_props);
1958
- }
1959
- if (output == null ? void 0 : output.urlEncodeParameters) {
1960
- route = makeRouteSafe(route);
1961
- }
1962
- const isRequestOptions = override.requestOptions !== false;
1963
- const isFormData = override.formData !== false;
1964
- const isFormUrlEncoded = override.formUrlEncoded !== false;
1965
- const hasSignal = !!override.query.signal;
1966
- const isSyntheticDefaultImportsAllowed = (0, import_core2.isSyntheticDefaultImportsAllow)(
1967
- context.output.tsconfig
1968
- );
1969
- const isExactOptionalPropertyTypes = !!((_b = (_a = context.output.tsconfig) == null ? void 0 : _a.compilerOptions) == null ? void 0 : _b.exactOptionalPropertyTypes);
1970
- const isBodyVerb = import_core2.VERBS_WITH_BODY.includes(verb);
1971
- const bodyForm = (0, import_core2.generateFormDataAndUrlEncodedFunction)({
1972
- formData,
1973
- formUrlEncoded,
1974
- body,
1975
- isFormData,
1976
- isFormUrlEncoded
1977
- });
1978
- if (mutator) {
1979
- const mutatorConfig = (0, import_core2.generateMutatorConfig)({
1980
- route,
1981
- body,
1982
- headers,
1983
- queryParams,
1984
- response,
1985
- verb,
1986
- isFormData,
1987
- isFormUrlEncoded,
1988
- isBodyVerb,
1989
- hasSignal,
1990
- isExactOptionalPropertyTypes,
1991
- isVue: isVue(outputClient)
1992
- });
1993
- let bodyDefinition = body.definition.replace("[]", "\\[\\]");
1994
- let propsImplementation = (mutator == null ? void 0 : mutator.bodyTypeName) && body.definition ? (0, import_core2.toObjectString)(props, "implementation").replace(
1995
- new RegExp(`(\\w*):\\s?${bodyDefinition}`),
1996
- `$1: ${mutator.bodyTypeName}<${body.definition}>`
1997
- ) : (0, import_core2.toObjectString)(props, "implementation");
1998
- const requestOptions = isRequestOptions ? (0, import_core2.generateMutatorRequestOptions)(
1999
- override.requestOptions,
2000
- mutator.hasSecondArg
2001
- ) : "";
2002
- if (mutator.isHook) {
2003
- return `${override.query.shouldExportMutatorHooks ? "export " : ""}const use${(0, import_core2.pascal)(operationName)}Hook = () => {
2004
- const ${operationName} = ${mutator.name}<${response.definition.success || "unknown"}>();
2005
-
2006
- return useCallback((
2007
- ${propsImplementation}
2008
- ${isRequestOptions && mutator.hasSecondArg ? `options${context.output.optionsParamRequired ? "" : "?"}: SecondParameter<ReturnType<typeof ${mutator.name}>>,` : ""}${!isBodyVerb && hasSignal ? "signal?: AbortSignal\n" : ""}) => {${bodyForm}
2009
- return ${operationName}(
2010
- ${mutatorConfig},
2011
- ${requestOptions});
2012
- }, [${operationName}])
2013
- }
2014
- `;
2015
- }
2016
- return `${override.query.shouldExportHttpClient ? "export " : ""}const ${operationName} = (
2017
- ${propsImplementation}
2018
- ${isRequestOptions && mutator.hasSecondArg ? `options${context.output.optionsParamRequired ? "" : "?"}: SecondParameter<typeof ${mutator.name}>,` : ""}${!isBodyVerb && hasSignal ? "signal?: AbortSignal\n" : ""}) => {
2019
- ${isVue(outputClient) ? vueUnRefParams(props) : ""}
2020
- ${bodyForm}
2021
- return ${mutator.name}<${response.definition.success || "unknown"}>(
2022
- ${mutatorConfig},
2023
- ${requestOptions});
2024
- }
2025
- `;
2026
- }
2027
- const options = (0, import_core2.generateOptions)({
2028
- route,
2029
- body,
2030
- headers,
2031
- queryParams,
2032
- response,
2033
- verb,
2034
- requestOptions: override == null ? void 0 : override.requestOptions,
2035
- isFormData,
2036
- isFormUrlEncoded,
2037
- paramsSerializer,
2038
- paramsSerializerOptions: override == null ? void 0 : override.paramsSerializerOptions,
2039
- isExactOptionalPropertyTypes,
2040
- hasSignal,
2041
- isVue: isVue(outputClient)
2042
- });
2043
- const optionsArgs = generateRequestOptionsArguments({
2044
- isRequestOptions,
2045
- hasSignal
2046
- });
2047
- const queryProps = (0, import_core2.toObjectString)(props, "implementation");
2048
- return `export const ${operationName} = (
2049
- ${queryProps} ${optionsArgs} ): Promise<AxiosResponse<${response.definition.success || "unknown"}>> => {${bodyForm}
2050
- ${isVue(outputClient) ? vueUnRefParams(props) : ""}
2051
- return axios${!isSyntheticDefaultImportsAllowed ? ".default" : ""}.${verb}(${options});
2052
- }
2053
- `;
2054
- };
2055
2149
  var QueryType = {
2056
2150
  INFINITE: "infiniteQuery",
2057
2151
  QUERY: "query",
@@ -2069,7 +2163,7 @@ var generateQueryOptions = ({
2069
2163
  if (options === false) {
2070
2164
  return "";
2071
2165
  }
2072
- const queryConfig = (0, import_core2.isObject)(options) ? ` ${(_a = (0, import_core2.stringify)(
2166
+ const queryConfig = (0, import_core3.isObject)(options) ? ` ${(_a = (0, import_core3.stringify)(
2073
2167
  (0, import_lodash.default)(
2074
2168
  options,
2075
2169
  (_, key) => (type !== QueryType.INFINITE || type !== QueryType.SUSPENSE_INFINITE) && INFINITE_QUERY_PROPERTIES.includes(key)
@@ -2081,19 +2175,10 @@ var generateQueryOptions = ({
2081
2175
  }
2082
2176
  return "...queryOptions";
2083
2177
  }
2084
- return `${!(0, import_core2.isObject)(options) || !options.hasOwnProperty("enabled") ? isVue(outputClient) ? `enabled: computed(() => !!(${params.map(({ name }) => `unref(${name})`).join(" && ")})),` : `enabled: !!(${params.map(({ name }) => name).join(" && ")}),` : ""}${queryConfig} ...queryOptions`;
2178
+ return `${!(0, import_core3.isObject)(options) || !options.hasOwnProperty("enabled") ? isVue(outputClient) ? `enabled: computed(() => !!(${params.map(({ name }) => `unref(${name})`).join(" && ")})),` : `enabled: !!(${params.map(({ name }) => name).join(" && ")}),` : ""}${queryConfig} ...queryOptions`;
2085
2179
  };
2086
- var getQueryArgumentsRequestType = (mutator) => {
2087
- if (!mutator) {
2088
- return `axios?: AxiosRequestConfig`;
2089
- }
2090
- if (mutator.hasSecondArg && !mutator.isHook) {
2091
- return `request?: SecondParameter<typeof ${mutator.name}>`;
2092
- }
2093
- if (mutator.hasSecondArg && mutator.isHook) {
2094
- return `request?: SecondParameter<ReturnType<typeof ${mutator.name}>>`;
2095
- }
2096
- return "";
2180
+ var isSuspenseQuery = (type) => {
2181
+ return [QueryType.SUSPENSE_INFINITE, QueryType.SUSPENSE_QUERY].includes(type);
2097
2182
  };
2098
2183
  var getQueryOptionsDefinition = ({
2099
2184
  operationName,
@@ -2104,18 +2189,27 @@ var getQueryOptionsDefinition = ({
2104
2189
  hasQueryV5,
2105
2190
  queryParams,
2106
2191
  queryParam,
2107
- isReturnType
2192
+ isReturnType,
2193
+ initialData
2108
2194
  }) => {
2109
2195
  const isMutatorHook = mutator == null ? void 0 : mutator.isHook;
2110
2196
  const prefix = !hasSvelteQueryV4 ? "Use" : "Create";
2111
2197
  const partialOptions = !isReturnType && hasQueryV5;
2112
2198
  if (type) {
2113
- const funcReturnType = `Awaited<ReturnType<${isMutatorHook ? `ReturnType<typeof use${(0, import_core2.pascal)(operationName)}Hook>` : `typeof ${operationName}`}>>`;
2114
- return `${partialOptions ? "Partial<" : ""}${prefix}${(0, import_core2.pascal)(
2199
+ const funcReturnType = `Awaited<ReturnType<${isMutatorHook ? `ReturnType<typeof use${(0, import_core3.pascal)(operationName)}Hook>` : `typeof ${operationName}`}>>`;
2200
+ const optionTypeInitialDataPostfix = initialData && !isSuspenseQuery(type) ? ` & Pick<
2201
+ ${(0, import_core3.pascal)(initialData)}InitialDataOptions<
2202
+ ${funcReturnType},
2203
+ TError,
2204
+ TData${hasQueryV5 && (type === QueryType.INFINITE || type === QueryType.SUSPENSE_INFINITE) && queryParam && queryParams ? `, QueryKey` : ""}
2205
+ > , 'initialData'
2206
+ >` : "";
2207
+ const optionType = `${prefix}${(0, import_core3.pascal)(
2115
2208
  type
2116
- )}Options<${funcReturnType}, TError, TData${hasQueryV5 && (type === QueryType.INFINITE || type === QueryType.SUSPENSE_INFINITE) && queryParam && queryParams ? `, ${funcReturnType}, QueryKey, ${queryParams == null ? void 0 : queryParams.schema.name}['${queryParam}']` : ""}>${partialOptions ? ">" : ""}`;
2209
+ )}Options<${funcReturnType}, TError, TData${hasQueryV5 && (type === QueryType.INFINITE || type === QueryType.SUSPENSE_INFINITE) && queryParam && queryParams ? `, ${funcReturnType}, QueryKey, ${queryParams == null ? void 0 : queryParams.schema.name}['${queryParam}']` : ""}>`;
2210
+ return `${partialOptions ? "Partial<" : ""}${optionType}${partialOptions ? ">" : ""}${optionTypeInitialDataPostfix}`;
2117
2211
  }
2118
- return `${prefix}MutationOptions<Awaited<ReturnType<${isMutatorHook ? `ReturnType<typeof use${(0, import_core2.pascal)(operationName)}Hook>` : `typeof ${operationName}`}>>, TError,${definitions ? `{${definitions}}` : "void"}, TContext>`;
2212
+ return `${prefix}MutationOptions<Awaited<ReturnType<${isMutatorHook ? `ReturnType<typeof use${(0, import_core3.pascal)(operationName)}Hook>` : `typeof ${operationName}`}>>, TError,${definitions ? `{${definitions}}` : "void"}, TContext>`;
2119
2213
  };
2120
2214
  var generateQueryArguments = ({
2121
2215
  operationName,
@@ -2126,7 +2220,9 @@ var generateQueryArguments = ({
2126
2220
  hasSvelteQueryV4,
2127
2221
  hasQueryV5,
2128
2222
  queryParams,
2129
- queryParam
2223
+ queryParam,
2224
+ initialData,
2225
+ httpClient
2130
2226
  }) => {
2131
2227
  const definition = getQueryOptionsDefinition({
2132
2228
  operationName,
@@ -2137,13 +2233,15 @@ var generateQueryArguments = ({
2137
2233
  hasQueryV5,
2138
2234
  queryParams,
2139
2235
  queryParam,
2140
- isReturnType: false
2236
+ isReturnType: false,
2237
+ initialData
2141
2238
  });
2142
2239
  if (!isRequestOptions) {
2143
2240
  return `${type ? "queryOptions" : "mutationOptions"}?: ${definition}`;
2144
2241
  }
2145
- const requestType = getQueryArgumentsRequestType(mutator);
2146
- return `options?: { ${type ? "query" : "mutation"}?:${definition}, ${requestType}}
2242
+ const requestType = getQueryArgumentsRequestType(httpClient, mutator);
2243
+ const isQueryRequired = initialData === "defined";
2244
+ return `options${isQueryRequired ? "" : "?"}: { ${type ? "query" : "mutation"}${isQueryRequired ? "" : "?"}:${definition}, ${requestType}}
2147
2245
  `;
2148
2246
  };
2149
2247
  var generateQueryReturnType = ({
@@ -2152,20 +2250,21 @@ var generateQueryReturnType = ({
2152
2250
  isMutatorHook,
2153
2251
  operationName,
2154
2252
  hasVueQueryV4,
2155
- hasSvelteQueryV4
2253
+ hasSvelteQueryV4,
2254
+ isInitialDataDefined
2156
2255
  }) => {
2157
2256
  switch (outputClient) {
2158
- case import_core2.OutputClient.SVELTE_QUERY: {
2257
+ case import_core3.OutputClient.SVELTE_QUERY: {
2159
2258
  if (!hasSvelteQueryV4) {
2160
- return `Use${(0, import_core2.pascal)(type)}StoreResult<Awaited<ReturnType<${isMutatorHook ? `ReturnType<typeof use${(0, import_core2.pascal)(operationName)}Hook>` : `typeof ${operationName}`}>>, TError, TData, QueryKey> & { queryKey: QueryKey }`;
2259
+ return `Use${(0, import_core3.pascal)(type)}StoreResult<Awaited<ReturnType<${isMutatorHook ? `ReturnType<typeof use${(0, import_core3.pascal)(operationName)}Hook>` : `typeof ${operationName}`}>>, TError, TData, QueryKey> & { queryKey: QueryKey }`;
2161
2260
  }
2162
- return `Create${(0, import_core2.pascal)(
2261
+ return `Create${(0, import_core3.pascal)(
2163
2262
  type
2164
2263
  )}Result<TData, TError> & { queryKey: QueryKey }`;
2165
2264
  }
2166
- case import_core2.OutputClient.VUE_QUERY: {
2265
+ case import_core3.OutputClient.VUE_QUERY: {
2167
2266
  if (!hasVueQueryV4) {
2168
- return ` UseQueryReturnType<TData, TError, Use${(0, import_core2.pascal)(
2267
+ return ` UseQueryReturnType<TData, TError, Use${(0, import_core3.pascal)(
2169
2268
  type
2170
2269
  )}Result<TData, TError>> & { queryKey: QueryKey }`;
2171
2270
  }
@@ -2174,9 +2273,9 @@ var generateQueryReturnType = ({
2174
2273
  }
2175
2274
  return `UseInfiniteQueryReturnType<TData, TError> & { queryKey: QueryKey }`;
2176
2275
  }
2177
- case import_core2.OutputClient.REACT_QUERY:
2276
+ case import_core3.OutputClient.REACT_QUERY:
2178
2277
  default: {
2179
- return ` Use${(0, import_core2.pascal)(
2278
+ return ` ${isInitialDataDefined && !isSuspenseQuery(type) ? "Defined" : ""}Use${(0, import_core3.pascal)(
2180
2279
  type
2181
2280
  )}Result<TData, TError> & { queryKey: QueryKey }`;
2182
2281
  }
@@ -2187,7 +2286,7 @@ var generateMutatorReturnType = ({
2187
2286
  dataType,
2188
2287
  variableType
2189
2288
  }) => {
2190
- if (outputClient === import_core2.OutputClient.REACT_QUERY) {
2289
+ if (outputClient === import_core3.OutputClient.REACT_QUERY) {
2191
2290
  return `: UseMutationResult<
2192
2291
  Awaited<ReturnType<${dataType}>>,
2193
2292
  TError,
@@ -2195,7 +2294,7 @@ var generateMutatorReturnType = ({
2195
2294
  TContext
2196
2295
  >`;
2197
2296
  }
2198
- if (outputClient === import_core2.OutputClient.SVELTE_QUERY) {
2297
+ if (outputClient === import_core3.OutputClient.SVELTE_QUERY) {
2199
2298
  return `: CreateMutationResult<
2200
2299
  Awaited<ReturnType<${dataType}>>,
2201
2300
  TError,
@@ -2203,7 +2302,7 @@ var generateMutatorReturnType = ({
2203
2302
  TContext
2204
2303
  >`;
2205
2304
  }
2206
- if (outputClient === import_core2.OutputClient.VUE_QUERY) {
2305
+ if (outputClient === import_core3.OutputClient.VUE_QUERY) {
2207
2306
  return `: UseMutationReturnType<
2208
2307
  Awaited<ReturnType<${dataType}>>,
2209
2308
  TError,
@@ -2213,46 +2312,6 @@ var generateMutatorReturnType = ({
2213
2312
  }
2214
2313
  return "";
2215
2314
  };
2216
- var getQueryOptions = ({
2217
- isRequestOptions,
2218
- mutator,
2219
- isExactOptionalPropertyTypes,
2220
- hasSignal
2221
- }) => {
2222
- if (!mutator && isRequestOptions) {
2223
- if (!hasSignal) {
2224
- return "axiosOptions";
2225
- }
2226
- return `{ ${isExactOptionalPropertyTypes ? "...(signal ? { signal } : {})" : "signal"}, ...axiosOptions }`;
2227
- }
2228
- if ((mutator == null ? void 0 : mutator.hasSecondArg) && isRequestOptions) {
2229
- if (!hasSignal) {
2230
- return "requestOptions";
2231
- }
2232
- return "requestOptions, signal";
2233
- }
2234
- if (hasSignal) {
2235
- return "signal";
2236
- }
2237
- return "";
2238
- };
2239
- var getHookOptions = ({
2240
- isRequestOptions,
2241
- mutator
2242
- }) => {
2243
- if (!isRequestOptions) {
2244
- return "";
2245
- }
2246
- let value = "const {query: queryOptions";
2247
- if (!mutator) {
2248
- value += ", axios: axiosOptions";
2249
- }
2250
- if (mutator == null ? void 0 : mutator.hasSecondArg) {
2251
- value += ", request: requestOptions";
2252
- }
2253
- value += "} = options ?? {};";
2254
- return value;
2255
- };
2256
2315
  var getQueryFnArguments = ({
2257
2316
  hasQueryParam,
2258
2317
  hasSignal
@@ -2283,6 +2342,7 @@ var generateQueryImplementation = ({
2283
2342
  isRequestOptions,
2284
2343
  response,
2285
2344
  outputClient,
2345
+ httpClient,
2286
2346
  isExactOptionalPropertyTypes,
2287
2347
  hasSignal,
2288
2348
  route,
@@ -2292,13 +2352,44 @@ var generateQueryImplementation = ({
2292
2352
  doc,
2293
2353
  usePrefetch
2294
2354
  }) => {
2295
- const queryProps = (0, import_core2.toObjectString)(props, "implementation");
2355
+ const queryPropDefinitions = (0, import_core3.toObjectString)(props, "definition");
2356
+ const definedInitialDataQueryPropsDefinitions = (0, import_core3.toObjectString)(
2357
+ props.map((prop) => {
2358
+ const regex = new RegExp(`^${prop.name}\\s*\\?:`);
2359
+ if (!regex.test(prop.definition)) {
2360
+ return prop;
2361
+ }
2362
+ const definitionWithUndefined = prop.definition.replace(
2363
+ regex,
2364
+ `${prop.name}: undefined | `
2365
+ );
2366
+ return {
2367
+ ...prop,
2368
+ definition: definitionWithUndefined
2369
+ };
2370
+ }),
2371
+ "definition"
2372
+ );
2373
+ const queryProps = (0, import_core3.toObjectString)(props, "implementation");
2296
2374
  const hasInfiniteQueryParam = queryParam && (queryParams == null ? void 0 : queryParams.schema.name);
2297
2375
  const httpFunctionProps = queryParam ? props.map((param) => {
2298
- if (param.type === import_core2.GetterPropType.NAMED_PATH_PARAMS && !isVue(outputClient))
2376
+ if (param.type === import_core3.GetterPropType.NAMED_PATH_PARAMS && !isVue(outputClient))
2299
2377
  return param.destructured;
2300
2378
  return param.name === "params" ? `{...${isVue(outputClient) ? `unref(params)` : "params"}, ${queryParam}: pageParam || ${isVue(outputClient) ? `unref(params)?.['${queryParam}']` : `params?.['${queryParam}']`}}` : param.name;
2301
- }).join(",") : queryProperties;
2379
+ }).join(",") : getHttpFunctionQueryProps(
2380
+ isVue(outputClient),
2381
+ httpClient,
2382
+ queryProperties
2383
+ );
2384
+ const definedInitialDataReturnType = generateQueryReturnType({
2385
+ outputClient,
2386
+ type,
2387
+ isMutatorHook: mutator == null ? void 0 : mutator.isHook,
2388
+ operationName,
2389
+ hasVueQueryV4,
2390
+ hasSvelteQueryV4,
2391
+ isInitialDataDefined: true
2392
+ });
2302
2393
  const returnType = generateQueryReturnType({
2303
2394
  outputClient,
2304
2395
  type,
@@ -2307,11 +2398,39 @@ var generateQueryImplementation = ({
2307
2398
  hasVueQueryV4,
2308
2399
  hasSvelteQueryV4
2309
2400
  });
2310
- let errorType = `AxiosError<${response.definition.errors || "unknown"}>`;
2311
- if (mutator) {
2312
- errorType = mutator.hasErrorType ? `${mutator.default ? (0, import_core2.pascal)(operationName) : ""}ErrorType<${response.definition.errors || "unknown"}>` : response.definition.errors || "unknown";
2313
- }
2314
- const dataType = (mutator == null ? void 0 : mutator.isHook) ? `ReturnType<typeof use${(0, import_core2.pascal)(operationName)}Hook>` : `typeof ${operationName}`;
2401
+ const errorType = getQueryErrorType(
2402
+ operationName,
2403
+ response,
2404
+ httpClient,
2405
+ mutator
2406
+ );
2407
+ const dataType = (mutator == null ? void 0 : mutator.isHook) ? `ReturnType<typeof use${(0, import_core3.pascal)(operationName)}Hook>` : `typeof ${operationName}`;
2408
+ const definedInitialDataQueryArguments = generateQueryArguments({
2409
+ operationName,
2410
+ definitions: "",
2411
+ mutator,
2412
+ isRequestOptions,
2413
+ type,
2414
+ hasSvelteQueryV4,
2415
+ hasQueryV5,
2416
+ queryParams,
2417
+ queryParam,
2418
+ initialData: "defined",
2419
+ httpClient
2420
+ });
2421
+ const undefinedInitialDataQueryArguments = generateQueryArguments({
2422
+ operationName,
2423
+ definitions: "",
2424
+ mutator,
2425
+ isRequestOptions,
2426
+ type,
2427
+ hasSvelteQueryV4,
2428
+ hasQueryV5,
2429
+ queryParams,
2430
+ queryParam,
2431
+ initialData: "undefined",
2432
+ httpClient
2433
+ });
2315
2434
  const queryArguments = generateQueryArguments({
2316
2435
  operationName,
2317
2436
  definitions: "",
@@ -2321,16 +2440,19 @@ var generateQueryImplementation = ({
2321
2440
  hasSvelteQueryV4,
2322
2441
  hasQueryV5,
2323
2442
  queryParams,
2324
- queryParam
2443
+ queryParam,
2444
+ httpClient
2325
2445
  });
2326
2446
  const queryOptions = getQueryOptions({
2327
2447
  isRequestOptions,
2328
2448
  isExactOptionalPropertyTypes,
2329
2449
  mutator,
2330
- hasSignal
2450
+ hasSignal,
2451
+ httpClient
2331
2452
  });
2332
2453
  const hookOptions = getHookOptions({
2333
2454
  isRequestOptions,
2455
+ httpClient,
2334
2456
  mutator
2335
2457
  });
2336
2458
  const queryFnArguments = getQueryFnArguments({
@@ -2354,7 +2476,7 @@ var generateQueryImplementation = ({
2354
2476
  type,
2355
2477
  outputClient
2356
2478
  });
2357
- const queryOptionsFnName = (0, import_core2.camel)(
2479
+ const queryOptionsFnName = (0, import_core3.camel)(
2358
2480
  queryKeyMutator || queryOptionsMutator || (mutator == null ? void 0 : mutator.isHook) ? `use-${name}-queryOptions` : `get-${name}-queryOptions`
2359
2481
  );
2360
2482
  const queryOptionsVarName = isRequestOptions ? "queryOptions" : "options";
@@ -2370,13 +2492,13 @@ ${hookOptions}
2370
2492
 
2371
2493
  const queryKey = ${!queryKeyMutator ? `${!hasVueQueryV4 ? "queryOptions?.queryKey ?? " : ""}${queryKeyFnName}(${queryKeyProperties});` : `${queryKeyMutator.name}({ ${queryProperties} }${queryKeyMutator.hasSecondArg ? `, { url: \`${route}\`, queryOptions }` : ""});`}
2372
2494
 
2373
- ${(mutator == null ? void 0 : mutator.isHook) ? `const ${operationName} = use${(0, import_core2.pascal)(operationName)}Hook();` : ""}
2495
+ ${(mutator == null ? void 0 : mutator.isHook) ? `const ${operationName} = use${(0, import_core3.pascal)(operationName)}Hook();` : ""}
2374
2496
 
2375
- const queryFn: QueryFunction<Awaited<ReturnType<${(mutator == null ? void 0 : mutator.isHook) ? `ReturnType<typeof use${(0, import_core2.pascal)(operationName)}Hook>` : `typeof ${operationName}`}>>${hasQueryV5 && hasInfiniteQueryParam ? `, QueryKey, ${queryParams == null ? void 0 : queryParams.schema.name}['${queryParam}']` : ""}> = (${queryFnArguments}) => ${operationName}(${httpFunctionProps}${httpFunctionProps ? ", " : ""}${queryOptions});
2497
+ const queryFn: QueryFunction<Awaited<ReturnType<${(mutator == null ? void 0 : mutator.isHook) ? `ReturnType<typeof use${(0, import_core3.pascal)(operationName)}Hook>` : `typeof ${operationName}`}>>${hasQueryV5 && hasInfiniteQueryParam ? `, QueryKey, ${queryParams == null ? void 0 : queryParams.schema.name}['${queryParam}']` : ""}> = (${queryFnArguments}) => ${operationName}(${httpFunctionProps}${httpFunctionProps ? ", " : ""}${queryOptions});
2376
2498
 
2377
2499
  ${isVue(outputClient) ? vueUnRefParams(
2378
2500
  props.filter(
2379
- (prop) => prop.type === import_core2.GetterPropType.NAMED_PATH_PARAMS
2501
+ (prop) => prop.type === import_core3.GetterPropType.NAMED_PATH_PARAMS
2380
2502
  )
2381
2503
  ) : ""}
2382
2504
 
@@ -2385,23 +2507,34 @@ ${hookOptions}
2385
2507
  return ${!queryOptionsMutator ? `{ queryKey, queryFn, ${queryOptionsImp}}` : "customOptions"} as ${queryOptionFnReturnType} ${isVue(outputClient) ? "" : "& { queryKey: QueryKey }"}
2386
2508
  }`;
2387
2509
  const operationPrefix = hasSvelteQueryV4 ? "create" : "use";
2510
+ const queryHookName = (0, import_core3.camel)(`${operationPrefix}-${name}`);
2511
+ const overrideTypes = `
2512
+ export function ${queryHookName}<TData = ${TData}, TError = ${errorType}>(
2513
+ ${definedInitialDataQueryPropsDefinitions} ${definedInitialDataQueryArguments}
2514
+ ): ${definedInitialDataReturnType}
2515
+ export function ${queryHookName}<TData = ${TData}, TError = ${errorType}>(
2516
+ ${queryPropDefinitions} ${undefinedInitialDataQueryArguments}
2517
+ ): ${returnType}
2518
+ export function ${queryHookName}<TData = ${TData}, TError = ${errorType}>(
2519
+ ${queryPropDefinitions} ${queryArguments}
2520
+ ): ${returnType}`;
2388
2521
  return `
2389
2522
  ${queryOptionsFn}
2390
2523
 
2391
- export type ${(0, import_core2.pascal)(
2524
+ export type ${(0, import_core3.pascal)(
2392
2525
  name
2393
2526
  )}QueryResult = NonNullable<Awaited<ReturnType<${dataType}>>>
2394
- export type ${(0, import_core2.pascal)(name)}QueryError = ${errorType}
2527
+ export type ${(0, import_core3.pascal)(name)}QueryError = ${errorType}
2395
2528
 
2396
- ${doc}export const ${(0, import_core2.camel)(
2397
- `${operationPrefix}-${name}`
2398
- )} = <TData = ${TData}, TError = ${errorType}>(
2529
+ ${hasQueryV5 && import_core3.OutputClient.REACT_QUERY === outputClient ? overrideTypes : ""}
2530
+ ${doc}
2531
+ export function ${queryHookName}<TData = ${TData}, TError = ${errorType}>(
2399
2532
  ${queryProps} ${queryArguments}
2400
- ): ${returnType} => {
2533
+ ): ${returnType} {
2401
2534
 
2402
2535
  const ${queryOptionsVarName} = ${queryOptionsFnName}(${queryProperties}${queryProperties ? "," : ""}${isRequestOptions ? "options" : "queryOptions"})
2403
2536
 
2404
- const ${queryResultVarName} = ${(0, import_core2.camel)(
2537
+ const ${queryResultVarName} = ${(0, import_core3.camel)(
2405
2538
  `${operationPrefix}-${type}`
2406
2539
  )}(${queryOptionsVarName}) as ${returnType};
2407
2540
 
@@ -2410,7 +2543,7 @@ ${doc}export const ${(0, import_core2.camel)(
2410
2543
  return ${queryResultVarName};
2411
2544
  }
2412
2545
 
2413
- ${usePrefetch && (type === QueryType.QUERY || type === QueryType.INFINITE) ? `${doc}export const ${(0, import_core2.camel)(
2546
+ ${usePrefetch && (type === QueryType.QUERY || type === QueryType.INFINITE) ? `${doc}export const ${(0, import_core3.camel)(
2414
2547
  `prefetch-${name}`
2415
2548
  )} = async <TData = Awaited<ReturnType<${dataType}>>, TError = ${errorType}>(
2416
2549
  queryClient: QueryClient, ${queryProps} ${queryArguments}
@@ -2418,7 +2551,7 @@ ${usePrefetch && (type === QueryType.QUERY || type === QueryType.INFINITE) ? `${
2418
2551
 
2419
2552
  const ${queryOptionsVarName} = ${queryOptionsFnName}(${queryProperties}${queryProperties ? "," : ""}${isRequestOptions ? "options" : "queryOptions"})
2420
2553
 
2421
- await queryClient.${(0, import_core2.camel)(`prefetch-${type}`)}(${queryOptionsVarName});
2554
+ await queryClient.${(0, import_core3.camel)(`prefetch-${type}`)}(${queryOptionsVarName});
2422
2555
 
2423
2556
  return queryClient;
2424
2557
  }
@@ -2448,16 +2581,17 @@ var generateQueryHook = async ({
2448
2581
  const isRequestOptions = (override == null ? void 0 : override.requestOptions) !== false;
2449
2582
  const operationQueryOptions = (_a = operations[operationId]) == null ? void 0 : _a.query;
2450
2583
  const isExactOptionalPropertyTypes = !!((_c = (_b = context.output.tsconfig) == null ? void 0 : _b.compilerOptions) == null ? void 0 : _c.exactOptionalPropertyTypes);
2451
- const hasVueQueryV4 = import_core2.OutputClient.VUE_QUERY === outputClient && (!isVueQueryV3(context.output.packageJson) || query.version === 4);
2452
- const hasSvelteQueryV4 = import_core2.OutputClient.SVELTE_QUERY === outputClient && (!isSvelteQueryV3(context.output.packageJson) || query.version === 4);
2584
+ const hasVueQueryV4 = import_core3.OutputClient.VUE_QUERY === outputClient && (!isVueQueryV3(context.output.packageJson) || query.version === 4);
2585
+ const hasSvelteQueryV4 = import_core3.OutputClient.SVELTE_QUERY === outputClient && (!isSvelteQueryV3(context.output.packageJson) || query.version === 4);
2453
2586
  const hasQueryV5 = query.version === 5 || isQueryV5(
2454
2587
  context.output.packageJson,
2455
2588
  outputClient
2456
2589
  );
2457
- const doc = (0, import_core2.jsDoc)({ summary, deprecated });
2590
+ const httpClient = context.output.httpClient;
2591
+ const doc = (0, import_core3.jsDoc)({ summary, deprecated });
2458
2592
  let implementation = "";
2459
2593
  let mutators = void 0;
2460
- let isQuery = import_core2.Verbs.GET === verb && (override.query.useQuery || override.query.useSuspenseQuery || override.query.useInfinite || override.query.useSuspenseInfiniteQuery);
2594
+ let isQuery = import_core3.Verbs.GET === verb && (override.query.useQuery || override.query.useSuspenseQuery || override.query.useInfinite || override.query.useSuspenseInfiniteQuery);
2461
2595
  if ((operationQueryOptions == null ? void 0 : operationQueryOptions.useInfinite) !== void 0) {
2462
2596
  isQuery = operationQueryOptions.useInfinite;
2463
2597
  }
@@ -2471,14 +2605,14 @@ var generateQueryHook = async ({
2471
2605
  isQuery = operationQueryOptions.useSuspenseQuery;
2472
2606
  }
2473
2607
  if (isQuery) {
2474
- const queryKeyMutator = query.queryKey ? await (0, import_core2.generateMutator)({
2608
+ const queryKeyMutator = query.queryKey ? await (0, import_core3.generateMutator)({
2475
2609
  output,
2476
2610
  mutator: query.queryKey,
2477
2611
  name: `${operationName}QueryKey`,
2478
2612
  workspace: context.workspace,
2479
2613
  tsconfig: context.output.tsconfig
2480
2614
  }) : void 0;
2481
- const queryOptionsMutator = query.queryOptions ? await (0, import_core2.generateMutator)({
2615
+ const queryOptionsMutator = query.queryOptions ? await (0, import_core3.generateMutator)({
2482
2616
  output,
2483
2617
  mutator: query.queryOptions,
2484
2618
  name: `${operationName}QueryOptions`,
@@ -2486,19 +2620,19 @@ var generateQueryHook = async ({
2486
2620
  tsconfig: context.output.tsconfig
2487
2621
  }) : void 0;
2488
2622
  const queryProperties = props.map((param) => {
2489
- if (param.type === import_core2.GetterPropType.NAMED_PATH_PARAMS && !isVue(outputClient))
2623
+ if (param.type === import_core3.GetterPropType.NAMED_PATH_PARAMS && !isVue(outputClient))
2490
2624
  return param.destructured;
2491
- return param.type === import_core2.GetterPropType.BODY ? body.implementation : param.name;
2625
+ return param.type === import_core3.GetterPropType.BODY ? body.implementation : param.name;
2492
2626
  }).join(",");
2493
- const queryKeyProperties = props.filter((prop) => prop.type !== import_core2.GetterPropType.HEADER).map((param) => {
2494
- if (param.type === import_core2.GetterPropType.NAMED_PATH_PARAMS && !isVue(outputClient))
2627
+ const queryKeyProperties = props.filter((prop) => prop.type !== import_core3.GetterPropType.HEADER).map((param) => {
2628
+ if (param.type === import_core3.GetterPropType.NAMED_PATH_PARAMS && !isVue(outputClient))
2495
2629
  return param.destructured;
2496
- return param.type === import_core2.GetterPropType.BODY ? body.implementation : param.name;
2630
+ return param.type === import_core3.GetterPropType.BODY ? body.implementation : param.name;
2497
2631
  }).join(",");
2498
2632
  const queries = [
2499
2633
  ...(query == null ? void 0 : query.useInfinite) || (operationQueryOptions == null ? void 0 : operationQueryOptions.useInfinite) ? [
2500
2634
  {
2501
- name: (0, import_core2.camel)(`${operationName}-infinite`),
2635
+ name: (0, import_core3.camel)(`${operationName}-infinite`),
2502
2636
  options: query == null ? void 0 : query.options,
2503
2637
  type: QueryType.INFINITE,
2504
2638
  queryParam: query == null ? void 0 : query.useInfiniteQueryParam
@@ -2513,26 +2647,26 @@ var generateQueryHook = async ({
2513
2647
  ] : [],
2514
2648
  ...(query == null ? void 0 : query.useSuspenseQuery) || (operationQueryOptions == null ? void 0 : operationQueryOptions.useSuspenseQuery) ? [
2515
2649
  {
2516
- name: (0, import_core2.camel)(`${operationName}-suspense`),
2650
+ name: (0, import_core3.camel)(`${operationName}-suspense`),
2517
2651
  options: query == null ? void 0 : query.options,
2518
2652
  type: QueryType.SUSPENSE_QUERY
2519
2653
  }
2520
2654
  ] : [],
2521
2655
  ...(query == null ? void 0 : query.useSuspenseInfiniteQuery) || (operationQueryOptions == null ? void 0 : operationQueryOptions.useSuspenseInfiniteQuery) ? [
2522
2656
  {
2523
- name: (0, import_core2.camel)(`${operationName}-suspense-infinite`),
2657
+ name: (0, import_core3.camel)(`${operationName}-suspense-infinite`),
2524
2658
  options: query == null ? void 0 : query.options,
2525
2659
  type: QueryType.SUSPENSE_INFINITE,
2526
2660
  queryParam: query == null ? void 0 : query.useInfiniteQueryParam
2527
2661
  }
2528
2662
  ] : []
2529
2663
  ];
2530
- const queryKeyFnName = (0, import_core2.camel)(`get-${operationName}-queryKey`);
2531
- let queryKeyProps = (0, import_core2.toObjectString)(
2532
- props.filter((prop) => prop.type !== import_core2.GetterPropType.HEADER),
2664
+ const queryKeyFnName = (0, import_core3.camel)(`get-${operationName}-queryKey`);
2665
+ let queryKeyProps = (0, import_core3.toObjectString)(
2666
+ props.filter((prop) => prop.type !== import_core3.GetterPropType.HEADER),
2533
2667
  "implementation"
2534
2668
  );
2535
- const routeString = isVue(outputClient) ? (0, import_core2.getRouteAsArray)(route) : `\`${route}\``;
2669
+ const routeString = isVue(outputClient) ? (0, import_core3.getRouteAsArray)(route) : `\`${route}\``;
2536
2670
  const queryKeyFn = `${override.query.shouldExportQueryKey ? "export " : ""}const ${queryKeyFnName} = (${queryKeyProps}) => {
2537
2671
  return [${routeString}${queryParams ? ", ...(params ? [params]: [])" : ""}${body.implementation ? `, ${body.implementation}` : ""}] as const;
2538
2672
  }`;
@@ -2552,6 +2686,7 @@ var generateQueryHook = async ({
2552
2686
  queryParams,
2553
2687
  response,
2554
2688
  outputClient,
2689
+ httpClient,
2555
2690
  isExactOptionalPropertyTypes,
2556
2691
  hasSignal: !!query.signal,
2557
2692
  queryOptionsMutator,
@@ -2571,12 +2706,12 @@ var generateQueryHook = async ({
2571
2706
  ...queryKeyMutator ? [queryKeyMutator] : []
2572
2707
  ] : void 0;
2573
2708
  }
2574
- let isMutation = verb !== import_core2.Verbs.GET && override.query.useMutation;
2709
+ let isMutation = verb !== import_core3.Verbs.GET && override.query.useMutation;
2575
2710
  if ((operationQueryOptions == null ? void 0 : operationQueryOptions.useMutation) !== void 0) {
2576
2711
  isMutation = operationQueryOptions.useMutation;
2577
2712
  }
2578
2713
  if (isMutation) {
2579
- const mutationOptionsMutator = query.mutationOptions ? await (0, import_core2.generateMutator)({
2714
+ const mutationOptionsMutator = query.mutationOptions ? await (0, import_core3.generateMutator)({
2580
2715
  output,
2581
2716
  mutator: query.mutationOptions,
2582
2717
  name: `${operationName}MutationOptions`,
@@ -2584,14 +2719,16 @@ var generateQueryHook = async ({
2584
2719
  tsconfig: context.output.tsconfig
2585
2720
  }) : void 0;
2586
2721
  const definitions = props.map(
2587
- ({ definition, type }) => type === import_core2.GetterPropType.BODY ? (mutator == null ? void 0 : mutator.bodyTypeName) ? `data: ${mutator.bodyTypeName}<${body.definition}>` : `data: ${body.definition}` : definition
2722
+ ({ definition, type }) => type === import_core3.GetterPropType.BODY ? (mutator == null ? void 0 : mutator.bodyTypeName) ? `data: ${mutator.bodyTypeName}<${body.definition}>` : `data: ${body.definition}` : definition
2588
2723
  ).join(";");
2589
- const properties = props.map(({ name, type }) => type === import_core2.GetterPropType.BODY ? "data" : name).join(",");
2590
- let errorType = `AxiosError<${response.definition.errors || "unknown"}>`;
2591
- if (mutator) {
2592
- errorType = mutator.hasErrorType ? `${mutator.default ? (0, import_core2.pascal)(operationName) : ""}ErrorType<${response.definition.errors || "unknown"}>` : response.definition.errors || "unknown";
2593
- }
2594
- const dataType = (mutator == null ? void 0 : mutator.isHook) ? `ReturnType<typeof use${(0, import_core2.pascal)(operationName)}Hook>` : `typeof ${operationName}`;
2724
+ const properties = props.map(({ name, type }) => type === import_core3.GetterPropType.BODY ? "data" : name).join(",");
2725
+ let errorType = getQueryErrorType(
2726
+ operationName,
2727
+ response,
2728
+ httpClient,
2729
+ mutator
2730
+ );
2731
+ const dataType = (mutator == null ? void 0 : mutator.isHook) ? `ReturnType<typeof use${(0, import_core3.pascal)(operationName)}Hook>` : `typeof ${operationName}`;
2595
2732
  const mutationOptionFnReturnType = getQueryOptionsDefinition({
2596
2733
  operationName,
2597
2734
  definitions,
@@ -2606,23 +2743,33 @@ var generateQueryHook = async ({
2606
2743
  mutator,
2607
2744
  isRequestOptions,
2608
2745
  hasSvelteQueryV4,
2609
- hasQueryV5
2746
+ hasQueryV5,
2747
+ httpClient
2610
2748
  });
2611
- const mutationOptionsFnName = (0, import_core2.camel)(
2749
+ const mutationOptionsFnName = (0, import_core3.camel)(
2612
2750
  mutationOptionsMutator || (mutator == null ? void 0 : mutator.isHook) ? `use-${operationName}-mutationOptions` : `get-${operationName}-mutationOptions`
2613
2751
  );
2614
2752
  const mutationOptionsVarName = isRequestOptions ? "mutationOptions" : "options";
2753
+ const hooksOptionImplementation = getHooksOptionImplementation(
2754
+ isRequestOptions,
2755
+ httpClient,
2756
+ mutator
2757
+ );
2615
2758
  const mutationOptionsFn = `export const ${mutationOptionsFnName} = <TError = ${errorType},
2616
2759
  TContext = unknown>(${mutationArguments}): ${mutationOptionFnReturnType} => {
2617
- ${isRequestOptions ? `const {mutation: mutationOptions${!mutator ? `, axios: axiosOptions` : (mutator == null ? void 0 : mutator.hasSecondArg) ? ", request: requestOptions" : ""}} = options ?? {};` : ""}
2760
+ ${hooksOptionImplementation}
2618
2761
 
2619
- ${(mutator == null ? void 0 : mutator.isHook) ? `const ${operationName} = use${(0, import_core2.pascal)(operationName)}Hook()` : ""}
2762
+ ${(mutator == null ? void 0 : mutator.isHook) ? `const ${operationName} = use${(0, import_core3.pascal)(operationName)}Hook()` : ""}
2620
2763
 
2621
2764
 
2622
2765
  const mutationFn: MutationFunction<Awaited<ReturnType<${dataType}>>, ${definitions ? `{${definitions}}` : "void"}> = (${properties ? "props" : ""}) => {
2623
2766
  ${properties ? `const {${properties}} = props ?? {};` : ""}
2624
2767
 
2625
- return ${operationName}(${properties}${properties ? "," : ""}${isRequestOptions ? !mutator ? `axiosOptions` : (mutator == null ? void 0 : mutator.hasSecondArg) ? "requestOptions" : "" : ""})
2768
+ return ${operationName}(${properties}${properties ? "," : ""}${getMutationRequestArgs(
2769
+ isRequestOptions,
2770
+ httpClient,
2771
+ mutator
2772
+ )})
2626
2773
  }
2627
2774
 
2628
2775
  ${mutationOptionsMutator ? `const customOptions = ${mutationOptionsMutator.name}({...mutationOptions, mutationFn}${mutationOptionsMutator.hasThirdArg ? `, { url: \`${route}\` }` : ""});` : ""}
@@ -2633,13 +2780,13 @@ ${isRequestOptions ? `const {mutation: mutationOptions${!mutator ? `, axios: axi
2633
2780
  implementation += `
2634
2781
  ${mutationOptionsFn}
2635
2782
 
2636
- export type ${(0, import_core2.pascal)(
2783
+ export type ${(0, import_core3.pascal)(
2637
2784
  operationName
2638
2785
  )}MutationResult = NonNullable<Awaited<ReturnType<${dataType}>>>
2639
- ${body.definition ? `export type ${(0, import_core2.pascal)(operationName)}MutationBody = ${(mutator == null ? void 0 : mutator.bodyTypeName) ? `${mutator.bodyTypeName}<${body.definition}>` : body.definition}` : ""}
2640
- export type ${(0, import_core2.pascal)(operationName)}MutationError = ${errorType}
2786
+ ${body.definition ? `export type ${(0, import_core3.pascal)(operationName)}MutationBody = ${(mutator == null ? void 0 : mutator.bodyTypeName) ? `${mutator.bodyTypeName}<${body.definition}>` : body.definition}` : ""}
2787
+ export type ${(0, import_core3.pascal)(operationName)}MutationError = ${errorType}
2641
2788
 
2642
- ${doc}export const ${(0, import_core2.camel)(
2789
+ ${doc}export const ${(0, import_core3.camel)(
2643
2790
  `${operationPrefix}-${operationName}`
2644
2791
  )} = <TError = ${errorType},
2645
2792
  TContext = unknown>(${mutationArguments})${generateMutatorReturnType({
@@ -2675,13 +2822,12 @@ ${isRequestOptions && isMutator ? `type SecondParameter<T extends (...args: any)
2675
2822
  ` : ""}
2676
2823
  `;
2677
2824
  };
2678
- var generateQuery = async (verbOptions, options, outputClient, output) => {
2679
- const imports = (0, import_core2.generateVerbImports)(verbOptions);
2825
+ var generateQuery = async (verbOptions, options, outputClient) => {
2826
+ const imports = (0, import_core3.generateVerbImports)(verbOptions);
2680
2827
  const functionImplementation = generateQueryRequestFunction(
2681
2828
  verbOptions,
2682
2829
  options,
2683
- outputClient,
2684
- output
2830
+ isVue(outputClient)
2685
2831
  );
2686
2832
  const { implementation: hookImplementation, mutators } = await generateQueryHook(verbOptions, options, outputClient);
2687
2833
  return {
@@ -2705,7 +2851,7 @@ var builder = ({
2705
2851
  const client = (verbOptions, options, outputClient) => {
2706
2852
  if (options.override.useNamedParameters && (type === "vue-query" || outputClient === "vue-query")) {
2707
2853
  throw new Error(
2708
- `vue-query client does not support named parameters, and had broken reactivity previously, please set useNamedParameters to false; See for context: https://github.com/anymaniax/orval/pull/931#issuecomment-1752355686`
2854
+ `vue-query client does not support named parameters, and had broken reactivity previously, please set useNamedParameters to false; See for context: https://github.com/orval-labs/orval/pull/931#issuecomment-1752355686`
2709
2855
  );
2710
2856
  }
2711
2857
  if (queryOptions) {
@@ -2713,11 +2859,11 @@ var builder = ({
2713
2859
  queryOptions,
2714
2860
  options.context.workspace
2715
2861
  );
2716
- verbOptions.override.query = (0, import_core2.mergeDeep)(
2862
+ verbOptions.override.query = (0, import_core3.mergeDeep)(
2717
2863
  normalizedQueryOptions,
2718
2864
  verbOptions.override.query
2719
2865
  );
2720
- options.override.query = (0, import_core2.mergeDeep)(
2866
+ options.override.query = (0, import_core3.mergeDeep)(
2721
2867
  normalizedQueryOptions,
2722
2868
  verbOptions.override.query
2723
2869
  );