@headless-lms/core 0.4.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 (249) hide show
  1. package/dist/assets/events.d.ts +27 -21
  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 +4 -4
  6. package/dist/assets/index.js +3 -3
  7. package/dist/assets/ports.d.ts +34 -15
  8. package/dist/assets/service.d.ts +30 -14
  9. package/dist/assets/service.js +230 -56
  10. package/dist/assets/service.js.map +1 -1
  11. package/dist/automations/actions.js.map +1 -1
  12. package/dist/automations/catalog.js +69 -4
  13. package/dist/automations/catalog.js.map +1 -1
  14. package/dist/automations/community-derivations.js +16 -16
  15. package/dist/automations/community-derivations.js.map +1 -1
  16. package/dist/automations/community-mail.d.ts +34 -4
  17. package/dist/automations/community-mail.js +32 -4
  18. package/dist/automations/community-mail.js.map +1 -1
  19. package/dist/automations/event-permissions.d.ts +12 -0
  20. package/dist/automations/event-permissions.js +38 -0
  21. package/dist/automations/event-permissions.js.map +1 -0
  22. package/dist/automations/index.d.ts +2 -1
  23. package/dist/automations/index.js +2 -1
  24. package/dist/automations/notifications/applicable.d.ts +8 -0
  25. package/dist/automations/notifications/applicable.js +12 -0
  26. package/dist/automations/notifications/applicable.js.map +1 -0
  27. package/dist/automations/notifications/debounce.js +1 -1
  28. package/dist/automations/notifications/debounce.js.map +1 -1
  29. package/dist/automations/notifications/defaults.js +33 -3
  30. package/dist/automations/notifications/defaults.js.map +1 -1
  31. package/dist/automations/notifications/processor.js +3 -3
  32. package/dist/automations/notifications/processor.js.map +1 -1
  33. package/dist/automations/notifications/rules/content.js +60 -3
  34. package/dist/automations/notifications/rules/content.js.map +1 -1
  35. package/dist/automations/notifications/rules/discussion.js +29 -29
  36. package/dist/automations/notifications/rules/discussion.js.map +1 -1
  37. package/dist/automations/notifications/rules/entitlements.js +36 -9
  38. package/dist/automations/notifications/rules/entitlements.js.map +1 -1
  39. package/dist/automations/notifications/rules/events.d.ts +9 -0
  40. package/dist/automations/notifications/rules/events.js +27 -0
  41. package/dist/automations/notifications/rules/events.js.map +1 -0
  42. package/dist/automations/notifications/rules/organizations.js +17 -10
  43. package/dist/automations/notifications/rules/organizations.js.map +1 -1
  44. package/dist/automations/notifications/rules/recipients.js +0 -1
  45. package/dist/automations/notifications/rules/recipients.js.map +1 -1
  46. package/dist/automations/notifications/service.d.ts +8 -6
  47. package/dist/automations/notifications/service.js +13 -13
  48. package/dist/automations/notifications/service.js.map +1 -1
  49. package/dist/automations/notifications/types.js +94 -7
  50. package/dist/automations/notifications/types.js.map +1 -1
  51. package/dist/automations/ports.d.ts +30 -31
  52. package/dist/automations/service.d.ts +20 -17
  53. package/dist/automations/service.js +91 -62
  54. package/dist/automations/service.js.map +1 -1
  55. package/dist/content/event-sight.d.ts +11 -0
  56. package/dist/content/event-sight.js +11 -0
  57. package/dist/content/event-sight.js.map +1 -0
  58. package/dist/content/events.d.ts +413 -72
  59. package/dist/content/events.js +34 -1
  60. package/dist/content/events.js.map +1 -1
  61. package/dist/content/index.d.ts +6 -4
  62. package/dist/content/index.js +3 -1
  63. package/dist/content/jobs.d.ts +16 -0
  64. package/dist/content/jobs.js +37 -0
  65. package/dist/content/jobs.js.map +1 -0
  66. package/dist/content/model.d.ts +2 -2
  67. package/dist/content/notification-categories.d.ts +5 -4
  68. package/dist/content/notification-categories.js +15 -6
  69. package/dist/content/notification-categories.js.map +1 -1
  70. package/dist/content/ports.d.ts +113 -68
  71. package/dist/content/service.d.ts +99 -67
  72. package/dist/content/service.js +680 -139
  73. package/dist/content/service.js.map +1 -1
  74. package/dist/content/titles.d.ts +6 -3
  75. package/dist/content/titles.js +37 -24
  76. package/dist/content/titles.js.map +1 -1
  77. package/dist/content/types.d.ts +2 -2
  78. package/dist/discussion/authors.d.ts +4 -2
  79. package/dist/discussion/authors.js +9 -5
  80. package/dist/discussion/authors.js.map +1 -1
  81. package/dist/discussion/chats.d.ts +56 -37
  82. package/dist/discussion/chats.js +393 -161
  83. package/dist/discussion/chats.js.map +1 -1
  84. package/dist/discussion/events.d.ts +77 -39
  85. package/dist/discussion/events.js +41 -3
  86. package/dist/discussion/events.js.map +1 -1
  87. package/dist/discussion/index.d.ts +8 -5
  88. package/dist/discussion/index.js +5 -3
  89. package/dist/discussion/live.d.ts +106 -0
  90. package/dist/discussion/live.js +642 -0
  91. package/dist/discussion/live.js.map +1 -0
  92. package/dist/discussion/mentions.js +2 -2
  93. package/dist/discussion/mentions.js.map +1 -1
  94. package/dist/discussion/ports.d.ts +182 -100
  95. package/dist/discussion/ports.js.map +1 -1
  96. package/dist/discussion/posts.d.ts +45 -39
  97. package/dist/discussion/posts.js +268 -154
  98. package/dist/discussion/posts.js.map +1 -1
  99. package/dist/discussion/rules.d.ts +18 -0
  100. package/dist/discussion/rules.js +22 -0
  101. package/dist/discussion/rules.js.map +1 -0
  102. package/dist/discussion/service.d.ts +37 -31
  103. package/dist/discussion/service.js +252 -188
  104. package/dist/discussion/service.js.map +1 -1
  105. package/dist/discussion/subscriptions.d.ts +8 -8
  106. package/dist/discussion/subscriptions.js +29 -13
  107. package/dist/discussion/subscriptions.js.map +1 -1
  108. package/dist/discussion/titles.d.ts +4 -2
  109. package/dist/discussion/titles.js +27 -13
  110. package/dist/discussion/titles.js.map +1 -1
  111. package/dist/entitlements/events.d.ts +20 -20
  112. package/dist/entitlements/index.d.ts +4 -4
  113. package/dist/entitlements/index.js +2 -2
  114. package/dist/entitlements/model.d.ts +2 -2
  115. package/dist/entitlements/ports.d.ts +65 -39
  116. package/dist/entitlements/rules.d.ts +3 -6
  117. package/dist/entitlements/rules.js +5 -10
  118. package/dist/entitlements/rules.js.map +1 -1
  119. package/dist/entitlements/service.d.ts +40 -28
  120. package/dist/entitlements/service.js +370 -163
  121. package/dist/entitlements/service.js.map +1 -1
  122. package/dist/identity/devices.d.ts +3 -3
  123. package/dist/identity/devices.js +7 -5
  124. package/dist/identity/devices.js.map +1 -1
  125. package/dist/identity/events.d.ts +2 -2
  126. package/dist/identity/index.d.ts +2 -2
  127. package/dist/identity/index.js +2 -2
  128. package/dist/identity/notification-settings.d.ts +1 -1
  129. package/dist/identity/notification-settings.js +3 -2
  130. package/dist/identity/notification-settings.js.map +1 -1
  131. package/dist/identity/ports.d.ts +7 -7
  132. package/dist/identity/service.d.ts +8 -7
  133. package/dist/identity/service.js +17 -13
  134. package/dist/identity/service.js.map +1 -1
  135. package/dist/integrations/events.d.ts +3 -3
  136. package/dist/integrations/ports.d.ts +9 -8
  137. package/dist/integrations/service.d.ts +9 -8
  138. package/dist/integrations/service.js +33 -16
  139. package/dist/integrations/service.js.map +1 -1
  140. package/dist/organizations/default-roles.d.ts +22 -0
  141. package/dist/organizations/default-roles.js +89 -0
  142. package/dist/organizations/default-roles.js.map +1 -0
  143. package/dist/organizations/effective-permissions.d.ts +45 -0
  144. package/dist/organizations/effective-permissions.js +113 -0
  145. package/dist/organizations/effective-permissions.js.map +1 -0
  146. package/dist/organizations/events.d.ts +320 -181
  147. package/dist/organizations/events.js +90 -18
  148. package/dist/organizations/events.js.map +1 -1
  149. package/dist/organizations/index.d.ts +14 -10
  150. package/dist/organizations/index.js +7 -3
  151. package/dist/organizations/members.d.ts +66 -8
  152. package/dist/organizations/members.js.map +1 -1
  153. package/dist/organizations/notification-catalog.d.ts +31 -0
  154. package/dist/organizations/notification-catalog.js +32 -0
  155. package/dist/organizations/notification-catalog.js.map +1 -0
  156. package/dist/organizations/notification-categories.d.ts +6 -4
  157. package/dist/organizations/notification-categories.js +25 -10
  158. package/dist/organizations/notification-categories.js.map +1 -1
  159. package/dist/organizations/org-roles.d.ts +33 -0
  160. package/dist/organizations/org-roles.js +49 -0
  161. package/dist/organizations/org-roles.js.map +1 -0
  162. package/dist/organizations/permissions.d.ts +311 -0
  163. package/dist/organizations/permissions.js +327 -0
  164. package/dist/organizations/permissions.js.map +1 -0
  165. package/dist/organizations/ports.d.ts +184 -65
  166. package/dist/organizations/service.d.ts +102 -35
  167. package/dist/organizations/service.js +1245 -328
  168. package/dist/organizations/service.js.map +1 -1
  169. package/dist/organizations/testing.d.ts +18 -0
  170. package/dist/organizations/testing.js +37 -0
  171. package/dist/organizations/testing.js.map +1 -0
  172. package/dist/organizations/types.d.ts +5 -16
  173. package/dist/progress/events.d.ts +14 -14
  174. package/dist/progress/index.d.ts +2 -2
  175. package/dist/progress/ports.d.ts +11 -3
  176. package/dist/progress/service.d.ts +6 -5
  177. package/dist/progress/service.js +23 -8
  178. package/dist/progress/service.js.map +1 -1
  179. package/dist/reporting/admin/index.d.ts +6 -4
  180. package/dist/reporting/admin/model.d.ts +36 -3
  181. package/dist/reporting/admin/ports.d.ts +39 -14
  182. package/dist/reporting/admin/service.d.ts +32 -11
  183. package/dist/reporting/admin/service.js +102 -18
  184. package/dist/reporting/admin/service.js.map +1 -1
  185. package/dist/reporting/events/index.d.ts +27 -0
  186. package/dist/reporting/events/index.js +20 -0
  187. package/dist/reporting/events/index.js.map +1 -0
  188. package/dist/reporting/member/calendar.d.ts +11 -0
  189. package/dist/reporting/member/calendar.js +75 -0
  190. package/dist/reporting/member/calendar.js.map +1 -0
  191. package/dist/reporting/member/index.d.ts +3 -2
  192. package/dist/reporting/member/model.d.ts +26 -5
  193. package/dist/reporting/member/ports.d.ts +48 -29
  194. package/dist/reporting/member/service.d.ts +56 -29
  195. package/dist/reporting/member/service.js +328 -113
  196. package/dist/reporting/member/service.js.map +1 -1
  197. package/dist/shared/actor.d.ts +22 -3
  198. package/dist/shared/errors.d.ts +2 -1
  199. package/dist/shared/errors.js +3 -1
  200. package/dist/shared/errors.js.map +1 -1
  201. package/dist/shared/id.d.ts +4 -0
  202. package/dist/shared/id.js +4 -0
  203. package/dist/shared/id.js.map +1 -1
  204. package/dist/shared/logger.d.ts +2 -1
  205. package/dist/shared/logger.js +10 -1
  206. package/dist/shared/logger.js.map +1 -1
  207. package/dist/shared/ports.d.ts +25 -5
  208. package/dist/types/content.d.ts +2 -2
  209. package/dist/types/discussion.d.ts +4 -5
  210. package/dist/types/email-templates.d.ts +22 -3
  211. package/dist/types/entitlements.d.ts +2 -2
  212. package/dist/types/identity.d.ts +13 -16
  213. package/dist/types/index.d.ts +9 -9
  214. package/dist/types/index.js +2 -1
  215. package/dist/types/notifications.d.ts +4 -4
  216. package/dist/types/organizations.d.ts +3 -2
  217. package/dist/types/ports.d.ts +8 -1
  218. package/dist/types/ports.js +7 -1
  219. package/dist/types/ports.js.map +1 -0
  220. package/dist/types/schemas/assets.d.ts +5 -5
  221. package/dist/types/schemas/assets.js +4 -3
  222. package/dist/types/schemas/assets.js.map +1 -1
  223. package/dist/types/schemas/content.d.ts +537 -13
  224. package/dist/types/schemas/content.js +201 -7
  225. package/dist/types/schemas/content.js.map +1 -1
  226. package/dist/types/schemas/discussion.d.ts +282 -59
  227. package/dist/types/schemas/discussion.js +77 -3
  228. package/dist/types/schemas/discussion.js.map +1 -1
  229. package/dist/types/schemas/entitlements.d.ts +14 -1
  230. package/dist/types/schemas/entitlements.js +11 -4
  231. package/dist/types/schemas/entitlements.js.map +1 -1
  232. package/dist/types/schemas/index.d.ts +5 -5
  233. package/dist/types/schemas/index.js +5 -5
  234. package/dist/types/schemas/notifications.d.ts +13 -12
  235. package/dist/types/schemas/notifications.js +3 -2
  236. package/dist/types/schemas/notifications.js.map +1 -1
  237. package/dist/types/schemas/organizations.d.ts +96 -60
  238. package/dist/types/schemas/organizations.js +78 -27
  239. package/dist/types/schemas/organizations.js.map +1 -1
  240. package/dist/types/schemas/progress.d.ts +3 -4
  241. package/dist/types/schemas/progress.js +0 -1
  242. package/dist/types/schemas/progress.js.map +1 -1
  243. package/package.json +1 -1
  244. package/dist/organizations/access-scopes.d.ts +0 -19
  245. package/dist/organizations/access-scopes.js +0 -89
  246. package/dist/organizations/access-scopes.js.map +0 -1
  247. package/dist/organizations/roles.d.ts +0 -19
  248. package/dist/organizations/roles.js +0 -82
  249. package/dist/organizations/roles.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { idSchema } from "../types/schemas/shared.js";
