amsdal 0.3.3__cp311-cp311-macosx_10_9_universal2.whl → 0.5.29__cp311-cp311-macosx_10_9_universal2.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 (244) hide show
  1. amsdal/Third-Party Materials - AMSDAL Dependencies - License Notices.md +56 -2
  2. amsdal/__about__.py +1 -1
  3. amsdal/__init__.py +20 -0
  4. amsdal/__init__.pyi +9 -0
  5. amsdal/__migrations__/0000_initial.py +23 -190
  6. amsdal/__migrations__/0001_create_class_file.py +61 -0
  7. amsdal/__migrations__/0002_create_class_file.py +109 -0
  8. amsdal/__migrations__/0003_update_class_file.py +91 -0
  9. amsdal/__migrations__/0004_update_class_file.py +45 -0
  10. amsdal/cloud/__init__.cpython-311-darwin.so +0 -0
  11. amsdal/cloud/client.cpython-311-darwin.so +0 -0
  12. amsdal/cloud/constants.cpython-311-darwin.so +0 -0
  13. amsdal/cloud/enums.cpython-311-darwin.so +0 -0
  14. amsdal/cloud/models/__init__.cpython-311-darwin.so +0 -0
  15. amsdal/cloud/models/base.cpython-311-darwin.so +0 -0
  16. amsdal/cloud/services/__init__.cpython-311-darwin.so +0 -0
  17. amsdal/cloud/services/actions/__init__.cpython-311-darwin.so +0 -0
  18. amsdal/cloud/services/actions/add_allowlist_ip.cpython-311-darwin.so +0 -0
  19. amsdal/cloud/services/actions/add_basic_auth.cpython-311-darwin.so +0 -0
  20. amsdal/cloud/services/actions/add_dependency.cpython-311-darwin.so +0 -0
  21. amsdal/cloud/services/actions/add_secret.cpython-311-darwin.so +0 -0
  22. amsdal/cloud/services/actions/base.cpython-311-darwin.so +0 -0
  23. amsdal/cloud/services/actions/create_deploy.cpython-311-darwin.so +0 -0
  24. amsdal/cloud/services/actions/create_env.cpython-311-darwin.so +0 -0
  25. amsdal/cloud/services/actions/create_session.cpython-311-darwin.so +0 -0
  26. amsdal/cloud/services/actions/delete_allowlist_ip.cpython-311-darwin.so +0 -0
  27. amsdal/cloud/services/actions/delete_basic_auth.cpython-311-darwin.so +0 -0
  28. amsdal/cloud/services/actions/delete_dependency.cpython-311-darwin.so +0 -0
  29. amsdal/cloud/services/actions/delete_env.cpython-311-darwin.so +0 -0
  30. amsdal/cloud/services/actions/delete_secret.cpython-311-darwin.so +0 -0
  31. amsdal/cloud/services/actions/destroy_deploy.cpython-311-darwin.so +0 -0
  32. amsdal/cloud/services/actions/expose_db.cpython-311-darwin.so +0 -0
  33. amsdal/cloud/services/actions/get_basic_auth_credentials.cpython-311-darwin.so +0 -0
  34. amsdal/cloud/services/actions/get_monitoring_info.cpython-311-darwin.so +0 -0
  35. amsdal/cloud/services/actions/list_dependencies.cpython-311-darwin.so +0 -0
  36. amsdal/cloud/services/actions/list_deploys.cpython-311-darwin.so +0 -0
  37. amsdal/cloud/services/actions/list_envs.cpython-311-darwin.so +0 -0
  38. amsdal/cloud/services/actions/list_secrets.cpython-311-darwin.so +0 -0
  39. amsdal/cloud/services/actions/manager.cpython-311-darwin.so +0 -0
  40. amsdal/cloud/services/actions/signup_action.cpython-311-darwin.so +0 -0
  41. amsdal/cloud/services/actions/update_deploy.cpython-311-darwin.so +0 -0
  42. amsdal/cloud/services/auth/__init__.cpython-311-darwin.so +0 -0
  43. amsdal/cloud/services/auth/base.cpython-311-darwin.so +0 -0
  44. amsdal/cloud/services/auth/credentials.cpython-311-darwin.so +0 -0
  45. amsdal/cloud/services/auth/credentials.pyi +0 -1
  46. amsdal/cloud/services/auth/manager.cpython-311-darwin.so +0 -0
  47. amsdal/cloud/services/auth/signup_service.cpython-311-darwin.so +0 -0
  48. amsdal/cloud/services/auth/token.cpython-311-darwin.so +0 -0
  49. amsdal/cloud/services/auth/token.pyi +0 -1
  50. amsdal/configs/main.py +40 -20
  51. amsdal/configs/main.pyi +19 -18
  52. amsdal/contrib/__init__.cpython-311-darwin.so +0 -0
  53. amsdal/contrib/auth/errors.py +36 -0
  54. amsdal/contrib/auth/errors.pyi +12 -0
  55. amsdal/contrib/auth/fixtures/basic_permissions.json +64 -0
  56. amsdal/contrib/auth/lifecycle/consumer.py +13 -13
  57. amsdal/contrib/auth/lifecycle/consumer.pyi +3 -0
  58. amsdal/contrib/auth/migrations/0000_initial.py +69 -31
  59. amsdal/contrib/auth/migrations/0001_add_mfa_support.py +188 -0
  60. amsdal/contrib/auth/models/__init__.py +1 -0
  61. amsdal/contrib/auth/models/backup_code.py +85 -0
  62. amsdal/contrib/auth/models/email_mfa_device.py +108 -0
  63. amsdal/contrib/auth/models/login_session.py +235 -0
  64. amsdal/contrib/auth/models/mfa_device.py +86 -0
  65. amsdal/contrib/auth/models/permission.py +23 -0
  66. amsdal/contrib/auth/models/sms_device.py +113 -0
  67. amsdal/contrib/auth/models/totp_device.py +58 -0
  68. amsdal/contrib/auth/models/user.py +156 -0
  69. amsdal/contrib/auth/services/__init__.py +1 -0
  70. amsdal/contrib/auth/services/mfa_device_service.py +544 -0
  71. amsdal/contrib/auth/services/mfa_device_service.pyi +216 -0
  72. amsdal/contrib/auth/services/totp_service.py +358 -0
  73. amsdal/contrib/auth/services/totp_service.pyi +158 -0
  74. amsdal/contrib/auth/settings.py +8 -0
  75. amsdal/contrib/auth/settings.pyi +8 -0
  76. amsdal/contrib/auth/transactions/__init__.py +1 -0
  77. amsdal/contrib/auth/transactions/mfa_device_transactions.py +463 -0
  78. amsdal/contrib/auth/transactions/mfa_device_transactions.pyi +226 -0
  79. amsdal/contrib/auth/transactions/totp_transactions.py +206 -0
  80. amsdal/contrib/auth/transactions/totp_transactions.pyi +113 -0
  81. amsdal/contrib/auth/utils/__init__.py +0 -0
  82. amsdal/contrib/auth/utils/__init__.pyi +0 -0
  83. amsdal/contrib/auth/utils/mfa.py +257 -0
  84. amsdal/contrib/auth/utils/mfa.pyi +119 -0
  85. amsdal/contrib/frontend_configs/conversion/convert.py +85 -25
  86. amsdal/contrib/frontend_configs/conversion/convert.pyi +0 -1
  87. amsdal/contrib/frontend_configs/lifecycle/consumer.py +32 -13
  88. amsdal/contrib/frontend_configs/lifecycle/consumer.pyi +1 -1
  89. amsdal/contrib/frontend_configs/migrations/0000_initial.py +167 -195
  90. amsdal/contrib/frontend_configs/migrations/0001_update_frontend_control_config.py +245 -0
  91. amsdal/contrib/frontend_configs/migrations/0002_add_button_and_invoke_actions.py +352 -0
  92. amsdal/contrib/frontend_configs/migrations/0003_create_class_frontendconfigdashboardelement.py +145 -0
  93. amsdal/contrib/frontend_configs/models/__init__.py +0 -0
  94. amsdal/contrib/frontend_configs/models/frontend_activator_config.py +22 -0
  95. amsdal/contrib/frontend_configs/models/frontend_config_async_validator.py +11 -0
  96. amsdal/contrib/frontend_configs/models/frontend_config_control_action.py +110 -0
  97. amsdal/contrib/frontend_configs/models/frontend_config_dashboard.py +51 -0
  98. amsdal/contrib/frontend_configs/models/frontend_config_group_validator.py +21 -0
  99. amsdal/contrib/frontend_configs/models/frontend_config_option.py +12 -0
  100. amsdal/contrib/frontend_configs/models/frontend_config_skip_none_base.py +17 -0
  101. amsdal/contrib/frontend_configs/models/frontend_config_slider_option.py +13 -0
  102. amsdal/contrib/frontend_configs/models/frontend_config_text_mask.py +14 -0
  103. amsdal/contrib/frontend_configs/models/frontend_config_validator.py +28 -0
  104. amsdal/contrib/frontend_configs/models/frontend_control_config.py +110 -0
  105. amsdal/contrib/frontend_configs/models/frontend_model_config.py +14 -0
  106. amsdal/errors.py +0 -3
  107. amsdal/errors.pyi +0 -1
  108. amsdal/fixtures/__init__.cpython-311-darwin.so +0 -0
  109. amsdal/fixtures/manager.cpython-311-darwin.so +0 -0
  110. amsdal/fixtures/manager.pyi +73 -123
  111. amsdal/fixtures/utils.cpython-311-darwin.so +0 -0
  112. amsdal/fixtures/utils.pyi +9 -0
  113. amsdal/manager.cpython-311-darwin.so +0 -0
  114. amsdal/manager.pyi +9 -96
  115. amsdal/mixins/__init__.cpython-311-darwin.so +0 -0
  116. amsdal/mixins/class_versions_mixin.cpython-311-darwin.so +0 -0
  117. amsdal/models/__init__.py +19 -0
  118. amsdal/models/core/__init__.py +0 -0
  119. amsdal/models/core/class_object.py +38 -0
  120. amsdal/models/core/class_property.py +26 -0
  121. amsdal/models/core/file.py +243 -0
  122. amsdal/models/core/fixture.py +25 -0
  123. amsdal/models/core/option.py +11 -0
  124. amsdal/models/core/storage_metadata.py +15 -0
  125. amsdal/models/core/validator.py +12 -0
  126. amsdal/models/mixins.py +31 -0
  127. amsdal/models/types/__init__.py +0 -0
  128. amsdal/models/types/object.py +26 -0
  129. amsdal/queryset/__init__.py +21 -0
  130. amsdal/queryset/__init__.pyi +6 -0
  131. amsdal/schemas/core/class_object/model.json +20 -0
  132. amsdal/schemas/core/class_property/model.json +19 -0
  133. amsdal/schemas/core/file/properties/from_file.py +1 -1
  134. amsdal/schemas/core/file/properties/validate_data.py +3 -4
  135. amsdal/schemas/core/storage_metadata/model.json +52 -0
  136. amsdal/schemas/interfaces.py +25 -0
  137. amsdal/schemas/interfaces.pyi +20 -0
  138. amsdal/schemas/manager.cpython-311-darwin.so +0 -0
  139. amsdal/schemas/manager.py +0 -116
  140. amsdal/schemas/manager.pyi +0 -65
  141. amsdal/schemas/mixins/__init__.py +0 -0
  142. amsdal/schemas/mixins/__init__.pyi +0 -0
  143. amsdal/schemas/mixins/check_dependencies_mixin.py +130 -0
  144. amsdal/schemas/mixins/check_dependencies_mixin.pyi +45 -0
  145. amsdal/schemas/mixins/verify_schemas_mixin.py +96 -0
  146. amsdal/schemas/mixins/verify_schemas_mixin.pyi +33 -0
  147. amsdal/schemas/repository.py +84 -0
  148. amsdal/schemas/repository.pyi +22 -0
  149. amsdal/schemas/utils.py +16 -0
  150. amsdal/schemas/utils.pyi +10 -0
  151. amsdal/services/__init__.py +11 -0
  152. amsdal/services/__init__.pyi +4 -0
  153. amsdal/services/external_connections.py +262 -0
  154. amsdal/services/external_connections.pyi +190 -0
  155. amsdal/services/external_model_generator.py +350 -0
  156. amsdal/services/external_model_generator.pyi +134 -0
  157. amsdal/services/transaction_execution.cpython-311-darwin.so +0 -0
  158. amsdal/services/transaction_execution.pyi +2 -1
  159. amsdal/storages/__init__.py +20 -0
  160. amsdal/storages/__init__.pyi +8 -0
  161. amsdal/storages/file_system.py +214 -0
  162. amsdal/storages/file_system.pyi +36 -0
  163. amsdal/transactions/__init__.py +13 -0
  164. amsdal/transactions/__init__.pyi +4 -0
  165. amsdal/utils/rollback/__init__.py +99 -54
  166. amsdal/utils/rollback/__init__.pyi +6 -0
  167. amsdal/utils/tests/enums.py +0 -2
  168. amsdal/utils/tests/helpers.py +253 -231
  169. amsdal/utils/tests/migrations.py +157 -0
  170. {amsdal-0.3.3.dist-info → amsdal-0.5.29.dist-info}/METADATA +17 -10
  171. amsdal-0.5.29.dist-info/RECORD +276 -0
  172. {amsdal-0.3.3.dist-info → amsdal-0.5.29.dist-info}/WHEEL +1 -1
  173. amsdal/__migrations__/0001_datetime_type.py +0 -18
  174. amsdal/__migrations__/0002_fixture_order.py +0 -40
  175. amsdal/__migrations__/0003_schema_type_in_class_meta.py +0 -56
  176. amsdal/contrib/auth/models/login_session/hooks/pre_init.py +0 -68
  177. amsdal/contrib/auth/models/login_session/model.json +0 -23
  178. amsdal/contrib/auth/models/login_session/modifiers/display_name.py +0 -11
  179. amsdal/contrib/auth/models/permission/fixtures/basic_permissions.json +0 -62
  180. amsdal/contrib/auth/models/permission/model.json +0 -18
  181. amsdal/contrib/auth/models/permission/modifiers/display_name.py +0 -11
  182. amsdal/contrib/auth/models/user/hooks/post_init.py +0 -76
  183. amsdal/contrib/auth/models/user/hooks/pre_create.py +0 -8
  184. amsdal/contrib/auth/models/user/model.json +0 -25
  185. amsdal/contrib/auth/models/user/modifiers/display_name.py +0 -19
  186. amsdal/contrib/frontend_configs/models/frontend_activator_config/model.json +0 -11
  187. amsdal/contrib/frontend_configs/models/frontend_config_async_validator/model.json +0 -11
  188. amsdal/contrib/frontend_configs/models/frontend_config_group_validator/model.json +0 -52
  189. amsdal/contrib/frontend_configs/models/frontend_config_option/model.json +0 -15
  190. amsdal/contrib/frontend_configs/models/frontend_config_skip_none_base/model.json +0 -6
  191. amsdal/contrib/frontend_configs/models/frontend_config_skip_none_base/properties/model_dump.py +0 -13
  192. amsdal/contrib/frontend_configs/models/frontend_config_slider_option/model.json +0 -19
  193. amsdal/contrib/frontend_configs/models/frontend_config_text_mask/model.json +0 -26
  194. amsdal/contrib/frontend_configs/models/frontend_config_validator/model.json +0 -41
  195. amsdal/contrib/frontend_configs/models/frontend_control_config/model.json +0 -250
  196. amsdal/contrib/frontend_configs/models/frontend_model_config/fixtures/permissions.json +0 -24
  197. amsdal/contrib/frontend_configs/models/frontend_model_config/model.json +0 -17
  198. amsdal/contrib/frontend_configs/models/frontent_config_control_action/model.json +0 -54
  199. amsdal/contrib/frontend_configs/models/frontent_config_control_action/properties/action_validate.py +0 -33
  200. amsdal/migration/__init__.cpython-311-darwin.so +0 -0
  201. amsdal/migration/base_migration_schemas.cpython-311-darwin.so +0 -0
  202. amsdal/migration/base_migration_schemas.pyi +0 -120
  203. amsdal/migration/data_classes.cpython-311-darwin.so +0 -0
  204. amsdal/migration/data_classes.pyi +0 -172
  205. amsdal/migration/executors/__init__.cpython-311-darwin.so +0 -0
  206. amsdal/migration/executors/base.cpython-311-darwin.so +0 -0
  207. amsdal/migration/executors/base.pyi +0 -118
  208. amsdal/migration/executors/default_executor.cpython-311-darwin.so +0 -0
  209. amsdal/migration/executors/default_executor.pyi +0 -184
  210. amsdal/migration/executors/state_executor.cpython-311-darwin.so +0 -0
  211. amsdal/migration/executors/state_executor.pyi +0 -78
  212. amsdal/migration/file_migration_executor.cpython-311-darwin.so +0 -0
  213. amsdal/migration/file_migration_executor.pyi +0 -68
  214. amsdal/migration/file_migration_generator.cpython-311-darwin.so +0 -0
  215. amsdal/migration/file_migration_generator.pyi +0 -139
  216. amsdal/migration/file_migration_store.cpython-311-darwin.so +0 -0
  217. amsdal/migration/file_migration_store.pyi +0 -61
  218. amsdal/migration/file_migration_writer.cpython-311-darwin.so +0 -0
  219. amsdal/migration/file_migration_writer.pyi +0 -73
  220. amsdal/migration/migrations.cpython-311-darwin.so +0 -0
  221. amsdal/migration/migrations.pyi +0 -166
  222. amsdal/migration/migrations_loader.cpython-311-darwin.so +0 -0
  223. amsdal/migration/migrations_loader.pyi +0 -32
  224. amsdal/migration/schemas_loaders.cpython-311-darwin.so +0 -0
  225. amsdal/migration/schemas_loaders.pyi +0 -37
  226. amsdal/migration/templates/data_migration.tmpl +0 -18
  227. amsdal/migration/templates/dict_validator.tmpl +0 -4
  228. amsdal/migration/templates/migration.tmpl +0 -6
  229. amsdal/migration/templates/model_class.tmpl +0 -8
  230. amsdal/migration/templates/model_class_layout.tmpl +0 -24
  231. amsdal/migration/templates/options_validator.tmpl +0 -4
  232. amsdal/migration/utils.cpython-311-darwin.so +0 -0
  233. amsdal/migration/utils.pyi +0 -58
  234. amsdal/mixins/build_mixin.cpython-311-darwin.so +0 -0
  235. amsdal/mixins/build_mixin.pyi +0 -78
  236. amsdal/schemas/core/class_object_meta/model.json +0 -59
  237. amsdal/schemas/core/class_property_meta/model.json +0 -23
  238. amsdal/services/__init__.cpython-311-darwin.so +0 -0
  239. amsdal-0.3.3.dist-info/RECORD +0 -257
  240. amsdal-0.3.3.dist-info/licenses/LICENSE.txt +0 -107
  241. /amsdal/{migration → contrib/auth/services}/__init__.pyi +0 -0
  242. /amsdal/{migration/executors → contrib/auth/transactions}/__init__.pyi +0 -0
  243. {amsdal-0.3.3.dist-info → amsdal-0.5.29.dist-info/licenses}/LICENSE.txt +0 -0
  244. {amsdal-0.3.3.dist-info → amsdal-0.5.29.dist-info}/top_level.txt +0 -0
