@ariaflowagents/messaging 0.8.1

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 (42) hide show
  1. package/README.md +165 -0
  2. package/dist/adapter/createMessagingRouter.d.ts +37 -0
  3. package/dist/adapter/createMessagingRouter.d.ts.map +1 -0
  4. package/dist/adapter/createMessagingRouter.js +115 -0
  5. package/dist/adapter/createMessagingRouter.js.map +1 -0
  6. package/dist/adapter/session-resolver.d.ts +13 -0
  7. package/dist/adapter/session-resolver.d.ts.map +1 -0
  8. package/dist/adapter/session-resolver.js +18 -0
  9. package/dist/adapter/session-resolver.js.map +1 -0
  10. package/dist/adapter/stream-mapper.d.ts +33 -0
  11. package/dist/adapter/stream-mapper.d.ts.map +1 -0
  12. package/dist/adapter/stream-mapper.js +117 -0
  13. package/dist/adapter/stream-mapper.js.map +1 -0
  14. package/dist/adapter/window-tracker.d.ts +57 -0
  15. package/dist/adapter/window-tracker.d.ts.map +1 -0
  16. package/dist/adapter/window-tracker.js +95 -0
  17. package/dist/adapter/window-tracker.js.map +1 -0
  18. package/dist/errors.d.ts +69 -0
  19. package/dist/errors.d.ts.map +1 -0
  20. package/dist/errors.js +101 -0
  21. package/dist/errors.js.map +1 -0
  22. package/dist/index.d.ts +11 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +18 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/shared/deduplicator.d.ts +36 -0
  27. package/dist/shared/deduplicator.d.ts.map +1 -0
  28. package/dist/shared/deduplicator.js +80 -0
  29. package/dist/shared/deduplicator.js.map +1 -0
  30. package/dist/shared/format-base.d.ts +44 -0
  31. package/dist/shared/format-base.d.ts.map +1 -0
  32. package/dist/shared/format-base.js +49 -0
  33. package/dist/shared/format-base.js.map +1 -0
  34. package/dist/shared/media-cache.d.ts +96 -0
  35. package/dist/shared/media-cache.d.ts.map +1 -0
  36. package/dist/shared/media-cache.js +111 -0
  37. package/dist/shared/media-cache.js.map +1 -0
  38. package/dist/types.d.ts +428 -0
  39. package/dist/types.d.ts.map +1 -0
  40. package/dist/types.js +2 -0
  41. package/dist/types.js.map +1 -0
  42. package/package.json +28 -0
