@headless-lms/core 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (307) hide show
  1. package/dist/assets/events.d.ts +42 -24
  2. package/dist/assets/events.js +1 -1
  3. package/dist/assets/events.js.map +1 -1
  4. package/dist/assets/file-urls.d.ts +20 -0
  5. package/dist/assets/file-urls.js +25 -0
  6. package/dist/assets/file-urls.js.map +1 -0
  7. package/dist/assets/index.d.ts +6 -4
  8. package/dist/assets/index.js +4 -2
  9. package/dist/assets/jobs.d.ts +15 -0
  10. package/dist/assets/jobs.js +30 -0
  11. package/dist/assets/jobs.js.map +1 -0
  12. package/dist/assets/model.d.ts +2 -2
  13. package/dist/assets/ports.d.ts +46 -15
  14. package/dist/assets/service.d.ts +38 -7
  15. package/dist/assets/service.js +287 -38
  16. package/dist/assets/service.js.map +1 -1
  17. package/dist/automations/actions.d.ts +13 -24
  18. package/dist/automations/actions.js +106 -42
  19. package/dist/automations/actions.js.map +1 -1
  20. package/dist/automations/catalog.js +226 -3
  21. package/dist/automations/catalog.js.map +1 -1
  22. package/dist/automations/community-derivations.d.ts +14 -0
  23. package/dist/automations/community-derivations.js +439 -0
  24. package/dist/automations/community-derivations.js.map +1 -0
  25. package/dist/automations/community-mail.d.ts +98 -0
  26. package/dist/automations/community-mail.js +70 -0
  27. package/dist/automations/community-mail.js.map +1 -0
  28. package/dist/automations/events.d.ts +18 -0
  29. package/dist/automations/index.d.ts +13 -4
  30. package/dist/automations/index.js +10 -2
  31. package/dist/automations/model.d.ts +10 -3
  32. package/dist/automations/model.js +15 -2
  33. package/dist/automations/model.js.map +1 -1
  34. package/dist/automations/notifications/debounce.d.ts +25 -0
  35. package/dist/automations/notifications/debounce.js +93 -0
  36. package/dist/automations/notifications/debounce.js.map +1 -0
  37. package/dist/automations/notifications/defaults.d.ts +8 -0
  38. package/dist/automations/notifications/defaults.js +316 -0
  39. package/dist/automations/notifications/defaults.js.map +1 -0
  40. package/dist/automations/notifications/delivery.d.ts +28 -0
  41. package/dist/automations/notifications/delivery.js +88 -0
  42. package/dist/automations/notifications/delivery.js.map +1 -0
  43. package/dist/automations/notifications/processor.d.ts +64 -0
  44. package/dist/automations/notifications/processor.js +270 -0
  45. package/dist/automations/notifications/processor.js.map +1 -0
  46. package/dist/automations/notifications/rules/content.d.ts +6 -0
  47. package/dist/automations/notifications/rules/content.js +39 -0
  48. package/dist/automations/notifications/rules/content.js.map +1 -0
  49. package/dist/automations/notifications/rules/discussion.d.ts +7 -0
  50. package/dist/automations/notifications/rules/discussion.js +678 -0
  51. package/dist/automations/notifications/rules/discussion.js.map +1 -0
  52. package/dist/automations/notifications/rules/entitlements.d.ts +6 -0
  53. package/dist/automations/notifications/rules/entitlements.js +249 -0
  54. package/dist/automations/notifications/rules/entitlements.js.map +1 -0
  55. package/dist/automations/notifications/rules/index.d.ts +6 -0
  56. package/dist/automations/notifications/rules/index.js +15 -0
  57. package/dist/automations/notifications/rules/index.js.map +1 -0
  58. package/dist/automations/notifications/rules/organizations.d.ts +6 -0
  59. package/dist/automations/notifications/rules/organizations.js +28 -0
  60. package/dist/automations/notifications/rules/organizations.js.map +1 -0
  61. package/dist/automations/notifications/rules/recipients.d.ts +32 -0
  62. package/dist/automations/notifications/rules/recipients.js +99 -0
  63. package/dist/automations/notifications/rules/recipients.js.map +1 -0
  64. package/dist/automations/notifications/service.d.ts +27 -0
  65. package/dist/automations/notifications/service.js +45 -0
  66. package/dist/automations/notifications/service.js.map +1 -0
  67. package/dist/automations/notifications/types.d.ts +7 -0
  68. package/dist/automations/notifications/types.js +473 -0
  69. package/dist/automations/notifications/types.js.map +1 -0
  70. package/dist/automations/ports.d.ts +121 -3
  71. package/dist/automations/schedule.d.ts +6 -0
  72. package/dist/automations/schedule.js +41 -0
  73. package/dist/automations/schedule.js.map +1 -0
  74. package/dist/automations/service.d.ts +20 -4
  75. package/dist/automations/service.js +246 -45
  76. package/dist/automations/service.js.map +1 -1
  77. package/dist/content/events.d.ts +712 -50
  78. package/dist/content/events.js +55 -1
  79. package/dist/content/events.js.map +1 -1
  80. package/dist/content/index.d.ts +6 -4
  81. package/dist/content/index.js +3 -1
  82. package/dist/content/model.d.ts +2 -2
  83. package/dist/content/notification-categories.d.ts +36 -0
  84. package/dist/content/notification-categories.js +64 -0
  85. package/dist/content/notification-categories.js.map +1 -0
  86. package/dist/content/ports.d.ts +90 -18
  87. package/dist/content/service.d.ts +57 -18
  88. package/dist/content/service.js +520 -25
  89. package/dist/content/service.js.map +1 -1
  90. package/dist/content/titles.d.ts +22 -0
  91. package/dist/content/titles.js +69 -0
  92. package/dist/content/titles.js.map +1 -0
  93. package/dist/content/types.d.ts +2 -2
  94. package/dist/discussion/authors.d.ts +10 -0
  95. package/dist/discussion/authors.js +23 -0
  96. package/dist/discussion/authors.js.map +1 -0
  97. package/dist/discussion/chats.d.ts +109 -0
  98. package/dist/discussion/chats.js +831 -0
  99. package/dist/discussion/chats.js.map +1 -0
  100. package/dist/discussion/digests.d.ts +24 -0
  101. package/dist/discussion/digests.js +104 -0
  102. package/dist/discussion/digests.js.map +1 -0
  103. package/dist/discussion/events.d.ts +785 -56
  104. package/dist/discussion/events.js +165 -5
  105. package/dist/discussion/events.js.map +1 -1
  106. package/dist/discussion/index.d.ts +12 -3
  107. package/dist/discussion/index.js +9 -1
  108. package/dist/discussion/jobs.d.ts +16 -0
  109. package/dist/discussion/jobs.js +40 -0
  110. package/dist/discussion/jobs.js.map +1 -0
  111. package/dist/discussion/mentions.d.ts +11 -0
  112. package/dist/discussion/mentions.js +35 -0
  113. package/dist/discussion/mentions.js.map +1 -0
  114. package/dist/discussion/ports.d.ts +372 -28
  115. package/dist/discussion/ports.js +6 -1
  116. package/dist/discussion/ports.js.map +1 -0
  117. package/dist/discussion/posts.d.ts +113 -0
  118. package/dist/discussion/posts.js +775 -0
  119. package/dist/discussion/posts.js.map +1 -0
  120. package/dist/discussion/service.d.ts +42 -11
  121. package/dist/discussion/service.js +364 -85
  122. package/dist/discussion/service.js.map +1 -1
  123. package/dist/discussion/subscriptions.d.ts +37 -0
  124. package/dist/discussion/subscriptions.js +99 -0
  125. package/dist/discussion/subscriptions.js.map +1 -0
  126. package/dist/discussion/titles.d.ts +26 -0
  127. package/dist/discussion/titles.js +84 -0
  128. package/dist/discussion/titles.js.map +1 -0
  129. package/dist/entitlements/events.d.ts +178 -11
  130. package/dist/entitlements/events.js +28 -1
  131. package/dist/entitlements/events.js.map +1 -1
  132. package/dist/entitlements/index.d.ts +6 -4
  133. package/dist/entitlements/index.js +3 -1
  134. package/dist/entitlements/jobs.d.ts +12 -0
  135. package/dist/entitlements/jobs.js +18 -0
  136. package/dist/entitlements/jobs.js.map +1 -0
  137. package/dist/entitlements/model.d.ts +3 -2
  138. package/dist/entitlements/ports.d.ts +128 -11
  139. package/dist/entitlements/rules.d.ts +12 -0
  140. package/dist/entitlements/rules.js +17 -0
  141. package/dist/entitlements/rules.js.map +1 -0
  142. package/dist/entitlements/service.d.ts +57 -3
  143. package/dist/entitlements/service.js +492 -2
  144. package/dist/entitlements/service.js.map +1 -1
  145. package/dist/identity/access.d.ts +6 -0
  146. package/dist/identity/access.js +7 -0
  147. package/dist/identity/access.js.map +1 -0
  148. package/dist/identity/devices.d.ts +30 -0
  149. package/dist/identity/devices.js +107 -0
  150. package/dist/identity/devices.js.map +1 -0
  151. package/dist/identity/events.d.ts +2 -2
  152. package/dist/identity/index.d.ts +7 -4
  153. package/dist/identity/index.js +4 -1
  154. package/dist/identity/model.d.ts +2 -1
  155. package/dist/identity/notification-settings.d.ts +28 -0
  156. package/dist/identity/notification-settings.js +113 -0
  157. package/dist/identity/notification-settings.js.map +1 -0
  158. package/dist/identity/ports.d.ts +97 -3
  159. package/dist/identity/service.d.ts +14 -3
  160. package/dist/identity/service.js +62 -5
  161. package/dist/identity/service.js.map +1 -1
  162. package/dist/integrations/events.d.ts +3 -3
  163. package/dist/integrations/model.js +1 -1
  164. package/dist/integrations/model.js.map +1 -1
  165. package/dist/integrations/service.js +2 -2
  166. package/dist/integrations/service.js.map +1 -1
  167. package/dist/organizations/access-scopes.d.ts +19 -0
  168. package/dist/organizations/access-scopes.js +89 -0
  169. package/dist/organizations/access-scopes.js.map +1 -0
  170. package/dist/organizations/events.d.ts +75 -33
  171. package/dist/organizations/events.js +6 -0
  172. package/dist/organizations/events.js.map +1 -1
  173. package/dist/organizations/index.d.ts +8 -6
  174. package/dist/organizations/index.js +5 -3
  175. package/dist/organizations/members.d.ts +8 -5
  176. package/dist/organizations/members.js.map +1 -1
  177. package/dist/organizations/notification-categories.d.ts +32 -0
  178. package/dist/organizations/notification-categories.js +51 -0
  179. package/dist/organizations/notification-categories.js.map +1 -0
  180. package/dist/organizations/ports.d.ts +17 -11
  181. package/dist/organizations/roles.d.ts +6 -10
  182. package/dist/organizations/roles.js +19 -7
  183. package/dist/organizations/roles.js.map +1 -1
  184. package/dist/organizations/service.d.ts +22 -11
  185. package/dist/organizations/service.js +164 -47
  186. package/dist/organizations/service.js.map +1 -1
  187. package/dist/organizations/types.d.ts +1 -10
  188. package/dist/progress/events.d.ts +14 -14
  189. package/dist/progress/index.d.ts +2 -2
  190. package/dist/progress/ports.d.ts +6 -1
  191. package/dist/progress/service.d.ts +3 -1
  192. package/dist/progress/service.js +6 -2
  193. package/dist/progress/service.js.map +1 -1
  194. package/dist/reporting/admin/index.d.ts +4 -0
  195. package/dist/reporting/admin/index.js +2 -0
  196. package/dist/reporting/admin/model.d.ts +108 -0
  197. package/dist/reporting/admin/ports.d.ts +27 -0
  198. package/dist/reporting/admin/service.d.ts +22 -0
  199. package/dist/reporting/admin/service.js +38 -0
  200. package/dist/reporting/admin/service.js.map +1 -0
  201. package/dist/reporting/member/index.d.ts +5 -0
  202. package/dist/reporting/member/index.js +2 -0
  203. package/dist/reporting/member/model.d.ts +157 -0
  204. package/dist/reporting/member/ports.d.ts +48 -0
  205. package/dist/reporting/member/service.d.ts +92 -0
  206. package/dist/reporting/member/service.js +364 -0
  207. package/dist/reporting/member/service.js.map +1 -0
  208. package/dist/shared/actor.d.ts +9 -0
  209. package/dist/shared/errors.d.ts +19 -1
  210. package/dist/shared/errors.js +27 -1
  211. package/dist/shared/errors.js.map +1 -1
  212. package/dist/shared/id.d.ts +14 -0
  213. package/dist/shared/id.js +15 -1
  214. package/dist/shared/id.js.map +1 -1
  215. package/dist/shared/mailer.d.ts +15 -2
  216. package/dist/shared/mailer.js +32 -5
  217. package/dist/shared/mailer.js.map +1 -1
  218. package/dist/shared/network.d.ts +10 -0
  219. package/dist/shared/network.js +211 -0
  220. package/dist/shared/network.js.map +1 -0
  221. package/dist/shared/notification-categories.d.ts +16 -0
  222. package/dist/shared/notification-categories.js +94 -0
  223. package/dist/shared/notification-categories.js.map +1 -0
  224. package/dist/shared/notification-settings.d.ts +14 -0
  225. package/dist/shared/notification-settings.js +61 -0
  226. package/dist/shared/notification-settings.js.map +1 -0
  227. package/dist/shared/ports.d.ts +48 -2
  228. package/dist/shared/settings.d.ts +2 -1
  229. package/dist/shared/settings.js +1 -0
  230. package/dist/shared/settings.js.map +1 -1
  231. package/dist/types/assets.d.ts +2 -2
  232. package/dist/types/automations.d.ts +15 -1
  233. package/dist/types/content.d.ts +2 -2
  234. package/dist/types/discussion.d.ts +11 -3
  235. package/dist/types/email-templates.d.ts +216 -1
  236. package/dist/types/entitlements.d.ts +2 -2
  237. package/dist/types/identity.d.ts +48 -2
  238. package/dist/types/index.d.ts +9 -8
  239. package/dist/types/notifications.d.ts +157 -0
  240. package/dist/types/ports.d.ts +6 -0
  241. package/dist/types/schemas/assets.d.ts +65 -37
  242. package/dist/types/schemas/assets.js +17 -12
  243. package/dist/types/schemas/assets.js.map +1 -1
  244. package/dist/types/schemas/automations.d.ts +9 -1
  245. package/dist/types/schemas/automations.js +13 -6
  246. package/dist/types/schemas/automations.js.map +1 -1
  247. package/dist/types/schemas/content.d.ts +396 -3
  248. package/dist/types/schemas/content.js +161 -3
  249. package/dist/types/schemas/content.js.map +1 -1
  250. package/dist/types/schemas/discussion.d.ts +443 -3
  251. package/dist/types/schemas/discussion.js +233 -4
  252. package/dist/types/schemas/discussion.js.map +1 -1
  253. package/dist/types/schemas/entitlements.d.ts +36 -2
  254. package/dist/types/schemas/entitlements.js +23 -1
  255. package/dist/types/schemas/entitlements.js.map +1 -1
  256. package/dist/types/schemas/identity.d.ts +27 -1
  257. package/dist/types/schemas/identity.js +14 -2
  258. package/dist/types/schemas/identity.js.map +1 -1
  259. package/dist/types/schemas/index.d.ts +9 -8
  260. package/dist/types/schemas/index.js +9 -8
  261. package/dist/types/schemas/notifications.d.ts +95 -0
  262. package/dist/types/schemas/notifications.js +56 -0
  263. package/dist/types/schemas/notifications.js.map +1 -0
  264. package/dist/types/schemas/organizations.d.ts +8 -0
  265. package/dist/types/schemas/organizations.js +2 -0
  266. package/dist/types/schemas/organizations.js.map +1 -1
  267. package/dist/types/schemas/progress.d.ts +3 -3
  268. package/dist/types/schemas/shared.d.ts +3 -1
  269. package/dist/types/schemas/shared.js +5 -1
  270. package/dist/types/schemas/shared.js.map +1 -1
  271. package/package.json +2 -2
  272. package/dist/reporting/courses/index.d.ts +0 -4
  273. package/dist/reporting/courses/index.js +0 -2
  274. package/dist/reporting/courses/model.d.ts +0 -24
  275. package/dist/reporting/courses/ports.d.ts +0 -13
  276. package/dist/reporting/courses/service.d.ts +0 -19
  277. package/dist/reporting/courses/service.js +0 -20
  278. package/dist/reporting/courses/service.js.map +0 -1
  279. package/dist/reporting/dashboard/index.d.ts +0 -4
  280. package/dist/reporting/dashboard/index.js +0 -2
  281. package/dist/reporting/dashboard/model.d.ts +0 -14
  282. package/dist/reporting/dashboard/ports.d.ts +0 -13
  283. package/dist/reporting/dashboard/service.d.ts +0 -19
  284. package/dist/reporting/dashboard/service.js +0 -20
  285. package/dist/reporting/dashboard/service.js.map +0 -1
  286. package/dist/reporting/learn/index.d.ts +0 -5
  287. package/dist/reporting/learn/index.js +0 -2
  288. package/dist/reporting/learn/model.d.ts +0 -23
  289. package/dist/reporting/learn/ports.d.ts +0 -43
  290. package/dist/reporting/learn/service.d.ts +0 -49
  291. package/dist/reporting/learn/service.js +0 -116
  292. package/dist/reporting/learn/service.js.map +0 -1
  293. package/dist/reporting/students/index.d.ts +0 -4
  294. package/dist/reporting/students/index.js +0 -2
  295. package/dist/reporting/students/model.d.ts +0 -51
  296. package/dist/reporting/students/model.js +0 -1
  297. package/dist/reporting/students/ports.d.ts +0 -15
  298. package/dist/reporting/students/ports.js +0 -1
  299. package/dist/reporting/students/service.d.ts +0 -20
  300. package/dist/reporting/students/service.js +0 -23
  301. package/dist/reporting/students/service.js.map +0 -1
  302. /package/dist/reporting/{courses → admin}/model.js +0 -0
  303. /package/dist/reporting/{courses → admin}/ports.js +0 -0
  304. /package/dist/reporting/{dashboard → member}/model.js +0 -0
  305. /package/dist/reporting/{dashboard → member}/ports.js +0 -0
  306. /package/dist/{reporting/learn/model.js → shared/actor.js} +0 -0
  307. /package/dist/{reporting/learn/ports.js → types/notifications.js} +0 -0
