@pattern-stack/codegen 0.22.0 → 0.24.0

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 (104) hide show
  1. package/CHANGELOG.md +56 -1
  2. package/consumer-skills/integration/SKILL.md +11 -3
  3. package/dist/{chunk-XKWOJZZ4.js → chunk-37PILMIT.js} +4 -4
  4. package/dist/{chunk-NR7QQ6ZI.js → chunk-6M6LZEP6.js} +3 -3
  5. package/dist/{chunk-VDL5CJ5C.js → chunk-7B7MMDOJ.js} +54 -1
  6. package/dist/chunk-7B7MMDOJ.js.map +1 -0
  7. package/dist/{chunk-NXHL5YII.js → chunk-7LKAMLV4.js} +4 -4
  8. package/dist/{chunk-6DQEIXYU.js → chunk-CKLM57IE.js} +10 -10
  9. package/dist/chunk-CKLM57IE.js.map +1 -0
  10. package/dist/{chunk-QXVCRA23.js → chunk-ENAR3F5S.js} +9 -4
  11. package/dist/chunk-ENAR3F5S.js.map +1 -0
  12. package/dist/{chunk-FFUDEIFF.js → chunk-HN5HT5WL.js} +2 -2
  13. package/dist/{chunk-6ECCJVYW.js → chunk-K4BQQ2NN.js} +46 -2
  14. package/dist/chunk-K4BQQ2NN.js.map +1 -0
  15. package/dist/{chunk-QFUIE37H.js → chunk-KFXXOFDC.js} +4 -4
  16. package/dist/{chunk-O2A6XHGD.js → chunk-LLDJS7PJ.js} +2 -2
  17. package/dist/{chunk-JOBQ6RUU.js → chunk-LQZESSM3.js} +28 -1
  18. package/dist/chunk-LQZESSM3.js.map +1 -0
  19. package/dist/{chunk-JRQO2IOF.js → chunk-MU54DZCC.js} +27 -1
  20. package/dist/chunk-MU54DZCC.js.map +1 -0
  21. package/dist/{chunk-INO47JXD.js → chunk-PBENHIN2.js} +3 -3
  22. package/dist/{chunk-CLWBNXKF.js → chunk-PLUJEQLU.js} +2 -2
  23. package/dist/{chunk-DB5UXJC3.js → chunk-PNCOUFFI.js} +4 -2
  24. package/dist/chunk-PNCOUFFI.js.map +1 -0
  25. package/dist/{chunk-S7C6TIIF.js → chunk-S5G3HO7N.js} +3 -1
  26. package/dist/chunk-S5G3HO7N.js.map +1 -0
  27. package/dist/{chunk-FNHNSFIJ.js → chunk-WZOPWQN2.js} +2 -2
  28. package/dist/{chunk-TDEHU73T.js → chunk-YIVQ7KLS.js} +46 -5
  29. package/dist/chunk-YIVQ7KLS.js.map +1 -0
  30. package/dist/runtime/subsystems/auth/auth.module.js +2 -2
  31. package/dist/runtime/subsystems/auth/index.js +4 -4
  32. package/dist/runtime/subsystems/bridge/bridge.module.js +7 -7
  33. package/dist/runtime/subsystems/bridge/index.js +7 -7
  34. package/dist/runtime/subsystems/events/event-bus.drizzle-backend.js +1 -1
  35. package/dist/runtime/subsystems/events/events.module.js +5 -5
  36. package/dist/runtime/subsystems/events/generated/bus.js +3 -3
  37. package/dist/runtime/subsystems/events/generated/index.d.ts +2 -2
  38. package/dist/runtime/subsystems/events/generated/index.js +9 -3
  39. package/dist/runtime/subsystems/events/generated/registry.d.ts +36 -0
  40. package/dist/runtime/subsystems/events/generated/registry.js +1 -1
  41. package/dist/runtime/subsystems/events/generated/schemas.d.ts +109 -1
  42. package/dist/runtime/subsystems/events/generated/schemas.js +7 -1
  43. package/dist/runtime/subsystems/events/generated/types.d.ts +48 -2
  44. package/dist/runtime/subsystems/events/index.js +5 -5
  45. package/dist/runtime/subsystems/index.d.ts +3 -2
  46. package/dist/runtime/subsystems/index.js +29 -25
  47. package/dist/runtime/subsystems/integration/execute-integration.use-case.d.ts +11 -1
  48. package/dist/runtime/subsystems/integration/execute-integration.use-case.js +2 -2
  49. package/dist/runtime/subsystems/integration/index.d.ts +2 -1
  50. package/dist/runtime/subsystems/integration/index.js +10 -8
  51. package/dist/runtime/subsystems/integration/integration-change-emitter.protocol.d.ts +106 -0
  52. package/dist/runtime/subsystems/integration/integration-change-emitter.protocol.js +1 -0
  53. package/dist/runtime/subsystems/integration/integration-change-emitter.protocol.js.map +1 -0
  54. package/dist/runtime/subsystems/integration/integration-cursor-store.drizzle-backend.js +2 -2
  55. package/dist/runtime/subsystems/integration/integration-run-recorder.drizzle-backend.js +2 -2
  56. package/dist/runtime/subsystems/integration/integration.module.js +4 -4
  57. package/dist/runtime/subsystems/integration/integration.tokens.d.ts +11 -1
  58. package/dist/runtime/subsystems/integration/integration.tokens.js +3 -1
  59. package/dist/runtime/subsystems/jobs/index.js +12 -12
  60. package/dist/runtime/subsystems/jobs/job-worker.d.ts +592 -4
  61. package/dist/runtime/subsystems/jobs/job-worker.js +3 -1
  62. package/dist/runtime/subsystems/jobs/job-worker.module.js +6 -6
  63. package/dist/runtime/subsystems/jobs/jobs-domain.module.d.ts +19 -0
  64. package/dist/runtime/subsystems/jobs/jobs-domain.module.js +4 -4
  65. package/dist/runtime/subsystems/observability/index.js +3 -3
  66. package/dist/runtime/subsystems/observability/observability.module.js +3 -3
  67. package/dist/runtime/subsystems/observability/observability.service.js +2 -2
  68. package/dist/src/cli/index.js +413 -85
  69. package/dist/src/cli/index.js.map +1 -1
  70. package/dist/src/index.d.ts +490 -1
  71. package/dist/src/index.js +7 -7
  72. package/package.json +1 -1
  73. package/runtime/subsystems/events/event-bus.drizzle-backend.ts +23 -7
  74. package/runtime/subsystems/events/generated/registry.ts +27 -0
  75. package/runtime/subsystems/events/generated/schemas.ts +26 -0
  76. package/runtime/subsystems/events/generated/types.ts +52 -0
  77. package/runtime/subsystems/index.ts +23 -0
  78. package/runtime/subsystems/integration/execute-integration.use-case.ts +69 -1
  79. package/runtime/subsystems/integration/index.ts +6 -0
  80. package/runtime/subsystems/integration/integration-change-emitter.protocol.ts +107 -0
  81. package/runtime/subsystems/integration/integration.tokens.ts +11 -0
  82. package/runtime/subsystems/jobs/job-worker.module.ts +5 -0
  83. package/runtime/subsystems/jobs/job-worker.ts +126 -12
  84. package/runtime/subsystems/jobs/jobs-domain.module.ts +19 -0
  85. package/templates/entity/new/clean-lite-ps/prompt-extension.js +59 -10
  86. package/templates/subsystem/jobs-config/codegen-config-jobs-block.ejs.t +11 -0
  87. package/dist/chunk-6DQEIXYU.js.map +0 -1
  88. package/dist/chunk-6ECCJVYW.js.map +0 -1
  89. package/dist/chunk-DB5UXJC3.js.map +0 -1
  90. package/dist/chunk-JOBQ6RUU.js.map +0 -1
  91. package/dist/chunk-JRQO2IOF.js.map +0 -1
  92. package/dist/chunk-QXVCRA23.js.map +0 -1
  93. package/dist/chunk-S7C6TIIF.js.map +0 -1
  94. package/dist/chunk-TDEHU73T.js.map +0 -1
  95. package/dist/chunk-VDL5CJ5C.js.map +0 -1
  96. /package/dist/{chunk-XKWOJZZ4.js.map → chunk-37PILMIT.js.map} +0 -0
  97. /package/dist/{chunk-NR7QQ6ZI.js.map → chunk-6M6LZEP6.js.map} +0 -0
  98. /package/dist/{chunk-NXHL5YII.js.map → chunk-7LKAMLV4.js.map} +0 -0
  99. /package/dist/{chunk-FFUDEIFF.js.map → chunk-HN5HT5WL.js.map} +0 -0
  100. /package/dist/{chunk-QFUIE37H.js.map → chunk-KFXXOFDC.js.map} +0 -0
  101. /package/dist/{chunk-O2A6XHGD.js.map → chunk-LLDJS7PJ.js.map} +0 -0
  102. /package/dist/{chunk-INO47JXD.js.map → chunk-PBENHIN2.js.map} +0 -0
  103. /package/dist/{chunk-CLWBNXKF.js.map → chunk-PLUJEQLU.js.map} +0 -0
  104. /package/dist/{chunk-FNHNSFIJ.js.map → chunk-WZOPWQN2.js.map} +0 -0
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  EventSchedulerLifecycle,
3
3
  EventsModule
