@uigen-dev/react 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +312 -0
- package/dist/assets/index-DDpgMB3g.js +181 -0
- package/dist/assets/index-eM06UHvs.css +1 -0
- package/dist/index.html +16 -0
- package/package.json +73 -0
package/README.md
ADDED
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
# UIGen
|
|
2
|
+
|
|
3
|
+
> Point it at an OpenAPI spec. Get a fully functional frontend. Zero boilerplate.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npx @uigen/cli serve ./openapi.yaml
|
|
7
|
+
# → Your UI is live at http://localhost:4400
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
No code. No config. No boilerplate. Just a spec.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## What you get
|
|
15
|
+
|
|
16
|
+
From a single OpenAPI file, UIGen generates a complete, production-quality frontend:
|
|
17
|
+
|
|
18
|
+
- **Sidebar navigation** — auto-built from your API resources
|
|
19
|
+
- **Fully interactive** — all API calls are live, hitting your real endpoints via a built-in proxy
|
|
20
|
+
- **Table views** — data from your GET endpoints, with sorting, pagination, and filtering
|
|
21
|
+
- **Create & edit forms** — fields, types, and validation derived from your schema
|
|
22
|
+
- **Detail views** — read-only record display with related resource links
|
|
23
|
+
- **Delete with confirmation** — one-click delete with a safety dialog
|
|
24
|
+
- **Authentication** — Bearer token, API Key, HTTP Basic, and credential-based login flows — persisted across sessions
|
|
25
|
+
- **Multi-step wizards** — auto-split for large forms (8+ fields)
|
|
26
|
+
- **Custom action buttons** — non-CRUD endpoints like `POST /users/{id}/activate`
|
|
27
|
+
- **Search views** — per-resource filtered search from query params in your spec
|
|
28
|
+
- **Dashboard** — overview of all resources with record counts
|
|
29
|
+
- **Environment switching** — dropdown from your spec's `servers` list
|
|
30
|
+
- **Dark / light theme** — built-in toggle, persisted to local storage
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Quick Start
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# Run directly with npx — no install required
|
|
39
|
+
npx @uigen/cli serve ./openapi.yaml
|
|
40
|
+
|
|
41
|
+
# Or with a remote spec URL
|
|
42
|
+
npx @uigen/cli serve https://petstore3.swagger.io/api/v3/openapi.json
|
|
43
|
+
|
|
44
|
+
# Custom port
|
|
45
|
+
npx @uigen/cli serve ./openapi.yaml --port 8080
|
|
46
|
+
|
|
47
|
+
# Override the target server
|
|
48
|
+
npx @uigen/cli serve ./openapi.yaml --proxy-base https://api.yourapp.com
|
|
49
|
+
|
|
50
|
+
# Choose a renderer (default: react)
|
|
51
|
+
npx @uigen/cli serve ./openapi.yaml --renderer react
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Visit `http://localhost:4400` to see your generated UI.
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Live Demo
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
git clone https://github.com/darula-hpp/uigen
|
|
62
|
+
cd uigen
|
|
63
|
+
pnpm install && pnpm build
|
|
64
|
+
node packages/cli/dist/index.js serve examples/twilio_messaging_v1.yaml
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## How it works
|
|
70
|
+
|
|
71
|
+
UIGen parses your OpenAPI spec and converts it into an **Intermediate Representation (IR)** — a structured description of your resources, operations, schemas, authentication, and relationships. A pre-built React SPA reads that IR and renders the appropriate views. A Vite dev server serves the SPA and proxies your API calls to your real backend.
|
|
72
|
+
|
|
73
|
+
Because the IR is framework-agnostic, the React layer is just the default. The same IR drives `@uigen/svelte` and `@uigen/vue` — same spec, different renderer, your choice of stack.
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
OpenAPI Spec (YAML/JSON)
|
|
77
|
+
│
|
|
78
|
+
▼
|
|
79
|
+
Adapter (parser)
|
|
80
|
+
│
|
|
81
|
+
▼
|
|
82
|
+
IR (typed config)
|
|
83
|
+
│
|
|
84
|
+
▼
|
|
85
|
+
React SPA (renderer)
|
|
86
|
+
│
|
|
87
|
+
▼ live API calls via proxy
|
|
88
|
+
Your API
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
The IR is the contract. Everything built on top of UIGen talks to the IR — not to the spec format or the UI framework.
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## Supported Specs
|
|
96
|
+
|
|
97
|
+
| Format | Status |
|
|
98
|
+
|---|---|
|
|
99
|
+
| OpenAPI 3.x (YAML/JSON) | ✅ Supported |
|
|
100
|
+
| Swagger 2.0 | ✅ Supported |
|
|
101
|
+
| OpenAPI 3.1 | 🔜 Planned |
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## What's implemented today
|
|
106
|
+
|
|
107
|
+
### Core engine
|
|
108
|
+
- [x] OpenAPI 3.x adapter — full schema resolution, `$ref` handling, circular reference detection
|
|
109
|
+
- [x] Swagger 2.0 adapter
|
|
110
|
+
- [x] IR types — resources, operations, auth, relationships, pagination hints, validation rules
|
|
111
|
+
- [x] View hint classifier — detects list, detail, create, update, delete, search, wizard, action
|
|
112
|
+
- [x] Relationship detector — `hasMany` from nested paths, `belongsTo` from URI fields
|
|
113
|
+
- [x] Pagination detector — offset, cursor, and page-based strategies
|
|
114
|
+
- [x] Graceful degradation — malformed operations are skipped, not crashed
|
|
115
|
+
|
|
116
|
+
### Views
|
|
117
|
+
- [x] **ListView** — TanStack Table, sorting, pagination, row actions, empty state, filter row
|
|
118
|
+
- [x] **DetailView** — read-only fields, related resource links, edit/delete/custom action buttons
|
|
119
|
+
- [x] **FormView** — React Hook Form + Zod validation, all field types, inline errors, loading state
|
|
120
|
+
- [x] **EditFormView** — pre-populated from current record data, PUT/PATCH on submit
|
|
121
|
+
- [x] **SearchView** — filter inputs per query param, result count, clear filters
|
|
122
|
+
- [x] **DashboardView** — resource cards with record counts and navigation links
|
|
123
|
+
- [x] **WizardView** — multi-step form for large schemas, step validation, back navigation
|
|
124
|
+
- [x] **LoginView** — auth credential input before accessing protected resources
|
|
125
|
+
|
|
126
|
+
### Field components
|
|
127
|
+
- [x] TextField (with `textarea` variant)
|
|
128
|
+
- [x] NumberField (with min/max enforcement)
|
|
129
|
+
- [x] CheckboxField
|
|
130
|
+
- [x] SelectField (enum values, `x-enumNames` support)
|
|
131
|
+
- [x] DatePicker / DateTimePicker
|
|
132
|
+
- [x] FileUpload (drag-and-drop, progress display)
|
|
133
|
+
- [x] ArrayField (add/remove items, length validation)
|
|
134
|
+
- [x] ObjectField (nested fieldsets, collapsible)
|
|
135
|
+
|
|
136
|
+
### Auth & infrastructure
|
|
137
|
+
- [x] Bearer token authentication — input, session storage, `Authorization` header injection, logout
|
|
138
|
+
- [x] API Key authentication — header and query param injection
|
|
139
|
+
- [x] HTTP Basic authentication — username/password, base64 encoded
|
|
140
|
+
- [x] Credential-based login — detects login endpoints from spec, posts credentials, extracts token
|
|
141
|
+
- [x] Server selector — environment dropdown from spec `servers`
|
|
142
|
+
- [x] Delete confirmation dialog
|
|
143
|
+
- [x] Custom action buttons (non-CRUD endpoints)
|
|
144
|
+
- [x] Toast notifications (success / error / warning / info, auto-dismiss)
|
|
145
|
+
- [x] Error boundary — component errors contained, app stays running
|
|
146
|
+
- [x] Dark / light theme toggle with system preference detection
|
|
147
|
+
|
|
148
|
+
### CLI
|
|
149
|
+
- [x] `uigen serve` — starts dev server with IR injected
|
|
150
|
+
- [x] YAML / JSON auto-detection
|
|
151
|
+
- [x] Vite proxy to real API server
|
|
152
|
+
- [x] CORS handling
|
|
153
|
+
- [x] Verbose logging flag
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## Project Structure
|
|
158
|
+
|
|
159
|
+
```
|
|
160
|
+
uigen/
|
|
161
|
+
├── packages/
|
|
162
|
+
│ ├── core/ # Framework-agnostic: adapters, IR types, engine
|
|
163
|
+
│ ├── react/ # Opinionated React UI layer
|
|
164
|
+
│ └── cli/ # CLI entry point (Commander.js)
|
|
165
|
+
├── examples/
|
|
166
|
+
│ └── petstore.yaml # Demo OpenAPI spec
|
|
167
|
+
└── pnpm-workspace.yaml
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Each package is independently publishable:
|
|
171
|
+
|
|
172
|
+
| Package | npm | Purpose |
|
|
173
|
+
|---|---|---|
|
|
174
|
+
| `@uigen/core` | soon | IR types, adapters, engine — framework agnostic. Build your own renderer on top |
|
|
175
|
+
| `@uigen/react` | soon | The default React renderer. Extend or swap components via the registry |
|
|
176
|
+
| `@uigen/cli` | soon | The `npx uigen` entry point |
|
|
177
|
+
| `@uigen/svelte` | planned | Svelte renderer — same IR, native Svelte components |
|
|
178
|
+
| `@uigen/vue` | planned | Vue 3 renderer — same IR, native Vue components |
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## Development
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
# Install dependencies
|
|
186
|
+
pnpm install
|
|
187
|
+
|
|
188
|
+
# Build all packages
|
|
189
|
+
pnpm build
|
|
190
|
+
|
|
191
|
+
# Run type checking
|
|
192
|
+
pnpm typecheck
|
|
193
|
+
|
|
194
|
+
# Run tests
|
|
195
|
+
pnpm test
|
|
196
|
+
|
|
197
|
+
# Run tests in watch mode
|
|
198
|
+
pnpm test:watch
|
|
199
|
+
|
|
200
|
+
# Run tests with coverage
|
|
201
|
+
pnpm test:coverage
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## Extending UIGen
|
|
207
|
+
|
|
208
|
+
### Custom field components
|
|
209
|
+
|
|
210
|
+
Register your own component for any field type — without touching the rest of the tool:
|
|
211
|
+
|
|
212
|
+
```tsx
|
|
213
|
+
import { registry } from '@uigen/react';
|
|
214
|
+
import { MyMapField } from './fields/MapField';
|
|
215
|
+
|
|
216
|
+
registry.register('geo', MyMapField);
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Spec annotations (`x-uigen-*`)
|
|
220
|
+
|
|
221
|
+
> Coming in the next release
|
|
222
|
+
|
|
223
|
+
Annotate your OpenAPI spec directly to control how fields are rendered:
|
|
224
|
+
|
|
225
|
+
```yaml
|
|
226
|
+
properties:
|
|
227
|
+
description:
|
|
228
|
+
type: string
|
|
229
|
+
x-uigen-widget: textarea
|
|
230
|
+
x-uigen-label: "Product Description"
|
|
231
|
+
internal_code:
|
|
232
|
+
type: string
|
|
233
|
+
x-uigen-hidden: true
|
|
234
|
+
status:
|
|
235
|
+
type: string
|
|
236
|
+
x-uigen-order: 1
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### Configuration file
|
|
240
|
+
|
|
241
|
+
> Coming soon
|
|
242
|
+
|
|
243
|
+
```json
|
|
244
|
+
// uigen.config.json
|
|
245
|
+
{
|
|
246
|
+
"theme": {
|
|
247
|
+
"primary": "hsl(220, 90%, 56%)",
|
|
248
|
+
"font": "Geist"
|
|
249
|
+
},
|
|
250
|
+
"resources": {
|
|
251
|
+
"users": { "label": "Team Members", "defaultPageSize": 50 }
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## Roadmap
|
|
259
|
+
|
|
260
|
+
### 🔜 Next up
|
|
261
|
+
- [ ] `x-uigen-*` vendor extension support — annotate your spec to customize rendering
|
|
262
|
+
- [ ] `uigen.config.json` — theme, labels, page sizes, field overrides
|
|
263
|
+
- [ ] `uigen validate` — lint your spec, report what can and can't be generated with actionable errors
|
|
264
|
+
- [ ] `uigen generate` — output a static production build to a directory
|
|
265
|
+
- [ ] OAuth2 PKCE flow — full login for OAuth2-secured APIs
|
|
266
|
+
- [ ] Spec hot-reload — file watcher pushes updated IR to UI via WebSocket, no restart needed
|
|
267
|
+
- [ ] Loading skeletons — shimmer placeholders matching actual content layout
|
|
268
|
+
- [ ] Virtual scrolling — TanStack Virtual for tables with 1000+ rows
|
|
269
|
+
|
|
270
|
+
### 🧩 Ecosystem
|
|
271
|
+
- [ ] **`@uigen/svelte`** — Svelte renderer consuming the same IR. Same adapters, different UI layer
|
|
272
|
+
- [ ] **`@uigen/vue`** — Vue 3 renderer. Drop-in alternative to `@uigen/react`
|
|
273
|
+
- [ ] **Plugin API** — register custom adapters, field types, and view strategies as npm packages
|
|
274
|
+
- [ ] **`uigen ui:config`** — a visual configuration dashboard served alongside your generated UI. Point-and-click theme editing, field label overrides, resource reordering — no YAML editing required
|
|
275
|
+
|
|
276
|
+
### ☁️ Cloud (planned)
|
|
277
|
+
- [ ] **uigen.cloud** — hosted UIGen. Point at your spec URL, get a shareable, live frontend at a custom domain — no local setup required
|
|
278
|
+
- [ ] **GitHub Action** — auto-deploy your generated UI when your spec changes in CI
|
|
279
|
+
- [ ] **Enterprise tier** — SSO/SAML, audit logs, RBAC, on-prem deployment
|
|
280
|
+
|
|
281
|
+
### 🔭 Further out
|
|
282
|
+
- [ ] OpenAPI 3.1 support
|
|
283
|
+
- [ ] GraphQL adapter
|
|
284
|
+
- [ ] gRPC / Protobuf adapter
|
|
285
|
+
- [ ] Response transformation — JSONPath selectors to reshape API responses before rendering
|
|
286
|
+
- [ ] Request / response interceptors — middleware for custom auth logic or tenant injection
|
|
287
|
+
- [ ] `@uigen/plugin-charts` — auto-generate chart widgets from numeric data
|
|
288
|
+
- [ ] `@uigen/plugin-mapbox` — map field renderer for geo coordinates
|
|
289
|
+
|
|
290
|
+
---
|
|
291
|
+
|
|
292
|
+
## Known limitations
|
|
293
|
+
|
|
294
|
+
- Schema `$ref` resolution works for most cases; deeply nested circular refs may degrade gracefully
|
|
295
|
+
- Edit view pre-population requires a `GET /resource/{id}` endpoint in your spec
|
|
296
|
+
- Authentication UI covers Bearer, API Key, HTTP Basic, and credential-based login — OAuth2 PKCE is in progress
|
|
297
|
+
- Sub-resources (e.g. `/services/{id}/members`) appear in the sidebar only when viewing a parent detail page
|
|
298
|
+
- Error messages are informative but not yet fully localised
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
## Contributing
|
|
303
|
+
|
|
304
|
+
Issues and PRs are welcome. See [ARCHITECTURE.md](./ARCHITECTURE.md) for the full design documentation.
|
|
305
|
+
|
|
306
|
+
> **Building a renderer for another framework?** The `@uigen/core` package is the only dependency you need. The IR contract is stable.
|
|
307
|
+
|
|
308
|
+
---
|
|
309
|
+
|
|
310
|
+
## License
|
|
311
|
+
|
|
312
|
+
MIT
|