@monorise/core 3.0.0 → 3.0.2

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 (206) hide show
  1. package/dist/index.d.ts +4759 -27
  2. package/dist/index.js +7940 -31
  3. package/dist/index.js.map +1 -1
  4. package/package.json +4 -4
  5. package/dist/configs/service.config.d.ts +0 -5
  6. package/dist/configs/service.config.d.ts.map +0 -1
  7. package/dist/configs/service.config.js +0 -5
  8. package/dist/configs/service.config.js.map +0 -1
  9. package/dist/constants/table.d.ts +0 -3
  10. package/dist/constants/table.d.ts.map +0 -1
  11. package/dist/constants/table.js +0 -3
  12. package/dist/constants/table.js.map +0 -1
  13. package/dist/controllers/entity/create-entity.controller.d.ts +0 -7
  14. package/dist/controllers/entity/create-entity.controller.d.ts.map +0 -1
  15. package/dist/controllers/entity/create-entity.controller.js +0 -64
  16. package/dist/controllers/entity/create-entity.controller.js.map +0 -1
  17. package/dist/controllers/entity/delete-entity.controller.d.ts +0 -7
  18. package/dist/controllers/entity/delete-entity.controller.d.ts.map +0 -1
  19. package/dist/controllers/entity/delete-entity.controller.js +0 -38
  20. package/dist/controllers/entity/delete-entity.controller.js.map +0 -1
  21. package/dist/controllers/entity/get-entity-by-unique-field-value.controller.d.ts +0 -7
  22. package/dist/controllers/entity/get-entity-by-unique-field-value.controller.d.ts.map +0 -1
  23. package/dist/controllers/entity/get-entity-by-unique-field-value.controller.js +0 -36
  24. package/dist/controllers/entity/get-entity-by-unique-field-value.controller.js.map +0 -1
  25. package/dist/controllers/entity/get-entity.controller.d.ts +0 -7
  26. package/dist/controllers/entity/get-entity.controller.d.ts.map +0 -1
  27. package/dist/controllers/entity/get-entity.controller.js +0 -37
  28. package/dist/controllers/entity/get-entity.controller.js.map +0 -1
  29. package/dist/controllers/entity/list-entities.controller.d.ts +0 -7
  30. package/dist/controllers/entity/list-entities.controller.d.ts.map +0 -1
  31. package/dist/controllers/entity/list-entities.controller.js +0 -61
  32. package/dist/controllers/entity/list-entities.controller.js.map +0 -1
  33. package/dist/controllers/entity/update-entity.controller.d.ts +0 -7
  34. package/dist/controllers/entity/update-entity.controller.d.ts.map +0 -1
  35. package/dist/controllers/entity/update-entity.controller.js +0 -62
  36. package/dist/controllers/entity/update-entity.controller.js.map +0 -1
  37. package/dist/controllers/entity/upsert-entity.controller.d.ts +0 -11
  38. package/dist/controllers/entity/upsert-entity.controller.d.ts.map +0 -1
  39. package/dist/controllers/entity/upsert-entity.controller.js +0 -84
  40. package/dist/controllers/entity/upsert-entity.controller.js.map +0 -1
  41. package/dist/controllers/mutual/create-mutual.controller.d.ts +0 -7
  42. package/dist/controllers/mutual/create-mutual.controller.d.ts.map +0 -1
  43. package/dist/controllers/mutual/create-mutual.controller.js +0 -60
  44. package/dist/controllers/mutual/create-mutual.controller.js.map +0 -1
  45. package/dist/controllers/mutual/delete-mutual.controller.d.ts +0 -7
  46. package/dist/controllers/mutual/delete-mutual.controller.d.ts.map +0 -1
  47. package/dist/controllers/mutual/delete-mutual.controller.js +0 -40
  48. package/dist/controllers/mutual/delete-mutual.controller.js.map +0 -1
  49. package/dist/controllers/mutual/get-mutual.controller.d.ts +0 -7
  50. package/dist/controllers/mutual/get-mutual.controller.d.ts.map +0 -1
  51. package/dist/controllers/mutual/get-mutual.controller.js +0 -36
  52. package/dist/controllers/mutual/get-mutual.controller.js.map +0 -1
  53. package/dist/controllers/mutual/list-entities-by-entity.controller.d.ts +0 -7
  54. package/dist/controllers/mutual/list-entities-by-entity.controller.d.ts.map +0 -1
  55. package/dist/controllers/mutual/list-entities-by-entity.controller.js +0 -72
  56. package/dist/controllers/mutual/list-entities-by-entity.controller.js.map +0 -1
  57. package/dist/controllers/mutual/update-mutual.controller.d.ts +0 -7
  58. package/dist/controllers/mutual/update-mutual.controller.d.ts.map +0 -1
  59. package/dist/controllers/mutual/update-mutual.controller.js +0 -54
  60. package/dist/controllers/mutual/update-mutual.controller.js.map +0 -1
  61. package/dist/controllers/setupRoutes.d.ts +0 -4
  62. package/dist/controllers/setupRoutes.d.ts.map +0 -1
  63. package/dist/controllers/setupRoutes.js +0 -32
  64. package/dist/controllers/setupRoutes.js.map +0 -1
  65. package/dist/controllers/tag/list-tags.controller.d.ts +0 -7
  66. package/dist/controllers/tag/list-tags.controller.d.ts.map +0 -1
  67. package/dist/controllers/tag/list-tags.controller.js +0 -57
  68. package/dist/controllers/tag/list-tags.controller.js.map +0 -1
  69. package/dist/data/DbUtils.d.ts +0 -7
  70. package/dist/data/DbUtils.d.ts.map +0 -1
  71. package/dist/data/DbUtils.js +0 -34
  72. package/dist/data/DbUtils.js.map +0 -1
  73. package/dist/data/Entity.d.ts +0 -77
  74. package/dist/data/Entity.d.ts.map +0 -1
  75. package/dist/data/Entity.js +0 -504
  76. package/dist/data/Entity.js.map +0 -1
  77. package/dist/data/EventUtils.d.ts +0 -15
  78. package/dist/data/EventUtils.d.ts.map +0 -1
  79. package/dist/data/EventUtils.js +0 -43
  80. package/dist/data/EventUtils.js.map +0 -1
  81. package/dist/data/FileObject.d.ts +0 -62
  82. package/dist/data/FileObject.d.ts.map +0 -1
  83. package/dist/data/FileObject.js +0 -13
  84. package/dist/data/FileObject.js.map +0 -1
  85. package/dist/data/Mutual.d.ts +0 -93
  86. package/dist/data/Mutual.d.ts.map +0 -1
  87. package/dist/data/Mutual.js +0 -439
  88. package/dist/data/Mutual.js.map +0 -1
  89. package/dist/data/ProjectionExpression.d.ts +0 -6
  90. package/dist/data/ProjectionExpression.d.ts.map +0 -1
  91. package/dist/data/ProjectionExpression.js +0 -5
  92. package/dist/data/ProjectionExpression.js.map +0 -1
  93. package/dist/data/Tag.d.ts +0 -77
  94. package/dist/data/Tag.d.ts.map +0 -1
  95. package/dist/data/Tag.js +0 -329
  96. package/dist/data/Tag.js.map +0 -1
  97. package/dist/data/abstract/Item.base.d.ts +0 -11
  98. package/dist/data/abstract/Item.base.d.ts.map +0 -1
  99. package/dist/data/abstract/Item.base.js +0 -9
  100. package/dist/data/abstract/Item.base.js.map +0 -1
  101. package/dist/data/abstract/Repository.base.d.ts +0 -11
  102. package/dist/data/abstract/Repository.base.d.ts.map +0 -1
  103. package/dist/data/abstract/Repository.base.js +0 -51
  104. package/dist/data/abstract/Repository.base.js.map +0 -1
  105. package/dist/errors/api-error.d.ts +0 -23
  106. package/dist/errors/api-error.d.ts.map +0 -1
  107. package/dist/errors/api-error.js +0 -26
  108. package/dist/errors/api-error.js.map +0 -1
  109. package/dist/errors/extendable-error.d.ts +0 -18
  110. package/dist/errors/extendable-error.d.ts.map +0 -1
  111. package/dist/errors/extendable-error.js +0 -15
  112. package/dist/errors/extendable-error.js.map +0 -1
  113. package/dist/errors/standard-error.d.ts +0 -33
  114. package/dist/errors/standard-error.d.ts.map +0 -1
  115. package/dist/errors/standard-error.js +0 -39
  116. package/dist/errors/standard-error.js.map +0 -1
  117. package/dist/handles/app.d.ts +0 -16
  118. package/dist/handles/app.d.ts.map +0 -1
  119. package/dist/handles/app.js +0 -31
  120. package/dist/handles/app.js.map +0 -1
  121. package/dist/helpers/dependencies.d.ts +0 -8
  122. package/dist/helpers/dependencies.d.ts.map +0 -1
  123. package/dist/helpers/dependencies.js +0 -10
  124. package/dist/helpers/dependencies.js.map +0 -1
  125. package/dist/helpers/event.d.ts +0 -22
  126. package/dist/helpers/event.d.ts.map +0 -1
  127. package/dist/helpers/event.js +0 -48
  128. package/dist/helpers/event.js.map +0 -1
  129. package/dist/helpers/fromLastKeyQuery.d.ts +0 -3
  130. package/dist/helpers/fromLastKeyQuery.d.ts.map +0 -1
  131. package/dist/helpers/fromLastKeyQuery.js +0 -7
  132. package/dist/helpers/fromLastKeyQuery.js.map +0 -1
  133. package/dist/helpers/sleep.d.ts +0 -2
  134. package/dist/helpers/sleep.d.ts.map +0 -1
  135. package/dist/helpers/sleep.js +0 -2
  136. package/dist/helpers/sleep.js.map +0 -1
  137. package/dist/helpers/toLastKeyResponse.d.ts +0 -3
  138. package/dist/helpers/toLastKeyResponse.d.ts.map +0 -1
  139. package/dist/helpers/toLastKeyResponse.js +0 -7
  140. package/dist/helpers/toLastKeyResponse.js.map +0 -1
  141. package/dist/index.d.ts.map +0 -1
  142. package/dist/middlewares/api-key-auth.d.ts +0 -3
  143. package/dist/middlewares/api-key-auth.d.ts.map +0 -1
  144. package/dist/middlewares/api-key-auth.js +0 -32
  145. package/dist/middlewares/api-key-auth.js.map +0 -1
  146. package/dist/middlewares/entity-type-check.d.ts +0 -3
  147. package/dist/middlewares/entity-type-check.d.ts.map +0 -1
  148. package/dist/middlewares/entity-type-check.js +0 -22
  149. package/dist/middlewares/entity-type-check.js.map +0 -1
  150. package/dist/middlewares/general-error-handler.d.ts +0 -7
  151. package/dist/middlewares/general-error-handler.d.ts.map +0 -1
  152. package/dist/middlewares/general-error-handler.js +0 -40
  153. package/dist/middlewares/general-error-handler.js.map +0 -1
  154. package/dist/middlewares/mutual-type-check.d.ts +0 -3
  155. package/dist/middlewares/mutual-type-check.d.ts.map +0 -1
  156. package/dist/middlewares/mutual-type-check.js +0 -23
  157. package/dist/middlewares/mutual-type-check.js.map +0 -1
  158. package/dist/processors/create-entity-processor.d.ts +0 -6
  159. package/dist/processors/create-entity-processor.d.ts.map +0 -1
  160. package/dist/processors/create-entity-processor.js +0 -44
  161. package/dist/processors/create-entity-processor.js.map +0 -1
  162. package/dist/processors/mutual-processor.d.ts +0 -16
  163. package/dist/processors/mutual-processor.d.ts.map +0 -1
  164. package/dist/processors/mutual-processor.js +0 -142
  165. package/dist/processors/mutual-processor.js.map +0 -1
  166. package/dist/processors/prejoin-processor.d.ts +0 -13
  167. package/dist/processors/prejoin-processor.d.ts.map +0 -1
  168. package/dist/processors/prejoin-processor.js +0 -161
  169. package/dist/processors/prejoin-processor.js.map +0 -1
  170. package/dist/processors/replication-processor.d.ts +0 -9
  171. package/dist/processors/replication-processor.d.ts.map +0 -1
  172. package/dist/processors/replication-processor.js +0 -180
  173. package/dist/processors/replication-processor.js.map +0 -1
  174. package/dist/processors/tag-processor.d.ts +0 -12
  175. package/dist/processors/tag-processor.d.ts.map +0 -1
  176. package/dist/processors/tag-processor.js +0 -118
  177. package/dist/processors/tag-processor.js.map +0 -1
  178. package/dist/services/DependencyContainer.d.ts +0 -67
  179. package/dist/services/DependencyContainer.d.ts.map +0 -1
  180. package/dist/services/DependencyContainer.js +0 -121
  181. package/dist/services/DependencyContainer.js.map +0 -1
  182. package/dist/services/entity-service-lifecycle.d.ts +0 -12
  183. package/dist/services/entity-service-lifecycle.d.ts.map +0 -1
  184. package/dist/services/entity-service-lifecycle.js +0 -41
  185. package/dist/services/entity-service-lifecycle.js.map +0 -1
  186. package/dist/services/entity.service.d.ts +0 -34
  187. package/dist/services/entity.service.d.ts.map +0 -1
  188. package/dist/services/entity.service.js +0 -120
  189. package/dist/services/entity.service.js.map +0 -1
  190. package/dist/services/mutual.service.d.ts +0 -64
  191. package/dist/services/mutual.service.d.ts.map +0 -1
  192. package/dist/services/mutual.service.js +0 -141
  193. package/dist/services/mutual.service.js.map +0 -1
  194. package/dist/tsconfig.tsbuildinfo +0 -1
  195. package/dist/types/entity.type.d.ts +0 -20
  196. package/dist/types/entity.type.d.ts.map +0 -1
  197. package/dist/types/entity.type.js +0 -2
  198. package/dist/types/entity.type.js.map +0 -1
  199. package/dist/types/event.d.ts +0 -73
  200. package/dist/types/event.d.ts.map +0 -1
  201. package/dist/types/event.js +0 -74
  202. package/dist/types/event.js.map +0 -1
  203. package/dist/vitest.config.d.ts +0 -3
  204. package/dist/vitest.config.d.ts.map +0 -1
  205. package/dist/vitest.config.js +0 -10
  206. package/dist/vitest.config.js.map +0 -1
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@monorise/core",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "scripts": {
9
- "build": "tsc -b",
10
- "dev": "tsc -b --watch",
9
+ "build": "tsup",
10
+ "dev": "tsup --watch",
11
11
  "test": "vitest run"
