import {z} from 'zod' export type SpanItemV3QuerySchema = {projectId?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array}) | undefined, primaryEntityId?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array}) | undefined, primaryEntityType?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, startTime?: (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, endTime?: (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, startTimeUnixNano?: (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, durationUnixNano?: (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, endTimeUnixNano?: (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, traceId?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, spanId?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, sessionId?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, parentSpanId?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, traceState?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, attributes?: ({[key: string]: string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Search', value: string}}) | undefined, attributeKeys?: ({_type: 'EqualTo', value: string} | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'Search', value: string}) | undefined, entityKeys?: ({_type: 'EqualTo', value: string} | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'Search', value: string}) | undefined, serviceEntityKey?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, hostEntityKey?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, k8sPodEntityKey?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, k8sNodeEntityKey?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, k8sClusterEntityKey?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, containerEntityKey?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, events?: ({_type: 'IsNull'} | {_type: 'NotNull'}) | undefined, links?: ({_type: 'IsNull'} | {_type: 'NotNull'}) | undefined, statusCode?: (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, statusMessage?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, name?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, kind?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, hasException?: (boolean | {_type: 'NotEqual', value: boolean} | {_type: 'IsNull'} | {_type: 'NotNull'}) | undefined, isRootSpan?: (boolean | {_type: 'NotEqual', value: boolean} | {_type: 'IsNull'} | {_type: 'NotNull'}) | undefined, isEntrySpan?: (boolean | {_type: 'NotEqual', value: boolean} | {_type: 'IsNull'} | {_type: 'NotNull'}) | undefined, isLlmSpan?: (boolean | {_type: 'NotEqual', value: boolean} | {_type: 'IsNull'} | {_type: 'NotNull'}) | undefined, llmSystem?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, llmOperation?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, llmRequestModel?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, llmResponseModel?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, llmAgentName?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, llmToolName?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, llmInputTokens?: (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, llmOutputTokens?: (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, llmTotalTokens?: (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, llmCost?: (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, llmConversationId?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, llmUserId?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, llmUserEmail?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, llmTeam?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, llmCallKind?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, llmIssues?: ({_type: 'EqualTo', value: string} | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'Search', value: string}) | undefined, llmUserMessagePreview?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: 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 SpanItemV3SelectSchema = {projectId?: boolean | undefined, primaryEntityId?: boolean | undefined, primaryEntityType?: boolean | undefined, startTime?: boolean | undefined, endTime?: boolean | undefined, startTimeUnixNano?: boolean | undefined, durationUnixNano?: boolean | undefined, endTimeUnixNano?: boolean | undefined, traceId?: boolean | undefined, spanId?: boolean | undefined, sessionId?: boolean | undefined, parentSpanId?: boolean | undefined, traceState?: boolean | undefined, attributes?: boolean | undefined, attributeKeys?: boolean | undefined, entityKeys?: boolean | undefined, serviceEntityKey?: boolean | undefined, hostEntityKey?: boolean | undefined, k8sPodEntityKey?: boolean | undefined, k8sNodeEntityKey?: boolean | undefined, k8sClusterEntityKey?: boolean | undefined, containerEntityKey?: boolean | undefined, events?: boolean | undefined, links?: boolean | undefined, statusCode?: boolean | undefined, statusMessage?: boolean | undefined, name?: boolean | undefined, kind?: boolean | undefined, hasException?: boolean | undefined, isRootSpan?: boolean | undefined, isEntrySpan?: boolean | undefined, isLlmSpan?: boolean | undefined, llmSystem?: boolean | undefined, llmOperation?: boolean | undefined, llmRequestModel?: boolean | undefined, llmResponseModel?: boolean | undefined, llmAgentName?: boolean | undefined, llmToolName?: boolean | undefined, llmInputTokens?: boolean | undefined, llmOutputTokens?: boolean | undefined, llmTotalTokens?: boolean | undefined, llmCost?: boolean | undefined, llmConversationId?: boolean | undefined, llmUserId?: boolean | undefined, llmUserEmail?: boolean | undefined, llmTeam?: boolean | undefined, llmCallKind?: boolean | undefined, llmIssues?: boolean | undefined, llmUserMessagePreview?: boolean | undefined, _id?: boolean | undefined, createdAt?: boolean | undefined}; export type SpanItemV3SortSchema = {projectId?: ('ASC' | 'DESC') | undefined, primaryEntityId?: ('ASC' | 'DESC') | undefined, primaryEntityType?: ('ASC' | 'DESC') | undefined, startTime?: ('ASC' | 'DESC') | undefined, endTime?: ('ASC' | 'DESC') | undefined, startTimeUnixNano?: ('ASC' | 'DESC') | undefined, durationUnixNano?: ('ASC' | 'DESC') | undefined, endTimeUnixNano?: ('ASC' | 'DESC') | undefined, traceId?: ('ASC' | 'DESC') | undefined, spanId?: ('ASC' | 'DESC') | undefined, sessionId?: ('ASC' | 'DESC') | undefined, parentSpanId?: ('ASC' | 'DESC') | undefined, traceState?: ('ASC' | 'DESC') | undefined, serviceEntityKey?: ('ASC' | 'DESC') | undefined, hostEntityKey?: ('ASC' | 'DESC') | undefined, k8sPodEntityKey?: ('ASC' | 'DESC') | undefined, k8sNodeEntityKey?: ('ASC' | 'DESC') | undefined, k8sClusterEntityKey?: ('ASC' | 'DESC') | undefined, containerEntityKey?: ('ASC' | 'DESC') | undefined, statusCode?: ('ASC' | 'DESC') | undefined, statusMessage?: ('ASC' | 'DESC') | undefined, name?: ('ASC' | 'DESC') | undefined, kind?: ('ASC' | 'DESC') | undefined, hasException?: ('ASC' | 'DESC') | undefined, isRootSpan?: ('ASC' | 'DESC') | undefined, isEntrySpan?: ('ASC' | 'DESC') | undefined, isLlmSpan?: ('ASC' | 'DESC') | undefined, llmSystem?: ('ASC' | 'DESC') | undefined, llmOperation?: ('ASC' | 'DESC') | undefined, llmRequestModel?: ('ASC' | 'DESC') | undefined, llmResponseModel?: ('ASC' | 'DESC') | undefined, llmAgentName?: ('ASC' | 'DESC') | undefined, llmToolName?: ('ASC' | 'DESC') | undefined, llmInputTokens?: ('ASC' | 'DESC') | undefined, llmOutputTokens?: ('ASC' | 'DESC') | undefined, llmTotalTokens?: ('ASC' | 'DESC') | undefined, llmCost?: ('ASC' | 'DESC') | undefined, llmConversationId?: ('ASC' | 'DESC') | undefined, llmUserId?: ('ASC' | 'DESC') | undefined, llmUserEmail?: ('ASC' | 'DESC') | undefined, llmTeam?: ('ASC' | 'DESC') | undefined, llmCallKind?: ('ASC' | 'DESC') | undefined, llmUserMessagePreview?: ('ASC' | 'DESC') | undefined, retentionDate?: ('ASC' | 'DESC') | undefined, _id?: ('ASC' | 'DESC') | undefined, createdAt?: ('ASC' | 'DESC') | undefined}; export type SpanItemV3GroupBySchema = {projectId?: boolean | undefined, primaryEntityId?: boolean | undefined, primaryEntityType?: boolean | undefined, traceId?: boolean | undefined, spanId?: boolean | undefined, sessionId?: boolean | undefined, parentSpanId?: boolean | undefined, traceState?: boolean | undefined, serviceEntityKey?: boolean | undefined, hostEntityKey?: boolean | undefined, k8sPodEntityKey?: boolean | undefined, k8sNodeEntityKey?: boolean | undefined, k8sClusterEntityKey?: boolean | undefined, containerEntityKey?: boolean | undefined, statusCode?: boolean | undefined, statusMessage?: boolean | undefined, name?: boolean | undefined, kind?: boolean | undefined, hasException?: boolean | undefined, isRootSpan?: boolean | undefined, isEntrySpan?: boolean | undefined, isLlmSpan?: boolean | undefined, llmSystem?: boolean | undefined, llmOperation?: boolean | undefined, llmRequestModel?: boolean | undefined, llmResponseModel?: boolean | undefined, llmAgentName?: boolean | undefined, llmToolName?: boolean | undefined, llmInputTokens?: boolean | undefined, llmOutputTokens?: boolean | undefined, llmTotalTokens?: boolean | undefined, llmConversationId?: boolean | undefined, llmUserId?: boolean | undefined, llmUserEmail?: boolean | undefined, llmTeam?: boolean | undefined, llmCallKind?: boolean | undefined, llmUserMessagePreview?: boolean | undefined, _id?: boolean | undefined, createdAt?: boolean | undefined}; export type CreateApiSpanGetListArgs = {body: {query?: SpanItemV3QuerySchema | undefined, select?: SpanItemV3SelectSchema | undefined, sort?: SpanItemV3SortSchema | undefined, groupBy?: SpanItemV3GroupBySchema | undefined, limit?: number | undefined, skip?: number | undefined}}; export type CreateApiSpanGetListOptions = {baseUrl?: string | undefined, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const spanItemV3 = z.object({projectId: z.string(), primaryEntityId: z.string(), primaryEntityType: z.string().optional(), startTime: z.string().optional(), endTime: z.string().optional(), startTimeUnixNano: z.string().optional(), durationUnixNano: z.number(), endTimeUnixNano: z.string().optional(), traceId: z.string(), spanId: z.string(), sessionId: z.string().optional(), parentSpanId: z.string().optional(), traceState: z.string().optional(), attributes: z.string().optional(), attributeKeys: z.array(z.string()).optional(), entityKeys: z.array(z.string()).optional(), serviceEntityKey: z.string().optional(), hostEntityKey: z.string().optional(), k8sPodEntityKey: z.string().optional(), k8sNodeEntityKey: z.string().optional(), k8sClusterEntityKey: z.string().optional(), containerEntityKey: z.string().optional(), events: z.array(z.object({})).optional(), links: z.object({}).optional(), statusCode: z.number().optional(), statusMessage: z.string().optional(), name: z.string().optional(), kind: z.string().optional(), hasException: z.boolean().optional(), isRootSpan: z.boolean().optional(), isEntrySpan: z.boolean().optional(), isLlmSpan: z.boolean().optional(), llmSystem: z.string().optional(), llmOperation: z.string().optional(), llmRequestModel: z.string().optional(), llmResponseModel: z.string().optional(), llmAgentName: z.string().optional(), llmToolName: z.string().optional(), llmInputTokens: z.number().optional(), llmOutputTokens: z.number().optional(), llmTotalTokens: z.number().optional(), llmCost: z.number().optional(), llmConversationId: z.string().optional(), llmUserId: z.string().optional(), llmUserEmail: z.string().optional(), llmTeam: z.string().optional(), llmCallKind: z.string().optional(), llmIssues: z.array(z.string()).optional(), llmUserMessagePreview: z.string().optional()}); export const createApiSpanGetListResponse = z.object({data: z.array(spanItemV3).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 Span * * POST /span/get-list */ export const createApiSpanGetList = async (args: CreateApiSpanGetListArgs, options?: CreateApiSpanGetListOptions) => { 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(/\/+$/, '')}/span/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(createApiSpanGetListResponse, await res.json()) };