Skip to content

Commit fec9824

Browse files
author
Jonathan Casarrubias
committed
Release 2.1.0-beta.7 🚀
- Fix: #141 - Fix: #140
1 parent 05df123 commit fec9824

File tree

11 files changed

+31
-24
lines changed

11 files changed

+31
-24
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
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`.
44

5+
## Release 2.1.0-beta.7
6+
7+
- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/141
8+
- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/140
9+
510
## Release 2.1.0-beta.6
611

712
- Hot Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/132

lib/angular2/index.js

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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 => {

lib/angular2/shared/index.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* export class AppModule { }
3333
*
3434
**/
35-
<%- buildModuleImports(models, false) %>
35+
<%- buildModuleImports(models, isIo) %>
3636

3737
@NgModule({
3838
imports: [ CommonModule, HttpModule ],

lib/angular2/shared/models/base.ejs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* tslint:disable */
22
<% if (!loadAccessToken) { %>
3-
import 'AccessToken' from './AccessToken';
3+
import { AccessToken } from './AccessToken';
44
<% } %>
55
declare var Object: any;
66
export interface LoopBackFilter {
@@ -33,10 +33,10 @@ export class AccessToken implements AccessTokenInterface {
3333
}
3434
<% } %>
3535
export class SDKToken extends AccessToken {
36-
id:string = null;
36+
id: any = null;
3737
ttl: number = null;
3838
created: any = null;
39-
userId: string = null;
39+
userId: any = null;
4040
user: any = null;
4141
rememberMe: boolean = null;
4242
constructor(instance?: AccessToken) {

lib/angular2/shared/services/core/auth.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Injectable } from '@angular/core';
44
import { StorageDriver } from '../../storage/storage.driver';
55
import { SDKToken<% if (loadAccessToken) { %>, AccessToken<% } %> } from '../../models/BaseModels';
66
<% if (!loadAccessToken) { %>
7-
import { AccessToken } from '../../models/BaseModels';
7+
import { AccessToken } from '../../models/AccessToken';
88
<% } %>
99
/**
1010
* @module LoopBackAuth

lib/angular2/shared/services/core/index.ejs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@ export * from './auth.service';
33
export * from './error.service';
44
export * from './search.params';
55
export * from './base.service';
6-
export * from './real.time';
6+
<% if ( isIo === 'enabled' ){ -%>export * from './real.time';
7+
<% }
8+
-%>
9+

lib/angular2/shared/services/custom/service.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* tslint:disable */
2-
<%- buildServiceImports(model) %>
2+
<%- buildServiceImports(model, loadAccessToken) %>
33

44
// Making Sure EventSource Type is available to avoid compilation issues.
55
declare var EventSource: any;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@mean-expert/loopback-sdk-builder",
3-
"version": "2.1.0-beta.6",
3+
"version": "2.1.0-beta.7",
44
"description": "Tool for auto-generating Software Development Kits (SDKs) for LoopBack",
55
"bin": {
66
"lb-sdk": "bin/lb-sdk"

tests/angular2/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"@angular/platform-browser": "2.0.0",
2222
"@angular/platform-browser-dynamic": "2.0.0",
2323
"@angular/router": "3.0.0",
24+
"@types/socket.io-client": "^1.4.27",
2425
"compression": "^1.0.3",
2526
"config-chain": "^1.1.10",
2627
"core-js": "^2.4.1",
@@ -35,6 +36,7 @@
3536
"loopback-connector-rest": "^2.0.0",
3637
"loopback-datasource-juggler": "^2.39.0",
3738
"rxjs": "5.0.0-beta.12",
39+
"socket.io-client": "^1.4.8",
3840
"ts-helpers": "^1.1.1",
3941
"zone.js": "^0.6.23"
4042
},

tests/angular2/src/app/shared/sdk/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@
3434
**/
3535
import { JSONSearchParams } from './services/core/search.params';
3636
import { ErrorHandler } from './services/core/error.service';
37-
import { RealTime } from './services/core/real.time';
3837
import { LoopBackAuth } from './services/core/auth.service';
3938
import { LoggerService } from './services/custom/logger.service';
4039
import { HttpModule } from '@angular/http';
4140
import { CommonModule } from '@angular/common';
4241
import { NgModule, ModuleWithProviders } from '@angular/core';
42+
import { RealTime } from './services/core/real.time';
4343
import { UserApi } from './services/custom/User';
4444
import { RoomApi } from './services/custom/Room';
4545
import { MessageApi } from './services/custom/Message';

0 commit comments

Comments
 (0)