nuxt-openapi-hyperfetch 0.2.7-alpha.1 β†’ 0.2.8-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.
Files changed (60) hide show
  1. package/.editorconfig +26 -26
  2. package/.prettierignore +17 -17
  3. package/CONTRIBUTING.md +291 -291
  4. package/INSTRUCTIONS.md +327 -327
  5. package/LICENSE +202 -202
  6. package/README.md +231 -231
  7. package/dist/cli/config.d.ts +9 -2
  8. package/dist/cli/config.js +1 -1
  9. package/dist/cli/logo.js +5 -5
  10. package/dist/cli/messages.d.ts +1 -0
  11. package/dist/cli/messages.js +2 -0
  12. package/dist/cli/prompts.d.ts +5 -0
  13. package/dist/cli/prompts.js +12 -0
  14. package/dist/cli/types.d.ts +1 -1
  15. package/dist/generators/components/connector-generator/templates.js +12 -12
  16. package/dist/generators/use-async-data/templates.js +17 -17
  17. package/dist/generators/use-fetch/templates.js +14 -14
  18. package/dist/index.js +39 -27
  19. package/dist/module/index.js +19 -0
  20. package/dist/module/types.d.ts +7 -0
  21. package/docs/API-REFERENCE.md +886 -886
  22. package/docs/generated-components.md +615 -615
  23. package/docs/headless-composables-ui.md +569 -569
  24. package/eslint.config.js +85 -85
  25. package/package.json +1 -1
  26. package/src/cli/config.ts +147 -140
  27. package/src/cli/logger.ts +124 -124
  28. package/src/cli/logo.ts +25 -25
  29. package/src/cli/messages.ts +4 -0
  30. package/src/cli/prompts.ts +14 -1
  31. package/src/cli/types.ts +50 -50
  32. package/src/generators/components/connector-generator/generator.ts +138 -138
  33. package/src/generators/components/connector-generator/templates.ts +254 -254
  34. package/src/generators/components/connector-generator/types.ts +34 -34
  35. package/src/generators/components/schema-analyzer/index.ts +44 -44
  36. package/src/generators/components/schema-analyzer/intent-detector.ts +187 -187
  37. package/src/generators/components/schema-analyzer/openapi-reader.ts +96 -96
  38. package/src/generators/components/schema-analyzer/resource-grouper.ts +166 -166
  39. package/src/generators/components/schema-analyzer/schema-field-mapper.ts +268 -268
  40. package/src/generators/components/schema-analyzer/types.ts +177 -177
  41. package/src/generators/nuxt-server/generator.ts +272 -272
  42. package/src/generators/shared/runtime/apiHelpers.ts +535 -535
  43. package/src/generators/shared/runtime/pagination.ts +323 -323
  44. package/src/generators/shared/runtime/useDeleteConnector.ts +109 -109
  45. package/src/generators/shared/runtime/useDetailConnector.ts +64 -64
  46. package/src/generators/shared/runtime/useFormConnector.ts +139 -139
  47. package/src/generators/shared/runtime/useListConnector.ts +148 -148
  48. package/src/generators/shared/runtime/zod-error-merger.ts +119 -119
  49. package/src/generators/shared/templates/api-callbacks-plugin.ts +399 -399
  50. package/src/generators/shared/templates/api-pagination-plugin.ts +158 -158
  51. package/src/generators/use-async-data/generator.ts +205 -205
  52. package/src/generators/use-async-data/runtime/useApiAsyncData.ts +329 -329
  53. package/src/generators/use-async-data/runtime/useApiAsyncDataRaw.ts +324 -324
  54. package/src/generators/use-async-data/templates.ts +257 -257
  55. package/src/generators/use-fetch/generator.ts +170 -170
  56. package/src/generators/use-fetch/runtime/useApiRequest.ts +354 -354
  57. package/src/generators/use-fetch/templates.ts +214 -214
  58. package/src/index.ts +305 -303
  59. package/src/module/index.ts +158 -133
  60. package/src/module/types.ts +39 -31
