amsdal 0.5.34__cp313-cp313-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 (276) hide show
  1. amsdal/Third-Party Materials - AMSDAL Dependencies - License Notices.md +1362 -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 +36 -0
  7. amsdal/__migrations__/0001_create_class_file.py +61 -0
  8. amsdal/__migrations__/0002_create_class_file.py +109 -0
  9. amsdal/__migrations__/0003_update_class_file.py +91 -0
  10. amsdal/__migrations__/0004_update_class_file.py +45 -0
  11. amsdal/cloud/__init__.cpython-313-x86_64-linux-gnu.so +0 -0
  12. amsdal/cloud/__init__.pyi +0 -0
  13. amsdal/cloud/client.cpython-313-x86_64-linux-gnu.so +0 -0
  14. amsdal/cloud/client.pyi +57 -0
  15. amsdal/cloud/constants.cpython-313-x86_64-linux-gnu.so +0 -0
  16. amsdal/cloud/constants.pyi +13 -0
  17. amsdal/cloud/enums.cpython-313-x86_64-linux-gnu.so +0 -0
  18. amsdal/cloud/enums.pyi +68 -0
  19. amsdal/cloud/models/__init__.cpython-313-x86_64-linux-gnu.so +0 -0
  20. amsdal/cloud/models/__init__.pyi +0 -0
  21. amsdal/cloud/models/base.cpython-313-x86_64-linux-gnu.so +0 -0
  22. amsdal/cloud/models/base.pyi +247 -0
  23. amsdal/cloud/services/__init__.cpython-313-x86_64-linux-gnu.so +0 -0
  24. amsdal/cloud/services/__init__.pyi +0 -0
  25. amsdal/cloud/services/actions/__init__.cpython-313-x86_64-linux-gnu.so +0 -0
  26. amsdal/cloud/services/actions/__init__.pyi +0 -0
  27. amsdal/cloud/services/actions/add_allowlist_ip.cpython-313-x86_64-linux-gnu.so +0 -0
  28. amsdal/cloud/services/actions/add_allowlist_ip.pyi +19 -0
  29. amsdal/cloud/services/actions/add_basic_auth.cpython-313-x86_64-linux-gnu.so +0 -0
  30. amsdal/cloud/services/actions/add_basic_auth.pyi +21 -0
  31. amsdal/cloud/services/actions/add_dependency.cpython-313-x86_64-linux-gnu.so +0 -0
  32. amsdal/cloud/services/actions/add_dependency.pyi +19 -0
  33. amsdal/cloud/services/actions/add_secret.cpython-313-x86_64-linux-gnu.so +0 -0
  34. amsdal/cloud/services/actions/add_secret.pyi +20 -0
  35. amsdal/cloud/services/actions/base.cpython-313-x86_64-linux-gnu.so +0 -0
  36. amsdal/cloud/services/actions/base.pyi +122 -0
  37. amsdal/cloud/services/actions/create_deploy.cpython-313-x86_64-linux-gnu.so +0 -0
  38. amsdal/cloud/services/actions/create_deploy.pyi +41 -0
  39. amsdal/cloud/services/actions/create_env.cpython-313-x86_64-linux-gnu.so +0 -0
  40. amsdal/cloud/services/actions/create_env.pyi +19 -0
  41. amsdal/cloud/services/actions/create_session.cpython-313-x86_64-linux-gnu.so +0 -0
  42. amsdal/cloud/services/actions/create_session.pyi +17 -0
  43. amsdal/cloud/services/actions/delete_allowlist_ip.cpython-313-x86_64-linux-gnu.so +0 -0
  44. amsdal/cloud/services/actions/delete_allowlist_ip.pyi +19 -0
  45. amsdal/cloud/services/actions/delete_basic_auth.cpython-313-x86_64-linux-gnu.so +0 -0
  46. amsdal/cloud/services/actions/delete_basic_auth.pyi +20 -0
  47. amsdal/cloud/services/actions/delete_dependency.cpython-313-x86_64-linux-gnu.so +0 -0
  48. amsdal/cloud/services/actions/delete_dependency.pyi +21 -0
  49. amsdal/cloud/services/actions/delete_env.cpython-313-x86_64-linux-gnu.so +0 -0
  50. amsdal/cloud/services/actions/delete_env.pyi +21 -0
  51. amsdal/cloud/services/actions/delete_secret.cpython-313-x86_64-linux-gnu.so +0 -0
  52. amsdal/cloud/services/actions/delete_secret.pyi +21 -0
  53. amsdal/cloud/services/actions/destroy_deploy.cpython-313-x86_64-linux-gnu.so +0 -0
  54. amsdal/cloud/services/actions/destroy_deploy.pyi +18 -0
  55. amsdal/cloud/services/actions/expose_db.cpython-313-x86_64-linux-gnu.so +0 -0
  56. amsdal/cloud/services/actions/expose_db.pyi +22 -0
  57. amsdal/cloud/services/actions/get_basic_auth_credentials.cpython-313-x86_64-linux-gnu.so +0 -0
  58. amsdal/cloud/services/actions/get_basic_auth_credentials.pyi +21 -0
  59. amsdal/cloud/services/actions/get_monitoring_info.cpython-313-x86_64-linux-gnu.so +0 -0
  60. amsdal/cloud/services/actions/get_monitoring_info.pyi +21 -0
  61. amsdal/cloud/services/actions/list_dependencies.cpython-313-x86_64-linux-gnu.so +0 -0
  62. amsdal/cloud/services/actions/list_dependencies.pyi +21 -0
  63. amsdal/cloud/services/actions/list_deploys.cpython-313-x86_64-linux-gnu.so +0 -0
  64. amsdal/cloud/services/actions/list_deploys.pyi +19 -0
  65. amsdal/cloud/services/actions/list_envs.cpython-313-x86_64-linux-gnu.so +0 -0
  66. amsdal/cloud/services/actions/list_envs.pyi +20 -0
  67. amsdal/cloud/services/actions/list_secrets.cpython-313-x86_64-linux-gnu.so +0 -0
  68. amsdal/cloud/services/actions/list_secrets.pyi +22 -0
  69. amsdal/cloud/services/actions/manager.cpython-313-x86_64-linux-gnu.so +0 -0
  70. amsdal/cloud/services/actions/manager.pyi +278 -0
  71. amsdal/cloud/services/actions/signup_action.cpython-313-x86_64-linux-gnu.so +0 -0
  72. amsdal/cloud/services/actions/signup_action.pyi +20 -0
  73. amsdal/cloud/services/actions/update_deploy.cpython-313-x86_64-linux-gnu.so +0 -0
  74. amsdal/cloud/services/actions/update_deploy.pyi +19 -0
  75. amsdal/cloud/services/auth/__init__.cpython-313-x86_64-linux-gnu.so +0 -0
  76. amsdal/cloud/services/auth/__init__.pyi +0 -0
  77. amsdal/cloud/services/auth/base.cpython-313-x86_64-linux-gnu.so +0 -0
  78. amsdal/cloud/services/auth/base.pyi +6 -0
  79. amsdal/cloud/services/auth/credentials.cpython-313-x86_64-linux-gnu.so +0 -0
  80. amsdal/cloud/services/auth/credentials.pyi +30 -0
  81. amsdal/cloud/services/auth/manager.cpython-313-x86_64-linux-gnu.so +0 -0
  82. amsdal/cloud/services/auth/manager.pyi +26 -0
  83. amsdal/cloud/services/auth/signup_service.cpython-313-x86_64-linux-gnu.so +0 -0
  84. amsdal/cloud/services/auth/signup_service.pyi +32 -0
  85. amsdal/cloud/services/auth/token.cpython-313-x86_64-linux-gnu.so +0 -0
  86. amsdal/cloud/services/auth/token.pyi +27 -0
  87. amsdal/configs/__init__.py +0 -0
  88. amsdal/configs/__init__.pyi +0 -0
  89. amsdal/configs/constants.py +33 -0
  90. amsdal/configs/constants.pyi +22 -0
  91. amsdal/configs/main.py +274 -0
  92. amsdal/configs/main.pyi +178 -0
  93. amsdal/context/__init__.py +0 -0
  94. amsdal/context/__init__.pyi +0 -0
  95. amsdal/context/manager.py +69 -0
  96. amsdal/context/manager.pyi +50 -0
  97. amsdal/contrib/__init__.cpython-313-x86_64-linux-gnu.so +0 -0
  98. amsdal/contrib/__init__.pyi +0 -0
  99. amsdal/contrib/app_config.py +7 -0
  100. amsdal/contrib/app_config.pyi +6 -0
  101. amsdal/contrib/auth/__init__.py +0 -0
  102. amsdal/contrib/auth/__init__.pyi +0 -0
  103. amsdal/contrib/auth/app.py +27 -0
  104. amsdal/contrib/auth/app.pyi +15 -0
  105. amsdal/contrib/auth/decorators/__init__.py +35 -0
  106. amsdal/contrib/auth/decorators/__init__.pyi +6 -0
  107. amsdal/contrib/auth/errors.py +43 -0
  108. amsdal/contrib/auth/errors.pyi +16 -0
  109. amsdal/contrib/auth/fixtures/basic_permissions.json +64 -0
  110. amsdal/contrib/auth/lifecycle/__init__.py +0 -0
  111. amsdal/contrib/auth/lifecycle/__init__.pyi +0 -0
  112. amsdal/contrib/auth/lifecycle/consumer.py +394 -0
  113. amsdal/contrib/auth/lifecycle/consumer.pyi +108 -0
  114. amsdal/contrib/auth/migrations/0000_initial.py +87 -0
  115. amsdal/contrib/auth/migrations/0001_add_mfa_support.py +188 -0
  116. amsdal/contrib/auth/models/__init__.py +1 -0
  117. amsdal/contrib/auth/models/backup_code.py +85 -0
  118. amsdal/contrib/auth/models/email_mfa_device.py +108 -0
  119. amsdal/contrib/auth/models/login_session.py +235 -0
  120. amsdal/contrib/auth/models/mfa_device.py +86 -0
  121. amsdal/contrib/auth/models/permission.py +23 -0
  122. amsdal/contrib/auth/models/sms_device.py +113 -0
  123. amsdal/contrib/auth/models/totp_device.py +58 -0
  124. amsdal/contrib/auth/models/user.py +156 -0
  125. amsdal/contrib/auth/services/__init__.py +1 -0
  126. amsdal/contrib/auth/services/__init__.pyi +0 -0
  127. amsdal/contrib/auth/services/mfa_device_service.py +544 -0
  128. amsdal/contrib/auth/services/mfa_device_service.pyi +216 -0
  129. amsdal/contrib/auth/services/totp_service.py +358 -0
  130. amsdal/contrib/auth/services/totp_service.pyi +158 -0
  131. amsdal/contrib/auth/settings.py +44 -0
  132. amsdal/contrib/auth/settings.pyi +34 -0
  133. amsdal/contrib/auth/transactions/__init__.py +1 -0
  134. amsdal/contrib/auth/transactions/__init__.pyi +0 -0
  135. amsdal/contrib/auth/transactions/mfa_device_transactions.py +458 -0
  136. amsdal/contrib/auth/transactions/mfa_device_transactions.pyi +226 -0
  137. amsdal/contrib/auth/transactions/totp_transactions.py +203 -0
  138. amsdal/contrib/auth/transactions/totp_transactions.pyi +113 -0
  139. amsdal/contrib/auth/utils/__init__.py +0 -0
  140. amsdal/contrib/auth/utils/__init__.pyi +0 -0
  141. amsdal/contrib/auth/utils/mfa.py +257 -0
  142. amsdal/contrib/auth/utils/mfa.pyi +119 -0
  143. amsdal/contrib/frontend_configs/__init__.py +0 -0
  144. amsdal/contrib/frontend_configs/__init__.pyi +0 -0
  145. amsdal/contrib/frontend_configs/app.py +24 -0
  146. amsdal/contrib/frontend_configs/app.pyi +19 -0
  147. amsdal/contrib/frontend_configs/constants.py +1 -0
  148. amsdal/contrib/frontend_configs/constants.pyi +1 -0
  149. amsdal/contrib/frontend_configs/conversion/__init__.py +5 -0
  150. amsdal/contrib/frontend_configs/conversion/__init__.pyi +3 -0
  151. amsdal/contrib/frontend_configs/conversion/convert.py +310 -0
  152. amsdal/contrib/frontend_configs/conversion/convert.pyi +22 -0
  153. amsdal/contrib/frontend_configs/lifecycle/__init__.py +0 -0
  154. amsdal/contrib/frontend_configs/lifecycle/__init__.pyi +0 -0
  155. amsdal/contrib/frontend_configs/lifecycle/consumer.py +306 -0
  156. amsdal/contrib/frontend_configs/lifecycle/consumer.pyi +98 -0
  157. amsdal/contrib/frontend_configs/migrations/0000_initial.py +227 -0
  158. amsdal/contrib/frontend_configs/migrations/0001_update_frontend_control_config.py +245 -0
  159. amsdal/contrib/frontend_configs/migrations/0002_add_button_and_invoke_actions.py +352 -0
  160. amsdal/contrib/frontend_configs/migrations/0003_create_class_frontendconfigdashboardelement.py +145 -0
  161. amsdal/contrib/frontend_configs/models/__init__.py +0 -0
  162. amsdal/contrib/frontend_configs/models/frontend_activator_config.py +22 -0
  163. amsdal/contrib/frontend_configs/models/frontend_config_async_validator.py +11 -0
  164. amsdal/contrib/frontend_configs/models/frontend_config_control_action.py +110 -0
  165. amsdal/contrib/frontend_configs/models/frontend_config_dashboard.py +51 -0
  166. amsdal/contrib/frontend_configs/models/frontend_config_group_validator.py +21 -0
  167. amsdal/contrib/frontend_configs/models/frontend_config_option.py +12 -0
  168. amsdal/contrib/frontend_configs/models/frontend_config_skip_none_base.py +17 -0
  169. amsdal/contrib/frontend_configs/models/frontend_config_slider_option.py +13 -0
  170. amsdal/contrib/frontend_configs/models/frontend_config_text_mask.py +14 -0
  171. amsdal/contrib/frontend_configs/models/frontend_config_validator.py +28 -0
  172. amsdal/contrib/frontend_configs/models/frontend_control_config.py +110 -0
  173. amsdal/contrib/frontend_configs/models/frontend_model_config.py +14 -0
  174. amsdal/contrib/frontend_configs/utils.py +29 -0
  175. amsdal/contrib/frontend_configs/utils.pyi +17 -0
  176. amsdal/errors.py +31 -0
  177. amsdal/errors.pyi +12 -0
  178. amsdal/fixtures/__init__.cpython-313-x86_64-linux-gnu.so +0 -0
  179. amsdal/fixtures/__init__.pyi +0 -0
  180. amsdal/fixtures/manager.cpython-313-x86_64-linux-gnu.so +0 -0
  181. amsdal/fixtures/manager.pyi +170 -0
  182. amsdal/fixtures/utils.cpython-313-x86_64-linux-gnu.so +0 -0
  183. amsdal/fixtures/utils.pyi +9 -0
  184. amsdal/manager.cpython-313-x86_64-linux-gnu.so +0 -0
  185. amsdal/manager.pyi +265 -0
  186. amsdal/mixins/__init__.cpython-313-x86_64-linux-gnu.so +0 -0
  187. amsdal/mixins/__init__.pyi +0 -0
  188. amsdal/mixins/class_versions_mixin.cpython-313-x86_64-linux-gnu.so +0 -0
  189. amsdal/mixins/class_versions_mixin.pyi +12 -0
  190. amsdal/models/__init__.py +19 -0
  191. amsdal/models/core/__init__.py +0 -0
  192. amsdal/models/core/class_object.py +38 -0
  193. amsdal/models/core/class_property.py +26 -0
  194. amsdal/models/core/file.py +243 -0
  195. amsdal/models/core/fixture.py +25 -0
  196. amsdal/models/core/option.py +11 -0
  197. amsdal/models/core/storage_metadata.py +15 -0
  198. amsdal/models/core/validator.py +12 -0
  199. amsdal/models/mixins.py +31 -0
  200. amsdal/models/types/__init__.py +0 -0
  201. amsdal/models/types/object.py +26 -0
  202. amsdal/py.typed +0 -0
  203. amsdal/queryset/__init__.py +21 -0
  204. amsdal/queryset/__init__.pyi +6 -0
  205. amsdal/schemas/__init__.py +0 -0
  206. amsdal/schemas/__init__.pyi +0 -0
  207. amsdal/schemas/core/class_object/model.json +51 -0
  208. amsdal/schemas/core/class_object/properties/display_name.py +9 -0
  209. amsdal/schemas/core/class_property/model.json +41 -0
  210. amsdal/schemas/core/file/hooks/pre_create.py +24 -0
  211. amsdal/schemas/core/file/hooks/pre_update.py +24 -0
  212. amsdal/schemas/core/file/model.json +23 -0
  213. amsdal/schemas/core/file/properties/from_file.py +34 -0
  214. amsdal/schemas/core/file/properties/mimetype.py +13 -0
  215. amsdal/schemas/core/file/properties/str.py +6 -0
  216. amsdal/schemas/core/file/properties/to_file.py +24 -0
  217. amsdal/schemas/core/file/properties/validate_data.py +31 -0
  218. amsdal/schemas/core/fixture/model.json +35 -0
  219. amsdal/schemas/core/option/model.json +19 -0
  220. amsdal/schemas/core/storage_metadata/model.json +52 -0
  221. amsdal/schemas/core/validator/model.json +19 -0
  222. amsdal/schemas/interfaces.py +25 -0
  223. amsdal/schemas/interfaces.pyi +20 -0
  224. amsdal/schemas/manager.cpython-313-x86_64-linux-gnu.so +0 -0
  225. amsdal/schemas/manager.py +0 -0
  226. amsdal/schemas/manager.pyi +0 -0
  227. amsdal/schemas/mixins/__init__.py +0 -0
  228. amsdal/schemas/mixins/__init__.pyi +0 -0
  229. amsdal/schemas/mixins/check_dependencies_mixin.py +130 -0
  230. amsdal/schemas/mixins/check_dependencies_mixin.pyi +45 -0
  231. amsdal/schemas/mixins/verify_schemas_mixin.py +96 -0
  232. amsdal/schemas/mixins/verify_schemas_mixin.pyi +33 -0
  233. amsdal/schemas/repository.py +84 -0
  234. amsdal/schemas/repository.pyi +22 -0
  235. amsdal/schemas/types/anything/model.json +7 -0
  236. amsdal/schemas/types/array/model.json +7 -0
  237. amsdal/schemas/types/binary/model.json +7 -0
  238. amsdal/schemas/types/boolean/model.json +17 -0
  239. amsdal/schemas/types/date/model.json +7 -0
  240. amsdal/schemas/types/datetime/model.json +7 -0
  241. amsdal/schemas/types/dictionary/model.json +8 -0
  242. amsdal/schemas/types/number/model.json +8 -0
  243. amsdal/schemas/types/object/model.json +53 -0
  244. amsdal/schemas/types/string/model.json +8 -0
  245. amsdal/schemas/utils.py +16 -0
  246. amsdal/schemas/utils.pyi +10 -0
  247. amsdal/services/__init__.py +11 -0
  248. amsdal/services/__init__.pyi +4 -0
  249. amsdal/services/external_connections.py +262 -0
  250. amsdal/services/external_connections.pyi +190 -0
  251. amsdal/services/external_model_generator.py +350 -0
  252. amsdal/services/external_model_generator.pyi +134 -0
  253. amsdal/services/transaction_execution.cpython-313-x86_64-linux-gnu.so +0 -0
  254. amsdal/services/transaction_execution.pyi +93 -0
  255. amsdal/storages/__init__.py +20 -0
  256. amsdal/storages/__init__.pyi +8 -0
  257. amsdal/storages/file_system.py +214 -0
  258. amsdal/storages/file_system.pyi +36 -0
  259. amsdal/transactions/__init__.py +13 -0
  260. amsdal/transactions/__init__.pyi +4 -0
  261. amsdal/utils/__init__.py +0 -0
  262. amsdal/utils/__init__.pyi +0 -0
  263. amsdal/utils/contrib_paths.py +23 -0
  264. amsdal/utils/contrib_paths.pyi +14 -0
  265. amsdal/utils/rollback/__init__.py +440 -0
  266. amsdal/utils/rollback/__init__.pyi +38 -0
  267. amsdal/utils/tests/__init__.py +0 -0
  268. amsdal/utils/tests/enums.py +16 -0
  269. amsdal/utils/tests/factories.py +49 -0
  270. amsdal/utils/tests/helpers.py +331 -0
  271. amsdal/utils/tests/migrations.py +157 -0
  272. amsdal-0.5.34.dist-info/METADATA +375 -0
  273. amsdal-0.5.34.dist-info/RECORD +276 -0
  274. amsdal-0.5.34.dist-info/WHEEL +6 -0
  275. amsdal-0.5.34.dist-info/licenses/LICENSE.txt +107 -0
  276. amsdal-0.5.34.dist-info/top_level.txt +1 -0
