/*
 * 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";
import {
  WorkspaceDocument,
  WorkspaceDocument$inboundSchema,
} from "./workspacedocument.js";

export type GetWorkspaceDocumentsResponse = {
  /**
   * The document summary list. Includes the ID, name, and metadata
   */
  documents?: Array<WorkspaceDocument> | null | undefined;
  /**
   * The number of documents returned in the response. Always equal or less than the `count` of the request
   */
  resultSetSize?: number | null | undefined;
  /**
   * Position of the first item in the total results
   */
  startPosition?: number | null | undefined;
  /**
   * Position of the last item in the total results
   */
  endPosition?: number | null | undefined;
  /**
   * The total number of documents in the workspace applicable to the request regardless of pagination. It may not always be computed
   */
  totalRowCount?: number | null | undefined;
};

/** @internal */
export const GetWorkspaceDocumentsResponse$inboundSchema: z.ZodType<
  GetWorkspaceDocumentsResponse,
  z.ZodTypeDef,
  unknown
> = z.object({
  documents: z.nullable(z.array(WorkspaceDocument$inboundSchema)).optional(),
  result_set_size: z.nullable(types.number()).optional(),
  start_position: z.nullable(types.number()).optional(),
  end_position: z.nullable(types.number()).optional(),
  total_row_count: z.nullable(types.number()).optional(),
}).transform((v) => {
  return remap$(v, {
    "result_set_size": "resultSetSize",
    "start_position": "startPosition",
    "end_position": "endPosition",
    "total_row_count": "totalRowCount",
  });
});

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