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,34 @@
1
+ from pathlib import Path
2
+ from typing import BinaryIO
3
+
4
+
5
+ @classmethod # type: ignore[misc, no-untyped-def]
6
+ def from_file(
7
+ cls,
8
+ file_or_path: Path | BinaryIO,
9
+ ) -> 'File': # type: ignore[name-defined] # noqa: F821
10
+ """
11
+ Creates a `File` object from a file path or a binary file object.
12
+
13
+ Args:
14
+ file_or_path (Path | BinaryIO): The file path or binary file object.
15
+
16
+ Returns:
17
+ File: The created `File` object.
18
+
19
+ Raises:
20
+ ValueError: If the provided path is a directory.
21
+ """
22
+ if isinstance(file_or_path, Path):
23
+ if file_or_path.is_dir():
24
+ msg = f'{file_or_path} is a directory'
25
+ raise ValueError(msg)
26
+
27
+ data = file_or_path.read_bytes()
28
+ filename = file_or_path.name
29
+ else:
30
+ file_or_path.seek(0)
31
+ data = file_or_path.read()
32
+ filename = Path(file_or_path.name).name
33
+
34
+ return cls(data=data, filename=filename)
@@ -0,0 +1,13 @@
1
+ @property # type: ignore[misc]
2
+ def mimetype(self) -> str | None: # type: ignore[no-untyped-def]
3
+ """
4
+ Returns the MIME type of the file based on its filename.
5
+
6
+ This method uses the `mimetypes` module to guess the MIME type of the file.
7
+
8
+ Returns:
9
+ str | None: The guessed MIME type of the file, or None if it cannot be determined.
10
+ """
11
+ import mimetypes
12
+
13
+ return mimetypes.guess_type(self.filename)[0]
@@ -0,0 +1,6 @@
1
+ def __str__(self) -> str: # type: ignore[no-untyped-def] # noqa: N807
2
+ return repr(self)
3
+
4
+
5
+ def __repr__(self) -> str: # type: ignore[no-untyped-def] # noqa: N807
6
+ return f'File<{self.filename}>({self.size or len(self.data) or 0} bytes)'
@@ -0,0 +1,24 @@
1
+ from pathlib import Path
2
+ from typing import BinaryIO
3
+
4
+
5
+ def to_file(self, file_or_path: Path | BinaryIO) -> None: # type: ignore[no-untyped-def]
6
+ """
7
+ Writes the object's data to a file path or a binary file object.
8
+
9
+ Args:
10
+ file_or_path (Path | BinaryIO): The file path or binary file object where the data will be written.
11
+
12
+ Returns:
13
+ None
14
+
15
+ Raises:
16
+ ValueError: If the provided path is a directory.
17
+ """
18
+ if isinstance(file_or_path, Path):
19
+ if file_or_path.is_dir():
20
+ file_or_path = file_or_path / self.name
21
+ file_or_path.write_bytes(self.data) # type: ignore[union-attr]
22
+ else:
23
+ file_or_path.write(self.data)
24
+ file_or_path.seek(0)
@@ -0,0 +1,32 @@
1
+ import base64
2
+
3
+ from pydantic import field_validator
4
+
5
+
6
+ @field_validator('data') # type: ignore[misc]
7
+ @classmethod
8
+ def data_base64_decode(cls, v: bytes) -> bytes: # type: ignore[no-untyped-def] # noqa: ARG001
9
+ """
10
+ Decodes a base64-encoded byte string if it is base64-encoded.
11
+
12
+ This method checks if the provided byte string is base64-encoded and decodes it if true.
13
+ If the byte string is not base64-encoded, it returns the original byte string.
14
+
15
+ Args:
16
+ cls: The class this method belongs to.
17
+ v (bytes): The byte string to be checked and potentially decoded.
18
+
19
+ Returns:
20
+ bytes: The decoded byte string if it was base64-encoded, otherwise the original byte string.
21
+ """
22
+ is_base64: bool = False
23
+
24
+ try:
25
+ is_base64 = base64.b64encode(base64.b64decode(v)) == v
26
+ except Exception:
27
+ ...
28
+
29
+ if is_base64:
30
+ return base64.b64decode(v)
31
+
32
+ return v
@@ -0,0 +1,35 @@
1
+ {
2
+ "title": "Fixture",
3
+ "type": "object",
4
+ "properties": {
5
+ "class_name": {
6
+ "title": "Class Name",
7
+ "type": "string"
8
+ },
9
+ "order": {
10
+ "title": "Order",
11
+ "type": "number"
12
+ },
13
+ "external_id": {
14
+ "title": "External ID",
15
+ "type": "string"
16
+ },
17
+ "data": {
18
+ "title": "Data",
19
+ "type": "dictionary",
20
+ "items": {
21
+ "key": {"type": "string"},
22
+ "value": {"type": "anything"}
23
+ }
24
+ }
25
+ },
26
+ "required": [
27
+ "data",
28
+ "external_id"
29
+ ],
30
+ "unique": [
31
+ [
32
+ "external_id"
33
+ ]
34
+ ]
35
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "title": "Option",
3
+ "type": "object",
4
+ "properties": {
5
+ "key": {
6
+ "title": "Key",
7
+ "type": "string"
8
+ },
9
+ "value": {
10
+ "title": "Value Type",
11
+ "type": "string"
12
+ }
13
+ },
14
+ "required": [
15
+ "key",
16
+ "value"
17
+ ],
18
+ "meta_class": "TypeMeta"
19
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "title": "Validator",
3
+ "type": "object",
4
+ "properties": {
5
+ "name": {
6
+ "title": "Validator Name",
7
+ "type": "string"
8
+ },
9
+ "data": {
10
+ "title": "Validator Data",
11
+ "type": "anything"
12
+ }
13
+ },
14
+ "required": [
15
+ "name",
16
+ "data"
17
+ ],
18
+ "meta_class": "TypeMeta"
19
+ }
@@ -0,0 +1,116 @@
1
+ from amsdal_models.schemas.manager import SchemaManagerHandler
2
+ from amsdal_utils.models.data_models.enums import BaseClasses
3
+ from amsdal_utils.models.data_models.schema import ObjectSchema
4
+ from amsdal_utils.models.enums import SchemaTypes
5
+ from amsdal_utils.utils.singleton import Singleton
6
+
7
+ from amsdal.configs.main import settings
8
+
9
+
10
+ class SchemaManager(metaclass=Singleton):
11
+ """
12
+ Manages schema operations including retrieval, invalidation, and sorting.
13
+
14
+ This class handles various schema-related operations such as invalidating user schemas,
15
+ retrieving schemas by name or type, and sorting schemas based on predefined rules.
16
+ """
17
+
18
+ def __init__(self) -> None:
19
+ self._schema_manager_handler = SchemaManagerHandler(settings.schemas_root_path)
20
+
21
+ def invalidate_user_schemas(self) -> None:
22
+ """
23
+ Invalidates user schemas.
24
+
25
+ This method calls the handler to invalidate all user schemas, ensuring that any cached or outdated schemas
26
+ are refreshed.
27
+
28
+ Returns:
29
+ None
30
+ """
31
+ self._schema_manager_handler.invalidate_user_schemas()
32
+
33
+ def class_schemas(self) -> list[tuple[ObjectSchema, SchemaTypes]]:
34
+ """
35
+ Returns a list of tuples containing object schemas and their types.
36
+
37
+ This method retrieves and sorts various schemas managed by the schema manager handler.
38
+ The schemas are categorized into types, core, user, and contrib schemas.
39
+
40
+ Returns:
41
+ list[tuple[ObjectSchema, SchemaTypes]]: A list of tuples where each tuple contains an object schema
42
+ and its corresponding type.
43
+ """
44
+ return (
45
+ [
46
+ (type_schema, SchemaTypes.TYPE)
47
+ for type_schema in self._schema_manager_handler.type_schemas
48
+ if type_schema.title == BaseClasses.OBJECT
49
+ ]
50
+ + [
51
+ (core_schema, SchemaTypes.CORE)
52
+ for core_schema in sorted(self._schema_manager_handler.core_schemas, key=self._sort_key_for_schema)
53
+ ]
54
+ + [(user_schema, SchemaTypes.USER) for user_schema in self._schema_manager_handler.user_schemas]
55
+ + [(contrib_schema, SchemaTypes.CONTRIB) for contrib_schema in self._schema_manager_handler.contrib_schemas]
56
+ )
57
+
58
+ @staticmethod
59
+ def _sort_key_for_schema(schema: ObjectSchema) -> int:
60
+ # We need to register ClassObject first, coz ClassObjectMeta has a reference to it.
61
+ # All other classes have reference to ClassObject
62
+ if schema.title == BaseClasses.CLASS_OBJECT:
63
+ return 0
64
+ elif schema.title == BaseClasses.CLASS_OBJECT_META:
65
+ return 1
66
+ else:
67
+ return 2
68
+
69
+ def get_schema_by_name(self, title: str, schema_type: SchemaTypes | None = None) -> ObjectSchema | None:
70
+ """
71
+ Retrieves a schema by its title and optional type.
72
+
73
+ This method searches for a schema with the specified title and optional type
74
+ among the schemas managed by the schema manager handler.
75
+
76
+ Args:
77
+ title (str): The title of the schema to be retrieved.
78
+ schema_type (SchemaTypes | None, optional): The type of the schema to be retrieved. Defaults to None.
79
+
80
+ Returns:
81
+ ObjectSchema | None: The schema with the specified title and type, or None if not found.
82
+ """
83
+ _schemas = self.get_schemas(schema_type)
84
+
85
+ for schema in _schemas:
86
+ if schema.title == title:
87
+ return schema
88
+
89
+ return None
90
+
91
+ def get_schemas(self, schema_type: SchemaTypes | None = None) -> list[ObjectSchema]:
92
+ """
93
+ Retrieves schemas based on the provided type.
94
+
95
+ This method returns a list of schemas filtered by the specified type. If no type is provided,
96
+ it returns all schemas managed by the schema manager handler.
97
+
98
+ Args:
99
+ schema_type (SchemaTypes | None, optional): The type of schemas to retrieve. Defaults to None.
100
+
101
+ Returns:
102
+ list[ObjectSchema]: A list of schemas filtered by the specified type, or all schemas if no type is provided.
103
+ """
104
+ if schema_type == SchemaTypes.CONTRIB:
105
+ return self._schema_manager_handler.contrib_schemas
106
+
107
+ if schema_type == SchemaTypes.CORE:
108
+ return self._schema_manager_handler.core_schemas
109
+
110
+ if schema_type == SchemaTypes.TYPE:
111
+ return self._schema_manager_handler.type_schemas
112
+
113
+ if schema_type == SchemaTypes.USER:
114
+ return self._schema_manager_handler.user_schemas
115
+
116
+ return self._schema_manager_handler.all_schemas
@@ -0,0 +1,65 @@
1
+ from _typeshed import Incomplete
2
+ from amsdal.configs.main import settings as settings
3
+ from amsdal_utils.models.data_models.schema import ObjectSchema as ObjectSchema
4
+ from amsdal_utils.models.enums import SchemaTypes
5
+ from amsdal_utils.utils.singleton import Singleton
6
+
7
+ class SchemaManager(metaclass=Singleton):
8
+ """
9
+ Manages schema operations including retrieval, invalidation, and sorting.
10
+
11
+ This class handles various schema-related operations such as invalidating user schemas,
12
+ retrieving schemas by name or type, and sorting schemas based on predefined rules.
13
+ """
14
+ _schema_manager_handler: Incomplete
15
+ def __init__(self) -> None: ...
16
+ def invalidate_user_schemas(self) -> None:
17
+ """
18
+ Invalidates user schemas.
19
+
20
+ This method calls the handler to invalidate all user schemas, ensuring that any cached or outdated schemas
21
+ are refreshed.
22
+
23
+ Returns:
24
+ None
25
+ """
26
+ def class_schemas(self) -> list[tuple[ObjectSchema, SchemaTypes]]:
27
+ """
28
+ Returns a list of tuples containing object schemas and their types.
29
+
30
+ This method retrieves and sorts various schemas managed by the schema manager handler.
31
+ The schemas are categorized into types, core, user, and contrib schemas.
32
+
33
+ Returns:
34
+ list[tuple[ObjectSchema, SchemaTypes]]: A list of tuples where each tuple contains an object schema
35
+ and its corresponding type.
36
+ """
37
+ @staticmethod
38
+ def _sort_key_for_schema(schema: ObjectSchema) -> int: ...
39
+ def get_schema_by_name(self, title: str, schema_type: SchemaTypes | None = None) -> ObjectSchema | None:
40
+ """
41
+ Retrieves a schema by its title and optional type.
42
+
43
+ This method searches for a schema with the specified title and optional type
44
+ among the schemas managed by the schema manager handler.
45
+
46
+ Args:
47
+ title (str): The title of the schema to be retrieved.
48
+ schema_type (SchemaTypes | None, optional): The type of the schema to be retrieved. Defaults to None.
49
+
50
+ Returns:
51
+ ObjectSchema | None: The schema with the specified title and type, or None if not found.
52
+ """
53
+ def get_schemas(self, schema_type: SchemaTypes | None = None) -> list[ObjectSchema]:
54
+ """
55
+ Retrieves schemas based on the provided type.
56
+
57
+ This method returns a list of schemas filtered by the specified type. If no type is provided,
58
+ it returns all schemas managed by the schema manager handler.
59
+
60
+ Args:
61
+ schema_type (SchemaTypes | None, optional): The type of schemas to retrieve. Defaults to None.
62
+
63
+ Returns:
64
+ list[ObjectSchema]: A list of schemas filtered by the specified type, or all schemas if no type is provided.
65
+ """
@@ -0,0 +1,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
+ }
File without changes
@@ -0,0 +1,76 @@
1
+ import ast
2
+ from _typeshed import Incomplete
3
+ from amsdal.configs.main import settings as settings
4
+ from amsdal.errors import TransactionNotFoundError as TransactionNotFoundError
5
+ from amsdal_utils.utils.singleton import Singleton
6
+ from collections.abc import Callable as Callable, Generator
7
+ from pathlib import Path
8
+ from typing import Any
9
+
10
+ logger: Incomplete
11
+
12
+ def is_transaction(statement: ast.AST) -> bool:
13
+ """
14
+ Determines if a given AST statement is a transaction function.
15
+
16
+ This function checks if the provided AST statement is an asynchronous or synchronous function
17
+ definition that is decorated with the `transaction` decorator.
18
+
19
+ Args:
20
+ statement (ast.AST): The AST statement to check.
21
+
22
+ Returns:
23
+ bool: True if the statement is a transaction function, False otherwise.
24
+ """
25
+
26
+ class TransactionExecutionService(metaclass=Singleton):
27
+ """
28
+ Service for executing transactions.
29
+
30
+ This class provides methods to execute transactions, load transaction functions,
31
+ and handle asynchronous transactions. It ensures that transactions are executed
32
+ with the correct arguments and handles any necessary preprocessing of arguments.
33
+ """
34
+ _transactions: Incomplete
35
+ def __init__(self) -> None: ...
36
+ def execute_transaction(self, transaction_name: str, args: dict[str, Any], *, load_references: bool = True) -> Any:
37
+ """
38
+ Executes a transaction with the given name and arguments.
39
+
40
+ This method retrieves the transaction function by its name, processes the arguments,
41
+ and executes the transaction. It handles both synchronous and asynchronous transactions
42
+ and performs necessary preprocessing of arguments, such as loading references.
43
+
44
+ Args:
45
+ transaction_name (str): The name of the transaction to execute.
46
+ args (dict[str, Any]): The arguments to pass to the transaction function.
47
+ load_references (bool, optional): Whether to load references in the arguments. Defaults to True.
48
+
49
+ Returns:
50
+ Any: The result of the transaction execution.
51
+ """
52
+ def get_transaction_func(self, transaction_name: str) -> Callable[..., Any]:
53
+ """
54
+ Retrieves the transaction function by its name.
55
+
56
+ This method checks if the transaction function is already loaded in the `_transactions` dictionary.
57
+ If not, it attempts to load the transaction function from the available transaction definitions.
58
+
59
+ Args:
60
+ transaction_name (str): The name of the transaction function to retrieve.
61
+
62
+ Returns:
63
+ Callable[..., Any]: The transaction function corresponding to the given name.
64
+
65
+ Raises:
66
+ TransactionNotFoundError: If the transaction function with the specified name is not found.
67
+ """
68
+ @staticmethod
69
+ def _run_async_transaction(transaction_func: Callable[..., Any], args: dict[str, Any]) -> Any: ...
70
+ def _load_transaction(self, transaction_name: str) -> Callable[..., Any]: ...
71
+ @classmethod
72
+ def _get_transaction_definitions(cls) -> Generator[tuple[ast.FunctionDef | ast.AsyncFunctionDef, Path], None, None]: ...
73
+ @classmethod
74
+ def _iterate_module(cls, module_path: Path) -> Generator[tuple[ast.FunctionDef | ast.AsyncFunctionDef, Path], None, None]: ...
75
+ @classmethod
76
+ def _iterate_file(cls, file_path: Path) -> Generator[tuple[ast.FunctionDef | ast.AsyncFunctionDef, Path], None, None]: ...
File without changes
File without changes
@@ -0,0 +1,23 @@
1
+ from collections.abc import Generator
2
+ from importlib import import_module
3
+ from pathlib import Path
4
+
5
+
6
+ def get_contrib_schemas_paths() -> Generator[Path, None, None]:
7
+ """
8
+ Retrieves paths to contribution schemas.
9
+
10
+ This function iterates over the configured contributions in the settings and yields
11
+ the paths to the 'models' directories for each contribution.
12
+
13
+ Returns:
14
+ Generator[Path, None, None]: A generator that yields paths to the 'models' directories
15
+ of the configured contributions.
16
+ """
17
+ from amsdal.configs.main import settings
18
+
19
+ for contrib in settings.CONTRIB:
20
+ module_name, *_ = contrib.rsplit('.', 2)
21
+ module = import_module(module_name)
22
+
23
+ yield Path(module.__file__).parent / 'models' # type: ignore[arg-type]
@@ -0,0 +1,14 @@
1
+ from collections.abc import Generator
2
+ from pathlib import Path
3
+
4
+ def get_contrib_schemas_paths() -> Generator[Path, None, None]:
5
+ """
6
+ Retrieves paths to contribution schemas.
7
+
8
+ This function iterates over the configured contributions in the settings and yields
9
+ the paths to the 'models' directories for each contribution.
10
+
11
+ Returns:
12
+ Generator[Path, None, None]: A generator that yields paths to the 'models' directories
13
+ of the configured contributions.
14
+ """
File without changes
@@ -0,0 +1,18 @@
1
+ from enum import Enum
2
+
3
+
4
+ class DbExecutionType(str, Enum):
5
+ lakehouse_only = 'lakehouse_only'
6
+ include_state_db = 'include_state_db'
7
+
8
+
9
+ class StateOption(str, Enum):
10
+ sqlite = 'sqlite'
11
+ postgres = 'postgres'
12
+
13
+
14
+ class LakehouseOption(str, Enum):
15
+ postgres = 'postgres'
16
+ postgres_immutable = 'postgres-immutable'
17
+ sqlite = 'sqlite'
18
+ sqlite_immutable = 'sqlite-immutable'