@llun/activities.schema 0.0.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/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@llun/activities.schema",
3
+ "version": "0.0.1",
4
+ "description": "Validate ActivityPub with Zod",
5
+ "exports": {
6
+ "types": "./dist/index.d.ts",
7
+ "default": "./dist/index.js"
8
+ },
9
+ "type": "module",
10
+ "scripts": {
11
+ "build": "tsc"
12
+ },
13
+ "author": "Maythee Anegboonlap <null@llun.dev>",
14
+ "license": "MIT",
15
+ "dependencies": {
16
+ "zod": "^3.22.4"
17
+ },
18
+ "devDependencies": {
19
+ "typescript": "^5.2.2"
20
+ }
21
+ }
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./note.js";
package/src/note.ts ADDED
@@ -0,0 +1,32 @@
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>;
28
+
29
+ export const Note = BaseContent.extend({
30
+ type: z.literal("Note"),
31
+ });
32
+ export type Note = z.infer<typeof Note>;
package/tsconfig.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2021",
4
+ "outDir": "dist",
5
+ "lib": ["DOM", "DOM.Iterable", "ES2021"],
6
+ "skipLibCheck": true,
7
+ "noEmitOnError": true,
8
+ "declaration": true,
9
+ "strict": true,
10
+ "module": "Node16",
11
+ "moduleResolution": "Node16",
12
+ "resolveJsonModule": false,
13
+ "isolatedModules": true
14
+ },
15
+ "include": ["src"]
16
+ }