nuxt-openapi-hyperfetch 0.1.7-alpha.1 → 0.2.7-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 (97) hide show
  1. package/CONTRIBUTING.md +291 -292
  2. package/INSTRUCTIONS.md +327 -327
  3. package/LICENSE +202 -202
  4. package/README.md +231 -227
  5. package/dist/cli/logger.d.ts +26 -0
  6. package/dist/cli/logger.js +36 -0
  7. package/dist/cli/logo.js +5 -5
  8. package/dist/generators/components/connector-generator/generator.d.ts +12 -0
  9. package/dist/generators/components/connector-generator/generator.js +116 -0
  10. package/dist/generators/components/connector-generator/templates.d.ts +18 -0
  11. package/dist/generators/components/connector-generator/templates.js +222 -0
  12. package/dist/generators/components/connector-generator/types.d.ts +32 -0
  13. package/dist/generators/components/connector-generator/types.js +7 -0
  14. package/dist/generators/components/schema-analyzer/index.d.ts +17 -0
  15. package/dist/generators/components/schema-analyzer/index.js +20 -0
  16. package/dist/generators/components/schema-analyzer/intent-detector.d.ts +17 -0
  17. package/dist/generators/components/schema-analyzer/intent-detector.js +143 -0
  18. package/dist/generators/components/schema-analyzer/openapi-reader.d.ts +11 -0
  19. package/dist/generators/components/schema-analyzer/openapi-reader.js +76 -0
  20. package/dist/generators/components/schema-analyzer/resource-grouper.d.ts +6 -0
  21. package/dist/generators/components/schema-analyzer/resource-grouper.js +132 -0
  22. package/dist/generators/components/schema-analyzer/schema-field-mapper.d.ts +35 -0
  23. package/dist/generators/components/schema-analyzer/schema-field-mapper.js +220 -0
  24. package/dist/generators/components/schema-analyzer/types.d.ts +156 -0
  25. package/dist/generators/components/schema-analyzer/types.js +7 -0
  26. package/dist/generators/nuxt-server/generator.d.ts +2 -1
  27. package/dist/generators/nuxt-server/generator.js +21 -21
  28. package/dist/generators/shared/runtime/apiHelpers.d.ts +81 -41
  29. package/dist/generators/shared/runtime/apiHelpers.js +97 -104
  30. package/dist/generators/shared/runtime/pagination.d.ts +168 -0
  31. package/dist/generators/shared/runtime/pagination.js +179 -0
  32. package/dist/generators/shared/runtime/useDeleteConnector.d.ts +16 -0
  33. package/dist/generators/shared/runtime/useDeleteConnector.js +93 -0
  34. package/dist/generators/shared/runtime/useDetailConnector.d.ts +14 -0
  35. package/dist/generators/shared/runtime/useDetailConnector.js +50 -0
  36. package/dist/generators/shared/runtime/useFormConnector.d.ts +19 -0
  37. package/dist/generators/shared/runtime/useFormConnector.js +113 -0
  38. package/dist/generators/shared/runtime/useListConnector.d.ts +25 -0
  39. package/dist/generators/shared/runtime/useListConnector.js +125 -0
  40. package/dist/generators/shared/runtime/zod-error-merger.d.ts +23 -0
  41. package/dist/generators/shared/runtime/zod-error-merger.js +106 -0
  42. package/dist/generators/shared/templates/api-callbacks-plugin.js +54 -11
  43. package/dist/generators/shared/templates/api-pagination-plugin.d.ts +51 -0
  44. package/dist/generators/shared/templates/api-pagination-plugin.js +152 -0
  45. package/dist/generators/use-async-data/generator.d.ts +2 -1
  46. package/dist/generators/use-async-data/generator.js +14 -14
  47. package/dist/generators/use-async-data/runtime/useApiAsyncData.js +114 -13
  48. package/dist/generators/use-async-data/runtime/useApiAsyncDataRaw.js +88 -10
  49. package/dist/generators/use-async-data/templates.js +17 -17
  50. package/dist/generators/use-fetch/generator.d.ts +2 -1
  51. package/dist/generators/use-fetch/generator.js +12 -12
  52. package/dist/generators/use-fetch/runtime/useApiRequest.js +149 -40
  53. package/dist/generators/use-fetch/templates.js +14 -14
  54. package/dist/index.js +25 -0
  55. package/dist/module/index.d.ts +4 -0
  56. package/dist/module/index.js +93 -0
  57. package/dist/module/types.d.ts +27 -0
  58. package/dist/module/types.js +1 -0
  59. package/docs/API-REFERENCE.md +886 -887
  60. package/docs/generated-components.md +615 -0
  61. package/docs/headless-composables-ui.md +569 -0
  62. package/eslint.config.js +13 -0
  63. package/package.json +29 -2
  64. package/src/cli/config.ts +140 -140
  65. package/src/cli/logger.ts +124 -66
  66. package/src/cli/logo.ts +25 -25
  67. package/src/cli/types.ts +50 -50
  68. package/src/generators/components/connector-generator/generator.ts +138 -0
  69. package/src/generators/components/connector-generator/templates.ts +254 -0
  70. package/src/generators/components/connector-generator/types.ts +34 -0
  71. package/src/generators/components/schema-analyzer/index.ts +44 -0
  72. package/src/generators/components/schema-analyzer/intent-detector.ts +187 -0
  73. package/src/generators/components/schema-analyzer/openapi-reader.ts +96 -0
  74. package/src/generators/components/schema-analyzer/resource-grouper.ts +166 -0
  75. package/src/generators/components/schema-analyzer/schema-field-mapper.ts +268 -0
  76. package/src/generators/components/schema-analyzer/types.ts +177 -0
  77. package/src/generators/nuxt-server/generator.ts +272 -270
  78. package/src/generators/shared/runtime/apiHelpers.ts +535 -507
  79. package/src/generators/shared/runtime/pagination.ts +323 -0
  80. package/src/generators/shared/runtime/useDeleteConnector.ts +109 -0
  81. package/src/generators/shared/runtime/useDetailConnector.ts +64 -0
  82. package/src/generators/shared/runtime/useFormConnector.ts +139 -0
  83. package/src/generators/shared/runtime/useListConnector.ts +148 -0
  84. package/src/generators/shared/runtime/zod-error-merger.ts +119 -0
  85. package/src/generators/shared/templates/api-callbacks-plugin.ts +399 -352
  86. package/src/generators/shared/templates/api-pagination-plugin.ts +158 -0
  87. package/src/generators/use-async-data/generator.ts +205 -204
  88. package/src/generators/use-async-data/runtime/useApiAsyncData.ts +329 -229
  89. package/src/generators/use-async-data/runtime/useApiAsyncDataRaw.ts +324 -245
  90. package/src/generators/use-async-data/templates.ts +257 -257
  91. package/src/generators/use-fetch/generator.ts +170 -169
  92. package/src/generators/use-fetch/runtime/useApiRequest.ts +354 -234
  93. package/src/generators/use-fetch/templates.ts +214 -214
  94. package/src/index.ts +303 -265
  95. package/src/module/index.ts +133 -0
  96. package/src/module/types.ts +31 -0
  97. package/src/generators/tanstack-query/generator.ts +0 -11
