@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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"org-roles.js","names":[],"sources":["../../src/organizations/org-roles.ts"],"sourcesContent":["import type { Level, Permission } from '../types/index.js';\nimport { ALL_PERMISSIONS, fitsLevels } from './permissions.js';\nimport { MEMBER_ROLE_KEY, OWNER_ROLE_KEY, type RoleDefinition } from './default-roles.js';\n\nexport interface StoredOrgRole {\n key: string;\n name: string | null;\n description: string | null;\n base: string;\n levels: Level[] | null;\n permissions: Partial<Record<Permission, boolean>>;\n team: boolean | null;\n}\n\nexport interface OrgRole {\n key: string;\n name: string;\n description: string;\n base: string;\n levels: Level[];\n team: boolean;\n permissions: Permission[];\n system: boolean;\n added: boolean;\n customized: boolean;\n}\n\nexport type RoleCatalog = ReadonlyMap<string, RoleDefinition>;\n\nexport function catalogOf(roles: readonly RoleDefinition[]): RoleCatalog {\n return new Map(roles.map((role) => [role.key, role]));\n}\n\nexport function isSystemRole(key: string): boolean {\n return key === OWNER_ROLE_KEY || key === MEMBER_ROLE_KEY;\n}\n\nexport function resolveRole(\n key: string,\n catalog: RoleCatalog,\n stored: StoredOrgRole | undefined,\n): OrgRole | null {\n const baseKey = stored?.base ?? key;\n const base = catalog.get(baseKey);\n if (!base) {\n return null;\n }\n const own = catalog.get(key);\n if (!own && !stored) {\n return null;\n }\n const levels = stored?.levels ?? base.levels;\n const permissions =\n key === OWNER_ROLE_KEY\n ? [...ALL_PERMISSIONS]\n : key === MEMBER_ROLE_KEY\n ? []\n : ALL_PERMISSIONS.filter((permission) => {\n const explicit = stored?.permissions[permission];\n const held = explicit ?? base.permissions.includes(permission);\n return held && fitsLevels(permission, levels);\n });\n return {\n key,\n name: stored?.name ?? own?.name ?? base.name,\n description: stored?.description ?? own?.description ?? base.description,\n base: baseKey,\n levels: key === OWNER_ROLE_KEY || key === MEMBER_ROLE_KEY ? ['org'] : levels,\n team: stored?.team ?? own?.team ?? base.team,\n permissions,\n system: isSystemRole(key),\n added: !own,\n customized: stored !== undefined,\n };\n}\n\nexport function resolveOrgRoles(catalog: RoleCatalog, stored: readonly StoredOrgRole[]): OrgRole[] {\n const byKey = new Map(stored.map((row) => [row.key, row]));\n const out: OrgRole[] = [];\n for (const key of catalog.keys()) {\n const role = resolveRole(key, catalog, byKey.get(key));\n if (role) {\n out.push(role);\n }\n }\n for (const row of stored) {\n if (!catalog.has(row.key)) {\n const role = resolveRole(row.key, catalog, row);\n if (role) {\n out.push(role);\n }\n }\n }\n return out;\n}\n"],"mappings":";;;AA6BA,SAAgB,UAAU,OAA+C;CACvE,OAAO,IAAI,IAAI,MAAM,KAAK,SAAS,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC;AACtD;AAEA,SAAgB,aAAa,KAAsB;CACjD,OAAO,QAAA,WAA0B,QAAA;AACnC;AAEA,SAAgB,YACd,KACA,SACA,QACgB;CAChB,MAAM,UAAU,QAAQ,QAAQ;CAChC,MAAM,OAAO,QAAQ,IAAI,OAAO;CAChC,IAAI,CAAC,MACH,OAAO;CAET,MAAM,MAAM,QAAQ,IAAI,GAAG;CAC3B,IAAI,CAAC,OAAO,CAAC,QACX,OAAO;CAET,MAAM,SAAS,QAAQ,UAAU,KAAK;CACtC,MAAM,cACJ,QAAA,UACI,CAAC,GAAG,eAAe,IACnB,QAAA,WACE,CAAC,IACD,gBAAgB,QAAQ,eAAe;EAGrC,QAFiB,QAAQ,YAAY,eACZ,KAAK,YAAY,SAAS,UAAU,MAC9C,WAAW,YAAY,MAAM;CAC9C,CAAC;CACT,OAAO;EACL;EACA,MAAM,QAAQ,QAAQ,KAAK,QAAQ,KAAK;EACxC,aAAa,QAAQ,eAAe,KAAK,eAAe,KAAK;EAC7D,MAAM;EACN,QAAQ,QAAA,WAA0B,QAAA,WAA0B,CAAC,KAAK,IAAI;EACtE,MAAM,QAAQ,QAAQ,KAAK,QAAQ,KAAK;EACxC;EACA,QAAQ,aAAa,GAAG;EACxB,OAAO,CAAC;EACR,YAAY,WAAW,KAAA;CACzB;AACF;AAEA,SAAgB,gBAAgB,SAAsB,QAA6C;CACjG,MAAM,QAAQ,IAAI,IAAI,OAAO,KAAK,QAAQ,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC;CACzD,MAAM,MAAiB,CAAC;CACxB,KAAK,MAAM,OAAO,QAAQ,KAAK,GAAG;EAChC,MAAM,OAAO,YAAY,KAAK,SAAS,MAAM,IAAI,GAAG,CAAC;EACrD,IAAI,MACF,IAAI,KAAK,IAAI;CAEjB;CACA,KAAK,MAAM,OAAO,QAChB,IAAI,CAAC,QAAQ,IAAI,IAAI,GAAG,GAAG;EACzB,MAAM,OAAO,YAAY,IAAI,KAAK,SAAS,GAAG;EAC9C,IAAI,MACF,IAAI,KAAK,IAAI;CAEjB;CAEF,OAAO;AACT"}
@@ -0,0 +1,311 @@
1
+ import { Level, Permission } from "../types/schemas/organizations.js";
2
+ import "../types/index.js";
3
+ //#region src/organizations/permissions.d.ts
4
+ type PermissionGroup = 'organization' | 'people' | 'access' | 'content' | 'courses' | 'downloads' | 'communities' | 'events' | 'automations';
5
+ interface PermissionDefinition {
6
+ group: PermissionGroup;
7
+ label: string;
8
+ description: string;
9
+ about: Level;
10
+ implies?: readonly Permission[];
11
+ }
12
+ declare const PERMISSIONS: {
13
+ readonly 'organizations:read': {
14
+ readonly group: "organization";
15
+ readonly label: "See the organization";
16
+ readonly description: "See the org's name, slug and general settings.";
17
+ readonly about: "org";
18
+ };
19
+ readonly 'organizations:write': {
20
+ readonly group: "organization";
21
+ readonly label: "Edit the organization";
22
+ readonly description: "Change the org's name, slug and general settings.";
23
+ readonly about: "org";
24
+ readonly implies: readonly ["organizations:read"];
25
+ };
26
+ readonly 'api_keys:read': {
27
+ readonly group: "organization";
28
+ readonly label: "See your API keys";
29
+ readonly description: "List your own API keys.";
30
+ readonly about: "org";
31
+ };
32
+ readonly 'api_keys:write': {
33
+ readonly group: "organization";
34
+ readonly label: "Create API keys";
35
+ readonly description: "Create your own API keys.";
36
+ readonly about: "org";
37
+ readonly implies: readonly ["api_keys:read"];
38
+ };
39
+ readonly 'api_keys:delete': {
40
+ readonly group: "organization";
41
+ readonly label: "Revoke API keys";
42
+ readonly description: "Revoke your own API keys.";
43
+ readonly about: "org";
44
+ readonly implies: readonly ["api_keys:read"];
45
+ };
46
+ readonly 'notification_categories:read': {
47
+ readonly group: "organization";
48
+ readonly label: "See notification categories";
49
+ readonly description: "See the notification types, channels and the org's categories and defaults.";
50
+ readonly about: "org";
51
+ };
52
+ readonly 'notification_categories:write': {
53
+ readonly group: "organization";
54
+ readonly label: "Edit notification categories";
55
+ readonly description: "Edit and reset the org's notification categories.";
56
+ readonly about: "org";
57
+ readonly implies: readonly ["notification_categories:read"];
58
+ };
59
+ readonly 'integrations:read': {
60
+ readonly group: "organization";
61
+ readonly label: "See integrations";
62
+ readonly description: "See connected integrations.";
63
+ readonly about: "org";
64
+ };
65
+ readonly 'integrations:write': {
66
+ readonly group: "organization";
67
+ readonly label: "Manage integrations";
68
+ readonly description: "Connect, configure and run actions on integrations.";
69
+ readonly about: "org";
70
+ readonly implies: readonly ["integrations:read"];
71
+ };
72
+ readonly 'integrations:delete': {
73
+ readonly group: "organization";
74
+ readonly label: "Disconnect integrations";
75
+ readonly description: "Disconnect integrations.";
76
+ readonly about: "org";
77
+ readonly implies: readonly ["integrations:read"];
78
+ };
79
+ readonly 'analytics:read': {
80
+ readonly group: "organization";
81
+ readonly label: "See the overview";
82
+ readonly description: "See the org's overview report.";
83
+ readonly about: "org";
84
+ };
85
+ readonly 'people:read': {
86
+ readonly group: "people";
87
+ readonly label: "See people";
88
+ readonly description: "List the org's people and pending invites, with each person's roles, and open any person's record.";
89
+ readonly about: "org";
90
+ readonly implies: readonly ["progress:read"];
91
+ };
92
+ readonly 'people:write': {
93
+ readonly group: "people";
94
+ readonly label: "Manage people";
95
+ readonly description: "Invite people, resend and cancel invites, set a person's org role and give and remove roles on content items.";
96
+ readonly about: "org";
97
+ readonly implies: readonly ["people:read"];
98
+ };
99
+ readonly 'people:delete': {
100
+ readonly group: "people";
101
+ readonly label: "Remove people";
102
+ readonly description: "Remove a person from the org.";
103
+ readonly about: "org";
104
+ readonly implies: readonly ["people:read"];
105
+ };
106
+ readonly 'roles:read': {
107
+ readonly group: "people";
108
+ readonly label: "See roles";
109
+ readonly description: "See the org's roles and their permissions.";
110
+ readonly about: "org";
111
+ };
112
+ readonly 'roles:write': {
113
+ readonly group: "people";
114
+ readonly label: "Manage roles";
115
+ readonly description: "Rename roles; change, reset and add roles through the API.";
116
+ readonly about: "org";
117
+ readonly implies: readonly ["roles:read"];
118
+ };
119
+ readonly 'roles:delete': {
120
+ readonly group: "people";
121
+ readonly label: "Delete roles";
122
+ readonly description: "Delete a role the org added.";
123
+ readonly about: "org";
124
+ readonly implies: readonly ["roles:read"];
125
+ };
126
+ readonly 'access:read': {
127
+ readonly group: "access";
128
+ readonly label: "See access";
129
+ readonly description: "See grants, including a community's roster of grant holders.";
130
+ readonly about: "org";
131
+ };
132
+ readonly 'access:write': {
133
+ readonly group: "access";
134
+ readonly label: "Manage access";
135
+ readonly description: "Grant, change and revoke access.";
136
+ readonly about: "org";
137
+ readonly implies: readonly ["access:read"];
138
+ };
139
+ readonly 'bundles:read': {
140
+ readonly group: "content";
141
+ readonly label: "See bundles";
142
+ readonly description: "See bundles and their names.";
143
+ readonly about: "org";
144
+ };
145
+ readonly 'bundles:write': {
146
+ readonly group: "content";
147
+ readonly label: "Edit bundles";
148
+ readonly description: "Create and edit bundles.";
149
+ readonly about: "org";
150
+ readonly implies: readonly ["bundles:read"];
151
+ };
152
+ readonly 'bundles:delete': {
153
+ readonly group: "content";
154
+ readonly label: "Delete bundles";
155
+ readonly description: "Delete bundles.";
156
+ readonly about: "org";
157
+ readonly implies: readonly ["bundles:read"];
158
+ };
159
+ readonly 'media:read': {
160
+ readonly group: "content";
161
+ readonly label: "See the media library";
162
+ readonly description: "See the whole media library and attach any of its files.";
163
+ readonly about: "org";
164
+ };
165
+ readonly 'media:write': {
166
+ readonly group: "content";
167
+ readonly label: "Upload media";
168
+ readonly description: "Upload to the media library and edit its files.";
169
+ readonly about: "org";
170
+ readonly implies: readonly ["media:read"];
171
+ };
172
+ readonly 'media:delete': {
173
+ readonly group: "content";
174
+ readonly label: "Delete media";
175
+ readonly description: "Delete files from the media library.";
176
+ readonly about: "org";
177
+ readonly implies: readonly ["media:read"];
178
+ };
179
+ readonly 'courses:read': {
180
+ readonly group: "courses";
181
+ readonly label: "See courses";
182
+ readonly description: "See the course, its modules and activities in the admin app; open it, its lessons, files and titles without a grant, unpublished included; be reachable for its lesson-comment mentions.";
183
+ readonly about: "course";
184
+ };
185
+ readonly 'courses:write': {
186
+ readonly group: "courses";
187
+ readonly label: "Edit courses";
188
+ readonly description: "Edit and publish the course; add, change and delete its modules and activities; upload media for it and attach media uploaded for it. Creating a course needs it on the org.";
189
+ readonly about: "course";
190
+ readonly implies: readonly ["courses:read"];
191
+ };
192
+ readonly 'courses:delete': {
193
+ readonly group: "courses";
194
+ readonly label: "Delete courses";
195
+ readonly description: "Delete the course.";
196
+ readonly about: "course";
197
+ readonly implies: readonly ["courses:read"];
198
+ };
199
+ readonly 'courses:moderate': {
200
+ readonly group: "courses";
201
+ readonly label: "Moderate lesson comments";
202
+ readonly description: "See the course's lesson comments, held ones included; approve, remove, restore, reply to and resolve reports on them; be notified of reports. The holder's own lesson comments publish without review.";
203
+ readonly about: "course";
204
+ readonly implies: readonly ["courses:read"];
205
+ };
206
+ readonly 'progress:read': {
207
+ readonly group: "courses";
208
+ readonly label: "See learners and progress";
209
+ readonly description: "See the course's learners, their progress and the course's analytics.";
210
+ readonly about: "course";
211
+ };
212
+ readonly 'downloads:read': {
213
+ readonly group: "downloads";
214
+ readonly label: "See downloads";
215
+ readonly description: "See the download in the admin app, and open it and its files without a grant, unpublished included.";
216
+ readonly about: "download";
217
+ };
218
+ readonly 'downloads:write': {
219
+ readonly group: "downloads";
220
+ readonly label: "Edit downloads";
221
+ readonly description: "Edit and publish the download; upload files for it and attach files uploaded for it. Creating a download needs it on the org.";
222
+ readonly about: "download";
223
+ readonly implies: readonly ["downloads:read"];
224
+ };
225
+ readonly 'downloads:delete': {
226
+ readonly group: "downloads";
227
+ readonly label: "Delete downloads";
228
+ readonly description: "Delete the download.";
229
+ readonly about: "download";
230
+ readonly implies: readonly ["downloads:read"];
231
+ };
232
+ readonly 'communities:read': {
233
+ readonly group: "communities";
234
+ readonly label: "See communities";
235
+ readonly description: "See the community, its spaces, notification categories and analytics in the admin app; be a member of it without a grant, unpublished included, open every space in it and see its thumbnail while unpublished.";
236
+ readonly about: "community";
237
+ };
238
+ readonly 'communities:write': {
239
+ readonly group: "communities";
240
+ readonly label: "Configure communities";
241
+ readonly description: "Configure the community, its spaces, topics, links, settings and notification categories; publish it; delete its spaces; upload media for it and attach media uploaded for it. Creating a community needs it on the org.";
242
+ readonly about: "community";
243
+ readonly implies: readonly ["communities:read"];
244
+ };
245
+ readonly 'communities:delete': {
246
+ readonly group: "communities";
247
+ readonly label: "Delete communities";
248
+ readonly description: "Delete the community.";
249
+ readonly about: "community";
250
+ readonly implies: readonly ["communities:read"];
251
+ };
252
+ readonly 'communities:moderate': {
253
+ readonly group: "communities";
254
+ readonly label: "Moderate communities";
255
+ readonly description: "See the review queue, pending and removed posts, held comments and their titles; open every space; approve, remove, restore, pin and lock posts and comments; turn comments and reactions on and off; delete any message, see deleted messages, read reported attachments, lock chats, see the message queue; see every space member and locked spaces' rosters; invite, add, approve, decline and remove space members; resolve reports; be notified of reviews, reports and join requests. The holder's own posts publish without review.";
256
+ readonly about: "community";
257
+ };
258
+ readonly 'events:read': {
259
+ readonly group: "events";
260
+ readonly label: "See events";
261
+ readonly description: "See the event in the admin app, drafts and canceled included; open it without a grant; see its attendees and analytics.";
262
+ readonly about: "event";
263
+ };
264
+ readonly 'events:write': {
265
+ readonly group: "events";
266
+ readonly label: "Edit events";
267
+ readonly description: "Edit, publish and cancel the event; set its recording; grant and revoke it for others; upload files for it and attach, rename, reorder and remove them. Creating an event needs it on the org.";
268
+ readonly about: "event";
269
+ readonly implies: readonly ["events:read"];
270
+ };
271
+ readonly 'events:delete': {
272
+ readonly group: "events";
273
+ readonly label: "Delete events";
274
+ readonly description: "Delete the event.";
275
+ readonly about: "event";
276
+ readonly implies: readonly ["events:read"];
277
+ };
278
+ readonly 'automations:read': {
279
+ readonly group: "automations";
280
+ readonly label: "See automations";
281
+ readonly description: "See workflows, webhooks and their runs.";
282
+ readonly about: "org";
283
+ };
284
+ readonly 'automations:write': {
285
+ readonly group: "automations";
286
+ readonly label: "Edit automations";
287
+ readonly description: "Create and edit workflows and webhooks, and reveal a webhook's signing secret.";
288
+ readonly about: "org";
289
+ readonly implies: readonly ["automations:read"];
290
+ };
291
+ readonly 'automations:delete': {
292
+ readonly group: "automations";
293
+ readonly label: "Delete automations";
294
+ readonly description: "Delete workflows and webhooks.";
295
+ readonly about: "org";
296
+ readonly implies: readonly ["automations:read"];
297
+ };
298
+ };
299
+ declare const ALL_PERMISSIONS: readonly Permission[];
300
+ declare function isPermission(value: string): value is Permission;
301
+ declare function permissionAbout(permission: Permission): Level;
302
+ declare function fitsLevels(permission: Permission, levels: readonly Level[]): boolean;
303
+ declare function withImplied(permissions: Iterable<Permission>): Set<Permission>;
304
+ interface PermissionListEntry extends Omit<PermissionDefinition, 'implies'> {
305
+ key: Permission;
306
+ implies?: Permission[];
307
+ }
308
+ declare function permissionList(): PermissionListEntry[];
309
+ //#endregion
310
+ export { ALL_PERMISSIONS, PERMISSIONS, PermissionDefinition, PermissionGroup, PermissionListEntry, fitsLevels, isPermission, permissionAbout, permissionList, withImplied };
311
+ //# sourceMappingURL=permissions.d.ts.map
@@ -0,0 +1,327 @@
1
+ import { PERMISSION_KEYS } from "../types/schemas/organizations.js";
2
+ //#region src/organizations/permissions.ts
3
+ const PERMISSIONS = {
4
+ "organizations:read": {
5
+ group: "organization",
6
+ label: "See the organization",
7
+ description: "See the org's name, slug and general settings.",
8
+ about: "org"
9
+ },
10
+ "organizations:write": {
11
+ group: "organization",
12
+ label: "Edit the organization",
13
+ description: "Change the org's name, slug and general settings.",
14
+ about: "org",
15
+ implies: ["organizations:read"]
16
+ },
17
+ "api_keys:read": {
18
+ group: "organization",
19
+ label: "See your API keys",
20
+ description: "List your own API keys.",
21
+ about: "org"
22
+ },
23
+ "api_keys:write": {
24
+ group: "organization",
25
+ label: "Create API keys",
26
+ description: "Create your own API keys.",
27
+ about: "org",
28
+ implies: ["api_keys:read"]
29
+ },
30
+ "api_keys:delete": {
31
+ group: "organization",
32
+ label: "Revoke API keys",
33
+ description: "Revoke your own API keys.",
34
+ about: "org",
35
+ implies: ["api_keys:read"]
36
+ },
37
+ "notification_categories:read": {
38
+ group: "organization",
39
+ label: "See notification categories",
40
+ description: "See the notification types, channels and the org's categories and defaults.",
41
+ about: "org"
42
+ },
43
+ "notification_categories:write": {
44
+ group: "organization",
45
+ label: "Edit notification categories",
46
+ description: "Edit and reset the org's notification categories.",
47
+ about: "org",
48
+ implies: ["notification_categories:read"]
49
+ },
50
+ "integrations:read": {
51
+ group: "organization",
52
+ label: "See integrations",
53
+ description: "See connected integrations.",
54
+ about: "org"
55
+ },
56
+ "integrations:write": {
57
+ group: "organization",
58
+ label: "Manage integrations",
59
+ description: "Connect, configure and run actions on integrations.",
60
+ about: "org",
61
+ implies: ["integrations:read"]
62
+ },
63
+ "integrations:delete": {
64
+ group: "organization",
65
+ label: "Disconnect integrations",
66
+ description: "Disconnect integrations.",
67
+ about: "org",
68
+ implies: ["integrations:read"]
69
+ },
70
+ "analytics:read": {
71
+ group: "organization",
72
+ label: "See the overview",
73
+ description: "See the org's overview report.",
74
+ about: "org"
75
+ },
76
+ "people:read": {
77
+ group: "people",
78
+ label: "See people",
79
+ description: "List the org's people and pending invites, with each person's roles, and open any person's record.",
80
+ about: "org",
81
+ implies: ["progress:read"]
82
+ },
83
+ "people:write": {
84
+ group: "people",
85
+ label: "Manage people",
86
+ description: "Invite people, resend and cancel invites, set a person's org role and give and remove roles on content items.",
87
+ about: "org",
88
+ implies: ["people:read"]
89
+ },
90
+ "people:delete": {
91
+ group: "people",
92
+ label: "Remove people",
93
+ description: "Remove a person from the org.",
94
+ about: "org",
95
+ implies: ["people:read"]
96
+ },
97
+ "roles:read": {
98
+ group: "people",
99
+ label: "See roles",
100
+ description: "See the org's roles and their permissions.",
101
+ about: "org"
102
+ },
103
+ "roles:write": {
104
+ group: "people",
105
+ label: "Manage roles",
106
+ description: "Rename roles; change, reset and add roles through the API.",
107
+ about: "org",
108
+ implies: ["roles:read"]
109
+ },
110
+ "roles:delete": {
111
+ group: "people",
112
+ label: "Delete roles",
113
+ description: "Delete a role the org added.",
114
+ about: "org",
115
+ implies: ["roles:read"]
116
+ },
117
+ "access:read": {
118
+ group: "access",
119
+ label: "See access",
120
+ description: "See grants, including a community's roster of grant holders.",
121
+ about: "org"
122
+ },
123
+ "access:write": {
124
+ group: "access",
125
+ label: "Manage access",
126
+ description: "Grant, change and revoke access.",
127
+ about: "org",
128
+ implies: ["access:read"]
129
+ },
130
+ "bundles:read": {
131
+ group: "content",
132
+ label: "See bundles",
133
+ description: "See bundles and their names.",
134
+ about: "org"
135
+ },
136
+ "bundles:write": {
137
+ group: "content",
138
+ label: "Edit bundles",
139
+ description: "Create and edit bundles.",
140
+ about: "org",
141
+ implies: ["bundles:read"]
142
+ },
143
+ "bundles:delete": {
144
+ group: "content",
145
+ label: "Delete bundles",
146
+ description: "Delete bundles.",
147
+ about: "org",
148
+ implies: ["bundles:read"]
149
+ },
150
+ "media:read": {
151
+ group: "content",
152
+ label: "See the media library",
153
+ description: "See the whole media library and attach any of its files.",
154
+ about: "org"
155
+ },
156
+ "media:write": {
157
+ group: "content",
158
+ label: "Upload media",
159
+ description: "Upload to the media library and edit its files.",
160
+ about: "org",
161
+ implies: ["media:read"]
162
+ },
163
+ "media:delete": {
164
+ group: "content",
165
+ label: "Delete media",
166
+ description: "Delete files from the media library.",
167
+ about: "org",
168
+ implies: ["media:read"]
169
+ },
170
+ "courses:read": {
171
+ group: "courses",
172
+ label: "See courses",
173
+ description: "See the course, its modules and activities in the admin app; open it, its lessons, files and titles without a grant, unpublished included; be reachable for its lesson-comment mentions.",
174
+ about: "course"
175
+ },
176
+ "courses:write": {
177
+ group: "courses",
178
+ label: "Edit courses",
179
+ description: "Edit and publish the course; add, change and delete its modules and activities; upload media for it and attach media uploaded for it. Creating a course needs it on the org.",
180
+ about: "course",
181
+ implies: ["courses:read"]
182
+ },
183
+ "courses:delete": {
184
+ group: "courses",
185
+ label: "Delete courses",
186
+ description: "Delete the course.",
187
+ about: "course",
188
+ implies: ["courses:read"]
189
+ },
190
+ "courses:moderate": {
191
+ group: "courses",
192
+ label: "Moderate lesson comments",
193
+ description: "See the course's lesson comments, held ones included; approve, remove, restore, reply to and resolve reports on them; be notified of reports. The holder's own lesson comments publish without review.",
194
+ about: "course",
195
+ implies: ["courses:read"]
196
+ },
197
+ "progress:read": {
198
+ group: "courses",
199
+ label: "See learners and progress",
200
+ description: "See the course's learners, their progress and the course's analytics.",
201
+ about: "course"
202
+ },
203
+ "downloads:read": {
204
+ group: "downloads",
205
+ label: "See downloads",
206
+ description: "See the download in the admin app, and open it and its files without a grant, unpublished included.",
207
+ about: "download"
208
+ },
209
+ "downloads:write": {
210
+ group: "downloads",
211
+ label: "Edit downloads",
212
+ description: "Edit and publish the download; upload files for it and attach files uploaded for it. Creating a download needs it on the org.",
213
+ about: "download",
214
+ implies: ["downloads:read"]
215
+ },
216
+ "downloads:delete": {
217
+ group: "downloads",
218
+ label: "Delete downloads",
219
+ description: "Delete the download.",
220
+ about: "download",
221
+ implies: ["downloads:read"]
222
+ },
223
+ "communities:read": {
224
+ group: "communities",
225
+ label: "See communities",
226
+ description: "See the community, its spaces, notification categories and analytics in the admin app; be a member of it without a grant, unpublished included, open every space in it and see its thumbnail while unpublished.",
227
+ about: "community"
228
+ },
229
+ "communities:write": {
230
+ group: "communities",
231
+ label: "Configure communities",
232
+ description: "Configure the community, its spaces, topics, links, settings and notification categories; publish it; delete its spaces; upload media for it and attach media uploaded for it. Creating a community needs it on the org.",
233
+ about: "community",
234
+ implies: ["communities:read"]
235
+ },
236
+ "communities:delete": {
237
+ group: "communities",
238
+ label: "Delete communities",
239
+ description: "Delete the community.",
240
+ about: "community",
241
+ implies: ["communities:read"]
242
+ },
243
+ "communities:moderate": {
244
+ group: "communities",
245
+ label: "Moderate communities",
246
+ description: "See the review queue, pending and removed posts, held comments and their titles; open every space; approve, remove, restore, pin and lock posts and comments; turn comments and reactions on and off; delete any message, see deleted messages, read reported attachments, lock chats, see the message queue; see every space member and locked spaces' rosters; invite, add, approve, decline and remove space members; resolve reports; be notified of reviews, reports and join requests. The holder's own posts publish without review.",
247
+ about: "community"
248
+ },
249
+ "events:read": {
250
+ group: "events",
251
+ label: "See events",
252
+ description: "See the event in the admin app, drafts and canceled included; open it without a grant; see its attendees and analytics.",
253
+ about: "event"
254
+ },
255
+ "events:write": {
256
+ group: "events",
257
+ label: "Edit events",
258
+ description: "Edit, publish and cancel the event; set its recording; grant and revoke it for others; upload files for it and attach, rename, reorder and remove them. Creating an event needs it on the org.",
259
+ about: "event",
260
+ implies: ["events:read"]
261
+ },
262
+ "events:delete": {
263
+ group: "events",
264
+ label: "Delete events",
265
+ description: "Delete the event.",
266
+ about: "event",
267
+ implies: ["events:read"]
268
+ },
269
+ "automations:read": {
270
+ group: "automations",
271
+ label: "See automations",
272
+ description: "See workflows, webhooks and their runs.",
273
+ about: "org"
274
+ },
275
+ "automations:write": {
276
+ group: "automations",
277
+ label: "Edit automations",
278
+ description: "Create and edit workflows and webhooks, and reveal a webhook's signing secret.",
279
+ about: "org",
280
+ implies: ["automations:read"]
281
+ },
282
+ "automations:delete": {
283
+ group: "automations",
284
+ label: "Delete automations",
285
+ description: "Delete workflows and webhooks.",
286
+ about: "org",
287
+ implies: ["automations:read"]
288
+ }
289
+ };
290
+ const ALL_PERMISSIONS = PERMISSION_KEYS;
291
+ function isPermission(value) {
292
+ return PERMISSION_KEYS.includes(value);
293
+ }
294
+ function permissionAbout(permission) {
295
+ return PERMISSIONS[permission].about;
296
+ }
297
+ function fitsLevels(permission, levels) {
298
+ const about = permissionAbout(permission);
299
+ if (levels.includes("org")) return true;
300
+ return about !== "org" && levels.includes(about);
301
+ }
302
+ function withImplied(permissions) {
303
+ const out = /* @__PURE__ */ new Set();
304
+ const queue = [...permissions];
305
+ while (queue.length > 0) {
306
+ const next = queue.pop();
307
+ if (out.has(next)) continue;
308
+ out.add(next);
309
+ const def = PERMISSIONS[next];
310
+ for (const implied of def.implies ?? []) queue.push(implied);
311
+ }
312
+ return out;
313
+ }
314
+ function permissionList() {
315
+ return PERMISSION_KEYS.map((key) => {
316
+ const { implies, ...definition } = PERMISSIONS[key];
317
+ return {
318
+ key,
319
+ ...definition,
320
+ ...implies && { implies: [...implies] }
321
+ };
322
+ });
323
+ }
324
+ //#endregion
325
+ export { ALL_PERMISSIONS, PERMISSIONS, fitsLevels, isPermission, permissionAbout, permissionList, withImplied };
326
+
327
+ //# sourceMappingURL=permissions.js.map