amsdal 0.4.13__cp312-cp312-macosx_10_13_universal2.whl → 0.5.33__cp312-cp312-macosx_10_13_universal2.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. amsdal/Third-Party Materials - AMSDAL Dependencies - License Notices.md +28 -0
  2. amsdal/__about__.py +1 -1
  3. amsdal/__migrations__/0000_initial.py +22 -203
  4. amsdal/__migrations__/0001_create_class_file.py +61 -0
  5. amsdal/__migrations__/0002_create_class_file.py +109 -0
  6. amsdal/__migrations__/0003_update_class_file.py +91 -0
  7. amsdal/__migrations__/0004_update_class_file.py +45 -0
  8. amsdal/cloud/__init__.cpython-312-darwin.so +0 -0
  9. amsdal/cloud/client.cpython-312-darwin.so +0 -0
  10. amsdal/cloud/constants.cpython-312-darwin.so +0 -0
  11. amsdal/cloud/enums.cpython-312-darwin.so +0 -0
  12. amsdal/cloud/models/__init__.cpython-312-darwin.so +0 -0
  13. amsdal/cloud/models/base.cpython-312-darwin.so +0 -0
  14. amsdal/cloud/services/__init__.cpython-312-darwin.so +0 -0
  15. amsdal/cloud/services/actions/__init__.cpython-312-darwin.so +0 -0
  16. amsdal/cloud/services/actions/add_allowlist_ip.cpython-312-darwin.so +0 -0
  17. amsdal/cloud/services/actions/add_basic_auth.cpython-312-darwin.so +0 -0
  18. amsdal/cloud/services/actions/add_dependency.cpython-312-darwin.so +0 -0
  19. amsdal/cloud/services/actions/add_secret.cpython-312-darwin.so +0 -0
  20. amsdal/cloud/services/actions/base.cpython-312-darwin.so +0 -0
  21. amsdal/cloud/services/actions/create_deploy.cpython-312-darwin.so +0 -0
  22. amsdal/cloud/services/actions/create_env.cpython-312-darwin.so +0 -0
  23. amsdal/cloud/services/actions/create_session.cpython-312-darwin.so +0 -0
  24. amsdal/cloud/services/actions/delete_allowlist_ip.cpython-312-darwin.so +0 -0
  25. amsdal/cloud/services/actions/delete_basic_auth.cpython-312-darwin.so +0 -0
  26. amsdal/cloud/services/actions/delete_dependency.cpython-312-darwin.so +0 -0
  27. amsdal/cloud/services/actions/delete_env.cpython-312-darwin.so +0 -0
  28. amsdal/cloud/services/actions/delete_secret.cpython-312-darwin.so +0 -0
  29. amsdal/cloud/services/actions/destroy_deploy.cpython-312-darwin.so +0 -0
  30. amsdal/cloud/services/actions/expose_db.cpython-312-darwin.so +0 -0
  31. amsdal/cloud/services/actions/get_basic_auth_credentials.cpython-312-darwin.so +0 -0
  32. amsdal/cloud/services/actions/get_monitoring_info.cpython-312-darwin.so +0 -0
  33. amsdal/cloud/services/actions/list_dependencies.cpython-312-darwin.so +0 -0
  34. amsdal/cloud/services/actions/list_deploys.cpython-312-darwin.so +0 -0
  35. amsdal/cloud/services/actions/list_envs.cpython-312-darwin.so +0 -0
  36. amsdal/cloud/services/actions/list_secrets.cpython-312-darwin.so +0 -0
  37. amsdal/cloud/services/actions/manager.cpython-312-darwin.so +0 -0
  38. amsdal/cloud/services/actions/signup_action.cpython-312-darwin.so +0 -0
  39. amsdal/cloud/services/actions/update_deploy.cpython-312-darwin.so +0 -0
  40. amsdal/cloud/services/auth/__init__.cpython-312-darwin.so +0 -0
  41. amsdal/cloud/services/auth/base.cpython-312-darwin.so +0 -0
  42. amsdal/cloud/services/auth/credentials.cpython-312-darwin.so +0 -0
  43. amsdal/cloud/services/auth/manager.cpython-312-darwin.so +0 -0
  44. amsdal/cloud/services/auth/signup_service.cpython-312-darwin.so +0 -0
  45. amsdal/cloud/services/auth/token.cpython-312-darwin.so +0 -0
  46. amsdal/configs/main.py +17 -1
  47. amsdal/configs/main.pyi +6 -1
  48. amsdal/contrib/__init__.cpython-312-darwin.so +0 -0
  49. amsdal/contrib/auth/errors.py +36 -0
  50. amsdal/contrib/auth/errors.pyi +12 -0
  51. amsdal/contrib/auth/lifecycle/consumer.py +2 -2
  52. amsdal/contrib/auth/migrations/0000_initial.py +55 -52
  53. amsdal/contrib/auth/migrations/0001_add_mfa_support.py +188 -0
  54. amsdal/contrib/auth/models/__init__.py +1 -0
  55. amsdal/contrib/auth/models/backup_code.py +85 -0
  56. amsdal/contrib/auth/models/email_mfa_device.py +108 -0
  57. amsdal/contrib/auth/models/login_session.py +117 -0
  58. amsdal/contrib/auth/models/mfa_device.py +86 -0
  59. amsdal/contrib/auth/models/sms_device.py +113 -0
  60. amsdal/contrib/auth/models/totp_device.py +58 -0
  61. amsdal/contrib/auth/models/user.py +50 -0
  62. amsdal/contrib/auth/services/__init__.py +1 -0
  63. amsdal/contrib/auth/services/mfa_device_service.py +544 -0
  64. amsdal/contrib/auth/services/mfa_device_service.pyi +216 -0
  65. amsdal/contrib/auth/services/totp_service.py +358 -0
  66. amsdal/contrib/auth/services/totp_service.pyi +158 -0
  67. amsdal/contrib/auth/settings.py +8 -0
  68. amsdal/contrib/auth/settings.pyi +8 -0
  69. amsdal/contrib/auth/transactions/__init__.py +1 -0
  70. amsdal/contrib/auth/transactions/mfa_device_transactions.py +458 -0
  71. amsdal/contrib/auth/transactions/mfa_device_transactions.pyi +226 -0
  72. amsdal/contrib/auth/transactions/totp_transactions.py +203 -0
  73. amsdal/contrib/auth/transactions/totp_transactions.pyi +113 -0
  74. amsdal/contrib/auth/utils/mfa.py +257 -0
  75. amsdal/contrib/auth/utils/mfa.pyi +119 -0
  76. amsdal/contrib/frontend_configs/conversion/convert.py +24 -0
  77. amsdal/contrib/frontend_configs/migrations/0000_initial.py +154 -183
  78. amsdal/contrib/frontend_configs/migrations/0001_update_frontend_control_config.py +245 -0
  79. amsdal/contrib/frontend_configs/migrations/0002_add_button_and_invoke_actions.py +352 -0
  80. amsdal/contrib/frontend_configs/migrations/0003_create_class_frontendconfigdashboardelement.py +145 -0
  81. amsdal/contrib/frontend_configs/models/frontend_config_control_action.py +57 -1
  82. amsdal/contrib/frontend_configs/models/frontend_config_dashboard.py +51 -0
  83. amsdal/contrib/frontend_configs/models/frontend_control_config.py +69 -46
  84. amsdal/fixtures/__init__.cpython-312-darwin.so +0 -0
  85. amsdal/fixtures/manager.cpython-312-darwin.so +0 -0
  86. amsdal/fixtures/utils.cpython-312-darwin.so +0 -0
  87. amsdal/manager.cpython-312-darwin.so +0 -0
  88. amsdal/mixins/__init__.cpython-312-darwin.so +0 -0
  89. amsdal/mixins/class_versions_mixin.cpython-312-darwin.so +0 -0
  90. amsdal/models/core/class_object.py +7 -6
  91. amsdal/models/core/class_property.py +7 -1
  92. amsdal/models/core/file.py +168 -81
  93. amsdal/models/core/storage_metadata.py +15 -0
  94. amsdal/models/mixins.py +31 -0
  95. amsdal/models/types/object.py +3 -3
  96. amsdal/schemas/core/class_object/model.json +20 -0
  97. amsdal/schemas/core/class_property/model.json +19 -0
  98. amsdal/schemas/core/file/properties/validate_data.py +2 -3
  99. amsdal/schemas/core/storage_metadata/model.json +52 -0
  100. amsdal/schemas/manager.cpython-312-darwin.so +0 -0
  101. amsdal/schemas/mixins/check_dependencies_mixin.py +8 -3
  102. amsdal/services/__init__.py +11 -0
  103. amsdal/services/__init__.pyi +4 -0
  104. amsdal/services/external_connections.py +262 -0
  105. amsdal/services/external_connections.pyi +190 -0
  106. amsdal/services/external_model_generator.py +350 -0
  107. amsdal/services/external_model_generator.pyi +134 -0
  108. amsdal/services/transaction_execution.cpython-312-darwin.so +0 -0
  109. amsdal/storages/__init__.py +20 -0
  110. amsdal/storages/__init__.pyi +8 -0
  111. amsdal/storages/file_system.py +214 -0
  112. amsdal/storages/file_system.pyi +36 -0
  113. amsdal/utils/tests/enums.py +0 -2
  114. amsdal/utils/tests/helpers.py +213 -381
  115. amsdal/utils/tests/migrations.py +157 -0
  116. {amsdal-0.4.13.dist-info → amsdal-0.5.33.dist-info}/METADATA +17 -11
  117. {amsdal-0.4.13.dist-info → amsdal-0.5.33.dist-info}/RECORD +124 -117
  118. amsdal/__migrations__/0001_datetime_type.py +0 -18
  119. amsdal/__migrations__/0002_fixture_order.py +0 -44
  120. amsdal/__migrations__/0003_schema_type_in_class_meta.py +0 -44
  121. amsdal/contrib/auth/models/login_session.pyi +0 -37
  122. amsdal/contrib/auth/models/permission.pyi +0 -18
  123. amsdal/contrib/auth/models/user.pyi +0 -46
  124. amsdal/contrib/frontend_configs/models/frontend_activator_config.pyi +0 -12
  125. amsdal/contrib/frontend_configs/models/frontend_config_async_validator.pyi +0 -7
  126. amsdal/contrib/frontend_configs/models/frontend_config_control_action.pyi +0 -32
  127. amsdal/contrib/frontend_configs/models/frontend_config_group_validator.pyi +0 -11
  128. amsdal/contrib/frontend_configs/models/frontend_config_option.pyi +0 -8
  129. amsdal/contrib/frontend_configs/models/frontend_config_skip_none_base.pyi +0 -8
  130. amsdal/contrib/frontend_configs/models/frontend_config_slider_option.pyi +0 -9
  131. amsdal/contrib/frontend_configs/models/frontend_config_text_mask.pyi +0 -10
  132. amsdal/contrib/frontend_configs/models/frontend_config_validator.pyi +0 -15
  133. amsdal/contrib/frontend_configs/models/frontend_control_config.pyi +0 -35
  134. amsdal/contrib/frontend_configs/models/frontend_model_config.pyi +0 -9
  135. amsdal/models/__init__.pyi +0 -9
  136. amsdal/models/core/class_object.pyi +0 -24
  137. amsdal/models/core/class_object_meta.py +0 -26
  138. amsdal/models/core/class_object_meta.pyi +0 -15
  139. amsdal/models/core/class_property.pyi +0 -11
  140. amsdal/models/core/class_property_meta.py +0 -15
  141. amsdal/models/core/class_property_meta.pyi +0 -10
  142. amsdal/models/core/file.pyi +0 -104
  143. amsdal/models/core/fixture.pyi +0 -14
  144. amsdal/models/core/option.pyi +0 -8
  145. amsdal/models/core/validator.pyi +0 -8
  146. amsdal/models/types/object.pyi +0 -16
  147. amsdal/schemas/core/class_object_meta/model.json +0 -59
  148. amsdal/schemas/core/class_property_meta/model.json +0 -23
  149. amsdal/services/__init__.cpython-312-darwin.so +0 -0
  150. /amsdal/contrib/auth/{models → services}/__init__.pyi +0 -0
  151. /amsdal/contrib/{frontend_configs/models → auth/transactions}/__init__.pyi +0 -0
  152. /amsdal/{models/core/__init__.pyi → contrib/auth/utils/__init__.py} +0 -0
  153. /amsdal/{models/types → contrib/auth/utils}/__init__.pyi +0 -0
  154. {amsdal-0.4.13.dist-info → amsdal-0.5.33.dist-info}/WHEEL +0 -0
  155. {amsdal-0.4.13.dist-info → amsdal-0.5.33.dist-info}/licenses/LICENSE.txt +0 -0
  156. {amsdal-0.4.13.dist-info → amsdal-0.5.33.dist-info}/top_level.txt +0 -0
