@eac-arch/infrastructure-http 1.0.2 → 1.0.6

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 CHANGED
@@ -1,63 +1,83 @@
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.
1
+ # @eac-arch/infrastructure-http
2
+
3
+ Angular infrastructure library for HTTP transport contracts and cross-cutting error handling.
4
+
5
+ ## Purpose
6
+
7
+ `@eac-arch/infrastructure-http` provides reusable transport primitives aligned with server contracts and ready-to-wire error handling infrastructure.
8
+
9
+ ## Main Capabilities
10
+
11
+ - `PagedList<T>`
12
+ : Client mirror of server paged list metadata and navigation flags.
13
+ - JSON:API error models
14
+ : Typed `ErrorResponse`/`ErrorObject` for API error payloads.
15
+ - `httpErrorInterceptor`
16
+ : Centralized HTTP error normalization and delegation.
17
+ - `GlobalErrorHandler` + `provideErrorHandling()`
18
+ : Captures non-HTTP runtime errors and routes them to a notification service.
19
+ - `ErrorNotificationService` contract
20
+ : Injection-token based bridge so UI layers decide how to display errors.
21
+ - JSON Patch helpers
22
+ : `JsonPatchOperation`, `UpdatePartialDelta`, and conversion from shared-kernel patch operations.
23
+
24
+ ## Public API
25
+
26
+ ```ts
27
+ export { PagedList };
28
+ export * from './errors';
29
+ export type { JsonPatchOperation, UpdatePartialDelta, UpdatePartialOperation };
30
+ export { toJsonPatchOperations };
31
+ ```
32
+
33
+ ## Usage
34
+
35
+ Register global error handler:
36
+
37
+ ```ts
38
+ import { provideErrorHandling } from '@eac-arch/infrastructure-http';
39
+
40
+ providers: [provideErrorHandling()]
41
+ ```
42
+
43
+ Provide notification bridge in UI module:
44
+
45
+ ```ts
46
+ { provide: ERROR_NOTIFICATION_SERVICE, useExisting: MyNotificationService }
47
+ ```
48
+
49
+ ## Dependencies
50
+
51
+ - `@eac-arch/shared-kernel`
52
+ - Angular core/common
53
+ - `tslib`
54
+
55
+ ## Development
56
+
57
+ From `eac-arch-infrastructure-http`:
58
+
59
+ ```bash
60
+ npm install
61
+ npm run build
62
+ npm test
63
+ ```
64
+
65
+
66
+ ## Created By
67
+
68
+ **Erick Arostegui Cunza**
69
+ Enterprise Solutions Architect
70
+
71
+ Professional Profile:
72
+ - LinkedIn: https://www.linkedin.com/in/erick-arostegui-cunza/
73
+
74
+ Articles:
75
+ - Medium: https://medium.com/@scorpius86
76
+
77
+ Channels and Media:
78
+ - Facebook: https://www.facebook.com/Erick.Arostegui.Cunza
79
+ - TikTok: https://www.tiktok.com/@erick_arostegui_cunza
80
+ - Instagram: https://www.instagram.com/erickarosteguicunza/
81
+ - Spotify: https://open.spotify.com/show/2JQxlxcRg7k7cJ1hB52Ge5
82
+
83
+ Created by Erick Arostegui Cunza.
@@ -1,23 +1,154 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Component } from '@angular/core';
3
-
4
- class EacArchInfrastructureHttp {
5
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.5", ngImport: i0, type: EacArchInfrastructureHttp, deps: [], target: i0.ɵɵFactoryTarget.Component });
6
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.1.5", type: EacArchInfrastructureHttp, isStandalone: true, selector: "eac-arch-eac-arch-infrastructure-http", ngImport: i0, template: `
7
- <p>
8
- eac-arch-infrastructure-http works!
9
- </p>
10
- `, isInline: true, styles: [""] });
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 });
11
136
  }
12
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.5", ngImport: i0, type: EacArchInfrastructureHttp, decorators: [{
13
- type: Component,
14
- args: [{ selector: 'eac-arch-eac-arch-infrastructure-http', imports: [], template: `
15
- <p>
16
- eac-arch-infrastructure-http works!
17
- </p>
18
- ` }]
137
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: GlobalErrorHandler, decorators: [{
138
+ type: Injectable
19
139
  }] });
20
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
+
21
152
  /*
22
153
  * Public API Surface of eac-arch-infrastructure-http
23
154
  */
@@ -26,5 +157,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.5", ngImpor
26
157
  * Generated bundle index. Do not edit.
27
158
  */
28
159
 
29
- export { EacArchInfrastructureHttp };
160
+ export { ERROR_NOTIFICATION_SERVICE, PagedList, httpErrorInterceptor, provideErrorHandling, toJsonPatchOperations };
30
161
  //# sourceMappingURL=eac-arch-infrastructure-http.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"eac-arch-infrastructure-http.mjs","sources":["../../../projects/eac-arch-infrastructure-http/src/lib/eac-arch-infrastructure-http.ts","../../../projects/eac-arch-infrastructure-http/src/public-api.ts","../../../projects/eac-arch-infrastructure-http/src/eac-arch-infrastructure-http.ts"],"sourcesContent":["import { Component } from '@angular/core';\r\n\r\n@Component({\r\n selector: 'eac-arch-eac-arch-infrastructure-http',\r\n imports: [],\r\n template: `\r\n <p>\r\n eac-arch-infrastructure-http works!\r\n </p>\r\n `,\r\n styles: ``,\r\n})\r\nexport class EacArchInfrastructureHttp {\r\n\r\n}\r\n","/*\r\n * Public API Surface of eac-arch-infrastructure-http\r\n */\r\n\r\nexport * from './lib/eac-arch-infrastructure-http';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;MAYa,yBAAyB,CAAA;uGAAzB,yBAAyB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAzB,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,yBAAyB,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,uCAAA,EAAA,QAAA,EAAA,EAAA,EAAA,QAAA,EAP1B,CAAA;;;;AAIT,EAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,MAAA,EAAA,CAAA,EAAA,CAAA,EAAA,CAAA;;2FAGU,yBAAyB,EAAA,UAAA,EAAA,CAAA;kBAVrC,SAAS;+BACE,uCAAuC,EAAA,OAAA,EACxC,EAAE,EAAA,QAAA,EACD,CAAA;;;;AAIT,EAAA,CAAA,EAAA;;;ACTH;;AAEG;;ACFH;;AAEG;;;;"}
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).\n// A read-only collection of items with pagination metadata.\nexport class PagedList<T> {\n readonly items: readonly T[];\n readonly currentPage: number;\n readonly totalPages: number;\n readonly pageSize: number;\n readonly totalCount: number;\n\n get hasPrevious(): boolean {\n return this.currentPage > 1;\n }\n\n get hasNext(): boolean {\n return this.currentPage < this.totalPages;\n }\n\n private constructor(items: T[], totalCount: number, pageNumber: number, pageSize: number) {\n if (pageSize <= 0) {\n throw new Error('Page size must be greater than 0');\n }\n if (pageNumber <= 0) {\n throw new Error('Page number must be greater than 0');\n }\n if (totalCount < 0) {\n throw new Error('Total count cannot be negative');\n }\n\n this.totalCount = totalCount;\n this.pageSize = pageSize;\n this.currentPage = pageNumber;\n this.totalPages = Math.ceil(totalCount / pageSize);\n this.items = Object.freeze([...items]);\n }\n\n static empty<T>(pageSize = 10): PagedList<T> {\n return new PagedList<T>([], 0, 1, pageSize);\n }\n\n static create<T>(items: T[], totalCount: number, pageNumber: number, pageSize: number): PagedList<T> {\n return new PagedList(items, totalCount, pageNumber, pageSize);\n }\n}\n","import { InjectionToken } from '@angular/core';\nimport type { ErrorResponse } from './models/json-api-error.models';\n\nexport interface ErrorNotificationService {\n handleHttpError(errorResponse: ErrorResponse, statusCode: number, requestUrl?: string): void;\n handleCoreError(error: Error): void;\n}\n\nexport const ERROR_NOTIFICATION_SERVICE = new InjectionToken<ErrorNotificationService>('ErrorNotificationService');\n","import { HttpErrorResponse, HttpInterceptorFn } from '@angular/common/http';\nimport { inject } from '@angular/core';\nimport { catchError, throwError } from 'rxjs';\nimport type { ErrorResponse } from './models/json-api-error.models';\nimport { ErrorNotificationService, ERROR_NOTIFICATION_SERVICE } from './error-notification.service.interface';\n\nexport const httpErrorInterceptor: HttpInterceptorFn = (req, next) => {\n // Capture in injection context, before any async operation\n const notificationService = inject(ERROR_NOTIFICATION_SERVICE, { optional: true });\n\n return next(req).pipe(\n catchError((error: unknown) => {\n // Skip if explicitly marked to skip global error handling\n if (req.headers.has('X-Skip-Global-Error-Handler')) {\n return throwError(() => error);\n }\n\n if (notificationService) {\n if (!(error instanceof HttpErrorResponse)) {\n const unknownError: ErrorResponse = {\n errors: [{\n status: '0',\n title: 'Unexpected Error',\n detail: error instanceof Error\n ? error.message\n : 'An unexpected error occurred while processing the request.'\n }]\n };\n notificationService.handleHttpError(unknownError, 0, req.url);\n return throwError(() => error);\n }\n\n // Network errors (ERR_CONNECTION_REFUSED, ERR_CONNECTION_TIMED_OUT, etc.)\n // have status 0 and error.error may be null/undefined with withFetch()\n if (error.status === 0 || !error.error) {\n const networkError: ErrorResponse = {\n errors: [{\n status: '0',\n title: 'Connection Error',\n detail: 'Could not connect to the server. Please check your connection or try again later.'\n }]\n };\n notificationService.handleHttpError(networkError, 0, req.url);\n } else {\n try {\n // Try to parse as JSON:API error response\n const errorResponse = error.error as ErrorResponse;\n if (errorResponse.errors && Array.isArray(errorResponse.errors)) {\n notificationService.handleHttpError(errorResponse, error.status, req.url);\n } else {\n // Not a JSON:API response, create generic error\n const genericError: ErrorResponse = {\n errors: [{\n status: error.status.toString(),\n title: error.statusText || 'Error',\n detail: typeof error.error === 'string'\n ? error.error\n : error.message || 'An unexpected error occurred'\n }]\n };\n notificationService.handleHttpError(genericError, error.status, req.url);\n }\n } catch {\n const genericError: ErrorResponse = {\n errors: [{\n status: error.status.toString(),\n title: 'Error',\n detail: error.message || 'An unexpected error occurred'\n }]\n };\n notificationService.handleHttpError(genericError, error.status, req.url);\n }\n }\n }\n\n return throwError(() => error);\n })\n );\n};\n","import { ErrorHandler, inject, Injectable } from '@angular/core';\nimport { HttpErrorResponse } from '@angular/common/http';\nimport { ERROR_NOTIFICATION_SERVICE } from './error-notification.service.interface';\n\n@Injectable()\nexport class GlobalErrorHandler extends ErrorHandler {\n // Inject in class field to stay within injection context\n private readonly notificationService = inject(ERROR_NOTIFICATION_SERVICE, { optional: true });\n\n override handleError(error: Error | HttpErrorResponse): void {\n // HTTP errors are already handled by the interceptor\n if (error instanceof HttpErrorResponse) {\n super.handleError(error);\n return;\n }\n\n // Log to console in all environments\n console.error('Unhandled error:', error);\n\n if (this.notificationService) {\n this.notificationService.handleCoreError(error);\n }\n\n // Call parent to ensure default Angular error handling\n super.handleError(error);\n }\n}\n","import { EnvironmentProviders, ErrorHandler, makeEnvironmentProviders } from '@angular/core';\nimport { GlobalErrorHandler } from './global-error.handler';\n\nexport function provideErrorHandling(): EnvironmentProviders {\n return makeEnvironmentProviders([\n { provide: ErrorHandler, useClass: GlobalErrorHandler }\n ]);\n}\n","import type { PatchOperation } from '@eac-arch/shared-kernel';\n\n// Represents a single JSON Patch operation as defined in RFC 6902.\n// Used as the body for HTTP PATCH requests with Content-Type: application/json-patch+json.\nexport interface JsonPatchOperation {\n readonly op: 'add' | 'remove' | 'replace' | 'move' | 'copy' | 'test';\n readonly path: string;\n readonly from?: string;\n readonly value?: unknown;\n}\n\n// Mirrors the server's UpdatePartialDelta (EAC.SharedKernel.Utils.UpdatePartialDelta).\n// Carries the entity ID and a list of field-level operations.\nexport interface UpdatePartialDelta {\n readonly entityId: string;\n readonly operations: readonly UpdatePartialOperation[];\n}\n\n// Mirrors the server's UpdatePartialOperation (EAC.SharedKernel.Utils.UpdatePartial.UpdatePartialOperation).\nexport interface UpdatePartialOperation {\n readonly op: string;\n readonly path: string;\n readonly value?: unknown;\n}\n\n// Converts shared-kernel PatchOperation[] to the HTTP transport representation.\nexport function toJsonPatchOperations(operations: PatchOperation[]): JsonPatchOperation[] {\n return operations.map(({ op, path, value, from }) => ({ op, path, value, from }));\n}\n","/*\n * Public API Surface of eac-arch-infrastructure-http\n */\n\nexport { PagedList } from './lib/pagination';\nexport * from './lib/errors';\nexport type { JsonPatchOperation, UpdatePartialDelta, UpdatePartialOperation } from './lib/patch';\nexport { toJsonPatchOperations } from './lib/patch';\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,KAAK,CAAC,kCAAkC,CAAC;QACrD;AACA,QAAA,IAAI,UAAU,IAAI,CAAC,EAAE;AACnB,Y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AAkB,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 CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@eac-arch/infrastructure-http",
3
- "version": "1.0.2",
3
+ "version": "1.0.6",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^21.1.0",
6
6
  "@angular/core": "^21.1.0"
7
7
  },
8
8
  "dependencies": {
9
+ "@eac-arch/shared-kernel": "1.0.6",
9
10
  "tslib": "^2.3.0"
10
11
  },
11
12
  "sideEffects": false,
@@ -20,4 +21,4 @@
20
21
  "default": "./fesm2022/eac-arch-infrastructure-http.mjs"
21
22
  }
22
23
  }
23
- }
24
+ }
@@ -1,8 +1,74 @@
1
- import * as i0 from '@angular/core';
1
+ import { InjectionToken, EnvironmentProviders } from '@angular/core';
2
+ import { HttpInterceptorFn } from '@angular/common/http';
3
+ import { PatchOperation } from '@eac-arch/shared-kernel';
2
4
 
3
- declare class EacArchInfrastructureHttp {
4
- static ɵfac: i0.ɵɵFactoryDeclaration<EacArchInfrastructureHttp, never>;
5
- static ɵcmp: i0.ɵɵComponentDeclaration<EacArchInfrastructureHttp, "eac-arch-eac-arch-infrastructure-http", never, {}, {}, never, never, true, never>;
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>;
6
16
  }
7
17
 
8
- export { EacArchInfrastructureHttp };
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 };