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
This commit is contained in:
parent
67938cdab9
commit
faafd4523a
1 changed files with 11 additions and 1 deletions
12
src/types.ts
12
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<typeof McpServerConfigSchema>;
|
||||
|
||||
|
|
@ -46,7 +49,14 @@ export type McpbUserConfigurationOption = z.infer<
|
|||
|
||||
export type McpbUserConfigValues = z.infer<typeof McpbUserConfigValuesSchema>;
|
||||
|
||||
export type McpbManifest = z.infer<typeof McpbManifestSchema>;
|
||||
/**
|
||||
* Discriminated union of all supported manifest versions.
|
||||
* Discriminated by manifest_version or dxt_version field.
|
||||
*/
|
||||
export type McpbManifest =
|
||||
| z.infer<typeof McpbManifestSchema_v0_1>
|
||||
| z.infer<typeof McpbManifestSchema_v0_2>
|
||||
| z.infer<typeof McpbManifestSchema_v0_3>;
|
||||
|
||||
/**
|
||||
* Information about a MCPB package signature
|
||||
|
|
|
|||
Loading…
Reference in a new issue