/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 * @generated-id: d83dd8b9a5ac
 */

import * as z from "zod/v4";
import { remap as remap$ } from "../../lib/primitives.js";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

export type GithubRepository = {
  type: "github";
  name: string;
  owner: string;
  ref?: string | null | undefined;
  weight: number;
  commitId: string;
};

/** @internal */
export const GithubRepository$inboundSchema: z.ZodType<
  GithubRepository,
  unknown
> = z.object({
  type: z.literal("github"),
  name: z.string(),
  owner: z.string(),
  ref: z.nullable(z.string()).optional(),
  weight: z.number().default(1),
  commit_id: z.string(),
}).transform((v) => {
  return remap$(v, {
    "commit_id": "commitId",
  });
});

export function githubRepositoryFromJSON(
  jsonString: string,
): SafeParseResult<GithubRepository, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => GithubRepository$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'GithubRepository' from JSON`,
  );
}
