LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows
Python ai-agentsdata-engineeringdocument-aigenerative-aiidpjson-extractionllmmcp-serverocrpdf-extractionprompt-engineeringstructured-output
UN-4168 [MISC] Merge UN-4108-zid: add UnstractRole, a provider-neutral home for the plugin role names (#2363)
Athul7bcb5d0616ff
diff --git a/backend/account_v2/enums.py b/backend/account_v2/enums.pyindex d8209ec2d..9ee2dd4f2 100644--- a/backend/account_v2/enums.py+++ b/backend/account_v2/enums.py@@ -1,6 +1,25 @@-from enum import Enum+"""Role values, independent of any authentication provider.+Both alphabets are wire contracts: stored in ``OrganizationMember.role`` and+matched literally by the permission checks and the SPA, so renaming a value+silently changes permissions.+"""++from enum import StrEnum+++class UserRole(StrEnum):+ """Roles of the OSS default authentication service (no auth plugin)."""-class UserRole(Enum):USER = "user"ADMIN = "admin"+++class UnstractRole(StrEnum):+ """Roles of the authentication plugins and of the Zipstack ID ``roles`` claim."""++ USER = "unstract_user"+ ADMIN = "unstract_admin"+ SUPERVISOR = "unstract_supervisor"+ REVIEWER = "unstract_reviewer"+ PLATFORM_ADMIN = "unstract_platform_admin"diff --git a/backend/account_v2/test_enums.py b/backend/account_v2/test_enums.pynew file mode 100644index 000000000..c63b32f17--- /dev/null+++ b/backend/account_v2/test_enums.py@@ -0,0 +1,30 @@+"""Pin every role value: a renamed value is a silent permission change."""++from account_v2.enums import UnstractRole, UserRole+++def test_default_service_alphabet_is_pinned() -> None:+ assert {role.name: role.value for role in UserRole} == {+ "USER": "user",+ "ADMIN": "admin",+ }+++def test_plugin_alphabet_is_pinned() -> None:+ assert {role.name: role.value for role in UnstractRole} == {+ "USER": "unstract_user",+ "ADMIN": "unstract_admin",+ "SUPERVISOR": "unstract_supervisor",+ "REVIEWER": "unstract_reviewer",+ "PLATFORM_ADMIN": "unstract_platform_admin",+ }+++def test_members_equal_their_stored_strings() -> None:+ # Call sites compare members with stored strings, which needs StrEnum.+ assert UserRole.ADMIN == "admin"+ assert UnstractRole.ADMIN == "unstract_admin"+++def test_alphabets_are_disjoint() -> None:+ assert not set(UserRole) & set(UnstractRole)diff --git a/backend/tenant_account_v2/enums.py b/backend/tenant_account_v2/enums.pyindex d8209ec2d..bb1a11000 100644--- a/backend/tenant_account_v2/enums.py+++ b/backend/tenant_account_v2/enums.py@@ -1,6 +1,4 @@-from enum import Enum+# Kept so existing imports resolve to the single definition in account_v2.+from account_v2.enums import UserRole--class UserRole(Enum):- USER = "user"- ADMIN = "admin"+__all__ = ["UserRole"]