@llun/activities.schema 0.0.5 → 0.0.7

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.7",
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",
@@ -14,10 +12,10 @@
14
12
  "author": "Maythee Anegboonlap <null@llun.dev>",
15
13
  "license": "MIT",
16
14
  "dependencies": {
17
- "zod": "^3.22.4"
15
+ "zod": "^3.23.6"
18
16
  },
19
17
  "devDependencies": {
20
- "typescript": "^5.2.2"
18
+ "typescript": "^5.4.5"
21
19
  },
22
- "packageManager": "yarn@4.0.1"
20
+ "packageManager": "yarn@4.1.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,33 @@
1
+ import { z } from "zod";
2
+ import { Attachment } from "./attachment.js";
3
+ import { Emoji } from "./emoji.js";
4
+ import { Mention } from "./mention.js";
5
+
6
+ export const BaseContent = z.object({
7
+ id: z.string(),
8
+ url: z.string({ description: "Note URL" }),
9
+ attributedTo: z.string({ description: "Note publisher" }),
10
+
11
+ to: z.union([z.string(), z.string().array()]),
12
+ cc: z.union([z.string(), z.string().array()]),
13
+
14
+ inReplyTo: z.string().nullable(),
15
+
16
+ summary: z.string({ description: "Note short summary" }).optional(),
17
+ summaryMap: z
18
+ .record(z.string(), { description: "Note short summary in each locale" })
19
+ .optional(),
20
+
21
+ content: z.string({ description: "Note content" }).optional(),
22
+ contentMap: z
23
+ .record(z.string(), { description: "Note content in each locale" })
24
+ .optional(),
25
+
26
+ attachment: z.union([Attachment, Attachment.array()]).optional(),
27
+ tag: z.union([Mention, Emoji]).array(),
28
+
29
+ published: z.string({ description: "Object published datetime" }),
30
+ updated: z.string({ description: "Object updated datetime" }).optional(),
31
+ });
32
+
33
+ export type BaseContent = z.infer<typeof BaseContent>;
@@ -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,30 +1,5 @@
1
1
  import { z } from "zod";
2
-
3
- const BaseContent = z.object({
4
- id: z.string(),
5
- url: z.string({ description: "Note URL" }),
6
- attributedTo: z.string({ description: "Note publisher" }),
7
-
8
- to: z.union([z.string(), z.string().array()]),
9
- cc: z.union([z.string(), z.string().array()]),
10
-
11
- inReplyTo: z.string().optional(),
12
-
13
- summary: z.string({ description: "Note short summary" }).optional(),
14
- summaryMap: z
15
- .record(z.string(), { description: "Note short summary in each locale" })
16
- .optional(),
17
-
18
- content: z.string({ description: "Note content" }).optional(),
19
- contentMap: z
20
- .record(z.string(), { description: "Note content in each locale" })
21
- .optional(),
22
-
23
- published: z.string({ description: "Object published datetime" }),
24
- updated: z.string({ description: "Object updated datetime" }).optional(),
25
- });
26
-
27
- type BaseContent = z.infer<typeof BaseContent>;
2
+ import { BaseContent } from "./note/baseContent.js";
28
3
 
29
4
  export const Note = BaseContent.extend({
30
5
  type: z.literal("Note"),
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>;