@@ -27,18 +27,18 @@ declare const entitlementEvents: {
27
27
  createdAt: unknown;
28
28
  updatedAt: unknown;
29
29
  }, import("zod").ZodObject<{
30
- orgId: import("zod").ZodString;
31
30
  id: import("zod").ZodString;
31
+ orgId: import("zod").ZodString;
32
+ orgUserId: import("zod").ZodString;
32
33
  createdAt: import("zod").ZodCoercedDate<unknown>;
33
34
  updatedAt: import("zod").ZodCoercedDate<unknown>;
35
+ source: import("zod").ZodString;
34
36
  status: import("zod").ZodEnum<{
35
37
  active: "active";
36
38
  revoked: "revoked";
37
39
  }>;
38
40
  bundleId: import("zod").ZodNullable<import("zod").ZodString>;
39
41
  contentId: import("zod").ZodNullable<import("zod").ZodString>;
40
- orgUserId: import("zod").ZodString;
41
- source: import("zod").ZodString;
42
42
  grantedAt: import("zod").ZodCoercedDate<unknown>;
43
43
  expiresAt: import("zod").ZodNullable<import("zod").ZodCoercedDate<unknown>>;
44
44
  }, import("zod/v4/core").$strip>>;
@@ -67,18 +67,18 @@ declare const entitlementEvents: {
67
67
  createdAt: unknown;
68
68
  updatedAt: unknown;
69
69
  }, import("zod").ZodObject<{
70
- orgId: import("zod").ZodString;
71
70
  id: import("zod").ZodString;
71
+ orgId: import("zod").ZodString;
72
+ orgUserId: import("zod").ZodString;
72
73
  createdAt: import("zod").ZodCoercedDate<unknown>;
73
74
  updatedAt: import("zod").ZodCoercedDate<unknown>;
75
+ source: import("zod").ZodString;
74
76
  status: import("zod").ZodEnum<{
75
77
  active: "active";
76
78
  revoked: "revoked";
77
79
  }>;
78
80
  bundleId: import("zod").ZodNullable<import("zod").ZodString>;
79
81
  contentId: import("zod").ZodNullable<import("zod").ZodString>;
80
- orgUserId: import("zod").ZodString;
81
- source: import("zod").ZodString;
82
82
  grantedAt: import("zod").ZodCoercedDate<unknown>;
83
83
  expiresAt: import("zod").ZodNullable<import("zod").ZodCoercedDate<unknown>>;
84
84
  }, import("zod/v4/core").$strip>>;
