scjson 0.2.0__tar.gz → 0.2.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.
Files changed (29) hide show
  1. {scjson-0.2.0/scjson.egg-info → scjson-0.2.1}/PKG-INFO +1 -1
  2. {scjson-0.2.0 → scjson-0.2.1}/pyproject.toml +1 -1
  3. {scjson-0.2.0 → scjson-0.2.1}/scjson/cli.py +3 -2
  4. {scjson-0.2.0 → scjson-0.2.1}/scjson/jinja_gen.py +24 -1
  5. {scjson-0.2.0 → scjson-0.2.1/scjson.egg-info}/PKG-INFO +1 -1
  6. {scjson-0.2.0 → scjson-0.2.1}/LEGAL.md +0 -0
  7. {scjson-0.2.0 → scjson-0.2.1}/LICENSE +0 -0
  8. {scjson-0.2.0 → scjson-0.2.1}/MANIFEST.in +0 -0
  9. {scjson-0.2.0 → scjson-0.2.1}/README.md +0 -0
  10. {scjson-0.2.0 → scjson-0.2.1}/scjson/CaseStyle.py +0 -0
  11. {scjson-0.2.0 → scjson-0.2.1}/scjson/SCXMLDocumentHandler.py +0 -0
  12. {scjson-0.2.0 → scjson-0.2.1}/scjson/__init__.py +0 -0
  13. {scjson-0.2.0 → scjson-0.2.1}/scjson/__main__.py +0 -0
  14. {scjson-0.2.0 → scjson-0.2.1}/scjson/dataclasses/__init__.py +0 -0
  15. {scjson-0.2.0 → scjson-0.2.1}/scjson/dataclasses/generated.py +0 -0
  16. {scjson-0.2.0 → scjson-0.2.1}/scjson/dataclasses_strict/__init__.py +0 -0
  17. {scjson-0.2.0 → scjson-0.2.1}/scjson/dataclasses_strict/generated.py +0 -0
  18. {scjson-0.2.0 → scjson-0.2.1}/scjson/pydantic/__init__.py +0 -0
  19. {scjson-0.2.0 → scjson-0.2.1}/scjson/pydantic/generated.py +0 -0
  20. {scjson-0.2.0 → scjson-0.2.1}/scjson/pydantic_strict/__init__.py +0 -0
  21. {scjson-0.2.0 → scjson-0.2.1}/scjson/pydantic_strict/generated.py +0 -0
  22. {scjson-0.2.0 → scjson-0.2.1}/scjson.egg-info/SOURCES.txt +0 -0
  23. {scjson-0.2.0 → scjson-0.2.1}/scjson.egg-info/dependency_links.txt +0 -0
  24. {scjson-0.2.0 → scjson-0.2.1}/scjson.egg-info/entry_points.txt +0 -0
  25. {scjson-0.2.0 → scjson-0.2.1}/scjson.egg-info/requires.txt +0 -0
  26. {scjson-0.2.0 → scjson-0.2.1}/scjson.egg-info/top_level.txt +0 -0
  27. {scjson-0.2.0 → scjson-0.2.1}/setup.cfg +0 -0
  28. {scjson-0.2.0 → scjson-0.2.1}/tests/__pycache__/test_cli.cpython-310-pytest-8.4.1.pyc +0 -0
  29. {scjson-0.2.0 → scjson-0.2.1}/tests/test_cli.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scjson
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: A JSON-based serialization of SCXML (State Chart XML) for modern tooling, interoperability, and education.
5
5
  Author-email: Ira Abbott <ira@mycloud.blue>
6
6
  License: BSD-1-Clause
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "scjson"
3
- version = "0.2.0"
3
+ version = "0.2.1"
4
4
  description = "A JSON-based serialization of SCXML (State Chart XML) for modern tooling, interoperability, and education."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.8"
@@ -188,11 +188,12 @@ def validate(path: Path, recursive: bool):
188
188
  @click.option("--output", "-o", type=click.Path(path_type=Path), help="Output file base.")
189
189
  def typescript(output: Path | None):
190
190
  """Create typescrupt Type files for scjson."""
191
- print(f"Convert Scjson tyoe for typescript - Path: {output}")
191
+ print(f"Convert Scjson type for typescript - Path: {output}")
192
192
  Gen = JinjaGenPydantic(output=output)
193
193
  base_dir = os.path.abspath(output)
194
194
  interfaces = Gen.interfaces
195
- schema = Gen.schemas
195
+ schemas = Gen.schemas
196
+ all_arrays = Gen.all_arrays
196
197
  os.makedirs(base_dir, exist_ok=True)
197
198
  is_runtime = True
198
199
  file_name = "scjsonProps.ts"
@@ -3,6 +3,7 @@ import os
3
3
  from pathlib import Path
4
4
  import importlib
5
5
  import inspect
6
+ from typing import List
6
7
  from enum import Enum
7
8
  from pydantic import BaseModel
8
9
  from jinja2 import Environment, select_autoescape, FileSystemLoader
@@ -35,7 +36,7 @@ class JinjaGenPydantic(object):
35
36
  self.objekts = {}
36
37
  self.schema = {}
37
38
  self.array_types = []
38
- self.env = Environment(loader=FileSystemLoader(my_path),
39
+ self.env = Environment(loader=FileSystemLoader(self.template_path),
39
40
  autoescape=select_autoescape([]),
40
41
  trim_blocks=True,
41
42
  extensions=["jinja2.ext.do"] # This enables {% do %}
@@ -166,6 +167,28 @@ class JinjaGenPydantic(object):
166
167
  # None -> null, integer -> number, else ->
167
168
  return ret_val
168
169
 
170
+ def _get_schema_types(schema: dict, name: str = "") -> List[str]:
171
+ """Template helper to return the reference type from teh schema."""
172
+ t_list = [f'{name}'] if name else []
173
+ for _, prop in schema['properties'].items():
174
+ if "type" in prop:
175
+ if prop["type"].find('$ref') == 0:
176
+ t_list.append(f'{prop["$ref"].split("/")[-1]}[]')
177
+ elif prop["type"] == "array" and "items" in prop:
178
+ if type(prop["items"]) == dict and '$ref' in prop["items"]:
179
+ t_list.append(JinjaGenPydantic._get_field_type(prop["items"])[:-5] + '[]')
180
+ elif "anyOf" in prop:
181
+ for option in prop["anyOf"]:
182
+ if "$ref" in option:
183
+ t_name = f'{option["$ref"].split("/")[-1]}'
184
+ if 'enum' not in schema['$defs'][t_name]:
185
+ t_list.append(t_name)
186
+ elif '$ref' in prop:
187
+ t_name = f'{prop["$ref"].split("/")[-1]}'
188
+ if 'enum' not in schema['$defs'][t_name]:
189
+ t_list.append(t_name)
190
+ return set(t_list)
191
+
169
192
  def _is_field_enum(prop: dict | str, schema: dict) -> bool:
170
193
  "Templat helper function to "
171
194
  ret_val = False
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scjson
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: A JSON-based serialization of SCXML (State Chart XML) for modern tooling, interoperability, and education.
5
5
  Author-email: Ira Abbott <ira@mycloud.blue>
6
6
  License: BSD-1-Clause
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