Giter VIP home page Giter VIP logo

loopback-sdk-builder's People

Contributors

arielschiavoni avatar bajtos avatar beeman avatar brannon-darby avatar davidcheung avatar dehypnosis avatar destreyf avatar dmastag avatar domvanrob avatar dreamdevil00 avatar fabianscheidt avatar jledun avatar jonathan-casarrubias avatar jonnybgod avatar jouke avatar khashayar avatar lx-vitalinedzvedz avatar lygstate avatar mbenedettini avatar mdasmendel avatar mnvx avatar mrbatista avatar nosfistis avatar nuba avatar palra avatar partap avatar pbouda avatar rmg avatar sam-github avatar sylvaindumont avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

loopback-sdk-builder's Issues

base.service.ts json param handling issue: treats post json params to url params

We have issues with custom end points that accept json param instead of data in body. Such params require to be transferred to the body for processing while sending in the request, and would not become part of the search/ url. So following assignment woudl never hit the API correctly:

      this.searchParams.setJSON(params);
      let request = new Request({
        headers : headers,
        method  : method,
        url     : requestUrl,
        search  : this.searchParams.getURLSearchParams(),
        body    : data ? JSON.stringify(data) : undefined
      });

params needs to be parsed and sent in the body I believe.

Update Angular2 documentation

Also rename again the angular generator to angular 2 and remove the angularjs one.

Reasons:

This builder won't support Angular 1.x, we will not compete with the loopback-sdk-angular

Problem when generate patch method.

When I use the SDK builder in Loopback 3 the method patchAttributes throws an error. The method is not sending the data passed as second argument.

User.getCurrent() using wrong URL

The URL from User.ts file for the function getCurrent() is missing the api version.

Instead of:

