54 行
1.7 KiB
TypeScript
54 行
1.7 KiB
TypeScript
import { z } from "zod";
|
|
|
|
export const profileRoleSchema = z.enum(["companion", "operations", "general"]);
|
|
|
|
export const authenticationTypeSchema = z.enum(["device-token", "api-key"]);
|
|
|
|
const optionalIdentifier = z.string().min(1).optional();
|
|
|
|
export const connectionProfileSchema = z
|
|
.object({
|
|
id: z.uuid(),
|
|
displayName: z.string().min(1).max(80),
|
|
role: profileRoleSchema,
|
|
baseUrl: z.url(),
|
|
eventStreamUrl: z.url().optional(),
|
|
authenticationType: authenticationTypeSchema,
|
|
credentialReference: optionalIdentifier,
|
|
allowInsecureHttp: z.boolean(),
|
|
pinnedCertificateFingerprint: z
|
|
.string()
|
|
.regex(/^[A-F0-9]{64}$/)
|
|
.optional(),
|
|
autoConnectSlot: z.enum(["companion", "operations"]).optional(),
|
|
autoConnect: z.boolean(),
|
|
serverInstanceId: optionalIdentifier,
|
|
serverVersion: optionalIdentifier,
|
|
protocolVersion: optionalIdentifier,
|
|
localToolPolicyId: optionalIdentifier,
|
|
lastConnectedAt: optionalIdentifier,
|
|
createdAt: z.string().min(1),
|
|
updatedAt: z.string().min(1),
|
|
})
|
|
.strict();
|
|
|
|
export const connectionProfileListSchema = z.array(connectionProfileSchema);
|
|
|
|
export type ProfileRole = z.infer<typeof profileRoleSchema>;
|
|
export type AuthenticationType = z.infer<typeof authenticationTypeSchema>;
|
|
export type ConnectionProfile = z.infer<typeof connectionProfileSchema>;
|
|
|
|
export interface ConnectionProfileInput {
|
|
displayName: string;
|
|
role: ProfileRole;
|
|
baseUrl: string;
|
|
eventStreamUrl?: string;
|
|
authenticationType: AuthenticationType;
|
|
allowInsecureHttp: boolean;
|
|
pinnedCertificateFingerprint?: string;
|
|
}
|
|
|
|
export interface UpdateConnectionProfileRequest {
|
|
id: string;
|
|
profile: ConnectionProfileInput;
|
|
}
|