JSON Model-to-Model Projection (JM2MP) Documentation

JSON Model-to-Model Projection (JM2MP) Documentation

Module

jm2mp/modules/resolver

Resolución de módulos: carga, detección de ciclos, normalización por módulo, fusión por importación.

PROTECCIÓN CONTRA CARGA EXCESIVA:

  • Detección de ciclos (DFS con conjunto 'visiting').
  • Cache de módulos ya cargados (clave normalizada a minúsculas).
  • Parámetro maxModules que limita el número total de módulos cargables en una resolución (protección contra DoS y errores de configuración).

NORMALIZACIÓN DE LA CACHÉ DE MÓDULOS: La caché interna usa el nombre del módulo en MINÚSCULAS como clave, para evitar duplicación accidental por diferencias de mayúsculas. El loader, sin embargo, recibe siempre el nombre ORIGINAL tal y como apareció en $depends-on (no normalizado), para que loaders sensibles a mayúsculas (como sistemas de ficheros UNIX) funcionen correctamente en la primera carga. Si dos referencias difieren solo en mayúsculas, la primera carga sí ocurre con su forma original; las siguientes usan la caché.

NORMALIZACIÓN POR MÓDULO: Tras cargar cada módulo, se normaliza (se añade $syntax a los $get que lo omitan) según el $default-query-language de ESE módulo, ANTES de fusionar. Esto preserva la sintaxis original de cada plantilla incluso al combinar módulos con sintaxis distintas.

Source

Members

Methods

static

resolve(rootName, loader, optionsopt) → {Promise.<object>}

It resolves a projection module since its root name using loader.

Parameters

  • rootName string

    The name of the root projection module.

  • loader LoaderFunction

    The function that loads a module by its name. The loader receives the original (not normalized) name, as declared in $.$options.$depends-on (path) clause.

  • options object <optional>

    An optional configuration object.

    Properties

    • maxModules number <optional>
      1000

      Maximum number of unique projection modules that must be loaded by loader in this resolution stage (threshold).

      Its purpose is to protect against extremely long dependency chains, whether accidental or malicious.

Returns

  • Promise.<object>

    The final resultant projection module already normalized and resolved.

Throws

Whenever a cycle, not loadable modules or undefined root template is found during this resolution stage.

Type
ResolutionError

Source

inner

importInto(dependencies, dependant) → {object}

It imports an m2 projection module into the accumulated m1 _projection module.

All keys from m2 overwrites keys from m1.

All meta-data properties ($options and $schema) are discarded from the resultant module, so only named templates are preserved.

Parameters

  • dependencies object

    The accumulated module (lower dependency, to the leafs).

  • dependant object

    The new module to import (higher dependency, to the root).

Returns

  • object

    Resultant projection module with only named templates and no meta-data.

Source

Type Definitions

LoaderFunction()

*typedef {(name: string) => Promise} LoaderFunction

Source

Copyright © 2026 Luis María CÁMARA ROSSI.
Trademark ™ Copyright © 2026 Universidad Nacional de Educación a Distancia (U.N.E.D.).
The JM2MP syntax and this library JM2MP.JS are licensed under BSD-3-Clause [1] [2] license.
See LICENSE.txt for more info.

Documentation generated using JSDoc 3.6.11 and tidy-jsdoc 1.4.1 on 2026-08-26T15:45:19.740Z