amsdal 0.3.3__cp311-cp311-macosx_10_9_universal2.whl → 0.5.29__cp311-cp311-macosx_10_9_universal2.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- amsdal/Third-Party Materials - AMSDAL Dependencies - License Notices.md +56 -2
- amsdal/__about__.py +1 -1
- amsdal/__init__.py +20 -0
- amsdal/__init__.pyi +9 -0
- amsdal/__migrations__/0000_initial.py +23 -190
- amsdal/__migrations__/0001_create_class_file.py +61 -0
- amsdal/__migrations__/0002_create_class_file.py +109 -0
- amsdal/__migrations__/0003_update_class_file.py +91 -0
- amsdal/__migrations__/0004_update_class_file.py +45 -0
- amsdal/cloud/__init__.cpython-311-darwin.so +0 -0
- amsdal/cloud/client.cpython-311-darwin.so +0 -0
- amsdal/cloud/constants.cpython-311-darwin.so +0 -0
- amsdal/cloud/enums.cpython-311-darwin.so +0 -0
- amsdal/cloud/models/__init__.cpython-311-darwin.so +0 -0
- amsdal/cloud/models/base.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/__init__.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/__init__.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/add_allowlist_ip.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/add_basic_auth.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/add_dependency.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/add_secret.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/base.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/create_deploy.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/create_env.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/create_session.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/delete_allowlist_ip.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/delete_basic_auth.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/delete_dependency.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/delete_env.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/delete_secret.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/destroy_deploy.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/expose_db.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/get_basic_auth_credentials.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/get_monitoring_info.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/list_dependencies.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/list_deploys.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/list_envs.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/list_secrets.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/manager.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/signup_action.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/actions/update_deploy.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/auth/__init__.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/auth/base.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/auth/credentials.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/auth/credentials.pyi +0 -1
- amsdal/cloud/services/auth/manager.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/auth/signup_service.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/auth/token.cpython-311-darwin.so +0 -0
- amsdal/cloud/services/auth/token.pyi +0 -1
- amsdal/configs/main.py +40 -20
- amsdal/configs/main.pyi +19 -18
- amsdal/contrib/__init__.cpython-311-darwin.so +0 -0
- amsdal/contrib/auth/errors.py +36 -0
- amsdal/contrib/auth/errors.pyi +12 -0
- amsdal/contrib/auth/fixtures/basic_permissions.json +64 -0
- amsdal/contrib/auth/lifecycle/consumer.py +13 -13
- amsdal/contrib/auth/lifecycle/consumer.pyi +3 -0
- amsdal/contrib/auth/migrations/0000_initial.py +69 -31
- amsdal/contrib/auth/migrations/0001_add_mfa_support.py +188 -0
- amsdal/contrib/auth/models/__init__.py +1 -0
- amsdal/contrib/auth/models/backup_code.py +85 -0
- amsdal/contrib/auth/models/email_mfa_device.py +108 -0
- amsdal/contrib/auth/models/login_session.py +235 -0
- amsdal/contrib/auth/models/mfa_device.py +86 -0
- amsdal/contrib/auth/models/permission.py +23 -0
- amsdal/contrib/auth/models/sms_device.py +113 -0
- amsdal/contrib/auth/models/totp_device.py +58 -0
- amsdal/contrib/auth/models/user.py +156 -0
- amsdal/contrib/auth/services/__init__.py +1 -0
- amsdal/contrib/auth/services/mfa_device_service.py +544 -0
- amsdal/contrib/auth/services/mfa_device_service.pyi +216 -0
- amsdal/contrib/auth/services/totp_service.py +358 -0
- amsdal/contrib/auth/services/totp_service.pyi +158 -0
- amsdal/contrib/auth/settings.py +8 -0
- amsdal/contrib/auth/settings.pyi +8 -0
- amsdal/contrib/auth/transactions/__init__.py +1 -0
- amsdal/contrib/auth/transactions/mfa_device_transactions.py +463 -0
- amsdal/contrib/auth/transactions/mfa_device_transactions.pyi +226 -0
- amsdal/contrib/auth/transactions/totp_transactions.py +206 -0
- amsdal/contrib/auth/transactions/totp_transactions.pyi +113 -0
- amsdal/contrib/auth/utils/__init__.py +0 -0
- amsdal/contrib/auth/utils/__init__.pyi +0 -0
- amsdal/contrib/auth/utils/mfa.py +257 -0
- amsdal/contrib/auth/utils/mfa.pyi +119 -0
- amsdal/contrib/frontend_configs/conversion/convert.py +85 -25
- amsdal/contrib/frontend_configs/conversion/convert.pyi +0 -1
- amsdal/contrib/frontend_configs/lifecycle/consumer.py +32 -13
- amsdal/contrib/frontend_configs/lifecycle/consumer.pyi +1 -1
- amsdal/contrib/frontend_configs/migrations/0000_initial.py +167 -195
- amsdal/contrib/frontend_configs/migrations/0001_update_frontend_control_config.py +245 -0
- amsdal/contrib/frontend_configs/migrations/0002_add_button_and_invoke_actions.py +352 -0
- amsdal/contrib/frontend_configs/migrations/0003_create_class_frontendconfigdashboardelement.py +145 -0
- amsdal/contrib/frontend_configs/models/__init__.py +0 -0
- amsdal/contrib/frontend_configs/models/frontend_activator_config.py +22 -0
- amsdal/contrib/frontend_configs/models/frontend_config_async_validator.py +11 -0
- amsdal/contrib/frontend_configs/models/frontend_config_control_action.py +110 -0
- amsdal/contrib/frontend_configs/models/frontend_config_dashboard.py +51 -0
- amsdal/contrib/frontend_configs/models/frontend_config_group_validator.py +21 -0
- amsdal/contrib/frontend_configs/models/frontend_config_option.py +12 -0
- amsdal/contrib/frontend_configs/models/frontend_config_skip_none_base.py +17 -0
- amsdal/contrib/frontend_configs/models/frontend_config_slider_option.py +13 -0
- amsdal/contrib/frontend_configs/models/frontend_config_text_mask.py +14 -0
- amsdal/contrib/frontend_configs/models/frontend_config_validator.py +28 -0
- amsdal/contrib/frontend_configs/models/frontend_control_config.py +110 -0
- amsdal/contrib/frontend_configs/models/frontend_model_config.py +14 -0
- amsdal/errors.py +0 -3
- amsdal/errors.pyi +0 -1
- amsdal/fixtures/__init__.cpython-311-darwin.so +0 -0
- amsdal/fixtures/manager.cpython-311-darwin.so +0 -0
- amsdal/fixtures/manager.pyi +73 -123
- amsdal/fixtures/utils.cpython-311-darwin.so +0 -0
- amsdal/fixtures/utils.pyi +9 -0
- amsdal/manager.cpython-311-darwin.so +0 -0
- amsdal/manager.pyi +9 -96
- amsdal/mixins/__init__.cpython-311-darwin.so +0 -0
- amsdal/mixins/class_versions_mixin.cpython-311-darwin.so +0 -0
- amsdal/models/__init__.py +19 -0
- amsdal/models/core/__init__.py +0 -0
- amsdal/models/core/class_object.py +38 -0
- amsdal/models/core/class_property.py +26 -0
- amsdal/models/core/file.py +243 -0
- amsdal/models/core/fixture.py +25 -0
- amsdal/models/core/option.py +11 -0
- amsdal/models/core/storage_metadata.py +15 -0
- amsdal/models/core/validator.py +12 -0
- amsdal/models/mixins.py +31 -0
- amsdal/models/types/__init__.py +0 -0
- amsdal/models/types/object.py +26 -0
- amsdal/queryset/__init__.py +21 -0
- amsdal/queryset/__init__.pyi +6 -0
- amsdal/schemas/core/class_object/model.json +20 -0
- amsdal/schemas/core/class_property/model.json +19 -0
- amsdal/schemas/core/file/properties/from_file.py +1 -1
- amsdal/schemas/core/file/properties/validate_data.py +3 -4
- amsdal/schemas/core/storage_metadata/model.json +52 -0
- amsdal/schemas/interfaces.py +25 -0
- amsdal/schemas/interfaces.pyi +20 -0
- amsdal/schemas/manager.cpython-311-darwin.so +0 -0
- amsdal/schemas/manager.py +0 -116
- amsdal/schemas/manager.pyi +0 -65
- amsdal/schemas/mixins/__init__.py +0 -0
- amsdal/schemas/mixins/__init__.pyi +0 -0
- amsdal/schemas/mixins/check_dependencies_mixin.py +130 -0
- amsdal/schemas/mixins/check_dependencies_mixin.pyi +45 -0
- amsdal/schemas/mixins/verify_schemas_mixin.py +96 -0
- amsdal/schemas/mixins/verify_schemas_mixin.pyi +33 -0
- amsdal/schemas/repository.py +84 -0
- amsdal/schemas/repository.pyi +22 -0
- amsdal/schemas/utils.py +16 -0
- amsdal/schemas/utils.pyi +10 -0
- amsdal/services/__init__.py +11 -0
- amsdal/services/__init__.pyi +4 -0
- amsdal/services/external_connections.py +262 -0
- amsdal/services/external_connections.pyi +190 -0
- amsdal/services/external_model_generator.py +350 -0
- amsdal/services/external_model_generator.pyi +134 -0
- amsdal/services/transaction_execution.cpython-311-darwin.so +0 -0
- amsdal/services/transaction_execution.pyi +2 -1
- amsdal/storages/__init__.py +20 -0
- amsdal/storages/__init__.pyi +8 -0
- amsdal/storages/file_system.py +214 -0
- amsdal/storages/file_system.pyi +36 -0
- amsdal/transactions/__init__.py +13 -0
- amsdal/transactions/__init__.pyi +4 -0
- amsdal/utils/rollback/__init__.py +99 -54
- amsdal/utils/rollback/__init__.pyi +6 -0
- amsdal/utils/tests/enums.py +0 -2
- amsdal/utils/tests/helpers.py +253 -231
- amsdal/utils/tests/migrations.py +157 -0
- {amsdal-0.3.3.dist-info → amsdal-0.5.29.dist-info}/METADATA +17 -10
- amsdal-0.5.29.dist-info/RECORD +276 -0
- {amsdal-0.3.3.dist-info → amsdal-0.5.29.dist-info}/WHEEL +1 -1
- amsdal/__migrations__/0001_datetime_type.py +0 -18
- amsdal/__migrations__/0002_fixture_order.py +0 -40
- amsdal/__migrations__/0003_schema_type_in_class_meta.py +0 -56
- amsdal/contrib/auth/models/login_session/hooks/pre_init.py +0 -68
- amsdal/contrib/auth/models/login_session/model.json +0 -23
- amsdal/contrib/auth/models/login_session/modifiers/display_name.py +0 -11
- amsdal/contrib/auth/models/permission/fixtures/basic_permissions.json +0 -62
- amsdal/contrib/auth/models/permission/model.json +0 -18
- amsdal/contrib/auth/models/permission/modifiers/display_name.py +0 -11
- amsdal/contrib/auth/models/user/hooks/post_init.py +0 -76
- amsdal/contrib/auth/models/user/hooks/pre_create.py +0 -8
- amsdal/contrib/auth/models/user/model.json +0 -25
- amsdal/contrib/auth/models/user/modifiers/display_name.py +0 -19
- amsdal/contrib/frontend_configs/models/frontend_activator_config/model.json +0 -11
- amsdal/contrib/frontend_configs/models/frontend_config_async_validator/model.json +0 -11
- amsdal/contrib/frontend_configs/models/frontend_config_group_validator/model.json +0 -52
- amsdal/contrib/frontend_configs/models/frontend_config_option/model.json +0 -15
- amsdal/contrib/frontend_configs/models/frontend_config_skip_none_base/model.json +0 -6
- amsdal/contrib/frontend_configs/models/frontend_config_skip_none_base/properties/model_dump.py +0 -13
- amsdal/contrib/frontend_configs/models/frontend_config_slider_option/model.json +0 -19
- amsdal/contrib/frontend_configs/models/frontend_config_text_mask/model.json +0 -26
- amsdal/contrib/frontend_configs/models/frontend_config_validator/model.json +0 -41
- amsdal/contrib/frontend_configs/models/frontend_control_config/model.json +0 -250
- amsdal/contrib/frontend_configs/models/frontend_model_config/fixtures/permissions.json +0 -24
- amsdal/contrib/frontend_configs/models/frontend_model_config/model.json +0 -17
- amsdal/contrib/frontend_configs/models/frontent_config_control_action/model.json +0 -54
- amsdal/contrib/frontend_configs/models/frontent_config_control_action/properties/action_validate.py +0 -33
- amsdal/migration/__init__.cpython-311-darwin.so +0 -0
- amsdal/migration/base_migration_schemas.cpython-311-darwin.so +0 -0
- amsdal/migration/base_migration_schemas.pyi +0 -120
- amsdal/migration/data_classes.cpython-311-darwin.so +0 -0
- amsdal/migration/data_classes.pyi +0 -172
- amsdal/migration/executors/__init__.cpython-311-darwin.so +0 -0
- amsdal/migration/executors/base.cpython-311-darwin.so +0 -0
- amsdal/migration/executors/base.pyi +0 -118
- amsdal/migration/executors/default_executor.cpython-311-darwin.so +0 -0
- amsdal/migration/executors/default_executor.pyi +0 -184
- amsdal/migration/executors/state_executor.cpython-311-darwin.so +0 -0
- amsdal/migration/executors/state_executor.pyi +0 -78
- amsdal/migration/file_migration_executor.cpython-311-darwin.so +0 -0
- amsdal/migration/file_migration_executor.pyi +0 -68
- amsdal/migration/file_migration_generator.cpython-311-darwin.so +0 -0
- amsdal/migration/file_migration_generator.pyi +0 -139
- amsdal/migration/file_migration_store.cpython-311-darwin.so +0 -0
- amsdal/migration/file_migration_store.pyi +0 -61
- amsdal/migration/file_migration_writer.cpython-311-darwin.so +0 -0
- amsdal/migration/file_migration_writer.pyi +0 -73
- amsdal/migration/migrations.cpython-311-darwin.so +0 -0
- amsdal/migration/migrations.pyi +0 -166
- amsdal/migration/migrations_loader.cpython-311-darwin.so +0 -0
- amsdal/migration/migrations_loader.pyi +0 -32
- amsdal/migration/schemas_loaders.cpython-311-darwin.so +0 -0
- amsdal/migration/schemas_loaders.pyi +0 -37
- amsdal/migration/templates/data_migration.tmpl +0 -18
- amsdal/migration/templates/dict_validator.tmpl +0 -4
- amsdal/migration/templates/migration.tmpl +0 -6
- amsdal/migration/templates/model_class.tmpl +0 -8
- amsdal/migration/templates/model_class_layout.tmpl +0 -24
- amsdal/migration/templates/options_validator.tmpl +0 -4
- amsdal/migration/utils.cpython-311-darwin.so +0 -0
- amsdal/migration/utils.pyi +0 -58
- amsdal/mixins/build_mixin.cpython-311-darwin.so +0 -0
- amsdal/mixins/build_mixin.pyi +0 -78
- amsdal/schemas/core/class_object_meta/model.json +0 -59
- amsdal/schemas/core/class_property_meta/model.json +0 -23
- amsdal/services/__init__.cpython-311-darwin.so +0 -0
- amsdal-0.3.3.dist-info/RECORD +0 -257
- amsdal-0.3.3.dist-info/licenses/LICENSE.txt +0 -107
- /amsdal/{migration → contrib/auth/services}/__init__.pyi +0 -0
- /amsdal/{migration/executors → contrib/auth/transactions}/__init__.pyi +0 -0
- {amsdal-0.3.3.dist-info → amsdal-0.5.29.dist-info/licenses}/LICENSE.txt +0 -0
- {amsdal-0.3.3.dist-info → amsdal-0.5.29.dist-info}/top_level.txt +0 -0
|
@@ -1100,7 +1100,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
|
1100
1100
|
|
|
1101
1101
|
## bcrypt **4.0 or later**
|
|
1102
1102
|
|
|
1103
|
-
|
|
1104
1103
|
### [https://github.com/pyca/bcrypt](https://github.com/pyca/bcrypt)
|
|
1105
1104
|
|
|
1106
1105
|
### **Apache License 2.0**
|
|
@@ -1305,4 +1304,59 @@ Unless required by applicable law or agreed to in writing, software
|
|
|
1305
1304
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
1306
1305
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1307
1306
|
See the License for the specific language governing permissions and
|
|
1308
|
-
limitations under the License.
|
|
1307
|
+
limitations under the License.
|
|
1308
|
+
|
|
1309
|
+
## pip **21.3.1 or later**
|
|
1310
|
+
|
|
1311
|
+
### [https://github.com/pypa/pip](https://github.com/pypa/pip)
|
|
1312
|
+
|
|
1313
|
+
### **MIT License**
|
|
1314
|
+
|
|
1315
|
+
Copyright (c) 2008-present The pip developers (see AUTHORS.txt file)
|
|
1316
|
+
|
|
1317
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
1318
|
+
a copy of this software and associated documentation files (the
|
|
1319
|
+
"Software"), to deal in the Software without restriction, including
|
|
1320
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
1321
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
1322
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
1323
|
+
the following conditions:
|
|
1324
|
+
|
|
1325
|
+
The above copyright notice and this permission notice shall be
|
|
1326
|
+
included in all copies or substantial portions of the Software.
|
|
1327
|
+
|
|
1328
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
1329
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
1330
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
1331
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
1332
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
1333
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
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
amsdal/__init__.py
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
1
|
# SPDX-FileCopyrightText: 2023-present
|
|
2
2
|
#
|
|
3
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
CHANGED
|
@@ -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']
|
|
@@ -1,203 +1,36 @@
|
|
|
1
|
-
from
|
|
2
|
-
|
|
3
|
-
from amsdal.migration import migrations
|
|
1
|
+
from amsdal_models.migration import migrations
|
|
2
|
+
from amsdal_utils.models.enums import ModuleType
|
|
4
3
|
|
|
5
4
|
|
|
6
5
|
class Migration(migrations.Migration):
|
|
7
6
|
operations: list[migrations.Operation] = [
|
|
8
7
|
migrations.CreateClass(
|
|
9
|
-
|
|
8
|
+
module_type=ModuleType.TYPE,
|
|
10
9
|
class_name='Object',
|
|
11
10
|
new_schema={
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
'unique': {
|
|
24
|
-
'type': 'array',
|
|
25
|
-
'items': {'type': 'array', 'items': {'type': 'string'}},
|
|
26
|
-
'title': 'Unique Fields',
|
|
27
|
-
},
|
|
28
|
-
'custom_code': {'type': 'string', 'title': 'Custom Code'},
|
|
29
|
-
'meta_class': {'type': 'string', 'title': 'Meta Class'},
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
),
|
|
33
|
-
migrations.CreateClass(
|
|
34
|
-
schema_type=SchemaTypes.TYPE,
|
|
35
|
-
class_name='Binary',
|
|
36
|
-
new_schema={'title': 'Binary', 'properties': {}, 'meta_class': 'TypeMeta'},
|
|
37
|
-
),
|
|
38
|
-
migrations.CreateClass(
|
|
39
|
-
schema_type=SchemaTypes.TYPE,
|
|
40
|
-
class_name='Dictionary',
|
|
41
|
-
new_schema={'title': 'Dictionary', 'properties': {}, 'meta_class': 'TypeMeta'},
|
|
42
|
-
),
|
|
43
|
-
migrations.CreateClass(
|
|
44
|
-
schema_type=SchemaTypes.TYPE,
|
|
45
|
-
class_name='Anything',
|
|
46
|
-
new_schema={'title': 'Anything', 'properties': {}, 'meta_class': 'TypeMeta'},
|
|
47
|
-
),
|
|
48
|
-
migrations.CreateClass(
|
|
49
|
-
schema_type=SchemaTypes.TYPE,
|
|
50
|
-
class_name='String',
|
|
51
|
-
new_schema={'title': 'String', 'default': '', 'properties': {}, 'meta_class': 'TypeMeta'},
|
|
52
|
-
),
|
|
53
|
-
migrations.CreateClass(
|
|
54
|
-
schema_type=SchemaTypes.TYPE,
|
|
55
|
-
class_name='Array',
|
|
56
|
-
new_schema={'title': 'Array', 'properties': {}, 'meta_class': 'TypeMeta'},
|
|
57
|
-
),
|
|
58
|
-
migrations.CreateClass(
|
|
59
|
-
schema_type=SchemaTypes.TYPE,
|
|
60
|
-
class_name='Number',
|
|
61
|
-
new_schema={'title': 'Number', 'properties': {}, 'meta_class': 'TypeMeta'},
|
|
62
|
-
),
|
|
63
|
-
migrations.CreateClass(
|
|
64
|
-
schema_type=SchemaTypes.TYPE,
|
|
65
|
-
class_name='Boolean',
|
|
66
|
-
new_schema={
|
|
67
|
-
'title': 'Boolean',
|
|
68
|
-
'properties': {},
|
|
69
|
-
'options': [{'key': 'true', 'value': True}, {'key': 'false', 'value': False}],
|
|
70
|
-
'meta_class': 'TypeMeta',
|
|
71
|
-
},
|
|
72
|
-
),
|
|
73
|
-
migrations.CreateClass(
|
|
74
|
-
schema_type=SchemaTypes.CORE,
|
|
75
|
-
class_name='Option',
|
|
76
|
-
new_schema={
|
|
77
|
-
'title': 'Option',
|
|
78
|
-
'required': ['key', 'value'],
|
|
79
|
-
'properties': {
|
|
80
|
-
'key': {'type': 'string', 'title': 'Key'},
|
|
81
|
-
'value': {'type': 'string', 'title': 'Value Type'},
|
|
82
|
-
},
|
|
83
|
-
'meta_class': 'TypeMeta',
|
|
84
|
-
},
|
|
85
|
-
),
|
|
86
|
-
migrations.CreateClass(
|
|
87
|
-
schema_type=SchemaTypes.CORE,
|
|
88
|
-
class_name='Validator',
|
|
89
|
-
new_schema={
|
|
90
|
-
'title': 'Validator',
|
|
91
|
-
'required': ['name', 'data'],
|
|
92
|
-
'properties': {
|
|
93
|
-
'name': {'type': 'string', 'title': 'Validator Name'},
|
|
94
|
-
'data': {'type': 'anything', 'title': 'Validator Data'},
|
|
95
|
-
},
|
|
96
|
-
'meta_class': 'TypeMeta',
|
|
97
|
-
},
|
|
98
|
-
),
|
|
99
|
-
migrations.CreateClass(
|
|
100
|
-
schema_type=SchemaTypes.CORE,
|
|
101
|
-
class_name='ClassPropertyMeta',
|
|
102
|
-
new_schema={
|
|
103
|
-
'title': 'ClassPropertyMeta',
|
|
104
|
-
'properties': {
|
|
105
|
-
'title': {'type': 'string', 'title': 'Title'},
|
|
106
|
-
'default': {'type': 'anything', 'title': 'Default'},
|
|
107
|
-
'options': {'type': 'array', 'items': {'type': 'Option'}, 'title': 'Options'},
|
|
108
|
-
},
|
|
109
|
-
'meta_class': 'TypeMeta',
|
|
110
|
-
},
|
|
111
|
-
),
|
|
112
|
-
migrations.CreateClass(
|
|
113
|
-
schema_type=SchemaTypes.CORE,
|
|
114
|
-
class_name='ClassProperty',
|
|
115
|
-
new_schema={
|
|
116
|
-
'title': 'ClassProperty',
|
|
117
|
-
'required': ['type'],
|
|
118
|
-
'properties': {
|
|
119
|
-
'type': {'type': 'string', 'title': 'Type'},
|
|
120
|
-
'items': {
|
|
121
|
-
'type': 'dictionary',
|
|
122
|
-
'items': {'key': {'type': 'string'}, 'value': {'type': 'anything'}},
|
|
123
|
-
'title': 'Items',
|
|
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",
|
|
124
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"},
|
|
125
26
|
},
|
|
126
|
-
'
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
new_schema={
|
|
133
|
-
'title': 'ClassObject',
|
|
134
|
-
'properties': {
|
|
135
|
-
'properties': {
|
|
136
|
-
'type': 'dictionary',
|
|
137
|
-
'items': {'key': {'type': 'string'}, 'value': {'type': 'ClassProperty'}},
|
|
138
|
-
'title': 'Properties',
|
|
139
|
-
},
|
|
140
|
-
'required': {'type': 'array', 'items': {'type': 'string'}, 'title': 'Required'},
|
|
141
|
-
'meta_class': {'type': 'string', 'default': 'ClassObject', 'title': 'Meta Class'},
|
|
142
|
-
},
|
|
143
|
-
'custom_code': '@property # type: ignore[misc]\ndef display_name(self) -> str: # type: ignore[no-untyped-def]\n return self.title',
|
|
144
|
-
},
|
|
145
|
-
),
|
|
146
|
-
migrations.CreateClass(
|
|
147
|
-
schema_type=SchemaTypes.CORE,
|
|
148
|
-
class_name='ClassObjectMeta',
|
|
149
|
-
new_schema={
|
|
150
|
-
'title': 'ClassObjectMeta',
|
|
151
|
-
'required': ['title', 'type'],
|
|
152
|
-
'properties': {
|
|
153
|
-
'title': {'type': 'string', 'title': 'Title'},
|
|
154
|
-
'type': {'type': 'string', 'title': 'Type'},
|
|
155
|
-
'default': {'type': 'anything', 'title': 'Default'},
|
|
156
|
-
'properties': {
|
|
157
|
-
'type': 'dictionary',
|
|
158
|
-
'items': {'key': {'type': 'string'}, 'value': {'type': 'ClassPropertyMeta'}},
|
|
159
|
-
'title': 'Properties',
|
|
160
|
-
},
|
|
161
|
-
'indexed': {'type': 'array', 'items': {'type': 'string'}, 'title': 'Indexed'},
|
|
162
|
-
'unique': {
|
|
163
|
-
'type': 'array',
|
|
164
|
-
'items': {'type': 'array', 'items': {'type': 'string'}},
|
|
165
|
-
'title': 'Unique Fields',
|
|
166
|
-
},
|
|
167
|
-
'custom_code': {'type': 'string', 'title': 'Custom Code'},
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
),
|
|
171
|
-
migrations.CreateClass(
|
|
172
|
-
schema_type=SchemaTypes.CORE,
|
|
173
|
-
class_name='Fixture',
|
|
174
|
-
new_schema={
|
|
175
|
-
'title': 'Fixture',
|
|
176
|
-
'required': ['data', 'external_id'],
|
|
177
|
-
'properties': {
|
|
178
|
-
'class_name': {'type': 'string', 'title': 'Class Name'},
|
|
179
|
-
'external_id': {'type': 'string', 'title': 'External ID'},
|
|
180
|
-
'data': {
|
|
181
|
-
'type': 'dictionary',
|
|
182
|
-
'items': {'key': {'type': 'string'}, 'value': {'type': 'anything'}},
|
|
183
|
-
'title': 'Data',
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
'unique': [['external_id']],
|
|
187
|
-
},
|
|
188
|
-
),
|
|
189
|
-
migrations.CreateClass(
|
|
190
|
-
schema_type=SchemaTypes.CORE,
|
|
191
|
-
class_name='File',
|
|
192
|
-
new_schema={
|
|
193
|
-
'title': 'File',
|
|
194
|
-
'required': ['filename', 'data'],
|
|
195
|
-
'properties': {
|
|
196
|
-
'filename': {'type': 'string', 'title': 'Filename'},
|
|
197
|
-
'data': {'type': 'binary', 'title': 'Data'},
|
|
198
|
-
'size': {'type': 'number', 'title': 'Size'},
|
|
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": {},
|
|
199
33
|
},
|
|
200
|
-
'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]",
|
|
201
34
|
},
|
|
202
35
|
),
|
|
203
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
|
+
]
|