nuxt-openapi-hyperfetch 0.1.7-alpha.1 → 0.1.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 (79) 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/eslint.config.js +13 -0
  61. package/package.json +23 -2
  62. package/src/cli/config.ts +140 -140
  63. package/src/cli/logger.ts +124 -66
  64. package/src/cli/logo.ts +25 -25
  65. package/src/cli/types.ts +50 -50
  66. package/src/generators/nuxt-server/generator.ts +272 -270
  67. package/src/generators/shared/runtime/apiHelpers.ts +507 -507
  68. package/src/generators/shared/templates/api-callbacks-plugin.ts +352 -352
  69. package/src/generators/use-async-data/generator.ts +205 -204
  70. package/src/generators/use-async-data/runtime/useApiAsyncData.ts +229 -229
  71. package/src/generators/use-async-data/runtime/useApiAsyncDataRaw.ts +245 -245
  72. package/src/generators/use-async-data/templates.ts +257 -257
  73. package/src/generators/use-fetch/generator.ts +170 -169
  74. package/src/generators/use-fetch/runtime/useApiRequest.ts +234 -234
  75. package/src/generators/use-fetch/templates.ts +214 -214
  76. package/src/index.ts +265 -265
  77. package/src/module/index.ts +133 -0
  78. package/src/module/types.ts +31 -0
  79. package/src/generators/tanstack-query/generator.ts +0 -11
