finalsa-common-models 2.0.4__tar.gz → 2.1.1__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.
- {finalsa_common_models-2.0.4 → finalsa_common_models-2.1.1}/PKG-INFO +3 -3
- {finalsa_common_models-2.0.4 → finalsa_common_models-2.1.1}/finalsa/common/models/__init__.py +6 -0
- {finalsa_common_models-2.0.4 → finalsa_common_models-2.1.1}/finalsa/common/models/models/__init__.py +4 -0
- finalsa_common_models-2.1.1/finalsa/common/models/models/pagination.py +99 -0
- {finalsa_common_models-2.0.4 → finalsa_common_models-2.1.1}/pyproject.toml +3 -3
- {finalsa_common_models-2.0.4 → finalsa_common_models-2.1.1}/.gitignore +0 -0
- {finalsa_common_models-2.0.4 → finalsa_common_models-2.1.1}/LICENSE.md +0 -0
- {finalsa_common_models-2.0.4 → finalsa_common_models-2.1.1}/README.md +0 -0
- {finalsa_common_models-2.0.4 → finalsa_common_models-2.1.1}/finalsa/common/models/exceptions/__init__.py +0 -0
- {finalsa_common_models-2.0.4 → finalsa_common_models-2.1.1}/finalsa/common/models/exceptions/base_domain_exception.py +0 -0
- {finalsa_common_models-2.0.4 → finalsa_common_models-2.1.1}/finalsa/common/models/models/functions.py +0 -0
- {finalsa_common_models-2.0.4 → finalsa_common_models-2.1.1}/finalsa/common/models/models/meta.py +0 -0
- {finalsa_common_models-2.0.4 → finalsa_common_models-2.1.1}/finalsa/common/models/models/sqs_response.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: finalsa-common-models
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.1.1
|
|
4
4
|
Summary: Common models for Finalsa
|
|
5
5
|
Project-URL: Homepage, https://github.com/finalsa/finalsa-common-models
|
|
6
6
|
Author-email: Luis Jimenez <luis@finalsa.com>
|
|
@@ -28,8 +28,8 @@ License: MIT License
|
|
|
28
28
|
License-File: LICENSE.md
|
|
29
29
|
Keywords: common,finalsa,models
|
|
30
30
|
Requires-Python: >=3.10
|
|
31
|
-
Requires-Dist: orjson>=3.11.
|
|
32
|
-
Requires-Dist: pydantic>=2.
|
|
31
|
+
Requires-Dist: orjson>=3.11.6
|
|
32
|
+
Requires-Dist: pydantic>=2.12.5
|
|
33
33
|
Requires-Dist: python-dateutil>=2.9.0.post0
|
|
34
34
|
Description-Content-Type: text/markdown
|
|
35
35
|
|
{finalsa_common_models-2.0.4 → finalsa_common_models-2.1.1}/finalsa/common/models/__init__.py
RENAMED
|
@@ -3,6 +3,9 @@ from finalsa.common.models.models import (
|
|
|
3
3
|
AsyncMeta,
|
|
4
4
|
Authorization,
|
|
5
5
|
HttpMeta,
|
|
6
|
+
PaginationMeta,
|
|
7
|
+
PaginationRequest,
|
|
8
|
+
PaginationResponse,
|
|
6
9
|
SqsReponse,
|
|
7
10
|
parse_sns_message_attributes,
|
|
8
11
|
parse_sqs_message_attributes,
|
|
@@ -19,6 +22,9 @@ __all__ = [
|
|
|
19
22
|
"AsyncMeta",
|
|
20
23
|
"Authorization",
|
|
21
24
|
"HttpMeta",
|
|
25
|
+
"PaginationMeta",
|
|
26
|
+
"PaginationRequest",
|
|
27
|
+
"PaginationResponse",
|
|
22
28
|
"SqsReponse",
|
|
23
29
|
"parse_sns_message_attributes",
|
|
24
30
|
"parse_sqs_message_attributes",
|
{finalsa_common_models-2.0.4 → finalsa_common_models-2.1.1}/finalsa/common/models/models/__init__.py
RENAMED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
from .functions import parse_sns_message_attributes, parse_sqs_message_attributes, to_sqs_message_attributes, to_sns_message_attributes
|
|
2
2
|
from .sqs_response import SqsReponse
|
|
3
3
|
from .meta import Meta, AsyncMeta, Authorization, HttpMeta
|
|
4
|
+
from .pagination import PaginationMeta, PaginationRequest, PaginationResponse
|
|
4
5
|
|
|
5
6
|
__all__ = [
|
|
6
7
|
"Meta",
|
|
7
8
|
"AsyncMeta",
|
|
8
9
|
"Authorization",
|
|
9
10
|
"HttpMeta",
|
|
11
|
+
"PaginationMeta",
|
|
12
|
+
"PaginationRequest",
|
|
13
|
+
"PaginationResponse",
|
|
10
14
|
"SqsReponse",
|
|
11
15
|
"parse_sns_message_attributes",
|
|
12
16
|
"parse_sqs_message_attributes",
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
from typing import Any, Dict, Generic, Optional, Sequence, TypeVar
|
|
2
|
+
|
|
3
|
+
from pydantic import BaseModel, ConfigDict, Field, model_validator
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
ItemT = TypeVar("ItemT")
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class PaginationRequest(BaseModel):
|
|
10
|
+
"""Represents the pagination related query params for HTTP GET requests."""
|
|
11
|
+
|
|
12
|
+
model_config = ConfigDict(populate_by_name=True)
|
|
13
|
+
|
|
14
|
+
limit: Optional[int] = Field(
|
|
15
|
+
default=None,
|
|
16
|
+
gt=0,
|
|
17
|
+
description="Maximum number of elements to evaluate in a single page.",
|
|
18
|
+
)
|
|
19
|
+
exclusive_start_key: Optional[Dict[str, Any]] = Field(
|
|
20
|
+
default=None,
|
|
21
|
+
alias="from",
|
|
22
|
+
description="DynamoDB ExclusiveStartKey encoded in the request.",
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class PaginationMeta(BaseModel):
|
|
27
|
+
"""Generic metadata that can be attached to a paginated response."""
|
|
28
|
+
|
|
29
|
+
model_config = ConfigDict(populate_by_name=True)
|
|
30
|
+
|
|
31
|
+
total: int
|
|
32
|
+
approx_pages: int
|
|
33
|
+
limit: Optional[int] = None
|
|
34
|
+
from_: Optional[int] = Field(default=None, alias="from")
|
|
35
|
+
to: Optional[int] = None
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class PaginationResponse(BaseModel, Generic[ItemT]):
|
|
39
|
+
"""
|
|
40
|
+
Generic response wrapper for paginated HTTP GET endpoints.
|
|
41
|
+
|
|
42
|
+
The model keeps track of the DynamoDB ExclusiveStartKey used to fetch
|
|
43
|
+
the current page and the LastEvaluatedKey required to fetch the next one.
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
model_config = ConfigDict(populate_by_name=True)
|
|
47
|
+
|
|
48
|
+
items: Sequence[ItemT]
|
|
49
|
+
count: int = Field(
|
|
50
|
+
description="Number of elements returned in the current page.",
|
|
51
|
+
)
|
|
52
|
+
limit: Optional[int] = Field(
|
|
53
|
+
default=None, description="Limit applied when retrieving this page."
|
|
54
|
+
)
|
|
55
|
+
exclusive_start_key: Optional[Dict[str, Any]] = Field(
|
|
56
|
+
default=None,
|
|
57
|
+
alias="from",
|
|
58
|
+
description="ExclusiveStartKey used to produce the current page.",
|
|
59
|
+
)
|
|
60
|
+
last_evaluated_key: Optional[Dict[str, Any]] = Field(
|
|
61
|
+
default=None,
|
|
62
|
+
alias="end",
|
|
63
|
+
description="DynamoDB LastEvaluatedKey to request the next page.",
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
@model_validator(mode="before")
|
|
67
|
+
@classmethod
|
|
68
|
+
def ensure_count(cls, data: Any) -> Any:
|
|
69
|
+
"""
|
|
70
|
+
Automatically populate count when only items are provided.
|
|
71
|
+
|
|
72
|
+
This makes it easier to build the response from raw query results.
|
|
73
|
+
"""
|
|
74
|
+
if isinstance(data, dict) and "count" not in data and "items" in data:
|
|
75
|
+
try:
|
|
76
|
+
data["count"] = len(data["items"])
|
|
77
|
+
except TypeError:
|
|
78
|
+
# When items is not sized we let validation handle the error later.
|
|
79
|
+
pass
|
|
80
|
+
return data
|
|
81
|
+
|
|
82
|
+
@classmethod
|
|
83
|
+
def from_items(
|
|
84
|
+
cls,
|
|
85
|
+
items: Sequence[ItemT],
|
|
86
|
+
*,
|
|
87
|
+
limit: Optional[int] = None,
|
|
88
|
+
exclusive_start_key: Optional[Dict[str, Any]] = None,
|
|
89
|
+
last_evaluated_key: Optional[Dict[str, Any]] = None,
|
|
90
|
+
) -> "PaginationResponse[ItemT]":
|
|
91
|
+
"""
|
|
92
|
+
Helper constructor that infers the count from the provided collection.
|
|
93
|
+
"""
|
|
94
|
+
return cls(
|
|
95
|
+
items=items,
|
|
96
|
+
limit=limit,
|
|
97
|
+
exclusive_start_key=exclusive_start_key,
|
|
98
|
+
last_evaluated_key=last_evaluated_key,
|
|
99
|
+
)
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "finalsa-common-models"
|
|
3
|
-
version = "2.
|
|
3
|
+
version = "2.1.1"
|
|
4
4
|
description = "Common models for Finalsa"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.10"
|
|
7
7
|
dependencies = [
|
|
8
|
-
"orjson>=3.11.
|
|
9
|
-
"pydantic>=2.
|
|
8
|
+
"orjson>=3.11.6",
|
|
9
|
+
"pydantic>=2.12.5",
|
|
10
10
|
"python-dateutil>=2.9.0.post0",
|
|
11
11
|
]
|
|
12
12
|
authors = [
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{finalsa_common_models-2.0.4 → finalsa_common_models-2.1.1}/finalsa/common/models/models/meta.py
RENAMED
|
File without changes
|
|
File without changes
|