From a61722146fef8a306293a73fa0be06f28e681933 Mon Sep 17 00:00:00 2001 From: Jonathan Casarrubias Date: Tue, 18 Oct 2016 14:05:17 -0500 Subject: [PATCH] Release 2.1.0-beta.11 :rocket: - Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/157 - Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/155 - Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/154 - Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/153 - Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/152 - Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/151 - Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/148 - Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/147 --- .travis.yml | 3 + CHANGELOG.md | 11 +++ README.md | 5 +- bin/lb-sdk | 1 + lib/angular2/index.js | 4 +- package.json | 14 ++-- tests/angular2/.github/CONTRIBUTING.md | 34 +++++++++ tests/angular2/common/models/room.js | 33 +++++++-- tests/angular2/karma.conf.js | 3 +- tests/angular2/loopback/boot/ng2finder.js | 25 +++++++ tests/angular2/package.json | 8 ++- .../angular2/src/app/access/access.routing.ts | 2 +- tests/angular2/src/app/app.component.ts | 4 +- tests/angular2/src/app/app.module.ts | 1 - tests/angular2/src/app/app.routing.ts | 1 - .../src/app/room-service.service.spec.ts | 10 +++ tests/angular2/src/app/room/room.routing.ts | 2 +- .../shared/sdk/services/core/base.service.ts | 69 +++++++++---------- .../shared/sdk/services/core/error.service.ts | 3 +- .../app/shared/sdk/services/custom/Account.ts | 5 +- .../app/shared/sdk/services/custom/Core.ts | 2 - .../app/shared/sdk/services/custom/Room.ts | 54 +++++++++++++-- .../app/shared/sdk/services/custom/Storage.ts | 12 +--- .../app/shared/sdk/services/custom/User.ts | 5 +- 24 files changed, 227 insertions(+), 84 deletions(-) create mode 100644 .travis.yml create mode 100644 tests/angular2/.github/CONTRIBUTING.md create mode 100644 tests/angular2/loopback/boot/ng2finder.js diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..b16d7f92 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,3 @@ +language: node_js +node_js: + - "6" \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index f4b1eb1a..b684a0dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,17 @@ 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.11 + +- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/157 +- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/155 +- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/154 +- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/153 +- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/152 +- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/151 +- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/148 +- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/147 + ## Release 2.1.0-beta.10 - Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/142 diff --git a/README.md b/README.md index d5ec087e..5e03e014 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,11 @@ +[![Build Status](https://travis-ci.org/mean-expert-official/loopback-sdk-builder.svg?branch=development)](https://travis-ci.org/mean-expert-official/loopback-sdk-builder) + ![LoopBack SDK Builder](https://storage.googleapis.com/mean-expert-images/sdk-builder.jpg) -LoopBack SDK Builder +LoopBack SDK Builder ================== + The [@mean-expert/loopback-sdk-builder](https://www.npmjs.com/package/@mean-expert/loopback-sdk-builder) is a community driven module forked from the official `loopback-sdk-angular` and refactored to support [Angular 2](http://angular.io). The [LoopBack SDK Builder](https://www.npmjs.com/package/@mean-expert/loopback-sdk-builder) will explore your [LoopBack Application](http://loopback.io) and will automatically build everything you need to start writing your [Angular 2 Applications](http://angular.io) right away. From Interfaces and Models to API Services and Real-time communications. diff --git a/bin/lb-sdk b/bin/lb-sdk index 7e1aa2ec..654cd777 100755 --- a/bin/lb-sdk +++ b/bin/lb-sdk @@ -53,6 +53,7 @@ console.log(chalk.green('* CONTRIBUTORS console.log(chalk.green('* João Ribeiro *')); console.log(chalk.green('* Nikolay Matiushenkov *')); console.log(chalk.green('* Sylvain Dumont *')); +console.log(chalk.green('* Yonggang Luo *')); console.log(chalk.green('* *')); console.log(chalk.green('* ORIGINALLY FORKED FROM *')); console.log(chalk.green('* Miroslav Bajtos\' *')); diff --git a/lib/angular2/index.js b/lib/angular2/index.js index 5a742d26..4fff33c8 100644 --- a/lib/angular2/index.js +++ b/lib/angular2/index.js @@ -403,7 +403,7 @@ module.exports = function generate(ctx) { { module: 'ErrorHandler', from: './error.service'}, { module: 'LoopBackAuth', from: './auth.service'}, { module: 'LoopBackConfig', from: '../../lb.config'}, - { module: 'AccessToken', from: '../../models'}, + { module: 'AccessToken', from: '../../models/index'}, { module: 'Observable', from: 'rxjs/Observable' }, { module: 'ErrorObservable', from: 'rxjs/observable/ErrorObservable' }, { module: 'rxjs/add/operator/catch' }, @@ -505,7 +505,7 @@ module.exports = function generate(ctx) { * Testing if the param is route type */ function paramIsRoute(param) { - return (param.http && param.http.source === 'path') || (param.arg && param.arg.match(/(id|fk|file|container)/)); + return (param.http && param.http.source === 'path') || (param.arg && param.arg.match(/(^id$|fk|file|container)/)); } /** * @method paramIsFunction diff --git a/package.json b/package.json index 52463830..b8b98b76 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mean-expert/loopback-sdk-builder", - "version": "2.1.0-beta.10", + "version": "2.1.0-beta.11", "description": "Tool for auto-generating Software Development Kits (SDKs) for LoopBack", "bin": { "lb-sdk": "bin/lb-sdk" @@ -8,9 +8,10 @@ "main": "index.js", "scripts": { "prepublish": "", - "test": "npm run test:angular2", - "pretest": "cd tests/angular2 && npm install", - "test:angular2": "cd tests/angular2 && ng lint && npm run test" + "test": "npm run load:api & npm run test:angular2", + "pretest": "cd tests/angular2 && npm install && npm install ../../ && npm run build:sdk", + "load:api": "cd tests/angular2 && NODE_ENV=testing node loopback/server", + "test:angular2": "cd tests/angular2 && npm test" }, "repository": { "type": "git", @@ -44,6 +45,11 @@ "name": "Sylvain Dumont", "email": "sylvain.dumont35@gmail.com", "url": "https://www.weboaks.com" + }, + { + "name": "Yonggang Luo", + "email": "luoyonggang@gmail.com", + "url": "https://github.com/lygstate" } ], "license": "MIT", diff --git a/tests/angular2/.github/CONTRIBUTING.md b/tests/angular2/.github/CONTRIBUTING.md new file mode 100644 index 00000000..9ada8155 --- /dev/null +++ b/tests/angular2/.github/CONTRIBUTING.md @@ -0,0 +1,34 @@ +# How to contribute + +I'm really glad you're reading this, volunteer developers to help this project are always welcome. + +If you haven't already, follow me ([@johncasarrubias](irc://chat.freenode.net/opengovernment) on twitter). I want you to keep informed about new features and tutorials. + +Here are some important resources: + + * [MEAN Expert Blog](http://mean.expert) tutorials about the MEAN Stack. + * [WIKI](https://github.com/mean-expert-official/loopback-sdk-builder/wiki) official wiki documentation. + * [Angular 2 Testing](https://angular.io/docs/ts/latest/guide/testing.html) official documentation for testing environment. + * Bugs? [GitHub Issues](https://github.com/mean-expert-official/loopback-sdk-builder/issues) is where to report them + +## Testing + +Tests are being created and excecuted by using the Angular-CLI Tool, please refer to the official documentation. + +````sh +$ cd to/loopback-sdk-builder +$ npm test +```` + +## Submitting changes + +Please send a [GitHub Pull Request](https://github.com/mean-expert-official/loopback-sdk-builder/pull/new/master) with a clear list of what you've done (read more about [pull requests](http://help.github.com/pull-requests/)). When you send a pull request, we will love you forever if you include RSpec examples. We can always use more test coverage. Please follow our coding conventions (below) and make sure all of your commits are atomic (one feature per commit). + +Always write a clear log message for your commits. One-line messages are fine for small changes, but bigger changes should look like this: + + $ git commit -m "A brief summary of the commit + > + > A paragraph describing what changed and its impact." + +Thanks, +Jonathan Casarrubias, [MEAN Expert](http://mean.expert). \ No newline at end of file diff --git a/tests/angular2/common/models/room.js b/tests/angular2/common/models/room.js index 19ed3141..3ac66c46 100644 --- a/tests/angular2/common/models/room.js +++ b/tests/angular2/common/models/room.js @@ -15,21 +15,42 @@ module.exports = function (Room) { } ); - Room.greetPost = greet; - + // We receive 3 copies of the body from loopback, not sure why + // I would expect body.a, body.b and body.c in 1 object param. + Room.greetPost = (b1, b2, b3, next) => { + next(null, `${b1.a}:${b2.b}:${b3.c}`); + }; + Room.remoteMethod( 'greetPost', { accepts: [ - { arg: 'a', type: 'string' }, - { arg: 'b', type: 'string' }, - { arg: 'c', type: 'string' } + { arg: 'a', type: 'object', http: { source: 'body' }}, + { arg: 'b', type: 'object', http: { source: 'body' }}, + { arg: 'c', type: 'object', http: { source: 'body' }} ], - returns: { arg: 'greeting', type: 'string' }, + returns: { arg: 'greeting', type: 'object' }, http: { path: '/who', verb: 'post' } } ); + Room.singleParamPost = function (body, next) { + next(null, body); + }; + + Room.remoteMethod( + 'singleParamPost', + { + accepts: { + arg: 'param', + type: 'object', + http: { source: 'body' } + }, + returns: { arg: 'param', type: 'object', root: true }, + http: { path: '/single-param-post', verb: 'post' } + } + ); + Room.greetGet = greet; Room.remoteMethod( diff --git a/tests/angular2/karma.conf.js b/tests/angular2/karma.conf.js index e28922ac..2609f9cd 100644 --- a/tests/angular2/karma.conf.js +++ b/tests/angular2/karma.conf.js @@ -8,6 +8,7 @@ module.exports = function (config) { plugins: [ require('karma-jasmine'), require('karma-chrome-launcher'), + require('karma-phantomjs-launcher'), require('karma-remap-istanbul'), require('angular-cli/plugins/karma') ], @@ -32,7 +33,7 @@ module.exports = function (config) { colors: true, logLevel: config.LOG_INFO, autoWatch: true, - browsers: ['Chrome'], + browsers: ['PhantomJS'], singleRun: false }); }; diff --git a/tests/angular2/loopback/boot/ng2finder.js b/tests/angular2/loopback/boot/ng2finder.js new file mode 100644 index 00000000..3ba0f702 --- /dev/null +++ b/tests/angular2/loopback/boot/ng2finder.js @@ -0,0 +1,25 @@ +var net = require('net') + +module.exports = function(app) { + if (process.NODE_ENV !== 'testing') return; + var testing = false; + var interval = setInterval(function () { + isPortTaken(9876, function (err, taken) { + if (!testing && taken) testing = true; + if (testing && !taken) process.exit() + }) + }, 1000); +}; + +var isPortTaken = function(port, fn) { + var tester = net.createServer() + .once('error', function (err) { + if (err.code != 'EADDRINUSE') return fn(err) + fn(null, true) + }) + .once('listening', function() { + tester.once('close', function() { fn(null, false) }) + .close() + }) + .listen(port) +} diff --git a/tests/angular2/package.json b/tests/angular2/package.json index af119edb..216042a5 100644 --- a/tests/angular2/package.json +++ b/tests/angular2/package.json @@ -8,8 +8,9 @@ "lint": "tslint \"src/**/*.ts\"", "pree2e": "webdriver-manager update", "e2e": "protractor", - "test": "node loopback/server.js & ng test", - "build:sdk": "./node_modules/.bin/lb-sdk loopback/server.js src/app/shared/sdk -i enabled" + "pretest": "ng lint", + "test": "ng test --watch=false", + "build:sdk": "./node_modules/.bin/lb-sdk loopback/server.js src/app/shared/sdk -i enabled -w enabled" }, "private": true, "dependencies": { @@ -21,6 +22,7 @@ "@angular/platform-browser": "2.0.0", "@angular/platform-browser-dynamic": "2.0.0", "@angular/router": "3.0.0", + "@mean-expert/loopback-component-realtime": "^1.0.0-beta.5", "@types/socket.io-client": "^1.4.27", "compression": "^1.0.3", "config-chain": "^1.1.10", @@ -51,7 +53,9 @@ "karma-chrome-launcher": "^2.0.0", "karma-cli": "^1.0.1", "karma-jasmine": "^1.0.2", + "karma-phantomjs-launcher": "^1.0.2", "karma-remap-istanbul": "^0.2.1", + "phantomjs": "^2.1.7", "protractor": "4.0.5", "ts-node": "1.2.1", "tslint": "3.13.0", diff --git a/tests/angular2/src/app/access/access.routing.ts b/tests/angular2/src/app/access/access.routing.ts index 96f560e5..f5bc9759 100644 --- a/tests/angular2/src/app/access/access.routing.ts +++ b/tests/angular2/src/app/access/access.routing.ts @@ -9,4 +9,4 @@ const accessRoutes: Routes = [ } ]; -export const accessRouting: ModuleWithProviders = RouterModule.forChild(accessRoutes); \ No newline at end of file +export const accessRouting: ModuleWithProviders = RouterModule.forChild(accessRoutes); diff --git a/tests/angular2/src/app/app.component.ts b/tests/angular2/src/app/app.component.ts index e26f1c4b..7371666d 100644 --- a/tests/angular2/src/app/app.component.ts +++ b/tests/angular2/src/app/app.component.ts @@ -23,8 +23,8 @@ export class AppComponent { ) { this.logger.info('LoopBack SDK Builder - Test Application'); // Simple IO Test - //this.realTime.IO.emit('hello', 'world'); - //this.realTime.IO.on('hello').subscribe((msg: any) => this.logger.info('REALTIME: ', msg)); + // this.realTime.IO.emit('hello', 'world'); + // this.realTime.IO.on('hello').subscribe((msg: any) => this.logger.info('REALTIME: ', msg)); // Simple FireLoop set and get examples. let RoomReference: FireLoopRef = this.realTime.FireLoop.ref(Room); // This will get the list of results and fire every time there is new data. diff --git a/tests/angular2/src/app/app.module.ts b/tests/angular2/src/app/app.module.ts index e33513c7..99f27c21 100644 --- a/tests/angular2/src/app/app.module.ts +++ b/tests/angular2/src/app/app.module.ts @@ -1,7 +1,6 @@ import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; -import { HttpModule } from '@angular/http'; import { AppComponent } from './app.component'; import { SDKModule } from './shared/sdk/index'; import { routing, appRoutingProviders } from './app.routing'; diff --git a/tests/angular2/src/app/app.routing.ts b/tests/angular2/src/app/app.routing.ts index 1ac415f6..0a1849a0 100644 --- a/tests/angular2/src/app/app.routing.ts +++ b/tests/angular2/src/app/app.routing.ts @@ -1,6 +1,5 @@ import { ModuleWithProviders } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; -import { RoomComponent } from './room/room.component'; import { AuthGuard } from './shared/auth.guard'; const appRoutes: Routes = [ diff --git a/tests/angular2/src/app/room-service.service.spec.ts b/tests/angular2/src/app/room-service.service.spec.ts index 9c18ae1b..16363d8d 100644 --- a/tests/angular2/src/app/room-service.service.spec.ts +++ b/tests/angular2/src/app/room-service.service.spec.ts @@ -111,6 +111,16 @@ describe('Service: Room Service', () => { }) )); + it('should fetch filter as object from single-param post method', + async(inject([RoomApi], (roomApi: RoomApi) => { + let param = { child: 'filtered' }; + return roomApi.singleParamPost(param).subscribe((result: { child: string, param: undefined }) => { + expect(result.param).toBe(undefined); + expect(result.child).toBe(param.child); + }); + }) + )); + it('should include multiple layers', async(inject([RoomApi, MessageApi], (roomApi: RoomApi, messageApi: MessageApi) => { let room: Room = new Room({ name: Date.now().toString() }); diff --git a/tests/angular2/src/app/room/room.routing.ts b/tests/angular2/src/app/room/room.routing.ts index 4757d677..736ca8d8 100644 --- a/tests/angular2/src/app/room/room.routing.ts +++ b/tests/angular2/src/app/room/room.routing.ts @@ -11,4 +11,4 @@ const roomRoutes: Routes = [ } ]; -export const roomRouting: ModuleWithProviders = RouterModule.forChild(roomRoutes); \ No newline at end of file +export const roomRouting: ModuleWithProviders = RouterModule.forChild(roomRoutes); diff --git a/tests/angular2/src/app/shared/sdk/services/core/base.service.ts b/tests/angular2/src/app/shared/sdk/services/core/base.service.ts index 880701b8..eac19124 100644 --- a/tests/angular2/src/app/shared/sdk/services/core/base.service.ts +++ b/tests/angular2/src/app/shared/sdk/services/core/base.service.ts @@ -6,7 +6,8 @@ import { JSONSearchParams } from './search.params'; import { ErrorHandler } from './error.service'; import { LoopBackAuth } from './auth.service'; import { LoopBackConfig } from '../../lb.config'; -import { AccessToken } from '../../models'; +import { AccessToken } from '../../models/index'; +import { Observable } from 'rxjs/Observable'; import { ErrorObservable } from 'rxjs/observable/ErrorObservable'; import 'rxjs/add/operator/catch'; import 'rxjs/add/operator/map'; @@ -29,9 +30,9 @@ export abstract class BaseLoopBackApi { protected path: string; constructor( - @Inject(Http) protected http: Http, - @Inject(LoopBackAuth) protected auth: LoopBackAuth, - @Inject(JSONSearchParams) protected searchParams: JSONSearchParams, + @Inject(Http) protected http: Http, + @Inject(LoopBackAuth) protected auth: LoopBackAuth, + @Inject(JSONSearchParams) protected searchParams: JSONSearchParams, @Optional() @Inject(ErrorHandler) protected errorHandler: ErrorHandler ) {} @@ -49,8 +50,9 @@ export abstract class BaseLoopBackApi { url : string, routeParams : any = {}, urlParams : any = {}, - postBody : any = null, isio : boolean = false - ) { + postBody : any = null, + isio : boolean = false + ): Observable { let headers = new Headers(); headers.append('Content-Type', 'application/json'); @@ -84,33 +86,30 @@ export abstract class BaseLoopBackApi { let socket: any = SocketConnections.getHandler(LoopBackConfig.getPath(), token); socket.on(event, (res: any) => subject.next(res)); return subject.asObservable(); - } else { // Body fix for built in remote methods using "data", "options" or "credentials - // that are the actual body, Custom remote method properties are different and need - // to be wrapped into a body object - let body: any; - if ( - typeof postBody === 'object' && - (postBody.data || postBody.credentials || postBody.options) && - Object.keys(postBody).length === 1 - ) { - body = postBody.data ? postBody.data : - postBody.options ? postBody.options : - postBody.credentials; - } else { - body = postBody; - } - this.searchParams.setJSON(urlParams); - let request: Request = new Request({ - headers : headers, - method : method, - url : urlParams.filter ? `${requestUrl}?filter=${ encodeURI(JSON.stringify(urlParams.filter))}` - : requestUrl, - search : !urlParams.filter && Object.keys(urlParams).length > 0 - ? this.searchParams.getURLSearchParams() : null, - body : body ? JSON.stringify(body) : undefined - }); - return this.http.request(request) - .map((res: any) => (res.text() != "" ? res.json() : {})) - .catch(this.errorHandler.handleError); - } } + } + + // Body fix for built in remote methods using "data", "options" or "credentials + // that are the actual body, Custom remote method properties are different and need + // to be wrapped into a body object + let body: any; + let postBodyKeys = typeof postBody === 'object' ? Object.keys(postBody) : [] + if (postBodyKeys.length === 1) { + body = postBody[postBodyKeys[0]] + } else { + body = postBody; + } + this.searchParams.setJSON(urlParams); + let request: Request = new Request({ + headers : headers, + method : method, + url : urlParams.filter ? `${requestUrl}?filter=${ encodeURI(JSON.stringify(urlParams.filter))}` + : requestUrl, + search : !urlParams.filter && Object.keys(urlParams).length > 0 + ? this.searchParams.getURLSearchParams() : null, + body : body ? JSON.stringify(body) : undefined + }); + return this.http.request(request) + .map((res: any) => (res.text() != "" ? res.json() : {})) + .catch(this.errorHandler.handleError); + } } diff --git a/tests/angular2/src/app/shared/sdk/services/core/error.service.ts b/tests/angular2/src/app/shared/sdk/services/core/error.service.ts index f1b33c1d..92c2d0ef 100644 --- a/tests/angular2/src/app/shared/sdk/services/core/error.service.ts +++ b/tests/angular2/src/app/shared/sdk/services/core/error.service.ts @@ -2,13 +2,14 @@ import { Injectable } from '@angular/core'; import { Response } from '@angular/http'; import { Observable } from 'rxjs/Observable'; +import { ErrorObservable } from 'rxjs/observable/ErrorObservable'; import 'rxjs/add/observable/throw'; /** * Default error handler */ @Injectable() export class ErrorHandler { - public handleError(error: Response) { + public handleError(error: Response): ErrorObservable { return Observable.throw(error.json().error || 'Server error'); } } diff --git a/tests/angular2/src/app/shared/sdk/services/custom/Account.ts b/tests/angular2/src/app/shared/sdk/services/custom/Account.ts index b48288e8..5dd547f1 100644 --- a/tests/angular2/src/app/shared/sdk/services/custom/Account.ts +++ b/tests/angular2/src/app/shared/sdk/services/custom/Account.ts @@ -1669,11 +1669,10 @@ export class AccountApi extends BaseLoopBackApi { let method: string = "GET"; let url: string = LoopBackConfig.getPath() + "/" + LoopBackConfig.getApiVersion() + "/Accounts/confirm"; - let routeParams: any = { - uid: uid - }; + let routeParams: any = {}; let postBody: any = {}; let urlParams: any = {}; + if (uid) urlParams.uid = uid; if (token) urlParams.token = token; if (redirect) urlParams.redirect = redirect; let result = this.request(method, url, routeParams, urlParams, postBody); diff --git a/tests/angular2/src/app/shared/sdk/services/custom/Core.ts b/tests/angular2/src/app/shared/sdk/services/custom/Core.ts index 829238e9..13cd101b 100644 --- a/tests/angular2/src/app/shared/sdk/services/custom/Core.ts +++ b/tests/angular2/src/app/shared/sdk/services/custom/Core.ts @@ -61,7 +61,6 @@ export class CoreApi extends BaseLoopBackApi { body: body }; let urlParams: any = {}; - if (body) urlParams.body = body; let result = this.request(method, url, routeParams, urlParams, postBody); return result; } @@ -90,7 +89,6 @@ export class CoreApi extends BaseLoopBackApi { request: request }; let urlParams: any = {}; - if (request) urlParams.request = request; let result = this.request(method, url, routeParams, urlParams, postBody); return result; } diff --git a/tests/angular2/src/app/shared/sdk/services/custom/Room.ts b/tests/angular2/src/app/shared/sdk/services/custom/Room.ts index 2a983a19..c18bdfda 100644 --- a/tests/angular2/src/app/shared/sdk/services/custom/Room.ts +++ b/tests/angular2/src/app/shared/sdk/services/custom/Room.ts @@ -2270,11 +2270,11 @@ export class RoomApi extends BaseLoopBackApi { * * @param object data Request data. * - * - `a` – `{string}` - + * - `a` – `{object}` - * - * - `b` – `{string}` - + * - `b` – `{object}` - * - * - `c` – `{string}` - + * - `c` – `{object}` - * * @returns object An empty reference that will be * populated with the actual data once the response is returned @@ -2282,7 +2282,7 @@ export class RoomApi extends BaseLoopBackApi { * * Data properties: * - * - `greeting` – `{string}` - + * - `greeting` – `{object}` - */ public greetPost(a: any = undefined, b: any = undefined, c: any = undefined): Observable { let method: string = "POST"; @@ -2295,9 +2295,6 @@ export class RoomApi extends BaseLoopBackApi { c: c }; let urlParams: any = {}; - if (a) urlParams.a = a; - if (b) urlParams.b = b; - if (c) urlParams.c = c; let result = this.request(method, url, routeParams, urlParams, postBody); return result; } @@ -2314,6 +2311,49 @@ export class RoomApi extends BaseLoopBackApi { return result; } + /** + * + * (The remote method definition does not provide any description.) + * + * + * @param object data Request data. + * + * This method expects a subset of model properties as request parameters. + * + * @returns object An empty reference that will be + * populated with the actual data once the response is returned + * from the server. + * + * + * (The remote method definition does not provide any description. + * This usually means the response is a `Room` object.) + * + */ + public singleParamPost(param: any = undefined): Observable { + let method: string = "POST"; + let url: string = LoopBackConfig.getPath() + "/" + LoopBackConfig.getApiVersion() + + "/rooms/single-param-post"; + let routeParams: any = {}; + let postBody: any = { + param: param + }; + let urlParams: any = {}; + let result = this.request(method, url, routeParams, urlParams, postBody); + return result; + } + + public onSingleParamPost(param: any = undefined): Observable { + let method: string = "POST"; + let url: string = "/" + LoopBackConfig.getApiVersion() + + "/rooms/single-param-post"; + let routeParams: any = {}; + let postBody: any = {}; + let urlParams: any = {}; + let result = this.request(method, url, routeParams, urlParams, postBody, true); + ; + return result; + } + /** * * (The remote method definition does not provide any description.) diff --git a/tests/angular2/src/app/shared/sdk/services/custom/Storage.ts b/tests/angular2/src/app/shared/sdk/services/custom/Storage.ts index d469c2a2..4e074562 100644 --- a/tests/angular2/src/app/shared/sdk/services/custom/Storage.ts +++ b/tests/angular2/src/app/shared/sdk/services/custom/Storage.ts @@ -110,7 +110,6 @@ export class StorageApi extends BaseLoopBackApi { }; let postBody: any = {}; let urlParams: any = {}; - if (container) urlParams.container = container; let result = this.request(method, url, routeParams, urlParams, postBody); return result; } @@ -140,7 +139,6 @@ export class StorageApi extends BaseLoopBackApi { }; let postBody: any = {}; let urlParams: any = {}; - if (container) urlParams.container = container; let result = this.request(method, url, routeParams, urlParams, postBody); return result; } @@ -170,7 +168,6 @@ export class StorageApi extends BaseLoopBackApi { }; let postBody: any = {}; let urlParams: any = {}; - if (container) urlParams.container = container; let result = this.request(method, url, routeParams, urlParams, postBody); return result; } @@ -203,8 +200,6 @@ export class StorageApi extends BaseLoopBackApi { }; let postBody: any = {}; let urlParams: any = {}; - if (container) urlParams.container = container; - if (file) urlParams.file = file; let result = this.request(method, url, routeParams, urlParams, postBody); return result; } @@ -236,8 +231,6 @@ export class StorageApi extends BaseLoopBackApi { }; let postBody: any = {}; let urlParams: any = {}; - if (container) urlParams.container = container; - if (file) urlParams.file = file; let result = this.request(method, url, routeParams, urlParams, postBody); return result; } @@ -266,10 +259,7 @@ export class StorageApi extends BaseLoopBackApi { let url: string = LoopBackConfig.getPath() + "/" + LoopBackConfig.getApiVersion() + "/storages/:container/upload"; let routeParams: any = {}; - let postBody: any = { - req: req, - res: res - }; + let postBody: any = {}; let urlParams: any = {}; if (req) urlParams.req = req; if (res) urlParams.res = res; diff --git a/tests/angular2/src/app/shared/sdk/services/custom/User.ts b/tests/angular2/src/app/shared/sdk/services/custom/User.ts index faaf83ee..8cb7ac1d 100644 --- a/tests/angular2/src/app/shared/sdk/services/custom/User.ts +++ b/tests/angular2/src/app/shared/sdk/services/custom/User.ts @@ -737,11 +737,10 @@ export class UserApi extends BaseLoopBackApi { let method: string = "GET"; let url: string = LoopBackConfig.getPath() + "/" + LoopBackConfig.getApiVersion() + "/Users/confirm"; - let routeParams: any = { - uid: uid - }; + let routeParams: any = {}; let postBody: any = {}; let urlParams: any = {}; + if (uid) urlParams.uid = uid; if (token) urlParams.token = token; if (redirect) urlParams.redirect = redirect; let result = this.request(method, url, routeParams, urlParams, postBody);