演示目录只保留可重建的源码。运行密钥、数据卷、依赖和带口令的本地配置不进入仓库。 Co-authored-by: Cursor <cursoragent@cursor.com>
45 lines
1.0 KiB
Python
45 lines
1.0 KiB
Python
"""Typed resource references for app ownership chains."""
|
|
|
|
from typing import NamedTuple
|
|
|
|
from models.model import App
|
|
|
|
|
|
class AppRef(NamedTuple):
|
|
"""App identifiers used to scope downstream resource lookups."""
|
|
|
|
tenant_id: str
|
|
app_id: str
|
|
|
|
|
|
class MessageRef(NamedTuple):
|
|
"""Message identifiers used to scope downstream resource lookups."""
|
|
|
|
app: AppRef
|
|
message_id: str
|
|
end_user_id: str | None = None
|
|
account_id: str | None = None
|
|
|
|
|
|
class AppRefService:
|
|
"""Factory helpers for app and child resource refs."""
|
|
|
|
@staticmethod
|
|
def create_app_ref(app: App) -> AppRef:
|
|
return AppRef(tenant_id=app.tenant_id, app_id=app.id)
|
|
|
|
@staticmethod
|
|
def create_message_ref(
|
|
app_ref: AppRef,
|
|
message_id: str,
|
|
*,
|
|
end_user_id: str | None = None,
|
|
account_id: str | None = None,
|
|
) -> MessageRef:
|
|
return MessageRef(
|
|
app=app_ref,
|
|
message_id=message_id,
|
|
end_user_id=end_user_id,
|
|
account_id=account_id,
|
|
)
|