amsdal 0.2.5__cp312-cp312-win_amd64.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.
- amsdal/Third-Party Materials - AMSDAL Dependencies - License Notices.md +1308 -0
- amsdal/__about__.py +4 -0
- amsdal/__about__.pyi +1 -0
- amsdal/__init__.py +3 -0
- amsdal/__init__.pyi +0 -0
- amsdal/__migrations__/0000_initial.py +203 -0
- amsdal/__migrations__/0001_datetime_type.py +18 -0
- amsdal/__migrations__/0002_fixture_order.py +40 -0
- amsdal/cloud/__init__.cp312-win_amd64.pyd +0 -0
- amsdal/cloud/__init__.pyi +0 -0
- amsdal/cloud/client.cp312-win_amd64.pyd +0 -0
- amsdal/cloud/client.pyi +57 -0
- amsdal/cloud/constants.cp312-win_amd64.pyd +0 -0
- amsdal/cloud/constants.pyi +13 -0
- amsdal/cloud/enums.cp312-win_amd64.pyd +0 -0
- amsdal/cloud/enums.pyi +68 -0
- amsdal/cloud/models/__init__.cp312-win_amd64.pyd +0 -0
- amsdal/cloud/models/__init__.pyi +0 -0
- amsdal/cloud/models/base.cp312-win_amd64.pyd +0 -0
- amsdal/cloud/models/base.pyi +247 -0
- amsdal/cloud/services/__init__.cp312-win_amd64.pyd +0 -0
- amsdal/cloud/services/__init__.pyi +0 -0
- amsdal/cloud/services/actions/__init__.cp312-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/__init__.pyi +0 -0
- amsdal/cloud/services/actions/add_allowlist_ip.cp312-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/add_allowlist_ip.pyi +19 -0
- amsdal/cloud/services/actions/add_basic_auth.cp312-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/add_basic_auth.pyi +21 -0
- amsdal/cloud/services/actions/add_dependency.cp312-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/add_dependency.pyi +19 -0
- amsdal/cloud/services/actions/add_secret.cp312-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/add_secret.pyi +20 -0
- amsdal/cloud/services/actions/base.cp312-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/base.pyi +122 -0
- amsdal/cloud/services/actions/create_deploy.cp312-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/create_deploy.pyi +41 -0
- amsdal/cloud/services/actions/create_env.cp312-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/create_env.pyi +19 -0
- amsdal/cloud/services/actions/create_session.cp312-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/create_session.pyi +17 -0
- amsdal/cloud/services/actions/delete_allowlist_ip.cp312-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/delete_allowlist_ip.pyi +19 -0
- amsdal/cloud/services/actions/delete_basic_auth.cp312-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/delete_basic_auth.pyi +20 -0
- amsdal/cloud/services/actions/delete_dependency.cp312-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/delete_dependency.pyi +21 -0
- amsdal/cloud/services/actions/delete_env.cp312-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/delete_env.pyi +21 -0
- amsdal/cloud/services/actions/delete_secret.cp312-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/delete_secret.pyi +21 -0
- amsdal/cloud/services/actions/destroy_deploy.cp312-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/destroy_deploy.pyi +18 -0
- amsdal/cloud/services/actions/expose_db.cp312-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/expose_db.pyi +22 -0
- amsdal/cloud/services/actions/get_basic_auth_credentials.cp312-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/get_basic_auth_credentials.pyi +21 -0
- amsdal/cloud/services/actions/get_monitoring_info.cp312-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/get_monitoring_info.pyi +21 -0
- amsdal/cloud/services/actions/list_dependencies.cp312-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/list_dependencies.pyi +21 -0
- amsdal/cloud/services/actions/list_deploys.cp312-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/list_deploys.pyi +19 -0
- amsdal/cloud/services/actions/list_envs.cp312-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/list_envs.pyi +20 -0
- amsdal/cloud/services/actions/list_secrets.cp312-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/list_secrets.pyi +22 -0
- amsdal/cloud/services/actions/manager.cp312-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/manager.pyi +278 -0
- amsdal/cloud/services/actions/signup_action.cp312-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/signup_action.pyi +20 -0
- amsdal/cloud/services/actions/update_deploy.cp312-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/update_deploy.pyi +19 -0
- amsdal/cloud/services/auth/__init__.cp312-win_amd64.pyd +0 -0
- amsdal/cloud/services/auth/__init__.pyi +0 -0
- amsdal/cloud/services/auth/base.cp312-win_amd64.pyd +0 -0
- amsdal/cloud/services/auth/base.pyi +6 -0
- amsdal/cloud/services/auth/credentials.cp312-win_amd64.pyd +0 -0
- amsdal/cloud/services/auth/credentials.pyi +31 -0
- amsdal/cloud/services/auth/manager.cp312-win_amd64.pyd +0 -0
- amsdal/cloud/services/auth/manager.pyi +26 -0
- amsdal/cloud/services/auth/signup_service.cp312-win_amd64.pyd +0 -0
- amsdal/cloud/services/auth/signup_service.pyi +32 -0
- amsdal/cloud/services/auth/token.cp312-win_amd64.pyd +0 -0
- amsdal/cloud/services/auth/token.pyi +28 -0
- amsdal/configs/__init__.py +0 -0
- amsdal/configs/__init__.pyi +0 -0
- amsdal/configs/constants.py +33 -0
- amsdal/configs/constants.pyi +22 -0
- amsdal/configs/main.py +254 -0
- amsdal/configs/main.pyi +177 -0
- amsdal/context/__init__.py +0 -0
- amsdal/context/__init__.pyi +0 -0
- amsdal/context/manager.py +69 -0
- amsdal/context/manager.pyi +50 -0
- amsdal/contrib/__init__.cp312-win_amd64.pyd +0 -0
- amsdal/contrib/__init__.pyi +0 -0
- amsdal/contrib/app_config.py +7 -0
- amsdal/contrib/app_config.pyi +6 -0
- amsdal/contrib/auth/__init__.py +0 -0
- amsdal/contrib/auth/__init__.pyi +0 -0
- amsdal/contrib/auth/app.py +27 -0
- amsdal/contrib/auth/app.pyi +15 -0
- amsdal/contrib/auth/decorators/__init__.py +20 -0
- amsdal/contrib/auth/decorators/__init__.pyi +6 -0
- amsdal/contrib/auth/errors.py +7 -0
- amsdal/contrib/auth/errors.pyi +4 -0
- amsdal/contrib/auth/lifecycle/__init__.py +0 -0
- amsdal/contrib/auth/lifecycle/__init__.pyi +0 -0
- amsdal/contrib/auth/lifecycle/consumer.py +222 -0
- amsdal/contrib/auth/lifecycle/consumer.pyi +69 -0
- amsdal/contrib/auth/migrations/0000_initial.py +49 -0
- amsdal/contrib/auth/models/login_session/hooks/pre_init.py +64 -0
- amsdal/contrib/auth/models/login_session/model.json +23 -0
- amsdal/contrib/auth/models/login_session/modifiers/display_name.py +11 -0
- amsdal/contrib/auth/models/permission/fixtures/basic_permissions.json +62 -0
- amsdal/contrib/auth/models/permission/model.json +18 -0
- amsdal/contrib/auth/models/permission/modifiers/display_name.py +11 -0
- amsdal/contrib/auth/models/user/hooks/post_init.py +58 -0
- amsdal/contrib/auth/models/user/hooks/pre_create.py +8 -0
- amsdal/contrib/auth/models/user/model.json +25 -0
- amsdal/contrib/auth/models/user/modifiers/display_name.py +19 -0
- amsdal/contrib/auth/settings.py +36 -0
- amsdal/contrib/auth/settings.pyi +26 -0
- amsdal/contrib/frontend_configs/__init__.py +0 -0
- amsdal/contrib/frontend_configs/__init__.pyi +0 -0
- amsdal/contrib/frontend_configs/app.py +24 -0
- amsdal/contrib/frontend_configs/app.pyi +19 -0
- amsdal/contrib/frontend_configs/constants.py +1 -0
- amsdal/contrib/frontend_configs/constants.pyi +1 -0
- amsdal/contrib/frontend_configs/conversion/__init__.py +5 -0
- amsdal/contrib/frontend_configs/conversion/__init__.pyi +3 -0
- amsdal/contrib/frontend_configs/conversion/convert.py +250 -0
- amsdal/contrib/frontend_configs/conversion/convert.pyi +23 -0
- amsdal/contrib/frontend_configs/lifecycle/__init__.py +0 -0
- amsdal/contrib/frontend_configs/lifecycle/__init__.pyi +0 -0
- amsdal/contrib/frontend_configs/lifecycle/consumer.py +242 -0
- amsdal/contrib/frontend_configs/lifecycle/consumer.pyi +86 -0
- amsdal/contrib/frontend_configs/migrations/0000_initial.py +255 -0
- amsdal/contrib/frontend_configs/models/frontend_activator_config/model.json +11 -0
- amsdal/contrib/frontend_configs/models/frontend_config_async_validator/model.json +11 -0
- amsdal/contrib/frontend_configs/models/frontend_config_group_validator/model.json +52 -0
- amsdal/contrib/frontend_configs/models/frontend_config_option/model.json +15 -0
- amsdal/contrib/frontend_configs/models/frontend_config_skip_none_base/model.json +6 -0
- amsdal/contrib/frontend_configs/models/frontend_config_skip_none_base/properties/model_dump.py +13 -0
- amsdal/contrib/frontend_configs/models/frontend_config_slider_option/model.json +19 -0
- amsdal/contrib/frontend_configs/models/frontend_config_text_mask/model.json +26 -0
- amsdal/contrib/frontend_configs/models/frontend_config_validator/model.json +41 -0
- amsdal/contrib/frontend_configs/models/frontend_control_config/model.json +250 -0
- amsdal/contrib/frontend_configs/models/frontend_model_config/fixtures/permissions.json +24 -0
- amsdal/contrib/frontend_configs/models/frontend_model_config/model.json +17 -0
- amsdal/contrib/frontend_configs/models/frontent_config_control_action/model.json +54 -0
- amsdal/contrib/frontend_configs/models/frontent_config_control_action/properties/action_validate.py +33 -0
- amsdal/contrib/frontend_configs/utils.py +29 -0
- amsdal/contrib/frontend_configs/utils.pyi +17 -0
- amsdal/errors.py +31 -0
- amsdal/errors.pyi +12 -0
- amsdal/fixtures/__init__.cp312-win_amd64.pyd +0 -0
- amsdal/fixtures/__init__.pyi +0 -0
- amsdal/fixtures/manager.cp312-win_amd64.pyd +0 -0
- amsdal/fixtures/manager.pyi +118 -0
- amsdal/manager.cp312-win_amd64.pyd +0 -0
- amsdal/manager.pyi +183 -0
- amsdal/migration/__init__.cp312-win_amd64.pyd +0 -0
- amsdal/migration/__init__.pyi +0 -0
- amsdal/migration/base_migration_schemas.cp312-win_amd64.pyd +0 -0
- amsdal/migration/base_migration_schemas.pyi +120 -0
- amsdal/migration/data_classes.cp312-win_amd64.pyd +0 -0
- amsdal/migration/data_classes.pyi +178 -0
- amsdal/migration/executors/__init__.cp312-win_amd64.pyd +0 -0
- amsdal/migration/executors/__init__.pyi +0 -0
- amsdal/migration/executors/base.cp312-win_amd64.pyd +0 -0
- amsdal/migration/executors/base.pyi +106 -0
- amsdal/migration/executors/default_executor.cp312-win_amd64.pyd +0 -0
- amsdal/migration/executors/default_executor.pyi +96 -0
- amsdal/migration/executors/state_executor.cp312-win_amd64.pyd +0 -0
- amsdal/migration/executors/state_executor.pyi +78 -0
- amsdal/migration/file_migration_executor.cp312-win_amd64.pyd +0 -0
- amsdal/migration/file_migration_executor.pyi +68 -0
- amsdal/migration/file_migration_generator.cp312-win_amd64.pyd +0 -0
- amsdal/migration/file_migration_generator.pyi +139 -0
- amsdal/migration/file_migration_store.cp312-win_amd64.pyd +0 -0
- amsdal/migration/file_migration_store.pyi +61 -0
- amsdal/migration/file_migration_writer.cp312-win_amd64.pyd +0 -0
- amsdal/migration/file_migration_writer.pyi +73 -0
- amsdal/migration/migrations.cp312-win_amd64.pyd +0 -0
- amsdal/migration/migrations.pyi +166 -0
- amsdal/migration/migrations_loader.cp312-win_amd64.pyd +0 -0
- amsdal/migration/migrations_loader.pyi +32 -0
- amsdal/migration/schemas_loaders.cp312-win_amd64.pyd +0 -0
- amsdal/migration/schemas_loaders.pyi +37 -0
- amsdal/migration/templates/data_migration.tmpl +18 -0
- amsdal/migration/templates/dict_validator.tmpl +4 -0
- amsdal/migration/templates/migration.tmpl +6 -0
- amsdal/migration/templates/model_class.tmpl +8 -0
- amsdal/migration/templates/model_class_layout.tmpl +24 -0
- amsdal/migration/templates/options_validator.tmpl +4 -0
- amsdal/migration/utils.cp312-win_amd64.pyd +0 -0
- amsdal/migration/utils.pyi +58 -0
- amsdal/mixins/__init__.cp312-win_amd64.pyd +0 -0
- amsdal/mixins/__init__.pyi +0 -0
- amsdal/mixins/build_mixin.cp312-win_amd64.pyd +0 -0
- amsdal/mixins/build_mixin.pyi +78 -0
- amsdal/mixins/class_versions_mixin.cp312-win_amd64.pyd +0 -0
- amsdal/mixins/class_versions_mixin.pyi +6 -0
- amsdal/py.typed +0 -0
- amsdal/schemas/__init__.py +0 -0
- amsdal/schemas/__init__.pyi +0 -0
- amsdal/schemas/core/class_object/model.json +31 -0
- amsdal/schemas/core/class_object/properties/display_name.py +9 -0
- amsdal/schemas/core/class_object_meta/model.json +55 -0
- amsdal/schemas/core/class_property/model.json +22 -0
- amsdal/schemas/core/class_property_meta/model.json +23 -0
- amsdal/schemas/core/file/hooks/pre_create.py +11 -0
- amsdal/schemas/core/file/hooks/pre_update.py +11 -0
- amsdal/schemas/core/file/model.json +23 -0
- amsdal/schemas/core/file/properties/from_file.py +34 -0
- amsdal/schemas/core/file/properties/mimetype.py +13 -0
- amsdal/schemas/core/file/properties/str.py +6 -0
- amsdal/schemas/core/file/properties/to_file.py +24 -0
- amsdal/schemas/core/file/properties/validate_data.py +32 -0
- amsdal/schemas/core/fixture/model.json +35 -0
- amsdal/schemas/core/option/model.json +19 -0
- amsdal/schemas/core/validator/model.json +19 -0
- amsdal/schemas/manager.cp312-win_amd64.pyd +0 -0
- amsdal/schemas/manager.py +116 -0
- amsdal/schemas/manager.pyi +65 -0
- amsdal/schemas/types/anything/model.json +7 -0
- amsdal/schemas/types/array/model.json +7 -0
- amsdal/schemas/types/binary/model.json +7 -0
- amsdal/schemas/types/boolean/model.json +17 -0
- amsdal/schemas/types/date/model.json +7 -0
- amsdal/schemas/types/datetime/model.json +7 -0
- amsdal/schemas/types/dictionary/model.json +8 -0
- amsdal/schemas/types/number/model.json +8 -0
- amsdal/schemas/types/object/model.json +53 -0
- amsdal/schemas/types/string/model.json +8 -0
- amsdal/services/__init__.cp312-win_amd64.pyd +0 -0
- amsdal/services/__init__.pyi +0 -0
- amsdal/services/transaction_execution.cp312-win_amd64.pyd +0 -0
- amsdal/services/transaction_execution.pyi +76 -0
- amsdal/utils/__init__.py +0 -0
- amsdal/utils/__init__.pyi +0 -0
- amsdal/utils/contrib_paths.py +23 -0
- amsdal/utils/contrib_paths.pyi +14 -0
- amsdal/utils/tests/__init__.py +0 -0
- amsdal/utils/tests/enums.py +18 -0
- amsdal/utils/tests/factories.py +49 -0
- amsdal/utils/tests/helpers.py +309 -0
- amsdal-0.2.5.dist-info/LICENSE.txt +107 -0
- amsdal-0.2.5.dist-info/METADATA +366 -0
- amsdal-0.2.5.dist-info/RECORD +254 -0
- amsdal-0.2.5.dist-info/WHEEL +5 -0
- amsdal-0.2.5.dist-info/license_check.py +35 -0
- amsdal-0.2.5.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from typing import BinaryIO
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@classmethod # type: ignore[misc, no-untyped-def]
|
|
6
|
+
def from_file(
|
|
7
|
+
cls,
|
|
8
|
+
file_or_path: Path | BinaryIO,
|
|
9
|
+
) -> 'File': # type: ignore[name-defined] # noqa: F821
|
|
10
|
+
"""
|
|
11
|
+
Creates a `File` object from a file path or a binary file object.
|
|
12
|
+
|
|
13
|
+
Args:
|
|
14
|
+
file_or_path (Path | BinaryIO): The file path or binary file object.
|
|
15
|
+
|
|
16
|
+
Returns:
|
|
17
|
+
File: The created `File` object.
|
|
18
|
+
|
|
19
|
+
Raises:
|
|
20
|
+
ValueError: If the provided path is a directory.
|
|
21
|
+
"""
|
|
22
|
+
if isinstance(file_or_path, Path):
|
|
23
|
+
if file_or_path.is_dir():
|
|
24
|
+
msg = f'{file_or_path} is a directory'
|
|
25
|
+
raise ValueError(msg)
|
|
26
|
+
|
|
27
|
+
data = file_or_path.read_bytes()
|
|
28
|
+
filename = file_or_path.name
|
|
29
|
+
else:
|
|
30
|
+
file_or_path.seek(0)
|
|
31
|
+
data = file_or_path.read()
|
|
32
|
+
filename = Path(file_or_path.name).name
|
|
33
|
+
|
|
34
|
+
return cls(data=data, filename=filename)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
@property # type: ignore[misc]
|
|
2
|
+
def mimetype(self) -> str | None: # type: ignore[no-untyped-def]
|
|
3
|
+
"""
|
|
4
|
+
Returns the MIME type of the file based on its filename.
|
|
5
|
+
|
|
6
|
+
This method uses the `mimetypes` module to guess the MIME type of the file.
|
|
7
|
+
|
|
8
|
+
Returns:
|
|
9
|
+
str | None: The guessed MIME type of the file, or None if it cannot be determined.
|
|
10
|
+
"""
|
|
11
|
+
import mimetypes
|
|
12
|
+
|
|
13
|
+
return mimetypes.guess_type(self.filename)[0]
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from typing import BinaryIO
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def to_file(self, file_or_path: Path | BinaryIO) -> None: # type: ignore[no-untyped-def]
|
|
6
|
+
"""
|
|
7
|
+
Writes the object's data to a file path or a binary file object.
|
|
8
|
+
|
|
9
|
+
Args:
|
|
10
|
+
file_or_path (Path | BinaryIO): The file path or binary file object where the data will be written.
|
|
11
|
+
|
|
12
|
+
Returns:
|
|
13
|
+
None
|
|
14
|
+
|
|
15
|
+
Raises:
|
|
16
|
+
ValueError: If the provided path is a directory.
|
|
17
|
+
"""
|
|
18
|
+
if isinstance(file_or_path, Path):
|
|
19
|
+
if file_or_path.is_dir():
|
|
20
|
+
file_or_path = file_or_path / self.name
|
|
21
|
+
file_or_path.write_bytes(self.data) # type: ignore[union-attr]
|
|
22
|
+
else:
|
|
23
|
+
file_or_path.write(self.data)
|
|
24
|
+
file_or_path.seek(0)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import base64
|
|
2
|
+
|
|
3
|
+
from pydantic import field_validator
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@field_validator('data') # type: ignore[misc]
|
|
7
|
+
@classmethod
|
|
8
|
+
def data_base64_decode(cls, v: bytes) -> bytes: # type: ignore[no-untyped-def] # noqa: ARG001
|
|
9
|
+
"""
|
|
10
|
+
Decodes a base64-encoded byte string if it is base64-encoded.
|
|
11
|
+
|
|
12
|
+
This method checks if the provided byte string is base64-encoded and decodes it if true.
|
|
13
|
+
If the byte string is not base64-encoded, it returns the original byte string.
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
cls: The class this method belongs to.
|
|
17
|
+
v (bytes): The byte string to be checked and potentially decoded.
|
|
18
|
+
|
|
19
|
+
Returns:
|
|
20
|
+
bytes: The decoded byte string if it was base64-encoded, otherwise the original byte string.
|
|
21
|
+
"""
|
|
22
|
+
is_base64: bool = False
|
|
23
|
+
|
|
24
|
+
try:
|
|
25
|
+
is_base64 = base64.b64encode(base64.b64decode(v)) == v
|
|
26
|
+
except Exception:
|
|
27
|
+
...
|
|
28
|
+
|
|
29
|
+
if is_base64:
|
|
30
|
+
return base64.b64decode(v)
|
|
31
|
+
|
|
32
|
+
return v
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"title": "Fixture",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"properties": {
|
|
5
|
+
"class_name": {
|
|
6
|
+
"title": "Class Name",
|
|
7
|
+
"type": "string"
|
|
8
|
+
},
|
|
9
|
+
"order": {
|
|
10
|
+
"title": "Order",
|
|
11
|
+
"type": "number"
|
|
12
|
+
},
|
|
13
|
+
"external_id": {
|
|
14
|
+
"title": "External ID",
|
|
15
|
+
"type": "string"
|
|
16
|
+
},
|
|
17
|
+
"data": {
|
|
18
|
+
"title": "Data",
|
|
19
|
+
"type": "dictionary",
|
|
20
|
+
"items": {
|
|
21
|
+
"key": {"type": "string"},
|
|
22
|
+
"value": {"type": "anything"}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"required": [
|
|
27
|
+
"data",
|
|
28
|
+
"external_id"
|
|
29
|
+
],
|
|
30
|
+
"unique": [
|
|
31
|
+
[
|
|
32
|
+
"external_id"
|
|
33
|
+
]
|
|
34
|
+
]
|
|
35
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"title": "Option",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"properties": {
|
|
5
|
+
"key": {
|
|
6
|
+
"title": "Key",
|
|
7
|
+
"type": "string"
|
|
8
|
+
},
|
|
9
|
+
"value": {
|
|
10
|
+
"title": "Value Type",
|
|
11
|
+
"type": "string"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"required": [
|
|
15
|
+
"key",
|
|
16
|
+
"value"
|
|
17
|
+
],
|
|
18
|
+
"meta_class": "TypeMeta"
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"title": "Validator",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"properties": {
|
|
5
|
+
"name": {
|
|
6
|
+
"title": "Validator Name",
|
|
7
|
+
"type": "string"
|
|
8
|
+
},
|
|
9
|
+
"data": {
|
|
10
|
+
"title": "Validator Data",
|
|
11
|
+
"type": "anything"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"required": [
|
|
15
|
+
"name",
|
|
16
|
+
"data"
|
|
17
|
+
],
|
|
18
|
+
"meta_class": "TypeMeta"
|
|
19
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
from amsdal_models.schemas.manager import SchemaManagerHandler
|
|
2
|
+
from amsdal_utils.models.data_models.enums import BaseClasses
|
|
3
|
+
from amsdal_utils.models.data_models.schema import ObjectSchema
|
|
4
|
+
from amsdal_utils.models.enums import SchemaTypes
|
|
5
|
+
from amsdal_utils.utils.singleton import Singleton
|
|
6
|
+
|
|
7
|
+
from amsdal.configs.main import settings
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class SchemaManager(metaclass=Singleton):
|
|
11
|
+
"""
|
|
12
|
+
Manages schema operations including retrieval, invalidation, and sorting.
|
|
13
|
+
|
|
14
|
+
This class handles various schema-related operations such as invalidating user schemas,
|
|
15
|
+
retrieving schemas by name or type, and sorting schemas based on predefined rules.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
def __init__(self) -> None:
|
|
19
|
+
self._schema_manager_handler = SchemaManagerHandler(settings.schemas_root_path)
|
|
20
|
+
|
|
21
|
+
def invalidate_user_schemas(self) -> None:
|
|
22
|
+
"""
|
|
23
|
+
Invalidates user schemas.
|
|
24
|
+
|
|
25
|
+
This method calls the handler to invalidate all user schemas, ensuring that any cached or outdated schemas
|
|
26
|
+
are refreshed.
|
|
27
|
+
|
|
28
|
+
Returns:
|
|
29
|
+
None
|
|
30
|
+
"""
|
|
31
|
+
self._schema_manager_handler.invalidate_user_schemas()
|
|
32
|
+
|
|
33
|
+
def class_schemas(self) -> list[tuple[ObjectSchema, SchemaTypes]]:
|
|
34
|
+
"""
|
|
35
|
+
Returns a list of tuples containing object schemas and their types.
|
|
36
|
+
|
|
37
|
+
This method retrieves and sorts various schemas managed by the schema manager handler.
|
|
38
|
+
The schemas are categorized into types, core, user, and contrib schemas.
|
|
39
|
+
|
|
40
|
+
Returns:
|
|
41
|
+
list[tuple[ObjectSchema, SchemaTypes]]: A list of tuples where each tuple contains an object schema
|
|
42
|
+
and its corresponding type.
|
|
43
|
+
"""
|
|
44
|
+
return (
|
|
45
|
+
[
|
|
46
|
+
(type_schema, SchemaTypes.TYPE)
|
|
47
|
+
for type_schema in self._schema_manager_handler.type_schemas
|
|
48
|
+
if type_schema.title == BaseClasses.OBJECT
|
|
49
|
+
]
|
|
50
|
+
+ [
|
|
51
|
+
(core_schema, SchemaTypes.CORE)
|
|
52
|
+
for core_schema in sorted(self._schema_manager_handler.core_schemas, key=self._sort_key_for_schema)
|
|
53
|
+
]
|
|
54
|
+
+ [(user_schema, SchemaTypes.USER) for user_schema in self._schema_manager_handler.user_schemas]
|
|
55
|
+
+ [(contrib_schema, SchemaTypes.CONTRIB) for contrib_schema in self._schema_manager_handler.contrib_schemas]
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
@staticmethod
|
|
59
|
+
def _sort_key_for_schema(schema: ObjectSchema) -> int:
|
|
60
|
+
# We need to register ClassObject first, coz ClassObjectMeta has a reference to it.
|
|
61
|
+
# All other classes have reference to ClassObject
|
|
62
|
+
if schema.title == BaseClasses.CLASS_OBJECT:
|
|
63
|
+
return 0
|
|
64
|
+
elif schema.title == BaseClasses.CLASS_OBJECT_META:
|
|
65
|
+
return 1
|
|
66
|
+
else:
|
|
67
|
+
return 2
|
|
68
|
+
|
|
69
|
+
def get_schema_by_name(self, title: str, schema_type: SchemaTypes | None = None) -> ObjectSchema | None:
|
|
70
|
+
"""
|
|
71
|
+
Retrieves a schema by its title and optional type.
|
|
72
|
+
|
|
73
|
+
This method searches for a schema with the specified title and optional type
|
|
74
|
+
among the schemas managed by the schema manager handler.
|
|
75
|
+
|
|
76
|
+
Args:
|
|
77
|
+
title (str): The title of the schema to be retrieved.
|
|
78
|
+
schema_type (SchemaTypes | None, optional): The type of the schema to be retrieved. Defaults to None.
|
|
79
|
+
|
|
80
|
+
Returns:
|
|
81
|
+
ObjectSchema | None: The schema with the specified title and type, or None if not found.
|
|
82
|
+
"""
|
|
83
|
+
_schemas = self.get_schemas(schema_type)
|
|
84
|
+
|
|
85
|
+
for schema in _schemas:
|
|
86
|
+
if schema.title == title:
|
|
87
|
+
return schema
|
|
88
|
+
|
|
89
|
+
return None
|
|
90
|
+
|
|
91
|
+
def get_schemas(self, schema_type: SchemaTypes | None = None) -> list[ObjectSchema]:
|
|
92
|
+
"""
|
|
93
|
+
Retrieves schemas based on the provided type.
|
|
94
|
+
|
|
95
|
+
This method returns a list of schemas filtered by the specified type. If no type is provided,
|
|
96
|
+
it returns all schemas managed by the schema manager handler.
|
|
97
|
+
|
|
98
|
+
Args:
|
|
99
|
+
schema_type (SchemaTypes | None, optional): The type of schemas to retrieve. Defaults to None.
|
|
100
|
+
|
|
101
|
+
Returns:
|
|
102
|
+
list[ObjectSchema]: A list of schemas filtered by the specified type, or all schemas if no type is provided.
|
|
103
|
+
"""
|
|
104
|
+
if schema_type == SchemaTypes.CONTRIB:
|
|
105
|
+
return self._schema_manager_handler.contrib_schemas
|
|
106
|
+
|
|
107
|
+
if schema_type == SchemaTypes.CORE:
|
|
108
|
+
return self._schema_manager_handler.core_schemas
|
|
109
|
+
|
|
110
|
+
if schema_type == SchemaTypes.TYPE:
|
|
111
|
+
return self._schema_manager_handler.type_schemas
|
|
112
|
+
|
|
113
|
+
if schema_type == SchemaTypes.USER:
|
|
114
|
+
return self._schema_manager_handler.user_schemas
|
|
115
|
+
|
|
116
|
+
return self._schema_manager_handler.all_schemas
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
from _typeshed import Incomplete
|
|
2
|
+
from amsdal.configs.main import settings as settings
|
|
3
|
+
from amsdal_utils.models.data_models.schema import ObjectSchema as ObjectSchema
|
|
4
|
+
from amsdal_utils.models.enums import SchemaTypes
|
|
5
|
+
from amsdal_utils.utils.singleton import Singleton
|
|
6
|
+
|
|
7
|
+
class SchemaManager(metaclass=Singleton):
|
|
8
|
+
"""
|
|
9
|
+
Manages schema operations including retrieval, invalidation, and sorting.
|
|
10
|
+
|
|
11
|
+
This class handles various schema-related operations such as invalidating user schemas,
|
|
12
|
+
retrieving schemas by name or type, and sorting schemas based on predefined rules.
|
|
13
|
+
"""
|
|
14
|
+
_schema_manager_handler: Incomplete
|
|
15
|
+
def __init__(self) -> None: ...
|
|
16
|
+
def invalidate_user_schemas(self) -> None:
|
|
17
|
+
"""
|
|
18
|
+
Invalidates user schemas.
|
|
19
|
+
|
|
20
|
+
This method calls the handler to invalidate all user schemas, ensuring that any cached or outdated schemas
|
|
21
|
+
are refreshed.
|
|
22
|
+
|
|
23
|
+
Returns:
|
|
24
|
+
None
|
|
25
|
+
"""
|
|
26
|
+
def class_schemas(self) -> list[tuple[ObjectSchema, SchemaTypes]]:
|
|
27
|
+
"""
|
|
28
|
+
Returns a list of tuples containing object schemas and their types.
|
|
29
|
+
|
|
30
|
+
This method retrieves and sorts various schemas managed by the schema manager handler.
|
|
31
|
+
The schemas are categorized into types, core, user, and contrib schemas.
|
|
32
|
+
|
|
33
|
+
Returns:
|
|
34
|
+
list[tuple[ObjectSchema, SchemaTypes]]: A list of tuples where each tuple contains an object schema
|
|
35
|
+
and its corresponding type.
|
|
36
|
+
"""
|
|
37
|
+
@staticmethod
|
|
38
|
+
def _sort_key_for_schema(schema: ObjectSchema) -> int: ...
|
|
39
|
+
def get_schema_by_name(self, title: str, schema_type: SchemaTypes | None = None) -> ObjectSchema | None:
|
|
40
|
+
"""
|
|
41
|
+
Retrieves a schema by its title and optional type.
|
|
42
|
+
|
|
43
|
+
This method searches for a schema with the specified title and optional type
|
|
44
|
+
among the schemas managed by the schema manager handler.
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
title (str): The title of the schema to be retrieved.
|
|
48
|
+
schema_type (SchemaTypes | None, optional): The type of the schema to be retrieved. Defaults to None.
|
|
49
|
+
|
|
50
|
+
Returns:
|
|
51
|
+
ObjectSchema | None: The schema with the specified title and type, or None if not found.
|
|
52
|
+
"""
|
|
53
|
+
def get_schemas(self, schema_type: SchemaTypes | None = None) -> list[ObjectSchema]:
|
|
54
|
+
"""
|
|
55
|
+
Retrieves schemas based on the provided type.
|
|
56
|
+
|
|
57
|
+
This method returns a list of schemas filtered by the specified type. If no type is provided,
|
|
58
|
+
it returns all schemas managed by the schema manager handler.
|
|
59
|
+
|
|
60
|
+
Args:
|
|
61
|
+
schema_type (SchemaTypes | None, optional): The type of schemas to retrieve. Defaults to None.
|
|
62
|
+
|
|
63
|
+
Returns:
|
|
64
|
+
list[ObjectSchema]: A list of schemas filtered by the specified type, or all schemas if no type is provided.
|
|
65
|
+
"""
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"title": "Object",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"default": null,
|
|
5
|
+
"properties": {
|
|
6
|
+
"title": {
|
|
7
|
+
"title": "Title",
|
|
8
|
+
"type": "string"
|
|
9
|
+
},
|
|
10
|
+
"type": {
|
|
11
|
+
"title": "Type",
|
|
12
|
+
"type": "string"
|
|
13
|
+
},
|
|
14
|
+
"default": {
|
|
15
|
+
"title": "Default",
|
|
16
|
+
"type": "anything"
|
|
17
|
+
},
|
|
18
|
+
"properties": {
|
|
19
|
+
"title": "Properties",
|
|
20
|
+
"type": "dictionary",
|
|
21
|
+
"items": {
|
|
22
|
+
"key": {"type": "string"},
|
|
23
|
+
"value": {"type": "anything"}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"required": {
|
|
27
|
+
"title": "Required",
|
|
28
|
+
"type": "array",
|
|
29
|
+
"items": {
|
|
30
|
+
"type": "string"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"unique": {
|
|
34
|
+
"title": "Unique Fields",
|
|
35
|
+
"type": "array",
|
|
36
|
+
"items": {
|
|
37
|
+
"type": "array",
|
|
38
|
+
"items": {
|
|
39
|
+
"type": "string"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"custom_code": {
|
|
44
|
+
"title": "Custom Code",
|
|
45
|
+
"type": "string"
|
|
46
|
+
},
|
|
47
|
+
"meta_class": {
|
|
48
|
+
"title": "Meta Class",
|
|
49
|
+
"type": "string"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"required": []
|
|
53
|
+
}
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import ast
|
|
2
|
+
from _typeshed import Incomplete
|
|
3
|
+
from amsdal.configs.main import settings as settings
|
|
4
|
+
from amsdal.errors import TransactionNotFoundError as TransactionNotFoundError
|
|
5
|
+
from amsdal_utils.utils.singleton import Singleton
|
|
6
|
+
from collections.abc import Callable as Callable, Generator
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Any
|
|
9
|
+
|
|
10
|
+
logger: Incomplete
|
|
11
|
+
|
|
12
|
+
def is_transaction(statement: ast.AST) -> bool:
|
|
13
|
+
"""
|
|
14
|
+
Determines if a given AST statement is a transaction function.
|
|
15
|
+
|
|
16
|
+
This function checks if the provided AST statement is an asynchronous or synchronous function
|
|
17
|
+
definition that is decorated with the `transaction` decorator.
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
statement (ast.AST): The AST statement to check.
|
|
21
|
+
|
|
22
|
+
Returns:
|
|
23
|
+
bool: True if the statement is a transaction function, False otherwise.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
class TransactionExecutionService(metaclass=Singleton):
|
|
27
|
+
"""
|
|
28
|
+
Service for executing transactions.
|
|
29
|
+
|
|
30
|
+
This class provides methods to execute transactions, load transaction functions,
|
|
31
|
+
and handle asynchronous transactions. It ensures that transactions are executed
|
|
32
|
+
with the correct arguments and handles any necessary preprocessing of arguments.
|
|
33
|
+
"""
|
|
34
|
+
_transactions: Incomplete
|
|
35
|
+
def __init__(self) -> None: ...
|
|
36
|
+
def execute_transaction(self, transaction_name: str, args: dict[str, Any], *, load_references: bool = True) -> Any:
|
|
37
|
+
"""
|
|
38
|
+
Executes a transaction with the given name and arguments.
|
|
39
|
+
|
|
40
|
+
This method retrieves the transaction function by its name, processes the arguments,
|
|
41
|
+
and executes the transaction. It handles both synchronous and asynchronous transactions
|
|
42
|
+
and performs necessary preprocessing of arguments, such as loading references.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
transaction_name (str): The name of the transaction to execute.
|
|
46
|
+
args (dict[str, Any]): The arguments to pass to the transaction function.
|
|
47
|
+
load_references (bool, optional): Whether to load references in the arguments. Defaults to True.
|
|
48
|
+
|
|
49
|
+
Returns:
|
|
50
|
+
Any: The result of the transaction execution.
|
|
51
|
+
"""
|
|
52
|
+
def get_transaction_func(self, transaction_name: str) -> Callable[..., Any]:
|
|
53
|
+
"""
|
|
54
|
+
Retrieves the transaction function by its name.
|
|
55
|
+
|
|
56
|
+
This method checks if the transaction function is already loaded in the `_transactions` dictionary.
|
|
57
|
+
If not, it attempts to load the transaction function from the available transaction definitions.
|
|
58
|
+
|
|
59
|
+
Args:
|
|
60
|
+
transaction_name (str): The name of the transaction function to retrieve.
|
|
61
|
+
|
|
62
|
+
Returns:
|
|
63
|
+
Callable[..., Any]: The transaction function corresponding to the given name.
|
|
64
|
+
|
|
65
|
+
Raises:
|
|
66
|
+
TransactionNotFoundError: If the transaction function with the specified name is not found.
|
|
67
|
+
"""
|
|
68
|
+
@staticmethod
|
|
69
|
+
def _run_async_transaction(transaction_func: Callable[..., Any], args: dict[str, Any]) -> Any: ...
|
|
70
|
+
def _load_transaction(self, transaction_name: str) -> Callable[..., Any]: ...
|
|
71
|
+
@classmethod
|
|
72
|
+
def _get_transaction_definitions(cls) -> Generator[tuple[ast.FunctionDef | ast.AsyncFunctionDef, Path], None, None]: ...
|
|
73
|
+
@classmethod
|
|
74
|
+
def _iterate_module(cls, module_path: Path) -> Generator[tuple[ast.FunctionDef | ast.AsyncFunctionDef, Path], None, None]: ...
|
|
75
|
+
@classmethod
|
|
76
|
+
def _iterate_file(cls, file_path: Path) -> Generator[tuple[ast.FunctionDef | ast.AsyncFunctionDef, Path], None, None]: ...
|
amsdal/utils/__init__.py
ADDED
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from collections.abc import Generator
|
|
2
|
+
from importlib import import_module
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def get_contrib_schemas_paths() -> Generator[Path, None, None]:
|
|
7
|
+
"""
|
|
8
|
+
Retrieves paths to contribution schemas.
|
|
9
|
+
|
|
10
|
+
This function iterates over the configured contributions in the settings and yields
|
|
11
|
+
the paths to the 'models' directories for each contribution.
|
|
12
|
+
|
|
13
|
+
Returns:
|
|
14
|
+
Generator[Path, None, None]: A generator that yields paths to the 'models' directories
|
|
15
|
+
of the configured contributions.
|
|
16
|
+
"""
|
|
17
|
+
from amsdal.configs.main import settings
|
|
18
|
+
|
|
19
|
+
for contrib in settings.CONTRIB:
|
|
20
|
+
module_name, *_ = contrib.rsplit('.', 2)
|
|
21
|
+
module = import_module(module_name)
|
|
22
|
+
|
|
23
|
+
yield Path(module.__file__).parent / 'models' # type: ignore[arg-type]
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from collections.abc import Generator
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
def get_contrib_schemas_paths() -> Generator[Path, None, None]:
|
|
5
|
+
"""
|
|
6
|
+
Retrieves paths to contribution schemas.
|
|
7
|
+
|
|
8
|
+
This function iterates over the configured contributions in the settings and yields
|
|
9
|
+
the paths to the 'models' directories for each contribution.
|
|
10
|
+
|
|
11
|
+
Returns:
|
|
12
|
+
Generator[Path, None, None]: A generator that yields paths to the 'models' directories
|
|
13
|
+
of the configured contributions.
|
|
14
|
+
"""
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class DbExecutionType(str, Enum):
|
|
5
|
+
lakehouse_only = 'lakehouse_only'
|
|
6
|
+
include_state_db = 'include_state_db'
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class StateOption(str, Enum):
|
|
10
|
+
sqlite = 'sqlite'
|
|
11
|
+
postgres = 'postgres'
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class LakehouseOption(str, Enum):
|
|
15
|
+
postgres = 'postgres'
|
|
16
|
+
postgres_immutable = 'postgres-immutable'
|
|
17
|
+
sqlite = 'sqlite'
|
|
18
|
+
sqlite_immutable = 'sqlite-immutable'
|