semantics
This commit is contained in:
@@ -9,11 +9,11 @@
|
||||
# @INVARIANT: Endpoints are self-scoped and never mutate another user preference.
|
||||
# @PRE: Auth middleware configured, database session available
|
||||
# @POST: Profile endpoints registered
|
||||
# @UX_STATE: ProfileLoad -> Returns stable ProfilePreferenceResponse for authenticated user.
|
||||
# @UX_STATE: Saving -> Validation errors map to actionable 422 details.
|
||||
# @UX_STATE: LookupLoading -> Returns success/degraded Superset lookup payload.
|
||||
# @UX_FEEDBACK: Stable status/message/warning payloads support profile page feedback.
|
||||
# @UX_RECOVERY: Lookup degradation keeps manual username save path available.
|
||||
# UX_STATE: ProfileLoad -> Returns stable ProfilePreferenceResponse for authenticated user.
|
||||
# UX_STATE: Saving -> Validation errors map to actionable 422 details.
|
||||
# UX_STATE: LookupLoading -> Returns success/degraded Superset lookup payload.
|
||||
# UX_FEEDBACK: Stable status/message/warning payloads support profile page feedback.
|
||||
# UX_RECOVERY: Lookup degradation keeps manual username save path available.
|
||||
# @SIDE_EFFECT: Registers /api/profile/* routes
|
||||
# @DATA_CONTRACT: ProfileRequest -> ProfileResponse
|
||||
|
||||
|
||||
@@ -18,9 +18,12 @@ from ....plugins.translate.service import (
|
||||
get_datasource_columns as fetch_datasource_columns_service,
|
||||
)
|
||||
from ....schemas.auth import User
|
||||
from ....plugins.translate.service_target_schema import validate_target_table_schema
|
||||
from ....schemas.translate import (
|
||||
DatasourceColumnsResponse,
|
||||
DuplicateJobResponse,
|
||||
TargetSchemaValidationRequest,
|
||||
TargetSchemaValidationResponse,
|
||||
TranslateJobCreate,
|
||||
TranslateJobResponse,
|
||||
TranslateJobUpdate,
|
||||
@@ -246,4 +249,42 @@ async def get_datasource_columns(
|
||||
)
|
||||
# #endregion get_datasource_columns
|
||||
|
||||
|
||||
# #region check_target_schema [C:3] [TYPE Function]
|
||||
# @BRIEF Проверяет схему целевой таблицы: какие колонки ожидаются, какие есть, каких не хватает.
|
||||
# @PRE User has translate.job.view permission.
|
||||
# @POST Возвращает diff expected vs actual columns.
|
||||
# @SIDE_EFFECT Делает SQL-запрос к information_schema.columns через Superset SQL Lab.
|
||||
# @RELATION DEPENDS_ON -> [validate_target_table_schema]
|
||||
# @RELATION DEPENDS_ON -> [TargetSchemaValidationRequest]
|
||||
# @RELATION DEPENDS_ON -> [TargetSchemaValidationResponse]
|
||||
# @RATIONALE Позволяет UI показать пользователю подсказку о недостающих колонках
|
||||
# на этапе настройки джобы, до запуска перевода.
|
||||
@router.post("/check-target-schema", response_model=TargetSchemaValidationResponse)
|
||||
async def check_target_schema(
|
||||
payload: TargetSchemaValidationRequest,
|
||||
current_user: User = Depends(get_current_user),
|
||||
_ = Depends(has_permission("translate.job", "VIEW")),
|
||||
config_manager: ConfigManager = Depends(get_config_manager),
|
||||
):
|
||||
"""Check target table schema — validate expected vs actual columns for translation inserts."""
|
||||
logger.reason(
|
||||
f"check_target_schema — Table: {payload.target_schema}.{payload.target_table}, "
|
||||
f"Env: {payload.environment_id}, User: {current_user.username}",
|
||||
extra={"src": "translate_routes"},
|
||||
)
|
||||
try:
|
||||
result = validate_target_table_schema(payload, config_manager)
|
||||
return result
|
||||
except Exception as e:
|
||||
logger.explore("check_target_schema failed",
|
||||
extra={"src": "translate_routes", "error": str(e)})
|
||||
return TargetSchemaValidationResponse(
|
||||
table_exists=False,
|
||||
error=str(e),
|
||||
all_present=False,
|
||||
)
|
||||
# #endregion check_target_schema
|
||||
|
||||
|
||||
# #endregion TranslateJobRoutesModule
|
||||
|
||||
Reference in New Issue
Block a user