@schorts/shared-kernel 2.5.8 → 2.6.0
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/CHANGELOG +12 -0
- package/dist/cjs/json-api/json-api-connector.js +16 -25
- package/dist/cjs/json-api/json-api-connector.js.map +1 -1
- package/dist/esm/json-api/json-api-connector.js +16 -25
- package/dist/esm/json-api/json-api-connector.js.map +1 -1
- package/dist/types/dao/dao.d.ts +1 -0
- package/dist/types/dao/dao.d.ts.map +1 -1
- package/dist/types/json-api/json-api-connector.d.ts +1 -0
- package/dist/types/json-api/json-api-connector.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/dao/dao.ts +1 -0
- package/src/json-api/json-api-connector.ts +17 -29
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.6.0] - 2025-10-14
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Added `countBy` to `DAO`.
|
|
13
|
+
|
|
14
|
+
## [2.5.9] - 2025-10-14
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- `JSONAPIErrors` was never thrown in the `JSONAPIConnector` due to a missing `await`.
|
|
19
|
+
|
|
8
20
|
## [2.5.8] - 2025-10-14
|
|
9
21
|
|
|
10
22
|
### Fixed
|
|
@@ -12,60 +12,51 @@ class JSONAPIConnector {
|
|
|
12
12
|
async findOne(url, criteria, include) {
|
|
13
13
|
try {
|
|
14
14
|
const fullUrl = new url_criteria_builder_1.URLCriteriaBuilder(url, criteria, include).build();
|
|
15
|
-
return this.http.get(fullUrl);
|
|
15
|
+
return await this.http.get(fullUrl);
|
|
16
16
|
}
|
|
17
17
|
catch (error) {
|
|
18
|
-
|
|
19
|
-
throw new exceptions_1.JSONAPIErrors(error.body['errors']);
|
|
20
|
-
}
|
|
21
|
-
throw error;
|
|
18
|
+
this.handleError(error);
|
|
22
19
|
}
|
|
23
20
|
}
|
|
24
21
|
async findMany(url, criteria, include) {
|
|
25
22
|
try {
|
|
26
23
|
const fullUrl = new url_criteria_builder_1.URLCriteriaBuilder(url, criteria, include).build();
|
|
27
|
-
return this.http.get(fullUrl);
|
|
24
|
+
return await this.http.get(fullUrl);
|
|
28
25
|
}
|
|
29
26
|
catch (error) {
|
|
30
|
-
|
|
31
|
-
throw new exceptions_1.JSONAPIErrors(error.body['errors']);
|
|
32
|
-
}
|
|
33
|
-
throw error;
|
|
27
|
+
this.handleError(error);
|
|
34
28
|
}
|
|
35
29
|
}
|
|
36
30
|
async create(url, payload) {
|
|
37
31
|
try {
|
|
38
|
-
return this.http.post(url, { data: payload });
|
|
32
|
+
return await this.http.post(url, { data: payload });
|
|
39
33
|
}
|
|
40
34
|
catch (error) {
|
|
41
|
-
|
|
42
|
-
throw new exceptions_1.JSONAPIErrors(error.body['errors']);
|
|
43
|
-
}
|
|
44
|
-
throw error;
|
|
35
|
+
this.handleError(error);
|
|
45
36
|
}
|
|
46
37
|
}
|
|
47
38
|
async update(url, payload) {
|
|
48
39
|
try {
|
|
49
|
-
return this.http.patch(url, { data: payload });
|
|
40
|
+
return await this.http.patch(url, { data: payload });
|
|
50
41
|
}
|
|
51
42
|
catch (error) {
|
|
52
|
-
|
|
53
|
-
throw new exceptions_1.JSONAPIErrors(error.body['errors']);
|
|
54
|
-
}
|
|
55
|
-
throw error;
|
|
43
|
+
this.handleError(error);
|
|
56
44
|
}
|
|
57
45
|
}
|
|
58
46
|
async delete(url) {
|
|
59
47
|
try {
|
|
60
|
-
return this.http.delete(url);
|
|
48
|
+
return await this.http.delete(url);
|
|
61
49
|
}
|
|
62
50
|
catch (error) {
|
|
63
|
-
|
|
64
|
-
throw new exceptions_1.JSONAPIErrors(error.body['errors']);
|
|
65
|
-
}
|
|
66
|
-
throw error;
|
|
51
|
+
this.handleError(error);
|
|
67
52
|
}
|
|
68
53
|
}
|
|
54
|
+
handleError(error) {
|
|
55
|
+
if (error instanceof http_1.HTTPException && error.body?.errors) {
|
|
56
|
+
throw new exceptions_1.JSONAPIErrors(error.body.errors);
|
|
57
|
+
}
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
69
60
|
}
|
|
70
61
|
exports.JSONAPIConnector = JSONAPIConnector;
|
|
71
62
|
//# sourceMappingURL=json-api-connector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-api-connector.js","sourceRoot":"","sources":["../../../src/json-api/json-api-connector.ts"],"names":[],"mappings":";;;AAAA,kCAAsD;AAGtD,iEAA4D;AAE5D,6CAA6C;AAE7C,MAAa,gBAAgB;IACP;IAApB,YAAoB,IAAkB;QAAlB,SAAI,GAAJ,IAAI,CAAc;IAAG,CAAC;IAE1C,KAAK,CAAC,OAAO,CACX,GAAQ,EACR,QAAmB,EACnB,OAAkB;QAElB,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,IAAI,yCAAkB,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,KAAK,EAAE,CAAC;YAEvE,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"json-api-connector.js","sourceRoot":"","sources":["../../../src/json-api/json-api-connector.ts"],"names":[],"mappings":";;;AAAA,kCAAsD;AAGtD,iEAA4D;AAE5D,6CAA6C;AAE7C,MAAa,gBAAgB;IACP;IAApB,YAAoB,IAAkB;QAAlB,SAAI,GAAJ,IAAI,CAAc;IAAG,CAAC;IAE1C,KAAK,CAAC,OAAO,CACX,GAAQ,EACR,QAAmB,EACnB,OAAkB;QAElB,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,IAAI,yCAAkB,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,CA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CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACrC,CAAC;QAAC,OAAM,KAAK,EAAE,CAAC;YACd,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;IAEO,WAAW,CAAC,KAAc;QAChC,IAAI,KAAK,YAAY,oBAAa,IAAI,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC;YACzD,MAAM,IAAI,0BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC7C,CAAC;QAED,MAAM,KAAK,CAAC;IACd,CAAC;CACF;AA9ED,4CA8EC"}
|
|
@@ -12,60 +12,51 @@ class JSONAPIConnector {
|
|
|
12
12
|
async findOne(url, criteria, include) {
|
|
13
13
|
try {
|
|
14
14
|
const fullUrl = new url_criteria_builder_1.URLCriteriaBuilder(url, criteria, include).build();
|
|
15
|
-
return this.http.get(fullUrl);
|
|
15
|
+
return await this.http.get(fullUrl);
|
|
16
16
|
}
|
|
17
17
|
catch (error) {
|
|
18
|
-
|
|
19
|
-
throw new exceptions_1.JSONAPIErrors(error.body['errors']);
|
|
20
|
-
}
|
|
21
|
-
throw error;
|
|
18
|
+
this.handleError(error);
|
|
22
19
|
}
|
|
23
20
|
}
|
|
24
21
|
async findMany(url, criteria, include) {
|
|
25
22
|
try {
|
|
26
23
|
const fullUrl = new url_criteria_builder_1.URLCriteriaBuilder(url, criteria, include).build();
|
|
27
|
-
return this.http.get(fullUrl);
|
|
24
|
+
return await this.http.get(fullUrl);
|
|
28
25
|
}
|
|
29
26
|
catch (error) {
|
|
30
|
-
|
|
31
|
-
throw new exceptions_1.JSONAPIErrors(error.body['errors']);
|
|
32
|
-
}
|
|
33
|
-
throw error;
|
|
27
|
+
this.handleError(error);
|
|
34
28
|
}
|
|
35
29
|
}
|
|
36
30
|
async create(url, payload) {
|
|
37
31
|
try {
|
|
38
|
-
return this.http.post(url, { data: payload });
|
|
32
|
+
return await this.http.post(url, { data: payload });
|
|
39
33
|
}
|
|
40
34
|
catch (error) {
|
|
41
|
-
|
|
42
|
-
throw new exceptions_1.JSONAPIErrors(error.body['errors']);
|
|
43
|
-
}
|
|
44
|
-
throw error;
|
|
35
|
+
this.handleError(error);
|
|
45
36
|
}
|
|
46
37
|
}
|
|
47
38
|
async update(url, payload) {
|
|
48
39
|
try {
|
|
49
|
-
return this.http.patch(url, { data: payload });
|
|
40
|
+
return await this.http.patch(url, { data: payload });
|
|
50
41
|
}
|
|
51
42
|
catch (error) {
|
|
52
|
-
|
|
53
|
-
throw new exceptions_1.JSONAPIErrors(error.body['errors']);
|
|
54
|
-
}
|
|
55
|
-
throw error;
|
|
43
|
+
this.handleError(error);
|
|
56
44
|
}
|
|
57
45
|
}
|
|
58
46
|
async delete(url) {
|
|
59
47
|
try {
|
|
60
|
-
return this.http.delete(url);
|
|
48
|
+
return await this.http.delete(url);
|
|
61
49
|
}
|
|
62
50
|
catch (error) {
|
|
63
|
-
|
|
64
|
-
throw new exceptions_1.JSONAPIErrors(error.body['errors']);
|
|
65
|
-
}
|
|
66
|
-
throw error;
|
|
51
|
+
this.handleError(error);
|
|
67
52
|
}
|
|
68
53
|
}
|
|
54
|
+
handleError(error) {
|
|
55
|
+
if (error instanceof http_1.HTTPException && error.body?.errors) {
|
|
56
|
+
throw new exceptions_1.JSONAPIErrors(error.body.errors);
|
|
57
|
+
}
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
69
60
|
}
|
|
70
61
|
exports.JSONAPIConnector = JSONAPIConnector;
|
|
71
62
|
//# sourceMappingURL=json-api-connector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-api-connector.js","sourceRoot":"","sources":["../../../src/json-api/json-api-connector.ts"],"names":[],"mappings":";;;AAAA,kCAAsD;AAGtD,iEAA4D;AAE5D,6CAA6C;AAE7C,MAAa,gBAAgB;IACP;IAApB,YAAoB,IAAkB;QAAlB,SAAI,GAAJ,IAAI,CAAc;IAAG,CAAC;IA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,CAAC,MAAM,CACV,GAAQ,EACR,OAIC;QAED,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;QACtD,CAAC;QAAC,OAAM,KAAK,EAAE,CAAC;YACd,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;IAED,KAAK,CAAC,MAAM,CACV,GAAQ,EACR,OAIC;QAED,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;QACvD,CAAC;QAAC,OAAM,KAAK,EAAE,CAAC;YACd,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;IAED,KAAK,CAAC,MAAM,CACV,GAAQ;QAER,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACrC,CAAC;QAAC,OAAM,KAAK,EAAE,CAAC;YACd,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;IAEO,WAAW,CAAC,KAAc;QAChC,IAAI,KAAK,YAAY,oBAAa,IAAI,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC;YACzD,MAAM,IAAI,0BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC7C,CAAC;QAED,MAAM,KAAK,CAAC;IACd,CAAC;CACF;AA9ED,4CA8EC"}
|
package/dist/types/dao/dao.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export interface DAO<Model extends BaseModel, Entity extends BaseEntity<ValueObj
|
|
|
8
8
|
findByID(id: Entity["id"]["value"]): Promise<Entity | null>;
|
|
9
9
|
findOneBy(criteria: Criteria): Promise<Entity | null>;
|
|
10
10
|
search(criteria: Criteria): Promise<Entity[]>;
|
|
11
|
+
countBy(criteria: Criteria): Promise<number>;
|
|
11
12
|
create(entity: Entity, uow?: UnitOfWork): Promise<Entity>;
|
|
12
13
|
update(entity: Entity, uow?: UnitOfWork): Promise<Entity>;
|
|
13
14
|
delete(entity: Entity, uow?: UnitOfWork): Promise<Entity>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dao.d.ts","sourceRoot":"","sources":["../../../src/dao/dao.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,MAAM,WAAW,GAAG,CAAC,KAAK,SAAS,SAAS,EAAE,MAAM,SAAS,UAAU,CAAC,WAAW,EAAE,KAAK,CAAC;IACzF,MAAM,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC5B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC5D,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACtD,MAAM,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC9C,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC1D,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAA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AAE,GAAG,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC3D"}
|
|
@@ -18,5 +18,6 @@ export declare class JSONAPIConnector {
|
|
|
18
18
|
attributes: Omit<Partial<EntityAttributes>, "id">;
|
|
19
19
|
}): Promise<JSONAPISingle<EntityAttributes>>;
|
|
20
20
|
delete<EntityAttributes>(url: URL): Promise<JSONAPISingle<EntityAttributes>>;
|
|
21
|
+
private handleError;
|
|
21
22
|
}
|
|
22
23
|
//# sourceMappingURL=json-api-connector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-api-connector.d.ts","sourceRoot":"","sources":["../../../src/json-api/json-api-connector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAiB,MAAM,SAAS,CAAC;AACtD,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;AAGvC,qBAAa,gBAAgB;IACf,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,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;
|
|
1
|
+
{"version":3,"file":"json-api-connector.d.ts","sourceRoot":"","sources":["../../../src/json-api/json-api-connector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAiB,MAAM,SAAS,CAAC;AACtD,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;AAGvC,qBAAa,gBAAgB;IACf,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,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;IAUrC,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;IAUnC,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;IAQrC,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;IAQrC,MAAM,CAAC,gBAAgB,EAC3B,GAAG,EAAE,GAAG,GACP,OAAO,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;IAQ3C,OAAO,CAAC,WAAW;CAOpB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schorts/shared-kernel",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
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",
|
package/src/dao/dao.ts
CHANGED
|
@@ -9,6 +9,7 @@ export interface DAO<Model extends BaseModel, Entity extends BaseEntity<ValueObj
|
|
|
9
9
|
findByID(id: Entity["id"]["value"]): Promise<Entity | null>;
|
|
10
10
|
findOneBy(criteria: Criteria): Promise<Entity | null>;
|
|
11
11
|
search(criteria: Criteria): Promise<Entity[]>;
|
|
12
|
+
countBy(criteria: Criteria): Promise<number>;
|
|
12
13
|
create(entity: Entity, uow?: UnitOfWork): Promise<Entity>;
|
|
13
14
|
update(entity: Entity, uow?: UnitOfWork): Promise<Entity>;
|
|
14
15
|
delete(entity: Entity, uow?: UnitOfWork): Promise<Entity>;
|
|
@@ -16,13 +16,9 @@ export class JSONAPIConnector {
|
|
|
16
16
|
try {
|
|
17
17
|
const fullUrl = new URLCriteriaBuilder(url, criteria, include).build();
|
|
18
18
|
|
|
19
|
-
return this.http.get(fullUrl);
|
|
19
|
+
return await this.http.get(fullUrl);
|
|
20
20
|
} catch(error) {
|
|
21
|
-
|
|
22
|
-
throw new JSONAPIErrors(error.body['errors']);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
throw error;
|
|
21
|
+
this.handleError(error);
|
|
26
22
|
}
|
|
27
23
|
}
|
|
28
24
|
|
|
@@ -34,13 +30,9 @@ export class JSONAPIConnector {
|
|
|
34
30
|
try {
|
|
35
31
|
const fullUrl = new URLCriteriaBuilder(url, criteria, include).build();
|
|
36
32
|
|
|
37
|
-
return this.http.get(fullUrl);
|
|
33
|
+
return await this.http.get(fullUrl);
|
|
38
34
|
} catch(error) {
|
|
39
|
-
|
|
40
|
-
throw new JSONAPIErrors(error.body['errors']);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
throw error;
|
|
35
|
+
this.handleError(error);
|
|
44
36
|
}
|
|
45
37
|
}
|
|
46
38
|
|
|
@@ -53,13 +45,9 @@ export class JSONAPIConnector {
|
|
|
53
45
|
}
|
|
54
46
|
): Promise<JSONAPISingle<EntityAttributes>> {
|
|
55
47
|
try {
|
|
56
|
-
return this.http.post(url, { data: payload });
|
|
48
|
+
return await this.http.post(url, { data: payload });
|
|
57
49
|
} catch(error) {
|
|
58
|
-
|
|
59
|
-
throw new JSONAPIErrors(error.body['errors']);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
throw error;
|
|
50
|
+
this.handleError(error);
|
|
63
51
|
}
|
|
64
52
|
}
|
|
65
53
|
|
|
@@ -72,13 +60,9 @@ export class JSONAPIConnector {
|
|
|
72
60
|
}
|
|
73
61
|
): Promise<JSONAPISingle<EntityAttributes>> {
|
|
74
62
|
try {
|
|
75
|
-
return this.http.patch(url, { data: payload });
|
|
63
|
+
return await this.http.patch(url, { data: payload });
|
|
76
64
|
} catch(error) {
|
|
77
|
-
|
|
78
|
-
throw new JSONAPIErrors(error.body['errors']);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
throw error;
|
|
65
|
+
this.handleError(error);
|
|
82
66
|
}
|
|
83
67
|
}
|
|
84
68
|
|
|
@@ -86,13 +70,17 @@ export class JSONAPIConnector {
|
|
|
86
70
|
url: URL
|
|
87
71
|
): Promise<JSONAPISingle<EntityAttributes>> {
|
|
88
72
|
try {
|
|
89
|
-
return this.http.delete(url);
|
|
73
|
+
return await this.http.delete(url);
|
|
90
74
|
} catch(error) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
75
|
+
this.handleError(error);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
94
78
|
|
|
95
|
-
|
|
79
|
+
private handleError(error: unknown): never {
|
|
80
|
+
if (error instanceof HTTPException && error.body?.errors) {
|
|
81
|
+
throw new JSONAPIErrors(error.body.errors);
|
|
96
82
|
}
|
|
83
|
+
|
|
84
|
+
throw error;
|
|
97
85
|
}
|
|
98
86
|
}
|