@indora-labs/redaction-react 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # indora-redaction-react
2
+ A React component library for rendering and reviewing redactions in text, audio, and video files. Provides headless, prop-driven UI components designed to embed cleanly into regulated data workflows and custom applications.
@@ -0,0 +1,191 @@
1
+ import React from 'react';
2
+
3
+ type RedactionType = 'TEXT' | 'AUDIO' | 'VIDEO';
4
+
5
+ type SpanAttribution = {
6
+ source: "policy" | "manual";
7
+ policyId: string | null;
8
+ ruleType: "REDACT" | "DETECT" | "EXCLUDE" | null;
9
+ sourceText: string | null;
10
+ target: string;
11
+ };
12
+ type Span = {
13
+ start: number;
14
+ end: number;
15
+ label: string;
16
+ attributions: SpanAttribution[];
17
+ };
18
+ type Rect = {
19
+ id: string;
20
+ page: number;
21
+ x: number;
22
+ y: number;
23
+ w: number;
24
+ h: number;
25
+ label: string;
26
+ type?: string;
27
+ reason?: string;
28
+ };
29
+ type OcrWordBox = {
30
+ x: number;
31
+ y: number;
32
+ w: number;
33
+ h: number;
34
+ str: string;
35
+ start: number;
36
+ end: number;
37
+ };
38
+ type DocumentPage = {
39
+ page: number;
40
+ /** Background surface. Keep it simple for portability. */
41
+ imageUrl: string;
42
+ /** Intrinsic size used to interpret x/y/w/h (your rect units). */
43
+ width: number;
44
+ height: number;
45
+ };
46
+ type DocumentRedactionViewerProps = {
47
+ pages: DocumentPage[];
48
+ /** Optional OCR word boxes to allow "text highlight" style selection. */
49
+ ocrByPage?: Record<number, OcrWordBox[]>;
50
+ /** Existing rects to render/edit. */
51
+ rects: Rect[];
52
+ /** Called whenever user creates/moves/resizes rects. */
53
+ onRectsChange: (next: Rect[]) => void;
54
+ /** Called when user selects a rect (optional). */
55
+ onRectSelect?: (rect: Rect | null) => void;
56
+ selectedRectId?: string | null;
57
+ /** Create rect label (optional). */
58
+ defaultRectLabel?: string;
59
+ /** If true, user can draw/create new rects. */
60
+ allowCreate?: boolean;
61
+ /** If true, user can move/resize rects. */
62
+ allowEdit?: boolean;
63
+ /** Viewer scale. (1 = native page units) */
64
+ zoom?: number;
65
+ /** Styling hooks */
66
+ className?: string;
67
+ style?: React.CSSProperties;
68
+ /** If provided, restrict selection to these pages. */
69
+ pageFilter?: (page: DocumentPage) => boolean;
70
+ /**
71
+ * If you want the selection behavior to create a rect even without OCR,
72
+ * set this true (will create a freeform drag-rectangle).
73
+ */
74
+ allowFreeformDragCreate?: boolean;
75
+ };
76
+ declare const DocumentRedactionViewer: React.FC<DocumentRedactionViewerProps>;
77
+
78
+ type PolicyRuleInput = {
79
+ id: string;
80
+ org_id: string;
81
+ doc_id: string;
82
+ session_id: string;
83
+ type: 'REDACT' | 'DETECT' | 'EXCLUDE';
84
+ target: string;
85
+ source_text: string;
86
+ source_page: number;
87
+ offset_start: number;
88
+ offset_end: number;
89
+ created_at: string;
90
+ };
91
+
92
+ interface ViewerRedactionFlag {
93
+ id: string;
94
+ type: 'PII' | 'SSN' | 'Address' | 'Phone' | 'Face' | 'License Plate' | 'Custom';
95
+ reason: string;
96
+ approved: boolean;
97
+ timestamp?: number;
98
+ coordinates?: {
99
+ x: number;
100
+ y: number;
101
+ width: number;
102
+ height: number;
103
+ };
104
+ }
105
+ declare enum ViewerIngestionMode {
106
+ Default = "default",
107
+ Policy = "policy"
108
+ }
109
+ type ViewerRedactionDecision = 'approved' | 'rejected';
110
+ interface ViewerRedactionReview {
111
+ reviewerId: string;
112
+ reviewerEmail: string;
113
+ decision: ViewerRedactionDecision;
114
+ reviewedAt: string;
115
+ comment?: string;
116
+ }
117
+ declare const RedactionReviewStatus: {
118
+ readonly Pending: "pending";
119
+ readonly Approved: "approved";
120
+ readonly Rejected: "rejected";
121
+ };
122
+ type RedactionReviewStatus = typeof RedactionReviewStatus[keyof typeof RedactionReviewStatus];
123
+ interface ViewerFileRecord {
124
+ id: string;
125
+ name: string;
126
+ size: number;
127
+ type: string;
128
+ uploadedAt: string;
129
+ department: string;
130
+ tags: string[];
131
+ relevancyScore: number;
132
+ reviewStatus: 'pending' | 'relevant' | 'irrelevant' | 'redacted';
133
+ redactionReviewStatus?: RedactionReviewStatus;
134
+ redactionReviews?: ViewerRedactionReview[];
135
+ redactionFlags: ViewerRedactionFlag[];
136
+ caseIds: string[];
137
+ pages?: number;
138
+ duration?: number;
139
+ ingestionMode?: ViewerIngestionMode;
140
+ }
141
+ interface DocumentViewerProps {
142
+ file: ViewerFileRecord;
143
+ documentUrl: string;
144
+ rects: Rect[];
145
+ rules: PolicyRuleInput[];
146
+ hideFileDetails: boolean;
147
+ hideAICaseFindings: boolean;
148
+ onRectsChange: (rects: Rect[]) => void;
149
+ onDeleteRedactionBox: (boxId: string) => void;
150
+ onClose: () => void;
151
+ onFinalizeRedaction: () => void;
152
+ onMarkRelevant?: (status: 'relevant' | 'irrelevant') => void;
153
+ }
154
+ declare const FileViewer: React.FC<DocumentViewerProps>;
155
+
156
+ type PdfRedactionViewerProps = {
157
+ pdfUrl: string;
158
+ rects: Rect[];
159
+ onRectsChange: (r: Rect[]) => void;
160
+ defaultRectLabel?: string;
161
+ /** If true, user can draw/create new rects. */
162
+ allowCreate?: boolean;
163
+ /** If true, user can move/resize rects. */
164
+ allowEdit?: boolean;
165
+ /** Viewer scale. (1 = native page units) */
166
+ zoom?: number;
167
+ /** Styling hooks */
168
+ className?: string;
169
+ style?: React.CSSProperties;
170
+ /** If provided, restrict selection to these pages. */
171
+ pageFilter?: (page: DocumentPage) => boolean;
172
+ /** Called when user selects a rect (optional). */
173
+ onRectSelect?: (rect: Rect | null) => void;
174
+ selectedRectId?: string | null;
175
+ /**
176
+ * If you want the selection behavior to create a rect even without OCR,
177
+ * set this true (will create a freeform drag-rectangle).
178
+ */
179
+ allowFreeformDragCreate?: boolean;
180
+ };
181
+ declare const PdfRedactionViewer: React.FC<PdfRedactionViewerProps>;
182
+
183
+ interface RedactionInspectorProps {
184
+ rect: Rect | null;
185
+ rules: PolicyRuleInput[];
186
+ onUpdate: (next: Rect) => void;
187
+ onDelete: (id: string) => void;
188
+ }
189
+ declare const RedactionInspector: React.FC<RedactionInspectorProps>;
190
+
191
+ export { type DocumentPage, DocumentRedactionViewer, type DocumentRedactionViewerProps, FileViewer, type OcrWordBox, PdfRedactionViewer, type PdfRedactionViewerProps, type Rect, RedactionInspector, RedactionReviewStatus, type RedactionType, type Span, type SpanAttribution, type ViewerFileRecord, ViewerIngestionMode, type ViewerRedactionDecision, type ViewerRedactionFlag, type ViewerRedactionReview };
@@ -0,0 +1,191 @@
1
+ import React from 'react';
2
+
3
+ type RedactionType = 'TEXT' | 'AUDIO' | 'VIDEO';
4
+
5
+ type SpanAttribution = {
6
+ source: "policy" | "manual";
7
+ policyId: string | null;
8
+ ruleType: "REDACT" | "DETECT" | "EXCLUDE" | null;
9
+ sourceText: string | null;
10
+ target: string;
11
+ };
12
+ type Span = {
13
+ start: number;
14
+ end: number;
15
+ label: string;
16
+ attributions: SpanAttribution[];
17
+ };
18
+ type Rect = {
19
+ id: string;
20
+ page: number;
21
+ x: number;
22
+ y: number;
23
+ w: number;
24
+ h: number;
25
+ label: string;
26
+ type?: string;
27
+ reason?: string;
28
+ };
29
+ type OcrWordBox = {
30
+ x: number;
31
+ y: number;
32
+ w: number;
33
+ h: number;
34
+ str: string;
35
+ start: number;
36
+ end: number;
37
+ };
38
+ type DocumentPage = {
39
+ page: number;
40
+ /** Background surface. Keep it simple for portability. */
41
+ imageUrl: string;
42
+ /** Intrinsic size used to interpret x/y/w/h (your rect units). */
43
+ width: number;
44
+ height: number;
45
+ };
46
+ type DocumentRedactionViewerProps = {
47
+ pages: DocumentPage[];
48
+ /** Optional OCR word boxes to allow "text highlight" style selection. */
49
+ ocrByPage?: Record<number, OcrWordBox[]>;
50
+ /** Existing rects to render/edit. */
51
+ rects: Rect[];
52
+ /** Called whenever user creates/moves/resizes rects. */
53
+ onRectsChange: (next: Rect[]) => void;
54
+ /** Called when user selects a rect (optional). */
55
+ onRectSelect?: (rect: Rect | null) => void;
56
+ selectedRectId?: string | null;
57
+ /** Create rect label (optional). */
58
+ defaultRectLabel?: string;
59
+ /** If true, user can draw/create new rects. */
60
+ allowCreate?: boolean;
61
+ /** If true, user can move/resize rects. */
62
+ allowEdit?: boolean;
63
+ /** Viewer scale. (1 = native page units) */
64
+ zoom?: number;
65
+ /** Styling hooks */
66
+ className?: string;
67
+ style?: React.CSSProperties;
68
+ /** If provided, restrict selection to these pages. */
69
+ pageFilter?: (page: DocumentPage) => boolean;
70
+ /**
71
+ * If you want the selection behavior to create a rect even without OCR,
72
+ * set this true (will create a freeform drag-rectangle).
73
+ */
74
+ allowFreeformDragCreate?: boolean;
75
+ };
76
+ declare const DocumentRedactionViewer: React.FC<DocumentRedactionViewerProps>;
77
+
78
+ type PolicyRuleInput = {
79
+ id: string;
80
+ org_id: string;
81
+ doc_id: string;
82
+ session_id: string;
83
+ type: 'REDACT' | 'DETECT' | 'EXCLUDE';
84
+ target: string;
85
+ source_text: string;
86
+ source_page: number;
87
+ offset_start: number;
88
+ offset_end: number;
89
+ created_at: string;
90
+ };
91
+
92
+ interface ViewerRedactionFlag {
93
+ id: string;
94
+ type: 'PII' | 'SSN' | 'Address' | 'Phone' | 'Face' | 'License Plate' | 'Custom';
95
+ reason: string;
96
+ approved: boolean;
97
+ timestamp?: number;
98
+ coordinates?: {
99
+ x: number;
100
+ y: number;
101
+ width: number;
102
+ height: number;
103
+ };
104
+ }
105
+ declare enum ViewerIngestionMode {
106
+ Default = "default",
107
+ Policy = "policy"
108
+ }
109
+ type ViewerRedactionDecision = 'approved' | 'rejected';
110
+ interface ViewerRedactionReview {
111
+ reviewerId: string;
112
+ reviewerEmail: string;
113
+ decision: ViewerRedactionDecision;
114
+ reviewedAt: string;
115
+ comment?: string;
116
+ }
117
+ declare const RedactionReviewStatus: {
118
+ readonly Pending: "pending";
119
+ readonly Approved: "approved";
120
+ readonly Rejected: "rejected";
121
+ };
122
+ type RedactionReviewStatus = typeof RedactionReviewStatus[keyof typeof RedactionReviewStatus];
123
+ interface ViewerFileRecord {
124
+ id: string;
125
+ name: string;
126
+ size: number;
127
+ type: string;
128
+ uploadedAt: string;
129
+ department: string;
130
+ tags: string[];
131
+ relevancyScore: number;
132
+ reviewStatus: 'pending' | 'relevant' | 'irrelevant' | 'redacted';
133
+ redactionReviewStatus?: RedactionReviewStatus;
134
+ redactionReviews?: ViewerRedactionReview[];
135
+ redactionFlags: ViewerRedactionFlag[];
136
+ caseIds: string[];
137
+ pages?: number;
138
+ duration?: number;
139
+ ingestionMode?: ViewerIngestionMode;
140
+ }
141
+ interface DocumentViewerProps {
142
+ file: ViewerFileRecord;
143
+ documentUrl: string;
144
+ rects: Rect[];
145
+ rules: PolicyRuleInput[];
146
+ hideFileDetails: boolean;
147
+ hideAICaseFindings: boolean;
148
+ onRectsChange: (rects: Rect[]) => void;
149
+ onDeleteRedactionBox: (boxId: string) => void;
150
+ onClose: () => void;
151
+ onFinalizeRedaction: () => void;
152
+ onMarkRelevant?: (status: 'relevant' | 'irrelevant') => void;
153
+ }
154
+ declare const FileViewer: React.FC<DocumentViewerProps>;
155
+
156
+ type PdfRedactionViewerProps = {
157
+ pdfUrl: string;
158
+ rects: Rect[];
159
+ onRectsChange: (r: Rect[]) => void;
160
+ defaultRectLabel?: string;
161
+ /** If true, user can draw/create new rects. */
162
+ allowCreate?: boolean;
163
+ /** If true, user can move/resize rects. */
164
+ allowEdit?: boolean;
165
+ /** Viewer scale. (1 = native page units) */
166
+ zoom?: number;
167
+ /** Styling hooks */
168
+ className?: string;
169
+ style?: React.CSSProperties;
170
+ /** If provided, restrict selection to these pages. */
171
+ pageFilter?: (page: DocumentPage) => boolean;
172
+ /** Called when user selects a rect (optional). */
173
+ onRectSelect?: (rect: Rect | null) => void;
174
+ selectedRectId?: string | null;
175
+ /**
176
+ * If you want the selection behavior to create a rect even without OCR,
177
+ * set this true (will create a freeform drag-rectangle).
178
+ */
179
+ allowFreeformDragCreate?: boolean;
180
+ };
181
+ declare const PdfRedactionViewer: React.FC<PdfRedactionViewerProps>;
182
+
183
+ interface RedactionInspectorProps {
184
+ rect: Rect | null;
185
+ rules: PolicyRuleInput[];
186
+ onUpdate: (next: Rect) => void;
187
+ onDelete: (id: string) => void;
188
+ }
189
+ declare const RedactionInspector: React.FC<RedactionInspectorProps>;
190
+
191
+ export { type DocumentPage, DocumentRedactionViewer, type DocumentRedactionViewerProps, FileViewer, type OcrWordBox, PdfRedactionViewer, type PdfRedactionViewerProps, type Rect, RedactionInspector, RedactionReviewStatus, type RedactionType, type Span, type SpanAttribution, type ViewerFileRecord, ViewerIngestionMode, type ViewerRedactionDecision, type ViewerRedactionFlag, type ViewerRedactionReview };