@eac-arch/infrastructure-http 0.0.0-ci.20260308042601
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
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# EacArchInfrastructureHttp
|
|
2
|
+
|
|
3
|
+
This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 21.1.0.
|
|
4
|
+
|
|
5
|
+
## Code scaffolding
|
|
6
|
+
|
|
7
|
+
Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
ng generate component component-name
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
ng generate --help
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Building
|
|
20
|
+
|
|
21
|
+
To build the library, run:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
ng build eac-arch-infrastructure-http
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
This command will compile your project, and the build artifacts will be placed in the `dist/` directory.
|
|
28
|
+
|
|
29
|
+
### Publishing the Library
|
|
30
|
+
|
|
31
|
+
Once the project is built, you can publish your library by following these steps:
|
|
32
|
+
|
|
33
|
+
1. Navigate to the `dist` directory:
|
|
34
|
+
```bash
|
|
35
|
+
cd dist/eac-arch-infrastructure-http
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
2. Run the `npm publish` command to publish your library to the npm registry:
|
|
39
|
+
```bash
|
|
40
|
+
npm publish
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Running unit tests
|
|
44
|
+
|
|
45
|
+
To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
ng test
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Running end-to-end tests
|
|
52
|
+
|
|
53
|
+
For end-to-end (e2e) testing, run:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
ng e2e
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
|
|
60
|
+
|
|
61
|
+
## Additional Resources
|
|
62
|
+
|
|
63
|
+
For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, inject, ErrorHandler, Injectable, makeEnvironmentProviders } from '@angular/core';
|
|
3
|
+
import { HttpErrorResponse } from '@angular/common/http';
|
|
4
|
+
import { catchError, throwError } from 'rxjs';
|
|
5
|
+
|
|
6
|
+
// Mirrors the server's PagedList<T> (EAC.SharedKernel.Application.Pagination).
|
|
7
|
+
// A read-only collection of items with pagination metadata.
|
|
8
|
+
class PagedList {
|
|
9
|
+
items;
|
|
10
|
+
currentPage;
|
|
11
|
+
totalPages;
|
|
12
|
+
pageSize;
|
|
13
|
+
totalCount;
|
|
14
|
+
get hasPrevious() {
|
|
15
|
+
return this.currentPage > 1;
|
|
16
|
+
}
|
|
17
|
+
get hasNext() {
|
|
18
|
+
return this.currentPage < this.totalPages;
|
|
19
|
+
}
|
|
20
|
+
constructor(items, totalCount, pageNumber, pageSize) {
|
|
21
|
+
if (pageSize <= 0) {
|
|
22
|
+
throw new Error('Page size must be greater than 0');
|
|
23
|
+
}
|
|
24
|
+
if (pageNumber <= 0) {
|
|
25
|
+
throw new Error('Page number must be greater than 0');
|
|
26
|
+
}
|
|
27
|
+
if (totalCount < 0) {
|
|
28
|
+
throw new Error('Total count cannot be negative');
|
|
29
|
+
}
|
|
30
|
+
this.totalCount = totalCount;
|
|
31
|
+
this.pageSize = pageSize;
|
|
32
|
+
this.currentPage = pageNumber;
|
|
33
|
+
this.totalPages = Math.ceil(totalCount / pageSize);
|
|
34
|
+
this.items = Object.freeze([...items]);
|
|
35
|
+
}
|
|
36
|
+
static empty(pageSize = 10) {
|
|
37
|
+
return new PagedList([], 0, 1, pageSize);
|
|
38
|
+
}
|
|
39
|
+
static create(items, totalCount, pageNumber, pageSize) {
|
|
40
|
+
return new PagedList(items, totalCount, pageNumber, pageSize);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const ERROR_NOTIFICATION_SERVICE = new InjectionToken('ErrorNotificationService');
|
|
45
|
+
|
|
46
|
+
const httpErrorInterceptor = (req, next) => {
|
|
47
|
+
// Capture in injection context, before any async operation
|
|
48
|
+
const notificationService = inject(ERROR_NOTIFICATION_SERVICE, { optional: true });
|
|
49
|
+
return next(req).pipe(catchError((error) => {
|
|
50
|
+
// Skip if explicitly marked to skip global error handling
|
|
51
|
+
if (req.headers.has('X-Skip-Global-Error-Handler')) {
|
|
52
|
+
return throwError(() => error);
|
|
53
|
+
}
|
|
54
|
+
if (notificationService) {
|
|
55
|
+
if (!(error instanceof HttpErrorResponse)) {
|
|
56
|
+
const unknownError = {
|
|
57
|
+
errors: [{
|
|
58
|
+
status: '0',
|
|
59
|
+
title: 'Unexpected Error',
|
|
60
|
+
detail: error instanceof Error
|
|
61
|
+
? error.message
|
|
62
|
+
: 'An unexpected error occurred while processing the request.'
|
|
63
|
+
}]
|
|
64
|
+
};
|
|
65
|
+
notificationService.handleHttpError(unknownError, 0, req.url);
|
|
66
|
+
return throwError(() => error);
|
|
67
|
+
}
|
|
68
|
+
// Network errors (ERR_CONNECTION_REFUSED, ERR_CONNECTION_TIMED_OUT, etc.)
|
|
69
|
+
// have status 0 and error.error may be null/undefined with withFetch()
|
|
70
|
+
if (error.status === 0 || !error.error) {
|
|
71
|
+
const networkError = {
|
|
72
|
+
errors: [{
|
|
73
|
+
status: '0',
|
|
74
|
+
title: 'Connection Error',
|
|
75
|
+
detail: 'Could not connect to the server. Please check your connection or try again later.'
|
|
76
|
+
}]
|
|
77
|
+
};
|
|
78
|
+
notificationService.handleHttpError(networkError, 0, req.url);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
try {
|
|
82
|
+
// Try to parse as JSON:API error response
|
|
83
|
+
const errorResponse = error.error;
|
|
84
|
+
if (errorResponse.errors && Array.isArray(errorResponse.errors)) {
|
|
85
|
+
notificationService.handleHttpError(errorResponse, error.status, req.url);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
// Not a JSON:API response, create generic error
|
|
89
|
+
const genericError = {
|
|
90
|
+
errors: [{
|
|
91
|
+
status: error.status.toString(),
|
|
92
|
+
title: error.statusText || 'Error',
|
|
93
|
+
detail: typeof error.error === 'string'
|
|
94
|
+
? error.error
|
|
95
|
+
: error.message || 'An unexpected error occurred'
|
|
96
|
+
}]
|
|
97
|
+
};
|
|
98
|
+
notificationService.handleHttpError(genericError, error.status, req.url);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
const genericError = {
|
|
103
|
+
errors: [{
|
|
104
|
+
status: error.status.toString(),
|
|
105
|
+
title: 'Error',
|
|
106
|
+
detail: error.message || 'An unexpected error occurred'
|
|
107
|
+
}]
|
|
108
|
+
};
|
|
109
|
+
notificationService.handleHttpError(genericError, error.status, req.url);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return throwError(() => error);
|
|
114
|
+
}));
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
class GlobalErrorHandler extends ErrorHandler {
|
|
118
|
+
// Inject in class field to stay within injection context
|
|
119
|
+
notificationService = inject(ERROR_NOTIFICATION_SERVICE, { optional: true });
|
|
120
|
+
handleError(error) {
|
|
121
|
+
// HTTP errors are already handled by the interceptor
|
|
122
|
+
if (error instanceof HttpErrorResponse) {
|
|
123
|
+
super.handleError(error);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
// Log to console in all environments
|
|
127
|
+
console.error('Unhandled error:', error);
|
|
128
|
+
if (this.notificationService) {
|
|
129
|
+
this.notificationService.handleCoreError(error);
|
|
130
|
+
}
|
|
131
|
+
// Call parent to ensure default Angular error handling
|
|
132
|
+
super.handleError(error);
|
|
133
|
+
}
|
|
134
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: GlobalErrorHandler, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
135
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: GlobalErrorHandler });
|
|
136
|
+
}
|
|
137
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: GlobalErrorHandler, decorators: [{
|
|
138
|
+
type: Injectable
|
|
139
|
+
}] });
|
|
140
|
+
|
|
141
|
+
function provideErrorHandling() {
|
|
142
|
+
return makeEnvironmentProviders([
|
|
143
|
+
{ provide: ErrorHandler, useClass: GlobalErrorHandler }
|
|
144
|
+
]);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Converts shared-kernel PatchOperation[] to the HTTP transport representation.
|
|
148
|
+
function toJsonPatchOperations(operations) {
|
|
149
|
+
return operations.map(({ op, path, value, from }) => ({ op, path, value, from }));
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/*
|
|
153
|
+
* Public API Surface of eac-arch-infrastructure-http
|
|
154
|
+
*/
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Generated bundle index. Do not edit.
|
|
158
|
+
*/
|
|
159
|
+
|
|
160
|
+
export { ERROR_NOTIFICATION_SERVICE, PagedList, httpErrorInterceptor, provideErrorHandling, toJsonPatchOperations };
|
|
161
|
+
//# sourceMappingURL=eac-arch-infrastructure-http.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eac-arch-infrastructure-http.mjs","sources":["../../../projects/eac-arch-infrastructure-http/src/lib/pagination/paged-list.ts","../../../projects/eac-arch-infrastructure-http/src/lib/errors/error-notification.service.interface.ts","../../../projects/eac-arch-infrastructure-http/src/lib/errors/http-error.interceptor.ts","../../../projects/eac-arch-infrastructure-http/src/lib/errors/global-error.handler.ts","../../../projects/eac-arch-infrastructure-http/src/lib/errors/provide-error-handling.ts","../../../projects/eac-arch-infrastructure-http/src/lib/patch/patch.models.ts","../../../projects/eac-arch-infrastructure-http/src/public-api.ts","../../../projects/eac-arch-infrastructure-http/src/eac-arch-infrastructure-http.ts"],"sourcesContent":["// Mirrors the server's PagedList<T> (EAC.SharedKernel.Application.Pagination).\r\n// A read-only collection of items with pagination metadata.\r\nexport class PagedList<T> {\r\n readonly items: readonly T[];\r\n readonly currentPage: number;\r\n readonly totalPages: number;\r\n readonly pageSize: number;\r\n readonly totalCount: number;\r\n\r\n get hasPrevious(): boolean {\r\n return this.currentPage > 1;\r\n }\r\n\r\n get hasNext(): boolean {\r\n return this.currentPage < this.totalPages;\r\n }\r\n\r\n private constructor(items: T[], totalCount: number, pageNumber: number, pageSize: number) {\r\n if (pageSize <= 0) {\r\n throw new Error('Page size must be greater than 0');\r\n }\r\n if (pageNumber <= 0) {\r\n throw new Error('Page number must be greater than 0');\r\n }\r\n if (totalCount < 0) {\r\n throw new Error('Total count cannot be negative');\r\n }\r\n\r\n this.totalCount = totalCount;\r\n this.pageSize = pageSize;\r\n this.currentPage = pageNumber;\r\n this.totalPages = Math.ceil(totalCount / pageSize);\r\n this.items = Object.freeze([...items]);\r\n }\r\n\r\n static empty<T>(pageSize = 10): PagedList<T> {\r\n return new PagedList<T>([], 0, 1, pageSize);\r\n }\r\n\r\n static create<T>(items: T[], totalCount: number, pageNumber: number, pageSize: number): PagedList<T> {\r\n return new PagedList(items, totalCount, pageNumber, pageSize);\r\n }\r\n}\r\n","import { InjectionToken } from '@angular/core';\r\nimport type { ErrorResponse } from './models/json-api-error.models';\r\n\r\nexport interface ErrorNotificationService {\r\n handleHttpError(errorResponse: ErrorResponse, statusCode: number, requestUrl?: string): void;\r\n handleCoreError(error: Error): void;\r\n}\r\n\r\nexport const ERROR_NOTIFICATION_SERVICE = new InjectionToken<ErrorNotificationService>('ErrorNotificationService');\r\n","import { HttpErrorResponse, HttpInterceptorFn } from '@angular/common/http';\r\nimport { inject } from '@angular/core';\r\nimport { catchError, throwError } from 'rxjs';\r\nimport type { ErrorResponse } from './models/json-api-error.models';\r\nimport { ErrorNotificationService, ERROR_NOTIFICATION_SERVICE } from './error-notification.service.interface';\r\n\r\nexport const httpErrorInterceptor: HttpInterceptorFn = (req, next) => {\r\n // Capture in injection context, before any async operation\r\n const notificationService = inject(ERROR_NOTIFICATION_SERVICE, { optional: true });\r\n\r\n return next(req).pipe(\r\n catchError((error: unknown) => {\r\n // Skip if explicitly marked to skip global error handling\r\n if (req.headers.has('X-Skip-Global-Error-Handler')) {\r\n return throwError(() => error);\r\n }\r\n\r\n if (notificationService) {\r\n if (!(error instanceof HttpErrorResponse)) {\r\n const unknownError: ErrorResponse = {\r\n errors: [{\r\n status: '0',\r\n title: 'Unexpected Error',\r\n detail: error instanceof Error\r\n ? error.message\r\n : 'An unexpected error occurred while processing the request.'\r\n }]\r\n };\r\n notificationService.handleHttpError(unknownError, 0, req.url);\r\n return throwError(() => error);\r\n }\r\n\r\n // Network errors (ERR_CONNECTION_REFUSED, ERR_CONNECTION_TIMED_OUT, etc.)\r\n // have status 0 and error.error may be null/undefined with withFetch()\r\n if (error.status === 0 || !error.error) {\r\n const networkError: ErrorResponse = {\r\n errors: [{\r\n status: '0',\r\n title: 'Connection Error',\r\n detail: 'Could not connect to the server. Please check your connection or try again later.'\r\n }]\r\n };\r\n notificationService.handleHttpError(networkError, 0, req.url);\r\n } else {\r\n try {\r\n // Try to parse as JSON:API error response\r\n const errorResponse = error.error as ErrorResponse;\r\n if (errorResponse.errors && Array.isArray(errorResponse.errors)) {\r\n notificationService.handleHttpError(errorResponse, error.status, req.url);\r\n } else {\r\n // Not a JSON:API response, create generic error\r\n const genericError: ErrorResponse = {\r\n errors: [{\r\n status: error.status.toString(),\r\n title: error.statusText || 'Error',\r\n detail: typeof error.error === 'string'\r\n ? error.error\r\n : error.message || 'An unexpected error occurred'\r\n }]\r\n };\r\n notificationService.handleHttpError(genericError, error.status, req.url);\r\n }\r\n } catch {\r\n const genericError: ErrorResponse = {\r\n errors: [{\r\n status: error.status.toString(),\r\n title: 'Error',\r\n detail: error.message || 'An unexpected error occurred'\r\n }]\r\n };\r\n notificationService.handleHttpError(genericError, error.status, req.url);\r\n }\r\n }\r\n }\r\n\r\n return throwError(() => error);\r\n })\r\n );\r\n};\r\n","import { ErrorHandler, inject, Injectable } from '@angular/core';\r\nimport { HttpErrorResponse } from '@angular/common/http';\r\nimport { ERROR_NOTIFICATION_SERVICE } from './error-notification.service.interface';\r\n\r\n@Injectable()\r\nexport class GlobalErrorHandler extends ErrorHandler {\r\n // Inject in class field to stay within injection context\r\n private readonly notificationService = inject(ERROR_NOTIFICATION_SERVICE, { optional: true });\r\n\r\n override handleError(error: Error | HttpErrorResponse): void {\r\n // HTTP errors are already handled by the interceptor\r\n if (error instanceof HttpErrorResponse) {\r\n super.handleError(error);\r\n return;\r\n }\r\n\r\n // Log to console in all environments\r\n console.error('Unhandled error:', error);\r\n\r\n if (this.notificationService) {\r\n this.notificationService.handleCoreError(error);\r\n }\r\n\r\n // Call parent to ensure default Angular error handling\r\n super.handleError(error);\r\n }\r\n}\r\n","import { EnvironmentProviders, ErrorHandler, makeEnvironmentProviders } from '@angular/core';\r\nimport { GlobalErrorHandler } from './global-error.handler';\r\n\r\nexport function provideErrorHandling(): EnvironmentProviders {\r\n return makeEnvironmentProviders([\r\n { provide: ErrorHandler, useClass: GlobalErrorHandler }\r\n ]);\r\n}\r\n","import type { PatchOperation } from '@eac-arch/shared-kernel';\r\n\r\n// Represents a single JSON Patch operation as defined in RFC 6902.\r\n// Used as the body for HTTP PATCH requests with Content-Type: application/json-patch+json.\r\nexport interface JsonPatchOperation {\r\n readonly op: 'add' | 'remove' | 'replace' | 'move' | 'copy' | 'test';\r\n readonly path: string;\r\n readonly from?: string;\r\n readonly value?: unknown;\r\n}\r\n\r\n// Mirrors the server's UpdatePartialDelta (EAC.SharedKernel.Utils.UpdatePartialDelta).\r\n// Carries the entity ID and a list of field-level operations.\r\nexport interface UpdatePartialDelta {\r\n readonly entityId: string;\r\n readonly operations: readonly UpdatePartialOperation[];\r\n}\r\n\r\n// Mirrors the server's UpdatePartialOperation (EAC.SharedKernel.Utils.UpdatePartial.UpdatePartialOperation).\r\nexport interface UpdatePartialOperation {\r\n readonly op: string;\r\n readonly path: string;\r\n readonly value?: unknown;\r\n}\r\n\r\n// Converts shared-kernel PatchOperation[] to the HTTP transport representation.\r\nexport function toJsonPatchOperations(operations: PatchOperation[]): JsonPatchOperation[] {\r\n return operations.map(({ op, path, value, from }) => ({ op, path, value, from }));\r\n}\r\n","/*\r\n * Public API Surface of eac-arch-infrastructure-http\r\n */\r\n\r\nexport { PagedList } from './lib/pagination';\r\nexport * from './lib/errors';\r\nexport type { JsonPatchOperation, UpdatePartialDelta, UpdatePartialOperation } from './lib/patch';\r\nexport { toJsonPatchOperations } from './lib/patch';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAAA;AACA;MACa,SAAS,CAAA;AACX,IAAA,KAAK;AACL,IAAA,WAAW;AACX,IAAA,UAAU;AACV,IAAA,QAAQ;AACR,IAAA,UAAU;AAEnB,IAAA,IAAI,WAAW,GAAA;AACb,QAAA,OAAO,IAAI,CAAC,WAAW,GAAG,CAAC;IAC7B;AAEA,IAAA,IAAI,OAAO,GAAA;AACT,QAAA,OAAO,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,UAAU;IAC3C;AAEA,IAAA,WAAA,CAAoB,KAAU,EAAE,UAAkB,EAAE,UAAkB,EAAE,QAAgB,EAAA;AACtF,QAAA,IAAI,QAAQ,IAAI,CAAC,EAAE;AACjB,YAAA,MAAM,IAAI,KAA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IAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;2GAAlB,kBAAkB,EAAA,CAAA;;2FAAlB,kBAAkB,EAAA,UAAA,EAAA,CAAA;kBAD9B;;;SCDe,oBAAoB,GAAA;AAClC,IAAA,OAAO,wBAAwB,CAAC;AAC9B,QAAA,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,kBAAkB;AACtD,KAAA,CAAC;AACJ;;ACkBA;AACM,SAAU,qBAAqB,CAAC,UAA4B,EAAA;AAChE,IAAA,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AACnF;;AC5BA;;AAEG;;ACFH;;AAEG;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@eac-arch/infrastructure-http",
|
|
3
|
+
"version": "0.0.0-ci.20260308042601",
|
|
4
|
+
"peerDependencies": {
|
|
5
|
+
"@eac-arch/shared-kernel": "^1.0.0",
|
|
6
|
+
"@angular/common": "^21.1.0",
|
|
7
|
+
"@angular/core": "^21.1.0"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"tslib": "^2.3.0"
|
|
11
|
+
},
|
|
12
|
+
"sideEffects": false,
|
|
13
|
+
"module": "fesm2022/eac-arch-infrastructure-http.mjs",
|
|
14
|
+
"typings": "types/eac-arch-infrastructure-http.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
"./package.json": {
|
|
17
|
+
"default": "./package.json"
|
|
18
|
+
},
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./types/eac-arch-infrastructure-http.d.ts",
|
|
21
|
+
"default": "./fesm2022/eac-arch-infrastructure-http.mjs"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { InjectionToken, EnvironmentProviders } from '@angular/core';
|
|
2
|
+
import { HttpInterceptorFn } from '@angular/common/http';
|
|
3
|
+
import { PatchOperation } from '@eac-arch/shared-kernel';
|
|
4
|
+
|
|
5
|
+
declare class PagedList<T> {
|
|
6
|
+
readonly items: readonly T[];
|
|
7
|
+
readonly currentPage: number;
|
|
8
|
+
readonly totalPages: number;
|
|
9
|
+
readonly pageSize: number;
|
|
10
|
+
readonly totalCount: number;
|
|
11
|
+
get hasPrevious(): boolean;
|
|
12
|
+
get hasNext(): boolean;
|
|
13
|
+
private constructor();
|
|
14
|
+
static empty<T>(pageSize?: number): PagedList<T>;
|
|
15
|
+
static create<T>(items: T[], totalCount: number, pageNumber: number, pageSize: number): PagedList<T>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface ErrorObject {
|
|
19
|
+
id?: string;
|
|
20
|
+
links?: ErrorLinks;
|
|
21
|
+
status: string;
|
|
22
|
+
code?: string;
|
|
23
|
+
title: string;
|
|
24
|
+
detail?: string;
|
|
25
|
+
source?: ErrorSource;
|
|
26
|
+
meta?: Record<string, unknown>;
|
|
27
|
+
}
|
|
28
|
+
interface ErrorLinks {
|
|
29
|
+
about?: string;
|
|
30
|
+
type?: string;
|
|
31
|
+
}
|
|
32
|
+
interface ErrorSource {
|
|
33
|
+
pointer?: string;
|
|
34
|
+
parameter?: string;
|
|
35
|
+
header?: string;
|
|
36
|
+
}
|
|
37
|
+
interface ErrorResponse {
|
|
38
|
+
errors: ErrorObject[];
|
|
39
|
+
meta?: Record<string, unknown>;
|
|
40
|
+
jsonapi?: ApiInfo;
|
|
41
|
+
}
|
|
42
|
+
interface ApiInfo {
|
|
43
|
+
version: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface ErrorNotificationService {
|
|
47
|
+
handleHttpError(errorResponse: ErrorResponse, statusCode: number, requestUrl?: string): void;
|
|
48
|
+
handleCoreError(error: Error): void;
|
|
49
|
+
}
|
|
50
|
+
declare const ERROR_NOTIFICATION_SERVICE: InjectionToken<ErrorNotificationService>;
|
|
51
|
+
|
|
52
|
+
declare const httpErrorInterceptor: HttpInterceptorFn;
|
|
53
|
+
|
|
54
|
+
declare function provideErrorHandling(): EnvironmentProviders;
|
|
55
|
+
|
|
56
|
+
interface JsonPatchOperation {
|
|
57
|
+
readonly op: 'add' | 'remove' | 'replace' | 'move' | 'copy' | 'test';
|
|
58
|
+
readonly path: string;
|
|
59
|
+
readonly from?: string;
|
|
60
|
+
readonly value?: unknown;
|
|
61
|
+
}
|
|
62
|
+
interface UpdatePartialDelta {
|
|
63
|
+
readonly entityId: string;
|
|
64
|
+
readonly operations: readonly UpdatePartialOperation[];
|
|
65
|
+
}
|
|
66
|
+
interface UpdatePartialOperation {
|
|
67
|
+
readonly op: string;
|
|
68
|
+
readonly path: string;
|
|
69
|
+
readonly value?: unknown;
|
|
70
|
+
}
|
|
71
|
+
declare function toJsonPatchOperations(operations: PatchOperation[]): JsonPatchOperation[];
|
|
72
|
+
|
|
73
|
+
export { ERROR_NOTIFICATION_SERVICE, PagedList, httpErrorInterceptor, provideErrorHandling, toJsonPatchOperations };
|
|
74
|
+
export type { ApiInfo, ErrorLinks, ErrorNotificationService, ErrorObject, ErrorResponse, ErrorSource, JsonPatchOperation, UpdatePartialDelta, UpdatePartialOperation };
|