@deepcitation/deepcitation-js 1.1.26 → 1.1.28

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.
Files changed (79) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +253 -253
  3. package/lib/chunk-2IZXUOQR.js +66 -0
  4. package/lib/chunk-4FGOHQFP.cjs +66 -0
  5. package/lib/chunk-CFXDRAJL.cjs +1 -0
  6. package/lib/chunk-DEUSSEFH.js +2 -0
  7. package/lib/chunk-F2MMVEVC.cjs +1 -0
  8. package/lib/chunk-J7U6YFOI.cjs +2 -0
  9. package/lib/chunk-O2XFH626.js +1 -0
  10. package/lib/chunk-RQPZSRID.js +1 -0
  11. package/lib/client/index.cjs +1 -0
  12. package/lib/client/{DeepCitation.d.ts → index.d.cts} +159 -3
  13. package/lib/client/index.d.ts +342 -2
  14. package/lib/client/index.js +1 -1
  15. package/lib/index.cjs +1 -0
  16. package/lib/index.d.cts +127 -0
  17. package/lib/index.d.ts +126 -23
  18. package/lib/index.js +1 -22
  19. package/lib/prompts/index.cjs +1 -0
  20. package/lib/prompts/index.d.cts +196 -0
  21. package/lib/prompts/index.d.ts +196 -3
  22. package/lib/prompts/index.js +1 -3
  23. package/lib/react/index.cjs +4 -0
  24. package/lib/react/index.js +4 -18
  25. package/lib/types/index.cjs +1 -0
  26. package/lib/types/index.d.cts +96 -0
  27. package/lib/types/index.d.ts +96 -11
  28. package/lib/types/index.js +1 -7
  29. package/package.json +62 -10
  30. package/lib/client/DeepCitation.js +0 -374
  31. package/lib/client/types.d.ts +0 -154
  32. package/lib/client/types.js +0 -1
  33. package/lib/parsing/normalizeCitation.d.ts +0 -5
  34. package/lib/parsing/normalizeCitation.js +0 -198
  35. package/lib/parsing/parseCitation.d.ts +0 -79
  36. package/lib/parsing/parseCitation.js +0 -431
  37. package/lib/parsing/parseWorkAround.d.ts +0 -2
  38. package/lib/parsing/parseWorkAround.js +0 -73
  39. package/lib/prompts/citationPrompts.d.ts +0 -138
  40. package/lib/prompts/citationPrompts.js +0 -168
  41. package/lib/prompts/promptCompression.d.ts +0 -14
  42. package/lib/prompts/promptCompression.js +0 -127
  43. package/lib/prompts/types.d.ts +0 -4
  44. package/lib/prompts/types.js +0 -1
  45. package/lib/react/CitationComponent.d.ts +0 -93
  46. package/lib/react/CitationComponent.js +0 -371
  47. package/lib/react/CitationVariants.d.ts +0 -132
  48. package/lib/react/CitationVariants.js +0 -284
  49. package/lib/react/DiffDisplay.d.ts +0 -10
  50. package/lib/react/DiffDisplay.js +0 -33
  51. package/lib/react/Popover.d.ts +0 -15
  52. package/lib/react/Popover.js +0 -20
  53. package/lib/react/UrlCitationComponent.d.ts +0 -83
  54. package/lib/react/UrlCitationComponent.js +0 -224
  55. package/lib/react/VerificationTabs.d.ts +0 -10
  56. package/lib/react/VerificationTabs.js +0 -36
  57. package/lib/react/icons.d.ts +0 -18
  58. package/lib/react/icons.js +0 -16
  59. package/lib/react/index.d.ts +0 -16
  60. package/lib/react/primitives.d.ts +0 -101
  61. package/lib/react/primitives.js +0 -193
  62. package/lib/react/types.d.ts +0 -283
  63. package/lib/react/types.js +0 -1
  64. package/lib/react/useSmartDiff.d.ts +0 -16
  65. package/lib/react/useSmartDiff.js +0 -64
  66. package/lib/react/utils.d.ts +0 -43
  67. package/lib/react/utils.js +0 -89
  68. package/lib/types/boxes.d.ts +0 -11
  69. package/lib/types/boxes.js +0 -1
  70. package/lib/types/citation.d.ts +0 -39
  71. package/lib/types/citation.js +0 -1
  72. package/lib/types/search.d.ts +0 -19
  73. package/lib/types/search.js +0 -1
  74. package/lib/types/verification.d.ts +0 -27
  75. package/lib/types/verification.js +0 -11
  76. package/lib/utils/diff.d.ts +0 -60
  77. package/lib/utils/diff.js +0 -414
  78. package/lib/utils/sha.d.ts +0 -10
  79. package/lib/utils/sha.js +0 -108
