amsdal 0.5.34__cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.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.
Files changed (276) hide show
  1. amsdal/Third-Party Materials - AMSDAL Dependencies - License Notices.md +1362 -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-313-x86_64-linux-gnu.so +0 -0
  12. amsdal/cloud/__init__.pyi +0 -0
  13. amsdal/cloud/client.cpython-313-x86_64-linux-gnu.so +0 -0
  14. amsdal/cloud/client.pyi +57 -0
  15. amsdal/cloud/constants.cpython-313-x86_64-linux-gnu.so +0 -0
  16. amsdal/cloud/constants.pyi +13 -0
  17. amsdal/cloud/enums.cpython-313-x86_64-linux-gnu.so +0 -0
  18. amsdal/cloud/enums.pyi +68 -0
  19. amsdal/cloud/models/__init__.cpython-313-x86_64-linux-gnu.so +0 -0
  20. amsdal/cloud/models/__init__.pyi +0 -0
  21. amsdal/cloud/models/base.cpython-313-x86_64-linux-gnu.so +0 -0
  22. amsdal/cloud/models/base.pyi +247 -0
  23. amsdal/cloud/services/__init__.cpython-313-x86_64-linux-gnu.so +0 -0
  24. amsdal/cloud/services/__init__.pyi +0 -0
  25. amsdal/cloud/services/actions/__init__.cpython-313-x86_64-linux-gnu.so +0 -0
  26. amsdal/cloud/services/actions/__init__.pyi +0 -0
  27. amsdal/cloud/services/actions/add_allowlist_ip.cpython-313-x86_64-linux-gnu.so +0 -0
  28. amsdal/cloud/services/actions/add_allowlist_ip.pyi +19 -0
  29. amsdal/cloud/services/actions/add_basic_auth.cpython-313-x86_64-linux-gnu.so +0 -0
  30. amsdal/cloud/services/actions/add_basic_auth.pyi +21 -0
  31. amsdal/cloud/services/actions/add_dependency.cpython-313-x86_64-linux-gnu.so +0 -0
  32. amsdal/cloud/services/actions/add_dependency.pyi +19 -0
  33. amsdal/cloud/services/actions/add_secret.cpython-313-x86_64-linux-gnu.so +0 -0
  34. amsdal/cloud/services/actions/add_secret.pyi +20 -0
  35. amsdal/cloud/services/actions/base.cpython-313-x86_64-linux-gnu.so +0 -0
  36. amsdal/cloud/services/actions/base.pyi +122 -0
  37. amsdal/cloud/services/actions/create_deploy.cpython-313-x86_64-linux-gnu.so +0 -0
  38. amsdal/cloud/services/actions/create_deploy.pyi +41 -0
  39. amsdal/cloud/services/actions/create_env.cpython-313-x86_64-linux-gnu.so +0 -0
  40. amsdal/cloud/services/actions/create_env.pyi +19 -0
  41. amsdal/cloud/services/actions/create_session.cpython-313-x86_64-linux-gnu.so +0 -0
  42. amsdal/cloud/services/actions/create_session.pyi +17 -0
  43. amsdal/cloud/services/actions/delete_allowlist_ip.cpython-313-x86_64-linux-gnu.so +0 -0
  44. amsdal/cloud/services/actions/delete_allowlist_ip.pyi +19 -0
  45. amsdal/cloud/services/actions/delete_basic_auth.cpython-313-x86_64-linux-gnu.so +0 -0
  46. amsdal/cloud/services/actions/delete_basic_auth.pyi +20 -0
  47. amsdal/cloud/services/actions/delete_dependency.cpython-313-x86_64-linux-gnu.so +0 -0
  48. amsdal/cloud/services/actions/delete_dependency.pyi +21 -0
  49. amsdal/cloud/services/actions/delete_env.cpython-313-x86_64-linux-gnu.so +0 -0
  50. amsdal/cloud/services/actions/delete_env.pyi +21 -0
  51. amsdal/cloud/services/actions/delete_secret.cpython-313-x86_64-linux-gnu.so +0 -0
  52. amsdal/cloud/services/actions/delete_secret.pyi +21 -0
  53. amsdal/cloud/services/actions/destroy_deploy.cpython-313-x86_64-linux-gnu.so +0 -0
  54. amsdal/cloud/services/actions/destroy_deploy.pyi +18 -0
  55. amsdal/cloud/services/actions/expose_db.cpython-313-x86_64-linux-gnu.so +0 -0
  56. amsdal/cloud/services/actions/expose_db.pyi +22 -0
  57. amsdal/cloud/services/actions/get_basic_auth_credentials.cpython-313-x86_64-linux-gnu.so +0 -0
  58. amsdal/cloud/services/actions/get_basic_auth_credentials.pyi +21 -0
  59. amsdal/cloud/services/actions/get_monitoring_info.cpython-313-x86_64-linux-gnu.so +0 -0
  60. amsdal/cloud/services/actions/get_monitoring_info.pyi +21 -0
  61. amsdal/cloud/services/actions/list_dependencies.cpython-313-x86_64-linux-gnu.so +0 -0
  62. amsdal/cloud/services/actions/list_dependencies.pyi +21 -0
  63. amsdal/cloud/services/actions/list_deploys.cpython-313-x86_64-linux-gnu.so +0 -0
  64. amsdal/cloud/services/actions/list_deploys.pyi +19 -0
  65. amsdal/cloud/services/actions/list_envs.cpython-313-x86_64-linux-gnu.so +0 -0
  66. amsdal/cloud/services/actions/list_envs.pyi +20 -0
  67. amsdal/cloud/services/actions/list_secrets.cpython-313-x86_64-linux-gnu.so +0 -0
  68. amsdal/cloud/services/actions/list_secrets.pyi +22 -0
  69. amsdal/cloud/services/actions/manager.cpython-313-x86_64-linux-gnu.so +0 -0
  70. amsdal/cloud/services/actions/manager.pyi +278 -0
  71. amsdal/cloud/services/actions/signup_action.cpython-313-x86_64-linux-gnu.so +0 -0
  72. amsdal/cloud/services/actions/signup_action.pyi +20 -0
  73. amsdal/cloud/services/actions/update_deploy.cpython-313-x86_64-linux-gnu.so +0 -0
  74. amsdal/cloud/services/actions/update_deploy.pyi +19 -0
  75. amsdal/cloud/services/auth/__init__.cpython-313-x86_64-linux-gnu.so +0 -0
  76. amsdal/cloud/services/auth/__init__.pyi +0 -0
  77. amsdal/cloud/services/auth/base.cpython-313-x86_64-linux-gnu.so +0 -0
  78. amsdal/cloud/services/auth/base.pyi +6 -0
  79. amsdal/cloud/services/auth/credentials.cpython-313-x86_64-linux-gnu.so +0 -0
  80. amsdal/cloud/services/auth/credentials.pyi +30 -0
  81. amsdal/cloud/services/auth/manager.cpython-313-x86_64-linux-gnu.so +0 -0
  82. amsdal/cloud/services/auth/manager.pyi +26 -0
  83. amsdal/cloud/services/auth/signup_service.cpython-313-x86_64-linux-gnu.so +0 -0
  84. amsdal/cloud/services/auth/signup_service.pyi +32 -0
  85. amsdal/cloud/services/auth/token.cpython-313-x86_64-linux-gnu.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-313-x86_64-linux-gnu.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 +43 -0
  108. amsdal/contrib/auth/errors.pyi +16 -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/migrations/0001_add_mfa_support.py +188 -0
  116. amsdal/contrib/auth/models/__init__.py +1 -0
  117. amsdal/contrib/auth/models/backup_code.py +85 -0
  118. amsdal/contrib/auth/models/email_mfa_device.py +108 -0
  119. amsdal/contrib/auth/models/login_session.py +235 -0
  120. amsdal/contrib/auth/models/mfa_device.py +86 -0
  121. amsdal/contrib/auth/models/permission.py +23 -0
  122. amsdal/contrib/auth/models/sms_device.py +113 -0
  123. amsdal/contrib/auth/models/totp_device.py +58 -0
  124. amsdal/contrib/auth/models/user.py +156 -0
  125. amsdal/contrib/auth/services/__init__.py +1 -0
  126. amsdal/contrib/auth/services/__init__.pyi +0 -0
  127. amsdal/contrib/auth/services/mfa_device_service.py +544 -0
  128. amsdal/contrib/auth/services/mfa_device_service.pyi +216 -0
  129. amsdal/contrib/auth/services/totp_service.py +358 -0
  130. amsdal/contrib/auth/services/totp_service.pyi +158 -0
  131. amsdal/contrib/auth/settings.py +44 -0
  132. amsdal/contrib/auth/settings.pyi +34 -0
  133. amsdal/contrib/auth/transactions/__init__.py +1 -0
  134. amsdal/contrib/auth/transactions/__init__.pyi +0 -0
  135. amsdal/contrib/auth/transactions/mfa_device_transactions.py +458 -0
  136. amsdal/contrib/auth/transactions/mfa_device_transactions.pyi +226 -0
  137. amsdal/contrib/auth/transactions/totp_transactions.py +203 -0
  138. amsdal/contrib/auth/transactions/totp_transactions.pyi +113 -0
  139. amsdal/contrib/auth/utils/__init__.py +0 -0
  140. amsdal/contrib/auth/utils/__init__.pyi +0 -0
  141. amsdal/contrib/auth/utils/mfa.py +257 -0
  142. amsdal/contrib/auth/utils/mfa.pyi +119 -0
  143. amsdal/contrib/frontend_configs/__init__.py +0 -0
  144. amsdal/contrib/frontend_configs/__init__.pyi +0 -0
  145. amsdal/contrib/frontend_configs/app.py +24 -0
  146. amsdal/contrib/frontend_configs/app.pyi +19 -0
  147. amsdal/contrib/frontend_configs/constants.py +1 -0
  148. amsdal/contrib/frontend_configs/constants.pyi +1 -0
  149. amsdal/contrib/frontend_configs/conversion/__init__.py +5 -0
  150. amsdal/contrib/frontend_configs/conversion/__init__.pyi +3 -0
  151. amsdal/contrib/frontend_configs/conversion/convert.py +310 -0
  152. amsdal/contrib/frontend_configs/conversion/convert.pyi +22 -0
  153. amsdal/contrib/frontend_configs/lifecycle/__init__.py +0 -0
  154. amsdal/contrib/frontend_configs/lifecycle/__init__.pyi +0 -0
  155. amsdal/contrib/frontend_configs/lifecycle/consumer.py +306 -0
  156. amsdal/contrib/frontend_configs/lifecycle/consumer.pyi +98 -0
  157. amsdal/contrib/frontend_configs/migrations/0000_initial.py +227 -0
  158. amsdal/contrib/frontend_configs/migrations/0001_update_frontend_control_config.py +245 -0
  159. amsdal/contrib/frontend_configs/migrations/0002_add_button_and_invoke_actions.py +352 -0
  160. amsdal/contrib/frontend_configs/migrations/0003_create_class_frontendconfigdashboardelement.py +145 -0
  161. amsdal/contrib/frontend_configs/models/__init__.py +0 -0
  162. amsdal/contrib/frontend_configs/models/frontend_activator_config.py +22 -0
  163. amsdal/contrib/frontend_configs/models/frontend_config_async_validator.py +11 -0
  164. amsdal/contrib/frontend_configs/models/frontend_config_control_action.py +110 -0
  165. amsdal/contrib/frontend_configs/models/frontend_config_dashboard.py +51 -0
  166. amsdal/contrib/frontend_configs/models/frontend_config_group_validator.py +21 -0
  167. amsdal/contrib/frontend_configs/models/frontend_config_option.py +12 -0
  168. amsdal/contrib/frontend_configs/models/frontend_config_skip_none_base.py +17 -0
  169. amsdal/contrib/frontend_configs/models/frontend_config_slider_option.py +13 -0
  170. amsdal/contrib/frontend_configs/models/frontend_config_text_mask.py +14 -0
  171. amsdal/contrib/frontend_configs/models/frontend_config_validator.py +28 -0
  172. amsdal/contrib/frontend_configs/models/frontend_control_config.py +110 -0
  173. amsdal/contrib/frontend_configs/models/frontend_model_config.py +14 -0
  174. amsdal/contrib/frontend_configs/utils.py +29 -0
  175. amsdal/contrib/frontend_configs/utils.pyi +17 -0
  176. amsdal/errors.py +31 -0
  177. amsdal/errors.pyi +12 -0
  178. amsdal/fixtures/__init__.cpython-313-x86_64-linux-gnu.so +0 -0
  179. amsdal/fixtures/__init__.pyi +0 -0
  180. amsdal/fixtures/manager.cpython-313-x86_64-linux-gnu.so +0 -0
  181. amsdal/fixtures/manager.pyi +170 -0
  182. amsdal/fixtures/utils.cpython-313-x86_64-linux-gnu.so +0 -0
  183. amsdal/fixtures/utils.pyi +9 -0
  184. amsdal/manager.cpython-313-x86_64-linux-gnu.so +0 -0
  185. amsdal/manager.pyi +265 -0
  186. amsdal/mixins/__init__.cpython-313-x86_64-linux-gnu.so +0 -0
  187. amsdal/mixins/__init__.pyi +0 -0
  188. amsdal/mixins/class_versions_mixin.cpython-313-x86_64-linux-gnu.so +0 -0
  189. amsdal/mixins/class_versions_mixin.pyi +12 -0
  190. amsdal/models/__init__.py +19 -0
  191. amsdal/models/core/__init__.py +0 -0
  192. amsdal/models/core/class_object.py +38 -0
  193. amsdal/models/core/class_property.py +26 -0
  194. amsdal/models/core/file.py +243 -0
  195. amsdal/models/core/fixture.py +25 -0
  196. amsdal/models/core/option.py +11 -0
  197. amsdal/models/core/storage_metadata.py +15 -0
  198. amsdal/models/core/validator.py +12 -0
  199. amsdal/models/mixins.py +31 -0
  200. amsdal/models/types/__init__.py +0 -0
  201. amsdal/models/types/object.py +26 -0
  202. amsdal/py.typed +0 -0
  203. amsdal/queryset/__init__.py +21 -0
  204. amsdal/queryset/__init__.pyi +6 -0
  205. amsdal/schemas/__init__.py +0 -0
  206. amsdal/schemas/__init__.pyi +0 -0
  207. amsdal/schemas/core/class_object/model.json +51 -0
  208. amsdal/schemas/core/class_object/properties/display_name.py +9 -0
  209. amsdal/schemas/core/class_property/model.json +41 -0
  210. amsdal/schemas/core/file/hooks/pre_create.py +24 -0
  211. amsdal/schemas/core/file/hooks/pre_update.py +24 -0
  212. amsdal/schemas/core/file/model.json +23 -0
  213. amsdal/schemas/core/file/properties/from_file.py +34 -0
  214. amsdal/schemas/core/file/properties/mimetype.py +13 -0
  215. amsdal/schemas/core/file/properties/str.py +6 -0
  216. amsdal/schemas/core/file/properties/to_file.py +24 -0
  217. amsdal/schemas/core/file/properties/validate_data.py +31 -0
  218. amsdal/schemas/core/fixture/model.json +35 -0
  219. amsdal/schemas/core/option/model.json +19 -0
  220. amsdal/schemas/core/storage_metadata/model.json +52 -0
  221. amsdal/schemas/core/validator/model.json +19 -0
  222. amsdal/schemas/interfaces.py +25 -0
  223. amsdal/schemas/interfaces.pyi +20 -0
  224. amsdal/schemas/manager.cpython-313-x86_64-linux-gnu.so +0 -0
  225. amsdal/schemas/manager.py +0 -0
  226. amsdal/schemas/manager.pyi +0 -0
  227. amsdal/schemas/mixins/__init__.py +0 -0
  228. amsdal/schemas/mixins/__init__.pyi +0 -0
  229. amsdal/schemas/mixins/check_dependencies_mixin.py +130 -0
  230. amsdal/schemas/mixins/check_dependencies_mixin.pyi +45 -0
  231. amsdal/schemas/mixins/verify_schemas_mixin.py +96 -0
  232. amsdal/schemas/mixins/verify_schemas_mixin.pyi +33 -0
  233. amsdal/schemas/repository.py +84 -0
  234. amsdal/schemas/repository.pyi +22 -0
  235. amsdal/schemas/types/anything/model.json +7 -0
  236. amsdal/schemas/types/array/model.json +7 -0
  237. amsdal/schemas/types/binary/model.json +7 -0
  238. amsdal/schemas/types/boolean/model.json +17 -0
  239. amsdal/schemas/types/date/model.json +7 -0
  240. amsdal/schemas/types/datetime/model.json +7 -0
  241. amsdal/schemas/types/dictionary/model.json +8 -0
  242. amsdal/schemas/types/number/model.json +8 -0
  243. amsdal/schemas/types/object/model.json +53 -0
  244. amsdal/schemas/types/string/model.json +8 -0
  245. amsdal/schemas/utils.py +16 -0
  246. amsdal/schemas/utils.pyi +10 -0
  247. amsdal/services/__init__.py +11 -0
  248. amsdal/services/__init__.pyi +4 -0
  249. amsdal/services/external_connections.py +262 -0
  250. amsdal/services/external_connections.pyi +190 -0
  251. amsdal/services/external_model_generator.py +350 -0
  252. amsdal/services/external_model_generator.pyi +134 -0
  253. amsdal/services/transaction_execution.cpython-313-x86_64-linux-gnu.so +0 -0
  254. amsdal/services/transaction_execution.pyi +93 -0
  255. amsdal/storages/__init__.py +20 -0
  256. amsdal/storages/__init__.pyi +8 -0
  257. amsdal/storages/file_system.py +214 -0
  258. amsdal/storages/file_system.pyi +36 -0
  259. amsdal/transactions/__init__.py +13 -0
  260. amsdal/transactions/__init__.pyi +4 -0
  261. amsdal/utils/__init__.py +0 -0
  262. amsdal/utils/__init__.pyi +0 -0
  263. amsdal/utils/contrib_paths.py +23 -0
  264. amsdal/utils/contrib_paths.pyi +14 -0
  265. amsdal/utils/rollback/__init__.py +440 -0
  266. amsdal/utils/rollback/__init__.pyi +38 -0
  267. amsdal/utils/tests/__init__.py +0 -0
  268. amsdal/utils/tests/enums.py +16 -0
  269. amsdal/utils/tests/factories.py +49 -0
  270. amsdal/utils/tests/helpers.py +331 -0
  271. amsdal/utils/tests/migrations.py +157 -0
  272. amsdal-0.5.34.dist-info/METADATA +375 -0
  273. amsdal-0.5.34.dist-info/RECORD +276 -0
  274. amsdal-0.5.34.dist-info/WHEEL +6 -0
  275. amsdal-0.5.34.dist-info/licenses/LICENSE.txt +107 -0
  276. amsdal-0.5.34.dist-info/top_level.txt +1 -0
