sera-2 1.14.5__tar.gz → 1.14.7__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.
Files changed (41) hide show
  1. {sera_2-1.14.5 → sera_2-1.14.7}/PKG-INFO +1 -1
  2. {sera_2-1.14.5 → sera_2-1.14.7}/pyproject.toml +1 -1
  3. {sera_2-1.14.5 → sera_2-1.14.7}/sera/make/make_typescript_model.py +13 -1
  4. {sera_2-1.14.5 → sera_2-1.14.7}/sera/misc/_utils.py +48 -2
  5. {sera_2-1.14.5 → sera_2-1.14.7}/README.md +0 -0
  6. {sera_2-1.14.5 → sera_2-1.14.7}/sera/__init__.py +0 -0
  7. {sera_2-1.14.5 → sera_2-1.14.7}/sera/constants.py +0 -0
  8. {sera_2-1.14.5 → sera_2-1.14.7}/sera/exports/__init__.py +0 -0
  9. {sera_2-1.14.5 → sera_2-1.14.7}/sera/exports/schema.py +0 -0
  10. {sera_2-1.14.5 → sera_2-1.14.7}/sera/exports/test.py +0 -0
  11. {sera_2-1.14.5 → sera_2-1.14.7}/sera/libs/__init__.py +0 -0
  12. {sera_2-1.14.5 → sera_2-1.14.7}/sera/libs/api_helper.py +0 -0
  13. {sera_2-1.14.5 → sera_2-1.14.7}/sera/libs/api_test_helper.py +0 -0
  14. {sera_2-1.14.5 → sera_2-1.14.7}/sera/libs/base_orm.py +0 -0
  15. {sera_2-1.14.5 → sera_2-1.14.7}/sera/libs/base_service.py +0 -0
  16. {sera_2-1.14.5 → sera_2-1.14.7}/sera/libs/dag/__init__.py +0 -0
  17. {sera_2-1.14.5 → sera_2-1.14.7}/sera/libs/dag/_dag.py +0 -0
  18. {sera_2-1.14.5 → sera_2-1.14.7}/sera/libs/middlewares/__init__.py +0 -0
  19. {sera_2-1.14.5 → sera_2-1.14.7}/sera/libs/middlewares/auth.py +0 -0
  20. {sera_2-1.14.5 → sera_2-1.14.7}/sera/libs/middlewares/uscp.py +0 -0
  21. {sera_2-1.14.5 → sera_2-1.14.7}/sera/make/__init__.py +0 -0
  22. {sera_2-1.14.5 → sera_2-1.14.7}/sera/make/__main__.py +0 -0
  23. {sera_2-1.14.5 → sera_2-1.14.7}/sera/make/make_app.py +0 -0
  24. {sera_2-1.14.5 → sera_2-1.14.7}/sera/make/make_python_api.py +0 -0
  25. {sera_2-1.14.5 → sera_2-1.14.7}/sera/make/make_python_model.py +0 -0
  26. {sera_2-1.14.5 → sera_2-1.14.7}/sera/make/make_python_services.py +0 -0
  27. {sera_2-1.14.5 → sera_2-1.14.7}/sera/misc/__init__.py +0 -0
  28. {sera_2-1.14.5 → sera_2-1.14.7}/sera/misc/_formatter.py +0 -0
  29. {sera_2-1.14.5 → sera_2-1.14.7}/sera/models/__init__.py +0 -0
  30. {sera_2-1.14.5 → sera_2-1.14.7}/sera/models/_class.py +0 -0
  31. {sera_2-1.14.5 → sera_2-1.14.7}/sera/models/_collection.py +0 -0
  32. {sera_2-1.14.5 → sera_2-1.14.7}/sera/models/_constraints.py +0 -0
  33. {sera_2-1.14.5 → sera_2-1.14.7}/sera/models/_datatype.py +0 -0
  34. {sera_2-1.14.5 → sera_2-1.14.7}/sera/models/_default.py +0 -0
  35. {sera_2-1.14.5 → sera_2-1.14.7}/sera/models/_enum.py +0 -0
  36. {sera_2-1.14.5 → sera_2-1.14.7}/sera/models/_module.py +0 -0
  37. {sera_2-1.14.5 → sera_2-1.14.7}/sera/models/_multi_lingual_string.py +0 -0
  38. {sera_2-1.14.5 → sera_2-1.14.7}/sera/models/_parse.py +0 -0
  39. {sera_2-1.14.5 → sera_2-1.14.7}/sera/models/_property.py +0 -0
  40. {sera_2-1.14.5 → sera_2-1.14.7}/sera/models/_schema.py +0 -0
  41. {sera_2-1.14.5 → sera_2-1.14.7}/sera/typing.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: sera-2
