import {z} from 'zod' export type Metadata = Record; export type ModifiedBy = string | null; export type ModifiedAt = string | null; export type AnnotationListTable = {visible?: boolean | undefined, width?: number | undefined, column_type?: ('meta' | 'schema') | undefined, schema_id?: string | undefined, data_type?: ('date' | 'number' | 'string' | 'boolean') | undefined, meta_type?: string | undefined}; export type QueueBase = {id?: number | undefined, name?: string | undefined, url?: string | undefined, workspace?: (string | null) | undefined, connector?: (string | null) | undefined, webhooks?: Array | undefined, hooks?: Array | undefined, schema?: string | undefined, inbox?: (string | null) | undefined, users?: Array | undefined, session_timeout?: string | undefined, rir_url?: (string | null) | undefined, rir_params?: (string | null) | undefined, dedicated_engine?: (string | null) | undefined, generic_engine?: (string | null) | undefined, counts?: ({importing?: number | undefined, split?: number | undefined, failed_import?: number | undefined, to_review?: number | undefined, reviewing?: number | undefined, confirmed?: number | undefined, exporting?: number | undefined, postponed?: number | undefined, failed_export?: number | undefined, exported?: number | undefined, deleted?: number | undefined, purged?: number | undefined, rejected?: number | undefined}) | undefined, default_score_threshold?: number | undefined, automation_enabled?: boolean | undefined, automation_level?: ('never' | 'confident' | 'always') | undefined, locale?: string | undefined, metadata?: Metadata | undefined, use_confirmed_state?: boolean | undefined, document_lifetime?: (string | null) | undefined, status?: ('active' | 'deletion_requested' | 'deletion_in_progress' | 'deletion_failed') | undefined, modified_by?: ModifiedBy | undefined, modified_at?: ModifiedAt | undefined, settings?: ({columns?: Array> | undefined, hide_export_button?: boolean | undefined, autopilot?: (Record | null) | undefined, accepted_mime_types?: Array | undefined, automation?: ({automate_duplicates?: boolean | undefined, automate_suggested_edit?: boolean | undefined}) | undefined, rejection_config?: ({enabled?: boolean | undefined}) | undefined, suggested_recipients_sources?: (Array<{source?: ('email_header' | 'extracted_value' | 'vendor_database' | 'queue_mailing_history' | 'organization_users') | undefined, schema_id?: string | undefined}>) | undefined, suggested_edit?: ('suggest' | 'disable') | undefined, dashboard_customization?: ({all_documents?: boolean | undefined, confirmed?: boolean | undefined, deleted?: boolean | undefined, exported?: boolean | undefined, postponed?: boolean | undefined, rejected?: boolean | undefined, to_review?: boolean | undefined}) | undefined, email_notifications?: ({recipient?: ({email?: string | undefined, name?: string | undefined} | null) | undefined, unprocessable_attachments?: boolean | undefined, email_with_no_attachments?: boolean | undefined, postponed_annotations?: boolean | undefined, deleted_annotations?: boolean | undefined}) | undefined, workflows?: ({enabled?: boolean | undefined, bypass_workflows_allowed?: boolean | undefined}) | undefined, annotation_list_table?: ({columns?: Array | undefined}) | undefined, upload_values?: (Array<{id?: string | undefined, type?: ('values' | 'metadata') | undefined, data_type?: ('enum' | 'string') | undefined, label?: string | undefined, enum_options?: (Array<{value?: string | undefined, label?: string | undefined}> | null) | undefined, required?: boolean | undefined}>) | undefined, html_conversion_enabled?: boolean | undefined, txt_conversion_enabled?: boolean | undefined, ui_upload_enabled?: boolean | undefined, ui_on_edit_confirm?: ('annotation_list' | 'edit_next' | 'validate_first') | undefined, ui_validation_screen_enabled?: boolean | undefined, ui_edit_target_queue_selection_enabled?: boolean | undefined, ui_edit_always_split_document?: boolean | undefined, ui_edit_values?: (Array<{id?: string | undefined, label?: string | undefined, data_type?: ('enum' | 'string') | undefined, enum_options?: (Array<{value?: string | undefined, label?: string | undefined}> | null) | undefined, required?: boolean | undefined}>) | undefined}) | undefined, workflows?: (Array<{url?: string | undefined, priority?: number | undefined}>) | undefined, enabled?: boolean | undefined}; export type UpdateApiApiV1QueuesIdArgs = {id: number, body: QueueBase}; export type UpdateApiApiV1QueuesIdOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const metadata = z.object({}); export const modifiedBy = z.string().nullable(); export const modifiedAt = z.string().nullable(); export const annotationListTable = z.object({visible: z.boolean().optional(), width: z.number().optional(), column_type: z.enum(["meta", "schema"]).optional(), schema_id: z.string().optional(), data_type: z.enum(["date", "number", "string", "boolean"]).optional(), meta_type: z.string().optional()}); export const queue = z.object({id: z.number().int(), name: z.string().max(255), url: z.string(), workspace: z.string().nullable(), connector: z.string().nullable(), webhooks: z.array(z.string()), hooks: z.array(z.string()), schema: z.string(), inbox: z.string().nullable(), users: z.array(z.string()), session_timeout: z.string(), rir_url: z.string().nullable(), rir_params: z.string().nullable(), dedicated_engine: z.string().nullable(), generic_engine: z.string().nullable(), counts: z.object({importing: z.number().int().optional(), split: z.number().int().optional(), failed_import: z.number().int().optional(), to_review: z.number().int().optional(), reviewing: z.number().int().optional(), confirmed: z.number().int().optional(), exporting: z.number().int().optional(), postponed: z.number().int().optional(), failed_export: z.number().int().optional(), exported: z.number().int().optional(), deleted: z.number().int().optional(), purged: z.number().int().optional(), rejected: z.number().int().optional()}), default_score_threshold: z.number().gte(0).lte(1), automation_enabled: z.boolean(), automation_level: z.enum(["never", "confident", "always"]), locale: z.string(), metadata: metadata, use_confirmed_state: z.boolean(), document_lifetime: z.string().nullable(), status: z.enum(["active", "deletion_requested", "deletion_in_progress", "deletion_failed"]), modified_by: modifiedBy, modified_at: modifiedAt, settings: z.object({columns: z.array(z.object({})).optional(), hide_export_button: z.boolean().optional(), autopilot: z.object({}).nullable().optional(), accepted_mime_types: z.array(z.string()).optional(), automation: z.object({automate_duplicates: z.boolean().optional(), automate_suggested_edit: z.boolean().optional()}).optional(), rejection_config: z.object({enabled: z.boolean().optional()}).optional(), suggested_recipients_sources: z.array(z.object({source: z.enum(["email_header", "extracted_value", "vendor_database", "queue_mailing_history", "organization_users"]).optional(), schema_id: z.string().optional()})).optional(), suggested_edit: z.enum(["suggest", "disable"]).optional(), dashboard_customization: z.object({all_documents: z.boolean().optional(), confirmed: z.boolean().optional(), deleted: z.boolean().optional(), exported: z.boolean().optional(), postponed: z.boolean().optional(), rejected: z.boolean().optional(), to_review: z.boolean().optional()}).optional(), email_notifications: z.object({recipient: z.object({email: z.string().optional(), name: z.string().optional()}).nullable().optional(), unprocessable_attachments: z.boolean().optional(), email_with_no_attachments: z.boolean().optional(), postponed_annotations: z.boolean().optional(), deleted_annotations: z.boolean().optional()}).optional(), workflows: z.object({enabled: z.boolean().optional(), bypass_workflows_allowed: z.boolean().optional()}).optional(), annotation_list_table: z.object({columns: z.array(annotationListTable).optional()}).optional(), upload_values: z.array(z.object({id: z.string().optional(), type: z.enum(["values", "metadata"]).optional(), data_type: z.enum(["enum", "string"]).optional(), label: z.string().optional(), enum_options: z.array(z.object({value: z.string().optional(), label: z.string().optional()})).nullable().optional(), required: z.boolean().optional()})).optional(), html_conversion_enabled: z.boolean().optional(), txt_conversion_enabled: z.boolean().optional(), ui_upload_enabled: z.boolean().optional(), ui_on_edit_confirm: z.enum(["annotation_list", "edit_next", "validate_first"]).optional(), ui_validation_screen_enabled: z.boolean().optional(), ui_edit_target_queue_selection_enabled: z.boolean().optional(), ui_edit_always_split_document: z.boolean().optional(), ui_edit_values: z.array(z.object({id: z.string().optional(), label: z.string().optional(), data_type: z.enum(["enum", "string"]).optional(), enum_options: z.array(z.object({value: z.string().optional(), label: z.string().optional()})).nullable().optional(), required: z.boolean().optional()})).optional()}), workflows: z.array(z.object({url: z.string().optional(), priority: z.number().int().optional()})), enabled: z.boolean()}); 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 }; /** * Update queue * * PUT /api/v1/queues/{id} */ export const updateApiApiV1QueuesId = async (args: UpdateApiApiV1QueuesIdArgs, options?: UpdateApiApiV1QueuesIdOptions) => { const {baseUrl = "https://example.rossum.app", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/queues/${encodeURIComponent(String(args.id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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(queue, await res.json()) };