@orval/fetch 7.11.1 → 7.12.1

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.d.ts CHANGED
@@ -1,9 +1,28 @@
1
- import { ClientGeneratorsBuilder, GeneratorVerbOptions, GeneratorOptions, ClientBuilder, ClientHeaderBuilder } from '@orval/core';
1
+ import { ClientBuilder, ClientGeneratorsBuilder, ClientHeaderBuilder, GeneratorOptions, GeneratorVerbOptions } from "@orval/core";
2
2
 
3
- declare const generateRequestFunction: ({ queryParams, headers, operationName, response, mutator, body, props, verb, fetchReviver, formData, formUrlEncoded, override, }: GeneratorVerbOptions, { route, context, pathRoute }: GeneratorOptions) => string;
3
+ //#region src/index.d.ts
4
+ declare const generateRequestFunction: ({
5
+ queryParams,
6
+ headers,
7
+ operationName,
8
+ response,
9
+ mutator,
10
+ body,
11
+ props,
12
+ verb,
13
+ fetchReviver,
14
+ formData,
15
+ formUrlEncoded,
16
+ override
17
+ }: GeneratorVerbOptions, {
18
+ route,
19
+ context,
20
+ pathRoute
21
+ }: GeneratorOptions) => string;
4
22
  declare const fetchResponseTypeName: (includeHttpResponseReturnType: boolean | undefined, definitionSuccessResponse: string, operationName: string) => string;
5
23
  declare const generateClient: ClientBuilder;
6
24
  declare const generateFetchHeader: ClientHeaderBuilder;
7
25
  declare const builder: () => () => ClientGeneratorsBuilder;
8
-
26
+ //#endregion
9
27
  export { builder, builder as default, fetchResponseTypeName, generateClient, generateFetchHeader, generateRequestFunction };
28
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;cAuBa;;;;;;;;;;;;;GAcR;;;;GAC4B;AAfpB,cA8SA,qBAFZ,EAAA,CAAA,6BAAA,EAAA,OAAA,GAAA,SAAA,EAAA,yBAAA,EAAA,MAAA,EAAA,aAAA,EAAA,MAAA,EAAA,GAAA,MAAA;AAAA,cAYY,cAZZ,EAY4B,aAZ5B;AA3SC,cA2UW,mBA3UX,EA2UgC,mBA3UhC;AAAA,cAyVW,OAzVX,EAAA,GAAA,GAAA,GAAA,GAyVkB,uBAzVlB"}
package/dist/index.js CHANGED
@@ -1,175 +1,133 @@
1
- "use strict";
1
+ Object.defineProperty(exports, '__esModule', { value: true });
2
+ //#region rolldown:runtime
3
+ var __create = Object.create;
2
4
  var __defProp = Object.defineProperty;
3
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
5
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
9
  var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
10
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
+ get: ((k) => from[k]).bind(null, key),
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ }
17
+ return to;
17
18
  };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
