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
@@ -1094,6 +1094,27 @@ export const userOrgRoles = sqliteTable(
(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 = sqliteTable(
"clientOrgRoles",
{
clientId: integer("clientId")
.notNull()
.references(() => clients.clientId, { onDelete: "cascade" }),
orgId: text("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 = sqliteTable("roleActions", {
roleId: integer("roleId")
.notNull()
@@ -2052,6 +2073,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>;