/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: 99b887973618 */ import * as z from "zod/v4"; import { safeParse } from "../lib/schemas.js"; import { Result as SafeParseResult } from "../types/fp.js"; import { SDKValidationError } from "./errors/sdkvalidationerror.js"; import { GitProvider, GitProvider$inboundSchema, GitProvider$Outbound, GitProvider$outboundSchema, } from "./gitprovider.js"; export type GitMetadata = { /** * The hash of the commit */ commitSha?: string | null | undefined; /** * The commit message */ commitMessage?: string | null | undefined; /** * The branch or tag on which the commit was made */ commitRef?: string | null | undefined; /** * The date and time when the commit was created */ commitDate?: Date | null | undefined; /** * Whether or not there have been modifications to the working tree since the latest commit */ dirty?: boolean | null | undefined; /** * The git repository's remote origin url */ remoteUrl?: string | null | undefined; /** * The name of the author of the commit (from git config) */ commitAuthorName?: string | null | undefined; /** * The author identity recorded by Git. This is not guaranteed to be an RFC-valid email address. */ commitAuthorEmail?: string | null | undefined; /** * The provider username of the commit author (e.g., GitHub login), resolved server-side from the commit email */ commitAuthorLogin?: string | null | undefined; /** * The avatar URL of the commit author, resolved server-side from the provider login */ commitAuthorAvatarUrl?: string | null | undefined; /** * Provider-specific repository information, resolved server-side from remoteUrl */ provider?: GitProvider | null | undefined; }; /** @internal */ export const GitMetadata$inboundSchema: z.ZodType = z .object({ commitSha: z.nullable(z.string()).optional(), commitMessage: z.nullable(z.string()).optional(), commitRef: z.nullable(z.string()).optional(), commitDate: z.nullable( z.iso.datetime({ offset: true }).transform(v => new Date(v)), ).optional(), dirty: z.nullable(z.boolean()).optional(), remoteUrl: z.nullable(z.string()).optional(), commitAuthorName: z.nullable(z.string()).optional(), commitAuthorEmail: z.nullable(z.string()).optional(), commitAuthorLogin: z.nullable(z.string()).optional(), commitAuthorAvatarUrl: z.nullable(z.string()).optional(), provider: z.nullable(GitProvider$inboundSchema).optional(), }); /** @internal */ export type GitMetadata$Outbound = { commitSha?: string | null | undefined; commitMessage?: string | null | undefined; commitRef?: string | null | undefined; commitDate?: string | null | undefined; dirty?: boolean | null | undefined; remoteUrl?: string | null | undefined; commitAuthorName?: string | null | undefined; commitAuthorEmail?: string | null | undefined; commitAuthorLogin?: string | null | undefined; commitAuthorAvatarUrl?: string | null | undefined; provider?: GitProvider$Outbound | null | undefined; }; /** @internal */ export const GitMetadata$outboundSchema: z.ZodType< GitMetadata$Outbound, GitMetadata > = z.object({ commitSha: z.nullable(z.string()).optional(), commitMessage: z.nullable(z.string()).optional(), commitRef: z.nullable(z.string()).optional(), commitDate: z.nullable(z.date().transform(v => v.toISOString())).optional(), dirty: z.nullable(z.boolean()).optional(), remoteUrl: z.nullable(z.string()).optional(), commitAuthorName: z.nullable(z.string()).optional(), commitAuthorEmail: z.nullable(z.string()).optional(), commitAuthorLogin: z.nullable(z.string()).optional(), commitAuthorAvatarUrl: z.nullable(z.string()).optional(), provider: z.nullable(GitProvider$outboundSchema).optional(), }); export function gitMetadataToJSON(gitMetadata: GitMetadata): string { return JSON.stringify(GitMetadata$outboundSchema.parse(gitMetadata)); } export function gitMetadataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GitMetadata$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GitMetadata' from JSON`, ); }