import { Ability } from '@casl/ability';
import { buildAccountHelpers } from './buildAccountHelpers';
/**
 * Reconstruct the full account with abilities and helper methods
 */
export const parseAccount = (deserializedAccount) => {
    const account = {
        ...deserializedAccount,
        user: {
            ...deserializedAccount.user,
            ability: new Ability(deserializedAccount.user.abilityRules),
        },
        ...buildAccountHelpers(deserializedAccount),
    };
    switch (account.authentication.type) {
        case 'session':
            return account;
        case 'pat':
            return account;
        case 'jwt':
            return account;
        case 'service-account':
            return account;
        default:
            return account;
    }
};
//# sourceMappingURL=parseAccount.js.map