muffin-rest 10.1.0__tar.gz → 11.0.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.
- {muffin_rest-10.1.0 → muffin_rest-11.0.1}/PKG-INFO +1 -1
- {muffin_rest-10.1.0 → muffin_rest-11.0.1}/muffin_rest/peewee/handler.py +12 -16
- {muffin_rest-10.1.0 → muffin_rest-11.0.1}/pyproject.toml +1 -1
- {muffin_rest-10.1.0 → muffin_rest-11.0.1}/LICENSE +0 -0
- {muffin_rest-10.1.0 → muffin_rest-11.0.1}/README.rst +0 -0
- {muffin_rest-10.1.0 → muffin_rest-11.0.1}/muffin_rest/__init__.py +0 -0
- {muffin_rest-10.1.0 → muffin_rest-11.0.1}/muffin_rest/api.py +0 -0
- {muffin_rest-10.1.0 → muffin_rest-11.0.1}/muffin_rest/errors.py +0 -0
- {muffin_rest-10.1.0 → muffin_rest-11.0.1}/muffin_rest/filters.py +0 -0
- {muffin_rest-10.1.0 → muffin_rest-11.0.1}/muffin_rest/handler.py +0 -0
- {muffin_rest-10.1.0 → muffin_rest-11.0.1}/muffin_rest/limits.py +0 -0
- {muffin_rest-10.1.0 → muffin_rest-11.0.1}/muffin_rest/marshmallow.py +0 -0
- {muffin_rest-10.1.0 → muffin_rest-11.0.1}/muffin_rest/mongo/__init__.py +0 -0
- {muffin_rest-10.1.0 → muffin_rest-11.0.1}/muffin_rest/mongo/filters.py +0 -0
- {muffin_rest-10.1.0 → muffin_rest-11.0.1}/muffin_rest/mongo/schema.py +0 -0
- {muffin_rest-10.1.0 → muffin_rest-11.0.1}/muffin_rest/mongo/sorting.py +0 -0
- {muffin_rest-10.1.0 → muffin_rest-11.0.1}/muffin_rest/mongo/types.py +0 -0
- {muffin_rest-10.1.0 → muffin_rest-11.0.1}/muffin_rest/mongo/utils.py +0 -0
- {muffin_rest-10.1.0 → muffin_rest-11.0.1}/muffin_rest/openapi.py +0 -0
- {muffin_rest-10.1.0 → muffin_rest-11.0.1}/muffin_rest/options.py +0 -0
- {muffin_rest-10.1.0 → muffin_rest-11.0.1}/muffin_rest/peewee/__init__.py +0 -0
- {muffin_rest-10.1.0 → muffin_rest-11.0.1}/muffin_rest/peewee/filters.py +0 -0
- {muffin_rest-10.1.0 → muffin_rest-11.0.1}/muffin_rest/peewee/openapi.py +0 -0
- {muffin_rest-10.1.0 → muffin_rest-11.0.1}/muffin_rest/peewee/options.py +0 -0
- {muffin_rest-10.1.0 → muffin_rest-11.0.1}/muffin_rest/peewee/schemas.py +0 -0
- {muffin_rest-10.1.0 → muffin_rest-11.0.1}/muffin_rest/peewee/sorting.py +0 -0
- {muffin_rest-10.1.0 → muffin_rest-11.0.1}/muffin_rest/peewee/types.py +0 -0
- {muffin_rest-10.1.0 → muffin_rest-11.0.1}/muffin_rest/peewee/utils.py +0 -0
- {muffin_rest-10.1.0 → muffin_rest-11.0.1}/muffin_rest/py.typed +0 -0
- {muffin_rest-10.1.0 → muffin_rest-11.0.1}/muffin_rest/redoc.html +0 -0
- {muffin_rest-10.1.0 → muffin_rest-11.0.1}/muffin_rest/schemas.py +0 -0
- {muffin_rest-10.1.0 → muffin_rest-11.0.1}/muffin_rest/sorting.py +0 -0
- {muffin_rest-10.1.0 → muffin_rest-11.0.1}/muffin_rest/sqlalchemy/__init__.py +0 -0
- {muffin_rest-10.1.0 → muffin_rest-11.0.1}/muffin_rest/sqlalchemy/filters.py +0 -0
- {muffin_rest-10.1.0 → muffin_rest-11.0.1}/muffin_rest/sqlalchemy/sorting.py +0 -0
- {muffin_rest-10.1.0 → muffin_rest-11.0.1}/muffin_rest/sqlalchemy/types.py +0 -0
- {muffin_rest-10.1.0 → muffin_rest-11.0.1}/muffin_rest/swagger.html +0 -0
- {muffin_rest-10.1.0 → muffin_rest-11.0.1}/muffin_rest/types.py +0 -0
- {muffin_rest-10.1.0 → muffin_rest-11.0.1}/muffin_rest/utils.py +0 -0
|
@@ -43,18 +43,16 @@ class PWRESTBase(RESTBase[TVModel], PeeweeOpenAPIMixin):
|
|
|
43
43
|
async def prepare_collection(
|
|
44
44
|
self: PWRESTBase[TVAIOModel],
|
|
45
45
|
_: Request,
|
|
46
|
-
) -> AIOModelSelect[TVAIOModel]:
|
|
47
|
-
...
|
|
46
|
+
) -> AIOModelSelect[TVAIOModel]: ...
|
|
48
47
|
|
|
49
48
|
@overload
|
|
50
49
|
async def prepare_collection(
|
|
51
50
|
self: PWRESTBase[pw.Model],
|
|
52
51
|
_: Request,
|
|
53
|
-
) -> pw.ModelSelect:
|
|
54
|
-
...
|
|
52
|
+
) -> pw.ModelSelect: ...
|
|
55
53
|
|
|
56
54
|
# NOTE: there is not a default sorting for peewee (conflict with muffin-admin)
|
|
57
|
-
async def prepare_collection(self, _: Request):
|
|
55
|
+
async def prepare_collection(self, _: Request): # type: ignore[override]
|
|
58
56
|
"""Initialize Peeewee QuerySet for a binded to the resource model."""
|
|
59
57
|
return self.meta.model.select()
|
|
60
58
|
|
|
@@ -81,16 +79,14 @@ class PWRESTBase(RESTBase[TVModel], PeeweeOpenAPIMixin):
|
|
|
81
79
|
@overload
|
|
82
80
|
async def paginate(
|
|
83
81
|
self: PWRESTBase[TVAIOModel], _: Request, *, limit: int = 0, offset: int = 0
|
|
84
|
-
) -> tuple[AIOModelSelect[TVAIOModel], int | None]:
|
|
85
|
-
...
|
|
82
|
+
) -> tuple[AIOModelSelect[TVAIOModel], int | None]: ...
|
|
86
83
|
|
|
87
84
|
@overload
|
|
88
85
|
async def paginate(
|
|
89
86
|
self: PWRESTBase[pw.Model], _: Request, *, limit: int = 0, offset: int = 0
|
|
90
|
-
) -> tuple[pw.ModelSelect, int | None]:
|
|
91
|
-
...
|
|
87
|
+
) -> tuple[pw.ModelSelect, int | None]: ...
|
|
92
88
|
|
|
93
|
-
async def paginate(self, _: Request, *, limit: int = 0, offset: int = 0):
|
|
89
|
+
async def paginate(self, _: Request, *, limit: int = 0, offset: int = 0): # type: ignore[override]
|
|
94
90
|
"""Paginate the collection."""
|
|
95
91
|
if self.meta.limit_total:
|
|
96
92
|
cqs = cast(pw.ModelSelect, self.collection.order_by())
|
|
@@ -118,9 +114,9 @@ class PWRESTBase(RESTBase[TVModel], PeeweeOpenAPIMixin):
|
|
|
118
114
|
meta = self.meta
|
|
119
115
|
manager = meta.manager
|
|
120
116
|
if issubclass(meta.model, AIOModel):
|
|
121
|
-
await resource.save()
|
|
117
|
+
await resource.save(force_insert=not update)
|
|
122
118
|
else:
|
|
123
|
-
await manager.save(resource)
|
|
119
|
+
await manager.save(resource, force_insert=not update)
|
|
124
120
|
|
|
125
121
|
return resource
|
|
126
122
|
|
|
@@ -136,9 +132,7 @@ class PWRESTBase(RESTBase[TVModel], PeeweeOpenAPIMixin):
|
|
|
136
132
|
return
|
|
137
133
|
|
|
138
134
|
model_pk = cast(pw.Field, meta.model_pk)
|
|
139
|
-
resources = await meta.manager.fetchall(
|
|
140
|
-
self.collection.where(model_pk << data),
|
|
141
|
-
)
|
|
135
|
+
resources = await meta.manager.fetchall(self.collection.where(model_pk << data)) # type: ignore[]
|
|
142
136
|
|
|
143
137
|
if not resources:
|
|
144
138
|
raise APIError.NOT_FOUND()
|
|
@@ -151,7 +145,9 @@ class PWRESTBase(RESTBase[TVModel], PeeweeOpenAPIMixin):
|
|
|
151
145
|
for res in resources:
|
|
152
146
|
await meta.manager.delete_instance(res, recursive=meta.delete_recursive)
|
|
153
147
|
|
|
154
|
-
|
|
148
|
+
return resource.get_id() if resource else [r.get_id() for r in resources]
|
|
149
|
+
|
|
150
|
+
async def delete(self, request: Request, resource: Optional[TVModel] = None): # type: ignore[override]
|
|
155
151
|
return await self.remove(request, resource)
|
|
156
152
|
|
|
157
153
|
def get_schema(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|