4
- } from "../../../chunk-NR7QQ6ZI.js";
5
- import "../../../chunk-INO47JXD.js";
6
- import "../../../chunk-JOBQ6RUU.js";
7
- import "../../../chunk-JRQO2IOF.js";
4
+ } from "../../../chunk-6M6LZEP6.js";
5
+ import "../../../chunk-PBENHIN2.js";
6
+ import "../../../chunk-LQZESSM3.js";
7
+ import "../../../chunk-MU54DZCC.js";
8
8
  import "../../../chunk-DUUCU77W.js";
9
9
  import "../../../chunk-DUBZOXJC.js";
10
- import "../../../chunk-DB5UXJC3.js";
10
+ import "../../../chunk-PNCOUFFI.js";
11
11
  import "../../../chunk-GOO5ZMYO.js";
12
12
  import "../../../chunk-UQ5EHOH2.js";
13
13
  import "../../../chunk-Q6LRJ4VI.js";
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  TypedEventBus
3
- } from "../../../../chunk-INO47JXD.js";
4
- import "../../../../chunk-JOBQ6RUU.js";
5
- import "../../../../chunk-JRQO2IOF.js";
3
+ } from "../../../../chunk-PBENHIN2.js";
4
+ import "../../../../chunk-LQZESSM3.js";
5
+ import "../../../../chunk-MU54DZCC.js";
6
6
  import "../../../../chunk-DUBZOXJC.js";
7
7
  import "../../../../chunk-H5NH7KPE.js";
8
8
  import "../../../../chunk-GYGNEQSC.js";
