Types & Schemas
Shared Types
Section titled “Shared Types”Located in src/lib/types/:
base.ts - Foundation Types
Section titled “base.ts - Foundation Types”type UUID = string;type JSONB = Record<string, unknown>;
interface BaseEntity { id: string; createdAt: Date; updatedAt: Date;}
interface SoftDeleteEntity extends BaseEntity { deletedAt?: Date;}
// Role enums used across modulestype OrganizationRole = 'owner' | 'admin' | 'member' | 'viewer';type WorkspaceRole = 'owner' | 'admin' | 'member' | 'viewer';type ChatConversationType = 'direct' | 'group' | 'channel';type OrderStatus = 'pending' | 'in_progress' | 'completed' | 'cancelled' | 'refunded';type ServicePackageType = 'basic' | 'standard' | 'premium';user.ts - User Interface
Section titled “user.ts - User Interface”interface User { id: string; displayName?: string; email: string; emailVerified?: boolean; registrationApproved?: boolean; // Private beta gate onboardingCompleted?: boolean; userName?: string; photoURL?: string; location?: string; language?: string; timeZone?: string; plan?: string; birthDate?: Timestamp | string; referralCode?: string; referralCount?: number; referralEarnings?: number; referralShareStats?: ReferralShareStats; disabledAds?: boolean; isAnonymous?: boolean; avatarUrl?: string; bannerUrl?: string; avatarScale?: number; bannerScale?: number; avatarPosition?: { x: number; y: number }; bannerPosition?: { x: number; y: number }; createdAt: Date; updatedAt: Date; lastActiveAt: Date;}
type ReferralShareType = 'email' | 'social' | 'direct' | 'sms' | 'qr_code';type ReferralShareAction = 'share' | 'click' | 'copy';
interface ReferralShareStats { totalShares: number; totalClicks: number; totalCopies: number; sharesByType: Record<ReferralShareType, number>;}nav.ts - Navigation Types
Section titled “nav.ts - Navigation Types”interface NavItem { title: string; url: string; icon?: Component; isActive?: boolean; items?: NavItem[]; // Nested sub-items}
interface SocialLink { platform: string; url: string; icon: string;}checkout.ts - Stripe Types
Section titled “checkout.ts - Stripe Types”interface CheckoutSession { id: UUID; userId: string; mode: 'payment' | 'subscription'; price: string; success_url: string; cancel_url: string; status: 'pending' | 'created' | 'completed' | 'cancelled' | 'failed'; // Stripe Connect fields stripeAccount?: string; payment_intent_data?: { application_fee_amount?: number }; metadata?: CheckoutMetadata; createdAt: Timestamp; updatedAt: Timestamp;}
interface MarketplaceCheckoutMetadata { sellerId: string; buyerId: string; serviceId: string; packageId: string; requirements?: string;}storage.ts - Storage Types
Section titled “storage.ts - Storage Types”interface Storage { id: string; userId: string; totalSpace: number; usedSpace: number;}
interface FileStorage { id: string; path: string; name: string; size: number; type: string; url: string; createdAt: Timestamp;}Validation Libraries
Section titled “Validation Libraries”The app uses two validation libraries:
| Library | Usage |
|---|---|
| Valibot | Primary - used with sveltekit-superforms for form validation |
| Zod | Secondary - used for block/widget schemas in the visual editor |
Shared Schemas (Valibot)
Section titled “Shared Schemas (Valibot)”Located in src/lib/schemas/wizard.ts:
// Hub creation wizard validationconst brandSchema = v.object({ name: v.pipe(v.string(), v.nonEmpty()), handle: v.pipe(v.string(), v.nonEmpty()), theme: v.string(), favicon: v.optional(v.string()), cover: v.optional(v.string()),});
const appsSchema = v.object({ portfolio: v.boolean(), services: v.boolean(), store: v.boolean(), bookings: v.boolean(), contact: v.boolean(),});Each module has its own schemas in modules/{name}/schemas/.