amsdal 0.4.13__cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (269) hide show
  1. amsdal/Third-Party Materials - AMSDAL Dependencies - License Notices.md +1334 -0
  2. amsdal/__about__.py +4 -0
  3. amsdal/__about__.pyi +1 -0
  4. amsdal/__init__.py +23 -0
  5. amsdal/__init__.pyi +9 -0
  6. amsdal/__migrations__/0000_initial.py +217 -0
  7. amsdal/__migrations__/0001_datetime_type.py +18 -0
  8. amsdal/__migrations__/0002_fixture_order.py +44 -0
  9. amsdal/__migrations__/0003_schema_type_in_class_meta.py +44 -0
  10. amsdal/cloud/__init__.cpython-311-x86_64-linux-gnu.so +0 -0
  11. amsdal/cloud/__init__.pyi +0 -0
  12. amsdal/cloud/client.cpython-311-x86_64-linux-gnu.so +0 -0
  13. amsdal/cloud/client.pyi +57 -0
  14. amsdal/cloud/constants.cpython-311-x86_64-linux-gnu.so +0 -0
  15. amsdal/cloud/constants.pyi +13 -0
  16. amsdal/cloud/enums.cpython-311-x86_64-linux-gnu.so +0 -0
  17. amsdal/cloud/enums.pyi +68 -0
  18. amsdal/cloud/models/__init__.cpython-311-x86_64-linux-gnu.so +0 -0
  19. amsdal/cloud/models/__init__.pyi +0 -0
  20. amsdal/cloud/models/base.cpython-311-x86_64-linux-gnu.so +0 -0
  21. amsdal/cloud/models/base.pyi +247 -0
  22. amsdal/cloud/services/__init__.cpython-311-x86_64-linux-gnu.so +0 -0
  23. amsdal/cloud/services/__init__.pyi +0 -0
  24. amsdal/cloud/services/actions/__init__.cpython-311-x86_64-linux-gnu.so +0 -0
  25. amsdal/cloud/services/actions/__init__.pyi +0 -0
  26. amsdal/cloud/services/actions/add_allowlist_ip.cpython-311-x86_64-linux-gnu.so +0 -0
  27. amsdal/cloud/services/actions/add_allowlist_ip.pyi +19 -0
  28. amsdal/cloud/services/actions/add_basic_auth.cpython-311-x86_64-linux-gnu.so +0 -0
  29. amsdal/cloud/services/actions/add_basic_auth.pyi +21 -0
  30. amsdal/cloud/services/actions/add_dependency.cpython-311-x86_64-linux-gnu.so +0 -0
  31. amsdal/cloud/services/actions/add_dependency.pyi +19 -0
  32. amsdal/cloud/services/actions/add_secret.cpython-311-x86_64-linux-gnu.so +0 -0
  33. amsdal/cloud/services/actions/add_secret.pyi +20 -0
  34. amsdal/cloud/services/actions/base.cpython-311-x86_64-linux-gnu.so +0 -0
  35. amsdal/cloud/services/actions/base.pyi +122 -0
  36. amsdal/cloud/services/actions/create_deploy.cpython-311-x86_64-linux-gnu.so +0 -0
  37. amsdal/cloud/services/actions/create_deploy.pyi +41 -0
  38. amsdal/cloud/services/actions/create_env.cpython-311-x86_64-linux-gnu.so +0 -0
  39. amsdal/cloud/services/actions/create_env.pyi +19 -0
  40. amsdal/cloud/services/actions/create_session.cpython-311-x86_64-linux-gnu.so +0 -0
  41. amsdal/cloud/services/actions/create_session.pyi +17 -0
  42. amsdal/cloud/services/actions/delete_allowlist_ip.cpython-311-x86_64-linux-gnu.so +0 -0
  43. amsdal/cloud/services/actions/delete_allowlist_ip.pyi +19 -0
  44. amsdal/cloud/services/actions/delete_basic_auth.cpython-311-x86_64-linux-gnu.so +0 -0
  45. amsdal/cloud/services/actions/delete_basic_auth.pyi +20 -0
  46. amsdal/cloud/services/actions/delete_dependency.cpython-311-x86_64-linux-gnu.so +0 -0
  47. amsdal/cloud/services/actions/delete_dependency.pyi +21 -0
  48. amsdal/cloud/services/actions/delete_env.cpython-311-x86_64-linux-gnu.so +0 -0
  49. amsdal/cloud/services/actions/delete_env.pyi +21 -0
  50. amsdal/cloud/services/actions/delete_secret.cpython-311-x86_64-linux-gnu.so +0 -0
  51. amsdal/cloud/services/actions/delete_secret.pyi +21 -0
  52. amsdal/cloud/services/actions/destroy_deploy.cpython-311-x86_64-linux-gnu.so +0 -0
  53. amsdal/cloud/services/actions/destroy_deploy.pyi +18 -0
  54. amsdal/cloud/services/actions/expose_db.cpython-311-x86_64-linux-gnu.so +0 -0
  55. amsdal/cloud/services/actions/expose_db.pyi +22 -0
  56. amsdal/cloud/services/actions/get_basic_auth_credentials.cpython-311-x86_64-linux-gnu.so +0 -0
  57. amsdal/cloud/services/actions/get_basic_auth_credentials.pyi +21 -0
  58. amsdal/cloud/services/actions/get_monitoring_info.cpython-311-x86_64-linux-gnu.so +0 -0
  59. amsdal/cloud/services/actions/get_monitoring_info.pyi +21 -0
  60. amsdal/cloud/services/actions/list_dependencies.cpython-311-x86_64-linux-gnu.so +0 -0
  61. amsdal/cloud/services/actions/list_dependencies.pyi +21 -0
  62. amsdal/cloud/services/actions/list_deploys.cpython-311-x86_64-linux-gnu.so +0 -0
  63. amsdal/cloud/services/actions/list_deploys.pyi +19 -0
  64. amsdal/cloud/services/actions/list_envs.cpython-311-x86_64-linux-gnu.so +0 -0
  65. amsdal/cloud/services/actions/list_envs.pyi +20 -0
  66. amsdal/cloud/services/actions/list_secrets.cpython-311-x86_64-linux-gnu.so +0 -0
  67. amsdal/cloud/services/actions/list_secrets.pyi +22 -0
  68. amsdal/cloud/services/actions/manager.cpython-311-x86_64-linux-gnu.so +0 -0
  69. amsdal/cloud/services/actions/manager.pyi +278 -0
  70. amsdal/cloud/services/actions/signup_action.cpython-311-x86_64-linux-gnu.so +0 -0
  71. amsdal/cloud/services/actions/signup_action.pyi +20 -0
  72. amsdal/cloud/services/actions/update_deploy.cpython-311-x86_64-linux-gnu.so +0 -0
  73. amsdal/cloud/services/actions/update_deploy.pyi +19 -0
  74. amsdal/cloud/services/auth/__init__.cpython-311-x86_64-linux-gnu.so +0 -0
  75. amsdal/cloud/services/auth/__init__.pyi +0 -0
  76. amsdal/cloud/services/auth/base.cpython-311-x86_64-linux-gnu.so +0 -0
  77. amsdal/cloud/services/auth/base.pyi +6 -0
  78. amsdal/cloud/services/auth/credentials.cpython-311-x86_64-linux-gnu.so +0 -0
  79. amsdal/cloud/services/auth/credentials.pyi +30 -0
  80. amsdal/cloud/services/auth/manager.cpython-311-x86_64-linux-gnu.so +0 -0
  81. amsdal/cloud/services/auth/manager.pyi +26 -0
  82. amsdal/cloud/services/auth/signup_service.cpython-311-x86_64-linux-gnu.so +0 -0
  83. amsdal/cloud/services/auth/signup_service.pyi +32 -0
  84. amsdal/cloud/services/auth/token.cpython-311-x86_64-linux-gnu.so +0 -0
  85. amsdal/cloud/services/auth/token.pyi +27 -0
  86. amsdal/configs/__init__.py +0 -0
  87. amsdal/configs/__init__.pyi +0 -0
  88. amsdal/configs/constants.py +33 -0
  89. amsdal/configs/constants.pyi +22 -0
  90. amsdal/configs/main.py +258 -0
  91. amsdal/configs/main.pyi +173 -0
  92. amsdal/context/__init__.py +0 -0
  93. amsdal/context/__init__.pyi +0 -0
  94. amsdal/context/manager.py +69 -0
  95. amsdal/context/manager.pyi +50 -0
  96. amsdal/contrib/__init__.cpython-311-x86_64-linux-gnu.so +0 -0
  97. amsdal/contrib/__init__.pyi +0 -0
  98. amsdal/contrib/app_config.py +7 -0
  99. amsdal/contrib/app_config.pyi +6 -0
  100. amsdal/contrib/auth/__init__.py +0 -0
  101. amsdal/contrib/auth/__init__.pyi +0 -0
  102. amsdal/contrib/auth/app.py +27 -0
  103. amsdal/contrib/auth/app.pyi +15 -0
  104. amsdal/contrib/auth/decorators/__init__.py +35 -0
  105. amsdal/contrib/auth/decorators/__init__.pyi +6 -0
  106. amsdal/contrib/auth/errors.py +7 -0
  107. amsdal/contrib/auth/errors.pyi +4 -0
  108. amsdal/contrib/auth/fixtures/basic_permissions.json +64 -0
  109. amsdal/contrib/auth/lifecycle/__init__.py +0 -0
  110. amsdal/contrib/auth/lifecycle/__init__.pyi +0 -0
  111. amsdal/contrib/auth/lifecycle/consumer.py +394 -0
  112. amsdal/contrib/auth/lifecycle/consumer.pyi +108 -0
  113. amsdal/contrib/auth/migrations/0000_initial.py +84 -0
  114. amsdal/contrib/auth/models/__init__.py +0 -0
  115. amsdal/contrib/auth/models/__init__.pyi +0 -0
  116. amsdal/contrib/auth/models/login_session.py +118 -0
  117. amsdal/contrib/auth/models/login_session.pyi +37 -0
  118. amsdal/contrib/auth/models/permission.py +23 -0
  119. amsdal/contrib/auth/models/permission.pyi +18 -0
  120. amsdal/contrib/auth/models/user.py +106 -0
  121. amsdal/contrib/auth/models/user.pyi +46 -0
  122. amsdal/contrib/auth/settings.py +36 -0
  123. amsdal/contrib/auth/settings.pyi +26 -0
  124. amsdal/contrib/frontend_configs/__init__.py +0 -0
  125. amsdal/contrib/frontend_configs/__init__.pyi +0 -0
  126. amsdal/contrib/frontend_configs/app.py +24 -0
  127. amsdal/contrib/frontend_configs/app.pyi +19 -0
  128. amsdal/contrib/frontend_configs/constants.py +1 -0
  129. amsdal/contrib/frontend_configs/constants.pyi +1 -0
  130. amsdal/contrib/frontend_configs/conversion/__init__.py +5 -0
  131. amsdal/contrib/frontend_configs/conversion/__init__.pyi +3 -0
  132. amsdal/contrib/frontend_configs/conversion/convert.py +286 -0
  133. amsdal/contrib/frontend_configs/conversion/convert.pyi +22 -0
  134. amsdal/contrib/frontend_configs/lifecycle/__init__.py +0 -0
  135. amsdal/contrib/frontend_configs/lifecycle/__init__.pyi +0 -0
  136. amsdal/contrib/frontend_configs/lifecycle/consumer.py +306 -0
  137. amsdal/contrib/frontend_configs/lifecycle/consumer.pyi +98 -0
  138. amsdal/contrib/frontend_configs/migrations/0000_initial.py +256 -0
  139. amsdal/contrib/frontend_configs/models/__init__.py +0 -0
  140. amsdal/contrib/frontend_configs/models/__init__.pyi +0 -0
  141. amsdal/contrib/frontend_configs/models/frontend_activator_config.py +22 -0
  142. amsdal/contrib/frontend_configs/models/frontend_activator_config.pyi +12 -0
  143. amsdal/contrib/frontend_configs/models/frontend_config_async_validator.py +11 -0
  144. amsdal/contrib/frontend_configs/models/frontend_config_async_validator.pyi +7 -0
  145. amsdal/contrib/frontend_configs/models/frontend_config_control_action.py +54 -0
  146. amsdal/contrib/frontend_configs/models/frontend_config_control_action.pyi +32 -0
  147. amsdal/contrib/frontend_configs/models/frontend_config_group_validator.py +21 -0
  148. amsdal/contrib/frontend_configs/models/frontend_config_group_validator.pyi +11 -0
  149. amsdal/contrib/frontend_configs/models/frontend_config_option.py +12 -0
  150. amsdal/contrib/frontend_configs/models/frontend_config_option.pyi +8 -0
  151. amsdal/contrib/frontend_configs/models/frontend_config_skip_none_base.py +17 -0
  152. amsdal/contrib/frontend_configs/models/frontend_config_skip_none_base.pyi +8 -0
  153. amsdal/contrib/frontend_configs/models/frontend_config_slider_option.py +13 -0
  154. amsdal/contrib/frontend_configs/models/frontend_config_slider_option.pyi +9 -0
  155. amsdal/contrib/frontend_configs/models/frontend_config_text_mask.py +14 -0
  156. amsdal/contrib/frontend_configs/models/frontend_config_text_mask.pyi +10 -0
  157. amsdal/contrib/frontend_configs/models/frontend_config_validator.py +28 -0
  158. amsdal/contrib/frontend_configs/models/frontend_config_validator.pyi +15 -0
  159. amsdal/contrib/frontend_configs/models/frontend_control_config.py +87 -0
  160. amsdal/contrib/frontend_configs/models/frontend_control_config.pyi +35 -0
  161. amsdal/contrib/frontend_configs/models/frontend_model_config.py +14 -0
  162. amsdal/contrib/frontend_configs/models/frontend_model_config.pyi +9 -0
  163. amsdal/contrib/frontend_configs/utils.py +29 -0
  164. amsdal/contrib/frontend_configs/utils.pyi +17 -0
  165. amsdal/errors.py +31 -0
  166. amsdal/errors.pyi +12 -0
  167. amsdal/fixtures/__init__.cpython-311-x86_64-linux-gnu.so +0 -0
  168. amsdal/fixtures/__init__.pyi +0 -0
  169. amsdal/fixtures/manager.cpython-311-x86_64-linux-gnu.so +0 -0
  170. amsdal/fixtures/manager.pyi +170 -0
  171. amsdal/fixtures/utils.cpython-311-x86_64-linux-gnu.so +0 -0
  172. amsdal/fixtures/utils.pyi +9 -0
  173. amsdal/manager.cpython-311-x86_64-linux-gnu.so +0 -0
  174. amsdal/manager.pyi +265 -0
  175. amsdal/mixins/__init__.cpython-311-x86_64-linux-gnu.so +0 -0
  176. amsdal/mixins/__init__.pyi +0 -0
  177. amsdal/mixins/class_versions_mixin.cpython-311-x86_64-linux-gnu.so +0 -0
  178. amsdal/mixins/class_versions_mixin.pyi +12 -0
  179. amsdal/models/__init__.py +19 -0
  180. amsdal/models/__init__.pyi +9 -0
  181. amsdal/models/core/__init__.py +0 -0
  182. amsdal/models/core/__init__.pyi +0 -0
  183. amsdal/models/core/class_object.py +37 -0
  184. amsdal/models/core/class_object.pyi +24 -0
  185. amsdal/models/core/class_object_meta.py +26 -0
  186. amsdal/models/core/class_object_meta.pyi +15 -0
  187. amsdal/models/core/class_property.py +20 -0
  188. amsdal/models/core/class_property.pyi +11 -0
  189. amsdal/models/core/class_property_meta.py +15 -0
  190. amsdal/models/core/class_property_meta.pyi +10 -0
  191. amsdal/models/core/file.py +156 -0
  192. amsdal/models/core/file.pyi +104 -0
  193. amsdal/models/core/fixture.py +25 -0
  194. amsdal/models/core/fixture.pyi +14 -0
  195. amsdal/models/core/option.py +11 -0
  196. amsdal/models/core/option.pyi +8 -0
  197. amsdal/models/core/validator.py +12 -0
  198. amsdal/models/core/validator.pyi +8 -0
  199. amsdal/models/types/__init__.py +0 -0
  200. amsdal/models/types/__init__.pyi +0 -0
  201. amsdal/models/types/object.py +26 -0
  202. amsdal/models/types/object.pyi +16 -0
  203. amsdal/py.typed +0 -0
  204. amsdal/queryset/__init__.py +21 -0
  205. amsdal/queryset/__init__.pyi +6 -0
  206. amsdal/schemas/__init__.py +0 -0
  207. amsdal/schemas/__init__.pyi +0 -0
  208. amsdal/schemas/core/class_object/model.json +31 -0
  209. amsdal/schemas/core/class_object/properties/display_name.py +9 -0
  210. amsdal/schemas/core/class_object_meta/model.json +59 -0
  211. amsdal/schemas/core/class_property/model.json +22 -0
  212. amsdal/schemas/core/class_property_meta/model.json +23 -0
  213. amsdal/schemas/core/file/hooks/pre_create.py +24 -0
  214. amsdal/schemas/core/file/hooks/pre_update.py +24 -0
  215. amsdal/schemas/core/file/model.json +23 -0
  216. amsdal/schemas/core/file/properties/from_file.py +34 -0
  217. amsdal/schemas/core/file/properties/mimetype.py +13 -0
  218. amsdal/schemas/core/file/properties/str.py +6 -0
  219. amsdal/schemas/core/file/properties/to_file.py +24 -0
  220. amsdal/schemas/core/file/properties/validate_data.py +32 -0
  221. amsdal/schemas/core/fixture/model.json +35 -0
  222. amsdal/schemas/core/option/model.json +19 -0
  223. amsdal/schemas/core/validator/model.json +19 -0
  224. amsdal/schemas/interfaces.py +25 -0
  225. amsdal/schemas/interfaces.pyi +20 -0
  226. amsdal/schemas/manager.cpython-311-x86_64-linux-gnu.so +0 -0
  227. amsdal/schemas/manager.py +0 -0
  228. amsdal/schemas/manager.pyi +0 -0
  229. amsdal/schemas/mixins/__init__.py +0 -0
  230. amsdal/schemas/mixins/__init__.pyi +0 -0
  231. amsdal/schemas/mixins/check_dependencies_mixin.py +125 -0
  232. amsdal/schemas/mixins/check_dependencies_mixin.pyi +45 -0
  233. amsdal/schemas/mixins/verify_schemas_mixin.py +96 -0
  234. amsdal/schemas/mixins/verify_schemas_mixin.pyi +33 -0
  235. amsdal/schemas/repository.py +84 -0
  236. amsdal/schemas/repository.pyi +22 -0
  237. amsdal/schemas/types/anything/model.json +7 -0
  238. amsdal/schemas/types/array/model.json +7 -0
  239. amsdal/schemas/types/binary/model.json +7 -0
  240. amsdal/schemas/types/boolean/model.json +17 -0
  241. amsdal/schemas/types/date/model.json +7 -0
  242. amsdal/schemas/types/datetime/model.json +7 -0
  243. amsdal/schemas/types/dictionary/model.json +8 -0
  244. amsdal/schemas/types/number/model.json +8 -0
  245. amsdal/schemas/types/object/model.json +53 -0
  246. amsdal/schemas/types/string/model.json +8 -0
  247. amsdal/schemas/utils.py +16 -0
  248. amsdal/schemas/utils.pyi +10 -0
  249. amsdal/services/__init__.cpython-311-x86_64-linux-gnu.so +0 -0
  250. amsdal/services/__init__.pyi +0 -0
  251. amsdal/services/transaction_execution.cpython-311-x86_64-linux-gnu.so +0 -0
  252. amsdal/services/transaction_execution.pyi +93 -0
  253. amsdal/transactions/__init__.py +13 -0
  254. amsdal/transactions/__init__.pyi +4 -0
  255. amsdal/utils/__init__.py +0 -0
  256. amsdal/utils/__init__.pyi +0 -0
  257. amsdal/utils/contrib_paths.py +23 -0
  258. amsdal/utils/contrib_paths.pyi +14 -0
  259. amsdal/utils/rollback/__init__.py +440 -0
  260. amsdal/utils/rollback/__init__.pyi +38 -0
  261. amsdal/utils/tests/__init__.py +0 -0
  262. amsdal/utils/tests/enums.py +18 -0
  263. amsdal/utils/tests/factories.py +49 -0
  264. amsdal/utils/tests/helpers.py +499 -0
  265. amsdal-0.4.13.dist-info/METADATA +369 -0
  266. amsdal-0.4.13.dist-info/RECORD +269 -0
  267. amsdal-0.4.13.dist-info/WHEEL +6 -0
  268. amsdal-0.4.13.dist-info/licenses/LICENSE.txt +107 -0
  269. amsdal-0.4.13.dist-info/top_level.txt +1 -0
