json-model-compiler 2.0.64__tar.gz → 2.0.66__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 (134) hide show
  1. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/BACKLOG.md +2 -1
  2. {json_model_compiler-2.0.64/json_model_compiler.egg-info → json_model_compiler-2.0.66}/PKG-INFO +1 -1
  3. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/SPEC.md +119 -83
  4. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/VERSION.md +21 -0
  5. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/about.sh +1 -1
  6. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/analyze.py +4 -0
  7. json_model_compiler-2.0.66/json_model/data/VERSION +1 -0
  8. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/model.py +34 -12
  9. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/resolver.py +4 -2
  10. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/script.py +3 -2
  11. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/url_cache.py +6 -3
  12. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66/json_model_compiler.egg-info}/PKG-INFO +1 -1
  13. json_model_compiler-2.0.64/json_model/data/VERSION +0 -1
  14. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/.github/workflows/docs.yml +0 -0
  15. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/.github/workflows/sanity.yml +0 -0
  16. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/.gitignore +0 -0
  17. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/.gitmodules +0 -0
  18. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/API.md +0 -0
  19. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/BENCH.md +0 -0
  20. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/COMP.md +0 -0
  21. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/DESIGN.md +0 -0
  22. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/DEV.md +0 -0
  23. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/DOC.md +0 -0
  24. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/HOWTO.md +0 -0
  25. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/INTEGRATION.md +0 -0
  26. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/MANIFEST.in +0 -0
  27. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/Makefile +0 -0
  28. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/PUBS.md +0 -0
  29. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/README.md +0 -0
  30. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/TUTO.md +0 -0
  31. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/bench.sh +0 -0
  32. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/README.md +0 -0
  33. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/__init__.py +0 -0
  34. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/clang.py +0 -0
  35. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/convert.py +0 -0
  36. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/data/clang_entry.c +0 -0
  37. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/data/clang_free.c +0 -0
  38. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/data/clang_init.c +0 -0
  39. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/data/clang_pcre2_fun.c +0 -0
  40. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/data/clang_re2_fun.c +0 -0
  41. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/data/java_free.java +0 -0
  42. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/data/java_init.java +0 -0
  43. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/data/javascript_exe.js +0 -0
  44. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/data/javascript_foot.js +0 -0
  45. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/data/javascript_free.js +0 -0
  46. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/data/javascript_head.js +0 -0
  47. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/data/javascript_init.js +0 -0
  48. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/data/javascript_main.js +0 -0
  49. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/data/jmc.pod +0 -0
  50. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/data/perl_entry.pl +0 -0
  51. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/data/perl_exe.pl +0 -0
  52. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/data/perl_free.pl +0 -0
  53. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/data/perl_init.pl +0 -0
  54. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/data/perl_main.pl +0 -0
  55. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/data/perl_pkg.pl +0 -0
  56. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/data/plpgsql_entry.sql +0 -0
  57. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/data/python_entry.py +0 -0
  58. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/data/python_exe.py +0 -0
  59. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/data/python_free.py +0 -0
  60. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/data/python_init.py +0 -0
  61. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/data/python_main.py +0 -0
  62. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/export.py +0 -0
  63. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/irep.py +0 -0
  64. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/iroptim.py +0 -0
  65. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/java.py +0 -0
  66. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/javascript.py +0 -0
  67. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/language.py +0 -0
  68. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/mtypes.py +0 -0
  69. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/objops.py +0 -0
  70. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/optim.py +0 -0
  71. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/perl.py +0 -0
  72. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/plpgsql.py +0 -0
  73. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/predefs.py +0 -0
  74. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/python.py +0 -0
  75. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/recurse.py +0 -0
  76. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/regex.py +0 -0
  77. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/Makefile +0 -0
  78. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/__init__.py +0 -0
  79. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/c/Makefile +0 -0
  80. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/c/json-model.c +0 -0
  81. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/c/json-model.h +0 -0
  82. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/c/main.c +0 -0
  83. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/java/.gitignore +0 -0
  84. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/java/Makefile +0 -0
  85. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/java/README.md +0 -0
  86. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/java/env.sh +0 -0
  87. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/java/json_model/Checker.java +0 -0
  88. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/java/json_model/GSON.java +0 -0
  89. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/java/json_model/JSON.java +0 -0
  90. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/java/json_model/JSONP.java +0 -0
  91. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/java/json_model/Jackson.java +0 -0
  92. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/java/json_model/Main.java +0 -0
  93. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/java/json_model/ModelChecker.java +0 -0
  94. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/java/json_model/Path.java +0 -0
  95. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/java/json_model/Report.java +0 -0
  96. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/java/json_model/Runtime.java +0 -0
  97. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/java/pom.xml +0 -0
  98. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/js/README.md +0 -0
  99. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/js/index.js +0 -0
  100. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/js/main.js +0 -0
  101. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/js/package.json +0 -0
  102. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/pl/.gitignore +0 -0
  103. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/pl/Changes +0 -0
  104. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/pl/LICENSE +0 -0
  105. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/pl/MANIFEST +0 -0
  106. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/pl/Makefile.PL +0 -0
  107. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/pl/README +0 -0
  108. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/pl/env.sh +0 -0
  109. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/pl/ignore.txt +0 -0
  110. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/pl/lib/JSON/JsonModel.pm +0 -0
  111. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/pl/t/00-load.t +0 -0
  112. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/pl/t/manifest.t +0 -0
  113. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/pl/t/pod-coverage.t +0 -0
  114. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/pl/t/pod.t +0 -0
  115. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/pl/xt/boilerplate.t +0 -0
  116. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/sql/META.json +0 -0
  117. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/sql/Makefile +0 -0
  118. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/sql/json_model--2.0.sql +0 -0
  119. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/sql/json_model.control +0 -0
  120. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/support.py +0 -0
  121. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/runtime/types.py +0 -0
  122. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/submodel.py +0 -0
  123. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/ts_export.py +0 -0
  124. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/utils.py +0 -0
  125. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model/xstatic.py +0 -0
  126. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model_compiler.egg-info/SOURCES.txt +0 -0
  127. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model_compiler.egg-info/dependency_links.txt +0 -0
  128. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model_compiler.egg-info/entry_points.txt +0 -0
  129. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model_compiler.egg-info/not-zip-safe +0 -0
  130. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model_compiler.egg-info/requires.txt +0 -0
  131. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/json_model_compiler.egg-info/top_level.txt +0 -0
  132. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/package.json +0 -0
  133. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/pyproject.toml +0 -0
  134. {json_model_compiler-2.0.64 → json_model_compiler-2.0.66}/setup.cfg +0 -0
