@llun/activities.schema 0.4.0 → 0.4.2

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.
Binary file
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VideoContent = exports.ArticleContent = exports.PageContent = exports.ImageContent = exports.Question = exports.ENTITY_TYPE_QUESTION = exports.Note = exports.ENTITY_TYPE_NOTE = void 0;
4
+ const zod_1 = require("zod");
5
+ const baseContent_js_1 = require("./note/baseContent.js");
6
+ const note_js_1 = require("./question/note.js");
7
+ /**
8
+ * Note content type - the standard ActivityPub content type.
9
+ */
10
+ exports.ENTITY_TYPE_NOTE = "Note";
11
+ exports.Note = baseContent_js_1.BaseContent.extend({
12
+ type: zod_1.z.literal(exports.ENTITY_TYPE_NOTE),
13
+ });
14
+ /**
15
+ * Question content type for polls.
16
+ */
17
+ exports.ENTITY_TYPE_QUESTION = "Question";
18
+ exports.Question = baseContent_js_1.BaseContent.extend({
19
+ type: zod_1.z.literal(exports.ENTITY_TYPE_QUESTION),
20
+ endTime: zod_1.z
21
+ .string()
22
+ .describe("Question end time in ISO 8601 datetime format")
23
+ .optional(),
24
+ closed: zod_1.z
25
+ .string()
26
+ .describe("The datetime when the poll was closed, in ISO 8601 format. Used when a poll is closed early")
27
+ .nullish(),
28
+ // Single-choice poll options (mutually exclusive with anyOf)
29
+ oneOf: note_js_1.Note.array()
30
+ .describe("Poll options for single-choice polls")
31
+ .optional(),
32
+ // Multiple-choice poll options (mutually exclusive with oneOf)
33
+ anyOf: note_js_1.Note.array()
34
+ .describe("Poll options for multiple-choice polls")
35
+ .optional(),
36
+ // Misskey extension for total unique voters
37
+ votersCount: zod_1.z
38
+ .number()
39
+ .describe("Total number of unique voters (Misskey extension)")
40
+ .optional(),
41
+ });
42
+ /**
43
+ * Image content type used by Pixelfed and similar services.
44
+ * Extends BaseContent with image-specific properties.
45
+ */
46
+ exports.ImageContent = baseContent_js_1.BaseContent.extend({
47
+ type: zod_1.z.literal("Image"),
48
+ name: zod_1.z.string().nullish(),
49
+ mediaType: zod_1.z.string().nullish(),
50
+ width: zod_1.z.number().nullish(),
51
+ height: zod_1.z.number().nullish(),
52
+ blurhash: zod_1.z.string().nullish(),
53
+ });
54
+ /**
55
+ * Page content type used by WriteFreely and similar services.
56
+ */
57
+ exports.PageContent = baseContent_js_1.BaseContent.extend({
58
+ type: zod_1.z.literal("Page"),
59
+ name: zod_1.z.string().nullish(),
60
+ mediaType: zod_1.z.string().nullish(),
61
+ width: zod_1.z.number().nullish(),
62
+ height: zod_1.z.number().nullish(),
63
+ blurhash: zod_1.z.string().nullish(),
64
+ });
65
+ /**
66
+ * Article content type used by blogs and similar services.
67
+ */
68
+ exports.ArticleContent = baseContent_js_1.BaseContent.extend({
69
+ type: zod_1.z.literal("Article"),
70
+ name: zod_1.z.string().nullish(),
71
+ mediaType: zod_1.z.string().nullish(),
72
+ width: zod_1.z.number().nullish(),
73
+ height: zod_1.z.number().nullish(),
74
+ blurhash: zod_1.z.string().nullish(),
75
+ });
76
+ /**
77
+ * Video content type used by PeerTube and similar services.
78
+ */
79
+ exports.VideoContent = baseContent_js_1.BaseContent.extend({
80
+ type: zod_1.z.literal("Video"),
81
+ name: zod_1.z.string().nullish(),
82
+ mediaType: zod_1.z.string().nullish(),
83
+ width: zod_1.z.number().nullish(),
84
+ height: zod_1.z.number().nullish(),
85
+ blurhash: zod_1.z.string().nullish(),
86
+ });
package/dist/cjs/index.js CHANGED
@@ -14,13 +14,12 @@ 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);
21
- __exportStar(require("./note.js"), exports);
21
+ __exportStar(require("./content.js"), exports);
22
22
  __exportStar(require("./collection.js"), exports);
23
- __exportStar(require("./question.js"), exports);
24
23
  __exportStar(require("./reject.js"), exports);
25
24
  __exportStar(require("./undo.js"), exports);
26
25
  __exportStar(require("./announce.js"), exports);
@@ -29,5 +28,7 @@ __exportStar(require("./note/emoji.js"), exports);
29
28
  __exportStar(require("./note/mention.js"), exports);
30
29
  __exportStar(require("./note/hashtag.js"), exports);
31
30
  __exportStar(require("./note/document.js"), exports);
31
+ var note_js_1 = require("./question/note.js");
32
+ Object.defineProperty(exports, "QuestionOption", { enumerable: true, get: function () { return note_js_1.QuestionOption; } });
32
33
  __exportStar(require("./actor.js"), exports);
33
34
  exports.Mastodon = require("./mastodon/index.js");
