statezero 0.1.0b13__py3-none-any.whl → 0.1.0b15__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.
Potentially problematic release.
This version of statezero might be problematic. Click here for more details.
- statezero/adaptors/django/schemas.py +13 -2
- statezero/core/ast_parser.py +13 -2
- statezero/core/config.py +2 -0
- {statezero-0.1.0b13.dist-info → statezero-0.1.0b15.dist-info}/METADATA +1 -1
- {statezero-0.1.0b13.dist-info → statezero-0.1.0b15.dist-info}/RECORD +8 -8
- {statezero-0.1.0b13.dist-info → statezero-0.1.0b15.dist-info}/WHEEL +0 -0
- {statezero-0.1.0b13.dist-info → statezero-0.1.0b15.dist-info}/licenses/license.md +0 -0
- {statezero-0.1.0b13.dist-info → statezero-0.1.0b15.dist-info}/top_level.txt +0 -0
|
@@ -41,9 +41,9 @@ class DjangoSchemaGenerator(AbstractSchemaGenerator):
|
|
|
41
41
|
all_field_names: Set[str] = set()
|
|
42
42
|
db_field_names: Set[str] = set()
|
|
43
43
|
|
|
44
|
-
if model_config.
|
|
44
|
+
if model_config.frontend_fields != "__all__":
|
|
45
45
|
all_fields = [
|
|
46
|
-
field for field in all_fields if field.name in model_config.
|
|
46
|
+
field for field in all_fields if field.name in model_config.frontend_fields
|
|
47
47
|
]
|
|
48
48
|
|
|
49
49
|
for field in all_fields:
|
|
@@ -178,6 +178,7 @@ class DjangoSchemaGenerator(AbstractSchemaGenerator):
|
|
|
178
178
|
nullable=False,
|
|
179
179
|
format=FieldFormat.ID,
|
|
180
180
|
description=description,
|
|
181
|
+
read_only=True,
|
|
181
182
|
)
|
|
182
183
|
elif isinstance(field, models.UUIDField):
|
|
183
184
|
return SchemaFieldMetadata(
|
|
@@ -187,6 +188,7 @@ class DjangoSchemaGenerator(AbstractSchemaGenerator):
|
|
|
187
188
|
nullable=False,
|
|
188
189
|
format=FieldFormat.UUID,
|
|
189
190
|
description=description,
|
|
191
|
+
read_only=True,
|
|
190
192
|
)
|
|
191
193
|
elif isinstance(field, models.CharField):
|
|
192
194
|
return SchemaFieldMetadata(
|
|
@@ -197,6 +199,7 @@ class DjangoSchemaGenerator(AbstractSchemaGenerator):
|
|
|
197
199
|
format=FieldFormat.ID,
|
|
198
200
|
max_length=field.max_length,
|
|
199
201
|
description=description,
|
|
202
|
+
read_only=True,
|
|
200
203
|
)
|
|
201
204
|
else:
|
|
202
205
|
return SchemaFieldMetadata(
|
|
@@ -206,6 +209,7 @@ class DjangoSchemaGenerator(AbstractSchemaGenerator):
|
|
|
206
209
|
nullable=False,
|
|
207
210
|
format=FieldFormat.ID,
|
|
208
211
|
description=description,
|
|
212
|
+
read_only=True,
|
|
209
213
|
)
|
|
210
214
|
|
|
211
215
|
def get_field_metadata(
|
|
@@ -286,6 +290,12 @@ class DjangoSchemaGenerator(AbstractSchemaGenerator):
|
|
|
286
290
|
elif callable(default):
|
|
287
291
|
default = default()
|
|
288
292
|
|
|
293
|
+
# Check if field should be read-only (auto_now or auto_now_add)
|
|
294
|
+
read_only = False
|
|
295
|
+
if isinstance(field, (models.DateTimeField, models.DateField)):
|
|
296
|
+
if getattr(field, "auto_now", False) or getattr(field, "auto_now_add", False):
|
|
297
|
+
read_only = True
|
|
298
|
+
|
|
289
299
|
return SchemaFieldMetadata(
|
|
290
300
|
type=field_type,
|
|
291
301
|
title=title,
|
|
@@ -299,6 +309,7 @@ class DjangoSchemaGenerator(AbstractSchemaGenerator):
|
|
|
299
309
|
max_digits=max_digits,
|
|
300
310
|
decimal_places=decimal_places,
|
|
301
311
|
description=description,
|
|
312
|
+
read_only=read_only,
|
|
302
313
|
)
|
|
303
314
|
|
|
304
315
|
def get_field_title(self, field: models.Field) -> str:
|
statezero/core/ast_parser.py
CHANGED
|
@@ -386,8 +386,19 @@ class ASTParser:
|
|
|
386
386
|
|
|
387
387
|
# If any permission allows all fields
|
|
388
388
|
if fields == "__all__":
|
|
389
|
-
|
|
390
|
-
|
|
389
|
+
# NEW: For read operations, default "__all__" to frontend_fields
|
|
390
|
+
if operation_type == "read":
|
|
391
|
+
# If frontend_fields is also "__all__", then return all fields
|
|
392
|
+
if model_config.frontend_fields == "__all__":
|
|
393
|
+
return all_fields
|
|
394
|
+
# Otherwise, use frontend_fields as the default for "__all__"
|
|
395
|
+
else:
|
|
396
|
+
fields = model_config.frontend_fields
|
|
397
|
+
fields &= all_fields # Ensure fields actually exist
|
|
398
|
+
allowed_fields |= fields
|
|
399
|
+
else:
|
|
400
|
+
# For create/update operations, "__all__" means truly all fields
|
|
401
|
+
return all_fields
|
|
391
402
|
# Add allowed fields from this permission
|
|
392
403
|
else: # Ensure we're not operating on the string "__all__"
|
|
393
404
|
fields &= all_fields # Ensure fields actually exist
|
statezero/core/config.py
CHANGED
|
@@ -181,6 +181,7 @@ class ModelConfig:
|
|
|
181
181
|
searchable_fields: Optional[Union[Set[str], Literal["__all__"]]] = None,
|
|
182
182
|
ordering_fields: Optional[Union[Set[str], Literal["__all__"]]] = None,
|
|
183
183
|
fields: Optional[Union[Set[str], Literal["__all__"]]] = None,
|
|
184
|
+
frontend_fields: Optional[Union[Set[str], Literal["__all__"]]] = None,
|
|
184
185
|
display: Optional[Any] = None,
|
|
185
186
|
DEBUG: bool = False,
|
|
186
187
|
):
|
|
@@ -195,6 +196,7 @@ class ModelConfig:
|
|
|
195
196
|
self.searchable_fields = searchable_fields or set()
|
|
196
197
|
self.ordering_fields = ordering_fields or set()
|
|
197
198
|
self.fields = fields or "__all__"
|
|
199
|
+
self.frontend_fields = frontend_fields or self.fields
|
|
198
200
|
self.display = display
|
|
199
201
|
self.DEBUG = DEBUG or False
|
|
200
202
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: statezero
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.0b15
|
|
4
4
|
Summary: Connect your Python backend to a modern JavaScript SPA frontend with 90% less complexity.
|
|
5
5
|
Author-email: Robert <robert.herring@statezero.dev>
|
|
6
6
|
Project-URL: homepage, https://www.statezero.dev
|
|
@@ -13,7 +13,7 @@ statezero/adaptors/django/middleware.py,sha256=YVr8fkqCk51xJQM-ovtrUiB9Kt9H81cLd
|
|
|
13
13
|
statezero/adaptors/django/orm.py,sha256=Z62XheCvuKIpKOoIIiLLOwrpJ5jPhv-BGxg-pqPgNaU,40757
|
|
14
14
|
statezero/adaptors/django/permissions.py,sha256=fU2c4bKK0zX2uuVB0UazZHTI-5OkiI5-BtPNcPEWmW0,9525
|
|
15
15
|
statezero/adaptors/django/query_optimizer.py,sha256=-iAh5kyE8WNZdjb_qBbNag_nxKzejroUYPBdwG_uVaQ,41462
|
|
16
|
-
statezero/adaptors/django/schemas.py,sha256=
|
|
16
|
+
statezero/adaptors/django/schemas.py,sha256=5t75ktdLtyoQiP3vMV8Ti8GOtyG4edVWZ3rrLkPjeRg,13934
|
|
17
17
|
statezero/adaptors/django/serializers.py,sha256=YFFDu6bzoWkSEOVH5Wmc4yJ8SaOkUA6HbXXYt6djlfc,23296
|
|
18
18
|
statezero/adaptors/django/urls.py,sha256=OrGQ60vj_wrbiREAKmYDZTwohpKmgjH9n0fdOw1qPaY,924
|
|
19
19
|
statezero/adaptors/django/views.py,sha256=2bJDbXuRGoG2_7zyapWzmRzpSVUHkCpcI58wsrXN1jc,19947
|
|
@@ -29,10 +29,10 @@ statezero/adaptors/django/search_providers/basic_search.py,sha256=5_GJ1r_B6JdIYX
|
|
|
29
29
|
statezero/adaptors/django/search_providers/postgres_search.py,sha256=IMoHxzfi-Y3hAxPND4Xc6GatrPs1eXAqpmcfwt5Zr14,2459
|
|
30
30
|
statezero/core/__init__.py,sha256=Z6RTutAAElLMEjBFphVVmpySPdJBA55j-Uo0BtR7c5E,1040
|
|
31
31
|
statezero/core/actions.py,sha256=eq4zuDhK1h-nZ24jUQhiWL6BcMqq-W4BhdVNdYegymw,2969
|
|
32
|
-
statezero/core/ast_parser.py,sha256=
|
|
32
|
+
statezero/core/ast_parser.py,sha256=QTFRDwanN2jJJOs4SeRdRPiVZWlK-tkmwZBlQNByew0,39321
|
|
33
33
|
statezero/core/ast_validator.py,sha256=YZAflPyba0kXWBNhd1Z_XeEk-_zUzM6MkY9zSlX1PMs,11582
|
|
34
34
|
statezero/core/classes.py,sha256=NLIiOPm6PwQAmJXFeN2iScdoGeHyimzdnXmyyfBM-NY,6977
|
|
35
|
-
statezero/core/config.py,sha256=
|
|
35
|
+
statezero/core/config.py,sha256=kOcQPzBA06d8EliP2bVY0daFlt8bm-8ZOsqb5x7-8JA,11822
|
|
36
36
|
statezero/core/context_storage.py,sha256=DVx525ZMRorj41kg5K0N6pPdGkQ5_XEJcBucpH5ChxQ,162
|
|
37
37
|
statezero/core/event_bus.py,sha256=2IFLBHSkLzpm1AX0MfSXSmF2X-lXK-gOoODZCtB2Jdw,6284
|
|
38
38
|
statezero/core/event_emitters.py,sha256=qjMbeUmdn4bG7WiVfqTmNdaflEea5amnTEpOn5X0J44,2046
|
|
@@ -41,8 +41,8 @@ statezero/core/hook_checks.py,sha256=uqtvwRx1qGsF7Vc49elAWdOjMzhuv3RADKY1wiLvhK4
|
|
|
41
41
|
statezero/core/interfaces.py,sha256=kVkNWyh52tUlzD02CRheLJof3DyQoVcPuvX33fL6sn8,20544
|
|
42
42
|
statezero/core/process_request.py,sha256=dwIeBEVOE8zA-oE1h65XNOGiVqFbbXA7SzTAguLNgZk,8060
|
|
43
43
|
statezero/core/types.py,sha256=mMtqK3fGhEM6LtzUgQrxlyP-V0VgVqc-1eVKgRjTzp0,913
|
|
44
|
-
statezero-0.1.
|
|
45
|
-
statezero-0.1.
|
|
46
|
-
statezero-0.1.
|
|
47
|
-
statezero-0.1.
|
|
48
|
-
statezero-0.1.
|
|
44
|
+
statezero-0.1.0b15.dist-info/licenses/license.md,sha256=0uKjybTt9K_YbEmYgf25JN292qjjJ-BPofvIZ3wdtX4,7411
|
|
45
|
+
statezero-0.1.0b15.dist-info/METADATA,sha256=4eAv11aK8F7hRrmso2O-7_YDllzjbz1RFloNHKjF_t0,6704
|
|
46
|
+
statezero-0.1.0b15.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
47
|
+
statezero-0.1.0b15.dist-info/top_level.txt,sha256=UAuZYPKczradU1kcMQxsGjUzEW0qdgsqzhXyscrcLpw,10
|
|
48
|
+
statezero-0.1.0b15.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|