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.
Files changed (109) hide show
  1. package/.editorconfig +26 -0
  2. package/.prettierignore +17 -0
  3. package/.prettierrc.json +12 -0
  4. package/CONTRIBUTING.md +292 -0
  5. package/INSTRUCTIONS.md +327 -0
  6. package/LICENSE +202 -0
  7. package/README.md +202 -0
  8. package/dist/cli/config.d.ts +57 -0
  9. package/dist/cli/config.js +85 -0
  10. package/dist/cli/logger.d.ts +44 -0
  11. package/dist/cli/logger.js +58 -0
  12. package/dist/cli/logo.d.ts +6 -0
  13. package/dist/cli/logo.js +21 -0
  14. package/dist/cli/messages.d.ts +65 -0
  15. package/dist/cli/messages.js +86 -0
  16. package/dist/cli/prompts.d.ts +30 -0
  17. package/dist/cli/prompts.js +118 -0
  18. package/dist/cli/types.d.ts +43 -0
  19. package/dist/cli/types.js +4 -0
  20. package/dist/cli/utils.d.ts +26 -0
  21. package/dist/cli/utils.js +45 -0
  22. package/dist/generate.d.ts +6 -0
  23. package/dist/generate.js +48 -0
  24. package/dist/generators/nuxt-server/bff-templates.d.ts +25 -0
  25. package/dist/generators/nuxt-server/bff-templates.js +737 -0
  26. package/dist/generators/nuxt-server/generator.d.ts +7 -0
  27. package/dist/generators/nuxt-server/generator.js +206 -0
  28. package/dist/generators/nuxt-server/parser.d.ts +5 -0
  29. package/dist/generators/nuxt-server/parser.js +5 -0
  30. package/dist/generators/nuxt-server/templates.d.ts +35 -0
  31. package/dist/generators/nuxt-server/templates.js +412 -0
  32. package/dist/generators/nuxt-server/types.d.ts +5 -0
  33. package/dist/generators/nuxt-server/types.js +5 -0
  34. package/dist/generators/shared/parsers/heyapi-parser.d.ts +11 -0
  35. package/dist/generators/shared/parsers/heyapi-parser.js +248 -0
  36. package/dist/generators/shared/parsers/official-parser.d.ts +5 -0
  37. package/dist/generators/shared/parsers/official-parser.js +5 -0
  38. package/dist/generators/shared/runtime/apiHelpers.d.ts +183 -0
  39. package/dist/generators/shared/runtime/apiHelpers.js +268 -0
  40. package/dist/generators/shared/templates/api-callbacks-plugin.d.ts +178 -0
  41. package/dist/generators/shared/templates/api-callbacks-plugin.js +338 -0
  42. package/dist/generators/shared/types.d.ts +25 -0
  43. package/dist/generators/shared/types.js +4 -0
  44. package/dist/generators/tanstack-query/generator.d.ts +5 -0
  45. package/dist/generators/tanstack-query/generator.js +11 -0
  46. package/dist/generators/use-async-data/generator.d.ts +5 -0
  47. package/dist/generators/use-async-data/generator.js +156 -0
  48. package/dist/generators/use-async-data/parser.d.ts +5 -0
  49. package/dist/generators/use-async-data/parser.js +5 -0
  50. package/dist/generators/use-async-data/runtime/useApiAsyncData.d.ts +38 -0
  51. package/dist/generators/use-async-data/runtime/useApiAsyncData.js +122 -0
  52. package/dist/generators/use-async-data/runtime/useApiAsyncDataRaw.d.ts +54 -0
  53. package/dist/generators/use-async-data/runtime/useApiAsyncDataRaw.js +126 -0
  54. package/dist/generators/use-async-data/templates.d.ts +20 -0
  55. package/dist/generators/use-async-data/templates.js +191 -0
  56. package/dist/generators/use-async-data/types.d.ts +4 -0
  57. package/dist/generators/use-async-data/types.js +4 -0
  58. package/dist/generators/use-fetch/generator.d.ts +5 -0
  59. package/dist/generators/use-fetch/generator.js +131 -0
  60. package/dist/generators/use-fetch/parser.d.ts +9 -0
  61. package/dist/generators/use-fetch/parser.js +282 -0
  62. package/dist/generators/use-fetch/runtime/useApiRequest.d.ts +46 -0
  63. package/dist/generators/use-fetch/runtime/useApiRequest.js +158 -0
  64. package/dist/generators/use-fetch/templates.d.ts +16 -0
  65. package/dist/generators/use-fetch/templates.js +169 -0
  66. package/dist/generators/use-fetch/types.d.ts +5 -0
  67. package/dist/generators/use-fetch/types.js +5 -0
  68. package/dist/index.d.ts +2 -0
  69. package/dist/index.js +213 -0
  70. package/docs/API-REFERENCE.md +887 -0
  71. package/docs/ARCHITECTURE.md +649 -0
  72. package/docs/DEVELOPMENT.md +918 -0
  73. package/docs/QUICK-START.md +323 -0
  74. package/docs/README.md +155 -0
  75. package/docs/TROUBLESHOOTING.md +881 -0
  76. package/eslint.config.js +72 -0
  77. package/package.json +65 -0
  78. package/src/cli/config.ts +140 -0
  79. package/src/cli/logger.ts +66 -0
  80. package/src/cli/logo.ts +25 -0
  81. package/src/cli/messages.ts +97 -0
  82. package/src/cli/prompts.ts +143 -0
  83. package/src/cli/types.ts +50 -0
  84. package/src/cli/utils.ts +49 -0
  85. package/src/generate.ts +57 -0
  86. package/src/generators/nuxt-server/bff-templates.ts +754 -0
  87. package/src/generators/nuxt-server/generator.ts +270 -0
  88. package/src/generators/nuxt-server/parser.ts +5 -0
  89. package/src/generators/nuxt-server/templates.ts +483 -0
  90. package/src/generators/nuxt-server/types.ts +5 -0
  91. package/src/generators/shared/parsers/heyapi-parser.ts +307 -0
  92. package/src/generators/shared/parsers/official-parser.ts +5 -0
  93. package/src/generators/shared/runtime/apiHelpers.ts +466 -0
  94. package/src/generators/shared/templates/api-callbacks-plugin.ts +352 -0
  95. package/src/generators/shared/types.ts +27 -0
  96. package/src/generators/tanstack-query/generator.ts +11 -0
  97. package/src/generators/use-async-data/generator.ts +204 -0
  98. package/src/generators/use-async-data/parser.ts +5 -0
  99. package/src/generators/use-async-data/runtime/useApiAsyncData.ts +220 -0
  100. package/src/generators/use-async-data/runtime/useApiAsyncDataRaw.ts +236 -0
  101. package/src/generators/use-async-data/templates.ts +250 -0
  102. package/src/generators/use-async-data/types.ts +4 -0
  103. package/src/generators/use-fetch/generator.ts +169 -0
  104. package/src/generators/use-fetch/parser.ts +341 -0
  105. package/src/generators/use-fetch/runtime/useApiRequest.ts +223 -0
  106. package/src/generators/use-fetch/templates.ts +214 -0
  107. package/src/generators/use-fetch/types.ts +5 -0
  108. package/src/index.ts +265 -0
  109. package/tsconfig.json +15 -0
