anbor-types 0.0.10__tar.gz
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.
- anbor_types-0.0.10/LICENCE.md +50 -0
- anbor_types-0.0.10/PKG-INFO +23 -0
- anbor_types-0.0.10/README.md +3 -0
- anbor_types-0.0.10/anbor_types/__init__.py +65 -0
- anbor_types-0.0.10/anbor_types/api/__init__.py +0 -0
- anbor_types-0.0.10/anbor_types/api/const.py +6 -0
- anbor_types-0.0.10/anbor_types/catalog/__init__.py +0 -0
- anbor_types-0.0.10/anbor_types/catalog/annotated.py +64 -0
- anbor_types-0.0.10/anbor_types/catalog/catalog_entry/__init__.py +0 -0
- anbor_types-0.0.10/anbor_types/catalog/catalog_entry/dto.py +31 -0
- anbor_types-0.0.10/anbor_types/catalog/category/__init__.py +0 -0
- anbor_types-0.0.10/anbor_types/catalog/category/commands.py +12 -0
- anbor_types-0.0.10/anbor_types/catalog/category/dto.py +26 -0
- anbor_types-0.0.10/anbor_types/catalog/category/queries.py +4 -0
- anbor_types-0.0.10/anbor_types/catalog/category/results.py +6 -0
- anbor_types-0.0.10/anbor_types/catalog/enums.py +12 -0
- anbor_types-0.0.10/anbor_types/catalog/offer/__init__.py +0 -0
- anbor_types-0.0.10/anbor_types/catalog/product/__init__.py +0 -0
- anbor_types-0.0.10/anbor_types/catalog/product/commands.py +5 -0
- anbor_types-0.0.10/anbor_types/catalog/product/constraints.py +28 -0
- anbor_types-0.0.10/anbor_types/catalog/product/dto.py +71 -0
- anbor_types-0.0.10/anbor_types/catalog/product/queries.py +7 -0
- anbor_types-0.0.10/anbor_types/catalog/product/results.py +7 -0
- anbor_types-0.0.10/anbor_types/common/__init__.py +0 -0
- anbor_types-0.0.10/anbor_types/common/annotated.py +52 -0
- anbor_types-0.0.10/anbor_types/common/constraints.py +49 -0
- anbor_types-0.0.10/anbor_types/gallery/__init__.py +0 -0
- anbor_types-0.0.10/anbor_types/gallery/commands.py +0 -0
- anbor_types-0.0.10/anbor_types/gallery/dto.py +9 -0
- anbor_types-0.0.10/anbor_types/gallery/queries.py +0 -0
- anbor_types-0.0.10/anbor_types/identity/__init__.py +0 -0
- anbor_types-0.0.10/anbor_types/identity/api_key/__init__.py +0 -0
- anbor_types-0.0.10/anbor_types/identity/api_key/commands +5 -0
- anbor_types-0.0.10/anbor_types/identity/api_key/dto.py +13 -0
- anbor_types-0.0.10/anbor_types/identity/company/__init__.py +0 -0
- anbor_types-0.0.10/anbor_types/identity/company/dto.py +10 -0
- anbor_types-0.0.10/anbor_types/module/__init__.py +0 -0
- anbor_types-0.0.10/anbor_types/module/annotated.py +0 -0
- anbor_types-0.0.10/anbor_types/module/enums.py +12 -0
- anbor_types-0.0.10/anbor_types/module/handshake/__init__.py +0 -0
- anbor_types-0.0.10/anbor_types/module/handshake/commands.py +6 -0
- anbor_types-0.0.10/anbor_types/module/handshake/dto.py +52 -0
- anbor_types-0.0.10/anbor_types/module/handshake/results.py +9 -0
- anbor_types-0.0.10/anbor_types/module/module/__init__.py +0 -0
- anbor_types-0.0.10/anbor_types/module/module/commands.py +9 -0
- anbor_types-0.0.10/anbor_types/module/module/dto.py +31 -0
- anbor_types-0.0.10/anbor_types/module/module/queries.py +7 -0
- anbor_types-0.0.10/anbor_types/module/module/results.py +9 -0
- anbor_types-0.0.10/anbor_types/utils/__init__.py +0 -0
- anbor_types-0.0.10/anbor_types/utils/functions.py +20 -0
- anbor_types-0.0.10/pyproject.toml +34 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
|
10
|
+
|
|
11
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
|
12
|
+
|
|
13
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
|
14
|
+
|
|
15
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
|
16
|
+
|
|
17
|
+
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
|
18
|
+
|
|
19
|
+
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
|
20
|
+
|
|
21
|
+
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
|
22
|
+
|
|
23
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
|
24
|
+
|
|
25
|
+
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
|
26
|
+
|
|
27
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
|
28
|
+
|
|
29
|
+
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
|
30
|
+
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
|
31
|
+
|
|
32
|
+
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
|
33
|
+
|
|
34
|
+
You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
|
35
|
+
You must cause any modified files to carry prominent notices stating that You changed the files; and
|
|
36
|
+
You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
|
37
|
+
If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
|
38
|
+
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
|
39
|
+
|
|
40
|
+
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
|
41
|
+
|
|
42
|
+
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
|
43
|
+
|
|
44
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
|
45
|
+
|
|
46
|
+
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
|
47
|
+
|
|
48
|
+
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
|
49
|
+
|
|
50
|
+
END OF TERMS AND CONDITIONS
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: anbor-types
|
|
3
|
+
Version: 0.0.10
|
|
4
|
+
Summary: Anbor typing lib
|
|
5
|
+
License: Apache 2.0
|
|
6
|
+
License-File: LICENCE.md
|
|
7
|
+
Author: Joniibek
|
|
8
|
+
Author-email: jonibek.ortikov03@gmail.com
|
|
9
|
+
Requires-Python: >=3.12,<3.15
|
|
10
|
+
Classifier: License :: Other/Proprietary License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
15
|
+
Requires-Dist: msgspec (>=0.20.0,<0.21.0)
|
|
16
|
+
Requires-Dist: pydantic (>=2.12.5,<3.0.0)
|
|
17
|
+
Requires-Dist: regex (>=2025.11.3,<2026.0.0)
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+
### Anbor types list
|
|
21
|
+
|
|
22
|
+
Here are all types of `Anbor` system for central type control
|
|
23
|
+
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import msgspec
|
|
2
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
3
|
+
|
|
4
|
+
from anbor_types.api import const
|
|
5
|
+
from typing import (
|
|
6
|
+
Generic,
|
|
7
|
+
List,
|
|
8
|
+
TypeAlias,
|
|
9
|
+
Callable,
|
|
10
|
+
Awaitable,
|
|
11
|
+
Any,
|
|
12
|
+
TypeVar,
|
|
13
|
+
Protocol,
|
|
14
|
+
Union,
|
|
15
|
+
Sequence,
|
|
16
|
+
Set,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
T = TypeVar("T")
|
|
20
|
+
ID_T: TypeAlias = int
|
|
21
|
+
Pipeline: TypeAlias = Callable[
|
|
22
|
+
[Callable[..., Awaitable[Any]]], Callable[..., Awaitable[Any]]
|
|
23
|
+
]
|
|
24
|
+
ListLike: TypeAlias = Union[Sequence, Set]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class FactoryT(Protocol[T]):
|
|
28
|
+
def __call__(self) -> T | Awaitable[T]: ...
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class BasePydanticModel(BaseModel):
|
|
32
|
+
model_config = ConfigDict(arbitrary_types_allowed=True)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class Query(BaseModel):
|
|
36
|
+
"""
|
|
37
|
+
The same as 'Command' class. But just standard for query-only use(get requests).
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
model_config = ConfigDict(arbitrary_types_allowed=True, extra="forbid", frozen=True)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class ListQuery(Query):
|
|
44
|
+
limit: int = Field(
|
|
45
|
+
default=const.DEFAULT_LIMIT,
|
|
46
|
+
gt=const.MIN_LIMIT - 1,
|
|
47
|
+
lt=const.MAX_LIMIT + 1,
|
|
48
|
+
)
|
|
49
|
+
offset: int = Field(default=const.DEFAULT_OFFSET, gt=const.MIN_OFFSET - 1)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class ListQueryResponse(msgspec.Struct, Generic[T]):
|
|
53
|
+
count: int
|
|
54
|
+
rows: List[T]
|
|
55
|
+
|
|
56
|
+
model_config = ConfigDict(arbitrary_types_allowed=True, extra="forbid", frozen=True)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class Command(BaseModel):
|
|
60
|
+
"""
|
|
61
|
+
Base class for creating commands for mediator.
|
|
62
|
+
Inherit and use with mediator.
|
|
63
|
+
"""
|
|
64
|
+
|
|
65
|
+
model_config = ConfigDict(arbitrary_types_allowed=True, extra="forbid", frozen=True)
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
from typing import Annotated, Optional
|
|
2
|
+
|
|
3
|
+
from pydantic import constr, conlist
|
|
4
|
+
|
|
5
|
+
from anbor_types import ID_T
|
|
6
|
+
from anbor_types.catalog.category.dto import CharValueDTO
|
|
7
|
+
from anbor_types.catalog.product import constraints as product_constraints
|
|
8
|
+
from anbor_types.common import constraints as common_constraints
|
|
9
|
+
from anbor_types.common.annotated import ATSingleLineStr
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
# ===== BASE =====
|
|
13
|
+
type ATCatalogEntryName = Annotated[
|
|
14
|
+
ATSingleLineStr,
|
|
15
|
+
constr(
|
|
16
|
+
max_length=common_constraints.NAME_MAX_LENGTH,
|
|
17
|
+
min_length=common_constraints.NAME_MIN_LENGTH,
|
|
18
|
+
pattern=common_constraints.NAME_REGEX,
|
|
19
|
+
),
|
|
20
|
+
]
|
|
21
|
+
type ATCatalogEntryDescription = Annotated[
|
|
22
|
+
Optional[ATSingleLineStr],
|
|
23
|
+
constr(max_length=common_constraints.DESCRIPTION_MAX_LENGTH),
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
# ===== PRODUCT =====
|
|
28
|
+
type ATProductProfileIdentifier = Annotated[
|
|
29
|
+
str,
|
|
30
|
+
constr(
|
|
31
|
+
max_length=product_constraints.PROFILE_IDENTIFIER_MAX_LENGTH,
|
|
32
|
+
min_length=product_constraints.PROFILE_IDENTIFIER_MIN_LENGTH,
|
|
33
|
+
pattern=product_constraints.PROFILE_IDENTIFIER_REGEX,
|
|
34
|
+
strip_whitespace=True,
|
|
35
|
+
),
|
|
36
|
+
]
|
|
37
|
+
type ATProductProfileCharValues = Annotated[
|
|
38
|
+
list[CharValueDTO],
|
|
39
|
+
conlist(
|
|
40
|
+
item_type=CharValueDTO,
|
|
41
|
+
max_length=product_constraints.PROFILES_MAX_COUNT,
|
|
42
|
+
),
|
|
43
|
+
]
|
|
44
|
+
type ATProductVendorCode = Annotated[
|
|
45
|
+
str,
|
|
46
|
+
constr(
|
|
47
|
+
max_length=product_constraints.VENDOR_CODE_MAX_LENGTH,
|
|
48
|
+
min_length=product_constraints.VENDOR_CODE_MIN_LENGTH,
|
|
49
|
+
pattern=product_constraints.VENDOR_CODE_REGEX,
|
|
50
|
+
strip_whitespace=True,
|
|
51
|
+
),
|
|
52
|
+
]
|
|
53
|
+
type ATProductShelfNumber = Annotated[
|
|
54
|
+
str,
|
|
55
|
+
constr(
|
|
56
|
+
max_length=product_constraints.SHELF_NUMBER_MAX_LENGTH,
|
|
57
|
+
min_length=product_constraints.SHELF_NUMBER_MIN_LENGTH,
|
|
58
|
+
pattern=product_constraints.SHELF_NUMBER_REGEX,
|
|
59
|
+
strip_whitespace=True,
|
|
60
|
+
),
|
|
61
|
+
]
|
|
62
|
+
type ATProductImages = Annotated[
|
|
63
|
+
list[ID_T], conlist(item_type=ID_T, max_length=product_constraints.IMAGES_MAX_COUNT)
|
|
64
|
+
]
|
|
File without changes
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from datetime import datetime
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
4
|
+
import msgspec
|
|
5
|
+
|
|
6
|
+
from anbor_types import ID_T, BasePydanticModel
|
|
7
|
+
from anbor_types.catalog.annotated import ATCatalogEntryDescription, ATCatalogEntryName
|
|
8
|
+
from anbor_types.common.annotated import ATDiscount, ATPrice, ATInformationStr
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class CatalogEntryListDTO(msgspec.Struct):
|
|
12
|
+
id: ID_T
|
|
13
|
+
name: str
|
|
14
|
+
updated_at: datetime
|
|
15
|
+
slug: str
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class CatalogEntryCreateDTO(BasePydanticModel):
|
|
19
|
+
name: ATCatalogEntryName
|
|
20
|
+
|
|
21
|
+
minimum_price: ATPrice
|
|
22
|
+
selling_price: ATPrice
|
|
23
|
+
max_discount: ATDiscount
|
|
24
|
+
|
|
25
|
+
description: Optional[ATCatalogEntryDescription] = None
|
|
26
|
+
information: Optional[ATInformationStr] = None
|
|
27
|
+
|
|
28
|
+
# Non-validate
|
|
29
|
+
category_id: ID_T
|
|
30
|
+
measurement_unit_id: ID_T
|
|
31
|
+
currency_id: ID_T
|
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from anbor_types import Command
|
|
4
|
+
from anbor_types.catalog.annotated import ATSingleLineStr
|
|
5
|
+
from anbor_types.catalog.enums import CategoryKind
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class CategoryCreateCommand(Command):
|
|
9
|
+
name: ATSingleLineStr
|
|
10
|
+
parent_id: Optional[int] = None
|
|
11
|
+
image_id: Optional[int] = None
|
|
12
|
+
kind: CategoryKind
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
import msgspec
|
|
3
|
+
from anbor_types import ID_T, BasePydanticModel
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class CharValueDTO(BasePydanticModel):
|
|
7
|
+
characteristic_id: ID_T
|
|
8
|
+
value_id: ID_T
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ValuesListDTO(msgspec.Struct):
|
|
12
|
+
id: ID_T
|
|
13
|
+
name: str
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class CharacteristicDetailedDTO(msgspec.Struct):
|
|
17
|
+
id: ID_T
|
|
18
|
+
name: str
|
|
19
|
+
values: ValuesListDTO
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class CategoryDetailedDTO(msgspec.Struct):
|
|
23
|
+
id: ID_T
|
|
24
|
+
name: str
|
|
25
|
+
parent_id: Optional[ID_T]
|
|
26
|
+
characteristic: CharacteristicDetailedDTO
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import regex
|
|
2
|
+
|
|
3
|
+
# BAR_CODE
|
|
4
|
+
|
|
5
|
+
PROFILE_IDENTIFIER_MAX_LENGTH = 14
|
|
6
|
+
PROFILE_IDENTIFIER_MIN_LENGTH = 8
|
|
7
|
+
PROFILES_MAX_COUNT = 50
|
|
8
|
+
PROFILE_CHAR_VALUE_MAX_COUNT = 15
|
|
9
|
+
|
|
10
|
+
PROFILE_IDENTIFIER_REGEX = regex.compile(r"^[A-Z0-9\-\_/()\s]+$")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
# SHELF_NUMBER
|
|
14
|
+
SHELF_NUMBER_MAX_LENGTH = 25
|
|
15
|
+
SHELF_NUMBER_MIN_LENGTH = 1
|
|
16
|
+
|
|
17
|
+
SHELF_NUMBER_REGEX = regex.compile(r"^\d+$")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
# VENDOR CODE
|
|
21
|
+
VENDOR_CODE_MAX_LENGTH = 24
|
|
22
|
+
VENDOR_CODE_MIN_LENGTH = 5
|
|
23
|
+
|
|
24
|
+
VENDOR_CODE_REGEX = regex.compile(r"^[\p{IsCyrillic}\p{IsLatin}0-9 _\-\(\)/]+$")
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
# IMAGES
|
|
28
|
+
IMAGES_MAX_COUNT = 5
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
from decimal import Decimal
|
|
2
|
+
from typing import Annotated, List, Optional
|
|
3
|
+
|
|
4
|
+
import msgspec
|
|
5
|
+
from pydantic import conlist, Field
|
|
6
|
+
|
|
7
|
+
from anbor_types import ID_T, BasePydanticModel
|
|
8
|
+
from anbor_types.catalog import annotated
|
|
9
|
+
from anbor_types.catalog.catalog_entry.dto import (
|
|
10
|
+
CatalogEntryCreateDTO,
|
|
11
|
+
CatalogEntryListDTO,
|
|
12
|
+
)
|
|
13
|
+
from anbor_types.catalog.product.constraints import IMAGES_MAX_COUNT, PROFILES_MAX_COUNT
|
|
14
|
+
from anbor_types.common import annotated as common_annotated
|
|
15
|
+
from anbor_types.gallery.dto import ImageListDTO
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# ===== PRODUCT PROFILE =====
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class ProductProfileCreateDTO(BasePydanticModel):
|
|
22
|
+
identifier: annotated.ATProductProfileIdentifier
|
|
23
|
+
char_values: Optional[annotated.ATProductProfileCharValues] = Field(
|
|
24
|
+
default_factory=list
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# ===== PRODUCT =====
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class ProductListDTO(CatalogEntryListDTO):
|
|
32
|
+
buying_price: Decimal
|
|
33
|
+
selling_price: Decimal
|
|
34
|
+
minimum_price: Decimal
|
|
35
|
+
vendor_code: str
|
|
36
|
+
|
|
37
|
+
image: dict
|
|
38
|
+
measurement_unit: dict
|
|
39
|
+
category: dict
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class ProductCreateDTO(CatalogEntryCreateDTO):
|
|
43
|
+
vendor_code: annotated.ATProductVendorCode
|
|
44
|
+
shelf_number: Optional[annotated.ATProductShelfNumber] = None
|
|
45
|
+
|
|
46
|
+
consider_characteristics: bool
|
|
47
|
+
buying_price: common_annotated.ATPrice
|
|
48
|
+
surcharge: common_annotated.ATPrice
|
|
49
|
+
images: Annotated[
|
|
50
|
+
list[ID_T],
|
|
51
|
+
Field(default_factory=list, max_length=IMAGES_MAX_COUNT),
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
profiles: Annotated[
|
|
55
|
+
Optional[List[ProductProfileCreateDTO]],
|
|
56
|
+
conlist(
|
|
57
|
+
item_type=ProductProfileCreateDTO,
|
|
58
|
+
max_length=PROFILES_MAX_COUNT,
|
|
59
|
+
),
|
|
60
|
+
Field(default_factory=list),
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class ProductDetailedListDTO(msgspec.Struct):
|
|
65
|
+
id: ID_T
|
|
66
|
+
name: str
|
|
67
|
+
description: str
|
|
68
|
+
information: str
|
|
69
|
+
selling_price: Decimal
|
|
70
|
+
measurement_unit_name: str
|
|
71
|
+
images: List[ImageListDTO]
|
|
File without changes
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
from decimal import Decimal
|
|
2
|
+
from typing import Annotated, TypeAlias
|
|
3
|
+
|
|
4
|
+
from pydantic import Field, constr, StringConstraints
|
|
5
|
+
from pydantic.functional_validators import BeforeValidator
|
|
6
|
+
from anbor_types.common import constraints as common_constraints
|
|
7
|
+
from anbor_types.utils.functions import parse_single_line_str
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# ===== Str =====
|
|
11
|
+
type ATSingleLineStr = Annotated[str, BeforeValidator(parse_single_line_str)]
|
|
12
|
+
|
|
13
|
+
type ATInformationStr = Annotated[
|
|
14
|
+
str, constr(max_length=common_constraints.INFORMATION_MAX_LENGTH)
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# ===== Decimal =====
|
|
19
|
+
type ATPrice = Annotated[
|
|
20
|
+
Decimal,
|
|
21
|
+
Field(
|
|
22
|
+
max_digits=common_constraints.DECIMAL_PRICE_DIGITS,
|
|
23
|
+
decimal_places=common_constraints.DECIMAL_PRICE_PLACES,
|
|
24
|
+
),
|
|
25
|
+
]
|
|
26
|
+
type ATDiscount = Annotated[
|
|
27
|
+
Decimal,
|
|
28
|
+
Field(
|
|
29
|
+
max_digits=common_constraints.DECIMAL_DISCOUNT_DIGITS,
|
|
30
|
+
decimal_places=common_constraints.DECIMAL_DISCOUNT_PLACES,
|
|
31
|
+
le=Decimal("100"),
|
|
32
|
+
),
|
|
33
|
+
]
|
|
34
|
+
ATBalance: TypeAlias = Annotated[
|
|
35
|
+
Decimal,
|
|
36
|
+
Field(
|
|
37
|
+
max_digits=common_constraints.DECIMAL_BALANCE_DIGITS,
|
|
38
|
+
decimal_places=common_constraints.DECIMAL_BALANCE_PLACES,
|
|
39
|
+
),
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
# ===== HTTP =====
|
|
43
|
+
type ATDomainName = Annotated[
|
|
44
|
+
str,
|
|
45
|
+
StringConstraints(
|
|
46
|
+
max_length=253,
|
|
47
|
+
min_length=4,
|
|
48
|
+
pattern=r"^(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,6}$",
|
|
49
|
+
strip_whitespace=True,
|
|
50
|
+
),
|
|
51
|
+
lambda x: x[:-1] if x[-1] == "/" else x,
|
|
52
|
+
]
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
from decimal import Decimal
|
|
2
|
+
|
|
3
|
+
import regex
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
TITLE_REGEX = regex.compile(r"^[\p{L}\p{N} _-]+$")
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
# NAME
|
|
10
|
+
NAME_MAX_LENGTH = 300
|
|
11
|
+
NAME_MIN_LENGTH = 5
|
|
12
|
+
|
|
13
|
+
NAME_REGEX = TITLE_REGEX
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
# SLUG
|
|
17
|
+
SLUG_MAX_LENGTH = 300
|
|
18
|
+
|
|
19
|
+
# INFORMATION
|
|
20
|
+
INFORMATION_MAX_LENGTH = 5000
|
|
21
|
+
|
|
22
|
+
# DESCRIPTION
|
|
23
|
+
DESCRIPTION_MAX_LENGTH = 5000
|
|
24
|
+
|
|
25
|
+
# DISCOUNTS
|
|
26
|
+
DISCOUNT_MAX = Decimal("100")
|
|
27
|
+
DISCOUNT_MIN = Decimal("0")
|
|
28
|
+
|
|
29
|
+
# PRICE
|
|
30
|
+
ANY_PRICE_MIN = Decimal("0")
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# ==== =====
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
DECIMAL_BALANCE_DIGITS = 30
|
|
37
|
+
DECIMAL_BALANCE_PLACES = 4
|
|
38
|
+
|
|
39
|
+
LONG_DECIMAL_DIGITS = 30
|
|
40
|
+
LONG_DECIMAL_PLACES = 4
|
|
41
|
+
|
|
42
|
+
DECIMAL_PRICE_DIGITS = 14
|
|
43
|
+
DECIMAL_PRICE_PLACES = 4
|
|
44
|
+
|
|
45
|
+
DECIMAL_RATE_DIGITS = 12
|
|
46
|
+
DECIMAL_RATE_PLACES = 6
|
|
47
|
+
|
|
48
|
+
DECIMAL_DISCOUNT_DIGITS = 5
|
|
49
|
+
DECIMAL_DISCOUNT_PLACES = 2
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import msgspec
|
|
2
|
+
|
|
3
|
+
from anbor_types import ID_T, BasePydanticModel
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ApiKeyCreateDTO(BasePydanticModel):
|
|
7
|
+
key: bytes
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ApiKeyListDTO(msgspec.Struct):
|
|
11
|
+
id: ID_T
|
|
12
|
+
# Api key, not a signature. In base64 format. If type is str, then its base64, raw api key otherwise
|
|
13
|
+
key: bytes | str
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
from datetime import datetime
|
|
2
|
+
from uuid import UUID
|
|
3
|
+
|
|
4
|
+
import msgspec
|
|
5
|
+
from anbor_types.identity.company.dto import CompanyListDTO
|
|
6
|
+
from pydantic import ConfigDict
|
|
7
|
+
from anbor_types import BasePydanticModel
|
|
8
|
+
from anbor_types.common.annotated import ATDomainName
|
|
9
|
+
from anbor_types.module.enums import HandshakeKindEnum, HandshakeStatusEnum
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class HandshakeInitDTO(BasePydanticModel):
|
|
13
|
+
domain: ATDomainName
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class HandshakeConfirmationDTO(BasePydanticModel):
|
|
17
|
+
handshake_id: UUID
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class HandshakeConfirmationResponseDTO(msgspec.Struct):
|
|
21
|
+
api_key: str # In base64 format
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class HandshakeInitRequestDTO(BasePydanticModel):
|
|
25
|
+
rel_callback_url: str
|
|
26
|
+
domain: str
|
|
27
|
+
company: CompanyListDTO
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class HandshakeInitResponseDTO(BasePydanticModel):
|
|
31
|
+
handshake_id: UUID
|
|
32
|
+
secret: str # In base64 format
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class HandshakeCreateDTO(BasePydanticModel):
|
|
36
|
+
id: UUID
|
|
37
|
+
kind: HandshakeKindEnum
|
|
38
|
+
expires_at: int
|
|
39
|
+
status: HandshakeStatusEnum
|
|
40
|
+
domain: str
|
|
41
|
+
secret: bytes # Encrypted bytes on save
|
|
42
|
+
|
|
43
|
+
model_config = ConfigDict(frozen=True)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class HandshakeListDTO(msgspec.Struct):
|
|
47
|
+
id: UUID
|
|
48
|
+
kind: HandshakeKindEnum
|
|
49
|
+
status: HandshakeStatusEnum
|
|
50
|
+
expires_at: int
|
|
51
|
+
created_at: datetime
|
|
52
|
+
updated_at: datetime
|
|
File without changes
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from datetime import datetime
|
|
2
|
+
from typing import Dict, Optional
|
|
3
|
+
import msgspec
|
|
4
|
+
from pydantic import Field
|
|
5
|
+
|
|
6
|
+
from anbor_types import ID_T, BasePydanticModel
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class DefaultModuleDTO(msgspec.Struct):
|
|
10
|
+
id: ID_T
|
|
11
|
+
kind: str
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ConnectedModuleListDTO(msgspec.Struct):
|
|
15
|
+
id: ID_T
|
|
16
|
+
kind: str
|
|
17
|
+
created_by_id: ID_T
|
|
18
|
+
updated_at: datetime
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class ModuleConnectDTO(BasePydanticModel):
|
|
22
|
+
default_module_id: ID_T
|
|
23
|
+
payload: Optional[Dict] = Field(default_factory=dict)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class ModuleConnectListDTO(ModuleConnectDTO):
|
|
27
|
+
id: ID_T
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class MarketplaceIntegrationPayloadDTO(BasePydanticModel):
|
|
31
|
+
domain: str
|
|
File without changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import re
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
re_rm_whitespace = re.compile(r"\s+")
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def parse_str(v: str) -> str:
|
|
8
|
+
return re_rm_whitespace.sub(" ", v.strip())
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def parse_single_line_str(v: str) -> str:
|
|
12
|
+
return parse_str(v).replace("\n", "")
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def min_length_exceeded(field: str) -> str:
|
|
16
|
+
return f"Длина {field} слишком короткая"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def max_length_exceeded(field: str) -> str:
|
|
20
|
+
return f"Превышена максимально допустимая длина {field}"
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "anbor-types"
|
|
3
|
+
version = "0.0.10" # MAJOR.MINOR.PATCH
|
|
4
|
+
description = "Anbor typing lib"
|
|
5
|
+
authors = [
|
|
6
|
+
{name = "Joniibek",email = "jonibek.ortikov03@gmail.com"}
|
|
7
|
+
]
|
|
8
|
+
license = {text = "Apache 2.0"}
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.12,<3.15"
|
|
11
|
+
dependencies = [
|
|
12
|
+
"msgspec (>=0.20.0,<0.21.0)",
|
|
13
|
+
"pydantic (>=2.12.5,<3.0.0)",
|
|
14
|
+
"regex (>=2025.11.3,<2026.0.0)"
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
[build-system]
|
|
19
|
+
requires = ["poetry-core>=2.0.0,<3.0.0"]
|
|
20
|
+
build-backend = "poetry.core.masonry.api"
|
|
21
|
+
|
|
22
|
+
[dependency-groups]
|
|
23
|
+
dev = [
|
|
24
|
+
"ruff (>=0.14.10,<0.15.0)",
|
|
25
|
+
"black (>=25.12.0,<26.0.0)",
|
|
26
|
+
"mypy (>=1.19.1,<2.0.0)",
|
|
27
|
+
"pre-commit (>=4.5.1,<5.0.0)"
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
[tool.poetry]
|
|
32
|
+
packages = [
|
|
33
|
+
{ include = "anbor_types" }
|
|
34
|
+
]
|