amsdal 0.5.23__cp311-cp311-macosx_10_9_universal2.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


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

Files changed (252) hide show
  1. amsdal/Third-Party Materials - AMSDAL Dependencies - License Notices.md +1334 -0
  2. amsdal/__about__.py +4 -0
  3. amsdal/__about__.pyi +1 -0
  4. amsdal/__init__.py +23 -0
  5. amsdal/__init__.pyi +9 -0
  6. amsdal/__migrations__/0000_initial.py +36 -0
  7. amsdal/__migrations__/0001_create_class_file.py +61 -0
  8. amsdal/__migrations__/0002_create_class_file.py +109 -0
  9. amsdal/__migrations__/0003_update_class_file.py +91 -0
  10. amsdal/__migrations__/0004_update_class_file.py +45 -0
  11. amsdal/cloud/__init__.cpython-311-darwin.so +0 -0
  12. amsdal/cloud/__init__.pyi +0 -0
  13. amsdal/cloud/client.cpython-311-darwin.so +0 -0
  14. amsdal/cloud/client.pyi +57 -0
  15. amsdal/cloud/constants.cpython-311-darwin.so +0 -0
  16. amsdal/cloud/constants.pyi +13 -0
  17. amsdal/cloud/enums.cpython-311-darwin.so +0 -0
  18. amsdal/cloud/enums.pyi +68 -0
  19. amsdal/cloud/models/__init__.cpython-311-darwin.so +0 -0
  20. amsdal/cloud/models/__init__.pyi +0 -0
  21. amsdal/cloud/models/base.cpython-311-darwin.so +0 -0
  22. amsdal/cloud/models/base.pyi +247 -0
  23. amsdal/cloud/services/__init__.cpython-311-darwin.so +0 -0
  24. amsdal/cloud/services/__init__.pyi +0 -0
  25. amsdal/cloud/services/actions/__init__.cpython-311-darwin.so +0 -0
  26. amsdal/cloud/services/actions/__init__.pyi +0 -0
  27. amsdal/cloud/services/actions/add_allowlist_ip.cpython-311-darwin.so +0 -0
  28. amsdal/cloud/services/actions/add_allowlist_ip.pyi +19 -0
  29. amsdal/cloud/services/actions/add_basic_auth.cpython-311-darwin.so +0 -0
  30. amsdal/cloud/services/actions/add_basic_auth.pyi +21 -0
  31. amsdal/cloud/services/actions/add_dependency.cpython-311-darwin.so +0 -0
  32. amsdal/cloud/services/actions/add_dependency.pyi +19 -0
  33. amsdal/cloud/services/actions/add_secret.cpython-311-darwin.so +0 -0
  34. amsdal/cloud/services/actions/add_secret.pyi +20 -0
  35. amsdal/cloud/services/actions/base.cpython-311-darwin.so +0 -0
  36. amsdal/cloud/services/actions/base.pyi +122 -0
  37. amsdal/cloud/services/actions/create_deploy.cpython-311-darwin.so +0 -0
  38. amsdal/cloud/services/actions/create_deploy.pyi +41 -0
  39. amsdal/cloud/services/actions/create_env.cpython-311-darwin.so +0 -0
  40. amsdal/cloud/services/actions/create_env.pyi +19 -0
  41. amsdal/cloud/services/actions/create_session.cpython-311-darwin.so +0 -0
  42. amsdal/cloud/services/actions/create_session.pyi +17 -0
  43. amsdal/cloud/services/actions/delete_allowlist_ip.cpython-311-darwin.so +0 -0
  44. amsdal/cloud/services/actions/delete_allowlist_ip.pyi +19 -0
  45. amsdal/cloud/services/actions/delete_basic_auth.cpython-311-darwin.so +0 -0
  46. amsdal/cloud/services/actions/delete_basic_auth.pyi +20 -0
  47. amsdal/cloud/services/actions/delete_dependency.cpython-311-darwin.so +0 -0
  48. amsdal/cloud/services/actions/delete_dependency.pyi +21 -0
  49. amsdal/cloud/services/actions/delete_env.cpython-311-darwin.so +0 -0
  50. amsdal/cloud/services/actions/delete_env.pyi +21 -0
  51. amsdal/cloud/services/actions/delete_secret.cpython-311-darwin.so +0 -0
  52. amsdal/cloud/services/actions/delete_secret.pyi +21 -0
  53. amsdal/cloud/services/actions/destroy_deploy.cpython-311-darwin.so +0 -0
  54. amsdal/cloud/services/actions/destroy_deploy.pyi +18 -0
  55. amsdal/cloud/services/actions/expose_db.cpython-311-darwin.so +0 -0
  56. amsdal/cloud/services/actions/expose_db.pyi +22 -0
  57. amsdal/cloud/services/actions/get_basic_auth_credentials.cpython-311-darwin.so +0 -0
  58. amsdal/cloud/services/actions/get_basic_auth_credentials.pyi +21 -0
  59. amsdal/cloud/services/actions/get_monitoring_info.cpython-311-darwin.so +0 -0
  60. amsdal/cloud/services/actions/get_monitoring_info.pyi +21 -0
  61. amsdal/cloud/services/actions/list_dependencies.cpython-311-darwin.so +0 -0
  62. amsdal/cloud/services/actions/list_dependencies.pyi +21 -0
  63. amsdal/cloud/services/actions/list_deploys.cpython-311-darwin.so +0 -0
  64. amsdal/cloud/services/actions/list_deploys.pyi +19 -0
  65. amsdal/cloud/services/actions/list_envs.cpython-311-darwin.so +0 -0
  66. amsdal/cloud/services/actions/list_envs.pyi +20 -0
  67. amsdal/cloud/services/actions/list_secrets.cpython-311-darwin.so +0 -0
  68. amsdal/cloud/services/actions/list_secrets.pyi +22 -0
  69. amsdal/cloud/services/actions/manager.cpython-311-darwin.so +0 -0
  70. amsdal/cloud/services/actions/manager.pyi +278 -0
  71. amsdal/cloud/services/actions/signup_action.cpython-311-darwin.so +0 -0
  72. amsdal/cloud/services/actions/signup_action.pyi +20 -0
  73. amsdal/cloud/services/actions/update_deploy.cpython-311-darwin.so +0 -0
  74. amsdal/cloud/services/actions/update_deploy.pyi +19 -0
  75. amsdal/cloud/services/auth/__init__.cpython-311-darwin.so +0 -0
  76. amsdal/cloud/services/auth/__init__.pyi +0 -0
  77. amsdal/cloud/services/auth/base.cpython-311-darwin.so +0 -0
  78. amsdal/cloud/services/auth/base.pyi +6 -0
  79. amsdal/cloud/services/auth/credentials.cpython-311-darwin.so +0 -0
  80. amsdal/cloud/services/auth/credentials.pyi +30 -0
  81. amsdal/cloud/services/auth/manager.cpython-311-darwin.so +0 -0
  82. amsdal/cloud/services/auth/manager.pyi +26 -0
  83. amsdal/cloud/services/auth/signup_service.cpython-311-darwin.so +0 -0
  84. amsdal/cloud/services/auth/signup_service.pyi +32 -0
  85. amsdal/cloud/services/auth/token.cpython-311-darwin.so +0 -0
  86. amsdal/cloud/services/auth/token.pyi +27 -0
  87. amsdal/configs/__init__.py +0 -0
  88. amsdal/configs/__init__.pyi +0 -0
  89. amsdal/configs/constants.py +33 -0
  90. amsdal/configs/constants.pyi +22 -0
  91. amsdal/configs/main.py +274 -0
  92. amsdal/configs/main.pyi +178 -0
  93. amsdal/context/__init__.py +0 -0
  94. amsdal/context/__init__.pyi +0 -0
  95. amsdal/context/manager.py +69 -0
  96. amsdal/context/manager.pyi +50 -0
  97. amsdal/contrib/__init__.cpython-311-darwin.so +0 -0
  98. amsdal/contrib/__init__.pyi +0 -0
  99. amsdal/contrib/app_config.py +7 -0
  100. amsdal/contrib/app_config.pyi +6 -0
  101. amsdal/contrib/auth/__init__.py +0 -0
  102. amsdal/contrib/auth/__init__.pyi +0 -0
  103. amsdal/contrib/auth/app.py +27 -0
  104. amsdal/contrib/auth/app.pyi +15 -0
  105. amsdal/contrib/auth/decorators/__init__.py +35 -0
  106. amsdal/contrib/auth/decorators/__init__.pyi +6 -0
  107. amsdal/contrib/auth/errors.py +7 -0
  108. amsdal/contrib/auth/errors.pyi +4 -0
  109. amsdal/contrib/auth/fixtures/basic_permissions.json +64 -0
  110. amsdal/contrib/auth/lifecycle/__init__.py +0 -0
  111. amsdal/contrib/auth/lifecycle/__init__.pyi +0 -0
  112. amsdal/contrib/auth/lifecycle/consumer.py +394 -0
  113. amsdal/contrib/auth/lifecycle/consumer.pyi +108 -0
  114. amsdal/contrib/auth/migrations/0000_initial.py +87 -0
  115. amsdal/contrib/auth/models/__init__.py +0 -0
  116. amsdal/contrib/auth/models/login_session.py +118 -0
  117. amsdal/contrib/auth/models/permission.py +23 -0
  118. amsdal/contrib/auth/models/user.py +106 -0
  119. amsdal/contrib/auth/settings.py +36 -0
  120. amsdal/contrib/auth/settings.pyi +26 -0
  121. amsdal/contrib/frontend_configs/__init__.py +0 -0
  122. amsdal/contrib/frontend_configs/__init__.pyi +0 -0
  123. amsdal/contrib/frontend_configs/app.py +24 -0
  124. amsdal/contrib/frontend_configs/app.pyi +19 -0
  125. amsdal/contrib/frontend_configs/constants.py +1 -0
  126. amsdal/contrib/frontend_configs/constants.pyi +1 -0
  127. amsdal/contrib/frontend_configs/conversion/__init__.py +5 -0
  128. amsdal/contrib/frontend_configs/conversion/__init__.pyi +3 -0
  129. amsdal/contrib/frontend_configs/conversion/convert.py +310 -0
  130. amsdal/contrib/frontend_configs/conversion/convert.pyi +22 -0
  131. amsdal/contrib/frontend_configs/lifecycle/__init__.py +0 -0
  132. amsdal/contrib/frontend_configs/lifecycle/__init__.pyi +0 -0
  133. amsdal/contrib/frontend_configs/lifecycle/consumer.py +306 -0
  134. amsdal/contrib/frontend_configs/lifecycle/consumer.pyi +98 -0
  135. amsdal/contrib/frontend_configs/migrations/0000_initial.py +227 -0
  136. amsdal/contrib/frontend_configs/migrations/0001_update_frontend_control_config.py +245 -0
  137. amsdal/contrib/frontend_configs/migrations/0002_add_button_and_invoke_actions.py +352 -0
  138. amsdal/contrib/frontend_configs/models/__init__.py +0 -0
  139. amsdal/contrib/frontend_configs/models/frontend_activator_config.py +22 -0
  140. amsdal/contrib/frontend_configs/models/frontend_config_async_validator.py +11 -0
  141. amsdal/contrib/frontend_configs/models/frontend_config_control_action.py +110 -0
  142. amsdal/contrib/frontend_configs/models/frontend_config_group_validator.py +21 -0
  143. amsdal/contrib/frontend_configs/models/frontend_config_option.py +12 -0
  144. amsdal/contrib/frontend_configs/models/frontend_config_skip_none_base.py +17 -0
  145. amsdal/contrib/frontend_configs/models/frontend_config_slider_option.py +13 -0
  146. amsdal/contrib/frontend_configs/models/frontend_config_text_mask.py +14 -0
  147. amsdal/contrib/frontend_configs/models/frontend_config_validator.py +28 -0
  148. amsdal/contrib/frontend_configs/models/frontend_control_config.py +108 -0
  149. amsdal/contrib/frontend_configs/models/frontend_model_config.py +14 -0
  150. amsdal/contrib/frontend_configs/utils.py +29 -0
  151. amsdal/contrib/frontend_configs/utils.pyi +17 -0
  152. amsdal/errors.py +31 -0
  153. amsdal/errors.pyi +12 -0
  154. amsdal/fixtures/__init__.cpython-311-darwin.so +0 -0
  155. amsdal/fixtures/__init__.pyi +0 -0
  156. amsdal/fixtures/manager.cpython-311-darwin.so +0 -0
  157. amsdal/fixtures/manager.pyi +170 -0
  158. amsdal/fixtures/utils.cpython-311-darwin.so +0 -0
  159. amsdal/fixtures/utils.pyi +9 -0
  160. amsdal/manager.cpython-311-darwin.so +0 -0
  161. amsdal/manager.pyi +265 -0
  162. amsdal/mixins/__init__.cpython-311-darwin.so +0 -0
  163. amsdal/mixins/__init__.pyi +0 -0
  164. amsdal/mixins/class_versions_mixin.cpython-311-darwin.so +0 -0
  165. amsdal/mixins/class_versions_mixin.pyi +12 -0
  166. amsdal/models/__init__.py +19 -0
  167. amsdal/models/core/__init__.py +0 -0
  168. amsdal/models/core/class_object.py +38 -0
  169. amsdal/models/core/class_property.py +26 -0
  170. amsdal/models/core/file.py +243 -0
  171. amsdal/models/core/fixture.py +25 -0
  172. amsdal/models/core/option.py +11 -0
  173. amsdal/models/core/storage_metadata.py +15 -0
  174. amsdal/models/core/validator.py +12 -0
  175. amsdal/models/mixins.py +31 -0
  176. amsdal/models/types/__init__.py +0 -0
  177. amsdal/models/types/object.py +26 -0
  178. amsdal/py.typed +0 -0
  179. amsdal/queryset/__init__.py +21 -0
  180. amsdal/queryset/__init__.pyi +6 -0
  181. amsdal/schemas/__init__.py +0 -0
  182. amsdal/schemas/__init__.pyi +0 -0
  183. amsdal/schemas/core/class_object/model.json +51 -0
  184. amsdal/schemas/core/class_object/properties/display_name.py +9 -0
  185. amsdal/schemas/core/class_property/model.json +41 -0
  186. amsdal/schemas/core/file/hooks/pre_create.py +24 -0
  187. amsdal/schemas/core/file/hooks/pre_update.py +24 -0
  188. amsdal/schemas/core/file/model.json +23 -0
  189. amsdal/schemas/core/file/properties/from_file.py +34 -0
  190. amsdal/schemas/core/file/properties/mimetype.py +13 -0
  191. amsdal/schemas/core/file/properties/str.py +6 -0
  192. amsdal/schemas/core/file/properties/to_file.py +24 -0
  193. amsdal/schemas/core/file/properties/validate_data.py +31 -0
  194. amsdal/schemas/core/fixture/model.json +35 -0
  195. amsdal/schemas/core/option/model.json +19 -0
  196. amsdal/schemas/core/storage_metadata/model.json +52 -0
  197. amsdal/schemas/core/validator/model.json +19 -0
  198. amsdal/schemas/interfaces.py +25 -0
  199. amsdal/schemas/interfaces.pyi +20 -0
  200. amsdal/schemas/manager.cpython-311-darwin.so +0 -0
  201. amsdal/schemas/manager.py +0 -0
  202. amsdal/schemas/manager.pyi +0 -0
  203. amsdal/schemas/mixins/__init__.py +0 -0
  204. amsdal/schemas/mixins/__init__.pyi +0 -0
  205. amsdal/schemas/mixins/check_dependencies_mixin.py +130 -0
  206. amsdal/schemas/mixins/check_dependencies_mixin.pyi +45 -0
  207. amsdal/schemas/mixins/verify_schemas_mixin.py +96 -0
  208. amsdal/schemas/mixins/verify_schemas_mixin.pyi +33 -0
  209. amsdal/schemas/repository.py +84 -0
  210. amsdal/schemas/repository.pyi +22 -0
  211. amsdal/schemas/types/anything/model.json +7 -0
  212. amsdal/schemas/types/array/model.json +7 -0
  213. amsdal/schemas/types/binary/model.json +7 -0
  214. amsdal/schemas/types/boolean/model.json +17 -0
  215. amsdal/schemas/types/date/model.json +7 -0
  216. amsdal/schemas/types/datetime/model.json +7 -0
  217. amsdal/schemas/types/dictionary/model.json +8 -0
  218. amsdal/schemas/types/number/model.json +8 -0
  219. amsdal/schemas/types/object/model.json +53 -0
  220. amsdal/schemas/types/string/model.json +8 -0
  221. amsdal/schemas/utils.py +16 -0
  222. amsdal/schemas/utils.pyi +10 -0
  223. amsdal/services/__init__.py +11 -0
  224. amsdal/services/__init__.pyi +4 -0
  225. amsdal/services/external_connections.py +262 -0
  226. amsdal/services/external_connections.pyi +190 -0
  227. amsdal/services/external_model_generator.py +350 -0
  228. amsdal/services/external_model_generator.pyi +134 -0
  229. amsdal/services/transaction_execution.cpython-311-darwin.so +0 -0
  230. amsdal/services/transaction_execution.pyi +93 -0
  231. amsdal/storages/__init__.py +20 -0
  232. amsdal/storages/__init__.pyi +8 -0
  233. amsdal/storages/file_system.py +214 -0
  234. amsdal/storages/file_system.pyi +36 -0
  235. amsdal/transactions/__init__.py +13 -0
  236. amsdal/transactions/__init__.pyi +4 -0
  237. amsdal/utils/__init__.py +0 -0
  238. amsdal/utils/__init__.pyi +0 -0
  239. amsdal/utils/contrib_paths.py +23 -0
  240. amsdal/utils/contrib_paths.pyi +14 -0
  241. amsdal/utils/rollback/__init__.py +440 -0
  242. amsdal/utils/rollback/__init__.pyi +38 -0
  243. amsdal/utils/tests/__init__.py +0 -0
  244. amsdal/utils/tests/enums.py +16 -0
  245. amsdal/utils/tests/factories.py +49 -0
  246. amsdal/utils/tests/helpers.py +331 -0
  247. amsdal/utils/tests/migrations.py +157 -0
  248. amsdal-0.5.23.dist-info/METADATA +373 -0
  249. amsdal-0.5.23.dist-info/RECORD +252 -0
  250. amsdal-0.5.23.dist-info/WHEEL +5 -0
  251. amsdal-0.5.23.dist-info/licenses/LICENSE.txt +107 -0
  252. amsdal-0.5.23.dist-info/top_level.txt +1 -0
