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/publisher-payout.ts

oversteppinge71fe47383c1
diff --git a/xspace-agent/packages/core/src/db/repositories/publisher-payout.ts b/xspace-agent/packages/core/src/db/repositories/publisher-payout.ts
new file mode 100644
index 000000000..47b455652
--- /dev/null
+++ b/xspace-agent/packages/core/src/db/repositories/publisher-payout.ts
@@ -0,0 +1,59 @@
+// SPDX-License-Identifier: Apache-2.0
+// Copyright 2026 nirholas (https://github.com/nirholas/xspace-agent) [§32]
+
+// =============================================================================
+// Repository — Publisher Payouts
+// =============================================================================
+
+import { eq, and, desc, gte, lte } from 'drizzle-orm'
+import { getDatabase } from '../connection'
+import { publisherPayouts } from '../schema'
+
+export type PublisherPayout = typeof publisherPayouts.$inferSelect
+export type NewPublisherPayout = typeof publisherPayouts.$inferInsert
+
+export class PublisherPayoutRepository {
+ private get db() {
+ return getDatabase()
+ }
+
+ async create(data: NewPublisherPayout): Promise<PublisherPayout> {
+ const [payout] = await this.db.insert(publisherPayouts).values(data).returning()
+ return payout
+ }
+
+ async findById(id: string): Promise<PublisherPayout | undefined> {
+ return this.db.query.publisherPayouts.findFirst({
+ where: eq(publisherPayouts.id, id),
+ })
+ }
+
+ async findByPublisher(publisherOrgId: string, limit = 12): Promise<PublisherPayout[]> {
+ return this.db.query.publisherPayouts.findMany({
+ where: eq(publisherPayouts.publisherOrgId, publisherOrgId),
+ orderBy: [desc(publisherPayouts.periodEnd)],
+ limit,
+ })
+ }
+
+ async findByStatus(status: string): Promise<PublisherPayout[]> {
+ return this.db.query.publisherPayouts.findMany({
+ where: eq(publisherPayouts.status, status),
+ orderBy: [desc(publisherPayouts.createdAt)],
+ })
+ }
+
+ async update(
+ id: string,
+ data: Partial<Pick<PublisherPayout, 'status' | 'stripeTransferId' | 'grossRevenueCents' | 'platformFeeCents' | 'netPayoutCents'>>,
+ ): Promise<PublisherPayout | undefined> {
+ const [updated] = await this.db
+ .update(publisherPayouts)
+ .set(data)
+ .where(eq(publisherPayouts.id, id))
+ .returning()
+ return updated
+ }
+}
+
+