diff --git a/README.md b/README.md index 510ac52b..5b9d5462 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Use the development branch to create a new branch from. If adding new features a # OIDC-SSO Service A new campaing to call developers to register as beta testers for the [OnixJS](https://onixjs.io) Single Sign-On Service is active now. This campaing will be running during the month of June 2018, allowing all of those registered users to have early access during closed beta. -- _Closed beta access will be active starting from July 2108._ +- _Closed beta access will be active starting from July 2018._ Register now and get the chance to have an unlimited annual enterprise membership for free. diff --git a/lib/angular2/shared/index.ejs b/lib/angular2/shared/index.ejs index 85748734..2bd804b2 100644 --- a/lib/angular2/shared/index.ejs +++ b/lib/angular2/shared/index.ejs @@ -1,139 +1,140 @@ /* tslint:disable */ /** * @module SDKModule -* @author 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 { } -* -**/ -<%- buildModuleImports(models, isIo, driver) %> -<% 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, HttpClientModule ], - declarations: [ ], - exports: [ ], - providers: [ +* @author 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 { } + * + **/ + <%- buildModuleImports(models, isIo, driver) %> + <% 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, HttpClientModule ], + declarations: [ ], + exports: [ ], + providers: [ <%- buildNgProviders(isIo) %> - ] -}) -export class SDKBrowserModule { - static forRoot(internalStorageProvider: any = { + ] + }) + export class SDKBrowserModule { + static forRoot(internalStorageProvider: any = { provide: InternalStorage, useClass: CookieBrowser - }): ModuleWithProviders { - return { - ngModule : SDKBrowserModule, + }): ModuleWithProviders { + return { + ngModule : SDKBrowserModule, providers : [ - <%- buildNgModuleImports(models, 'browser', isIo, driver) %> + <%- 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 === 'ng2universal' ) { -%> + /** + * @module SDKNodeModule + * @description + * This module should be imported when building a Angular Universal Application. + **/ + @NgModule({ + imports: [ CommonModule, HttpModule ], + declarations: [ ], + exports: [ ], + providers: [ + <%- buildNgProviders(isIo) %> ] - }; - } -} -<% } -%> -<% 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'; -<% } -%> + }) + 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'; + <% } -%> -<% if ( isNgrx === 'enabled' || isNgrx === 'orm' ) { -%> -export * from './actions/index'; -export * from './reducers/index'; -export * from './state'; -export * from './guards/index'; -export * from './resolvers/index'; -<% } -%> + <% if ( isNgrx === 'enabled' || isNgrx === 'orm' ) { -%> + export * from './actions/index'; + export * from './reducers/index'; + export * from './state'; + export * from './guards/index'; + export * from './resolvers/index'; + <% } -%> diff --git a/lib/angular2/shared/models/base.ejs b/lib/angular2/shared/models/base.ejs index e3cc6a87..c07c7b57 100644 --- a/lib/angular2/shared/models/base.ejs +++ b/lib/angular2/shared/models/base.ejs @@ -111,6 +111,7 @@ export class SDKToken implements AccessTokenInterface { userId: any = null; user: any = null; rememberMe: boolean = null; + principalType: string = null; constructor(data?: AccessTokenInterface) { Object.assign(this, data); } diff --git a/lib/angular2/shared/orm/index.ejs b/lib/angular2/shared/orm/index.ejs index 70cf67f7..ef696497 100644 --- a/lib/angular2/shared/orm/index.ejs +++ b/lib/angular2/shared/orm/index.ejs @@ -1,9 +1,9 @@ /* tslint:disable */ import { - NgModule, - ModuleWithProviders, - Optional, - SkipSelf +NgModule, +ModuleWithProviders, +Optional, +SkipSelf } from '@angular/core'; import { Orm } from './orm'; @@ -11,18 +11,18 @@ export * from './orm'; @NgModule({}) export class OrmModule { - constructor(@Optional() @SkipSelf() parentModule: OrmModule) { - if (parentModule) { - throw new Error( - 'OrmModule.forRoot() called twice. Lazy loaded modules do not need to import OrmModule.', - ); - } - } +constructor(@Optional() @SkipSelf() parentModule: OrmModule) { +if (parentModule) { +throw new Error( +'OrmModule.forRoot() called twice. Lazy loaded modules do not need to import OrmModule.', +); +} +} - static forRoot(): ModuleWithProviders { - return { - ngModule: OrmModule, - providers: [ Orm ] - }; +static forRoot(): ModuleWithProviders { + return { + ngModule: OrmModule, + providers: [ Orm ] + }; + } } -} diff --git a/lib/angular2/shared/services/core/auth.ts b/lib/angular2/shared/services/core/auth.ts index 78ece2fd..e04b161b 100644 --- a/lib/angular2/shared/services/core/auth.ts +++ b/lib/angular2/shared/services/core/auth.ts @@ -35,6 +35,7 @@ export class LoopBackAuth { this.token.created = this.load('created'); this.token.ttl = this.load('ttl'); this.token.rememberMe = this.load('rememberMe'); + this.token.principalType = this.load('principalType'); } /** * @method setRememberMe @@ -121,6 +122,7 @@ export class LoopBackAuth { this.persist('created', this.token.created, expires); this.persist('ttl', this.token.ttl, expires); this.persist('rememberMe', this.token.rememberMe, expires); + this.persist('principalType', this.token.principalType, expires); return true; }; /** diff --git a/lib/templates/shared/index.ejs b/lib/templates/shared/index.ejs index 8cae1b87..d3a53898 100644 --- a/lib/templates/shared/index.ejs +++ b/lib/templates/shared/index.ejs @@ -1,148 +1,148 @@ - /** * @module SDKModule -* @author 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'; +* @author 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) { + 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 ( 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: [ + } + } + <% } %> + <% 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 = { + ] + }) + 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, + }): ModuleWithProviders { + return { + ngModule : SDKBrowserModule, providers : [ - <%- buildNgModuleImports(models, 'node', isIo, driver) %> + <%- buildNgModuleImports(models, 'browser', 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) %> + }; + } + } + <% } -%> + <% 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) %> ] - }; - } -} -<% } -%> -<% } %> -/** -* 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'; -<% } -%> + }) + 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'; + <% } -%> diff --git a/package.json b/package.json index 9a59e2bd..8f996eed 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mean-expert/loopback-sdk-builder", - "version": "2.3.0", + "version": "2.3.2", "description": "Tool for auto-generating Software Development Kits (SDKs) for LoopBack", "bin": { "lb-sdk": "bin/lb-sdk"