diff --git a/bun.lockb b/bun.lockb index e7e0e9e9..25f0c3b0 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 19cd2390..1ec93678 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "wc": "find server database *.ts docs packages types utils drizzle tests -type f -print0 | wc -m --files0-from=-", "cli": "bun run cli/index.ts", "prune": "ts-prune | grep -v server/ | grep -v dist/ | grep -v '(used in module)'", - "schema:generate": "bun run packages/config-manager/json-schema.ts > config/config.schema.json", + "schema:generate": "bun run packages/config-manager/json-schema.ts > config/config.schema.json && bun run packages/plugin-kit/json-schema.ts > packages/plugin-kit/manifest.schema.json", "check": "bunx tsc -p ." }, "trustedDependencies": [ diff --git a/packages/plugin-kit/json-schema.ts b/packages/plugin-kit/json-schema.ts new file mode 100644 index 00000000..477924e1 --- /dev/null +++ b/packages/plugin-kit/json-schema.ts @@ -0,0 +1,6 @@ +import { zodToJsonSchema } from "zod-to-json-schema"; +import { manifestSchema } from "./schema"; + +const jsonSchema = zodToJsonSchema(manifestSchema); + +console.write(`${JSON.stringify(jsonSchema, null, 4)}\n`); diff --git a/packages/plugin-kit/manifest.schema.json b/packages/plugin-kit/manifest.schema.json new file mode 100644 index 00000000..b2a82d74 --- /dev/null +++ b/packages/plugin-kit/manifest.schema.json @@ -0,0 +1,84 @@ +{ + "type": "object", + "properties": { + "$schema": { + "type": "string" + }, + "name": { + "type": "string", + "minLength": 3, + "maxLength": 100 + }, + "version": { + "type": "string", + "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$" + }, + "description": { + "type": "string", + "minLength": 1, + "maxLength": 4096 + }, + "authors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string", + "minLength": 1, + "maxLength": 100 + }, + "email": { + "type": "string", + "format": "email" + }, + "url": { + "type": "string", + "format": "uri" + } + }, + "required": ["name"], + "additionalProperties": false + } + }, + "repository": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "git", + "svn", + "mercurial", + "bzr", + "darcs", + "mtn", + "cvs", + "fossil", + "bazaar", + "arch", + "tla", + "archie", + "monotone", + "perforce", + "sourcevault", + "plastic", + "clearcase", + "accurev", + "surroundscm", + "bitkeeper", + "other" + ] + }, + "url": { + "type": "string", + "format": "uri" + } + }, + "additionalProperties": false + } + }, + "required": ["name", "version", "description"], + "additionalProperties": false, + "$schema": "http://json-schema.org/draft-07/schema#" +} diff --git a/packages/plugin-kit/package.json b/packages/plugin-kit/package.json index 7821777f..2d8a4abc 100644 --- a/packages/plugin-kit/package.json +++ b/packages/plugin-kit/package.json @@ -30,6 +30,7 @@ "dependencies": { "mitt": "^3.0.1", "zod": "^3.23.8", + "zod-to-json-schema": "^3.23.3", "zod-validation-error": "^3.3.0" }, "exports": { diff --git a/packages/plugin-kit/schema.ts b/packages/plugin-kit/schema.ts index 0a30274c..fba07278 100644 --- a/packages/plugin-kit/schema.ts +++ b/packages/plugin-kit/schema.ts @@ -1,6 +1,8 @@ import { z } from "zod"; export const manifestSchema = z.object({ + // biome-ignore lint/style/useNamingConvention: + $schema: z.string().optional(), name: z.string().min(3).max(100), version: z .string() diff --git a/plugins/openid/manifest.json b/plugins/openid/manifest.json new file mode 100644 index 00000000..e0b856a7 --- /dev/null +++ b/plugins/openid/manifest.json @@ -0,0 +1,17 @@ +{ + "$schema": "../../packages/plugin-kit/manifest.schema.json", + "name": "@versia/openid", + "description": "OpenID authentication.", + "version": "0.1.0", + "authors": [ + { + "name": "Jesse Wierzbinski", + "email": "contact@cpluspatch.com", + "url": "https://cpluspatch.com" + } + ], + "repository": { + "type": "git", + "url": "https://github.com/versia-pub/server.git" + } +}