@retab/react 0.0.1

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,1606 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as React from 'react';
3
+ import React__default from 'react';
4
+ import { JSONSchema7 } from 'json-schema';
5
+ import * as _tanstack_react_query from '@tanstack/react-query';
6
+ import { QueryClient } from '@tanstack/react-query';
7
+ import { z } from 'zod';
8
+ import { ClassValue } from 'clsx';
9
+
10
+ interface ExtendedJSONSchema7 extends JSONSchema7 {
11
+ "X-ReasoningPrompt"?: string;
12
+ "X-ComputedField"?: boolean;
13
+ }
14
+
15
+ interface AuthError {
16
+ message: string;
17
+ code: 'NETWORK_ERROR' | 'TOKEN_FETCH_FAILED' | 'AUTH_EXPIRED' | 'UNKNOWN';
18
+ timestamp: number;
19
+ retryCount: number;
20
+ }
21
+ interface AuthConfig {
22
+ /**
23
+ * Function that returns a session token (external users implement this on their backend)
24
+ */
25
+ getToken: () => Promise<string>;
26
+ /** Base URL for Auth API (default: https://api.retab.com) */
27
+ baseUrl?: string;
28
+ /** Optional QueryClient - if not provided, one will be created */
29
+ queryClient?: QueryClient;
30
+ /** Maximum number of retry attempts for token fetch (default: 3) */
31
+ maxRetries?: number;
32
+ /** Base delay in ms for exponential backoff (default: 1000) */
33
+ retryBaseDelay?: number;
34
+ }
35
+ interface AuthContextValue {
36
+ /** Base URL for API calls */
37
+ baseUrl: string;
38
+ /** Get authentication headers with token */
39
+ getAuthHeaders: () => Promise<Record<string, string>>;
40
+ /** Authenticated fetch function */
41
+ fetchWithAuth: (url: string, options?: RequestInit) => Promise<Response>;
42
+ /** Force refresh the token (clears cache) */
43
+ refreshToken: () => Promise<void>;
44
+ /** Current auth error state (null if no error) */
45
+ authError: AuthError | null;
46
+ /** Whether currently online */
47
+ isOnline: boolean;
48
+ /** Whether token fetch is in progress */
49
+ isAuthenticating: boolean;
50
+ /** Manually retry authentication after an error */
51
+ retryAuth: () => Promise<void>;
52
+ }
53
+ declare function useAuth(): AuthContextValue;
54
+
55
+ /** ──────────────────────────────────────────────────────────────
56
+ * Project Schemas
57
+ * ────────────────────────────────────────────────────────────── */
58
+ declare const ProjectSchema: z.ZodObject<{
59
+ id: z.ZodString;
60
+ name: z.ZodString;
61
+ updated_at: z.ZodString;
62
+ published_config: z.ZodObject<{
63
+ inference_settings: z.ZodObject<{
64
+ id: z.ZodOptional<z.ZodString>;
65
+ model: z.ZodString;
66
+ temperature: z.ZodNumber;
67
+ image_resolution_dpi: z.ZodNumber;
68
+ reasoning_effort: z.ZodEnum<["minimal", "low", "medium", "high"]>;
69
+ n_consensus: z.ZodNumber;
70
+ parallel_ocr_keys: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
71
+ }, "strict", z.ZodTypeAny, {
72
+ model: string;
73
+ temperature: number;
74
+ n_consensus: number;
75
+ image_resolution_dpi: number;
76
+ reasoning_effort: "minimal" | "low" | "medium" | "high";
77
+ id?: string | undefined;
78
+ parallel_ocr_keys?: Record<string, string> | undefined;
79
+ }, {
80
+ model: string;
81
+ temperature: number;
82
+ n_consensus: number;
83
+ image_resolution_dpi: number;
84
+ reasoning_effort: "minimal" | "low" | "medium" | "high";
85
+ id?: string | undefined;
86
+ parallel_ocr_keys?: Record<string, string> | undefined;
87
+ }>;
88
+ json_schema: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodAny>>;
89
+ human_in_the_loop_criteria: z.ZodDefault<z.ZodArray<z.ZodObject<{
90
+ path: z.ZodString;
91
+ agentic_fix: z.ZodBoolean;
92
+ }, "strict", z.ZodTypeAny, {
93
+ path: string;
94
+ agentic_fix: boolean;
95
+ }, {
96
+ path: string;
97
+ agentic_fix: boolean;
98
+ }>, "many">>;
99
+ computation_spec: z.ZodObject<{
100
+ computations: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
101
+ expression: z.ZodString;
102
+ }, "strict", z.ZodTypeAny, {
103
+ expression: string;
104
+ }, {
105
+ expression: string;
106
+ }>>>;
107
+ }, "strict", z.ZodTypeAny, {
108
+ computations: Record<string, {
109
+ expression: string;
110
+ }>;
111
+ }, {
112
+ computations?: Record<string, {
113
+ expression: string;
114
+ }> | undefined;
115
+ }>;
116
+ } & {
117
+ origin: z.ZodDefault<z.ZodString>;
118
+ }, "strict", z.ZodTypeAny, {
119
+ json_schema: Record<string, any>;
120
+ inference_settings: {
121
+ model: string;
122
+ temperature: number;
123
+ n_consensus: number;
124
+ image_resolution_dpi: number;
125
+ reasoning_effort: "minimal" | "low" | "medium" | "high";
126
+ id?: string | undefined;
127
+ parallel_ocr_keys?: Record<string, string> | undefined;
128
+ };
129
+ human_in_the_loop_criteria: {
130
+ path: string;
131
+ agentic_fix: boolean;
132
+ }[];
133
+ computation_spec: {
134
+ computations: Record<string, {
135
+ expression: string;
136
+ }>;
137
+ };
138
+ origin: string;
139
+ }, {
140
+ inference_settings: {
141
+ model: string;
142
+ temperature: number;
143
+ n_consensus: number;
144
+ image_resolution_dpi: number;
145
+ reasoning_effort: "minimal" | "low" | "medium" | "high";
146
+ id?: string | undefined;
147
+ parallel_ocr_keys?: Record<string, string> | undefined;
148
+ };
149
+ computation_spec: {
150
+ computations?: Record<string, {
151
+ expression: string;
152
+ }> | undefined;
153
+ };
154
+ json_schema?: Record<string, any> | undefined;
155
+ human_in_the_loop_criteria?: {
156
+ path: string;
157
+ agentic_fix: boolean;
158
+ }[] | undefined;
159
+ origin?: string | undefined;
160
+ }>;
161
+ draft_config: z.ZodObject<{
162
+ inference_settings: z.ZodObject<{
163
+ id: z.ZodOptional<z.ZodString>;
164
+ model: z.ZodString;
165
+ temperature: z.ZodNumber;
166
+ image_resolution_dpi: z.ZodNumber;
167
+ reasoning_effort: z.ZodEnum<["minimal", "low", "medium", "high"]>;
168
+ n_consensus: z.ZodNumber;
169
+ parallel_ocr_keys: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
170
+ }, "strict", z.ZodTypeAny, {
171
+ model: string;
172
+ temperature: number;
173
+ n_consensus: number;
174
+ image_resolution_dpi: number;
175
+ reasoning_effort: "minimal" | "low" | "medium" | "high";
176
+ id?: string | undefined;
177
+ parallel_ocr_keys?: Record<string, string> | undefined;
178
+ }, {
179
+ model: string;
180
+ temperature: number;
181
+ n_consensus: number;
182
+ image_resolution_dpi: number;
183
+ reasoning_effort: "minimal" | "low" | "medium" | "high";
184
+ id?: string | undefined;
185
+ parallel_ocr_keys?: Record<string, string> | undefined;
186
+ }>;
187
+ json_schema: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodAny>>;
188
+ human_in_the_loop_criteria: z.ZodDefault<z.ZodArray<z.ZodObject<{
189
+ path: z.ZodString;
190
+ agentic_fix: z.ZodBoolean;
191
+ }, "strict", z.ZodTypeAny, {
192
+ path: string;
193
+ agentic_fix: boolean;
194
+ }, {
195
+ path: string;
196
+ agentic_fix: boolean;
197
+ }>, "many">>;
198
+ computation_spec: z.ZodObject<{
199
+ computations: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
200
+ expression: z.ZodString;
201
+ }, "strict", z.ZodTypeAny, {
202
+ expression: string;
203
+ }, {
204
+ expression: string;
205
+ }>>>;
206
+ }, "strict", z.ZodTypeAny, {
207
+ computations: Record<string, {
208
+ expression: string;
209
+ }>;
210
+ }, {
211
+ computations?: Record<string, {
212
+ expression: string;
213
+ }> | undefined;
214
+ }>;
215
+ }, "strict", z.ZodTypeAny, {
216
+ json_schema: Record<string, any>;
217
+ inference_settings: {
218
+ model: string;
219
+ temperature: number;
220
+ n_consensus: number;
221
+ image_resolution_dpi: number;
222
+ reasoning_effort: "minimal" | "low" | "medium" | "high";
223
+ id?: string | undefined;
224
+ parallel_ocr_keys?: Record<string, string> | undefined;
225
+ };
226
+ human_in_the_loop_criteria: {
227
+ path: string;
228
+ agentic_fix: boolean;
229
+ }[];
230
+ computation_spec: {
231
+ computations: Record<string, {
232
+ expression: string;
233
+ }>;
234
+ };
235
+ }, {
236
+ inference_settings: {
237
+ model: string;
238
+ temperature: number;
239
+ n_consensus: number;
240
+ image_resolution_dpi: number;
241
+ reasoning_effort: "minimal" | "low" | "medium" | "high";
242
+ id?: string | undefined;
243
+ parallel_ocr_keys?: Record<string, string> | undefined;
244
+ };
245
+ computation_spec: {
246
+ computations?: Record<string, {
247
+ expression: string;
248
+ }> | undefined;
249
+ };
250
+ json_schema?: Record<string, any> | undefined;
251
+ human_in_the_loop_criteria?: {
252
+ path: string;
253
+ agentic_fix: boolean;
254
+ }[] | undefined;
255
+ }>;
256
+ is_published: z.ZodDefault<z.ZodBoolean>;
257
+ is_schema_generated: z.ZodDefault<z.ZodBoolean>;
258
+ }, "strict", z.ZodTypeAny, {
259
+ id: string;
260
+ name: string;
261
+ updated_at: string;
262
+ published_config: {
263
+ json_schema: Record<string, any>;
264
+ inference_settings: {
265
+ model: string;
266
+ temperature: number;
267
+ n_consensus: number;
268
+ image_resolution_dpi: number;
269
+ reasoning_effort: "minimal" | "low" | "medium" | "high";
270
+ id?: string | undefined;
271
+ parallel_ocr_keys?: Record<string, string> | undefined;
272
+ };
273
+ human_in_the_loop_criteria: {
274
+ path: string;
275
+ agentic_fix: boolean;
276
+ }[];
277
+ computation_spec: {
278
+ computations: Record<string, {
279
+ expression: string;
280
+ }>;
281
+ };
282
+ origin: string;
283
+ };
284
+ draft_config: {
285
+ json_schema: Record<string, any>;
286
+ inference_settings: {
287
+ model: string;
288
+ temperature: number;
289
+ n_consensus: number;
290
+ image_resolution_dpi: number;
291
+ reasoning_effort: "minimal" | "low" | "medium" | "high";
292
+ id?: string | undefined;
293
+ parallel_ocr_keys?: Record<string, string> | undefined;
294
+ };
295
+ human_in_the_loop_criteria: {
296
+ path: string;
297
+ agentic_fix: boolean;
298
+ }[];
299
+ computation_spec: {
300
+ computations: Record<string, {
301
+ expression: string;
302
+ }>;
303
+ };
304
+ };
305
+ is_published: boolean;
306
+ is_schema_generated: boolean;
307
+ }, {
308
+ id: string;
309
+ name: string;
310
+ updated_at: string;
311
+ published_config: {
312
+ inference_settings: {
313
+ model: string;
314
+ temperature: number;
315
+ n_consensus: number;
316
+ image_resolution_dpi: number;
317
+ reasoning_effort: "minimal" | "low" | "medium" | "high";
318
+ id?: string | undefined;
319
+ parallel_ocr_keys?: Record<string, string> | undefined;
320
+ };
321
+ computation_spec: {
322
+ computations?: Record<string, {
323
+ expression: string;
324
+ }> | undefined;
325
+ };
326
+ json_schema?: Record<string, any> | undefined;
327
+ human_in_the_loop_criteria?: {
328
+ path: string;
329
+ agentic_fix: boolean;
330
+ }[] | undefined;
331
+ origin?: string | undefined;
332
+ };
333
+ draft_config: {
334
+ inference_settings: {
335
+ model: string;
336
+ temperature: number;
337
+ n_consensus: number;
338
+ image_resolution_dpi: number;
339
+ reasoning_effort: "minimal" | "low" | "medium" | "high";
340
+ id?: string | undefined;
341
+ parallel_ocr_keys?: Record<string, string> | undefined;
342
+ };
343
+ computation_spec: {
344
+ computations?: Record<string, {
345
+ expression: string;
346
+ }> | undefined;
347
+ };
348
+ json_schema?: Record<string, any> | undefined;
349
+ human_in_the_loop_criteria?: {
350
+ path: string;
351
+ agentic_fix: boolean;
352
+ }[] | undefined;
353
+ };
354
+ is_published?: boolean | undefined;
355
+ is_schema_generated?: boolean | undefined;
356
+ }>;
357
+ declare const PatchProjectRequestSchema: z.ZodObject<{
358
+ name: z.ZodOptional<z.ZodString>;
359
+ published_config: z.ZodOptional<z.ZodObject<{
360
+ inference_settings: z.ZodObject<{
361
+ id: z.ZodOptional<z.ZodString>;
362
+ model: z.ZodString;
363
+ temperature: z.ZodNumber;
364
+ image_resolution_dpi: z.ZodNumber;
365
+ reasoning_effort: z.ZodEnum<["minimal", "low", "medium", "high"]>;
366
+ n_consensus: z.ZodNumber;
367
+ parallel_ocr_keys: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
368
+ }, "strict", z.ZodTypeAny, {
369
+ model: string;
370
+ temperature: number;
371
+ n_consensus: number;
372
+ image_resolution_dpi: number;
373
+ reasoning_effort: "minimal" | "low" | "medium" | "high";
374
+ id?: string | undefined;
375
+ parallel_ocr_keys?: Record<string, string> | undefined;
376
+ }, {
377
+ model: string;
378
+ temperature: number;
379
+ n_consensus: number;
380
+ image_resolution_dpi: number;
381
+ reasoning_effort: "minimal" | "low" | "medium" | "high";
382
+ id?: string | undefined;
383
+ parallel_ocr_keys?: Record<string, string> | undefined;
384
+ }>;
385
+ json_schema: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodAny>>;
386
+ human_in_the_loop_criteria: z.ZodDefault<z.ZodArray<z.ZodObject<{
387
+ path: z.ZodString;
388
+ agentic_fix: z.ZodBoolean;
389
+ }, "strict", z.ZodTypeAny, {
390
+ path: string;
391
+ agentic_fix: boolean;
392
+ }, {
393
+ path: string;
394
+ agentic_fix: boolean;
395
+ }>, "many">>;
396
+ computation_spec: z.ZodObject<{
397
+ computations: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
398
+ expression: z.ZodString;
399
+ }, "strict", z.ZodTypeAny, {
400
+ expression: string;
401
+ }, {
402
+ expression: string;
403
+ }>>>;
404
+ }, "strict", z.ZodTypeAny, {
405
+ computations: Record<string, {
406
+ expression: string;
407
+ }>;
408
+ }, {
409
+ computations?: Record<string, {
410
+ expression: string;
411
+ }> | undefined;
412
+ }>;
413
+ } & {
414
+ origin: z.ZodDefault<z.ZodString>;
415
+ }, "strict", z.ZodTypeAny, {
416
+ json_schema: Record<string, any>;
417
+ inference_settings: {
418
+ model: string;
419
+ temperature: number;
420
+ n_consensus: number;
421
+ image_resolution_dpi: number;
422
+ reasoning_effort: "minimal" | "low" | "medium" | "high";
423
+ id?: string | undefined;
424
+ parallel_ocr_keys?: Record<string, string> | undefined;
425
+ };
426
+ human_in_the_loop_criteria: {
427
+ path: string;
428
+ agentic_fix: boolean;
429
+ }[];
430
+ computation_spec: {
431
+ computations: Record<string, {
432
+ expression: string;
433
+ }>;
434
+ };
435
+ origin: string;
436
+ }, {
437
+ inference_settings: {
438
+ model: string;
439
+ temperature: number;
440
+ n_consensus: number;
441
+ image_resolution_dpi: number;
442
+ reasoning_effort: "minimal" | "low" | "medium" | "high";
443
+ id?: string | undefined;
444
+ parallel_ocr_keys?: Record<string, string> | undefined;
445
+ };
446
+ computation_spec: {
447
+ computations?: Record<string, {
448
+ expression: string;
449
+ }> | undefined;
450
+ };
451
+ json_schema?: Record<string, any> | undefined;
452
+ human_in_the_loop_criteria?: {
453
+ path: string;
454
+ agentic_fix: boolean;
455
+ }[] | undefined;
456
+ origin?: string | undefined;
457
+ }>>;
458
+ draft_config: z.ZodOptional<z.ZodObject<{
459
+ inference_settings: z.ZodObject<{
460
+ id: z.ZodOptional<z.ZodString>;
461
+ model: z.ZodString;
462
+ temperature: z.ZodNumber;
463
+ image_resolution_dpi: z.ZodNumber;
464
+ reasoning_effort: z.ZodEnum<["minimal", "low", "medium", "high"]>;
465
+ n_consensus: z.ZodNumber;
466
+ parallel_ocr_keys: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
467
+ }, "strict", z.ZodTypeAny, {
468
+ model: string;
469
+ temperature: number;
470
+ n_consensus: number;
471
+ image_resolution_dpi: number;
472
+ reasoning_effort: "minimal" | "low" | "medium" | "high";
473
+ id?: string | undefined;
474
+ parallel_ocr_keys?: Record<string, string> | undefined;
475
+ }, {
476
+ model: string;
477
+ temperature: number;
478
+ n_consensus: number;
479
+ image_resolution_dpi: number;
480
+ reasoning_effort: "minimal" | "low" | "medium" | "high";
481
+ id?: string | undefined;
482
+ parallel_ocr_keys?: Record<string, string> | undefined;
483
+ }>;
484
+ json_schema: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodAny>>;
485
+ human_in_the_loop_criteria: z.ZodDefault<z.ZodArray<z.ZodObject<{
486
+ path: z.ZodString;
487
+ agentic_fix: z.ZodBoolean;
488
+ }, "strict", z.ZodTypeAny, {
489
+ path: string;
490
+ agentic_fix: boolean;
491
+ }, {
492
+ path: string;
493
+ agentic_fix: boolean;
494
+ }>, "many">>;
495
+ computation_spec: z.ZodObject<{
496
+ computations: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
497
+ expression: z.ZodString;
498
+ }, "strict", z.ZodTypeAny, {
499
+ expression: string;
500
+ }, {
501
+ expression: string;
502
+ }>>>;
503
+ }, "strict", z.ZodTypeAny, {
504
+ computations: Record<string, {
505
+ expression: string;
506
+ }>;
507
+ }, {
508
+ computations?: Record<string, {
509
+ expression: string;
510
+ }> | undefined;
511
+ }>;
512
+ }, "strict", z.ZodTypeAny, {
513
+ json_schema: Record<string, any>;
514
+ inference_settings: {
515
+ model: string;
516
+ temperature: number;
517
+ n_consensus: number;
518
+ image_resolution_dpi: number;
519
+ reasoning_effort: "minimal" | "low" | "medium" | "high";
520
+ id?: string | undefined;
521
+ parallel_ocr_keys?: Record<string, string> | undefined;
522
+ };
523
+ human_in_the_loop_criteria: {
524
+ path: string;
525
+ agentic_fix: boolean;
526
+ }[];
527
+ computation_spec: {
528
+ computations: Record<string, {
529
+ expression: string;
530
+ }>;
531
+ };
532
+ }, {
533
+ inference_settings: {
534
+ model: string;
535
+ temperature: number;
536
+ n_consensus: number;
537
+ image_resolution_dpi: number;
538
+ reasoning_effort: "minimal" | "low" | "medium" | "high";
539
+ id?: string | undefined;
540
+ parallel_ocr_keys?: Record<string, string> | undefined;
541
+ };
542
+ computation_spec: {
543
+ computations?: Record<string, {
544
+ expression: string;
545
+ }> | undefined;
546
+ };
547
+ json_schema?: Record<string, any> | undefined;
548
+ human_in_the_loop_criteria?: {
549
+ path: string;
550
+ agentic_fix: boolean;
551
+ }[] | undefined;
552
+ }>>;
553
+ is_published: z.ZodOptional<z.ZodBoolean>;
554
+ computation_spec: z.ZodOptional<z.ZodObject<{
555
+ computations: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
556
+ expression: z.ZodString;
557
+ }, "strict", z.ZodTypeAny, {
558
+ expression: string;
559
+ }, {
560
+ expression: string;
561
+ }>>>;
562
+ }, "strict", z.ZodTypeAny, {
563
+ computations: Record<string, {
564
+ expression: string;
565
+ }>;
566
+ }, {
567
+ computations?: Record<string, {
568
+ expression: string;
569
+ }> | undefined;
570
+ }>>;
571
+ }, "strict", z.ZodTypeAny, {
572
+ name?: string | undefined;
573
+ computation_spec?: {
574
+ computations: Record<string, {
575
+ expression: string;
576
+ }>;
577
+ } | undefined;
578
+ published_config?: {
579
+ json_schema: Record<string, any>;
580
+ inference_settings: {
581
+ model: string;
582
+ temperature: number;
583
+ n_consensus: number;
584
+ image_resolution_dpi: number;
585
+ reasoning_effort: "minimal" | "low" | "medium" | "high";
586
+ id?: string | undefined;
587
+ parallel_ocr_keys?: Record<string, string> | undefined;
588
+ };
589
+ human_in_the_loop_criteria: {
590
+ path: string;
591
+ agentic_fix: boolean;
592
+ }[];
593
+ computation_spec: {
594
+ computations: Record<string, {
595
+ expression: string;
596
+ }>;
597
+ };
598
+ origin: string;
599
+ } | undefined;
600
+ draft_config?: {
601
+ json_schema: Record<string, any>;
602
+ inference_settings: {
603
+ model: string;
604
+ temperature: number;
605
+ n_consensus: number;
606
+ image_resolution_dpi: number;
607
+ reasoning_effort: "minimal" | "low" | "medium" | "high";
608
+ id?: string | undefined;
609
+ parallel_ocr_keys?: Record<string, string> | undefined;
610
+ };
611
+ human_in_the_loop_criteria: {
612
+ path: string;
613
+ agentic_fix: boolean;
614
+ }[];
615
+ computation_spec: {
616
+ computations: Record<string, {
617
+ expression: string;
618
+ }>;
619
+ };
620
+ } | undefined;
621
+ is_published?: boolean | undefined;
622
+ }, {
623
+ name?: string | undefined;
624
+ computation_spec?: {
625
+ computations?: Record<string, {
626
+ expression: string;
627
+ }> | undefined;
628
+ } | undefined;
629
+ published_config?: {
630
+ inference_settings: {
631
+ model: string;
632
+ temperature: number;
633
+ n_consensus: number;
634
+ image_resolution_dpi: number;
635
+ reasoning_effort: "minimal" | "low" | "medium" | "high";
636
+ id?: string | undefined;
637
+ parallel_ocr_keys?: Record<string, string> | undefined;
638
+ };
639
+ computation_spec: {
640
+ computations?: Record<string, {
641
+ expression: string;
642
+ }> | undefined;
643
+ };
644
+ json_schema?: Record<string, any> | undefined;
645
+ human_in_the_loop_criteria?: {
646
+ path: string;
647
+ agentic_fix: boolean;
648
+ }[] | undefined;
649
+ origin?: string | undefined;
650
+ } | undefined;
651
+ draft_config?: {
652
+ inference_settings: {
653
+ model: string;
654
+ temperature: number;
655
+ n_consensus: number;
656
+ image_resolution_dpi: number;
657
+ reasoning_effort: "minimal" | "low" | "medium" | "high";
658
+ id?: string | undefined;
659
+ parallel_ocr_keys?: Record<string, string> | undefined;
660
+ };
661
+ computation_spec: {
662
+ computations?: Record<string, {
663
+ expression: string;
664
+ }> | undefined;
665
+ };
666
+ json_schema?: Record<string, any> | undefined;
667
+ human_in_the_loop_criteria?: {
668
+ path: string;
669
+ agentic_fix: boolean;
670
+ }[] | undefined;
671
+ } | undefined;
672
+ is_published?: boolean | undefined;
673
+ }>;
674
+ declare const DuplicateProjectRequestSchema: z.ZodObject<{
675
+ name: z.ZodOptional<z.ZodString>;
676
+ }, "strict", z.ZodTypeAny, {
677
+ name?: string | undefined;
678
+ }, {
679
+ name?: string | undefined;
680
+ }>;
681
+ /** ──────────────────────────────────────────────────────────────
682
+ * Builder Document Schemas
683
+ * ────────────────────────────────────────────────────────────── */
684
+ declare const BuilderDocumentSchema: z.ZodObject<{
685
+ id: z.ZodString;
686
+ project_id: z.ZodString;
687
+ mime_data: z.ZodObject<{
688
+ id: z.ZodString;
689
+ filename: z.ZodString;
690
+ mime_type: z.ZodString;
691
+ }, "strict", z.ZodTypeAny, {
692
+ id: string;
693
+ filename: string;
694
+ mime_type: string;
695
+ }, {
696
+ id: string;
697
+ filename: string;
698
+ mime_type: string;
699
+ }>;
700
+ prediction_data: z.ZodDefault<z.ZodObject<{
701
+ prediction: z.ZodRecord<z.ZodString, z.ZodAny>;
702
+ metadata: z.ZodOptional<z.ZodObject<{
703
+ likelihoods: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
704
+ field_locations: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
705
+ consensus_details: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodAny>, "many">>;
706
+ extraction_id: z.ZodNullable<z.ZodOptional<z.ZodString>>;
707
+ }, "strict", z.ZodTypeAny, {
708
+ likelihoods?: Record<string, any> | undefined;
709
+ field_locations?: Record<string, any> | null | undefined;
710
+ consensus_details?: Record<string, any>[] | undefined;
711
+ extraction_id?: string | null | undefined;
712
+ }, {
713
+ likelihoods?: Record<string, any> | undefined;
714
+ field_locations?: Record<string, any> | null | undefined;
715
+ consensus_details?: Record<string, any>[] | undefined;
716
+ extraction_id?: string | null | undefined;
717
+ }>>;
718
+ }, "strict", z.ZodTypeAny, {
719
+ prediction: Record<string, any>;
720
+ metadata?: {
721
+ likelihoods?: Record<string, any> | undefined;
722
+ field_locations?: Record<string, any> | null | undefined;
723
+ consensus_details?: Record<string, any>[] | undefined;
724
+ extraction_id?: string | null | undefined;
725
+ } | undefined;
726
+ }, {
727
+ prediction: Record<string, any>;
728
+ metadata?: {
729
+ likelihoods?: Record<string, any> | undefined;
730
+ field_locations?: Record<string, any> | null | undefined;
731
+ consensus_details?: Record<string, any>[] | undefined;
732
+ extraction_id?: string | null | undefined;
733
+ } | undefined;
734
+ }>>;
735
+ extraction_id: z.ZodNullable<z.ZodString>;
736
+ }, "strict", z.ZodTypeAny, {
737
+ id: string;
738
+ extraction_id: string | null;
739
+ project_id: string;
740
+ mime_data: {
741
+ id: string;
742
+ filename: string;
743
+ mime_type: string;
744
+ };
745
+ prediction_data: {
746
+ prediction: Record<string, any>;
747
+ metadata?: {
748
+ likelihoods?: Record<string, any> | undefined;
749
+ field_locations?: Record<string, any> | null | undefined;
750
+ consensus_details?: Record<string, any>[] | undefined;
751
+ extraction_id?: string | null | undefined;
752
+ } | undefined;
753
+ };
754
+ }, {
755
+ id: string;
756
+ extraction_id: string | null;
757
+ project_id: string;
758
+ mime_data: {
759
+ id: string;
760
+ filename: string;
761
+ mime_type: string;
762
+ };
763
+ prediction_data?: {
764
+ prediction: Record<string, any>;
765
+ metadata?: {
766
+ likelihoods?: Record<string, any> | undefined;
767
+ field_locations?: Record<string, any> | null | undefined;
768
+ consensus_details?: Record<string, any>[] | undefined;
769
+ extraction_id?: string | null | undefined;
770
+ } | undefined;
771
+ } | undefined;
772
+ }>;
773
+ type Project = z.infer<typeof ProjectSchema>;
774
+ type PatchProjectRequest = z.infer<typeof PatchProjectRequestSchema>;
775
+ type DuplicateProjectRequest = z.infer<typeof DuplicateProjectRequestSchema>;
776
+ type BuilderDocument = z.infer<typeof BuilderDocumentSchema>;
777
+ /** ──────────────────────────────────────────────────────────────
778
+ * Dataset Document Schemas
779
+ * ────────────────────────────────────────────────────────────── */
780
+ declare const DatasetDocumentSchema: z.ZodObject<{
781
+ id: z.ZodString;
782
+ project_id: z.ZodString;
783
+ mime_data: z.ZodObject<{
784
+ id: z.ZodString;
785
+ filename: z.ZodString;
786
+ mime_type: z.ZodString;
787
+ }, "strict", z.ZodTypeAny, {
788
+ id: string;
789
+ filename: string;
790
+ mime_type: string;
791
+ }, {
792
+ id: string;
793
+ filename: string;
794
+ mime_type: string;
795
+ }>;
796
+ prediction_data: z.ZodDefault<z.ZodObject<{
797
+ prediction: z.ZodRecord<z.ZodString, z.ZodAny>;
798
+ metadata: z.ZodOptional<z.ZodObject<{
799
+ likelihoods: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
800
+ field_locations: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
801
+ consensus_details: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodAny>, "many">>;
802
+ extraction_id: z.ZodNullable<z.ZodOptional<z.ZodString>>;
803
+ }, "strict", z.ZodTypeAny, {
804
+ likelihoods?: Record<string, any> | undefined;
805
+ field_locations?: Record<string, any> | null | undefined;
806
+ consensus_details?: Record<string, any>[] | undefined;
807
+ extraction_id?: string | null | undefined;
808
+ }, {
809
+ likelihoods?: Record<string, any> | undefined;
810
+ field_locations?: Record<string, any> | null | undefined;
811
+ consensus_details?: Record<string, any>[] | undefined;
812
+ extraction_id?: string | null | undefined;
813
+ }>>;
814
+ }, "strict", z.ZodTypeAny, {
815
+ prediction: Record<string, any>;
816
+ metadata?: {
817
+ likelihoods?: Record<string, any> | undefined;
818
+ field_locations?: Record<string, any> | null | undefined;
819
+ consensus_details?: Record<string, any>[] | undefined;
820
+ extraction_id?: string | null | undefined;
821
+ } | undefined;
822
+ }, {
823
+ prediction: Record<string, any>;
824
+ metadata?: {
825
+ likelihoods?: Record<string, any> | undefined;
826
+ field_locations?: Record<string, any> | null | undefined;
827
+ consensus_details?: Record<string, any>[] | undefined;
828
+ extraction_id?: string | null | undefined;
829
+ } | undefined;
830
+ }>>;
831
+ extraction_id: z.ZodNullable<z.ZodString>;
832
+ } & {
833
+ dataset_id: z.ZodString;
834
+ validation_flags: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodAny>>;
835
+ }, "strict", z.ZodTypeAny, {
836
+ id: string;
837
+ extraction_id: string | null;
838
+ dataset_id: string;
839
+ project_id: string;
840
+ mime_data: {
841
+ id: string;
842
+ filename: string;
843
+ mime_type: string;
844
+ };
845
+ prediction_data: {
846
+ prediction: Record<string, any>;
847
+ metadata?: {
848
+ likelihoods?: Record<string, any> | undefined;
849
+ field_locations?: Record<string, any> | null | undefined;
850
+ consensus_details?: Record<string, any>[] | undefined;
851
+ extraction_id?: string | null | undefined;
852
+ } | undefined;
853
+ };
854
+ validation_flags: Record<string, any>;
855
+ }, {
856
+ id: string;
857
+ extraction_id: string | null;
858
+ dataset_id: string;
859
+ project_id: string;
860
+ mime_data: {
861
+ id: string;
862
+ filename: string;
863
+ mime_type: string;
864
+ };
865
+ prediction_data?: {
866
+ prediction: Record<string, any>;
867
+ metadata?: {
868
+ likelihoods?: Record<string, any> | undefined;
869
+ field_locations?: Record<string, any> | null | undefined;
870
+ consensus_details?: Record<string, any>[] | undefined;
871
+ extraction_id?: string | null | undefined;
872
+ } | undefined;
873
+ } | undefined;
874
+ validation_flags?: Record<string, any> | undefined;
875
+ }>;
876
+ /** ──────────────────────────────────────────────────────────────
877
+ * Dataset Document Types
878
+ * ────────────────────────────────────────────────────────────── */
879
+ type DatasetDocument = z.infer<typeof DatasetDocumentSchema>;
880
+ /** ──────────────────────────────────────────────────────────────
881
+ * Iteration Document Schemas
882
+ * ────────────────────────────────────────────────────────────── */
883
+ declare const IterationDocumentSchema: z.ZodObject<{
884
+ id: z.ZodString;
885
+ project_id: z.ZodString;
886
+ mime_data: z.ZodObject<{
887
+ id: z.ZodString;
888
+ filename: z.ZodString;
889
+ mime_type: z.ZodString;
890
+ }, "strict", z.ZodTypeAny, {
891
+ id: string;
892
+ filename: string;
893
+ mime_type: string;
894
+ }, {
895
+ id: string;
896
+ filename: string;
897
+ mime_type: string;
898
+ }>;
899
+ prediction_data: z.ZodDefault<z.ZodObject<{
900
+ prediction: z.ZodRecord<z.ZodString, z.ZodAny>;
901
+ metadata: z.ZodOptional<z.ZodObject<{
902
+ likelihoods: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
903
+ field_locations: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
904
+ consensus_details: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodAny>, "many">>;
905
+ extraction_id: z.ZodNullable<z.ZodOptional<z.ZodString>>;
906
+ }, "strict", z.ZodTypeAny, {
907
+ likelihoods?: Record<string, any> | undefined;
908
+ field_locations?: Record<string, any> | null | undefined;
909
+ consensus_details?: Record<string, any>[] | undefined;
910
+ extraction_id?: string | null | undefined;
911
+ }, {
912
+ likelihoods?: Record<string, any> | undefined;
913
+ field_locations?: Record<string, any> | null | undefined;
914
+ consensus_details?: Record<string, any>[] | undefined;
915
+ extraction_id?: string | null | undefined;
916
+ }>>;
917
+ }, "strict", z.ZodTypeAny, {
918
+ prediction: Record<string, any>;
919
+ metadata?: {
920
+ likelihoods?: Record<string, any> | undefined;
921
+ field_locations?: Record<string, any> | null | undefined;
922
+ consensus_details?: Record<string, any>[] | undefined;
923
+ extraction_id?: string | null | undefined;
924
+ } | undefined;
925
+ }, {
926
+ prediction: Record<string, any>;
927
+ metadata?: {
928
+ likelihoods?: Record<string, any> | undefined;
929
+ field_locations?: Record<string, any> | null | undefined;
930
+ consensus_details?: Record<string, any>[] | undefined;
931
+ extraction_id?: string | null | undefined;
932
+ } | undefined;
933
+ }>>;
934
+ extraction_id: z.ZodNullable<z.ZodString>;
935
+ } & {
936
+ iteration_id: z.ZodString;
937
+ dataset_id: z.ZodString;
938
+ dataset_document_id: z.ZodString;
939
+ }, "strict", z.ZodTypeAny, {
940
+ id: string;
941
+ extraction_id: string | null;
942
+ dataset_id: string;
943
+ project_id: string;
944
+ iteration_id: string;
945
+ mime_data: {
946
+ id: string;
947
+ filename: string;
948
+ mime_type: string;
949
+ };
950
+ prediction_data: {
951
+ prediction: Record<string, any>;
952
+ metadata?: {
953
+ likelihoods?: Record<string, any> | undefined;
954
+ field_locations?: Record<string, any> | null | undefined;
955
+ consensus_details?: Record<string, any>[] | undefined;
956
+ extraction_id?: string | null | undefined;
957
+ } | undefined;
958
+ };
959
+ dataset_document_id: string;
960
+ }, {
961
+ id: string;
962
+ extraction_id: string | null;
963
+ dataset_id: string;
964
+ project_id: string;
965
+ iteration_id: string;
966
+ mime_data: {
967
+ id: string;
968
+ filename: string;
969
+ mime_type: string;
970
+ };
971
+ dataset_document_id: string;
972
+ prediction_data?: {
973
+ prediction: Record<string, any>;
974
+ metadata?: {
975
+ likelihoods?: Record<string, any> | undefined;
976
+ field_locations?: Record<string, any> | null | undefined;
977
+ consensus_details?: Record<string, any>[] | undefined;
978
+ extraction_id?: string | null | undefined;
979
+ } | undefined;
980
+ } | undefined;
981
+ }>;
982
+ /** ──────────────────────────────────────────────────────────────
983
+ * Iteration Document Types
984
+ * ────────────────────────────────────────────────────────────── */
985
+ type IterationDocument = z.infer<typeof IterationDocumentSchema>;
986
+ type TableDocument = BuilderDocument | DatasetDocument | IterationDocument;
987
+
988
+ interface ProjectContextType {
989
+ project: Project;
990
+ isLoading: boolean;
991
+ isError: boolean;
992
+ error: Error | null;
993
+ updateProject: (request: PatchProjectRequest, options?: {
994
+ optimistic?: boolean;
995
+ }) => Promise<Project>;
996
+ deleteProject: (projectId: string) => Promise<void>;
997
+ duplicateProject: (request?: DuplicateProjectRequest) => Promise<Project>;
998
+ renameProject: (name: string) => Promise<Project>;
999
+ publishProject: (origin?: string) => Promise<Project>;
1000
+ unpublishProject: () => Promise<Project>;
1001
+ refreshProject: () => void;
1002
+ batchPerformOCR: () => Promise<void>;
1003
+ autoComputeNonIterationFieldLocations: (document: TableDocument, currentIterationId: string) => Promise<void>;
1004
+ autoComputeIterationFieldLocations: (document: TableDocument, iterationId: string) => Promise<void>;
1005
+ applyComputations: (data: any) => Promise<any>;
1006
+ }
1007
+ declare function useProject(): ProjectContextType;
1008
+
1009
+ declare const ExtractionSchema: z.ZodObject<{
1010
+ id: z.ZodString;
1011
+ file: z.ZodObject<{
1012
+ id: z.ZodString;
1013
+ filename: z.ZodString;
1014
+ mime_type: z.ZodString;
1015
+ }, "strip", z.ZodTypeAny, {
1016
+ id: string;
1017
+ filename: string;
1018
+ mime_type: string;
1019
+ }, {
1020
+ id: string;
1021
+ filename: string;
1022
+ mime_type: string;
1023
+ }>;
1024
+ predictions: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>;
1025
+ predictions_draft: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>;
1026
+ human_review_status: z.ZodEnum<["success", "review_required", "reviewed"]>;
1027
+ origin: z.ZodObject<{
1028
+ type: z.ZodString;
1029
+ id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1030
+ }, "strict", z.ZodTypeAny, {
1031
+ type: string;
1032
+ id?: string | null | undefined;
1033
+ }, {
1034
+ type: string;
1035
+ id?: string | null | undefined;
1036
+ }>;
1037
+ inference_settings: z.ZodObject<{
1038
+ id: z.ZodOptional<z.ZodString>;
1039
+ model: z.ZodString;
1040
+ temperature: z.ZodNumber;
1041
+ image_resolution_dpi: z.ZodNumber;
1042
+ reasoning_effort: z.ZodEnum<["minimal", "low", "medium", "high"]>;
1043
+ n_consensus: z.ZodNumber;
1044
+ parallel_ocr_keys: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1045
+ }, "strict", z.ZodTypeAny, {
1046
+ model: string;
1047
+ temperature: number;
1048
+ n_consensus: number;
1049
+ image_resolution_dpi: number;
1050
+ reasoning_effort: "minimal" | "low" | "medium" | "high";
1051
+ id?: string | undefined;
1052
+ parallel_ocr_keys?: Record<string, string> | undefined;
1053
+ }, {
1054
+ model: string;
1055
+ temperature: number;
1056
+ n_consensus: number;
1057
+ image_resolution_dpi: number;
1058
+ reasoning_effort: "minimal" | "low" | "medium" | "high";
1059
+ id?: string | undefined;
1060
+ parallel_ocr_keys?: Record<string, string> | undefined;
1061
+ }>;
1062
+ json_schema: z.ZodRecord<z.ZodString, z.ZodAny>;
1063
+ created_at: z.ZodString;
1064
+ updated_at: z.ZodString;
1065
+ organization_id: z.ZodString;
1066
+ metadata: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>>;
1067
+ }, "strict", z.ZodTypeAny, {
1068
+ id: string;
1069
+ json_schema: Record<string, any>;
1070
+ metadata: Record<string, string>;
1071
+ updated_at: string;
1072
+ organization_id: string;
1073
+ created_at: string;
1074
+ inference_settings: {
1075
+ model: string;
1076
+ temperature: number;
1077
+ n_consensus: number;
1078
+ image_resolution_dpi: number;
1079
+ reasoning_effort: "minimal" | "low" | "medium" | "high";
1080
+ id?: string | undefined;
1081
+ parallel_ocr_keys?: Record<string, string> | undefined;
1082
+ };
1083
+ origin: {
1084
+ type: string;
1085
+ id?: string | null | undefined;
1086
+ };
1087
+ file: {
1088
+ id: string;
1089
+ filename: string;
1090
+ mime_type: string;
1091
+ };
1092
+ human_review_status: "success" | "reviewed" | "review_required";
1093
+ predictions?: Record<string, any> | null | undefined;
1094
+ predictions_draft?: Record<string, any> | null | undefined;
1095
+ }, {
1096
+ id: string;
1097
+ json_schema: Record<string, any>;
1098
+ updated_at: string;
1099
+ organization_id: string;
1100
+ created_at: string;
1101
+ inference_settings: {
1102
+ model: string;
1103
+ temperature: number;
1104
+ n_consensus: number;
1105
+ image_resolution_dpi: number;
1106
+ reasoning_effort: "minimal" | "low" | "medium" | "high";
1107
+ id?: string | undefined;
1108
+ parallel_ocr_keys?: Record<string, string> | undefined;
1109
+ };
1110
+ origin: {
1111
+ type: string;
1112
+ id?: string | null | undefined;
1113
+ };
1114
+ file: {
1115
+ id: string;
1116
+ filename: string;
1117
+ mime_type: string;
1118
+ };
1119
+ human_review_status: "success" | "reviewed" | "review_required";
1120
+ metadata?: Record<string, string> | undefined;
1121
+ predictions?: Record<string, any> | null | undefined;
1122
+ predictions_draft?: Record<string, any> | null | undefined;
1123
+ }>;
1124
+ type Extraction = z.infer<typeof ExtractionSchema>;
1125
+
1126
+ interface DateFromTo {
1127
+ from?: Date;
1128
+ to?: Date;
1129
+ }
1130
+
1131
+ interface ExtractionsContextType {
1132
+ extractions: Extraction[];
1133
+ cursors: {
1134
+ before: string | null;
1135
+ after: string | null;
1136
+ };
1137
+ meta: {
1138
+ before: string | null;
1139
+ after: string | null;
1140
+ };
1141
+ isLoading: boolean;
1142
+ isError: boolean;
1143
+ error: Error | null;
1144
+ limit: number;
1145
+ setLimit: (limit: number) => void;
1146
+ order: 'asc' | 'desc';
1147
+ setOrder: (order: 'asc' | 'desc') => void;
1148
+ originId?: string | null;
1149
+ setOriginId: (originId?: string | null) => void;
1150
+ dateRange: DateFromTo;
1151
+ setDateRange: (range: DateFromTo) => void;
1152
+ humanReviewStatus: 'success' | 'review_required' | 'reviewed' | 'all';
1153
+ setHumanReviewStatus: (status: 'success' | 'review_required' | 'reviewed' | 'all') => void;
1154
+ selectedExtractionId: string | null;
1155
+ setSelectedExtractionId: (id: string | null) => void;
1156
+ fetchNextPage: () => void;
1157
+ fetchPrevPage: () => void;
1158
+ refresh: () => void;
1159
+ setCursorsFromUrl: (cursors: {
1160
+ before: string | null;
1161
+ after: string | null;
1162
+ }) => void;
1163
+ transientUpdateExtraction: (extractionId: string, data: Partial<Extraction>) => void;
1164
+ validateExtraction: (extractionId: string) => Promise<any>;
1165
+ invalidateHumanReview: (extractionId: string) => Promise<any>;
1166
+ }
1167
+ declare function useExtractions(): ExtractionsContextType;
1168
+ declare function useOptionalExtractions(): ExtractionsContextType | undefined;
1169
+
1170
+ interface OCRContextType {
1171
+ computeFieldLocations: (documentId: string, targetDataType: 'ground_truth' | 'extraction', currentIterationId: string, data: Record<string, any>, file_id: string) => Promise<Record<string, any> | null>;
1172
+ getFieldLocationsError: (documentId: string, currentIterationId: string) => string | null;
1173
+ clearFieldLocationsError: (documentId: string, currentIterationId: string) => void;
1174
+ getFieldLocationsErrorByType: (documentId: string, dataType: 'ground_truth' | 'extraction', currentIterationId: string) => string | null;
1175
+ clearFieldLocationsErrorByType: (documentId: string, dataType: 'ground_truth' | 'extraction', currentIterationId: string) => void;
1176
+ isPerformingOCR: (documentId: string) => boolean;
1177
+ performOCR: (documentId: string, verbose: boolean) => Promise<void>;
1178
+ ocrFileUrls: Record<string, string>;
1179
+ getInMemoryFieldLocations: (documentId: string, currentIterationId: string) => Record<string, any> | null;
1180
+ getInMemoryFieldLocationsByType: (documentId: string, dataType: 'ground_truth' | 'extraction', currentIterationId: string) => Record<string, any> | null;
1181
+ inMemoryFieldLocationsRef: React.RefObject<Record<string, {
1182
+ fieldLocations: Record<string, any>;
1183
+ dataHash: string;
1184
+ }>>;
1185
+ counterFieldLocationUpdated: number;
1186
+ setCounterFieldLocationUpdated: React.Dispatch<React.SetStateAction<number>>;
1187
+ isInitializingFieldLocations: (documentId: string, currentIterationId: string) => boolean;
1188
+ autoPerformOCR: (documentId: string) => Promise<void>;
1189
+ autoComputeFieldLocations: (documentId: string, data: Record<string, any>, file_id: string, currentIterationId: string) => Promise<void>;
1190
+ refreshOCRUrl: (fileId: string) => Promise<void>;
1191
+ }
1192
+ declare function useOCR(): OCRContextType;
1193
+
1194
+ interface JsonSchemaContextType {
1195
+ jsonSchema: ExtendedJSONSchema7;
1196
+ setJsonSchema: (value: React__default.SetStateAction<ExtendedJSONSchema7>, persist?: boolean) => Promise<void>;
1197
+ computedSchema: ExtendedJSONSchema7;
1198
+ isValidSchema: boolean;
1199
+ validationErrors?: string;
1200
+ }
1201
+ declare function useJsonSchema(): JsonSchemaContextType;
1202
+
1203
+ /**
1204
+ * Configuration for the extractions list
1205
+ */
1206
+ interface ExtractionsConfig {
1207
+ /**
1208
+ * Initial number of items to fetch per page
1209
+ * @default 50
1210
+ */
1211
+ initialLimit?: number;
1212
+ /**
1213
+ * Initial sort order
1214
+ * @default 'desc'
1215
+ */
1216
+ initialOrder?: 'asc' | 'desc';
1217
+ /**
1218
+ * Initial human review status filter
1219
+ * @default 'review_required'
1220
+ */
1221
+ initialHumanStatus?: 'success' | 'review_required' | 'reviewed' | 'all';
1222
+ /**
1223
+ * Mode for extractions context
1224
+ * - 'full': Fetches and manages extraction lists
1225
+ * - 'lite': Only provides actions (like validate), no list fetching
1226
+ * @default 'full'
1227
+ */
1228
+ mode?: 'full' | 'lite';
1229
+ }
1230
+ /**
1231
+ * Configuration for JSON schema editing
1232
+ */
1233
+ interface JsonSchemaConfig {
1234
+ /**
1235
+ * Whether to enable schema updates
1236
+ * @default false
1237
+ */
1238
+ enableSchemaUpdates?: boolean;
1239
+ /**
1240
+ * Custom callback for persisting schema changes
1241
+ * If not provided and enableSchemaUpdates is false, schema updates are read-only
1242
+ */
1243
+ persistJsonSchemaCallback?: (schema: ExtendedJSONSchema7) => Promise<void>;
1244
+ /**
1245
+ * Whether to include computed fields in the schema
1246
+ * @default true
1247
+ */
1248
+ includeComputedFields?: boolean;
1249
+ }
1250
+ /**
1251
+ * Props for the RetabProvider component
1252
+ */
1253
+ interface RetabProviderProps {
1254
+ /**
1255
+ * The project ID to load context for
1256
+ */
1257
+ projectId: string;
1258
+ /**
1259
+ * Configuration for authentication
1260
+ * Required for API access
1261
+ */
1262
+ authConfig: AuthConfig;
1263
+ /**
1264
+ * Configuration for extractions context
1265
+ */
1266
+ extractionsConfig?: ExtractionsConfig;
1267
+ /**
1268
+ * Configuration for JSON schema context
1269
+ */
1270
+ jsonSchemaConfig?: JsonSchemaConfig;
1271
+ /**
1272
+ * Whether to include the OCR provider
1273
+ * @default true
1274
+ */
1275
+ enableOCR?: boolean;
1276
+ /**
1277
+ * Whether to include the extractions provider
1278
+ * @default true
1279
+ */
1280
+ enableExtractions?: boolean;
1281
+ /**
1282
+ * Whether to include the JSON schema provider
1283
+ * @default true
1284
+ */
1285
+ enableJsonSchema?: boolean;
1286
+ /**
1287
+ * Child components to render
1288
+ */
1289
+ children: React__default.ReactNode;
1290
+ }
1291
+ /**
1292
+ * RetabProvider - A centralized layout component that provides all necessary Retab contexts
1293
+ *
1294
+ * This component wraps your application with all the necessary providers for working with Retab:
1295
+ * - AuthProvider: Provides authentication and API access (QueryClient, token management)
1296
+ * - OCRProvider: Manages OCR operations and field location detection
1297
+ * - ProjectProvider: Provides project data and CRUD operations
1298
+ * - JsonSchemaEditorProvider: Manages JSON schema editing and validation
1299
+ * - ExtractionsProvider: Manages extraction lists and human-in-the-loop workflows
1300
+ *
1301
+ * @example Basic usage
1302
+ * ```tsx
1303
+ * <RetabProvider
1304
+ * projectId="proj_123"
1305
+ * authConfig={{
1306
+ * getToken: async () => await fetchTokenFromYourBackend(),
1307
+ * }}
1308
+ * >
1309
+ * <YourComponent />
1310
+ * </RetabProvider>
1311
+ * ```
1312
+ *
1313
+ * @example With custom configuration
1314
+ * ```tsx
1315
+ * <RetabProvider
1316
+ * projectId="proj_123"
1317
+ * authConfig={{
1318
+ * getToken: async () => await fetchTokenFromYourBackend(),
1319
+ * baseUrl: 'https://api.retab.com',
1320
+ * }}
1321
+ * extractionsConfig={{
1322
+ * initialLimit: 10,
1323
+ * initialOrder: 'asc',
1324
+ * initialHumanStatus: 'review_required'
1325
+ * }}
1326
+ * jsonSchemaConfig={{
1327
+ * enableSchemaUpdates: true,
1328
+ * includeComputedFields: false
1329
+ * }}
1330
+ * >
1331
+ * <YourComponent />
1332
+ * </RetabProvider>
1333
+ * ```
1334
+ *
1335
+ * @example Without certain providers
1336
+ * ```tsx
1337
+ * <RetabProvider
1338
+ * projectId="proj_123"
1339
+ * authConfig={{
1340
+ * getToken: async () => await fetchTokenFromYourBackend(),
1341
+ * }}
1342
+ * enableExtractions={false}
1343
+ * enableOCR={false}
1344
+ * >
1345
+ * <YourComponent />
1346
+ * </RetabProvider>
1347
+ * ```
1348
+ */
1349
+ declare function RetabProvider({ projectId, authConfig, extractionsConfig, jsonSchemaConfig, children, }: RetabProviderProps): react_jsx_runtime.JSX.Element;
1350
+
1351
+ /** ──────────────────────────────────────────────────────────────
1352
+ * Query Parameters
1353
+ * ────────────────────────────────────────────────────────────── */
1354
+ interface ListExtractionsParams {
1355
+ before?: string | null;
1356
+ after?: string | null;
1357
+ limit?: number;
1358
+ order?: 'asc' | 'desc';
1359
+ origin_dot_id?: string | null;
1360
+ filename?: string | null;
1361
+ from_date?: string;
1362
+ to_date?: string;
1363
+ human_review_status?: 'success' | 'review_required' | 'reviewed';
1364
+ metadata?: Record<string, string> | null;
1365
+ }
1366
+ interface ListMetadata {
1367
+ before: string | null;
1368
+ after: string | null;
1369
+ }
1370
+ interface ListExtractionsResponse {
1371
+ data: Extraction[];
1372
+ list_metadata: ListMetadata;
1373
+ }
1374
+ /** ──────────────────────────────────────────────────────────────
1375
+ * Extractions List Hook
1376
+ * ────────────────────────────────────────────────────────────── */
1377
+ declare const useExtractionList: (filters?: ListExtractionsParams, options?: {
1378
+ enabled?: boolean;
1379
+ }) => _tanstack_react_query.UseQueryResult<ListExtractionsResponse, Error>;
1380
+ /** ──────────────────────────────────────────────────────────────
1381
+ * Extraction Detail Hook
1382
+ * ────────────────────────────────────────────────────────────── */
1383
+ declare const useExtraction: (extractionId: string | null | undefined) => _tanstack_react_query.UseQueryResult<{
1384
+ id: string;
1385
+ json_schema: Record<string, any>;
1386
+ metadata: Record<string, string>;
1387
+ updated_at: string;
1388
+ organization_id: string;
1389
+ created_at: string;
1390
+ inference_settings: {
1391
+ model: string;
1392
+ temperature: number;
1393
+ n_consensus: number;
1394
+ image_resolution_dpi: number;
1395
+ reasoning_effort: "minimal" | "low" | "medium" | "high";
1396
+ id?: string | undefined;
1397
+ parallel_ocr_keys?: Record<string, string> | undefined;
1398
+ };
1399
+ origin: {
1400
+ type: string;
1401
+ id?: string | null | undefined;
1402
+ };
1403
+ file: {
1404
+ id: string;
1405
+ filename: string;
1406
+ mime_type: string;
1407
+ };
1408
+ human_review_status: "success" | "reviewed" | "review_required";
1409
+ predictions?: Record<string, any> | null | undefined;
1410
+ predictions_draft?: Record<string, any> | null | undefined;
1411
+ } | null, Error>;
1412
+
1413
+ /***********************************************************
1414
+ * Types
1415
+ ***********************************************************/
1416
+ interface FileContent {
1417
+ file: File;
1418
+ buffer: ArrayBuffer;
1419
+ unprocessed?: boolean;
1420
+ }
1421
+ interface FileData extends FileContent {
1422
+ id: string;
1423
+ }
1424
+
1425
+ /** Available view modes for extraction display */
1426
+ type ViewMode = "table" | "form" | "code";
1427
+ /** Filter field options */
1428
+ type FilterField = 'created_date' | 'status' | 'metadata';
1429
+ /** Filter operator options */
1430
+ type FilterOperator = 'after' | 'before' | 'within' | 'is' | 'is_not' | 'contains';
1431
+ /** Filter type for filtering extractions */
1432
+ interface FilterType {
1433
+ id: string;
1434
+ field: FilterField;
1435
+ operator: FilterOperator;
1436
+ value: string | Date;
1437
+ /** For date range filters (within), the end date */
1438
+ endValue?: Date;
1439
+ /** For metadata filters, the key to filter on */
1440
+ metadataKey?: string;
1441
+ }
1442
+ /** Options for controlling extraction display behavior */
1443
+ interface ExtractionDisplayOptions {
1444
+ /** View mode for the extraction data */
1445
+ view?: ViewMode;
1446
+ /** Controls whether prediction data values can be edited */
1447
+ allowEditing?: boolean;
1448
+ /** Controls whether reasoning is displayed */
1449
+ showReasoning?: boolean;
1450
+ /** If true, shows tabs to switch between views and edit/view modes */
1451
+ showTabs?: boolean;
1452
+ }
1453
+ /** Options for continue/review button */
1454
+ interface ContinueButtonOptions {
1455
+ /** Callback when continue/mark as reviewed button is clicked */
1456
+ onClick?: () => void;
1457
+ /** Label for the continue button (default: "Continue") */
1458
+ label?: string;
1459
+ }
1460
+ /** Options for streaming state */
1461
+ interface ExtractionStreamingOptions<T = unknown> {
1462
+ /** Whether we're in streaming mode */
1463
+ isActive?: boolean;
1464
+ /** Streaming data */
1465
+ data?: T;
1466
+ /** Filename being streamed */
1467
+ filename?: string;
1468
+ }
1469
+ /** Visibility options for list columns/features */
1470
+ interface VisibilityOptions {
1471
+ /** Whether to show the search input */
1472
+ search?: boolean;
1473
+ /** Whether to show the display popover */
1474
+ displayPopover?: boolean;
1475
+ /** Whether to show the status column */
1476
+ statusColumn?: boolean;
1477
+ /** Whether to show the date column */
1478
+ dateColumn?: boolean;
1479
+ /** Whether to show the filters */
1480
+ filters?: boolean;
1481
+ /** Whether to show the metadata filter option */
1482
+ metadataFilter?: boolean;
1483
+ }
1484
+ interface ExtractionComponentProps {
1485
+ extractionId?: string;
1486
+ projectId?: string;
1487
+ /** Whether this is a new extraction that requires file upload (default: false) */
1488
+ isNewExtraction?: boolean;
1489
+ /** Display options for the extraction viewer */
1490
+ extractionDisplayOptions?: ExtractionDisplayOptions;
1491
+ /** Continue button configuration */
1492
+ continueButtonOptions?: ContinueButtonOptions;
1493
+ }
1494
+ interface ExtractionReviewerVisibilityOptions {
1495
+ extractionDisplayOptions?: ExtractionDisplayOptions;
1496
+ metadataFilter?: boolean;
1497
+ search?: boolean;
1498
+ filterMenu?: boolean;
1499
+ displayMenu?: boolean;
1500
+ exportMenu?: boolean;
1501
+ uploadButton?: boolean;
1502
+ }
1503
+ interface ExtractionReviewerProps {
1504
+ /** The project ID to filter extractions */
1505
+ projectId: string;
1506
+ /** The currently selected extraction ID */
1507
+ extractionId?: string;
1508
+ /** Callback when navigation is needed */
1509
+ onNavigate: (params: {
1510
+ extractionId?: string;
1511
+ }) => void;
1512
+ /** Initial/default filters to apply */
1513
+ initialFilters?: FilterType[];
1514
+ /** Visibility options for the extraction reviewer */
1515
+ visibility?: ExtractionReviewerVisibilityOptions;
1516
+ /** Default view mode when component mounts */
1517
+ defaultView?: ViewMode;
1518
+ }
1519
+ interface ExtractionsListProps {
1520
+ /** Callback when an extraction is selected */
1521
+ onSelectExtraction?: (extraction: Extraction) => void;
1522
+ /** Callback when "new extraction" is clicked */
1523
+ onNewExtractionClick?: () => void;
1524
+ /** Title displayed in the list header */
1525
+ title?: string;
1526
+ /** Visibility options for list features */
1527
+ visibility?: VisibilityOptions;
1528
+ /** Initial/default filters to apply */
1529
+ initialFilters?: FilterType[];
1530
+ }
1531
+ interface DataComponentProps {
1532
+ extraction: Extraction | null;
1533
+ /** Callback for field path changes */
1534
+ onFieldPathChange?: (fieldPath: string) => void;
1535
+ /** Display options for the data viewer */
1536
+ extractionDisplayOptions?: ExtractionDisplayOptions;
1537
+ /** Continue button configuration */
1538
+ continueButtonOptions?: ContinueButtonOptions;
1539
+ /** Streaming state options */
1540
+ extractionStreamingOptions?: ExtractionStreamingOptions;
1541
+ }
1542
+ interface FileComponentProps {
1543
+ extraction: Extraction | null;
1544
+ fieldPath?: string | null;
1545
+ /** Streaming state options */
1546
+ extractionStreamingOptions?: ExtractionStreamingOptions<FileData | null>;
1547
+ }
1548
+ interface UploadJobsListProps$1 {
1549
+ /** Optional metadata to associate uploads with */
1550
+ metadata?: Record<string, string>;
1551
+ }
1552
+
1553
+ declare function DataComponent({ extraction, onFieldPathChange, extractionDisplayOptions, continueButtonOptions, extractionStreamingOptions, }: DataComponentProps): react_jsx_runtime.JSX.Element;
1554
+
1555
+ declare function FileComponent({ extraction, fieldPath, extractionStreamingOptions, }: FileComponentProps): react_jsx_runtime.JSX.Element;
1556
+
1557
+ declare function ExtractionComponent({ extractionId, projectId, isNewExtraction, extractionDisplayOptions: { view, allowEditing, showReasoning, showTabs, }, continueButtonOptions: { onClick: onContinueButtonClick, label: continueButtonLabel, }, }: ExtractionComponentProps): react_jsx_runtime.JSX.Element;
1558
+
1559
+ declare function ExtractionReviewer({ projectId, extractionId, onNavigate, initialFilters, visibility: { search: showSearch, metadataFilter: showMetadataFilter, filterMenu: showFilterMenu, displayMenu: showDisplayMenu, exportMenu: showExportMenu, uploadButton: showUploadButton, extractionDisplayOptions: { allowEditing, showReasoning, showTabs, }, }, defaultView, }: ExtractionReviewerProps): react_jsx_runtime.JSX.Element;
1560
+
1561
+ declare function ExtractionsList({ title, onSelectExtraction, onNewExtractionClick, visibility: { displayPopover: showDisplayPopover, statusColumn: showStatusColumn, dateColumn: showDateColumn, search: showSearch, filters: showFilters, metadataFilter: showMetadataFilter, }, initialFilters, }?: ExtractionsListProps): react_jsx_runtime.JSX.Element;
1562
+
1563
+ interface UploadJobsListProps {
1564
+ /**
1565
+ * Optional metadata to associate uploads with
1566
+ */
1567
+ metadata?: Record<string, string>;
1568
+ }
1569
+ declare function UploadJobsList({ metadata }?: UploadJobsListProps): react_jsx_runtime.JSX.Element;
1570
+
1571
+ interface AuthErrorDisplayProps {
1572
+ /** Custom class name for the container */
1573
+ className?: string;
1574
+ /** Whether to show the error inline or as a full-page overlay */
1575
+ variant?: 'inline' | 'overlay' | 'banner';
1576
+ /** Custom render function for the error state */
1577
+ renderError?: (error: AuthError, retryAuth: () => Promise<void>, isOnline: boolean) => React__default.ReactNode;
1578
+ /** Children to render when there's no error */
1579
+ children?: React__default.ReactNode;
1580
+ }
1581
+ /**
1582
+ * AuthErrorDisplay - A component that displays auth errors gracefully
1583
+ *
1584
+ * Use this component to wrap content that depends on authentication.
1585
+ * When an auth error occurs (e.g., network issues, token expiry),
1586
+ * it will display a user-friendly error message instead of crashing.
1587
+ *
1588
+ * @example Basic usage (shows error banner when there's an auth error)
1589
+ * ```tsx
1590
+ * <AuthErrorDisplay variant="banner">
1591
+ * <YourAuthenticatedContent />
1592
+ * </AuthErrorDisplay>
1593
+ * ```
1594
+ *
1595
+ * @example Full-page overlay on error
1596
+ * ```tsx
1597
+ * <AuthErrorDisplay variant="overlay">
1598
+ * <YourAuthenticatedContent />
1599
+ * </AuthErrorDisplay>
1600
+ * ```
1601
+ */
1602
+ declare function AuthErrorDisplay({ className, variant, renderError, children, }: AuthErrorDisplayProps): react_jsx_runtime.JSX.Element;
1603
+
1604
+ declare function cn(...inputs: ClassValue[]): string;
1605
+
1606
+ export { type AuthContextValue, AuthErrorDisplay, DataComponent, type DataComponentProps, ExtractionComponent, type ExtractionComponentProps, ExtractionReviewer, type ExtractionReviewerProps, type ExtractionsConfig, type ExtractionsContextType, ExtractionsList, type ExtractionsListProps, FileComponent, type FileComponentProps, type JsonSchemaConfig, type OCRContextType, type ProjectContextType, RetabProvider, type RetabProviderProps, UploadJobsList, type UploadJobsListProps$1 as UploadJobsListProps, cn, useAuth, useExtraction, useExtractionList, useExtractions, useJsonSchema, useOCR, useOptionalExtractions, useProject };