fix(person): type mention items as PersonSummaryDTO, regenerate api
The dropdown and editor typed /api/persons list items as the full Person entity. The actual wire shape is PersonSummaryDTO, which until the previous commit had no date fields - so the life-date subtitle rendered blank in production while fixtures (built from the entity type) kept the tests green. Retype items as the summary projection and guard the two personId consumers against the schema-optional id. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -12,7 +12,9 @@ import MentionDropdown from './MentionDropdown.svelte';
|
||||
import { createMentionNodeView } from './mentionNodeView';
|
||||
import { MAX_QUERY_LENGTH, SEARCH_DEBOUNCE_MS, SEARCH_RESULT_LIMIT } from './mentionConstants';
|
||||
|
||||
type Person = components['schemas']['Person'];
|
||||
// PersonSummaryDTO, not Person: /api/persons list items are the summary projection.
|
||||
// Typing them as the full entity hid a runtime bug (missing date fields, #812).
|
||||
type Person = components['schemas']['PersonSummaryDTO'];
|
||||
|
||||
type Props = {
|
||||
value: string;
|
||||
@@ -216,14 +218,15 @@ const controller = createMentionController();
|
||||
// reflected data-person-id or the search input).
|
||||
function commitRelink(pos: number): CommitFn {
|
||||
return (item: Person) => {
|
||||
if (!editor) return;
|
||||
if (!editor || !item.id) return;
|
||||
const personId = item.id;
|
||||
editor
|
||||
.chain()
|
||||
.focus()
|
||||
.command(({ tr, state }) => {
|
||||
const node = state.doc.nodeAt(pos);
|
||||
if (!node || node.type.name !== 'mention') return false;
|
||||
tr.setNodeMarkup(pos, undefined, { ...node.attrs, personId: item.id });
|
||||
tr.setNodeMarkup(pos, undefined, { ...node.attrs, personId });
|
||||
return true;
|
||||
})
|
||||
.run();
|
||||
@@ -364,8 +367,10 @@ onMount(() => {
|
||||
render() {
|
||||
const buildFreshCommit = (loose: LooseRenderProps): CommitFn => {
|
||||
const clippedQuery = loose.query.slice(0, MAX_QUERY_LENGTH);
|
||||
return (item: Person) =>
|
||||
return (item: Person) => {
|
||||
if (!item.id) return;
|
||||
loose.command({ personId: item.id, displayName: clippedQuery });
|
||||
};
|
||||
};
|
||||
return {
|
||||
onStart(renderProps) {
|
||||
|
||||
Reference in New Issue
Block a user