/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
import * as z from "zod";
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";
import {
ReferenceRep,
ReferenceRep$inboundSchema,
ReferenceRep$Outbound,
ReferenceRep$outboundSchema,
} from "./referencerep.js";
export type BranchRep = {
/**
* The branch name
*/
name: string;
/**
* An ID representing the branch HEAD. For example, a commit SHA.
*/
head: string;
/**
* An optional ID used to prevent older data from overwriting newer data
*/
updateSequenceId?: number | undefined;
syncTime: number;
/**
* An array of flag references found on the branch
*/
references?: Array<ReferenceRep> | undefined;
/**
* The location and content type of related resources
*/
links: { [k: string]: any };
};
/** @internal */
export const BranchRep$inboundSchema: z.ZodType<
BranchRep,
z.ZodTypeDef,
unknown
> = z.object({
name: z.string(),
head: z.string(),
updateSequenceId: z.number().int().optional(),
syncTime: z.number().int(),
references: z.array(ReferenceRep$inboundSchema).optional(),
_links: z.record(z.any()),
}).transform((v) => {
return remap$(v, {
"_links": "links",
});
});
/** @internal */
export type BranchRep$Outbound = {
name: string;
head: string;
updateSequenceId?: number | undefined;
syncTime: number;
references?: Array<ReferenceRep$Outbound> | undefined;
_links: { [k: string]: any };
};
/** @internal */
export const BranchRep$outboundSchema: z.ZodType<
BranchRep$Outbound,
z.ZodTypeDef,
BranchRep
> = z.object({
name: z.string(),
head: z.string(),
updateSequenceId: z.number().int().optional(),
syncTime: z.number().int(),
references: z.array(ReferenceRep$outboundSchema).optional(),
links: z.record(z.any()),
}).transform((v) => {
return remap$(v, {
links: "_links",
});
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace BranchRep$ {
/** @deprecated use `BranchRep$inboundSchema` instead. */
export const inboundSchema = BranchRep$inboundSchema;
/** @deprecated use `BranchRep$outboundSchema` instead. */
export const outboundSchema = BranchRep$outboundSchema;
/** @deprecated use `BranchRep$Outbound` instead. */
export type Outbound = BranchRep$Outbound;
}
export function branchRepToJSON(branchRep: BranchRep): string {
return JSON.stringify(BranchRep$outboundSchema.parse(branchRep));
}
export function branchRepFromJSON(
jsonString: string,
): SafeParseResult<BranchRep, SDKValidationError> {
return safeParse(
jsonString,
(x) => BranchRep$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'BranchRep' from JSON`,
);
}