@@ -107,18 +107,18 @@ declare const entitlementEvents: {
107
107
  createdAt: unknown;
108
108
  updatedAt: unknown;
109
109
  }, import("zod").ZodObject<{
110
- orgId: import("zod").ZodString;
111
110
  id: import("zod").ZodString;
111
+ orgId: import("zod").ZodString;
112
+ orgUserId: import("zod").ZodString;
112
113
  createdAt: import("zod").ZodCoercedDate<unknown>;
113
114
  updatedAt: import("zod").ZodCoercedDate<unknown>;
115
+ source: import("zod").ZodString;
114
116
  status: import("zod").ZodEnum<{
115
117
  active: "active";
116
118
  revoked: "revoked";
117
119
  }>;
118
120
  bundleId: import("zod").ZodNullable<import("zod").ZodString>;
119
121
  contentId: import("zod").ZodNullable<import("zod").ZodString>;
120
- orgUserId: import("zod").ZodString;
121
- source: import("zod").ZodString;
122
122
  grantedAt: import("zod").ZodCoercedDate<unknown>;
123
123
  expiresAt: import("zod").ZodNullable<import("zod").ZodCoercedDate<unknown>>;
124
124
  }, import("zod/v4/core").$strip>>;
@@ -147,27 +147,194 @@ declare const entitlementEvents: {
147
147
  createdAt: unknown;
148
148
  updatedAt: unknown;
149
149
  }, import("zod").ZodObject<{
150
- orgId: import("zod").ZodString;
151
150
  id: import("zod").ZodString;
151
+ orgId: import("zod").ZodString;
152
+ orgUserId: import("zod").ZodString;
152
153
  createdAt: import("zod").ZodCoercedDate<unknown>;
153
154
  updatedAt: import("zod").ZodCoercedDate<unknown>;
155
+ source: import("zod").ZodString;
154
156
  status: import("zod").ZodEnum<{
155
157
  active: "active";
156
158
  revoked: "revoked";
157
159
  }>;
158
160
  bundleId: import("zod").ZodNullable<import("zod").ZodString>;
159
161
  contentId: import("zod").ZodNullable<import("zod").ZodString>;
162
+ grantedAt: import("zod").ZodCoercedDate<unknown>;
163
+ expiresAt: import("zod").ZodNullable<import("zod").ZodCoercedDate<unknown>>;
164
+ }, import("zod/v4/core").$strip>>;
165
+ entitlementEndingSoon: RuntimeEventDefinition<VersionedDomainEvent<{
166
+ orgId: string;
167
+ id: string;
168
+ orgUserId: string;
169
+ bundleId: string | null;
170
+ contentId: string | null;
171
+ status: "active" | "revoked";
172
+ source: string;
173
+ grantedAt: Date;
174
+ expiresAt: Date | null;
175
+ createdAt: Date;
176
+ updatedAt: Date;
177
+ communityId: string;
178
+ }, "entitlement.ending_soon", 1>, {
179
+ orgId: string;
180
+ id: string;
181
+ orgUserId: string;
182
+ bundleId: string | null;
183
+ contentId: string | null;
184
+ status: "active" | "revoked";
185
+ source: string;
186
+ grantedAt: unknown;
187
+ expiresAt: unknown;
188
+ createdAt: unknown;
189
+ updatedAt: unknown;
190
+ communityId: string;
191
+ }, import("zod").ZodObject<{
192
+ id: import("zod").ZodString;
193
+ orgId: import("zod").ZodString;
160
194
  orgUserId: import("zod").ZodString;
195
+ createdAt: import("zod").ZodCoercedDate<unknown>;
196
+ updatedAt: import("zod").ZodCoercedDate<unknown>;
161
197
  source: import("zod").ZodString;
198
+ status: import("zod").ZodEnum<{
199
+ active: "active";
200
+ revoked: "revoked";
201
+ }>;
202
+ bundleId: import("zod").ZodNullable<import("zod").ZodString>;
203
+ contentId: import("zod").ZodNullable<import("zod").ZodString>;
162
204
  grantedAt: import("zod").ZodCoercedDate<unknown>;
163
205
  expiresAt: import("zod").ZodNullable<import("zod").ZodCoercedDate<unknown>>;
206
+ communityId: import("zod").ZodString;
164
207
  }, import("zod/v4/core").$strip>>;
