@headless-lms/core 0.3.0 → 0.4.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 (205) hide show
  1. package/dist/assets/events.d.ts +9 -9
  2. package/dist/assets/index.d.ts +3 -2
  3. package/dist/assets/index.js +2 -1
  4. package/dist/assets/jobs.d.ts +15 -0
  5. package/dist/assets/jobs.js +30 -0
  6. package/dist/assets/jobs.js.map +1 -0
  7. package/dist/assets/ports.d.ts +4 -3
  8. package/dist/assets/service.d.ts +0 -1
  9. package/dist/assets/service.js +0 -4
  10. package/dist/assets/service.js.map +1 -1
  11. package/dist/automations/actions.js +2 -63
  12. package/dist/automations/actions.js.map +1 -1
  13. package/dist/automations/catalog.d.ts +1 -2
  14. package/dist/automations/catalog.js +69 -62
  15. package/dist/automations/catalog.js.map +1 -1
  16. package/dist/automations/community-derivations.js +4 -4
  17. package/dist/automations/community-derivations.js.map +1 -1
  18. package/dist/automations/community-mail.d.ts +3 -17
  19. package/dist/automations/community-mail.js +1 -21
  20. package/dist/automations/community-mail.js.map +1 -1
  21. package/dist/automations/events.d.ts +0 -10
  22. package/dist/automations/index.d.ts +11 -4
  23. package/dist/automations/index.js +8 -1
  24. package/dist/automations/notifications/debounce.d.ts +25 -0
  25. package/dist/automations/notifications/debounce.js +93 -0
  26. package/dist/automations/notifications/debounce.js.map +1 -0
  27. package/dist/automations/notifications/defaults.d.ts +8 -0
  28. package/dist/automations/notifications/defaults.js +316 -0
  29. package/dist/automations/notifications/defaults.js.map +1 -0
  30. package/dist/automations/notifications/delivery.d.ts +28 -0
  31. package/dist/automations/notifications/delivery.js +88 -0
  32. package/dist/automations/notifications/delivery.js.map +1 -0
  33. package/dist/automations/notifications/processor.d.ts +64 -0
  34. package/dist/automations/notifications/processor.js +270 -0
  35. package/dist/automations/notifications/processor.js.map +1 -0
  36. package/dist/automations/notifications/rules/content.d.ts +6 -0
  37. package/dist/automations/notifications/rules/content.js +39 -0
  38. package/dist/automations/notifications/rules/content.js.map +1 -0
  39. package/dist/automations/notifications/rules/discussion.d.ts +7 -0
  40. package/dist/automations/notifications/rules/discussion.js +678 -0
  41. package/dist/automations/notifications/rules/discussion.js.map +1 -0
  42. package/dist/automations/notifications/rules/entitlements.d.ts +6 -0
  43. package/dist/automations/notifications/rules/entitlements.js +249 -0
  44. package/dist/automations/notifications/rules/entitlements.js.map +1 -0
  45. package/dist/automations/notifications/rules/index.d.ts +6 -0
  46. package/dist/automations/notifications/rules/index.js +15 -0
  47. package/dist/automations/notifications/rules/index.js.map +1 -0
  48. package/dist/automations/notifications/rules/organizations.d.ts +6 -0
  49. package/dist/automations/notifications/rules/organizations.js +28 -0
  50. package/dist/automations/notifications/rules/organizations.js.map +1 -0
  51. package/dist/automations/notifications/rules/recipients.d.ts +32 -0
  52. package/dist/automations/notifications/rules/recipients.js +99 -0
  53. package/dist/automations/notifications/rules/recipients.js.map +1 -0
  54. package/dist/automations/notifications/service.d.ts +27 -0
  55. package/dist/automations/notifications/service.js +45 -0
  56. package/dist/automations/notifications/service.js.map +1 -0
  57. package/dist/automations/notifications/types.d.ts +7 -0
  58. package/dist/automations/notifications/types.js +473 -0
  59. package/dist/automations/notifications/types.js.map +1 -0
  60. package/dist/automations/ports.d.ts +119 -5
  61. package/dist/automations/service.d.ts +10 -13
  62. package/dist/automations/service.js +21 -83
  63. package/dist/automations/service.js.map +1 -1
  64. package/dist/content/events.d.ts +130 -80
  65. package/dist/content/events.js +11 -0
  66. package/dist/content/events.js.map +1 -1
  67. package/dist/content/index.d.ts +6 -4
  68. package/dist/content/index.js +3 -1
  69. package/dist/content/model.d.ts +2 -2
  70. package/dist/content/notification-categories.d.ts +36 -0
  71. package/dist/content/notification-categories.js +64 -0
  72. package/dist/content/notification-categories.js.map +1 -0
  73. package/dist/content/ports.d.ts +25 -6
  74. package/dist/content/service.d.ts +4 -4
  75. package/dist/content/service.js +24 -8
  76. package/dist/content/service.js.map +1 -1
  77. package/dist/content/titles.d.ts +22 -0
  78. package/dist/content/titles.js +69 -0
  79. package/dist/content/titles.js.map +1 -0
  80. package/dist/content/types.d.ts +2 -2
  81. package/dist/discussion/chats.d.ts +9 -4
  82. package/dist/discussion/chats.js +80 -47
  83. package/dist/discussion/chats.js.map +1 -1
  84. package/dist/discussion/digests.d.ts +24 -0
  85. package/dist/discussion/digests.js +104 -0
  86. package/dist/discussion/digests.js.map +1 -0
  87. package/dist/discussion/events.d.ts +194 -28
  88. package/dist/discussion/events.js +74 -17
  89. package/dist/discussion/events.js.map +1 -1
  90. package/dist/discussion/index.d.ts +7 -2
  91. package/dist/discussion/index.js +6 -1
  92. package/dist/discussion/jobs.d.ts +16 -0
  93. package/dist/discussion/jobs.js +40 -0
  94. package/dist/discussion/jobs.js.map +1 -0
  95. package/dist/discussion/mentions.d.ts +11 -0
  96. package/dist/discussion/mentions.js +35 -0
  97. package/dist/discussion/mentions.js.map +1 -0
  98. package/dist/discussion/ports.d.ts +107 -24
  99. package/dist/discussion/ports.js.map +1 -1
  100. package/dist/discussion/posts.d.ts +18 -8
  101. package/dist/discussion/posts.js +207 -155
  102. package/dist/discussion/posts.js.map +1 -1
  103. package/dist/discussion/service.d.ts +17 -8
  104. package/dist/discussion/service.js +105 -41
  105. package/dist/discussion/service.js.map +1 -1
  106. package/dist/discussion/subscriptions.d.ts +37 -0
  107. package/dist/discussion/subscriptions.js +99 -0
  108. package/dist/discussion/subscriptions.js.map +1 -0
  109. package/dist/discussion/titles.d.ts +26 -0
  110. package/dist/discussion/titles.js +84 -0
  111. package/dist/discussion/titles.js.map +1 -0
  112. package/dist/entitlements/events.d.ts +20 -20
  113. package/dist/entitlements/index.d.ts +2 -1
  114. package/dist/entitlements/index.js +2 -1
  115. package/dist/entitlements/jobs.d.ts +12 -0
  116. package/dist/entitlements/jobs.js +18 -0
  117. package/dist/entitlements/jobs.js.map +1 -0
  118. package/dist/entitlements/ports.d.ts +7 -3
  119. package/dist/entitlements/service.d.ts +5 -2
  120. package/dist/entitlements/service.js +23 -3
  121. package/dist/entitlements/service.js.map +1 -1
  122. package/dist/identity/devices.d.ts +30 -0
  123. package/dist/identity/devices.js +107 -0
  124. package/dist/identity/devices.js.map +1 -0
  125. package/dist/identity/events.d.ts +2 -2
  126. package/dist/identity/index.d.ts +5 -4
  127. package/dist/identity/index.js +3 -2
  128. package/dist/identity/model.d.ts +2 -2
  129. package/dist/identity/notification-settings.d.ts +28 -0
  130. package/dist/identity/notification-settings.js +113 -0
  131. package/dist/identity/notification-settings.js.map +1 -0
  132. package/dist/identity/ports.d.ts +78 -54
  133. package/dist/integrations/events.d.ts +3 -3
  134. package/dist/organizations/events.d.ts +32 -32
  135. package/dist/organizations/index.d.ts +2 -1
  136. package/dist/organizations/index.js +2 -1
  137. package/dist/organizations/notification-categories.d.ts +32 -0
  138. package/dist/organizations/notification-categories.js +51 -0
  139. package/dist/organizations/notification-categories.js.map +1 -0
  140. package/dist/organizations/ports.d.ts +3 -0
  141. package/dist/organizations/service.d.ts +2 -0
  142. package/dist/organizations/service.js +7 -0
  143. package/dist/organizations/service.js.map +1 -1
  144. package/dist/progress/events.d.ts +14 -14
  145. package/dist/reporting/member/index.d.ts +2 -2
  146. package/dist/reporting/member/model.d.ts +56 -23
  147. package/dist/reporting/member/ports.d.ts +9 -6
  148. package/dist/reporting/member/service.d.ts +33 -14
  149. package/dist/reporting/member/service.js +138 -60
  150. package/dist/reporting/member/service.js.map +1 -1
  151. package/dist/shared/errors.d.ts +13 -1
  152. package/dist/shared/errors.js +18 -1
  153. package/dist/shared/errors.js.map +1 -1
  154. package/dist/shared/id.d.ts +3 -0
  155. package/dist/shared/id.js +4 -1
  156. package/dist/shared/id.js.map +1 -1
  157. package/dist/shared/mailer.d.ts +11 -1
  158. package/dist/shared/mailer.js +32 -5
  159. package/dist/shared/mailer.js.map +1 -1
  160. package/dist/shared/notification-categories.d.ts +16 -0
  161. package/dist/shared/notification-categories.js +94 -0
  162. package/dist/shared/notification-categories.js.map +1 -0
  163. package/dist/shared/notification-settings.d.ts +14 -0
  164. package/dist/shared/notification-settings.js +61 -0
  165. package/dist/shared/notification-settings.js.map +1 -0
  166. package/dist/shared/ports.d.ts +48 -2
  167. package/dist/shared/settings.d.ts +2 -1
  168. package/dist/shared/settings.js +1 -0
  169. package/dist/shared/settings.js.map +1 -1
  170. package/dist/types/automations.d.ts +8 -2
  171. package/dist/types/content.d.ts +2 -2
  172. package/dist/types/discussion.d.ts +2 -2
  173. package/dist/types/email-templates.d.ts +97 -3
  174. package/dist/types/identity.d.ts +2 -2
  175. package/dist/types/index.d.ts +7 -6
  176. package/dist/types/notifications.d.ts +157 -0
  177. package/dist/types/notifications.js +1 -0
  178. package/dist/types/schemas/automations.d.ts +1 -10
  179. package/dist/types/schemas/automations.js +1 -3
  180. package/dist/types/schemas/automations.js.map +1 -1
  181. package/dist/types/schemas/content.d.ts +62 -1
  182. package/dist/types/schemas/content.js +25 -3
  183. package/dist/types/schemas/content.js.map +1 -1
  184. package/dist/types/schemas/discussion.d.ts +85 -12
  185. package/dist/types/schemas/discussion.js +47 -13
  186. package/dist/types/schemas/discussion.js.map +1 -1
  187. package/dist/types/schemas/identity.d.ts +1 -85
  188. package/dist/types/schemas/identity.js +1 -42
  189. package/dist/types/schemas/identity.js.map +1 -1
  190. package/dist/types/schemas/index.d.ts +6 -5
  191. package/dist/types/schemas/index.js +6 -5
  192. package/dist/types/schemas/notifications.d.ts +95 -0
  193. package/dist/types/schemas/notifications.js +56 -0
  194. package/dist/types/schemas/notifications.js.map +1 -0
  195. package/dist/types/schemas/progress.d.ts +3 -3
  196. package/package.json +1 -1
  197. package/dist/automations/community-notifications.d.ts +0 -16
  198. package/dist/automations/community-notifications.js +0 -84
  199. package/dist/automations/community-notifications.js.map +0 -1
  200. package/dist/automations/seeds.d.ts +0 -17
  201. package/dist/automations/seeds.js +0 -235
  202. package/dist/automations/seeds.js.map +0 -1
  203. package/dist/identity/notifications.d.ts +0 -27
  204. package/dist/identity/notifications.js +0 -101
  205. package/dist/identity/notifications.js.map +0 -1
