import { rule } from '../../src/constructors'; import type { TestContext } from './setup'; // Common test rules export const isAuthenticated = rule()(async (ctx) => { return ctx.user !== null; }); export const isAdmin = rule()(async (ctx) => { return ctx.user?.role === 'admin'; }); export const isEditor = rule()(async (ctx) => { return ctx.user?.role === 'editor'; }); export const isOwner = rule()(async (ctx, type, path, input) => { return ctx.user?.id === input.userId; }); export const alwaysTrue = rule()(async () => { return true; }); export const alwaysFalse = rule()(async () => { return false; }); export const throwsError = rule()(async () => { throw new Error('Custom rule error'); }); export const returnsError = rule()(async () => { return new Error('Rule returned error'); }); export const returnsString = rule()(async () => { return 'String error message'; });