@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,86 @@
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.EventSubscriberRegistry = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ let EventSubscriberRegistry = class EventSubscriberRegistry {
12
+ constructor() {
13
+ this.subscribers = new Map();
14
+ }
15
+ /**
16
+ * Register a subscriber for an event
17
+ */
18
+ registerHandler(definition) {
19
+ const { eventName } = definition;
20
+ if (!this.subscribers.has(eventName)) {
21
+ this.subscribers.set(eventName, []);
22
+ }
23
+ this.subscribers.get(eventName).push(definition);
24
+ // Sort by priority (higher priority first)
25
+ const handlers = this.subscribers.get(eventName);
26
+ handlers.sort((a, b) => (b.priority || 0) - (a.priority || 0));
27
+ }
28
+ /**
29
+ * Ergonomic registration for module services.
30
+ */
31
+ subscribe(eventName, consumerName, handler, priority = 0) {
32
+ this.registerHandler({
33
+ eventName,
34
+ consumerName,
35
+ handler,
36
+ priority,
37
+ });
38
+ }
39
+ /**
40
+ * Register multiple handlers in one call.
41
+ */
42
+ subscribeMany(definitions) {
43
+ for (const definition of definitions) {
44
+ this.registerHandler(definition);
45
+ }
46
+ }
47
+ /**
48
+ * Get all handlers for an event, sorted by priority
49
+ */
50
+ getHandlers(eventName) {
51
+ return this.subscribers.get(eventName) || [];
52
+ }
53
+ /**
54
+ * Check if event has any handlers
55
+ */
56
+ hasHandlers(eventName) {
57
+ return this.subscribers.has(eventName) && this.subscribers.get(eventName).length > 0;
58
+ }
59
+ /**
60
+ * Get all registered event names
61
+ */
62
+ getEventNames() {
63
+ return Array.from(this.subscribers.keys());
64
+ }
65
+ /**
66
+ * Get total count of all registered handlers
67
+ */
68
+ getHandlerCount() {
69
+ let count = 0;
70
+ for (const handlers of this.subscribers.values()) {
71
+ count += handlers.length;
72
+ }
73
+ return count;
74
+ }
75
+ /**
76
+ * Clear all handlers (useful for testing)
77
+ */
78
+ clear() {
79
+ this.subscribers.clear();
80
+ }
81
+ };
82
+ exports.EventSubscriberRegistry = EventSubscriberRegistry;
83
+ exports.EventSubscriberRegistry = EventSubscriberRegistry = __decorate([
84
+ (0, common_1.Injectable)()
85
+ ], EventSubscriberRegistry);
86
+ //# sourceMappingURL=event-subscriber.registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-subscriber.registry.js","sourceRoot":"","sources":["../../../src/integration/services/event-subscriber.registry.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAIrC,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAA7B;QACY,gBAAW,GAAG,IAAI,GAAG,EAAkC,CAAC;IAmF3E,CAAC;IAjFC;;OAEG;IACH,eAAe,CAAC,UAAgC;QAC9C,MAAM,EAAE,SAAS,EAAE,GAAG,UAAU,CAAC;QAEjC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YACrC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QACtC,CAAC;QAED,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,SAAS,CAAE,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAElD,2CAA2C;QAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,SAAS,CAAE,CAAC;QAClD,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,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uB;kCAAvB,uBAAuB;IADnC,IAAA,mBAAU,GAAE;GACA,uBAAuB,CAoFnC"}
@@ -0,0 +1,55 @@
1
+ import { PrismaService } from '@hed-hog/api-prisma';
2
+ import { InboxEvent, InboxEventStatus } from '../types';
3
+ export declare class InboxService {
4
+ private readonly prisma;
5
+ constructor(prisma: PrismaService);
6
+ private toDomainEvent;
7
+ private toDatabaseId;
8
+ private toDatabaseUpdate;
9
+ /**
10
+ * Get or create inbox event for idempotency tracking
11
+ * Returns existing if already processed, otherwise creates new
12
+ */
13
+ getOrCreate(outboxEventId: string | number, consumerName: string): Promise<InboxEvent>;
14
+ /**
15
+ * Update inbox event status
16
+ */
17
+ updateStatus(inboxEventId: string | number, status: InboxEventStatus, partialUpdate?: {
18
+ attemptCount?: number;
19
+ lastError?: string | null;
20
+ processedAt?: Date | null;
21
+ }): Promise<InboxEvent>;
22
+ /**
23
+ * Mark inbox event as processing
24
+ */
25
+ markProcessing(inboxEventId: string | number): Promise<InboxEvent>;
26
+ /**
27
+ * Mark inbox event as successfully processed
28
+ */
29
+ markProcessed(inboxEventId: string | number): Promise<InboxEvent>;
30
+ /**
31
+ * Mark inbox event as failed
32
+ */
33
+ markFailed(inboxEventId: string | number, error: string): Promise<InboxEvent>;
34
+ /**
35
+ * Mark inbox event as skipped
36
+ */
37
+ markSkipped(inboxEventId: string | number): Promise<InboxEvent>;
38
+ /**
39
+ * Increment attempt count
40
+ */
41
+ incrementAttempt(inboxEventId: string | number): Promise<InboxEvent>;
42
+ /**
43
+ * Get inbox event by ID
44
+ */
45
+ getById(inboxEventId: string | number): Promise<InboxEvent | null>;
46
+ /**
47
+ * Check if event was already processed by consumer
48
+ */
49
+ isProcessed(outboxEventId: string | number, consumerName: string): Promise<boolean>;
50
+ /**
51
+ * Count unprocessed items for a consumer
52
+ */
53
+ countUnprocessed(consumerName: string): Promise<number>;
54
+ }
55
+ //# sourceMappingURL=inbox.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"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OAEG;IACG,OAAO,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAQxE;;OAEG;IACG,WAAW,CACf,aAAa,EAAE,MAAM,GAAG,MAAM,EAC9B,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,OAAO,CAAC;IAcnB;;OAEG;IACG,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAU9D"}
@@ -0,0 +1,173 @@
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.InboxService = void 0;
13
+ const api_prisma_1 = require("@hed-hog/api-prisma");
14
+ const common_1 = require("@nestjs/common");
15
+ const types_1 = require("../types");
16
+ let InboxService = class InboxService {
17
+ constructor(prisma) {
18
+ this.prisma = prisma;
19
+ }
20
+ toDomainEvent(record) {
21
+ return {
22
+ id: String(record.id),
23
+ outboxEventId: String(record.outbox_event_id),
24
+ consumerName: record.consumer_name,
25
+ status: record.status,
26
+ attemptCount: record.attempt_count,
27
+ lastError: record.last_error,
28
+ processedAt: record.processed_at,
29
+ createdAt: record.created_at,
30
+ updatedAt: record.updated_at,
31
+ };
32
+ }
33
+ toDatabaseId(eventId) {
34
+ return typeof eventId === 'number' ? eventId : Number(eventId);
35
+ }
36
+ toDatabaseUpdate(partialUpdate) {
37
+ if (!partialUpdate) {
38
+ return undefined;
39
+ }
40
+ return {
41
+ attempt_count: partialUpdate.attemptCount,
42
+ last_error: partialUpdate.lastError,
43
+ processed_at: partialUpdate.processedAt,
44
+ };
45
+ }
46
+ /**
47
+ * Get or create inbox event for idempotency tracking
48
+ * Returns existing if already processed, otherwise creates new
49
+ */
50
+ async getOrCreate(outboxEventId, consumerName) {
51
+ // Try to find existing
52
+ let inboxEvent = await this.prisma.inbox_event.findFirst({
53
+ where: {
54
+ outbox_event_id: this.toDatabaseId(outboxEventId),
55
+ consumer_name: consumerName,
56
+ },
57
+ });
58
+ // Create if doesn't exist
59
+ if (!inboxEvent) {
60
+ inboxEvent = await this.prisma.inbox_event.create({
61
+ data: {
62
+ outbox_event_id: this.toDatabaseId(outboxEventId),
63
+ consumer_name: consumerName,
64
+ status: types_1.InboxEventStatus.RECEIVED,
65
+ attempt_count: 0,
66
+ },
67
+ });
68
+ }
69
+ return this.toDomainEvent(inboxEvent);
70
+ }
71
+ /**
72
+ * Update inbox event status
73
+ */
74
+ async updateStatus(inboxEventId, status, partialUpdate) {
75
+ const inboxEvent = await this.prisma.inbox_event.update({
76
+ where: { id: this.toDatabaseId(inboxEventId) },
77
+ data: Object.assign({ status }, this.toDatabaseUpdate(partialUpdate)),
78
+ });
79
+ return this.toDomainEvent(inboxEvent);
80
+ }
81
+ /**
82
+ * Mark inbox event as processing
83
+ */
84
+ async markProcessing(inboxEventId) {
85
+ return this.updateStatus(inboxEventId, types_1.InboxEventStatus.PROCESSING);
86
+ }
87
+ /**
88
+ * Mark inbox event as successfully processed
89
+ */
90
+ async markProcessed(inboxEventId) {
91
+ return this.updateStatus(inboxEventId, types_1.InboxEventStatus.PROCESSED, {
92
+ processedAt: new Date(),
93
+ });
94
+ }
95
+ /**
96
+ * Mark inbox event as failed
97
+ */
98
+ async markFailed(inboxEventId, error) {
99
+ const record = await this.prisma.inbox_event.findUnique({
100
+ where: { id: this.toDatabaseId(inboxEventId) },
101
+ });
102
+ if (!record) {
103
+ throw new Error(`Inbox event ${inboxEventId} not found`);
104
+ }
105
+ const inboxEvent = this.toDomainEvent(record);
106
+ return this.updateStatus(inboxEventId, types_1.InboxEventStatus.FAILED, {
107
+ attemptCount: inboxEvent.attemptCount + 1,
108
+ lastError: error,
109
+ });
110
+ }
111
+ /**
112
+ * Mark inbox event as skipped
113
+ */
114
+ async markSkipped(inboxEventId) {
115
+ return this.updateStatus(inboxEventId, types_1.InboxEventStatus.SKIPPED);
116
+ }
117
+ /**
118
+ * Increment attempt count
119
+ */
120
+ async incrementAttempt(inboxEventId) {
121
+ const record = await this.prisma.inbox_event.findUnique({
122
+ where: { id: this.toDatabaseId(inboxEventId) },
123
+ });
124
+ if (!record) {
125
+ throw new Error(`Inbox event ${inboxEventId} not found`);
126
+ }
127
+ const inboxEvent = this.toDomainEvent(record);
128
+ return this.updateStatus(inboxEventId, inboxEvent.status, {
129
+ attemptCount: inboxEvent.attemptCount + 1,
130
+ });
131
+ }
132
+ /**
133
+ * Get inbox event by ID
134
+ */
135
+ async getById(inboxEventId) {
136
+ const inboxEvent = await this.prisma.inbox_event.findUnique({
137
+ where: { id: this.toDatabaseId(inboxEventId) },
138
+ });
139
+ return inboxEvent ? this.toDomainEvent(inboxEvent) : null;
140
+ }
141
+ /**
142
+ * Check if event was already processed by consumer
143
+ */
144
+ async isProcessed(outboxEventId, consumerName) {
145
+ const inboxEvent = await this.prisma.inbox_event.findFirst({
146
+ where: {
147
+ outbox_event_id: this.toDatabaseId(outboxEventId),
148
+ consumer_name: consumerName,
149
+ },
150
+ });
151
+ return (inboxEvent !== null &&
152
+ inboxEvent.status === types_1.InboxEventStatus.PROCESSED);
153
+ }
154
+ /**
155
+ * Count unprocessed items for a consumer
156
+ */
157
+ async countUnprocessed(consumerName) {
158
+ return this.prisma.inbox_event.count({
159
+ where: {
160
+ consumer_name: consumerName,
161
+ status: {
162
+ notIn: [types_1.InboxEventStatus.PROCESSED, types_1.InboxEventStatus.SKIPPED],
163
+ },
164
+ },
165
+ });
166
+ }
167
+ };
168
+ exports.InboxService = InboxService;
169
+ exports.InboxService = InboxService = __decorate([
170
+ (0, common_1.Injectable)(),
171
+ __metadata("design:paramtypes", [api_prisma_1.PrismaService])
172
+ ], InboxService);
173
+ //# sourceMappingURL=inbox.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inbox.service.js","sourceRoot":"","sources":["../../../src/integration/services/inbox.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAoD;AACpD,2CAA4C;AAC5C,oCAAwD;AAejD,IAAM,YAAY,GAAlB,MAAM,YAAY;IACvB,YAA6B,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;IAAG,CAAC;IAE9C,aAAa,CAAC,MAAwB;QAC5C,OAAO;YACL,EAAE,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;YACrB,aAAa,EAAE,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC;YAC7C,YAAY,EAAE,MAAM,CAAC,aAAa;YAClC,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,YAAY,EAAE,MAAM,CAAC,aAAa;YAClC,SAAS,EAAE,MAAM,CAAC,UAAU;YAC5B,WAAW,EAAE,MAAM,CAAC,YAAY;YAChC,SAAS,EAAE,MAAM,CAAC,UAAU;YAC5B,SAAS,EAAE,MAAM,CAAC,UAAU;SAC7B,CAAC;IACJ,CAAC;IAEO,YAAY,CAAC,OAAwB;QAC3C,OAAO,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACjE,CAAC;IAEO,gBAAgB,CACtB,aAIC;QAED,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,OAAO;YACL,aAAa,EAAE,aAAa,CAAC,YAAY;YACzC,UAAU,EAAE,aAAa,CAA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,CAAC;iBAC9D;aACF;SACF,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAxMY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,mBAAU,GAAE;qCAE0B,0BAAa;GADvC,YAAY,CAwMxB"}
@@ -0,0 +1,12 @@
1
+ export * from './domain-event.publisher';
2
+ export * from './event-subscriber.registry';
3
+ export * from './inbox.service';
4
+ export * from './integration-developer-api.service';
5
+ export * from './integration-link.service';
6
+ export * from './integration-settings.service';
7
+ export * from './outbox-polling.coordinator';
8
+ export * from './outbox.notifier';
9
+ export * from './outbox.processor';
10
+ export * from './outbox.processor.job';
11
+ export * from './outbox.service';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/integration/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iBAAiB,CAAC;AAChC,cAAc,qCAAqC,CAAC;AACpD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./domain-event.publisher"), exports);
18
+ __exportStar(require("./event-subscriber.registry"), exports);
19
+ __exportStar(require("./inbox.service"), exports);
20
+ __exportStar(require("./integration-developer-api.service"), exports);
21
+ __exportStar(require("./integration-link.service"), exports);
22
+ __exportStar(require("./integration-settings.service"), exports);
23
+ __exportStar(require("./outbox-polling.coordinator"), exports);
24
+ __exportStar(require("./outbox.notifier"), exports);
25
+ __exportStar(require("./outbox.processor"), exports);
26
+ __exportStar(require("./outbox.processor.job"), exports);
27
+ __exportStar(require("./outbox.service"), exports);
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/integration/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC;AACzC,8DAA4C;AAC5C,kDAAgC;AAChC,sEAAoD;AACpD,6DAA2C;AAC3C,iEAA+C;AAC/C,+DAA6C;AAC7C,oDAAkC;AAClC,qDAAmC;AACnC,yDAAuC;AACvC,mDAAiC"}
@@ -0,0 +1,30 @@
1
+ import { DomainEvent, EventHandler, IntegrationLink, LinkType, OutboxEvent, SubscriberDefinition } from '../types';
2
+ import { DomainEventPublisher, PublishDomainEventInput, PublishDomainEventOptions } from './domain-event.publisher';
3
+ import { EventSubscriberRegistry } from './event-subscriber.registry';
4
+ import { CreateIntegrationLinkDto, IntegrationLinkPersistenceClient, IntegrationLinkService } from './integration-link.service';
5
+ export interface IntegrationSubscriptionInput {
6
+ eventName: string;
7
+ consumerName: string;
8
+ handler: EventHandler;
9
+ priority?: number;
10
+ }
11
+ export interface IntegrationLinkQuery {
12
+ module: string;
13
+ entityType: string;
14
+ entityId: string;
15
+ }
16
+ export declare class IntegrationDeveloperApiService {
17
+ private readonly publisher;
18
+ private readonly subscriberRegistry;
19
+ private readonly linkService;
20
+ constructor(publisher: DomainEventPublisher, subscriberRegistry: EventSubscriberRegistry, linkService: IntegrationLinkService);
21
+ publishEvent(input: PublishDomainEventInput, options?: PublishDomainEventOptions): Promise<OutboxEvent>;
22
+ publishEvents(events: Array<DomainEvent | PublishDomainEventInput>, options?: PublishDomainEventOptions): Promise<OutboxEvent[]>;
23
+ subscribe(input: IntegrationSubscriptionInput): void;
24
+ subscribeMany(definitions: SubscriberDefinition[]): void;
25
+ createLink(dto: CreateIntegrationLinkDto, persistenceClient?: IntegrationLinkPersistenceClient): Promise<IntegrationLink>;
26
+ findLinksBySource(query: IntegrationLinkQuery): Promise<IntegrationLink[]>;
27
+ findLinksByTarget(query: IntegrationLinkQuery): Promise<IntegrationLink[]>;
28
+ findLinksByType(linkType: LinkType): Promise<IntegrationLink[]>;
29
+ }
30
+ //# sourceMappingURL=integration-developer-api.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integration-developer-api.service.d.ts","sourceRoot":"","sources":["../../../src/integration/services/integration-developer-api.service.ts"],"names":[],"mappings":"AACA,OAAO,EACH,WAAW,EACX,YAAY,EACZ,eAAe,EACf,QAAQ,EACR,WAAW,EACX,oBAAoB,EACvB,MAAM,UAAU,CAAC;AAClB,OAAO,EACH,oBAAoB,EACpB,uBAAuB,EACvB,yBAAyB,EAC5B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EACH,wBAAwB,EACxB,gCAAgC,EAChC,sBAAsB,EACzB,MAAM,4BAA4B,CAAC;AAEpC,MAAM,WAAW,4BAA4B;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,YAAY,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,qBACa,8BAA8B;IAEvC,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,kBAAkB;IACnC,OAAO,CAAC,QAAQ,CAAC,WAAW;gBAFX,SAAS,EAAE,oBAAoB,EAC/B,kBAAkB,EAAE,uBAAuB,EAC3C,WAAW,EAAE,sBAAsB;IAGhD,YAAY,CAChB,KAAK,EAAE,uBAAuB,EAC9B,OAAO,CAAC,EAAE,yBAAyB,GAClC,OAAO,CAAC,WAAW,CAAC;IAIjB,aAAa,CACjB,MAAM,EAAE,KAAK,CAAC,WAAW,GAAG,uBAAuB,CAAC,EACpD,OAAO,CAAC,EAAE,yBAAyB,GAClC,OAAO,CAAC,WAAW,EAAE,CAAC;IAIzB,SAAS,CAAC,KAAK,EAAE,4BAA4B,GAAG,IAAI;IASpD,aAAa,CAAC,WAAW,EAAE,oBAAoB,EAAE,GAAG,IAAI;IAIlD,UAAU,CACd,GAAG,EAAE,wBAAwB,EAC7B,iBAAiB,CAAC,EAAE,gCAAgC,GACnD,OAAO,CAAC,eAAe,CAAC;IAIrB,iBAAiB,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAQ1E,iBAAiB,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAQ1E,eAAe,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;CAGtE"}
@@ -0,0 +1,55 @@
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.IntegrationDeveloperApiService = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const domain_event_publisher_1 = require("./domain-event.publisher");
15
+ const event_subscriber_registry_1 = require("./event-subscriber.registry");
16
+ const integration_link_service_1 = require("./integration-link.service");
17
+ let IntegrationDeveloperApiService = class IntegrationDeveloperApiService {
18
+ constructor(publisher, subscriberRegistry, linkService) {
19
+ this.publisher = publisher;
20
+ this.subscriberRegistry = subscriberRegistry;
21
+ this.linkService = linkService;
22
+ }
23
+ async publishEvent(input, options) {
24
+ return this.publisher.publishEvent(input, options);
25
+ }
26
+ async publishEvents(events, options) {
27
+ return this.publisher.publishEvents(events, options);
28
+ }
29
+ subscribe(input) {
30
+ this.subscriberRegistry.subscribe(input.eventName, input.consumerName, input.handler, input.priority || 0);
31
+ }
32
+ subscribeMany(definitions) {
33
+ this.subscriberRegistry.subscribeMany(definitions);
34
+ }
35
+ async createLink(dto, persistenceClient) {
36
+ return this.linkService.createLink(dto, persistenceClient);
37
+ }
38
+ async findLinksBySource(query) {
39
+ return this.linkService.findOutbound(query.module, query.entityType, query.entityId);
40
+ }
41
+ async findLinksByTarget(query) {
42
+ return this.linkService.findInbound(query.module, query.entityType, query.entityId);
43
+ }
44
+ async findLinksByType(linkType) {
45
+ return this.linkService.findByLinkType(linkType);
46
+ }
47
+ };
48
+ exports.IntegrationDeveloperApiService = IntegrationDeveloperApiService;
49
+ exports.IntegrationDeveloperApiService = IntegrationDeveloperApiService = __decorate([
50
+ (0, common_1.Injectable)(),
51
+ __metadata("design:paramtypes", [domain_event_publisher_1.DomainEventPublisher,
52
+ event_subscriber_registry_1.EventSubscriberRegistry,
53
+ integration_link_service_1.IntegrationLinkService])
54
+ ], IntegrationDeveloperApiService);
55
+ //# sourceMappingURL=integration-developer-api.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integration-developer-api.service.js","sourceRoot":"","sources":["../../../src/integration/services/integration-developer-api.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAS5C,qEAIkC;AAClC,2EAAsE;AACtE,yEAIoC;AAgB7B,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IACzC,YACmB,SAA+B,EAC/B,kBAA2C,EAC3C,WAAmC;QAFnC,cAAS,GAAT,SAAS,CAAsB;QAC/B,uBAAkB,GAAlB,kBAAkB,CAAyB;QAC3C,gBAAW,GAAX,WAAW,CAAwB;IACnD,CAAC;IAEJ,KAAK,CAAC,YAAY,CAChB,KAA8B,EAC9B,OAAmC;QAEnC,OAAO,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,aAAa,CACjB,MAAoD,EACpD,OAAmC;QAEnC,OAAO,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC;IAED,SAAS,CAAC,KAAmC;QAC3C,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAC/B,KAAK,CAAC,SAAS,EACf,KAAK,CAAC,YAAY,EAClB,KAAK,CAAC,OAAO,EACb,KAAK,CAAC,QAAQ,IAAI,CAAC,CACpB,CAAC;IACJ,CAAC;IAED,aAAa,CAAC,WAAmC;QAC/C,IAAI,CAAC,kBAAkB,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,UAAU,CACd,GAA6B,EAC7B,iBAAoD;QAEpD,OAAO,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC;IAC7D,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,KAA2B;QACjD,OAAO,IAAI,CAAC,WAAW,CAAC,YAAY,CAClC,KAAK,CAAC,MAAM,EACZ,KAAK,CAAC,UAAU,EAChB,KAAK,CAAC,QAAQ,CACf,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,KAA2B;QACjD,OAAO,IAAI,CAAC,WAAW,CAAC,WAAW,CACjC,KAAK,CAAC,MAAM,EACZ,KAAK,CAAC,UAAU,EAChB,KAAK,CAAC,QAAQ,CACf,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,QAAkB;QACtC,OAAO,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;IACnD,CAAC;CACF,CAAA;AA5DY,wEAA8B;yCAA9B,8BAA8B;IAD1C,IAAA,mBAAU,GAAE;qCAGmB,6CAAoB;QACX,mDAAuB;QAC9B,iDAAsB;GAJ3C,8BAA8B,CA4D1C"}
@@ -0,0 +1,52 @@
1
+ import { PrismaService } from '@hed-hog/api-prisma';
2
+ import { IntegrationLink, LinkType } from '../types';
3
+ export interface CreateIntegrationLinkDto {
4
+ sourceModule: string;
5
+ sourceEntityType: string;
6
+ sourceEntityId: string;
7
+ targetModule: string;
8
+ targetEntityType: string;
9
+ targetEntityId: string;
10
+ linkType: LinkType;
11
+ metadata?: Record<string, any>;
12
+ }
13
+ export interface IntegrationLinkPersistenceClient {
14
+ integrationLink: PrismaService['integrationLink'];
15
+ }
16
+ export declare class IntegrationLinkService {
17
+ private readonly prisma;
18
+ constructor(prisma: PrismaService);
19
+ /**
20
+ * Create a link between entities from different modules
21
+ */
22
+ createLink(dto: CreateIntegrationLinkDto, persistenceClient?: IntegrationLinkPersistenceClient): Promise<IntegrationLink>;
23
+ /**
24
+ * Find all links originating from a source entity
25
+ */
26
+ findOutbound(sourceModule: string, sourceEntityType: string, sourceEntityId: string): Promise<IntegrationLink[]>;
27
+ /**
28
+ * Find all links terminating at a target entity
29
+ */
30
+ findInbound(targetModule: string, targetEntityType: string, targetEntityId: string): Promise<IntegrationLink[]>;
31
+ /**
32
+ * Find links of a specific type
33
+ */
34
+ findByLinkType(linkType: LinkType): Promise<IntegrationLink[]>;
35
+ /**
36
+ * Delete a link
37
+ */
38
+ deleteLink(linkId: string): Promise<IntegrationLink>;
39
+ /**
40
+ * Get link by ID
41
+ */
42
+ getById(linkId: string): Promise<IntegrationLink | null>;
43
+ /**
44
+ * Find bidirectional link between two entities
45
+ */
46
+ findBidirectional(module1: string, entity1Type: string, entity1Id: string, module2: string, entity2Type: string, entity2Id: string): Promise<IntegrationLink | null>;
47
+ /**
48
+ * Count links from a module
49
+ */
50
+ countFromModule(sourceModule: string): Promise<number>;
51
+ }
52
+ //# sourceMappingURL=integration-link.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integration-link.service.d.ts","sourceRoot":"","sources":["../../../src/integration/services/integration-link.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAErD,MAAM,WAAW,wBAAwB;IACvC,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,gCAAgC;IAC/C,eAAe,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;CACnD;AAED,qBACa,sBAAsB;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAElD;;OAEG;IACG,UAAU,CACd,GAAG,EAAE,wBAAwB,EAC7B,iBAAiB,CAAC,EAAE,g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