@orval/fetch 7.11.2 → 7.12.2

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
package/dist/index.js CHANGED
@@ -1,172 +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
- const schemaObject = schema.schema;
63
- return schema.in === "query" && schemaObject.type === "array" && (schema.explode || override.fetch.explode);
64
- });
65
- const explodeParametersNames = explodeParameters.map((parameter) => {
66
- const { schema } = (0, import_core2.resolveRef)(parameter, context);
67
- return schema.name;
68
- });
69
- const hasDateParams = context.output.override.useDates && parameters.some(
70
- (p) => "schema" in p && p.schema && "format" in p.schema && p.schema.format === "date-time"
71
- );
72
- 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)};
73
49
 
74
50
  if (Array.isArray(value) && explodeParameters.includes(key)) {
75
51
  value.forEach((v) => normalizedParams.append(key, v === null ? 'null' : ${hasDateParams ? "v instanceof Date ? v.toISOString() : " : ""}v.toString()));
76
52
  return;
77
53
  }
78
54
  ` : "";
79
- const isExplodeParametersOnly = explodeParameters.length === parameters.length;
80
- const nomalParamsImplementation = `if (value !== undefined) {
81
- normalizedParams.append(key, value === null ? 'null' : ${hasDateParams ? "value instanceof Date ? value.toISOString() : " : ""}value.toString())
82
- }`;
83
- const getUrlFnImplementation = `export const ${getUrlFnName} = (${getUrlFnProps}) => {
55
+ const isExplodeParametersOnly = explodeParameters.length === parameters.length;
56
+ const getUrlFnImplementation = `export const ${getUrlFnName} = (${getUrlFnProps}) => {
84
57
  ${queryParams ? ` const normalizedParams = new URLSearchParams();
85
58
 
86
59
  Object.entries(params || {}).forEach(([key, value]) => {
87
60
  ${explodeArrayImplementation}
88
- ${!isExplodeParametersOnly ? nomalParamsImplementation : ""}
61
+ ${!isExplodeParametersOnly ? `if (value !== undefined) {
62
+ normalizedParams.append(key, value === null ? 'null' : ${hasDateParams ? "value instanceof Date ? value.toISOString() : " : ""}value.toString())
63
+ }` : ""}
89
64
  });` : ""}
90
65
 
91
66
  ${queryParams ? `const stringifiedParams = normalizedParams.toString();` : ``}
92
67
 
93
- ${queryParams ? `return stringifiedParams.length > 0 ? \`${route}${"?${stringifiedParams}"}\` : \`${route}\`` : `return \`${route}\``}
94
- }
95
- `;
96
- const isContentTypeNdJson = (contentType) => contentType === "application/nd-json" || contentType === "application/x-ndjson";
97
- const isNdJson = response.contentTypes.some(isContentTypeNdJson);
98
- const responseTypeName = fetchResponseTypeName(
99
- (_b = override.fetch) == null ? void 0 : _b.includeHttpResponseReturnType,
100
- isNdJson ? "Response" : response.definition.success,
101
- operationName
102
- );
103
- const allResponses = [...response.types.success, ...response.types.errors];
104
- if (allResponses.length === 0) {
105
- allResponses.push({
106
- contentType: "",
107
- hasReadonlyProps: false,
108
- imports: [],
109
- isEnum: false,
110
- isRef: false,
111
- key: "default",
112
- schemas: [],
113
- type: "unknown",
114
- value: "unknown"
115
- });
116
- }
117
- const nonDefaultStatuses = allResponses.filter((r) => r.key !== "default").map((r) => r.key);
118
- const responseDataTypes = allResponses.map(
119
- (r) => allResponses.filter((r2) => r2.key === r.key).length > 1 ? { ...r, suffix: (0, import_core.pascal)(r.contentType) } : r
120
- ).map((r) => {
121
- const name = `${responseTypeName}${(0, import_core.pascal)(r.key)}${"suffix" in r ? r.suffix : ""}`;
122
- return {
123
- name,
124
- 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} = {
125
95
  ${isContentTypeNdJson(r.contentType) ? `stream: TypedResponse<${r.value}>` : `data: ${r.value || "unknown"}`}
126
96
  status: ${r.key === "default" ? nonDefaultStatuses.length ? `Exclude<HTTPStatusCodes, ${nonDefaultStatuses.join(" | ")}>` : "number" : r.key}
127
97
  }`
128
- };
129
- });
130
- const compositeName = `${responseTypeName}Composite`;
131
- const compositeResponse = `${compositeName} = ${responseDataTypes.map((r) => r.name).join(" | ")}`;
132
- 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")}
133
105
 
134
- export type ${compositeResponse};
135
-
136
- 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(" | ")}) & {
137
110
  headers: Headers;
138
- }
111
+ }` : ""};
139
112
 
140
- ` : "";
141
- const getUrlFnProperties = props.filter(
142
- (prop) => prop.type === import_core2.GetterPropType.PARAM || prop.type === import_core2.GetterPropType.QUERY_PARAM || prop.type === import_core2.GetterPropType.NAMED_PATH_PARAMS
143
- ).map((param) => {
144
- if (param.type === import_core2.GetterPropType.NAMED_PATH_PARAMS) {
145
- return param.destructured;
146
- } else {
147
- return param.name;
148
- }
149
- }).join(",");
150
- const args = `${(0, import_core2.toObjectString)(props, "implementation")} ${isRequestOptions ? `options?: RequestInit` : ""}`;
151
- const returnType = `Promise<${responseTypeName}>`;
152
- 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()}` : "";
153
- const fetchMethodOption = `method: '${verb.toUpperCase()}'`;
154
- const ignoreContentTypes = ["multipart/form-data"];
155
- const headersToAdd = [
156
- ...body.contentType && !ignoreContentTypes.includes(body.contentType) ? [`'Content-Type': '${body.contentType}'`] : [],
157
- ...isNdJson && response.contentTypes.length === 1 ? [
158
- `Accept: ${response.contentTypes[0] === "application/x-ndjson" ? "'application/x-ndjson'" : "'application/nd-json'"}`
159
- ] : [],
160
- ...headers ? ["...headers"] : []
161
- ];
162
- const fetchHeadersOption = headersToAdd.length ? `headers: { ${headersToAdd.join(",")}, ...options?.headers }` : "";
163
- const requestBodyParams = (0, import_core2.generateBodyOptions)(
164
- body,
165
- isFormData,
166
- isFormUrlEncoded
167
- );
168
- const fetchBodyOption = requestBodyParams ? isFormData && body.formData || isFormUrlEncoded && body.formUrlEncoded || body.contentType === "text/plain" ? `body: ${requestBodyParams}` : `body: JSON.stringify(${requestBodyParams})` : "";
169
- 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}),
170
131
  {${globalFetchOptions ? "\n" : ""} ${globalFetchOptions}
171
132
  ${isRequestOptions ? "...options," : ""}
172
133
  ${fetchMethodOption}${fetchHeadersOption ? "," : ""}
@@ -174,48 +135,51 @@ export type ${responseTypeName} = ${compositeName} & {
174
135
  ${fetchBodyOption}
175
136
  }
176
137
  `;
177
- const reviver = fetchReviver ? `, ${fetchReviver.name}` : "";
178
- const fetchResponseImplementation = isNdJson ? `const stream = await fetch(${fetchFnOptions})
179
-
180
- ${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`}
181
150
  ` : `const res = await fetch(${fetchFnOptions})
182
151
 
183
- const body = [204, 205, 304].includes(res.status) ? null : await res.text()
184
- const data: ${responseTypeName}${override.fetch.includeHttpResponseReturnType ? `['data']` : ""} = body ? JSON.parse(body${reviver}) : {}
185
-
186
- ${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"}
187
156
  `;
188
- const customFetchResponseImplementation = `return ${mutator == null ? void 0 : mutator.name}<${responseTypeName}>(${fetchFnOptions});`;
189
- const bodyForm = (0, import_core2.generateFormDataAndUrlEncodedFunction)({
190
- formData,
191
- formUrlEncoded,
192
- body,
193
- isFormData,
194
- isFormUrlEncoded
195
- });
196
- const fetchImplementationBody = mutator ? customFetchResponseImplementation : fetchResponseImplementation;
197
- 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} => {
198
167
  ${bodyForm ? ` ${bodyForm}` : ""}
199
168
  ${fetchImplementationBody}}
200
169
  `;
201
- const implementation = `${responseTypeImplementation}${getUrlFnImplementation}
202
- ${fetchImplementation}
203
- `;
204
- return implementation;
170
+ return `${responseTypeImplementation}${getUrlFnImplementation}\n${fetchImplementation}\n`;
205
171
  };
