src/models/index.js
/**
 * Imports remote models and overrides their service adapters
 * with those specified by the host config.
 * @param {*} remoteEntries -
 * @param {*} services - services on which the model depends
 * @param {*} adapters - adapters for talking to the services
 */
Imports remote models and overrides their service adapters
with those specified by the host config.
@param {*} remoteEntries
@param {*} services - services on which the model depends
@param {*} adapters - adapters for talking to the services
Imports remote models and overrides their service adapters with those specified by the host config . @param { * } remoteEntries @param { * } services - services on which the model depends @param { * } adapters - adapters for talking to the services
async function initModels(remoteEntries, services, adapters) {
  const models = await importRemoteModels(remoteEntries);
  Object.values(models).forEach(model => {
    if (
      model.hasOwnProperty("modelName") &&
      model.hasOwnProperty("factory") &&
      model.hasOwnProperty("endpoint")
    ) {
      const serviceAdapters = makeAdapters(model.ports, adapters, services);
      const dependencies = {
        ...model.dependencies,
        ...serviceAdapters,
      };
      ModelFactory.registerModel({
        ...model,
        dependencies,
        factory: model.factory(dependencies),
        isRemote: true,
      });
      ModelFactory.registerEvent(
        ModelFactory.EventTypes.CREATE,
        model.modelName,
        createEvent
      );
      ModelFactory.registerEvent(
        ModelFactory.EventTypes.UPDATE,
        model.modelName,
        updateEvent
      );
      ModelFactory.registerEvent(
        ModelFactory.EventTypes.DELETE,
        model.modelName,
        deleteEvent
      );
    }
  });
}
async function initModels ( remoteEntries , services , adapters ) { const models = await importRemoteModels ( remoteEntries ) ; Object . values ( models ) . forEach ( model => { if ( model . hasOwnProperty ( "modelName" ) && model . hasOwnProperty ( "factory" ) && model . hasOwnProperty ( "endpoint" ) ) { const serviceAdapters = makeAdapters ( model . ports , adapters , services ) ; const dependencies = { ... model . dependencies , ... serviceAdapters , } ; ModelFactory . registerModel ( { ... model , dependencies , factory : model . factory ( dependencies ) , isRemote : true , } ) ; ModelFactory . registerEvent ( ModelFactory . EventTypes . CREATE , model . modelName , createEvent ) ; ModelFactory . registerEvent ( ModelFactory . EventTypes . UPDATE , model . modelName , updateEvent ) ; ModelFactory . registerEvent ( ModelFactory . EventTypes . DELETE , model . modelName , deleteEvent ) ; } } ) ; }
Imports remote models and overrides their service adapters
 with those specified by the host config.
Imports remote models and overrides their service adapters with those specified by the host config .
// override adapters