@@ -0,0 +1,104 @@
1
+ from amsdal_models.classes.model import Model
2
+ from amsdal_utils.models.enums import ModuleType
3
+ from pathlib import Path
4
+ from typing import BinaryIO, ClassVar
5
+
6
+ class File(Model):
7
+ __module_type__: ClassVar[ModuleType] = ...
8
+ filename: str = ...
9
+ data: bytes = ...
10
+ size: float | None = ...
11
+ def __repr__(self) -> str: ...
12
+ def __str__(self) -> str: ...
13
+ async def apre_create(self) -> None:
14
+ """
15
+ Prepares the object for creation by setting its size attribute.
16
+
17
+ This method calculates the size of the object's data and assigns it to the size attribute.
18
+ If the data is None, it defaults to an empty byte string.
19
+
20
+ Args:
21
+ None
22
+ """
23
+ async def apre_update(self) -> None:
24
+ """
25
+ Prepares the object for update by setting its size attribute.
26
+
27
+ This method calculates the size of the object's data and assigns it to the size attribute.
28
+ If the data is None, it defaults to an empty byte string.
29
+
30
+ Args:
31
+ None
32
+ """
33
+ @classmethod
34
+ def data_base64_decode(cls, v: bytes) -> bytes:
35
+ """
36
+ Decodes a base64-encoded byte string if it is base64-encoded.
37
+
38
+ This method checks if the provided byte string is base64-encoded and decodes it if true.
39
+ If the byte string is not base64-encoded, it returns the original byte string.
40
+
41
+ Args:
42
+ cls: The class this method belongs to.
43
+ v (bytes): The byte string to be checked and potentially decoded.
44
+
45
+ Returns:
46
+ bytes: The decoded byte string if it was base64-encoded, otherwise the original byte string.
47
+ """
48
+ @classmethod
49
+ def from_file(cls, file_or_path: Path | BinaryIO) -> File:
50
+ """
51
+ Creates a `File` object from a file path or a binary file object.
52
+
53
+ Args:
54
+ file_or_path (Path | BinaryIO): The file path or binary file object.
55
+
56
+ Returns:
57
+ File: The created `File` object.
58
+
59
+ Raises:
60
+ ValueError: If the provided path is a directory.
61
+ """
62
+ @property
63
+ def mimetype(self) -> str | None:
64
+ """
65
+ Returns the MIME type of the file based on its filename.
66
+
67
+ This method uses the `mimetypes` module to guess the MIME type of the file.
68
+
69
+ Returns:
70
+ str | None: The guessed MIME type of the file, or None if it cannot be determined.
71
+ """
72
+ def pre_create(self) -> None:
73
+ """
74
+ Prepares the object for creation by setting its size attribute.
75
+
76
+ This method calculates the size of the object's data and assigns it to the size attribute.
77
+ If the data is None, it defaults to an empty byte string.
78
+
79
+ Args:
80
+ None
81
+ """
82
+ def pre_update(self) -> None:
83
+ """
84
+ Prepares the object for update by setting its size attribute.
85
+
86
+ This method calculates the size of the object's data and assigns it to the size attribute.
87
+ If the data is None, it defaults to an empty byte string.
88
+
89
+ Args:
90
+ None
91
+ """
92
+ def to_file(self, file_or_path: Path | BinaryIO) -> None:
93
+ """
94
+ Writes the object's data to a file path or a binary file object.
95
+
96
+ Args:
97
+ file_or_path (Path | BinaryIO): The file path or binary file object where the data will be written.
98
+
99
+ Returns:
100
+ None
101
+
102
+ Raises:
103
+ ValueError: If the provided path is a directory.
104
+ """
@@ -0,0 +1,25 @@
1
+ from typing import Any
2
+ from typing import ClassVar
3
+
4
+ from amsdal_models.builder.validators.dict_validators import validate_non_empty_keys
5
+ from amsdal_models.classes.data_models.constraints import UniqueConstraint
6
+ from amsdal_models.classes.model import Model
7
+ from amsdal_utils.models.enums import ModuleType
8
+ from pydantic.fields import Field
9
+ from pydantic.functional_validators import field_validator
10
+
11
+
12
+ class Fixture(Model):
13
+ __module_type__: ClassVar[ModuleType] = ModuleType.CORE
14
+ __constraints__: ClassVar[list[UniqueConstraint]] = [
15
+ UniqueConstraint(name='unq_fixture_external_id', fields=['external_id'])
16
+ ]
17
+ class_name: str | None = Field(None, title='Class Name')
18
+ order: float | None = Field(None, title='Order')
19
+ external_id: str = Field(title='External ID')
20
+ data: dict[str, Any | None] = Field(title='Data')
21
+
22
+ @field_validator('data')
23
+ @classmethod
24
+ def _non_empty_keys_data(cls: type, value: Any) -> Any:
25
+ return validate_non_empty_keys(value)
@@ -0,0 +1,14 @@
1
+ from amsdal_models.classes.data_models.constraints import UniqueConstraint
2
+ from amsdal_models.classes.model import Model
3
+ from amsdal_utils.models.enums import ModuleType
4
+ from typing import Any, ClassVar
5
+
6
+ class Fixture(Model):
7
+ __module_type__: ClassVar[ModuleType] = ...
8
+ __constraints__: ClassVar[list[UniqueConstraint]] = ...
9
+ class_name: str | None = ...
10
+ order: float | None = ...
11
+ external_id: str = ...
12
+ data: dict[str, Any | None] = ...
13
+ @classmethod
14
+ def _non_empty_keys_data(cls, value: Any) -> Any: ...
@@ -0,0 +1,11 @@
1
+ from typing import ClassVar
2
+
3
+ from amsdal_models.classes.model import TypeModel
4
+ from amsdal_utils.models.enums import ModuleType
5
+ from pydantic.fields import Field
6
+
7
+
8
+ class Option(TypeModel):
9
+ __module_type__: ClassVar[ModuleType] = ModuleType.CORE
10
+ key: str = Field(title='Key')
11
+ value: str = Field(title='Value Type')
@@ -0,0 +1,8 @@
1
+ from amsdal_models.classes.model import TypeModel
2
+ from amsdal_utils.models.enums import ModuleType
3
+ from typing import ClassVar
4
+
5
+ class Option(TypeModel):
6
+ __module_type__: ClassVar[ModuleType]
7
+ key: str
8
+ value: str
@@ -0,0 +1,12 @@
1
+ from typing import Any
2
+ from typing import ClassVar
3
+
4
+ from amsdal_models.classes.model import TypeModel
5
+ from amsdal_utils.models.enums import ModuleType
6
+ from pydantic.fields import Field
7
+
8
+
9
+ class Validator(TypeModel):
10
+ __module_type__: ClassVar[ModuleType] = ModuleType.CORE
11
+ name: str = Field(title='Validator Name')
12
+ data: Any = Field(title='Validator Data')
@@ -0,0 +1,8 @@
1
+ from amsdal_models.classes.model import TypeModel
2
+ from amsdal_utils.models.enums import ModuleType
3
+ from typing import Any, ClassVar
4
+
5
+ class Validator(TypeModel):
6
+ __module_type__: ClassVar[ModuleType]
7
+ name: str
8
+ data: Any
File without changes
File without changes
@@ -0,0 +1,26 @@
1
+ from typing import Any
2
+ from typing import ClassVar
3
+ from typing import Optional
4
+
5
+ from amsdal_models.builder.validators.dict_validators import validate_non_empty_keys
6
+ from amsdal_models.classes.model import Model
7
+ from amsdal_utils.models.enums import ModuleType
8
+ from pydantic.fields import Field
9
+ from pydantic.functional_validators import field_validator
10
+
11
+
12
+ class Object(Model):
13
+ __module_type__: ClassVar[ModuleType] = ModuleType.TYPE
14
+ title: Optional[str] = Field(None, title='Title') # noqa: UP007
15
+ type: Optional[str] = Field(None, title='Type') # noqa: UP007
16
+ default: Optional[Any] = Field(None, title='Default') # noqa: UP007
17
+ properties: Optional[dict[str, Optional[Any]]] = Field(None, title='Properties') # noqa: UP007
18
+ required: Optional[list[str]] = Field(None, title='Required') # noqa: UP007
19
+ unique: Optional[list[list[str]]] = Field(None, title='Unique Fields') # noqa: UP007
20
+ custom_code: Optional[str] = Field(None, title='Custom Code') # noqa: UP007
21
+ meta_class: Optional[str] = Field(None, title='Meta Class') # noqa: UP007
22
+
23
+ @field_validator('properties')
24
+ @classmethod
25
+ def _non_empty_keys_properties(cls: type, value: Any) -> Any: # type: ignore # noqa: A003
26
+ return validate_non_empty_keys(value)
@@ -0,0 +1,16 @@
1
+ from amsdal_models.classes.model import Model
2
+ from amsdal_utils.models.enums import ModuleType
3
+ from typing import Any, ClassVar
4
+
5
+ class Object(Model):
6
+ __module_type__: ClassVar[ModuleType] = ...
7
+ title: str | None = ...
8
+ type: str | None = ...
9
+ default: Any | None = ...
10
+ properties: dict[str, Any | None] | None = ...
11
+ required: list[str] | None = ...
12
+ unique: list[list[str]] | None = ...
13
+ custom_code: str | None = ...
14
+ meta_class: str | None = ...
15
+ @classmethod
16
+ def _non_empty_keys_properties(cls, value: Any) -> Any: ...
amsdal/py.typed ADDED
File without changes
@@ -0,0 +1,21 @@
1
+ from amsdal_models.querysets.base_queryset import QuerySet
2
+ from amsdal_models.querysets.base_queryset import QuerySetCount
3
+ from amsdal_models.querysets.base_queryset import QuerySetOne
4
+ from amsdal_models.querysets.base_queryset import QuerySetOneRequired
5
+ from amsdal_utils.query.data_models.filter import Filter
6
+ from amsdal_utils.query.enums import Lookup
7
+ from amsdal_utils.query.enums import OrderDirection
8
+ from amsdal_utils.query.utils import ConnectorEnum
9
+ from amsdal_utils.query.utils import Q
10
+
11
+ __all__ = [
12
+ 'ConnectorEnum',
13
+ 'Filter',
14
+ 'Lookup',
15
+ 'OrderDirection',
16
+ 'Q',
17
+ 'QuerySet',
18
+ 'QuerySetCount',
19
+ 'QuerySetOne',
20
+ 'QuerySetOneRequired',
21
+ ]
@@ -0,0 +1,6 @@
1
+ from amsdal_models.querysets.base_queryset import QuerySet as QuerySet, QuerySetCount as QuerySetCount, QuerySetOne as QuerySetOne, QuerySetOneRequired as QuerySetOneRequired
2
+ from amsdal_utils.query.data_models.filter import Filter as Filter
3
+ from amsdal_utils.query.enums import Lookup as Lookup, OrderDirection as OrderDirection
4
+ from amsdal_utils.query.utils import ConnectorEnum as ConnectorEnum, Q as Q
5
+
6
+ __all__ = ['ConnectorEnum', 'Filter', 'Lookup', 'OrderDirection', 'Q', 'QuerySet', 'QuerySetCount', 'QuerySetOne', 'QuerySetOneRequired']
File without changes
File without changes
@@ -0,0 +1,31 @@
1
+ {
2
+ "title": "ClassObject",
3
+ "type": "object",
4
+ "properties": {
5
+ "properties": {
6
+ "title": "Properties",
7
+ "type": "dictionary",
8
+ "items": {
9
+ "key": {
10
+ "type": "string"
11
+ },
12
+ "value": {
13
+ "type": "ClassProperty"
14
+ }
15
+ }
16
+ },
17
+ "required": {
18
+ "title": "Required",
19
+ "type": "array",
20
+ "items": {
21
+ "type": "string"
22
+ }
23
+ },
24
+ "meta_class": {
25
+ "title": "Meta Class",
26
+ "type": "string",
27
+ "default": "ClassObject"
28
+ }
29
+ },
30
+ "required": []
31
+ }
@@ -0,0 +1,9 @@
1
+ @property # type: ignore[misc]
2
+ def display_name(self) -> str: # type: ignore[no-untyped-def]
3
+ """
4
+ Returns the display name of the object.
5
+
6
+ Returns:
7
+ str: The display name, which is the title of the object.
8
+ """
9
+ return self.title
@@ -0,0 +1,59 @@
1
+ {
2
+ "title": "ClassObjectMeta",
3
+ "type": "object",
4
+ "properties": {
5
+ "title": {
6
+ "title": "Title",
7
+ "type": "string"
8
+ },
9
+ "type": {
10
+ "title": "Type",
11
+ "type": "string"
12
+ },
13
+ "default": {
14
+ "title": "Default",
15
+ "type": "anything"
16
+ },
17
+ "class_schema_type": {
18
+ "title": "Schema Type",
19
+ "type": "string"
20
+ },
21
+ "properties": {
22
+ "title": "Properties",
23
+ "type": "dictionary",
24
+ "items": {
25
+ "key": {
26
+ "type": "string"
27
+ },
28
+ "value": {
29
+ "type": "ClassPropertyMeta"
30
+ }
31
+ }
32
+ },
33
+ "indexed": {
34
+ "title": "Indexed",
35
+ "type": "array",
36
+ "items": {
37
+ "type": "string"
38
+ }
39
+ },
40
+ "unique": {
41
+ "title": "Unique Fields",
42
+ "type": "array",
43
+ "items": {
44
+ "type": "array",
45
+ "items": {
46
+ "type": "string"
47
+ }
48
+ }
49
+ },
50
+ "custom_code": {
51
+ "title": "Custom Code",
52
+ "type": "string"
53
+ }
54
+ },
55
+ "required": [
56
+ "title",
57
+ "type"
58
+ ]
59
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "title": "ClassProperty",
3
+ "type": "object",
4
+ "properties": {
5
+ "type": {
6
+ "title": "Type",
7
+ "type": "string"
8
+ },
9
+ "items": {
10
+ "title": "Items",
11
+ "type": "dictionary",
12
+ "items": {
13
+ "key": {"type": "string"},
14
+ "value": {"type": "anything"}
15
+ }
16
+ }
17
+ },
18
+ "required": [
19
+ "type"
20
+ ],
21
+ "meta_class": "TypeMeta"
22
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "title": "ClassPropertyMeta",
3
+ "type": "object",
4
+ "properties": {
5
+ "title": {
6
+ "title": "Title",
7
+ "type": "string"
8
+ },
9
+ "default": {
10
+ "title": "Default",
11
+ "type": "anything"
12
+ },
13
+ "options": {
14
+ "title": "Options",
15
+ "type": "array",
16
+ "items": {
17
+ "type": "Option"
18
+ }
19
+ }
20
+ },
21
+ "required": [],
22
+ "meta_class": "TypeMeta"
23
+ }
@@ -0,0 +1,24 @@
1
+ def pre_create(self) -> None: # type: ignore[no-untyped-def]
2
+ """
3
+ Prepares the object for creation by setting its size attribute.
4
+
5
+ This method calculates the size of the object's data and assigns it to the size attribute.
6
+ If the data is None, it defaults to an empty byte string.
7
+
8
+ Args:
9
+ None
10
+ """
11
+ self.size = len(self.data or b'')
12
+
13
+
14
+ async def apre_create(self) -> None: # type: ignore[no-untyped-def]
15
+ """
16
+ Prepares the object for creation by setting its size attribute.
17
+
18
+ This method calculates the size of the object's data and assigns it to the size attribute.
19
+ If the data is None, it defaults to an empty byte string.
20
+
21
+ Args:
22
+ None
23
+ """
24
+ self.size = len(self.data or b'')
@@ -0,0 +1,24 @@
1
+ def pre_update(self): # type: ignore[no-untyped-def]
2
+ """
3
+ Prepares the object for update by setting its size attribute.
4
+
5
+ This method calculates the size of the object's data and assigns it to the size attribute.
6
+ If the data is None, it defaults to an empty byte string.
7
+
8
+ Args:
9
+ None
10
+ """
11
+ self.size = len(self.data or b'')
12
+
13
+
14
+ async def apre_update(self): # type: ignore[no-untyped-def]
15
+ """
16
+ Prepares the object for update by setting its size attribute.
17
+
18
+ This method calculates the size of the object's data and assigns it to the size attribute.
19
+ If the data is None, it defaults to an empty byte string.
20
+
21
+ Args:
22
+ None
23
+ """
24
+ self.size = len(self.data or b'')
@@ -0,0 +1,23 @@
1
+ {
2
+ "title": "File",
3
+ "type": "object",
4
+ "default": null,
5
+ "properties": {
6
+ "filename": {
7
+ "title": "Filename",
8
+ "type": "string"
9
+ },
10
+ "data": {
11
+ "title": "Data",
12
+ "type": "binary"
13
+ },
14
+ "size": {
15
+ "title": "Size",
16
+ "type": "number"
17
+ }
18
+ },
19
+ "required": [
20
+ "filename",
21
+ "data"
22
+ ]
23
+ }
@@ -0,0 +1,34 @@
1
+ from pathlib import Path
2
+ from typing import BinaryIO
3
+
4
+
5
+ @classmethod # type: ignore[misc, no-untyped-def]
6
+ def from_file( # type: ignore[no-untyped-def]
7
+ cls,
8
+ file_or_path: Path | BinaryIO,
9
+ ) -> 'File': # type: ignore[name-defined] # noqa: F821
10
+ """
11
+ Creates a `File` object from a file path or a binary file object.
12
+
13
+ Args:
14
+ file_or_path (Path | BinaryIO): The file path or binary file object.
15
+
16
+ Returns:
17
+ File: The created `File` object.
18
+
19
+ Raises:
20
+ ValueError: If the provided path is a directory.
21
+ """
22
+ if isinstance(file_or_path, Path):
23
+ if file_or_path.is_dir():
24
+ msg = f'{file_or_path} is a directory'
25
+ raise ValueError(msg)
26
+
27
+ data = file_or_path.read_bytes()
28
+ filename = file_or_path.name
29
+ else:
30
+ file_or_path.seek(0)
31
+ data = file_or_path.read()
32
+ filename = Path(file_or_path.name).name
33
+
34
+ return cls(data=data, filename=filename)
@@ -0,0 +1,13 @@
1
+ @property # type: ignore[misc]
2
+ def mimetype(self) -> str | None: # type: ignore[no-untyped-def]
3
+ """
4
+ Returns the MIME type of the file based on its filename.
5
+
6
+ This method uses the `mimetypes` module to guess the MIME type of the file.
7
+
8
+ Returns:
9
+ str | None: The guessed MIME type of the file, or None if it cannot be determined.
10
+ """
11
+ import mimetypes
12
+
13
+ return mimetypes.guess_type(self.filename)[0]
@@ -0,0 +1,6 @@
1
+ def __str__(self) -> str: # type: ignore[no-untyped-def] # noqa: N807
2
+ return repr(self)
3
+
4
+
5
+ def __repr__(self) -> str: # type: ignore[no-untyped-def] # noqa: N807
6
+ return f'File<{self.filename}>({self.size or len(self.data) or 0} bytes)'
@@ -0,0 +1,24 @@
1
+ from pathlib import Path
2
+ from typing import BinaryIO
3
+
4
+
5
+ def to_file(self, file_or_path: Path | BinaryIO) -> None: # type: ignore[no-untyped-def]
6
+ """
7
+ Writes the object's data to a file path or a binary file object.
8
+
9
+ Args:
10
+ file_or_path (Path | BinaryIO): The file path or binary file object where the data will be written.
11
+
12
+ Returns:
13
+ None
14
+
15
+ Raises:
16
+ ValueError: If the provided path is a directory.
17
+ """
18
+ if isinstance(file_or_path, Path):
19
+ if file_or_path.is_dir():
20
+ file_or_path = file_or_path / self.name
21
+ file_or_path.write_bytes(self.data) # type: ignore[union-attr]
22
+ else:
23
+ file_or_path.write(self.data)
24
+ file_or_path.seek(0)
@@ -0,0 +1,32 @@
1
+ import base64
2
+
3
+ from pydantic import field_validator
4
+
5
+
6
+ @field_validator('data') # type: ignore[misc]
7
+ @classmethod
8
+ def data_base64_decode(cls, v: bytes) -> bytes: # type: ignore[no-untyped-def]
9
+ """
10
+ Decodes a base64-encoded byte string if it is base64-encoded.
11
+
12
+ This method checks if the provided byte string is base64-encoded and decodes it if true.
13
+ If the byte string is not base64-encoded, it returns the original byte string.
14
+
15
+ Args:
16
+ cls: The class this method belongs to.
17
+ v (bytes): The byte string to be checked and potentially decoded.
18
+
19
+ Returns:
20
+ bytes: The decoded byte string if it was base64-encoded, otherwise the original byte string.
21
+ """
22
+ is_base64: bool = False
23
+
24
+ try:
25
+ is_base64 = base64.b64encode(base64.b64decode(v)) == v
26
+ except Exception:
27
+ ...
28
+
29
+ if is_base64:
30
+ return base64.b64decode(v)
31
+
32
+ return v
@@ -0,0 +1,35 @@
1
+ {
2
+ "title": "Fixture",
3
+ "type": "object",
4
+ "properties": {
5
+ "class_name": {
6
+ "title": "Class Name",
7
+ "type": "string"
8
+ },
9
+ "order": {
10
+ "title": "Order",
11
+ "type": "number"
12
+ },
13
+ "external_id": {
14
+ "title": "External ID",
15
+ "type": "string"
16
+ },
17
+ "data": {
18
+ "title": "Data",
19
+ "type": "dictionary",
20
+ "items": {
21
+ "key": {"type": "string"},
22
+ "value": {"type": "anything"}
23
+ }
24
+ }
25
+ },
26
+ "required": [
27
+ "data",
28
+ "external_id"
29
+ ],
30
+ "unique": [
31
+ [
32
+ "external_id"
33
+ ]
34
+ ]
35
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "title": "Option",
3
+ "type": "object",
4
+ "properties": {
5
+ "key": {
6
+ "title": "Key",
7
+ "type": "string"
8
+ },
9
+ "value": {
10
+ "title": "Value Type",
11
+ "type": "string"
12
+ }
13
+ },
14
+ "required": [
15
+ "key",
16
+ "value"
17
+ ],
18
+ "meta_class": "TypeMeta"
19
+ }