import {z} from 'zod' export type DownloadExportedFileRequest = {JobId?: string | undefined, FileType?: string | undefined}; export type DownloadExportedFileAsyncRequestBody = {request?: DownloadExportedFileRequest | undefined}; export type CreateApiRelativityAuditV1WorkspacesWorkspaceIDExportDownloadArgs = {workspaceID: number, 'x-csrf-header': string, body: DownloadExportedFileAsyncRequestBody}; export type CreateApiRelativityAuditV1WorkspacesWorkspaceIDExportDownloadOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; export const iKeplerStream = z.object({ContentType: z.string().optional(), ContentDisposition: z.string().optional(), CacheControl: z.string().optional(), StatusCode: z.enum(["Continue", "SwitchingProtocols", "OK", "Created", "Accepted", "NonAuthoritativeInformation", "NoContent", "ResetContent", "PartialContent", "MultipleChoices", "Ambiguous", "MovedPermanently", "Moved", "Found", "Redirect", "SeeOther", "RedirectMethod", "NotModified", "UseProxy", "Unused", "TemporaryRedirect", "RedirectKeepVerb", "BadRequest", "Unauthorized", "PaymentRequired", "Forbidden", "NotFound", "MethodNotAllowed", "NotAcceptable", "ProxyAuthenticationRequired", "RequestTimeout", "Conflict", "Gone", "LengthRequired", "PreconditionFailed", "RequestEntityTooLarge", "RequestUriTooLong", "UnsupportedMediaType", "RequestedRangeNotSatisfiable", "ExpectationFailed", "UpgradeRequired", "InternalServerError", "NotImplemented", "BadGateway", "ServiceUnavailable", "GatewayTimeout", "HttpVersionNotSupported"]).nullable().optional(), Headers: z.array(z.string()).optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * [Public] IAuditExportService - * * POST /relativity-audit/v1/workspaces/{workspaceID}/export/download */ export const createApiRelativityAuditV1WorkspacesWorkspaceIDExportDownload = async (args: CreateApiRelativityAuditV1WorkspacesWorkspaceIDExportDownloadArgs, options: CreateApiRelativityAuditV1WorkspacesWorkspaceIDExportDownloadOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args['x-csrf-header'] != null) headers.set("x-csrf-header", String(args['x-csrf-header'])) const url = `${baseUrl.replace(/\/+$/, '')}/relativity-audit/v1/workspaces/${encodeURIComponent(String(args.workspaceID))}/export/download${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(iKeplerStream, await res.json()) };