@@ -0,0 +1,84 @@
1
+ from amsdal_utils.models.enums import ModuleType
2
+ from amsdal_utils.schemas.interfaces import BaseDependsSchemaLoader
3
+ from amsdal_utils.schemas.interfaces import BaseSchemaLoader
4
+ from amsdal_utils.schemas.schema import ObjectSchema
5
+
6
+ from amsdal.schemas.mixins.check_dependencies_mixin import CheckDependenciesMixin
7
+ from amsdal.schemas.mixins.verify_schemas_mixin import VerifySchemasMixin
8
+ from amsdal.schemas.utils import ModelModuleInfo
9
+
10
+
11
+ class SchemaRepository(VerifySchemasMixin, CheckDependenciesMixin):
12
+ type_schemas: list[ObjectSchema]
13
+ core_schemas: list[ObjectSchema]
14
+ contrib_schemas: list[ObjectSchema]
15
+ user_schemas: list[ObjectSchema]
16
+
17
+ def __init__(
18
+ self,
19
+ type_schema_loader: BaseSchemaLoader,
20
+ core_schema_loader: BaseSchemaLoader | BaseDependsSchemaLoader,
21
+ contrib_schema_loader: BaseSchemaLoader | BaseDependsSchemaLoader,
22
+ user_schema_loader: BaseSchemaLoader | BaseDependsSchemaLoader,
23
+ ):
24
+ self._type_schema_loader = type_schema_loader
25
+ self._core_schema_loader = core_schema_loader
26
+ self._contrib_schema_loader = contrib_schema_loader
27
+ self._user_schema_loader = user_schema_loader
28
+
29
+ self.type_schemas = type_schema_loader.load()
30
+ self.core_schemas = self._load_schemas(core_schema_loader)
31
+ self.contrib_schemas = self._load_schemas(contrib_schema_loader, self.core_schemas)
32
+ self.user_schemas = self._load_schemas(user_schema_loader, self.core_schemas, self.contrib_schemas)
33
+
34
+ self.verify_schemas(
35
+ self.type_schemas,
36
+ self.core_schemas,
37
+ self.contrib_schemas,
38
+ self.user_schemas,
39
+ )
40
+ self.check_dependencies(
41
+ self.type_schemas,
42
+ self.core_schemas,
43
+ self.contrib_schemas,
44
+ self.user_schemas,
45
+ )
46
+
47
+ @property
48
+ def model_module_info(self) -> ModelModuleInfo:
49
+ _type_info = self._prepare_info(self._type_schema_loader.schemas_per_module)
50
+ _core_info = self._prepare_info(self._core_schema_loader.schemas_per_module)
51
+ _contrib_info = self._prepare_info(self._contrib_schema_loader.schemas_per_module)
52
+ _user_info = self._prepare_info(self._user_schema_loader.schemas_per_module)
53
+
54
+ return ModelModuleInfo(
55
+ info={
56
+ ModuleType.TYPE: _type_info,
57
+ ModuleType.CORE: _core_info,
58
+ ModuleType.CONTRIB: _contrib_info,
59
+ ModuleType.USER: _user_info,
60
+ },
61
+ )
62
+
63
+ def _load_schemas(
64
+ self,
65
+ loader: BaseSchemaLoader | BaseDependsSchemaLoader,
66
+ *extra_schemas: list[ObjectSchema],
67
+ ) -> list[ObjectSchema]:
68
+
69
+ if isinstance(loader, BaseDependsSchemaLoader):
70
+ return loader.load(self.type_schemas, *extra_schemas)
71
+ else:
72
+ _schemas, _circular = loader.load_sorted()
73
+ return _schemas + _circular
74
+
75
+ @staticmethod
76
+ def _prepare_info(schemas_per_module: dict[str, list[ObjectSchema]]) -> dict[str, str]:
77
+ _info = {}
78
+
79
+ for module_path, schemas in schemas_per_module.items():
80
+ _info.update(
81
+ {_schema.title: module_path for _schema in schemas},
82
+ )
83
+
84
+ return _info
@@ -0,0 +1,22 @@
1
+ from _typeshed import Incomplete
2
+ from amsdal.schemas.mixins.check_dependencies_mixin import CheckDependenciesMixin as CheckDependenciesMixin
3
+ from amsdal.schemas.mixins.verify_schemas_mixin import VerifySchemasMixin as VerifySchemasMixin
4
+ from amsdal.schemas.utils import ModelModuleInfo as ModelModuleInfo
5
+ from amsdal_utils.schemas.interfaces import BaseDependsSchemaLoader, BaseSchemaLoader as BaseSchemaLoader
6
+ from amsdal_utils.schemas.schema import ObjectSchema as ObjectSchema
7
+
8
+ class SchemaRepository(VerifySchemasMixin, CheckDependenciesMixin):
9
+ type_schemas: list[ObjectSchema]
10
+ core_schemas: list[ObjectSchema]
11
+ contrib_schemas: list[ObjectSchema]
12
+ user_schemas: list[ObjectSchema]
13
+ _type_schema_loader: Incomplete
14
+ _core_schema_loader: Incomplete
15
+ _contrib_schema_loader: Incomplete
16
+ _user_schema_loader: Incomplete
17
+ def __init__(self, type_schema_loader: BaseSchemaLoader, core_schema_loader: BaseSchemaLoader | BaseDependsSchemaLoader, contrib_schema_loader: BaseSchemaLoader | BaseDependsSchemaLoader, user_schema_loader: BaseSchemaLoader | BaseDependsSchemaLoader) -> None: ...
18
+ @property
19
+ def model_module_info(self) -> ModelModuleInfo: ...
20
+ def _load_schemas(self, loader: BaseSchemaLoader | BaseDependsSchemaLoader, *extra_schemas: list[ObjectSchema]) -> list[ObjectSchema]: ...
21
+ @staticmethod
22
+ def _prepare_info(schemas_per_module: dict[str, list[ObjectSchema]]) -> dict[str, str]: ...
@@ -0,0 +1,7 @@
1
+ {
2
+ "title": "Anything",
3
+ "type": "object",
4
+ "properties":{},
5
+ "required":[],
6
+ "meta_class": "TypeMeta"
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "title": "Array",
3
+ "type": "object",
4
+ "properties":{},
5
+ "required":[],
6
+ "meta_class": "TypeMeta"
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "title": "Binary",
3
+ "type": "object",
4
+ "properties":{},
5
+ "required":[],
6
+ "meta_class": "TypeMeta"
7
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "title": "Boolean",
3
+ "type": "object",
4
+ "options": [
5
+ {
6
+ "key": "true",
7
+ "value": true
8
+ },
9
+ {
10
+ "key": "false",
11
+ "value": false
12
+ }
13
+ ],
14
+ "properties": {},
15
+ "required": [],
16
+ "meta_class": "TypeMeta"
17
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "title": "Date",
3
+ "type": "object",
4
+ "properties":{},
5
+ "required":[],
6
+ "meta_class": "TypeMeta"
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "title": "Datetime",
3
+ "type": "object",
4
+ "properties":{},
5
+ "required":[],
6
+ "meta_class": "TypeMeta"
7
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "title": "Dictionary",
3
+ "type": "object",
4
+ "default": null,
5
+ "properties": {},
6
+ "required": [],
7
+ "meta_class": "TypeMeta"
8
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "title": "Number",
3
+ "type": "object",
4
+ "default": null,
5
+ "properties": {},
6
+ "required": [],
7
+ "meta_class": "TypeMeta"
8
+ }
@@ -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
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "title": "String",
3
+ "type": "object",
4
+ "default": "",
5
+ "properties": {},
6
+ "required": [],
7
+ "meta_class": "TypeMeta"
8
+ }
@@ -0,0 +1,16 @@
1
+ from typing import TypeAlias
2
+
3
+ from amsdal_utils.models.enums import ModuleType
4
+
5
+ ModulePathType: TypeAlias = str
6
+ ClassNameType: TypeAlias = str
7
+
8
+
9
+ class ModelModuleInfo:
10
+ _info: dict[ModuleType, dict[ClassNameType, ModulePathType]]
11
+
12
+ def __init__(self, info: dict[ModuleType, dict[ClassNameType, ModulePathType]]) -> None:
13
+ self._info = info
14
+
15
+ def get_by_type(self, module_type: ModuleType) -> dict[ClassNameType, ModulePathType]:
16
+ return self._info.get(module_type, {})
@@ -0,0 +1,10 @@
1
+ from amsdal_utils.models.enums import ModuleType as ModuleType
2
+ from typing import TypeAlias
3
+
4
+ ModulePathType: TypeAlias = str
5
+ ClassNameType: TypeAlias = str
6
+
7
+ class ModelModuleInfo:
8
+ _info: dict[ModuleType, dict[ClassNameType, ModulePathType]]
9
+ def __init__(self, info: dict[ModuleType, dict[ClassNameType, ModulePathType]]) -> None: ...
10
+ def get_by_type(self, module_type: ModuleType) -> dict[ClassNameType, ModulePathType]: ...
@@ -0,0 +1,11 @@
1
+ # AMSDAL services package
2
+
3
+ from amsdal.services.external_connections import ExternalConnectionManager
4
+ from amsdal.services.external_connections import ExternalDatabaseReader
5
+ from amsdal.services.external_model_generator import ExternalModelGenerator
6
+
7
+ __all__ = [
8
+ 'ExternalConnectionManager',
9
+ 'ExternalDatabaseReader',
10
+ 'ExternalModelGenerator',
11
+ ]
@@ -0,0 +1,4 @@
1
+ from amsdal.services.external_connections import ExternalConnectionManager as ExternalConnectionManager, ExternalDatabaseReader as ExternalDatabaseReader
2
+ from amsdal.services.external_model_generator import ExternalModelGenerator as ExternalModelGenerator
3
+
4
+ __all__ = ['ExternalConnectionManager', 'ExternalDatabaseReader', 'ExternalModelGenerator']
@@ -0,0 +1,262 @@
1
+ """
2
+ External Connection Manager for accessing external services and databases.
3
+
4
+ This module provides a high-level interface for working with external connections
5
+ such as read-only databases, email services, storage services, etc.
6
+ """
7
+
8
+ from typing import Any
9
+ from typing import TypeVar
10
+
11
+ from amsdal_data.application import AsyncDataApplication
12
+ from amsdal_data.application import DataApplication
13
+ from amsdal_utils.utils.singleton import Singleton
14
+
15
+ T = TypeVar('T')
16
+
17
+
18
+ class ExternalConnectionManager(metaclass=Singleton):
19
+ """
20
+ Manager for accessing external service connections.
21
+
22
+ Provides a convenient interface to access external connections configured
23
+ in the application, such as read-only databases, email services, etc.
24
+
25
+ Example usage:
26
+ manager = ExternalConnectionManager()
27
+
28
+ # Get read-only database connection
29
+ external_db = manager.get_connection('external_users_db')
30
+ rows = external_db.fetch_all('SELECT * FROM users WHERE active = 1')
31
+
32
+ # Get email service
33
+ email = manager.get_connection('email_service')
34
+ email.send_email(...)
35
+ """
36
+
37
+ def __init__(self) -> None:
38
+ self._data_application: DataApplication | None = None
39
+ self._async_data_application: AsyncDataApplication | None = None
40
+
41
+ def setup(
42
+ self,
43
+ data_application: DataApplication | None = None,
44
+ async_data_application: AsyncDataApplication | None = None,
45
+ ) -> None:
46
+ """
47
+ Set up the manager with the data application instance.
48
+
49
+ Args:
50
+ data_application: Sync DataApplication instance
51
+ async_data_application: Async DataApplication instance
52
+ """
53
+ self._data_application = data_application
54
+ self._async_data_application = async_data_application
55
+
56
+ def get_connection(self, name: str) -> Any:
57
+ """
58
+ Get an external service connection by name.
59
+
60
+ Args:
61
+ name: Name of the external connection (as configured in resources)
62
+
63
+ Returns:
64
+ The external connection object
65
+
66
+ Raises:
67
+ RuntimeError: If manager is not set up
68
+ KeyError: If connection not found
69
+ """
70
+ if self._data_application is None and self._async_data_application is None:
71
+ msg = 'ExternalConnectionManager not set up. Call setup() first.'
72
+ raise RuntimeError(msg)
73
+
74
+ app = self._data_application or self._async_data_application
75
+ if app is None: # Shouldn't happen due to check above, but satisfy mypy
76
+ msg = 'No data application available'
77
+ raise RuntimeError(msg)
78
+ return app.get_external_service_connection(name)
79
+
80
+ def has_connection(self, name: str) -> bool:
81
+ """
82
+ Check if an external connection exists.
83
+
84
+ Args:
85
+ name: Name of the external connection
86
+
87
+ Returns:
88
+ bool: True if connection exists, False otherwise
89
+ """
90
+ if self._data_application is None and self._async_data_application is None:
91
+ return False
92
+
93
+ try:
94
+ self.get_connection(name)
95
+ return True
96
+ except KeyError:
97
+ return False
98
+
99
+ def list_connections(self) -> list[str]:
100
+ """
101
+ List all available external connection names.
102
+
103
+ Returns:
104
+ list[str]: List of connection names
105
+ """
106
+ if self._data_application:
107
+ return list(self._data_application._external_service_connections.keys()) # noqa: SLF001
108
+ if self._async_data_application:
109
+ return list(self._async_data_application._external_service_connections.keys()) # noqa: SLF001
110
+ return []
111
+
112
+
113
+ class ExternalDatabaseReader:
114
+ """
115
+ Helper class for reading from external read-only databases.
116
+
117
+ Provides a convenient interface for querying external databases
118
+ with common patterns like filtering, mapping results, etc.
119
+
120
+ Example usage:
121
+ reader = ExternalDatabaseReader('external_users_db')
122
+
123
+ # Fetch all users
124
+ users = reader.fetch_all('SELECT * FROM users')
125
+
126
+ # Fetch with parameters
127
+ active_users = reader.fetch_all(
128
+ 'SELECT * FROM users WHERE active = ?',
129
+ (1,)
130
+ )
131
+
132
+ # Fetch one record
133
+ user = reader.fetch_one('SELECT * FROM users WHERE id = ?', (user_id,))
134
+
135
+ # Get as dictionaries
136
+ user_dicts = reader.fetch_all_as_dicts('SELECT * FROM users LIMIT 10')
137
+ """
138
+
139
+ def __init__(self, connection_name: str):
140
+ """
141
+ Initialize the reader with a connection name.
142
+
143
+ Args:
144
+ connection_name: Name of the external database connection
145
+ """
146
+ self.connection_name = connection_name
147
+ self._manager = ExternalConnectionManager()
148
+
149
+ @property
150
+ def connection(self) -> Any:
151
+ """Get the underlying connection object."""
152
+ return self._manager.get_connection(self.connection_name)
153
+
154
+ def fetch_all(self, query: str, parameters: tuple[Any, ...] | None = None) -> list[Any]:
155
+ """
156
+ Execute query and fetch all results.
157
+
158
+ Args:
159
+ query: SQL query to execute
160
+ parameters: Query parameters (optional)
161
+
162
+ Returns:
163
+ list: List of result rows
164
+ """
165
+ return self.connection.fetch_all(query, parameters)
166
+
167
+ def fetch_one(self, query: str, parameters: tuple[Any, ...] | None = None) -> Any | None:
168
+ """
169
+ Execute query and fetch one result.
170
+
171
+ Args:
172
+ query: SQL query to execute
173
+ parameters: Query parameters (optional)
174
+
175
+ Returns:
176
+ Single result row or None
177
+ """
178
+ return self.connection.fetch_one(query, parameters)
179
+
180
+ def fetch_all_as_dicts(self, query: str, parameters: tuple[Any, ...] | None = None) -> list[dict[str, Any]]:
181
+ """
182
+ Execute query and fetch all results as dictionaries.
183
+
184
+ Args:
185
+ query: SQL query to execute
186
+ parameters: Query parameters (optional)
187
+
188
+ Returns:
189
+ list[dict]: List of result dictionaries
190
+ """
191
+ rows = self.fetch_all(query, parameters)
192
+ return [dict(row) for row in rows]
193
+
194
+ def fetch_one_as_dict(self, query: str, parameters: tuple[Any, ...] | None = None) -> dict[str, Any] | None:
195
+ """
196
+ Execute query and fetch one result as dictionary.
197
+
198
+ Args:
199
+ query: SQL query to execute
200
+ parameters: Query parameters (optional)
201
+
202
+ Returns:
203
+ dict | None: Result dictionary or None
204
+ """
205
+ row = self.fetch_one(query, parameters)
206
+ return dict(row) if row else None
207
+
208
+ def get_table_names(self) -> list[str]:
209
+ """
210
+ Get list of all tables in the database.
211
+
212
+ Returns:
213
+ list[str]: List of table names
214
+ """
215
+ return self.connection.get_table_names()
216
+
217
+ def get_table_schema(self, table_name: str) -> list[dict[str, Any]]:
218
+ """
219
+ Get schema information for a table.
220
+
221
+ Args:
222
+ table_name: Name of the table
223
+
224
+ Returns:
225
+ list[dict]: List of column information dictionaries
226
+ """
227
+ return self.connection.get_table_schema(table_name)
228
+
229
+ def count(self, table: str, where_clause: str = '', parameters: tuple[Any, ...] | None = None) -> int:
230
+ """
231
+ Count rows in a table.
232
+
233
+ Args:
234
+ table: Table name
235
+ where_clause: Optional WHERE clause (without WHERE keyword)
236
+ parameters: Query parameters for WHERE clause
237
+
238
+ Returns:
239
+ int: Number of rows
240
+ """
241
+ query = f'SELECT COUNT(*) as count FROM {table}' # noqa: S608
242
+ if where_clause:
243
+ query += f' WHERE {where_clause}'
244
+
245
+ result = self.fetch_one(query, parameters)
246
+ return result['count'] if result else 0
247
+
248
+ def exists(self, table: str, where_clause: str, parameters: tuple[Any, ...]) -> bool:
249
+ """
250
+ Check if a record exists.
251
+
252
+ Args:
253
+ table: Table name
254
+ where_clause: WHERE clause (without WHERE keyword)
255
+ parameters: Query parameters
256
+
257
+ Returns:
258
+ bool: True if record exists, False otherwise
259
+ """
260
+ query = f'SELECT 1 FROM {table} WHERE {where_clause} LIMIT 1' # noqa: S608
261
+ result = self.fetch_one(query, parameters)
262
+ return result is not None