packages/
mizan-runtime/ Framework-agnostic state engine (~150 lines)
Context registry, batched invalidation, fetch primitives
mizan-django/ Django server adapter (was packages/mizan-rpc/adapters/django/)
Codegen moved to mizan-django/generate/
mizan-react/ React adapter (was packages/mizan-csr/adapters/react/)
Removed premature abstractions: mizan-ast, mizan-schema, mizan-rpc,
mizan-csr, mizan-ssr stub packages. The actual architecture is three
concrete packages, not five abstract layers.
mizan-runtime implements the v1 spec: registerContext with params,
scoped invalidation via microtask batching, server-driven invalidation
from mutation responses, mizanFetch for context bundles, mizanCall for
mutations.
264 Django + 33 React tests pass.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
116 lines
3.1 KiB
TypeScript
116 lines
3.1 KiB
TypeScript
/**
|
|
* mizan - Django Server Functions Client
|
|
*
|
|
* Frontend client for Django server functions.
|
|
* Server functions are the core primitive - accessed via React hooks.
|
|
*
|
|
* Two-layer architecture:
|
|
*
|
|
* 1. Library layer (this package) - Generic name-based API
|
|
* Used by libraries like Allauth that need to call functions by name.
|
|
*
|
|
* import { useMizan, useMizanContext, useMizanCall } from 'mizan'
|
|
* const user = useMizanContext('current_user')
|
|
* const call = useMizanCall('update_profile')
|
|
*
|
|
* 2. Generated layer (@/api) - Typed project-specific API
|
|
* Used by product code for type-safe hooks.
|
|
*
|
|
* import { useCurrentUser, useUpdateProfile } from '@/api'
|
|
* const user = useCurrentUser()
|
|
* const updateProfile = useUpdateProfile()
|
|
*
|
|
* The generated code wraps MizanProvider and adds type-safe hooks.
|
|
*/
|
|
|
|
// ============================================================================
|
|
// React Context & Hooks (primary API)
|
|
// ============================================================================
|
|
|
|
export {
|
|
// Provider
|
|
MizanProvider,
|
|
type MizanProviderProps,
|
|
type MizanHydration,
|
|
|
|
// Hooks (generic name-based API for libraries)
|
|
useMizan,
|
|
useMizanContext,
|
|
useMizanCall,
|
|
useMizanStatus,
|
|
usePush,
|
|
|
|
// Types
|
|
type MizanContextValue,
|
|
type ConnectionStatus,
|
|
type PushMessage,
|
|
type PushListener,
|
|
type ContextStore,
|
|
type Transport,
|
|
|
|
// Legacy aliases (deprecated, for migration)
|
|
DjangoContext,
|
|
useDjango,
|
|
useDjangoStatus,
|
|
useServerFunction,
|
|
type DjangoContextValue,
|
|
type DjangoContextProps,
|
|
} from './context'
|
|
|
|
// ============================================================================
|
|
// HTTP Client (for SSR or non-React usage)
|
|
// ============================================================================
|
|
|
|
export {
|
|
httpFunctionCall,
|
|
createDjangoCSRClient,
|
|
createDjangoSSRClient,
|
|
ensureDjangoSession,
|
|
Auth,
|
|
type DjangoHTTPClient,
|
|
type CSRClientConfig,
|
|
type JWTClientConfig,
|
|
type SSRClientConfig,
|
|
} from './client/'
|
|
|
|
// ============================================================================
|
|
// Errors
|
|
// ============================================================================
|
|
|
|
export {
|
|
DjangoError,
|
|
type FunctionErrorResponse,
|
|
type ErrorCode,
|
|
} from './errors'
|
|
|
|
// ============================================================================
|
|
// Forms (typed form hooks core)
|
|
// ============================================================================
|
|
|
|
export {
|
|
// Single form
|
|
useMizanFormCore,
|
|
// Legacy alias
|
|
useMizanFormCore as useDjangoFormCore,
|
|
type DjangoFormState,
|
|
type FormSchema,
|
|
type FormErrors,
|
|
type FormOptions,
|
|
type FormSubmitResult,
|
|
type FormCoreConfig,
|
|
// Formset
|
|
useMizanFormsetCore,
|
|
// Legacy alias
|
|
useMizanFormsetCore as useDjangoFormsetCore,
|
|
type DjangoFormsetState,
|
|
type FormsetSchema,
|
|
type FormsetErrors,
|
|
type FormsetCoreConfig,
|
|
type FormsetSubmitResult,
|
|
// Shared types
|
|
type FieldSchema,
|
|
type FieldChoice,
|
|
type FieldError,
|
|
type FormMeta,
|
|
} from './forms'
|