ngx-gp-api-core 0.0.1
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/README.md +34 -0
- package/fesm2022/ngx-gp-api-core.mjs +115 -0
- package/fesm2022/ngx-gp-api-core.mjs.map +1 -0
- package/package.json +23 -0
- package/types/ngx-gp-api-core.d.ts +31 -0
package/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# GP API Core
|
|
2
|
+
A library that provides business logic endpoints to interact with the GP Widgets Resource Server on a higher abstraction level. No deeper knowledge of the endpoints of the resource server necessary for application of the provided functions.
|
|
3
|
+
|
|
4
|
+
## Building
|
|
5
|
+
|
|
6
|
+
To build the library, run:
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
ng build ngx-gp-api-core
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
This command will compile your project, and the build artifacts will be placed in the `dist/` directory.
|
|
13
|
+
|
|
14
|
+
### Publishing the Library
|
|
15
|
+
|
|
16
|
+
Once the project is built, you can publish your library by following these steps:
|
|
17
|
+
|
|
18
|
+
1. Navigate to the `dist` directory:
|
|
19
|
+
```bash
|
|
20
|
+
cd dist/ngx-gp-api-core
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
2. Run the `npm publish` command to publish your library to the npm registry:
|
|
24
|
+
```bash
|
|
25
|
+
npm publish
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Running unit tests
|
|
29
|
+
|
|
30
|
+
To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
ng test
|
|
34
|
+
```
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, Injectable } from '@angular/core';
|
|
3
|
+
import { HttpHeaders, HttpErrorResponse, HttpClient } from '@angular/common/http';
|
|
4
|
+
import { throwError } from 'rxjs';
|
|
5
|
+
import { catchError } from 'rxjs/operators';
|
|
6
|
+
|
|
7
|
+
function buildAuthHeaders(bearerToken) {
|
|
8
|
+
let headers = new HttpHeaders();
|
|
9
|
+
if (bearerToken)
|
|
10
|
+
headers = headers.set('Authorization', `Bearer ${bearerToken}`);
|
|
11
|
+
return headers;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
class ApiError extends Error {
|
|
15
|
+
status;
|
|
16
|
+
payload;
|
|
17
|
+
url;
|
|
18
|
+
constructor(message, status, payload, url) {
|
|
19
|
+
super(message);
|
|
20
|
+
this.status = status;
|
|
21
|
+
this.payload = payload;
|
|
22
|
+
this.url = url;
|
|
23
|
+
this.name = 'ApiError';
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function toApiError(err, url) {
|
|
27
|
+
if (err instanceof HttpErrorResponse) {
|
|
28
|
+
const payload = err.error;
|
|
29
|
+
const message = (typeof payload === 'string' && payload) ||
|
|
30
|
+
(payload && (payload.message || payload.error)) ||
|
|
31
|
+
err.message ||
|
|
32
|
+
`HTTP error ${err.status}`;
|
|
33
|
+
return new ApiError(message, err.status, payload, url ?? err.url ?? undefined);
|
|
34
|
+
}
|
|
35
|
+
return new ApiError(err?.message || 'Request failed', undefined, undefined, url);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function get(http, opts) {
|
|
39
|
+
const headers = buildAuthHeaders(opts.bearerToken);
|
|
40
|
+
if (opts.responseType === 'blob') {
|
|
41
|
+
return http
|
|
42
|
+
.get(opts.url, { headers, responseType: 'blob' })
|
|
43
|
+
.pipe(catchError((e) => throwError(() => toApiError(e, opts.url))));
|
|
44
|
+
}
|
|
45
|
+
return http
|
|
46
|
+
.get(opts.url, { headers, responseType: 'json' })
|
|
47
|
+
.pipe(catchError((e) => throwError(() => toApiError(e, opts.url))));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function post(http, opts) {
|
|
51
|
+
let headers = buildAuthHeaders(opts.bearerToken);
|
|
52
|
+
headers = headers.set('Content-Type', 'application/json');
|
|
53
|
+
if (opts.responseType === 'blob') {
|
|
54
|
+
return http
|
|
55
|
+
.post(opts.url, opts.body, { headers, responseType: 'blob' })
|
|
56
|
+
.pipe(catchError((e) => throwError(() => toApiError(e, opts.url))));
|
|
57
|
+
}
|
|
58
|
+
return http
|
|
59
|
+
.post(opts.url, opts.body, { headers, responseType: 'json' })
|
|
60
|
+
.pipe(catchError((e) => throwError(() => toApiError(e, opts.url))));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function put(http, opts) {
|
|
64
|
+
let headers = buildAuthHeaders(opts.bearerToken);
|
|
65
|
+
headers = headers.set('Content-Type', 'application/json');
|
|
66
|
+
if (opts.responseType === 'blob') {
|
|
67
|
+
return http
|
|
68
|
+
.put(opts.url, opts.body, { headers, responseType: 'blob' })
|
|
69
|
+
.pipe(catchError((e) => throwError(() => toApiError(e, opts.url))));
|
|
70
|
+
}
|
|
71
|
+
return http
|
|
72
|
+
.put(opts.url, opts.body, { headers, responseType: 'json' })
|
|
73
|
+
.pipe(catchError((e) => throwError(() => toApiError(e, opts.url))));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function delete_(http, opts) {
|
|
77
|
+
const headers = buildAuthHeaders(opts.bearerToken);
|
|
78
|
+
return http
|
|
79
|
+
.delete(opts.url, { headers, responseType: 'json' })
|
|
80
|
+
.pipe(catchError((e) => throwError(() => toApiError(e, opts.url))));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
class GPApiCore {
|
|
84
|
+
http = inject(HttpClient);
|
|
85
|
+
get(opts) {
|
|
86
|
+
return get(this.http, opts);
|
|
87
|
+
}
|
|
88
|
+
post(opts) {
|
|
89
|
+
return post(this.http, opts);
|
|
90
|
+
}
|
|
91
|
+
put(opts) {
|
|
92
|
+
return put(this.http, opts);
|
|
93
|
+
}
|
|
94
|
+
delete(opts) {
|
|
95
|
+
return delete_(this.http, opts);
|
|
96
|
+
}
|
|
97
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.5", ngImport: i0, type: GPApiCore, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
98
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.5", ngImport: i0, type: GPApiCore, providedIn: 'root' });
|
|
99
|
+
}
|
|
100
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.5", ngImport: i0, type: GPApiCore, decorators: [{
|
|
101
|
+
type: Injectable,
|
|
102
|
+
args: [{ providedIn: 'root' }]
|
|
103
|
+
}] });
|
|
104
|
+
|
|
105
|
+
/*
|
|
106
|
+
* Public API Surface of ngx-gp-api-core
|
|
107
|
+
*/
|
|
108
|
+
//TODO: Adjust exports to what actually should be public
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Generated bundle index. Do not edit.
|
|
112
|
+
*/
|
|
113
|
+
|
|
114
|
+
export { GPApiCore };
|
|
115
|
+
//# sourceMappingURL=ngx-gp-api-core.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ngx-gp-api-core.mjs","sources":["../../../projects/ngx-gp-api-core/src/lib/http-helpers/request-helpers.ts","../../../projects/ngx-gp-api-core/src/lib/http-helpers/api-error.ts","../../../projects/ngx-gp-api-core/src/lib/requests/get.ts","../../../projects/ngx-gp-api-core/src/lib/requests/post.ts","../../../projects/ngx-gp-api-core/src/lib/requests/put.ts","../../../projects/ngx-gp-api-core/src/lib/requests/delete.ts","../../../projects/ngx-gp-api-core/src/lib/ngx-gp-api-core.ts","../../../projects/ngx-gp-api-core/src/public-api.ts","../../../projects/ngx-gp-api-core/src/ngx-gp-api-core.ts"],"sourcesContent":["import { HttpHeaders } from '@angular/common/http';\n\nexport function buildAuthHeaders(bearerToken?: string) {\n let headers = new HttpHeaders();\n if (bearerToken) headers = headers.set('Authorization', `Bearer ${bearerToken}`);\n return headers;\n}\n","import { HttpErrorResponse } from '@angular/common/http';\n\nexport class ApiError extends Error {\n constructor(\n message: string,\n public readonly status?: number,\n public readonly payload?: unknown,\n public readonly url?: string\n ) {\n super(message);\n this.name = 'ApiError';\n }\n}\n\nexport function toApiError(err: unknown, url?: string): ApiError {\n if (err instanceof HttpErrorResponse) {\n const payload = err.error;\n const message =\n (typeof payload === 'string' && payload) ||\n (payload && (payload.message || payload.error)) ||\n err.message ||\n `HTTP error ${err.status}`;\n\n return new ApiError(message, err.status, payload, url ?? err.url ?? undefined);\n }\n\n return new ApiError((err as any)?.message || 'Request failed', undefined, undefined, url);\n}\n","import {RequestOptionsBlob, RequestOptionsJson} from '../http-helpers/request-options';\nimport { buildAuthHeaders } from '../http-helpers/request-helpers';\nimport {HttpClient} from '@angular/common/http';\nimport {Observable, throwError} from 'rxjs';\nimport {catchError} from 'rxjs/operators';\nimport {toApiError} from '../http-helpers/api-error';\n\nexport function get<T = unknown>(\n http: HttpClient,\n opts: RequestOptionsJson | RequestOptionsBlob\n): Observable<T | Blob> {\n const headers = buildAuthHeaders(opts.bearerToken);\n\n if (opts.responseType === 'blob') {\n return http\n .get(opts.url, { headers, responseType: 'blob' as const })\n .pipe(catchError((e) => throwError(() => toApiError(e, opts.url))));\n }\n\n return http\n .get<T>(opts.url, { headers, responseType: 'json' as const })\n .pipe(catchError((e) => throwError(() => toApiError(e, opts.url))));\n}\n","import {HttpClient} from '@angular/common/http';\nimport {Observable, throwError} from 'rxjs';\nimport {catchError} from 'rxjs/operators';\n\nimport {toApiError} from '../http-helpers/api-error';\nimport {BodyRequestOptionsBlob, BodyRequestOptionsJson} from '../http-helpers/request-options';\nimport {buildAuthHeaders} from '../http-helpers/request-helpers';\n\nexport function post<T = unknown>(\n http: HttpClient,\n opts: BodyRequestOptionsJson | BodyRequestOptionsBlob\n): Observable<T | Blob> {\n\n let headers = buildAuthHeaders(opts.bearerToken);\n\n headers = headers.set('Content-Type', 'application/json');\n\n if (opts.responseType === 'blob') {\n return http\n .post(opts.url, opts.body, {headers, responseType: 'blob' as const})\n .pipe(catchError((e) => throwError(() => toApiError(e, opts.url))));\n }\n\n return http\n .post<T>(opts.url, opts.body, {headers, responseType: 'json' as const})\n .pipe(catchError((e) => throwError(() => toApiError(e, opts.url))));\n}\n","import {HttpClient} from '@angular/common/http';\nimport {Observable, throwError} from 'rxjs';\nimport {catchError} from 'rxjs/operators';\n\nimport {toApiError} from '../http-helpers/api-error';\nimport {BodyRequestOptionsBlob, BodyRequestOptionsJson} from '../http-helpers/request-options';\nimport {buildAuthHeaders} from '../http-helpers/request-helpers';\n\nexport function put<T = unknown>(\n http: HttpClient,\n opts: BodyRequestOptionsJson | BodyRequestOptionsBlob\n): Observable<T | Blob> {\n let headers = buildAuthHeaders(opts.bearerToken);\n\n headers = headers.set('Content-Type', 'application/json');\n\n if (opts.responseType === 'blob') {\n return http\n .put(opts.url, opts.body, {headers, responseType: 'blob' as const})\n .pipe(catchError((e) => throwError(() => toApiError(e, opts.url))));\n }\n\n return http\n .put<T>(opts.url, opts.body, {headers, responseType: 'json' as const})\n .pipe(catchError((e) => throwError(() => toApiError(e, opts.url))));\n}\n","import {HttpClient} from '@angular/common/http';\nimport {Observable, throwError} from 'rxjs';\nimport {buildAuthHeaders} from '../http-helpers/request-helpers';\nimport {catchError} from 'rxjs/operators';\nimport {toApiError} from '../http-helpers/api-error';\nimport {BaseRequestOptions} from '../http-helpers/request-options';\n\nexport function delete_<T = unknown>(\n http: HttpClient,\n opts: BaseRequestOptions\n): Observable<T> {\n const headers = buildAuthHeaders(opts.bearerToken);\n\n return http\n .delete<T>(opts.url, {headers, responseType: 'json' as const})\n .pipe(catchError((e) => throwError(() => toApiError(e, opts.url))));\n}\n","import { inject, Injectable } from '@angular/core';\nimport { Observable } from 'rxjs';\nimport { HttpClient } from '@angular/common/http';\n\nimport { get } from './requests/get';\nimport { post } from './requests/post';\nimport { put } from './requests/put';\nimport { delete_ } from './requests/delete';\nimport {\n BaseRequestOptions,\n RequestOptionsBlob,\n RequestOptionsJson,\n BodyRequestOptionsBlob,\n BodyRequestOptionsJson\n} from './http-helpers/request-options';\n\n@Injectable({ providedIn: 'root' })\nexport class GPApiCore {\n private http = inject(HttpClient);\n\n public get<T = unknown>(opts: RequestOptionsJson | RequestOptionsBlob): Observable<T | Blob> {\n return get<T>(this.http, opts as any);\n }\n\n public post<T = unknown>(opts: BodyRequestOptionsJson | BodyRequestOptionsBlob): Observable<T | Blob> {\n return post<T>(this.http, opts as any);\n }\n\n public put<T = unknown>(opts: BodyRequestOptionsJson | BodyRequestOptionsBlob): Observable<T | Blob> {\n return put<T>(this.http, opts as any);\n }\n\n public delete<T = unknown>(opts: BaseRequestOptions): Observable<T>{\n return delete_(this.http, opts as any);\n }\n}\n","/*\n * Public API Surface of ngx-gp-api-core\n */\n\n//TODO: Adjust exports to what actually should be public\nexport { GPApiCore } from './lib/ngx-gp-api-core';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;AAEM,SAAU,gBAAgB,CAAC,WAAoB,EAAA;AACnD,IAAA,IAAI,OAAO,GAAG,IAAI,WAAW,EAAE;AAC/B,IAAA,IAAI,WAAW;QAAE,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,CAAA,OAAA,EAAU,WAAW,CAAA,CAAE,CAAC;AAChF,IAAA,OAAO,OAAO;AAChB;;ACJM,MAAO,QAAS,SAAQ,KAAK,CAAA;AAGf,IAAA,MAAA;AACA,IAAA,OAAA;AACA,IAAA,GAAA;AAJlB,IAAA,WAAA,CACE,OAAe,EACC,MAAe,EACf,OAAiB,EACjB,GAAY,EAAA;QAE5B,KAAK,CAAC,OAAO,CAAC;QAJE,IAAA,CAAA,MAAM,GAAN,MAAM;QACN,IAAA,CAAA,OAAO,GAAP,OAAO;QACP,IAAA,CAAA,GAAG,GAAH,GAAG;AAGnB,QAAA,IAAI,CAAC,IAAI,GAAG,UAAU;IACxB;AACD;AAEK,SAAU,UAAU,CAAC,GAAY,EAAE,GAAY,EAA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,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAAT,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,SAAS,cADI,MAAM,EAAA,CAAA;;2FACnB,SAAS,EAAA,UAAA,EAAA,CAAA;kBADrB,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;AChBlC;;AAEG;AAEH;;ACJA;;AAEG;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ngx-gp-api-core",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"peerDependencies": {
|
|
5
|
+
"@angular/common": "^21.1.0",
|
|
6
|
+
"@angular/core": "^21.1.0"
|
|
7
|
+
},
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"tslib": "^2.3.0"
|
|
10
|
+
},
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"module": "fesm2022/ngx-gp-api-core.mjs",
|
|
13
|
+
"typings": "types/ngx-gp-api-core.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
"./package.json": {
|
|
16
|
+
"default": "./package.json"
|
|
17
|
+
},
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./types/ngx-gp-api-core.d.ts",
|
|
20
|
+
"default": "./fesm2022/ngx-gp-api-core.mjs"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
|
|
4
|
+
interface BaseRequestOptions {
|
|
5
|
+
url: string;
|
|
6
|
+
bearerToken?: string;
|
|
7
|
+
}
|
|
8
|
+
type RequestOptionsJson = BaseRequestOptions & {
|
|
9
|
+
responseType?: 'json';
|
|
10
|
+
};
|
|
11
|
+
type RequestOptionsBlob = BaseRequestOptions & {
|
|
12
|
+
responseType: 'blob';
|
|
13
|
+
};
|
|
14
|
+
type BodyRequestOptionsJson = RequestOptionsJson & {
|
|
15
|
+
body: unknown;
|
|
16
|
+
};
|
|
17
|
+
type BodyRequestOptionsBlob = RequestOptionsBlob & {
|
|
18
|
+
body: unknown;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
declare class GPApiCore {
|
|
22
|
+
private http;
|
|
23
|
+
get<T = unknown>(opts: RequestOptionsJson | RequestOptionsBlob): Observable<T | Blob>;
|
|
24
|
+
post<T = unknown>(opts: BodyRequestOptionsJson | BodyRequestOptionsBlob): Observable<T | Blob>;
|
|
25
|
+
put<T = unknown>(opts: BodyRequestOptionsJson | BodyRequestOptionsBlob): Observable<T | Blob>;
|
|
26
|
+
delete<T = unknown>(opts: BaseRequestOptions): Observable<T>;
|
|
27
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<GPApiCore, never>;
|
|
28
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<GPApiCore>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { GPApiCore };
|