@@ -1,11 +1,10 @@
1
1
  from _typeshed import Incomplete
2
- from amsdal.schemas.manager import SchemaManager as SchemaManager
3
- from amsdal_models.classes.manager import ClassManager
4
- from amsdal_utils.config.manager import AmsdalConfigManager as AmsdalConfigManager
5
- from amsdal_utils.models.data_models.core import DictSchema, TypeData as TypeData
6
- from amsdal_utils.models.data_models.schema import PropertyData as PropertyData
2
+ from amsdal.fixtures.utils import process_fixture_value as process_fixture_value
3
+ from amsdal_models.classes.model import Model
4
+ from collections.abc import Generator
7
5
  from pathlib import Path
8
6
  from pydantic import BaseModel
7
+ from pydantic.fields import FieldInfo as FieldInfo
9
8
  from typing import Any
10
9
 
11
10
  logger: Incomplete
@@ -13,24 +12,16 @@ logger: Incomplete
13
12
  class FixtureData(BaseModel):
14
13
  class_name: str
15
14
  external_id: str
15
+ order: float
16
16
  data: dict[str, Any]
17
17
 
18
- class FixturesManager:
19
- """
20
- Manager class for handling fixture data.
21
-
22
- This class is responsible for loading, processing, and applying fixture data
23
- to the database. It supports nested object construction, data processing,
24
- and file fixture handling.
25
- """
26
- fixtures_path: Incomplete
27
- fixtures: Incomplete
28
- _created_cache: Incomplete
29
- data_to_process: Incomplete
18
+ class BaseFixturesManager:
19
+ ORDER_MULTIPLIER: int
20
+ fixtures_paths: Incomplete
21
+ fixtures: dict[str | int, list[tuple[float, FixtureData]]]
30
22
  _class_manager: Incomplete
