Imported as a linear vendor commit so forge rebases do not replay the upstream root tree. git-subtree-dir: third_party/pi git-subtree-split: 71023aec1546d6d677a65669c5665c0927ce0dd0
41 lines
1.8 KiB
TypeScript
41 lines
1.8 KiB
TypeScript
import type { Static } from "typebox";
|
|
import { Compile } from "typebox/compile";
|
|
import { describe, expect, expectTypeOf, it } from "vitest";
|
|
import {
|
|
AnthropicMessagesCompatSchema,
|
|
BedrockCompatSchema,
|
|
OpenAICompletionsCompatSchema,
|
|
OpenAIResponsesCompatSchema,
|
|
ProviderCompatSchema,
|
|
} from "../src/providers/compat-schema.ts";
|
|
|
|
type ProviderCompat = Static<typeof ProviderCompatSchema>;
|
|
|
|
describe("compatibility schemas", () => {
|
|
it("preserves property types in the provider superset", () => {
|
|
expectTypeOf<ProviderCompat["supportsStore"]>().toEqualTypeOf<boolean | undefined>();
|
|
expectTypeOf<ProviderCompat["sessionAffinityFormat"]>().toEqualTypeOf<
|
|
"openai" | "openai-nosession" | "openrouter" | undefined
|
|
>();
|
|
});
|
|
|
|
it("preserves API-specific defaults", () => {
|
|
const completionsDefaults = Compile(OpenAICompletionsCompatSchema).Default({});
|
|
expect(completionsDefaults).not.toHaveProperty("thinkingFormat");
|
|
expect(completionsDefaults).not.toHaveProperty("supportsLongCacheRetention");
|
|
expect(Compile(OpenAIResponsesCompatSchema).Default({})).toMatchObject({ supportsDeveloperRole: true });
|
|
const anthropicDefaults = Compile(AnthropicMessagesCompatSchema).Default({});
|
|
expect(anthropicDefaults).not.toHaveProperty("sendSessionAffinityHeaders");
|
|
expect(anthropicDefaults).toMatchObject({ supportsLongCacheRetention: true });
|
|
expect(Compile(BedrockCompatSchema).Default({})).toMatchObject({ supportsStrictMode: false });
|
|
});
|
|
|
|
it("does not assign API-specific defaults to the provider superset", () => {
|
|
const defaults = Compile(ProviderCompatSchema).Default({});
|
|
expect(defaults).not.toHaveProperty("supportsDeveloperRole");
|
|
expect(defaults).not.toHaveProperty("sendSessionAffinityHeaders");
|
|
expect(defaults).not.toHaveProperty("supportsLongCacheRetention");
|
|
expect(defaults).not.toHaveProperty("supportsStrictMode");
|
|
});
|
|
});
|