@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
@@ -1,20 +1,79 @@
1
1
  import { emailSchema, idSchema } from "./shared.js";
2
+ import { contentTypeSchema } from "./content.js";
2
3
  import { z } from "zod";
3
4
  //#region src/types/schemas/organizations.ts
4
- const roleSchema = z.enum([
5
- "owner",
6
- "admin",
7
- "instructor",
8
- "moderator",
9
- "student"
10
- ]);
5
+ const levelSchema = z.union([z.literal("org"), z.lazy(() => contentTypeSchema)]);
6
+ const PERMISSION_KEYS = [
7
+ "organizations:read",
8
+ "organizations:write",
9
+ "api_keys:read",
10
+ "api_keys:write",
11
+ "api_keys:delete",
12
+ "notification_categories:read",
13
+ "notification_categories:write",
14
+ "integrations:read",
15
+ "integrations:write",
16
+ "integrations:delete",
17
+ "analytics:read",
18
+ "people:read",
19
+ "people:write",
20
+ "people:delete",
21
+ "roles:read",
22
+ "roles:write",
23
+ "roles:delete",
24
+ "access:read",
25
+ "access:write",
26
+ "bundles:read",
27
+ "bundles:write",
28
+ "bundles:delete",
29
+ "media:read",
30
+ "media:write",
31
+ "media:delete",
32
+ "courses:read",
33
+ "courses:write",
34
+ "courses:delete",
35
+ "courses:moderate",
36
+ "progress:read",
37
+ "downloads:read",
38
+ "downloads:write",
39
+ "downloads:delete",
40
+ "communities:read",
41
+ "communities:write",
42
+ "communities:delete",
43
+ "communities:moderate",
44
+ "events:read",
45
+ "events:write",
46
+ "events:delete",
47
+ "automations:read",
48
+ "automations:write",
49
+ "automations:delete"
50
+ ];
51
+ const permissionSchema = z.enum(PERMISSION_KEYS);
52
+ const roleKeySchema = z.string().trim().min(1).max(64).regex(/^[a-z][a-zA-Z0-9_]*$/, "A role key starts with a lowercase letter and holds letters, digits and underscores");
53
+ const orgRoleRowSchema = z.object({
54
+ id: idSchema,
55
+ orgId: idSchema,
56
+ key: z.string(),
57
+ name: z.string().nullable(),
58
+ description: z.string().nullable(),
59
+ base: z.string(),
60
+ levels: z.array(levelSchema).nullable(),
61
+ permissions: z.record(z.string(), z.boolean()),
62
+ team: z.boolean().nullable(),
63
+ createdAt: z.coerce.date(),
64
+ updatedAt: z.coerce.date()
65
+ }).strict();
66
+ const roleAssignmentSchema = z.object({
67
+ id: idSchema,
68
+ orgId: idSchema,
69
+ orgUserId: idSchema,
70
+ roleKey: z.string(),
71
+ contentId: idSchema.nullable(),
72
+ contentType: z.lazy(() => contentTypeSchema).nullable(),
73
+ assignedBy: z.string(),
74
+ createdAt: z.coerce.date()
75
+ }).strict();
11
76
  const orgUserStatusSchema = z.enum(["invited", "active"]);
