@memberjunction/communication-engine 6.3.0-edge.1 → 6.3.0-edge.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/README.md +203 -0
  2. package/dist/CommsActivityWorker.d.ts +130 -0
  3. package/dist/CommsActivityWorker.d.ts.map +1 -0
  4. package/dist/CommsActivityWorker.js +1054 -0
  5. package/dist/CommsActivityWorker.js.map +1 -0
  6. package/dist/DefaultCommunicationPrincipal.d.ts +62 -0
  7. package/dist/DefaultCommunicationPrincipal.d.ts.map +1 -0
  8. package/dist/DefaultCommunicationPrincipal.js +382 -0
  9. package/dist/DefaultCommunicationPrincipal.js.map +1 -0
  10. package/dist/Engine.d.ts +54 -1
  11. package/dist/Engine.d.ts.map +1 -1
  12. package/dist/Engine.js +123 -2
  13. package/dist/Engine.js.map +1 -1
  14. package/dist/LocalJsonCommunicationProvider.d.ts +133 -0
  15. package/dist/LocalJsonCommunicationProvider.d.ts.map +1 -0
  16. package/dist/LocalJsonCommunicationProvider.js +1337 -0
  17. package/dist/LocalJsonCommunicationProvider.js.map +1 -0
  18. package/dist/V2SendService.d.ts +293 -0
  19. package/dist/V2SendService.d.ts.map +1 -0
  20. package/dist/V2SendService.js +2035 -0
  21. package/dist/V2SendService.js.map +1 -0
  22. package/dist/compliance/ComplianceGate.d.ts +56 -0
  23. package/dist/compliance/ComplianceGate.d.ts.map +1 -0
  24. package/dist/compliance/ComplianceGate.js +452 -0
  25. package/dist/compliance/ComplianceGate.js.map +1 -0
  26. package/dist/compliance/JurisdictionResolver.d.ts +82 -0
  27. package/dist/compliance/JurisdictionResolver.d.ts.map +1 -0
  28. package/dist/compliance/JurisdictionResolver.js +249 -0
  29. package/dist/compliance/JurisdictionResolver.js.map +1 -0
  30. package/dist/compliance/index.d.ts +4 -0
  31. package/dist/compliance/index.d.ts.map +1 -0
  32. package/dist/compliance/index.js +4 -0
  33. package/dist/compliance/index.js.map +1 -0
  34. package/dist/compliance/rules/ConsentEvidenceRuleDriver.d.ts +22 -0
  35. package/dist/compliance/rules/ConsentEvidenceRuleDriver.d.ts.map +1 -0
  36. package/dist/compliance/rules/ConsentEvidenceRuleDriver.js +76 -0
  37. package/dist/compliance/rules/ConsentEvidenceRuleDriver.js.map +1 -0
  38. package/dist/compliance/rules/ConsentExpiryRuleDriver.d.ts +20 -0
  39. package/dist/compliance/rules/ConsentExpiryRuleDriver.d.ts.map +1 -0
  40. package/dist/compliance/rules/ConsentExpiryRuleDriver.js +70 -0
  41. package/dist/compliance/rules/ConsentExpiryRuleDriver.js.map +1 -0
  42. package/dist/compliance/rules/ConsentModelRuleDriver.d.ts +22 -0
  43. package/dist/compliance/rules/ConsentModelRuleDriver.d.ts.map +1 -0
  44. package/dist/compliance/rules/ConsentModelRuleDriver.js +65 -0
  45. package/dist/compliance/rules/ConsentModelRuleDriver.js.map +1 -0
  46. package/dist/compliance/rules/QuietHoursRuleDriver.d.ts +37 -0
  47. package/dist/compliance/rules/QuietHoursRuleDriver.d.ts.map +1 -0
  48. package/dist/compliance/rules/QuietHoursRuleDriver.js +144 -0
  49. package/dist/compliance/rules/QuietHoursRuleDriver.js.map +1 -0
  50. package/dist/compliance/rules/RequireDoubleOptInRuleDriver.d.ts +16 -0
  51. package/dist/compliance/rules/RequireDoubleOptInRuleDriver.d.ts.map +1 -0
  52. package/dist/compliance/rules/RequireDoubleOptInRuleDriver.js +40 -0
  53. package/dist/compliance/rules/RequireDoubleOptInRuleDriver.js.map +1 -0
  54. package/dist/compliance/rules/RuleParamUtils.d.ts +13 -0
  55. package/dist/compliance/rules/RuleParamUtils.d.ts.map +1 -0
  56. package/dist/compliance/rules/RuleParamUtils.js +51 -0
  57. package/dist/compliance/rules/RuleParamUtils.js.map +1 -0
  58. package/dist/compliance/rules/SenderIdentificationRuleDriver.d.ts +17 -0
  59. package/dist/compliance/rules/SenderIdentificationRuleDriver.d.ts.map +1 -0
  60. package/dist/compliance/rules/SenderIdentificationRuleDriver.js +64 -0
  61. package/dist/compliance/rules/SenderIdentificationRuleDriver.js.map +1 -0
  62. package/dist/compliance/rules/TrackingConsentRuleDriver.d.ts +23 -0
  63. package/dist/compliance/rules/TrackingConsentRuleDriver.d.ts.map +1 -0
  64. package/dist/compliance/rules/TrackingConsentRuleDriver.js +81 -0
  65. package/dist/compliance/rules/TrackingConsentRuleDriver.js.map +1 -0
  66. package/dist/compliance/rules/UnsubscribeHonorWindowRuleDriver.d.ts +21 -0
  67. package/dist/compliance/rules/UnsubscribeHonorWindowRuleDriver.d.ts.map +1 -0
  68. package/dist/compliance/rules/UnsubscribeHonorWindowRuleDriver.js +33 -0
  69. package/dist/compliance/rules/UnsubscribeHonorWindowRuleDriver.js.map +1 -0
  70. package/dist/compliance/rules/UnsubscribeMechanismRuleDriver.d.ts +19 -0
  71. package/dist/compliance/rules/UnsubscribeMechanismRuleDriver.d.ts.map +1 -0
  72. package/dist/compliance/rules/UnsubscribeMechanismRuleDriver.js +73 -0
  73. package/dist/compliance/rules/UnsubscribeMechanismRuleDriver.js.map +1 -0
  74. package/dist/compliance/rules/index.d.ts +10 -0
  75. package/dist/compliance/rules/index.d.ts.map +1 -0
  76. package/dist/compliance/rules/index.js +10 -0
  77. package/dist/compliance/rules/index.js.map +1 -0
  78. package/dist/index.d.ts +5 -0
  79. package/dist/index.d.ts.map +1 -1
  80. package/dist/index.js +5 -0
  81. package/dist/index.js.map +1 -1
  82. package/dist/tsconfig.tsbuildinfo +1 -1
  83. package/package.json +9 -9
