Two-stage codegen: React + Vue + Svelte from one schema
Stage 1 (framework-agnostic):
types.ts — OpenAPI interfaces
contexts/<name>.ts — fetchXxxContext(params) using mizanFetch
mutations/<name>.ts — callXxx(args) using mizanCall
functions/<name>.ts — callXxx(args) using mizanCall
index.ts — re-exports
Stage 2 (per framework):
react.tsx — hooks + context providers + SSR hydration
vue.ts — composables with provide/inject + ref/computed
svelte.ts — writable/derived store factories
New packages:
mizan-runtime — the kernel (~200 lines, zero framework deps)
configure(), initSession(), registerContext(), invalidate(),
mizanFetch(), mizanCall(), MizanError
mizan-vue — Vue adapter (package.json, codegen template)
mizan-svelte — Svelte adapter (package.json, codegen template)
CLI: mizan-generate --target react,vue,svelte
Config: target: 'react' (default) in django.config.mjs
Verified: codegen produces 33 functions across 2 contexts,
14 plain functions, 0 mutations, generating all three Stage 2
outputs from one schema fetch.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
17
examples/django-react-site/harness/src/api/contexts/local.ts
Normal file
17
examples/django-react-site/harness/src/api/contexts/local.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
// AUTO-GENERATED by mizan — do not edit
|
||||
|
||||
import { mizanFetch } from '@mizan/runtime'
|
||||
|
||||
import type { greetOutput } from '../types'
|
||||
|
||||
export interface LocalContextData {
|
||||
greet: greetOutput
|
||||
}
|
||||
|
||||
export interface LocalContextParams {
|
||||
name: string
|
||||
}
|
||||
|
||||
export function fetchLocalContext(params: LocalContextParams): Promise<LocalContextData> {
|
||||
return mizanFetch('local', params)
|
||||
}
|
||||
Reference in New Issue
Block a user