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

import * as z from "zod/v3";
import { safeParse } from "../lib/schemas.js";
import { ClosedEnum } from "../types/enums.js";
import { Result as SafeParseResult } from "../types/fp.js";
import { SDKValidationError } from "./sdkvalidationerror.js";

/**
 * The affected authorization scope. user means each affected user must authorize again.
 */
export const Scope = {
  User: "user",
} as const;
/**
 * The affected authorization scope. user means each affected user must authorize again.
 */
export type Scope = ClosedEnum<typeof Scope>;

/**
 * Existing authorizations no longer cover the connector's configured scopes, so they must be re-authorized.
 */
export type ConnectReconsent = {
  /**
   * The affected authorization scope. user means each affected user must authorize again.
   */
  scope: Scope;
};

/** @internal */
export const Scope$inboundSchema: z.ZodNativeEnum<typeof Scope> = z.nativeEnum(
  Scope,
);

/** @internal */
export const ConnectReconsent$inboundSchema: z.ZodType<
  ConnectReconsent,
  z.ZodTypeDef,
  unknown
> = z.object({
  scope: Scope$inboundSchema,
});

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