import * as v from 'valibot';

import { datetimeSchema } from '../utils';

/**
 * @category Admin schemas
 * @see {@link https://docs.pleroma.social/backend/development/API/admin_api/#get-apiv1pleromaadminrules}
 */
const adminRuleSchema = v.object({
  id: v.string(),
  text: v.fallback(v.string(), ''),
  hint: v.fallback(v.string(), ''),
  priority: v.fallback(v.nullable(v.number()), null),

  created_at: v.fallback(v.optional(datetimeSchema), undefined),
  updated_at: v.fallback(v.optional(datetimeSchema), undefined),
});

/**
 * @category Admin entity types
 */
type AdminRule = v.InferOutput<typeof adminRuleSchema>;

export { adminRuleSchema, type AdminRule };