20
+ value: mod,
21
+ enumerable: true
22
+ }) : target, mod));
19
23
 
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- builder: () => builder,
24
- default: () => index_default,
25
- fetchResponseTypeName: () => fetchResponseTypeName,
26
- generateClient: () => generateClient,
27
- generateFetchHeader: () => generateFetchHeader,
28
- generateRequestFunction: () => generateRequestFunction
29
- });
30
- module.exports = __toCommonJS(index_exports);
31
- var import_core = require("@orval/core");
32
- var import_core2 = require("@orval/core");
33
- var generateRequestFunction = ({
34
- queryParams,
35
- headers,
36
- operationName,
37
- response,
38
- mutator,
39
- body,
40
- props,
41
- verb,
42
- fetchReviver,
43
- formData,
44
- formUrlEncoded,
45
- override
46
- }, { route, context, pathRoute }) => {
47
- var _a, _b, _c, _d;
48
- const isRequestOptions = (override == null ? void 0 : override.requestOptions) !== false;
49
- const isFormData = (override == null ? void 0 : override.formData.disabled) === false;
50
- const isFormUrlEncoded = (override == null ? void 0 : override.formUrlEncoded) !== false;
51
- const getUrlFnName = (0, import_core2.camel)(`get-${operationName}-url`);
52
- const getUrlFnProps = (0, import_core2.toObjectString)(
53
- props.filter(
54
- (prop) => prop.type === import_core2.GetterPropType.PARAM || prop.type === import_core2.GetterPropType.NAMED_PATH_PARAMS || prop.type === import_core2.GetterPropType.QUERY_PARAM
55
- ),
56
- "implementation"
57
- );
58
- const spec = context.specs[context.specKey].paths[pathRoute];
59
- const parameters = ((_a = spec == null ? void 0 : spec[verb]) == null ? void 0 : _a.parameters) || [];
60
- const explodeParameters = parameters.filter((parameter) => {
61
- const { schema } = (0, import_core2.resolveRef)(parameter, context);
62
- if (override.fetch.explode) {
63
- return schema.in === "query" && schema.explode;
64
- } else {
65
- return schema.in === "query" && schema.explode !== false;
66
- }
67
- });
68
- const explodeParametersNames = explodeParameters.map((parameter) => {
69
- const { schema } = (0, import_core2.resolveRef)(parameter, context);
70
- return schema.name;
71
- });
72
- const hasDateParams = context.output.override.useDates && parameters.some(
73
- (p) => "schema" in p && p.schema && "format" in p.schema && p.schema.format === "date-time"
74
- );
75
- const explodeArrayImplementation = explodeParameters.length > 0 ? `const explodeParameters = ${JSON.stringify(explodeParametersNames)};
24
+ //#endregion
25
+ let __orval_core = require("@orval/core");
26
+ __orval_core = __toESM(__orval_core);
27
+ require("openapi3-ts/oas30");
28
+ require("openapi3-ts/oas31");
29
+
30
+ //#region src/index.ts
31
+ const generateRequestFunction = ({ queryParams, headers, operationName, response, mutator, body, props, verb, fetchReviver, formData, formUrlEncoded, override }, { route, context, pathRoute }) => {
32
+ const isRequestOptions = override?.requestOptions !== false;
33
+ const isFormData = override?.formData.disabled === false;
34
+ const isFormUrlEncoded = override?.formUrlEncoded !== false;
35
+ const getUrlFnName = (0, __orval_core.camel)(`get-${operationName}-url`);
36
+ const getUrlFnProps = (0, __orval_core.toObjectString)(props.filter((prop) => prop.type === __orval_core.GetterPropType.PARAM || prop.type === __orval_core.GetterPropType.NAMED_PATH_PARAMS || prop.type === __orval_core.GetterPropType.QUERY_PARAM), "implementation");
37
+ const parameters = context.specs[context.specKey].paths[pathRoute]?.[verb]?.parameters || [];
38
+ const explodeParameters = parameters.filter((parameter) => {
39
+ const { schema } = (0, __orval_core.resolveRef)(parameter, context);
40
+ const schemaObject = schema.schema;
41
+ return schema.in === "query" && schemaObject.type === "array" && (schema.explode || override.fetch.explode);
42
+ });
43
+ const explodeParametersNames = explodeParameters.map((parameter) => {
44
+ const { schema } = (0, __orval_core.resolveRef)(parameter, context);
45
+ return schema.name;
46
+ });
47
+ const hasDateParams = context.output.override.useDates && parameters.some((p) => "schema" in p && p.schema && "format" in p.schema && p.schema.format === "date-time");
48
+ const explodeArrayImplementation = explodeParameters.length > 0 ? `const explodeParameters = ${JSON.stringify(explodeParametersNames)};
76
49
 
77
50
  if (Array.isArray(value) && explodeParameters.includes(key)) {
78
51
  value.forEach((v) => normalizedParams.append(key, v === null ? 'null' : ${hasDateParams ? "v instanceof Date ? v.toISOString() : " : ""}v.toString()));
79
52
  return;
80
53
  }
81
54
  ` : "";
82
- const isExplodeParametersOnly = explodeParameters.length === parameters.length;
83
- const nomalParamsImplementation = `if (value !== undefined) {
84
- normalizedParams.append(key, value === null ? 'null' : ${hasDateParams ? "value instanceof Date ? value.toISOString() : " : ""}value.toString())
85
- }`;
86
- const getUrlFnImplementation = `export const ${getUrlFnName} = (${getUrlFnProps}) => {
55
+ const isExplodeParametersOnly = explodeParameters.length === parameters.length;
56
+ const getUrlFnImplementation = `export const ${getUrlFnName} = (${getUrlFnProps}) => {
87
57
  ${queryParams ? ` const normalizedParams = new URLSearchParams();
88
58
 
89
59
  Object.entries(params || {}).forEach(([key, value]) => {
90
60
  ${explodeArrayImplementation}
91
- ${!isExplodeParametersOnly ? nomalParamsImplementation : ""}
61
+ ${!isExplodeParametersOnly ? `if (value !== undefined) {
62
+ normalizedParams.append(key, value === null ? 'null' : ${hasDateParams ? "value instanceof Date ? value.toISOString() : " : ""}value.toString())
63
+ }` : ""}
92
64
  });` : ""}
93
65
 
94
66
  ${queryParams ? `const stringifiedParams = normalizedParams.toString();` : ``}
95
67
 
96
- ${queryParams ? `return stringifiedParams.length > 0 ? \`${route}${"?${stringifiedParams}"}\` : \`${route}\`` : `return \`${route}\``}
97
- }
98
- `;
99
- const isContentTypeNdJson = (contentType) => contentType === "application/nd-json" || contentType === "application/x-ndjson";
100
- const isNdJson = response.contentTypes.some(isContentTypeNdJson);
101
- const responseTypeName = fetchResponseTypeName(
102
- (_b = override.fetch) == null ? void 0 : _b.includeHttpResponseReturnType,
103
- isNdJson ? "Response" : response.definition.success,
104
- operationName
105
- );
106
- const allResponses = [...response.types.success, ...response.types.errors];
107
- if (allResponses.length === 0) {
108
- allResponses.push({
109
- contentType: "",
110
- hasReadonlyProps: false,
111
- imports: [],
112
- isEnum: false,
113
- isRef: false,
114
- key: "default",
115
- schemas: [],
116
- type: "unknown",
117
- value: "unknown"
118
- });
119
- }
120
- const nonDefaultStatuses = allResponses.filter((r) => r.key !== "default").map((r) => r.key);
121
- const responseDataTypes = allResponses.map(
122
- (r) => allResponses.filter((r2) => r2.key === r.key).length > 1 ? { ...r, suffix: (0, import_core.pascal)(r.contentType) } : r
123
- ).map((r) => {
124
- const name = `${responseTypeName}${(0, import_core.pascal)(r.key)}${"suffix" in r ? r.suffix : ""}`;
125
- return {
126
- name,
127
- value: `export type ${name} = {
68
+ ${queryParams ? `return stringifiedParams.length > 0 ? \`${route}?\${stringifiedParams}\` : \`${route}\`` : `return \`${route}\``}
69
+ }\n`;
70
+ const isContentTypeNdJson = (contentType) => contentType === "application/nd-json" || contentType === "application/x-ndjson";
71
+ const isNdJson = response.contentTypes.some(isContentTypeNdJson);
72
+ const responseTypeName = fetchResponseTypeName(override.fetch?.includeHttpResponseReturnType, isNdJson ? "Response" : response.definition.success, operationName);
73
+ const allResponses = [...response.types.success, ...response.types.errors];
74
+ if (allResponses.length === 0) allResponses.push({
75
+ contentType: "",
76
+ hasReadonlyProps: false,
77
+ imports: [],
78
+ isEnum: false,
79
+ isRef: false,
80
+ key: "default",
81
+ schemas: [],
82
+ type: "unknown",
83
+ value: "unknown"
84
+ });
85
+ const nonDefaultStatuses = allResponses.filter((r) => r.key !== "default").map((r) => r.key);
86
+ const responseDataTypes = allResponses.map((r) => allResponses.filter((r2) => r2.key === r.key).length > 1 ? {
87
+ ...r,
88
+ suffix: (0, __orval_core.pascal)(r.contentType)
89
+ } : r).map((r) => {
90
+ const name = `${responseTypeName}${(0, __orval_core.pascal)(r.key)}${"suffix" in r ? r.suffix : ""}`;
91
+ return {
92
+ name,
93
+ success: response.types.success.some((s) => s.key === r.key),
94
+ value: `export type ${name} = {
128
95
  ${isContentTypeNdJson(r.contentType) ? `stream: TypedResponse<${r.value}>` : `data: ${r.value || "unknown"}`}
129
96
  status: ${r.key === "default" ? nonDefaultStatuses.length ? `Exclude<HTTPStatusCodes, ${nonDefaultStatuses.join(" | ")}>` : "number" : r.key}
130
97
  }`
131
- };
132
- });
133
- const compositeName = `${responseTypeName}Composite`;
134
- const compositeResponse = `${compositeName} = ${responseDataTypes.map((r) => r.name).join(" | ")}`;
135
- const responseTypeImplementation = override.fetch.includeHttpResponseReturnType ? `${responseDataTypes.map((r) => r.value).join("\n\n")}
98
+ };
99
+ });
100
+ const successName = `${responseTypeName}Success`;
101
+ const errorName = `${responseTypeName}Error`;
102
+ const hasSuccess = responseDataTypes.some((r) => r.success);
103
+ const hasError = responseDataTypes.some((r) => !r.success);
104
+ const responseTypeImplementation = override.fetch.includeHttpResponseReturnType ? `${responseDataTypes.map((r) => r.value).join("\n\n")}
136
105
 
137
- export type ${compositeResponse};
138
-
139
- export type ${responseTypeName} = ${compositeName} & {
106
+ ${hasSuccess ? `export type ${successName} = (${responseDataTypes.filter((r) => r.success).map((r) => r.name).join(" | ")}) & {
107
+ headers: Headers;
108
+ }` : ""};
109
+ ${hasError ? `export type ${errorName} = (${responseDataTypes.filter((r) => !r.success).map((r) => r.name).join(" | ")}) & {
140
110
  headers: Headers;
141
- }
111
+ }` : ""};
142
112
 
143
- ` : "";
144
- const getUrlFnProperties = props.filter(
145
- (prop) => prop.type === import_core2.GetterPropType.PARAM || prop.type === import_core2.GetterPropType.QUERY_PARAM || prop.type === import_core2.GetterPropType.NAMED_PATH_PARAMS
146
- ).map((param) => {
147
- if (param.type === import_core2.GetterPropType.NAMED_PATH_PARAMS) {
148
- return param.destructured;
149
- } else {
150
- return param.name;
151
- }
152
- }).join(",");
153
- const args = `${(0, import_core2.toObjectString)(props, "implementation")} ${isRequestOptions ? `options?: RequestInit` : ""}`;
154
- const returnType = `Promise<${responseTypeName}>`;
155
- const globalFetchOptions = (0, import_core2.isObject)(override == null ? void 0 : override.requestOptions) ? `${(_d = (_c = (0, import_core2.stringify)(override == null ? void 0 : override.requestOptions)) == null ? void 0 : _c.slice(1, -1)) == null ? void 0 : _d.trim()}` : "";
156
- const fetchMethodOption = `method: '${verb.toUpperCase()}'`;
157
- const ignoreContentTypes = ["multipart/form-data"];
158
- const headersToAdd = [
159
- ...body.contentType && !ignoreContentTypes.includes(body.contentType) ? [`'Content-Type': '${body.contentType}'`] : [],
160
- ...isNdJson && response.contentTypes.length === 1 ? [
161
- `Accept: ${response.contentTypes[0] === "application/x-ndjson" ? "'application/x-ndjson'" : "'application/nd-json'"}`
162
- ] : [],
163
- ...headers ? ["...headers"] : []
164
- ];
165
- const fetchHeadersOption = headersToAdd.length ? `headers: { ${headersToAdd.join(",")}, ...options?.headers }` : "";
166
- const requestBodyParams = (0, import_core2.generateBodyOptions)(
167
- body,
168
- isFormData,
169
- isFormUrlEncoded
170
- );
171
- const fetchBodyOption = requestBodyParams ? isFormData && body.formData || isFormUrlEncoded && body.formUrlEncoded || body.contentType === "text/plain" ? `body: ${requestBodyParams}` : `body: JSON.stringify(${requestBodyParams})` : "";
172
- const fetchFnOptions = `${getUrlFnName}(${getUrlFnProperties}),
113
+ ${override.fetch.forceSuccessResponse && hasSuccess ? "" : `export type ${responseTypeName} = (${hasError && hasSuccess ? `${successName} | ${errorName}` : hasSuccess ? successName : errorName})\n\n`}` : "";
114
+ const getUrlFnProperties = props.filter((prop) => prop.type === __orval_core.GetterPropType.PARAM || prop.type === __orval_core.GetterPropType.QUERY_PARAM || prop.type === __orval_core.GetterPropType.NAMED_PATH_PARAMS).map((param) => {
115
+ if (param.type === __orval_core.GetterPropType.NAMED_PATH_PARAMS) return param.destructured;
116
+ else return param.name;
117
+ }).join(",");
118
+ const args = `${(0, __orval_core.toObjectString)(props, "implementation")} ${isRequestOptions ? `options?: RequestInit` : ""}`;
119
+ const returnType = override.fetch.forceSuccessResponse && hasSuccess ? `Promise<${successName}>` : `Promise<${responseTypeName}>`;
120
+ const globalFetchOptions = (0, __orval_core.isObject)(override?.requestOptions) ? `${(0, __orval_core.stringify)(override?.requestOptions)?.slice(1, -1)?.trim()}` : "";
121
+ const fetchMethodOption = `method: '${verb.toUpperCase()}'`;
122
+ const headersToAdd = [
123
+ ...body.contentType && !["multipart/form-data"].includes(body.contentType) ? [`'Content-Type': '${body.contentType}'`] : [],
124
+ ...isNdJson && response.contentTypes.length === 1 ? [`Accept: ${response.contentTypes[0] === "application/x-ndjson" ? "'application/x-ndjson'" : "'application/nd-json'"}`] : [],
125
+ ...headers ? ["...headers"] : []
126
+ ];
127
+ const fetchHeadersOption = headersToAdd.length ? `headers: { ${headersToAdd.join(",")}, ...options?.headers }` : "";
128
+ const requestBodyParams = (0, __orval_core.generateBodyOptions)(body, isFormData, isFormUrlEncoded);
129
+ const fetchBodyOption = requestBodyParams ? isFormData && body.formData || isFormUrlEncoded && body.formUrlEncoded || body.contentType === "text/plain" ? `body: ${requestBodyParams}` : `body: JSON.stringify(${requestBodyParams})` : "";
130
+ const fetchFnOptions = `${getUrlFnName}(${getUrlFnProperties}),
173
131
  {${globalFetchOptions ? "\n" : ""} ${globalFetchOptions}
174
132
  ${isRequestOptions ? "...options," : ""}
175
133
  ${fetchMethodOption}${fetchHeadersOption ? "," : ""}
@@ -177,48 +135,51 @@ export type ${responseTypeName} = ${compositeName} & {
177
135
  ${fetchBodyOption}
178
136
  }
179
137
  `;
