Skip to content

Commit

Permalink
Merge commit '997856c3ac33aa2e70ee9e6df9363f955560bef2' into new-ngrx
Browse files Browse the repository at this point in the history
# Conflicts:
#	bin/lb-sdk
#	package.json
#	tests/fireloop/package.json
  • Loading branch information
JonnyBGod committed Oct 24, 2017
2 parents c3bdc1d + 997856c commit f37aecf
Show file tree
Hide file tree
Showing 126 changed files with 71,286 additions and 3,313 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -10,6 +10,7 @@
*.pid
*.swp
*.swo
*package-lock.json
node_modules
bower_component
checkstyle.xml
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,15 @@

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-rc.14

- Milestone Details: https://github.com/mean-expert-official/loopback-sdk-builder/milestone/48?closed=1

- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/515
- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/514
- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/511
- WIP: https://github.com/mean-expert-official/loopback-sdk-builder/issues/495

## Release 2.1.0-rc.13.5

- Milestone Details: https://github.com/mean-expert-official/loopback-sdk-builder/milestone/47?closed=1
Expand Down
12 changes: 7 additions & 5 deletions bin/lb-sdk
Expand Up @@ -23,22 +23,24 @@ var argv = optimist
'\nGenerate Client SDK for your LoopBack Application.' +
'\nUsage:' +
'\n ./node_modules/.bin/lb-sdk server/server app/shared/sdk -d [ng2web | ng2native | ng2universal] -i [enabled | disabled] -v [enabled | strict | disabled]')
.describe('l', 'Client\'s library (angular2, react <todo>, ...)')
.describe('d', 'Platform specific drivers (ng2web, ng2native, ng2universal)')
.describe('l', 'Client\'s library (angular, react, vuejs <todo> ...)')
.describe('d', 'Platform specific drivers (ng2web, ng2native, ng2universal, react-web)')
.describe('i', 'Enable PubSub, IO and FireLoop functionality')
.describe('n', 'Enable NGRX functionality (enabled | orm) EXPERIMENTAL FEATURE')
.describe('w', 'Automatically wipe SDK Directory')
.describe('v', 'Add default values in models')
.describe('f', 'Generate only FireLoop SDK + Auth Services')
.describe('q', 'quiet mode - no console output (forces -w)')
.describe('t', 'Enable Typescript default true ( React Only )')
.default('l', 'angular2')
.default('d', 'ng2web')
.default('i', 'enabled')
.default('w', 'disabled')
.default('v', 'disabled')
.default('f', 'disabled')
.default('q', false)
.alias({ u: 'url', m: 'module-name', l: 'library', i: 'io', n: 'ngrx', d: 'driver', w: 'wipe', v: 'default-values', f: 'fireloop-only', q: 'quiet' })
.default('t', true)
.alias({ u: 'url', m: 'module-name', l: 'library', i: 'io', n: 'ngrx', d: 'driver', w: 'wipe', v: 'default-values', f: 'fireloop-only', q: 'quiet', t: 'typescript' })
.demand(1)
.argv;
/**
Expand Down Expand Up @@ -88,7 +90,6 @@ var appFile = path.resolve(argv._[0]);
* Load and Boot LoopBack Application
*/
var app = require(appFile);