package/INSTRUCTIONS.md CHANGED
@@ -1,327 +1,327 @@
1
- # Nuxt Generator - Documentation Index
2
-
3
- > **Note**: This project's documentation has been reorganized for better accessibility. All detailed technical documentation is now in the `docs/` directory.
4
-
5
- ---
6
-
7
- ## 📚 Documentation Structure
8
-
9
- The documentation is organized to help different audiences find what they need quickly:
10
-
11
- ### 🚀 For New Developers & AI Assistants
12
-
13
- **Start here if you're new to the project:**
14
-
15
- 👉 **[Quick Start Guide](./docs/QUICK-START.md)** - Understand the project in 5 minutes
16
-
17
- - What is this project and how does it work?
18
- - Core concepts you need to know (two-stage generation, wrapper pattern, runtime architecture)
19
- - Key files to read first
20
- - Most common development tasks
21
- - Quick commands reference
22
-
23
- ### 🏗️ For Understanding Architecture
24
-
25
- **Learn about design patterns and decisions:**
26
-
27
- 👉 **[Architecture & Design Documentation](./docs/ARCHITECTURE.md)** - Deep dive into patterns
28
-
29
- - Architectural overview with diagrams
30
- - Core patterns explained (two-stage generation, wrapper pattern, shared code, BFF)
31
- - Design decisions (ADRs) with rationale and trade-offs
32
- - Component dependency map
33
- - Global callbacks system architecture
34
- - Extension points for customization
35
-
36
- ### 📖 For Technical Reference
37
-
38
- **Look up interfaces, functions, and APIs:**
39
-
40
- 👉 **[Complete API Reference](./docs/API-REFERENCE.md)** - Technical documentation
41
-
42
- - CLI commands and options
43
- - Configuration reference
44
- - All TypeScript interfaces and types (MethodInfo, ApiRequestOptions, etc.)
45
- - Parser API (extractMethodInfo, parseApiFile, scanApiFiles)
46
- - Template API (generateComposableFile, generateFunctionBody)
47
- - Runtime APIs (useApiRequest, useApiAsyncData, useApiAsyncDataRaw)
48
- - Callback interfaces (RequestContext, SuccessContext, ErrorContext, FinishContext)
49
- - Generated composables reference
50
-
51
- ### 🔧 For Development & Contributing
52
-
53
- **Extend the generator or contribute code:**
54
-
55
- 👉 **[Development Guide](./docs/DEVELOPMENT.md)** - Practical development instructions
56
-
57
- - Getting started with development
58
- - Development workflow and best practices
59
- - How to add new features:
60
- - Adding a new callback type
61
- - Adding a new generator (TanStack Query, etc.)
62
- - Adding parser features
63
- - Testing strategies
64
- - Code style guidelines
65
- - Common development tasks
66
- - Debugging tips and tools
67
-
68
- ### 🐛 For Problem Solving
69
-
70
- **When things go wrong:**
71
-
72
- 👉 **[Troubleshooting Guide](./docs/TROUBLESHOOTING.md)** - Solutions to common issues
73
-
74
- - Installation problems
75
- - Generation errors (APIs directory not found, found 0 methods, etc.)
76
- - Runtime errors (module not found, useFetch not defined, etc.)
77
- - Type errors
78
- - Callback troubleshooting (callbacks not firing, global callbacks not working)
79
- - Performance optimization
80
- - OpenAPI spec issues
81
-
82
- ---
83
-
84
- ## Quick Navigation
85
-
86
- ### By Role
87
-
88
- | I am a... | Start here... |
89
- | ----------------------------- | ---------------------------------------------------- |
90
- | New developer or AI assistant | [Quick Start Guide](./docs/QUICK-START.md) |
91
- | Contributor adding features | [Development Guide](./docs/DEVELOPMENT.md) |
92
- | Architect reviewing design | [Architecture Documentation](./docs/ARCHITECTURE.md) |
93
- | Developer with an error | [Troubleshooting Guide](./docs/TROUBLESHOOTING.md) |
94
- | Looking up an interface/type | [API Reference](./docs/API-REFERENCE.md) |
95
-
96
- ### By Task
97
-
98
- | I want to... | See... |
99
- | -------------------------------- | --------------------------------------------------------------------------------------- |
100
- | Understand the project quickly | [Quick Start - What is this?](./docs/QUICK-START.md#what-is-this) |
101
- | Know why it's built this way | [Architecture - Design Decisions](./docs/ARCHITECTURE.md#design-decisions-adrs) |
102
- | Add a new callback type | [Development - Add Callback](./docs/DEVELOPMENT.md#add-a-new-callback-type) |
103
- | Add a new generator | [Development - Add Generator](./docs/DEVELOPMENT.md#add-a-new-generator-type) |
104
- | Understand global callbacks | [Architecture - Global Callbacks](./docs/ARCHITECTURE.md#global-callbacks-deep-dive) |
105
- | Debug parser not finding methods | [Troubleshooting - Parser Issues](./docs/TROUBLESHOOTING.md#parser-not-finding-methods) |
106
- | Look up MethodInfo interface | [API Reference - Interfaces](./docs/API-REFERENCE.md#methodinfo) |
107
- | Understand execution order | [API Reference - Callback Interfaces](./docs/API-REFERENCE.md#callback-interfaces) |
108
- | See all available CLI commands | [API Reference - CLI Commands](./docs/API-REFERENCE.md#cli-commands) |
109
-
110
- ---
111
-
112
- ## Key Concepts (Quick Reference)
113
-
114
- ### Generator Backends
115
-
116
- The CLI supports two backends for Stage 1 (OpenAPI → TypeScript Client):
117
-
118
- | Backend | Flag | Requires | Notes |
119
- |---|---|---|---|
120
- | `official` | `--backend official` | Java 11+ | Uses `@openapitools/openapi-generator-cli` |
121
- | `heyapi` | `--backend heyapi` | Node.js only | Uses `@hey-api/openapi-ts` |
122
-
123
- Both backends feed into the same Stage 2 parsers (`src/generators/shared/parsers/`), producing identical `MethodInfo[]` so all templates are shared. The CLI checks for Java and aborts with an install link if `official` is selected without Java present.
124
-
125
- **Read more**: [Quick Start - Generator Backends](./docs/QUICK-START.md#generator-backends)
126
-
127
- ### Two-Stage Generation
128
-
129
- ```
130
- OpenAPI Spec → [Stage 1: official or heyapi backend] → TypeScript Client
131
- TypeScript Client → [Stage 2: Our Parser + Templates] → Nuxt Composables
132
- ```
133
-
134
- **Why?** Leverage the mature OpenAPI ecosystem instead of parsing YAML ourselves.
135
-
136
- **Read more**: [Architecture - Two-Stage Generation Pattern](./docs/ARCHITECTURE.md#1-two-stage-generation-pattern)
137
-
138
- ### Wrapper Pattern
139
-
140
- ```
141
- useFetchAddPet → useApiRequest → useFetch (Nuxt native)
142
-
143
- Adds: callbacks, auth, interceptors
144
- ```
145
-
146
- **Why?** Add features (callbacks, auth) without modifying generated code.
147
-
148
- **Read more**: [Architecture - Wrapper Pattern](./docs/ARCHITECTURE.md#2-wrapper-pattern)
149
-
150
- ### Runtime vs Build-time
151
-
152
- | Type | Environment | Dependencies |
153
- | ---------------- | ---------------------- | ----------------------- |
154
- | **Build-time** | CLI tool (Node.js) | ts-morph, commander |
155
- | **User runtime** | Nuxt project (browser) | Vue 3, Nuxt composables |
156
-
157
- **Why separate?** Runtime files are **copied** to user's project, not imported from npm.
158
-
159
- **Read more**: [Quick Start - Runtime vs Build-time](./docs/QUICK-START.md#2-runtime-vs-build-time)
160
-
161
- ### Global Callbacks System
162
-
163
- Define callbacks **once** in a plugin, apply to **all** requests:
164
-
165
- ```typescript
166
- // plugins/api-callbacks.ts
167
- export default defineNuxtPlugin(() => ({
168
- provide: {
169
- getGlobalApiCallbacks: () => ({
170
- onRequest: (ctx) => {
171
- /* Add auth */
172
- },
173
- onSuccess: (data) => {
174
- /* Show toast */
175
- },
176
- onError: (error) => {
177
- /* Handle errors */
178
- },
179
- }),
180
- },
181
- }));
182
- ```
183
-
184
- **Control**: 3 ways to disable (skipGlobalCallbacks, return false, patterns)
185
-
186
- **Read more**: [Architecture - Global Callbacks Deep Dive](./docs/ARCHITECTURE.md#global-callbacks-deep-dive)
187
-
188
- ---
189
-
190
- ## Project Structure Quick Overview
191
-
192
- ```
193
- nuxt-generator/
194
- ├── docs/ # 📚 Documentation (START HERE)
195
- │ ├── README.md # Documentation index
196
- │ ├── QUICK-START.md # 5-minute overview
197
- │ ├── ARCHITECTURE.md # Design patterns & ADRs
198
- │ ├── API-REFERENCE.md # Complete technical reference
199
- │ ├── DEVELOPMENT.md # How to contribute
200
- │ └── TROUBLESHOOTING.md # Problem solving
201
-
202
- ├── src/ # Source code
203
- │ ├── index.ts # ⭐ CLI entry point
204
- │ ├── generate.ts # OpenAPI Generator wrapper
205
- │ └── generators/
206
- │ ├── shared/ # Common code
207
- │ │ ├── types.ts # MethodInfo, ApiClassInfo
208
- │ │ ├── runtime/ # Copied to output
209
- │ │ │ └── apiHelpers.ts # Callbacks, auth, transforms
210
- │ │ └── templates/
211
- │ │ └── api-callbacks-plugin.ts # Global callbacks template
212
- │ │
213
- │ ├── use-fetch/ # ⭐ Main generator
214
- │ │ ├── parser.ts # Extract API info (ts-morph)
215
- │ │ ├── templates.ts # Generate composables
216
- │ │ ├── generator.ts # Orchestration
217
- │ │ └── runtime/
218
- │ │ └── useApiRequest.ts # Wrapper (copied to user)
219
- │ │
220
- │ ├── use-async-data/ # useAsyncData generator
221
- │ └── nuxt-server/ # Server routes generator
222
-
223
- ├── README.md # User-facing documentation
224
- ├── CONTRIBUTING.md # Contribution guidelines
225
- ├── INSTRUCTIONS.md # This file (documentation index)
226
- └── package.json
227
- ```
228
-
229
- ---
230
-
231
- ## Migration Guide (Old INSTRUCTIONS.md → New docs/)
232
-
233
- If you're looking for content from the old `INSTRUCTIONS.md` file, here's where it moved:
234
-
235
- | Old Section | New Location |
236
- | ------------------------------ | ------------------------------------------------------------------------------------------ |
237
- | Project Overview | [Quick Start - What is this?](./docs/QUICK-START.md#what-is-this) |
238
- | Project Structure | [Quick Start - Project Structure](./docs/QUICK-START.md#project-structure-overview) |
239
- | Technology Stack | [Quick Start - Technology Stack](./docs/QUICK-START.md#technology-stack-quick-ref) |
240
- | Architecture & Design Patterns | [Architecture Documentation](./docs/ARCHITECTURE.md) |
241
- | Two-Stage Generation | [Architecture - Two-Stage](./docs/ARCHITECTURE.md#1-two-stage-generation-pattern) |
242
- | Wrapper Pattern | [Architecture - Wrapper](./docs/ARCHITECTURE.md#2-wrapper-pattern) |
243
- | Parser Architecture | [Architecture - ADR-001](./docs/ARCHITECTURE.md#adr-001-use-ts-morph-instead-of-regex) |
244
- | Template-Based Generation | [Architecture - Template Pattern](./docs/ARCHITECTURE.md#4-template-based-code-generation) |
245
- | Runtime Design | [Quick Start - Runtime vs Build-time](./docs/QUICK-START.md#2-runtime-vs-build-time) |
246
- | Global Callbacks System | [Architecture - Global Callbacks](./docs/ARCHITECTURE.md#global-callbacks-deep-dive) |
247
- | Testing Strategy | [Development - Testing](./docs/DEVELOPMENT.md#testing-changes) |
248
- | Common Pitfalls | [Troubleshooting Guide](./docs/TROUBLESHOOTING.md) |
249
- | BFF Architecture | [Architecture - BFF](./docs/ARCHITECTURE.md) + [README - BFF](./README.md) |
250
- | Code Style & Conventions | [Development - Code Style](./docs/DEVELOPMENT.md#code-style) |
251
- | CLI Design Principles | [API Reference - CLI Commands](./docs/API-REFERENCE.md#cli-commands) |
252
- | Interfaces & Types | [API Reference - Interfaces](./docs/API-REFERENCE.md#interfaces--types) |
253
- | Parser API | [API Reference - Parser API](./docs/API-REFERENCE.md#parser-api) |
254
- | Template API | [API Reference - Template API](./docs/API-REFERENCE.md#template-api) |
255
- | Runtime APIs | [API Reference - Runtime APIs](./docs/API-REFERENCE.md#runtime-apis) |
256
-
257
- ---
258
-
259
- ## ⚠️ Important: Always Build Before Testing
260
-
261
- After editing any file in `src/`, you **must** run the build before testing changes:
262
-
263
- ```bash
264
- npm run build
265
- ```
266
-
267
- This compiles TypeScript from `src/` to JavaScript in `dist/`. The CLI (`nxh` / `node dist/index.js`) runs from `dist/` — **without rebuilding, your changes have no effect**.
268
-
269
- **Full cycle:**
270
-
271
- ```bash
272
- # 1. Edit files in src/
273
- # 2. Build
274
- npm run build
275
- # 3. Test
276
- node dist/index.js generate -i swagger.yaml -o ./swagger
277
- ```
278
-
279
- See [Development Workflow](./docs/DEVELOPMENT.md#development-workflow) for the full step-by-step guide.
280
-
281
- ---
282
-
283
- ## Glossary
284
-
285
- Quick reference for technical terms used throughout the documentation:
286
-
287
- - **Two-Stage Generation**: OpenAPI → TypeScript Fetch → Nuxt Composables
288
- - **Wrapper Pattern**: Generated composables call runtime wrappers (useApiRequest, useApiAsyncData)
289
- - **Runtime Files**: Code copied to user's project (not imported from npm package)
290
- - **Build-time Runtime**: Environment where CLI tool runs (Node.js, ts-morph, commander)
291
- - **User Runtime**: Environment where generated code runs (Vue 3, Nuxt composables, browser/SSR)
292
- - **MethodInfo**: TypeScript interface containing all extracted data about an API endpoint
293
- - **ApiClassInfo**: Interface grouping all methods from a single API class
294
- - **Parser**: Code using ts-morph to extract API information from TypeScript files
295
- - **Template**: Functions that generate composable code from MethodInfo
296
- - **Generator**: Orchestrator that calls parser, templates, and writes files
297
- - **Global Callbacks**: Callbacks defined once in a plugin that apply to all API requests
298
- - **BFF**: Backend for Frontend - pattern separating routing from business logic
299
- - **Raw Composables**: useAsyncData composables that return full response (data + headers + status)
300
- - **Normal Composables**: Standard composables that return only data
301
- - **ADR**: Architectural Decision Record - document explaining why a design choice was made
302
- - **SSR**: Server-Side Rendering - Nuxt's ability to render pages on the server
303
- - **AST**: Abstract Syntax Tree - tree representation of TypeScript code structure
304
- - **Dual Composables**: Pattern where both normal and raw versions are generated
305
-
306
- ---
307
-
308
- ## Getting Help
309
-
310
- ### Documentation Issues
311
-
312
- If you can't find what you're looking for or the documentation is unclear:
313
-
314
- 1. Check the [Documentation Index](./docs/README.md)
315
- 2. Use the "By Task" navigation table above
316
- 3. Search across all docs (GitHub search: `repo:username/nuxt-generator path:docs/ <your query>`)
317
- 4. [Open a documentation issue](https://github.com/dmartindiaz/nuxt-openapi-hyperfetch/issues/new?labels=documentation)
318
-
319
- ### Technical Support
320
-
321
- - **Bug Reports**: [Open an issue](https://github.com/dmartindiaz/nuxt-openapi-hyperfetch/issues/new?template=bug_report.md)
322
- - **Feature Requests**: [Open an issue](https://github.com/dmartindiaz/nuxt-openapi-hyperfetch/issues/new?template=feature_request.md)
323
- - **Questions**: [Start a discussion](https://github.com/dmartindiaz/nuxt-openapi-hyperfetch/discussions)
324
-
325
- ---
326
-
327
- **Ready to dive in?** Start with the [Quick Start Guide](./docs/QUICK-START.md)!
1
+ # Nuxt Generator - Documentation Index
2
+
3
+ > **Note**: This project's documentation has been reorganized for better accessibility. All detailed technical documentation is now in the `docs/` directory.
4
+
5
+ ---
6
+
7
+ ## 📚 Documentation Structure
8
+
9
+ The documentation is organized to help different audiences find what they need quickly:
10
+
11
+ ### 🚀 For New Developers & AI Assistants
12
+
13
+ **Start here if you're new to the project:**
14
+
15
+ 👉 **[Quick Start Guide](./docs/QUICK-START.md)** - Understand the project in 5 minutes
16
+
17
+ - What is this project and how does it work?
18
+ - Core concepts you need to know (two-stage generation, wrapper pattern, runtime architecture)
19
+ - Key files to read first
20
+ - Most common development tasks
21
+ - Quick commands reference
22
+
23
+ ### 🏗️ For Understanding Architecture
24
+
25
+ **Learn about design patterns and decisions:**
26
+
27
+ 👉 **[Architecture & Design Documentation](./docs/ARCHITECTURE.md)** - Deep dive into patterns
28
+
29
+ - Architectural overview with diagrams
30
+ - Core patterns explained (two-stage generation, wrapper pattern, shared code, BFF)
31
+ - Design decisions (ADRs) with rationale and trade-offs
32
+ - Component dependency map
33
+ - Global callbacks system architecture
34
+ - Extension points for customization
35
+
36
+ ### 📖 For Technical Reference
37
+
38
+ **Look up interfaces, functions, and APIs:**
39
+
40
+ 👉 **[Complete API Reference](./docs/API-REFERENCE.md)** - Technical documentation
41
+
42
+ - CLI commands and options
43
+ - Configuration reference
44
+ - All TypeScript interfaces and types (MethodInfo, ApiRequestOptions, etc.)
45
+ - Parser API (extractMethodInfo, parseApiFile, scanApiFiles)
46
+ - Template API (generateComposableFile, generateFunctionBody)
47
+ - Runtime APIs (useApiRequest, useApiAsyncData, useApiAsyncDataRaw)
48
+ - Callback interfaces (RequestContext, SuccessContext, ErrorContext, FinishContext)
49
+ - Generated composables reference
50
+
51
+ ### 🔧 For Development & Contributing
52
+
53
+ **Extend the generator or contribute code:**
54
+
55
+ 👉 **[Development Guide](./docs/DEVELOPMENT.md)** - Practical development instructions
56
+
57
+ - Getting started with development
58
+ - Development workflow and best practices
59
+ - How to add new features:
60
+ - Adding a new callback type
61
+ - Adding a new generator
62
+ - Adding parser features
63
+ - Testing strategies
64
+ - Code style guidelines
65
+ - Common development tasks
66
+ - Debugging tips and tools
67
+
68
+ ### 🐛 For Problem Solving
69
+
70
+ **When things go wrong:**
71
+
72
+ 👉 **[Troubleshooting Guide](./docs/TROUBLESHOOTING.md)** - Solutions to common issues
73
+
74
+ - Installation problems
75
+ - Generation errors (APIs directory not found, found 0 methods, etc.)
76
+ - Runtime errors (module not found, useFetch not defined, etc.)
77
+ - Type errors
78
+ - Callback troubleshooting (callbacks not firing, global callbacks not working)
79
+ - Performance optimization
80
+ - OpenAPI spec issues
81
+
82
+ ---
83
+
84
+ ## Quick Navigation
85
+
86
+ ### By Role
87
+
88
+ | I am a... | Start here... |
89
+ | ----------------------------- | ---------------------------------------------------- |
90
+ | New developer or AI assistant | [Quick Start Guide](./docs/QUICK-START.md) |
91
+ | Contributor adding features | [Development Guide](./docs/DEVELOPMENT.md) |
92
+ | Architect reviewing design | [Architecture Documentation](./docs/ARCHITECTURE.md) |
93
+ | Developer with an error | [Troubleshooting Guide](./docs/TROUBLESHOOTING.md) |
94
+ | Looking up an interface/type | [API Reference](./docs/API-REFERENCE.md) |
95
+
96
+ ### By Task
97
+
98
+ | I want to... | See... |
99
+ | -------------------------------- | --------------------------------------------------------------------------------------- |
100
+ | Understand the project quickly | [Quick Start - What is this?](./docs/QUICK-START.md#what-is-this) |
101
+ | Know why it's built this way | [Architecture - Design Decisions](./docs/ARCHITECTURE.md#design-decisions-adrs) |
102
+ | Add a new callback type | [Development - Add Callback](./docs/DEVELOPMENT.md#add-a-new-callback-type) |
103
+ | Add a new generator | [Development - Add Generator](./docs/DEVELOPMENT.md#add-a-new-generator-type) |
104
+ | Understand global callbacks | [Architecture - Global Callbacks](./docs/ARCHITECTURE.md#global-callbacks-deep-dive) |
105
+ | Debug parser not finding methods | [Troubleshooting - Parser Issues](./docs/TROUBLESHOOTING.md#parser-not-finding-methods) |
106
+ | Look up MethodInfo interface | [API Reference - Interfaces](./docs/API-REFERENCE.md#methodinfo) |
107
+ | Understand execution order | [API Reference - Callback Interfaces](./docs/API-REFERENCE.md#callback-interfaces) |
108
+ | See all available CLI commands | [API Reference - CLI Commands](./docs/API-REFERENCE.md#cli-commands) |
109
+
110
+ ---
111
+
112
+ ## Key Concepts (Quick Reference)
113
+
114
+ ### Generator Backends
115
+
116
+ The CLI supports two backends for Stage 1 (OpenAPI → TypeScript Client):
117
+
118
+ | Backend | Flag | Requires | Notes |
119
+ |---|---|---|---|
120
+ | `official` | `--backend official` | Java 11+ | Uses `@openapitools/openapi-generator-cli` |
121
+ | `heyapi` | `--backend heyapi` | Node.js only | Uses `@hey-api/openapi-ts` |
122
+
123
+ Both backends feed into the same Stage 2 parsers (`src/generators/shared/parsers/`), producing identical `MethodInfo[]` so all templates are shared. The CLI checks for Java and aborts with an install link if `official` is selected without Java present.
124
+
125
+ **Read more**: [Quick Start - Generator Backends](./docs/QUICK-START.md#generator-backends)
126
+
127
+ ### Two-Stage Generation
128
+
129
+ ```
130
+ OpenAPI Spec → [Stage 1: official or heyapi backend] → TypeScript Client
131
+ TypeScript Client → [Stage 2: Our Parser + Templates] → Nuxt Composables
132
+ ```
133
+
134
+ **Why?** Leverage the mature OpenAPI ecosystem instead of parsing YAML ourselves.
135
+
136
+ **Read more**: [Architecture - Two-Stage Generation Pattern](./docs/ARCHITECTURE.md#1-two-stage-generation-pattern)
137
+
138
+ ### Wrapper Pattern
139
+
140
+ ```
141
+ useFetchAddPet → useApiRequest → useFetch (Nuxt native)
142
+
143
+ Adds: callbacks, auth, interceptors
144
+ ```
145
+
146
+ **Why?** Add features (callbacks, auth) without modifying generated code.
147
+
148
+ **Read more**: [Architecture - Wrapper Pattern](./docs/ARCHITECTURE.md#2-wrapper-pattern)
149
+
150
+ ### Runtime vs Build-time
151
+
152
+ | Type | Environment | Dependencies |
153
+ | ---------------- | ---------------------- | ----------------------- |
154
+ | **Build-time** | CLI tool (Node.js) | ts-morph, commander |
155
+ | **User runtime** | Nuxt project (browser) | Vue 3, Nuxt composables |
156
+
157
+ **Why separate?** Runtime files are **copied** to user's project, not imported from npm.
158
+
159
+ **Read more**: [Quick Start - Runtime vs Build-time](./docs/QUICK-START.md#2-runtime-vs-build-time)
160
+
161
+ ### Global Callbacks System
162
+
163
+ Define callbacks **once** in a plugin, apply to **all** requests:
164
+
165
+ ```typescript
166
+ // plugins/api-callbacks.ts
167
+ export default defineNuxtPlugin(() => ({
168
+ provide: {
169
+ getGlobalApiCallbacks: () => ({
170
+ onRequest: (ctx) => {
171
+ /* Add auth */
172
+ },
173
+ onSuccess: (data) => {
174
+ /* Show toast */
175
+ },
176
+ onError: (error) => {
177
+ /* Handle errors */
178
+ },
179
+ }),
180
+ },
181
+ }));
182
+ ```
183
+
184
+ **Control**: 3 ways to disable (skipGlobalCallbacks, return false, patterns)
185
+
186
+ **Read more**: [Architecture - Global Callbacks Deep Dive](./docs/ARCHITECTURE.md#global-callbacks-deep-dive)
187
+
188
+ ---
189
+
190
+ ## Project Structure Quick Overview
191
+
192
+ ```
193
+ nuxt-generator/
194
+ ├── docs/ # 📚 Documentation (START HERE)
195
+ │ ├── README.md # Documentation index
196
+ │ ├── QUICK-START.md # 5-minute overview
197
+ │ ├── ARCHITECTURE.md # Design patterns & ADRs
198
+ │ ├── API-REFERENCE.md # Complete technical reference
199
+ │ ├── DEVELOPMENT.md # How to contribute
200
+ │ └── TROUBLESHOOTING.md # Problem solving
201
+
202
+ ├── src/ # Source code
203
+ │ ├── index.ts # ⭐ CLI entry point
204
+ │ ├── generate.ts # OpenAPI Generator wrapper
205
+ │ └── generators/
206
+ │ ├── shared/ # Common code
207
+ │ │ ├── types.ts # MethodInfo, ApiClassInfo
208
+ │ │ ├── runtime/ # Copied to output
209
+ │ │ │ └── apiHelpers.ts # Callbacks, auth, transforms
210
+ │ │ └── templates/
211
+ │ │ └── api-callbacks-plugin.ts # Global callbacks template
212
+ │ │
213
+ │ ├── use-fetch/ # ⭐ Main generator
214
+ │ │ ├── parser.ts # Extract API info (ts-morph)
215
+ │ │ ├── templates.ts # Generate composables
216
+ │ │ ├── generator.ts # Orchestration
217
+ │ │ └── runtime/
218
+ │ │ └── useApiRequest.ts # Wrapper (copied to user)
219
+ │ │
220
+ │ ├── use-async-data/ # useAsyncData generator
221
+ │ └── nuxt-server/ # Server routes generator
222
+
223
+ ├── README.md # User-facing documentation
224
+ ├── CONTRIBUTING.md # Contribution guidelines
225
+ ├── INSTRUCTIONS.md # This file (documentation index)
226
+ └── package.json
227
+ ```
228
+
229
+ ---
230
+
231
+ ## Migration Guide (Old INSTRUCTIONS.md → New docs/)
232
+
233
+ If you're looking for content from the old `INSTRUCTIONS.md` file, here's where it moved:
234
+
235
+ | Old Section | New Location |
236
+ | ------------------------------ | ------------------------------------------------------------------------------------------ |
237
+ | Project Overview | [Quick Start - What is this?](./docs/QUICK-START.md#what-is-this) |
238
+ | Project Structure | [Quick Start - Project Structure](./docs/QUICK-START.md#project-structure-overview) |
239
+ | Technology Stack | [Quick Start - Technology Stack](./docs/QUICK-START.md#technology-stack-quick-ref) |
240
+ | Architecture & Design Patterns | [Architecture Documentation](./docs/ARCHITECTURE.md) |
241
+ | Two-Stage Generation | [Architecture - Two-Stage](./docs/ARCHITECTURE.md#1-two-stage-generation-pattern) |
242
+ | Wrapper Pattern | [Architecture - Wrapper](./docs/ARCHITECTURE.md#2-wrapper-pattern) |
243
+ | Parser Architecture | [Architecture - ADR-001](./docs/ARCHITECTURE.md#adr-001-use-ts-morph-instead-of-regex) |
244
+ | Template-Based Generation | [Architecture - Template Pattern](./docs/ARCHITECTURE.md#4-template-based-code-generation) |
245
+ | Runtime Design | [Quick Start - Runtime vs Build-time](./docs/QUICK-START.md#2-runtime-vs-build-time) |
246
+ | Global Callbacks System | [Architecture - Global Callbacks](./docs/ARCHITECTURE.md#global-callbacks-deep-dive) |
247
+ | Testing Strategy | [Development - Testing](./docs/DEVELOPMENT.md#testing-changes) |
248
+ | Common Pitfalls | [Troubleshooting Guide](./docs/TROUBLESHOOTING.md) |
249
+ | BFF Architecture | [Architecture - BFF](./docs/ARCHITECTURE.md) + [README - BFF](./README.md) |
250
+ | Code Style & Conventions | [Development - Code Style](./docs/DEVELOPMENT.md#code-style) |
251
+ | CLI Design Principles | [API Reference - CLI Commands](./docs/API-REFERENCE.md#cli-commands) |
252
+ | Interfaces & Types | [API Reference - Interfaces](./docs/API-REFERENCE.md#interfaces--types) |
253
+ | Parser API | [API Reference - Parser API](./docs/API-REFERENCE.md#parser-api) |
254
+ | Template API | [API Reference - Template API](./docs/API-REFERENCE.md#template-api) |
255
+ | Runtime APIs | [API Reference - Runtime APIs](./docs/API-REFERENCE.md#runtime-apis) |
256
+
257
+ ---
258
+
259
+ ## ⚠️ Important: Always Build Before Testing
260
+
261
+ After editing any file in `src/`, you **must** run the build before testing changes:
262
+
263
+ ```bash
264
+ npm run build
265
+ ```
266
+
267
+ This compiles TypeScript from `src/` to JavaScript in `dist/`. The CLI (`nxh` / `node dist/index.js`) runs from `dist/` — **without rebuilding, your changes have no effect**.
268
+
269
+ **Full cycle:**
270
+
271
+ ```bash
272
+ # 1. Edit files in src/
273
+ # 2. Build
274
+ npm run build
275
+ # 3. Test
276
+ node dist/index.js generate -i swagger.yaml -o ./swagger
277
+ ```
278
+
279
+ See [Development Workflow](./docs/DEVELOPMENT.md#development-workflow) for the full step-by-step guide.
280
+
281
+ ---
282
+
283
+ ## Glossary
284
+
285
+ Quick reference for technical terms used throughout the documentation:
286
+
287
+ - **Two-Stage Generation**: OpenAPI → TypeScript Fetch → Nuxt Composables
288
+ - **Wrapper Pattern**: Generated composables call runtime wrappers (useApiRequest, useApiAsyncData)
289
+ - **Runtime Files**: Code copied to user's project (not imported from npm package)
290
+ - **Build-time Runtime**: Environment where CLI tool runs (Node.js, ts-morph, commander)
291
+ - **User Runtime**: Environment where generated code runs (Vue 3, Nuxt composables, browser/SSR)
292
+ - **MethodInfo**: TypeScript interface containing all extracted data about an API endpoint
293
+ - **ApiClassInfo**: Interface grouping all methods from a single API class
294
+ - **Parser**: Code using ts-morph to extract API information from TypeScript files
295
+ - **Template**: Functions that generate composable code from MethodInfo
296
+ - **Generator**: Orchestrator that calls parser, templates, and writes files
297
+ - **Global Callbacks**: Callbacks defined once in a plugin that apply to all API requests
298
+ - **BFF**: Backend for Frontend - pattern separating routing from business logic
299
+ - **Raw Composables**: useAsyncData composables that return full response (data + headers + status)
300
+ - **Normal Composables**: Standard composables that return only data
301
+ - **ADR**: Architectural Decision Record - document explaining why a design choice was made
302
+ - **SSR**: Server-Side Rendering - Nuxt's ability to render pages on the server
303
+ - **AST**: Abstract Syntax Tree - tree representation of TypeScript code structure
304
+ - **Dual Composables**: Pattern where both normal and raw versions are generated
305
+
306
+ ---
307
+
308
+ ## Getting Help
309
+
310
+ ### Documentation Issues
311
+
312
+ If you can't find what you're looking for or the documentation is unclear:
313
+
314
+ 1. Check the [Documentation Index](./docs/README.md)
315
+ 2. Use the "By Task" navigation table above
316
+ 3. Search across all docs (GitHub search: `repo:username/nuxt-generator path:docs/ <your query>`)
317
+ 4. [Open a documentation issue](https://github.com/dmartindiaz/nuxt-openapi-hyperfetch/issues/new?labels=documentation)
318
+
319
+ ### Technical Support
320
+
321
+ - **Bug Reports**: [Open an issue](https://github.com/dmartindiaz/nuxt-openapi-hyperfetch/issues/new?template=bug_report.md)
322
+ - **Feature Requests**: [Open an issue](https://github.com/dmartindiaz/nuxt-openapi-hyperfetch/issues/new?template=feature_request.md)
323
+ - **Questions**: [Start a discussion](https://github.com/dmartindiaz/nuxt-openapi-hyperfetch/discussions)
324
+
325
+ ---
326
+
327
+ **Ready to dive in?** Start with the [Quick Start Guide](./docs/QUICK-START.md)!