180
- const reviver = fetchReviver ? `, ${fetchReviver.name}` : "";
181
- const fetchResponseImplementation = isNdJson ? `const stream = await fetch(${fetchFnOptions})
182
-
183
- ${override.fetch.includeHttpResponseReturnType ? `return { status: stream.status, stream, headers: stream.headers } as ${responseTypeName}` : `return stream`}
138
+ const reviver = fetchReviver ? `, ${fetchReviver.name}` : "";
139
+ const throwOnErrorImplementation = `if (!${isNdJson ? "stream" : "res"}.ok) {
140
+ ${isNdJson ? "const body = [204, 205, 304].includes(stream.status) ? null : await stream.text();" : ""}
141
+ const err: globalThis.Error & {info?: ${hasError ? `${errorName}${override.fetch.includeHttpResponseReturnType ? "['data']" : ""}` : "any"}, status?: number} = new globalThis.Error();
142
+ const data ${hasError ? `: ${errorName}${override.fetch.includeHttpResponseReturnType ? `['data']` : ""}` : ""} = body ? JSON.parse(body${reviver}) : {}
143
+ err.info = data;
144
+ err.status = ${isNdJson ? "stream" : "res"}.status;
145
+ throw err;
146
+ }`;
147
+ const fetchResponseImplementation = isNdJson ? ` const stream = await fetch(${fetchFnOptions});
148
+ ${override.fetch.forceSuccessResponse ? throwOnErrorImplementation : ""}
149
+ ${override.fetch.includeHttpResponseReturnType ? `return { status: stream.status, stream, headers: stream.headers } as ${override.fetch.forceSuccessResponse && hasSuccess ? successName : responseTypeName}` : `return stream`}
184
150
  ` : `const res = await fetch(${fetchFnOptions})
185
151
 
