Fix/zoom response zod object (#3141)
* Added deepPartial to zodResultSchema * Adding passtrough to zoomResponseSchemapull/3147/head
parent
6f354e0c7f
commit
fef6f3baff
|
@ -10,31 +10,29 @@ import type { VideoApiAdapter, VideoCallData } from "@calcom/types/VideoApiAdapt
|
|||
import { getZoomAppKeys } from "./getZoomAppKeys";
|
||||
|
||||
/** @link https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetingcreate */
|
||||
export const zoomEventResultSchema = z.object({
|
||||
assistant_id: z.string().optional(),
|
||||
host_email: z.string(),
|
||||
id: z.number(),
|
||||
registration_url: z.string().optional(),
|
||||
agenda: z.string().optional(),
|
||||
created_at: z.string(),
|
||||
duration: z.number(),
|
||||
h323_password: z.string(),
|
||||
join_url: z.string(),
|
||||
occurrences: z
|
||||
.array(
|
||||
export const zoomEventResultSchema = z
|
||||
.object({
|
||||
assistant_id: z.string(),
|
||||
host_email: z.string(),
|
||||
id: z.number(),
|
||||
registration_url: z.string(),
|
||||
agenda: z.string(),
|
||||
created_at: z.string(),
|
||||
duration: z.number(),
|
||||
h323_password: z.string(),
|
||||
join_url: z.string(),
|
||||
occurrences: z.array(
|
||||
z.object({
|
||||
duration: z.number(),
|
||||
occurrence_id: z.string(),
|
||||
start_time: z.string(),
|
||||
status: z.string(),
|
||||
})
|
||||
)
|
||||
.optional(),
|
||||
password: z.string(),
|
||||
pmi: z.number().optional(),
|
||||
pre_schedule: z.boolean(),
|
||||
recurrence: z
|
||||
.object({
|
||||
),
|
||||
password: z.string(),
|
||||
pmi: z.number(),
|
||||
pre_schedule: z.boolean(),
|
||||
recurrence: z.object({
|
||||
end_date_time: z.string(),
|
||||
end_times: z.number(),
|
||||
monthly_day: z.number(),
|
||||
|
@ -43,46 +41,44 @@ export const zoomEventResultSchema = z.object({
|
|||
repeat_interval: z.number(),
|
||||
type: z.number(),
|
||||
weekly_days: z.string(),
|
||||
})
|
||||
.optional(),
|
||||
settings: z.object({
|
||||
allow_multiple_devices: z.boolean(),
|
||||
alternative_hosts: z.string(),
|
||||
alternative_hosts_email_notification: z.boolean(),
|
||||
alternative_host_update_polls: z.boolean(),
|
||||
approval_type: z.number(),
|
||||
approved_or_denied_countries_or_regions: z.object({
|
||||
approved_list: z.array(z.string()).optional(),
|
||||
denied_list: z.array(z.string()).optional(),
|
||||
enable: z.boolean(),
|
||||
method: z.string().optional(),
|
||||
}),
|
||||
audio: z.string(),
|
||||
authentication_domains: z.string().optional(),
|
||||
authentication_exception: z
|
||||
.array(z.object({ email: z.string(), name: z.string(), join_url: z.string() }))
|
||||
.optional(),
|
||||
authentication_name: z.string().optional(),
|
||||
authentication_option: z.string().optional(),
|
||||
auto_recording: z.string(),
|
||||
breakout_room: z.object({
|
||||
enable: z.boolean(),
|
||||
rooms: z.array(z.object({ name: z.string(), participants: z.array(z.string()) })).optional(),
|
||||
}),
|
||||
calendar_type: z.number().optional(),
|
||||
close_registration: z.boolean(),
|
||||
cn_meeting: z.boolean(),
|
||||
contact_email: z.string().optional(),
|
||||
contact_name: z.string().optional(),
|
||||
custom_keys: z.array(z.object({ key: z.string(), value: z.string() })).optional(),
|
||||
email_notification: z.boolean(),
|
||||
encryption_type: z.string(),
|
||||
enforce_login: z.boolean(),
|
||||
enforce_login_domains: z.string(),
|
||||
focus_mode: z.boolean(),
|
||||
global_dial_in_countries: z.array(z.string()).optional(),
|
||||
global_dial_in_numbers: z
|
||||
.array(
|
||||
settings: z.object({
|
||||
allow_multiple_devices: z.boolean(),
|
||||
alternative_hosts: z.string(),
|
||||
alternative_hosts_email_notification: z.boolean(),
|
||||
alternative_host_update_polls: z.boolean(),
|
||||
approval_type: z.number(),
|
||||
approved_or_denied_countries_or_regions: z.object({
|
||||
approved_list: z.array(z.string()),
|
||||
denied_list: z.array(z.string()),
|
||||
enable: z.boolean(),
|
||||
method: z.string(),
|
||||
}),
|
||||
audio: z.string(),
|
||||
authentication_domains: z.string(),
|
||||
authentication_exception: z.array(
|
||||
z.object({ email: z.string(), name: z.string(), join_url: z.string() })
|
||||
),
|
||||
authentication_name: z.string(),
|
||||
authentication_option: z.string(),
|
||||
auto_recording: z.string(),
|
||||
breakout_room: z.object({
|
||||
enable: z.boolean(),
|
||||
rooms: z.array(z.object({ name: z.string(), participants: z.array(z.string()) })),
|
||||
}),
|
||||
calendar_type: z.number(),
|
||||
close_registration: z.boolean(),
|
||||
cn_meeting: z.boolean(),
|
||||
contact_email: z.string(),
|
||||
contact_name: z.string(),
|
||||
custom_keys: z.array(z.object({ key: z.string(), value: z.string() })),
|
||||
email_notification: z.boolean(),
|
||||
encryption_type: z.string(),
|
||||
enforce_login: z.boolean(),
|
||||
enforce_login_domains: z.string(),
|
||||
focus_mode: z.boolean(),
|
||||
global_dial_in_countries: z.array(z.string()),
|
||||
global_dial_in_numbers: z.array(
|
||||
z.object({
|
||||
city: z.string(),
|
||||
country: z.string(),
|
||||
|
@ -90,40 +86,36 @@ export const zoomEventResultSchema = z.object({
|
|||
number: z.string(),
|
||||
type: z.string(),
|
||||
})
|
||||
)
|
||||
.optional(),
|
||||
host_video: z.boolean(),
|
||||
in_meeting: z.boolean(),
|
||||
jbh_time: z.number(),
|
||||
join_before_host: z.boolean(),
|
||||
language_interpretation: z
|
||||
.object({
|
||||
),
|
||||
host_video: z.boolean(),
|
||||
in_meeting: z.boolean(),
|
||||
jbh_time: z.number(),
|
||||
join_before_host: z.boolean(),
|
||||
language_interpretation: z.object({
|
||||
enable: z.boolean(),
|
||||
interpreters: z.array(z.object({ email: z.string(), languages: z.string() })),
|
||||
})
|
||||
.optional(),
|
||||
meeting_authentication: z.boolean(),
|
||||
mute_upon_entry: z.boolean(),
|
||||
participant_video: z.boolean(),
|
||||
private_meeting: z.boolean(),
|
||||
registrants_confirmation_email: z.boolean(),
|
||||
registrants_email_notification: z.boolean(),
|
||||
registration_type: z.number().optional(),
|
||||
show_share_button: z.boolean(),
|
||||
use_pmi: z.boolean(),
|
||||
waiting_room: z.boolean(),
|
||||
watermark: z.boolean(),
|
||||
host_save_video_order: z.boolean(),
|
||||
}),
|
||||
start_time: z.string(),
|
||||
start_url: z.string(),
|
||||
timezone: z.string(),
|
||||
topic: z.string(),
|
||||
tracking_fields: z
|
||||
.array(z.object({ field: z.string(), value: z.string(), visible: z.boolean() }))
|
||||
.optional(),
|
||||
type: z.number(),
|
||||
});
|
||||
}),
|
||||
meeting_authentication: z.boolean(),
|
||||
mute_upon_entry: z.boolean(),
|
||||
participant_video: z.boolean(),
|
||||
private_meeting: z.boolean(),
|
||||
registrants_confirmation_email: z.boolean(),
|
||||
registrants_email_notification: z.boolean(),
|
||||
registration_type: z.number(),
|
||||
show_share_button: z.boolean(),
|
||||
use_pmi: z.boolean(),
|
||||
waiting_room: z.boolean(),
|
||||
watermark: z.boolean(),
|
||||
host_save_video_order: z.boolean(),
|
||||
}),
|
||||
start_time: z.string(),
|
||||
start_url: z.string(),
|
||||
timezone: z.string(),
|
||||
topic: z.string(),
|
||||
tracking_fields: z.array(z.object({ field: z.string(), value: z.string(), visible: z.boolean() })),
|
||||
type: z.number(),
|
||||
})
|
||||
.deepPartial();
|
||||
|
||||
export type ZoomEventResult = z.infer<typeof zoomEventResultSchema>;
|
||||
|
||||
|
@ -280,14 +272,16 @@ const ZoomVideoApiAdapter = (credential: Credential): VideoApiAdapter => {
|
|||
body: JSON.stringify(translateEvent(event)),
|
||||
});
|
||||
|
||||
const result = zoomEventResultSchema.parse(response);
|
||||
|
||||
return Promise.resolve({
|
||||
type: "zoom_video",
|
||||
id: result.id.toString(),
|
||||
password: result.password,
|
||||
url: result.join_url,
|
||||
});
|
||||
const result = zoomEventResultSchema.passthrough().parse(response);
|
||||
if (result.id && result.join_url) {
|
||||
return Promise.resolve({
|
||||
type: "zoom_video",
|
||||
id: result.id.toString(),
|
||||
password: result.password || "",
|
||||
url: result.join_url,
|
||||
});
|
||||
}
|
||||
return Promise.reject(new Error("Failed to create meeting"));
|
||||
},
|
||||
deleteMeeting: async (uid: string): Promise<void> => {
|
||||
await fetchZoomApi(`meetings/${uid}`, {
|
||||
|
|
Loading…
Reference in New Issue