The CLI-adapter era `connector.command` field became vestigial once every provider dispatch went through pi-ai. The schema still required a non-empty command, so onboarding saveConnector silently rejected every Pi Mono row (which carries an empty default). Remove the field from the payload chain (renderer → IPC schema → DB CRUD → run dispatch → worker job), narrow RunJob.taskId to match EnqueueRunPayload, and drop the dead helper plus its test. Schema column stays NOT NULL for DB compatibility; seedConnectors writes a literal empty string so no migration is needed.
67 lines
1.6 KiB
TypeScript
67 lines
1.6 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
connectorInputSchema,
|
|
runLogSchema,
|
|
secretInputSchema,
|
|
startRunSchema,
|
|
workspaceInputSchema,
|
|
} from "../../src/shared/contracts";
|
|
|
|
describe("shared contracts", () => {
|
|
it("fills connector defaults for optional fields", () => {
|
|
const parsed = connectorInputSchema.parse({
|
|
id: "openai-codex",
|
|
});
|
|
|
|
expect(parsed.model).toBeUndefined();
|
|
expect(parsed.envBindingText).toBe("");
|
|
expect(parsed.notes).toBe("");
|
|
});
|
|
|
|
it("validates workspace and run payloads", () => {
|
|
expect(() =>
|
|
workspaceInputSchema.parse({
|
|
companyId: "bad-id",
|
|
name: "Primary Workspace",
|
|
localPath: "/tmp/workspace",
|
|
}),
|
|
).toThrow();
|
|
|
|
expect(() =>
|
|
startRunSchema.parse({
|
|
taskId: "bad-id",
|
|
}),
|
|
).toThrow();
|
|
|
|
expect(() =>
|
|
runLogSchema.parse({
|
|
runId: "bad-id",
|
|
}),
|
|
).toThrow();
|
|
});
|
|
|
|
it("accepts bounded secret payloads", () => {
|
|
const parsed = secretInputSchema.parse({
|
|
companyId: "00000000-0000-0000-0000-000000000000",
|
|
name: "vault-openai",
|
|
description: "OpenAI API token",
|
|
value: "sk-test-value",
|
|
});
|
|
|
|
expect(parsed.companyId).toBe("00000000-0000-0000-0000-000000000000");
|
|
expect(parsed.name).toBe("vault-openai");
|
|
expect(parsed.value).toContain("sk-");
|
|
});
|
|
|
|
it("normalizes empty optional ids to null", () => {
|
|
const parsed = workspaceInputSchema.parse({
|
|
companyId: "00000000-0000-0000-0000-000000000000",
|
|
name: "Primary Workspace",
|
|
localPath: "/tmp/workspace",
|
|
projectId: "",
|
|
});
|
|
|
|
expect(parsed.projectId).toBeNull();
|
|
});
|
|
});
|