Skip to content

v0.1.0-Beta.5 🚀

Pre-release
Pre-release

Choose a tag to compare

@alialfostovar alialfostovar released this 13 Jul 15:07
· 349 commits to master since this release
7f50572

Welcome to v0.1.0-beta.5 of the ZCore Framework! This release represents a significant architectural evolution, centering on Engineered Simplicity (KISS). We have deprecated complex, reflection-based configuration variables and brittle runtime hacks, replacing them with standard Object-Oriented patterns, native Pydantic V2 integrations, and cleaner dependency structures.


🚀 Core Features & Enhancements

🛡️ Unified Schema Security (Zchema)

We have completely overhaulled our data pruning and shielding mechanisms. Previously, data masking was handled globally in the web layer via a generic resource.* prefix, which was prone to namespace collisions.

  • The Zchema Class: All schemas now inherit from Zchema (extending BaseModel).
  • Domain-Specific Namespacing: You now define a class-level __db_name__ attribute (e.g., __db_name__ = "user").
  • 3-Tier Protection: Zchema handles security natively within Pydantic boundaries:
    1. Dynamic Schemas (?schema=true): Automatically prunes restricted fields from the exposed JSON Schema.
    2. Input Filtering: Automatically strips restricted fields from incoming payloads, defending against Mass Assignment.
    3. Response Pruning: Automatically masks fields during serialization.

🚦 Template Method Service Hooks

To guarantee that business-critical pre_ and post_ lifecycle hooks and transaction boundaries are never skipped, we separated orchestration from execution.

  • Custom Database Operations: Developers now override dedicated on_create, on_update, and on_delete callback hooks instead of overriding the public create() orchestrator.
  • The orchestrator guarantees that validation, hooks, and transaction commits (_safe_commit) are executed in the exact correct order.

🔗 FastAPI-Native Route Dependencies

We have conceptually renamed the routing security layer from "Permissions" to "Dependencies", matching FastAPI's design.

  • Removed 8 static class variables (DEFAULT_PERMISSIONS, POST_PERMISSIONS, etc.).
  • Introduced a single, elegant factory method: get_route_dependencies(self, route_key: RouteKey, action: str) -> list[Any].
  • Developers can now use standard Python inheritance and super() to customize specific endpoints while maintaining default scopes for others.

📦 Robust Modular Monolith Imports

Resolved ModuleNotFoundError across nested modules (such as importing from shared/ within modules/identity/) using a 3-layer approach:

  1. CLI: Auto-injects the root into PYTHONPATH during zc run.
  2. Runtime: Bootstraps sys.path dynamically at the top of main.py.
  3. IDE: Generates PYTHONPATH=. in .env to eliminate warning lines in VSCode/PyCharm.

⚠️ Breaking Changes & Migration Guide

1. Schema Base Class Update

You must replace BaseModel with Zchema and define __db_name__ on your schemas.

  • Old:
    from pydantic import BaseModel
    class UserResponse(BaseModel):
        email: str
  • New:
    from zcore import Zchema
    class UserResponse(Zchema):
        __db_name__ = "user"
        email: str

2. Router Security Configuration

Static permission variables have been deprecated. Move your custom security logic to the new factory method.

  • Old:
    class ProductRouter(BaseRouter):
        DEFAULT_PERMISSIONS = "AUTO"
        DELETE_PERMISSIONS = [AdminOnly()]
  • New:
    class ProductRouter(BaseRouter):
        def get_route_dependencies(self, route_key: RouteKey, action: str):
            if route_key == RouteKey.DELETE:
                return [AdminOnly()]
            return super().get_route_dependencies(route_key, action)

3. Service Overrides

If you previously overrode create, update, or delete directly, move that database logic to the corresponding on_ hook.

  • Old:
    async def create(self, schema: ProductCreate):
        return await self.repository.create(schema)
  • New:
    async def on_create(self, schema: ProductCreate) -> Product:
        return await self.repository.create(schema)

🐛 Bug Fixes & Refactoring

  • Fixed ModuleNotFoundError in subfolders of modular directory layouts (#53).
  • Corrected IoCContainer resolution for Annotated type hints and manual request-scope instance registration (#48).
  • Simplified ZCoreJSONResponse and removed ResponseProjector to avoid redundant serialization overhead.