UNPKG

@nutrient-sdk/dws-client-typescript

Version:

Node.js TypeScript client library for Nutrient Document Web Services (DWS) API

154 lines 5.37 kB
import type { FileInput, OutputTypeMap, TypedWorkflowResult, UrlInput, WorkflowDryRunResult, WorkflowExecuteOptions } from '../types'; import type { ActionWithFileInput } from '../build'; import { BaseBuilder } from './base'; import type { components } from '../generated/api-types'; /** * Actions that can be applied to workflows - either regular actions or actions that need file registration */ export type ApplicableAction = components['schemas']['BuildAction'] | ActionWithFileInput; /** * Workflow builder implementation using the composable Build API */ export declare class WorkflowBuilder<TOutput extends keyof OutputTypeMap | undefined = undefined> extends BaseBuilder<TypedWorkflowResult<TOutput>> { private buildInstructions; private assets; private assetIndex; private currentStep; private isExecuted; /** * Registers an asset in the workflow and returns its key for use in actions * @param asset - The asset to register * @returns The asset key that can be used in BuildActions */ private registerAssets; /** * Adds a file part to the workflow */ addFilePart(file: FileInput, options?: Omit<components['schemas']['FilePart'], 'file' | 'actions'>, actions?: ApplicableAction[]): this; /** * Adds an HTML part to the workflow */ addHtmlPart(html: FileInput, assets?: Exclude<FileInput, UrlInput>[], options?: Omit<components['schemas']['HTMLPart'], 'html' | 'actions'>, actions?: ApplicableAction[]): this; /** * Adds a new page part to the workflow */ addNewPage(options?: Omit<components['schemas']['NewPagePart'], 'page' | 'actions'>, actions?: ApplicableAction[]): this; /** * Adds a document part by document ID */ addDocumentPart(documentId: string, options?: Omit<components['schemas']['DocumentPart'], 'document' | 'actions'> & { layer?: string; }, actions?: ApplicableAction[]): this; /** * Processes an action, registering files if needed */ private processAction; /** * Type guard to check if action needs file registration */ private isActionWithFileInput; /** * Applies actions to the entire document */ applyActions(actions: ApplicableAction[]): this; /** * Applies a single action to the entire document */ applyAction(action: ApplicableAction): this; /** * Sets the output configuration */ private output; /** * Sets PDF output */ outputPdf(options?: { metadata?: components['schemas']['Metadata']; labels?: components['schemas']['Label'][]; userPassword?: string; ownerPassword?: string; userPermissions?: components['schemas']['PDFUserPermission'][]; optimize?: components['schemas']['OptimizePdf']; }): WorkflowBuilder<'pdf'>; /** * Sets PDF/A output */ outputPdfA(options?: { conformance?: components['schemas']['PDFAOutput']['conformance']; vectorization?: boolean; rasterization?: boolean; metadata?: components['schemas']['Metadata']; labels?: components['schemas']['Label'][]; userPassword?: string; ownerPassword?: string; userPermissions?: components['schemas']['PDFUserPermission'][]; optimize?: components['schemas']['OptimizePdf']; }): WorkflowBuilder<'pdfa'>; /** * Sets PDF/UA output */ outputPdfUa(options?: { metadata?: components['schemas']['Metadata']; labels?: components['schemas']['Label'][]; userPassword?: string; ownerPassword?: string; userPermissions?: components['schemas']['PDFUserPermission'][]; optimize?: components['schemas']['OptimizePdf']; }): WorkflowBuilder<'pdfua'>; /** * Sets image output */ outputImage<T extends 'png' | 'jpeg' | 'jpg' | 'webp'>(format: T, options?: { pages?: components['schemas']['PageRange']; width?: number; height?: number; dpi?: number; }): WorkflowBuilder<T>; /** * Sets Office format output */ outputOffice<T extends 'docx' | 'xlsx' | 'pptx'>(format: T): WorkflowBuilder<T>; /** * Sets HTML output */ outputHtml(layout: 'page' | 'reflow'): WorkflowBuilder<'html'>; /** * Set Markdown output */ outputMarkdown(): WorkflowBuilder<'markdown'>; /** * Sets JSON content extraction output */ outputJson(options?: { plainText?: boolean; structuredText?: boolean; keyValuePairs?: boolean; tables?: boolean; language?: components['schemas']['OcrLanguage'] | components['schemas']['OcrLanguage'][]; }): WorkflowBuilder<'json-content'>; /** * Validates the workflow before execution */ private validate; /** * Ensures the workflow hasn't been executed */ private ensureNotExecuted; /** * Prepares files for the request */ private prepareFiles; /** * Cleans up resources after execution */ private cleanup; /** * Executes the workflow */ execute(options?: WorkflowExecuteOptions): Promise<TypedWorkflowResult<TOutput>>; /** * Performs a dry run to analyze the workflow */ dryRun(): Promise<WorkflowDryRunResult>; } //# sourceMappingURL=workflow.d.ts.map