Skip to content

Commit 2326af4

Browse files
authored
Update to 18 (#10)
* update to angular 18 * update eslint and package deps
1 parent 68c140b commit 2326af4

File tree

9 files changed

+4821
-3679
lines changed

9 files changed

+4821
-3679
lines changed

package-lock.json

Lines changed: 4772 additions & 3621 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,23 @@
1212
"test": "ng test"
1313
},
1414
"devDependencies": {
15-
"@angular-devkit/build-angular": "^17.3.10",
16-
"@angular-eslint/builder": "17.5.3",
17-
"@angular-eslint/eslint-plugin": "17.5.3",
18-
"@angular-eslint/eslint-plugin-template": "17.5.3",
19-
"@angular-eslint/schematics": "17.5.3",
20-
"@angular-eslint/template-parser": "17.5.3",
21-
"@angular/animations": "^17.3.12",
22-
"@angular/cli": "^17.3.10",
23-
"@angular/common": "^17.3.12",
24-
"@angular/compiler": "^17.3.12",
25-
"@angular/compiler-cli": "^17.3.12",
26-
"@angular/core": "^17.3.12",
27-
"@angular/forms": "^17.3.12",
28-
"@angular/language-service": "^17.3.12",
29-
"@angular/platform-browser": "^17.3.12",
30-
"@angular/platform-browser-dynamic": "^17.3.12",
31-
"@angular/router": "^17.3.12",
15+
"@angular-devkit/build-angular": "^18.2.9",
16+
"@angular-eslint/builder": "18.3.1",
17+
"@angular-eslint/eslint-plugin": "18.3.1",
18+
"@angular-eslint/eslint-plugin-template": "18.3.1",
19+
"@angular-eslint/schematics": "18.3.1",
20+
"@angular-eslint/template-parser": "18.3.1",
21+
"@angular/animations": "^18.2.8",
22+
"@angular/cli": "^18.2.9",
23+
"@angular/common": "^18.2.8",
24+
"@angular/compiler": "^18.2.8",
25+
"@angular/compiler-cli": "^18.2.8",
26+
"@angular/core": "^18.2.8",
27+
"@angular/forms": "^18.2.8",
28+
"@angular/language-service": "^18.2.8",
29+
"@angular/platform-browser": "^18.2.8",
30+
"@angular/platform-browser-dynamic": "^18.2.8",
31+
"@angular/router": "^18.2.8",
3232
"@types/jasmine": "^5.1.1",
3333
"@types/node": "^20.8.10",
3434
"@typescript-eslint/eslint-plugin": "^7.2.0",
@@ -44,7 +44,7 @@
4444
"karma-jasmine": "^5.1.0",
4545
"karma-jasmine-html-reporter": "^2.1.0",
4646
"lodash-es": "^4.17.21",
47-
"ng-packagr": "^17.3.0",
47+
"ng-packagr": "^18.2.1",
4848
"reflect-metadata": "^0.2.2",
4949
"rxjs": "~7.8.0",
5050
"ts-node": "^10.9.2",

projects/angular2-jsonapi/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@michalkotas/angular2-jsonapi",
3-
"version": "17.0.0",
3+
"version": "18.0.0",
44
"description": "A lightweight Angular 2 adapter for JSON API",
55
"repository": {
66
"type": "git",
@@ -27,8 +27,8 @@
2727
"tslib": "^2.8.0"
2828
},
2929
"peerDependencies": {
30-
"@angular/common": "^17.3.12",
31-
"@angular/core": "^17.3.12",
30+
"@angular/common": "^18.2.8",
31+
"@angular/core": "^18.2.8",
3232
"reflect-metadata": "^0.2.2",
3333
"rxjs": "*"
3434
}

projects/angular2-jsonapi/src/models/json-api.model.spec.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,24 @@ import { parseISO } from 'date-fns/parseISO';
33
import { Author } from '../../test/models/author.model';
44
import { AUTHOR_ID, BOOK_PUBLISHED, BOOK_TITLE, CHAPTER_TITLE, getAuthorData, getIncludedBooks } from '../../test/fixtures/author.fixture';
55
import { Book } from '../../test/models/book.model';
6-
import { HttpClientTestingModule } from '@angular/common/http/testing';
6+
import { provideHttpClientTesting } from '@angular/common/http/testing';
77
import { Datastore } from '../../test/datastore.service';
88
import { Chapter } from '../../test/models/chapter.model';
9+
import { provideHttpClient } from '@angular/common/http';
910

1011
describe('JsonApiModel', () => {
1112
let datastore: Datastore;
1213

1314
beforeEach(() => {
1415

1516
TestBed.configureTestingModule({
16-
imports: [
17-
HttpClientTestingModule,
18-
],
19-
providers: [
20-
Datastore
21-
]
22-
});
17+
imports: [],
18+
providers: [
19+
Datastore,
20+
provideHttpClient(),
21+
provideHttpClientTesting()
22+
]
23+
});
2324

2425
datastore = TestBed.inject(Datastore);
2526
});

projects/angular2-jsonapi/src/module.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

projects/angular2-jsonapi/src/public-api.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,4 @@ export * from './interfaces/model-config.interface';
2121
export * from './interfaces/attribute-decorator-options.interface';
2222
export * from './interfaces/property-converter.interface';
2323

24-
export * from './providers';
25-
26-
export * from './module';
24+
export * from './services/json-api-datastore.service'

projects/angular2-jsonapi/src/services/json-api-datastore.service.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import { Author } from '../../test/models/author.model';
44
import { Chapter } from '../../test/models/chapter.model';
55
import { AUTHOR_API_VERSION, AUTHOR_MODEL_ENDPOINT_URL, CustomAuthor } from '../../test/models/custom-author.model';
66
import { AUTHOR_BIRTH, AUTHOR_ID, AUTHOR_NAME, BOOK_TITLE, getAuthorData } from '../../test/fixtures/author.fixture';
7-
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
7+
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
88
import { API_VERSION, BASE_URL, Datastore } from '../../test/datastore.service';
99
import { ErrorResponse } from '../models/error-response.model';
1010
import { getSampleBook } from '../../test/fixtures/book.fixture';
1111
import { Book } from '../../test/models/book.model';
1212
import { CrimeBook } from '../../test/models/crime-book.model';
1313
import { API_VERSION_FROM_CONFIG, BASE_URL_FROM_CONFIG, DatastoreWithConfig } from '../../test/datastore-with-config.service';
14-
import { HttpHeaders } from '@angular/common/http';
14+
import { HttpHeaders, provideHttpClient } from '@angular/common/http';
1515
import { Thing } from '../../test/models/thing';
1616
import { getSampleThing } from '../../test/fixtures/thing.fixture';
1717
import { ModelConfig } from '../interfaces/model-config.interface';
@@ -32,14 +32,14 @@ describe('JsonApiDatastore', () => {
3232

3333
beforeEach(() => {
3434
TestBed.configureTestingModule({
35-
imports: [
36-
HttpClientTestingModule,
37-
],
38-
providers: [
35+
imports: [],
36+
providers: [
3937
Datastore,
4038
DatastoreWithConfig,
41-
]
42-
});
39+
provideHttpClient(),
40+
provideHttpClientTesting(),
41+
]
42+
});
4343
datastore = TestBed.inject(Datastore);
4444
datastoreWithConfig = TestBed.inject(DatastoreWithConfig);
4545
httpMock = TestBed.inject(HttpTestingController);

projects/angular2-jsonapi/src/services/json-api-datastore.service.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,16 @@ export type ModelType<T extends JsonApiModel> = new(datastore: JsonApiDatastore,
2323
*/
2424
const AttributeMetadataIndex: string = AttributeMetadata as any;
2525

26-
@Injectable()
26+
@Injectable({
27+
providedIn: 'root'
28+
})
2729
export class JsonApiDatastore {
2830

2931
protected config: DatastoreConfig;
3032
private globalHeaders: HttpHeaders;
3133
private globalRequestOptions: object = {};
3234
private internalStore: { [type: string]: { [id: string]: JsonApiModel } } = {};
33-
private toQueryString: (params: any) => string = this.datastoreConfig.overrides
35+
private toQueryString: (params: Record<string, unknown>) => string = this.datastoreConfig.overrides
3436
&& this.datastoreConfig.overrides.toQueryString ?
3537
this.datastoreConfig.overrides.toQueryString : this._toQueryString;
3638

@@ -79,7 +81,7 @@ export class JsonApiDatastore {
7981
*/
8082
query<T extends JsonApiModel>(
8183
modelType: ModelType<T>,
82-
params?: any,
84+
params?: Record<string, unknown>,
8385
headers?: HttpHeaders,
8486
customUrl?: string
8587
): Observable<T[]> {
@@ -94,7 +96,7 @@ export class JsonApiDatastore {
9496

9597
public findAll<T extends JsonApiModel>(
9698
modelType: ModelType<T>,
97-
params?: any,
99+
params?: Record<string, unknown>,
98100
headers?: HttpHeaders,
99101
customUrl?: string
100102
): Observable<JsonApiQueryData<T>> {
@@ -111,7 +113,7 @@ export class JsonApiDatastore {
111113
public findRecord<T extends JsonApiModel>(
112114
modelType: ModelType<T>,
113115
id: string,
114-
params?: any,
116+
params?: Record<string, unknown>,
115117
headers?: HttpHeaders,
116118
customUrl?: string
117119
): Observable<T> {
@@ -132,7 +134,7 @@ export class JsonApiDatastore {
132134
public saveRecord<T extends JsonApiModel>(
133135
attributesMetadata: any,
134136
model: T,
135-
params?: any,
137+
params?: Record<string, unknown>,
136138
headers?: HttpHeaders,
137139
customUrl?: string
138140
): Observable<T> {
@@ -233,7 +235,7 @@ export class JsonApiDatastore {
233235

234236
protected buildUrl<T extends JsonApiModel>(
235237
modelType: ModelType<T>,
236-
params?: any,
238+
params?: Record<string, unknown>,
237239
id?: string,
238240
customUrl?: string
239241
): string {

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"outDir": "./dist/out-tsc",
66
"sourceMap": true,
77
"declaration": false,
8-
"downlevelIteration": true,
8+
"esModuleInterop": true,
99
"emitDecoratorMetadata": true,
1010
"experimentalDecorators": true,
1111
"module": "es2020",

0 commit comments

Comments
 (0)