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.

Files changed (254) hide show
  1. amsdal/Third-Party Materials - AMSDAL Dependencies - License Notices.md +1308 -0
  2. amsdal/__about__.py +4 -0
  3. amsdal/__about__.pyi +1 -0
  4. amsdal/__init__.py +3 -0
  5. amsdal/__init__.pyi +0 -0
  6. amsdal/__migrations__/0000_initial.py +203 -0
  7. amsdal/__migrations__/0001_datetime_type.py +18 -0
  8. amsdal/__migrations__/0002_fixture_order.py +40 -0
  9. amsdal/cloud/__init__.cp312-win_amd64.pyd +0 -0
  10. amsdal/cloud/__init__.pyi +0 -0
  11. amsdal/cloud/client.cp312-win_amd64.pyd +0 -0
  12. amsdal/cloud/client.pyi +57 -0
  13. amsdal/cloud/constants.cp312-win_amd64.pyd +0 -0
  14. amsdal/cloud/constants.pyi +13 -0
  15. amsdal/cloud/enums.cp312-win_amd64.pyd +0 -0
  16. amsdal/cloud/enums.pyi +68 -0
  17. amsdal/cloud/models/__init__.cp312-win_amd64.pyd +0 -0
  18. amsdal/cloud/models/__init__.pyi +0 -0
  19. amsdal/cloud/models/base.cp312-win_amd64.pyd +0 -0
  20. amsdal/cloud/models/base.pyi +247 -0
  21. amsdal/cloud/services/__init__.cp312-win_amd64.pyd +0 -0
  22. amsdal/cloud/services/__init__.pyi +0 -0
  23. amsdal/cloud/services/actions/__init__.cp312-win_amd64.pyd +0 -0
  24. amsdal/cloud/services/actions/__init__.pyi +0 -0
  25. amsdal/cloud/services/actions/add_allowlist_ip.cp312-win_amd64.pyd +0 -0
  26. amsdal/cloud/services/actions/add_allowlist_ip.pyi +19 -0
  27. amsdal/cloud/services/actions/add_basic_auth.cp312-win_amd64.pyd +0 -0
  28. amsdal/cloud/services/actions/add_basic_auth.pyi +21 -0
  29. amsdal/cloud/services/actions/add_dependency.cp312-win_amd64.pyd +0 -0
  30. amsdal/cloud/services/actions/add_dependency.pyi +19 -0
  31. amsdal/cloud/services/actions/add_secret.cp312-win_amd64.pyd +0 -0
  32. amsdal/cloud/services/actions/add_secret.pyi +20 -0
  33. amsdal/cloud/services/actions/base.cp312-win_amd64.pyd +0 -0
  34. amsdal/cloud/services/actions/base.pyi +122 -0
  35. amsdal/cloud/services/actions/create_deploy.cp312-win_amd64.pyd +0 -0
  36. amsdal/cloud/services/actions/create_deploy.pyi +41 -0
  37. amsdal/cloud/services/actions/create_env.cp312-win_amd64.pyd +0 -0
  38. amsdal/cloud/services/actions/create_env.pyi +19 -0
  39. amsdal/cloud/services/actions/create_session.cp312-win_amd64.pyd +0 -0
  40. amsdal/cloud/services/actions/create_session.pyi +17 -0
  41. amsdal/cloud/services/actions/delete_allowlist_ip.cp312-win_amd64.pyd +0 -0
  42. amsdal/cloud/services/actions/delete_allowlist_ip.pyi +19 -0
  43. amsdal/cloud/services/actions/delete_basic_auth.cp312-win_amd64.pyd +0 -0
  44. amsdal/cloud/services/actions/delete_basic_auth.pyi +20 -0
  45. amsdal/cloud/services/actions/delete_dependency.cp312-win_amd64.pyd +0 -0
  46. amsdal/cloud/services/actions/delete_dependency.pyi +21 -0
  47. amsdal/cloud/services/actions/delete_env.cp312-win_amd64.pyd +0 -0
  48. amsdal/cloud/services/actions/delete_env.pyi +21 -0
  49. amsdal/cloud/services/actions/delete_secret.cp312-win_amd64.pyd +0 -0
  50. amsdal/cloud/services/actions/delete_secret.pyi +21 -0
  51. amsdal/cloud/services/actions/destroy_deploy.cp312-win_amd64.pyd +0 -0
  52. amsdal/cloud/services/actions/destroy_deploy.pyi +18 -0
  53. amsdal/cloud/services/actions/expose_db.cp312-win_amd64.pyd +0 -0
  54. amsdal/cloud/services/actions/expose_db.pyi +22 -0
  55. amsdal/cloud/services/actions/get_basic_auth_credentials.cp312-win_amd64.pyd +0 -0
  56. amsdal/cloud/services/actions/get_basic_auth_credentials.pyi +21 -0
  57. amsdal/cloud/services/actions/get_monitoring_info.cp312-win_amd64.pyd +0 -0
  58. amsdal/cloud/services/actions/get_monitoring_info.pyi +21 -0
  59. amsdal/cloud/services/actions/list_dependencies.cp312-win_amd64.pyd +0 -0
  60. amsdal/cloud/services/actions/list_dependencies.pyi +21 -0
  61. amsdal/cloud/services/actions/list_deploys.cp312-win_amd64.pyd +0 -0
  62. amsdal/cloud/services/actions/list_deploys.pyi +19 -0
  63. amsdal/cloud/services/actions/list_envs.cp312-win_amd64.pyd +0 -0
  64. amsdal/cloud/services/actions/list_envs.pyi +20 -0
  65. amsdal/cloud/services/actions/list_secrets.cp312-win_amd64.pyd +0 -0
  66. amsdal/cloud/services/actions/list_secrets.pyi +22 -0
  67. amsdal/cloud/services/actions/manager.cp312-win_amd64.pyd +0 -0
  68. amsdal/cloud/services/actions/manager.pyi +278 -0
  69. amsdal/cloud/services/actions/signup_action.cp312-win_amd64.pyd +0 -0
  70. amsdal/cloud/services/actions/signup_action.pyi +20 -0
  71. amsdal/cloud/services/actions/update_deploy.cp312-win_amd64.pyd +0 -0
  72. amsdal/cloud/services/actions/update_deploy.pyi +19 -0
  73. amsdal/cloud/services/auth/__init__.cp312-win_amd64.pyd +0 -0
  74. amsdal/cloud/services/auth/__init__.pyi +0 -0
  75. amsdal/cloud/services/auth/base.cp312-win_amd64.pyd +0 -0
  76. amsdal/cloud/services/auth/base.pyi +6 -0
  77. amsdal/cloud/services/auth/credentials.cp312-win_amd64.pyd +0 -0
  78. amsdal/cloud/services/auth/credentials.pyi +31 -0
  79. amsdal/cloud/services/auth/manager.cp312-win_amd64.pyd +0 -0
  80. amsdal/cloud/services/auth/manager.pyi +26 -0
  81. amsdal/cloud/services/auth/signup_service.cp312-win_amd64.pyd +0 -0
  82. amsdal/cloud/services/auth/signup_service.pyi +32 -0
  83. amsdal/cloud/services/auth/token.cp312-win_amd64.pyd +0 -0
  84. amsdal/cloud/services/auth/token.pyi +28 -0
  85. amsdal/configs/__init__.py +0 -0
  86. amsdal/configs/__init__.pyi +0 -0
  87. amsdal/configs/constants.py +33 -0
  88. amsdal/configs/constants.pyi +22 -0
  89. amsdal/configs/main.py +254 -0
  90. amsdal/configs/main.pyi +177 -0
  91. amsdal/context/__init__.py +0 -0
  92. amsdal/context/__init__.pyi +0 -0
  93. amsdal/context/manager.py +69 -0
  94. amsdal/context/manager.pyi +50 -0
  95. amsdal/contrib/__init__.cp312-win_amd64.pyd +0 -0
  96. amsdal/contrib/__init__.pyi +0 -0
  97. amsdal/contrib/app_config.py +7 -0
  98. amsdal/contrib/app_config.pyi +6 -0
  99. amsdal/contrib/auth/__init__.py +0 -0
  100. amsdal/contrib/auth/__init__.pyi +0 -0
  101. amsdal/contrib/auth/app.py +27 -0
  102. amsdal/contrib/auth/app.pyi +15 -0
  103. amsdal/contrib/auth/decorators/__init__.py +20 -0
  104. amsdal/contrib/auth/decorators/__init__.pyi +6 -0
  105. amsdal/contrib/auth/errors.py +7 -0
  106. amsdal/contrib/auth/errors.pyi +4 -0
  107. amsdal/contrib/auth/lifecycle/__init__.py +0 -0
  108. amsdal/contrib/auth/lifecycle/__init__.pyi +0 -0
  109. amsdal/contrib/auth/lifecycle/consumer.py +222 -0
  110. amsdal/contrib/auth/lifecycle/consumer.pyi +69 -0
  111. amsdal/contrib/auth/migrations/0000_initial.py +49 -0
  112. amsdal/contrib/auth/models/login_session/hooks/pre_init.py +64 -0
  113. amsdal/contrib/auth/models/login_session/model.json +23 -0
  114. amsdal/contrib/auth/models/login_session/modifiers/display_name.py +11 -0
  115. amsdal/contrib/auth/models/permission/fixtures/basic_permissions.json +62 -0
  116. amsdal/contrib/auth/models/permission/model.json +18 -0
  117. amsdal/contrib/auth/models/permission/modifiers/display_name.py +11 -0
  118. amsdal/contrib/auth/models/user/hooks/post_init.py +58 -0
  119. amsdal/contrib/auth/models/user/hooks/pre_create.py +8 -0
  120. amsdal/contrib/auth/models/user/model.json +25 -0
  121. amsdal/contrib/auth/models/user/modifiers/display_name.py +19 -0
  122. amsdal/contrib/auth/settings.py +36 -0
  123. amsdal/contrib/auth/settings.pyi +26 -0
  124. amsdal/contrib/frontend_configs/__init__.py +0 -0
  125. amsdal/contrib/frontend_configs/__init__.pyi +0 -0
  126. amsdal/contrib/frontend_configs/app.py +24 -0
  127. amsdal/contrib/frontend_configs/app.pyi +19 -0
  128. amsdal/contrib/frontend_configs/constants.py +1 -0
  129. amsdal/contrib/frontend_configs/constants.pyi +1 -0
  130. amsdal/contrib/frontend_configs/conversion/__init__.py +5 -0
  131. amsdal/contrib/frontend_configs/conversion/__init__.pyi +3 -0
  132. amsdal/contrib/frontend_configs/conversion/convert.py +250 -0
  133. amsdal/contrib/frontend_configs/conversion/convert.pyi +23 -0
  134. amsdal/contrib/frontend_configs/lifecycle/__init__.py +0 -0
  135. amsdal/contrib/frontend_configs/lifecycle/__init__.pyi +0 -0
  136. amsdal/contrib/frontend_configs/lifecycle/consumer.py +242 -0
  137. amsdal/contrib/frontend_configs/lifecycle/consumer.pyi +86 -0
  138. amsdal/contrib/frontend_configs/migrations/0000_initial.py +255 -0
  139. amsdal/contrib/frontend_configs/models/frontend_activator_config/model.json +11 -0
  140. amsdal/contrib/frontend_configs/models/frontend_config_async_validator/model.json +11 -0
  141. amsdal/contrib/frontend_configs/models/frontend_config_group_validator/model.json +52 -0
  142. amsdal/contrib/frontend_configs/models/frontend_config_option/model.json +15 -0
  143. amsdal/contrib/frontend_configs/models/frontend_config_skip_none_base/model.json +6 -0
  144. amsdal/contrib/frontend_configs/models/frontend_config_skip_none_base/properties/model_dump.py +13 -0
  145. amsdal/contrib/frontend_configs/models/frontend_config_slider_option/model.json +19 -0
  146. amsdal/contrib/frontend_configs/models/frontend_config_text_mask/model.json +26 -0
  147. amsdal/contrib/frontend_configs/models/frontend_config_validator/model.json +41 -0
  148. amsdal/contrib/frontend_configs/models/frontend_control_config/model.json +250 -0
  149. amsdal/contrib/frontend_configs/models/frontend_model_config/fixtures/permissions.json +24 -0
  150. amsdal/contrib/frontend_configs/models/frontend_model_config/model.json +17 -0
  151. amsdal/contrib/frontend_configs/models/frontent_config_control_action/model.json +54 -0
  152. amsdal/contrib/frontend_configs/models/frontent_config_control_action/properties/action_validate.py +33 -0
  153. amsdal/contrib/frontend_configs/utils.py +29 -0
  154. amsdal/contrib/frontend_configs/utils.pyi +17 -0
  155. amsdal/errors.py +31 -0
  156. amsdal/errors.pyi +12 -0
  157. amsdal/fixtures/__init__.cp312-win_amd64.pyd +0 -0
  158. amsdal/fixtures/__init__.pyi +0 -0
  159. amsdal/fixtures/manager.cp312-win_amd64.pyd +0 -0
  160. amsdal/fixtures/manager.pyi +118 -0
  161. amsdal/manager.cp312-win_amd64.pyd +0 -0
  162. amsdal/manager.pyi +183 -0
  163. amsdal/migration/__init__.cp312-win_amd64.pyd +0 -0
  164. amsdal/migration/__init__.pyi +0 -0
  165. amsdal/migration/base_migration_schemas.cp312-win_amd64.pyd +0 -0
  166. amsdal/migration/base_migration_schemas.pyi +120 -0
  167. amsdal/migration/data_classes.cp312-win_amd64.pyd +0 -0
  168. amsdal/migration/data_classes.pyi +178 -0
  169. amsdal/migration/executors/__init__.cp312-win_amd64.pyd +0 -0
  170. amsdal/migration/executors/__init__.pyi +0 -0
  171. amsdal/migration/executors/base.cp312-win_amd64.pyd +0 -0
  172. amsdal/migration/executors/base.pyi +106 -0
  173. amsdal/migration/executors/default_executor.cp312-win_amd64.pyd +0 -0
  174. amsdal/migration/executors/default_executor.pyi +96 -0
  175. amsdal/migration/executors/state_executor.cp312-win_amd64.pyd +0 -0
  176. amsdal/migration/executors/state_executor.pyi +78 -0
  177. amsdal/migration/file_migration_executor.cp312-win_amd64.pyd +0 -0
  178. amsdal/migration/file_migration_executor.pyi +68 -0
  179. amsdal/migration/file_migration_generator.cp312-win_amd64.pyd +0 -0
  180. amsdal/migration/file_migration_generator.pyi +139 -0
  181. amsdal/migration/file_migration_store.cp312-win_amd64.pyd +0 -0
  182. amsdal/migration/file_migration_store.pyi +61 -0
  183. amsdal/migration/file_migration_writer.cp312-win_amd64.pyd +0 -0
  184. amsdal/migration/file_migration_writer.pyi +73 -0
  185. amsdal/migration/migrations.cp312-win_amd64.pyd +0 -0
  186. amsdal/migration/migrations.pyi +166 -0
  187. amsdal/migration/migrations_loader.cp312-win_amd64.pyd +0 -0
  188. amsdal/migration/migrations_loader.pyi +32 -0
  189. amsdal/migration/schemas_loaders.cp312-win_amd64.pyd +0 -0
  190. amsdal/migration/schemas_loaders.pyi +37 -0
  191. amsdal/migration/templates/data_migration.tmpl +18 -0
  192. amsdal/migration/templates/dict_validator.tmpl +4 -0
  193. amsdal/migration/templates/migration.tmpl +6 -0
  194. amsdal/migration/templates/model_class.tmpl +8 -0
  195. amsdal/migration/templates/model_class_layout.tmpl +24 -0
  196. amsdal/migration/templates/options_validator.tmpl +4 -0
  197. amsdal/migration/utils.cp312-win_amd64.pyd +0 -0
  198. amsdal/migration/utils.pyi +58 -0
  199. amsdal/mixins/__init__.cp312-win_amd64.pyd +0 -0
  200. amsdal/mixins/__init__.pyi +0 -0
  201. amsdal/mixins/build_mixin.cp312-win_amd64.pyd +0 -0
  202. amsdal/mixins/build_mixin.pyi +78 -0
  203. amsdal/mixins/class_versions_mixin.cp312-win_amd64.pyd +0 -0
  204. amsdal/mixins/class_versions_mixin.pyi +6 -0
  205. amsdal/py.typed +0 -0
  206. amsdal/schemas/__init__.py +0 -0
  207. amsdal/schemas/__init__.pyi +0 -0
  208. amsdal/schemas/core/class_object/model.json +31 -0
  209. amsdal/schemas/core/class_object/properties/display_name.py +9 -0
  210. amsdal/schemas/core/class_object_meta/model.json +55 -0
  211. amsdal/schemas/core/class_property/model.json +22 -0
  212. amsdal/schemas/core/class_property_meta/model.json +23 -0
  213. amsdal/schemas/core/file/hooks/pre_create.py +11 -0
  214. amsdal/schemas/core/file/hooks/pre_update.py +11 -0
  215. amsdal/schemas/core/file/model.json +23 -0
  216. amsdal/schemas/core/file/properties/from_file.py +34 -0
  217. amsdal/schemas/core/file/properties/mimetype.py +13 -0
  218. amsdal/schemas/core/file/properties/str.py +6 -0
  219. amsdal/schemas/core/file/properties/to_file.py +24 -0
  220. amsdal/schemas/core/file/properties/validate_data.py +32 -0
  221. amsdal/schemas/core/fixture/model.json +35 -0
  222. amsdal/schemas/core/option/model.json +19 -0
  223. amsdal/schemas/core/validator/model.json +19 -0
  224. amsdal/schemas/manager.cp312-win_amd64.pyd +0 -0
  225. amsdal/schemas/manager.py +116 -0
  226. amsdal/schemas/manager.pyi +65 -0
  227. amsdal/schemas/types/anything/model.json +7 -0
  228. amsdal/schemas/types/array/model.json +7 -0
  229. amsdal/schemas/types/binary/model.json +7 -0
  230. amsdal/schemas/types/boolean/model.json +17 -0
  231. amsdal/schemas/types/date/model.json +7 -0
  232. amsdal/schemas/types/datetime/model.json +7 -0
  233. amsdal/schemas/types/dictionary/model.json +8 -0
  234. amsdal/schemas/types/number/model.json +8 -0
  235. amsdal/schemas/types/object/model.json +53 -0
  236. amsdal/schemas/types/string/model.json +8 -0
  237. amsdal/services/__init__.cp312-win_amd64.pyd +0 -0
  238. amsdal/services/__init__.pyi +0 -0
  239. amsdal/services/transaction_execution.cp312-win_amd64.pyd +0 -0
  240. amsdal/services/transaction_execution.pyi +76 -0
  241. amsdal/utils/__init__.py +0 -0
  242. amsdal/utils/__init__.pyi +0 -0
  243. amsdal/utils/contrib_paths.py +23 -0
  244. amsdal/utils/contrib_paths.pyi +14 -0
  245. amsdal/utils/tests/__init__.py +0 -0
  246. amsdal/utils/tests/enums.py +18 -0
  247. amsdal/utils/tests/factories.py +49 -0
  248. amsdal/utils/tests/helpers.py +309 -0
  249. amsdal-0.2.5.dist-info/LICENSE.txt +107 -0
  250. amsdal-0.2.5.dist-info/METADATA +366 -0
  251. amsdal-0.2.5.dist-info/RECORD +254 -0
  252. amsdal-0.2.5.dist-info/WHEEL +5 -0
  253. amsdal-0.2.5.dist-info/license_check.py +35 -0
  254. amsdal-0.2.5.dist-info/top_level.txt +1 -0
