@privateaim/server-telemetry-kit 0.8.21 → 0.8.23

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 (108) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/dist/components/event/constants.d.ts +3 -4
  3. package/dist/components/event/constants.d.ts.map +1 -1
  4. package/dist/components/event/handlers/create/types.d.ts +1 -0
  5. package/dist/components/event/handlers/create/types.d.ts.map +1 -1
  6. package/dist/components/event/index.d.ts +2 -0
  7. package/dist/components/event/index.d.ts.map +1 -1
  8. package/dist/components/event/module.d.ts +9 -0
  9. package/dist/components/event/module.d.ts.map +1 -0
  10. package/dist/components/event/singleton.d.ts +4 -0
  11. package/dist/components/event/singleton.d.ts.map +1 -0
  12. package/dist/components/event/types.d.ts +10 -28
  13. package/dist/components/event/types.d.ts.map +1 -1
  14. package/dist/components/log/index.d.ts +2 -0
  15. package/dist/components/log/index.d.ts.map +1 -1
  16. package/dist/components/log/module.d.ts +8 -0
  17. package/dist/components/log/module.d.ts.map +1 -0
  18. package/dist/components/log/singleton.d.ts +4 -0
  19. package/dist/components/log/singleton.d.ts.map +1 -0
  20. package/dist/core/event/subscriber.d.ts.map +1 -1
  21. package/dist/index.mjs +226 -0
  22. package/dist/index.mjs.map +1 -0
  23. package/dist/services/index.d.ts +0 -2
  24. package/dist/services/index.d.ts.map +1 -1
  25. package/package.json +19 -9
  26. package/rollup.config.mjs +14 -0
  27. package/src/components/event/constants.ts +3 -4
  28. package/src/components/event/handlers/create/types.ts +2 -0
  29. package/src/components/event/index.ts +2 -0
  30. package/src/components/event/module.ts +30 -0
  31. package/src/{services → components}/event/singleton.ts +6 -6
  32. package/src/components/event/types.ts +10 -33
  33. package/src/components/log/index.ts +2 -0
  34. package/src/components/log/module.ts +26 -0
  35. package/src/{services → components}/log/singleton.ts +6 -6
  36. package/src/core/event/subscriber.ts +4 -7
  37. package/src/services/index.ts +0 -2
  38. package/src/services/logger/transport.ts +1 -1
  39. package/dist/components/event/constants.js +0 -31
  40. package/dist/components/event/constants.js.map +0 -1
  41. package/dist/components/event/handlers/create/index.js +0 -24
  42. package/dist/components/event/handlers/create/index.js.map +0 -1
  43. package/dist/components/event/handlers/create/types.js +0 -9
  44. package/dist/components/event/handlers/create/types.js.map +0 -1
  45. package/dist/components/event/handlers/index.js +0 -24
  46. package/dist/components/event/handlers/index.js.map +0 -1
  47. package/dist/components/event/index.js +0 -26
  48. package/dist/components/event/index.js.map +0 -1
  49. package/dist/components/event/types.js +0 -9
  50. package/dist/components/event/types.js.map +0 -1
  51. package/dist/components/index.js +0 -25
  52. package/dist/components/index.js.map +0 -1
  53. package/dist/components/log/constants.js +0 -30
  54. package/dist/components/log/constants.js.map +0 -1
  55. package/dist/components/log/handlers/index.js +0 -24
  56. package/dist/components/log/handlers/index.js.map +0 -1
  57. package/dist/components/log/handlers/write/index.js +0 -24
  58. package/dist/components/log/handlers/write/index.js.map +0 -1
  59. package/dist/components/log/handlers/write/types.js +0 -9
  60. package/dist/components/log/handlers/write/types.js.map +0 -1
  61. package/dist/components/log/index.js +0 -26
  62. package/dist/components/log/index.js.map +0 -1
  63. package/dist/components/log/types.js +0 -9
  64. package/dist/components/log/types.js.map +0 -1
  65. package/dist/core/event/index.js +0 -24
  66. package/dist/core/event/index.js.map +0 -1
  67. package/dist/core/event/subscriber.js +0 -86
  68. package/dist/core/event/subscriber.js.map +0 -1
  69. package/dist/core/index.js +0 -24
  70. package/dist/core/index.js.map +0 -1
  71. package/dist/index.js +0 -26
  72. package/dist/index.js.map +0 -1
  73. package/dist/services/event/index.d.ts +0 -3
  74. package/dist/services/event/index.d.ts.map +0 -1
  75. package/dist/services/event/index.js +0 -25
  76. package/dist/services/event/index.js.map +0 -1
  77. package/dist/services/event/module.d.ts +0 -6
  78. package/dist/services/event/module.d.ts.map +0 -1
  79. package/dist/services/event/module.js +0 -47
  80. package/dist/services/event/module.js.map +0 -1
  81. package/dist/services/event/singleton.d.ts +0 -4
  82. package/dist/services/event/singleton.d.ts.map +0 -1
  83. package/dist/services/event/singleton.js +0 -24
  84. package/dist/services/event/singleton.js.map +0 -1
  85. package/dist/services/index.js +0 -26
  86. package/dist/services/index.js.map +0 -1
  87. package/dist/services/log/index.d.ts +0 -3
  88. package/dist/services/log/index.d.ts.map +0 -1
  89. package/dist/services/log/index.js +0 -25
  90. package/dist/services/log/index.js.map +0 -1
  91. package/dist/services/log/module.d.ts +0 -6
  92. package/dist/services/log/module.d.ts.map +0 -1
  93. package/dist/services/log/module.js +0 -50
  94. package/dist/services/log/module.js.map +0 -1
  95. package/dist/services/log/singleton.d.ts +0 -4
  96. package/dist/services/log/singleton.d.ts.map +0 -1
  97. package/dist/services/log/singleton.js +0 -24
  98. package/dist/services/log/singleton.js.map +0 -1
  99. package/dist/services/logger/index.js +0 -25
  100. package/dist/services/logger/index.js.map +0 -1
  101. package/dist/services/logger/transport.js +0 -76
  102. package/dist/services/logger/transport.js.map +0 -1
  103. package/dist/services/logger/type.js +0 -9
  104. package/dist/services/logger/type.js.map +0 -1
  105. package/src/services/event/index.ts +0 -9
  106. package/src/services/event/module.ts +0 -56
  107. package/src/services/log/index.ts +0 -9
  108. package/src/services/log/module.ts +0 -60
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2024.
2
+ * Copyright (c) 2024-2025.
3
3
  * Author Peter Placzek (tada5hi)
