nuxt-openapi-hyperfetch 0.1.6-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.
- package/CONTRIBUTING.md +291 -292
- package/INSTRUCTIONS.md +327 -327
- package/LICENSE +202 -202
- package/README.md +231 -227
- package/dist/cli/logger.d.ts +26 -0
- package/dist/cli/logger.js +36 -0
- package/dist/cli/logo.js +6 -6
- package/dist/generators/components/connector-generator/generator.d.ts +12 -0
- package/dist/generators/components/connector-generator/generator.js +116 -0
- package/dist/generators/components/connector-generator/templates.d.ts +18 -0
- package/dist/generators/components/connector-generator/templates.js +222 -0
- package/dist/generators/components/connector-generator/types.d.ts +32 -0
- package/dist/generators/components/connector-generator/types.js +7 -0
- package/dist/generators/components/schema-analyzer/index.d.ts +17 -0
- package/dist/generators/components/schema-analyzer/index.js +20 -0
- package/dist/generators/components/schema-analyzer/intent-detector.d.ts +17 -0
- package/dist/generators/components/schema-analyzer/intent-detector.js +143 -0
- package/dist/generators/components/schema-analyzer/openapi-reader.d.ts +11 -0
- package/dist/generators/components/schema-analyzer/openapi-reader.js +76 -0
- package/dist/generators/components/schema-analyzer/resource-grouper.d.ts +6 -0
- package/dist/generators/components/schema-analyzer/resource-grouper.js +132 -0
- package/dist/generators/components/schema-analyzer/schema-field-mapper.d.ts +35 -0
- package/dist/generators/components/schema-analyzer/schema-field-mapper.js +220 -0
- package/dist/generators/components/schema-analyzer/types.d.ts +156 -0
- package/dist/generators/components/schema-analyzer/types.js +7 -0
- package/dist/generators/nuxt-server/generator.d.ts +2 -1
- package/dist/generators/nuxt-server/generator.js +21 -21
- package/dist/generators/shared/runtime/apiHelpers.d.ts +98 -41
- package/dist/generators/shared/runtime/apiHelpers.js +97 -104
- package/dist/generators/shared/runtime/pagination.d.ts +168 -0
- package/dist/generators/shared/runtime/pagination.js +179 -0
- package/dist/generators/shared/runtime/useDeleteConnector.d.ts +16 -0
- package/dist/generators/shared/runtime/useDeleteConnector.js +93 -0
- package/dist/generators/shared/runtime/useDetailConnector.d.ts +14 -0
- package/dist/generators/shared/runtime/useDetailConnector.js +50 -0
- package/dist/generators/shared/runtime/useFormConnector.d.ts +19 -0
- package/dist/generators/shared/runtime/useFormConnector.js +113 -0
- package/dist/generators/shared/runtime/useListConnector.d.ts +25 -0
- package/dist/generators/shared/runtime/useListConnector.js +125 -0
- package/dist/generators/shared/runtime/zod-error-merger.d.ts +23 -0
- package/dist/generators/shared/runtime/zod-error-merger.js +106 -0
- package/dist/generators/shared/templates/api-callbacks-plugin.js +54 -11
- package/dist/generators/shared/templates/api-pagination-plugin.d.ts +51 -0
- package/dist/generators/shared/templates/api-pagination-plugin.js +152 -0
- package/dist/generators/use-async-data/generator.d.ts +2 -1
- package/dist/generators/use-async-data/generator.js +14 -14
- package/dist/generators/use-async-data/runtime/useApiAsyncData.js +130 -17
- package/dist/generators/use-async-data/runtime/useApiAsyncDataRaw.js +103 -13
- package/dist/generators/use-async-data/templates.js +20 -14
- package/dist/generators/use-fetch/generator.d.ts +2 -1
- package/dist/generators/use-fetch/generator.js +12 -12
- package/dist/generators/use-fetch/runtime/useApiRequest.js +149 -40
- package/dist/generators/use-fetch/templates.js +14 -14
- package/dist/index.js +25 -0
- package/dist/module/index.d.ts +4 -0
- package/dist/module/index.js +93 -0
- package/dist/module/types.d.ts +27 -0
- package/dist/module/types.js +1 -0
- package/docs/API-REFERENCE.md +886 -887
- package/docs/generated-components.md +615 -0
- package/docs/headless-composables-ui.md +569 -0
- package/eslint.config.js +13 -0
- package/package.json +29 -2
- package/src/cli/config.ts +140 -140
- package/src/cli/logger.ts +124 -66
- package/src/cli/logo.ts +25 -25
- package/src/cli/types.ts +50 -50
- package/src/generators/components/connector-generator/generator.ts +138 -0
- package/src/generators/components/connector-generator/templates.ts +254 -0
- package/src/generators/components/connector-generator/types.ts +34 -0
- package/src/generators/components/schema-analyzer/index.ts +44 -0
- package/src/generators/components/schema-analyzer/intent-detector.ts +187 -0
- package/src/generators/components/schema-analyzer/openapi-reader.ts +96 -0
- package/src/generators/components/schema-analyzer/resource-grouper.ts +166 -0
- package/src/generators/components/schema-analyzer/schema-field-mapper.ts +268 -0
- package/src/generators/components/schema-analyzer/types.ts +177 -0
- package/src/generators/nuxt-server/generator.ts +272 -270
- package/src/generators/shared/runtime/apiHelpers.ts +535 -481
- package/src/generators/shared/runtime/pagination.ts +323 -0
- package/src/generators/shared/runtime/useDeleteConnector.ts +109 -0
- package/src/generators/shared/runtime/useDetailConnector.ts +64 -0
- package/src/generators/shared/runtime/useFormConnector.ts +139 -0
- package/src/generators/shared/runtime/useListConnector.ts +148 -0
- package/src/generators/shared/runtime/zod-error-merger.ts +119 -0
- package/src/generators/shared/templates/api-callbacks-plugin.ts +399 -352
- package/src/generators/shared/templates/api-pagination-plugin.ts +158 -0
- package/src/generators/use-async-data/generator.ts +205 -204
- package/src/generators/use-async-data/runtime/useApiAsyncData.ts +329 -214
- package/src/generators/use-async-data/runtime/useApiAsyncDataRaw.ts +324 -230
- package/src/generators/use-async-data/templates.ts +257 -250
- package/src/generators/use-fetch/generator.ts +170 -169
- package/src/generators/use-fetch/runtime/useApiRequest.ts +354 -234
- package/src/generators/use-fetch/templates.ts +214 -214
- package/src/index.ts +303 -265
- package/src/module/index.ts +133 -0
- package/src/module/types.ts +31 -0
- 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
|
-
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
+--
|
|
97
|
-
|
|
98
|
-
│ +--
|
|
99
|
-
+--
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
+--
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
|
203
|
-
|
|
204
|
-
| [
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
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**
|
package/dist/cli/logger.d.ts
CHANGED
|
@@ -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;
|
package/dist/cli/logger.js
CHANGED
|
@@ -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,11 +1,11 @@
|
|
|
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
|
-
const SUBTITLE = '
|
|
8
|
+
const SUBTITLE = 'Nuxt OpenAPI Generator - useFetch, useAsyncData & Nuxt server';
|
|
9
9
|
/**
|
|
10
10
|
* Display the Nuxt logo with gradient colors
|
|
11
11
|
* - Green gradient for Nuxt logo (official Nuxt color #00DC82)
|
|
@@ -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>;
|