@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 +3 -1
- package/dist/cjs/mastodon/visibility.js +1 -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/mastodon/visibility.js +1 -1
- 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/mastodon/account/source.d.ts +1 -1
- package/dist/types/mastodon/account.d.ts +2 -2
- package/dist/types/mastodon/status/base.d.ts +3 -3
- package/dist/types/mastodon/status/index.d.ts +6 -6
- package/dist/types/mastodon/visibility.d.ts +1 -1
- 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/mastodon/visibility.ts +1 -1
- 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");
|
|
@@ -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", "
|
|
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
|
-
|
|
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";
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
456
|
+
unlisted: "unlisted";
|
|
457
457
|
private: "private";
|
|
458
458
|
direct: "direct";
|
|
459
459
|
}>;
|
|
@@ -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
|
@@ -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", "
|
|
4
|
+
export const Visibility = z.enum(["public", "unlisted", "private", "direct"]);
|
|
5
5
|
export type Visibility = z.infer<typeof Visibility>;
|
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>;
|