UNPKG

eggi-ai-db-schema

Version:

Type-safe database schema and ORM client for Eggi.AI with direct RDS connection

70 lines 2.79 kB
/** * ============================================================================= * USER OPERATIONS UTILITIES * ============================================================================= * Utility functions for creating and managing authenticated users */ import { type AuthenticatedUser, type UnipileAccount } from "../lib/schema"; /** * Interface for Cognito user data extracted from post-authentication events */ export interface CognitoUserData { cognitoUserId: string; email: string; name?: string; givenName?: string; familyName?: string; preferredUsername?: string; } /** * Gets authenticated user record by Cognito ID * * This function queries the authenticated_users table and returns the authenticated user record. * * @param cognitoUserId - The Cognito User ID to search for * @returns Promise resolving to authenticated user or null if not found */ export declare function getAuthenticatedUserByCognitoId(cognitoUserId: string): Promise<AuthenticatedUser | null>; /** * Gets the actual user record from users table via Cognito ID * * This function: * 1. Finds authenticated user by Cognito ID * 2. Uses authenticated_user.user_id to get the user from users table * * @param cognitoUserId - The Cognito User ID to search for * @returns Promise resolving to user record or null if not found */ export declare function getUserByCognitoId(cognitoUserId: string): Promise<{ id: number; givenName: string | null; familyName: string | null; createdAt: Date; } | null>; /** * @deprecated Use getAuthenticatedUserByCognitoId instead */ export declare function findUserByCognitoId(cognitoUserId: string): Promise<AuthenticatedUser | null>; /** * Checks if a user already has a Unipile account for a specific platform * @param cognitoUserId - The Cognito User ID * @param platformType - The platform to check (e.g., "linkedin") * @returns Promise resolving to the existing account or null if not found */ export declare function getExistingUnipileAccount(cognitoUserId: string, platformType: "linkedin" | "whatsapp" | "twitter" | "instagram" | "facebook"): Promise<UnipileAccount | null>; /** * Upserts a linked social media account for a user * Finds or creates user by Cognito ID, then upserts the Unipile account * * @param cognitoUserId - The Cognito User ID * @param accountData - Account linking data * @returns Promise resolving to the upserted account */ export declare function upsertLinkedAccount(cognitoUserId: string, accountData: { unipileAccountId: string; providerType: "linkedin" | "whatsapp" | "twitter" | "instagram" | "facebook"; internalIdentifier?: string; email?: string; linkedAt: string; }): Promise<UnipileAccount>; //# sourceMappingURL=user-operations.d.ts.map