|
2 | 2 |
|
3 | 3 | from __future__ import annotations |
4 | 4 |
|
5 | | -from typing import Union, Iterable |
6 | | -from typing_extensions import Required, TypeAlias, TypedDict |
| 5 | +from typing import Union, Iterable, Optional |
| 6 | +from typing_extensions import Literal, Required, TypeAlias, TypedDict |
7 | 7 |
|
8 | 8 | from .message_type_text_field_param import MessageTypeTextFieldParam |
9 | 9 | from .shared_params.message_type_url_field import MessageTypeURLField |
|
16 | 16 | from .shared_params.message_type_textarea_field import MessageTypeTextareaField |
17 | 17 | from .shared_params.message_type_multi_select_field import MessageTypeMultiSelectField |
18 | 18 |
|
19 | | -__all__ = ["MessageTypeVariantParam", "Field"] |
| 19 | +__all__ = [ |
| 20 | + "MessageTypeVariantParam", |
| 21 | + "Field", |
| 22 | + "FieldMessageTypeListField", |
| 23 | + "FieldMessageTypeListFieldSettings", |
| 24 | + "FieldMessageTypeNumberField", |
| 25 | + "FieldMessageTypeNumberFieldSettings", |
| 26 | + "FieldMessageTypeColorField", |
| 27 | + "FieldMessageTypeColorFieldSettings", |
| 28 | +] |
| 29 | + |
| 30 | + |
| 31 | +class FieldMessageTypeListFieldSettings(TypedDict, total=False): |
| 32 | + """Settings for the list field.""" |
| 33 | + |
| 34 | + default: Optional[Iterable[object]] |
| 35 | + """The default value of the list field.""" |
| 36 | + |
| 37 | + description: Optional[str] |
| 38 | + |
| 39 | + item_schema: Optional[object] |
| 40 | + """A JSON schema used to validate the structure of each item in the list. |
| 41 | +
|
| 42 | + Must be a valid JSON schema. |
| 43 | + """ |
| 44 | + |
| 45 | + placeholder: Optional[str] |
| 46 | + |
| 47 | + required: bool |
| 48 | + """Whether the field is required.""" |
| 49 | + |
| 50 | + |
| 51 | +class FieldMessageTypeListField(TypedDict, total=False): |
| 52 | + """A list field used in a message type.""" |
| 53 | + |
| 54 | + key: Required[str] |
| 55 | + """The unique key of the field.""" |
| 56 | + |
| 57 | + label: Required[Optional[str]] |
| 58 | + """The label of the field.""" |
| 59 | + |
| 60 | + type: Required[Literal["list"]] |
| 61 | + """The type of the field.""" |
| 62 | + |
| 63 | + settings: FieldMessageTypeListFieldSettings |
| 64 | + """Settings for the list field.""" |
| 65 | + |
| 66 | + |
| 67 | +class FieldMessageTypeNumberFieldSettings(TypedDict, total=False): |
| 68 | + """Settings for the number field.""" |
| 69 | + |
| 70 | + default: Optional[float] |
| 71 | + """The default numeric value.""" |
| 72 | + |
| 73 | + description: Optional[str] |
| 74 | + |
| 75 | + max: Optional[float] |
| 76 | + """Optional inclusive maximum allowed value.""" |
| 77 | + |
| 78 | + min: Optional[float] |
| 79 | + """Optional inclusive minimum allowed value.""" |
| 80 | + |
| 81 | + placeholder: Optional[str] |
| 82 | + |
| 83 | + required: bool |
| 84 | + """Whether the field is required.""" |
| 85 | + |
| 86 | + unit_label: Optional[str] |
| 87 | + """Optional short label shown after the input (e.g. px, kg).""" |
| 88 | + |
| 89 | + |
| 90 | +class FieldMessageTypeNumberField(TypedDict, total=False): |
| 91 | + """ |
| 92 | + A numeric field used in a message type or partial input schema, with optional min/max bounds and a unit label for display. |
| 93 | + """ |
| 94 | + |
| 95 | + key: Required[str] |
| 96 | + """The unique key of the field.""" |
| 97 | + |
| 98 | + label: Required[Optional[str]] |
| 99 | + """The label of the field.""" |
| 100 | + |
| 101 | + type: Required[Literal["number"]] |
| 102 | + """The type of the field.""" |
| 103 | + |
| 104 | + settings: FieldMessageTypeNumberFieldSettings |
| 105 | + """Settings for the number field.""" |
| 106 | + |
| 107 | + |
| 108 | +class FieldMessageTypeColorFieldSettings(TypedDict, total=False): |
| 109 | + """Settings for the color field.""" |
| 110 | + |
| 111 | + default: Optional[str] |
| 112 | + """The default hex color value.""" |
| 113 | + |
| 114 | + description: Optional[str] |
| 115 | + |
| 116 | + placeholder: Optional[str] |
| 117 | + |
| 118 | + required: bool |
| 119 | + """Whether the field is required.""" |
| 120 | + |
| 121 | + |
| 122 | +class FieldMessageTypeColorField(TypedDict, total=False): |
| 123 | + """ |
| 124 | + A hex color field (#RGB or #RRGGBB) used in a message type or partial input schema. |
| 125 | + """ |
| 126 | + |
| 127 | + key: Required[str] |
| 128 | + """The unique key of the field.""" |
| 129 | + |
| 130 | + label: Required[Optional[str]] |
| 131 | + """The label of the field.""" |
| 132 | + |
| 133 | + type: Required[Literal["color"]] |
| 134 | + """The type of the field.""" |
| 135 | + |
| 136 | + settings: FieldMessageTypeColorFieldSettings |
| 137 | + """Settings for the color field.""" |
| 138 | + |
20 | 139 |
|
21 | 140 | Field: TypeAlias = Union[ |
| 141 | + FieldMessageTypeListField, |
22 | 142 | MessageTypeSelectField, |
23 | 143 | MessageTypeBooleanField, |
24 | 144 | MessageTypeJsonField, |
| 145 | + FieldMessageTypeNumberField, |
25 | 146 | MessageTypeTextFieldParam, |
26 | 147 | MessageTypeImageField, |
| 148 | + FieldMessageTypeColorField, |
27 | 149 | MessageTypeURLField, |
28 | 150 | MessageTypeMarkdownField, |
29 | 151 | MessageTypeMultiSelectField, |
|
0 commit comments