feat(health-checks): enhance health check functionality and add new routes
quality / commitlint (push) Skipped
CD / update-wiki (push) Failing after 8s
quality / changes (push) Successful in 5s
quality / docker-check (push) Skipped
quality / web (push) Successful in 50s
quality / api (push) Successful in 41s
CD / quality (push) Successful in 1m40s
CD / publish (push) Successful in 1m33s
quality / commitlint (push) Skipped
CD / update-wiki (push) Failing after 8s
quality / changes (push) Successful in 5s
quality / docker-check (push) Skipped
quality / web (push) Successful in 50s
quality / api (push) Successful in 41s
CD / quality (push) Successful in 1m40s
CD / publish (push) Successful in 1m33s
- Introduced origin health check routes and integrated them into the application. - Updated health check configuration to include success recovery thresholds. - Expanded error handling with new error codes for health check failures. - Added new service routes for managing health checks, including creation and listing. - Improved health check service logic to track consecutive successes and failures. This commit enhances the health check capabilities, providing better monitoring and management of service health.
This commit is contained in:
Vendored
+219
-1
@@ -60,6 +60,8 @@ interface ServiceBinding {
|
||||
health_check_interval_sec: number;
|
||||
health_check_timeout_ms: number;
|
||||
health_check_verify_tls: boolean;
|
||||
routing_strategy: LbMode;
|
||||
operation_version: number;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
@@ -114,6 +116,23 @@ interface ServiceDomainBindingView {
|
||||
health_check_verify_tls: boolean;
|
||||
sync_status: string | null;
|
||||
}
|
||||
interface ServiceView$1 {
|
||||
id: number;
|
||||
name: string;
|
||||
slug: string;
|
||||
service_group_id: number | null;
|
||||
subdomain: string;
|
||||
enabled: boolean;
|
||||
computed_fqdn: string | null;
|
||||
lb_weight: number;
|
||||
lb_priority: number;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
ips: string[];
|
||||
domains: ServiceDomainBindingView[];
|
||||
health_status: IpHealthState;
|
||||
health_latency_ms: number | null;
|
||||
}
|
||||
interface SyncJob {
|
||||
id: string;
|
||||
status: string;
|
||||
@@ -159,6 +178,8 @@ interface JwtClaims {
|
||||
type LbMode = "round_robin" | "failover" | "weighted";
|
||||
type HealthCheckType = "tcp" | "http" | "ping" | "dns";
|
||||
type IpHealthState = "up" | "down" | "degraded" | "unknown";
|
||||
type NodeHealthState = "unknown" | "checking" | "healthy" | "degraded" | "unhealthy" | "disabled";
|
||||
type HealthCheckProvider = "local" | "cloudflare";
|
||||
type HealthCheckScope = "binding" | "group";
|
||||
interface IpHealthStatus {
|
||||
scope: HealthCheckScope;
|
||||
@@ -167,9 +188,75 @@ interface IpHealthStatus {
|
||||
status: IpHealthState;
|
||||
latency_ms: number | null;
|
||||
consecutive_failures: number;
|
||||
consecutive_successes?: number;
|
||||
last_checked_at: string | null;
|
||||
last_error: string | null;
|
||||
}
|
||||
interface ServiceNode {
|
||||
id: number;
|
||||
service_id: number;
|
||||
address: string;
|
||||
protocol: string;
|
||||
port: number | null;
|
||||
enabled: boolean;
|
||||
priority: number;
|
||||
weight: number;
|
||||
health_status: NodeHealthState;
|
||||
health_check_id: number | null;
|
||||
consecutive_failures: number;
|
||||
consecutive_successes: number;
|
||||
last_check_at: string | null;
|
||||
last_failure_reason: string | null;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
interface OriginHealthCheck {
|
||||
id: number;
|
||||
provider: HealthCheckProvider;
|
||||
cf_healthcheck_id: string | null;
|
||||
cf_zone_id: string | null;
|
||||
name: string;
|
||||
protocol: string;
|
||||
path: string | null;
|
||||
method: string | null;
|
||||
timeout: number;
|
||||
interval_sec: number;
|
||||
retries: number;
|
||||
expected_status: number | null;
|
||||
consecutive_fails: number;
|
||||
consecutive_successes: number;
|
||||
suspended: boolean;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
interface ServiceOverview {
|
||||
service: ServiceView$1;
|
||||
nodes: ServiceNode[];
|
||||
health_check: OriginHealthCheck | null;
|
||||
routing_strategy: LbMode;
|
||||
active_addresses: string[];
|
||||
}
|
||||
interface PatchDnsRecordPayload {
|
||||
type?: string;
|
||||
name?: string;
|
||||
content?: string;
|
||||
ttl?: number;
|
||||
proxied?: boolean;
|
||||
priority?: number;
|
||||
}
|
||||
interface CfHealthCheck {
|
||||
id: string;
|
||||
address: string;
|
||||
name: string;
|
||||
status?: string;
|
||||
type?: string;
|
||||
interval?: number;
|
||||
timeout?: number;
|
||||
retries?: number;
|
||||
consecutive_fails?: number;
|
||||
consecutive_successes?: number;
|
||||
suspended?: boolean;
|
||||
}
|
||||
interface HealthCheckTarget {
|
||||
scope: HealthCheckScope;
|
||||
ref_id: number;
|
||||
@@ -250,6 +337,18 @@ declare const ipHealthStateSchema: z.ZodEnum<{
|
||||
down: "down";
|
||||
degraded: "degraded";
|
||||
}>;
|
||||
declare const nodeHealthStateSchema: z.ZodEnum<{
|
||||
unknown: "unknown";
|
||||
degraded: "degraded";
|
||||
checking: "checking";
|
||||
healthy: "healthy";
|
||||
unhealthy: "unhealthy";
|
||||
disabled: "disabled";
|
||||
}>;
|
||||
declare const healthCheckProviderSchema: z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
}>;
|
||||
declare const healthCheckScopeSchema: z.ZodEnum<{
|
||||
binding: "binding";
|
||||
group: "group";
|
||||
@@ -269,6 +368,7 @@ declare const ipHealthStatusSchema: z.ZodObject<{
|
||||
}>;
|
||||
latency_ms: z.ZodNullable<z.ZodNumber>;
|
||||
consecutive_failures: z.ZodNumber;
|
||||
consecutive_successes: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
||||
last_checked_at: z.ZodNullable<z.ZodString>;
|
||||
last_error: z.ZodNullable<z.ZodString>;
|
||||
}, z.core.$strip>;
|
||||
@@ -1414,6 +1514,124 @@ type CreateServiceBindingInput = z.infer<typeof createServiceBindingSchema>;
|
||||
type CreateDomainInput = z.infer<typeof createDomainSchema>;
|
||||
type LoginInput = z.infer<typeof loginSchema>;
|
||||
type CreateDnsRecordInput = z.infer<typeof createDnsRecordSchema>;
|
||||
declare const serviceNodeSchema: z.ZodObject<{
|
||||
id: z.ZodNumber;
|
||||
service_id: z.ZodNumber;
|
||||
address: z.ZodString;
|
||||
protocol: z.ZodString;
|
||||
port: z.ZodNullable<z.ZodNumber>;
|
||||
enabled: z.ZodCoercedBoolean<unknown>;
|
||||
priority: z.ZodNumber;
|
||||
weight: z.ZodNumber;
|
||||
health_status: z.ZodEnum<{
|
||||
unknown: "unknown";
|
||||
degraded: "degraded";
|
||||
checking: "checking";
|
||||
healthy: "healthy";
|
||||
unhealthy: "unhealthy";
|
||||
disabled: "disabled";
|
||||
}>;
|
||||
health_check_id: z.ZodNullable<z.ZodNumber>;
|
||||
consecutive_failures: z.ZodNumber;
|
||||
consecutive_successes: z.ZodNumber;
|
||||
last_check_at: z.ZodNullable<z.ZodString>;
|
||||
last_failure_reason: z.ZodNullable<z.ZodString>;
|
||||
created_at: z.ZodString;
|
||||
updated_at: z.ZodString;
|
||||
}, z.core.$strip>;
|
||||
declare const createServiceNodeSchema: z.ZodObject<{
|
||||
address: z.ZodString;
|
||||
protocol: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
||||
tcp: "tcp";
|
||||
http: "http";
|
||||
https: "https";
|
||||
}>>>;
|
||||
port: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
||||
enabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
||||
priority: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
||||
weight: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
||||
health_check_id: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
||||
}, z.core.$strip>;
|
||||
declare const updateServiceNodeSchema: z.ZodObject<{
|
||||
address: z.ZodOptional<z.ZodString>;
|
||||
protocol: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
||||
tcp: "tcp";
|
||||
http: "http";
|
||||
https: "https";
|
||||
}>>>>;
|
||||
port: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodNumber>>>;
|
||||
enabled: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
||||
priority: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodNumber>>>;
|
||||
weight: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodNumber>>>;
|
||||
health_check_id: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodNumber>>>;
|
||||
}, z.core.$strip>;
|
||||
declare const originHealthCheckSchema: z.ZodObject<{
|
||||
id: z.ZodNumber;
|
||||
provider: z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
}>;
|
||||
cf_healthcheck_id: z.ZodNullable<z.ZodString>;
|
||||
cf_zone_id: z.ZodNullable<z.ZodString>;
|
||||
name: z.ZodString;
|
||||
protocol: z.ZodString;
|
||||
path: z.ZodNullable<z.ZodString>;
|
||||
method: z.ZodNullable<z.ZodString>;
|
||||
timeout: z.ZodNumber;
|
||||
interval_sec: z.ZodNumber;
|
||||
retries: z.ZodNumber;
|
||||
expected_status: z.ZodNullable<z.ZodNumber>;
|
||||
consecutive_fails: z.ZodNumber;
|
||||
consecutive_successes: z.ZodNumber;
|
||||
suspended: z.ZodCoercedBoolean<unknown>;
|
||||
created_at: z.ZodString;
|
||||
updated_at: z.ZodString;
|
||||
}, z.core.$strip>;
|
||||
declare const createOriginHealthCheckSchema: z.ZodObject<{
|
||||
provider: z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
}>;
|
||||
name: z.ZodString;
|
||||
cf_zone_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
||||
protocol: z.ZodOptional<z.ZodEnum<{
|
||||
tcp: "tcp";
|
||||
http: "http";
|
||||
https: "https";
|
||||
HTTP: "HTTP";
|
||||
HTTPS: "HTTPS";
|
||||
TCP: "TCP";
|
||||
}>>;
|
||||
path: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
||||
method: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
||||
timeout: z.ZodOptional<z.ZodNumber>;
|
||||
interval_sec: z.ZodOptional<z.ZodNumber>;
|
||||
retries: z.ZodOptional<z.ZodNumber>;
|
||||
expected_status: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
||||
consecutive_fails: z.ZodOptional<z.ZodNumber>;
|
||||
consecutive_successes: z.ZodOptional<z.ZodNumber>;
|
||||
suspended: z.ZodOptional<z.ZodBoolean>;
|
||||
node_id: z.ZodOptional<z.ZodNumber>;
|
||||
}, z.core.$strip>;
|
||||
declare const changeIpSchema: z.ZodObject<{
|
||||
from_ip: z.ZodOptional<z.ZodString>;
|
||||
to_ip: z.ZodOptional<z.ZodString>;
|
||||
node_id: z.ZodOptional<z.ZodNumber>;
|
||||
dry_run: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
||||
}, z.core.$strip>;
|
||||
declare const changeDomainSchema: z.ZodObject<{
|
||||
from_domain_id: z.ZodNumber;
|
||||
to_domain_id: z.ZodNumber;
|
||||
hostnames: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
||||
dry_run: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
||||
}, z.core.$strip>;
|
||||
type ServiceNodeRecord = z.infer<typeof serviceNodeSchema>;
|
||||
type CreateServiceNodeInput = z.infer<typeof createServiceNodeSchema>;
|
||||
type UpdateServiceNodeInput = z.infer<typeof updateServiceNodeSchema>;
|
||||
type OriginHealthCheckRecord = z.infer<typeof originHealthCheckSchema>;
|
||||
type CreateOriginHealthCheckInput = z.infer<typeof createOriginHealthCheckSchema>;
|
||||
type ChangeIpInput = z.infer<typeof changeIpSchema>;
|
||||
type ChangeDomainInput = z.infer<typeof changeDomainSchema>;
|
||||
|
||||
declare const appSwitcherIconSchema: z.ZodEnum<{
|
||||
server: "server";
|
||||
@@ -1617,4 +1835,4 @@ declare const ingestAuditEventSchema: z.ZodObject<{
|
||||
}, z.core.$strip>;
|
||||
type IngestAuditEvent = z.infer<typeof ingestAuditEventSchema>;
|
||||
|
||||
export { AUDIT_SEVERITIES, AUDIT_SOURCE_APPS, AUDIT_TARGET_TYPES, type AppSettingsPatch, type AppSwitcherConfig, type AppSwitcherEntry, type AuditListQuery, type AuditLogEntry, type AuditSeverity, type AuditSourceApp, type AuditTargetType, type BulkUpdateDomainsInput, CERT_ERROR, CERT_EXPIRED, CERT_MONITORING_VALUES, CERT_MONITOR_AUTO, CERT_MONITOR_REQUIRED, CERT_MONITOR_SKIPPED, CERT_OK, CERT_UNKNOWN, CERT_WARNING, type CertMonitoring, type Certificate, type CfDnsRecord, type CfZone, type CfdmBindingSyncItem, type CreateDnsRecordInput, type CreateDnsRecordPayload, type CreateDomainInput, type CreateDomainMonitorInput, type CreateGroupInput, type CreateServiceBindingInput, type CreateServiceGroupInput, type CreateServiceInput, type CreateServiceWithConfigInput, type CreateSubdomainInput, type DnsRecord, type Domain, type DomainEnvironment, type DomainListItem, type DomainMonitor, type DomainMonitorResult, type DomainMonitorType, type Group, type GroupWithStats, type HealthCheckConfig, type HealthCheckScope, type HealthCheckTarget, type HealthCheckType, type HealthStatusQuery, type IngestAuditEvent, type IpHealthState, type IpHealthStatus, type JwtClaims, type LbMode, type LoginInput, type LoginRequest, type LoginResponse, type NotificationLog, type ParsedFqdn, type ReorderServicesInput, SYNC_CONFLICT, SYNC_ERROR, SYNC_PENDING_DELETE, SYNC_PENDING_PUSH, SYNC_SYNCED, type Service, type ServiceBinding, type ServiceBindingView, type ServiceDomainBinding, type ServiceDomainBindingView, type ServiceGroup, type ServiceGroupView, type ServiceGroupsResponse, type ServiceView, type Subdomain, type SubdomainRecord, type SyncJob, type ToggleEnabledInput, type UpdateDomainInput, type UpdateServiceConfigInput, type UpdateServiceGroupInput, type UpdateSubdomainInput, ValidationError, type VpsTrackerEvent, appSettingsPatchSchema, appSwitcherConfigSchema, appSwitcherEntrySchema, appSwitcherIconSchema, auditListQuerySchema, auditLogEntrySchema, auditSeveritySchema, auditSourceAppSchema, auditTargetTypeSchema, bindingToFqdn, bulkUpdateDomainsSchema, certMonitoringSchema, certStatusFromExpiry, certificateSchema, cfdmBindingSyncItemSchema, cfdmSyncBindingsBodySchema, createDnsRecordSchema, createDomainMonitorSchema, createDomainSchema, createGroupSchema, createServiceBindingSchema, createServiceGroupSchema, createServiceSchema, createServiceWithConfigSchema, createSubdomainSchema, dnsNameToSubdomainLabel, dnsRecordNamesMatch, dnsRecordSchema, domainEnvironmentSchema, domainListItemSchema, domainMonitorResultSchema, domainMonitorSchema, domainMonitorTypeSchema, domainSchema, fqdnToDisplay, groupSchema, groupWithStatsSchema, healthCheckConfigSchema, healthCheckScopeSchema, healthCheckTypeSchema, healthStatusQuerySchema, ingestAuditEventSchema, ipHealthStateSchema, ipHealthStatusSchema, isIpLiteral, isValidIpv4, lbModeSchema, loginSchema, normalizeDnsRecordName, notificationLogSchema, parseFqdn, reorderServicesSchema, serviceBindingSchema, serviceDomainBindingSchema, serviceGroupSchema, serviceGroupTypeSchema, serviceGroupViewSchema, serviceGroupsResponseSchema, serviceSchema, serviceViewSchema, shouldMonitorService, subdomainLabelToFqdn, subdomainSchema, toggleEnabledSchema, updateDomainGroupSchema, updateDomainSchema, updateServiceConfigSchema, updateServiceGroupSchema, updateSubdomainSchema, validateDnsRecord, vpsTrackerEventSchema };
|
||||
export { AUDIT_SEVERITIES, AUDIT_SOURCE_APPS, AUDIT_TARGET_TYPES, type AppSettingsPatch, type AppSwitcherConfig, type AppSwitcherEntry, type AuditListQuery, type AuditLogEntry, type AuditSeverity, type AuditSourceApp, type AuditTargetType, type BulkUpdateDomainsInput, CERT_ERROR, CERT_EXPIRED, CERT_MONITORING_VALUES, CERT_MONITOR_AUTO, CERT_MONITOR_REQUIRED, CERT_MONITOR_SKIPPED, CERT_OK, CERT_UNKNOWN, CERT_WARNING, type CertMonitoring, type Certificate, type CfDnsRecord, type CfHealthCheck, type CfZone, type CfdmBindingSyncItem, type ChangeDomainInput, type ChangeIpInput, type CreateDnsRecordInput, type CreateDnsRecordPayload, type CreateDomainInput, type CreateDomainMonitorInput, type CreateGroupInput, type CreateOriginHealthCheckInput, type CreateServiceBindingInput, type CreateServiceGroupInput, type CreateServiceInput, type CreateServiceNodeInput, type CreateServiceWithConfigInput, type CreateSubdomainInput, type DnsRecord, type Domain, type DomainEnvironment, type DomainListItem, type DomainMonitor, type DomainMonitorResult, type DomainMonitorType, type Group, type GroupWithStats, type HealthCheckConfig, type HealthCheckProvider, type HealthCheckScope, type HealthCheckTarget, type HealthCheckType, type HealthStatusQuery, type IngestAuditEvent, type IpHealthState, type IpHealthStatus, type JwtClaims, type LbMode, type LoginInput, type LoginRequest, type LoginResponse, type NodeHealthState, type NotificationLog, type OriginHealthCheck, type OriginHealthCheckRecord, type ParsedFqdn, type PatchDnsRecordPayload, type ReorderServicesInput, SYNC_CONFLICT, SYNC_ERROR, SYNC_PENDING_DELETE, SYNC_PENDING_PUSH, SYNC_SYNCED, type Service, type ServiceBinding, type ServiceBindingView, type ServiceDomainBinding, type ServiceDomainBindingView, type ServiceGroup, type ServiceGroupView, type ServiceGroupsResponse, type ServiceNode, type ServiceNodeRecord, type ServiceOverview, type ServiceView, type Subdomain, type SubdomainRecord, type SyncJob, type ToggleEnabledInput, type UpdateDomainInput, type UpdateServiceConfigInput, type UpdateServiceGroupInput, type UpdateServiceNodeInput, type UpdateSubdomainInput, ValidationError, type VpsTrackerEvent, appSettingsPatchSchema, appSwitcherConfigSchema, appSwitcherEntrySchema, appSwitcherIconSchema, auditListQuerySchema, auditLogEntrySchema, auditSeveritySchema, auditSourceAppSchema, auditTargetTypeSchema, bindingToFqdn, bulkUpdateDomainsSchema, certMonitoringSchema, certStatusFromExpiry, certificateSchema, cfdmBindingSyncItemSchema, cfdmSyncBindingsBodySchema, changeDomainSchema, changeIpSchema, createDnsRecordSchema, createDomainMonitorSchema, createDomainSchema, createGroupSchema, createOriginHealthCheckSchema, createServiceBindingSchema, createServiceGroupSchema, createServiceNodeSchema, createServiceSchema, createServiceWithConfigSchema, createSubdomainSchema, dnsNameToSubdomainLabel, dnsRecordNamesMatch, dnsRecordSchema, domainEnvironmentSchema, domainListItemSchema, domainMonitorResultSchema, domainMonitorSchema, domainMonitorTypeSchema, domainSchema, fqdnToDisplay, groupSchema, groupWithStatsSchema, healthCheckConfigSchema, healthCheckProviderSchema, healthCheckScopeSchema, healthCheckTypeSchema, healthStatusQuerySchema, ingestAuditEventSchema, ipHealthStateSchema, ipHealthStatusSchema, isIpLiteral, isValidIpv4, lbModeSchema, loginSchema, nodeHealthStateSchema, normalizeDnsRecordName, notificationLogSchema, originHealthCheckSchema, parseFqdn, reorderServicesSchema, serviceBindingSchema, serviceDomainBindingSchema, serviceGroupSchema, serviceGroupTypeSchema, serviceGroupViewSchema, serviceGroupsResponseSchema, serviceNodeSchema, serviceSchema, serviceViewSchema, shouldMonitorService, subdomainLabelToFqdn, subdomainSchema, toggleEnabledSchema, updateDomainGroupSchema, updateDomainSchema, updateServiceConfigSchema, updateServiceGroupSchema, updateServiceNodeSchema, updateSubdomainSchema, validateDnsRecord, vpsTrackerEventSchema };
|
||||
|
||||
Vendored
+95
@@ -171,6 +171,15 @@ var healthCheckTypeSchema = z.enum(["tcp", "http", "ping", "dns"]);
|
||||
var domainEnvironmentSchema = z.enum(["prod", "staging", "dev"]);
|
||||
var domainMonitorTypeSchema = z.enum(["http", "ping", "dns"]);
|
||||
var ipHealthStateSchema = z.enum(["up", "down", "degraded", "unknown"]);
|
||||
var nodeHealthStateSchema = z.enum([
|
||||
"unknown",
|
||||
"checking",
|
||||
"healthy",
|
||||
"degraded",
|
||||
"unhealthy",
|
||||
"disabled"
|
||||
]);
|
||||
var healthCheckProviderSchema = z.enum(["local", "cloudflare"]);
|
||||
var healthCheckScopeSchema = z.enum(["binding", "group"]);
|
||||
var ipHealthStatusSchema = z.object({
|
||||
scope: healthCheckScopeSchema,
|
||||
@@ -179,6 +188,7 @@ var ipHealthStatusSchema = z.object({
|
||||
status: ipHealthStateSchema,
|
||||
latency_ms: z.number().nullable(),
|
||||
consecutive_failures: z.number(),
|
||||
consecutive_successes: z.number().optional().default(0),
|
||||
last_checked_at: z.string().nullable(),
|
||||
last_error: z.string().nullable()
|
||||
});
|
||||
@@ -366,6 +376,7 @@ var ipv4Schema = z.string().regex(
|
||||
/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
|
||||
"\u041D\u0435\u043A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u044B\u0439 IPv4"
|
||||
);
|
||||
var nodeAddressSchema = z.string().min(1, "\u0423\u043A\u0430\u0436\u0438\u0442\u0435 IP \u0438\u043B\u0438 hostname").max(255);
|
||||
var healthCheckConfigFields = {
|
||||
health_check_enabled: z.boolean().optional(),
|
||||
health_check_type: healthCheckTypeSchema.optional(),
|
||||
@@ -549,6 +560,81 @@ var healthStatusQuerySchema = z.object({
|
||||
scope: healthCheckScopeSchema,
|
||||
ref_id: z.coerce.number().int().positive()
|
||||
});
|
||||
var serviceNodeSchema = z.object({
|
||||
id: z.number(),
|
||||
service_id: z.number(),
|
||||
address: z.string(),
|
||||
protocol: z.string(),
|
||||
port: z.number().nullable(),
|
||||
enabled: z.coerce.boolean(),
|
||||
priority: z.number(),
|
||||
weight: z.number(),
|
||||
health_status: nodeHealthStateSchema,
|
||||
health_check_id: z.number().nullable(),
|
||||
consecutive_failures: z.number(),
|
||||
consecutive_successes: z.number(),
|
||||
last_check_at: z.string().nullable(),
|
||||
last_failure_reason: z.string().nullable(),
|
||||
created_at: z.string(),
|
||||
updated_at: z.string()
|
||||
});
|
||||
var createServiceNodeSchema = z.object({
|
||||
address: nodeAddressSchema,
|
||||
protocol: z.enum(["tcp", "http", "https"]).optional().default("tcp"),
|
||||
port: z.number().int().min(1).max(65535).nullable().optional(),
|
||||
enabled: z.boolean().optional().default(true),
|
||||
priority: z.number().int().min(1).max(100).optional().default(1),
|
||||
weight: z.number().int().min(1).max(100).optional().default(1),
|
||||
health_check_id: z.number().int().positive().nullable().optional()
|
||||
});
|
||||
var updateServiceNodeSchema = createServiceNodeSchema.partial();
|
||||
var originHealthCheckSchema = z.object({
|
||||
id: z.number(),
|
||||
provider: healthCheckProviderSchema,
|
||||
cf_healthcheck_id: z.string().nullable(),
|
||||
cf_zone_id: z.string().nullable(),
|
||||
name: z.string(),
|
||||
protocol: z.string(),
|
||||
path: z.string().nullable(),
|
||||
method: z.string().nullable(),
|
||||
timeout: z.number(),
|
||||
interval_sec: z.number(),
|
||||
retries: z.number(),
|
||||
expected_status: z.number().nullable(),
|
||||
consecutive_fails: z.number(),
|
||||
consecutive_successes: z.number(),
|
||||
suspended: z.coerce.boolean(),
|
||||
created_at: z.string(),
|
||||
updated_at: z.string()
|
||||
});
|
||||
var createOriginHealthCheckSchema = z.object({
|
||||
provider: healthCheckProviderSchema,
|
||||
name: z.string().min(1).max(64),
|
||||
cf_zone_id: z.string().nullable().optional(),
|
||||
protocol: z.enum(["HTTP", "HTTPS", "TCP", "tcp", "http", "https"]).optional(),
|
||||
path: z.string().nullable().optional(),
|
||||
method: z.string().nullable().optional(),
|
||||
timeout: z.number().int().min(1).max(60).optional(),
|
||||
interval_sec: z.number().int().min(5).max(3600).optional(),
|
||||
retries: z.number().int().min(0).max(10).optional(),
|
||||
expected_status: z.number().int().min(100).max(599).nullable().optional(),
|
||||
consecutive_fails: z.number().int().min(1).max(20).optional(),
|
||||
consecutive_successes: z.number().int().min(1).max(20).optional(),
|
||||
suspended: z.boolean().optional(),
|
||||
node_id: z.number().int().positive().optional()
|
||||
});
|
||||
var changeIpSchema = z.object({
|
||||
from_ip: z.string().optional(),
|
||||
to_ip: z.string().min(1).optional(),
|
||||
node_id: z.number().int().positive().optional(),
|
||||
dry_run: z.boolean().optional().default(false)
|
||||
});
|
||||
var changeDomainSchema = z.object({
|
||||
from_domain_id: z.number().int().positive(),
|
||||
to_domain_id: z.number().int().positive(),
|
||||
hostnames: z.array(z.string().min(1)).optional(),
|
||||
dry_run: z.boolean().optional().default(false)
|
||||
});
|
||||
|
||||
// src/app-switcher.ts
|
||||
import { z as z2 } from "zod";
|
||||
@@ -708,12 +794,16 @@ export {
|
||||
certificateSchema,
|
||||
cfdmBindingSyncItemSchema,
|
||||
cfdmSyncBindingsBodySchema,
|
||||
changeDomainSchema,
|
||||
changeIpSchema,
|
||||
createDnsRecordSchema,
|
||||
createDomainMonitorSchema,
|
||||
createDomainSchema,
|
||||
createGroupSchema,
|
||||
createOriginHealthCheckSchema,
|
||||
createServiceBindingSchema,
|
||||
createServiceGroupSchema,
|
||||
createServiceNodeSchema,
|
||||
createServiceSchema,
|
||||
createServiceWithConfigSchema,
|
||||
createSubdomainSchema,
|
||||
@@ -730,6 +820,7 @@ export {
|
||||
groupSchema,
|
||||
groupWithStatsSchema,
|
||||
healthCheckConfigSchema,
|
||||
healthCheckProviderSchema,
|
||||
healthCheckScopeSchema,
|
||||
healthCheckTypeSchema,
|
||||
healthStatusQuerySchema,
|
||||
@@ -740,8 +831,10 @@ export {
|
||||
isValidIpv4,
|
||||
lbModeSchema,
|
||||
loginSchema,
|
||||
nodeHealthStateSchema,
|
||||
normalizeDnsRecordName,
|
||||
notificationLogSchema,
|
||||
originHealthCheckSchema,
|
||||
parseFqdn,
|
||||
reorderServicesSchema,
|
||||
serviceBindingSchema,
|
||||
@@ -750,6 +843,7 @@ export {
|
||||
serviceGroupTypeSchema,
|
||||
serviceGroupViewSchema,
|
||||
serviceGroupsResponseSchema,
|
||||
serviceNodeSchema,
|
||||
serviceSchema,
|
||||
serviceViewSchema,
|
||||
shouldMonitorService,
|
||||
@@ -760,6 +854,7 @@ export {
|
||||
updateDomainSchema,
|
||||
updateServiceConfigSchema,
|
||||
updateServiceGroupSchema,
|
||||
updateServiceNodeSchema,
|
||||
updateSubdomainSchema,
|
||||
validateDnsRecord,
|
||||
vpsTrackerEventSchema
|
||||
|
||||
@@ -21,7 +21,14 @@ export type {
|
||||
LbMode,
|
||||
HealthCheckType,
|
||||
IpHealthState,
|
||||
NodeHealthState,
|
||||
HealthCheckProvider,
|
||||
HealthCheckScope,
|
||||
IpHealthStatus,
|
||||
HealthCheckTarget,
|
||||
ServiceNode,
|
||||
OriginHealthCheck,
|
||||
ServiceOverview,
|
||||
PatchDnsRecordPayload,
|
||||
CfHealthCheck,
|
||||
} from "./types.js";
|
||||
|
||||
@@ -19,6 +19,19 @@ export type DomainMonitorType = z.infer<typeof domainMonitorTypeSchema>
|
||||
export const ipHealthStateSchema = z.enum(['up', 'down', 'degraded', 'unknown'])
|
||||
export type IpHealthState = z.infer<typeof ipHealthStateSchema>
|
||||
|
||||
export const nodeHealthStateSchema = z.enum([
|
||||
'unknown',
|
||||
'checking',
|
||||
'healthy',
|
||||
'degraded',
|
||||
'unhealthy',
|
||||
'disabled',
|
||||
])
|
||||
export type NodeHealthState = z.infer<typeof nodeHealthStateSchema>
|
||||
|
||||
export const healthCheckProviderSchema = z.enum(['local', 'cloudflare'])
|
||||
export type HealthCheckProvider = z.infer<typeof healthCheckProviderSchema>
|
||||
|
||||
export const healthCheckScopeSchema = z.enum(['binding', 'group'])
|
||||
export type HealthCheckScope = z.infer<typeof healthCheckScopeSchema>
|
||||
|
||||
@@ -29,6 +42,7 @@ export const ipHealthStatusSchema = z.object({
|
||||
status: ipHealthStateSchema,
|
||||
latency_ms: z.number().nullable(),
|
||||
consecutive_failures: z.number(),
|
||||
consecutive_successes: z.number().optional().default(0),
|
||||
last_checked_at: z.string().nullable(),
|
||||
last_error: z.string().nullable(),
|
||||
})
|
||||
@@ -266,6 +280,11 @@ const ipv4Schema = z
|
||||
'Некорректный IPv4',
|
||||
)
|
||||
|
||||
const nodeAddressSchema = z
|
||||
.string()
|
||||
.min(1, 'Укажите IP или hostname')
|
||||
.max(255)
|
||||
|
||||
const healthCheckConfigFields = {
|
||||
health_check_enabled: z.boolean().optional(),
|
||||
health_check_type: healthCheckTypeSchema.optional(),
|
||||
@@ -512,3 +531,93 @@ export type CreateServiceBindingInput = z.infer<typeof createServiceBindingSchem
|
||||
export type CreateDomainInput = z.infer<typeof createDomainSchema>
|
||||
export type LoginInput = z.infer<typeof loginSchema>
|
||||
export type CreateDnsRecordInput = z.infer<typeof createDnsRecordSchema>
|
||||
|
||||
export const serviceNodeSchema = z.object({
|
||||
id: z.number(),
|
||||
service_id: z.number(),
|
||||
address: z.string(),
|
||||
protocol: z.string(),
|
||||
port: z.number().nullable(),
|
||||
enabled: z.coerce.boolean(),
|
||||
priority: z.number(),
|
||||
weight: z.number(),
|
||||
health_status: nodeHealthStateSchema,
|
||||
health_check_id: z.number().nullable(),
|
||||
consecutive_failures: z.number(),
|
||||
consecutive_successes: z.number(),
|
||||
last_check_at: z.string().nullable(),
|
||||
last_failure_reason: z.string().nullable(),
|
||||
created_at: z.string(),
|
||||
updated_at: z.string(),
|
||||
})
|
||||
|
||||
export const createServiceNodeSchema = z.object({
|
||||
address: nodeAddressSchema,
|
||||
protocol: z.enum(['tcp', 'http', 'https']).optional().default('tcp'),
|
||||
port: z.number().int().min(1).max(65535).nullable().optional(),
|
||||
enabled: z.boolean().optional().default(true),
|
||||
priority: z.number().int().min(1).max(100).optional().default(1),
|
||||
weight: z.number().int().min(1).max(100).optional().default(1),
|
||||
health_check_id: z.number().int().positive().nullable().optional(),
|
||||
})
|
||||
|
||||
export const updateServiceNodeSchema = createServiceNodeSchema.partial()
|
||||
|
||||
export const originHealthCheckSchema = z.object({
|
||||
id: z.number(),
|
||||
provider: healthCheckProviderSchema,
|
||||
cf_healthcheck_id: z.string().nullable(),
|
||||
cf_zone_id: z.string().nullable(),
|
||||
name: z.string(),
|
||||
protocol: z.string(),
|
||||
path: z.string().nullable(),
|
||||
method: z.string().nullable(),
|
||||
timeout: z.number(),
|
||||
interval_sec: z.number(),
|
||||
retries: z.number(),
|
||||
expected_status: z.number().nullable(),
|
||||
consecutive_fails: z.number(),
|
||||
consecutive_successes: z.number(),
|
||||
suspended: z.coerce.boolean(),
|
||||
created_at: z.string(),
|
||||
updated_at: z.string(),
|
||||
})
|
||||
|
||||
export const createOriginHealthCheckSchema = z.object({
|
||||
provider: healthCheckProviderSchema,
|
||||
name: z.string().min(1).max(64),
|
||||
cf_zone_id: z.string().nullable().optional(),
|
||||
protocol: z.enum(['HTTP', 'HTTPS', 'TCP', 'tcp', 'http', 'https']).optional(),
|
||||
path: z.string().nullable().optional(),
|
||||
method: z.string().nullable().optional(),
|
||||
timeout: z.number().int().min(1).max(60).optional(),
|
||||
interval_sec: z.number().int().min(5).max(3600).optional(),
|
||||
retries: z.number().int().min(0).max(10).optional(),
|
||||
expected_status: z.number().int().min(100).max(599).nullable().optional(),
|
||||
consecutive_fails: z.number().int().min(1).max(20).optional(),
|
||||
consecutive_successes: z.number().int().min(1).max(20).optional(),
|
||||
suspended: z.boolean().optional(),
|
||||
node_id: z.number().int().positive().optional(),
|
||||
})
|
||||
|
||||
export const changeIpSchema = z.object({
|
||||
from_ip: z.string().optional(),
|
||||
to_ip: z.string().min(1).optional(),
|
||||
node_id: z.number().int().positive().optional(),
|
||||
dry_run: z.boolean().optional().default(false),
|
||||
})
|
||||
|
||||
export const changeDomainSchema = z.object({
|
||||
from_domain_id: z.number().int().positive(),
|
||||
to_domain_id: z.number().int().positive(),
|
||||
hostnames: z.array(z.string().min(1)).optional(),
|
||||
dry_run: z.boolean().optional().default(false),
|
||||
})
|
||||
|
||||
export type ServiceNodeRecord = z.infer<typeof serviceNodeSchema>
|
||||
export type CreateServiceNodeInput = z.infer<typeof createServiceNodeSchema>
|
||||
export type UpdateServiceNodeInput = z.infer<typeof updateServiceNodeSchema>
|
||||
export type OriginHealthCheckRecord = z.infer<typeof originHealthCheckSchema>
|
||||
export type CreateOriginHealthCheckInput = z.infer<typeof createOriginHealthCheckSchema>
|
||||
export type ChangeIpInput = z.infer<typeof changeIpSchema>
|
||||
export type ChangeDomainInput = z.infer<typeof changeDomainSchema>
|
||||
|
||||
@@ -121,6 +121,8 @@ export interface ServiceBinding {
|
||||
health_check_interval_sec: number;
|
||||
health_check_timeout_ms: number;
|
||||
health_check_verify_tls: boolean;
|
||||
routing_strategy: LbMode;
|
||||
operation_version: number;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
@@ -267,6 +269,16 @@ export type DomainMonitorType = "http" | "ping" | "dns";
|
||||
|
||||
export type IpHealthState = "up" | "down" | "degraded" | "unknown";
|
||||
|
||||
export type NodeHealthState =
|
||||
| "unknown"
|
||||
| "checking"
|
||||
| "healthy"
|
||||
| "degraded"
|
||||
| "unhealthy"
|
||||
| "disabled";
|
||||
|
||||
export type HealthCheckProvider = "local" | "cloudflare";
|
||||
|
||||
export type HealthCheckScope = "binding" | "group";
|
||||
|
||||
export interface IpHealthStatus {
|
||||
@@ -276,10 +288,81 @@ export interface IpHealthStatus {
|
||||
status: IpHealthState;
|
||||
latency_ms: number | null;
|
||||
consecutive_failures: number;
|
||||
consecutive_successes?: number;
|
||||
last_checked_at: string | null;
|
||||
last_error: string | null;
|
||||
}
|
||||
|
||||
export interface ServiceNode {
|
||||
id: number;
|
||||
service_id: number;
|
||||
address: string;
|
||||
protocol: string;
|
||||
port: number | null;
|
||||
enabled: boolean;
|
||||
priority: number;
|
||||
weight: number;
|
||||
health_status: NodeHealthState;
|
||||
health_check_id: number | null;
|
||||
consecutive_failures: number;
|
||||
consecutive_successes: number;
|
||||
last_check_at: string | null;
|
||||
last_failure_reason: string | null;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
export interface OriginHealthCheck {
|
||||
id: number;
|
||||
provider: HealthCheckProvider;
|
||||
cf_healthcheck_id: string | null;
|
||||
cf_zone_id: string | null;
|
||||
name: string;
|
||||
protocol: string;
|
||||
path: string | null;
|
||||
method: string | null;
|
||||
timeout: number;
|
||||
interval_sec: number;
|
||||
retries: number;
|
||||
expected_status: number | null;
|
||||
consecutive_fails: number;
|
||||
consecutive_successes: number;
|
||||
suspended: boolean;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
export interface ServiceOverview {
|
||||
service: ServiceView;
|
||||
nodes: ServiceNode[];
|
||||
health_check: OriginHealthCheck | null;
|
||||
routing_strategy: LbMode;
|
||||
active_addresses: string[];
|
||||
}
|
||||
|
||||
export interface PatchDnsRecordPayload {
|
||||
type?: string;
|
||||
name?: string;
|
||||
content?: string;
|
||||
ttl?: number;
|
||||
proxied?: boolean;
|
||||
priority?: number;
|
||||
}
|
||||
|
||||
export interface CfHealthCheck {
|
||||
id: string;
|
||||
address: string;
|
||||
name: string;
|
||||
status?: string;
|
||||
type?: string;
|
||||
interval?: number;
|
||||
timeout?: number;
|
||||
retries?: number;
|
||||
consecutive_fails?: number;
|
||||
consecutive_successes?: number;
|
||||
suspended?: boolean;
|
||||
}
|
||||
|
||||
export interface HealthCheckTarget {
|
||||
scope: HealthCheckScope;
|
||||
ref_id: number;
|
||||
|
||||
Reference in New Issue
Block a user