@von-development-studio/angular-rest-service 19.2.0 → 20.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -1,5 +1,149 @@
1
+ import { HttpHeaders, HttpParams, HttpInterceptor, HttpRequest, HttpHandler, HttpEvent, HttpErrorResponse, HttpClient } from '@angular/common/http';
2
+ import { Router } from '@angular/router';
3
+ import { Observable } from 'rxjs';
4
+ import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
5
+
6
+ interface VonErrorRestInterceptorModel {
7
+ status: number;
8
+ message: string;
9
+ body?: any;
10
+ }
11
+
12
+ type HeaderParams = {
13
+ contentType?: string;
14
+ accept?: string;
15
+ responseType?: 'json';
16
+ };
17
+
18
+ interface VonHttpOptionsModel {
19
+ headers?: HttpHeaders | {
20
+ [header: string]: string | string[];
21
+ };
22
+ observe?: 'body';
23
+ params?: HttpParams | {
24
+ [param: string]: string | string[];
25
+ };
26
+ reportProgress?: boolean;
27
+ responseType?: 'json';
28
+ withCredentials?: boolean;
29
+ }
30
+
1
31
  /**
2
- * Generated bundle index. Do not edit.
32
+ * @deprecated Define this model in the solution
3
33
  */
4
- /// <amd-module name="@von-development-studio/angular-rest-service" />
5
- export * from './public-api';
34
+ interface VonPageResponseModel<T> {
35
+ content: T[];
36
+ last: boolean;
37
+ totalPages: number;
38
+ totalElements: number;
39
+ size: number;
40
+ numberOfElements: number;
41
+ number: number;
42
+ }
43
+
44
+ interface GenericParams {
45
+ [key: string]: any;
46
+ }
47
+ interface BaseParams {
48
+ url: string;
49
+ urlParams?: GenericParams;
50
+ queryParams?: GenericParams;
51
+ headerParams?: HeaderParams;
52
+ /**
53
+ * @deprecated Use headerParams instead
54
+ */
55
+ header?: HeaderParams;
56
+ /**
57
+ * @deprecated Use queryParams instead
58
+ */
59
+ params?: GenericParams;
60
+ }
61
+ type BodyParams<B = GenericParams | FormData> = BaseParams & {
62
+ body?: B;
63
+ };
64
+
65
+ declare abstract class VonRestInterceptorService implements HttpInterceptor {
66
+ protected router: Router;
67
+ protected consoleDebug: boolean;
68
+ protected errorResponseUnknown: string;
69
+ protected errorResponseForbidden: string;
70
+ constructor(router: Router);
71
+ intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>;
72
+ protected mapEvent: (event: HttpEvent<any>) => HttpEvent<any>;
73
+ protected catchError: (errorResponse: HttpErrorResponse) => Observable<never>;
74
+ /**
75
+ * Execute custom implementation before any other pipe from the subscription.
76
+ */
77
+ protected executeBeforePipesOnSuccess: () => void;
78
+ /**
79
+ * Execute custom implementation before any other pipe from the subscription.
80
+ */
81
+ protected executeBeforePipesOnError: () => void;
82
+ /**
83
+ * Execute custom implementation to redirect to 403 page based on a specific condition.
84
+ */
85
+ protected execute403Redirect: () => void;
86
+ /**
87
+ * @deprecated Use the new custom method execute403Redirect() to trigger redirect to 403. This property is marked to be removed.
88
+ * TODO: Remove this property
89
+ */
90
+ protected urlWhoAmI: string;
91
+ /**
92
+ * @deprecated Use the new custom method execute403Redirect() to trigger redirect to 403. This property is marked to be removed.
93
+ * TODO: Remove this property
94
+ */
95
+ protected redirectOn403: boolean;
96
+ /**
97
+ * @deprecated Use the new custom method execute403Redirect() to trigger redirect to 403. This property is marked to be removed.
98
+ * TODO: Remove this property
99
+ */
100
+ protected redirect403Url: string[];
101
+ /**
102
+ * @deprecated Use either executeBeforePipesOnSuccess() or executeBeforePipesOnError() base on your case. This method is marked to be removed.
103
+ */
104
+ protected postHttpRequest: () => void;
105
+ }
106
+
107
+ /**
108
+ * Rest service wrapper for API calls. This class needs to be extended in a `@Injectable({ providedIn: 'root' })` service.
109
+ * Parameters needed:
110
+ * @HttpClient
111
+ * @DomSanitizer
112
+ */
113
+ declare abstract class VonRestService {
114
+ protected http: HttpClient;
115
+ protected sanitizer: DomSanitizer;
116
+ constructor(http: HttpClient, sanitizer: DomSanitizer);
117
+ /**
118
+ * Allows to set the default headers
119
+ * @param headerParams Check HeaderParams interface to verify allowed overrides
120
+ * @returns
121
+ * ```json
122
+ * {
123
+ * "Content-Type": "application/json",
124
+ * "Accept": "application/json",
125
+ * "Access-Control-Allow-Origin": "*"
126
+ * }
127
+ * ```
128
+ */
129
+ protected setHeaders: (headerParams?: HeaderParams) => HttpHeaders;
130
+ protected setOptions: ({ headerParams, queryParams: params, }?: {
131
+ headerParams?: HeaderParams;
132
+ queryParams?: GenericParams;
133
+ }) => VonHttpOptionsModel;
134
+ protected setOptionsForFile: ({ headerParams, queryParams, }?: {
135
+ headerParams?: HeaderParams;
136
+ queryParams?: GenericParams;
137
+ }) => VonHttpOptionsModel;
138
+ protected setUrlParams: (url: string, params?: GenericParams) => string;
139
+ protected authenticate: (url: string, username: string, password: string) => Observable<any>;
140
+ protected get: <R = any>({ url, urlParams, queryParams: params, headerParams, header: oldHeaderParams, params: oldParams, }: BaseParams) => Observable<R>;
141
+ protected delete: <R = any>({ url, urlParams, queryParams: params, headerParams, header: oldHeaderParams, params: oldParams, }: BaseParams) => Observable<R>;
142
+ protected post: <R = any, B = GenericParams | FormData>({ url, body, urlParams, queryParams: params, headerParams, header: oldHeaderParams, params: oldParams, }: BodyParams<B>) => Observable<R>;
143
+ protected put: <R = any, B = GenericParams | FormData>({ url, body, urlParams, queryParams: params, headerParams, header: oldHeaderParams, params: oldParams, }: BodyParams<B>) => Observable<R>;
144
+ protected patch: <R = any, B = GenericParams | FormData>({ url, body, urlParams, queryParams: params, headerParams, header: oldHeaderParams, params: oldParams, }: BodyParams<B>) => Observable<R>;
145
+ protected file: ({ url, urlParams, queryParams: params, headerParams, header: oldHeaderParams, params: oldParams, }: BaseParams) => Observable<SafeResourceUrl>;
146
+ }
147
+
148
+ export { VonRestInterceptorService, VonRestService };
149
+ export type { BaseParams, BodyParams, GenericParams, HeaderParams, VonErrorRestInterceptorModel, VonHttpOptionsModel, VonPageResponseModel };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@von-development-studio/angular-rest-service",
3
- "version": "19.2.0",
3
+ "version": "20.3.0",
4
4
  "description": "Angular Rest Service wrapper.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -8,14 +8,14 @@