@@ -2,7 +2,8 @@
2
2
 
3
3
  ## Current Tasks
4
4
 
5
- - [ ] models: add for openapi overlay spec, json patch and others
5
+ - [ ] bench: add resilience to jmc failure to radar generation
6
+ - [ ] model: preprocessed model output is _not_ reintrant: feature or bug?
6
7
  - [ ] java-runtime: consider automatic updates?
7
8
  - [ ] pr: improve compiler page, list and describe optimizations?
8
9
  - [ ] bench: better count should ignore bads
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: json_model_compiler
3
- Version: 2.0.64
3
+ Version: 2.0.66
4
4
  Summary: JSON Model Tools
5
5
  Author: Fabien Coelho, Claire Yannou-Medrala
6
6
  License-Expression: CC0-1.0
@@ -146,7 +146,7 @@ for all possible values for that type.
146
146
  - `"$IP6"`: an ipv6, eg _0::0_
147
147
  - `"$ETH"`: an ethernet (mac) address, eg _De:ad:Be:ef:01:23_
148
148
  - `"$CARD"`: a credit card number with a Luhn checksum, eg _1234567890123452_
149
- - `"$JSONPT"`: an RFC6901 json pointer, eg _/http:~1~1json-model.org_
149
+ - `"$JSONPT"`: an RFC6901 json pointer, eg _/http:\~1\~1json-model.org_
150
150
  - `"$TIMETZ"`: time with timezone
