@schorts/shared-kernel 2.3.4 → 2.4.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.
Files changed (30) hide show
  1. package/CHANGELOG +12 -0
  2. package/dist/cjs/json-api/exceptions/index.js +6 -0
  3. package/dist/cjs/json-api/exceptions/index.js.map +1 -0
  4. package/dist/cjs/json-api/exceptions/json-api-errors.js +12 -0
  5. package/dist/cjs/json-api/exceptions/json-api-errors.js.map +1 -0
  6. package/dist/cjs/json-api/index.js +15 -0
  7. package/dist/cjs/json-api/index.js.map +1 -1
  8. package/dist/cjs/json-api/json-api-connector.js +49 -7
  9. package/dist/cjs/json-api/json-api-connector.js.map +1 -1
  10. package/dist/esm/json-api/exceptions/index.js +6 -0
  11. package/dist/esm/json-api/exceptions/index.js.map +1 -0
  12. package/dist/esm/json-api/exceptions/json-api-errors.js +12 -0
  13. package/dist/esm/json-api/exceptions/json-api-errors.js.map +1 -0
  14. package/dist/esm/json-api/index.js +15 -0
  15. package/dist/esm/json-api/index.js.map +1 -1
  16. package/dist/esm/json-api/json-api-connector.js +49 -7
  17. package/dist/esm/json-api/json-api-connector.js.map +1 -1
  18. package/dist/types/json-api/exceptions/index.d.ts +2 -0
  19. package/dist/types/json-api/exceptions/index.d.ts.map +1 -0
  20. package/dist/types/json-api/exceptions/json-api-errors.d.ts +19 -0
  21. package/dist/types/json-api/exceptions/json-api-errors.d.ts.map +1 -0
  22. package/dist/types/json-api/index.d.ts +1 -0
  23. package/dist/types/json-api/index.d.ts.map +1 -1
  24. package/dist/types/json-api/json-api-connector.d.ts +1 -1
  25. package/dist/types/json-api/json-api-connector.d.ts.map +1 -1
  26. package/package.json +1 -1
  27. package/src/json-api/exceptions/index.ts +1 -0
  28. package/src/json-api/exceptions/json-api-errors.ts +17 -0
  29. package/src/json-api/index.ts +1 -0
  30. package/src/json-api/json-api-connector.ts +49 -8
package/CHANGELOG CHANGED
@@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [2.4.1] - 2025-10-12
9
+
10
+ ### Fixed
11
+
12
+ - Added missed export for `JSONAPIErrors`.
13
+
14
+ ## [2.4.0] - 2025-10-11
15
+
16
+ ### Changed
17
+
18
+ - Now the `JSONAPIConnector` throws a `JSONAPIErrors` exception instead of a generic `HTTPException`.
19
+
8
20
  ## [2.3.4] - 2025-10-11
9
21
 
