amsdal 0.0.41__cp311-cp311-macosx_10_9_universal2.whl → 0.1.1__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.

Potentially problematic release.


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

Files changed (99) hide show
  1. amsdal/__about__.py +1 -1
  2. amsdal/__migrations__/0000_initial.py +203 -0
  3. amsdal/cloud/__init__.cpython-311-darwin.so +0 -0
  4. amsdal/cloud/client.cpython-311-darwin.so +0 -0
  5. amsdal/cloud/constants.cpython-311-darwin.so +0 -0
  6. amsdal/cloud/enums.cpython-311-darwin.so +0 -0
  7. amsdal/cloud/models/__init__.cpython-311-darwin.so +0 -0
  8. amsdal/cloud/models/base.cpython-311-darwin.so +0 -0
  9. amsdal/cloud/services/__init__.cpython-311-darwin.so +0 -0
  10. amsdal/cloud/services/actions/__init__.cpython-311-darwin.so +0 -0
  11. amsdal/cloud/services/actions/add_dependency.cpython-311-darwin.so +0 -0
  12. amsdal/cloud/services/actions/add_secret.cpython-311-darwin.so +0 -0
  13. amsdal/cloud/services/actions/base.cpython-311-darwin.so +0 -0
  14. amsdal/cloud/services/actions/create_deploy.cpython-311-darwin.so +0 -0
  15. amsdal/cloud/services/actions/create_session.cpython-311-darwin.so +0 -0
  16. amsdal/cloud/services/actions/delete_dependency.cpython-311-darwin.so +0 -0
  17. amsdal/cloud/services/actions/delete_secret.cpython-311-darwin.so +0 -0
  18. amsdal/cloud/services/actions/destroy_deploy.cpython-311-darwin.so +0 -0
  19. amsdal/cloud/services/actions/expose_db.cpython-311-darwin.so +0 -0
  20. amsdal/cloud/services/actions/list_dependencies.cpython-311-darwin.so +0 -0
  21. amsdal/cloud/services/actions/list_deploys.cpython-311-darwin.so +0 -0
  22. amsdal/cloud/services/actions/list_secrets.cpython-311-darwin.so +0 -0
  23. amsdal/cloud/services/actions/manager.cpython-311-darwin.so +0 -0
  24. amsdal/cloud/services/actions/signup_action.cpython-311-darwin.so +0 -0
  25. amsdal/cloud/services/actions/update_deploy.cpython-311-darwin.so +0 -0
  26. amsdal/cloud/services/auth/__init__.cpython-311-darwin.so +0 -0
  27. amsdal/cloud/services/auth/base.cpython-311-darwin.so +0 -0
  28. amsdal/cloud/services/auth/credentials.cpython-311-darwin.so +0 -0
  29. amsdal/cloud/services/auth/manager.cpython-311-darwin.so +0 -0
  30. amsdal/cloud/services/auth/signup_service.cpython-311-darwin.so +0 -0
  31. amsdal/cloud/services/auth/token.cpython-311-darwin.so +0 -0
  32. amsdal/configs/constants.py +2 -0
  33. amsdal/configs/constants.pyi +1 -0
  34. amsdal/configs/main.py +6 -0
  35. amsdal/configs/main.pyi +3 -0
  36. amsdal/contrib/__init__.cpython-311-darwin.so +0 -0
  37. amsdal/contrib/auth/migrations/0000_initial.py +49 -0
  38. amsdal/contrib/frontend_configs/migrations/0000_initial.py +255 -0
  39. amsdal/fixtures/__init__.cpython-311-darwin.so +0 -0
  40. amsdal/fixtures/manager.cpython-311-darwin.so +0 -0
  41. amsdal/manager.cpython-311-darwin.so +0 -0
  42. amsdal/manager.pyi +9 -3
  43. amsdal/migration/__init__.cpython-311-darwin.so +0 -0
  44. amsdal/migration/base_migration_schemas.cpython-311-darwin.so +0 -0
  45. amsdal/migration/base_migration_schemas.pyi +44 -0
  46. amsdal/migration/data_classes.cpython-311-darwin.so +0 -0
  47. amsdal/migration/data_classes.pyi +78 -0
  48. amsdal/migration/executors/__init__.cpython-311-darwin.so +0 -0
  49. amsdal/migration/executors/base.cpython-311-darwin.so +0 -0
  50. amsdal/migration/executors/base.pyi +21 -0
  51. amsdal/migration/executors/default_executor.cpython-311-darwin.so +0 -0
  52. amsdal/migration/executors/default_executor.pyi +20 -0
  53. amsdal/migration/executors/state_executor.cpython-311-darwin.so +0 -0
  54. amsdal/migration/executors/state_executor.pyi +14 -0
  55. amsdal/migration/file_migration_executor.cpython-311-darwin.so +0 -0
  56. amsdal/migration/file_migration_executor.pyi +35 -0
  57. amsdal/migration/file_migration_generator.cpython-311-darwin.so +0 -0
  58. amsdal/migration/file_migration_generator.pyi +49 -0
  59. amsdal/migration/file_migration_store.cpython-311-darwin.so +0 -0
  60. amsdal/migration/file_migration_store.pyi +33 -0
  61. amsdal/migration/file_migration_writer.cpython-311-darwin.so +0 -0
  62. amsdal/migration/file_migration_writer.pyi +18 -0
  63. amsdal/migration/migrations.cpython-311-darwin.so +0 -0
  64. amsdal/migration/migrations.pyi +57 -0
  65. amsdal/migration/migrations_loader.cpython-311-darwin.so +0 -0
  66. amsdal/migration/migrations_loader.pyi +17 -0
  67. amsdal/migration/schemas_loaders.cpython-311-darwin.so +0 -0
  68. amsdal/migration/schemas_loaders.pyi +24 -0
  69. amsdal/migration/utils.cpython-311-darwin.so +0 -0
  70. amsdal/migration/utils.pyi +5 -0
  71. amsdal/mixins/__init__.cpython-311-darwin.so +0 -0
  72. amsdal/mixins/build_mixin.cpython-311-darwin.so +0 -0
  73. amsdal/mixins/build_mixin.pyi +2 -0
  74. amsdal/mixins/class_versions_mixin.cpython-311-darwin.so +0 -0
  75. amsdal/mixins/class_versions_mixin.pyi +1 -1
  76. amsdal/operations/__init__.cpython-311-darwin.so +0 -0
  77. amsdal/operations/manager.cpython-311-darwin.so +0 -0
  78. amsdal/operations/manager.pyi +3 -1
  79. amsdal/schemas/core/class_object/model.json +5 -58
  80. amsdal/schemas/core/class_object_meta/model.json +55 -0
  81. amsdal/schemas/core/class_property/model.json +0 -19
  82. amsdal/schemas/core/class_property_meta/model.json +23 -0
  83. amsdal/schemas/manager.cpython-311-darwin.so +0 -0
  84. amsdal/schemas/manager.py +15 -4
  85. amsdal/schemas/manager.pyi +2 -0
  86. amsdal/schemas/types/object/model.json +12 -2
  87. amsdal/services/__init__.cpython-311-darwin.so +0 -0
  88. amsdal/services/transaction_execution.cpython-311-darwin.so +0 -0
  89. {amsdal-0.0.41.dist-info → amsdal-0.1.1.dist-info}/METADATA +14 -14
  90. {amsdal-0.0.41.dist-info → amsdal-0.1.1.dist-info}/RECORD +94 -69
  91. amsdal/contrib/auth/models/__init__.py +0 -0
  92. amsdal/contrib/frontend_configs/models/__init__.py +0 -0
  93. amsdal/contrib/frontend_configs/models/__init__.pyi +0 -0
  94. amsdal/migration/manager.cpython-311-darwin.so +0 -0
  95. amsdal/migration/manager.pyi +0 -20
  96. /amsdal/{contrib/auth/models → migration/executors}/__init__.pyi +0 -0
  97. {amsdal-0.0.41.dist-info → amsdal-0.1.1.dist-info}/LICENSE.txt +0 -0
  98. {amsdal-0.0.41.dist-info → amsdal-0.1.1.dist-info}/WHEEL +0 -0
  99. {amsdal-0.0.41.dist-info → amsdal-0.1.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,255 @@
1
+ from amsdal_utils.models.enums import SchemaTypes
2
+
3
+ from amsdal.migration import migrations
4
+
5
+
6
+ class Migration(migrations.Migration):
7
+ operations: list[migrations.Operation] = [
8
+ migrations.CreateClass(
9
+ schema_type=SchemaTypes.CONTRIB,
10
+ class_name='FrontendConfigSkipNoneBase',
11
+ new_schema={
12
+ 'title': 'FrontendConfigSkipNoneBase',
13
+ 'properties': {},
14
+ 'meta_class': 'TypeMeta',
15
+ 'custom_code': "from typing import Any\n\n\ndef model_dump(self, **kwargs: Any) -> dict[str, Any]: # type: ignore[no-untyped-def] # noqa: ARG001\n kwargs['exclude_none'] = True\n\n return super().model_dump(**kwargs) # type: ignore[misc]\n\n\ndef model_dump_json(self, **kwargs: Any) -> str: # type: ignore[no-untyped-def] # noqa: ARG001\n kwargs['exclude_none'] = True\n\n return super().model_dump_json(**kwargs) # type: ignore[misc]",
16
+ },
17
+ ),
18
+ migrations.CreateClass(
19
+ schema_type=SchemaTypes.CONTRIB,
20
+ class_name='FrontendConfigGroupValidator',
21
+ new_schema={
22
+ 'title': 'FrontendConfigGroupValidator',
23
+ 'type': 'FrontendConfigSkipNoneBase',
24
+ 'properties': {
25
+ 'mainControl': {'type': 'string', 'title': 'Main Control'},
26
+ 'dependentControls': {'type': 'array', 'items': {'type': 'string'}, 'title': 'Dependent Controls'},
27
+ 'condition': {
28
+ 'type': 'string',
29
+ 'title': 'Condition',
30
+ 'options': [
31
+ {'key': 'Less Than', 'value': 'lt'},
32
+ {'key': 'Less Than or Equal', 'value': 'lte'},
33
+ {'key': 'Greater Than', 'value': 'gt'},
34
+ {'key': 'Greater Than or Equal', 'value': 'gte'},
35
+ {'key': 'Equal', 'value': 'eq'},
36
+ {'key': 'Not Equal', 'value': 'neq'},
37
+ {'key': 'Exist', 'value': 'exist'},
38
+ ],
39
+ },
40
+ },
41
+ 'meta_class': 'TypeMeta',
42
+ },
43
+ ),
44
+ migrations.CreateClass(
45
+ schema_type=SchemaTypes.CONTRIB,
46
+ class_name='FrontendActivatorConfig',
47
+ new_schema={
48
+ 'title': 'FrontendActivatorConfig',
49
+ 'type': 'FrontendConfigGroupValidator',
50
+ 'properties': {'value': {'type': 'anything', 'title': 'Value'}},
51
+ 'meta_class': 'TypeMeta',
52
+ },
53
+ ),
54
+ migrations.CreateClass(
55
+ schema_type=SchemaTypes.CONTRIB,
56
+ class_name='FrontendConfigTextMask',
57
+ new_schema={
58
+ 'title': 'FrontendConfigTextMask',
59
+ 'type': 'FrontendConfigSkipNoneBase',
60
+ 'required': ['mask_string'],
61
+ 'properties': {
62
+ 'mask_string': {'type': 'string', 'title': 'Mask String'},
63
+ 'prefix': {'type': 'string', 'title': 'Prefix'},
64
+ 'suffix': {'type': 'string', 'title': 'Suffix'},
65
+ 'thousands_separator': {'type': 'string', 'title': 'Thousands Separator'},
66
+ },
67
+ 'meta_class': 'TypeMeta',
68
+ },
69
+ ),
70
+ migrations.CreateClass(
71
+ schema_type=SchemaTypes.CONTRIB,
72
+ class_name='FrontendConfigSliderOption',
73
+ new_schema={
74
+ 'title': 'FrontendConfigSliderOption',
75
+ 'type': 'FrontendConfigSkipNoneBase',
76
+ 'properties': {
77
+ 'min': {'type': 'number', 'title': 'Minimum'},
78
+ 'max': {'type': 'number', 'title': 'Maximum'},
79
+ 'range': {'type': 'boolean', 'title': 'Range'},
80
+ },
81
+ 'meta_class': 'TypeMeta',
82
+ },
83
+ ),
84
+ migrations.CreateClass(
85
+ schema_type=SchemaTypes.CONTRIB,
86
+ class_name='FrontendConfigValidator',
87
+ new_schema={
88
+ 'title': 'FrontendConfigValidator',
89
+ 'type': 'FrontendConfigGroupValidator',
90
+ 'properties': {
91
+ 'function': {
92
+ 'type': 'string',
93
+ 'title': 'Function',
94
+ 'options': [
95
+ {'key': 'Minimum', 'value': 'min'},
96
+ {'key': 'Maximum', 'value': 'max'},
97
+ {'key': 'Minimum Length', 'value': 'minLength'},
98
+ {'key': 'Maximum Length', 'value': 'maxLength'},
99
+ {'key': 'Required', 'value': 'required'},
100
+ {'key': 'Pattern', 'value': 'pattern'},
101
+ ],
102
+ },
103
+ 'value': {'type': 'string', 'title': 'Value'},
104
+ },
105
+ 'meta_class': 'TypeMeta',
106
+ },
107
+ ),
108
+ migrations.CreateClass(
109
+ schema_type=SchemaTypes.CONTRIB,
110
+ class_name='FrontendConfigAsyncValidator',
111
+ new_schema={
112
+ 'title': 'FrontendConfigAsyncValidator',
113
+ 'type': 'FrontendConfigSkipNoneBase',
114
+ 'properties': {'endpoint': {'type': 'string', 'title': 'Endpoint'}},
115
+ 'meta_class': 'TypeMeta',
116
+ },
117
+ ),
118
+ migrations.CreateClass(
119
+ schema_type=SchemaTypes.CONTRIB,
120
+ class_name='FrontendConfigControlAction',
121
+ new_schema={
122
+ 'title': 'FrontendConfigControlAction',
123
+ 'type': 'FrontendConfigSkipNoneBase',
124
+ 'required': ['action', 'text', 'type'],
125
+ 'properties': {
126
+ 'action': {'type': 'string', 'title': 'Action'},
127
+ 'text': {'type': 'string', 'title': 'Text'},
128
+ 'type': {
129
+ 'type': 'string',
130
+ 'title': 'Type',
131
+ 'options': [
132
+ {'key': 'Arrow Next', 'value': 'arrow-next'},
133
+ {'key': 'Arrow Prev', 'value': 'arrow-prev'},
134
+ {'key': 'Action Button', 'value': 'action-button'},
135
+ {'key': 'Text Next', 'value': 'text-next'},
136
+ {'key': 'Text Prev', 'value': 'text-prev'},
137
+ ],
138
+ },
139
+ 'dataLayerEvent': {'type': 'string', 'title': 'Data Layer Event'},
140
+ 'activator': {'type': 'string', 'title': 'Activator'},
141
+ 'icon': {'type': 'string', 'title': 'Icon'},
142
+ },
143
+ 'meta_class': 'TypeMeta',
144
+ 'custom_code': "from pydantic import field_validator\n\n\n@field_validator('action', mode='after') # type: ignore[misc]\n@classmethod\ndef validate_action(cls, v: str) -> str: # type: ignore[no-untyped-def] # noqa: ARG001\n if not v.startswith('navigate::') and v not in [\n 'goPrev',\n 'goNext',\n 'goNextWithSubmit',\n 'submit',\n 'submitWithDataLayer',\n ]:\n msg = 'Action must be one of: goPrev, goNext, goNextWithSubmit, submit, submitWithDataLayer, navigate::{string}'\n raise ValueError(msg)\n\n return v",
145
+ },
146
+ ),
147
+ migrations.CreateClass(
148
+ schema_type=SchemaTypes.CONTRIB,
149
+ class_name='FrontendConfigOption',
150
+ new_schema={
151
+ 'title': 'FrontendConfigOption',
152
+ 'type': 'FrontendConfigSkipNoneBase',
153
+ 'properties': {
154
+ 'label': {'type': 'string', 'title': 'Label'},
155
+ 'value': {'type': 'string', 'title': 'Value'},
156
+ },
157
+ 'meta_class': 'TypeMeta',
158
+ },
159
+ ),
160
+ migrations.CreateClass(
161
+ schema_type=SchemaTypes.CONTRIB,
162
+ class_name='FrontendControlConfig',
163
+ new_schema={
164
+ 'title': 'FrontendControlConfig',
165
+ 'type': 'FrontendConfigSkipNoneBase',
166
+ 'required': ['type', 'name'],
167
+ 'properties': {
168
+ 'type': {
169
+ 'type': 'string',
170
+ 'title': 'Type',
171
+ 'options': [
172
+ {'key': 'Infoscreen', 'value': 'infoscreen'},
173
+ {'key': 'Info Group', 'value': 'info-group'},
174
+ {'key': 'Text', 'value': 'text'},
175
+ {'key': 'Number', 'value': 'number'},
176
+ {'key': 'Select', 'value': 'select'},
177
+ {'key': 'Object Group', 'value': 'object_group'},
178
+ {'key': 'Group', 'value': 'group'},
179
+ {'key': 'Group Toggle', 'value': 'group_toggle'},
180
+ {'key': 'Group Switch', 'value': 'group_switch'},
181
+ {'key': 'Password', 'value': 'password'},
182
+ {'key': 'Email', 'value': 'email'},
183
+ {'key': 'Phone', 'value': 'phone'},
184
+ {'key': 'textarea', 'value': 'textarea'},
185
+ {'key': 'Multiselect', 'value': 'multiselect'},
186
+ {'key': 'number_initial', 'value': 'number_initial'},
187
+ {'key': 'number_plus', 'value': 'number_plus'},
188
+ {'key': 'number_minus', 'value': 'number_minus'},
189
+ {'key': 'number_equals', 'value': 'number_equals'},
190
+ {'key': 'toggle', 'value': 'toggle'},
191
+ {'key': 'radio', 'value': 'radio'},
192
+ {'key': 'checkbox', 'value': 'checkbox'},
193
+ {'key': 'number-slider', 'value': 'number-slider'},
194
+ {'key': 'number-operations', 'value': 'number-operations'},
195
+ {'key': 'date', 'value': 'date'},
196
+ {'key': 'dateTriplet', 'value': 'dateTriplet'},
197
+ {'key': 'array', 'value': 'array'},
198
+ {'key': 'object', 'value': 'object'},
199
+ {'key': 'file', 'value': 'file'},
200
+ {'key': 'dropzone', 'value': 'dropzone'},
201
+ {'key': 'object_latest', 'value': 'object_latest'},
202
+ {'key': 'Dictionary', 'value': 'dict'},
203
+ {'key': 'Time', 'value': 'time'},
204
+ {'key': 'Datetime', 'value': 'datetime'},
205
+ {'key': 'Bytes', 'value': 'Bytes'},
206
+ ],
207
+ },
208
+ 'name': {'type': 'string', 'title': 'Name'},
209
+ 'label': {'type': 'string', 'title': 'Label'},
210
+ 'required': {'type': 'boolean', 'title': 'Required'},
211
+ 'hideLabel': {'type': 'boolean', 'title': 'Hide Label'},
212
+ 'actions': {'type': 'array', 'items': {'type': 'FrontendConfigControlAction'}, 'title': 'Actions'},
213
+ 'validators': {
214
+ 'type': 'array',
215
+ 'items': {'type': 'FrontendConfigValidator'},
216
+ 'title': 'Validators',
217
+ },
218
+ 'asyncValidators': {
219
+ 'type': 'array',
220
+ 'items': {'type': 'FrontendConfigAsyncValidator'},
221
+ 'title': 'Async Validators',
222
+ },
223
+ 'activators': {
224
+ 'type': 'array',
225
+ 'items': {'type': 'FrontendActivatorConfig'},
226
+ 'title': 'Activators',
227
+ },
228
+ 'additionalText': {'type': 'string', 'title': 'Additional Text'},
229
+ 'value': {'type': 'anything', 'title': 'Value'},
230
+ 'placeholder': {'type': 'string', 'title': 'Placeholder'},
231
+ 'options': {'type': 'array', 'items': {'type': 'FrontendConfigOption'}, 'title': 'Options'},
232
+ 'mask': {'type': 'FrontendConfigTextMask', 'title': 'Mask'},
233
+ 'controls': {'type': 'array', 'items': {'type': 'FrontendControlConfig'}, 'title': 'Controls'},
234
+ 'showSearch': {'type': 'boolean', 'title': 'Show Search'},
235
+ 'sliderOptions': {'type': 'FrontendConfigSliderOption', 'title': 'Slider Option'},
236
+ 'customLabel': {'type': 'array', 'items': {'type': 'string'}, 'title': 'Custom Label'},
237
+ 'control': {'type': 'FrontendControlConfig', 'title': 'Control'},
238
+ 'entityType': {'type': 'string', 'title': 'Entity Type'},
239
+ },
240
+ 'meta_class': 'TypeMeta',
241
+ },
242
+ ),
243
+ migrations.CreateClass(
244
+ schema_type=SchemaTypes.CONTRIB,
245
+ class_name='FrontendModelConfig',
246
+ new_schema={
247
+ 'title': 'FrontendModelConfig',
248
+ 'required': ['class_name'],
249
+ 'properties': {
250
+ 'class_name': {'type': 'string', 'title': 'Class Name'},
251
+ 'control': {'type': 'FrontendControlConfig', 'title': 'Control'},
252
+ },
253
+ },
254
+ ),
255
+ ]
Binary file
amsdal/manager.pyi CHANGED
@@ -5,7 +5,6 @@ from amsdal.cloud.services.auth.signup_service import SignupService as SignupSer
5
5
  from amsdal.configs.main import settings as settings
6
6
  from amsdal.errors import AmsdalAuthenticationError as AmsdalAuthenticationError, AmsdalMissingCredentialsError as AmsdalMissingCredentialsError, AmsdalRuntimeError as AmsdalRuntimeError, AmsdalSignupError as AmsdalSignupError
7
7
  from amsdal.fixtures.manager import FixturesManager as FixturesManager
8
- from amsdal.migration.manager import MigrationManager as MigrationManager
9
8
  from amsdal.mixins.build_mixin import BuildMixin as BuildMixin
10
9
  from amsdal.mixins.class_versions_mixin import ClassVersionsMixin as ClassVersionsMixin
11
10
  from amsdal.operations.manager import OperationsManager as OperationsManager
@@ -31,6 +30,8 @@ class AmsdalManager(BuildMixin, ClassVersionsMixin, metaclass=Singleton):
31
30
  Initializes all sub managers. Reads the configuration.
32
31
  """
33
32
  @property
33
+ def is_setup(self) -> bool: ...
34
+ @property
34
35
  def is_authenticated(self) -> bool:
35
36
  """
36
37
  Indicates if you have passed the AMSDAL license authentication process.
@@ -43,7 +44,7 @@ class AmsdalManager(BuildMixin, ClassVersionsMixin, metaclass=Singleton):
43
44
  """
44
45
  Initiates models root path and the connections
45
46
  """
46
- def build(self, source_models_path: Path, source_transactions_path: Path, source_static_files_path: Path, source_fixtures_path: Path) -> None:
47
+ 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:
47
48
  """
48
49
  Build method
49
50
 
@@ -51,6 +52,7 @@ class AmsdalManager(BuildMixin, ClassVersionsMixin, metaclass=Singleton):
51
52
  :param source_transactions_path: Path to the directory where the source transactions are located.
52
53
  :param source_static_files_path: Path to the directory where the source static files are located.
53
54
  :param source_fixtures_path: Path to the directory where the source fixtures are located.
55
+ :param source_migrations_path: Path to the directory where the source migrations are located.
54
56
  :return: None
55
57
 
56
58
  This method is used to build the necessary components for the Amsdal framework.
@@ -67,9 +69,13 @@ class AmsdalManager(BuildMixin, ClassVersionsMixin, metaclass=Singleton):
67
69
  and `ClassVersionsMixin`. It is intended to be used in the Amsdal framework for managing
68
70
  and building components.
69
71
  """
72
+ def post_setup(self) -> None:
73
+ """
74
+ Registers internal classes and prepares connections (creates internal tables).
75
+ """
70
76
  def migrate(self) -> None:
71
77
  """
72
- Check changes in the models and apply them to the database.
78
+ DEPRECATED: Check changes in the models and apply them to the database.
73
79
  """
74
80
  def _check_auth(self) -> None: ...
75
81
  @property
@@ -0,0 +1,44 @@
1
+ import abc
2
+ from _typeshed import Incomplete
3
+ from abc import ABC, abstractmethod
4
+ from amsdal.configs.constants import BASE_DIR as BASE_DIR
5
+ from amsdal_models.classes.model import Model
6
+ from amsdal_models.schemas.data_models.core import DictSchema, LegacyDictSchema, TypeData
7
+ from amsdal_models.schemas.data_models.schema import ObjectSchema, PropertyData
8
+ from amsdal_utils.models.enums import SchemaTypes as SchemaTypes
9
+ from pathlib import Path
10
+
11
+ class BaseMigrationSchemas(ABC, metaclass=abc.ABCMeta):
12
+ _classes: Incomplete
13
+ _classes_versions: Incomplete
14
+ _buffered_classes: Incomplete
15
+ def __init__(self) -> None: ...
16
+ def get_model(self, name: str) -> type[Model]: ...
17
+ @abstractmethod
18
+ def register_model(self, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes) -> None: ...
19
+ @abstractmethod
20
+ def unregister_model(self, class_name: str) -> None: ...
21
+ @abstractmethod
22
+ def compile_buffered_classes(self) -> None: ...
23
+ @staticmethod
24
+ def register_model_version(class_name: str, class_version: str) -> None: ...
25
+
26
+ class DefaultMigrationSchemas(BaseMigrationSchemas):
27
+ model_class_template_layout: Path
28
+ model_class_template: Path
29
+ dict_validator_template: Path
30
+ options_validator_template: Path
31
+ def register_model(self, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes) -> None: ...
32
+ def compile_buffered_classes(self) -> None: ...
33
+ def unregister_model(self, class_name: str) -> None: ...
34
+ def _compile_buffered_classes(self) -> list[tuple[str, type[Model]]]: ...
35
+ def _build_class_source(self, class_name: str, schema: ObjectSchema, schema_type: SchemaTypes) -> tuple[str, str]: ...
36
+ @staticmethod
37
+ def _resolve_class_inheritance(schema: ObjectSchema) -> str: ...
38
+ @staticmethod
39
+ def _process_custom_code(custom_code: str | None) -> tuple[str, str]: ...
40
+ def _render_property(self, name: str, property_schema: PropertyData, required: list[str]) -> str: ...
41
+ def _render_type_annotation(self, type_: str, items: TypeData | DictSchema | LegacyDictSchema | None) -> str: ...
42
+ def _render_validators(self, schema: ObjectSchema) -> list[str]: ...
43
+ def _get_all_types(self, type_: str, items: TypeData | DictSchema | LegacyDictSchema | None) -> set[str]: ...
44
+ def _is_reference(self, type_: str) -> bool: ...
@@ -0,0 +1,78 @@
1
+ from amsdal_models.classes.model import Model
2
+ from amsdal_models.schemas.data_models.schema import ObjectSchema, PropertyData
3
+ from amsdal_utils.models.data_models.address import Address as Address
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
+ CREATED: str
11
+ UPDATED: str
12
+ NO_ACTION: str
13
+
14
+ @dataclass
15
+ class ClassSaveResult:
16
+ action: Action
17
+ instance: Model
18
+ def __init__(self, action, instance) -> None: ...
19
+
20
+ @dataclass
21
+ class ClassUpdateResult:
22
+ is_updated: bool
23
+ class_instance: Model
24
+ def __init__(self, is_updated, class_instance) -> None: ...
25
+
26
+ @dataclass
27
+ class MigrateResult:
28
+ class_instance: Model
29
+ is_table_created: bool
30
+ is_data_migrated: bool
31
+ def __init__(self, class_instance, is_table_created, is_data_migrated) -> None: ...
32
+
33
+ class ModuleTypes(str, Enum):
34
+ APP: str
35
+ CORE: str
36
+ CONTRIB: str
37
+
38
+ @dataclass
39
+ class MigrationFile:
40
+ path: Path
41
+ type: ModuleTypes
42
+ number: int
43
+ module: str | None = ...
44
+ applied_at: float | None = ...
45
+ stored_address: Address | None = ...
46
+ @property
47
+ def is_initial(self) -> bool: ...
48
+ def __init__(self, path, type, number, module, applied_at, stored_address) -> None: ...
49
+
50
+ @dataclass
51
+ class ClassSchema:
52
+ object_schema: ObjectSchema
53
+ type: ModuleTypes
54
+ def __init__(self, object_schema, type) -> None: ...
55
+
56
+ class OperationTypes(str, Enum):
57
+ CREATE_CLASS: str
58
+ UPDATE_CLASS: str
59
+ DELETE_CLASS: str
60
+
61
+ @dataclass
62
+ class MigrateOperation:
63
+ type: OperationTypes
64
+ class_name: str
65
+ schema_type: SchemaTypes
66
+ old_schema: ObjectSchema | PropertyData | None = ...
67
+ new_schema: ObjectSchema | PropertyData | None = ...
68
+ def __init__(self, type, class_name, schema_type, old_schema, new_schema) -> None: ...
69
+
70
+ class MigrationDirection(str, Enum):
71
+ FORWARD: str
72
+ BACKWARD: str
73
+
74
+ @dataclass
75
+ class MigrationResult:
76
+ direction: MigrationDirection
77
+ migration: MigrationFile
78
+ def __init__(self, direction, migration) -> None: ...
@@ -0,0 +1,21 @@
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_models.schemas.data_models.schema import ObjectSchema
6
+ from amsdal_utils.models.enums import SchemaTypes as SchemaTypes
7
+
8
+ class BaseMigrationExecutor(ABC, metaclass=abc.ABCMeta):
9
+ schemas: BaseMigrationSchemas
10
+ _buffer: Incomplete
11
+ def __init__(self) -> None: ...
12
+ @abstractmethod
13
+ def create_class(self, schemas: BaseMigrationSchemas, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes) -> None: ...
14
+ @abstractmethod
15
+ def update_class(self, schemas: BaseMigrationSchemas, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes) -> None: ...
16
+ @abstractmethod
17
+ def delete_class(self, schemas: BaseMigrationSchemas, class_name: str, schema_type: SchemaTypes) -> None: ...
18
+ @staticmethod
19
+ def _resolve_base_class_name(class_name: str, meta_class: str) -> str: ...
20
+ def buffer_class_migration(self, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes) -> None: ...
21
+ def flush_buffer(self) -> None: ...
@@ -0,0 +1,20 @@
1
+ from _typeshed import Incomplete
2
+ from amsdal.migration.base_migration_schemas import BaseMigrationSchemas as BaseMigrationSchemas
3
+ from amsdal.migration.data_classes import Action as Action, ClassSaveResult as ClassSaveResult
4
+ from amsdal.migration.executors.base import BaseMigrationExecutor as BaseMigrationExecutor
5
+ from amsdal.migration.utils import object_schema_to_table_schema as object_schema_to_table_schema
6
+ from amsdal_models.classes.model import Model
7
+ from amsdal_models.schemas.data_models.schema import ObjectSchema
8
+ from amsdal_utils.models.enums import SchemaTypes
9
+
10
+ class DefaultMigrationExecutor(BaseMigrationExecutor):
11
+ schemas: Incomplete
12
+ _table_schemas_manager: Incomplete
13
+ def __init__(self, schemas: BaseMigrationSchemas) -> None: ...
14
+ def create_class(self, schemas: BaseMigrationSchemas, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes) -> None: ...
15
+ def update_class(self, schemas: BaseMigrationSchemas, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes) -> None: ...
16
+ def delete_class(self, schemas: BaseMigrationSchemas, class_name: str, schema_type: SchemaTypes) -> None: ...
17
+ def flush_buffer(self) -> None: ...
18
+ def _save_class(self, base_class: type[Model], object_schema: ObjectSchema, schema_type: SchemaTypes) -> ClassSaveResult: ...
19
+ def _create_table(self, object_schema: ObjectSchema, class_version: str) -> None: ...
20
+ def _migrate_historical_data(self, schemas: BaseMigrationSchemas, class_name: str, prior_version: str, new_version: str) -> None: ...
@@ -0,0 +1,14 @@
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_models.schemas.data_models.schema import ObjectSchema
5
+ from amsdal_utils.models.enums import SchemaTypes
6
+
7
+ class StateMigrationExecutor(BaseMigrationExecutor):
8
+ schemas: Incomplete
9
+ do_fetch_latest_version: Incomplete
10
+ def __init__(self, schemas: BaseMigrationSchemas, *, do_fetch_latest_version: bool = True) -> None: ...
11
+ def create_class(self, schemas: BaseMigrationSchemas, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes) -> None: ...
12
+ def update_class(self, schemas: BaseMigrationSchemas, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes) -> None: ...
13
+ def delete_class(self, schemas: BaseMigrationSchemas, class_name: str, schema_type: SchemaTypes) -> None: ...
14
+ def flush_buffer(self) -> None: ...
@@ -0,0 +1,35 @@
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
+ migration_address: Address
18
+ core_loader: Incomplete
19
+ contrib_loaders: Incomplete
20
+ app_loader: Incomplete
21
+ executor: Incomplete
22
+ _applied_migration_files: Incomplete
23
+ store: Incomplete
24
+ def __init__(self, app_migrations_loader: MigrationsLoader, executor: BaseMigrationExecutor, store: BaseMigrationStore | None = None) -> None: ...
25
+ def execute(self, migration_number: int | None = None, module_type: ModuleTypes | None = None, *, fake: bool = False, skip_data_migrations: bool = False) -> list[MigrationResult]: ...
26
+ @staticmethod
27
+ def _get_contrib_loaders() -> list[MigrationsLoader]: ...
28
+ def _apply(self, migration_number: int | None = None, module_type: ModuleTypes | None = None, *, fake: bool = False, skip_data_migrations: bool = False) -> list[MigrationResult]: ...
29
+ def _apply_migrations(self, loader: MigrationsLoader, module_type: ModuleTypes, migration_number: int | None = None, *, fake: bool = False, skip_data_migrations: bool = False) -> list[MigrationResult]: ...
30
+ def _init_state_from_applied_migrations(self, migrations: list[MigrationFile], module_type: ModuleTypes) -> None: ...
31
+ @staticmethod
32
+ def get_migration_class(migration: MigrationFile) -> type['Migration']: ...
33
+ def _is_migration_applied(self, migration: MigrationFile, module_type: ModuleTypes) -> bool: ...
34
+ @staticmethod
35
+ def _map_module_type_to_schema_type(module_type: ModuleTypes) -> SchemaTypes: ...
@@ -0,0 +1,49 @@
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_models.schemas.data_models.schema import ObjectSchema
12
+ from amsdal_utils.models.enums import SchemaTypes
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
+ state: Incomplete
24
+ def __init__(self) -> None: ...
25
+ def register_model(self, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes) -> None: ...
26
+ def unregister_model(self, class_name: str) -> None: ...
27
+ def compile_buffered_classes(self) -> None: ...
28
+
29
+ class FileMigrationGenerator:
30
+ _operations: ClassVar[dict[OperationTypes, Callable[..., MigrateOperation]]]
31
+ _app_migrations_path: Incomplete
32
+ _app_migrations_loader: Incomplete
33
+ _schema_loader: Incomplete
34
+ _state: Incomplete
35
+ def __init__(self, schema_loader: BaseClassSchemaLoader, app_migrations_path: Path | None = None) -> None: ...
36
+ def init_migrations(self, schema_type: SchemaTypes = ...) -> None:
37
+ """Reads class schemas and creates initial migration file"""
38
+ def make_migrations(self, name: str | None = None, *, is_data: bool = False, schema_type: SchemaTypes = ...) -> MigrationFile: ...
39
+ def generate_operations(self, schema_type: SchemaTypes) -> list[MigrateOperation]: ...
40
+ def _make_data_migrations(self, name: str | None = None) -> MigrationFile: ...
41
+ def _init_state(self) -> None: ...
42
+ @classmethod
43
+ def build_operations(cls, schema_type: SchemaTypes, class_schema: ObjectSchema, old_class_schema: ObjectSchema | None) -> list[MigrateOperation]: ...
44
+ def write_migration_file(self, operations: list[MigrateOperation], name: str | None = None) -> MigrationFile: ...
45
+ def write_data_migration_file(self, name: str | None = None) -> MigrationFile: ...
46
+ @staticmethod
47
+ def generate_name_from_operations(operations: list[MigrateOperation]) -> str: ...
48
+ @staticmethod
49
+ def _get_migration_file_name(number: int, name: str) -> str: ...
@@ -0,0 +1,33 @@
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.config.data_models.amsdal_config import AmsdalConfig as AmsdalConfig
8
+ from amsdal_utils.models.data_models.address import Address
9
+ from typing import Any
10
+
11
+ class BaseMigrationStore(ABC, metaclass=abc.ABCMeta):
12
+ @abstractmethod
13
+ def fetch_migrations(self) -> list[MigrationFile]: ...
14
+ @abstractmethod
15
+ def save_migration(self, migration: MigrationFile) -> None: ...
16
+ @abstractmethod
17
+ def delete_migration(self, migration: MigrationFile) -> None: ...
18
+
19
+ class FileMigrationStore(BaseMigrationStore):
20
+ migration_address: Address
21
+ _config_manager: Incomplete
22
+ _amsdal_config: Incomplete
23
+ _connections_manager: Incomplete
24
+ def __init__(self) -> None: ...
25
+ def fetch_migrations(self) -> list[MigrationFile]: ...
26
+ def save_migration(self, migration: MigrationFile) -> None: ...
27
+ def delete_migration(self, migration: MigrationFile) -> None: ...
28
+ def _save_historical_data(self, address: Address, data: dict[str, Any], metadata: dict[str, Any]) -> None: ...
29
+ @staticmethod
30
+ def _build_migration_data(migration: MigrationFile) -> dict[str, Any]: ...
31
+ @classmethod
32
+ def _build_migration_metadata(cls, migration: MigrationFile, object_id: str | None = None) -> tuple[Address, dict[str, Any]]: ...
33
+ def _init_migration_table(self) -> None: ...