@@ -16,7 +16,6 @@ declare const automationEvents: {
16
16
  }[];
17
17
  enabled: boolean;
18
18
  filter: Record<string, JsonValue> | null;
19
- source: "system" | "user";
20
19
  createdAt: Date;
21
20
  updatedAt: Date;
22
21
  }, "automation.created", 2>, {
@@ -32,7 +31,6 @@ declare const automationEvents: {
32
31
  }[];
33
32
  enabled: boolean;
34
33
  filter: Record<string, unknown> | null;
35
- source: "system" | "user";
36
34
  createdAt: unknown;
37
35
  updatedAt: unknown;
38
36
  }, undefined>;
@@ -49,7 +47,6 @@ declare const automationEvents: {
49
47
  }[];
50
48
  enabled: boolean;
51
49
  filter: Record<string, JsonValue> | null;
52
- source: "system" | "user";
53
50
  createdAt: Date;
54
51
  updatedAt: Date;
55
52
  }, "automation.updated", 2>, {
@@ -65,7 +62,6 @@ declare const automationEvents: {
65
62
  }[];
66
63
  enabled: boolean;
67
64
  filter: Record<string, unknown> | null;
68
- source: "system" | "user";
69
65
  createdAt: unknown;
70
66
  updatedAt: unknown;
71
67
  }, undefined>;
