amsdal 0.1.26__cp310-cp310-win_amd64.whl → 0.2.0__cp310-cp310-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.

Files changed (163) hide show
  1. amsdal/__about__.py +1 -1
  2. amsdal/cloud/__init__.cp310-win_amd64.pyd +0 -0
  3. amsdal/cloud/client.cp310-win_amd64.pyd +0 -0
  4. amsdal/cloud/client.pyi +46 -2
  5. amsdal/cloud/constants.cp310-win_amd64.pyd +0 -0
  6. amsdal/cloud/enums.cp310-win_amd64.pyd +0 -0
  7. amsdal/cloud/enums.pyi +46 -0
  8. amsdal/cloud/models/__init__.cp310-win_amd64.pyd +0 -0
  9. amsdal/cloud/models/base.cp310-win_amd64.pyd +0 -0
  10. amsdal/cloud/models/base.pyi +156 -0
  11. amsdal/cloud/services/__init__.cp310-win_amd64.pyd +0 -0
  12. amsdal/cloud/services/actions/__init__.cp310-win_amd64.pyd +0 -0
  13. amsdal/cloud/services/actions/add_allowlist_ip.cp310-win_amd64.pyd +0 -0
  14. amsdal/cloud/services/actions/add_allowlist_ip.pyi +16 -1
  15. amsdal/cloud/services/actions/add_basic_auth.cp310-win_amd64.pyd +0 -0
  16. amsdal/cloud/services/actions/add_basic_auth.pyi +17 -1
  17. amsdal/cloud/services/actions/add_dependency.cp310-win_amd64.pyd +0 -0
  18. amsdal/cloud/services/actions/add_dependency.pyi +16 -1
  19. amsdal/cloud/services/actions/add_secret.cp310-win_amd64.pyd +0 -0
  20. amsdal/cloud/services/actions/add_secret.pyi +17 -1
  21. amsdal/cloud/services/actions/base.cp310-win_amd64.pyd +0 -0
  22. amsdal/cloud/services/actions/base.pyi +71 -3
  23. amsdal/cloud/services/actions/create_deploy.cp310-win_amd64.pyd +0 -0
  24. amsdal/cloud/services/actions/create_deploy.pyi +33 -3
  25. amsdal/cloud/services/actions/create_env.cp310-win_amd64.pyd +0 -0
  26. amsdal/cloud/services/actions/create_env.pyi +15 -1
  27. amsdal/cloud/services/actions/create_session.cp310-win_amd64.pyd +0 -0
  28. amsdal/cloud/services/actions/create_session.pyi +13 -1
  29. amsdal/cloud/services/actions/delete_allowlist_ip.cp310-win_amd64.pyd +0 -0
  30. amsdal/cloud/services/actions/delete_allowlist_ip.pyi +16 -1
  31. amsdal/cloud/services/actions/delete_basic_auth.cp310-win_amd64.pyd +0 -0
  32. amsdal/cloud/services/actions/delete_basic_auth.pyi +17 -1
  33. amsdal/cloud/services/actions/delete_dependency.cp310-win_amd64.pyd +0 -0
  34. amsdal/cloud/services/actions/delete_dependency.pyi +18 -1
  35. amsdal/cloud/services/actions/delete_env.cp310-win_amd64.pyd +0 -0
  36. amsdal/cloud/services/actions/delete_env.pyi +17 -1
  37. amsdal/cloud/services/actions/delete_secret.cp310-win_amd64.pyd +0 -0
  38. amsdal/cloud/services/actions/delete_secret.pyi +18 -1
  39. amsdal/cloud/services/actions/destroy_deploy.cp310-win_amd64.pyd +0 -0
  40. amsdal/cloud/services/actions/destroy_deploy.pyi +15 -1
  41. amsdal/cloud/services/actions/expose_db.cp310-win_amd64.pyd +0 -0
  42. amsdal/cloud/services/actions/expose_db.pyi +18 -1
  43. amsdal/cloud/services/actions/get_basic_auth_credentials.cp310-win_amd64.pyd +0 -0
  44. amsdal/cloud/services/actions/get_basic_auth_credentials.pyi +17 -1
  45. amsdal/cloud/services/actions/get_monitoring_info.cp310-win_amd64.pyd +0 -0
  46. amsdal/cloud/services/actions/get_monitoring_info.pyi +17 -1
  47. amsdal/cloud/services/actions/list_dependencies.cp310-win_amd64.pyd +0 -0
  48. amsdal/cloud/services/actions/list_dependencies.pyi +17 -1
  49. amsdal/cloud/services/actions/list_deploys.cp310-win_amd64.pyd +0 -0
  50. amsdal/cloud/services/actions/list_deploys.pyi +15 -1
  51. amsdal/cloud/services/actions/list_envs.cp310-win_amd64.pyd +0 -0
  52. amsdal/cloud/services/actions/list_envs.pyi +16 -1
  53. amsdal/cloud/services/actions/list_secrets.cp310-win_amd64.pyd +0 -0
  54. amsdal/cloud/services/actions/list_secrets.pyi +18 -1
  55. amsdal/cloud/services/actions/manager.cp310-win_amd64.pyd +0 -0
  56. amsdal/cloud/services/actions/manager.pyi +254 -20
  57. amsdal/cloud/services/actions/signup_action.cp310-win_amd64.pyd +0 -0
  58. amsdal/cloud/services/actions/signup_action.pyi +16 -1
  59. amsdal/cloud/services/actions/update_deploy.cp310-win_amd64.pyd +0 -0
  60. amsdal/cloud/services/actions/update_deploy.pyi +15 -1
  61. amsdal/cloud/services/auth/__init__.cp310-win_amd64.pyd +0 -0
  62. amsdal/cloud/services/auth/base.cp310-win_amd64.pyd +0 -0
  63. amsdal/cloud/services/auth/credentials.cp310-win_amd64.pyd +0 -0
  64. amsdal/cloud/services/auth/credentials.pyi +12 -1
  65. amsdal/cloud/services/auth/manager.cp310-win_amd64.pyd +0 -0
  66. amsdal/cloud/services/auth/manager.pyi +15 -1
  67. amsdal/cloud/services/auth/signup_service.cp310-win_amd64.pyd +0 -0
  68. amsdal/cloud/services/auth/signup_service.pyi +16 -1
  69. amsdal/cloud/services/auth/token.cp310-win_amd64.pyd +0 -0
  70. amsdal/cloud/services/auth/token.pyi +15 -1
  71. amsdal/configs/constants.py +10 -0
  72. amsdal/configs/constants.pyi +11 -1
  73. amsdal/configs/main.py +132 -19
  74. amsdal/configs/main.pyi +140 -10
  75. amsdal/context/manager.py +39 -0
  76. amsdal/context/manager.pyi +41 -3
  77. amsdal/contrib/__init__.cp310-win_amd64.pyd +0 -0
  78. amsdal/contrib/auth/app.py +12 -0
  79. amsdal/contrib/auth/app.pyi +12 -1
  80. amsdal/contrib/auth/lifecycle/consumer.py +53 -0
  81. amsdal/contrib/auth/lifecycle/consumer.pyi +53 -3
  82. amsdal/contrib/auth/models/login_session/hooks/pre_init.py +13 -0
  83. amsdal/contrib/auth/models/login_session/modifiers/display_name.py +8 -0
  84. amsdal/contrib/auth/models/permission/modifiers/display_name.py +8 -0
  85. amsdal/contrib/auth/models/user/hooks/post_init.py +13 -0
  86. amsdal/contrib/auth/models/user/hooks/pre_create.py +6 -0
  87. amsdal/contrib/auth/models/user/modifiers/display_name.py +8 -0
  88. amsdal/contrib/auth/settings.py +15 -0
  89. amsdal/contrib/auth/settings.pyi +14 -0
  90. amsdal/contrib/frontend_configs/app.py +14 -0
  91. amsdal/contrib/frontend_configs/app.pyi +14 -1
  92. amsdal/contrib/frontend_configs/conversion/convert.py +14 -0
  93. amsdal/contrib/frontend_configs/conversion/convert.pyi +15 -1
  94. amsdal/contrib/frontend_configs/lifecycle/consumer.py +75 -3
  95. amsdal/contrib/frontend_configs/lifecycle/consumer.pyi +77 -6
  96. amsdal/contrib/frontend_configs/models/frontent_config_control_action/properties/action_validate.py +16 -0
  97. amsdal/contrib/frontend_configs/utils.py +12 -1
  98. amsdal/contrib/frontend_configs/utils.pyi +12 -1
  99. amsdal/fixtures/__init__.cp310-win_amd64.pyd +0 -0
  100. amsdal/fixtures/manager.cp310-win_amd64.pyd +0 -0
  101. amsdal/fixtures/manager.pyi +90 -8
  102. amsdal/manager.cp310-win_amd64.pyd +0 -0
  103. amsdal/manager.pyi +113 -25
  104. amsdal/migration/__init__.cp310-win_amd64.pyd +0 -0
  105. amsdal/migration/base_migration_schemas.cp310-win_amd64.pyd +0 -0
  106. amsdal/migration/base_migration_schemas.pyi +84 -8
  107. amsdal/migration/data_classes.cp310-win_amd64.pyd +0 -0
  108. amsdal/migration/data_classes.pyi +104 -4
  109. amsdal/migration/executors/__init__.cp310-win_amd64.pyd +0 -0
  110. amsdal/migration/executors/base.cp310-win_amd64.pyd +0 -0
  111. amsdal/migration/executors/base.pyi +75 -5
  112. amsdal/migration/executors/default_executor.cp310-win_amd64.pyd +0 -0
  113. amsdal/migration/executors/default_executor.pyi +82 -10
  114. amsdal/migration/executors/state_executor.cp310-win_amd64.pyd +0 -0
  115. amsdal/migration/executors/state_executor.pyi +69 -5
  116. amsdal/migration/file_migration_executor.cp310-win_amd64.pyd +0 -0
  117. amsdal/migration/file_migration_executor.pyi +34 -2
  118. amsdal/migration/file_migration_generator.cp310-win_amd64.pyd +0 -0
  119. amsdal/migration/file_migration_generator.pyi +102 -10
  120. amsdal/migration/file_migration_store.cp310-win_amd64.pyd +0 -0
  121. amsdal/migration/file_migration_store.pyi +36 -8
  122. amsdal/migration/file_migration_writer.cp310-win_amd64.pyd +0 -0
  123. amsdal/migration/file_migration_writer.pyi +60 -5
  124. amsdal/migration/migrations.cp310-win_amd64.pyd +0 -0
  125. amsdal/migration/migrations.pyi +111 -6
  126. amsdal/migration/migrations_loader.cp310-win_amd64.pyd +0 -0
  127. amsdal/migration/migrations_loader.pyi +17 -2
  128. amsdal/migration/schemas_loaders.cp310-win_amd64.pyd +0 -0
  129. amsdal/migration/schemas_loaders.pyi +15 -2
  130. amsdal/migration/utils.cp310-win_amd64.pyd +0 -0
  131. amsdal/migration/utils.pyi +46 -6
  132. amsdal/mixins/__init__.cp310-win_amd64.pyd +0 -0
  133. amsdal/mixins/build_mixin.cp310-win_amd64.pyd +0 -0
  134. amsdal/mixins/build_mixin.pyi +60 -8
  135. amsdal/mixins/class_versions_mixin.cp310-win_amd64.pyd +0 -0
  136. amsdal/mixins/class_versions_mixin.pyi +3 -7
  137. amsdal/schemas/core/class_object/properties/display_name.py +6 -0
  138. amsdal/schemas/core/file/hooks/pre_create.py +9 -0
  139. amsdal/schemas/core/file/hooks/pre_update.py +9 -0
  140. amsdal/schemas/core/file/properties/from_file.py +12 -0
  141. amsdal/schemas/core/file/properties/mimetype.py +8 -0
  142. amsdal/schemas/core/file/properties/to_file.py +12 -0
  143. amsdal/schemas/core/file/properties/validate_data.py +13 -0
  144. amsdal/schemas/manager.cp310-win_amd64.pyd +0 -0
  145. amsdal/schemas/manager.py +53 -2
  146. amsdal/schemas/manager.pyi +55 -5
  147. amsdal/services/__init__.cp310-win_amd64.pyd +0 -0
  148. amsdal/services/transaction_execution.cp310-win_amd64.pyd +0 -0
  149. amsdal/services/transaction_execution.pyi +52 -3
  150. amsdal/utils/contrib_paths.py +10 -0
  151. amsdal/utils/contrib_paths.pyi +11 -1
  152. amsdal/utils/tests/helpers.py +5 -7
  153. {amsdal-0.1.26.dist-info → amsdal-0.2.0.dist-info}/METADATA +4 -6
  154. amsdal-0.2.0.dist-info/RECORD +254 -0
  155. amsdal/operations/__init__.cp310-win_amd64.pyd +0 -0
  156. amsdal/operations/__init__.pyi +0 -0
  157. amsdal/operations/manager.cp310-win_amd64.pyd +0 -0
  158. amsdal/operations/manager.pyi +0 -24
  159. amsdal-0.1.26.dist-info/RECORD +0 -258
  160. {amsdal-0.1.26.dist-info → amsdal-0.2.0.dist-info}/LICENSE.txt +0 -0
  161. {amsdal-0.1.26.dist-info → amsdal-0.2.0.dist-info}/WHEEL +0 -0
  162. {amsdal-0.1.26.dist-info → amsdal-0.2.0.dist-info}/license_check.py +0 -0
  163. {amsdal-0.1.26.dist-info → amsdal-0.2.0.dist-info}/top_level.txt +0 -0
