diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0bd2775..4a266c1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,8 @@
- HttpStorage deprecated: jsons were saved as sent by the server, now we save json with logic (saving ids and resources separately).
- Service with `toServer()` and `fromServer()` functions. They execute before and after http request. Ideal for type conversions.
- `JsonapiCore.duplicateResource(resouce, ...relationtypes)` return a duplication of resource. You can duplicate resources and, optionally, their relationships. (v0.6.16)
+- resource save() method return a promise.
+- Fix problem with `Possibly unhandled rejection: undefined` with new AngularJs.
## No more declaration file .d.ts
diff --git a/conf/webpack-dist.conf.js b/conf/webpack-dist.conf.js
index 78b8c27..947c449 100644
--- a/conf/webpack-dist.conf.js
+++ b/conf/webpack-dist.conf.js
@@ -57,6 +57,7 @@ module.exports = {
// compress: {unused: true, dead_code: true} // eslint-disable-line camelcase
// })
],
+ bail: true,
output: {
// https://webpack.github.io/docs/library-and-externals.html
path: path.join(process.cwd(), conf.paths.dist),
diff --git a/package.json b/package.json
index 33d0fc7..9820912 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "ts-angular-jsonapi",
- "version": "0.6.24",
+ "version": "0.6.30",
"description": "JSONAPI library developed for AngularJS in Typescript",
"repository": {
"type": "git",
@@ -10,20 +10,19 @@
"url": "https://github.com/reyesoft/ts-angular-jsonapi/issues"
},
"dependencies": {
- "angular": "<1.6.0",
- "angular-localforage": "^1.3.0",
- "localforage-getitems": "^1.3.0"
+ "angular": ">=1.4.0",
+ "angular-localforage": "1.3.7"
},
"devDependencies": {
- "@types/angular": "^1.6.6",
+ "@types/angular": "^1.6.4",
"@types/angular-mocks": "^1.5.9",
"@types/angular-ui-router": "^1.1.36",
"@types/es6-shim": "^0.31.32",
"@types/jasmine": "^2.5.43",
- "@types/jquery": "^2.0.40",
- "@types/node": "^7.0.5",
+ "@types/jquery": "^3.2.6",
+ "@types/node": "^8.0.8",
"angular-mocks": "^1.6.2",
- "angular-ui-router": "1.0.0-beta.3",
+ "angular-ui-router": "1.0.3",
"autoprefixer": "^6.7.3",
"babel-eslint": "^7.1.1",
"babel-loader": "^6.3.2",
@@ -34,7 +33,7 @@
"declaration-bundler-webpack-plugin": "^1.0.3",
"del": "^2.2.2",
"es6-shim": "^0.35.3",
- "eslint": "^3.15.0",
+ "eslint": "^4.1.1",
"eslint-config-angular": "^0.5.0",
"eslint-config-xo-space": "^0.15.0",
"eslint-loader": "^1.6.1",
@@ -81,7 +80,7 @@
"ts-loader": "^2.0.0",
"tslint": "^4.4.2",
"tslint-loader": "^3.4.2",
- "typescript": "^2.1.0",
+ "typescript": "^2.4.0",
"webpack": "^2.2.1",
"webpack-fail-plugin": "^1.0.5"
},
diff --git a/src/demo/authors/author.component.ts b/src/demo/authors/author.component.ts
index 8313204..50c3f0d 100644
--- a/src/demo/authors/author.component.ts
+++ b/src/demo/authors/author.component.ts
@@ -2,7 +2,7 @@ import * as angular from 'angular';
import 'angular-ui-router';
import * as Jsonapi from '../../library/index';
-class AuthorController {
+class AuthorController implements ng.IController {
public author: Jsonapi.IResource;
public relatedbooks: Jsonapi.IResource[];
@@ -31,9 +31,13 @@ class AuthorController {
);
}
- /**
+ public $onInit() {
+
+ }
+
+ /*
Add a new author
- **/
+ */
public new() {
let author = this.AuthorsService.new();
author.attributes.name = 'Pablo Reyes';
@@ -45,9 +49,9 @@ class AuthorController {
// author.save( /* { include: ['book'] } */ );
}
- /**
+ /*
Update name for actual author
- **/
+ */
public update() {
this.author.attributes.name += 'o';
this.author.save(
@@ -64,14 +68,7 @@ class AuthorController {
}
}
-export const Author = {
- templateUrl: 'demo/authors/author.html',
- controller: AuthorController
- // bindings: {
- // completedCount: '<',
- // activeCount: '<',
- // selectedFilter: '
-
import * as Jsonapi from '../../library/index';
export class AuthorsService extends Jsonapi.Service {
diff --git a/src/demo/books/book.component.ts b/src/demo/books/book.component.ts
index 9720375..fd98cef 100644
--- a/src/demo/books/book.component.ts
+++ b/src/demo/books/book.component.ts
@@ -1,6 +1,6 @@
import * as Jsonapi from '../../library/index';
-export class BookController {
+export class BookController implements ng.IController {
public book: any = null;
/** @ngInject */
@@ -22,9 +22,13 @@ export class BookController {
}
);
}
+
+ public $onInit() {
+
+ }
}
-export const Book = {
- templateUrl: 'demo/books/book.html',
- controller: BookController
+export class Book {
+ public templateUrl = 'demo/books/book.html';
+ public controller = BookController;
};
diff --git a/src/demo/books/books.component.ts b/src/demo/books/books.component.ts
index 0ca5e89..73a7d56 100644
--- a/src/demo/books/books.component.ts
+++ b/src/demo/books/books.component.ts
@@ -1,6 +1,6 @@
import * as Jsonapi from '../../library/index';
-class BooksController {
+class BooksController implements ng.IController {
public books: Jsonapi.ICollection;
/** @ngInject */
@@ -20,9 +20,9 @@ class BooksController {
this.books = BooksService.all(
{
localfilter: filter,
- remotefilter: {
+ remotefilter: {
date: {
- since:'1983-01-01',
+ since: '1983-01-01',
until: '2010-01-01'
}
},
@@ -63,12 +63,16 @@ class BooksController {
);
}
+ public $onInit() {
+
+ }
+
public delete(book: Jsonapi.IResource) {
this.BooksService.delete(book.id);
}
}
-export const Books = {
- templateUrl: 'demo/books/books.html',
- controller: BooksController
+export class Books {
+ public templateUrl = 'demo/books/books.html';
+ public controller = BooksController;
};
diff --git a/src/demo/books/books.service.ts b/src/demo/books/books.service.ts
index e106a4a..81af4fe 100644
--- a/src/demo/books/books.service.ts
+++ b/src/demo/books/books.service.ts
@@ -1,5 +1,3 @@
-///
-
import * as Jsonapi from '../../library/index';
export class BooksService extends Jsonapi.Service {
diff --git a/src/demo/containers/app.ts b/src/demo/containers/app.ts
index fe825ad..7b3f734 100644
--- a/src/demo/containers/app.ts
+++ b/src/demo/containers/app.ts
@@ -1,5 +1,4 @@
-export class AppController {
-
+class AppController implements ng.IController {
/** @ngInject */
constructor(
protected JsonapiCore,
@@ -31,10 +30,19 @@ export class AppController {
self.$scope.loading = 'No connection 2!!!';
};
}
+
+ public $onInit() {
+
+ }
}
-export const App = {
- templateUrl: 'demo/containers/app.html',
- controller: AppController,
- transclude: true
+export class App implements ng.IComponentOptions {
+ public templateUrl: string;
+ public controller: ng.Injectable = AppController;
+ public transclude: boolean;
+
+ constructor() {
+ this.templateUrl = 'demo/containers/app.html';
+ this.transclude = true;
+ }
};
diff --git a/src/demo/index.ts b/src/demo/index.ts
index 5e1cb93..efe1aef 100644
--- a/src/demo/index.ts
+++ b/src/demo/index.ts
@@ -33,11 +33,11 @@ angular
.service('AuthorsService', AuthorsService)
.service('BooksService', BooksService)
.service('PhotosService', PhotosService)
- .component('app', App)
- .component('author', Author)
- .component('authors', Authors)
- .component('book', Book)
- .component('books', Books)
- .component('photos', Photos)
- .component('noduplicatedcalltests', NoDuplicatedHttpCalls)
+ .component('app', new App())
+ .component('author', new Author())
+ .component('authors', new Authors())
+ .component('book', new Book())
+ .component('books', new Books())
+ .component('photos', new Photos())
+ .component('noduplicatedcalltests', new NoDuplicatedHttpCalls())
;
diff --git a/src/demo/photos/photos.component.ts b/src/demo/photos/photos.component.ts
index 41cf2cd..e813d08 100644
--- a/src/demo/photos/photos.component.ts
+++ b/src/demo/photos/photos.component.ts
@@ -1,6 +1,6 @@
import * as Jsonapi from '../../library/index';
-class PhotosController {
+class PhotosController implements ng.IController {
public photos: Jsonapi.ICollection;
/** @ngInject */
@@ -15,6 +15,10 @@ class PhotosController {
this.makeRequest(5);
}
+ public $onInit() {
+
+ }
+
public makeRequest(id) {
this.photos = this.PhotosService.all(
succes => {
@@ -24,7 +28,7 @@ class PhotosController {
}
}
-export const Photos = {
- templateUrl: 'demo/photos/photos.html',
- controller: PhotosController
+export class Photos {
+ public templateUrl = 'demo/photos/photos.html';
+ public controller = PhotosController;
};
diff --git a/src/demo/photos/photos.service.ts b/src/demo/photos/photos.service.ts
index ccf1339..61c9c1a 100644
--- a/src/demo/photos/photos.service.ts
+++ b/src/demo/photos/photos.service.ts
@@ -1,5 +1,3 @@
-///
-
import * as Jsonapi from '../../library/index';
export class PhotosService extends Jsonapi.Service {
diff --git a/src/demo/tests/noduplicatedhttpcalls.component.ts b/src/demo/tests/noduplicatedhttpcalls.component.ts
index acb5931..5c4ce71 100644
--- a/src/demo/tests/noduplicatedhttpcalls.component.ts
+++ b/src/demo/tests/noduplicatedhttpcalls.component.ts
@@ -1,6 +1,6 @@
import * as Jsonapi from '../../library/index';
-class NoDuplicatedHttpCallsComponent {
+class NoDuplicatedHttpCallsComponent implements ng.IController {
public authors: Array = [];
/** @ngInject */
@@ -19,9 +19,13 @@ class NoDuplicatedHttpCallsComponent {
);
}
}
+
+ public $onInit() {
+
+ }
}
-export const NoDuplicatedHttpCalls = {
- templateUrl: 'demo/tests/noduplicatedhttpcalls.html',
- controller: NoDuplicatedHttpCallsComponent
+export class NoDuplicatedHttpCalls {
+ public templateUrl = 'demo/tests/noduplicatedhttpcalls.html';
+ public controller = NoDuplicatedHttpCallsComponent;
};
diff --git a/src/library/core.ts b/src/library/core.ts
index 003a4c7..bf6d599 100644
--- a/src/library/core.ts
+++ b/src/library/core.ts
@@ -3,17 +3,21 @@ import './services/core-services.service';
import { ICore, IResource, ICollection, IService } from './interfaces';
export class Core implements ICore {
- private resourceServices: Object = {};
+ public static me: ICore;
+ public static injectedServices: {
+ $q: ng.IQService,
+ JsonapiStoreService: any,
+ JsonapiHttp: any,
+ rsJsonapiConfig: any
+ };
+ private resourceServices: Object = {};
public loadingsCounter: number = 0;
public loadingsStart = () => {};
public loadingsDone = () => {};
public loadingsError = () => {};
public loadingsOffline = () => {};
- public static me: ICore;
- public static injectedServices: any;
-
/** @ngInject */
public constructor(
protected rsJsonapiConfig,
diff --git a/src/library/interfaces/cache.d.ts b/src/library/interfaces/cache.d.ts
index 6b8ca6c..4919673 100644
--- a/src/library/interfaces/cache.d.ts
+++ b/src/library/interfaces/cache.d.ts
@@ -1,7 +1,6 @@
-import { ICollection, IResource } from '../interfaces';
+import { IResource } from '../interfaces';
export interface ICache {
- setCollection(url: string, collection: ICollection): void;
setResource(resource: IResource): void;
deprecateCollections(path_start_with: string): boolean;
}
diff --git a/src/library/interfaces/cachememory.d.ts b/src/library/interfaces/cachememory.d.ts
index 5229c3c..ce8e98c 100644
--- a/src/library/interfaces/cachememory.d.ts
+++ b/src/library/interfaces/cachememory.d.ts
@@ -10,6 +10,7 @@ export interface ICacheMemory extends ICache {
isResourceLive(id: string, ttl: number): boolean;
getOrCreateResource(type: string, id: string): IResource;
+ setCollection(url: string, collection: ICollection): void;
removeResource(id: string): void;
}
diff --git a/src/library/interfaces/cachestore.d.ts b/src/library/interfaces/cachestore.d.ts
index edc0815..7cbf720 100644
--- a/src/library/interfaces/cachestore.d.ts
+++ b/src/library/interfaces/cachestore.d.ts
@@ -3,5 +3,6 @@ import { ICache } from '../interfaces/cache.d';
export interface ICacheStore extends ICache {
getResource(resource: IResource): ng.IPromise