/*
 * 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 * as types from "../types/primitives.js";
import { SDKValidationError } from "./sdkvalidationerror.js";

/**
 * Provider synchronization errors, when synchronization is required.
 */
export type ConnectServiceSyncError = {
  /**
   * Human-readable provider synchronization error.
   */
  message: string;
  /**
   * Connector fields that caused the synchronization error.
   */
  fields?: Array<string> | undefined;
  /**
   * Provider-specific error details that are safe to expose.
   */
  vendor?: { [k: string]: any } | undefined;
};

/** @internal */
export const ConnectServiceSyncError$inboundSchema: z.ZodType<
  ConnectServiceSyncError,
  z.ZodTypeDef,
  unknown
> = z.object({
  message: types.string(),
  fields: types.optional(z.array(types.string())),
  vendor: types.optional(z.record(z.any())),
});

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