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

import * as z from "zod";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import {
  Tab,
  Tab$inboundSchema,
  Tab$Outbound,
  Tab$outboundSchema,
} from "./tab.js";

export type TabInfo = {
  /**
   * Unique ID of the installed extension app
   */
  appId: string;
  /**
   * Tab data representing the tabs associated with installed apps in the account
   */
  tabs: Array<Tab>;
};

/** @internal */
export const TabInfo$inboundSchema: z.ZodType<TabInfo, z.ZodTypeDef, unknown> =
  z.object({
    appId: z.string(),
    tabs: z.array(Tab$inboundSchema),
  });

/** @internal */
export type TabInfo$Outbound = {
  appId: string;
  tabs: Array<Tab$Outbound>;
};

/** @internal */
export const TabInfo$outboundSchema: z.ZodType<
  TabInfo$Outbound,
  z.ZodTypeDef,
  TabInfo
> = z.object({
  appId: z.string(),
  tabs: z.array(Tab$outboundSchema),
});

/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export namespace TabInfo$ {
  /** @deprecated use `TabInfo$inboundSchema` instead. */
  export const inboundSchema = TabInfo$inboundSchema;
  /** @deprecated use `TabInfo$outboundSchema` instead. */
  export const outboundSchema = TabInfo$outboundSchema;
  /** @deprecated use `TabInfo$Outbound` instead. */
  export type Outbound = TabInfo$Outbound;
}

export function tabInfoToJSON(tabInfo: TabInfo): string {
  return JSON.stringify(TabInfo$outboundSchema.parse(tabInfo));
}

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