import type { ChunkEntityLink, ExtractionAnalysis, ExtractionAgent, ExtractionDocument, ExtractionResult, ExtractionBatch, ExtractionExport, ExtractionWorkflow, ConfigEnum, PostProcessingHook, SchemaDiscovery, ShadowComparison, TrainingAnalytics, FieldMappingResult, DocumentStats, OperationSuccess, PresignedUrl } from "../_internal/types.gen"; import type { RequestOptions } from "../base-client"; import { RequestBuilder } from "../request-builder"; /** * A single field correction submitted to `results.saveCorrections`. * * `value` is intentionally unconstrained — agent schemas decide the type. */ export interface ExtractionCorrectionRow { field?: string; name?: string; value?: unknown; notes?: string; } /** * A single source→target column mapping for `fieldMappings.create`. * * Admin callers typically use the `source`/`target` pair; `source_column` / * `target_field` are accepted as aliases. */ export interface FieldMappingEntry { source_column?: string; target_field?: string; source?: string; target?: string; confidence?: number; } /** * A single step in an `ExtractionWorkflow.steps` array. * * Shape is intentionally loose — user-authored `config` values depend on * step type and are server-validated. */ export interface ExtractionWorkflowStep { name?: string; type?: string; agent_id?: string; agent_source?: string; config?: Record; order?: number; outputs?: string[]; } /** * A single inferred field returned by schema discovery. * * `examples` mirror whatever the LLM extracted — no narrowing. */ export interface SchemaDiscoveryField { name?: string; field_type?: string; description?: string; examples?: unknown[]; confidence?: number; } /** * A single row inside `ExtractionResult.rows` (tabular extraction output). * * Keys are user-defined field names. */ export type ExtractionRowResultRow = Record; /** * Attributes for updating document processing status. * * Mirrors `Document.update_status` accept list: `status`, `progress`, * `error_message`, `pages`, `billed_credits`, `domain`, `document_type`, * `municipality`, `state`, `classification_confidence`, `avg_confidence`, * `completed_at`, `processed_at`, `training_metadata`, `agent_id`, * `agent_version_id`, `schema_revision`, `char_count`, `word_count`, * `line_count`, `image_width`, `image_height`. */ export interface UpdateDocumentStatusAttributes { status: string; progress?: number; error_message?: string | null; pages?: number; billed_credits?: number; domain?: string; document_type?: string; municipality?: string; state?: string; classification_confidence?: number; avg_confidence?: number; completed_at?: string; processed_at?: string; training_metadata?: Record; agent_id?: string; agent_version_id?: string; schema_revision?: number; char_count?: number; word_count?: number; line_count?: number; image_width?: number; image_height?: number; } /** * Attributes for updating document verification. * * Mirrors `Document.update_verification` accept list. */ export interface UpdateDocumentVerificationAttributes { verification_status?: "partially_verified" | "fully_verified" | string; verified_by_user_id?: string; last_verified_at?: string; avg_confidence?: number; } /** * Attributes for beginning a document upload. * * Mirrors `Document.begin_upload` accept list + `content_type` action * argument. */ export interface AdminBeginUploadAttributes { filename: string; file_type: string; workspace_id: string; content_type?: string; file_size_bytes?: number; file_hash?: string; parent_document_id?: string; batch_id?: string; } /** * Attributes for finding or beginning a document upload. * * Mirrors `Document.find_or_begin_upload` action arguments. */ export interface AdminFindOrBeginUploadAttributes { filename: string; file_type: string; workspace_id: string; file_hash?: string; file_size_bytes?: number; content_type?: string; parent_document_id?: string; batch_id?: string; force?: boolean; } /** * Attributes for direct document upload. * * Mirrors `Document.upload` accept list. */ export interface AdminUploadDocumentAttributes { filename: string; file_type: string; workspace_id: string; storage_path?: string; file_size_bytes?: number; file_hash?: string; parent_document_id?: string; bucket_name?: string; } /** * Request attributes for bulk-reprocessing multiple documents (admin). * * Mirrors `BulkReprocessResult.:bulk_reprocess` arguments. `workspace_id` * and `document_ids` are both required; the server returns a 400 otherwise. */ export interface AdminBulkReprocessAttributes { workspace_id: string; document_ids: string[]; schema_version_id?: string; } export type AdminWorkspaceThroughputWindow = "today" | "7d" | "30d"; export type AdminWorkspaceThroughputBucket = { start_at: string; end_at: string; count: number; unit: "hour" | "day"; }; export type AdminWorkspaceThroughput = { metrics: { decided: number; completed: number; failed: number; median_cycle_seconds: number | null; }; buckets: AdminWorkspaceThroughputBucket[]; }; /** Attributes for requesting a presigned upload URL. */ export interface AdminPresignedUploadAttributes { filename: string; mime_type: string; size_bytes: number; workspace_id: string; } /** Result of a batch finish-all operation. */ export interface AdminBatchFinishAllResult { processed_count?: number; results?: Record; } /** * Attributes for updating an extraction result. * * Mirrors the `ExtractionResult :update` accept list: `status`, * `credits_used`, `processing_time_ms`, `extracted_fields`, * `classification_confidence`, `domain`, `document_type`, `municipality`, * `state`. `review_status` is the UI-facing alias. */ export interface AdminUpdateResultAttributes { review_status?: string; status?: string; classification_confidence?: number; domain?: string; document_type?: string; municipality?: string; state?: string; } /** * Attributes for regenerating an extraction result. * * Mirrors the `:regenerate` action arguments: `feedback`, `fields_to_retry`, * `schema_version_id`. */ export interface AdminRegenerateResultAttributes { feedback?: string; fields_to_retry?: string[]; schema_version_id?: string; } /** Attributes for saving corrections to an extraction result. */ export interface AdminSaveCorrectionsAttributes { corrections: ExtractionCorrectionRow[]; } /** * Attributes for creating an extraction batch. * * Mirrors `Batch :create` accept list (`workspace_id`, `name`, `user_label`). * `agent_id` and `document_ids` are accepted as supplemental server-side * arguments in some deployments. */ export interface AdminCreateBatchAttributes { name?: string; user_label?: string; agent_id?: string; workspace_id: string; document_ids?: string[]; } /** * Attributes for creating an extraction export. * * Mirrors `Export :create` accept list (`workspace_id`, `format`, `config`). */ export interface AdminCreateExportAttributes { format: "csv" | "json" | "xlsx"; agent_id?: string; config?: Record; } /** * Attributes for creating an extraction workflow. * * Mirrors `ExtractionWorkflow :create` accept list: `name`, `description`, * `trigger`, `steps`, `workspace_id`, `enabled`. */ export interface AdminCreateWorkflowAttributes { name: string; description?: string; trigger?: "on_upload" | "on_schedule" | "manual"; steps?: ExtractionWorkflowStep[]; workspace_id?: string; enabled?: boolean; } /** * Attributes for updating an extraction workflow. * * Mirrors `ExtractionWorkflow :update` accept list. */ export interface AdminUpdateWorkflowAttributes { name?: string; description?: string; trigger?: "on_upload" | "on_schedule" | "manual"; steps?: ExtractionWorkflowStep[]; enabled?: boolean; } /** * Attributes for creating a config enum. * * Mirrors `ConfigEnum :create` accept list: `type`, `value`, `label`, * `description`, `is_active`, `sort_order`. */ export interface AdminCreateConfigEnumAttributes { type: string; value: string; label?: string; description?: string; is_active?: boolean; sort_order?: number; } /** * Attributes for updating a config enum. * * Mirrors `ConfigEnum :update` accept list: `label`, `description`, * `is_active`, `sort_order`. */ export interface AdminUpdateConfigEnumAttributes { label?: string; description?: string; is_active?: boolean; sort_order?: number; } /** * Attributes for creating a schema discovery. * * Mirrors the three `:create` variants in `SchemaDiscovery`: combinations of * `agent_id`, `document_id`, `workspace_id`, `advanced_mode`, * `discovered_fields`, `suggested_name`, `source`. */ export interface AdminCreateSchemaDiscoveryAttributes { agent_id?: string; document_id?: string; workspace_id?: string; advanced_mode?: boolean; suggested_name?: string; discovered_fields?: SchemaDiscoveryField[]; source?: string; } /** Attributes for bootstrapping schema discovery. */ export interface AdminBootstrapSchemaDiscoveryAttributes { workspace_id?: string; advanced_mode?: boolean; source?: string; } /** * Attributes for creating/updating field mappings. * * Mirrors `FieldMappingConfirmation :confirm` accept list: * `mappings`, `add_to_schema`, `ignored_fields`, `confirmed`. */ export interface AdminFieldMappingAttributes { confirmed: boolean; mappings: FieldMappingEntry[]; add_to_schema?: FieldMappingEntry[]; ignored_fields?: string[]; } /** * Attributes for creating a post-processing hook. * * Mirrors `PostProcessingHook :create` accept list. */ export interface AdminCreatePostProcessingHookAttributes { name: string; trigger?: "after_extraction" | "after_validation" | "before_downstream"; type?: "webhook" | "oban_worker" | "reactor_step"; config?: Record; field_filter?: string[]; can_modify?: boolean; order?: number; enabled?: boolean; workspace_id: string; application_id?: string; } /** * Attributes for updating a post-processing hook. * * Mirrors `PostProcessingHook :update` accept list. */ export interface AdminUpdatePostProcessingHookAttributes { name?: string; trigger?: "after_extraction" | "after_validation" | "before_downstream"; type?: "webhook" | "oban_worker" | "reactor_step"; config?: Record; field_filter?: string[]; can_modify?: boolean; order?: number; enabled?: boolean; } /** Attributes for predicting the best extraction agent for a document. */ export interface AdminPredictExtractionAgentAttributes { name?: string; description?: string; file_content?: string; document_id?: string; } /** * Attributes for creating a shadow comparison. * * Mirrors `ShadowComparison :create` accept list. `document_id` and * `workspace_id` are the conventional seed inputs; other fields are * computed server-side. */ export interface AdminCreateShadowComparisonAttributes { document_id?: string; workspace_id?: string; mime_type?: string; filename?: string; file_size?: number; page_count?: number; primary_extractor?: string; shadow_extractor?: string; } /** * Admin extraction namespace — full document processing pipeline management. * * Sub-namespaces: documents, results, batches, exports, workflows, * configEnums, schemaDiscoveries, fieldMappings, postProcessingHooks, * trainingAnalytics, extractionAgents. * * @example * ```typescript * const admin = new GptAdmin({ apiKey: 'sk_srv_...' }); * * // List documents for a workspace * const docs = await admin.extraction.documents.listByWorkspace(workspaceId); * * // Get extraction result history * const history = await admin.extraction.results.history(documentId); * * // Create a batch upload * const batch = await admin.extraction.batches.create({ workspace_id: '...' }); * ``` */ export declare function createExtractionNamespace(rb: RequestBuilder): { /** Document lifecycle — upload, process, review, train, bulk operations. */ documents: { /** * Lists all extraction documents across the platform. * * @param options - Optional request options (abort signal, custom headers). * @returns An array of extraction document objects. * * @example * ```typescript * const docs = await admin.extraction.documents.list(); * ``` */ list: (options?: RequestOptions) => Promise; /** * Retrieves a single extraction document by its unique identifier. * * @param id - The UUID of the document to retrieve. * @param options - Optional request options (abort signal, custom headers). * @returns The matching extraction document object. * * @example * ```typescript * const doc = await admin.extraction.documents.get('doc-uuid'); * console.log(doc.status, doc.filename); * ``` */ get: (id: string, options?: RequestOptions) => Promise; /** * Permanently deletes an extraction document and its associated results. * * @param id - The UUID of the document to delete. * @param options - Optional request options (abort signal, custom headers). * @returns `true` when the deletion succeeds. * * @example * ```typescript * await admin.extraction.documents.delete('doc-uuid'); * ``` */ delete: (id: string, options?: RequestOptions) => Promise; /** * Retrieves the rendered view of a document, including page images and * overlay data for visual inspection. * * @param id - The UUID of the document. * @param options - Optional request options (abort signal, custom headers). * @returns The document object with rendered view data. * * @example * ```typescript * const view = await admin.extraction.documents.view('doc-uuid'); * ``` */ view: (id: string, options?: RequestOptions) => Promise; /** * Retrieves the current processing status of a document, including * progress percentage and any error details. * * @param id - The UUID of the document. * @param options - Optional request options (abort signal, custom headers). * @returns The document object with current status fields. * * @example * ```typescript * const { status, progress_percent } = await admin.extraction.documents.status('doc-uuid'); * console.log(`Status: ${status} (${progress_percent}%)`); * ``` */ status: (id: string, options?: RequestOptions) => Promise; /** * Updates the processing status of a document. Used by admin tooling to * manually transition a document between pipeline states. * * @param id - The UUID of the document to update. * @param attributes - The status attributes to set. * @param options - Optional request options (abort signal, custom headers). * @returns The updated extraction document object. * * @example * ```typescript * const doc = await admin.extraction.documents.updateStatus('doc-uuid', { * status: 'completed', * }); * ``` */ updateStatus: (id: string, attributes: UpdateDocumentStatusAttributes, options?: RequestOptions) => Promise; /** * Reprocesses a completed or failed document through the extraction * pipeline from scratch. * * @param id - The UUID of the document to reprocess. * @param options - Optional request options (abort signal, custom headers). * @returns The document object with its new processing status. * * @example * ```typescript * const doc = await admin.extraction.documents.reprocess('doc-uuid'); * console.log(`Reprocessing: ${doc.status}`); * ``` */ reprocess: (id: string, options?: RequestOptions) => Promise; /** * Cancels a document that is currently queued or being processed. * * @param id - The UUID of the document to cancel. * @param options - Optional request options (abort signal, custom headers). * @returns The document object with its updated (cancelled) status. * * @example * ```typescript * const doc = await admin.extraction.documents.cancel('doc-uuid'); * ``` */ cancel: (id: string, options?: RequestOptions) => Promise; /** * Dismisses a document from the review queue without changing its * underlying data or verification status. * * @param id - The UUID of the document to dismiss. * @param options - Optional request options (abort signal, custom headers). * @returns The updated extraction document object. * * @example * ```typescript * await admin.extraction.documents.dismiss('doc-uuid'); * ``` */ dismiss: (id: string, options?: RequestOptions) => Promise; /** * Excludes a document from the training dataset. Excluded documents are * not used when retraining extraction models. * * @param id - The UUID of the document to exclude. * @param options - Optional request options (abort signal, custom headers). * @returns The updated extraction document object. * * @example * ```typescript * await admin.extraction.documents.exclude('doc-uuid'); * ``` */ exclude: (id: string, options?: RequestOptions) => Promise; /** * Re-includes a previously excluded document in the training dataset. * * @param id - The UUID of the document to include. * @param options - Optional request options (abort signal, custom headers). * @returns The updated extraction document object. * * @example * ```typescript * await admin.extraction.documents.include('doc-uuid'); * ``` */ include: (id: string, options?: RequestOptions) => Promise; /** * Restores a soft-deleted (trashed) document back to active status. * * @param id - The UUID of the document to restore. * @param options - Optional request options (abort signal, custom headers). * @returns The restored extraction document object. * * @example * ```typescript * const doc = await admin.extraction.documents.restore('doc-uuid'); * console.log(`Restored: ${doc.filename}`); * ``` */ restore: (id: string, options?: RequestOptions) => Promise; /** * Updates the verification status of a document. Used during the human * review step to confirm or reject extracted data. * * @param id - The UUID of the document to update. * @param attributes - Verification attributes to set. * @param options - Optional request options (abort signal, custom headers). * @returns The updated extraction document object. * * @example * ```typescript * const doc = await admin.extraction.documents.updateVerification('doc-uuid', { * verification_status: 'verified', * avg_confidence: 0.95, * }); * ``` */ updateVerification: (id: string, attributes: UpdateDocumentVerificationAttributes, options?: RequestOptions) => Promise; /** * Marks a document as trained, indicating its extraction results have been * incorporated into the model training set. * * @param id - The UUID of the document to mark as trained. * @param options - Optional request options (abort signal, custom headers). * @returns The updated extraction document object. * * @example * ```typescript * await admin.extraction.documents.markTrained('doc-uuid'); * ``` */ markTrained: (id: string, options?: RequestOptions) => Promise; /** * Dismisses the training flag on a document without un-training it. * Useful for clearing training notifications in the review UI. * * @param id - The UUID of the document. * @param options - Optional request options (abort signal, custom headers). * @returns The updated extraction document object. * * @example * ```typescript * await admin.extraction.documents.dismissTraining('doc-uuid'); * ``` */ dismissTraining: (id: string, options?: RequestOptions) => Promise; /** * Signals the server that a multi-part upload has completed and the * document is ready for processing. * * @param id - The UUID of the document whose upload is being finalized. * @param options - Optional request options (abort signal, custom headers). * @returns The document object transitioned to processing state. * * @example * ```typescript * await admin.extraction.documents.finishUpload('doc-uuid'); * ``` */ finishUpload: (id: string, options?: RequestOptions) => Promise; /** * Begins a new document upload and returns a presigned URL for direct * browser-to-storage upload. * * @param attributes - Upload attributes including the filename and optional metadata. * @param options - Optional request options (abort signal, custom headers). * @returns A presigned URL object for uploading the file. * * @example * ```typescript * const presigned = await admin.extraction.documents.beginUpload({ * filename: 'invoice-2026.pdf', * file_type: 'pdf', * workspace_id: 'ws-uuid', * content_type: 'application/pdf', * }); * // Upload file to presigned.upload_url * ``` */ beginUpload: (attributes: AdminBeginUploadAttributes, options?: RequestOptions) => Promise; /** * Finds an existing document by file hash (for deduplication) or begins a * new upload if no match is found. * * @param attributes - Attributes for finding or beginning the upload. * @param options - Optional request options (abort signal, custom headers). * @returns A presigned URL object (or a reference to the existing document). * * @example * ```typescript * const result = await admin.extraction.documents.findOrBeginUpload({ * filename: 'invoice-2026.pdf', * file_type: 'pdf', * workspace_id: 'ws-uuid', * file_hash: 'blake3:abc123...', * content_type: 'application/pdf', * }); * ``` */ findOrBeginUpload: (attributes: AdminFindOrBeginUploadAttributes, options?: RequestOptions) => Promise; /** * Requests a presigned upload URL for direct S3-compatible upload of a * document. Validates file type and size server-side, then returns a URL * the client PUTs the raw bytes to. Distinct from `beginUpload`, which * creates the Document record up front; `presignedUpload` only returns * a URL + storage path without creating the Document row. * * @param attributes - filename, mime_type, size_bytes (max 50 MB), workspace_id. * @param options - Optional request options (abort signal, custom headers). * @returns A presigned URL object (`upload_url`, `storage_path`, `expires_in`). * * @example * ```typescript * const presigned = await admin.extraction.documents.presignedUpload({ * filename: 'invoice.pdf', * mime_type: 'application/pdf', * size_bytes: 512000, * workspace_id: 'ws-uuid', * }); * ``` */ presignedUpload: (attributes: AdminPresignedUploadAttributes, options?: RequestOptions) => Promise; /** * Uploads a document directly in a single shot. The server handles storage * placement and immediately enqueues the document for processing. * * @param attributes - Upload attributes including filename and optional storage path. * @param options - Optional request options (abort signal, custom headers). * @returns The created extraction document object. * * @example * ```typescript * const doc = await admin.extraction.documents.upload({ * filename: 'contract.pdf', * file_type: 'pdf', * workspace_id: 'ws-uuid', * storage_path: 'workspaces/ws-uuid/contract.pdf', * }); * ``` */ upload: (attributes: AdminUploadDocumentAttributes, options?: RequestOptions) => Promise; /** * Reprocesses multiple documents in a single bulk operation. * * @param attrs - Bulk reprocess attributes: `workspace_id` and `document_ids` are required. * @param options - Optional request options (abort signal, custom headers). * @returns An operation success result with the count of enqueued documents. * * @example * ```typescript * const result = await admin.extraction.documents.bulkReprocess({ * workspace_id: 'ws-uuid', * document_ids: ['doc-uuid-1', 'doc-uuid-2'], * }); * console.log(`Enqueued: ${result.enqueued_count}`); * ``` */ bulkReprocess: (attrs: AdminBulkReprocessAttributes, options?: RequestOptions) => Promise; /** * Permanently deletes multiple documents in a single bulk operation. * * @param ids - An array of document UUIDs to delete. * @param options - Optional request options (abort signal, custom headers). * @returns An operation success result with the count of deleted documents. * * @example * ```typescript * const result = await admin.extraction.documents.bulkDelete([ * 'doc-uuid-1', * 'doc-uuid-2', * ]); * console.log(`Deleted: ${result.deleted_count}`); * ``` */ bulkDelete: (ids: string[], options?: RequestOptions) => Promise; /** * Retrieves platform-wide document statistics including counts by status. * * @param options - Optional request options (abort signal, custom headers). * @returns Aggregate document statistics. * * @example * ```typescript * const stats = await admin.extraction.documents.stats(); * console.log(`Total: ${stats.total}, Failed: ${stats.failed}`); * ``` */ stats: (options?: RequestOptions) => Promise; /** * Retrieve throughput metrics and time buckets for a workspace. * * @param workspaceId - Workspace UUID to scope the admin request. * @param window - Optional reporting window. Defaults to `7d` server-side. * @param options - Optional request settings. * @returns Throughput metrics and completed-document buckets. */ workspaceThroughput: (workspaceId: string, window?: AdminWorkspaceThroughputWindow, options?: RequestOptions) => Promise; /** * Lists all extraction documents belonging to a specific workspace. * * @param workspaceId - The UUID of the workspace. * @param options - Optional request options (abort signal, custom headers). * @returns An array of extraction documents for the workspace. * * @example * ```typescript * const docs = await admin.extraction.documents.listByWorkspace('ws-uuid'); * ``` */ listByWorkspace: (workspaceId: string, options?: RequestOptions) => Promise; /** * Lists documents filtered by processing status within a workspace. * * @param workspaceId - The UUID of the workspace. * @param status - The processing status to filter by (e.g. `"completed"`, `"failed"`). * @param options - Optional request options (abort signal, custom headers). * @returns An array of extraction documents matching the status filter. * * @example * ```typescript * const failed = await admin.extraction.documents.listByStatus('ws-uuid', 'failed'); * console.log(`${failed.length} failed documents`); * ``` */ listByStatus: (workspaceId: string, status: string, options?: RequestOptions) => Promise; /** * Returns the review queue for a workspace — documents awaiting human * verification of their extraction results. * * @param workspaceId - The UUID of the workspace. * @param options - Optional request options (abort signal, custom headers). * @returns An array of documents in the review queue. * * @example * ```typescript * const queue = await admin.extraction.documents.reviewQueue('ws-uuid'); * console.log(`${queue.length} documents awaiting review`); * ``` */ reviewQueue: (workspaceId: string, options?: RequestOptions) => Promise; /** * Lists documents that have been marked as trained within a workspace. * * @param workspaceId - The UUID of the workspace. * @param options - Optional request options (abort signal, custom headers). * @returns An array of trained extraction documents. * * @example * ```typescript * const trained = await admin.extraction.documents.listTrained('ws-uuid'); * ``` */ listTrained: (workspaceId: string, options?: RequestOptions) => Promise; /** * Lists soft-deleted (trashed) documents for a workspace. These can be * restored via the `restore` method. * * @param workspaceId - The UUID of the workspace. * @param options - Optional request options (abort signal, custom headers). * @returns An array of trashed extraction documents. * * @example * ```typescript * const trashed = await admin.extraction.documents.listTrashed('ws-uuid'); * ``` */ listTrashed: (workspaceId: string, options?: RequestOptions) => Promise; /** * Lists documents that have been excluded from the training dataset * within a workspace. * * @param workspaceId - The UUID of the workspace. * @param options - Optional request options (abort signal, custom headers). * @returns An array of excluded extraction documents. * * @example * ```typescript * const excluded = await admin.extraction.documents.listExcluded('ws-uuid'); * ``` */ listExcluded: (workspaceId: string, options?: RequestOptions) => Promise; /** * Dismisses all trained-flagged documents in a workspace in one operation. * Useful for clearing training notifications after a batch review. * * @param workspaceId - The UUID of the workspace. * @param options - Optional request options (abort signal, custom headers). * @returns An operation success result with the dismissed count. * * @example * ```typescript * const result = await admin.extraction.documents.dismissAllTrained('ws-uuid'); * console.log(`Dismissed ${result.dismissed_count} documents`); * ``` */ dismissAllTrained: (workspaceId: string, options?: RequestOptions) => Promise; }; /** Extraction result management — CRUD, history, corrections, regeneration. */ results: { /** * Lists all extraction results across the platform. * * @param options - Optional request options (abort signal, custom headers). * @returns An array of extraction result objects. * * @example * ```typescript * const results = await admin.extraction.results.list(); * ``` */ list: (options?: RequestOptions) => Promise; /** * Retrieves a single extraction result by its unique identifier. * * @param id - The UUID of the extraction result. * @param options - Optional request options (abort signal, custom headers). * @returns The matching extraction result object. * * @example * ```typescript * const result = await admin.extraction.results.get('result-uuid'); * console.log(result.extracted_data); * ``` */ get: (id: string, options?: RequestOptions) => Promise; /** * Updates an extraction result's metadata (e.g. review status). * * @param id - The UUID of the extraction result to update. * @param attributes - The attributes to update. * @param options - Optional request options (abort signal, custom headers). * @returns The updated extraction result object. * * @example * ```typescript * const result = await admin.extraction.results.update('result-uuid', { * review_status: 'approved', * }); * ``` */ update: (id: string, attributes: AdminUpdateResultAttributes, options?: RequestOptions) => Promise; /** * Permanently deletes an extraction result. * * @param id - The UUID of the extraction result to delete. * @param options - Optional request options (abort signal, custom headers). * @returns `true` when the deletion succeeds. * * @example * ```typescript * await admin.extraction.results.delete('result-uuid'); * ``` */ delete: (id: string, options?: RequestOptions) => Promise; /** * Retrieves all extraction results for a specific document. * * @param documentId - The UUID of the parent document. * @param options - Optional request options (abort signal, custom headers). * @returns An array of extraction results for the document. * * @example * ```typescript * const results = await admin.extraction.results.byDocument('doc-uuid'); * ``` */ byDocument: (documentId: string, options?: RequestOptions) => Promise; /** * Retrieves the version history of extraction results for a document, * showing how results have changed over reprocessing cycles. * * @param documentId - The UUID of the parent document. * @param options - Optional request options (abort signal, custom headers). * @returns An array of historical extraction result versions. * * @example * ```typescript * const history = await admin.extraction.results.history('doc-uuid'); * console.log(`${history.length} result versions`); * ``` */ history: (documentId: string, options?: RequestOptions) => Promise; /** * Retrieves partial (in-progress) extraction results for a document that * is still being processed. * * @param documentId - The UUID of the parent document. * @param options - Optional request options (abort signal, custom headers). * @returns An array of partial extraction results available so far. * * @example * ```typescript * const partial = await admin.extraction.results.partial('doc-uuid'); * ``` */ partial: (documentId: string, options?: RequestOptions) => Promise; /** * Regenerates an extraction result, optionally incorporating human * feedback or restricting which fields to retry. * * @param id - The UUID of the extraction result to regenerate. * @param attributes - Regeneration parameters (feedback, fields to retry). * @param options - Optional request options (abort signal, custom headers). * @returns The regenerated extraction result object. * * @example * ```typescript * const result = await admin.extraction.results.regenerate('result-uuid', { * feedback: 'The date field was parsed incorrectly.', * fields_to_retry: ['invoice_date', 'due_date'], * }); * ``` */ regenerate: (id: string, attributes: AdminRegenerateResultAttributes, options?: RequestOptions) => Promise; /** * Saves manual corrections to an extraction result. The corrections are * stored alongside the original data and can be used for model training. * * @param id - The UUID of the extraction result to correct. * @param attributes - The corrections to save. * @param options - Optional request options (abort signal, custom headers). * @returns The updated extraction result object with corrections applied. * * @example * ```typescript * const result = await admin.extraction.results.saveCorrections('result-uuid', { * corrections: [ * { field: 'invoice_number', value: 'INV-2026-001' }, * { field: 'total_amount', value: 1250.00 }, * ], * }); * ``` */ saveCorrections: (id: string, attributes: AdminSaveCorrectionsAttributes, options?: RequestOptions) => Promise; /** * Lists all extraction results belonging to a specific workspace. * * @param workspaceId - The UUID of the workspace. * @param options - Optional request options (abort signal, custom headers). * @returns An array of extraction results for the workspace. * * @example * ```typescript * const results = await admin.extraction.results.listByWorkspace('ws-uuid'); * ``` */ listByWorkspace: (workspaceId: string, options?: RequestOptions) => Promise; }; /** Batch upload management — create batches, get upload URLs. */ batches: { /** * Retrieves a single extraction batch by its unique identifier. * * @param id - The UUID of the batch. * @param options - Optional request options (abort signal, custom headers). * @returns The matching extraction batch object. * * @example * ```typescript * const batch = await admin.extraction.batches.get('batch-uuid'); * console.log(`Batch: ${batch.name}, ${batch.document_count} docs`); * ``` */ get: (id: string, options?: RequestOptions) => Promise; /** * Permanently deletes an extraction batch. * * @param id - The UUID of the batch to delete. * @param options - Optional request options (abort signal, custom headers). * @returns `true` when the deletion succeeds. * * @example * ```typescript * await admin.extraction.batches.delete('batch-uuid'); * ``` */ delete: (id: string, options?: RequestOptions) => Promise; /** * Creates a new extraction batch for grouping document uploads. * * @param attributes - Batch creation attributes including workspace ID. * @param options - Optional request options (abort signal, custom headers). * @returns The newly created extraction batch object. * * @example * ```typescript * const batch = await admin.extraction.batches.create({ * name: 'Q1 Invoices', * workspace_id: 'ws-uuid', * agent_id: 'agent-uuid', * }); * ``` */ create: (attributes: AdminCreateBatchAttributes, options?: RequestOptions) => Promise; /** * Lists all extraction batches belonging to a specific workspace. * * @param workspaceId - The UUID of the workspace. * @param options - Optional request options (abort signal, custom headers). * @returns An array of extraction batches for the workspace. * * @example * ```typescript * const batches = await admin.extraction.batches.listByWorkspace('ws-uuid'); * ``` */ listByWorkspace: (workspaceId: string, options?: RequestOptions) => Promise; /** * Retrieves presigned upload URLs for all documents in a batch, enabling * parallel direct-to-storage uploads. * * @param id - The UUID of the batch. * @param options - Optional request options (abort signal, custom headers). * @returns An array of presigned URL objects, one per document slot. * * @example * ```typescript * const urls = await admin.extraction.batches.getUploadUrls('batch-uuid'); * // Upload files in parallel to each presigned URL * await Promise.all(urls.map((u, i) => fetch(u.upload_url, { * method: 'PUT', * body: files[i], * }))); * ``` */ getUploadUrls: (id: string, options?: RequestOptions) => Promise; /** * Finish upload for all documents in a batch that are awaiting processing. * * Calls `:finish_upload` on each document in the batch that is still in * `:queued` status and returns processed count plus per-document results. * * @param batchId - The UUID of the extraction batch. * @param options - Optional request options (abort signal, custom headers). * @returns An operation result with processed count and per-document outcomes. * * @example * ```typescript * const result = await admin.extraction.batches.finishAll('batch-uuid'); * console.log(result.processed_count); * ``` */ finishAll: (batchId: string, options?: RequestOptions) => Promise; }; /** Export management — create and retrieve data exports. */ exports: { /** * Lists all extraction exports for a workspace. * * @param workspaceId - The UUID of the workspace. * @param options - Optional request options (abort signal, custom headers). * @returns An array of extraction export objects. * * @example * ```typescript * const exports = await admin.extraction.exports.list('ws-uuid'); * ``` */ list: (workspaceId: string, options?: RequestOptions) => Promise; /** * Creates a new data export for a workspace in the specified format. * * @param workspaceId - The UUID of the workspace. * @param attributes - Export creation attributes including format. * @param options - Optional request options (abort signal, custom headers). * @returns The newly created extraction export object. * * @example * ```typescript * const exp = await admin.extraction.exports.create('ws-uuid', { * format: 'csv', * agent_id: 'agent-uuid', * }); * console.log(`Export ${exp.id} created, status: ${exp.status}`); * ``` */ create: (workspaceId: string, attributes: AdminCreateExportAttributes, options?: RequestOptions) => Promise; /** * Retrieves a single extraction export by ID within a workspace. * * @param workspaceId - The UUID of the workspace. * @param id - The UUID of the export to retrieve. * @param options - Optional request options (abort signal, custom headers). * @returns The matching extraction export object, including download URL * when the export is complete. * * @example * ```typescript * const exp = await admin.extraction.exports.get('ws-uuid', 'export-uuid'); * if (exp.status === 'completed') { * console.log(`Download: ${exp.download_url}`); * } * ``` */ get: (workspaceId: string, id: string, options?: RequestOptions) => Promise; }; /** Workflow management — configurable extraction pipelines. */ workflows: { /** * Lists all extraction workflows across the platform. * * @param options - Optional request options (abort signal, custom headers). * @returns An array of extraction workflow objects. * * @example * ```typescript * const workflows = await admin.extraction.workflows.list(); * ``` */ list: (options?: RequestOptions) => Promise; /** * Creates a new extraction workflow with the specified configuration. * * @param attributes - Workflow creation attributes including name. * @param options - Optional request options (abort signal, custom headers). * @returns The newly created extraction workflow object. * * @example * ```typescript * const workflow = await admin.extraction.workflows.create({ * name: 'Invoice Processing', * workspace_id: 'ws-uuid', * }); * ``` */ create: (attributes: AdminCreateWorkflowAttributes, options?: RequestOptions) => Promise; /** * Retrieves a single extraction workflow by its unique identifier. * * @param id - The UUID of the workflow. * @param options - Optional request options (abort signal, custom headers). * @returns The matching extraction workflow object. * * @example * ```typescript * const workflow = await admin.extraction.workflows.get('workflow-uuid'); * ``` */ get: (id: string, options?: RequestOptions) => Promise; /** * Updates an existing extraction workflow's configuration. * * @param id - The UUID of the workflow to update. * @param attributes - The attributes to update. * @param options - Optional request options (abort signal, custom headers). * @returns The updated extraction workflow object. * * @example * ```typescript * const workflow = await admin.extraction.workflows.update('workflow-uuid', { * name: 'Updated Invoice Pipeline', * }); * ``` */ update: (id: string, attributes: AdminUpdateWorkflowAttributes, options?: RequestOptions) => Promise; /** * Permanently deletes an extraction workflow. * * @param id - The UUID of the workflow to delete. * @param options - Optional request options (abort signal, custom headers). * @returns `true` when the deletion succeeds. * * @example * ```typescript * await admin.extraction.workflows.delete('workflow-uuid'); * ``` */ delete: (id: string, options?: RequestOptions) => Promise; }; /** Config enum management — dropdown and validation values. */ configEnums: { /** * Lists all config enums used for extraction field validation and * dropdown options. * * @param options - Optional request options (abort signal, custom headers). * @returns An array of config enum objects. * * @example * ```typescript * const enums = await admin.extraction.configEnums.list(); * ``` */ list: (options?: RequestOptions) => Promise; /** * Creates a new config enum value for use in extraction field dropdowns * and validation. * * @param attributes - Config enum creation attributes. * @param options - Optional request options (abort signal, custom headers). * @returns The newly created config enum object. * * @example * ```typescript * const enumVal = await admin.extraction.configEnums.create({ * type: 'document_category', * value: 'invoice', * label: 'Invoice', * }); * ``` */ create: (attributes: AdminCreateConfigEnumAttributes, options?: RequestOptions) => Promise; /** * Retrieves a single config enum by its unique identifier. * * @param id - The UUID of the config enum. * @param options - Optional request options (abort signal, custom headers). * @returns The matching config enum object. * * @example * ```typescript * const enumVal = await admin.extraction.configEnums.get('enum-uuid'); * ``` */ get: (id: string, options?: RequestOptions) => Promise; /** * Updates an existing config enum's label or other mutable attributes. * * @param id - The UUID of the config enum to update. * @param attributes - The attributes to update. * @param options - Optional request options (abort signal, custom headers). * @returns The updated config enum object. * * @example * ```typescript * const enumVal = await admin.extraction.configEnums.update('enum-uuid', { * label: 'Updated Label', * }); * ``` */ update: (id: string, attributes: AdminUpdateConfigEnumAttributes, options?: RequestOptions) => Promise; }; /** Schema discovery — AI-powered field schema detection. */ schemaDiscoveries: { /** * Runs schema discovery on documents to automatically detect extraction * field schemas using AI. * * @param attributes - Schema discovery attributes (document or workspace scope). * @param options - Optional request options (abort signal, custom headers). * @returns The created schema discovery object with detected fields. * * @example * ```typescript * const discovery = await admin.extraction.schemaDiscoveries.create({ * document_id: 'doc-uuid', * workspace_id: 'ws-uuid', * }); * console.log(discovery.suggested_fields); * ``` */ create: (attributes: AdminCreateSchemaDiscoveryAttributes, options?: RequestOptions) => Promise; /** * Retrieves a schema discovery result by its unique identifier. * * @param id - The UUID of the schema discovery. * @param options - Optional request options (abort signal, custom headers). * @returns The matching schema discovery object. * * @example * ```typescript * const discovery = await admin.extraction.schemaDiscoveries.get('discovery-uuid'); * ``` */ get: (id: string, options?: RequestOptions) => Promise; /** * Bootstraps schema discovery for a workspace, analyzing existing * documents to suggest an initial extraction schema. * * @param attributes - Bootstrap attributes (workspace scope). * @param options - Optional request options (abort signal, custom headers). * @returns The bootstrapped schema discovery object. * * @example * ```typescript * const discovery = await admin.extraction.schemaDiscoveries.bootstrap({ * workspace_id: 'ws-uuid', * }); * ``` */ bootstrap: (attributes: AdminBootstrapSchemaDiscoveryAttributes, options?: RequestOptions) => Promise; }; /** Field mapping — document-to-schema field alignment. */ fieldMappings: { /** * Retrieves the current field mapping for a document within a workspace, * showing how extracted fields align with the schema. * * @param workspaceId - The UUID of the workspace. * @param documentId - The UUID of the document. * @param options - Optional request options (abort signal, custom headers). * @returns The field mapping result for the document. * * @example * ```typescript * const mapping = await admin.extraction.fieldMappings.get('ws-uuid', 'doc-uuid'); * console.log(mapping.mappings); * ``` */ get: (workspaceId: string, documentId: string, options?: RequestOptions) => Promise; /** * Creates or updates the field mapping for a document, confirming how * extracted fields should map to schema fields. * * @param workspaceId - The UUID of the workspace. * @param documentId - The UUID of the document. * @param attributes - The mapping attributes including confirmation and mappings. * @param options - Optional request options (abort signal, custom headers). * @returns The created or updated field mapping result. * * @example * ```typescript * const mapping = await admin.extraction.fieldMappings.create( * 'ws-uuid', * 'doc-uuid', * { * confirmed: true, * mappings: [ * { source: 'inv_num', target: 'invoice_number' }, * { source: 'amt', target: 'total_amount' }, * ], * }, * ); * ``` */ create: (workspaceId: string, documentId: string, attributes: AdminFieldMappingAttributes, options?: RequestOptions) => Promise; }; /** Shadow comparison results — primary vs shadow extractor quality metrics. */ shadowComparisons: { /** * Lists all shadow comparison records across the platform. * * @param options - Optional request options (abort signal, custom headers). * @returns An array of shadow comparison objects. * * @example * ```typescript * const comparisons = await admin.extraction.shadowComparisons.list(); * ``` */ list: (options?: RequestOptions) => Promise; /** * Retrieves a single shadow comparison by its unique identifier. * * @param id - The UUID of the shadow comparison. * @param options - Optional request options (abort signal, custom headers). * @returns The matching shadow comparison object. * * @example * ```typescript * const comparison = await admin.extraction.shadowComparisons.get('comparison-uuid'); * ``` */ get: (id: string, options?: RequestOptions) => Promise; /** * Creates a new shadow comparison record to compare the output of the * primary extractor against a shadow extractor for quality evaluation. * * @param attributes - Shadow comparison creation attributes. * @param options - Optional request options (abort signal, custom headers). * @returns The newly created shadow comparison object. * * @example * ```typescript * const comparison = await admin.extraction.shadowComparisons.create({ * document_id: 'doc-uuid', * workspace_id: 'ws-uuid', * }); * ``` */ create: (attributes: AdminCreateShadowComparisonAttributes, options?: RequestOptions) => Promise; /** * Permanently deletes a shadow comparison record. * * @param id - The UUID of the shadow comparison to delete. * @param options - Optional request options (abort signal, custom headers). * @returns `true` when the deletion succeeds. * * @example * ```typescript * await admin.extraction.shadowComparisons.delete('comparison-uuid'); * ``` */ delete: (id: string, options?: RequestOptions) => Promise; /** * Retrieves the aggregated analysis report comparing primary vs shadow * extractor performance across all shadow comparison records. * * @param options - Optional request options (abort signal, custom headers). * @returns An array of shadow comparison analysis results. * * @example * ```typescript * const analysis = await admin.extraction.shadowComparisons.analysis(); * ``` */ analysis: (options?: RequestOptions) => Promise; }; /** Content analysis results — PII detection, OCR quality, entity extraction. */ analyses: { /** * Lists all extraction analysis records across the platform, including * PII detection results and OCR quality metrics. * * @param options - Optional request options (abort signal, custom headers). * @returns An array of extraction analysis objects. * * @example * ```typescript * const analyses = await admin.extraction.analyses.list(); * ``` */ list: (options?: RequestOptions) => Promise; /** * Retrieves a single extraction analysis by its unique identifier. * * @param id - The UUID of the extraction analysis. * @param options - Optional request options (abort signal, custom headers). * @returns The matching extraction analysis object. * * @example * ```typescript * const analysis = await admin.extraction.analyses.get('analysis-uuid'); * console.log(analysis.pii_detected, analysis.ocr_confidence); * ``` */ get: (id: string, options?: RequestOptions) => Promise; }; /** Post-processing hooks — configurable hooks that execute after extraction. */ postProcessingHooks: { /** * Lists all post-processing hooks across the platform. * * @param options - Optional request options (abort signal, custom headers). * @returns An array of post-processing hook objects. * * @example * ```typescript * const hooks = await admin.extraction.postProcessingHooks.list(); * ``` */ list: (options?: RequestOptions) => Promise; /** * Retrieves a single post-processing hook by its unique identifier. * * @param id - The UUID of the hook. * @param options - Optional request options (abort signal, custom headers). * @returns The matching post-processing hook object. * * @example * ```typescript * const hook = await admin.extraction.postProcessingHooks.get('hook-uuid'); * ``` */ get: (id: string, options?: RequestOptions) => Promise; /** * Creates a new post-processing hook for the extraction pipeline. * * @param attributes - Hook creation attributes including name, trigger, and type. * @param options - Optional request options (abort signal, custom headers). * @returns The newly created post-processing hook object. * * @example * ```typescript * const hook = await admin.extraction.postProcessingHooks.create({ * name: 'Notify on extraction', * trigger: 'after_extraction', * type: 'webhook', * config: { url: 'https://example.com/hook' }, * workspace_id: 'ws-uuid', * }); * ``` */ create: (attributes: AdminCreatePostProcessingHookAttributes, options?: RequestOptions) => Promise; /** * Updates an existing post-processing hook's configuration. * * @param id - The UUID of the hook to update. * @param attributes - The attributes to update. * @param options - Optional request options (abort signal, custom headers). * @returns The updated post-processing hook object. * * @example * ```typescript * const hook = await admin.extraction.postProcessingHooks.update('hook-uuid', { * enabled: false, * }); * ``` */ update: (id: string, attributes: AdminUpdatePostProcessingHookAttributes, options?: RequestOptions) => Promise; /** * Permanently deletes a post-processing hook. * * @param id - The UUID of the hook to delete. * @param options - Optional request options (abort signal, custom headers). * @returns `true` when the deletion succeeds. * * @example * ```typescript * await admin.extraction.postProcessingHooks.delete('hook-uuid'); * ``` */ delete: (id: string, options?: RequestOptions) => Promise; }; /** Training analytics — workspace-level extraction training metrics. */ trainingAnalytics: { /** * Retrieves training analytics for a specific workspace, including * accuracy trends, correction counts, and low-confidence documents. * * @param workspaceId - The UUID of the workspace. * @param options - Optional request options (abort signal, custom headers). * @returns The training analytics object for the workspace. * * @example * ```typescript * const analytics = await admin.extraction.trainingAnalytics.forWorkspace('ws-uuid'); * console.log(analytics.avg_confidence, analytics.total_examples); * ``` */ forWorkspace: (workspaceId: string, options?: RequestOptions) => Promise; /** * Retrieves training analytics for multiple workspaces in a single * request (max 50). Pass workspace IDs as a comma-separated string. * * @param workspaceIds - Comma-separated workspace UUIDs. * @param options - Optional request options (abort signal, custom headers). * @returns An array of training analytics objects. * * @example * ```typescript * const batch = await admin.extraction.trainingAnalytics.batch('ws-1,ws-2,ws-3'); * ``` */ batch: (workspaceIds: string, options?: RequestOptions) => Promise; }; /** Extraction agents — list and predict best extraction agents for documents. */ extractionAgents: { /** * Lists all available extraction agents (system agents tagged with * "extraction" category). * * @param options - Optional request options (abort signal, custom headers). * @returns An array of extraction agent objects. * * @example * ```typescript * const agents = await admin.extraction.extractionAgents.list(); * ``` */ list: (options?: RequestOptions) => Promise; /** * Retrieves a single extraction agent by its unique identifier. * * @param id - The UUID of the extraction agent. * @param options - Optional request options (abort signal, custom headers). * @returns The matching extraction agent object. * * @example * ```typescript * const agent = await admin.extraction.extractionAgents.get('agent-uuid'); * ``` */ get: (id: string, options?: RequestOptions) => Promise; /** * Predicts the best extraction agent for a given document based on its * name, description, or file content. * * @param attributes - Prediction input attributes. * @param options - Optional request options (abort signal, custom headers). * @returns A prediction result with recommended agents. * * @example * ```typescript * const prediction = await admin.extraction.extractionAgents.predict({ * name: 'invoice.pdf', * description: 'Monthly vendor invoice', * file_content: 'Invoice #12345...', * }); * ``` */ predict: (attributes: AdminPredictExtractionAgentAttributes, options?: RequestOptions) => Promise; }; /** Chunk-entity links — bridge between document chunks and knowledge graph entities. */ chunkEntityLinks: { /** * Lists all chunk-entity links across the platform. * * @param options - Optional request options (abort signal, custom headers). * @returns An array of chunk-entity link objects. * * @example * ```typescript * const links = await admin.extraction.chunkEntityLinks.list(); * ``` */ list: (options?: RequestOptions) => Promise; /** * Retrieves a single chunk-entity link by its unique identifier. * * @param id - The UUID of the chunk-entity link. * @param options - Optional request options (abort signal, custom headers). * @returns The matching chunk-entity link object. * * @example * ```typescript * const link = await admin.extraction.chunkEntityLinks.get('link-uuid'); * ``` */ get: (id: string, options?: RequestOptions) => Promise; /** * Lists all chunk-entity links for a specific document. * * @param documentId - The UUID of the document. * @param options - Optional request options (abort signal, custom headers). * @returns An array of chunk-entity links for the document. * * @example * ```typescript * const links = await admin.extraction.chunkEntityLinks.byDocument('doc-uuid'); * ``` */ byDocument: (documentId: string, options?: RequestOptions) => Promise; /** * Lists all chunk-entity links for a specific document chunk. * * @param documentChunkId - The UUID of the document chunk. * @param options - Optional request options (abort signal, custom headers). * @returns An array of chunk-entity links for the chunk. * * @example * ```typescript * const links = await admin.extraction.chunkEntityLinks.byChunk('chunk-uuid'); * ``` */ byChunk: (documentChunkId: string, options?: RequestOptions) => Promise; /** * Lists all chunk-entity links for a specific knowledge graph entity. * * @param graphNodeId - The UUID of the graph node (entity). * @param options - Optional request options (abort signal, custom headers). * @returns An array of chunk-entity links for the entity. * * @example * ```typescript * const links = await admin.extraction.chunkEntityLinks.byEntity('node-uuid'); * ``` */ byEntity: (graphNodeId: string, options?: RequestOptions) => Promise; }; }; //# sourceMappingURL=extraction.d.ts.map