@dataclouder/ngx-core 0.1.9 → 0.1.11
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/fesm2022/dataclouder-ngx-core.mjs +646 -163
- package/fesm2022/dataclouder-ngx-core.mjs.map +1 -1
- package/lib/components/confirm/confirm.component.d.ts +4 -3
- package/lib/components/empty-state/empty-state.component.d.ts +2 -2
- package/lib/components/list-filter-bar/dc-list-filter-bar.component.d.ts +7 -6
- package/lib/components/loading-bar/loading-bar.d.ts +0 -1
- package/lib/components/progress-toast/progress-toast.d.ts +7 -7
- package/lib/components/quick-table/quick-table.d.ts +13 -15
- package/lib/models/pagination.abstract.d.ts +3 -4
- package/lib/services/confirm.service.d.ts +2 -1
- package/lib/services/http-core.service.d.ts +204 -0
- package/package.json +1 -1
- package/public-api.d.ts +1 -0
- package/README.md +0 -24
|
@@ -11,7 +11,8 @@ export interface ConfirmOptions {
|
|
|
11
11
|
}
|
|
12
12
|
export declare class ConfirmService {
|
|
13
13
|
pdialogService: DialogService;
|
|
14
|
-
|
|
14
|
+
/** Inserted by Angular inject() migration for backwards compatibility */
|
|
15
|
+
constructor(...args: unknown[]);
|
|
15
16
|
openConfirm(title?: string, message?: string, acceptText?: string): import("rxjs").Observable<any>;
|
|
16
17
|
confirm(options: ConfirmOptions): Promise<any>;
|
|
17
18
|
static ɵfac: i0.ɵɵFactoryDeclaration<ConfirmService, never>;
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { HttpErrorResponse } from '@angular/common/http';
|
|
2
|
+
import { InjectionToken } from '@angular/core';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
/**
|
|
6
|
+
* Interface for HTTP error responses
|
|
7
|
+
*/
|
|
8
|
+
export interface HttpCoreError {
|
|
9
|
+
error_message: string;
|
|
10
|
+
explanation: string;
|
|
11
|
+
status?: number;
|
|
12
|
+
code?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Interface for deleted data response
|
|
16
|
+
*/
|
|
17
|
+
export interface DeletedData {
|
|
18
|
+
acknowledged: boolean;
|
|
19
|
+
deletedCount: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Configuration for HttpCoreService
|
|
23
|
+
*/
|
|
24
|
+
export interface HttpCoreConfig {
|
|
25
|
+
primaryUrl: string;
|
|
26
|
+
secondaryUrl?: string;
|
|
27
|
+
defaultHost?: 'primary' | 'secondary';
|
|
28
|
+
errorHandler?: (error: HttpErrorResponse) => void;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Injection token for HttpCoreService configuration
|
|
32
|
+
*/
|
|
33
|
+
export declare const HTTP_CORE_CONFIG: InjectionToken<HttpCoreConfig>;
|
|
34
|
+
/**
|
|
35
|
+
* Modern HTTP service for Angular applications
|
|
36
|
+
* Provides methods for making HTTP requests with proper error handling and response transformation
|
|
37
|
+
*/
|
|
38
|
+
export declare class HttpCoreService {
|
|
39
|
+
private httpClient;
|
|
40
|
+
private isLoading;
|
|
41
|
+
private lastError;
|
|
42
|
+
private config;
|
|
43
|
+
constructor(config: HttpCoreConfig | null);
|
|
44
|
+
/**
|
|
45
|
+
* Set the configuration for the service
|
|
46
|
+
* This allows for manual configuration when not using dependency injection
|
|
47
|
+
*/
|
|
48
|
+
setConfig(config: HttpCoreConfig): void;
|
|
49
|
+
/**
|
|
50
|
+
* Get the loading state as a signal
|
|
51
|
+
*/
|
|
52
|
+
loading(): import("@angular/core").WritableSignal<boolean>;
|
|
53
|
+
/**
|
|
54
|
+
* Get the last error as a signal
|
|
55
|
+
*/
|
|
56
|
+
error(): import("@angular/core").WritableSignal<HttpCoreError>;
|
|
57
|
+
/**
|
|
58
|
+
* Make a POST request to the specified service
|
|
59
|
+
* @param service The service endpoint
|
|
60
|
+
* @param data The data to send
|
|
61
|
+
* @param host The host to use (primary or secondary)
|
|
62
|
+
* @returns A promise with the response
|
|
63
|
+
*/
|
|
64
|
+
post<T = any>(service: string, data: any, host?: "primary" | "secondary"): Promise<T>;
|
|
65
|
+
/**
|
|
66
|
+
* Make a POST request to a specific URL
|
|
67
|
+
* @param baseUrl The base URL
|
|
68
|
+
* @param service The service endpoint
|
|
69
|
+
* @param data The data to send
|
|
70
|
+
* @returns A promise with the response
|
|
71
|
+
*/
|
|
72
|
+
postToUrl<T = any>(baseUrl: string, service: string, data: any): Promise<T>;
|
|
73
|
+
/**
|
|
74
|
+
* Make a PUT request to the specified service
|
|
75
|
+
* @param service The service endpoint
|
|
76
|
+
* @param data The data to send
|
|
77
|
+
* @param host The host to use (primary or secondary)
|
|
78
|
+
* @returns A promise with the response
|
|
79
|
+
*/
|
|
80
|
+
put<T = any>(service: string, data: any, host?: "primary" | "secondary"): Promise<T>;
|
|
81
|
+
/**
|
|
82
|
+
* Make a PUT request to a specific URL
|
|
83
|
+
* @param baseUrl The base URL
|
|
84
|
+
* @param service The service endpoint
|
|
85
|
+
* @param data The data to send
|
|
86
|
+
* @returns A promise with the response
|
|
87
|
+
*/
|
|
88
|
+
putToUrl<T = any>(baseUrl: string, service: string, data: any): Promise<T>;
|
|
89
|
+
/**
|
|
90
|
+
* Make a GET request to the specified service
|
|
91
|
+
* @param service The service endpoint
|
|
92
|
+
* @param host The host to use (primary or secondary)
|
|
93
|
+
* @param skipErrorHandling Whether to skip error handling
|
|
94
|
+
* @returns A promise with the response
|
|
95
|
+
*/
|
|
96
|
+
get<T = any>(service: string, host?: "primary" | "secondary", skipErrorHandling?: boolean): Promise<T>;
|
|
97
|
+
/**
|
|
98
|
+
* Make a GET request to a specific URL
|
|
99
|
+
* @param baseUrl The base URL
|
|
100
|
+
* @param service The service endpoint
|
|
101
|
+
* @param skipErrorHandling Whether to skip error handling
|
|
102
|
+
* @returns A promise with the response
|
|
103
|
+
*/
|
|
104
|
+
getFromUrl<T = any>(baseUrl: string, service: string, skipErrorHandling?: boolean): Promise<T>;
|
|
105
|
+
/**
|
|
106
|
+
* Make a DELETE request to the specified service
|
|
107
|
+
* @param service The service endpoint
|
|
108
|
+
* @param host The host to use (primary or secondary)
|
|
109
|
+
* @returns A promise with the response
|
|
110
|
+
*/
|
|
111
|
+
delete<T = DeletedData>(service: string, host?: "primary" | "secondary"): Promise<T>;
|
|
112
|
+
/**
|
|
113
|
+
* Make a DELETE request to a specific URL
|
|
114
|
+
* @param baseUrl The base URL
|
|
115
|
+
* @param service The service endpoint
|
|
116
|
+
* @returns A promise with the response
|
|
117
|
+
*/
|
|
118
|
+
deleteFromUrl<T = DeletedData>(baseUrl: string, service: string): Promise<T>;
|
|
119
|
+
/**
|
|
120
|
+
* Get an observable for a GET request
|
|
121
|
+
* @param service The service endpoint
|
|
122
|
+
* @param host The host to use (primary or secondary)
|
|
123
|
+
* @returns An observable with the response
|
|
124
|
+
*/
|
|
125
|
+
getObservable<T = any>(service: string, host?: "primary" | "secondary"): Observable<T>;
|
|
126
|
+
/**
|
|
127
|
+
* Get an observable for a POST request
|
|
128
|
+
* @param service The service endpoint
|
|
129
|
+
* @param data The data to send
|
|
130
|
+
* @param skipErrorHandling Whether to skip error handling
|
|
131
|
+
* @param host The host to use (primary or secondary)
|
|
132
|
+
* @returns An observable with the response
|
|
133
|
+
*/
|
|
134
|
+
postObservable<T = any>(service: string, data: any, skipErrorHandling?: boolean, host?: "primary" | "secondary"): Observable<T>;
|
|
135
|
+
/**
|
|
136
|
+
* Get an observable for a DELETE request
|
|
137
|
+
* @param service The service endpoint
|
|
138
|
+
* @param host The host to use (primary or secondary)
|
|
139
|
+
* @returns An observable with the response
|
|
140
|
+
*/
|
|
141
|
+
deleteObservable<T = DeletedData>(service: string, host?: "primary" | "secondary"): Observable<T>;
|
|
142
|
+
/**
|
|
143
|
+
* Upload a file to the specified service
|
|
144
|
+
* @param service The service endpoint
|
|
145
|
+
* @param file The file to upload
|
|
146
|
+
* @param metadata Optional metadata to send with the file
|
|
147
|
+
* @param host The host to use (primary or secondary)
|
|
148
|
+
* @returns A promise with the response
|
|
149
|
+
*/
|
|
150
|
+
uploadFile<T = any>(service: string, file: Blob, metadata?: any, host?: "primary" | "secondary"): Promise<T>;
|
|
151
|
+
/**
|
|
152
|
+
* Download a file from the specified service
|
|
153
|
+
* @param service The service endpoint
|
|
154
|
+
* @param host The host to use (primary or secondary)
|
|
155
|
+
* @returns A promise with the response
|
|
156
|
+
*/
|
|
157
|
+
downloadFile(service: string, host?: "primary" | "secondary"): Promise<any>;
|
|
158
|
+
/**
|
|
159
|
+
* Upload a file to the specified service and get the response as a blob
|
|
160
|
+
* @param service The service endpoint
|
|
161
|
+
* @param data The data to send
|
|
162
|
+
* @param host The host to use (primary or secondary)
|
|
163
|
+
* @returns A promise with the response
|
|
164
|
+
*/
|
|
165
|
+
postFileAndGetBlob(service: string, data: any, host?: "primary" | "secondary"): Promise<any>;
|
|
166
|
+
/**
|
|
167
|
+
* Get a file from the specified service as an observable
|
|
168
|
+
* @param service The service endpoint
|
|
169
|
+
* @param host The host to use (primary or secondary)
|
|
170
|
+
* @returns An observable with the response
|
|
171
|
+
*/
|
|
172
|
+
getFileObservable(service: string, host?: "primary" | "secondary"): Observable<Blob>;
|
|
173
|
+
/**
|
|
174
|
+
* Get the URL for the specified host
|
|
175
|
+
* @param host The host to use (primary or secondary)
|
|
176
|
+
* @returns The URL for the specified host
|
|
177
|
+
*/
|
|
178
|
+
private getHostUrl;
|
|
179
|
+
/**
|
|
180
|
+
* Handle an error from a request
|
|
181
|
+
* @param error The error to handle
|
|
182
|
+
* @returns An observable that throws the error
|
|
183
|
+
*/
|
|
184
|
+
private handleRequestError;
|
|
185
|
+
/**
|
|
186
|
+
* Handle an error from a blob request
|
|
187
|
+
* @param error The error to handle
|
|
188
|
+
* @returns An observable that throws the error
|
|
189
|
+
*/
|
|
190
|
+
private handleBlobError;
|
|
191
|
+
/**
|
|
192
|
+
* Check the status of a response
|
|
193
|
+
* @param response The response to check
|
|
194
|
+
*/
|
|
195
|
+
private checkResponseStatus;
|
|
196
|
+
/**
|
|
197
|
+
* Convert an object to a plain object
|
|
198
|
+
* @param obj The object to convert
|
|
199
|
+
* @returns A plain object
|
|
200
|
+
*/
|
|
201
|
+
private toPlainObject;
|
|
202
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<HttpCoreService, [{ optional: true; }]>;
|
|
203
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<HttpCoreService>;
|
|
204
|
+
}
|
package/package.json
CHANGED
package/public-api.d.ts
CHANGED
|
@@ -11,3 +11,4 @@ export * from './lib/components/loading-bar/loading-bar';
|
|
|
11
11
|
export * from './lib/components/loading-bar/loading-bar.service';
|
|
12
12
|
export * from './lib/components/quick-table/quick-table';
|
|
13
13
|
export * from './lib/pipes/loadash-get.pipe';
|
|
14
|
+
export * from './lib/services/http-core.service';
|
package/README.md
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# CoreComponents
|
|
2
|
-
|
|
3
|
-
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 17.3.0.
|
|
4
|
-
|
|
5
|
-
## Code scaffolding
|
|
6
|
-
|
|
7
|
-
Run `ng generate component component-name --project core-components` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project core-components`.
|
|
8
|
-
> Note: Don't forget to add `--project core-components` or else it will be added to the default project in your `angular.json` file.
|
|
9
|
-
|
|
10
|
-
## Build
|
|
11
|
-
|
|
12
|
-
Run `ng build core-components` to build the project. The build artifacts will be stored in the `dist/` directory.
|
|
13
|
-
|
|
14
|
-
## Publishing
|
|
15
|
-
|
|
16
|
-
After building your library with `ng build core-components`, go to the dist folder `cd dist/core-components` and run `npm publish`.
|
|
17
|
-
|
|
18
|
-
## Running unit tests
|
|
19
|
-
|
|
20
|
-
Run `ng test core-components` to execute the unit tests via [Karma](https://karma-runner.github.io).
|
|
21
|
-
|
|
22
|
-
## Further help
|
|
23
|
-
|
|
24
|
-
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
|