amsdal 0.3.6__cp312-cp312-macosx_10_13_universal2.whl → 0.4.1__cp312-cp312-macosx_10_13_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.

Potentially problematic release.


This version of amsdal might be problematic. Click here for more details.

Files changed (209) hide show
  1. amsdal/__about__.py +1 -1
  2. amsdal/__migrations__/0000_initial.py +34 -25
  3. amsdal/__migrations__/0001_datetime_type.py +4 -4
  4. amsdal/__migrations__/0002_fixture_order.py +7 -3
  5. amsdal/__migrations__/0003_schema_type_in_class_meta.py +3 -15
  6. amsdal/cloud/__init__.cpython-312-darwin.so +0 -0
  7. amsdal/cloud/client.cpython-312-darwin.so +0 -0
  8. amsdal/cloud/constants.cpython-312-darwin.so +0 -0
  9. amsdal/cloud/enums.cpython-312-darwin.so +0 -0
  10. amsdal/cloud/models/__init__.cpython-312-darwin.so +0 -0
  11. amsdal/cloud/models/base.cpython-312-darwin.so +0 -0
  12. amsdal/cloud/services/__init__.cpython-312-darwin.so +0 -0
  13. amsdal/cloud/services/actions/__init__.cpython-312-darwin.so +0 -0
  14. amsdal/cloud/services/actions/add_allowlist_ip.cpython-312-darwin.so +0 -0
  15. amsdal/cloud/services/actions/add_basic_auth.cpython-312-darwin.so +0 -0
  16. amsdal/cloud/services/actions/add_dependency.cpython-312-darwin.so +0 -0
  17. amsdal/cloud/services/actions/add_secret.cpython-312-darwin.so +0 -0
  18. amsdal/cloud/services/actions/base.cpython-312-darwin.so +0 -0
  19. amsdal/cloud/services/actions/create_deploy.cpython-312-darwin.so +0 -0
  20. amsdal/cloud/services/actions/create_env.cpython-312-darwin.so +0 -0
  21. amsdal/cloud/services/actions/create_session.cpython-312-darwin.so +0 -0
  22. amsdal/cloud/services/actions/delete_allowlist_ip.cpython-312-darwin.so +0 -0
  23. amsdal/cloud/services/actions/delete_basic_auth.cpython-312-darwin.so +0 -0
  24. amsdal/cloud/services/actions/delete_dependency.cpython-312-darwin.so +0 -0
  25. amsdal/cloud/services/actions/delete_env.cpython-312-darwin.so +0 -0
  26. amsdal/cloud/services/actions/delete_secret.cpython-312-darwin.so +0 -0
  27. amsdal/cloud/services/actions/destroy_deploy.cpython-312-darwin.so +0 -0
  28. amsdal/cloud/services/actions/expose_db.cpython-312-darwin.so +0 -0
  29. amsdal/cloud/services/actions/get_basic_auth_credentials.cpython-312-darwin.so +0 -0
  30. amsdal/cloud/services/actions/get_monitoring_info.cpython-312-darwin.so +0 -0
  31. amsdal/cloud/services/actions/list_dependencies.cpython-312-darwin.so +0 -0
  32. amsdal/cloud/services/actions/list_deploys.cpython-312-darwin.so +0 -0
  33. amsdal/cloud/services/actions/list_envs.cpython-312-darwin.so +0 -0
  34. amsdal/cloud/services/actions/list_secrets.cpython-312-darwin.so +0 -0
  35. amsdal/cloud/services/actions/manager.cpython-312-darwin.so +0 -0
  36. amsdal/cloud/services/actions/signup_action.cpython-312-darwin.so +0 -0
  37. amsdal/cloud/services/actions/update_deploy.cpython-312-darwin.so +0 -0
  38. amsdal/cloud/services/auth/__init__.cpython-312-darwin.so +0 -0
  39. amsdal/cloud/services/auth/base.cpython-312-darwin.so +0 -0
  40. amsdal/cloud/services/auth/credentials.cpython-312-darwin.so +0 -0
  41. amsdal/cloud/services/auth/credentials.pyi +0 -1
  42. amsdal/cloud/services/auth/manager.cpython-312-darwin.so +0 -0
  43. amsdal/cloud/services/auth/signup_service.cpython-312-darwin.so +0 -0
  44. amsdal/cloud/services/auth/token.cpython-312-darwin.so +0 -0
  45. amsdal/cloud/services/auth/token.pyi +0 -1
  46. amsdal/configs/main.py +23 -19
  47. amsdal/configs/main.pyi +12 -15
  48. amsdal/contrib/__init__.cpython-312-darwin.so +0 -0
  49. amsdal/contrib/auth/fixtures/basic_permissions.json +64 -0
  50. amsdal/contrib/auth/lifecycle/consumer.py +10 -10
  51. amsdal/contrib/auth/migrations/0000_initial.py +41 -7
  52. amsdal/contrib/auth/models/login_session.py +66 -0
  53. amsdal/contrib/auth/models/login_session.pyi +33 -0
  54. amsdal/contrib/auth/models/permission.py +23 -0
  55. amsdal/contrib/auth/models/permission.pyi +18 -0
  56. amsdal/contrib/auth/models/user.py +106 -0
  57. amsdal/contrib/auth/models/user.pyi +46 -0
  58. amsdal/contrib/frontend_configs/conversion/convert.py +47 -15
  59. amsdal/contrib/frontend_configs/conversion/convert.pyi +0 -1
  60. amsdal/contrib/frontend_configs/lifecycle/consumer.py +32 -13
  61. amsdal/contrib/frontend_configs/lifecycle/consumer.pyi +1 -1
  62. amsdal/contrib/frontend_configs/migrations/0000_initial.py +15 -14
  63. amsdal/contrib/frontend_configs/models/__init__.py +0 -0
  64. amsdal/contrib/frontend_configs/models/__init__.pyi +0 -0
  65. amsdal/contrib/frontend_configs/models/frontend_activator_config.py +22 -0
  66. amsdal/contrib/frontend_configs/models/frontend_activator_config.pyi +12 -0
  67. amsdal/contrib/frontend_configs/models/frontend_config_async_validator.py +11 -0
  68. amsdal/contrib/frontend_configs/models/frontend_config_async_validator.pyi +7 -0
  69. amsdal/contrib/frontend_configs/models/frontend_config_control_action.py +54 -0
  70. amsdal/contrib/frontend_configs/models/frontend_config_control_action.pyi +32 -0
  71. amsdal/contrib/frontend_configs/models/frontend_config_group_validator.py +21 -0
  72. amsdal/contrib/frontend_configs/models/frontend_config_group_validator.pyi +11 -0
  73. amsdal/contrib/frontend_configs/models/frontend_config_option.py +12 -0
  74. amsdal/contrib/frontend_configs/models/frontend_config_option.pyi +8 -0
  75. amsdal/contrib/frontend_configs/models/frontend_config_skip_none_base.py +17 -0
  76. amsdal/contrib/frontend_configs/models/frontend_config_skip_none_base.pyi +8 -0
  77. amsdal/contrib/frontend_configs/models/frontend_config_slider_option.py +13 -0
  78. amsdal/contrib/frontend_configs/models/frontend_config_slider_option.pyi +9 -0
  79. amsdal/contrib/frontend_configs/models/frontend_config_text_mask.py +14 -0
  80. amsdal/contrib/frontend_configs/models/frontend_config_text_mask.pyi +10 -0
  81. amsdal/contrib/frontend_configs/models/frontend_config_validator.py +28 -0
  82. amsdal/contrib/frontend_configs/models/frontend_config_validator.pyi +15 -0
  83. amsdal/contrib/frontend_configs/models/frontend_control_config.py +87 -0
  84. amsdal/contrib/frontend_configs/models/frontend_control_config.pyi +35 -0
  85. amsdal/contrib/frontend_configs/models/frontend_model_config.py +14 -0
  86. amsdal/contrib/frontend_configs/models/frontend_model_config.pyi +9 -0
  87. amsdal/errors.py +0 -3
  88. amsdal/errors.pyi +0 -1
  89. amsdal/fixtures/__init__.cpython-312-darwin.so +0 -0
  90. amsdal/fixtures/manager.cpython-312-darwin.so +0 -0
  91. amsdal/fixtures/manager.pyi +72 -123
  92. amsdal/fixtures/utils.cpython-312-darwin.so +0 -0
  93. amsdal/fixtures/utils.pyi +9 -0
  94. amsdal/manager.cpython-312-darwin.so +0 -0
  95. amsdal/manager.pyi +4 -96
  96. amsdal/mixins/__init__.cpython-312-darwin.so +0 -0
  97. amsdal/mixins/class_versions_mixin.cpython-312-darwin.so +0 -0
  98. amsdal/models/__init__.py +0 -0
  99. amsdal/models/__init__.pyi +0 -0
  100. amsdal/models/core/__init__.py +0 -0
  101. amsdal/models/core/__init__.pyi +0 -0
  102. amsdal/models/core/class_object.py +37 -0
  103. amsdal/models/core/class_object.pyi +24 -0
  104. amsdal/models/core/class_object_meta.py +26 -0
  105. amsdal/models/core/class_object_meta.pyi +15 -0
  106. amsdal/models/core/class_property.py +19 -0
  107. amsdal/models/core/class_property.pyi +10 -0
  108. amsdal/models/core/class_property_meta.py +15 -0
  109. amsdal/models/core/class_property_meta.pyi +10 -0
  110. amsdal/models/core/file.py +156 -0
  111. amsdal/models/core/file.pyi +104 -0
  112. amsdal/models/core/fixture.py +25 -0
  113. amsdal/models/core/fixture.pyi +14 -0
  114. amsdal/models/core/option.py +11 -0
  115. amsdal/models/core/option.pyi +8 -0
  116. amsdal/models/core/validator.py +12 -0
  117. amsdal/models/core/validator.pyi +8 -0
  118. amsdal/models/types/__init__.py +0 -0
  119. amsdal/models/types/__init__.pyi +0 -0
  120. amsdal/models/types/object.py +26 -0
  121. amsdal/models/types/object.pyi +16 -0
  122. amsdal/schemas/core/file/properties/validate_data.py +1 -1
  123. amsdal/schemas/interfaces.py +25 -0
  124. amsdal/schemas/interfaces.pyi +20 -0
  125. amsdal/schemas/manager.cpython-312-darwin.so +0 -0
  126. amsdal/schemas/manager.py +0 -116
  127. amsdal/schemas/manager.pyi +0 -65
  128. amsdal/schemas/mixins/__init__.py +0 -0
  129. amsdal/schemas/mixins/__init__.pyi +0 -0
  130. amsdal/schemas/mixins/check_dependencies_mixin.py +115 -0
  131. amsdal/schemas/mixins/check_dependencies_mixin.pyi +42 -0
  132. amsdal/schemas/mixins/verify_schemas_mixin.py +96 -0
  133. amsdal/schemas/mixins/verify_schemas_mixin.pyi +33 -0
  134. amsdal/schemas/repository.py +84 -0
  135. amsdal/schemas/repository.pyi +22 -0
  136. amsdal/schemas/utils.py +16 -0
  137. amsdal/schemas/utils.pyi +10 -0
  138. amsdal/services/__init__.cpython-312-darwin.so +0 -0
  139. amsdal/services/transaction_execution.cpython-312-darwin.so +0 -0
  140. amsdal/utils/rollback/__init__.py +99 -54
  141. amsdal/utils/tests/helpers.py +46 -37
  142. {amsdal-0.3.6.dist-info → amsdal-0.4.1.dist-info}/METADATA +8 -8
  143. {amsdal-0.3.6.dist-info → amsdal-0.4.1.dist-info}/RECORD +149 -140
  144. {amsdal-0.3.6.dist-info → amsdal-0.4.1.dist-info}/WHEEL +1 -1
  145. amsdal/contrib/auth/models/login_session/hooks/pre_init.py +0 -68
  146. amsdal/contrib/auth/models/login_session/model.json +0 -23
  147. amsdal/contrib/auth/models/login_session/modifiers/display_name.py +0 -11
  148. amsdal/contrib/auth/models/permission/fixtures/basic_permissions.json +0 -62
  149. amsdal/contrib/auth/models/permission/model.json +0 -18
  150. amsdal/contrib/auth/models/permission/modifiers/display_name.py +0 -11
  151. amsdal/contrib/auth/models/user/hooks/post_init.py +0 -76
  152. amsdal/contrib/auth/models/user/hooks/pre_create.py +0 -8
  153. amsdal/contrib/auth/models/user/model.json +0 -25
  154. amsdal/contrib/auth/models/user/modifiers/display_name.py +0 -19
  155. amsdal/contrib/frontend_configs/models/frontend_activator_config/model.json +0 -11
  156. amsdal/contrib/frontend_configs/models/frontend_config_async_validator/model.json +0 -11
  157. amsdal/contrib/frontend_configs/models/frontend_config_group_validator/model.json +0 -52
  158. amsdal/contrib/frontend_configs/models/frontend_config_option/model.json +0 -15
  159. amsdal/contrib/frontend_configs/models/frontend_config_skip_none_base/model.json +0 -6
  160. amsdal/contrib/frontend_configs/models/frontend_config_skip_none_base/properties/model_dump.py +0 -13
  161. amsdal/contrib/frontend_configs/models/frontend_config_slider_option/model.json +0 -19
  162. amsdal/contrib/frontend_configs/models/frontend_config_text_mask/model.json +0 -26
  163. amsdal/contrib/frontend_configs/models/frontend_config_validator/model.json +0 -41
  164. amsdal/contrib/frontend_configs/models/frontend_control_config/model.json +0 -250
  165. amsdal/contrib/frontend_configs/models/frontend_model_config/fixtures/permissions.json +0 -24
  166. amsdal/contrib/frontend_configs/models/frontend_model_config/model.json +0 -17
  167. amsdal/contrib/frontend_configs/models/frontent_config_control_action/model.json +0 -54
  168. amsdal/contrib/frontend_configs/models/frontent_config_control_action/properties/action_validate.py +0 -33
  169. amsdal/migration/__init__.cpython-312-darwin.so +0 -0
  170. amsdal/migration/base_migration_schemas.cpython-312-darwin.so +0 -0
  171. amsdal/migration/base_migration_schemas.pyi +0 -119
  172. amsdal/migration/data_classes.cpython-312-darwin.so +0 -0
  173. amsdal/migration/data_classes.pyi +0 -165
  174. amsdal/migration/executors/__init__.cpython-312-darwin.so +0 -0
  175. amsdal/migration/executors/base.cpython-312-darwin.so +0 -0
  176. amsdal/migration/executors/base.pyi +0 -117
  177. amsdal/migration/executors/default_executor.cpython-312-darwin.so +0 -0
  178. amsdal/migration/executors/default_executor.pyi +0 -184
  179. amsdal/migration/executors/state_executor.cpython-312-darwin.so +0 -0
  180. amsdal/migration/executors/state_executor.pyi +0 -151
  181. amsdal/migration/file_migration_executor.cpython-312-darwin.so +0 -0
  182. amsdal/migration/file_migration_executor.pyi +0 -122
  183. amsdal/migration/file_migration_generator.cpython-312-darwin.so +0 -0
  184. amsdal/migration/file_migration_generator.pyi +0 -229
  185. amsdal/migration/file_migration_store.cpython-312-darwin.so +0 -0
  186. amsdal/migration/file_migration_store.pyi +0 -114
  187. amsdal/migration/file_migration_writer.cpython-312-darwin.so +0 -0
  188. amsdal/migration/file_migration_writer.pyi +0 -73
  189. amsdal/migration/migrations.cpython-312-darwin.so +0 -0
  190. amsdal/migration/migrations.pyi +0 -166
  191. amsdal/migration/migrations_loader.cpython-312-darwin.so +0 -0
  192. amsdal/migration/migrations_loader.pyi +0 -32
  193. amsdal/migration/schemas_loaders.cpython-312-darwin.so +0 -0
  194. amsdal/migration/schemas_loaders.pyi +0 -37
  195. amsdal/migration/templates/data_migration.tmpl +0 -18
  196. amsdal/migration/templates/dict_validator.tmpl +0 -4
  197. amsdal/migration/templates/migration.tmpl +0 -6
  198. amsdal/migration/templates/model_class.tmpl +0 -8
  199. amsdal/migration/templates/model_class_layout.tmpl +0 -24
  200. amsdal/migration/templates/options_validator.tmpl +0 -4
  201. amsdal/migration/utils.cpython-312-darwin.so +0 -0
  202. amsdal/migration/utils.pyi +0 -58
  203. amsdal/mixins/build_mixin.cpython-312-darwin.so +0 -0
  204. amsdal/mixins/build_mixin.pyi +0 -78
  205. /amsdal/{migration/__init__.pyi → contrib/auth/models/__init__.py} +0 -0
  206. /amsdal/{migration/executors → contrib/auth/models}/__init__.pyi +0 -0
  207. {amsdal-0.3.6.dist-info → amsdal-0.4.1.dist-info}/LICENSE.txt +0 -0
  208. {amsdal-0.3.6.dist-info → amsdal-0.4.1.dist-info}/licenses/LICENSE.txt +0 -0
  209. {amsdal-0.3.6.dist-info → amsdal-0.4.1.dist-info}/top_level.txt +0 -0
