/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; 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 { DiffActionEnum, DiffActionEnum$inboundSchema, } from "./diffactionenum.js"; import { ResourceTypeEnum, ResourceTypeEnum$inboundSchema, } from "./resourcetypeenum.js"; /** * User who last updated the resource */ export type ResourceDiffDtoUpdatedBy = { /** * User ID */ id: string; /** * User first name */ firstName: string; /** * User last name */ lastName?: string | null | undefined; /** * User external ID */ externalId?: string | undefined; }; /** * Source resource information */ export type ResourceDiffDtoSourceResource = { /** * Resource ID (workflow ID or step ID) */ id?: string | null | undefined; /** * Resource name (workflow name or step name) */ name?: string | null | undefined; /** * User who last updated the resource */ updatedBy?: ResourceDiffDtoUpdatedBy | null | undefined; /** * When the resource was last updated */ updatedAt?: Date | null | undefined; }; /** * User who last updated the resource */ export type ResourceDiffDtoTargetResourceUpdatedBy = { /** * User ID */ id: string; /** * User first name */ firstName: string; /** * User last name */ lastName?: string | null | undefined; /** * User external ID */ externalId?: string | undefined; }; /** * Target resource information */ export type ResourceDiffDtoTargetResource = { /** * Resource ID (workflow ID or step ID) */ id?: string | null | undefined; /** * Resource name (workflow name or step name) */ name?: string | null | undefined; /** * User who last updated the resource */ updatedBy?: ResourceDiffDtoTargetResourceUpdatedBy | null | undefined; /** * When the resource was last updated */ updatedAt?: Date | null | undefined; }; /** * Detailed changes (only for modified resources) */ export type Diffs = { /** * Previous state of the resource (null for added resources) */ previous?: { [k: string]: any } | null | undefined; /** * New state of the resource (null for deleted resources) */ new?: { [k: string]: any } | null | undefined; }; export type ResourceDiffDto = { /** * Source resource information */ sourceResource?: ResourceDiffDtoSourceResource | null | undefined; /** * Target resource information */ targetResource?: ResourceDiffDtoTargetResource | null | undefined; /** * Type of the layout */ resourceType: ResourceTypeEnum; /** * Type of change */ action: DiffActionEnum; /** * Detailed changes (only for modified resources) */ diffs?: Diffs | undefined; /** * Step type (only for step resources) */ stepType?: string | undefined; /** * Previous index in steps array (for moved/deleted steps) */ previousIndex?: number | undefined; /** * New index in steps array (for moved/added steps) */ newIndex?: number | undefined; }; /** @internal */ export const ResourceDiffDtoUpdatedBy$inboundSchema: z.ZodType< ResourceDiffDtoUpdatedBy, z.ZodTypeDef, unknown > = z.object({ _id: z.string(), firstName: z.string(), lastName: z.nullable(z.string()).optional(), externalId: z.string().optional(), }).transform((v) => { return remap$(v, { "_id": "id", }); }); export function resourceDiffDtoUpdatedByFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ResourceDiffDtoUpdatedBy$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ResourceDiffDtoUpdatedBy' from JSON`, ); } /** @internal */ export const ResourceDiffDtoSourceResource$inboundSchema: z.ZodType< ResourceDiffDtoSourceResource, z.ZodTypeDef, unknown > = z.object({ id: z.nullable(z.string()).optional(), name: z.nullable(z.string()).optional(), updatedBy: z.nullable(z.lazy(() => ResourceDiffDtoUpdatedBy$inboundSchema)) .optional(), updatedAt: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), }); export function resourceDiffDtoSourceResourceFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ResourceDiffDtoSourceResource$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ResourceDiffDtoSourceResource' from JSON`, ); } /** @internal */ export const ResourceDiffDtoTargetResourceUpdatedBy$inboundSchema: z.ZodType< ResourceDiffDtoTargetResourceUpdatedBy, z.ZodTypeDef, unknown > = z.object({ _id: z.string(), firstName: z.string(), lastName: z.nullable(z.string()).optional(), externalId: z.string().optional(), }).transform((v) => { return remap$(v, { "_id": "id", }); }); export function resourceDiffDtoTargetResourceUpdatedByFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ResourceDiffDtoTargetResourceUpdatedBy$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ResourceDiffDtoTargetResourceUpdatedBy' from JSON`, ); } /** @internal */ export const ResourceDiffDtoTargetResource$inboundSchema: z.ZodType< ResourceDiffDtoTargetResource, z.ZodTypeDef, unknown > = z.object({ id: z.nullable(z.string()).optional(), name: z.nullable(z.string()).optional(), updatedBy: z.nullable( z.lazy(() => ResourceDiffDtoTargetResourceUpdatedBy$inboundSchema), ).optional(), updatedAt: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), }); export function resourceDiffDtoTargetResourceFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ResourceDiffDtoTargetResource$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ResourceDiffDtoTargetResource' from JSON`, ); } /** @internal */ export const Diffs$inboundSchema: z.ZodType = z .object({ previous: z.nullable(z.record(z.any())).optional(), new: z.nullable(z.record(z.any())).optional(), }); export function diffsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Diffs$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Diffs' from JSON`, ); } /** @internal */ export const ResourceDiffDto$inboundSchema: z.ZodType< ResourceDiffDto, z.ZodTypeDef, unknown > = z.object({ sourceResource: z.nullable( z.lazy(() => ResourceDiffDtoSourceResource$inboundSchema), ).optional(), targetResource: z.nullable( z.lazy(() => ResourceDiffDtoTargetResource$inboundSchema), ).optional(), resourceType: ResourceTypeEnum$inboundSchema, action: DiffActionEnum$inboundSchema, diffs: z.lazy(() => Diffs$inboundSchema).optional(), stepType: z.string().optional(), previousIndex: z.number().optional(), newIndex: z.number().optional(), }); export function resourceDiffDtoFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ResourceDiffDto$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ResourceDiffDto' from JSON`, ); }