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.
- package/dist/generators/use-async-data/generator.js +1 -1
- package/dist/generators/use-async-data/templates.js +2 -2
- package/dist/generators/use-fetch/generator.js +1 -1
- package/dist/generators/use-fetch/templates.js +2 -2
- package/package.json +1 -1
- package/src/generators/use-async-data/generator.ts +1 -1
- package/src/generators/use-async-data/templates.ts +2 -2
- package/src/generators/use-fetch/generator.ts +1 -1
- package/src/generators/use-fetch/templates.ts +2 -2
|
@@ -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:
|
|
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 =
|
|
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:
|
|
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 =
|
|
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
|
@@ -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:
|
|
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 =
|
|
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:
|
|
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 =
|
|
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})
|