nuxt-openapi-hyperfetch 0.2.7-alpha.1 → 0.2.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 (60) hide show
  1. package/.editorconfig +26 -26
  2. package/.prettierignore +17 -17
  3. package/CONTRIBUTING.md +291 -291
  4. package/INSTRUCTIONS.md +327 -327
  5. package/LICENSE +202 -202
  6. package/README.md +231 -231
  7. package/dist/cli/config.d.ts +9 -2
  8. package/dist/cli/config.js +1 -1
  9. package/dist/cli/logo.js +5 -5
  10. package/dist/cli/messages.d.ts +1 -0
  11. package/dist/cli/messages.js +2 -0
  12. package/dist/cli/prompts.d.ts +5 -0
  13. package/dist/cli/prompts.js +12 -0
  14. package/dist/cli/types.d.ts +1 -1
  15. package/dist/generators/components/connector-generator/templates.js +12 -12
  16. package/dist/generators/use-async-data/templates.js +17 -17
  17. package/dist/generators/use-fetch/templates.js +14 -14
  18. package/dist/index.js +39 -27
  19. package/dist/module/index.js +19 -0
  20. package/dist/module/types.d.ts +7 -0
  21. package/docs/API-REFERENCE.md +886 -886
  22. package/docs/generated-components.md +615 -615
  23. package/docs/headless-composables-ui.md +569 -569
  24. package/eslint.config.js +85 -85
  25. package/package.json +1 -1
  26. package/src/cli/config.ts +147 -140
  27. package/src/cli/logger.ts +124 -124
  28. package/src/cli/logo.ts +25 -25
  29. package/src/cli/messages.ts +4 -0
  30. package/src/cli/prompts.ts +14 -1
  31. package/src/cli/types.ts +50 -50
  32. package/src/generators/components/connector-generator/generator.ts +138 -138
  33. package/src/generators/components/connector-generator/templates.ts +254 -254
  34. package/src/generators/components/connector-generator/types.ts +34 -34
  35. package/src/generators/components/schema-analyzer/index.ts +44 -44
  36. package/src/generators/components/schema-analyzer/intent-detector.ts +187 -187
  37. package/src/generators/components/schema-analyzer/openapi-reader.ts +96 -96
  38. package/src/generators/components/schema-analyzer/resource-grouper.ts +166 -166
  39. package/src/generators/components/schema-analyzer/schema-field-mapper.ts +268 -268
  40. package/src/generators/components/schema-analyzer/types.ts +177 -177
  41. package/src/generators/nuxt-server/generator.ts +272 -272
  42. package/src/generators/shared/runtime/apiHelpers.ts +535 -535
  43. package/src/generators/shared/runtime/pagination.ts +323 -323
  44. package/src/generators/shared/runtime/useDeleteConnector.ts +109 -109
  45. package/src/generators/shared/runtime/useDetailConnector.ts +64 -64
  46. package/src/generators/shared/runtime/useFormConnector.ts +139 -139
  47. package/src/generators/shared/runtime/useListConnector.ts +148 -148
  48. package/src/generators/shared/runtime/zod-error-merger.ts +119 -119
  49. package/src/generators/shared/templates/api-callbacks-plugin.ts +399 -399
  50. package/src/generators/shared/templates/api-pagination-plugin.ts +158 -158
  51. package/src/generators/use-async-data/generator.ts +205 -205
  52. package/src/generators/use-async-data/runtime/useApiAsyncData.ts +329 -329
  53. package/src/generators/use-async-data/runtime/useApiAsyncDataRaw.ts +324 -324
  54. package/src/generators/use-async-data/templates.ts +257 -257
  55. package/src/generators/use-fetch/generator.ts +170 -170
  56. package/src/generators/use-fetch/runtime/useApiRequest.ts +354 -354
  57. package/src/generators/use-fetch/templates.ts +214 -214
  58. package/src/index.ts +305 -303
  59. package/src/module/index.ts +158 -133
  60. package/src/module/types.ts +39 -31
