amsdal_utils 0.4.4__py3-none-any.whl → 0.5.0__py3-none-any.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_utils/__about__.py +1 -1
- amsdal_utils/models/data_models/core.py +40 -3
- amsdal_utils/schemas/schema.py +10 -2
- {amsdal_utils-0.4.4.dist-info → amsdal_utils-0.5.0.dist-info}/METADATA +1 -1
- {amsdal_utils-0.4.4.dist-info → amsdal_utils-0.5.0.dist-info}/RECORD +7 -7
- {amsdal_utils-0.4.4.dist-info → amsdal_utils-0.5.0.dist-info}/WHEEL +0 -0
- {amsdal_utils-0.4.4.dist-info → amsdal_utils-0.5.0.dist-info}/licenses/LICENSE.txt +0 -0
amsdal_utils/__about__.py
CHANGED
|
@@ -72,16 +72,44 @@ class LegacyDictSchema(BaseModel):
|
|
|
72
72
|
value_type: str
|
|
73
73
|
|
|
74
74
|
|
|
75
|
+
def process_one_of(data: dict[str, Any]) -> dict[str, Any]:
|
|
76
|
+
one_of = [
|
|
77
|
+
ao
|
|
78
|
+
for ao in data.pop('oneOf')
|
|
79
|
+
if ao not in [{'type': 'null'}, {'$ref': '#/$defs/Reference'}, {'$ref': '#/$defs/LegacyModel'}]
|
|
80
|
+
]
|
|
81
|
+
|
|
82
|
+
for _one_of_item in one_of:
|
|
83
|
+
if not _one_of_item or '$ref' not in _one_of_item:
|
|
84
|
+
msg = f'Multiple oneOf should contain $ref. Currently: {one_of}'
|
|
85
|
+
raise ValueError(msg)
|
|
86
|
+
|
|
87
|
+
_types = [_one_of_item['$ref'].rsplit('/', 1)[-1] for _one_of_item in one_of]
|
|
88
|
+
data['type'] = '|'.join(_types)
|
|
89
|
+
|
|
90
|
+
return data
|
|
91
|
+
|
|
92
|
+
|
|
75
93
|
def process_any_of(data: dict[str, Any], info: ValidationInfo) -> dict[str, Any]:
|
|
94
|
+
_any_of = data.pop('anyOf')
|
|
95
|
+
if _any_of in [[{'$ref': '#/$defs/Reference'}], [{'$ref': '#/$defs/Reference'}, {'type': 'null'}]]:
|
|
96
|
+
data['type'] = 'object'
|
|
97
|
+
return data
|
|
98
|
+
|
|
76
99
|
any_of = [
|
|
77
100
|
ao
|
|
78
|
-
for ao in
|
|
101
|
+
for ao in _any_of
|
|
79
102
|
if ao not in [{'type': 'null'}, {'$ref': '#/$defs/Reference'}, {'$ref': '#/$defs/LegacyModel'}]
|
|
80
103
|
]
|
|
81
104
|
|
|
82
105
|
if len(any_of) != 1:
|
|
83
|
-
|
|
84
|
-
|
|
106
|
+
for _any_of_item in any_of:
|
|
107
|
+
if not _any_of_item or '$ref' not in _any_of_item:
|
|
108
|
+
msg = f'Multiple anyOf should contain $ref. Currently: {any_of}'
|
|
109
|
+
raise ValueError(msg)
|
|
110
|
+
_types = [_any_of_item['$ref'].rsplit('/', 1)[-1] for _any_of_item in any_of]
|
|
111
|
+
|
|
112
|
+
data['type'] = '|'.join(_types)
|
|
85
113
|
|
|
86
114
|
_any_of_element = any_of[0]
|
|
87
115
|
|
|
@@ -181,6 +209,15 @@ class TypeData(BaseModel, extra='allow'):
|
|
|
181
209
|
if 'anyOf' in data:
|
|
182
210
|
data = process_any_of(data, info)
|
|
183
211
|
|
|
212
|
+
if 'oneOf' in data:
|
|
213
|
+
data = process_one_of(data)
|
|
214
|
+
|
|
215
|
+
if 'discriminator' in data and isinstance(data['discriminator'], dict):
|
|
216
|
+
try:
|
|
217
|
+
data['discriminator'] = data['discriminator']['propertyName']
|
|
218
|
+
except:
|
|
219
|
+
raise
|
|
220
|
+
|
|
184
221
|
if 'type' not in data:
|
|
185
222
|
data['type'] = 'object'
|
|
186
223
|
|
amsdal_utils/schemas/schema.py
CHANGED
|
@@ -30,7 +30,6 @@ class PropertyData(TypeData, extra='allow'):
|
|
|
30
30
|
field_name (str | None): The name of the field.
|
|
31
31
|
field_id (str | None): The ID of the field.
|
|
32
32
|
is_deleted (bool): Indicates if the property is deleted.
|
|
33
|
-
db_field (list[str] | None): The database fields.
|
|
34
33
|
"""
|
|
35
34
|
|
|
36
35
|
title: str | None = None
|
|
@@ -38,7 +37,7 @@ class PropertyData(TypeData, extra='allow'):
|
|
|
38
37
|
field_name: str | None = None
|
|
39
38
|
field_id: str | None = None
|
|
40
39
|
is_deleted: bool = False
|
|
41
|
-
|
|
40
|
+
discriminator: str | None = None
|
|
42
41
|
|
|
43
42
|
@model_validator(mode='before')
|
|
44
43
|
@classmethod
|
|
@@ -101,6 +100,14 @@ class PropertyData(TypeData, extra='allow'):
|
|
|
101
100
|
return self
|
|
102
101
|
|
|
103
102
|
|
|
103
|
+
class StorageMetadata(BaseModel, extra='allow'):
|
|
104
|
+
table_name: str | None = Field(None, title='Table name')
|
|
105
|
+
db_fields: dict[str, list[str]] | None = Field(None, title='Database property to fields mapping')
|
|
106
|
+
primary_key: list[str] | None = Field(None, title='Primary key fields')
|
|
107
|
+
indexed: list[list[str]] | None = Field(None, title='Indexed')
|
|
108
|
+
unique: list[list[str]] | None = Field(None, title='Unique Fields')
|
|
109
|
+
|
|
110
|
+
|
|
104
111
|
class ObjectSchema(BaseModel, extra='allow'):
|
|
105
112
|
r"""
|
|
106
113
|
Schema for an object.
|
|
@@ -127,6 +134,7 @@ class ObjectSchema(BaseModel, extra='allow'):
|
|
|
127
134
|
options: list[OptionItemData] | None = None
|
|
128
135
|
meta_class: str = MetaClasses.CLASS_OBJECT.value
|
|
129
136
|
custom_code: str | None = None
|
|
137
|
+
storage_metadata: StorageMetadata | None = None
|
|
130
138
|
|
|
131
139
|
@model_validator(mode='before')
|
|
132
140
|
@classmethod
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
amsdal_utils/Third-Party Materials - AMSDAL Dependencies - License Notices.md,sha256=blZRsT9Qg4u4LzZuxlWQOzlWGpLAg7DugWS6nz7s_yw,62595
|
|
2
|
-
amsdal_utils/__about__.py,sha256=
|
|
2
|
+
amsdal_utils/__about__.py,sha256=TbPNaTH0RD4R7lbHg7ldzYno1o55MHD6GiUpoGifv0c,124
|
|
3
3
|
amsdal_utils/__init__.py,sha256=EQCJ5OevmkkIpIULumPNIbWk3UI7afDfRzIsZN5mfwg,73
|
|
4
4
|
amsdal_utils/errors.py,sha256=P90oGdKczHZzHukWnzJfbsSxMC-Sc8dUXvHzP7b1IIA,129
|
|
5
5
|
amsdal_utils/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -25,7 +25,7 @@ amsdal_utils/models/base.py,sha256=jcY7ZE6n0lANGjg87sEwlz6val_8ZRHWaCmNZo9Oxnc,1
|
|
|
25
25
|
amsdal_utils/models/enums.py,sha256=1iuixjmfHMIMDM3rEQ1YUjOPF3aV_OEoPq61I61KvGI,745
|
|
26
26
|
amsdal_utils/models/data_models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
27
27
|
amsdal_utils/models/data_models/address.py,sha256=haQmHYfQcQdejgM1KrNIylfNS-0R0KEDH4v2I8sjIWo,6600
|
|
28
|
-
amsdal_utils/models/data_models/core.py,sha256=
|
|
28
|
+
amsdal_utils/models/data_models/core.py,sha256=F1UpyJ4efAvb-BEWzxwdDVpUMP19hMO41T0QoOvdHbU,8566
|
|
29
29
|
amsdal_utils/models/data_models/enums.py,sha256=qDJDPU5oxPlSNENFNf3PPgxiFJYbTM8OOE8stMmYYHc,4130
|
|
30
30
|
amsdal_utils/models/data_models/metadata.py,sha256=J9r7K2_coE2qD3au-Y7wS2YXcjMUOkW_kx3Gubr3Oyg,2979
|
|
31
31
|
amsdal_utils/models/data_models/reference.py,sha256=hA-06Dq64oMVNv6L6DIelpraxpQJAPiHf4_3UqLmuw4,5098
|
|
@@ -49,7 +49,7 @@ amsdal_utils/query/data_models/paginator.py,sha256=oDEWEdyrEBBkHXyrS4K2mglYVw8An
|
|
|
49
49
|
amsdal_utils/query/data_models/query_specifier.py,sha256=7rEVChU2XPy-3ooaTgfSZGKIOyIIKn8245MMuWrv3Mk,469
|
|
50
50
|
amsdal_utils/schemas/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
51
51
|
amsdal_utils/schemas/interfaces.py,sha256=XJGw45IE7E1HjYArdz2LELOcx15PeTw4L1V34atKm6Y,773
|
|
52
|
-
amsdal_utils/schemas/schema.py,sha256=
|
|
52
|
+
amsdal_utils/schemas/schema.py,sha256=xuepN8NEYFCk7hjuQbx1M6I0DFtWXpXMbx9ffkzmnMw,6372
|
|
53
53
|
amsdal_utils/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
54
54
|
amsdal_utils/utils/classes.py,sha256=GeJIt-jxOHgMnlEHMmzNk9vwxv4_V5dLP-Fv89hN5hc,354
|
|
55
55
|
amsdal_utils/utils/decorators.py,sha256=RCWbbQJ2hY2s-uAI0C5M0X8gTXqUbL1Gx9NxACYBMOA,992
|
|
@@ -57,7 +57,7 @@ amsdal_utils/utils/identifier.py,sha256=oP3CHd2i8EBHMVUC8DWLr9pFZBt1IdH7Falaa3M2
|
|
|
57
57
|
amsdal_utils/utils/lazy_object.py,sha256=eIVHBDNCSHKQopzYjviPCuh0svbRJQOCZ8KzqFLiS-s,2115
|
|
58
58
|
amsdal_utils/utils/singleton.py,sha256=DbgQVJdeftO8sGVm2ti4zf4KDaDd2ogclO3B6gxfqag,744
|
|
59
59
|
amsdal_utils/utils/text.py,sha256=4L5aICJGbmFZwNUhMrACb5thqmcIaWb3aVD24lW24a0,1962
|
|
60
|
-
amsdal_utils-0.
|
|
61
|
-
amsdal_utils-0.
|
|
62
|
-
amsdal_utils-0.
|
|
63
|
-
amsdal_utils-0.
|
|
60
|
+
amsdal_utils-0.5.0.dist-info/METADATA,sha256=h-tD6DxXgWM9sOVzF2Yv8XJO6qzAkzHQjMOyhPtrbE8,57431
|
|
61
|
+
amsdal_utils-0.5.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
62
|
+
amsdal_utils-0.5.0.dist-info/licenses/LICENSE.txt,sha256=hG-541PFYfNJi9WRZi_hno91UyqNg7YLK8LR3vLblZA,27355
|
|
63
|
+
amsdal_utils-0.5.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|