<commit_before>import DataSourceMongodb from './data-source/mongodb';
import DataSourceMock from './data-source/mock';
import Repo from './repo';
import RepoPopulator from './repo-populator';
import Service from './service';
import Schema from 'mzen-schema';

export interface ModelManagerConfigDataSource
{
  name?: string;
  type?: 'mongodb'|'mock'|string;
  [key: string]: any;
}

export interface ModelManagerConfig
{
  dataSources?: Array<ModelManagerConfigDataSource>;
  constructors?: {[key: string]: any} | Array<any>;
  schemas?: {[key: string]: Schema} | Array<Schema>;
  repos?: {[key: string]: Repo} | Array<Repo>;
  services?: {[key: string]: Service} | Array<Service>;
  app?: any; // adhoc app configuration passed by consumers
}

/**
 * ModelManager
 *
 * The model manager is responsible for loading and initialising repositories, services.
 * It loads repository and service class definitions from the file system.
 */
export class ModelManager
{
  initialised:boolean;
  initialisers: {
    [key: string]: any[]
  };
  shutdownHandlers: {
    [key: string]: any[]
  };
  config:ModelManagerConfig;
  dataSources:{[key: string]: any};
  constructors:{[key: string]: any};
  schemas:{[key: string]: Schema};
  repos:{[key: string]: Repo};
  services:{[key: string]: Service};
  repoPopulator:RepoPopulator;
  logger:any;
  
  constructor(options?: ModelManagerConfig)
  {
    this.config = options ? options : {};
    this.config.dataSources = this.config.dataSources 
      ? this.config.dataSources : [];
    this.config.constructors = this.config.constructors 
      ? this.config.constructors : {};
    this.config.schemas = this.config.schemas ? this.config.schemas : {};
    this.config.repos = this.config.repos ? this.config.repos : {};
    this.config.services = this.config.services ? this.config.services : {};

    this.logger = console;

    this.initialised = false;
    this.initialisers = {};
    this.dataSources = {};
    this.constructors = {};
    this.schemas = {};<commit_msg>Update model manager init shutdown handlers<commit_after>import DataSourceMongodb from './data-source/mongodb';
import DataSourceMock from './data-source/mock';
import Repo from './repo';
import RepoPopulator from './repo-populator';
import Service from './service';
import Schema from 'mzen-schema';

export interface ModelManagerConfigDataSource
{
  name?: string;
  type?: 'mongodb'|'mock'|string;
  [key: string]: any;
}

export interface ModelManagerConfig
{
  dataSources?: Array<ModelManagerConfigDataSource>;
  constructors?: {[key: string]: any} | Array<any>;
  schemas?: {[key: string]: Schema} | Array<Schema>;
  repos?: {[key: string]: Repo} | Array<Repo>;
  services?: {[key: string]: Service} | Array<Service>;
  app?: any; // adhoc app configuration passed by consumers
}

/**
 * ModelManager
 *
 * The model manager is responsible for loading and initialising repositories, services.
 * It loads repository and service class definitions from the file system.
 */
export class ModelManager
{
  initialised:boolean;
  initialisers: {
    [key: string]: any[]
  };
  shutdownHandlers: {
    [key: string]: any[]
  };
  config:ModelManagerConfig;
  dataSources:{[key: string]: any};
  constructors:{[key: string]: any};
  schemas:{[key: string]: Schema};
  repos:{[key: string]: Repo};
  services:{[key: string]: Service};
  repoPopulator:RepoPopulator;
  logger:any;
  
  constructor(options?: ModelManagerConfig)
  {
    this.config = options ? options : {};
    this.config.dataSources = this.config.dataSources 
      ? this.config.dataSources : [];
    this.config.constructors = this.config.constructors 
      ? this.config.constructors : {};
    this.config.schemas = this.config.schemas ? this.config.schemas : {};
    this.config.repos = this.config.repos ? this.config.repos : {};
    this.config.services = this.config.services ? this.config.services : {};

    this.logger = console;

    this.initialised = false;
    this.initialisers = {};
    this.shutdownHandlers = {};
    this.dataSources = {};
    this.constructors = {};
    this.schemas = {};
{'fraction_non_alphanumeric': 0.145405669599218, 'fraction_numerical': 0.0, 'mean_word_length': 4.129072681704261, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1835946', 'n_tokens_mistral': 1238, 'n_tokens_neox': 1193, 'n_words': 302}