@@ -1,5 +1,5 @@
1
- export { AppDomainEvent, ContactCreatedEvent, ContactMarkedChampionEvent, ContactMergedEvent, CrmSyncStartedEvent, DealCreatedEvent, DealStageChangedEvent, EventOfType, EventTypeName, PayloadOfType, StripePaymentReceivedEvent, WebhookOutboundContactSyncEvent } from './types.js';
2
- export { contactCreatedPayloadSchema, contactMarkedChampionPayloadSchema, contactMergedPayloadSchema, crmSyncStartedPayloadSchema, dealCreatedPayloadSchema, dealStageChangedPayloadSchema, eventPayloadSchemas, stripePaymentReceivedPayloadSchema, webhookOutboundContactSyncPayloadSchema } from './schemas.js';
1
+ export { AppDomainEvent, ContactCreatedEvent, ContactMarkedChampionEvent, ContactMergedEvent, CrmSyncStartedEvent, DealCreatedEvent, DealStageChangedEvent, EventOfType, EventTypeName, MessageCreatedEvent, MessageDeletedEvent, MessageEditedEvent, PayloadOfType, StripePaymentReceivedEvent, WebhookOutboundContactSyncEvent } from './types.js';
2
+ export { contactCreatedPayloadSchema, contactMarkedChampionPayloadSchema, contactMergedPayloadSchema, crmSyncStartedPayloadSchema, dealCreatedPayloadSchema, dealStageChangedPayloadSchema, eventPayloadSchemas, messageCreatedPayloadSchema, messageDeletedPayloadSchema, messageEditedPayloadSchema, stripePaymentReceivedPayloadSchema, webhookOutboundContactSyncPayloadSchema } from './schemas.js';
3
3
  export { EventMetadata, eventRegistry, getEventMetadata } from './registry.js';
4
4
  export { TypedEventBus } from './bus.js';
5
5
  import '../event-bus.protocol.js';
@@ -1,11 +1,11 @@
1
1
  import "../../../../chunk-HUH73XGI.js";
2
2
  import {
3
3
  TypedEventBus
4
- } from "../../../../chunk-INO47JXD.js";
4
+ } from "../../../../chunk-PBENHIN2.js";
5
5
  import {
6
6
  eventRegistry,
7
7
  getEventMetadata
8
- } from "../../../../chunk-JOBQ6RUU.js";
8
+ } from "../../../../chunk-LQZESSM3.js";
9
9
  import {
10
10
  contactCreatedPayloadSchema,
11
11
  contactMarkedChampionPayloadSchema,
@@ -14,9 +14,12 @@ import {
14
14
  dealCreatedPayloadSchema,
15
15
  dealStageChangedPayloadSchema,
16
16
  eventPayloadSchemas,
17
+ messageCreatedPayloadSchema,
18
+ messageDeletedPayloadSchema,
19
+ messageEditedPayloadSchema,
17
20
  stripePaymentReceivedPayloadSchema,
18
21
  webhookOutboundContactSyncPayloadSchema
19
- } from "../../../../chunk-JRQO2IOF.js";
22
+ } from "../../../../chunk-MU54DZCC.js";
20
23
  import "../../../../chunk-DUBZOXJC.js";
21
24
  import "../../../../chunk-H5NH7KPE.js";
22
25
  import "../../../../chunk-GYGNEQSC.js";
@@ -32,6 +35,9 @@ export {
32
35
  eventPayloadSchemas,
33
36
  eventRegistry,
34
37
  getEventMetadata,
38
+ messageCreatedPayloadSchema,
39
+ messageDeletedPayloadSchema,
40
+ messageEditedPayloadSchema,
35
41
  stripePaymentReceivedPayloadSchema,
36
42
  webhookOutboundContactSyncPayloadSchema
37
43
  };
@@ -95,6 +95,42 @@ declare const eventRegistry: {
95
95
  readonly backoff: "exponential";
96
96
  };
97
97
  };
98
+ readonly message_created: {
99
+ readonly type: "message_created";
100
+ readonly tier: "domain";
101
+ readonly direction: "change";
102
+ readonly pool: "events_change";
103
+ readonly aggregate: "message";
104
+ readonly version: 1;
105
+ readonly retry: {
106
+ readonly attempts: 3;
107
+ readonly backoff: "exponential";
108
+ };
109
+ };
110
+ readonly message_deleted: {
111
+ readonly type: "message_deleted";
112
+ readonly tier: "domain";
113
+ readonly direction: "change";
114
+ readonly pool: "events_change";
115
+ readonly aggregate: "message";
116
+ readonly version: 1;
117
+ readonly retry: {
118
+ readonly attempts: 3;
119
+ readonly backoff: "exponential";
120
+ };
121
+ };
122
+ readonly message_edited: {
123
+ readonly type: "message_edited";
124
+ readonly tier: "domain";
125
+ readonly direction: "change";
126
+ readonly pool: "events_change";
127
+ readonly aggregate: "message";
128
+ readonly version: 1;
129
+ readonly retry: {
130
+ readonly attempts: 3;
131
+ readonly backoff: "exponential";
132
+ };
133
+ };
98
134
  readonly stripe_payment_received: {
99
135
  readonly type: "stripe_payment_received";
100
136
  readonly tier: "domain";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  eventRegistry,
3
3
  getEventMetadata
4
- } from "../../../../chunk-JOBQ6RUU.js";
4
+ } from "../../../../chunk-LQZESSM3.js";
5
5
  import "../../../../chunk-2E224ZSN.js";
