nuxt-openapi-hyperfetch 0.1.0-alpha.1 → 0.1.2-alpha.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.
@@ -43,7 +43,7 @@ export async function generateUseAsyncDataComposables(inputDir, outputDir, optio
43
43
  mainSpinner.start('Preparing output directories');
44
44
  const composablesDir = path.join(outputDir, 'composables');
45
45
  const runtimeDir = path.join(outputDir, 'runtime');
46
- const sharedRuntimeDir = path.join(outputDir, 'shared', 'runtime');
46
+ const sharedRuntimeDir = path.join(path.dirname(outputDir), 'shared', 'runtime');
47
47
  await fs.emptyDir(composablesDir);
48
48
  await fs.ensureDir(runtimeDir);
49
49
  await fs.ensureDir(sharedRuntimeDir);
@@ -97,7 +97,7 @@ function generateImports(method, apiImportPath, isRaw) {
97
97
  */
98
98
  function generateFunctionBody(method, isRaw, generateOptions) {
99
99
  const hasParams = !!method.requestType;
100
- const paramsArg = hasParams ? `params: MaybeRef<${method.requestType}>` : '';
100
+ const paramsArg = hasParams ? `params: ${method.requestType}` : '';
101
101
  // Determine the options type based on isRaw
102
102
  const optionsType = isRaw
103
103
  ? `ApiAsyncDataRawOptions<${method.responseType}>`
@@ -116,7 +116,7 @@ function generateFunctionBody(method, isRaw, generateOptions) {
116
116
  const description = method.description ? `/**\n * ${method.description}\n */\n` : '';
117
117
  // Choose the correct wrapper function
118
118
  const wrapperFunction = isRaw ? 'useApiAsyncDataRaw' : 'useApiAsyncData';
119
- const pInit = hasParams ? `\n const p = isRef(params) ? params : shallowRef(params)` : '';
119
+ const pInit = hasParams ? `\n const p = shallowRef(params)` : '';
120
120
  return `${description}export const ${composableName} = (${args}) => {${pInit}
121
121
  return ${wrapperFunction}${responseTypeGeneric}(${key}, ${url}, ${fetchOptions})
122
122
  }`;
@@ -43,7 +43,7 @@ export async function generateUseFetchComposables(inputDir, outputDir, options)
43
43
  mainSpinner.start('Preparing output directories');
44
44
  const composablesDir = path.join(outputDir, 'composables');
45
45
  const runtimeDir = path.join(outputDir, 'runtime');
46
- const sharedRuntimeDir = path.join(outputDir, 'shared', 'runtime');
46
+ const sharedRuntimeDir = path.join(path.dirname(outputDir), 'shared', 'runtime');
47
47
  await fs.emptyDir(composablesDir);
48
48
  await fs.ensureDir(runtimeDir);
49
49
  await fs.ensureDir(sharedRuntimeDir);
@@ -86,7 +86,7 @@ function generateImports(method, apiImportPath) {
86
86
  */
87
87
  function generateFunctionBody(method, options) {
88
88
  const hasParams = !!method.requestType;
89
- const paramsArg = hasParams ? `params: MaybeRef<${method.requestType}>` : '';
89
+ const paramsArg = hasParams ? `params: ${method.requestType}` : '';
90
90
  const optionsType = `ApiRequestOptions<${method.responseType}>`;
91
91
  const optionsArg = `options?: ${optionsType}`;
92
92
  const args = hasParams ? `${paramsArg}, ${optionsArg}` : optionsArg;
@@ -94,7 +94,7 @@ function generateFunctionBody(method, options) {
94
94
  const url = generateUrl(method);
95
95
  const fetchOptions = generateFetchOptions(method, options);
96
96
  const description = method.description ? `/**\n * ${method.description}\n */\n` : '';
97
- const pInit = hasParams ? `\n const p = isRef(params) ? params : shallowRef(params)` : '';
97
+ const pInit = hasParams ? `\n const p = shallowRef(params)` : '';
98
98
  return `${description}export const ${method.composableName} = (${args}) => {${pInit}
99
99
  return useApiRequest${responseTypeGeneric}(${url}, ${fetchOptions})
100
100
  }`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-openapi-hyperfetch",
3
- "version": "0.1.0-alpha.1",
3
+ "version": "0.1.2-alpha.1",
4
4
  "description": "Nuxt useFetch, useAsyncData and Nuxt server OpenAPI generator",
5
5
  "type": "module",
6
6
  "author": "",
@@ -67,7 +67,7 @@ export async function generateUseAsyncDataComposables(
67
67
  mainSpinner.start('Preparing output directories');
68
68
  const composablesDir = path.join(outputDir, 'composables');
69
69
  const runtimeDir = path.join(outputDir, 'runtime');
70
- const sharedRuntimeDir = path.join(outputDir, 'shared', 'runtime');
70
+ const sharedRuntimeDir = path.join(path.dirname(outputDir), 'shared', 'runtime');
71
71
  await fs.emptyDir(composablesDir);
72
72
  await fs.ensureDir(runtimeDir);
73
73
  await fs.ensureDir(sharedRuntimeDir);
@@ -135,7 +135,7 @@ function generateFunctionBody(
135
135
  generateOptions?: GenerateOptions
136
136
  ): string {
137
137
  const hasParams = !!method.requestType;
138
- const paramsArg = hasParams ? `params: MaybeRef<${method.requestType}>` : '';
138
+ const paramsArg = hasParams ? `params: ${method.requestType}` : '';
139
139
 
140
140
  // Determine the options type based on isRaw
141
141
  const optionsType = isRaw
@@ -163,7 +163,7 @@ function generateFunctionBody(
163
163
  // Choose the correct wrapper function
164
164
  const wrapperFunction = isRaw ? 'useApiAsyncDataRaw' : 'useApiAsyncData';
165
165
 
166
- const pInit = hasParams ? `\n const p = isRef(params) ? params : shallowRef(params)` : '';
166
+ const pInit = hasParams ? `\n const p = shallowRef(params)` : '';
167
167
 
168
168
  return `${description}export const ${composableName} = (${args}) => {${pInit}
169
169
  return ${wrapperFunction}${responseTypeGeneric}(${key}, ${url}, ${fetchOptions})
@@ -62,7 +62,7 @@ export async function generateUseFetchComposables(
62
62
  mainSpinner.start('Preparing output directories');
63
63
  const composablesDir = path.join(outputDir, 'composables');
64
64
  const runtimeDir = path.join(outputDir, 'runtime');
65
- const sharedRuntimeDir = path.join(outputDir, 'shared', 'runtime');
65
+ const sharedRuntimeDir = path.join(path.dirname(outputDir), 'shared', 'runtime');
66
66
  await fs.emptyDir(composablesDir);
67
67
  await fs.ensureDir(runtimeDir);
68
68
  await fs.ensureDir(sharedRuntimeDir);
@@ -115,7 +115,7 @@ function generateImports(method: MethodInfo, apiImportPath: string): string {
115
115
  */
116
116
  function generateFunctionBody(method: MethodInfo, options?: GenerateOptions): string {
117
117
  const hasParams = !!method.requestType;
118
- const paramsArg = hasParams ? `params: MaybeRef<${method.requestType}>` : '';
118
+ const paramsArg = hasParams ? `params: ${method.requestType}` : '';
119
119
  const optionsType = `ApiRequestOptions<${method.responseType}>`;
120
120
  const optionsArg = `options?: ${optionsType}`;
121
121
  const args = hasParams ? `${paramsArg}, ${optionsArg}` : optionsArg;
@@ -127,7 +127,7 @@ function generateFunctionBody(method: MethodInfo, options?: GenerateOptions): st
127
127
 
128
128
  const description = method.description ? `/**\n * ${method.description}\n */\n` : '';
129
129
 
130
- const pInit = hasParams ? `\n const p = isRef(params) ? params : shallowRef(params)` : '';
130
+ const pInit = hasParams ? `\n const p = shallowRef(params)` : '';
131
131
 
132
132
  return `${description}export const ${method.composableName} = (${args}) => {${pInit}
133
133
  return useApiRequest${responseTypeGeneric}(${url}, ${fetchOptions})