@softr/sdk
Version:
The SDK for building Softr apps on TanStack Start. It lets an app interact with Softr: auth, datasources, workflows and integrations.
39 lines (38 loc) • 1.57 kB
TypeScript
import { User } from "../user.js";
import { AuthError, Result } from "./utils.js";
//#region src/auth/methods/profile.d.ts
type Profile = Pick<User, "id" | "email" | "fullName" | "userGroupIds" | "avatarUrl" | "avatarEditable">;
/**
* Changes the signed-in visitor's own name, photo, or both. A field left out
* stays as it is. {@link removeAvatar} removes the photo.
*
* The photo can change only where `user.avatarEditable` is true. Elsewhere a
* photo answers `avatarNotSupported`, so hide the photo controls instead.
*
* Answers with the visitor as they are now, without `properties`. The page keeps showing what it
* loaded until its route context loads again, so call `router.invalidate()`
* after a success.
*
* A bad name answers `invalidName`. A photo the platform refuses, sent alone,
* answers `invalidPhoto`. When a name and a photo are sent together, a refusal
* answers `invalidName`.
*
* @example
* const result = await auth.updateProfile({ fullName: 'Ann Lee' })
* const result = await auth.updateProfile({ avatar: file })
*/
declare function updateProfile(changes: {
fullName?: string;
avatar?: File;
}): Promise<Result<Profile, AuthError>>;
/**
* Removes the signed-in visitor's own photo. Like {@link updateProfile}, it
* works only where `user.avatarEditable` is true, and answers with the visitor
* as they are now, without `properties`.
*
* @example
* const result = await auth.removeAvatar()
*/
declare function removeAvatar(): Promise<Result<Profile, AuthError>>;
//#endregion
export { removeAvatar, updateProfile };