@@ -1,54 +0,0 @@
1
- {
2
- "title": "FrontendConfigControlAction",
3
- "type": "FrontendConfigSkipNoneBase",
4
- "properties": {
5
- "action": {
6
- "title": "Action",
7
- "type": "string"
8
- },
9
- "text": {
10
- "title": "Text",
11
- "type": "string"
12
- },
13
- "type": {
14
- "title": "Type",
15
- "type": "string",
16
- "options": [
17
- {
18
- "key": "Arrow Next",
19
- "value": "arrow-next"
20
- },
21
- {
22
- "key": "Arrow Prev",
23
- "value": "arrow-prev"
24
- },
25
- {
26
- "key": "Action Button",
27
- "value": "action-button"
28
- },
29
- {
30
- "key": "Text Next",
31
- "value": "text-next"
32
- },
33
- {
34
- "key": "Text Prev",
35
- "value": "text-prev"
36
- }
37
- ]
38
- },
39
- "dataLayerEvent": {
40
- "title": "Data Layer Event",
41
- "type": "string"
42
- },
43
- "activator": {
44
- "title": "Activator",
45
- "type": "string"
46
- },
47
- "icon": {
48
- "title": "Icon",
49
- "type": "string"
50
- }
51
- },
52
- "required": ["action", "text", "type"],
53
- "meta_class": "TypeMeta"
54
- }
@@ -1,33 +0,0 @@
1
- from pydantic import field_validator
2
-
3
-
4
- @field_validator('action', mode='after') # type: ignore[misc]
5
- @classmethod
6
- def validate_action(cls, v: str) -> str: # type: ignore[no-untyped-def] # noqa: ARG001
7
- """
8
- Validates the action string to ensure it is one of the allowed values.
9
-
10
- This method checks if the action string starts with 'navigate::' or is one of the predefined
11
- actions. If the action string is invalid, it raises a ValueError.
12
-
13
- Args:
14
- cls: The class this method is attached to.
15
- v (str): The action string to validate.
16
-
17
- Returns:
18
- str: The validated action string.
19
-
20
- Raises:
21
- ValueError: If the action string is not valid.
22
- """
23
- if not v.startswith('navigate::') and v not in [
24
- 'goPrev',
25
- 'goNext',
26
- 'goNextWithSubmit',
27
- 'submit',
28
- 'submitWithDataLayer',
29
- ]:
30
- msg = 'Action must be one of: goPrev, goNext, goNextWithSubmit, submit, submitWithDataLayer, navigate::{string}'
31
- raise ValueError(msg)
32
-
33
- return v
@@ -1,119 +0,0 @@
1
- import abc
2
- from abc import ABC, abstractmethod
3
- from amsdal.configs.constants import BASE_DIR as BASE_DIR
4
- from amsdal_models.classes.model import Model
5
- from amsdal_utils.models.data_models.core import DictSchema, LegacyDictSchema, TypeData as TypeData
6
- from amsdal_utils.models.data_models.schema import ObjectSchema as ObjectSchema, PropertyData as PropertyData
7
- from amsdal_utils.models.enums import SchemaTypes as SchemaTypes, Versions
8
- from pathlib import Path
9
-
10
- class BaseMigrationSchemas(ABC, metaclass=abc.ABCMeta):
11
- """
12
- Abstract base class for migration schemas.
13
-
14
- This class provides the interface for managing and compiling database schema migrations.
15
- It includes methods for registering, unregistering, and compiling classes, as well as
16
- managing class versions.
17
- """
18
- _classes: dict[str, type[Model]]
19
- _classes_versions: dict[str, dict[str, type[Model]]]
20
- _buffered_classes: list[tuple[str, ObjectSchema, SchemaTypes]]
21
- def __init__(self) -> None: ...
22
- def get_model(self, name: str) -> type[Model]:
23
- """
24
- Retrieves the model type for the given class name.
25
-
26
- Args:
27
- name (str): The name of the class whose model type is to be retrieved.
28
-
29
- Returns:
30
- type[Model]: The model type associated with the given class name.
31
- """
32
- @abstractmethod
33
- def register_model(self, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes, class_version: str | Versions = ...) -> None: ...
34
- @abstractmethod
35
- def unregister_model(self, class_name: str) -> None: ...
36
- @abstractmethod
37
- def compile_buffered_classes(self) -> None: ...
38
- @staticmethod
39
- def register_model_version(class_name: str, class_version: str | Versions) -> None:
40
- """
41
- Registers a specific version of a model class.
42
-
43
- This method registers a specific version of a model class using the ClassVersionManager.
44
-
45
- Args:
46
- class_name (str): The name of the class to register the version for.
47
- class_version (str | Versions): The version of the class to be registered.
48
-
49
- Returns:
50
- None
51
- """
52
-
53
- class DefaultMigrationSchemas(BaseMigrationSchemas):
54
- """
55
- Default implementation of the BaseMigrationSchemas.
56
-
57
- This class provides the default implementation for managing and compiling database schema migrations.
58
- It includes methods for registering, unregistering, and compiling classes, as well as managing class versions.
59
-
60
- Attributes:
61
- model_class_template_layout (Path): Path to the model class layout template.
62
- model_class_template (Path): Path to the model class template.
63
- dict_validator_template (Path): Path to the dictionary validator template.
64
- options_validator_template (Path): Path to the options validator template.
65
- """
66
- model_class_template_layout: Path
67
- model_class_template: Path
68
- dict_validator_template: Path
69
- options_validator_template: Path
70
- def register_model(self, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes, class_version: str | Versions = ...) -> None:
71
- """
72
- Registers a model class for migration.
73
-
74
- This method registers a model class for migration by adding it to the buffered classes
75
- and registering its latest version.
76
-
77
- Args:
78
- class_name (str): The name of the class to be registered.
79
- object_schema (ObjectSchema): The schema of the object to be registered.
80
- schema_type (SchemaTypes): The type of the schema.
81
-
82
- Returns:
83
- None
84
- """
85
- def compile_buffered_classes(self) -> None:
86
- """
87
- Compiles all buffered classes for migration.
88
-
89
- This method compiles all classes that have been buffered for migration and updates the
90
- internal class dictionary with the compiled class types. It clears the buffer after
91
- compilation.
92
-
93
- Returns:
94
- None
95
- """
96
- def unregister_model(self, class_name: str) -> None:
97
- """
98
- Unregisters a model class from the migration schemas.
99
-
100
- This method removes the specified model class from the internal class dictionary,
101
- effectively unregistering it from the migration schemas.
102
-
103
- Args:
104
- class_name (str): The name of the class to be unregistered.
105
-
106
- Returns:
107
- None
108
- """
109
- def _compile_buffered_classes(self) -> list[tuple[str, type[Model]]]: ...
110
- def _build_class_source(self, class_name: str, schema: ObjectSchema, schema_type: SchemaTypes) -> tuple[str, str]: ...
111
- @staticmethod
112
- def _resolve_class_inheritance(schema: ObjectSchema) -> str: ...
113
- @staticmethod
114
- def _process_custom_code(custom_code: str | None) -> tuple[str, str]: ...
115
- def _render_property(self, name: str, property_schema: PropertyData, required: list[str]) -> str: ...
116
- def _render_type_annotation(self, type_: str, items: TypeData | DictSchema | LegacyDictSchema | None) -> str: ...
117
- def _render_validators(self, schema: ObjectSchema) -> list[str]: ...
118
- def _get_all_types(self, type_: str, items: TypeData | DictSchema | LegacyDictSchema | None) -> set[str]: ...
119
- def _is_reference(self, type_: str) -> bool: ...
@@ -1,165 +0,0 @@
1
- from amsdal_models.classes.model import Model
2
- from amsdal_utils.models.data_models.address import Address as Address
3
- from amsdal_utils.models.data_models.schema import ObjectSchema as ObjectSchema, PropertyData as PropertyData
4
- from amsdal_utils.models.enums import SchemaTypes as SchemaTypes
5
- from dataclasses import dataclass
6
- from enum import Enum
7
- from pathlib import Path
8
-
9
- class Action(str, Enum):
10
- """
11
- Enumeration for different types of actions.
12
-
13
- Attributes:
14
- CREATED (str): Represents a created action.
15
- UPDATED (str): Represents an updated action.
16
- NO_ACTION (str): Represents no action.
17
- """
18
- CREATE = 'CREATE'
19
- UPDATE = 'UPDATE'
20
- NO_ACTION = 'NO_ACTION'
21
-
22
- @dataclass
23
- class ClassSaveResult:
24
- """
25
- Data class representing the result of a class save operation.
26
-
27
- Attributes:
28
- action (Action): The action performed during the save operation.
29
- instance (Model): The instance of the model that was saved.
30
- """
31
- action: Action
32
- instance: Model
33
-
34
- @dataclass
35
- class ClassUpdateResult:
36
- """
37
- Data class representing the result of a class update operation.
38
-
39
- Attributes:
40
- is_updated (bool): Indicates whether the class was updated.
41
- class_instance (Model): The instance of the model that was updated.
42
- """
43
- is_updated: bool
44
- class_instance: Model
45
-
46
- @dataclass
47
- class MigrateResult:
48
- """
49
- Data class representing the result of a migration operation.
50
-
51
- Attributes:
52
- class_instance (Model): The instance of the model that was migrated.
53
- is_table_created (bool): Indicates whether the table was created during the migration.
54
- is_data_migrated (bool): Indicates whether the data was migrated.
55
- """
56
- class_instance: Model
57
- is_table_created: bool
58
- is_data_migrated: bool
59
-
60
- class ModuleTypes(str, Enum):
61
- """
62
- Enumeration for different types of modules.
63
-
64
- Attributes:
65
- APP (str): Represents an application module.
66
- CORE (str): Represents a core module.
67
- CONTRIB (str): Represents a contributed module.
68
- """
69
- APP = 'APP'
70
- CORE = 'CORE'
71
- CONTRIB = 'CONTRIB'
72
-
73
- @dataclass
74
- class MigrationFile:
75
- """
76
- Data class representing a migration file.
77
-
78
- Attributes:
79
- path (Path): The file path of the migration.
80
- type (ModuleTypes): The type of module the migration belongs to.
81
- number (int): The migration number.
82
- module (str | None): The module name, if applicable.
83
- applied_at (float | None): The timestamp when the migration was applied.
84
- stored_address (Address | None): The stored address associated with the migration.
85
- """
86
- path: Path
87
- type: ModuleTypes
88
- number: int
89
- module: str | None = ...
90
- applied_at: float | None = ...
91
- stored_address: Address | None = ...
92
- @property
93
- def is_initial(self) -> bool:
94
- """
95
- Indicates whether this migration is the initial migration.
96
-
97
- Returns:
98
- bool: True if this is the initial migration, False otherwise.
99
- """
100
-
101
- @dataclass
102
- class ClassSchema:
103
- """
104
- Data class representing a class schema.
105
-
106
- Attributes:
107
- object_schema (ObjectSchema): The object schema associated with the class.
108
- type (ModuleTypes): The type of module the class belongs to.
109
- """
110
- object_schema: ObjectSchema
111
- type: ModuleTypes
112
-
113
- class OperationTypes(str, Enum):
114
- """
115
- Enumeration for different types of operations.
116
-
117
- Attributes:
118
- CREATE_CLASS (str): Represents the operation to create a class.
119
- UPDATE_CLASS (str): Represents the operation to update a class.
120
- DELETE_CLASS (str): Represents the operation to delete a class.
121
- """
122
- CREATE_CLASS = 'CREATE_CLASS'
123
- UPDATE_CLASS = 'UPDATE_CLASS'
124
- DELETE_CLASS = 'DELETE_CLASS'
125
-
126
- @dataclass
127
- class MigrateOperation:
128
- """
129
- Data class representing a migration operation.
130
-
131
- Attributes:
132
- type (OperationTypes): The type of operation being performed.
133
- class_name (str): The name of the class involved in the migration.
134
- schema_type (SchemaTypes): The type of schema associated with the migration.
135
- old_schema (ObjectSchema | PropertyData | None): The old schema before the migration, if applicable.
136
- new_schema (ObjectSchema | PropertyData | None): The new schema after the migration, if applicable.
137
- """
138
- type: OperationTypes
139
- class_name: str
140
- schema_type: SchemaTypes
141
- old_schema: ObjectSchema | PropertyData | None = ...
142
- new_schema: ObjectSchema | PropertyData | None = ...
143
-
144
- class MigrationDirection(str, Enum):
145
- """
146
- Enumeration for the direction of a migration.
147
-
148
- Attributes:
149
- FORWARD (str): Represents a forward migration.
150
- BACKWARD (str): Represents a backward migration.
151
- """
152
- FORWARD = 'forward'
153
- BACKWARD = 'backward'
154
-
155
- @dataclass
156
- class MigrationResult:
157
- """
158
- Data class representing the result of a migration.
159
-
160
- Attributes:
161
- direction (MigrationDirection): The direction of the migration.
162
- migration (MigrationFile): The migration file associated with the migration.
163
- """
164
- direction: MigrationDirection
165
- migration: MigrationFile
@@ -1,117 +0,0 @@
1
- import abc
2
- from abc import ABC, abstractmethod
3
- from amsdal.migration.base_migration_schemas import BaseMigrationSchemas as BaseMigrationSchemas
4
- from amsdal_utils.models.data_models.schema import ObjectSchema as ObjectSchema
5
- from amsdal_utils.models.enums import SchemaTypes as SchemaTypes
6
- from pydantic import BaseModel
7
-
8
- class FieldDescription(BaseModel):
9
- """
10
- Represents a description of a field in a database schema.
11
-
12
- This class holds information about a field, including its name, ID, type,
13
- and whether it has been marked as deleted.
14
-
15
- Attributes:
16
- field_name (str): The name of the field.
17
- field_id (str): The unique identifier of the field.
18
- field_type (str): The type of the field.
19
- is_deleted (bool): Indicates whether the field is marked as deleted.
20
- """
21
- field_name: str
22
- field_id: str
23
- field_type: str
24
- is_deleted: bool
25
-
26
- def _schema_to_table_description(schema: ObjectSchema | None) -> dict[str, str]: ...
27
- def _compare_schemas(previous_scheme: dict[str, str], new_scheme: dict[str, str]) -> list[tuple[str, str, str]]: ...
28
- def _id_for_column(field_name: str, iteration: str | int) -> str: ...
29
- def _new_table_schemas(previous_scheme: ObjectSchema | None, new_scheme: ObjectSchema, iteration: int, existing_table_structure: list[FieldDescription]) -> None: ...
30
-
31
- class BaseMigrationExecutor(ABC, metaclass=abc.ABCMeta):
32
- """
33
- Abstract base class for executing migration operations on database schemas.
34
-
35
- This class provides methods for creating, updating, and deleting classes in the database schema.
36
- It also manages schema migration buffers and generates full object schemas based on the migration history.
37
- """
38
- schemas: BaseMigrationSchemas
39
- _buffer: list[tuple[str, ObjectSchema, SchemaTypes]]
40
- _non_flushable_buffer: list[tuple[str, ObjectSchema, SchemaTypes]]
41
- def __init__(self) -> None: ...
42
- def generate_full_object_schema(self, class_name: str, object_schema: ObjectSchema, buffer: list[tuple[str, ObjectSchema, SchemaTypes]]) -> list[FieldDescription]:
43
- """
44
- Generates the full object schema based on the migration history.
45
-
46
- This method constructs the full object schema for a given class by iterating through
47
- the migration history buffer and applying schema changes in sequence.
48
-
49
- Args:
50
- class_name (str): The name of the class for which the schema is being generated.
51
- object_schema (ObjectSchema): The current object schema.
52
- buffer (list[tuple[str, ObjectSchema, SchemaTypes]]): The migration history buffer.
53
-
54
- Returns:
55
- list[FieldDescription]: A list of field descriptions representing the full object schema.
56
- """
57
- @abstractmethod
58
- def create_class(self, schemas: BaseMigrationSchemas, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes) -> None: ...
59
- @abstractmethod
60
- def update_class(self, schemas: BaseMigrationSchemas, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes) -> None: ...
61
- @abstractmethod
62
- def delete_class(self, schemas: BaseMigrationSchemas, class_name: str, schema_type: SchemaTypes) -> None: ...
63
- def forward_schema(self, schemas: BaseMigrationSchemas, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes) -> None:
64
- """
65
- Forwards the schema to the non-flushable buffer.
66
-
67
- This method appends the given class name, object schema, and schema type to the
68
- non-flushable buffer for further processing.
69
-
70
- Args:
71
- schemas (BaseMigrationSchemas): The migration schemas used for the operations.
72
- class_name (str): The name of the class for which the schema is being forwarded.
73
- object_schema (ObjectSchema): The current object schema.
74
- schema_type (SchemaTypes): The type of the schema.
75
-
76
- Returns:
77
- None
78
- """
79
- @staticmethod
80
- def _resolve_base_class_name(class_name: str, meta_class: str) -> str: ...
81
- def buffer_class_migration(self, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes) -> None:
82
- """
83
- Buffers the class migration operation.
84
-
85
- This method appends the given class name, object schema, and schema type to both
86
- the non-flushable buffer and the main buffer for further processing.
87
-
88
- Args:
89
- class_name (str): The name of the class for which the migration is being buffered.
90
- object_schema (ObjectSchema): The current object schema.
91
- schema_type (SchemaTypes): The type of the schema.
92
-
93
- Returns:
94
- None
95
- """
96
- def flush_buffer(self) -> None:
97
- """
98
- Flushes the migration buffer.
99
-
100
- This method clears all entries from the main migration buffer, effectively
101
- resetting it for future migration operations.
102
-
103
- Returns:
104
- None
105
- """
106
-
107
- class AsyncBaseMigrationExecutor(BaseMigrationExecutor, metaclass=abc.ABCMeta):
108
- async def flush_buffer(self) -> None:
109
- """
110
- Flushes the migration buffer.
111
-
112
- This method clears all entries from the main migration buffer, effectively
113
- resetting it for future migration operations.
114
-
115
- Returns:
116
- None
117
- """