diff --git a/package-lock.json b/package-lock.json index 833b2c8..e729ce9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,8 @@ "name": "wplace-bluemarble", "version": "0.81.0", "dependencies": { - "@types/greasemonkey": "^4.0.7" + "@types/greasemonkey": "^4.0.7", + "zod": "^4.0.17" }, "devDependencies": { "@eslint/js": "^9.33.0", @@ -2788,6 +2789,15 @@ "funding": { "url": "https://github.com/sponsors/sindresorhus" } + }, + "node_modules/zod": { + "version": "4.0.17", + "resolved": "https://registry.npmjs.org/zod/-/zod-4.0.17.tgz", + "integrity": "sha512-1PHjlYRevNxxdy2JZ8JcNAw7rX8V9P1AKkP+x/xZfxB0K5FYfuV+Ug6P/6NVSR2jHQ+FzDDoDHS04nYUsOIyLQ==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } } } } diff --git a/package.json b/package.json index ade9506..fcc2574 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "typescript-eslint": "^8.39.1" }, "dependencies": { - "@types/greasemonkey": "^4.0.7" + "@types/greasemonkey": "^4.0.7", + "zod": "^4.0.17" } } diff --git a/types/schemas.ts b/types/schemas.ts new file mode 100644 index 0000000..0a363a8 --- /dev/null +++ b/types/schemas.ts @@ -0,0 +1,57 @@ +import z from "zod/v3"; + +export const CharityJSON = z.object({ + meta: z.object({ + whoami: z.string(), + schemaVersion: z.string().refine((version) => version.match("^0|([1-9]\d*)([.](0|([1-9]\d*))){2}$")), + scriptVersion: z + .string() + .refine((version) => version.match("^0|([1-9]\d*)([.](0|([1-9]\d*))){2}$")) + .optional(), + }), + alliance: z.object({ + name: z.string(), + contact: z.string(), + }).optional(), + templates: z.array( + z.object({ + name: z.string().optional(), + enabled: z.boolean(), + coords: z.object({ + tx: z.number(), + ty: z.number(), + px: z.number(), + py: z.number(), + }), + sources: z.array(z.string()), + author: z.number().optional(), + animation: z + .object({ + frameWidth: z.number().optional(), + frameHeight: z.number().optional(), + frameCount: z.number().optional(), + secondsPerFrame: z.number().optional(), + frameRate: z.number().optional(), + frameSpeed: z.number().optional(), + startTimestamp: z.number().optional(), + startTime: z.number().optional(), + looping: z.boolean().optional(), + }) + .optional(), + uuid: z.string(), + }) + ), + whitelist: z.array( + z.object({ + name: z.string().optional(), + url: z.string(), + }) + ), + blacklist: z.array( + z.object({ + name: z.string().optional(), + url: z.string(), + }) + ), +}); + diff --git a/src/types.ts b/types/types.ts similarity index 100% rename from src/types.ts rename to types/types.ts