186
- const body = [204, 205, 304].includes(res.status) ? null : await res.text()
187
- const data: ${responseTypeName}${override.fetch.includeHttpResponseReturnType ? `['data']` : ""} = body ? JSON.parse(body${reviver}) : {}
188
-
189
- ${override.fetch.includeHttpResponseReturnType ? `return { data, status: res.status, headers: res.headers } as ${responseTypeName}` : "return data"}
152
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
153
+ ${override.fetch.forceSuccessResponse ? throwOnErrorImplementation : ""}
154
+ const data: ${override.fetch.forceSuccessResponse && hasSuccess ? successName : responseTypeName}${override.fetch.includeHttpResponseReturnType ? `['data']` : ""} = body ? JSON.parse(body${reviver}) : {}
155
+ ${override.fetch.includeHttpResponseReturnType ? `return { data, status: res.status, headers: res.headers } as ${override.fetch.forceSuccessResponse && hasSuccess ? successName : responseTypeName}` : "return data"}
190
156
  `;
191
- const customFetchResponseImplementation = `return ${mutator == null ? void 0 : mutator.name}<${responseTypeName}>(${fetchFnOptions});`;
192
- const bodyForm = (0, import_core2.generateFormDataAndUrlEncodedFunction)({
193
- formData,
194
- formUrlEncoded,
195
- body,
196
- isFormData,
197
- isFormUrlEncoded
198
- });
199
- const fetchImplementationBody = mutator ? customFetchResponseImplementation : fetchResponseImplementation;
200
- const fetchImplementation = `export const ${operationName} = async (${args}): ${returnType} => {
157
+ const customFetchResponseImplementation = `return ${mutator?.name}<${override.fetch.forceSuccessResponse && hasSuccess ? successName : responseTypeName}>(${fetchFnOptions});`;
158
+ const bodyForm = (0, __orval_core.generateFormDataAndUrlEncodedFunction)({
159
+ formData,
160
+ formUrlEncoded,
161
+ body,
162
+ isFormData,
163
+ isFormUrlEncoded
164
+ });
165
+ const fetchImplementationBody = mutator ? customFetchResponseImplementation : fetchResponseImplementation;
166
+ const fetchImplementation = `export const ${operationName} = async (${args}): ${returnType} => {
201
167
  ${bodyForm ? ` ${bodyForm}` : ""}
202
168
  ${fetchImplementationBody}}
203
169
  `;
204
- const implementation = `${responseTypeImplementation}${getUrlFnImplementation}
205
- ${fetchImplementation}
206
- `;
207
- return implementation;
170
+ return `${responseTypeImplementation}${getUrlFnImplementation}\n${fetchImplementation}\n`;
208
171
  };