package/README.md CHANGED
@@ -1,231 +1,231 @@
1
- ο»Ώ# πŸš€ Nuxt OpenAPI Generator
2
-
3
- **Generate type-safe, SSR-compatible Nuxt composables from OpenAPI/Swagger specifications.**
4
-
5
- πŸ“– **[Full documentation β†’ nuxt-openapi-hyperfetch.netlify.app](https://nuxt-openapi-hyperfetch.netlify.app/)**
6
-
7
- ---
8
-
9
- Transform your API documentation into production-ready **100% Nuxt-native** codeβ€”`useFetch` composables, `useAsyncData` composables, and Nuxt Server Routesβ€”with full TypeScript support, lifecycle callbacks, and request interception. No third-party runtime, no wrappers: just Nuxt.
10
-
11
- ---
12
-
13
- ## ✨ Features
14
-
15
- - πŸ”’ **Type-Safe**: Full TypeScript support derived from your OpenAPI schema
16
- - ⚑ **SSR Compatible**: Works seamlessly with Nuxt server-side rendering
17
- - πŸ”„ **Lifecycle Callbacks**: `onRequest`, `onSuccess`, `onError`, `onFinish`
18
- - 🌐 **Global Callbacks Plugin**: Define callbacks once, apply to all requests
19
- - πŸ›‘οΈ **Request Interception**: Modify headers, body, and query params before sending
20
- - 🎯 **Smart Data Selection**: Pick specific fields with dot notation for nested paths
21
- - πŸ€– **Auto Type Inference**: Transform response data with automatic TypeScript type inference
22
- - ⚑ **Automatic Generation**: Single command generates all composables and server routes
23
- - πŸ’š **100% Nuxt Native**: Generated composables use `useFetch` / `useAsyncData`; server routes use `defineEventHandler` β€” no third-party runtime required
24
- - πŸ“¦ **Zero Runtime Dependencies**: Generated code only uses Nuxt built-ins
25
- - πŸ’‘ **Developer Experience**: Interactive CLI with smart defaults
26
-
27
- ---
28
-
29
- ## πŸ”§ Generator Engines
30
-
31
- Two generation engines are available. The CLI will ask you to choose one when running `nxh generate`:
32
-
33
- | Engine | Tool | Node Native | Best for |
34
- |--------|------|:---:|----------|
35
- | **official** | [@openapitools/openapi-generator-cli](https://openapi-generator.tech/) | ❌ Requires Java 11+ | Maximum spec compatibility, enterprise projects |
36
- | **heyapi** | [@hey-api/openapi-ts](https://heyapi.dev/) | βœ… Yes | Quick setup, CI/CD pipelines, Node-only environments |
37
-
38
- > The CLI checks for Java automatically when `official` is selected and aborts with an install link if it is not found. Get Java at [adoptium.net](https://adoptium.net).
39
-
40
- You can also pre-select the engine in your `nxh.config.js` β€” the CLI will skip the prompt entirely:
41
-
42
- ```js
43
- // nxh.config.js
44
- export default {
45
- generator: 'openapi', // 'openapi' | 'heyapi'
46
- input: './swagger.yaml',
47
- output: './api',
48
- };
49
- ```
50
-
51
- ---
52
-
53
- ## πŸ“¦ Installation
54
-
55
- ```bash
56
- npm install -g nuxt-openapi-hyperfetch
57
- # or
58
- yarn global add nuxt-openapi-hyperfetch
59
- # or
60
- pnpm add -g nuxt-openapi-hyperfetch
61
- ```
62
-
63
- Or use directly with npx:
64
-
65
- ```bash
66
- npx nuxt-openapi-hyperfetch generate
67
- ```
68
-
69
- ---
70
-
71
- ## πŸš€ Quick Start
72
-
73
- ### 1. Run the generator
74
-
75
- ```bash
76
- nxh generate
77
- ```
78
-
79
- The CLI will ask you for:
80
-
81
- - πŸ“‚ Path to your OpenAPI/Swagger file (`.yaml` or `.json`)
82
- - πŸ“ Output directory for generated files
83
- - πŸ”§ Which generation engine to use (`official` or `heyapi`)
84
- - βœ… Which composables to generate (`useFetch`, `useAsyncData`, `Nuxt server routes`)
85
-
86
- Or pass arguments directly:
87
-
88
- ```bash
89
- nxh generate -i ./swagger.yaml -o ./api
90
- ```
91
-
92
- ### 2. Generated output
93
-
94
- ```
95
- api/
96
- +-- runtime.ts
97
- +-- apis/
98
- β”‚ +-- PetApi.ts
99
- β”‚ +-- StoreApi.ts
100
- +-- models/
101
- β”‚ +-- Pet.ts
102
- β”‚ +-- Order.ts
103
- +-- composables/
104
- +-- use-fetch/
105
- +-- runtime/
106
- β”‚ +-- useApiRequest.ts
107
- +-- composables/
108
- β”‚ +-- useFetchGetPetById.ts
109
- β”‚ +-- useFetchAddPet.ts
110
- +-- index.ts
111
- ```
112
-
113
- ### 3. Configure the API base URL
114
-
115
- Add to `nuxt.config.ts`:
116
-
117
- ```typescript
118
- export default defineNuxtConfig({
119
- runtimeConfig: {
120
- public: {
121
- apiBaseUrl: process.env.NUXT_PUBLIC_API_BASE_URL || 'https://api.example.com'
122
- }
123
- }
124
- })
125
- ```
126
-
127
- And in `.env`:
128
-
129
- ```env
130
- NUXT_PUBLIC_API_BASE_URL=https://api.example.com
131
- ```
132
-
133
- All generated `useFetch` and `useAsyncData` composables will automatically use this as `baseURL`. You can still override it per-composable via `options.baseURL`.
134
-
135
- ### 4. Use in your Nuxt app
136
-
137
- ```vue
138
- <script setup lang="ts">
139
- import { useFetchGetPetById } from '@/api/composables/use-fetch';
140
-
141
- const { data: pet, pending, error } = useFetchGetPetById(
142
- { petId: 123 },
143
- {
144
- onSuccess: (pet) => console.log('Loaded:', pet.name),
145
- onError: (err) => console.error('Failed:', err),
146
- }
147
- );
148
- </script>
149
-
150
- <template>
151
- <div>
152
- <div v-if="pending">Loading...</div>
153
- <div v-else-if="error">Error: {{ error }}</div>
154
- <div v-else-if="pet">{{ pet.name }} β€” {{ pet.status }}</div>
155
- </div>
156
- </template>
157
- ```
158
-
159
- ---
160
-
161
- ## πŸ–₯️ Nuxt Server Routes Generator
162
-
163
- In addition to client-side composables, you can generate **Nuxt Server Routes** that proxy requests to your backend APIβ€”keeping API keys and secrets server-side.
164
-
165
- ```
166
- Client β†’ Nuxt Server Route (generated) β†’ External API
167
- ```
168
-
169
- After generation, configure your backend URL in `.env`:
170
-
171
- ```env
172
- API_BASE_URL=https://your-backend-api.com/api
173
- API_SECRET=your-secret-token
174
- ```
175
-
176
- And add it to `nuxt.config.ts`:
177
-
178
- ```typescript
179
- export default defineNuxtConfig({
180
- runtimeConfig: {
181
- // Private β€” server-side only (never exposed to the browser)
182
- apiBaseUrl: process.env.API_BASE_URL || '',
183
- apiSecret: process.env.API_SECRET || '',
184
- },
185
- });
186
- ```
187
-
188
- > **Note:** `runtimeConfig.apiBaseUrl` (private) is only for **Server Routes**. For `useFetch`/`useAsyncData` composables use `runtimeConfig.public.apiBaseUrl` instead β€” see the [Quick Start](#-quick-start) section above.
189
-
190
- Then use standard `useFetch` against your Nuxt routes:
191
-
192
- ```typescript
193
- const { data: pet } = useFetch('/api/pet/123');
194
- ```
195
-
196
- > **BFF (Backend for Frontend) mode** is also available β€” generates a transformer layer for auth context, data enrichment, and permission filtering without ever overwriting your custom code. See the [Server Routes Guide](./docs/DEVELOPMENT.md) for details.
197
-
198
- ---
199
-
200
- ## πŸ“š Documentation
201
-
202
- | Guide | Description |
203
- |-------|-------------|
204
- | [Quick Start Guide](./docs/QUICK-START.md) | Understand the project in 5 minutes |
205
- | [Architecture](./docs/ARCHITECTURE.md) | Design patterns, two-stage generation, shared code |
206
- | [API Reference](./docs/API-REFERENCE.md) | All CLI options, TypeScript types, composable APIs |
207
- | [Development Guide](./docs/DEVELOPMENT.md) | Contributing, adding generators, code style |
208
- | [Troubleshooting](./docs/TROUBLESHOOTING.md) | Common errors and solutions |
209
-
210
- ---
211
-
212
- ## 🀝 Contributing
213
-
214
- Contributions are welcome! Please read the [Contributing Guidelines](./CONTRIBUTING.md) before submitting a PR.
215
-
216
- ```bash
217
- # Development setup
218
- npm install
219
- npm run build
220
- npm run validate # lint + type check
221
- ```
222
-
223
- ---
224
-
225
- ## πŸ“„ License
226
-
227
- Apache-2.0 β€” see [LICENSE](./LICENSE) for details.
228
-
229
- ---
230
-
231
- **Made with ❀️ for Nuxt developers**
1
+ ο»Ώ# πŸš€ Nuxt OpenAPI Generator
2
+
3
+ **Generate type-safe, SSR-compatible Nuxt composables from OpenAPI/Swagger specifications.**
4
+
5
+ πŸ“– **[Full documentation β†’ nuxt-openapi-hyperfetch.netlify.app](https://nuxt-openapi-hyperfetch.netlify.app/)**
6
+
7
+ ---
8
+
9
+ Transform your API documentation into production-ready **100% Nuxt-native** codeβ€”`useFetch` composables, `useAsyncData` composables, and Nuxt Server Routesβ€”with full TypeScript support, lifecycle callbacks, and request interception. No third-party runtime, no wrappers: just Nuxt.
10
+
11
+ ---
12
+
13
+ ## ✨ Features
14
+
15
+ - πŸ”’ **Type-Safe**: Full TypeScript support derived from your OpenAPI schema
16
+ - ⚑ **SSR Compatible**: Works seamlessly with Nuxt server-side rendering
17
+ - πŸ”„ **Lifecycle Callbacks**: `onRequest`, `onSuccess`, `onError`, `onFinish`
18
+ - 🌐 **Global Callbacks Plugin**: Define callbacks once, apply to all requests
19
+ - πŸ›‘οΈ **Request Interception**: Modify headers, body, and query params before sending
20
+ - 🎯 **Smart Data Selection**: Pick specific fields with dot notation for nested paths
21
+ - πŸ€– **Auto Type Inference**: Transform response data with automatic TypeScript type inference
22
+ - ⚑ **Automatic Generation**: Single command generates all composables and server routes
23
+ - πŸ’š **100% Nuxt Native**: Generated composables use `useFetch` / `useAsyncData`; server routes use `defineEventHandler` β€” no third-party runtime required
24
+ - πŸ“¦ **Zero Runtime Dependencies**: Generated code only uses Nuxt built-ins
25
+ - πŸ’‘ **Developer Experience**: Interactive CLI with smart defaults
26
+
27
+ ---
28
+
29
+ ## πŸ”§ Generator Engines
30
+
31
+ Two generation engines are available. The CLI will ask you to choose one when running `nxh generate`:
32
+
33
+ | Engine | Tool | Node Native | Best for |
34
+ |--------|------|:---:|----------|
35
+ | **official** | [@openapitools/openapi-generator-cli](https://openapi-generator.tech/) | ❌ Requires Java 11+ | Maximum spec compatibility, enterprise projects |
36
+ | **heyapi** | [@hey-api/openapi-ts](https://heyapi.dev/) | βœ… Yes | Quick setup, CI/CD pipelines, Node-only environments |
37
+
38
+ > The CLI checks for Java automatically when `official` is selected and aborts with an install link if it is not found. Get Java at [adoptium.net](https://adoptium.net).
39
+
40
+ You can also pre-select the engine in your `nxh.config.js` β€” the CLI will skip the prompt entirely:
41
+
42
+ ```js
43
+ // nxh.config.js
44
+ export default {
45
+ generator: 'openapi', // 'openapi' | 'heyapi'
46
+ input: './swagger.yaml',
47
+ output: './api',
48
+ };
49
+ ```
50
+
51
+ ---
52
+
53
+ ## πŸ“¦ Installation
54
+
55
+ ```bash
56
+ npm install -g nuxt-openapi-hyperfetch
57
+ # or
58
+ yarn global add nuxt-openapi-hyperfetch
59
+ # or
60
+ pnpm add -g nuxt-openapi-hyperfetch
61
+ ```
62
+
63
+ Or use directly with npx:
64
+
65
+ ```bash
66
+ npx nuxt-openapi-hyperfetch generate
67
+ ```
68
+
69
+ ---
70
+
71
+ ## πŸš€ Quick Start
72
+
73
+ ### 1. Run the generator
74
+
75
+ ```bash
76
+ nxh generate
77
+ ```
78
+
79
+ The CLI will ask you for:
80
+
81
+ - πŸ“‚ Path to your OpenAPI/Swagger file (`.yaml` or `.json`)
82
+ - πŸ“ Output directory for generated files
83
+ - πŸ”§ Which generation engine to use (`official` or `heyapi`)
84
+ - βœ… Which composables to generate (`useFetch`, `useAsyncData`, `Nuxt server routes`)
85
+
86
+ Or pass arguments directly:
87
+
88
+ ```bash
89
+ nxh generate -i ./swagger.yaml -o ./api
90
+ ```
91
+
92
+ ### 2. Generated output
93
+
94
+ ```
95
+ api/
96
+ +-- runtime.ts
97
+ +-- apis/
98
+ β”‚ +-- PetApi.ts
99
+ β”‚ +-- StoreApi.ts
100
+ +-- models/
101
+ β”‚ +-- Pet.ts
102
+ β”‚ +-- Order.ts
103
+ +-- composables/
104
+ +-- use-fetch/
105
+ +-- runtime/
106
+ β”‚ +-- useApiRequest.ts
107
+ +-- composables/
108
+ β”‚ +-- useFetchGetPetById.ts
109
+ β”‚ +-- useFetchAddPet.ts
110
+ +-- index.ts
111
+ ```
112
+
113
+ ### 3. Configure the API base URL
114
+
115
+ Add to `nuxt.config.ts`:
116
+
117
+ ```typescript
118
+ export default defineNuxtConfig({
119
+ runtimeConfig: {
120
+ public: {
121
+ apiBaseUrl: process.env.NUXT_PUBLIC_API_BASE_URL || 'https://api.example.com'
122
+ }
123
+ }
124
+ })
125
+ ```
126
+
127
+ And in `.env`:
128
+
129
+ ```env
130
+ NUXT_PUBLIC_API_BASE_URL=https://api.example.com
131
+ ```
132
+
133
+ All generated `useFetch` and `useAsyncData` composables will automatically use this as `baseURL`. You can still override it per-composable via `options.baseURL`.
134
+
135
+ ### 4. Use in your Nuxt app
136
+
137
+ ```vue
138
+ <script setup lang="ts">
139
+ import { useFetchGetPetById } from '@/api/composables/use-fetch';
140
+
141
+ const { data: pet, pending, error } = useFetchGetPetById(
142
+ { petId: 123 },
143
+ {
144
+ onSuccess: (pet) => console.log('Loaded:', pet.name),
145
+ onError: (err) => console.error('Failed:', err),
146
+ }
147
+ );
148
+ </script>
149
+
150
+ <template>
151
+ <div>
152
+ <div v-if="pending">Loading...</div>
153
+ <div v-else-if="error">Error: {{ error }}</div>
154
+ <div v-else-if="pet">{{ pet.name }} β€” {{ pet.status }}</div>
155
+ </div>
156
+ </template>
157
+ ```
158
+
159
+ ---
160
+
161
+ ## πŸ–₯️ Nuxt Server Routes Generator
162
+
163
+ In addition to client-side composables, you can generate **Nuxt Server Routes** that proxy requests to your backend APIβ€”keeping API keys and secrets server-side.
164
+
165
+ ```
166
+ Client β†’ Nuxt Server Route (generated) β†’ External API
167
+ ```
168
+
169
+ After generation, configure your backend URL in `.env`:
170
+
171
+ ```env
172
+ API_BASE_URL=https://your-backend-api.com/api
173
+ API_SECRET=your-secret-token
174
+ ```
175
+
176
+ And add it to `nuxt.config.ts`:
177
+
178
+ ```typescript
179
+ export default defineNuxtConfig({
180
+ runtimeConfig: {
181
+ // Private β€” server-side only (never exposed to the browser)
182
+ apiBaseUrl: process.env.API_BASE_URL || '',
183
+ apiSecret: process.env.API_SECRET || '',
184
+ },
185
+ });
186
+ ```
187
+
188
+ > **Note:** `runtimeConfig.apiBaseUrl` (private) is only for **Server Routes**. For `useFetch`/`useAsyncData` composables use `runtimeConfig.public.apiBaseUrl` instead β€” see the [Quick Start](#-quick-start) section above.
189
+
190
+ Then use standard `useFetch` against your Nuxt routes:
191
+
192
+ ```typescript
193
+ const { data: pet } = useFetch('/api/pet/123');
194
+ ```
195
+
196
+ > **BFF (Backend for Frontend) mode** is also available β€” generates a transformer layer for auth context, data enrichment, and permission filtering without ever overwriting your custom code. See the [Server Routes Guide](./docs/DEVELOPMENT.md) for details.
197
+
198
+ ---
199
+
200
+ ## πŸ“š Documentation
201
+
202
+ | Guide | Description |
203
+ |-------|-------------|
204
+ | [Quick Start Guide](./docs/QUICK-START.md) | Understand the project in 5 minutes |
205
+ | [Architecture](./docs/ARCHITECTURE.md) | Design patterns, two-stage generation, shared code |
206
+ | [API Reference](./docs/API-REFERENCE.md) | All CLI options, TypeScript types, composable APIs |
207
+ | [Development Guide](./docs/DEVELOPMENT.md) | Contributing, adding generators, code style |
208
+ | [Troubleshooting](./docs/TROUBLESHOOTING.md) | Common errors and solutions |
209
+
210
+ ---
211
+
212
+ ## 🀝 Contributing
213
+
214
+ Contributions are welcome! Please read the [Contributing Guidelines](./CONTRIBUTING.md) before submitting a PR.
215
+
216
+ ```bash
217
+ # Development setup
218
+ npm install
219
+ npm run build
220
+ npm run validate # lint + type check
221
+ ```
222
+
223
+ ---
224
+
225
+ ## πŸ“„ License
226
+
227
+ Apache-2.0 β€” see [LICENSE](./LICENSE) for details.
228
+
229
+ ---
230
+
231
+ **Made with ❀️ for Nuxt developers**
@@ -24,7 +24,7 @@ export interface GeneratorConfig {
24
24
  /** Watch mode - regenerate on file changes */
25
25
  watch?: boolean;
26
26
  /** Generator types to use */
27
- generators?: ('useFetch' | 'useAsyncData' | 'nuxtServer')[];
27
+ generators?: ('useFetch' | 'useAsyncData' | 'nuxtServer' | 'connectors')[];
28
28
  /** Server route path (for nuxtServer mode) */
29
29
  serverRoutePath?: string;
30
30
  /** Enable BFF pattern (for nuxtServer mode) */
@@ -38,6 +38,13 @@ export interface GeneratorConfig {
38
38
  * When set, the CLI will not ask which engine to use.
39
39
  */
40
40
  generator?: ConfigGenerator;
41
+ /**
42
+ * Generate headless UI connector composables on top of useAsyncData.
43
+ * Connectors provide ready-made logic for tables, pagination, forms and delete actions.
44
+ * Requires useAsyncData to also be generated.
45
+ * @default false
46
+ */
47
+ createUseAsyncDataConnectors?: boolean;
41
48
  }
42
49
  /**
43
50
  * Load configuration from nxh.config.js, nuxt-openapi-generator.config.js, or package.json
@@ -54,4 +61,4 @@ export declare function parseTags(tagsString?: string): string[] | undefined;
54
61
  /**
55
62
  * Parse generators string into array
56
63
  */
57
- export declare function parseGenerators(generatorsString?: string): ('useFetch' | 'useAsyncData' | 'nuxtServer')[] | undefined;
64
+ export declare function parseGenerators(generatorsString?: string): ('useFetch' | 'useAsyncData' | 'nuxtServer' | 'connectors')[] | undefined;
@@ -81,5 +81,5 @@ export function parseGenerators(generatorsString) {
81
81
  return undefined;
82
82
  }
83
83
  const parts = generatorsString.split(',').map((g) => g.trim());
84
- return parts.filter((g) => ['useFetch', 'useAsyncData', 'nuxtServer'].includes(g));
84
+ return parts.filter((g) => ['useFetch', 'useAsyncData', 'nuxtServer', 'connectors'].includes(g));
85
85
  }
package/dist/cli/logo.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import gradient from 'gradient-string';
2
- const NUXT_LOGO = `β–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•—β–ˆβ–ˆβ•— β–ˆβ–ˆβ•—β–ˆβ–ˆβ•— β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
3
- β–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•šβ•β•β–ˆβ–ˆβ•”β•β•β•
4
- β–ˆβ–ˆβ•”β–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β•šβ–ˆβ–ˆβ–ˆβ•”β• β–ˆβ–ˆβ•‘
5
- β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•”β–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘
6
- β–ˆβ–ˆβ•‘ β•šβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•”β• β–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘
2
+ const NUXT_LOGO = `β–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•—β–ˆβ–ˆβ•— β–ˆβ–ˆβ•—β–ˆβ–ˆβ•— β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
3
+ β–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•šβ•β•β–ˆβ–ˆβ•”β•β•β•
4
+ β–ˆβ–ˆβ•”β–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β•šβ–ˆβ–ˆβ–ˆβ•”β• β–ˆβ–ˆβ•‘
5
+ β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•”β–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘
6
+ β–ˆβ–ˆβ•‘ β•šβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•”β• β–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘
7
7
  β•šβ•β• β•šβ•β•β•β• β•šβ•β•β•β•β•β• β•šβ•β• β•šβ•β• β•šβ•β•`;
8
8
  const SUBTITLE = 'Nuxt OpenAPI Generator - useFetch, useAsyncData & Nuxt server';
9
9
  /**
@@ -43,6 +43,7 @@ export declare const CHOICES: {
43
43
  label: string;
44
44
  hint?: undefined;
45
45
  })[];
46
+ connectorsPrompt: string;
46
47
  serverPaths: ({
47
48
  value: string;
48
49
  label: string;
@@ -57,6 +57,8 @@ export const CHOICES = {
57
57
  label: 'Nuxt Server Routes - Generate server/api/* proxy routes',
58
58
  },
59
59
  ],
60
+ // Connectors prompt (shown only when useAsyncData is selected)
61
+ connectorsPrompt: 'Generate headless UI connectors? (tables, pagination, forms & delete logic built on top of useAsyncData)',
60
62
  // Server path options
61
63
  serverPaths: [
62
64
  {
@@ -28,3 +28,8 @@ export declare function promptServerRoutePath(): Promise<string>;
28
28
  * Returns whether BFF should be enabled
29
29
  */
30
30
  export declare function promptBffConfig(): Promise<BffConfig>;
31
+ /**
32
+ * Ask whether to generate headless UI connectors on top of useAsyncData.
33
+ * Only called when useAsyncData was selected and no config value is present.
34
+ */
35
+ export declare function promptConnectors(): Promise<boolean>;
@@ -116,3 +116,15 @@ export async function promptBffConfig() {
116
116
  checkCancellation(result);
117
117
  return { enableBff: result };
118
118
  }
119
+ /**
120
+ * Ask whether to generate headless UI connectors on top of useAsyncData.
121
+ * Only called when useAsyncData was selected and no config value is present.
122
+ */
123
+ export async function promptConnectors() {
124
+ const result = await p.confirm({
125
+ message: CHOICES.connectorsPrompt,
126
+ initialValue: false,
127
+ });
128
+ checkCancellation(result);
129
+ return result;
130
+ }
@@ -40,4 +40,4 @@ export interface BffConfig {
40
40
  /**
41
41
  * Valid composable types
42
42
  */
43
- export type ComposableType = 'useFetch' | 'useAsyncData' | 'nuxtServer';
43
+ export type ComposableType = 'useFetch' | 'useAsyncData' | 'nuxtServer' | 'connectors';
@@ -1,18 +1,18 @@
1
1
  import { pascalCase, kebabCase } from 'change-case';
2
2
  // ─── File header ──────────────────────────────────────────────────────────────
3
3
  function generateFileHeader() {
4
- return `/**
5
- * ⚠️ AUTO-GENERATED FILE - DO NOT EDIT MANUALLY
6
- *
7
- * This file was automatically generated by nuxt-openapi-generator.
8
- * Any manual changes will be overwritten on the next generation.
9
- *
10
- * @generated by nuxt-openapi-generator
11
- * @see https://github.com/dmartindiaz/nuxt-openapi-hyperfetch
12
- */
13
-
14
- /* eslint-disable */
15
- // @ts-nocheck
4
+ return `/**
5
+ * ⚠️ AUTO-GENERATED FILE - DO NOT EDIT MANUALLY
6
+ *
7
+ * This file was automatically generated by nuxt-openapi-generator.
8
+ * Any manual changes will be overwritten on the next generation.
9
+ *
10
+ * @generated by nuxt-openapi-generator
11
+ * @see https://github.com/dmartindiaz/nuxt-openapi-hyperfetch
12
+ */
13
+
14
+ /* eslint-disable */
15
+ // @ts-nocheck
16
16
  `;
17
17
  }
18
18
  // ─── Naming helpers ───────────────────────────────────────────────────────────
@@ -2,18 +2,18 @@
2
2
  * Generate file header with auto-generation warning
3
3
  */
4
4
  function generateFileHeader() {
5
- return `/**
6
- * ⚠️ AUTO-GENERATED FILE - DO NOT EDIT MANUALLY
7
- *
8
- * This file was automatically generated by nuxt-openapi-generator.
9
- * Any manual changes will be overwritten on the next generation.
10
- *
11
- * @generated by nuxt-openapi-generator
12
- * @see https://github.com/dmartindiaz/nuxt-openapi-hyperfetch
13
- */
14
-
15
- /* eslint-disable */
16
- // @ts-nocheck
5
+ return `/**
6
+ * ⚠️ AUTO-GENERATED FILE - DO NOT EDIT MANUALLY
7
+ *
8
+ * This file was automatically generated by nuxt-openapi-generator.
9
+ * Any manual changes will be overwritten on the next generation.
10
+ *
11
+ * @generated by nuxt-openapi-generator
12
+ * @see https://github.com/dmartindiaz/nuxt-openapi-hyperfetch
13
+ */
14
+
15
+ /* eslint-disable */
16
+ // @ts-nocheck
17
17
  `;
18
18
  }
19
19
  /**
@@ -120,11 +120,11 @@ function generateFunctionBody(method, isRaw, generateOptions) {
120
120
  const argsExtraction = hasParams
121
121
  ? ` const _hasKey = typeof args[0] === 'string'\n const params = _hasKey ? args[1] : args[0]\n const options = _hasKey ? { cacheKey: args[0], ...args[2] } : args[1]`
122
122
  : ` const _hasKey = typeof args[0] === 'string'\n const options = _hasKey ? { cacheKey: args[0], ...args[1] } : args[0]`;
123
- return `${description}export function ${composableName}(key: string, ${args})
124
- export function ${composableName}(${args})
125
- export function ${composableName}(...args: any[]) {
126
- ${argsExtraction}${pInit}
127
- return ${wrapperFunction}${responseTypeGeneric}(${key}, ${url}, ${fetchOptions})
123
+ return `${description}export function ${composableName}(key: string, ${args})
124
+ export function ${composableName}(${args})
125
+ export function ${composableName}(...args: any[]) {
126
+ ${argsExtraction}${pInit}
127
+ return ${wrapperFunction}${responseTypeGeneric}(${key}, ${url}, ${fetchOptions})
128
128
  }`;
129
129
  }
130
130
  /**