@@ -0,0 +1,95 @@
1
+ /** Default messaging window duration: 24 hours. */
2
+ const DEFAULT_WINDOW_MS = 24 * 60 * 60 * 1000;
3
+ /** Stale entry cleanup interval: 1 hour. */
4
+ const CLEANUP_INTERVAL_MS = 60 * 60 * 1000;
5
+ /**
6
+ * Tracks the 24-hour messaging window for each conversation thread.
7
+ *
8
+ * Many messaging platforms (notably WhatsApp) only allow free-form messages
9
+ * within a window that starts when the user last messaged. After the window
10
+ * closes, only template messages can be sent.
11
+ *
12
+ * The tracker records:
13
+ * - Inbound message timestamps (sets window to `timestamp + 24h`)
14
+ * - Platform-reported expiry times (from status webhooks, more accurate)
15
+ *
16
+ * Stale entries are periodically cleaned up to prevent unbounded memory growth.
17
+ */
18
+ export class WindowTracker {
19
+ windows = new Map();
20
+ lastCleanup = Date.now();
21
+ /**
22
+ * Record an inbound message, opening or extending the messaging window.
23
+ * The window is set to 24 hours from the message timestamp.
24
+ *
25
+ * @param threadId - The conversation thread identifier.
26
+ * @param timestamp - When the user's message was sent.
27
+ */
28
+ recordInbound(threadId, timestamp) {
29
+ this.maybeCleanup();
30
+ const expiresAt = new Date(timestamp.getTime() + DEFAULT_WINDOW_MS);
31
+ const existing = this.windows.get(threadId);
32
+ // Only extend — never shrink the window
33
+ if (!existing || expiresAt > existing.expiresAt) {
34
+ this.windows.set(threadId, { expiresAt });
35
+ }
36
+ }
37
+ /**
38
+ * Record a platform-reported window expiry (e.g. from a WhatsApp status webhook).
39
+ * Platform-reported values are more accurate than computed ones.
40
+ *
41
+ * @param threadId - The conversation thread identifier.
42
+ * @param expiresAt - The platform-reported expiration timestamp.
43
+ */
44
+ recordExpiry(threadId, expiresAt) {
45
+ this.maybeCleanup();
46
+ this.windows.set(threadId, { expiresAt });
47
+ }
48
+ /**
49
+ * Check whether the messaging window is currently open for a thread.
50
+ *
51
+ * @param threadId - The conversation thread identifier.
52
+ * @returns `true` if the window is open and free-form messages can be sent.
53
+ */
54
+ isWindowOpen(threadId) {
55
+ const entry = this.windows.get(threadId);
56
+ if (!entry)
57
+ return false;
58
+ return entry.expiresAt > new Date();
59
+ }
60
+ /**
61
+ * Get the window expiry timestamp for a thread.
62
+ *
63
+ * @param threadId - The conversation thread identifier.
64
+ * @returns The expiry date, or `null` if no window is tracked.
65
+ */
66
+ getExpiry(threadId) {
67
+ const entry = this.windows.get(threadId);
68
+ return entry?.expiresAt ?? null;
69
+ }
70
+ /**
71
+ * Run cleanup if enough time has passed since the last cleanup.
72
+ * Removes all expired entries to prevent unbounded memory growth.
73
+ */
74
+ maybeCleanup() {
75
+ const now = Date.now();
76
+ if (now - this.lastCleanup < CLEANUP_INTERVAL_MS)
77
+ return;
78
+ this.lastCleanup = now;
79
+ const cutoff = new Date(now);
80
+ for (const [threadId, entry] of this.windows) {
81
+ if (entry.expiresAt <= cutoff) {
82
+ this.windows.delete(threadId);
83
+ }
84
+ }
85
+ }
86
+ /** Return the number of tracked windows. */
87
+ get size() {
88
+ return this.windows.size;
89
+ }
90
+ /** Clear all tracked windows. */
91
+ clear() {
92
+ this.windows.clear();
93
+ }
94
+ }
95
+ //# sourceMappingURL=window-tracker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"window-tracker.js","sourceRoot":"","sources":["../../src/adapter/window-tracker.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,MAAM,iBAAiB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAE9C,4CAA4C;AAC5C,MAAM,mBAAmB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAO3C;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,aAAa;IACP,OAAO,GAA6B,IAAI,GAAG,EAAE,CAAC;IACvD,WAAW,GAAW,IAAI,CAAC,GAAG,EAAE,CAAC;IAEzC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C,WAAW,GAAG,GAAG,CAAC;QACvB,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC;QAC7B,KAAK,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAC7C,IAAI,KAAK,CAAC,SAAS,IAAI,MAAM,EAAE,CAAC;gBAC9B,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAChC,CAAC;QACH,CAAC;IACH,CAAC;IAED,4CAA4C;IAC5C,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IAC3B,CAAC;IAED,iCAAiC;IACjC,KAAK;QACH,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;CACF"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Base error class for all messaging SDK errors.
3
+ * Carries a machine-readable `code` and the `platform` where the error originated.
4
+ */
5
+ export declare class MessagingError extends Error {
6
+ /** Machine-readable error code (e.g. "RATE_LIMIT", "AUTH_FAILED"). */
7
+ readonly code: string;
8
+ /** The platform where this error originated (e.g. "whatsapp", "messenger"). */
9
+ readonly platform: string;
10
+ constructor(message: string, code: string, platform: string);
11
+ }
12
+ /**
13
+ * Thrown when the platform's rate limit has been exceeded.
14
+ * Includes the recommended wait time before retrying.
15
+ */
16
+ export declare class RateLimitError extends MessagingError {
17
+ /** Number of milliseconds to wait before retrying. */
18
+ readonly retryAfterMs: number;
19
+ constructor(message: string, platform: string, retryAfterMs: number);
20
+ }
21
+ /**
22
+ * Thrown when attempting to send a message outside the allowed messaging window
23
+ * (e.g. WhatsApp's 24-hour customer service window).
24
+ */
25
+ export declare class WindowClosedError extends MessagingError {
26
+ /** When the messaging window expired. */
27
+ readonly expiredAt: Date;
28
+ /** Template message IDs that can still be sent outside the window. */
29
+ readonly suggestedTemplates?: string[];
30
+ constructor(message: string, platform: string, expiredAt: Date, suggestedTemplates?: string[]);
31
+ }
32
+ /**
33
+ * Thrown when API authentication fails (invalid token, expired credentials).
34
+ */
35
+ export declare class AuthenticationError extends MessagingError {
36
+ constructor(message: string, platform: string);
37
+ }
38
+ /**
39
+ * Thrown when the API token lacks required permissions for the operation.
40
+ */
41
+ export declare class PermissionError extends MessagingError {
42
+ constructor(message: string, platform: string);
43
+ }
44
+ /**
45
+ * Thrown when the recipient is invalid, blocked, or unreachable.
46
+ */
47
+ export declare class RecipientError extends MessagingError {
48
+ constructor(message: string, platform: string);
49
+ }
50
+ /**
51
+ * Thrown when a template message is invalid or not approved.
52
+ */
53
+ export declare class TemplateError extends MessagingError {
54
+ constructor(message: string, platform: string);
55
+ }
56
+ /**
57
+ * Thrown when a media operation fails (upload, download, invalid format).
58
+ */
59
+ export declare class MediaError extends MessagingError {
60
+ constructor(message: string, platform: string);
61
+ }
62
+ /**
63
+ * Thrown when webhook signature verification fails.
64
+ * Indicates a potentially spoofed or tampered webhook request.
65
+ */
66
+ export declare class WebhookVerificationError extends MessagingError {
67
+ constructor(message: string, platform: string);
68
+ }
69
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC,sEAAsE;IACtE,SAAgB,IAAI,EAAE,MAAM,CAAC;IAE7B,+EAA+E;IAC/E,SAAgB,QAAQ,EAAE,MAAM,CAAC;gBAErB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAM5D;AAED;;;GAGG;AACH,qBAAa,cAAe,SAAQ,cAAc;IAChD,sDAAsD;IACtD,SAAgB,YAAY,EAAE,MAAM,CAAC;gBAEzB,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;CAKpE;AAED;;;GAGG;AACH,qBAAa,iBAAkB,SAAQ,cAAc;IACnD,yCAAyC;IACzC,SAAgB,SAAS,EAAE,IAAI,CAAC;IAEhC,sEAAsE;IACtE,SAAgB,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;gBAElC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,kBAAkB,CAAC,EAAE,MAAM,EAAE;CAM9F;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,cAAc;gBACzC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAI9C;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,cAAc;gBACrC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAI9C;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,cAAc;gBACpC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAI9C;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,cAAc;gBACnC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAI9C;AAED;;GAEG;AACH,qBAAa,UAAW,SAAQ,cAAc;gBAChC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAI9C;AAED;;;GAGG;AACH,qBAAa,wBAAyB,SAAQ,cAAc;gBAC9C,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAI9C"}
package/dist/errors.js ADDED
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Base error class for all messaging SDK errors.
3
+ * Carries a machine-readable `code` and the `platform` where the error originated.
4
+ */
5
+ export class MessagingError extends Error {
6
+ /** Machine-readable error code (e.g. "RATE_LIMIT", "AUTH_FAILED"). */
7
+ code;
8
+ /** The platform where this error originated (e.g. "whatsapp", "messenger"). */
9
+ platform;
10
+ constructor(message, code, platform) {
11
+ super(message);
12
+ this.name = 'MessagingError';
13
+ this.code = code;
14
+ this.platform = platform;
15
+ }
16
+ }
17
+ /**
18
+ * Thrown when the platform's rate limit has been exceeded.
19
+ * Includes the recommended wait time before retrying.
20
+ */
21
+ export class RateLimitError extends MessagingError {
22
+ /** Number of milliseconds to wait before retrying. */
23
+ retryAfterMs;
24
+ constructor(message, platform, retryAfterMs) {
25
+ super(message, 'RATE_LIMIT', platform);
26
+ this.name = 'RateLimitError';
27
+ this.retryAfterMs = retryAfterMs;
28
+ }
29
+ }
30
+ /**
31
+ * Thrown when attempting to send a message outside the allowed messaging window
32
+ * (e.g. WhatsApp's 24-hour customer service window).
33
+ */
34
+ export class WindowClosedError extends MessagingError {
35
+ /** When the messaging window expired. */
36
+ expiredAt;
37
+ /** Template message IDs that can still be sent outside the window. */
38
+ suggestedTemplates;
39
+ constructor(message, platform, expiredAt, suggestedTemplates) {
40
+ super(message, 'WINDOW_CLOSED', platform);
41
+ this.name = 'WindowClosedError';
42
+ this.expiredAt = expiredAt;
43
+ this.suggestedTemplates = suggestedTemplates;
44
+ }
45
+ }
46
+ /**
47
+ * Thrown when API authentication fails (invalid token, expired credentials).
48
+ */
49
+ export class AuthenticationError extends MessagingError {
50
+ constructor(message, platform) {
51
+ super(message, 'AUTH_FAILED', platform);
52
+ this.name = 'AuthenticationError';
53
+ }
54
+ }
55
+ /**
56
+ * Thrown when the API token lacks required permissions for the operation.
57
+ */
58
+ export class PermissionError extends MessagingError {
59
+ constructor(message, platform) {
60
+ super(message, 'PERMISSION_DENIED', platform);
61
+ this.name = 'PermissionError';
62
+ }
63
+ }
64
+ /**
65
+ * Thrown when the recipient is invalid, blocked, or unreachable.
66
+ */
67
+ export class RecipientError extends MessagingError {
68
+ constructor(message, platform) {
69
+ super(message, 'RECIPIENT_ERROR', platform);
70
+ this.name = 'RecipientError';
71
+ }
72
+ }
73
+ /**
74
+ * Thrown when a template message is invalid or not approved.
75
+ */
76
+ export class TemplateError extends MessagingError {
77
+ constructor(message, platform) {
78
+ super(message, 'TEMPLATE_ERROR', platform);
79
+ this.name = 'TemplateError';
80
+ }
81
+ }
82
+ /**
83
+ * Thrown when a media operation fails (upload, download, invalid format).
84
+ */
85
+ export class MediaError extends MessagingError {
86
+ constructor(message, platform) {
87
+ super(message, 'MEDIA_ERROR', platform);
88
+ this.name = 'MediaError';
89
+ }
90
+ }
91
+ /**
92
+ * Thrown when webhook signature verification fails.
93
+ * Indicates a potentially spoofed or tampered webhook request.
94
+ */
95
+ export class WebhookVerificationError extends MessagingError {
96
+ constructor(message, platform) {
97
+ super(message, 'WEBHOOK_VERIFICATION_FAILED', platform);
98
+ this.name = 'WebhookVerificationError';
99
+ }
100
+ }
101
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK;IACvC,sEAAsE;IACtD,IAAI,CAAS;IAE7B,+EAA+E;IAC/D,QAAQ,CAAS;IAEjC,YAAY,OAAe,EAAE,IAAY,EAAE,QAAgB;QACzD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,cAAe,SAAQ,cAAc;IAChD,sDAAsD;IACtC,YAAY,CAAS;IAErC,YAAY,OAAe,EAAE,QAAgB,EAAE,YAAoB;QACjE,KAAK,CAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC;QACvC,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,iBAAkB,SAAQ,cAAc;IACnD,yCAAyC;IACzB,SAAS,CAAO;IAEhC,sEAAsE;IACtD,kBAAkB,CAAY;IAE9C,YAAY,OAAe,EAAE,Q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,CAAC,IAAI,GAAG,YAAY,CAAC;IAC3B,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,wBAAyB,SAAQ,cAAc;IAC1D,YAAY,OAAe,EAAE,QAAgB;QAC3C,KAAK,CAAC,OAAO,EAAE,6BAA6B,EAAE,QAAQ,CAAC,CAAC;QACxD,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IACzC,CAAC;CACF"}
@@ -0,0 +1,11 @@
1
+ export type { PlatformClient, InboundMessage, StatusUpdate, SendResult, MediaPayload, MediaHandle, MediaDownload, MediaUploadOptions, MediaReference, InteractiveMessage, InteractiveAction, InteractiveReply, ContactInfo, LocationData, ReactionData, MessageContext, ConversationInfo, PricingInfo, StatusError, FormatConverter, MessageHandler, StatusHandler, ReactionHandler, MessagingRouterConfig, SessionResolver, ResponseMapper, ResponseContext, ErrorContext, StreamMapperOptions, } from './types.js';
2
+ export { MessagingError, RateLimitError, WindowClosedError, AuthenticationError, PermissionError, RecipientError, TemplateError, MediaError, WebhookVerificationError, } from './errors.js';
3
+ export { createMessagingRouter } from './adapter/createMessagingRouter.js';
4
+ export { defaultSessionResolver } from './adapter/session-resolver.js';
5
+ export { StreamMapper } from './adapter/stream-mapper.js';
6
+ export { WindowTracker } from './adapter/window-tracker.js';
7
+ export { MessageDeduplicator } from './shared/deduplicator.js';
8
+ export { BaseFormatConverter } from './shared/format-base.js';
9
+ export { MediaCache } from './shared/media-cache.js';
10
+ export type { MediaCacheConfig, CachedMedia } from './shared/media-cache.js';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,YAAY,EACV,cAAc,EACd,cAAc,EACd,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,WAAW,EACX,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,eAAe,EACf,cAAc,EACd,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,eAAe,EACf,YAAY,EACZ,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAKpB,OAAO,EACL,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,aAAa,EACb,UAAU,EACV,wBAAwB,GACzB,MAAM,aAAa,CAAC;AAKrB,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAK5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ // ====================================
2
+ // Errors
3
+ // ====================================
4
+ export { MessagingError, RateLimitError, WindowClosedError, AuthenticationError, PermissionError, RecipientError, TemplateError, MediaError, WebhookVerificationError, } from './errors.js';
5
+ // ====================================
6
+ // Adapter
7
+ // ====================================
8
+ export { createMessagingRouter } from './adapter/createMessagingRouter.js';
9
+ export { defaultSessionResolver } from './adapter/session-resolver.js';
10
+ export { StreamMapper } from './adapter/stream-mapper.js';
11
+ export { WindowTracker } from './adapter/window-tracker.js';
12
+ // ====================================
13
+ // Shared
14
+ // ====================================
15
+ export { MessageDeduplicator } from './shared/deduplicator.js';
16
+ export { BaseFormatConverter } from './shared/format-base.js';
17
+ export { MediaCache } from './shared/media-cache.js';
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAmCA,uCAAuC;AACvC,SAAS;AACT,uCAAuC;AACvC,OAAO,EACL,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,aAAa,EACb,UAAU,EACV,wBAAwB,GACzB,MAAM,aAAa,CAAC;AAErB,uCAAuC;AACvC,UAAU;AACV,uCAAuC;AACvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,uCAAuC;AACvC,SAAS;AACT,uCAAuC;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * LRU-based message deduplication to prevent processing the same
3
+ * webhook event twice. Uses a Map (which preserves insertion order)
4
+ * as the underlying data structure with TTL-based expiration.
5
+ */
6
+ export declare class MessageDeduplicator {
7
+ private readonly cache;
8
+ private readonly maxSize;
9
+ private readonly ttlMs;
10
+ /**
11
+ * Create a new deduplicator.
12
+ * @param maxSize - Maximum number of message IDs to track. Default: 10000.
13
+ * @param ttlMs - Time-to-live for entries in milliseconds. Default: 300000 (5 minutes).
14
+ */
15
+ constructor(maxSize?: number, ttlMs?: number);
16
+ /**
17
+ * Check if a message ID has been seen recently.
18
+ *
19
+ * If the message ID is new, it is recorded and `false` is returned.
20
+ * If it has been seen within the TTL window, `true` is returned.
21
+ * Expired entries are treated as new.
22
+ *
23
+ * @param messageId - The platform-specific message identifier.
24
+ * @returns `true` if this message was already processed (duplicate), `false` if new.
25
+ */
26
+ isDuplicate(messageId: string): boolean;
27
+ /**
28
+ * Remove expired entries, then evict oldest if still at capacity.
29
+ */
30
+ private evict;
31
+ /** Return the current number of tracked message IDs. */
32
+ get size(): number;
33
+ /** Clear all tracked message IDs. */
34
+ clear(): void;
35
+ }
36
+ //# sourceMappingURL=deduplicator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deduplicator.d.ts","sourceRoot":"","sources":["../../src/shared/deduplicator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAsB;IAC5C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAE/B;;;;OAIG;gBACS,OAAO,SAAS,EAAE,KAAK,SAAU;IAM7C;;;;;;;;;OASG;IACH,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAuBvC;;OAEG;IACH,OAAO,CAAC,KAAK;IAoBb,wDAAwD;IACxD,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,qCAAqC;IACrC,KAAK,IAAI,IAAI;CAGd"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * LRU-based message deduplication to prevent processing the same
3
+ * webhook event twice. Uses a Map (which preserves insertion order)
4
+ * as the underlying data structure with TTL-based expiration.
5
+ */
6
+ export class MessageDeduplicator {
7
+ cache;
8
+ maxSize;
9
+ ttlMs;
10
+ /**
11
+ * Create a new deduplicator.
12
+ * @param maxSize - Maximum number of message IDs to track. Default: 10000.
13
+ * @param ttlMs - Time-to-live for entries in milliseconds. Default: 300000 (5 minutes).
14
+ */
15
+ constructor(maxSize = 10_000, ttlMs = 300_000) {
16
+ this.cache = new Map();
17
+ this.maxSize = maxSize;
18
+ this.ttlMs = ttlMs;
19
+ }
20
+ /**
21
+ * Check if a message ID has been seen recently.
22
+ *
23
+ * If the message ID is new, it is recorded and `false` is returned.
24
+ * If it has been seen within the TTL window, `true` is returned.
25
+ * Expired entries are treated as new.
26
+ *
27
+ * @param messageId - The platform-specific message identifier.
28
+ * @returns `true` if this message was already processed (duplicate), `false` if new.
29
+ */
30
+ isDuplicate(messageId) {
31
+ const now = Date.now();
32
+ const existing = this.cache.get(messageId);
33
+ if (existing !== undefined) {
34
+ // Check if the entry has expired
35
+ if (now - existing < this.ttlMs) {
36
+ return true;
37
+ }
38
+ // Expired — delete so we can re-insert at the end
39
+ this.cache.delete(messageId);
40
+ }
41
+ // Evict oldest entries if at capacity
42
+ if (this.cache.size >= this.maxSize) {
43
+ this.evict(now);
44
+ }
45
+ // Record this message
46
+ this.cache.set(messageId, now);
47
+ return false;
48
+ }
49
+ /**
50
+ * Remove expired entries, then evict oldest if still at capacity.
51
+ */
52
+ evict(now) {
53
+ // First pass: remove all expired entries
54
+ for (const [key, timestamp] of this.cache) {
55
+ if (now - timestamp >= this.ttlMs) {
56
+ this.cache.delete(key);
57
+ }
58
+ }
59
+ // If still at capacity, remove oldest entries (Map iterates in insertion order)
60
+ if (this.cache.size >= this.maxSize) {
61
+ const toRemove = this.cache.size - this.maxSize + 1;
62
+ let removed = 0;
63
+ for (const key of this.cache.keys()) {
64
+ if (removed >= toRemove)
65
+ break;
66
+ this.cache.delete(key);
67
+ removed++;
68
+ }
69
+ }
70
+ }
71
+ /** Return the current number of tracked message IDs. */
72
+ get size() {
73
+ return this.cache.size;
74
+ }
75
+ /** Clear all tracked message IDs. */
76
+ clear() {
77
+ this.cache.clear();
78
+ }
79
+ }
80
+ //# sourceMappingURL=deduplicator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deduplicator.js","sourceRoot":"","sources":["../../src/shared/deduplicator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,OAAO,mBAAmB;IACb,KAAK,CAAsB;IAC3B,OAAO,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QAED,gFAAgF;QAChF,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACpC,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;YACpD,IAAI,OAAO,GAAG,CAAC,CAAC;YAChB,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;gBACpC,IAAI,OAAO,IAAI,QAAQ;oBAAE,MAAM;gBAC/B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBACvB,OAAO,EAAE,CAAC;YACZ,CAAC;QACH,CAAC;IACH,CAAC;IAED,wDAAwD;IACxD,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IACzB,CAAC;IAED,qCAAqC;IACrC,KAAK;QACH,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;CACF"}
@@ -0,0 +1,44 @@
1
+ import type { FormatConverter } from '../types.js';
2
+ /**
3
+ * Base format converter that passes text through unchanged.
4
+ *
5
+ * Platform-specific packages should extend this class and override
6
+ * methods to handle their native formatting conventions. For example,
7
+ * a WhatsApp converter would translate Markdown bold (`**text**`) to
8
+ * WhatsApp bold (`*text*`).
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * class WhatsAppFormatConverter extends BaseFormatConverter {
13
+ * toPlatformFormat(markdown: string): string {
14
+ * return markdown
15
+ * .replace(/\*\*(.*?)\*\* /g, '*$1*') // bold
16
+ * .replace(/__(.*?)__/g, '_$1_'); // italic
17
+ * }
18
+ * }
19
+ * ```
20
+ */
21
+ export declare abstract class BaseFormatConverter implements FormatConverter {
22
+ /**
23
+ * Convert Markdown text to plain text by stripping all formatting.
24
+ * Default implementation returns the input unchanged.
25
+ * @param markdown - Markdown-formatted text.
26
+ * @returns Plain text with formatting removed.
27
+ */
28
+ toPlainText(markdown: string): string;
29
+ /**
30
+ * Convert platform-specific formatted text to Markdown.
31
+ * Default implementation returns the input unchanged.
32
+ * @param text - Platform-formatted text.
33
+ * @returns Markdown-formatted text.
34
+ */
35
+ toMarkdown(text: string): string;
36
+ /**
37
+ * Convert Markdown to the platform's native text format.
38
+ * Default implementation returns the input unchanged.
39
+ * @param markdown - Markdown-formatted text.
40
+ * @returns Text in the platform's native format.
41
+ */
42
+ toPlatformFormat(markdown: string): string;
43
+ }
44
+ //# sourceMappingURL=format-base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-base.d.ts","sourceRoot":"","sources":["../../src/shared/format-base.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD;;;;;;;;;;;;;;;;;;GAkBG;AACH,8BAAsB,mBAAoB,YAAW,eAAe;IAClE;;;;;OAKG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAIrC;;;;;OAKG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAIhC;;;;;OAKG;IACH,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;CAG3C"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Base format converter that passes text through unchanged.
3
+ *
4
+ * Platform-specific packages should extend this class and override
5
+ * methods to handle their native formatting conventions. For example,
6
+ * a WhatsApp converter would translate Markdown bold (`**text**`) to
7
+ * WhatsApp bold (`*text*`).
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * class WhatsAppFormatConverter extends BaseFormatConverter {
12
+ * toPlatformFormat(markdown: string): string {
13
+ * return markdown
14
+ * .replace(/\*\*(.*?)\*\* /g, '*$1*') // bold
15
+ * .replace(/__(.*?)__/g, '_$1_'); // italic
16
+ * }
17
+ * }
18
+ * ```
19
+ */
20
+ export class BaseFormatConverter {
21
+ /**
22
+ * Convert Markdown text to plain text by stripping all formatting.
23
+ * Default implementation returns the input unchanged.
24
+ * @param markdown - Markdown-formatted text.
25
+ * @returns Plain text with formatting removed.
26
+ */
27
+ toPlainText(markdown) {
28
+ return markdown;
29
+ }
30
+ /**
31
+ * Convert platform-specific formatted text to Markdown.
32
+ * Default implementation returns the input unchanged.
33
+ * @param text - Platform-formatted text.
34
+ * @returns Markdown-formatted text.
35
+ */
36
+ toMarkdown(text) {
37
+ return text;
38
+ }
39
+ /**
40
+ * Convert Markdown to the platform's native text format.
41
+ * Default implementation returns the input unchanged.
42
+ * @param markdown - Markdown-formatted text.
43
+ * @returns Text in the platform's native format.
44
+ */
45
+ toPlatformFormat(markdown) {
46
+ return markdown;
47
+ }
48
+ }
49
+ //# sourceMappingURL=format-base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-base.js","sourceRoot":"","sources":["../../src/shared/format-base.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,OAAgB,mBAAmB;IACvC;;;;;OAKG;IACH,WAAW,CAAC,QAAgB;QAC1B,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;OAKG;IACH,UAAU,CAAC,IAAY;QACrB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACH,gBAAgB,CAAC,QAAgB;QAC/B,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * @module shared/media-cache
3
+ *
4
+ * In-memory LRU cache for downloaded media attachments.
5
+ *
6
+ * Avoids re-downloading the same attachment when multiple handlers
7
+ * or retry logic access the same media ID. Uses a Map-based LRU
8
+ * with TTL expiration (media URLs from Meta are temporary -- typically
9
+ * valid for ~5 minutes).
10
+ */
11
+ /** Configuration for the {@link MediaCache}. */
12
+ export interface MediaCacheConfig {
13
+ /** Max entries in the cache. Default: 100. */
14
+ maxSize?: number;
15
+ /** TTL for cached entries in ms. Default: 300_000 (5 minutes). */
16
+ ttlMs?: number;
17
+ }
18
+ /** A cached media entry with metadata. */
19
+ export interface CachedMedia {
20
+ /** Raw media bytes. */
21
+ data: Buffer;
22
+ /** MIME type of the media. */
23
+ mimeType: string;
24
+ /** Original filename (if available). */
25
+ filename?: string;
26
+ /** Timestamp when the entry was cached (ms since epoch). */
27
+ cachedAt: number;
28
+ }
29
+ /**
30
+ * In-memory LRU cache for downloaded media.
31
+ *
32
+ * Avoids re-downloading the same attachment when multiple handlers
33
+ * or retry logic access the same media ID. Uses a Map-based LRU
34
+ * with TTL expiration (media URLs from Meta are temporary -- typically
35
+ * valid for ~5 minutes).
36
+ */
37
+ export declare class MediaCache {
38
+ private readonly cache;
39
+ private readonly maxSize;
40
+ private readonly ttlMs;
41
+ constructor(config?: MediaCacheConfig);
42
+ /**
43
+ * Get cached media by ID. Returns `undefined` if not found or expired.
44
+ *
45
+ * Accessing an entry refreshes its LRU position (moves it to the end
46
+ * of the eviction queue).
47
+ *
48
+ * @param mediaId - The platform-specific media identifier.
49
+ * @returns The cached media entry, or `undefined`.
50
+ */
51
+ get(mediaId: string): CachedMedia | undefined;
52
+ /**
53
+ * Store media in the cache.
54
+ *
55
+ * If the cache is at capacity, the least-recently-used entry is evicted.
56
+ *
57
+ * @param mediaId - The platform-specific media identifier.
58
+ * @param media - The media content to cache.
59
+ */
60
+ set(mediaId: string, media: {
61
+ data: Buffer;
62
+ mimeType: string;
63
+ filename?: string;
64
+ }): void;
65
+ /**
66
+ * Check if media is cached and not expired.
67
+ *
68
+ * @param mediaId - The platform-specific media identifier.
69
+ * @returns `true` if the media is cached and still valid.
70
+ */
71
+ has(mediaId: string): boolean;
72
+ /**
73
+ * Wrap a download function with caching.
74
+ *
75
+ * If the media is cached, returns the cached version. Otherwise
76
+ * calls `downloadFn`, caches the result, and returns it.
77
+ *
78
+ * @param mediaId - The platform-specific media identifier.
79
+ * @param downloadFn - A function that downloads the media.
80
+ * @returns The media content (from cache or fresh download).
81
+ */
82
+ getOrDownload(mediaId: string, downloadFn: () => Promise<{
83
+ data: Buffer;
84
+ mimeType: string;
85
+ filename?: string;
86
+ }>): Promise<{
87
+ data: Buffer;
88
+ mimeType: string;
89
+ filename?: string;
90
+ }>;
91
+ /** Return the current number of cached entries. */
92
+ get size(): number;
93
+ /** Clear all cached entries. */
94
+ clear(): void;
95
+ }
96
+ //# sourceMappingURL=media-cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media-cache.d.ts","sourceRoot":"","sources":["../../src/shared/media-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,gDAAgD;AAChD,MAAM,WAAW,gBAAgB;IAC/B,8CAA8C;IAC9C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kEAAkE;IAClE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAMD,0CAA0C;AAC1C,MAAM,WAAW,WAAW;IAC1B,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,8BAA8B;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,wCAAwC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4DAA4D;IAC5D,QAAQ,EAAE,MAAM,CAAC;CAClB;AAMD;;;;;;;GAOG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA2B;IACjD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;gBAEnB,MAAM,CAAC,EAAE,gBAAgB;IAMrC;;;;;;;;OAQG;IACH,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IAe7C;;;;;;;OAOG;IACH,GAAG,CACD,OAAO,EAAE,MAAM,EACf,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GAC3D,IAAI;IAeP;;;;;OAKG;IACH,GAAG,CAAC,OAAO,EAAE,MA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