import {z} from 'zod' export type IncidentVideoCallCreateSchema = {projectId?: string | undefined, incidentId: string, provider?: ('Zoom' | 'GoogleMeet' | 'MicrosoftTeams' | 'SlackHuddle' | 'CustomLink') | undefined, videoCallConnectionId?: string | undefined, title?: string | undefined, joinUrl?: string | undefined}; export type CreateApiIncidentVideoCallArgs = {body: {data: IncidentVideoCallCreateSchema}}; export type CreateApiIncidentVideoCallOptions = {baseUrl?: string | undefined, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const incidentVideoCallReadSchema = z.object({_id: z.string().optional(), createdAt: z.object({}).optional(), updatedAt: z.object({}).optional(), deletedAt: z.object({}).optional(), projectId: z.string().optional(), incidentId: z.string(), provider: z.enum(["Zoom", "GoogleMeet", "MicrosoftTeams", "SlackHuddle", "CustomLink"]).optional(), videoCallConnectionId: z.string().optional(), title: z.string().optional(), joinUrl: z.string().optional(), externalMeetingId: z.string().optional(), externalCalendarEventId: z.string().optional(), workspaceNotificationRuleId: z.string().optional(), transcript: z.string().optional(), transcriptSource: z.enum(["Provider", "Upload"]).optional(), transcriptInfo: z.object({}).optional(), transcriptAddedAt: z.object({}).optional(), transcriptAddedByUserId: z.string().optional(), callSummary: z.object({}).optional(), callSummaryStatus: z.enum(["Pending", "Ready", "Failed", "Skipped"]).optional(), callSummaryStatusMessage: z.string().optional(), callSummaryUpdatedAt: z.object({}).optional(), rootCauseSuggestionStatus: z.enum(["Suggested", "Accepted", "Dismissed"]).optional(), rootCauseSuggestionReviewedAt: z.object({}).optional(), rootCauseSuggestionReviewedByUserId: z.string().optional(), transcriptFetchStatus: z.enum(["Waiting", "Stopped"]).optional(), transcriptFetchReason: z.enum(["NotReady", "NotTranscribed", "NoMeeting", "Expired", "PermissionMissing", "ConnectionProblem", "NotSupported"]).optional(), transcriptFetchCheckedAt: z.object({}).optional(), transcriptFetchNextAttemptAt: z.object({}).optional(), createdByUserId: z.string().optional()}); export const createApiIncidentVideoCallResponse = z.object({data: incidentVideoCallReadSchema.optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Create Incident Video Call * * POST /incident-video-call */ export const createApiIncidentVideoCall = async (args: CreateApiIncidentVideoCallArgs, options?: CreateApiIncidentVideoCallOptions) => { const {baseUrl = "https://oneuptime.com/api", fetch: fetchFn = fetch, ApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (ApiKey !== undefined) headers.set("APIKey", ApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/incident-video-call${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(createApiIncidentVideoCallResponse, await res.json()) };