bigbuffet-rw/packages/pl-api/lib/entities/suggestion.ts
marcin mikołajczak 036fa32cd3 Add pl-api to workspace
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-08-28 13:43:23 +02:00

25 lines
648 B
TypeScript

import { z } from 'zod';
import { accountSchema } from './account';
/** @see {@link https://docs.joinmastodon.org/entities/Suggestion} */
const suggestionSchema = z.preprocess((suggestion: any) => {
/**
* Support `/api/v1/suggestions`
* @see {@link https://docs.joinmastodon.org/methods/suggestions/#v1}
*/
if (suggestion?.acct) return {
source: 'staff',
sources: 'featured',
account: suggestion,
};
return suggestion;
}, z.object({
source: z.string(),
sources: z.array(z.string()),
account: accountSchema,
}));
type Suggestion = z.infer<typeof suggestionSchema>;
export { suggestionSchema, type Suggestion };