Files
xingrin/frontend/types/endpoint.types.ts
yyhuni 9eda2caceb feat(asset): add response headers and body tracking with pg_trgm indexing
- Rename body_preview to response_body across endpoint and website models for consistency
- Change response_headers from Dict to string type for efficient text indexing
- Add pg_trgm PostgreSQL extension initialization in AssetConfig for GIN index support
- Update all DTOs to reflect response_body and response_headers field changes
- Modify repositories to handle new response_body and response_headers formats
- Update serializers and views to work with string-based response headers
- Add response_headers and response_body columns to frontend endpoint and website tables
- Update command templates and scan tasks to populate response_body and response_headers
- Add database initialization script for pg_trgm extension in PostgreSQL setup
- Update frontend types and translations for new field names
- Enable efficient full-text search on response headers and body content through GIN indexes
2026-01-01 19:34:11 +08:00

102 lines
3.2 KiB
TypeScript

// Endpoint specific data type definitions
// Note: Backend returns snake_case, but api-client.ts automatically converts to camelCase
import type { BatchCreateResponse } from './api-response.types'
export interface Endpoint {
id: number
url: string
// HTTP metadata (may be null in some scenarios)
method?: string
statusCode: number | null // Backend: status_code (pointer type, may be null)
title: string
contentLength: number | null // Backend: content_length (pointer type, may be null)
contentType?: string | null // Backend: content_type (optional)
responseTime?: number | null // Backend: response_time (in seconds, optional)
gfPatterns?: string[] | null // Backend: matched_gf_patterns, GF pattern matching results
// Site/endpoint dimension additional info (used by both asset table and snapshot table)
host?: string
location?: string
webserver?: string
responseBody?: string
tech?: string[]
vhost?: boolean | null
responseHeaders?: string
createdAt?: string
// Legacy domain association fields (may not exist in some APIs)
domainId?: number // Backend: domain_id
subdomainId?: number // Backend: subdomain_id
domain?: string
subdomain?: string
updatedAt?: string // Backend: updated_at
}
// Endpoint list request parameters
// Backend sorts by update time descending
export interface GetEndpointsRequest {
page?: number
pageSize?: number
search?: string
}
// Endpoint list response data
// Note: Backend returns snake_case, but api-client.ts automatically converts to camelCase
export interface GetEndpointsResponse {
endpoints: Endpoint[]
total: number
page: number
pageSize: number // Backend returns camelCase format
totalPages: number // Backend returns camelCase format
// Compatibility fields (backward compatible)
page_size?: number
total_pages?: number
}
// Create Endpoint request parameters
export interface CreateEndpointRequest {
url: string // Required
method?: string // Optional
statusCode?: number | null // Optional
title?: string // Optional
contentLength?: number | null // Optional
contentType?: string | null // Optional
responseTime?: number | null // Optional
gfPatterns?: string[] | null // Optional, GF pattern matching results
domain?: string // Optional
subdomain?: string // Optional
}
// Create Endpoint response (extends common batch create response)
export interface CreateEndpointsResponse extends BatchCreateResponse {
// Inherited fields: message, requestedCount, createdCount, existedCount
}
// Update Endpoint request parameters
export interface UpdateEndpointRequest {
id: number
url?: string
method?: string
statusCode?: number
title?: string
contentLength?: number
contentType?: string | null
responseTime?: number | null
gfPatterns?: string[] | null
domain?: string
subdomain?: string
}
// Batch delete Endpoint request parameters
export interface BatchDeleteEndpointsRequest {
endpointIds: number[]
}
// Batch delete Endpoint response data
export interface BatchDeleteEndpointsResponse {
message: string
deletedCount: number
}