forked from r.muellner/velum-raycast
feat: preselect all entity types except IP, Datum and Referenz
Forms and the project-file command now preselect the backend's default_entity_types from /api/entity-types instead of every type. Older backends without that field fall back to all types except IP, DATUM and REFERENZ. Saved project selections are still loaded unchanged; the project-file command keeps excluding ORT by default as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -76,6 +76,7 @@ export default function Command() {
|
|||||||
const [sessions, setSessions] = useState<VelumSession[]>([]);
|
const [sessions, setSessions] = useState<VelumSession[]>([]);
|
||||||
const [activeSessionId, setActiveSessionId] = useState<string>();
|
const [activeSessionId, setActiveSessionId] = useState<string>();
|
||||||
const [entityTypes, setEntityTypes] = useState<EntityType[]>([]);
|
const [entityTypes, setEntityTypes] = useState<EntityType[]>([]);
|
||||||
|
const [defaultEntityTypes, setDefaultEntityTypes] = useState<EntityType[]>([]);
|
||||||
const [selectedEntityTypes, setSelectedEntityTypes] = useState<string[]>([]);
|
const [selectedEntityTypes, setSelectedEntityTypes] = useState<string[]>([]);
|
||||||
const [model, setModel] = useState<string>(DEFAULT_MODEL);
|
const [model, setModel] = useState<string>(DEFAULT_MODEL);
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
@@ -99,8 +100,9 @@ export default function Command() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const loadedEntityTypes = await getEntityTypes();
|
const loadedEntityTypes = await getEntityTypes();
|
||||||
setEntityTypes(loadedEntityTypes);
|
setEntityTypes(loadedEntityTypes.all);
|
||||||
setSelectedEntityTypes(loadedEntityTypes);
|
setDefaultEntityTypes(loadedEntityTypes.defaults);
|
||||||
|
setSelectedEntityTypes(loadedEntityTypes.defaults);
|
||||||
} catch {
|
} catch {
|
||||||
setEntityTypes([]);
|
setEntityTypes([]);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -213,7 +215,8 @@ export default function Command() {
|
|||||||
placeholder="Meeting-Notizen, Stichpunkte, Transkript …"
|
placeholder="Meeting-Notizen, Stichpunkte, Transkript …"
|
||||||
/>
|
/>
|
||||||
<ContextPicker sessions={sessions} activeSessionId={activeSessionId}
|
<ContextPicker sessions={sessions} activeSessionId={activeSessionId}
|
||||||
availableEntityTypes={entityTypes} onEntityTypesChange={setSelectedEntityTypes} />
|
availableEntityTypes={entityTypes} defaultEntityTypes={defaultEntityTypes}
|
||||||
|
onEntityTypesChange={setSelectedEntityTypes} />
|
||||||
{entityTypes.length > 0 ? (
|
{entityTypes.length > 0 ? (
|
||||||
<Form.TagPicker
|
<Form.TagPicker
|
||||||
id="entityTypes"
|
id="entityTypes"
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ import { CHOOSE_CONTEXT_ID, NEW_PROJECT_ID } from "./context-values";
|
|||||||
export type { ContextFormValues } from "./context-values";
|
export type { ContextFormValues } from "./context-values";
|
||||||
|
|
||||||
export function ContextPicker(props: { sessions: VelumSession[]; activeSessionId?: string;
|
export function ContextPicker(props: { sessions: VelumSession[]; activeSessionId?: string;
|
||||||
availableEntityTypes: EntityType[]; onEntityTypesChange: (types: EntityType[]) => void }) {
|
availableEntityTypes: EntityType[]; defaultEntityTypes: EntityType[];
|
||||||
|
onEntityTypesChange: (types: EntityType[]) => void }) {
|
||||||
const [projects, setProjects] = useState<Array<{ path: string; name: string }>>([]);
|
const [projects, setProjects] = useState<Array<{ path: string; name: string }>>([]);
|
||||||
const [selected, setSelected] = useState(CHOOSE_CONTEXT_ID);
|
const [selected, setSelected] = useState(CHOOSE_CONTEXT_ID);
|
||||||
|
|
||||||
@@ -32,7 +33,7 @@ export function ContextPicker(props: { sessions: VelumSession[]; activeSessionId
|
|||||||
try {
|
try {
|
||||||
const saved = id.startsWith("project:")
|
const saved = id.startsWith("project:")
|
||||||
? await loadProjectEntityTypes(id.slice("project:".length)) : null;
|
? await loadProjectEntityTypes(id.slice("project:".length)) : null;
|
||||||
props.onEntityTypesChange(saved ?? props.availableEntityTypes);
|
props.onEntityTypesChange(saved ?? props.defaultEntityTypes);
|
||||||
setSelected(id);
|
setSelected(id);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await showToast({ style: Toast.Style.Failure,
|
await showToast({ style: Toast.Style.Failure,
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ export default function Command() {
|
|||||||
const [sessions, setSessions] = useState<VelumSession[]>([]);
|
const [sessions, setSessions] = useState<VelumSession[]>([]);
|
||||||
const [activeSessionId, setActiveSessionId] = useState<string>();
|
const [activeSessionId, setActiveSessionId] = useState<string>();
|
||||||
const [entityTypes, setEntityTypes] = useState<EntityType[]>([]);
|
const [entityTypes, setEntityTypes] = useState<EntityType[]>([]);
|
||||||
|
const [defaultEntityTypes, setDefaultEntityTypes] = useState<EntityType[]>([]);
|
||||||
const [selectedEntityTypes, setSelectedEntityTypes] = useState<string[]>([]);
|
const [selectedEntityTypes, setSelectedEntityTypes] = useState<string[]>([]);
|
||||||
const [model, setModel] = useState<string>(DEFAULT_MODEL);
|
const [model, setModel] = useState<string>(DEFAULT_MODEL);
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
@@ -104,8 +105,9 @@ export default function Command() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const loadedEntityTypes = await getEntityTypes();
|
const loadedEntityTypes = await getEntityTypes();
|
||||||
setEntityTypes(loadedEntityTypes);
|
setEntityTypes(loadedEntityTypes.all);
|
||||||
setSelectedEntityTypes(loadedEntityTypes);
|
setDefaultEntityTypes(loadedEntityTypes.defaults);
|
||||||
|
setSelectedEntityTypes(loadedEntityTypes.defaults);
|
||||||
} catch {
|
} catch {
|
||||||
setEntityTypes([]);
|
setEntityTypes([]);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -218,7 +220,8 @@ export default function Command() {
|
|||||||
placeholder="Meeting-Notizen, Email-Thread, Transkript …"
|
placeholder="Meeting-Notizen, Email-Thread, Transkript …"
|
||||||
/>
|
/>
|
||||||
<ContextPicker sessions={sessions} activeSessionId={activeSessionId}
|
<ContextPicker sessions={sessions} activeSessionId={activeSessionId}
|
||||||
availableEntityTypes={entityTypes} onEntityTypesChange={setSelectedEntityTypes} />
|
availableEntityTypes={entityTypes} defaultEntityTypes={defaultEntityTypes}
|
||||||
|
onEntityTypesChange={setSelectedEntityTypes} />
|
||||||
{entityTypes.length > 0 ? (
|
{entityTypes.length > 0 ? (
|
||||||
<Form.TagPicker
|
<Form.TagPicker
|
||||||
id="entityTypes"
|
id="entityTypes"
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ export default function Command() {
|
|||||||
const [sessions, setSessions] = useState<VelumSession[]>([]);
|
const [sessions, setSessions] = useState<VelumSession[]>([]);
|
||||||
const [activeSessionId, setActiveSessionId] = useState<string>();
|
const [activeSessionId, setActiveSessionId] = useState<string>();
|
||||||
const [entityTypes, setEntityTypes] = useState<EntityType[]>([]);
|
const [entityTypes, setEntityTypes] = useState<EntityType[]>([]);
|
||||||
|
const [defaultEntityTypes, setDefaultEntityTypes] = useState<EntityType[]>([]);
|
||||||
const [selectedEntityTypes, setSelectedEntityTypes] = useState<string[]>([]);
|
const [selectedEntityTypes, setSelectedEntityTypes] = useState<string[]>([]);
|
||||||
const [model, setModel] = useState<string>(DEFAULT_MODEL);
|
const [model, setModel] = useState<string>(DEFAULT_MODEL);
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
@@ -125,8 +126,9 @@ export default function Command() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const loadedEntityTypes = await getEntityTypes();
|
const loadedEntityTypes = await getEntityTypes();
|
||||||
setEntityTypes(loadedEntityTypes);
|
setEntityTypes(loadedEntityTypes.all);
|
||||||
setSelectedEntityTypes(loadedEntityTypes);
|
setDefaultEntityTypes(loadedEntityTypes.defaults);
|
||||||
|
setSelectedEntityTypes(loadedEntityTypes.defaults);
|
||||||
} catch {
|
} catch {
|
||||||
setEntityTypes([]);
|
setEntityTypes([]);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -278,7 +280,8 @@ export default function Command() {
|
|||||||
))}
|
))}
|
||||||
</Form.Dropdown>
|
</Form.Dropdown>
|
||||||
<ContextPicker sessions={sessions} activeSessionId={activeSessionId}
|
<ContextPicker sessions={sessions} activeSessionId={activeSessionId}
|
||||||
availableEntityTypes={entityTypes} onEntityTypesChange={setSelectedEntityTypes} />
|
availableEntityTypes={entityTypes} defaultEntityTypes={defaultEntityTypes}
|
||||||
|
onEntityTypesChange={setSelectedEntityTypes} />
|
||||||
{entityTypes.length > 0 ? (
|
{entityTypes.length > 0 ? (
|
||||||
<Form.TagPicker
|
<Form.TagPicker
|
||||||
id="entityTypes"
|
id="entityTypes"
|
||||||
|
|||||||
22
src/lib/entity-types.ts
Normal file
22
src/lib/entity-types.ts
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import type { EntityType } from "../types";
|
||||||
|
|
||||||
|
/** Fallback for Velum backends that do not report `default_entity_types` yet. */
|
||||||
|
export const DEFAULT_DISABLED_ENTITY_TYPES: readonly EntityType[] = [
|
||||||
|
"IP",
|
||||||
|
"DATUM",
|
||||||
|
"REFERENZ",
|
||||||
|
];
|
||||||
|
|
||||||
|
export type EntityTypeCatalog = { all: EntityType[]; defaults: EntityType[] };
|
||||||
|
|
||||||
|
/** Preselection for unconfigured contexts; the backend default wins when it is available. */
|
||||||
|
export function entityTypeCatalog(payload: {
|
||||||
|
entity_types: EntityType[];
|
||||||
|
default_entity_types?: EntityType[];
|
||||||
|
}): EntityTypeCatalog {
|
||||||
|
const all = payload.entity_types;
|
||||||
|
const defaults = payload.default_entity_types
|
||||||
|
? payload.default_entity_types.filter((type) => all.includes(type))
|
||||||
|
: all.filter((type) => !DEFAULT_DISABLED_ENTITY_TYPES.includes(type));
|
||||||
|
return { all, defaults };
|
||||||
|
}
|
||||||
@@ -136,6 +136,7 @@ export default function Command() {
|
|||||||
const [sessions, setSessions] = useState<VelumSession[]>([]);
|
const [sessions, setSessions] = useState<VelumSession[]>([]);
|
||||||
const [activeSessionId, setActiveSessionId] = useState<string>();
|
const [activeSessionId, setActiveSessionId] = useState<string>();
|
||||||
const [entityTypes, setEntityTypes] = useState<EntityType[]>([]);
|
const [entityTypes, setEntityTypes] = useState<EntityType[]>([]);
|
||||||
|
const [defaultEntityTypes, setDefaultEntityTypes] = useState<EntityType[]>([]);
|
||||||
const [selectedEntityTypes, setSelectedEntityTypes] = useState<string[]>([]);
|
const [selectedEntityTypes, setSelectedEntityTypes] = useState<string[]>([]);
|
||||||
const [model, setModel] = useState<string>(DEFAULT_MODEL);
|
const [model, setModel] = useState<string>(DEFAULT_MODEL);
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
@@ -164,8 +165,9 @@ export default function Command() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const loadedEntityTypes = await getEntityTypes();
|
const loadedEntityTypes = await getEntityTypes();
|
||||||
setEntityTypes(loadedEntityTypes);
|
setEntityTypes(loadedEntityTypes.all);
|
||||||
setSelectedEntityTypes(loadedEntityTypes);
|
setDefaultEntityTypes(loadedEntityTypes.defaults);
|
||||||
|
setSelectedEntityTypes(loadedEntityTypes.defaults);
|
||||||
} catch {
|
} catch {
|
||||||
setEntityTypes([]);
|
setEntityTypes([]);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -278,7 +280,8 @@ export default function Command() {
|
|||||||
placeholder="Statusmeeting-Stichpunkte, Email-Auszüge, Risiken, Zahlen, Entscheidungen …"
|
placeholder="Statusmeeting-Stichpunkte, Email-Auszüge, Risiken, Zahlen, Entscheidungen …"
|
||||||
/>
|
/>
|
||||||
<ContextPicker sessions={sessions} activeSessionId={activeSessionId}
|
<ContextPicker sessions={sessions} activeSessionId={activeSessionId}
|
||||||
availableEntityTypes={entityTypes} onEntityTypesChange={setSelectedEntityTypes} />
|
availableEntityTypes={entityTypes} defaultEntityTypes={defaultEntityTypes}
|
||||||
|
onEntityTypesChange={setSelectedEntityTypes} />
|
||||||
{entityTypes.length > 0 ? (
|
{entityTypes.length > 0 ? (
|
||||||
<Form.TagPicker
|
<Form.TagPicker
|
||||||
id="entityTypes"
|
id="entityTypes"
|
||||||
|
|||||||
@@ -472,6 +472,7 @@ export default function Command() {
|
|||||||
const [imagePolicy, setImagePolicy] = useState<ImagePolicy>(DEFAULT_IMAGE_POLICY);
|
const [imagePolicy, setImagePolicy] = useState<ImagePolicy>(DEFAULT_IMAGE_POLICY);
|
||||||
const [rules, setRules] = useState("");
|
const [rules, setRules] = useState("");
|
||||||
const [availableTypes, setAvailableTypes] = useState<EntityType[]>([]);
|
const [availableTypes, setAvailableTypes] = useState<EntityType[]>([]);
|
||||||
|
const [defaultTypes, setDefaultTypes] = useState<EntityType[]>([]);
|
||||||
const [selectedTypes, setSelectedTypes] = useState<EntityType[]>([]);
|
const [selectedTypes, setSelectedTypes] = useState<EntityType[]>([]);
|
||||||
const [typesLoaded, setTypesLoaded] = useState(false);
|
const [typesLoaded, setTypesLoaded] = useState(false);
|
||||||
const [typesReadyFor, setTypesReadyFor] = useState<string | null>(null);
|
const [typesReadyFor, setTypesReadyFor] = useState<string | null>(null);
|
||||||
@@ -482,14 +483,15 @@ export default function Command() {
|
|||||||
useEffect(() => { finderFolder().then((path) => { if (path) setRoot((current) => current || path); }); }, []);
|
useEffect(() => { finderFolder().then((path) => { if (path) setRoot((current) => current || path); }); }, []);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getEntityTypes().then((types) => {
|
getEntityTypes().then((types) => {
|
||||||
setAvailableTypes(types);
|
setAvailableTypes(types.all);
|
||||||
|
setDefaultTypes(types.defaults);
|
||||||
setTypesLoaded(true);
|
setTypesLoaded(true);
|
||||||
}).catch((error: Error) => showToast({ style: Toast.Style.Failure,
|
}).catch((error: Error) => showToast({ style: Toast.Style.Failure,
|
||||||
title: "Kategorien nicht verfügbar", message: error.message }));
|
title: "Kategorien nicht verfügbar", message: error.message }));
|
||||||
}, []);
|
}, []);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!typesLoaded) return;
|
if (!typesLoaded) return;
|
||||||
const defaults = availableTypes.filter((type) => type !== "ORT");
|
const defaults = defaultTypes.filter((type) => type !== "ORT");
|
||||||
if (!root) { setSelectedTypes(defaults); setTypesReadyFor(""); return; }
|
if (!root) { setSelectedTypes(defaults); setTypesReadyFor(""); return; }
|
||||||
let active = true;
|
let active = true;
|
||||||
setTypesReadyFor(null);
|
setTypesReadyFor(null);
|
||||||
@@ -500,7 +502,7 @@ export default function Command() {
|
|||||||
}).catch((error: Error) => showToast({ style: Toast.Style.Failure,
|
}).catch((error: Error) => showToast({ style: Toast.Style.Failure,
|
||||||
title: "Projektkategorien nicht lesbar", message: error.message }));
|
title: "Projektkategorien nicht lesbar", message: error.message }));
|
||||||
return () => { active = false; };
|
return () => { active = false; };
|
||||||
}, [root, availableTypes, typesLoaded]);
|
}, [root, availableTypes, defaultTypes, typesLoaded]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!root) return;
|
if (!root) return;
|
||||||
let active = true;
|
let active = true;
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ export default function Command(props: { initialSource?: "selection" | "clipboar
|
|||||||
const [sessions, setSessions] = useState<VelumSession[]>([]);
|
const [sessions, setSessions] = useState<VelumSession[]>([]);
|
||||||
const [activeSessionId, setActiveSessionId] = useState<string>();
|
const [activeSessionId, setActiveSessionId] = useState<string>();
|
||||||
const [entityTypes, setEntityTypes] = useState<EntityType[]>([]);
|
const [entityTypes, setEntityTypes] = useState<EntityType[]>([]);
|
||||||
|
const [defaultEntityTypes, setDefaultEntityTypes] = useState<EntityType[]>([]);
|
||||||
const [selectedEntityTypes, setSelectedEntityTypes] = useState<string[]>([]);
|
const [selectedEntityTypes, setSelectedEntityTypes] = useState<string[]>([]);
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
const { push } = useNavigation();
|
const { push } = useNavigation();
|
||||||
@@ -62,8 +63,9 @@ export default function Command(props: { initialSource?: "selection" | "clipboar
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const loadedEntityTypes = await getEntityTypes();
|
const loadedEntityTypes = await getEntityTypes();
|
||||||
setEntityTypes(loadedEntityTypes);
|
setEntityTypes(loadedEntityTypes.all);
|
||||||
setSelectedEntityTypes(loadedEntityTypes);
|
setDefaultEntityTypes(loadedEntityTypes.defaults);
|
||||||
|
setSelectedEntityTypes(loadedEntityTypes.defaults);
|
||||||
} catch {
|
} catch {
|
||||||
setEntityTypes([]);
|
setEntityTypes([]);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -176,7 +178,8 @@ export default function Command(props: { initialSource?: "selection" | "clipboar
|
|||||||
placeholder="Zu pseudonymisierender Text"
|
placeholder="Zu pseudonymisierender Text"
|
||||||
/>
|
/>
|
||||||
<ContextPicker key={contextVersion} sessions={sessions} activeSessionId={activeSessionId}
|
<ContextPicker key={contextVersion} sessions={sessions} activeSessionId={activeSessionId}
|
||||||
availableEntityTypes={entityTypes} onEntityTypesChange={setSelectedEntityTypes} />
|
availableEntityTypes={entityTypes} defaultEntityTypes={defaultEntityTypes}
|
||||||
|
onEntityTypesChange={setSelectedEntityTypes} />
|
||||||
{entityTypes.length > 0 ? (
|
{entityTypes.length > 0 ? (
|
||||||
<Form.TagPicker
|
<Form.TagPicker
|
||||||
id="entityTypes"
|
id="entityTypes"
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ export default function Command() {
|
|||||||
const [sessions, setSessions] = useState<VelumSession[]>([]);
|
const [sessions, setSessions] = useState<VelumSession[]>([]);
|
||||||
const [activeSessionId, setActiveSessionId] = useState<string>();
|
const [activeSessionId, setActiveSessionId] = useState<string>();
|
||||||
const [entityTypes, setEntityTypes] = useState<EntityType[]>([]);
|
const [entityTypes, setEntityTypes] = useState<EntityType[]>([]);
|
||||||
|
const [defaultEntityTypes, setDefaultEntityTypes] = useState<EntityType[]>([]);
|
||||||
const [selectedEntityTypes, setSelectedEntityTypes] = useState<string[]>([]);
|
const [selectedEntityTypes, setSelectedEntityTypes] = useState<string[]>([]);
|
||||||
const [greeting, setGreeting] = useState("Lieber");
|
const [greeting, setGreeting] = useState("Lieber");
|
||||||
const [signOff, setSignOff] = useState("Alles Liebe,");
|
const [signOff, setSignOff] = useState("Alles Liebe,");
|
||||||
@@ -99,8 +100,9 @@ export default function Command() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const loadedEntityTypes = await getEntityTypes();
|
const loadedEntityTypes = await getEntityTypes();
|
||||||
setEntityTypes(loadedEntityTypes);
|
setEntityTypes(loadedEntityTypes.all);
|
||||||
setSelectedEntityTypes(loadedEntityTypes);
|
setDefaultEntityTypes(loadedEntityTypes.defaults);
|
||||||
|
setSelectedEntityTypes(loadedEntityTypes.defaults);
|
||||||
} catch {
|
} catch {
|
||||||
setEntityTypes([]);
|
setEntityTypes([]);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -299,7 +301,8 @@ export default function Command() {
|
|||||||
/>
|
/>
|
||||||
<Form.Separator />
|
<Form.Separator />
|
||||||
<ContextPicker sessions={sessions} activeSessionId={activeSessionId}
|
<ContextPicker sessions={sessions} activeSessionId={activeSessionId}
|
||||||
availableEntityTypes={entityTypes} onEntityTypesChange={setSelectedEntityTypes} />
|
availableEntityTypes={entityTypes} defaultEntityTypes={defaultEntityTypes}
|
||||||
|
onEntityTypesChange={setSelectedEntityTypes} />
|
||||||
{entityTypes.length > 0 ? (
|
{entityTypes.length > 0 ? (
|
||||||
<Form.TagPicker
|
<Form.TagPicker
|
||||||
id="entityTypes"
|
id="entityTypes"
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ export default function Command() {
|
|||||||
const [sessions, setSessions] = useState<VelumSession[]>([]);
|
const [sessions, setSessions] = useState<VelumSession[]>([]);
|
||||||
const [activeSessionId, setActiveSessionId] = useState<string>();
|
const [activeSessionId, setActiveSessionId] = useState<string>();
|
||||||
const [entityTypes, setEntityTypes] = useState<EntityType[]>([]);
|
const [entityTypes, setEntityTypes] = useState<EntityType[]>([]);
|
||||||
|
const [defaultEntityTypes, setDefaultEntityTypes] = useState<EntityType[]>([]);
|
||||||
const [selectedEntityTypes, setSelectedEntityTypes] = useState<string[]>([]);
|
const [selectedEntityTypes, setSelectedEntityTypes] = useState<string[]>([]);
|
||||||
const [model, setModel] = useState<string>(DEFAULT_MODEL);
|
const [model, setModel] = useState<string>(DEFAULT_MODEL);
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
@@ -77,8 +78,9 @@ export default function Command() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const loadedEntityTypes = await getEntityTypes();
|
const loadedEntityTypes = await getEntityTypes();
|
||||||
setEntityTypes(loadedEntityTypes);
|
setEntityTypes(loadedEntityTypes.all);
|
||||||
setSelectedEntityTypes(loadedEntityTypes);
|
setDefaultEntityTypes(loadedEntityTypes.defaults);
|
||||||
|
setSelectedEntityTypes(loadedEntityTypes.defaults);
|
||||||
} catch {
|
} catch {
|
||||||
setEntityTypes([]);
|
setEntityTypes([]);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -183,7 +185,8 @@ export default function Command() {
|
|||||||
placeholder="Email-Konversation einfügen oder laden"
|
placeholder="Email-Konversation einfügen oder laden"
|
||||||
/>
|
/>
|
||||||
<ContextPicker sessions={sessions} activeSessionId={activeSessionId}
|
<ContextPicker sessions={sessions} activeSessionId={activeSessionId}
|
||||||
availableEntityTypes={entityTypes} onEntityTypesChange={setSelectedEntityTypes} />
|
availableEntityTypes={entityTypes} defaultEntityTypes={defaultEntityTypes}
|
||||||
|
onEntityTypesChange={setSelectedEntityTypes} />
|
||||||
{entityTypes.length > 0 ? (
|
{entityTypes.length > 0 ? (
|
||||||
<Form.TagPicker
|
<Form.TagPicker
|
||||||
id="entityTypes"
|
id="entityTypes"
|
||||||
|
|||||||
@@ -107,6 +107,7 @@ export default function Command() {
|
|||||||
const [sessions, setSessions] = useState<VelumSession[]>([]);
|
const [sessions, setSessions] = useState<VelumSession[]>([]);
|
||||||
const [activeSessionId, setActiveSessionId] = useState<string>();
|
const [activeSessionId, setActiveSessionId] = useState<string>();
|
||||||
const [entityTypes, setEntityTypes] = useState<EntityType[]>([]);
|
const [entityTypes, setEntityTypes] = useState<EntityType[]>([]);
|
||||||
|
const [defaultEntityTypes, setDefaultEntityTypes] = useState<EntityType[]>([]);
|
||||||
const [selectedEntityTypes, setSelectedEntityTypes] = useState<string[]>([]);
|
const [selectedEntityTypes, setSelectedEntityTypes] = useState<string[]>([]);
|
||||||
const [model, setModel] = useState<string>(DEFAULT_MODEL);
|
const [model, setModel] = useState<string>(DEFAULT_MODEL);
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
@@ -130,8 +131,9 @@ export default function Command() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const loadedEntityTypes = await getEntityTypes();
|
const loadedEntityTypes = await getEntityTypes();
|
||||||
setEntityTypes(loadedEntityTypes);
|
setEntityTypes(loadedEntityTypes.all);
|
||||||
setSelectedEntityTypes(loadedEntityTypes);
|
setDefaultEntityTypes(loadedEntityTypes.defaults);
|
||||||
|
setSelectedEntityTypes(loadedEntityTypes.defaults);
|
||||||
} catch {
|
} catch {
|
||||||
setEntityTypes([]);
|
setEntityTypes([]);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -244,7 +246,8 @@ export default function Command() {
|
|||||||
placeholder="Meeting-Notizen als Fließtext einfügen — z. B. handgeschriebene Protokollnotizen, ein diktiertes Transkript oder ein zusammenhängender Bericht."
|
placeholder="Meeting-Notizen als Fließtext einfügen — z. B. handgeschriebene Protokollnotizen, ein diktiertes Transkript oder ein zusammenhängender Bericht."
|
||||||
/>
|
/>
|
||||||
<ContextPicker sessions={sessions} activeSessionId={activeSessionId}
|
<ContextPicker sessions={sessions} activeSessionId={activeSessionId}
|
||||||
availableEntityTypes={entityTypes} onEntityTypesChange={setSelectedEntityTypes} />
|
availableEntityTypes={entityTypes} defaultEntityTypes={defaultEntityTypes}
|
||||||
|
onEntityTypesChange={setSelectedEntityTypes} />
|
||||||
{entityTypes.length > 0 ? (
|
{entityTypes.length > 0 ? (
|
||||||
<Form.TagPicker
|
<Form.TagPicker
|
||||||
id="entityTypes"
|
id="entityTypes"
|
||||||
|
|||||||
12
src/velum.ts
12
src/velum.ts
@@ -1,6 +1,7 @@
|
|||||||
import { fetchWithAuth } from "./auth";
|
import { fetchWithAuth } from "./auth";
|
||||||
import { restoreXlsxBuffer } from "./lib/xlsx-restoration";
|
import { restoreXlsxBuffer } from "./lib/xlsx-restoration";
|
||||||
import { checkProjectCapabilities } from "./lib/project-capabilities";
|
import { checkProjectCapabilities } from "./lib/project-capabilities";
|
||||||
|
import { entityTypeCatalog, type EntityTypeCatalog } from "./lib/entity-types";
|
||||||
import { checkedImagePolicy, checkedImageReport, DEFAULT_IMAGE_POLICY } from "./lib/image-policy";
|
import { checkedImagePolicy, checkedImageReport, DEFAULT_IMAGE_POLICY } from "./lib/image-policy";
|
||||||
import type { ImagePolicy, DocumentImageReport } from "./lib/image-policy";
|
import type { ImagePolicy, DocumentImageReport } from "./lib/image-policy";
|
||||||
import { getPreferences } from "./preferences";
|
import { getPreferences } from "./preferences";
|
||||||
@@ -103,12 +104,13 @@ async function parseJsonResponse<T>(response: Response): Promise<T> {
|
|||||||
return (await response.json()) as T;
|
return (await response.json()) as T;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getEntityTypes(): Promise<EntityType[]> {
|
export async function getEntityTypes(): Promise<EntityTypeCatalog> {
|
||||||
const response = await fetchWithAuth(apiUrl("/api/entity-types"));
|
const response = await fetchWithAuth(apiUrl("/api/entity-types"));
|
||||||
const payload = await parseJsonResponse<{ entity_types: EntityType[] }>(
|
const payload = await parseJsonResponse<{
|
||||||
response,
|
entity_types: EntityType[];
|
||||||
);
|
default_entity_types?: EntityType[];
|
||||||
return payload.entity_types;
|
}>(response);
|
||||||
|
return entityTypeCatalog(payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function pseudonymize(
|
export async function pseudonymize(
|
||||||
|
|||||||
22
tests/entity-types.test.ts
Normal file
22
tests/entity-types.test.ts
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import { expect, it } from "bun:test";
|
||||||
|
import { entityTypeCatalog } from "../src/lib/entity-types";
|
||||||
|
|
||||||
|
const all = ["PERSON", "EMAIL", "REFERENZ", "ORT", "DATUM", "URL", "IP"];
|
||||||
|
|
||||||
|
it("uses the backend default selection when Velum reports one", () => {
|
||||||
|
expect(
|
||||||
|
entityTypeCatalog({
|
||||||
|
entity_types: all,
|
||||||
|
default_entity_types: ["PERSON", "IP", "UNBEKANNT"],
|
||||||
|
}),
|
||||||
|
).toEqual({ all, defaults: ["PERSON", "IP"] });
|
||||||
|
});
|
||||||
|
|
||||||
|
it("leaves IP, Datum and Referenz off for backends without a default list", () => {
|
||||||
|
expect(entityTypeCatalog({ entity_types: all }).defaults).toEqual([
|
||||||
|
"PERSON",
|
||||||
|
"EMAIL",
|
||||||
|
"ORT",
|
||||||
|
"URL",
|
||||||
|
]);
|
||||||
|
});
|
||||||
@@ -6,6 +6,7 @@ import ts from "typescript";
|
|||||||
import * as xlsxRestoration from "../src/lib/xlsx-restoration";
|
import * as xlsxRestoration from "../src/lib/xlsx-restoration";
|
||||||
import * as imagePolicy from "../src/lib/image-policy";
|
import * as imagePolicy from "../src/lib/image-policy";
|
||||||
import * as projectCapabilities from "../src/lib/project-capabilities";
|
import * as projectCapabilities from "../src/lib/project-capabilities";
|
||||||
|
import * as entityTypes from "../src/lib/entity-types";
|
||||||
import { checkedImagePolicy, checkedImageReport, DEFAULT_IMAGE_POLICY, KEEP_IMAGE_WARNING, sameImagePolicyCoverage, summarizeImages } from "../src/lib/image-policy";
|
import { checkedImagePolicy, checkedImageReport, DEFAULT_IMAGE_POLICY, KEEP_IMAGE_WARNING, sameImagePolicyCoverage, summarizeImages } from "../src/lib/image-policy";
|
||||||
|
|
||||||
const policies = ["placeholder", "remove", "keep"] as const;
|
const policies = ["placeholder", "remove", "keep"] as const;
|
||||||
@@ -64,6 +65,7 @@ it("übermittelt dieselbe Bildoption in Vorschau, Anwendung und erneutem Abgleic
|
|||||||
"./lib/image-policy": imagePolicy,
|
"./lib/image-policy": imagePolicy,
|
||||||
"./lib/xlsx-restoration": xlsxRestoration,
|
"./lib/xlsx-restoration": xlsxRestoration,
|
||||||
"./lib/project-capabilities": projectCapabilities,
|
"./lib/project-capabilities": projectCapabilities,
|
||||||
|
"./lib/entity-types": entityTypes,
|
||||||
};
|
};
|
||||||
const module = { exports: {} as { pseudonymizeDocument: (...args: unknown[]) => Promise<unknown>; requireProjectCapabilities: (images?: boolean) => Promise<void> } };
|
const module = { exports: {} as { pseudonymizeDocument: (...args: unknown[]) => Promise<unknown>; requireProjectCapabilities: (images?: boolean) => Promise<void> } };
|
||||||
new Function("require", "module", "exports", code)((id: string) => mocks[id] ?? require(id), module, module.exports);
|
new Function("require", "module", "exports", code)((id: string) => mocks[id] ?? require(id), module, module.exports);
|
||||||
@@ -97,6 +99,7 @@ it("restores XLSX locally and keeps the API route for DOCX", async () => {
|
|||||||
"./preferences": { getPreferences: () => ({ velumBaseUrl: "https://velum.test" }) },
|
"./preferences": { getPreferences: () => ({ velumBaseUrl: "https://velum.test" }) },
|
||||||
"./lib/image-policy": imagePolicy,
|
"./lib/image-policy": imagePolicy,
|
||||||
"./lib/project-capabilities": projectCapabilities,
|
"./lib/project-capabilities": projectCapabilities,
|
||||||
|
"./lib/entity-types": entityTypes,
|
||||||
"./lib/xlsx-restoration": xlsxRestoration,
|
"./lib/xlsx-restoration": xlsxRestoration,
|
||||||
};
|
};
|
||||||
const module = { exports: {} as { depseudonymizeDocument: (name: string, data: Buffer, mapping: Record<string, { original: string; type: string }>) => Promise<Buffer> } };
|
const module = { exports: {} as { depseudonymizeDocument: (name: string, data: Buffer, mapping: Record<string, { original: string; type: string }>) => Promise<Buffer> } };
|
||||||
|
|||||||
Reference in New Issue
Block a user