package/README.md CHANGED
@@ -179,6 +179,209 @@ sequenceDiagram
179
179
  | `SendSingleMessage(provider, type, message, run?, preview?, credentials?)` | Send one message |
180
180
  | `SendMessages(provider, type, message, recipients, preview?, credentials?)` | Send to multiple recipients |
181
181
  | `CreateDraft(message, providerName, contextUser?, credentials?)` | Create a draft message |
182
+ | `Send(params, contextUser?)` | V2: compliance-gated send to principals and endpoints |
183
+ | `EvaluateEligibility(params, contextUser?)` | V2: run the compliance gate without sending |
184
+ | `ResolveEndpoints(records, channelID, contextUser?)` | V2: resolve (and register) the endpoints of principal records |
185
+ | `ConfigureV2Dispatch(config)` | V2: set chunking, tracking URL, HMAC secret, enforcement default and work-queue publisher |
186
+ | `StartScheduledDeferralSweep(intervalMs?)` / `StopScheduledDeferralSweep()` | V2: periodically send due deferred and scheduled messages |
187
+ | `ProcessDueScheduledLogs(contextUser?, batchSize?)` | V2: run one sweep pass |
188
+ | `CheckV1ComplianceGate(channelID, address, messageClass?, contextUser?)` / `CheckV1ComplianceGateBatch(...)` | Endpoint-status and suppression check used by the V1 send path |
189
+
190
+ ## Communications V2
191
+
192
+ V2 sends are addressed to principals (records) and endpoints (addresses) under a sender, a channel and a message
193
+ class. Every recipient passes through a compliance gate before anything reaches the provider, and delivery
194
+ events flow back into suppressions and consent. Read the
195
+ [Communications V2 Guide](../../../guides/COMMUNICATIONS_V2_GUIDE.md) for the data flow, the entities, the
196
+ deployment requirements and the extension points; this section is the package's API.
197
+
198
+ ### What this package adds
199
+
200
+ | Export | Purpose |
201
+ |--------|---------|
202
+ | `CommunicationEngine.Send()`, `EvaluateEligibility()`, `ResolveEndpoints()` | The V2 entry points (table above) |
203
+ | `V2SendService`, `V2DispatchConfig` | The pipeline behind those methods and its settings. Use it through the engine. |
204
+ | `ComplianceGate`, `ComplianceGateEvalOptions` | The gate. Synchronous, no I/O; usable directly in tests and simulators. |
205
+ | `JurisdictionResolver`, `ComplianceMetadataSource` | Jurisdiction expansion and regime/rule selection over the cached metadata |
206
+ | `ConsentModelRuleDriver`, `RequireDoubleOptInRuleDriver`, `ConsentEvidenceRuleDriver`, `ConsentExpiryRuleDriver`, `UnsubscribeMechanismRuleDriver`, `UnsubscribeHonorWindowRuleDriver`, `SenderIdentificationRuleDriver`, `QuietHoursRuleDriver`, `TrackingConsentRuleDriver` | The nine built-in rule drivers |
207
+ | `ReadParamValue`, `ReadBooleanParam`, `ReadNumberParam`, `ReadStringParam` | Helpers for reading rule parameters in camelCase or PascalCase |
208
+ | `DefaultCommunicationPrincipal` | Metadata-driven principal driver, used for any entity without its own |
209
+ | `PrincipalRecordKey`, `NormalizeEndpointAddress`, `ComputeEndpointHash` | Keys, address normalization and the endpoint hash |
210
+ | `CommsActivityWorker` | Applies `NormalizedActivityEvent`s: endpoint health, suppressions, opt-outs, audit log, activity rows; `EraseEndpointPII()` |
211
+ | `SoftBounceThresholdPolicy` | Built-in suppression policy |
212
+ | `ComputeTrackingSignature`, `VerifyTrackingSignature`, `RewriteLinksForTracking`, `InjectOpenPixel`, `ComputeProtectedElementsHash` | Tracking and integrity helpers |
213
+
214
+ ### Sending
215
+
216
+ A new installation cannot send until a sender, a provider, a provider message type and an address mapping for
217
+ the recipient's entity are configured. See
218
+ [Minimum setup to send one email](../../../guides/COMMUNICATIONS_V2_GUIDE.md#minimum-setup-to-send-one-email)
219
+ in the guide.
220
+
221
+ ```typescript
222
+ import { CommunicationEngine } from '@memberjunction/communication-engine';
223
+
224
+ await CommunicationEngine.Instance.Config(false, contextUser);
225
+
226
+ const result = await CommunicationEngine.Instance.Send(
227
+ {
228
+ Envelope: {
229
+ ChannelID: emailChannelID, // MJ: Communication Base Message Types ID
230
+ MessageClass: 'Marketing',
231
+ PreferenceID: newsletterPreferenceID, // optional; enables the opt-in check
232
+ // SenderID omitted: the active sender with IsDefault = 1
233
+ },
234
+ Payload: { Subject: 'October newsletter', HTMLBody: '<p>Hello</p>', Body: 'Hello' },
235
+ Recipients: [{ Principal: { EntityID: contactsEntityID, RecordID: contactID } }],
236
+ },
237
+ contextUser,
238
+ );
239
+
240
+ if (!result.Success) {
241
+ throw new Error(result.ErrorMessage); // the send could not start
242
+ }
243
+ for (const outcome of result.Outcomes ?? []) {
244
+ // Status: 'Sent' | 'Blocked' | 'Deferred' | 'Failed' | 'DryRun'
245
+ console.log(outcome.Status, outcome.Reason, outcome.Detail);
246
+ }
247
+ ```
248
+
249
+ `Send()` checks, in order: an active sender (the default one when `SenderID` is omitted), the caller's
250
+ permission on it (`MJ: Communication Sender Permissions`; a sender chain with no rows is unrestricted), the
251
+ provider, and a verified sending domain when the provider has `RequireVerifiedDomain`. Any of these failing
252
+ returns `Success: false`. After that, blocked or failed recipients are reported per recipient and do not change
253
+ `Success`.
254
+
255
+ The provider is the envelope's `ProviderID`, else the sender's `CommunicationProviderID`. When neither is set,
256
+ `Send()` uses the only active sending provider for the channel, and fails if there are several rather than
257
+ pick one.
258
+
259
+ With more recipients than `AsyncThreshold` and a configured `EnqueueWork`, the send is published as
260
+ `comms.dispatch` chunks and returns `IsAsyncRun: true` without `Outcomes`. Each chunk carries the caller's
261
+ `ActingUserID`, so the worker sends as that user.
262
+
263
+ **Runs.** A send with no `CommunicationRunID` starts a run and ends it. A send given a `CommunicationRunID`
264
+ (a `comms.dispatch` chunk, a templated batch) adds to that run and leaves it open. A chunked run stores its
265
+ `ChunkCount`; each chunk, on every exit including refusals and errors, records a `MJ: Communication Run
266
+ Chunks` row (unique per run and chunk index, so a redelivered chunk is not counted twice). The chunk that
267
+ brings the count to `ChunkCount` sets the run's `Status` to `Complete`, or `Failed` if any chunk was
268
+ refused, and sets `EndedAt`.
269
+
270
+ **Delivery guarantee.** A log is claimed with one conditional `UPDATE` before the provider call, so two
271
+ workers never send the same run and endpoint at once; the database provider must support `ExecuteSQL`, and
272
+ without it nothing is sent. What happens when a log is found stuck `In-Progress` with no
273
+ `ProviderMessageID` for over 15 minutes (its worker died, or saving the log failed after the provider call)
274
+ depends on the send's `DeliveryGuarantee`:
275
+
276
+ | Setting | Stuck log is... | Consequence |
277
+ |---|---|---|
278
+ | `At Most Once` (default) | reported `Failed` with reason `OutcomeUnknown`, never resent | The recipient may miss the message. Settle it from the provider's delivery events. |
279
+ | `At Least Once` | reclaimed and sent again | The recipient may get the message twice. |
280
+
281
+ The setting comes from the first of these that has one: `Envelope.DeliveryGuarantee`, the run's
282
+ `DeliveryGuarantee`, the sender's, its ancestor senders' (nearest first), then the provider's (which defaults
283
+ to `At Most Once`). If resolving it fails, `At Most Once` is used. The claim SQL is written for SQL Server.
284
+
285
+ **Dry runs.** With `Envelope.DryRun`, an accepted message is reported `DryRun` and counted in `DryRunCount`,
286
+ not `QueuedCount`. Its log is `Complete` with `IsDryRun` set.
287
+
288
+ **Deferred sends.** A deferred or scheduled recipient's rendered message is stored in the log's
289
+ `DeferredPayload` and cleared once the message is dispatched. `CorrelationData` holds only the caller's data.
290
+
291
+ **Preferences across senders.** A principal's choice for a preference is read for the sender, its ancestors
292
+ and sender-less rows. An opt-out at any of those levels blocks the send; otherwise the nearest row wins.
293
+
294
+ ### Checking eligibility
295
+
296
+ ```typescript
297
+ const { Sendable, Blocked } = await CommunicationEngine.Instance.EvaluateEligibility(
298
+ { Envelope: envelope, Recipients: recipients },
299
+ contextUser,
300
+ );
301
+ for (const b of Blocked) console.log(b.Reason, b.Detail);
302
+ for (const s of Sendable) console.log(s.Decision, s.DeferUntil, s.Obligations);
303
+ ```
304
+
305
+ ### Using the gate directly
306
+
307
+ ```typescript
308
+ import { ComplianceGate, JurisdictionResolver } from '@memberjunction/communication-engine';
309
+
310
+ const gate = new ComplianceGate(new JurisdictionResolver()); // reads CommunicationEngineBase.Instance
311
+ const decision = gate.Evaluate(
312
+ {
313
+ Sender: sender, // MJCommunicationSenderEntity
314
+ SenderAncestors: [],
315
+ Endpoint: endpoint, // MJCommunicationEndpointEntity
316
+ MessageClass: 'Marketing',
317
+ ChannelID: emailChannelID,
318
+ Now: new Date(),
319
+ },
320
+ { Suppressions: suppressions, RecipientJurisdiction: 'DE' },
321
+ );
322
+ // decision.Decision: 'Allowed' | 'Blocked' | 'Deferred'
323
+ ```
324
+
325
+ `JurisdictionResolver` takes an optional `ComplianceMetadataSource`, so tests can supply plain arrays instead of
326
+ a configured engine.
327
+
328
+ ### Processing activity
329
+
330
+ ```typescript
331
+ import { CommsActivityWorker } from '@memberjunction/communication-engine';
332
+
333
+ const worker = new CommsActivityWorker();
334
+ const batch = await worker.ProcessActivityBatch(events, contextUser); // NormalizedActivityEvent[]
335
+ // batch.ProcessedCount, batch.DuplicateCount, batch.ErrorCount
336
+
337
+ const erased = await worker.EraseEndpointPII('person@example.org', emailChannelID, contextUser);
338
+ ```
339
+
340
+ MJAPI calls `ProcessActivityBatch` from its `comms.activity` work-queue handler; call it yourself only when you
341
+ ingest events another way.
342
+
343
+ ### Configuration
344
+
345
+ ```typescript
346
+ CommunicationEngine.Instance.ConfigureV2Dispatch({
347
+ ChunkSize: 50, // recipients per comms.dispatch item
348
+ AsyncThreshold: 100, // above this, publish to the work queue
349
+ BaseTrackingURL: 'https://api.example.org/comms',
350
+ TrackingHMACSecret: secret,
351
+ InstanceEnforcementMode: 'Enforce',
352
+ EnqueueWork: async (topic, payload) => { /* publish to your queue */ },
353
+ });
354
+ ```
355
+
356
+ | Setting | Default | Notes |
357
+ |---------|---------|-------|
358
+ | `ChunkSize` | 50 | |
359
+ | `AsyncThreshold` | 100 | |
360
+ | `BaseTrackingURL` | none | Base of unsubscribe, open and click links. MJAPI sets it to its public `/comms` URL. Unset, links are relative and do not work in mail. |
361
+ | `TrackingHMACSecret` | `MJ_COMMS_HMAC_SECRET` | Signs click-tracking links and open pixels. With neither set, links are not rewritten and the pixel is unsigned. |
362
+ | `InstanceEnforcementMode` | `Enforce` | Used for senders with no `EnforcementMode`. |
363
+ | `EnqueueWork` | none | Without it every send runs inline. MJAPI supplies a work-queue publisher. |
364
+
365
+ Each call merges into the existing configuration and clears the 60-second caches of senders and preferences.
366
+
367
+ | Environment variable | Required | Purpose |
368
+ |----------------------|----------|---------|
369
+ | `MJ_COMMS_HMAC_SECRET` | For click tracking | Fallback for `TrackingHMACSecret`. A secret: long, random, the same on every instance. Unset, click links are left as written and open pixels are unsigned. |
370
+
371
+ MJAPI configures all of this at startup (`ConfigureCommsV2WorkQueue` in `@memberjunction/server`); a standalone
372
+ host must call `ConfigureV2Dispatch()` and, if it wants deferred sends, `StartScheduledDeferralSweep()` itself.
373
+
374
+ ### V1 sends can opt in to the suppression check
375
+
376
+ V1 `SendSingleMessage()` and `SendMessages()` are unchanged by default. Set `Message.CheckComplianceGate = true`
377
+ on a message, or `MJ_COMMS_V1_COMPLIANCE_GATE=true` for the whole instance, to check the To, CC and BCC
378
+ addresses against endpoint status and active suppressions before the provider is called. The class is
379
+ `Message.MessageClass` (`Transactional` when absent), so a checked V1 send is blocked by hard bounces, invalid
380
+ addresses and erased endpoints, and additionally by complaints, unsubscribes, admin blocks and policy
381
+ suppressions when the caller marks it `Operational` or `Marketing`. Suppressions on a principal that has used
382
+ the address (through `MJ: Communication Endpoint Principals`) count as well as suppressions on the address
383
+ itself. A blocked send returns `Success: false` and marks its log `Failed`. Addresses with no endpoint row are
384
+ always allowed.
182
385
 