151
151
  - `"$SEMVER"`: semantic versioning 2.0
152
152
 
@@ -458,111 +458,147 @@ A reference is a string which begins with the `$` character.
458
458
 
459
459
  Implementation should detect external reference cycles which are errors and should be rejected.
460
460
 
461
- ## (EXPERIMENTAL) Model Transformations
461
+ ## (EXPERIMENTAL) Type Edition (aka Model Transformations)
462
462
 
463
- Symbol `%` at the root of the model defines a global model transformation object, which
463
+ Type edition allows to transform models by editing nodes inside a model.
464
+ It comes in two forms:
465
+
466
+ 1. Global Type Edition with special keyword `%` at the root of the model.
467
+ 2. Local Type Edition within `$`-definitions.
468
+
469
+ The are executed when the model is loaded, as an initial syntactic step,
470
+ before any interpretation of the model beside considering its definitions `$`
471
+ and editions `%`.
472
+
473
+ ### Global Type Editions
474
+
475
+ Symbol `%` at the root of the model defines a global type edition object, which
464
476
  may include symbol renamings, model importations and model editions.
477
+ Inside the type edition objects, `#...` properties are comments to be ignored.
478
+ Other allowed properties are imports (`<`) and references (`$...`).
479
+ Any other property is an error.
465
480
 
466
- - **Symbol Names**
481
+ - **Importation**
467
482
 
468
- Within the `%` object at the root, properties beginning with a `.` introduce new symbol names.
469
- The value is the symbol string which is replaced, in `# ~ $ % @ = != <= < >= > ! | ^ & + / *`.
470
- For instance:
483
+ Special property `<` inside a edition object expects a reference to an external model,
484
+ or a list of such references, and imports all **definitions** of the targets into the
485
+ local scope, as local **definitions**.
471
486
 
472
- ```json
473
- {
474
- "%": { ".com": "#", ".or": "|", ".merge": "+" }
475
- }
476
- ```
487
+ While importing, homonymous definitions are invalid and must be rejected.
477
488
 
478
- Declares property substitutions, which translate this model:
489
+ - **Model Removal, Addition and Edition**
479
490
 
480
- ```json
481
- { ".merge": [ {"a": 0}, {".or": [ {"b": 0}, {"c": 0} ] } ] }
482
- ```
491
+ Model editions are specified with properties which are references (`$...`) possibly followed
492
+ by a JSON path, allowing to point to a JSON element in the model, and either a value
493
+ with special properties `/ *` to remove or add sub elements, `:` to rename properties.
494
+ Anything else taken as-is, but which must not be an object with any of the special properties.
483
495
 
484
- Into:
496
+ - If the reference ends with `#`, it designates the model _definitions_ on which the
497
+ editions are performed. The reference object must be a root model, eg imported with
498
+ a URL (`{ "model": "$https://json-model/models/json-model" }`). `$#` is a reference
499
+ to a model's own definitions. A reference may designate an indirectly imported model,
500
+ eg `$openapi#schema#` where `schema` is a definition inside `openapi`.
501
+ If the referenced object does not exist, this is an error.
485
502
 
486
- ```json
487
- { "+": [ {"a": 0}, {"|": [ {"b": 0}, {"c": 0} ] } ] }
488
- ```
503
+ The target value may contains any of `/ * ~` properties, this is a type edition object,
504
+ which is interpreted as follow, in this order, when they exist:
489
505
 
490
- These substitutions can be carried out by a separate preprocessor which generates
491
- the resulting standard model without any renamed symbol.
506
+ `/` must be a string or list of strings, the corresponding definitions must exist and
507
+ are removed.
492
508
 
