11import importlib
22from datetime import datetime
3+ from enum import Enum
34from functools import partial
45from typing import (
56 TYPE_CHECKING ,
3031 from pyairtable import orm
3132
3233
34+ class FieldType (str , Enum ):
35+ """
36+ Enumeration of all field types supported by Airtable.
37+
38+ Usage:
39+ >>> from pyairtable.models.schema import FieldType
40+ >>> FieldType.SINGLE_LINE_TEXT
41+ FieldType('singleLineText')
42+ """
43+
44+ AI_TEXT = "aiText"
45+ AUTO_NUMBER = "autoNumber"
46+ BARCODE = "barcode"
47+ BUTTON = "button"
48+ CHECKBOX = "checkbox"
49+ COUNT = "count"
50+ CREATED_BY = "createdBy"
51+ CREATED_TIME = "createdTime"
52+ CURRENCY = "currency"
53+ DATE = "date"
54+ DATE_TIME = "dateTime"
55+ DURATION = "duration"
56+ EMAIL = "email"
57+ EXTERNAL_SYNC_SOURCE = "externalSyncSource"
58+ FORMULA = "formula"
59+ LAST_MODIFIED_BY = "lastModifiedBy"
60+ LAST_MODIFIED_TIME = "lastModifiedTime"
61+ MANUAL_SORT = "manualSort"
62+ MULTILINE_TEXT = "multilineText"
63+ MULTIPLE_ATTACHMENTS = "multipleAttachments"
64+ MULTIPLE_COLLABORATORS = "multipleCollaborators"
65+ MULTIPLE_LOOKUP_VALUES = "multipleLookupValues"
66+ MULTIPLE_RECORD_LINKS = "multipleRecordLinks"
67+ MULTIPLE_SELECTS = "multipleSelects"
68+ NUMBER = "number"
69+ PERCENT = "percent"
70+ PHONE_NUMBER = "phoneNumber"
71+ RATING = "rating"
72+ RICH_TEXT = "richText"
73+ ROLLUP = "rollup"
74+ SINGLE_COLLABORATOR = "singleCollaborator"
75+ SINGLE_LINE_TEXT = "singleLineText"
76+ SINGLE_SELECT = "singleSelect"
77+ URL = "url"
78+
79+ def __repr__ (self ) -> str :
80+ return f"FieldType({ self .value !r} )"
81+
82+
3383FieldSpecifier : TypeAlias = Union [str , "orm.fields.AnyField" ]
3484
3585_T = TypeVar ("_T" , bound = Any )
@@ -755,7 +805,7 @@ class AITextFieldConfig(AirtableModel):
755805 Field configuration for `AI text <https://airtable.com/developers/web/api/field-model#aitext>`__.
756806 """
757807
758- type : Literal ["aiText" ]
808+ type : Literal [FieldType . AI_TEXT ]
759809 options : "AITextFieldOptions"
760810
761811
@@ -772,31 +822,31 @@ class AutoNumberFieldConfig(AirtableModel):
772822 Field configuration for `Auto number <https://airtable.com/developers/web/api/field-model#autonumber>`__.
773823 """
774824
775- type : Literal ["autoNumber" ]
825+ type : Literal [FieldType . AUTO_NUMBER ]
776826
777827
778828class BarcodeFieldConfig (AirtableModel ):
779829 """
780830 Field configuration for `Barcode <https://airtable.com/developers/web/api/field-model#barcode>`__.
781831 """
782832
783- type : Literal ["barcode" ]
833+ type : Literal [FieldType . BARCODE ]
784834
785835
786836class ButtonFieldConfig (AirtableModel ):
787837 """
788838 Field configuration for `Button <https://airtable.com/developers/web/api/field-model#button>`__.
789839 """
790840
791- type : Literal ["button" ]
841+ type : Literal [FieldType . BUTTON ]
792842
793843
794844class CheckboxFieldConfig (AirtableModel ):
795845 """
796846 Field configuration for `Checkbox <https://airtable.com/developers/web/api/field-model#checkbox>`__.
797847 """
798848
799- type : Literal ["checkbox" ]
849+ type : Literal [FieldType . CHECKBOX ]
800850 options : "CheckboxFieldOptions"
801851
802852
@@ -810,7 +860,7 @@ class CountFieldConfig(AirtableModel):
810860 Field configuration for `Count <https://airtable.com/developers/web/api/field-model#count>`__.
811861 """
812862
813- type : Literal ["count" ]
863+ type : Literal [FieldType . COUNT ]
814864 options : "CountFieldOptions"
815865
816866
@@ -824,23 +874,23 @@ class CreatedByFieldConfig(AirtableModel):
824874 Field configuration for `Created by <https://airtable.com/developers/web/api/field-model#createdby>`__.
825875 """
826876
827- type : Literal ["createdBy" ]
877+ type : Literal [FieldType . CREATED_BY ]
828878
829879
830880class CreatedTimeFieldConfig (AirtableModel ):
831881 """
832882 Field configuration for `Created time <https://airtable.com/developers/web/api/field-model#createdtime>`__.
833883 """
834884
835- type : Literal ["createdTime" ]
885+ type : Literal [FieldType . CREATED_TIME ]
836886
837887
838888class CurrencyFieldConfig (AirtableModel ):
839889 """
840890 Field configuration for `Currency <https://airtable.com/developers/web/api/field-model#currencynumber>`__.
841891 """
842892
843- type : Literal ["currency" ]
893+ type : Literal [FieldType . CURRENCY ]
844894 options : "CurrencyFieldOptions"
845895
846896
@@ -854,7 +904,7 @@ class DateFieldConfig(AirtableModel):
854904 Field configuration for `Date <https://airtable.com/developers/web/api/field-model#dateonly>`__.
855905 """
856906
857- type : Literal ["date" ]
907+ type : Literal [FieldType . DATE ]
858908 options : "DateFieldOptions"
859909
860910
@@ -867,7 +917,7 @@ class DateTimeFieldConfig(AirtableModel):
867917 Field configuration for `Date and time <https://airtable.com/developers/web/api/field-model#dateandtime>`__.
868918 """
869919
870- type : Literal ["dateTime" ]
920+ type : Literal [FieldType . DATE_TIME ]
871921 options : "DateTimeFieldOptions"
872922
873923
@@ -890,7 +940,7 @@ class DurationFieldConfig(AirtableModel):
890940 Field configuration for `Duration <https://airtable.com/developers/web/api/field-model#durationnumber>`__.
891941 """
892942
893- type : Literal ["duration" ]
943+ type : Literal [FieldType . DURATION ]
894944 options : "DurationFieldOptions"
895945
896946
@@ -903,15 +953,15 @@ class EmailFieldConfig(AirtableModel):
903953 Field configuration for `Email <https://airtable.com/developers/web/api/field-model#email>`__.
904954 """
905955
906- type : Literal ["email" ]
956+ type : Literal [FieldType . EMAIL ]
907957
908958
909959class ExternalSyncSourceFieldConfig (AirtableModel ):
910960 """
911961 Field configuration for `Sync source <https://airtable.com/developers/web/api/field-model#syncsource>`__.
912962 """
913963
914- type : Literal ["externalSyncSource" ]
964+ type : Literal [FieldType . EXTERNAL_SYNC_SOURCE ]
915965 options : "SingleSelectFieldOptions"
916966
917967
@@ -920,7 +970,7 @@ class FormulaFieldConfig(AirtableModel):
920970 Field configuration for `Formula <https://airtable.com/developers/web/api/field-model#formula>`__.
921971 """
922972
923- type : Literal ["formula" ]
973+ type : Literal [FieldType . FORMULA ]
924974 options : "FormulaFieldOptions"
925975
926976
@@ -936,15 +986,15 @@ class LastModifiedByFieldConfig(AirtableModel):
936986 Field configuration for `Last modified by <https://airtable.com/developers/web/api/field-model#lastmodifiedby>`__.
937987 """
938988
939- type : Literal ["lastModifiedBy" ]
989+ type : Literal [FieldType . LAST_MODIFIED_BY ]
940990
941991
942992class LastModifiedTimeFieldConfig (AirtableModel ):
943993 """
944994 Field configuration for `Last modified time <https://airtable.com/developers/web/api/field-model#lastmodifiedtime>`__.
945995 """
946996
947- type : Literal ["lastModifiedTime" ]
997+ type : Literal [FieldType . LAST_MODIFIED_TIME ]
948998 options : "LastModifiedTimeFieldOptions"
949999
9501000
@@ -959,23 +1009,23 @@ class ManualSortFieldConfig(AirtableModel):
9591009 Field configuration for ``manualSort`` field type (not documented).
9601010 """
9611011
962- type : Literal ["manualSort" ]
1012+ type : Literal [FieldType . MANUAL_SORT ]
9631013
9641014
9651015class MultilineTextFieldConfig (AirtableModel ):
9661016 """
9671017 Field configuration for `Long text <https://airtable.com/developers/web/api/field-model#multilinetext>`__.
9681018 """
9691019
970- type : Literal ["multilineText" ]
1020+ type : Literal [FieldType . MULTILINE_TEXT ]
9711021
9721022
9731023class MultipleAttachmentsFieldConfig (AirtableModel ):
9741024 """
9751025 Field configuration for `Attachments <https://airtable.com/developers/web/api/field-model#multipleattachment>`__.
9761026 """
9771027
978- type : Literal ["multipleAttachments" ]
1028+ type : Literal [FieldType . MULTIPLE_ATTACHMENTS ]
9791029 options : "MultipleAttachmentsFieldOptions"
9801030
9811031
@@ -992,15 +1042,15 @@ class MultipleCollaboratorsFieldConfig(AirtableModel):
9921042 Field configuration for `Multiple Collaborators <https://airtable.com/developers/web/api/field-model#multicollaborator>`__.
9931043 """
9941044
995- type : Literal ["multipleCollaborators" ]
1045+ type : Literal [FieldType . MULTIPLE_COLLABORATORS ]
9961046
9971047
9981048class MultipleLookupValuesFieldConfig (AirtableModel ):
9991049 """
10001050 Field configuration for `Lookup <https://airtable.com/developers/web/api/field-model#lookup>__`.
10011051 """
10021052
1003- type : Literal ["multipleLookupValues" ]
1053+ type : Literal [FieldType . MULTIPLE_LOOKUP_VALUES ]
10041054 options : "MultipleLookupValuesFieldOptions"
10051055
10061056
@@ -1016,7 +1066,7 @@ class MultipleRecordLinksFieldConfig(AirtableModel):
10161066 Field configuration for `Link to another record <https://airtable.com/developers/web/api/field-model#foreignkey>__`.
10171067 """
10181068
1019- type : Literal ["multipleRecordLinks" ]
1069+ type : Literal [FieldType . MULTIPLE_RECORD_LINKS ]
10201070 options : "MultipleRecordLinksFieldOptions"
10211071
10221072
@@ -1033,7 +1083,7 @@ class MultipleSelectsFieldConfig(AirtableModel):
10331083 Field configuration for `Multiple select <https://airtable.com/developers/web/api/field-model#multiselect>`__.
10341084 """
10351085
1036- type : Literal ["multipleSelects" ]
1086+ type : Literal [FieldType . MULTIPLE_SELECTS ]
10371087 options : "SingleSelectFieldOptions"
10381088
10391089
@@ -1042,7 +1092,7 @@ class NumberFieldConfig(AirtableModel):
10421092 Field configuration for `Number <https://airtable.com/developers/web/api/field-model#decimalorintegernumber>`__.
10431093 """
10441094
1045- type : Literal ["number" ]
1095+ type : Literal [FieldType . NUMBER ]
10461096 options : "NumberFieldOptions"
10471097
10481098
@@ -1055,7 +1105,7 @@ class PercentFieldConfig(AirtableModel):
10551105 Field configuration for `Percent <https://airtable.com/developers/web/api/field-model#percentnumber>`__.
10561106 """
10571107
1058- type : Literal ["percent" ]
1108+ type : Literal [FieldType . PERCENT ]
10591109 options : "NumberFieldOptions"
10601110
10611111
@@ -1064,15 +1114,15 @@ class PhoneNumberFieldConfig(AirtableModel):
10641114 Field configuration for `Phone <https://airtable.com/developers/web/api/field-model#phone>`__.
10651115 """
10661116
1067- type : Literal ["phoneNumber" ]
1117+ type : Literal [FieldType . PHONE_NUMBER ]
10681118
10691119
10701120class RatingFieldConfig (AirtableModel ):
10711121 """
10721122 Field configuration for `Rating <https://airtable.com/developers/web/api/field-model#rating>`__.
10731123 """
10741124
1075- type : Literal ["rating" ]
1125+ type : Literal [FieldType . RATING ]
10761126 options : "RatingFieldOptions"
10771127
10781128
@@ -1087,15 +1137,15 @@ class RichTextFieldConfig(AirtableModel):
10871137 Field configuration for `Rich text <https://airtable.com/developers/web/api/field-model#rich-text>`__.
10881138 """
10891139
1090- type : Literal ["richText" ]
1140+ type : Literal [FieldType . RICH_TEXT ]
10911141
10921142
10931143class RollupFieldConfig (AirtableModel ):
10941144 """
10951145 Field configuration for `Rollup <https://airtable.com/developers/web/api/field-model#rollup>__`.
10961146 """
10971147
1098- type : Literal ["rollup" ]
1148+ type : Literal [FieldType . ROLLUP ]
10991149 options : "RollupFieldOptions"
11001150
11011151
@@ -1112,23 +1162,23 @@ class SingleCollaboratorFieldConfig(AirtableModel):
11121162 Field configuration for `Collaborator <https://airtable.com/developers/web/api/field-model#collaborator>`__.
11131163 """
11141164
1115- type : Literal ["singleCollaborator" ]
1165+ type : Literal [FieldType . SINGLE_COLLABORATOR ]
11161166
11171167
11181168class SingleLineTextFieldConfig (AirtableModel ):
11191169 """
11201170 Field configuration for `Single line text <https://airtable.com/developers/web/api/field-model#simpletext>`__.
11211171 """
11221172
1123- type : Literal ["singleLineText" ]
1173+ type : Literal [FieldType . SINGLE_LINE_TEXT ]
11241174
11251175
11261176class SingleSelectFieldConfig (AirtableModel ):
11271177 """
11281178 Field configuration for `Single select <https://airtable.com/developers/web/api/field-model#select>`__.
11291179 """
11301180
1131- type : Literal ["singleSelect" ]
1181+ type : Literal [FieldType . SINGLE_SELECT ]
11321182 options : "SingleSelectFieldOptions"
11331183
11341184
@@ -1146,7 +1196,7 @@ class UrlFieldConfig(AirtableModel):
11461196 Field configuration for `Url <https://airtable.com/developers/web/api/field-model#urltext>`__.
11471197 """
11481198
1149- type : Literal ["url" ]
1199+ type : Literal [FieldType . URL ]
11501200
11511201
11521202class UnknownFieldConfig (AirtableModel ):
0 commit comments