JSON Model-to-Model Projection (JM2MP) Documentation

JSON Model-to-Model Projection (JM2MP) Documentation

Module

jm2mp/modules/normalizer

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

staticconstant

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

static

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 object

    The projection module to mormalize (so it must be a JSON root object).

Returns

  • object

    The just created and normalized projection module.

Source

inner

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 object

    The projection module to normalize (so it must be a JSON root object).

Returns

  • string

    The name of the query language to be used by default.

Source

inner

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 object

    The current get template command to normalize.

  • defaultSyntax string

    The default query language for the projection module.

Returns

  • object

    A new object, equivalent to 'getOp' but with a $syntax clause present.

Source

inner

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 string

    The default query language declared (or considered) for this projection module.

Returns

  • *

    The normalized node.

Source