209
- var fetchResponseTypeName = (includeHttpResponseReturnType, definitionSuccessResponse, operationName) => {
210
- return includeHttpResponseReturnType ? `${operationName}Response` : definitionSuccessResponse;
172
+ const fetchResponseTypeName = (includeHttpResponseReturnType, definitionSuccessResponse, operationName) => {
173
+ return includeHttpResponseReturnType ? `${operationName}Response` : definitionSuccessResponse;
211
174
  };
212
- var generateClient = (verbOptions, options) => {
213
- const imports = (0, import_core2.generateVerbImports)(verbOptions);
214
- const functionImplementation = generateRequestFunction(verbOptions, options);
215
- return {
216
- implementation: `${functionImplementation}
217
- `,
218
- imports
219
- };
175
+ const generateClient = (verbOptions, options) => {
176
+ const imports = (0, __orval_core.generateVerbImports)(verbOptions);
177
+ return {
178
+ implementation: `${generateRequestFunction(verbOptions, options)}\n`,
179
+ imports
180
+ };
220
181
  };
221
- var getHTTPStatusCodes = () => `
182
+ const getHTTPStatusCodes = () => `
222
183
  export type HTTPStatusCode1xx = 100 | 101 | 102 | 103;
223
184
  export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207;
224
185
  export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308;
@@ -227,24 +188,22 @@ export type HTTPStatusCode5xx = 500 | 501 | 502 | 503 | 504 | 505 | 507 | 511;
227
188
  export type HTTPStatusCodes = HTTPStatusCode1xx | HTTPStatusCode2xx | HTTPStatusCode3xx | HTTPStatusCode4xx | HTTPStatusCode5xx;
228
189
 
229
190
  `;
230
- var generateFetchHeader = ({
231
- clientImplementation
232
- }) => {
233
- return clientImplementation.includes("<HTTPStatusCodes,") ? getHTTPStatusCodes() : "";
191
+ const generateFetchHeader = ({ clientImplementation }) => {
192
+ return clientImplementation.includes("<HTTPStatusCodes,") ? getHTTPStatusCodes() : "";
234
193
  };
235
- var fetchClientBuilder = {
236
- client: generateClient,
237
- header: generateFetchHeader,
238
- dependencies: () => []
194
+ const fetchClientBuilder = {
195
+ client: generateClient,
196
+ header: generateFetchHeader,
197
+ dependencies: () => []
239
198
  };
240
- var builder = () => () => fetchClientBuilder;
241
- var index_default = builder;
242
- // Annotate the CommonJS export names for ESM import in node:
243
- 0 && (module.exports = {
244
- builder,
245
- fetchResponseTypeName,
246
- generateClient,
247
- generateFetchHeader,
248
- generateRequestFunction
249
- });
199
+ const builder = () => () => fetchClientBuilder;
200
+ var src_default = builder;
201
+
202
+ //#endregion
203
+ exports.builder = builder;
204
+ exports.default = src_default;
205
+ exports.fetchResponseTypeName = fetchResponseTypeName;
206
+ exports.generateClient = generateClient;
207
+ exports.generateFetchHeader = generateFetchHeader;
208
+ exports.generateRequestFunction = generateRequestFunction;
250
209
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { ClientHeaderBuilder, pascal } from '@orval/core';\nimport {\n camel,\n ClientBuilder,\n ClientGeneratorsBuilder,\n generateFormDataAndUrlEncodedFunction,\n generateVerbImports,\n GeneratorOptions,\n GeneratorVerbOptions,\n GetterPropType,\n stringify,\n toObjectString,\n generateBodyOptions,\n isObject,\n resolveRef,\n} from '@orval/core';\nimport {\n PathItemObject,\n ParameterObject,\n ReferenceObject,\n} from 'openapi3-ts/oas30';\n\nexport const generateRequestFunction = (\n {\n queryParams,\n headers,\n operationName,\n response,\n mutator,\n body,\n props,\n verb,\n fetchReviver,\n formData,\n formUrlEncoded,\n override,\n }: GeneratorVerbOptions,\n { route, context, pathRoute }: GeneratorOptions,\n) => {\n const isRequestOptions = override?.requestOptions !== false;\n const isFormData = override?.formData.disabled === false;\n const isFormUrlEncoded = override?.formUrlEncoded !== false;\n\n const getUrlFnName = camel(`get-${operationName}-url`);\n const getUrlFnProps = toObjectString(\n props.filter(\n (prop) =>\n prop.type === GetterPropType.PARAM ||\n prop.type === GetterPropType.NAMED_PATH_PARAMS ||\n prop.type === GetterPropType.QUERY_PARAM,\n ),\n 'implementation',\n );\n\n const spec = context.specs[context.specKey].paths[pathRoute] as\n | PathItemObject\n | undefined;\n const parameters =\n spec?.[verb]?.parameters || ([] as (ParameterObject | ReferenceObject)[]);\n\n const explodeParameters = parameters.filter((parameter) => {\n const { schema } = resolveRef<ParameterObject>(parameter, context);\n\n if (override.fetch.explode) {\n return schema.in === 'query' && schema.explode;\n } else {\n return schema.in === 'query' && schema.explode !== false;\n }\n });\n\n const explodeParametersNames = explodeParameters.map((parameter) => {\n const { schema } = resolveRef<ParameterObject>(parameter, context);\n\n return schema.name;\n });\n const hasDateParams =\n context.output.override.useDates &&\n parameters.some(\n (p) =>\n 'schema' in p &&\n p.schema &&\n 'format' in p.schema &&\n p.schema.format === 'date-time',\n );\n\n const explodeArrayImplementation =\n explodeParameters.length > 0\n ? `const explodeParameters = ${JSON.stringify(explodeParametersNames)};\n\n if (Array.isArray(value) && explodeParameters.includes(key)) {\n value.forEach((v) => normalizedParams.append(key, v === null ? 'null' : ${hasDateParams ? 'v instanceof Date ? v.toISOString() : ' : ''}v.toString()));\n return;\n }\n `\n : '';\n\n const isExplodeParametersOnly =\n explodeParameters.length === parameters.length;\n\n const nomalParamsImplementation = `if (value !== undefined) {\n normalizedParams.append(key, value === null ? 'null' : ${hasDateParams ? 'value instanceof Date ? value.toISOString() : ' : ''}value.toString())\n }`;\n\n const getUrlFnImplementation = `export const ${getUrlFnName} = (${getUrlFnProps}) => {\n${\n queryParams\n ? ` const normalizedParams = new URLSearchParams();\n\n Object.entries(params || {}).forEach(([key, value]) => {\n ${explodeArrayImplementation}\n ${!isExplodeParametersOnly ? nomalParamsImplementation : ''}\n });`\n : ''\n}\n\n ${queryParams ? `const stringifiedParams = normalizedParams.toString();` : ``}\n\n ${\n queryParams\n ? `return stringifiedParams.length > 0 ? \\`${route}${'?${stringifiedParams}'}\\` : \\`${route}\\``\n : `return \\`${route}\\``\n }\n}\\n`;\n\n const isContentTypeNdJson = (contentType: string) =>\n contentType === 'application/nd-json' ||\n contentType === 'application/x-ndjson';\n\n const isNdJson = response.contentTypes.some(isContentTypeNdJson);\n const responseTypeName = fetchResponseTypeName(\n override.fetch?.includeHttpResponseReturnType,\n isNdJson ? 'Response' : response.definition.success,\n operationName,\n );\n\n const allResponses = [...response.types.success, ...response.types.errors];\n if (allResponses.length === 0) {\n allResponses.push({\n contentType: '',\n hasReadonlyProps: false,\n imports: [],\n isEnum: false,\n isRef: false,\n key: 'default',\n schemas: [],\n type: 'unknown',\n value: 'unknown',\n });\n }\n const nonDefaultStatuses = allResponses\n .filter((r) => r.key !== 'default')\n .map((r) => r.key);\n const responseDataTypes = allResponses\n .map((r) =>\n allResponses.filter((r2) => r2.key === r.key).length > 1\n ? { ...r, suffix: pascal(r.contentType) }\n : r,\n )\n .map((r) => {\n const name = `${responseTypeName}${pascal(r.key)}${'suffix' in r ? r.suffix : ''}`;\n return {\n name,\n value: `export type ${name} = {\n ${isContentTypeNdJson(r.contentType) ? `stream: TypedResponse<${r.value}>` : `data: ${r.value || 'unknown'}`}\n status: ${\n r.key === 'default'\n ? nonDefaultStatuses.length\n ? `Exclude<HTTPStatusCodes, ${nonDefaultStatuses.join(' | ')}>`\n : 'number'\n : r.key\n }\n}`,\n };\n });\n\n const compositeName = `${responseTypeName}Composite`;\n const compositeResponse = `${compositeName} = ${responseDataTypes.map((r) => r.name).join(' | ')}`;\n\n const responseTypeImplementation = override.fetch\n .includeHttpResponseReturnType\n ? `${responseDataTypes.map((r) => r.value).join('\\n\\n')}\n \nexport type ${compositeResponse};\n \nexport type ${responseTypeName} = ${compositeName} & {\n headers: Headers;\n}\\n\\n`\n : '';\n\n const getUrlFnProperties = props\n .filter(\n (prop) =>\n prop.type === GetterPropType.PARAM ||\n prop.type === GetterPropType.QUERY_PARAM ||\n prop.type === GetterPropType.NAMED_PATH_PARAMS,\n )\n .map((param) => {\n if (param.type === GetterPropType.NAMED_PATH_PARAMS) {\n return param.destructured;\n } else {\n return param.name;\n }\n })\n .join(',');\n\n const args = `${toObjectString(props, 'implementation')} ${isRequestOptions ? `options?: RequestInit` : ''}`;\n const returnType = `Promise<${responseTypeName}>`;\n\n const globalFetchOptions = isObject(override?.requestOptions)\n ? `${stringify(override?.requestOptions)?.slice(1, -1)?.trim()}`\n : '';\n const fetchMethodOption = `method: '${verb.toUpperCase()}'`;\n const ignoreContentTypes = ['multipart/form-data'];\n const headersToAdd: string[] = [\n ...(body.contentType && !ignoreContentTypes.includes(body.contentType)\n ? [`'Content-Type': '${body.contentType}'`]\n : []),\n ...(isNdJson && response.contentTypes.length === 1\n ? [\n `Accept: ${\n response.contentTypes[0] === 'application/x-ndjson'\n ? \"'application/x-ndjson'\"\n : \"'application/nd-json'\"\n }`,\n ]\n : []),\n ...(headers ? ['...headers'] : []),\n ];\n const fetchHeadersOption = headersToAdd.length\n ? `headers: { ${headersToAdd.join(',')}, ...options?.headers }`\n : '';\n const requestBodyParams = generateBodyOptions(\n body,\n isFormData,\n isFormUrlEncoded,\n );\n const fetchBodyOption = requestBodyParams\n ? (isFormData && body.formData) ||\n (isFormUrlEncoded && body.formUrlEncoded) ||\n body.contentType === 'text/plain'\n ? `body: ${requestBodyParams}`\n : `body: JSON.stringify(${requestBodyParams})`\n : '';\n\n const fetchFnOptions = `${getUrlFnName}(${getUrlFnProperties}),\n {${globalFetchOptions ? '\\n' : ''} ${globalFetchOptions}\n ${isRequestOptions ? '...options,' : ''}\n ${fetchMethodOption}${fetchHeadersOption ? ',' : ''}\n ${fetchHeadersOption}${fetchBodyOption ? ',' : ''}\n ${fetchBodyOption}\n }\n`;\n const reviver = fetchReviver ? `, ${fetchReviver.name}` : '';\n const fetchResponseImplementation = isNdJson\n ? `const stream = await fetch(${fetchFnOptions})\n\n ${override.fetch.includeHttpResponseReturnType ? `return { status: stream.status, stream, headers: stream.headers } as ${responseTypeName}` : `return stream`}\n `\n : `const res = await fetch(${fetchFnOptions})\n\n const body = [204, 205, 304].includes(res.status) ? null : await res.text()\n const data: ${responseTypeName}${override.fetch.includeHttpResponseReturnType ? `['data']` : ''} = body ? JSON.parse(body${reviver}) : {}\n\n ${override.fetch.includeHttpResponseReturnType ? `return { data, status: res.status, headers: res.headers } as ${responseTypeName}` : 'return data'}\n`;\n const customFetchResponseImplementation = `return ${mutator?.name}<${responseTypeName}>(${fetchFnOptions});`;\n\n const bodyForm = generateFormDataAndUrlEncodedFunction({\n formData,\n formUrlEncoded,\n body,\n isFormData,\n isFormUrlEncoded,\n });\n\n const fetchImplementationBody = mutator\n ? customFetchResponseImplementation\n : fetchResponseImplementation;\n\n const fetchImplementation = `export const ${operationName} = async (${args}): ${returnType} => {\n ${bodyForm ? ` ${bodyForm}` : ''}\n ${fetchImplementationBody}}\n`;\n\n const implementation =\n `${responseTypeImplementation}` +\n `${getUrlFnImplementation}\\n` +\n `${fetchImplementation}\\n`;\n\n return implementation;\n};\n\nexport const fetchResponseTypeName = (\n includeHttpResponseReturnType: boolean | undefined,\n definitionSuccessResponse: string,\n operationName: string,\n) => {\n return includeHttpResponseReturnType\n ? `${operationName}Response`\n : definitionSuccessResponse;\n};\n\nexport const generateClient: ClientBuilder = (verbOptions, options) => {\n const imports = generateVerbImports(verbOptions);\n const functionImplementation = generateRequestFunction(verbOptions, options);\n\n return {\n implementation: `${functionImplementation}\\n`,\n imports,\n };\n};\n\nconst getHTTPStatusCodes = () => `\nexport type HTTPStatusCode1xx = 100 | 101 | 102 | 103;\nexport type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207;\nexport type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308;\nexport type HTTPStatusCode4xx = 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 426 | 428 | 429 | 431 | 451;\nexport type HTTPStatusCode5xx = 500 | 501 | 502 | 503 | 504 | 505 | 507 | 511;\nexport type HTTPStatusCodes = HTTPStatusCode1xx | HTTPStatusCode2xx | HTTPStatusCode3xx | HTTPStatusCode4xx | HTTPStatusCode5xx;\n\n`;\n\nexport const generateFetchHeader: ClientHeaderBuilder = ({\n clientImplementation,\n}) => {\n return clientImplementation.includes('<HTTPStatusCodes,')\n ? getHTTPStatusCodes()\n : '';\n};\n\nconst fetchClientBuilder: ClientGeneratorsBuilder = {\n client: generateClient,\n header: generateFetchHeader,\n dependencies: () => [],\n};\n\nexport const builder = () => () => fetchClientBuilder;\n\nexport default builder;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA4C;AAC5C,IAAAA,eAcO;AAOA,IAAM,0BAA0B,CACrC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GACA,EAAE,OAAO,SAAS,UAAU,MACzB;AAtCL;AAuCE,QAAM,oBAAmB,qCAAU,oBAAmB;AACtD,QAAM,cAAa,qCAAU,SAAS,cAAa;AACnD,QAAM,oBAAmB,qCAAU,oBAAmB;AAEtD,QAAM,mBAAe,oBAAM,OAAO,aAAa,MAAM;AACrD,QAAM,oBAAgB;AAAA,IACpB,MAAM;AAAA,MACJ,CAAC,SACC,KAAK,SAAS,4BAAe,SAC7B,KAAK,SAAS,4BAAe,qBAC7B,KAAK,SAAS,4BAAe;AAAA,IACjC;AAAA,IACA;AAAA,EACF;AAEA,QAAM,OAAO,QAAQ,MAAM,QAAQ,OAAO,EAAE,MAAM,S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ExB,SAAO;AACT;AAEO,IAAM,wBAAwB,CACnC,+BACA,2BACA,kBACG;AACH,SAAO,gCACH,GAAG,aAAa,aAChB;AACN;AAEO,IAAM,iBAAgC,CAAC,aAAa,YAAY;AACrE,QAAM,cAAU,kCAAoB,WAAW;AAC/C,QAAM,yBAAyB,wBAAwB,aAAa,OAAO;AAE3E,SAAO;AAAA,IACL,gBAAgB,GAAG,sBAAsB;AAAA;AAAA,IACzC;AAAA,EACF;AACF;AAEA,IAAM,qBAAqB,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAU1B,IAAM,sBAA2C,CAAC;AAAA,EACvD;AACF,MAAM;AACJ,SAAO,qBAAqB,SAAS,mBAAmB,IACpD,mBAAmB,IACnB;AACN;AAEA,IAAM,qBAA8C;AAAA,EAClD,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,cAAc,MAAM,CAAC;AACvB;AAEO,IAAM,UAAU,MAAM,MAAM;AAEnC,IAAO,gBAAQ;","names":["import_core"]}
1
+ {"version":3,"file":"index.js","names":["GetterPropType","headersToAdd: string[]","generateClient: ClientBuilder","generateFetchHeader: ClientHeaderBuilder","fetchClientBuilder: ClientGeneratorsBuilder"],"sources":["../src/index.ts"],"sourcesContent":["import { ClientHeaderBuilder, pascal } from '@orval/core';\nimport {\n camel,\n ClientBuilder,\n ClientGeneratorsBuilder,\n generateFormDataAndUrlEncodedFunction,\n generateVerbImports,\n GeneratorOptions,\n GeneratorVerbOptions,\n GetterPropType,\n stringify,\n toObjectString,\n generateBodyOptions,\n isObject,\n resolveRef,\n} from '@orval/core';\nimport {\n PathItemObject,\n ParameterObject,\n ReferenceObject,\n} from 'openapi3-ts/oas30';\nimport { SchemaObject } from 'openapi3-ts/oas31';\n\nexport const generateRequestFunction = (\n {\n queryParams,\n headers,\n operationName,\n response,\n mutator,\n body,\n props,\n verb,\n fetchReviver,\n formData,\n formUrlEncoded,\n override,\n }: GeneratorVerbOptions,\n { route, context, pathRoute }: GeneratorOptions,\n) => {\n const isRequestOptions = override?.requestOptions !== false;\n const isFormData = override?.formData.disabled === false;\n const isFormUrlEncoded = override?.formUrlEncoded !== false;\n\n const getUrlFnName = camel(`get-${operationName}-url`);\n const getUrlFnProps = toObjectString(\n props.filter(\n (prop) =>\n prop.type === GetterPropType.PARAM ||\n prop.type === GetterPropType.NAMED_PATH_PARAMS ||\n prop.type === GetterPropType.QUERY_PARAM,\n ),\n 'implementation',\n );\n\n const spec = context.specs[context.specKey].paths[pathRoute] as\n | PathItemObject\n | undefined;\n const parameters =\n spec?.[verb]?.parameters || ([] as (ParameterObject | ReferenceObject)[]);\n\n const explodeParameters = parameters.filter((parameter) => {\n const { schema } = resolveRef<ParameterObject>(parameter, context);\n const schemaObject = schema.schema as SchemaObject;\n\n return (\n schema.in === 'query' &&\n schemaObject.type === 'array' &&\n (schema.explode || override.fetch.explode)\n );\n });\n\n const explodeParametersNames = explodeParameters.map((parameter) => {\n const { schema } = resolveRef<ParameterObject>(parameter, context);\n\n return schema.name;\n });\n const hasDateParams =\n context.output.override.useDates &&\n parameters.some(\n (p) =>\n 'schema' in p &&\n p.schema &&\n 'format' in p.schema &&\n p.schema.format === 'date-time',\n );\n\n const explodeArrayImplementation =\n explodeParameters.length > 0\n ? `const explodeParameters = ${JSON.stringify(explodeParametersNames)};\n\n if (Array.isArray(value) && explodeParameters.includes(key)) {\n value.forEach((v) => normalizedParams.append(key, v === null ? 'null' : ${hasDateParams ? 'v instanceof Date ? v.toISOString() : ' : ''}v.toString()));\n return;\n }\n `\n : '';\n\n const isExplodeParametersOnly =\n explodeParameters.length === parameters.length;\n\n const nomalParamsImplementation = `if (value !== undefined) {\n normalizedParams.append(key, value === null ? 'null' : ${hasDateParams ? 'value instanceof Date ? value.toISOString() : ' : ''}value.toString())\n }`;\n\n const getUrlFnImplementation = `export const ${getUrlFnName} = (${getUrlFnProps}) => {\n${\n queryParams\n ? ` const normalizedParams = new URLSearchParams();\n\n Object.entries(params || {}).forEach(([key, value]) => {\n ${explodeArrayImplementation}\n ${!isExplodeParametersOnly ? nomalParamsImplementation : ''}\n });`\n : ''\n}\n\n ${queryParams ? `const stringifiedParams = normalizedParams.toString();` : ``}\n\n ${\n queryParams\n ? `return stringifiedParams.length > 0 ? \\`${route}${'?${stringifiedParams}'}\\` : \\`${route}\\``\n : `return \\`${route}\\``\n }\n}\\n`;\n\n const isContentTypeNdJson = (contentType: string) =>\n contentType === 'application/nd-json' ||\n contentType === 'application/x-ndjson';\n\n const isNdJson = response.contentTypes.some(isContentTypeNdJson);\n const responseTypeName = fetchResponseTypeName(\n override.fetch?.includeHttpResponseReturnType,\n isNdJson ? 'Response' : response.definition.success,\n operationName,\n );\n\n const allResponses = [...response.types.success, ...response.types.errors];\n if (allResponses.length === 0) {\n allResponses.push({\n contentType: '',\n hasReadonlyProps: false,\n imports: [],\n isEnum: false,\n isRef: false,\n key: 'default',\n schemas: [],\n type: 'unknown',\n value: 'unknown',\n });\n }\n const nonDefaultStatuses = allResponses\n .filter((r) => r.key !== 'default')\n .map((r) => r.key);\n const responseDataTypes = allResponses\n .map((r) =>\n allResponses.filter((r2) => r2.key === r.key).length > 1\n ? { ...r, suffix: pascal(r.contentType) }\n : r,\n )\n .map((r) => {\n const name = `${responseTypeName}${pascal(r.key)}${'suffix' in r ? r.suffix : ''}`;\n return {\n name,\n success: response.types.success.some((s) => s.key === r.key),\n value: `export type ${name} = {\n ${isContentTypeNdJson(r.contentType) ? `stream: TypedResponse<${r.value}>` : `data: ${r.value || 'unknown'}`}\n status: ${\n r.key === 'default'\n ? nonDefaultStatuses.length\n ? `Exclude<HTTPStatusCodes, ${nonDefaultStatuses.join(' | ')}>`\n : 'number'\n : r.key\n }\n}`,\n };\n });\n\n const successName = `${responseTypeName}Success`;\n const errorName = `${responseTypeName}Error`;\n const hasSuccess = responseDataTypes.some((r) => r.success);\n const hasError = responseDataTypes.some((r) => !r.success);\n\n const responseTypeImplementation = override.fetch\n .includeHttpResponseReturnType\n ? `${responseDataTypes.map((r) => r.value).join('\\n\\n')}\n \n${\n hasSuccess\n ? `export type ${successName} = (${responseDataTypes\n .filter((r) => r.success)\n .map((r) => r.name)\n .join(' | ')}) & {\n headers: Headers;\n}`\n : ''\n};\n${\n hasError\n ? `export type ${errorName} = (${responseDataTypes\n .filter((r) => !r.success)\n .map((r) => r.name)\n .join(' | ')}) & {\n headers: Headers;\n}`\n : ''\n};\n\n${override.fetch.forceSuccessResponse && hasSuccess ? '' : `export type ${responseTypeName} = (${hasError && hasSuccess ? `${successName} | ${errorName}` : hasSuccess ? successName : errorName})\\n\\n`}`\n : '';\n\n const getUrlFnProperties = props\n .filter(\n (prop) =>\n prop.type === GetterPropType.PARAM ||\n prop.type === GetterPropType.QUERY_PARAM ||\n prop.type === GetterPropType.NAMED_PATH_PARAMS,\n )\n .map((param) => {\n if (param.type === GetterPropType.NAMED_PATH_PARAMS) {\n return param.destructured;\n } else {\n return param.name;\n }\n })\n .join(',');\n\n const args = `${toObjectString(props, 'implementation')} ${isRequestOptions ? `options?: RequestInit` : ''}`;\n const returnType =\n override.fetch.forceSuccessResponse && hasSuccess\n ? `Promise<${successName}>`\n : `Promise<${responseTypeName}>`;\n\n const globalFetchOptions = isObject(override?.requestOptions)\n ? `${stringify(override?.requestOptions)?.slice(1, -1)?.trim()}`\n : '';\n const fetchMethodOption = `method: '${verb.toUpperCase()}'`;\n const ignoreContentTypes = ['multipart/form-data'];\n const headersToAdd: string[] = [\n ...(body.contentType && !ignoreContentTypes.includes(body.contentType)\n ? [`'Content-Type': '${body.contentType}'`]\n : []),\n ...(isNdJson && response.contentTypes.length === 1\n ? [\n `Accept: ${\n response.contentTypes[0] === 'application/x-ndjson'\n ? \"'application/x-ndjson'\"\n : \"'application/nd-json'\"\n }`,\n ]\n : []),\n ...(headers ? ['...headers'] : []),\n ];\n const fetchHeadersOption = headersToAdd.length\n ? `headers: { ${headersToAdd.join(',')}, ...options?.headers }`\n : '';\n const requestBodyParams = generateBodyOptions(\n body,\n isFormData,\n isFormUrlEncoded,\n );\n const fetchBodyOption = requestBodyParams\n ? (isFormData && body.formData) ||\n (isFormUrlEncoded && body.formUrlEncoded) ||\n body.contentType === 'text/plain'\n ? `body: ${requestBodyParams}`\n : `body: JSON.stringify(${requestBodyParams})`\n : '';\n\n const fetchFnOptions = `${getUrlFnName}(${getUrlFnProperties}),\n {${globalFetchOptions ? '\\n' : ''} ${globalFetchOptions}\n ${isRequestOptions ? '...options,' : ''}\n ${fetchMethodOption}${fetchHeadersOption ? ',' : ''}\n ${fetchHeadersOption}${fetchBodyOption ? ',' : ''}\n ${fetchBodyOption}\n }\n`;\n const reviver = fetchReviver ? `, ${fetchReviver.name}` : '';\n const throwOnErrorImplementation = `if (!${isNdJson ? 'stream' : 'res'}.ok) {\n ${isNdJson ? 'const body = [204, 205, 304].includes(stream.status) ? null : await stream.text();' : ''}\n const err: globalThis.Error & {info?: ${hasError ? `${errorName}${override.fetch.includeHttpResponseReturnType ? \"['data']\" : ''}` : 'any'}, status?: number} = new globalThis.Error();\n const data ${hasError ? `: ${errorName}${override.fetch.includeHttpResponseReturnType ? `['data']` : ''}` : ''} = body ? JSON.parse(body${reviver}) : {}\n err.info = data;\n err.status = ${isNdJson ? 'stream' : 'res'}.status;\n throw err;\n }`;\n const fetchResponseImplementation = isNdJson\n ? ` const stream = await fetch(${fetchFnOptions});\n ${override.fetch.forceSuccessResponse ? throwOnErrorImplementation : ''}\n ${override.fetch.includeHttpResponseReturnType ? `return { status: stream.status, stream, headers: stream.headers } as ${override.fetch.forceSuccessResponse && hasSuccess ? successName : responseTypeName}` : `return stream`}\n `\n : `const res = await fetch(${fetchFnOptions})\n\n const body = [204, 205, 304].includes(res.status) ? null : await res.text();\n ${override.fetch.forceSuccessResponse ? throwOnErrorImplementation : ''}\n const data: ${override.fetch.forceSuccessResponse && hasSuccess ? successName : responseTypeName}${override.fetch.includeHttpResponseReturnType ? `['data']` : ''} = body ? JSON.parse(body${reviver}) : {}\n ${override.fetch.includeHttpResponseReturnType ? `return { data, status: res.status, headers: res.headers } as ${override.fetch.forceSuccessResponse && hasSuccess ? successName : responseTypeName}` : 'return data'}\n`;\n const customFetchResponseImplementation = `return ${mutator?.name}<${override.fetch.forceSuccessResponse && hasSuccess ? successName : responseTypeName}>(${fetchFnOptions});`;\n\n const bodyForm = generateFormDataAndUrlEncodedFunction({\n formData,\n formUrlEncoded,\n body,\n isFormData,\n isFormUrlEncoded,\n });\n\n const fetchImplementationBody = mutator\n ? customFetchResponseImplementation\n : fetchResponseImplementation;\n\n const fetchImplementation = `export const ${operationName} = async (${args}): ${returnType} => {\n ${bodyForm ? ` ${bodyForm}` : ''}\n ${fetchImplementationBody}}\n`;\n\n const implementation =\n `${responseTypeImplementation}` +\n `${getUrlFnImplementation}\\n` +\n `${fetchImplementation}\\n`;\n\n return implementation;\n};\n\nexport const fetchResponseTypeName = (\n includeHttpResponseReturnType: boolean | undefined,\n definitionSuccessResponse: string,\n operationName: string,\n) => {\n return includeHttpResponseReturnType\n ? `${operationName}Response`\n : definitionSuccessResponse;\n};\n\nexport const generateClient: ClientBuilder = (verbOptions, options) => {\n const imports = generateVerbImports(verbOptions);\n const functionImplementation = generateRequestFunction(verbOptions, options);\n\n return {\n implementation: `${functionImplementation}\\n`,\n imports,\n };\n};\n\nconst getHTTPStatusCodes = () => `\nexport type HTTPStatusCode1xx = 100 | 101 | 102 | 103;\nexport type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207;\nexport type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308;\nexport type HTTPStatusCode4xx = 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 426 | 428 | 429 | 431 | 451;\nexport type HTTPStatusCode5xx = 500 | 501 | 502 | 503 | 504 | 505 | 507 | 511;\nexport type HTTPStatusCodes = HTTPStatusCode1xx | HTTPStatusCode2xx | HTTPStatusCode3xx | HTTPStatusCode4xx | HTTPStatusCode5xx;\n\n`;\n\nexport const generateFetchHeader: ClientHeaderBuilder = ({\n clientImplementation,\n}) => {\n return clientImplementation.includes('<HTTPStatusCodes,')\n ? getHTTPStatusCodes()\n : '';\n};\n\nconst fetchClientBuilder: ClientGeneratorsBuilder = {\n client: generateClient,\n header: generateFetchHeader,\n dependencies: () => [],\n};\n\nexport const builder = () => () => fetchClientBuilder;\n\nexport default builder;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,2BACX,EACE,aACA,SACA,eACA,UACA,SACA,MACA,OACA,MACA,cACA,UACA,gBACA,YAEF,EAAE,OAAO,SAAS,gBACf;CACH,MAAM,mBAAmB,UAAU,mBAAmB;CACtD,MAAM,aAAa,UAAU,SAAS,aAAa;CACnD,MAAM,mBAAmB,UAAU,mBAAmB;CAEtD,MAAM,uCAAqB,OAAO,cAAc,MAAM;CACtD,MAAM,iDACJ,MAAM,QACH,SACC,KAAK,SAASA,4BAAe,SAC7B,KAAK,SAASA,4BAAe,qBAC7B,KAAK,SAASA,4BAAe,YAChC,EACD,iBACD;CAKD,MAAM,aAHO,QAAQ,MAAM,QAAQ,SAAS,MAAM,aAIzC,OAAO,cAAe,EAAE;CAEjC,MAAM,oBAAoB,WAAW,QAAQ,cAAc;EACzD,MAAM,EAAE,wCAAuC,WAAW,QAAQ;EAClE,MAAM,eAAe,OAAO;AAE5B,SACE,OAAO,OAAO,WACd,aAAa,SAAS,YACrB,OAAO,WAAW,SAAS,MAAM;GAEpC;CAEF,MAAM,yBAAyB,kBAAkB,KAAK,cAAc;EAClE,MAAM,EAAE,wCAAuC,WAAW,QAAQ;AAElE,SAAO,OAAO;GACd;CACF,MAAM,gBACJ,QAAQ,OAAO,SAAS,YACxB,WAAW,MACR,MACC,YAAY,KACZ,EAAE,UACF,YAAY,EAAE,UACd,EAAE,OAAO,WAAW,YACvB;CAEH,MAAM,6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1",
3
+ "version": "7.12.1",
4
4
  "license": "MIT",
5
- "main": "./dist/index.js",
6
- "types": "./dist/index.d.ts",
5
+ "exports": {
6
+ ".": {
7
+ "types": "./dist/index.d.ts",
8
+ "default": "./dist/index.js"
9
+ }
10
+ },
7
11
  "files": [
8
12
  "dist"
9
13
  ],
10
14
  "scripts": {
11
- "build": "tsup ./src/index.ts --target node12 --clean --sourcemap --dts",
12
- "dev": "tsup ./src/index.ts --target node12 --clean --sourcemap --watch src",
13
- "lint": "eslint src/**/*.ts"
15
+ "build": "tsdown --config-loader unconfig",
16
+ "dev": "tsdown --config-loader unconfig --watch src",
17
+ "lint": "eslint .",
18
+ "clean": "rimraf .turbo dist",
19
+ "nuke": "rimraf .turbo dist node_modules"
14
20
  },
15
21
  "dependencies": {
16
- "@orval/core": "7.11.1"
22
+ "@orval/core": "workspace:*",
23
+ "openapi3-ts": "4.5.0"
24
+ },
25
+ "devDependencies": {
26
+ "eslint": "^9.35.0",
27
+ "rimraf": "^6.0.1",
28
+ "tsdown": "^0.15.2",
29
+ "typescript": "^5.9.2"
17
30
  }
18
31
  }