8
8
  },
9
9
  "keywords": [
10
10
  "angular",
11
- "angular 19",
11
+ "angular 20",
12
12
  "rest client"
13
13
  ],
14
14
  "author": "Luis García Castro",
15
15
  "license": "MIT",
16
16
  "peerDependencies": {
17
- "@angular/common": "^19.2.0",
18
- "@angular/core": "^19.2.0"
17
+ "@angular/common": "^20.3.0",
18
+ "@angular/core": "^20.3.0"
19
19
  },
20
20
  "dependencies": {
21
21
  "tslib": "^2.4.0"
@@ -1,5 +0,0 @@
1
- export interface VonErrorRestInterceptorModel {
2
- status: number;
3
- message: string;
4
- body?: any;
5
- }
@@ -1,5 +0,0 @@
1
- export type HeaderParams = {
2
- contentType?: string;
3
- accept?: string;
4
- responseType?: 'json';
5
- };
@@ -1,13 +0,0 @@
1
- import { HttpHeaders, HttpParams } from '@angular/common/http';
2
- export interface VonHttpOptionsModel {
3
- headers?: HttpHeaders | {
4
- [header: string]: string | string[];
5
- };
6
- observe?: 'body';
7
- params?: HttpParams | {
8
- [param: string]: string | string[];
9
- };
10
- reportProgress?: boolean;
11
- responseType?: 'json';
12
- withCredentials?: boolean;
13
- }
@@ -1,12 +0,0 @@
1
- /**
2
- * @deprecated Define this model in the solution
3
- */
4
- export interface VonPageResponseModel<T> {
5
- content: T[];
6
- last: boolean;
7
- totalPages: number;
8
- totalElements: number;
9
- size: number;
10
- numberOfElements: number;
11
- number: number;
12
- }
@@ -1,21 +0,0 @@
1
- import { HeaderParams } from './von-header-params.model';
2
- export interface GenericParams {
3
- [key: string]: any;
4
- }
5
- export interface BaseParams {
6
- url: string;
7
- urlParams?: GenericParams;
8
- queryParams?: GenericParams;
9
- headerParams?: HeaderParams;
10
- /**
11
- * @deprecated Use headerParams instead
12
- */
13
- header?: HeaderParams;
14
- /**
15
- * @deprecated Use queryParams instead
16
- */
17
- params?: GenericParams;
18
- }
19
- export type BodyParams<B = GenericParams | FormData> = BaseParams & {
20
- body?: B;
21
- };
@@ -1,44 +0,0 @@
1
- import { HttpErrorResponse, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
2
- import { Router } from '@angular/router';
3
- import { Observable } from 'rxjs';
4
- export declare abstract class VonRestInterceptorService implements HttpInterceptor {
5
- protected router: Router;
6
- protected consoleDebug: boolean;
7
- protected errorResponseUnknown: string;
8
- protected errorResponseForbidden: string;
9
- constructor(router: Router);
10
- intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>;
11
- protected mapEvent: (event: HttpEvent<any>) => HttpEvent<any>;
12
- protected catchError: (errorResponse: HttpErrorResponse) => Observable<never>;
13
- /**
14
- * Execute custom implementation before any other pipe from the subscription.
15
- */
16
- protected executeBeforePipesOnSuccess: () => void;
17
- /**
18
- * Execute custom implementation before any other pipe from the subscription.
19
- */
20
- protected executeBeforePipesOnError: () => void;
21
- /**
22
- * Execute custom implementation to redirect to 403 page based on a specific condition.
23
- */
24
- protected execute403Redirect: () => void;
25
- /**
26
- * @deprecated Use the new custom method execute403Redirect() to trigger redirect to 403. This property is marked to be removed.
27
- * TODO: Remove this property
28
- */
29
- protected urlWhoAmI: string;
30
- /**
31
- * @deprecated Use the new custom method execute403Redirect() to trigger redirect to 403. This property is marked to be removed.
32
- * TODO: Remove this property
33
- */
34
- protected redirectOn403: boolean;
35
- /**
36
- * @deprecated Use the new custom method execute403Redirect() to trigger redirect to 403. This property is marked to be removed.
37
- * TODO: Remove this property
38
- */
39
- protected redirect403Url: string[];
40
- /**
41
- * @deprecated Use either executeBeforePipesOnSuccess() or executeBeforePipesOnError() base on your case. This method is marked to be removed.
42
- */
43
- protected postHttpRequest: () => void;
44
- }
@@ -1,46 +0,0 @@
1
- import { HttpClient, HttpHeaders } from '@angular/common/http';
2
- import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
3
- import { Observable } from 'rxjs';
4
- import { HeaderParams } from './models/von-header-params.model';
5
- import { VonHttpOptionsModel } from './models/von-http-options.model';
6
- import { BaseParams, BodyParams, GenericParams } from './models/von-rest-definition.model';
7
- /**
8
- * Rest service wrapper for API calls. This class needs to be extended in a `@Injectable({ providedIn: 'root' })` service.
9
- * Parameters needed:
10
- * @HttpClient
11
- * @DomSanitizer
12
- */
13
- export declare abstract class VonRestService {
14
- protected http: HttpClient;
15
- protected sanitizer: DomSanitizer;
16
- constructor(http: HttpClient, sanitizer: DomSanitizer);
17
- /**
18
- * Allows to set the default headers
19
- * @param headerParams Check HeaderParams interface to verify allowed overrides
20
- * @returns
21
- * ```json
22
- * {
23
- * "Content-Type": "application/json",
24
- * "Accept": "application/json",
25
- * "Access-Control-Allow-Origin": "*"
26
- * }
27
- * ```
28
- */
29
- protected setHeaders: (headerParams?: HeaderParams) => HttpHeaders;
30
- protected setOptions: ({ headerParams, queryParams: params, }?: {
31
- headerParams?: HeaderParams;
32
- queryParams?: GenericParams;
33
- }) => VonHttpOptionsModel;
34
- protected setOptionsForFile: ({ headerParams, queryParams, }?: {
35
- headerParams?: HeaderParams;
36
- queryParams?: GenericParams;
37
- }) => VonHttpOptionsModel;
38
- protected setUrlParams: (url: string, params?: GenericParams) => string;
39
- protected authenticate: (url: string, username: string, password: string) => Observable<any>;
40
- protected get: <R = any>({ url, urlParams, queryParams: params, headerParams, header: oldHeaderParams, params: oldParams, }: BaseParams) => Observable<R>;
41
- protected delete: <R = any>({ url, urlParams, queryParams: params, headerParams, header: oldHeaderParams, params: oldParams, }: BaseParams) => Observable<R>;
42
- protected post: <R = any, B = GenericParams | FormData>({ url, body, urlParams, queryParams: params, headerParams, header: oldHeaderParams, params: oldParams, }: BodyParams<B>) => Observable<R>;
43
- protected put: <R = any, B = GenericParams | FormData>({ url, body, urlParams, queryParams: params, headerParams, header: oldHeaderParams, params: oldParams, }: BodyParams<B>) => Observable<R>;
44
- protected patch: <R = any, B = GenericParams | FormData>({ url, body, urlParams, queryParams: params, headerParams, header: oldHeaderParams, params: oldParams, }: BodyParams<B>) => Observable<R>;
45
- protected file: ({ url, urlParams, queryParams: params, headerParams, header: oldHeaderParams, params: oldParams, }: BaseParams) => Observable<SafeResourceUrl>;
46
- }
package/public-api.d.ts DELETED
@@ -1,7 +0,0 @@
1
- export * from './lib/models/von-error-rest-interceptor.model';
2
- export * from './lib/models/von-header-params.model';
3
- export * from './lib/models/von-http-options.model';
4
- export * from './lib/models/von-page-response.model';
5
- export * from './lib/models/von-rest-definition.model';
6
- export * from './lib/von-rest-interceptor.service';
7
- export * from './lib/von-rest.service';