Skip to content

Commit 30e46ad

Browse files
authored
Merge branch 'main' into dependabot/npm_and_yarn/multi-0e0f46bd34
2 parents 4fbaad9 + bc4bbb0 commit 30e46ad

25 files changed

+1367
-881
lines changed

.prettierignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
node_modules
22
lib
3-
examples
43
docs

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [Unreleased]
8+
## [7.13.0] - 2025-09-01
99

1010
### Added
1111
- Support `isPlaintext` boolean for messages send and drafts create requests

examples/calendars/event_with_notetaker.ts

Lines changed: 83 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ import dotenv from 'dotenv';
22
import path from 'path';
33
import * as process from 'process';
44
import Nylas from 'nylas';
5-
import {
5+
import {
66
Notetaker,
77
Event,
88
NylasResponse,
99
NylasApiError,
1010
CreateEventRequest,
1111
UpdateEventRequest,
12-
NotetakerSettings
12+
NotetakerSettings,
1313
} from 'nylas';
1414

1515
// Load environment variables from .env file
@@ -33,7 +33,7 @@ if (!calendarId) {
3333
// Initialize the Nylas client
3434
const nylas = new Nylas({
3535
apiKey,
36-
apiUri: process.env.NYLAS_API_URI || 'https://api.us.nylas.com'
36+
apiUri: process.env.NYLAS_API_URI || 'https://api.us.nylas.com',
3737
});
3838

3939
/**
@@ -42,61 +42,63 @@ const nylas = new Nylas({
4242
*/
4343
async function createEventWithNotetaker(): Promise<NylasResponse<Event>> {
4444
console.log('\n=== Creating Event with Notetaker ===');
45-
45+
4646
try {
4747
// Calculate start and end times (1 day from now, 1 hour duration)
4848
const startTime = Math.floor(Date.now() / 1000) + 24 * 60 * 60; // 24 hours from now
4949
const endTime = startTime + 60 * 60; // 1 hour later
50-
50+
5151
// Create the request body
5252
const requestBody: CreateEventRequest = {
53-
title: "Project Planning Meeting",
54-
description: "Initial project planning and resource allocation",
53+
title: 'Project Planning Meeting',
54+
description: 'Initial project planning and resource allocation',
5555
when: {
5656
startTime,
57-
endTime
57+
endTime,
5858
},
5959
metadata: {
60-
project_id: "PROJ-123",
61-
priority: "high"
60+
project_id: 'PROJ-123',
61+
priority: 'high',
6262
},
6363
conferencing: {
64-
provider: "Google Meet",
65-
autocreate: {}
64+
provider: 'Google Meet',
65+
autocreate: {},
6666
},
6767
notetaker: {
68-
name: "Nylas Notetaker",
68+
name: 'Nylas Notetaker',
6969
meetingSettings: {
7070
videoRecording: true,
7171
audioRecording: true,
72-
transcription: true
73-
}
74-
}
72+
transcription: true,
73+
},
74+
},
7575
};
76-
76+
7777
console.log(`Request body: ${JSON.stringify(requestBody, null, 2)}`);
78-
78+
7979
// Create the event
8080
const event = await nylas.events.create({
8181
identifier: grantId,
8282
requestBody,
8383
queryParams: {
84-
calendarId
85-
}
84+
calendarId,
85+
},
8686
});
87-
87+
8888
console.log(`Created event with ID: ${event.data.id}`);
8989
if (event.data.notetaker) {
9090
console.log(`Event Notetaker ID: ${event.data.notetaker.id}`);
9191
}
92-
92+
9393
return event;
9494
} catch (error) {
9595
if (error instanceof NylasApiError) {
9696
console.error(`Error creating event: ${error.message}`);
9797
console.error(`Error details: ${JSON.stringify(error, null, 2)}`);
9898
} else if (error instanceof Error) {
99-
console.error(`Unexpected error in createEventWithNotetaker: ${error.message}`);
99+
console.error(
100+
`Unexpected error in createEventWithNotetaker: ${error.message}`
101+
);
100102
console.error(`Error type: ${error.constructor.name}`);
101103
}
102104
throw error;
@@ -108,39 +110,47 @@ async function createEventWithNotetaker(): Promise<NylasResponse<Event>> {
108110
* @param eventId The ID of the event to retrieve the Notetaker for
109111
* @returns The Notetaker associated with the event, or null if none found
110112
*/
111-
async function getEventNotetaker(eventId: string): Promise<NylasResponse<Notetaker> | null> {
113+
async function getEventNotetaker(
114+
eventId: string
115+
): Promise<NylasResponse<Notetaker> | null> {
112116
console.log('\n=== Retrieving Event Notetaker ===');
113-
117+
114118
try {
115119
// First, retrieve the event to get the Notetaker ID
116120
const event = await nylas.events.find({
117121
identifier: grantId,
118122
eventId,
119123
queryParams: {
120-
calendarId
121-
}
124+
calendarId,
125+
},
122126
});
123-
127+
124128
if (!event.data.notetaker || !event.data.notetaker.id) {
125129
console.log(`No Notetaker found for event ${eventId}`);
126130
return null;
127131
}
128-
132+
129133
// Get the Notetaker details
130134
const notetaker = await nylas.notetakers.find({
131135
identifier: grantId,
132-
notetakerId: event.data.notetaker.id
136+
notetakerId: event.data.notetaker.id,
133137
});
134-
138+
135139
console.log(`Found Notetaker for event ${eventId}:`);
136140
console.log(`- ID: ${notetaker.data.id}`);
137141
console.log(`- State: ${notetaker.data.state}`);
138142
console.log(`- Meeting Provider: ${notetaker.data.meetingProvider}`);
139143
console.log(`- Meeting Settings:`);
140-
console.log(` - Video Recording: ${notetaker.data.meetingSettings.videoRecording}`);
141-
console.log(` - Audio Recording: ${notetaker.data.meetingSettings.audioRecording}`);
142-
console.log(` - Transcription: ${notetaker.data.meetingSettings.transcription}`);
143-
144+
console.log(
145+
` - Video Recording: ${notetaker.data.meetingSettings.videoRecording}`
146+
);
147+
console.log(
148+
` - Audio Recording: ${notetaker.data.meetingSettings.audioRecording}`
149+
);
150+
console.log(
151+
` - Transcription: ${notetaker.data.meetingSettings.transcription}`
152+
);
153+
144154
return notetaker;
145155
} catch (error) {
146156
if (error instanceof NylasApiError) {
@@ -160,53 +170,60 @@ async function getEventNotetaker(eventId: string): Promise<NylasResponse<Notetak
160170
* @param notetakerId The ID of the Notetaker to update
161171
* @returns The updated event
162172
*/
163-
async function updateEventAndNotetaker(eventId: string, notetakerId: string): Promise<NylasResponse<Event>> {
173+
async function updateEventAndNotetaker(
174+
eventId: string,
175+
notetakerId: string
176+
): Promise<NylasResponse<Event>> {
164177
console.log('\n=== Updating Event and Notetaker ===');
165-
178+
166179
try {
167180
// Create the request body with updated event details and Notetaker settings
168181
const requestBody: UpdateEventRequest = {
169-
title: "Updated Project Planning Meeting",
170-
description: "Revised project planning with new timeline",
182+
title: 'Updated Project Planning Meeting',
183+
description: 'Revised project planning with new timeline',
171184
metadata: {
172-
project_id: "PROJ-123",
173-
priority: "urgent"
185+
project_id: 'PROJ-123',
186+
priority: 'urgent',
174187
},
175188
notetaker: {
176189
id: notetakerId,
177-
name: "Updated Nylas Notetaker",
190+
name: 'Updated Nylas Notetaker',
178191
meetingSettings: {
179192
videoRecording: false,
180193
audioRecording: true,
181-
transcription: false
182-
}
183-
}
194+
transcription: false,
195+
},
196+
},
184197
};
185-
198+
186199
console.log(`Request body: ${JSON.stringify(requestBody, null, 2)}`);
187-
200+
188201
// Update the event
189202
const updatedEvent = await nylas.events.update({
190203
identifier: grantId,
191204
eventId,
192205
requestBody,
193206
queryParams: {
194-
calendarId
195-
}
207+
calendarId,
208+
},
196209
});
197-
210+
198211
console.log(`Updated event with ID: ${updatedEvent.data.id}`);
199212
if (updatedEvent.data.notetaker) {
200-
console.log(`Updated Event Notetaker ID: ${updatedEvent.data.notetaker.id}`);
213+
console.log(
214+
`Updated Event Notetaker ID: ${updatedEvent.data.notetaker.id}`
215+
);
201216
}
202-
217+
203218
return updatedEvent;
204219
} catch (error) {
205220
if (error instanceof NylasApiError) {
206221
console.error(`Error updating event: ${error.message}`);
207222
console.error(`Error details: ${JSON.stringify(error, null, 2)}`);
208223
} else if (error instanceof Error) {
209-
console.error(`Unexpected error in updateEventAndNotetaker: ${error.message}`);
224+
console.error(
225+
`Unexpected error in updateEventAndNotetaker: ${error.message}`
226+
);
210227
console.error(`Error type: ${error.constructor.name}`);
211228
}
212229
throw error;
@@ -222,30 +239,34 @@ async function main(): Promise<void> {
222239
console.log(`Using API key: ${apiKey.substring(0, 5)}...`);
223240
console.log(`Using Grant ID: ${grantId.substring(0, 5)}...`);
224241
console.log(`Using Calendar ID: ${calendarId.substring(0, 5)}...`);
225-
242+
226243
// Create an event with a Notetaker
227244
const event = await createEventWithNotetaker();
228245
if (!event || !event.data.id) {
229-
console.error("Failed to create event");
246+
console.error('Failed to create event');
230247
return;
231248
}
232-
249+
233250
// Get the Notetaker for the event
234251
const notetaker = await getEventNotetaker(event.data.id);
235252
if (!notetaker || !notetaker.data.id) {
236253
console.error(`Failed to get Notetaker for event ${event.data.id}`);
237254
return;
238255
}
239-
256+
240257
// Update both the event and its Notetaker
241-
const updatedEvent = await updateEventAndNotetaker(event.data.id, notetaker.data.id);
258+
const updatedEvent = await updateEventAndNotetaker(
259+
event.data.id,
260+
notetaker.data.id
261+
);
242262
if (!updatedEvent) {
243263
console.error(`Failed to update event ${event.data.id}`);
244264
return;
245265
}
246-
247-
console.log("\n=== Calendar Event with Notetaker Demo Completed Successfully ===");
248-
266+
267+
console.log(
268+
'\n=== Calendar Event with Notetaker Demo Completed Successfully ==='
269+
);
249270
} catch (error) {
250271
if (error instanceof NylasApiError) {
251272
console.error(`\nNylas API Error: ${error.message}`);
@@ -262,4 +283,4 @@ async function main(): Promise<void> {
262283
// Run the main function
263284
if (require.main === module) {
264285
main().catch(console.error);
265-
}
286+
}

examples/edge-environment/src/worker.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import Nylas, { SendMessageRequest } from 'nylas';
32
import * as mimeTypes from 'mime-types';
43

@@ -268,14 +267,16 @@ const HTML_INTERFACE = `
268267
`;
269268

270269
// Helper function to parse multipart form data
271-
async function parseFormData(request: Request): Promise<{ [key: string]: any }> {
270+
async function parseFormData(
271+
request: Request
272+
): Promise<{ [key: string]: any }> {
272273
const formData = await request.formData();
273274
const result: { [key: string]: any } = {};
274-
275+
275276
for (const [key, value] of formData.entries()) {
276277
result[key] = value;
277278
}
278-
279+
279280
return result;
280281
}
281282

@@ -288,7 +289,7 @@ function getContentType(filename: string): string {
288289
export default {
289290
async fetch(request: Request, env: Env): Promise<Response> {
290291
const url = new URL(request.url);
291-
292+
292293
// CORS headers for the response
293294
const corsHeaders = {
294295
'Access-Control-Allow-Origin': '*',
@@ -317,7 +318,10 @@ export default {
317318
// Validate environment variables
318319
if (!env.NYLAS_API_KEY || !env.NYLAS_GRANT_ID) {
319320
return new Response(
320-
JSON.stringify({ error: 'Missing required environment variables (NYLAS_API_KEY, NYLAS_GRANT_ID)' }),
321+
JSON.stringify({
322+
error:
323+
'Missing required environment variables (NYLAS_API_KEY, NYLAS_GRANT_ID)',
324+
}),
321325
{
322326
status: 500,
323327
headers: { 'Content-Type': 'application/json', ...corsHeaders },
@@ -418,13 +422,13 @@ export default {
418422
headers: { 'Content-Type': 'application/json', ...corsHeaders },
419423
}
420424
);
421-
422425
} catch (error) {
423426
console.error('Error sending email:', error);
424-
427+
425428
return new Response(
426429
JSON.stringify({
427-
error: error instanceof Error ? error.message : 'Unknown error occurred',
430+
error:
431+
error instanceof Error ? error.message : 'Unknown error occurred',
428432
}),
429433
{
430434
status: 500,
@@ -440,4 +444,4 @@ export default {
440444
headers: corsHeaders,
441445
});
442446
},
443-
};
447+
};

0 commit comments

Comments
 (0)