Submatter/packages/shared/src/connected-repos/schemas.ts
Randall Stillwell 30c4e533e8 feat(automation): connected repos — paste remote URL and forge adapters (Epic 3)
Workspace admins connect git remotes via settings UI; forge type is inferred
from the URL, API tokens stay env-var references, and test connection fetches
default branch for orchestrator/worker consumers.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-07 14:45:40 -05:00

47 lines
1.3 KiB
TypeScript

import { z } from "zod";
export const forgeTypeSchema = z.enum([
"github",
"forgejo",
"gitlab",
"bitbucket",
]);
export type ForgeType = z.infer<typeof forgeTypeSchema>;
export const parsedGitRemoteSchema = z.object({
forgeType: forgeTypeSchema,
gitRemoteUrl: z.string().url(),
webUrl: z.string().url(),
apiBaseUrl: z.string().url(),
owner: z.string().min(1).max(200),
repoName: z.string().min(1).max(200),
});
export type ParsedGitRemote = z.infer<typeof parsedGitRemoteSchema>;
export const connectedRepoSchema = z.object({
id: z.string().uuid(),
workspaceId: z.string().uuid(),
displayName: z.string().min(1).max(200),
gitRemoteUrl: z.string().url(),
forgeType: forgeTypeSchema,
apiBaseUrl: z.string().url(),
owner: z.string().min(1).max(200),
repoName: z.string().min(1).max(200),
defaultBranch: z.string().min(1).max(200).nullable(),
tokenEnvVar: z.string().min(1).max(120).nullable(),
metadata: z.record(z.unknown()).nullable(),
createdAt: z.coerce.date(),
updatedAt: z.coerce.date(),
});
export type ConnectedRepo = z.infer<typeof connectedRepoSchema>;
export const repoMetadataSchema = z.object({
defaultBranch: z.string().min(1),
cloneUrl: z.string().url(),
description: z.string().optional(),
});
export type RepoMetadata = z.infer<typeof repoMetadataSchema>;