12
12
  },
13
13
  "files": [
@@ -26,7 +26,7 @@
26
26
  "ulid": "^2.3.0"
27
27
  },
28
28
  "devDependencies": {
29
- "@monorise/base": "^3.0.0",
29
+ "@monorise/base": "^3.0.1",
30
30
  "@types/aws-lambda": "^8.10.147",
31
31
  "vitest": "^3.1.1"
32
32
  },
@@ -1,5 +0,0 @@
1
- import { ENTITY_REPLICATION_INDEX, MUTUAL_REPLICATION_INDEX } from '../constants/table';
2
- declare const CORE_TABLE: string;
3
- declare const CORE_EVENT_BUS: string;
4
- export { CORE_TABLE, CORE_EVENT_BUS, ENTITY_REPLICATION_INDEX, MUTUAL_REPLICATION_INDEX, };
5
- //# sourceMappingURL=service.config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"service.config.d.ts","sourceRoot":"","sources":["../../configs/service.config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACzB,MAAM,oBAAoB,CAAC;AAE5B,QAAA,MAAM,UAAU,QAA+B,CAAC;AAChD,QAAA,MAAM,cAAc,QAAmC,CAAC;AAExD,OAAO,EACL,UAAU,EACV,cAAc,EACd,wBAAwB,EACxB,wBAAwB,GACzB,CAAC"}
@@ -1,5 +0,0 @@
1
- import { ENTITY_REPLICATION_INDEX, MUTUAL_REPLICATION_INDEX, } from '../constants/table';
2
- const CORE_TABLE = process.env.CORE_TABLE || '';
3
- const CORE_EVENT_BUS = process.env.CORE_EVENT_BUS || '';
4
- export { CORE_TABLE, CORE_EVENT_BUS, ENTITY_REPLICATION_INDEX, MUTUAL_REPLICATION_INDEX, };
5
- //# sourceMappingURL=service.config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"service.config.js","sourceRoot":"","sources":["../../configs/service.config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,EAAE,CAAC;AAChD,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,EAAE,CAAC;AAExD,OAAO,EACL,UAAU,EACV,cAAc,EACd,wBAAwB,EACxB,wBAAwB,GACzB,CAAC"}
@@ -1,3 +0,0 @@
1
- export declare const ENTITY_REPLICATION_INDEX = "ENTITY_REPLICATION_INDEX";
2
- export declare const MUTUAL_REPLICATION_INDEX = "MUTUAL_REPLICATION_INDEX";
3
- //# sourceMappingURL=table.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../constants/table.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wBAAwB,6BAA6B,CAAC;AACnE,eAAO,MAAM,wBAAwB,6BAA6B,CAAC"}
@@ -1,3 +0,0 @@
1
- export const ENTITY_REPLICATION_INDEX = 'ENTITY_REPLICATION_INDEX';
2
- export const MUTUAL_REPLICATION_INDEX = 'MUTUAL_REPLICATION_INDEX';
3
- //# sourceMappingURL=table.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"table.js","sourceRoot":"","sources":["../../constants/table.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,wBAAwB,GAAG,0BAA0B,CAAC;AACnE,MAAM,CAAC,MAAM,wBAAwB,GAAG,0BAA0B,CAAC"}
@@ -1,7 +0,0 @@
1
- import type { EntityService } from '../../services/entity.service';
2
- export declare class CreateEntityController {
3
- private entityService;
4
- constructor(entityService: EntityService);
5
- controller: import("hono").MiddlewareHandler<any, string, {}>;
6
- }
7
- //# sourceMappingURL=create-entity.controller.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1,64 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { createMiddleware } from 'hono/factory';
11
- import httpStatus from 'http-status';
12
- import { StandardError, StandardErrorCode } from '../../errors/standard-error';
13
- export class CreateEntityController {
14
- constructor(entityService) {
15
- this.entityService = entityService;
16
- this.controller = createMiddleware((c) => __awaiter(this, void 0, void 0, function* () {
17
- var _a;
18
- const accountId = c.req.header('account-id');
19
- const { entityType } = c.req.param();
20
- const body = yield c.req.json();
21
- try {
22
- const entity = yield this.entityService.createEntity({
23
- entityType,
24
- entityPayload: body,
25
- accountId,
26
- options: {
27
- createAndUpdateDatetime: body.createdAt,
28
- },
29
- });
30
- c.status(httpStatus.OK);
31
- return c.json(entity);
32
- }
33
- catch (err) {
34
- if (((_a = err.constructor) === null || _a === void 0 ? void 0 : _a.name) === 'ZodError') {
35
- c.status(httpStatus.BAD_REQUEST);
36
- return c.json({
37
- code: 'API_VALIDATION_ERROR',
38
- message: 'API validation failed',
39
- details: err.flatten(),
40
- });
41
- }
42
- if (err instanceof StandardError &&
43
- err.code === StandardErrorCode.EMAIL_EXISTS) {
44
- c.status(httpStatus.BAD_REQUEST);
45
- return c.json(Object.assign({}, err.toJSON()));
46
- }
47
- if (err instanceof StandardError &&
48
- err.code === StandardErrorCode.UNIQUE_VALUE_EXISTS) {
49
- c.status(httpStatus.BAD_REQUEST);
50
- return c.json(Object.assign({}, err.toJSON()));
51
- }
52
- console.log('===create-entity error:', {
53
- err,
54
- errorContext: JSON.stringify({
55
- body,
56
- headers: c.req.header(),
57
- }),
58
- });
59
- throw err;
60
- }
61
- }));
62
- }
63
- }
64
- //# sourceMappingURL=create-entity.controller.js.map
@@ -1 +0,0 @@
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,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;YAC7C,MAAM,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,EAEjC,CAAC;YAEF,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;YAEhC,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC;oBACnD,UAAU;oBACV,aAAa,EAAE,IAAI;oBACnB,SAAS;oBACT,OAAO,EAAE;wBACP,uBAAuB,EAAE,IAAI,CAAC,SAAS;qBACxC;iBACF,CAAC,CAAC;gBAEH,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,IAAI,CAAA,MAAC,GAAgB,CAAC,WAAW,0CAAE,IAAI,MAAK,UAAU,EAAE,CAAC;oBACvD,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,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,YAAY,EAC3C,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,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,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,7 +0,0 @@
1
- import type { EntityService } from '../../services/entity.service';
2
- export declare class DeleteEntityController {
3
- private readonly entityService;
4
- constructor(entityService: EntityService);
5
- controller: import("hono").MiddlewareHandler<any, string, {}>;
6
- }
7
- //# sourceMappingURL=delete-entity.controller.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1,38 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { createMiddleware } from 'hono/factory';
11
- import httpStatus from 'http-status';
12
- import { StandardError, StandardErrorCode } from '../../errors/standard-error';
13
- export class DeleteEntityController {
14
- constructor(entityService) {
15
- this.entityService = entityService;
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();
19
- try {
20
- yield this.entityService.deleteEntity({
21
- entityType,
22
- entityId,
23
- accountId,
24
- });
25
- return c.json({ message: 'entity deleted' });
26
- }
27
- catch (err) {
28
- if (err instanceof StandardError &&
29
- err.code === StandardErrorCode.ENTITY_NOT_FOUND) {
30
- c.status(httpStatus.NOT_FOUND);
31
- return c.json(Object.assign({}, err.toJSON()));
32
- }
33
- throw err;
34
- }
35
- }));
36
- }
37
- }
38
- //# sourceMappingURL=delete-entity.controller.js.map
@@ -1 +0,0 @@
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,7 +0,0 @@
1
- import type { EntityRepository } from '../../data/Entity';
2
- export declare class GetEntityByUniqueFieldValueController {
3
- private entityRepository;
4
- constructor(entityRepository: EntityRepository);
5
- controller: import("hono").MiddlewareHandler<any, string, {}>;
6
- }
7
- //# sourceMappingURL=get-entity-by-unique-field-value.controller.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1,36 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { createMiddleware } from 'hono/factory';
11
- import httpStatus from 'http-status';
12
- import { StandardError, StandardErrorCode } from '../../errors/standard-error';
13
- export class GetEntityByUniqueFieldValueController {
14
- constructor(entityRepository) {
15
- this.entityRepository = entityRepository;
16
- this.controller = createMiddleware((c) => __awaiter(this, void 0, void 0, function* () {
17
- const { entityType, uniqueField, uniqueFieldValue } = c.req.param();
18
- try {
19
- const entity = yield this.entityRepository.getEntityByUniqueField(entityType, uniqueField, uniqueFieldValue);
20
- return c.json(entity);
21
- }
22
- catch (err) {
23
- if (err instanceof StandardError &&
24
- err.code === StandardErrorCode.ENTITY_IS_UNDEFINED) {
25
- c.status(httpStatus.NOT_FOUND);
26
- return c.json({
27
- code: 'ENTITY_NOT_FOUND',
28
- message: 'Entity not found',
29
- });
30
- }
31
- throw err;
32
- }
33
- }));
34
- }
35
- }
36
- //# sourceMappingURL=get-entity-by-unique-field-value.controller.js.map
@@ -1 +0,0 @@
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,7 +0,0 @@
1
- import type { EntityRepository } from '../../data/Entity';
2
- export declare class GetEntityController {
3
- private entityRepository;
4
- constructor(entityRepository: EntityRepository);
5
- controller: import("hono").MiddlewareHandler<any, string, {}>;
6
- }
7
- //# sourceMappingURL=get-entity.controller.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1,37 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { createMiddleware } from 'hono/factory';
11
- import httpStatus from 'http-status';
12
- import { StandardError, StandardErrorCode } from '../../errors/standard-error';
13
- export class GetEntityController {
14
- constructor(entityRepository) {
15
- this.entityRepository = entityRepository;
16
- this.controller = createMiddleware((c) => __awaiter(this, void 0, void 0, function* () {
17
- const { entityType, entityId } = c.req.param();
18
- try {
19
- const entity = yield this.entityRepository.getEntity(entityType, entityId);
20
- c.status(httpStatus.OK);
21
- return c.json(entity);
22
- }
23
- catch (err) {
24
- if (err instanceof StandardError &&
25
- err.code === StandardErrorCode.ENTITY_IS_UNDEFINED) {
26
- c.status(httpStatus.NOT_FOUND);
27
- return c.json({
28
- code: 'ENTITY_NOT_FOUND',
29
- message: 'Entity not found',
30
- });
31
- }
32
- throw err;
33
- }
34
- }));
35
- }
36
- }
37
- //# sourceMappingURL=get-entity.controller.js.map
@@ -1 +0,0 @@
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,7 +0,0 @@
1
- import type { EntityRepository } from '../../data/Entity';
2
- export declare class ListEntitiesController {
3
- private entityRepository;
4
- constructor(entityRepository: EntityRepository);
5
- controller: import("hono").MiddlewareHandler<any, string, {}>;
6
- }
7
- //# sourceMappingURL=list-entities.controller.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1,61 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { createMiddleware } from 'hono/factory';
11
- import { z } from 'zod';
12
- const querySchema = z.object({
13
- limit: z.string().optional(),
14
- lastKey: z.string().optional(),
15
- query: z.string().trim().optional(),
16
- start: z.string().optional(),
17
- end: z.string().optional(),
18
- });
19
- export class ListEntitiesController {
20
- constructor(entityRepository) {
21
- this.entityRepository = entityRepository;
22
- this.controller = createMiddleware((c) => __awaiter(this, void 0, void 0, function* () {
23
- const errorContext = {};
24
- try {
25
- const accountId = c.req.header('account-id') || '';
26
- if (Array.isArray(accountId)) {
27
- throw new Error('multiple account-id detected');
28
- }
29
- const params = c.req.param();
30
- const queries = c.req.query();
31
- errorContext.accountId = accountId;
32
- errorContext.params = params;
33
- errorContext.query = queries;
34
- const { entityType } = params;
35
- const { lastKey, query, limit, start, end } = querySchema.parse(queries);
36
- if (query) {
37
- const results = yield this.entityRepository.queryEntities(entityType, query);
38
- return c.json({
39
- data: results.items.map((item) => item.toJSON()),
40
- totalCount: results.totalCount,
41
- filteredCount: results.filteredCount,
42
- });
43
- }
44
- const results = yield this.entityRepository.listEntities(Object.assign({ entityType, limit: Number(limit), options: {
45
- lastKey,
46
- } }, (start && end ? { between: { start, end } } : {})));
47
- return c.json({
48
- data: results.items.map((item) => item.toJSON()),
49
- totalCount: results.totalCount,
50
- lastKey: results.lastKey,
51
- });
52
- }
53
- catch (error) {
54
- console.log({ error, errorContext });
55
- c.status(500);
56
- return c.json({ message: error });
57
- }
58
- }));
59
- }
60
- }
61
- //# sourceMappingURL=list-entities.controller.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"list-entities.controller.js","sourceRoot":"","sources":["../../../controllers/entity/list-entities.controller.ts"],"names":[],"mappings":"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"}
@@ -1,7 +0,0 @@
1
- import type { EntityService } from '../../services/entity.service';
2
- export declare class UpdateEntityController {
3
- private entityService;
4
- constructor(entityService: EntityService);
5
- controller: import("hono").MiddlewareHandler<any, string, {}>;
6
- }
7
- //# sourceMappingURL=update-entity.controller.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1,62 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { createMiddleware } from 'hono/factory';
11
- import httpStatus from 'http-status';
12
- import { StandardError, StandardErrorCode } from '../../errors/standard-error';
13
- export class UpdateEntityController {
14
- constructor(entityService) {
15
- this.entityService = entityService;
16
- this.controller = createMiddleware((c) => __awaiter(this, void 0, void 0, function* () {
17
- var _a;
18
- const accountId = c.req.header('account-id');
19
- const { entityType, entityId } = c.req.param();
20
- const body = yield c.req.json();
21
- const errorContext = {
22
- accountId,
23
- 'req.params': c.req.param(),
24
- 'req.body': body,
25
- };
26
- try {
27
- const entity = yield this.entityService.updateEntity({
28
- entityType,
29
- entityId,
30
- entityPayload: body,
31
- accountId,
32
- });
33
- errorContext.entity = entity;
34
- c.status(httpStatus.OK);
35
- return c.json(entity);
36
- }
37
- catch (err) {
38
- if (((_a = err.constructor) === null || _a === void 0 ? void 0 : _a.name) === 'ZodError') {
39
- c.status(httpStatus.BAD_REQUEST);
40
- return c.json({
41
- code: 'API_VALIDATION_ERROR',
42
- message: 'API validation failed',
43
- details: err.flatten(),
44
- });
45
- }
46
- if (err instanceof StandardError &&
47
- err.code === StandardErrorCode.ENTITY_NOT_FOUND) {
48
- c.status(httpStatus.NOT_FOUND);
49
- return c.json(Object.assign({}, err.toJSON()));
50
- }
51
- if (err instanceof StandardError &&
52
- err.code === StandardErrorCode.UNIQUE_VALUE_EXISTS) {
53
- c.status(httpStatus.BAD_REQUEST);
54
- return c.json(Object.assign({}, err.toJSON()));
55
- }
56
- console.log('====UPDATE_ENTITY_CONTROLLER_ERROR', err, JSON.stringify({ errorContext }, null, 2));
57
- throw err;
58
- }
59
- }));
60
- }
61
- }
62
- //# sourceMappingURL=update-entity.controller.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"update-entity.controller.js","sourceRoot":"","sources":["../../../controllers/entity/update-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,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;YAC7C,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,EAG3C,CAAC;YAEF,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;YAEhC,MAAM,YAAY,GAAQ;gBACxB,SAAS;gBACT,YAAY,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE;gBAC3B,UAAU,EAAE,IAAI;aACjB,CAAC;YAEF,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC;oBACnD,UAAU;oBACV,QAAQ;oBACR,aAAa,EAAE,IAAI;oBACnB,SAAS;iBACV,CAAC,CAAC;gBACH,YAAY,CAAC,MAAM,GAAG,MAAM,CAAC;gBAE7B,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,IAAI,CAAA,MAAC,GAAgB,CAAC,WAAW,0CAAE,IAAI,MAAK,UAAU,EAAE,CAAC;oBACvD,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,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,11 +0,0 @@
1
- import type { Entity, createEntityConfig } from '@monorise/base';
2
- import type { EntityRepository } from '../../data/Entity';
3
- import type { publishEvent as publishEventType } from '../../helpers/event';
4
- export declare class UpsertEntityController {
5
- private EntityConfig;
6
- private entityRepository;
7
- private publishEvent;
8
- constructor(EntityConfig: Record<Entity, ReturnType<typeof createEntityConfig>>, entityRepository: EntityRepository, publishEvent: typeof publishEventType);
9
- controller: import("hono").MiddlewareHandler<any, string, {}>;
10
- }
11
- //# sourceMappingURL=upsert-entity.controller.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1,84 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { createMiddleware } from 'hono/factory';
11
- import httpStatus from 'http-status';
12
- import { ZodError } from 'zod';
13
- import { StandardError, StandardErrorCode } from '../../errors/standard-error';
14
- import { EVENT } from '../../types/event';
15
- export class UpsertEntityController {
16
- constructor(EntityConfig, entityRepository, publishEvent) {
17
- this.EntityConfig = EntityConfig;
18
- this.entityRepository = entityRepository;
19
- this.publishEvent = publishEvent;
20
- this.controller = createMiddleware((c) => __awaiter(this, void 0, void 0, function* () {
21
- var _a, _b;
22
- const accountId = c.req.header('account-id');
23
- const { entityType, entityId } = c.req.param();
24
- try {
25
- const entitySchema = this.EntityConfig[entityType].createSchema ||
26
- this.EntityConfig[entityType].baseSchema;
27
- const mutualSchema = (_a = this.EntityConfig[entityType].mutual) === null || _a === void 0 ? void 0 : _a.mutualSchema;
28
- if (!entitySchema || !mutualSchema) {
29
- throw new StandardError(StandardErrorCode.INVALID_ENTITY_TYPE, 'Invalid entity type');
30
- }
31
- const body = yield c.req.json();
32
- const parsedEntityPayload = entitySchema.parse(body);
33
- const parsedMutualPayload = mutualSchema.parse(body);
34
- const entity = yield this.entityRepository.upsertEntity(entityType, entityId, parsedEntityPayload);
35
- if (parsedMutualPayload) {
36
- const byEntityType = entityType;
37
- const byEntityId = entity.entityId;
38
- const publishEventPromises = [];
39
- for (const [fieldKey, config] of Object.entries(((_b = this.EntityConfig[entityType].mutual) === null || _b === void 0 ? void 0 : _b.mutualFields) || {})) {
40
- publishEventPromises.push(this.publishEvent({
41
- event: EVENT.CORE.ENTITY_MUTUAL_TO_UPDATE,
42
- payload: {
43
- byEntityType,
44
- byEntityId,
45
- entityType: config.entityType,
46
- field: fieldKey,
47
- mutualIds: parsedMutualPayload[fieldKey],
48
- publishedAt: entity.updatedAt || new Date().toISOString(),
49
- },
50
- }));
51
- }
52
- yield Promise.allSettled(publishEventPromises);
53
- }
54
- yield this.publishEvent({
55
- event: EVENT.CORE.ENTITY_UPSERTED,
56
- payload: {
57
- entityType,
58
- entityId: entity.entityId,
59
- payload: body,
60
- createdByAccountId: accountId,
61
- },
62
- });
63
- return c.json(entity);
64
- }
65
- catch (err) {
66
- if (err instanceof ZodError) {
67
- c.status(httpStatus.BAD_REQUEST);
68
- return c.json({
69
- code: 'API_VALIDATION_ERROR',
70
- message: 'API validation failed',
71
- details: err.flatten(),
72
- });
73
- }
74
- if (err instanceof StandardError &&
75
- err.code === StandardErrorCode.EMAIL_EXISTS) {
76
- c.status(httpStatus.BAD_REQUEST);
77
- return c.json(Object.assign({}, err.toJSON()));
78
- }
79
- throw err;
80
- }
81
- }));
82
- }
83
- }
84
- //# sourceMappingURL=upsert-entity.controller.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"upsert-entity.controller.js","sourceRoot":"","sources":["../../../controllers/entity/upsert-entity.controller.ts"],"names":[],"mappings":"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"}
@@ -1,7 +0,0 @@
1
- import type { MutualService } from '../../services/mutual.service';
2
- export declare class CreateMutualController {
3
- private mutualService;
4
- constructor(mutualService: MutualService);
5
- controller: import("hono").MiddlewareHandler<any, string, {}>;
6
- }
7
- //# sourceMappingURL=create-mutual.controller.d.ts.map
@@ -1 +0,0 @@
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"}