sera-2 1.7.1__py3-none-any.whl → 1.7.2__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.
@@ -241,8 +241,15 @@ def make_typescript_data_model(schema: Schema, target_pkg: Package):
|
|
241
241
|
program.import_("mobx.makeObservable", True)
|
242
242
|
program.import_("mobx.observable", True)
|
243
243
|
program.import_("mobx.action", True)
|
244
|
+
program.import_("sera-db.validators", True)
|
244
245
|
|
245
|
-
program.root
|
246
|
+
program.root(
|
247
|
+
stmt.LineBreak(),
|
248
|
+
stmt.TypescriptStatement(
|
249
|
+
"const {getValidator, memoizeOneValidators} = validators;"
|
250
|
+
),
|
251
|
+
stmt.LineBreak(),
|
252
|
+
)
|
246
253
|
|
247
254
|
# make sure that the property stale is not in existing properties
|
248
255
|
if "stale" in cls.properties:
|
@@ -252,6 +259,7 @@ def make_typescript_data_model(schema: Schema, target_pkg: Package):
|
|
252
259
|
cls_pk = None
|
253
260
|
observable_args: list[tuple[expr.Expr, expr.ExprIdent]] = []
|
254
261
|
prop_defs = []
|
262
|
+
prop_validators = []
|
255
263
|
prop_constructor_assigns = []
|
256
264
|
# attrs needed for the cls.create function
|
257
265
|
create_args = []
|
@@ -330,6 +338,25 @@ def make_typescript_data_model(schema: Schema, target_pkg: Package):
|
|
330
338
|
else:
|
331
339
|
create_propvalue = tstype.get_default()
|
332
340
|
|
341
|
+
prop_validators.append(
|
342
|
+
(
|
343
|
+
expr.ExprIdent(propname),
|
344
|
+
expr.ExprFuncCall(
|
345
|
+
expr.ExprIdent("getValidator"),
|
346
|
+
[
|
347
|
+
PredefinedFn.list(
|
348
|
+
[
|
349
|
+
expr.ExprConstant(
|
350
|
+
constraint.get_typescript_constraint()
|
351
|
+
)
|
352
|
+
for constraint in prop.data.constraints
|
353
|
+
]
|
354
|
+
),
|
355
|
+
],
|
356
|
+
),
|
357
|
+
)
|
358
|
+
)
|
359
|
+
|
333
360
|
if prop.db is not None and prop.db.is_primary_key:
|
334
361
|
# for checking if the primary key is from the database or default (create_propvalue)
|
335
362
|
cls_pk = (expr.ExprIdent(propname), create_propvalue)
|
@@ -530,6 +557,10 @@ def make_typescript_data_model(schema: Schema, target_pkg: Package):
|
|
530
557
|
)
|
531
558
|
observable_args.sort(key=lambda x: {"observable": 0, "action": 1}[x[1].ident])
|
532
559
|
|
560
|
+
validators = expr.ExprFuncCall(
|
561
|
+
expr.ExprIdent("memoizeOneValidators"), [PredefinedFn.dict(prop_validators)]
|
562
|
+
)
|
563
|
+
|
533
564
|
program.root(
|
534
565
|
lambda ast00: ast00.class_like(
|
535
566
|
"interface",
|
@@ -539,6 +570,10 @@ def make_typescript_data_model(schema: Schema, target_pkg: Package):
|
|
539
570
|
lambda ast10: ast10.class_(draft_clsname)(
|
540
571
|
*prop_defs,
|
541
572
|
stmt.LineBreak(),
|
573
|
+
stmt.DefClassVarStatement(
|
574
|
+
"validators", type=None, value=validators, is_static=True
|
575
|
+
),
|
576
|
+
stmt.LineBreak(),
|
542
577
|
lambda ast10: ast10.func(
|
543
578
|
"constructor",
|
544
579
|
[
|
@@ -12,7 +12,7 @@ sera/make/make_app.py,sha256=n9NtW73O3s_5Q31VHIRmnd-jEIcpDO7ksAsOdovde2s,5999
|
|
12
12
|
sera/make/make_python_api.py,sha256=RuJUm9z-4plBEtjobeOPr12o27OT-0tSeXI4ZlM3IY0,29433
|
13
13
|
sera/make/make_python_model.py,sha256=xf4revAwVWEnF6QhxbbqPyUGgXOOB--Gu3jPxsESg0Y,36593
|
14
14
|
sera/make/make_python_services.py,sha256=RsinYZdfkrTlTn9CT50VgqGs9w6IZawsJx-KEmqfnEY,2062
|
15
|
-
sera/make/make_typescript_model.py,sha256=
|
15
|
+
sera/make/make_typescript_model.py,sha256=27lk4YgfJ6_7xxBirxJKgK0-wBNowMWZkvcMUFdmStE,46865
|
16
16
|
sera/misc/__init__.py,sha256=Dh4uDq0D4N53h3zhvmwfa5a0TPVRSUvLzb0hkFuPirk,411
|
17
17
|
sera/misc/_formatter.py,sha256=aCGYL08l8f3aLODHxSocxBBwkRYEo3K1QzCDEn3suj0,1685
|
18
18
|
sera/misc/_utils.py,sha256=V5g4oLGHOhUCR75Kkcn1w01pAvGvaepK-T8Z3pIgHjI,1450
|
@@ -29,6 +29,6 @@ sera/models/_parse.py,sha256=sJYfQtwek96ltpgxExG4xUbiLnU3qvNYhTP1CeyXGjs,9746
|
|
29
29
|
sera/models/_property.py,sha256=CmEmgOShtSyNFq05YW3tGupwCIVRzPMKudXWld8utPk,5530
|
30
30
|
sera/models/_schema.py,sha256=r-Gqg9Lb_wR3UrbNvfXXgt_qs5bts0t2Ve7aquuF_OI,1155
|
31
31
|
sera/typing.py,sha256=Q4QMfbtfrCjC9tFfsZPhsAnbNX4lm4NHQ9lmjNXYdV0,772
|
32
|
-
sera_2-1.7.
|
33
|
-
sera_2-1.7.
|
34
|
-
sera_2-1.7.
|
32
|
+
sera_2-1.7.2.dist-info/METADATA,sha256=xzCJfINCVbrv5Xd3oAKXJnhF_tYm7A51PpdTpdVqUW8,856
|
33
|
+
sera_2-1.7.2.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
34
|
+
sera_2-1.7.2.dist-info/RECORD,,
|
File without changes
|