@@ -82,7 +78,6 @@ declare const automationEvents: {
82
78
  }[];
83
79
  enabled: boolean;
84
80
  filter: Record<string, JsonValue> | null;
85
- source: "system" | "user";
86
81
  createdAt: Date;
87
82
  updatedAt: Date;
88
83
  }, "automation.deleted", 2>, {
@@ -98,7 +93,6 @@ declare const automationEvents: {
98
93
  }[];
99
94
  enabled: boolean;
100
95
  filter: Record<string, unknown> | null;
101
- source: "system" | "user";
102
96
  createdAt: unknown;
103
97
  updatedAt: unknown;
104
98
  }, undefined>;
@@ -115,7 +109,6 @@ declare const automationEvents: {
115
109
  }[];
116
110
  enabled: boolean;
117
111
  filter: Record<string, JsonValue> | null;
118
- source: "system" | "user";
119
112
  createdAt: Date;
120
113
  updatedAt: Date;
121
114
  }, "automation.enabled", 2>, {
@@ -131,7 +124,6 @@ declare const automationEvents: {
131
124
  }[];
132
125
  enabled: boolean;
133
126
  filter: Record<string, unknown> | null;
134
- source: "system" | "user";
135
127
  createdAt: unknown;
136
128
  updatedAt: unknown;
137
129
  }, undefined>;
@@ -148,7 +140,6 @@ declare const automationEvents: {
148
140
  }[];
149
141
  enabled: boolean;
150
142
  filter: Record<string, JsonValue> | null;
151
- source: "system" | "user";
152
143
  createdAt: Date;
153
144
  updatedAt: Date;
154
145
  }, "automation.disabled", 2>, {
@@ -164,7 +155,6 @@ declare const automationEvents: {
164
155
  }[];
165
156
  enabled: boolean;
166
157
  filter: Record<string, unknown> | null;
167
- source: "system" | "user";
168
158
  createdAt: unknown;
169
159
  updatedAt: unknown;
170
160
  }, undefined>;
@@ -1,11 +1,18 @@
1
1
  import { Page } from "../types/shared.js";
2
2
  import { Automation, AutomationAction, AutomationActionResult, AutomationKind, AutomationRun, AutomationRunStatus, AutomationRunsQuery, AutomationTrigger, AutomationsQuery, AvailableAction, AvailableActions, AvailableTriggers, CreateAutomationInput, CreateWebhookInput, CreatedWebhook, UpdateAutomationInput, UpdateWebhookInput, Webhook, WebhookSecret } from "../types/schemas/automations.js";
3
- import { AutomationDispatch, AutomationEngine, AutomationExecutor, WebhookRequest, WebhookResponse, WebhookSender } from "../types/automations.js";
3
+ import { AutomationDispatch, AutomationEngine, AutomationExecutor, DeliveryDispatch, WebhookRequest, WebhookResponse, WebhookSender } from "../types/automations.js";
4
4
  import { ACTION_FAILED, ActionFailedError, AutomationKindMismatchError, InvalidTriggerError, ReservedActionError, actionFailureMessage } from "./model.js";
5
5
  import "./types.js";
6
- import { AutomationRunsRepository, AutomationsRepository, AutomationsService, AutomationsUnitOfWork, NewAutomation, NewAutomationRun } from "./ports.js";
7
- import { CommunityMailReads, GrantWriter, ScheduledWork } from "./community-mail.js";
6
+ import { AutomationRunsRepository, AutomationsRepository, AutomationsService, AutomationsUnitOfWork, ChatDebounce, ListedNotification, NewAutomation, NewAutomationRun, NewDelivery, NewNotification, NotificationCategories, NotificationPage, NotificationReads, NotificationsRepository, NotificationsService, RecipientRule, UnreadCounts } from "./ports.js";
7
+ import { CommunityMailReads, GrantWriter } from "./community-mail.js";
8
8
  import { AutomationActionFailed, AutomationCreated, AutomationDeleted, AutomationDisabled, AutomationEnabled, AutomationEvent, AutomationRunCompleted, AutomationRunFailed, AutomationRunStarted, AutomationUpdated, automationEvents } from "./events.js";
9
+ import { CHANNEL_NOT_CONFIGURED, NOT_ACCEPTED, NO_ADDRESS, NotificationDelivery } from "./notifications/delivery.js";
10
+ import { DEVICE_WINDOW_MS, IN_APP, MESSAGE_SENT, NotificationProcessor, PUSH } from "./notifications/processor.js";
9
11
  import { AutomationsServiceImpl } from "./service.js";
10
12
  import { cronMatches } from "./schedule.js";
