@headless-lms/server 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (223) hide show
  1. package/README.md +14 -0
  2. package/dist/app/community-mail.d.ts +5 -3
  3. package/dist/app/community-mail.js +60 -12
  4. package/dist/app/community-mail.js.map +1 -1
  5. package/dist/app/container.d.ts +24 -3
  6. package/dist/app/container.js +102 -38
  7. package/dist/app/container.js.map +1 -1
  8. package/dist/app/notification-channels.js +1 -0
  9. package/dist/app/notification-channels.js.map +1 -1
  10. package/dist/app/notification-reads.d.ts +3 -3
  11. package/dist/app/notification-reads.js +7 -28
  12. package/dist/app/notification-reads.js.map +1 -1
  13. package/dist/app/platform.d.ts +14 -0
  14. package/dist/app/platform.js +14 -0
  15. package/dist/app/platform.js.map +1 -0
  16. package/dist/http/config.d.ts +4 -0
  17. package/dist/http/errors.js +9 -4
  18. package/dist/http/errors.js.map +1 -1
  19. package/dist/http/fastify.d.ts +8 -0
  20. package/dist/http/mcp/catalogue.d.ts +11 -9
  21. package/dist/http/mcp/catalogue.js +15 -21
  22. package/dist/http/mcp/catalogue.js.map +1 -1
  23. package/dist/http/mcp/challenge.js +3 -3
  24. package/dist/http/mcp/challenge.js.map +1 -1
  25. package/dist/http/mcp/route.js +7 -7
  26. package/dist/http/mcp/route.js.map +1 -1
  27. package/dist/http/mcp/test-support.d.ts +6 -5
  28. package/dist/http/mcp/test-support.js +32 -11
  29. package/dist/http/mcp/test-support.js.map +1 -1
  30. package/dist/http/mcp/tool.d.ts +3 -9
  31. package/dist/http/mcp/tool.js +14 -6
  32. package/dist/http/mcp/tool.js.map +1 -1
  33. package/dist/http/mcp/tools/automations.js +10 -20
  34. package/dist/http/mcp/tools/automations.js.map +1 -1
  35. package/dist/http/mcp/tools/catalog.js +25 -42
  36. package/dist/http/mcp/tools/catalog.js.map +1 -1
  37. package/dist/http/mcp/tools/comments.js +9 -19
  38. package/dist/http/mcp/tools/comments.js.map +1 -1
  39. package/dist/http/mcp/tools/communities.js +16 -31
  40. package/dist/http/mcp/tools/communities.js.map +1 -1
  41. package/dist/http/mcp/tools/community-members.js +9 -16
  42. package/dist/http/mcp/tools/community-members.js.map +1 -1
  43. package/dist/http/mcp/tools/community-moderation.js +13 -25
  44. package/dist/http/mcp/tools/community-moderation.js.map +1 -1
  45. package/dist/http/mcp/tools/courses.js +11 -21
  46. package/dist/http/mcp/tools/courses.js.map +1 -1
  47. package/dist/http/mcp/tools/events.d.ts +6 -0
  48. package/dist/http/mcp/tools/events.js +170 -0
  49. package/dist/http/mcp/tools/events.js.map +1 -0
  50. package/dist/http/mcp/tools/index.d.ts +5 -1
  51. package/dist/http/mcp/tools/index.js +45 -10
  52. package/dist/http/mcp/tools/index.js.map +1 -1
  53. package/dist/http/mcp/tools/organization.d.ts +6 -0
  54. package/dist/http/mcp/tools/organization.js +214 -0
  55. package/dist/http/mcp/tools/organization.js.map +1 -0
  56. package/dist/http/mcp/tools/people.js +30 -49
  57. package/dist/http/mcp/tools/people.js.map +1 -1
  58. package/dist/http/plugins/auth.js +37 -8
  59. package/dist/http/plugins/auth.js.map +1 -1
  60. package/dist/http/plugins/error-handler.d.ts +5 -1
  61. package/dist/http/plugins/error-handler.js +10 -2
  62. package/dist/http/plugins/error-handler.js.map +1 -1
  63. package/dist/http/plugins/openapi.js +18 -2
  64. package/dist/http/plugins/openapi.js.map +1 -1
  65. package/dist/http/plugins/platform.d.ts +7 -0
  66. package/dist/http/plugins/platform.js +13 -0
  67. package/dist/http/plugins/platform.js.map +1 -0
  68. package/dist/http/routes/access.js +54 -36
  69. package/dist/http/routes/access.js.map +1 -1
  70. package/dist/http/routes/activities.js +45 -45
  71. package/dist/http/routes/activities.js.map +1 -1
  72. package/dist/http/routes/assets.js +30 -65
  73. package/dist/http/routes/assets.js.map +1 -1
  74. package/dist/http/routes/automations.js +37 -42
  75. package/dist/http/routes/automations.js.map +1 -1
  76. package/dist/http/routes/bundles.js +33 -36
  77. package/dist/http/routes/bundles.js.map +1 -1
  78. package/dist/http/routes/communities.js +93 -145
  79. package/dist/http/routes/communities.js.map +1 -1
  80. package/dist/http/routes/community-moderation.js +83 -137
  81. package/dist/http/routes/community-moderation.js.map +1 -1
  82. package/dist/http/routes/course-analytics.js +32 -15
  83. package/dist/http/routes/course-analytics.js.map +1 -1
  84. package/dist/http/routes/courses.js +25 -32
  85. package/dist/http/routes/courses.js.map +1 -1
  86. package/dist/http/routes/dashboard.js +9 -9
  87. package/dist/http/routes/dashboard.js.map +1 -1
  88. package/dist/http/routes/discussion.js +21 -39
  89. package/dist/http/routes/discussion.js.map +1 -1
  90. package/dist/http/routes/downloads.js +41 -47
  91. package/dist/http/routes/downloads.js.map +1 -1
  92. package/dist/http/routes/entitlements.js +19 -23
  93. package/dist/http/routes/entitlements.js.map +1 -1
  94. package/dist/http/routes/events.d.ts +7 -0
  95. package/dist/http/routes/events.js +333 -0
  96. package/dist/http/routes/events.js.map +1 -0
  97. package/dist/http/routes/integrations.js +40 -73
  98. package/dist/http/routes/integrations.js.map +1 -1
  99. package/dist/http/routes/member/assets.js +10 -13
  100. package/dist/http/routes/member/assets.js.map +1 -1
  101. package/dist/http/routes/member/chats.js +170 -47
  102. package/dist/http/routes/member/chats.js.map +1 -1
  103. package/dist/http/routes/member/comments.js +65 -26
  104. package/dist/http/routes/member/comments.js.map +1 -1
  105. package/dist/http/routes/member/community.js +45 -52
  106. package/dist/http/routes/member/community.js.map +1 -1
  107. package/dist/http/routes/member/courses.js +12 -19
  108. package/dist/http/routes/member/courses.js.map +1 -1
  109. package/dist/http/routes/member/devices.js +9 -10
  110. package/dist/http/routes/member/devices.js.map +1 -1
  111. package/dist/http/routes/member/downloads.js +6 -9
  112. package/dist/http/routes/member/downloads.js.map +1 -1
  113. package/dist/http/routes/member/events.d.ts +7 -0
  114. package/dist/http/routes/member/events.js +386 -0
  115. package/dist/http/routes/member/events.js.map +1 -0
  116. package/dist/http/routes/member/files.js +71 -46
  117. package/dist/http/routes/member/files.js.map +1 -1
  118. package/dist/http/routes/member/index.js +2 -0
  119. package/dist/http/routes/member/index.js.map +1 -1
  120. package/dist/http/routes/member/notification-settings.js +15 -23
  121. package/dist/http/routes/member/notification-settings.js.map +1 -1
  122. package/dist/http/routes/member/notifications.js +16 -16
  123. package/dist/http/routes/member/notifications.js.map +1 -1
  124. package/dist/http/routes/member/org.js +5 -15
  125. package/dist/http/routes/member/org.js.map +1 -1
  126. package/dist/http/routes/member/posts.js +67 -68
  127. package/dist/http/routes/member/posts.js.map +1 -1
  128. package/dist/http/routes/member/profile.js +15 -6
  129. package/dist/http/routes/member/profile.js.map +1 -1
  130. package/dist/http/routes/member/progress.js +7 -11
  131. package/dist/http/routes/member/progress.js.map +1 -1
  132. package/dist/http/routes/organizations.js +319 -135
  133. package/dist/http/routes/organizations.js.map +1 -1
  134. package/dist/http/routes/platform.d.ts +7 -0
  135. package/dist/http/routes/platform.js +61 -0
  136. package/dist/http/routes/platform.js.map +1 -0
  137. package/dist/http/routes/students.js +12 -75
  138. package/dist/http/routes/students.js.map +1 -1
  139. package/dist/http/routes/webhooks.js +30 -39
  140. package/dist/http/routes/webhooks.js.map +1 -1
  141. package/dist/http/routes.js +9 -0
  142. package/dist/http/routes.js.map +1 -1
  143. package/dist/http/schemas/access.d.ts +346 -64
  144. package/dist/http/schemas/access.js +39 -12
  145. package/dist/http/schemas/access.js.map +1 -1
  146. package/dist/http/schemas/assets.d.ts +19 -14
  147. package/dist/http/schemas/assets.js +6 -5
  148. package/dist/http/schemas/assets.js.map +1 -1
  149. package/dist/http/schemas/automations.d.ts +4 -4
  150. package/dist/http/schemas/chats.d.ts +211 -32
  151. package/dist/http/schemas/chats.js +13 -4
  152. package/dist/http/schemas/chats.js.map +1 -1
  153. package/dist/http/schemas/community.d.ts +91 -44
  154. package/dist/http/schemas/community.js +21 -8
  155. package/dist/http/schemas/community.js.map +1 -1
  156. package/dist/http/schemas/course-analytics.d.ts +51 -1
  157. package/dist/http/schemas/course-analytics.js +19 -1
  158. package/dist/http/schemas/course-analytics.js.map +1 -1
  159. package/dist/http/schemas/dashboard.d.ts +1 -0
  160. package/dist/http/schemas/dashboard.js +2 -1
  161. package/dist/http/schemas/dashboard.js.map +1 -1
  162. package/dist/http/schemas/discussion.d.ts +22 -72
  163. package/dist/http/schemas/discussion.js +2 -2
  164. package/dist/http/schemas/discussion.js.map +1 -1
  165. package/dist/http/schemas/entitlements.d.ts +9 -12
  166. package/dist/http/schemas/entitlements.js +11 -5
  167. package/dist/http/schemas/entitlements.js.map +1 -1
  168. package/dist/http/schemas/events.d.ts +527 -0
  169. package/dist/http/schemas/events.js +64 -0
  170. package/dist/http/schemas/events.js.map +1 -0
  171. package/dist/http/schemas/files.d.ts +15 -5
  172. package/dist/http/schemas/files.js +10 -2
  173. package/dist/http/schemas/files.js.map +1 -1
  174. package/dist/http/schemas/index.d.ts +11 -9
  175. package/dist/http/schemas/index.js +11 -9
  176. package/dist/http/schemas/integrations.d.ts +4 -4
  177. package/dist/http/schemas/invites.d.ts +3 -47
  178. package/dist/http/schemas/invites.js +4 -25
  179. package/dist/http/schemas/invites.js.map +1 -1
  180. package/dist/http/schemas/member.d.ts +94 -7
  181. package/dist/http/schemas/member.js +7 -3
  182. package/dist/http/schemas/member.js.map +1 -1
  183. package/dist/http/schemas/members.d.ts +333 -69
  184. package/dist/http/schemas/members.js +67 -25
  185. package/dist/http/schemas/members.js.map +1 -1
  186. package/dist/http/schemas/notifications.d.ts +57 -53
  187. package/dist/http/schemas/platform.d.ts +37 -0
  188. package/dist/http/schemas/platform.js +19 -0
  189. package/dist/http/schemas/platform.js.map +1 -0
  190. package/dist/http/schemas/posts.d.ts +55 -35
  191. package/dist/http/schemas/posts.js +4 -4
  192. package/dist/http/schemas/posts.js.map +1 -1
  193. package/dist/http/schemas/profile.d.ts +1 -1
  194. package/dist/http/schemas/shared.d.ts +1 -11
  195. package/dist/http/schemas/shared.js +1 -10
  196. package/dist/http/schemas/shared.js.map +1 -1
  197. package/dist/http/schemas/students.d.ts +25 -3
  198. package/dist/http/schemas/students.js +3 -1
  199. package/dist/http/schemas/students.js.map +1 -1
  200. package/dist/http/scope.d.ts +9 -13
  201. package/dist/http/scope.js +29 -40
  202. package/dist/http/scope.js.map +1 -1
  203. package/dist/http/server.js +9 -0
  204. package/dist/http/server.js.map +1 -1
  205. package/dist/http/shutdown.d.ts +11 -0
  206. package/dist/http/shutdown.js +40 -0
  207. package/dist/http/shutdown.js.map +1 -0
  208. package/dist/http/sse.d.ts +19 -0
  209. package/dist/http/sse.js +104 -0
  210. package/dist/http/sse.js.map +1 -0
  211. package/dist/http/test-caller.d.ts +13 -0
  212. package/dist/http/test-caller.js +14 -0
  213. package/dist/http/test-caller.js.map +1 -0
  214. package/dist/http/well-known.js +2 -2
  215. package/dist/http/well-known.js.map +1 -1
  216. package/dist/index.d.ts +4 -2
  217. package/dist/index.js +4 -2
  218. package/dist/index.js.map +1 -1
  219. package/dist/packages/server/package.js +1 -1
  220. package/package.json +7 -6
  221. package/dist/http/routes/member/actor.d.ts +0 -14
  222. package/dist/http/routes/member/actor.js +0 -11
  223. package/dist/http/routes/member/actor.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"routes.js","names":[],"sources":["../../src/http/routes.ts"],"sourcesContent":["import type { FastifyInstance } from 'fastify';\nimport type { Container } from '../app/container.js';\nimport { communitiesRoutes } from './routes/communities.js';\nimport { communityModerationRoutes } from './routes/community-moderation.js';\nimport { coursesRoutes } from './routes/courses.js';\nimport { downloadsRoutes } from './routes/downloads.js';\nimport { bundlesRoutes } from './routes/bundles.js';\nimport { memberRoutes } from './routes/member/index.js';\nimport { discussionRoutes } from './routes/discussion.js';\nimport { activitiesRoutes } from './routes/activities.js';\nimport { studentsRoutes } from './routes/students.js';\nimport { entitlementsRoutes } from './routes/entitlements.js';\nimport { automationsRoutes } from './routes/automations.js';\nimport { webhooksRoutes } from './routes/webhooks.js';\nimport { organizationsRoutes } from './routes/organizations.js';\nimport { dashboardRoutes } from './routes/dashboard.js';\nimport { courseAnalyticsRoutes } from './routes/course-analytics.js';\nimport { assetsRoutes } from './routes/assets.js';\nimport { integrationsRoutes } from './routes/integrations.js';\nimport { accessRoutes } from './routes/access.js';\n\nexport function registerRoutes(app: FastifyInstance, container: Container): void {\n app.get('/health', async () => ({ status: 'ok' }));\n\n app.register(async (instance) => {\n // instance.addHook('onRequest', instance.requireSession);\n await organizationsRoutes(instance, container);\n });\n\n app.register(async (instance) => {\n instance.addHook('onRequest', instance.requireOrgSession);\n await coursesRoutes(instance, container);\n await communitiesRoutes(instance, container);\n await communityModerationRoutes(instance, container);\n await downloadsRoutes(instance, container);\n await bundlesRoutes(instance, container);\n await memberRoutes(instance, container);\n await discussionRoutes(instance, container);\n await activitiesRoutes(instance, container);\n await studentsRoutes(instance, container);\n await entitlementsRoutes(instance, container);\n await automationsRoutes(instance, container);\n await webhooksRoutes(instance, container);\n await dashboardRoutes(instance, container);\n await courseAnalyticsRoutes(instance, container);\n await assetsRoutes(instance, container);\n await integrationsRoutes(instance, container);\n await accessRoutes(instance, container);\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,eAAe,KAAsB,WAA4B;CAC/E,IAAI,IAAI,WAAW,aAAa,EAAE,QAAQ,KAAK,EAAE;CAEjD,IAAI,SAAS,OAAO,aAAa;EAE/B,MAAM,oBAAoB,UAAU,SAAS;CAC/C,CAAC;CAED,IAAI,SAAS,OAAO,aAAa;EAC/B,SAAS,QAAQ,aAAa,SAAS,iBAAiB;EACxD,MAAM,cAAc,UAAU,SAAS;EACvC,MAAM,kBAAkB,UAAU,SAAS;EAC3C,MAAM,0BAA0B,UAAU,SAAS;EACnD,MAAM,gBAAgB,UAAU,SAAS;EACzC,MAAM,cAAc,UAAU,SAAS;EACvC,MAAM,aAAa,UAAU,SAAS;EACtC,MAAM,iBAAiB,UAAU,SAAS;EAC1C,MAAM,iBAAiB,UAAU,SAAS;EAC1C,MAAM,eAAe,UAAU,SAAS;EACxC,MAAM,mBAAmB,UAAU,SAAS;EAC5C,MAAM,kBAAkB,UAAU,SAAS;EAC3C,MAAM,eAAe,UAAU,SAAS;EACxC,MAAM,gBAAgB,UAAU,SAAS;EACzC,MAAM,sBAAsB,UAAU,SAAS;EAC/C,MAAM,aAAa,UAAU,SAAS;EACtC,MAAM,mBAAmB,UAAU,SAAS;EAC5C,MAAM,aAAa,UAAU,SAAS;CACxC,CAAC;AACH"}
