import {z} from 'zod' export type ConnectProtocolVersion = number; export type ConnectTimeoutHeader = number; export type TextqlRpcPublicPatchesListOntologySyncRunsRequest = {pageSize?: (number | null) | undefined, pageToken?: (string | null) | undefined}; export type CreateApiTextqlRpcPublicPatchesOntologyManagementServiceListOntologySyncRunsArgs = {'Connect-Protocol-Version': ConnectProtocolVersion, 'Connect-Timeout-Ms'?: ConnectTimeoutHeader | undefined, body: TextqlRpcPublicPatchesListOntologySyncRunsRequest}; export type CreateApiTextqlRpcPublicPatchesOntologyManagementServiceListOntologySyncRunsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; export const textqlRpcPublicPatchesOntologySyncRunStatus = z.enum(["ONTOLOGY_SYNC_RUN_STATUS_UNSPECIFIED", "ONTOLOGY_SYNC_RUN_STATUS_IN_PROGRESS", "ONTOLOGY_SYNC_RUN_STATUS_SUCCEEDED", "ONTOLOGY_SYNC_RUN_STATUS_FAILED", "ONTOLOGY_SYNC_RUN_STATUS_CONFLICTS"]); export const googleProtobufTimestamp = z.string(); export const textqlRpcPublicPatchesOntologySyncRun = z.object({id: z.string().optional(), remoteId: z.string().nullable().optional(), remoteUrl: z.string().nullable().optional(), defaultBranch: z.string().nullable().optional(), source: z.string().optional(), status: textqlRpcPublicPatchesOntologySyncRunStatus.optional(), startedAt: googleProtobufTimestamp.optional(), completedAt: googleProtobufTimestamp.optional(), errorMessage: z.string().nullable().optional(), conflictCount: z.number().int().optional()}); export const textqlRpcPublicPatchesListOntologySyncRunsResponse = z.object({runs: z.array(textqlRpcPublicPatchesOntologySyncRun).optional(), nextPageToken: z.string().nullable().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 }; /** * ListOntologySyncRuns * * POST /textql.rpc.public.patches.OntologyManagementService/ListOntologySyncRuns */ export const createApiTextqlRpcPublicPatchesOntologyManagementServiceListOntologySyncRuns = async (args: CreateApiTextqlRpcPublicPatchesOntologyManagementServiceListOntologySyncRunsArgs, options: CreateApiTextqlRpcPublicPatchesOntologyManagementServiceListOntologySyncRunsOptions) => { 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['Connect-Protocol-Version'] != null) headers.set("Connect-Protocol-Version", String(args['Connect-Protocol-Version'])) if (args['Connect-Timeout-Ms'] != null) headers.set("Connect-Timeout-Ms", String(args['Connect-Timeout-Ms'])) const url = `${baseUrl.replace(/\/+$/, '')}/textql.rpc.public.patches.OntologyManagementService/ListOntologySyncRuns${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(textqlRpcPublicPatchesListOntologySyncRunsResponse, await res.json()) };