208
+ spaceMemberCreated: RuntimeEventDefinition<VersionedDomainEvent<{
209
+ orgId: string;
210
+ id: string;
211
+ communityId: string;
212
+ spaceId: string;
213
+ orgUserId: string;
214
+ status: "active" | "revoked" | "requested" | "invited";
215
+ source: "request" | "invite" | "manual";
216
+ createdAt: Date;
217
+ updatedAt: Date;
218
+ }, "entitlement.space_member.created", 1>, {
219
+ orgId: string;
220
+ id: string;
221
+ communityId: string;
222
+ spaceId: string;
223
+ orgUserId: string;
224
+ status: "active" | "revoked" | "requested" | "invited";
225
+ source: "request" | "invite" | "manual";
226
+ createdAt: unknown;
227
+ updatedAt: unknown;
228
+ }, import("zod").ZodObject<{
229
+ orgId: import("zod").ZodString;
230
+ id: import("zod").ZodString;
231
+ communityId: import("zod").ZodString;
232
+ spaceId: import("zod").ZodString;
233
+ orgUserId: import("zod").ZodString;
234
+ status: import("zod").ZodEnum<{
235
+ active: "active";
236
+ revoked: "revoked";
237
+ requested: "requested";
238
+ invited: "invited";
239
+ }>;
240
+ source: import("zod").ZodEnum<{
241
+ request: "request";
242
+ invite: "invite";
243
+ manual: "manual";
244
+ }>;
245
+ createdAt: import("zod").ZodCoercedDate<unknown>;
246
+ updatedAt: import("zod").ZodCoercedDate<unknown>;
247
+ }, import("zod/v4/core").$strict>>;
248
+ spaceMemberUpdated: RuntimeEventDefinition<VersionedDomainEvent<{
249
+ orgId: string;
250
+ id: string;
251
+ communityId: string;
252
+ spaceId: string;
253
+ orgUserId: string;
254
+ status: "active" | "revoked" | "requested" | "invited";
255
+ source: "request" | "invite" | "manual";
256
+ createdAt: Date;
257
+ updatedAt: Date;
258
+ }, "entitlement.space_member.updated", 1>, {
259
+ orgId: string;
260
+ id: string;
261
+ communityId: string;
262
+ spaceId: string;
263
+ orgUserId: string;
264
+ status: "active" | "revoked" | "requested" | "invited";
265
+ source: "request" | "invite" | "manual";
266
+ createdAt: unknown;
267
+ updatedAt: unknown;
268
+ }, import("zod").ZodObject<{
269
+ orgId: import("zod").ZodString;
270
+ id: import("zod").ZodString;
271
+ communityId: import("zod").ZodString;
272
+ spaceId: import("zod").ZodString;
273
+ orgUserId: import("zod").ZodString;
274
+ status: import("zod").ZodEnum<{
275
+ active: "active";
276
+ revoked: "revoked";
277
+ requested: "requested";
278
+ invited: "invited";
279
+ }>;
280
+ source: import("zod").ZodEnum<{
281
+ request: "request";
282
+ invite: "invite";
283
+ manual: "manual";
284
+ }>;
285
+ createdAt: import("zod").ZodCoercedDate<unknown>;
286
+ updatedAt: import("zod").ZodCoercedDate<unknown>;
287
+ }, import("zod/v4/core").$strict>>;
288
+ spaceMemberDeleted: RuntimeEventDefinition<VersionedDomainEvent<{
289
+ orgId: string;
290
+ id: string;
291
+ communityId: string;
292
+ spaceId: string;
293
+ orgUserId: string;
294
+ status: "active" | "revoked" | "requested" | "invited";
295
+ source: "request" | "invite" | "manual";
296
+ createdAt: Date;
297
+ updatedAt: Date;
298
+ }, "entitlement.space_member.deleted", 1>, {
299
+ orgId: string;
300
+ id: string;
301
+ communityId: string;
302
+ spaceId: string;
303
+ orgUserId: string;
304
+ status: "active" | "revoked" | "requested" | "invited";
305
+ source: "request" | "invite" | "manual";
306
+ createdAt: unknown;
307
+ updatedAt: unknown;
308
+ }, import("zod").ZodObject<{
309
+ orgId: import("zod").ZodString;
310
+ id: import("zod").ZodString;
311
+ communityId: import("zod").ZodString;
312
+ spaceId: import("zod").ZodString;
313
+ orgUserId: import("zod").ZodString;
314
+ status: import("zod").ZodEnum<{
315
+ active: "active";
316
+ revoked: "revoked";
317
+ requested: "requested";
318
+ invited: "invited";
319
+ }>;
320
+ source: import("zod").ZodEnum<{
321
+ request: "request";
322
+ invite: "invite";
323
+ manual: "manual";
324
+ }>;
325
+ createdAt: import("zod").ZodCoercedDate<unknown>;
326
+ updatedAt: import("zod").ZodCoercedDate<unknown>;
327
+ }, import("zod/v4/core").$strict>>;
165
328
  };
166
329
  type EntitlementCreated = EventOf<typeof entitlementEvents.entitlementCreated>;
167
330
  type EntitlementUpdated = EventOf<typeof entitlementEvents.entitlementUpdated>;
168
331
  type EntitlementDeleted = EventOf<typeof entitlementEvents.entitlementDeleted>;
169
332
  type EntitlementExpired = EventOf<typeof entitlementEvents.entitlementExpired>;
333
+ type EntitlementEndingSoon = EventOf<typeof entitlementEvents.entitlementEndingSoon>;
334
+ type SpaceMemberCreated = EventOf<typeof entitlementEvents.spaceMemberCreated>;
335
+ type SpaceMemberUpdated = EventOf<typeof entitlementEvents.spaceMemberUpdated>;
336
+ type SpaceMemberDeleted = EventOf<typeof entitlementEvents.spaceMemberDeleted>;
170
337
  type EntitlementEvent = EventOfValues<typeof entitlementEvents>;
171
338
  //#endregion
172
- export { EntitlementCreated, EntitlementDeleted, EntitlementEvent, EntitlementExpired, EntitlementUpdated, entitlementEvents };
339
+ export { EntitlementCreated, EntitlementDeleted, EntitlementEndingSoon, EntitlementEvent, EntitlementExpired, EntitlementUpdated, SpaceMemberCreated, SpaceMemberDeleted, SpaceMemberUpdated, entitlementEvents };
173
340
  //# sourceMappingURL=events.d.ts.map
@@ -1,4 +1,5 @@
1
- import { entitlementSchema } from "../types/schemas/entitlements.js";
1
+ import { idSchema } from "../types/schemas/shared.js";
2
+ import { entitlementSchema, spaceMemberSchema } from "../types/schemas/entitlements.js";
2
3
  import { defineEvent } from "../shared/events.js";