6
6
  export {
7
7
  eventRegistry,
@@ -72,6 +72,60 @@ declare const dealStageChangedPayloadSchema: z.ZodObject<{
72
72
  newStage: string;
73
73
  oldStage: string;
74
74
  }>;
75
+ declare const messageCreatedPayloadSchema: z.ZodObject<{
76
+ changedFields: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
77
+ entityId: z.ZodString;
78
+ externalId: z.ZodString;
79
+ provider: z.ZodString;
80
+ source: z.ZodString;
81
+ }, "strict", z.ZodTypeAny, {
82
+ source: string;
83
+ changedFields: Record<string, unknown> | null;
84
+ entityId: string;
85
+ externalId: string;
86
+ provider: string;
87
+ }, {
88
+ source: string;
89
+ changedFields: Record<string, unknown> | null;
90
+ entityId: string;
91
+ externalId: string;
92
+ provider: string;
93
+ }>;
94
+ declare const messageDeletedPayloadSchema: z.ZodObject<{
95
+ entityId: z.ZodString;
96
+ externalId: z.ZodString;
97
+ provider: z.ZodString;
98
+ source: z.ZodString;
99
+ }, "strict", z.ZodTypeAny, {
100
+ source: string;
101
+ entityId: string;
102
+ externalId: string;
103
+ provider: string;
104
+ }, {
105
+ source: string;
106
+ entityId: string;
107
+ externalId: string;
108
+ provider: string;
109
+ }>;
110
+ declare const messageEditedPayloadSchema: z.ZodObject<{
111
+ changedFields: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
112
+ entityId: z.ZodString;
113
+ externalId: z.ZodString;
114
+ provider: z.ZodString;
115
+ source: z.ZodString;
116
+ }, "strict", z.ZodTypeAny, {
117
+ source: string;
118
+ changedFields: Record<string, unknown> | null;
119
+ entityId: string;
120
+ externalId: string;
121
+ provider: string;
122
+ }, {
123
+ source: string;
124
+ changedFields: Record<string, unknown> | null;
125
+ entityId: string;
126
+ externalId: string;
127
+ provider: string;
128
+ }>;
75
129
  declare const stripePaymentReceivedPayloadSchema: z.ZodObject<{
76
130
  amountCents: z.ZodNumber;
77
131
  currency: z.ZodString;
@@ -177,6 +231,60 @@ declare const eventPayloadSchemas: {
177
231
  newStage: string;
178
232
  oldStage: string;
179
233
  }>;
234
+ readonly message_created: z.ZodObject<{
235
+ changedFields: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
236
+ entityId: z.ZodString;
237
+ externalId: z.ZodString;
238
+ provider: z.ZodString;
239
+ source: z.ZodString;
240
+ }, "strict", z.ZodTypeAny, {
241
+ source: string;
242
+ changedFields: Record<string, unknown> | null;
243
+ entityId: string;
244
+ externalId: string;
245
+ provider: string;
246
+ }, {
247
+ source: string;
248
+ changedFields: Record<string, unknown> | null;
249
+ entityId: string;
250
+ externalId: string;
251
+ provider: string;
252
+ }>;
253
+ readonly message_deleted: z.ZodObject<{
254
+ entityId: z.ZodString;
255
+ externalId: z.ZodString;
256
+ provider: z.ZodString;
257
+ source: z.ZodString;
258
+ }, "strict", z.ZodTypeAny, {
259
+ source: string;
260
+ entityId: string;
261
+ externalId: string;
262
+ provider: string;
263
+ }, {
264
+ source: string;
265
+ entityId: string;
266
+ externalId: string;
267
+ provider: string;
268
+ }>;
269
+ readonly message_edited: z.ZodObject<{
270
+ changedFields: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
271
+ entityId: z.ZodString;
272
+ externalId: z.ZodString;
273
+ provider: z.ZodString;
274
+ source: z.ZodString;
275
+ }, "strict", z.ZodTypeAny, {
276
+ source: string;
277
+ changedFields: Record<string, unknown> | null;
278
+ entityId: string;
279
+ externalId: string;
280
+ provider: string;
281
+ }, {
282
+ source: string;
283
+ changedFields: Record<string, unknown> | null;
284
+ entityId: string;
285
+ externalId: string;
286
+ provider: string;
287
+ }>;
180
288
  readonly stripe_payment_received: z.ZodObject<{
181
289
  amountCents: z.ZodNumber;
182
290
  currency: z.ZodString;
@@ -211,4 +319,4 @@ declare const eventPayloadSchemas: {
211
319
  }>;
212
320
  };
213
321
 
214
- export { contactCreatedPayloadSchema, contactMarkedChampionPayloadSchema, contactMergedPayloadSchema, crmSyncStartedPayloadSchema, dealCreatedPayloadSchema, dealStageChangedPayloadSchema, eventPayloadSchemas, stripePaymentReceivedPayloadSchema, webhookOutboundContactSyncPayloadSchema };
322
+ export { contactCreatedPayloadSchema, contactMarkedChampionPayloadSchema, contactMergedPayloadSchema, crmSyncStartedPayloadSchema, dealCreatedPayloadSchema, dealStageChangedPayloadSchema, eventPayloadSchemas, messageCreatedPayloadSchema, messageDeletedPayloadSchema, messageEditedPayloadSchema, stripePaymentReceivedPayloadSchema, webhookOutboundContactSyncPayloadSchema };
@@ -6,9 +6,12 @@ import {
6
6
  dealCreatedPayloadSchema,
7
7
  dealStageChangedPayloadSchema,
8
8
  eventPayloadSchemas,
9
+ messageCreatedPayloadSchema,
10
+ messageDeletedPayloadSchema,
11
+ messageEditedPayloadSchema,
9
12
  stripePaymentReceivedPayloadSchema,
10
13
  webhookOutboundContactSyncPayloadSchema
11
- } from "../../../../chunk-JRQO2IOF.js";
14
+ } from "../../../../chunk-MU54DZCC.js";
12
15
  import "../../../../chunk-2E224ZSN.js";
13
16
  export {
14
17
  contactCreatedPayloadSchema,
@@ -18,6 +21,9 @@ export {
18
21
  dealCreatedPayloadSchema,
19
22
  dealStageChangedPayloadSchema,
20
23
  eventPayloadSchemas,
24
+ messageCreatedPayloadSchema,
25
+ messageDeletedPayloadSchema,
26
+ messageEditedPayloadSchema,
21
27
  stripePaymentReceivedPayloadSchema,
22
28
  webhookOutboundContactSyncPayloadSchema
23
29
  };
@@ -56,6 +56,52 @@ interface DealStageChangedEvent extends DomainEvent {
56
56
  oldStage: string;
57
57
  };
58
58
  }
59
+ interface MessageCreatedEvent extends DomainEvent {
60
+ readonly type: 'message_created';
61
+ readonly aggregateType: 'message';
62
+ readonly payload: {
63
+ /** Differ's per-field before/after map (same value as integration_run_items.changed_fields). */
64
+ changedFields: Record<string, unknown> | null;
65
+ /** Local aggregate id the sink wrote/soft-deleted. */
66
+ entityId: string;
67
+ /** Vendor external id the change keyed on. */
68
+ externalId: string;
69
+ /** Provider label (e.g. 'slack', 'google'). */
70
+ provider: string;
71
+ /** Provenance marker — always 'integration'. A write-back action reads this to avoid echoing the change back to the vendor. */
72
+ source: string;
73
+ };
74
+ }
75
+ interface MessageDeletedEvent extends DomainEvent {
76
+ readonly type: 'message_deleted';
77
+ readonly aggregateType: 'message';
78
+ readonly payload: {
79
+ /** Local aggregate id the sink wrote/soft-deleted. */
80
+ entityId: string;
81
+ /** Vendor external id the change keyed on. */
82
+ externalId: string;
83
+ /** Provider label (e.g. 'slack', 'google'). */
84
+ provider: string;
85
+ /** Provenance marker — always 'integration'. A write-back action reads this to avoid echoing the change back to the vendor. */
86
+ source: string;
87
+ };
88
+ }
89
+ interface MessageEditedEvent extends DomainEvent {
90
+ readonly type: 'message_edited';
91
+ readonly aggregateType: 'message';
92
+ readonly payload: {
93
+ /** Differ's per-field before/after map (same value as integration_run_items.changed_fields). */
94
+ changedFields: Record<string, unknown> | null;
95
+ /** Local aggregate id the sink wrote/soft-deleted. */
96
+ entityId: string;
97
+ /** Vendor external id the change keyed on. */
98
+ externalId: string;
99
+ /** Provider label (e.g. 'slack', 'google'). */
100
+ provider: string;
101
+ /** Provenance marker — always 'integration'. A write-back action reads this to avoid echoing the change back to the vendor. */
102
+ source: string;
103
+ };
104
+ }
59
105
  /** Stripe charge.succeeded webhook, post-signature-verification. */
60
106
  interface StripePaymentReceivedEvent extends DomainEvent {
61
107
  readonly type: 'stripe_payment_received';
@@ -80,11 +126,11 @@ interface WebhookOutboundContactSyncEvent extends DomainEvent {
80
126
  operation: string;
81
127
  };
82
128
  }
83
- type AppDomainEvent = ContactCreatedEvent | ContactMarkedChampionEvent | ContactMergedEvent | CrmSyncStartedEvent | DealCreatedEvent | DealStageChangedEvent | StripePaymentReceivedEvent | WebhookOutboundContactSyncEvent;
129
+ type AppDomainEvent = ContactCreatedEvent | ContactMarkedChampionEvent | ContactMergedEvent | CrmSyncStartedEvent | DealCreatedEvent | DealStageChangedEvent | MessageCreatedEvent | MessageDeletedEvent | MessageEditedEvent | StripePaymentReceivedEvent | WebhookOutboundContactSyncEvent;
84
130
  type EventTypeName = AppDomainEvent['type'];
85
131
  type EventOfType<T extends EventTypeName> = Extract<AppDomainEvent, {
86
132
  type: T;
87
133
  }>;
88
134
  type PayloadOfType<T extends EventTypeName> = EventOfType<T>['payload'];
89
135
 
90
- export type { AppDomainEvent, ContactCreatedEvent, ContactMarkedChampionEvent, ContactMergedEvent, CrmSyncStartedEvent, DealCreatedEvent, DealStageChangedEvent, EventOfType, EventTypeName, PayloadOfType, StripePaymentReceivedEvent, WebhookOutboundContactSyncEvent };
136
+ export type { AppDomainEvent, ContactCreatedEvent, ContactMarkedChampionEvent, ContactMergedEvent, CrmSyncStartedEvent, DealCreatedEvent, DealStageChangedEvent, EventOfType, EventTypeName, MessageCreatedEvent, MessageDeletedEvent, MessageEditedEvent, PayloadOfType, StripePaymentReceivedEvent, WebhookOutboundContactSyncEvent };
@@ -2,12 +2,12 @@ import "../../../chunk-SYVZ4MD2.js";
2
2
  import {
3
3
  EventSchedulerLifecycle,
4
4
  EventsModule
5
- } from "../../../chunk-NR7QQ6ZI.js";
5
+ } from "../../../chunk-6M6LZEP6.js";
6
6
  import {
7
7
  TypedEventBus
8
- } from "../../../chunk-INO47JXD.js";
9
- import "../../../chunk-JOBQ6RUU.js";
10
- import "../../../chunk-JRQO2IOF.js";
8
+ } from "../../../chunk-PBENHIN2.js";
9
+ import "../../../chunk-LQZESSM3.js";
10
+ import "../../../chunk-MU54DZCC.js";
11
11
  import {
12
12
  EventScheduler,
13
13
  SCHEDULE_FLOOR_MS,
@@ -25,7 +25,7 @@ import {
25
25
  } from "../../../chunk-DUBZOXJC.js";
26
26
  import {
27
27
  DrizzleEventBus
28
- } from "../../../chunk-DB5UXJC3.js";
28
+ } from "../../../chunk-PNCOUFFI.js";
29
29
  import {
30
30
  MemoryEventBus
31
31
  } from "../../../chunk-GOO5ZMYO.js";
