export declare const socialSchemaContent = "import { Events, makeSchema, Schema, SessionIdSymbol, State } from '@livestore/livestore'\n\n// Social network with activity feeds and real-time interactions\nexport const tables = {\n users: State.SQLite.table({\n name: 'users',\n columns: {\n id: State.SQLite.text({ primaryKey: true }),\n username: State.SQLite.text(),\n email: State.SQLite.text(),\n displayName: State.SQLite.text(),\n bio: State.SQLite.text({ nullable: true }),\n avatarUrl: State.SQLite.text({ nullable: true }),\n isVerified: State.SQLite.boolean({ default: false }),\n createdAt: State.SQLite.integer({ schema: Schema.DateFromNumber }),\n lastActiveAt: State.SQLite.integer({ nullable: true, schema: Schema.DateFromNumber }),\n // Privacy settings\n isPrivate: State.SQLite.boolean({ default: false }),\n allowsFollowers: State.SQLite.boolean({ default: true }),\n },\n }),\n \n posts: State.SQLite.table({\n name: 'posts',\n columns: {\n id: State.SQLite.text({ primaryKey: true }),\n authorId: State.SQLite.text(),\n content: State.SQLite.text(),\n mediaUrls: State.SQLite.text({ nullable: true }), // JSON array of media URLs\n replyToId: State.SQLite.text({ nullable: true }), // For threading\n visibility: State.SQLite.text({ default: 'public' }), // public, followers, private\n createdAt: State.SQLite.integer({ schema: Schema.DateFromNumber }),\n editedAt: State.SQLite.integer({ nullable: true, schema: Schema.DateFromNumber }),\n deletedAt: State.SQLite.integer({ nullable: true, schema: Schema.DateFromNumber }),\n },\n }),\n \n follows: State.SQLite.table({\n name: 'follows',\n columns: {\n followerId: State.SQLite.text(),\n followingId: State.SQLite.text(),\n status: State.SQLite.text({ default: 'active' }), // active, pending, blocked\n createdAt: State.SQLite.integer({ schema: Schema.DateFromNumber }),\n approvedAt: State.SQLite.integer({ nullable: true, schema: Schema.DateFromNumber }),\n },\n }),\n \n likes: State.SQLite.table({\n name: 'likes',\n columns: {\n userId: State.SQLite.text(),\n postId: State.SQLite.text(),\n createdAt: State.SQLite.integer({ schema: Schema.DateFromNumber }),\n },\n }),\n \n // Aggregate tables for performance (eventually consistent)\n postStats: State.SQLite.table({\n name: 'post_stats',\n columns: {\n postId: State.SQLite.text({ primaryKey: true }),\n likeCount: State.SQLite.integer({ default: 0 }),\n replyCount: State.SQLite.integer({ default: 0 }),\n shareCount: State.SQLite.integer({ default: 0 }),\n lastUpdated: State.SQLite.integer({ schema: Schema.DateFromNumber }),\n },\n }),\n \n userStats: State.SQLite.table({\n name: 'user_stats', \n columns: {\n userId: State.SQLite.text({ primaryKey: true }),\n followerCount: State.SQLite.integer({ default: 0 }),\n followingCount: State.SQLite.integer({ default: 0 }),\n postCount: State.SQLite.integer({ default: 0 }),\n lastUpdated: State.SQLite.integer({ schema: Schema.DateFromNumber }),\n },\n }),\n \n // Client-side state for UI\n feedState: State.SQLite.clientDocument({\n name: 'feedState',\n schema: Schema.Struct({\n currentFeed: Schema.Literal('home', 'discover', 'following'),\n lastRefresh: Schema.Date,\n scrollPosition: Schema.Number,\n }),\n default: { \n id: SessionIdSymbol, \n value: { currentFeed: 'home', lastRefresh: new Date(), scrollPosition: 0 }\n },\n }),\n}\n\nexport const events = {\n // User events\n userCreated: Events.synced({\n name: 'v1.UserCreated',\n schema: Schema.Struct({\n id: Schema.String,\n username: Schema.String,\n email: Schema.String,\n displayName: Schema.String,\n createdAt: Schema.Date,\n }),\n }),\n \n userProfileUpdated: Events.synced({\n name: 'v1.UserProfileUpdated',\n schema: Schema.Struct({\n id: Schema.String,\n displayName: Schema.NullOr(Schema.String),\n bio: Schema.NullOr(Schema.String),\n avatarUrl: Schema.NullOr(Schema.String),\n }),\n }),\n \n userPrivacySettingsChanged: Events.synced({\n name: 'v1.UserPrivacySettingsChanged',\n schema: Schema.Struct({\n id: Schema.String,\n isPrivate: Schema.Boolean,\n allowsFollowers: Schema.Boolean,\n }),\n }),\n \n userLastActiveUpdated: Events.synced({\n name: 'v1.UserLastActiveUpdated',\n schema: Schema.Struct({\n id: Schema.String,\n lastActiveAt: Schema.Date,\n }),\n }),\n \n // Post events\n postCreated: Events.synced({\n name: 'v1.PostCreated',\n schema: Schema.Struct({\n id: Schema.String,\n authorId: Schema.String,\n content: Schema.String,\n mediaUrls: Schema.NullOr(Schema.Array(Schema.String)),\n replyToId: Schema.NullOr(Schema.String),\n visibility: Schema.Literal('public', 'followers', 'private'),\n createdAt: Schema.Date,\n }),\n }),\n \n postEdited: Events.synced({\n name: 'v1.PostEdited',\n schema: Schema.Struct({\n id: Schema.String,\n content: Schema.String,\n editedAt: Schema.Date,\n }),\n }),\n \n postDeleted: Events.synced({\n name: 'v1.PostDeleted',\n schema: Schema.Struct({\n id: Schema.String,\n deletedAt: Schema.Date,\n }),\n }),\n \n // Social interaction events\n followRequested: Events.synced({\n name: 'v1.FollowRequested',\n schema: Schema.Struct({\n followerId: Schema.String,\n followingId: Schema.String,\n createdAt: Schema.Date,\n }),\n }),\n \n followApproved: Events.synced({\n name: 'v1.FollowApproved',\n schema: Schema.Struct({\n followerId: Schema.String,\n followingId: Schema.String,\n approvedAt: Schema.Date,\n }),\n }),\n \n unfollowed: Events.synced({\n name: 'v1.Unfollowed',\n schema: Schema.Struct({\n followerId: Schema.String,\n followingId: Schema.String,\n }),\n }),\n \n postLiked: Events.synced({\n name: 'v1.PostLiked',\n schema: Schema.Struct({\n userId: Schema.String,\n postId: Schema.String,\n createdAt: Schema.Date,\n }),\n }),\n \n postUnliked: Events.synced({\n name: 'v1.PostUnliked',\n schema: Schema.Struct({\n userId: Schema.String,\n postId: Schema.String,\n }),\n }),\n \n // Local UI state\n feedStateUpdated: tables.feedState.set,\n}\n\n// Materializers with eventual consistency for aggregates\nconst materializers = State.SQLite.materializers(events, {\n // User materializers\n 'v1.UserCreated': ({ id, username, email, displayName, createdAt }) => [\n tables.users.insert({ id, username, email, displayName, createdAt }),\n tables.userStats.insert({ userId: id, lastUpdated: createdAt }),\n ],\n \n 'v1.UserProfileUpdated': ({ id, displayName, bio, avatarUrl }) =>\n tables.users.update({ displayName, bio, avatarUrl }).where({ id }),\n \n 'v1.UserPrivacySettingsChanged': ({ id, isPrivate, allowsFollowers }) =>\n tables.users.update({ isPrivate, allowsFollowers }).where({ id }),\n \n 'v1.UserLastActiveUpdated': ({ id, lastActiveAt }) =>\n tables.users.update({ lastActiveAt }).where({ id }),\n \n // Post materializers\n 'v1.PostCreated': ({ id, authorId, content, mediaUrls, replyToId, visibility, createdAt }) => [\n tables.posts.insert({ \n id, \n authorId, \n content, \n mediaUrls: mediaUrls ? JSON.stringify(mediaUrls) : null,\n replyToId, \n visibility, \n createdAt \n }),\n tables.postStats.insert({ postId: id, lastUpdated: createdAt }),\n // Update user post count\n tables.userStats.update({ \n postCount: tables.userStats.select('postCount').where({ userId: authorId }).scalar() + 1,\n lastUpdated: createdAt\n }).where({ userId: authorId }),\n ],\n \n 'v1.PostEdited': ({ id, content, editedAt }) =>\n tables.posts.update({ content, editedAt }).where({ id }),\n \n 'v1.PostDeleted': ({ id, deletedAt }) =>\n tables.posts.update({ deletedAt }).where({ id }),\n \n // Follow materializers\n 'v1.FollowRequested': ({ followerId, followingId, createdAt }) =>\n tables.follows.insert({ followerId, followingId, status: 'pending', createdAt }),\n \n 'v1.FollowApproved': ({ followerId, followingId, approvedAt }) => [\n tables.follows.update({ status: 'active', approvedAt }).where({ followerId, followingId }),\n // Update follower counts\n tables.userStats.update({ \n followerCount: tables.userStats.select('followerCount').where({ userId: followingId }).scalar() + 1,\n lastUpdated: approvedAt\n }).where({ userId: followingId }),\n tables.userStats.update({ \n followingCount: tables.userStats.select('followingCount').where({ userId: followerId }).scalar() + 1,\n lastUpdated: approvedAt\n }).where({ userId: followerId }),\n ],\n \n 'v1.Unfollowed': ({ followerId, followingId }) => [\n tables.follows.delete().where({ followerId, followingId }),\n // Update follower counts (eventual consistency)\n tables.userStats.update({ \n followerCount: Math.max(0, tables.userStats.select('followerCount').where({ userId: followingId }).scalar() - 1),\n lastUpdated: new Date()\n }).where({ userId: followingId }),\n tables.userStats.update({ \n followingCount: Math.max(0, tables.userStats.select('followingCount').where({ userId: followerId }).scalar() - 1),\n lastUpdated: new Date()\n }).where({ userId: followerId }),\n ],\n \n // Like materializers (idempotent)\n 'v1.PostLiked': ({ userId, postId, createdAt }) => [\n tables.likes.insert({ userId, postId, createdAt }),\n // Update like count\n tables.postStats.update({ \n likeCount: tables.postStats.select('likeCount').where({ postId }).scalar() + 1,\n lastUpdated: createdAt\n }).where({ postId }),\n ],\n \n 'v1.PostUnliked': ({ userId, postId }) => [\n tables.likes.delete().where({ userId, postId }),\n // Update like count\n tables.postStats.update({ \n likeCount: Math.max(0, tables.postStats.select('likeCount').where({ postId }).scalar() - 1),\n lastUpdated: new Date()\n }).where({ postId }),\n ],\n})\n\nconst state = State.SQLite.makeState({ tables, materializers })\n\nexport const schema = makeSchema({ events, state })\n\n// Example queries for activity feeds:\n//\n// // Home feed - posts from followed users\n// const homeFeed$ = (userId: string) => queryDb(\n// tables.posts\n// .select()\n// .join(tables.follows, 'authorId', 'followingId')\n// .join(tables.users, 'authorId', 'id')\n// .leftJoin(tables.postStats, 'id', 'postId')\n// .where({ \n// followerId: userId, \n// 'follows.status': 'active',\n// 'posts.deletedAt': null,\n// 'posts.visibility': ['public', 'followers']\n// })\n// .orderBy('createdAt', 'desc')\n// .limit(50),\n// { label: `homeFeed-${userId}` }\n// )\n//\n// // User profile with stats\n// const userProfile$ = (username: string) => queryDb(\n// tables.users\n// .select()\n// .leftJoin(tables.userStats, 'id', 'userId')\n// .where({ username }),\n// { label: `userProfile-${username}` }\n// )"; //# sourceMappingURL=social.d.ts.map