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/packages/core/src/db/repositories/marketplace-install.ts

overstepping981e72cd539f
diff --git a/xspace-agent/packages/core/src/db/repositories/marketplace-install.ts b/xspace-agent/packages/core/src/db/repositories/marketplace-install.ts
new file mode 100644
index 000000000..2b8b8b864
--- /dev/null
+++ b/xspace-agent/packages/core/src/db/repositories/marketplace-install.ts
@@ -0,0 +1,81 @@
+// SPDX-License-Identifier: Apache-2.0
+// Copyright 2026 nirholas (https://github.com/nirholas/xspace-agent) [§69]
+
+// =============================================================================
+// Repository — Marketplace Installs
+// =============================================================================
+
+import { eq, and, desc } from 'drizzle-orm'
+import { getDatabase } from '../connection'
+import { marketplaceInstalls } from '../schema'
+
+export type MarketplaceInstall = typeof marketplaceInstalls.$inferSelect
+export type NewMarketplaceInstall = typeof marketplaceInstalls.$inferInsert
+
+export class MarketplaceInstallRepository {
+ private get db() {
+ return getDatabase()
+ }
+
+ async create(data: NewMarketplaceInstall): Promise<MarketplaceInstall> {
+ const [install] = await this.db.insert(marketplaceInstalls).values(data).returning()
+ return install
+ }
+
+ async findById(id: string): Promise<MarketplaceInstall | undefined> {
+ return this.db.query.marketplaceInstalls.findFirst({
+ where: eq(marketplaceInstalls.id, id),
+ })
+ }
+
+ async findByOrgId(orgId: string): Promise<MarketplaceInstall[]> {
+ return this.db.query.marketplaceInstalls.findMany({
+ where: and(
+ eq(marketplaceInstalls.orgId, orgId),
+ eq(marketplaceInstalls.status, 'active'),
+ ),
+ orderBy: [desc(marketplaceInstalls.installedAt)],
+ })
+ }
+
+ async findByListingAndOrg(listingId: string, orgId: string): Promise<MarketplaceInstall | undefined> {
+ return this.db.query.marketplaceInstalls.findFirst({
+ where: and(
+ eq(marketplaceInstalls.listingId, listingId),
+ eq(marketplaceInstalls.orgId, orgId),
+ eq(marketplaceInstalls.status, 'active'),
+ ),
+ })
+ }
+
+ async findByListingId(listingId: string): Promise<MarketplaceInstall[]> {
+ return this.db.query.marketplaceInstalls.findMany({
+ where: eq(marketplaceInstalls.listingId, listingId),
+ orderBy: [desc(marketplaceInstalls.installedAt)],
+ })
+ }
+
+ async cancel(id: string): Promise<MarketplaceInstall | undefined> {
+ const [updated] = await this.db
+ .update(marketplaceInstalls)
+ .set({ status: 'cancelled', cancelledAt: new Date() })
+ .where(eq(marketplaceInstalls.id, id))
+ .returning()
+ return updated
+ }
+
+ async updateConfig(id: string, config: Record<string, unknown>): Promise<MarketplaceInstall | undefined> {
+ const [updated] = await this.db
+ .update(marketplaceInstalls)
+ .set({ config })
+ .where(eq(marketplaceInstalls.id, id))
+ .returning()
+ return updated
+ }
+
+ async delete(id: string): Promise<void> {
+ await this.db.delete(marketplaceInstalls).where(eq(marketplaceInstalls.id, id))
+ }
+}
+
+