@headless-lms/core 0.3.0 → 0.5.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 (307) hide show
  1. package/dist/assets/events.d.ts +24 -18
  2. package/dist/assets/file-urls.d.ts +11 -7
  3. package/dist/assets/file-urls.js +14 -4
  4. package/dist/assets/file-urls.js.map +1 -1
  5. package/dist/assets/index.d.ts +5 -4
  6. package/dist/assets/index.js +4 -3
  7. package/dist/assets/jobs.d.ts +15 -0
  8. package/dist/assets/jobs.js +30 -0
  9. package/dist/assets/jobs.js.map +1 -0
  10. package/dist/assets/ports.d.ts +37 -17
  11. package/dist/assets/service.d.ts +30 -15
  12. package/dist/assets/service.js +229 -59
  13. package/dist/assets/service.js.map +1 -1
  14. package/dist/automations/actions.js +2 -63
  15. package/dist/automations/actions.js.map +1 -1
  16. package/dist/automations/catalog.d.ts +1 -2
  17. package/dist/automations/catalog.js +137 -65
  18. package/dist/automations/catalog.js.map +1 -1
  19. package/dist/automations/community-derivations.js +20 -20
  20. package/dist/automations/community-derivations.js.map +1 -1
  21. package/dist/automations/community-mail.d.ts +36 -20
  22. package/dist/automations/community-mail.js +32 -24
  23. package/dist/automations/community-mail.js.map +1 -1
  24. package/dist/automations/event-permissions.d.ts +12 -0
  25. package/dist/automations/event-permissions.js +38 -0
  26. package/dist/automations/event-permissions.js.map +1 -0
  27. package/dist/automations/events.d.ts +0 -10
  28. package/dist/automations/index.d.ts +12 -4
  29. package/dist/automations/index.js +9 -1
  30. package/dist/automations/notifications/applicable.d.ts +8 -0
  31. package/dist/automations/notifications/applicable.js +12 -0
  32. package/dist/automations/notifications/applicable.js.map +1 -0
  33. package/dist/automations/notifications/debounce.d.ts +25 -0
  34. package/dist/automations/notifications/debounce.js +93 -0
  35. package/dist/automations/notifications/debounce.js.map +1 -0
  36. package/dist/automations/notifications/defaults.d.ts +8 -0
  37. package/dist/automations/notifications/defaults.js +346 -0
  38. package/dist/automations/notifications/defaults.js.map +1 -0
  39. package/dist/automations/notifications/delivery.d.ts +28 -0
  40. package/dist/automations/notifications/delivery.js +88 -0
  41. package/dist/automations/notifications/delivery.js.map +1 -0
  42. package/dist/automations/notifications/processor.d.ts +64 -0
  43. package/dist/automations/notifications/processor.js +270 -0
  44. package/dist/automations/notifications/processor.js.map +1 -0
  45. package/dist/automations/notifications/rules/content.d.ts +6 -0
  46. package/dist/automations/notifications/rules/content.js +96 -0
  47. package/dist/automations/notifications/rules/content.js.map +1 -0
  48. package/dist/automations/notifications/rules/discussion.d.ts +7 -0
  49. package/dist/automations/notifications/rules/discussion.js +678 -0
  50. package/dist/automations/notifications/rules/discussion.js.map +1 -0
  51. package/dist/automations/notifications/rules/entitlements.d.ts +6 -0
  52. package/dist/automations/notifications/rules/entitlements.js +276 -0
  53. package/dist/automations/notifications/rules/entitlements.js.map +1 -0
  54. package/dist/automations/notifications/rules/events.d.ts +9 -0
  55. package/dist/automations/notifications/rules/events.js +27 -0
  56. package/dist/automations/notifications/rules/events.js.map +1 -0
  57. package/dist/automations/notifications/rules/index.d.ts +6 -0
  58. package/dist/automations/notifications/rules/index.js +15 -0
  59. package/dist/automations/notifications/rules/index.js.map +1 -0
  60. package/dist/automations/notifications/rules/organizations.d.ts +6 -0
  61. package/dist/automations/notifications/rules/organizations.js +35 -0
  62. package/dist/automations/notifications/rules/organizations.js.map +1 -0
  63. package/dist/automations/notifications/rules/recipients.d.ts +32 -0
  64. package/dist/automations/notifications/rules/recipients.js +98 -0
  65. package/dist/automations/notifications/rules/recipients.js.map +1 -0
  66. package/dist/automations/notifications/service.d.ts +29 -0
  67. package/dist/automations/notifications/service.js +45 -0
  68. package/dist/automations/notifications/service.js.map +1 -0
  69. package/dist/automations/notifications/types.d.ts +7 -0
  70. package/dist/automations/notifications/types.js +560 -0
  71. package/dist/automations/notifications/types.js.map +1 -0
  72. package/dist/automations/ports.d.ts +134 -21
  73. package/dist/automations/service.d.ts +30 -30
  74. package/dist/automations/service.js +111 -144
  75. package/dist/automations/service.js.map +1 -1
  76. package/dist/content/event-sight.d.ts +11 -0
  77. package/dist/content/event-sight.js +11 -0
  78. package/dist/content/event-sight.js.map +1 -0
  79. package/dist/content/events.d.ts +437 -46
  80. package/dist/content/events.js +45 -1
  81. package/dist/content/events.js.map +1 -1
  82. package/dist/content/index.d.ts +8 -4
  83. package/dist/content/index.js +5 -1
  84. package/dist/content/jobs.d.ts +16 -0
  85. package/dist/content/jobs.js +37 -0
  86. package/dist/content/jobs.js.map +1 -0
  87. package/dist/content/model.d.ts +2 -2
  88. package/dist/content/notification-categories.d.ts +37 -0
  89. package/dist/content/notification-categories.js +73 -0
  90. package/dist/content/notification-categories.js.map +1 -0
  91. package/dist/content/ports.d.ts +132 -68
  92. package/dist/content/service.d.ts +100 -68
  93. package/dist/content/service.js +703 -146
  94. package/dist/content/service.js.map +1 -1
  95. package/dist/content/titles.d.ts +25 -0
  96. package/dist/content/titles.js +82 -0
  97. package/dist/content/titles.js.map +1 -0
  98. package/dist/content/types.d.ts +2 -2
  99. package/dist/discussion/authors.d.ts +4 -2
  100. package/dist/discussion/authors.js +9 -5
  101. package/dist/discussion/authors.js.map +1 -1
  102. package/dist/discussion/chats.d.ts +63 -39
  103. package/dist/discussion/chats.js +455 -190
  104. package/dist/discussion/chats.js.map +1 -1
  105. package/dist/discussion/digests.d.ts +24 -0
  106. package/dist/discussion/digests.js +104 -0
  107. package/dist/discussion/digests.js.map +1 -0
  108. package/dist/discussion/events.d.ts +227 -23
  109. package/dist/discussion/events.js +114 -19
  110. package/dist/discussion/events.js.map +1 -1
  111. package/dist/discussion/index.d.ts +12 -4
  112. package/dist/discussion/index.js +9 -2
  113. package/dist/discussion/jobs.d.ts +16 -0
  114. package/dist/discussion/jobs.js +40 -0
  115. package/dist/discussion/jobs.js.map +1 -0
  116. package/dist/discussion/live.d.ts +106 -0
  117. package/dist/discussion/live.js +642 -0
  118. package/dist/discussion/live.js.map +1 -0
  119. package/dist/discussion/mentions.d.ts +11 -0
  120. package/dist/discussion/mentions.js +35 -0
  121. package/dist/discussion/mentions.js.map +1 -0
  122. package/dist/discussion/ports.d.ts +279 -114
  123. package/dist/discussion/ports.js.map +1 -1
  124. package/dist/discussion/posts.d.ts +60 -44
  125. package/dist/discussion/posts.js +453 -287
  126. package/dist/discussion/posts.js.map +1 -1
  127. package/dist/discussion/rules.d.ts +18 -0
  128. package/dist/discussion/rules.js +22 -0
  129. package/dist/discussion/rules.js.map +1 -0
  130. package/dist/discussion/service.d.ts +50 -35
  131. package/dist/discussion/service.js +333 -205
  132. package/dist/discussion/service.js.map +1 -1
  133. package/dist/discussion/subscriptions.d.ts +37 -0
  134. package/dist/discussion/subscriptions.js +115 -0
  135. package/dist/discussion/subscriptions.js.map +1 -0
  136. package/dist/discussion/titles.d.ts +28 -0
  137. package/dist/discussion/titles.js +98 -0
  138. package/dist/discussion/titles.js.map +1 -0
  139. package/dist/entitlements/events.d.ts +20 -20
  140. package/dist/entitlements/index.d.ts +5 -4
  141. package/dist/entitlements/index.js +3 -2
  142. package/dist/entitlements/jobs.d.ts +12 -0
  143. package/dist/entitlements/jobs.js +18 -0
  144. package/dist/entitlements/jobs.js.map +1 -0
  145. package/dist/entitlements/model.d.ts +2 -2
  146. package/dist/entitlements/ports.d.ts +68 -38
  147. package/dist/entitlements/rules.d.ts +3 -6
  148. package/dist/entitlements/rules.js +5 -10
  149. package/dist/entitlements/rules.js.map +1 -1
  150. package/dist/entitlements/service.d.ts +43 -28
  151. package/dist/entitlements/service.js +387 -160
  152. package/dist/entitlements/service.js.map +1 -1
  153. package/dist/identity/devices.d.ts +30 -0
  154. package/dist/identity/devices.js +109 -0
  155. package/dist/identity/devices.js.map +1 -0
  156. package/dist/identity/index.d.ts +6 -5
  157. package/dist/identity/index.js +4 -3
  158. package/dist/identity/model.d.ts +2 -2
  159. package/dist/identity/notification-settings.d.ts +28 -0
  160. package/dist/identity/notification-settings.js +114 -0
  161. package/dist/identity/notification-settings.js.map +1 -0
  162. package/dist/identity/ports.d.ts +80 -56
  163. package/dist/identity/service.d.ts +8 -7
  164. package/dist/identity/service.js +17 -13
  165. package/dist/identity/service.js.map +1 -1
  166. package/dist/integrations/ports.d.ts +9 -8
  167. package/dist/integrations/service.d.ts +9 -8
  168. package/dist/integrations/service.js +33 -16
  169. package/dist/integrations/service.js.map +1 -1
  170. package/dist/organizations/default-roles.d.ts +22 -0
  171. package/dist/organizations/default-roles.js +89 -0
  172. package/dist/organizations/default-roles.js.map +1 -0
  173. package/dist/organizations/effective-permissions.d.ts +45 -0
  174. package/dist/organizations/effective-permissions.js +113 -0
  175. package/dist/organizations/effective-permissions.js.map +1 -0
  176. package/dist/organizations/events.d.ts +320 -181
  177. package/dist/organizations/events.js +90 -18
  178. package/dist/organizations/events.js.map +1 -1
  179. package/dist/organizations/index.d.ts +15 -10
  180. package/dist/organizations/index.js +8 -3
  181. package/dist/organizations/members.d.ts +66 -8
  182. package/dist/organizations/members.js.map +1 -1
  183. package/dist/organizations/notification-catalog.d.ts +31 -0
  184. package/dist/organizations/notification-catalog.js +32 -0
  185. package/dist/organizations/notification-catalog.js.map +1 -0
  186. package/dist/organizations/notification-categories.d.ts +34 -0
  187. package/dist/organizations/notification-categories.js +66 -0
  188. package/dist/organizations/notification-categories.js.map +1 -0
  189. package/dist/organizations/org-roles.d.ts +33 -0
  190. package/dist/organizations/org-roles.js +49 -0
  191. package/dist/organizations/org-roles.js.map +1 -0
  192. package/dist/organizations/permissions.d.ts +311 -0
  193. package/dist/organizations/permissions.js +327 -0
  194. package/dist/organizations/permissions.js.map +1 -0
  195. package/dist/organizations/ports.d.ts +187 -65
  196. package/dist/organizations/service.d.ts +104 -35
  197. package/dist/organizations/service.js +1247 -323
  198. package/dist/organizations/service.js.map +1 -1
  199. package/dist/organizations/testing.d.ts +18 -0
  200. package/dist/organizations/testing.js +37 -0
  201. package/dist/organizations/testing.js.map +1 -0
  202. package/dist/organizations/types.d.ts +5 -16
  203. package/dist/progress/index.d.ts +2 -2
  204. package/dist/progress/ports.d.ts +11 -3
  205. package/dist/progress/service.d.ts +6 -5
  206. package/dist/progress/service.js +23 -8
  207. package/dist/progress/service.js.map +1 -1
  208. package/dist/reporting/admin/index.d.ts +6 -4
  209. package/dist/reporting/admin/model.d.ts +36 -3
  210. package/dist/reporting/admin/ports.d.ts +39 -14
  211. package/dist/reporting/admin/service.d.ts +32 -11
  212. package/dist/reporting/admin/service.js +102 -18
  213. package/dist/reporting/admin/service.js.map +1 -1
  214. package/dist/reporting/events/index.d.ts +27 -0
  215. package/dist/reporting/events/index.js +20 -0
  216. package/dist/reporting/events/index.js.map +1 -0
  217. package/dist/reporting/member/calendar.d.ts +11 -0
  218. package/dist/reporting/member/calendar.js +75 -0
  219. package/dist/reporting/member/calendar.js.map +1 -0
  220. package/dist/reporting/member/index.d.ts +3 -2
  221. package/dist/reporting/member/model.d.ts +80 -26
  222. package/dist/reporting/member/ports.d.ts +50 -28
  223. package/dist/reporting/member/service.d.ts +81 -35
  224. package/dist/reporting/member/service.js +438 -145
  225. package/dist/reporting/member/service.js.map +1 -1
  226. package/dist/shared/actor.d.ts +22 -3
  227. package/dist/shared/errors.d.ts +15 -2
  228. package/dist/shared/errors.js +21 -2
  229. package/dist/shared/errors.js.map +1 -1
  230. package/dist/shared/id.d.ts +7 -0
  231. package/dist/shared/id.js +8 -1
  232. package/dist/shared/id.js.map +1 -1
  233. package/dist/shared/logger.d.ts +2 -1
  234. package/dist/shared/logger.js +10 -1
  235. package/dist/shared/logger.js.map +1 -1
  236. package/dist/shared/mailer.d.ts +11 -1
  237. package/dist/shared/mailer.js +32 -5
  238. package/dist/shared/mailer.js.map +1 -1
  239. package/dist/shared/notification-categories.d.ts +16 -0
  240. package/dist/shared/notification-categories.js +94 -0
  241. package/dist/shared/notification-categories.js.map +1 -0
  242. package/dist/shared/notification-settings.d.ts +14 -0
  243. package/dist/shared/notification-settings.js +61 -0
  244. package/dist/shared/notification-settings.js.map +1 -0
  245. package/dist/shared/ports.d.ts +68 -2
  246. package/dist/shared/settings.d.ts +2 -1
  247. package/dist/shared/settings.js +1 -0
  248. package/dist/shared/settings.js.map +1 -1
  249. package/dist/types/automations.d.ts +8 -2
  250. package/dist/types/content.d.ts +2 -2
  251. package/dist/types/discussion.d.ts +4 -5
  252. package/dist/types/email-templates.d.ts +119 -6
  253. package/dist/types/entitlements.d.ts +2 -2
  254. package/dist/types/identity.d.ts +14 -17
  255. package/dist/types/index.d.ts +13 -12
  256. package/dist/types/index.js +2 -1
  257. package/dist/types/notifications.d.ts +157 -0
  258. package/dist/types/notifications.js +1 -0
  259. package/dist/types/organizations.d.ts +3 -2
  260. package/dist/types/ports.d.ts +8 -1
  261. package/dist/types/ports.js +7 -1
  262. package/dist/types/ports.js.map +1 -0
  263. package/dist/types/schemas/assets.d.ts +5 -5
  264. package/dist/types/schemas/assets.js +4 -3
  265. package/dist/types/schemas/assets.js.map +1 -1
  266. package/dist/types/schemas/automations.d.ts +1 -10
  267. package/dist/types/schemas/automations.js +1 -3
  268. package/dist/types/schemas/automations.js.map +1 -1
  269. package/dist/types/schemas/content.d.ts +596 -11
  270. package/dist/types/schemas/content.js +225 -9
  271. package/dist/types/schemas/content.js.map +1 -1
  272. package/dist/types/schemas/discussion.d.ts +362 -66
  273. package/dist/types/schemas/discussion.js +123 -15
  274. package/dist/types/schemas/discussion.js.map +1 -1
  275. package/dist/types/schemas/entitlements.d.ts +14 -1
  276. package/dist/types/schemas/entitlements.js +11 -4
  277. package/dist/types/schemas/entitlements.js.map +1 -1
  278. package/dist/types/schemas/identity.d.ts +1 -85
  279. package/dist/types/schemas/identity.js +1 -42
  280. package/dist/types/schemas/identity.js.map +1 -1
  281. package/dist/types/schemas/index.d.ts +8 -7
  282. package/dist/types/schemas/index.js +8 -7
  283. package/dist/types/schemas/notifications.d.ts +96 -0
  284. package/dist/types/schemas/notifications.js +57 -0
  285. package/dist/types/schemas/notifications.js.map +1 -0
  286. package/dist/types/schemas/organizations.d.ts +96 -60
  287. package/dist/types/schemas/organizations.js +78 -27
  288. package/dist/types/schemas/organizations.js.map +1 -1
  289. package/dist/types/schemas/progress.d.ts +0 -1
  290. package/dist/types/schemas/progress.js +0 -1
  291. package/dist/types/schemas/progress.js.map +1 -1
  292. package/package.json +1 -1
  293. package/dist/automations/community-notifications.d.ts +0 -16
  294. package/dist/automations/community-notifications.js +0 -84
  295. package/dist/automations/community-notifications.js.map +0 -1
  296. package/dist/automations/seeds.d.ts +0 -17
  297. package/dist/automations/seeds.js +0 -235
  298. package/dist/automations/seeds.js.map +0 -1
  299. package/dist/identity/notifications.d.ts +0 -27
  300. package/dist/identity/notifications.js +0 -101
  301. package/dist/identity/notifications.js.map +0 -1
  302. package/dist/organizations/access-scopes.d.ts +0 -19
  303. package/dist/organizations/access-scopes.js +0 -89
  304. package/dist/organizations/access-scopes.js.map +0 -1
  305. package/dist/organizations/roles.d.ts +0 -19
  306. package/dist/organizations/roles.js +0 -82
  307. package/dist/organizations/roles.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,19 @@
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
+ import { applicableCategories } from "./notifications/applicable.js";
19
+ 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, applicableCategories, automationEvents, cronMatches, flushKey, notificationJobs };
@@ -2,4 +2,12 @@ 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
+ import { applicableCategories } from "./notifications/applicable.js";
13
+ 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, applicableCategories, automationEvents, cronMatches, flushKey, notificationJobs };
@@ -0,0 +1,8 @@
1
+ import { NotificationCategory, SettingsScope } from "../../types/notifications.js";
2
+ import "../../types/index.js";
3
+ import { EffectivePermissions } from "../../shared/actor.js";
4
+ //#region src/automations/notifications/applicable.d.ts
5
+ declare function applicableCategories(categories: NotificationCategory[], permissions: EffectivePermissions, scope: SettingsScope): NotificationCategory[];
6
+ //#endregion
7
+ export { applicableCategories };
8
+ //# sourceMappingURL=applicable.d.ts.map
@@ -0,0 +1,12 @@
1
+ //#region src/automations/notifications/applicable.ts
2
+ function reasonApplies(reason, permissions, scope) {
3
+ if (reason !== "moderator") return true;
4
+ return scope === "org" ? permissions.anywhere("courses:moderate") : permissions.has("communities:moderate", scope.communityId);
5
+ }
6
+ function applicableCategories(categories, permissions, scope) {
7
+ return categories.filter((category) => category.covers.some((cover) => cover.reasons.some((reason) => reasonApplies(reason, permissions, scope))));
8
+ }
9
+ //#endregion
10
+ export { applicableCategories };
11
+
12
+ //# sourceMappingURL=applicable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applicable.js","names":[],"sources":["../../../src/automations/notifications/applicable.ts"],"sourcesContent":["import type { EffectivePermissions } from '../../shared/actor.js';\nimport type { NotificationCategory, Reason, SettingsScope } from '../../types/index.js';\n\nfunction reasonApplies(\n reason: Reason,\n permissions: EffectivePermissions,\n scope: SettingsScope,\n): boolean {\n if (reason !== 'moderator') {\n return true;\n }\n return scope === 'org'\n ? permissions.anywhere('courses:moderate')\n : permissions.has('communities:moderate', scope.communityId);\n}\n\nexport function applicableCategories(\n categories: NotificationCategory[],\n permissions: EffectivePermissions,\n scope: SettingsScope,\n): NotificationCategory[] {\n return categories.filter((category) =>\n category.covers.some((cover) =>\n cover.reasons.some((reason) => reasonApplies(reason, permissions, scope)),\n ),\n );\n}\n"],"mappings":";AAGA,SAAS,cACP,QACA,aACA,OACS;CACT,IAAI,WAAW,aACb,OAAO;CAET,OAAO,UAAU,QACb,YAAY,SAAS,kBAAkB,IACvC,YAAY,IAAI,wBAAwB,MAAM,WAAW;AAC/D;AAEA,SAAgB,qBACd,YACA,aACA,OACwB;CACxB,OAAO,WAAW,QAAQ,aACxB,SAAS,OAAO,MAAM,UACpB,MAAM,QAAQ,MAAM,WAAW,cAAc,QAAQ,aAAa,KAAK,CAAC,CAC1E,CACF;AACF"}
@@ -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
+ actorId: 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 actorId: 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;EAC7E,MAAM,SAAS,OAAO,IAAI;EAC1B,IAAI,CAAC,QACH;EAEF,MAAM,QAAQ,IAAI,KAAK,WAAW,QAAQ,IAAI,aAAa;EAC3D,KAAK,MAAM,aAAa,KAAK,cAAc,CAAC,GAC1C,MAAM,KAAK,UAAU,GAAG,WAAW,OAAO,SAAS,UAAU,QAAQ,MAAM,GAAG;GAC5E;GACA,QAAQ,UAAU;GAClB,WAAW,UAAU;GACrB;EACF,CAAC;CAEL;CAEA,MAAM,UAAU,QAAgB,QAAgB,QAA+B;EAC7E,MAAM,KAAK,UAAU,OAAO,WAAW,SAAS,QAAQ,MAAM,CAAC;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F,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,346 @@
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: ["moderator"]
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: "role.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: ["moderator"]
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: "events",
302
+ covers: [
303
+ {
304
+ type: "event.granted",
305
+ reasons: ["event_member"]
306
+ },
307
+ {
308
+ type: "event.starting_soon",
309
+ reasons: ["event_member"]
310
+ },
311
+ {
312
+ type: "event.changed",
313
+ reasons: ["event_member"]
314
+ },
315
+ {
316
+ type: "event.canceled",
317
+ reasons: ["event_member"]
318
+ },
319
+ {
320
+ type: "event.revoked",
321
+ reasons: ["event_member"]
322
+ }
323
+ ],
324
+ channels: {
325
+ inApp: lockedOn,
326
+ email: on,
327
+ push: on
328
+ }
329
+ },
330
+ {
331
+ key: "course_content",
332
+ covers: [{
333
+ type: "course.activity_added",
334
+ reasons: ["course_member"]
335
+ }],
336
+ channels: {
337
+ inApp: on,
338
+ email: off,
339
+ push: off
340
+ }
341
+ }
342
+ ];
343
+ //#endregion
344
+ export { DEFAULT_COMMUNITY_CATEGORIES, DEFAULT_ORG_CATEGORIES };
345
+
346
+ //# 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: ['moderator'] },\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: 'role.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: ['moderator'] }],\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: 'events',\n covers: [\n { type: 'event.granted', reasons: ['event_member'] },\n { type: 'event.starting_soon', reasons: ['event_member'] },\n { type: 'event.changed', reasons: ['event_member'] },\n { type: 'event.canceled', reasons: ['event_member'] },\n { type: 'event.revoked', reasons: ['event_member'] },\n ],\n channels: { inApp: lockedOn, email: on, push: on },\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;I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