mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 05:28:59 +01:00 
			
		
		
		
	refactor(types): better type definitions
This commit is contained in:
		
							parent
							
								
									5b9bfac1f8
								
							
						
					
					
						commit
						6f2a0f9ee1
					
				@ -3,9 +3,11 @@ import FNote from "../entities/fnote.js";
 | 
				
			|||||||
import froca from "../services/froca.js";
 | 
					import froca from "../services/froca.js";
 | 
				
			||||||
import FAttribute from "../entities/fattribute.js";
 | 
					import FAttribute from "../entities/fattribute.js";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
interface NoteDefinition {
 | 
					type AttributeDefinitions = { [key in `#${string}`]: string; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					interface NoteDefinition extends AttributeDefinitions {
 | 
				
			||||||
 | 
					    id?: string | undefined;
 | 
				
			||||||
    title: string;
 | 
					    title: string;
 | 
				
			||||||
    [key: string]: string;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
@ -27,9 +29,8 @@ export function buildNotes(notes: NoteDefinition[]) {
 | 
				
			|||||||
    const ids = [];
 | 
					    const ids = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (const noteDef of notes) {
 | 
					    for (const noteDef of notes) {
 | 
				
			||||||
        const fakeNoteId = utils.randomString(6);
 | 
					 | 
				
			||||||
        const note = new FNote(froca, {
 | 
					        const note = new FNote(froca, {
 | 
				
			||||||
            noteId: fakeNoteId,
 | 
					            noteId: noteDef.id ?? utils.randomString(12),
 | 
				
			||||||
            title: noteDef.title,
 | 
					            title: noteDef.title,
 | 
				
			||||||
            type: "text",
 | 
					            type: "text",
 | 
				
			||||||
            mime: "text/html",
 | 
					            mime: "text/html",
 | 
				
			||||||
 | 
				
			|||||||
@ -18,7 +18,7 @@ describe("Building events", () => {
 | 
				
			|||||||
    it("ignores notes with only end date", async () => {
 | 
					    it("ignores notes with only end date", async () => {
 | 
				
			||||||
        const noteIds = buildNotes([
 | 
					        const noteIds = buildNotes([
 | 
				
			||||||
            { title: "Note 1", "#endDate": "2025-05-05" },
 | 
					            { title: "Note 1", "#endDate": "2025-05-05" },
 | 
				
			||||||
            { title: "Note 2", "#endDateDate": "2025-05-07" },
 | 
					            { title: "Note 2", "#endDateDate": "2025-05-07" }
 | 
				
			||||||
        ]);
 | 
					        ]);
 | 
				
			||||||
        const events = await CalendarView.buildEvents(noteIds);
 | 
					        const events = await CalendarView.buildEvents(noteIds);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user