@@ -3,7 +3,8 @@ import { useLocalizedStrings } from '@papi/frontend/react';
33import { Info } from 'lucide-react' ;
44import { Button } from 'platform-bible-react' ;
55import { useCallback , useEffect , useRef , useState } from 'react' ;
6- import type { InterlinearProject } from 'interlinearizer' ;
6+ import type { InterlinearProjectSummary } from '../types/interlinear-project-summary' ;
7+ import { isInterlinearProjectSummary } from '../utils/interlinear-project-summary' ;
78
89/** Localized string keys used by {@link SelectInterlinearProjectModal}. */
910const SELECT_INTERLINEAR_PROJECT_STRING_KEYS : `%${string } %`[ ] = [
@@ -15,56 +16,6 @@ const SELECT_INTERLINEAR_PROJECT_STRING_KEYS: `%${string}%`[] = [
1516 '%interlinearizer_modal_select_info_button_label%' ,
1617] ;
1718
18- /** The subset of InterlinearProject fields this modal displays and returns. */
19- export type InterlinearProjectSummary = Pick <
20- InterlinearProject ,
21- | 'id'
22- | 'createdAt'
23- | 'sourceProjectId'
24- | 'targetProjectId'
25- | 'analysisLanguages'
26- | 'name'
27- | 'description'
28- > ;
29-
30- /** Fields of the active interlinear project persisted in WebView state. */
31- export type ActiveProjectState = Pick <
32- InterlinearProjectSummary ,
33- | 'id'
34- | 'createdAt'
35- | 'name'
36- | 'description'
37- | 'sourceProjectId'
38- | 'targetProjectId'
39- | 'analysisLanguages'
40- > ;
41-
42- /**
43- * Type guard for {@link InterlinearProjectSummary} parsed from unknown JSON.
44- *
45- * @param p - The value to test, typically a parsed JSON object of unknown shape.
46- * @returns `true` if `p` satisfies the {@link InterlinearProjectSummary} shape, narrowing its type
47- * accordingly.
48- */
49- export function isInterlinearProjectSummary ( p : unknown ) : p is InterlinearProjectSummary {
50- return (
51- ! ! p &&
52- typeof p === 'object' &&
53- 'id' in p &&
54- typeof p . id === 'string' &&
55- 'createdAt' in p &&
56- typeof p . createdAt === 'string' &&
57- 'sourceProjectId' in p &&
58- typeof p . sourceProjectId === 'string' &&
59- 'analysisLanguages' in p &&
60- Array . isArray ( p . analysisLanguages ) &&
61- p . analysisLanguages . every ( ( l ) => typeof l === 'string' ) &&
62- ( ! ( 'name' in p ) || typeof p . name === 'string' ) &&
63- ( ! ( 'description' in p ) || typeof p . description === 'string' ) &&
64- ( ! ( 'targetProjectId' in p ) || typeof p . targetProjectId === 'string' )
65- ) ;
66- }
67-
6819/**
6920 * Modal that lists all existing interlinearizer projects for a source project and lets the user
7021 * select one, view its details (via the info icon), or request that a new one be created. Fires
0 commit comments