493
- When declaring the model meta-model with `"~"` at the root, any renaming section specified
494
- in the meta-model **must** be applied to the current model before further processing.
495
- This feature allow the localization of the model syntax.
509
+ `*` is a object containing new definitions to be added to the name space. If
510
+ the name already exists, this is an error.
496
511
 
497
- - **Importation**
512
+ `~` is a string-to-string map to rename definitions, which the source must exist
513
+ and the target must not.
514
+ The renaming occurs simultaneously, i.e. `{"a": "b", "b": "a"}` inverts `a`
515
+ and `b` values and is allowed.
498
516
 
499
- Special property `"<"` inside a transformation object expects a reference to an external
500
- model, or a list of such references, and imports all definitions of the targets into the
501
- local scope.
517
+ The target object may also include comments (`# ...` properties) which are ignored.
518
+ It cannot include anything else.
502
519
 
503
- While importing, homonymous definitions are invalid and must be rejected.
520
+ - If the reference does **not** end with a `#`, this is interpreted as a `$` reference
521
+ possibly followed by a simple `.`-separated JSON Path: `$Foo.?bla` is definition `Foo`
522
+ and within this definition property `?bla`. As expected, `$.foo` refer to property
523
+ `foo` at the root of the model itself.
504
524
 
505
- - **Model Addition and Edition**
525
+ - If the reference is a name without a path, it designates a definition.
506
526
 
507
- Model editions are specified with properties which are references possibly followed
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, `:` to rename properties.
510
- Anything else taken as-is, but which must not be an object with any of the special properties.
527
+ If the definition does not exist, it is created and the value is associated
528
+ to the definition, which may be a model **or** a local type edition.
529
+
530
+ - If the definition exists, or if the reference is a name with an existing path:
531
+
532
+ - If the target value is an object which contains any of contains `/ * ~` properties
533
+ and possibly some comments, this is an edition, interpreted as follow:
534
+
535
+ `/` is a scalar or list of stuff and the referenced model is an array,
536
+ the values are removed from the array; if it is an object, the scalar or stuffs
537
+ must be strings, and the corresponding properties are removed. Other cases are errors.
511
538
 
512
- - Addition/replacement on a `"$External#name"` reference to a definition:
513
- - a non-existing definition is added to available definitions _in the target scope_.
514
- - an existing definition is replaced _in the target scope_.
515
- - Edition on a `"$External#name.foo.0"`: the target element **must** exist.
516
- The `.foo.0` path instructs to select the first element (index _0_) of
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.
519
-
520
- The following edition rules apply, in order, depending on the type of the target element:
521
-
522
- - if the transformation value is an edition object (ie include at least one `/ * ~` property):
523
- - if the target is a JSON object (not necessarily a model for an object):
524
- - `/` value may be a string or a list of strings.
525
- All properties of these names are removed.
526
- If a property does not exist, this is an error and must be rejected.
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.
536
- - if the target is a JSON array (not necessarily a model for an array):
537
- - `/`: may be value or a list of values.
538
- Array items equal to these values are removed.
539
- If a value is not found, this is an error and must be rejected.
540
- - `*`: if the value is an array, append its items to the target array.
541
- If the value is something else, appends to the array.
542
- - `~`: currently invalid
543
- - if the target is a JSON scalar: this is an error and must be rejected.
544
- - if the transformation value is a model (i.e. an object without any `/ *` property),
545
- the target value is _replaced_ by this value, in place.
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
-
554
- These additions and editions are performed _after_ property renamings and imports,
555
- and _before_ merge pre-processing.
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.
539
+ `*` interpretation is also type dependent:
540
+ If a scalar and the target a list, the item must exist and is removed;
541
+ If a list of stuff and the target a list, the items must exist and are removed;
542
+ If a list of strings and the target is an objects, keep only those properties;
543
+ If an object and the target an object, both objects are merged,
544
+ with property collisions considered as errors.
545
+ All other cases are errors.
546
+
547
+ `~` is a string-to-string map, the target must be an object, the sources
548
+ must exist as properties and are renamed to the target, which must not exist.
549
+ The renaming occurs simultaneously, i.e. `{"a": "b", "b": "a"}` inverts `a`
550
+ and `b` value and is allowed.
551
+
552
+ - Otherwise the target is assumed to be a model and replaces initial definition
553
+ or value at the path.
554
+
555
+ - If the reference is a name with a non existing path, this is an error.
556
+
557
+ ### Local Type Editions
558
+
559
+ Symbols `<`, `/`, `*`, `~` inside a _definition_ constitute a local type edition.
560
+
561
+ - `<` must be a simple local reference `$name`, the target model is **copied** inside the definition.
560
562
  - `/`, `*` and `~` define local editions inside the definition, as describe above.
