@llun/activities.schema 0.4.0 → 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 +3 -1
- package/dist/cjs/question/note.js +8 -4
- package/dist/cjs/question.js +21 -2
- package/dist/esm/index.js +1 -0
- package/dist/esm/question/note.js +7 -3
- package/dist/esm/question.js +21 -2
- package/dist/types/index.d.ts +1 -0
- package/dist/types/question/note.d.ts +10 -1
- package/dist/types/question.d.ts +13 -3
- package/package.json +1 -1
- package/src/index.ts +2 -0
- package/src/question/note.ts +10 -4
- package/src/question.ts +25 -2
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");
|
|
@@ -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
|
-
|
|
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;
|
package/dist/cjs/question.js
CHANGED
|
@@ -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
|
|
11
|
-
|
|
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,9 +1,13 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
|
|
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;
|
package/dist/esm/question.js
CHANGED
|
@@ -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
|
|
8
|
-
|
|
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
|
});
|
package/dist/types/index.d.ts
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,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 =
|
|
19
|
+
export type Note = QuestionOption;
|
package/dist/types/question.d.ts
CHANGED
|
@@ -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
|
-
|
|
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
package/src/index.ts
CHANGED
package/src/question/note.ts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
|
|
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
|
|
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
|
|
10
|
-
|
|
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>;
|