10
22
  ### Changed
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JSONAPIErrors = void 0;
4
+ var json_api_errors_1 = require("./json-api-errors");
5
+ Object.defineProperty(exports, "JSONAPIErrors", { enumerable: true, get: function () { return json_api_errors_1.JSONAPIErrors; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/json-api/exceptions/index.ts"],"names":[],"mappings":";;;AAAA,qDAAkD;AAAzC,gHAAA,aAAa,OAAA"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JSONAPIErrors = void 0;
4
+ class JSONAPIErrors extends Error {
5
+ errors;
6
+ constructor(errors) {
7
+ super();
8
+ this.errors = errors;
9
+ }
10
+ }
11
+ exports.JSONAPIErrors = JSONAPIErrors;
12
+ //# sourceMappingURL=json-api-errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-api-errors.js","sourceRoot":"","sources":["../../../../src/json-api/exceptions/json-api-errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,aAAc,SAAQ,KAAK;IAC7B,MAAM,CAQZ;IAEH,YAAY,MAA+B;QACzC,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAhBD,sCAgBC"}
@@ -1,8 +1,23 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
17
  exports.JSONAPIConnector = exports.URLCriteriaBuilder = void 0;
4
18
  var url_criteria_builder_1 = require("./url-criteria-builder");
5
19
  Object.defineProperty(exports, "URLCriteriaBuilder", { enumerable: true, get: function () { return url_criteria_builder_1.URLCriteriaBuilder; } });
6
20
  var json_api_connector_1 = require("./json-api-connector");
7
21
  Object.defineProperty(exports, "JSONAPIConnector", { enumerable: true, get: function () { return json_api_connector_1.JSONAPIConnector; } });
22
+ __exportStar(require("./exceptions"), exports);
8
23
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/json-api/index.ts"],"names":[],"mappings":";;;AAEA,+DAA4D;AAAnD,0HAAA,kBAAkB,OAAA;AAC3B,2DAAwD;AAA/C,sHAAA,gBAAgB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/json-api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAEA,+DAA4D;AAAnD,0HAAA,kBAAkB,OAAA;AAC3B,2DAAwD;AAA/C,sHAAA,gBAAgB,OAAA;AACzB,+CAA6B"}
@@ -1,28 +1,70 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.JSONAPIConnector = void 0;
4
+ const http_1 = require("../http");
4
5
  const url_criteria_builder_1 = require("./url-criteria-builder");
6
+ const exceptions_1 = require("./exceptions");
5
7
  class JSONAPIConnector {
6
8
  http;
7
9
  constructor(http) {
8
10
  this.http = http;
9
11
  }
10
12
  async findOne(url, criteria, include) {
11
- const fullUrl = new url_criteria_builder_1.URLCriteriaBuilder(url, criteria, include).build();
12
- return this.http.get(fullUrl);
13
+ try {
14
+ const fullUrl = new url_criteria_builder_1.URLCriteriaBuilder(url, criteria, include).build();
15
+ return this.http.get(fullUrl);
16
+ }
17
+ catch (error) {
18
+ if (error instanceof http_1.HTTPException && error.body) {
19
+ throw new exceptions_1.JSONAPIErrors(error.body['errors']);
20
+ }
21
+ throw error;
22
+ }
13
23
  }
14
24
  async findMany(url, criteria, include) {
15
- const fullUrl = new url_criteria_builder_1.URLCriteriaBuilder(url, criteria, include).build();
16
- return this.http.get(fullUrl);
25
+ try {
26
+ const fullUrl = new url_criteria_builder_1.URLCriteriaBuilder(url, criteria, include).build();
27
+ return this.http.get(fullUrl);
28
+ }
29
+ catch (error) {
30
+ if (error instanceof http_1.HTTPException && error.body) {
31
+ throw new exceptions_1.JSONAPIErrors(error.body['errors']);
32
+ }
33
+ throw error;
34
+ }
17
35
  }
18
36
  async create(url, payload) {
19
- return this.http.post(url, { data: payload });
37
+ try {
38
+ return this.http.post(url, { data: payload });
39
+ }
40
+ catch (error) {
41
+ if (error instanceof http_1.HTTPException && error.body) {
42
+ throw new exceptions_1.JSONAPIErrors(error.body['errors']);
43
+ }
44
+ throw error;
45
+ }
20
46
  }
21
47
  async update(url, payload) {
22
- return this.http.patch(url, { data: payload });
48
+ try {
49
+ return this.http.patch(url, { data: payload });
50
+ }
51
+ catch (error) {
52
+ if (error instanceof http_1.HTTPException && error.body) {
53
+ throw new exceptions_1.JSONAPIErrors(error.body['errors']);
54
+ }
55
+ throw error;
56
+ }
23
57
  }
24
58
  async delete(url) {
25
- return this.http.delete(url);
59
+ try {
60
+ return this.http.delete(url);
61
+ }
62
+ catch (error) {
63
+ if (error instanceof http_1.HTTPException && error.body) {
64
+ throw new exceptions_1.JSONAPIErrors(error.body['errors']);
65
+ }
66
+ throw error;
67
+ }
26
68
  }
27
69
  }
28
70
  exports.JSONAPIConnector = JSONAPIConnector;
@@ -1 +1 @@
1
- {"version":3,"file":"json-api-connector.js","sourceRoot":"","sources":["../../../src/json-api/json-api-connector.ts"],"names":[],"mappings":";;;AAGA,iEAA4D;AAG5D,MAAa,gBAAgB;IACP;IAApB,YAAoB,IAAkB;QAAlB,SAAI,GAAJ,IAAI,CAAc;IAAG,CAAC;IAE1C,KAAK,CAAC,OAAO,CACX,GAAQ,EACR,QAAmB,EACnB,OAAkB;QAElB,MAAM,OAAO,GAAG,IAAI,yCAAkB,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,KAAK,EAAE,CAAC;QAEvE,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,QAAQ,CACZ,GAAQ,EACR,QAAmB,EACnB,OAAkB;QAElB,MAAM,OAAO,GAAG,IAAI,yCAAkB,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,KAAK,EAAE,CAAC;QAEvE,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,MAAM,CACV,GAAQ,EACR,OAGC;QAED,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,MAAM,CACV,GAAQ,EACR,OAIC;QAED,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,OAAO,EAA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K,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;YAChD,CAAC;YAED,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF;AAzFD,4CAyFC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JSONAPIErrors = void 0;
4
+ var json_api_errors_1 = require("./json-api-errors");
5
+ Object.defineProperty(exports, "JSONAPIErrors", { enumerable: true, get: function () { return json_api_errors_1.JSONAPIErrors; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/json-api/exceptions/index.ts"],"names":[],"mappings":";;;AAAA,qDAAkD;AAAzC,gHAAA,aAAa,OAAA"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JSONAPIErrors = void 0;
4
+ class JSONAPIErrors extends Error {
5
+ errors;
6
+ constructor(errors) {
7
+ super();
8
+ this.errors = errors;
9
+ }
10
+ }
11
+ exports.JSONAPIErrors = JSONAPIErrors;
12
+ //# sourceMappingURL=json-api-errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-api-errors.js","sourceRoot":"","sources":["../../../../src/json-api/exceptions/json-api-errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,aAAc,SAAQ,KAAK;IAC7B,MAAM,CAQZ;IAEH,YAAY,MAA+B;QACzC,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAhBD,sCAgBC"}
@@ -1,8 +1,23 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
17
  exports.JSONAPIConnector = exports.URLCriteriaBuilder = void 0;
4
18
  var url_criteria_builder_1 = require("./url-criteria-builder");
5
19
  Object.defineProperty(exports, "URLCriteriaBuilder", { enumerable: true, get: function () { return url_criteria_builder_1.URLCriteriaBuilder; } });
6
20
  var json_api_connector_1 = require("./json-api-connector");
7
21
  Object.defineProperty(exports, "JSONAPIConnector", { enumerable: true, get: function () { return json_api_connector_1.JSONAPIConnector; } });
22
+ __exportStar(require("./exceptions"), exports);
8
23
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/json-api/index.ts"],"names":[],"mappings":";;;AAEA,+DAA4D;AAAnD,0HAAA,kBAAkB,OAAA;AAC3B,2DAAwD;AAA/C,sHAAA,gBAAgB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/json-api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAEA,+DAA4D;AAAnD,0HAAA,kBAAkB,OAAA;AAC3B,2DAAwD;AAA/C,sHAAA,gBAAgB,OAAA;AACzB,+CAA6B"}
@@ -1,28 +1,70 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.JSONAPIConnector = void 0;
4
+ const http_1 = require("../http");
4
5
  const url_criteria_builder_1 = require("./url-criteria-builder");
6
+ const exceptions_1 = require("./exceptions");
5
7
  class JSONAPIConnector {
6
8
  http;
7
9
  constructor(http) {
8
10
  this.http = http;
9
11
  }
10
12
  async findOne(url, criteria, include) {
11
- const fullUrl = new url_criteria_builder_1.URLCriteriaBuilder(url, criteria, include).build();
12
- return this.http.get(fullUrl);
13
+ try {
14
+ const fullUrl = new url_criteria_builder_1.URLCriteriaBuilder(url, criteria, include).build();
15
+ return this.http.get(fullUrl);
16
+ }
17
+ catch (error) {
18
+ if (error instanceof http_1.HTTPException && error.body) {
19
+ throw new exceptions_1.JSONAPIErrors(error.body['errors']);
20
+ }
21
+ throw error;
22
+ }
13
23
  }
14
24
  async findMany(url, criteria, include) {
15
- const fullUrl = new url_criteria_builder_1.URLCriteriaBuilder(url, criteria, include).build();
16
- return this.http.get(fullUrl);
25
+ try {
26
+ const fullUrl = new url_criteria_builder_1.URLCriteriaBuilder(url, criteria, include).build();
27
+ return this.http.get(fullUrl);
28
+ }
29
+ catch (error) {
30
+ if (error instanceof http_1.HTTPException && error.body) {
31
+ throw new exceptions_1.JSONAPIErrors(error.body['errors']);
32
+ }
33
+ throw error;
34
+ }
17
35
  }
18
36
  async create(url, payload) {
19
- return this.http.post(url, { data: payload });
37
+ try {
38
+ return this.http.post(url, { data: payload });
39
+ }
40
+ catch (error) {
41
+ if (error instanceof http_1.HTTPException && error.body) {
42
+ throw new exceptions_1.JSONAPIErrors(error.body['errors']);
43
+ }
44
+ throw error;
45
+ }
20
46
  }
21
47
  async update(url, payload) {
22
- return this.http.patch(url, { data: payload });
48
+ try {
49
+ return this.http.patch(url, { data: payload });
50
+ }
51
+ catch (error) {
52
+ if (error instanceof http_1.HTTPException && error.body) {
53
+ throw new exceptions_1.JSONAPIErrors(error.body['errors']);
54
+ }
55
+ throw error;
56
+ }
23
57
  }
24
58
  async delete(url) {
25
- return this.http.delete(url);
59
+ try {
60
+ return this.http.delete(url);
61
+ }
62
+ catch (error) {
63
+ if (error instanceof http_1.HTTPException && error.body) {
64
+ throw new exceptions_1.JSONAPIErrors(error.body['errors']);
65
+ }
66
+ throw error;
67
+ }
26
68
  }
27
69
  }
28
70
  exports.JSONAPIConnector = JSONAPIConnector;
@@ -1 +1 @@
1
- {"version":3,"file":"json-api-connector.js","sourceRoot":"","sources":["../../../src/json-api/json-api-connector.ts"],"names":[],"mappings":";;;AAGA,iEAA4D;AAG5D,MAAa,gBAAgB;IACP;IAApB,YAAoB,IAAkB;QAAlB,SAAI,GAAJ,IAAI,CAAc;IAAG,CAAC;IAE1C,KAAK,CAAC,OAAO,CACX,GAAQ,EACR,QAAmB,EACnB,OAAkB;QAElB,MAAM,OAAO,GAAG,IAAI,yCAAkB,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,KAAK,EAAE,CAAC;QAEvE,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,QAAQ,CACZ,GAAQ,EACR,QAAmB,EACnB,OAAkB;QAElB,MAAM,OAAO,GAAG,IAAI,yCAAkB,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,KAAK,EAAE,CAAC;QAEvE,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,MAAM,CACV,GAAQ,EACR,OAGC;QAED,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,MAAM,CACV,GAAQ,EACR,OAIC;QAED,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IACjD,CAAC;IAED,KAAK,CAAC,MAAM,CACV,GAAQ;QAER,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;CACF;AAjDD,4CAiDC"}
1
+ {"version":3,"file":"json-api-connector.js","sourceRoot":"","sources":["../../../src/json-api/json-api-connector.ts"],"names":[],"m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"index.d.ts","sourceRoot":"","sources":["../../../../src/json-api/exceptions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,19 @@
1
+ export declare class JSONAPIErrors extends Error {
2
+ readonly errors: Array<{
3
+ id?: string;
4
+ status: string;
5
+ code: string;
6
+ title: string;
7
+ detail: string;
8
+ source?: {
9
+ pointer: string;
10
+ } | {
11
+ parameter: string;
12
+ } | {
13
+ header: string;
14
+ };
15
+ meta?: Record<string, any>;
16
+ }>;
17
+ constructor(errors: JSONAPIErrors["errors"]);
18
+ }
19
+ //# sourceMappingURL=json-api-errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-api-errors.d.ts","sourceRoot":"","sources":["../../../../src/json-api/exceptions/json-api-errors.ts"],"names":[],"mappings":"AAAA,qBAAa,aAAc,SAAQ,KAAK;IACtC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC;QACrB,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE;YAAE,OAAO,EAAE,MAAM,CAAA;SAAE,GAAG;YAAE,SAAS,EAAE,MAAM,CAAA;SAAE,GAAG;YAAE,MAAM,EAAE,MAAM,CAAA;SAAE,CAAC;QAC1E,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAC5B,CAAC,CAAC;gBAES,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC;CAK5C"}
@@ -2,4 +2,5 @@ export type { JSONAPISingle } from "./json-api-single";
2
2
  export type { JSONAPIList } from "./json-api-list";
3
3
  export { URLCriteriaBuilder } from "./url-criteria-builder";
4
4
  export { JSONAPIConnector } from "./json-api-connector";
5
+ export * from "./exceptions";
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/json-api/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/json-api/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,cAAc,cAAc,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { HTTPProvider } from "../http";
1
+ import { HTTPProvider } from "../http";
2
2
  import type { JSONAPIList } from "./json-api-list";
3
3
  import type { JSONAPISingle } from "./json-api-single";
4
4
  import { Criteria } from "../criteria";
@@ -1 +1 @@
1
- {"version":3,"file":"json-api-connector.d.ts","sourceRoot":"","sources":["../../../src/json-api/json-api-connector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,qBAAa,gBAAgB;IACf,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,YAAY;IAEhC,OAAO,CAAC,gBAAgB,EAC5B,GAAG,EAAE,GAAG,EACR,QAAQ,CAAC,EAAE,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AAE,YAAY;IAEhC,OAAO,CAAC,gBAAgB,EAC5B,GAAG,EAAE,GAAG,EACR,QAAQ,CAAC,EAAE,QAAQ,EACnB,OAAO,CAAC,EAAE,MAAM,EAAE,GACjB,OAAO,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;IAcrC,QAAQ,CAAC,gBAAgB,EAC7B,GAAG,EAAE,GAAG,EACR,QAAQ,CAAC,EAAE,QAAQ,EACnB,OAAO,CAAC,EAAE,MAAM,EAAE,GACjB,OAAO,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;IAcnC,MAAM,CAAC,gBAAgB,EAC3B,GAAG,EAAE,GAAG,EACR,OAAO,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,IAAI,CAAC,CAAC;KACnD,GACA,OAAO,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;IAYrC,MAAM,CAAC,gBAAgB,EAC3B,GAAG,EAAE,GAAG,EACR,OAAO,EAAE;QACP,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,IAAI,CAAC,CAAC;KACnD,GACA,OAAO,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;IAYrC,MAAM,CAAC,gBAAgB,EAC3B,GAAG,EAAE,GAAG,GACP,OAAO,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;CAW5C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schorts/shared-kernel",
3
- "version": "2.3.4",
3
+ "version": "2.4.1",
4
4
  "description": "A modular, type-safe foundation for building expressive, maintainable applications. This package provides core abstractions for domain modeling, HTTP integration, authentication, state management, and more — designed to be framework-agnostic and highly extensible.",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -0,0 +1 @@
1
+ export { JSONAPIErrors } from "./json-api-errors";
@@ -0,0 +1,17 @@
1
+ export class JSONAPIErrors extends Error {
2
+ readonly errors: Array<{
3
+ id?: string;
4
+ status: string;
5
+ code: string;
6
+ title: string;
7
+ detail: string;
8
+ source?: { pointer: string } | { parameter: string } | { header: string };
9
+ meta?: Record<string, any>;
10
+ }>;
11
+
12
+ constructor(errors: JSONAPIErrors["errors"]) {
13
+ super();
14
+
15
+ this.errors = errors;
16
+ }
17
+ }
@@ -2,3 +2,4 @@ export type { JSONAPISingle } from "./json-api-single";
2
2
  export type { JSONAPIList } from "./json-api-list";
3
3
  export { URLCriteriaBuilder } from "./url-criteria-builder";
4
4
  export { JSONAPIConnector } from "./json-api-connector";
5
+ export * from "./exceptions";
@@ -1,8 +1,9 @@
1
- import type { HTTPProvider } from "../http";
1
+ import { HTTPProvider, HTTPException } from "../http";
2
2
  import type { JSONAPIList } from "./json-api-list";
3
3
  import type { JSONAPISingle } from "./json-api-single";
4
4
  import { URLCriteriaBuilder } from "./url-criteria-builder";
5
5
  import { Criteria } from "../criteria";
6
+ import { JSONAPIErrors } from "./exceptions";
6
7
 
7
8
  export class JSONAPIConnector {
8
9
  constructor(private http: HTTPProvider) {}
@@ -12,9 +13,17 @@ export class JSONAPIConnector {
12
13
  criteria?: Criteria,
13
14
  include?: string[]
14
15
  ): Promise<JSONAPISingle<EntityAttributes>> {
15
- const fullUrl = new URLCriteriaBuilder(url, criteria, include).build();
16
+ try {
17
+ const fullUrl = new URLCriteriaBuilder(url, criteria, include).build();
16
18
 
17
- return this.http.get(fullUrl);
19
+ return this.http.get(fullUrl);
20
+ } catch(error) {
21
+ if (error instanceof HTTPException && error.body) {
22
+ throw new JSONAPIErrors(error.body['errors']);
23
+ }
24
+
25
+ throw error;
26
+ }
18
27
  }
19
28
 
20
29
  async findMany<EntityAttributes>(
@@ -22,9 +31,17 @@ export class JSONAPIConnector {
22
31
  criteria?: Criteria,
23
32
  include?: string[]
24
33
  ): Promise<JSONAPIList<EntityAttributes>> {
25
- const fullUrl = new URLCriteriaBuilder(url, criteria, include).build();
34
+ try {
35
+ const fullUrl = new URLCriteriaBuilder(url, criteria, include).build();
36
+
37
+ return this.http.get(fullUrl);
38
+ } catch(error) {
39
+ if (error instanceof HTTPException && error.body) {
40
+ throw new JSONAPIErrors(error.body['errors']);
41
+ }
26
42
 
27
- return this.http.get(fullUrl);
43
+ throw error;
44
+ }
28
45
  }
29
46
 
30
47
  async create<EntityAttributes>(
@@ -34,7 +51,15 @@ export class JSONAPIConnector {
34
51
  attributes: Omit<Partial<EntityAttributes>, "id">;
35
52
  }
36
53
  ): Promise<JSONAPISingle<EntityAttributes>> {
37
- return this.http.post(url, { data: payload });
54
+ try {
55
+ return this.http.post(url, { data: payload });
56
+ } catch(error) {
57
+ if (error instanceof HTTPException && error.body) {
58
+ throw new JSONAPIErrors(error.body['errors']);
59
+ }
60
+
61
+ throw error;
62
+ }
38
63
  }
39
64
 
40
65
  async update<EntityAttributes>(
@@ -45,12 +70,28 @@ export class JSONAPIConnector {
45
70
  attributes: Omit<Partial<EntityAttributes>, "id">;
46
71
  }
47
72
  ): Promise<JSONAPISingle<EntityAttributes>> {
48
- return this.http.patch(url, { data: payload });
73
+ try {
74
+ return this.http.patch(url, { data: payload });
75
+ } catch(error) {
76
+ if (error instanceof HTTPException && error.body) {
77
+ throw new JSONAPIErrors(error.body['errors']);
78
+ }
79
+
80
+ throw error;
81
+ }
49
82
  }
50
83
 
51
84
  async delete<EntityAttributes>(
52
85
  url: URL
53
86
  ): Promise<JSONAPISingle<EntityAttributes>> {
54
- return this.http.delete(url);
87
+ try {
88
+ return this.http.delete(url);
89
+ } catch(error) {
90
+ if (error instanceof HTTPException && error.body) {
91
+ throw new JSONAPIErrors(error.body['errors']);
92
+ }
93
+
94
+ throw error;
95
+ }
55
96
  }
56
97
  }