Added charity JSON schema

This commit is contained in:
AloeSapling 2025-08-16 21:03:55 +02:00
parent 18ee37e7dd
commit 2dffa7cea0
4 changed files with 70 additions and 2 deletions

12
package-lock.json generated
View file

@ -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"
}
}
}
}

View file

@ -20,6 +20,7 @@
"typescript-eslint": "^8.39.1"
},
"dependencies": {
"@types/greasemonkey": "^4.0.7"
"@types/greasemonkey": "^4.0.7",
"zod": "^4.0.17"
}
}

57
types/schemas.ts Normal file
View file

@ -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(),
})
),
});