3
4
  //#region src/entitlements/events.ts
4
5
  const publicEntitlement = entitlementSchema.pick({
@@ -14,6 +15,8 @@ const publicEntitlement = entitlementSchema.pick({
14
15
  createdAt: true,
15
16
  updatedAt: true
16
17
  }).strip();
18
+ const endingSoonSchema = entitlementSchema.extend({ communityId: idSchema }).strict();
19
+ const publicEndingSoon = publicEntitlement.extend({ communityId: idSchema }).strip();
17
20
  const entitlementEvents = {
18
21
  entitlementCreated: defineEvent({
19
22
  type: "entitlement.created",
@@ -38,6 +41,30 @@ const entitlementEvents = {
38
41
  version: 1,
39
42
  data: entitlementSchema,
40
43
  publicData: publicEntitlement
44
+ }),
45
+ entitlementEndingSoon: defineEvent({
46
+ type: "entitlement.ending_soon",
47
+ version: 1,
48
+ data: endingSoonSchema,
49
+ publicData: publicEndingSoon
50
+ }),
51
+ spaceMemberCreated: defineEvent({
52
+ type: "entitlement.space_member.created",
53
+ version: 1,
54
+ data: spaceMemberSchema,
55
+ publicData: spaceMemberSchema
56
+ }),
57
+ spaceMemberUpdated: defineEvent({
58
+ type: "entitlement.space_member.updated",
59
+ version: 1,
60
+ data: spaceMemberSchema,
61
+ publicData: spaceMemberSchema
62
+ }),
63
+ spaceMemberDeleted: defineEvent({
64
+ type: "entitlement.space_member.deleted",
65
+ version: 1,
66
+ data: spaceMemberSchema,
67
+ publicData: spaceMemberSchema
41
68
  })
42
69
  };
43
70
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"events.js","names":[],"sources":["../../src/entitlements/events.ts"],"sourcesContent":["import { entitlementSchema } from '../types/schemas/index.js';\nimport { defineEvent, type EventOf, type EventOfValues } from '../shared/ports.js';\n\nconst publicEntitlement = entitlementSchema\n .pick({\n orgId: true,\n id: true,\n orgUserId: true,\n bundleId: true,\n contentId: true,\n status: true,\n source: true,\n grantedAt: true,\n expiresAt: true,\n createdAt: true,\n updatedAt: true,\n })\n .strip();\n\nexport const entitlementEvents = {\n entitlementCreated: defineEvent({\n type: 'entitlement.created',\n version: 1,\n data: entitlementSchema,\n publicData: publicEntitlement,\n }),\n entitlementUpdated: defineEvent({\n type: 'entitlement.updated',\n version: 1,\n data: entitlementSchema,\n publicData: publicEntitlement,\n }),\n entitlementDeleted: defineEvent({\n type: 'entitlement.deleted',\n version: 1,\n data: entitlementSchema,\n publicData: publicEntitlement,\n }),\n entitlementExpired: defineEvent({\n type: 'entitlement.expired',\n version: 1,\n data: entitlementSchema,\n publicData: publicEntitlement,\n }),\n};\n\nexport type EntitlementCreated = EventOf<typeof entitlementEvents.entitlementCreated>;\nexport type EntitlementUpdated = EventOf<typeof entitlementEvents.entitlementUpdated>;\nexport type EntitlementDeleted = EventOf<typeof entitlementEvents.entitlementDeleted>;\nexport type EntitlementExpired = EventOf<typeof entitlementEvents.entitlementExpired>;\nexport type EntitlementEvent = EventOfValues<typeof entitlementEvents>;\n"],"mappings":";;;AAGA,MAAM,oBAAoB,kBACvB,KAAK;CACJ,OAAO;CACP,IAAI;CACJ,WAAW;CACX,UAAU;CACV,WAAW;CACX,QAAQ;CACR,QAAQ;CACR,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;AACb,CAAC,CAAC,CACD,MAAM;AAET,MAAa,oBAAoB;CAC/B,oBAAoB,YAAY;EAC9B,MAAM;EACN,SAAS;EACT,MAAM;EACN,YAAY;CACd,CAAC;CACD,oBAAoB,YAAY;EAC9B,MAAM;EACN,SAAS;EACT,MAAM;EACN,YAAY;CACd,CAAC;CACD,oBAAoB,YAAY;EAC9B,MAAM;EACN,SAAS;EACT,MAAM;EACN,YAAY;CACd,CAAC;CACD,oBAAoB,YAAY;EAC9B,MAAM;EACN,SAAS;EACT,MAAM;EACN,YAAY;CACd,CAAC;AACH"}
1
+ {"version":3,"file":"events.js","names":[],"sources":["../../src/entitlements/events.ts"],"sourcesContent":["import { entitlementSchema, idSchema, spaceMemberSchema } from '../types/schemas/index.js';\nimport { defineEvent, type EventOf, type EventOfValues } from '../shared/ports.js';\n\nconst publicEntitlement = entitlementSchema\n .pick({\n orgId: true,\n id: true,\n orgUserId: true,\n bundleId: true,\n contentId: true,\n status: true,\n source: true,\n grantedAt: true,\n expiresAt: true,\n createdAt: true,\n updatedAt: true,\n })\n .strip();\n\nconst endingSoonSchema = entitlementSchema.extend({ communityId: idSchema }).strict();\nconst publicEndingSoon = publicEntitlement.extend({ communityId: idSchema }).strip();\n\nexport const entitlementEvents = {\n entitlementCreated: defineEvent({\n type: 'entitlement.created',\n version: 1,\n data: entitlementSchema,\n publicData: publicEntitlement,\n }),\n entitlementUpdated: defineEvent({\n type: 'entitlement.updated',\n version: 1,\n data: entitlementSchema,\n publicData: publicEntitlement,\n }),\n entitlementDeleted: defineEvent({\n type: 'entitlement.deleted',\n version: 1,\n data: entitlementSchema,\n publicData: publicEntitlement,\n }),\n entitlementExpired: defineEvent({\n type: 'entitlement.expired',\n version: 1,\n data: entitlementSchema,\n publicData: publicEntitlement,\n }),\n entitlementEndingSoon: defineEvent({\n type: 'entitlement.ending_soon',\n version: 1,\n data: endingSoonSchema,\n publicData: publicEndingSoon,\n }),\n spaceMemberCreated: defineEvent({\n type: 'entitlement.space_member.created',\n version: 1,\n data: spaceMemberSchema,\n publicData: spaceMemberSchema,\n }),\n spaceMemberUpdated: defineEvent({\n type: 'entitlement.space_member.updated',\n version: 1,\n data: spaceMemberSchema,\n publicData: spaceMemberSchema,\n }),\n spaceMemberDeleted: defineEvent({\n type: 'entitlement.space_member.deleted',\n version: 1,\n data: spaceMemberSchema,\n publicData: spaceMemberSchema,\n }),\n};\n\nexport type EntitlementCreated = EventOf<typeof entitlementEvents.entitlementCreated>;\nexport type EntitlementUpdated = EventOf<typeof entitlementEvents.entitlementUpdated>;\nexport type EntitlementDeleted = EventOf<typeof entitlementEvents.entitlementDeleted>;\nexport type EntitlementExpired = EventOf<typeof entitlementEvents.entitlementExpired>;\nexport type EntitlementEndingSoon = EventOf<typeof entitlementEvents.entitlementEndingSoon>;\nexport type SpaceMemberCreated = EventOf<typeof entitlementEvents.spaceMemberCreated>;\nexport type SpaceMemberUpdated = EventOf<typeof entitlementEvents.spaceMemberUpdated>;\nexport type SpaceMemberDeleted = EventOf<typeof entitlementEvents.spaceMemberDeleted>;\nexport type EntitlementEvent = EventOfValues<typeof entitlementEvents>;\n"],"mappings":";;;;AAGA,MAAM,oBAAoB,kBACvB,KAAK;CACJ,OAAO;CACP,IAAI;CACJ,WAAW;CACX,UAAU;CACV,WAAW;CACX,QAAQ;CACR,QAAQ;CACR,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;AACb,CAAC,CAAC,CACD,MAAM;AAET,MAAM,mBAAmB,kBAAkB,OAAO,EAAE,aAAa,SAAS,CAAC,CAAC,CAAC,OAAO;AACpF,MAAM,mBAAmB,kBAAkB,OAAO,EAAE,aAAa,SAAS,CAAC,CAAC,CAAC,MAAM;AAEnF,MAAa,oBAAoB;CAC/B,oBAAoB,YAAY;EAC9B,MAAM;EACN,SAAS;EACT,MAAM;EACN,YAAY;CACd,CAAC;CACD,oBAAoB,YAAY;EAC9B,MAAM;EACN,SAAS;EACT,MAAM;EACN,YAAY;CACd,CAAC;CACD,oBAAoB,YAAY;EAC9B,MAAM;EACN,SAAS;EACT,MAAM;EACN,YAAY;CACd,CAAC;CACD,oBAAoB,YAAY;EAC9B,MAAM;EACN,SAAS;EACT,MAAM;EACN,YAAY;CACd,CAAC;CACD,uBAAuB,YAAY;EACjC,MAAM;EACN,SAAS;EACT,MAAM;EACN,YAAY;CACd,CAAC;CACD,oBAAoB,YAAY;EAC9B,MAAM;EACN,SAAS;EACT,MAAM;EACN,YAAY;CACd,CAAC;CACD,oBAAoB,YAAY;EAC9B,MAAM;EACN,SAAS;EACT,MAAM;EACN,YAAY;CACd,CAAC;CACD,oBAAoB,YAAY;EAC9B,MAAM;EACN,SAAS;EACT,MAAM;EACN,YAAY;CACd,CAAC;AACH"}
@@ -1,7 +1,9 @@
1
1
  import { Page } from "../types/shared.js";
2
- import { Entitlement, EntitlementStatus, EntitlementsQuery, GrantEntitlementInput } from "../types/schemas/entitlements.js";
3
- import { EntitlementCreated, EntitlementDeleted, EntitlementEvent, EntitlementExpired, EntitlementUpdated, entitlementEvents } from "./events.js";
2
+ import { Entitlement, EntitlementStatus, EntitlementsQuery, GrantEntitlementInput, SpaceMember, SpaceMemberSource, SpaceMemberStatus } from "../types/schemas/entitlements.js";
4
3
  import "./model.js";
5
- import { EntitlementsRepository, EntitlementsService } from "./ports.js";
4
+ import { AccessFacts, CommunityAccessReader, EndingGrant, EndingGrantKey, EntitlementNotice, EntitlementsRepository, EntitlementsService, GrantKey, GrantTarget, InsertSpaceMemberInput, OpenableSpace, SpaceAccessRule, SpaceMembersQuery } from "./ports.js";
6
5
  import { EntitlementsServiceImpl } from "./service.js";
7
- export { type Entitlement, type EntitlementCreated, type EntitlementDeleted, type EntitlementEvent, type EntitlementExpired, type EntitlementStatus, type EntitlementUpdated, type EntitlementsQuery, type EntitlementsRepository, type EntitlementsService, EntitlementsServiceImpl, type GrantEntitlementInput, type Page, entitlementEvents };
6
+ import { EntitlementCreated, EntitlementDeleted, EntitlementEndingSoon, EntitlementEvent, EntitlementExpired, EntitlementUpdated, SpaceMemberCreated, SpaceMemberDeleted, SpaceMemberUpdated, entitlementEvents } from "./events.js";
7
+ import { seesSpace } from "./rules.js";
8
+ import { GRANTS_EXPIRE_JOB, entitlementsJobs, entitlementsRecurringJobs } from "./jobs.js";
9
+ export { type AccessFacts, type CommunityAccessReader, type EndingGrant, type EndingGrantKey, type Entitlement, type EntitlementCreated, type EntitlementDeleted, type EntitlementEndingSoon, type EntitlementEvent, type EntitlementExpired, type EntitlementNotice, type EntitlementStatus, type EntitlementUpdated, type EntitlementsQuery, type EntitlementsRepository, type EntitlementsService, EntitlementsServiceImpl, GRANTS_EXPIRE_JOB, type GrantEntitlementInput, type GrantKey, type GrantTarget, type InsertSpaceMemberInput, type OpenableSpace, type Page, type SpaceAccessRule, type SpaceMember, type SpaceMemberCreated, type SpaceMemberDeleted, type SpaceMemberSource, type SpaceMemberStatus, type SpaceMemberUpdated, type SpaceMembersQuery, entitlementEvents, entitlementsJobs, entitlementsRecurringJobs, seesSpace };
@@ -1,3 +1,5 @@
1
1
  import { entitlementEvents } from "./events.js";
2
+ import { seesSpace } from "./rules.js";
2
3
  import { EntitlementsServiceImpl } from "./service.js";
3
- export { EntitlementsServiceImpl, entitlementEvents };
4
+ import { GRANTS_EXPIRE_JOB, entitlementsJobs, entitlementsRecurringJobs } from "./jobs.js";
5
+ export { EntitlementsServiceImpl, GRANTS_EXPIRE_JOB, entitlementEvents, entitlementsJobs, entitlementsRecurringJobs, seesSpace };
@@ -0,0 +1,12 @@
1
+ import { RecurringJob, ScheduledJob } from "../shared/ports.js";
2
+ import { EntitlementsService } from "./ports.js";
3
+ //#region src/entitlements/jobs.d.ts
4
+ declare const GRANTS_EXPIRE_JOB = "entitlements.grants.expire";
5
+ interface EntitlementsJobDeps {
6
+ grants: Pick<EntitlementsService, 'expireDueGrants'>;
7
+ }
8
+ declare function entitlementsJobs(deps: EntitlementsJobDeps): ScheduledJob[];
9
+ declare const entitlementsRecurringJobs: RecurringJob[];
10
+ //#endregion
11
+ export { EntitlementsJobDeps, GRANTS_EXPIRE_JOB, entitlementsJobs, entitlementsRecurringJobs };
12
+ //# sourceMappingURL=jobs.d.ts.map
@@ -0,0 +1,18 @@
1
+ //#region src/entitlements/jobs.ts
2
+ const GRANTS_EXPIRE_JOB = "entitlements.grants.expire";
3
+ function entitlementsJobs(deps) {
4
+ return [{
5
+ job: GRANTS_EXPIRE_JOB,
6
+ async run(_payload, fire) {
7
+ await deps.grants.expireDueGrants(fire.startedAt);
8
+ }
9
+ }];
10
+ }
11
+ const entitlementsRecurringJobs = [{
12
+ job: GRANTS_EXPIRE_JOB,
13
+ cron: "0 * * * *"
14
+ }];
15
+ //#endregion
16
+ export { GRANTS_EXPIRE_JOB, entitlementsJobs, entitlementsRecurringJobs };
17
+
18
+ //# sourceMappingURL=jobs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jobs.js","names":[],"sources":["../../src/entitlements/jobs.ts"],"sourcesContent":["import type { RecurringJob, ScheduledJob } from '../shared/ports.js';\nimport type { EntitlementsService } from './ports.js';\n\nexport const GRANTS_EXPIRE_JOB = 'entitlements.grants.expire';\n\nexport interface EntitlementsJobDeps {\n grants: Pick<EntitlementsService, 'expireDueGrants'>;\n}\n\nexport function entitlementsJobs(deps: EntitlementsJobDeps): ScheduledJob[] {\n return [\n {\n job: GRANTS_EXPIRE_JOB,\n async run(_payload, fire) {\n await deps.grants.expireDueGrants(fire.startedAt);\n },\n },\n ];\n}\n\nexport const entitlementsRecurringJobs: RecurringJob[] = [\n { job: GRANTS_EXPIRE_JOB, cron: '0 * * * *' },\n];\n"],"mappings":";AAGA,MAAa,oBAAoB;AAMjC,SAAgB,iBAAiB,MAA2C;CAC1E,OAAO,CACL;EACE,KAAK;EACL,MAAM,IAAI,UAAU,MAAM;GACxB,MAAM,KAAK,OAAO,gBAAgB,KAAK,SAAS;EAClD;CACF,CACF;AACF;AAEA,MAAa,4BAA4C,CACvD;CAAE,KAAK;CAAmB,MAAM;AAAY,CAC9C"}
@@ -1,4 +1,5 @@
1
1
  import { Page } from "../types/shared.js";
2
- import { Entitlement, EntitlementStatus, EntitlementsQuery, GrantEntitlementInput } from "../types/schemas/entitlements.js";
2
+ import { ContentType } from "../types/schemas/content.js";
3
+ import { Entitlement, EntitlementStatus, EntitlementsQuery, GrantEntitlementInput, SpaceMember, SpaceMemberSource, SpaceMemberStatus } from "../types/schemas/entitlements.js";
3
4
  import "../types/index.js";
4
- export type { Entitlement, EntitlementStatus, EntitlementsQuery, GrantEntitlementInput, Page };
5
+ export type { ContentType, Entitlement, EntitlementStatus, EntitlementsQuery, GrantEntitlementInput, Page, SpaceMember, SpaceMemberSource, SpaceMemberStatus };
@@ -1,34 +1,151 @@
1
1
  import { Page } from "../types/shared.js";
2
- import { Entitlement, EntitlementsQuery, GrantEntitlementInput } from "../types/schemas/entitlements.js";
2
+ import { ContentType, Space } from "../types/schemas/content.js";
3
+ import { Role } from "../types/schemas/organizations.js";
4
+ import { Entitlement, EntitlementsQuery, GrantEntitlementInput, SpaceMember, SpaceMemberSource, SpaceMemberStatus } from "../types/schemas/entitlements.js";
3
5
  import { OutboxAppender, UnitOfWork } from "../shared/ports.js";
6
+ import { Actor } from "../shared/actor.js";
7
+ import { SpaceRowLock } from "../content/ports.js";
8
+ import "../content/index.js";
4
9
  import "./model.js";
10
+ import "../organizations/index.js";
5
11
  //#region src/entitlements/ports.d.ts
6
- interface EntitlementsService {
12
+ interface GrantTarget {
13
+ contentId: string | null;
14
+ bundleId: string | null;
15
+ }
16
+ type SpaceAccessRule = 'all_members' | 'by_request' | 'by_invite';
17
+ interface OpenableSpace {
18
+ id: string;
19
+ communityId: string;
20
+ accessRule: SpaceAccessRule;
21
+ }
22
+ interface CommunityAccessReader {
23
+ isCommunityMember(orgId: string, actor: Actor, communityId: string): Promise<boolean>;
24
+ canOpenSpace(orgId: string, actor: Actor, spaceId: string): Promise<boolean>;
25
+ canOpen(orgId: string, actor: Actor, space: OpenableSpace): Promise<boolean>;
26
+ openSpaceIds(orgId: string, actor: Actor, communityId: string): Promise<string[]>;
27
+ openSpacesFor(orgId: string, actor: Actor, communityId: string): Promise<Space[]>;
28
+ spaceStandings(orgId: string, actor: Actor, communityId: string): Promise<Record<string, SpaceMember['status']>>;
29
+ communityMembersAmong(orgId: string, communityId: string, orgUserIds: string[]): Promise<string[]>;
30
+ spaceOpenersAmong(orgId: string, spaceId: string, orgUserIds: string[]): Promise<string[]>;
31
+ spaceOpeners(orgId: string, spaceId: string): Promise<string[]>;
32
+ }
33
+ type EntitlementNotice = {
34
+ kind: 'expired';
35
+ entitlementId: string;
36
+ expiresAt: Date;
37
+ } | {
38
+ kind: 'ending_soon';
39
+ entitlementId: string;
40
+ communityId: string;
41
+ expiresAt: Date;
42
+ };
43
+ interface EndingGrant {
44
+ grant: Entitlement;
45
+ communityId: string;
46
+ }
47
+ interface EndingGrantKey {
48
+ entitlementId: string;
49
+ communityId: string;
50
+ }
51
+ interface AccessFacts {
52
+ orgUserId: string;
53
+ role: Role;
54
+ member: boolean;
55
+ activeInSpace: boolean;
56
+ }
57
+ interface GrantKey {
58
+ orgUserId: string;
59
+ contentId?: string | null;
60
+ bundleId?: string | null;
61
+ }
62
+ interface SpaceMembersQuery {
63
+ page: number;
64
+ pageSize: number;
65
+ statuses?: SpaceMemberStatus[];
66
+ }
67
+ interface InsertSpaceMemberInput {
68
+ communityId: string;
69
+ spaceId: string;
70
+ orgUserId: string;
71
+ status: SpaceMemberStatus;
72
+ source: SpaceMemberSource;
73
+ }
74
+ interface EntitlementsService extends CommunityAccessReader {
7
75
  list(orgId: string, query: EntitlementsQuery): Promise<Page<Entitlement>>;
8
76
  grant(orgId: string, input: GrantEntitlementInput): Promise<Entitlement>;
77
+ ensureGrant(orgId: string, input: GrantEntitlementInput): Promise<Entitlement>;
9
78
  setStatus(orgId: string, id: string, status: 'active' | 'revoked'): Promise<Entitlement | null>;
10
- /** Whether this org user currently holds active access to the course.
11
- * The authority for course access — a reporting read must never be used to
12
- * infer it. */
13
- hasCourseAccess(orgId: string, orgUserId: string, courseId: string): Promise<boolean>;
79
+ /** Whether this org user can open the content right now, through a grant to
80
+ * it or to a bundle holding it. The only access check — nothing else may
81
+ * derive access from grants. */
82
+ hasAccess(orgId: string, orgUserId: string, contentId: string): Promise<boolean>;
83
+ /** Ids of the content this org user can open right now, optionally of one type. */
84
+ listAccessibleContent(orgId: string, orgUserId: string, type?: ContentType): Promise<string[]>;
85
+ requestJoin(orgId: string, actor: Actor, communityId: string, spaceId: string): Promise<SpaceMember>;
86
+ invite(orgId: string, actor: Actor, communityId: string, spaceId: string, orgUserId: string): Promise<SpaceMember>;
87
+ addSpaceMember(orgId: string, actor: Actor, communityId: string, spaceId: string, orgUserId: string): Promise<SpaceMember>;
88
+ accept(orgId: string, actor: Actor, communityId: string, spaceId: string): Promise<SpaceMember>;
89
+ approve(orgId: string, actor: Actor, communityId: string, spaceId: string, orgUserId: string): Promise<SpaceMember>;
90
+ decline(orgId: string, actor: Actor, communityId: string, spaceId: string, orgUserId: string): Promise<SpaceMember>;
91
+ refuse(orgId: string, actor: Actor, communityId: string, spaceId: string): Promise<SpaceMember>;
92
+ leave(orgId: string, actor: Actor, communityId: string, spaceId: string): Promise<SpaceMember>;
93
+ remove(orgId: string, actor: Actor, communityId: string, spaceId: string, orgUserId: string): Promise<SpaceMember>;
94
+ listSpaceMembers(orgId: string, actor: Actor, communityId: string, spaceId: string, query: {
95
+ page: number;
96
+ pageSize: number;
97
+ }): Promise<Page<SpaceMember>>;
98
+ expireDueGrants(now: Date): Promise<void>;
99
+ communitiesOpenedBy(orgId: string, grant: GrantTarget): Promise<string[]>;
100
+ communityModeratorIds(orgId: string, communityId: string): Promise<string[]>;
101
+ communityIdsOpenedFor(orgId: string, orgUserId: string): Promise<string[]>;
102
+ openCommunityIds(orgId: string, actor: Actor): Promise<string[]>;
103
+ communityMemberIds(orgId: string, communityId: string): Promise<string[]>;
104
+ contentHolderIds(orgId: string, contentId: string): Promise<string[]>;
105
+ countActiveSpaceMembers(orgId: string, spaceId: string): Promise<number>;
14
106
  }
15
107
  interface EntitlementsRepository {
16
108
  list(orgId: string, query: EntitlementsQuery): Promise<Page<Entitlement>>;
17
109
  insert(orgId: string, input: GrantEntitlementInput): Promise<Entitlement>;
110
+ insertIfAbsent(orgId: string, input: GrantEntitlementInput): Promise<Entitlement | null>;
111
+ lockGrant(orgId: string, key: GrantKey): Promise<Entitlement | null>;
112
+ setExpiresAt(orgId: string, id: string, expiresAt: Date | null): Promise<Entitlement | null>;
18
113
  setStatus(orgId: string, id: string, status: 'active' | 'revoked'): Promise<Entitlement | null>;
19
- /** Whether this org user currently holds active access to the course.
20
- * The authority for course access — a reporting read must never be used to
21
- * infer it. */
22
- hasCourseAccess(orgId: string, orgUserId: string, courseId: string): Promise<boolean>;
114
+ hasAccess(orgId: string, orgUserId: string, contentId: string): Promise<boolean>;
115
+ listAccessibleContent(orgId: string, orgUserId: string, type?: ContentType): Promise<string[]>;
116
+ hasCommunityAccess(orgId: string, orgUserId: string, communityId: string): Promise<boolean>;
117
+ communitiesOpenedBy(orgId: string, grant: GrantTarget): Promise<string[]>;
118
+ accessAmong(orgId: string, communityId: string, spaceId: string | null, orgUserIds: string[]): Promise<AccessFacts[]>;
119
+ findSpaceMember(orgId: string, spaceId: string, orgUserId: string): Promise<SpaceMember | null>;
120
+ listSpaceMembersFor(orgId: string, orgUserId: string, communityId: string): Promise<SpaceMember[]>;
121
+ lockSpaceMember(orgId: string, spaceId: string, orgUserId: string): Promise<SpaceMember | null>;
122
+ listSpaceMembers(orgId: string, spaceId: string, query: SpaceMembersQuery): Promise<Page<SpaceMember>>;
123
+ insertSpaceMember(orgId: string, input: InsertSpaceMemberInput): Promise<SpaceMember>;
124
+ updateSpaceMemberStatus(orgId: string, id: string, status: SpaceMemberStatus): Promise<SpaceMember | null>;
125
+ deleteSpaceMember(orgId: string, id: string): Promise<void>;
126
+ countActiveSpaceMembers(orgId: string, spaceId: string): Promise<number>;
127
+ activeSpaceIds(orgId: string, orgUserId: string, communityId: string): Promise<string[]>;
128
+ /** Expired grants with no expiry notice, in id order, after `afterId` when given. */
129
+ listGrantsExpiredBy(orgId: string, now: Date, limit: number, afterId?: string): Promise<Entitlement[]>;
130
+ /** Grants ending in the window with no notice, in (grant id, community id) order, after `afterKey`. */
131
+ listGrantsEndingBetween(orgId: string, after: Date, until: Date, limit: number, afterKey?: EndingGrantKey): Promise<EndingGrant[]>;
132
+ orgIdsWithDueNotices(now: Date, until: Date): Promise<string[]>;
133
+ claimNotice(orgId: string, notice: EntitlementNotice, now: Date): Promise<boolean>;
134
+ communityModeratorIds(orgId: string, communityId: string): Promise<string[]>;
135
+ communityMemberIds(orgId: string, communityId: string): Promise<string[]>;
136
+ communityIdsOpenedFor(orgId: string, orgUserId: string): Promise<string[]>;
137
+ openCommunityIds(orgId: string, orgUserId: string): Promise<string[]>;
138
+ contentHolderIds(orgId: string, contentId: string): Promise<string[]>;
23
139
  }
24
140
  /** Tx-scoped port bundle for this context's mutating use cases — every member
25
141
  * is bound to the UnitOfWork's transaction, so the write and the event append
26
142
  * commit or roll back as one. */
27
143
  interface EntitlementsTxScope {
28
144
  entitlements: EntitlementsRepository;
145
+ spaces: SpaceRowLock;
29
146
  outbox: OutboxAppender;
30
147
  }
31
148
  type EntitlementsUnitOfWork = UnitOfWork<EntitlementsTxScope>;
32
149
  //#endregion
33
- export { EntitlementsRepository, EntitlementsService, EntitlementsTxScope, EntitlementsUnitOfWork };
150
+ export { AccessFacts, CommunityAccessReader, EndingGrant, EndingGrantKey, EntitlementNotice, EntitlementsRepository, EntitlementsService, EntitlementsTxScope, EntitlementsUnitOfWork, GrantKey, GrantTarget, InsertSpaceMemberInput, OpenableSpace, SpaceAccessRule, SpaceMembersQuery };
34
151
  //# sourceMappingURL=ports.d.ts.map
@@ -0,0 +1,12 @@
1
+ import { Role } from "../types/schemas/organizations.js";
2
+ import { SpaceMemberStatus } from "../types/schemas/entitlements.js";
3
+ import "./model.js";
4
+ import "../organizations/index.js";
5
+ import { SpaceAccessRule } from "./ports.js";
6
+ //#region src/entitlements/rules.d.ts
7
+ declare function opensSpace(role: Role, member: boolean, accessRule: SpaceAccessRule, activeInSpace: boolean): boolean;
8
+ declare function seesSpace(role: Role, accessRule: SpaceAccessRule, status: SpaceMemberStatus | undefined): boolean;
9
+ declare function laterExpiry(a: Date | null, b: Date | null): Date | null;
10
+ //#endregion
11
+ export { laterExpiry, opensSpace, seesSpace };
12
+ //# sourceMappingURL=rules.d.ts.map
@@ -0,0 +1,17 @@
1
+ import { canModerate } from "../organizations/roles.js";
2
+ //#region src/entitlements/rules.ts
3
+ function opensSpace(role, member, accessRule, activeInSpace) {
4
+ if (!member) return false;
5
+ return canModerate(role) || accessRule === "all_members" || activeInSpace;
6
+ }
7
+ function seesSpace(role, accessRule, status) {
8
+ return canModerate(role) || accessRule !== "by_invite" || status !== void 0 && status !== "revoked";
9
+ }
10
+ function laterExpiry(a, b) {
11
+ if (a === null || b === null) return null;
12
+ return a.getTime() >= b.getTime() ? a : b;
13
+ }
14
+ //#endregion
15
+ export { laterExpiry, opensSpace, seesSpace };
16
+
17
+ //# sourceMappingURL=rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rules.js","names":[],"sources":["../../src/entitlements/rules.ts"],"sourcesContent":["import { canModerate, type Role } from '../organizations/index.js';\nimport type { SpaceAccessRule } from './ports.js';\nimport type { SpaceMemberStatus } from './model.js';\n\nexport function opensSpace(\n role: Role,\n member: boolean,\n accessRule: SpaceAccessRule,\n activeInSpace: boolean,\n): boolean {\n if (!member) {\n return false;\n }\n return canModerate(role) || accessRule === 'all_members' || activeInSpace;\n}\n\nexport function seesSpace(\n role: Role,\n accessRule: SpaceAccessRule,\n status: SpaceMemberStatus | undefined,\n): boolean {\n return (\n canModerate(role) ||\n accessRule !== 'by_invite' ||\n (status !== undefined && status !== 'revoked')\n );\n}\n\nexport function laterExpiry(a: Date | null, b: Date | null): Date | null {\n if (a === null || b === null) {\n return null;\n }\n return a.getTime() >= b.getTime() ? a : b;\n}\n"],"mappings":";;AAIA,SAAgB,WACd,MACA,QACA,YACA,eACS;CACT,IAAI,CAAC,QACH,OAAO;CAET,OAAO,YAAY,IAAI,KAAK,eAAe,iBAAiB;AAC9D;AAEA,SAAgB,UACd,MACA,YACA,QACS;CACT,OACE,YAAY,IAAI,KAChB,eAAe,eACd,WAAW,KAAA,KAAa,WAAW;AAExC;AAEA,SAAgB,YAAY,GAAgB,GAA6B;CACvE,IAAI,MAAM,QAAQ,MAAM,MACtB,OAAO;CAET,OAAO,EAAE,QAAQ,KAAK,EAAE,QAAQ,IAAI,IAAI;AAC1C"}