12
- const inviteRoleSchema = z.enum([
13
- "admin",
14
- "instructor",
15
- "moderator",
16
- "student"
17
- ]);
18
77
  const organizationSchema = z.object({
19
78
  id: idSchema,
20
79
  externalId: idSchema.nullable(),
@@ -28,7 +87,6 @@ const orgUserSchema = z.object({
28
87
  id: idSchema,
29
88
  orgId: idSchema,
30
89
  userId: idSchema,
31
- role: roleSchema,
32
90
  status: orgUserStatusSchema,
33
91
  createdAt: z.coerce.date(),
34
92
  updatedAt: z.coerce.date()
@@ -44,7 +102,7 @@ const inviteSchema = z.object({
44
102
  id: idSchema,
45
103
  orgId: idSchema,
46
104
  email: emailSchema,
47
- role: inviteRoleSchema,
105
+ roleKey: z.string(),
48
106
  status: z.enum([
49
107
  "pending",
50
108
  "accepted",
@@ -64,34 +122,27 @@ const newOrganizationInputSchema = z.object({
64
122
  }).strict();
65
123
  const addOrgUserInputSchema = z.object({
66
124
  orgId: idSchema,
67
- userId: idSchema,
68
- role: roleSchema
125
+ userId: idSchema
69
126
  }).strict();
70
127
  const createOrgUserInputSchema = z.object({
71
128
  orgId: idSchema,
72
129
  userId: idSchema,
73
- role: roleSchema,
74
- status: orgUserStatusSchema.optional()
75
- }).strict();
76
- const updateOrgUserInputSchema = z.object({
77
- role: roleSchema.optional(),
78
130
  status: orgUserStatusSchema.optional()
79
131
  }).strict();
132
+ const updateOrgUserInputSchema = z.object({ status: orgUserStatusSchema.optional() }).strict();
80
133
  const createInviteInputSchema = z.object({
81
- orgId: idSchema,
82
134
  email: emailSchema,
83
- role: inviteRoleSchema,
84
- inviterUserId: idSchema,
135
+ roleKey: roleKeySchema.default("member"),
85
136
  firstName: z.string().optional(),
86
137
  lastName: z.string().optional(),
87
138
  sendEmail: z.boolean().optional()
88
139
  }).strict();
89
140
  const acceptInviteInputSchema = z.object({
90
141
  token: z.string().trim().min(1),
91
- userId: idSchema,
142
+ authUserId: idSchema,
92
143
  email: emailSchema
93
144
  }).strict();
94
145
  //#endregion
95
- export { acceptInviteInputSchema, addOrgUserInputSchema, createInviteInputSchema, createOrgUserInputSchema, inviteRoleSchema, inviteSchema, newOrganizationInputSchema, orgUserProfileSchema, orgUserSchema, orgUserStatusSchema, organizationSchema, roleSchema, updateOrgUserInputSchema };
146
+ export { PERMISSION_KEYS, acceptInviteInputSchema, addOrgUserInputSchema, createInviteInputSchema, createOrgUserInputSchema, inviteSchema, levelSchema, newOrganizationInputSchema, orgRoleRowSchema, orgUserProfileSchema, orgUserSchema, orgUserStatusSchema, organizationSchema, permissionSchema, roleAssignmentSchema, roleKeySchema, updateOrgUserInputSchema };
96
147
 
97
148
  //# sourceMappingURL=organizations.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"organizations.js","names":[],"sources":["../../../src/types/schemas/organizations.ts"],"sourcesContent":["import { z } from 'zod';\nimport { idSchema, emailSchema } from './shared.js';\n\nexport const roleSchema = z.enum(['owner', 'admin', 'instructor', 'moderator', 'student']);\nexport type Role = z.infer<typeof roleSchema>;\n\nexport const orgUserStatusSchema = z.enum(['invited', 'active']);\nexport type OrgUserStatus = z.infer<typeof orgUserStatusSchema>;\n\nexport const inviteRoleSchema = z.enum(['admin', 'instructor', 'moderator', 'student']);\nexport type InviteRole = z.infer<typeof inviteRoleSchema>;\n\nexport const organizationSchema = z\n .object({\n id: idSchema,\n externalId: idSchema.nullable(),\n name: z.string(),\n slug: z.string(),\n ownerId: idSchema,\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n })\n .strict();\nexport type Organization = z.output<typeof organizationSchema>;\nexport type OrganizationInput = z.input<typeof organizationSchema>;\n\nexport const orgUserSchema = z\n .object({\n id: idSchema,\n orgId: idSchema,\n userId: idSchema,\n role: roleSchema,\n status: orgUserStatusSchema,\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n })\n .strict();\nexport type OrgUser = z.output<typeof orgUserSchema>;\nexport type OrgUserInput = z.input<typeof orgUserSchema>;\n\nexport const orgUserProfileSchema = z\n .object({\n id: idSchema,\n firstName: z.string().nullable(),\n lastName: z.string().nullable(),\n email: emailSchema,\n image: z.string().nullable(),\n })\n .strict();\nexport type OrgUserProfile = z.infer<typeof orgUserProfileSchema>;\n\nexport const inviteSchema = z\n .object({\n id: idSchema,\n orgId: idSchema,\n email: emailSchema,\n role: inviteRoleSchema,\n status: z.enum(['pending', 'accepted', 'rejected', 'canceled']),\n invitedBy: idSchema,\n tokenHash: z.string().nullable(),\n expiresAt: z.coerce.date().nullable(),\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n })\n .strict();\nexport type Invite = z.output<typeof inviteSchema>;\nexport type InviteInput = z.input<typeof inviteSchema>;\n\nexport const newOrganizationInputSchema = z\n .object({\n name: z.string(),\n slug: z.string(),\n logo: z.string().optional(),\n })\n .strict();\nexport type NewOrganizationInput = z.infer<typeof newOrganizationInputSchema>;\n\nexport const addOrgUserInputSchema = z\n .object({\n orgId: idSchema,\n userId: idSchema,\n role: roleSchema,\n })\n .strict();\nexport type AddOrgUserInput = z.infer<typeof addOrgUserInputSchema>;\n\nexport const createOrgUserInputSchema = z\n .object({\n orgId: idSchema,\n userId: idSchema,\n role: roleSchema,\n status: orgUserStatusSchema.optional(),\n })\n .strict();\nexport type CreateOrgUserInput = z.infer<typeof createOrgUserInputSchema>;\n\nexport const updateOrgUserInputSchema = z\n .object({\n role: roleSchema.optional(),\n status: orgUserStatusSchema.optional(),\n })\n .strict();\nexport type UpdateOrgUserInput = z.infer<typeof updateOrgUserInputSchema>;\n\nexport const createInviteInputSchema = z\n .object({\n orgId: idSchema,\n email: emailSchema,\n role: inviteRoleSchema,\n inviterUserId: idSchema,\n firstName: z.string().optional(),\n lastName: z.string().optional(),\n sendEmail: z.boolean().optional(),\n })\n .strict();\nexport type CreateInviteInput = z.infer<typeof createInviteInputSchema>;\n\nexport const acceptInviteInputSchema = z\n .object({\n token: z.string().trim().min(1),\n userId: idSchema,\n email: emailSchema,\n })\n .strict();\nexport type AcceptInviteInput = z.infer<typeof acceptInviteInputSchema>;\n"],"mappings":";;;AAGA,MAAa,aAAa,EAAE,KAAK;CAAC;CAAS;CAAS;CAAc;CAAa;AAAS,CAAC;AAGzF,MAAa,sBAAsB,EAAE,KAAK,CAAC,WAAW,QAAQ,CAAC;AAG/D,MAAa,mBAAmB,EAAE,KAAK;CAAC;CAAS;CAAc;CAAa;AAAS,CAAC;AAGtF,MAAa,qBAAqB,EAC/B,OAAO;CACN,IAAI;CACJ,YAAY,SAAS,SAAS;CAC9B,MAAM,EAAE,OAAO;CACf,MAAM,EAAE,OAAO;CACf,SAAS;CAC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1B,QAAQ,oBAAoB,SAAS;AACvC,CAAC,CAAC,CACD,OAAO;AAGV,MAAa,0BAA0B,EACpC,OAAO;CACN,OAAO;CACP,OAAO;CACP,MAAM;CACN,eAAe;CACf,WAAW,EAAE,OAAO,CAAC,CAAC,SAAS;CAC/B,UAAU,EAAE,OAAO,CAAC,CAAC,SAAS;CAC9B,WAAW,EAAE,QAAQ,CAAC,CAAC,SAAS;AAClC,CAAC,CAAC,CACD,OAAO;AAGV,MAAa,0BAA0B,EACpC,OAAO;CACN,OAAO,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC;CAC9B,QAAQ;CACR,OAAO;AACT,CAAC,CAAC,CACD,OAAO"}
1
+ {"version":3,"file":"organizations.js","names":[],"sources":["../../../src/types/schemas/organizations.ts"],"sourcesContent":["import { z } from 'zod';\nimport { idSchema, emailSchema } from './shared.js';\nimport { contentTypeSchema } from './content.js';\n\nexport const levelSchema = z.union([z.literal('org'), z.lazy(() => contentTypeSchema)]);\nexport type Level = z.infer<typeof levelSchema>;\n\nexport const PERMISSION_KEYS = [\n 'organizations:read',\n 'organizations:write',\n 'api_keys:read',\n 'api_keys:write',\n 'api_keys:delete',\n 'notification_categories:read',\n 'notification_categories:write',\n 'integrations:read',\n 'integrations:write',\n 'integrations:delete',\n 'analytics:read',\n 'people:read',\n 'people:write',\n 'people:delete',\n 'roles:read',\n 'roles:write',\n 'roles:delete',\n 'access:read',\n 'access:write',\n 'bundles:read',\n 'bundles:write',\n 'bundles:delete',\n 'media:read',\n 'media:write',\n 'media:delete',\n 'courses:read',\n 'courses:write',\n 'courses:delete',\n 'courses:moderate',\n 'progress:read',\n 'downloads:read',\n 'downloads:write',\n 'downloads:delete',\n 'communities:read',\n 'communities:write',\n 'communities:delete',\n 'communities:moderate',\n 'events:read',\n 'events:write',\n 'events:delete',\n 'automations:read',\n 'automations:write',\n 'automations:delete',\n] as const;\n\nexport const permissionSchema = z.enum(PERMISSION_KEYS);\nexport type Permission = z.infer<typeof permissionSchema>;\n\nexport const roleKeySchema = z\n .string()\n .trim()\n .min(1)\n .max(64)\n .regex(\n /^[a-z][a-zA-Z0-9_]*$/,\n 'A role key starts with a lowercase letter and holds letters, digits and underscores',\n );\nexport type RoleKey = z.infer<typeof roleKeySchema>;\n\nexport const orgRoleRowSchema = z\n .object({\n id: idSchema,\n orgId: idSchema,\n key: z.string(),\n name: z.string().nullable(),\n description: z.string().nullable(),\n base: z.string(),\n levels: z.array(levelSchema).nullable(),\n permissions: z.record(z.string(), z.boolean()),\n team: z.boolean().nullable(),\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n })\n .strict();\nexport type OrgRoleRow = z.output<typeof orgRoleRowSchema>;\n\nexport const roleAssignmentSchema = z\n .object({\n id: idSchema,\n orgId: idSchema,\n orgUserId: idSchema,\n roleKey: z.string(),\n contentId: idSchema.nullable(),\n contentType: z.lazy(() => contentTypeSchema).nullable(),\n assignedBy: z.string(),\n createdAt: z.coerce.date(),\n })\n .strict();\nexport type RoleAssignment = z.output<typeof roleAssignmentSchema>;\n\nexport const orgUserStatusSchema = z.enum(['invited', 'active']);\nexport type OrgUserStatus = z.infer<typeof orgUserStatusSchema>;\n\nexport const organizationSchema = z\n .object({\n id: idSchema,\n externalId: idSchema.nullable(),\n name: z.string(),\n slug: z.string(),\n ownerId: idSchema,\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n })\n .strict();\nexport type Organization = z.output<typeof organizationSchema>;\nexport type OrganizationInput = z.input<typeof organizationSchema>;\n\nexport const orgUserSchema = z\n .object({\n id: idSchema,\n orgId: idSchema,\n userId: idSchema,\n status: orgUserStatusSchema,\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n })\n .strict();\nexport type OrgUser = z.output<typeof orgUserSchema>;\nexport type OrgUserInput = z.input<typeof orgUserSchema>;\n\nexport const orgUserProfileSchema = z\n .object({\n id: idSchema,\n firstName: z.string().nullable(),\n lastName: z.string().nullable(),\n email: emailSchema,\n image: z.string().nullable(),\n })\n .strict();\nexport type OrgUserProfile = z.infer<typeof orgUserProfileSchema>;\n\nexport const inviteSchema = z\n .object({\n id: idSchema,\n orgId: idSchema,\n email: emailSchema,\n roleKey: z.string(),\n status: z.enum(['pending', 'accepted', 'rejected', 'canceled']),\n invitedBy: idSchema,\n tokenHash: z.string().nullable(),\n expiresAt: z.coerce.date().nullable(),\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n })\n .strict();\nexport type Invite = z.output<typeof inviteSchema>;\nexport type InviteInput = z.input<typeof inviteSchema>;\n\nexport const newOrganizationInputSchema = z\n .object({\n name: z.string(),\n slug: z.string(),\n logo: z.string().optional(),\n })\n .strict();\nexport type NewOrganizationInput = z.infer<typeof newOrganizationInputSchema>;\n\nexport const addOrgUserInputSchema = z\n .object({\n orgId: idSchema,\n userId: idSchema,\n })\n .strict();\nexport type AddOrgUserInput = z.infer<typeof addOrgUserInputSchema>;\n\nexport const createOrgUserInputSchema = z\n .object({\n orgId: idSchema,\n userId: idSchema,\n status: orgUserStatusSchema.optional(),\n })\n .strict();\nexport type CreateOrgUserInput = z.infer<typeof createOrgUserInputSchema>;\n\nexport const updateOrgUserInputSchema = z\n .object({\n status: orgUserStatusSchema.optional(),\n })\n .strict();\nexport type UpdateOrgUserInput = z.infer<typeof updateOrgUserInputSchema>;\n\nexport const createInviteInputSchema = z\n .object({\n email: emailSchema,\n roleKey: roleKeySchema.default('member'),\n firstName: z.string().optional(),\n lastName: z.string().optional(),\n sendEmail: z.boolean().optional(),\n })\n .strict();\nexport type CreateInviteInput = z.input<typeof createInviteInputSchema>;\n\nexport const acceptInviteInputSchema = z\n .object({\n token: z.string().trim().min(1),\n authUserId: idSchema,\n email: emailSchema,\n })\n .strict();\nexport type AcceptInviteInput = z.infer<typeof acceptInviteInputSchema>;\n"],"mappings":";;;;AAIA,MAAa,cAAc,EAAE,MAAM,CAAC,EAAE,QAAQ,KAAK,GAAG,EAAE,WAAW,iBAAiB,CAAC,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ACN,QAAQ,oBAAoB,SAAS,EACvC,CAAC,CAAC,CACD,OAAO;AAGV,MAAa,0BAA0B,EACpC,OAAO;CACN,OAAO;CACP,SAAS,cAAc,QAAQ,QAAQ;CACvC,WAAW,EAAE,OAAO,CAAC,CAAC,SAAS;CAC/B,UAAU,EAAE,OAAO,CAAC,CAAC,SAAS;CAC9B,WAAW,EAAE,QAAQ,CAAC,CAAC,SAAS;AAClC,CAAC,CAAC,CACD,OAAO;AAGV,MAAa,0BAA0B,EACpC,OAAO;CACN,OAAO,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC;CAC9B,YAAY;CACZ,OAAO;AACT,CAAC,CAAC,CACD,OAAO"}
@@ -41,7 +41,6 @@ declare const progressReportItemSchema: z.ZodObject<{
41
41
  }, z.core.$catchall<z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>>;
42
42
  type ProgressReportItem = z.infer<typeof progressReportItemSchema>;
43
43
  declare const reportProgressInputSchema: z.ZodObject<{
44
- orgUserId: z.ZodString;
45
44
  activityId: z.ZodString;
46
45
  reports: z.ZodArray<z.ZodObject<{
47
46
  asset: z.ZodOptional<z.ZodString>;
@@ -28,7 +28,6 @@ const progressReportItemSchema = z.object({
28
28
  completed: z.boolean().optional()
29
29
  }).catchall(jsonValueSchema);
30
30
  const reportProgressInputSchema = z.object({
31
- orgUserId: idSchema,
32
31
  activityId: idSchema,
33
32
  reports: z.array(progressReportItemSchema)
34
33
  }).strict();
@@ -1 +1 @@
1
- {"version":3,"file":"progress.js","names":[],"sources":["../../../src/types/schemas/progress.ts"],"sourcesContent":["import { z } from 'zod';\nimport { idSchema, jsonValueSchema } from './shared.js';\n\nexport const progressTargetTypeSchema = z.enum(['activity', 'module', 'course']);\nexport type ProgressTargetType = z.infer<typeof progressTargetTypeSchema>;\n\nexport const progressRecordSchema = z\n .object({\n id: idSchema,\n orgId: idSchema,\n orgUserId: idSchema,\n targetType: progressTargetTypeSchema,\n targetId: idSchema,\n startedAt: z.coerce.date(),\n position: jsonValueSchema.nullable(),\n completedAt: z.coerce.date().nullable(),\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n })\n .strict();\nexport type ProgressRecord = z.output<typeof progressRecordSchema>;\nexport type ProgressRecordInput = z.input<typeof progressRecordSchema>;\n\nexport const progressTargetSchema = z\n .object({\n orgUserId: idSchema,\n targetType: progressTargetTypeSchema,\n targetId: idSchema,\n })\n .strict();\nexport type ProgressTarget = z.infer<typeof progressTargetSchema>;\n\nexport const progressReportItemSchema = z\n .object({\n asset: z.string().optional(),\n completed: z.boolean().optional(),\n })\n .catchall(jsonValueSchema);\nexport type ProgressReportItem = z.infer<typeof progressReportItemSchema>;\n\nexport const reportProgressInputSchema = z\n .object({\n orgUserId: idSchema,\n activityId: idSchema,\n reports: z.array(progressReportItemSchema),\n })\n .strict();\nexport type ReportProgressInput = z.infer<typeof reportProgressInputSchema>;\n"],"mappings":";;;AAGA,MAAa,2BAA2B,EAAE,KAAK;CAAC;CAAY;CAAU;AAAQ,CAAC;AAG/E,MAAa,uBAAuB,EACjC,OAAO;CACN,IAAI;CACJ,OAAO;CACP,WAAW;CACX,YAAY;CACZ,UAAU;CACV,WAAW,EAAE,OAAO,KAAK;CACzB,UAAU,gBAAgB,SAAS;CACnC,aAAa,EAAE,OAAO,KAAK,CAAC,CAAC,SAAS;CACtC,WAAW,EAAE,OAAO,KAAK;CACzB,WAAW,EAAE,OAAO,KAAK;AAC3B,CAAC,CAAC,CACD,OAAO;AAIV,MAAa,uBAAuB,EACjC,OAAO;CACN,WAAW;CACX,YAAY;CACZ,UAAU;AACZ,CAAC,CAAC,CACD,OAAO;AAGV,MAAa,2BAA2B,EACrC,OAAO;CACN,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS;CAC3B,WAAW,EAAE,QAAQ,CAAC,CAAC,SAAS;AAClC,CAAC,CAAC,CACD,SAAS,eAAe;AAG3B,MAAa,4BAA4B,EACtC,OAAO;CACN,WAAW;CACX,YAAY;CACZ,SAAS,EAAE,MAAM,wBAAwB;AAC3C,CAAC,CAAC,CACD,OAAO"}
1
+ {"version":3,"file":"progress.js","names":[],"sources":["../../../src/types/schemas/progress.ts"],"sourcesContent":["import { z } from 'zod';\nimport { idSchema, jsonValueSchema } from './shared.js';\n\nexport const progressTargetTypeSchema = z.enum(['activity', 'module', 'course']);\nexport type ProgressTargetType = z.infer<typeof progressTargetTypeSchema>;\n\nexport const progressRecordSchema = z\n .object({\n id: idSchema,\n orgId: idSchema,\n orgUserId: idSchema,\n targetType: progressTargetTypeSchema,\n targetId: idSchema,\n startedAt: z.coerce.date(),\n position: jsonValueSchema.nullable(),\n completedAt: z.coerce.date().nullable(),\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n })\n .strict();\nexport type ProgressRecord = z.output<typeof progressRecordSchema>;\nexport type ProgressRecordInput = z.input<typeof progressRecordSchema>;\n\nexport const progressTargetSchema = z\n .object({\n orgUserId: idSchema,\n targetType: progressTargetTypeSchema,\n targetId: idSchema,\n })\n .strict();\nexport type ProgressTarget = z.infer<typeof progressTargetSchema>;\n\nexport const progressReportItemSchema = z\n .object({\n asset: z.string().optional(),\n completed: z.boolean().optional(),\n })\n .catchall(jsonValueSchema);\nexport type ProgressReportItem = z.infer<typeof progressReportItemSchema>;\n\nexport const reportProgressInputSchema = z\n .object({\n activityId: idSchema,\n reports: z.array(progressReportItemSchema),\n })\n .strict();\nexport type ReportProgressInput = z.infer<typeof reportProgressInputSchema>;\n"],"mappings":";;;AAGA,MAAa,2BAA2B,EAAE,KAAK;CAAC;CAAY;CAAU;AAAQ,CAAC;AAG/E,MAAa,uBAAuB,EACjC,OAAO;CACN,IAAI;CACJ,OAAO;CACP,WAAW;CACX,YAAY;CACZ,UAAU;CACV,WAAW,EAAE,OAAO,KAAK;CACzB,UAAU,gBAAgB,SAAS;CACnC,aAAa,EAAE,OAAO,KAAK,CAAC,CAAC,SAAS;CACtC,WAAW,EAAE,OAAO,KAAK;CACzB,WAAW,EAAE,OAAO,KAAK;AAC3B,CAAC,CAAC,CACD,OAAO;AAIV,MAAa,uBAAuB,EACjC,OAAO;CACN,WAAW;CACX,YAAY;CACZ,UAAU;AACZ,CAAC,CAAC,CACD,OAAO;AAGV,MAAa,2BAA2B,EACrC,OAAO;CACN,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS;CAC3B,WAAW,EAAE,QAAQ,CAAC,CAAC,SAAS;AAClC,CAAC,CAAC,CACD,SAAS,eAAe;AAG3B,MAAa,4BAA4B,EACtC,OAAO;CACN,YAAY;CACZ,SAAS,EAAE,MAAM,wBAAwB;AAC3C,CAAC,CAAC,CACD,OAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@headless-lms/core",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "exports": {
@@ -1,16 +0,0 @@
1
- import { DomainEvent } from "../types/shared.js";
2
- import { NotificationKind } from "../types/schemas/identity.js";
3
- import "../types/index.js";
4
- import "../shared/ports.js";
5
- import { NewNotification } from "../identity/ports.js";
6
- import "../identity/index.js";
7
- import { ActionDeps, EmailRecipient } from "./community-mail.js";
8
- //#region src/automations/community-notifications.d.ts
9
- type Placement = Omit<NewNotification, 'userId' | 'kind'>;
10
- interface NotificationPlacement<K extends NotificationKind> {
11
- place(event: DomainEvent, recipient: EmailRecipient<K>, deps: ActionDeps): Promise<Placement[]>;
12
- }
13
- declare const NOTIFICATION_PLACEMENTS: { [K in NotificationKind]: NotificationPlacement<K>; };
14
- //#endregion
15
- export { NOTIFICATION_PLACEMENTS, NotificationPlacement };
16
- //# sourceMappingURL=community-notifications.d.ts.map
@@ -1,84 +0,0 @@
1
- import { actorOf } from "./community-mail.js";
2
- //#region src/automations/community-notifications.ts
3
- function text(event, key) {
4
- if (typeof event.data !== "object" || event.data === null) return null;
5
- const value = event.data[key];
6
- return typeof value === "string" ? value : null;
7
- }
8
- function at(communityId, actorOrgUserId, about) {
9
- return [{
10
- communityId,
11
- actorOrgUserId,
12
- spaceId: about.spaceId ?? null,
13
- postId: about.postId ?? null,
14
- commentId: about.commentId ?? null,
15
- chatId: about.chatId ?? null,
16
- messageId: about.messageId ?? null
17
- }];
18
- }
19
- function actor(event) {
20
- return actorOf(event) ?? null;
21
- }
22
- async function spaceOfPost(deps, event, postId) {
23
- return postId ? (await deps.mail.post(event.orgId, postId))?.spaceId ?? null : null;
24
- }
25
- const NOTIFICATION_PLACEMENTS = {
26
- newPostInSpace: { place: async (event, { params }) => at(params.communityId, text(event, "orgUserId"), {
27
- postId: params.postId,
28
- spaceId: text(event, "spaceId")
29
- }) },
30
- newCommentOnPost: { place: async (event, { params }, deps) => at(params.communityId, text(event, "orgUserId"), {
31
- postId: params.postId,
32
- commentId: params.commentId,
33
- spaceId: await spaceOfPost(deps, event, params.postId)
34
- }) },
35
- replyToYourComment: { place: async (event, { params }, deps) => at(params.communityId, text(event, "orgUserId"), {
36
- postId: params.postId,
37
- commentId: params.commentId,
38
- spaceId: await spaceOfPost(deps, event, params.postId)
39
- }) },
40
- yourPostWasPublished: { place: async (event, { params }) => at(params.communityId, actor(event), {
41
- postId: params.postId,
42
- spaceId: text(event, "spaceId")
43
- }) },
44
- yourPostWasRemoved: { place: async (event, { params }) => at(params.communityId, text(event, "removedBy"), {
45
- postId: text(event, "id"),
46
- spaceId: params.spaceId
47
- }) },
48
- yourCommentWasRemoved: { place: async (event, { params }, deps) => at(params.communityId, text(event, "removedBy"), {
49
- postId: params.postId,
50
- commentId: text(event, "id"),
51
- spaceId: await spaceOfPost(deps, event, params.postId)
52
- }) },
53
- requestApproved: { place: async (event, { params }) => at(params.communityId, actor(event), { spaceId: params.spaceId }) },
54
- requestDeclined: { place: async (event, { params }) => at(params.communityId, actor(event), { spaceId: text(event, "spaceId") }) },
55
- invitedToSpace: { place: async (event, { params }) => at(params.communityId, actor(event), { spaceId: params.spaceId }) },
56
- newMessage: { place: async (event, { params }) => at(params.communityId, text(event, "orgUserId"), {
57
- chatId: params.chatId,
58
- messageId: text(event, "id")
59
- }) },
60
- messageRequest: { place: async (event, { params }) => at(params.communityId, text(event, "createdBy"), { chatId: params.chatId }) },
61
- addedToGroupChat: { place: async (event, { params }) => at(params.communityId, text(event, "addedBy"), { chatId: params.chatId }) },
62
- youAreNowAModerator: { place: async (event) => at(null, actor(event), {}) },
63
- membershipEndingSoon: { place: async (_event, { params }) => at(params.communityId, null, {}) },
64
- welcomeToCommunity: { place: async (event, { params }) => at(params.communityId, actor(event), {}) },
65
- postAwaitingReview: { place: async (event, { params }) => at(params.communityId, text(event, "orgUserId"), {
66
- postId: text(event, "id"),
67
- spaceId: params.spaceId
68
- }) },
69
- joinRequest: { place: async (event, { params }) => at(params.communityId, text(event, "orgUserId"), { spaceId: params.spaceId }) },
70
- somethingWasFlagged: { place: async (event, { params }, deps) => {
71
- const commentId = text(event, "commentId");
72
- const postId = commentId ? (await deps.mail.comment(event.orgId, commentId))?.postId ?? null : text(event, "postId");
73
- return at(params.communityId, text(event, "orgUserId"), {
74
- spaceId: params.spaceId,
75
- postId,
76
- commentId
77
- });
78
- } },
79
- messageWasFlagged: { place: async (event, { params }) => at(params.communityId, text(event, "orgUserId"), { messageId: text(event, "messageId") }) }
80
- };
81
- //#endregion
82
- export { NOTIFICATION_PLACEMENTS };
83
-
84
- //# sourceMappingURL=community-notifications.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"community-notifications.js","names":[],"sources":["../../src/automations/community-notifications.ts"],"sourcesContent":["import type { NewNotification } from '../identity/index.js';\nimport type { NotificationKind } from '../types/index.js';\nimport type { DomainEvent } from '../shared/ports.js';\nimport { actorOf, type ActionDeps, type EmailRecipient } from './community-mail.js';\n\ntype Placement = Omit<NewNotification, 'userId' | 'kind'>;\n\nexport interface NotificationPlacement<K extends NotificationKind> {\n place(event: DomainEvent, recipient: EmailRecipient<K>, deps: ActionDeps): Promise<Placement[]>;\n}\n\ntype About = Partial<Pick<Placement, 'spaceId' | 'postId' | 'commentId' | 'chatId' | 'messageId'>>;\n\nfunction text(event: DomainEvent, key: string): string | null {\n if (typeof event.data !== 'object' || event.data === null) {\n return null;\n }\n const value = (event.data as Record<string, unknown>)[key];\n return typeof value === 'string' ? value : null;\n}\n\nfunction at(communityId: string | null, actorOrgUserId: string | null, about: About): Placement[] {\n return [\n {\n communityId,\n actorOrgUserId,\n spaceId: about.spaceId ?? null,\n postId: about.postId ?? null,\n commentId: about.commentId ?? null,\n chatId: about.chatId ?? null,\n messageId: about.messageId ?? null,\n },\n ];\n}\n\nfunction actor(event: DomainEvent): string | null {\n return actorOf(event) ?? null;\n}\n\nasync function spaceOfPost(\n deps: ActionDeps,\n event: DomainEvent,\n postId: string | null,\n): Promise<string | null> {\n return postId ? ((await deps.mail.post(event.orgId, postId))?.spaceId ?? null) : null;\n}\n\nexport const NOTIFICATION_PLACEMENTS: {\n [K in NotificationKind]: NotificationPlacement<K>;\n} = {\n newPostInSpace: {\n place: async (event, { params }) =>\n at(params.communityId, text(event, 'orgUserId'), {\n postId: params.postId,\n spaceId: text(event, 'spaceId'),\n }),\n },\n newCommentOnPost: {\n place: async (event, { params }, deps) =>\n at(params.communityId, text(event, 'orgUserId'), {\n postId: params.postId,\n commentId: params.commentId,\n spaceId: await spaceOfPost(deps, event, params.postId),\n }),\n },\n replyToYourComment: {\n place: async (event, { params }, deps) =>\n at(params.communityId, text(event, 'orgUserId'), {\n postId: params.postId,\n commentId: params.commentId,\n spaceId: await spaceOfPost(deps, event, params.postId),\n }),\n },\n yourPostWasPublished: {\n place: async (event, { params }) =>\n at(params.communityId, actor(event), {\n postId: params.postId,\n spaceId: text(event, 'spaceId'),\n }),\n },\n yourPostWasRemoved: {\n place: async (event, { params }) =>\n at(params.communityId, text(event, 'removedBy'), {\n postId: text(event, 'id'),\n spaceId: params.spaceId,\n }),\n },\n yourCommentWasRemoved: {\n place: async (event, { params }, deps) =>\n at(params.communityId, text(event, 'removedBy'), {\n postId: params.postId,\n commentId: text(event, 'id'),\n spaceId: await spaceOfPost(deps, event, params.postId),\n }),\n },\n requestApproved: {\n place: async (event, { params }) =>\n at(params.communityId, actor(event), { spaceId: params.spaceId }),\n },\n requestDeclined: {\n place: async (event, { params }) =>\n at(params.communityId, actor(event), { spaceId: text(event, 'spaceId') }),\n },\n invitedToSpace: {\n place: async (event, { params }) =>\n at(params.communityId, actor(event), { spaceId: params.spaceId }),\n },\n newMessage: {\n place: async (event, { params }) =>\n at(params.communityId, text(event, 'orgUserId'), {\n chatId: params.chatId,\n messageId: text(event, 'id'),\n }),\n },\n messageRequest: {\n place: async (event, { params }) =>\n at(params.communityId, text(event, 'createdBy'), { chatId: params.chatId }),\n },\n addedToGroupChat: {\n place: async (event, { params }) =>\n at(params.communityId, text(event, 'addedBy'), { chatId: params.chatId }),\n },\n youAreNowAModerator: {\n place: async (event) => at(null, actor(event), {}),\n },\n membershipEndingSoon: {\n place: async (_event, { params }) => at(params.communityId, null, {}),\n },\n welcomeToCommunity: {\n place: async (event, { params }) => at(params.communityId, actor(event), {}),\n },\n postAwaitingReview: {\n place: async (event, { params }) =>\n at(params.communityId, text(event, 'orgUserId'), {\n postId: text(event, 'id'),\n spaceId: params.spaceId,\n }),\n },\n joinRequest: {\n place: async (event, { params }) =>\n at(params.communityId, text(event, 'orgUserId'), { spaceId: params.spaceId }),\n },\n somethingWasFlagged: {\n place: async (event, { params }, deps) => {\n const commentId = text(event, 'commentId');\n const postId = commentId\n ? ((await deps.mail.comment(event.orgId, commentId))?.postId ?? null)\n : text(event, 'postId');\n return at(params.communityId, text(event, 'orgUserId'), {\n spaceId: params.spaceId,\n postId,\n commentId,\n });\n },\n },\n messageWasFlagged: {\n place: async (event, { params }) =>\n at(params.communityId, text(event, 'orgUserId'), { messageId: text(event, 'messageId') }),\n },\n};\n"],"mappings":";;AAaA,SAAS,KAAK,OAAoB,KAA4B;CAC5D,IAAI,OAAO,MAAM,SAAS,YAAY,MAAM,SAAS,MACnD,OAAO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,OAAO,OAAO,QAAQ,EAAE,aAAa,GAAG,OAAO,aAAa,MAAM,CAAC,CAAC,EACtE;CACA,oBAAoB,EAClB,OAAO,OAAO,OAAO,EAAE,aAAa,GAAG,OAAO,aAAa,MAAM,KAAK,GAAG,CAAC,CAAC,EAC7E;CACA,oBAAoB,EAClB,OAAO,OAAO,OAAO,EAAE,aACrB,GAAG,OAAO,aAAa,KAAK,OAAO,WAAW,GAAG;EAC/C,QAAQ,KAAK,OAAO,IAAI;EACxB,SAAS,OAAO;CAClB,CAAC,EACL;CACA,aAAa,EACX,OAAO,OAAO,OAAO,EAAE,aACrB,GAAG,OAAO,aAAa,KAAK,OAAO,WAAW,GAAG,EAAE,SAAS,OAAO,QAAQ,CAAC,EAChF;CACA,qBAAqB,EACnB,OAAO,OAAO,OAAO,EAAE,UAAU,SAAS;EACxC,MAAM,YAAY,KAAK,OAAO,WAAW;EACzC,MAAM,SAAS,aACT,MAAM,KAAK,KAAK,QAAQ,MAAM,OAAO,SAAS,EAAA,EAAI,UAAU,OAC9D,KAAK,OAAO,QAAQ;EACxB,OAAO,GAAG,OAAO,aAAa,KAAK,OAAO,WAAW,GAAG;GACtD,SAAS,OAAO;GAChB;GACA;EACF,CAAC;CACH,EACF;CACA,mBAAmB,EACjB,OAAO,OAAO,OAAO,EAAE,aACrB,GAAG,OAAO,aAAa,KAAK,OAAO,WAAW,GAAG,EAAE,WAAW,KAAK,OAAO,WAAW,EAAE,CAAC,EAC5F;AACF"}
@@ -1,17 +0,0 @@
1
- import { JsonValue } from "../types/shared.js";
2
- import { AutomationAction } from "../types/schemas/automations.js";
3
- import "../types/index.js";
4
- import "./model.js";
5
- //#region src/automations/seeds.d.ts
6
- interface SeedAutomation {
7
- name: string;
8
- description: string;
9
- triggers: string[];
10
- actions: AutomationAction[];
11
- filter: Record<string, JsonValue> | null;
12
- }
13
- declare function orgSeeds(): SeedAutomation[];
14
- declare function communitySeeds(communityId: string): SeedAutomation[];
15
- //#endregion
16
- export { SeedAutomation, communitySeeds, orgSeeds };
17
- //# sourceMappingURL=seeds.d.ts.map
@@ -1,235 +0,0 @@
1
- //#region src/automations/seeds.ts
2
- function email(template, communityId) {
3
- return {
4
- type: "sendEmail",
5
- input: communityId === void 0 ? { template } : {
6
- template,
7
- communityId
8
- }
9
- };
10
- }
11
- function notify(kind, communityId) {
12
- return {
13
- type: "notify",
14
- input: communityId === void 0 ? { kind } : {
15
- kind,
16
- communityId
17
- }
18
- };
19
- }
20
- function orgSeeds() {
21
- return [
22
- {
23
- name: "Access granted",
24
- description: "Email the person when they are granted a content item.",
25
- triggers: ["entitlement.created"],
26
- actions: [email("accessGranted")],
27
- filter: null
28
- },
29
- {
30
- name: "Access revoked",
31
- description: "Email the person when a content grant is deleted.",
32
- triggers: ["entitlement.deleted"],
33
- actions: [email("accessRevoked")],
34
- filter: null
35
- },
36
- {
37
- name: "You are now a moderator",
38
- description: "Notify the person when they are given the moderator role.",
39
- triggers: ["organization.user.updated"],
40
- actions: [notify("youAreNowAModerator")],
41
- filter: null
42
- },
43
- {
44
- name: "Publish due posts",
45
- description: "Submit scheduled posts whose time has passed.",
46
- triggers: ["schedule:* * * * *"],
47
- actions: [{
48
- type: "publishDuePosts",
49
- input: {}
50
- }],
51
- filter: null
52
- },
53
- {
54
- name: "Expire due grants",
55
- description: "Expire grants whose time has passed and remind those ending within a week.",
56
- triggers: ["schedule:0 * * * *"],
57
- actions: [{
58
- type: "expireDueGrants",
59
- input: {}
60
- }],
61
- filter: null
62
- },
63
- {
64
- name: "Send digest",
65
- description: "Open the daily digest for every community.",
66
- triggers: ["schedule:0 7 * * *"],
67
- actions: [{
68
- type: "sendDigest",
69
- input: {}
70
- }],
71
- filter: null
72
- },
73
- {
74
- name: "Remove unattached uploads",
75
- description: "Remove member uploads older than an hour that nothing references.",
76
- triggers: ["schedule:0 * * * *"],
77
- actions: [{
78
- type: "removeUnattachedUploads",
79
- input: {}
80
- }],
81
- filter: null
82
- },
83
- {
84
- name: "Welcome to the community",
85
- description: "Notify a person when a grant opens a community.",
86
- triggers: ["entitlement.created"],
87
- actions: [notify("welcomeToCommunity")],
88
- filter: null
89
- },
90
- {
91
- name: "Membership ended",
92
- description: "Email a person when a grant that opened a community ends.",
93
- triggers: ["entitlement.expired", "entitlement.deleted"],
94
- actions: [email("membershipEnded")],
95
- filter: null
96
- }
97
- ];
98
- }
99
- function communitySeeds(communityId) {
100
- const filter = { communityId };
101
- const scoped = (template) => email(template, communityId);
102
- const told = (kind) => notify(kind, communityId);
103
- return [
104
- {
105
- name: "Membership ending soon",
106
- description: "Notify a member a week before this community grant ends.",
107
- triggers: ["entitlement.ending_soon"],
108
- actions: [told("membershipEndingSoon")],
109
- filter: { communityId }
110
- },
111
- {
112
- name: "New post in a space",
113
- description: "Notify members who can open the space.",
114
- triggers: ["discussion.post.published"],
115
- actions: [told("newPostInSpace")],
116
- filter
117
- },
118
- {
119
- name: "Your post was published",
120
- description: "Notify the author when a pending post is published.",
121
- triggers: ["discussion.post.published"],
122
- actions: [told("yourPostWasPublished")],
123
- filter
124
- },
125
- {
126
- name: "Your post was removed",
127
- description: "Notify the author when someone else removes their post.",
128
- triggers: ["discussion.post.removed"],
129
- actions: [told("yourPostWasRemoved")],
130
- filter
131
- },
132
- {
133
- name: "New comment on a post you follow",
134
- description: "Notify the author and followers when a comment is published.",
135
- triggers: ["discussion.comment.created"],
136
- actions: [told("newCommentOnPost")],
137
- filter
138
- },
139
- {
140
- name: "Reply to your comment",
141
- description: "Notify the parent author when a reply is published.",
142
- triggers: ["discussion.comment.created"],
143
- actions: [told("replyToYourComment")],
144
- filter
145
- },
146
- {
147
- name: "Your comment was removed",
148
- description: "Notify the author when someone else removes their comment.",
149
- triggers: ["discussion.comment.removed"],
150
- actions: [told("yourCommentWasRemoved")],
151
- filter
152
- },
153
- {
154
- name: "Post awaiting review",
155
- description: "Notify staff and moderators when a post enters review.",
156
- triggers: ["discussion.post.created", "discussion.post.updated"],
157
- actions: [told("postAwaitingReview")],
158
- filter
159
- },
160
- {
161
- name: "Join request",
162
- description: "Notify staff and moderators when someone requests a space.",
163
- triggers: ["entitlement.space_member.created"],
164
- actions: [told("joinRequest")],
165
- filter
166
- },
167
- {
168
- name: "Request approved",
169
- description: "Notify the member when their request is approved.",
170
- triggers: ["entitlement.space_member.updated"],
171
- actions: [told("requestApproved")],
172
- filter
173
- },
174
- {
175
- name: "Request declined",
176
- description: "Notify the person when their request is declined.",
177
- triggers: ["entitlement.space_member.deleted"],
178
- actions: [told("requestDeclined")],
179
- filter
180
- },
181
- {
182
- name: "Invited to a space",
183
- description: "Notify the person when they are invited to a space.",
184
- triggers: ["entitlement.space_member.created"],
185
- actions: [told("invitedToSpace")],
186
- filter
187
- },
188
- {
189
- name: "New message",
190
- description: "Notify participants who are not muted, at most once per chat per 15 minutes.",
191
- triggers: ["discussion.message.sent"],
192
- actions: [told("newMessage")],
193
- filter
194
- },
195
- {
196
- name: "Message request",
197
- description: "Notify the recipient when a direct chat starts as a request.",
198
- triggers: ["discussion.chat.created"],
199
- actions: [told("messageRequest")],
200
- filter
201
- },
202
- {
203
- name: "Added to a group chat",
204
- description: "Notify the person added to a group chat.",
205
- triggers: ["discussion.chat.participant.added"],
206
- actions: [told("addedToGroupChat")],
207
- filter
208
- },
209
- {
210
- name: "Something was flagged",
211
- description: "Notify staff and moderators when a post or comment is flagged.",
212
- triggers: ["discussion.post.reported", "discussion.comment.reported"],
213
- actions: [told("somethingWasFlagged")],
214
- filter
215
- },
216
- {
217
- name: "A message was flagged",
218
- description: "Notify staff when a message is flagged.",
219
- triggers: ["discussion.message.reported"],
220
- actions: [told("messageWasFlagged")],
221
- filter
222
- },
223
- {
224
- name: "Digest",
225
- description: "Email members their unread activity. Not sent until email preferences exist.",
226
- triggers: ["discussion.digest.due"],
227
- actions: [scoped("digest")],
228
- filter
229
- }
230
- ];
231
- }
232
- //#endregion
233
- export { communitySeeds, orgSeeds };
234
-
235
- //# sourceMappingURL=seeds.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"seeds.js","names":[],"sources":["../../src/automations/seeds.ts"],"sourcesContent":["import type { JsonValue } from '../types/index.js';\nimport type { AutomationAction } from './model.js';\n\nexport interface SeedAutomation {\n name: string;\n description: string;\n triggers: string[];\n actions: AutomationAction[];\n filter: Record<string, JsonValue> | null;\n}\n\nfunction email(template: string, communityId?: string): AutomationAction {\n return {\n type: 'sendEmail',\n input: communityId === undefined ? { template } : { template, communityId },\n };\n}\n\nfunction notify(kind: string, communityId?: string): AutomationAction {\n return {\n type: 'notify',\n input: communityId === undefined ? { kind } : { kind, communityId },\n };\n}\n\nexport function orgSeeds(): SeedAutomation[] {\n return [\n {\n name: 'Access granted',\n description: 'Email the person when they are granted a content item.',\n triggers: ['entitlement.created'],\n actions: [email('accessGranted')],\n filter: null,\n },\n {\n name: 'Access revoked',\n description: 'Email the person when a content grant is deleted.',\n triggers: ['entitlement.deleted'],\n actions: [email('accessRevoked')],\n filter: null,\n },\n {\n name: 'You are now a moderator',\n description: 'Notify the person when they are given the moderator role.',\n triggers: ['organization.user.updated'],\n actions: [notify('youAreNowAModerator')],\n filter: null,\n },\n {\n name: 'Publish due posts',\n description: 'Submit scheduled posts whose time has passed.',\n triggers: ['schedule:* * * * *'],\n actions: [{ type: 'publishDuePosts', input: {} }],\n filter: null,\n },\n {\n name: 'Expire due grants',\n description: 'Expire grants whose time has passed and remind those ending within a week.',\n triggers: ['schedule:0 * * * *'],\n actions: [{ type: 'expireDueGrants', input: {} }],\n filter: null,\n },\n {\n name: 'Send digest',\n description: 'Open the daily digest for every community.',\n triggers: ['schedule:0 7 * * *'],\n actions: [{ type: 'sendDigest', input: {} }],\n filter: null,\n },\n {\n name: 'Remove unattached uploads',\n description: 'Remove member uploads older than an hour that nothing references.',\n triggers: ['schedule:0 * * * *'],\n actions: [{ type: 'removeUnattachedUploads', input: {} }],\n filter: null,\n },\n {\n name: 'Welcome to the community',\n description: 'Notify a person when a grant opens a community.',\n triggers: ['entitlement.created'],\n actions: [notify('welcomeToCommunity')],\n filter: null,\n },\n {\n name: 'Membership ended',\n description: 'Email a person when a grant that opened a community ends.',\n triggers: ['entitlement.expired', 'entitlement.deleted'],\n actions: [email('membershipEnded')],\n filter: null,\n },\n ];\n}\n\nexport function communitySeeds(communityId: string): SeedAutomation[] {\n const filter = { communityId };\n const scoped = (template: string): AutomationAction => email(template, communityId);\n const told = (kind: string): AutomationAction => notify(kind, communityId);\n return [\n {\n name: 'Membership ending soon',\n description: 'Notify a member a week before this community grant ends.',\n triggers: ['entitlement.ending_soon'],\n actions: [told('membershipEndingSoon')],\n filter: { communityId },\n },\n {\n name: 'New post in a space',\n description: 'Notify members who can open the space.',\n triggers: ['discussion.post.published'],\n actions: [told('newPostInSpace')],\n filter,\n },\n {\n name: 'Your post was published',\n description: 'Notify the author when a pending post is published.',\n triggers: ['discussion.post.published'],\n actions: [told('yourPostWasPublished')],\n filter,\n },\n {\n name: 'Your post was removed',\n description: 'Notify the author when someone else removes their post.',\n triggers: ['discussion.post.removed'],\n actions: [told('yourPostWasRemoved')],\n filter,\n },\n {\n name: 'New comment on a post you follow',\n description: 'Notify the author and followers when a comment is published.',\n triggers: ['discussion.comment.created'],\n actions: [told('newCommentOnPost')],\n filter,\n },\n {\n name: 'Reply to your comment',\n description: 'Notify the parent author when a reply is published.',\n triggers: ['discussion.comment.created'],\n actions: [told('replyToYourComment')],\n filter,\n },\n {\n name: 'Your comment was removed',\n description: 'Notify the author when someone else removes their comment.',\n triggers: ['discussion.comment.removed'],\n actions: [told('yourCommentWasRemoved')],\n filter,\n },\n {\n name: 'Post awaiting review',\n description: 'Notify staff and moderators when a post enters review.',\n triggers: ['discussion.post.created', 'discussion.post.updated'],\n actions: [told('postAwaitingReview')],\n filter,\n },\n {\n name: 'Join request',\n description: 'Notify staff and moderators when someone requests a space.',\n triggers: ['entitlement.space_member.created'],\n actions: [told('joinRequest')],\n filter,\n },\n {\n name: 'Request approved',\n description: 'Notify the member when their request is approved.',\n triggers: ['entitlement.space_member.updated'],\n actions: [told('requestApproved')],\n filter,\n },\n {\n name: 'Request declined',\n description: 'Notify the person when their request is declined.',\n triggers: ['entitlement.space_member.deleted'],\n actions: [told('requestDeclined')],\n filter,\n },\n {\n name: 'Invited to a space',\n description: 'Notify the person when they are invited to a space.',\n triggers: ['entitlement.space_member.created'],\n actions: [told('invitedToSpace')],\n filter,\n },\n {\n name: 'New message',\n description: 'Notify participants who are not muted, at most once per chat per 15 minutes.',\n triggers: ['discussion.message.sent'],\n actions: [told('newMessage')],\n filter,\n },\n {\n name: 'Message request',\n description: 'Notify the recipient when a direct chat starts as a request.',\n triggers: ['discussion.chat.created'],\n actions: [told('messageRequest')],\n filter,\n },\n {\n name: 'Added to a group chat',\n description: 'Notify the person added to a group chat.',\n triggers: ['discussion.chat.participant.added'],\n actions: [told('addedToGroupChat')],\n filter,\n },\n {\n name: 'Something was flagged',\n description: 'Notify staff and moderators when a post or comment is flagged.',\n triggers: ['discussion.post.reported', 'discussion.comment.reported'],\n actions: [told('somethingWasFlagged')],\n filter,\n },\n {\n name: 'A message was flagged',\n description: 'Notify staff when a message is flagged.',\n triggers: ['discussion.message.reported'],\n actions: [told('messageWasFlagged')],\n filter,\n },\n {\n name: 'Digest',\n description: 'Email members their unread activity. Not sent until email preferences exist.',\n triggers: ['discussion.digest.due'],\n actions: [scoped('digest')],\n filter,\n },\n ];\n}\n"],"mappings":";AAWA,SAAS,MAAM,UAAkB,aAAwC;CACvE,OAAO;EACL,MAAM;EACN,OAAO,gBAAgB,KAAA,IAAY,EAAE,SAAS,IAAI;GAAE;GAAU;EAAY;CAC5E;AACF;AAEA,SAAS,OAAO,MAAc,aAAwC;CACpE,OAAO;EACL,MAAM;EACN,OAAO,gBAAgB,KAAA,IAAY,EAAE,KAAK,IAAI;GAAE;GAAM;EAAY;CACpE;AACF;AAEA,SAAgB,WAA6B;CAC3C,OAAO;EACL;GACE,MAAM;GACN,aAAa;GACb,UAAU,CAAC,qBAAqB;GAChC,SAAS,CAAC,MAAM,e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ACpC,SAAS,CAAC,KAAK,YAAY,CAAC;GAC5B;EACF;EACA;GACE,MAAM;GACN,aAAa;GACb,UAAU,CAAC,yBAAyB;GACpC,SAAS,CAAC,KAAK,gBAAgB,CAAC;GAChC;EACF;EACA;GACE,MAAM;GACN,aAAa;GACb,UAAU,CAAC,mCAAmC;GAC9C,SAAS,CAAC,KAAK,kBAAkB,CAAC;GAClC;EACF;EACA;GACE,MAAM;GACN,aAAa;GACb,UAAU,CAAC,4BAA4B,6BAA6B;GACpE,SAAS,CAAC,KAAK,qBAAqB,CAAC;GACrC;EACF;EACA;GACE,MAAM;GACN,aAAa;GACb,UAAU,CAAC,6BAA6B;GACxC,SAAS,CAAC,KAAK,mBAAmB,CAAC;GACnC;EACF;EACA;GACE,MAAM;GACN,aAAa;GACb,UAAU,CAAC,uBAAuB;GAClC,SAAS,CAAC,OAAO,QAAQ,CAAC;GAC1B;EACF;CACF;AACF"}
@@ -1,27 +0,0 @@
1
- import { Logger } from "../types/ports.js";
2
- import { Notification, NotificationKind, NotificationPreference } from "../types/schemas/identity.js";
3
- import "../shared/ports.js";
4
- import "./model.js";
5
- import { NewNotification, NotificationPage, NotificationService, NotificationsQuery, NotificationsRepository } from "./ports.js";
6
- //#region src/identity/notifications.d.ts
7
- declare function defaultPreference(kind: NotificationKind): NotificationPreference;
8
- declare class NotificationServiceImpl implements NotificationService {
9
- private readonly repo;
10
- private readonly logger;
11
- constructor(params: {
12
- repo: NotificationsRepository;
13
- logger?: Logger;
14
- });
15
- notify(orgId: string, notifications: NewNotification[]): Promise<void>;
16
- preferencesFor(orgId: string, userIds: string[], kind: NotificationKind): Promise<Record<string, NotificationPreference>>;
17
- listNotifications(orgId: string, userId: string, query: NotificationsQuery): Promise<NotificationPage>;
18
- markNotificationRead(orgId: string, userId: string, notificationId: string): Promise<Notification>;
19
- markAllNotificationsRead(orgId: string, userId: string): Promise<{
20
- updated: number;
21
- }>;
22
- notificationPreferences(orgId: string, userId: string): Promise<NotificationPreference[]>;
23
- setNotificationPreferences(orgId: string, userId: string, preferences: NotificationPreference[]): Promise<NotificationPreference[]>;
24
- }
25
- //#endregion
26
- export { NotificationServiceImpl, defaultPreference };
27
- //# sourceMappingURL=notifications.d.ts.map