Skip to content

Commit

Permalink
Release 2.1.0-beta.7 🚀
Browse files Browse the repository at this point in the history
- Fix: #141
- Fix: #140
  • Loading branch information
Jonathan Casarrubias committed Oct 5, 2016
1 parent 05df123 commit fec9824
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 24 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

This file is created to keep history of the LoopBack SDK Builder, it does not consider or keeps any history of its parent module `loopback-sdk-angular`.

## Release 2.1.0-beta.7

- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/141
- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/140

## Release 2.1.0-beta.6

- Hot Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/132
Expand Down
23 changes: 10 additions & 13 deletions lib/angular2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ module.exports = function generate(ctx) {
{
template: './shared/services/core/index.ejs',
output: '/services/core/index.ts',
params: {}
params: { isIo: ctx.isIo }
},
/**
* SDK CONFIG
Expand Down Expand Up @@ -215,6 +215,7 @@ module.exports = function generate(ctx) {
buildPostBody: buildPostBody,
buildUrlParams: buildUrlParams,
buildRouteParams: buildRouteParams,
loadAccessToken: ctx.loadAccessToken,
buildMethodParams: buildMethodParams,
buildServiceImports: buildServiceImports,
normalizeMethodName: normalizeMethodName,
Expand Down Expand Up @@ -313,7 +314,7 @@ module.exports = function generate(ctx) {
* IMPORTANT: This method have a very specific flow, changing it may create
* multiple issues on multiple different use cases.
*/
function buildServiceImports(model) {
function buildServiceImports(model, loadAccessToken) {
let modelName = capitalize(model.name);
let imports = [
{ module: 'Injectable, Inject, Optional', from: '@angular/core'},
Expand All @@ -322,7 +323,7 @@ module.exports = function generate(ctx) {
{ module: 'LoopBackConfig', from: '../../lb.config'},
{ module: 'LoopBackAuth', from: '../core/auth.service'},
{
module: `LoopBackFilter, ${model.isUser ? `SDKToken${ctx.loadAccessToken ? ', AccessToken' : ''}` : '' }`,
module: `LoopBackFilter, ${model.isUser ? `SDKToken${ (loadAccessToken && model.isUser) ? ', AccessToken' : '' }` : '' }`,
from: '../../models/BaseModels'
},
{ module: 'JSONSearchParams', from: '../core/search.params'},
Expand All @@ -332,8 +333,6 @@ module.exports = function generate(ctx) {
{ module: 'rxjs/add/operator/map' },
{ module: modelName, from: `../../models/${modelName}`},
];
if (!ctx.loadAccessToken && model.isUser)
imports.push({ module: `AccessToken`, from: '../../models/AccessToken' });
let loaded = {}; loaded[model.name] = true;
getModelRelations(model).forEach((relationName, i) => {
let targetClass = model.sharedClass.ctor.relations[relationName].targetClass;
Expand Down Expand Up @@ -368,21 +367,19 @@ module.exports = function generate(ctx) {
* @description
* Define import statement for the SDK Module
*/
function buildModuleImports(models, isIndex) {
function buildModuleImports(models, isIo) {
let imports = [
{ module: 'JSONSearchParams', from: './services/core/search.params'},
{ module: 'ErrorHandler', from: './services/core/error.service'},
{ module: 'RealTime', from: './services/core/real.time'},
{ module: 'LoopBackAuth', from: './services/core/auth.service'},
{ module: 'LoggerService', from: './services/custom/logger.service'},
{ module: 'HttpModule', from: '@angular/http'},
{ module: 'CommonModule', from: '@angular/common'},
{ module: 'NgModule, ModuleWithProviders', from: '@angular/core'}
];

if (!isIndex) {
imports = imports.concat([
{ module: 'HttpModule', from: '@angular/http'},
{ module: 'CommonModule', from: '@angular/common'},
{ module: 'NgModule, ModuleWithProviders', from: '@angular/core'}
]);
if (isIo) {
imports.push({ module: 'RealTime', from: './services/core/real.time'});
}

Object.keys(models).forEach(modelName => {
Expand Down
2 changes: 1 addition & 1 deletion lib/angular2/shared/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* export class AppModule { }
*
**/
<%- buildModuleImports(models, false) %>
<%- buildModuleImports(models, isIo) %>

@NgModule({
imports: [ CommonModule, HttpModule ],
Expand Down
6 changes: 3 additions & 3 deletions lib/angular2/shared/models/base.ejs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* tslint:disable */
<% if (!loadAccessToken) { %>
import 'AccessToken' from './AccessToken';
import { AccessToken } from './AccessToken';
<% } %>
declare var Object: any;
export interface LoopBackFilter {
Expand Down Expand Up @@ -33,10 +33,10 @@ export class AccessToken implements AccessTokenInterface {
}
<% } %>
export class SDKToken extends AccessToken {
id:string = null;
id: any = null;
ttl: number = null;
created: any = null;
userId: string = null;
userId: any = null;
user: any = null;
rememberMe: boolean = null;
constructor(instance?: AccessToken) {
Expand Down
2 changes: 1 addition & 1 deletion lib/angular2/shared/services/core/auth.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Injectable } from '@angular/core';
import { StorageDriver } from '../../storage/storage.driver';
import { SDKToken<% if (loadAccessToken) { %>, AccessToken<% } %> } from '../../models/BaseModels';
<% if (!loadAccessToken) { %>
import { AccessToken } from '../../models/BaseModels';
import { AccessToken } from '../../models/AccessToken';
<% } %>
/**
* @module LoopBackAuth
Expand Down
5 changes: 4 additions & 1 deletion lib/angular2/shared/services/core/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ export * from './auth.service';
export * from './error.service';
export * from './search.params';
export * from './base.service';
export * from './real.time';
<% if ( isIo === 'enabled' ){ -%>export * from './real.time';
<% }
-%>

2 changes: 1 addition & 1 deletion lib/angular2/shared/services/custom/service.ejs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* tslint:disable */
<%- buildServiceImports(model) %>
<%- buildServiceImports(model, loadAccessToken) %>

// Making Sure EventSource Type is available to avoid compilation issues.
declare var EventSource: any;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mean-expert/loopback-sdk-builder",
"version": "2.1.0-beta.6",
"version": "2.1.0-beta.7",
"description": "Tool for auto-generating Software Development Kits (SDKs) for LoopBack",
"bin": {
"lb-sdk": "bin/lb-sdk"
Expand Down
2 changes: 2 additions & 0 deletions tests/angular2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"@angular/platform-browser": "2.0.0",
"@angular/platform-browser-dynamic": "2.0.0",
"@angular/router": "3.0.0",
"@types/socket.io-client": "^1.4.27",
"compression": "^1.0.3",
"config-chain": "^1.1.10",
"core-js": "^2.4.1",
Expand All @@ -35,6 +36,7 @@
"loopback-connector-rest": "^2.0.0",
"loopback-datasource-juggler": "^2.39.0",
"rxjs": "5.0.0-beta.12",
"socket.io-client": "^1.4.8",
"ts-helpers": "^1.1.1",
"zone.js": "^0.6.23"
},
Expand Down
2 changes: 1 addition & 1 deletion tests/angular2/src/app/shared/sdk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
**/
import { JSONSearchParams } from './services/core/search.params';
import { ErrorHandler } from './services/core/error.service';
import { RealTime } from './services/core/real.time';
import { LoopBackAuth } from './services/core/auth.service';
import { LoggerService } from './services/custom/logger.service';
import { HttpModule } from '@angular/http';
import { CommonModule } from '@angular/common';
import { NgModule, ModuleWithProviders } from '@angular/core';
import { RealTime } from './services/core/real.time';
import { UserApi } from './services/custom/User';
import { RoomApi } from './services/custom/Room';
import { MessageApi } from './services/custom/Message';
Expand Down
4 changes: 2 additions & 2 deletions tests/angular2/src/app/shared/sdk/models/BaseModels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ export class AccessToken implements AccessTokenInterface {
}

export class SDKToken extends AccessToken {
id:string = null;
id: any = null;
ttl: number = null;
created: any = null;
userId: string = null;
userId: any = null;
user: any = null;
rememberMe: boolean = null;
constructor(instance?: AccessToken) {
Expand Down

0 comments on commit fec9824

Please sign in to comment.