@llun/activities.schema 0.0.5 → 0.0.6

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,11 +1,9 @@
1
1
  {
2
2
  "name": "@llun/activities.schema",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "Validate ActivityPub with Zod",
5
- "exports": {
6
- "types": "./dist/index.d.ts",
7
- "default": "./dist/index.js"
8
- },
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
9
7
  "type": "module",
10
8
  "scripts": {
11
9
  "build": "tsc",
@@ -17,7 +15,7 @@
17
15
  "zod": "^3.22.4"
18
16
  },
19
17
  "devDependencies": {
20
- "typescript": "^5.2.2"
18
+ "typescript": "^5.3.2"
21
19
  },
22
20
  "packageManager": "yarn@4.0.1"
23
21
  }
package/src/index.ts CHANGED
@@ -1 +1,6 @@
1
+ export * from "./accept.js";
2
+ export * from "./follow.js";
3
+ export * from "./like.js";
1
4
  export * from "./note.js";
5
+ export * from "./reject.js";
6
+ export * from "./undo.js";
@@ -0,0 +1,8 @@
1
+ import { z } from "zod";
2
+
3
+ import { Document } from "./document.js";
4
+ import { PropertyValue } from "./propertyValue.js";
5
+
6
+ export const Attachment = z.union([PropertyValue, Document]);
7
+
8
+ export type Attachment = z.infer<typeof Attachment>;
@@ -0,0 +1,14 @@
1
+ import { z } from "zod";
2
+
3
+ export const Document = z.object({
4
+ type: z.literal("Document"),
5
+ mediaType: z.string(),
6
+ url: z.string(),
7
+ blurhash: z.string().optional(),
8
+ width: z.number().optional(),
9
+ height: z.number().optional(),
10
+ name: z.string().optional().nullable(),
11
+ focalPoint: z.tuple([z.number(), z.number()]).optional(),
12
+ });
13
+
14
+ export type Document = z.infer<typeof Document>;
@@ -0,0 +1,12 @@
1
+ import { z } from "zod";
2
+
3
+ import { Image } from "./image.js";
4
+
5
+ export const Emoji = z.object({
6
+ type: z.literal("Emoji"),
7
+ name: z.string(),
8
+ updated: z.string(),
9
+ icon: Image,
10
+ });
11
+
12
+ export type Emoji = z.infer<typeof Emoji>;
@@ -0,0 +1,9 @@
1
+ import { z } from "zod";
2
+
3
+ export const Image = z.object({
4
+ type: z.literal("Image"),
5
+ mediaType: z.string(),
6
+ url: z.string(),
7
+ });
8
+
9
+ export type Image = z.infer<typeof Image>;
@@ -0,0 +1,9 @@
1
+ import { z } from "zod";
2
+
3
+ export const Mention = z.object({
4
+ type: z.literal("Mention"),
5
+ href: z.string(),
6
+ name: z.string(),
7
+ });
8
+
9
+ export type Mention = z.infer<typeof Mention>;
@@ -0,0 +1,9 @@
1
+ import { z } from "zod";
2
+
3
+ export const PropertyValue = z.object({
4
+ type: z.literal("PropertyValue"),
5
+ name: z.string(),
6
+ value: z.string(),
7
+ });
8
+
9
+ export type PropertyValue = z.infer<typeof PropertyValue>;
package/src/note.ts CHANGED
@@ -1,4 +1,7 @@
1
1
  import { z } from "zod";
2
+ import { Attachment } from "./note/attachment.js";
3
+ import { Emoji } from "./note/emoji.js";
4
+ import { Mention } from "./note/mention.js";
2
5
 
3
6
  const BaseContent = z.object({
4
7
  id: z.string(),
@@ -8,7 +11,7 @@ const BaseContent = z.object({
8
11
  to: z.union([z.string(), z.string().array()]),
9
12
  cc: z.union([z.string(), z.string().array()]),
10
13
 
11
- inReplyTo: z.string().optional(),
14
+ inReplyTo: z.string().nullable(),
12
15
 
13
16
  summary: z.string({ description: "Note short summary" }).optional(),
14
17
  summaryMap: z
@@ -20,6 +23,9 @@ const BaseContent = z.object({
20
23
  .record(z.string(), { description: "Note content in each locale" })
21
24
  .optional(),
22
25
 
26
+ attachment: z.union([Attachment, Attachment.array()]).optional(),
27
+ tag: z.union([Mention, Emoji]).array(),
28
+
23
29
  published: z.string({ description: "Object published datetime" }),
24
30
  updated: z.string({ description: "Object updated datetime" }).optional(),
25
31
  });
package/src/undo.ts CHANGED
@@ -9,3 +9,5 @@ export const Undo = z.object({
9
9
  type: z.literal("Undo"),
10
10
  object: z.union([Like, Follow]),
11
11
  });
12
+
13
+ export type Undo = z.infer<typeof Undo>;