revert: undo preprocessing changes to any.ts and types.ts

Reverts the preprocessing logic and type name changes to restore
the simpler union schema approach.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Joan Xie 2025-11-01 15:37:15 -07:00
commit 86166630b4
No known key found for this signature in database
2 changed files with 9 additions and 28 deletions

View file

@ -5,24 +5,11 @@ import * as v0_2 from "./0.2.js";
import * as v0_3 from "./0.3.js"; import * as v0_3 from "./0.3.js";
/** /**
* Union schema that accepts any supported manifest version. * Union schema that accepts any supported manifest version (0.1, 0.2, 0.3).
* Uses preprocessing to normalize dxt_version to manifest_version, * Use this when you need to validate manifests of any version.
* then efficiently discriminates based on the now-required manifest_version field.
*/ */
export const McpbManifestSchema = z.preprocess( export const McpbManifestSchema = z.union([
(val) => { v0_1.McpbManifestSchema,
// Normalize: if it has dxt_version, ensure manifest_version is also set v0_2.McpbManifestSchema,
if (val && typeof val === "object" && "dxt_version" in val) { v0_3.McpbManifestSchema,
const obj = val as Record<string, unknown>; ]);
if (!obj.manifest_version && obj.dxt_version) {
return { ...obj, manifest_version: obj.dxt_version };
}
}
return val;
},
z.union([
v0_1.McpbManifestSchema,
v0_2.McpbManifestSchema,
v0_3.McpbManifestSchema,
]),
);

View file

@ -1,6 +1,6 @@
import type * as z from "zod"; import type * as z from "zod";
import type { McpbManifestSchema as McpbManifestSchema_vAny } from "./schemas/any.js"; import type { McpbManifestSchema as McpbManifestSchemaAny } from "./schemas/any.js";
import type { import type {
McpbManifestAuthorSchema, McpbManifestAuthorSchema,
McpbManifestCompatibilitySchema, McpbManifestCompatibilitySchema,
@ -51,7 +51,7 @@ export type McpbUserConfigValues = z.infer<typeof McpbUserConfigValuesSchema>;
* McpbManifest type that accepts any supported manifest version * McpbManifest type that accepts any supported manifest version
* This is the default manifest type that should be used for maximum compatibility. * This is the default manifest type that should be used for maximum compatibility.
*/ */
export type McpbManifestAny = z.infer<typeof McpbManifestSchema_vAny>; export type McpbManifest = z.infer<typeof McpbManifestSchemaAny>;
/** /**
* McpbManifest type for the latest manifest version only * McpbManifest type for the latest manifest version only
@ -59,12 +59,6 @@ export type McpbManifestAny = z.infer<typeof McpbManifestSchema_vAny>;
*/ */
export type McpbManifestLatest = z.infer<typeof McpbManifestSchema>; export type McpbManifestLatest = z.infer<typeof McpbManifestSchema>;
/**
* @deprecated Use McpbManifestAny instead
* Default manifest type that accepts any supported version
*/
export type McpbManifest = McpbManifestAny;
/** /**
* Information about a MCPB package signature * Information about a MCPB package signature
*/ */