diff --git a/CHANGELOG.md b/CHANGELOG.md index 7de735d3..7e8cca48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,12 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -Planned version: **8.5.1**. +Planned version: **9.0.0**, because of the breaking TypeScript changes below. ### Added +- Type `notetakerSettings` on Notetaker create and update requests, `configId` on Notetaker create requests, and `notetakerSettings` on Notetaker responses, matching the current Notetaker API. +- Type the summary, action item, transcription, silence and message fields on `NotetakerMeetingSettings`. +- Type `notetakerSettings`, `configId`, `autocreate` and `deduplicationPolicy` on calendar Notetaker settings, `notetakerSettings` and `deduplicationPolicy` on event Notetaker settings, and nested AND groups in calendar `rules.eventSelection`. - `certificateExpiresAt` and `thumbprint` on `Credential`, plus `CredentialType.CONNECTORCERTIFICATE` and `CredentialType.ADMINCONSENTCERTIFICATE`, for Dashboard-generated certificate credentials (NYL-515). +### Changed +- Mark the Notetaker request `name` and `meetingSettings` fields as deprecated in favor of `notetakerSettings`. +- **Breaking TypeScript change:** make `Notetaker.name` and `Notetaker.meetingSettings` optional. The API omits them when it returns `notetakerSettings`, as it does for most Notetakers created with `notetakerSettings` or `configId` and for Notetakers that inherit a workspace or application configuration. Code that reads them under `strict` now needs a check or a fallback. Read `notetakerSettings` when present and fall back to the old fields, such as `notetaker.notetakerSettings?.name ?? notetaker.name ?? 'Nylas Notetaker'`. +- **Breaking TypeScript change:** calendar Notetaker `rules.eventSelection` items can now be nested groups, so code that treats the array as `string[]` needs to handle `string[]` items too. +- **Breaking TypeScript change:** `Calendar.notetaker` and `Event.notetaker` are now typed as `CalendarNotetakerResponse` and `EventNotetakerResponse`. A fetched `notetaker` object carries resolved settings, including inherited ones, and can carry values the API rejects on writes, such as stored image metadata or an `active` deduplication policy. Passing it straight into a create or update request no longer compiles. Build the request from the fields you want to set. + ### Fixed +- Type calendar Notetaker `rules.eventSelection` values as the API expects them (`own_events`, `participant_only`). The SDK sent `ownEvents` and `participantOnly` unchanged, and the API rejected them. - Populate `requestId` on API errors from the response body `request_id` when the `x-request-id` header is absent, e.g. on `api.provider_error` responses (CUST-5800). - Preserve upload-session HTTP header map keys while decoding API responses (NYL-476). - Patch vulnerable SDK tooling and example HTTP dependencies while preserving TypeDoc compatibility (NYL-471). diff --git a/cjs-wrapper.d.ts b/cjs-wrapper.d.ts index 94c8142a..dbe9242b 100644 --- a/cjs-wrapper.d.ts +++ b/cjs-wrapper.d.ts @@ -47,7 +47,9 @@ declare namespace Nylas { export import BuildServiceAccountHeadersParams = models.BuildServiceAccountHeadersParams; export import Calendar = models.Calendar; export import CalendarNotetaker = models.CalendarNotetaker; + export import CalendarNotetakerEventSelection = models.CalendarNotetakerEventSelection; export import CalendarNotetakerParticipantFilter = models.CalendarNotetakerParticipantFilter; + export import CalendarNotetakerResponse = models.CalendarNotetakerResponse; export import CalendarNotetakerRules = models.CalendarNotetakerRules; export import CleanMessagesRequest = models.CleanMessagesRequest; export import CleanMessagesResponse = models.CleanMessagesResponse; @@ -120,6 +122,7 @@ declare namespace Nylas { export import EmailTemplate = models.EmailTemplate; export import Event = models.Event; export import EventBooking = models.EventBooking; + export import EventNotetakerResponse = models.EventNotetakerResponse; export import EventResource = models.EventResource; export import EventType = models.EventType; export import FindAttachmentQueryParams = models.FindAttachmentQueryParams; @@ -181,14 +184,27 @@ declare namespace Nylas { export import MicrosoftCreateConnectorRequest = models.MicrosoftCreateConnectorRequest; export import MicrosoftCreateConnectorSettings = models.MicrosoftCreateConnectorSettings; export import Notetaker = models.Notetaker; + export import NotetakerConfigSettings = models.NotetakerConfigSettings; + export import NotetakerConfigSettingsResponse = models.NotetakerConfigSettingsResponse; + export import NotetakerCustomInstructionsSettings = models.NotetakerCustomInstructionsSettings; + export import NotetakerDeduplicationPolicy = models.NotetakerDeduplicationPolicy; export import NotetakerLeaveResponse = models.NotetakerLeaveResponse; export import NotetakerMedia = models.NotetakerMedia; export import NotetakerMeetingProvider = models.NotetakerMeetingProvider; export import NotetakerMeetingSettings = models.NotetakerMeetingSettings; + export import NotetakerMessages = models.NotetakerMessages; + export import NotetakerOnJoinMessage = models.NotetakerOnJoinMessage; + export import NotetakerOnParticipantJoinMessage = models.NotetakerOnParticipantJoinMessage; export import NotetakerRecording = models.NotetakerRecording; + export import NotetakerRecordingType = models.NotetakerRecordingType; export import NotetakerSettings = models.NotetakerSettings; export import NotetakerState = models.NotetakerState; + export import NotetakerSyncSettings = models.NotetakerSyncSettings; export import NotetakerTranscript = models.NotetakerTranscript; + export import NotetakerTranscriptionSettings = models.NotetakerTranscriptionSettings; + export import NotetakerVideoOutput = models.NotetakerVideoOutput; + export import NotetakerVideoOutputMediaType = models.NotetakerVideoOutputMediaType; + export import NotetakerVideoOutputUpload = models.NotetakerVideoOutputUpload; export import NylasApiError = models.NylasApiError; export import NylasApiErrorResponse = models.NylasApiErrorResponse; export import NylasApiErrorResponseData = models.NylasApiErrorResponseData; diff --git a/examples/calendars/event_with_notetaker.ts b/examples/calendars/event_with_notetaker.ts index 6f63af67..481190c3 100644 --- a/examples/calendars/event_with_notetaker.ts +++ b/examples/calendars/event_with_notetaker.ts @@ -160,13 +160,13 @@ async function getEventNotetaker( console.log(`- Meeting Provider: ${notetaker.data.meetingProvider}`); console.log(`- Meeting Settings:`); console.log( - ` - Video Recording: ${notetaker.data.meetingSettings.videoRecording}` + ` - Video Recording: ${notetaker.data.meetingSettings?.videoRecording}` ); console.log( - ` - Audio Recording: ${notetaker.data.meetingSettings.audioRecording}` + ` - Audio Recording: ${notetaker.data.meetingSettings?.audioRecording}` ); console.log( - ` - Transcription: ${notetaker.data.meetingSettings.transcription}` + ` - Transcription: ${notetaker.data.meetingSettings?.transcription}` ); return notetaker; diff --git a/examples/notetakers/notetaker.ts b/examples/notetakers/notetaker.ts index cc3166fc..05318f02 100644 --- a/examples/notetakers/notetaker.ts +++ b/examples/notetakers/notetaker.ts @@ -45,11 +45,12 @@ async function inviteNotetaker(): Promise> { const requestBody: CreateNotetakerRequest = { meetingLink, - name: 'Nylas Notetaker', - meetingSettings: { - videoRecording: true, - audioRecording: true, + notetakerSettings: { + name: 'Nylas Notetaker', + recordingType: 'audio_video', transcription: true, + summary: true, + actionItems: true, }, }; @@ -58,7 +59,9 @@ async function inviteNotetaker(): Promise> { const notetaker = await nylas.notetakers.create({ requestBody }); console.log(`Invited Notetaker with ID: ${notetaker.data.id}`); - console.log(`Name: ${notetaker.data.name}`); + console.log( + `Name: ${notetaker.data.notetakerSettings?.name ?? notetaker.data.name}` + ); console.log(`State: ${notetaker.data.state}`); return notetaker; } catch (error) { @@ -94,7 +97,7 @@ async function listNotetakers(): Promise> { ); for (const notetaker of notetakers.data) { console.log( - `- ${notetaker.name} (ID: ${notetaker.id}, State: ${notetaker.state})` + `- ${notetaker.notetakerSettings?.name ?? notetaker.name} (ID: ${notetaker.id}, State: ${notetaker.state})` ); } diff --git a/package-lock.json b/package-lock.json index 0df2677d..fe8e871b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "nylas", - "version": "8.5.1", + "version": "9.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "nylas", - "version": "8.5.1", + "version": "9.0.0", "license": "MIT", "dependencies": { "change-case": "^4.1.2", diff --git a/package.json b/package.json index aa4ca580..0fd1315c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nylas", - "version": "8.5.1", + "version": "9.0.0", "description": "A NodeJS wrapper for the Nylas REST API for email, contacts, and calendar.", "main": "lib/cjs/nylas.js", "types": "lib/types/nylas.d.ts", diff --git a/src/models/calendars.ts b/src/models/calendars.ts index 2fe92a0a..4cd237b2 100644 --- a/src/models/calendars.ts +++ b/src/models/calendars.ts @@ -1,5 +1,10 @@ import { ListQueryParams } from './listQueryParams.js'; -import { NotetakerMeetingSettings } from './notetakers.js'; +import { + NotetakerConfigSettingsResponse, + NotetakerDeduplicationPolicy, + NotetakerSyncSettings, + NotetakerMeetingSettings, +} from './notetakers.js'; /** * Interface for Calendar Notetaker participant filter @@ -15,20 +20,31 @@ export interface CalendarNotetakerParticipantFilter { participantsLte?: number; } +/** + * A criterion for which events a calendar's Notetaker joins. + * "all": Events with meeting links. + * "internal": Events where the host's domain matches all participants' domains. + * "external": Events where the host's domain differs from any participant's domain. + * "own_events": Events where the user's grant is the host. + * "participant_only": Events where the user's grant is a participant but not the host. + */ +export type CalendarNotetakerEventSelection = + 'all' | 'internal' | 'external' | 'own_events' | 'participant_only'; + /** * Interface for Calendar Notetaker rules */ export interface CalendarNotetakerRules { /** - * Types of events to include for notetaking. This is a union of events that should have a Notetaker sent to them. - * "internal": Events where the host domain matches all participants' domain names - * "external": Events where the host domain differs from any participant's domain name - * "own_events": Events where the host is the same as the user's grant - * "participant_only": Events where the user's grant is a participant but not the host - * "all": When all options are included, all events with meeting links will have Notetakers + * Types of events to include for notetaking. + * Each item is a single criterion or a group of criteria. + * Top-level items are OR'd together, and criteria inside a group are AND'd. + * Each group needs at least one criterion. + * For example, `['internal', ['own_events', 'external']]` matches internal events, + * or events the user hosts that have at least one external participant. */ eventSelection?: Array< - 'internal' | 'external' | 'all' | 'ownEvents' | 'participantOnly' + CalendarNotetakerEventSelection | CalendarNotetakerEventSelection[] >; /** * Filters to apply based on the number of participants. This is an intersection with the event_selection. @@ -38,24 +54,90 @@ export interface CalendarNotetakerRules { } /** - * Interface for Calendar Notetaker settings + * Interface for Calendar Notetaker settings. + * Use one of `notetakerSettings`, `configId`, `autocreate`, or the deprecated + * `name` and `meetingSettings`. Combining them returns a validation error. + * `rules` can be combined with `notetakerSettings` or the deprecated fields. + * + * Build update requests from the fields you want to set. A fetched calendar's + * `notetaker` object can carry resolved values, such as stored image metadata, + * that the API rejects on writes. */ export interface CalendarNotetaker { /** * The display name for the Notetaker bot. * @default "Nylas Notetaker" + * @deprecated Use `notetakerSettings.name` instead. */ name?: string; /** * Notetaker Meeting Settings + * @deprecated Use `notetakerSettings` instead. */ meetingSettings?: NotetakerMeetingSettings; + /** + * Settings for the Notetakers that join this calendar's events. + * Nylas saves them as a calendar configuration. + * Requests replace the whole `notetaker` object. Include these settings when + * you update `rules`: a `notetaker` object with only `rules` replaces the + * calendar's settings with legacy defaults. + */ + notetakerSettings?: NotetakerSyncSettings; + /** + * The ID of an application or workspace Notetaker configuration to apply to this calendar. + */ + configId?: string; + /** + * When true, Nylas creates Notetakers for matching events using the settings + * inherited from your configurations. Cannot be combined with `rules`. + */ + autocreate?: true; + /** + * Whether Notetakers created from this calendar take part in deduplication. + * "inherit": Use the policy from your configurations. + * "disable": Opt this calendar out of deduplication. + * Only valid with `notetakerSettings`. Updates that omit it reset it to + * "inherit", so send it again to keep an opt-out. + */ + deduplicationPolicy?: 'inherit' | 'disable'; /** * Rules for when the Notetaker should join a meeting. */ rules?: CalendarNotetakerRules; } +/** + * Calendar Notetaker settings as returned in Calendar responses. + * Calendar reads return resolved `notetakerSettings` that include settings + * inherited from workspace and application configurations. Create and update + * responses return the settings you sent. Responses can carry values the API + * rejects on writes, so this type can't be passed straight into a create or + * update request. Build the request from the fields you want to set. + */ +export interface CalendarNotetakerResponse extends Omit< + CalendarNotetaker, + 'notetakerSettings' | 'autocreate' | 'deduplicationPolicy' +> { + /** + * Settings for the Notetakers that join this calendar's events. In calendar + * reads these are resolved and include inherited values. + */ + notetakerSettings?: NotetakerConfigSettingsResponse; + /** + * Only in create and update responses, which return the settings you sent. + * Calendar reads don't include it. + */ + autocreate?: boolean; + /** + * The deduplication policy of the configuration this calendar uses. With + * inline `notetakerSettings` it is the calendar's own value, and "inherit" + * means a parent configuration decides. For a calendar that uses `configId` + * or `autocreate`, reads return that configuration's policy, which can be + * "active" or "inactive". + */ + deduplicationPolicy?: NotetakerDeduplicationPolicy; +} + /** * Interface of the query parameters for listing calendars. */ @@ -185,5 +267,5 @@ export interface Calendar { /** * Notetaker meeting bot settings */ - notetaker?: CalendarNotetaker; + notetaker?: CalendarNotetakerResponse; } diff --git a/src/models/events.ts b/src/models/events.ts index 396d0f6d..a804ac92 100644 --- a/src/models/events.ts +++ b/src/models/events.ts @@ -2,10 +2,16 @@ import { Subset } from '../utils.js'; import { NylasApiErrorResponseData } from './error.js'; import { ListQueryParams } from './listQueryParams.js'; import { NylasBaseResponse } from './response.js'; -import { NotetakerMeetingSettings } from './notetakers.js'; +import { + NotetakerConfigSettingsResponse, + NotetakerDeduplicationPolicy, + NotetakerSyncSettings, + NotetakerMeetingSettings, +} from './notetakers.js'; /** - * Interface representing Notetaker settings + * Interface representing Notetaker settings for an event. + * Use either `notetakerSettings` or the older `name` and `meetingSettings`, not both. */ export interface NotetakerSettings { /** @@ -17,6 +23,50 @@ export interface NotetakerSettings { * Notetaker Meeting Settings */ meetingSettings?: NotetakerMeetingSettings; + /** + * Settings for the Notetaker that joins this event. + * Nylas saves them as an event configuration. + */ + notetakerSettings?: NotetakerSyncSettings; + /** + * Whether this event's Notetaker takes part in deduplication. + * "inherit": Use the policy from your configurations. + * "disable": Exempt this event's Notetaker from deduplication. + * Only valid with `notetakerSettings`. + */ + deduplicationPolicy?: 'inherit' | 'disable'; +} + +/** + * Event Notetaker settings as returned in Event responses. + * `notetakerSettings` are resolved values that include inherited settings, + * such as those from the calendar, workspace or application configuration. + * Responses can carry values the API rejects on writes, so this type can't be + * passed straight into a create or update request. Build the request from the + * fields you want to set. + * Many event reads return only `id`, `name` and `meetingSettings`. Read + * `notetakerSettings` when present and fall back to those fields. + */ +export interface EventNotetakerResponse extends Omit< + NotetakerSettings, + 'notetakerSettings' | 'deduplicationPolicy' +> { + /** + * The Notetaker bot ID. + */ + id?: string; + /** + * Resolved settings for the Notetaker that joins this event. + */ + notetakerSettings?: NotetakerConfigSettingsResponse; + /** + * The deduplication policy of the configuration this event uses. With + * inline `notetakerSettings` it is the event's own value, and "inherit" + * means a parent configuration decides. For an event that uses a + * configuration, reads return that configuration's policy, which can be + * "active" or "inactive". + */ + deduplicationPolicy?: NotetakerDeduplicationPolicy; } /** @@ -178,7 +228,7 @@ export interface Event { /** * Notetaker meeting bot settings */ - notetaker?: NotetakerSettings; + notetaker?: EventNotetakerResponse; } /** diff --git a/src/models/notetakers.ts b/src/models/notetakers.ts index 2fefcdaf..a27ab759 100644 --- a/src/models/notetakers.ts +++ b/src/models/notetakers.ts @@ -21,6 +21,256 @@ export type NotetakerState = | 'media_error' | 'media_deleted'; +/** + * What Notetaker records. + * `audio_video` produces an MP4 recording of the meeting's video and audio. + * `audio` produces an MP3 audio-only recording. + */ +export type NotetakerRecordingType = 'audio_video' | 'audio'; + +/** + * Optional settings that tune how Notetaker transcribes audio. + * `transcription` must be true for these settings to take effect. + */ +export interface NotetakerTranscriptionSettings { + /** + * Language codes the audio is expected to contain. + * When provided, it must contain at least one supported code. + */ + expectedLanguages?: string[]; + /** + * Language to use if Notetaker does not detect one of the expected languages. + */ + fallbackLanguage?: string; + /** + * Domain-specific terms that bias transcription toward recognizing them, + * such as names, acronyms, and product names. + */ + keywords?: string[]; + /** + * When true, Notetaker adds known speaker names to the keyword set. + */ + useSpeakerNamesAsKeywords?: boolean; +} + +/** + * Custom instructions for the AI model that generates a summary or action items. + */ +export interface NotetakerCustomInstructionsSettings { + /** + * A custom prompt for the AI model. + */ + customInstructions?: string; +} + +/** + * A message the Notetaker bot posts to the meeting chat shortly after joining. + */ +export interface NotetakerOnJoinMessage { + /** + * The message format. Currently only `text` is supported. + */ + type: 'text'; + /** + * The message text. HTML tags are stripped before the message is sent. + */ + content: string; + /** + * Delay in milliseconds between the bot joining and the message being posted. + */ + sendAfterMs: number; +} + +/** + * A message the Notetaker bot posts to the meeting chat when a new participant joins. + */ +export interface NotetakerOnParticipantJoinMessage { + /** + * The message format. Currently only `text` is supported. + */ + type: 'text'; + /** + * The message text. HTML tags are stripped before the message is sent. + */ + content: string; + /** + * Trailing debounce window in milliseconds. + * A burst of joins inside the window produces a single message. + */ + debounceMs: number; +} + +/** + * Custom announcements the Notetaker bot posts to the meeting chat. + */ +export interface NotetakerMessages { + /** + * Messages the bot sends shortly after it joins the meeting. Up to 10. + */ + onJoin?: NotetakerOnJoinMessage[] | null; + /** + * Messages the bot sends when a new participant joins the meeting. Up to 10. + */ + onParticipantJoin?: NotetakerOnParticipantJoinMessage[] | null; +} + +/** + * The image formats Notetaker accepts for video output. + */ +export type NotetakerVideoOutputMediaType = + 'image/png' | 'image/jpeg' | 'image/webp'; + +/** + * A static image for the Notetaker bot to show as its camera feed. + * Send `mediaType` and base64 `data` together to upload an image, + * or an empty object to disable video output. + */ +export type NotetakerVideoOutputUpload = + | { + /** + * The image MIME type. Must match the actual file content. + */ + mediaType: NotetakerVideoOutputMediaType; + /** + * The base64-encoded image bytes. + */ + data: string; + /** Read-only; not accepted on writes. */ + size?: never; + /** Read-only; not accepted on writes. */ + previewUrl?: never; + /** Read-only; not accepted on writes. */ + previewUrlExpiresAt?: never; + } + | Record; + +/** + * The stored video output image returned in Notetaker responses. + */ +export interface NotetakerVideoOutput { + /** + * The image MIME type. + */ + mediaType?: NotetakerVideoOutputMediaType; + /** + * The size of the stored image, in bytes. + */ + size?: number; + /** + * A signed URL for previewing the stored image. Valid for 1 hour. + */ + previewUrl?: string; + /** + * When `previewUrl` expires, in Unix timestamp format. + */ + previewUrlExpiresAt?: number; +} + +/** + * Interface representing Notetaker settings. + * Cannot be used together with the deprecated `name` and `meetingSettings` fields. + */ +export interface NotetakerConfigSettings { + /** + * The display name shown when the Notetaker joins a meeting. + */ + name?: string; + /** + * What Notetaker records. + * When no level of the configuration hierarchy sets it, Notetaker records audio and video. + */ + recordingType?: NotetakerRecordingType; + /** + * When true, Notetaker transcribes the meeting's audio. + */ + transcription?: boolean; + /** + * Optional settings that tune how Notetaker transcribes audio. + * On create, send `null` or `{}` to clear inherited settings. + * In `notetakers.update()`, `null` removes this Notetaker's override and + * restores the inherited settings, and `{}` clears them. + * In calendar and event Notetaker settings, `null` clears them like `{}`. + * Leave the field out to inherit. + */ + transcriptionSettings?: NotetakerTranscriptionSettings | null; + /** + * When true, Notetaker generates a summary of the meeting. + * Requires `transcription` to also be true. + */ + summary?: boolean; + /** + * Settings for the summary. + */ + summarySettings?: NotetakerCustomInstructionsSettings; + /** + * When true, Notetaker generates a list of action items. + * Requires `transcription` to also be true. + */ + actionItems?: boolean; + /** + * Settings for the action items. + */ + actionItemsSettings?: NotetakerCustomInstructionsSettings; + /** + * Seconds of continuous silence after which Notetaker leaves the meeting. + * Must be between 10 and 3600. + */ + leaveAfterSilenceSeconds?: number; + /** + * Seconds Notetaker waits after joining before it can leave automatically. + * Must be between 0 and 3600. + */ + leaveDetectionDelaySeconds?: number; + /** + * Custom announcements the Notetaker bot posts to the meeting chat. + */ + messages?: NotetakerMessages; + /** + * A static image the Notetaker bot shows as its camera feed. + */ + videoOutput?: NotetakerVideoOutputUpload; + /** + * How long Notetaker media is kept before Nylas deletes it, in seconds. + * Must be between 300 and 2592000. + */ + retentionTime?: number; +} + +/** + * A deduplication policy as returned in calendar and event responses. + * Requests accept only "inherit" and "disable"; responses can also carry + * "active" or "inactive" from a workspace or application configuration. + */ +export type NotetakerDeduplicationPolicy = + 'inherit' | 'disable' | 'active' | 'inactive'; + +/** + * Notetaker settings for calendar and event sync. + * Calendar and event sync do not support `videoOutput`. + */ +export type NotetakerSyncSettings = Omit< + NotetakerConfigSettings, + 'videoOutput' +> & { + videoOutput?: never; +}; + +/** + * Notetaker settings as returned in Notetaker responses. + * Responses can include stored metadata that the API rejects on writes, so + * send only the fields you want to change in an update instead of the + * fetched settings. + */ +export interface NotetakerConfigSettingsResponse extends Omit< + NotetakerConfigSettings, + 'videoOutput' +> { + /** + * The stored video output image, if one is set. + */ + videoOutput?: NotetakerVideoOutput; +} + /** * Interface representing Notetaker Meeting Settings */ @@ -38,6 +288,37 @@ export interface NotetakerMeetingSettings { * If transcription is true, audioRecording must also be true. */ transcription: boolean; + /** + * Optional settings that tune how Notetaker transcribes audio. + */ + transcriptionSettings?: NotetakerTranscriptionSettings | null; + /** + * When true, Notetaker generates a summary of the meeting. + * If summary is true, transcription must also be true. + */ + summary?: boolean; + /** + * Settings for the summary. + */ + summarySettings?: NotetakerCustomInstructionsSettings; + /** + * When true, Notetaker generates a list of action items. + * If actionItems is true, transcription must also be true. + */ + actionItems?: boolean; + /** + * Settings for the action items. + */ + actionItemsSettings?: NotetakerCustomInstructionsSettings; + /** + * Seconds of silence after which Notetaker leaves the meeting. + * Must be between 10 and 3600. + */ + leaveAfterSilenceSeconds?: number; + /** + * Custom announcements the Notetaker bot posts to the meeting chat. + */ + messages?: NotetakerMessages; } /** @@ -50,8 +331,12 @@ export interface Notetaker { id: string; /** * The display name for the Notetaker bot. + * The API omits this field when it returns `notetakerSettings`, as it does + * for most Notetakers created with `notetakerSettings` or `configId` and for + * Notetakers that inherit a workspace or application configuration. Read + * `notetakerSettings.name` when present and fall back to this field. */ - name: string; + name?: string; /** * When Notetaker joined the meeting, in Unix timestamp format. */ @@ -77,9 +362,16 @@ export interface Notetaker { */ eventId?: string; /** - * Notetaker Meeting Settings + * Notetaker Meeting Settings. + * The API omits this field when it returns `notetakerSettings` (see `name`). + * Read `notetakerSettings` when present and fall back to this field. + */ + meetingSettings?: NotetakerMeetingSettings; + /** + * The Notetaker's settings. + * When present, use these instead of `name` and `meetingSettings`. */ - meetingSettings: NotetakerMeetingSettings; + notetakerSettings?: NotetakerConfigSettingsResponse; } /** @@ -180,14 +472,29 @@ export interface CreateNotetakerRequest { */ joinTime?: number; + /** + * The ID of an existing configuration to use for this Notetaker. + * Cannot be used together with `notetakerSettings` or the deprecated + * `name` and `meetingSettings` fields. + */ + configId?: string; + + /** + * Notetaker settings. + * Cannot be used together with `configId` or the deprecated `name` and `meetingSettings` fields. + */ + notetakerSettings?: NotetakerConfigSettings; + /** * The display name for the Notetaker bot. * Default: Nylas Notetaker + * @deprecated Use `notetakerSettings.name` instead. */ name?: string; /** * Notetaker Meeting Settings + * @deprecated Use `notetakerSettings` instead. */ meetingSettings?: Partial; } @@ -203,14 +510,24 @@ export interface UpdateNotetakerRequest { */ joinTime?: number; + /** + * Notetaker settings to change. Omitted fields keep their current values. + * `transcriptionSettings`, `messages`, and `videoOutput` are replaced whole, + * so send the complete object you want to end up with. + * Cannot be used together with the deprecated `name` and `meetingSettings` fields. + */ + notetakerSettings?: NotetakerConfigSettings; + /** * The display name for the Notetaker bot. * Default: Nylas Notetaker + * @deprecated Use `notetakerSettings.name` instead. */ name?: string; /** * Notetaker Meeting Settings + * @deprecated Use `notetakerSettings` instead. */ meetingSettings?: Partial; } diff --git a/src/version.ts b/src/version.ts index 69694128..28d8e3e0 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1,2 +1,2 @@ // This file is generated by scripts/exportVersion.js -export const SDK_VERSION = '8.5.1'; +export const SDK_VERSION = '9.0.0'; diff --git a/tests/resources/calendars.spec.ts b/tests/resources/calendars.spec.ts index 327d458b..d43c86d2 100644 --- a/tests/resources/calendars.spec.ts +++ b/tests/resources/calendars.spec.ts @@ -4,6 +4,13 @@ import { AvailabilityMethod, SpecificTimeAvailability, } from '../../src/models/availability'; +import { + CalendarNotetaker, + CalendarNotetakerResponse, + UpdateCalenderRequest, +} from '../../src/models/calendars'; +import { NotetakerConfigSettings } from '../../src/models/notetakers'; +import { objKeysToCamelCase, objKeysToSnakeCase } from '../../src/utils'; jest.mock('../../src/apiClient'); describe('Calendars', () => { @@ -255,6 +262,129 @@ describe('Calendars', () => { }, }); }); + + it('should send notetakerSettings with nested event selection rules', async () => { + const requestBody: UpdateCalenderRequest = { + notetaker: { + notetakerSettings: { + name: 'Calendar Notetaker', + recordingType: 'audio', + transcription: true, + summary: true, + actionItems: true, + }, + deduplicationPolicy: 'disable', + rules: { + eventSelection: ['internal', ['own_events', 'external']], + participantFilter: { participantsGte: 2 }, + }, + }, + }; + + await calendars.update({ + identifier: 'id123', + calendarId: 'calendar123', + requestBody, + }); + + expect(apiClient.request).toHaveBeenCalledWith( + expect.objectContaining({ + method: 'PUT', + path: '/v3/grants/id123/calendars/calendar123', + body: requestBody, + }) + ); + expect( + objKeysToSnakeCase(requestBody as Record, ['metadata']) + ).toEqual({ + notetaker: { + notetaker_settings: { + name: 'Calendar Notetaker', + recording_type: 'audio', + transcription: true, + summary: true, + action_items: true, + }, + deduplication_policy: 'disable', + rules: { + event_selection: ['internal', ['own_events', 'external']], + participant_filter: { participants_gte: 2 }, + }, + }, + }); + }); + + it('should accept configId and autocreate modes', () => { + const fromConfig: CalendarNotetaker = { configId: 'config-123' }; + const autocreate: CalendarNotetaker = { autocreate: true }; + expect(fromConfig.configId).toBe('config-123'); + expect(autocreate.autocreate).toBe(true); + }); + + it('should only accept event selection values the API accepts', () => { + const rules: CalendarNotetaker['rules'] = { + // @ts-expect-error The API takes own_events; values are not case-converted. + eventSelection: ['ownEvents'], + }; + expect(rules).toBeDefined(); + }); + + it('should reject video output on calendar sync settings', () => { + const notetaker: CalendarNotetaker = { + notetakerSettings: { + // @ts-expect-error Calendar sync does not support videoOutput. + videoOutput: { mediaType: 'image/png', data: 'aGVsbG8=' }, + }, + }; + expect(notetaker).toBeDefined(); + + const shared: NotetakerConfigSettings = { + videoOutput: { mediaType: 'image/png', data: 'aGVsbG8=' }, + }; + const fromShared: CalendarNotetaker = { + // @ts-expect-error Reused settings with videoOutput are rejected too. + notetakerSettings: shared, + }; + expect(fromShared).toBeDefined(); + }); + + it('should camelCase notetakerSettings in calendar responses', () => { + const notetaker = objKeysToCamelCase({ + notetaker_settings: { + name: 'Calendar Notetaker', + recording_type: 'audio_video', + video_output: { media_type: 'image/png', size: 1024 }, + }, + deduplication_policy: 'active', + rules: { event_selection: ['participant_only'] }, + }) as CalendarNotetakerResponse; + + expect(notetaker.notetakerSettings?.recordingType).toBe('audio_video'); + expect(notetaker.notetakerSettings?.videoOutput?.size).toBe(1024); + expect(notetaker.deduplicationPolicy).toBe('active'); + expect(notetaker.rules?.eventSelection).toEqual(['participant_only']); + }); + + it('should not accept a fetched calendar notetaker as an update', () => { + const fetched: CalendarNotetakerResponse = { + notetakerSettings: { name: 'Calendar Notetaker', summary: true }, + deduplicationPolicy: 'active', + rules: { eventSelection: ['all'] }, + }; + const copied: UpdateCalenderRequest = { + // @ts-expect-error Fetched settings can carry values the API rejects on writes. + notetaker: fetched, + }; + const update: UpdateCalenderRequest = { + notetaker: { + notetakerSettings: { name: 'Calendar Notetaker', summary: true }, + rules: { eventSelection: ['all'] }, + deduplicationPolicy: 'disable', + }, + }; + expect(copied).toBeDefined(); + expect(update.notetaker?.notetakerSettings?.summary).toBe(true); + }); }); describe('destroy', () => { diff --git a/tests/resources/events.spec.ts b/tests/resources/events.spec.ts index 96c9a6f6..ed75e3ed 100644 --- a/tests/resources/events.spec.ts +++ b/tests/resources/events.spec.ts @@ -1,5 +1,11 @@ import APIClient from '../../src/apiClient'; import { Events } from '../../src/resources/events'; +import { + CreateEventRequest, + EventNotetakerResponse, + UpdateEventRequest, +} from '../../src/models/events'; +import { objKeysToCamelCase, objKeysToSnakeCase } from '../../src/utils'; jest.mock('../../src/apiClient'); describe('Events', () => { @@ -383,6 +389,72 @@ describe('Events', () => { }, }); }); + + it('should send notetakerSettings on an event', async () => { + const requestBody: CreateEventRequest = { + when: { time: 123, timezone: 'America/Toronto' }, + notetaker: { + notetakerSettings: { + name: 'Finance Meeting Notetaker', + recordingType: 'audio_video', + summary: true, + leaveAfterSilenceSeconds: 360, + }, + deduplicationPolicy: 'disable', + }, + }; + + await events.create({ + identifier: 'id123', + requestBody, + queryParams: { calendarId: 'calendar123' }, + }); + + expect(apiClient.request).toHaveBeenCalledWith( + expect.objectContaining({ + method: 'POST', + path: '/v3/grants/id123/events', + body: requestBody, + }) + ); + expect( + objKeysToSnakeCase(requestBody as unknown as Record, [ + 'metadata', + ]) + ).toEqual({ + when: { time: 123, timezone: 'America/Toronto' }, + notetaker: { + notetaker_settings: { + name: 'Finance Meeting Notetaker', + recording_type: 'audio_video', + summary: true, + leave_after_silence_seconds: 360, + }, + deduplication_policy: 'disable', + }, + }); + }); + + it('should camelCase notetakerSettings in event responses', () => { + const notetaker = objKeysToCamelCase({ + id: 'notetaker-123', + notetaker_settings: { + name: 'Finance Meeting Notetaker', + summary: true, + }, + deduplication_policy: 'inactive', + }) as EventNotetakerResponse; + + expect(notetaker.id).toBe('notetaker-123'); + expect(notetaker.notetakerSettings?.summary).toBe(true); + expect(notetaker.deduplicationPolicy).toBe('inactive'); + + const copied: UpdateEventRequest = { + // @ts-expect-error Fetched settings can carry values the API rejects on writes. + notetaker, + }; + expect(copied).toBeDefined(); + }); }); describe('update', () => { diff --git a/tests/resources/notetakers.spec.ts b/tests/resources/notetakers.spec.ts index 7d42e57a..bfe96523 100644 --- a/tests/resources/notetakers.spec.ts +++ b/tests/resources/notetakers.spec.ts @@ -1,7 +1,17 @@ import APIClient from '../../src/apiClient'; import { Notetakers } from '../../src/resources/notetakers'; +import { + CreateNotetakerRequest, + Notetaker, + UpdateNotetakerRequest, +} from '../../src/models/notetakers'; +import { objKeysToCamelCase, objKeysToSnakeCase } from '../../src/utils'; jest.mock('../../src/apiClient'); +// Mirrors how APIClient serializes JSON request bodies. +const toWireFormat = (body: object): Record => + objKeysToSnakeCase(body as Record, ['metadata']); + describe('Notetakers', () => { let apiClient: jest.Mocked; let notetakers: Notetakers; @@ -275,6 +285,148 @@ describe('Notetakers', () => { }); }); + it('should create a notetaker with notetakerSettings', async () => { + const requestBody: CreateNotetakerRequest = { + meetingLink: 'https://meet.google.com/abc-defg-hij', + notetakerSettings: { + name: 'Nylas Notetaker', + recordingType: 'audio', + transcription: true, + transcriptionSettings: { + expectedLanguages: ['en', 'es'], + fallbackLanguage: 'en', + keywords: ['Nylas'], + useSpeakerNamesAsKeywords: true, + }, + summary: true, + summarySettings: { customInstructions: 'Use bullet points.' }, + actionItems: true, + actionItemsSettings: { customInstructions: 'Top 5 only.' }, + leaveAfterSilenceSeconds: 600, + leaveDetectionDelaySeconds: 30, + messages: { + onJoin: [{ type: 'text', content: 'Hello', sendAfterMs: 1000 }], + onParticipantJoin: [ + { type: 'text', content: 'Welcome', debounceMs: 5000 }, + ], + }, + videoOutput: { mediaType: 'image/png', data: 'aGVsbG8=' }, + retentionTime: 604800, + }, + }; + + await notetakers.create({ + identifier: 'id123', + requestBody, + }); + + expect(apiClient.request).toHaveBeenCalledWith({ + method: 'POST', + path: '/v3/grants/id123/notetakers', + body: requestBody, + }); + expect(toWireFormat(requestBody)).toEqual({ + meeting_link: 'https://meet.google.com/abc-defg-hij', + notetaker_settings: { + name: 'Nylas Notetaker', + recording_type: 'audio', + transcription: true, + transcription_settings: { + expected_languages: ['en', 'es'], + fallback_language: 'en', + keywords: ['Nylas'], + use_speaker_names_as_keywords: true, + }, + summary: true, + summary_settings: { custom_instructions: 'Use bullet points.' }, + action_items: true, + action_items_settings: { custom_instructions: 'Top 5 only.' }, + leave_after_silence_seconds: 600, + leave_detection_delay_seconds: 30, + messages: { + on_join: [{ type: 'text', content: 'Hello', send_after_ms: 1000 }], + on_participant_join: [ + { type: 'text', content: 'Welcome', debounce_ms: 5000 }, + ], + }, + video_output: { media_type: 'image/png', data: 'aGVsbG8=' }, + retention_time: 604800, + }, + }); + }); + + it('should create a notetaker from a configuration', async () => { + const requestBody: CreateNotetakerRequest = { + meetingLink: 'https://meet.google.com/abc-defg-hij', + configId: 'config123', + }; + + await notetakers.create({ requestBody }); + + expect(apiClient.request).toHaveBeenCalledWith({ + method: 'POST', + path: '/v3/notetakers', + body: requestBody, + }); + expect(toWireFormat(requestBody)).toEqual({ + meeting_link: 'https://meet.google.com/abc-defg-hij', + config_id: 'config123', + }); + }); + + it('should type video output uploads separately from stored metadata', () => { + const disable: CreateNotetakerRequest = { + meetingLink: 'https://meet.google.com/abc-defg-hij', + notetakerSettings: { videoOutput: {} }, + }; + const missingMediaType: CreateNotetakerRequest = { + meetingLink: 'https://meet.google.com/abc-defg-hij', + // @ts-expect-error data requires mediaType + notetakerSettings: { videoOutput: { data: 'aGVsbG8=' } }, + }; + const responseMetadata: CreateNotetakerRequest = { + meetingLink: 'https://meet.google.com/abc-defg-hij', + notetakerSettings: { + // @ts-expect-error stored image metadata is read-only + videoOutput: { mediaType: 'image/png', size: 1024 }, + }, + }; + + const stored = { + mediaType: 'image/png' as const, + size: 1024, + previewUrl: 'https://example.com/preview.png', + previewUrlExpiresAt: 1234567890, + }; + const spreadStored: CreateNotetakerRequest = { + meetingLink: 'https://meet.google.com/abc-defg-hij', + notetakerSettings: { + // @ts-expect-error stored image metadata cannot ride along with an upload + videoOutput: { ...stored, data: 'aGVsbG8=' }, + }, + }; + + expect(spreadStored).toBeDefined(); + expect(toWireFormat(disable)).toEqual({ + meeting_link: 'https://meet.google.com/abc-defg-hij', + notetaker_settings: { video_output: {} }, + }); + expect(missingMediaType).toBeDefined(); + expect(responseMetadata).toBeDefined(); + }); + + it('should keep a null transcriptionSettings when serializing', () => { + const requestBody: CreateNotetakerRequest = { + meetingLink: 'https://meet.google.com/abc-defg-hij', + notetakerSettings: { transcriptionSettings: null }, + }; + + expect(toWireFormat(requestBody)).toEqual({ + meeting_link: 'https://meet.google.com/abc-defg-hij', + notetaker_settings: { transcription_settings: null }, + }); + }); + it('should create a notetaker without identifier', async () => { const requestBody = { meetingLink: 'https://meet.google.com/abc-def-ghi', @@ -330,6 +482,47 @@ describe('Notetakers', () => { }); }); + describe('response', () => { + it('should camelCase notetaker_settings in a notetaker response', () => { + const notetaker = objKeysToCamelCase({ + id: 'notetaker123', + join_time: 1234567890, + meeting_link: 'https://meet.google.com/abc-defg-hij', + meeting_provider: 'Google Meet', + state: 'scheduled', + notetaker_settings: { + name: 'Nylas Notetaker', + recording_type: 'audio', + transcription: true, + action_items: true, + messages: { on_join: null, on_participant_join: null }, + video_output: { + media_type: 'image/png', + size: 1024, + preview_url: 'https://example.com/preview.png', + preview_url_expires_at: 1234567890, + }, + }, + }) as Notetaker; + + expect(notetaker.name).toBeUndefined(); + expect(notetaker.meetingSettings).toBeUndefined(); + expect(notetaker.notetakerSettings).toEqual({ + name: 'Nylas Notetaker', + recordingType: 'audio', + transcription: true, + actionItems: true, + messages: { onJoin: null, onParticipantJoin: null }, + videoOutput: { + mediaType: 'image/png', + size: 1024, + previewUrl: 'https://example.com/preview.png', + previewUrlExpiresAt: 1234567890, + }, + }); + }); + }); + describe('find', () => { it('should find a notetaker by ID', async () => { await notetakers.find({ @@ -435,6 +628,30 @@ describe('Notetakers', () => { }); }); + it('should update a notetaker with notetakerSettings', async () => { + const requestBody: UpdateNotetakerRequest = { + notetakerSettings: { + recordingType: 'audio_video', + summary: false, + }, + }; + + await notetakers.update({ + identifier: 'id123', + notetakerId: 'notetaker123', + requestBody, + }); + + expect(apiClient.request).toHaveBeenCalledWith({ + method: 'PATCH', + path: '/v3/grants/id123/notetakers/notetaker123', + body: requestBody, + }); + expect(toWireFormat(requestBody)).toEqual({ + notetaker_settings: { recording_type: 'audio_video', summary: false }, + }); + }); + it('should update a notetaker with partial data', async () => { const requestBody = { name: 'Updated Notetaker', diff --git a/tests/types/package.cts b/tests/types/package.cts index bd92b80a..e851f92c 100644 --- a/tests/types/package.cts +++ b/tests/types/package.cts @@ -1,5 +1,6 @@ import Nylas, { Attachment, + CreateNotetakerRequest, NylasApiError, NylasOAuthError, NylasSdkTimeoutError, @@ -28,7 +29,19 @@ const apiError: NylasApiError = new NylasApiError({ void client; void classicClient; void classicDefaultClient; +const notetakerRequest: CreateNotetakerRequest = { + meetingLink: 'https://meet.google.com/abc-defg-hij', + notetakerSettings: { + name: 'Nylas Notetaker', + recordingType: 'audio', + transcription: true, + summary: true, + actionItems: true, + }, +}; + void attachment; +void notetakerRequest; void apiError; void NylasOAuthError; void NylasSdkTimeoutError; diff --git a/tests/types/package.mts b/tests/types/package.mts index 1e06b591..b37fd305 100644 --- a/tests/types/package.mts +++ b/tests/types/package.mts @@ -1,5 +1,6 @@ import Nylas, { Attachment, + CreateNotetakerRequest, NylasApiError, NylasOAuthError, NylasSdkTimeoutError, @@ -19,7 +20,19 @@ const apiError: NylasApiError = new NylasApiError({ }); void client; +const notetakerRequest: CreateNotetakerRequest = { + meetingLink: 'https://meet.google.com/abc-defg-hij', + notetakerSettings: { + name: 'Nylas Notetaker', + recordingType: 'audio', + transcription: true, + summary: true, + actionItems: true, + }, +}; + void attachment; +void notetakerRequest; void apiError; void NylasOAuthError; void NylasSdkTimeoutError;