import {z} from 'zod' export type LabelRelationSelectSchema = {_id?: boolean | undefined, createdAt?: boolean | undefined, updatedAt?: boolean | undefined, deletedAt?: boolean | undefined, name?: boolean | undefined, projectId?: boolean | undefined, color?: boolean | undefined, isArchived?: boolean | undefined}; export type MonitorStatusRelationSelectSchema = {_id?: boolean | undefined, createdAt?: boolean | undefined, updatedAt?: boolean | undefined, deletedAt?: boolean | undefined, projectId?: boolean | undefined, name?: boolean | undefined, color?: boolean | undefined, isOperationalState?: boolean | undefined, isOfflineState?: boolean | undefined, priority?: boolean | undefined, isArchived?: boolean | undefined}; export type StatusPageSelectSchema = {_id?: boolean | undefined, createdAt?: boolean | undefined, updatedAt?: boolean | undefined, deletedAt?: boolean | undefined, projectId?: boolean | undefined, name?: boolean | undefined, pageTitle?: boolean | undefined, pageDescription?: boolean | undefined, enableSearchEngineIndexing?: boolean | undefined, description?: boolean | undefined, slug?: boolean | undefined, labels?: LabelRelationSelectSchema | undefined, createdByUserId?: boolean | undefined, isArchived?: boolean | undefined, archivedAt?: boolean | undefined, archivedByUserId?: boolean | undefined, faviconFileId?: boolean | undefined, logoFileId?: boolean | undefined, darkThemeLogoFileId?: boolean | undefined, coverImageFileId?: boolean | undefined, headerHTML?: boolean | undefined, footerHTML?: boolean | undefined, customCSS?: boolean | undefined, customJavaScript?: boolean | undefined, isPublicStatusPage?: boolean | undefined, enableMcpServer?: boolean | undefined, enableMasterPassword?: boolean | undefined, masterPassword?: boolean | undefined, showIncidentLabelsOnStatusPage?: boolean | undefined, showScheduledEventLabelsOnStatusPage?: boolean | undefined, enableEmailSubscribers?: boolean | undefined, allowSubscribersToChooseResources?: boolean | undefined, allowSubscribersToChooseEventTypes?: boolean | undefined, enableSmsSubscribers?: boolean | undefined, enableSlackSubscribers?: boolean | undefined, enableMicrosoftTeamsSubscribers?: boolean | undefined, enableWebhookSubscribers?: boolean | undefined, sendSubscriberNotifications?: boolean | undefined, limitSubscribersToPrivateUsers?: boolean | undefined, allowedSubscriberEmailDomains?: boolean | undefined, copyrightText?: boolean | undefined, logoAltText?: boolean | undefined, coverImageAltText?: boolean | undefined, customFields?: boolean | undefined, requireSsoForLogin?: boolean | undefined, enableMagicLinkLogin?: boolean | undefined, privateUserSessionLengthInHours?: boolean | undefined, smtpConfigId?: boolean | undefined, callSmsConfigId?: boolean | undefined, showIncidentHistoryInDays?: boolean | undefined, showAnnouncementHistoryInDays?: boolean | undefined, showScheduledEventHistoryInDays?: boolean | undefined, overviewPageDescription?: boolean | undefined, hidePoweredByOneUptimeBranding?: boolean | undefined, defaultBarColor?: boolean | undefined, theme?: boolean | undefined, downtimeMonitorStatuses?: MonitorStatusRelationSelectSchema | undefined, subscriberTimezones?: boolean | undefined, isReportEnabled?: boolean | undefined, reportStartDateTime?: boolean | undefined, reportRecurringInterval?: boolean | undefined, sendNextReportBy?: boolean | undefined, reportDataInDays?: boolean | undefined, reportPeriodType?: boolean | undefined, reportTimezone?: boolean | undefined, showOverallUptimePercentOnStatusPage?: boolean | undefined, overallUptimePercentPrecision?: boolean | undefined, subscriberEmailNotificationFooterText?: boolean | undefined, enableCustomSubscriberEmailNotificationFooterText?: boolean | undefined, showIncidentsOnStatusPage?: boolean | undefined, onlyShowScopedIncidents?: boolean | undefined, showAnnouncementsOnStatusPage?: boolean | undefined, showEpisodesOnStatusPage?: boolean | undefined, showEpisodeHistoryInDays?: boolean | undefined, showEpisodeLabelsOnStatusPage?: boolean | undefined, showScheduledMaintenanceEventsOnStatusPage?: boolean | undefined, showSubscriberPageOnStatusPage?: boolean | undefined, ipWhitelist?: boolean | undefined, enableEmbeddedOverallStatus?: boolean | undefined, showUptimeHistoryInDays?: boolean | undefined, embeddedOverallStatusToken?: boolean | undefined, defaultLanguage?: boolean | undefined, enabledLanguages?: boolean | undefined}; export type CreateApiStatusPageIdGetItemArgs = {id: string, body: {select?: StatusPageSelectSchema | undefined}}; export type CreateApiStatusPageIdGetItemOptions = {baseUrl?: string | undefined, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const statusPage = z.object({_id: z.string().optional(), createdAt: z.object({}).optional(), updatedAt: z.object({}).optional(), deletedAt: z.object({}).optional(), version: z.number().optional(), projectId: z.string(), name: z.string(), pageTitle: z.string().optional(), pageDescription: z.string().optional(), enableSearchEngineIndexing: z.boolean().optional(), description: z.string().optional(), slug: z.string(), labels: z.array(z.object({_id: z.string().optional()})).optional(), createdByUserId: z.string().optional(), isArchived: z.boolean(), archivedAt: z.object({}).optional(), archivedByUserId: z.string().optional(), faviconFileId: z.string().optional(), logoFileId: z.string().optional(), darkThemeLogoFileId: z.string().optional(), coverImageFileId: z.string().optional(), headerHTML: z.string().optional(), footerHTML: z.string().optional(), customCSS: z.string().optional(), customJavaScript: z.string().optional(), isPublicStatusPage: z.boolean().optional(), enableMcpServer: z.boolean().optional(), enableMasterPassword: z.boolean().optional(), masterPassword: z.string().optional(), showIncidentLabelsOnStatusPage: z.boolean().optional(), showScheduledEventLabelsOnStatusPage: z.boolean().optional(), enableEmailSubscribers: z.boolean().optional(), allowSubscribersToChooseResources: z.boolean().optional(), allowSubscribersToChooseEventTypes: z.boolean().optional(), enableSmsSubscribers: z.boolean().optional(), enableSlackSubscribers: z.boolean().optional(), enableMicrosoftTeamsSubscribers: z.boolean().optional(), enableWebhookSubscribers: z.boolean().optional(), sendSubscriberNotifications: z.boolean().optional(), limitSubscribersToPrivateUsers: z.boolean().optional(), allowedSubscriberEmailDomains: z.string().optional(), copyrightText: z.string().optional(), logoAltText: z.string().optional(), coverImageAltText: z.string().optional(), customFields: z.object({}).optional(), requireSsoForLogin: z.boolean(), enableMagicLinkLogin: z.boolean().optional(), privateUserSessionLengthInHours: z.number().optional(), smtpConfigId: z.string().optional(), callSmsConfigId: z.string().optional(), isOwnerNotifiedOfResourceCreation: z.boolean(), showIncidentHistoryInDays: z.number(), showAnnouncementHistoryInDays: z.number(), showScheduledEventHistoryInDays: z.number(), overviewPageDescription: z.string().optional(), hidePoweredByOneUptimeBranding: z.boolean().optional(), defaultBarColor: z.object({}).optional(), theme: z.enum(["Light", "Dark", "System"]).optional(), downtimeMonitorStatuses: z.array(z.object({_id: z.string().optional()})).optional(), subscriberTimezones: z.object({}).optional(), isReportEnabled: z.boolean().optional(), reportStartDateTime: z.object({}).optional(), reportRecurringInterval: z.object({}).optional(), sendNextReportBy: z.object({}).optional(), reportDataInDays: z.number().optional(), reportPeriodType: z.enum(["Rolling", "Previous Calendar Period"]).optional(), reportTimezone: z.string().optional(), showOverallUptimePercentOnStatusPage: z.boolean().optional(), overallUptimePercentPrecision: z.enum(["99% (No Decimal)", "99.9% (One Decimal)", "99.99% (Two Decimal)", "99.999% (Three Decimal)"]).optional(), subscriberEmailNotificationFooterText: z.string().optional(), enableCustomSubscriberEmailNotificationFooterText: z.boolean().optional(), showIncidentsOnStatusPage: z.boolean().optional(), onlyShowScopedIncidents: z.boolean().optional(), showAnnouncementsOnStatusPage: z.boolean().optional(), showEpisodesOnStatusPage: z.boolean().optional(), showEpisodeHistoryInDays: z.number().optional(), showEpisodeLabelsOnStatusPage: z.boolean().optional(), showScheduledMaintenanceEventsOnStatusPage: z.boolean().optional(), showSubscriberPageOnStatusPage: z.boolean().optional(), ipWhitelist: z.string().optional(), enableEmbeddedOverallStatus: z.boolean().optional(), showUptimeHistoryInDays: z.number().optional(), embeddedOverallStatusToken: z.string().optional(), defaultLanguage: z.string().optional(), enabledLanguages: z.object({}).optional()}); export const createApiStatusPageIdGetItemResponse = z.object({data: statusPage.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 }; /** * Get Status Page * * POST /status-page/{id}/get-item */ export const createApiStatusPageIdGetItem = async (args: CreateApiStatusPageIdGetItemArgs, options?: CreateApiStatusPageIdGetItemOptions) => { 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(/\/+$/, '')}/status-page/${encodeURIComponent(String(args.id))}/get-item${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(createApiStatusPageIdGetItemResponse, await res.json()) };