42 lines
934 B
Python
42 lines
934 B
Python
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass
|
|
from typing import Any, Dict
|
|
|
|
|
|
@dataclass
|
|
class Object:
|
|
name: str
|
|
data: Dict[str, Any]
|
|
|
|
|
|
@dataclass
|
|
class Morphism:
|
|
name: str
|
|
input_schema: Dict[str, Any]
|
|
output_schema: Dict[str, Any]
|
|
|
|
|
|
@dataclass
|
|
class Functor:
|
|
name: str
|
|
map_func: object # Callable to map between schemas
|
|
|
|
|
|
class DataContractLayer:
|
|
"""Minimal scaffold for the data-contract layer (Objs, Morphs, Functors)."""
|
|
|
|
def __init__(self) -> None:
|
|
self.objects: Dict[str, Object] = {}
|
|
self.morphisms: Dict[str, Morphism] = {}
|
|
self.functors: Dict[str, Functor] = {}
|
|
|
|
def register_object(self, obj: Object) -> None:
|
|
self.objects[obj.name] = obj
|
|
|
|
def register_morphism(self, morph: Morphism) -> None:
|
|
self.morphisms[morph.name] = morph
|
|
|
|
def register_functor(self, f: Functor) -> None:
|
|
self.functors[f.name] = f
|