@@ -1,10 +1,6 @@
1
- from amsdal.migration.utils import object_schema_to_table_schema as object_schema_to_table_schema
2
- from amsdal_models.classes.model import Model
3
-
4
1
  class ClassVersionsMixin:
5
- @classmethod
6
- def _create_table(cls, class_object: Model, *, skip_class_meta: bool = False) -> None: ...
7
- @classmethod
8
- def init_class_versions(cls, *, create_tables: bool = False) -> None: ...
2
+ """
3
+ Mixin class to manage class versions and related table schemas.
4
+ """
9
5
  @staticmethod
10
6
  def register_internal_classes() -> None: ...
@@ -1,3 +1,9 @@
1
1
  @property # type: ignore[misc]
2
2
  def display_name(self) -> str: # type: ignore[no-untyped-def]
3
+ """
4
+ Returns the display name of the object.
5
+
6
+ Returns:
7
+ str: The display name, which is the title of the object.
8
+ """
3
9
  return self.title
@@ -1,2 +1,11 @@
1
1
  def pre_create(self) -> None: # type: ignore[no-untyped-def]
2
+ """
3
+ Prepares the object for creation by setting its size attribute.
4
+
5
+ This method calculates the size of the object's data and assigns it to the size attribute.
6
+ If the data is None, it defaults to an empty byte string.
7
+
8
+ Args:
9
+ None
10
+ """
2
11
  self.size = len(self.data or b'')