@@ -1,5 +1,5 @@
1
1
  export { DomainEvent, DrizzleTransaction, IEventBus } from './events/event-bus.protocol.js';
2
- export { EVENT_BUS } from './events/events.tokens.js';
2
+ export { EVENT_BUS, TYPED_EVENT_BUS } from './events/events.tokens.js';
3
3
  export { EventsModule } from './events/events.module.js';
4
4
  export { MemoryEventBus } from './events/event-bus.memory-backend.js';
5
5
  export { DrizzleEventBus } from './events/event-bus.drizzle-backend.js';
@@ -22,6 +22,7 @@ export { ObservabilityError } from './observability/observability-errors.js';
22
22
  export { IChangeSource, IntegrationSubscriptionView } from './integration/integration-change-source.protocol.js';
23
23
  export { CursorSnapshot } from './integration/integration-cursor-store.protocol.js';
24
24
  export { IIntegrationSink } from './integration/integration-sink.protocol.js';
25
+ export { IIntegrationChangeEmitter, IntegrationChangeAction, IntegrationChangeNotification } from './integration/integration-change-emitter.protocol.js';
25
26
  export { IntegrationRunSummary } from './integration/integration-run-recorder.protocol.js';
26
27
  export { IEntityChangeSourceRegistry, UnknownEntityError } from './integration/entity-change-source-registry.protocol.js';
