From f48edfba456652318451cf46e7fd7e515458d55f Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 3 May 2023 13:40:30 -0500 Subject: [PATCH] Add tagSchema --- app/soapbox/schemas/index.ts | 1 + app/soapbox/schemas/tag.ts | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 app/soapbox/schemas/tag.ts 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