@orval/fetch 6.31.0 → 7.0.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  [![npm version](https://badge.fury.io/js/orval.svg)](https://badge.fury.io/js/orval)
2
2
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
3
- [![tests](https://github.com/anymaniax/orval/actions/workflows/tests.yaml/badge.svg)](https://github.com/anymaniax/orval/actions/workflows/tests.yaml)
3
+ [![tests](https://github.com/orval-labs/orval/actions/workflows/tests.yaml/badge.svg)](https://github.com/orval-labs/orval/actions/workflows/tests.yaml)
4
4
 
5
5
  <p align="center">
6
6
  <img src="./logo/orval-logo-horizontal.svg?raw=true" width="500" height="160" alt="orval - Restfull Client Generator" />
@@ -19,12 +19,12 @@
19
19
 
20
20
  You can find below some samples
21
21
 
22
- - [react app](https://github.com/anymaniax/orval/tree/master/samples/react-app)
23
- - [react query](https://github.com/anymaniax/orval/tree/master/samples/react-query)
24
- - [svelte query](https://github.com/anymaniax/orval/tree/master/samples/svelte-query)
25
- - [vue query](https://github.com/anymaniax/orval/tree/master/samples/vue-query)
26
- - [react app with swr](https://github.com/anymaniax/orval/tree/master/samples/react-app-with-swr)
27
- - [nx fastify react](https://github.com/anymaniax/orval/tree/master/samples/nx-fastify-react)
28
- - [angular app](https://github.com/anymaniax/orval/tree/master/samples/angular-app)
29
- - [hono](https://github.com/anymaniax/orval/tree/master/samples/hono)
30
- - [next app with fetch](https://github.com/anymaniax/orval/tree/master/samples/next-app-with-fetch)
22
+ - [react app](https://github.com/orval-labs/orval/tree/master/samples/react-app)
23
+ - [react query](https://github.com/orval-labs/orval/tree/master/samples/react-query)
24
+ - [svelte query](https://github.com/orval-labs/orval/tree/master/samples/svelte-query)
25
+ - [vue query](https://github.com/orval-labs/orval/tree/master/samples/vue-query)
26
+ - [react app with swr](https://github.com/orval-labs/orval/tree/master/samples/react-app-with-swr)
27
+ - [nx fastify react](https://github.com/orval-labs/orval/tree/master/samples/nx-fastify-react)
28
+ - [angular app](https://github.com/orval-labs/orval/tree/master/samples/angular-app)
29
+ - [hono](https://github.com/orval-labs/orval/tree/master/samples/hono)
30
+ - [next app with fetch](https://github.com/orval-labs/orval/tree/master/samples/next-app-with-fetch)
package/dist/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
- import { ClientBuilder, ClientGeneratorsBuilder } from '@orval/core';
1
+ import { GeneratorVerbOptions, GeneratorOptions, ClientBuilder, ClientGeneratorsBuilder } from '@orval/core';
2
2
 
3
+ declare const generateRequestFunction: ({ queryParams, operationName, response, mutator, body, props, verb, formData, formUrlEncoded, override, }: GeneratorVerbOptions, { route }: GeneratorOptions) => string;
4
+ declare const fetchResponseTypeName: (includeHttpStatusReturnType: boolean, definitionSuccessResponse: string, operationName: string) => string;
3
5
  declare const generateClient: ClientBuilder;
4
6
  declare const builder: () => () => ClientGeneratorsBuilder;
5
7
 
6
- export { builder, builder as default, generateClient };
8
+ export { builder, builder as default, fetchResponseTypeName, generateClient, generateRequestFunction };
package/dist/index.js CHANGED
@@ -22,7 +22,9 @@ var src_exports = {};
22
22
  __export(src_exports, {
23
23
  builder: () => builder,
24
24
  default: () => src_default,
25
- generateClient: () => generateClient
25
+ fetchResponseTypeName: () => fetchResponseTypeName,
26
+ generateClient: () => generateClient,
27
+ generateRequestFunction: () => generateRequestFunction
26
28
  });
27
29
  module.exports = __toCommonJS(src_exports);
28
30
  var import_core = require("@orval/core");
@@ -61,14 +63,20 @@ ${queryParams ? `
61
63
  }
62
64
  });` : ""}
63
65
 
64
- return \`${route}${queryParams ? "?${normalizedParams.toString()}" : ""}\`
66
+ ${queryParams ? `return normalizedParams.size ? \`${route}${"?${normalizedParams.toString()}"}\` : \`${route}\`` : `return \`${route}\``}
65
67
  }
66
68
  `;
67
- const responseTypeName = `${operationName}Response`;
68
- const responseTypeImplementation = `export type ${operationName}Response = {
69
+ const responseTypeName = fetchResponseTypeName(
70
+ override.fetch.includeHttpStatusReturnType,
71
+ response.definition.success,
72
+ operationName
73
+ );
74
+ const responseTypeImplementation = override.fetch.includeHttpStatusReturnType ? `export type ${responseTypeName} = {
69
75
  data: ${response.definition.success || "unknown"};
70
76
  status: number;
71
- }`;
77
+ }
78
+
79
+ ` : "";
72
80
  const getUrlFnProperties = props.filter(
73
81
  (prop) => prop.type === import_core.GetterPropType.PARAM || prop.type === import_core.GetterPropType.QUERY_PARAM || prop.type === import_core.GetterPropType.NAMED_PATH_PARAMS
74
82
  ).map((param) => {
@@ -82,16 +90,19 @@ ${queryParams ? `
82
90
  const retrunType = `Promise<${responseTypeName}>`;
83
91
  const globalFetchOptions = (0, import_core.isObject)(override == null ? void 0 : override.requestOptions) ? `${(_b = (_a = (0, import_core.stringify)(override == null ? void 0 : override.requestOptions)) == null ? void 0 : _a.slice(1, -1)) == null ? void 0 : _b.trim()}` : "";
84
92
  const fetchMethodOption = `method: '${verb.toUpperCase()}'`;
93
+ const ignoreContentTypes = ["multipart/form-data"];
94
+ const fetchHeadersOption = body.contentType && !ignoreContentTypes.includes(body.contentType) ? `headers: { 'Content-Type': '${body.contentType}' }` : "";
85
95
  const requestBodyParams = (0, import_core.generateBodyOptions)(
86
96
  body,
87
97
  isFormData,
88
98
  isFormUrlEncoded
89
99
  );
90
- const fetchBodyOption = requestBodyParams ? `body: JSON.stringify(${requestBodyParams})` : "";
100
+ const fetchBodyOption = requestBodyParams ? isFormData && body.formData || isFormUrlEncoded && body.formUrlEncoded ? `body: ${requestBodyParams}` : `body: JSON.stringify(${requestBodyParams})` : "";
91
101
  const fetchFnOptions = `${getUrlFnName}(${getUrlFnProperties}),
92
102
  {${globalFetchOptions ? "\n" : ""} ${globalFetchOptions}
93
103
  ${isRequestOptions ? "...options," : ""}
94
- ${fetchMethodOption}${fetchBodyOption ? "," : ""}
104
+ ${fetchMethodOption}${fetchHeadersOption ? "," : ""}
105
+ ${fetchHeadersOption}${fetchBodyOption ? "," : ""}
95
106
  ${fetchBodyOption}
96
107
  }
97
108
  `;
@@ -99,7 +110,7 @@ ${queryParams ? `
99
110
  )
100
111
  const data = await res.json()
101
112
 
102
- return { status: res.status, data }
113
+ ${override.fetch.includeHttpStatusReturnType ? "return { status: res.status, data }" : `return data as ${responseTypeName}`}
103
114
  `;
104
115
  const customFetchResponseImplementation = `return ${mutator == null ? void 0 : mutator.name}<${retrunType}>(${fetchFnOptions});`;
105
116
  const bodyForm = (0, import_core.generateFormDataAndUrlEncodedFunction)({
@@ -109,17 +120,19 @@ ${queryParams ? `
109
120
  isFormData,
110
121
  isFormUrlEncoded
111
122
  });
112
- const fetchImplementationBody = mutator ? customFetchResponseImplementation : `${bodyForm ? ` ${bodyForm}
113
- ` : ""} ${fetchResponseImplementation}`;
123
+ const fetchImplementationBody = mutator ? customFetchResponseImplementation : fetchResponseImplementation;
114
124
  const fetchImplementation = `export const ${operationName} = async (${args}): ${retrunType} => {
115
- ${fetchImplementationBody}}`;
116
- const implementation = `${responseTypeImplementation}
117
-
118
- ${getUrlFnImplementation}
125
+ ${bodyForm ? ` ${bodyForm}` : ""}
126
+ ${fetchImplementationBody}}
127
+ `;
128
+ const implementation = `${responseTypeImplementation}${getUrlFnImplementation}
119
129
  ${fetchImplementation}
120
130
  `;
121
131
  return implementation;
122
132
  };
133
+ var fetchResponseTypeName = (includeHttpStatusReturnType, definitionSuccessResponse, operationName) => {
134
+ return includeHttpStatusReturnType ? `${operationName}Response` : definitionSuccessResponse;
135
+ };
123
136
  var generateClient = (verbOptions, options) => {
124
137
  const imports = (0, import_core.generateVerbImports)(verbOptions);
125
138
  const functionImplementation = generateRequestFunction(verbOptions, options);
@@ -138,6 +151,8 @@ var src_default = builder;
138
151
  // Annotate the CommonJS export names for ESM import in node:
139
152
  0 && (module.exports = {
140
153
  builder,
141
- generateClient
154
+ fetchResponseTypeName,
155
+ generateClient,
156
+ generateRequestFunction
142
157
  });
143
158
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {\n camel,\n ClientBuilder,\n ClientDependenciesBuilder,\n ClientGeneratorsBuilder,\n generateFormDataAndUrlEncodedFunction,\n generateVerbImports,\n GeneratorDependency,\n GeneratorOptions,\n GeneratorVerbOptions,\n GetterPropType,\n stringify,\n toObjectString,\n generateBodyOptions,\n isObject,\n} from '@orval/core';\n\nconst generateRequestFunction = (\n {\n queryParams,\n operationName,\n response,\n mutator,\n body,\n props,\n verb,\n formData,\n formUrlEncoded,\n override,\n }: GeneratorVerbOptions,\n { route }: GeneratorOptions,\n) => {\n const isRequestOptions = override?.requestOptions !== false;\n const isFormData = override?.formData !== 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 const getUrlFnImplementation = `export const ${getUrlFnName} = (${getUrlFnProps}) => {\n${\n queryParams\n ? `\n const normalizedParams = new URLSearchParams();\n\n Object.entries(params || {}).forEach(([key, value]) => {\n if (value === null) {\n normalizedParams.append(key, 'null');\n } else if (value !== undefined) {\n normalizedParams.append(key, value.toString());\n }\n });`\n : ''\n}\n\n return \\`${route}${queryParams ? '?${normalizedParams.toString()}' : ''}\\`\n}\\n`;\n\n const responseTypeName = `${operationName}Response`;\n const responseTypeImplementation = `export type ${operationName}Response = {\n data: ${response.definition.success || 'unknown'};\n status: number;\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 retrunType = `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\n const requestBodyParams = generateBodyOptions(\n body,\n isFormData,\n isFormUrlEncoded,\n );\n const fetchBodyOption = requestBodyParams\n ? `body: JSON.stringify(${requestBodyParams})`\n : '';\n\n const fetchFnOptions = `${getUrlFnName}(${getUrlFnProperties}),\n {${globalFetchOptions ? '\\n' : ''} ${globalFetchOptions}\n ${isRequestOptions ? '...options,' : ''}\n ${fetchMethodOption}${fetchBodyOption ? ',' : ''}\n ${fetchBodyOption}\n }\n`;\n const fetchResponseImplementation = `const res = await fetch(${fetchFnOptions}\n )\n const data = await res.json()\n\n return { status: res.status, data }\n`;\n const customFetchResponseImplementation = `return ${mutator?.name}<${retrunType}>(${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 : `${bodyForm ? ` ${bodyForm}\\n` : ''}` +\n ` ${fetchResponseImplementation}`;\n const fetchImplementation = `export const ${operationName} = async (${args}): ${retrunType} => {\\n${fetchImplementationBody}}`;\n\n const implementation =\n `${responseTypeImplementation}\\n\\n` +\n `${getUrlFnImplementation}\\n` +\n `${fetchImplementation}\\n`;\n\n return implementation;\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 fetchClientBuilder: ClientGeneratorsBuilder = {\n client: generateClient,\n dependencies: () => [],\n};\n\nexport const builder = () => () => fetchClientBu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BAAsB;AAAA;AAAA,IACzC;AAAA,EACF;AACF;AAEA,IAAM,qBAA8C;AAAA,EAClD,QAAQ;AAAA,EACR,cAAc,MAAM,CAAC;AACvB;AAEO,IAAM,UAAU,MAAM,MAAM;AAEnC,IAAO,cAAQ;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {\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} from '@orval/core';\n\nexport const generateRequestFunction = (\n {\n queryParams,\n operationName,\n response,\n mutator,\n body,\n props,\n verb,\n formData,\n formUrlEncoded,\n override,\n }: GeneratorVerbOptions,\n { route }: GeneratorOptions,\n) => {\n const isRequestOptions = override?.requestOptions !== false;\n const isFormData = override?.formData !== 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 const getUrlFnImplementation = `export const ${getUrlFnName} = (${getUrlFnProps}) => {\n${\n queryParams\n ? `\n const normalizedParams = new URLSearchParams();\n\n Object.entries(params || {}).forEach(([key, value]) => {\n if (value === null) {\n normalizedParams.append(key, 'null');\n } else if (value !== undefined) {\n normalizedParams.append(key, value.toString());\n }\n });`\n : ''\n}\n\n ${\n queryParams\n ? `return normalizedParams.size ? \\`${route}${'?${normalizedParams.toString()}'}\\` : \\`${route}\\``\n : `return \\`${route}\\``\n }\n}\\n`;\n\n const responseTypeName = fetchResponseTypeName(\n override.fetch.includeHttpStatusReturnType,\n response.definition.success,\n operationName,\n );\n const responseTypeImplementation = override.fetch.includeHttpStatusReturnType\n ? `export type ${responseTypeName} = {\n data: ${response.definition.success || 'unknown'};\n status: number;\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 retrunType = `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 fetchHeadersOption =\n body.contentType && !ignoreContentTypes.includes(body.contentType)\n ? `headers: { 'Content-Type': '${body.contentType}' }`\n : '';\n const requestBodyParams = generateBodyOptions(\n body,\n isFormData,\n isFormUrlEncoded,\n );\n const fetchBodyOption = requestBodyParams\n ? (isFormData && body.formData) || (isFormUrlEncoded && body.formUrlEncoded)\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 fetchResponseImplementation = `const res = await fetch(${fetchFnOptions}\n )\n const data = await res.json()\n\n ${override.fetch.includeHttpStatusReturnType ? 'return { status: res.status, data }' : `return data as ${responseTypeName}`}\n`;\n const customFetchResponseImplementation = `return ${mutator?.name}<${retrunType}>(${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}): ${retrunType} => {\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 includeHttpStatusReturnType: boolean,\n definitionSuccessResponse: string,\n operationName: string,\n) => {\n return includeHttpStatusReturnType\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 fetchClientBuilder: ClientGeneratorsBuilder = {\n client: generateClient,\n dependencies: () => [],\n};\n\nexport const builder = () => () => fetchClientBuilder;\n\nexport default builder;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAaO;AAEA,IAAM,0BAA0B,CACrC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GACA,EAAE,MAAM,MACL;AA7BL;AA8BE,QAAM,oBAAmB,qCAAU,oBAAmB;AACtD,QAAM,cAAa,qCAAU,cAAa;AAC1C,QAAM,oBAAmB,qCAAU,oBAAmB;AAEtD,QAAM,mBAAe,mBAAM,OAAO,aAAa,MAAM;AACrD,QAAM,oBAAgB;AAAA,IACpB,MAAM;AAAA,MACJ,CAAC,SACC,KAAK,SAAS,2BAAe,SAC7B,KAAK,SAAS,2BAAe,qBAC7B,KAAK,SAAS,2BAAe;AAAA,IACjC;AAAA,IACA;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AAA,EACR,cAAc,MAAM,CAAC;AACvB;AAEO,IAAM,UAAU,MAAM,MAAM;AAEnC,IAAO,cAAQ;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orval/fetch",
3
- "version": "6.31.0",
3
+ "version": "7.0.1",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -13,6 +13,6 @@
13
13
  "lint": "eslint src/**/*.ts"
14
14
  },
15
15
  "dependencies": {
16
- "@orval/core": "6.31.0"
16
+ "@orval/core": "7.0.1"
17
17
  }
18
18
  }