@llun/activities.schema 0.0.7 → 0.0.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llun/activities.schema",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "Validate ActivityPub with Zod",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -4,3 +4,5 @@ export * from "./like.js";
4
4
  export * from "./note.js";
5
5
  export * from "./reject.js";
6
6
  export * from "./undo.js";
7
+
8
+ export * as Mastodon from "./mastodon/index.js";
@@ -0,0 +1,111 @@
1
+ // This schema is base on https://docs.joinmastodon.org/entities/Account/
2
+ import { z } from "zod";
3
+ import { AccountField } from "./accountField.js";
4
+ import { CustomEmoji } from "./customEmoji.js";
5
+
6
+ const BaseAccount = z.object({
7
+ id: z.string({
8
+ description:
9
+ "This is actor id, for Mastodon, it is a string that case from number but in Activities.next, this is URI",
10
+ }),
11
+ username: z.string({
12
+ description: "The username of the actor, not including domain",
13
+ }),
14
+ acct: z.string({
15
+ description:
16
+ "The Webfinger actor URI. Equal to username for local users, or username@domain for remote users",
17
+ }),
18
+ url: z.string({
19
+ description: "The location of the user's profile page",
20
+ }),
21
+ display_name: z.string({
22
+ description: "The profile's display name",
23
+ }),
24
+ note: z.string({
25
+ description: "The profile's bio or description",
26
+ }),
27
+ avatar: z.string({
28
+ description:
29
+ "An image URL icon that is shown next to statuses and in the profile",
30
+ }),
31
+ avatar_static: z.string({
32
+ description:
33
+ "A static version of the `avatar`. Equal to `avatar` if its value is a static image; different if `avatar` is an animated GIF",
34
+ }),
35
+ header: z.string({
36
+ description:
37
+ "An image banner URL that is shown above the profile and in profile cards.",
38
+ }),
39
+ header_static: z.string({
40
+ description:
41
+ "A static version of the `header`. Equal to `header` if its value is a static image; different if `header` is an animated GIF",
42
+ }),
43
+ loacked: z.string({
44
+ description: "Whether the actor manually approves follow requests",
45
+ }),
46
+ fields: AccountField.array().describe(
47
+ "Additional metadata attached to a profile as name-value pairs"
48
+ ),
49
+ emojis: CustomEmoji.array().describe(
50
+ "Custom emoji entities to be used when rendering the profile"
51
+ ),
52
+ bot: z.boolean({
53
+ description:
54
+ "Indicates that the actor may perform automated actions, may not be monitored, or identifies as a robot",
55
+ }),
56
+ group: z.boolean({
57
+ description: "Indicates that the actor represents a Group actor",
58
+ }),
59
+ discoverable: z
60
+ .boolean({
61
+ description:
62
+ "Whether the actor has opted into discovery features such as the profile directory",
63
+ })
64
+ .nullable(),
65
+ noindex: z
66
+ .boolean({
67
+ description:
68
+ "Whether the local user has opted out of being indexed by search engines",
69
+ })
70
+ .nullish(),
71
+ suspended: z
72
+ .boolean({
73
+ description:
74
+ "An extra attribute returned only when an actor is suspended",
75
+ })
76
+ .optional(),
77
+ limited: z
78
+ .boolean({
79
+ description:
80
+ "An extra attribute returned only when an actor is silenced. If true, indicates that the actor should be hidden behind a warning screen.",
81
+ })
82
+ .optional(),
83
+
84
+ created_at: z.string({
85
+ description: "The time the actor was created in ISO 8601 Datetime format",
86
+ }),
87
+ last_status_at: z
88
+ .string({
89
+ description:
90
+ "The time when the most recent status was posted in ISO 8601 Datetime format",
91
+ })
92
+ .nullable(),
93
+
94
+ statuses_count: z.number({
95
+ description: "How many statuses are attached to this actor",
96
+ }),
97
+ followers_count: z.number({
98
+ description: "The reported followers of this profile",
99
+ }),
100
+ following_count: z.number({
101
+ description: "The reported follows of this profile",
102
+ }),
103
+ });
104
+ type BaseAccount = z.infer<typeof BaseAccount>;
105
+
106
+ export const Account = BaseAccount.extend({
107
+ moved: BaseAccount.nullable().describe(
108
+ "Indicates that the profile is currently inactive and that its user has moved to a new account"
109
+ ),
110
+ });
111
+ export type Account = z.infer<typeof Account>;
@@ -0,0 +1,18 @@
1
+ // This schema is base on https://docs.joinmastodon.org/entities/Account/#Field
2
+ import { z } from "zod";
3
+
4
+ export const AccountField = z.object({
5
+ name: z.string({
6
+ description: "The key of a given field’s key-value pair",
7
+ }),
8
+ value: z.string({
9
+ description: "The value associated with the `name` key.",
10
+ }),
11
+ verified_at: z
12
+ .string({
13
+ description:
14
+ 'Timestamp of when the server verified a URL value for a rel="me" link in ISO 8601 Date time format',
15
+ })
16
+ .nullable(),
17
+ });
18
+ export type AccountField = z.infer<typeof AccountField>;
@@ -0,0 +1,24 @@
1
+ // This schema is base on https://docs.joinmastodon.org/entities/CustomEmoji/
2
+ import { z } from "zod";
3
+
4
+ export const CustomEmoji = z.object({
5
+ shortcode: z.string({
6
+ description: "The name of the custom emoji",
7
+ }),
8
+ static_url: z.string({
9
+ description: "A link to a static copy of the custom emoji",
10
+ }),
11
+ url: z.string({
12
+ description: "A link to the custom emoji",
13
+ }),
14
+ visible_in_picker: z.boolean({
15
+ description:
16
+ "Whether this Emoji should be visible in the picker or unlisted",
17
+ }),
18
+ category: z
19
+ .string({
20
+ description: "Used for sorting custom emoji in the picker",
21
+ })
22
+ .nullable(),
23
+ });
24
+ export type CustomEmoji = z.infer<typeof CustomEmoji>;
@@ -0,0 +1,3 @@
1
+ export * from "./account.js";
2
+ export * from "./accountField.js";
3
+ export * from "./customEmoji.js";