nuxt-openapi-hyperfetch 0.1.0-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/.editorconfig +26 -0
- package/.prettierignore +17 -0
- package/.prettierrc.json +12 -0
- package/CONTRIBUTING.md +292 -0
- package/INSTRUCTIONS.md +327 -0
- package/LICENSE +202 -0
- package/README.md +202 -0
- package/dist/cli/config.d.ts +57 -0
- package/dist/cli/config.js +85 -0
- package/dist/cli/logger.d.ts +44 -0
- package/dist/cli/logger.js +58 -0
- package/dist/cli/logo.d.ts +6 -0
- package/dist/cli/logo.js +21 -0
- package/dist/cli/messages.d.ts +65 -0
- package/dist/cli/messages.js +86 -0
- package/dist/cli/prompts.d.ts +30 -0
- package/dist/cli/prompts.js +118 -0
- package/dist/cli/types.d.ts +43 -0
- package/dist/cli/types.js +4 -0
- package/dist/cli/utils.d.ts +26 -0
- package/dist/cli/utils.js +45 -0
- package/dist/generate.d.ts +6 -0
- package/dist/generate.js +48 -0
- package/dist/generators/nuxt-server/bff-templates.d.ts +25 -0
- package/dist/generators/nuxt-server/bff-templates.js +737 -0
- package/dist/generators/nuxt-server/generator.d.ts +7 -0
- package/dist/generators/nuxt-server/generator.js +206 -0
- package/dist/generators/nuxt-server/parser.d.ts +5 -0
- package/dist/generators/nuxt-server/parser.js +5 -0
- package/dist/generators/nuxt-server/templates.d.ts +35 -0
- package/dist/generators/nuxt-server/templates.js +412 -0
- package/dist/generators/nuxt-server/types.d.ts +5 -0
- package/dist/generators/nuxt-server/types.js +5 -0
- package/dist/generators/shared/parsers/heyapi-parser.d.ts +11 -0
- package/dist/generators/shared/parsers/heyapi-parser.js +248 -0
- package/dist/generators/shared/parsers/official-parser.d.ts +5 -0
- package/dist/generators/shared/parsers/official-parser.js +5 -0
- package/dist/generators/shared/runtime/apiHelpers.d.ts +183 -0
- package/dist/generators/shared/runtime/apiHelpers.js +268 -0
- package/dist/generators/shared/templates/api-callbacks-plugin.d.ts +178 -0
- package/dist/generators/shared/templates/api-callbacks-plugin.js +338 -0
- package/dist/generators/shared/types.d.ts +25 -0
- package/dist/generators/shared/types.js +4 -0
- package/dist/generators/tanstack-query/generator.d.ts +5 -0
- package/dist/generators/tanstack-query/generator.js +11 -0
- package/dist/generators/use-async-data/generator.d.ts +5 -0
- package/dist/generators/use-async-data/generator.js +156 -0
- package/dist/generators/use-async-data/parser.d.ts +5 -0
- package/dist/generators/use-async-data/parser.js +5 -0
- package/dist/generators/use-async-data/runtime/useApiAsyncData.d.ts +38 -0
- package/dist/generators/use-async-data/runtime/useApiAsyncData.js +122 -0
- package/dist/generators/use-async-data/runtime/useApiAsyncDataRaw.d.ts +54 -0
- package/dist/generators/use-async-data/runtime/useApiAsyncDataRaw.js +126 -0
- package/dist/generators/use-async-data/templates.d.ts +20 -0
- package/dist/generators/use-async-data/templates.js +191 -0
- package/dist/generators/use-async-data/types.d.ts +4 -0
- package/dist/generators/use-async-data/types.js +4 -0
- package/dist/generators/use-fetch/generator.d.ts +5 -0
- package/dist/generators/use-fetch/generator.js +131 -0
- package/dist/generators/use-fetch/parser.d.ts +9 -0
- package/dist/generators/use-fetch/parser.js +282 -0
- package/dist/generators/use-fetch/runtime/useApiRequest.d.ts +46 -0
- package/dist/generators/use-fetch/runtime/useApiRequest.js +158 -0
- package/dist/generators/use-fetch/templates.d.ts +16 -0
- package/dist/generators/use-fetch/templates.js +169 -0
- package/dist/generators/use-fetch/types.d.ts +5 -0
- package/dist/generators/use-fetch/types.js +5 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +213 -0
- package/docs/API-REFERENCE.md +887 -0
- package/docs/ARCHITECTURE.md +649 -0
- package/docs/DEVELOPMENT.md +918 -0
- package/docs/QUICK-START.md +323 -0
- package/docs/README.md +155 -0
- package/docs/TROUBLESHOOTING.md +881 -0
- package/eslint.config.js +72 -0
- package/package.json +65 -0
- package/src/cli/config.ts +140 -0
- package/src/cli/logger.ts +66 -0
- package/src/cli/logo.ts +25 -0
- package/src/cli/messages.ts +97 -0
- package/src/cli/prompts.ts +143 -0
- package/src/cli/types.ts +50 -0
- package/src/cli/utils.ts +49 -0
- package/src/generate.ts +57 -0
- package/src/generators/nuxt-server/bff-templates.ts +754 -0
- package/src/generators/nuxt-server/generator.ts +270 -0
- package/src/generators/nuxt-server/parser.ts +5 -0
- package/src/generators/nuxt-server/templates.ts +483 -0
- package/src/generators/nuxt-server/types.ts +5 -0
- package/src/generators/shared/parsers/heyapi-parser.ts +307 -0
- package/src/generators/shared/parsers/official-parser.ts +5 -0
- package/src/generators/shared/runtime/apiHelpers.ts +466 -0
- package/src/generators/shared/templates/api-callbacks-plugin.ts +352 -0
- package/src/generators/shared/types.ts +27 -0
- package/src/generators/tanstack-query/generator.ts +11 -0
- package/src/generators/use-async-data/generator.ts +204 -0
- package/src/generators/use-async-data/parser.ts +5 -0
- package/src/generators/use-async-data/runtime/useApiAsyncData.ts +220 -0
- package/src/generators/use-async-data/runtime/useApiAsyncDataRaw.ts +236 -0
- package/src/generators/use-async-data/templates.ts +250 -0
- package/src/generators/use-async-data/types.ts +4 -0
- package/src/generators/use-fetch/generator.ts +169 -0
- package/src/generators/use-fetch/parser.ts +341 -0
- package/src/generators/use-fetch/runtime/useApiRequest.ts +223 -0
- package/src/generators/use-fetch/templates.ts +214 -0
- package/src/generators/use-fetch/types.ts +5 -0
- package/src/index.ts +265 -0
- package/tsconfig.json +15 -0
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
# 🚀 Quick Start - Understand in 5 Minutes
|
|
2
|
+
|
|
3
|
+
> **For AI Assistants & New Developers**: This is your entry point to understand the codebase quickly.
|
|
4
|
+
|
|
5
|
+
## What is this?
|
|
6
|
+
|
|
7
|
+
**Nuxt Generator** is a CLI tool that automatically converts OpenAPI/Swagger specifications into type-safe Nuxt 3 composables.
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
OpenAPI/Swagger → TypeScript Client → Nuxt Composables
|
|
11
|
+
(swagger.yaml) (PetApi.ts) (useFetchAddPet)
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Generator Backends
|
|
15
|
+
|
|
16
|
+
The tool supports two backends for **Stage 1** (OpenAPI → TypeScript Client). You choose at runtime:
|
|
17
|
+
|
|
18
|
+
| Backend | Command | Requires | Output format |
|
|
19
|
+
|---|---|---|---|
|
|
20
|
+
| **OpenAPI Generator** (official) | `@openapitools/openapi-generator-cli` | Java 11+ | `apis/PetApi.ts`, `models/` |
|
|
21
|
+
| **Hey API** | `@hey-api/openapi-ts` | Node.js only | `sdk.gen.ts`, `types.gen.ts` |
|
|
22
|
+
|
|
23
|
+
Both produce the same final Nuxt composables. The choice affects only Stage 1 output and the parser used in Stage 2.
|
|
24
|
+
|
|
25
|
+
> **Note**: If you select the official backend and Java is not installed, the CLI will abort with an installation link.
|
|
26
|
+
|
|
27
|
+
## Core Flow
|
|
28
|
+
|
|
29
|
+
```mermaid
|
|
30
|
+
graph LR
|
|
31
|
+
A[OpenAPI Spec] --> B{Backend choice}
|
|
32
|
+
B -->|official| C1[openapi-generator-cli]
|
|
33
|
+
B -->|heyapi| C2[@hey-api/openapi-ts]
|
|
34
|
+
C1 --> D[ts-morph Parser]
|
|
35
|
+
C2 --> D
|
|
36
|
+
D --> E[Template Generator]
|
|
37
|
+
E --> F[Nuxt Composables]
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Step by Step
|
|
41
|
+
|
|
42
|
+
1. **Select backend** — official (Java) or heyapi (Node.js)
|
|
43
|
+
2. **Stage 1** — chosen backend generates TypeScript client code from swagger.yaml
|
|
44
|
+
3. **Parser** (ts-morph) reads generated TypeScript and extracts API info
|
|
45
|
+
4. **Template Generator** creates Nuxt composables from extracted info
|
|
46
|
+
5. **Runtime Files** are copied to user's project (wrappers, helpers)
|
|
47
|
+
|
|
48
|
+
## 3 Critical Concepts
|
|
49
|
+
|
|
50
|
+
### 1. Two-Stage Generation
|
|
51
|
+
|
|
52
|
+
**Stage 1: OpenAPI → TypeScript Client** (two backend options)
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# Option A: official (requires Java 11+)
|
|
56
|
+
npx @openapitools/openapi-generator-cli generate \
|
|
57
|
+
-i swagger.yaml -g typescript-fetch -o ./output
|
|
58
|
+
# Generates: apis/PetApi.ts, models/, runtime.ts
|
|
59
|
+
|
|
60
|
+
# Option B: heyapi (Node.js only)
|
|
61
|
+
npx @hey-api/openapi-ts -i swagger.yaml -o ./output
|
|
62
|
+
# Generates: sdk.gen.ts, types.gen.ts, client.gen.ts
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**Stage 2: TypeScript Fetch → Nuxt Composables**
|
|
66
|
+
|
|
67
|
+
Our tool parses `PetApi.ts` and generates:
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
// Generated by our tool
|
|
71
|
+
export const useFetchAddPet = (params, options) => {
|
|
72
|
+
return useApiRequest<Pet>('/pet', {
|
|
73
|
+
method: 'POST',
|
|
74
|
+
body: params.pet,
|
|
75
|
+
...options,
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### 2. Wrapper Pattern
|
|
81
|
+
|
|
82
|
+
We DON'T generate direct `useFetch()` calls. We use a **wrapper**:
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
useFetchAddPet → useApiRequest → useFetch (Nuxt native)
|
|
86
|
+
↑
|
|
87
|
+
Callbacks, auth, interceptors
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**Why?** Adds lifecycle callbacks & global behaviors without modifying generated code.
|
|
91
|
+
|
|
92
|
+
### 3. Runtime vs Build-time
|
|
93
|
+
|
|
94
|
+
| File Type | Generated? | Copied to user? | User modifiable? |
|
|
95
|
+
| ---------------- | ---------- | --------------- | ---------------- |
|
|
96
|
+
| Composables | ✅ Always | ✅ | ❌ (regenerated) |
|
|
97
|
+
| Runtime wrappers | ❌ | ✅ (once) | ✅ (safe) |
|
|
98
|
+
| Plugin templates | ❌ | ✅ (once) | ✅ (safe) |
|
|
99
|
+
| CLI tool itself | ❌ | ❌ | ✅ (you edit) |
|
|
100
|
+
|
|
101
|
+
## Key Files (Read These First)
|
|
102
|
+
|
|
103
|
+
### 1. **CLI Entry** - `src/index.ts`
|
|
104
|
+
|
|
105
|
+
Starts here. Uses Commander.js for CLI commands.
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
program
|
|
109
|
+
.command('generate')
|
|
110
|
+
.option('-i, --input <file>', 'OpenAPI file')
|
|
111
|
+
.option('-o, --output <dir>', 'Output directory')
|
|
112
|
+
.action(async (options) => {
|
|
113
|
+
// Orchestrates generation
|
|
114
|
+
});
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### 2. **Main Generator** - `src/generators/use-fetch/generator.ts`
|
|
118
|
+
|
|
119
|
+
Orchestrates the generation process:
|
|
120
|
+
|
|
121
|
+
1. Scans for API files
|
|
122
|
+
2. Calls parser
|
|
123
|
+
3. Calls template generator
|
|
124
|
+
4. Writes files
|
|
125
|
+
5. Formats with Prettier
|
|
126
|
+
|
|
127
|
+
### 3. **Parser** - `src/generators/use-fetch/parser.ts`
|
|
128
|
+
|
|
129
|
+
Uses ts-morph to extract API info from TypeScript:
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
// Extracts this pattern:
|
|
133
|
+
async addPetRequestOpts(requestParameters): Promise<RequestOpts> {
|
|
134
|
+
return {
|
|
135
|
+
path: '/pet', // → method.path
|
|
136
|
+
method: 'POST', // → method.method
|
|
137
|
+
body: requestParameters['pet'] // → method.bodyField
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### 4. **Templates** - `src/generators/use-fetch/templates.ts`
|
|
143
|
+
|
|
144
|
+
Generates composable code:
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
function generateFunctionBody(method: MethodInfo): string {
|
|
148
|
+
return `export const ${method.composableName} = (
|
|
149
|
+
params: MaybeRef<${method.requestType}>,
|
|
150
|
+
options?: ApiRequestOptions<${method.responseType}>
|
|
151
|
+
) => {
|
|
152
|
+
const p = isRef(params) ? params : shallowRef(params)
|
|
153
|
+
return useApiRequest<${method.responseType}>(
|
|
154
|
+
() => \`${url}\`, // URL as function → reactive
|
|
155
|
+
{ ...fetchOptions, ...options }
|
|
156
|
+
)
|
|
157
|
+
}`;
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### 5. **Runtime Wrapper** - `src/generators/use-fetch/runtime/useApiRequest.ts`
|
|
162
|
+
|
|
163
|
+
Copied to user's project. Adds callbacks to useFetch:
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
export function useApiRequest<T>(
|
|
167
|
+
url: string | (() => string), // supports reactive URL
|
|
168
|
+
options?: ApiRequestOptions<T>
|
|
169
|
+
) {
|
|
170
|
+
const { onRequest, onSuccess, onError, onFinish, ...fetchOptions } = options || {};
|
|
171
|
+
|
|
172
|
+
// Merge local callbacks with global callbacks (from plugin)
|
|
173
|
+
const mergedCallbacks = mergeCallbacks(url, { onRequest, onSuccess, onError, onFinish });
|
|
174
|
+
|
|
175
|
+
// Apply global headers
|
|
176
|
+
const modifiedOptions = { ...fetchOptions, ...getGlobalHeaders() };
|
|
177
|
+
|
|
178
|
+
// Execute onRequest interceptor
|
|
179
|
+
if (mergedCallbacks.onRequest) {
|
|
180
|
+
applyRequestModifications(modifiedOptions, mergedCallbacks.onRequest(requestContext));
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const result = useFetch<T>(url, modifiedOptions);
|
|
184
|
+
|
|
185
|
+
// Watch for data, error, and pending state changes
|
|
186
|
+
watch(
|
|
187
|
+
() => [result.data.value, result.error.value, result.pending.value] as const,
|
|
188
|
+
async ([data, error, pending]) => {
|
|
189
|
+
if (data) await mergedCallbacks.onSuccess?.(data);
|
|
190
|
+
if (error) await mergedCallbacks.onError?.(error);
|
|
191
|
+
if (!pending) await mergedCallbacks.onFinish?.();
|
|
192
|
+
}
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
return result;
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## Project Structure Overview
|
|
200
|
+
|
|
201
|
+
```
|
|
202
|
+
nuxt-generator/
|
|
203
|
+
├── src/
|
|
204
|
+
│ ├── index.ts # ⭐ START: CLI entry point
|
|
205
|
+
│ ├── generate.ts # OpenAPI Generator wrapper
|
|
206
|
+
│ └── generators/
|
|
207
|
+
│ ├── shared/ # Common code
|
|
208
|
+
│ │ ├── types.ts # MethodInfo interface
|
|
209
|
+
│ │ ├── runtime/
|
|
210
|
+
│ │ │ └── apiHelpers.ts # Callbacks, auth, transforms
|
|
211
|
+
│ │ └── templates/
|
|
212
|
+
│ │ └── api-callbacks-plugin.ts # Global callbacks template
|
|
213
|
+
│ │
|
|
214
|
+
│ ├── use-fetch/ # ⭐ Main generator
|
|
215
|
+
│ │ ├── parser.ts # Extract API info (ts-morph)
|
|
216
|
+
│ │ ├── templates.ts # Generate composables
|
|
217
|
+
│ │ ├── generator.ts # Orchestration
|
|
218
|
+
│ │ └── runtime/
|
|
219
|
+
│ │ └── useApiRequest.ts # Wrapper (copied to user)
|
|
220
|
+
│ │
|
|
221
|
+
│ ├── use-async-data/ # Alternative generator
|
|
222
|
+
│ │ └── ... (similar structure)
|
|
223
|
+
│ │
|
|
224
|
+
│ └── nuxt-server/ # Server routes generator
|
|
225
|
+
│ ├── bff-templates.ts # BFF pattern support
|
|
226
|
+
│ └── ... (similar structure)
|
|
227
|
+
│
|
|
228
|
+
├── dist/ # Compiled JavaScript
|
|
229
|
+
└── docs/ # 📚 You are here
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## Most Common Tasks
|
|
233
|
+
|
|
234
|
+
### Debugging a Parser Error
|
|
235
|
+
|
|
236
|
+
1. Check error message for method name
|
|
237
|
+
2. Open `src/generators/use-fetch/parser.ts`
|
|
238
|
+
3. Look at `extractMethodInfo()` function (line ~81)
|
|
239
|
+
4. Add `console.log()` to see what's being parsed
|
|
240
|
+
5. Run: `npm run build && node dist/index.js generate -i swagger.yaml -o ./test`
|
|
241
|
+
|
|
242
|
+
### Adding a New Generator Type
|
|
243
|
+
|
|
244
|
+
1. Copy `src/generators/use-fetch/` → `src/generators/your-generator/`
|
|
245
|
+
2. Modify `templates.ts` to generate your format
|
|
246
|
+
3. Update `runtime/` wrapper if needed
|
|
247
|
+
4. Add to CLI choices in `src/index.ts`
|
|
248
|
+
5. Test: `npm run build && node dist/index.js generate`
|
|
249
|
+
|
|
250
|
+
### Modifying Callback Behavior
|
|
251
|
+
|
|
252
|
+
1. Edit `src/generators/shared/runtime/apiHelpers.ts`
|
|
253
|
+
2. Modify `mergeCallbacks()` function
|
|
254
|
+
3. Update runtime wrappers to use new logic
|
|
255
|
+
4. Rebuild: `npm run build`
|
|
256
|
+
5. Regenerate test output to verify
|
|
257
|
+
|
|
258
|
+
### Changing Generated Code Format
|
|
259
|
+
|
|
260
|
+
1. Edit `src/generators/use-fetch/templates.ts`
|
|
261
|
+
2. Modify `generateFunctionBody()` or related functions
|
|
262
|
+
3. Test template with: `npm run build && npm run generator`
|
|
263
|
+
4. Check output in `swagger/composables/`
|
|
264
|
+
|
|
265
|
+
## Technology Stack Quick Ref
|
|
266
|
+
|
|
267
|
+
| Library | Purpose | Used in |
|
|
268
|
+
| ----------------------- | ------------------------- | -------------- |
|
|
269
|
+
| `commander` | CLI commands & args | `src/index.ts` |
|
|
270
|
+
| `@clack/prompts` | Interactive prompts | `src/cli/` |
|
|
271
|
+
| `ts-morph` | TypeScript AST parsing | `parser.ts` |
|
|
272
|
+
| `openapi-generator-cli` | Generate typescript-fetch | `generate.ts` |
|
|
273
|
+
| `prettier` | Format generated code | `generator.ts` |
|
|
274
|
+
| `change-case` | String conversions | `templates.ts` |
|
|
275
|
+
| `fs-extra` | File operations | Everywhere |
|
|
276
|
+
|
|
277
|
+
## Next Steps
|
|
278
|
+
|
|
279
|
+
- **Architecture Details**: See [ARCHITECTURE.md](./ARCHITECTURE.md)
|
|
280
|
+
- **API Reference**: See [API-REFERENCE.md](./API-REFERENCE.md)
|
|
281
|
+
- **Development Guide**: See [DEVELOPMENT.md](./DEVELOPMENT.md)
|
|
282
|
+
- **Troubleshooting**: See [TROUBLESHOOTING.md](./TROUBLESHOOTING.md)
|
|
283
|
+
- **Contributing**: See [../CONTRIBUTING.md](../CONTRIBUTING.md)
|
|
284
|
+
|
|
285
|
+
## Quick Commands
|
|
286
|
+
|
|
287
|
+
```bash
|
|
288
|
+
# Build
|
|
289
|
+
npm run build
|
|
290
|
+
|
|
291
|
+
# Generate from example swagger
|
|
292
|
+
npm run generator
|
|
293
|
+
|
|
294
|
+
# Generate specific type
|
|
295
|
+
echo "useFetch" | npm run generator
|
|
296
|
+
|
|
297
|
+
# Test generation
|
|
298
|
+
node dist/index.js generate -i swagger.yaml -o ./test-output
|
|
299
|
+
|
|
300
|
+
# Validate code quality
|
|
301
|
+
npm run validate
|
|
302
|
+
|
|
303
|
+
# Format + lint
|
|
304
|
+
npm run format && npm run lint:fix
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
## Common Gotchas
|
|
308
|
+
|
|
309
|
+
❌ **Don't** edit files in `swagger/composables/` - they're regenerated
|
|
310
|
+
✅ **Do** edit files in `src/generators/*/runtime/` - they're your templates
|
|
311
|
+
❌ **Don't** import runtime files in CLI - they run in user's Nuxt project
|
|
312
|
+
✅ **Do** use `@ts-nocheck` in runtime files - different TS configs
|
|
313
|
+
❌ **Don't** use `&&` in PowerShell commands - use `;` instead
|
|
314
|
+
✅ **Do** test with both `useFetch` and `useAsyncData` generators
|
|
315
|
+
|
|
316
|
+
---
|
|
317
|
+
|
|
318
|
+
**Ready to dive deeper?** Choose your path:
|
|
319
|
+
|
|
320
|
+
- 🏗️ [Understanding Architecture](./ARCHITECTURE.md) - Design patterns & decisions
|
|
321
|
+
- 🔧 [Development Guide](./DEVELOPMENT.md) - Extending and contributing
|
|
322
|
+
- 📖 [API Reference](./API-REFERENCE.md) - Complete technical reference
|
|
323
|
+
- 🐛 [Troubleshooting](./TROUBLESHOOTING.md) - Common issues & solutions
|
package/docs/README.md
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# 📚 Documentation Index
|
|
2
|
+
|
|
3
|
+
Welcome to the Nuxt Generator documentation! Choose your path:
|
|
4
|
+
|
|
5
|
+
## 🚀 For New Developers & AI Assistants
|
|
6
|
+
|
|
7
|
+
Start here if you're new to the project:
|
|
8
|
+
|
|
9
|
+
- **[Quick Start Guide](./QUICK-START.md)** - Understand the project in 5 minutes
|
|
10
|
+
- What is this project?
|
|
11
|
+
- Core concepts (Two-stage generation, wrapper pattern, runtime vs build-time)
|
|
12
|
+
- Key files to read first
|
|
13
|
+
- Most common tasks
|
|
14
|
+
- Quick commands reference
|
|
15
|
+
|
|
16
|
+
## 🏗️ Understanding the Codebase
|
|
17
|
+
|
|
18
|
+
Learn about architecture and design decisions:
|
|
19
|
+
|
|
20
|
+
- **[Architecture & Design](./ARCHITECTURE.md)** - Patterns and decisions
|
|
21
|
+
- Architectural overview
|
|
22
|
+
- Core patterns explained
|
|
23
|
+
- Design decisions (ADRs)
|
|
24
|
+
- Component dependency map
|
|
25
|
+
- Global callbacks system deep dive
|
|
26
|
+
- Extension points
|
|
27
|
+
|
|
28
|
+
## 📖 Technical Reference
|
|
29
|
+
|
|
30
|
+
Complete API documentation:
|
|
31
|
+
|
|
32
|
+
- **[API Reference](./API-REFERENCE.md)** - Complete technical reference
|
|
33
|
+
- CLI commands
|
|
34
|
+
- Configuration options
|
|
35
|
+
- All interfaces & types
|
|
36
|
+
- Parser API
|
|
37
|
+
- Template API
|
|
38
|
+
- Runtime APIs
|
|
39
|
+
- Callback interfaces
|
|
40
|
+
- Generated composables reference
|
|
41
|
+
|
|
42
|
+
## 🔧 Development & Contributing
|
|
43
|
+
|
|
44
|
+
Guide for contributors:
|
|
45
|
+
|
|
46
|
+
- **[Development Guide](./DEVELOPMENT.md)** - Extending and contributing
|
|
47
|
+
- Getting started
|
|
48
|
+
- Development workflow
|
|
49
|
+
- Adding new features
|
|
50
|
+
- Testing changes
|
|
51
|
+
- Code style guide
|
|
52
|
+
- Common tasks
|
|
53
|
+
- Debugging tips
|
|
54
|
+
|
|
55
|
+
## 🐛 Problem Solving
|
|
56
|
+
|
|
57
|
+
When things go wrong:
|
|
58
|
+
|
|
59
|
+
- **[Troubleshooting](./TROUBLESHOOTING.md)** - Common issues & solutions
|
|
60
|
+
- Installation problems
|
|
61
|
+
- Generation errors
|
|
62
|
+
- Runtime errors
|
|
63
|
+
- Type errors
|
|
64
|
+
- Callback issues
|
|
65
|
+
- Performance problems
|
|
66
|
+
- OpenAPI spec issues
|
|
67
|
+
- Getting help
|
|
68
|
+
|
|
69
|
+
## 📋 Other Resources
|
|
70
|
+
|
|
71
|
+
- **[Contributing Guidelines](../CONTRIBUTING.md)** - How to contribute code
|
|
72
|
+
- **[License](../LICENSE)** - Project license
|
|
73
|
+
|
|
74
|
+
## Quick Navigation by Task
|
|
75
|
+
|
|
76
|
+
### "I want to understand what this project does"
|
|
77
|
+
|
|
78
|
+
→ Start with [Quick Start](./QUICK-START.md#what-is-this)
|
|
79
|
+
|
|
80
|
+
### "I want to know WHY it's built this way"
|
|
81
|
+
|
|
82
|
+
→ Read [Architecture - Design Decisions](./ARCHITECTURE.md#design-decisions-adrs)
|
|
83
|
+
|
|
84
|
+
### "I need to add a new feature"
|
|
85
|
+
|
|
86
|
+
→ Follow [Development Guide - Adding Features](./DEVELOPMENT.md#adding-features)
|
|
87
|
+
|
|
88
|
+
### "I'm getting an error"
|
|
89
|
+
|
|
90
|
+
→ Check [Troubleshooting Guide](./TROUBLESHOOTING.md)
|
|
91
|
+
|
|
92
|
+
### "I want to see all available options"
|
|
93
|
+
|
|
94
|
+
→ Browse [API Reference](./API-REFERENCE.md)
|
|
95
|
+
|
|
96
|
+
### "I want to understand how callbacks work"
|
|
97
|
+
|
|
98
|
+
→ Read [Architecture - Global Callbacks](./ARCHITECTURE.md#global-callbacks-deep-dive)
|
|
99
|
+
|
|
100
|
+
### "I want to extend the parser"
|
|
101
|
+
|
|
102
|
+
→ Follow [Development - Add Parser Feature](./DEVELOPMENT.md#add-parser-feature)
|
|
103
|
+
|
|
104
|
+
### "I want to add a new generator type"
|
|
105
|
+
|
|
106
|
+
→ Follow [Development - Add New Generator](./DEVELOPMENT.md#add-a-new-generator-type)
|
|
107
|
+
|
|
108
|
+
## Document Structure
|
|
109
|
+
|
|
110
|
+
Each document is organized for different purposes:
|
|
111
|
+
|
|
112
|
+
| Document | Audience | Purpose |
|
|
113
|
+
| --------------- | -------------- | ------------------------------ |
|
|
114
|
+
| Quick Start | Newcomers, AI | Fast onboarding, 5-min context |
|
|
115
|
+
| Architecture | Developers | Understand design & patterns |
|
|
116
|
+
| API Reference | All developers | Look up interfaces & functions |
|
|
117
|
+
| Development | Contributors | Extend & contribute |
|
|
118
|
+
| Troubleshooting | All users | Solve problems |
|
|
119
|
+
|
|
120
|
+
## Glossary
|
|
121
|
+
|
|
122
|
+
Quick reference for common terms:
|
|
123
|
+
|
|
124
|
+
- **Two-Stage Generation**: OpenAPI → TypeScript Fetch → Nuxt Composables
|
|
125
|
+
- **Wrapper Pattern**: Generated composables call runtime wrappers (useApiRequest)
|
|
126
|
+
- **Runtime Files**: Code copied to user's project (not imported from npm)
|
|
127
|
+
- **Build-time Runtime**: CLI tool environment (Node.js, ts-morph)
|
|
128
|
+
- **User Runtime**: User's Nuxt project (Vue 3, Nuxt composables)
|
|
129
|
+
- **MethodInfo**: Interface containing all data about an API endpoint
|
|
130
|
+
- **Parser**: ts-morph-based code that extracts API info from TypeScript
|
|
131
|
+
- **Template**: Functions that generate composable code
|
|
132
|
+
- **Global Callbacks**: Callbacks defined once in plugin, apply to all requests
|
|
133
|
+
- **BFF**: Backend for Frontend - pattern separating routing from business logic
|
|
134
|
+
- **Raw Composables**: useAsyncData composables that return headers + status
|
|
135
|
+
- **ADR**: Architectural Decision Record - documents why choices were made
|
|
136
|
+
|
|
137
|
+
## Contributing to Docs
|
|
138
|
+
|
|
139
|
+
Found a mistake or unclear section? Please:
|
|
140
|
+
|
|
141
|
+
1. [Open an issue](https://github.com/dmartindiaz/nuxt-openapi-hyperfetch/issues) describing the problem
|
|
142
|
+
2. Or submit a PR with improvements
|
|
143
|
+
3. Follow the [Contributing Guide](../CONTRIBUTING.md)
|
|
144
|
+
|
|
145
|
+
**Documentation Standards:**
|
|
146
|
+
|
|
147
|
+
- Use clear, concise language
|
|
148
|
+
- Include code examples for complex concepts
|
|
149
|
+
- Link between documents for cross-references
|
|
150
|
+
- Update related docs when making changes
|
|
151
|
+
- Test all command examples before committing
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
**Ready to dive in?** Start with the [Quick Start Guide](./QUICK-START.md)!
|