package/dist/cjs/like.js CHANGED
@@ -2,11 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Like = exports.ENTITY_TYPE_LIKE = void 0;
4
4
  const zod_1 = require("zod");
5
- const note_js_1 = require("./note.js");
5
+ const content_js_1 = require("./content.js");
6
6
  exports.ENTITY_TYPE_LIKE = "Like";
7
7
  exports.Like = zod_1.z.object({
8
8
  type: zod_1.z.literal(exports.ENTITY_TYPE_LIKE),
9
9
  id: zod_1.z.string(),
10
10
  actor: zod_1.z.string(),
11
- object: zod_1.z.union([zod_1.z.string(), note_js_1.Note]),
11
+ object: zod_1.z.union([zod_1.z.string(), content_js_1.Note]),
12
12
  });
@@ -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;
@@ -0,0 +1,83 @@
1
+ import { z } from "zod";
2
+ import { BaseContent } from "./note/baseContent.js";
3
+ import { Note as QuestionOptionNote } from "./question/note.js";
4
+ /**
5
+ * Note content type - the standard ActivityPub content type.
6
+ */
7
+ export const ENTITY_TYPE_NOTE = "Note";
8
+ export const Note = BaseContent.extend({
9
+ type: z.literal(ENTITY_TYPE_NOTE),
10
+ });
11
+ /**
12
+ * Question content type for polls.
13
+ */
14
+ export const ENTITY_TYPE_QUESTION = "Question";
15
+ export const Question = BaseContent.extend({
16
+ type: z.literal(ENTITY_TYPE_QUESTION),
17
+ endTime: z
18
+ .string()
19
+ .describe("Question end time in ISO 8601 datetime format")
20
+ .optional(),
21
+ closed: z
22
+ .string()
23
+ .describe("The datetime when the poll was closed, in ISO 8601 format. Used when a poll is closed early")
24
+ .nullish(),
25
+ // Single-choice poll options (mutually exclusive with anyOf)
26
+ oneOf: QuestionOptionNote.array()
27
+ .describe("Poll options for single-choice polls")
28
+ .optional(),
29
+ // Multiple-choice poll options (mutually exclusive with oneOf)
30
+ anyOf: QuestionOptionNote.array()
31
+ .describe("Poll options for multiple-choice polls")
32
+ .optional(),
33
+ // Misskey extension for total unique voters
34
+ votersCount: z
35
+ .number()
36
+ .describe("Total number of unique voters (Misskey extension)")
37
+ .optional(),
38
+ });
39
+ /**
40
+ * Image content type used by Pixelfed and similar services.
41
+ * Extends BaseContent with image-specific properties.
42
+ */
43
+ export const ImageContent = BaseContent.extend({
44
+ type: z.literal("Image"),
45
+ name: z.string().nullish(),
46
+ mediaType: z.string().nullish(),
47
+ width: z.number().nullish(),
48
+ height: z.number().nullish(),
49
+ blurhash: z.string().nullish(),
50
+ });
51
+ /**
52
+ * Page content type used by WriteFreely and similar services.
53
+ */
54
+ export const PageContent = BaseContent.extend({
55
+ type: z.literal("Page"),
56
+ name: z.string().nullish(),
57
+ mediaType: z.string().nullish(),
58
+ width: z.number().nullish(),
59
+ height: z.number().nullish(),
60
+ blurhash: z.string().nullish(),
61
+ });
62
+ /**
63
+ * Article content type used by blogs and similar services.
64
+ */
65
+ export const ArticleContent = BaseContent.extend({
66
+ type: z.literal("Article"),
67
+ name: z.string().nullish(),
68
+ mediaType: z.string().nullish(),
69
+ width: z.number().nullish(),
70
+ height: z.number().nullish(),
71
+ blurhash: z.string().nullish(),
72
+ });
73
+ /**
74
+ * Video content type used by PeerTube and similar services.
75
+ */
76
+ export const VideoContent = BaseContent.extend({
77
+ type: z.literal("Video"),
78
+ name: z.string().nullish(),
79
+ mediaType: z.string().nullish(),
80
+ width: z.number().nullish(),
81
+ height: z.number().nullish(),
82
+ blurhash: z.string().nullish(),
83
+ });
package/dist/esm/index.js CHANGED
@@ -1,9 +1,8 @@
1
1
  export * from "./accept.js";
2
2
  export * from "./follow.js";
3
3
  export * from "./like.js";
4
- export * from "./note.js";
4
+ export * from "./content.js";
5
5
  export * from "./collection.js";
6
- export * from "./question.js";
7
6
  export * from "./reject.js";
8
7
  export * from "./undo.js";
9
8
  export * from "./announce.js";
@@ -12,5 +11,6 @@ export * from "./note/emoji.js";
12
11
  export * from "./note/mention.js";
13
12
  export * from "./note/hashtag.js";
14
13
  export * from "./note/document.js";
14
+ export { QuestionOption } from "./question/note.js";
15
15
  export * from "./actor.js";
16
16
  export * as Mastodon from "./mastodon/index.js";
package/dist/esm/like.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import { Note } from "./note.js";
2
+ import { Note } from "./content.js";
3
3
  export const ENTITY_TYPE_LIKE = "Like";
4
4
  export const Like = z.object({
5
5
  type: z.literal(ENTITY_TYPE_LIKE),
@@ -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;