import {z} from 'zod' export type GetApiHubsHubHashIdProjectsProjectIdProjectAuthorsArgs = {HubHashId: string, ProjectId: number, UserName?: string | undefined, IsFromSystem?: boolean | undefined, AccessToken?: string | undefined}; export type GetApiHubsHubHashIdProjectsProjectIdProjectAuthorsOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; export const featuresSharedModelsUserSummary = z.object({id: z.number().int().optional(), firstName: z.string().nullable().optional(), lastName: z.string().nullable().optional(), email: z.string().nullable().optional(), avatarUrl: z.string().nullable().optional(), isDisabled: z.boolean().optional()}); export const featuresProjectsGetProjectAuthorsGetProjectAuthorsResponse = z.object({authors: z.array(featuresSharedModelsUserSummary).nullable()}); 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 }; /** * List author users * * GET /hubs/{HubHashId}/projects/{ProjectId}/project_authors */ export const getApiHubsHubHashIdProjectsProjectIdProjectAuthors = async (args: GetApiHubsHubHashIdProjectsProjectIdProjectAuthorsArgs, options?: GetApiHubsHubHashIdProjectsProjectIdProjectAuthorsOptions) => { const {baseUrl = "https://docs.bimtrackapp.co", fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.UserName != null) query.append("UserName", String(args.UserName)) if (args.IsFromSystem != null) query.append("IsFromSystem", String(args.IsFromSystem)) if (args.AccessToken != null) query.append("AccessToken", String(args.AccessToken)) if (Bearer !== undefined) headers.set("Authorization", Bearer) const url = `${baseUrl.replace(/\/+$/, '')}/hubs/${encodeURIComponent(String(args.HubHashId))}/projects/${encodeURIComponent(String(args.ProjectId))}/project_authors${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(featuresProjectsGetProjectAuthorsGetProjectAuthorsResponse, await res.json()) };