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

export type WorkspaceSummary = {
  /**
   * The ID of the workspace
   */
  workspaceId?: string | undefined;
  /**
   * The name of the workspace
   */
  name?: string | null | undefined;
  /**
   * The date the workspace was created
   */
  createdDate?: Date | null | undefined;
  /**
   * The ID of the user who created the workspace
   */
  createdByUserId?: string | undefined;
};

/** @internal */
export const WorkspaceSummary$inboundSchema: z.ZodType<
  WorkspaceSummary,
  z.ZodTypeDef,
  unknown
> = z.object({
  workspace_id: types.optional(types.string()),
  name: z.nullable(types.string()).optional(),
  created_date: z.nullable(types.date()).optional(),
  created_by_user_id: types.optional(types.string()),
}).transform((v) => {
  return remap$(v, {
    "workspace_id": "workspaceId",
    "created_date": "createdDate",
    "created_by_user_id": "createdByUserId",
  });
});

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