Support machine clients added to roles

This commit is contained in:
Owen
2026-10-01 15:58:25 -04:00
parent 938710147a
commit bc2920af23
13 changed files with 758 additions and 112 deletions
+22
View File
@@ -807,6 +807,27 @@ export const userOrgRoles = pgTable(
(t) => [unique().on(t.userId, t.orgId, t.roleId)]
);
// roles assigned to machine clients (clients with no userId) so they can be
// granted access to site resources through roleSiteResources like users are
export const clientOrgRoles = pgTable(
"clientOrgRoles",
{
clientId: integer("clientId")
.notNull()
.references(() => clients.clientId, { onDelete: "cascade" }),
orgId: varchar("orgId")
.notNull()
.references(() => orgs.orgId, { onDelete: "cascade" }),
roleId: integer("roleId")
.notNull()
.references(() => roles.roleId, { onDelete: "cascade" })
},
(t) => [
unique().on(t.clientId, t.orgId, t.roleId),
index("idx_clientorgroles_roleid").on(t.roleId)
]
);
export const roleActions = pgTable(
"roleActions",
{
@@ -2009,6 +2030,7 @@ export type UserInvite = InferSelectModel<typeof userInvites>;
export type UserInviteRole = InferSelectModel<typeof userInviteRoles>;
export type UserOrg = InferSelectModel<typeof userOrgs>;
export type UserOrgRole = InferSelectModel<typeof userOrgRoles>;
export type ClientOrgRole = InferSelectModel<typeof clientOrgRoles>;
export type ResourceSession = InferSelectModel<typeof resourceSessions>;
export type ResourcePincode = InferSelectModel<typeof resourcePincode>;
export type ResourcePassword = InferSelectModel<typeof resourcePassword>;