@llun/activities.schema 0.3.1 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.Mastodon = void 0;
17
+ exports.Mastodon = exports.QuestionOption = void 0;
18
18
  __exportStar(require("./accept.js"), exports);
19
19
  __exportStar(require("./follow.js"), exports);
20
20
  __exportStar(require("./like.js"), exports);
@@ -29,5 +29,7 @@ __exportStar(require("./note/emoji.js"), exports);
29
29
  __exportStar(require("./note/mention.js"), exports);
30
30
  __exportStar(require("./note/hashtag.js"), exports);
31
31
  __exportStar(require("./note/document.js"), exports);
32
+ var note_js_1 = require("./question/note.js");
33
+ Object.defineProperty(exports, "QuestionOption", { enumerable: true, get: function () { return note_js_1.QuestionOption; } });
32
34
  __exportStar(require("./actor.js"), exports);
33
35
  exports.Mastodon = require("./mastodon/index.js");
@@ -3,4 +3,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Visibility = void 0;
4
4
  // This schema is base on https://docs.joinmastodon.org/entities/Status/#visibility
5
5
  const zod_1 = require("zod");
6
- exports.Visibility = zod_1.z.enum(["public", "unlist", "private", "direct"]);
6
+ exports.Visibility = zod_1.z.enum(["public", "unlisted", "private", "direct"]);
@@ -1,12 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Note = void 0;
3
+ exports.Note = exports.QuestionOption = void 0;
4
4
  const zod_1 = require("zod");
