From faafd4523a23f271e489de232a2a94696141522a Mon Sep 17 00:00:00 2001 From: Joan Xie Date: Wed, 29 Oct 2025 16:33:23 -0700 Subject: [PATCH] feat: make McpbManifest a discriminated union of all versions Changed McpbManifest type from a single version to a discriminated union of all historical manifest versions (0.1, 0.2, 0.3). This allows the type system to properly handle manifests from any version while maintaining type safety through the manifest_version/dxt_version discriminator field. Benefits: - Type-safe handling of multiple manifest versions - TypeScript can narrow types based on version field - No need for type assertions when working with versioned manifests - Maintains backward compatibility with all historical versions --- src/types.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/types.ts b/src/types.ts index 0b6b2a3..23c2061 100644 --- a/src/types.ts +++ b/src/types.ts @@ -15,6 +15,9 @@ import type { McpbUserConfigValuesSchema, McpServerConfigSchema, } from "./schemas/latest.js"; +import type { McpbManifestSchema as McpbManifestSchema_v0_1 } from "./schemas/0.1.js"; +import type { McpbManifestSchema as McpbManifestSchema_v0_2 } from "./schemas/0.2.js"; +import type { McpbManifestSchema as McpbManifestSchema_v0_3 } from "./schemas/0.3.js"; export type McpServerConfig = z.infer; @@ -46,7 +49,14 @@ export type McpbUserConfigurationOption = z.infer< export type McpbUserConfigValues = z.infer; -export type McpbManifest = z.infer; +/** + * Discriminated union of all supported manifest versions. + * Discriminated by manifest_version or dxt_version field. + */ +export type McpbManifest = + | z.infer + | z.infer + | z.infer; /** * Information about a MCPB package signature