(input: NoteCommentInput, notePath: string)
| 2661 | } |
| 2662 | |
| 2663 | function normalizeNoteComment(input: NoteCommentInput, notePath: string): NoteComment | null { |
| 2664 | const body = typeof input.body === 'string' ? input.body.trim() : '' |
| 2665 | if (!body) return null |
| 2666 | const now = Date.now() |
| 2667 | const rawStart = Number.isFinite(input.anchorStart) ? Math.max(0, Math.floor(input.anchorStart)) : 0 |
| 2668 | const rawEnd = Number.isFinite(input.anchorEnd) ? Math.max(0, Math.floor(input.anchorEnd)) : rawStart |
| 2669 | const anchorStart = Math.min(rawStart, rawEnd) |
| 2670 | const anchorEnd = Math.max(rawStart, rawEnd) |
| 2671 | const anchorText = |
| 2672 | typeof input.anchorText === 'string' |
| 2673 | ? input.anchorText.replace(/\s+/g, ' ').trim().slice(0, 500) |
| 2674 | : '' |
| 2675 | return { |
| 2676 | id: typeof input.id === 'string' && input.id.trim() ? input.id.trim() : randomUUID(), |
| 2677 | notePath, |
| 2678 | anchorStart, |
| 2679 | anchorEnd, |
| 2680 | anchorText, |
| 2681 | body, |
| 2682 | createdAt: |
| 2683 | typeof input.createdAt === 'number' && Number.isFinite(input.createdAt) |
| 2684 | ? input.createdAt |
| 2685 | : now, |
| 2686 | updatedAt: |
| 2687 | typeof input.updatedAt === 'number' && Number.isFinite(input.updatedAt) |
| 2688 | ? input.updatedAt |
| 2689 | : now, |
| 2690 | resolvedAt: |
| 2691 | typeof input.resolvedAt === 'number' && Number.isFinite(input.resolvedAt) |
| 2692 | ? input.resolvedAt |
| 2693 | : null |
| 2694 | } |
| 2695 | } |
| 2696 | |
| 2697 | function normalizeNoteComments(raw: unknown, notePath: string): NoteComment[] { |
| 2698 | const values = Array.isArray(raw) |
no outgoing calls
no test coverage detected