package/.editorconfig ADDED
@@ -0,0 +1,26 @@
1
+ # EditorConfig is awesome: https://EditorConfig.org
2
+
3
+ # Top-most EditorConfig file
4
+ root = true
5
+
6
+ # Unix-style newlines with a newline ending every file
7
+ [*]
8
+ charset = utf-8
9
+ end_of_line = lf
10
+ insert_final_newline = true
11
+ trim_trailing_whitespace = true
12
+
13
+ # TypeScript, JavaScript, JSON
14
+ [*.{ts,js,json}]
15
+ indent_style = space
16
+ indent_size = 2
17
+
18
+ # Markdown
19
+ [*.md]
20
+ trim_trailing_whitespace = false
21
+ indent_size = 2
22
+
23
+ # YAML
24
+ [*.{yml,yaml}]
25
+ indent_style = space
26
+ indent_size = 2
@@ -0,0 +1,17 @@
1
+ # Dependencies
2
+ node_modules/
3
+
4
+ # Build output
5
+ dist/
6
+
7
+ # Generated files
8
+ swagger/
9
+ test-*/
10
+
11
+ # Lock files
12
+ package-lock.json
13
+ pnpm-lock.yaml
14
+ yarn.lock
15
+
16
+ # CHANGELOG
17
+ CHANGELOG.md
@@ -0,0 +1,12 @@
1
+ {
2
+ "semi": true,
3
+ "trailingComma": "es5",
4
+ "singleQuote": true,
5
+ "printWidth": 100,
6
+ "tabWidth": 2,
7
+ "useTabs": false,
8
+ "arrowParens": "always",
9
+ "endOfLine": "lf",
10
+ "bracketSpacing": true,
11
+ "quoteProps": "as-needed"
12
+ }
@@ -0,0 +1,292 @@
1
+ # Contributing to Nuxt Generator
2
+
3
+ Thank you for your interest in contributing to Nuxt Generator! This document provides guidelines and instructions for contributing to the project.
4
+
5
+ ## 📋 Prerequisites
6
+
7
+ - **Node.js** >= 18.x
8
+ - **npm** >= 9.x
9
+ - **Git**
10
+
11
+ ## 📚 Before You Start - Read the Documentation
12
+
13
+ Before contributing, we highly recommend reading the technical documentation in the `docs/` directory:
14
+
15
+ ### Essential Reading
16
+
17
+ 1. **[Quick Start Guide](./docs/QUICK-START.md)** - Understand the project structure and core concepts
18
+ - Project overview and architecture
19
+ - Key files and their purposes
20
+ - Most common tasks
21
+
22
+ 2. **[Architecture Documentation](./docs/ARCHITECTURE.md)** - Understand design decisions
23
+ - Why the codebase is structured this way
24
+ - Core patterns (two-stage generation, wrapper pattern, shared code)
25
+ - Design decisions (ADRs) with trade-offs explained
26
+
27
+ 3. **[Development Guide](./docs/DEVELOPMENT.md)** - Practical development instructions
28
+ - How to add features (new callbacks, generators, parser features)
29
+ - Testing strategies
30
+ - Code style guidelines
31
+ - Debugging tips
32
+
33
+ 4. **[API Reference](./docs/API-REFERENCE.md)** - Complete technical reference
34
+ - All interfaces and types
35
+ - Parser, template, and runtime APIs
36
+ - Callback system documentation
37
+
38
+ ### Quick Reference
39
+
40
+ - Adding a new callback type? → See [Development Guide - Add a New Callback](./docs/DEVELOPMENT.md#add-a-new-callback-type)
41
+ - Adding a new generator? → See [Development Guide - Add a New Generator](./docs/DEVELOPMENT.md#add-a-new-generator-type)
42
+ - Parser not working? → See [Troubleshooting Guide](./docs/TROUBLESHOOTING.md#parser-not-finding-methods)
43
+ - Understanding global callbacks? → See [Architecture - Global Callbacks](./docs/ARCHITECTURE.md#global-callbacks-deep-dive)
44
+
45
+ ---
46
+
47
+ ## 🚀 Getting Started
48
+
49
+ ### 1. Fork and Clone
50
+
51
+ ```bash
52
+ # Fork the repository on GitHub, then clone your fork
53
+ git clone https://github.com/dmartindiaz/nuxt-openapi-hyperfetch.git
54
+ cd nuxt-openapi-hyperfetch
55
+ ```
56
+
57
+ ### 2. Install Dependencies
58
+
59
+ ```bash
60
+ npm install
61
+ ```
62
+
63
+ ### 3. Build the Project
64
+
65
+ ```bash
66
+ npm run build
67
+ ```
68
+
69
+ ## 🛠️ Development Workflow
70
+
71
+ ### Available Scripts
72
+
73
+ | Script | Description |
74
+ | ---------------------- | ------------------------------------------------------- |
75
+ | `npm run build` | Compile TypeScript to JavaScript |
76
+ | `npm run start` | Build and run the CLI |
77
+ | `npm run lint` | Check code for linting errors |
78
+ | `npm run lint:fix` | Automatically fix linting errors |
79
+ | `npm run format` | Format all code with Prettier |
80
+ | `npm run format:check` | Check if code is formatted correctly |
81
+ | `npm run type-check` | Run TypeScript type checking without building |
82
+ | `npm run validate` | Run type-check + lint + format-check (pre-commit check) |
83
+
84
+ ### Before Committing
85
+
86
+ **Always run these commands before committing:**
87
+
88
+ ```bash
89
+ # Format code
90
+ npm run format
91
+
92
+ # Fix linting issues
93
+ npm run lint:fix
94
+
95
+ # Validate everything
96
+ npm run validate
97
+ ```
98
+
99
+ ### Code Style
100
+
101
+ We use **ESLint** and **Prettier** to maintain consistent code style across the project.
102
+
103
+ #### ESLint Rules
104
+
105
+ - **TypeScript strict mode** - All code must pass type checking
106
+ - **No unused variables** - Prefix with `_` if intentionally unused
107
+ - **Prefer const** - Use `const` over `let` when possible
108
+ - **No var** - Always use `const` or `let`
109
+ - **Explicit return types** - Recommended but not enforced
110
+
111
+ #### Prettier Configuration
112
+
113
+ - **Single quotes** - Use `'` instead of `"`
114
+ - **Semicolons** - Always use semicolons
115
+ - **Trailing commas** - ES5 style (objects, arrays)
116
+ - **Print width** - 100 characters
117
+ - **Tab width** - 2 spaces
118
+ - **Line endings** - LF (Unix style)
119
+
120
+ ### EditorConfig
121
+
122
+ The project includes an `.editorconfig` file. Make sure your editor supports EditorConfig:
123
+
124
+ - **VS Code**: Install "EditorConfig for VS Code" extension
125
+ - **WebStorm/IntelliJ**: Built-in support
126
+ - **Sublime**: Install "EditorConfig" package
127
+ - **Vim**: Install "editorconfig-vim" plugin
128
+
129
+ ## 📝 Pull Request Process
130
+
131
+ ### 1. Create a Feature Branch
132
+
133
+ ```bash
134
+ git checkout -b feature/your-feature-name
135
+ # or
136
+ git checkout -b fix/your-bugfix-name
137
+ ```
138
+
139
+ ### 2. Make Your Changes
140
+
141
+ - Write clean, readable code
142
+ - Follow existing code patterns
143
+ - Add comments for complex logic
144
+ - Update documentation if needed
145
+
146
+ ### 3. Test Your Changes
147
+
148
+ ```bash
149
+ # Build the project
150
+ npm run build
151
+
152
+ # Test generation with example
153
+ npm run generator
154
+
155
+ # Or test with specific swagger file
156
+ node dist/index.js generate -i swagger.yaml -o ./test-output
157
+ ```
158
+
159
+ ### 4. Validate Your Code
160
+
161
+ ```bash
162
+ # Run all checks
163
+ npm run validate
164
+
165
+ # This runs:
166
+ # - TypeScript type checking
167
+ # - ESLint
168
+ # - Prettier format check
169
+ ```
170
+
171
+ ### 5. Commit Your Changes
172
+
173
+ Use clear, descriptive commit messages:
174
+
175
+ ```bash
176
+ # Good commit messages
177
+ git commit -m "feat: add support for @tanstack/vue-query generator"
178
+ git commit -m "fix: resolve path issues on Windows"
179
+ git commit -m "docs: update README with global callbacks examples"
180
+ git commit -m "refactor: extract common parser logic to shared module"
181
+
182
+ # Follow conventional commits format
183
+ # <type>: <description>
184
+ # Types: feat, fix, docs, style, refactor, test, chore
185
+ ```
186
+
187
+ ### 6. Push and Create PR
188
+
189
+ ```bash
190
+ git push origin feature/your-feature-name
191
+ ```
192
+
193
+ Then create a Pull Request on GitHub with:
194
+
195
+ - **Clear title** - What does this PR do?
196
+ - **Description** - Why is this change needed?
197
+ - **Testing** - How did you test it?
198
+ - **Screenshots** - If applicable
199
+
200
+ ## 🐛 Reporting Bugs
201
+
202
+ When reporting bugs, please include:
203
+
204
+ 1. **Description** - Clear description of the bug
205
+ 2. **Steps to reproduce** - Minimal steps to reproduce the issue
206
+ 3. **Expected behavior** - What you expected to happen
207
+ 4. **Actual behavior** - What actually happened
208
+ 5. **Environment**:
209
+ - Node.js version: `node --version`
210
+ - npm version: `npm --version`
211
+ - OS: Windows/Mac/Linux
212
+ 6. **Swagger file** - If possible, provide the OpenAPI/Swagger file that causes the issue
213
+
214
+ ## 💡 Suggesting Features
215
+
216
+ Feature requests are welcome! Please include:
217
+
218
+ 1. **Use case** - What problem does this solve?
219
+ 2. **Proposed solution** - How should it work?
220
+ 3. **Alternatives** - Have you considered other approaches?
221
+ 4. **Examples** - Code examples if applicable
222
+
223
+ ## 📂 Project Structure
224
+
225
+ ```
226
+ nuxt-generator/
227
+ ├── src/
228
+ │ ├── index.ts # CLI entry point
229
+ │ ├── generate.ts # OpenAPI generator wrapper
230
+ │ ├── cli/ # CLI utilities (prompts, logger, logo)
231
+ │ └── generators/
232
+ │ ├── shared/ # Shared types and runtime helpers
233
+ │ ├── use-fetch/ # useFetch generator
234
+ │ ├── use-async-data/ # useAsyncData generator
235
+ │ ├── nuxt-server/ # Nuxt Server Routes generator
236
+ │ └── tanstack-query/ # TanStack Query generator (TODO)
237
+ ├── dist/ # Compiled output
238
+ ├── eslint.config.js # ESLint configuration
239
+ ├── .prettierrc.json # Prettier configuration
240
+ ├── .editorconfig # Editor configuration
241
+ ├── tsconfig.json # TypeScript configuration
242
+ ├── INSTRUCTIONS.md # Detailed technical documentation
243
+ └── README.md # User documentation
244
+ ```
245
+
246
+ ## 🧪 Testing
247
+
248
+ ### Manual Testing
249
+
250
+ 1. Generate composables from example swagger.yaml:
251
+
252
+ ```bash
253
+ npm run generator
254
+ ```
255
+
256
+ 2. Test different generators:
257
+
258
+ ```bash
259
+ # useFetch
260
+ echo useFetch | npm run generator
261
+
262
+ # useAsyncData
263
+ echo useAsyncData | npm run generator
264
+
265
+ # Nuxt Server Routes
266
+ echo nuxtServer | npm run generator
267
+ ```
268
+
269
+ 3. Verify generated code compiles in a Nuxt project
270
+
271
+ ### Future: Automated Tests
272
+
273
+ We plan to add automated tests in the future. Contributions welcome!
274
+
275
+ ## ❓ Questions?
276
+
277
+ - **Documentation**: Read the comprehensive docs in the `docs/` directory:
278
+ - [Quick Start](./docs/QUICK-START.md) - Project overview and core concepts
279
+ - [Architecture](./docs/ARCHITECTURE.md) - Design patterns and decisions
280
+ - [Development Guide](./docs/DEVELOPMENT.md) - How to extend and contribute
281
+ - [API Reference](./docs/API-REFERENCE.md) - Complete technical reference
282
+ - [Troubleshooting](./docs/TROUBLESHOOTING.md) - Common issues and solutions
283
+ - **Issues**: Search [existing issues](https://github.com/dmartindiaz/nuxt-openapi-hyperfetch/issues)
284
+ - **Discussions**: Start a [discussion](https://github.com/dmartindiaz/nuxt-openapi-hyperfetch/discussions)
285
+
286
+ ## 📄 License
287
+
288
+ By contributing, you agree that your contributions will be licensed under the Apache-2.0 License.
289
+
290
+ ---
291
+
292
+ **Happy coding! 🚀**
@@ -0,0 +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)!