@@ -1,2 +1,11 @@
1
1
  def pre_update(self): # type: ignore[no-untyped-def]
2
+ """
3
+ Prepares the object for update by setting its size attribute.
4
+
5
+ This method calculates the size of the object's data and assigns it to the size attribute.
6
+ If the data is None, it defaults to an empty byte string.
7
+
8
+ Args:
9
+ None
10
+ """
2
11
  self.size = len(self.data or b'')
@@ -7,6 +7,18 @@ def from_file(
7
7
  cls,
8
8
  file_or_path: Path | BinaryIO,
9
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
+ """
10
22
  if isinstance(file_or_path, Path):
11
23
  if file_or_path.is_dir():
12
24
  msg = f'{file_or_path} is a directory'
@@ -1,5 +1,13 @@
1
1
  @property # type: ignore[misc]
2
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
+ """
3
11
  import mimetypes
4
12
 
5
13
  return mimetypes.guess_type(self.filename)[0]
@@ -3,6 +3,18 @@ from typing import BinaryIO
3
3
 
4
4
 
5
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
+ """
6
18
  if isinstance(file_or_path, Path):
7
19
  if file_or_path.is_dir():
8
20
  file_or_path = file_or_path / self.name
@@ -6,6 +6,19 @@ from pydantic import field_validator
6
6
  @field_validator('data') # type: ignore[misc]
7
7
  @classmethod
8
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
+ """
9
22
  is_base64: bool = False
10
23
 
11
24
  try:
Binary file
amsdal/schemas/manager.py CHANGED
@@ -1,6 +1,6 @@
1
- from amsdal_models.enums import BaseClasses
2
- from amsdal_models.schemas.data_models.schema import ObjectSchema
3
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
4
  from amsdal_utils.models.enums import SchemaTypes
5
5
  from amsdal_utils.utils.singleton import Singleton
6
6
 
@@ -8,13 +8,39 @@ from amsdal.configs.main import settings
8
8
 
9
9
 
10
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
+
11
18
  def __init__(self) -> None:
12
19
  self._schema_manager_handler = SchemaManagerHandler(settings.schemas_root_path)
13
20
 
14
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
+ """
15
31
  self._schema_manager_handler.invalidate_user_schemas()
16
32
 
17
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
+ """
18
44
  return (
19
45
  [
20
46
  (type_schema, SchemaTypes.TYPE)
@@ -41,6 +67,19 @@ class SchemaManager(metaclass=Singleton):
41
67
  return 2
42
68
 
43
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
+ """
44
83
  _schemas = self.get_schemas(schema_type)
45
84
 
46
85
  for schema in _schemas:
@@ -50,6 +89,18 @@ class SchemaManager(metaclass=Singleton):
50
89
  return None
51
90
 
52
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
+ """
53
104
  if schema_type == SchemaTypes.CONTRIB:
54
105
  return self._schema_manager_handler.contrib_schemas
55
106
 
@@ -1,15 +1,65 @@
1
1
  from _typeshed import Incomplete
2
2
  from amsdal.configs.main import settings as settings
3
- from amsdal_models.schemas.data_models.schema import ObjectSchema
3
+ from amsdal_utils.models.data_models.schema import ObjectSchema as ObjectSchema
4
4
  from amsdal_utils.models.enums import SchemaTypes
5
5
  from amsdal_utils.utils.singleton import Singleton
6
6
 
7
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
+ """
8
14
  _schema_manager_handler: Incomplete
9
15
  def __init__(self) -> None: ...
10
- def invalidate_user_schemas(self) -> None: ...
11
- def class_schemas(self) -> list[tuple[ObjectSchema, SchemaTypes]]: ...
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
+ """
12
37
  @staticmethod
13
38
  def _sort_key_for_schema(schema: ObjectSchema) -> int: ...
14
- def get_schema_by_name(self, title: str, schema_type: SchemaTypes | None = None) -> ObjectSchema | None: ...
15
- def get_schemas(self, schema_type: SchemaTypes | None = None) -> list[ObjectSchema]: ...
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
+ """
@@ -9,13 +9,62 @@ from typing import Any
9
9
 
10
10
  logger: Incomplete
11
11
 
12
- def is_transaction(statement: ast.AST) -> bool: ...
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
+ """
13
25
 
14
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
+ """
15
34
  _transactions: Incomplete
16
35
  def __init__(self) -> None: ...
17
- def execute_transaction(self, transaction_name: str, args: dict[str, Any], *, load_references: bool = True) -> Any: ...
18
- def get_transaction_func(self, transaction_name: str) -> Callable[..., Any]: ...
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
+ """
19
68
  @staticmethod
20
69
  def _run_async_transaction(transaction_func: Callable[..., Any], args: dict[str, Any]) -> Any: ...
21
70
  def _load_transaction(self, transaction_name: str) -> Callable[..., Any]: ...
@@ -4,6 +4,16 @@ from pathlib import Path
4
4
 
5
5
 
6
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
+ """
7
17
  from amsdal.configs.main import settings
8
18
 
9
19
  for contrib in settings.CONTRIB:
@@ -1,4 +1,14 @@
1
1
  from collections.abc import Generator
2
2
  from pathlib import Path
3
3
 
4
- def get_contrib_schemas_paths() -> Generator[Path, None, None]: ...
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
+ """
@@ -35,24 +35,23 @@ TESTS_DIR = Path(os.getcwd())
35
35
 
36
36
 
37
37
  def create_postgres_database(database: str) -> tuple[str, str, str, str]:
38
- import psycopg2
39
- from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT
38
+ import psycopg
40
39
 
41
40
  db_host = os.getenv('POSTGRES_HOST', 'localhost')
42
41
  db_port = os.getenv('POSTGRES_PORT', '5432')
43
42
  db_user = os.getenv('POSTGRES_USER', 'postgres')
44
43
  db_password = os.getenv('POSTGRES_PASSWORD', 'example')
45
44
 
46
- conn = psycopg2.connect(
45
+ conn = psycopg.connect(
47
46
  host=db_host,
48
47
  port=db_port,
49
48
  user=db_user,
50
49
  password=db_password,
50
+ autocommit=True,
51
51
  )
52
- conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
53
52
  cur = conn.cursor()
54
53
 
55
- with suppress(psycopg2.errors.DuplicateDatabase):
54
+ with suppress(psycopg.errors.DuplicateDatabase):
56
55
  cur.execute(f'CREATE DATABASE "{database}"')
57
56
 
58
57
  cur.close()
@@ -210,7 +209,7 @@ def init_manager(
210
209
  config_manager.load_config(config_path)
211
210
  manager = AmsdalManager()
212
211
  manager.setup()
213
- manager.post_setup()
212
+ manager.post_setup() # type: ignore[call-arg]
214
213
 
215
214
  try:
216
215
  yield manager
@@ -306,6 +305,5 @@ def init_manager_and_migrate(
306
305
  manager.authenticate()
307
306
  migrate(app_schemas_path)
308
307
  manager.init_classes()
309
- manager.init_class_versions()
310
308
 
311
309
  yield manager
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: amsdal
3
- Version: 0.1.26
3
+ Version: 0.2.0
4
4
  Summary: AMSDAL
5
5
  License: AMSDAL End User License Agreement
6
6
 
@@ -130,17 +130,15 @@ Requires-Dist: cryptography ~=42.0
130
130
  Requires-Dist: httpx ~=0.25
131
131
  Requires-Dist: bcrypt ~=4.0
132
132
  Requires-Dist: black >=24.3.0
133
- Requires-Dist: amsdal-utils ==0.1.*
134
- Requires-Dist: amsdal-data[postgres] ==0.1.*
135
- Requires-Dist: amsdal-models ==0.1.*
133
+ Requires-Dist: amsdal-utils ==0.2.*
134
+ Requires-Dist: amsdal-data[postgres-binary] ==0.2.*
135
+ Requires-Dist: amsdal-models ==0.2.*
136
136
  Provides-Extra: celery
137
137
  Requires-Dist: celery ==5.4.0 ; extra == 'celery'
138
138
  Provides-Extra: cli
139
139
  Requires-Dist: amsdal-cli ==0.1.* ; extra == 'cli'
140
140
  Provides-Extra: factory
141
141
  Requires-Dist: polyfactory ==2.* ; extra == 'factory'
142
- Provides-Extra: redis-lock
143
- Requires-Dist: amsdal-data[redis-lock] ==0.1.* ; extra == 'redis-lock'
144
142
  Provides-Extra: server
145
143
  Requires-Dist: amsdal-server ==0.1.* ; extra == 'server'
146
144