4
4
  * For the full copyright and license information,
5
5
  * view the LICENSE file that was distributed with this source code.
@@ -7,17 +7,17 @@
7
7
 
8
8
  import { singa } from 'singa';
9
9
  import { isQueueRouterUsable } from '@privateaim/server-kit';
10
- import { EventComponentService } from './module';
10
+ import { EventComponentCaller } from './module';
11
11
 
12
- const instance = singa<EventComponentService>({
12
+ const instance = singa<EventComponentCaller>({
13
13
  name: 'eventComponentService',
14
- factory: () => new EventComponentService(),
14
+ factory: () => new EventComponentCaller(),
15
15
  });
16
16
 
17
- export function isEventComponentServiceUsable() {
17
+ export function isEventComponentCallerUsable() {
18
18
  return isQueueRouterUsable();
19
19
  }
20
20
 
21
- export function useEventComponentService(): EventComponentService {
21
+ export function useEventComponentCaller(): EventComponentCaller {
22
22
  return instance.use();
23
23
  }
@@ -5,6 +5,9 @@
5
5
  * view the LICENSE file that was distributed with this source code.
6
6
  */
7
7
 
8
+ import type { ObjectLiteralKeys } from '@privateaim/kit';
9
+ import type { ComponentMetadata } from '@privateaim/server-kit';
10
+ import type { Event } from '@privateaim/telemetry-kit';
8
11
  import type { EventCommand, EventEvent } from './constants';
9
12
  import type {
10
13
  EventCreateCommandPayload,
@@ -14,37 +17,11 @@ import type {
14
17
 
15
18
  //-----------------------------------------------------------------------
16
19
 
17
- type TelemetryEventCommandMapRaw = {
18
- [EventCommand.CREATE]: EventCreateCommandPayload,
19
- [EventCommand.CLEAN]: EventCreateCommandPayload,
20
- };
20
+ export type EventComponentEventMap = ObjectLiteralKeys<{
21
+ [EventCommand.CREATE]: [EventCreateCommandPayload, ComponentMetadata],
22
+ [EventCommand.CLEAN]: [EventCreateCommandPayload, ComponentMetadata],
21
23
 
22
- export type EventCommandMap = {
23
- [K in keyof TelemetryEventCommandMapRaw as `${K}`]: TelemetryEventCommandMapRaw[K]
24
- };
25
-
26
- export type EventCommandContext = {
27
- [K in keyof EventCommandMap]: {
28
- command: K,
29
- data: EventCommandMap[K]
30
- }
31
- }[keyof EventCommandMap];
32
-
33
- //-----------------------------------------------------------------------
34
-
35
- type EventEventMapRaw = {
36
- [EventEvent.STARTING]: EventCreateEventPayload,
37
- [EventEvent.STARTED]: EventCreateEventPayload,
38
- [EventEvent.FAILED]: EventCreateFailedEventPayload,
39
- };
40
-
41
- export type EventEventMap = {
42
- [K in keyof EventEventMapRaw as `${K}`]: EventEventMapRaw[K]
43
- };
44
-
45
- export type EventEventContext = {
46
- [K in keyof EventEventMap]: {
47
- event: K,
48
- data: EventEventMap[K]
49
- }
50
- }[keyof EventEventMap];
24
+ [EventEvent.CREATION_STARTED]: [EventCreateEventPayload, ComponentMetadata],
25
+ [EventEvent.CREATION_FINISHED]: [Event, ComponentMetadata],
26
+ [EventEvent.CREATION_FAILED]: [EventCreateFailedEventPayload, ComponentMetadata],
27
+ }>;
@@ -7,4 +7,6 @@
7
7
 
8
8
  export * from './handlers';
9
9
  export * from './constants';
10
+ export * from './module';
11
+ export * from './singleton';
10
12
  export * from './types';
@@ -0,0 +1,26 @@
1
+ /*
2
+ * Copyright (c) 2025-2025.
3
+ * Author Peter Placzek (tada5hi)
4
+ * For the full copyright and license information,
5
+ * view the LICENSE file that was distributed with this source code.
6
+ */
7
+
8
+ import type { ComponentMetadata } from '@privateaim/server-kit';
9
+ import {
10
+ QueueDispatchComponentCaller,
11
+ } from '@privateaim/server-kit';
12
+ import { LogCommand, LogTaskQueueRouterRouting } from './constants';
13
+ import type { LogWriteCommandPayload } from './handlers';
14
+
15
+ export class LogComponentCaller extends QueueDispatchComponentCaller {
16
+ constructor() {
17
+ super({
18
+ queue: LogTaskQueueRouterRouting,
19
+ logging: false,
20
+ });
21
+ }
22
+
23
+ async callWrite(payload: LogWriteCommandPayload, metadata: ComponentMetadata = {}) {
24
+ return this.call(LogCommand.WRITE, payload, metadata);
25
+ }
26
+ }
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2024.
2
+ * Copyright (c) 2024-2025.
3
3
  * Author Peter Placzek (tada5hi)
4
4
  * For the full copyright and license information,
5
5
  * view the LICENSE file that was distributed with this source code.
@@ -7,17 +7,17 @@
7
7
 
8
8
  import { singa } from 'singa';
9
9
  import { isQueueRouterUsable } from '@privateaim/server-kit';
10
- import { LogComponentService } from './module';
10
+ import { LogComponentCaller } from './module';
11
11
 
12
- const instance = singa<LogComponentService>({
12
+ const instance = singa<LogComponentCaller>({
13
13
  name: 'logComponentService',
14
- factory: () => new LogComponentService(),
14
+ factory: () => new LogComponentCaller(),
15
15
  });
16
16
 
17
- export function isLogComponentServiceUsable() {
17
+ export function isLogComponentCallerUsable() {
18
18
  return isQueueRouterUsable();
19
19
  }
20
20
 
21
- export function useLogComponentService(): LogComponentService {
21
+ export function useLogComponentCaller(): LogComponentCaller {
22
22
  return instance.use();
23
23
  }
@@ -12,7 +12,7 @@ import type { Event, EventData } from '@privateaim/telemetry-kit';
12
12
  import { DomainType } from '@privateaim/telemetry-kit';
13
13
  import type { ObjectDiff, ObjectLiteral } from '@privateaim/kit';
14
14
  import { WEEK_IN_MS, isObject } from '@privateaim/kit';
15
- import { isEventComponentServiceUsable, useEventComponentService } from '../../services';
15
+ import { isEventComponentCallerUsable, useEventComponentCaller } from '../../components';
16
16
 
17
17
  export class EntityEventHandler implements IEntityEventHandler {
18
18
  async handle(ctx: EntityEventHandleOptions): Promise<void> {
@@ -93,12 +93,9 @@ export class EntityEventHandler implements IEntityEventHandler {
93
93
 
94
94
  entity.data = data;
95
95
 
96
- if (isEventComponentServiceUsable()) {
97
- const eventService = useEventComponentService();
98
- await eventService.command({
99
- command: 'create',
100
- data: entity,
101
- });
96
+ if (isEventComponentCallerUsable()) {
97
+ const eventService = useEventComponentCaller();
98
+ await eventService.callCreate(entity);
102
99
 
103
100
  return;
104
101
  }
@@ -5,6 +5,4 @@
5
5
  * view the LICENSE file that was distributed with this source code.
6
6
  */
7
7
 
8
- export * from './event';
9
- export * from './log';
10
8
  export * from './logger';
@@ -26,7 +26,7 @@ export class LoggerTransport extends WinstonTransport {
26
26
 
27
27
  Promise.resolve()
28
28
  .then(() => this.save(payload))
29
- .then(() => next());
29
+ .finally(() => next());
30
30
  }
31
31
 
32
32
  protected normalizeInput(info: Record<PropertyKey, any>) : LogInput {
@@ -1,31 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2023-2024.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.EventTaskQueueRouterRouting = exports.EventEventQueueRouterRouting = exports.EventCommand = exports.EventEvent = void 0;
10
- const server_kit_1 = require("@privateaim/server-kit");
11
- var EventEvent;
12
- (function (EventEvent) {
13
- EventEvent["STARTING"] = "starting";
14
- EventEvent["STARTED"] = "started";
15
- EventEvent["FINISHED"] = "finished";
16
- EventEvent["FAILED"] = "failed";
17
- })(EventEvent || (exports.EventEvent = EventEvent = {}));
18
- var EventCommand;
19
- (function (EventCommand) {
20
- EventCommand["CREATE"] = "create";
21
- EventCommand["CLEAN"] = "clean";
22
- })(EventCommand || (exports.EventCommand = EventCommand = {}));
23
- exports.EventEventQueueRouterRouting = {
24
- type: server_kit_1.QueueRouterRoutingType.PUB_SUB,
25
- key: 'telemetryEventEvents',
26
- };
27
- exports.EventTaskQueueRouterRouting = {
28
- type: server_kit_1.QueueRouterRoutingType.WORK,
29
- key: 'telemetryEventTasks',
30
- };
31
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/components/event/constants.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,uDAAgE;AAEhE,IAAY,UAKX;AALD,WAAY,UAAU;IAClB,mCAAqB,CAAA;IACrB,iCAAmB,CAAA;IACnB,mCAAqB,CAAA;IACrB,+BAAiB,CAAA;AACrB,CAAC,EALW,UAAU,0BAAV,UAAU,QAKrB;AAED,IAAY,YAGX;AAHD,WAAY,YAAY;IACpB,iCAAiB,CAAA;IACjB,+BAAe,CAAA;AACnB,CAAC,EAHW,YAAY,4BAAZ,YAAY,QAGvB;AAEY,QAAA,4BAA4B,GAAG;IACxC,IAAI,EAAE,mCAAsB,CAAC,OAAO;IACpC,GAAG,EAAE,sBAAsB;CAC9B,CAAC;AAEW,QAAA,2BAA2B,GAAG;IACvC,IAAI,EAAE,mCAAsB,CAAC,IAAI;IACjC,GAAG,EAAE,qBAAqB;CAC7B,CAAC"}
@@ -1,24 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2025.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
- if (k2 === undefined) k2 = k;
10
- var desc = Object.getOwnPropertyDescriptor(m, k);
11
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
- desc = { enumerable: true, get: function() { return m[k]; } };
13
- }
14
- Object.defineProperty(o, k2, desc);
15
- }) : (function(o, m, k, k2) {
16
- if (k2 === undefined) k2 = k;
17
- o[k2] = m[k];
18
- }));
19
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
- };
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- __exportStar(require("./types"), exports);
24
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/components/event/handlers/create/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,0CAAwB"}
@@ -1,9 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2025.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/components/event/handlers/create/types.ts"],"names":[],"mappings":";AAAA;;;;;GAKG"}
@@ -1,24 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2025.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
- if (k2 === undefined) k2 = k;
10
- var desc = Object.getOwnPropertyDescriptor(m, k);
11
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
- desc = { enumerable: true, get: function() { return m[k]; } };
13
- }
14
- Object.defineProperty(o, k2, desc);
15
- }) : (function(o, m, k, k2) {
16
- if (k2 === undefined) k2 = k;
17
- o[k2] = m[k];
18
- }));
19
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
- };
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- __exportStar(require("./create"), exports);
24
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/event/handlers/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,2CAAyB"}
@@ -1,26 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2025.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
- if (k2 === undefined) k2 = k;
10
- var desc = Object.getOwnPropertyDescriptor(m, k);
11
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
- desc = { enumerable: true, get: function() { return m[k]; } };
13
- }
14
- Object.defineProperty(o, k2, desc);
15
- }) : (function(o, m, k, k2) {
16
- if (k2 === undefined) k2 = k;
17
- o[k2] = m[k];
18
- }));
19
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
- };
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- __exportStar(require("./handlers"), exports);
24
- __exportStar(require("./constants"), exports);
25
- __exportStar(require("./types"), exports);
26
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/event/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,6CAA2B;AAC3B,8CAA4B;AAC5B,0CAAwB"}
@@ -1,9 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2023-2024.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/event/types.ts"],"names":[],"mappings":";AAAA;;;;;GAKG"}
@@ -1,25 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2025.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
- if (k2 === undefined) k2 = k;
10
- var desc = Object.getOwnPropertyDescriptor(m, k);
11
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
- desc = { enumerable: true, get: function() { return m[k]; } };
13
- }
14
- Object.defineProperty(o, k2, desc);
15
- }) : (function(o, m, k, k2) {
16
- if (k2 === undefined) k2 = k;
17
- o[k2] = m[k];
18
- }));
19
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
- };
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- __exportStar(require("./event"), exports);
24
- __exportStar(require("./log"), exports);
25
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,0CAAwB;AACxB,wCAAsB"}
@@ -1,30 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2023-2024.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.LogTaskQueueRouterRouting = exports.LogEventQueueRouterRouting = exports.LogCommand = exports.LogEvent = void 0;
10
- const server_kit_1 = require("@privateaim/server-kit");
11
- var LogEvent;
12
- (function (LogEvent) {
13
- LogEvent["STARTING"] = "starting";
14
- LogEvent["STARTED"] = "started";
15
- LogEvent["FINISHED"] = "finished";
16
- LogEvent["FAILED"] = "failed";
17
- })(LogEvent || (exports.LogEvent = LogEvent = {}));
18
- var LogCommand;
19
- (function (LogCommand) {
20
- LogCommand["WRITE"] = "write";
21
- })(LogCommand || (exports.LogCommand = LogCommand = {}));
22
- exports.LogEventQueueRouterRouting = {
23
- type: server_kit_1.QueueRouterRoutingType.PUB_SUB,
24
- key: 'telemetryLogEvents',
25
- };
26
- exports.LogTaskQueueRouterRouting = {
27
- type: server_kit_1.QueueRouterRoutingType.WORK,
28
- key: 'telemetryLogTasks',
29
- };
30
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/components/log/constants.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,uDAAgE;AAEhE,IAAY,QAKX;AALD,WAAY,QAAQ;IAChB,iCAAqB,CAAA;IACrB,+BAAmB,CAAA;IACnB,iCAAqB,CAAA;IACrB,6BAAiB,CAAA;AACrB,CAAC,EALW,QAAQ,wBAAR,QAAQ,QAKnB;AAED,IAAY,UAEX;AAFD,WAAY,UAAU;IAClB,6BAAe,CAAA;AACnB,CAAC,EAFW,UAAU,0BAAV,UAAU,QAErB;AAEY,QAAA,0BAA0B,GAAG;IACtC,IAAI,EAAE,mCAAsB,CAAC,OAAO;IACpC,GAAG,EAAE,oBAAoB;CAC5B,CAAC;AAEW,QAAA,yBAAyB,GAAG;IACrC,IAAI,EAAE,mCAAsB,CAAC,IAAI;IACjC,GAAG,EAAE,mBAAmB;CAC3B,CAAC"}
@@ -1,24 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2025.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
- if (k2 === undefined) k2 = k;
10
- var desc = Object.getOwnPropertyDescriptor(m, k);
11
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
- desc = { enumerable: true, get: function() { return m[k]; } };
13
- }
14
- Object.defineProperty(o, k2, desc);
15
- }) : (function(o, m, k, k2) {
16
- if (k2 === undefined) k2 = k;
17
- o[k2] = m[k];
18
- }));
19
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
- };
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- __exportStar(require("./write"), exports);
24
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/log/handlers/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,0CAAwB"}
@@ -1,24 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2025.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
- if (k2 === undefined) k2 = k;
10
- var desc = Object.getOwnPropertyDescriptor(m, k);
11
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
- desc = { enumerable: true, get: function() { return m[k]; } };
13
- }
14
- Object.defineProperty(o, k2, desc);
15
- }) : (function(o, m, k, k2) {
16
- if (k2 === undefined) k2 = k;
17
- o[k2] = m[k];
18
- }));
19
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
- };
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- __exportStar(require("./types"), exports);
24
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/components/log/handlers/write/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,0CAAwB"}
@@ -1,9 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2025.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/components/log/handlers/write/types.ts"],"names":[],"mappings":";AAAA;;;;;GAKG"}
@@ -1,26 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2025.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
- if (k2 === undefined) k2 = k;
10
- var desc = Object.getOwnPropertyDescriptor(m, k);
11
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
- desc = { enumerable: true, get: function() { return m[k]; } };
13
- }
14
- Object.defineProperty(o, k2, desc);
15
- }) : (function(o, m, k, k2) {
16
- if (k2 === undefined) k2 = k;
17
- o[k2] = m[k];
18
- }));
19
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
- };
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- __exportStar(require("./handlers"), exports);
24
- __exportStar(require("./constants"), exports);
25
- __exportStar(require("./types"), exports);
26
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/log/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,6CAA2B;AAC3B,8CAA4B;AAC5B,0CAAwB"}
@@ -1,9 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2023-2024.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/log/types.ts"],"names":[],"mappings":";AAAA;;;;;GAKG"}
@@ -1,24 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2025.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
- if (k2 === undefined) k2 = k;
10
- var desc = Object.getOwnPropertyDescriptor(m, k);
11
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
- desc = { enumerable: true, get: function() { return m[k]; } };
13
- }
14
- Object.defineProperty(o, k2, desc);
15
- }) : (function(o, m, k, k2) {
16
- if (k2 === undefined) k2 = k;
17
- o[k2] = m[k];
18
- }));
19
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
- };
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- __exportStar(require("./subscriber"), exports);
24
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/event/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,+CAA6B"}
@@ -1,86 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2025.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.EntityEventHandler = void 0;
10
- const smob_1 = require("smob");
11
- const server_kit_1 = require("@privateaim/server-kit");
12
- const telemetry_kit_1 = require("@privateaim/telemetry-kit");
13
- const kit_1 = require("@privateaim/kit");
14
- const services_1 = require("../../services");
15
- class EntityEventHandler {
16
- async handle(ctx) {
17
- if (ctx.metadata.ref_type === telemetry_kit_1.DomainType.EVENT) {
18
- return;
19
- }
20
- const entity = {
21
- ref_type: ctx.metadata.ref_type,
22
- name: ctx.metadata.event,
23
- scope: 'entity',
24
- expiring: true,
25
- expires_at: new Date(Date.now() + kit_1.WEEK_IN_MS).toISOString(),
26
- };
27
- if (ctx.metadata.ref_id) {
28
- entity.ref_id = ctx.metadata.ref_id;
29
- }
30
- const keys = [
31
- 'actor_id',
32
- 'actor_type',
33
- 'actor_name',
34
- 'request_path',
35
- 'request_method',
36
- 'request_ip_address',
37
- 'request_user_agent',
38
- ];
39
- for (let i = 0; i < keys.length; i++) {
40
- if (ctx.metadata[keys[i]]) {
41
- entity[keys[i]] = ctx.metadata[keys[i]];
42
- }
43
- }
44
- if (entity.request_ip_address &&
45
- entity.request_ip_address === '::1') {
46
- entity.request_ip_address = '127.0.0.1';
47
- }
48
- const data = {};
49
- if (
50
- // todo: use enum
51
- ctx.metadata.event === 'updated' &&
52
- ctx.dataPrevious) {
53
- const diff = {};
54
- const keys = Object.keys(ctx.data);
55
- for (let i = 0; i < keys.length; i++) {
56
- const key = keys[i];
57
- // skip date changes
58
- if (key.endsWith('_at')) {
59
- continue;
60
- }
61
- if ((0, kit_1.isObject)(ctx.data[key]) || Array.isArray(ctx.data[key])) {
62
- continue;
63
- }
64
- if (!(0, smob_1.isEqual)(ctx.data[key], ctx.dataPrevious[key])) {
65
- diff[key] = {
66
- next: ctx.data[key],
67
- previous: ctx.dataPrevious[key],
68
- };
69
- }
70
- }
71
- data.diff = diff;
72
- }
73
- entity.data = data;
74
- if ((0, services_1.isEventComponentServiceUsable)()) {
75
- const eventService = (0, services_1.useEventComponentService)();
76
- await eventService.command({
77
- command: 'create',
78
- data: entity,
79
- });
80
- return;
81
- }
82
- (0, server_kit_1.useLogger)().debug('Event service is not available to publish events.');
83
- }
84
- }
85
- exports.EntityEventHandler = EntityEventHandler;
86
- //# sourceMappingURL=subscriber.js.map