31
23
  _config_manager: Incomplete
32
- _schema_manager: Incomplete
33
- def __init__(self, fixtures_path: Path, class_manager: ClassManager, config_manager: AmsdalConfigManager, schema_manager: SchemaManager) -> None: ...
24
+ def __init__(self, fixtures_paths: list[Path]) -> None: ...
34
25
  def load_fixtures(self) -> None:
35
26
  """
36
27
  Loads fixture data from the specified path.
@@ -42,41 +33,45 @@ class FixturesManager:
42
33
  Returns:
43
34
  None
44
35
  """
45
- def construct_nested_object(self, external_id: Any) -> Any:
46
- """
47
- Constructs a nested object reference from the given external ID.
36
+ def _load_fixtures(self, fixtures_path: Path, order_shift: int = 0) -> None: ...
37
+ def iter_fixtures(self) -> Generator[FixtureData, None, None]: ...
38
+ def _process_object_data(self, data: dict[str, Any], model_fields: dict[str, FieldInfo], m2m_fields: dict[str, type[Model]]) -> dict[str, Any]: ...
48
39
 
49
- This method takes an external ID and constructs a nested object reference
50
- dictionary. If the external ID is a dictionary containing an '_object_id' key,
51
- it extracts the ID. If the external ID is not a string or integer, it returns
52
- the external ID as is.
40
+ class FixturesManager(BaseFixturesManager):
41
+ """
42
+ Manager class for handling fixture data.
53
43
 