@@ -0,0 +1,32 @@
1
+ from _typeshed import Incomplete
2
+ from amsdal.cloud.services.actions.signup_action import FreeSignupAction as FreeSignupAction
3
+ from amsdal.configs.main import settings as settings
4
+
5
+ LICENCE_PATH: Incomplete
6
+ LICENCE_MESSAGE: Incomplete
7
+
8
+ def _input(msg: str) -> str: ...
9
+ def _print(msg: str) -> None: ...
10
+ def want_signup_input() -> str: ...
11
+ def licence_input() -> str: ...
12
+ def organization_name_input() -> str: ...
13
+ def email_input() -> str: ...
14
+
15
+ class SignupService:
16
+ """
17
+ Service to handle the signup process for the Amsdal Framework.
18
+
19
+ This class provides functionality to prompt the user for signup details, validate the license agreement,
20
+ and create credentials for the user.
21
+ """
22
+ @classmethod
23
+ def signup_prompt(cls) -> bool:
24
+ """
25
+ Prompts the user to sign up for the Amsdal Framework.
26
+
27
+ This method guides the user through the signup process, including accepting the license agreement and
28
+ entering organization and email details. It then creates credentials for the user.
29
+
30
+ Returns:
31
+ bool: True if the signup process is completed successfully, False otherwise.
32
+ """
@@ -0,0 +1,28 @@
1
+ from _typeshed import Incomplete
2
+ from amsdal.cloud.constants import JWT_PUBLIC_KEY as JWT_PUBLIC_KEY
3
+ from amsdal.cloud.services.auth.base import AuthHandlerBase as AuthHandlerBase
4
+ from amsdal.errors import AmsdalAuthenticationError as AmsdalAuthenticationError
5
+ from amsdal.schemas.manager import SchemaManager as SchemaManager
6
+
7
+ HMAC_KEY: bytes
8
+
9
+ class TokenAuthHandler(AuthHandlerBase):
10
+ """
11
+ Handles authentication using a token.
12
+
13
+ This class provides functionality to authenticate using a JWT token and validate its checksum.
14
+ """
15
+ __token: Incomplete
16
+ public_key: Incomplete
17
+ def __init__(self, token: str | None, public_key: str = ...) -> None: ...
18
+ def _validate_checksum(self, expected_checksum: str) -> None: ...
19
+ def validate_credentials(self) -> None:
20
+ """
21
+ Validates the provided JWT token.
22
+
23
+ This method decodes the token and validates its checksum or expiration date.
24
+
25
+ Raises:
26
+ AmsdalAuthenticationError: If the token is expired, has an invalid signature, is invalid, or is missing
27
+ an expiration date.
28
+ """
File without changes
File without changes
@@ -0,0 +1,33 @@
1
+ import sys
2
+ from pathlib import Path
3
+
4
+ BASE_DIR = Path(__file__).resolve().parent.parent
5
+
6
+ TYPE_SCHEMAS_PATH: Path = BASE_DIR / 'schemas' / 'types'
7
+ CORE_SCHEMAS_PATH: Path = BASE_DIR / 'schemas' / 'core'
8
+
9
+ CORE_MIGRATIONS_PATH: Path = BASE_DIR / '__migrations__'
10
+
11
+ # Environment
12
+ TESTING_ENVIRONMENT = 'testing'
13
+ DEVELOPMENT_ENVIRONMENT = 'development'
14
+ PRODUCTION_ENVIRONMENT = 'production'
15
+
16
+
17
+ def get_default_environment() -> str:
18
+ """
19
+ Determines the default environment based on the command used to run the script.
20
+
21
+ This function checks the command used to run the script and returns the appropriate
22
+ environment string. If the script is run using `pytest`, it returns 'testing'. Otherwise,
23
+ it returns 'development'.
24
+
25
+ Returns:
26
+ str: The default environment string, either 'testing' or 'development'.
27
+ """
28
+ cmd = sys.argv[0] if sys.argv else ''
29
+
30
+ if 'pytest' in cmd:
31
+ return TESTING_ENVIRONMENT
32
+
33
+ return DEVELOPMENT_ENVIRONMENT
@@ -0,0 +1,22 @@
1
+ from _typeshed import Incomplete
2
+ from pathlib import Path
3
+
4
+ BASE_DIR: Incomplete
5
+ TYPE_SCHEMAS_PATH: Path
6
+ CORE_SCHEMAS_PATH: Path
7
+ CORE_MIGRATIONS_PATH: Path
8
+ TESTING_ENVIRONMENT: str
9
+ DEVELOPMENT_ENVIRONMENT: str
10
+ PRODUCTION_ENVIRONMENT: str
11
+
12
+ def get_default_environment() -> str:
13
+ """
14
+ Determines the default environment based on the command used to run the script.
15
+
16
+ This function checks the command used to run the script and returns the appropriate
17
+ environment string. If the script is run using `pytest`, it returns 'testing'. Otherwise,
18
+ it returns 'development'.
19
+
20
+ Returns:
21
+ str: The default environment string, either 'testing' or 'development'.
22
+ """
amsdal/configs/main.py ADDED
@@ -0,0 +1,254 @@
1
+ import importlib
2
+ from pathlib import Path
3
+ from typing import TYPE_CHECKING
4
+ from typing import Any
5
+ from typing import TypeAlias
6
+
7
+ from pydantic import field_validator
8
+ from pydantic import model_validator
9
+ from pydantic_settings import BaseSettings
10
+ from pydantic_settings import SettingsConfigDict
11
+
12
+
13
+ class Settings(BaseSettings):
14
+ """
15
+ Configuration settings for the application.
16
+
17
+ This class defines the configuration settings for the application, including paths,
18
+ environment variables, and other settings.
19
+
20
+ Attributes:
21
+ model_config (SettingsConfigDict): Configuration for the settings model.
22
+ APP_PATH (Path): Path to the app directory where the generated models and other files will be placed.
23
+ CONFIG_PATH (Path | None): Path to the config.yml file. If not specified, the default APP_PATH/config.yml
24
+ file will be used.
25
+ MODELS_MODULE_NAME (str): The models module name. The generated models will be placed in this module.
26
+ SCHEMAS_MODULE_NAME (str): The schemas module name. The schemas will be placed in this module.
27
+ FIXTURES_MODULE_NAME (str): The fixtures module name. The fixtures will be placed in this module.
28
+ STATIC_MODULE_NAME (str): The static module name. The static files will be placed in this module.
29
+ TRANSACTIONS_MODULE_NAME (str): The transactions module name. The transactions will be placed in this module.
30
+ MIGRATIONS_DIRECTORY_NAME (str): The migrations directory name. The migration files will be placed in this
31
+ folder.
32
+ ACCESS_KEY_ID (str | None): The access key that you will get during registering process.
33
+ SECRET_ACCESS_KEY (str | None): The secret access key that you will get during registering process.
34
+ ACCESS_TOKEN (str | None): The access token that you will get during sign in process.
35
+ SANDBOX_ENVIRONMENT (bool | None): If True, the sandbox environment will be used. If False,
36
+ the cloud environment will be used.
37
+ CONTRIBS (list[str]): List of contrib modules that will be loaded and used.
38
+ Can be specified via environment variable AMSDAL_CONTRIBS as comma separated string.
39
+ """
40
+
41
+ model_config = SettingsConfigDict(
42
+ case_sensitive=True,
43
+ env_prefix='AMSDAL_',
44
+ env_file='.env',
45
+ env_file_encoding='utf-8',
46
+ extra='ignore',
47
+ )
48
+
49
+ APP_PATH: Path = Path('.')
50
+ CONFIG_PATH: Path | None = None
51
+ MODELS_MODULE_NAME: str = 'models'
52
+ SCHEMAS_MODULE_NAME: str = 'schemas'
53
+ FIXTURES_MODULE_NAME: str = 'fixtures'
54
+ STATIC_MODULE_NAME: str = 'static'
55
+ TRANSACTIONS_MODULE_NAME: str = 'transactions'
56
+ MIGRATIONS_DIRECTORY_NAME: str = 'migrations'
57
+ ACCESS_KEY_ID: str | None = None
58
+ SECRET_ACCESS_KEY: str | None = None
59
+ ACCESS_TOKEN: str | None = None
60
+ SANDBOX_ENVIRONMENT: bool | None = None
61
+ CONTRIBS: list[str] = [
62
+ 'amsdal.contrib.auth.app.AuthAppConfig',
63
+ 'amsdal.contrib.frontend_configs.app.FrontendConfigAppConfig',
64
+ ]
65
+
66
+ @field_validator('CONTRIBS', mode='after')
67
+ def load_contrib_modules(cls, value: list[str]) -> list[str]: # noqa: N805
68
+ """
69
+ Loads and initializes contrib modules.
70
+
71
+ This method takes a list of contrib module paths, imports each module, and calls the `on_ready` method
72
+ of the `AppConfig` class within each module.
73
+
74
+ Args:
75
+ value (list[str]): A list of contrib module paths in the format 'package.module.ClassName'.
76
+
77
+ Returns:
78
+ list[str]: The same list of contrib module paths after loading and initializing the modules.
79
+ """
80
+ from amsdal.contrib.app_config import AppConfig
81
+
82
+ for contrib_module in value:
83
+ package_name, class_name = contrib_module.rsplit('.', 1)
84
+ _contrib_module = importlib.import_module(package_name)
85
+ app_config_class: type[AppConfig] = getattr(_contrib_module, class_name)
86
+ app_config_class().on_ready()
87
+
88
+ return value
89
+
90
+ @property
91
+ def models_root_path(self) -> Path:
92
+ """
93
+ Returns the root path for models.
94
+
95
+ This property constructs and returns the path to the models directory
96
+ based on the `APP_PATH` and `MODELS_MODULE_NAME` attributes.
97
+
98
+ Returns:
99
+ Path: The root path for the models directory.
100
+ """
101
+ return self.APP_PATH / self.MODELS_MODULE_NAME
102
+
103
+ @property
104
+ def schemas_root_path(self) -> Path:
105
+ """
106
+ Returns the root path for schemas.
107
+
108
+ This property constructs and returns the path to the schemas directory
109
+ based on the `APP_PATH` and `SCHEMAS_MODULE_NAME` attributes.
110
+
111
+ Returns:
112
+ Path: The root path for the schemas directory.
113
+ """
114
+ return self.APP_PATH / self.SCHEMAS_MODULE_NAME
115
+
116
+ @property
117
+ def fixtures_root_path(self) -> Path:
118
+ """
119
+ Returns the root path for fixtures.
120
+
121
+ This property constructs and returns the path to the fixtures directory
122
+ based on the `APP_PATH` and `FIXTURES_MODULE_NAME` attributes.
123
+
124
+ Returns:
125
+ Path: The root path for the fixtures directory.
126
+ """
127
+ return self.APP_PATH / self.FIXTURES_MODULE_NAME
128
+
129
+ @property
130
+ def static_root_path(self) -> Path:
131
+ """
132
+ Returns the root path for static files.
133
+
134
+ This property constructs and returns the path to the static files directory
135
+ based on the `APP_PATH` and `STATIC_MODULE_NAME` attributes.
136
+
137
+ Returns:
138
+ Path: The root path for the static files directory.
139
+ """
140
+ return self.APP_PATH / self.STATIC_MODULE_NAME
141
+
142
+ @property
143
+ def transactions_root_path(self) -> Path:
144
+ """
145
+ Returns the root path for transactions.
146
+
147
+ This property constructs and returns the path to the transactions directory
148
+ based on the `models_root_path` and `TRANSACTIONS_MODULE_NAME` attributes.
149
+
150
+ Returns:
151
+ Path: The root path for the transactions directory.
152
+ """
153
+ return self.models_root_path / self.TRANSACTIONS_MODULE_NAME
154
+
155
+ @property
156
+ def migrations_root_path(self) -> Path:
157
+ """
158
+ Returns the root path for migrations.
159
+
160
+ This property constructs and returns the path to the migrations directory
161
+ based on the `models_root_path` and `MIGRATIONS_DIRECTORY_NAME` attributes.
162
+
163
+ Returns:
164
+ Path: The root path for the migrations directory.
165
+ """
166
+ return self.models_root_path / self.MIGRATIONS_DIRECTORY_NAME
167
+
168
+ @model_validator(mode='after')
169
+ def check_passwords_match(self) -> 'Settings':
170
+ """
171
+ Ensures the configuration path is set.
172
+
173
+ This method checks if the `CONFIG_PATH` attribute is set. If it is not set,
174
+ it assigns a default path based on the `APP_PATH` attribute.
175
+
176
+ Returns:
177
+ Settings: The updated settings instance with the `CONFIG_PATH` attribute set.
178
+ """
179
+ config_path = self.CONFIG_PATH
180
+
181
+ if not config_path:
182
+ self.CONFIG_PATH = self.APP_PATH / 'config.yml'
183
+
184
+ return self
185
+
186
+
187
+ if TYPE_CHECKING:
188
+ base: TypeAlias = Settings
189
+ else:
190
+ base: TypeAlias = object
191
+
192
+
193
+ class SettingsProxy(base):
194
+ """
195
+ Proxy class for accessing and modifying settings.
196
+
197
+ This class acts as a proxy for the `Settings` class, allowing for dynamic
198
+ overriding and accessing of settings attributes.
199
+ """
200
+
201
+ def __init__(self) -> None:
202
+ self._settings = Settings()
203
+
204
+ def override(self, **kwargs: Any) -> None:
205
+ """
206
+ Overrides settings with provided keyword arguments.
207
+
208
+ This method updates the current settings with the provided keyword arguments.
209
+
210
+ Args:
211
+ **kwargs: Keyword arguments representing settings to override.
212
+
213
+ Returns:
214
+ None
215
+ """
216
+ new_settings = self._settings.model_dump()
217
+ new_settings.update(kwargs)
218
+ self._settings = Settings(**new_settings)
219
+
220
+ def model_dump(self, *args: Any, **kwargs: Any) -> dict[str, Any]:
221
+ """
222
+ Dumps the current settings model to a dictionary.
223
+
224
+ This method returns the current settings as a dictionary.
225
+
226
+ Args:
227
+ *args: Additional positional arguments to pass to the underlying model dump method.
228
+ **kwargs: Additional keyword arguments to pass to the underlying model dump method.
229
+
230
+ Returns:
231
+ dict[str, Any]: The current settings as a dictionary.
232
+ """
233
+ return self._settings.model_dump(*args, **kwargs)
234
+
235
+ def __getattr__(self, name: str) -> Any:
236
+ return getattr(self._settings, name)
237
+
238
+ def __delattr__(self, name: str) -> None:
239
+ try:
240
+ getattr(self._settings, name)
241
+ self._settings.__delattr__(name)
242
+ except AttributeError:
243
+ msg = f'Settings object has no attribute {name}'
244
+ raise AttributeError(msg) from None
245
+
246
+ def __setattr__(self, name: str, value: Any) -> None:
247
+ if name == '_settings':
248
+ super().__setattr__(name, value)
249
+ return
250
+
251
+ self._settings.__setattr__(name, value)
252
+
253
+
254
+ settings: SettingsProxy = SettingsProxy()
@@ -0,0 +1,177 @@
1
+ from _typeshed import Incomplete
2
+ from pathlib import Path
3
+ from pydantic_settings import BaseSettings
4
+ from typing import Any, TypeAlias
5
+
6
+ class Settings(BaseSettings):
7
+ """
8
+ Configuration settings for the application.
9
+
10
+ This class defines the configuration settings for the application, including paths,
11
+ environment variables, and other settings.
12
+
13
+ Attributes:
14
+ model_config (SettingsConfigDict): Configuration for the settings model.
15
+ APP_PATH (Path): Path to the app directory where the generated models and other files will be placed.
16
+ CONFIG_PATH (Path | None): Path to the config.yml file. If not specified, the default APP_PATH/config.yml
17
+ file will be used.
18
+ MODELS_MODULE_NAME (str): The models module name. The generated models will be placed in this module.
19
+ SCHEMAS_MODULE_NAME (str): The schemas module name. The schemas will be placed in this module.
20
+ FIXTURES_MODULE_NAME (str): The fixtures module name. The fixtures will be placed in this module.
21
+ STATIC_MODULE_NAME (str): The static module name. The static files will be placed in this module.
22
+ TRANSACTIONS_MODULE_NAME (str): The transactions module name. The transactions will be placed in this module.
23
+ MIGRATIONS_DIRECTORY_NAME (str): The migrations directory name. The migration files will be placed in this
24
+ folder.
25
+ ACCESS_KEY_ID (str | None): The access key that you will get during registering process.
26
+ SECRET_ACCESS_KEY (str | None): The secret access key that you will get during registering process.
27
+ ACCESS_TOKEN (str | None): The access token that you will get during sign in process.
28
+ SANDBOX_ENVIRONMENT (bool | None): If True, the sandbox environment will be used. If False,
29
+ the cloud environment will be used.
30
+ CONTRIBS (list[str]): List of contrib modules that will be loaded and used.
31
+ Can be specified via environment variable AMSDAL_CONTRIBS as comma separated string.
32
+ """
33
+ model_config: Incomplete
34
+ APP_PATH: Path
35
+ CONFIG_PATH: Path | None
36
+ MODELS_MODULE_NAME: str
37
+ SCHEMAS_MODULE_NAME: str
38
+ FIXTURES_MODULE_NAME: str
39
+ STATIC_MODULE_NAME: str
40
+ TRANSACTIONS_MODULE_NAME: str
41
+ MIGRATIONS_DIRECTORY_NAME: str
42
+ ACCESS_KEY_ID: str | None
43
+ SECRET_ACCESS_KEY: str | None
44
+ ACCESS_TOKEN: str | None
45
+ SANDBOX_ENVIRONMENT: bool | None
46
+ CONTRIBS: list[str]
47
+ def load_contrib_modules(cls, value: list[str]) -> list[str]:
48
+ """
49
+ Loads and initializes contrib modules.
50
+
51
+ This method takes a list of contrib module paths, imports each module, and calls the `on_ready` method
52
+ of the `AppConfig` class within each module.
53
+
54
+ Args:
55
+ value (list[str]): A list of contrib module paths in the format 'package.module.ClassName'.
56
+
57
+ Returns:
58
+ list[str]: The same list of contrib module paths after loading and initializing the modules.
59
+ """
60
+ @property
61
+ def models_root_path(self) -> Path:
62
+ """
63
+ Returns the root path for models.
64
+
65
+ This property constructs and returns the path to the models directory
66
+ based on the `APP_PATH` and `MODELS_MODULE_NAME` attributes.
67
+
68
+ Returns:
69
+ Path: The root path for the models directory.
70
+ """
71
+ @property
72
+ def schemas_root_path(self) -> Path:
73
+ """
74
+ Returns the root path for schemas.
75
+
76
+ This property constructs and returns the path to the schemas directory
77
+ based on the `APP_PATH` and `SCHEMAS_MODULE_NAME` attributes.
78
+
79
+ Returns:
80
+ Path: The root path for the schemas directory.
81
+ """
82
+ @property
83
+ def fixtures_root_path(self) -> Path:
84
+ """
85
+ Returns the root path for fixtures.
86
+
87
+ This property constructs and returns the path to the fixtures directory
88
+ based on the `APP_PATH` and `FIXTURES_MODULE_NAME` attributes.
89
+
90
+ Returns:
91
+ Path: The root path for the fixtures directory.
92
+ """
93
+ @property
94
+ def static_root_path(self) -> Path:
95
+ """
96
+ Returns the root path for static files.
97
+
98
+ This property constructs and returns the path to the static files directory
99
+ based on the `APP_PATH` and `STATIC_MODULE_NAME` attributes.
100
+
101
+ Returns:
102
+ Path: The root path for the static files directory.
103
+ """
104
+ @property
105
+ def transactions_root_path(self) -> Path:
106
+ """
107
+ Returns the root path for transactions.
108
+
109
+ This property constructs and returns the path to the transactions directory
110
+ based on the `models_root_path` and `TRANSACTIONS_MODULE_NAME` attributes.
111
+
112
+ Returns:
113
+ Path: The root path for the transactions directory.
114
+ """
115
+ @property
116
+ def migrations_root_path(self) -> Path:
117
+ """
118
+ Returns the root path for migrations.
119
+
120
+ This property constructs and returns the path to the migrations directory
121
+ based on the `models_root_path` and `MIGRATIONS_DIRECTORY_NAME` attributes.
122
+
123
+ Returns:
124
+ Path: The root path for the migrations directory.
125
+ """
126
+ def check_passwords_match(self) -> Settings:
127
+ """
128
+ Ensures the configuration path is set.
129
+
130
+ This method checks if the `CONFIG_PATH` attribute is set. If it is not set,
131
+ it assigns a default path based on the `APP_PATH` attribute.
132
+
133
+ Returns:
134
+ Settings: The updated settings instance with the `CONFIG_PATH` attribute set.
135
+ """
136
+
137
+ base: TypeAlias
138
+
139
+ class SettingsProxy(base):
140
+ """
141
+ Proxy class for accessing and modifying settings.
142
+
143
+ This class acts as a proxy for the `Settings` class, allowing for dynamic
144
+ overriding and accessing of settings attributes.
145
+ """
146
+ _settings: Incomplete
147
+ def __init__(self) -> None: ...
148
+ def override(self, **kwargs: Any) -> None:
149
+ """
150
+ Overrides settings with provided keyword arguments.
151
+
152
+ This method updates the current settings with the provided keyword arguments.
153
+
154
+ Args:
155
+ **kwargs: Keyword arguments representing settings to override.
156
+
157
+ Returns:
158
+ None
159
+ """
160
+ def model_dump(self, *args: Any, **kwargs: Any) -> dict[str, Any]:
161
+ """
162
+ Dumps the current settings model to a dictionary.
163
+
164
+ This method returns the current settings as a dictionary.
165
+
166
+ Args:
167
+ *args: Additional positional arguments to pass to the underlying model dump method.
168
+ **kwargs: Additional keyword arguments to pass to the underlying model dump method.
169
+
170
+ Returns:
171
+ dict[str, Any]: The current settings as a dictionary.
172
+ """
173
+ def __getattr__(self, name: str) -> Any: ...
174
+ def __delattr__(self, name: str) -> None: ...
175
+ def __setattr__(self, name: str, value: Any) -> None: ...
176
+
177
+ settings: SettingsProxy
File without changes
File without changes
@@ -0,0 +1,69 @@
1
+ from contextvars import ContextVar
2
+ from typing import Any
3
+
4
+ _CONTEXT: ContextVar[dict[str, Any] | None] = ContextVar('_context', default=None)
5
+
6
+
7
+ class AmsdalContextManager:
8
+ """
9
+ Manages a context for storing and retrieving data.
10
+
11
+ This class provides methods to get, set, and add to a context stored in a
12
+ `ContextVar`. The context is a dictionary that can hold any key-value pairs.
13
+ """
14
+
15
+ @classmethod
16
+ def get_context(cls) -> dict[str, Any]:
17
+ """
18
+ Retrieves the current context or creates a new one if none exists.
19
+
20
+ This method gets the current context from the `_CONTEXT` variable. If no
21
+ context exists, it creates a new empty context and sets it.
22
+
23
+ Returns:
24
+ dict[str, Any]: The current context.
25
+ """
26
+ _context = _CONTEXT.get()
27
+
28
+ if _context is not None:
29
+ return _context
30
+
31
+ new_context: dict[str, Any] = {}
32
+ cls.set_context(new_context)
33
+
34
+ return new_context
35
+
36
+ @classmethod
37
+ def set_context(cls, context: dict[str, Any]) -> None:
38
+ """
39
+ Sets the context to the provided dictionary.
40
+
41
+ This method sets the `_CONTEXT` variable to the provided context.
42
+
43
+ Args:
44
+ context (dict[str, Any]): The context to set.
45
+
46
+ Returns:
47
+ None
48
+ """
49
+ _CONTEXT.set(context)
50
+
51
+ @classmethod
52
+ def add_to_context(cls, key: str, value: Any) -> None:
53
+ """
54
+ Adds a key-value pair to the current context.
55
+
56
+ This method adds the provided key-value pair to the current context.
57
+
58
+ Args:
59
+ key (str): The key to add to the context.
60
+ value (Any): The value to associate with the key.
61
+
62
+ Returns:
63
+ None
64
+ """
65
+ context = cls.get_context()
66
+
67
+ context[key] = value
68
+
69
+ cls.set_context(context)
@@ -0,0 +1,50 @@
1
+ from contextvars import ContextVar
2
+ from typing import Any
3
+
4
+ _CONTEXT: ContextVar[dict[str, Any] | None]
5
+
6
+ class AmsdalContextManager:
7
+ """
8
+ Manages a context for storing and retrieving data.
9
+
10
+ This class provides methods to get, set, and add to a context stored in a
11
+ `ContextVar`. The context is a dictionary that can hold any key-value pairs.
12
+ """
13
+ @classmethod
14
+ def get_context(cls) -> dict[str, Any]:
15
+ """
16
+ Retrieves the current context or creates a new one if none exists.
17
+
18
+ This method gets the current context from the `_CONTEXT` variable. If no
19
+ context exists, it creates a new empty context and sets it.
20
+
21
+ Returns:
22
+ dict[str, Any]: The current context.
23
+ """
24
+ @classmethod
25
+ def set_context(cls, context: dict[str, Any]) -> None:
26
+ """
27
+ Sets the context to the provided dictionary.
28
+
29
+ This method sets the `_CONTEXT` variable to the provided context.
30
+
31
+ Args:
32
+ context (dict[str, Any]): The context to set.
33
+
34
+ Returns:
35
+ None
36
+ """
37
+ @classmethod
38
+ def add_to_context(cls, key: str, value: Any) -> None:
39
+ """
40
+ Adds a key-value pair to the current context.
41
+
42
+ This method adds the provided key-value pair to the current context.
43
+
44
+ Args:
45
+ key (str): The key to add to the context.
46
+ value (Any): The value to associate with the key.
47
+
48
+ Returns:
49
+ None
50
+ """
File without changes