561
563
 
562
564
  What is the _right_ balance between features, syntax and ease-of-use for a type transformation
563
565
  language is an on-going investigation: should it allow renaming, moving or copying attributes?
564
566
  Should it allow to remove definitions? Should imports allow to define a namespace?
565
567
 
568
+ Local editions are executed _after_ global editions, which may add new definitions with
569
+ such local editions.
570
+
571
+ ## (EXPERIMENTAL) Symbol Names
572
+
573
+ Within the `%` object at the root, properties beginning with a `.` introduce new symbol names.
574
+ The value is the symbol string which is replaced, in `# ~ $ % @ = != <= < >= > ! | ^ & + / *`.
575
+ For instance:
576
+
577
+ ```json
578
+ {
579
+ "%": { ".com": "#", ".or": "|", ".merge": "+" }
580
+ }
581
+ ```
582
+
583
+ Declares property substitutions, which translate this model:
584
+
585
+ ```json
586
+ { ".merge": [ {"a": 0}, {".or": [ {"b": 0}, {"c": 0} ] } ] }
587
+ ```
588
+
589
+ Into:
590
+
591
+ ```json
592
+ { "+": [ {"a": 0}, {"|": [ {"b": 0}, {"c": 0} ] } ] }
593
+ ```
594
+
595
+ These substitutions can be carried out by a separate preprocessor which generates
596
+ the resulting standard model without any renamed symbol.
597
+
598
+ When declaring the model meta-model with `"~"` at the root, any renaming section specified
599
+ in the meta-model **must** be applied to the current model before further processing.
600
+ This feature allow the localization of the model syntax.
601
+
566
602
  ## Static Typing Lattice
567
603
 
568
604
  In the above specification, there are several requirements for having _one_ known type
@@ -1,5 +1,26 @@
1
1
  # JSON Model Compiler Versions
2
2
 
3
+ ## 2.0.66 on 2026-11-02
4
+
5
+ - model: make resolver log actual file source when using cache
6
+ - bench: explicitly skip cache
7
+ - bench: use an unprocessed model instead of preprocessed as an intermediate
8
+ - front: make -U more verbose under debug
9
+ - tests: add ref tests for various native models
10
+
11
+ ## 2.0.65 on 2026-11-01
12
+
13
+ - models: json schema drafts as a diff (4, 6, 7, 8, 9)
14
+ - tests: also check json schema diff versions
15
+ - tests: add more trafo tests
16
+ - tests: update trafo support in model schema used by some tests
17
+ - models: add for openapi overlay spec
18
+ - models: add json patch spec (RFC6902) and tests
19
+ - model: allow comments in trafo
20
+ - model: fix missing resolver forwarding
21
+ - pr: rewrite trafo spec
22
+ - tests: add sanity assertion about xdist parallel pytest runs
23
+
3
24
  ## 2.0.64 on 2026-10-26
4
25
 
5
26
  - bench: do not link same version and message artifacts, keep first encountered
@@ -158,7 +158,7 @@ on a set of test vectors.
158
158
  - Number of test vector JSON values: _${n_values}_
159
159
  - All tested JSON values (including models, generated schemas and IR, and test suite schemas): _${all_values}_
160
160
 