54
- Args:
55
- external_id (Any): The external ID to construct the nested object reference from.
44
+ This class is responsible for loading, processing, and applying fixture data
45
+ to the database. It supports nested object construction, data processing,
46
+ and file fixture handling.
47
+ """
48
+ def apply_file_fixtures(self) -> None:
49
+ """
50
+ Applies file fixtures from the specified directory.
51
+
52
+ This method processes file fixtures located in the 'files' directory adjacent to the
53
+ `fixtures_path`. It iterates through each file, reads its content, and processes it
54
+ as a fixture. If the file fixture already exists in the database, it updates the
55
+ existing fixture; otherwise, it creates a new one.
56
56
 
57
57
  Returns:
58
- Any: A dictionary representing the nested object reference or the original
59
- external ID if it is not a string or integer.
58
+ None
60
59
  """
61
- def _process_object_data(self, model_properties: dict[str, PropertyData], data: dict[str, Any]) -> dict[str, Any]: ...
62
- def _process_object_value(self, field_configuration: PropertyData | DictSchema | TypeData, value: Any) -> Any: ...
63
- def process_fixture_object_data(self, class_name: str, external_id: str, data: dict[str, Any]) -> None:
60
+ def _apply_file_fixtures(self, file_dir: Path) -> None: ...
61
+ def _apply_file_fixtures_rec(self, nested_dir: Path, base_dir: Path) -> None: ...
62
+ def apply_fixtures(self) -> None:
64
63
  """
