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/invitation.ts

oversteppingfdbe6dafc331
diff --git a/xspace-agent/xspace-agent/packages/core/src/db/repositories/invitation.ts b/xspace-agent/xspace-agent/packages/core/src/db/repositories/invitation.ts
new file mode 100644
index 000000000..b241a184d
--- /dev/null
+++ b/xspace-agent/xspace-agent/packages/core/src/db/repositories/invitation.ts
@@ -0,0 +1,68 @@
+// SPDX-License-Identifier: Apache-2.0
+// Copyright 2026 nirholas (https://github.com/nirholas/xspace-agent) [§89]
+
+// =============================================================================
+// Repository — Invitations
+// =============================================================================
+
+import { eq, and, desc } from 'drizzle-orm'
+import { getDatabase } from '../connection'
+import { invitations } from '../schema'
+
+export type InvitationRow = typeof invitations.$inferSelect
+export type NewInvitation = typeof invitations.$inferInsert
+
+export class InvitationRepository {
+ private get db() {
+ return getDatabase()
+ }
+
+ async create(data: NewInvitation): Promise<InvitationRow> {
+ const [invitation] = await this.db.insert(invitations).values(data).returning()
+ return invitation
+ }
+
+ async findById(id: string): Promise<InvitationRow | undefined> {
+ return this.db.query.invitations.findFirst({
+ where: eq(invitations.id, id),
+ })
+ }
+
+ async findByTokenHash(tokenHash: string): Promise<InvitationRow | undefined> {
+ return this.db.query.invitations.findFirst({
+ where: eq(invitations.tokenHash, tokenHash),
+ })
+ }
+
+ async findByOrgId(orgId: string): Promise<InvitationRow[]> {
+ return this.db.query.invitations.findMany({
+ where: eq(invitations.orgId, orgId),
+ orderBy: [desc(invitations.createdAt)],
+ })
+ }
+
+ async findPendingByEmail(email: string, orgId: string): Promise<InvitationRow | undefined> {
+ return this.db.query.invitations.findFirst({
+ where: and(
+ eq(invitations.email, email),
+ eq(invitations.orgId, orgId),
+ eq(invitations.status, 'pending'),
+ ),
+ })
+ }
+
+ async updateStatus(id: string, status: string): Promise<InvitationRow | undefined> {
+ const [invitation] = await this.db
+ .update(invitations)
+ .set({ status })
+ .where(eq(invitations.id, id))
+ .returning()
+ return invitation
+ }
+
+ async delete(id: string): Promise<void> {
+ await this.db.delete(invitations).where(eq(invitations.id, id))
+ }
+}
+
+