22import uuid
33from enum import Enum
44from typing import Optional
5-
5+ import shortuuid
66from fastapi import APIRouter
77
88from ted_sws .notice_transformer .entrypoints .api .digest_service .common import ResponseType , single_result_response , \
@@ -30,6 +30,7 @@ class UUIDNamespaceType(Enum):
3030class UUIDVersion (Enum ):
3131 UUID3 = "UUID3"
3232 UUID5 = "UUID5"
33+ SHORT_UUID = "short"
3334
3435
3536def string_md5 (value : str ):
@@ -73,7 +74,7 @@ async def fn_md5(value: str, response_type: Optional[ResponseType] = ResponseTyp
7374async def fn_uuid (
7475 value : str ,
7576 process_type : Optional [UUIDInputProcessType ] = UUIDInputProcessType .XPATH ,
76- version : Optional [UUIDVersion ] = UUIDVersion .UUID3 ,
77+ version : Optional [UUIDVersion ] = UUIDVersion .SHORT_UUID ,
7778 ns_type : Optional [UUIDNamespaceType ] = UUIDNamespaceType .URL ,
7879 response_type : Optional [ResponseType ] = ResponseType .RAW
7980):
@@ -95,7 +96,9 @@ async def fn_uuid(
9596 uuid_ns = uuid_ns_by_type (ns_type )
9697
9798 uuid_result : uuid .UUID
98- if version == UUIDVersion .UUID5 :
99+ if version == UUIDVersion .SHORT_UUID :
100+ uuid_result = shortuuid .uuid (name = value )
101+ elif version == UUIDVersion .UUID5 :
99102 uuid_result = uuid .uuid5 (uuid_ns , value )
100103 else :
101104 uuid_result = uuid .uuid3 (uuid_ns , value )
0 commit comments