@@ -5,36 +5,65 @@ import { HACKMD_DEFAULT_PERMISSIONS } from './constants.mjs';
55/**
66 * Creates a HackMD API client
77 * @param {import('./types.d.ts').AppConfig } config - Application configuration
8- * @param {import('./types.d.ts').MeetingConfig } meetingConfig - Meeting configuration
98 * @returns {HackMDClient } Configured HackMD API client
109 */
11- export const createHackMDClient = ( { hackmd : { apiToken } } , meetingConfig ) => {
12- // Use team-specific API endpoint if teamName is provided in meeting config
13- const teamName = meetingConfig . properties . HACKMD_TEAM_NAME ;
14-
15- const baseURL = teamName
16- ? `https://api.hackmd.io/v1/teams/${ teamName } `
17- : 'https://api.hackmd.io/v1' ;
18-
19- return new HackMDAPI ( apiToken , baseURL ) ;
10+ export const createHackMDClient = ( { hackmd : { apiToken } } ) => {
11+ return new HackMDAPI ( apiToken ) ;
2012} ;
2113
2214/**
23- * Creates a new meeting notes document in HackMD
15+ * Creates a new meeting notes document in HackMD with appropriate tags
2416 * @param {HackMDAPI } hackmdClient - HackMD API client
2517 * @param {string } title - Document title
2618 * @param {string } content - Document content in Markdown
19+ * @param {import('./types.d.ts').MeetingConfig } meetingConfig - Meeting configuration for tags
2720 * @returns {Promise<HackMDNote> } Created note data with ID and URLs
2821 */
29- export const createMeetingNotesDocument = ( hackmdClient , title , content ) =>
30- hackmdClient . createNote ( { title, content, ...HACKMD_DEFAULT_PERMISSIONS } ) ;
22+ export const createMeetingNotesDocument = (
23+ hackmdClient ,
24+ title ,
25+ content ,
26+ meetingConfig
27+ ) => {
28+ const meetingTag =
29+ meetingConfig ?. properties ?. GROUP_NAME ??
30+ meetingConfig ?. properties ?. AGENDA_TAG ;
31+
32+ const teamName = meetingConfig ?. properties ?. HACKMD_TEAM_NAME ;
33+
34+ const noteOptions = {
35+ title,
36+ content,
37+ tags : [ meetingTag , 'Meetings' ] ,
38+ ...HACKMD_DEFAULT_PERMISSIONS ,
39+ } ;
40+
41+ if ( teamName ) {
42+ return hackmdClient . createTeamNote ( teamName , noteOptions ) ;
43+ }
44+
45+ return hackmdClient . createNote ( noteOptions ) ;
46+ } ;
3147
3248/**
33- * Updates an existing meeting notes document in HackMD
49+ * Updates an existing meeting notes document in HackMD with retry logic
3450 * @param {HackMDClient } hackmdClient - HackMD API client
3551 * @param {string } noteId - HackMD note ID
3652 * @param {string } content - Updated document content in Markdown
53+ * @param {import('./types.d.ts').MeetingConfig } meetingConfig - Meeting configuration for team context
3754 * @returns {Promise<HackMDNote> } Updated note data
3855 */
39- export const updateMeetingNotesDocument = ( hackmdClient , noteId , content ) =>
40- hackmdClient . updateNote ( noteId , { content } ) ;
56+ export const updateMeetingNotesDocument = (
57+ hackmdClient ,
58+ noteId ,
59+ content ,
60+ meetingConfig
61+ ) => {
62+ const teamName = meetingConfig ?. properties ?. HACKMD_TEAM_NAME ;
63+
64+ if ( teamName ) {
65+ return hackmdClient . updateTeamNote ( teamName , noteId , { content } ) ;
66+ }
67+
68+ return hackmdClient . updateNote ( noteId , { content } ) ;
69+ } ;
0 commit comments