convertit 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +85 -0
- package/README.md +503 -0
- package/dist/converters/base.d.ts +27 -0
- package/dist/converters/base.d.ts.map +1 -0
- package/dist/converters/csv.d.ts +67 -0
- package/dist/converters/csv.d.ts.map +1 -0
- package/dist/converters/excel-styles.d.ts +51 -0
- package/dist/converters/excel-styles.d.ts.map +1 -0
- package/dist/converters/excel.d.ts +40 -0
- package/dist/converters/excel.d.ts.map +1 -0
- package/dist/converters/html.d.ts +21 -0
- package/dist/converters/html.d.ts.map +1 -0
- package/dist/converters/image.d.ts +80 -0
- package/dist/converters/image.d.ts.map +1 -0
- package/dist/converters/index.d.ts +10 -0
- package/dist/converters/index.d.ts.map +1 -0
- package/dist/converters/pdf.d.ts +68 -0
- package/dist/converters/pdf.d.ts.map +1 -0
- package/dist/converters/text.d.ts +36 -0
- package/dist/converters/text.d.ts.map +1 -0
- package/dist/converters/word.d.ts +24 -0
- package/dist/converters/word.d.ts.map +1 -0
- package/dist/core/converter.d.ts +65 -0
- package/dist/core/converter.d.ts.map +1 -0
- package/dist/core/errors.d.ts +64 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/index.d.ts +8 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/template-engine.d.ts +57 -0
- package/dist/core/template-engine.d.ts.map +1 -0
- package/dist/core/types.d.ts +702 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +270420 -0
- package/dist/transformers/index.d.ts +61 -0
- package/dist/transformers/index.d.ts.map +1 -0
- package/dist/utils/helpers.d.ts +55 -0
- package/dist/utils/helpers.d.ts.map +1 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/validator.d.ts +26 -0
- package/dist/utils/validator.d.ts.map +1 -0
- package/package.json +129 -0
|
@@ -0,0 +1,702 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for file conversion operations.
|
|
3
|
+
*/
|
|
4
|
+
export type FileFormat = 'pdf' | 'word' | 'docx' | 'excel' | 'xlsx' | 'csv' | 'html' | 'txt' | 'json' | 'xml' | 'markdown' | 'md' | 'png' | 'jpg' | 'jpeg' | 'webp' | 'svg' | 'gif' | 'bmp' | 'tiff';
|
|
5
|
+
export type InputDataType = string | Buffer | ArrayBuffer | Uint8Array | ReadableStream | object | object[];
|
|
6
|
+
export type OutputFormat = 'buffer' | 'base64' | 'stream' | 'file' | 'blob';
|
|
7
|
+
export interface PageSize {
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
}
|
|
11
|
+
export interface PageMargins {
|
|
12
|
+
top: number;
|
|
13
|
+
right: number;
|
|
14
|
+
bottom: number;
|
|
15
|
+
left: number;
|
|
16
|
+
}
|
|
17
|
+
export interface FontConfig {
|
|
18
|
+
family: string;
|
|
19
|
+
size: number;
|
|
20
|
+
color?: string;
|
|
21
|
+
bold?: boolean;
|
|
22
|
+
italic?: boolean;
|
|
23
|
+
underline?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface HeaderFooterConfig {
|
|
26
|
+
enabled: boolean;
|
|
27
|
+
content?: string;
|
|
28
|
+
font?: Partial<FontConfig>;
|
|
29
|
+
alignment?: 'left' | 'center' | 'right';
|
|
30
|
+
includePageNumber?: boolean;
|
|
31
|
+
pageNumberFormat?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface WatermarkConfig {
|
|
34
|
+
text?: string;
|
|
35
|
+
image?: string | Buffer;
|
|
36
|
+
opacity?: number;
|
|
37
|
+
rotation?: number;
|
|
38
|
+
position?: 'center' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'tile';
|
|
39
|
+
font?: Partial<FontConfig>;
|
|
40
|
+
scale?: number;
|
|
41
|
+
}
|
|
42
|
+
export interface EncryptionConfig {
|
|
43
|
+
password: string;
|
|
44
|
+
ownerPassword?: string;
|
|
45
|
+
permissions?: {
|
|
46
|
+
printing?: boolean;
|
|
47
|
+
modifying?: boolean;
|
|
48
|
+
copying?: boolean;
|
|
49
|
+
annotating?: boolean;
|
|
50
|
+
fillingForms?: boolean;
|
|
51
|
+
contentAccessibility?: boolean;
|
|
52
|
+
documentAssembly?: boolean;
|
|
53
|
+
};
|
|
54
|
+
encryptionMethod?: '40bit' | '128bit' | '256bit';
|
|
55
|
+
}
|
|
56
|
+
export interface CompressionConfig {
|
|
57
|
+
level?: 'low' | 'medium' | 'high' | 'maximum';
|
|
58
|
+
quality?: number;
|
|
59
|
+
removeMetadata?: boolean;
|
|
60
|
+
optimizeImages?: boolean;
|
|
61
|
+
imageQuality?: number;
|
|
62
|
+
grayscale?: boolean;
|
|
63
|
+
}
|
|
64
|
+
export interface MergeConfig {
|
|
65
|
+
files: Array<string | Buffer>;
|
|
66
|
+
outputFormat?: FileFormat;
|
|
67
|
+
addPageBreaks?: boolean;
|
|
68
|
+
addTableOfContents?: boolean;
|
|
69
|
+
bookmarks?: boolean;
|
|
70
|
+
}
|
|
71
|
+
export interface SplitConfig {
|
|
72
|
+
mode: 'pages' | 'ranges' | 'size' | 'bookmarks';
|
|
73
|
+
pages?: number[];
|
|
74
|
+
ranges?: Array<{
|
|
75
|
+
start: number;
|
|
76
|
+
end: number;
|
|
77
|
+
}>;
|
|
78
|
+
maxSize?: number;
|
|
79
|
+
outputPrefix?: string;
|
|
80
|
+
}
|
|
81
|
+
export interface RotateConfig {
|
|
82
|
+
angle: 90 | 180 | 270;
|
|
83
|
+
pages?: number[] | 'all' | 'odd' | 'even';
|
|
84
|
+
}
|
|
85
|
+
export interface PageNumberConfig {
|
|
86
|
+
enabled: boolean;
|
|
87
|
+
format?: string;
|
|
88
|
+
position?: 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
|
|
89
|
+
startFrom?: number;
|
|
90
|
+
font?: Partial<FontConfig>;
|
|
91
|
+
skipPages?: number[];
|
|
92
|
+
}
|
|
93
|
+
export interface ImageConversionConfig {
|
|
94
|
+
format?: 'png' | 'jpg' | 'webp' | 'gif' | 'bmp' | 'tiff';
|
|
95
|
+
quality?: number;
|
|
96
|
+
dpi?: number;
|
|
97
|
+
width?: number;
|
|
98
|
+
height?: number;
|
|
99
|
+
fit?: 'contain' | 'cover' | 'fill' | 'inside' | 'outside';
|
|
100
|
+
background?: string;
|
|
101
|
+
pages?: number[] | 'all';
|
|
102
|
+
}
|
|
103
|
+
export interface OCRConfig {
|
|
104
|
+
enabled: boolean;
|
|
105
|
+
language?: string | string[];
|
|
106
|
+
enhanceScans?: boolean;
|
|
107
|
+
outputFormat?: 'text' | 'searchable-pdf' | 'hocr';
|
|
108
|
+
}
|
|
109
|
+
export interface TableConfig {
|
|
110
|
+
headers?: string[];
|
|
111
|
+
data: any[][];
|
|
112
|
+
style?: {
|
|
113
|
+
headerBackground?: string;
|
|
114
|
+
headerColor?: string;
|
|
115
|
+
alternateRowColors?: boolean;
|
|
116
|
+
borderColor?: string;
|
|
117
|
+
borderWidth?: number;
|
|
118
|
+
};
|
|
119
|
+
columnWidths?: number[];
|
|
120
|
+
autoFit?: boolean;
|
|
121
|
+
}
|
|
122
|
+
export interface PDFOptions {
|
|
123
|
+
pageSize?: 'A4' | 'A3' | 'A5' | 'Letter' | 'Legal' | 'Tabloid' | PageSize;
|
|
124
|
+
orientation?: 'portrait' | 'landscape';
|
|
125
|
+
margins?: Partial<PageMargins>;
|
|
126
|
+
font?: Partial<FontConfig>;
|
|
127
|
+
header?: HeaderFooterConfig;
|
|
128
|
+
footer?: HeaderFooterConfig;
|
|
129
|
+
watermark?: WatermarkConfig;
|
|
130
|
+
encryption?: EncryptionConfig;
|
|
131
|
+
compression?: CompressionConfig;
|
|
132
|
+
pageNumbers?: PageNumberConfig;
|
|
133
|
+
metadata?: {
|
|
134
|
+
title?: string;
|
|
135
|
+
author?: string;
|
|
136
|
+
subject?: string;
|
|
137
|
+
keywords?: string[];
|
|
138
|
+
creator?: string;
|
|
139
|
+
producer?: string;
|
|
140
|
+
creationDate?: Date;
|
|
141
|
+
modificationDate?: Date;
|
|
142
|
+
};
|
|
143
|
+
accessibilityTags?: boolean;
|
|
144
|
+
embedFonts?: boolean;
|
|
145
|
+
}
|
|
146
|
+
export interface WordOptions {
|
|
147
|
+
pageSize?: 'A4' | 'A3' | 'A5' | 'Letter' | 'Legal' | PageSize;
|
|
148
|
+
orientation?: 'portrait' | 'landscape';
|
|
149
|
+
margins?: Partial<PageMargins>;
|
|
150
|
+
font?: Partial<FontConfig>;
|
|
151
|
+
header?: HeaderFooterConfig;
|
|
152
|
+
footer?: HeaderFooterConfig;
|
|
153
|
+
watermark?: WatermarkConfig;
|
|
154
|
+
styles?: {
|
|
155
|
+
title?: Partial<FontConfig>;
|
|
156
|
+
heading1?: Partial<FontConfig>;
|
|
157
|
+
heading2?: Partial<FontConfig>;
|
|
158
|
+
heading3?: Partial<FontConfig>;
|
|
159
|
+
paragraph?: Partial<FontConfig>;
|
|
160
|
+
};
|
|
161
|
+
tableOfContents?: boolean;
|
|
162
|
+
pageNumbers?: PageNumberConfig;
|
|
163
|
+
metadata?: {
|
|
164
|
+
title?: string;
|
|
165
|
+
author?: string;
|
|
166
|
+
description?: string;
|
|
167
|
+
subject?: string;
|
|
168
|
+
keywords?: string[];
|
|
169
|
+
category?: string;
|
|
170
|
+
company?: string;
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
export interface ExcelOptions {
|
|
174
|
+
sheetName?: string;
|
|
175
|
+
sheets?: Array<{
|
|
176
|
+
name: string;
|
|
177
|
+
data: any[][];
|
|
178
|
+
headers?: string[];
|
|
179
|
+
}>;
|
|
180
|
+
headers?: string[];
|
|
181
|
+
columnWidths?: number[];
|
|
182
|
+
autoFilter?: boolean;
|
|
183
|
+
freezePane?: {
|
|
184
|
+
row?: number;
|
|
185
|
+
column?: number;
|
|
186
|
+
};
|
|
187
|
+
style?: {
|
|
188
|
+
headerStyle?: {
|
|
189
|
+
font?: Partial<FontConfig>;
|
|
190
|
+
fill?: string;
|
|
191
|
+
alignment?: 'left' | 'center' | 'right';
|
|
192
|
+
};
|
|
193
|
+
dataStyle?: {
|
|
194
|
+
font?: Partial<FontConfig>;
|
|
195
|
+
alternateRowFill?: string;
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* Conditional formatting rules for dynamic row/cell styling
|
|
200
|
+
* Allows styling based on cell values, row position, or custom logic
|
|
201
|
+
*/
|
|
202
|
+
conditionalFormatting?: ConditionalFormattingRule[];
|
|
203
|
+
/**
|
|
204
|
+
* Row styling rules - apply styles based on row conditions
|
|
205
|
+
*/
|
|
206
|
+
rowStyles?: RowStyleRule[];
|
|
207
|
+
/**
|
|
208
|
+
* Cell styling rules - apply styles to specific cells
|
|
209
|
+
*/
|
|
210
|
+
cellStyles?: CellStyleRule[];
|
|
211
|
+
formulas?: Array<{
|
|
212
|
+
cell: string;
|
|
213
|
+
formula: string;
|
|
214
|
+
}>;
|
|
215
|
+
protection?: {
|
|
216
|
+
password?: string;
|
|
217
|
+
lockCells?: boolean;
|
|
218
|
+
lockFormulas?: boolean;
|
|
219
|
+
};
|
|
220
|
+
metadata?: {
|
|
221
|
+
title?: string;
|
|
222
|
+
author?: string;
|
|
223
|
+
company?: string;
|
|
224
|
+
description?: string;
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
export interface ConditionalFormattingRule {
|
|
228
|
+
type: 'cellValue' | 'expression' | 'colorScale' | 'dataBar' | 'iconSet';
|
|
229
|
+
priority?: number;
|
|
230
|
+
range?: string;
|
|
231
|
+
condition?: {
|
|
232
|
+
operator?: 'equal' | 'notEqual' | 'greaterThan' | 'lessThan' | 'greaterThanOrEqual' | 'lessThanOrEqual' | 'between' | 'notBetween' | 'containsText' | 'notContainsText' | 'beginsWith' | 'endsWith';
|
|
233
|
+
value?: string | number;
|
|
234
|
+
value2?: string | number;
|
|
235
|
+
formula?: string;
|
|
236
|
+
};
|
|
237
|
+
style: CellStyle;
|
|
238
|
+
}
|
|
239
|
+
export interface RowStyleRule {
|
|
240
|
+
condition: {
|
|
241
|
+
type: 'even';
|
|
242
|
+
} | {
|
|
243
|
+
type: 'odd';
|
|
244
|
+
} | {
|
|
245
|
+
type: 'every';
|
|
246
|
+
n: number;
|
|
247
|
+
offset?: number;
|
|
248
|
+
} | {
|
|
249
|
+
type: 'range';
|
|
250
|
+
start: number;
|
|
251
|
+
end: number;
|
|
252
|
+
} | {
|
|
253
|
+
type: 'custom';
|
|
254
|
+
predicate: (rowData: any[], rowIndex: number) => boolean;
|
|
255
|
+
} | {
|
|
256
|
+
type: 'columnValue';
|
|
257
|
+
column: string | number;
|
|
258
|
+
operator: ComparisonOperator;
|
|
259
|
+
value: any;
|
|
260
|
+
};
|
|
261
|
+
style: CellStyle;
|
|
262
|
+
}
|
|
263
|
+
export interface CellStyleRule {
|
|
264
|
+
target: string;
|
|
265
|
+
condition?: {
|
|
266
|
+
operator: ComparisonOperator;
|
|
267
|
+
value: any;
|
|
268
|
+
};
|
|
269
|
+
style: CellStyle;
|
|
270
|
+
}
|
|
271
|
+
export interface CellStyle {
|
|
272
|
+
font?: {
|
|
273
|
+
name?: string;
|
|
274
|
+
size?: number;
|
|
275
|
+
bold?: boolean;
|
|
276
|
+
italic?: boolean;
|
|
277
|
+
underline?: boolean;
|
|
278
|
+
strike?: boolean;
|
|
279
|
+
color?: string;
|
|
280
|
+
};
|
|
281
|
+
fill?: {
|
|
282
|
+
type?: 'solid' | 'pattern' | 'gradient';
|
|
283
|
+
color?: string;
|
|
284
|
+
fgColor?: string;
|
|
285
|
+
bgColor?: string;
|
|
286
|
+
pattern?: 'solid' | 'darkGray' | 'mediumGray' | 'lightGray' | 'gray125' | 'gray0625';
|
|
287
|
+
gradient?: {
|
|
288
|
+
type: 'linear' | 'path';
|
|
289
|
+
degree?: number;
|
|
290
|
+
stops: Array<{
|
|
291
|
+
position: number;
|
|
292
|
+
color: string;
|
|
293
|
+
}>;
|
|
294
|
+
};
|
|
295
|
+
};
|
|
296
|
+
border?: {
|
|
297
|
+
top?: BorderStyle;
|
|
298
|
+
bottom?: BorderStyle;
|
|
299
|
+
left?: BorderStyle;
|
|
300
|
+
right?: BorderStyle;
|
|
301
|
+
diagonal?: BorderStyle;
|
|
302
|
+
};
|
|
303
|
+
alignment?: {
|
|
304
|
+
horizontal?: 'left' | 'center' | 'right' | 'fill' | 'justify' | 'centerContinuous' | 'distributed';
|
|
305
|
+
vertical?: 'top' | 'middle' | 'bottom' | 'distributed' | 'justify';
|
|
306
|
+
wrapText?: boolean;
|
|
307
|
+
shrinkToFit?: boolean;
|
|
308
|
+
indent?: number;
|
|
309
|
+
textRotation?: number;
|
|
310
|
+
};
|
|
311
|
+
numFmt?: string;
|
|
312
|
+
}
|
|
313
|
+
export interface BorderStyle {
|
|
314
|
+
style?: 'thin' | 'medium' | 'thick' | 'dotted' | 'dashed' | 'double' | 'hair' | 'mediumDashed' | 'dashDot' | 'mediumDashDot' | 'dashDotDot' | 'slantDashDot';
|
|
315
|
+
color?: string;
|
|
316
|
+
}
|
|
317
|
+
export type ComparisonOperator = 'equal' | 'notEqual' | 'greaterThan' | 'lessThan' | 'greaterThanOrEqual' | 'lessThanOrEqual' | 'contains' | 'notContains' | 'startsWith' | 'endsWith' | 'isEmpty' | 'isNotEmpty';
|
|
318
|
+
export interface CSVOptions {
|
|
319
|
+
delimiter?: ',' | ';' | '\t' | '|' | string;
|
|
320
|
+
quote?: string;
|
|
321
|
+
escape?: string;
|
|
322
|
+
headers?: boolean | string[];
|
|
323
|
+
encoding?: BufferEncoding;
|
|
324
|
+
newline?: '\n' | '\r\n';
|
|
325
|
+
skipEmptyLines?: boolean;
|
|
326
|
+
trimFields?: boolean;
|
|
327
|
+
}
|
|
328
|
+
export interface HTMLOptions {
|
|
329
|
+
template?: string;
|
|
330
|
+
css?: string;
|
|
331
|
+
inlineStyles?: boolean;
|
|
332
|
+
includeDoctype?: boolean;
|
|
333
|
+
encoding?: BufferEncoding;
|
|
334
|
+
title?: string;
|
|
335
|
+
meta?: Record<string, string>;
|
|
336
|
+
scripts?: string[];
|
|
337
|
+
stylesheets?: string[];
|
|
338
|
+
minify?: boolean;
|
|
339
|
+
responsive?: boolean;
|
|
340
|
+
}
|
|
341
|
+
export interface ImageOptions {
|
|
342
|
+
format?: 'png' | 'jpg' | 'jpeg' | 'webp' | 'gif' | 'bmp' | 'tiff' | 'svg';
|
|
343
|
+
quality?: number;
|
|
344
|
+
width?: number;
|
|
345
|
+
height?: number;
|
|
346
|
+
dpi?: number;
|
|
347
|
+
fit?: 'contain' | 'cover' | 'fill' | 'inside' | 'outside';
|
|
348
|
+
background?: string;
|
|
349
|
+
transparent?: boolean;
|
|
350
|
+
compression?: 'none' | 'lzw' | 'jpeg' | 'deflate';
|
|
351
|
+
progressive?: boolean;
|
|
352
|
+
grayscale?: boolean;
|
|
353
|
+
rotate?: number;
|
|
354
|
+
flip?: 'horizontal' | 'vertical' | 'both';
|
|
355
|
+
blur?: number;
|
|
356
|
+
sharpen?: boolean;
|
|
357
|
+
brightness?: number;
|
|
358
|
+
contrast?: number;
|
|
359
|
+
saturation?: number;
|
|
360
|
+
}
|
|
361
|
+
export interface ConvertFileOptions {
|
|
362
|
+
type: FileFormat;
|
|
363
|
+
output?: OutputFormat;
|
|
364
|
+
outputPath?: string;
|
|
365
|
+
pdf?: PDFOptions;
|
|
366
|
+
word?: WordOptions;
|
|
367
|
+
excel?: ExcelOptions;
|
|
368
|
+
csv?: CSVOptions;
|
|
369
|
+
html?: HTMLOptions;
|
|
370
|
+
image?: ImageOptions;
|
|
371
|
+
merge?: MergeConfig;
|
|
372
|
+
split?: SplitConfig;
|
|
373
|
+
compress?: CompressionConfig;
|
|
374
|
+
watermark?: WatermarkConfig;
|
|
375
|
+
encrypt?: EncryptionConfig;
|
|
376
|
+
rotate?: RotateConfig;
|
|
377
|
+
ocr?: OCRConfig;
|
|
378
|
+
tables?: TableConfig[];
|
|
379
|
+
customStyles?: Record<string, any>;
|
|
380
|
+
hooks?: {
|
|
381
|
+
beforeConvert?: (data: InputDataType) => InputDataType | Promise<InputDataType>;
|
|
382
|
+
afterConvert?: (result: ConversionResult) => ConversionResult | Promise<ConversionResult>;
|
|
383
|
+
onProgress?: (progress: ProgressInfo) => void;
|
|
384
|
+
onError?: (error: Error) => void;
|
|
385
|
+
};
|
|
386
|
+
timeout?: number;
|
|
387
|
+
retries?: number;
|
|
388
|
+
cache?: boolean;
|
|
389
|
+
tempDir?: string;
|
|
390
|
+
verbose?: boolean;
|
|
391
|
+
}
|
|
392
|
+
export interface ConversionResult {
|
|
393
|
+
success: boolean;
|
|
394
|
+
data: Buffer | string | ReadableStream | null;
|
|
395
|
+
format: FileFormat;
|
|
396
|
+
size: number;
|
|
397
|
+
filename?: string;
|
|
398
|
+
path?: string;
|
|
399
|
+
mimeType: string;
|
|
400
|
+
metadata?: Record<string, any>;
|
|
401
|
+
pages?: number;
|
|
402
|
+
duration: number;
|
|
403
|
+
warnings?: string[];
|
|
404
|
+
}
|
|
405
|
+
export interface BatchConversionResult {
|
|
406
|
+
success: boolean;
|
|
407
|
+
results: ConversionResult[];
|
|
408
|
+
totalFiles: number;
|
|
409
|
+
successCount: number;
|
|
410
|
+
failedCount: number;
|
|
411
|
+
totalDuration: number;
|
|
412
|
+
errors?: ConversionError[];
|
|
413
|
+
}
|
|
414
|
+
export interface ProgressInfo {
|
|
415
|
+
stage: 'preparing' | 'converting' | 'processing' | 'finalizing';
|
|
416
|
+
progress: number;
|
|
417
|
+
currentFile?: string;
|
|
418
|
+
totalFiles?: number;
|
|
419
|
+
currentFileIndex?: number;
|
|
420
|
+
message?: string;
|
|
421
|
+
}
|
|
422
|
+
export interface ConversionError {
|
|
423
|
+
code: string;
|
|
424
|
+
message: string;
|
|
425
|
+
details?: any;
|
|
426
|
+
file?: string;
|
|
427
|
+
recoverable: boolean;
|
|
428
|
+
}
|
|
429
|
+
export interface ConvertFileBuilder {
|
|
430
|
+
toPdf(options?: PDFOptions): ConvertFileBuilder;
|
|
431
|
+
toWord(options?: WordOptions): ConvertFileBuilder;
|
|
432
|
+
toExcel(options?: ExcelOptions): ConvertFileBuilder;
|
|
433
|
+
toCsv(options?: CSVOptions): ConvertFileBuilder;
|
|
434
|
+
toHtml(options?: HTMLOptions): ConvertFileBuilder;
|
|
435
|
+
toImage(options?: ImageOptions): ConvertFileBuilder;
|
|
436
|
+
withWatermark(config: WatermarkConfig): ConvertFileBuilder;
|
|
437
|
+
withEncryption(config: EncryptionConfig): ConvertFileBuilder;
|
|
438
|
+
withCompression(config: CompressionConfig): ConvertFileBuilder;
|
|
439
|
+
withPageNumbers(config: PageNumberConfig): ConvertFileBuilder;
|
|
440
|
+
withHeader(config: HeaderFooterConfig): ConvertFileBuilder;
|
|
441
|
+
withFooter(config: HeaderFooterConfig): ConvertFileBuilder;
|
|
442
|
+
merge(files: Array<string | Buffer>): ConvertFileBuilder;
|
|
443
|
+
split(config: SplitConfig): ConvertFileBuilder;
|
|
444
|
+
rotate(config: RotateConfig): ConvertFileBuilder;
|
|
445
|
+
addTable(config: TableConfig): ConvertFileBuilder;
|
|
446
|
+
onProgress(callback: (progress: ProgressInfo) => void): ConvertFileBuilder;
|
|
447
|
+
toBuffer(): Promise<Buffer>;
|
|
448
|
+
toBase64(): Promise<string>;
|
|
449
|
+
toFile(path: string): Promise<string>;
|
|
450
|
+
toStream(): Promise<ReadableStream>;
|
|
451
|
+
execute(): Promise<ConversionResult>;
|
|
452
|
+
}
|
|
453
|
+
export interface ConverterPlugin {
|
|
454
|
+
name: string;
|
|
455
|
+
version: string;
|
|
456
|
+
supportedFormats: FileFormat[];
|
|
457
|
+
convert(data: InputDataType, options: ConvertFileOptions): Promise<ConversionResult>;
|
|
458
|
+
validate?(data: InputDataType, options: ConvertFileOptions): boolean;
|
|
459
|
+
}
|
|
460
|
+
export interface TransformerPlugin {
|
|
461
|
+
name: string;
|
|
462
|
+
version: string;
|
|
463
|
+
transform(result: ConversionResult, options: any): Promise<ConversionResult>;
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Template configuration for document generation
|
|
467
|
+
*/
|
|
468
|
+
export interface TemplateConfig {
|
|
469
|
+
/** Template string or file path */
|
|
470
|
+
source: string;
|
|
471
|
+
/** Template engine to use */
|
|
472
|
+
engine?: 'handlebars' | 'mustache' | 'ejs' | 'simple';
|
|
473
|
+
/** Data to inject into template */
|
|
474
|
+
data: Record<string, any>;
|
|
475
|
+
/** Partials/components */
|
|
476
|
+
partials?: Record<string, string>;
|
|
477
|
+
/** Helper functions */
|
|
478
|
+
helpers?: Record<string, (...args: any[]) => any>;
|
|
479
|
+
/** Custom delimiters */
|
|
480
|
+
delimiters?: [string, string];
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Streaming configuration for large files
|
|
484
|
+
*/
|
|
485
|
+
export interface StreamConfig {
|
|
486
|
+
/** Enable streaming mode */
|
|
487
|
+
enabled: boolean;
|
|
488
|
+
/** Chunk size in bytes */
|
|
489
|
+
chunkSize?: number;
|
|
490
|
+
/** High water mark for backpressure */
|
|
491
|
+
highWaterMark?: number;
|
|
492
|
+
/** Callback for each chunk */
|
|
493
|
+
onChunk?: (chunk: Buffer, index: number) => void;
|
|
494
|
+
/** Enable compression during streaming */
|
|
495
|
+
compress?: boolean;
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Report generation configuration
|
|
499
|
+
*/
|
|
500
|
+
export interface ReportConfig {
|
|
501
|
+
/** Report title */
|
|
502
|
+
title: string;
|
|
503
|
+
/** Report subtitle */
|
|
504
|
+
subtitle?: string;
|
|
505
|
+
/** Company/organization logo */
|
|
506
|
+
logo?: string | Buffer;
|
|
507
|
+
/** Report sections */
|
|
508
|
+
sections: ReportSection[];
|
|
509
|
+
/** Header configuration */
|
|
510
|
+
header?: {
|
|
511
|
+
content?: string;
|
|
512
|
+
logo?: string | Buffer;
|
|
513
|
+
showDate?: boolean;
|
|
514
|
+
showPageNumber?: boolean;
|
|
515
|
+
};
|
|
516
|
+
/** Footer configuration */
|
|
517
|
+
footer?: {
|
|
518
|
+
content?: string;
|
|
519
|
+
showPageNumber?: boolean;
|
|
520
|
+
showTotalPages?: boolean;
|
|
521
|
+
};
|
|
522
|
+
/** Table of contents */
|
|
523
|
+
tableOfContents?: boolean;
|
|
524
|
+
/** Theme configuration */
|
|
525
|
+
theme?: ReportTheme;
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Report section configuration
|
|
529
|
+
*/
|
|
530
|
+
export interface ReportSection {
|
|
531
|
+
/** Section type */
|
|
532
|
+
type: 'heading' | 'paragraph' | 'table' | 'chart' | 'image' | 'list' | 'pageBreak' | 'spacer';
|
|
533
|
+
/** Section content */
|
|
534
|
+
content?: string | any[] | Record<string, any>;
|
|
535
|
+
/** Section level (for headings) */
|
|
536
|
+
level?: 1 | 2 | 3 | 4 | 5 | 6;
|
|
537
|
+
/** Section style overrides */
|
|
538
|
+
style?: Partial<CellStyle>;
|
|
539
|
+
/** Chart configuration (for chart type) */
|
|
540
|
+
chart?: ChartConfig;
|
|
541
|
+
/** Image configuration (for image type) */
|
|
542
|
+
image?: {
|
|
543
|
+
src: string | Buffer;
|
|
544
|
+
width?: number;
|
|
545
|
+
height?: number;
|
|
546
|
+
alignment?: 'left' | 'center' | 'right';
|
|
547
|
+
caption?: string;
|
|
548
|
+
};
|
|
549
|
+
/** List configuration */
|
|
550
|
+
list?: {
|
|
551
|
+
type: 'bullet' | 'number' | 'check';
|
|
552
|
+
items: string[];
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* Chart configuration for reports
|
|
557
|
+
*/
|
|
558
|
+
export interface ChartConfig {
|
|
559
|
+
type: 'bar' | 'line' | 'pie' | 'doughnut' | 'area' | 'scatter';
|
|
560
|
+
data: {
|
|
561
|
+
labels: string[];
|
|
562
|
+
datasets: Array<{
|
|
563
|
+
label: string;
|
|
564
|
+
data: number[];
|
|
565
|
+
backgroundColor?: string | string[];
|
|
566
|
+
borderColor?: string | string[];
|
|
567
|
+
}>;
|
|
568
|
+
};
|
|
569
|
+
options?: {
|
|
570
|
+
title?: string;
|
|
571
|
+
width?: number;
|
|
572
|
+
height?: number;
|
|
573
|
+
legend?: boolean;
|
|
574
|
+
responsive?: boolean;
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
/**
|
|
578
|
+
* Report theme configuration
|
|
579
|
+
*/
|
|
580
|
+
export interface ReportTheme {
|
|
581
|
+
primaryColor?: string;
|
|
582
|
+
secondaryColor?: string;
|
|
583
|
+
accentColor?: string;
|
|
584
|
+
backgroundColor?: string;
|
|
585
|
+
textColor?: string;
|
|
586
|
+
fontFamily?: string;
|
|
587
|
+
fontSize?: number;
|
|
588
|
+
headingFont?: string;
|
|
589
|
+
spacing?: 'compact' | 'normal' | 'relaxed';
|
|
590
|
+
}
|
|
591
|
+
/**
|
|
592
|
+
* Invoice/Receipt generation configuration
|
|
593
|
+
*/
|
|
594
|
+
export interface InvoiceConfig {
|
|
595
|
+
/** Invoice number */
|
|
596
|
+
invoiceNumber: string;
|
|
597
|
+
/** Invoice date */
|
|
598
|
+
date: Date | string;
|
|
599
|
+
/** Due date */
|
|
600
|
+
dueDate?: Date | string;
|
|
601
|
+
/** Currency */
|
|
602
|
+
currency?: string;
|
|
603
|
+
/** Company details */
|
|
604
|
+
company: {
|
|
605
|
+
name: string;
|
|
606
|
+
address?: string[];
|
|
607
|
+
phone?: string;
|
|
608
|
+
email?: string;
|
|
609
|
+
website?: string;
|
|
610
|
+
logo?: string | Buffer;
|
|
611
|
+
taxId?: string;
|
|
612
|
+
};
|
|
613
|
+
/** Customer details */
|
|
614
|
+
customer: {
|
|
615
|
+
name: string;
|
|
616
|
+
address?: string[];
|
|
617
|
+
phone?: string;
|
|
618
|
+
email?: string;
|
|
619
|
+
};
|
|
620
|
+
/** Line items */
|
|
621
|
+
items: Array<{
|
|
622
|
+
description: string;
|
|
623
|
+
quantity: number;
|
|
624
|
+
unitPrice: number;
|
|
625
|
+
discount?: number;
|
|
626
|
+
tax?: number;
|
|
627
|
+
total?: number;
|
|
628
|
+
}>;
|
|
629
|
+
/** Subtotal */
|
|
630
|
+
subtotal?: number;
|
|
631
|
+
/** Tax details */
|
|
632
|
+
tax?: {
|
|
633
|
+
rate: number;
|
|
634
|
+
amount: number;
|
|
635
|
+
label?: string;
|
|
636
|
+
};
|
|
637
|
+
/** Discount */
|
|
638
|
+
discount?: {
|
|
639
|
+
type: 'percentage' | 'fixed';
|
|
640
|
+
value: number;
|
|
641
|
+
amount?: number;
|
|
642
|
+
};
|
|
643
|
+
/** Total amount */
|
|
644
|
+
total: number;
|
|
645
|
+
/** Payment terms */
|
|
646
|
+
paymentTerms?: string;
|
|
647
|
+
/** Notes */
|
|
648
|
+
notes?: string;
|
|
649
|
+
/** Bank details */
|
|
650
|
+
bankDetails?: {
|
|
651
|
+
bankName?: string;
|
|
652
|
+
accountName?: string;
|
|
653
|
+
accountNumber?: string;
|
|
654
|
+
routingNumber?: string;
|
|
655
|
+
iban?: string;
|
|
656
|
+
swift?: string;
|
|
657
|
+
};
|
|
658
|
+
/** Theme */
|
|
659
|
+
theme?: ReportTheme;
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* Data validation rule
|
|
663
|
+
*/
|
|
664
|
+
export interface DataValidationRule {
|
|
665
|
+
/** Column or field name */
|
|
666
|
+
field: string;
|
|
667
|
+
/** Validation type */
|
|
668
|
+
type: 'required' | 'email' | 'url' | 'number' | 'date' | 'regex' | 'custom' | 'list';
|
|
669
|
+
/** List of allowed values (for list type) */
|
|
670
|
+
allowedValues?: any[];
|
|
671
|
+
/** Regex pattern (for regex type) */
|
|
672
|
+
pattern?: string | RegExp;
|
|
673
|
+
/** Custom validation function */
|
|
674
|
+
validator?: (value: any) => boolean;
|
|
675
|
+
/** Min value (for number/date) */
|
|
676
|
+
min?: number | Date;
|
|
677
|
+
/** Max value (for number/date) */
|
|
678
|
+
max?: number | Date;
|
|
679
|
+
/** Error message */
|
|
680
|
+
errorMessage?: string;
|
|
681
|
+
/** Show dropdown (for list type in Excel) */
|
|
682
|
+
showDropdown?: boolean;
|
|
683
|
+
}
|
|
684
|
+
export type DeepPartial<T> = {
|
|
685
|
+
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
686
|
+
};
|
|
687
|
+
export type RequiredFields<T, K extends keyof T> = T & Required<Pick<T, K>>;
|
|
688
|
+
export type FileExtension = `.${FileFormat}`;
|
|
689
|
+
export interface FileInfo {
|
|
690
|
+
name: string;
|
|
691
|
+
extension: FileExtension;
|
|
692
|
+
size: number;
|
|
693
|
+
mimeType: string;
|
|
694
|
+
path?: string;
|
|
695
|
+
createdAt?: Date;
|
|
696
|
+
modifiedAt?: Date;
|
|
697
|
+
}
|
|
698
|
+
export declare const MIME_TYPES: Record<FileFormat, string>;
|
|
699
|
+
export declare const DEFAULT_PAGE_SIZES: Record<string, PageSize>;
|
|
700
|
+
export declare const DEFAULT_MARGINS: PageMargins;
|
|
701
|
+
export declare const DEFAULT_FONT: FontConfig;
|
|
702
|
+
//# sourceMappingURL=types.d.ts.map
|