@elqnt/docs 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.
@@ -0,0 +1,390 @@
1
+ import { Variable } from '@elqnt/types';
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
3
+
4
+ interface DocumentValidationRequest {
5
+ fileName: string;
6
+ templateName: string;
7
+ docBlob: string;
8
+ fields: DocTemplateField[];
9
+ validationRules: DocTemplateValidationRule[];
10
+ }
11
+ interface DocumentValidationResponse {
12
+ success: boolean;
13
+ message: string;
14
+ fields: DocTemplateField[];
15
+ }
16
+ interface AzureDocumentIntelligenceResponse {
17
+ status: string;
18
+ createdDateTime: string;
19
+ lastUpdatedDateTime: string;
20
+ analyzeResult: AnalyzeResult;
21
+ }
22
+ interface AnalyzeResult {
23
+ apiVersion: string;
24
+ modelId: string;
25
+ stringIndexType: string;
26
+ pages: Page[];
27
+ content: string;
28
+ contentFormat: string;
29
+ Paragraphs: Paragraph[];
30
+ Tables: Tables[];
31
+ }
32
+ interface DocumentLayout {
33
+ paragraphs: Paragraph[];
34
+ tables: Tables[];
35
+ pages: PageInfo[];
36
+ }
37
+ interface Page {
38
+ pageNumber: number;
39
+ angle: number;
40
+ width: number;
41
+ height: number;
42
+ unit: string;
43
+ words: Word[];
44
+ lines: Line[];
45
+ }
46
+ interface Line {
47
+ content: string;
48
+ spans: Span[];
49
+ }
50
+ interface Paragraph {
51
+ content: string;
52
+ role: string;
53
+ spans: Span[];
54
+ boundingRegions: BoundingRegion[];
55
+ }
56
+ interface BoundingRegion {
57
+ pageNumber: number;
58
+ polygon: number[];
59
+ }
60
+ interface Word {
61
+ content: string;
62
+ boundingBox: number[];
63
+ confidence: number;
64
+ span: Span;
65
+ }
66
+ interface Span {
67
+ offset: number;
68
+ length: number;
69
+ }
70
+ interface Tables {
71
+ rowCount: number;
72
+ columnCount: number;
73
+ cells: Cells[];
74
+ boundingRegions: BoundingRegion[];
75
+ spans: Spans[];
76
+ }
77
+ interface Cells {
78
+ kind?: string;
79
+ rowIndex: number;
80
+ columnIndex: number;
81
+ content: string;
82
+ boundingRegions: BoundingRegion[];
83
+ spans: Spans[];
84
+ elements: string[];
85
+ }
86
+ interface Spans {
87
+ offset: number;
88
+ length: number;
89
+ }
90
+ /**
91
+ * ** our own custom types mainly for the docs ingestion
92
+ */
93
+ interface PageInfo {
94
+ pageNumber: number;
95
+ angle: number;
96
+ width: number;
97
+ height: number;
98
+ unit: string;
99
+ }
100
+ interface ParagraphContent {
101
+ paragraph_number: number;
102
+ content: string;
103
+ role: string;
104
+ }
105
+ interface ParagraphContentReference {
106
+ page_number: number;
107
+ paragraph_number: number;
108
+ markdown_tag: string;
109
+ }
110
+ interface DocumentReference {
111
+ URL: string;
112
+ Title: string;
113
+ PageNumber: number;
114
+ ParagraphReferences: ParagraphReference[];
115
+ }
116
+ interface ParagraphReference {
117
+ ParagraphNumber: number;
118
+ BoundingRegions: BoundingRegion[];
119
+ }
120
+ interface DocsIngestionRequest {
121
+ urls: string[];
122
+ mode: string;
123
+ brief: string;
124
+ labels: string[];
125
+ }
126
+ interface RawAnalysisRequest {
127
+ fileUrl: string;
128
+ model: 'prebuilt-read' | 'prebuilt-layout';
129
+ fromPage: number;
130
+ toPage: number;
131
+ outputMarkdown: boolean;
132
+ }
133
+ /**
134
+ * Citation represents the citation data for a page chunk
135
+ */
136
+ interface Citation {
137
+ boundingRegions: BoundingRegion[];
138
+ pageInfo?: PageInfo;
139
+ }
140
+ /**
141
+ * PageChunk represents a chunk of document content with its associated citations
142
+ */
143
+ interface PageChunk {
144
+ text: string;
145
+ citations: Citation;
146
+ }
147
+ /**
148
+ * DocAnalysisConfig holds configuration for document analysis processing
149
+ */
150
+ interface DocAnalysisConfig {
151
+ maxConcurrentEmbeddings: number;
152
+ batchStorageSize: number;
153
+ embeddingTimeout: any;
154
+ }
155
+ /**
156
+ * DocumentAnalysisResult represents the result of analyzing a document
157
+ */
158
+ interface DocumentAnalysisResult {
159
+ docId: string;
160
+ success: boolean;
161
+ message: string;
162
+ metadata: DocumentMetadata;
163
+ totalChunks: number;
164
+ successCount: number;
165
+ errorCount: number;
166
+ status: string;
167
+ }
168
+ interface DocumentAnalysisReference {
169
+ doc_id: string;
170
+ url: string;
171
+ title: string;
172
+ }
173
+ interface WorkflowDocumentExtractionRequest {
174
+ orgID: string;
175
+ instanceID: string;
176
+ nodeID: string;
177
+ fileUrl: string;
178
+ schema: any;
179
+ instructions: string;
180
+ documentType: string;
181
+ subType: string;
182
+ companyID: string;
183
+ }
184
+ interface WorkflowDocumentExtractionStatus {
185
+ status: string;
186
+ error?: string;
187
+ timestamp: number;
188
+ percentage: number;
189
+ }
190
+ interface WorkflowDocumentExtractionResponse {
191
+ result: {
192
+ [key: string]: any;
193
+ };
194
+ }
195
+ interface DocJob {
196
+ id?: string;
197
+ templateId: string;
198
+ templateTitle: string;
199
+ title: string;
200
+ label: string;
201
+ fields: {
202
+ [key: string]: Variable;
203
+ };
204
+ status: 'started' | 'pending' | 'failed' | 'success';
205
+ progress: number;
206
+ fileUrls: string[];
207
+ createdAt: number;
208
+ updatedAt: number;
209
+ createdBy: string;
210
+ updatedBy: string;
211
+ }
212
+ type DocJobStatus = string;
213
+ declare const DocJobStatusStarted: DocJobStatus;
214
+ declare const DocJobStatusInProgress: DocJobStatus;
215
+ declare const DocJobStatusPending: DocJobStatus;
216
+ declare const DocJobStatusFailed: DocJobStatus;
217
+ declare const DocJobStatusSuccess: DocJobStatus;
218
+ interface DocExtractionResult {
219
+ id?: string;
220
+ jobId: string;
221
+ templateId: string;
222
+ fileUrl: string;
223
+ fields: DocTemplateField[];
224
+ status: DocJobStatus;
225
+ label: string;
226
+ error: string;
227
+ message: string;
228
+ createdAt: number;
229
+ updatedAt: number;
230
+ }
231
+ interface QuarterlyFinancialStatement {
232
+ companyName: string;
233
+ year: number;
234
+ quarter: number;
235
+ totalAssets: number;
236
+ totalEquity: number;
237
+ totalLiabilities: number;
238
+ totalRevenueForPeriod: number;
239
+ totalRevenuePrevPeriod: number;
240
+ totalOperatingIncome: number;
241
+ totalOperatingExpenses: number;
242
+ profitLossForPeriod: number;
243
+ }
244
+ interface PassportInfo {
245
+ firstNameEn: string;
246
+ secondNameEn: string;
247
+ thirdNameEn: string;
248
+ fourthNameEn: string;
249
+ lastNameEn: string;
250
+ firstNameAr: string;
251
+ secondNameAr: string;
252
+ thirdNameAr: string;
253
+ fourthNameAr: string;
254
+ lastNameAr: string;
255
+ passportNumber: string;
256
+ nationality: string;
257
+ dateOfBirth: string;
258
+ expiryDate: string;
259
+ passportType: string;
260
+ gender: string;
261
+ }
262
+ interface QuotationAnalyzeRequest {
263
+ fileUrls: string[];
264
+ rfqTables: RFQTable[];
265
+ rfqLineItems: RFQLineItem[];
266
+ evaluationCriteria: string;
267
+ }
268
+ interface RFQAnalyzeRequest {
269
+ fileUrl: string;
270
+ instructions: string;
271
+ }
272
+ interface RFQAnalyzeResponse {
273
+ rfqLineItems: RFQLineItem[];
274
+ rfqTables: RFQTable[];
275
+ }
276
+ interface RFQTable {
277
+ title: string;
278
+ markdown: string;
279
+ }
280
+ interface QuotationAnalyzeResponse {
281
+ quotationLineItems: QuotationLineItem[];
282
+ }
283
+ interface RFQLineItem {
284
+ item_name: string;
285
+ description: string;
286
+ quantity: number;
287
+ }
288
+ interface QuotationLineItem {
289
+ item_name: string;
290
+ supplier_name: string;
291
+ description: string;
292
+ quantity: number;
293
+ item_price: number;
294
+ total_price: number;
295
+ notes: string;
296
+ meet_criteria: boolean;
297
+ }
298
+ interface InvoiceAnalyzeRequest {
299
+ fileUrl: string;
300
+ instructions: string;
301
+ }
302
+ interface InvoiceAnalyzeResponse {
303
+ supplier_name: string;
304
+ customer_name: string;
305
+ invoice_date: string;
306
+ invoice_due_date: string;
307
+ invoice_number: string;
308
+ invoice_total: number;
309
+ invoice_items_tables: MarkdownTable[];
310
+ }
311
+ interface MarkdownTable {
312
+ title: string;
313
+ markdown: string;
314
+ }
315
+ /**
316
+ * DocumentChunk represents a chunk of analyzed document for ClickHouse
317
+ */
318
+ interface DocumentChunk {
319
+ doc_id: string;
320
+ title: string;
321
+ doc_url: string;
322
+ chunk_id: string;
323
+ chunk_text: string;
324
+ chunk_index: number;
325
+ embeddings: number[];
326
+ citations: Citation;
327
+ owner_email: string;
328
+ visibility_level: string;
329
+ created_at: string;
330
+ }
331
+ /**
332
+ * DocumentMetadata represents document-level metadata for ClickHouse
333
+ */
334
+ interface DocumentMetadata {
335
+ doc_id: string;
336
+ title: string;
337
+ doc_url: string;
338
+ total_chunks: number;
339
+ page_count: number;
340
+ from_page: number;
341
+ to_page: number;
342
+ status: string;
343
+ model: string;
344
+ owner_email: string;
345
+ visibility_level: string;
346
+ created_at: string;
347
+ updated_at: string;
348
+ }
349
+ interface DocTemplate {
350
+ id?: string;
351
+ name: string;
352
+ title: string;
353
+ description?: string;
354
+ fields: DocTemplateField[];
355
+ validationRules?: DocTemplateValidationRule[];
356
+ }
357
+ interface DocTemplateField {
358
+ name: string;
359
+ title: string;
360
+ description?: string;
361
+ dataType: string;
362
+ required?: boolean;
363
+ options?: string[];
364
+ defaultValue?: string;
365
+ value?: any;
366
+ validationRules?: DocTemplateValidationRule[];
367
+ subFields?: DocTemplateField[];
368
+ issues: string;
369
+ }
370
+ interface DocTemplateValidationRule {
371
+ type: ValidationRuleType;
372
+ expectedValue?: any;
373
+ isValid: boolean;
374
+ error?: string;
375
+ }
376
+ type ValidationRuleType = string;
377
+ declare const ValidationRuleTypeEqual: ValidationRuleType;
378
+ declare const ValidationRuleTypeGreaterThan: ValidationRuleType;
379
+ declare const ValidationRuleTypeLessThan: ValidationRuleType;
380
+ declare const ValidationRuleTypeRegex: ValidationRuleType;
381
+ declare const ValidationRuleTypeRequired: ValidationRuleType;
382
+ declare const ValidationRuleTypeNotEmpty: ValidationRuleType;
383
+ declare const ValidationRuleTypeNotEqual: ValidationRuleType;
384
+ declare const ValidationRuleTypeNotExpired: ValidationRuleType;
385
+ declare const ValidationRuleTypeCustom: ValidationRuleType;
386
+
387
+ declare const getFileIcon: (fileName: string) => react_jsx_runtime.JSX.Element;
388
+ declare const getFileName: (url: string) => string;
389
+
390
+ export { type AnalyzeResult, type AzureDocumentIntelligenceResponse, type BoundingRegion, type Cells, type Citation, type DocAnalysisConfig, type DocExtractionResult, type DocJob, type DocJobStatus, DocJobStatusFailed, DocJobStatusInProgress, DocJobStatusPending, DocJobStatusStarted, DocJobStatusSuccess, type DocTemplate, type DocTemplateField, type DocTemplateValidationRule, type DocsIngestionRequest, type DocumentAnalysisReference, type DocumentAnalysisResult, type DocumentChunk, type DocumentLayout, type DocumentMetadata, type DocumentReference, type DocumentValidationRequest, type DocumentValidationResponse, type InvoiceAnalyzeRequest, type InvoiceAnalyzeResponse, type Line, type MarkdownTable, type Page, type PageChunk, type PageInfo, type Paragraph, type ParagraphContent, type ParagraphContentReference, type ParagraphReference, type PassportInfo, type QuarterlyFinancialStatement, type QuotationAnalyzeRequest, type QuotationAnalyzeResponse, type QuotationLineItem, type RFQAnalyzeRequest, type RFQAnalyzeResponse, type RFQLineItem, type RFQTable, type RawAnalysisRequest, type Span, type Spans, type Tables, type ValidationRuleType, ValidationRuleTypeCustom, ValidationRuleTypeEqual, ValidationRuleTypeGreaterThan, ValidationRuleTypeLessThan, ValidationRuleTypeNotEmpty, ValidationRuleTypeNotEqual, ValidationRuleTypeNotExpired, ValidationRuleTypeRegex, ValidationRuleTypeRequired, type Word, type WorkflowDocumentExtractionRequest, type WorkflowDocumentExtractionResponse, type WorkflowDocumentExtractionStatus, getFileIcon, getFileName };
@@ -0,0 +1,390 @@
1
+ import { Variable } from '@elqnt/types';
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
3
+
4
+ interface DocumentValidationRequest {
5
+ fileName: string;
6
+ templateName: string;
7
+ docBlob: string;
8
+ fields: DocTemplateField[];
9
+ validationRules: DocTemplateValidationRule[];
10
+ }
11
+ interface DocumentValidationResponse {
12
+ success: boolean;
13
+ message: string;
14
+ fields: DocTemplateField[];
15
+ }
16
+ interface AzureDocumentIntelligenceResponse {
17
+ status: string;
18
+ createdDateTime: string;
19
+ lastUpdatedDateTime: string;
20
+ analyzeResult: AnalyzeResult;
21
+ }
22
+ interface AnalyzeResult {
23
+ apiVersion: string;
24
+ modelId: string;
25
+ stringIndexType: string;
26
+ pages: Page[];
27
+ content: string;
28
+ contentFormat: string;
29
+ Paragraphs: Paragraph[];
30
+ Tables: Tables[];
31
+ }
32
+ interface DocumentLayout {
33
+ paragraphs: Paragraph[];
34
+ tables: Tables[];
35
+ pages: PageInfo[];
36
+ }
37
+ interface Page {
38
+ pageNumber: number;
39
+ angle: number;
40
+ width: number;
41
+ height: number;
42
+ unit: string;
43
+ words: Word[];
44
+ lines: Line[];
45
+ }
46
+ interface Line {
47
+ content: string;
48
+ spans: Span[];
49
+ }
50
+ interface Paragraph {
51
+ content: string;
52
+ role: string;
53
+ spans: Span[];
54
+ boundingRegions: BoundingRegion[];
55
+ }
56
+ interface BoundingRegion {
57
+ pageNumber: number;
58
+ polygon: number[];
59
+ }
60
+ interface Word {
61
+ content: string;
62
+ boundingBox: number[];
63
+ confidence: number;
64
+ span: Span;
65
+ }
66
+ interface Span {
67
+ offset: number;
68
+ length: number;
69
+ }
70
+ interface Tables {
71
+ rowCount: number;
72
+ columnCount: number;
73
+ cells: Cells[];
74
+ boundingRegions: BoundingRegion[];
75
+ spans: Spans[];
76
+ }
77
+ interface Cells {
78
+ kind?: string;
79
+ rowIndex: number;
80
+ columnIndex: number;
81
+ content: string;
82
+ boundingRegions: BoundingRegion[];
83
+ spans: Spans[];
84
+ elements: string[];
85
+ }
86
+ interface Spans {
87
+ offset: number;
88
+ length: number;
89
+ }
90
+ /**
91
+ * ** our own custom types mainly for the docs ingestion
92
+ */
93
+ interface PageInfo {
94
+ pageNumber: number;
95
+ angle: number;
96
+ width: number;
97
+ height: number;
98
+ unit: string;
99
+ }
100
+ interface ParagraphContent {
101
+ paragraph_number: number;
102
+ content: string;
103
+ role: string;
104
+ }
105
+ interface ParagraphContentReference {
106
+ page_number: number;
107
+ paragraph_number: number;
108
+ markdown_tag: string;
109
+ }
110
+ interface DocumentReference {
111
+ URL: string;
112
+ Title: string;
113
+ PageNumber: number;
114
+ ParagraphReferences: ParagraphReference[];
115
+ }
116
+ interface ParagraphReference {
117
+ ParagraphNumber: number;
118
+ BoundingRegions: BoundingRegion[];
119
+ }
120
+ interface DocsIngestionRequest {
121
+ urls: string[];
122
+ mode: string;
123
+ brief: string;
124
+ labels: string[];
125
+ }
126
+ interface RawAnalysisRequest {
127
+ fileUrl: string;
128
+ model: 'prebuilt-read' | 'prebuilt-layout';
129
+ fromPage: number;
130
+ toPage: number;
131
+ outputMarkdown: boolean;
132
+ }
133
+ /**
134
+ * Citation represents the citation data for a page chunk
135
+ */
136
+ interface Citation {
137
+ boundingRegions: BoundingRegion[];
138
+ pageInfo?: PageInfo;
139
+ }
140
+ /**
141
+ * PageChunk represents a chunk of document content with its associated citations
142
+ */
143
+ interface PageChunk {
144
+ text: string;
145
+ citations: Citation;
146
+ }
147
+ /**
148
+ * DocAnalysisConfig holds configuration for document analysis processing
149
+ */
150
+ interface DocAnalysisConfig {
151
+ maxConcurrentEmbeddings: number;
152
+ batchStorageSize: number;
153
+ embeddingTimeout: any;
154
+ }
155
+ /**
156
+ * DocumentAnalysisResult represents the result of analyzing a document
157
+ */
158
+ interface DocumentAnalysisResult {
159
+ docId: string;
160
+ success: boolean;
161
+ message: string;
162
+ metadata: DocumentMetadata;
163
+ totalChunks: number;
164
+ successCount: number;
165
+ errorCount: number;
166
+ status: string;
167
+ }
168
+ interface DocumentAnalysisReference {
169
+ doc_id: string;
170
+ url: string;
171
+ title: string;
172
+ }
173
+ interface WorkflowDocumentExtractionRequest {
174
+ orgID: string;
175
+ instanceID: string;
176
+ nodeID: string;
177
+ fileUrl: string;
178
+ schema: any;
179
+ instructions: string;
180
+ documentType: string;
181
+ subType: string;
182
+ companyID: string;
183
+ }
184
+ interface WorkflowDocumentExtractionStatus {
185
+ status: string;
186
+ error?: string;
187
+ timestamp: number;
188
+ percentage: number;
189
+ }
190
+ interface WorkflowDocumentExtractionResponse {
191
+ result: {
192
+ [key: string]: any;
193
+ };
194
+ }
195
+ interface DocJob {
196
+ id?: string;
197
+ templateId: string;
198
+ templateTitle: string;
199
+ title: string;
200
+ label: string;
201
+ fields: {
202
+ [key: string]: Variable;
203
+ };
204
+ status: 'started' | 'pending' | 'failed' | 'success';
205
+ progress: number;
206
+ fileUrls: string[];
207
+ createdAt: number;
208
+ updatedAt: number;
209
+ createdBy: string;
210
+ updatedBy: string;
211
+ }
212
+ type DocJobStatus = string;
213
+ declare const DocJobStatusStarted: DocJobStatus;
214
+ declare const DocJobStatusInProgress: DocJobStatus;
215
+ declare const DocJobStatusPending: DocJobStatus;
216
+ declare const DocJobStatusFailed: DocJobStatus;
217
+ declare const DocJobStatusSuccess: DocJobStatus;
218
+ interface DocExtractionResult {
219
+ id?: string;
220
+ jobId: string;
221
+ templateId: string;
222
+ fileUrl: string;
223
+ fields: DocTemplateField[];
224
+ status: DocJobStatus;
225
+ label: string;
226
+ error: string;
227
+ message: string;
228
+ createdAt: number;
229
+ updatedAt: number;
230
+ }
231
+ interface QuarterlyFinancialStatement {
232
+ companyName: string;
233
+ year: number;
234
+ quarter: number;
235
+ totalAssets: number;
236
+ totalEquity: number;
237
+ totalLiabilities: number;
238
+ totalRevenueForPeriod: number;
239
+ totalRevenuePrevPeriod: number;
240
+ totalOperatingIncome: number;
241
+ totalOperatingExpenses: number;
242
+ profitLossForPeriod: number;
243
+ }
244
+ interface PassportInfo {
245
+ firstNameEn: string;
246
+ secondNameEn: string;
247
+ thirdNameEn: string;
248
+ fourthNameEn: string;
249
+ lastNameEn: string;
250
+ firstNameAr: string;
251
+ secondNameAr: string;
252
+ thirdNameAr: string;
253
+ fourthNameAr: string;
254
+ lastNameAr: string;
255
+ passportNumber: string;
256
+ nationality: string;
257
+ dateOfBirth: string;
258
+ expiryDate: string;
259
+ passportType: string;
260
+ gender: string;
261
+ }
262
+ interface QuotationAnalyzeRequest {
263
+ fileUrls: string[];
264
+ rfqTables: RFQTable[];
265
+ rfqLineItems: RFQLineItem[];
266
+ evaluationCriteria: string;
267
+ }
268
+ interface RFQAnalyzeRequest {
269
+ fileUrl: string;
270
+ instructions: string;
271
+ }
272
+ interface RFQAnalyzeResponse {
273
+ rfqLineItems: RFQLineItem[];
274
+ rfqTables: RFQTable[];
275
+ }
276
+ interface RFQTable {
277
+ title: string;
278
+ markdown: string;
279
+ }
280
+ interface QuotationAnalyzeResponse {
281
+ quotationLineItems: QuotationLineItem[];
282
+ }
283
+ interface RFQLineItem {
284
+ item_name: string;
285
+ description: string;
286
+ quantity: number;
287
+ }
288
+ interface QuotationLineItem {
289
+ item_name: string;
290
+ supplier_name: string;
291
+ description: string;
292
+ quantity: number;
293
+ item_price: number;
294
+ total_price: number;
295
+ notes: string;
296
+ meet_criteria: boolean;
297
+ }
298
+ interface InvoiceAnalyzeRequest {
299
+ fileUrl: string;
300
+ instructions: string;
301
+ }
302
+ interface InvoiceAnalyzeResponse {
303
+ supplier_name: string;
304
+ customer_name: string;
305
+ invoice_date: string;
306
+ invoice_due_date: string;
307
+ invoice_number: string;
308
+ invoice_total: number;
309
+ invoice_items_tables: MarkdownTable[];
310
+ }
311
+ interface MarkdownTable {
312
+ title: string;
313
+ markdown: string;
314
+ }
315
+ /**
316
+ * DocumentChunk represents a chunk of analyzed document for ClickHouse
317
+ */
318
+ interface DocumentChunk {
319
+ doc_id: string;
320
+ title: string;
321
+ doc_url: string;
322
+ chunk_id: string;
323
+ chunk_text: string;
324
+ chunk_index: number;
325
+ embeddings: number[];
326
+ citations: Citation;
327
+ owner_email: string;
328
+ visibility_level: string;
329
+ created_at: string;
330
+ }
331
+ /**
332
+ * DocumentMetadata represents document-level metadata for ClickHouse
333
+ */
334
+ interface DocumentMetadata {
335
+ doc_id: string;
336
+ title: string;
337
+ doc_url: string;
338
+ total_chunks: number;
339
+ page_count: number;
340
+ from_page: number;
341
+ to_page: number;
342
+ status: string;
343
+ model: string;
344
+ owner_email: string;
345
+ visibility_level: string;
346
+ created_at: string;
347
+ updated_at: string;
348
+ }
349
+ interface DocTemplate {
350
+ id?: string;
351
+ name: string;
352
+ title: string;
353
+ description?: string;
354
+ fields: DocTemplateField[];
355
+ validationRules?: DocTemplateValidationRule[];
356
+ }
357
+ interface DocTemplateField {
358
+ name: string;
359
+ title: string;
360
+ description?: string;
361
+ dataType: string;
362
+ required?: boolean;
363
+ options?: string[];
364
+ defaultValue?: string;
365
+ value?: any;
366
+ validationRules?: DocTemplateValidationRule[];
367
+ subFields?: DocTemplateField[];
368
+ issues: string;
369
+ }
370
+ interface DocTemplateValidationRule {
371
+ type: ValidationRuleType;
372
+ expectedValue?: any;
373
+ isValid: boolean;
374
+ error?: string;
375
+ }
376
+ type ValidationRuleType = string;
377
+ declare const ValidationRuleTypeEqual: ValidationRuleType;
378
+ declare const ValidationRuleTypeGreaterThan: ValidationRuleType;
379
+ declare const ValidationRuleTypeLessThan: ValidationRuleType;
380
+ declare const ValidationRuleTypeRegex: ValidationRuleType;
381
+ declare const ValidationRuleTypeRequired: ValidationRuleType;
382
+ declare const ValidationRuleTypeNotEmpty: ValidationRuleType;
383
+ declare const ValidationRuleTypeNotEqual: ValidationRuleType;
384
+ declare const ValidationRuleTypeNotExpired: ValidationRuleType;
385
+ declare const ValidationRuleTypeCustom: ValidationRuleType;
386
+
387
+ declare const getFileIcon: (fileName: string) => react_jsx_runtime.JSX.Element;
388
+ declare const getFileName: (url: string) => string;
389
+
390
+ export { type AnalyzeResult, type AzureDocumentIntelligenceResponse, type BoundingRegion, type Cells, type Citation, type DocAnalysisConfig, type DocExtractionResult, type DocJob, type DocJobStatus, DocJobStatusFailed, DocJobStatusInProgress, DocJobStatusPending, DocJobStatusStarted, DocJobStatusSuccess, type DocTemplate, type DocTemplateField, type DocTemplateValidationRule, type DocsIngestionRequest, type DocumentAnalysisReference, type DocumentAnalysisResult, type DocumentChunk, type DocumentLayout, type DocumentMetadata, type DocumentReference, type DocumentValidationRequest, type DocumentValidationResponse, type InvoiceAnalyzeRequest, type InvoiceAnalyzeResponse, type Line, type MarkdownTable, type Page, type PageChunk, type PageInfo, type Paragraph, type ParagraphContent, type ParagraphContentReference, type ParagraphReference, type PassportInfo, type QuarterlyFinancialStatement, type QuotationAnalyzeRequest, type QuotationAnalyzeResponse, type QuotationLineItem, type RFQAnalyzeRequest, type RFQAnalyzeResponse, type RFQLineItem, type RFQTable, type RawAnalysisRequest, type Span, type Spans, type Tables, type ValidationRuleType, ValidationRuleTypeCustom, ValidationRuleTypeEqual, ValidationRuleTypeGreaterThan, ValidationRuleTypeLessThan, ValidationRuleTypeNotEmpty, ValidationRuleTypeNotEqual, ValidationRuleTypeNotExpired, ValidationRuleTypeRegex, ValidationRuleTypeRequired, type Word, type WorkflowDocumentExtractionRequest, type WorkflowDocumentExtractionResponse, type WorkflowDocumentExtractionStatus, getFileIcon, getFileName };
package/dist/index.js ADDED
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // index.tsx
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ DocJobStatusFailed: () => DocJobStatusFailed,
24
+ DocJobStatusInProgress: () => DocJobStatusInProgress,
25
+ DocJobStatusPending: () => DocJobStatusPending,
26
+ DocJobStatusStarted: () => DocJobStatusStarted,
27
+ DocJobStatusSuccess: () => DocJobStatusSuccess,
28
+ ValidationRuleTypeCustom: () => ValidationRuleTypeCustom,
29
+ ValidationRuleTypeEqual: () => ValidationRuleTypeEqual,
30
+ ValidationRuleTypeGreaterThan: () => ValidationRuleTypeGreaterThan,
31
+ ValidationRuleTypeLessThan: () => ValidationRuleTypeLessThan,
32
+ ValidationRuleTypeNotEmpty: () => ValidationRuleTypeNotEmpty,
33
+ ValidationRuleTypeNotEqual: () => ValidationRuleTypeNotEqual,
34
+ ValidationRuleTypeNotExpired: () => ValidationRuleTypeNotExpired,
35
+ ValidationRuleTypeRegex: () => ValidationRuleTypeRegex,
36
+ ValidationRuleTypeRequired: () => ValidationRuleTypeRequired,
37
+ getFileIcon: () => getFileIcon,
38
+ getFileName: () => getFileName
39
+ });
40
+ module.exports = __toCommonJS(index_exports);
41
+
42
+ // models/docs.ts
43
+ var DocJobStatusStarted = "started";
44
+ var DocJobStatusInProgress = "in progress";
45
+ var DocJobStatusPending = "pending";
46
+ var DocJobStatusFailed = "failed";
47
+ var DocJobStatusSuccess = "success";
48
+ var ValidationRuleTypeEqual = "equal";
49
+ var ValidationRuleTypeGreaterThan = "greaterThan";
50
+ var ValidationRuleTypeLessThan = "lessThan";
51
+ var ValidationRuleTypeRegex = "regex";
52
+ var ValidationRuleTypeRequired = "required";
53
+ var ValidationRuleTypeNotEmpty = "notEmpty";
54
+ var ValidationRuleTypeNotEqual = "notEqual";
55
+ var ValidationRuleTypeNotExpired = "notExpired";
56
+ var ValidationRuleTypeCustom = "custom";
57
+
58
+ // util/index.tsx
59
+ var import_lucide_react = require("lucide-react");
60
+ var import_jsx_runtime = require("react/jsx-runtime");
61
+ var getFileIcon = (fileName) => {
62
+ const extensionMatch = fileName.match(/\.([^.]+)$/);
63
+ const extension = extensionMatch ? extensionMatch[1].toLowerCase() : null;
64
+ if (!extension) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.File, { className: "w-8 h-8 text-gray-500" });
65
+ switch (extension) {
66
+ case "pdf":
67
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.File, { className: "w-8 h-8 text-red-500" });
68
+ case "doc":
69
+ case "docx":
70
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.FileText, { className: "w-8 h-8 text-blue-500" });
71
+ case "xls":
72
+ case "xlsx":
73
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.FileSpreadsheet, { className: "w-8 h-8 text-green-500" });
74
+ default:
75
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.File, { className: "w-8 h-8 text-gray-500" });
76
+ }
77
+ };
78
+ var getFileName = (url) => {
79
+ const fileName = decodeURIComponent(url.split("/").pop() ?? "");
80
+ const cleanFileName = fileName.replace(/%28(\d+)%29/g, "($1)").replace(/[^\w\s().-]/g, "").replace(/\s+/g, "_").replace(/-\d+(?=\.pdf)/g, "");
81
+ return cleanFileName;
82
+ };
83
+ // Annotate the CommonJS export names for ESM import in node:
84
+ 0 && (module.exports = {
85
+ DocJobStatusFailed,
86
+ DocJobStatusInProgress,
87
+ DocJobStatusPending,
88
+ DocJobStatusStarted,
89
+ DocJobStatusSuccess,
90
+ ValidationRuleTypeCustom,
91
+ ValidationRuleTypeEqual,
92
+ ValidationRuleTypeGreaterThan,
93
+ ValidationRuleTypeLessThan,
94
+ ValidationRuleTypeNotEmpty,
95
+ ValidationRuleTypeNotEqual,
96
+ ValidationRuleTypeNotExpired,
97
+ ValidationRuleTypeRegex,
98
+ ValidationRuleTypeRequired,
99
+ getFileIcon,
100
+ getFileName
101
+ });
102
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../index.tsx","../models/docs.ts","../util/index.tsx"],"sourcesContent":["export * from \"./models\";\nexport * from \"./util\";\n// export * from \"./context\";\n// export * from \"./hooks\";\n// export * from \"./components\";\n","// Code generated by tygo. DO NOT EDIT.\nimport { Variable } from \"@elqnt/types\";\n\n//////////\n// source: api.go\n\nexport interface DocumentValidationRequest {\n fileName: string;\n templateName: string;\n docBlob: string;\n fields: DocTemplateField[];\n validationRules: DocTemplateValidationRule[];\n}\nexport interface DocumentValidationResponse {\n success: boolean;\n message: string;\n fields: DocTemplateField[];\n}\n\n//////////\n// source: azure-doc-intelligence-models.go\n\nexport interface AzureDocumentIntelligenceResponse {\n status: string;\n createdDateTime: string;\n lastUpdatedDateTime: string;\n analyzeResult: AnalyzeResult;\n}\nexport interface AnalyzeResult {\n apiVersion: string;\n modelId: string;\n stringIndexType: string;\n pages: Page[];\n content: string;\n contentFormat: string;\n Paragraphs: Paragraph[];\n Tables: Tables[];\n}\nexport interface DocumentLayout {\n paragraphs: Paragraph[];\n tables: Tables[];\n pages: PageInfo[];\n}\nexport interface Page {\n pageNumber: number /* int */;\n angle: number /* float64 */;\n width: number /* float64 */;\n height: number /* float64 */;\n unit: string;\n words: Word[];\n lines: Line[];\n}\nexport interface Line {\n content: string;\n spans: Span[];\n}\nexport interface Paragraph {\n content: string;\n role: string;\n spans: Span[];\n boundingRegions: BoundingRegion[];\n}\nexport interface BoundingRegion {\n pageNumber: number /* int */;\n polygon: number /* float64 */[];\n}\nexport interface Word {\n content: string;\n boundingBox: number /* float64 */[];\n confidence: number /* float64 */;\n span: Span;\n}\nexport interface Span {\n offset: number /* int */;\n length: number /* int */;\n}\nexport interface Tables {\n rowCount: number /* int */;\n columnCount: number /* int */;\n cells: Cells[];\n boundingRegions: BoundingRegion[];\n spans: Spans[];\n}\nexport interface Cells {\n kind?: string;\n rowIndex: number /* int */;\n columnIndex: number /* int */;\n content: string;\n boundingRegions: BoundingRegion[];\n spans: Spans[];\n elements: string[];\n}\nexport interface Spans {\n offset: number /* int */;\n length: number /* int */;\n}\n\n//////////\n// source: citations-models.go\n\n/**\n * ** our own custom types mainly for the docs ingestion\n */\nexport interface PageInfo {\n pageNumber: number /* int */;\n angle: number /* float64 */;\n width: number /* float64 */;\n height: number /* float64 */;\n unit: string;\n}\nexport interface ParagraphContent {\n paragraph_number: number /* int */;\n content: string;\n role: string;\n}\nexport interface ParagraphContentReference {\n page_number: number /* int */;\n paragraph_number: number /* int */;\n markdown_tag: string;\n}\nexport interface DocumentReference {\n URL: string;\n Title: string;\n PageNumber: number /* int */;\n ParagraphReferences: ParagraphReference[];\n}\nexport interface ParagraphReference {\n ParagraphNumber: number /* int */;\n BoundingRegions: BoundingRegion[];\n}\nexport interface DocsIngestionRequest {\n urls: string[];\n mode: string;\n brief: string;\n labels: string[];\n}\nexport interface RawAnalysisRequest {\n fileUrl: string;\n model: 'prebuilt-read' | 'prebuilt-layout';\n fromPage: number /* int */;\n toPage: number /* int */;\n outputMarkdown: boolean;\n}\n/**\n * Citation represents the citation data for a page chunk\n */\nexport interface Citation {\n boundingRegions: BoundingRegion[];\n pageInfo?: PageInfo;\n}\n/**\n * PageChunk represents a chunk of document content with its associated citations\n */\nexport interface PageChunk {\n text: string;\n citations: Citation;\n}\n\n//////////\n// source: doc-analysis-models.go\n\n/**\n * DocAnalysisConfig holds configuration for document analysis processing\n */\nexport interface DocAnalysisConfig {\n maxConcurrentEmbeddings: number /* int */;\n batchStorageSize: number /* int */;\n embeddingTimeout: any /* time.Duration */;\n}\n/**\n * DocumentAnalysisResult represents the result of analyzing a document\n */\nexport interface DocumentAnalysisResult {\n docId: string;\n success: boolean;\n message: string;\n metadata: DocumentMetadata;\n totalChunks: number /* int */;\n successCount: number /* int */;\n errorCount: number /* int */;\n status: string;\n}\nexport interface DocumentAnalysisReference {\n doc_id: string;\n url: string;\n title: string;\n}\n\n//////////\n// source: doc-flow-models.go\n\nexport interface WorkflowDocumentExtractionRequest {\n orgID: string;\n instanceID: string;\n nodeID: string;\n fileUrl: string;\n schema: any /* types.JSONSchema */;\n instructions: string;\n documentType: string;\n subType: string; // the workflow node sub type, determines the document extraction function to use\n companyID: string;\n}\nexport interface WorkflowDocumentExtractionStatus {\n status: string;\n error?: string;\n timestamp: number /* int64 */;\n percentage: number /* int */;\n}\nexport interface WorkflowDocumentExtractionResponse {\n result: { [key: string]: any};\n}\n\n//////////\n// source: jobs-models.go\n\nexport interface DocJob {\n id?: string /* ObjectID */;\n templateId: string;\n templateTitle: string;\n title: string;\n label: string;\n fields: { [key: string]: Variable };\n status: 'started' | 'pending' | 'failed' | 'success';\n progress: number /* int */;\n fileUrls: string[];\n createdAt: number /* int64 */;\n updatedAt: number /* int64 */;\n createdBy: string;\n updatedBy: string;\n}\nexport type DocJobStatus = string;\nexport const DocJobStatusStarted: DocJobStatus = \"started\";\nexport const DocJobStatusInProgress: DocJobStatus = \"in progress\";\nexport const DocJobStatusPending: DocJobStatus = \"pending\";\nexport const DocJobStatusFailed: DocJobStatus = \"failed\";\nexport const DocJobStatusSuccess: DocJobStatus = \"success\";\nexport interface DocExtractionResult {\n id?: string /* ObjectID */;\n jobId: string;\n templateId: string;\n fileUrl: string;\n fields: DocTemplateField[];\n status: DocJobStatus;\n label: string;\n error: string;\n message: string;\n createdAt: number /* int64 */;\n updatedAt: number /* int64 */;\n}\n\n//////////\n// source: poc-models.go\n\nexport interface QuarterlyFinancialStatement {\n companyName: string;\n year: number /* int */;\n quarter: number /* int */;\n totalAssets: number /* float64 */;\n totalEquity: number /* float64 */;\n totalLiabilities: number /* float64 */;\n totalRevenueForPeriod: number /* float64 */;\n totalRevenuePrevPeriod: number /* float64 */;\n totalOperatingIncome: number /* float64 */;\n totalOperatingExpenses: number /* float64 */;\n profitLossForPeriod: number /* float64 */;\n}\nexport interface PassportInfo {\n firstNameEn: string;\n secondNameEn: string;\n thirdNameEn: string;\n fourthNameEn: string;\n lastNameEn: string;\n firstNameAr: string;\n secondNameAr: string;\n thirdNameAr: string;\n fourthNameAr: string;\n lastNameAr: string;\n passportNumber: string;\n nationality: string;\n dateOfBirth: string;\n expiryDate: string;\n passportType: string;\n gender: string;\n}\nexport interface QuotationAnalyzeRequest {\n fileUrls: string[];\n rfqTables: RFQTable[];\n rfqLineItems: RFQLineItem[];\n evaluationCriteria: string;\n}\nexport interface RFQAnalyzeRequest {\n fileUrl: string;\n instructions: string;\n}\nexport interface RFQAnalyzeResponse {\n rfqLineItems: RFQLineItem[];\n rfqTables: RFQTable[];\n}\nexport interface RFQTable {\n title: string;\n markdown: string;\n}\nexport interface QuotationAnalyzeResponse {\n quotationLineItems: QuotationLineItem[];\n}\nexport interface RFQLineItem {\n item_name: string;\n description: string;\n quantity: number /* int */;\n}\nexport interface QuotationLineItem {\n item_name: string;\n supplier_name: string;\n description: string;\n quantity: number /* int */;\n item_price: number /* float64 */;\n total_price: number /* float64 */;\n notes: string;\n meet_criteria: boolean;\n}\nexport interface InvoiceAnalyzeRequest {\n fileUrl: string;\n instructions: string;\n}\nexport interface InvoiceAnalyzeResponse {\n supplier_name: string;\n customer_name: string;\n invoice_date: string;\n invoice_due_date: string;\n invoice_number: string;\n invoice_total: number /* float64 */;\n invoice_items_tables: MarkdownTable[];\n}\nexport interface MarkdownTable {\n title: string;\n markdown: string;\n}\n\n//////////\n// source: search-models.go\n\n/**\n * DocumentChunk represents a chunk of analyzed document for ClickHouse\n */\nexport interface DocumentChunk {\n doc_id: string;\n title: string;\n doc_url: string;\n chunk_id: string;\n chunk_text: string;\n chunk_index: number /* uint32 */;\n embeddings: number /* float64 */[];\n citations: Citation;\n owner_email: string;\n visibility_level: string;\n created_at: string /* RFC3339 */;\n}\n/**\n * DocumentMetadata represents document-level metadata for ClickHouse\n */\nexport interface DocumentMetadata {\n doc_id: string;\n title: string;\n doc_url: string;\n total_chunks: number /* uint32 */;\n page_count: number /* uint32 */;\n from_page: number /* uint32 */;\n to_page: number /* uint32 */;\n status: string;\n model: string;\n owner_email: string;\n visibility_level: string;\n created_at: string /* RFC3339 */;\n updated_at: string /* RFC3339 */;\n}\n\n//////////\n// source: templates-models.go\n\nexport interface DocTemplate {\n id?: string /* ObjectID */;\n name: string;\n title: string;\n description?: string;\n fields: DocTemplateField[];\n validationRules?: DocTemplateValidationRule[];\n}\nexport interface DocTemplateField {\n name: string;\n title: string;\n description?: string;\n dataType: string;\n required?: boolean;\n options?: string[];\n defaultValue?: string;\n value?: any;\n validationRules?: DocTemplateValidationRule[];\n subFields?: DocTemplateField[];\n issues: string;\n}\nexport interface DocTemplateValidationRule {\n type: ValidationRuleType;\n expectedValue?: any;\n isValid: boolean;\n error?: string;\n}\nexport type ValidationRuleType = string;\nexport const ValidationRuleTypeEqual: ValidationRuleType = \"equal\";\nexport const ValidationRuleTypeGreaterThan: ValidationRuleType = \"greaterThan\";\nexport const ValidationRuleTypeLessThan: ValidationRuleType = \"lessThan\";\nexport const ValidationRuleTypeRegex: ValidationRuleType = \"regex\";\nexport const ValidationRuleTypeRequired: ValidationRuleType = \"required\";\nexport const ValidationRuleTypeNotEmpty: ValidationRuleType = \"notEmpty\";\nexport const ValidationRuleTypeNotEqual: ValidationRuleType = \"notEqual\";\nexport const ValidationRuleTypeNotExpired: ValidationRuleType = \"notExpired\";\nexport const ValidationRuleTypeCustom: ValidationRuleType = \"custom\";\n","import { File, FileSpreadsheet, FileText } from \"lucide-react\";\nexport const getFileIcon = (fileName: string) => {\n const extensionMatch = fileName.match(/\\.([^.]+)$/);\n const extension = extensionMatch ? extensionMatch[1].toLowerCase() : null;\n\n if (!extension) return <File className=\"w-8 h-8 text-gray-500\" />;\n\n switch (extension) {\n case \"pdf\":\n return <File className=\"w-8 h-8 text-red-500\" />;\n case \"doc\":\n case \"docx\":\n return <FileText className=\"w-8 h-8 text-blue-500\" />;\n case \"xls\":\n case \"xlsx\":\n return <FileSpreadsheet className=\"w-8 h-8 text-green-500\" />;\n default:\n return <File className=\"w-8 h-8 text-gray-500\" />;\n }\n};\n\nexport const getFileName = (url: string) => {\n const fileName = decodeURIComponent(url.split(\"/\").pop() ?? \"\");\n\n const cleanFileName = fileName\n .replace(/%28(\\d+)%29/g, \"($1)\") // Replace %28 and %29 with parentheses\n .replace(/[^\\w\\s().-]/g, \"\") // Remove any other special characters\n .replace(/\\s+/g, \"_\") // Replace spaces with underscores\n .replace(/-\\d+(?=\\.pdf)/g, \"\"); // Remove the trailing number before .pdf\n\n return cleanFileName;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACuOO,IAAM,sBAAoC;AAC1C,IAAM,yBAAuC;AAC7C,IAAM,sBAAoC;AAC1C,IAAM,qBAAmC;AACzC,IAAM,sBAAoC;AA4K1C,IAAM,0BAA8C;AACpD,IAAM,gCAAoD;AAC1D,IAAM,6BAAiD;AACvD,IAAM,0BAA8C;AACpD,IAAM,6BAAiD;AACvD,IAAM,6BAAiD;AACvD,IAAM,6BAAiD;AACvD,IAAM,+BAAmD;AACzD,IAAM,2BAA+C;;;AC/Z5D,0BAAgD;AAKvB;AAJlB,IAAM,cAAc,CAAC,aAAqB;AAC/C,QAAM,iBAAiB,SAAS,MAAM,YAAY;AAClD,QAAM,YAAY,iBAAiB,eAAe,CAAC,EAAE,YAAY,IAAI;AAErE,MAAI,CAAC,UAAW,QAAO,4CAAC,4BAAK,WAAU,yBAAwB;AAE/D,UAAQ,WAAW;AAAA,IACjB,KAAK;AACH,aAAO,4CAAC,4BAAK,WAAU,wBAAuB;AAAA,IAChD,KAAK;AAAA,IACL,KAAK;AACH,aAAO,4CAAC,gCAAS,WAAU,yBAAwB;AAAA,IACrD,KAAK;AAAA,IACL,KAAK;AACH,aAAO,4CAAC,uCAAgB,WAAU,0BAAyB;AAAA,IAC7D;AACE,aAAO,4CAAC,4BAAK,WAAU,yBAAwB;AAAA,EACnD;AACF;AAEO,IAAM,cAAc,CAAC,QAAgB;AAC1C,QAAM,WAAW,mBAAmB,IAAI,MAAM,GAAG,EAAE,IAAI,KAAK,EAAE;AAE9D,QAAM,gBAAgB,SACnB,QAAQ,gBAAgB,MAAM,EAC9B,QAAQ,gBAAgB,EAAE,EAC1B,QAAQ,QAAQ,GAAG,EACnB,QAAQ,kBAAkB,EAAE;AAE/B,SAAO;AACT;","names":[]}
package/dist/index.mjs ADDED
@@ -0,0 +1,60 @@
1
+ // models/docs.ts
2
+ var DocJobStatusStarted = "started";
3
+ var DocJobStatusInProgress = "in progress";
4
+ var DocJobStatusPending = "pending";
5
+ var DocJobStatusFailed = "failed";
6
+ var DocJobStatusSuccess = "success";
7
+ var ValidationRuleTypeEqual = "equal";
8
+ var ValidationRuleTypeGreaterThan = "greaterThan";
9
+ var ValidationRuleTypeLessThan = "lessThan";
10
+ var ValidationRuleTypeRegex = "regex";
11
+ var ValidationRuleTypeRequired = "required";
12
+ var ValidationRuleTypeNotEmpty = "notEmpty";
13
+ var ValidationRuleTypeNotEqual = "notEqual";
14
+ var ValidationRuleTypeNotExpired = "notExpired";
15
+ var ValidationRuleTypeCustom = "custom";
16
+
17
+ // util/index.tsx
18
+ import { File, FileSpreadsheet, FileText } from "lucide-react";
19
+ import { jsx } from "react/jsx-runtime";
20
+ var getFileIcon = (fileName) => {
21
+ const extensionMatch = fileName.match(/\.([^.]+)$/);
22
+ const extension = extensionMatch ? extensionMatch[1].toLowerCase() : null;
23
+ if (!extension) return /* @__PURE__ */ jsx(File, { className: "w-8 h-8 text-gray-500" });
24
+ switch (extension) {
25
+ case "pdf":
26
+ return /* @__PURE__ */ jsx(File, { className: "w-8 h-8 text-red-500" });
27
+ case "doc":
28
+ case "docx":
29
+ return /* @__PURE__ */ jsx(FileText, { className: "w-8 h-8 text-blue-500" });
30
+ case "xls":
31
+ case "xlsx":
32
+ return /* @__PURE__ */ jsx(FileSpreadsheet, { className: "w-8 h-8 text-green-500" });
33
+ default:
34
+ return /* @__PURE__ */ jsx(File, { className: "w-8 h-8 text-gray-500" });
35
+ }
36
+ };
37
+ var getFileName = (url) => {
38
+ const fileName = decodeURIComponent(url.split("/").pop() ?? "");
39
+ const cleanFileName = fileName.replace(/%28(\d+)%29/g, "($1)").replace(/[^\w\s().-]/g, "").replace(/\s+/g, "_").replace(/-\d+(?=\.pdf)/g, "");
40
+ return cleanFileName;
41
+ };
42
+ export {
43
+ DocJobStatusFailed,
44
+ DocJobStatusInProgress,
45
+ DocJobStatusPending,
46
+ DocJobStatusStarted,
47
+ DocJobStatusSuccess,
48
+ ValidationRuleTypeCustom,
49
+ ValidationRuleTypeEqual,
50
+ ValidationRuleTypeGreaterThan,
51
+ ValidationRuleTypeLessThan,
52
+ ValidationRuleTypeNotEmpty,
53
+ ValidationRuleTypeNotEqual,
54
+ ValidationRuleTypeNotExpired,
55
+ ValidationRuleTypeRegex,
56
+ ValidationRuleTypeRequired,
57
+ getFileIcon,
58
+ getFileName
59
+ };
60
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../models/docs.ts","../util/index.tsx"],"sourcesContent":["// Code generated by tygo. DO NOT EDIT.\nimport { Variable } from \"@elqnt/types\";\n\n//////////\n// source: api.go\n\nexport interface DocumentValidationRequest {\n fileName: string;\n templateName: string;\n docBlob: string;\n fields: DocTemplateField[];\n validationRules: DocTemplateValidationRule[];\n}\nexport interface DocumentValidationResponse {\n success: boolean;\n message: string;\n fields: DocTemplateField[];\n}\n\n//////////\n// source: azure-doc-intelligence-models.go\n\nexport interface AzureDocumentIntelligenceResponse {\n status: string;\n createdDateTime: string;\n lastUpdatedDateTime: string;\n analyzeResult: AnalyzeResult;\n}\nexport interface AnalyzeResult {\n apiVersion: string;\n modelId: string;\n stringIndexType: string;\n pages: Page[];\n content: string;\n contentFormat: string;\n Paragraphs: Paragraph[];\n Tables: Tables[];\n}\nexport interface DocumentLayout {\n paragraphs: Paragraph[];\n tables: Tables[];\n pages: PageInfo[];\n}\nexport interface Page {\n pageNumber: number /* int */;\n angle: number /* float64 */;\n width: number /* float64 */;\n height: number /* float64 */;\n unit: string;\n words: Word[];\n lines: Line[];\n}\nexport interface Line {\n content: string;\n spans: Span[];\n}\nexport interface Paragraph {\n content: string;\n role: string;\n spans: Span[];\n boundingRegions: BoundingRegion[];\n}\nexport interface BoundingRegion {\n pageNumber: number /* int */;\n polygon: number /* float64 */[];\n}\nexport interface Word {\n content: string;\n boundingBox: number /* float64 */[];\n confidence: number /* float64 */;\n span: Span;\n}\nexport interface Span {\n offset: number /* int */;\n length: number /* int */;\n}\nexport interface Tables {\n rowCount: number /* int */;\n columnCount: number /* int */;\n cells: Cells[];\n boundingRegions: BoundingRegion[];\n spans: Spans[];\n}\nexport interface Cells {\n kind?: string;\n rowIndex: number /* int */;\n columnIndex: number /* int */;\n content: string;\n boundingRegions: BoundingRegion[];\n spans: Spans[];\n elements: string[];\n}\nexport interface Spans {\n offset: number /* int */;\n length: number /* int */;\n}\n\n//////////\n// source: citations-models.go\n\n/**\n * ** our own custom types mainly for the docs ingestion\n */\nexport interface PageInfo {\n pageNumber: number /* int */;\n angle: number /* float64 */;\n width: number /* float64 */;\n height: number /* float64 */;\n unit: string;\n}\nexport interface ParagraphContent {\n paragraph_number: number /* int */;\n content: string;\n role: string;\n}\nexport interface ParagraphContentReference {\n page_number: number /* int */;\n paragraph_number: number /* int */;\n markdown_tag: string;\n}\nexport interface DocumentReference {\n URL: string;\n Title: string;\n PageNumber: number /* int */;\n ParagraphReferences: ParagraphReference[];\n}\nexport interface ParagraphReference {\n ParagraphNumber: number /* int */;\n BoundingRegions: BoundingRegion[];\n}\nexport interface DocsIngestionRequest {\n urls: string[];\n mode: string;\n brief: string;\n labels: string[];\n}\nexport interface RawAnalysisRequest {\n fileUrl: string;\n model: 'prebuilt-read' | 'prebuilt-layout';\n fromPage: number /* int */;\n toPage: number /* int */;\n outputMarkdown: boolean;\n}\n/**\n * Citation represents the citation data for a page chunk\n */\nexport interface Citation {\n boundingRegions: BoundingRegion[];\n pageInfo?: PageInfo;\n}\n/**\n * PageChunk represents a chunk of document content with its associated citations\n */\nexport interface PageChunk {\n text: string;\n citations: Citation;\n}\n\n//////////\n// source: doc-analysis-models.go\n\n/**\n * DocAnalysisConfig holds configuration for document analysis processing\n */\nexport interface DocAnalysisConfig {\n maxConcurrentEmbeddings: number /* int */;\n batchStorageSize: number /* int */;\n embeddingTimeout: any /* time.Duration */;\n}\n/**\n * DocumentAnalysisResult represents the result of analyzing a document\n */\nexport interface DocumentAnalysisResult {\n docId: string;\n success: boolean;\n message: string;\n metadata: DocumentMetadata;\n totalChunks: number /* int */;\n successCount: number /* int */;\n errorCount: number /* int */;\n status: string;\n}\nexport interface DocumentAnalysisReference {\n doc_id: string;\n url: string;\n title: string;\n}\n\n//////////\n// source: doc-flow-models.go\n\nexport interface WorkflowDocumentExtractionRequest {\n orgID: string;\n instanceID: string;\n nodeID: string;\n fileUrl: string;\n schema: any /* types.JSONSchema */;\n instructions: string;\n documentType: string;\n subType: string; // the workflow node sub type, determines the document extraction function to use\n companyID: string;\n}\nexport interface WorkflowDocumentExtractionStatus {\n status: string;\n error?: string;\n timestamp: number /* int64 */;\n percentage: number /* int */;\n}\nexport interface WorkflowDocumentExtractionResponse {\n result: { [key: string]: any};\n}\n\n//////////\n// source: jobs-models.go\n\nexport interface DocJob {\n id?: string /* ObjectID */;\n templateId: string;\n templateTitle: string;\n title: string;\n label: string;\n fields: { [key: string]: Variable };\n status: 'started' | 'pending' | 'failed' | 'success';\n progress: number /* int */;\n fileUrls: string[];\n createdAt: number /* int64 */;\n updatedAt: number /* int64 */;\n createdBy: string;\n updatedBy: string;\n}\nexport type DocJobStatus = string;\nexport const DocJobStatusStarted: DocJobStatus = \"started\";\nexport const DocJobStatusInProgress: DocJobStatus = \"in progress\";\nexport const DocJobStatusPending: DocJobStatus = \"pending\";\nexport const DocJobStatusFailed: DocJobStatus = \"failed\";\nexport const DocJobStatusSuccess: DocJobStatus = \"success\";\nexport interface DocExtractionResult {\n id?: string /* ObjectID */;\n jobId: string;\n templateId: string;\n fileUrl: string;\n fields: DocTemplateField[];\n status: DocJobStatus;\n label: string;\n error: string;\n message: string;\n createdAt: number /* int64 */;\n updatedAt: number /* int64 */;\n}\n\n//////////\n// source: poc-models.go\n\nexport interface QuarterlyFinancialStatement {\n companyName: string;\n year: number /* int */;\n quarter: number /* int */;\n totalAssets: number /* float64 */;\n totalEquity: number /* float64 */;\n totalLiabilities: number /* float64 */;\n totalRevenueForPeriod: number /* float64 */;\n totalRevenuePrevPeriod: number /* float64 */;\n totalOperatingIncome: number /* float64 */;\n totalOperatingExpenses: number /* float64 */;\n profitLossForPeriod: number /* float64 */;\n}\nexport interface PassportInfo {\n firstNameEn: string;\n secondNameEn: string;\n thirdNameEn: string;\n fourthNameEn: string;\n lastNameEn: string;\n firstNameAr: string;\n secondNameAr: string;\n thirdNameAr: string;\n fourthNameAr: string;\n lastNameAr: string;\n passportNumber: string;\n nationality: string;\n dateOfBirth: string;\n expiryDate: string;\n passportType: string;\n gender: string;\n}\nexport interface QuotationAnalyzeRequest {\n fileUrls: string[];\n rfqTables: RFQTable[];\n rfqLineItems: RFQLineItem[];\n evaluationCriteria: string;\n}\nexport interface RFQAnalyzeRequest {\n fileUrl: string;\n instructions: string;\n}\nexport interface RFQAnalyzeResponse {\n rfqLineItems: RFQLineItem[];\n rfqTables: RFQTable[];\n}\nexport interface RFQTable {\n title: string;\n markdown: string;\n}\nexport interface QuotationAnalyzeResponse {\n quotationLineItems: QuotationLineItem[];\n}\nexport interface RFQLineItem {\n item_name: string;\n description: string;\n quantity: number /* int */;\n}\nexport interface QuotationLineItem {\n item_name: string;\n supplier_name: string;\n description: string;\n quantity: number /* int */;\n item_price: number /* float64 */;\n total_price: number /* float64 */;\n notes: string;\n meet_criteria: boolean;\n}\nexport interface InvoiceAnalyzeRequest {\n fileUrl: string;\n instructions: string;\n}\nexport interface InvoiceAnalyzeResponse {\n supplier_name: string;\n customer_name: string;\n invoice_date: string;\n invoice_due_date: string;\n invoice_number: string;\n invoice_total: number /* float64 */;\n invoice_items_tables: MarkdownTable[];\n}\nexport interface MarkdownTable {\n title: string;\n markdown: string;\n}\n\n//////////\n// source: search-models.go\n\n/**\n * DocumentChunk represents a chunk of analyzed document for ClickHouse\n */\nexport interface DocumentChunk {\n doc_id: string;\n title: string;\n doc_url: string;\n chunk_id: string;\n chunk_text: string;\n chunk_index: number /* uint32 */;\n embeddings: number /* float64 */[];\n citations: Citation;\n owner_email: string;\n visibility_level: string;\n created_at: string /* RFC3339 */;\n}\n/**\n * DocumentMetadata represents document-level metadata for ClickHouse\n */\nexport interface DocumentMetadata {\n doc_id: string;\n title: string;\n doc_url: string;\n total_chunks: number /* uint32 */;\n page_count: number /* uint32 */;\n from_page: number /* uint32 */;\n to_page: number /* uint32 */;\n status: string;\n model: string;\n owner_email: string;\n visibility_level: string;\n created_at: string /* RFC3339 */;\n updated_at: string /* RFC3339 */;\n}\n\n//////////\n// source: templates-models.go\n\nexport interface DocTemplate {\n id?: string /* ObjectID */;\n name: string;\n title: string;\n description?: string;\n fields: DocTemplateField[];\n validationRules?: DocTemplateValidationRule[];\n}\nexport interface DocTemplateField {\n name: string;\n title: string;\n description?: string;\n dataType: string;\n required?: boolean;\n options?: string[];\n defaultValue?: string;\n value?: any;\n validationRules?: DocTemplateValidationRule[];\n subFields?: DocTemplateField[];\n issues: string;\n}\nexport interface DocTemplateValidationRule {\n type: ValidationRuleType;\n expectedValue?: any;\n isValid: boolean;\n error?: string;\n}\nexport type ValidationRuleType = string;\nexport const ValidationRuleTypeEqual: ValidationRuleType = \"equal\";\nexport const ValidationRuleTypeGreaterThan: ValidationRuleType = \"greaterThan\";\nexport const ValidationRuleTypeLessThan: ValidationRuleType = \"lessThan\";\nexport const ValidationRuleTypeRegex: ValidationRuleType = \"regex\";\nexport const ValidationRuleTypeRequired: ValidationRuleType = \"required\";\nexport const ValidationRuleTypeNotEmpty: ValidationRuleType = \"notEmpty\";\nexport const ValidationRuleTypeNotEqual: ValidationRuleType = \"notEqual\";\nexport const ValidationRuleTypeNotExpired: ValidationRuleType = \"notExpired\";\nexport const ValidationRuleTypeCustom: ValidationRuleType = \"custom\";\n","import { File, FileSpreadsheet, FileText } from \"lucide-react\";\nexport const getFileIcon = (fileName: string) => {\n const extensionMatch = fileName.match(/\\.([^.]+)$/);\n const extension = extensionMatch ? extensionMatch[1].toLowerCase() : null;\n\n if (!extension) return <File className=\"w-8 h-8 text-gray-500\" />;\n\n switch (extension) {\n case \"pdf\":\n return <File className=\"w-8 h-8 text-red-500\" />;\n case \"doc\":\n case \"docx\":\n return <FileText className=\"w-8 h-8 text-blue-500\" />;\n case \"xls\":\n case \"xlsx\":\n return <FileSpreadsheet className=\"w-8 h-8 text-green-500\" />;\n default:\n return <File className=\"w-8 h-8 text-gray-500\" />;\n }\n};\n\nexport const getFileName = (url: string) => {\n const fileName = decodeURIComponent(url.split(\"/\").pop() ?? \"\");\n\n const cleanFileName = fileName\n .replace(/%28(\\d+)%29/g, \"($1)\") // Replace %28 and %29 with parentheses\n .replace(/[^\\w\\s().-]/g, \"\") // Remove any other special characters\n .replace(/\\s+/g, \"_\") // Replace spaces with underscores\n .replace(/-\\d+(?=\\.pdf)/g, \"\"); // Remove the trailing number before .pdf\n\n return cleanFileName;\n};\n"],"mappings":";AAuOO,IAAM,sBAAoC;AAC1C,IAAM,yBAAuC;AAC7C,IAAM,sBAAoC;AAC1C,IAAM,qBAAmC;AACzC,IAAM,sBAAoC;AA4K1C,IAAM,0BAA8C;AACpD,IAAM,gCAAoD;AAC1D,IAAM,6BAAiD;AACvD,IAAM,0BAA8C;AACpD,IAAM,6BAAiD;AACvD,IAAM,6BAAiD;AACvD,IAAM,6BAAiD;AACvD,IAAM,+BAAmD;AACzD,IAAM,2BAA+C;;;AC/Z5D,SAAS,MAAM,iBAAiB,gBAAgB;AAKvB;AAJlB,IAAM,cAAc,CAAC,aAAqB;AAC/C,QAAM,iBAAiB,SAAS,MAAM,YAAY;AAClD,QAAM,YAAY,iBAAiB,eAAe,CAAC,EAAE,YAAY,IAAI;AAErE,MAAI,CAAC,UAAW,QAAO,oBAAC,QAAK,WAAU,yBAAwB;AAE/D,UAAQ,WAAW;AAAA,IACjB,KAAK;AACH,aAAO,oBAAC,QAAK,WAAU,wBAAuB;AAAA,IAChD,KAAK;AAAA,IACL,KAAK;AACH,aAAO,oBAAC,YAAS,WAAU,yBAAwB;AAAA,IACrD,KAAK;AAAA,IACL,KAAK;AACH,aAAO,oBAAC,mBAAgB,WAAU,0BAAyB;AAAA,IAC7D;AACE,aAAO,oBAAC,QAAK,WAAU,yBAAwB;AAAA,EACnD;AACF;AAEO,IAAM,cAAc,CAAC,QAAgB;AAC1C,QAAM,WAAW,mBAAmB,IAAI,MAAM,GAAG,EAAE,IAAI,KAAK,EAAE;AAE9D,QAAM,gBAAgB,SACnB,QAAQ,gBAAgB,MAAM,EAC9B,QAAQ,gBAAgB,EAAE,EAC1B,QAAQ,QAAQ,GAAG,EACnB,QAAQ,kBAAkB,EAAE;AAE/B,SAAO;AACT;","names":[]}
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@elqnt/docs",
3
+ "version": "1.0.0",
4
+ "description": "Document management utilities for Eloquent platform",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.mjs",
11
+ "require": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
13
+ }
14
+ },
15
+ "files": ["dist"],
16
+ "scripts": {
17
+ "build": "tsup",
18
+ "dev": "tsup --watch",
19
+ "clean": "rm -rf dist",
20
+ "typecheck": "tsc --noEmit"
21
+ },
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/Blazi-Commerce/eloquent-packages.git",
25
+ "directory": "packages/docs"
26
+ },
27
+ "dependencies": {
28
+ "@elqnt/types": "^1.0.0",
29
+ "lucide-react": "^0.483.0"
30
+ },
31
+ "peerDependencies": {
32
+ "react": "^18.0.0 || ^19.0.0"
33
+ },
34
+ "devDependencies": {
35
+ "@types/react": "^19.0.0",
36
+ "react": "^19.0.0",
37
+ "tsup": "^8.0.0",
38
+ "typescript": "^5.0.0"
39
+ }
40
+ }