import {z} from 'zod' export type ObjectIDFilter = string | {_type: 'EqualTo', value: string} | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'EqualToOrNull', value: string} | {_type: 'Includes', value: Array}; export type DateFilter = string | {_type: 'EqualTo', value: string} | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'EqualToOrNull', value: string} | {_type: 'GreaterThan', value: string} | {_type: 'LessThan', value: string} | {_type: 'GreaterThanOrEqual', value: string} | {_type: 'LessThanOrEqual', value: string} | {_type: 'InBetween', startValue: string, endValue: string}; export type ShortTextFilter = string | {_type: 'EqualTo', value: string} | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string} | {_type: 'Includes', value: Array}; export type LongTextFilter = string | {_type: 'EqualTo', value: string} | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string} | {_type: 'Includes', value: Array}; export type BooleanFilter = boolean | {_type: 'EqualTo', value: boolean} | {_type: 'NotEqual', value: boolean} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'EqualToOrNull', value: boolean}; export type UserOnCallLogTimelineQuerySchema = {_id?: ObjectIDFilter | undefined, createdAt?: DateFilter | undefined, updatedAt?: DateFilter | undefined, deletedAt?: DateFilter | undefined, userId?: ObjectIDFilter | undefined, projectId?: ObjectIDFilter | undefined, userNotificationLogId?: ObjectIDFilter | undefined, userNotificationRuleId?: ObjectIDFilter | undefined, onCallDutyPolicyId?: ObjectIDFilter | undefined, triggeredByIncidentId?: ObjectIDFilter | undefined, triggeredByAlertId?: ObjectIDFilter | undefined, triggeredByAlertEpisodeId?: ObjectIDFilter | undefined, triggeredByIncidentEpisodeId?: ObjectIDFilter | undefined, onCallDutyPolicyExecutionLogId?: ObjectIDFilter | undefined, onCallDutyPolicyExecutionLogTimelineId?: ObjectIDFilter | undefined, userNotificationEventType?: ShortTextFilter | undefined, onCallDutyPolicyEscalationRuleId?: ObjectIDFilter | undefined, userBelongsToTeamId?: ObjectIDFilter | undefined, statusMessage?: LongTextFilter | undefined, status?: ShortTextFilter | undefined, createdByUserId?: ObjectIDFilter | undefined, isAcknowledged?: BooleanFilter | undefined, acknowledgedAt?: DateFilter | undefined, userCallId?: ObjectIDFilter | undefined, userSmsId?: ObjectIDFilter | undefined, userWhatsAppId?: ObjectIDFilter | undefined, userTelegramId?: ObjectIDFilter | undefined, userSlackId?: ObjectIDFilter | undefined, userMicrosoftTeamsId?: ObjectIDFilter | undefined, userMattermostId?: ObjectIDFilter | undefined, userWebhookId?: ObjectIDFilter | undefined, customNotificationChannelId?: ObjectIDFilter | undefined, userEmailId?: ObjectIDFilter | undefined, userPushId?: ObjectIDFilter | undefined}; export type UserOnCallLogTimelineSelectSchema = {_id?: boolean | undefined, createdAt?: boolean | undefined, updatedAt?: boolean | undefined, deletedAt?: boolean | undefined, userId?: boolean | undefined, projectId?: boolean | undefined, userNotificationLogId?: boolean | undefined, userNotificationRuleId?: boolean | undefined, onCallDutyPolicyId?: boolean | undefined, triggeredByIncidentId?: boolean | undefined, triggeredByAlertId?: boolean | undefined, triggeredByAlertEpisodeId?: boolean | undefined, triggeredByIncidentEpisodeId?: boolean | undefined, onCallDutyPolicyExecutionLogId?: boolean | undefined, onCallDutyPolicyExecutionLogTimelineId?: boolean | undefined, userNotificationEventType?: boolean | undefined, onCallDutyPolicyEscalationRuleId?: boolean | undefined, userBelongsToTeamId?: boolean | undefined, statusMessage?: boolean | undefined, status?: boolean | undefined, createdByUserId?: boolean | undefined, isAcknowledged?: boolean | undefined, acknowledgedAt?: boolean | undefined, userCallId?: boolean | undefined, userSmsId?: boolean | undefined, userWhatsAppId?: boolean | undefined, userTelegramId?: boolean | undefined, userSlackId?: boolean | undefined, userMicrosoftTeamsId?: boolean | undefined, userMattermostId?: boolean | undefined, userWebhookId?: boolean | undefined, customNotificationChannelId?: boolean | undefined, userEmailId?: boolean | undefined, userPushId?: boolean | undefined}; export type SortOrder = 'ASC' | 'DESC'; export type UserOnCallLogTimelineSortSchema = {_id?: SortOrder | undefined, createdAt?: SortOrder | undefined, updatedAt?: SortOrder | undefined, deletedAt?: SortOrder | undefined, userId?: SortOrder | undefined, projectId?: SortOrder | undefined, userNotificationLogId?: SortOrder | undefined, userNotificationRuleId?: SortOrder | undefined, onCallDutyPolicyId?: SortOrder | undefined, triggeredByIncidentId?: SortOrder | undefined, triggeredByAlertId?: SortOrder | undefined, triggeredByAlertEpisodeId?: SortOrder | undefined, triggeredByIncidentEpisodeId?: SortOrder | undefined, onCallDutyPolicyExecutionLogId?: SortOrder | undefined, onCallDutyPolicyExecutionLogTimelineId?: SortOrder | undefined, userNotificationEventType?: SortOrder | undefined, onCallDutyPolicyEscalationRuleId?: SortOrder | undefined, userBelongsToTeamId?: SortOrder | undefined, statusMessage?: SortOrder | undefined, status?: SortOrder | undefined, createdByUserId?: SortOrder | undefined, isAcknowledged?: SortOrder | undefined, acknowledgedAt?: SortOrder | undefined, userCallId?: SortOrder | undefined, userSmsId?: SortOrder | undefined, userWhatsAppId?: SortOrder | undefined, userTelegramId?: SortOrder | undefined, userSlackId?: SortOrder | undefined, userMicrosoftTeamsId?: SortOrder | undefined, userMattermostId?: SortOrder | undefined, userWebhookId?: SortOrder | undefined, customNotificationChannelId?: SortOrder | undefined, userEmailId?: SortOrder | undefined, userPushId?: SortOrder | undefined}; export type CreateApiUserNotificationLogTimelineGetListArgs = {body: {query?: UserOnCallLogTimelineQuerySchema | undefined, select?: UserOnCallLogTimelineSelectSchema | undefined, sort?: UserOnCallLogTimelineSortSchema | undefined, limit?: number | undefined, skip?: number | undefined}}; export type CreateApiUserNotificationLogTimelineGetListOptions = {baseUrl?: string | undefined, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const userOnCallLogTimeline = z.object({_id: z.string().optional(), createdAt: z.object({}).optional(), updatedAt: z.object({}).optional(), deletedAt: z.object({}).optional(), version: z.number().optional(), userId: z.string().optional(), projectId: z.string(), userNotificationLogId: z.string(), userNotificationRuleId: z.string().optional(), onCallDutyPolicyId: z.string().optional(), triggeredByIncidentId: z.string().optional(), triggeredByAlertId: z.string().optional(), triggeredByAlertEpisodeId: z.string().optional(), triggeredByIncidentEpisodeId: z.string().optional(), onCallDutyPolicyExecutionLogId: z.string(), onCallDutyPolicyExecutionLogTimelineId: z.string(), userNotificationEventType: z.enum(["Incident Created", "Alert Created", "Alert Episode Created", "Incident Episode Created"]), onCallDutyPolicyEscalationRuleId: z.string().optional(), userBelongsToTeamId: z.string().optional(), statusMessage: z.string(), status: z.enum(["Sent", "Acknowledged", "Error", "Sending", "Skipped", "Passed On"]), createdByUserId: z.string().optional(), isAcknowledged: z.boolean().optional(), acknowledgedAt: z.object({}).optional(), userCallId: z.string().optional(), userSmsId: z.string().optional(), userWhatsAppId: z.string().optional(), userTelegramId: z.string().optional(), userSlackId: z.string().optional(), userMicrosoftTeamsId: z.string().optional(), userMattermostId: z.string().optional(), userWebhookId: z.string().optional(), customNotificationChannelId: z.string().optional(), userEmailId: z.string().optional(), userPushId: z.string().optional()}); export const createApiUserNotificationLogTimelineGetListResponse = z.object({data: z.array(userOnCallLogTimeline).optional(), count: z.number().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 }; /** * List User On-Call Log Timeline * * POST /user-notification-log-timeline/get-list */ export const createApiUserNotificationLogTimelineGetList = async (args: CreateApiUserNotificationLogTimelineGetListArgs, options?: CreateApiUserNotificationLogTimelineGetListOptions) => { 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(/\/+$/, '')}/user-notification-log-timeline/get-list${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(createApiUserNotificationLogTimelineGetListResponse, await res.json()) };