5
- exports.Note = zod_1.z.object({
5
+ // Poll option representation in ActivityPub Question
6
+ // Each option is a Note with a name (the option text) and replies collection (vote count)
7
+ exports.QuestionOption = zod_1.z.object({
6
8
  type: zod_1.z.literal("Note"),
7
- name: zod_1.z.string(),
9
+ name: zod_1.z.string().describe("The text of the poll option"),
8
10
  replies: zod_1.z.object({
9
11
  type: zod_1.z.literal("Collection"),
10
- totalItems: zod_1.z.number(),
12
+ totalItems: zod_1.z.number().describe("The number of votes for this option"),
11
13
  }),
12
14
  });
15
+ // Internal alias used by Question schema (not exported to avoid conflict with main Note)
16
+ exports.Note = exports.QuestionOption;
@@ -7,6 +7,25 @@ const note_js_1 = require("./question/note.js");
7
7
  exports.ENTITY_TYPE_QUESTION = "Question";
8
8
  exports.Question = baseContent_js_1.BaseContent.extend({
9
9
  type: zod_1.z.literal(exports.ENTITY_TYPE_QUESTION),
10
- endTime: zod_1.z.string().describe("Question end time"),
11
- oneOf: note_js_1.Note.array(),
10
+ endTime: zod_1.z
11
+ .string()
12
+ .describe("Question end time in ISO 8601 datetime format")
13
+ .optional(),
14
+ closed: zod_1.z
15
+ .string()
16
+ .describe("The datetime when the poll was closed, in ISO 8601 format. Used when a poll is closed early")
17
+ .nullish(),
18
+ // Single-choice poll options (mutually exclusive with anyOf)
19
+ oneOf: note_js_1.Note.array()
20
+ .describe("Poll options for single-choice polls")
21
+ .optional(),
22
+ // Multiple-choice poll options (mutually exclusive with oneOf)
23
+ anyOf: note_js_1.Note.array()
24
+ .describe("Poll options for multiple-choice polls")
25
+ .optional(),
26
+ // Misskey extension for total unique voters
27
+ votersCount: zod_1.z
28
+ .number()
29
+ .describe("Total number of unique voters (Misskey extension)")
30
+ .optional(),
12
31
  });
package/dist/esm/index.js CHANGED
@@ -12,5 +12,6 @@ export * from "./note/emoji.js";
12
12
  export * from "./note/mention.js";
13
13
  export * from "./note/hashtag.js";
14
14
  export * from "./note/document.js";
15
+ export { QuestionOption } from "./question/note.js";
15
16
  export * from "./actor.js";
16
17
  export * as Mastodon from "./mastodon/index.js";
@@ -1,3 +1,3 @@
1
1
  // This schema is base on https://docs.joinmastodon.org/entities/Status/#visibility
2
2
  import { z } from "zod";
3
- export const Visibility = z.enum(["public", "unlist", "private", "direct"]);
3
+ export const Visibility = z.enum(["public", "unlisted", "private", "direct"]);
@@ -1,9 +1,13 @@
1
1
  import { z } from "zod";
2
- export const Note = z.object({
2
+ // Poll option representation in ActivityPub Question
3
+ // Each option is a Note with a name (the option text) and replies collection (vote count)
4
+ export const QuestionOption = z.object({
3
5
  type: z.literal("Note"),
4
- name: z.string(),
6
+ name: z.string().describe("The text of the poll option"),
5
7
  replies: z.object({
6
8
  type: z.literal("Collection"),
7
- totalItems: z.number(),
9
+ totalItems: z.number().describe("The number of votes for this option"),
8
10
  }),
9
11
  });
12
+ // Internal alias used by Question schema (not exported to avoid conflict with main Note)
13
+ export const Note = QuestionOption;
@@ -4,6 +4,25 @@ import { Note } from "./question/note.js";
4
4
  export const ENTITY_TYPE_QUESTION = "Question";
5
5
  export const Question = BaseContent.extend({
6
6
  type: z.literal(ENTITY_TYPE_QUESTION),
7
- endTime: z.string().describe("Question end time"),
8
- oneOf: Note.array(),
7
+ endTime: z
8
+ .string()
9
+ .describe("Question end time in ISO 8601 datetime format")
10
+ .optional(),
11
+ closed: z
12
+ .string()
13
+ .describe("The datetime when the poll was closed, in ISO 8601 format. Used when a poll is closed early")
14
+ .nullish(),
15
+ // Single-choice poll options (mutually exclusive with anyOf)
16
+ oneOf: Note.array()
17
+ .describe("Poll options for single-choice polls")
18
+ .optional(),
19
+ // Multiple-choice poll options (mutually exclusive with oneOf)
20
+ anyOf: Note.array()
21
+ .describe("Poll options for multiple-choice polls")
22
+ .optional(),
23
+ // Misskey extension for total unique voters
24
+ votersCount: z
25
+ .number()
26
+ .describe("Total number of unique voters (Misskey extension)")
27
+ .optional(),
9
28
  });
@@ -12,5 +12,6 @@ export * from "./note/emoji.js";
12
12
  export * from "./note/mention.js";
13
13
  export * from "./note/hashtag.js";
14
14
  export * from "./note/document.js";
15
+ export { QuestionOption } from "./question/note.js";
15
16
  export * from "./actor.js";
16
17
  export * as Mastodon from "./mastodon/index.js";
@@ -8,7 +8,7 @@ export declare const Source: z.ZodObject<{
8
8
  }, z.core.$strip>>;
9
9
  privacy: z.ZodEnum<{
10
10
  public: "public";
11
- unlist: "unlist";
11
+ unlisted: "unlisted";
12
12
  private: "private";
13
13
  direct: "direct";
14
14
  }>;
@@ -20,7 +20,7 @@ export declare const Account: z.ZodObject<{
20
20
  }, z.core.$strip>>;
21
21
  privacy: z.ZodEnum<{
22
22
  public: "public";
23
- unlist: "unlist";
23
+ unlisted: "unlisted";
24
24
  private: "private";
25
25
  direct: "direct";
26
26
  }>;
@@ -72,7 +72,7 @@ export declare const Account: z.ZodObject<{
72
72
  }, z.core.$strip>>;
73
73
  privacy: z.ZodEnum<{
74
74
  public: "public";
75
- unlist: "unlist";
75
+ unlisted: "unlisted";
76
76
  private: "private";
77
77
  direct: "direct";
78
78
  }>;
@@ -23,7 +23,7 @@ export declare const BaseStatus: z.ZodObject<{
23
23
  }, z.core.$strip>>;
24
24
  privacy: z.ZodEnum<{
25
25
  public: "public";
26
- unlist: "unlist";
26
+ unlisted: "unlisted";
27
27
  private: "private";
28
28
  direct: "direct";
29
29
  }>;
@@ -75,7 +75,7 @@ export declare const BaseStatus: z.ZodObject<{
75
75
  }, z.core.$strip>>;
76
76
  privacy: z.ZodEnum<{
77
77
  public: "public";
78
- unlist: "unlist";
78
+ unlisted: "unlisted";
79
79
  private: "private";
80
80
  direct: "direct";
81
81
  }>;
@@ -111,7 +111,7 @@ export declare const BaseStatus: z.ZodObject<{
111
111
  content: z.ZodString;
112
112
  visibility: z.ZodEnum<{
113
113
  public: "public";
114
- unlist: "unlist";
114
+ unlisted: "unlisted";
115
115
  private: "private";
116
116
  direct: "direct";
117
117
  }>;
@@ -23,7 +23,7 @@ export declare const Status: z.ZodObject<{
23
23
  }, z.core.$strip>>;
24
24
  privacy: z.ZodEnum<{
25
25
  public: "public";
26
- unlist: "unlist";
26
+ unlisted: "unlisted";
27
27
  private: "private";
28
28
  direct: "direct";
29
29
  }>;
@@ -75,7 +75,7 @@ export declare const Status: z.ZodObject<{
75
75
  }, z.core.$strip>>;
76
76
  privacy: z.ZodEnum<{
77
77
  public: "public";
78
- unlist: "unlist";
78
+ unlisted: "unlisted";
79
79
  private: "private";
80
80
  direct: "direct";
81
81
  }>;
@@ -111,7 +111,7 @@ export declare const Status: z.ZodObject<{
111
111
  content: z.ZodString;
112
112
  visibility: z.ZodEnum<{
113
113
  public: "public";
114
- unlist: "unlist";
114
+ unlisted: "unlisted";
115
115
  private: "private";
116
116
  direct: "direct";
117
117
  }>;
@@ -365,7 +365,7 @@ export declare const Status: z.ZodObject<{
365
365
  }, z.core.$strip>>;
366
366
  privacy: z.ZodEnum<{
367
367
  public: "public";
368
- unlist: "unlist";
368
+ unlisted: "unlisted";
369
369
  private: "private";
370
370
  direct: "direct";
371
371
  }>;
@@ -417,7 +417,7 @@ export declare const Status: z.ZodObject<{
417
417
  }, z.core.$strip>>;
418
418
  privacy: z.ZodEnum<{
419
419
  public: "public";
420
- unlist: "unlist";
420
+ unlisted: "unlisted";
421
421
  private: "private";
422
422
  direct: "direct";
423
423
  }>;
@@ -453,7 +453,7 @@ export declare const Status: z.ZodObject<{
453
453
  content: z.ZodString;
454
454
  visibility: z.ZodEnum<{
455
455
  public: "public";
456
- unlist: "unlist";
456
+ unlisted: "unlisted";
457
457
  private: "private";
458
458
  direct: "direct";
459
459
  }>;
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  export declare const Visibility: z.ZodEnum<{
3
3
  public: "public";
4
- unlist: "unlist";
4
+ unlisted: "unlisted";
5
5
  private: "private";
6
6
  direct: "direct";
7
7
  }>;
@@ -1,4 +1,13 @@
1
1
  import { z } from "zod";
2
+ export declare const QuestionOption: z.ZodObject<{
3
+ type: z.ZodLiteral<"Note">;
4
+ name: z.ZodString;
5
+ replies: z.ZodObject<{
6
+ type: z.ZodLiteral<"Collection">;
7
+ totalItems: z.ZodNumber;
8
+ }, z.core.$strip>;
9
+ }, z.core.$strip>;
10
+ export type QuestionOption = z.infer<typeof QuestionOption>;
2
11
  export declare const Note: z.ZodObject<{
3
12
  type: z.ZodLiteral<"Note">;
4
13
  name: z.ZodString;
@@ -7,4 +16,4 @@ export declare const Note: z.ZodObject<{
7
16
  totalItems: z.ZodNumber;
8
17
  }, z.core.$strip>;
9
18
  }, z.core.$strip>;
10
- export type Note = z.infer<typeof Note>;
19
+ export type Note = QuestionOption;
@@ -91,14 +91,24 @@ export declare const Question: z.ZodObject<{
91
91
  published: z.ZodString;
92
92
  updated: z.ZodOptional<z.ZodNullable<z.ZodString>>;
93
93
  type: z.ZodLiteral<"Question">;
94
- endTime: z.ZodString;
95
- oneOf: z.ZodArray<z.ZodObject<{
94
+ endTime: z.ZodOptional<z.ZodString>;
95
+ closed: z.ZodOptional<z.ZodNullable<z.ZodString>>;
96
+ oneOf: z.ZodOptional<z.ZodArray<z.ZodObject<{
96
97
  type: z.ZodLiteral<"Note">;
97
98
  name: z.ZodString;
98
99
  replies: z.ZodObject<{
99
100
  type: z.ZodLiteral<"Collection">;
100
101
  totalItems: z.ZodNumber;
101
102
  }, z.core.$strip>;
102
- }, z.core.$strip>>;
103
+ }, z.core.$strip>>>;
104
+ anyOf: z.ZodOptional<z.ZodArray<z.ZodObject<{
105
+ type: z.ZodLiteral<"Note">;
106
+ name: z.ZodString;
107
+ replies: z.ZodObject<{
108
+ type: z.ZodLiteral<"Collection">;
109
+ totalItems: z.ZodNumber;
110
+ }, z.core.$strip>;
111
+ }, z.core.$strip>>>;
112
+ votersCount: z.ZodOptional<z.ZodNumber>;
103
113
  }, z.core.$strip>;
104
114
  export type Question = z.infer<typeof Question>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llun/activities.schema",
3
- "version": "0.3.1",
3
+ "version": "0.4.1",
4
4
  "description": "Validate ActivityPub and Mastodon with Zod",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
package/src/index.ts CHANGED
@@ -14,6 +14,8 @@ export * from "./note/mention.js";
14
14
  export * from "./note/hashtag.js";
15
15
  export * from "./note/document.js";
16
16
 
17
+ export { QuestionOption } from "./question/note.js";
18
+
17
19
  export * from "./actor.js";
18
20
 
19
21
  export * as Mastodon from "./mastodon/index.js";
@@ -1,5 +1,5 @@
1
1
  // This schema is base on https://docs.joinmastodon.org/entities/Status/#visibility
2
2
  import { z } from "zod";
3
3
 
4
- export const Visibility = z.enum(["public", "unlist", "private", "direct"]);
4
+ export const Visibility = z.enum(["public", "unlisted", "private", "direct"]);
5
5
  export type Visibility = z.infer<typeof Visibility>;
@@ -1,12 +1,18 @@
1
1
  import { z } from "zod";
2
2
 
3
- export const Note = z.object({
3
+ // Poll option representation in ActivityPub Question
4
+ // Each option is a Note with a name (the option text) and replies collection (vote count)
5
+ export const QuestionOption = z.object({
4
6
  type: z.literal("Note"),
5
- name: z.string(),
7
+ name: z.string().describe("The text of the poll option"),
6
8
  replies: z.object({
7
9
  type: z.literal("Collection"),
8
- totalItems: z.number(),
10
+ totalItems: z.number().describe("The number of votes for this option"),
9
11
  }),
10
12
  });
11
13
 
12
- export type Note = z.infer<typeof Note>;
14
+ export type QuestionOption = z.infer<typeof QuestionOption>;
15
+
16
+ // Internal alias used by Question schema (not exported to avoid conflict with main Note)
17
+ export const Note = QuestionOption;
18
+ export type Note = QuestionOption;
package/src/question.ts CHANGED
@@ -6,7 +6,30 @@ export const ENTITY_TYPE_QUESTION = "Question";
6
6
  export const Question = BaseContent.extend({
7
7
  type: z.literal(ENTITY_TYPE_QUESTION),
8
8
 
9
- endTime: z.string().describe("Question end time"),
10
- oneOf: Note.array(),
9
+ endTime: z
10
+ .string()
11
+ .describe("Question end time in ISO 8601 datetime format")
12
+ .optional(),
13
+ closed: z
14
+ .string()
15
+ .describe(
16
+ "The datetime when the poll was closed, in ISO 8601 format. Used when a poll is closed early"
17
+ )
18
+ .nullish(),
19
+
20
+ // Single-choice poll options (mutually exclusive with anyOf)
21
+ oneOf: Note.array()
22
+ .describe("Poll options for single-choice polls")
23
+ .optional(),
24
+ // Multiple-choice poll options (mutually exclusive with oneOf)
25
+ anyOf: Note.array()
26
+ .describe("Poll options for multiple-choice polls")
27
+ .optional(),
28
+
29
+ // Misskey extension for total unique voters
30
+ votersCount: z
31
+ .number()
32
+ .describe("Total number of unique voters (Misskey extension)")
33
+ .optional(),
11
34
  });
12
35
  export type Question = z.infer<typeof Question>;