package/README.md CHANGED
@@ -1,227 +1,231 @@
1
- # 🚀 Nuxt OpenAPI Generator
2
-
3
- **Generate type-safe, SSR-compatible Nuxt composables from OpenAPI/Swagger specifications.**
4
-
5
- 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.
6
-
7
- ---
8
-
9
- ## Features
10
-
11
- - 🔒 **Type-Safe**: Full TypeScript support derived from your OpenAPI schema
12
- - ⚡ **SSR Compatible**: Works seamlessly with Nuxt server-side rendering
13
- - 🔄 **Lifecycle Callbacks**: `onRequest`, `onSuccess`, `onError`, `onFinish`
14
- - 🌐 **Global Callbacks Plugin**: Define callbacks once, apply to all requests
15
- - 🛡️ **Request Interception**: Modify headers, body, and query params before sending
16
- - 🎯 **Smart Data Selection**: Pick specific fields with dot notation for nested paths
17
- - 🤖 **Auto Type Inference**: Transform response data with automatic TypeScript type inference
18
- - **Automatic Generation**: Single command generates all composables and server routes
19
- - 💚 **100% Nuxt Native**: Generated composables use `useFetch` / `useAsyncData`; server routes use `defineEventHandler` — no third-party runtime required
20
- - 📦 **Zero Runtime Dependencies**: Generated code only uses Nuxt built-ins
21
- - 💡 **Developer Experience**: Interactive CLI with smart defaults
22
-
23
- ---
24
-
25
- ## 🔧 Generator Engines
26
-
27
- Two generation engines are available. The CLI will ask you to choose one when running `nxh generate`:
28
-
29
- | Engine | Tool | Node Native | Best for |
30
- |--------|------|:---:|----------|
31
- | **official** | [@openapitools/openapi-generator-cli](https://openapi-generator.tech/) | Requires Java 11+ | Maximum spec compatibility, enterprise projects |
32
- | **heyapi** | [@hey-api/openapi-ts](https://heyapi.dev/) | ✅ Yes | Quick setup, CI/CD pipelines, Node-only environments |
33
-
34
- > 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).
35
-
36
- You can also pre-select the engine in your `nxh.config.js` the CLI will skip the prompt entirely:
37
-
38
- ```js
39
- // nxh.config.js
40
- export default {
41
- generator: 'openapi', // 'openapi' | 'heyapi'
42
- input: './swagger.yaml',
43
- output: './api',
44
- };
45
- ```
46
-
47
- ---
48
-
49
- ## 📦 Installation
50
-
51
- ```bash
52
- npm install -g nuxt-openapi-hyperfetch
53
- # or
54
- yarn global add nuxt-openapi-hyperfetch
55
- # or
56
- pnpm add -g nuxt-openapi-hyperfetch
57
- ```
58
-
59
- Or use directly with npx:
60
-
61
- ```bash
62
- npx nuxt-openapi-hyperfetch generate
63
- ```
64
-
65
- ---
66
-
67
- ## 🚀 Quick Start
68
-
69
- ### 1. Run the generator
70
-
71
- ```bash
72
- nxh generate
73
- ```
74
-
75
- The CLI will ask you for:
76
-
77
- - 📂 Path to your OpenAPI/Swagger file (`.yaml` or `.json`)
78
- - 📁 Output directory for generated files
79
- - 🔧 Which generation engine to use (`official` or `heyapi`)
80
- - ✅ Which composables to generate (`useFetch`, `useAsyncData`, `TanStack Query`, or Nuxt Server Routes)
81
-
82
- Or pass arguments directly:
83
-
84
- ```bash
85
- nxh generate -i ./swagger.yaml -o ./api
86
- ```
87
-
88
- ### 2. Generated output
89
-
90
- ```
91
- api/
92
- +-- runtime.ts
93
- +-- apis/
94
- │ +-- PetApi.ts
95
- │ +-- StoreApi.ts
96
- +-- models/
97
- +-- Pet.ts
98
- │ +-- Order.ts
99
- +-- composables/
100
- +-- use-fetch/
101
- +-- runtime/
102
- │ +-- useApiRequest.ts
103
- +-- composables/
104
- +-- useFetchGetPetById.ts
105
- +-- useFetchAddPet.ts
106
- +-- index.ts
107
- ```
108
-
109
- ### 3. Configure the API base URL
110
-
111
- Add to `nuxt.config.ts`:
112
-
113
- ```typescript
114
- export default defineNuxtConfig({
115
- runtimeConfig: {
116
- public: {
117
- apiBaseUrl: process.env.NUXT_PUBLIC_API_BASE_URL || 'https://api.example.com'
118
- }
119
- }
120
- })
121
- ```
122
-
123
- And in `.env`:
124
-
125
- ```env
126
- NUXT_PUBLIC_API_BASE_URL=https://api.example.com
127
- ```
128
-
129
- All generated `useFetch` and `useAsyncData` composables will automatically use this as `baseURL`. You can still override it per-composable via `options.baseURL`.
130
-
131
- ### 4. Use in your Nuxt app
132
-
133
- ```vue
134
- <script setup lang="ts">
135
- import { useFetchGetPetById } from '@/api/composables/use-fetch';
136
-
137
- const { data: pet, pending, error } = useFetchGetPetById(
138
- { petId: 123 },
139
- {
140
- onSuccess: (pet) => console.log('Loaded:', pet.name),
141
- onError: (err) => console.error('Failed:', err),
142
- }
143
- );
144
- </script>
145
-
146
- <template>
147
- <div>
148
- <div v-if="pending">Loading...</div>
149
- <div v-else-if="error">Error: {{ error }}</div>
150
- <div v-else-if="pet">{{ pet.name }} — {{ pet.status }}</div>
151
- </div>
152
- </template>
153
- ```
154
-
155
- ---
156
-
157
- ## 🖥️ Nuxt Server Routes Generator
158
-
159
- 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.
160
-
161
- ```
162
- Client → Nuxt Server Route (generated) → External API
163
- ```
164
-
165
- After generation, configure your backend URL in `.env`:
166
-
167
- ```env
168
- API_BASE_URL=https://your-backend-api.com/api
169
- API_SECRET=your-secret-token
170
- ```
171
-
172
- And add it to `nuxt.config.ts`:
173
-
174
- ```typescript
175
- export default defineNuxtConfig({
176
- runtimeConfig: {
177
- // Private — server-side only (never exposed to the browser)
178
- apiBaseUrl: process.env.API_BASE_URL || '',
179
- apiSecret: process.env.API_SECRET || '',
180
- },
181
- });
182
- ```
183
-
184
- > **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.
185
-
186
- Then use standard `useFetch` against your Nuxt routes:
187
-
188
- ```typescript
189
- const { data: pet } = useFetch('/api/pet/123');
190
- ```
191
-
192
- > **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.
193
-
194
- ---
195
-
196
- ## 📚 Documentation
197
-
198
- | Guide | Description |
199
- |-------|-------------|
200
- | [Quick Start Guide](./docs/QUICK-START.md) | Understand the project in 5 minutes |
201
- | [Architecture](./docs/ARCHITECTURE.md) | Design patterns, two-stage generation, shared code |
202
- | [API Reference](./docs/API-REFERENCE.md) | All CLI options, TypeScript types, composable APIs |
203
- | [Development Guide](./docs/DEVELOPMENT.md) | Contributing, adding generators, code style |
204
- | [Troubleshooting](./docs/TROUBLESHOOTING.md) | Common errors and solutions |
205
-
206
- ---
207
-
208
- ## 🤝 Contributing
209
-
210
- Contributions are welcome! Please read the [Contributing Guidelines](./CONTRIBUTING.md) before submitting a PR.
211
-
212
- ```bash
213
- # Development setup
214
- npm install
215
- npm run build
216
- npm run validate # lint + type check
217
- ```
218
-
219
- ---
220
-
221
- ## 📄 License
222
-
223
- Apache-2.0 — see [LICENSE](./LICENSE) for details.
224
-
225
- ---
226
-
227
- **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**
@@ -42,3 +42,29 @@ export declare function logNote(message: string, title?: string): void;
42
42
  * Display section separator
43
43
  */
44
44
  export declare function logStep(message: string): void;
45
+ /**
46
+ * Abstract logger interface used by generators.
47
+ * Decouples generator output from @clack/prompts so the same generators work
48
+ * in the interactive CLI and in the Nuxt module (where clack is irrelevant).
49
+ */
50
+ export interface Logger {
51
+ spinner(): {
52
+ start(msg: string): void;
53
+ stop(msg: string): void;
54
+ };
55
+ log: {
56
+ warn(msg: string): void;
57
+ info(msg: string): void;
58
+ success(msg: string): void;
59
+ error(msg: string): void;
60
+ };
61
+ note(msg: string, title?: string): void;
62
+ }
63
+ /**
64
+ * Creates a Logger backed by @clack/prompts — used by the CLI.
65
+ */
66
+ export declare function createClackLogger(): Logger;
67
+ /**
68
+ * Creates a Logger backed by console — used by the Nuxt module.
69
+ */
70
+ export declare function createConsoleLogger(): Logger;
@@ -56,3 +56,39 @@ export function logNote(message, title) {
56
56
  export function logStep(message) {
57
57
  p.log.step(message);
58
58
  }
59
+ /**
60
+ * Creates a Logger backed by @clack/prompts — used by the CLI.
61
+ */
62
+ export function createClackLogger() {
63
+ return {
64
+ spinner: () => p.spinner(),
65
+ log: {
66
+ warn: (msg) => p.log.warn(msg),
67
+ info: (msg) => p.log.info(msg),
68
+ success: (msg) => p.log.success(msg),
69
+ error: (msg) => p.log.error(msg),
70
+ },
71
+ note: (msg, title) => p.note(msg, title),
72
+ };
73
+ }
74
+ /**
75
+ * Creates a Logger backed by console — used by the Nuxt module.
76
+ */
77
+ export function createConsoleLogger() {
78
+ const prefix = '[nuxt-openapi-hyperfetch]';
79
+ return {
80
+ spinner() {
81
+ return {
82
+ start: (msg) => console.log(`${prefix} ⏳ ${msg}`),
83
+ stop: (msg) => console.log(`${prefix} ✓ ${msg}`),
84
+ };
85
+ },
86
+ log: {
87
+ warn: (msg) => console.warn(`${prefix} ⚠ ${msg}`),
88
+ info: (msg) => console.info(`${prefix} ℹ ${msg}`),
89
+ success: (msg) => console.log(`${prefix} ✓ ${msg}`),
90
+ error: (msg) => console.error(`${prefix} ✗ ${msg}`),
91
+ },
92
+ note: (msg, title) => console.log(title ? `\n${prefix} ${title}:\n${msg}\n` : `\n${msg}\n`),
93
+ };
94
+ }
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
  /**
@@ -0,0 +1,12 @@
1
+ import type { ConnectorGeneratorOptions } from './types.js';
2
+ import { type Logger } from '../../../cli/logger.js';
3
+ /**
4
+ * Generate headless connector composables from an OpenAPI spec.
5
+ *
6
+ * Steps:
7
+ * 1. Analyze the spec → ResourceMap (Schema Analyzer)
8
+ * 2. For each resource: generate connector source, format, write
9
+ * 3. Write an index barrel file
10
+ * 4. Copy runtime helpers to the user's project
11
+ */
12
+ export declare function generateConnectors(options: ConnectorGeneratorOptions, logger?: Logger): Promise<void>;