/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { IssueStatusTypeForSnapshot, IssueStatusTypeForSnapshot$inboundSchema, } from "./issuestatustypeforsnapshot.js"; /** * The issue's approval progress at the time the snapshot was captured, * * @remarks * or null if no approval was in progress or issue approvals are not enabled. */ export type ApprovalProgress = { /** * The number of approvers who have approved the issue. */ approvedCount: number; /** * The total number of approvers in the issue's approval chain. */ totalApprovers: number; }; export type IssueSnapshotItem = { /** * The unique identifier for the snapshot of an issue. * * @remarks * * This is distinct from the issueId, which identifies the underlying issue across snapshots. * The snapshot item ID is unique to this specific snapshot of the issue. */ id: string; /** * The issue title */ title?: string | undefined; /** * The issue description */ description?: string | undefined; /** * The human-readable identifier for the issue. * * @remarks * * This field is unique per-domain, and can be used to correlate * this issue snapshot item to the underlying issue across different snapshots. */ readableIssueId: string; /** * The globally unique identifier for the underlying issue across snapshots. * * @remarks * * This field can be used to correlate this snapshot item to the underlying issue across different snapshots. */ issueId: string; /** * The identifier for the snapshot this issue item belongs to. */ snapshotId: string; /** * The due date for the issue. */ dueDate?: Date | null | undefined; status?: IssueStatusTypeForSnapshot | undefined; /** * The issue's approval progress at the time the snapshot was captured, * * @remarks * or null if no approval was in progress or issue approvals are not enabled. */ approvalProgress?: ApprovalProgress | null | undefined; /** * The date and time when the issue was last modified. */ lastModifiedAt?: Date | undefined; /** * The date and time when the issue was created. */ createdAt?: Date | undefined; /** * The date and time when the issue was detected. */ detectedAt?: Date | undefined; }; /** @internal */ export const ApprovalProgress$inboundSchema: z.ZodType< ApprovalProgress, z.ZodTypeDef, unknown > = z.object({ approvedCount: z.number(), totalApprovers: z.number(), }); export function approvalProgressFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ApprovalProgress$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ApprovalProgress' from JSON`, ); } /** @internal */ export const IssueSnapshotItem$inboundSchema: z.ZodType< IssueSnapshotItem, z.ZodTypeDef, unknown > = z.object({ id: z.string(), title: z.string().optional(), description: z.string().optional(), readableIssueId: z.string(), issueId: z.string(), snapshotId: z.string(), dueDate: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), status: IssueStatusTypeForSnapshot$inboundSchema.optional(), approvalProgress: z.nullable(z.lazy(() => ApprovalProgress$inboundSchema)) .optional(), lastModifiedAt: z.string().datetime({ offset: true }).transform(v => new Date(v) ).optional(), createdAt: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), detectedAt: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), }); export function issueSnapshotItemFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => IssueSnapshotItem$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'IssueSnapshotItem' from JSON`, ); }