WIP
This commit is contained in:
parent
8c543a32f6
commit
98fc900d5a
2 changed files with 30 additions and 11 deletions
|
|
@ -5,11 +5,24 @@ import * as v0_2 from "./0.2.js";
|
|||
import * as v0_3 from "./0.3.js";
|
||||
|
||||
/**
|
||||
* Union schema that accepts any supported manifest version (0.1, 0.2, 0.3).
|
||||
* Use this when you need to validate manifests of any version.
|
||||
* Union schema that accepts any supported manifest version.
|
||||
* Uses preprocessing to normalize dxt_version to manifest_version,
|
||||
* then efficiently discriminates based on the now-required manifest_version field.
|
||||
*/
|
||||
export const McpbManifestSchema = z.union([
|
||||
v0_1.McpbManifestSchema,
|
||||
v0_2.McpbManifestSchema,
|
||||
v0_3.McpbManifestSchema,
|
||||
]);
|
||||
export const McpbManifestSchema = z.preprocess(
|
||||
(val) => {
|
||||
// Normalize: if it has dxt_version, ensure manifest_version is also set
|
||||
if (val && typeof val === "object" && "dxt_version" in val) {
|
||||
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,
|
||||
]),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
export * as v0_1 from "./0.1.js";
|
||||
export * as v0_2 from "./0.2.js";
|
||||
export * as v0_3 from "./0.3.js";
|
||||
export * as any from "./any.js";
|
||||
export * as latest from "./latest.js";
|
||||
export * as vAny from "./any.js";
|
||||
export * as vLatest from "./latest.js";
|
||||
export {
|
||||
MANIFEST_VERSION as LATEST_MANIFEST_VERSION,
|
||||
McpbManifestSchema,
|
||||
|
|
|
|||
Loading…
Reference in a new issue