@llun/activities.schema 0.1.2 → 0.2.0

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.
Files changed (116) hide show
  1. package/dist/cjs/accept.js +11 -0
  2. package/dist/cjs/follow.js +10 -0
  3. package/dist/cjs/index.js +24 -0
  4. package/dist/cjs/like.js +11 -0
  5. package/dist/cjs/mastodon/account.js +90 -0
  6. package/dist/cjs/mastodon/accountField.js +18 -0
  7. package/dist/cjs/mastodon/customEmoji.js +24 -0
  8. package/dist/cjs/mastodon/filter/index.js +27 -0
  9. package/dist/cjs/mastodon/filter/keyword.js +12 -0
  10. package/dist/cjs/mastodon/filter/status.js +11 -0
  11. package/dist/cjs/mastodon/filterResult.js +19 -0
  12. package/dist/cjs/mastodon/index.js +25 -0
  13. package/dist/cjs/mastodon/mediaAttachment/audio.js +20 -0
  14. package/dist/cjs/mastodon/mediaAttachment/base.js +29 -0
  15. package/dist/cjs/mastodon/mediaAttachment/gifv.js +40 -0
  16. package/dist/cjs/mastodon/mediaAttachment/image.js +33 -0
  17. package/dist/cjs/mastodon/mediaAttachment/index.js +11 -0
  18. package/dist/cjs/mastodon/mediaAttachment/unknown.js +11 -0
  19. package/dist/cjs/mastodon/mediaAttachment/video.js +41 -0
  20. package/dist/cjs/mastodon/poll/index.js +30 -0
  21. package/dist/cjs/mastodon/poll/option.js +13 -0
  22. package/dist/cjs/mastodon/previewCard.js +37 -0
  23. package/dist/cjs/mastodon/status/application.js +15 -0
  24. package/dist/cjs/mastodon/status/base.js +99 -0
  25. package/dist/cjs/mastodon/status/index.js +7 -0
  26. package/dist/cjs/mastodon/status/mention.js +15 -0
  27. package/dist/cjs/mastodon/status/tag.js +13 -0
  28. package/dist/cjs/mastodon/status/visibility.js +6 -0
  29. package/dist/cjs/note/attachment.js +7 -0
  30. package/dist/cjs/note/baseContent.js +27 -0
  31. package/dist/cjs/note/document.js +14 -0
  32. package/dist/cjs/note/emoji.js +11 -0
  33. package/dist/cjs/note/image.js +9 -0
  34. package/dist/cjs/note/mention.js +9 -0
  35. package/dist/cjs/note/propertyValue.js +9 -0
  36. package/dist/cjs/note.js +8 -0
  37. package/dist/cjs/reject.js +11 -0
  38. package/dist/cjs/undo.js +12 -0
  39. package/package.json +12 -4
  40. package/tsconfig.json +0 -3
  41. /package/dist/{accept.js → esm/accept.js} +0 -0
  42. /package/dist/{follow.js → esm/follow.js} +0 -0
  43. /package/dist/{index.js → esm/index.js} +0 -0
  44. /package/dist/{like.js → esm/like.js} +0 -0
  45. /package/dist/{mastodon → esm/mastodon}/account.js +0 -0
  46. /package/dist/{mastodon → esm/mastodon}/accountField.js +0 -0
  47. /package/dist/{mastodon → esm/mastodon}/customEmoji.js +0 -0
  48. /package/dist/{mastodon → esm/mastodon}/filter/index.js +0 -0
  49. /package/dist/{mastodon → esm/mastodon}/filter/keyword.js +0 -0
  50. /package/dist/{mastodon → esm/mastodon}/filter/status.js +0 -0
  51. /package/dist/{mastodon → esm/mastodon}/filterResult.js +0 -0
  52. /package/dist/{mastodon → esm/mastodon}/index.js +0 -0
  53. /package/dist/{mastodon → esm/mastodon}/mediaAttachment/audio.js +0 -0
  54. /package/dist/{mastodon → esm/mastodon}/mediaAttachment/base.js +0 -0
  55. /package/dist/{mastodon → esm/mastodon}/mediaAttachment/gifv.js +0 -0
  56. /package/dist/{mastodon → esm/mastodon}/mediaAttachment/image.js +0 -0
  57. /package/dist/{mastodon → esm/mastodon}/mediaAttachment/index.js +0 -0
  58. /package/dist/{mastodon → esm/mastodon}/mediaAttachment/unknown.js +0 -0
  59. /package/dist/{mastodon → esm/mastodon}/mediaAttachment/video.js +0 -0
  60. /package/dist/{mastodon → esm/mastodon}/poll/index.js +0 -0
  61. /package/dist/{mastodon → esm/mastodon}/poll/option.js +0 -0
  62. /package/dist/{mastodon → esm/mastodon}/previewCard.js +0 -0
  63. /package/dist/{mastodon → esm/mastodon}/status/application.js +0 -0
  64. /package/dist/{mastodon → esm/mastodon}/status/base.js +0 -0
  65. /package/dist/{mastodon → esm/mastodon}/status/index.js +0 -0
  66. /package/dist/{mastodon → esm/mastodon}/status/mention.js +0 -0
  67. /package/dist/{mastodon → esm/mastodon}/status/tag.js +0 -0
  68. /package/dist/{mastodon → esm/mastodon}/status/visibility.js +0 -0
  69. /package/dist/{note → esm/note}/attachment.js +0 -0
  70. /package/dist/{note → esm/note}/baseContent.js +0 -0
  71. /package/dist/{note → esm/note}/document.js +0 -0
  72. /package/dist/{note → esm/note}/emoji.js +0 -0
  73. /package/dist/{note → esm/note}/image.js +0 -0
  74. /package/dist/{note → esm/note}/mention.js +0 -0
  75. /package/dist/{note → esm/note}/propertyValue.js +0 -0
  76. /package/dist/{note.js → esm/note.js} +0 -0
  77. /package/dist/{reject.js → esm/reject.js} +0 -0
  78. /package/dist/{undo.js → esm/undo.js} +0 -0
  79. /package/dist/{accept.d.ts → types/accept.d.ts} +0 -0
  80. /package/dist/{follow.d.ts → types/follow.d.ts} +0 -0
  81. /package/dist/{index.d.ts → types/index.d.ts} +0 -0
  82. /package/dist/{like.d.ts → types/like.d.ts} +0 -0
  83. /package/dist/{mastodon → types/mastodon}/account.d.ts +0 -0
  84. /package/dist/{mastodon → types/mastodon}/accountField.d.ts +0 -0
  85. /package/dist/{mastodon → types/mastodon}/customEmoji.d.ts +0 -0
  86. /package/dist/{mastodon → types/mastodon}/filter/index.d.ts +0 -0
  87. /package/dist/{mastodon → types/mastodon}/filter/keyword.d.ts +0 -0
  88. /package/dist/{mastodon → types/mastodon}/filter/status.d.ts +0 -0
  89. /package/dist/{mastodon → types/mastodon}/filterResult.d.ts +0 -0
  90. /package/dist/{mastodon → types/mastodon}/index.d.ts +0 -0
  91. /package/dist/{mastodon → types/mastodon}/mediaAttachment/audio.d.ts +0 -0
  92. /package/dist/{mastodon → types/mastodon}/mediaAttachment/base.d.ts +0 -0
  93. /package/dist/{mastodon → types/mastodon}/mediaAttachment/gifv.d.ts +0 -0
  94. /package/dist/{mastodon → types/mastodon}/mediaAttachment/image.d.ts +0 -0
  95. /package/dist/{mastodon → types/mastodon}/mediaAttachment/index.d.ts +0 -0
  96. /package/dist/{mastodon → types/mastodon}/mediaAttachment/unknown.d.ts +0 -0
  97. /package/dist/{mastodon → types/mastodon}/mediaAttachment/video.d.ts +0 -0
  98. /package/dist/{mastodon → types/mastodon}/poll/index.d.ts +0 -0
  99. /package/dist/{mastodon → types/mastodon}/poll/option.d.ts +0 -0
  100. /package/dist/{mastodon → types/mastodon}/previewCard.d.ts +0 -0
  101. /package/dist/{mastodon → types/mastodon}/status/application.d.ts +0 -0
  102. /package/dist/{mastodon → types/mastodon}/status/base.d.ts +0 -0
  103. /package/dist/{mastodon → types/mastodon}/status/index.d.ts +0 -0
  104. /package/dist/{mastodon → types/mastodon}/status/mention.d.ts +0 -0
  105. /package/dist/{mastodon → types/mastodon}/status/tag.d.ts +0 -0
  106. /package/dist/{mastodon → types/mastodon}/status/visibility.d.ts +0 -0
  107. /package/dist/{note → types/note}/attachment.d.ts +0 -0
  108. /package/dist/{note → types/note}/baseContent.d.ts +0 -0
  109. /package/dist/{note → types/note}/document.d.ts +0 -0
  110. /package/dist/{note → types/note}/emoji.d.ts +0 -0
  111. /package/dist/{note → types/note}/image.d.ts +0 -0
  112. /package/dist/{note → types/note}/mention.d.ts +0 -0
  113. /package/dist/{note → types/note}/propertyValue.d.ts +0 -0
  114. /package/dist/{note.d.ts → types/note.d.ts} +0 -0
  115. /package/dist/{reject.d.ts → types/reject.d.ts} +0 -0
  116. /package/dist/{undo.d.ts → types/undo.d.ts} +0 -0
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseStatus = void 0;
4
+ // This schema is base on https://docs.joinmastodon.org/entities/Status/
5
+ const zod_1 = require("zod");
6
+ const account_js_1 = require("../account.js");
7
+ const visibility_js_1 = require("./visibility.js");
8
+ const index_js_1 = require("../mediaAttachment/index.js");
9
+ const application_js_1 = require("./application.js");
10
+ const customEmoji_js_1 = require("../customEmoji.js");
11
+ const index_js_2 = require("../poll/index.js");
12
+ const previewCard_js_1 = require("../previewCard.js");
13
+ const filterResult_js_1 = require("../filterResult.js");
14
+ exports.BaseStatus = zod_1.z.object({
15
+ id: zod_1.z.string({
16
+ description: "ID of the status in the database, for Mastodon, it is numeric casting to string. For Activities.next, this is equal to status URI",
17
+ }),
18
+ uri: zod_1.z.string({
19
+ description: "URI of the status used for federation",
20
+ }),
21
+ account: account_js_1.Account.describe("The actor that authored the status"),
22
+ content: zod_1.z.string({ description: "HTML-encoded status content" }),
23
+ visibility: visibility_js_1.Visibility.describe("Visibility of this status"),
24
+ sensitive: zod_1.z.boolean({
25
+ description: "Is this status marked as sensitive content?",
26
+ }),
27
+ spoiler_text: zod_1.z.string({
28
+ description: "Subject or summary line, below which status content is collapsed until expanded",
29
+ }),
30
+ media_attachments: index_js_1.MediaAttachment.array(),
31
+ application: application_js_1.Application.optional(),
32
+ emojis: customEmoji_js_1.CustomEmoji.array().describe("Custom emoji to be used when rendering status content"),
33
+ reblogs_count: zod_1.z.number({
34
+ description: "How many boosts this status has received",
35
+ }),
36
+ favourites_count: zod_1.z.number({
37
+ description: "How many favourites this status has received",
38
+ }),
39
+ replies_count: zod_1.z.number({
40
+ description: "How many replies this status has received",
41
+ }),
42
+ url: zod_1.z
43
+ .string({ description: "A link to the status’s HTML representation" })
44
+ .nullable(),
45
+ in_reply_to_id: zod_1.z
46
+ .string({ description: "ID of the status being replied to" })
47
+ .nullable(),
48
+ in_reply_to_account_id: zod_1.z
49
+ .string({
50
+ description: "ID of the actor that authored the status being replied to",
51
+ })
52
+ .nullable(),
53
+ poll: index_js_2.Poll.nullable().describe("The poll attached to the status"),
54
+ card: previewCard_js_1.PreviewCard.nullable().describe("Preview card for links included within status content"),
55
+ language: zod_1.z
56
+ .string({
57
+ description: "Primary language of this status in ISO 639 Part 1 two-letter language code",
58
+ })
59
+ .nullable(),
60
+ text: zod_1.z
61
+ .string({
62
+ description: "Plain-text source of a status. Returned instead of `content` when status is deleted, so the user may redraft from the source text without the client having to reverse-engineer the original text from the HTML content",
63
+ })
64
+ .nullable(),
65
+ created_at: zod_1.z.string({
66
+ description: "The date when this status was created in ISO 8601 Datetime format",
67
+ }),
68
+ edited_at: zod_1.z
69
+ .string({
70
+ description: "Timestamp of when the status was last edited in ISO 8601 Datetime format",
71
+ })
72
+ .nullable(),
73
+ favourited: zod_1.z
74
+ .boolean({
75
+ description: "If the current token has an authorized user: Have you favourited this status?",
76
+ })
77
+ .optional(),
78
+ reblogged: zod_1.z
79
+ .boolean({
80
+ description: "If the current token has an authorized user: Have you boosted this status?",
81
+ })
82
+ .optional(),
83
+ muted: zod_1.z
84
+ .boolean({
85
+ description: "If the current token has an authorized user: Have you muted notifications for this status’s conversation?",
86
+ })
87
+ .optional(),
88
+ bookmarked: zod_1.z
89
+ .boolean({
90
+ description: "If the current token has an authorized user: Have you bookmarked this status?",
91
+ })
92
+ .optional(),
93
+ pinned: zod_1.z
94
+ .boolean({
95
+ description: "If the current token has an authorized user: Have you pinned this status? Only appears if the status is pinnable",
96
+ })
97
+ .optional(),
98
+ filtered: filterResult_js_1.FilterResult.optional().describe("If the current token has an authorized user: The filter and keywords that matched this status"),
99
+ });
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Status = void 0;
4
+ const base_js_1 = require("./base.js");
5
+ exports.Status = base_js_1.BaseStatus.extend({
6
+ reblog: base_js_1.BaseStatus.nullable().describe("The status being reblogged"),
7
+ });
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Mention = void 0;
4
+ // This schema is base on https://docs.joinmastodon.org/entities/Status/#Mention
5
+ const zod_1 = require("zod");
6
+ exports.Mention = zod_1.z.object({
7
+ id: zod_1.z.string({ description: "The actor ID of the mentioned user" }),
8
+ username: zod_1.z.string({ description: "The username of the mentioned user" }),
9
+ url: zod_1.z.string({
10
+ description: "The location of the mentioned user’s profile",
11
+ }),
12
+ acct: zod_1.z.string({
13
+ description: "The webfinger acct: URI of the mentioned user. Equivalent to `username` for local users, or `username@domain` for remote users",
14
+ }),
15
+ });
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Tag = void 0;
4
+ // This schema is base on https://docs.joinmastodon.org/entities/Status/#Tag
5
+ const zod_1 = require("zod");
6
+ exports.Tag = zod_1.z.object({
7
+ name: zod_1.z.string({
8
+ description: "The value of the hashtag after the `#` sign",
9
+ }),
10
+ url: zod_1.z.string({
11
+ description: "A link to the hashtag on the instance",
12
+ }),
13
+ });
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Visibility = void 0;
4
+ // This schema is base on https://docs.joinmastodon.org/entities/Status/#visibility
5
+ const zod_1 = require("zod");
6
+ exports.Visibility = zod_1.z.enum(["public", "unlist", "private", "direct"]);
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Attachment = void 0;
4
+ const zod_1 = require("zod");
5
+ const document_js_1 = require("./document.js");
6
+ const propertyValue_js_1 = require("./propertyValue.js");
7
+ exports.Attachment = zod_1.z.union([propertyValue_js_1.PropertyValue, document_js_1.Document]);
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseContent = void 0;
4
+ const zod_1 = require("zod");
5
+ const attachment_js_1 = require("./attachment.js");
6
+ const emoji_js_1 = require("./emoji.js");
7
+ const mention_js_1 = require("./mention.js");
8
+ exports.BaseContent = zod_1.z.object({
9
+ id: zod_1.z.string(),
10
+ url: zod_1.z.string({ description: "Note URL" }),
11
+ attributedTo: zod_1.z.string({ description: "Note publisher" }),
12
+ to: zod_1.z.union([zod_1.z.string(), zod_1.z.string().array()]),
13
+ cc: zod_1.z.union([zod_1.z.string(), zod_1.z.string().array()]),
14
+ inReplyTo: zod_1.z.string().nullable(),
15
+ summary: zod_1.z.string({ description: "Note short summary" }).optional(),
16
+ summaryMap: zod_1.z
17
+ .record(zod_1.z.string(), { description: "Note short summary in each locale" })
18
+ .optional(),
19
+ content: zod_1.z.string({ description: "Note content" }).optional(),
20
+ contentMap: zod_1.z
21
+ .record(zod_1.z.string(), { description: "Note content in each locale" })
22
+ .optional(),
23
+ attachment: zod_1.z.union([attachment_js_1.Attachment, attachment_js_1.Attachment.array()]).optional(),
24
+ tag: zod_1.z.union([mention_js_1.Mention, emoji_js_1.Emoji]).array(),
25
+ published: zod_1.z.string({ description: "Object published datetime" }),
26
+ updated: zod_1.z.string({ description: "Object updated datetime" }).optional(),
27
+ });
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Document = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.Document = zod_1.z.object({
6
+ type: zod_1.z.literal("Document"),
7
+ mediaType: zod_1.z.string(),
8
+ url: zod_1.z.string(),
9
+ blurhash: zod_1.z.string().optional(),
10
+ width: zod_1.z.number().optional(),
11
+ height: zod_1.z.number().optional(),
12
+ name: zod_1.z.string().optional().nullable(),
13
+ focalPoint: zod_1.z.tuple([zod_1.z.number(), zod_1.z.number()]).optional(),
14
+ });
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Emoji = void 0;
4
+ const zod_1 = require("zod");
5
+ const image_js_1 = require("./image.js");
6
+ exports.Emoji = zod_1.z.object({
7
+ type: zod_1.z.literal("Emoji"),
8
+ name: zod_1.z.string(),
9
+ updated: zod_1.z.string(),
10
+ icon: image_js_1.Image,
11
+ });
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Image = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.Image = zod_1.z.object({
6
+ type: zod_1.z.literal("Image"),
7
+ mediaType: zod_1.z.string(),
8
+ url: zod_1.z.string(),
9
+ });
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Mention = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.Mention = zod_1.z.object({
6
+ type: zod_1.z.literal("Mention"),
7
+ href: zod_1.z.string(),
8
+ name: zod_1.z.string(),
9
+ });
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PropertyValue = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.PropertyValue = zod_1.z.object({
6
+ type: zod_1.z.literal("PropertyValue"),
7
+ name: zod_1.z.string(),
8
+ value: zod_1.z.string(),
9
+ });
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Note = void 0;
4
+ const zod_1 = require("zod");
5
+ const baseContent_js_1 = require("./note/baseContent.js");
6
+ exports.Note = baseContent_js_1.BaseContent.extend({
7
+ type: zod_1.z.literal("Note"),
8
+ });
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Reject = void 0;
4
+ const zod_1 = require("zod");
5
+ const follow_js_1 = require("./follow.js");
6
+ exports.Reject = zod_1.z.object({
7
+ id: zod_1.z.string(),
8
+ actor: zod_1.z.string(),
9
+ type: zod_1.z.literal("Reject"),
10
+ object: follow_js_1.Follow,
11
+ });
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Undo = void 0;
4
+ const zod_1 = require("zod");
5
+ const follow_js_1 = require("./follow.js");
6
+ const like_js_1 = require("./like.js");
7
+ exports.Undo = zod_1.z.object({
8
+ id: zod_1.z.string(),
9
+ actor: zod_1.z.string(),
10
+ type: zod_1.z.literal("Undo"),
11
+ object: zod_1.z.union([like_js_1.Like, follow_js_1.Follow]),
12
+ });
package/package.json CHANGED
@@ -1,12 +1,20 @@
1
1
  {
2
2
  "name": "@llun/activities.schema",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "description": "Validate ActivityPub and Mastodon with Zod",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
5
+ "main": "dist/cjs/index.js",
6
+ "module": "dist/esm/index.js",
7
+ "types": "dist/esm/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "require": "./dist/cjs/index.js",
11
+ "import": "./dist/esm/index.mjs",
12
+ "types": "./dist/cjs/index.d.ts"
13
+ }
14
+ },
7
15
  "type": "module",
8
16
  "scripts": {
9
- "build": "tsc",
17
+ "build": "mkdir -p dist && tsc --module commonjs --outDir dist/cjs && tsc --module node16 --outDir dist/esm && tsc --emitDeclarationOnly --declaration --moduleResolution node16 --module node16 --outDir dist/types",
10
18
  "release": "rm -rf dist && npm run build && npm publish --access public"
11
19
  },
12
20
  "author": "Maythee Anegboonlap <null@llun.dev>",
package/tsconfig.json CHANGED
@@ -5,10 +5,7 @@
5
5
  "lib": ["DOM", "DOM.Iterable", "ES2021"],
6
6
  "skipLibCheck": true,
7
7
  "noEmitOnError": true,
8
- "declaration": true,
9
8
  "strict": true,
10
- "module": "Node16",
11
- "moduleResolution": "Node16",
12
9
  "resolveJsonModule": false,
13
10
  "isolatedModules": true
14
11
  },
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes