@hed-hog/core 0.0.295 → 0.0.296

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 (144) hide show
  1. package/dist/auth/auth.controller.d.ts +4 -4
  2. package/dist/auth/auth.service.d.ts +4 -4
  3. package/dist/challenge/challenge.service.d.ts +2 -2
  4. package/dist/core.module.d.ts.map +1 -1
  5. package/dist/core.module.js +4 -1
  6. package/dist/core.module.js.map +1 -1
  7. package/dist/dashboard/dashboard-core/dashboard-core.controller.d.ts +1 -1
  8. package/dist/dashboard/dashboard-core/dashboard-core.service.d.ts +2 -2
  9. package/dist/index.d.ts +13 -0
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +14 -0
  12. package/dist/index.js.map +1 -1
  13. package/dist/integration/index.d.ts +4 -0
  14. package/dist/integration/index.d.ts.map +1 -0
  15. package/dist/integration/index.js +20 -0
  16. package/dist/integration/index.js.map +1 -0
  17. package/dist/integration/integration-api.validation.d.ts +2 -0
  18. package/dist/integration/integration-api.validation.d.ts.map +1 -0
  19. package/dist/integration/integration-api.validation.js +126 -0
  20. package/dist/integration/integration-api.validation.js.map +1 -0
  21. package/dist/integration/integration.module.d.ts +3 -0
  22. package/dist/integration/integration.module.d.ts.map +1 -0
  23. package/dist/integration/integration.module.js +54 -0
  24. package/dist/integration/integration.module.js.map +1 -0
  25. package/dist/integration/services/domain-event.publisher.d.ts +31 -0
  26. package/dist/integration/services/domain-event.publisher.d.ts.map +1 -0
  27. package/dist/integration/services/domain-event.publisher.js +79 -0
  28. package/dist/integration/services/domain-event.publisher.js.map +1 -0
  29. package/dist/integration/services/event-subscriber.registry.d.ts +37 -0
  30. package/dist/integration/services/event-subscriber.registry.d.ts.map +1 -0
  31. package/dist/integration/services/event-subscriber.registry.js +86 -0
  32. package/dist/integration/services/event-subscriber.registry.js.map +1 -0
  33. package/dist/integration/services/inbox.service.d.ts +55 -0
  34. package/dist/integration/services/inbox.service.d.ts.map +1 -0
  35. package/dist/integration/services/inbox.service.js +173 -0
  36. package/dist/integration/services/inbox.service.js.map +1 -0
  37. package/dist/integration/services/index.d.ts +12 -0
  38. package/dist/integration/services/index.d.ts.map +1 -0
  39. package/dist/integration/services/index.js +28 -0
  40. package/dist/integration/services/index.js.map +1 -0
  41. package/dist/integration/services/integration-developer-api.service.d.ts +30 -0
  42. package/dist/integration/services/integration-developer-api.service.d.ts.map +1 -0
  43. package/dist/integration/services/integration-developer-api.service.js +55 -0
  44. package/dist/integration/services/integration-developer-api.service.js.map +1 -0
  45. package/dist/integration/services/integration-link.service.d.ts +52 -0
  46. package/dist/integration/services/integration-link.service.d.ts.map +1 -0
  47. package/dist/integration/services/integration-link.service.js +128 -0
  48. package/dist/integration/services/integration-link.service.js.map +1 -0
  49. package/dist/integration/services/integration-settings.service.d.ts +23 -0
  50. package/dist/integration/services/integration-settings.service.d.ts.map +1 -0
  51. package/dist/integration/services/integration-settings.service.js +81 -0
  52. package/dist/integration/services/integration-settings.service.js.map +1 -0
  53. package/dist/integration/services/outbox-polling.coordinator.d.ts +45 -0
  54. package/dist/integration/services/outbox-polling.coordinator.d.ts.map +1 -0
  55. package/dist/integration/services/outbox-polling.coordinator.js +143 -0
  56. package/dist/integration/services/outbox-polling.coordinator.js.map +1 -0
  57. package/dist/integration/services/outbox.notifier.d.ts +30 -0
  58. package/dist/integration/services/outbox.notifier.d.ts.map +1 -0
  59. package/dist/integration/services/outbox.notifier.js +57 -0
  60. package/dist/integration/services/outbox.notifier.js.map +1 -0
  61. package/dist/integration/services/outbox.processor.d.ts +42 -0
  62. package/dist/integration/services/outbox.processor.d.ts.map +1 -0
  63. package/dist/integration/services/outbox.processor.job.d.ts +43 -0
  64. package/dist/integration/services/outbox.processor.job.d.ts.map +1 -0
  65. package/dist/integration/services/outbox.processor.job.js +100 -0
  66. package/dist/integration/services/outbox.processor.job.js.map +1 -0
  67. package/dist/integration/services/outbox.processor.js +208 -0
  68. package/dist/integration/services/outbox.processor.js.map +1 -0
  69. package/dist/integration/services/outbox.service.d.ts +53 -0
  70. package/dist/integration/services/outbox.service.d.ts.map +1 -0
  71. package/dist/integration/services/outbox.service.js +149 -0
  72. package/dist/integration/services/outbox.service.js.map +1 -0
  73. package/dist/integration/types/event.types.d.ts +88 -0
  74. package/dist/integration/types/event.types.d.ts.map +1 -0
  75. package/dist/integration/types/event.types.js +35 -0
  76. package/dist/integration/types/event.types.js.map +1 -0
  77. package/dist/integration/types/index.d.ts +3 -0
  78. package/dist/integration/types/index.d.ts.map +1 -0
  79. package/dist/integration/types/index.js +19 -0
  80. package/dist/integration/types/index.js.map +1 -0
  81. package/dist/integration/types/subscriber.types.d.ts +31 -0
  82. package/dist/integration/types/subscriber.types.d.ts.map +1 -0
  83. package/dist/integration/types/subscriber.types.js +3 -0
  84. package/dist/integration/types/subscriber.types.js.map +1 -0
  85. package/dist/oauth/oauth.controller.js.map +1 -1
  86. package/dist/oauth/oauth.service.d.ts +3 -3
  87. package/dist/oauth/oauth.service.d.ts.map +1 -1
  88. package/dist/oauth/oauth.service.js.map +1 -1
  89. package/dist/profile/profile.controller.d.ts +3 -3
  90. package/dist/profile/profile.service.d.ts +3 -3
  91. package/dist/setting/setting.controller.d.ts +12 -8
  92. package/dist/setting/setting.controller.d.ts.map +1 -1
  93. package/dist/setting/setting.service.d.ts +12 -8
  94. package/dist/setting/setting.service.d.ts.map +1 -1
  95. package/dist/setting/setting.service.js +21 -1
  96. package/dist/setting/setting.service.js.map +1 -1
  97. package/dist/user/user.controller.d.ts +4 -4
  98. package/dist/user/user.service.d.ts +9 -9
  99. package/hedhog/data/dashboard_component_role.yaml +223 -223
  100. package/hedhog/data/dashboard_role.yaml +18 -18
  101. package/hedhog/data/route.yaml +2 -0
  102. package/hedhog/data/setting_group.yaml +955 -470
  103. package/hedhog/data/setting_subgroup.yaml +303 -0
  104. package/hedhog/frontend/app/configurations/[slug]/components/setting-field.tsx.ejs +44 -18
  105. package/hedhog/frontend/app/configurations/[slug]/page.tsx.ejs +134 -27
  106. package/hedhog/frontend/app/configurations/layout.tsx.ejs +84 -23
  107. package/hedhog/frontend/app/dashboard/components/widgets/permissions-chart.tsx.ejs +62 -62
  108. package/hedhog/frontend/app/dashboard/page.tsx.ejs +29 -29
  109. package/hedhog/frontend/app/preferences/page.tsx.ejs +2 -5
  110. package/hedhog/table/inbox_event.yaml +40 -0
  111. package/hedhog/table/integration_link.yaml +33 -0
  112. package/hedhog/table/outbox_event.yaml +45 -0
  113. package/hedhog/table/setting.yaml +7 -0
  114. package/hedhog/table/setting_subgroup.yaml +19 -0
  115. package/package.json +8 -8
  116. package/src/ai/ai.service.ts +3 -3
  117. package/src/auth/auth.controller.ts +11 -11
  118. package/src/auth/auth.service.ts +8 -8
  119. package/src/core.module.ts +4 -1
  120. package/src/index.ts +15 -0
  121. package/src/integration/README.md +397 -0
  122. package/src/integration/USAGE_EXAMPLE.md +279 -0
  123. package/src/integration/index.ts +4 -0
  124. package/src/integration/integration-api.validation.ts +154 -0
  125. package/src/integration/integration.module.ts +53 -0
  126. package/src/integration/services/domain-event.publisher.ts +136 -0
  127. package/src/integration/services/event-subscriber.registry.ts +89 -0
  128. package/src/integration/services/inbox.service.ts +218 -0
  129. package/src/integration/services/index.ts +12 -0
  130. package/src/integration/services/integration-developer-api.service.ts +96 -0
  131. package/src/integration/services/integration-link.service.ts +154 -0
  132. package/src/integration/services/integration-settings.service.ts +128 -0
  133. package/src/integration/services/outbox-polling.coordinator.ts +146 -0
  134. package/src/integration/services/outbox.notifier.ts +48 -0
  135. package/src/integration/services/outbox.processor.job.ts +97 -0
  136. package/src/integration/services/outbox.processor.ts +266 -0
  137. package/src/integration/services/outbox.service.ts +209 -0
  138. package/src/integration/types/event.types.ts +93 -0
  139. package/src/integration/types/index.ts +3 -0
  140. package/src/integration/types/subscriber.types.ts +37 -0
  141. package/src/oauth/oauth.controller.ts +17 -17
  142. package/src/oauth/oauth.service.ts +20 -20
  143. package/src/setting/setting.service.ts +27 -2
  144. package/src/task/task.service.ts +5 -5
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.IntegrationLinkService = void 0;
13
+ const api_prisma_1 = require("@hed-hog/api-prisma");
14
+ const common_1 = require("@nestjs/common");
15
+ let IntegrationLinkService = class IntegrationLinkService {
16
+ constructor(prisma) {
17
+ this.prisma = prisma;
18
+ }
19
+ /**
20
+ * Create a link between entities from different modules
21
+ */
22
+ async createLink(dto, persistenceClient) {
23
+ const client = persistenceClient !== null && persistenceClient !== void 0 ? persistenceClient : this.prisma;
24
+ return client.integrationLink.create({
25
+ data: {
26
+ sourceModule: dto.sourceModule,
27
+ sourceEntityType: dto.sourceEntityType,
28
+ sourceEntityId: dto.sourceEntityId,
29
+ targetModule: dto.targetModule,
30
+ targetEntityType: dto.targetEntityType,
31
+ targetEntityId: dto.targetEntityId,
32
+ linkType: dto.linkType,
33
+ metadata: dto.metadata || null,
34
+ },
35
+ });
36
+ }
37
+ /**
38
+ * Find all links originating from a source entity
39
+ */
40
+ async findOutbound(sourceModule, sourceEntityType, sourceEntityId) {
41
+ return this.prisma.integrationLink.findMany({
42
+ where: {
43
+ sourceModule,
44
+ sourceEntityType,
45
+ sourceEntityId,
46
+ },
47
+ });
48
+ }
49
+ /**
50
+ * Find all links terminating at a target entity
51
+ */
52
+ async findInbound(targetModule, targetEntityType, targetEntityId) {
53
+ return this.prisma.integrationLink.findMany({
54
+ where: {
55
+ targetModule,
56
+ targetEntityType,
57
+ targetEntityId,
58
+ },
59
+ });
60
+ }
61
+ /**
62
+ * Find links of a specific type
63
+ */
64
+ async findByLinkType(linkType) {
65
+ return this.prisma.integrationLink.findMany({
66
+ where: { linkType },
67
+ });
68
+ }
69
+ /**
70
+ * Delete a link
71
+ */
72
+ async deleteLink(linkId) {
73
+ return this.prisma.integrationLink.delete({
74
+ where: { id: linkId },
75
+ });
76
+ }
77
+ /**
78
+ * Get link by ID
79
+ */
80
+ async getById(linkId) {
81
+ return this.prisma.integrationLink.findUnique({
82
+ where: { id: linkId },
83
+ });
84
+ }
85
+ /**
86
+ * Find bidirectional link between two entities
87
+ */
88
+ async findBidirectional(module1, entity1Type, entity1Id, module2, entity2Type, entity2Id) {
89
+ // Look for forward or reverse direction
90
+ const link = await this.prisma.integrationLink.findFirst({
91
+ where: {
92
+ OR: [
93
+ {
94
+ sourceModule: module1,
95
+ sourceEntityType: entity1Type,
96
+ sourceEntityId: entity1Id,
97
+ targetModule: module2,
98
+ targetEntityType: entity2Type,
99
+ targetEntityId: entity2Id,
100
+ },
101
+ {
102
+ sourceModule: module2,
103
+ sourceEntityType: entity2Type,
104
+ sourceEntityId: entity2Id,
105
+ targetModule: module1,
106
+ targetEntityType: entity1Type,
107
+ targetEntityId: entity1Id,
108
+ },
109
+ ],
110
+ },
111
+ });
112
+ return link;
113
+ }
114
+ /**
115
+ * Count links from a module
116
+ */
117
+ async countFromModule(sourceModule) {
118
+ return this.prisma.integrationLink.count({
119
+ where: { sourceModule },
120
+ });
121
+ }
122
+ };
123
+ exports.IntegrationLinkService = IntegrationLinkService;
124
+ exports.IntegrationLinkService = IntegrationLinkService = __decorate([
125
+ (0, common_1.Injectable)(),
126
+ __metadata("design:paramtypes", [api_prisma_1.PrismaService])
127
+ ], IntegrationLinkService);
128
+ //# sourceMappingURL=integration-link.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integration-link.service.js","sourceRoot":"","sources":["../../../src/integration/services/integration-link.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAoD;AACpD,2CAA4C;AAmBrC,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IACjC,YAA6B,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;IAAG,CAAC;IAEtD;;OAEG;IACH,KAAK,CAAC,UAAU,CACd,GAA6B,EAC7B,iBAAoD;QAEpD,MAAM,MAAM,GAAG,iBAAiB,aAAjB,iBAAiB,cAAjB,iBAAiB,GAAI,IAAI,CAAC,MAAM,CAAC;QAEhD,OAAO,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC;YACnC,IAAI,EAAE;gBACJ,YAAY,EAAE,GAAG,CAAC,YAAY;gBAC9B,gBAAgB,EAAE,GAAG,CAAC,gBAAgB;gBACtC,cAAc,EAAE,GAAG,CAAC,cAAc;gBAClC,YAAY,EAAE,GAAG,CAAC,YAAY;gBAC9B,gBAAgB,EAAE,GAAG,CAAC,gBAAgB;gBACtC,cAAc,EAAE,GAAG,CAAC,cAAc;gBAClC,QAAQ,EAAE,GAAG,CAAC,QAAQ;gBACtB,QAAQ,EAAE,GAAG,CAAC,QAAQ,IAAI,IAAI;aAC/B;SACF,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,YAAY,CAChB,YAAoB,EACpB,gBAAwB,EACxB,cAAsB;QAEtB,OAAO,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,QAAQ,CAAC;YAC1C,KAAK,EAAE;gBACL,YAAY;gBACZ,gBAAgB;gBAChB,cAAc;aACf;SACF,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW,CACf,YAAoB,EACpB,gBAAwB,EACxB,cAAsB;QAEtB,OAAO,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,QAAQ,CAAC;YAC1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;SACF,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,eAAe,CAAC,YAAoB;QACxC,OAAO,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC;YACvC,KAAK,EAAE,EAAE,YAAY,EAAE;SACxB,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AArIY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,mBAAU,GAAE;qCAE0B,0BAAa;GADvC,sBAAsB,CAqIlC"}
@@ -0,0 +1,23 @@
1
+ import { SettingService } from '../../setting/setting.service';
2
+ export interface IntegrationRuntimeSettings {
3
+ outboxEnabled: boolean;
4
+ outboxProcessorEnabled: boolean;
5
+ startupDrainEnabled: boolean;
6
+ pollingIntervalMs: number;
7
+ idlePollingIntervalMs: number;
8
+ batchSize: number;
9
+ startupDrainBatchSize: number;
10
+ maxAttempts: number;
11
+ processingLeaseMs: number;
12
+ retryBaseDelayMs: number;
13
+ deadLetterEnabled: boolean;
14
+ }
15
+ export declare class IntegrationSettingsService {
16
+ private readonly settingService;
17
+ private readonly logger;
18
+ constructor(settingService: SettingService);
19
+ getRuntimeSettings(): Promise<IntegrationRuntimeSettings>;
20
+ private getPositiveInt;
21
+ private getBoolean;
22
+ }
23
+ //# sourceMappingURL=integration-settings.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integration-settings.service.d.ts","sourceRoot":"","sources":["../../../src/integration/services/integration-settings.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,MAAM,WAAW,0BAA0B;IACzC,aAAa,EAAE,OAAO,CAAC;IACvB,sBAAsB,EAAE,OAAO,CAAC;IAChC,mBAAmB,EAAE,OAAO,CAAC;IAC7B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,OAAO,CAAC;CAC5B;AAED,qBACa,0BAA0B;IAGzB,OAAO,CAAC,QAAQ,CAAC,cAAc;IAF3C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA+C;gBAEzC,cAAc,EAAE,cAAc;IAErD,kBAAkB,IAAI,OAAO,CAAC,0BAA0B,CAAC;IAwE/D,OAAO,CAAC,cAAc;IAiBtB,OAAO,CAAC,UAAU;CAenB"}
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var IntegrationSettingsService_1;
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.IntegrationSettingsService = void 0;
14
+ const common_1 = require("@nestjs/common");
15
+ const setting_service_1 = require("../../setting/setting.service");
16
+ let IntegrationSettingsService = IntegrationSettingsService_1 = class IntegrationSettingsService {
17
+ constructor(settingService) {
18
+ this.settingService = settingService;
19
+ this.logger = new common_1.Logger(IntegrationSettingsService_1.name);
20
+ }
21
+ async getRuntimeSettings() {
22
+ const values = await this.settingService.getSettingValues([
23
+ 'outbox-enabled',
24
+ 'outbox-processor-enabled',
25
+ 'outbox-startup-drain-enabled',
26
+ 'outbox-polling-interval-ms',
27
+ 'outbox-idle-polling-interval-ms',
28
+ 'outbox-batch-size',
29
+ 'outbox-startup-drain-batch-size',
30
+ 'outbox-max-attempts',
31
+ 'outbox-processing-lease-ms',
32
+ 'outbox-retry-base-delay-ms',
33
+ 'outbox-dead-letter-enabled',
34
+ ]);
35
+ const pollingIntervalMs = this.getPositiveInt(values['outbox-polling-interval-ms'], 5000, 100, 'outbox-polling-interval-ms');
36
+ let idlePollingIntervalMs = this.getPositiveInt(values['outbox-idle-polling-interval-ms'], 30000, 100, 'outbox-idle-polling-interval-ms');
37
+ if (idlePollingIntervalMs < pollingIntervalMs) {
38
+ this.logger.warn(`Setting outbox-idle-polling-interval-ms (${idlePollingIntervalMs}) is lower than outbox-polling-interval-ms (${pollingIntervalMs}). Using ${pollingIntervalMs}.`);
39
+ idlePollingIntervalMs = pollingIntervalMs;
40
+ }
41
+ return {
42
+ outboxEnabled: this.getBoolean(values['outbox-enabled'], true),
43
+ outboxProcessorEnabled: this.getBoolean(values['outbox-processor-enabled'], true),
44
+ startupDrainEnabled: this.getBoolean(values['outbox-startup-drain-enabled'], true),
45
+ pollingIntervalMs,
46
+ idlePollingIntervalMs,
47
+ batchSize: this.getPositiveInt(values['outbox-batch-size'], 10, 1, 'outbox-batch-size'),
48
+ startupDrainBatchSize: this.getPositiveInt(values['outbox-startup-drain-batch-size'], 50, 1, 'outbox-startup-drain-batch-size'),
49
+ maxAttempts: this.getPositiveInt(values['outbox-max-attempts'], 3, 1, 'outbox-max-attempts'),
50
+ processingLeaseMs: this.getPositiveInt(values['outbox-processing-lease-ms'], 30000, 1000, 'outbox-processing-lease-ms'),
51
+ retryBaseDelayMs: this.getPositiveInt(values['outbox-retry-base-delay-ms'], 1000, 100, 'outbox-retry-base-delay-ms'),
52
+ deadLetterEnabled: this.getBoolean(values['outbox-dead-letter-enabled'], true),
53
+ };
54
+ }
55
+ getPositiveInt(value, fallback, min, slug) {
56
+ const parsed = Number(value);
57
+ if (!Number.isFinite(parsed) || parsed < min) {
58
+ this.logger.warn(`Invalid ${slug} setting value (${String(value)}). Using fallback ${fallback}.`);
59
+ return fallback;
60
+ }
61
+ return Math.floor(parsed);
62
+ }
63
+ getBoolean(value, fallback) {
64
+ if (typeof value === 'boolean') {
65
+ return value;
66
+ }
67
+ if (value === 'true' || value === '1') {
68
+ return true;
69
+ }
70
+ if (value === 'false' || value === '0') {
71
+ return false;
72
+ }
73
+ return fallback;
74
+ }
75
+ };
76
+ exports.IntegrationSettingsService = IntegrationSettingsService;
77
+ exports.IntegrationSettingsService = IntegrationSettingsService = IntegrationSettingsService_1 = __decorate([
78
+ (0, common_1.Injectable)(),
79
+ __metadata("design:paramtypes", [setting_service_1.SettingService])
80
+ ], IntegrationSettingsService);
81
+ //# sourceMappingURL=integration-settings.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integration-settings.service.js","sourceRoot":"","sources":["../../../src/integration/services/integration-settings.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,mEAA+D;AAiBxD,IAAM,0BAA0B,kCAAhC,MAAM,0BAA0B;IAGrC,YAA6B,cAA8B;QAA9B,mBAAc,GAAd,cAAc,CAAgB;QAF1C,WAAM,GAAG,IAAI,eAAM,CAAC,4BAA0B,CAAC,IAAI,CAAC,CAAC;IAER,CAAC;IAE/D,KAAK,CAAC,kBAAkB;QACtB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC;YACxD,gBAAgB;YAChB,0BAA0B;YAC1B,8BAA8B;YAC9B,4BAA4B;YAC5B,iCAAiC;YACjC,mBAAmB;YACnB,iCAAiC;YACjC,qBAAqB;YACrB,4BAA4B;YAC5B,4BAA4B;YAC5B,4BAA4B;SAC7B,CAAC,CAAC;QAEH,MAAM,iBAAiB,GAAG,IAAI,CAAC,cAAc,CAC3C,MAAM,CAAC,4BAA4B,CAAC,EACpC,IAAI,EACJ,GAAG,EACH,4BAA4B,CA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,CAAC,UAAU,CAAC,MAAM,CAAC,4BAA4B,CAAC,EAAE,IAAI,CAAC;SAC/E,CAAC;IACJ,CAAC;IAEO,cAAc,CACpB,KAAc,EACd,QAAgB,EAChB,GAAW,EACX,IAAY;QAEZ,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAC7B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,GAAG,EAAE,CAAC;YAC7C,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,WAAW,IAAI,mBAAmB,MAAM,CAAC,KAAK,CAAC,qBAAqB,QAAQ,GAAG,CAChF,CAAC;YACF,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;IAEO,UAAU,CAAC,KAAc,EAAE,QAAiB;QAClD,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;YAC/B,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,GAAG,EAAE,CAAC;YACtC,OAAO,IAAI,CAAC;QACd,CAAC;QAED,IAAI,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,GAAG,EAAE,CAAC;YACvC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF,CAAA;AA7GY,gEAA0B;qCAA1B,0BAA0B;IADtC,IAAA,mBAAU,GAAE;qCAIkC,gCAAc;GAHhD,0BAA0B,CA6GtC"}
@@ -0,0 +1,45 @@
1
+ import { IntegrationSettingsService } from './integration-settings.service';
2
+ import { OutboxNotifier } from './outbox.notifier';
3
+ import { OutboxProcessor } from './outbox.processor';
4
+ /**
5
+ * Hybrid polling coordinator
6
+ * Manages the adaptive polling strategy: immediate reactions + periodic checks
7
+ * Uses in-memory notifications for immediate wakeup + configurable polling intervals
8
+ */
9
+ export declare class OutboxPollingCoordinator {
10
+ private readonly processor;
11
+ private readonly notifier;
12
+ private readonly integrationSettingsService;
13
+ private readonly logger;
14
+ private processingLoopRunning;
15
+ private processingLoopPromise;
16
+ private immediateWakeupTriggered;
17
+ private shouldStopLoop;
18
+ constructor(processor: OutboxProcessor, notifier: OutboxNotifier, integrationSettingsService: IntegrationSettingsService);
19
+ /**
20
+ * Start the hybrid processing loop
21
+ * Reacts to notifications immediately, polls periodically
22
+ */
23
+ startProcessingLoop(): Promise<void>;
24
+ /**
25
+ * Stop the processing loop gracefully
26
+ */
27
+ stopProcessingLoop(): Promise<void>;
28
+ /**
29
+ * Trigger immediate processing from notifier
30
+ */
31
+ triggerImmediateProcessing(): void;
32
+ /**
33
+ * Check if loop is currently running
34
+ */
35
+ isRunning(): boolean;
36
+ /**
37
+ * Main processing loop - runs continuously
38
+ */
39
+ private runProcessingLoop;
40
+ /**
41
+ * Utility: delay with cancellation support
42
+ */
43
+ private delay;
44
+ }
45
+ //# sourceMappingURL=outbox-polling.coordinator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outbox-polling.coordinator.d.ts","sourceRoot":"","sources":["../../../src/integration/services/outbox-polling.coordinator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;;GAIG;AACH,qBACa,wBAAwB;IAQjC,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,0BAA0B;IAT7C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA6C;IACpE,OAAO,CAAC,qBAAqB,CAAS;IACtC,OAAO,CAAC,qBAAqB,CAA8B;IAC3D,OAAO,CAAC,wBAAwB,CAAS;IACzC,OAAO,CAAC,cAAc,CAAS;gBAGZ,SAAS,EAAE,eAAe,EAC1B,QAAQ,EAAE,cAAc,EACxB,0BAA0B,EAAE,0BAA0B;IAGzE;;;OAGG;IACG,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAa1C;;OAEG;IACG,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;IAezC;;OAEG;IACH,0BAA0B,IAAI,IAAI;IAIlC;;OAEG;IACH,SAAS,IAAI,OAAO;IAIpB;;OAEG;YACW,iBAAiB;IA2D/B;;OAEG;IACH,OAAO,CAAC,KAAK;CAOd"}
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var OutboxPollingCoordinator_1;
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.OutboxPollingCoordinator = void 0;
14
+ const common_1 = require("@nestjs/common");
15
+ const integration_settings_service_1 = require("./integration-settings.service");
16
+ const outbox_notifier_1 = require("./outbox.notifier");
17
+ const outbox_processor_1 = require("./outbox.processor");
18
+ /**
19
+ * Hybrid polling coordinator
20
+ * Manages the adaptive polling strategy: immediate reactions + periodic checks
21
+ * Uses in-memory notifications for immediate wakeup + configurable polling intervals
22
+ */
23
+ let OutboxPollingCoordinator = OutboxPollingCoordinator_1 = class OutboxPollingCoordinator {
24
+ constructor(processor, notifier, integrationSettingsService) {
25
+ this.processor = processor;
26
+ this.notifier = notifier;
27
+ this.integrationSettingsService = integrationSettingsService;
28
+ this.logger = new common_1.Logger(OutboxPollingCoordinator_1.name);
29
+ this.processingLoopRunning = false;
30
+ this.processingLoopPromise = null;
31
+ this.immediateWakeupTriggered = false;
32
+ this.shouldStopLoop = false;
33
+ }
34
+ /**
35
+ * Start the hybrid processing loop
36
+ * Reacts to notifications immediately, polls periodically
37
+ */
38
+ async startProcessingLoop() {
39
+ if (this.processingLoopRunning) {
40
+ this.logger.warn('Processing loop already running');
41
+ return;
42
+ }
43
+ this.processingLoopRunning = true;
44
+ this.shouldStopLoop = false;
45
+ this.logger.log('Starting outbox hybrid processing loop');
46
+ this.processingLoopPromise = this.runProcessingLoop();
47
+ }
48
+ /**
49
+ * Stop the processing loop gracefully
50
+ */
51
+ async stopProcessingLoop() {
52
+ if (!this.processingLoopRunning) {
53
+ return;
54
+ }
55
+ this.logger.log('Stopping outbox processing loop');
56
+ this.shouldStopLoop = true;
57
+ if (this.processingLoopPromise) {
58
+ await this.processingLoopPromise;
59
+ }
60
+ this.processingLoopRunning = false;
61
+ }
62
+ /**
63
+ * Trigger immediate processing from notifier
64
+ */
65
+ triggerImmediateProcessing() {
66
+ this.immediateWakeupTriggered = true;
67
+ }
68
+ /**
69
+ * Check if loop is currently running
70
+ */
71
+ isRunning() {
72
+ return this.processingLoopRunning;
73
+ }
74
+ /**
75
+ * Main processing loop - runs continuously
76
+ */
77
+ async runProcessingLoop() {
78
+ // Subscribe to notifications
79
+ const immediateWakeupListener = () => {
80
+ this.triggerImmediateProcessing();
81
+ };
82
+ this.notifier.subscribe(immediateWakeupListener);
83
+ try {
84
+ while (!this.shouldStopLoop) {
85
+ const settings = await this.integrationSettingsService.getRuntimeSettings();
86
+ const isEnabled = settings.outboxEnabled;
87
+ const processorEnabled = settings.outboxProcessorEnabled;
88
+ if (!isEnabled || !processorEnabled) {
89
+ // If disabled, wait before checking again
90
+ await this.delay(settings.idlePollingIntervalMs);
91
+ continue;
92
+ }
93
+ // Check if we should process immediately (woken by notification)
94
+ const shouldProcessImmediately = this.immediateWakeupTriggered;
95
+ this.immediateWakeupTriggered = false;
96
+ // Process batch
97
+ const processedCount = await this.processor.processBatch();
98
+ // Determine next polling interval
99
+ let nextDelayMs;
100
+ if (shouldProcessImmediately && processedCount > 0) {
101
+ // We processed items from immediate wakeup - use active polling interval
102
+ nextDelayMs = settings.pollingIntervalMs;
103
+ this.logger.debug(`Processed ${processedCount} events from immediate wakeup, next poll in ${nextDelayMs}ms`);
104
+ }
105
+ else if (processedCount > 0) {
106
+ // Processed items from periodic polling - use active interval
107
+ nextDelayMs = settings.pollingIntervalMs;
108
+ this.logger.debug(`Processed ${processedCount} events, next poll in ${nextDelayMs}ms`);
109
+ }
110
+ else {
111
+ // No items processed - use idle interval
112
+ nextDelayMs = settings.idlePollingIntervalMs;
113
+ this.logger.debug(`No events processed, idle polling for ${nextDelayMs}ms`);
114
+ }
115
+ // Wait for next poll, but be ready for immediate wakeup
116
+ await this.delay(nextDelayMs);
117
+ }
118
+ }
119
+ finally {
120
+ // Cleanup: unsubscribe from notifications
121
+ this.notifier.unsubscribe(immediateWakeupListener);
122
+ this.logger.log('Processing loop stopped');
123
+ }
124
+ }
125
+ /**
126
+ * Utility: delay with cancellation support
127
+ */
128
+ delay(ms) {
129
+ return new Promise((resolve) => {
130
+ const timeout = setTimeout(resolve, ms);
131
+ // Store timeout for potential cancellation (not used yet, but available)
132
+ this._currentTimeout = timeout;
133
+ });
134
+ }
135
+ };
136
+ exports.OutboxPollingCoordinator = OutboxPollingCoordinator;
137
+ exports.OutboxPollingCoordinator = OutboxPollingCoordinator = OutboxPollingCoordinator_1 = __decorate([
138
+ (0, common_1.Injectable)(),
139
+ __metadata("design:paramtypes", [outbox_processor_1.OutboxProcessor,
140
+ outbox_notifier_1.OutboxNotifier,
141
+ integration_settings_service_1.IntegrationSettingsService])
142
+ ], OutboxPollingCoordinator);
143
+ //# sourceMappingURL=outbox-polling.coordinator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outbox-polling.coordinator.js","sourceRoot":"","sources":["../../../src/integration/services/outbox-polling.coordinator.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,iFAA4E;AAC5E,uDAAmD;AACnD,yDAAqD;AAErD;;;;GAIG;AAEI,IAAM,wBAAwB,gCAA9B,MAAM,wBAAwB;IAOnC,YACmB,SAA0B,EAC1B,QAAwB,EACxB,0BAAsD;QAFtD,cAAS,GAAT,SAAS,CAAiB;QAC1B,aAAQ,GAAR,QAAQ,CAAgB;QACxB,+BAA0B,GAA1B,0BAA0B,CAA4B;QATxD,WAAM,GAAG,IAAI,eAAM,CAAC,0BAAwB,CAAC,IAAI,CAAC,CAAC;QAC5D,0BAAqB,GAAG,KAAK,CAAC;QAC9B,0BAAqB,GAAyB,IAAI,CAAC;QACnD,6BAAwB,GAAG,KAAK,CAAC;QACjC,mBAAc,GAAG,KAAK,CAAC;IAM5B,CAAC;IAEJ;;;OAGG;IACH,KAAK,CAAC,mBAAmB;QACvB,IAAI,IAAI,CAAC,qBAAqB,EAAE,CAAC;YAC/B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;YACpD,OAAO;QACT,CAAC;QAED,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC;QAClC,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC;QAC5B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAC;QAE1D,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC;IACxD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,kBAAkB;QACtB,IAAI,CAAC,IAAI,CAAC,qBAAqB,EAAE,CAAC;YAChC,OAAO;QACT,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;QACnD,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAE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**
2
+ * In-memory notifier for signaling new outbox events
3
+ * Provides immediate wakeup to the processor without database polling
4
+ * NOT the source of truth; database outbox is the authoritative queue
5
+ */
6
+ export declare class OutboxNotifier {
7
+ private readonly emitter;
8
+ private readonly EVENT_WRITTEN;
9
+ /**
10
+ * Subscribe to outbox event notifications
11
+ */
12
+ subscribe(listener: () => void): void;
13
+ /**
14
+ * Unsubscribe from outbox event notifications
15
+ */
16
+ unsubscribe(listener: () => void): void;
17
+ /**
18
+ * Emit notification that a new event was written to outbox
19
+ */
20
+ notifyEventWritten(): void;
21
+ /**
22
+ * Get current number of subscribers
23
+ */
24
+ getSubscriberCount(): number;
25
+ /**
26
+ * Remove all listeners
27
+ */
28
+ removeAllListeners(): void;
29
+ }
30
+ //# sourceMappingURL=outbox.notifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outbox.notifier.d.ts","sourceRoot":"","sources":["../../../src/integration/services/outbox.notifier.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,qBACa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAsB;IAC9C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA0B;IAExD;;OAEG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;IAIrC;;OAEG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;IAIvC;;OAEG;IACH,kBAAkB,IAAI,IAAI;IAI1B;;OAEG;IACH,kBAAkB,IAAI,MAAM;IAI5B;;OAEG;IACH,kBAAkB,IAAI,IAAI;CAG3B"}
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.OutboxNotifier = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ const events_1 = require("events");
12
+ /**
13
+ * In-memory notifier for signaling new outbox events
14
+ * Provides immediate wakeup to the processor without database polling
15
+ * NOT the source of truth; database outbox is the authoritative queue
16
+ */
17
+ let OutboxNotifier = class OutboxNotifier {
18
+ constructor() {
19
+ this.emitter = new events_1.EventEmitter();
20
+ this.EVENT_WRITTEN = 'outbox:event:written';
21
+ }
22
+ /**
23
+ * Subscribe to outbox event notifications
24
+ */
25
+ subscribe(listener) {
26
+ this.emitter.on(this.EVENT_WRITTEN, listener);
27
+ }
28
+ /**
29
+ * Unsubscribe from outbox event notifications
30
+ */
31
+ unsubscribe(listener) {
32
+ this.emitter.removeListener(this.EVENT_WRITTEN, listener);
33
+ }
34
+ /**
35
+ * Emit notification that a new event was written to outbox
36
+ */
37
+ notifyEventWritten() {
38
+ this.emitter.emit(this.EVENT_WRITTEN);
39
+ }
40
+ /**
41
+ * Get current number of subscribers
42
+ */
43
+ getSubscriberCount() {
44
+ return this.emitter.listenerCount(this.EVENT_WRITTEN);
45
+ }
46
+ /**
47
+ * Remove all listeners
48
+ */
49
+ removeAllListeners() {
50
+ this.emitter.removeAllListeners(this.EVENT_WRITTEN);
51
+ }
52
+ };
53
+ exports.OutboxNotifier = OutboxNotifier;
54
+ exports.OutboxNotifier = OutboxNotifier = __decorate([
55
+ (0, common_1.Injectable)()
56
+ ], OutboxNotifier);
57
+ //# sourceMappingURL=outbox.notifier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outbox.notifier.js","sourceRoot":"","sources":["../../../src/integration/services/outbox.notifier.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAC5C,mCAAsC;AAEtC;;;;GAIG;AAEI,IAAM,cAAc,GAApB,MAAM,cAAc;IAApB;QACY,YAAO,GAAG,IAAI,qBAAY,EAAE,CAAC;QAC7B,kBAAa,GAAG,sBAAsB,CAAC;IAoC1D,CAAC;IAlCC;;OAEG;IACH,SAAS,CAAC,QAAoB;QAC5B,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;IAChD,CAAC;IAED;;OAEG;IACH,WAAW,CAAC,QAAoB;QAC9B,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;IAC5D,CAAC;IAED;;OAEG;IACH,kBAAkB;QAChB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,kBAAkB;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACxD,CAAC;IAED;;OAEG;IACH,kBAAkB;QAChB,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACtD,CAAC;CACF,CAAA;AAtCY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;GACA,cAAc,CAsC1B"}
@@ -0,0 +1,42 @@
1
+ import { EventSubscriberRegistry } from './event-subscriber.registry';
2
+ import { InboxService } from './inbox.service';
3
+ import { IntegrationLinkService } from './integration-link.service';
4
+ import { IntegrationSettingsService } from './integration-settings.service';
5
+ import { OutboxService } from './outbox.service';
6
+ export declare class OutboxProcessor {
7
+ private readonly outboxService;
8
+ private readonly inboxService;
9
+ private readonly linkService;
10
+ private readonly registry;
11
+ private readonly integrationSettingsService;
12
+ private readonly logger;
13
+ constructor(outboxService: OutboxService, inboxService: InboxService, linkService: IntegrationLinkService, registry: EventSubscriberRegistry, integrationSettingsService: IntegrationSettingsService);
14
+ /**
15
+ * Process a batch of pending events
16
+ * Called in a loop or by scheduled job
17
+ */
18
+ processBatch(options?: {
19
+ batchSizeOverride?: number;
20
+ }): Promise<number>;
21
+ /**
22
+ * Handle event that failed to process
23
+ */
24
+ private handleEventFailure;
25
+ /**
26
+ * Process all pending events at startup (drain)
27
+ */
28
+ startupDrain(): Promise<number>;
29
+ /**
30
+ * Get processor statistics
31
+ */
32
+ getStats(): Promise<{
33
+ pending: number;
34
+ processing: number;
35
+ processed: number;
36
+ failed: number;
37
+ dead_letter: number;
38
+ total: number;
39
+ handlerCount: number;
40
+ }>;
41
+ }
42
+ //# sourceMappingURL=outbox.processor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outbox.processor.d.ts","sourceRoot":"","sources":["../../../src/integration/services/outbox.processor.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,qBACa,eAAe;IAIxB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,0BAA0B;IAP7C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoC;gBAGxC,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,YAAY,EAC1B,WAAW,EAAE,sBAAsB,EACnC,QAAQ,EAAE,uBAAuB,EACjC,0BAA0B,EAAE,0BAA0B;IAGzE;;;OAGG;IACG,YAAY,CAAC,OAAO,CAAC,EAAE;QAAE,iBAAiB,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAqH7E;;OAEG;YACW,kBAAkB;IAyDhC;;OAEG;IACG,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC;IA0BrC;;OAEG;IACG,QAAQ;;;;;;;;;CAgCf"}
@@ -0,0 +1,43 @@
1
+ import { OnModuleDestroy, OnModuleInit } from '@nestjs/common';
2
+ import { IntegrationSettingsService } from './integration-settings.service';
3
+ import { OutboxPollingCoordinator } from './outbox-polling.coordinator';
4
+ import { OutboxNotifier } from './outbox.notifier';
5
+ import { OutboxProcessor } from './outbox.processor';
6
+ /**
7
+ * Hybrid background job for outbox processing
8
+ * Combines startup recovery, immediate notification reactions, and periodic polling
9
+ */
10
+ export declare class OutboxProcessorJob implements OnModuleInit, OnModuleDestroy {
11
+ private readonly processor;
12
+ private readonly notifier;
13
+ private readonly coordinator;
14
+ private readonly integrationSettingsService;
15
+ private readonly logger;
16
+ constructor(processor: OutboxProcessor, notifier: OutboxNotifier, coordinator: OutboxPollingCoordinator, integrationSettingsService: IntegrationSettingsService);
17
+ /**
18
+ * Called when module initializes
19
+ * 1. Drain pending events from startup
20
+ * 2. Start hybrid processing loop
21
+ */
22
+ onModuleInit(): Promise<void>;
23
+ /**
24
+ * Called when module is destroyed
25
+ * Gracefully stop the processing loop
26
+ */
27
+ onModuleDestroy(): Promise<void>;
28
+ /**
29
+ * Get current processing statistics
30
+ * Useful for health checks and monitoring
31
+ */
32
+ getStats(): Promise<{
33
+ pollingLoopRunning: boolean;
34
+ pending: number;
35
+ processing: number;
36
+ processed: number;
37
+ failed: number;
38
+ dead_letter: number;
39
+ total: number;
40
+ handlerCount: number;
41
+ }>;
42
+ }
43
+ //# sourceMappingURL=outbox.processor.job.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outbox.processor.job.d.ts","sourceRoot":"","sources":["../../../src/integration/services/outbox.processor.job.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,eAAe,EACf,YAAY,EACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;GAGG;AACH,qBACa,kBAAmB,YAAW,YAAY,EAAE,eAAe;IAIpE,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,0BAA0B;IAN7C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuC;gBAG3C,SAAS,EAAE,eAAe,EAC1B,QAAQ,EAAE,cAAc,EACxB,WAAW,EAAE,wBAAwB,EACrC,0BAA0B,EAAE,0BAA0B;IAGzE;;;;OAIG;IACG,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAsCnC;;;OAGG;IACG,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAYtC;;;OAGG;IACG,QAAQ;;;;;;;;;;CAOf"}