@monorise/core 0.1.11 → 1.0.0-dev.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/dist/controllers/entity/create-entity.controller.d.ts +1 -2
- package/dist/controllers/entity/create-entity.controller.d.ts.map +1 -1
- package/dist/controllers/entity/create-entity.controller.js +20 -11
- package/dist/controllers/entity/create-entity.controller.js.map +1 -1
- package/dist/controllers/entity/delete-entity.controller.d.ts +1 -2
- package/dist/controllers/entity/delete-entity.controller.d.ts.map +1 -1
- package/dist/controllers/entity/delete-entity.controller.js +8 -6
- package/dist/controllers/entity/delete-entity.controller.js.map +1 -1
- package/dist/controllers/entity/get-entity-by-unique-field-value.controller.d.ts +1 -2
- package/dist/controllers/entity/get-entity-by-unique-field-value.controller.d.ts.map +1 -1
- package/dist/controllers/entity/get-entity-by-unique-field-value.controller.js +7 -5
- package/dist/controllers/entity/get-entity-by-unique-field-value.controller.js.map +1 -1
- package/dist/controllers/entity/get-entity.controller.d.ts +1 -2
- package/dist/controllers/entity/get-entity.controller.d.ts.map +1 -1
- package/dist/controllers/entity/get-entity.controller.js +8 -5
- package/dist/controllers/entity/get-entity.controller.js.map +1 -1
- package/dist/controllers/entity/list-entities.controller.d.ts +1 -2
- package/dist/controllers/entity/list-entities.controller.d.ts.map +1 -1
- package/dist/controllers/entity/list-entities.controller.js +14 -10
- package/dist/controllers/entity/list-entities.controller.js.map +1 -1
- package/dist/controllers/entity/update-entity.controller.d.ts +1 -2
- package/dist/controllers/entity/update-entity.controller.d.ts.map +1 -1
- package/dist/controllers/entity/update-entity.controller.js +17 -11
- package/dist/controllers/entity/update-entity.controller.js.map +1 -1
- package/dist/controllers/entity/upsert-entity.controller.d.ts +1 -2
- package/dist/controllers/entity/upsert-entity.controller.d.ts.map +1 -1
- package/dist/controllers/entity/upsert-entity.controller.js +14 -10
- package/dist/controllers/entity/upsert-entity.controller.js.map +1 -1
- package/dist/controllers/mutual/create-mutual.controller.d.ts +1 -2
- package/dist/controllers/mutual/create-mutual.controller.d.ts.map +1 -1
- package/dist/controllers/mutual/create-mutual.controller.js +16 -11
- package/dist/controllers/mutual/create-mutual.controller.js.map +1 -1
- package/dist/controllers/mutual/delete-mutual.controller.d.ts +1 -2
- package/dist/controllers/mutual/delete-mutual.controller.d.ts.map +1 -1
- package/dist/controllers/mutual/delete-mutual.controller.js +8 -6
- package/dist/controllers/mutual/delete-mutual.controller.js.map +1 -1
- package/dist/controllers/mutual/get-mutual.controller.d.ts +1 -2
- package/dist/controllers/mutual/get-mutual.controller.d.ts.map +1 -1
- package/dist/controllers/mutual/get-mutual.controller.js +7 -5
- package/dist/controllers/mutual/get-mutual.controller.js.map +1 -1
- package/dist/controllers/mutual/list-entities-by-entity.controller.d.ts +1 -2
- package/dist/controllers/mutual/list-entities-by-entity.controller.d.ts.map +1 -1
- package/dist/controllers/mutual/list-entities-by-entity.controller.js +10 -14
- package/dist/controllers/mutual/list-entities-by-entity.controller.js.map +1 -1
- package/dist/controllers/mutual/update-mutual.controller.d.ts +1 -2
- package/dist/controllers/mutual/update-mutual.controller.d.ts.map +1 -1
- package/dist/controllers/mutual/update-mutual.controller.js +12 -8
- package/dist/controllers/mutual/update-mutual.controller.js.map +1 -1
- package/dist/controllers/setupRoutes.d.ts +2 -3
- package/dist/controllers/setupRoutes.d.ts.map +1 -1
- package/dist/controllers/setupRoutes.js +19 -18
- package/dist/controllers/setupRoutes.js.map +1 -1
- package/dist/controllers/tag/list-tags.controller.d.ts +1 -2
- package/dist/controllers/tag/list-tags.controller.d.ts.map +1 -1
- package/dist/controllers/tag/list-tags.controller.js +11 -8
- package/dist/controllers/tag/list-tags.controller.js.map +1 -1
- package/dist/data/Entity.d.ts.map +1 -1
- package/dist/data/Entity.js +10 -10
- package/dist/data/Entity.js.map +1 -1
- package/dist/handles/app.d.ts +16 -0
- package/dist/handles/app.d.ts.map +1 -0
- package/dist/handles/app.js +31 -0
- package/dist/handles/app.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/middlewares/api-key-auth.d.ts +3 -0
- package/dist/middlewares/api-key-auth.d.ts.map +1 -0
- package/dist/middlewares/api-key-auth.js +32 -0
- package/dist/middlewares/api-key-auth.js.map +1 -0
- package/dist/middlewares/entity-type-check.d.ts +1 -2
- package/dist/middlewares/entity-type-check.d.ts.map +1 -1
- package/dist/middlewares/entity-type-check.js +16 -6
- package/dist/middlewares/entity-type-check.js.map +1 -1
- package/dist/middlewares/general-error-handler.d.ts +7 -0
- package/dist/middlewares/general-error-handler.d.ts.map +1 -0
- package/dist/middlewares/general-error-handler.js +40 -0
- package/dist/middlewares/general-error-handler.js.map +1 -0
- package/dist/middlewares/mutual-type-check.d.ts +1 -2
- package/dist/middlewares/mutual-type-check.d.ts.map +1 -1
- package/dist/middlewares/mutual-type-check.js +16 -6
- package/dist/middlewares/mutual-type-check.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -5
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { Request, Response } from 'express';
|
|
2
1
|
import type { EntityService } from '../../services/entity.service';
|
|
3
2
|
export declare class CreateEntityController {
|
|
4
3
|
private entityService;
|
|
5
4
|
constructor(entityService: EntityService);
|
|
6
|
-
controller: (
|
|
5
|
+
controller: import("hono").MiddlewareHandler<any, string, {}>;
|
|
7
6
|
}
|
|
8
7
|
//# sourceMappingURL=create-entity.controller.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-entity.controller.d.ts","sourceRoot":"","sources":["../../../controllers/entity/create-entity.controller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-entity.controller.d.ts","sourceRoot":"","sources":["../../../controllers/entity/create-entity.controller.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,qBAAa,sBAAsB;IACrB,OAAO,CAAC,aAAa;gBAAb,aAAa,EAAE,aAAa;IAEhD,UAAU,oDA4DP;CACJ"}
|
|
@@ -7,29 +7,33 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
+
import { createMiddleware } from 'hono/factory';
|
|
10
11
|
import httpStatus from 'http-status';
|
|
11
12
|
import { StandardError, StandardErrorCode } from '../../errors/standard-error';
|
|
12
13
|
export class CreateEntityController {
|
|
13
14
|
constructor(entityService) {
|
|
14
15
|
this.entityService = entityService;
|
|
15
|
-
this.controller = (
|
|
16
|
+
this.controller = createMiddleware((c) => __awaiter(this, void 0, void 0, function* () {
|
|
16
17
|
var _a;
|
|
17
|
-
const accountId = req.
|
|
18
|
-
const { entityType } = req.
|
|
18
|
+
const accountId = c.req.header('account-id');
|
|
19
|
+
const { entityType } = c.req.param();
|
|
20
|
+
const body = yield c.req.json();
|
|
19
21
|
try {
|
|
20
22
|
const entity = yield this.entityService.createEntity({
|
|
21
23
|
entityType,
|
|
22
|
-
entityPayload:
|
|
24
|
+
entityPayload: body,
|
|
23
25
|
accountId,
|
|
24
26
|
options: {
|
|
25
|
-
createAndUpdateDatetime:
|
|
27
|
+
createAndUpdateDatetime: body.createdAt,
|
|
26
28
|
},
|
|
27
29
|
});
|
|
28
|
-
|
|
30
|
+
c.status(httpStatus.OK);
|
|
31
|
+
return c.json(entity);
|
|
29
32
|
}
|
|
30
33
|
catch (err) {
|
|
31
34
|
if (((_a = err.constructor) === null || _a === void 0 ? void 0 : _a.name) === 'ZodError') {
|
|
32
|
-
|
|
35
|
+
c.status(httpStatus.BAD_REQUEST);
|
|
36
|
+
return c.json({
|
|
33
37
|
code: 'API_VALIDATION_ERROR',
|
|
34
38
|
message: 'API validation failed',
|
|
35
39
|
details: err.flatten(),
|
|
@@ -37,19 +41,24 @@ export class CreateEntityController {
|
|
|
37
41
|
}
|
|
38
42
|
if (err instanceof StandardError &&
|
|
39
43
|
err.code === StandardErrorCode.EMAIL_EXISTS) {
|
|
40
|
-
|
|
44
|
+
c.status(httpStatus.BAD_REQUEST);
|
|
45
|
+
return c.json(Object.assign({}, err.toJSON()));
|
|
41
46
|
}
|
|
42
47
|
if (err instanceof StandardError &&
|
|
43
48
|
err.code === StandardErrorCode.UNIQUE_VALUE_EXISTS) {
|
|
44
|
-
|
|
49
|
+
c.status(httpStatus.BAD_REQUEST);
|
|
50
|
+
return c.json(Object.assign({}, err.toJSON()));
|
|
45
51
|
}
|
|
46
52
|
console.log('===create-entity error:', {
|
|
47
53
|
err,
|
|
48
|
-
errorContext: JSON.stringify({
|
|
54
|
+
errorContext: JSON.stringify({
|
|
55
|
+
body,
|
|
56
|
+
headers: c.req.header(),
|
|
57
|
+
}),
|
|
49
58
|
});
|
|
50
59
|
throw err;
|
|
51
60
|
}
|
|
52
|
-
});
|
|
61
|
+
}));
|
|
53
62
|
}
|
|
54
63
|
}
|
|
55
64
|
//# sourceMappingURL=create-entity.controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-entity.controller.js","sourceRoot":"","sources":["../../../controllers/entity/create-entity.controller.ts"],"names":[],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"create-entity.controller.js","sourceRoot":"","sources":["../../../controllers/entity/create-entity.controller.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,UAAU,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAG/E,MAAM,OAAO,sBAAsB;IACjC,YAAoB,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;QAEhD,eAAU,GAAG,gBAAgB,CAAC,CAAO,CAAC,EAAE,EAAE;;YACxC,MAAM,SAAS,GAAG,CAAC,CAAC,GAAG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MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;oBACjC,OAAO,CAAC,CAAC,IAAI,mBACR,GAAG,CAAC,MAAM,EAAE,EACf,CAAC;gBACL,CAAC;gBAED,OAAO,CAAC,GAAG,CAAC,yBAAyB,EAAE;oBACrC,GAAG;oBACH,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC;wBAC3B,IAAI;wBACJ,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE;qBACxB,CAAC;iBACH,CAAC,CAAC;gBAEH,MAAM,GAAG,CAAC;YACZ,CAAC;QACH,CAAC,CAAA,CAAC,CAAC;IA9DgD,CAAC;CA+DrD"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { Request, Response } from 'express';
|
|
2
1
|
import type { EntityService } from '../../services/entity.service';
|
|
3
2
|
export declare class DeleteEntityController {
|
|
4
3
|
private readonly entityService;
|
|
5
4
|
constructor(entityService: EntityService);
|
|
6
|
-
controller: (
|
|
5
|
+
controller: import("hono").MiddlewareHandler<any, string, {}>;
|
|
7
6
|
}
|
|
8
7
|
//# sourceMappingURL=delete-entity.controller.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete-entity.controller.d.ts","sourceRoot":"","sources":["../../../controllers/entity/delete-entity.controller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"delete-entity.controller.d.ts","sourceRoot":"","sources":["../../../controllers/entity/delete-entity.controller.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,qBAAa,sBAAsB;IACrB,OAAO,CAAC,QAAQ,CAAC,aAAa;gBAAb,aAAa,EAAE,aAAa;IAEzD,UAAU,oDA4BP;CACJ"}
|
|
@@ -7,30 +7,32 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
+
import { createMiddleware } from 'hono/factory';
|
|
10
11
|
import httpStatus from 'http-status';
|
|
11
12
|
import { StandardError, StandardErrorCode } from '../../errors/standard-error';
|
|
12
13
|
export class DeleteEntityController {
|
|
13
14
|
constructor(entityService) {
|
|
14
15
|
this.entityService = entityService;
|
|
15
|
-
this.controller = (
|
|
16
|
-
const accountId = req.
|
|
17
|
-
const { entityType, entityId } = req.
|
|
16
|
+
this.controller = createMiddleware((c) => __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
const accountId = c.req.header('account-id');
|
|
18
|
+
const { entityType, entityId } = c.req.param();
|
|
18
19
|
try {
|
|
19
20
|
yield this.entityService.deleteEntity({
|
|
20
21
|
entityType,
|
|
21
22
|
entityId,
|
|
22
23
|
accountId,
|
|
23
24
|
});
|
|
24
|
-
return
|
|
25
|
+
return c.json({ message: 'entity deleted' });
|
|
25
26
|
}
|
|
26
27
|
catch (err) {
|
|
27
28
|
if (err instanceof StandardError &&
|
|
28
29
|
err.code === StandardErrorCode.ENTITY_NOT_FOUND) {
|
|
29
|
-
|
|
30
|
+
c.status(httpStatus.NOT_FOUND);
|
|
31
|
+
return c.json(Object.assign({}, err.toJSON()));
|
|
30
32
|
}
|
|
31
33
|
throw err;
|
|
32
34
|
}
|
|
33
|
-
});
|
|
35
|
+
}));
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
38
|
//# sourceMappingURL=delete-entity.controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete-entity.controller.js","sourceRoot":"","sources":["../../../controllers/entity/delete-entity.controller.ts"],"names":[],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"delete-entity.controller.js","sourceRoot":"","sources":["../../../controllers/entity/delete-entity.controller.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAG/E,MAAM,OAAO,sBAAsB;IACjC,YAA6B,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;QAEzD,eAAU,GAAG,gBAAgB,CAAC,CAAO,CAAC,EAAE,EAAE;YACxC,MAAM,SAAS,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;YAC7C,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,EAG3C,CAAC;YAEF,IAAI,CAAC;gBACH,MAAM,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC;oBACpC,UAAU;oBACV,QAAQ;oBACR,SAAS;iBACV,CAAC,CAAC;gBAEH,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC,CAAC;YAC/C,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,IACE,GAAG,YAAY,aAAa;oBAC5B,GAAG,CAAC,IAAI,KAAK,iBAAiB,CAAC,gBAAgB,EAC/C,CAAC;oBACD,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;oBAC/B,OAAO,CAAC,CAAC,IAAI,mBACR,GAAG,CAAC,MAAM,EAAE,EACf,CAAC;gBACL,CAAC;gBAED,MAAM,GAAG,CAAC;YACZ,CAAC;QACH,CAAC,CAAA,CAAC,CAAC;IA9ByD,CAAC;CA+B9D"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { Request, Response } from 'express';
|
|
2
1
|
import type { EntityRepository } from '../../data/Entity';
|
|
3
2
|
export declare class GetEntityByUniqueFieldValueController {
|
|
4
3
|
private entityRepository;
|
|
5
4
|
constructor(entityRepository: EntityRepository);
|
|
6
|
-
controller: (
|
|
5
|
+
controller: import("hono").MiddlewareHandler<any, string, {}>;
|
|
7
6
|
}
|
|
8
7
|
//# sourceMappingURL=get-entity-by-unique-field-value.controller.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-entity-by-unique-field-value.controller.d.ts","sourceRoot":"","sources":["../../../controllers/entity/get-entity-by-unique-field-value.controller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-entity-by-unique-field-value.controller.d.ts","sourceRoot":"","sources":["../../../controllers/entity/get-entity-by-unique-field-value.controller.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAG1D,qBAAa,qCAAqC;IACpC,OAAO,CAAC,gBAAgB;gBAAhB,gBAAgB,EAAE,gBAAgB;IAEtD,UAAU,oDA6BP;CACJ"}
|
|
@@ -7,28 +7,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
+
import { createMiddleware } from 'hono/factory';
|
|
10
11
|
import httpStatus from 'http-status';
|
|
11
12
|
import { StandardError, StandardErrorCode } from '../../errors/standard-error';
|
|
12
13
|
export class GetEntityByUniqueFieldValueController {
|
|
13
14
|
constructor(entityRepository) {
|
|
14
15
|
this.entityRepository = entityRepository;
|
|
15
|
-
this.controller = (
|
|
16
|
-
const { entityType, uniqueField, uniqueFieldValue } = req.
|
|
16
|
+
this.controller = createMiddleware((c) => __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
const { entityType, uniqueField, uniqueFieldValue } = c.req.param();
|
|
17
18
|
try {
|
|
18
19
|
const entity = yield this.entityRepository.getEntityByUniqueField(entityType, uniqueField, uniqueFieldValue);
|
|
19
|
-
return
|
|
20
|
+
return c.json(entity);
|
|
20
21
|
}
|
|
21
22
|
catch (err) {
|
|
22
23
|
if (err instanceof StandardError &&
|
|
23
24
|
err.code === StandardErrorCode.ENTITY_IS_UNDEFINED) {
|
|
24
|
-
|
|
25
|
+
c.status(httpStatus.NOT_FOUND);
|
|
26
|
+
return c.json({
|
|
25
27
|
code: 'ENTITY_NOT_FOUND',
|
|
26
28
|
message: 'Entity not found',
|
|
27
29
|
});
|
|
28
30
|
}
|
|
29
31
|
throw err;
|
|
30
32
|
}
|
|
31
|
-
});
|
|
33
|
+
}));
|
|
32
34
|
}
|
|
33
35
|
}
|
|
34
36
|
//# sourceMappingURL=get-entity-by-unique-field-value.controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-entity-by-unique-field-value.controller.js","sourceRoot":"","sources":["../../../controllers/entity/get-entity-by-unique-field-value.controller.ts"],"names":[],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"get-entity-by-unique-field-value.controller.js","sourceRoot":"","sources":["../../../controllers/entity/get-entity-by-unique-field-value.controller.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,UAAU,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAE/E,MAAM,OAAO,qCAAqC;IAChD,YAAoB,gBAAkC;QAAlC,qBAAgB,GAAhB,gBAAgB,CAAkB;QAEtD,eAAU,GAAG,gBAAgB,CAAC,CAAO,CAAC,EAAE,EAAE;YACxC,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,gBAAgB,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,EAIhE,CAAC;YAEF,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,sBAAsB,CAC/D,UAAU,EACV,WAAW,EACX,gBAAgB,CACjB,CAAC;gBAEF,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACxB,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,IACE,GAAG,YAAY,aAAa;oBAC5B,GAAG,CAAC,IAAI,KAAK,iBAAiB,CAAC,mBAAmB,EAClD,CAAC;oBACD,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;oBAC/B,OAAO,CAAC,CAAC,IAAI,CAAC;wBACZ,IAAI,EAAE,kBAAkB;wBACxB,OAAO,EAAE,kBAAkB;qBAC5B,CAAC,CAAC;gBACL,CAAC;gBAED,MAAM,GAAG,CAAC;YACZ,CAAC;QACH,CAAC,CAAA,CAAC,CAAC;IA/BsD,CAAC;CAgC3D"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { Request, Response } from 'express';
|
|
2
1
|
import type { EntityRepository } from '../../data/Entity';
|
|
3
2
|
export declare class GetEntityController {
|
|
4
3
|
private entityRepository;
|
|
5
4
|
constructor(entityRepository: EntityRepository);
|
|
6
|
-
controller: (
|
|
5
|
+
controller: import("hono").MiddlewareHandler<any, string, {}>;
|
|
7
6
|
}
|
|
8
7
|
//# sourceMappingURL=get-entity.controller.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-entity.controller.d.ts","sourceRoot":"","sources":["../../../controllers/entity/get-entity.controller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-entity.controller.d.ts","sourceRoot":"","sources":["../../../controllers/entity/get-entity.controller.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAG1D,qBAAa,mBAAmB;IAClB,OAAO,CAAC,gBAAgB;gBAAhB,gBAAgB,EAAE,gBAAgB;IAEtD,UAAU,oDA4BP;CACJ"}
|
|
@@ -7,28 +7,31 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
+
import { createMiddleware } from 'hono/factory';
|
|
10
11
|
import httpStatus from 'http-status';
|
|
11
12
|
import { StandardError, StandardErrorCode } from '../../errors/standard-error';
|
|
12
13
|
export class GetEntityController {
|
|
13
14
|
constructor(entityRepository) {
|
|
14
15
|
this.entityRepository = entityRepository;
|
|
15
|
-
this.controller = (
|
|
16
|
-
const { entityType, entityId } = req.
|
|
16
|
+
this.controller = createMiddleware((c) => __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
const { entityType, entityId } = c.req.param();
|
|
17
18
|
try {
|
|
18
19
|
const entity = yield this.entityRepository.getEntity(entityType, entityId);
|
|
19
|
-
|
|
20
|
+
c.status(httpStatus.OK);
|
|
21
|
+
return c.json(entity);
|
|
20
22
|
}
|
|
21
23
|
catch (err) {
|
|
22
24
|
if (err instanceof StandardError &&
|
|
23
25
|
err.code === StandardErrorCode.ENTITY_IS_UNDEFINED) {
|
|
24
|
-
|
|
26
|
+
c.status(httpStatus.NOT_FOUND);
|
|
27
|
+
return c.json({
|
|
25
28
|
code: 'ENTITY_NOT_FOUND',
|
|
26
29
|
message: 'Entity not found',
|
|
27
30
|
});
|
|
28
31
|
}
|
|
29
32
|
throw err;
|
|
30
33
|
}
|
|
31
|
-
});
|
|
34
|
+
}));
|
|
32
35
|
}
|
|
33
36
|
}
|
|
34
37
|
//# sourceMappingURL=get-entity.controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-entity.controller.js","sourceRoot":"","sources":["../../../controllers/entity/get-entity.controller.ts"],"names":[],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"get-entity.controller.js","sourceRoot":"","sources":["../../../controllers/entity/get-entity.controller.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,UAAU,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAE/E,MAAM,OAAO,mBAAmB;IAC9B,YAAoB,gBAAkC;QAAlC,qBAAgB,GAAhB,gBAAgB,CAAkB;QAEtD,eAAU,GAAG,gBAAgB,CAAC,CAAO,CAAC,EAAE,EAAE;YACxC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,EAG3C,CAAC;YAEF,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAClD,UAAU,EACV,QAAQ,CACT,CAAC;gBAEF,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;gBACxB,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACxB,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,IACE,GAAG,YAAY,aAAa;oBAC5B,GAAG,CAAC,IAAI,KAAK,iBAAiB,CAAC,mBAAmB,EAClD,CAAC;oBACD,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;oBAC/B,OAAO,CAAC,CAAC,IAAI,CAAC;wBACZ,IAAI,EAAE,kBAAkB;wBACxB,OAAO,EAAE,kBAAkB;qBAC5B,CAAC,CAAC;gBACL,CAAC;gBAED,MAAM,GAAG,CAAC;YACZ,CAAC;QACH,CAAC,CAAA,CAAC,CAAC;IA9BsD,CAAC;CA+B3D"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { Request, Response } from 'express';
|
|
2
1
|
import type { EntityRepository } from '../../data/Entity';
|
|
3
2
|
export declare class ListEntitiesController {
|
|
4
3
|
private entityRepository;
|
|
5
4
|
constructor(entityRepository: EntityRepository);
|
|
6
|
-
controller: (
|
|
5
|
+
controller: import("hono").MiddlewareHandler<any, string, {}>;
|
|
7
6
|
}
|
|
8
7
|
//# sourceMappingURL=list-entities.controller.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-entities.controller.d.ts","sourceRoot":"","sources":["../../../controllers/entity/list-entities.controller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"list-entities.controller.d.ts","sourceRoot":"","sources":["../../../controllers/entity/list-entities.controller.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAU1D,qBAAa,sBAAsB;IACrB,OAAO,CAAC,gBAAgB;gBAAhB,gBAAgB,EAAE,gBAAgB;IAEtD,UAAU,oDAmDP;CACJ"}
|
|
@@ -7,6 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
+
import { createMiddleware } from 'hono/factory';
|
|
10
11
|
import { z } from 'zod';
|
|
11
12
|
const querySchema = z.object({
|
|
12
13
|
limit: z.string().optional(),
|
|
@@ -18,21 +19,23 @@ const querySchema = z.object({
|
|
|
18
19
|
export class ListEntitiesController {
|
|
19
20
|
constructor(entityRepository) {
|
|
20
21
|
this.entityRepository = entityRepository;
|
|
21
|
-
this.controller = (
|
|
22
|
+
this.controller = createMiddleware((c) => __awaiter(this, void 0, void 0, function* () {
|
|
22
23
|
const errorContext = {};
|
|
23
24
|
try {
|
|
24
|
-
const accountId = req.
|
|
25
|
+
const accountId = c.req.header('account-id') || '';
|
|
25
26
|
if (Array.isArray(accountId)) {
|
|
26
27
|
throw new Error('multiple account-id detected');
|
|
27
28
|
}
|
|
29
|
+
const params = c.req.param();
|
|
30
|
+
const queries = c.req.query();
|
|
28
31
|
errorContext.accountId = accountId;
|
|
29
|
-
errorContext.params =
|
|
30
|
-
errorContext.query =
|
|
31
|
-
const { entityType } =
|
|
32
|
-
const { lastKey, query, limit, start, end } = querySchema.parse(
|
|
32
|
+
errorContext.params = params;
|
|
33
|
+
errorContext.query = queries;
|
|
34
|
+
const { entityType } = params;
|
|
35
|
+
const { lastKey, query, limit, start, end } = querySchema.parse(queries);
|
|
33
36
|
if (query) {
|
|
34
37
|
const results = yield this.entityRepository.queryEntities(entityType, query);
|
|
35
|
-
return
|
|
38
|
+
return c.json({
|
|
36
39
|
data: results.items.map((item) => item.toJSON()),
|
|
37
40
|
totalCount: results.totalCount,
|
|
38
41
|
filteredCount: results.filteredCount,
|
|
@@ -41,7 +44,7 @@ export class ListEntitiesController {
|
|
|
41
44
|
const results = yield this.entityRepository.listEntities(Object.assign({ entityType, limit: Number(limit), options: {
|
|
42
45
|
lastKey,
|
|
43
46
|
} }, (start && end ? { between: { start, end } } : {})));
|
|
44
|
-
return
|
|
47
|
+
return c.json({
|
|
45
48
|
data: results.items.map((item) => item.toJSON()),
|
|
46
49
|
totalCount: results.totalCount,
|
|
47
50
|
lastKey: results.lastKey,
|
|
@@ -49,9 +52,10 @@ export class ListEntitiesController {
|
|
|
49
52
|
}
|
|
50
53
|
catch (error) {
|
|
51
54
|
console.log({ error, errorContext });
|
|
52
|
-
|
|
55
|
+
c.status(500);
|
|
56
|
+
return c.json({ message: error });
|
|
53
57
|
}
|
|
54
|
-
});
|
|
58
|
+
}));
|
|
55
59
|
}
|
|
56
60
|
}
|
|
57
61
|
//# sourceMappingURL=list-entities.controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-entities.controller.js","sourceRoot":"","sources":["../../../controllers/entity/list-entities.controller.ts"],"names":[],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"list-entities.controller.js","sourceRoot":"","sources":["../../../controllers/entity/list-entities.controller.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CA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CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;wBAChD,UAAU,EAAE,OAAO,CAAC,UAAU;wBAC9B,aAAa,EAAE,OAAO,CAAC,aAAa;qBACrC,CAAC,CAAC;gBACL,CAAC;gBAED,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,YAAY,iBACtD,UAAU,EACV,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EACpB,OAAO,EAAE;wBACP,OAAO;qBACR,IACE,CAAC,KAAK,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EACpD,CAAC;gBACH,OAAO,CAAC,CAAC,IAAI,CAAC;oBACZ,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;oBAChD,UAAU,EAAE,OAAO,CAAC,UAAU;oBAC9B,OAAO,EAAE,OAAO,CAAC,OAAO;iBACzB,CAAC,CAAC;YACL,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC;gBACrC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBACd,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;YACpC,CAAC;QACH,CAAC,CAAA,CAAC,CAAC;IArDsD,CAAC;CAsD3D"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { Request, Response } from 'express';
|
|
2
1
|
import type { EntityService } from '../../services/entity.service';
|
|
3
2
|
export declare class UpdateEntityController {
|
|
4
3
|
private entityService;
|
|
5
4
|
constructor(entityService: EntityService);
|
|
6
|
-
controller: (
|
|
5
|
+
controller: import("hono").MiddlewareHandler<any, string, {}>;
|
|
7
6
|
}
|
|
8
7
|
//# sourceMappingURL=update-entity.controller.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-entity.controller.d.ts","sourceRoot":"","sources":["../../../controllers/entity/update-entity.controller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"update-entity.controller.d.ts","sourceRoot":"","sources":["../../../controllers/entity/update-entity.controller.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,qBAAa,sBAAsB;IACrB,OAAO,CAAC,aAAa;gBAAb,aAAa,EAAE,aAAa;IAEhD,UAAU,oDA+DP;CACJ"}
|
|
@@ -7,33 +7,37 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
+
import { createMiddleware } from 'hono/factory';
|
|
10
11
|
import httpStatus from 'http-status';
|
|
11
12
|
import { StandardError, StandardErrorCode } from '../../errors/standard-error';
|
|
12
13
|
export class UpdateEntityController {
|
|
13
14
|
constructor(entityService) {
|
|
14
15
|
this.entityService = entityService;
|
|
15
|
-
this.controller = (
|
|
16
|
+
this.controller = createMiddleware((c) => __awaiter(this, void 0, void 0, function* () {
|
|
16
17
|
var _a;
|
|
17
|
-
const accountId = req.
|
|
18
|
-
const { entityType, entityId } = req.
|
|
18
|
+
const accountId = c.req.header('account-id');
|
|
19
|
+
const { entityType, entityId } = c.req.param();
|
|
20
|
+
const body = yield c.req.json();
|
|
19
21
|
const errorContext = {
|
|
20
22
|
accountId,
|
|
21
|
-
'req.params': req.
|
|
22
|
-
'req.body':
|
|
23
|
+
'req.params': c.req.param(),
|
|
24
|
+
'req.body': body,
|
|
23
25
|
};
|
|
24
26
|
try {
|
|
25
27
|
const entity = yield this.entityService.updateEntity({
|
|
26
28
|
entityType,
|
|
27
29
|
entityId,
|
|
28
|
-
entityPayload:
|
|
30
|
+
entityPayload: body,
|
|
29
31
|
accountId,
|
|
30
32
|
});
|
|
31
33
|
errorContext.entity = entity;
|
|
32
|
-
|
|
34
|
+
c.status(httpStatus.OK);
|
|
35
|
+
return c.json(entity);
|
|
33
36
|
}
|
|
34
37
|
catch (err) {
|
|
35
38
|
if (((_a = err.constructor) === null || _a === void 0 ? void 0 : _a.name) === 'ZodError') {
|
|
36
|
-
|
|
39
|
+
c.status(httpStatus.BAD_REQUEST);
|
|
40
|
+
return c.json({
|
|
37
41
|
code: 'API_VALIDATION_ERROR',
|
|
38
42
|
message: 'API validation failed',
|
|
39
43
|
details: err.flatten(),
|
|
@@ -41,16 +45,18 @@ export class UpdateEntityController {
|
|
|
41
45
|
}
|
|
42
46
|
if (err instanceof StandardError &&
|
|
43
47
|
err.code === StandardErrorCode.ENTITY_NOT_FOUND) {
|
|
44
|
-
|
|
48
|
+
c.status(httpStatus.NOT_FOUND);
|
|
49
|
+
return c.json(Object.assign({}, err.toJSON()));
|
|
45
50
|
}
|
|
46
51
|
if (err instanceof StandardError &&
|
|
47
52
|
err.code === StandardErrorCode.UNIQUE_VALUE_EXISTS) {
|
|
48
|
-
|
|
53
|
+
c.status(httpStatus.BAD_REQUEST);
|
|
54
|
+
return c.json(Object.assign({}, err.toJSON()));
|
|
49
55
|
}
|
|
50
56
|
console.log('====UPDATE_ENTITY_CONTROLLER_ERROR', err, JSON.stringify({ errorContext }, null, 2));
|
|
51
57
|
throw err;
|
|
52
58
|
}
|
|
53
|
-
});
|
|
59
|
+
}));
|
|
54
60
|
}
|
|
55
61
|
}
|
|
56
62
|
//# sourceMappingURL=update-entity.controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-entity.controller.js","sourceRoot":"","sources":["../../../controllers/entity/update-entity.controller.ts"],"names":[],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"update-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,WAAW,CAAC,CAAC;oBACjC,OAAO,CAAC,CAAC,IAAI,CAAC;wBACZ,IAAI,EAAE,sBAAsB;wBAC5B,OAAO,EAAE,uBAAuB;wBAChC,OAAO,EAAG,GAAgB,CAAC,OAAO,EAAE;qBACrC,CAAC,CAAC;gBACL,CAAC;gBAED,IACE,GAAG,YAAY,aAAa;oBAC5B,GAAG,CAAC,IAAI,KAAK,iBAAiB,CAAC,gBAAgB,EAC/C,CAAC;oBACD,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;oBAC/B,OAAO,CAAC,CAAC,IAAI,mBACR,GAAG,CAAC,MAAM,EAAE,EACf,CAAC;gBACL,CAAC;gBAED,IACE,GAAG,YAAY,aAAa;oBAC5B,GAAG,CAAC,IAAI,KAAK,iBAAiB,CAAC,mBAAmB,EAClD,CAAC;oBACD,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;oBACjC,OAAO,CAAC,CAAC,IAAI,mBACR,GAAG,CAAC,MAAM,EAAE,EACf,CAAC;gBACL,CAAC;gBAED,OAAO,CAAC,GAAG,CACT,oCAAoC,EACpC,GAAG,EACH,IAAI,CAAC,SAAS,CAAC,EAAE,YAAY,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAC1C,CAAC;gBACF,MAAM,GAAG,CAAC;YACZ,CAAC;QACH,CAAC,CAAA,CAAC,CAAC;IAjEgD,CAAC;CAkErD"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Entity, createEntityConfig } from '@monorise/base';
|
|
2
|
-
import type { Request, Response } from 'express';
|
|
3
2
|
import type { EntityRepository } from '../../data/Entity';
|
|
4
3
|
import type { publishEvent as publishEventType } from '../../helpers/event';
|
|
5
4
|
export declare class UpsertEntityController {
|
|
@@ -7,6 +6,6 @@ export declare class UpsertEntityController {
|
|
|
7
6
|
private entityRepository;
|
|
8
7
|
private publishEvent;
|
|
9
8
|
constructor(EntityConfig: Record<Entity, ReturnType<typeof createEntityConfig>>, entityRepository: EntityRepository, publishEvent: typeof publishEventType);
|
|
10
|
-
controller: (
|
|
9
|
+
controller: import("hono").MiddlewareHandler<any, string, {}>;
|
|
11
10
|
}
|
|
12
11
|
//# sourceMappingURL=upsert-entity.controller.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upsert-entity.controller.d.ts","sourceRoot":"","sources":["../../../controllers/entity/upsert-entity.controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"upsert-entity.controller.d.ts","sourceRoot":"","sources":["../../../controllers/entity/upsert-entity.controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAIjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,KAAK,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAG5E,qBAAa,sBAAsB;IAE/B,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,gBAAgB;IACxB,OAAO,CAAC,YAAY;gBAFZ,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,EACnE,gBAAgB,EAAE,gBAAgB,EAClC,YAAY,EAAE,OAAO,gBAAgB;IAG/C,UAAU,oDAyFP;CACJ"}
|
|
@@ -7,6 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
+
import { createMiddleware } from 'hono/factory';
|
|
10
11
|
import httpStatus from 'http-status';
|
|
11
12
|
import { ZodError } from 'zod';
|
|
12
13
|
import { StandardError, StandardErrorCode } from '../../errors/standard-error';
|
|
@@ -16,10 +17,10 @@ export class UpsertEntityController {
|
|
|
16
17
|
this.EntityConfig = EntityConfig;
|
|
17
18
|
this.entityRepository = entityRepository;
|
|
18
19
|
this.publishEvent = publishEvent;
|
|
19
|
-
this.controller = (
|
|
20
|
+
this.controller = createMiddleware((c) => __awaiter(this, void 0, void 0, function* () {
|
|
20
21
|
var _a, _b;
|
|
21
|
-
const accountId = req.
|
|
22
|
-
const { entityType, entityId } = req.
|
|
22
|
+
const accountId = c.req.header('account-id');
|
|
23
|
+
const { entityType, entityId } = c.req.param();
|
|
23
24
|
try {
|
|
24
25
|
const entitySchema = this.EntityConfig[entityType].createSchema ||
|
|
25
26
|
this.EntityConfig[entityType].baseSchema;
|
|
@@ -27,8 +28,9 @@ export class UpsertEntityController {
|
|
|
27
28
|
if (!entitySchema || !mutualSchema) {
|
|
28
29
|
throw new StandardError(StandardErrorCode.INVALID_ENTITY_TYPE, 'Invalid entity type');
|
|
29
30
|
}
|
|
30
|
-
const
|
|
31
|
-
const
|
|
31
|
+
const body = yield c.req.json();
|
|
32
|
+
const parsedEntityPayload = entitySchema.parse(body);
|
|
33
|
+
const parsedMutualPayload = mutualSchema.parse(body);
|
|
32
34
|
const entity = yield this.entityRepository.upsertEntity(entityType, entityId, parsedEntityPayload);
|
|
33
35
|
if (parsedMutualPayload) {
|
|
34
36
|
const byEntityType = entityType;
|
|
@@ -54,15 +56,16 @@ export class UpsertEntityController {
|
|
|
54
56
|
payload: {
|
|
55
57
|
entityType,
|
|
56
58
|
entityId: entity.entityId,
|
|
57
|
-
payload:
|
|
59
|
+
payload: body,
|
|
58
60
|
createdByAccountId: accountId,
|
|
59
61
|
},
|
|
60
62
|
});
|
|
61
|
-
return
|
|
63
|
+
return c.json(entity);
|
|
62
64
|
}
|
|
63
65
|
catch (err) {
|
|
64
66
|
if (err instanceof ZodError) {
|
|
65
|
-
|
|
67
|
+
c.status(httpStatus.BAD_REQUEST);
|
|
68
|
+
return c.json({
|
|
66
69
|
code: 'API_VALIDATION_ERROR',
|
|
67
70
|
message: 'API validation failed',
|
|
68
71
|
details: err.flatten(),
|
|
@@ -70,11 +73,12 @@ export class UpsertEntityController {
|
|
|
70
73
|
}
|
|
71
74
|
if (err instanceof StandardError &&
|
|
72
75
|
err.code === StandardErrorCode.EMAIL_EXISTS) {
|
|
73
|
-
|
|
76
|
+
c.status(httpStatus.BAD_REQUEST);
|
|
77
|
+
return c.json(Object.assign({}, err.toJSON()));
|
|
74
78
|
}
|
|
75
79
|
throw err;
|
|
76
80
|
}
|
|
77
|
-
});
|
|
81
|
+
}));
|
|
78
82
|
}
|
|
79
83
|
}
|
|
80
84
|
//# sourceMappingURL=upsert-entity.controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upsert-entity.controller.js","sourceRoot":"","sources":["../../../controllers/entity/upsert-entity.controller.ts"],"names":[],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"upsert-entity.controller.js","sourceRoot":"","sources":["../../../controllers/entity/upsert-entity.controller.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAE/B,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAE/E,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,MAAM,OAAO,sBAAsB;IACjC,YACU,YAAmE,EACnE,gBAAkC,EAClC,YAAqC;QAFrC,iBAAY,GAAZ,YAAY,CAAuD;QACnE,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,iBAAY,GAAZ,YAAY,CAAyB;QAG/C,eAAU,GAAG,gBAAgB,CAAC,CAAO,CAAC,EAAE,EAAE;;YACxC,MAAM,SAAS,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,CAA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L,CAAC;gBAED,MAAM,GAAG,CAAC;YACZ,CAAC;QACH,CAAC,CAAA,CAAC,CAAC;IA3FA,CAAC;CA4FL"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { Request, Response } from 'express';
|
|
2
1
|
import type { MutualService } from '../../services/mutual.service';
|
|
3
2
|
export declare class CreateMutualController {
|
|
4
3
|
private mutualService;
|
|
5
4
|
constructor(mutualService: MutualService);
|
|
6
|
-
controller: (
|
|
5
|
+
controller: import("hono").MiddlewareHandler<any, string, {}>;
|
|
7
6
|
}
|
|
8
7
|
//# sourceMappingURL=create-mutual.controller.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-mutual.controller.d.ts","sourceRoot":"","sources":["../../../controllers/mutual/create-mutual.controller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-mutual.controller.d.ts","sourceRoot":"","sources":["../../../controllers/mutual/create-mutual.controller.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,qBAAa,sBAAsB;IACrB,OAAO,CAAC,aAAa;gBAAb,aAAa,EAAE,aAAa;IAEhD,UAAU,oDA2DP;CACJ"}
|