161
- Over _170,000_ assertion checks are performed when running non-regression tests:
161
+ Over _180,000_ assertion checks are performed when running non-regression tests:
162
162
  generated files, values validated in various languages…
163
163
 
164
164
  [Example models](https://json-model.org/MODELS) cover typical use cases and demonstrate
@@ -106,6 +106,10 @@ def valid(jm: JsonModel,
106
106
  finite = not jm._isRef(ref) or ref == "$#" # Hmmm…
107
107
  if not finite:
108
108
  log.debug(f"infinite recursion on {smodel}: {recref} ({recid})")
109
+ if jm._debug >= 3:
110
+ log.debug(f"{jm._id}: {jm._model}")
111
+ for name, j in jm._defs.items():
112
+ log.debug(f"{jm._id}: {name} -> {j._id} ({j._model})")
109
113
  return finite
110
114
 
111
115
  def validFlt(model: ModelType, path: ModelPath) -> bool:
@@ -0,0 +1 @@
1
+ 2.0.66
@@ -294,7 +294,7 @@ class JsonModel:
294
294
 
295
295
  # extract actual definitions
296
296
  self._defs.update({
297
- n: JsonModel(m, resolver, url=self._url + "#" + n,
297
+ n: JsonModel(m, self._resolver, url=self._url + "#" + n,
298
298
  head=self._head, scope=self._defs, debug=self._debug,
299
299
  loose_int=self._loose_int, loose_float=self._loose_float,
300
300
  dname=n, single_line=self._single_line)
@@ -558,6 +558,9 @@ class JsonModel:
558
558
  ntodo.add(jm._id)
559
559
  todo = ntodo
560
560
 
561
+ # NOTE see mv-38/edit_05: keep all root models just in case
562
+ keep |= {mid for mid, mmo in self._models.items() if mmo._is_root}
563
+
561
564
  # cleanup
562
565
  total = len(self._models)
563
566
  for mid in list(self._models.keys()):
@@ -1023,22 +1026,26 @@ class JsonModel:
1023
1026
  else:
1024
1027
  name, xpath = tpath, []
1025
1028
  log.debug(f"{self._id}: parsePath name={name} xpath={xpath}")
1029
+ # log.debug(f"{self._id}: defs={list(self._defs.keys())}")
1026
1030
  jm = self.resolveRef(name, path, True)
1027
1031
  log.debug(f"{self._id}: {name} resolved to {jm._id}")
1028
1032
  return (jm, xpath)
1029
1033
 
1030
1034
  def _isTrafo(self, trafo: ModelTrafo):
1031
1035
  """Tell whether trafo is a transformation object."""
1032
- return isinstance(trafo, dict) and set(trafo.keys()).issubset({"#", "/", "*", "~"})
1036
+ return isinstance(trafo, dict) and \
1037
+ set(filter(lambda p: not p.startswith("#"), trafo.keys())).issubset({"/", "*", "~"})
1033
1038
 
1034
1039
  def _applyTrafo(self, j: Jsonable, trafo: ModelTrafo, path: ModelPath):
1035
1040
  """Apply this transformation on j."""
1036
1041
 
1042
+ if self._debug:
1043
+ log.debug(f"{self._id}: IN applyTrafo trafo={trafo} on j={j} at {path}")
1044
+
1045
+ # replace
1037
1046
  if not self._isTrafo(trafo):
1038
1047
  return trafo
1039
1048
  assert isinstance(trafo, dict) # pyright hint
1040
- if self._debug:
1041
- log.debug(f"{self._id}: applyTrafo trafo={trafo} on j={j} [{path}]")
1042
1049
 
1043
1050
  if "/" in trafo:
1044
1051
  sub = trafo["/"]
@@ -1071,14 +1078,15 @@ class JsonModel:
1071
1078
  # keep only those props, as well as comments
1072
1079
  for prop in list(j.keys()):
1073
1080
  if prop.startswith("#") or prop in add:
1074
- pass
1075
- else:
1076
- del j[prop]
1081
+ continue
1082
+ del j[prop]
1077
1083
  else:
1078
1084
  raise ModelError(f"cannot add list to {tname(j)} at {path}")
1079
1085
  elif isinstance(add, dict):
1080
1086
  if isinstance(j, dict):
1081
1087
  for k, v in add.items():
1088
+ if k.startswith("#"):
1089
+ continue
1082
1090
  if k in j:
1083
1091
  log.warning(f"overwriting property {k} at {path}")
1084
1092
  j[k] = v
@@ -1128,6 +1136,7 @@ class JsonModel:
1128
1136
  pn = p[1:]
1129
1137
  new[pn] = v
1130
1138
  del j[p]
1139
+ # else skip
1131
1140
  j.update(**new)
1132
1141
  new = {}
1133
1142
  # simple changes
@@ -1141,6 +1150,9 @@ class JsonModel:
1141
1150
  else:
1142
1151
  raise ModelError(f"unexpected rename type at {path}")
1143
1152
 
1153
+ if self._debug >= 3:
1154
+ log.debug(f"{self._id}: OUT applyTrafo is j={j} {path}")
1155
+
1144
1156
  return j
1145
1157
 
1146
1158
  def _applyModelTrafoAtPath(self,
@@ -1152,7 +1164,9 @@ class JsonModel:
1152
1164
  """Apply a transformation into a JSON Model."""
1153
1165
 
1154
1166
  if self._debug:
1155
- log.debug(f"{jm._id}: {trafo} at {path}: {tpath}")
1167
+ log.debug(f"{jm._id}: applying {trafo} at {path}: {tpath}")
1168
+ if self._debug >= 3:
1169
+ log.debug(f"{jm._id}: model = {jm._model}")
1156
1170
 
1157
1171
  j = jm._model
1158
1172
 
@@ -1208,9 +1222,11 @@ class JsonModel:
1208
1222
  if not isinstance(names, list) or not all(isinstance(s, str) for s in names):
1209
1223
  raise ModelError(f"namespace remove must be a list of names at {path}")
1210
1224
  for name in names:
1225
+ if name.startswith("#"):
1226
+ continue
1211
1227
  if name not in jm._defs:
1212
1228
  raise ModelError(f"missing {name} definition in model {jm._id} at {path}")
1213
- # FIXME this may not be enough!
1229
+ # NOTE this may not be enough!
1214
1230
  del jm._defs[name]
1215
1231
  # add new definitions
1216
1232
  if "*" in trafo:
@@ -1218,8 +1234,10 @@ class JsonModel:
1218
1234
  if not isinstance(defs, dict):
1219
1235
  raise ModelError(f"expecting definitions at {path}")
1220
1236
  for name, model in defs.items():
1237
+ if name.startswith("#"):
1238
+ continue
1221
1239
  # log.warning(f"{jm._id}: adding {name}")
1222
- # FIXME this may not be enough!
1240
+ # NOTE this may not be enough!
1223
1241
  jm._defs[name] = JsonModel(
1224
1242
  model, jm._resolver, head=jm._head, scope=jm._defs,
1225
1243
  loose_int=jm._loose_int, loose_float=jm._loose_float,
@@ -1235,6 +1253,8 @@ class JsonModel:
1235
1253
  # build update
1236
1254
  updates = {}
1237
1255
  for po, pn in renames.items():
1256
+ if po.startswith("#"):
1257
+ continue
1238
1258
  if po not in self._defs:
1239
1259
  raise ModelError(f"missing definition {po} at {path}")
1240
1260
  updates[pn] = self._defs[po]
@@ -1250,14 +1270,16 @@ class JsonModel:
1250
1270
 
1251
1271
  # NOTE transformation specs may be empty
1252
1272
  for tpath, trafo in rules.items():
1253
- log.warning(f"tpath={tpath} trafo={trafo}")
1273
+ if self._debug:
1274
+ log.debug(f"{self._id}: tpath={tpath} trafo={trafo}")
1254
1275
  lpath = ["%", tpath] # FIXME
1255
1276
  # typing issue, cannot assign list[str] to list[str|int] !?
1256
1277
  jm, path = self._parsePath(tpath, lpath) # type: ignore
1278
+ # log.debug(f"{self._id}: {jm._id} is {jm._model}")
1257
1279
  if tpath.endswith("#"): # model namespace
1258
1280
  self._applyRootTrafoAtPath(jm, path, trafo, lpath)
1259
1281
  else:
1260
1282
  self._applyModelTrafoAtPath(jm, path, trafo, lpath) # type: ignore
1261
1283
 
1262
1284
  if self._debug >= 2:
1263
- log.debug(f"edited model: {self._model} ({self._defs})")
1285
+ log.debug(f"{self._id}: edited model {self._model} ({self._defs})")
@@ -74,11 +74,13 @@ class Resolver:
74
74
  if url in self._jsons:
75
75
  return self._jsons[url]
76
76
 
77
+ FILE = "file://"
78
+
77
79
  # handle local files
78
80
  if url.startswith("./") or url.startswith("../") or url.startswith("/"):
79
81
  file = url
80
- elif url.startswith("file://"):
81
- file = url[7:]
82
+ elif url.startswith(FILE):
83
+ file = url[len(FILE):]
82
84
  elif ":" not in url:
83
85
  file = "./" + url
84
86
  else:
@@ -900,11 +900,12 @@ def jmc_script(xargs: list[str]|None = None) -> int:
900
900
  elif args.op == "U": # model dump
901
901
  assert model._models
902
902
  show = []
903
- for mid in sorted(model._models.keys()):
904
- m = model._models[mid]
903
+ for mid, m in sorted(model._models.items()):
905
904
  j = m.toModel(m._is_root)
906
905
  if isinstance(j, dict) or model._is_root:
907
906
  show.append(j)
907
+ elif args.debug:
908
+ show.append(j)
908
909
  print(json2str(show), file=output)
909
910
  elif args.op == "N": # no operation
910
911
  print(json2str(model._init_md), file=output)
@@ -42,6 +42,7 @@ class JsonURLCache:
42
42
  self._cache: dict[str, Jsonable] = {}
43
43
 
44
44
  def getJSON(self, url: str) -> Jsonable:
45
+ """Load URL for a JSON representation from JSON or YaML."""
45
46
  res = self._requests.get(url)
46
47
  try:
47
48
  return res.json()
@@ -64,20 +65,22 @@ class JsonURLCache:
64
65
  # first cache (memory)
65
66
  # log.error("skipping cache!")
66
67
  if u in self._cache:
68
+ log.info(f"mem cache: {url}")
67
69
  return self._cache[u]
68
70
 
69
71
  # second cache (file): we assume no hash collision
70
72
  h = hashlib.sha3_256(u.encode("UTF-8")).hexdigest()
71
73
  hfile = self._cache_dir + "/" + h
72
74
  if os.path.exists(hfile):
73
- log.info(f"loading: {url}")
75
+ log.info(f"file cache: {url}")
74
76
  with open(hfile) as f:
75
77
  j = json.load(f)
76
78
  self._cache[u] = j
77
79
  return j
78
80
 
79
- # download
80
- log.info(f"downloading: {url}")
81
+ # download or load
82
+ op = "downloading" if url.startswith("http:") or url.startswith("https:") else "loading"
83
+ log.info(f"{op}: {url}")
81
84
  j = self.getJSON(u)
82
85
  self._cache[u] = j
83
86
  with open(hfile, "w") as f:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: json_model_compiler
3
- Version: 2.0.64
3
+ Version: 2.0.66
4
4
  Summary: JSON Model Tools
5
5
  Author: Fabien Coelho, Claire Yannou-Medrala
6
6
  License-Expression: CC0-1.0
@@ -1 +0,0 @@
1
- 2.0.64