diff --git a/app/soapbox/schemas/index.ts b/app/soapbox/schemas/index.ts index 655bffc7f..25f5f3d45 100644 --- a/app/soapbox/schemas/index.ts +++ b/app/soapbox/schemas/index.ts @@ -8,6 +8,7 @@ export { groupRelationshipSchema, type GroupRelationship } from './group-relatio export { groupTagSchema, type GroupTag } from './group-tag'; export { pollSchema, type Poll, type PollOption } from './poll'; export { relationshipSchema, type Relationship } from './relationship'; +export { tagSchema, type Tag } from './tag'; // Soapbox export { adSchema, type Ad } from './soapbox/ad'; \ No newline at end of file diff --git a/app/soapbox/schemas/tag.ts b/app/soapbox/schemas/tag.ts new file mode 100644 index 000000000..5f74a31c7 --- /dev/null +++ b/app/soapbox/schemas/tag.ts @@ -0,0 +1,18 @@ +import { z } from 'zod'; + +const historySchema = z.object({ + accounts: z.coerce.number(), + uses: z.coerce.number(), +}); + +/** // https://docs.joinmastodon.org/entities/tag */ +const tagSchema = z.object({ + name: z.string().min(1), + url: z.string().url().catch(''), + history: z.array(historySchema).nullable().catch(null), + following: z.boolean().catch(false), +}); + +type Tag = z.infer; + +export { tagSchema, type Tag }; \ No newline at end of file