digital-tools 2.0.2 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/package.json +3 -4
- package/src/define.js +267 -0
- package/src/entities/advertising.js +999 -0
- package/src/entities/ai.js +756 -0
- package/src/entities/analytics.js +1588 -0
- package/src/entities/automation.js +601 -0
- package/src/entities/communication.js +1150 -0
- package/src/entities/crm.js +1386 -0
- package/src/entities/design.js +546 -0
- package/src/entities/development.js +2212 -0
- package/src/entities/document.js +874 -0
- package/src/entities/ecommerce.js +1429 -0
- package/src/entities/experiment.js +1039 -0
- package/src/entities/finance.js +3478 -0
- package/src/entities/forms.js +1892 -0
- package/src/entities/hr.js +661 -0
- package/src/entities/identity.js +997 -0
- package/src/entities/index.js +282 -0
- package/src/entities/infrastructure.js +1153 -0
- package/src/entities/knowledge.js +1438 -0
- package/src/entities/marketing.js +1610 -0
- package/src/entities/media.js +1634 -0
- package/src/entities/notification.js +1199 -0
- package/src/entities/presentation.js +1274 -0
- package/src/entities/productivity.js +1317 -0
- package/src/entities/project-management.js +1136 -0
- package/src/entities/recruiting.js +736 -0
- package/src/entities/shipping.js +509 -0
- package/src/entities/signature.js +1102 -0
- package/src/entities/site.js +222 -0
- package/src/entities/spreadsheet.js +1341 -0
- package/src/entities/storage.js +1198 -0
- package/src/entities/support.js +1166 -0
- package/src/entities/video-conferencing.js +1750 -0
- package/src/entities/video.js +950 -0
- package/src/entities.js +1663 -0
- package/src/index.js +74 -0
- package/src/providers/analytics/index.js +17 -0
- package/src/providers/analytics/mixpanel.js +255 -0
- package/src/providers/calendar/cal-com.js +303 -0
- package/src/providers/calendar/google-calendar.js +335 -0
- package/src/providers/calendar/index.js +20 -0
- package/src/providers/crm/hubspot.js +566 -0
- package/src/providers/crm/index.js +17 -0
- package/src/providers/development/github.js +472 -0
- package/src/providers/development/index.js +17 -0
- package/src/providers/ecommerce/index.js +17 -0
- package/src/providers/ecommerce/shopify.js +378 -0
- package/src/providers/email/index.js +20 -0
- package/src/providers/email/resend.js +258 -0
- package/src/providers/email/sendgrid.js +161 -0
- package/src/providers/finance/index.js +17 -0
- package/src/providers/finance/stripe.js +549 -0
- package/src/providers/forms/index.js +17 -0
- package/src/providers/forms/typeform.js +500 -0
- package/src/providers/index.js +123 -0
- package/src/providers/knowledge/index.js +17 -0
- package/src/providers/knowledge/notion.js +389 -0
- package/src/providers/marketing/index.js +17 -0
- package/src/providers/marketing/mailchimp.js +443 -0
- package/src/providers/media/cloudinary.js +318 -0
- package/src/providers/media/index.js +17 -0
- package/src/providers/messaging/index.js +20 -0
- package/src/providers/messaging/slack.js +393 -0
- package/src/providers/messaging/twilio-sms.js +249 -0
- package/src/providers/project-management/index.js +17 -0
- package/src/providers/project-management/linear.js +575 -0
- package/src/providers/registry.js +86 -0
- package/src/providers/spreadsheet/google-sheets.js +375 -0
- package/src/providers/spreadsheet/index.js +20 -0
- package/src/providers/spreadsheet/xlsx.js +423 -0
- package/src/providers/storage/index.js +24 -0
- package/src/providers/storage/s3.js +419 -0
- package/src/providers/support/index.js +17 -0
- package/src/providers/support/zendesk.js +373 -0
- package/src/providers/tasks/index.js +17 -0
- package/src/providers/tasks/todoist.js +286 -0
- package/src/providers/types.js +9 -0
- package/src/providers/video-conferencing/google-meet.js +286 -0
- package/src/providers/video-conferencing/index.js +31 -0
- package/src/providers/video-conferencing/jitsi.js +254 -0
- package/src/providers/video-conferencing/teams.js +270 -0
- package/src/providers/video-conferencing/zoom.js +332 -0
- package/src/registry.js +128 -0
- package/src/tools/communication.js +184 -0
- package/src/tools/data.js +205 -0
- package/src/tools/index.js +11 -0
- package/src/tools/web.js +137 -0
- package/src/types.js +10 -0
- package/test/define.test.js +306 -0
- package/test/registry.test.js +357 -0
- package/test/tools.test.js +363 -0
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Microsoft Teams Video Conferencing Provider
|
|
3
|
+
*
|
|
4
|
+
* Concrete implementation of VideoConferencingProvider using Microsoft Graph API
|
|
5
|
+
* to create and manage Microsoft Teams online meetings.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import { defineProvider } from '../registry.js';
|
|
10
|
+
const GRAPH_API_URL = 'https://graph.microsoft.com/v1.0';
|
|
11
|
+
/**
|
|
12
|
+
* Microsoft Teams provider info
|
|
13
|
+
*/
|
|
14
|
+
export const teamsInfo = {
|
|
15
|
+
id: 'meeting.teams',
|
|
16
|
+
name: 'Microsoft Teams',
|
|
17
|
+
description: 'Microsoft Teams video conferencing via Microsoft Graph API',
|
|
18
|
+
category: 'video-conferencing',
|
|
19
|
+
website: 'https://teams.microsoft.com',
|
|
20
|
+
docsUrl: 'https://docs.microsoft.com/en-us/graph/api/resources/onlinemeeting',
|
|
21
|
+
requiredConfig: ['accessToken'],
|
|
22
|
+
optionalConfig: ['clientId', 'clientSecret', 'tenantId'],
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Create Microsoft Teams provider
|
|
26
|
+
*/
|
|
27
|
+
export function createTeamsProvider(config) {
|
|
28
|
+
let accessToken;
|
|
29
|
+
let clientId;
|
|
30
|
+
let clientSecret;
|
|
31
|
+
let tenantId;
|
|
32
|
+
let tokenExpiresAt = 0;
|
|
33
|
+
let currentUserId;
|
|
34
|
+
/**
|
|
35
|
+
* Refresh OAuth access token
|
|
36
|
+
*/
|
|
37
|
+
async function refreshAccessToken() {
|
|
38
|
+
if (!clientId || !clientSecret || !tenantId) {
|
|
39
|
+
throw new Error('clientId, clientSecret, and tenantId required for token refresh');
|
|
40
|
+
}
|
|
41
|
+
const response = await fetch(`https://login.microsoftonline.com/${tenantId}/oauth2/v2.0/token`, {
|
|
42
|
+
method: 'POST',
|
|
43
|
+
headers: {
|
|
44
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
45
|
+
},
|
|
46
|
+
body: new URLSearchParams({
|
|
47
|
+
client_id: clientId,
|
|
48
|
+
client_secret: clientSecret,
|
|
49
|
+
scope: 'https://graph.microsoft.com/.default',
|
|
50
|
+
grant_type: 'client_credentials',
|
|
51
|
+
}),
|
|
52
|
+
});
|
|
53
|
+
if (!response.ok) {
|
|
54
|
+
throw new Error(`Failed to refresh access token: HTTP ${response.status}`);
|
|
55
|
+
}
|
|
56
|
+
const data = (await response.json());
|
|
57
|
+
accessToken = data.access_token;
|
|
58
|
+
tokenExpiresAt = Date.now() + data.expires_in * 1000;
|
|
59
|
+
return accessToken;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get valid access token
|
|
63
|
+
*/
|
|
64
|
+
async function getAccessToken() {
|
|
65
|
+
// Return cached token if still valid (with 5-minute buffer)
|
|
66
|
+
if (accessToken && Date.now() < tokenExpiresAt - 300000) {
|
|
67
|
+
return accessToken;
|
|
68
|
+
}
|
|
69
|
+
// Try to refresh if we have credentials
|
|
70
|
+
if (tenantId && clientId && clientSecret) {
|
|
71
|
+
return refreshAccessToken();
|
|
72
|
+
}
|
|
73
|
+
// Otherwise use the provided token
|
|
74
|
+
return accessToken;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Make authenticated API request
|
|
78
|
+
*/
|
|
79
|
+
async function apiRequest(endpoint, options = {}) {
|
|
80
|
+
const token = await getAccessToken();
|
|
81
|
+
const url = endpoint.startsWith('http') ? endpoint : `${GRAPH_API_URL}${endpoint}`;
|
|
82
|
+
const response = await fetch(url, {
|
|
83
|
+
...options,
|
|
84
|
+
headers: {
|
|
85
|
+
Authorization: `Bearer ${token}`,
|
|
86
|
+
'Content-Type': 'application/json',
|
|
87
|
+
...options.headers,
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
if (!response.ok) {
|
|
91
|
+
const errorData = await response.json().catch(() => ({}));
|
|
92
|
+
throw new Error(`Microsoft Graph API error: ${response.status} - ${errorData?.error?.message || response.statusText}`);
|
|
93
|
+
}
|
|
94
|
+
return response.json();
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Get current user ID
|
|
98
|
+
*/
|
|
99
|
+
async function getUserId() {
|
|
100
|
+
if (currentUserId) {
|
|
101
|
+
return currentUserId;
|
|
102
|
+
}
|
|
103
|
+
const user = await apiRequest('/me');
|
|
104
|
+
currentUserId = user.id;
|
|
105
|
+
return currentUserId;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Convert Graph online meeting to MeetingData
|
|
109
|
+
*/
|
|
110
|
+
function convertMeeting(meeting) {
|
|
111
|
+
const startTime = new Date(meeting.startDateTime);
|
|
112
|
+
const endTime = new Date(meeting.endDateTime);
|
|
113
|
+
const duration = Math.round((endTime.getTime() - startTime.getTime()) / 60000); // minutes
|
|
114
|
+
return {
|
|
115
|
+
id: meeting.id,
|
|
116
|
+
topic: meeting.subject,
|
|
117
|
+
startTime,
|
|
118
|
+
duration,
|
|
119
|
+
joinUrl: meeting.joinWebUrl || meeting.joinUrl || '',
|
|
120
|
+
hostId: meeting.participants?.organizer?.identity?.user?.id || '',
|
|
121
|
+
status: 'waiting',
|
|
122
|
+
createdAt: new Date(meeting.creationDateTime),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
info: teamsInfo,
|
|
127
|
+
async initialize(cfg) {
|
|
128
|
+
accessToken = cfg.accessToken;
|
|
129
|
+
clientId = cfg.clientId;
|
|
130
|
+
clientSecret = cfg.clientSecret;
|
|
131
|
+
tenantId = cfg.tenantId;
|
|
132
|
+
if (!accessToken) {
|
|
133
|
+
throw new Error('Microsoft Teams requires accessToken');
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
async healthCheck() {
|
|
137
|
+
const start = Date.now();
|
|
138
|
+
try {
|
|
139
|
+
// Get current user to verify API access
|
|
140
|
+
await apiRequest('/me');
|
|
141
|
+
return {
|
|
142
|
+
healthy: true,
|
|
143
|
+
latencyMs: Date.now() - start,
|
|
144
|
+
message: 'Connected',
|
|
145
|
+
checkedAt: new Date(),
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
return {
|
|
150
|
+
healthy: false,
|
|
151
|
+
latencyMs: Date.now() - start,
|
|
152
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
153
|
+
checkedAt: new Date(),
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
async dispose() {
|
|
158
|
+
// Clear cached token
|
|
159
|
+
accessToken = '';
|
|
160
|
+
tokenExpiresAt = 0;
|
|
161
|
+
currentUserId = undefined;
|
|
162
|
+
},
|
|
163
|
+
async createMeeting(meeting) {
|
|
164
|
+
const userId = await getUserId();
|
|
165
|
+
const startTime = meeting.startTime || new Date();
|
|
166
|
+
const endTime = new Date(startTime.getTime() + (meeting.duration || 60) * 60000);
|
|
167
|
+
const body = {
|
|
168
|
+
subject: meeting.topic,
|
|
169
|
+
startDateTime: startTime.toISOString(),
|
|
170
|
+
endDateTime: endTime.toISOString(),
|
|
171
|
+
participants: {
|
|
172
|
+
attendees: [],
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
const response = await apiRequest(`/users/${userId}/onlineMeetings`, {
|
|
176
|
+
method: 'POST',
|
|
177
|
+
body: JSON.stringify(body),
|
|
178
|
+
});
|
|
179
|
+
return convertMeeting(response);
|
|
180
|
+
},
|
|
181
|
+
async getMeeting(meetingId) {
|
|
182
|
+
try {
|
|
183
|
+
const userId = await getUserId();
|
|
184
|
+
const response = await apiRequest(`/users/${userId}/onlineMeetings/${meetingId}`);
|
|
185
|
+
return convertMeeting(response);
|
|
186
|
+
}
|
|
187
|
+
catch (error) {
|
|
188
|
+
if (error instanceof Error && error.message.includes('404')) {
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
throw error;
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
async updateMeeting(meetingId, updates) {
|
|
195
|
+
const userId = await getUserId();
|
|
196
|
+
// First get the current meeting
|
|
197
|
+
const current = await this.getMeeting(meetingId);
|
|
198
|
+
if (!current) {
|
|
199
|
+
throw new Error(`Meeting ${meetingId} not found`);
|
|
200
|
+
}
|
|
201
|
+
const body = {};
|
|
202
|
+
if (updates.topic)
|
|
203
|
+
body.subject = updates.topic;
|
|
204
|
+
if (updates.startTime) {
|
|
205
|
+
const endTime = new Date(updates.startTime.getTime() + (updates.duration || current.duration || 60) * 60000);
|
|
206
|
+
body.startDateTime = updates.startTime.toISOString();
|
|
207
|
+
body.endDateTime = endTime.toISOString();
|
|
208
|
+
}
|
|
209
|
+
const response = await apiRequest(`/users/${userId}/onlineMeetings/${meetingId}`, {
|
|
210
|
+
method: 'PATCH',
|
|
211
|
+
body: JSON.stringify(body),
|
|
212
|
+
});
|
|
213
|
+
return convertMeeting(response);
|
|
214
|
+
},
|
|
215
|
+
async deleteMeeting(meetingId) {
|
|
216
|
+
try {
|
|
217
|
+
const userId = await getUserId();
|
|
218
|
+
await apiRequest(`/users/${userId}/onlineMeetings/${meetingId}`, {
|
|
219
|
+
method: 'DELETE',
|
|
220
|
+
});
|
|
221
|
+
return true;
|
|
222
|
+
}
|
|
223
|
+
catch (error) {
|
|
224
|
+
if (error instanceof Error && error.message.includes('404')) {
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
throw error;
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
async listMeetings(options = {}) {
|
|
231
|
+
const userId = await getUserId();
|
|
232
|
+
const params = new URLSearchParams();
|
|
233
|
+
if (options.limit)
|
|
234
|
+
params.append('$top', options.limit.toString());
|
|
235
|
+
// Note: Graph API doesn't provide easy filtering by time for online meetings
|
|
236
|
+
// We'll fetch and filter client-side if needed
|
|
237
|
+
let endpoint = `/users/${userId}/onlineMeetings`;
|
|
238
|
+
if (params.toString()) {
|
|
239
|
+
endpoint += `?${params.toString()}`;
|
|
240
|
+
}
|
|
241
|
+
// Handle pagination cursor
|
|
242
|
+
const url = options.cursor || endpoint;
|
|
243
|
+
const response = await apiRequest(url);
|
|
244
|
+
return {
|
|
245
|
+
items: response.value.map(convertMeeting),
|
|
246
|
+
hasMore: !!response['@odata.nextLink'],
|
|
247
|
+
nextCursor: response['@odata.nextLink'],
|
|
248
|
+
};
|
|
249
|
+
},
|
|
250
|
+
endMeeting: async function (meetingId) {
|
|
251
|
+
// Microsoft Teams doesn't support programmatically ending meetings
|
|
252
|
+
// We can delete the meeting instead
|
|
253
|
+
return await this.deleteMeeting(meetingId);
|
|
254
|
+
},
|
|
255
|
+
async getParticipants(meetingId) {
|
|
256
|
+
// Microsoft Graph API doesn't provide detailed participant data
|
|
257
|
+
// This would require Teams Meeting Recording APIs with admin consent
|
|
258
|
+
return [];
|
|
259
|
+
},
|
|
260
|
+
async getRecordings(meetingId) {
|
|
261
|
+
// Microsoft Teams recordings are stored in OneDrive/SharePoint
|
|
262
|
+
// This would require additional Graph API calls with different permissions
|
|
263
|
+
return [];
|
|
264
|
+
},
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Microsoft Teams provider definition
|
|
269
|
+
*/
|
|
270
|
+
export const teamsProvider = defineProvider(teamsInfo, async (config) => createTeamsProvider(config));
|
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zoom Video Conferencing Provider
|
|
3
|
+
*
|
|
4
|
+
* Concrete implementation of VideoConferencingProvider using Zoom API v2.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
import { defineProvider } from '../registry.js';
|
|
9
|
+
const ZOOM_API_URL = 'https://api.zoom.us/v2';
|
|
10
|
+
/**
|
|
11
|
+
* Zoom provider info
|
|
12
|
+
*/
|
|
13
|
+
export const zoomInfo = {
|
|
14
|
+
id: 'video-conferencing.zoom',
|
|
15
|
+
name: 'Zoom',
|
|
16
|
+
description: 'Zoom video conferencing and webinar platform',
|
|
17
|
+
category: 'video-conferencing',
|
|
18
|
+
website: 'https://zoom.us',
|
|
19
|
+
docsUrl: 'https://developers.zoom.us/docs/api/',
|
|
20
|
+
requiredConfig: ['accountId', 'clientId', 'clientSecret'],
|
|
21
|
+
optionalConfig: ['accessToken'],
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Create Zoom video conferencing provider
|
|
25
|
+
*/
|
|
26
|
+
export function createZoomProvider(config) {
|
|
27
|
+
let accountId;
|
|
28
|
+
let clientId;
|
|
29
|
+
let clientSecret;
|
|
30
|
+
let accessToken;
|
|
31
|
+
let tokenExpiresAt = 0;
|
|
32
|
+
/**
|
|
33
|
+
* Get OAuth access token using Server-to-Server OAuth
|
|
34
|
+
*/
|
|
35
|
+
async function getAccessToken() {
|
|
36
|
+
// Return cached token if still valid (with 5-minute buffer)
|
|
37
|
+
if (accessToken && Date.now() < tokenExpiresAt - 300000) {
|
|
38
|
+
return accessToken;
|
|
39
|
+
}
|
|
40
|
+
// Get new token
|
|
41
|
+
const credentials = Buffer.from(`${clientId}:${clientSecret}`).toString('base64');
|
|
42
|
+
const response = await fetch(`https://zoom.us/oauth/token?grant_type=account_credentials&account_id=${accountId}`, {
|
|
43
|
+
method: 'POST',
|
|
44
|
+
headers: {
|
|
45
|
+
Authorization: `Basic ${credentials}`,
|
|
46
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
if (!response.ok) {
|
|
50
|
+
throw new Error(`Failed to get access token: HTTP ${response.status}`);
|
|
51
|
+
}
|
|
52
|
+
const data = (await response.json());
|
|
53
|
+
accessToken = data.access_token;
|
|
54
|
+
tokenExpiresAt = Date.now() + data.expires_in * 1000;
|
|
55
|
+
return accessToken;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Make authenticated API request
|
|
59
|
+
*/
|
|
60
|
+
async function apiRequest(endpoint, options = {}) {
|
|
61
|
+
const token = await getAccessToken();
|
|
62
|
+
const url = `${ZOOM_API_URL}${endpoint}`;
|
|
63
|
+
const response = await fetch(url, {
|
|
64
|
+
...options,
|
|
65
|
+
headers: {
|
|
66
|
+
Authorization: `Bearer ${token}`,
|
|
67
|
+
'Content-Type': 'application/json',
|
|
68
|
+
...options.headers,
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
if (!response.ok) {
|
|
72
|
+
const errorData = await response.json().catch(() => ({}));
|
|
73
|
+
throw new Error(`Zoom API error: ${response.status} - ${errorData?.message || response.statusText}`);
|
|
74
|
+
}
|
|
75
|
+
return response.json();
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Convert Zoom meeting response to MeetingData
|
|
79
|
+
*/
|
|
80
|
+
function convertMeeting(meeting) {
|
|
81
|
+
return {
|
|
82
|
+
id: meeting.id.toString(),
|
|
83
|
+
topic: meeting.topic,
|
|
84
|
+
startTime: meeting.start_time ? new Date(meeting.start_time) : undefined,
|
|
85
|
+
duration: meeting.duration,
|
|
86
|
+
timezone: meeting.timezone,
|
|
87
|
+
agenda: meeting.agenda,
|
|
88
|
+
joinUrl: meeting.join_url,
|
|
89
|
+
hostId: meeting.host_id,
|
|
90
|
+
status: meeting.status,
|
|
91
|
+
password: meeting.password,
|
|
92
|
+
createdAt: new Date(meeting.created_at),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
info: zoomInfo,
|
|
97
|
+
async initialize(cfg) {
|
|
98
|
+
accountId = cfg.accountId;
|
|
99
|
+
clientId = cfg.clientId;
|
|
100
|
+
clientSecret = cfg.clientSecret;
|
|
101
|
+
accessToken = cfg.accessToken;
|
|
102
|
+
if (!accountId || !clientId || !clientSecret) {
|
|
103
|
+
throw new Error('Zoom requires accountId, clientId, and clientSecret');
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
async healthCheck() {
|
|
107
|
+
const start = Date.now();
|
|
108
|
+
try {
|
|
109
|
+
// Get current user to verify API access
|
|
110
|
+
await apiRequest('/users/me');
|
|
111
|
+
return {
|
|
112
|
+
healthy: true,
|
|
113
|
+
latencyMs: Date.now() - start,
|
|
114
|
+
message: 'Connected',
|
|
115
|
+
checkedAt: new Date(),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
return {
|
|
120
|
+
healthy: false,
|
|
121
|
+
latencyMs: Date.now() - start,
|
|
122
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
123
|
+
checkedAt: new Date(),
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
async dispose() {
|
|
128
|
+
// Clear cached token
|
|
129
|
+
accessToken = undefined;
|
|
130
|
+
tokenExpiresAt = 0;
|
|
131
|
+
},
|
|
132
|
+
async createMeeting(meeting) {
|
|
133
|
+
const body = {
|
|
134
|
+
topic: meeting.topic,
|
|
135
|
+
type: meeting.startTime ? 2 : 1, // 1 = instant, 2 = scheduled
|
|
136
|
+
...(meeting.startTime && {
|
|
137
|
+
start_time: meeting.startTime.toISOString(),
|
|
138
|
+
}),
|
|
139
|
+
...(meeting.duration && { duration: meeting.duration }),
|
|
140
|
+
...(meeting.timezone && { timezone: meeting.timezone }),
|
|
141
|
+
...(meeting.agenda && { agenda: meeting.agenda }),
|
|
142
|
+
...(meeting.password && { password: meeting.password }),
|
|
143
|
+
};
|
|
144
|
+
if (meeting.settings) {
|
|
145
|
+
body.settings = {
|
|
146
|
+
...(meeting.settings.hostVideo !== undefined && {
|
|
147
|
+
host_video: meeting.settings.hostVideo,
|
|
148
|
+
}),
|
|
149
|
+
...(meeting.settings.participantVideo !== undefined && {
|
|
150
|
+
participant_video: meeting.settings.participantVideo,
|
|
151
|
+
}),
|
|
152
|
+
...(meeting.settings.joinBeforeHost !== undefined && {
|
|
153
|
+
join_before_host: meeting.settings.joinBeforeHost,
|
|
154
|
+
}),
|
|
155
|
+
...(meeting.settings.muteUponEntry !== undefined && {
|
|
156
|
+
mute_upon_entry: meeting.settings.muteUponEntry,
|
|
157
|
+
}),
|
|
158
|
+
...(meeting.settings.waitingRoom !== undefined && {
|
|
159
|
+
waiting_room: meeting.settings.waitingRoom,
|
|
160
|
+
}),
|
|
161
|
+
...(meeting.settings.autoRecording && {
|
|
162
|
+
auto_recording: meeting.settings.autoRecording,
|
|
163
|
+
}),
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
const response = await apiRequest('/users/me/meetings', {
|
|
167
|
+
method: 'POST',
|
|
168
|
+
body: JSON.stringify(body),
|
|
169
|
+
});
|
|
170
|
+
return convertMeeting(response);
|
|
171
|
+
},
|
|
172
|
+
async getMeeting(meetingId) {
|
|
173
|
+
try {
|
|
174
|
+
const response = await apiRequest(`/meetings/${meetingId}`);
|
|
175
|
+
return convertMeeting(response);
|
|
176
|
+
}
|
|
177
|
+
catch (error) {
|
|
178
|
+
if (error instanceof Error && error.message.includes('404')) {
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
throw error;
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
async updateMeeting(meetingId, updates) {
|
|
185
|
+
const body = {};
|
|
186
|
+
if (updates.topic)
|
|
187
|
+
body.topic = updates.topic;
|
|
188
|
+
if (updates.startTime)
|
|
189
|
+
body.start_time = updates.startTime.toISOString();
|
|
190
|
+
if (updates.duration !== undefined)
|
|
191
|
+
body.duration = updates.duration;
|
|
192
|
+
if (updates.timezone)
|
|
193
|
+
body.timezone = updates.timezone;
|
|
194
|
+
if (updates.agenda !== undefined)
|
|
195
|
+
body.agenda = updates.agenda;
|
|
196
|
+
if (updates.password !== undefined)
|
|
197
|
+
body.password = updates.password;
|
|
198
|
+
if (updates.settings) {
|
|
199
|
+
body.settings = {
|
|
200
|
+
...(updates.settings.hostVideo !== undefined && {
|
|
201
|
+
host_video: updates.settings.hostVideo,
|
|
202
|
+
}),
|
|
203
|
+
...(updates.settings.participantVideo !== undefined && {
|
|
204
|
+
participant_video: updates.settings.participantVideo,
|
|
205
|
+
}),
|
|
206
|
+
...(updates.settings.joinBeforeHost !== undefined && {
|
|
207
|
+
join_before_host: updates.settings.joinBeforeHost,
|
|
208
|
+
}),
|
|
209
|
+
...(updates.settings.muteUponEntry !== undefined && {
|
|
210
|
+
mute_upon_entry: updates.settings.muteUponEntry,
|
|
211
|
+
}),
|
|
212
|
+
...(updates.settings.waitingRoom !== undefined && {
|
|
213
|
+
waiting_room: updates.settings.waitingRoom,
|
|
214
|
+
}),
|
|
215
|
+
...(updates.settings.autoRecording !== undefined && {
|
|
216
|
+
auto_recording: updates.settings.autoRecording,
|
|
217
|
+
}),
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
await apiRequest(`/meetings/${meetingId}`, {
|
|
221
|
+
method: 'PATCH',
|
|
222
|
+
body: JSON.stringify(body),
|
|
223
|
+
});
|
|
224
|
+
// Fetch updated meeting
|
|
225
|
+
const updated = await this.getMeeting(meetingId);
|
|
226
|
+
if (!updated) {
|
|
227
|
+
throw new Error(`Failed to fetch updated meeting ${meetingId}`);
|
|
228
|
+
}
|
|
229
|
+
return updated;
|
|
230
|
+
},
|
|
231
|
+
async deleteMeeting(meetingId) {
|
|
232
|
+
try {
|
|
233
|
+
await apiRequest(`/meetings/${meetingId}`, {
|
|
234
|
+
method: 'DELETE',
|
|
235
|
+
});
|
|
236
|
+
return true;
|
|
237
|
+
}
|
|
238
|
+
catch (error) {
|
|
239
|
+
if (error instanceof Error && error.message.includes('404')) {
|
|
240
|
+
return false;
|
|
241
|
+
}
|
|
242
|
+
throw error;
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
async listMeetings(options = {}) {
|
|
246
|
+
const params = new URLSearchParams();
|
|
247
|
+
// Map type option to Zoom API parameter
|
|
248
|
+
const typeMap = {
|
|
249
|
+
scheduled: 'scheduled',
|
|
250
|
+
live: 'live',
|
|
251
|
+
upcoming: 'upcoming',
|
|
252
|
+
previous: 'previous_meetings',
|
|
253
|
+
};
|
|
254
|
+
if (options.type) {
|
|
255
|
+
params.append('type', typeMap[options.type] || 'scheduled');
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
params.append('type', 'scheduled');
|
|
259
|
+
}
|
|
260
|
+
if (options.limit)
|
|
261
|
+
params.append('page_size', options.limit.toString());
|
|
262
|
+
if (options.cursor)
|
|
263
|
+
params.append('next_page_token', options.cursor);
|
|
264
|
+
const response = await apiRequest(`/users/me/meetings?${params.toString()}`);
|
|
265
|
+
return {
|
|
266
|
+
items: response.meetings.map(convertMeeting),
|
|
267
|
+
total: response.total_records,
|
|
268
|
+
hasMore: !!response.next_page_token,
|
|
269
|
+
nextCursor: response.next_page_token,
|
|
270
|
+
};
|
|
271
|
+
},
|
|
272
|
+
async endMeeting(meetingId) {
|
|
273
|
+
try {
|
|
274
|
+
await apiRequest(`/meetings/${meetingId}/status`, {
|
|
275
|
+
method: 'PUT',
|
|
276
|
+
body: JSON.stringify({ action: 'end' }),
|
|
277
|
+
});
|
|
278
|
+
return true;
|
|
279
|
+
}
|
|
280
|
+
catch (error) {
|
|
281
|
+
if (error instanceof Error && error.message.includes('404')) {
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
284
|
+
throw error;
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
async getParticipants(meetingId) {
|
|
288
|
+
try {
|
|
289
|
+
const response = await apiRequest(`/past_meetings/${meetingId}/participants`);
|
|
290
|
+
return response.participants.map((p) => ({
|
|
291
|
+
id: p.id,
|
|
292
|
+
name: p.name,
|
|
293
|
+
email: p.user_email,
|
|
294
|
+
joinTime: new Date(p.join_time),
|
|
295
|
+
leaveTime: p.leave_time ? new Date(p.leave_time) : undefined,
|
|
296
|
+
duration: p.duration,
|
|
297
|
+
}));
|
|
298
|
+
}
|
|
299
|
+
catch (error) {
|
|
300
|
+
if (error instanceof Error && error.message.includes('404')) {
|
|
301
|
+
return [];
|
|
302
|
+
}
|
|
303
|
+
throw error;
|
|
304
|
+
}
|
|
305
|
+
},
|
|
306
|
+
async getRecordings(meetingId) {
|
|
307
|
+
try {
|
|
308
|
+
const response = await apiRequest(`/meetings/${meetingId}/recordings`);
|
|
309
|
+
return response.recording_files.map((r) => ({
|
|
310
|
+
id: r.id,
|
|
311
|
+
meetingId: r.meeting_id,
|
|
312
|
+
type: r.recording_type === 'audio_only' ? 'audio' :
|
|
313
|
+
r.file_type === 'TRANSCRIPT' ? 'transcript' : 'video',
|
|
314
|
+
url: r.download_url,
|
|
315
|
+
size: r.file_size,
|
|
316
|
+
duration: undefined, // Not provided in this endpoint
|
|
317
|
+
createdAt: new Date(r.recording_start),
|
|
318
|
+
}));
|
|
319
|
+
}
|
|
320
|
+
catch (error) {
|
|
321
|
+
if (error instanceof Error && error.message.includes('404')) {
|
|
322
|
+
return [];
|
|
323
|
+
}
|
|
324
|
+
throw error;
|
|
325
|
+
}
|
|
326
|
+
},
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Zoom provider definition
|
|
331
|
+
*/
|
|
332
|
+
export const zoomProvider = defineProvider(zoomInfo, async (config) => createZoomProvider(config));
|