Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"ignorePatterns": [
"projects/**/*",
"e2e/**/*",
"dist/**/*",
"setup-jest.ts"
],
"overrides": [
Expand All @@ -19,11 +20,11 @@
"createDefaultProgram": true
},
"extends": [
"plugin:@angular-eslint/ng-cli-compat",
"plugin:@angular-eslint/ng-cli-compat--formatting-add-on",
"plugin:@angular-eslint/template/process-inline-templates"
],
"plugins": [
"@angular-eslint",
"@typescript-eslint",
"eslint-plugin-no-null",
"eslint-plugin-unicorn",
"eslint-plugin-rxjs"
Expand Down Expand Up @@ -149,13 +150,6 @@
"error",
"multi-line"
],
"indent": [
"error",
4,
{
"SwitchCase": 1
}
],
"default-case": "off",
"eol-last": "off",
"guard-for-in": "off",
Expand Down
82 changes: 82 additions & 0 deletions .github/workflows/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: version 3
on: [push]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout código
uses: actions/checkout@v4

- name: Instalar Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'

- name: Restaurar caché de Yarn
uses: actions/cache@v4
with:
path: |
~/.cache/yarn
node_modules
key: yarn-cache-${{ hashFiles('yarn.lock') }}

- name: Instalar dependencias
run: yarn install

- name: Prettier TS
run: yarn prettier-ts:show --list-different

- name: Prettier MD
run: yarn prettier-md:show --list-different

- name: Prettier SCSS
run: yarn prettier-scss:show --list-different

- name: Lint
run: yarn lint

test:
runs-on: ubuntu-latest
steps:
- name: Checkout código
uses: actions/checkout@v4

- name: Instalar Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'

- name: Restaurar caché de Yarn
uses: actions/cache@v4
with:
path: |
~/.cache/yarn
node_modules
key: yarn-cache-${{ hashFiles('yarn.lock') }}

- name: Instalar dependencias
run: yarn install --frozen-lockfile

- name: Ejecutar CI
run: yarn run ci

# - name: Subir reporte de cobertura a Coveralls
# run: |
# if [ ! -z "$COVERALLS_REPO_TOKEN" ]; then
# npx @cedx/coveralls build/logs/clover.xml
# else
# echo 'Skipped'
# fi

- name: Demo build
run: yarn run demo:build

# - name: Demo test nowatch
# run: yarn run demo:test:nowatch

# - name: Build (ya lo ejecuta demo:build)
# run: yarn run build

# - name: Test (ya lo ejecuta yarn run ci)
# run: yarn run test
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"tabWidth": 4,
"useTabs": false
}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

## [2.4.0-dev-test] - 2025-07-15

- Migrate to angular 17

## [2.3.0-dev-test] - 2023-08-11

- Migrate to angular 16
Expand Down
36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ import { NgxJsonapiModule } from 'ngx-jsonapi';
@NgModule({
imports: [
NgxJsonapiModule.forRoot({
url: '//jsonapiplayground.reyesoft.com/v2/'
})
]
url: '//jsonapiplayground.reyesoft.com/v2/',
}),
],
})
export class AppModule {}
```
Expand All @@ -82,19 +82,19 @@ import { JsonRipper } from 'ngx-jsonapi/services/json-ripper';
@NgModule({
imports: [
NgxJsonapiModule.forRoot({
url: '//jsonapiplayground.reyesoft.com/v2/'
})
url: '//jsonapiplayground.reyesoft.com/v2/',
}),
],
providers: [
{
provide: JSONAPI_RIPPER_SERVICE,
useClass: JsonRipperFake
useClass: JsonRipperFake,
},
{
provide: JSONAPI_STORE_SERVICE,
useClass: StoreFakeService
}
]
useClass: StoreFakeService,
},
],
})
export class AppModule {}
```
Expand All @@ -116,12 +116,12 @@ import { Photo } from '../photos/photos.service';
export class Author extends Resource {
public attributes = {
name: 'default name',
date_of_birth: ''
date_of_birth: '',
};

public relationships = {
books: new DocumentCollection<Book>(),
photo: new DocumentResource<Photo>()
photo: new DocumentResource<Photo>(),
};
}

Expand All @@ -144,7 +144,7 @@ import { AuthorsService, Author } from './../authors.service';

@Component({
selector: 'demo-authors',
templateUrl: './authors.component.html'
templateUrl: './authors.component.html',
})
export class AuthorsComponent {
public authors: DocumentCollection<Author>;
Expand All @@ -154,7 +154,7 @@ export class AuthorsComponent {
.all({
// include: ['books', 'photos'],
})
.subscribe(authors => (this.authors = authors));
.subscribe((authors) => (this.authors = authors));
}
}
```
Expand All @@ -175,7 +175,7 @@ Example: `name` is a authors attribute, and makes a query like `/authors?sort=na

```typescript
let authors = authorsService.all({
sort: ['name', 'job_title']
sort: ['name', 'job_title'],
});
```

Expand All @@ -185,7 +185,7 @@ Filter resources with `attribute: value` values. Filters are used as 'exact matc

```typescript
authorsService.all({
remotefilter: { country: 'Argentina' }
remotefilter: { country: 'Argentina' },
});
```

Expand Down Expand Up @@ -241,16 +241,16 @@ let relatedbooks = booksService.all({ beforepath: 'authors/1' });
// you need get a cached object? you can force ttl on get
let author$ = authorsService.get(
'some_author_id',
{ ttl: 60 } // ttl on seconds (default: 0)
{ ttl: 60 }, // ttl on seconds (default: 0)
);
```

### Update a resource

```typescript
authorsService.get('some_author_id').suscribe(author => {
authorsService.get('some_author_id').suscribe((author) => {
this.author.attributes.name += 'New Name';
this.author.save(success => {
this.author.save((success) => {
console.log('author saved!');
});
});
Expand Down
3 changes: 3 additions & 0 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,8 @@
"@schematics/angular:directive": {
"prefix": "bc"
}
},
"cli": {
"analytics": false
}
}
4 changes: 1 addition & 3 deletions demo/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import { JsonapiCore } from 'ngx-jsonapi';
export class AppComponent /* implements OnInit */ {
public loading: string = '';

public constructor(
private jsonapiCore: JsonapiCore
) {
public constructor(private jsonapiCore: JsonapiCore) {
jsonapiCore.loadingsStart = (): void => {
this.loading = 'LOADING...';
};
Expand Down
6 changes: 2 additions & 4 deletions demo/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ import { AuthorsService } from './authors/authors.service';
import { BooksService } from './books/books.service';
import { PhotosService } from './photos/photos.service';
import { SharedModule } from './shared/shared.module';

import { StoreService } from 'ngx-jsonapi/sources/store.service';
import { JsonRipper } from 'ngx-jsonapi/services/json-ripper';
import { JsonRipper, StoreService } from '../../projects/ngx-jsonapi-lib/src/lib/store';

const appRoutes: Routes = [
{
Expand Down Expand Up @@ -54,7 +52,7 @@ const appRoutes: Routes = [
SharedModule,
RouterModule.forRoot(appRoutes, { useHash: true }),
NgxJsonapiModule.forRoot({
url: environment.api_saldo,
url: environment.api_saldo
})
],
declarations: [AppComponent],
Expand Down
4 changes: 2 additions & 2 deletions demo/app/authors/authors-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const routes: Routes = [
];

@NgModule({
imports: [ RouterModule.forChild(routes) ],
exports: [ RouterModule ]
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class AuthorsRoutingModule {}
2 changes: 1 addition & 1 deletion demo/app/authors/authors.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class Author extends Resource {

public relationships: {
books: DocumentCollection<Book>;
photos: DocumentCollection<Photo>
photos: DocumentCollection<Photo>;
} = {
books: new DocumentCollection<Book>(),
photos: new DocumentCollection<Photo>()
Expand Down
8 changes: 4 additions & 4 deletions demo/app/authors/components/author.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ export class AuthorComponent {
) {
route.params.subscribe(({ id }) => {
authorsService.get(id, { include: ['books', 'photos'], ttl: 100 }).subscribe(
author => {
(author) => {
this.author = author;
},
error => console.error('Could not load author.', error)
(error) => console.error('Could not load author.', error)
);
});
}
Expand All @@ -44,7 +44,7 @@ export class AuthorComponent {
.save
/* { include: ['book'] } */
()
.subscribe(success => {
.subscribe((success) => {
console.log('author saved', author.toObject());
});
}
Expand All @@ -56,7 +56,7 @@ export class AuthorComponent {
this.author.attributes.name = prompt('Author name:', this.author.attributes.name);
console.log('author data for save with book include', this.author.toObject({ include: ['books'] }));
console.log('author data for save without any include', this.author.toObject());
this.author.save(/* { include: ['book'] } */).subscribe(success => {
this.author.save(/* { include: ['book'] } */).subscribe((success) => {
console.log('author saved', this.author.toObject());
});
}
Expand Down
11 changes: 7 additions & 4 deletions demo/app/authors/components/authors.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Photo } from './../../../../src/tests/factories/photos.service';
import { BooksService } from './../../books/books.service';
import { Component } from '@angular/core';
import { DocumentCollection } from 'ngx-jsonapi';
Expand All @@ -12,7 +11,11 @@ import { ActivatedRoute } from '@angular/router';
export class AuthorsComponent {
public authors: DocumentCollection<Author>;

public constructor(private route: ActivatedRoute, private authorsService: AuthorsService, booksService: BooksService) {
public constructor(
private route: ActivatedRoute,
private authorsService: AuthorsService,
booksService: BooksService
) {
route.queryParams.subscribe(({ page }) => {
authorsService
.all({
Expand All @@ -23,10 +26,10 @@ export class AuthorsComponent {
ttl: 3600
})
.subscribe(
authors => {
(authors) => {
this.authors = authors;
},
error => console.error('Could not load authors :(', error)
(error) => console.error('Could not load authors :(', error)
);
});
}
Expand Down
4 changes: 2 additions & 2 deletions demo/app/books/books-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const routes: Routes = [
];

@NgModule({
imports: [ RouterModule.forChild(routes) ],
exports: [ RouterModule ]
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class BooksRoutingModule {}
2 changes: 1 addition & 1 deletion demo/app/books/books.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class Book extends Resource {
};

public relationships: {
author: DocumentResource<Author>
author: DocumentResource<Author>;
photos: DocumentCollection<Photo>;
} = {
author: new DocumentResource<Author>(),
Expand Down
4 changes: 2 additions & 2 deletions demo/app/books/components/book.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ export class BookComponent {
) {
route.params.subscribe(({ id }) => {
booksService.get(id, { include: ['author', 'photos'] }).subscribe(
book => {
(book) => {
this.book = book;
console.log('success book', this.book);
},
error => console.log('error books controll', error)
(error) => console.log('error books controll', error)
);
});
}
Expand Down
Loading
Loading