import {z} from 'zod' export type GetApiApiPublicV1IncidentSearchListArgs = {Statuses?: Array | undefined, Severities?: Array | undefined, IntegrationIds?: Array | undefined, TeamIds?: Array | undefined, UserIds?: Array | undefined, SearchTerm?: string | undefined, Unattended?: boolean | undefined, IsArchived?: boolean | undefined, IncludeSnoozed?: boolean | undefined, OnlySnoozed?: boolean | undefined, CreatedFrom?: string | undefined, CreatedUntil?: string | undefined, CreatedUntilExclusive?: string | undefined, LastUpdatedFrom?: string | undefined, Limit?: number | undefined, Offset?: number | undefined, SortBy?: string | undefined, Asc?: boolean | undefined, 'If-None-Match'?: string | undefined}; export type GetApiApiPublicV1IncidentSearchListOptions = {baseUrl: string, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const allQuietApiPublicIncidentsIncidentResourceEntityDto = z.object({id: z.string(), displayName: z.string().nullable()}); export const allQuietApiPublicIncidentsIncidentResourceVoiceMail = z.object({downloadUrl: z.string().nullable(), privateDownloadUrl: z.string().nullable()}); export const allQuietApiPublicIncidentsIncidentResourceAttribute = z.object({name: z.string().nullable(), value: z.string().nullable(), isImage: z.boolean(), isGroupingKey: z.boolean(), hideInPreviews: z.boolean(), voiceMail: allQuietApiPublicIncidentsIncidentResourceVoiceMail.optional()}); export const allQuietApiPublicIncidentsIncidentResourceUser = z.object({id: z.string().optional(), displayName: z.string().nullable(), avatarUrl: z.string().nullable(), email: z.string().nullable()}); export const allQuietApiPublicIncidentsIncidentResourceUserExternal = z.object({id: z.string().nullable(), displayName: z.string().nullable(), avatarUrl: z.string().nullable(), provider: z.string().nullable()}); export const allQuietApiPublicIncidentsIncidentResourceModification = z.object({timestamp: z.string(), intent: z.string().nullable(), user: allQuietApiPublicIncidentsIncidentResourceUser, externalUser: allQuietApiPublicIncidentsIncidentResourceUserExternal}); export const allQuietApiPublicIncidentsIncidentResourceAttributeChange = z.object({name: z.string().nullable(), newValue: z.string().nullable(), oldValue: z.string().nullable()}); export const allQuietApiPublicIncidentsIncidentResourceEvent = z.object({severity: z.string().nullable(), status: z.string().nullable(), modification: allQuietApiPublicIncidentsIncidentResourceModification, userAssignments: z.array(allQuietApiPublicIncidentsIncidentResourceUser).nullable(), onCallUsers: z.array(allQuietApiPublicIncidentsIncidentResourceUser).nullable(), message: z.string().nullable(), messageIsPublic: z.boolean().nullable(), unattended: z.boolean(), teams: z.array(allQuietApiPublicIncidentsIncidentResourceEntityDto).nullable(), attributeChanges: z.array(allQuietApiPublicIncidentsIncidentResourceAttributeChange).nullable()}); export const allQuietApiPublicIncidentsIncidentResourceSnoozingProperties = z.object({snoozedUntil: z.string().nullable()}); export const allQuietApiPublicIncidentsIncidentResourceSubIncidentEvent = z.object({severity: z.string().nullable(), status: z.string().nullable(), modification: allQuietApiPublicIncidentsIncidentResourceModification, attributeChanges: z.array(allQuietApiPublicIncidentsIncidentResourceAttributeChange).nullable()}); export const allQuietApiPublicIncidentsIncidentResourceSubIncident = z.object({id: z.string(), title: z.string().nullable(), events: z.array(allQuietApiPublicIncidentsIncidentResourceSubIncidentEvent).nullable(), attributes: z.array(allQuietApiPublicIncidentsIncidentResourceAttribute).nullable(), lastUpdatedAt: z.string(), createdAt: z.string().nullable()}); export const allQuietApiPublicIncidentsIncidentResource = z.object({id: z.string(), title: z.string().nullable(), integration: allQuietApiPublicIncidentsIncidentResourceEntityDto, createdAt: z.string().nullable(), lastUpdatedAt: z.string(), attributes: z.array(allQuietApiPublicIncidentsIncidentResourceAttribute).nullable(), events: z.array(allQuietApiPublicIncidentsIncidentResourceEvent).nullable(), eventsTotalCount: z.number().int(), services: z.array(allQuietApiPublicIncidentsIncidentResourceEntityDto).nullable(), sourceUser: allQuietApiPublicIncidentsIncidentResourceUser, unattended: z.boolean(), isArchived: z.boolean(), onCallUsers: z.array(allQuietApiPublicIncidentsIncidentResourceUser).nullable(), teams: z.array(allQuietApiPublicIncidentsIncidentResourceEntityDto).nullable(), snoozed: allQuietApiPublicIncidentsIncidentResourceSnoozingProperties, subIncidents: z.array(allQuietApiPublicIncidentsIncidentResourceSubIncident).nullable(), allowedIntents: z.array(z.string()).nullable(), canDelete: z.boolean().nullable().optional(), excludeFromUptimeCalculation: z.boolean().optional(), statusPageStartOverride: z.string().nullable().optional(), statusPageEndOverride: z.string().nullable().optional()}); export const allQuietApiPublicIncidentsIncidentResourceListResponse = z.object({incidents: z.array(allQuietApiPublicIncidentsIncidentResource).nullable().optional(), hasMore: z.boolean().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 }; /** * Search and list incidents * * GET /api/public/v1/incident/search/list */ export const getApiApiPublicV1IncidentSearchList = async (args: GetApiApiPublicV1IncidentSearchListArgs, options: GetApiApiPublicV1IncidentSearchListOptions) => { const {baseUrl, fetch: fetchFn = fetch, ApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") for (const item of args.Statuses ?? []) query.append("Statuses", String(item)) for (const item of args.Severities ?? []) query.append("Severities", String(item)) for (const item of args.IntegrationIds ?? []) query.append("IntegrationIds", String(item)) for (const item of args.TeamIds ?? []) query.append("TeamIds", String(item)) for (const item of args.UserIds ?? []) query.append("UserIds", String(item)) if (args.SearchTerm != null) query.append("SearchTerm", String(args.SearchTerm)) if (args.Unattended != null) query.append("Unattended", String(args.Unattended)) if (args.IsArchived != null) query.append("IsArchived", String(args.IsArchived)) if (args.IncludeSnoozed != null) query.append("IncludeSnoozed", String(args.IncludeSnoozed)) if (args.OnlySnoozed != null) query.append("OnlySnoozed", String(args.OnlySnoozed)) if (args.CreatedFrom != null) query.append("CreatedFrom", String(args.CreatedFrom)) if (args.CreatedUntil != null) query.append("CreatedUntil", String(args.CreatedUntil)) if (args.CreatedUntilExclusive != null) query.append("CreatedUntilExclusive", String(args.CreatedUntilExclusive)) if (args.LastUpdatedFrom != null) query.append("LastUpdatedFrom", String(args.LastUpdatedFrom)) if (args.Limit != null) query.append("Limit", String(args.Limit)) if (args.Offset != null) query.append("Offset", String(args.Offset)) if (args.SortBy != null) query.append("SortBy", String(args.SortBy)) if (args.Asc != null) query.append("Asc", String(args.Asc)) if (args['If-None-Match'] != null) headers.set("If-None-Match", String(args['If-None-Match'])) if (ApiKey !== undefined) headers.set("Authorization", ApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/api/public/v1/incident/search/list${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(allQuietApiPublicIncidentsIncidentResourceListResponse, await res.json()) };