@@ -80,7 +80,7 @@ module.exports = function generate(ctx) {
8080 {
8181 template : './shared/services/core/index.ejs' ,
8282 output : '/services/core/index.ts' ,
83- params : { }
83+ params : { isIo : ctx . isIo }
8484 } ,
8585 /**
8686 * SDK CONFIG
@@ -215,6 +215,7 @@ module.exports = function generate(ctx) {
215215 buildPostBody : buildPostBody ,
216216 buildUrlParams : buildUrlParams ,
217217 buildRouteParams : buildRouteParams ,
218+ loadAccessToken : ctx . loadAccessToken ,
218219 buildMethodParams : buildMethodParams ,
219220 buildServiceImports : buildServiceImports ,
220221 normalizeMethodName : normalizeMethodName ,
@@ -313,7 +314,7 @@ module.exports = function generate(ctx) {
313314 * IMPORTANT: This method have a very specific flow, changing it may create
314315 * multiple issues on multiple different use cases.
315316 */
316- function buildServiceImports ( model ) {
317+ function buildServiceImports ( model , loadAccessToken ) {
317318 let modelName = capitalize ( model . name ) ;
318319 let imports = [
319320 { module : 'Injectable, Inject, Optional' , from : '@angular/core' } ,
@@ -322,7 +323,7 @@ module.exports = function generate(ctx) {
322323 { module : 'LoopBackConfig' , from : '../../lb.config' } ,
323324 { module : 'LoopBackAuth' , from : '../core/auth.service' } ,
324325 {
325- module : `LoopBackFilter, ${ model . isUser ? `SDKToken${ ctx . loadAccessToken ? ', AccessToken' : '' } ` : '' } ` ,
326+ module : `LoopBackFilter, ${ model . isUser ? `SDKToken${ ( loadAccessToken && model . isUser ) ? ', AccessToken' : '' } ` : '' } ` ,
326327 from : '../../models/BaseModels'
327328 } ,
328329 { module : 'JSONSearchParams' , from : '../core/search.params' } ,
@@ -332,8 +333,6 @@ module.exports = function generate(ctx) {
332333 { module : 'rxjs/add/operator/map' } ,
333334 { module : modelName , from : `../../models/${ modelName } ` } ,
334335 ] ;
335- if ( ! ctx . loadAccessToken && model . isUser )
336- imports . push ( { module : `AccessToken` , from : '../../models/AccessToken' } ) ;
337336 let loaded = { } ; loaded [ model . name ] = true ;
338337 getModelRelations ( model ) . forEach ( ( relationName , i ) => {
339338 let targetClass = model . sharedClass . ctor . relations [ relationName ] . targetClass ;
@@ -368,21 +367,19 @@ module.exports = function generate(ctx) {
368367 * @description
369368 * Define import statement for the SDK Module
370369 */
371- function buildModuleImports ( models , isIndex ) {
370+ function buildModuleImports ( models , isIo ) {
372371 let imports = [
373372 { module : 'JSONSearchParams' , from : './services/core/search.params' } ,
374373 { module : 'ErrorHandler' , from : './services/core/error.service' } ,
375- { module : 'RealTime' , from : './services/core/real.time' } ,
376374 { module : 'LoopBackAuth' , from : './services/core/auth.service' } ,
377375 { module : 'LoggerService' , from : './services/custom/logger.service' } ,
376+ { module : 'HttpModule' , from : '@angular/http' } ,
377+ { module : 'CommonModule' , from : '@angular/common' } ,
378+ { module : 'NgModule, ModuleWithProviders' , from : '@angular/core' }
378379 ] ;
379380
380- if ( ! isIndex ) {
381- imports = imports . concat ( [
382- { module : 'HttpModule' , from : '@angular/http' } ,
383- { module : 'CommonModule' , from : '@angular/common' } ,
384- { module : 'NgModule, ModuleWithProviders' , from : '@angular/core' }
385- ] ) ;
381+ if ( isIo ) {
382+ imports . push ( { module : 'RealTime' , from : './services/core/real.time' } ) ;
386383 }
387384
388385 Object . keys ( models ) . forEach ( modelName => {
0 commit comments