@@ -5,65 +5,51 @@ 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
89 * @returns {HackMDClient } Configured HackMD API client
910 */
10- export const createHackMDClient = ( { hackmd : { apiToken } } ) => {
11- return new HackMDAPI ( apiToken ) ;
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 ) ;
1220} ;
1321
1422/**
1523 * Creates a new meeting notes document in HackMD with appropriate tags
1624 * @param {HackMDAPI } hackmdClient - HackMD API client
1725 * @param {string } title - Document title
1826 * @param {string } content - Document content in Markdown
19- * @param {import('./types.d.ts').MeetingConfig } meetingConfig - Meeting configuration for tags
2027 * @returns {Promise<HackMDNote> } Created note data with ID and URLs
2128 */
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-
29+ export const createMeetingNotesDocument = ( hackmdClient , title , content ) => {
3430 const noteOptions = {
3531 title,
3632 content,
37- tags : [ meetingTag , 'Meetings' ] ,
33+ parentFolderId : '' ,
3834 ...HACKMD_DEFAULT_PERMISSIONS ,
3935 } ;
4036
41- if ( teamName ) {
42- return hackmdClient . createTeamNote ( teamName , noteOptions ) ;
43- }
44-
45- return hackmdClient . createNote ( noteOptions ) ;
37+ // apparently it can return either { note: {...} } or just {...}
38+ return hackmdClient
39+ . createNote ( noteOptions )
40+ . then ( response => response ?. note ?? response ) ;
4641} ;
4742
4843/**
4944 * Updates an existing meeting notes document in HackMD with retry logic
5045 * @param {HackMDClient } hackmdClient - HackMD API client
5146 * @param {string } noteId - HackMD note ID
5247 * @param {string } content - Updated document content in Markdown
53- * @param {import('./types.d.ts').MeetingConfig } meetingConfig - Meeting configuration for team context
5448 * @returns {Promise<HackMDNote> } Updated note data
5549 */
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 } ) ;
50+ export const updateMeetingNotesDocument = ( hackmdClient , noteId , content ) => {
51+ // apparently it can return either { note: {...} } or just {...}
52+ return hackmdClient
53+ . updateNote ( noteId , { content } )
54+ . then ( response => response ?. note ?? response ) ;
6955} ;
0 commit comments