2024-05-14 09:00:05 +02:00
|
|
|
/**
|
|
|
|
|
* Polls extension
|
|
|
|
|
* @module federation/schemas/extensions/polls
|
|
|
|
|
* @see module:federation/schemas/base
|
2024-08-24 14:58:50 +02:00
|
|
|
* @see https://versia.pub/extensions/polls
|
2024-05-14 09:00:05 +02:00
|
|
|
*/
|
|
|
|
|
import { z } from "zod";
|
2024-08-25 15:47:03 +02:00
|
|
|
import { EntitySchema } from "../base";
|
2024-05-14 09:00:05 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @description Vote extension entity
|
2024-08-24 14:58:50 +02:00
|
|
|
* @see https://versia.pub/extensions/polls
|
2024-05-14 09:00:05 +02:00
|
|
|
* @example
|
|
|
|
|
* {
|
2024-08-25 15:47:03 +02:00
|
|
|
* "id": "6f27bc77-58ee-4c9b-b804-8cc1c1182fa9",
|
|
|
|
|
* "type": "pub.versia:polls/Vote",
|
|
|
|
|
* "uri": "https://example.com/actions/6f27bc77-58ee-4c9b-b804-8cc1c1182fa9",
|
2024-05-14 09:00:05 +02:00
|
|
|
* "created_at": "2021-01-01T00:00:00.000Z",
|
2024-08-25 15:47:03 +02:00
|
|
|
* "author": "https://example.com/users/6e0204a2-746c-4972-8602-c4f37fc63bbe",
|
|
|
|
|
* "poll": "https://example.com/notes/f08a124e-fe90-439e-8be4-15a428a72a19",
|
2024-05-14 09:00:05 +02:00
|
|
|
* "option": 1
|
|
|
|
|
* }
|
|
|
|
|
*/
|
2024-08-25 15:47:03 +02:00
|
|
|
export const VoteSchema = EntitySchema.extend({
|
|
|
|
|
type: z.literal("pub.versia:polls/Vote"),
|
|
|
|
|
author: z.string().url(),
|
2024-05-14 09:00:05 +02:00
|
|
|
poll: z.string().url(),
|
2024-08-25 15:47:03 +02:00
|
|
|
option: z
|
|
|
|
|
.number()
|
|
|
|
|
.int()
|
|
|
|
|
.nonnegative()
|
|
|
|
|
.max(2 ** 64 - 1),
|
2024-05-14 09:00:05 +02:00
|
|
|
});
|