amsdal/__about__.py ADDED
@@ -0,0 +1,4 @@
1
+ # SPDX-FileCopyrightText: 2023-present
2
+ #
3
+ # SPDX-License-Identifier: AMSDAL End User License Agreement
4
+ __version__ = '0.5.34'
amsdal/__about__.pyi ADDED
@@ -0,0 +1 @@
1
+ __version__: str
amsdal/__init__.py ADDED
@@ -0,0 +1,23 @@
1
+ # SPDX-FileCopyrightText: 2023-present
2
+ #
3
+ # SPDX-License-Identifier: TODO
4
+ from amsdal_data.aliases.using import DEFAULT_DB_ALIAS
5
+ from amsdal_data.aliases.using import LAKEHOUSE_DB_ALIAS
6
+ from amsdal_models.classes.helpers.reference_loader import ReferenceLoader
7
+ from amsdal_utils.config.manager import AmsdalConfigManager
8
+ from amsdal_utils.models.data_models.metadata import Metadata
9
+ from amsdal_utils.models.data_models.reference import Reference
10
+ from amsdal_utils.models.enums import Versions
11
+
12
+ from amsdal.context.manager import AmsdalContextManager
13
+
14
+ __all__ = [
15
+ 'DEFAULT_DB_ALIAS',
16
+ 'LAKEHOUSE_DB_ALIAS',
17
+ 'AmsdalConfigManager',
18
+ 'AmsdalContextManager',
19
+ 'Metadata',
20
+ 'Reference',
21
+ 'ReferenceLoader',
22
+ 'Versions',
23
+ ]
amsdal/__init__.pyi ADDED
@@ -0,0 +1,9 @@
1
+ from amsdal.context.manager import AmsdalContextManager as AmsdalContextManager
2
+ from amsdal_data.aliases.using import DEFAULT_DB_ALIAS as DEFAULT_DB_ALIAS, LAKEHOUSE_DB_ALIAS as LAKEHOUSE_DB_ALIAS
3
+ from amsdal_models.classes.helpers.reference_loader import ReferenceLoader as ReferenceLoader
4
+ from amsdal_utils.config.manager import AmsdalConfigManager as AmsdalConfigManager
5
+ from amsdal_utils.models.data_models.metadata import Metadata as Metadata
6
+ from amsdal_utils.models.data_models.reference import Reference as Reference
7
+ from amsdal_utils.models.enums import Versions as Versions
8
+
9
+ __all__ = ['DEFAULT_DB_ALIAS', 'LAKEHOUSE_DB_ALIAS', 'AmsdalConfigManager', 'AmsdalContextManager', 'Metadata', 'Reference', 'ReferenceLoader', 'Versions']
@@ -0,0 +1,36 @@
1
+ from amsdal_models.migration import migrations
2
+ from amsdal_utils.models.enums import ModuleType
3
+
4
+
5
+ class Migration(migrations.Migration):
6
+ operations: list[migrations.Operation] = [
7
+ migrations.CreateClass(
8
+ module_type=ModuleType.TYPE,
9
+ class_name='Object',
10
+ new_schema={
11
+ "title": "Object",
12
+ "required": ["title", "type", "module_type"],
13
+ "properties": {
14
+ "title": {"type": "string", "title": "Title"},
15
+ "type": {"type": "string", "title": "Type"},
16
+ "module_type": {"type": "string", "title": "Module Type"},
17
+ "default": {"type": "anything", "title": "Default"},
18
+ "properties": {
19
+ "type": "dictionary",
20
+ "items": {"key": {"type": "string"}, "value": {"type": "anything"}},
21
+ "title": "Properties",
22
+ },
23
+ "required": {"type": "array", "items": {"type": "string"}, "title": "Required"},
24
+ "custom_code": {"type": "string", "title": "Custom Code"},
25
+ "meta_class": {"type": "string", "title": "Meta Class"},
26
+ },
27
+ "custom_code": "from typing import Any\n\nfrom amsdal_models.builder.validators.dict_validators import validate_non_empty_keys\nfrom pydantic.functional_validators import field_validator\n\n\n@field_validator('properties')\n@classmethod\ndef _non_empty_keys_properties(cls: type, value: Any) -> Any:\n return validate_non_empty_keys(value)",
28
+ "storage_metadata": {
29
+ "table_name": "Object",
30
+ "db_fields": {},
31
+ "primary_key": ["partition_key"],
32
+ "foreign_keys": {},
33
+ },
34
+ },
35
+ ),
36
+ ]
@@ -0,0 +1,61 @@
1
+ from amsdal_models.migration import migrations
2
+ from amsdal_utils.models.enums import ModuleType
3
+
4
+
5
+ class Migration(migrations.Migration):
6
+ operations: list[migrations.Operation] = [
7
+ migrations.CreateClass(
8
+ module_type=ModuleType.CORE,
9
+ class_name="ClassProperty",
10
+ new_schema={
11
+ "title": "ClassProperty",
12
+ "required": ["type"],
13
+ "properties": {
14
+ "title": {"type": "string", "title": "Title"},
15
+ "type": {"type": "string", "title": "Type"},
16
+ "default": {"type": "anything", "title": "Default"},
17
+ "options": {"type": "array", "items": {"type": "Option", "title": "Option"}, "title": "Options"},
18
+ "items": {
19
+ "type": "dictionary",
20
+ "items": {"key": {"type": "string"}, "value": {"type": "anything"}},
21
+ "title": "Items",
22
+ },
23
+ "discriminator": {"type": "string", "title": "Discriminator"},
24
+ },
25
+ "meta_class": "TypeMeta",
26
+ "custom_code": "from typing import Any\n\nfrom amsdal_models.builder.validators.dict_validators import validate_non_empty_keys\nfrom pydantic.functional_validators import field_validator\n\nfrom amsdal.models.core.option import *\n\n\n@field_validator('items')\n@classmethod\ndef _non_empty_keys_items(cls: type, value: Any) -> Any:\n return validate_non_empty_keys(value)",
27
+ "storage_metadata": {"table_name": "ClassProperty", "db_fields": {}, "foreign_keys": {}},
28
+ },
29
+ ),
30
+ migrations.CreateClass(
31
+ module_type=ModuleType.CORE,
32
+ class_name="ClassObject",
33
+ new_schema={
34
+ "title": "ClassObject",
35
+ "required": ["title", "type", "module_type"],
36
+ "properties": {
37
+ "title": {"type": "string", "title": "Title"},
38
+ "type": {"type": "string", "title": "Type"},
39
+ "module_type": {"type": "string", "title": "Module Type"},
40
+ "properties": {
41
+ "type": "dictionary",
42
+ "items": {
43
+ "key": {"type": "string"},
44
+ "value": {"type": "ClassProperty", "title": "ClassProperty"},
45
+ },
46
+ "title": "Properties",
47
+ },
48
+ "required": {"type": "array", "items": {"type": "string"}, "title": "Required"},
49
+ "custom_code": {"type": "string", "title": "Custom Code"},
50
+ "storage_metadata": {"type": "StorageMetadata", "title": "Storage metadata"},
51
+ },
52
+ "custom_code": 'from typing import Any\n\nfrom amsdal_models.builder.validators.dict_validators import validate_non_empty_keys\nfrom pydantic.functional_validators import field_validator\n\nfrom amsdal.models.core.class_property import *\nfrom amsdal.models.core.storage_metadata import *\n\n\n@field_validator(\'properties\')\n@classmethod\ndef _non_empty_keys_properties(cls: type, value: Any) -> Any:\n return validate_non_empty_keys(value)\n\n@property\ndef display_name(self) -> str:\n """\n Returns the display name of the object.\n\n Returns:\n str: The display name, which is the title of the object.\n """\n return self.title',
53
+ "storage_metadata": {
54
+ "table_name": "ClassObject",
55
+ "db_fields": {},
56
+ "primary_key": ["partition_key"],
57
+ "foreign_keys": {},
58
+ },
59
+ },
60
+ ),
61
+ ]
@@ -0,0 +1,109 @@
1
+ from amsdal_models.migration import migrations
2
+ from amsdal_utils.models.enums import ModuleType
3
+
4
+
5
+ class Migration(migrations.Migration):
6
+ operations: list[migrations.Operation] = [
7
+ migrations.CreateClass(
8
+ module_type=ModuleType.CORE,
9
+ class_name="File",
10
+ new_schema={
11
+ "title": "File",
12
+ "required": ["filename", "data"],
13
+ "properties": {
14
+ "filename": {"type": "string", "title": "Filename"},
15
+ "data": {"type": "binary", "title": "Data"},
16
+ "size": {"type": "number", "title": "Size"},
17
+ },
18
+ "custom_code": 'import base64\nfrom pathlib import Path\nfrom typing import BinaryIO\n\nfrom pydantic import field_validator\n\n\n@classmethod\ndef from_file(cls, file_or_path: Path | BinaryIO) -> \'File\':\n """\n Creates a `File` object from a file path or a binary file object.\n\n Args:\n file_or_path (Path | BinaryIO): The file path or binary file object.\n\n Returns:\n File: The created `File` object.\n\n Raises:\n ValueError: If the provided path is a directory.\n """\n if isinstance(file_or_path, Path):\n if file_or_path.is_dir():\n msg = f\'{file_or_path} is a directory\'\n raise ValueError(msg)\n data = file_or_path.read_bytes()\n filename = file_or_path.name\n else:\n file_or_path.seek(0)\n data = file_or_path.read()\n filename = Path(file_or_path.name).name\n return cls(data=data, filename=filename)\n\n@field_validator(\'data\')\n@classmethod\ndef data_base64_decode(cls, v: bytes) -> bytes:\n """\n Decodes a base64-encoded byte string if it is base64-encoded.\n\n This method checks if the provided byte string is base64-encoded and decodes it if true.\n If the byte string is not base64-encoded, it returns the original byte string.\n\n Args:\n cls: The class this method belongs to.\n v (bytes): The byte string to be checked and potentially decoded.\n\n Returns:\n bytes: The decoded byte string if it was base64-encoded, otherwise the original byte string.\n """\n is_base64: bool = False\n try:\n is_base64 = base64.b64encode(base64.b64decode(v)) == v\n except Exception:\n ...\n if is_base64:\n return base64.b64decode(v)\n return v\n\n@property\ndef mimetype(self) -> str | None:\n """\n Returns the MIME type of the file based on its filename.\n\n This method uses the `mimetypes` module to guess the MIME type of the file.\n\n Returns:\n str | None: The guessed MIME type of the file, or None if it cannot be determined.\n """\n import mimetypes\n return mimetypes.guess_type(self.filename)[0]\n\nasync def apre_create(self) -> None:\n """\n Prepares the object for creation by setting its size attribute.\n\n This method calculates the size of the object\'s data and assigns it to the size attribute.\n If the data is None, it defaults to an empty byte string.\n\n Args:\n None\n """\n self.size = len(self.data or b\'\')\n\nasync def apre_update(self) -> None:\n """\n Prepares the object for update by setting its size attribute.\n\n This method calculates the size of the object\'s data and assigns it to the size attribute.\n If the data is None, it defaults to an empty byte string.\n\n Args:\n None\n """\n self.size = len(self.data or b\'\')\n\ndef __repr__(self) -> str:\n return f\'File<{self.filename}>({self.size or len(self.data) or 0} bytes)\'\n\ndef __str__(self) -> str:\n return repr(self)\n\ndef pre_create(self) -> None:\n """\n Prepares the object for creation by setting its size attribute.\n\n This method calculates the size of the object\'s data and assigns it to the size attribute.\n If the data is None, it defaults to an empty byte string.\n\n Args:\n None\n """\n self.size = len(self.data or b\'\')\n\ndef pre_update(self) -> None:\n """\n Prepares the object for update by setting its size attribute.\n\n This method calculates the size of the object\'s data and assigns it to the size attribute.\n If the data is None, it defaults to an empty byte string.\n\n Args:\n None\n """\n self.size = len(self.data or b\'\')\n\ndef to_file(self, file_or_path: Path | BinaryIO) -> None:\n """\n Writes the object\'s data to a file path or a binary file object.\n\n Args:\n file_or_path (Path | BinaryIO): The file path or binary file object where the data will be written.\n\n Returns:\n None\n\n Raises:\n ValueError: If the provided path is a directory.\n """\n if isinstance(file_or_path, Path):\n if file_or_path.is_dir():\n file_or_path = file_or_path / self.name\n file_or_path.write_bytes(self.data)\n else:\n file_or_path.write(self.data)\n file_or_path.seek(0)',
19
+ "storage_metadata": {
20
+ "table_name": "File",
21
+ "db_fields": {},
22
+ "primary_key": ["partition_key"],
23
+ "foreign_keys": {},
24
+ },
25
+ },
26
+ ),
27
+ migrations.CreateClass(
28
+ module_type=ModuleType.CORE,
29
+ class_name="Fixture",
30
+ new_schema={
31
+ "title": "Fixture",
32
+ "required": ["external_id", "data"],
33
+ "properties": {
34
+ "class_name": {"type": "string", "title": "Class Name"},
35
+ "order": {"type": "number", "title": "Order"},
36
+ "external_id": {"type": "string", "title": "External ID"},
37
+ "data": {
38
+ "type": "dictionary",
39
+ "items": {"key": {"type": "string"}, "value": {"type": "anything"}},
40
+ "title": "Data",
41
+ },
42
+ },
43
+ "custom_code": "from typing import Any\n\nfrom amsdal_models.builder.validators.dict_validators import validate_non_empty_keys\nfrom pydantic.functional_validators import field_validator\n\n\n@field_validator('data')\n@classmethod\ndef _non_empty_keys_data(cls: type, value: Any) -> Any:\n return validate_non_empty_keys(value)",
44
+ "storage_metadata": {
45
+ "table_name": "Fixture",
46
+ "db_fields": {},
47
+ "primary_key": ["partition_key"],
48
+ "unique": [["external_id"]],
49
+ "foreign_keys": {},
50
+ },
51
+ },
52
+ ),
53
+ migrations.CreateClass(
54
+ module_type=ModuleType.CORE,
55
+ class_name="Option",
56
+ new_schema={
57
+ "title": "Option",
58
+ "required": ["key", "value"],
59
+ "properties": {
60
+ "key": {"type": "string", "title": "Key"},
61
+ "value": {"type": "string", "title": "Value Type"},
62
+ },
63
+ "meta_class": "TypeMeta",
64
+ "storage_metadata": {"table_name": "Option", "db_fields": {}, "foreign_keys": {}},
65
+ },
66
+ ),
67
+ migrations.CreateClass(
68
+ module_type=ModuleType.CORE,
69
+ class_name="StorageMetadata",
70
+ new_schema={
71
+ "title": "StorageMetadata",
72
+ "properties": {
73
+ "table_name": {"type": "string", "title": "Table name"},
74
+ "db_fields": {
75
+ "type": "dictionary",
76
+ "items": {"key": {"type": "string"}, "value": {"type": "array", "items": {"type": "string"}}},
77
+ "title": "Database fields",
78
+ },
79
+ "primary_key": {"type": "array", "items": {"type": "string"}, "title": "Primary key fields"},
80
+ "indexed": {
81
+ "type": "array",
82
+ "items": {"type": "array", "items": {"type": "string"}},
83
+ "title": "Indexed",
84
+ },
85
+ "unique": {
86
+ "type": "array",
87
+ "items": {"type": "array", "items": {"type": "string"}},
88
+ "title": "Unique Fields",
89
+ },
90
+ },
91
+ "meta_class": "TypeMeta",
92
+ "storage_metadata": {"table_name": "StorageMetadata", "db_fields": {}, "foreign_keys": {}},
93
+ },
94
+ ),
95
+ migrations.CreateClass(
96
+ module_type=ModuleType.CORE,
97
+ class_name="Validator",
98
+ new_schema={
99
+ "title": "Validator",
100
+ "required": ["name", "data"],
101
+ "properties": {
102
+ "name": {"type": "string", "title": "Validator Name"},
103
+ "data": {"type": "anything", "title": "Validator Data"},
104
+ },
105
+ "meta_class": "TypeMeta",
106
+ "storage_metadata": {"table_name": "Validator", "db_fields": {}, "foreign_keys": {}},
107
+ },
108
+ ),
109
+ ]
@@ -0,0 +1,91 @@
1
+ from amsdal_models.migration import migrations
2
+ from amsdal_utils.models.enums import ModuleType
3
+
4
+
5
+ class Migration(migrations.Migration):
6
+ operations: list[migrations.Operation] = [
7
+ migrations.UpdateClass(
8
+ module_type=ModuleType.CORE,
9
+ class_name="File",
10
+ old_schema={
11
+ "title": "File",
12
+ "required": ["filename", "data"],
13
+ "properties": {
14
+ "filename": {"type": "string", "title": "Filename"},
15
+ "data": {"type": "binary", "title": "Data"},
16
+ "size": {"type": "number", "title": "Size"},
17
+ },
18
+ "custom_code": 'import base64\nfrom pathlib import Path\nfrom typing import BinaryIO\n\nfrom pydantic import field_validator\n\n\n@classmethod\ndef from_file(cls, file_or_path: Path | BinaryIO) -> \'File\':\n """\n Creates a `File` object from a file path or a binary file object.\n\n Args:\n file_or_path (Path | BinaryIO): The file path or binary file object.\n\n Returns:\n File: The created `File` object.\n\n Raises:\n ValueError: If the provided path is a directory.\n """\n if isinstance(file_or_path, Path):\n if file_or_path.is_dir():\n msg = f\'{file_or_path} is a directory\'\n raise ValueError(msg)\n data = file_or_path.read_bytes()\n filename = file_or_path.name\n else:\n file_or_path.seek(0)\n data = file_or_path.read()\n filename = Path(file_or_path.name).name\n return cls(data=data, filename=filename)\n\n@field_validator(\'data\')\n@classmethod\ndef data_base64_decode(cls, v: bytes) -> bytes:\n """\n Decodes a base64-encoded byte string if it is base64-encoded.\n\n This method checks if the provided byte string is base64-encoded and decodes it if true.\n If the byte string is not base64-encoded, it returns the original byte string.\n\n Args:\n cls: The class this method belongs to.\n v (bytes): The byte string to be checked and potentially decoded.\n\n Returns:\n bytes: The decoded byte string if it was base64-encoded, otherwise the original byte string.\n """\n is_base64: bool = False\n try:\n is_base64 = base64.b64encode(base64.b64decode(v)) == v\n except Exception:\n ...\n if is_base64:\n return base64.b64decode(v)\n return v\n\n@property\ndef mimetype(self) -> str | None:\n """\n Returns the MIME type of the file based on its filename.\n\n This method uses the `mimetypes` module to guess the MIME type of the file.\n\n Returns:\n str | None: The guessed MIME type of the file, or None if it cannot be determined.\n """\n import mimetypes\n return mimetypes.guess_type(self.filename)[0]\n\nasync def apre_create(self) -> None:\n """\n Prepares the object for creation by setting its size attribute.\n\n This method calculates the size of the object\'s data and assigns it to the size attribute.\n If the data is None, it defaults to an empty byte string.\n\n Args:\n None\n """\n self.size = len(self.data or b\'\')\n\nasync def apre_update(self) -> None:\n """\n Prepares the object for update by setting its size attribute.\n\n This method calculates the size of the object\'s data and assigns it to the size attribute.\n If the data is None, it defaults to an empty byte string.\n\n Args:\n None\n """\n self.size = len(self.data or b\'\')\n\ndef __repr__(self) -> str:\n return f\'File<{self.filename}>({self.size or len(self.data) or 0} bytes)\'\n\ndef __str__(self) -> str:\n return repr(self)\n\ndef pre_create(self) -> None:\n """\n Prepares the object for creation by setting its size attribute.\n\n This method calculates the size of the object\'s data and assigns it to the size attribute.\n If the data is None, it defaults to an empty byte string.\n\n Args:\n None\n """\n self.size = len(self.data or b\'\')\n\ndef pre_update(self) -> None:\n """\n Prepares the object for update by setting its size attribute.\n\n This method calculates the size of the object\'s data and assigns it to the size attribute.\n If the data is None, it defaults to an empty byte string.\n\n Args:\n None\n """\n self.size = len(self.data or b\'\')\n\ndef to_file(self, file_or_path: Path | BinaryIO) -> None:\n """\n Writes the object\'s data to a file path or a binary file object.\n\n Args:\n file_or_path (Path | BinaryIO): The file path or binary file object where the data will be written.\n\n Returns:\n None\n\n Raises:\n ValueError: If the provided path is a directory.\n """\n if isinstance(file_or_path, Path):\n if file_or_path.is_dir():\n file_or_path = file_or_path / self.name\n file_or_path.write_bytes(self.data)\n else:\n file_or_path.write(self.data)\n file_or_path.seek(0)',
19
+ "storage_metadata": {
20
+ "table_name": "File",
21
+ "db_fields": {},
22
+ "primary_key": ["partition_key"],
23
+ "foreign_keys": {},
24
+ },
25
+ },
26
+ new_schema={
27
+ "title": "File",
28
+ "required": ["filename"],
29
+ "properties": {
30
+ "filename": {"type": "string", "title": "Filename"},
31
+ "data": {"type": "binary", "title": "Data"},
32
+ "size": {"type": "number", "title": "Size"},
33
+ "storage_address": {"type": "anything", "title": "Storage Reference"},
34
+ },
35
+ "custom_code": 'import base64\nimport io\nfrom contextlib import suppress\nfrom pathlib import Path\nfrom typing import IO\nfrom typing import Any\nfrom typing import BinaryIO\n\nfrom amsdal_models.storage.backends.db import DBStorage\nfrom amsdal_models.storage.base import Storage\nfrom pydantic import model_validator\n\n\n@classmethod\ndef data_base64_decode(cls, data: Any) -> bytes:\n if isinstance(data, str):\n data = data.encode(\'utf-8\')\n is_base64: bool = False\n with suppress(Exception):\n is_base64 = base64.b64encode(base64.b64decode(data)) == data\n if is_base64:\n return base64.b64decode(data)\n return data\n\n@classmethod\ndef from_bytes(cls, filename: str, data: bytes) -> \'File\':\n """\n Creates a `File` object from a byte string.\n\n Args:\n filename (str): The filename of the file.\n data (bytes): The byte string containing the file data.:\n\n Returns:\n File: The created `File` object.\n """\n obj = cls(filename=filename, data=data, size=len(data))\n obj._needs_persist = True\n return obj\n\n@classmethod\ndef from_file(cls, file_or_path: Path | BinaryIO) -> \'File\':\n """\n Creates a `File` object from a file path or a binary file object.\n\n Args:\n file_or_path (Path | BinaryIO): The file path or binary file object.\n\n Returns:\n File: The created `File` object.\n\n Raises:\n ValueError: If the provided path is a directory.\n """\n f: BinaryIO | io.BufferedReader\n if isinstance(file_or_path, Path):\n if file_or_path.is_dir():\n msg = f\'{file_or_path} is a directory\'\n raise ValueError(msg)\n f = file_or_path.open(\'rb\')\n filename = file_or_path.name\n size = file_or_path.stat().st_size\n else:\n f = file_or_path\n filename = Path(getattr(f, \'name\', \'unnamed\')).name\n try:\n if f.seekable():\n f.seek(0, io.SEEK_END)\n size = f.tell()\n f.seek(0)\n else:\n size = None\n except (OSError, AttributeError):\n size = None\n obj = cls(filename=filename, size=size)\n obj._source = f\n obj._needs_persist = True\n return obj\n\n@model_validator(mode=\'before\')\n@classmethod\ndef validate_model_data(cls, data: Any) -> Any:\n if isinstance(data, dict):\n if \'data\' in data:\n if data[\'data\']:\n data[\'data\'] = cls.data_base64_decode(data[\'data\'])\n data[\'size\'] = len(data[\'data\'])\n else:\n data[\'size\'] = 0\n return data\n\n@property\ndef mimetype(self) -> str | None:\n """\n Returns the MIME type of the file based on its filename.\n\n This method uses the `mimetypes` module to guess the MIME type of the file.\n\n Returns:\n str | None: The guessed MIME type of the file, or None if it cannot be determined.\n """\n import mimetypes\n return mimetypes.guess_type(self.filename)[0]\n\n@property\ndef storage(self) -> Storage:\n from amsdal.storages import default_storage\n if self._storage:\n return self._storage\n if self.storage_address:\n return Storage.from_storage_spec({\'storage_class\': self.storage_address.ref.resource})\n return default_storage()\n\nasync def aopen(self, mode: str=\'rb\') -> Any:\n """\n Async variant of open().\n\n Uses the resolved storage to call aopen(); if the backend does not implement\n async, falls back to the sync open().\n """\n try:\n return await self.storage.aopen(self, mode)\n except NotImplementedError:\n return self.storage.open(self, mode)\n\nasync def apre_create(self) -> None:\n if self._needs_persist:\n from amsdal_models.storage.persistence import apersist_file\n await apersist_file(self, storage=self.storage)\n\nasync def apre_update(self) -> None:\n if self._needs_persist:\n from amsdal_models.storage.persistence import apersist_file\n await apersist_file(self, storage=self.storage)\n\nasync def aread_bytes(self) -> bytes:\n async with await self.aopen() as f:\n return await f.read()\n\nasync def aurl(self) -> str:\n """\n Async variant of url().\n\n Uses the resolved storage to call aurl(); if the backend does not implement\n async, falls back to the sync url().\n """\n try:\n return await self.storage.aurl(self)\n except NotImplementedError:\n return self.storage.url(self)\n\ndef __repr__(self) -> str:\n return f"File<{self.filename}>({self.size or len(self.data or \'\') or 0} bytes)"\n\ndef __str__(self) -> str:\n return repr(self)\n\ndef open(self, mode: str=\'rb\') -> IO[Any]:\n """\n Open a binary stream for reading (or other modes if supported) using storage_address.\n\n Raises StateError if storage_address is missing.\n """\n return self.storage.open(self, mode)\n\ndef pre_create(self) -> None:\n if self._needs_persist:\n from amsdal_models.storage.persistence import persist_file\n persist_file(self, storage=self.storage)\n\ndef pre_update(self) -> None:\n if self._needs_persist:\n from amsdal_models.storage.persistence import persist_file\n persist_file(self, storage=self.storage)\n\ndef read_bytes(self) -> bytes:\n with self.open() as f:\n return f.read()\n\ndef set_data(self, data: bytes | str) -> None:\n if not isinstance(self.storage, DBStorage):\n msg = \'Cannot set data on a file that is not stored in a database. Use `File.from_bytes` instead.\'\n raise ValueError(msg)\n self.data = self.data_base64_decode(data)\n self.size = len(self.data)\n self._needs_persist = True\n\ndef to_file(self, file_or_path: Path | BinaryIO) -> None:\n """\n Writes the object\'s data to a file path or a binary file object.\n\n Args:\n file_or_path (Path | BinaryIO): The file path or binary file object where the data will be written.\n\n Returns:\n None\n\n Raises:\n ValueError: If the provided path is a directory.\n """\n with self.open() as f:\n if isinstance(file_or_path, Path):\n if file_or_path.is_dir():\n file_or_path = file_or_path / self.name\n file_or_path.write_bytes(f.read())\n else:\n file_or_path.write(f.read())\n file_or_path.seek(0)\n\ndef url(self) -> str:\n """\n Return a URL for this file using its storage_address.\n\n Raises StateError if storage_address is missing.\n """\n return self.storage.url(self)',
36
+ "storage_metadata": {
37
+ "table_name": "File",
38
+ "db_fields": {},
39
+ "primary_key": ["partition_key"],
40
+ "foreign_keys": {},
41
+ },
42
+ },
43
+ ),
44
+ migrations.UpdateClass(
45
+ module_type=ModuleType.CORE,
46
+ class_name="ClassProperty",
47
+ old_schema={
48
+ "title": "ClassProperty",
49
+ "required": ["type"],
50
+ "properties": {
51
+ "title": {"type": "string", "title": "Title"},
52
+ "type": {"type": "string", "title": "Type"},
53
+ "default": {"type": "anything", "title": "Default"},
54
+ "options": {"type": "array", "items": {"type": "Option", "title": "Option"}, "title": "Options"},
55
+ "items": {
56
+ "type": "dictionary",
57
+ "items": {"key": {"type": "string"}, "value": {"type": "anything"}},
58
+ "title": "Items",
59
+ },
60
+ "discriminator": {"type": "string", "title": "Discriminator"},
61
+ },
62
+ "meta_class": "TypeMeta",
63
+ "custom_code": "from typing import Any\n\nfrom amsdal_models.builder.validators.dict_validators import validate_non_empty_keys\nfrom pydantic.functional_validators import field_validator\n\nfrom amsdal.models.core.option import *\n\n\n@field_validator('items')\n@classmethod\ndef _non_empty_keys_items(cls: type, value: Any) -> Any:\n return validate_non_empty_keys(value)",
64
+ "storage_metadata": {"table_name": "ClassProperty", "db_fields": {}, "foreign_keys": {}},
65
+ },
66
+ new_schema={
67
+ "title": "ClassProperty",
68
+ "required": ["type"],
69
+ "properties": {
70
+ "title": {"type": "string", "title": "Title"},
71
+ "type": {"type": "string", "title": "Type"},
72
+ "default": {"type": "anything", "title": "Default"},
73
+ "options": {"type": "array", "items": {"type": "Option", "title": "Option"}, "title": "Options"},
74
+ "items": {
75
+ "type": "dictionary",
76
+ "items": {"key": {"type": "string"}, "value": {"type": "anything"}},
77
+ "title": "Items",
78
+ },
79
+ "discriminator": {"type": "string", "title": "Discriminator"},
80
+ "extra": {
81
+ "type": "dictionary",
82
+ "items": {"key": {"type": "string"}, "value": {"type": "anything"}},
83
+ "title": "Extra",
84
+ },
85
+ },
86
+ "meta_class": "TypeMeta",
87
+ "custom_code": "from typing import Any\n\nfrom amsdal_models.builder.validators.dict_validators import validate_non_empty_keys\nfrom pydantic.functional_validators import field_validator\n\nfrom amsdal.models.core.option import *\n\n\n@field_validator('items')\n@classmethod\ndef _non_empty_keys_items(cls: type, value: Any) -> Any:\n return validate_non_empty_keys(value)",
88
+ "storage_metadata": {"table_name": "ClassProperty", "db_fields": {}, "foreign_keys": {}},
89
+ },
90
+ ),
91
+ ]
@@ -0,0 +1,45 @@
1
+ from amsdal_models.migration import migrations
2
+ from amsdal_utils.models.enums import ModuleType
3
+
4
+
5
+ class Migration(migrations.Migration):
6
+ operations: list[migrations.Operation] = [
7
+ migrations.UpdateClass(
8
+ module_type=ModuleType.CORE,
9
+ class_name="File",
10
+ old_schema={
11
+ "title": "File",
12
+ "required": ["filename"],
13
+ "properties": {
14
+ "filename": {"type": "string", "title": "Filename"},
15
+ "data": {"type": "binary", "title": "Data"},
16
+ "size": {"type": "number", "title": "Size"},
17
+ "storage_address": {"type": "anything", "title": "Storage Reference"},
18
+ },
19
+ "custom_code": 'import base64\nimport io\nfrom contextlib import suppress\nfrom pathlib import Path\nfrom typing import IO\nfrom typing import Any\nfrom typing import BinaryIO\n\nfrom amsdal_models.storage.backends.db import DBStorage\nfrom amsdal_models.storage.base import Storage\nfrom pydantic import model_validator\n\n\n@classmethod\ndef data_base64_decode(cls, data: Any) -> bytes:\n if isinstance(data, str):\n data = data.encode(\'utf-8\')\n is_base64: bool = False\n with suppress(Exception):\n is_base64 = base64.b64encode(base64.b64decode(data)) == data\n if is_base64:\n return base64.b64decode(data)\n return data\n\n@classmethod\ndef from_bytes(cls, filename: str, data: bytes) -> \'File\':\n """\n Creates a `File` object from a byte string.\n\n Args:\n filename (str): The filename of the file.\n data (bytes): The byte string containing the file data.:\n\n Returns:\n File: The created `File` object.\n """\n obj = cls(filename=filename, data=data, size=len(data))\n obj._needs_persist = True\n return obj\n\n@classmethod\ndef from_file(cls, file_or_path: Path | BinaryIO) -> \'File\':\n """\n Creates a `File` object from a file path or a binary file object.\n\n Args:\n file_or_path (Path | BinaryIO): The file path or binary file object.\n\n Returns:\n File: The created `File` object.\n\n Raises:\n ValueError: If the provided path is a directory.\n """\n f: BinaryIO | io.BufferedReader\n if isinstance(file_or_path, Path):\n if file_or_path.is_dir():\n msg = f\'{file_or_path} is a directory\'\n raise ValueError(msg)\n f = file_or_path.open(\'rb\')\n filename = file_or_path.name\n size = file_or_path.stat().st_size\n else:\n f = file_or_path\n filename = Path(getattr(f, \'name\', \'unnamed\')).name\n try:\n if f.seekable():\n f.seek(0, io.SEEK_END)\n size = f.tell()\n f.seek(0)\n else:\n size = None\n except (OSError, AttributeError):\n size = None\n obj = cls(filename=filename, size=size)\n obj._source = f\n obj._needs_persist = True\n return obj\n\n@model_validator(mode=\'before\')\n@classmethod\ndef validate_model_data(cls, data: Any) -> Any:\n if isinstance(data, dict):\n if \'data\' in data:\n if data[\'data\']:\n data[\'data\'] = cls.data_base64_decode(data[\'data\'])\n data[\'size\'] = len(data[\'data\'])\n else:\n data[\'size\'] = 0\n return data\n\n@property\ndef mimetype(self) -> str | None:\n """\n Returns the MIME type of the file based on its filename.\n\n This method uses the `mimetypes` module to guess the MIME type of the file.\n\n Returns:\n str | None: The guessed MIME type of the file, or None if it cannot be determined.\n """\n import mimetypes\n return mimetypes.guess_type(self.filename)[0]\n\n@property\ndef storage(self) -> Storage:\n from amsdal.storages import default_storage\n if self._storage:\n return self._storage\n if self.storage_address:\n return Storage.from_storage_spec({\'storage_class\': self.storage_address.ref.resource})\n return default_storage()\n\nasync def aopen(self, mode: str=\'rb\') -> Any:\n """\n Async variant of open().\n\n Uses the resolved storage to call aopen(); if the backend does not implement\n async, falls back to the sync open().\n """\n try:\n return await self.storage.aopen(self, mode)\n except NotImplementedError:\n return self.storage.open(self, mode)\n\nasync def apre_create(self) -> None:\n if self._needs_persist:\n from amsdal_models.storage.persistence import apersist_file\n await apersist_file(self, storage=self.storage)\n\nasync def apre_update(self) -> None:\n if self._needs_persist:\n from amsdal_models.storage.persistence import apersist_file\n await apersist_file(self, storage=self.storage)\n\nasync def aread_bytes(self) -> bytes:\n async with await self.aopen() as f:\n return await f.read()\n\nasync def aurl(self) -> str:\n """\n Async variant of url().\n\n Uses the resolved storage to call aurl(); if the backend does not implement\n async, falls back to the sync url().\n """\n try:\n return await self.storage.aurl(self)\n except NotImplementedError:\n return self.storage.url(self)\n\ndef __repr__(self) -> str:\n return f"File<{self.filename}>({self.size or len(self.data or \'\') or 0} bytes)"\n\ndef __str__(self) -> str:\n return repr(self)\n\ndef open(self, mode: str=\'rb\') -> IO[Any]:\n """\n Open a binary stream for reading (or other modes if supported) using storage_address.\n\n Raises StateError if storage_address is missing.\n """\n return self.storage.open(self, mode)\n\ndef pre_create(self) -> None:\n if self._needs_persist:\n from amsdal_models.storage.persistence import persist_file\n persist_file(self, storage=self.storage)\n\ndef pre_update(self) -> None:\n if self._needs_persist:\n from amsdal_models.storage.persistence import persist_file\n persist_file(self, storage=self.storage)\n\ndef read_bytes(self) -> bytes:\n with self.open() as f:\n return f.read()\n\ndef set_data(self, data: bytes | str) -> None:\n if not isinstance(self.storage, DBStorage):\n msg = \'Cannot set data on a file that is not stored in a database. Use `File.from_bytes` instead.\'\n raise ValueError(msg)\n self.data = self.data_base64_decode(data)\n self.size = len(self.data)\n self._needs_persist = True\n\ndef to_file(self, file_or_path: Path | BinaryIO) -> None:\n """\n Writes the object\'s data to a file path or a binary file object.\n\n Args:\n file_or_path (Path | BinaryIO): The file path or binary file object where the data will be written.\n\n Returns:\n None\n\n Raises:\n ValueError: If the provided path is a directory.\n """\n with self.open() as f:\n if isinstance(file_or_path, Path):\n if file_or_path.is_dir():\n file_or_path = file_or_path / self.name\n file_or_path.write_bytes(f.read())\n else:\n file_or_path.write(f.read())\n file_or_path.seek(0)\n\ndef url(self) -> str:\n """\n Return a URL for this file using its storage_address.\n\n Raises StateError if storage_address is missing.\n """\n return self.storage.url(self)',
20
+ "storage_metadata": {
21
+ "table_name": "File",
22
+ "db_fields": {},
23
+ "primary_key": ["partition_key"],
24
+ "foreign_keys": {},
25
+ },
26
+ },
27
+ new_schema={
28
+ "title": "File",
29
+ "required": ["filename"],
30
+ "properties": {
31
+ "filename": {"type": "string", "title": "Filename"},
32
+ "data": {"type": "binary", "title": "Data"},
33
+ "size": {"type": "number", "title": "Size"},
34
+ "storage_address": {"type": "anything", "title": "Storage Reference"},
35
+ },
36
+ "custom_code": 'import base64\nimport io\nfrom contextlib import suppress\nfrom pathlib import Path\nfrom typing import IO\nfrom typing import Any\nfrom typing import BinaryIO\n\nfrom amsdal_models.storage.backends.db import AsyncFileWrapper\nfrom amsdal_models.storage.backends.db import DBStorage\nfrom amsdal_models.storage.base import Storage\nfrom pydantic import model_validator\n\n\n@classmethod\ndef data_base64_decode(cls, data: Any) -> bytes:\n if isinstance(data, str):\n data = data.encode(\'utf-8\')\n is_base64: bool = False\n with suppress(Exception):\n is_base64 = base64.b64encode(base64.b64decode(data)) == data\n if is_base64:\n return base64.b64decode(data)\n return data\n\n@classmethod\ndef from_bytes(cls, filename: str, data: bytes) -> \'File\':\n """\n Creates a `File` object from a byte string.\n\n Args:\n filename (str): The filename of the file.\n data (bytes): The byte string containing the file data.:\n\n Returns:\n File: The created `File` object.\n """\n obj = cls(filename=filename, data=data, size=len(data))\n return obj\n\n@classmethod\ndef from_file(cls, file_or_path: Path | BinaryIO) -> \'File\':\n """\n Creates a `File` object from a file path or a binary file object.\n\n Args:\n file_or_path (Path | BinaryIO): The file path or binary file object.\n\n Returns:\n File: The created `File` object.\n\n Raises:\n ValueError: If the provided path is a directory.\n """\n f: BinaryIO | io.BufferedReader\n if isinstance(file_or_path, Path):\n if file_or_path.is_dir():\n msg = f\'{file_or_path} is a directory\'\n raise ValueError(msg)\n f = file_or_path.open(\'rb\')\n filename = file_or_path.name\n size = file_or_path.stat().st_size\n else:\n f = file_or_path\n filename = Path(getattr(f, \'name\', \'unnamed\')).name\n try:\n if f.seekable():\n f.seek(0, io.SEEK_END)\n size = f.tell()\n f.seek(0)\n else:\n size = None\n except (OSError, AttributeError):\n size = None\n obj = cls(filename=filename, size=size)\n obj._source = f\n return obj\n\n@model_validator(mode=\'before\')\n@classmethod\ndef validate_model_data(cls, data: Any) -> Any:\n if isinstance(data, dict):\n if \'data\' in data:\n if data[\'data\']:\n data[\'data\'] = cls.data_base64_decode(data[\'data\'])\n data[\'size\'] = len(data[\'data\'])\n else:\n data[\'size\'] = 0\n return data\n\n@property\ndef mimetype(self) -> str | None:\n """\n Returns the MIME type of the file based on its filename.\n\n This method uses the `mimetypes` module to guess the MIME type of the file.\n\n Returns:\n str | None: The guessed MIME type of the file, or None if it cannot be determined.\n """\n import mimetypes\n return mimetypes.guess_type(self.filename)[0]\n\n@property\ndef storage(self) -> Storage:\n from amsdal.storages import default_storage\n if self._storage:\n return self._storage\n if self.storage_address:\n return Storage.from_storage_spec({\'storage_class\': self.storage_address.ref.resource})\n return default_storage()\n\nasync def aopen(self, mode: str=\'rb\') -> Any:\n """\n Async variant of open().\n\n Uses the resolved storage to call aopen(); if the backend does not implement\n async, falls back to the sync open().\n """\n try:\n return await self.storage.aopen(self, mode)\n except NotImplementedError:\n return AsyncFileWrapper(self.storage.open(self, mode))\n\nasync def apre_create(self) -> None:\n from amsdal_models.storage.persistence import apersist_file\n await apersist_file(self, storage=self.storage)\n\nasync def apre_update(self) -> None:\n from amsdal_models.storage.persistence import apersist_file\n await apersist_file(self, storage=self.storage)\n\nasync def aread_bytes(self) -> bytes:\n async with await self.aopen() as f:\n return await f.read()\n\nasync def aurl(self) -> str:\n """\n Async variant of url().\n\n Uses the resolved storage to call aurl(); if the backend does not implement\n async, falls back to the sync url().\n """\n try:\n return await self.storage.aurl(self)\n except NotImplementedError:\n return self.storage.url(self)\n\ndef __repr__(self) -> str:\n return f"File<{self.filename}>({self.size or len(self.data or \'\') or 0} bytes)"\n\ndef __str__(self) -> str:\n return repr(self)\n\ndef open(self, mode: str=\'rb\') -> IO[Any]:\n """\n Open a binary stream for reading (or other modes if supported) using storage_address.\n\n Raises StateError if storage_address is missing.\n """\n return self.storage.open(self, mode)\n\ndef pre_create(self) -> None:\n from amsdal_models.storage.persistence import persist_file\n persist_file(self, storage=self.storage)\n\ndef pre_update(self) -> None:\n from amsdal_models.storage.persistence import persist_file\n persist_file(self, storage=self.storage)\n\ndef read_bytes(self) -> bytes:\n with self.open() as f:\n return f.read()\n\ndef set_data(self, data: bytes | str) -> None:\n if not isinstance(self.storage, DBStorage):\n msg = \'Cannot set data on a file that is not stored in a database. Use `File.from_bytes` instead.\'\n raise ValueError(msg)\n self.data = self.data_base64_decode(data)\n self.size = len(self.data)\n\ndef to_file(self, file_or_path: Path | BinaryIO) -> None:\n """\n Writes the object\'s data to a file path or a binary file object.\n\n Args:\n file_or_path (Path | BinaryIO): The file path or binary file object where the data will be written.\n\n Returns:\n None\n\n Raises:\n ValueError: If the provided path is a directory.\n """\n with self.open() as f:\n if isinstance(file_or_path, Path):\n if file_or_path.is_dir():\n file_or_path = file_or_path / self.name\n file_or_path.write_bytes(f.read())\n else:\n file_or_path.write(f.read())\n file_or_path.seek(0)\n\ndef url(self) -> str:\n """\n Return a URL for this file using its storage_address.\n\n Raises StateError if storage_address is missing.\n """\n return self.storage.url(self)',
37
+ "storage_metadata": {
38
+ "table_name": "File",
39
+ "db_fields": {},
40
+ "primary_key": ["partition_key"],
41
+ "foreign_keys": {},
42
+ },
43
+ },
44
+ ),
45
+ ]
File without changes
@@ -0,0 +1,57 @@
1
+ import httpx
2
+ from amsdal.cloud.constants import BASE_AUTH_URL as BASE_AUTH_URL
3
+ from amsdal.errors import AmsdalAuthConnectionError as AmsdalAuthConnectionError
4
+ from typing import Any, Protocol
5
+
6
+ class HttpFunction(Protocol):
7
+ """
8
+ Protocol for HTTP function callables.
9
+
10
+ This protocol defines the structure for callables that perform HTTP requests, ensuring they accept a URL and
11
+ additional keyword arguments.
12
+ """
13
+ def __call__(self, url: str, **kwargs: Any) -> httpx.Response: ...
14
+
15
+ class AuthClientService:
16
+ """
17
+ Service to handle HTTP requests for authentication.
18
+
19
+ This class provides functionality to perform HTTP GET and POST requests to the authentication server,
20
+ handling connection errors and setting default timeouts.
21
+ """
22
+ DEFAULT_TIMEOUT: int
23
+ def _default_handler(self, calling_function: HttpFunction, path: str, **kwargs: Any) -> httpx.Response: ...
24
+ def post(self, path: str, **kwargs: Any) -> httpx.Response:
25
+ """
26
+ Sends an HTTP POST request to the specified path.
27
+
28
+ This method constructs the full URL using the base authentication URL and the provided path,
29
+ sets a default timeout, and sends an HTTP POST request.
30
+
31
+ Args:
32
+ path (str): The path to append to the base authentication URL.
33
+ **kwargs (Any): Additional keyword arguments to pass to the `httpx.post` function.
34
+
35
+ Returns:
36
+ httpx.Response: The response from the HTTP POST request.
37
+
38
+ Raises:
39
+ AmsdalAuthConnectionError: If there is a connection error.
40
+ """
41
+ def get(self, path: str, **kwargs: Any) -> httpx.Response:
42
+ """
43
+ Sends an HTTP GET request to the specified path.
44
+
45
+ This method constructs the full URL using the base authentication URL and the provided path,
46
+ sets a default timeout, and sends an HTTP GET request.
47
+
48
+ Args:
49
+ path (str): The path to append to the base authentication URL.
50
+ **kwargs (Any): Additional keyword arguments to pass to the `httpx.get` function.
51
+
52
+ Returns:
53
+ httpx.Response: The response from the HTTP GET request.
54
+
55
+ Raises:
56
+ AmsdalAuthConnectionError: If there is a connection error.
57
+ """
@@ -0,0 +1,13 @@
1
+ from _typeshed import Incomplete
2
+ from pydantic_settings import BaseSettings
3
+
4
+ class Settings(BaseSettings):
5
+ model_config: Incomplete
6
+ AMSDAL_SANDBOX_ENVIRONMENT: bool | None
7
+
8
+ JWT_PUBLIC_KEY: str
9
+ ENCRYPT_PUBLIC_KEY: str
10
+ cloud_settings: Incomplete
11
+ SYNC_KEY: bytes
12
+ AMSDAL_ENV_SUBDOMAIN: Incomplete
13
+ BASE_AUTH_URL: Incomplete
amsdal/cloud/enums.pyi ADDED
@@ -0,0 +1,68 @@
1
+ from enum import Enum
2
+
3
+ class AuthType(Enum):
4
+ """
5
+ Enumeration for authentication types.
6
+
7
+ This enum defines the types of authentication methods available.
8
+
9
+ Attributes:
10
+ CREDENTIALS: Authentication using credentials.
11
+ TOKEN: Authentication using a token.
12
+ """
13
+ CREDENTIALS = ...
14
+ TOKEN = ...
15
+
16
+ class DeployType(str, Enum):
17
+ """
18
+ Enumeration for deployment types.
19
+
20
+ This enum defines the types of deployment methods available.
21
+
22
+ Attributes:
23
+ lakehouse_only: Deployment only to the lakehouse.
24
+ include_state_db: Deployment including the state database.
25
+ """
26
+ lakehouse_only = 'lakehouse_only'
27
+ include_state_db = 'include_state_db'
28
+
29
+ class StateOption(str, Enum):
30
+ """
31
+ Enumeration for state options.
32
+
33
+ This enum defines the types of state database options available.
34
+
35
+ Attributes:
36
+ sqlite: State database using SQLite.
37
+ postgres: State database using PostgreSQL.
38
+ """
39
+ sqlite = 'sqlite'
40
+ postgres = 'postgres'
41
+
42
+ class LakehouseOption(str, Enum):
43
+ """
44
+ Enumeration for lakehouse options.
45
+
46
+ This enum defines the types of lakehouse options available.
47
+
48
+ Attributes:
49
+ spark: Lakehouse option using Spark.
50
+ postgres: Lakehouse option using PostgreSQL.
51
+ postgres_immutable: Lakehouse option using immutable PostgreSQL.
52
+ """
53
+ spark = 'spark'
54
+ postgres = 'postgres'
55
+ postgres_immutable = 'postgres-immutable'
56
+
57
+ class ResponseStatus(str, Enum):
58
+ """
59
+ Enumeration for response statuses.
60
+
61
+ This enum defines the types of response statuses available.
62
+
63
+ Attributes:
64
+ success: Indicates a successful response.
65
+ error: Indicates an error response.
66
+ """
67
+ success = 'success'
68
+ error = 'error'
File without changes