getModelFromSource allows to compile a set of Publicodes files into a RawRules that can be used by the Publicodes Engine.
getModelFromSource
RawRules
Engine
Note that it supports the importer! syntax to import other Publicodes rules from NPM packages -- see Imports rules from a NPM package.
importer!
import { getModelFromSource } from '@publicodes/tools/compilation'const model = getModelFromSource( 'data/**/*.publicodes', // could simply be 'data' { ignore: ['data/test/**'], verbose: true },) Copy
import { getModelFromSource } from '@publicodes/tools/compilation'const model = getModelFromSource( 'data/**/*.publicodes', // could simply be 'data' { ignore: ['data/test/**'], verbose: true },)
To import rules from a packaged Publicodes model, you need to specify the following syntax :
importer!: depuis: nom: <npm_package_name> source: <path_to_the_model_file> (optional) url: <url_to_the_package_documentation> (optional) dans: <namespace> (optional) les règles: - <rule_name_from_the_npm_package> - <rule_name_from_the_npm_package>: <attr_to_overwrite>: <value> ... ... Copy
importer!: depuis: nom: <npm_package_name> source: <path_to_the_model_file> (optional) url: <url_to_the_package_documentation> (optional) dans: <namespace> (optional) les règles: - <rule_name_from_the_npm_package> - <rule_name_from_the_npm_package>: <attr_to_overwrite>: <value> ... ...
When compiling , each YAML entry importer! will be replaced by all imported rules and their dependencies by getModelFromSource.
compilation.ImportMacro | ImportMacro for more details.
ImportMacro
By default if no source is specified, the model is assumed to be compiled RawRules into <package_name>.model.json in the NPM package root folder.
source
<package_name>.model.json
If no dans is specified, the rules will be imported in a namespace corresponding to the package name (nom).
dans
nom
Generated using TypeDoc
Compile a model from a source
getModelFromSource
allows to compile a set of Publicodes files into aRawRules
that can be used by the PublicodesEngine
.Note that it supports the
importer!
syntax to import other Publicodes rules from NPM packages -- see Imports rules from a NPM package.Usage
Import rules from a NPM package
To import rules from a packaged Publicodes model, you need to specify the following syntax :
When compiling , each YAML entry
importer!
will be replaced by all imported rules and their dependencies bygetModelFromSource
.See
compilation.ImportMacro |
ImportMacro
for more details.Note
By default if no
source
is specified, the model is assumed to be compiledRawRules
into<package_name>.model.json
in the NPM package root folder.If no
dans
is specified, the rules will be imported in a namespace corresponding to the package name (nom
).