json-model-compiler 2.0.63__tar.gz → 2.0.64__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.
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/BACKLOG.md +2 -16
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/BENCH.md +13 -3
- {json_model_compiler-2.0.63/json_model_compiler.egg-info → json_model_compiler-2.0.64}/PKG-INFO +1 -1
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/SPEC.md +28 -7
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/VERSION.md +24 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/bench.sh +19 -10
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/analyze.py +4 -1
- json_model_compiler-2.0.64/json_model/data/VERSION +1 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/model.py +210 -43
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/recurse.py +7 -2
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64/json_model_compiler.egg-info}/PKG-INFO +1 -1
- json_model_compiler-2.0.63/json_model/data/VERSION +0 -1
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/.github/workflows/docs.yml +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/.github/workflows/sanity.yml +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/.gitignore +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/.gitmodules +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/API.md +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/COMP.md +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/DESIGN.md +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/DEV.md +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/DOC.md +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/HOWTO.md +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/INTEGRATION.md +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/MANIFEST.in +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/Makefile +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/PUBS.md +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/README.md +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/TUTO.md +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/about.sh +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/README.md +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/__init__.py +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/clang.py +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/convert.py +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/data/clang_entry.c +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/data/clang_free.c +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/data/clang_init.c +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/data/clang_pcre2_fun.c +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/data/clang_re2_fun.c +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/data/java_free.java +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/data/java_init.java +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/data/javascript_exe.js +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/data/javascript_foot.js +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/data/javascript_free.js +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/data/javascript_head.js +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/data/javascript_init.js +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/data/javascript_main.js +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/data/jmc.pod +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/data/perl_entry.pl +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/data/perl_exe.pl +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/data/perl_free.pl +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/data/perl_init.pl +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/data/perl_main.pl +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/data/perl_pkg.pl +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/data/plpgsql_entry.sql +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/data/python_entry.py +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/data/python_exe.py +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/data/python_free.py +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/data/python_init.py +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/data/python_main.py +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/export.py +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/irep.py +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/iroptim.py +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/java.py +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/javascript.py +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/language.py +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/mtypes.py +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/objops.py +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/optim.py +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/perl.py +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/plpgsql.py +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/predefs.py +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/python.py +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/regex.py +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/resolver.py +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/Makefile +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/__init__.py +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/c/Makefile +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/c/json-model.c +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/c/json-model.h +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/c/main.c +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/java/.gitignore +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/java/Makefile +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/java/README.md +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/java/env.sh +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/java/json_model/Checker.java +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/java/json_model/GSON.java +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/java/json_model/JSON.java +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/java/json_model/JSONP.java +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/java/json_model/Jackson.java +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/java/json_model/Main.java +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/java/json_model/ModelChecker.java +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/java/json_model/Path.java +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/java/json_model/Report.java +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/java/json_model/Runtime.java +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/java/pom.xml +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/js/README.md +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/js/index.js +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/js/main.js +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/js/package.json +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/pl/.gitignore +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/pl/Changes +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/pl/LICENSE +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/pl/MANIFEST +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/pl/Makefile.PL +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/pl/README +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/pl/env.sh +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/pl/ignore.txt +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/pl/lib/JSON/JsonModel.pm +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/pl/t/00-load.t +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/pl/t/manifest.t +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/pl/t/pod-coverage.t +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/pl/t/pod.t +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/pl/xt/boilerplate.t +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/sql/META.json +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/sql/Makefile +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/sql/json_model--2.0.sql +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/sql/json_model.control +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/support.py +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/types.py +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/script.py +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/submodel.py +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/ts_export.py +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/url_cache.py +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/utils.py +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/xstatic.py +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model_compiler.egg-info/SOURCES.txt +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model_compiler.egg-info/dependency_links.txt +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model_compiler.egg-info/entry_points.txt +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model_compiler.egg-info/not-zip-safe +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model_compiler.egg-info/requires.txt +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model_compiler.egg-info/top_level.txt +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/package.json +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/pyproject.toml +0 -0
- {json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/setup.cfg +0 -0
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
## Current Tasks
|
|
4
4
|
|
|
5
|
+
- [ ] models: add for openapi overlay spec, json patch and others
|
|
5
6
|
- [ ] java-runtime: consider automatic updates?
|
|
6
|
-
- [ ] bench: re-build corvus image automatically
|
|
7
|
-
- [ ] bench: run cron bench with corvus (wip)
|
|
8
7
|
- [ ] pr: improve compiler page, list and describe optimizations?
|
|
9
8
|
- [ ] bench: better count should ignore bads
|
|
10
9
|
- [ ] bench: handle case failures for radar (wip, ajv handling)
|
|
@@ -24,7 +23,6 @@
|
|
|
24
23
|
- [ ] front: generate valid minimal, maximal and random values from a model
|
|
25
24
|
- [ ] front: generate invalid minimal values from a model
|
|
26
25
|
- [ ] optim: collect and display stats about what works
|
|
27
|
-
- [ ] spec: allow to _remove_ definitions, eg `{ "$stuff": {"/": "$foo"}}`
|
|
28
26
|
- [ ] spec: restrict regex syntax to a smaller subset
|
|
29
27
|
- [ ] perf: drop and/or merge identical results when comparing
|
|
30
28
|
- [ ] backend: check `mv-34/mu` test case which may require some utf normalization
|
|
@@ -52,7 +50,6 @@
|
|
|
52
50
|
- [ ] predefs: _url_ vs _uri_ vs _iri_
|
|
53
51
|
- [ ] predefs: improve `$URI` and `$URL`
|
|
54
52
|
- [ ] predefs: add `$SIMPLE_REGEX` for regex syntax subset?
|
|
55
|
-
- [ ] docker: enable user remap
|
|
56
53
|
- [ ] export: java classes
|
|
57
54
|
- [ ] export: go interfaces
|
|
58
55
|
- [ ] export: ts interfaces
|
|
@@ -113,19 +110,8 @@
|
|
|
113
110
|
- [ ] predefs: add country codes, eg `$COUNTRY $COUNTRY2 $COUNTRY3 $COUNTRYN`
|
|
114
111
|
- [ ] spec: be precise about predefs standard references, eg `$DATE` and co.
|
|
115
112
|
|
|
116
|
-
## Internship
|
|
113
|
+
## Internship Ideas
|
|
117
114
|
|
|
118
|
-
- [x] pr: read www, papers, spec… setup dev env, report issues
|
|
119
|
-
- [x] pr: try tutorial, report issues and suggest improvements
|
|
120
|
-
- [x] tests: add a few tests for jsonrpc model
|
|
121
|
-
- [x] model: write a model for MCP
|
|
122
|
-
- [x] tests: add a few tests for MCP model
|
|
123
|
-
- [x] export: generate ts interfaces
|
|
124
|
-
- [x] model: fix IR model and tests
|
|
125
|
-
- [x] front: IR re-entrance
|
|
126
|
-
- [ ] tests: generate valid (pseudo-random) values
|
|
127
|
-
- [ ] tests: generate invalid minimal, maximal, pseudo-random values
|
|
128
|
-
- [ ] tests: generate invalid values on each constraint
|
|
129
115
|
- [ ] backend: C and runtime with json-c (\*, but beware of runtime integration)
|
|
130
116
|
- [ ] backend: C# (\*\*)
|
|
131
117
|
- [ ] backend: go (\*\*\*)
|
|
@@ -60,14 +60,16 @@ differences in the validated results, in which case they are manually
|
|
|
60
60
|
validated and discussed.
|
|
61
61
|
|
|
62
62
|
- Performance elapsed times for each test are collected over a loop to compute
|
|
63
|
-
an average and standard deviation.
|
|
64
|
-
such as JIT compilation, GC runs and
|
|
63
|
+
an average and standard deviation.
|
|
64
|
+
The repetition also intends to catch hidden costs such as JIT compilation, GC runs and
|
|
65
|
+
lazy initializations, amortized over the loop and tests, typically _1,000,000_ validations
|
|
66
|
+
for a _1000_ iteration loop over _1000_ test values.
|
|
65
67
|
- Several independent runs are performed to reduce host load effects.
|
|
66
68
|
- Compilation times and performance times are the _median_ encountered over the runs.
|
|
67
69
|
- Runs are usually performed in _fast_ mode: the rejection reasons are not collected,
|
|
68
70
|
and the run stops as soon as possible.
|
|
69
71
|
- The benchmark presents relative comparison ratios to smooth out the wide range of
|
|
70
|
-
collected performances (from 10 ns to over 300 µs for validating one value).
|
|
72
|
+
collected performances (from 10 ns to over 300 µs for validating one test value).
|
|
71
73
|
|
|
72
74
|
Note that performance figures **must** be taken with a pinch of salt, please consider
|
|
73
75
|
the following caveats, and others:
|
|
@@ -84,6 +86,14 @@ the following caveats, and others:
|
|
|
84
86
|
so it is often disabled.
|
|
85
87
|
- The measure overhead is estimated and deduced from the performance figures by default,
|
|
86
88
|
which leads to potentially fuzzy results when testing very small values.
|
|
89
|
+
- Parsing is not taken into account:
|
|
90
|
+
From a user perspective, the combined time for parsing or building, checking, and
|
|
91
|
+
using or serializing makes more sense.
|
|
92
|
+
From our tool perspective, it is built around external representations, and
|
|
93
|
+
aims at being _inserted_ into existing code, without changing the underlying
|
|
94
|
+
JSON libraries, so the validation is the only new overhead to consider.
|
|
95
|
+
For other tools which force using their own representation (eg Blaze or Corvus C#)
|
|
96
|
+
and may imply conversion costs, an end-to-end measure seems more appropriate.
|
|
87
97
|
- Compilers, libraries and other design and updates can have dramatic effects:
|
|
88
98
|
for faster parsing, a library may use linked-list for properties, which means
|
|
89
99
|
that retrieving a given property value will cost more than a library which uses
|
|
@@ -460,7 +460,7 @@ Implementation should detect external reference cycles which are errors and shou
|
|
|
460
460
|
|
|
461
461
|
## (EXPERIMENTAL) Model Transformations
|
|
462
462
|
|
|
463
|
-
Symbol `%` at the root of the model defines a model transformation object, which
|
|
463
|
+
Symbol `%` at the root of the model defines a global model transformation object, which
|
|
464
464
|
may include symbol renamings, model importations and model editions.
|
|
465
465
|
|
|
466
466
|
- **Symbol Names**
|
|
@@ -506,8 +506,8 @@ may include symbol renamings, model importations and model editions.
|
|
|
506
506
|
|
|
507
507
|
Model editions are specified with properties which are references possibly followed
|
|
508
508
|
by a JSON path, allowing to point to a JSON element in the model, and either a value
|
|
509
|
-
with special properties `/ *` to remove or add sub elements,
|
|
510
|
-
taken as-is, but which must not be an object with any of the special properties.
|
|
509
|
+
with special properties `/ *` to remove or add sub elements, `:` to rename properties.
|
|
510
|
+
Anything else taken as-is, but which must not be an object with any of the special properties.
|
|
511
511
|
|
|
512
512
|
- Addition/replacement on a `"$External#name"` reference to a definition:
|
|
513
513
|
- a non-existing definition is added to available definitions _in the target scope_.
|
|
@@ -515,29 +515,50 @@ may include symbol renamings, model importations and model editions.
|
|
|
515
515
|
- Edition on a `"$External#name.foo.0"`: the target element **must** exist.
|
|
516
516
|
The `.foo.0` path instructs to select the first element (index _0_) of
|
|
517
517
|
the array value of property _foo_ inside definition _name_.
|
|
518
|
+
- Rename on "$External:name.foo.0": the target element **must** exist and be an object.
|
|
518
519
|
|
|
519
520
|
The following edition rules apply, in order, depending on the type of the target element:
|
|
520
521
|
|
|
521
|
-
- if the transformation value is an edition object (ie include at least one `/
|
|
522
|
+
- if the transformation value is an edition object (ie include at least one `/ * ~` property):
|
|
522
523
|
- if the target is a JSON object (not necessarily a model for an object):
|
|
523
524
|
- `/` value may be a string or a list of strings.
|
|
524
525
|
All properties of these names are removed.
|
|
525
526
|
If a property does not exist, this is an error and must be rejected.
|
|
526
|
-
- `*` value
|
|
527
|
-
If
|
|
527
|
+
- `*` value may be an objecti or list
|
|
528
|
+
If the value is an obhect, it is merged into the target object.
|
|
529
|
+
If a property already exists, this is an error and must be rejected.
|
|
530
|
+
If the value is a list, keep only the listed properties, others are discarded.
|
|
531
|
+
- `~` value must be an object, which is a string mapping to rename properties
|
|
532
|
+
in the target object. All renamed properties **must** exists.
|
|
533
|
+
Specifying `{"?a": "b", "?b": "a"}` exchanges optional property values and makes them mandatory.
|
|
534
|
+
As a special case, `{"!": "?"}` and `{"?": "!"}` are bulk changes to downgrade
|
|
535
|
+
mandatory properties to optional, or upgrade optional properties to mandatory.
|
|
528
536
|
- if the target is a JSON array (not necessarily a model for an array):
|
|
529
537
|
- `/`: may be value or a list of values.
|
|
530
538
|
Array items equal to these values are removed.
|
|
531
539
|
If a value is not found, this is an error and must be rejected.
|
|
532
540
|
- `*`: if the value is an array, append its items to the target array.
|
|
533
|
-
|
|
541
|
+
If the value is something else, appends to the array.
|
|
542
|
+
- `~`: currently invalid
|
|
534
543
|
- if the target is a JSON scalar: this is an error and must be rejected.
|
|
535
544
|
- if the transformation value is a model (i.e. an object without any `/ *` property),
|
|
536
545
|
the target value is _replaced_ by this value, in place.
|
|
537
546
|
|
|
547
|
+
Moreover, operations can also apply on model definitions when the path ends with `#` and
|
|
548
|
+
must designate a _head_ model, not a submodel:
|
|
549
|
+
|
|
550
|
+
- `/`: remove one (scalar) or several (array) definitions
|
|
551
|
+
- `*`: add or override definitions
|
|
552
|
+
- `~`: Rename, and possibly override, existing definitions
|
|
553
|
+
|
|
538
554
|
These additions and editions are performed _after_ property renamings and imports,
|
|
539
555
|
and _before_ merge pre-processing.
|
|
540
556
|
|
|
557
|
+
Symbols `<`, `/`, `*`, `~` inside a _definition_ define a local transformation.
|
|
558
|
+
|
|
559
|
+
- `<` must be a local reference `$name`, the target model is **copied** inside the definition.
|
|
560
|
+
- `/`, `*` and `~` define local editions inside the definition, as describe above.
|
|
561
|
+
|
|
541
562
|
What is the _right_ balance between features, syntax and ease-of-use for a type transformation
|
|
542
563
|
language is an on-going investigation: should it allow renaming, moving or copying attributes?
|
|
543
564
|
Should it allow to remove definitions? Should imports allow to define a namespace?
|
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# JSON Model Compiler Versions
|
|
2
2
|
|
|
3
|
+
## 2.0.64 on 2026-10-26
|
|
4
|
+
|
|
5
|
+
- bench: do not link same version and message artifacts, keep first encountered
|
|
6
|
+
- bench: move corvus at then end of the radar to keep colors consistent
|
|
7
|
+
- bench: run cron bench with corvus
|
|
8
|
+
- bench: re-build corvus image automatically
|
|
9
|
+
- model: transformation rename properties with `~` (experimental)
|
|
10
|
+
- model: transformation make work on import? checked!
|
|
11
|
+
- model: allow to edit definitions (namespace `$foo#`) with transformations
|
|
12
|
+
- models: add `:` trafo to json model meta model
|
|
13
|
+
- models: add diff model from v1 to v2
|
|
14
|
+
- bench: work around cal dns issues
|
|
15
|
+
- bench: fix missing jmc on cron job
|
|
16
|
+
- bench: improve report section title about classification metrics
|
|
17
|
+
- docker: enable user remap (for a long time?)
|
|
18
|
+
- models: add OpenAPI-with-models alternative model
|
|
19
|
+
- model: fix definition cross renames
|
|
20
|
+
- model: add local transformations
|
|
21
|
+
- model: add keep-only transformation
|
|
22
|
+
- model: allow bulk mandatory to optional and optional to mandatory renames
|
|
23
|
+
- model: fix model internals when adding definitions with a namespace trafo
|
|
24
|
+
- models: add json schema draft 03 diff model
|
|
25
|
+
- model: move local transformations _after_ global transformations
|
|
26
|
+
|
|
3
27
|
## 2.0.63 on 2026-10-05
|
|
4
28
|
|
|
5
29
|
- pr: center logo in sidebar
|
|
@@ -20,29 +20,38 @@ get_version()
|
|
|
20
20
|
sed -ne '1,/BENCHES/p' < BENCH.md | grep -v '^BENCHES$'
|
|
21
21
|
|
|
22
22
|
# list max 10 latest artifacts
|
|
23
|
-
nartifacts=0
|
|
23
|
+
nartifacts=0 p_jsu= p_jmc= p_sbc= p_crv= p_msg=
|
|
24
24
|
|
|
25
25
|
for artifact in $(ls site/benchmarks/*.md | sort -r) ; do
|
|
26
|
-
let nartifacts+=1
|
|
27
26
|
|
|
28
|
-
link=${artifact#site/}
|
|
29
|
-
name=${link#benchmarks/}
|
|
30
|
-
name=${name%.md}
|
|
31
27
|
jsu=$(get_version jsu $artifact)
|
|
32
28
|
jmc=$(get_version jmc $artifact)
|
|
33
29
|
sbc=$(get_version jsonschema-cli $artifact)
|
|
34
30
|
crv=$(get_version corvus-cli $artifact)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
[ "$(grep '
|
|
38
|
-
[ "$(grep '
|
|
31
|
+
|
|
32
|
+
msg=""
|
|
33
|
+
[ "$(grep 'content:.*yes' $artifact)" ] && msg+="content" || msg+="no content"
|
|
34
|
+
[ "$(grep 'JSU_OPT.*--no-id' $artifact)" ] && msg+=", no id" || msg+=", id"
|
|
35
|
+
[ "$(grep 'fix:.*yes' $artifact)" ] && msg+=", fix" || msg+=", no fix"
|
|
36
|
+
|
|
37
|
+
# skip same version (details may differ, keep first encountered)
|
|
38
|
+
[ "$jsu" = "$p_jsu" -a "$jmc" = "$p_jmc" -a \
|
|
39
|
+
"$sbc" = "$p_sbc" -a "$crv" = "$p_crv" -a "$msg" = "$p_msg" ] && continue
|
|
40
|
+
|
|
41
|
+
p_jsu=$jsu p_jmc=$jmc p_sbc=$sbc p_crv=$crv p_msg=$msg
|
|
42
|
+
|
|
43
|
+
link=${artifact#site/}
|
|
44
|
+
name=${link#benchmarks/}
|
|
45
|
+
name=${name%.md}
|
|
46
|
+
|
|
39
47
|
echo "- Artifact [$name]($link) using"
|
|
40
48
|
echo " [JMC $jmc]($PYPI/json-model-compiler/$jmc/), "
|
|
41
49
|
echo " [JSU $jsu]($PYPI/json-schema-utils/$jsu/), "
|
|
42
50
|
[ "$sbc" ] && echo " [SBC $sbc](https://github.com/sourcemeta/jsonschema/releases/tag/v$sbc),"
|
|
43
51
|
[ "$crv" ] && echo " [Corvus $crv](https://corvus-oss.org/Corvus.JsonSchema/),"
|
|
44
|
-
echo " $
|
|
52
|
+
echo " $msg."
|
|
45
53
|
|
|
54
|
+
let nartifacts+=1
|
|
46
55
|
[ $nartifacts -eq $MAX ] && break
|
|
47
56
|
done
|
|
48
57
|
|
|
@@ -60,7 +60,7 @@ def check(jm: JsonModel, assertion: ModelFilter, what: str = "?", short: bool =
|
|
|
60
60
|
okay = False
|
|
61
61
|
return okay if short else True
|
|
62
62
|
|
|
63
|
-
recModel(jm._model, checkFlt, noRwt, True)
|
|
63
|
+
recModel(jm._model, checkFlt, noRwt, True, jm._is_root)
|
|
64
64
|
|
|
65
65
|
return okay
|
|
66
66
|
|
|
@@ -83,6 +83,9 @@ def valid(jm: JsonModel,
|
|
|
83
83
|
ARR_KW = {"!"}
|
|
84
84
|
OP_KW = {"@", "|", "&", "^", "+"}
|
|
85
85
|
|
|
86
|
+
# trafo are applied before checking model validity, thus out of scope
|
|
87
|
+
# TRAFO_KW = {"/", "*", "~"}
|
|
88
|
+
|
|
86
89
|
if extend: # multiple-of: number, contains: model
|
|
87
90
|
CMP_KW |= {".mo"}
|
|
88
91
|
ARR_KW |= {".in"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.0.64
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import copy
|
|
2
|
-
import re
|
|
3
2
|
import typing
|
|
3
|
+
import re
|
|
4
4
|
from collections.abc import MutableMapping
|
|
5
5
|
import json
|
|
6
6
|
|
|
@@ -99,8 +99,9 @@ class JsonModel:
|
|
|
99
99
|
ROOT_KW = ["$", "%", "~"]
|
|
100
100
|
SCAL_KW = ["@"]
|
|
101
101
|
CONS_KW = ["!", "#", "<", "<=", ">", ">=", "=", "!="]
|
|
102
|
-
TRAN_KW = ["*", "/"]
|
|
102
|
+
TRAN_KW = ["*", "/", "~"]
|
|
103
103
|
KEYWORDS = LIST_KW + ROOT_KW + SCAL_KW + CONS_KW + TRAN_KW
|
|
104
|
+
LTRA_KW = {"#", "<", "%"} | set(TRAN_KW)
|
|
104
105
|
|
|
105
106
|
# sentinel characters
|
|
106
107
|
# $: reference
|
|
@@ -177,9 +178,9 @@ class JsonModel:
|
|
|
177
178
|
self._single_line = single_line
|
|
178
179
|
|
|
179
180
|
# copy parameter which may be modified
|
|
180
|
-
model = self.noComment(copy.deepcopy(model))
|
|
181
|
+
model = self.noComment(copy.deepcopy(model), root=self._is_root)
|
|
181
182
|
|
|
182
|
-
# %: names and rewrites
|
|
183
|
+
# %: import, names and rewrites
|
|
183
184
|
self._init_pc: dict[str, ModelType] = {}
|
|
184
185
|
self._name: ModelRename = {}
|
|
185
186
|
self._rewrite: dict[str, ModelTrafo] = {}
|
|
@@ -245,7 +246,7 @@ class JsonModel:
|
|
|
245
246
|
}
|
|
246
247
|
|
|
247
248
|
# FIXME what is the scope of renamings, eg wrt references?
|
|
248
|
-
model = self.rename(model, [], True)
|
|
249
|
+
model = self.rename(model, self._name, [], True)
|
|
249
250
|
assert isinstance(model, dict)
|
|
250
251
|
|
|
251
252
|
# reference imports
|
|
@@ -259,7 +260,7 @@ class JsonModel:
|
|
|
259
260
|
self._imports = imports # type: ignore
|
|
260
261
|
|
|
261
262
|
# extract rewrites
|
|
262
|
-
# TODO check
|
|
263
|
+
# TODO check reference syntax? $Path#To#Def.path.to.prop
|
|
263
264
|
self._rewrite = {
|
|
264
265
|
name: rw
|
|
265
266
|
for name, rw in model_pc.items()
|
|
@@ -289,7 +290,8 @@ class JsonModel:
|
|
|
289
290
|
if self._url != "" and u != self._url:
|
|
290
291
|
log.info(f"inconsistent url identifier: {u}")
|
|
291
292
|
self._url = u # override
|
|
292
|
-
# TODO restrict names
|
|
293
|
+
# TODO restrict names
|
|
294
|
+
|
|
293
295
|
# extract actual definitions
|
|
294
296
|
self._defs.update({
|
|
295
297
|
n: JsonModel(m, resolver, url=self._url + "#" + n,
|
|
@@ -299,19 +301,21 @@ class JsonModel:
|
|
|
299
301
|
for n, m in dollar.items()
|
|
300
302
|
if isinstance(n, str) and n not in ("#", "")
|
|
301
303
|
})
|
|
304
|
+
|
|
302
305
|
# warn about possibly missing $
|
|
303
306
|
for name, value in self._defs.items():
|
|
304
307
|
m = value._model
|
|
305
308
|
if isinstance(m, str) and re.search("^((https?|file)://|\\.)", m):
|
|
306
309
|
log.warning(f"url-looking {name}: "
|
|
307
310
|
"add missing $ or prefix with _ for string constants")
|
|
311
|
+
|
|
308
312
|
# keep initial definitions
|
|
309
313
|
self._init_dl = dollar
|
|
310
314
|
else:
|
|
311
315
|
self._init_dl = None
|
|
312
316
|
|
|
313
|
-
|
|
314
|
-
|
|
317
|
+
# ~ at root is the meta model
|
|
318
|
+
if isinstance(model, dict) and "~" in model and self._is_root:
|
|
315
319
|
version = model["~"]
|
|
316
320
|
del model["~"]
|
|
317
321
|
# FIXME should accept a *model*, not just a URL? or not?
|
|
@@ -325,7 +329,7 @@ class JsonModel:
|
|
|
325
329
|
else:
|
|
326
330
|
self._spec = self
|
|
327
331
|
log.info(f"renaming {self._id} from ~")
|
|
328
|
-
model = self._spec.rename(model, [], True)
|
|
332
|
+
model = self._spec.rename(model, self._spec._name, ["~", "%"], True)
|
|
329
333
|
else:
|
|
330
334
|
# FIXME add a default?
|
|
331
335
|
self._spec = None
|
|
@@ -352,7 +356,12 @@ class JsonModel:
|
|
|
352
356
|
if self._is_root:
|
|
353
357
|
# loading twice, rewriting may add references…
|
|
354
358
|
self.allLoads()
|
|
355
|
-
self.rewrite()
|
|
359
|
+
self.rewrite(self._rewrite)
|
|
360
|
+
|
|
361
|
+
# apply local trafo copies late, some definitions may have been added by rewrite
|
|
362
|
+
for name, jm in self._defs.items():
|
|
363
|
+
if jm._isLocalTrafo():
|
|
364
|
+
self._localTrafo(jm, ["$", name])
|
|
356
365
|
|
|
357
366
|
if self._is_head:
|
|
358
367
|
# hmmm… the above rewriting may have changed external dependencies,
|
|
@@ -386,6 +395,33 @@ class JsonModel:
|
|
|
386
395
|
|
|
387
396
|
self._model = recModel(self._model, allFlt, rwtRegex, keys=True)
|
|
388
397
|
|
|
398
|
+
def _isLocalTrafo(self):
|
|
399
|
+
return (
|
|
400
|
+
isinstance(self._model, dict) and
|
|
401
|
+
self._model.keys() & self.LTRA_KW and
|
|
402
|
+
"@" not in self._model # avoid constraint models
|
|
403
|
+
)
|
|
404
|
+
|
|
405
|
+
def _localTrafo(self, jm: JsonModel, names: list[str]):
|
|
406
|
+
trafo = jm._model
|
|
407
|
+
# log.debug(f"trafo = {trafo}")
|
|
408
|
+
if scopy := trafo.get("<"):
|
|
409
|
+
del trafo["<"]
|
|
410
|
+
assert isinstance(scopy, str) and scopy and scopy[0] == "$"
|
|
411
|
+
ncopy = scopy[1:]
|
|
412
|
+
assert ncopy not in names, f"local transformation cycle: {ncopy} {names}"
|
|
413
|
+
assert ncopy in self._defs, f"local definition copy must exist: {ncopy}"
|
|
414
|
+
jmc = self._defs[ncopy]
|
|
415
|
+
if jmc._isLocalTrafo():
|
|
416
|
+
# recursion to handle misordering
|
|
417
|
+
self._localTrafo(jmc, names + [ncopy])
|
|
418
|
+
jm._model = copy.deepcopy(self._defs[ncopy]._model)
|
|
419
|
+
if "#" in trafo:
|
|
420
|
+
jm._model["#"] = trafo["#"]
|
|
421
|
+
del trafo["#"]
|
|
422
|
+
log.info(f"{jm._id} copied as {jm._model}")
|
|
423
|
+
jm._applyTrafo(jm._model, trafo, names)
|
|
424
|
+
|
|
389
425
|
def load(self, url: str, path: ModelPath, is_head: bool = False) -> JsonModel:
|
|
390
426
|
"""Retrieve external JSON Model for a URL."""
|
|
391
427
|
log.debug(f"{self._id}: getting {url} at {path}")
|
|
@@ -533,7 +569,7 @@ class JsonModel:
|
|
|
533
569
|
kept = " ".join(str(mid) for mid in sorted(keep))
|
|
534
570
|
log.debug(f"{self._id}: unload {len(self._models)}/{total} models kept ({kept})")
|
|
535
571
|
|
|
536
|
-
def noComment(self, model: ModelType):
|
|
572
|
+
def noComment(self, model: ModelType, root: bool = True):
|
|
537
573
|
"""Remove non trivial comments."""
|
|
538
574
|
|
|
539
575
|
def rmComments(m: ModelType, p: ModelPath):
|
|
@@ -547,7 +583,7 @@ class JsonModel:
|
|
|
547
583
|
else:
|
|
548
584
|
return m
|
|
549
585
|
|
|
550
|
-
return recModel(model, allFlt, rmComments)
|
|
586
|
+
return recModel(model, allFlt, rmComments, root=root)
|
|
551
587
|
|
|
552
588
|
#
|
|
553
589
|
# Display
|
|
@@ -934,16 +970,19 @@ class JsonModel:
|
|
|
934
970
|
self._defs.gset(m, m)
|
|
935
971
|
return m
|
|
936
972
|
|
|
937
|
-
self._model = recModel(self._model, allFlt, globRwt, True)
|
|
973
|
+
self._model = recModel(self._model, allFlt, globRwt, True, self._is_root)
|
|
938
974
|
|
|
939
975
|
#
|
|
940
|
-
# Rename
|
|
976
|
+
# Rename Transformation
|
|
941
977
|
#
|
|
942
|
-
def rename(self,
|
|
978
|
+
def rename(self,
|
|
979
|
+
model: ModelType, names: dict[str, str],
|
|
980
|
+
path: ModelPath = [], root: bool = False
|
|
981
|
+
) -> ModelType:
|
|
943
982
|
"""Apply keyword renaming."""
|
|
944
983
|
|
|
945
984
|
# FIXME should check that all are ".…" are replaced?!
|
|
946
|
-
if root and not
|
|
985
|
+
if root and not names:
|
|
947
986
|
return model
|
|
948
987
|
|
|
949
988
|
def rnFlt(m: ModelType, path: ModelPath) -> bool:
|
|
@@ -951,8 +990,8 @@ class JsonModel:
|
|
|
951
990
|
remove, added = set(), {}
|
|
952
991
|
for k, v in m.items():
|
|
953
992
|
assert isinstance(k, str)
|
|
954
|
-
if k in
|
|
955
|
-
added[
|
|
993
|
+
if k in names:
|
|
994
|
+
added[names[k]] = v
|
|
956
995
|
remove.add(k)
|
|
957
996
|
for k in remove:
|
|
958
997
|
del m[k]
|
|
@@ -964,6 +1003,9 @@ class JsonModel:
|
|
|
964
1003
|
|
|
965
1004
|
return recModel(model, rnFlt, noRwt)
|
|
966
1005
|
|
|
1006
|
+
#
|
|
1007
|
+
# Rewrite Transformations
|
|
1008
|
+
#
|
|
967
1009
|
# FIXME parsing should conform to JSON Path
|
|
968
1010
|
# TODO think transformation path spec
|
|
969
1011
|
def _parsePath(self, tpath: str, path: ModelPath) -> tuple[JsonModel, ModelPath]:
|
|
@@ -971,6 +1013,8 @@ class JsonModel:
|
|
|
971
1013
|
if self._debug:
|
|
972
1014
|
log.debug(f"{self._id}: parsePath at {path}: {tpath}")
|
|
973
1015
|
assert tpath and tpath[0] == "$", f"tpath must be a reference: {tpath}"
|
|
1016
|
+
if tpath == "$" or tpath == "$#":
|
|
1017
|
+
return self, []
|
|
974
1018
|
if "." in tpath:
|
|
975
1019
|
name, jpath = tpath.split(".", 1)
|
|
976
1020
|
if jpath == "":
|
|
@@ -980,17 +1024,18 @@ class JsonModel:
|
|
|
980
1024
|
name, xpath = tpath, []
|
|
981
1025
|
log.debug(f"{self._id}: parsePath name={name} xpath={xpath}")
|
|
982
1026
|
jm = self.resolveRef(name, path, True)
|
|
1027
|
+
log.debug(f"{self._id}: {name} resolved to {jm._id}")
|
|
983
1028
|
return (jm, xpath)
|
|
984
1029
|
|
|
985
1030
|
def _isTrafo(self, trafo: ModelTrafo):
|
|
986
|
-
|
|
1031
|
+
"""Tell whether trafo is a transformation object."""
|
|
1032
|
+
return isinstance(trafo, dict) and set(trafo.keys()).issubset({"#", "/", "*", "~"})
|
|
987
1033
|
|
|
988
1034
|
def _applyTrafo(self, j: Jsonable, trafo: ModelTrafo, path: ModelPath):
|
|
989
1035
|
"""Apply this transformation on j."""
|
|
990
1036
|
|
|
991
|
-
if not
|
|
1037
|
+
if not self._isTrafo(trafo):
|
|
992
1038
|
return trafo
|
|
993
|
-
assert self._isTrafo(trafo)
|
|
994
1039
|
assert isinstance(trafo, dict) # pyright hint
|
|
995
1040
|
if self._debug:
|
|
996
1041
|
log.debug(f"{self._id}: applyTrafo trafo={trafo} on j={j} [{path}]")
|
|
@@ -1020,7 +1065,15 @@ class JsonModel:
|
|
|
1020
1065
|
add = trafo["*"]
|
|
1021
1066
|
if isinstance(add, list):
|
|
1022
1067
|
if isinstance(j, list):
|
|
1068
|
+
# append new items to list
|
|
1023
1069
|
j.extend(add)
|
|
1070
|
+
elif isinstance(j, dict):
|
|
1071
|
+
# keep only those props, as well as comments
|
|
1072
|
+
for prop in list(j.keys()):
|
|
1073
|
+
if prop.startswith("#") or prop in add:
|
|
1074
|
+
pass
|
|
1075
|
+
else:
|
|
1076
|
+
del j[prop]
|
|
1024
1077
|
else:
|
|
1025
1078
|
raise ModelError(f"cannot add list to {tname(j)} at {path}")
|
|
1026
1079
|
elif isinstance(add, dict):
|
|
@@ -1034,30 +1087,75 @@ class JsonModel:
|
|
|
1034
1087
|
else:
|
|
1035
1088
|
raise ModelError(f"unexpected add type at {path}")
|
|
1036
1089
|
|
|
1090
|
+
if "~" in trafo:
|
|
1091
|
+
# log.error(f"trafo ~ on {j}")
|
|
1092
|
+
# rename properties
|
|
1093
|
+
reprop = trafo["~"]
|
|
1094
|
+
if not isinstance(reprop, dict):
|
|
1095
|
+
raise ModelError(f"rename ~ requires an object at {path}")
|
|
1096
|
+
if not all(isinstance(p, str) and isinstance(v, str) for p, v in reprop.items()):
|
|
1097
|
+
raise ModelError(f"rename ~ must be a string map at {path}")
|
|
1098
|
+
|
|
1099
|
+
# bulk changes
|
|
1100
|
+
bulk: bool|None = None
|
|
1101
|
+
if "!" in reprop or "?" in reprop:
|
|
1102
|
+
if "!" in reprop and reprop["!"] != "?":
|
|
1103
|
+
raise ModelError(f"rename ~ special ! value must be ? at {path}")
|
|
1104
|
+
if "?" in reprop and reprop["?"] != "!":
|
|
1105
|
+
raise ModelError(f"rename ~ special ? value must be ! at {path}")
|
|
1106
|
+
if "?" in reprop and "!" in reprop:
|
|
1107
|
+
raise ModelError(f"rename ~ cannot have both ! and ? specials at {path}")
|
|
1108
|
+
bulk = "!" in reprop # True for mandatory -> optional
|
|
1109
|
+
if "!" in reprop:
|
|
1110
|
+
del reprop["!"]
|
|
1111
|
+
if "?" in reprop:
|
|
1112
|
+
del reprop["?"]
|
|
1113
|
+
|
|
1114
|
+
if isinstance(j, dict):
|
|
1115
|
+
if "@" in j:
|
|
1116
|
+
# could it follow @?
|
|
1117
|
+
raise ModelError(f"cannot bulk change a constraint model at {path}")
|
|
1118
|
+
new = {}
|
|
1119
|
+
if bulk is not None:
|
|
1120
|
+
# do bulk changes
|
|
1121
|
+
for p, v in list(j.items()):
|
|
1122
|
+
if p and p[0] not in "$/#~%": # simple prop
|
|
1123
|
+
if bulk and p[0] != "?": # mandatory to optional
|
|
1124
|
+
pn = "?" + (p[1:] if p[0] in "!_" else p)
|
|
1125
|
+
new[pn] = v
|
|
1126
|
+
del j[p]
|
|
1127
|
+
elif not bulk and p[0] == "?": # opt to mandatory
|
|
1128
|
+
pn = p[1:]
|
|
1129
|
+
new[pn] = v
|
|
1130
|
+
del j[p]
|
|
1131
|
+
j.update(**new)
|
|
1132
|
+
new = {}
|
|
1133
|
+
# simple changes
|
|
1134
|
+
for p, v in reprop.items():
|
|
1135
|
+
if p in j:
|
|
1136
|
+
new[v] = j[p]
|
|
1137
|
+
del j[p]
|
|
1138
|
+
else:
|
|
1139
|
+
raise ModelError(f"unexpected property {p} to rename at {path}")
|
|
1140
|
+
j.update(**new)
|
|
1141
|
+
else:
|
|
1142
|
+
raise ModelError(f"unexpected rename type at {path}")
|
|
1143
|
+
|
|
1037
1144
|
return j
|
|
1038
1145
|
|
|
1039
|
-
def
|
|
1040
|
-
|
|
1146
|
+
def _applyModelTrafoAtPath(self,
|
|
1147
|
+
jm: JsonModel,
|
|
1148
|
+
tpath: ModelPath,
|
|
1149
|
+
trafo: ModelTrafo,
|
|
1150
|
+
path: ModelPath,
|
|
1151
|
+
):
|
|
1041
1152
|
"""Apply a transformation into a JSON Model."""
|
|
1042
1153
|
|
|
1043
1154
|
if self._debug:
|
|
1044
|
-
log.debug(f"{jm._id}: trafo at {path}: {tpath}")
|
|
1155
|
+
log.debug(f"{jm._id}: {trafo} at {path}: {tpath}")
|
|
1045
1156
|
|
|
1046
1157
|
j = jm._model
|
|
1047
1158
|
|
|
1048
|
-
# if tpath == ["$"]:
|
|
1049
|
-
# log.warning("TODO add/remove definitions ?!")
|
|
1050
|
-
# if "/" in trafo:
|
|
1051
|
-
# assert isinstance(trafo["/"], list)
|
|
1052
|
-
# for name in trafo["/"]:
|
|
1053
|
-
# assert isinstance(name, str)
|
|
1054
|
-
# if name in jm._defs:
|
|
1055
|
-
# del jm._defs[name]
|
|
1056
|
-
# else:
|
|
1057
|
-
# log.warning(f"cannot remove definition for {name}")
|
|
1058
|
-
# assert "*" not in trafo, f"not implemented yet"
|
|
1059
|
-
# return
|
|
1060
|
-
|
|
1061
1159
|
# follow the JSON path
|
|
1062
1160
|
for i, p in enumerate(tpath):
|
|
1063
1161
|
assert isinstance(j, (list, dict))
|
|
@@ -1082,15 +1180,84 @@ class JsonModel:
|
|
|
1082
1180
|
log.debug(f"{jm._id}: moving forward on p={p}")
|
|
1083
1181
|
j = j[p] # type: ignore
|
|
1084
1182
|
if not tpath:
|
|
1085
|
-
log.debug(f"{jm._id}: empty tpath on {jm._model}")
|
|
1183
|
+
log.debug(f"{jm._id}: empty tpath on {jm._model} for {trafo}")
|
|
1086
1184
|
jm._model = self._applyTrafo(jm._model, trafo, path)
|
|
1087
1185
|
|
|
1088
|
-
def
|
|
1186
|
+
def _applyRootTrafoAtPath(self,
|
|
1187
|
+
jm: JsonModel,
|
|
1188
|
+
tpath: ModelPath,
|
|
1189
|
+
trafo: ModelTrafo,
|
|
1190
|
+
path: ModelPath,
|
|
1191
|
+
):
|
|
1192
|
+
"""Apply a transformation on definitions (namespace)."""
|
|
1193
|
+
if self._debug:
|
|
1194
|
+
log.debug(f"{jm._id}: applying {trafo} at {path}")
|
|
1195
|
+
# log.debug(f"{jm._id}: before defs = {jm._defs}")
|
|
1196
|
+
# sanity
|
|
1197
|
+
if not jm._is_root:
|
|
1198
|
+
raise ModelError(f"expecting a root model at {path}")
|
|
1199
|
+
if not isinstance(trafo, dict):
|
|
1200
|
+
raise ModelError(f"namespace trafo must be a dict at {path}")
|
|
1201
|
+
if tpath:
|
|
1202
|
+
raise ModelError(f"unresolved namespace at {path}")
|
|
1203
|
+
# remove definitions
|
|
1204
|
+
if "/" in trafo:
|
|
1205
|
+
names = trafo["/"]
|
|
1206
|
+
if isinstance(names, str): # scalar case
|
|
1207
|
+
names = [names]
|
|
1208
|
+
if not isinstance(names, list) or not all(isinstance(s, str) for s in names):
|
|
1209
|
+
raise ModelError(f"namespace remove must be a list of names at {path}")
|
|
1210
|
+
for name in names:
|
|
1211
|
+
if name not in jm._defs:
|
|
1212
|
+
raise ModelError(f"missing {name} definition in model {jm._id} at {path}")
|
|
1213
|
+
# FIXME this may not be enough!
|
|
1214
|
+
del jm._defs[name]
|
|
1215
|
+
# add new definitions
|
|
1216
|
+
if "*" in trafo:
|
|
1217
|
+
defs = trafo["*"]
|
|
1218
|
+
if not isinstance(defs, dict):
|
|
1219
|
+
raise ModelError(f"expecting definitions at {path}")
|
|
1220
|
+
for name, model in defs.items():
|
|
1221
|
+
# log.warning(f"{jm._id}: adding {name}")
|
|
1222
|
+
# FIXME this may not be enough!
|
|
1223
|
+
jm._defs[name] = JsonModel(
|
|
1224
|
+
model, jm._resolver, head=jm._head, scope=jm._defs,
|
|
1225
|
+
loose_int=jm._loose_int, loose_float=jm._loose_float,
|
|
1226
|
+
debug=jm._debug, dname=name, single_line=jm._single_line,
|
|
1227
|
+
)
|
|
1228
|
+
# rename definitions
|
|
1229
|
+
if "~" in trafo:
|
|
1230
|
+
renames = trafo["~"]
|
|
1231
|
+
if not isinstance(renames, dict):
|
|
1232
|
+
raise ModelError(f"expecting an object for ~ at {path}")
|
|
1233
|
+
if not all(isinstance(p, str) and isinstance(v, str) for p, v in renames.items()):
|
|
1234
|
+
raise ModelError(f"expecting a string mapping for ~ at {path}")
|
|
1235
|
+
# build update
|
|
1236
|
+
updates = {}
|
|
1237
|
+
for po, pn in renames.items():
|
|
1238
|
+
if po not in self._defs:
|
|
1239
|
+
raise ModelError(f"missing definition {po} at {path}")
|
|
1240
|
+
updates[pn] = self._defs[po]
|
|
1241
|
+
del self._defs[po]
|
|
1242
|
+
self._defs.update(**updates)
|
|
1243
|
+
# log.debug(f"{jm._id}: after defs = {jm._defs}")
|
|
1244
|
+
|
|
1245
|
+
def rewrite(self, rules: dict[str, typing.Any]):
|
|
1089
1246
|
"""Apply model rewriting to current JSON Model."""
|
|
1090
1247
|
|
|
1248
|
+
if self._debug >= 2:
|
|
1249
|
+
log.debug(f"raw model: {self._model} ({self._defs})")
|
|
1250
|
+
|
|
1091
1251
|
# NOTE transformation specs may be empty
|
|
1092
|
-
for tpath, trafo in
|
|
1093
|
-
|
|
1252
|
+
for tpath, trafo in rules.items():
|
|
1253
|
+
log.warning(f"tpath={tpath} trafo={trafo}")
|
|
1254
|
+
lpath = ["%", tpath] # FIXME
|
|
1094
1255
|
# typing issue, cannot assign list[str] to list[str|int] !?
|
|
1095
1256
|
jm, path = self._parsePath(tpath, lpath) # type: ignore
|
|
1096
|
-
|
|
1257
|
+
if tpath.endswith("#"): # model namespace
|
|
1258
|
+
self._applyRootTrafoAtPath(jm, path, trafo, lpath)
|
|
1259
|
+
else:
|
|
1260
|
+
self._applyModelTrafoAtPath(jm, path, trafo, lpath) # type: ignore
|
|
1261
|
+
|
|
1262
|
+
if self._debug >= 2:
|
|
1263
|
+
log.debug(f"edited model: {self._model} ({self._defs})")
|
|
@@ -56,11 +56,16 @@ def _recModel(
|
|
|
56
56
|
if prop == "#":
|
|
57
57
|
assert isinstance(val, str), f"# is a string {lpath}"
|
|
58
58
|
elif prop == "~":
|
|
59
|
-
|
|
59
|
+
if root:
|
|
60
|
+
assert isinstance(val, str), f"~ is a string at root {lpath}"
|
|
61
|
+
else:
|
|
62
|
+
assert isinstance(val, dict) and \
|
|
63
|
+
all(isinstance(k, str) and isinstance(v, str) for k, v in val.items()), \
|
|
64
|
+
f"~ is a string mapping {lpath}"
|
|
60
65
|
elif prop == "!":
|
|
61
66
|
assert isinstance(val, bool), f"! is a bool {lpath}"
|
|
62
67
|
elif prop == "/":
|
|
63
|
-
assert isinstance(val, list), f"/ is a list {lpath}"
|
|
68
|
+
assert isinstance(val, str) or isinstance(val, list), f"/ is a string or list {lpath}"
|
|
64
69
|
continue
|
|
65
70
|
elif prop in MODEL_LIST_KEYWORDS:
|
|
66
71
|
assert isinstance(val, list), f"{prop} is a list {lpath}"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
2.0.63
|
|
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
|
{json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/data/javascript_foot.js
RENAMED
|
File without changes
|
{json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/data/javascript_free.js
RENAMED
|
File without changes
|
{json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/data/javascript_head.js
RENAMED
|
File without changes
|
{json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/data/javascript_init.js
RENAMED
|
File without changes
|
{json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/data/javascript_main.js
RENAMED
|
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
|
{json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/java/.gitignore
RENAMED
|
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
|
{json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/js/package.json
RENAMED
|
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
|
{json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/pl/t/manifest.t
RENAMED
|
File without changes
|
{json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/pl/t/pod-coverage.t
RENAMED
|
File without changes
|
|
File without changes
|
{json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/pl/xt/boilerplate.t
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/sql/json_model--2.0.sql
RENAMED
|
File without changes
|
{json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model/runtime/sql/json_model.control
RENAMED
|
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
|
{json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model_compiler.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model_compiler.egg-info/not-zip-safe
RENAMED
|
File without changes
|
{json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model_compiler.egg-info/requires.txt
RENAMED
|
File without changes
|
{json_model_compiler-2.0.63 → json_model_compiler-2.0.64}/json_model_compiler.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|