@@ -1332,3 +1332,31 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
1332
1332
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
1333
1333
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
1334
1334
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1335
+
1336
+ ## pyotp **2.9 or later**
1337
+
1338
+ ### [https://github.com/pyauth/pyotp](https://github.com/pyauth/pyotp)
1339
+
1340
+ ### **MIT License**
1341
+
1342
+ Copyright (C) 2011-2021 Mark Percival <m@mdp.im>,
1343
+ Nathan Reynolds <email@nreynolds.co.uk>, Andrey Kislyuk <kislyuk@gmail.com>,
1344
+ and PyOTP contributors
1345
+
1346
+ Permission is hereby granted, free of charge, to any person obtaining a copy
1347
+ of this software and associated documentation files (the "Software"), to deal
1348
+ in the Software without restriction, including without limitation the rights
1349
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1350
+ copies of the Software, and to permit persons to whom the Software is
1351
+ furnished to do so, subject to the following conditions:
1352
+
1353
+ The above copyright notice and this permission notice shall be included in
1354
+ all copies or substantial portions of the Software.
1355
+
1356
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1357
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1358
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1359
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1360
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1361
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1362
+ THE SOFTWARE.
amsdal/__about__.py CHANGED
@@ -1,4 +1,4 @@
1
1
  # SPDX-FileCopyrightText: 2023-present
