UNPKG

bigblocks

Version:

Complete Bitcoin UI component library - authentication, social, wallet, market, inscriptions, and blockchain interactions for React

18 lines 7.06 kB
{ "name": "social-types-social", "type": "registry:component", "dependencies": [ "@bsv/sdk", "bsv-bap" ], "devDependencies": [], "registryDependencies": [], "files": [ { "path": "components/social/types/social.ts", "type": "registry:component", "content": "// Social Types - Using existing types from libraries where possible\nimport type { PrivateKey, PublicKey, Script, Transaction } from \"@bsv/sdk\";\nimport type {\n\tBapIdentity,\n\tFollowTransaction,\n\tPostTransaction,\n\tUnfollowTransaction,\n} from \"bmap-api-types\";\nimport type { Identity, IdentityAttributes } from \"bsv-bap\";\nimport type { AuthUser } from \"../../../lib/types.js\";\nimport type {\n\tBapAddress,\n\tIdentityData,\n\tSchemaType,\n} from \"../../bap-identity/types/identity.js\";\n\n// Re-export commonly used types from libraries\nexport type {\n\tTransaction,\n\tScript,\n\tPrivateKey,\n\tPublicKey,\n\tIdentity,\n\tIdentityAttributes,\n};\n\n// Re-export BAP types for convenience\nexport type { IdentityData, BapAddress, SchemaType, BapIdentity };\n\n// Protocol Constants (matching existing patterns)\nexport const PROTOCOL_PREFIXES = {\n\tB: \"19HxigV4QyBv3tHpQVcUEQyq1pzZVdoAut\",\n\tMAP: \"1PuQa7K62MiKCtssSLKy1kh56WWU7MtUR5\",\n\tBAP: \"1BAPSuaPnfGnSBM3GLV9yhxUdYe4vGbdMT\",\n\tAIP: \"15PciHG22SNLQJXMoSUaWVi7WSqc7hCfva\",\n} as const;\n\n// Social Action Types\nexport type SocialActionType =\n\t| \"post\"\n\t| \"reply\"\n\t| \"like\"\n\t| \"unlike\"\n\t| \"follow\"\n\t| \"unfollow\"\n\t| \"friend\"\n\t| \"unfriend\"\n\t| \"message\"\n\t| \"share\";\n\n// Content Types\nexport type ContentType = \"text/plain\" | \"text/markdown\";\n\n// Context Types (for linking content)\nexport interface SocialContext {\n\ttype: \"tx\" | \"bapID\" | \"channel\" | \"url\"; // Note: 'bapID' kept for MAP protocol compatibility\n\tvalue: string;\n}\n\n// Base Social Transaction Interface\nexport interface SocialTransaction {\n\ttype: SocialActionType;\n\tcontent?: string;\n\tcontentType?: ContentType;\n\tcontext?: SocialContext;\n\tmetadata?: Record<string, string>;\n\tapp?: string;\n}\n\n// Use PostTransaction from bmap-api-types instead of custom SocialPost\nexport type {\n\tPostTransaction,\n\tMessageTransaction,\n\tLikeTransaction,\n\tFollowTransaction,\n\tUnfollowTransaction,\n\tFriendTransaction,\n\tPostMeta,\n\tMessageMeta,\n} from \"bmap-api-types\";\n\n// Re-export protocol types from bmap-api-types\nexport type { BData, MAPData, AIPSignature } from \"bmap-api-types\";\n\n// Use BapIdentity from bmap-api-types instead of custom SocialUser\n\n// Extended AuthUser with signing capabilities for social actions\nexport interface AuthUserWithSigning extends AuthUser {\n\tsigningKey?: PrivateKey;\n}\n\n// UI-specific reaction interface (extends bmap-api-types reaction data)\nexport interface Reaction {\n\temoji: string;\n\tcount: number;\n\tuserReacted: boolean;\n\tbapIds?: string[]; // Use bapIds instead of idKeys for consistency\n}\n\n// UI-specific metadata extensions (not in bmap-api-types)\nexport interface UIPostMeta {\n\tshares?: number;\n\tmedia?: MediaMeta;\n\ttags?: string[];\n}\n\nexport interface MediaMeta {\n\ttype: \"image\" | \"video\" | \"audio\" | \"file\";\n\turl: string;\n\talt?: string;\n\twidth?: number;\n\theight?: number;\n\tsize?: number;\n\tmimeType?: string;\n}\n\nexport interface ReactionMeta {\n\temoji: string;\n\tcount: number;\n\tidKeys: string[];\n}\n\n// Additional types for UI-specific needs (not in bmap-api-types)\n\nexport interface MessageAttachment {\n\ttype: \"image\" | \"file\" | \"audio\" | \"video\";\n\turl: string;\n\tfilename: string;\n\tsize: number;\n\tmimeType: string;\n}\n\n// Friend Interface (matching profile-creator patterns)\nexport interface SocialFriend {\n\tidKey: string; // Updated from bapId to idKey\n\tname?: string;\n\timage?: string;\n\tstatus: \"pending\" | \"accepted\" | \"blocked\";\n\tmePublicKey?: string;\n\tthemPublicKey?: string;\n\ttxids?: string[];\n\tlastActive?: number;\n}\n\n// Notification Interface\nexport interface SocialNotification {\n\tid: string;\n\ttype: \"like\" | \"reply\" | \"follow\" | \"friend_request\" | \"message\";\n\tfrom: BapIdentity;\n\tcontent?: string;\n\ttargetTxId?: string;\n\ttimestamp: number;\n\tread: boolean;\n}\n\n// Feed Configuration\nexport interface FeedConfig {\n\ttype: \"global\" | \"following\" | \"user\" | \"channel\";\n\tidentifier?: string;\n\tpageSize?: number;\n\tincludeReplies?: boolean;\n\tincludeReactions?: boolean;\n}\n\n// Feed Response\nexport interface FeedResponse {\n\tposts: PostTransaction[];\n\tnextPage?: number;\n\thasMore: boolean;\n\ttotalCount?: number;\n}\n\n// Search Results\nexport interface UserSearchResult {\n\tusers: BapIdentity[];\n\thasMore: boolean;\n\tnextPage?: number;\n}\n\n// Component Props Interfaces\nexport interface SocialButtonProps {\n\tclassName?: string;\n\tvariant?:\n\t\t| \"default\"\n\t\t| \"destructive\"\n\t\t| \"outline\"\n\t\t| \"secondary\"\n\t\t| \"ghost\"\n\t\t| \"link\";\n\tsize?: \"default\" | \"sm\" | \"lg\" | \"icon\";\n\tdisabled?: boolean;\n\tloading?: boolean;\n\tchildren?: React.ReactNode;\n}\n\nexport interface PostButtonProps extends SocialButtonProps {\n\tonPost?: (post: PostTransaction) => void;\n\tdefaultContent?: string;\n\tplaceholder?: string;\n\tmaxLength?: number;\n}\n\nexport interface LikeButtonProps extends SocialButtonProps {\n\ttxid: string;\n\temoji?: string;\n\tshowCount?: boolean;\n\tonLike?: (txid: string, emoji: string) => void;\n\tonUnlike?: (txid: string, emoji: string) => void;\n}\n\nexport interface FollowButtonProps extends SocialButtonProps {\n\tidKey: string; // Updated from bapId to idKey\n\tisFollowing?: boolean;\n\tonFollow?: (transaction: FollowTransaction) => void;\n\tonUnfollow?: (transaction: UnfollowTransaction) => void;\n}\n\nexport interface MessageButtonProps extends SocialButtonProps {\n\trecipient?: string;\n\tonMessage?: (txid: string) => void;\n\tdefaultContent?: string;\n}\n\nexport interface FriendButtonProps extends SocialButtonProps {\n\tidKey: string; // Updated from bapId to idKey\n\tstatus?: \"none\" | \"pending\" | \"accepted\" | \"blocked\";\n\tonFriendRequest?: (idKey: string) => void;\n\tonAcceptFriend?: (idKey: string) => void;\n\tonUnfriend?: (idKey: string) => void;\n}\n\n// Error Types\nexport interface SocialError {\n\tcode: SocialErrorCode;\n\tmessage: string;\n\tdetails?: Error | Record<string, unknown>;\n}\n\nexport type SocialErrorCode =\n\t| \"TRANSACTION_FAILED\"\n\t| \"INVALID_CONTENT\"\n\t| \"USER_NOT_FOUND\"\n\t| \"INSUFFICIENT_FUNDS\"\n\t| \"NETWORK_ERROR\"\n\t| \"BROADCAST_FAILED\"\n\t| \"ENCRYPTION_FAILED\"\n\t| \"INVALID_BAP_ID\"\n\t| \"RATE_LIMITED\"\n\t| \"CONTENT_TOO_LONG\"\n\t| \"UNAUTHORIZED\"\n\t| \"UNKNOWN_ERROR\";\n\n// Broadcast Result (moved from protocol to avoid circular deps)\nexport interface BroadcastResult {\n\tsuccess: boolean;\n\ttxid?: string;\n\trawTx?: string;\n\terror?: string;\n\tfee?: number;\n}\n", "target": "<%- config.aliases.components %>/social.tsx" } ] }