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:
2026-04-07 12:09:35 -04:00
parent 6108845d99
commit c20de182e1
35 changed files with 6009 additions and 817 deletions

View File

@@ -1,97 +1,21 @@
/**
* mizan API - Consolidated Exports
*
* Import everything from here:
*
* @example
* ```tsx
* import {
* MizanContext,
* useCurrentUser,
* useEcho,
* useChatChannel,
* } from '@/api'
* ```
*/
// AUTO-GENERATED by mizan — do not edit
// AUTO-GENERATED by mizan - do not edit manually
// Regenerate with: npm run schemas
export * from './types'
// =============================================================================
// mizan Provider & Hooks
// =============================================================================
export { fetchGlobalContext, type GlobalContextData, type GlobalContextParams } from './contexts/global'
export { fetchLocalContext, type LocalContextData, type LocalContextParams } from './contexts/local'
export {
getMizanHydration,
getDjangoHydration,
type MizanHydrationData,
type DjangoHydration,
} from './generated.server'
export {
// Provider
MizanContext,
type MizanContextProps,
DjangoContext,
type DjangoContextProps,
// Global context hooks
useCurrentUser,
// Refresh hooks
useMizanRefresh,
useDjangoRefresh,
// Named context providers
LocalContext,
useGreet,
// Function hooks
useEcho,
useAdd,
useWhoami,
useHttpOnlyEcho,
useStaffOnly,
useSuperuserOnly,
useVerifiedOnly,
useMultiply,
useNotImplementedFn,
useBuggyFn,
usePermissionCheckFn,
useWsWhoami,
useJwtObtain,
useJwtRefresh,
// Re-exports from mizan library
useMizan,
useMizanStatus,
usePush,
DjangoError,
type ConnectionStatus,
type PushMessage,
type PushListener,
} from './generated.provider'
// =============================================================================
// Channel Hooks
// =============================================================================
export {
useChatChannel,
useNotificationsChannel,
usePresenceChannel,
usePrivateChannel,
} from './generated.channels.hooks'
// =============================================================================
// Channel Types
// =============================================================================
export type {
ChatParams,
ChatReactMessage,
ChatDjangoMessage,
NotificationsDjangoMessage,
PresenceDjangoMessage,
PrivateDjangoMessage,
} from './generated.channels'
export { callEcho } from './functions/echo'
export { callAdd } from './functions/add'
export { callWhoami } from './functions/whoami'
export { callHttpOnlyEcho } from './functions/httpOnlyEcho'
export { callStaffOnly } from './functions/staffOnly'
export { callSuperuserOnly } from './functions/superuserOnly'
export { callVerifiedOnly } from './functions/verifiedOnly'
export { callMultiply } from './functions/multiply'
export { callNotImplementedFn } from './functions/notImplementedFn'
export { callBuggyFn } from './functions/buggyFn'
export { callPermissionCheckFn } from './functions/permissionCheckFn'
export { callWsWhoami } from './functions/wsWhoami'
export { callJwtObtain } from './functions/jwtObtain'
export { callJwtRefresh } from './functions/jwtRefresh'