Skip to content
This repository was archived by the owner on Aug 18, 2018. It is now read-only.

Commit c68d711

Browse files
committed
relationships has a types now
1 parent 20dc56f commit c68d711

14 files changed

Lines changed: 96 additions & 43 deletions

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,12 @@ let authors = AuthorsService.all(
212212
);
213213
```
214214

215+
#### Collection page
216+
217+
- number: number of the current page
218+
- limit: limit of resources per page ([it's sended to server by url](http://jsonapi.org/format/#fetching-pagination))
219+
- information returned from server (check if is avaible) **total_resources: total of avaible resources on server** resources_per_page: total of resources returned per page requested
220+
215221
### Include anothers resources (is comming)
216222

217223
## Demo local

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ts-angular-jsonapi",
3-
"version": "0.4.2",
3+
"version": "0.4.14",
44
"description": "JSONAPI library developed for AngularJS in Typescript",
55
"repository": {
66
"type": "git",
@@ -74,7 +74,7 @@
7474
"ts-loader": "^0.7.2",
7575
"tslint": "^3.2.1",
7676
"tslint-loader": "^2.1.0",
77-
"typescript": "^1.7.5",
77+
"typescript": "^2.2.0",
7878
"typings": "^1.0.4",
7979
"webpack": "2.1.0-beta.8",
8080
"webpack-split-by-path": "^0.0.10"

src/library/index.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
/// <reference path="./interfaces/errors.d.ts"/>
1111
/// <reference path="./interfaces/links.d.ts"/>
1212

13+
/// <reference path="./interfaces/relationship.d.ts"/>
14+
/// <reference path="./interfaces/relationships.d.ts"/>
15+
1316
// Parameters for TS-Jsonapi Classes
1417
/// <reference path="./interfaces/schema.d.ts"/>
1518

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export interface IAttributes {
2+
[value: string]: boolean | string | number;
3+
}

src/library/interfaces/index.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
export * from './attributes.d'
12
export * from './core.d'
23
export * from './collection.d'
34
export * from './schema.d'
45
export * from './service.d'
56
export * from './resource.d'
7+
export * from './relationship.d'
8+
export * from './relationships.d'
69
export * from './cache.d'
710
export * from './params-collection.d'
811
export * from './params-resource.d'

src/library/interfaces/params-collection.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { IPage } from './page.d';
44
interface IParamsCollection extends IParams {
55
localfilter?: any;
66
remotefilter?: any;
7+
smartfilter?: any;
78
page?: IPage;
89
storage_ttl?: number;
910
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { ICollection, IResource } from '../interfaces';
2+
3+
interface IRelationship {
4+
// IDataResource added for this reason:
5+
// redefined from IDataResource (return errors /home/rsk/desarrollo/ts-angular-jsonapi/src/library/services/resource-functions.ts)
6+
data: ICollection | IResource | IDataResource | {};
7+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { IRelationship } from '../interfaces/relationship.d';
2+
3+
interface IRelationships {
4+
[value: string]: IRelationship;
5+
}

src/library/interfaces/resource.d.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ICollection, ICache, IParamsResource } from './index';
1+
import { IRelationships, ICollection, ICache, IParamsResource } from './index';
22

33
export interface IResource extends IDataResource {
44
is_new: boolean;
@@ -8,6 +8,10 @@ export interface IResource extends IDataResource {
88

99
memorycache: ICache;
1010

11+
type: string; // dont work extend?
12+
13+
relationships: IRelationships; // redefined from IDataResource
14+
1115
reset? (): void;
1216
addRelationship? (resource: IResource, type_alias?: string): void;
1317
addRelationships? (resources: ICollection, type_alias: string): void;

src/library/interfaces/service.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { ISchema, IResource, ICollection, IParamsCollection, IParamsResource } from './index';
22

33
export interface IService {
4+
smartfilter?: string;
45
schema?: ISchema;
56
new? (): IResource;
67
register? (): boolean;
7-
get (id: String, params?: Object | Function, success?: Function, error?: Function): IResource;
8+
get<T extends IResource>(id: string | number, params?: IParamsResource | Function, fc_success?: Function, fc_error?: Function): T;
89
all(params?: IParamsCollection | Function, success?: Function, error?: Function): ICollection;
910
delete (id: String, params?: IParamsResource | Function, success?: Function, error?: Function): void;
1011
getService? (): any; // any, becouse depends of extended class

0 commit comments

Comments
 (0)