Skip to content

Commit

Permalink
Release 2.0.0-rc.8.3 🚀
Browse files Browse the repository at this point in the history
- Milestone Details: https://github.com/mean-expert-official/loopback-sdk-builder/milestone/33?closed=1

- Fix: #330
- Fix: #329
- Fix: #324
- Fix: #320
- Fix: #316
- Fix: #314
- Fix: #311
- Fix: #310
- Fix: #287
- Fix: #282
  • Loading branch information
Jonathan Casarrubias committed Jan 30, 2017
1 parent 97879c0 commit f90e348
Show file tree
Hide file tree
Showing 66 changed files with 2,684 additions and 1,074 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@

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.8.3

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

- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/330
- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/329
- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/324
- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/320
- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/316
- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/314
- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/311
- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/310
- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/287
- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/282

## Release 2.1.0-rc.8.2

- Milestone Details: https://github.com/mean-expert-official/loopback-sdk-builder/milestone/32?closed=1
Expand Down
20 changes: 13 additions & 7 deletions lib/angular2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ module.exports = function generate(ctx) {
params: { loadAccessToken: ctx.loadAccessToken, buildServiceDI }
},
{
template: './shared/services/core/auth.ejs',
template: './shared/services/core/auth.ts',
output: '/services/core/auth.service.ts',
params: { loadAccessToken: ctx.loadAccessToken }
},
Expand Down Expand Up @@ -203,7 +203,7 @@ module.exports = function generate(ctx) {
params: {}
},
{
template: './shared/services/core/realtime.ejs',
template: './shared/services/core/realtime.ts',
output: '/services/core/real.time.ts',
params: {}
},
Expand All @@ -213,7 +213,7 @@ module.exports = function generate(ctx) {
params: {}
},
{
template: './shared/models/flref.ejs',
template: './shared/models/flref.ts',
output: '/models/FireLoopRef.ts',
params: {}
}
Expand Down Expand Up @@ -388,18 +388,24 @@ module.exports = function generate(ctx) {
let targetClass = relation.targetClass;
let basicType = (ctx.models[targetClass]) ? targetClass : 'any';
let finalType = relation.type.match(/(hasOne|belongsTo)/g)
? basicType : `Array<${basicType}>`;
? basicType : `${basicType}[]`;
return finalType;
}
/**
* @method buildObservableType
* @description
* Define observable type
*/
function buildObservableType(modelName, methodName) {
function buildObservableType(model, method) {
let type = 'any';
if (methodName.match(/(^createMany$|^find)/g)) type = `Array<${modelName}>`;
if (methodName.match(/(^create$|upsert|^findBy|^findOne$)/g)) type = modelName;
if (
method.name.match(/(^createMany$|^find)/g) ||
(
typeof method.returns === 'object' &&
(method.returns.type === 'array' || Array.isArray(method.returns.type))
)
) type = `${model.name}[]`;
if (method.name.match(/(^create$|upsert|^findBy|^findOne$)/g)) type = model.name;
return type;
}
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ export class FireLoopRef<T> {
private childs: any = {};
/**
* @method constructor
* @param model
* @param socket
* @param parent
* @param relationship
* @param {any} model The model we want to create a reference
* @param {SocketConnection} socket Socket connection to handle events
* @param {FireLoopRef<any>} parent Parent FireLoop model reference
* @param {string} relationship The defined model relationship
* @description
* The constructor will receive the required parameters and then will register this reference
* into the server, needed to allow multiple references for the same model.
Expand All @@ -33,8 +33,8 @@ export class FireLoopRef<T> {
constructor(
private model: any,
private socket: SocketConnection,
private parent: any = null,
private relationship: any = null
private parent: FireLoopRef<any> = null,
private relationship: string = null
) {
this.socket.emit(
`Subscribe.${ !parent ? model.getModelName() : parent.model.getModelName() }`,
Expand All @@ -44,6 +44,7 @@ export class FireLoopRef<T> {
}
/**
* @method dispose
* @return {void}
* @description
* This method is super important to avoid memory leaks in the server.
* This method requires to be called on components destroy
Expand All @@ -52,42 +53,47 @@ export class FireLoopRef<T> {
* this.someRef.dispose()
* }
**/
public dispose() {
public dispose(): void {
this.operation('dispose', {})
.subscribe()
.unsubscribe();
}
/**
* @method upsert
* @param data
* @param {T} data Persisted model instance
* @return {Observable<T>}
* @description
* Operation wrapper for upsert function.
**/
public upsert(data: any): Observable<T> {
public upsert(data: T): Observable<T> {
return this.operation('upsert', data);
}
/**
* @method create
* @param data
* @param {T} data Persisted model instance
* @return {Observable<T>}
* @description
* Operation wrapper for create function.
**/
public create(data: any): Observable<T> {
public create(data: T): Observable<T> {
return this.operation('create', data);
}
/**
* @method remove
* @param data
* @param {T} data Persisted model instance
* @return {Observable<T>}
* @description
* Operation wrapper for remove function.
**/
public remove(data: any): Observable<T> {
public remove(data: T): Observable<T> {
return this.operation('remove', data);
}
/**
* @method remote
* @param method
* @param params
* @param {string} method Remote method name
* @param {any[]=} params Parameters to be applied into the remote method
* @param {boolean} broadcast Flag to define if the method results should be broadcasted
* @return {Observable<any>}
* @description
* This method calls for any remote method. It is flexible enough to
* allow you call either built-in or custom remote methods.
Expand All @@ -96,17 +102,18 @@ export class FireLoopRef<T> {
* but also to optionally send any defined accept params that will be
* applied within the server.
**/
public remote(method: string, params?: any[], broadcast: Boolean = false): Observable<T> {
public remote(method: string, params?: any[], broadcast: boolean = false): Observable<any> {
return this.operation('remote', { method, params, broadcast });
}
/**
* @method onRemote
* @param method
* @param params
* @param {string} method Remote method name
* @return {Observable<any>}
* @description
* This method listen for public .
* This method listen for public broadcasted remote method results. If the remote method
* execution is not public only the owner will receive the result data.
**/
public onRemote(method: string): Observable<T> {
public onRemote(method: string): Observable<any> {
let event: string = 'remote';
if (!this.relationship) {
event = `${ this.model.getModelName() }.${event}`;
Expand All @@ -117,8 +124,9 @@ export class FireLoopRef<T> {
}
/**
* @method on
* @param event
* @param filter
* @param {string} event Event name
* @param {LoopBackFilter} filter LoopBack query filter
* @return {Observable<T>}
* @description
* Listener for different type of events. Valid events are:
* - change (Triggers on any model change -create, update, remove-)
Expand Down Expand Up @@ -150,7 +158,8 @@ export class FireLoopRef<T> {
}
/**
* @method stats
* @param filter
* @param {LoopBackFilter=} filter LoopBack query filter
* @return {Observable<T>}
* @description
* Listener for real-time statistics, will trigger on every
* statistic modification.
Expand All @@ -161,7 +170,8 @@ export class FireLoopRef<T> {
}
/**
* @method make
* @param instance
* @param {any} instance Persisted model instance reference
* @return {Observable<T>}
* @description
* This method will set a model instance into this a new FireLoop Reference.
* This allows to persiste parentship when creating related instances.
Expand All @@ -177,7 +187,8 @@ export class FireLoopRef<T> {
}
/**
* @method child
* @param relationship
* @param {string} relationship A defined model relationship
* @return {FireLoopRef<T>}
* @description
* This method creates child references, which will persist related model
* instances. e.g. Room.messages, where messages belongs to a specific Room.
Expand All @@ -204,7 +215,9 @@ export class FireLoopRef<T> {
}
/**
* @method pull
* @param relationship
* @param {string} event Event name
* @param {any} request Type of request, can be LB-only filter or FL+LB filter
* @return {Observable<T>}
* @description
* This method will pull initial data from server
**/
Expand All @@ -223,10 +236,13 @@ export class FireLoopRef<T> {
return sbj.asObservable();
}
/**
* @method operation
* @param relationship
* @method broadcasts
* @param {string} event Event name
* @param {any} request Type of request, can be LB-only filter or FL+LB filter
* @return {Observable<T>}
* @description
* This internal method will run operations depending on current context
* This will listen for public broadcasts announces and then request
* for data according a specific client request, not shared with other clients.
**/
private broadcasts(event: string, request: any): Observable<T> {
let sbj: Subject<T> = new Subject<T>();
Expand All @@ -240,8 +256,9 @@ export class FireLoopRef<T> {
}
/**
* @method operation
* @param event
* @param data
* @param {string} event Event name
* @param {any} data Any type of data sent to the server
* @return {Observable<T>}
* @description
* This internal method will run operations depending on current context
**/
Expand Down Expand Up @@ -270,6 +287,7 @@ export class FireLoopRef<T> {
}
/**
* @method buildId
* @return {number}
* @description
* This internal method build an ID for this reference, this allows to have
* multiple references for the same model or relationships.
Expand Down
88 changes: 0 additions & 88 deletions lib/angular2/shared/services/core/auth.ejs

This file was deleted.

Loading

0 comments on commit f90e348

Please sign in to comment.