2
2
  #
3
3
  # SPDX-License-Identifier: AMSDAL End User License Agreement
4
- __version__ = '0.4.13'
4
+ __version__ = '0.5.33'
@@ -8,210 +8,29 @@ class Migration(migrations.Migration):
8
8
  module_type=ModuleType.TYPE,
9
9
  class_name='Object',
10
10
  new_schema={
11
- 'title': 'Object',
12
- 'properties': {
13
- 'title': {'type': 'string', 'title': 'Title'},
14
- 'type': {'type': 'string', 'title': 'Type'},
15
- 'default': {'type': 'anything', 'title': 'Default'},
16
- 'properties': {
17
- 'type': 'dictionary',
18
- 'items': {'key': {'type': 'string'}, 'value': {'type': 'anything'}},
19
- 'title': 'Properties',
20
- },
21
- 'required': {'type': 'array', 'items': {'type': 'string'}, 'title': 'Required'},
22
- 'unique': {
23
- 'type': 'array',
24
- 'items': {'type': 'array', 'items': {'type': 'string'}},
25
- 'title': 'Unique Fields',
26
- },
27
- 'custom_code': {'type': 'string', 'title': 'Custom Code'},
28
- 'meta_class': {'type': 'string', 'title': 'Meta Class'},
29
- },
30
- },
31
- ),
32
- migrations.CreateClass(
33
- module_type=ModuleType.TYPE,
34
- class_name='Binary',
35
- new_schema={'title': 'Binary', 'properties': {}, 'meta_class': 'TypeMeta'},
36
- ),
37
- migrations.CreateClass(
38
- module_type=ModuleType.TYPE,
39
- class_name='Dictionary',
40
- new_schema={'title': 'Dictionary', 'properties': {}, 'meta_class': 'TypeMeta'},
41
- ),
42
- migrations.CreateClass(
43
- module_type=ModuleType.TYPE,
44
- class_name='Anything',
45
- new_schema={'title': 'Anything', 'properties': {}, 'meta_class': 'TypeMeta'},
46
- ),
47
- migrations.CreateClass(
48
- module_type=ModuleType.TYPE,
49
- class_name='String',
50
- new_schema={'title': 'String', 'default': '', 'properties': {}, 'meta_class': 'TypeMeta'},
51
- ),
52
- migrations.CreateClass(
53
- module_type=ModuleType.TYPE,
54
- class_name='Array',
55
- new_schema={'title': 'Array', 'properties': {}, 'meta_class': 'TypeMeta'},
56
- ),
57
- migrations.CreateClass(
58
- module_type=ModuleType.TYPE,
59
- class_name='Number',
60
- new_schema={'title': 'Number', 'properties': {}, 'meta_class': 'TypeMeta'},
61
- ),
62
- migrations.CreateClass(
63
- module_type=ModuleType.TYPE,
64
- class_name='Boolean',
65
- new_schema={
66
- 'title': 'Boolean',
67
- 'properties': {},
68
- 'options': [{'key': 'true', 'value': True}, {'key': 'false', 'value': False}],
69
- 'meta_class': 'TypeMeta',
70
- },
71
- ),
72
- migrations.CreateClass(
73
- module_type=ModuleType.CORE,
74
- class_name='Option',
75
- new_schema={
76
- 'title': 'Option',
77
- 'required': ['key', 'value'],
78
- 'properties': {
79
- 'key': {'type': 'string', 'title': 'Key'},
80
- 'value': {'type': 'string', 'title': 'Value Type'},
81
- },
82
- 'meta_class': 'TypeMeta',
83
- },
84
- ),
85
- migrations.CreateClass(
86
- module_type=ModuleType.CORE,
87
- class_name='Validator',
88
- new_schema={
89
- 'title': 'Validator',
90
- 'required': ['name', 'data'],
91
- 'properties': {
92
- 'name': {'type': 'string', 'title': 'Validator Name'},
93
- 'data': {'type': 'anything', 'title': 'Validator Data'},
94
- },
95
- 'meta_class': 'TypeMeta',
96
- },
97
- ),
98
- migrations.CreateClass(
99
- module_type=ModuleType.CORE,
100
- class_name='ClassPropertyMeta',
101
- new_schema={
102
- 'title': 'ClassPropertyMeta',
103
- 'properties': {
104
- 'title': {'type': 'string', 'title': 'Title'},
105
- 'default': {'type': 'anything', 'title': 'Default'},
106
- 'options': {'type': 'array', 'items': {'type': 'Option'}, 'title': 'Options'},
107
- },
108
- 'meta_class': 'TypeMeta',
109
- },
110
- ),
111
- migrations.CreateClass(
112
- module_type=ModuleType.CORE,
113
- class_name='ClassProperty',
114
- new_schema={
115
- 'title': 'ClassProperty',
116
- 'required': ['type'],
117
- 'properties': {
118
- 'type': {'type': 'string', 'title': 'Type'},
119
- 'items': {
120
- 'type': 'dictionary',
121
- 'items': {'key': {'type': 'string'}, 'value': {'type': 'anything'}},
122
- 'title': 'Items',
123
- },
124
- 'db_field': {
125
- 'type': 'array',
126
- 'items': {'type': 'string'},
127
- 'title': 'DB Fields',
128
- },
129
- },
130
- 'meta_class': 'TypeMeta',
131
- },
132
- ),
133
- migrations.CreateClass(
134
- module_type=ModuleType.CORE,
135
- class_name='ClassObject',
136
- new_schema={
137
- 'title': 'ClassObject',
138
- 'properties': {
139
- 'table_name': {'type': 'string', 'title': 'Table Name'},
140
- 'properties': {
141
- 'type': 'dictionary',
142
- 'items': {'key': {'type': 'string'}, 'value': {'type': 'ClassProperty'}},
143
- 'title': 'Properties',
144
- },
145
- 'primary_key': {
146
- 'type': 'array',
147
- 'items': {'type': 'string'},
148
- 'title': 'Primary key fields',
149
- },
150
- 'indexed': {'type': 'array', 'items': {'type': 'string'}, 'title': 'Indexed'},
151
- 'unique': {
152
- 'type': 'array',
153
- 'items': {'type': 'array', 'items': {'type': 'string'}},
154
- 'title': 'Unique Fields',
155
- },
156
- 'required': {'type': 'array', 'items': {'type': 'string'}, 'title': 'Required'},
157
- 'meta_class': {'type': 'string', 'default': 'ClassObject', 'title': 'Meta Class'},
158
- },
159
- 'custom_code': '@property # type: ignore[misc]\ndef display_name(self) -> str: # type: ignore[no-untyped-def]\n return self.title',
160
- },
161
- ),
162
- migrations.CreateClass(
163
- module_type=ModuleType.CORE,
164
- class_name='ClassObjectMeta',
165
- new_schema={
166
- 'title': 'ClassObjectMeta',
167
- 'required': ['title', 'type'],
168
- 'properties': {
169
- 'title': {'type': 'string', 'title': 'Title'},
170
- 'type': {'type': 'string', 'title': 'Type'},
171
- 'default': {'type': 'anything', 'title': 'Default'},
172
- 'properties': {
173
- 'type': 'dictionary',
174
- 'items': {'key': {'type': 'string'}, 'value': {'type': 'ClassPropertyMeta'}},
175
- 'title': 'Properties',
176
- },
177
- 'custom_code': {'type': 'string', 'title': 'Custom Code'},
178
- },
179
- },
180
- ),
181
- migrations.CreateClass(
182
- module_type=ModuleType.CORE,
183
- class_name='Fixture',
184
- new_schema={
185
- 'title': 'Fixture',
186
- 'required': ['data', 'external_id'],
187
- 'properties': {
188
- 'class_name': {'type': 'string', 'title': 'Class Name'},
189
- 'external_id': {'type': 'string', 'title': 'External ID'},
190
- 'data': {
191
- 'type': 'dictionary',
192
- 'items': {'key': {'type': 'string'}, 'value': {'type': 'anything'}},
193
- 'title': 'Data',
194
- },
195
- },
196
- "primary_key": ["partition_key"],
197
- "table_name": "Fixture",
198
- 'unique': [['external_id']],
199
- },
200
- ),
201
- migrations.CreateClass(
202
- module_type=ModuleType.CORE,
203
- class_name='File',
204
- new_schema={
205
- 'title': 'File',
206
- 'required': ['filename', 'data'],
207
- 'properties': {
208
- 'filename': {'type': 'string', 'title': 'Filename'},
209
- 'data': {'type': 'binary', 'title': 'Data'},
210
- 'size': {'type': 'number', 'title': 'Size'},
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": {},
211
33
  },
212
- "primary_key": ["partition_key"],
213
- "table_name": "File",
214
- 'custom_code': "def pre_update(self): # type: ignore[no-untyped-def]\n self.size = len(self.data or b'')\n\ndef pre_create(self) -> None: # type: ignore[no-untyped-def]\n self.size = len(self.data or b'')\n\nfrom pathlib import Path\nfrom typing import BinaryIO\n\n\ndef to_file(self, file_or_path: Path | BinaryIO) -> None: # type: ignore[no-untyped-def]\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) # type: ignore[union-attr]\n else:\n file_or_path.write(self.data)\n file_or_path.seek(0)\n\nfrom pathlib import Path\nfrom typing import BinaryIO\n\n\n@classmethod # type: ignore[misc, no-untyped-def]\ndef from_file(\n cls,\n file_or_path: Path | BinaryIO,\n) -> 'File': # type: ignore[name-defined] # noqa: F821\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\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\n return cls(data=data, filename=filename)\n\nimport base64\n\nfrom pydantic import field_validator\n\n\n@field_validator('data') # type: ignore[misc]\n@classmethod\ndef data_base64_decode(cls, v: bytes) -> bytes: # type: ignore[no-untyped-def] # noqa: ARG001\n is_base64: bool = False\n\n try:\n is_base64 = base64.b64encode(base64.b64decode(v)) == v\n except Exception:\n ...\n\n if is_base64:\n return base64.b64decode(v)\n\n return v\n\n@property # type: ignore[misc]\ndef mimetype(self) -> str | None: # type: ignore[no-untyped-def]\n import mimetypes\n\n return mimetypes.guess_type(self.filename)[0]",
215
34
  },
216
35
  ),
217
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
+ ]