feat: emit json schema in npm package
This commit is contained in:
parent
8613de6078
commit
9849e046a9
8 changed files with 30 additions and 7 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"$schema": "../../dist/dxt-manifest.schema.json",
|
||||||
"dxt_version": "0.1",
|
"dxt_version": "0.1",
|
||||||
"name": "chrome-applescript",
|
"name": "chrome-applescript",
|
||||||
"display_name": "Control Chrome with AppleScript",
|
"display_name": "Control Chrome with AppleScript",
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"$schema": "../../dist/dxt-manifest.schema.json",
|
||||||
"dxt_version": "0.1",
|
"dxt_version": "0.1",
|
||||||
"name": "file-manager-python",
|
"name": "file-manager-python",
|
||||||
"display_name": "Python File Manager MCP",
|
"display_name": "Python File Manager MCP",
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"$schema": "../../dist/dxt-manifest.schema.json",
|
||||||
"dxt_version": "0.1",
|
"dxt_version": "0.1",
|
||||||
"name": "hello-world-node",
|
"name": "hello-world-node",
|
||||||
"display_name": "Hello World MCP Server (Reference Extension)",
|
"display_name": "Hello World MCP Server (Reference Extension)",
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,9 @@
|
||||||
"dist"
|
"dist"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc",
|
"build": "yarn run build:code && yarn run build:schema",
|
||||||
|
"build:code": "tsc",
|
||||||
|
"build:schema": "node --experimental-strip-types ./scripts/build-dxt-schema.js",
|
||||||
"dev": "tsc --watch",
|
"dev": "tsc --watch",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
"test:watch": "jest --watch",
|
"test:watch": "jest --watch",
|
||||||
|
|
@ -68,7 +70,7 @@
|
||||||
"commander": "^13.1.0",
|
"commander": "^13.1.0",
|
||||||
"fflate": "^0.8.2",
|
"fflate": "^0.8.2",
|
||||||
"node-forge": "^1.3.1",
|
"node-forge": "^1.3.1",
|
||||||
"zod": "^3.24.4"
|
"zod": "^3.25.67"
|
||||||
},
|
},
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
"@babel/helpers": "7.27.1",
|
"@babel/helpers": "7.27.1",
|
||||||
|
|
|
||||||
14
scripts/build-dxt-schema.js
Normal file
14
scripts/build-dxt-schema.js
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
import { DxtManifestSchema } from "../src/schemas.ts";
|
||||||
|
import * as z from "zod/v4";
|
||||||
|
import fs from "node:fs/promises";
|
||||||
|
import path from "node:path";
|
||||||
|
|
||||||
|
const schema = z.toJSONSchema(DxtManifestSchema);
|
||||||
|
await fs.mkdir(path.join(import.meta.dirname, "../dist"), { recursive: true });
|
||||||
|
await fs.writeFile(
|
||||||
|
path.join(import.meta.dirname, "../dist", "dxt-manifest.schema.json"),
|
||||||
|
JSON.stringify(schema, null, 2),
|
||||||
|
{
|
||||||
|
encoding: "utf8",
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import { z } from "zod";
|
import * as z from "zod/v4";
|
||||||
|
|
||||||
export const McpServerConfigSchema = z.object({
|
export const McpServerConfigSchema = z.object({
|
||||||
command: z.string(),
|
command: z.string(),
|
||||||
args: z.array(z.string()).optional(),
|
args: z.array(z.string()).optional(),
|
||||||
env: z.record(z.string()).optional(),
|
env: z.record(z.string(), z.string()).optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const DxtManifestAuthorSchema = z.object({
|
export const DxtManifestAuthorSchema = z.object({
|
||||||
|
|
@ -72,10 +72,12 @@ export const DxtUserConfigurationOptionSchema = z.object({
|
||||||
});
|
});
|
||||||
|
|
||||||
export const DxtUserConfigValuesSchema = z.record(
|
export const DxtUserConfigValuesSchema = z.record(
|
||||||
|
z.string(),
|
||||||
z.union([z.string(), z.number(), z.boolean(), z.array(z.string())]),
|
z.union([z.string(), z.number(), z.boolean(), z.array(z.string())]),
|
||||||
);
|
);
|
||||||
|
|
||||||
export const DxtManifestSchema = z.object({
|
export const DxtManifestSchema = z.object({
|
||||||
|
$schema: z.string().optional(),
|
||||||
dxt_version: z.string(),
|
dxt_version: z.string(),
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
display_name: z.string().optional(),
|
display_name: z.string().optional(),
|
||||||
|
|
@ -97,5 +99,7 @@ export const DxtManifestSchema = z.object({
|
||||||
keywords: z.array(z.string()).optional(),
|
keywords: z.array(z.string()).optional(),
|
||||||
license: z.string().optional(),
|
license: z.string().optional(),
|
||||||
compatibility: DxtManifestCompatibilitySchema.optional(),
|
compatibility: DxtManifestCompatibilitySchema.optional(),
|
||||||
user_config: z.record(DxtUserConfigurationOptionSchema).optional(),
|
user_config: z
|
||||||
|
.record(z.string(), DxtUserConfigurationOptionSchema)
|
||||||
|
.optional(),
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import type { z } from "zod";
|
import type * as z from "zod/v4";
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
DxtManifestAuthorSchema,
|
DxtManifestAuthorSchema,
|
||||||
|
|
|
||||||
|
|
@ -4277,7 +4277,7 @@ yoctocolors-cjs@^2.1.2:
|
||||||
resolved "https://registry.yarnpkg.com/yoctocolors-cjs/-/yoctocolors-cjs-2.1.2.tgz#f4b905a840a37506813a7acaa28febe97767a242"
|
resolved "https://registry.yarnpkg.com/yoctocolors-cjs/-/yoctocolors-cjs-2.1.2.tgz#f4b905a840a37506813a7acaa28febe97767a242"
|
||||||
integrity sha512-cYVsTjKl8b+FrnidjibDWskAv7UKOfcwaVZdp/it9n1s9fU3IkgDbhdIRKCW4JDsAlECJY0ytoVPT3sK6kideA==
|
integrity sha512-cYVsTjKl8b+FrnidjibDWskAv7UKOfcwaVZdp/it9n1s9fU3IkgDbhdIRKCW4JDsAlECJY0ytoVPT3sK6kideA==
|
||||||
|
|
||||||
zod@^3.24.4:
|
zod@^3.25.67:
|
||||||
version "3.25.67"
|
version "3.25.67"
|
||||||
resolved "https://registry.yarnpkg.com/zod/-/zod-3.25.67.tgz#62987e4078e2ab0f63b491ef0c4f33df24236da8"
|
resolved "https://registry.yarnpkg.com/zod/-/zod-3.25.67.tgz#62987e4078e2ab0f63b491ef0c4f33df24236da8"
|
||||||
integrity sha512-idA2YXwpCdqUSKRCACDE6ItZD9TZzy3OZMtpfLoh6oPR47lipysRrJfjzMqFxQ3uJuUPyUeWe1r9vLH33xO/Qw==
|
integrity sha512-idA2YXwpCdqUSKRCACDE6ItZD9TZzy3OZMtpfLoh6oPR47lipysRrJfjzMqFxQ3uJuUPyUeWe1r9vLH33xO/Qw==
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue