@mat3ra/esse 2024.2.6-0 → 2024.2.19-0
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.
- package/.eslintrc.json +9 -1
- package/.mocharc.json +5 -0
- package/build_schemas.js +7 -32
- package/compile_ts.ts +3 -0
- package/example/models_directory/re.json +1 -0
- package/example/workflow/subworkflow.json +1 -1
- package/example/workflow.json +2 -1
- package/lib/js/esse/JSONSchemasGenerator.d.ts +20 -0
- package/lib/js/esse/JSONSchemasGenerator.js +64 -0
- package/lib/js/esse/JSONSchemasInterface.d.ts +31 -0
- package/lib/js/esse/JSONSchemasInterface.js +48 -0
- package/lib/js/esse/JSONSchemasInterfaceServer.d.ts +9 -0
- package/lib/js/esse/JSONSchemasInterfaceServer.js +46 -0
- package/lib/js/esse/schemaUtils.d.ts +4 -0
- package/lib/js/esse/schemaUtils.js +13 -74
- package/lib/js/esse/settings.d.ts +3 -0
- package/lib/js/esse/settings.js +9 -21
- package/lib/js/esse/types.d.ts +3 -0
- package/lib/js/esse/types.js +2 -0
- package/lib/js/esse/utils.d.ts +14 -0
- package/lib/js/esse/utils.js +42 -62
- package/lib/js/example/3pse/file/applications/espresso/7.2/pw.x.json +94 -0
- package/lib/js/example/core/abstract/2d_data.json +19 -0
- package/lib/js/example/core/abstract/2d_plot.json +26 -0
- package/lib/js/example/core/abstract/3d_grid.json +12 -0
- package/lib/js/example/core/abstract/3d_tensor.json +17 -0
- package/lib/js/example/core/abstract/3d_vector_basis.json +17 -0
- package/lib/js/example/core/abstract/point.json +5 -0
- package/lib/js/example/core/abstract/vector.json +5 -0
- package/lib/js/example/core/primitive/1d_data_series.json +12 -0
- package/lib/js/example/core/primitive/3d_lattice.json +8 -0
- package/lib/js/example/core/primitive/array_of_3_booleans.json +5 -0
- package/lib/js/example/core/primitive/array_of_3_numbers.json +5 -0
- package/lib/js/example/core/primitive/array_of_ids.json +8 -0
- package/lib/js/example/core/primitive/axis.json +4 -0
- package/lib/js/example/core/primitive/scalar.json +3 -0
- package/lib/js/example/core/primitive/string.json +3 -0
- package/lib/js/example/core/reference/experiment/condition.json +12 -0
- package/lib/js/example/core/reference/experiment/location.json +4 -0
- package/lib/js/example/core/reference/experiment.json +38 -0
- package/lib/js/example/core/reference/literature/name.json +5 -0
- package/lib/js/example/core/reference/literature/pages.json +4 -0
- package/lib/js/example/core/reference/literature.json +10 -0
- package/lib/js/example/core/reference/modeling/exabyte.json +9 -0
- package/lib/js/example/core/reference/modeling.json +9 -0
- package/lib/js/example/core/reference.json +9 -0
- package/lib/js/example/core/reusable/atomic_vectors.json +18 -0
- package/lib/js/example/core/reusable/band_gap.json +16 -0
- package/lib/js/example/core/reusable/energy.json +5 -0
- package/lib/js/example/core/reusable/file_metadata.json +5 -0
- package/lib/js/example/core/reusable/object_storage_container_data.json +8 -0
- package/lib/js/example/element.json +17 -0
- package/lib/js/example/job/compute.json +26 -0
- package/lib/js/example/job.json +183 -0
- package/lib/js/example/material.json +128 -0
- package/lib/js/example/method/categorized_method.json +47 -0
- package/lib/js/example/method/method_parameters.json +3 -0
- package/lib/js/example/method.json +7 -0
- package/lib/js/example/methods_directory/legacy/localorbital.json +4 -0
- package/lib/js/example/methods_directory/legacy/pseudopotential.json +4 -0
- package/lib/js/example/methods_directory/legacy/regression.json +61 -0
- package/lib/js/example/methods_directory/legacy/unknown.json +4 -0
- package/lib/js/example/methods_directory/mathematical/cg.json +10 -0
- package/lib/js/example/methods_directory/mathematical/regression.json +65 -0
- package/lib/js/example/methods_directory/physical/ao/dunning.json +13 -0
- package/lib/js/example/methods_directory/physical/psp/file.json +54 -0
- package/lib/js/example/methods_directory/physical/psp.json +67 -0
- package/lib/js/example/methods_directory/physical/pw.json +9 -0
- package/lib/js/example/methods_directory/physical/smearing.json +10 -0
- package/lib/js/example/methods_directory/physical/tetrahedron.json +10 -0
- package/lib/js/example/model/categorized_model.json +77 -0
- package/lib/js/example/model/model_parameters.json +7 -0
- package/lib/js/example/model.json +11 -0
- package/lib/js/example/models_category/pb/qm/abin/gw.json +7 -0
- package/lib/js/example/models_category/pb/qm/dft/ksdft.json +6 -0
- package/lib/js/example/models_category/pb/qm/semp.json +5 -0
- package/lib/js/example/models_directory/gga.json +15 -0
- package/lib/js/example/models_directory/gw.json +15 -0
- package/lib/js/example/models_directory/hybrid.json +15 -0
- package/lib/js/example/models_directory/lda.json +15 -0
- package/lib/js/example/models_directory/legacy/dft.json +12 -0
- package/lib/js/example/models_directory/legacy/ml.json +11 -0
- package/lib/js/example/models_directory/legacy/unknown.json +11 -0
- package/lib/js/example/models_directory/re.json +10 -0
- package/lib/js/example/project.json +25 -0
- package/lib/js/example/properties_directory/electronic_configuration.json +4 -0
- package/lib/js/example/properties_directory/elemental/atomic_radius.json +4 -0
- package/lib/js/example/properties_directory/elemental/electronegativity.json +4 -0
- package/lib/js/example/properties_directory/elemental/ionization_potential.json +4 -0
- package/lib/js/example/properties_directory/non_scalar/band_gaps.json +25 -0
- package/lib/js/example/properties_directory/non_scalar/band_structure.json +47 -0
- package/lib/js/example/properties_directory/non_scalar/charge_density_profile.json +22 -0
- package/lib/js/example/properties_directory/non_scalar/density_of_states.json +55 -0
- package/lib/js/example/properties_directory/non_scalar/dielectric_tensor.json +133 -0
- package/lib/js/example/properties_directory/non_scalar/file_content.json +13 -0
- package/lib/js/example/properties_directory/non_scalar/hubbard_u.json +24 -0
- package/lib/js/example/properties_directory/non_scalar/hubbard_v.json +22 -0
- package/lib/js/example/properties_directory/non_scalar/hubbard_v_nn.json +24 -0
- package/lib/js/example/properties_directory/non_scalar/phonon_dispersions.json +41 -0
- package/lib/js/example/properties_directory/non_scalar/phonon_dos.json +37 -0
- package/lib/js/example/properties_directory/non_scalar/potential_profile.json +32 -0
- package/lib/js/example/properties_directory/non_scalar/reaction_energy_profile.json +30 -0
- package/lib/js/example/properties_directory/non_scalar/stress_tensor.json +21 -0
- package/lib/js/example/properties_directory/non_scalar/total_energy_contributions.json +44 -0
- package/lib/js/example/properties_directory/non_scalar/vibrational_spectrum.json +25 -0
- package/lib/js/example/properties_directory/scalar/electron_affinity.json +5 -0
- package/lib/js/example/properties_directory/scalar/fermi_energy.json +5 -0
- package/lib/js/example/properties_directory/scalar/formation_energy.json +5 -0
- package/lib/js/example/properties_directory/scalar/ionization_potential.json +5 -0
- package/lib/js/example/properties_directory/scalar/pressure.json +5 -0
- package/lib/js/example/properties_directory/scalar/reaction_energy_barrier.json +5 -0
- package/lib/js/example/properties_directory/scalar/surface_energy.json +5 -0
- package/lib/js/example/properties_directory/scalar/total_energy.json +5 -0
- package/lib/js/example/properties_directory/scalar/total_force.json +5 -0
- package/lib/js/example/properties_directory/scalar/valence_band_offset.json +5 -0
- package/lib/js/example/properties_directory/scalar/zero_point_energy.json +5 -0
- package/lib/js/example/properties_directory/structural/atomic_forces.json +22 -0
- package/lib/js/example/properties_directory/structural/basis/atomic_constraints.json +21 -0
- package/lib/js/example/properties_directory/structural/basis/atomic_coordinate.json +8 -0
- package/lib/js/example/properties_directory/structural/basis/atomic_coordinates.json +21 -0
- package/lib/js/example/properties_directory/structural/basis/atomic_element.json +4 -0
- package/lib/js/example/properties_directory/structural/basis/bonds.json +24 -0
- package/lib/js/example/properties_directory/structural/basis.json +46 -0
- package/lib/js/example/properties_directory/structural/density.json +5 -0
- package/lib/js/example/properties_directory/structural/elemental_ratio.json +5 -0
- package/lib/js/example/properties_directory/structural/inchi.json +4 -0
- package/lib/js/example/properties_directory/structural/inchi_key.json +4 -0
- package/lib/js/example/properties_directory/structural/lattice/lattice_bravais.json +13 -0
- package/lib/js/example/properties_directory/structural/lattice/lattice_vectors.json +19 -0
- package/lib/js/example/properties_directory/structural/lattice.json +33 -0
- package/lib/js/example/properties_directory/structural/magnetic_moments.json +22 -0
- package/lib/js/example/properties_directory/structural/molecular_pattern.json +71 -0
- package/lib/js/example/properties_directory/structural/p_norm.json +5 -0
- package/lib/js/example/properties_directory/structural/symmetry.json +9 -0
- package/lib/js/example/properties_directory/structural/volume.json +5 -0
- package/lib/js/example/properties_directory/workflow/convergence/electronic.json +15 -0
- package/lib/js/example/properties_directory/workflow/convergence/ionic.json +20 -0
- package/lib/js/example/properties_directory/workflow/convergence/kpoint.json +22 -0
- package/lib/js/example/property/base.json +31 -0
- package/lib/js/example/software/application.json +7 -0
- package/lib/js/example/software/executable.json +20 -0
- package/lib/js/example/software/flavor.json +9 -0
- package/lib/js/example/software/template.json +14 -0
- package/lib/js/example/software_directory/ml/exabyteml.json +6 -0
- package/lib/js/example/software_directory/ml/unit/execution/evaluate/cross_validate.json +20 -0
- package/lib/js/example/software_directory/ml/unit/execution/initialize.json +23 -0
- package/lib/js/example/software_directory/ml/unit/execution/score.json +18 -0
- package/lib/js/example/software_directory/ml/unit/execution/train.json +29 -0
- package/lib/js/example/software_directory/ml/unit/processing/data_transformation/manipulation.json +14 -0
- package/lib/js/example/software_directory/ml/unit/processing/data_transformation/scale_and_reduce.json +26 -0
- package/lib/js/example/software_directory/ml/unit/processing/feature_selection/filter_based.json +13 -0
- package/lib/js/example/software_directory/modeling/espresso/arguments.json +5 -0
- package/lib/js/example/software_directory/modeling/espresso.json +6 -0
- package/lib/js/example/software_directory/modeling/nwchem.json +6 -0
- package/lib/js/example/software_directory/modeling/unit/execution.json +19 -0
- package/lib/js/example/software_directory/modeling/vasp.json +6 -0
- package/lib/js/example/software_directory/scripting/jupyter_lab.json +8 -0
- package/lib/js/example/software_directory/scripting/python.json +8 -0
- package/lib/js/example/software_directory/scripting/shell.json +8 -0
- package/lib/js/example/software_directory/scripting/unit/execution.json +22 -0
- package/lib/js/example/system/_material.json +5 -0
- package/lib/js/example/system/_parent_job.json +5 -0
- package/lib/js/example/system/_project.json +5 -0
- package/lib/js/example/system/consistency_check.json +6 -0
- package/lib/js/example/system/creator.json +5 -0
- package/lib/js/example/system/entity_reference.json +5 -0
- package/lib/js/example/system/file_source.json +6 -0
- package/lib/js/example/system/message.json +16 -0
- package/lib/js/example/system/owner.json +5 -0
- package/lib/js/example/workflow/subworkflow.json +93 -0
- package/lib/js/example/workflow/unit/assignment.json +19 -0
- package/lib/js/example/workflow/unit/condition.json +22 -0
- package/lib/js/example/workflow/unit/execution.json +66 -0
- package/lib/js/example/workflow/unit/input/_inputItemScope.json +4 -0
- package/lib/js/example/workflow/unit/io/api.json +31 -0
- package/lib/js/example/workflow/unit/io/db.json +15 -0
- package/lib/js/example/workflow/unit/io/object_storage.json +12 -0
- package/lib/js/example/workflow/unit/io.json +41 -0
- package/lib/js/example/workflow/unit/map.json +16 -0
- package/lib/js/example/workflow/unit/processing.json +13 -0
- package/lib/js/example/workflow/unit/reduce.json +16 -0
- package/lib/js/example/workflow/unit/runtime/runtime_items.json +14 -0
- package/lib/js/example/workflow.json +129 -0
- package/lib/js/json_include/index.d.ts +20 -0
- package/lib/js/json_include/index.js +61 -97
- package/lib/js/json_include/settings.d.ts +3 -0
- package/lib/js/json_include/settings.js +4 -11
- package/lib/js/schema/3pse/file/applications/espresso/7.2/pw.x/atomic_positions.json +72 -0
- package/lib/js/schema/3pse/file/applications/espresso/7.2/pw.x/atomic_species.json +30 -0
- package/lib/js/schema/3pse/file/applications/espresso/7.2/pw.x/cell.json +89 -0
- package/lib/js/schema/3pse/file/applications/espresso/7.2/pw.x/cell_parameters.json +54 -0
- package/lib/js/schema/3pse/file/applications/espresso/7.2/pw.x/control.json +181 -0
- package/lib/js/schema/3pse/file/applications/espresso/7.2/pw.x/electrons.json +163 -0
- package/lib/js/schema/3pse/file/applications/espresso/7.2/pw.x/hubbard.json +219 -0
- package/lib/js/schema/3pse/file/applications/espresso/7.2/pw.x/ions.json +216 -0
- package/lib/js/schema/3pse/file/applications/espresso/7.2/pw.x/k_points.json +87 -0
- package/lib/js/schema/3pse/file/applications/espresso/7.2/pw.x/system.json +652 -0
- package/lib/js/schema/3pse/file/applications/espresso/7.2/pw.x.json +1776 -0
- package/lib/js/schema/core/abstract/2d_data.json +31 -0
- package/lib/js/schema/core/abstract/2d_plot.json +74 -0
- package/lib/js/schema/core/abstract/3d_grid.json +32 -0
- package/lib/js/schema/core/abstract/3d_tensor.json +18 -0
- package/lib/js/schema/core/abstract/3d_vector_basis.json +43 -0
- package/lib/js/schema/core/abstract/point.json +11 -0
- package/lib/js/schema/core/abstract/vector.json +27 -0
- package/lib/js/schema/core/primitive/1d_data_series.json +16 -0
- package/lib/js/schema/core/primitive/3d_lattice.json +40 -0
- package/lib/js/schema/core/primitive/array_of_3_booleans.json +11 -0
- package/lib/js/schema/core/primitive/array_of_3_numbers.json +11 -0
- package/lib/js/schema/core/primitive/array_of_ids.json +16 -0
- package/lib/js/schema/core/primitive/array_of_strings.json +11 -0
- package/lib/js/schema/core/primitive/axis.json +19 -0
- package/lib/js/schema/core/primitive/group_info.json +16 -0
- package/lib/js/schema/core/primitive/integer_one_or_zero.json +8 -0
- package/lib/js/schema/core/primitive/linked_list/base_node.json +36 -0
- package/lib/js/schema/core/primitive/linked_list/named_node.json +40 -0
- package/lib/js/schema/core/primitive/linked_list/named_node_in_group.json +48 -0
- package/lib/js/schema/core/primitive/linked_list/node_with_type.json +39 -0
- package/lib/js/schema/core/primitive/linked_list.json +171 -0
- package/lib/js/schema/core/primitive/scalar.json +14 -0
- package/lib/js/schema/core/primitive/slugified_entry.json +21 -0
- package/lib/js/schema/core/primitive/slugified_entry_or_slug.json +31 -0
- package/lib/js/schema/core/primitive/string.json +14 -0
- package/lib/js/schema/core/reference/exabyte.json +19 -0
- package/lib/js/schema/core/reference/experiment/condition.json +31 -0
- package/lib/js/schema/core/reference/experiment/location.json +20 -0
- package/lib/js/schema/core/reference/experiment.json +249 -0
- package/lib/js/schema/core/reference/literature/name.json +24 -0
- package/lib/js/schema/core/reference/literature/pages.json +17 -0
- package/lib/js/schema/core/reference/literature.json +131 -0
- package/lib/js/schema/core/reference/modeling/exabyte.json +46 -0
- package/lib/js/schema/core/reference/modeling.json +52 -0
- package/lib/js/schema/core/reference.json +436 -0
- package/lib/js/schema/core/reusable/atomic_data/per_orbital.json +22 -0
- package/lib/js/schema/core/reusable/atomic_data/per_orbital_pair.json +39 -0
- package/lib/js/schema/core/reusable/atomic_data/value_number.json +13 -0
- package/lib/js/schema/core/reusable/atomic_data/value_string.json +13 -0
- package/lib/js/schema/core/reusable/atomic_data_per_orbital_numeric.json +26 -0
- package/lib/js/schema/core/reusable/atomic_data_per_orbital_pair_numeric.json +43 -0
- package/lib/js/schema/core/reusable/atomic_orbital.json +32 -0
- package/lib/js/schema/core/reusable/atomic_scalars.json +29 -0
- package/lib/js/schema/core/reusable/atomic_strings.json +19 -0
- package/lib/js/schema/core/reusable/atomic_vectors.json +42 -0
- package/lib/js/schema/core/reusable/band_gap.json +64 -0
- package/lib/js/schema/core/reusable/categories.json +159 -0
- package/lib/js/schema/core/reusable/category_path.json +7 -0
- package/lib/js/schema/core/reusable/dielectric_tensor_component.json +46 -0
- package/lib/js/schema/core/reusable/energy.json +39 -0
- package/lib/js/schema/core/reusable/file_metadata.json +21 -0
- package/lib/js/schema/core/reusable/frequency_function_matrix.json +30 -0
- package/lib/js/schema/core/reusable/object_storage_container_data.json +38 -0
- package/lib/js/schema/definitions/units.json +103 -0
- package/lib/js/schema/element.json +103 -0
- package/lib/js/schema/in_memory_entity/base.json +65 -0
- package/lib/js/schema/in_memory_entity/defaultable.json +70 -0
- package/lib/js/schema/in_memory_entity/named.json +69 -0
- package/lib/js/schema/in_memory_entity/named_defaultable.json +74 -0
- package/lib/js/schema/in_memory_entity/named_defaultable_has_metadata.json +77 -0
- package/lib/js/schema/in_memory_entity/named_defaultable_runtime_items.json +194 -0
- package/lib/js/schema/job/base.json +376 -0
- package/lib/js/schema/job/compute.json +176 -0
- package/lib/js/schema/job.json +6868 -0
- package/lib/js/schema/material/conventional.json +11 -0
- package/lib/js/schema/material.json +624 -0
- package/lib/js/schema/method/categorized_method.json +221 -0
- package/lib/js/schema/method/method_parameters.json +47 -0
- package/lib/js/schema/method/unit_method.json +191 -0
- package/lib/js/schema/method.json +28 -0
- package/lib/js/schema/methods_category/mathematical/diff/enum_options.json +8 -0
- package/lib/js/schema/methods_category/mathematical/diff/fd.json +165 -0
- package/lib/js/schema/methods_category/mathematical/diff.json +162 -0
- package/lib/js/schema/methods_category/mathematical/discr/enum_options.json +8 -0
- package/lib/js/schema/methods_category/mathematical/discr/mesh/enum_options.json +18 -0
- package/lib/js/schema/methods_category/mathematical/discr/mesh/hybrid.json +168 -0
- package/lib/js/schema/methods_category/mathematical/discr/mesh/nstruct.json +168 -0
- package/lib/js/schema/methods_category/mathematical/discr/mesh/struct/cartesian.json +171 -0
- package/lib/js/schema/methods_category/mathematical/discr/mesh/struct/enum_options.json +8 -0
- package/lib/js/schema/methods_category/mathematical/discr/mesh/struct.json +168 -0
- package/lib/js/schema/methods_category/mathematical/discr/mesh.json +165 -0
- package/lib/js/schema/methods_category/mathematical/discr.json +162 -0
- package/lib/js/schema/methods_category/mathematical/enum_options.json +45 -0
- package/lib/js/schema/methods_category/mathematical/fapprx/basisexp.json +165 -0
- package/lib/js/schema/methods_category/mathematical/fapprx/enum_options.json +13 -0
- package/lib/js/schema/methods_category/mathematical/fapprx/ipol/enum_options.json +18 -0
- package/lib/js/schema/methods_category/mathematical/fapprx/ipol/lin.json +168 -0
- package/lib/js/schema/methods_category/mathematical/fapprx/ipol/poly.json +168 -0
- package/lib/js/schema/methods_category/mathematical/fapprx/ipol/spline.json +168 -0
- package/lib/js/schema/methods_category/mathematical/fapprx/ipol.json +165 -0
- package/lib/js/schema/methods_category/mathematical/fapprx.json +162 -0
- package/lib/js/schema/methods_category/mathematical/intgr/analytic/enum_options.json +20 -0
- package/lib/js/schema/methods_category/mathematical/intgr/analytic/volume.json +178 -0
- package/lib/js/schema/methods_category/mathematical/intgr/analytic.json +165 -0
- package/lib/js/schema/methods_category/mathematical/intgr/diffeq/enum_options.json +13 -0
- package/lib/js/schema/methods_category/mathematical/intgr/diffeq/order1.json +168 -0
- package/lib/js/schema/methods_category/mathematical/intgr/diffeq/order2.json +168 -0
- package/lib/js/schema/methods_category/mathematical/intgr/diffeq.json +165 -0
- package/lib/js/schema/methods_category/mathematical/intgr/enum_options.json +23 -0
- package/lib/js/schema/methods_category/mathematical/intgr/numquad/enum_options.json +13 -0
- package/lib/js/schema/methods_category/mathematical/intgr/numquad/gauss.json +168 -0
- package/lib/js/schema/methods_category/mathematical/intgr/numquad/newcot.json +168 -0
- package/lib/js/schema/methods_category/mathematical/intgr/numquad.json +165 -0
- package/lib/js/schema/methods_category/mathematical/intgr/transf/enum_options.json +8 -0
- package/lib/js/schema/methods_category/mathematical/intgr/transf/fourier.json +168 -0
- package/lib/js/schema/methods_category/mathematical/intgr/transf.json +165 -0
- package/lib/js/schema/methods_category/mathematical/intgr.json +162 -0
- package/lib/js/schema/methods_category/mathematical/linalg/dcomp.json +165 -0
- package/lib/js/schema/methods_category/mathematical/linalg/diag/davidson.json +168 -0
- package/lib/js/schema/methods_category/mathematical/linalg/diag/enum_options.json +8 -0
- package/lib/js/schema/methods_category/mathematical/linalg/diag.json +165 -0
- package/lib/js/schema/methods_category/mathematical/linalg/enum_options.json +23 -0
- package/lib/js/schema/methods_category/mathematical/linalg/lintra.json +165 -0
- package/lib/js/schema/methods_category/mathematical/linalg/matf.json +165 -0
- package/lib/js/schema/methods_category/mathematical/linalg.json +162 -0
- package/lib/js/schema/methods_category/mathematical/opt/diff/bracket.json +168 -0
- package/lib/js/schema/methods_category/mathematical/opt/diff/enum_options.json +28 -0
- package/lib/js/schema/methods_category/mathematical/opt/diff/local.json +168 -0
- package/lib/js/schema/methods_category/mathematical/opt/diff/order1.json +168 -0
- package/lib/js/schema/methods_category/mathematical/opt/diff/order2.json +168 -0
- package/lib/js/schema/methods_category/mathematical/opt/diff/ordern/cg.json +171 -0
- package/lib/js/schema/methods_category/mathematical/opt/diff/ordern/enum_options.json +8 -0
- package/lib/js/schema/methods_category/mathematical/opt/diff/ordern.json +168 -0
- package/lib/js/schema/methods_category/mathematical/opt/diff.json +165 -0
- package/lib/js/schema/methods_category/mathematical/opt/enum_options.json +18 -0
- package/lib/js/schema/methods_category/mathematical/opt/ndiff/direct.json +168 -0
- package/lib/js/schema/methods_category/mathematical/opt/ndiff/enum_options.json +18 -0
- package/lib/js/schema/methods_category/mathematical/opt/ndiff/pop.json +168 -0
- package/lib/js/schema/methods_category/mathematical/opt/ndiff/stoch.json +168 -0
- package/lib/js/schema/methods_category/mathematical/opt/ndiff.json +165 -0
- package/lib/js/schema/methods_category/mathematical/opt/root/bracket.json +168 -0
- package/lib/js/schema/methods_category/mathematical/opt/root/enum_options.json +13 -0
- package/lib/js/schema/methods_category/mathematical/opt/root/iter.json +168 -0
- package/lib/js/schema/methods_category/mathematical/opt/root.json +165 -0
- package/lib/js/schema/methods_category/mathematical/opt.json +162 -0
- package/lib/js/schema/methods_category/mathematical/regression.json +167 -0
- package/lib/js/schema/methods_category/physical/enum_options.json +8 -0
- package/lib/js/schema/methods_category/physical/qm/enum_options.json +8 -0
- package/lib/js/schema/methods_category/physical/qm/wf/ao/dunning.json +171 -0
- package/lib/js/schema/methods_category/physical/qm/wf/ao/other.json +171 -0
- package/lib/js/schema/methods_category/physical/qm/wf/ao/pople.json +171 -0
- package/lib/js/schema/methods_category/physical/qm/wf/ao.json +173 -0
- package/lib/js/schema/methods_category/physical/qm/wf/enum_options.json +63 -0
- package/lib/js/schema/methods_category/physical/qm/wf/psp.json +174 -0
- package/lib/js/schema/methods_category/physical/qm/wf/pw.json +168 -0
- package/lib/js/schema/methods_category/physical/qm/wf/smearing.json +174 -0
- package/lib/js/schema/methods_category/physical/qm/wf/tetrahedron.json +173 -0
- package/lib/js/schema/methods_category/physical/qm/wf.json +165 -0
- package/lib/js/schema/methods_category/physical/qm.json +162 -0
- package/lib/js/schema/methods_directory/legacy/localorbital.json +34 -0
- package/lib/js/schema/methods_directory/legacy/pseudopotential.json +37 -0
- package/lib/js/schema/methods_directory/legacy/regression.json +185 -0
- package/lib/js/schema/methods_directory/legacy/unknown.json +34 -0
- package/lib/js/schema/methods_directory/mathematical/cg.json +207 -0
- package/lib/js/schema/methods_directory/mathematical/davidson.json +204 -0
- package/lib/js/schema/methods_directory/mathematical/regression/data.json +122 -0
- package/lib/js/schema/methods_directory/mathematical/regression/dataset.json +21 -0
- package/lib/js/schema/methods_directory/mathematical/regression/kernel_ridge/data_per_property.json +47 -0
- package/lib/js/schema/methods_directory/mathematical/regression/linear/data_per_property.json +42 -0
- package/lib/js/schema/methods_directory/mathematical/regression/per_feature_item.json +23 -0
- package/lib/js/schema/methods_directory/mathematical/regression/precision.json +33 -0
- package/lib/js/schema/methods_directory/mathematical/regression/precision_per_property.json +23 -0
- package/lib/js/schema/methods_directory/mathematical/regression.json +354 -0
- package/lib/js/schema/methods_directory/physical/ao/dunning.json +230 -0
- package/lib/js/schema/methods_directory/physical/ao/enum_options.json +28 -0
- package/lib/js/schema/methods_directory/physical/ao/other.json +238 -0
- package/lib/js/schema/methods_directory/physical/ao/pople.json +230 -0
- package/lib/js/schema/methods_directory/physical/psp/file.json +140 -0
- package/lib/js/schema/methods_directory/physical/psp/file_data_item.json +116 -0
- package/lib/js/schema/methods_directory/physical/psp.json +352 -0
- package/lib/js/schema/methods_directory/physical/pw.json +204 -0
- package/lib/js/schema/methods_directory/physical/smearing.json +210 -0
- package/lib/js/schema/methods_directory/physical/tetrahedron.json +208 -0
- package/lib/js/schema/model/categorized_model.json +542 -0
- package/lib/js/schema/model/mixins/dft/double_hybrid_functional.json +13 -0
- package/lib/js/schema/model/mixins/dft/enum_options.json +30 -0
- package/lib/js/schema/model/mixins/dft/gga_functional.json +15 -0
- package/lib/js/schema/model/mixins/dft/hybrid_functional.json +14 -0
- package/lib/js/schema/model/mixins/dft/lda_functional.json +14 -0
- package/lib/js/schema/model/mixins/dft/mgga_functional.json +14 -0
- package/lib/js/schema/model/mixins/dispersion_correction.json +16 -0
- package/lib/js/schema/model/mixins/enum_options.json +22 -0
- package/lib/js/schema/model/mixins/hubbard.json +13 -0
- package/lib/js/schema/model/mixins/spin_orbit_coupling.json +12 -0
- package/lib/js/schema/model/mixins/spin_polarization.json +15 -0
- package/lib/js/schema/model/model_parameters.json +98 -0
- package/lib/js/schema/model/model_without_method.json +321 -0
- package/lib/js/schema/model.json +49 -0
- package/lib/js/schema/models_category/enum_options.json +13 -0
- package/lib/js/schema/models_category/pb/enum_options.json +8 -0
- package/lib/js/schema/models_category/pb/qm/abin/enum_options.json +15 -0
- package/lib/js/schema/models_category/pb/qm/abin/gw.json +176 -0
- package/lib/js/schema/models_category/pb/qm/abin.json +168 -0
- package/lib/js/schema/models_category/pb/qm/dft/enum_options.json +8 -0
- package/lib/js/schema/models_category/pb/qm/dft/ksdft/double_hybrid.json +174 -0
- package/lib/js/schema/models_category/pb/qm/dft/ksdft/enum_options.json +28 -0
- package/lib/js/schema/models_category/pb/qm/dft/ksdft/gga.json +174 -0
- package/lib/js/schema/models_category/pb/qm/dft/ksdft/hybrid.json +174 -0
- package/lib/js/schema/models_category/pb/qm/dft/ksdft/lda.json +174 -0
- package/lib/js/schema/models_category/pb/qm/dft/ksdft/mgga.json +174 -0
- package/lib/js/schema/models_category/pb/qm/dft/ksdft.json +171 -0
- package/lib/js/schema/models_category/pb/qm/dft.json +168 -0
- package/lib/js/schema/models_category/pb/qm/enum_options.json +18 -0
- package/lib/js/schema/models_category/pb/qm/semp.json +168 -0
- package/lib/js/schema/models_category/pb/qm.json +165 -0
- package/lib/js/schema/models_category/pb.json +162 -0
- package/lib/js/schema/models_category/st/det/enum_options.json +8 -0
- package/lib/js/schema/models_category/st/det/ml/enum_options.json +8 -0
- package/lib/js/schema/models_category/st/det/ml/re.json +171 -0
- package/lib/js/schema/models_category/st/det/ml.json +168 -0
- package/lib/js/schema/models_category/st/det.json +165 -0
- package/lib/js/schema/models_category/st/enum_options.json +8 -0
- package/lib/js/schema/models_category/st.json +162 -0
- package/lib/js/schema/models_directory/double_hybrid.json +387 -0
- package/lib/js/schema/models_directory/gga.json +401 -0
- package/lib/js/schema/models_directory/gw.json +415 -0
- package/lib/js/schema/models_directory/hybrid.json +400 -0
- package/lib/js/schema/models_directory/lda.json +400 -0
- package/lib/js/schema/models_directory/legacy/dft.json +154 -0
- package/lib/js/schema/models_directory/legacy/ml.json +55 -0
- package/lib/js/schema/models_directory/legacy/unknown.json +55 -0
- package/lib/js/schema/models_directory/mgga.json +400 -0
- package/lib/js/schema/models_directory/re.json +334 -0
- package/lib/js/schema/project.json +103 -0
- package/lib/js/schema/properties_directory/derived_properties.json +185 -0
- package/lib/js/schema/properties_directory/electronic_configuration.json +16 -0
- package/lib/js/schema/properties_directory/elemental/atomic_radius.json +35 -0
- package/lib/js/schema/properties_directory/elemental/electronegativity.json +20 -0
- package/lib/js/schema/properties_directory/elemental/ionization_potential.json +31 -0
- package/lib/js/schema/properties_directory/non_scalar/average_potential_profile.json +107 -0
- package/lib/js/schema/properties_directory/non_scalar/band_gaps.json +121 -0
- package/lib/js/schema/properties_directory/non_scalar/band_structure.json +118 -0
- package/lib/js/schema/properties_directory/non_scalar/charge_density_profile.json +88 -0
- package/lib/js/schema/properties_directory/non_scalar/density_of_states.json +123 -0
- package/lib/js/schema/properties_directory/non_scalar/dielectric_tensor.json +65 -0
- package/lib/js/schema/properties_directory/non_scalar/file_content.json +73 -0
- package/lib/js/schema/properties_directory/non_scalar/hubbard_u.json +56 -0
- package/lib/js/schema/properties_directory/non_scalar/hubbard_v.json +75 -0
- package/lib/js/schema/properties_directory/non_scalar/hubbard_v_nn.json +75 -0
- package/lib/js/schema/properties_directory/non_scalar/phonon_dispersions.json +103 -0
- package/lib/js/schema/properties_directory/non_scalar/phonon_dos.json +95 -0
- package/lib/js/schema/properties_directory/non_scalar/potential_profile.json +94 -0
- package/lib/js/schema/properties_directory/non_scalar/reaction_energy_profile.json +94 -0
- package/lib/js/schema/properties_directory/non_scalar/stress_tensor.json +36 -0
- package/lib/js/schema/properties_directory/non_scalar/total_energy_contributions.json +271 -0
- package/lib/js/schema/properties_directory/non_scalar/vibrational_spectrum.json +99 -0
- package/lib/js/schema/properties_directory/scalar/electron_affinity.json +42 -0
- package/lib/js/schema/properties_directory/scalar/fermi_energy.json +42 -0
- package/lib/js/schema/properties_directory/scalar/formation_energy.json +42 -0
- package/lib/js/schema/properties_directory/scalar/ionization_potential.json +42 -0
- package/lib/js/schema/properties_directory/scalar/pressure.json +26 -0
- package/lib/js/schema/properties_directory/scalar/reaction_energy_barrier.json +42 -0
- package/lib/js/schema/properties_directory/scalar/surface_energy.json +42 -0
- package/lib/js/schema/properties_directory/scalar/total_energy.json +42 -0
- package/lib/js/schema/properties_directory/scalar/total_force.json +29 -0
- package/lib/js/schema/properties_directory/scalar/valence_band_offset.json +42 -0
- package/lib/js/schema/properties_directory/scalar/zero_point_energy.json +42 -0
- package/lib/js/schema/properties_directory/structural/atomic_forces.json +65 -0
- package/lib/js/schema/properties_directory/structural/basis/atomic_constraints.json +55 -0
- package/lib/js/schema/properties_directory/structural/basis/atomic_coordinate.json +38 -0
- package/lib/js/schema/properties_directory/structural/basis/atomic_coordinates.json +68 -0
- package/lib/js/schema/properties_directory/structural/basis/atomic_element.json +26 -0
- package/lib/js/schema/properties_directory/structural/basis/bonds.json +42 -0
- package/lib/js/schema/properties_directory/structural/basis.json +127 -0
- package/lib/js/schema/properties_directory/structural/density.json +24 -0
- package/lib/js/schema/properties_directory/structural/elemental_ratio.json +26 -0
- package/lib/js/schema/properties_directory/structural/inchi.json +19 -0
- package/lib/js/schema/properties_directory/structural/inchi_key.json +19 -0
- package/lib/js/schema/properties_directory/structural/lattice/lattice_bravais.json +81 -0
- package/lib/js/schema/properties_directory/structural/lattice/lattice_vectors.json +63 -0
- package/lib/js/schema/properties_directory/structural/lattice/type_enum.json +22 -0
- package/lib/js/schema/properties_directory/structural/lattice/type_extended_enum.json +32 -0
- package/lib/js/schema/properties_directory/structural/lattice.json +148 -0
- package/lib/js/schema/properties_directory/structural/magnetic_moments.json +60 -0
- package/lib/js/schema/properties_directory/structural/molecular_pattern.json +111 -0
- package/lib/js/schema/properties_directory/structural/p_norm.json +24 -0
- package/lib/js/schema/properties_directory/structural/patterns/functional_group.json +36 -0
- package/lib/js/schema/properties_directory/structural/patterns/ring.json +35 -0
- package/lib/js/schema/properties_directory/structural/patterns/special_bond.json +33 -0
- package/lib/js/schema/properties_directory/structural/symmetry.json +40 -0
- package/lib/js/schema/properties_directory/structural/volume.json +24 -0
- package/lib/js/schema/properties_directory/workflow/convergence/electronic.json +32 -0
- package/lib/js/schema/properties_directory/workflow/convergence/ionic.json +62 -0
- package/lib/js/schema/properties_directory/workflow/convergence/kpoint.json +48 -0
- package/lib/js/schema/property/base.json +387 -0
- package/lib/js/schema/property/meta.json +387 -0
- package/lib/js/schema/property/raw.json +387 -0
- package/lib/js/schema/property/source.json +286 -0
- package/lib/js/schema/software/application.json +99 -0
- package/lib/js/schema/software/executable.json +208 -0
- package/lib/js/schema/software/flavor.json +228 -0
- package/lib/js/schema/software/template.json +103 -0
- package/lib/js/schema/software_directory/ml/exabyteml.json +23 -0
- package/lib/js/schema/software_directory/ml/unit/execution/evaluate/cross_validate.json +814 -0
- package/lib/js/schema/software_directory/ml/unit/execution/initialize.json +818 -0
- package/lib/js/schema/software_directory/ml/unit/execution/score.json +804 -0
- package/lib/js/schema/software_directory/ml/unit/execution/train.json +827 -0
- package/lib/js/schema/software_directory/ml/unit/execution.json +3264 -0
- package/lib/js/schema/software_directory/ml/unit/processing/data_transformation/manipulation.json +310 -0
- package/lib/js/schema/software_directory/ml/unit/processing/data_transformation/scale_and_reduce.json +330 -0
- package/lib/js/schema/software_directory/ml/unit/processing/data_transformation.json +334 -0
- package/lib/js/schema/software_directory/ml/unit/processing/feature_selection/filter_based.json +305 -0
- package/lib/js/schema/software_directory/ml/unit/processing/feature_selection.json +309 -0
- package/lib/js/schema/software_directory/ml/unit/processing.json +646 -0
- package/lib/js/schema/software_directory/modeling/deepmd.json +115 -0
- package/lib/js/schema/software_directory/modeling/espresso/arguments.json +44 -0
- package/lib/js/schema/software_directory/modeling/espresso.json +34 -0
- package/lib/js/schema/software_directory/modeling/nwchem.json +114 -0
- package/lib/js/schema/software_directory/modeling/unit/execution.json +847 -0
- package/lib/js/schema/software_directory/modeling/vasp.json +120 -0
- package/lib/js/schema/software_directory/scripting/jupyter_lab.json +118 -0
- package/lib/js/schema/software_directory/scripting/python.json +132 -0
- package/lib/js/schema/software_directory/scripting/shell.json +132 -0
- package/lib/js/schema/software_directory/scripting/unit/execution.json +847 -0
- package/lib/js/schema/system/_material.json +23 -0
- package/lib/js/schema/system/_parent_job.json +23 -0
- package/lib/js/schema/system/_project.json +23 -0
- package/lib/js/schema/system/bankable.json +16 -0
- package/lib/js/schema/system/consistency_check.json +39 -0
- package/lib/js/schema/system/creator.json +23 -0
- package/lib/js/schema/system/creator_account.json +27 -0
- package/lib/js/schema/system/database_source.json +38 -0
- package/lib/js/schema/system/defaultable.json +13 -0
- package/lib/js/schema/system/description.json +15 -0
- package/lib/js/schema/system/entity_reference.json +20 -0
- package/lib/js/schema/system/file_source.json +30 -0
- package/lib/js/schema/system/history.json +26 -0
- package/lib/js/schema/system/in_set.json +36 -0
- package/lib/js/schema/system/is_multi_material.json +11 -0
- package/lib/js/schema/system/is_outdated.json +11 -0
- package/lib/js/schema/system/job_extended.json +64 -0
- package/lib/js/schema/system/message.json +68 -0
- package/lib/js/schema/system/metadata.json +11 -0
- package/lib/js/schema/system/name.json +12 -0
- package/lib/js/schema/system/owner.json +23 -0
- package/lib/js/schema/system/path.json +14 -0
- package/lib/js/schema/system/path_entity.json +18 -0
- package/lib/js/schema/system/schema_version.json +13 -0
- package/lib/js/schema/system/scope.json +11 -0
- package/lib/js/schema/system/set.json +17 -0
- package/lib/js/schema/system/sharing.json +11 -0
- package/lib/js/schema/system/soft_removable.json +16 -0
- package/lib/js/schema/system/status.json +32 -0
- package/lib/js/schema/system/tags.json +15 -0
- package/lib/js/schema/system/timestampable.json +38 -0
- package/lib/js/schema/system/use_values.json +11 -0
- package/lib/js/schema/workflow/base.json +103 -0
- package/lib/js/schema/workflow/base_flow.json +218 -0
- package/lib/js/schema/workflow/scope.json +20 -0
- package/lib/js/schema/workflow/subworkflow/unit.json +2713 -0
- package/lib/js/schema/workflow/subworkflow.json +3087 -0
- package/lib/js/schema/workflow/unit/assertion.json +277 -0
- package/lib/js/schema/workflow/unit/assignment.json +314 -0
- package/lib/js/schema/workflow/unit/base.json +264 -0
- package/lib/js/schema/workflow/unit/condition.json +315 -0
- package/lib/js/schema/workflow/unit/execution.json +804 -0
- package/lib/js/schema/workflow/unit/input/_input.json +53 -0
- package/lib/js/schema/workflow/unit/input/_inputItem.json +20 -0
- package/lib/js/schema/workflow/unit/input/_inputItemId.json +19 -0
- package/lib/js/schema/workflow/unit/input/_inputItemScope.json +20 -0
- package/lib/js/schema/workflow/unit/input/_map_input/values.json +11 -0
- package/lib/js/schema/workflow/unit/input/_map_input.json +36 -0
- package/lib/js/schema/workflow/unit/io/api.json +24 -0
- package/lib/js/schema/workflow/unit/io/db.json +39 -0
- package/lib/js/schema/workflow/unit/io/object_storage.json +67 -0
- package/lib/js/schema/workflow/unit/io.json +418 -0
- package/lib/js/schema/workflow/unit/map.json +314 -0
- package/lib/js/schema/workflow/unit/processing.json +281 -0
- package/lib/js/schema/workflow/unit/reduce.json +297 -0
- package/lib/js/schema/workflow/unit/runtime/_runtime_item_full_object.json +15 -0
- package/lib/js/schema/workflow/unit/runtime/_runtime_item_name_object.json +15 -0
- package/lib/js/schema/workflow/unit/runtime/_runtime_item_string.json +7 -0
- package/lib/js/schema/workflow/unit/runtime/runtime_item.json +27 -0
- package/lib/js/schema/workflow/unit/runtime/runtime_items.json +128 -0
- package/lib/js/schema/workflow/unit/subworkflow.json +267 -0
- package/lib/js/schema/workflow/unit.json +3292 -0
- package/lib/js/schema/workflow.json +6492 -0
- package/lib/js/schemas.json +1 -0
- package/lib/js/scripts/compileTs.d.ts +1 -0
- package/lib/js/scripts/compileTs.js +79 -0
- package/lib/js/scripts/createEnumsFromYaml.d.ts +1 -0
- package/lib/js/scripts/createEnumsFromYaml.js +21 -67
- package/lib/js/scripts/setSchemaIds.d.ts +5 -0
- package/lib/js/scripts/setSchemaIds.js +26 -153
- package/lib/js/utils/ajv.d.ts +31 -0
- package/lib/js/utils/ajv.js +94 -0
- package/lib/js/utils/common.d.ts +6 -0
- package/lib/js/utils/common.js +15 -0
- package/lib/js/utils/filesystem.d.ts +2 -0
- package/lib/js/utils/filesystem.js +38 -0
- package/modules.d.ts +5 -0
- package/package.json +48 -23
- package/schema/3pse/file/applications/espresso/7.2/pw.x/atomic_positions.json +1 -1
- package/schema/3pse/file/applications/espresso/7.2/pw.x/atomic_species.json +1 -1
- package/schema/3pse/file/applications/espresso/7.2/pw.x/cell.json +1 -1
- package/schema/3pse/file/applications/espresso/7.2/pw.x/cell_parameters.json +1 -1
- package/schema/3pse/file/applications/espresso/7.2/pw.x/control.json +1 -1
- package/schema/3pse/file/applications/espresso/7.2/pw.x/electrons.json +1 -1
- package/schema/3pse/file/applications/espresso/7.2/pw.x/hubbard.json +1 -1
- package/schema/3pse/file/applications/espresso/7.2/pw.x/ions.json +1 -1
- package/schema/3pse/file/applications/espresso/7.2/pw.x/k_points.json +1 -1
- package/schema/3pse/file/applications/espresso/7.2/pw.x/system.json +9 -6
- package/schema/3pse/file/applications/espresso/7.2/pw.x.json +2 -1
- package/schema/core/abstract/2d_data.json +1 -1
- package/schema/core/abstract/2d_plot.json +2 -1
- package/schema/core/abstract/3d_grid.json +2 -1
- package/schema/core/abstract/3d_tensor.json +1 -1
- package/schema/core/abstract/3d_vector_basis.json +1 -1
- package/schema/core/abstract/point.json +1 -1
- package/schema/core/abstract/vector.json +1 -1
- package/schema/core/primitive/1d_data_series.json +1 -1
- package/schema/core/primitive/3d_lattice.json +1 -1
- package/schema/core/primitive/array_of_3_booleans.json +1 -1
- package/schema/core/primitive/array_of_3_numbers.json +1 -1
- package/schema/core/primitive/array_of_ids.json +2 -3
- package/schema/core/primitive/array_of_strings.json +1 -1
- package/schema/core/primitive/axis.json +2 -1
- package/schema/core/primitive/group_info.json +1 -1
- package/schema/core/primitive/integer_one_or_zero.json +1 -1
- package/schema/core/primitive/linked_list/base_node.json +1 -1
- package/schema/core/primitive/linked_list/named_node.json +1 -1
- package/schema/core/primitive/linked_list/named_node_in_group.json +1 -1
- package/schema/core/primitive/linked_list/node_with_type.json +1 -1
- package/schema/core/primitive/linked_list.json +1 -1
- package/schema/core/primitive/scalar.json +1 -1
- package/schema/core/primitive/slugified_entry.json +1 -1
- package/schema/core/primitive/slugified_entry_or_slug.json +1 -1
- package/schema/core/primitive/string.json +1 -1
- package/schema/core/reference/exabyte.json +1 -1
- package/schema/core/reference/experiment/condition.json +3 -1
- package/schema/core/reference/experiment/location.json +2 -1
- package/schema/core/reference/experiment.json +2 -1
- package/schema/core/reference/literature/name.json +1 -1
- package/schema/core/reference/literature/pages.json +1 -1
- package/schema/core/reference/literature.json +2 -1
- package/schema/core/reference/modeling/exabyte.json +2 -1
- package/schema/core/reference/modeling.json +1 -1
- package/schema/core/reference.json +1 -1
- package/schema/core/reusable/atomic_data/per_orbital.json +1 -1
- package/schema/core/reusable/atomic_data/per_orbital_pair.json +1 -1
- package/schema/core/reusable/atomic_data/value_number.json +1 -1
- package/schema/core/reusable/atomic_data/value_string.json +2 -2
- package/schema/core/reusable/atomic_data_per_orbital_numeric.json +2 -2
- package/schema/core/reusable/atomic_data_per_orbital_pair_numeric.json +2 -2
- package/schema/core/reusable/atomic_orbital.json +1 -1
- package/schema/core/reusable/atomic_scalars.json +2 -1
- package/schema/core/reusable/atomic_strings.json +1 -1
- package/schema/core/reusable/atomic_vectors.json +3 -1
- package/schema/core/reusable/band_gap.json +2 -1
- package/schema/core/reusable/categories.json +2 -2
- package/schema/core/reusable/category_path.json +1 -1
- package/schema/core/reusable/dielectric_tensor_component.json +2 -1
- package/schema/core/reusable/energy.json +2 -1
- package/schema/core/reusable/file_metadata.json +2 -1
- package/schema/core/reusable/frequency_function_matrix.json +1 -1
- package/schema/core/reusable/object_storage_container_data.json +2 -1
- package/schema/element.json +2 -1
- package/schema/in_memory_entity/base.json +2 -1
- package/schema/in_memory_entity/defaultable.json +1 -1
- package/schema/in_memory_entity/named.json +1 -1
- package/schema/in_memory_entity/named_defaultable.json +1 -1
- package/schema/in_memory_entity/named_defaultable_has_metadata.json +1 -1
- package/schema/in_memory_entity/named_defaultable_runtime_items.json +1 -1
- package/schema/job/base.json +3 -2
- package/schema/job/compute.json +6 -14
- package/schema/job.json +2 -1
- package/schema/material/conventional.json +2 -1
- package/schema/material.json +2 -1
- package/schema/method/categorized_method.json +2 -1
- package/schema/method/method_parameters.json +1 -1
- package/schema/method/unit_method.json +2 -1
- package/schema/method.json +2 -1
- package/schema/methods_category/mathematical/diff/fd.json +3 -2
- package/schema/methods_category/mathematical/diff.json +3 -2
- package/schema/methods_category/mathematical/discr/mesh/hybrid.json +3 -2
- package/schema/methods_category/mathematical/discr/mesh/nstruct.json +3 -2
- package/schema/methods_category/mathematical/discr/mesh/struct/cartesian.json +2 -1
- package/schema/methods_category/mathematical/discr/mesh/struct.json +3 -2
- package/schema/methods_category/mathematical/discr/mesh.json +3 -2
- package/schema/methods_category/mathematical/discr.json +3 -2
- package/schema/methods_category/mathematical/fapprx/basisexp.json +3 -2
- package/schema/methods_category/mathematical/fapprx/ipol/lin.json +3 -2
- package/schema/methods_category/mathematical/fapprx/ipol/poly.json +3 -2
- package/schema/methods_category/mathematical/fapprx/ipol/spline.json +3 -2
- package/schema/methods_category/mathematical/fapprx/ipol.json +3 -2
- package/schema/methods_category/mathematical/fapprx.json +3 -2
- package/schema/methods_category/mathematical/intgr/analytic/volume.json +3 -2
- package/schema/methods_category/mathematical/intgr/analytic.json +3 -2
- package/schema/methods_category/mathematical/intgr/diffeq/order1.json +3 -1
- package/schema/methods_category/mathematical/intgr/diffeq/order2.json +3 -1
- package/schema/methods_category/mathematical/intgr/diffeq.json +3 -2
- package/schema/methods_category/mathematical/intgr/numquad/gauss.json +3 -2
- package/schema/methods_category/mathematical/intgr/numquad/newcot.json +3 -2
- package/schema/methods_category/mathematical/intgr/numquad.json +3 -2
- package/schema/methods_category/mathematical/intgr/transf/fourier.json +3 -1
- package/schema/methods_category/mathematical/intgr/transf.json +3 -1
- package/schema/methods_category/mathematical/intgr.json +3 -2
- package/schema/methods_category/mathematical/linalg/dcomp.json +3 -2
- package/schema/methods_category/mathematical/linalg/diag/davidson.json +3 -2
- package/schema/methods_category/mathematical/linalg/diag.json +3 -2
- package/schema/methods_category/mathematical/linalg/lintra.json +3 -2
- package/schema/methods_category/mathematical/linalg/matf.json +3 -2
- package/schema/methods_category/mathematical/linalg.json +3 -2
- package/schema/methods_category/mathematical/opt/diff/bracket.json +3 -2
- package/schema/methods_category/mathematical/opt/diff/local.json +3 -2
- package/schema/methods_category/mathematical/opt/diff/order1.json +3 -2
- package/schema/methods_category/mathematical/opt/diff/order2.json +3 -2
- package/schema/methods_category/mathematical/opt/diff/ordern/cg.json +3 -2
- package/schema/methods_category/mathematical/opt/diff/ordern.json +3 -2
- package/schema/methods_category/mathematical/opt/diff.json +3 -2
- package/schema/methods_category/mathematical/opt/ndiff/direct.json +3 -2
- package/schema/methods_category/mathematical/opt/ndiff/pop.json +3 -2
- package/schema/methods_category/mathematical/opt/ndiff/stoch.json +3 -2
- package/schema/methods_category/mathematical/opt/ndiff.json +3 -2
- package/schema/methods_category/mathematical/opt/root/bracket.json +3 -2
- package/schema/methods_category/mathematical/opt/root/iter.json +3 -2
- package/schema/methods_category/mathematical/opt/root.json +3 -2
- package/schema/methods_category/mathematical/opt.json +3 -2
- package/schema/methods_category/mathematical/regression.json +2 -1
- package/schema/methods_category/physical/qm/wf/ao/dunning.json +3 -2
- package/schema/methods_category/physical/qm/wf/ao/other.json +3 -2
- package/schema/methods_category/physical/qm/wf/ao/pople.json +3 -2
- package/schema/methods_category/physical/qm/wf/ao.json +3 -2
- package/schema/methods_category/physical/qm/wf/psp.json +3 -2
- package/schema/methods_category/physical/qm/wf/pw.json +3 -2
- package/schema/methods_category/physical/qm/wf/smearing.json +2 -1
- package/schema/methods_category/physical/qm/wf/tetrahedron.json +3 -2
- package/schema/methods_category/physical/qm/wf.json +3 -2
- package/schema/methods_category/physical/qm.json +3 -2
- package/schema/methods_directory/legacy/localorbital.json +2 -1
- package/schema/methods_directory/legacy/pseudopotential.json +2 -1
- package/schema/methods_directory/legacy/regression.json +2 -1
- package/schema/methods_directory/legacy/unknown.json +2 -1
- package/schema/methods_directory/mathematical/cg.json +6 -3
- package/schema/methods_directory/mathematical/davidson.json +6 -3
- package/schema/methods_directory/mathematical/regression/data.json +1 -1
- package/schema/methods_directory/mathematical/regression/dataset.json +1 -1
- package/schema/methods_directory/mathematical/regression/kernel_ridge/data_per_property.json +2 -1
- package/schema/methods_directory/mathematical/regression/linear/data_per_property.json +2 -1
- package/schema/methods_directory/mathematical/regression/per_feature_item.json +2 -1
- package/schema/methods_directory/mathematical/regression/precision.json +1 -1
- package/schema/methods_directory/mathematical/regression/precision_per_property.json +1 -1
- package/schema/methods_directory/mathematical/regression.json +2 -1
- package/schema/methods_directory/physical/ao/dunning.json +6 -2
- package/schema/methods_directory/physical/ao/other.json +6 -2
- package/schema/methods_directory/physical/ao/pople.json +6 -2
- package/schema/methods_directory/physical/psp/file.json +5 -2
- package/schema/methods_directory/physical/psp/file_data_item.json +5 -2
- package/schema/methods_directory/physical/psp.json +5 -2
- package/schema/methods_directory/physical/pw.json +5 -2
- package/schema/methods_directory/physical/smearing.json +5 -2
- package/schema/methods_directory/physical/tetrahedron.json +5 -2
- package/schema/model/categorized_model.json +2 -1
- package/schema/model/mixins/dft/double_hybrid_functional.json +1 -1
- package/schema/model/mixins/dft/gga_functional.json +3 -2
- package/schema/model/mixins/dft/hybrid_functional.json +1 -1
- package/schema/model/mixins/dft/lda_functional.json +3 -2
- package/schema/model/mixins/dft/mgga_functional.json +3 -2
- package/schema/model/mixins/dispersion_correction.json +1 -1
- package/schema/model/mixins/hubbard.json +1 -1
- package/schema/model/mixins/spin_orbit_coupling.json +3 -2
- package/schema/model/mixins/spin_polarization.json +3 -2
- package/schema/model/model_parameters.json +2 -1
- package/schema/model/model_without_method.json +2 -1
- package/schema/model.json +2 -1
- package/schema/models_category/pb/qm/abin/gw.json +2 -1
- package/schema/models_category/pb/qm/abin.json +2 -1
- package/schema/models_category/pb/qm/dft/ksdft/double_hybrid.json +2 -1
- package/schema/models_category/pb/qm/dft/ksdft/gga.json +2 -1
- package/schema/models_category/pb/qm/dft/ksdft/hybrid.json +2 -1
- package/schema/models_category/pb/qm/dft/ksdft/lda.json +2 -1
- package/schema/models_category/pb/qm/dft/ksdft/mgga.json +2 -1
- package/schema/models_category/pb/qm/dft/ksdft.json +2 -1
- package/schema/models_category/pb/qm/dft.json +2 -1
- package/schema/models_category/pb/qm/semp.json +2 -1
- package/schema/models_category/pb/qm.json +2 -1
- package/schema/models_category/pb.json +2 -1
- package/schema/models_category/st/det/ml/re.json +2 -1
- package/schema/models_category/st/det/ml.json +1 -1
- package/schema/models_category/st/det.json +1 -1
- package/schema/models_category/st.json +2 -1
- package/schema/models_directory/double_hybrid.json +2 -1
- package/schema/models_directory/gga.json +2 -1
- package/schema/models_directory/gw.json +3 -1
- package/schema/models_directory/hybrid.json +2 -1
- package/schema/models_directory/lda.json +2 -1
- package/schema/models_directory/legacy/dft.json +2 -1
- package/schema/models_directory/legacy/ml.json +2 -1
- package/schema/models_directory/legacy/unknown.json +2 -1
- package/schema/models_directory/mgga.json +2 -1
- package/schema/models_directory/re.json +2 -1
- package/schema/project.json +1 -1
- package/schema/properties_directory/derived_properties.json +8 -2
- package/schema/properties_directory/electronic_configuration.json +1 -1
- package/schema/properties_directory/elemental/atomic_radius.json +2 -1
- package/schema/properties_directory/elemental/electronegativity.json +2 -1
- package/schema/properties_directory/elemental/ionization_potential.json +2 -1
- package/schema/properties_directory/non-scalar/average_potential_profile.json +2 -1
- package/schema/properties_directory/non-scalar/band_gaps.json +4 -1
- package/schema/properties_directory/non-scalar/band_structure.json +4 -1
- package/schema/properties_directory/non-scalar/charge_density_profile.json +4 -1
- package/schema/properties_directory/non-scalar/density_of_states.json +4 -1
- package/schema/properties_directory/non-scalar/dielectric_tensor.json +2 -1
- package/schema/properties_directory/non-scalar/file_content.json +2 -1
- package/schema/properties_directory/non-scalar/hubbard_u.json +11 -4
- package/schema/properties_directory/non-scalar/hubbard_v.json +12 -4
- package/schema/properties_directory/non-scalar/hubbard_v_nn.json +2 -1
- package/schema/properties_directory/non-scalar/phonon_dispersions.json +4 -1
- package/schema/properties_directory/non-scalar/phonon_dos.json +3 -1
- package/schema/properties_directory/non-scalar/potential_profile.json +4 -1
- package/schema/properties_directory/non-scalar/reaction_energy_profile.json +4 -1
- package/schema/properties_directory/non-scalar/stress_tensor.json +2 -1
- package/schema/properties_directory/non-scalar/total_energy_contributions.json +14 -1
- package/schema/properties_directory/non-scalar/vibrational_spectrum.json +3 -1
- package/schema/properties_directory/scalar/electron_affinity.json +2 -1
- package/schema/properties_directory/scalar/fermi_energy.json +2 -1
- package/schema/properties_directory/scalar/formation_energy.json +2 -1
- package/schema/properties_directory/scalar/ionization_potential.json +2 -1
- package/schema/properties_directory/scalar/pressure.json +2 -1
- package/schema/properties_directory/scalar/reaction_energy_barrier.json +2 -1
- package/schema/properties_directory/scalar/surface_energy.json +2 -1
- package/schema/properties_directory/scalar/total_energy.json +2 -1
- package/schema/properties_directory/scalar/total_force.json +2 -1
- package/schema/properties_directory/scalar/valence_band_offset.json +2 -1
- package/schema/properties_directory/scalar/zero_point_energy.json +2 -1
- package/schema/properties_directory/structural/atomic_forces.json +2 -1
- package/schema/properties_directory/structural/basis/atomic_constraints.json +2 -1
- package/schema/properties_directory/structural/basis/atomic_coordinate.json +2 -1
- package/schema/properties_directory/structural/basis/atomic_coordinates.json +1 -0
- package/schema/properties_directory/structural/basis/atomic_element.json +2 -1
- package/schema/properties_directory/structural/basis/bonds.json +2 -1
- package/schema/properties_directory/structural/basis.json +1 -1
- package/schema/properties_directory/structural/density.json +2 -1
- package/schema/properties_directory/structural/elemental_ratio.json +4 -3
- package/schema/properties_directory/structural/inchi.json +2 -1
- package/schema/properties_directory/structural/inchi_key.json +2 -1
- package/schema/properties_directory/structural/lattice/lattice_bravais.json +2 -1
- package/schema/properties_directory/structural/lattice/lattice_vectors.json +2 -1
- package/schema/properties_directory/structural/lattice/type_enum.json +1 -2
- package/schema/properties_directory/structural/lattice/type_extended_enum.json +1 -1
- package/schema/properties_directory/structural/lattice.json +1 -1
- package/schema/properties_directory/structural/magnetic_moments.json +2 -1
- package/schema/properties_directory/structural/molecular_pattern.json +1 -1
- package/schema/properties_directory/structural/p-norm.json +2 -1
- package/schema/properties_directory/structural/patterns/functional_group.json +3 -1
- package/schema/properties_directory/structural/patterns/ring.json +3 -1
- package/schema/properties_directory/structural/patterns/special_bond.json +3 -1
- package/schema/properties_directory/structural/symmetry.json +3 -1
- package/schema/properties_directory/structural/volume.json +2 -1
- package/schema/properties_directory/workflow/convergence/electronic.json +2 -1
- package/schema/properties_directory/workflow/convergence/ionic.json +3 -1
- package/schema/properties_directory/workflow/convergence/kpoint.json +3 -1
- package/schema/property/base.json +2 -1
- package/schema/property/meta.json +2 -1
- package/schema/property/raw.json +2 -1
- package/schema/property/source.json +1 -1
- package/schema/software/application.json +7 -9
- package/schema/software/executable.json +3 -4
- package/schema/software/flavor.json +3 -11
- package/schema/software/template.json +4 -2
- package/schema/software_directory/ml/exabyteml.json +1 -1
- package/schema/software_directory/ml/unit/execution/evaluate/cross-validate.json +2 -1
- package/schema/software_directory/ml/unit/execution/initialize.json +2 -1
- package/schema/software_directory/ml/unit/execution/score.json +2 -1
- package/schema/software_directory/ml/unit/execution/train.json +2 -1
- package/schema/software_directory/ml/unit/processing/data_transformation/manipulation.json +1 -1
- package/schema/software_directory/ml/unit/processing/data_transformation/scale_and_reduce.json +2 -2
- package/schema/software_directory/ml/unit/processing/feature_selection/filter_based.json +1 -1
- package/schema/software_directory/modeling/deepmd.json +1 -1
- package/schema/software_directory/modeling/espresso/arguments.json +1 -1
- package/schema/software_directory/modeling/espresso.json +1 -1
- package/schema/software_directory/modeling/nwchem.json +1 -1
- package/schema/software_directory/modeling/unit/execution.json +1 -1
- package/schema/software_directory/modeling/vasp.json +1 -1
- package/schema/software_directory/scripting/jupyter-lab.json +1 -1
- package/schema/software_directory/scripting/python.json +1 -1
- package/schema/software_directory/scripting/shell.json +1 -1
- package/schema/software_directory/scripting/unit/execution.json +1 -1
- package/schema/system/_material.json +2 -1
- package/schema/system/_parent_job.json +2 -1
- package/schema/system/_project.json +2 -1
- package/schema/system/bankable.json +2 -1
- package/schema/system/consistency_check.json +1 -1
- package/schema/system/creator.json +2 -1
- package/schema/system/creator_account.json +2 -1
- package/schema/system/database_source.json +6 -8
- package/schema/system/defaultable.json +2 -1
- package/schema/system/description.json +2 -1
- package/schema/system/entity_reference.json +2 -1
- package/schema/system/file_source.json +1 -1
- package/schema/system/history.json +2 -1
- package/schema/system/in_set.json +2 -1
- package/schema/system/is_multi_material.json +2 -1
- package/schema/system/is_outdated.json +2 -1
- package/schema/system/job_extended.json +2 -1
- package/schema/system/message.json +2 -1
- package/schema/system/metadata.json +2 -1
- package/schema/system/name.json +2 -1
- package/schema/system/owner.json +2 -1
- package/schema/system/path.json +1 -1
- package/schema/system/path_entity.json +1 -1
- package/schema/system/schema_version.json +2 -1
- package/schema/system/scope.json +2 -1
- package/schema/system/set.json +2 -1
- package/schema/system/sharing.json +2 -1
- package/schema/system/soft_removable.json +2 -1
- package/schema/system/status.json +2 -1
- package/schema/system/tags.json +2 -1
- package/schema/system/timestampable.json +2 -1
- package/schema/system/use_values.json +2 -1
- package/schema/workflow/base.json +1 -1
- package/schema/workflow/base_flow.json +9 -2
- package/schema/workflow/scope.json +1 -1
- package/schema/workflow/subworkflow/unit.json +35 -0
- package/schema/workflow/subworkflow.json +2 -2
- package/schema/workflow/unit/assertion.json +2 -2
- package/schema/workflow/unit/assignment.json +16 -3
- package/schema/workflow/unit/base.json +68 -0
- package/schema/workflow/unit/condition.json +2 -2
- package/schema/workflow/unit/execution.json +2 -2
- package/schema/workflow/unit/input/_input.json +1 -1
- package/schema/workflow/unit/input/_inputItem.json +1 -1
- package/schema/workflow/unit/input/_inputItemId.json +2 -4
- package/schema/workflow/unit/input/_inputItemScope.json +1 -1
- package/schema/workflow/unit/input/_map_input/values.json +11 -0
- package/schema/workflow/unit/input/_map_input.json +36 -0
- package/schema/workflow/unit/io/api.json +1 -1
- package/schema/workflow/unit/io/db.json +1 -1
- package/schema/workflow/unit/io/object_storage.json +2 -2
- package/schema/workflow/unit/io.json +2 -2
- package/schema/workflow/unit/map.json +2 -2
- package/schema/workflow/unit/processing.json +2 -2
- package/schema/workflow/unit/reduce.json +2 -2
- package/schema/workflow/unit/runtime/_runtime_item_full_object.json +1 -1
- package/schema/workflow/unit/runtime/_runtime_item_name_object.json +1 -1
- package/schema/workflow/unit/runtime/_runtime_item_string.json +1 -1
- package/schema/workflow/unit/runtime/runtime_item.json +1 -1
- package/schema/workflow/unit/runtime/runtime_items.json +1 -1
- package/schema/workflow/unit/subworkflow.json +18 -0
- package/schema/workflow/unit.json +22 -46
- package/schema/workflow.json +2 -30
- package/set_schema_ids.ts +3 -0
- package/src/js/esse/JSONSchemasGenerator.ts +94 -0
- package/src/js/esse/JSONSchemasInterface.ts +56 -0
- package/src/js/esse/JSONSchemasInterfaceServer.ts +49 -0
- package/src/js/esse/schemaUtils.ts +28 -0
- package/src/js/esse/types.ts +3 -0
- package/src/js/esse/utils.ts +72 -0
- package/src/js/json_include/{index.js → index.ts} +22 -21
- package/src/js/scripts/compileTs.ts +84 -0
- package/src/js/scripts/{createEnumsFromYaml.mjs → createEnumsFromYaml.ts} +5 -19
- package/src/js/scripts/setSchemaIds.ts +28 -0
- package/src/js/utils/ajv.ts +119 -0
- package/src/js/utils/common.ts +15 -0
- package/src/js/utils/filesystem.ts +34 -0
- package/tsconfig.json +34 -0
- package/example/workflow/unit.json +0 -8
- package/lib/js/esse/index.js +0 -101
- package/lib/js/json_include/utils.js +0 -22
- package/src/js/esse/index.js +0 -57
- package/src/js/esse/schemaUtils.js +0 -45
- package/src/js/esse/utils.js +0 -52
- package/src/js/json_include/utils.js +0 -11
- package/src/js/scripts/setSchemaIds.mjs +0 -34
- /package/src/js/esse/{settings.js → settings.ts} +0 -0
- /package/src/js/json_include/{settings.js → settings.ts} +0 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/* eslint-disable class-methods-use-this */
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import yaml from "js-yaml";
|
|
4
|
+
import mergeAllOf from "json-schema-merge-allof";
|
|
5
|
+
import path from "path";
|
|
6
|
+
|
|
7
|
+
import { EXAMPLES_DIR, PROPERTIES_MANIFEST_PATH, SCHEMAS_DIR } from "./settings";
|
|
8
|
+
import { JSONSchema, JSONSchemaWithPath, parseIncludeReferenceStatementsByDir } from "./utils";
|
|
9
|
+
|
|
10
|
+
interface JSONSchemasGeneratorConfig {
|
|
11
|
+
schemasDir: string;
|
|
12
|
+
examplesDir?: string;
|
|
13
|
+
propertiesManifestDir?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const DEFAULT_CONFIG = {
|
|
17
|
+
schemasDir: SCHEMAS_DIR,
|
|
18
|
+
examplesDir: EXAMPLES_DIR,
|
|
19
|
+
propertiesManifestDir: PROPERTIES_MANIFEST_PATH,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default class JSONSchemasGenerator implements JSONSchemasGeneratorConfig {
|
|
23
|
+
readonly schemas: JSONSchema[];
|
|
24
|
+
|
|
25
|
+
readonly examples?: JSONSchema[];
|
|
26
|
+
|
|
27
|
+
readonly wrappedExamples: JSONSchemaWithPath[];
|
|
28
|
+
|
|
29
|
+
readonly propertiesManifest: object;
|
|
30
|
+
|
|
31
|
+
readonly results: object;
|
|
32
|
+
|
|
33
|
+
readonly schemasDir: string;
|
|
34
|
+
|
|
35
|
+
readonly examplesDir?: string;
|
|
36
|
+
|
|
37
|
+
readonly propertiesManifestDir?: string;
|
|
38
|
+
|
|
39
|
+
constructor(config: JSONSchemasGeneratorConfig = DEFAULT_CONFIG) {
|
|
40
|
+
this.schemasDir = config.schemasDir;
|
|
41
|
+
this.examplesDir = config.examplesDir;
|
|
42
|
+
this.propertiesManifestDir = config.propertiesManifestDir;
|
|
43
|
+
|
|
44
|
+
this.schemas = parseIncludeReferenceStatementsByDir(this.schemasDir);
|
|
45
|
+
|
|
46
|
+
this.wrappedExamples = this.examplesDir
|
|
47
|
+
? parseIncludeReferenceStatementsByDir(this.examplesDir, true)
|
|
48
|
+
: [];
|
|
49
|
+
|
|
50
|
+
this.examples = this.wrappedExamples.map((example) => example.data);
|
|
51
|
+
|
|
52
|
+
this.propertiesManifest = this.propertiesManifestDir
|
|
53
|
+
? (yaml.load(fs.readFileSync(this.propertiesManifestDir, "utf-8")) as object)
|
|
54
|
+
: {};
|
|
55
|
+
|
|
56
|
+
this.results = Object.entries(this.propertiesManifest)
|
|
57
|
+
.map((k) => (k[1].isResult ? k[0] : null))
|
|
58
|
+
.filter((x) => x) as object;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
writeResolvedSchemas(subfolder: string, skipMergeAllOff = false) {
|
|
62
|
+
const schemasFolder = `${subfolder}/schema`;
|
|
63
|
+
fs.rmSync(schemasFolder, { recursive: true, force: true });
|
|
64
|
+
|
|
65
|
+
const mergeAllOfConfig = {
|
|
66
|
+
resolvers: { defaultResolver: mergeAllOf.options.resolvers.title },
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const schemas = this.schemas.map((schema) => {
|
|
70
|
+
console.log(`Resolving schema: ${schema.$id}`);
|
|
71
|
+
const mergedSchema = skipMergeAllOff ? schema : mergeAllOf(schema, mergeAllOfConfig);
|
|
72
|
+
const idAsPath = mergedSchema.$id?.replace(/-/g, "_");
|
|
73
|
+
const fullPath = `${schemasFolder}/${idAsPath}.json`;
|
|
74
|
+
|
|
75
|
+
fs.mkdirSync(path.dirname(fullPath), { recursive: true });
|
|
76
|
+
fs.writeFileSync(fullPath, JSON.stringify(mergedSchema, null, 4), "utf8");
|
|
77
|
+
|
|
78
|
+
return mergedSchema;
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
fs.writeFileSync(`${subfolder}/schemas.json`, `${JSON.stringify(schemas)}`);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
writeResolvedExamples(subfolder: string) {
|
|
85
|
+
const examplesFolder = `${subfolder}/example`;
|
|
86
|
+
fs.rmSync(`${examplesFolder}`, { recursive: true, force: true });
|
|
87
|
+
this.wrappedExamples.forEach((e) => {
|
|
88
|
+
const idAsPath = e.path.replace(/-/g, "_");
|
|
89
|
+
const fullPath = `${examplesFolder}/${idAsPath}.json`;
|
|
90
|
+
fs.mkdirSync(path.dirname(fullPath), { recursive: true });
|
|
91
|
+
fs.writeFileSync(fullPath, JSON.stringify(e.data, null, 4), "utf8");
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { JSONSchema } from "./utils";
|
|
2
|
+
|
|
3
|
+
export type JSONSchemasInterfaceQuery = { [key in keyof JSONSchema]: { $regex: string } };
|
|
4
|
+
|
|
5
|
+
export default class JSONSchemasInterface {
|
|
6
|
+
static schemasCache = new Map<string, JSONSchema>();
|
|
7
|
+
|
|
8
|
+
static setSchemas(schema: JSONSchema[]) {
|
|
9
|
+
schema.forEach((schema) => this.addSchema(schema));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
static addSchema(schema: JSONSchema) {
|
|
13
|
+
if (schema.$id) {
|
|
14
|
+
this.schemasCache.set(schema.$id, schema);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static getSchemaById(schemaId: string) {
|
|
19
|
+
return this.schemasCache.get(schemaId);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @example <caption>Search by $id regex</caption>
|
|
24
|
+
* JSONSchemasInterface.matchSchema({
|
|
25
|
+
* $id: {
|
|
26
|
+
* $regex: 'software-application'
|
|
27
|
+
* }
|
|
28
|
+
* })
|
|
29
|
+
*
|
|
30
|
+
* @example <caption>Search by $id and title regex</caption>
|
|
31
|
+
* JSONSchemasInterface.matchSchema({
|
|
32
|
+
* $id: {
|
|
33
|
+
* $regex: 'software-application'
|
|
34
|
+
* },
|
|
35
|
+
* title: {
|
|
36
|
+
* $regex: 'application'
|
|
37
|
+
* }
|
|
38
|
+
* })
|
|
39
|
+
*/
|
|
40
|
+
static matchSchema(query: JSONSchemasInterfaceQuery) {
|
|
41
|
+
const searchFields = Object.keys(query) as Array<keyof typeof query>;
|
|
42
|
+
|
|
43
|
+
return Array.from(this.schemasCache.values()).find((schema) => {
|
|
44
|
+
return searchFields.every((field) => {
|
|
45
|
+
const queryField = query[field];
|
|
46
|
+
const schemaField = schema[field];
|
|
47
|
+
|
|
48
|
+
if (!queryField || typeof schemaField !== "string") {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return new RegExp(queryField.$regex).test(schemaField);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { SchemaObject } from "ajv";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
|
|
5
|
+
import { walkDirSync } from "../utils/filesystem";
|
|
6
|
+
import JSONSchemasInterface from "./JSONSchemasInterface";
|
|
7
|
+
|
|
8
|
+
export function readSchemaFolderSync(folderPath: string) {
|
|
9
|
+
const schemas: SchemaObject[] = [];
|
|
10
|
+
|
|
11
|
+
walkDirSync(folderPath, (filePath: string) => {
|
|
12
|
+
if (path.extname(filePath) !== ".json") {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const schema = JSON.parse(fs.readFileSync(filePath).toString());
|
|
16
|
+
schemas.push(schema);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
return schemas;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default class JSONSchemasInterfaceServer extends JSONSchemasInterface {
|
|
23
|
+
static schemaFolder = path.resolve(__dirname, "./../schema");
|
|
24
|
+
|
|
25
|
+
static setSchemaFolder(schemaFolder: string) {
|
|
26
|
+
if (this.schemaFolder !== schemaFolder) {
|
|
27
|
+
this.schemaFolder = schemaFolder;
|
|
28
|
+
this.readSchemaFolder();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
static readSchemaFolder() {
|
|
33
|
+
const schemas = readSchemaFolderSync(this.schemaFolder);
|
|
34
|
+
|
|
35
|
+
schemas.forEach((schema) => {
|
|
36
|
+
if (schema.$id) {
|
|
37
|
+
this.schemasCache.set(schema.$id, schema);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
static getSchemaById(schemaId: string) {
|
|
43
|
+
if (this.schemasCache.size === 0) {
|
|
44
|
+
this.readSchemaFolder();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return super.getSchemaById(schemaId);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { JSONSchema, JSONSchemaDefinition } from "./utils";
|
|
2
|
+
|
|
3
|
+
export type MapSchema = (prop: JSONSchemaDefinition) => JSONSchemaDefinition | undefined;
|
|
4
|
+
|
|
5
|
+
export function mapObjectDeep(object: JSONSchemaDefinition, mapValue: MapSchema): JSONSchema;
|
|
6
|
+
|
|
7
|
+
export function mapObjectDeep(object: JSONSchemaDefinition[], mapValue: MapSchema): JSONSchema[];
|
|
8
|
+
|
|
9
|
+
export function mapObjectDeep(
|
|
10
|
+
object: JSONSchemaDefinition | JSONSchemaDefinition[],
|
|
11
|
+
mapValue: MapSchema,
|
|
12
|
+
): JSONSchemaDefinition | JSONSchemaDefinition[] {
|
|
13
|
+
if (typeof object !== "object" || object === null) {
|
|
14
|
+
return object;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (Array.isArray(object)) {
|
|
18
|
+
return object.map((innerValue) => mapObjectDeep(innerValue, mapValue));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const mappedObject = mapValue(object) || object;
|
|
22
|
+
|
|
23
|
+
const entries = Object.entries(mappedObject).map(([key, value]) => {
|
|
24
|
+
return [key, mapObjectDeep(value, mapValue)];
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
return Object.fromEntries(entries);
|
|
28
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { JSONSchema7, JSONSchema7Definition } from "json-schema";
|
|
2
|
+
import deref from "json-schema-deref-sync";
|
|
3
|
+
import path from "path";
|
|
4
|
+
|
|
5
|
+
import { JSONInclude } from "../json_include";
|
|
6
|
+
import { walkDirSync } from "../utils/filesystem";
|
|
7
|
+
|
|
8
|
+
export type JSONSchema = JSONSchema7;
|
|
9
|
+
|
|
10
|
+
export type JSONSchemaDefinition = JSONSchema7Definition;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Resolves `include` and `$ref` statements.
|
|
14
|
+
* @param filePath {String} file to parse.
|
|
15
|
+
*/
|
|
16
|
+
export function parseIncludeReferenceStatements(filePath: string): JSONSchema {
|
|
17
|
+
const jsonResolver = new JSONInclude();
|
|
18
|
+
const parsed = jsonResolver.parseIncludeStatements(filePath);
|
|
19
|
+
const dirPath = path.dirname(filePath);
|
|
20
|
+
let dereferenced = deref(parsed, { baseFolder: dirPath, removeIds: true });
|
|
21
|
+
// handle circular references and use non-dereferenced source
|
|
22
|
+
if (dereferenced instanceof Error && dereferenced.message === "Circular self reference") {
|
|
23
|
+
dereferenced = parsed as JSONSchema;
|
|
24
|
+
}
|
|
25
|
+
return dereferenced;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface JSONSchemaWithPath {
|
|
29
|
+
data: JSONSchema;
|
|
30
|
+
path: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function parseIncludeReferenceStatementsByDir(
|
|
34
|
+
dirPath: string,
|
|
35
|
+
wrapInDataAndPath: true,
|
|
36
|
+
): JSONSchemaWithPath[];
|
|
37
|
+
|
|
38
|
+
export function parseIncludeReferenceStatementsByDir(
|
|
39
|
+
dirPath: string,
|
|
40
|
+
wrapInDataAndPath?: false,
|
|
41
|
+
): JSONSchema[];
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Resolves `include` and `$ref` statements for all the JSON files inside a given directory.
|
|
45
|
+
* @param dirPath directory to parse.
|
|
46
|
+
*/
|
|
47
|
+
export function parseIncludeReferenceStatementsByDir(dirPath: string, wrapInDataAndPath = false) {
|
|
48
|
+
const schemas: JSONSchema[] = [];
|
|
49
|
+
const schemasWithPath: JSONSchemaWithPath[] = [];
|
|
50
|
+
const topDir = path.resolve(__dirname, "../../../");
|
|
51
|
+
|
|
52
|
+
walkDirSync(dirPath, (filePath) => {
|
|
53
|
+
if (filePath.endsWith(".json")) {
|
|
54
|
+
const config = parseIncludeReferenceStatements(filePath);
|
|
55
|
+
if (wrapInDataAndPath) {
|
|
56
|
+
const _path = path.join(
|
|
57
|
+
// remove leading slashes and "example" from path
|
|
58
|
+
path
|
|
59
|
+
.dirname(filePath)
|
|
60
|
+
.replace(path.join(topDir, "example"), "")
|
|
61
|
+
.replace(/^\/+/, ""),
|
|
62
|
+
path.basename(filePath).replace(".json", ""),
|
|
63
|
+
);
|
|
64
|
+
schemasWithPath.push({ data: config, path: _path });
|
|
65
|
+
} else {
|
|
66
|
+
schemas.push(config);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
return wrapInDataAndPath ? schemasWithPath : schemas;
|
|
72
|
+
}
|
|
@@ -1,31 +1,37 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
3
|
|
|
4
|
+
import { AnyObject } from "../esse/types";
|
|
5
|
+
import { isInstanceOf, safeParseJSON } from "../utils/common";
|
|
4
6
|
import { INCLUDE_KEY, INCLUDE_VALUE_REGEX, OBJECT_ONLY } from "./settings";
|
|
5
|
-
import { isInstanceOf, safeParseJSON } from "./utils";
|
|
6
7
|
|
|
7
8
|
export class JSONInclude {
|
|
8
|
-
|
|
9
|
-
this.JSON_INCLUDE_CACHE = {};
|
|
10
|
-
}
|
|
9
|
+
JSON_INCLUDE_CACHE: AnyObject = {};
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
12
|
* Extracts file name(path) from the include statement.
|
|
14
|
-
* @param value
|
|
13
|
+
* @param value string to extract the file name from.
|
|
15
14
|
*/
|
|
16
|
-
_getIncludeFileName = (value) => {
|
|
17
|
-
if (
|
|
18
|
-
|
|
15
|
+
_getIncludeFileName = (value: unknown) => {
|
|
16
|
+
if (typeof value === "string" && value.search(INCLUDE_VALUE_REGEX) !== -1) {
|
|
17
|
+
const matched = value.match(INCLUDE_VALUE_REGEX);
|
|
18
|
+
return matched && matched[1];
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Walks a nested object to resolve include statements.
|
|
24
|
-
* @param obj
|
|
25
|
-
* @param dirpath
|
|
24
|
+
* @param obj Object to traverse.
|
|
25
|
+
* @param dirpath directory from which `obj` is obtained. Include statements are relative to `obj` path.
|
|
26
26
|
*/
|
|
27
|
-
_walkObjectToInclude(obj, dirpath) {
|
|
28
|
-
if (isInstanceOf(obj, "
|
|
27
|
+
_walkObjectToInclude(obj: AnyObject | AnyObject[], dirpath: string) {
|
|
28
|
+
if (isInstanceOf(obj, "Array")) {
|
|
29
|
+
for (let i = 0; i < obj.length; i++) {
|
|
30
|
+
if (isInstanceOf(obj[i], "Object") || isInstanceOf(obj[i], "Array")) {
|
|
31
|
+
this._walkObjectToInclude(obj[i], dirpath);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
} else if (isInstanceOf(obj, "Object")) {
|
|
29
35
|
if (INCLUDE_KEY in obj) {
|
|
30
36
|
const includeName = this._getIncludeFileName(obj[INCLUDE_KEY]);
|
|
31
37
|
if (includeName) {
|
|
@@ -36,6 +42,7 @@ export class JSONInclude {
|
|
|
36
42
|
this.parseIncludeStatements(filePath);
|
|
37
43
|
}
|
|
38
44
|
Object.keys(this.JSON_INCLUDE_CACHE[includeName]).forEach((attr) => {
|
|
45
|
+
// @ts-ignore
|
|
39
46
|
obj[attr] = this.JSON_INCLUDE_CACHE[includeName][attr];
|
|
40
47
|
});
|
|
41
48
|
}
|
|
@@ -45,21 +52,15 @@ export class JSONInclude {
|
|
|
45
52
|
this._walkObjectToInclude(obj[key], dirpath);
|
|
46
53
|
}
|
|
47
54
|
});
|
|
48
|
-
} else if (isInstanceOf(obj, "Array")) {
|
|
49
|
-
for (let i = 0; i < obj.length; i++) {
|
|
50
|
-
if (isInstanceOf(obj[i], "Object") || isInstanceOf(obj[i], "Array")) {
|
|
51
|
-
this._walkObjectToInclude(obj[i], dirpath);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
/**
|
|
58
59
|
* Resolves `include` statements.
|
|
59
|
-
* @param filePath
|
|
60
|
+
* @param filePath file to parse.
|
|
60
61
|
*/
|
|
61
|
-
parseIncludeStatements(filePath) {
|
|
62
|
-
const data = safeParseJSON(fs.readFileSync(filePath, "utf8"));
|
|
62
|
+
parseIncludeStatements(filePath: string) {
|
|
63
|
+
const data: AnyObject[] = safeParseJSON(fs.readFileSync(filePath, "utf8"));
|
|
63
64
|
if (OBJECT_ONLY && !isInstanceOf(data, "Object")) {
|
|
64
65
|
throw new Error(
|
|
65
66
|
"The JSON file being included should always be a dict rather than a list",
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { SchemaObject } from "ajv";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import { compile } from "json-schema-to-typescript";
|
|
4
|
+
|
|
5
|
+
import { mapObjectDeep } from "../esse/schemaUtils";
|
|
6
|
+
import { JSONSchema } from "../esse/utils";
|
|
7
|
+
import { walkDir } from "../utils/filesystem";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* By definition, the "compile" function will generate 2 schemas based on the following input:
|
|
11
|
+
* {
|
|
12
|
+
* "title": "schema1",
|
|
13
|
+
* "type": "object",
|
|
14
|
+
* "properties": {
|
|
15
|
+
* "prop": {
|
|
16
|
+
* "title": "schema2",
|
|
17
|
+
* "type": "string"
|
|
18
|
+
* }
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
*
|
|
22
|
+
* Result:
|
|
23
|
+
* type schema2 = string;
|
|
24
|
+
*
|
|
25
|
+
* interface schema1 {
|
|
26
|
+
* prop: schema2
|
|
27
|
+
* }
|
|
28
|
+
*
|
|
29
|
+
* To disable this behavior we need to remove "title" property from the "prop":
|
|
30
|
+
* {
|
|
31
|
+
* "title": "schema1",
|
|
32
|
+
* "type": "object",
|
|
33
|
+
* "properties": {
|
|
34
|
+
* "prop": {
|
|
35
|
+
* "type": "string"
|
|
36
|
+
* }
|
|
37
|
+
* }
|
|
38
|
+
* }
|
|
39
|
+
*
|
|
40
|
+
* New result:
|
|
41
|
+
* interface schema1 {
|
|
42
|
+
* prop: string;
|
|
43
|
+
* }
|
|
44
|
+
* @returns Clean schema
|
|
45
|
+
*/
|
|
46
|
+
function cleanSchema(schema: JSONSchema): JSONSchema {
|
|
47
|
+
let firstRun = true;
|
|
48
|
+
|
|
49
|
+
return mapObjectDeep(schema, (object) => {
|
|
50
|
+
if (typeof object === "object" && object?.title && !firstRun) {
|
|
51
|
+
firstRun = false;
|
|
52
|
+
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
54
|
+
const { title, $schema, ...restObject } = object as SchemaObject;
|
|
55
|
+
return restObject;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
firstRun = false;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export default async function compileTS(schemaPath: string, savePath: string) {
|
|
63
|
+
try {
|
|
64
|
+
await fs.promises.unlink(savePath);
|
|
65
|
+
} catch (err) {
|
|
66
|
+
console.log("File with types not exists");
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
await walkDir(schemaPath, async (filePath) => {
|
|
70
|
+
const data = await fs.promises.readFile(filePath, "utf8");
|
|
71
|
+
const schema = cleanSchema(JSON.parse(data));
|
|
72
|
+
|
|
73
|
+
console.log(`Compiling Typescript: ${filePath}`);
|
|
74
|
+
|
|
75
|
+
// @ts-ignore
|
|
76
|
+
const compiledSchema = await compile(schema, schema.title || "", {
|
|
77
|
+
unreachableDefinitions: true,
|
|
78
|
+
additionalProperties: false,
|
|
79
|
+
bannerComment: `/** Schema ${filePath} */`,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
await fs.promises.appendFile(savePath, `${compiledSchema} \n`, { flag: "a+" });
|
|
83
|
+
});
|
|
84
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
/* eslint-disable no-restricted-syntax */
|
|
2
1
|
import fs from "fs";
|
|
3
2
|
import yaml from "js-yaml";
|
|
4
|
-
import path from "path";
|
|
5
3
|
import lodash from "lodash";
|
|
4
|
+
import path from "path";
|
|
5
|
+
|
|
6
|
+
import { walkDir } from "../utils/filesystem";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* We use YAML files to list enum options which need to be reused in other places.
|
|
@@ -12,22 +13,7 @@ import lodash from "lodash";
|
|
|
12
13
|
|
|
13
14
|
const SCHEMA_DIR = "../../../schema/";
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
const subDirs = fs.readdirSync(dir);
|
|
17
|
-
|
|
18
|
-
for (const subDir of subDirs) {
|
|
19
|
-
const itemPath = path.join(dir, subDir);
|
|
20
|
-
const stat = fs.statSync(itemPath);
|
|
21
|
-
|
|
22
|
-
if (stat.isDirectory()) {
|
|
23
|
-
walkDir(itemPath, callback);
|
|
24
|
-
} else {
|
|
25
|
-
callback(itemPath);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
walkDir(SCHEMA_DIR, (filePath) => {
|
|
16
|
+
walkDir(SCHEMA_DIR, (filePath: string) => {
|
|
31
17
|
if (path.extname(filePath) !== ".yml") {
|
|
32
18
|
return;
|
|
33
19
|
}
|
|
@@ -36,7 +22,7 @@ walkDir(SCHEMA_DIR, (filePath) => {
|
|
|
36
22
|
const dirname = path.dirname(filePath);
|
|
37
23
|
|
|
38
24
|
const fileContents = fs.readFileSync(filePath);
|
|
39
|
-
const obj = yaml.load(fileContents);
|
|
25
|
+
const obj = yaml.load(fileContents.toString()) as object;
|
|
40
26
|
const enumObj = lodash.mapValues(obj, (value) => ({ enum: value }));
|
|
41
27
|
|
|
42
28
|
fs.writeFileSync(`${path.join(dirname, outFilename)}`, `${JSON.stringify(enumObj, null, 4)}\n`);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
import { walkDirSync } from "../utils/filesystem";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Helper script.
|
|
8
|
+
* Applies correct $id to all schemas based on the schema path
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export default function setSchemaIds(schemaDir: string) {
|
|
12
|
+
walkDirSync(schemaDir, (filePath) => {
|
|
13
|
+
if (path.extname(filePath) !== ".json") {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const fileContents = fs.readFileSync(filePath);
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
19
|
+
const { $id, ...schema } = JSON.parse(fileContents.toString());
|
|
20
|
+
const schemaId = filePath.replace(schemaDir, "").replace(".json", "").replace(/_/g, "-");
|
|
21
|
+
if ($id !== schemaId) {
|
|
22
|
+
console.log(`Set correct $id: ${filePath}`);
|
|
23
|
+
const newContent = JSON.stringify({ $id: schemaId, ...schema }, null, 4);
|
|
24
|
+
|
|
25
|
+
fs.writeFileSync(filePath, `${newContent}\n`);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type {} from "ajv"; // @see https://github.com/microsoft/TypeScript/issues/47663
|
|
2
|
+
import Ajv, { SchemaObject } from "ajv";
|
|
3
|
+
import { AnyValidateFunction } from "ajv/dist/core";
|
|
4
|
+
|
|
5
|
+
import { mapObjectDeep } from "../esse/schemaUtils";
|
|
6
|
+
import { AnyObject } from "../esse/types";
|
|
7
|
+
import { JSONSchema } from "../esse/utils";
|
|
8
|
+
|
|
9
|
+
function addAdditionalPropertiesToSchema(schema: JSONSchema, additionalProperties = false) {
|
|
10
|
+
return mapObjectDeep(schema, (object) => {
|
|
11
|
+
const schema = object as JSONSchema;
|
|
12
|
+
|
|
13
|
+
if (
|
|
14
|
+
typeof object === "object" &&
|
|
15
|
+
schema?.type === "object" &&
|
|
16
|
+
schema?.properties &&
|
|
17
|
+
!("additionalProperties" in schema)
|
|
18
|
+
) {
|
|
19
|
+
return {
|
|
20
|
+
...schema,
|
|
21
|
+
additionalProperties,
|
|
22
|
+
unevaluatedProperties: false,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const ajvConfig = {
|
|
29
|
+
strict: false, // TODO: adjust schemas and enable strict mode
|
|
30
|
+
useDefaults: true,
|
|
31
|
+
/**
|
|
32
|
+
* discriminator fixes default values in oneOf
|
|
33
|
+
* @see https://ajv.js.org/guide/modifying-data.html#assigning-defaults
|
|
34
|
+
*/
|
|
35
|
+
discriminator: true,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const ajvValidator = new Ajv({ ...ajvConfig });
|
|
39
|
+
const ajvValidatorAndCleaner = new Ajv({ ...ajvConfig, removeAdditional: true });
|
|
40
|
+
const ajvValidatorAndCleanerWithCoercingTypes = new Ajv({
|
|
41
|
+
...ajvConfig,
|
|
42
|
+
removeAdditional: true,
|
|
43
|
+
coerceTypes: true,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
interface AjvInstanceOptions {
|
|
47
|
+
clean: boolean;
|
|
48
|
+
coerceTypes: boolean;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function getAjvInstance({ clean, coerceTypes }: AjvInstanceOptions) {
|
|
52
|
+
if (clean && coerceTypes) {
|
|
53
|
+
return ajvValidatorAndCleanerWithCoercingTypes;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (clean) {
|
|
57
|
+
return ajvValidatorAndCleaner;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return ajvValidator;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function getValidator(
|
|
64
|
+
jsonSchema: SchemaObject,
|
|
65
|
+
{ clean, coerceTypes }: AjvInstanceOptions,
|
|
66
|
+
): AnyValidateFunction {
|
|
67
|
+
const schemaKey = jsonSchema.$id as string;
|
|
68
|
+
const ajv = getAjvInstance({ clean, coerceTypes });
|
|
69
|
+
let validate = ajv.getSchema(schemaKey);
|
|
70
|
+
|
|
71
|
+
if (!validate) {
|
|
72
|
+
// properties that were not defined in schema will be ignored when clean = false
|
|
73
|
+
const patchedSchema = clean ? addAdditionalPropertiesToSchema(jsonSchema) : jsonSchema;
|
|
74
|
+
ajv.addSchema(patchedSchema, schemaKey);
|
|
75
|
+
validate = ajv.getSchema(schemaKey);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (!validate) {
|
|
79
|
+
throw new Error("JSONSchemasInterface AJV validator error");
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return validate;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Validates a given example against the schema.
|
|
87
|
+
* @param example example to validate.
|
|
88
|
+
* @param schema schema to validate the example with.
|
|
89
|
+
* @returns whether example is valid.
|
|
90
|
+
*/
|
|
91
|
+
export function validate(data: AnyObject, jsonSchema: SchemaObject) {
|
|
92
|
+
const validator = getValidator(jsonSchema, { clean: false, coerceTypes: false });
|
|
93
|
+
const isValid = validator(data);
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
isValid,
|
|
97
|
+
errors: validator.errors,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Validates and clean a given example against the schema
|
|
103
|
+
* @param example example to validate.
|
|
104
|
+
* @param schema schema to validate the example with.
|
|
105
|
+
* @returns whether example is valid.
|
|
106
|
+
*/
|
|
107
|
+
export function validateAndClean(
|
|
108
|
+
data: AnyObject,
|
|
109
|
+
jsonSchema: SchemaObject,
|
|
110
|
+
{ coerceTypes = false },
|
|
111
|
+
) {
|
|
112
|
+
const validator = getValidator(jsonSchema, { clean: true, coerceTypes });
|
|
113
|
+
const isValid = validator(data);
|
|
114
|
+
|
|
115
|
+
return {
|
|
116
|
+
isValid,
|
|
117
|
+
errors: validator.errors,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function isInstanceOf(object: object, type: "Array"): object is object[];
|
|
2
|
+
|
|
3
|
+
export function isInstanceOf(object: object, type: "Object"): object is object;
|
|
4
|
+
|
|
5
|
+
export function isInstanceOf(object: object, type: string): boolean {
|
|
6
|
+
return Object.prototype.toString.call(object).slice(8, -1) === type;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Makes sure that text representing arrays is parsed into Arrays.
|
|
11
|
+
*/
|
|
12
|
+
export function safeParseJSON(string: string) {
|
|
13
|
+
const obj = JSON.parse(string);
|
|
14
|
+
return string[0] === "[" ? Object.keys(obj).map((key) => obj[key]) : obj;
|
|
15
|
+
}
|