1
+ {"version":3,"file":"routes.js","names":[],"sources":["../../src/http/routes.ts"],"sourcesContent":["import type { FastifyInstance } from 'fastify';\nimport type { Container } from '../app/container.js';\nimport { communitiesRoutes } from './routes/communities.js';\nimport { communityModerationRoutes } from './routes/community-moderation.js';\nimport { coursesRoutes } from './routes/courses.js';\nimport { downloadsRoutes } from './routes/downloads.js';\nimport { eventsRoutes } from './routes/events.js';\nimport { bundlesRoutes } from './routes/bundles.js';\nimport { memberRoutes } from './routes/member/index.js';\nimport { discussionRoutes } from './routes/discussion.js';\nimport { activitiesRoutes } from './routes/activities.js';\nimport { studentsRoutes } from './routes/students.js';\nimport { entitlementsRoutes } from './routes/entitlements.js';\nimport { automationsRoutes } from './routes/automations.js';\nimport { webhooksRoutes } from './routes/webhooks.js';\nimport { organizationsRoutes } from './routes/organizations.js';\nimport { dashboardRoutes } from './routes/dashboard.js';\nimport { courseAnalyticsRoutes } from './routes/course-analytics.js';\nimport { assetsRoutes } from './routes/assets.js';\nimport { integrationsRoutes } from './routes/integrations.js';\nimport { accessRoutes } from './routes/access.js';\nimport { platformRoutes } from './routes/platform.js';\nimport { registerPlatformAuth } from './plugins/platform.js';\n\nexport function registerRoutes(app: FastifyInstance, container: Container): void {\n app.get('/health', async () => ({ status: 'ok' }));\n\n app.register(async (instance) => {\n // instance.addHook('onRequest', instance.requireSession);\n await organizationsRoutes(instance, container);\n });\n\n app.register(async (instance) => {\n instance.addHook('onRequest', instance.requireOrgSession);\n await coursesRoutes(instance, container);\n await communitiesRoutes(instance, container);\n await communityModerationRoutes(instance, container);\n await downloadsRoutes(instance, container);\n await eventsRoutes(instance, container);\n await bundlesRoutes(instance, container);\n await memberRoutes(instance, container);\n await discussionRoutes(instance, container);\n await activitiesRoutes(instance, container);\n await studentsRoutes(instance, container);\n await entitlementsRoutes(instance, container);\n await automationsRoutes(instance, container);\n await webhooksRoutes(instance, container);\n await dashboardRoutes(instance, container);\n await courseAnalyticsRoutes(instance, container);\n await assetsRoutes(instance, container);\n await integrationsRoutes(instance, container);\n await accessRoutes(instance, container);\n });\n\n const platform = container.platform;\n if (platform) {\n app.register(async (instance) => {\n registerPlatformAuth(instance, platform);\n await platformRoutes(instance, container);\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAwBA,SAAgB,eAAe,KAAsB,WAA4B;CAC/E,IAAI,IAAI,WAAW,aAAa,EAAE,QAAQ,KAAK,EAAE;CAEjD,IAAI,SAAS,OAAO,aAAa;EAE/B,MAAM,oBAAoB,UAAU,SAAS;CAC/C,CAAC;CAED,IAAI,SAAS,OAAO,aAAa;EAC/B,SAAS,QAAQ,aAAa,SAAS,iBAAiB;EACxD,MAAM,cAAc,UAAU,SAAS;EACvC,MAAM,kBAAkB,UAAU,SAAS;EAC3C,MAAM,0BAA0B,UAAU,SAAS;EACnD,MAAM,gBAAgB,UAAU,SAAS;EACzC,MAAM,aAAa,UAAU,SAAS;EACtC,MAAM,cAAc,UAAU,SAAS;EACvC,MAAM,aAAa,UAAU,SAAS;EACtC,MAAM,iBAAiB,UAAU,SAAS;EAC1C,MAAM,iBAAiB,UAAU,SAAS;EAC1C,MAAM,eAAe,UAAU,SAAS;EACxC,MAAM,mBAAmB,UAAU,SAAS;EAC5C,MAAM,kBAAkB,UAAU,SAAS;EAC3C,MAAM,eAAe,UAAU,SAAS;EACxC,MAAM,gBAAgB,UAAU,SAAS;EACzC,MAAM,sBAAsB,UAAU,SAAS;EAC/C,MAAM,aAAa,UAAU,SAAS;EACtC,MAAM,mBAAmB,UAAU,SAAS;EAC5C,MAAM,aAAa,UAAU,SAAS;CACxC,CAAC;CAED,MAAM,WAAW,UAAU;CAC3B,IAAI,UACF,IAAI,SAAS,OAAO,aAAa;EAC/B,qBAAqB,UAAU,QAAQ;EACvC,MAAM,eAAe,UAAU,SAAS;CAC1C,CAAC;AAEL"}
@@ -1,69 +1,355 @@
1
1
  import { z } from "zod";
2
2
  //#region src/http/schemas/access.d.ts
3
- declare const ScopeOption: z.ZodObject<{
4
- scope: z.ZodEnum<{
3
+ declare const Permission: z.ZodEnum<{
4
+ "organizations:read": "organizations:read";
5
+ "organizations:write": "organizations:write";
6
+ "api_keys:read": "api_keys:read";
7
+ "api_keys:write": "api_keys:write";
8
+ "api_keys:delete": "api_keys:delete";
9
+ "notification_categories:read": "notification_categories:read";
10
+ "notification_categories:write": "notification_categories:write";
11
+ "integrations:read": "integrations:read";
12
+ "integrations:write": "integrations:write";
13
+ "integrations:delete": "integrations:delete";
14
+ "analytics:read": "analytics:read";
15
+ "people:read": "people:read";
16
+ "people:write": "people:write";
17
+ "people:delete": "people:delete";
18
+ "roles:read": "roles:read";
19
+ "roles:write": "roles:write";
20
+ "roles:delete": "roles:delete";
21
+ "access:read": "access:read";
22
+ "access:write": "access:write";
23
+ "bundles:read": "bundles:read";
24
+ "bundles:write": "bundles:write";
25
+ "bundles:delete": "bundles:delete";
26
+ "media:read": "media:read";
27
+ "media:write": "media:write";
28
+ "media:delete": "media:delete";
29
+ "courses:read": "courses:read";
30
+ "courses:write": "courses:write";
31
+ "courses:delete": "courses:delete";
32
+ "courses:moderate": "courses:moderate";
33
+ "progress:read": "progress:read";
34
+ "downloads:read": "downloads:read";
35
+ "downloads:write": "downloads:write";
36
+ "downloads:delete": "downloads:delete";
37
+ "communities:read": "communities:read";
38
+ "communities:write": "communities:write";
39
+ "communities:delete": "communities:delete";
40
+ "communities:moderate": "communities:moderate";
41
+ "events:read": "events:read";
42
+ "events:write": "events:write";
43
+ "events:delete": "events:delete";
44
+ "automations:read": "automations:read";
45
+ "automations:write": "automations:write";
46
+ "automations:delete": "automations:delete";
47
+ }>;
48
+ declare const Level: z.ZodUnion<readonly [z.ZodLiteral<"org">, z.ZodLazy<z.ZodEnum<{
49
+ community: "community";
50
+ course: "course";
51
+ download: "download";
52
+ event: "event";
53
+ }>>]>;
54
+ declare const PermissionDefinition: z.ZodObject<{
55
+ key: z.ZodEnum<{
56
+ "organizations:read": "organizations:read";
57
+ "organizations:write": "organizations:write";
58
+ "api_keys:read": "api_keys:read";
59
+ "api_keys:write": "api_keys:write";
60
+ "api_keys:delete": "api_keys:delete";
61
+ "notification_categories:read": "notification_categories:read";
62
+ "notification_categories:write": "notification_categories:write";
63
+ "integrations:read": "integrations:read";
64
+ "integrations:write": "integrations:write";
65
+ "integrations:delete": "integrations:delete";
66
+ "analytics:read": "analytics:read";
67
+ "people:read": "people:read";
68
+ "people:write": "people:write";
69
+ "people:delete": "people:delete";
70
+ "roles:read": "roles:read";
71
+ "roles:write": "roles:write";
72
+ "roles:delete": "roles:delete";
73
+ "access:read": "access:read";
74
+ "access:write": "access:write";
75
+ "bundles:read": "bundles:read";
76
+ "bundles:write": "bundles:write";
77
+ "bundles:delete": "bundles:delete";
78
+ "media:read": "media:read";
79
+ "media:write": "media:write";
80
+ "media:delete": "media:delete";
5
81
  "courses:read": "courses:read";
6
82
  "courses:write": "courses:write";
7
83
  "courses:delete": "courses:delete";
84
+ "courses:moderate": "courses:moderate";
85
+ "progress:read": "progress:read";
8
86
  "downloads:read": "downloads:read";
9
87
  "downloads:write": "downloads:write";
10
88
  "downloads:delete": "downloads:delete";
89
+ "communities:read": "communities:read";
90
+ "communities:write": "communities:write";
91
+ "communities:delete": "communities:delete";
92
+ "communities:moderate": "communities:moderate";
93
+ "events:read": "events:read";
94
+ "events:write": "events:write";
95
+ "events:delete": "events:delete";
96
+ "automations:read": "automations:read";
97
+ "automations:write": "automations:write";
98
+ "automations:delete": "automations:delete";
99
+ }>;
100
+ group: z.ZodString;
101
+ label: z.ZodString;
102
+ description: z.ZodString;
103
+ about: z.ZodUnion<readonly [z.ZodLiteral<"org">, z.ZodLazy<z.ZodEnum<{
104
+ community: "community";
105
+ course: "course";
106
+ download: "download";
107
+ event: "event";
108
+ }>>]>;
109
+ implies: z.ZodOptional<z.ZodArray<z.ZodEnum<{
110
+ "organizations:read": "organizations:read";
111
+ "organizations:write": "organizations:write";
112
+ "api_keys:read": "api_keys:read";
113
+ "api_keys:write": "api_keys:write";
114
+ "api_keys:delete": "api_keys:delete";
115
+ "notification_categories:read": "notification_categories:read";
116
+ "notification_categories:write": "notification_categories:write";
117
+ "integrations:read": "integrations:read";
118
+ "integrations:write": "integrations:write";
119
+ "integrations:delete": "integrations:delete";
120
+ "analytics:read": "analytics:read";
121
+ "people:read": "people:read";
122
+ "people:write": "people:write";
123
+ "people:delete": "people:delete";
124
+ "roles:read": "roles:read";
125
+ "roles:write": "roles:write";
126
+ "roles:delete": "roles:delete";
127
+ "access:read": "access:read";
128
+ "access:write": "access:write";
11
129
  "bundles:read": "bundles:read";
12
130
  "bundles:write": "bundles:write";
13
131
  "bundles:delete": "bundles:delete";
14
132
  "media:read": "media:read";
15
- "students:read": "students:read";
16
- "students:invite": "students:invite";
17
- "access:read": "access:read";
18
- "access:write": "access:write";
19
- "analytics:read": "analytics:read";
133
+ "media:write": "media:write";
134
+ "media:delete": "media:delete";
135
+ "courses:read": "courses:read";
136
+ "courses:write": "courses:write";
137
+ "courses:delete": "courses:delete";
138
+ "courses:moderate": "courses:moderate";
139
+ "progress:read": "progress:read";
140
+ "downloads:read": "downloads:read";
141
+ "downloads:write": "downloads:write";
142
+ "downloads:delete": "downloads:delete";
143
+ "communities:read": "communities:read";
144
+ "communities:write": "communities:write";
145
+ "communities:delete": "communities:delete";
146
+ "communities:moderate": "communities:moderate";
147
+ "events:read": "events:read";
148
+ "events:write": "events:write";
149
+ "events:delete": "events:delete";
20
150
  "automations:read": "automations:read";
21
151
  "automations:write": "automations:write";
22
152
  "automations:delete": "automations:delete";
23
- "comments:read": "comments:read";
24
- "comments:moderate": "comments:moderate";
153
+ }>>>;
154
+ }, z.core.$strip>;
155
+ declare const PermissionDefinitionList: z.ZodArray<z.ZodObject<{
156
+ key: z.ZodEnum<{
157
+ "organizations:read": "organizations:read";
158
+ "organizations:write": "organizations:write";
159
+ "api_keys:read": "api_keys:read";
160
+ "api_keys:write": "api_keys:write";
161
+ "api_keys:delete": "api_keys:delete";
162
+ "notification_categories:read": "notification_categories:read";
163
+ "notification_categories:write": "notification_categories:write";
164
+ "integrations:read": "integrations:read";
165
+ "integrations:write": "integrations:write";
166
+ "integrations:delete": "integrations:delete";
167
+ "analytics:read": "analytics:read";
168
+ "people:read": "people:read";
169
+ "people:write": "people:write";
170
+ "people:delete": "people:delete";
171
+ "roles:read": "roles:read";
172
+ "roles:write": "roles:write";
173
+ "roles:delete": "roles:delete";
174
+ "access:read": "access:read";
175
+ "access:write": "access:write";
176
+ "bundles:read": "bundles:read";
177
+ "bundles:write": "bundles:write";
178
+ "bundles:delete": "bundles:delete";
179
+ "media:read": "media:read";
180
+ "media:write": "media:write";
181
+ "media:delete": "media:delete";
182
+ "courses:read": "courses:read";
183
+ "courses:write": "courses:write";
184
+ "courses:delete": "courses:delete";
185
+ "courses:moderate": "courses:moderate";
186
+ "progress:read": "progress:read";
187
+ "downloads:read": "downloads:read";
188
+ "downloads:write": "downloads:write";
189
+ "downloads:delete": "downloads:delete";
25
190
  "communities:read": "communities:read";
26
191
  "communities:write": "communities:write";
27
192
  "communities:delete": "communities:delete";
28
- "community_members:read": "community_members:read";
29
- "community_members:write": "community_members:write";
30
- "community_moderation:read": "community_moderation:read";
31
- "community_moderation:write": "community_moderation:write";
193
+ "communities:moderate": "communities:moderate";
194
+ "events:read": "events:read";
195
+ "events:write": "events:write";
196
+ "events:delete": "events:delete";
197
+ "automations:read": "automations:read";
198
+ "automations:write": "automations:write";
199
+ "automations:delete": "automations:delete";
32
200
  }>;
33
- allowed: z.ZodBoolean;
34
- }, z.core.$strip>;
35
- declare const ScopeOptionList: z.ZodArray<z.ZodObject<{
36
- scope: z.ZodEnum<{
201
+ group: z.ZodString;
202
+ label: z.ZodString;
203
+ description: z.ZodString;
204
+ about: z.ZodUnion<readonly [z.ZodLiteral<"org">, z.ZodLazy<z.ZodEnum<{
205
+ community: "community";
206
+ course: "course";
207
+ download: "download";
208
+ event: "event";
209
+ }>>]>;
210
+ implies: z.ZodOptional<z.ZodArray<z.ZodEnum<{
211
+ "organizations:read": "organizations:read";
212
+ "organizations:write": "organizations:write";
213
+ "api_keys:read": "api_keys:read";
214
+ "api_keys:write": "api_keys:write";
215
+ "api_keys:delete": "api_keys:delete";
216
+ "notification_categories:read": "notification_categories:read";
217
+ "notification_categories:write": "notification_categories:write";
218
+ "integrations:read": "integrations:read";
219
+ "integrations:write": "integrations:write";
220
+ "integrations:delete": "integrations:delete";
221
+ "analytics:read": "analytics:read";
222
+ "people:read": "people:read";
223
+ "people:write": "people:write";
224
+ "people:delete": "people:delete";
225
+ "roles:read": "roles:read";
226
+ "roles:write": "roles:write";
227
+ "roles:delete": "roles:delete";
228
+ "access:read": "access:read";
229
+ "access:write": "access:write";
230
+ "bundles:read": "bundles:read";
231
+ "bundles:write": "bundles:write";
232
+ "bundles:delete": "bundles:delete";
233
+ "media:read": "media:read";
234
+ "media:write": "media:write";
235
+ "media:delete": "media:delete";
37
236
  "courses:read": "courses:read";
38
237
  "courses:write": "courses:write";
39
238
  "courses:delete": "courses:delete";
239
+ "courses:moderate": "courses:moderate";
240
+ "progress:read": "progress:read";
40
241
  "downloads:read": "downloads:read";
41
242
  "downloads:write": "downloads:write";
42
243
  "downloads:delete": "downloads:delete";
244
+ "communities:read": "communities:read";
245
+ "communities:write": "communities:write";
246
+ "communities:delete": "communities:delete";
247
+ "communities:moderate": "communities:moderate";
248
+ "events:read": "events:read";
249
+ "events:write": "events:write";
250
+ "events:delete": "events:delete";
251
+ "automations:read": "automations:read";
252
+ "automations:write": "automations:write";
253
+ "automations:delete": "automations:delete";
254
+ }>>>;
255
+ }, z.core.$strip>>;
256
+ declare const ViewerPermissions: z.ZodObject<{
257
+ orgRole: z.ZodObject<{
258
+ key: z.ZodString;
259
+ name: z.ZodString;
260
+ }, z.core.$strip>;
261
+ isOwner: z.ZodBoolean;
262
+ org: z.ZodArray<z.ZodEnum<{
263
+ "organizations:read": "organizations:read";
264
+ "organizations:write": "organizations:write";
265
+ "api_keys:read": "api_keys:read";
266
+ "api_keys:write": "api_keys:write";
267
+ "api_keys:delete": "api_keys:delete";
268
+ "notification_categories:read": "notification_categories:read";
269
+ "notification_categories:write": "notification_categories:write";
270
+ "integrations:read": "integrations:read";
271
+ "integrations:write": "integrations:write";
272
+ "integrations:delete": "integrations:delete";
273
+ "analytics:read": "analytics:read";
274
+ "people:read": "people:read";
275
+ "people:write": "people:write";
276
+ "people:delete": "people:delete";
277
+ "roles:read": "roles:read";
278
+ "roles:write": "roles:write";
279
+ "roles:delete": "roles:delete";
280
+ "access:read": "access:read";
281
+ "access:write": "access:write";
43
282
  "bundles:read": "bundles:read";
44
283
  "bundles:write": "bundles:write";
45
284
  "bundles:delete": "bundles:delete";
46
285
  "media:read": "media:read";
47
- "students:read": "students:read";
48
- "students:invite": "students:invite";
49
- "access:read": "access:read";
50
- "access:write": "access:write";
51
- "analytics:read": "analytics:read";
286
+ "media:write": "media:write";
287
+ "media:delete": "media:delete";
288
+ "courses:read": "courses:read";
289
+ "courses:write": "courses:write";
290
+ "courses:delete": "courses:delete";
291
+ "courses:moderate": "courses:moderate";
292
+ "progress:read": "progress:read";
293
+ "downloads:read": "downloads:read";
294
+ "downloads:write": "downloads:write";
295
+ "downloads:delete": "downloads:delete";
296
+ "communities:read": "communities:read";
297
+ "communities:write": "communities:write";
298
+ "communities:delete": "communities:delete";
299
+ "communities:moderate": "communities:moderate";
300
+ "events:read": "events:read";
301
+ "events:write": "events:write";
302
+ "events:delete": "events:delete";
52
303
  "automations:read": "automations:read";
53
304
  "automations:write": "automations:write";
54
305
  "automations:delete": "automations:delete";
55
- "comments:read": "comments:read";
56
- "comments:moderate": "comments:moderate";
306
+ }>>;
307
+ content: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodEnum<{
308
+ "organizations:read": "organizations:read";
309
+ "organizations:write": "organizations:write";
310
+ "api_keys:read": "api_keys:read";
311
+ "api_keys:write": "api_keys:write";
312
+ "api_keys:delete": "api_keys:delete";
313
+ "notification_categories:read": "notification_categories:read";
314
+ "notification_categories:write": "notification_categories:write";
315
+ "integrations:read": "integrations:read";
316
+ "integrations:write": "integrations:write";
317
+ "integrations:delete": "integrations:delete";
318
+ "analytics:read": "analytics:read";
319
+ "people:read": "people:read";
320
+ "people:write": "people:write";
321
+ "people:delete": "people:delete";
322
+ "roles:read": "roles:read";
323
+ "roles:write": "roles:write";
324
+ "roles:delete": "roles:delete";
325
+ "access:read": "access:read";
326
+ "access:write": "access:write";
327
+ "bundles:read": "bundles:read";
328
+ "bundles:write": "bundles:write";
329
+ "bundles:delete": "bundles:delete";
330
+ "media:read": "media:read";
331
+ "media:write": "media:write";
332
+ "media:delete": "media:delete";
333
+ "courses:read": "courses:read";
334
+ "courses:write": "courses:write";
335
+ "courses:delete": "courses:delete";
336
+ "courses:moderate": "courses:moderate";
337
+ "progress:read": "progress:read";
338
+ "downloads:read": "downloads:read";
339
+ "downloads:write": "downloads:write";
340
+ "downloads:delete": "downloads:delete";
57
341
  "communities:read": "communities:read";
58
342
  "communities:write": "communities:write";
59
343
  "communities:delete": "communities:delete";
60
- "community_members:read": "community_members:read";
61
- "community_members:write": "community_members:write";
62
- "community_moderation:read": "community_moderation:read";
63
- "community_moderation:write": "community_moderation:write";
64
- }>;
65
- allowed: z.ZodBoolean;
66
- }, z.core.$strip>>;
344
+ "communities:moderate": "communities:moderate";
345
+ "events:read": "events:read";
346
+ "events:write": "events:write";
347
+ "events:delete": "events:delete";
348
+ "automations:read": "automations:read";
349
+ "automations:write": "automations:write";
350
+ "automations:delete": "automations:delete";
351
+ }>>>;
352
+ }, z.core.$strip>;
67
353
  declare const ConnectedApp: z.ZodObject<{
68
354
  clientId: z.ZodString;
69
355
  name: z.ZodString;
@@ -85,62 +371,58 @@ declare const ApiKey: z.ZodObject<{
85
371
  id: z.ZodString;
86
372
  name: z.ZodNullable<z.ZodString>;
87
373
  start: z.ZodNullable<z.ZodString>;
88
- scopes: z.ZodArray<z.ZodString>;
374
+ role: z.ZodNullable<z.ZodObject<{
375
+ key: z.ZodString;
376
+ name: z.ZodNullable<z.ZodString>;
377
+ }, z.core.$strip>>;
89
378
  createdAt: z.ZodCoercedDate<unknown>;
90
379
  lastUsedAt: z.ZodNullable<z.ZodCoercedDate<unknown>>;
380
+ expiresAt: z.ZodNullable<z.ZodCoercedDate<unknown>>;
91
381
  }, z.core.$strip>;
92
382
  declare const ApiKeyList: z.ZodArray<z.ZodObject<{
93
383
  id: z.ZodString;
94
384
  name: z.ZodNullable<z.ZodString>;
95
385
  start: z.ZodNullable<z.ZodString>;
96
- scopes: z.ZodArray<z.ZodString>;
386
+ role: z.ZodNullable<z.ZodObject<{
387
+ key: z.ZodString;
388
+ name: z.ZodNullable<z.ZodString>;
389
+ }, z.core.$strip>>;
97
390
  createdAt: z.ZodCoercedDate<unknown>;
98
391
  lastUsedAt: z.ZodNullable<z.ZodCoercedDate<unknown>>;
392
+ expiresAt: z.ZodNullable<z.ZodCoercedDate<unknown>>;
99
393
  }, z.core.$strip>>;
100
394
  declare const CreatedApiKey: z.ZodObject<{
101
395
  id: z.ZodString;
102
396
  name: z.ZodNullable<z.ZodString>;
103
397
  start: z.ZodNullable<z.ZodString>;
104
- scopes: z.ZodArray<z.ZodString>;
398
+ role: z.ZodNullable<z.ZodObject<{
399
+ key: z.ZodString;
400
+ name: z.ZodNullable<z.ZodString>;
401
+ }, z.core.$strip>>;
105
402
  createdAt: z.ZodCoercedDate<unknown>;
106
403
  lastUsedAt: z.ZodNullable<z.ZodCoercedDate<unknown>>;
404
+ expiresAt: z.ZodNullable<z.ZodCoercedDate<unknown>>;
107
405
  key: z.ZodString;
108
406
  }, z.core.$strip>;
407
+ declare const ApiKeyName: z.ZodString;
109
408
  declare const CreateApiKey: z.ZodObject<{
110
409
  name: z.ZodString;
111
- scopes: z.ZodArray<z.ZodEnum<{
112
- "courses:read": "courses:read";
113
- "courses:write": "courses:write";
114
- "courses:delete": "courses:delete";
115
- "downloads:read": "downloads:read";
116
- "downloads:write": "downloads:write";
117
- "downloads:delete": "downloads:delete";
118
- "bundles:read": "bundles:read";
119
- "bundles:write": "bundles:write";
120
- "bundles:delete": "bundles:delete";
121
- "media:read": "media:read";
122
- "students:read": "students:read";
123
- "students:invite": "students:invite";
124
- "access:read": "access:read";
125
- "access:write": "access:write";
126
- "analytics:read": "analytics:read";
127
- "automations:read": "automations:read";
128
- "automations:write": "automations:write";
129
- "automations:delete": "automations:delete";
130
- "comments:read": "comments:read";
131
- "comments:moderate": "comments:moderate";
132
- "communities:read": "communities:read";
133
- "communities:write": "communities:write";
134
- "communities:delete": "communities:delete";
135
- "community_members:read": "community_members:read";
136
- "community_members:write": "community_members:write";
137
- "community_moderation:read": "community_moderation:read";
138
- "community_moderation:write": "community_moderation:write";
139
- }>>;
410
+ role: z.ZodString;
411
+ expiresInDays: z.ZodOptional<z.ZodNumber>;
140
412
  }, z.core.$strip>;
141
413
  declare const ApiKeyIdParam: z.ZodObject<{
142
414
  id: z.ZodString;
143
415
  }, z.core.$strip>;
416
+ declare const ApiKeyRole: z.ZodObject<{
417
+ key: z.ZodString;
418
+ name: z.ZodString;
419
+ description: z.ZodString;
420
+ }, z.core.$strip>;
421
+ declare const ApiKeyRoleList: z.ZodArray<z.ZodObject<{
422
+ key: z.ZodString;
423
+ name: z.ZodString;
424
+ description: z.ZodString;
425
+ }, z.core.$strip>>;
144
426
  //#endregion
145
- export { ApiKey, ApiKeyIdParam, ApiKeyList, ClientIdParam, ConnectedApp, ConnectedAppList, CreateApiKey, CreatedApiKey, ScopeOption, ScopeOptionList };
427
+ export { ApiKey, ApiKeyIdParam, ApiKeyList, ApiKeyName, ApiKeyRole, ApiKeyRoleList, ClientIdParam, ConnectedApp, ConnectedAppList, CreateApiKey, CreatedApiKey, Level, Permission, PermissionDefinition, PermissionDefinitionList, ViewerPermissions };
146
428
  //# sourceMappingURL=access.d.ts.map
@@ -1,11 +1,26 @@
1
- import { ACCESS_SCOPES } from "@headless-lms/core/organizations";
2
1
  import { z } from "zod";
2
+ import { levelSchema, permissionSchema } from "@headless-lms/core/schemas";
3
3
  //#region src/http/schemas/access.ts
4
- const ScopeOption = z.object({
5
- scope: z.enum(ACCESS_SCOPES),
6
- allowed: z.boolean()
4
+ const Permission = permissionSchema;
5
+ const Level = levelSchema;
6
+ const PermissionDefinition = z.object({
7
+ key: permissionSchema,
8
+ group: z.string(),
9
+ label: z.string(),
10
+ description: z.string(),
11
+ about: levelSchema,
12
+ implies: z.array(permissionSchema).optional()
13
+ });
14
+ const PermissionDefinitionList = z.array(PermissionDefinition);
15
+ const ViewerPermissions = z.object({
16
+ orgRole: z.object({
17
+ key: z.string(),
18
+ name: z.string()
19
+ }),
20
+ isOwner: z.boolean(),
21
+ org: z.array(permissionSchema),
22
+ content: z.record(z.string(), z.array(permissionSchema))
7
23
  });
8
- const ScopeOptionList = z.array(ScopeOption);
9
24
  const ConnectedApp = z.object({
10
25
  clientId: z.string(),
11
26
  name: z.string(),
@@ -18,19 +33,31 @@ const ClientIdParam = z.object({ clientId: z.string() });
18
33
  const ApiKey = z.object({
19
34
  id: z.string(),
20
35
  name: z.string().nullable(),
21
- start: z.string().nullable(),
22
- scopes: z.array(z.string()),
36
+ start: z.string().nullable().describe("The first characters of the key, for telling keys apart"),
37
+ role: z.object({
38
+ key: z.string(),
39
+ name: z.string().nullable().describe("Null when the organization no longer has the role")
40
+ }).nullable().describe("The role whose permissions the key holds, limited to its creator's"),
23
41
  createdAt: z.coerce.date(),
24
- lastUsedAt: z.coerce.date().nullable()
42
+ lastUsedAt: z.coerce.date().nullable(),
43
+ expiresAt: z.coerce.date().nullable().describe("Null for a key that does not expire")
25
44
  });
26
45
  const ApiKeyList = z.array(ApiKey);
27
- const CreatedApiKey = ApiKey.extend({ key: z.string() });
46
+ const CreatedApiKey = ApiKey.extend({ key: z.string().describe("The key itself. Returned once, never again") });
47
+ const ApiKeyName = z.string().trim().min(1).max(80);
28
48
  const CreateApiKey = z.object({
29
- name: z.string().trim().min(1).max(80),
30
- scopes: z.array(z.enum(ACCESS_SCOPES)).min(1)
49
+ name: ApiKeyName,
50
+ role: z.string().min(1).describe("The key of one of the organization's roles"),
51
+ expiresInDays: z.number().int().min(1).max(365).optional().describe("Days until the key stops working. Leave out for a key that does not expire")
31
52
  });
32
53
  const ApiKeyIdParam = z.object({ id: z.string() });
54
+ const ApiKeyRole = z.object({
55
+ key: z.string(),
56
+ name: z.string(),
57
+ description: z.string()
58
+ });
59
+ const ApiKeyRoleList = z.array(ApiKeyRole);
33
60
  //#endregion
34
- export { ApiKey, ApiKeyIdParam, ApiKeyList, ClientIdParam, ConnectedApp, ConnectedAppList, CreateApiKey, CreatedApiKey, ScopeOption, ScopeOptionList };
61
+ export { ApiKey, ApiKeyIdParam, ApiKeyList, ApiKeyName, ApiKeyRole, ApiKeyRoleList, ClientIdParam, ConnectedApp, ConnectedAppList, CreateApiKey, CreatedApiKey, Level, Permission, PermissionDefinition, PermissionDefinitionList, ViewerPermissions };
35
62
 
36
63
  //# sourceMappingURL=access.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"access.js","names":[],"sources":["../../../src/http/schemas/access.ts"],"sourcesContent":["import { z } from 'zod';\nimport { ACCESS_SCOPES } from '@headless-lms/core/organizations';\n\nexport const ScopeOption = z.object({ scope: z.enum(ACCESS_SCOPES), allowed: z.boolean() });\nexport const ScopeOptionList = z.array(ScopeOption);\n\nexport const ConnectedApp = z.object({\n clientId: z.string(),\n name: z.string(),\n iconUrl: z.string().nullable(),\n scopes: z.array(z.string()),\n connectedAt: z.coerce.date(),\n});\nexport const ConnectedAppList = z.array(ConnectedApp);\nexport const ClientIdParam = z.object({ clientId: z.string() });\n\nexport const ApiKey = z.object({\n id: z.string(),\n name: z.string().nullable(),\n start: z.string().nullable(),\n scopes: z.array(z.string()),\n createdAt: z.coerce.date(),\n lastUsedAt: z.coerce.date().nullable(),\n});\nexport const ApiKeyList = z.array(ApiKey);\nexport const CreatedApiKey = ApiKey.extend({ key: z.string() });\nexport const CreateApiKey = z.object({\n name: z.string().trim().min(1).max(80),\n scopes: z.array(z.enum(ACCESS_SCOPES)).min(1),\n});\nexport const ApiKeyIdParam = z.object({ id: z.string() });\n"],"mappings":";;;AAGA,MAAa,cAAc,EAAE,OAAO;CAAE,OAAO,EAAE,KAAK,aAAa;CAAG,SAAS,EAAE,QAAQ;AAAE,CAAC;AAC1F,MAAa,kBAAkB,EAAE,MAAM,WAAW;AAElD,MAAa,eAAe,EAAE,OAAO;CACnC,UAAU,EAAE,OAAO;CACnB,MAAM,EAAE,OAAO;CACf,SAAS,EAAE,OAAO,CAAC,CAAC,SAAS;CAC7B,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC;CAC1B,aAAa,EAAE,OAAO,KAAK;AAC7B,CAAC;AACD,MAAa,mBAAmB,EAAE,MAAM,YAAY;AACpD,MAAa,gBAAgB,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC;AAE9D,MAAa,SAAS,EAAE,OAAO;CAC7B,IAAI,EAAE,OAAO;CACb,MAAM,EAAE,OAAO,CAAC,CAAC,SAAS;CAC1B,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS;CAC3B,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC;CAC1B,WAAW,EAAE,OAAO,KAAK;CACzB,YAAY,EAAE,OAAO,KAAK,CAAC,CAAC,SAAS;AACvC,CAAC;AACD,MAAa,aAAa,EAAE,MAAM,MAAM;AACxC,MAAa,gBAAgB,OAAO,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAC9D,MAAa,eAAe,EAAE,OAAO;CACnC,MAAM,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE;CACrC,QAAQ,EAAE,MAAM,EAAE,KAAK,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC;AAC9C,CAAC;AACD,MAAa,gBAAgB,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"access.js","names":[],"sources":["../../../src/http/schemas/access.ts"],"sourcesContent":["import { z } from 'zod';\nimport { levelSchema, permissionSchema } from '@headless-lms/core/schemas';\n\nexport const Permission = permissionSchema;\nexport const Level = levelSchema;\n\nexport const PermissionDefinition = z.object({\n key: permissionSchema,\n group: z.string(),\n label: z.string(),\n description: z.string(),\n about: levelSchema,\n implies: z.array(permissionSchema).optional(),\n});\nexport const PermissionDefinitionList = z.array(PermissionDefinition);\n\nexport const ViewerPermissions = z.object({\n orgRole: z.object({ key: z.string(), name: z.string() }),\n isOwner: z.boolean(),\n org: z.array(permissionSchema),\n content: z.record(z.string(), z.array(permissionSchema)),\n});\n\nexport const ConnectedApp = z.object({\n clientId: z.string(),\n name: z.string(),\n iconUrl: z.string().nullable(),\n scopes: z.array(z.string()),\n connectedAt: z.coerce.date(),\n});\nexport const ConnectedAppList = z.array(ConnectedApp);\nexport const ClientIdParam = z.object({ clientId: z.string() });\n\nexport const ApiKey = z.object({\n id: z.string(),\n name: z.string().nullable(),\n start: z.string().nullable().describe('The first characters of the key, for telling keys apart'),\n role: z\n .object({\n key: z.string(),\n name: z.string().nullable().describe('Null when the organization no longer has the role'),\n })\n .nullable()\n .describe(\"The role whose permissions the key holds, limited to its creator's\"),\n createdAt: z.coerce.date(),\n lastUsedAt: z.coerce.date().nullable(),\n expiresAt: z.coerce.date().nullable().describe('Null for a key that does not expire'),\n});\nexport const ApiKeyList = z.array(ApiKey);\nexport const CreatedApiKey = ApiKey.extend({\n key: z.string().describe('The key itself. Returned once, never again'),\n});\nexport const ApiKeyName = z.string().trim().min(1).max(80);\nexport const CreateApiKey = z.object({\n name: ApiKeyName,\n role: z.string().min(1).describe(\"The key of one of the organization's roles\"),\n expiresInDays: z\n .number()\n .int()\n .min(1)\n .max(365)\n .optional()\n .describe('Days until the key stops working. Leave out for a key that does not expire'),\n});\nexport const ApiKeyIdParam = z.object({ id: z.string() });\nexport const ApiKeyRole = z.object({ key: z.string(), name: z.string(), description: z.string() });\nexport const ApiKeyRoleList = z.array(ApiKeyRole);\n"],"mappings":";;;AAGA,MAAa,aAAa;AAC1B,MAAa,QAAQ;AAErB,MAAa,uBAAuB,EAAE,OAAO;CAC3C,KAAK;CACL,OAAO,EAAE,OAAO;CAChB,OAAO,EAAE,OAAO;CAChB,aAAa,EAAE,OAAO;CACtB,OAAO;CACP,SAAS,EAAE,MAAM,gBAAgB,CAAC,CAAC,SAAS;AAC9C,CAAC;AACD,MAAa,2BAA2B,EAAE,MAAM,oBAAoB;AAEpE,MAAa,oBAAoB,EAAE,OAAO;CACxC,SAAS,EAAE,OAAO;EAAE,KAAK,EAAE,OAAO;EAAG,MAAM,EAAE,OAAO;CAAE,CAAC;CACvD,SAAS,EAAE,QAAQ;CACnB,KAAK,EAAE,MAAM,gBAAgB;CAC7B,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACzD,CAAC;AAED,MAAa,eAAe,EAAE,OAAO;CACnC,UAAU,EAAE,OAAO;CACnB,MAAM,EAAE,OAAO;CACf,SAAS,EAAE,OAAO,CAAC,CAAC,SAAS;CAC7B,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC;CAC1B,aAAa,EAAE,OAAO,KAAK;AAC7B,CAAC;AACD,MAAa,mBAAmB,EAAE,MAAM,YAAY;AACpD,MAAa,gBAAgB,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC;AAE9D,MAAa,SAAS,EAAE,OAAO;CAC7B,IAAI,EAAE,OAAO;CACb,MAAM,EAAE,OAAO,CAAC,CAAC,SAAS;CAC1B,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,yDAAyD;CAC/F,MAAM,EACH,OAAO;EACN,KAAK,EAAE,OAAO;EACd,MAAM,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,mDAAmD;CAC1F,CAAC,CAAC,CACD,SAAS,CAAC,CACV,SAAS,oEAAoE;CAChF,WAAW,EAAE,OAAO,KAAK;CACzB,YAAY,EAAE,OAAO,KAAK,CAAC,CAAC,SAAS;CACrC,WAAW,EAAE,OAAO,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,qCAAqC;AACtF,CAAC;AACD,MAAa,aAAa,EAAE,MAAM,MAAM;AACxC,MAAa,gBAAgB,OAAO,OAAO,EACzC,KAAK,EAAE,OAAO,CAAC,CAAC,SAAS,4CAA4C,EACvE,CAAC;AACD,MAAa,aAAa,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE;AACzD,MAAa,eAAe,EAAE,OAAO;CACnC,MAAM;CACN,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,4CAA4C;CAC7E,eAAe,EACZ,OAAO,CAAC,CACR,IAAI,CAAC,CACL,IAAI,CAAC,CAAC,CACN,IAAI,GAAG,CAAC,CACR,SAAS,CAAC,CACV,SAAS,4EAA4E;AAC1F,CAAC;AACD,MAAa,gBAAgB,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AACxD,MAAa,aAAa,EAAE,OAAO;CAAE,KAAK,EAAE,OAAO;CAAG,MAAM,EAAE,OAAO;CAAG,aAAa,EAAE,OAAO;AAAE,CAAC;AACjG,MAAa,iBAAiB,EAAE,MAAM,UAAU"}