206
- var fetchResponseTypeName = (includeHttpResponseReturnType, definitionSuccessResponse, operationName) => {
207
- return includeHttpResponseReturnType ? `${operationName}Response` : definitionSuccessResponse;
172
+ const fetchResponseTypeName = (includeHttpResponseReturnType, definitionSuccessResponse, operationName) => {
173
+ return includeHttpResponseReturnType ? `${operationName}Response` : definitionSuccessResponse;
208
174
  };
209
- var generateClient = (verbOptions, options) => {
210
- const imports = (0, import_core2.generateVerbImports)(verbOptions);
211
- const functionImplementation = generateRequestFunction(verbOptions, options);
212
- return {
213
- implementation: `${functionImplementation}
214
- `,
215
- imports
216
- };
175
+ const generateClient = (verbOptions, options) => {
176
+ const imports = (0, __orval_core.generateVerbImports)(verbOptions);
177
+ return {
178
+ implementation: `${generateRequestFunction(verbOptions, options)}\n`,
179
+ imports
180
+ };
217
181
  };
218
- var getHTTPStatusCodes = () => `
182
+ const getHTTPStatusCodes = () => `
219
183
  export type HTTPStatusCode1xx = 100 | 101 | 102 | 103;
220
184
  export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207;
221
185
  export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308;
@@ -224,24 +188,22 @@ export type HTTPStatusCode5xx = 500 | 501 | 502 | 503 | 504 | 505 | 507 | 511;
224
188
  export type HTTPStatusCodes = HTTPStatusCode1xx | HTTPStatusCode2xx | HTTPStatusCode3xx | HTTPStatusCode4xx | HTTPStatusCode5xx;
225
189
 
226
190
  `;
227
- var generateFetchHeader = ({
228
- clientImplementation
229
- }) => {
230
- return clientImplementation.includes("<HTTPStatusCodes,") ? getHTTPStatusCodes() : "";
191
+ const generateFetchHeader = ({ clientImplementation }) => {
192
+ return clientImplementation.includes("<HTTPStatusCodes,") ? getHTTPStatusCodes() : "";
231
193
  };
232
- var fetchClientBuilder = {
233
- client: generateClient,
234
- header: generateFetchHeader,
235
- dependencies: () => []
194
+ const fetchClientBuilder = {
195
+ client: generateClient,
196
+ header: generateFetchHeader,
197
+ dependencies: () => []
236
198
  };
237
- var builder = () => () => fetchClientBuilder;
238
- var index_default = builder;
239
- // Annotate the CommonJS export names for ESM import in node:
240
- 0 && (module.exports = {
241
- builder,
242
- fetchResponseTypeName,
243
- generateClient,
244
- generateFetchHeader,
245
- generateRequestFunction
246
- });
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;
247
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';\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 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;AAQA,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;AAvCL;AAwCE,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,SAAS;AAG3D,QAAM,eACJ,kCAAO,UAAP,mBAAc,eAAe,CAAC;AAEhC,QAAM,oBAAoB,WAAW,OAAO,CAAC,cAAc;AACzD,UAAM,EAAE,OAAO,QAAI,yBAA4B,WAAW,OAAO;AACjE,UAAM,eAAe,OAAO;AAE5B,WACE,OAAO,OAAO,WACd,aAAa,SAAS,YACrB,OAAO,WAAW,SAAS,MAAM;AAAA,EAEtC,CAAC;AAED,QAAM,yBAAyB,kBAAkB,IAAI,CAAC,cAAc;AAClE,UAAM,EAAE,OAAO,QAAI,yBAA4B,WAAW,OAAO;A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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,MAC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AAK,GAAG,SAAS,MAAM,wBAAwB,aAAa,cAAc,iBAAiB,IAAI,eAAe;CAE3K,MAAM,mEAAiD;EACrD;EACA;EACA;EACA;EACA;EACD,CAAC;CAEF,MAAM,0BAA0B,UAC5B,oCACA;CAEJ,MAAM,sBAAsB,gBAAgB,cAAc,YAAY,KAAK,KAAK,WAAW;IACzF,WAAW,KAAK,aAAa,GAAG;IAChC,wBAAwB;;AAQ1B,QAJE,GAAG,6BACA,uBAAuB,IACvB,oBAAoB;;AAK3B,MAAa,yBACX,+BACA,2BACA,kBACG;AACH,QAAO,gCACH,GAAG,cAAc,YACjB;;AAGN,MAAaC,kBAAiC,aAAa,YAAY;CACrE,MAAM,gDAA8B,YAAY;AAGhD,QAAO;EACL,gBAAgB,GAHa,wBAAwB,aAAa,QAAQ,CAGhC;EAC1C;EACD;;AAGH,MAAM,2BAA2B;;;;;;;;;AAUjC,MAAaC,uBAA4C,EACvD,2BACI;AACJ,QAAO,qBAAqB,SAAS,oBAAoB,GACrD,oBAAoB,GACpB;;AAGN,MAAMC,qBAA8C;CAClD,QAAQ;CACR,QAAQ;CACR,oBAAoB,EAAE;CACvB;AAED,MAAa,sBAAsB;AAEnC,kBAAe"}
package/package.json CHANGED
@@ -1,18 +1,32 @@
1
1
  {
2
2
  "name": "@orval/fetch",
3
- "version": "7.11.2",
3
+ "version": "7.12.2",
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
- "dist"
12
+ "dist",
13
+ "!dist/**/*.d.ts.map"
9
14
  ],
10
15
  "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"
16
+ "build": "tsdown --config-loader unconfig",
17
+ "dev": "tsdown --config-loader unconfig --watch src",
18
+ "lint": "eslint .",
19
+ "clean": "rimraf .turbo dist",
20
+ "nuke": "rimraf .turbo dist node_modules"
14
21
  },
15
22
  "dependencies": {
16
- "@orval/core": "7.11.2"
23
+ "@orval/core": "7.12.2",
24
+ "openapi3-ts": "4.5.0"
25
+ },
26
+ "devDependencies": {
27
+ "eslint": "^9.35.0",
28
+ "rimraf": "^6.0.1",
29
+ "tsdown": "^0.15.2",
30
+ "typescript": "^5.9.2"
17
31
  }
18
- }
32
+ }