The module normalizer
implements the standardization process over the JM2MP projection
modules content in the stage of resolution, before it will be evaluated.
Each module can declare a default query language (in
$.$options.$default-query-language path). Such syntax is applied
inside the module to every get template command that omit their
$syntaxclause, adding to it in its absence.
So, after normalization, every get template command in the
projection module will carry an explicit $syntaxclause;
therefore, all the get templates will be self-explanatory and can
be merged across different projection modules each one with different
syntaxes without ambiguity.
The two meta-data properties that will be ignored by the normalizer are:
$options: used for module configuration (dependencies, default syntax, ...).$schema: used to add an optional reference to an external JSON Schema.
These two meta-data properties are never considered as named templates and only affects to the current projection module. The normalizer preserves them without processing their content.
Source
Members
MODULE_METADATA_KEYSSet.<string>
The set of keys (property names) considered as module meta-data and not as names templates.
This keys are preserved as is, without traversing its content during the normalization process.
Type
-
Set.<string>
Source
Methods
normalizeModule(module) → {object}
It normalizes a complete projection module, adding $syntaxclauses
to every gettemplate command that ommits it.
It never modifies the original module; it always returns a new structured object.
Parameters
-
module
objectThe projection module to mormalize (so it must be a JSON root object).
Returns
-
objectThe just created and normalized projection module.
Source
getDefaultSyntax(module) → {string}
It extracts the optionally declared default query language,
which if if exists must be declared in path
$.$options.$default-query-language. If it is not declared or is
not considered as valid, the native syntax will be used by default.
Parameters
-
module
objectThe projection module to normalize (so it must be a JSON root object).
Returns
-
stringThe name of the query language to be used by default.
Source
normalizeGet(getOp, defaultSyntax) → {object}
It normalizes a get template command, adding a new $syntax
clause if missing; rest of clauses will be also traversed (for if
inner get commands are present).
Parameters
-
getOp
objectThe current
gettemplate command to normalize. -
defaultSyntax
stringThe default query language for the projection module.
Returns
-
objectA new object, equivalent to 'getOp' but with a
$syntaxclause present.
Source
normalizeNode(node, defaultSyntax) → {*}
It recursively normalizes a node of the entire tree of JSON values (named templates and command templates of the projection module).
It only modifies nodes that represent actual get template
commands without a $syntax clause; every other node is just
traversed to normalize their children.
Parameters
-
node
*The current node (JSON value) a normalize.
-
defaultSyntax
stringThe default query language declared (or considered) for this projection module.
Returns
-
*The normalized node.