
/**
* @module SDKModule
* @author Jonathan Casarrubias <t:@johncasarrubias> <gh:jonathan-casarrubias>
* @license MIT 2016 Jonathan Casarrubias
* @version 2.1.0
* @description
* The SDKModule is a generated Software Development Kit automatically built by
* the LoopBack SDK Builder open source module.
*
* The SDKModule provides Angular 2 >= RC.5 support, which means that NgModules
* can import this Software Development Kit as follows:
*
*
* APP Route Module Context
* ============================================================================
* import { NgModule }       from '@angular/core';
* import { BrowserModule }  from '@angular/platform-browser';
* // App Root 
* import { AppComponent }   from './app.component';
* // Feature Modules
* import { SDK[Browser|Node|Native]Module } from './shared/sdk/sdk.module';
* // Import Routing
* import { routing }        from './app.routing';
* @NgModule({
*  imports: [
*    BrowserModule,
*    routing,
*    SDK[Browser|Node|Native]Module.forRoot()
*  ],
*  declarations: [ AppComponent ],
*  bootstrap:    [ AppComponent ]
* })
* export class AppModule { }
*
**/
<%- (framework === 'angular') ? buildModuleImports(models, isIo, driver): '' %>
<% if (framework === 'react') { -%>
import React, { Component as ReactComponent } from 'react';
import * as Services from './services';

export class Component extends ReactComponent {
  models = {};
  constructor(config) {
    super();
    config.services.forEach((service) => {
      if ( typeof this.services === 'object') this.services = {};
      this[service] = new Services[service]();
    });
  }
}
<% } %>
<% if (framework === 'angular') { %>
<% if ( driver === 'ng2web' || driver === 'ng2universal' ) { -%>
/**
* @module SDKBrowserModule
* @description
* This module should be imported when building a Web Application in the following scenarios:
*
*  1.- Regular web application
*  2.- Angular universal application (Browser Portion)
*  3.- Progressive applications (Angular Mobile, Ionic, WebViews, etc)
**/
@NgModule({
  imports:      [ CommonModule, HttpModule ],
  declarations: [ ],
  exports:      [ ],
  providers:    [
    <%- buildNgProviders(isIo) %>
  ]
})
export class SDKBrowserModule {
  static forRoot(internalStorageProvider: any = {
    provide: InternalStorage,
    useClass: CookieBrowser
  }): ModuleWithProviders {
    return {
      ngModule  : SDKBrowserModule,
      providers : [
        <%- buildNgModuleImports(models, 'browser', isIo, driver) %>
      ]
    };
  }
}
<% } -%>
<% if ( driver === 'ng2universal' ) { -%>
/**
* @module SDKNodeModule
* @description
* This module should be imported when building a Angular Universal Application.
**/
@NgModule({
  imports:      [ CommonModule, HttpModule ],
  declarations: [ ],
  exports:      [ ],
  providers:    [
    <%- buildNgProviders(isIo) %>
  ]
})
export class SDKNodeModule {
  static forRoot(): ModuleWithProviders {
    return {
      ngModule  : SDKNodeModule,
      providers : [
        <%- buildNgModuleImports(models, 'node', isIo, driver) %>
      ]
    };
  }
}
<% } -%>
<% if ( driver === 'ng2native' ) { -%>
/**
* @module SDKNativeModule
* @description
* This module should be imported when building a NativeScript Applications.
**/
@NgModule({
  imports:      [ CommonModule, NativeScriptHttpModule ],
  declarations: [ ],
  exports:      [ ],
  providers:    [
    <%- buildNgProviders(isIo) %>
  ]
})
export class SDKNativeModule {
  static forRoot(): ModuleWithProviders {
    return {
      ngModule  : SDKNativeModule,
      providers : [
        <%- buildNgModuleImports(models, 'nativescript', isIo, driver) %>
      ]
    };
  }
}
<% } -%>
<% } %>
/**
* Have Fun!!!
* - Jon
**/
export * from './models/index';
export * from './services/index';
export * from './lb.config';
<% if ( driver === 'ng2web' ) { -%>
export * from './storage/storage.swaps';
export { CookieBrowser } from './storage/cookie.browser';
export { StorageBrowser } from './storage/storage.browser';
<% } -%>
