import { CollaboratorData, UserId } from '../types/collaborator'; import { PermissionLevel } from '../types/permission_levels'; import { ObjectValues } from '../private_utils'; import { PermissionCheckResult } from '../types/mutations'; import AbstractModel from './abstract_model'; /** @hidden */ interface SessionData { currentUserId: UserId | null; permissionLevel: PermissionLevel; enabledFeatureNames: Array; } declare const WatchableSessionKeys: Readonly<{ permissionLevel: "permissionLevel"; currentUser: "currentUser"; }>; /** * Watchable keys in {@link Session}. * - `currentUser` * - `permissionLevel` */ type WatchableSessionKey = ObjectValues; /** * Model class representing the current user's session. * * @example * ```js * import {useSession} from '@airtable/blocks/ui'; * * function Username() { * const session = useSession(); * * if (session.currentUser !== null) { * return The current user's name is {session.currentUser.name}; * } else { * return This extension is being viewed in a public share; * } * } * ``` * @docsPath models/Session */ declare class Session extends AbstractModel { /** * The current user, or `null` if the extension is running in a publicly shared base. * * @example * ```js * import {useSession} from '@airtable/blocks/ui'; * * function CurrentUser() { * const session = useSession(); * * if (!session.currentUser) { * return
This extension is being used in a public share.
; * } * * return
    *
  • ID: {session.currentUser.id}
  • *
  • E-mail: {session.currentUser.email}
  • *
  • Name: {session.currentUser.name}
  • *
; * } * ``` */ get currentUser(): CollaboratorData | null; /** * Checks whether the current user has permission to update any records in the current base. For * more granular permission checks, see {@link Table.checkPermissionsForUpdateRecords}. * * Returns `{hasPermission: true}` if the current user can update records, * `{hasPermission: false, reasonDisplayString: string}` otherwise. `reasonDisplayString` may * be used to display an error message to the user. * * @example * ```js * import {useSession} from '@airtable/blocks/ui'; * * function UpdateButton({onClick}) { * const session = useSession(); * const updateRecordsCheckResult = session.checkPermissionsForUpdateRecords(); * const deniedReason = updateRecordsCheckResult.hasPermission * ? {updateRecordsCheckResult.reasonDisplayString} * : null; * * return
* {deniedReason} * *
; * } */ checkPermissionsForUpdateRecords(): PermissionCheckResult; /** * An alias for `session.checkPermissionsForUpdateRecords().hasPermission`. For more granular * permission checks, see {@link Table.hasPermissionToUpdateRecords}. */ hasPermissionToUpdateRecords(): boolean; /** * Checks whether the current user has permission to create any records in the current base. For * more granular permission checks, see {@link Table.checkPermissionsForCreateRecords}. * * Returns `{hasPermission: true}` if the current user can create records, * `{hasPermission: false, reasonDisplayString: string}` otherwise. `reasonDisplayString` may be * used to display an error message to the user. * * @example * ```js * import {useSession} from '@airtable/blocks/ui'; * * function CreateButton({onClick}) { * const session = useSession(); * const updateRecordsCheckResult = session.checkPermissionsForCreateRecords(); * const deniedReason = updateRecordsCheckResult.hasPermission * ? {updateRecordsCheckResult.reasonDisplayString} * : null; * * return
* {deniedReason} * *
; * } */ checkPermissionsForCreateRecords(): PermissionCheckResult; /** * An alias for `session.checkPermissionsForCreateRecords().hasPermission`. For more granular * permission checks, see {@link Table.hasPermissionToCreateRecords}. */ hasPermissionToCreateRecords(): boolean; /** * Checks whether the current user has permission to delete any records in the current base. For * more granular permission checks, see {@link Table.checkPermissionsForDeleteRecords}. * * Returns `{hasPermission: true}` if the current user can delete records, * `{hasPermission: false, reasonDisplayString: string}` otherwise. `reasonDisplayString` may be * used to display an error message to the user. * * @example * ```js * import {useSession} from '@airtable/blocks/ui'; * * function DeleteButton({onClick}) { * const session = useSession(); * const updateRecordsCheckResult = session.checkPermissionsForDeleteRecords(); * const deniedReason = updateRecordsCheckResult.hasPermission * ? {updateRecordsCheckResult.reasonDisplayString} * : null; * * return
* {deniedReason} * *
; */ checkPermissionsForDeleteRecords(): PermissionCheckResult; /** * An alias for `session.checkPermissionsForDeleteRecords().hasPermission`. For more granular * permission checks, see {@link Table.hasPermissionToDeleteRecords}. */ hasPermissionToDeleteRecords(): boolean; } export default Session; //# sourceMappingURL=session.d.ts.map