Airalogy Types
airalogy offers a set of built-in data types that the platform understands natively. When you define data fields in an Airalogy Protocol Model with these types, the platform can automatically parse them and provide extra features—such as auto-filling values from a user’s profile or rendering specialised UI controls.
UserName
from airalogy.types import UserName
from pydantic import BaseModel
class VarModel(BaseModel):
user_name: UserNameA field declared as UserName is automatically populated with the current user’s login name.
All built-in types add an extra JSON-Schema attribute—airalogy_type—to indicate the specific Airalogy type. The schema for the class above is therefore:
{
"title": "VarModel",
"type": "object",
"properties": {
"user_name": {
"title": "User Name",
"type": "string",
"airalogy_type": "UserName"
}
},
"required": ["user_name"]
}Current
CurrentTime
from airalogy.types import CurrentTime
from pydantic import BaseModel
class VarModel(BaseModel):
current_time: CurrentTimeCurrentTime is automatically filled with the current time in the user’s browser time-zone.
CurrentProtocolId
from airalogy.types import CurrentProtocolId
from pydantic import BaseModel
class VarModel(BaseModel):
current_protocol_id: CurrentProtocolIdA field declared as CurrentProtocolId is automatically populated with the Airalogy Protocol ID of the current Protocol.
CurrentRecordId
from airalogy.types import CurrentRecordId
from pydantic import BaseModel
class VarModel(BaseModel):
current_record_id: CurrentRecordIdA field declared as CurrentRecordId is automatically populated with the Airalogy Record ID of the current Record.
AiralogyMarkdown
from airalogy.types import AiralogyMarkdown
from pydantic import BaseModel
class VarModel(BaseModel):
content: AiralogyMarkdownFields of type AiralogyMarkdown render a Markdown editor that supports Airalogy Markdown, the platform’s own dialect. Using a distinct name avoids confusion with the many Markdown variants and guarantees consistent rendering.
SnakeStr
from airalogy.types import SnakeStr
from pydantic import BaseModel
class VarModel(BaseModel):
snake_case_string: SnakeStrA field declared as SnakeStr requires the string to follow Python's snake_case naming convention. This type is typically used for string fields that need to adhere to specific naming standards.
VersionStr
from airalogy.types import VersionStr
from pydantic import BaseModel
class VarModel(BaseModel):
version: VersionStrA field declared as VersionStr requires the string to conform to Semantic Versioning (SemVer) standards, formatted as x.y.z, where x, y, and z are non-negative integers. This type is commonly used to represent version numbers.
ProtocolId
from airalogy.types import ProtocolId
from pydantic import BaseModel
class Model(BaseModel):
protocol_id: ProtocolIdA field declared as ProtocolId requires the string to follow the Airalogy Protocol ID format, which is typically used to uniquely identify a Protocol. The format is:
airalogy.id.lab.{lab_id}.project.{project_id}.protocol.{protocol_id}.v.{version}where lab_id, project_id, and protocol_id must conform to the SnakeStr format, and version must conform to the VersionStr format.
RecordId
from airalogy.types import RecordId
from pydantic import BaseModel
class VarModel(BaseModel):
record_id: RecordIdDeclaring a field as RecordId produces a dropdown that lets the user pick an existing Record; the field is then set to that Record’s string ID.
FileId* Types
When a field uses any FileId* type, the UI shows an upload button. The uploaded file is stored in Airalogy’s file system and assigned a unique string ID.
from airalogy.types import (
# Images
FileIdPNG, FileIdJPG, FileIdSVG, FileIdWEBP, FileIdTIFF,
# Video
FileIdMP4,
# Audio
FileIdMP3,
# Documents
FileIdAIMD, FileIdMD, FileIdTXT,
FileIdCSV, FileIdJSON,
FileIdDOCX, FileIdXLSX, FileIdPPTX,
FileIdPDF,
FileIdDna # SnapGene's .dna file type
)
from pydantic import BaseModel
class VarModel(BaseModel):
png_file_id: FileIdPNG
jpg_file_id: FileIdJPG
svg_file_id: FileIdSVG
webp_file_id: FileIdWEBP
tiff_file_id: FileIdTIFF
mp4_file_id: FileIdMP4
mp3_file_id: FileIdMP3
aimd_file_id: FileIdAIMD
md_file_id: FileIdMD
txt_file_id: FileIdTXT
csv_file_id: FileIdCSV
json_file_id: FileIdJSON
docx_file_id: FileIdDOCX
xlsx_file_id: FileIdXLSX
pptx_file_id: FileIdPPTX
pdf_file_id: FileIdPDF
dna_file_id: FileIdDnaIgnoreStr
IgnoreStr fields accept any string, pass it to the Assigner, but store an empty string in the saved Record. Use this for secrets such as API keys that you need at runtime but do not want persisted.
from airalogy.types import IgnoreStr
from pydantic import BaseModel
class VarModel(BaseModel):
api_key: IgnoreStrCode-String Types
PyStr, JsStr, TsStr, JsonStr, TomlStr, YamlStr
from airalogy.types import PyStr, JsStr, TsStr, JsonStr, TomlStr, YamlStr
from pydantic import BaseModel
class VarModel(BaseModel):
python_code: PyStr
javascript_code: JsStr
typescript_code: TsStr
json_str: JsonStr
toml_str: TomlStr
yaml_str: YamlStrEach of these types renders a language-specific code editor with syntax highlighting. The field value is stored as a plain string.
ATCG
ATCG is a built-in type for managing DNA sequences. It only allows strings containing the four letters A, T, C, and G. Any other character will raise a validation error.
from airalogy.types import ATCG
from pydantic import BaseModel
class VarModel(BaseModel):
dna_seq: ATCGA field declared as ATCG will only accept valid DNA sequences. The type also provides a .complement() method to get the complementary DNA strand (A<->T, C<->G):
seq = ATCG("ATCG")
print(seq.complement()) # Output: TAGCThe JSON-Schema for a model using ATCG will include:
{
"title": "VarModel",
"type": "object",
"properties": {
"dna_seq": {
"title": "Dna Seq",
"type": "string",
"airalogy_type": "ATCG",
"pattern": "^[ATCG]*$"
}
},
"required": ["dna_seq"]
}Chinese Enum Types
airalogy.types.chinese bundles several enumerations that match common demographic fields in mainland China scenarios.
from airalogy.types import (
ChineseEthnicGroup,
ChineseProvinceLevelRegion,
ChineseGender,
ChineseMaritalStatus,
ChineseEducationLevel,
)
from pydantic import BaseModel
class DemographicModel(BaseModel):
ethnic_group: ChineseEthnicGroup
province: ChineseProvinceLevelRegion
gender: ChineseGender
marital_status: ChineseMaritalStatus
education_level: ChineseEducationLevelChineseEthnicGroup
Enumerates all 56 ethnic groups officially recognised by the State Council (e.g. "汉族", "藏族", "维吾尔族"). Use it when a protocol needs a user’s ethnicity with the legally defined list of options.
ChineseProvinceLevelRegion
Covers every current province-level administrative region—34 in total (23 provinces, 5 autonomous regions, 4 municipalities, and 2 Special Administrative Regions)—so values such as "北京", "广东", "新疆", or "香港" are all available.
ChineseGender
Restricts input to "男" or "女", matching the gender labels commonly used in national resident registries.
ChineseMaritalStatus
Provides the five statuses "未婚", "已婚", "丧偶", "离婚", and "再婚" for forms that need a standard marital-status question.
ChineseEducationLevel
Represents the nine education levels ("无学历", "小学", "初中", "高中", "中专", "大专", "本科", "硕士", "博士") to keep education background data aligned with domestic conventions.