import {z} from 'zod' export type ThreatIntelIndicatorItemV1QuerySchema = {projectId?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array}) | undefined, feedId?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array}) | undefined, feedName?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, stixId?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, indicatorType?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, indicatorValue?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, indicatorName?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, confidence?: (number | {_type: 'NotEqual', value: number} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: number} | {_type: 'GreaterThanOrEqual', value: number} | {_type: 'LessThan', value: number} | {_type: 'LessThanOrEqual', value: number} | {_type: 'InBetween', startValue: number, endValue: number}) | undefined, stixLabels?: ({_type: 'EqualTo', value: string} | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'Search', value: string}) | undefined, validFrom?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: string} | {_type: 'GreaterThanOrEqual', value: string} | {_type: 'LessThan', value: string} | {_type: 'LessThanOrEqual', value: string} | {_type: 'InBetween', startValue: string, endValue: string}) | undefined, validUntil?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: string} | {_type: 'GreaterThanOrEqual', value: string} | {_type: 'LessThan', value: string} | {_type: 'LessThanOrEqual', value: string} | {_type: 'InBetween', startValue: string, endValue: string}) | undefined, revoked?: (boolean | {_type: 'NotEqual', value: boolean} | {_type: 'IsNull'} | {_type: 'NotNull'}) | undefined, version?: (number | string | {_type: 'NotEqual', value: number | string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: number | string} | {_type: 'GreaterThanOrEqual', value: number | string} | {_type: 'LessThan', value: number | string} | {_type: 'LessThanOrEqual', value: number | string} | {_type: 'InBetween', startValue: number | string, endValue: number | string}) | undefined, retentionDate?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: string} | {_type: 'GreaterThanOrEqual', value: string} | {_type: 'LessThan', value: string} | {_type: 'LessThanOrEqual', value: string} | {_type: 'InBetween', startValue: string, endValue: string}) | undefined, _id?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array}) | undefined, createdAt?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: string} | {_type: 'GreaterThanOrEqual', value: string} | {_type: 'LessThan', value: string} | {_type: 'LessThanOrEqual', value: string} | {_type: 'InBetween', startValue: string, endValue: string}) | undefined}; export type ThreatIntelIndicatorItemV1SelectSchema = {projectId?: boolean | undefined, feedId?: boolean | undefined, feedName?: boolean | undefined, stixId?: boolean | undefined, indicatorType?: boolean | undefined, indicatorValue?: boolean | undefined, indicatorName?: boolean | undefined, confidence?: boolean | undefined, stixLabels?: boolean | undefined, validFrom?: boolean | undefined, validUntil?: boolean | undefined, revoked?: boolean | undefined, version?: boolean | undefined, retentionDate?: boolean | undefined, _id?: boolean | undefined, createdAt?: boolean | undefined}; export type ThreatIntelIndicatorItemV1SortSchema = {projectId?: ('ASC' | 'DESC') | undefined, feedId?: ('ASC' | 'DESC') | undefined, feedName?: ('ASC' | 'DESC') | undefined, stixId?: ('ASC' | 'DESC') | undefined, indicatorType?: ('ASC' | 'DESC') | undefined, indicatorValue?: ('ASC' | 'DESC') | undefined, indicatorName?: ('ASC' | 'DESC') | undefined, confidence?: ('ASC' | 'DESC') | undefined, validFrom?: ('ASC' | 'DESC') | undefined, validUntil?: ('ASC' | 'DESC') | undefined, revoked?: ('ASC' | 'DESC') | undefined, version?: ('ASC' | 'DESC') | undefined, retentionDate?: ('ASC' | 'DESC') | undefined, _id?: ('ASC' | 'DESC') | undefined, createdAt?: ('ASC' | 'DESC') | undefined}; export type ThreatIntelIndicatorItemV1GroupBySchema = {projectId?: boolean | undefined, feedId?: boolean | undefined, feedName?: boolean | undefined, stixId?: boolean | undefined, indicatorType?: boolean | undefined, indicatorValue?: boolean | undefined, indicatorName?: boolean | undefined, confidence?: boolean | undefined, revoked?: boolean | undefined, retentionDate?: boolean | undefined, _id?: boolean | undefined, createdAt?: boolean | undefined}; export type CreateApiThreatIntelIndicatorsGetListArgs = {body: {query?: ThreatIntelIndicatorItemV1QuerySchema | undefined, select?: ThreatIntelIndicatorItemV1SelectSchema | undefined, sort?: ThreatIntelIndicatorItemV1SortSchema | undefined, groupBy?: ThreatIntelIndicatorItemV1GroupBySchema | undefined, limit?: number | undefined, skip?: number | undefined}}; export type CreateApiThreatIntelIndicatorsGetListOptions = {baseUrl?: string | undefined, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const threatIntelIndicatorItemV1 = z.object({projectId: z.string(), feedId: z.string(), feedName: z.string().optional(), stixId: z.string().optional(), indicatorType: z.string().optional(), indicatorValue: z.string().optional(), indicatorName: z.string().optional(), confidence: z.number().optional(), stixLabels: z.array(z.string()).optional(), validFrom: z.string().optional(), validUntil: z.string().optional(), revoked: z.boolean().optional(), version: z.string().optional(), retentionDate: z.string()}); export const createApiThreatIntelIndicatorsGetListResponse = z.object({data: z.array(threatIntelIndicatorItemV1).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 Threat Intel Indicator * * POST /threat-intel-indicators/get-list */ export const createApiThreatIntelIndicatorsGetList = async (args: CreateApiThreatIntelIndicatorsGetListArgs, options?: CreateApiThreatIntelIndicatorsGetListOptions) => { 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(/\/+$/, '')}/threat-intel-indicators/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(createApiThreatIntelIndicatorsGetListResponse, await res.json()) };