65
- Processes and saves fixture object data to the database.
66
-
67
- This method takes the class name, external ID, and data dictionary of a fixture object,
68
- processes the data according to the class schema, and saves the object to the database.
69
- If the object already exists, it updates the existing object with the new data.
64
+ Applies all loaded fixtures to the database.
70
65
 
71
- Args:
72
- class_name (str): The name of the class to which the fixture object belongs.
73
- external_id (str): The external ID of the fixture object.
74
- data (dict[str, Any]): The data dictionary of the fixture object.
66
+ This method processes each fixture in the `fixtures` dictionary in the order
67
+ specified by their 'order' value. It calls the `process_fixture` method for
68
+ each fixture and then processes the data in the processing queue.
75
69
 
76
70
  Returns:
77
71
  None
78
72
  """
79
- def process_fixture(self, fixture: dict[str, Any]) -> None:
73
+ def _process_file_fixture(self, file_path: Path, file_key: str) -> None: ...
74
+ def _process_fixture(self, fixture: FixtureData) -> FixtureData | None:
80
75
  """
81
76
  Processes a single fixture and adds it to the processing queue.
82
77
 
@@ -91,94 +86,58 @@ class FixturesManager:
91
86
  Returns:
92
87
  None
93
88
  """
94
- def apply_fixtures(self) -> None:
89
+ def _process_fixture_object_data(self, class_name: str, external_id: str, data: dict[str, Any]) -> None:
95
90
  """
96
- Applies all loaded fixtures to the database.
97
-
98
- This method processes each fixture in the `fixtures` dictionary in the order
99
- specified by their 'order' value. It calls the `process_fixture` method for
100
- each fixture and then processes the data in the processing queue.
91
+ Processes and saves fixture object data to the database.
101
92
 
102
- Returns:
103
- None
104
- """
105
- def _process_data(self) -> None: ...
106
- def apply_file_fixtures(self) -> None:
107
- """
108
- Applies file fixtures from the specified directory.
93
+ This method takes the class name, external ID, and data dictionary of a fixture object,
94
+ processes the data according to the class schema, and saves the object to the database.
95
+ If the object already exists, it updates the existing object with the new data.
109
96
 
110
- This method processes file fixtures located in the 'files' directory adjacent to the
111
- `fixtures_path`. It iterates through each file, reads its content, and processes it
112
- as a fixture. If the file fixture already exists in the database, it updates the
113
- existing fixture; otherwise, it creates a new one.
97
+ Args:
98
+ class_name (str): The name of the class to which the fixture object belongs.
99
+ external_id (str): The external ID of the fixture object.
100
+ data (dict[str, Any]): The data dictionary of the fixture object.
114
101
 
