bigbuffet-rw/packages/pl-api/lib/entities/interaction-policy.ts
2024-10-14 20:54:44 +02:00

31 lines
1.1 KiB
TypeScript

import * as v from 'valibot';
import { coerceObject } from './utils';
const interactionPolicyEntrySchema = v.picklist(['public', 'followers', 'following', 'mutuals', 'mentioned', 'author', 'me']);
const interactionPolicyRuleSchema = coerceObject({
always: v.fallback(v.array(interactionPolicyEntrySchema), ['public']),
with_approval: v.fallback(v.array(interactionPolicyEntrySchema), []),
});
/** @see {@link https://docs.gotosocial.org/en/latest/api/swagger/} */
const interactionPolicySchema = coerceObject({
can_favourite: interactionPolicyRuleSchema,
can_reblog: interactionPolicyRuleSchema,
can_reply: interactionPolicyRuleSchema,
});
type InteractionPolicy = v.InferOutput<typeof interactionPolicySchema>;
const interactionPoliciesSchema = coerceObject({
public: interactionPolicySchema,
unlisted: interactionPolicySchema,
private: interactionPolicySchema,
direct: interactionPolicySchema,
});
type InteractionPolicies = v.InferOutput<typeof interactionPoliciesSchema>;
export { interactionPolicySchema, interactionPoliciesSchema, type InteractionPolicy, type InteractionPolicies };