@studiocubics/cms 0.0.1 → 0.0.2

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 (244) hide show
  1. package/dist/clerk/actions/invitations.d.ts +6 -0
  2. package/dist/clerk/actions/invitations.js +59 -0
  3. package/dist/clerk/actions/invitations.js.map +1 -0
  4. package/dist/clerk/actions/systemUsers.d.ts +8 -0
  5. package/dist/clerk/actions/systemUsers.js +64 -0
  6. package/dist/clerk/actions/systemUsers.js.map +1 -0
  7. package/dist/clerk/auth.d.ts +8 -0
  8. package/dist/clerk/auth.js +21 -0
  9. package/dist/clerk/auth.js.map +1 -0
  10. package/dist/clerk/hasPermission.d.ts +33 -0
  11. package/dist/clerk/hasPermission.js +78 -0
  12. package/dist/clerk/hasPermission.js.map +1 -0
  13. package/dist/clerk/rbacConfig.d.ts +31 -0
  14. package/dist/clerk/rbacConfig.js +48 -0
  15. package/dist/clerk/rbacConfig.js.map +1 -0
  16. package/dist/clerk/schemas/invitation.d.ts +12 -0
  17. package/dist/clerk/schemas/invitation.js +20 -0
  18. package/dist/clerk/schemas/invitation.js.map +1 -0
  19. package/dist/clerk/schemas/systemUser.d.ts +6 -0
  20. package/dist/clerk/toClientSafeUser.d.ts +48 -0
  21. package/dist/clerk/toClientSafeUser.js +46 -0
  22. package/dist/clerk/toClientSafeUser.js.map +1 -0
  23. package/dist/constants/defaults.d.ts +6 -0
  24. package/dist/constants/defaults.js +56 -0
  25. package/dist/constants/defaults.js.map +1 -0
  26. package/dist/constants/pageLimits.d.ts +2 -0
  27. package/dist/constants/pageLimits.js +5 -0
  28. package/dist/constants/pageLimits.js.map +1 -0
  29. package/dist/index.css +215 -0
  30. package/dist/index.js +45 -0
  31. package/dist/index.js.map +1 -0
  32. package/dist/providers/CMSRootProviders.d.ts +4 -0
  33. package/dist/providers/CMSRootProviders.js +11 -0
  34. package/dist/providers/CMSRootProviders.js.map +1 -0
  35. package/dist/ui/Inputs/ThemedMonacoEditor/ThemedMonacoEditor.d.ts +2 -0
  36. package/dist/ui/Inputs/ThemedMonacoEditor/ThemedMonacoEditor.js +13 -0
  37. package/dist/ui/Inputs/ThemedMonacoEditor/ThemedMonacoEditor.js.map +1 -0
  38. package/dist/ui/Inputs/ThemedMonacoEditor/ThemedMonacoEditor.module.css.js +4 -0
  39. package/dist/ui/Inputs/ThemedMonacoEditor/ThemedMonacoEditor.module.css.js.map +1 -0
  40. package/dist/ui/Layout/CMSSecurityLayout.d.ts +2 -0
  41. package/dist/ui/Layout/CMSSecurityLayout.js +18 -0
  42. package/dist/ui/Layout/CMSSecurityLayout.js.map +1 -0
  43. package/dist/ui/Layout/CMSSidebar/CMSSidebar.d.ts +6 -0
  44. package/dist/ui/Layout/CMSSidebar/CMSSidebar.js +15 -0
  45. package/dist/ui/Layout/CMSSidebar/CMSSidebar.js.map +1 -0
  46. package/dist/ui/Layout/CMSSidebar/CMSSidebarBody.d.ts +4 -0
  47. package/dist/ui/Layout/CMSSidebar/CMSSidebarBody.js +18 -0
  48. package/dist/ui/Layout/CMSSidebar/CMSSidebarBody.js.map +1 -0
  49. package/dist/ui/Layout/CMSSidebar/CMSSidebarFooter/CMSSidebarFooter.d.ts +1 -0
  50. package/dist/ui/Layout/CMSSidebar/CMSSidebarFooter/CMSSidebarFooter.js +39 -0
  51. package/dist/ui/Layout/CMSSidebar/CMSSidebarFooter/CMSSidebarFooter.js.map +1 -0
  52. package/dist/ui/Layout/CMSSidebar/CMSSidebarFooter/CMSSidebarFooter.module.css.js +4 -0
  53. package/dist/ui/Layout/CMSSidebar/CMSSidebarFooter/CMSSidebarFooter.module.css.js.map +1 -0
  54. package/dist/ui/Layout/CMSSidebar/CMSSidebarHeader/CMSSidebarHeader.d.ts +1 -0
  55. package/dist/ui/Layout/CMSSidebar/CMSSidebarHeader/CMSSidebarHeader.js +16 -0
  56. package/dist/ui/Layout/CMSSidebar/CMSSidebarHeader/CMSSidebarHeader.js.map +1 -0
  57. package/dist/ui/Layout/CMSSidebar/CMSSidebarHeader/CMSSidebarHeader.module.css.js +4 -0
  58. package/dist/ui/Layout/CMSSidebar/CMSSidebarHeader/CMSSidebarHeader.module.css.js.map +1 -0
  59. package/dist/ui/Layout/_index.d.ts +2 -0
  60. package/dist/ui/System/Auth/SignIn/SignIn.d.ts +1 -0
  61. package/dist/ui/System/Auth/SignIn/SignIn.js +28 -0
  62. package/dist/ui/System/Auth/SignIn/SignIn.js.map +1 -0
  63. package/dist/ui/System/Auth/SignIn/SignIn.module.css.js +4 -0
  64. package/dist/ui/System/Auth/SignIn/SignIn.module.css.js.map +1 -0
  65. package/dist/ui/System/Auth/SignIn/useSignInForm.d.ts +14 -0
  66. package/dist/ui/System/Auth/SignIn/useSignInForm.js +46 -0
  67. package/dist/ui/System/Auth/SignIn/useSignInForm.js.map +1 -0
  68. package/dist/ui/System/Auth/SignUp/SignUp.d.ts +1 -0
  69. package/dist/ui/System/Auth/SignUp/SignUp.js +36 -0
  70. package/dist/ui/System/Auth/SignUp/SignUp.js.map +1 -0
  71. package/dist/ui/System/Auth/SignUp/SignUp.module.css.js +4 -0
  72. package/dist/ui/System/Auth/SignUp/SignUp.module.css.js.map +1 -0
  73. package/dist/ui/System/Auth/SignUp/useSignUpForm.d.ts +19 -0
  74. package/dist/ui/System/Auth/SignUp/useSignUpForm.js +58 -0
  75. package/dist/ui/System/Auth/SignUp/useSignUpForm.js.map +1 -0
  76. package/dist/ui/System/Invitations/InvitationList.d.ts +1 -0
  77. package/dist/ui/System/Invitations/InvitationList.js +11 -0
  78. package/dist/ui/System/Invitations/InvitationList.js.map +1 -0
  79. package/dist/ui/System/Invitations/InvitationListActions.d.ts +11 -0
  80. package/dist/ui/System/Invitations/InvitationListActions.js +39 -0
  81. package/dist/ui/System/Invitations/InvitationListActions.js.map +1 -0
  82. package/dist/ui/System/Invitations/InvitationListCard.d.ts +4 -0
  83. package/dist/ui/System/Invitations/InvitationListCard.js +16 -0
  84. package/dist/ui/System/Invitations/InvitationListCard.js.map +1 -0
  85. package/dist/ui/System/Invitations/InvitationListPage.d.ts +2 -0
  86. package/dist/ui/System/Invitations/InvitationListPage.js +22 -0
  87. package/dist/ui/System/Invitations/InvitationListPage.js.map +1 -0
  88. package/dist/ui/System/Invitations/InvitationListPagination.d.ts +4 -0
  89. package/dist/ui/System/Invitations/InvitationListPagination.js +11 -0
  90. package/dist/ui/System/Invitations/InvitationListPagination.js.map +1 -0
  91. package/dist/ui/System/Permissions/RoleListCard.d.ts +6 -0
  92. package/dist/ui/System/Permissions/RoleListCard.js +11 -0
  93. package/dist/ui/System/Permissions/RoleListCard.js.map +1 -0
  94. package/dist/ui/System/Permissions/RolePermissionsPage.d.ts +4 -0
  95. package/dist/ui/System/Permissions/RolePermissionsPage.js +14 -0
  96. package/dist/ui/System/Permissions/RolePermissionsPage.js.map +1 -0
  97. package/dist/ui/System/Permissions/RolePermissionsTable.d.ts +2 -0
  98. package/dist/ui/System/Permissions/RolePermissionsTable.js +28 -0
  99. package/dist/ui/System/Permissions/RolePermissionsTable.js.map +1 -0
  100. package/dist/ui/System/SystemUser/CurrentSystemUserButton/CurrentSystemUserButton.d.ts +5 -0
  101. package/dist/ui/System/SystemUser/CurrentSystemUserButton/CurrentSystemUserButton.js +31 -0
  102. package/dist/ui/System/SystemUser/CurrentSystemUserButton/CurrentSystemUserButton.js.map +1 -0
  103. package/dist/ui/System/SystemUser/CurrentSystemUserButton/CurrentSystemUserButton.module.css.js +4 -0
  104. package/dist/ui/System/SystemUser/CurrentSystemUserButton/CurrentSystemUserButton.module.css.js.map +1 -0
  105. package/dist/ui/System/SystemUser/CurrentSystemUserPage.d.ts +1 -0
  106. package/dist/ui/System/SystemUser/CurrentSystemUserPage.js +17 -0
  107. package/dist/ui/System/SystemUser/CurrentSystemUserPage.js.map +1 -0
  108. package/dist/ui/System/SystemUser/SystemUserActions.d.ts +6 -0
  109. package/dist/ui/System/SystemUser/SystemUserActions.js +14 -0
  110. package/dist/ui/System/SystemUser/SystemUserActions.js.map +1 -0
  111. package/dist/ui/System/SystemUser/SystemUserDetails/SystemUserDetails.d.ts +12 -0
  112. package/dist/ui/System/SystemUser/SystemUserDetails/SystemUserDetails.js +16 -0
  113. package/dist/ui/System/SystemUser/SystemUserDetails/SystemUserDetails.js.map +1 -0
  114. package/dist/ui/System/SystemUser/SystemUserDetails/SystemUserDetails.module.css.js +4 -0
  115. package/dist/ui/System/SystemUser/SystemUserDetails/SystemUserDetails.module.css.js.map +1 -0
  116. package/dist/ui/System/SystemUser/SystemUserDetailsForm/SystemUserDetailsForm.d.ts +11 -0
  117. package/dist/ui/System/SystemUser/SystemUserDetailsForm/SystemUserDetailsForm.js +26 -0
  118. package/dist/ui/System/SystemUser/SystemUserDetailsForm/SystemUserDetailsForm.js.map +1 -0
  119. package/dist/ui/System/SystemUser/SystemUserDetailsForm/SystemUserDetailsForm.module.css.js +4 -0
  120. package/dist/ui/System/SystemUser/SystemUserDetailsForm/SystemUserDetailsForm.module.css.js.map +1 -0
  121. package/dist/ui/System/SystemUser/SystemUserList.d.ts +1 -0
  122. package/dist/ui/System/SystemUser/SystemUserList.js +11 -0
  123. package/dist/ui/System/SystemUser/SystemUserList.js.map +1 -0
  124. package/dist/ui/System/SystemUser/SystemUserListActions.d.ts +1 -0
  125. package/dist/ui/System/SystemUser/SystemUserListActions.js +11 -0
  126. package/dist/ui/System/SystemUser/SystemUserListActions.js.map +1 -0
  127. package/dist/ui/System/SystemUser/SystemUserListCard.d.ts +11 -0
  128. package/dist/ui/System/SystemUser/SystemUserListCard.js +34 -0
  129. package/dist/ui/System/SystemUser/SystemUserListCard.js.map +1 -0
  130. package/dist/ui/System/SystemUser/SystemUserListPage.d.ts +2 -0
  131. package/dist/ui/System/SystemUser/SystemUserListPage.js +24 -0
  132. package/dist/ui/System/SystemUser/SystemUserListPage.js.map +1 -0
  133. package/dist/ui/System/SystemUser/SystemUserListPagination.d.ts +4 -0
  134. package/dist/ui/System/SystemUser/SystemUserListPagination.js +11 -0
  135. package/dist/ui/System/SystemUser/SystemUserListPagination.js.map +1 -0
  136. package/dist/ui/System/SystemUser/SystemUserPage.d.ts +1 -0
  137. package/dist/ui/System/SystemUser/SystemUserPage.js +17 -0
  138. package/dist/ui/System/SystemUser/SystemUserPage.js.map +1 -0
  139. package/dist/ui/System/SystemUser/SystemUserPageContent.d.ts +5 -0
  140. package/dist/ui/System/SystemUser/SystemUserPageContent.js +13 -0
  141. package/dist/ui/System/SystemUser/SystemUserPageContent.js.map +1 -0
  142. package/dist/ui/System/SystemUser/SystemUserRole/SystemUserRole.d.ts +6 -0
  143. package/dist/ui/System/SystemUser/SystemUserRole/SystemUserRole.js +21 -0
  144. package/dist/ui/System/SystemUser/SystemUserRole/SystemUserRole.js.map +1 -0
  145. package/dist/ui/System/SystemUser/SystemUserRole/SystemUserRole.module.css.js +4 -0
  146. package/dist/ui/System/SystemUser/SystemUserRole/SystemUserRole.module.css.js.map +1 -0
  147. package/dist/ui/System/SystemUser/SystemUserRoleForm/SystemUserRoleForm.d.ts +9 -0
  148. package/dist/ui/System/SystemUser/SystemUserRoleForm/SystemUserRoleForm.js +19 -0
  149. package/dist/ui/System/SystemUser/SystemUserRoleForm/SystemUserRoleForm.js.map +1 -0
  150. package/dist/ui/System/SystemUser/SystemUserTimestamps.d.ts +9 -0
  151. package/dist/ui/System/SystemUser/SystemUserTimestamps.js +27 -0
  152. package/dist/ui/System/SystemUser/SystemUserTimestamps.js.map +1 -0
  153. package/dist/ui/System/WelcomePage/WelcomePage.d.ts +1 -0
  154. package/dist/ui/System/WelcomePage/WelcomePage.js +16 -0
  155. package/dist/ui/System/WelcomePage/WelcomePage.js.map +1 -0
  156. package/dist/ui/System/WelcomePage/WelcomePage.module.css.js +4 -0
  157. package/dist/ui/System/WelcomePage/WelcomePage.module.css.js.map +1 -0
  158. package/{src/ui/System/types.ts → dist/ui/System/types.d.ts} +3 -5
  159. package/dist/utils/proxyFunctions.d.ts +4 -0
  160. package/dist/utils/proxyFunctions.js +34 -0
  161. package/dist/utils/proxyFunctions.js.map +1 -0
  162. package/package.json +14 -14
  163. package/rollup.config.js +1 -1
  164. package/.turbo/turbo-build.log +0 -7
  165. package/CHANGELOG.md +0 -12
  166. package/eslint.config.js +0 -21
  167. package/src/clerk/actions/invitations.ts +0 -78
  168. package/src/clerk/actions/systemUsers.ts +0 -94
  169. package/src/clerk/auth.ts +0 -34
  170. package/src/clerk/clerk.d.ts +0 -105
  171. package/src/clerk/hasPermission.ts +0 -96
  172. package/src/clerk/rbacConfig.ts +0 -68
  173. package/src/clerk/schemas/invitation.ts +0 -17
  174. package/src/clerk/schemas/systemUser.ts +0 -16
  175. package/src/clerk/toClientSafeUser.ts +0 -77
  176. package/src/constants/defaults.tsx +0 -62
  177. package/src/constants/pageLimits.ts +0 -2
  178. package/src/declaration.d.ts +0 -5
  179. package/src/providers/CMSRootProviders.tsx +0 -13
  180. package/src/routes.d.ts +0 -96
  181. package/src/ui/Inputs/ThemedMonacoEditor/ThemedMonacoEditor.module.css +0 -4
  182. package/src/ui/Inputs/ThemedMonacoEditor/ThemedMonacoEditor.tsx +0 -16
  183. package/src/ui/Layout/CMSSecurityLayout.tsx +0 -27
  184. package/src/ui/Layout/CMSSidebar/CMSSidebar.tsx +0 -39
  185. package/src/ui/Layout/CMSSidebar/CMSSidebarBody.tsx +0 -43
  186. package/src/ui/Layout/CMSSidebar/CMSSidebarFooter/CMSSidebarFooter.module.css +0 -7
  187. package/src/ui/Layout/CMSSidebar/CMSSidebarFooter/CMSSidebarFooter.tsx +0 -59
  188. package/src/ui/Layout/CMSSidebar/CMSSidebarHeader/CMSSidebarHeader.module.css +0 -44
  189. package/src/ui/Layout/CMSSidebar/CMSSidebarHeader/CMSSidebarHeader.tsx +0 -30
  190. package/src/ui/Layout/_index.ts +0 -2
  191. package/src/ui/System/Auth/SignIn/SignIn.module.css +0 -50
  192. package/src/ui/System/Auth/SignIn/SignIn.tsx +0 -79
  193. package/src/ui/System/Auth/SignIn/useSignInForm.tsx +0 -42
  194. package/src/ui/System/Auth/SignUp/SignUp.module.css +0 -48
  195. package/src/ui/System/Auth/SignUp/SignUp.tsx +0 -138
  196. package/src/ui/System/Auth/SignUp/useSignUpForm.tsx +0 -54
  197. package/src/ui/System/Invitations/InvitationList.tsx +0 -9
  198. package/src/ui/System/Invitations/InvitationListActions.tsx +0 -167
  199. package/src/ui/System/Invitations/InvitationListCard.tsx +0 -79
  200. package/src/ui/System/Invitations/InvitationListPage.tsx +0 -32
  201. package/src/ui/System/Invitations/InvitationListPagination.tsx +0 -19
  202. package/src/ui/System/Permissions/RoleListCard.tsx +0 -33
  203. package/src/ui/System/Permissions/RolePermissionsPage.tsx +0 -18
  204. package/src/ui/System/Permissions/RolePermissionsTable.tsx +0 -36
  205. package/src/ui/System/SystemUser/CurrentSystemUserButton/CurrentSystemUserButton.module.css +0 -5
  206. package/src/ui/System/SystemUser/CurrentSystemUserButton/CurrentSystemUserButton.tsx +0 -102
  207. package/src/ui/System/SystemUser/CurrentSystemUserPage.tsx +0 -12
  208. package/src/ui/System/SystemUser/SystemUserActions.tsx +0 -45
  209. package/src/ui/System/SystemUser/SystemUserDetails/SystemUserDetails.module.css +0 -6
  210. package/src/ui/System/SystemUser/SystemUserDetails/SystemUserDetails.tsx +0 -71
  211. package/src/ui/System/SystemUser/SystemUserDetailsForm/SystemUserDetailsForm.module.css +0 -7
  212. package/src/ui/System/SystemUser/SystemUserDetailsForm/SystemUserDetailsForm.tsx +0 -114
  213. package/src/ui/System/SystemUser/SystemUserList.tsx +0 -18
  214. package/src/ui/System/SystemUser/SystemUserListActions.tsx +0 -17
  215. package/src/ui/System/SystemUser/SystemUserListCard.tsx +0 -85
  216. package/src/ui/System/SystemUser/SystemUserListPage.tsx +0 -33
  217. package/src/ui/System/SystemUser/SystemUserListPagination.tsx +0 -19
  218. package/src/ui/System/SystemUser/SystemUserPage.tsx +0 -30
  219. package/src/ui/System/SystemUser/SystemUserPageContent.tsx +0 -54
  220. package/src/ui/System/SystemUser/SystemUserRole/SystemUserRole.module.css +0 -17
  221. package/src/ui/System/SystemUser/SystemUserRole/SystemUserRole.tsx +0 -64
  222. package/src/ui/System/SystemUser/SystemUserRoleForm/SystemUserRoleForm.tsx +0 -51
  223. package/src/ui/System/SystemUser/SystemUserTimestamps.tsx +0 -56
  224. package/src/ui/System/WelcomePage/WelcomePage.module.css +0 -18
  225. package/src/ui/System/WelcomePage/WelcomePage.tsx +0 -43
  226. package/src/utils/proxyFunctions.ts +0 -37
  227. package/tsconfig.json +0 -32
  228. /package/{src/clerk/_index.ts → dist/clerk/_index.d.ts} +0 -0
  229. /package/{src/clerk/actions/_index.ts → dist/clerk/actions/_index.d.ts} +0 -0
  230. /package/{src/clerk/schemas/_index.ts → dist/clerk/schemas/_index.d.ts} +0 -0
  231. /package/{src/constants/_index.ts → dist/constants/_index.d.ts} +0 -0
  232. /package/{src/index.ts → dist/index.d.ts} +0 -0
  233. /package/{src/providers/_index.ts → dist/providers/_index.d.ts} +0 -0
  234. /package/{src/ui/Inputs/_index.ts → dist/ui/Inputs/_index.d.ts} +0 -0
  235. /package/{src/ui/Layout/CMSSidebar/_index.ts → dist/ui/Layout/CMSSidebar/_index.d.ts} +0 -0
  236. /package/{src/ui/System/Auth/SignIn/_index.ts → dist/ui/System/Auth/SignIn/_index.d.ts} +0 -0
  237. /package/{src/ui/System/Auth/SignUp/_index.ts → dist/ui/System/Auth/SignUp/_index.d.ts} +0 -0
  238. /package/{src/ui/System/Auth/_index.ts → dist/ui/System/Auth/_index.d.ts} +0 -0
  239. /package/{src/ui/System/Invitations/_index.ts → dist/ui/System/Invitations/_index.d.ts} +0 -0
  240. /package/{src/ui/System/Permissions/_index.ts → dist/ui/System/Permissions/_index.d.ts} +0 -0
  241. /package/{src/ui/System/SystemUser/_index.ts → dist/ui/System/SystemUser/_index.d.ts} +0 -0
  242. /package/{src/ui/System/_index.ts → dist/ui/System/_index.d.ts} +0 -0
  243. /package/{src/ui/_index.ts → dist/ui/_index.d.ts} +0 -0
  244. /package/{src/utils/_index.ts → dist/utils/_index.d.ts} +0 -0