2
- import { activitySchema, bundleItemSchema, bundleSchema, communitySchema, courseSchema, downloadAssetSchema, downloadSchema, moduleSchema, spaceDetailSchema } from "../types/schemas/content.js";
2
+ import { activitySchema, bundleItemSchema, bundleSchema, communitySchema, courseSchema, downloadAssetSchema, downloadSchema, eventLeadSchema, eventSchema, moduleSchema, spaceDetailSchema } from "../types/schemas/content.js";
3
3
  import { defineEvent } from "../shared/events.js";
4
4
  import { z } from "zod";
5
5
  //#region src/content/events.ts
@@ -72,6 +72,15 @@ const publicDownloadAsset = downloadAssetSchema.pick({
72
72
  updatedAt: true
73
73
  }).strip();
74
74
  const publicCommunity = communitySchema.omit({ settings: true }).strip();
75
+ const publicEvent = eventSchema.omit({
76
+ location: true,
77
+ recording: true
78
+ }).strip();
79
+ const eventStartingSoonSchema = z.object({
80
+ eventId: idSchema,
81
+ lead: eventLeadSchema,
82
+ startsAt: z.coerce.date()
83
+ }).strict();
75
84
  const publicDownloadAssets = z.object({
76
85
  downloadId: idSchema,
77
86
  assets: z.array(publicDownloadAsset)
@@ -234,6 +243,30 @@ const contentEvents = {
234
243
  data: communitySchema,
235
244
  publicData: publicCommunity
236
245
  }),
246
+ eventCreated: defineEvent({
247
+ type: "content.event.created",
248
+ version: 1,
249
+ data: eventSchema,
250
+ publicData: publicEvent
251
+ }),
252
+ eventUpdated: defineEvent({
253
+ type: "content.event.updated",
254
+ version: 1,
255
+ data: eventSchema,
256
+ publicData: publicEvent
257
+ }),
258
+ eventDeleted: defineEvent({
259
+ type: "content.event.deleted",
260
+ version: 1,
261
+ data: eventSchema,
262
+ publicData: publicEvent
263
+ }),
264
+ eventStartingSoon: defineEvent({
265
+ type: "content.event.starting_soon",
266
+ version: 1,
267
+ data: eventStartingSoonSchema,
268
+ publicData: eventStartingSoonSchema
269
+ }),
237
270
  spaceCreated: defineEvent({
238
271
  type: "content.community.space.created",
239
272
  version: 1,
@@ -1 +1 @@
1
- {"version":3,"file":"events.js","names":[],"sources":["../../src/content/events.ts"],"sourcesContent":["import { z } from 'zod';\nimport {\n activitySchema,\n bundleItemSchema,\n bundleSchema,\n communitySchema,\n courseSchema,\n downloadAssetSchema,\n downloadSchema,\n idSchema,\n moduleSchema,\n spaceDetailSchema,\n} from '../types/schemas/index.js';\nimport { defineEvent, type EventOf, type EventOfValues } from '../shared/ports.js';\n\nconst activityPublishedSchema = z\n .object({ activityId: idSchema, moduleId: idSchema, courseId: idSchema })\n .strict();\n\nconst downloadAssetsEventSchema = z\n .object({\n downloadId: idSchema,\n assets: z.array(downloadAssetSchema),\n })\n .strict();\n\nconst bundleItemsEventSchema = z\n .object({\n bundleId: idSchema,\n items: z.array(bundleItemSchema),\n })\n .strict();\n\nconst publicCourse = courseSchema\n .pick({\n orgId: true,\n id: true,\n type: true,\n title: true,\n slug: true,\n description: true,\n status: true,\n category: true,\n thumbnailAssetId: true,\n settings: true,\n createdAt: true,\n updatedAt: true,\n })\n .strip();\n\nconst publicModule = moduleSchema\n .pick({\n orgId: true,\n id: true,\n courseId: true,\n title: true,\n seq: true,\n createdAt: true,\n updatedAt: true,\n })\n .strip();\n\nconst publicActivity = activitySchema\n .pick({\n orgId: true,\n id: true,\n moduleId: true,\n courseId: true,\n seq: true,\n createdAt: true,\n updatedAt: true,\n })\n .strip();\n\nconst publicDownload = downloadSchema\n .pick({\n orgId: true,\n id: true,\n type: true,\n title: true,\n slug: true,\n description: true,\n status: true,\n category: true,\n thumbnailAssetId: true,\n createdAt: true,\n updatedAt: true,\n })\n .strip();\n\nconst publicDownloadAsset = downloadAssetSchema\n .pick({\n orgId: true,\n id: true,\n downloadId: true,\n assetId: true,\n seq: true,\n displayName: true,\n createdAt: true,\n updatedAt: true,\n })\n .strip();\n\nconst publicCommunity = communitySchema.omit({ settings: true }).strip();\n\nconst publicDownloadAssets = z.object({\n downloadId: idSchema,\n assets: z.array(publicDownloadAsset),\n});\n\nexport const contentEvents = {\n courseCreated: defineEvent({\n type: 'content.course.created',\n version: 1,\n data: courseSchema,\n publicData: publicCourse,\n }),\n courseUpdated: defineEvent({\n type: 'content.course.updated',\n version: 1,\n data: courseSchema,\n publicData: publicCourse,\n }),\n courseDeleted: defineEvent({\n type: 'content.course.deleted',\n version: 1,\n data: courseSchema,\n publicData: publicCourse,\n }),\n moduleCreated: defineEvent({\n type: 'content.course.module.created',\n version: 1,\n data: moduleSchema,\n publicData: publicModule,\n }),\n moduleUpdated: defineEvent({\n type: 'content.course.module.updated',\n version: 1,\n data: moduleSchema,\n publicData: publicModule,\n }),\n moduleDeleted: defineEvent({\n type: 'content.course.module.deleted',\n version: 1,\n data: moduleSchema,\n publicData: publicModule,\n }),\n modulesReordered: defineEvent({\n type: 'content.course.modules.reordered',\n version: 1,\n data: z.array(moduleSchema),\n publicData: z.array(publicModule),\n }),\n activityCreated: defineEvent({\n type: 'content.course.activity.created',\n version: 1,\n data: activitySchema,\n publicData: publicActivity,\n }),\n activityUpdated: defineEvent({\n type: 'content.course.activity.updated',\n version: 1,\n data: activitySchema,\n publicData: publicActivity,\n }),\n activityDeleted: defineEvent({\n type: 'content.course.activity.deleted',\n version: 1,\n data: activitySchema,\n publicData: publicActivity,\n }),\n activityPublished: defineEvent({\n type: 'content.course.activity.published',\n version: 1,\n data: activityPublishedSchema,\n publicData: activityPublishedSchema,\n }),\n activitiesReordered: defineEvent({\n type: 'content.course.activities.reordered',\n version: 1,\n data: moduleSchema,\n publicData: publicModule,\n }),\n downloadCreated: defineEvent({\n type: 'content.download.created',\n version: 1,\n data: downloadSchema,\n publicData: publicDownload,\n }),\n downloadUpdated: defineEvent({\n type: 'content.download.updated',\n version: 1,\n data: downloadSchema,\n publicData: publicDownload,\n }),\n downloadDeleted: defineEvent({\n type: 'content.download.deleted',\n version: 1,\n data: downloadSchema,\n publicData: publicDownload,\n }),\n downloadAssetAdded: defineEvent({\n type: 'content.download.asset.added',\n version: 1,\n data: downloadAssetsEventSchema,\n publicData: publicDownloadAssets,\n }),\n downloadAssetRemoved: defineEvent({\n type: 'content.download.asset.removed',\n version: 1,\n data: downloadAssetsEventSchema,\n publicData: publicDownloadAssets,\n }),\n downloadAssetRenamed: defineEvent({\n type: 'content.download.asset.renamed',\n version: 1,\n data: downloadAssetsEventSchema,\n publicData: publicDownloadAssets,\n }),\n downloadAssetsReordered: defineEvent({\n type: 'content.download.assets.reordered',\n version: 1,\n data: downloadAssetsEventSchema,\n publicData: publicDownloadAssets,\n }),\n bundleCreated: defineEvent({\n type: 'content.bundle.created',\n version: 1,\n data: bundleSchema,\n }),\n bundleUpdated: defineEvent({\n type: 'content.bundle.updated',\n version: 1,\n data: bundleSchema,\n }),\n bundleDeleted: defineEvent({\n type: 'content.bundle.deleted',\n version: 1,\n data: bundleSchema,\n }),\n bundleItemAdded: defineEvent({\n type: 'content.bundle.item.added',\n version: 1,\n data: bundleItemsEventSchema,\n }),\n bundleItemRemoved: defineEvent({\n type: 'content.bundle.item.removed',\n version: 1,\n data: bundleItemsEventSchema,\n }),\n communityCreated: defineEvent({\n type: 'content.community.created',\n version: 1,\n data: communitySchema,\n publicData: publicCommunity,\n }),\n communityUpdated: defineEvent({\n type: 'content.community.updated',\n version: 1,\n data: communitySchema,\n publicData: publicCommunity,\n }),\n communityDeleted: defineEvent({\n type: 'content.community.deleted',\n version: 1,\n data: communitySchema,\n publicData: publicCommunity,\n }),\n spaceCreated: defineEvent({\n type: 'content.community.space.created',\n version: 1,\n data: spaceDetailSchema,\n publicData: spaceDetailSchema,\n }),\n spaceUpdated: defineEvent({\n type: 'content.community.space.updated',\n version: 1,\n data: spaceDetailSchema,\n publicData: spaceDetailSchema,\n }),\n spaceDeleted: defineEvent({\n type: 'content.community.space.deleted',\n version: 1,\n data: spaceDetailSchema,\n publicData: spaceDetailSchema,\n }),\n spacesReordered: defineEvent({\n type: 'content.community.spaces.reordered',\n version: 1,\n data: z.array(spaceDetailSchema),\n publicData: z.array(spaceDetailSchema),\n }),\n};\n\nexport type CourseCreated = EventOf<typeof contentEvents.courseCreated>;\nexport type CourseUpdated = EventOf<typeof contentEvents.courseUpdated>;\nexport type CourseDeleted = EventOf<typeof contentEvents.courseDeleted>;\nexport type CourseModuleCreated = EventOf<typeof contentEvents.moduleCreated>;\nexport type CourseModuleUpdated = EventOf<typeof contentEvents.moduleUpdated>;\nexport type CourseModuleDeleted = EventOf<typeof contentEvents.moduleDeleted>;\nexport type CourseModulesReordered = EventOf<typeof contentEvents.modulesReordered>;\nexport type CourseActivityCreated = EventOf<typeof contentEvents.activityCreated>;\nexport type CourseActivityUpdated = EventOf<typeof contentEvents.activityUpdated>;\nexport type CourseActivityDeleted = EventOf<typeof contentEvents.activityDeleted>;\nexport type CourseActivityPublished = EventOf<typeof contentEvents.activityPublished>;\nexport type CourseActivitiesReordered = EventOf<typeof contentEvents.activitiesReordered>;\nexport type DownloadCreated = EventOf<typeof contentEvents.downloadCreated>;\nexport type DownloadUpdated = EventOf<typeof contentEvents.downloadUpdated>;\nexport type DownloadDeleted = EventOf<typeof contentEvents.downloadDeleted>;\nexport type DownloadAssetAdded = EventOf<typeof contentEvents.downloadAssetAdded>;\nexport type DownloadAssetRemoved = EventOf<typeof contentEvents.downloadAssetRemoved>;\nexport type DownloadAssetRenamed = EventOf<typeof contentEvents.downloadAssetRenamed>;\nexport type DownloadAssetsReordered = EventOf<typeof contentEvents.downloadAssetsReordered>;\nexport type BundleCreated = EventOf<typeof contentEvents.bundleCreated>;\nexport type BundleUpdated = EventOf<typeof contentEvents.bundleUpdated>;\nexport type BundleDeleted = EventOf<typeof contentEvents.bundleDeleted>;\nexport type BundleItemAdded = EventOf<typeof contentEvents.bundleItemAdded>;\nexport type BundleItemRemoved = EventOf<typeof contentEvents.bundleItemRemoved>;\nexport type CommunityCreated = EventOf<typeof contentEvents.communityCreated>;\nexport type CommunityUpdated = EventOf<typeof contentEvents.communityUpdated>;\nexport type CommunityDeleted = EventOf<typeof contentEvents.communityDeleted>;\nexport type CommunitySpaceCreated = EventOf<typeof contentEvents.spaceCreated>;\nexport type CommunitySpaceUpdated = EventOf<typeof contentEvents.spaceUpdated>;\nexport type CommunitySpaceDeleted = EventOf<typeof contentEvents.spaceDeleted>;\nexport type CommunitySpacesReordered = EventOf<typeof contentEvents.spacesReordered>;\nexport type ContentEvent = EventOfValues<typeof contentEvents>;\n"],"mappings":";;;;;AAeA,MAAM,0BAA0B,EAC7B,OAAO;CAAE,YAAY;CAAU,UAAU;CAAU,UAAU;AAAS,CAAC,CAAC,CACxE,OAAO;AAEV,MAAM,4BAA4B,EAC/B,OAAO;CACN,YAAY;CACZ,QAAQ,EAAE,MAAM,mBAAmB;AACrC,CAAC,CAAC,CACD,OAAO;AAEV,MAAM,yBAAyB,EAC5B,OAAO;CACN,UAAU;CACV,OAAO,EAAE,MAAM,gBAAgB;AACjC,CAAC,CAAC,CACD,OAAO;AAEV,MAAM,eAAe,aAClB,KAAK;CACJ,OAAO;CACP,IAAI;CACJ,MAAM;CACN,OAAO;CACP,MAAM;CACN,aAAa;CACb,QAAQ;CACR,UAAU;CACV,kBAAkB;CAClB,UAAU;CACV,WAAW;CACX,WAAW;AACb,CAAC,CAAC,CACD,MAAM;AAET,MAAM,eAAe,aAClB,KAAK;CACJ,OAAO;CACP,IAAI;CACJ,UAAU;CACV,OAAO;CACP,KAAK;CACL,WAAW;CACX,WAAW;AACb,CAAC,CAAC,CACD,MAAM;AAET,MAAM,iBAAiB,eACpB,KAAK;CACJ,OAAO;CACP,IAAI;CACJ,UAAU;CACV,UAAU;CACV,KAAK;CACL,WAAW;CACX,WAAW;AACb,CAAC,CAAC,CACD,MAAM;AAET,MAAM,iBAAiB,eACpB,KAAK;CACJ,OAAO;CACP,IAAI;CACJ,MAAM;CACN,OAAO;CACP,MAAM;CACN,aAAa;CACb,QAAQ;CACR,UAAU;CACV,kBAAkB;CAClB,WAAW;CACX,WAAW;AACb,CAAC,CAAC,CACD,MAAM;AAET,MAAM,sBAAsB,oBAC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Ac,YAAY;EACxB,MAAM;EACN,SAAS;EACT,MAAM;EACN,YAAY;CACd,CAAC;CACD,iBAAiB,YAAY;EAC3B,MAAM;EACN,SAAS;EACT,MAAM,EAAE,MAAM,iBAAiB;EAC/B,YAAY,EAAE,MAAM,iBAAiB;CACvC,CAAC;AACH"}
1
+ {"version":3,"file":"events.js","names":[],"sources":["../../src/content/events.ts"],"sourcesContent":["import { z } from 'zod';\nimport {\n activitySchema,\n bundleItemSchema,\n bundleSchema,\n communitySchema,\n courseSchema,\n downloadAssetSchema,\n downloadSchema,\n eventLeadSchema,\n eventSchema,\n idSchema,\n moduleSchema,\n spaceDetailSchema,\n} from '../types/schemas/index.js';\nimport { defineEvent, type EventOf, type EventOfValues } from '../shared/ports.js';\n\nconst activityPublishedSchema = z\n .object({ activityId: idSchema, moduleId: idSchema, courseId: idSchema })\n .strict();\n\nconst downloadAssetsEventSchema = z\n .object({\n downloadId: idSchema,\n assets: z.array(downloadAssetSchema),\n })\n .strict();\n\nconst bundleItemsEventSchema = z\n .object({\n bundleId: idSchema,\n items: z.array(bundleItemSchema),\n })\n .strict();\n\nconst publicCourse = courseSchema\n .pick({\n orgId: true,\n id: true,\n type: true,\n title: true,\n slug: true,\n description: true,\n status: true,\n category: true,\n thumbnailAssetId: true,\n settings: true,\n createdAt: true,\n updatedAt: true,\n })\n .strip();\n\nconst publicModule = moduleSchema\n .pick({\n orgId: true,\n id: true,\n courseId: true,\n title: true,\n seq: true,\n createdAt: true,\n updatedAt: true,\n })\n .strip();\n\nconst publicActivity = activitySchema\n .pick({\n orgId: true,\n id: true,\n moduleId: true,\n courseId: true,\n seq: true,\n createdAt: true,\n updatedAt: true,\n })\n .strip();\n\nconst publicDownload = downloadSchema\n .pick({\n orgId: true,\n id: true,\n type: true,\n title: true,\n slug: true,\n description: true,\n status: true,\n category: true,\n thumbnailAssetId: true,\n createdAt: true,\n updatedAt: true,\n })\n .strip();\n\nconst publicDownloadAsset = downloadAssetSchema\n .pick({\n orgId: true,\n id: true,\n downloadId: true,\n assetId: true,\n seq: true,\n displayName: true,\n createdAt: true,\n updatedAt: true,\n })\n .strip();\n\nconst publicCommunity = communitySchema.omit({ settings: true }).strip();\n\nconst publicEvent = eventSchema.omit({ location: true, recording: true }).strip();\n\nconst eventStartingSoonSchema = z\n .object({ eventId: idSchema, lead: eventLeadSchema, startsAt: z.coerce.date() })\n .strict();\n\nconst publicDownloadAssets = z.object({\n downloadId: idSchema,\n assets: z.array(publicDownloadAsset),\n});\n\nexport const contentEvents = {\n courseCreated: defineEvent({\n type: 'content.course.created',\n version: 1,\n data: courseSchema,\n publicData: publicCourse,\n }),\n courseUpdated: defineEvent({\n type: 'content.course.updated',\n version: 1,\n data: courseSchema,\n publicData: publicCourse,\n }),\n courseDeleted: defineEvent({\n type: 'content.course.deleted',\n version: 1,\n data: courseSchema,\n publicData: publicCourse,\n }),\n moduleCreated: defineEvent({\n type: 'content.course.module.created',\n version: 1,\n data: moduleSchema,\n publicData: publicModule,\n }),\n moduleUpdated: defineEvent({\n type: 'content.course.module.updated',\n version: 1,\n data: moduleSchema,\n publicData: publicModule,\n }),\n moduleDeleted: defineEvent({\n type: 'content.course.module.deleted',\n version: 1,\n data: moduleSchema,\n publicData: publicModule,\n }),\n modulesReordered: defineEvent({\n type: 'content.course.modules.reordered',\n version: 1,\n data: z.array(moduleSchema),\n publicData: z.array(publicModule),\n }),\n activityCreated: defineEvent({\n type: 'content.course.activity.created',\n version: 1,\n data: activitySchema,\n publicData: publicActivity,\n }),\n activityUpdated: defineEvent({\n type: 'content.course.activity.updated',\n version: 1,\n data: activitySchema,\n publicData: publicActivity,\n }),\n activityDeleted: defineEvent({\n type: 'content.course.activity.deleted',\n version: 1,\n data: activitySchema,\n publicData: publicActivity,\n }),\n activityPublished: defineEvent({\n type: 'content.course.activity.published',\n version: 1,\n data: activityPublishedSchema,\n publicData: activityPublishedSchema,\n }),\n activitiesReordered: defineEvent({\n type: 'content.course.activities.reordered',\n version: 1,\n data: moduleSchema,\n publicData: publicModule,\n }),\n downloadCreated: defineEvent({\n type: 'content.download.created',\n version: 1,\n data: downloadSchema,\n publicData: publicDownload,\n }),\n downloadUpdated: defineEvent({\n type: 'content.download.updated',\n version: 1,\n data: downloadSchema,\n publicData: publicDownload,\n }),\n downloadDeleted: defineEvent({\n type: 'content.download.deleted',\n version: 1,\n data: downloadSchema,\n publicData: publicDownload,\n }),\n downloadAssetAdded: defineEvent({\n type: 'content.download.asset.added',\n version: 1,\n data: downloadAssetsEventSchema,\n publicData: publicDownloadAssets,\n }),\n downloadAssetRemoved: defineEvent({\n type: 'content.download.asset.removed',\n version: 1,\n data: downloadAssetsEventSchema,\n publicData: publicDownloadAssets,\n }),\n downloadAssetRenamed: defineEvent({\n type: 'content.download.asset.renamed',\n version: 1,\n data: downloadAssetsEventSchema,\n publicData: publicDownloadAssets,\n }),\n downloadAssetsReordered: defineEvent({\n type: 'content.download.assets.reordered',\n version: 1,\n data: downloadAssetsEventSchema,\n publicData: publicDownloadAssets,\n }),\n bundleCreated: defineEvent({\n type: 'content.bundle.created',\n version: 1,\n data: bundleSchema,\n }),\n bundleUpdated: defineEvent({\n type: 'content.bundle.updated',\n version: 1,\n data: bundleSchema,\n }),\n bundleDeleted: defineEvent({\n type: 'content.bundle.deleted',\n version: 1,\n data: bundleSchema,\n }),\n bundleItemAdded: defineEvent({\n type: 'content.bundle.item.added',\n version: 1,\n data: bundleItemsEventSchema,\n }),\n bundleItemRemoved: defineEvent({\n type: 'content.bundle.item.removed',\n version: 1,\n data: bundleItemsEventSchema,\n }),\n communityCreated: defineEvent({\n type: 'content.community.created',\n version: 1,\n data: communitySchema,\n publicData: publicCommunity,\n }),\n communityUpdated: defineEvent({\n type: 'content.community.updated',\n version: 1,\n data: communitySchema,\n publicData: publicCommunity,\n }),\n communityDeleted: defineEvent({\n type: 'content.community.deleted',\n version: 1,\n data: communitySchema,\n publicData: publicCommunity,\n }),\n eventCreated: defineEvent({\n type: 'content.event.created',\n version: 1,\n data: eventSchema,\n publicData: publicEvent,\n }),\n eventUpdated: defineEvent({\n type: 'content.event.updated',\n version: 1,\n data: eventSchema,\n publicData: publicEvent,\n }),\n eventDeleted: defineEvent({\n type: 'content.event.deleted',\n version: 1,\n data: eventSchema,\n publicData: publicEvent,\n }),\n eventStartingSoon: defineEvent({\n type: 'content.event.starting_soon',\n version: 1,\n data: eventStartingSoonSchema,\n publicData: eventStartingSoonSchema,\n }),\n spaceCreated: defineEvent({\n type: 'content.community.space.created',\n version: 1,\n data: spaceDetailSchema,\n publicData: spaceDetailSchema,\n }),\n spaceUpdated: defineEvent({\n type: 'content.community.space.updated',\n version: 1,\n data: spaceDetailSchema,\n publicData: spaceDetailSchema,\n }),\n spaceDeleted: defineEvent({\n type: 'content.community.space.deleted',\n version: 1,\n data: spaceDetailSchema,\n publicData: spaceDetailSchema,\n }),\n spacesReordered: defineEvent({\n type: 'content.community.spaces.reordered',\n version: 1,\n data: z.array(spaceDetailSchema),\n publicData: z.array(spaceDetailSchema),\n }),\n};\n\nexport type CourseCreated = EventOf<typeof contentEvents.courseCreated>;\nexport type CourseUpdated = EventOf<typeof contentEvents.courseUpdated>;\nexport type CourseDeleted = EventOf<typeof contentEvents.courseDeleted>;\nexport type CourseModuleCreated = EventOf<typeof contentEvents.moduleCreated>;\nexport type CourseModuleUpdated = EventOf<typeof contentEvents.moduleUpdated>;\nexport type CourseModuleDeleted = EventOf<typeof contentEvents.moduleDeleted>;\nexport type CourseModulesReordered = EventOf<typeof contentEvents.modulesReordered>;\nexport type CourseActivityCreated = EventOf<typeof contentEvents.activityCreated>;\nexport type CourseActivityUpdated = EventOf<typeof contentEvents.activityUpdated>;\nexport type CourseActivityDeleted = EventOf<typeof contentEvents.activityDeleted>;\nexport type CourseActivityPublished = EventOf<typeof contentEvents.activityPublished>;\nexport type CourseActivitiesReordered = EventOf<typeof contentEvents.activitiesReordered>;\nexport type DownloadCreated = EventOf<typeof contentEvents.downloadCreated>;\nexport type DownloadUpdated = EventOf<typeof contentEvents.downloadUpdated>;\nexport type DownloadDeleted = EventOf<typeof contentEvents.downloadDeleted>;\nexport type DownloadAssetAdded = EventOf<typeof contentEvents.downloadAssetAdded>;\nexport type DownloadAssetRemoved = EventOf<typeof contentEvents.downloadAssetRemoved>;\nexport type DownloadAssetRenamed = EventOf<typeof contentEvents.downloadAssetRenamed>;\nexport type DownloadAssetsReordered = EventOf<typeof contentEvents.downloadAssetsReordered>;\nexport type BundleCreated = EventOf<typeof contentEvents.bundleCreated>;\nexport type BundleUpdated = EventOf<typeof contentEvents.bundleUpdated>;\nexport type BundleDeleted = EventOf<typeof contentEvents.bundleDeleted>;\nexport type BundleItemAdded = EventOf<typeof contentEvents.bundleItemAdded>;\nexport type BundleItemRemoved = EventOf<typeof contentEvents.bundleItemRemoved>;\nexport type CommunityCreated = EventOf<typeof contentEvents.communityCreated>;\nexport type CommunityUpdated = EventOf<typeof contentEvents.communityUpdated>;\nexport type CommunityDeleted = EventOf<typeof contentEvents.communityDeleted>;\nexport type EventCreated = EventOf<typeof contentEvents.eventCreated>;\nexport type EventUpdated = EventOf<typeof contentEvents.eventUpdated>;\nexport type EventDeleted = EventOf<typeof contentEvents.eventDeleted>;\nexport type EventStartingSoon = EventOf<typeof contentEvents.eventStartingSoon>;\nexport type CommunitySpaceCreated = EventOf<typeof contentEvents.spaceCreated>;\nexport type CommunitySpaceUpdated = EventOf<typeof contentEvents.spaceUpdated>;\nexport type CommunitySpaceDeleted = EventOf<typeof contentEvents.spaceDeleted>;\nexport type CommunitySpacesReordered = EventOf<typeof contentEvents.spacesReordered>;\nexport type ContentEvent = EventOfValues<typeof contentEvents>;\n"],"mappings":";;;;;AAiBA,MAAM,0BAA0B,EAC7B,OAAO;CAAE,YAAY;CAAU,UAAU;CAAU,UAAU;AAAS,CAAC,CAAC,CACxE,OAAO;AAEV,MAAM,4BAA4B,EAC/B,OAAO;CACN,YAAY;CACZ,QAAQ,EAAE,MAAM,mBAAmB;AACrC,CAAC,CAAC,CACD,OAA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N,SAAS;EACT,MAAM;EACN,YAAY;CACd,CAAC;CACD,cAAc,YAAY;EACxB,MAAM;EACN,SAAS;EACT,MAAM;EACN,YAAY;CACd,CAAC;CACD,iBAAiB,YAAY;EAC3B,MAAM;EACN,SAAS;EACT,MAAM,EAAE,MAAM,iBAAiB;EAC/B,YAAY,EAAE,MAAM,iBAAiB;CACvC,CAAC;AACH"}
@@ -1,10 +1,12 @@
1
1
  import { Page } from "../types/shared.js";
2
- import { Activity, ActivityAsset, ActivityView, AddDownloadAssetInput, Bundle, BundleItem, Community, CommunityStatus, CommunityView, Course, CourseSettings, CourseStatus, CourseView, CreateBundleInput, CreateCommunityInput, CreateCourseInput, CreateDownloadInput, CreateSpaceInput, DigestSchedule, DmSettings, Download, DownloadAsset, DownloadFile, DownloadStatus, DownloadView, ListBundlesQuery, ListCommunitiesQuery, ListCoursesQuery, ListDownloadsQuery, Module, PatchCommunitySettingsInput, PatchDmSettingsInput, ReorderDownloadAssetsInput, SaveActivityInput, SetSpaceTopicsInput, Space, SpaceAccessRule, SpaceDetail, SpaceLink, SpaceTopic, UpdateBundleInput, UpdateCommunityInput, UpdateCourseInput, UpdateDownloadInput, UpdateSpaceInput } from "../types/schemas/content.js";
2
+ import { Activity, ActivityAsset, ActivityView, AddDownloadAssetInput, AddEventAssetInput, Bundle, BundleItem, Community, CommunityStatus, CommunityView, Course, CourseSettings, CourseStatus, CourseView, CreateBundleInput, CreateCommunityInput, CreateCourseInput, CreateDownloadInput, CreateEventInput, CreateSpaceInput, DigestSchedule, DmSettings, Download, DownloadAsset, DownloadFile, DownloadStatus, DownloadView, Event, EventAsset, EventFile, EventLead, EventLocation, EventRecording, EventSettings, EventStatus, EventType, EventView, ListBundlesQuery, ListCommunitiesQuery, ListCoursesQuery, ListDownloadsQuery, ListEventsQuery, Module, PatchCommunitySettingsInput, PatchDmSettingsInput, ReorderDownloadAssetsInput, ReorderEventAssetsInput, SaveActivityInput, SetSpaceTopicsInput, Space, SpaceAccessRule, SpaceDetail, SpaceLink, SpaceTopic, UpdateBundleInput, UpdateCommunityInput, UpdateCourseInput, UpdateDownloadInput, UpdateEventInput, UpdateSpaceInput } from "../types/schemas/content.js";
3
3
  import "./model.js";
4
4
  import "./types.js";
5
- import { BundlesService, CommunitiesService, CommunityDigest, CommunityReader, ContentRepository, ContentService as ContentService$1, CourseManagementService, DownloadablesService, ItemTitle, ItemTitleAccess, ItemTitles, SpaceRowLock } from "./ports.js";
5
+ import { BundlesService, CommunitiesService, CommunityDigest, CommunityReader, ContentAssetReader, ContentRepository, ContentService as ContentService$1, CourseManagementService, DownloadablesService, EventPatch, EventsService, ItemTitle, ItemTitleAccess, ItemTitles, LibraryAssetRef, SpaceRowLock } from "./ports.js";
6
6
  import { ContentService } from "./service.js";
7
7
  import { CommunityNotificationCategories } from "./notification-categories.js";
8
8
  import { ContentItemTitles, activityTitle } from "./titles.js";
9
- import { BundleCreated, BundleDeleted, BundleItemAdded, BundleItemRemoved, BundleUpdated, CommunityCreated, CommunityDeleted, CommunitySpaceCreated, CommunitySpaceDeleted, CommunitySpaceUpdated, CommunitySpacesReordered, CommunityUpdated, ContentEvent, CourseActivitiesReordered, CourseActivityCreated, CourseActivityDeleted, CourseActivityPublished, CourseActivityUpdated, CourseCreated, CourseDeleted, CourseModuleCreated, CourseModuleDeleted, CourseModuleUpdated, CourseModulesReordered, CourseUpdated, DownloadCreated, DownloadDeleted, DownloadUpdated, contentEvents } from "./events.js";
10
- export { type Activity, type ActivityAsset, type ActivityView, type AddDownloadAssetInput, type Bundle, type BundleCreated, type BundleDeleted, type BundleItem, type BundleItemAdded, type BundleItemRemoved, type BundleUpdated, type BundlesService, type CommunitiesService, type Community, type CommunityCreated, type CommunityDeleted, type CommunityDigest, CommunityNotificationCategories, type CommunityReader, type CommunitySpaceCreated, type CommunitySpaceDeleted, type CommunitySpaceUpdated, type CommunitySpacesReordered, type CommunityStatus, type CommunityUpdated, type CommunityView, type ContentEvent, ContentItemTitles, type ContentRepository, ContentService, type ContentService$1 as ContentServicePort, type Course, type CourseActivitiesReordered, type CourseActivityCreated, type CourseActivityDeleted, type CourseActivityPublished, type CourseActivityUpdated, type CourseCreated, type CourseDeleted, type CourseManagementService, type CourseModuleCreated, type CourseModuleDeleted, type CourseModuleUpdated, type CourseModulesReordered, type CourseSettings, type CourseStatus, type CourseUpdated, type CourseView, type CreateBundleInput, type CreateCommunityInput, type CreateCourseInput, type CreateDownloadInput, type CreateSpaceInput, type DigestSchedule, type DmSettings, type Download, type DownloadAsset, type DownloadCreated, type DownloadDeleted, type DownloadFile, type DownloadStatus, type DownloadUpdated, type DownloadView, type DownloadablesService, type ItemTitle, type ItemTitleAccess, type ItemTitles, type ListBundlesQuery, type ListCommunitiesQuery, type ListCoursesQuery, type ListDownloadsQuery, type Module, type Page, type PatchCommunitySettingsInput, type PatchDmSettingsInput, type ReorderDownloadAssetsInput, type SaveActivityInput, type SetSpaceTopicsInput, type Space, type SpaceAccessRule, type SpaceDetail, type SpaceLink, type SpaceRowLock, type SpaceTopic, type UpdateBundleInput, type UpdateCommunityInput, type UpdateCourseInput, type UpdateDownloadInput, type UpdateSpaceInput, activityTitle, contentEvents };
9
+ import { EventSight, eventSight } from "./event-sight.js";
10
+ import { EVENT_LEADS, EVENT_STARTING_SOON_JOB, contentJobs } from "./jobs.js";
11
+ import { BundleCreated, BundleDeleted, BundleItemAdded, BundleItemRemoved, BundleUpdated, CommunityCreated, CommunityDeleted, CommunitySpaceCreated, CommunitySpaceDeleted, CommunitySpaceUpdated, CommunitySpacesReordered, CommunityUpdated, ContentEvent, CourseActivitiesReordered, CourseActivityCreated, CourseActivityDeleted, CourseActivityPublished, CourseActivityUpdated, CourseCreated, CourseDeleted, CourseModuleCreated, CourseModuleDeleted, CourseModuleUpdated, CourseModulesReordered, CourseUpdated, DownloadCreated, DownloadDeleted, DownloadUpdated, EventCreated, EventDeleted, EventStartingSoon, EventUpdated, contentEvents } from "./events.js";
12
+ export { type Activity, type ActivityAsset, type ActivityView, type AddDownloadAssetInput, type AddEventAssetInput, type Bundle, type BundleCreated, type BundleDeleted, type BundleItem, type BundleItemAdded, type BundleItemRemoved, type BundleUpdated, type BundlesService, type CommunitiesService, type Community, type CommunityCreated, type CommunityDeleted, type CommunityDigest, CommunityNotificationCategories, type CommunityReader, type CommunitySpaceCreated, type CommunitySpaceDeleted, type CommunitySpaceUpdated, type CommunitySpacesReordered, type CommunityStatus, type CommunityUpdated, type CommunityView, type ContentAssetReader, type ContentEvent, ContentItemTitles, type ContentRepository, ContentService, type ContentService$1 as ContentServicePort, type Course, type CourseActivitiesReordered, type CourseActivityCreated, type CourseActivityDeleted, type CourseActivityPublished, type CourseActivityUpdated, type CourseCreated, type CourseDeleted, type CourseManagementService, type CourseModuleCreated, type CourseModuleDeleted, type CourseModuleUpdated, type CourseModulesReordered, type CourseSettings, type CourseStatus, type CourseUpdated, type CourseView, type CreateBundleInput, type CreateCommunityInput, type CreateCourseInput, type CreateDownloadInput, type CreateEventInput, type CreateSpaceInput, type DigestSchedule, type DmSettings, type Download, type DownloadAsset, type DownloadCreated, type DownloadDeleted, type DownloadFile, type DownloadStatus, type DownloadUpdated, type DownloadView, type DownloadablesService, EVENT_LEADS, EVENT_STARTING_SOON_JOB, type Event, type EventAsset, type EventCreated, type EventDeleted, type EventFile, type EventLead, type EventLocation, type EventPatch, type EventRecording, type EventSettings, type EventSight, type EventStartingSoon, type EventStatus, type EventType, type EventUpdated, type EventView, type EventsService, type ItemTitle, type ItemTitleAccess, type ItemTitles, type LibraryAssetRef, type ListBundlesQuery, type ListCommunitiesQuery, type ListCoursesQuery, type ListDownloadsQuery, type ListEventsQuery, type Module, type Page, type PatchCommunitySettingsInput, type PatchDmSettingsInput, type ReorderDownloadAssetsInput, type ReorderEventAssetsInput, type SaveActivityInput, type SetSpaceTopicsInput, type Space, type SpaceAccessRule, type SpaceDetail, type SpaceLink, type SpaceRowLock, type SpaceTopic, type UpdateBundleInput, type UpdateCommunityInput, type UpdateCourseInput, type UpdateDownloadInput, type UpdateEventInput, type UpdateSpaceInput, activityTitle, contentEvents, contentJobs, eventSight };
@@ -1,5 +1,7 @@
1
1
  import { contentEvents } from "./events.js";
2
+ import { EVENT_LEADS, EVENT_STARTING_SOON_JOB, contentJobs } from "./jobs.js";
2
3
  import { ContentService } from "./service.js";
3
4
  import { CommunityNotificationCategories } from "./notification-categories.js";
5
+ import { eventSight } from "./event-sight.js";
4
6
  import { ContentItemTitles, activityTitle } from "./titles.js";
5
- export { CommunityNotificationCategories, ContentItemTitles, ContentService, activityTitle, contentEvents };
7
+ export { CommunityNotificationCategories, ContentItemTitles, ContentService, EVENT_LEADS, EVENT_STARTING_SOON_JOB, activityTitle, contentEvents, contentJobs, eventSight };
@@ -0,0 +1,16 @@
1
+ import { Logger } from "../types/ports.js";
2
+ import { EventLead } from "../types/schemas/content.js";
3
+ import "../types/index.js";
4
+ import { ScheduledJob } from "../shared/ports.js";
5
+ import { EventsService } from "./ports.js";
6
+ //#region src/content/jobs.d.ts
7
+ declare const EVENT_STARTING_SOON_JOB = "content.events.starting_soon";
8
+ declare const EVENT_LEADS: Readonly<Record<EventLead, number>>;
9
+ interface ContentJobDeps {
10
+ events: Pick<EventsService, 'startingSoon'>;
11
+ logger?: Logger;
12
+ }
13
+ declare function contentJobs(deps: ContentJobDeps): ScheduledJob[];
14
+ //#endregion
15
+ export { ContentJobDeps, EVENT_LEADS, EVENT_STARTING_SOON_JOB, contentJobs };
16
+ //# sourceMappingURL=jobs.d.ts.map
@@ -0,0 +1,37 @@
1
+ import { idSchema } from "../types/schemas/shared.js";
2
+ import { eventLeadSchema } from "../types/schemas/content.js";
3
+ import { noopLogger } from "../shared/logger.js";
4
+ import { z } from "zod";
5
+ //#region src/content/jobs.ts
6
+ const EVENT_STARTING_SOON_JOB = "content.events.starting_soon";
7
+ const EVENT_LEADS = {
8
+ "1d": 1440 * 60 * 1e3,
9
+ "1h": 3600 * 1e3
10
+ };
11
+ const startingSoonPayload = z.object({
12
+ orgId: idSchema,
13
+ eventId: idSchema,
14
+ lead: eventLeadSchema
15
+ }).strict();
16
+ function contentJobs(deps) {
17
+ const logger = deps.logger ?? noopLogger;
18
+ return [{
19
+ job: EVENT_STARTING_SOON_JOB,
20
+ async run(payload, fire) {
21
+ const parsed = startingSoonPayload.safeParse(payload);
22
+ if (!parsed.success) {
23
+ logger.error("event starting soon payload refused", {
24
+ job: EVENT_STARTING_SOON_JOB,
25
+ fireId: fire.id
26
+ });
27
+ return;
28
+ }
29
+ const { orgId, eventId, lead } = parsed.data;
30
+ await deps.events.startingSoon(orgId, eventId, lead, fire.startedAt);
31
+ }
32
+ }];
33
+ }
34
+ //#endregion
35
+ export { EVENT_LEADS, EVENT_STARTING_SOON_JOB, contentJobs };
36
+
37
+ //# sourceMappingURL=jobs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jobs.js","names":[],"sources":["../../src/content/jobs.ts"],"sourcesContent":["import { z } from 'zod';\nimport { eventLeadSchema, idSchema } from '../types/schemas/index.js';\nimport type { EventLead } from '../types/index.js';\nimport type { Logger, ScheduledJob } from '../shared/ports.js';\nimport { noopLogger } from '../shared/logger.js';\nimport type { EventsService } from './ports.js';\n\nexport const EVENT_STARTING_SOON_JOB = 'content.events.starting_soon';\n\nexport const EVENT_LEADS: Readonly<Record<EventLead, number>> = {\n '1d': 24 * 60 * 60 * 1000,\n '1h': 60 * 60 * 1000,\n};\n\nconst startingSoonPayload = z\n .object({ orgId: idSchema, eventId: idSchema, lead: eventLeadSchema })\n .strict();\n\nexport interface ContentJobDeps {\n events: Pick<EventsService, 'startingSoon'>;\n logger?: Logger;\n}\n\nexport function contentJobs(deps: ContentJobDeps): ScheduledJob[] {\n const logger = deps.logger ?? noopLogger;\n return [\n {\n job: EVENT_STARTING_SOON_JOB,\n async run(payload, fire) {\n const parsed = startingSoonPayload.safeParse(payload);\n if (!parsed.success) {\n logger.error('event starting soon payload refused', {\n job: EVENT_STARTING_SOON_JOB,\n fireId: fire.id,\n });\n return;\n }\n const { orgId, eventId, lead } = parsed.data;\n await deps.events.startingSoon(orgId, eventId, lead, fire.startedAt);\n },\n },\n ];\n}\n"],"mappings":";;;;;AAOA,MAAa,0BAA0B;AAEvC,MAAa,cAAmD;CAC9D,MAAM,OAAU,KAAK;CACrB,MAAM,OAAU;AAClB;AAEA,MAAM,sBAAsB,EACzB,OAAO;CAAE,OAAO;CAAU,SAAS;CAAU,MAAM;AAAgB,CAAC,CAAC,CACrE,OAAO;AAOV,SAAgB,YAAY,MAAsC;CAChE,MAAM,SAAS,KAAK,UAAU;CAC9B,OAAO,CACL;EACE,KAAK;EACL,MAAM,IAAI,SAAS,MAAM;GACvB,MAAM,SAAS,oBAAoB,UAAU,OAAO;GACpD,IAAI,CAAC,OAAO,SAAS;IACnB,OAAO,MAAM,uCAAuC;KAClD,KAAK;KACL,QAAQ,KAAK;IACf,CAAC;IACD;GACF;GACA,MAAM,EAAE,OAAO,SAAS,SAAS,OAAO;GACxC,MAAM,KAAK,OAAO,aAAa,OAAO,SAAS,MAAM,KAAK,SAAS;EACrE;CACF,CACF;AACF"}
@@ -1,3 +1,3 @@
1
- import { Activity, ActivityAsset, ActivitySettings, ActivityView, Bundle, BundleItem, Community, CommunitySettings, CommunityStatus, CommunityView, ContentItem, ContentType, Course, CourseSettings, CourseStatus, CourseView, DigestSchedule, DmSettings, Download, DownloadAsset, DownloadFile, DownloadStatus, DownloadView, Module, SaveActivityInput, Space, SpaceAccessRule, SpaceDetail, SpaceLink, SpaceSettings, SpaceTopic } from "../types/schemas/content.js";
1
+ import { Activity, ActivityAsset, ActivitySettings, ActivityView, Bundle, BundleItem, Community, CommunitySettings, CommunityStatus, CommunityView, ContentItem, ContentType, Course, CourseSettings, CourseStatus, CourseView, DigestSchedule, DmSettings, Download, DownloadAsset, DownloadFile, DownloadStatus, DownloadView, Event, EventAsset, EventFile, EventLead, EventLocation, EventRecording, EventSettings, EventStatus, EventType, EventView, Module, SaveActivityInput, Space, SpaceAccessRule, SpaceDetail, SpaceLink, SpaceSettings, SpaceTopic } from "../types/schemas/content.js";
2
2
  import "../types/index.js";
3
- export type { Activity, ActivityAsset, ActivitySettings, ActivityView, Bundle, BundleItem, Community, CommunitySettings, CommunityStatus, CommunityView, ContentItem, ContentType, Course, CourseSettings, CourseStatus, CourseView, DigestSchedule, DmSettings, Download, DownloadAsset, DownloadFile, DownloadStatus, DownloadView, Module, SaveActivityInput, Space, SpaceAccessRule, SpaceDetail, SpaceLink, SpaceSettings, SpaceTopic };
3
+ export type { Activity, ActivityAsset, ActivitySettings, ActivityView, Bundle, BundleItem, Community, CommunitySettings, CommunityStatus, CommunityView, ContentItem, ContentType, Course, CourseSettings, CourseStatus, CourseView, DigestSchedule, DmSettings, Download, DownloadAsset, DownloadFile, DownloadStatus, DownloadView, Event, EventAsset, EventFile, EventLead, EventLocation, EventRecording, EventSettings, EventStatus, EventType, EventView, Module, SaveActivityInput, Space, SpaceAccessRule, SpaceDetail, SpaceLink, SpaceSettings, SpaceTopic };
@@ -1,6 +1,7 @@
1
1
  import { Logger } from "../types/ports.js";
2
2
  import { NotificationCategory } from "../types/notifications.js";
3
3
  import "../types/index.js";
4
+ import { Actor } from "../shared/actor.js";
4
5
  import { ChannelRegistry, NotificationCategoryService, NotificationTypeRegistry } from "../shared/ports.js";
5
6
  import { ContentRepository } from "./ports.js";
6
7
  import { SettingsService } from "../shared/settings.js";
@@ -19,16 +20,16 @@ declare class CommunityNotificationCategories implements NotificationCategorySer
19
20
  private readonly channels;
20
21
  private readonly logger;
21
22
  constructor(params: CommunityNotificationCategoriesParams);
22
- get(orgId: string, communityId: string): Promise<{
23
+ get(communityId: string, actor: Actor): Promise<{
23
24
  categories: NotificationCategory[];
24
25
  source: 'default' | 'stored';
25
26
  }>;
26
- replace(orgId: string, communityId: string, categories: NotificationCategory[]): Promise<{
27
+ replace(communityId: string, categories: NotificationCategory[], actor: Actor): Promise<{
27
28
  categories: NotificationCategory[];
28
29
  source: 'stored';
29
30
  }>;
30
- reset(orgId: string, communityId: string): Promise<void>;
31
- defaults(): NotificationCategory[];
31
+ reset(communityId: string, actor: Actor): Promise<void>;
32
+ defaults(actor: Actor): NotificationCategory[];
32
33
  private assertCommunity;
33
34
  }
34
35
  //#endregion
@@ -1,5 +1,5 @@
1
- import { NotFoundError } from "../shared/errors.js";
2
1
  import { noopLogger } from "../shared/logger.js";
2
+ import { ForbiddenError, NotFoundError } from "../shared/errors.js";
3
3
  import "../shared/settings.js";
4
4
  import { assertValidCategoryList, offeringConfigured, storedCategoryList } from "../shared/notification-categories.js";
5
5
  //#region src/content/notification-categories.ts
@@ -16,18 +16,22 @@ var CommunityNotificationCategories = class {
16
16
  this.channels = params.channels;
17
17
  this.logger = params.logger ?? noopLogger;
18
18
  }
19
- async get(orgId, communityId) {
19
+ async get(communityId, actor) {
20
+ actor.permissions.require("communities:read", communityId);
21
+ const orgId = actor.orgId;
20
22
  await this.assertCommunity(orgId, communityId);
21
23
  const stored = storedCategoryList((await this.settings.get(orgId, "content", communityId))?.notificationCategories);
22
24
  return stored ? {
23
25
  categories: offeringConfigured(stored, this.channels.list()),
24
26
  source: "stored"
25
27
  } : {
26
- categories: this.defaults(),
28
+ categories: this.types.defaults("community"),
27
29
  source: "default"
28
30
  };
29
31
  }
30
- async replace(orgId, communityId, categories) {
32
+ async replace(communityId, categories, actor) {
33
+ actor.permissions.require("communities:write", communityId);
34
+ const orgId = actor.orgId;
31
35
  await this.assertCommunity(orgId, communityId);
32
36
  const configured = this.channels.list();
33
37
  assertValidCategoryList(categories, "community", this.types, configured);
@@ -35,6 +39,7 @@ var CommunityNotificationCategories = class {
35
39
  await this.settings.patch(orgId, "content", communityId, { notificationCategories: ordered });
36
40
  this.logger.info("community notification categories replaced", {
37
41
  orgId,
42
+ orgUserId: actor.id,
38
43
  communityId,
39
44
  keys: categories.map((category) => category.key)
40
45
  });
@@ -43,15 +48,19 @@ var CommunityNotificationCategories = class {
43
48
  source: "stored"
44
49
  };
45
50
  }
46
- async reset(orgId, communityId) {
51
+ async reset(communityId, actor) {
52
+ actor.permissions.require("communities:write", communityId);
53
+ const orgId = actor.orgId;
47
54
  await this.assertCommunity(orgId, communityId);
48
55
  await this.settings.patch(orgId, "content", communityId, { notificationCategories: null });
49
56
  this.logger.info("community notification categories reset", {
50
57
  orgId,
58
+ orgUserId: actor.id,
51
59
  communityId
52
60
  });
53
61
  }
54
- defaults() {
62
+ defaults(actor) {
63
+ if (!actor.permissions.has("notification_categories:read") && !actor.permissions.anywhere("communities:read")) throw new ForbiddenError("You need notification_categories:read or communities:read");
55
64
  return this.types.defaults("community");
56
65
  }
57
66
  async assertCommunity(orgId, communityId) {
@@ -1 +1 @@
1
- {"version":3,"file":"notification-categories.js","names":[],"sources":["../../src/content/notification-categories.ts"],"sourcesContent":["import type { NotificationCategory } from '../types/index.js';\nimport type {\n ChannelRegistry,\n Logger,\n NotificationCategoryService,\n NotificationTypeRegistry,\n} from '../shared/ports.js';\nimport { NotFoundError } from '../shared/errors.js';\nimport { noopLogger } from '../shared/logger.js';\nimport { SettingsNamespace, type SettingsService } from '../shared/settings.js';\nimport {\n assertValidCategoryList,\n offeringConfigured,\n storedCategoryList,\n} from '../shared/notification-categories.js';\nimport type { ContentRepository } from './ports.js';\n\nexport type CommunityNotificationCategoriesParams = {\n communities: Pick<ContentRepository, 'findCommunityById'>;\n settings: SettingsService;\n types: NotificationTypeRegistry;\n channels: ChannelRegistry;\n logger?: Logger;\n};\n\nexport class CommunityNotificationCategories implements NotificationCategoryService {\n private readonly communities: Pick<ContentRepository, 'findCommunityById'>;\n private readonly settings: SettingsService;\n private readonly types: NotificationTypeRegistry;\n private readonly channels: ChannelRegistry;\n private readonly logger: Logger;\n\n constructor(params: CommunityNotificationCategoriesParams) {\n this.communities = params.communities;\n this.settings = params.settings;\n this.types = params.types;\n this.channels = params.channels;\n this.logger = params.logger ?? noopLogger;\n }\n\n async get(\n orgId: string,\n communityId: string,\n ): Promise<{ categories: NotificationCategory[]; source: 'default' | 'stored' }> {\n await this.assertCommunity(orgId, communityId);\n const value = await this.settings.get<Record<string, unknown>>(\n orgId,\n SettingsNamespace.content,\n communityId,\n );\n const stored = storedCategoryList(value?.notificationCategories);\n return stored\n ? { categories: offeringConfigured(stored, this.channels.list()), source: 'stored' }\n : { categories: this.defaults(), source: 'default' };\n }\n\n async replace(\n orgId: string,\n communityId: string,\n categories: NotificationCategory[],\n ): Promise<{ categories: NotificationCategory[]; source: 'stored' }> {\n await this.assertCommunity(orgId, communityId);\n const configured = this.channels.list();\n assertValidCategoryList(categories, 'community', this.types, configured);\n const ordered = offeringConfigured(categories, configured);\n await this.settings.patch(orgId, SettingsNamespace.content, communityId, {\n notificationCategories: ordered,\n });\n this.logger.info('community notification categories replaced', {\n orgId,\n communityId,\n keys: categories.map((category) => category.key),\n });\n return { categories: ordered, source: 'stored' };\n }\n\n async reset(orgId: string, communityId: string): Promise<void> {\n await this.assertCommunity(orgId, communityId);\n await this.settings.patch(orgId, SettingsNamespace.content, communityId, {\n notificationCategories: null,\n });\n this.logger.info('community notification categories reset', { orgId, communityId });\n }\n\n defaults(): NotificationCategory[] {\n return this.types.defaults('community');\n }\n\n private async assertCommunity(orgId: string, communityId: string): Promise<void> {\n const community = await this.communities.findCommunityById(orgId, communityId);\n if (!community) {\n throw new NotFoundError('Community', communityId);\n }\n }\n}\n"],"mappings":";;;;;AAyBA,IAAa,kCAAb,MAAoF;CAClF;CACA;CACA;CACA;CACA;CAEA,YAAY,QAA+C;EACzD,KAAK,cAAc,OAAO;EAC1B,KAAK,WAAW,OAAO;EACvB,KAAK,QAAQ,OAAO;EACpB,KAAK,WAAW,OAAO;EACvB,KAAK,SAAS,OAAO,UAAU;CACjC;CAEA,MAAM,IACJ,OACA,aAC+E;EAC/E,MAAM,KAAK,gBAAgB,OAAO,WAAW;EAM7C,MAAM,SAAS,oBAAmB,MALd,KAAK,SAAS,IAChC,OAAA,WAEA,WACF,EAAA,EACyC,sBAAsB;EAC/D,OAAO,SACH;GAAE,YAAY,mBAAmB,QAAQ,KAAK,SAAS,KAAK,CAAC;GAAG,QAAQ;EAAS,IACjF;GAAE,YAAY,KAAK,SAAS;GAAG,QAAQ;EAAU;CACvD;CAEA,MAAM,QACJ,OACA,aACA,YACmE;EACnE,MAAM,KAAK,gBAAgB,OAAO,WAAW;EAC7C,MAAM,aAAa,KAAK,SAAS,KAAK;EACtC,wBAAwB,YAAY,aAAa,KAAK,OAAO,UAAU;EACvE,MAAM,UAAU,mBAAmB,YAAY,UAAU;EACzD,MAAM,KAAK,SAAS,MAAM,OAAA,WAAkC,aAAa,EACvE,wBAAwB,QAC1B,CAAC;EACD,KAAK,OAAO,KAAK,8CAA8C;GAC7D;GACA;GACA,MAAM,WAAW,KAAK,aAAa,SAAS,GAAG;EACjD,CAAC;EACD,OAAO;GAAE,YAAY;GAAS,QAAQ;EAAS;CACjD;CAEA,MAAM,MAAM,OAAe,aAAoC;EAC7D,MAAM,KAAK,gBAAgB,OAAO,WAAW;EAC7C,MAAM,KAAK,SAAS,MAAM,OAAA,WAAkC,aAAa,EACvE,wBAAwB,KAC1B,CAAC;EACD,KAAK,OAAO,KAAK,2CAA2C;GAAE;GAAO;EAAY,CAAC;CACpF;CAEA,WAAmC;EACjC,OAAO,KAAK,MAAM,SAAS,WAAW;CACxC;CAEA,MAAc,gBAAgB,OAAe,aAAoC;EAE/E,IAAI,CAAC,MADmB,KAAK,YAAY,kBAAkB,OAAO,WAAW,GAE3E,MAAM,IAAI,cAAc,aAAa,WAAW;CAEpD;AACF"}
1
+ {"version":3,"file":"notification-categories.js","names":[],"sources":["../../src/content/notification-categories.ts"],"sourcesContent":["import type { NotificationCategory } from '../types/index.js';\nimport type {\n ChannelRegistry,\n Logger,\n NotificationCategoryService,\n NotificationTypeRegistry,\n} from '../shared/ports.js';\nimport { ForbiddenError, NotFoundError } from '../shared/errors.js';\nimport type { Actor } from '../shared/actor.js';\nimport { noopLogger } from '../shared/logger.js';\nimport { SettingsNamespace, type SettingsService } from '../shared/settings.js';\nimport {\n assertValidCategoryList,\n offeringConfigured,\n storedCategoryList,\n} from '../shared/notification-categories.js';\nimport type { ContentRepository } from './ports.js';\n\nexport type CommunityNotificationCategoriesParams = {\n communities: Pick<ContentRepository, 'findCommunityById'>;\n settings: SettingsService;\n types: NotificationTypeRegistry;\n channels: ChannelRegistry;\n logger?: Logger;\n};\n\nexport class CommunityNotificationCategories implements NotificationCategoryService {\n private readonly communities: Pick<ContentRepository, 'findCommunityById'>;\n private readonly settings: SettingsService;\n private readonly types: NotificationTypeRegistry;\n private readonly channels: ChannelRegistry;\n private readonly logger: Logger;\n\n constructor(params: CommunityNotificationCategoriesParams) {\n this.communities = params.communities;\n this.settings = params.settings;\n this.types = params.types;\n this.channels = params.channels;\n this.logger = params.logger ?? noopLogger;\n }\n\n async get(\n communityId: string,\n actor: Actor,\n ): Promise<{ categories: NotificationCategory[]; source: 'default' | 'stored' }> {\n actor.permissions.require('communities:read', communityId);\n const orgId = actor.orgId;\n await this.assertCommunity(orgId, communityId);\n const value = await this.settings.get<Record<string, unknown>>(\n orgId,\n SettingsNamespace.content,\n communityId,\n );\n const stored = storedCategoryList(value?.notificationCategories);\n return stored\n ? { categories: offeringConfigured(stored, this.channels.list()), source: 'stored' }\n : { categories: this.types.defaults('community'), source: 'default' };\n }\n\n async replace(\n communityId: string,\n categories: NotificationCategory[],\n actor: Actor,\n ): Promise<{ categories: NotificationCategory[]; source: 'stored' }> {\n actor.permissions.require('communities:write', communityId);\n const orgId = actor.orgId;\n await this.assertCommunity(orgId, communityId);\n const configured = this.channels.list();\n assertValidCategoryList(categories, 'community', this.types, configured);\n const ordered = offeringConfigured(categories, configured);\n await this.settings.patch(orgId, SettingsNamespace.content, communityId, {\n notificationCategories: ordered,\n });\n this.logger.info('community notification categories replaced', {\n orgId,\n orgUserId: actor.id,\n communityId,\n keys: categories.map((category) => category.key),\n });\n return { categories: ordered, source: 'stored' };\n }\n\n async reset(communityId: string, actor: Actor): Promise<void> {\n actor.permissions.require('communities:write', communityId);\n const orgId = actor.orgId;\n await this.assertCommunity(orgId, communityId);\n await this.settings.patch(orgId, SettingsNamespace.content, communityId, {\n notificationCategories: null,\n });\n this.logger.info('community notification categories reset', {\n orgId,\n orgUserId: actor.id,\n communityId,\n });\n }\n\n defaults(actor: Actor): NotificationCategory[] {\n if (\n !actor.permissions.has('notification_categories:read') &&\n !actor.permissions.anywhere('communities:read')\n ) {\n throw new ForbiddenError('You need notification_categories:read or communities:read');\n }\n return this.types.defaults('community');\n }\n\n private async assertCommunity(orgId: string, communityId: string): Promise<void> {\n const community = await this.communities.findCommunityById(orgId, communityId);\n if (!community) {\n throw new NotFoundError('Community', communityId);\n }\n }\n}\n"],"mappings":";;;;;AA0BA,IAAa,kCAAb,MAAoF;CAClF;CACA;CACA;CACA;CACA;CAEA,YAAY,QAA+C;EACzD,KAAK,cAAc,OAAO;EAC1B,KAAK,WAAW,OAAO;EACvB,KAAK,QAAQ,OAAO;EACpB,KAAK,WAAW,OAAO;EACvB,KAAK,SAAS,OAAO,UAAU;CACjC;CAEA,MAAM,IACJ,aACA,OAC+E;EAC/E,MAAM,YAAY,QAAQ,oBAAoB,WAAW;EACzD,MAAM,QAAQ,MAAM;EACpB,MAAM,KAAK,gBAAgB,OAAO,WAAW;EAM7C,MAAM,SAAS,oBAAmB,MALd,KAAK,SAAS,IAChC,OAAA,WAEA,WACF,EAAA,EACyC,sBAAsB;EAC/D,OAAO,SACH;GAAE,YAAY,mBAAmB,QAAQ,KAAK,SAAS,KAAK,CAAC;GAAG,QAAQ;EAAS,IACjF;GAAE,YAAY,KAAK,MAAM,SAAS,WAAW;GAAG,QAAQ;EAAU;CACxE;CAEA,MAAM,QACJ,aACA,YACA,OACmE;EACnE,MAAM,YAAY,QAAQ,qBAAqB,WAAW;EAC1D,MAAM,QAAQ,MAAM;EACpB,MAAM,KAAK,gBAAgB,OAAO,WAAW;EAC7C,MAAM,aAAa,KAAK,SAAS,KAAK;EACtC,wBAAwB,YAAY,aAAa,KAAK,OAAO,UAAU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