11
- export { ACTION_FAILED, ActionFailedError, type Automation, type AutomationAction, type AutomationActionFailed, type AutomationActionResult, type AutomationCreated, type AutomationDeleted, type AutomationDisabled, type AutomationDispatch, type AutomationEnabled, type AutomationEngine, type AutomationEvent, type AutomationExecutor, type AutomationKind, AutomationKindMismatchError, type AutomationRun, type AutomationRunCompleted, type AutomationRunFailed, type AutomationRunStarted, type AutomationRunStatus, type AutomationRunsQuery, type AutomationRunsRepository, type AutomationTrigger, type AutomationUpdated, type AutomationsQuery, type AutomationsRepository, type AutomationsService, AutomationsServiceImpl, type AutomationsUnitOfWork, type AvailableAction, type AvailableActions, type AvailableTriggers, type CommunityMailReads, type CreateAutomationInput, type CreateWebhookInput, type CreatedWebhook, type GrantWriter, InvalidTriggerError, type NewAutomation, type NewAutomationRun, type Page, ReservedActionError, type ScheduledWork, type UpdateAutomationInput, type UpdateWebhookInput, type Webhook, type WebhookRequest, type WebhookResponse, type WebhookSecret, type WebhookSender, actionFailureMessage, automationEvents, cronMatches };
13
+ import { NotificationsServiceImpl } from "./notifications/service.js";
14
+ import { CHAT_QUIET_MS, FLUSH_JOB, SchedulerChatDebounce, flushKey, notificationJobs } from "./notifications/debounce.js";
15
+ import { RECIPIENT_RULES } from "./notifications/rules/index.js";
16
+ import { NOTIFICATION_TYPES } from "./notifications/types.js";
17
+ import { DEFAULT_COMMUNITY_CATEGORIES, DEFAULT_ORG_CATEGORIES } from "./notifications/defaults.js";
18
+ export { ACTION_FAILED, ActionFailedError, type Automation, type AutomationAction, type AutomationActionFailed, type AutomationActionResult, type AutomationCreated, type AutomationDeleted, type AutomationDisabled, type AutomationDispatch, type AutomationEnabled, type AutomationEngine, type AutomationEvent, type AutomationExecutor, type AutomationKind, AutomationKindMismatchError, type AutomationRun, type AutomationRunCompleted, type AutomationRunFailed, type AutomationRunStarted, type AutomationRunStatus, type AutomationRunsQuery, type AutomationRunsRepository, type AutomationTrigger, type AutomationUpdated, type AutomationsQuery, type AutomationsRepository, type AutomationsService, AutomationsServiceImpl, type AutomationsUnitOfWork, type AvailableAction, type AvailableActions, type AvailableTriggers, CHANNEL_NOT_CONFIGURED, CHAT_QUIET_MS, type ChatDebounce, type CommunityMailReads, type CreateAutomationInput, type CreateWebhookInput, type CreatedWebhook, DEFAULT_COMMUNITY_CATEGORIES, DEFAULT_ORG_CATEGORIES, DEVICE_WINDOW_MS, type DeliveryDispatch, FLUSH_JOB, type GrantWriter, IN_APP, InvalidTriggerError, type ListedNotification, MESSAGE_SENT, NOTIFICATION_TYPES, NOT_ACCEPTED, NO_ADDRESS, type NewAutomation, type NewAutomationRun, type NewDelivery, type NewNotification, type NotificationCategories, NotificationDelivery, type NotificationPage, NotificationProcessor, type NotificationReads, type NotificationsRepository, type NotificationsService, NotificationsServiceImpl, PUSH, type Page, RECIPIENT_RULES, type RecipientRule, ReservedActionError, SchedulerChatDebounce, type UnreadCounts, type UpdateAutomationInput, type UpdateWebhookInput, type Webhook, type WebhookRequest, type WebhookResponse, type WebhookSecret, type WebhookSender, actionFailureMessage, automationEvents, cronMatches, flushKey, notificationJobs };
@@ -2,4 +2,11 @@ import { ACTION_FAILED, ActionFailedError, AutomationKindMismatchError, InvalidT
2
2
  import { automationEvents } from "./events.js";
3
3
  import { cronMatches } from "./schedule.js";
4
4
  import { AutomationsServiceImpl } from "./service.js";
5
- export { ACTION_FAILED, ActionFailedError, AutomationKindMismatchError, AutomationsServiceImpl, InvalidTriggerError, ReservedActionError, actionFailureMessage, automationEvents, cronMatches };
5
+ import { NotificationsServiceImpl } from "./notifications/service.js";
6
+ import { CHANNEL_NOT_CONFIGURED, NOT_ACCEPTED, NO_ADDRESS, NotificationDelivery } from "./notifications/delivery.js";
7
+ import { DEVICE_WINDOW_MS, IN_APP, MESSAGE_SENT, NotificationProcessor, PUSH } from "./notifications/processor.js";
8
+ import { CHAT_QUIET_MS, FLUSH_JOB, SchedulerChatDebounce, flushKey, notificationJobs } from "./notifications/debounce.js";
9
+ import { RECIPIENT_RULES } from "./notifications/rules/index.js";
10
+ import { NOTIFICATION_TYPES } from "./notifications/types.js";
11
+ import { DEFAULT_COMMUNITY_CATEGORIES, DEFAULT_ORG_CATEGORIES } from "./notifications/defaults.js";
12
+ export { ACTION_FAILED, ActionFailedError, AutomationKindMismatchError, AutomationsServiceImpl, CHANNEL_NOT_CONFIGURED, CHAT_QUIET_MS, DEFAULT_COMMUNITY_CATEGORIES, DEFAULT_ORG_CATEGORIES, DEVICE_WINDOW_MS, FLUSH_JOB, IN_APP, InvalidTriggerError, MESSAGE_SENT, NOTIFICATION_TYPES, NOT_ACCEPTED, NO_ADDRESS, NotificationDelivery, NotificationProcessor, NotificationsServiceImpl, PUSH, RECIPIENT_RULES, ReservedActionError, SchedulerChatDebounce, actionFailureMessage, automationEvents, cronMatches, flushKey, notificationJobs };
@@ -0,0 +1,25 @@
1
+ import { Logger } from "../../types/ports.js";
2
+ import { RecipientList } from "../../types/notifications.js";
3
+ import "../../types/index.js";
4
+ import { ScheduledJob, Scheduler } from "../../shared/ports.js";
5
+ import { ChatDebounce, NotificationReads } from "../ports.js";
6
+ import { NotificationProcessor } from "./processor.js";
7
+ //#region src/automations/notifications/debounce.d.ts
8
+ declare const FLUSH_JOB = "automations.notifications.flush";
9
+ declare const CHAT_QUIET_MS: number;
10
+ declare function flushKey(userId: string, chatId: string): string;
11
+ declare class SchedulerChatDebounce implements ChatDebounce {
12
+ private readonly scheduler;
13
+ constructor(scheduler: Pick<Scheduler, 'at' | 'cancel'>);
14
+ arm(orgId: string, list: RecipientList, occurredAt: Date): Promise<void>;
15
+ mentioned(_orgId: string, userId: string, chatId: string): Promise<void>;
16
+ }
17
+ interface NotificationJobDeps {
18
+ processor: Pick<NotificationProcessor, 'file'>;
19
+ reads: NotificationReads;
20
+ logger?: Logger;
21
+ }
22
+ declare function notificationJobs(deps: NotificationJobDeps): ScheduledJob[];
23
+ //#endregion
24
+ export { CHAT_QUIET_MS, FLUSH_JOB, NotificationJobDeps, SchedulerChatDebounce, flushKey, notificationJobs };
25
+ //# sourceMappingURL=debounce.d.ts.map
@@ -0,0 +1,93 @@
1
+ import { idSchema } from "../../types/schemas/shared.js";
2
+ import { noopLogger } from "../../shared/logger.js";
3
+ import "../community-mail.js";
4
+ import { chatOf } from "./processor.js";
5
+ import { Reasons, chatReach, chatTitle, recipientsOf, textExcerpt } from "./rules/recipients.js";
6
+ import { messageSummary } from "./rules/discussion.js";
7
+ import { z } from "zod";
8
+ //#region src/automations/notifications/debounce.ts
9
+ const FLUSH_JOB = "automations.notifications.flush";
10
+ const CHAT_QUIET_MS = 120 * 1e3;
11
+ const flushPayload = z.object({
12
+ orgId: idSchema,
13
+ userId: idSchema,
14
+ orgUserId: idSchema,
15
+ chatId: idSchema
16
+ }).strict();
17
+ function flushKey(userId, chatId) {
18
+ return `${userId}:${chatId}`;
19
+ }
20
+ var SchedulerChatDebounce = class {
21
+ scheduler;
22
+ constructor(scheduler) {
23
+ this.scheduler = scheduler;
24
+ }
25
+ async arm(orgId, list, occurredAt) {
26
+ const chatId = chatOf(list);
27
+ if (!chatId) return;
28
+ const runAt = new Date(occurredAt.getTime() + CHAT_QUIET_MS);
29
+ for (const recipient of list.recipients ?? []) await this.scheduler.at(FLUSH_JOB, runAt, flushKey(recipient.userId, chatId), {
30
+ orgId,
31
+ userId: recipient.userId,
32
+ orgUserId: recipient.orgUserId,
33
+ chatId
34
+ });
35
+ }
36
+ async mentioned(_orgId, userId, chatId) {
37
+ await this.scheduler.cancel(FLUSH_JOB, flushKey(userId, chatId));
38
+ }
39
+ };
40
+ function notificationJobs(deps) {
41
+ const logger = deps.logger ?? noopLogger;
42
+ return [{
43
+ job: FLUSH_JOB,
44
+ async run(payload, fire) {
45
+ const parsed = flushPayload.safeParse(payload);
46
+ if (!parsed.success) {
47
+ logger.error("chat flush payload refused", {
48
+ job: FLUSH_JOB,
49
+ fireId: fire.id
50
+ });
51
+ return;
52
+ }
53
+ const { orgId, orgUserId, chatId } = parsed.data;
54
+ const unread = await deps.reads.unreadInChat(orgId, chatId, orgUserId);
55
+ if (unread.count === 0 || !unread.latest) return;
56
+ const chat = await deps.reads.chat(orgId, chatId);
57
+ if (!chat) return;
58
+ const latest = unread.latest;
59
+ const recipients = await recipientsOf(deps.reads, orgId, new Reasons().add([orgUserId], "participant"), chatReach(deps.reads, orgId, chat, chatId, latest.senderOrgUserId, fire.startedAt));
60
+ if (recipients.length === 0) return;
61
+ await deps.processor.file(orgId, `chat-flush:${chatId}:${latest.messageId}`, [{
62
+ type: "message.sent",
63
+ scope: "chat",
64
+ actorOrgUserId: latest.senderOrgUserId,
65
+ communityId: chat.communityId,
66
+ spaceId: null,
67
+ subject: {
68
+ type: "message",
69
+ id: latest.messageId
70
+ },
71
+ parent: {
72
+ type: "chat",
73
+ id: chatId
74
+ },
75
+ display: {
76
+ senderName: await deps.reads.displayName(orgId, latest.senderOrgUserId),
77
+ chatTitle: await chatTitle(deps.reads, orgId, chat, latest.senderOrgUserId),
78
+ excerpt: await textExcerpt(deps.reads, orgId, latest.body, 140),
79
+ count: String(unread.count),
80
+ summary: messageSummary(unread.count)
81
+ },
82
+ recipients
83
+ }], {
84
+ occurredAt: fire.startedAt,
85
+ debounce: false
86
+ });
87
+ }
88
+ }];
89
+ }
90
+ //#endregion
91
+ export { CHAT_QUIET_MS, FLUSH_JOB, SchedulerChatDebounce, flushKey, notificationJobs };
92
+
93
+ //# sourceMappingURL=debounce.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debounce.js","names":[],"sources":["../../../src/automations/notifications/debounce.ts"],"sourcesContent":["import { z } from 'zod';\nimport { idSchema } from '../../types/schemas/index.js';\nimport type { RecipientList } from '../../types/index.js';\nimport { noopLogger } from '../../shared/logger.js';\nimport type { Logger, ScheduledJob, Scheduler } from '../../shared/ports.js';\nimport { MESSAGE_EXCERPT } from '../community-mail.js';\nimport type { ChatDebounce, NotificationReads } from '../ports.js';\nimport { chatOf, type NotificationProcessor } from './processor.js';\nimport { messageSummary } from './rules/discussion.js';\nimport { chatReach, chatTitle, Reasons, recipientsOf, textExcerpt } from './rules/recipients.js';\n\nexport const FLUSH_JOB = 'automations.notifications.flush';\nexport const CHAT_QUIET_MS = 2 * 60 * 1000;\n\nconst flushPayload = z\n .object({ orgId: idSchema, userId: idSchema, orgUserId: idSchema, chatId: idSchema })\n .strict();\n\nexport function flushKey(userId: string, chatId: string): string {\n return `${userId}:${chatId}`;\n}\n\nexport class SchedulerChatDebounce implements ChatDebounce {\n constructor(private readonly scheduler: Pick<Scheduler, 'at' | 'cancel'>) {}\n\n async arm(orgId: string, list: RecipientList, occurredAt: Date): Promise<void> {\n const chatId = chatOf(list);\n if (!chatId) {\n return;\n }\n const runAt = new Date(occurredAt.getTime() + CHAT_QUIET_MS);\n for (const recipient of list.recipients ?? []) {\n await this.scheduler.at(FLUSH_JOB, runAt, flushKey(recipient.userId, chatId), {\n orgId,\n userId: recipient.userId,\n orgUserId: recipient.orgUserId,\n chatId,\n });\n }\n }\n\n async mentioned(_orgId: string, userId: string, chatId: string): Promise<void> {\n await this.scheduler.cancel(FLUSH_JOB, flushKey(userId, chatId));\n }\n}\n\nexport interface NotificationJobDeps {\n processor: Pick<NotificationProcessor, 'file'>;\n reads: NotificationReads;\n logger?: Logger;\n}\n\nexport function notificationJobs(deps: NotificationJobDeps): ScheduledJob[] {\n const logger = deps.logger ?? noopLogger;\n return [\n {\n job: FLUSH_JOB,\n async run(payload, fire) {\n const parsed = flushPayload.safeParse(payload);\n if (!parsed.success) {\n logger.error('chat flush payload refused', { job: FLUSH_JOB, fireId: fire.id });\n return;\n }\n const { orgId, orgUserId, chatId } = parsed.data;\n const unread = await deps.reads.unreadInChat(orgId, chatId, orgUserId);\n if (unread.count === 0 || !unread.latest) {\n return;\n }\n const chat = await deps.reads.chat(orgId, chatId);\n if (!chat) {\n return;\n }\n const latest = unread.latest;\n const recipients = await recipientsOf(\n deps.reads,\n orgId,\n new Reasons().add([orgUserId], 'participant'),\n chatReach(deps.reads, orgId, chat, chatId, latest.senderOrgUserId, fire.startedAt),\n );\n if (recipients.length === 0) {\n return;\n }\n await deps.processor.file(\n orgId,\n `chat-flush:${chatId}:${latest.messageId}`,\n [\n {\n type: 'message.sent',\n scope: 'chat',\n actorOrgUserId: latest.senderOrgUserId,\n communityId: chat.communityId,\n spaceId: null,\n subject: { type: 'message', id: latest.messageId },\n parent: { type: 'chat', id: chatId },\n display: {\n senderName: await deps.reads.displayName(orgId, latest.senderOrgUserId),\n chatTitle: await chatTitle(deps.reads, orgId, chat, latest.senderOrgUserId),\n excerpt: await textExcerpt(deps.reads, orgId, latest.body, MESSAGE_EXCERPT),\n count: String(unread.count),\n summary: messageSummary(unread.count),\n },\n recipients,\n },\n ],\n { occurredAt: fire.startedAt, debounce: false },\n );\n },\n },\n ];\n}\n"],"mappings":";;;;;;;;AAWA,MAAa,YAAY;AACzB,MAAa,gBAAgB,MAAS;AAEtC,MAAM,eAAe,EAClB,OAAO;CAAE,OAAO;CAAU,QAAQ;CAAU,WAAW;CAAU,QAAQ;AAAS,CAAC,CAAC,CACpF,OAAO;AAEV,SAAgB,SAAS,QAAgB,QAAwB;CAC/D,OAAO,GAAG,OAAO,GAAG;AACtB;AAEA,IAAa,wBAAb,MAA2D;CAC5B;CAA7B,YAAY,WAA8D;EAA7C,KAAA,YAAA;CAA8C;CAE3E,MAAM,IAAI,OAAe,MAAqB,YAAiC;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,gBAAgB,OAAO;IACvB,aAAa,KAAK;IAClB,SAAS;IACT,SAAS;KAAE,MAAM;KAAW,IAAI,OAAO;IAAU;IACjD,QAAQ;KAAE,MAAM;KAAQ,IAAI;IAAO;IACnC,SAAS;KACP,YAAY,MAAM,KAAK,MAAM,YAAY,OAAO,OAAO,eAAe;KACtE,WAAW,MAAM,UAAU,KAAK,OAAO,OAAO,MAAM,OAAO,eAAe;KAC1E,SAAS,MAAM,YAAY,KAAK,OAAO,OAAO,OAAO,MAAA,GAAqB;KAC1E,OAAO,OAAO,OAAO,KAAK;KAC1B,SAAS,eAAe,OAAO,KAAK;IACtC;IACA;GACF,CACF,GACA;IAAE,YAAY,KAAK;IAAW,UAAU;GAAM,CAChD;EACF;CACF,CACF;AACF"}
@@ -0,0 +1,8 @@
1
+ import { NotificationCategory } from "../../types/notifications.js";
2
+ import "../../types/index.js";
3
+ //#region src/automations/notifications/defaults.d.ts
4
+ declare const DEFAULT_COMMUNITY_CATEGORIES: NotificationCategory[];
5
+ declare const DEFAULT_ORG_CATEGORIES: NotificationCategory[];
6
+ //#endregion
7
+ export { DEFAULT_COMMUNITY_CATEGORIES, DEFAULT_ORG_CATEGORIES };
8
+ //# sourceMappingURL=defaults.d.ts.map
@@ -0,0 +1,316 @@
1
+ //#region src/automations/notifications/defaults.ts
2
+ const on = {
3
+ default: true,
4
+ locked: false
5
+ };
6
+ const off = {
7
+ default: false,
8
+ locked: false
9
+ };
10
+ const lockedOn = {
11
+ default: true,
12
+ locked: true
13
+ };
14
+ const DEFAULT_COMMUNITY_CATEGORIES = [
15
+ {
16
+ key: "about_you",
17
+ covers: [
18
+ {
19
+ type: "post.approved",
20
+ reasons: ["subject"]
21
+ },
22
+ {
23
+ type: "post.removed",
24
+ reasons: ["subject"]
25
+ },
26
+ {
27
+ type: "comment.removed",
28
+ reasons: ["subject"]
29
+ },
30
+ {
31
+ type: "space.invited",
32
+ reasons: ["subject"]
33
+ },
34
+ {
35
+ type: "space.request_approved",
36
+ reasons: ["subject"]
37
+ },
38
+ {
39
+ type: "space.request_declined",
40
+ reasons: ["subject"]
41
+ },
42
+ {
43
+ type: "community.welcome",
44
+ reasons: ["subject"]
45
+ },
46
+ {
47
+ type: "community.ending_soon",
48
+ reasons: ["subject"]
49
+ },
50
+ {
51
+ type: "chat.added",
52
+ reasons: ["subject"]
53
+ }
54
+ ],
55
+ channels: {
56
+ inApp: lockedOn,
57
+ email: on,
58
+ push: on
59
+ }
60
+ },
61
+ {
62
+ key: "review",
63
+ covers: [
64
+ {
65
+ type: "post.awaiting_review",
66
+ reasons: ["moderator"]
67
+ },
68
+ {
69
+ type: "space.join_requested",
70
+ reasons: ["moderator"]
71
+ },
72
+ {
73
+ type: "content.flagged",
74
+ reasons: ["moderator"]
75
+ },
76
+ {
77
+ type: "message.flagged",
78
+ reasons: ["staff"]
79
+ }
80
+ ],
81
+ channels: {
82
+ inApp: on,
83
+ email: on,
84
+ push: on
85
+ }
86
+ },
87
+ {
88
+ key: "mentions",
89
+ covers: [{
90
+ type: "mention",
91
+ reasons: ["mentioned"]
92
+ }],
93
+ channels: {
94
+ inApp: on,
95
+ email: on,
96
+ push: on
97
+ }
98
+ },
99
+ {
100
+ key: "comments_on_my_posts",
101
+ covers: [{
102
+ type: "comment.created",
103
+ reasons: ["post_author"]
104
+ }],
105
+ channels: {
106
+ inApp: on,
107
+ email: on,
108
+ push: on
109
+ }
110
+ },
111
+ {
112
+ key: "replies_to_my_comments",
113
+ covers: [{
114
+ type: "comment.created",
115
+ reasons: ["comment_author"]
116
+ }],
117
+ channels: {
118
+ inApp: on,
119
+ email: on,
120
+ push: on
121
+ }
122
+ },
123
+ {
124
+ key: "followed_posts",
125
+ covers: [{
126
+ type: "comment.created",
127
+ reasons: ["follower", "thread_participant"]
128
+ }],
129
+ channels: {
130
+ inApp: on,
131
+ email: off,
132
+ push: on
133
+ }
134
+ },
135
+ {
136
+ key: "messages",
137
+ covers: [
138
+ {
139
+ type: "message.sent",
140
+ reasons: ["participant"]
141
+ },
142
+ {
143
+ type: "chat.request",
144
+ reasons: ["participant"]
145
+ },
146
+ {
147
+ type: "message.reacted",
148
+ reasons: ["message_author"]
149
+ }
150
+ ],
151
+ channels: {
152
+ inApp: on,
153
+ email: off,
154
+ push: on
155
+ }
156
+ },
157
+ {
158
+ key: "likes_on_my_posts",
159
+ covers: [{
160
+ type: "post.reacted",
161
+ reasons: ["post_author"]
162
+ }],
163
+ channels: {
164
+ inApp: on,
165
+ email: off,
166
+ push: off
167
+ }
168
+ },
169
+ {
170
+ key: "likes_on_my_comments",
171
+ covers: [{
172
+ type: "comment.reacted",
173
+ reasons: ["comment_author"]
174
+ }],
175
+ channels: {
176
+ inApp: on,
177
+ email: off,
178
+ push: off
179
+ }
180
+ },
181
+ {
182
+ key: "new_posts",
183
+ perSpace: true,
184
+ covers: [{
185
+ type: "post.published",
186
+ reasons: ["space_member"]
187
+ }],
188
+ channels: {
189
+ inApp: off,
190
+ email: off,
191
+ push: off
192
+ }
193
+ },
194
+ {
195
+ key: "digest",
196
+ covers: [{
197
+ type: "digest",
198
+ reasons: ["community_member"]
199
+ }],
200
+ channels: { email: on }
201
+ }
202
+ ];
203
+ const DEFAULT_ORG_CATEGORIES = [
204
+ {
205
+ key: "about_you",
206
+ covers: [{
207
+ type: "moderator.assigned",
208
+ reasons: ["subject"]
209
+ }, {
210
+ type: "comment.removed",
211
+ reasons: ["subject"]
212
+ }],
213
+ channels: {
214
+ inApp: lockedOn,
215
+ email: on,
216
+ push: on
217
+ }
218
+ },
219
+ {
220
+ key: "review",
221
+ covers: [{
222
+ type: "content.flagged",
223
+ reasons: ["staff"]
224
+ }],
225
+ channels: {
226
+ inApp: on,
227
+ email: on,
228
+ push: on
229
+ }
230
+ },
231
+ {
232
+ key: "mentions",
233
+ covers: [{
234
+ type: "mention",
235
+ reasons: ["mentioned"]
236
+ }],
237
+ channels: {
238
+ inApp: on,
239
+ email: on,
240
+ push: on
241
+ }
242
+ },
243
+ {
244
+ key: "replies_to_my_comments",
245
+ covers: [{
246
+ type: "comment.created",
247
+ reasons: ["comment_author"]
248
+ }],
249
+ channels: {
250
+ inApp: on,
251
+ email: on,
252
+ push: on
253
+ }
254
+ },
255
+ {
256
+ key: "followed_threads",
257
+ covers: [{
258
+ type: "comment.created",
259
+ reasons: ["thread_participant"]
260
+ }],
261
+ channels: {
262
+ inApp: on,
263
+ email: off,
264
+ push: on
265
+ }
266
+ },
267
+ {
268
+ key: "likes_on_my_comments",
269
+ covers: [{
270
+ type: "comment.reacted",
271
+ reasons: ["comment_author"]
272
+ }],
273
+ channels: {
274
+ inApp: on,
275
+ email: off,
276
+ push: off
277
+ }
278
+ },
279
+ {
280
+ key: "access",
281
+ covers: [
282
+ {
283
+ type: "access.granted",
284
+ reasons: ["subject"]
285
+ },
286
+ {
287
+ type: "access.revoked",
288
+ reasons: ["subject"]
289
+ },
290
+ {
291
+ type: "community.membership_ended",
292
+ reasons: ["subject"]
293
+ }
294
+ ],
295
+ channels: {
296
+ inApp: on,
297
+ email: lockedOn
298
+ }
299
+ },
300
+ {
301
+ key: "course_content",
302
+ covers: [{
303
+ type: "course.activity_added",
304
+ reasons: ["course_member"]
305
+ }],
306
+ channels: {
307
+ inApp: on,
308
+ email: off,
309
+ push: off
310
+ }
311
+ }
312
+ ];
313
+ //#endregion
314
+ export { DEFAULT_COMMUNITY_CATEGORIES, DEFAULT_ORG_CATEGORIES };
315
+
316
+ //# sourceMappingURL=defaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.js","names":[],"sources":["../../../src/automations/notifications/defaults.ts"],"sourcesContent":["import type { NotificationCategory } from '../../types/index.js';\n\nconst on = { default: true, locked: false };\nconst off = { default: false, locked: false };\nconst lockedOn = { default: true, locked: true };\n\nexport const DEFAULT_COMMUNITY_CATEGORIES: NotificationCategory[] = [\n {\n key: 'about_you',\n covers: [\n { type: 'post.approved', reasons: ['subject'] },\n { type: 'post.removed', reasons: ['subject'] },\n { type: 'comment.removed', reasons: ['subject'] },\n { type: 'space.invited', reasons: ['subject'] },\n { type: 'space.request_approved', reasons: ['subject'] },\n { type: 'space.request_declined', reasons: ['subject'] },\n { type: 'community.welcome', reasons: ['subject'] },\n { type: 'community.ending_soon', reasons: ['subject'] },\n { type: 'chat.added', reasons: ['subject'] },\n ],\n channels: { inApp: lockedOn, email: on, push: on },\n },\n {\n key: 'review',\n covers: [\n { type: 'post.awaiting_review', reasons: ['moderator'] },\n { type: 'space.join_requested', reasons: ['moderator'] },\n { type: 'content.flagged', reasons: ['moderator'] },\n { type: 'message.flagged', reasons: ['staff'] },\n ],\n channels: { inApp: on, email: on, push: on },\n },\n {\n key: 'mentions',\n covers: [{ type: 'mention', reasons: ['mentioned'] }],\n channels: { inApp: on, email: on, push: on },\n },\n {\n key: 'comments_on_my_posts',\n covers: [{ type: 'comment.created', reasons: ['post_author'] }],\n channels: { inApp: on, email: on, push: on },\n },\n {\n key: 'replies_to_my_comments',\n covers: [{ type: 'comment.created', reasons: ['comment_author'] }],\n channels: { inApp: on, email: on, push: on },\n },\n {\n key: 'followed_posts',\n covers: [{ type: 'comment.created', reasons: ['follower', 'thread_participant'] }],\n channels: { inApp: on, email: off, push: on },\n },\n {\n key: 'messages',\n covers: [\n { type: 'message.sent', reasons: ['participant'] },\n { type: 'chat.request', reasons: ['participant'] },\n { type: 'message.reacted', reasons: ['message_author'] },\n ],\n channels: { inApp: on, email: off, push: on },\n },\n {\n key: 'likes_on_my_posts',\n covers: [{ type: 'post.reacted', reasons: ['post_author'] }],\n channels: { inApp: on, email: off, push: off },\n },\n {\n key: 'likes_on_my_comments',\n covers: [{ type: 'comment.reacted', reasons: ['comment_author'] }],\n channels: { inApp: on, email: off, push: off },\n },\n {\n key: 'new_posts',\n perSpace: true,\n covers: [{ type: 'post.published', reasons: ['space_member'] }],\n channels: { inApp: off, email: off, push: off },\n },\n {\n key: 'digest',\n covers: [{ type: 'digest', reasons: ['community_member'] }],\n channels: { email: on },\n },\n];\n\nexport const DEFAULT_ORG_CATEGORIES: NotificationCategory[] = [\n {\n key: 'about_you',\n covers: [\n { type: 'moderator.assigned', reasons: ['subject'] },\n { type: 'comment.removed', reasons: ['subject'] },\n ],\n channels: { inApp: lockedOn, email: on, push: on },\n },\n {\n key: 'review',\n covers: [{ type: 'content.flagged', reasons: ['staff'] }],\n channels: { inApp: on, email: on, push: on },\n },\n {\n key: 'mentions',\n covers: [{ type: 'mention', reasons: ['mentioned'] }],\n channels: { inApp: on, email: on, push: on },\n },\n {\n key: 'replies_to_my_comments',\n covers: [{ type: 'comment.created', reasons: ['comment_author'] }],\n channels: { inApp: on, email: on, push: on },\n },\n {\n key: 'followed_threads',\n covers: [{ type: 'comment.created', reasons: ['thread_participant'] }],\n channels: { inApp: on, email: off, push: on },\n },\n {\n key: 'likes_on_my_comments',\n covers: [{ type: 'comment.reacted', reasons: ['comment_author'] }],\n channels: { inApp: on, email: off, push: off },\n },\n {\n key: 'access',\n covers: [\n { type: 'access.granted', reasons: ['subject'] },\n { type: 'access.revoked', reasons: ['subject'] },\n { type: 'community.membership_ended', reasons: ['subject'] },\n ],\n channels: { inApp: on, email: lockedOn },\n },\n {\n key: 'course_content',\n covers: [{ type: 'course.activity_added', reasons: ['course_member'] }],\n channels: { inApp: on, email: off, push: off },\n },\n];\n"],"mappings":";AAEA,MAAM,KAAK;CAAE,SAAS;CAAM,QAAQ;AAAM;AAC1C,MAAM,MAAM;CAAE,SAAS;CAAO,QAAQ;AAAM;AAC5C,MAAM,WAAW;CAAE,SAAS;CAAM,QAAQ;AAAK;AAE/C,MAAa,+BAAuD;CAClE;EACE,KAAK;EACL,QAAQ;GACN;IAAE,MAAM;IAAiB,SAAS,CAAC,SAAS;GAAE;GAC9C;IAAE,MAAM;IAAgB,SAAS,CAAC,SAAS;GAAE;GAC7C;IAAE,MAAM;IAAmB,SAAS,CAAC,SAAS;GAAE;GAChD;IAAE,MAAM;IAAiB,SAAS,CAAC,SAAS;GAAE;GAC9C;IAAE,MAAM;IAA0B,SAAS,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AAG;CAC7C;CACA;EACE,KAAK;EACL,QAAQ,CAAC;GAAE,MAAM;GAAmB,SAAS,CAAC,gBAAgB;EAAE,CAAC;EACjE,UAAU;GAAE,OAAO;GAAI,OAAO;GAAI,MAAM;EAAG;CAC7C;CACA;EACE,KAAK;EACL,QAAQ,CAAC;GAAE,MAAM;GAAmB,SAAS,CAAC,oBAAoB;EAAE,CAAC;EACrE,UAAU;GAAE,OAAO;GAAI,OAAO;GAAK,MAAM;EAAG;CAC9C;CACA;EACE,KAAK;EACL,QAAQ,CAAC;GAAE,MAAM;GAAmB,SAAS,CAAC,gBAAgB;EAAE,CAAC;EACjE,UAAU;GAAE,OAAO;GAAI,OAAO;GAAK,MAAM;EAAI;CAC/C;CACA;EACE,KAAK;EACL,QAAQ;GACN;IAAE,MAAM;IAAkB,SAAS,CAAC,SAAS;GAAE;GAC/C;IAAE,MAAM;IAAkB,SAAS,CAAC,SAAS;GAAE;GAC/C;IAAE,MAAM;IAA8B,SAAS,CAAC,SAAS;GAAE;EAC7D;EACA,UAAU;GAAE,OAAO;GAAI,OAAO;EAAS;CACzC;CACA;EACE,KAAK;EACL,QAAQ,CAAC;GAAE,MAAM;GAAyB,SAAS,CAAC,eAAe;EAAE,CAAC;EACtE,UAAU;GAAE,OAAO;GAAI,OAAO;GAAK,MAAM;EAAI;CAC/C;AACF"}
@@ -0,0 +1,28 @@
1
+ import { Logger } from "../../types/ports.js";
2
+ import { DeliveryDispatch } from "../../types/automations.js";
3
+ import "../../types/index.js";
4
+ import { ChannelRegistry } from "../../shared/ports.js";
5
+ import { DevicesService } from "../../identity/ports.js";
6
+ import "../../identity/index.js";
7
+ import { NotificationsRepository } from "../ports.js";
8
+ //#region src/automations/notifications/delivery.d.ts
9
+ declare const CHANNEL_NOT_CONFIGURED = "channel not configured";
10
+ declare const NO_ADDRESS = "no address";
11
+ declare const NOT_ACCEPTED = "not accepted";
12
+ type NotificationDeliveryParams = {
13
+ repo: Pick<NotificationsRepository, 'findDelivery' | 'markSent' | 'recordError' | 'markFailed'>;
14
+ channels: Pick<ChannelRegistry, 'get'>;
15
+ devices: Pick<DevicesService, 'removeDead'>;
16
+ logger?: Logger;
17
+ };
18
+ declare class NotificationDelivery {
19
+ private readonly repo;
20
+ private readonly channels;
21
+ private readonly devices;
22
+ private readonly logger;
23
+ constructor(params: NotificationDeliveryParams);
24
+ run(d: DeliveryDispatch, lastAttempt: boolean): Promise<void>;
25
+ }
26
+ //#endregion
27
+ export { CHANNEL_NOT_CONFIGURED, NOT_ACCEPTED, NO_ADDRESS, NotificationDelivery, NotificationDeliveryParams };
28
+ //# sourceMappingURL=delivery.d.ts.map