115
102
  Returns:
116
103
  None
117
104
  """
118
- def _process_file_fixture(self, file_path: Path, file_key: str) -> None: ...
119
105
 
120
- class AsyncFixturesManager:
106
+ class AsyncFixturesManager(BaseFixturesManager):
121
107
  """
122
- Manager class for handling fixture data.
108
+ Manager class for handling fixture data asynchronously.
123
109
 
124
110
  This class is responsible for loading, processing, and applying fixture data
125
111
  to the database. It supports nested object construction, data processing,
126
112
  and file fixture handling.
127
113
  """
128
- fixtures_path: Incomplete
129
- fixtures: Incomplete
130
- _created_cache: Incomplete
131
- data_to_process: Incomplete
132
- _class_manager: Incomplete
133
- _config_manager: Incomplete
134
- _schema_manager: Incomplete
135
- def __init__(self, fixtures_path: Path, class_manager: ClassManager, config_manager: AmsdalConfigManager, schema_manager: SchemaManager) -> None: ...
136
- def load_fixtures(self) -> None:
114
+ async def apply_file_fixtures(self) -> None:
137
115
  """
138
- Loads fixture data from the specified path.
116
+ Applies file fixtures from the specified directory.
139
117
 
140
- This method reads fixture data from a JSON file located at the `fixtures_path`.
141
- It populates the `fixtures` dictionary with the loaded data, where each fixture
142
- is indexed by its external ID.
118
+ This method processes file fixtures located in the 'files' directory adjacent to the
119
+ `fixtures_path`. It iterates through each file, reads its content, and processes it
120
+ as a fixture. If the file fixture already exists in the database, it updates the
121
+ existing fixture; otherwise, it creates a new one.
143
122
 
144
123
  Returns:
145
124
  None
146
125
  """
147
- def construct_nested_object(self, external_id: Any) -> Any:
148
- """
149
- Constructs a nested object reference from the given external ID.
150
-
151
- This method takes an external ID and constructs a nested object reference
152
- dictionary. If the external ID is a dictionary containing an '_object_id' key,
153
- it extracts the ID. If the external ID is not a string or integer, it returns
154
- the external ID as is.
155
-
156
- Args:
157
- external_id (Any): The external ID to construct the nested object reference from.
158
-
159
- Returns:
160
- Any: A dictionary representing the nested object reference or the original
161
- external ID if it is not a string or integer.
162
- """
163
- def _process_object_data(self, model_properties: dict[str, PropertyData], data: dict[str, Any]) -> dict[str, Any]: ...
164
- def _process_object_value(self, field_configuration: PropertyData | DictSchema | TypeData, value: Any) -> Any: ...
165
- async def process_fixture_object_data(self, class_name: str, external_id: str, data: dict[str, Any]) -> None:
126
+ async def _apply_file_fixtures(self, file_dir: Path) -> None: ...
127
+ async def _apply_file_fixtures_rec(self, nested_dir: Path, base_dir: Path) -> None: ...
128
+ async def apply_fixtures(self) -> None:
166
129
  """
167
- Processes and saves fixture object data to the database.
168
-
169
- This method takes the class name, external ID, and data dictionary of a fixture object,
170
- processes the data according to the class schema, and saves the object to the database.
171
- If the object already exists, it updates the existing object with the new data.
130
+ Applies all loaded fixtures to the database.
172
131
 
173
- Args:
174
- class_name (str): The name of the class to which the fixture object belongs.
175
- external_id (str): The external ID of the fixture object.
176
- data (dict[str, Any]): The data dictionary of the fixture object.
132
+ This method processes each fixture in the `fixtures` dictionary in the order
133
+ specified by their 'order' value. It calls the `process_fixture` method for
134
+ each fixture and then processes the data in the processing queue.
177
135
 
178
136
  Returns:
179
137
  None
180
138
  """
181
- async def process_fixture(self, fixture: dict[str, Any]) -> None:
139
+ async def _process_file_fixture(self, file_path: Path, file_key: str) -> None: ...
140
+ async def _process_fixture(self, fixture: FixtureData) -> FixtureData | None:
182
141
  """
183
142
  Processes a single fixture and adds it to the processing queue.
184
143
 
@@ -193,28 +152,19 @@ class AsyncFixturesManager:
193
152
  Returns:
194
153
  None
195
154
  """
196
- async def apply_fixtures(self) -> None:
155
+ async def _process_fixture_object_data(self, class_name: str, external_id: str, data: dict[str, Any]) -> None:
197
156
  """
198
- Applies all loaded fixtures to the database.
199
-
200
- This method processes each fixture in the `fixtures` dictionary in the order
201
- specified by their 'order' value. It calls the `process_fixture` method for
202
- each fixture and then processes the data in the processing queue.
157
+ Processes and saves fixture object data to the database.
203
158
 
204
- Returns:
205
- None
206
- """
207
- async def _process_data(self) -> None: ...
208
- async def apply_file_fixtures(self) -> None:
209
- """
210
- Applies file fixtures from the specified directory.
159
+ This method takes the class name, external ID, and data dictionary of a fixture object,
160
+ processes the data according to the class schema, and saves the object to the database.
161
+ If the object already exists, it updates the existing object with the new data.
211
162
 
