Initial project import

This commit is contained in:
2026-08-14 09:40:51 +03:00
parent 00040e5ce4
commit d7099bf80d
146 changed files with 30509 additions and 1055 deletions
+1
View File
@@ -0,0 +1 @@
"""Typed write-dispatch contracts for the SQL-only 1C adapter."""
+20
View File
@@ -0,0 +1,20 @@
"""Explicit adapter services available to typed write handlers."""
from __future__ import annotations
from collections.abc import Callable
from dataclasses import dataclass
from typing import Any
@dataclass(frozen=True)
class AdapterWriteContext:
"""Migration boundary: handlers receive services, never server globals.
`legacy_scheduled_job_writer` is temporary while the existing proven
implementation is characterized. It prevents the dispatcher from keeping
a direct dependency on that writer and is replaced by granular services
when the implementation body moves into the handler.
"""
legacy_scheduled_job_writer: Callable[[dict[str, Any]], dict[str, Any]]
+14
View File
@@ -0,0 +1,14 @@
"""Stable contracts shared by the universal dispatcher and typed handlers."""
from __future__ import annotations
from dataclasses import dataclass
@dataclass(frozen=True)
class WriteHandler:
"""A supported public write surface, not an SQL implementation detail."""
key: str
public_target_kind: str
operation: str | None = None
@@ -0,0 +1,5 @@
"""Typed write-handler declarations.
Implementations are migrated here one at a time after their existing adapter
tests become handler-level characterization tests.
"""
@@ -0,0 +1,5 @@
from write.contracts import WriteHandler
# Element, command/button, and embedded-module routing needs decoded form
# evidence, so it remains a sub-dispatch inside this public form surface.
HANDLER = WriteHandler("form", "form")
@@ -0,0 +1,3 @@
from write.contracts import WriteHandler
HANDLER = WriteHandler("module", "module")
@@ -0,0 +1,3 @@
from write.contracts import WriteHandler
HANDLER = WriteHandler("object_member", "object", "add_attribute")
@@ -0,0 +1,3 @@
from write.contracts import WriteHandler
HANDLER = WriteHandler("object_property", "object")
@@ -0,0 +1,11 @@
from typing import Any
from write.context import AdapterWriteContext
from write.contracts import WriteHandler
HANDLER = WriteHandler("scheduled_job_schedule", "schedule")
def execute(payload: dict[str, Any], context: AdapterWriteContext) -> dict[str, Any]:
"""Run the current proven scheduled-job writer through the handler seam."""
return context.legacy_scheduled_job_writer(payload)
+45
View File
@@ -0,0 +1,45 @@
"""Pure, storage-free selection of a typed configuration write handler.
The registry deliberately contains no SQL, payload, or 1C metadata decoding.
It is the first migration seam out of the monolithic adapter server.
"""
from __future__ import annotations
from write.contracts import WriteHandler
from write.handlers.form import HANDLER as FORM_HANDLER
from write.handlers.module import HANDLER as MODULE_HANDLER
from write.handlers.object_member import HANDLER as OBJECT_MEMBER_HANDLER
from write.handlers.object_property import HANDLER as OBJECT_PROPERTY_HANDLER
from write.handlers.scheduled_job import HANDLER as SCHEDULE_HANDLER
def select_write_handler(*, target_kind: str, operation: str = "", is_schedule: bool = False) -> WriteHandler | None:
"""Return one supported typed handler or ``None`` for a forbidden target.
Detailed form sub-routing (element, command, embedded module) remains in
the form handler. It needs decoded target evidence that is unavailable at
this pure public-intent stage.
"""
if is_schedule:
return SCHEDULE_HANDLER
normalized_kind = str(target_kind or "").strip().casefold()
normalized_operation = str(operation or "").strip().casefold()
if normalized_kind in {"object", "объект", "metadata", "метаданные"}:
if normalized_operation in {"add_attribute", "attribute_add", "добавить_реквизит", "добавитьреквизит"}:
return OBJECT_MEMBER_HANDLER
return OBJECT_PROPERTY_HANDLER
if normalized_kind in {"module", "модуль", "bsl"}:
return MODULE_HANDLER
if normalized_kind in {"form", "форма"}:
return FORM_HANDLER
return None
def registered_handlers() -> list[dict[str, str | None]]:
"""Public-safe registry summary; contains no SQL implementation details."""
handlers = [MODULE_HANDLER, FORM_HANDLER, OBJECT_PROPERTY_HANDLER, OBJECT_MEMBER_HANDLER, SCHEDULE_HANDLER]
return [
{"key": handler.key, "target_kind": handler.public_target_kind, "operation": handler.operation}
for handler in handlers
]