@@ -1,283 +0,0 @@
1
- import type { Citation, CitationStatus } from "../types/citation.js";
2
- import type { Verification } from "../types/verification.js";
3
- import type { SearchStatus } from "../types/search.js";
4
- /**
5
- * Available citation display variants.
6
- *
7
- * - `brackets`: Shows keySpan/number in brackets with blue text styling (default).
8
- * Use hideKeySpan=true for numeric-only display.
9
- * Use hideBrackets=true to hide the square brackets.
10
- * - `text`: Shows the keySpan, inherits parent text styling, no truncation, shows indicator
11
- * - `minimal`: No brackets, just display text with indicator
12
- * - `indicator`: Only the status indicator (checkmark/warning), no text
13
- */
14
- export type CitationVariant = "brackets" | "text" | "minimal" | "indicator";
15
- /**
16
- * URL fetch status for URL citations.
17
- */
18
- export type UrlFetchStatus = "verified" | "partial" | "pending" | "blocked_antibot" | "blocked_login" | "blocked_paywall" | "blocked_geo" | "blocked_rate_limit" | "error_timeout" | "error_not_found" | "error_server" | "error_network" | "unknown";
19
- /**
20
- * URL citation metadata.
21
- */
22
- export interface UrlCitationMeta {
23
- /** The full URL */
24
- url: string;
25
- /** Display domain (e.g., "example.com") */
26
- domain?: string;
27
- /** Page title if fetched */
28
- title?: string;
29
- /** Fetch/verification status */
30
- fetchStatus: UrlFetchStatus;
31
- /** When the URL was last verified */
32
- verifiedAt?: Date | string;
33
- /** HTTP status code if available */
34
- httpStatus?: number;
35
- /** Error message if applicable */
36
- errorMessage?: string;
37
- /** Favicon URL if available */
38
- faviconUrl?: string;
39
- }
40
- /**
41
- * Style configuration for the citation component.
42
- * All properties are optional class name strings.
43
- */
44
- export interface CitationStyles {
45
- /** Container wrapper class */
46
- container?: string;
47
- /** Citation number bracket wrapper */
48
- bracketWrapper?: string;
49
- /** Inner bracket content */
50
- bracketContent?: string;
51
- /** Citation text/number itself */
52
- citationText?: string;
53
- /** Verified status indicator */
54
- verifiedIcon?: string;
55
- /** Partial match indicator */
56
- partialIcon?: string;
57
- /** Pending/loading state */
58
- pendingText?: string;
59
- }
60
- /**
61
- * State classes applied based on citation verification status
62
- */
63
- export interface CitationStateClasses {
64
- /** Applied when citation is verified (found in document) */
65
- verified?: string;
66
- /** Applied when citation is a miss (not found) */
67
- miss?: string;
68
- /** Applied when citation is a partial match */
69
- partial?: string;
70
- /** Applied when citation verification is pending */
71
- pending?: string;
72
- }
73
- /**
74
- * Cursor classes for different zoom states
75
- */
76
- export interface CitationCursorClasses {
77
- zoomIn?: string;
78
- zoomOut?: string;
79
- pointer?: string;
80
- }
81
- /**
82
- * Props for the base CitationComponent
83
- */
84
- export interface BaseCitationProps {
85
- /** The citation data to display */
86
- citation: Citation;
87
- /** Child content to render before the citation bracket */
88
- children?: React.ReactNode;
89
- /** Additional class name for the container */
90
- className?: string;
91
- /** Class name for controlling inner content width */
92
- innerWidthClassName?: string;
93
- /**
94
- * When true, hides keySpan and displays citation number only. When false, displays keySpan text.
95
- * @default false
96
- */
97
- hideKeySpan?: boolean;
98
- /** Fallback display text when citation keySpan is empty */
99
- fallbackDisplay?: string | null;
100
- /** Display variant for the citation */
101
- variant?: CitationVariant;
102
- }
103
- /**
104
- * Props for URL citation component
105
- */
106
- export interface UrlCitationProps extends Omit<BaseCitationProps, "citation"> {
107
- /** URL metadata including fetch status */
108
- urlMeta: UrlCitationMeta;
109
- /** The citation data (optional, will be derived from urlMeta if not provided) */
110
- citation?: Citation;
111
- /** Whether to show the full URL on hover */
112
- showFullUrlOnHover?: boolean;
113
- /** Whether to show favicon */
114
- showFavicon?: boolean;
115
- /** Whether to show the page title instead of domain */
116
- showTitle?: boolean;
117
- /** Maximum characters for truncated display */
118
- maxDisplayLength?: number;
119
- /** Custom render for the blocked status indicator */
120
- renderBlockedIndicator?: (status: UrlFetchStatus, errorMessage?: string) => React.ReactNode;
121
- /** Click handler for the URL */
122
- onUrlClick?: (url: string, event: React.MouseEvent) => void;
123
- /** Event handlers for citation interactions */
124
- eventHandlers?: CitationEventHandlers;
125
- /** Whether tooltips should be prevented */
126
- preventTooltips?: boolean;
127
- }
128
- /**
129
- * Extended props for the citation content renderer
130
- */
131
- export interface CitationContentProps extends BaseCitationProps {
132
- /** Unique key for this citation */
133
- citationKey: string;
134
- /** Unique instance ID for this citation render */
135
- citationInstanceId: string;
136
- /** Found citation highlight data */
137
- verification: Verification | null | undefined;
138
- /** Search status */
139
- searchStatus: SearchStatus | undefined | null;
140
- /** Actual page number where citation was found */
141
- actualPageNumber?: number | null;
142
- /** Page number from citation data */
143
- citationPageNumber?: number | null;
144
- /** Unique highlight ID */
145
- highlightId?: string;
146
- /** Citation verification status */
147
- status: CitationStatus;
148
- /** Whether tooltips should be suppressed */
149
- preventTooltips?: boolean;
150
- /** Whether on mobile device */
151
- isMobile?: boolean;
152
- /** Style configuration */
153
- styles?: CitationStyles;
154
- /** State-based classes */
155
- stateClasses?: CitationStateClasses;
156
- /** Cursor classes */
157
- cursorClasses?: CitationCursorClasses;
158
- }
159
- /**
160
- * Render props for custom citation rendering
161
- */
162
- export interface CitationRenderProps {
163
- /** The citation data */
164
- citation: Citation;
165
- /** Citation verification status */
166
- status: CitationStatus;
167
- /** The citation key */
168
- citationKey: string;
169
- /** Display text for the citation */
170
- displayText: string;
171
- /** Whether this is a merged keySpan display */
172
- isMergedDisplay: boolean;
173
- }
174
- /**
175
- * Event handlers for citation interactions
176
- */
177
- export interface CitationEventHandlers {
178
- /** Called when mouse enters citation */
179
- onMouseEnter?: (citation: Citation, citationKey: string) => void;
180
- /** Called when mouse leaves citation */
181
- onMouseLeave?: (citation: Citation, citationKey: string) => void;
182
- /** Called when citation is clicked */
183
- onClick?: (citation: Citation, citationKey: string, event: React.MouseEvent | React.TouchEvent) => void;
184
- /** Called on touch end (mobile) */
185
- onTouchEnd?: (citation: Citation, citationKey: string, event: React.TouchEvent) => void;
186
- }
187
- /**
188
- * Context provided to behavior handlers for making decisions.
189
- */
190
- export interface CitationBehaviorContext {
191
- /** The citation data */
192
- citation: Citation;
193
- /** Unique key for this citation */
194
- citationKey: string;
195
- /** Verification result if available */
196
- verification: Verification | null;
197
- /** Whether the popover is currently pinned open */
198
- isTooltipExpanded: boolean;
199
- /** Whether the full-size image overlay is currently open */
200
- isImageExpanded: boolean;
201
- /** Whether a verification image is available */
202
- hasImage: boolean;
203
- }
204
- /**
205
- * Actions that can be performed by the citation component.
206
- * These are returned by behavior handlers to control component state.
207
- */
208
- export interface CitationBehaviorActions {
209
- /** Pin or unpin the popover (keeps it visible without hover) */
210
- setTooltipExpanded?: boolean;
211
- /** Open or close the full-size image overlay */
212
- setImageExpanded?: boolean | string;
213
- /** Expand or collapse the search phrases list (for miss/partial states) */
214
- setPhrasesExpanded?: boolean;
215
- }
216
- /**
217
- * Configuration for click behavior.
218
- * Return actions to perform, or `false` to prevent default behavior.
219
- */
220
- export type CitationClickBehavior = (context: CitationBehaviorContext, event: React.MouseEvent | React.TouchEvent) => CitationBehaviorActions | false | void;
221
- /**
222
- * Configuration for hover behavior.
223
- */
224
- export interface CitationHoverBehavior {
225
- /** Called when mouse enters the citation */
226
- onEnter?: (context: CitationBehaviorContext) => void;
227
- /** Called when mouse leaves the citation */
228
- onLeave?: (context: CitationBehaviorContext) => void;
229
- }
230
- /**
231
- * Configuration for customizing default citation behaviors.
232
- *
233
- * When you provide `onClick` or `onHover`, they REPLACE the corresponding default behaviors.
234
- * Use `eventHandlers` for side effects that should run alongside defaults.
235
- *
236
- * @example Custom click behavior (replaces default)
237
- * ```tsx
238
- * <CitationComponent
239
- * citation={citation}
240
- * verification={verification}
241
- * behaviorConfig={{
242
- * onClick: (context, event) => {
243
- * if (context.hasImage) {
244
- * return { setImageExpanded: true };
245
- * }
246
- * }
247
- * }}
248
- * />
249
- * ```
250
- *
251
- * @example Disable click behavior entirely
252
- * ```tsx
253
- * <CitationComponent
254
- * citation={citation}
255
- * verification={verification}
256
- * behaviorConfig={{ onClick: () => false }}
257
- * />
258
- * ```
259
- */
260
- export interface CitationBehaviorConfig {
261
- /**
262
- * Custom click behavior handler. When provided, REPLACES the default click behavior.
263
- *
264
- * Return values:
265
- * - `CitationBehaviorActions`: Apply specific state changes
266
- * - `false`: Prevent any state changes
267
- * - `void`/`undefined`: No state changes
268
- */
269
- onClick?: CitationClickBehavior;
270
- /**
271
- * Custom hover behavior handlers. When provided, REPLACE the default hover behavior.
272
- */
273
- onHover?: CitationHoverBehavior;
274
- }
275
- /**
276
- * Props for the tooltip wrapper component
277
- */
278
- export interface CitationTooltipProps {
279
- children: React.ReactNode;
280
- citation: Citation;
281
- verification?: Verification | null;
282
- shouldShowTooltip: boolean;
283
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,16 +0,0 @@
1
- export type DiffBlockType = "modified" | "added" | "removed" | "unchanged";
2
- export interface DiffPart {
3
- value: string;
4
- added?: boolean;
5
- removed?: boolean;
6
- }
7
- export interface DiffBlock {
8
- type: DiffBlockType;
9
- parts: DiffPart[];
10
- }
11
- export declare const useSmartDiff: (expected?: string, actual?: string) => {
12
- diffResult: DiffBlock[];
13
- hasDiff: boolean;
14
- similarity: number;
15
- isHighVariance: boolean;
16
- };
@@ -1,64 +0,0 @@
1
- import { diffLines, diffWordsWithSpace } from "../utils/diff.js";
2
- import { useMemo } from "react";
3
- export const useSmartDiff = (expected = "", actual = "") => {
4
- return useMemo(() => {
5
- // 1. Sanitize standard noise (CRLF, trailing spaces)
6
- const cleanExpected = (expected || "").trim().replace(/\r\n/g, "\n");
7
- const cleanActual = (actual || "").trim().replace(/\r\n/g, "\n");
8
- // 2. First Pass: Diff by LINES.
9
- // This isolates the "extra line" issue. The extra line becomes one "added" chunk,
10
- // and it prevents the tokenizer from getting confused on the rest of the text.
11
- const lineDiffs = diffLines(cleanExpected, cleanActual);
12
- // 3. Second Pass: Process the line results to find "Modifications"
13
- const processedDiffs = [];
14
- let hasDiff = false;
15
- let totalChange = 0;
16
- for (let i = 0; i < lineDiffs.length; i++) {
17
- const part = lineDiffs[i];
18
- const nextPart = lineDiffs[i + 1];
19
- // CHECK FOR MODIFICATION:
20
- // If we see a "Removed" block immediately followed by an "Added" block,
21
- // it means this specific line changed. We should DIFF WORDS inside this line.
22
- if (part.removed && nextPart && nextPart.added) {
23
- // Run word diff ONLY on this pair of lines
24
- const wordDiffs = diffWordsWithSpace(part.value, nextPart.value);
25
- processedDiffs.push({
26
- type: "modified",
27
- parts: wordDiffs,
28
- });
29
- hasDiff = true;
30
- // Calculate raw change amount for variance score
31
- totalChange += Math.abs(part.value.length - nextPart.value.length);
32
- i++; // Skip the next part since we merged it into this block
33
- }
34
- // CHECK FOR PURE ADDITION/DELETION (The "Extra Line" Scenario)
35
- else if (part.added || part.removed) {
36
- processedDiffs.push({
37
- type: part.added ? "added" : "removed",
38
- parts: [{ value: part.value, added: part.added, removed: part.removed }],
39
- });
40
- hasDiff = true;
41
- totalChange += part.value.length;
42
- }
43
- // UNCHANGED BLOCKS
44
- else {
45
- processedDiffs.push({
46
- type: "unchanged",
47
- parts: [{ value: part.value }],
48
- });
49
- }
50
- }
51
- // 4. Calculate a similarity score to decide UI defaults
52
- // 1.0 = Perfect match, 0.0 = Totally different
53
- const maxLength = Math.max(cleanExpected.length, cleanActual.length);
54
- const similarity = maxLength === 0 ? 1 : 1 - totalChange / maxLength;
55
- return {
56
- diffResult: processedDiffs,
57
- hasDiff,
58
- similarity,
59
- // If similarity is too low (< 60%), the Diff view is likely "Fruit Salad" (messy).
60
- // We can use this boolean to default the UI to the "Source" tab.
61
- isHighVariance: similarity < 0.6,
62
- };
63
- }, [expected, actual]);
64
- };
@@ -1,43 +0,0 @@
1
- import type { Citation } from "../types/citation.js";
2
- import type { Verification } from "../types/verification.js";
3
- export declare function cn(...classes: (string | undefined | null | false)[]): string;
4
- /**
5
- * Generates a unique, deterministic key for a citation based on its content.
6
- * @param citation - The citation to generate a key for
7
- * @returns A unique, deterministic key for the citation
8
- */
9
- export declare function generateCitationKey(citation: Citation): string;
10
- /**
11
- * Generates a unique, deterministic key for a verification based on its content.
12
- * @param verification - The verification to generate a key for
13
- * @returns
14
- */
15
- export declare function generateVerificationKey(verification: Verification): string;
16
- /**
17
- * Generates a unique instance ID for a citation component render.
18
- * Combines the citation key with a random suffix for uniqueness.
19
- */
20
- export declare function generateCitationInstanceId(citationKey: string): string;
21
- /**
22
- * Gets the display text for a citation based on configuration.
23
- */
24
- export declare function getCitationDisplayText(citation: Citation, options?: {
25
- hideKeySpan?: boolean;
26
- fallbackDisplay?: string | null;
27
- }): string;
28
- /**
29
- * Gets the keySpan text to display before the citation bracket.
30
- */
31
- export declare function getCitationKeySpanText(citation: Citation, options?: {
32
- hideKeySpan?: boolean;
33
- }): string;
34
- /**
35
- * Joins class names, filtering out falsy values.
36
- * This is a minimal implementation for the base component.
37
- */
38
- export declare function classNames(...classes: (string | undefined | null | false)[]): string;
39
- /**
40
- * Default padding values for citation styling.
41
- */
42
- export declare const CITATION_X_PADDING = 4;
43
- export declare const CITATION_Y_PADDING = 1;
@@ -1,89 +0,0 @@
1
- import { sha1Hash } from "../utils/sha.js";
2
- import { getCitationPageNumber } from "../parsing/normalizeCitation.js";
3
- // =============================================================================
4
- // UTILITY FUNCTIONS
5
- // =============================================================================
6
- export function cn(...classes) {
7
- return classes.filter(Boolean).join(" ");
8
- }
9
- /**
10
- * Generates a unique, deterministic key for a citation based on its content.
11
- * @param citation - The citation to generate a key for
12
- * @returns A unique, deterministic key for the citation
13
- */
14
- export function generateCitationKey(citation) {
15
- const pageNumber = citation.pageNumber || getCitationPageNumber(citation.startPageKey);
16
- const keyParts = [
17
- citation.attachmentId || "",
18
- pageNumber?.toString() || "",
19
- citation.fullPhrase || "",
20
- citation.keySpan?.toString() || "",
21
- citation.lineIds?.join(",") || "",
22
- citation.timestamps?.startTime || "",
23
- citation.timestamps?.endTime || "",
24
- ];
25
- return sha1Hash(keyParts.join("|")).slice(0, 16);
26
- }
27
- /**
28
- * Generates a unique, deterministic key for a verification based on its content.
29
- * @param verification - The verification to generate a key for
30
- * @returns
31
- */
32
- export function generateVerificationKey(verification) {
33
- const keyParts = [
34
- verification.attachmentId || "",
35
- verification.label || "",
36
- verification.verifiedFullPhrase || "",
37
- verification.verifiedKeySpan || "",
38
- verification.verifiedLineIds?.join(",") || "",
39
- verification.verifiedPageNumber?.toString() || "",
40
- verification.verifiedTimestamps?.startTime || "",
41
- verification.verifiedTimestamps?.endTime || "",
42
- verification.verifiedMatchSnippet || "",
43
- verification.hitIndexWithinPage?.toString() || "",
44
- ];
45
- return sha1Hash(keyParts.join("|")).slice(0, 16);
46
- }
47
- /**
48
- * Generates a unique instance ID for a citation component render.
49
- * Combines the citation key with a random suffix for uniqueness.
50
- */
51
- export function generateCitationInstanceId(citationKey) {
52
- const randomSuffix = Math.random().toString(36).slice(2, 11);
53
- return `${citationKey}-${randomSuffix}`;
54
- }
55
- /**
56
- * Gets the display text for a citation based on configuration.
57
- */
58
- export function getCitationDisplayText(citation, options = {}) {
59
- const { hideKeySpan = false, fallbackDisplay } = options;
60
- if (!hideKeySpan) {
61
- return (citation.keySpan?.toString() ||
62
- citation.citationNumber?.toString() ||
63
- fallbackDisplay ||
64
- "");
65
- }
66
- return citation.citationNumber?.toString() || "";
67
- }
68
- /**
69
- * Gets the keySpan text to display before the citation bracket.
70
- */
71
- export function getCitationKeySpanText(citation, options = {}) {
72
- const { hideKeySpan = false } = options;
73
- if (!hideKeySpan) {
74
- return "";
75
- }
76
- return citation.keySpan?.toString() || "";
77
- }
78
- /**
79
- * Joins class names, filtering out falsy values.
80
- * This is a minimal implementation for the base component.
81
- */
82
- export function classNames(...classes) {
83
- return classes.filter(Boolean).join(" ");
84
- }
85
- /**
86
- * Default padding values for citation styling.
87
- */
88
- export const CITATION_X_PADDING = 4;
89
- export const CITATION_Y_PADDING = 1;
@@ -1,11 +0,0 @@
1
- export interface PdfSpaceItem extends ScreenBox {
2
- text?: string;
3
- }
4
- export type IVertex = {
5
- x: number;
6
- y: number;
7
- };
8
- export interface ScreenBox extends IVertex {
9
- width: number;
10
- height: number;
11
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,39 +0,0 @@
1
- import { type ScreenBox } from "./boxes.js";
2
- import { type Verification } from "./verification.js";
3
- export type OutputImageFormat = "jpeg" | "png" | "avif" | undefined | null;
4
- export declare const DEFAULT_OUTPUT_IMAGE_FORMAT: "avif";
5
- export interface VerifyCitationResponse {
6
- verifications: {
7
- [key: string]: Verification;
8
- };
9
- }
10
- export interface VerifyCitationRequest {
11
- attachmentId: string;
12
- citations: {
13
- [key: string]: Citation;
14
- };
15
- outputImageFormat?: OutputImageFormat;
16
- apiKey?: string;
17
- }
18
- export interface Citation {
19
- attachmentId?: string;
20
- fullPhrase?: string | null;
21
- keySpan?: string | null;
22
- startPageKey?: string | null;
23
- lineIds?: number[] | null;
24
- reasoning?: string | null;
25
- selection?: ScreenBox | null;
26
- citationNumber?: number;
27
- pageNumber?: number | null;
28
- timestamps?: {
29
- endTime?: string;
30
- startTime?: string;
31
- };
32
- beforeCite?: string;
33
- }
34
- export interface CitationStatus {
35
- isVerified: boolean;
36
- isMiss: boolean;
37
- isPartialMatch: boolean;
38
- isPending: boolean;
39
- }
@@ -1 +0,0 @@
1
- export const DEFAULT_OUTPUT_IMAGE_FORMAT = "avif";
@@ -1,19 +0,0 @@
1
- export type SearchStatus = "loading" | "pending" | "not_found" | "partial_text_found" | "found" | "found_key_span_only" | "found_phrase_missed_value" | "found_on_other_page" | "found_on_other_line" | "first_word_found" | "timestamp_wip";
2
- export type SearchMethod = "exact_line_match" | "line_with_buffer" | "current_page" | "keyspan_fallback" | "adjacent_pages" | "expanded_window" | "regex_search" | "bm25_search" | "fuzzy_regex" | "first_word_fallback";
3
- export interface SearchAttempt {
4
- method: SearchMethod;
5
- success: boolean;
6
- searchPhrases: string[];
7
- pageSearched?: number;
8
- matchedPhrases?: string[];
9
- matchedVariation?: string;
10
- phraseVariations?: string[];
11
- matchQuality?: string;
12
- isPartialMatch?: boolean;
13
- matchScore?: number;
14
- matchSnippet?: string;
15
- notes?: string;
16
- startTime?: number;
17
- endTime?: number;
18
- durationMs?: number;
19
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,27 +0,0 @@
1
- import { type Citation } from "./citation.js";
2
- import { type SearchStatus, type SearchAttempt } from "./search.js";
3
- import { type PdfSpaceItem } from "./boxes.js";
4
- export declare const NOT_FOUND_VERIFICATION_INDEX = -1;
5
- export declare const PENDING_VERIFICATION_INDEX = -2;
6
- export declare const BLANK_VERIFICATION: Verification;
7
- export interface Verification {
8
- attachmentId?: string | null;
9
- label?: string | null;
10
- citation?: Citation;
11
- status?: SearchStatus | null;
12
- searchAttempts?: SearchAttempt[];
13
- highlightColor?: string | null;
14
- verifiedPageNumber?: number | null;
15
- verifiedLineIds?: number[] | null;
16
- verifiedTimestamps?: {
17
- startTime?: string;
18
- endTime?: string;
19
- } | null;
20
- verifiedFullPhrase?: string | null;
21
- verifiedKeySpan?: string | null;
22
- verifiedMatchSnippet?: string | null;
23
- hitIndexWithinPage?: number | null;
24
- pdfSpaceItem?: PdfSpaceItem;
25
- verificationImageBase64?: string | null;
26
- verifiedAt?: Date;
27
- }
@@ -1,11 +0,0 @@
1
- export const NOT_FOUND_VERIFICATION_INDEX = -1;
2
- export const PENDING_VERIFICATION_INDEX = -2;
3
- export const BLANK_VERIFICATION = {
4
- attachmentId: null,
5
- verifiedPageNumber: NOT_FOUND_VERIFICATION_INDEX,
6
- verifiedMatchSnippet: null,
7
- citation: {
8
- pageNumber: NOT_FOUND_VERIFICATION_INDEX,
9
- },
10
- status: "not_found",
11
- };
@@ -1,60 +0,0 @@
1
- /**
2
- * Custom diff implementation to replace the 'diff' npm package.
3
- * This avoids dependency issues in Firebase Functions environments.
4
- *
5
- * Implements a Myers diff algorithm with optimizations inspired by jsdiff.
6
- * @see https://github.com/kpdecker/jsdiff
7
- *
8
- * ---
9
- *
10
- * BSD 3-Clause License
11
- *
12
- * Copyright (c) 2009-2015, Kevin Decker <kpdecker@gmail.com>
13
- * All rights reserved.
14
- *
15
- * Redistribution and use in source and binary forms, with or without
16
- * modification, are permitted provided that the following conditions are met:
17
- *
18
- * 1. Redistributions of source code must retain the above copyright notice, this
19
- * list of conditions and the following disclaimer.
20
- *
21
- * 2. Redistributions in binary form must reproduce the above copyright notice,
22
- * this list of conditions and the following disclaimer in the documentation
23
- * and/or other materials provided with the distribution.
24
- *
25
- * 3. Neither the name of the copyright holder nor the names of its
26
- * contributors may be used to endorse or promote products derived from
27
- * this software without specific prior written permission.
28
- *
29
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
30
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
32
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
33
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
35
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
36
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
37
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39
- */
40
- export interface Change {
41
- value: string;
42
- added?: boolean;
43
- removed?: boolean;
44
- count?: number;
45
- }
46
- /**
47
- * Compare two strings line by line.
48
- * Similar to Diff.diffLines from the 'diff' package.
49
- */
50
- export declare function diffLines(oldStr: string, newStr: string): Change[];
51
- /**
52
- * Compare two strings word by word, preserving whitespace.
53
- * Similar to Diff.diffWordsWithSpace from the 'diff' package.
54
- *
55
- * Features matching jsdiff:
56
- * - Extended Unicode word character support
57
- * - Proper tokenization (words, whitespace runs, single punctuation)
58
- * - Whitespace deduplication in consecutive changes
59
- */
60
- export declare function diffWordsWithSpace(oldStr: string, newStr: string): Change[];