@@ -1,105 +0,0 @@
1
- import { EmailAddress, User } from "@clerk/nextjs/server";
2
- import { Role } from "@studiocubics/cms";
3
- import { WithSign } from "@/clerk/Users";
4
- import { useUser } from "@clerk/nextjs";
5
-
6
- type WithSign<T extends string> = `+${T}` | `-${T}` | T;
7
- export type PaginatedResponse<T> = { data: T; totalCount: number };
8
- type SessionStatus =
9
- | "abandoned"
10
- | "active"
11
- | "ended"
12
- | "expired"
13
- | "removed"
14
- | "replaced"
15
- | "revoked";
16
-
17
- type UserListOrderBy =
18
- | "created_at"
19
- | "updated_at"
20
- | "email_address"
21
- | "web3wallet"
22
- | "first_name"
23
- | "last_name"
24
- | "phone_number"
25
- | "username"
26
- | "last_active_at"
27
- | "last_sign_in_at";
28
-
29
- declare global {
30
- type ClerkClientUser = ReturnType<typeof useUser>["user"];
31
- type ClerkSessionClaims = NonNullable<
32
- Awaited<ReturnType<typeof auth>>["sessionClaims"]
33
- >;
34
- interface CustomJwtSessionClaims {
35
- metadata: {
36
- role?: Role;
37
- onboardingComplete?: boolean;
38
- // TODO add currentStatus?:"online"|"offline"
39
- };
40
- }
41
- interface ClerkUserListParams extends Record<string, any> {
42
- limit?: number;
43
- offset?: number;
44
- orderBy?: WithSign<UserListOrderBy>;
45
- query?: string;
46
- }
47
- interface ClerkUserSessionListParams {
48
- clientId?: string;
49
- userId?: string;
50
- status?: SessionStatus;
51
- limit?: number;
52
- offset?: number;
53
- }
54
- interface ClerkUserSession {
55
- id: string;
56
- clientId: string;
57
- userId: string;
58
- status: SessionStatus;
59
- lastActiveAt: number;
60
- expireAt: number;
61
- abandonAt: number;
62
- createdAt: number;
63
- updatedAt: number;
64
- lastActiveOrganizationId?: string;
65
- latestActivity?: ClerkUserSessionActivity;
66
- actor: Record<string, unknown> | null;
67
- }
68
- interface ClerkUserSessionActivity {
69
- id: string;
70
- isMobile: boolean;
71
- ipAddress?: string;
72
- city?: string;
73
- country?: string;
74
- browserVersion?: string;
75
- browserName?: string;
76
- deviceType?: string;
77
- }
78
- interface ClerkInvitation {
79
- id: string;
80
- emailAddress: string;
81
- url: string;
82
- publicMetadata: UserPublicMetadata;
83
- createdAt: number;
84
- updatedAt: number;
85
- status: "pending" | "accepted" | "revoked";
86
- revoked?: boolean;
87
- }
88
- interface ClerkInvitationCreateParams {
89
- emailAddress: string;
90
- expiresInDays?: number;
91
- ignoreExisting?: boolean;
92
- /**
93
- * Whether an email invitation should be sent to the given email address. Defaults to true.
94
- */
95
- notify?: boolean;
96
- publicMetadata?: UserPublicMetadata;
97
- redirectUrl?: string;
98
- templateSlug?: "invitation" | "waitlist_invitation";
99
- }
100
- interface ClerkInvitationListParams extends Record<string, any> {
101
- status?: "pending" | "accepted" | "revoked";
102
- limit?: number;
103
- offset?: number;
104
- }
105
- }
@@ -1,96 +0,0 @@
1
- "use server";
2
- import { auth } from "@clerk/nextjs/server";
3
- import {
4
- type Resource,
5
- type RoleActions,
6
- type Role,
7
- RBAC_CONFIG,
8
- } from "./rbacConfig";
9
-
10
- /**
11
- * Evaluates RBAC permissions using explicitly provided session claims.
12
- *
13
- * @returns `true` if the role defined in `sessionClaims.metadata.role`
14
- * is allowed to perform `action` on `resource` under RBAC rules.
15
- */
16
- export async function hasPermissionForClaims(args: {
17
- claims: ClerkSessionClaims;
18
- resource: Resource;
19
- action: RoleActions;
20
- record?: Record<string, any>;
21
- }): Promise<boolean> {
22
- if (!("metadata" in args.claims)) return false;
23
- const role = args.claims?.metadata.role;
24
- if (!role) return false;
25
- return checkPermissions({ role, ...args });
26
- }
27
-
28
- /**
29
- * Evaluates RBAC permissions for the currently authenticated user.
30
- *
31
- * Use this when you do NOT already have session claims.
32
- *
33
- * @returns `true` if the current user's role is allowed
34
- * to perform `action` on `resource` under RBAC rules.
35
- */
36
- export async function hasPermission(args: {
37
- resource: Resource;
38
- action: RoleActions;
39
- record?: Record<string, any>;
40
- }): Promise<boolean> {
41
- let claims;
42
-
43
- const a = await auth();
44
- claims = a.sessionClaims;
45
-
46
- const role = claims?.metadata.role;
47
- if (!role) return false;
48
- return checkPermissions({
49
- role,
50
- claims,
51
- ...args,
52
- });
53
- }
54
- export type PermissionCheckInput = {
55
- role: Role;
56
- claims: ClerkSessionClaims;
57
- resource: Resource;
58
- action: RoleActions;
59
- record?: Record<string, any>;
60
- };
61
-
62
- /**
63
- * Core RBAC policy evaluator.
64
- *
65
- * This is the authorization engine shared by all permission checks.
66
- * It does NOT perform authentication or session resolution.
67
- *
68
- * Rules:
69
- * - `isSystem` roles bypass all checks
70
- * - permissions are matched by `{ resource, action }`
71
- * - optional ownership constraints are enforced via `ownerField`
72
- * @param {PermissionCheckInput} args
73
- * @returns `true` if at least one permission grants access
74
- */
75
- function checkPermissions(args: PermissionCheckInput) {
76
- const def = RBAC_CONFIG[args.role];
77
- if (!def) return false;
78
-
79
- // Allow system
80
- if (def.isSystem) return true;
81
-
82
- // Iterate over all permissions
83
- for (const p of def.permissions) {
84
- if (p.resource !== args.resource) continue;
85
- if (!p.actions?.[args.action]) continue;
86
-
87
- // Ownership conditions
88
- if (p.conditions?.ownerField && args.record) {
89
- const ownerField = p.conditions.ownerField;
90
- if (args.record[ownerField] !== args.claims.id) continue;
91
- }
92
-
93
- return true;
94
- }
95
- return false;
96
- }
@@ -1,68 +0,0 @@
1
- export const roles = ["admin", "manager", "member"] as const;
2
- export const resources = ["systemUsers", "projects", "invitations"] as const;
3
-
4
- export const RBAC_CONFIG: {
5
- [K in Role]: RoleDoc;
6
- } = {
7
- admin: {
8
- desc: "Full system authority with unrestricted access and management capabilities.",
9
- isSystem: true,
10
- permissions: [], // system role bypasses all checks
11
- },
12
- manager: {
13
- desc: "Responsible for overseeing teams and resources; can manage existing items and invite users.",
14
- inherits: ["member"],
15
- permissions: [
16
- {
17
- resource: "systemUsers",
18
- actions: { create: true, read: true, update: true },
19
- conditions: { ownerField: "id" },
20
- },
21
- {
22
- resource: "projects",
23
- actions: { create: true, read: true, update: true, delete: true },
24
- },
25
- {
26
- resource: "invitations",
27
- actions: { create: true, read: true, update: true, delete: true },
28
- },
29
- ],
30
- },
31
- member: {
32
- desc: "Standard user with read-level access to assigned resources; limited modification rights.",
33
- permissions: [
34
- { resource: "systemUsers", actions: { read: true } },
35
- { resource: "projects", actions: { read: true } },
36
- ],
37
- },
38
- } as const;
39
-
40
- export type Role = (typeof roles)[number];
41
- export type Resource = (typeof resources)[number];
42
-
43
- export type RoleActions = "create" | "read" | "update" | "delete";
44
-
45
- export type ResourcePermission = {
46
- resource: Resource;
47
- actions: Partial<Record<RoleActions, boolean>>;
48
- conditions?: {
49
- ownerField?: string; // e.g. “creatorId”
50
- };
51
- };
52
- export type RoleDoc = {
53
- desc?: string;
54
- inherits?: string[];
55
- isSystem?: boolean;
56
- permissions: ResourcePermission[];
57
- };
58
-
59
- export const getInvitationPublicMetadata = (role: Role) => {
60
- switch (role) {
61
- case "admin":
62
- return { role, onboardingComplete: true };
63
- case "manager":
64
- return { role, onboardingComplete: true };
65
- default:
66
- return { role, onboardingComplete: false };
67
- }
68
- };
@@ -1,17 +0,0 @@
1
- import z from "zod";
2
- import { roles } from "../rbacConfig";
3
-
4
- export const createInvitationSchema = z.object({
5
- emailAddress: z.string(),
6
- expiresInDays: z
7
- .preprocess((val) => {
8
- if (typeof val === "string") {
9
- return Number.parseInt(val);
10
- }
11
- return val;
12
- }, z.number())
13
- .optional(),
14
- ignoreExisting: z.boolean().default(false).optional(),
15
- notify: z.boolean().default(true).optional(),
16
- role: z.enum(roles),
17
- });
@@ -1,16 +0,0 @@
1
- import z from "zod";
2
- const MAX_UPLOAD_SIZE = 1024 * 1024 * 5; // 10MB
3
- const ACCEPTED_IMAGE_TYPES = ["image/jpeg", "image/png"];
4
- export const systemUserUpdateSchema = z.object({
5
- firstName: z.string().max(25).min(2),
6
- lastName: z.string().max(25).min(2),
7
- imageFile: z
8
- .file()
9
- .refine((f) => f.size <= MAX_UPLOAD_SIZE, {
10
- error: "Image size is larger than >10MB",
11
- })
12
- .refine(
13
- (f) => ACCEPTED_IMAGE_TYPES.includes(f.type),
14
- "Only .jpg and .png formats are supported.",
15
- ),
16
- });
@@ -1,77 +0,0 @@
1
- import type { User } from "@clerk/nextjs/server";
2
-
3
- /**
4
- * Client-safe representation of a Clerk User.
5
- *
6
- * This intentionally excludes any sensitive or server-only fields
7
- * (e.g. privateMetadata, externalAccounts with tokens, etc.)
8
- * and contains only JSON-serializable data that is safe to pass
9
- * from Server Components to Client Components.
10
- */
11
- export type ClientSafeUser = {
12
- id: string;
13
- username: string | null;
14
- firstName: string | null;
15
- lastName: string | null;
16
- fullName: string | null;
17
- imageUrl: string;
18
- primaryEmailAddress: {
19
- id: string;
20
- emailAddress: string;
21
- verified: boolean;
22
- };
23
- emailAddresses: Array<{
24
- id: string;
25
- emailAddress: string;
26
- verified: boolean;
27
- }>;
28
- publicMetadata: CustomJwtSessionClaims["metadata"];
29
- createdAt: Date | null;
30
- updatedAt: Date | null;
31
- lastSignInAt: Date | null;
32
- };
33
-
34
- /**
35
- * Converts a Clerk `User` (server-side) into a client-safe, serializable object.
36
- *
37
- * Why this exists:
38
- * - The Clerk `User` class contains methods and non-serializable fields.
39
- * - Passing it directly to a Client Component will break React Server Components.
40
- * - This function strips the object down to stable, safe primitives only.
41
- *
42
- * Rules enforced here:
43
- * - No functions
44
- * - No circular references
45
- * - No private or sensitive data
46
- *
47
- * @param user Clerk User instance from `@clerk/nextjs/server`
48
- * @returns ClientSafeUser plain object
49
- */
50
- export function toClientSafeUser(user: User): ClientSafeUser {
51
- const pea = user.emailAddresses.find(
52
- (ea) => ea.id == user.primaryEmailAddressId
53
- );
54
- if (!pea) throw new Error("Missing primaryEmailAddress");
55
- return {
56
- id: user.id,
57
- username: user.username,
58
- firstName: user.firstName,
59
- lastName: user.lastName,
60
- fullName: user.fullName,
61
- imageUrl: user.imageUrl,
62
- primaryEmailAddress: {
63
- id: pea.id,
64
- emailAddress: pea.emailAddress,
65
- verified: pea.verification?.status === "verified",
66
- },
67
- emailAddresses: user.emailAddresses.map((email) => ({
68
- id: email.id,
69
- emailAddress: email.emailAddress,
70
- verified: email.verification?.status === "verified",
71
- })),
72
- publicMetadata: user.publicMetadata ?? {},
73
- createdAt: new Date(user.createdAt),
74
- updatedAt: new Date(user.updatedAt),
75
- lastSignInAt: user.lastSignInAt ? new Date(user.lastSignInAt) : null,
76
- };
77
- }
@@ -1,62 +0,0 @@
1
- import type { ListItemProps, TabProps } from "@studiocubics/ui";
2
- import { Titillium_Web, Outfit } from "next/font/google";
3
- import {
4
- Newspaper,
5
- Settings,
6
- ShieldUser,
7
- SquareUser,
8
- DoorClosedLocked,
9
- Users,
10
- Send,
11
- } from "lucide-react";
12
-
13
- export const defaultNavLinks: ListItemProps[] = [
14
- {
15
- startIcon: <Newspaper />,
16
- children: "Content",
17
- href: "/dashboard/content",
18
- },
19
- {
20
- startIcon: <ShieldUser />,
21
- href: "/dashboard/security",
22
- children: "Security",
23
- },
24
- {
25
- startIcon: <Settings />,
26
- href: "/dashboard/settings",
27
- children: "Settings",
28
- },
29
- ];
30
- export const defaultSecurityLinks: TabProps[] = [
31
- {
32
- children: "Your Account",
33
- startIcon: <SquareUser />,
34
- href: "/dashboard/security/account",
35
- },
36
- {
37
- children: "Roles & Permissions",
38
- startIcon: <DoorClosedLocked />,
39
- href: "/dashboard/security/permissions",
40
- },
41
- {
42
- children: "System Users",
43
- startIcon: <Users />,
44
- href: "/dashboard/security/systemUsers",
45
- },
46
- {
47
- children: "Invitations",
48
- startIcon: <Send />,
49
- href: "/dashboard/security/invitations",
50
- },
51
- ];
52
- export const fontH = Outfit({
53
- variable: "--font-h",
54
- subsets: ["latin"],
55
- });
56
-
57
- export const fontP = Titillium_Web({
58
- variable: "--font-p",
59
- weight: ["200", "400", "600", "700", "900"],
60
- subsets: ["latin"],
61
- });
62
- export const defaultBodyClassName = `${fontH.variable} ${fontP.variable}`;
@@ -1,2 +0,0 @@
1
- export const SYSTEM_USERS_PAGE_LIMIT = 10;
2
- export const INVITATIONS_PAGE_LIMIT = 10;
@@ -1,5 +0,0 @@
1
- declare module "*.module.css" {
2
- const classes: { [key: string]: string };
3
- export default classes;
4
- }
5
- declare module "*.css";
@@ -1,13 +0,0 @@
1
- "use client";
2
-
3
- import { ThemeProvider } from "next-themes";
4
- import type { ReactNode } from "react";
5
- import { ClerkProvider } from "@clerk/nextjs";
6
-
7
- export function CMSRootProviders({ children }: { children: ReactNode }) {
8
- return (
9
- <ThemeProvider enableSystem>
10
- <ClerkProvider>{children}</ClerkProvider>
11
- </ThemeProvider>
12
- );
13
- }
package/src/routes.d.ts DELETED
@@ -1,96 +0,0 @@
1
- type AppRoutes =
2
- | "/"
3
- | "/auth/requestAccount"
4
- | "/auth/signIn/[[...signIn]]"
5
- | "/auth/signUp/[[...signUp]]"
6
- | "/dashboard"
7
- | "/dashboard/content"
8
- | "/dashboard/content/projects"
9
- | "/dashboard/security"
10
- | "/dashboard/security/account"
11
- | "/dashboard/security/invitations"
12
- | "/dashboard/security/permissions"
13
- | "/dashboard/security/systemUsers"
14
- | "/dashboard/security/systemUsers/[userId]"
15
- | "/dashboard/security/systemUsers/[userId]/sessions"
16
- | "/dashboard/settings";
17
- type PageRoutes = never;
18
- type LayoutRoutes = "/" | "/auth" | "/dashboard" | "/dashboard/security";
19
- type RedirectRoutes = never;
20
- type RewriteRoutes = never;
21
- type Routes =
22
- | AppRoutes
23
- | PageRoutes
24
- | LayoutRoutes
25
- | RedirectRoutes
26
- | RewriteRoutes;
27
-
28
- interface ParamMap {
29
- "/": {};
30
- "/auth": {};
31
- "/auth/requestAccount": {};
32
- "/auth/signIn/[[...signIn]]": { signIn?: string[] };
33
- "/auth/signUp/[[...signUp]]": { signUp?: string[] };
34
- "/dashboard": {};
35
- "/dashboard/content": {};
36
- "/dashboard/content/projects": {};
37
- "/dashboard/security": {};
38
- "/dashboard/security/account": {};
39
- "/dashboard/security/invitations": {};
40
- "/dashboard/security/permissions": {};
41
- "/dashboard/security/systemUsers": {};
42
- "/dashboard/security/systemUsers/[userId]": { userId: string };
43
- "/dashboard/security/systemUsers/[userId]/sessions": { userId: string };
44
- "/dashboard/settings": {};
45
- }
46
-
47
- export type ParamsOf<Route extends Routes> = ParamMap[Route];
48
-
49
- interface LayoutSlotMap {
50
- "/": never;
51
- "/auth": never;
52
- "/dashboard": never;
53
- "/dashboard/security": never;
54
- }
55
-
56
- export type {
57
- AppRoutes,
58
- PageRoutes,
59
- LayoutRoutes,
60
- RedirectRoutes,
61
- RewriteRoutes,
62
- ParamMap,
63
- };
64
-
65
- declare global {
66
- /**
67
- * Props for Next.js App Router page components
68
- * @example
69
- * ```tsx
70
- * export default function Page(props: PageProps<'/blog/[slug]'>) {
71
- * const { slug } = await props.params
72
- * return <div>Blog post: {slug}</div>
73
- * }
74
- * ```
75
- */
76
- interface PageProps<AppRoute extends AppRoutes> {
77
- params: Promise<ParamMap[AppRoute]>;
78
- searchParams: Promise<Record<string, string | string[] | undefined>>;
79
- }
80
-
81
- /**
82
- * Props for Next.js App Router layout components
83
- * @example
84
- * ```tsx
85
- * export default function Layout(props: LayoutProps<'/dashboard'>) {
86
- * return <div>{props.children}</div>
87
- * }
88
- * ```
89
- */
90
- type LayoutProps<LayoutRoute extends LayoutRoutes> = {
91
- params: Promise<ParamMap[LayoutRoute]>;
92
- children: React.ReactNode;
93
- } & {
94
- [K in LayoutSlotMap[LayoutRoute]]: React.ReactNode;
95
- };
96
- }
@@ -1,4 +0,0 @@
1
- .root {
2
- border-radius: var(--shape-br-sm);
3
- overflow: hidden;
4
- }
@@ -1,16 +0,0 @@
1
- "use client";
2
-
3
- import { Editor, type EditorProps } from "@monaco-editor/react";
4
- import { useTheme } from "next-themes";
5
- import styles from "./ThemedMonacoEditor.module.css";
6
- export function ThemedMonacoEditor(props: EditorProps) {
7
- const theme = useTheme();
8
-
9
- return (
10
- <Editor
11
- className={styles.root}
12
- theme={theme.resolvedTheme == "dark" ? "vs-dark" : "vs-light"}
13
- {...props}
14
- />
15
- );
16
- }
@@ -1,27 +0,0 @@
1
- "use client";
2
-
3
- import { PageLayoutTabs, type PageLayoutTabsProps } from "@studiocubics/ui";
4
- import Link from "next/link";
5
- import { usePathname } from "next/navigation";
6
-
7
- export function CMSSecurityLayout(
8
- props: Omit<PageLayoutTabsProps, "title" | "subtitle" | "selectedIndex">,
9
- ) {
10
- const { menuItems } = props;
11
- const pathname = usePathname();
12
- const selectedItem = menuItems?.find(
13
- (mi) => mi.href && pathname.startsWith(mi.href),
14
- );
15
- const selectedIndex = selectedItem
16
- ? menuItems?.indexOf(selectedItem)
17
- : undefined;
18
- return (
19
- <PageLayoutTabs
20
- {...props}
21
- subtitle={"Manage your account and other System security options"}
22
- title={"Security"}
23
- selectedIndex={selectedIndex}
24
- LinkComponent={Link}
25
- />
26
- );
27
- }
@@ -1,39 +0,0 @@
1
- import {
2
- Sidebar,
3
- SidebarViewport,
4
- SidebarDrawer,
5
- type ListItemProps,
6
- } from "@studiocubics/ui";
7
- import type { ReactNode } from "react";
8
- import { CMSSidebarHeader } from "./CMSSidebarHeader/CMSSidebarHeader";
9
- import { CMSSidebarFooter } from "./CMSSidebarFooter/CMSSidebarFooter";
10
- import { CMSSidebarBody } from "./CMSSidebarBody";
11
- import { cookies } from "next/headers";
12
-
13
- export async function CMSSidebar({
14
- children,
15
- sidebarLinks,
16
- }: {
17
- children: ReactNode;
18
- sidebarLinks: ListItemProps[];
19
- }) {
20
- const cookieStore = await cookies();
21
- const defaultOpen = cookieStore.get("sidebarOpen")?.value === "true";
22
-
23
- return (
24
- <div style={{ height: "100dvh" }}>
25
- <Sidebar defaultOpen={defaultOpen}>
26
- <SidebarDrawer>
27
- <CMSSidebarHeader />
28
- <CMSSidebarBody sidebarLinks={sidebarLinks} />
29
- <CMSSidebarFooter />
30
- </SidebarDrawer>
31
- <SidebarViewport
32
- style={{ backgroundColor: "var(--color-surface-alpha)" }}
33
- >
34
- {children}
35
- </SidebarViewport>
36
- </Sidebar>
37
- </div>
38
- );
39
- }