212
- This method processes file fixtures located in the 'files' directory adjacent to the
213
- `fixtures_path`. It iterates through each file, reads its content, and processes it
214
- as a fixture. If the file fixture already exists in the database, it updates the
215
- existing fixture; otherwise, it creates a new one.
163
+ Args:
164
+ class_name (str): The name of the class to which the fixture object belongs.
165
+ external_id (str): The external ID of the fixture object.
166
+ data (dict[str, Any]): The data dictionary of the fixture object.
216
167
 
217
168
  Returns:
218
169
  None
219
170
  """
220
- async def _process_file_fixture(self, file_path: Path, file_key: str) -> None: ...
@@ -0,0 +1,9 @@
1
+ from amsdal_utils.models.data_models.reference import Reference
2
+ from types import GenericAlias
3
+ from typing import Any
4
+
5
+ def process_fixture_value(annotation: Any, value: Any) -> Any: ...
6
+ def _cast_value_to_type(value_type: type | GenericAlias, value: Any) -> Any: ...
7
+ def _is_optional(annotation: Any) -> bool: ...
8
+ def _resolve_type_from_optional(annotation: Any) -> Any: ...
9
+ def _construct_reference_value(class_name: str, object_id: Any) -> Reference: ...
Binary file
amsdal/manager.pyi CHANGED
@@ -1,19 +1,16 @@
1
1
  from _typeshed import Incomplete
2
2
  from amsdal.cloud.services.actions.manager import CloudActionsManager as CloudActionsManager
3
- from amsdal.cloud.services.auth.manager import AuthManager as AuthManager
4
3
  from amsdal.cloud.services.auth.signup_service import SignupService as SignupService
5
4
  from amsdal.configs.main import settings as settings
6
5
  from amsdal.errors import AmsdalAuthenticationError as AmsdalAuthenticationError, AmsdalMissingCredentialsError as AmsdalMissingCredentialsError, AmsdalRuntimeError as AmsdalRuntimeError, AmsdalSignupError as AmsdalSignupError
7
6
  from amsdal.fixtures.manager import AsyncFixturesManager as AsyncFixturesManager, FixturesManager as FixturesManager
8
- from amsdal.mixins.build_mixin import BuildMixin as BuildMixin
9
7
  from amsdal.mixins.class_versions_mixin import ClassVersionsMixin as ClassVersionsMixin
10
- from amsdal.schemas.manager import SchemaManager as SchemaManager
11
- from amsdal_models.classes.manager import ClassManager
8
+ from amsdal_data.transactions.decorators import async_transaction, transaction
9
+ from amsdal_models.classes.class_manager import ClassManager
12
10
  from amsdal_utils.config.data_models.amsdal_config import AmsdalConfig as AmsdalConfig
13
11
  from amsdal_utils.utils.singleton import Singleton
14
- from pathlib import Path
15
12
 
16
- class AmsdalManager(BuildMixin, ClassVersionsMixin, metaclass=Singleton):
13
+ class AmsdalManager(ClassVersionsMixin, metaclass=Singleton):
17
14
  """
18
15
  Manages the AMSDAL framework components and operations.
19
16
 
@@ -27,7 +24,6 @@ class AmsdalManager(BuildMixin, ClassVersionsMixin, metaclass=Singleton):
27
24
  _data_application: Incomplete
28
25
  _is_setup: bool
29
26
  __is_authenticated: bool
30
- _schema_manager: Incomplete
31
27
  _metadata_manager: Incomplete
32
28
  _auth_manager: Incomplete
33
29
  def __init__(self, *, raise_on_new_signup: bool = False) -> None:
@@ -54,7 +50,7 @@ class AmsdalManager(BuildMixin, ClassVersionsMixin, metaclass=Singleton):
54
50
  """
55
51
  Initiates models root path and adds it into sys.path.
56
52
 
57
- This method initializes the class manager and sets up the models root path
53
+ This method initializes the class manager models modules and sets up the models root path
58
54
  as specified in the settings. It ensures that the models root path is added
59
55
  to the system path for proper module resolution.
60
56
 
@@ -74,53 +70,11 @@ class AmsdalManager(BuildMixin, ClassVersionsMixin, metaclass=Singleton):
74
70
  Returns:
75
71
  None
76
72
  """
73
+ @transaction
77
74
  def post_setup(self) -> None:
78
75
  """
79
76
  Registers internal classes and prepares connections (creates internal tables).
80
77
  """