@@ -1,177 +1,177 @@
1
- /**
2
- * Types for the Schema Analyzer — Fase 1 of the Connector Generator.
3
- *
4
- * The Schema Analyzer reads an OpenAPI YAML/JSON spec directly and produces
5
- * a ResourceMap: one ResourceInfo per tag/path-prefix group of endpoints.
6
- */
7
-
8
- // ─── Intent ─────────────────────────────────────────────────────────────────
9
-
10
- export type Intent = 'list' | 'detail' | 'create' | 'update' | 'delete' | 'unknown';
11
-
12
- // ─── OpenAPI raw schema types (minimal surface we need) ─────────────────────
13
-
14
- export interface OpenApiPropertySchema {
15
- type?: string;
16
- format?: string;
17
- enum?: string[];
18
- items?: OpenApiPropertySchema;
19
- $ref?: string;
20
- readOnly?: boolean;
21
- writeOnly?: boolean;
22
- minLength?: number;
23
- maxLength?: number;
24
- minimum?: number;
25
- maximum?: number;
26
- minItems?: number;
27
- maxItems?: number;
28
- properties?: Record<string, OpenApiPropertySchema>;
29
- required?: string[];
30
- description?: string;
31
- example?: unknown;
32
- additionalProperties?: OpenApiPropertySchema | boolean;
33
- allOf?: OpenApiPropertySchema[];
34
- oneOf?: OpenApiPropertySchema[];
35
- anyOf?: OpenApiPropertySchema[];
36
- }
37
-
38
- export interface OpenApiSchema extends OpenApiPropertySchema {
39
- required?: string[];
40
- properties?: Record<string, OpenApiPropertySchema>;
41
- }
42
-
43
- export interface OpenApiParameter {
44
- name: string;
45
- in: 'path' | 'query' | 'header' | 'cookie';
46
- required?: boolean;
47
- schema?: OpenApiPropertySchema;
48
- description?: string;
49
- }
50
-
51
- export interface OpenApiOperation {
52
- operationId?: string;
53
- tags?: string[];
54
- summary?: string;
55
- description?: string;
56
- parameters?: OpenApiParameter[];
57
- requestBody?: {
58
- required?: boolean;
59
- content?: Record<string, { schema?: OpenApiPropertySchema }>;
60
- };
61
- responses?: Record<
62
- string,
63
- {
64
- description?: string;
65
- content?: Record<string, { schema?: OpenApiPropertySchema }>;
66
- }
67
- >;
68
- /** Developer override — detected intent for this endpoint */
69
- 'x-nxh-intent'?: Intent;
70
- }
71
-
72
- export interface OpenApiPathItem {
73
- get?: OpenApiOperation;
74
- post?: OpenApiOperation;
75
- put?: OpenApiOperation;
76
- patch?: OpenApiOperation;
77
- delete?: OpenApiOperation;
78
- }
79
-
80
- export interface OpenApiSpec {
81
- openapi: string;
82
- info: { title: string; version: string };
83
- tags?: Array<{ name: string; description?: string }>;
84
- paths: Record<string, OpenApiPathItem>;
85
- components?: {
86
- schemas?: Record<string, OpenApiPropertySchema>;
87
- };
88
- }
89
-
90
- // ─── Analyzed endpoint ───────────────────────────────────────────────────────
91
-
92
- export interface EndpointInfo {
93
- operationId: string;
94
- method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
95
- path: string;
96
- tags: string[];
97
- summary?: string;
98
- description?: string;
99
- intent: Intent;
100
- /** Resolved (no $ref) request body schema for POST/PUT/PATCH */
101
- requestBodySchema?: OpenApiSchema;
102
- /** Resolved (no $ref) successful response schema (first 2xx) */
103
- responseSchema?: OpenApiSchema;
104
- hasPathParams: boolean;
105
- pathParams: string[];
106
- }
107
-
108
- // ─── Form field definition ───────────────────────────────────────────────────
109
-
110
- export type FieldType = 'input' | 'textarea' | 'select' | 'checkbox' | 'datepicker' | 'number';
111
-
112
- export interface FormFieldDef {
113
- key: string;
114
- label: string;
115
- type: FieldType;
116
- required: boolean;
117
- options?: { label: string; value: string }[];
118
- placeholder?: string;
119
- hidden?: boolean;
120
- /** Zod expression string, e.g. 'z.string().min(1)' */
121
- zodExpression: string;
122
- }
123
-
124
- // ─── Table column definition ─────────────────────────────────────────────────
125
-
126
- export type ColumnType = 'text' | 'number' | 'date' | 'boolean' | 'badge';
127
-
128
- export interface ColumnDef {
129
- key: string;
130
- label: string;
131
- type: ColumnType;
132
- }
133
-
134
- // ─── Resource ────────────────────────────────────────────────────────────────
135
-
136
- export interface ResourceInfo {
137
- /** Normalized resource name, PascalCase. E.g. 'Pet', 'Store' */
138
- name: string;
139
- /** Tag name as it appears in the spec. E.g. 'pet', 'store' */
140
- tag: string;
141
- /** Generated connector composable name. E.g. 'usePetsConnector' */
142
- composableName: string;
143
-
144
- endpoints: EndpointInfo[];
145
-
146
- /** The one endpoint detected as list (GET array) */
147
- listEndpoint?: EndpointInfo;
148
- /** The one endpoint detected as detail (GET single object) */
149
- detailEndpoint?: EndpointInfo;
150
- /** The one endpoint detected as create (POST) */
151
- createEndpoint?: EndpointInfo;
152
- /** The one endpoint detected as update (PUT/PATCH) */
153
- updateEndpoint?: EndpointInfo;
154
- /** The one endpoint detected as delete (DELETE) */
155
- deleteEndpoint?: EndpointInfo;
156
-
157
- /** Columns inferred from the list/detail response schema */
158
- columns: ColumnDef[];
159
-
160
- /** Form fields inferred from the request body schema */
161
- formFields: {
162
- create?: FormFieldDef[];
163
- update?: FormFieldDef[];
164
- };
165
-
166
- /**
167
- * Zod schema object expression strings, ready to embed in generated code.
168
- * E.g. "z.object({\n name: z.string().min(1),\n ....\n})"
169
- */
170
- zodSchemas: {
171
- create?: string;
172
- update?: string;
173
- };
174
- }
175
-
176
- /** One entry per tag (or path-prefix fallback) */
177
- export type ResourceMap = Map<string, ResourceInfo>;
1
+ /**
2
+ * Types for the Schema Analyzer — Fase 1 of the Connector Generator.
3
+ *
4
+ * The Schema Analyzer reads an OpenAPI YAML/JSON spec directly and produces
5
+ * a ResourceMap: one ResourceInfo per tag/path-prefix group of endpoints.
6
+ */
7
+
8
+ // ─── Intent ─────────────────────────────────────────────────────────────────
9
+
10
+ export type Intent = 'list' | 'detail' | 'create' | 'update' | 'delete' | 'unknown';
11
+
12
+ // ─── OpenAPI raw schema types (minimal surface we need) ─────────────────────
13
+
14
+ export interface OpenApiPropertySchema {
15
+ type?: string;
16
+ format?: string;
17
+ enum?: string[];
18
+ items?: OpenApiPropertySchema;
19
+ $ref?: string;
20
+ readOnly?: boolean;
21
+ writeOnly?: boolean;
22
+ minLength?: number;
23
+ maxLength?: number;
24
+ minimum?: number;
25
+ maximum?: number;
26
+ minItems?: number;
27
+ maxItems?: number;
28
+ properties?: Record<string, OpenApiPropertySchema>;
29
+ required?: string[];
30
+ description?: string;
31
+ example?: unknown;
32
+ additionalProperties?: OpenApiPropertySchema | boolean;
33
+ allOf?: OpenApiPropertySchema[];
34
+ oneOf?: OpenApiPropertySchema[];
35
+ anyOf?: OpenApiPropertySchema[];
36
+ }
37
+
38
+ export interface OpenApiSchema extends OpenApiPropertySchema {
39
+ required?: string[];
40
+ properties?: Record<string, OpenApiPropertySchema>;
41
+ }
42
+
43
+ export interface OpenApiParameter {
44
+ name: string;
45
+ in: 'path' | 'query' | 'header' | 'cookie';
46
+ required?: boolean;
47
+ schema?: OpenApiPropertySchema;
48
+ description?: string;
49
+ }
50
+
51
+ export interface OpenApiOperation {
52
+ operationId?: string;
53
+ tags?: string[];
54
+ summary?: string;
55
+ description?: string;
56
+ parameters?: OpenApiParameter[];
57
+ requestBody?: {
58
+ required?: boolean;
59
+ content?: Record<string, { schema?: OpenApiPropertySchema }>;
60
+ };
61
+ responses?: Record<
62
+ string,
63
+ {
64
+ description?: string;
65
+ content?: Record<string, { schema?: OpenApiPropertySchema }>;
66
+ }
67
+ >;
68
+ /** Developer override — detected intent for this endpoint */
69
+ 'x-nxh-intent'?: Intent;
70
+ }
71
+
72
+ export interface OpenApiPathItem {
73
+ get?: OpenApiOperation;
74
+ post?: OpenApiOperation;
75
+ put?: OpenApiOperation;
76
+ patch?: OpenApiOperation;
77
+ delete?: OpenApiOperation;
78
+ }
79
+
80
+ export interface OpenApiSpec {
81
+ openapi: string;
82
+ info: { title: string; version: string };
83
+ tags?: Array<{ name: string; description?: string }>;
84
+ paths: Record<string, OpenApiPathItem>;
85
+ components?: {
86
+ schemas?: Record<string, OpenApiPropertySchema>;
87
+ };
88
+ }
89
+
90
+ // ─── Analyzed endpoint ───────────────────────────────────────────────────────
91
+
92
+ export interface EndpointInfo {
93
+ operationId: string;
94
+ method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
95
+ path: string;
96
+ tags: string[];
97
+ summary?: string;
98
+ description?: string;
99
+ intent: Intent;
100
+ /** Resolved (no $ref) request body schema for POST/PUT/PATCH */
101
+ requestBodySchema?: OpenApiSchema;
102
+ /** Resolved (no $ref) successful response schema (first 2xx) */
103
+ responseSchema?: OpenApiSchema;
104
+ hasPathParams: boolean;
105
+ pathParams: string[];
106
+ }
107
+
108
+ // ─── Form field definition ───────────────────────────────────────────────────
109
+
110
+ export type FieldType = 'input' | 'textarea' | 'select' | 'checkbox' | 'datepicker' | 'number';
111
+
112
+ export interface FormFieldDef {
113
+ key: string;
114
+ label: string;
115
+ type: FieldType;
116
+ required: boolean;
117
+ options?: { label: string; value: string }[];
118
+ placeholder?: string;
119
+ hidden?: boolean;
120
+ /** Zod expression string, e.g. 'z.string().min(1)' */
121
+ zodExpression: string;
122
+ }
123
+
124
+ // ─── Table column definition ─────────────────────────────────────────────────
125
+
126
+ export type ColumnType = 'text' | 'number' | 'date' | 'boolean' | 'badge';
127
+
128
+ export interface ColumnDef {
129
+ key: string;
130
+ label: string;
131
+ type: ColumnType;
132
+ }
133
+
134
+ // ─── Resource ────────────────────────────────────────────────────────────────
135
+
136
+ export interface ResourceInfo {
137
+ /** Normalized resource name, PascalCase. E.g. 'Pet', 'Store' */
138
+ name: string;
139
+ /** Tag name as it appears in the spec. E.g. 'pet', 'store' */
140
+ tag: string;
141
+ /** Generated connector composable name. E.g. 'usePetsConnector' */
142
+ composableName: string;
143
+
144
+ endpoints: EndpointInfo[];
145
+
146
+ /** The one endpoint detected as list (GET array) */
147
+ listEndpoint?: EndpointInfo;
148
+ /** The one endpoint detected as detail (GET single object) */
149
+ detailEndpoint?: EndpointInfo;
150
+ /** The one endpoint detected as create (POST) */
151
+ createEndpoint?: EndpointInfo;
152
+ /** The one endpoint detected as update (PUT/PATCH) */
153
+ updateEndpoint?: EndpointInfo;
154
+ /** The one endpoint detected as delete (DELETE) */
155
+ deleteEndpoint?: EndpointInfo;
156
+
157
+ /** Columns inferred from the list/detail response schema */
158
+ columns: ColumnDef[];
159
+
160
+ /** Form fields inferred from the request body schema */
161
+ formFields: {
162
+ create?: FormFieldDef[];
163
+ update?: FormFieldDef[];
164
+ };
165
+
166
+ /**
167
+ * Zod schema object expression strings, ready to embed in generated code.
168
+ * E.g. "z.object({\n name: z.string().min(1),\n ....\n})"
169
+ */
170
+ zodSchemas: {
171
+ create?: string;
172
+ update?: string;
173
+ };
174
+ }
175
+
176
+ /** One entry per tag (or path-prefix fallback) */
177
+ export type ResourceMap = Map<string, ResourceInfo>;