@krutai/excel-comparison 0.0.6
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/AI_REFERENCE.md +353 -0
- package/README.md +161 -0
- package/dist/index.d.mts +187 -0
- package/dist/index.d.ts +187 -0
- package/dist/index.js +34745 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +34711 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +53 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
interface ComparisonClientConfig {
|
|
2
|
+
/**
|
|
3
|
+
* KrutAI API key.
|
|
4
|
+
* Optional: defaults to process.env.KRUTAI_API_KEY
|
|
5
|
+
*/
|
|
6
|
+
apiKey?: string;
|
|
7
|
+
/**
|
|
8
|
+
* Base URL of your deployed comparison backend server.
|
|
9
|
+
* @default "http://localhost:8000"
|
|
10
|
+
* @example "https://api.krut.ai"
|
|
11
|
+
*/
|
|
12
|
+
serverUrl?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Request timeout in milliseconds.
|
|
15
|
+
* @default 60000
|
|
16
|
+
*/
|
|
17
|
+
timeout?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Whether to validate the API key against the server on initialization.
|
|
20
|
+
* @default true
|
|
21
|
+
*/
|
|
22
|
+
validateOnInit?: boolean;
|
|
23
|
+
}
|
|
24
|
+
interface CompareFilesOptions {
|
|
25
|
+
matchColumn?: string;
|
|
26
|
+
ignoreColumns?: string[];
|
|
27
|
+
tolerance?: number;
|
|
28
|
+
caseSensitive?: boolean;
|
|
29
|
+
}
|
|
30
|
+
interface FilePreview {
|
|
31
|
+
name: string;
|
|
32
|
+
rowCount: number;
|
|
33
|
+
columns: string[];
|
|
34
|
+
sample: Record<string, unknown>[];
|
|
35
|
+
}
|
|
36
|
+
interface PreviewResponse {
|
|
37
|
+
success: boolean;
|
|
38
|
+
file1?: FilePreview;
|
|
39
|
+
file2?: FilePreview;
|
|
40
|
+
suggestedMatchColumn?: string;
|
|
41
|
+
error?: string;
|
|
42
|
+
}
|
|
43
|
+
interface ComparisonApiResponse {
|
|
44
|
+
success: boolean;
|
|
45
|
+
result?: {
|
|
46
|
+
summary: {
|
|
47
|
+
totalRows: number;
|
|
48
|
+
matchesFound: number;
|
|
49
|
+
differencesFound: number;
|
|
50
|
+
uniqueToFile1: number;
|
|
51
|
+
uniqueToFile2: number;
|
|
52
|
+
status: 'SUCCESS' | 'PARTIAL' | 'NO_MATCH';
|
|
53
|
+
};
|
|
54
|
+
matchColumn: string;
|
|
55
|
+
metadata: {
|
|
56
|
+
file1Name: string;
|
|
57
|
+
file1Columns: string[];
|
|
58
|
+
file1RowCount: number;
|
|
59
|
+
file2Name: string;
|
|
60
|
+
file2Columns: string[];
|
|
61
|
+
file2RowCount: number;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
downloadUrl?: string;
|
|
65
|
+
fileName?: string;
|
|
66
|
+
error?: string;
|
|
67
|
+
}
|
|
68
|
+
declare class ComparisonApiClient {
|
|
69
|
+
private serverUrl;
|
|
70
|
+
private apiKey?;
|
|
71
|
+
private timeout;
|
|
72
|
+
private initialized;
|
|
73
|
+
private validateOnInit;
|
|
74
|
+
private initializationPromise;
|
|
75
|
+
constructor(config: ComparisonClientConfig);
|
|
76
|
+
/**
|
|
77
|
+
* Initialize the client.
|
|
78
|
+
* Validates the API key against the server if validateOnInit is true.
|
|
79
|
+
* @throws {Error} If validation fails or API key is missing
|
|
80
|
+
*/
|
|
81
|
+
initialize(): Promise<void>;
|
|
82
|
+
private getHeaders;
|
|
83
|
+
private request;
|
|
84
|
+
compareFiles(file1Buffer: Buffer, file1Name: string, file2Buffer: Buffer, file2Name: string, compareOptions?: CompareFilesOptions): Promise<ComparisonApiResponse>;
|
|
85
|
+
compareFilesFromFileObjects(file1: File, file2: File, compareOptions?: CompareFilesOptions): Promise<ComparisonApiResponse>;
|
|
86
|
+
previewFiles(file1: File, file2: File): Promise<PreviewResponse>;
|
|
87
|
+
previewFilesFromBuffers(file1Buffer: Buffer, file1Name: string, file2Buffer: Buffer, file2Name: string): Promise<PreviewResponse>;
|
|
88
|
+
}
|
|
89
|
+
declare function createComparisonClient(config: ComparisonClientConfig): ComparisonApiClient;
|
|
90
|
+
|
|
91
|
+
interface DataRecord {
|
|
92
|
+
[key: string]: unknown;
|
|
93
|
+
}
|
|
94
|
+
interface ComparisonResult {
|
|
95
|
+
data: DataRecord[];
|
|
96
|
+
summary: {
|
|
97
|
+
totalRows: number;
|
|
98
|
+
differencesFound: number;
|
|
99
|
+
matchesFound: number;
|
|
100
|
+
status: 'SUCCESS' | 'PARTIAL' | 'NO_MATCH';
|
|
101
|
+
};
|
|
102
|
+
metadata?: {
|
|
103
|
+
file1Columns?: string[];
|
|
104
|
+
file2Columns?: string[];
|
|
105
|
+
executionTime?: number;
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
interface ExcelLoaderOptions {
|
|
109
|
+
sheetIndex?: number;
|
|
110
|
+
sheetName?: string;
|
|
111
|
+
headerRow?: number;
|
|
112
|
+
skipRows?: number;
|
|
113
|
+
sampleRows?: number;
|
|
114
|
+
}
|
|
115
|
+
interface LoaderOptions {
|
|
116
|
+
sheetName?: string;
|
|
117
|
+
headerRow?: number;
|
|
118
|
+
skipRows?: number;
|
|
119
|
+
}
|
|
120
|
+
interface ReporterOptions {
|
|
121
|
+
headerColor?: string;
|
|
122
|
+
differenceColor?: string;
|
|
123
|
+
matchColor?: string;
|
|
124
|
+
sheetName?: string;
|
|
125
|
+
includeSummary?: boolean;
|
|
126
|
+
}
|
|
127
|
+
interface EngineOptions {
|
|
128
|
+
timeout?: number;
|
|
129
|
+
maxMemory?: number;
|
|
130
|
+
}
|
|
131
|
+
interface CodeGenerationResult {
|
|
132
|
+
code: string;
|
|
133
|
+
humanExplanation: string[];
|
|
134
|
+
constants?: Record<string, unknown>;
|
|
135
|
+
}
|
|
136
|
+
interface ComparisonRequest {
|
|
137
|
+
file1Data: DataRecord[];
|
|
138
|
+
file2Data: DataRecord[];
|
|
139
|
+
file1Columns?: string[];
|
|
140
|
+
file2Columns?: string[];
|
|
141
|
+
file1Sample?: DataRecord[];
|
|
142
|
+
file2Sample?: DataRecord[];
|
|
143
|
+
prompt?: string;
|
|
144
|
+
}
|
|
145
|
+
interface ExcelSchema {
|
|
146
|
+
headers: string[];
|
|
147
|
+
rowCount: number;
|
|
148
|
+
columnCount: number;
|
|
149
|
+
sample: DataRecord[];
|
|
150
|
+
data: DataRecord[];
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
declare class StyledReporter {
|
|
154
|
+
private options;
|
|
155
|
+
constructor(options?: ReporterOptions);
|
|
156
|
+
generateReport(result: ComparisonResult, _file1Columns?: string[], _file2Columns?: string[]): Promise<Buffer>;
|
|
157
|
+
private addSummarySheet;
|
|
158
|
+
private addResultSheet;
|
|
159
|
+
private formatValue;
|
|
160
|
+
generateDetailedReport(result: ComparisonResult, file1Columns?: string[], file2Columns?: string[]): Promise<Buffer>;
|
|
161
|
+
private addDataSheet;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
interface ExcelDataFrame {
|
|
165
|
+
headers: string[];
|
|
166
|
+
data: DataRecord[];
|
|
167
|
+
rowCount: number;
|
|
168
|
+
columnCount: number;
|
|
169
|
+
sample: DataRecord[];
|
|
170
|
+
}
|
|
171
|
+
declare class DataLoader {
|
|
172
|
+
static loadFromBuffer(buffer: Buffer, fileName: string, options?: ExcelLoaderOptions): Promise<ExcelDataFrame>;
|
|
173
|
+
static getColumnNames(data: DataRecord[]): string[];
|
|
174
|
+
static getSampleData(data: DataRecord[], count?: number): DataRecord[];
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* krutExcelComparison — convenience factory.
|
|
179
|
+
*
|
|
180
|
+
* Creates a `ComparisonApiClient` instance configured to call the Krut comparison server.
|
|
181
|
+
*
|
|
182
|
+
* @param config - Client configuration (apiKey and serverUrl)
|
|
183
|
+
* @returns A `ComparisonApiClient` instance
|
|
184
|
+
*/
|
|
185
|
+
declare function krutExcelComparison(config: ComparisonClientConfig): ComparisonApiClient;
|
|
186
|
+
|
|
187
|
+
export { type FilePreview as ApiFilePreview, type CodeGenerationResult, type CompareFilesOptions, ComparisonApiClient, type ComparisonApiResponse, type ComparisonClientConfig, type ComparisonRequest, type ComparisonResult, DataLoader, type DataRecord, type EngineOptions, type ExcelLoaderOptions, type ExcelSchema, type LoaderOptions, type PreviewResponse, type ReporterOptions, StyledReporter, createComparisonClient, krutExcelComparison };
|