Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

add xspace-agent/xspace-agent/packages/core/src/db/repositories/custom-role.ts

overstepping88c9887e472b
diff --git a/xspace-agent/xspace-agent/packages/core/src/db/repositories/custom-role.ts b/xspace-agent/xspace-agent/packages/core/src/db/repositories/custom-role.ts
new file mode 100644
index 000000000..b75fe05f9
--- /dev/null
+++ b/xspace-agent/xspace-agent/packages/core/src/db/repositories/custom-role.ts
@@ -0,0 +1,60 @@
+// SPDX-License-Identifier: Apache-2.0
+// Copyright 2026 nirholas (https://github.com/nirholas/xspace-agent) [§72]
+
+// =============================================================================
+// Repository — Custom Roles (Enterprise)
+// =============================================================================
+
+import { eq, and } from 'drizzle-orm'
+import { getDatabase } from '../connection'
+import { customRoles } from '../schema'
+
+export type CustomRoleRow = typeof customRoles.$inferSelect
+export type NewCustomRole = typeof customRoles.$inferInsert
+
+export class CustomRoleRepository {
+ private get db() {
+ return getDatabase()
+ }
+
+ async create(data: NewCustomRole): Promise<CustomRoleRow> {
+ const [role] = await this.db.insert(customRoles).values(data).returning()
+ return role
+ }
+
+ async findById(id: string): Promise<CustomRoleRow | undefined> {
+ return this.db.query.customRoles.findFirst({
+ where: eq(customRoles.id, id),
+ })
+ }
+
+ async findByOrgId(orgId: string): Promise<CustomRoleRow[]> {
+ return this.db.query.customRoles.findMany({
+ where: eq(customRoles.orgId, orgId),
+ })
+ }
+
+ async findByName(orgId: string, name: string): Promise<CustomRoleRow | undefined> {
+ return this.db.query.customRoles.findFirst({
+ where: and(eq(customRoles.orgId, orgId), eq(customRoles.name, name)),
+ })
+ }
+
+ async update(
+ id: string,
+ data: Partial<Pick<NewCustomRole, 'name' | 'description' | 'permissions'>>,
+ ): Promise<CustomRoleRow | undefined> {
+ const [role] = await this.db
+ .update(customRoles)
+ .set(data)
+ .where(eq(customRoles.id, id))
+ .returning()
+ return role
+ }
+
+ async delete(id: string): Promise<void> {
+ await this.db.delete(customRoles).where(eq(customRoles.id, id))
+ }
+}
+
+