27
28
  export { MemoryEntityChangeSourceRegistry } from './integration/entity-change-source-registry.memory.js';
@@ -30,7 +31,7 @@ export { PollChangeSource, PollChangeSourceOptions, PollCursor, PollFetchCallbac
30
31
  export { IncrementalRead, IncrementalReadBase, RandomRead, ReadContext, ReadMode, ReadRequest, Ref, SourcedRecord, mapConcurrent } from './integration/incremental-read.js';
31
32
  export { WebhookChangeSource, WebhookChangeSourceOptions, WebhookCursor, WebhookFetchCallback, WebhookFetchContext } from './integration/webhook-change-source.js';
32
33
  export { buildChangeSource } from './integration/build-change-source.js';
33
- export { ENTITY_CHANGE_SOURCE_REGISTRY, INTEGRATION_CHANGE_SOURCE, INTEGRATION_SINK } from './integration/integration.tokens.js';
34
+ export { ENTITY_CHANGE_SOURCE_REGISTRY, INTEGRATION_CHANGE_EMITTER, INTEGRATION_CHANGE_SOURCE, INTEGRATION_SINK } from './integration/integration.tokens.js';
34
35
  export { ExecuteIntegrationUseCase } from './integration/execute-integration.use-case.js';
35
36
  export { AuthCredentials, AuthResolveOptions, IAuthStrategy } from './auth/protocols/auth-strategy.js';
36
37
  export { IEncryptionKey } from './auth/protocols/encryption-key.js';
@@ -1,3 +1,4 @@
1
+ import "../../chunk-W4HOHZVF.js";
1
2
  import "../../chunk-ZUMULSEQ.js";
2
3
  import {
3
4
  StorageModule
@@ -19,27 +20,26 @@ import {
19
20
  } from "../../chunk-EWYCWP4H.js";
20
21
  import {
21
22
  ObservabilityModule
22
- } from "../../chunk-XKWOJZZ4.js";
23
+ } from "../../chunk-37PILMIT.js";
23
24
  import "../../chunk-AQFQ4BYM.js";
24
- import "../../chunk-CLWBNXKF.js";
25
25
  import {
26
26
  OBSERVABILITY,
27
27
  OBSERVABILITY_MODULE_OPTIONS
28
28
  } from "../../chunk-Y7RRSEOC.js";
29
- import "../../chunk-W4HOHZVF.js";
29
+ import "../../chunk-PLUJEQLU.js";
30
30
  import "../../chunk-SYVZ4MD2.js";
31
31
  import {
32
32
  EventsModule
33
- } from "../../chunk-NR7QQ6ZI.js";
34
- import "../../chunk-INO47JXD.js";
35
- import "../../chunk-JOBQ6RUU.js";
36
- import "../../chunk-JRQO2IOF.js";
33
+ } from "../../chunk-6M6LZEP6.js";
34
+ import "../../chunk-PBENHIN2.js";
35
+ import "../../chunk-LQZESSM3.js";
36
+ import "../../chunk-MU54DZCC.js";
37
37
  import "../../chunk-DUUCU77W.js";
38
38
  import "../../chunk-DUBZOXJC.js";
39
39
  import "../../chunk-IWAOY6KC.js";
40
40
  import {
41
41
  DrizzleEventBus
42
- } from "../../chunk-DB5UXJC3.js";
42
+ } from "../../chunk-PNCOUFFI.js";
43
43
  import {
44
44
  MemoryEventBus
45
45
  } from "../../chunk-GOO5ZMYO.js";
