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,118 +0,0 @@
1
- import abc
2
- from _typeshed import Incomplete
3
- from abc import ABC, abstractmethod
4
- from amsdal.migration.base_migration_schemas import BaseMigrationSchemas as BaseMigrationSchemas
5
- from amsdal_utils.models.data_models.schema import ObjectSchema as ObjectSchema
6
- from amsdal_utils.models.enums import SchemaTypes as SchemaTypes
7
- from pydantic import BaseModel
8
-
9
- class FieldDescription(BaseModel):
10
- """
11
- Represents a description of a field in a database schema.
12
-
13
- This class holds information about a field, including its name, ID, type,
14
- and whether it has been marked as deleted.
15
-
16
- Attributes:
17
- field_name (str): The name of the field.
18
- field_id (str): The unique identifier of the field.
19
- field_type (str): The type of the field.
20
- is_deleted (bool): Indicates whether the field is marked as deleted.
21
- """
22
- field_name: str
23
- field_id: str
24
- field_type: str
25
- is_deleted: bool
26
-
27
- def _schema_to_table_description(schema: ObjectSchema | None) -> dict[str, str]: ...
28
- def _compare_schemas(previous_scheme: dict[str, str], new_scheme: dict[str, str]) -> list[tuple[str, str, str]]: ...
29
- def _id_for_column(field_name: str, iteration: str | int) -> str: ...
30
- def _new_table_schemas(previous_scheme: ObjectSchema | None, new_scheme: ObjectSchema, iteration: int, existing_table_structure: list[FieldDescription]) -> None: ...
31
-
32
- class BaseMigrationExecutor(ABC, metaclass=abc.ABCMeta):
33
- """
34
- Abstract base class for executing migration operations on database schemas.
35
-
36
- This class provides methods for creating, updating, and deleting classes in the database schema.
37
- It also manages schema migration buffers and generates full object schemas based on the migration history.
38
- """
39
- schemas: BaseMigrationSchemas
40
- _buffer: Incomplete
41
- _non_flushable_buffer: Incomplete
42
- def __init__(self) -> None: ...
43
- def generate_full_object_schema(self, class_name: str, object_schema: ObjectSchema, buffer: list[tuple[str, ObjectSchema, SchemaTypes]]) -> list[FieldDescription]:
44
- """
45
- Generates the full object schema based on the migration history.
46
-
47
- This method constructs the full object schema for a given class by iterating through
48
- the migration history buffer and applying schema changes in sequence.
49
-
50
- Args:
51
- class_name (str): The name of the class for which the schema is being generated.
52
- object_schema (ObjectSchema): The current object schema.
53
- buffer (list[tuple[str, ObjectSchema, SchemaTypes]]): The migration history buffer.
54
-
55
- Returns:
56
- list[FieldDescription]: A list of field descriptions representing the full object schema.
57
- """
58
- @abstractmethod
59
- def create_class(self, schemas: BaseMigrationSchemas, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes) -> None: ...
60
- @abstractmethod
61
- def update_class(self, schemas: BaseMigrationSchemas, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes) -> None: ...
62
- @abstractmethod
63
- def delete_class(self, schemas: BaseMigrationSchemas, class_name: str, schema_type: SchemaTypes) -> None: ...
64
- def forward_schema(self, schemas: BaseMigrationSchemas, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes) -> None:
65
- """
66
- Forwards the schema to the non-flushable buffer.
67
-
68
- This method appends the given class name, object schema, and schema type to the
69
- non-flushable buffer for further processing.
70
-
71
- Args:
72
- schemas (BaseMigrationSchemas): The migration schemas used for the operations.
73
- class_name (str): The name of the class for which the schema is being forwarded.
74
- object_schema (ObjectSchema): The current object schema.
75
- schema_type (SchemaTypes): The type of the schema.
76
-
77
- Returns:
78
- None
79
- """
80
- @staticmethod
81
- def _resolve_base_class_name(class_name: str, meta_class: str) -> str: ...
82
- def buffer_class_migration(self, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes) -> None:
83
- """
84
- Buffers the class migration operation.
85
-
86
- This method appends the given class name, object schema, and schema type to both
87
- the non-flushable buffer and the main buffer for further processing.
88
-
89
- Args:
90
- class_name (str): The name of the class for which the migration is being buffered.
91
- object_schema (ObjectSchema): The current object schema.
92
- schema_type (SchemaTypes): The type of the schema.
93
-
94
- Returns:
95
- None
96
- """
97
- def flush_buffer(self) -> None:
98
- """
99
- Flushes the migration buffer.
100
-
101
- This method clears all entries from the main migration buffer, effectively
102
- resetting it for future migration operations.
103
-
104
- Returns:
105
- None
106
- """
107
-
108
- class AsyncBaseMigrationExecutor(BaseMigrationExecutor, metaclass=abc.ABCMeta):
109
- async def flush_buffer(self) -> None:
110
- """
111
- Flushes the migration buffer.
112
-
113
- This method clears all entries from the main migration buffer, effectively
114
- resetting it for future migration operations.
115
-
116
- Returns:
117
- None
118
- """
@@ -1,184 +0,0 @@
1
- import amsdal_glue as glue
2
- from _typeshed import Incomplete
3
- from amsdal.errors import MigrationsError as MigrationsError
4
- from amsdal.migration.base_migration_schemas import BaseMigrationSchemas as BaseMigrationSchemas
5
- from amsdal.migration.data_classes import Action as Action
6
- from amsdal.migration.executors.base import AsyncBaseMigrationExecutor as AsyncBaseMigrationExecutor, BaseMigrationExecutor as BaseMigrationExecutor
7
- from amsdal_models.classes.model import Model
8
- from amsdal_utils.models.data_models.schema import ObjectSchema
9
- from amsdal_utils.models.enums import SchemaTypes, Versions
10
- from typing import Any
11
-
12
- class DefaultMigrationExecutor(BaseMigrationExecutor):
13
- """
14
- Default implementation of the BaseMigrationExecutor for handling database schema migrations.
15
-
16
- This class provides concrete implementations for creating, updating, and deleting classes
17
- in the database schema. It also manages schema migration buffers and processes object schemas.
18
- """
19
- schemas: Incomplete
20
- _table_schemas_manager: Incomplete
21
- def __init__(self, schemas: BaseMigrationSchemas) -> None: ...
22
- def create_class(self, schemas: BaseMigrationSchemas, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes) -> None:
23
- """
24
- Creates a class in the database schema.
25
-
26
- This method registers a new class version if the schema type is `TYPE` and the class name
27
- is not `BaseClasses.OBJECT`.
28
- Otherwise, it buffers the class migration operation for further processing.
29
-
30
- Args:
31
- schemas (BaseMigrationSchemas): The migration schemas used for the operations.
32
- class_name (str): The name of the class to be created.
33
- object_schema (ObjectSchema): The schema of the object to be created.
34
- schema_type (SchemaTypes): The type of the schema.
35
-
36
- Returns:
37
- None
38
- """
39
- def update_class(self, schemas: BaseMigrationSchemas, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes) -> None:
40
- """
41
- Buffers the class update operation.
42
-
43
- This method appends the given class name, object schema, and schema type to both
44
- the non-flushable buffer and the main buffer for further processing.
45
-
46
- Args:
47
- schemas (BaseMigrationSchemas): The migration schemas used for the operations.
48
- class_name (str): The name of the class to be updated.
49
- object_schema (ObjectSchema): The current object schema.
50
- schema_type (SchemaTypes): The type of the schema.
51
-
52
- Returns:
53
- None
54
- """
55
- def delete_class(self, schemas: BaseMigrationSchemas, class_name: str, schema_type: SchemaTypes) -> None:
56
- """
57
- Deletes a class from the database schema.
58
-
59
- This method removes the specified class from the database schema and unregisters it from the migration schemas.
60
-
61
- Args:
62
- schemas (BaseMigrationSchemas): The migration schemas used for the operations.
63
- class_name (str): The name of the class to be deleted.
64
- schema_type (SchemaTypes): The type of the schema.
65
-
66
- Returns:
67
- None
68
- """
69
- def flush_buffer(self) -> None:
70
- """
71
- Flushes the migration buffer and processes the buffered classes.
72
-
73
- This method registers the buffered classes in the migration schemas, compiles the buffered classes,
74
- and processes each class in the buffer to create tables, save class objects, and migrate historical data.
75
- Finally, it clears the main migration buffer.
76
-
77
- Returns:
78
- None
79
- """
80
- def _check_class(self, schema_reference: glue.SchemaReference, object_schema: ObjectSchema, base_class: type[Model]) -> Action: ...
81
- def _save_class(self, schema_reference: glue.SchemaReference, base_class: type[Model], object_schema: ObjectSchema, action: Action) -> dict[str, Any]: ...
82
- def _save_object_class_meta(self, base_class: type[Model], object_schema: ObjectSchema, schema_type: str) -> None: ...
83
- def _create_table(self, object_schema: ObjectSchema, class_version: str | Versions, using: str | None = None) -> None: ...
84
- def _migrate_historical_data(self, schemas: BaseMigrationSchemas, class_name: str, prior_version: str, new_version: str) -> None: ...
85
- def _clean_data(self, model_class: type[Model], data: dict[str, Any]) -> dict[str, Any]: ...
86
- def _process_object_schema(self, object_schema: ObjectSchema, class_name: str, buffer: list[tuple[str, ObjectSchema, SchemaTypes]]) -> ObjectSchema: ...
87
- def register_schemas(self) -> None:
88
- """
89
- Registers the schemas in the table schemas manager.
90
-
91
- This method retrieves the object schemas from the database, processes them, and registers
92
- them in the table schemas manager. It handles both `ClassObject` and `ClassObjectMeta` schemas,
93
- and ensures that all necessary references are loaded and processed.
94
-
95
- Returns:
96
- None
97
- """
98
-
99
- class DefaultAsyncMigrationExecutor(AsyncBaseMigrationExecutor):
100
- """
101
- Default implementation of the BaseMigrationExecutor for handling database schema migrations.
102
-
103
- This class provides concrete implementations for creating, updating, and deleting classes
104
- in the database schema. It also manages schema migration buffers and processes object schemas.
105
- """
106
- schemas: Incomplete
107
- _table_schemas_manager: Incomplete
108
- def __init__(self, schemas: BaseMigrationSchemas) -> None: ...
109
- def create_class(self, schemas: BaseMigrationSchemas, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes) -> None:
110
- """
111
- Creates a class in the database schema.
112
-
113
- This method registers a new class version if the schema type is `TYPE` and the class name
114
- is not `BaseClasses.OBJECT`.
115
- Otherwise, it buffers the class migration operation for further processing.
116
-
117
- Args:
118
- schemas (BaseMigrationSchemas): The migration schemas used for the operations.
119
- class_name (str): The name of the class to be created.
120
- object_schema (ObjectSchema): The schema of the object to be created.
121
- schema_type (SchemaTypes): The type of the schema.
122
-
123
- Returns:
124
- None
125
- """
126
- def update_class(self, schemas: BaseMigrationSchemas, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes) -> None:
127
- """
128
- Buffers the class update operation.
129
-
130
- This method appends the given class name, object schema, and schema type to both
131
- the non-flushable buffer and the main buffer for further processing.
132
-
133
- Args:
134
- schemas (BaseMigrationSchemas): The migration schemas used for the operations.
135
- class_name (str): The name of the class to be updated.
136
- object_schema (ObjectSchema): The current object schema.
137
- schema_type (SchemaTypes): The type of the schema.
138
-
139
- Returns:
140
- None
141
- """
142
- async def delete_class(self, schemas: BaseMigrationSchemas, class_name: str, schema_type: SchemaTypes) -> None:
143
- """
144
- Deletes a class from the database schema.
145
-
146
- This method removes the specified class from the database schema and unregisters it from the migration schemas.
147
-
148
- Args:
149
- schemas (BaseMigrationSchemas): The migration schemas used for the operations.
150
- class_name (str): The name of the class to be deleted.
151
- schema_type (SchemaTypes): The type of the schema.
152
-
153
- Returns:
154
- None
155
- """
156
- async def flush_buffer(self) -> None:
157
- """
158
- Flushes the migration buffer and processes the buffered classes.
159
-
160
- This method registers the buffered classes in the migration schemas, compiles the buffered classes,
161
- and processes each class in the buffer to create tables, save class objects, and migrate historical data.
162
- Finally, it clears the main migration buffer.
163
-
164
- Returns:
165
- None
166
- """
167
- async def _check_class(self, schema_reference: glue.SchemaReference, object_schema: ObjectSchema, base_class: type[Model]) -> Action: ...
168
- async def _save_class(self, schema_reference: glue.SchemaReference, base_class: type[Model], object_schema: ObjectSchema, action: Action) -> dict[str, Any]: ...
169
- async def _save_object_class_meta(self, base_class: type[Model], object_schema: ObjectSchema, schema_type: SchemaTypes) -> None: ...
170
- async def _create_table(self, object_schema: ObjectSchema, class_version: str | Versions, using: str | None = None) -> None: ...
171
- async def _migrate_historical_data(self, schemas: BaseMigrationSchemas, class_name: str, prior_version: str, new_version: str) -> None: ...
172
- def _clean_data(self, model_class: type[Model], data: dict[str, Any]) -> dict[str, Any]: ...
173
- def _process_object_schema(self, object_schema: ObjectSchema, class_name: str, buffer: list[tuple[str, ObjectSchema, SchemaTypes]]) -> ObjectSchema: ...
174
- async def register_schemas(self) -> None:
175
- """
176
- Registers the schemas in the table schemas manager.
177
-
178
- This method retrieves the object schemas from the database, processes them, and registers
179
- them in the table schemas manager. It handles both `ClassObject` and `ClassObjectMeta` schemas,
180
- and ensures that all necessary references are loaded and processed.
181
-
182
- Returns:
183
- None
184
- """
@@ -1,78 +0,0 @@
1
- from _typeshed import Incomplete
2
- from amsdal.migration.base_migration_schemas import BaseMigrationSchemas as BaseMigrationSchemas
3
- from amsdal.migration.executors.base import BaseMigrationExecutor as BaseMigrationExecutor
4
- from amsdal_utils.models.data_models.schema import ObjectSchema as ObjectSchema
5
- from amsdal_utils.models.enums import SchemaTypes
6
-
7
- class StateMigrationExecutor(BaseMigrationExecutor):
8
- """
9
- Executes state migrations for database schemas.
10
-
11
- This class handles the creation, updating, and deletion of classes in the database schema,
12
- as well as flushing buffered migration operations.
13
-
14
- Attributes:
15
- schemas (BaseMigrationSchemas): The migration schemas used for the operations.
16
- do_fetch_latest_version (bool): Flag indicating whether to fetch the latest version of the schema.
17
- """
18
- schemas: Incomplete
19
- do_fetch_latest_version: Incomplete
20
- def __init__(self, schemas: BaseMigrationSchemas, *, do_fetch_latest_version: bool = True) -> None: ...
21
- def create_class(self, schemas: BaseMigrationSchemas, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes) -> None:
22
- """
23
- Creates a class in the database schema.
24
-
25
- This method registers a new class in the database schema or buffers the class migration
26
- operation based on the schema type and class name.
27
-
28
- Args:
29
- schemas (BaseMigrationSchemas): The migration schemas used for the operations.
30
- class_name (str): The name of the class to be created.
31
- object_schema (ObjectSchema): The current object schema.
32
- schema_type (SchemaTypes): The type of the schema.
33
-
34
- Returns:
35
- None
36
- """
37
- def update_class(self, schemas: BaseMigrationSchemas, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes) -> None:
38
- """
39
- Buffers the class update operation.
40
-
41
- This method adds the class update operation to the migration buffer, which will be processed
42
- when the buffer is flushed.
43
-
44
- Args:
45
- schemas (BaseMigrationSchemas): The migration schemas used for the operations.
46
- class_name (str): The name of the class to be updated.
47
- object_schema (ObjectSchema): The current object schema.
48
- schema_type (SchemaTypes): The type of the schema.
49
-
50
- Returns:
51
- None
52
- """
53
- def delete_class(self, schemas: BaseMigrationSchemas, class_name: str, schema_type: SchemaTypes) -> None:
54
- """
55
- Deletes a class from the database schema.
56
-
57
- This method unregisters a class from the database schema based on the provided class name
58
- and schema type.
59
-
60
- Args:
61
- schemas (BaseMigrationSchemas): The migration schemas used for the operations.
62
- class_name (str): The name of the class to be deleted.
63
- schema_type (SchemaTypes): The type of the schema.
64
-
65
- Returns:
66
- None
67
- """
68
- def flush_buffer(self) -> None:
69
- """
70
- Flushes the migration buffer and processes the buffered classes.
71
-
72
- This method registers all classes in the migration buffer to the database schema and compiles
73
- the buffered classes. If the `do_fetch_latest_version` flag is set, it also fetches and registers
74
- the latest version of each class.
75
-
76
- Returns:
77
- None
78
- """
@@ -1,68 +0,0 @@
1
- from _typeshed import Incomplete
2
- from amsdal.configs.constants import CORE_MIGRATIONS_PATH as CORE_MIGRATIONS_PATH
3
- from amsdal.configs.main import settings as settings
4
- from amsdal.migration.data_classes import MigrationDirection as MigrationDirection, MigrationFile as MigrationFile, MigrationResult as MigrationResult, ModuleTypes as ModuleTypes
5
- from amsdal.migration.executors.base import BaseMigrationExecutor as BaseMigrationExecutor
6
- from amsdal.migration.executors.state_executor import StateMigrationExecutor as StateMigrationExecutor
7
- from amsdal.migration.file_migration_store import BaseMigrationStore as BaseMigrationStore, FileMigrationStore as FileMigrationStore
8
- from amsdal.migration.migrations import MigrateData as MigrateData, Migration as Migration
9
- from amsdal.migration.migrations_loader import MigrationsLoader as MigrationsLoader
10
- from amsdal.migration.utils import contrib_to_module_root_path as contrib_to_module_root_path
11
- from amsdal_utils.models.data_models.address import Address
12
- from amsdal_utils.models.enums import SchemaTypes
13
-
14
- logger: Incomplete
15
-
16
- class FileMigrationExecutorManager:
17
- """
18
- Manager class for executing file migrations.
19
-
20
- Attributes:
21
- migration_address (Address): The address associated with the migration.
22
- core_loader (MigrationsLoader): Loader for core migrations.
23
- contrib_loaders (list[MigrationsLoader]): List of loaders for contributed migrations.
24
- app_loader (MigrationsLoader): Loader for application migrations.
25
- executor (BaseMigrationExecutor): The executor responsible for running migrations.
26
- store (BaseMigrationStore): The store for managing migration files.
27
- """
28
- migration_address: Address
29
- core_loader: Incomplete
30
- contrib_loaders: Incomplete
31
- app_loader: Incomplete
32
- executor: Incomplete
33
- _applied_migration_files: Incomplete
34
- store: Incomplete
35
- def __init__(self, app_migrations_loader: MigrationsLoader, executor: BaseMigrationExecutor, store: BaseMigrationStore | None = None) -> None: ...
36
- def execute(self, migration_number: int | None = None, module_type: ModuleTypes | None = None, *, fake: bool = False, skip_data_migrations: bool = False) -> list[MigrationResult]:
37
- """
38
- Executes the migrations.
39
-
40
- Args:
41
- migration_number (int | None): The migration number to execute up to. Defaults to None.
42
- module_type (ModuleTypes | None): The type of module to migrate. Defaults to None.
43
- fake (bool): If True, simulates the migration without applying changes. Defaults to False.
44
- skip_data_migrations (bool): If True, skips data migrations. Defaults to False.
45
-
46
- Returns:
47
- list[MigrationResult]: List of results from the migration execution.
48
- """
49
- @staticmethod
50
- def _get_contrib_loaders() -> list[MigrationsLoader]: ...
51
- def _apply(self, migration_number: int | None = None, module_type: ModuleTypes | None = None, *, fake: bool = False, skip_data_migrations: bool = False) -> list[MigrationResult]: ...
52
- def _apply_migrations(self, loader: MigrationsLoader, module_type: ModuleTypes, migration_number: int | None = None, *, fake: bool = False, skip_data_migrations: bool = False) -> list[MigrationResult]: ...
53
- def _register_schemas(self, executor: BaseMigrationExecutor) -> None: ...
54
- def _init_state_from_applied_migrations(self, migrations: list[MigrationFile], module_type: ModuleTypes) -> None: ...
55
- @staticmethod
56
- def get_migration_class(migration: MigrationFile) -> type['Migration']:
57
- """
58
- Retrieves the migration class from the migration file.
59
-
60
- Args:
61
- migration (MigrationFile): The migration file.
62
-
63
- Returns:
64
- type[Migration]: The migration class.
65
- """
66
- def _is_migration_applied(self, migration: MigrationFile, module_type: ModuleTypes) -> bool: ...
67
- @staticmethod
68
- def _map_module_type_to_schema_type(module_type: ModuleTypes) -> SchemaTypes: ...
@@ -1,139 +0,0 @@
1
- from _typeshed import Incomplete
2
- from amsdal.configs.main import settings as settings
3
- from amsdal.migration.base_migration_schemas import BaseMigrationSchemas as BaseMigrationSchemas
4
- from amsdal.migration.data_classes import MigrateOperation as MigrateOperation, MigrationFile as MigrationFile, ModuleTypes as ModuleTypes, OperationTypes as OperationTypes
5
- from amsdal.migration.executors.state_executor import StateMigrationExecutor as StateMigrationExecutor
6
- from amsdal.migration.file_migration_executor import FileMigrationExecutorManager as FileMigrationExecutorManager
7
- from amsdal.migration.file_migration_store import BaseMigrationStore as BaseMigrationStore
8
- from amsdal.migration.file_migration_writer import FileMigrationWriter as FileMigrationWriter
9
- from amsdal.migration.migrations_loader import MigrationsLoader as MigrationsLoader
10
- from amsdal.migration.schemas_loaders import BaseClassSchemaLoader as BaseClassSchemaLoader
11
- from amsdal_utils.models.data_models.schema import ObjectSchema as ObjectSchema
12
- from amsdal_utils.models.enums import SchemaTypes, Versions
13
- from collections.abc import Callable as Callable
14
- from pathlib import Path
15
- from typing import ClassVar
16
-
17
- class StateMigrationStore(BaseMigrationStore):
18
- def save_migration(self, migration: MigrationFile) -> None: ...
19
- def delete_migration(self, migration: MigrationFile) -> None: ...
20
- def fetch_migrations(self) -> list[MigrationFile]: ...
21
-
22
- class StateMigrationSchemas(BaseMigrationSchemas):
23
- """
24
- Manages the state of migration schemas.
25
-
26
- Attributes:
27
- state (dict[str, tuple[SchemaTypes, ObjectSchema]]): A dictionary mapping class names to their schema types
28
- and object schemas.
29
- """
30
- state: Incomplete
31
- def __init__(self) -> None: ...
32
- def register_model(self, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes, class_version: str | Versions = ...) -> None:
33
- """
34
- Registers a model with the given class name, object schema, and schema type.
35
-
36
- Args:
37
- class_name (str): The name of the class to register.
38
- object_schema (ObjectSchema): The object schema of the class.
39
- schema_type (SchemaTypes): The type of schema.
40
-
41
- Returns:
42
- None
43
- """
44
- def unregister_model(self, class_name: str) -> None:
45
- """
46
- Unregisters a model with the given class name.
47
-
48
- Args:
49
- class_name (str): The name of the class to unregister.
50
-
51
- Returns:
52
- None
53
- """
54
- def compile_buffered_classes(self) -> None: ...
55
-
56
- class FileMigrationGenerator:
57
- """
58
- Generates migration files based on schema changes.
59
- """
60
- _operations: ClassVar[dict[OperationTypes, Callable[..., MigrateOperation]]]
61
- _app_migrations_path: Incomplete
62
- _app_migrations_loader: Incomplete
63
- _schema_loader: Incomplete
64
- _state: Incomplete
65
- def __init__(self, schema_loader: BaseClassSchemaLoader, app_migrations_path: Path | None = None) -> None: ...
66
- def make_migrations(self, name: str | None = None, *, is_data: bool = False, schema_type: SchemaTypes = ...) -> MigrationFile:
67
- """
68
- Creates migration files based on schema changes.
69
-
70
- Args:
71
- name (str | None): The name of the migration. Defaults to None.
72
- is_data (bool): If True, creates a data migration. Defaults to False.
73
- schema_type (SchemaTypes): The type of schema. Defaults to SchemaTypes.USER.
74
-
75
- Returns:
76
- MigrationFile: The created migration file.
77
-
78
- Raises:
79
- UserWarning: If no changes are detected.
80
- """
81
- def generate_operations(self, schema_type: SchemaTypes) -> list[MigrateOperation]:
82
- """
83
- Generates migration operations based on schema changes.
84
-
85
- Args:
86
- schema_type (SchemaTypes): The type of schema.
87
-
88
- Returns:
89
- list[MigrateOperation]: List of migration operations.
90
- """
91
- def _make_data_migrations(self, name: str | None = None) -> MigrationFile: ...
92
- def _init_state(self) -> None: ...
93
- @classmethod
94
- def build_operations(cls, schema_type: SchemaTypes, class_schema: ObjectSchema, old_class_schema: ObjectSchema | None) -> list[MigrateOperation]:
95
- """
96
- Builds migration operations based on schema changes.
97
-
98
- Args:
99
- schema_type (SchemaTypes): The type of schema.
100
- class_schema (ObjectSchema): The new class schema.
101
- old_class_schema (ObjectSchema | None): The old class schema. Defaults to None.
102
-
103
- Returns:
104
- list[MigrateOperation]: List of migration operations.
105
- """
106
- def write_migration_file(self, operations: list[MigrateOperation], name: str | None = None) -> MigrationFile:
107
- """
108
- Writes migration operations to a file.
109
-
110
- Args:
111
- operations (list[MigrateOperation]): List of migration operations.
112
- name (str | None): The name of the migration. Defaults to None.
113
-
114
- Returns:
115
- MigrationFile: The created migration file.
116
- """
117
- def write_data_migration_file(self, name: str | None = None) -> MigrationFile:
118
- """
119
- Writes data migration operations to a file.
120
-
121
- Args:
122
- name (str | None): The name of the migration. Defaults to None.
123
-
124
- Returns:
125
- MigrationFile: The created data migration file.
126
- """
127
- @staticmethod
128
- def generate_name_from_operations(operations: list[MigrateOperation]) -> str:
129
- """
130
- Generates a name for the migration file based on operations.
131
-
132
- Args:
133
- operations (list[MigrateOperation]): List of migration operations.
134
-
135
- Returns:
136
- str: The generated name.
137
- """
138
- @staticmethod
139
- def _get_migration_file_name(number: int, name: str) -> str: ...
@@ -1,61 +0,0 @@
1
- import abc
2
- from _typeshed import Incomplete
3
- from abc import ABC, abstractmethod
4
- from amsdal.configs.main import settings as settings
5
- from amsdal.migration.data_classes import MigrationFile as MigrationFile, ModuleTypes as ModuleTypes
6
- from amsdal.migration.utils import contrib_to_module_root_path as contrib_to_module_root_path, map_module_type_to_schema_type as map_module_type_to_schema_type
7
- from amsdal_utils.models.data_models.address import Address
8
- from typing import Any, ClassVar
9
-
10
- class BaseMigrationStore(ABC, metaclass=abc.ABCMeta):
11
- @abstractmethod
12
- def fetch_migrations(self) -> list[MigrationFile]: ...
13
- @abstractmethod
14
- def save_migration(self, migration: MigrationFile) -> None: ...
15
- @abstractmethod
16
- def delete_migration(self, migration: MigrationFile) -> None: ...
17
-
18
- class FileMigrationStore(BaseMigrationStore):
19
- """
20
- Manages the storage and retrieval of migration files.
21
-
22
- Attributes:
23
- migration_address (Address): The address associated with the migration.
24
- """
25
- MIGRATION_TABLE: ClassVar[str]
26
- migration_address: Address
27
- _operation_manager: Incomplete
28
- def __init__(self) -> None: ...
29
- def fetch_migrations(self) -> list[MigrationFile]:
30
- """
31
- Fetches the list of applied migrations.
32
-
33
- Returns:
34
- list[MigrationFile]: List of applied migration files.
35
- """
36
- def save_migration(self, migration: MigrationFile) -> None:
37
- """
38
- Saves a migration file.
39
-
40
- Args:
41
- migration (MigrationFile): The migration file to save.
42
-
43
- Returns:
44
- None
45
- """
46
- def delete_migration(self, migration: MigrationFile) -> None:
47
- """
48
- Deletes a migration file.
49
-
50
- Args:
51
- migration (MigrationFile): The migration file to delete.
52
-
53
- Returns:
54
- None
55
- """
56
- def _save_historical_data(self, address: Address, data: dict[str, Any], metadata: dict[str, Any]) -> None: ...
57
- @staticmethod
58
- def _build_migration_data(migration: MigrationFile) -> dict[str, Any]: ...
59
- @classmethod
60
- def _build_migration_metadata(cls, migration: MigrationFile, object_id: str | None = None) -> tuple[Address, dict[str, Any]]: ...
61
- def _init_migration_table(self) -> None: ...