// Default Values
var context = {
app: app,
Expand All @@ -102,7 +103,8 @@ var context = {
wipe: argv['w'] || 'disabled',
defaultValue: argv['v'] || 'disabled',
fireloopOnly: argv['f'] || 'disabled',
quiet: argv['q'] || false
quiet: argv['q'] || false,
isTyped: argv['t'] == 'false' ? false : true
};

if (context.quiet) {
Expand Down
2 changes: 1 addition & 1 deletion lib/angular2/index.js
Expand Up @@ -724,7 +724,7 @@ module.exports = function generate(ctx) {
// the password property anymore but is required for TypeScript purposes
if (model.isUser && !model.properties.password) {
model.properties.password = {
type: model.properties.username.type
type: String
}
}
// Add Model Properties
Expand Down
9 changes: 9 additions & 0 deletions lib/angular2/shared/config.ejs
Expand Up @@ -26,6 +26,7 @@ export class LoopBackConfig {
private static debug: boolean = true;
private static filterOn: string = 'headers';
private static secure: boolean = false;
private static withCredentials: boolean = false;

public static setApiVersion(version: string = 'api'): void {
LoopBackConfig.version = version;
Expand Down Expand Up @@ -82,4 +83,12 @@ export class LoopBackConfig {
public static isSecureWebSocketsSet(): boolean {
return LoopBackConfig.secure;
}

public static setRequestOptionsCredentials(withCredentials: boolean = false): void {
LoopBackConfig.withCredentials = withCredentials;
}

public static getRequestOptionsCredentials(): boolean {
return LoopBackConfig.withCredentials;
}
}
13 changes: 13 additions & 0 deletions lib/angular2/shared/effects/model.ejs
Expand Up @@ -11,6 +11,7 @@ import { LoopbackAction } from '../models/BaseModels';
import { BaseLoopbackEffects } from './base';
import { resolver } from './resolver';

import * as actions from '../actions';
import { <%- modelName %>ActionTypes, <%- modelName %>Actions } from '../actions/<%- modelName %>';
import { LoopbackErrorActions } from '../actions/error';
import { <%- modelName %>Api } from '../services/index';
Expand Down Expand Up @@ -57,6 +58,18 @@ export class <%- modelName %>Effects extends BaseLoopbackEffects {
resolver({data: response, meta: action.meta}, '<%- model.sharedClass.ctor.relations[rel].targetClass %>', 'deleteByIdSuccess'),
of(new <%- modelName %>Actions.<%- normalizeMethodName(methodName) %>Success(action.payload.id, response, action.meta))
))
<% } else if (methodName.match(/(^__link)/) && model.sharedClass.ctor.relations[action.name.split('_').pop()].targetClass) {
var rel = action.name.split('_').pop(); -%>
.mergeMap((response: any) => concat(
of(new actions['<%- model.sharedClass.ctor.relations[rel].modelThrough.definition.name %>Actions'].createSuccess(response, action.meta)),
of(new <%- modelName %>Actions.<%- normalizeMethodName(methodName) %>Success(action.payload.id, response, action.meta))
))
<% } else if (methodName.match(/(^__unlink)/) && model.sharedClass.ctor.relations[action.name.split('_').pop()].targetClass) {
var rel = action.name.split('_').pop(); -%>
.mergeMap((response: any) => concat(
of(new actions['<%- model.sharedClass.ctor.relations[rel].modelThrough.definition.name %>Actions'].deleteByIdSuccess(response.id, action.meta)),
of(new <%- modelName %>Actions.<%- normalizeMethodName(methodName) %>Success(action.payload.id, response, action.meta))
))
<% } else if (!action.returns || action.returns.length == 0) { -%>
.map((response: any) => new <%- modelName %>Actions.<%- normalizeMethodName(methodName) %>Success(action.payload.id, action.payload.fk, action.meta))
<% } else { -%>
Expand Down
1 change: 1 addition & 0 deletions lib/angular2/shared/orm/filter.ejs
Expand Up @@ -2,6 +2,7 @@
import 'rxjs/add/operator/publishReplay';
import 'rxjs/add/operator/combineLatest';
import 'rxjs/add/operator/withLatestFrom';
import 'rxjs/add/operator/auditTime';
import { Observable } from 'rxjs/Observable';
import * as filterNodes from 'loopback-filters';

Expand Down
14 changes: 7 additions & 7 deletions lib/angular2/shared/services/core/base.ejs
Expand Up @@ -84,7 +84,7 @@ export abstract class BaseLoopBackApi {
if (LoopBackConfig.isHeadersFilteringSet()) {
headers.append('filter', JSON.stringify(urlParams.filter));
} else {
filter = `?filter=${ encodeURI(JSON.stringify(urlParams.filter))}`;
filter = `?filter=${ encodeURIComponent(JSON.stringify(urlParams.filter))}`;
}
delete urlParams.filter;
}
Expand All @@ -104,12 +104,12 @@ export abstract class BaseLoopBackApi {
this.searchParams.setJSON(urlParams);
let request: Request = new Request(
new RequestOptions({
headers : headers,
method : method,
url : `${url}${filter}`,
search : Object.keys(urlParams).length > 0
? this.searchParams.getURLSearchParams() : null,
body : body ? JSON.stringify(body) : undefined
headers : headers,
method : method,
url : `${url}${filter}`,
search : Object.keys(urlParams).length > 0 ? this.searchParams.getURLSearchParams() : null,
body : body ? JSON.stringify(body) : undefined,
withCredentials: LoopBackConfig.getRequestOptionsCredentials()
})
);
return this.http.request(request)
Expand Down

0 comments on commit f37aecf

Please sign in to comment.