diff --git a/lexicons/build.ts b/lexicons/build.ts index 5d3062ac..e0a7e4d1 100644 --- a/lexicons/build.ts +++ b/lexicons/build.ts @@ -2,6 +2,7 @@ import * as PageLexicons from "./src/pages"; import { BlockLexicons } from "./src/blocks"; import { PubLeafletDocument } from "./src/document"; import * as PublicationLexicons from "./src/publication"; +import * as PollLexicons from "./src/polls"; import { ThemeLexicons } from "./src/theme"; import * as fs from "fs"; @@ -24,6 +25,7 @@ const lexicons = [ ...ThemeLexicons, ...BlockLexicons, ...Object.values(PublicationLexicons), + ...Object.values(PollLexicons), ]; // Write each lexicon to a file diff --git a/lexicons/src/polls/index.ts b/lexicons/src/polls/index.ts new file mode 100644 index 00000000..8d49fd9a --- /dev/null +++ b/lexicons/src/polls/index.ts @@ -0,0 +1,47 @@ +import { LexiconDoc } from "@atproto/lexicon"; + +export const PubLeafletPollDefinition: LexiconDoc = { + lexicon: 1, + id: "pub.leaflet.poll.definition", + defs: { + main: { + type: "record", + key: "tid", + description: "Record declaring a poll", + record: { + type: "object", + required: ["name", "options"], + properties: { + options: { type: "array", items: { type: "ref", ref: "#option" } }, + endDate: { type: "string", format: "datetime" }, + }, + }, + }, + option: { + type: "object", + properties: { + text: { type: "string", maxLength: 500, maxGraphemes: 50 }, + }, + }, + }, +}; + +export const PubLeafletPollVote: LexiconDoc = { + lexicon: 1, + id: "pub.leaflet.poll.vote", + defs: { + main: { + type: "record", + key: "tid", + description: "Record declaring a vote on a poll", + record: { + type: "object", + required: ["poll"], + properties: { + poll: { type: "ref", ref: "com.atproto.repo.strongRef" }, + option: { type: "string" }, + }, + }, + }, + }, +};