81
- def build(self, source_models_path: Path, source_transactions_path: Path, source_static_files_path: Path, source_fixtures_path: Path, source_migrations_path: Path) -> None:
82
- """
83
- Builds the necessary components for the Amsdal framework.
84
-
85
- This method is used to build the necessary components for the Amsdal framework.
86
- It takes five parameters which are all of type `Path`.
87
- These parameters represent the paths to the directories where the corresponding components are located.
88
-
89
- Args:
90
- source_models_path (Path): Path to the directory where the source models are located.
91
- source_transactions_path (Path): Path to the directory where the source transactions are located.
92
- source_static_files_path (Path): Path to the directory where the source static files are located.
93
- source_fixtures_path (Path): Path to the directory where the source fixtures are located.
94
- source_migrations_path (Path): Path to the directory where the source migrations are located.
95
-
96
- Returns:
97
- None
98
-
99
- The method performs the following build steps in order:
100
- - Builds the models from the `source_models_path` by calling the `build_models` method.
101
- - Builds the transactions from the `source_transactions_path` by calling the `build_transactions` method.
102
- - Builds the static files from the `source_static_files_path` by calling the `build_static_files` method.
103
- - Builds the fixtures from the `source_fixtures_path` by calling the `build_fixtures` method.
104
-
105
- Note:
106
- This method is part of the `AmsdalManager` class which includes mixins for `BuildMixin`
107
- and `ClassVersionsMixin`. It is intended to be used in the Amsdal framework for managing
108
- and building components.
109
- """
110
- def migrate(self) -> None:
111
- """
112
- DEPRECATED: Check changes in the models and apply them to the database.
113
-
114
- This method is deprecated and should not be used. It checks for changes in the models
115
- and applies them to the database. Use `amsdal.migration.file_migration_generator.FileMigrationGenerator`
116
- instead.
117
-
118
- Raises:
119
- DeprecationWarning: Always raised to indicate that this method is deprecated.
120
-
121
- Returns:
122
- None
123
- """
124
78
  def _check_auth(self) -> None: ...
125
79
  @property
126
80
  def cloud_actions_manager(self) -> CloudActionsManager:
@@ -146,6 +100,7 @@ class AmsdalManager(BuildMixin, ClassVersionsMixin, metaclass=Singleton):
146
100
  Returns:
147
101
  None
148
102
  """
103
+ @transaction
149
104
  def apply_fixtures(self) -> None:
150
105
  """
151
106
  Loads and applies fixtures defined in your application.
@@ -182,7 +137,7 @@ class AmsdalManager(BuildMixin, ClassVersionsMixin, metaclass=Singleton):
182
137
  None
183
138
  """
184
139
 
185
- class AsyncAmsdalManager(BuildMixin, ClassVersionsMixin, metaclass=Singleton):
140
+ class AsyncAmsdalManager(ClassVersionsMixin, metaclass=Singleton):
186
141
  """
187
142
  Manages the AMSDAL framework components and operations.
188
143
 
@@ -196,7 +151,6 @@ class AsyncAmsdalManager(BuildMixin, ClassVersionsMixin, metaclass=Singleton):
196
151
  _data_application: Incomplete
197
152
  _is_setup: bool
198
153
  __is_authenticated: bool
199
- _schema_manager: Incomplete
200
154
  _metadata_manager: Incomplete
201
155
  _auth_manager: Incomplete
202
156
  def __init__(self, *, raise_on_new_signup: bool = False) -> None:
@@ -243,53 +197,11 @@ class AsyncAmsdalManager(BuildMixin, ClassVersionsMixin, metaclass=Singleton):
243
197
  Returns:
244
198
  None
245
199
  """
200
+ @async_transaction
246
201
  async def post_setup(self) -> None:
247
202
  """
248
203
  Registers internal classes and prepares connections (creates internal tables).
249
204
  """
250
- def build(self, source_models_path: Path, source_transactions_path: Path, source_static_files_path: Path, source_fixtures_path: Path, source_migrations_path: Path) -> None:
251
- """
252
- Builds the necessary components for the Amsdal framework.
253
-
254
- This method is used to build the necessary components for the Amsdal framework.
255
- It takes five parameters which are all of type `Path`.
256
- These parameters represent the paths to the directories where the corresponding components are located.
257
-
258
- Args:
259
- source_models_path (Path): Path to the directory where the source models are located.
260
- source_transactions_path (Path): Path to the directory where the source transactions are located.
261
- source_static_files_path (Path): Path to the directory where the source static files are located.
262
- source_fixtures_path (Path): Path to the directory where the source fixtures are located.
263
- source_migrations_path (Path): Path to the directory where the source migrations are located.
264
-
265
- Returns:
266
- None
267
-
268
- The method performs the following build steps in order:
269
- - Builds the models from the `source_models_path` by calling the `build_models` method.
270
- - Builds the transactions from the `source_transactions_path` by calling the `build_transactions` method.
271
- - Builds the static files from the `source_static_files_path` by calling the `build_static_files` method.
272
- - Builds the fixtures from the `source_fixtures_path` by calling the `build_fixtures` method.
273
-
274
- Note:
275
- This method is part of the `AmsdalManager` class which includes mixins for `BuildMixin`
276
- and `ClassVersionsMixin`. It is intended to be used in the Amsdal framework for managing
277
- and building components.
278
- """
279
- def migrate(self) -> None:
280
- """
281
- DEPRECATED: Check changes in the models and apply them to the database.
282
-
283
- This method is deprecated and should not be used. It checks for changes in the models
284
- and applies them to the database. Use `amsdal.migration.file_migration_generator.FileMigrationGenerator`
285
- instead.
286
-
287
- Raises:
288
- DeprecationWarning: Always raised to indicate that this method is deprecated.
289
-
290
- Returns:
291
- None
292
- """
293
205
  def _check_auth(self) -> None: ...
294
206
  @property
295
207
  def cloud_actions_manager(self) -> CloudActionsManager:
@@ -315,6 +227,7 @@ class AsyncAmsdalManager(BuildMixin, ClassVersionsMixin, metaclass=Singleton):
315
227
  Returns:
316
228
  None
317
229
  """
230
+ @async_transaction
318
231
  async def apply_fixtures(self) -> None:
319
232
  """
320
233
  Loads and applies fixtures defined in your application.
@@ -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)