import {z} from 'zod' export type GetApiApiV1ConfigurationChangelogArgs = {version_id?: string | undefined, version_id_range_min?: number | undefined, version_id_range_max?: number | undefined, q?: string | undefined, object_type?: string | undefined, object_id?: string | undefined, version_event?: ('create' | 'update' | 'delete') | undefined, modifier_id?: string | undefined, changed_fields?: string | undefined, version_created_at_after?: string | undefined, version_created_at_before?: string | undefined, include_snapshot?: boolean | undefined, page?: number | undefined, page_size?: number | undefined}; export type GetApiApiV1ConfigurationChangelogOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const configurationChangelogEntry = z.object({version_id: z.number().int(), tenant: z.string(), organization_id: z.number().int(), object_type: z.enum(["hook", "schema", "queue", "rule", "email_template", "trigger", "workspace", "engine"]), object_id: z.number().int(), version_event: z.enum(["create", "update", "delete"]), version_created_at: z.string(), modifier_id: z.number().int().nullable(), changed_fields: z.array(z.string()), name: z.string().nullable().optional(), created_at: z.string().optional(), modified_at: z.string().optional(), creator_id: z.number().int().nullable().optional(), description: z.string().nullable().optional(), snapshot: z.record(z.string(), z.unknown()).optional()}); export const pagination = z.object({next: z.string().nullable().optional(), previous: z.string().nullable().optional()}); export const configurationChangelogResponse = z.object({results: z.array(configurationChangelogEntry), pagination: pagination}); 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 configuration changelog * * GET /api/v1/configuration_changelog */ export const getApiApiV1ConfigurationChangelog = async (args: GetApiApiV1ConfigurationChangelogArgs, options?: GetApiApiV1ConfigurationChangelogOptions) => { const {baseUrl = "https://example.rossum.app", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.version_id != null) query.append("version_id", String(args.version_id)) if (args.version_id_range_min != null) query.append("version_id_range_min", String(args.version_id_range_min)) if (args.version_id_range_max != null) query.append("version_id_range_max", String(args.version_id_range_max)) if (args.q != null) query.append("q", String(args.q)) if (args.object_type != null) query.append("object_type", String(args.object_type)) if (args.object_id != null) query.append("object_id", String(args.object_id)) if (args.version_event != null) query.append("version_event", String(args.version_event)) if (args.modifier_id != null) query.append("modifier_id", String(args.modifier_id)) if (args.changed_fields != null) query.append("changed_fields", String(args.changed_fields)) if (args.version_created_at_after != null) query.append("version_created_at_after", String(args.version_created_at_after)) if (args.version_created_at_before != null) query.append("version_created_at_before", String(args.version_created_at_before)) if (args.include_snapshot != null) query.append("include_snapshot", String(args.include_snapshot)) if (args.page != null) query.append("page", String(args.page)) if (args.page_size != null) query.append("page_size", String(args.page_size)) if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/configuration_changelog${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(configurationChangelogResponse, await res.json()) };