183
386
  ## Dependencies
184
387
 
@@ -0,0 +1,130 @@
1
+ import { BaseCommunicationSuppressionPolicy, NormalizedActivityEvent } from '@memberjunction/communication-types';
2
+ import { UserInfo } from '@memberjunction/core';
3
+ import type { MJCommunicationSuppressionEntity } from '@memberjunction/core-entities';
4
+ /** Options for {@link CommsActivityWorker.ProcessActivityBatch}. */
5
+ export interface ProcessActivityOptions {
6
+ /** Write an `MJ: Communication Activities` row per event. Defaults to `true`. */
7
+ PersistActivity?: boolean;
8
+ }
9
+ /** Counts for one processed batch. */
10
+ export interface ProcessActivityBatchResult {
11
+ /** Events applied. */
12
+ ProcessedCount: number;
13
+ /**
14
+ * Events skipped because their `ProviderEventID` was already recorded or repeated in the batch.
15
+ */
16
+ DuplicateCount: number;
17
+ /** Events that failed. Their deduplication claim is released so a retry can process them. */
18
+ ErrorCount: number;
19
+ /**
20
+ * Open and click hits from MJ's own routes whose tracking token matched no message log. They
21
+ * are dropped: not recorded, and not counted as errors.
22
+ */
23
+ UnmatchedCount?: number;
24
+ }
25
+ /** Result of {@link CommsActivityWorker.EraseEndpointPII}. */
26
+ export interface EraseEndpointPIIResult {
27
+ /** Whether an endpoint matched. */
28
+ Found: boolean;
29
+ /** The erased endpoint. */
30
+ CommunicationEndpointID?: string;
31
+ /** Logs whose `RecipientAddress` was cleared. */
32
+ ScrubbedLogs: number;
33
+ /** Activity rows whose `IPAddress`, `UserAgent` and `RawPayload` were cleared. */
34
+ ScrubbedActivities: number;
35
+ /** Always 0: the consent audit log is append-only and is not changed by erasure. */
36
+ ScrubbedAuditLogs: number;
37
+ }
38
+ /**
39
+ * Processes normalized provider activity events (`comms.activity` WorkQueue worker)
40
+ * and implements GDPR endpoint PII erasure.
41
+ */
42
+ export declare class CommsActivityWorker {
43
+ /**
44
+ * Processes a batch of normalized activity events: deduplicates by provider event ID,
45
+ * correlates to logs/endpoints, detects machine opens/clicks, updates endpoint health
46
+ * and suppressions/consent, invokes principal & policy drivers, and optionally persists
47
+ * `MJ: Communication Activities` rows.
48
+ */
49
+ ProcessActivityBatch(events: NormalizedActivityEvent[], contextUser: UserInfo, options?: ProcessActivityOptions): Promise<ProcessActivityBatchResult>;
50
+ /**
51
+ * True for an open or click hit from MJ's own routes whose tracking token matches no message
52
+ * log. Those routes accept a hit on its signature alone and leave the lookup to this worker, so
53
+ * a hit for a message that no longer exists arrives here. There is nothing to record it
54
+ * against, and it must not count as an error: an error makes the queue retry it for good.
55
+ */
56
+ private isUnmatchedTrackingHit;
57
+ /**
58
+ * GDPR erasure routine: marks the endpoint `Erased`, clears `NormalizedValue`
59
+ * while preserving `ValueHash` and all `CommunicationSuppression` rows, clears
60
+ * `RecipientAddress` on the endpoint's logs, and clears `IPAddress`, `UserAgent` and
61
+ * `RawPayload` on its activity rows. Consent audit log rows are append-only and are not changed.
62
+ *
63
+ * @param endpointIdOrAddress - An `MJ: Communication Endpoints` ID, or a raw address.
64
+ * @param channelID - `MJ: Communication Base Message Types` ID, used when matching by address.
65
+ */
66
+ EraseEndpointPII(endpointIdOrAddress: string, channelID: string, contextUser: UserInfo): Promise<EraseEndpointPIIResult>;
67
+ /**
68
+ * Determines whether an Opened/Clicked User-Agent represents an automated proxy
69
+ * or link scanner (Apple MPP, GoogleImageProxy, Microsoft SafeLinks, Proofpoint, Barracuda).
70
+ */
71
+ IsMachineUserAgent(userAgent?: string | null): boolean;
72
+ private getProvider;
73
+ private getRunView;
74
+ private ensureFirstPartyEventId;
75
+ private processSingleEvent;
76
+ private deduplicateEvents;
77
+ private providerEventKey;
78
+ private loadExistingProviderEventKeys;
79
+ private claimProviderEvent;
80
+ private correlateEvent;
81
+ private buildLogCorrelationFilter;
82
+ private hydrateEventFromLog;
83
+ private resolveOrLoadEndpoint;
84
+ private applyComplianceAndHealth;
85
+ private handleDelivered;
86
+ private handleSoftBounce;
87
+ private resolveSoftBouncePolicyConfig;
88
+ private handleHardBounce;
89
+ private handleDropped;
90
+ private mapDropReason;
91
+ private handleSpamComplaint;
92
+ private handleUnsubscribed;
93
+ private upsertPrincipalPreferenceOptOut;
94
+ private appendConsentAuditLog;
95
+ private handleEngagement;
96
+ private saveEndpoint;
97
+ /**
98
+ * Creates an active suppression and its consent audit entry, unless an Active suppression with
99
+ * the same scope, reason and policy already exists (then that one is returned and nothing is
100
+ * written). For use by suppression policy drivers, which re-evaluate on every batch.
101
+ *
102
+ * @param fields - The suppression's scope (endpoint and/or principal, sender, preference,
103
+ * channel), reason, source and dates.
104
+ * @returns The saved or existing suppression. Throws when the lookup or the save fails.
105
+ */
106
+ CreatePolicySuppression(fields: Parameters<CommsActivityWorker['createSuppression']>[0], contextUser: UserInfo): Promise<MJCommunicationSuppressionEntity | undefined>;
107
+ /**
108
+ * Creates a suppression unless an Active one with exactly the same scope and reason already
109
+ * exists. Used for state-change events (unsubscribe, policy cooldown) that can arrive more than
110
+ * once for the same recipient, so repeats add no suppression or consent-audit row. A failed
111
+ * lookup throws: the batch is retried rather than guessing.
112
+ */
113
+ private createSuppressionIfAbsent;
114
+ private findActiveSuppression;
115
+ private createSuppression;
116
+ private persistActivityRow;
117
+ private dispatchDriverHooks;
118
+ private getPrincipalDriver;
119
+ private findEndpointForErasure;
120
+ private scrubLogsForEndpoint;
121
+ private scrubActivitiesForEndpoint;
122
+ }
123
+ /**
124
+ * Built-in policy driver for `SoftBounceThresholdPolicy`: evaluates soft-bounce
125
+ * counts against the configured threshold and creates a cooldown `Policy` suppression.
126
+ */
127
+ export declare class SoftBounceThresholdPolicy extends BaseCommunicationSuppressionPolicy {
128
+ Evaluate(events: NormalizedActivityEvent[], parameters: Record<string, unknown>, contextUser: UserInfo): Promise<void>;
129
+ }
130
+ //# sourceMappingURL=CommsActivityWorker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommsActivityWorker.d.ts","sourceRoot":"","sources":["../src/CommsActivityWorker.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,kCAAkC,EAElC,uBAAuB,EAExB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAKL,QAAQ,EACT,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAQV,gCAAgC,EAEjC,MAAM,+BAA+B,CAAC;AAkBvC,oEAAoE;AACpE,MAAM,WAAW,sBAAsB;IACrC,iFAAiF;IACjF,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,sCAAsC;AACtC,MAAM,WAAW,0BAA0B;IACzC,sBAAsB;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB,6FAA6F;IAC7F,UAAU,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,8DAA8D;AAC9D,MAAM,WAAW,sBAAsB;IACrC,mCAAmC;IACnC,KAAK,EAAE,OAAO,CAAC;IACf,2BAA2B;IAC3B,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,iDAAiD;IACjD,YAAY,EAAE,MAAM,CAAC;IACrB,kFAAkF;IAClF,kBAAkB,EAAE,MAAM,CAAC;IAC3B,oFAAoF;IACpF,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAWD;;;GAGG;AACH,qBAAa,mBAAmB;IAC9B;;;;;OAKG;IACU,oBAAoB,CAC/B,MAAM,EAAE,uBAAuB,EAAE,EACjC,WAAW,EAAE,QAAQ,EACrB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,0BAA0B,CAAC;IAyFtC;;;;;OAKG;IACH,OAAO,CAAC,sBAAsB;IAO9B;;;;;;;;OAQG;IACU,gBAAgB,CAC3B,mBAAmB,EAAE,MAAM,EAC3B,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,QAAQ,GACpB,OAAO,CAAC,sBAAsB,CAAC;IA0ClC;;;OAGG;IACI,kBAAkB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO;IAoB7D,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,uBAAuB;YAkCjB,kBAAkB;YAwBlB,iBAAiB;IAyC/B,OAAO,CAAC,gBAAgB;YAIV,6BAA6B;YA6C7B,kBAAkB;YAmClB,cAAc;IA+B5B,OAAO,CAAC,yBAAyB;IAqBjC,OAAO,CAAC,mBAAmB;YAmCb,qBAAqB;YAiDrB,wBAAwB;YAkCxB,eAAe;YAoBf,gBAAgB;IAkB9B,OAAO,CAAC,6BAA6B;YAmCvB,gBAAgB;YAgChB,aAAa;IAkC3B,OAAO,CAAC,aAAa;YAuBP,mBAAmB;YA4BnB,kBAAkB;YAiFlB,+BAA+B;YAqE/B,qBAAqB;YAqCrB,gBAAgB;YAWhB,YAAY;IAU1B;;;;;;;;OAQG;IACU,uBAAuB,CAClC,MAAM,EAAE,UAAU,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,EAC/D,WAAW,EAAE,QAAQ,GACpB,OAAO,CAAC,gCAAgC,GAAG,SAAS,CAAC;IAIxD;;;;;OAKG;YACW,yBAAyB;YAWzB,qBAAqB;YAoCrB,iBAAiB;YAwEjB,kBAAkB;YAwClB,mBAAmB;IA+EjC,OAAO,CAAC,kBAAkB;YAYZ,sBAAsB;YAoCtB,oBAAoB;YAoCpB,0BAA0B;CAsCzC;AAqBD;;;GAGG;AACH,qBACa,yBAA0B,SAAQ,kCAAkC;IAClE,QAAQ,CACnB,MAAM,EAAE,uBAAuB,EAAE,EACjC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACnC,WAAW,EAAE,QAAQ,GACpB,OAAO,CAAC,IAAI,CAAC;CAqFjB"}