3
- Version: 1.14.5
3
+ Version: 1.14.7
4
4
  Summary:
5
5
  Author: Binh Vu
6
6
  Author-email: bvu687@gmail.com
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "sera-2"
3
- version = "1.14.5"
3
+ version = "1.14.7"
4
4
  description = ""
5
5
  authors = ["Binh Vu <bvu687@gmail.com>"]
6
6
  readme = "README.md"
@@ -1104,7 +1104,19 @@ def make_typescript_data_model(schema: Schema, target_pkg: Package):
1104
1104
  for dep in tstype.deps:
1105
1105
  program.import_(dep, True)
1106
1106
  tsprop = [
1107
- (expr.ExprIdent("datatype"), expr.ExprConstant(tstype.type)),
1107
+ (
1108
+ expr.ExprIdent("datatype"),
1109
+ (
1110
+ expr.ExprConstant(tstype.type)
1111
+ if tstype.type not in schema.enums
1112
+ else expr.ExprConstant("enum")
1113
+ ),
1114
+ ),
1115
+ *(
1116
+ [(expr.ExprIdent("enumType"), expr.ExprIdent(tstype.type))]
1117
+ if tstype.type in schema.enums
1118
+ else []
1119
+ ),
1108
1120
  (
1109
1121
  expr.ExprIdent("isRequired"),
1110
1122
  expr.ExprConstant(
@@ -4,6 +4,44 @@ import re
4
4
  from typing import Any, Callable, Iterable, Optional, TypeVar
5
5
 
6
6
  T = TypeVar("T")
7
+ reserved_keywords = {
8
+ "and",
9
+ "or",
10
+ "not",
11
+ "is",
12
+ "in",
13
+ "if",
14
+ "else",
15
+ "elif",
16
+ "for",
17
+ "while",
18
+ "def",
19
+ "class",
20
+ "return",
21
+ "yield",
22
+ "import",
23
+ "from",
24
+ "as",
25
+ "with",
26
+ "try",
27
+ "except",
28
+ "finally",
29
+ "raise",
30
+ "assert",
31
+ "break",
32
+ "continue",
33
+ "pass",
34
+ "del",
35
+ "global",
36
+ "nonlocal",
37
+ "lambda",
38
+ "async",
39
+ "await",
40
+ "True",
41
+ "False",
42
+ "None",
43
+ "self",
44
+ }
7
45
 
8
46
 
9
47
  def to_snake_case(camelcase: str) -> str:
@@ -16,13 +54,21 @@ def to_snake_case(camelcase: str) -> str:
16
54
  def to_camel_case(snake: str) -> str:
17
55
  """Convert snake_case to camelCase."""
18
56
  components = snake.split("_")
19
- return components[0] + "".join(x.title() for x in components[1:])
57
+ out = components[0] + "".join(x.title() for x in components[1:])
58
+ # handle a corner case where the _ is added to the end of the string to avoid reserved keywords
59
+ if snake.endswith("_") and snake[:-1] in reserved_keywords:
60
+ out += "_"
61
+ return out
20
62
 
21
63
 
22
64
  def to_pascal_case(snake: str) -> str:
23
65
  """Convert snake_case to PascalCase."""
24
66
  components = snake.split("_")
25
- return "".join(x.title() for x in components)
67
+ out = "".join(x.title() for x in components)
68
+ # handle a corner case where the _ is added to the end of the string to avoid reserved keywords
69
+ if snake.endswith("_") and snake[:-1] in reserved_keywords:
70
+ out += "_"
71
+ return out
26
72
 
27
73
 
28
74
  def assert_isinstance(x: Any, cls: type[T]) -> T:
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