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
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Utility functions for CLI operations
3
+ */
4
+ import * as p from '@clack/prompts';
5
+ import { MESSAGES } from './messages.js';
6
+
7
+ /**
8
+ * Handle cancellation uniformly across all prompts
9
+ * This function never returns - it exits the process
10
+ */
11
+ export function handleCancel(): never {
12
+ p.cancel(MESSAGES.outro.cancelled);
13
+ process.exit(0);
14
+ }
15
+
16
+ /**
17
+ * Check if user cancelled the prompt and exit if so
18
+ * Use this after every prompt to handle Ctrl+C gracefully
19
+ *
20
+ * @param value - The value returned from a prompt
21
+ *
22
+ * @example
23
+ * const result = await p.text({ message: 'Enter name' });
24
+ * checkCancellation(result);
25
+ * // Now we know result is not a cancel symbol
26
+ */
27
+ export function checkCancellation(value: unknown): void {
28
+ if (p.isCancel(value)) {
29
+ handleCancel();
30
+ }
31
+ }
32
+
33
+ /**
34
+ * Format a file path for display in messages
35
+ * Normalizes path separators and removes trailing slashes
36
+ */
37
+ export function formatPath(path: string): string {
38
+ return path.replace(/\\/g, '/').replace(/\/$/, '');
39
+ }
40
+
41
+ /**
42
+ * Validate that a path is not empty
43
+ */
44
+ export function validateNonEmpty(value: string | undefined): string | undefined {
45
+ if (!value || value.trim() === '') {
46
+ return 'This field is required';
47
+ }
48
+ return undefined;
49
+ }
@@ -0,0 +1,57 @@
1
+ import { execSync } from 'child_process';
2
+ import * as path from 'path';
3
+ import { p, logSuccess, logError } from './cli/logger.js';
4
+
5
+ /**
6
+ * Check if Java is installed. Returns true if found, false otherwise.
7
+ */
8
+ export function checkJavaInstalled(): boolean {
9
+ try {
10
+ execSync('java -version', { stdio: 'ignore' });
11
+ return true;
12
+ } catch {
13
+ return false;
14
+ }
15
+ }
16
+
17
+ export const generateOpenApiFiles = (input: string, output: string) => {
18
+ try {
19
+ const inputPath = path.resolve(input);
20
+ const outputPath = path.resolve(output);
21
+
22
+ p.log.info(`Input: ${inputPath}`);
23
+ p.log.info(`Output: ${outputPath}`);
24
+
25
+ execSync(
26
+ `npx @openapitools/openapi-generator-cli generate -i "${inputPath}" -g typescript-fetch -o "${outputPath}"`,
27
+ { stdio: 'inherit' }
28
+ );
29
+
30
+ logSuccess(`Files generated successfully in ${outputPath}`);
31
+ } catch (error) {
32
+ logError(`Error generating files: ${String(error)}`);
33
+ process.exit(1);
34
+ }
35
+ };
36
+
37
+ export const generateHeyApiFiles = async (input: string, output: string) => {
38
+ try {
39
+ const inputPath = path.resolve(input);
40
+ const outputPath = path.resolve(output);
41
+
42
+ p.log.info(`Input: ${inputPath}`);
43
+ p.log.info(`Output: ${outputPath}`);
44
+
45
+ const { createClient } = await import('@hey-api/openapi-ts');
46
+ await createClient({
47
+ input: inputPath,
48
+ output: outputPath,
49
+ plugins: ['@hey-api/typescript', '@hey-api/sdk'],
50
+ });
51
+
52
+ logSuccess(`Files generated successfully in ${outputPath}`);
53
+ } catch (error) {
54
+ logError(`Error generating files: ${String(error)}`);
55
+ process.exit(1);
56
+ }
57
+ };