public getCurrent(): any {
let method: string = "GET";
let url: string = LoopBackConfig.getPath() + "/users" + "/:id";

I think it should be:

let url: string = LoopBackConfig.getPath() + "/" + LoopBackConfig.getApiVersion() + "/users" + "/:id";

This seems to be the only call that is missing the api version (api.ejs):

public getCurrent(): any {
let method: string = "GET";
let url: string = LoopBackConfig.getPath() + <%-: meta.getPath() | q %> + "/:id";

Angular Universal Driver

Hi, any thoughts on what should include the Angular Universal driver?

I have been playing around and the main issue should be with the LoopBackAuth and StorageDriver that uses localStorage (which by definition is not supported in node.js).

Other considerations (things that node.js doesn't support) may be:

  • cookies
  • DOM interactions

But I don't know if the loopback SDK even uses these features.

Anyways, maybe we just need to avoid the LoopBackAuth dependency to get things working for de Angular Universal driver.

Do you see any other pain point or roadblock?

Missing generated files (angular2) - beta6

The following files are missing on the angular2 generated files (beta):

import { LoggerService } from './services/logger.service';
import { JSONSearchParams } from './services/search.params';

RC.3.2 still does not resolve missing models and model name Casing issue

I see that if the loopback model is public, then the imports refer to it in Title case, whereas if the model is public: false it does not get generated (which creates typing issues in typescript, where the variable types of relational properties is undefined).

And also for such models all imports mention them in lower case (my loopback model names are all lower case) and the property definitions also refer to them in lower case.

here, business model is exporting in lower case, but it is being imported elsewhere in Title case, another model that is private : breview, does not get generated (if i make it public just to carry over the generated model - tmp fix, it would be exported in Title case and I'd need to make all references to change case. It becomes nuance. if a model is private, its service can be skipped, but model is required with new RC.2/3 changes.

import {
  Job,
  User,
  breview
} from '../index';

export interface businessInterface {
  brief?: string;    
  jobs?: Array<Job>;
  user?:User;
  reviews?: Array<breview>;
}

export class business implements businessInterface {
  brief: string;  
  jobs: Array<Job>;
  user:User;
  reviews: Array<breview>;

  constructor(instance?: business) {
    Object.assign(this, instance);
  }
}

Merge Angular2 with Nativescript2

Angular2 and Nativescript2 are integrating very well together and there are project trying to reuse most of the code for both platforms. (I am also working on such a starter)

Also looking to our current implementation it seams that both generators are very similar apart form two specific point:

  • socket layer
  • storage layer

I would consider trying to abstract both layers in a way that we could end up with only one template for both platforms.

Would like to know your thought on this.

Routes

How i can import angular 2 routes in loopback. thanks

RC.2 breaking

Hi,
I test the new rc2 sdk builder, but i have some bugs :(

First of all, i launch the build:sdk command, everything is ok, but when i launch the typescript compiler, i have these errors :

Error:(20, 1) TS2308: Module './AccessToken' has already exported a member named 'AccessToken'. Consider explicitly re-exporting to resolve the ambiguity.

this is the content of my sdk/models/index.ts :

/* tslint:disable */
export * from './AccessToken';

export * from './Seminaire';

export * from './User';

export * from './UserEvent';

export * from './UserSeminaire';

export * from './Session';

export * from './Feed';

export * from './Like';

export * from './Comment';

export * from './UserSession';

export * from './Intervenant';

export * from './Image';

export * from './Organisateur';

export * from './Notation';

export * from './ACL';

export * from './RoleMapping';

export * from './Role';

export * from './Email';

export * from './BaseModels';

the error come from the last line because a conflict exist with /AccessToken.

Content of sdk/models/AccessToken.ts :

/* tslint:disable */
import {
    User
} from '../index';

export interface AccessTokenInterface {
    id?:string;
    /**
     * time to live in seconds (2 weeks by default)
     */
    ttl?:number;
    created?:any;
    userId?:string;
    user?:User;
}

export class AccessToken implements AccessTokenInterface {
    id:string;
    /**
     * time to live in seconds (2 weeks by default)
     */
    ttl:number;
    created:any;
    userId:string;
    user:User;

    constructor(instance?:AccessToken) {
        Object.assign(this, instance);
    }
}

Content of sdk/models/BaseModels.ts :

/* tslint:disable */
export interface LoopBackFilterInterface {
  fields?: any;
  include?: any;
  limit?: any;
  order?: any;
  skip?: any;
  offset?: any;
  where?: any;
}

export class LoopBackFilter implements LoopBackFilterInterface {
  fields: any;
  include: any;
  limit: any;
  order: any;
  skip: any;
  offset: any;
  where: any;
}

export interface TokenInterface {
  id?: any;
  user?: any;
  userId?: any;
  ttl?: any;
  created?: any;
}

export class AccessToken implements TokenInterface {
  id: any;
  user: any;
  userId: any;
  ttl: any;
  created: any;
}

This is the 1st error, if i rename AccessToken to Token inside BaseModels.ts, my console.log display this error after the application launching :

zone.js:323 Error: (SystemJS) TypeError: Class extends value undefined is not a function or null
at Object.eval (http://localhost:3000/sdk/services/custom/AccessToken.js:27:58)
at eval (http://localhost:3000/sdk/services/custom/AccessToken.js:948:4)
at eval (http://localhost:3000/sdk/services/custom/AccessToken.js:949:3)
at Object.eval (http://localhost:3000/sdk/services/custom/index.js:6:10)
Evaluating http://localhost:3000/sdk/services/custom/AccessToken.js
Evaluating http://localhost:3000/sdk/services/custom/index.js
Evaluating http://localhost:3000/sdk/services/index.js
Evaluating http://localhost:3000/sdk/index.js
Evaluating http://localhost:3000/sdk/services/core/logger.service.js
Evaluating http://localhost:3000/sdk/services/core/index.js
Evaluating http://localhost:3000/sdk/services/custom/Organisateur.js
Evaluating http://localhost:3000/services/auth.service.js
Evaluating http://localhost:3000/app/ui/navbar.component.js
Evaluating http://localhost:3000/app/app.component.js
Evaluating http://localhost:3000/app/main.js
Error loading http://localhost:3000/app/main.js

I don't understand what is the problem... please do you have this bug ? and can you resolve it please ?

Many thanks for your help,
best regards
BM

Proposal: Add to manual

Actually in my project I have a warning (node) warning: possible EventEmitter memory leak detected. 11 authentication listeners added. Use emitter.setMaxListeners() to increase limit.

I thing is good idea add in the manual anything help or instruction for that.

Angular 2 won't compile in webpack when using built SDK

I've followed the instructions for generating the angular2 sdk in the documention and receive the following error when building my project with webpack.

ERROR in ./src/client/app/shared/lb-services/services/api.d.ts
Module build failed: Error: Debug Failure. False expression: Output generation failed
    at Object.assert (C:\Users\Josh\Documents\Github\muskoka\node_modules\typescript\lib\typescript.js:2099:23)
    at Object.transpileModule (C:\Users\Josh\Documents\Github\muskoka\node_modules\typescript\lib\typescript.js:53173:18)
    at State.fastEmit (C:\Users\Josh\Documents\Github\muskoka\node_modules\awesome-typescript-loader\dist.babel\host.js:302:43)
    at transform (C:\Users\Josh\Documents\Github\muskoka\node_modules\awesome-typescript-loader\dist.babel\index.js:215:53)
    at _callee3$ (C:\Users\Josh\Documents\Github\muskoka\node_modules\awesome-typescript-loader\dist.babel\index.js:265:42)
    at tryCatch (C:\Users\Josh\Documents\Github\muskoka\node_modules\regenerator-runtime\runtime.js:62:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\Josh\Documents\Github\muskoka\node_modules\regenerator-runtime\runtime.js:336:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (C:\Users\Josh\Documents\Github\muskoka\node_modules\regenerator-runtime\runtime.js:95:21)
    at fulfilled (C:\Users\Josh\Documents\Github\muskoka\node_modules\awesome-typescript-loader\dist.babel\index.js:31:32)
    at run (C:\Users\Josh\Documents\Github\muskoka\node_modules\core-js\modules\es6.promise.js:89:22)
    at C:\Users\Josh\Documents\Github\muskoka\node_modules\core-js\modules\es6.promise.js:102:28
    at flush (C:\Users\Josh\Documents\Github\muskoka\node_modules\core-js\modules\_microtask.js:18:9)
    at nextTickCallbackWith0Args (node.js:420:9)
    at process._tickCallback (node.js:349:13)
 @ ./src/client/app/shared/lb-services/index.ts 22:9-36

generate local lb-ng blob

This should generate an executable in node_modules/.bin/lb-ng to prevent need for global installation and easy CI.

Refactor Angular 2 Generator

We already have a pretty stable generated SDK but the generator is super messy and out of any standard. Refactor to avoid multiple loops and the huge amount of duplicated code.

This is for release candidate 3 and should be transparent for final usage.

This should improve performance while generating SDK

Consistent model naming / referring

Although the models and APIs are referred to in Title case, the interface and models are being exported in provided case (in my case lower case). This results in errors in case you have any model name in lower case.

Following two changes correct the Title casing for properties and models: (utils.js)


    var name = c.name;
    var name = c.name[0].toUpperCase() + c.name.slice(1);
 targetClass = targetClass[0].toUpperCase() + targetClass.slice(1);
  modelClass.sharedClass.ctor.relations[scopeName].targetClass = targetClass;

Issue on storage.driver.ts

On the storage.driver.ts of ng4web the line 10 is setting "null" as string to the localStorage[key]. Then assuming that getCurrentUserId() is null, when I'm doing something like:

if (this.loopbackAuth.getCurrentUserId() !== null) {
    //this code will be executed
}

The code will be executed.

Here how I replaced to fix it:

/* tslint:disable */
export class StorageDriver {
  static set(key: string, value: string) {
    localStorage.setItem(key, value); //instead of localStorage[key] = value;
  }
  static get(key: string): string {
    return localStorage.getItem(key); //instead of localStorage[key];
  }
  static remove(key: string): any {
    localStorage.removeItem(key);  //instead of localStorage[key] = null;
  }
}

Thank you again!

Issue while generating angular 2 sdk

undefined:25
throw err;
^

TypeError: ejs:9
7| import { ErrorHandler } from './services/errorHandler.service';
8| import {

9| <% models.forEach(function(modelName, i, arr) {
10| var meta = models[modelName];
11| // capitalize the model name
12| modelName = modelName[0].toUpperCase() + modelName.slice(1);

custom methods with json params do not get appended to request body

In the model function the "data" property is wrongly set from the first param (by ejs), this results in other params being missed, ideally we need to merge the params with data and send in request body:


    let result = this.request(method, url, urlParams, params<%= 
      postData && postData.length > 0 ? ", " + postData[0].arg : '' %>, true)<%

https://github.com/jonathan-casarrubias/loopback-sdk-builder/blob/master/lib/angular2/shared/services/custom/service.ejs#L194-L195

Add unexpected ;

In the beta15 version the created code have a error with unexpected ; in LoopBackConfig.getApiVersion() + ;

redux/ngrx support

What are your thoughts on including generators for both redux since you want to support react and ngrx for angular2?

I am not sure if we should include these in this project or spin another project specific for it. What do you think?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.