amsdal/manager.pyi ADDED
@@ -0,0 +1,265 @@
1
+ from _typeshed import Incomplete
2
+ from amsdal.cloud.services.actions.manager import CloudActionsManager as CloudActionsManager
3
+ from amsdal.cloud.services.auth.signup_service import SignupService as SignupService
4
+ from amsdal.configs.main import settings as settings
5
+ from amsdal.errors import AmsdalAuthenticationError as AmsdalAuthenticationError, AmsdalMissingCredentialsError as AmsdalMissingCredentialsError, AmsdalRuntimeError as AmsdalRuntimeError, AmsdalSignupError as AmsdalSignupError
6
+ from amsdal.fixtures.manager import AsyncFixturesManager as AsyncFixturesManager, FixturesManager as FixturesManager
7
+ from amsdal.mixins.class_versions_mixin import ClassVersionsMixin as ClassVersionsMixin
8
+ from amsdal_data.transactions.decorators import async_transaction, transaction
9
+ from amsdal_models.classes.class_manager import ClassManager
10
+ from amsdal_utils.config.data_models.amsdal_config import AmsdalConfig as AmsdalConfig
11
+ from amsdal_utils.utils.singleton import Singleton
12
+
13
+ class AmsdalManager(ClassVersionsMixin, metaclass=Singleton):
14
+ """
15
+ Manages the AMSDAL framework components and operations.
16
+
17
+ This class is responsible for initializing, setting up, and managing various components
18
+ of the AMSDAL framework, including connections, data management, schema management,
19
+ and authentication. It also provides methods for building and tearing down the framework.
20
+ """
21
+ _class_manager: ClassManager
22
+ _config_manager: Incomplete
23
+ _config: Incomplete
24
+ _data_application: Incomplete
25
+ _is_setup: bool
26
+ __is_authenticated: bool
27
+ _metadata_manager: Incomplete
28
+ _auth_manager: Incomplete
29
+ def __init__(self, *, raise_on_new_signup: bool = False) -> None:
30
+ """
31
+ Initializes all sub managers. Reads the configuration.
32
+
33
+ Returns:
34
+ None
35
+ """
36
+ @property
37
+ def is_setup(self) -> bool: ...
38
+ @property
39
+ def is_authenticated(self) -> bool:
40
+ """
41
+ Indicates if the AMSDAL license authentication process has been passed.
42
+
43
+ This property returns a boolean value indicating whether the AMSDAL license
44
+ authentication process has been successfully completed.
45
+
46
+ Returns:
47
+ bool: True if authenticated, False otherwise.
48
+ """
49
+ def pre_setup(self) -> None:
50
+ """
51
+ Initiates models root path and adds it into sys.path.
52
+
53
+ This method initializes the class manager models modules and sets up the models root path
54
+ as specified in the settings. It ensures that the models root path is added
55
+ to the system path for proper module resolution.
56
+
57
+ Returns:
58
+ None
59
+ """
60
+ def setup(self) -> None:
61
+ """
62
+ Initiates models root path and the connections.
63
+
64
+ This method sets up the AMSDAL framework by initializing the models root path and
65
+ establishing connections. It ensures that the setup process is only performed once.
66
+
67
+ Raises:
68
+ AmsdalRuntimeError: If the AMSDAL manager is already set up.
69
+
70
+ Returns:
71
+ None
72
+ """
73
+ @transaction
74
+ def post_setup(self) -> None:
75
+ """
76
+ Registers internal classes and prepares connections (creates internal tables).
77
+ """
78
+ def _check_auth(self) -> None: ...
79
+ @property
80
+ def cloud_actions_manager(self) -> CloudActionsManager:
81
+ """
82
+ Provides access to the CloudActionsManager.
83
+
84
+ This property checks if the AMSDAL manager is authenticated and then returns
85
+ an instance of the CloudActionsManager.
86
+
87
+ Returns:
88
+ CloudActionsManager: An instance of the CloudActionsManager.
89
+
90
+ Raises:
91
+ AmsdalAuthenticationError: If the AMSDAL manager is not authenticated.
92
+ """
93
+ def authenticate(self) -> None:
94
+ """
95
+ Run AMSDAL license authentication process.
96
+
97
+ This method runs the AMSDAL license authentication process and sets the
98
+ authentication status accordingly.
99
+
100
+ Returns:
101
+ None
102
+ """
103
+ @transaction
104
+ def apply_fixtures(self) -> None:
105
+ """
106
+ Loads and applies fixtures defined in your application.
107
+
108
+ This method loads the fixtures from the specified path and applies them to the
109
+ AMSDAL framework. It uses the `FixturesManager` to manage the loading and application
110
+ of the fixtures.
111
+
112
+ Returns:
113
+ None
114
+ """
115
+ def init_classes(self) -> None:
116
+ """
117
+ Initializes and imports classes based on the schema manager's class schemas.
118
+
119
+ This method iterates over the class schemas provided by the schema manager and imports
120
+ the classes into the class manager, excluding those of type `SchemaTypes.TYPE`.
121
+
122
+ Returns:
123
+ None
124
+ """
125
+ def teardown(self) -> None:
126
+ """
127
+ Clean up everything on the application exit.
128
+
129
+ This method performs a cleanup of all components managed by the AMSDAL framework
130
+ when the application exits. It disconnects and invalidates connections, clears caches,
131
+ and resets the setup status.
132
+
133
+ Raises:
134
+ AmsdalRuntimeError: If the AMSDAL manager is not set up.
135
+
136
+ Returns:
137
+ None
138
+ """
139
+
140
+ class AsyncAmsdalManager(ClassVersionsMixin, metaclass=Singleton):
141
+ """
142
+ Manages the AMSDAL framework components and operations.
143
+
144
+ This class is responsible for initializing, setting up, and managing various components
145
+ of the AMSDAL framework, including connections, data management, schema management,
146
+ and authentication. It also provides methods for building and tearing down the framework.
147
+ """
148
+ _class_manager: ClassManager
149
+ _config_manager: Incomplete
150
+ _config: Incomplete
151
+ _data_application: Incomplete
152
+ _is_setup: bool
153
+ __is_authenticated: bool
154
+ _metadata_manager: Incomplete
155
+ _auth_manager: Incomplete
156
+ def __init__(self, *, raise_on_new_signup: bool = False) -> None:
157
+ """
158
+ Initializes all sub managers. Reads the configuration.
159
+
160
+ Returns:
161
+ None
162
+ """
163
+ @property
164
+ def is_setup(self) -> bool: ...
165
+ @property
166
+ def is_authenticated(self) -> bool:
167
+ """
168
+ Indicates if the AMSDAL license authentication process has been passed.
169
+
170
+ This property returns a boolean value indicating whether the AMSDAL license
171
+ authentication process has been successfully completed.
172
+
173
+ Returns:
174
+ bool: True if authenticated, False otherwise.
175
+ """
176
+ def pre_setup(self) -> None:
177
+ """
178
+ Initiates models root path and adds it into sys.path.
179
+
180
+ This method initializes the class manager and sets up the models root path
181
+ as specified in the settings. It ensures that the models root path is added
182
+ to the system path for proper module resolution.
183
+
184
+ Returns:
185
+ None
186
+ """
187
+ async def setup(self) -> None:
188
+ """
189
+ Initiates models root path and the connections.
190
+
191
+ This method sets up the AMSDAL framework by initializing the models root path and
192
+ establishing connections. It ensures that the setup process is only performed once.
193
+
194
+ Raises:
195
+ AmsdalRuntimeError: If the AMSDAL manager is already set up.
196
+
197
+ Returns:
198
+ None
199
+ """
200
+ @async_transaction
201
+ async def post_setup(self) -> None:
202
+ """
203
+ Registers internal classes and prepares connections (creates internal tables).
204
+ """
205
+ def _check_auth(self) -> None: ...
206
+ @property
207
+ def cloud_actions_manager(self) -> CloudActionsManager:
208
+ """
209
+ Provides access to the CloudActionsManager.
210
+
211
+ This property checks if the AMSDAL manager is authenticated and then returns
212
+ an instance of the CloudActionsManager.
213
+
214
+ Returns:
215
+ CloudActionsManager: An instance of the CloudActionsManager.
216
+
217
+ Raises:
218
+ AmsdalAuthenticationError: If the AMSDAL manager is not authenticated.
219
+ """
220
+ def authenticate(self) -> None:
221
+ """
222
+ Run AMSDAL license authentication process.
223
+
224
+ This method runs the AMSDAL license authentication process and sets the
225
+ authentication status accordingly.
226
+
227
+ Returns:
228
+ None
229
+ """
230
+ @async_transaction
231
+ async def apply_fixtures(self) -> None:
232
+ """
233
+ Loads and applies fixtures defined in your application.
234
+
235
+ This method loads the fixtures from the specified path and applies them to the
236
+ AMSDAL framework. It uses the `FixturesManager` to manage the loading and application
237
+ of the fixtures.
238
+
239
+ Returns:
240
+ None
241
+ """
242
+ def init_classes(self) -> None:
243
+ """
244
+ Initializes and imports classes based on the schema manager's class schemas.
245
+
246
+ This method iterates over the class schemas provided by the schema manager and imports
247
+ the classes into the class manager, excluding those of type `SchemaTypes.TYPE`.
248
+
249
+ Returns:
250
+ None
251
+ """
252
+ async def teardown(self) -> None:
253
+ """
254
+ Clean up everything on the application exit.
255
+
256
+ This method performs a cleanup of all components managed by the AMSDAL framework
257
+ when the application exits. It disconnects and invalidates connections, clears caches,
258
+ and resets the setup status.
259
+
260
+ Raises:
261
+ AmsdalRuntimeError: If the AMSDAL manager is not set up.
262
+
263
+ Returns:
264
+ None
265
+ """
File without changes
@@ -0,0 +1,12 @@
1
+ from amsdal_data.connections.historical.schema_version_manager import AsyncHistoricalSchemaVersionManager, HistoricalSchemaVersionManager
2
+
3
+ class ClassVersionsMixin:
4
+ """
5
+ Mixin class to manage class versions and related table schemas.
6
+ """
7
+ @staticmethod
8
+ def _register_internal_classes(schema_version_manager: HistoricalSchemaVersionManager | AsyncHistoricalSchemaVersionManager) -> None: ...
9
+ @classmethod
10
+ def register_internal_classes(cls) -> None: ...
11
+ @classmethod
12
+ def aregister_internal_classes(cls) -> None: ...
@@ -0,0 +1,19 @@
1
+ from amsdal_models.builder.validators.dict_validators import validate_non_empty_keys
2
+ from amsdal_models.builder.validators.options_validators import validate_options
3
+ from amsdal_models.classes.data_models.constraints import UniqueConstraint
4
+ from amsdal_models.classes.data_models.indexes import IndexInfo
5
+ from amsdal_models.classes.model import Model
6
+ from amsdal_models.classes.model import TypeModel
7
+ from amsdal_models.classes.relationships.many_reference_field import ManyReferenceField
8
+ from amsdal_models.classes.relationships.reference_field import ReferenceField
9
+
10
+ __all__ = [
11
+ 'IndexInfo',
12
+ 'ManyReferenceField',
13
+ 'Model',
14
+ 'ReferenceField',
15
+ 'TypeModel',
16
+ 'UniqueConstraint',
17
+ 'validate_non_empty_keys',
18
+ 'validate_options',
19
+ ]
File without changes
@@ -0,0 +1,38 @@
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
+ from amsdal.models.core.class_property import * # noqa: F403
12
+ from amsdal.models.core.storage_metadata import * # noqa: F403
13
+
14
+
15
+ class ClassObject(Model):
16
+ __module_type__: ClassVar[ModuleType] = ModuleType.CORE
17
+ title: str = Field(title='Title')
18
+ type: str = Field(title='Type')
19
+ module_type: str = Field(title='Module Type')
20
+ properties: Optional[dict[str, Optional['ClassProperty']]] = Field(None, title='Properties') # noqa: F405, UP007
21
+ required: Optional[list[str]] = Field(None, title='Required') # noqa: UP007
22
+ custom_code: str | None = Field(None, title='Custom Code')
23
+ storage_metadata: Optional['StorageMetadata'] = Field(None, title='Storage metadata') # noqa: F405
24
+
25
+ @field_validator('properties')
26
+ @classmethod
27
+ def _non_empty_keys_properties(cls: type, value: Any) -> Any: # type: ignore # noqa: A003
28
+ return validate_non_empty_keys(value)
29
+
30
+ @property
31
+ def display_name(self) -> str:
32
+ """
33
+ Returns the display name of the object.
34
+
35
+ Returns:
36
+ str: The display name, which is the title of the object.
37
+ """
38
+ return self.title
@@ -0,0 +1,26 @@
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.model import TypeModel
6
+ from amsdal_utils.models.enums import ModuleType
7
+ from pydantic.fields import Field
8
+ from pydantic.functional_validators import field_validator
9
+
10
+ from amsdal.models.core.option import * # noqa: F403
11
+
12
+
13
+ class ClassProperty(TypeModel):
14
+ __module_type__: ClassVar[ModuleType] = ModuleType.CORE
15
+ title: str | None = Field(None, title='Title')
16
+ type: str = Field(title='Type')
17
+ default: Any | None = Field(None, title='Default')
18
+ options: list['Option'] | None = Field(None, title='Options') # noqa: F405
19
+ items: dict[str, Any | None] | None = Field(None, title='Items')
20
+ discriminator: str | None = Field(None, title='Discriminator')
21
+ extra: dict[str, Any | None] = Field(default_factory=dict, title='Extra')
22
+
23
+ @field_validator('items')
24
+ @classmethod
25
+ def _non_empty_keys_items(cls: type, value: Any) -> Any: # type: ignore # noqa: A003
26
+ return validate_non_empty_keys(value)
@@ -0,0 +1,243 @@
1
+ import base64
2
+ import io
3
+ from contextlib import suppress
4
+ from pathlib import Path
5
+ from typing import IO
6
+ from typing import Any
7
+ from typing import BinaryIO
8
+ from typing import ClassVar
9
+
10
+ from amsdal_models.classes.model import Model
11
+ from amsdal_models.storage.backends.db import AsyncFileWrapper
12
+ from amsdal_models.storage.backends.db import DBStorage
13
+ from amsdal_models.storage.base import Storage
14
+ from amsdal_utils.models.data_models.reference import Reference
15
+ from amsdal_utils.models.enums import ModuleType
16
+ from pydantic import PrivateAttr
17
+ from pydantic import model_validator
18
+ from pydantic.fields import Field
19
+
20
+
21
+ class File(Model):
22
+ __module_type__: ClassVar[ModuleType] = ModuleType.CORE
23
+ filename: str = Field(title='Filename')
24
+ data: bytes | None = Field(default=None, title='Data')
25
+ size: float | None = Field(default=None, title='Size')
26
+ storage_address: Reference | None = Field(default=None, title='Storage Reference')
27
+
28
+ _source: BinaryIO | None = PrivateAttr(default=None)
29
+ _storage: Storage | None = PrivateAttr(default=None)
30
+
31
+ @property
32
+ def storage(self) -> Storage:
33
+ from amsdal.storages import default_storage
34
+
35
+ if self._storage:
36
+ return self._storage
37
+
38
+ if self.storage_address:
39
+ return Storage.from_storage_spec({'storage_class': self.storage_address.ref.resource})
40
+
41
+ return default_storage()
42
+
43
+ def __repr__(self) -> str:
44
+ return f'File<{self.filename}>({self.size or len(self.data or "") or 0} bytes)'
45
+
46
+ def __str__(self) -> str:
47
+ return repr(self)
48
+
49
+ def pre_create(self) -> None:
50
+ from amsdal_models.storage.persistence import persist_file
51
+
52
+ persist_file(self, storage=self.storage)
53
+
54
+ def pre_update(self) -> None:
55
+ from amsdal_models.storage.persistence import persist_file
56
+
57
+ persist_file(self, storage=self.storage)
58
+
59
+ async def apre_create(self) -> None:
60
+ from amsdal_models.storage.persistence import apersist_file
61
+
62
+ await apersist_file(self, storage=self.storage)
63
+
64
+ async def apre_update(self) -> None:
65
+ from amsdal_models.storage.persistence import apersist_file
66
+
67
+ await apersist_file(self, storage=self.storage)
68
+
69
+ @model_validator(mode='before')
70
+ @classmethod
71
+ def validate_model_data(cls, data: Any) -> Any:
72
+ if isinstance(data, dict):
73
+ if 'data' in data:
74
+ if data['data']:
75
+ data['data'] = cls.data_base64_decode(data['data'])
76
+ data['size'] = len(data['data'])
77
+ else:
78
+ data['size'] = 0
79
+ return data
80
+
81
+ @classmethod
82
+ def data_base64_decode(cls, data: Any) -> bytes:
83
+ if isinstance(data, str):
84
+ data = data.encode('utf-8')
85
+
86
+ is_base64: bool = False
87
+
88
+ with suppress(Exception):
89
+ is_base64 = base64.b64encode(base64.b64decode(data)) == data
90
+
91
+ if is_base64:
92
+ return base64.b64decode(data)
93
+
94
+ return data
95
+
96
+ @classmethod
97
+ def from_file(cls, file_or_path: Path | BinaryIO) -> 'File':
98
+ """
99
+ Creates a `File` object from a file path or a binary file object.
100
+
101
+ Args:
102
+ file_or_path (Path | BinaryIO): The file path or binary file object.
103
+
104
+ Returns:
105
+ File: The created `File` object.
106
+
107
+ Raises:
108
+ ValueError: If the provided path is a directory.
109
+ """
110
+ f: BinaryIO | io.BufferedReader
111
+
112
+ if isinstance(file_or_path, Path):
113
+ if file_or_path.is_dir():
114
+ msg = f'{file_or_path} is a directory'
115
+ raise ValueError(msg)
116
+ f = file_or_path.open('rb')
117
+ filename = file_or_path.name
118
+ size = file_or_path.stat().st_size
119
+
120
+ else:
121
+ f = file_or_path
122
+ filename = Path(getattr(f, 'name', 'unnamed')).name
123
+
124
+ try:
125
+ if f.seekable():
126
+ f.seek(0, io.SEEK_END)
127
+ size = f.tell()
128
+ f.seek(0)
129
+ else:
130
+ size = None
131
+ except (OSError, AttributeError):
132
+ size = None
133
+
134
+ obj = cls(filename=filename, size=size)
135
+ obj._source = f
136
+ return obj
137
+
138
+ @classmethod
139
+ def from_bytes(cls, filename: str, data: bytes) -> 'File':
140
+ """
141
+ Creates a `File` object from a byte string.
142
+
143
+ Args:
144
+ filename (str): The filename of the file.
145
+ data (bytes): The byte string containing the file data.:
146
+
147
+ Returns:
148
+ File: The created `File` object.
149
+ """
150
+ obj = cls(filename=filename, data=data, size=len(data))
151
+ return obj
152
+
153
+ def to_file(self, file_or_path: Path | BinaryIO) -> None:
154
+ """
155
+ Writes the object's data to a file path or a binary file object.
156
+
157
+ Args:
158
+ file_or_path (Path | BinaryIO): The file path or binary file object where the data will be written.
159
+
160
+ Returns:
161
+ None
162
+
163
+ Raises:
164
+ ValueError: If the provided path is a directory.
165
+ """
166
+ with self.open() as f:
167
+ if isinstance(file_or_path, Path):
168
+ if file_or_path.is_dir():
169
+ file_or_path = file_or_path / self.name
170
+ file_or_path.write_bytes(f.read()) # type: ignore[union-attr]
171
+ else:
172
+ file_or_path.write(f.read())
173
+ file_or_path.seek(0)
174
+
175
+ def url(self) -> str:
176
+ """
177
+ Return a URL for this file using its storage_address.
178
+
179
+ Raises StateError if storage_address is missing.
180
+ """
181
+ return self.storage.url(self)
182
+
183
+ def open(self, mode: str = 'rb') -> IO[Any]:
184
+ """
185
+ Open a binary stream for reading (or other modes if supported) using storage_address.
186
+
187
+ Raises StateError if storage_address is missing.
188
+ """
189
+ return self.storage.open(self, mode)
190
+
191
+ async def aurl(self) -> str:
192
+ """
193
+ Async variant of url().
194
+
195
+ Uses the resolved storage to call aurl(); if the backend does not implement
196
+ async, falls back to the sync url().
197
+ """
198
+ try:
199
+ return await self.storage.aurl(self) # type: ignore[attr-defined]
200
+ except NotImplementedError:
201
+ return self.storage.url(self)
202
+
203
+ async def aopen(self, mode: str = 'rb') -> Any:
204
+ """
205
+ Async variant of open().
206
+
207
+ Uses the resolved storage to call aopen(); if the backend does not implement
208
+ async, falls back to the sync open().
209
+ """
210
+ try:
211
+ return await self.storage.aopen(self, mode)
212
+ except NotImplementedError:
213
+ return AsyncFileWrapper(self.storage.open(self, mode))
214
+
215
+ @property
216
+ def mimetype(self) -> str | None:
217
+ """
218
+ Returns the MIME type of the file based on its filename.
219
+
220
+ This method uses the `mimetypes` module to guess the MIME type of the file.
221
+
222
+ Returns:
223
+ str | None: The guessed MIME type of the file, or None if it cannot be determined.
224
+ """
225
+ import mimetypes
226
+
227
+ return mimetypes.guess_type(self.filename)[0]
228
+
229
+ def read_bytes(self) -> bytes:
230
+ with self.open() as f:
231
+ return f.read()
232
+
233
+ async def aread_bytes(self) -> bytes:
234
+ async with await self.aopen() as f:
235
+ return await f.read()
236
+
237
+ def set_data(self, data: bytes | str) -> None:
238
+ if not isinstance(self.storage, DBStorage):
239
+ msg = 'Cannot set data on a file that is not stored in a database. Use `File.from_bytes` instead.'
240
+ raise ValueError(msg)
241
+
242
+ self.data = self.data_base64_decode(data)
243
+ self.size = len(self.data)
@@ -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,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,15 @@
1
+ from typing import ClassVar
2
+ from typing import Optional
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 StorageMetadata(TypeModel):
10
+ __module_type__: ClassVar[ModuleType] = ModuleType.CORE
11
+ table_name: Optional[str] = Field(None, title='Table name') # noqa: UP007
12
+ db_fields: dict[str, list[str]] | None = Field(None, title='Database fields')
13
+ primary_key: Optional[list[str]] = Field(None, title='Primary key fields') # noqa: UP007
14
+ indexed: Optional[list[list[str]]] = Field(None, title='Indexed') # noqa: UP007
15
+ unique: Optional[list[list[str]]] = Field(None, title='Unique Fields') # noqa: UP007
@@ -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')