@@ -57,25 +57,26 @@ import {
57
57
  import {
58
58
  CACHE
59
59
  } from "../../chunk-L6FTY45T.js";
60
- import "../../chunk-QXVCRA23.js";
61
- import "../../chunk-VDL5CJ5C.js";
62
- import "../../chunk-6DQEIXYU.js";
63
- import "../../chunk-VQOAATIG.js";
60
+ import "../../chunk-ENAR3F5S.js";
61
+ import "../../chunk-7B7MMDOJ.js";
62
+ import "../../chunk-CKLM57IE.js";
64
63
  import "../../chunk-3VEVGL74.js";
65
64
  import "../../chunk-CDLWYZVQ.js";
66
65
  import "../../chunk-L3LZWWSX.js";
67
66
  import "../../chunk-DV4RV2DC.js";
68
- import "../../chunk-PNZSGAB2.js";
69
- import "../../chunk-SNQ3TOWP.js";
70
67
  import "../../chunk-I6MVCB5A.js";
71
68
  import "../../chunk-RHVN6NA7.js";
72
69
  import "../../chunk-E6PLM6QG.js";
70
+ import "../../chunk-VQOAATIG.js";
71
+ import "../../chunk-PNZSGAB2.js";
72
+ import "../../chunk-SNQ3TOWP.js";
73
73
  import "../../chunk-T4BIIU5E.js";
74
74
  import "../../chunk-Q6LRJ4VI.js";
75
75
  import "../../chunk-7P5ODGLA.js";
76
76
  import "../../chunk-ZPL74UQN.js";
77
77
  import {
78
- EVENT_BUS
78
+ EVENT_BUS,
79
+ TYPED_EVENT_BUS
79
80
  } from "../../chunk-H5NH7KPE.js";
80
81
  import "../../chunk-4LH67P4U.js";
81
82
  import {
@@ -109,19 +110,19 @@ import {
109
110
  import "../../chunk-OSQRXVG2.js";
110
111
  import {
111
112
  AuthModule
112
- } from "../../chunk-NXHL5YII.js";
113
+ } from "../../chunk-7LKAMLV4.js";
113
114
  import {
114
115
  EnvEncryptionKey
115
116
  } from "../../chunk-IP4OO26U.js";
117
+ import {
118
+ DrizzleOAuthStateStore
119
+ } from "../../chunk-N5OTOWTP.js";
116
120
  import {
117
121
  MemoryOAuthStateStore
118
122
  } from "../../chunk-QLTJSCE6.js";
119
123
  import {
120
124
  AuthController
121
125
  } from "../../chunk-SZVPIHWE.js";
122
- import {
123
- DrizzleOAuthStateStore
124
- } from "../../chunk-N5OTOWTP.js";
125
126
  import {
126
127
  OAuthStateError
127
128
  } from "../../chunk-BPARRK6F.js";
@@ -140,11 +141,11 @@ import {
140
141
  } from "../../chunk-6XY6ZMMD.js";
141
142
  import "../../chunk-GYGNEQSC.js";
142
143
  import "../../chunk-KVOWSC5S.js";
143
- import "../../chunk-QFUIE37H.js";
144
- import "../../chunk-FFUDEIFF.js";
145
- import "../../chunk-EO2QPOKH.js";
146
144
  import "../../chunk-PRWIX6UW.js";
147
- import "../../chunk-O2A6XHGD.js";
145
+ import "../../chunk-KFXXOFDC.js";
146
+ import "../../chunk-HN5HT5WL.js";
147
+ import "../../chunk-EO2QPOKH.js";
148
+ import "../../chunk-LLDJS7PJ.js";
148
149
  import "../../chunk-HNWZFNKP.js";
149
150
  import "../../chunk-AHV4GDYM.js";
150
151
  import "../../chunk-SQDOBLBP.js";
@@ -171,12 +172,13 @@ import {
171
172
  } from "../../chunk-3CJFPU6Q.js";
172
173
  import {
173
174
  ExecuteIntegrationUseCase
174
- } from "../../chunk-TDEHU73T.js";
175
+ } from "../../chunk-YIVQ7KLS.js";
175
176
  import {
176
177
  ENTITY_CHANGE_SOURCE_REGISTRY,
178
+ INTEGRATION_CHANGE_EMITTER,
177
179
  INTEGRATION_CHANGE_SOURCE,
178
180
  INTEGRATION_SINK
179
- } from "../../chunk-S7C6TIIF.js";
181
+ } from "../../chunk-S5G3HO7N.js";
180
182
  import "../../chunk-MZ6GV4YF.js";
