Skip to main content

Core domain abstractions for varco (models, mapper, meta, query)

Project description

varco-core

Backend-agnostic domain model and service layer for varco.

Provides the pure-Python building blocks that all backend packages depend on — no ORM imports at the core layer.

What lives here

Module Purpose
model.py DomainModel, AuditedDomainModel, VersionedDomainModel, SoftDeleteMixin, TenantMixin and derived classes
meta.py FieldHint, ForeignKey, PrimaryKey, PKStrategy, constraints, pk_field()
mapper.py AbstractMapper — bidirectional ORM ↔ domain translation
repository.py AsyncRepository ABC — CRUD + exists() + stream_by_query()
uow.py AsyncUnitOfWork ABC
registry.py DomainModelRegistry + @register decorator
providers.py RepositoryProvider ABC
assembler.py AbstractDTOAssembler[D, C, R, U]
service/base.py AsyncService, IUoWProvider
service/tenant.py TenantAwareService, TenantUoWProvider, tenant_context
service/soft_delete.py SoftDeleteService
service/types.py Assembler alias, ServiceProtocol
auth/ AbstractAuthorizer, Action, AuthContext, ResourceGrant
auth/helpers.py GrantBasedAuthorizer, OwnershipAuthorizer, RoleBasedAuthorizer
exception/codes.py FastrestErrorCodes enum, ErrorCode
exception/http.py ErrorMessage, error_message_for, register_error_code
tracing.py correlation_context, current_correlation_id, CorrelationIdFilter
query/ QueryBuilder, QueryParams, QueryParser, AST visitors

Install

pip install varco-core

Quick start

from __future__ import annotations
from typing import Annotated
from varco_core import AuditedDomainModel
from varco_core.meta import FieldHint, PrimaryKey, PKStrategy, pk_field

class Post(AuditedDomainModel):
    pk: Annotated[int, PrimaryKey(PKStrategy.INT_AUTO)] = pk_field()
    title: Annotated[str, FieldHint(max_length=200)]
    body: str
    published: bool = False

Install varco-sa or varco-beanie for a concrete backend, then wire a service:

from varco_core import AsyncService, IUoWProvider
from varco_core.assembler import AbstractDTOAssembler
from varco_core.auth import AbstractAuthorizer
from providify import Inject, Singleton

@Singleton
class PostService(AsyncService[Post, int, CreatePostDTO, PostReadDTO, UpdatePostDTO]):
    def __init__(
        self,
        uow_provider: Inject[IUoWProvider],
        authorizer:   Inject[AbstractAuthorizer],
        assembler:    Inject[AbstractDTOAssembler[Post, CreatePostDTO, PostReadDTO, UpdatePostDTO]],
    ) -> None:
        super().__init__(uow_provider=uow_provider, authorizer=authorizer, assembler=assembler)

    def _get_repo(self, uow): return uow.posts

See the root README for the full documentation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

varco_core-0.0.1.tar.gz (162.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

varco_core-0.0.1-py3-none-any.whl (210.8 kB view details)

Uploaded Python 3

File details

Details for the file varco_core-0.0.1.tar.gz.

File metadata

  • Download URL: varco_core-0.0.1.tar.gz
  • Upload date:
  • Size: 162.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.11.11 Linux/6.6.87.2-microsoft-standard-WSL2

File hashes

Hashes for varco_core-0.0.1.tar.gz
Algorithm Hash digest
SHA256 4ff1f34015ec174dbccf9bb882f3d643e3956e77f685fb783f535a4e4a21a34a
MD5 fb4057f1acb71fd01bbdbfd7cab78849
BLAKE2b-256 bf40cba5e9b45fcb9fee4d8efaf77d6e1b1ba11898c3658610e40a55dd6fc056

See more details on using hashes here.

File details

Details for the file varco_core-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: varco_core-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 210.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.11.11 Linux/6.6.87.2-microsoft-standard-WSL2

File hashes

Hashes for varco_core-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3bd2bb8337fecda572537511b165f5b4d1d53792b24e4a74e0216d224209847f
MD5 33f0585fdad89f2dd05d3427edf43a1b
BLAKE2b-256 e38b4b1ee200ad389f6821ae3ccd85e6f57299197cbd42dc2cb47a0c9541b199

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page