amsdal 0.4.11__cp312-cp312-macosx_10_13_universal2.whl → 0.5.0__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 (80) hide show
  1. amsdal/__about__.py +1 -1
  2. amsdal/__migrations__/0000_initial.py +24 -205
  3. amsdal/__migrations__/0001_create_class_file.py +160 -0
  4. amsdal/cloud/__init__.cpython-312-darwin.so +0 -0
  5. amsdal/cloud/client.cpython-312-darwin.so +0 -0
  6. amsdal/cloud/constants.cpython-312-darwin.so +0 -0
  7. amsdal/cloud/enums.cpython-312-darwin.so +0 -0
  8. amsdal/cloud/models/__init__.cpython-312-darwin.so +0 -0
  9. amsdal/cloud/models/base.cpython-312-darwin.so +0 -0
  10. amsdal/cloud/services/__init__.cpython-312-darwin.so +0 -0
  11. amsdal/cloud/services/actions/__init__.cpython-312-darwin.so +0 -0
  12. amsdal/cloud/services/actions/add_allowlist_ip.cpython-312-darwin.so +0 -0
  13. amsdal/cloud/services/actions/add_basic_auth.cpython-312-darwin.so +0 -0
  14. amsdal/cloud/services/actions/add_dependency.cpython-312-darwin.so +0 -0
  15. amsdal/cloud/services/actions/add_secret.cpython-312-darwin.so +0 -0
  16. amsdal/cloud/services/actions/base.cpython-312-darwin.so +0 -0
  17. amsdal/cloud/services/actions/create_deploy.cpython-312-darwin.so +0 -0
  18. amsdal/cloud/services/actions/create_env.cpython-312-darwin.so +0 -0
  19. amsdal/cloud/services/actions/create_session.cpython-312-darwin.so +0 -0
  20. amsdal/cloud/services/actions/delete_allowlist_ip.cpython-312-darwin.so +0 -0
  21. amsdal/cloud/services/actions/delete_basic_auth.cpython-312-darwin.so +0 -0
  22. amsdal/cloud/services/actions/delete_dependency.cpython-312-darwin.so +0 -0
  23. amsdal/cloud/services/actions/delete_env.cpython-312-darwin.so +0 -0
  24. amsdal/cloud/services/actions/delete_secret.cpython-312-darwin.so +0 -0
  25. amsdal/cloud/services/actions/destroy_deploy.cpython-312-darwin.so +0 -0
  26. amsdal/cloud/services/actions/expose_db.cpython-312-darwin.so +0 -0
  27. amsdal/cloud/services/actions/get_basic_auth_credentials.cpython-312-darwin.so +0 -0
  28. amsdal/cloud/services/actions/get_monitoring_info.cpython-312-darwin.so +0 -0
  29. amsdal/cloud/services/actions/list_dependencies.cpython-312-darwin.so +0 -0
  30. amsdal/cloud/services/actions/list_deploys.cpython-312-darwin.so +0 -0
  31. amsdal/cloud/services/actions/list_envs.cpython-312-darwin.so +0 -0
  32. amsdal/cloud/services/actions/list_secrets.cpython-312-darwin.so +0 -0
  33. amsdal/cloud/services/actions/manager.cpython-312-darwin.so +0 -0
  34. amsdal/cloud/services/actions/signup_action.cpython-312-darwin.so +0 -0
  35. amsdal/cloud/services/actions/update_deploy.cpython-312-darwin.so +0 -0
  36. amsdal/cloud/services/auth/__init__.cpython-312-darwin.so +0 -0
  37. amsdal/cloud/services/auth/base.cpython-312-darwin.so +0 -0
  38. amsdal/cloud/services/auth/credentials.cpython-312-darwin.so +0 -0
  39. amsdal/cloud/services/auth/manager.cpython-312-darwin.so +0 -0
  40. amsdal/cloud/services/auth/signup_service.cpython-312-darwin.so +0 -0
  41. amsdal/cloud/services/auth/token.cpython-312-darwin.so +0 -0
  42. amsdal/contrib/__init__.cpython-312-darwin.so +0 -0
  43. amsdal/contrib/auth/migrations/0000_initial.py +55 -52
  44. amsdal/contrib/frontend_configs/migrations/0000_initial.py +154 -183
  45. amsdal/fixtures/__init__.cpython-312-darwin.so +0 -0
  46. amsdal/fixtures/manager.cpython-312-darwin.so +0 -0
  47. amsdal/fixtures/utils.cpython-312-darwin.so +0 -0
  48. amsdal/manager.cpython-312-darwin.so +0 -0
  49. amsdal/mixins/__init__.cpython-312-darwin.so +0 -0
  50. amsdal/mixins/class_versions_mixin.cpython-312-darwin.so +0 -0
  51. amsdal/models/core/class_object.py +7 -6
  52. amsdal/models/core/class_object.pyi +6 -5
  53. amsdal/models/core/class_property.py +6 -1
  54. amsdal/models/core/class_property.pyi +5 -1
  55. amsdal/models/core/storage_metadata.py +15 -0
  56. amsdal/models/core/storage_metadata.pyi +11 -0
  57. amsdal/models/types/object.py +3 -3
  58. amsdal/models/types/object.pyi +3 -3
  59. amsdal/schemas/core/class_object/model.json +20 -0
  60. amsdal/schemas/core/class_property/model.json +19 -0
  61. amsdal/schemas/core/storage_metadata/model.json +52 -0
  62. amsdal/schemas/manager.cpython-312-darwin.so +0 -0
  63. amsdal/services/__init__.cpython-312-darwin.so +0 -0
  64. amsdal/services/transaction_execution.cpython-312-darwin.so +0 -0
  65. amsdal/services/transaction_execution.pyi +1 -0
  66. amsdal/utils/tests/helpers.py +8 -8
  67. {amsdal-0.4.11.dist-info → amsdal-0.5.0.dist-info}/METADATA +4 -4
  68. {amsdal-0.4.11.dist-info → amsdal-0.5.0.dist-info}/RECORD +71 -76
  69. {amsdal-0.4.11.dist-info → amsdal-0.5.0.dist-info}/WHEEL +1 -1
  70. amsdal/__migrations__/0001_datetime_type.py +0 -18
  71. amsdal/__migrations__/0002_fixture_order.py +0 -44
  72. amsdal/__migrations__/0003_schema_type_in_class_meta.py +0 -44
  73. amsdal/models/core/class_object_meta.py +0 -26
  74. amsdal/models/core/class_object_meta.pyi +0 -15
  75. amsdal/models/core/class_property_meta.py +0 -15
  76. amsdal/models/core/class_property_meta.pyi +0 -10
  77. amsdal/schemas/core/class_object_meta/model.json +0 -59
  78. amsdal/schemas/core/class_property_meta/model.json +0 -23
  79. {amsdal-0.4.11.dist-info → amsdal-0.5.0.dist-info}/licenses/LICENSE.txt +0 -0
  80. {amsdal-0.4.11.dist-info → amsdal-0.5.0.dist-info}/top_level.txt +0 -0
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.11'
4
+ __version__ = '0.5.0'
@@ -6,212 +6,31 @@ class Migration(migrations.Migration):
6
6
  operations: list[migrations.Operation] = [
7
7
  migrations.CreateClass(
8
8
  module_type=ModuleType.TYPE,
9
- class_name='Object',
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'},
9
+ class_name="Object",
10
+ new_schema={
11
+ "title": "Object",
12
+ "required": ["title", "type", "module_type"],
13
+ "properties": {
14
+ "title": {"type": "string", "title": "Title"},
15
+ "type": {"type": "string", "title": "Type"},
16
+ "module_type": {"type": "string", "title": "Module Type"},
17
+ "default": {"type": "anything", "title": "Default"},
18
+ "properties": {
19
+ "type": "dictionary",
20
+ "items": {"key": {"type": "string"}, "value": {"type": "anything"}},
21
+ "title": "Properties",
22
+ },
23
+ "required": {"type": "array", "items": {"type": "string"}, "title": "Required"},
24
+ "custom_code": {"type": "string", "title": "Custom Code"},
25
+ "meta_class": {"type": "string", "title": "Meta Class"},
26
+ },
27
+ "custom_code": "from typing import Any\n\nfrom amsdal_models.builder.validators.dict_validators import validate_non_empty_keys\nfrom pydantic.functional_validators import field_validator\n\n\n@field_validator('properties')\n@classmethod\ndef _non_empty_keys_properties(cls: type, value: Any) -> Any:\n return validate_non_empty_keys(value)",
28
+ "storage_metadata": {
29
+ "table_name": "Object",
30
+ "db_fields": {},
31
+ "primary_key": ["partition_key"],
32
+ "foreign_keys": {},
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,160 @@
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": {"key": {"type": "string"}, "value": {"type": "ClassProperty"}},
43
+ "title": "Properties",
44
+ },
45
+ "required": {"type": "array", "items": {"type": "string"}, "title": "Required"},
46
+ "custom_code": {"type": "string", "title": "Custom Code"},
47
+ "storage_metadata": {"type": "StorageMetadata", "title": "Storage metadata"},
48
+ },
49
+ "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',
50
+ "storage_metadata": {
51
+ "table_name": "ClassObject",
52
+ "db_fields": {},
53
+ "primary_key": ["partition_key"],
54
+ "foreign_keys": {},
55
+ },
56
+ },
57
+ ),
58
+ migrations.CreateClass(
59
+ module_type=ModuleType.CORE,
60
+ class_name="File",
61
+ new_schema={
62
+ "title": "File",
63
+ "required": ["filename", "data"],
64
+ "properties": {
65
+ "filename": {"type": "string", "title": "Filename"},
66
+ "data": {"type": "binary", "title": "Data"},
67
+ "size": {"type": "number", "title": "Size"},
68
+ },
69
+ "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)',
70
+ "storage_metadata": {
71
+ "table_name": "File",
72
+ "db_fields": {},
73
+ "primary_key": ["partition_key"],
74
+ "foreign_keys": {},
75
+ },
76
+ },
77
+ ),
78
+ migrations.CreateClass(
79
+ module_type=ModuleType.CORE,
80
+ class_name="Fixture",
81
+ new_schema={
82
+ "title": "Fixture",
83
+ "required": ["external_id", "data"],
84
+ "properties": {
85
+ "class_name": {"type": "string", "title": "Class Name"},
86
+ "order": {"type": "number", "title": "Order"},
87
+ "external_id": {"type": "string", "title": "External ID"},
88
+ "data": {
89
+ "type": "dictionary",
90
+ "items": {"key": {"type": "string"}, "value": {"type": "anything"}},
91
+ "title": "Data",
92
+ },
93
+ },
94
+ "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)",
95
+ "storage_metadata": {
96
+ "table_name": "Fixture",
97
+ "db_fields": {},
98
+ "primary_key": ["partition_key"],
99
+ "unique": [["external_id"]],
100
+ "foreign_keys": {},
101
+ },
102
+ },
103
+ ),
104
+ migrations.CreateClass(
105
+ module_type=ModuleType.CORE,
106
+ class_name="Option",
107
+ new_schema={
108
+ "title": "Option",
109
+ "required": ["key", "value"],
110
+ "properties": {
111
+ "key": {"type": "string", "title": "Key"},
112
+ "value": {"type": "string", "title": "Value Type"},
113
+ },
114
+ "meta_class": "TypeMeta",
115
+ "storage_metadata": {"table_name": "Option", "db_fields": {}, "foreign_keys": {}},
116
+ },
117
+ ),
118
+ migrations.CreateClass(
119
+ module_type=ModuleType.CORE,
120
+ class_name="StorageMetadata",
121
+ new_schema={
122
+ "title": "StorageMetadata",
123
+ "properties": {
124
+ "table_name": {"type": "string", "title": "Table name"},
125
+ "db_fields": {
126
+ "type": "dictionary",
127
+ "items": {"key": {"type": "string"}, "value": {"type": "array"}},
128
+ "title": "Database fields",
129
+ },
130
+ "primary_key": {"type": "array", "items": {"type": "string"}, "title": "Primary key fields"},
131
+ "indexed": {
132
+ "type": "array",
133
+ "items": {"type": "array", "items": {"type": "string"}},
134
+ "title": "Indexed",
135
+ },
136
+ "unique": {
137
+ "type": "array",
138
+ "items": {"type": "array", "items": {"type": "string"}},
139
+ "title": "Unique Fields",
140
+ },
141
+ },
142
+ "meta_class": "TypeMeta",
143
+ "storage_metadata": {"table_name": "StorageMetadata", "db_fields": {}, "foreign_keys": {}},
144
+ },
145
+ ),
146
+ migrations.CreateClass(
147
+ module_type=ModuleType.CORE,
148
+ class_name="Validator",
149
+ new_schema={
150
+ "title": "Validator",
151
+ "required": ["name", "data"],
152
+ "properties": {
153
+ "name": {"type": "string", "title": "Validator Name"},
154
+ "data": {"type": "anything", "title": "Validator Data"},
155
+ },
156
+ "meta_class": "TypeMeta",
157
+ "storage_metadata": {"table_name": "Validator", "db_fields": {}, "foreign_keys": {}},
158
+ },
159
+ ),
160
+ ]
Binary file
Binary file
Binary file