bigbuffet-rw/packages/pl-api/lib/entities/admin/announcement.ts
marcin mikołajczak bc65755862 pl-api: Update docs
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-11-29 16:01:54 +01:00

27 lines
712 B
TypeScript

import pick from 'lodash.pick';
import * as v from 'valibot';
import { announcementSchema } from '../announcement';
/**
* @category Admin schemas
* @see {@link https://docs.pleroma.social/backend/development/API/admin_api/#get-apiv1pleromaadminannouncements}
*/
const adminAnnouncementSchema = v.pipe(
v.any(),
v.transform((announcement: any) => ({
...announcement,
...pick(announcement.pleroma, 'raw_content'),
})),
v.object({
...announcementSchema.entries,
raw_content: v.fallback(v.string(), ''),
}),
);
/**
* @category Admin entity types
*/
type AdminAnnouncement = v.InferOutput<typeof adminAnnouncementSchema>;
export { adminAnnouncementSchema, type AdminAnnouncement };