181
183
  import {
182
184
  IncrementalReadBase,
@@ -207,6 +209,7 @@ export {
207
209
  EnvEncryptionKey,
208
210
  EventsModule,
209
211
  ExecuteIntegrationUseCase,
212
+ INTEGRATION_CHANGE_EMITTER,
210
213
  INTEGRATION_CHANGE_SOURCE,
211
214
  INTEGRATION_SINK,
212
215
  IncrementalReadBase,
@@ -228,6 +231,7 @@ export {
228
231
  STRATEGY_REGISTRY,
229
232
  SessionExpiredError,
230
233
  StorageModule,
234
+ TYPED_EVENT_BUS,
231
235
  UnknownEntityError,
232
236
  WebhookChangeSource,
233
237
  authOAuthState,
@@ -3,6 +3,7 @@ import { ICursorStore } from './integration-cursor-store.protocol.js';
3
3
  import { IFieldDiffer } from './integration-field-diff.protocol.js';
4
4
  import { IIntegrationSink } from './integration-sink.protocol.js';
5
5
  import { IIntegrationRunRecorder } from './integration-run-recorder.protocol.js';
6
+ import { IIntegrationChangeEmitter } from './integration-change-emitter.protocol.js';
6
7
  import 'zod';
7
8
 
8
9
  interface ExecuteIntegrationInput<T> {
@@ -47,10 +48,19 @@ declare class ExecuteIntegrationUseCase<T extends Record<string, unknown>> {
47
48
  private readonly sink;
48
49
  private readonly recorder;
49
50
  private readonly multiTenant;
51
+ private readonly emitter;
50
52
  private readonly logger;
51
- constructor(source: IChangeSource<T>, cursors: ICursorStore, differ: IFieldDiffer<T>, sink: IIntegrationSink<T>, recorder: IIntegrationRunRecorder, multiTenant?: boolean);
53
+ constructor(source: IChangeSource<T>, cursors: ICursorStore, differ: IFieldDiffer<T>, sink: IIntegrationSink<T>, recorder: IIntegrationRunRecorder, multiTenant?: boolean, emitter?: IIntegrationChangeEmitter | null);
52
54
  execute(input: ExecuteIntegrationInput<T>): Promise<ExecuteIntegrationResult>;
53
55
  private processChange;
56
+ /**
57
+ * Publish one typed data-level change event via the optional emitter
58
+ * (EMIT-CHANGES seam). No-op when no emitter is bound (the back-compat
59
+ * default). A failed publish is logged but never aborts the run — the row is
60
+ * already written; emission is best-effort (the outbox tx, when the generated
61
+ * adapter rides on one, gives the at-least-once guarantee, not this try/catch).
62
+ */
63
+ private emitChange;
54
64
  }
55
65
 
56
66
  export { type ExecuteIntegrationInput, type ExecuteIntegrationResult, ExecuteIntegrationUseCase };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ExecuteIntegrationUseCase
3
- } from "../../../chunk-TDEHU73T.js";
4
- import "../../../chunk-S7C6TIIF.js";
3
+ } from "../../../chunk-YIVQ7KLS.js";
4
+ import "../../../chunk-S5G3HO7N.js";
5
5
  import "../../../chunk-MZ6GV4YF.js";
6
6
  import "../../../chunk-2E224ZSN.js";
7
7
  export {
@@ -2,6 +2,7 @@ export { Change, ChangeSource, IChangeSource, IntegrationSubscriptionView } from
2
2
  export { CursorSnapshot, ICursorStore } from './integration-cursor-store.protocol.js';
3
3
  export { DiffResult, FieldDiff, FieldDiffSchema, FieldDiffValue, FieldDiffValueSchema, IFieldDiffer } from './integration-field-diff.protocol.js';
4
4
  export { IIntegrationSink } from './integration-sink.protocol.js';
5
+ export { IIntegrationChangeEmitter, IntegrationChangeAction, IntegrationChangeNotification } from './integration-change-emitter.protocol.js';
5
6
  export { CompleteRunInput, IIntegrationRunRecorder, IntegrationRunSummary, RecordItemInput, StartRunInput } from './integration-run-recorder.protocol.js';
6
7
  export { ILoopbackFingerprintStore } from './integration-loopback.protocol.js';
7
8
  export { IEntityChangeSourceRegistry, UnknownEntityError } from './entity-change-source-registry.protocol.js';
@@ -13,7 +14,7 @@ export { PollChangeSource, PollChangeSourceOptions, PollCursor, PollFetchCallbac
13
14
  export { IncrementalRead, IncrementalReadBase, RandomRead, ReadContext, ReadMode, ReadRequest, Ref, SourcedRecord, mapConcurrent } from './incremental-read.js';
14
15
  export { WebhookChangeSource, WebhookChangeSourceOptions, WebhookCursor, WebhookFetchCallback, WebhookFetchContext } from './webhook-change-source.js';
15
16
  export { buildChangeSource } from './build-change-source.js';
16
- export { ENTITY_CHANGE_SOURCE_REGISTRY, INTEGRATION_CHANGE_SOURCE, INTEGRATION_CURSOR_STORE, INTEGRATION_FIELD_DIFFER, INTEGRATION_MODULE_OPTIONS, INTEGRATION_MULTI_TENANT, INTEGRATION_RUN_RECORDER, INTEGRATION_SINK } from './integration.tokens.js';
17
+ export { ENTITY_CHANGE_SOURCE_REGISTRY, INTEGRATION_CHANGE_EMITTER, INTEGRATION_CHANGE_SOURCE, INTEGRATION_CURSOR_STORE, INTEGRATION_FIELD_DIFFER, INTEGRATION_MODULE_OPTIONS, INTEGRATION_MULTI_TENANT, INTEGRATION_RUN_RECORDER, INTEGRATION_SINK } from './integration.tokens.js';
17
18
  export { MissingTenantIdError, assertTenantId } from './integration-errors.js';
18
19
  export { IntegrationRunItemRow, IntegrationRunRow, IntegrationSubscriptionRow, integrationRunActionEnum, integrationRunDirectionEnum, integrationRunItemOperationEnum, integrationRunItemStatusEnum, integrationRunItems, integrationRunStatusEnum, integrationRuns, integrationSubscriptions } from './integration-audit.schema.js';
19
20
  export { MemoryCursorStore } from './integration-cursor-store.memory-backend.js';
@@ -1,19 +1,19 @@
1
1
  import "../../../chunk-KVOWSC5S.js";
2
+ import {
3
+ createLoopbackMiddleware
4
+ } from "../../../chunk-PRWIX6UW.js";
2
5
  import {
3
6
  IntegrationModule
4
- } from "../../../chunk-QFUIE37H.js";
7
+ } from "../../../chunk-KFXXOFDC.js";
5
8
  import {
6
9
  DrizzleIntegrationRunRecorder
7
- } from "../../../chunk-FFUDEIFF.js";
10
+ } from "../../../chunk-HN5HT5WL.js";
8
11
  import {
9
12
  MemoryRunRecorder
10
13
  } from "../../../chunk-EO2QPOKH.js";
11
- import {
12
- createLoopbackMiddleware
13
- } from "../../../chunk-PRWIX6UW.js";
14
14
  import {
15
15
  PostgresCursorStore
16
- } from "../../../chunk-O2A6XHGD.js";
16
+ } from "../../../chunk-LLDJS7PJ.js";
17
17
  import {
18
18
  integrationRunActionEnum,
19
19
  integrationRunDirectionEnum,
@@ -61,9 +61,10 @@ import {
61
61
  } from "../../../chunk-3CJFPU6Q.js";
62
62
  import {
63
63
  ExecuteIntegrationUseCase
64
- } from "../../../chunk-TDEHU73T.js";
64
+ } from "../../../chunk-YIVQ7KLS.js";
65
65
  import {
66
66
  ENTITY_CHANGE_SOURCE_REGISTRY,
67
+ INTEGRATION_CHANGE_EMITTER,
67
68
  INTEGRATION_CHANGE_SOURCE,
68
69
  INTEGRATION_CURSOR_STORE,
69
70
  INTEGRATION_FIELD_DIFFER,
@@ -71,7 +72,7 @@ import {
71
72
  INTEGRATION_MULTI_TENANT,
72
73
  INTEGRATION_RUN_RECORDER,
73
74
  INTEGRATION_SINK
74
- } from "../../../chunk-S7C6TIIF.js";
75
+ } from "../../../chunk-S5G3HO7N.js";
75
76
  import {
76
77
  MissingTenantIdError,
77
78
  assertTenantId
@@ -93,6 +94,7 @@ export {
93
94
  FieldDiffSchema,
94
95
  FieldDiffValueSchema,
95
96
  FieldMappingSchema,
97
+ INTEGRATION_CHANGE_EMITTER,
96
98
  INTEGRATION_CHANGE_SOURCE,
97
99
  INTEGRATION_CURSOR_STORE,
98
100
  INTEGRATION_FIELD_DIFFER,