feat(health): добавить Globalping и мультивыбор источников проб
CD / update-wiki (push) Successful in 8s
quality / commitlint (push) Skipped
quality / changes (push) Successful in 5s
quality / docker-check (push) Skipped
quality / web (push) Successful in 54s
quality / api (push) Successful in 46s
CD / quality (push) Successful in 1m49s
CD / publish (push) Successful in 1m40s
CD / update-wiki (push) Successful in 8s
quality / commitlint (push) Skipped
quality / changes (push) Successful in 5s
quality / docker-check (push) Skipped
quality / web (push) Successful in 54s
quality / api (push) Successful in 46s
CD / quality (push) Successful in 1m49s
CD / publish (push) Successful in 1m40s
Несколько источников проб сразу и правило агрегации на сервисе вместо XOR Local/Cloudflare. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Vendored
+278
-3
@@ -1,7 +1,7 @@
|
||||
import * as drizzle_orm_sqlite_core from 'drizzle-orm/sqlite-core';
|
||||
import Database from 'better-sqlite3';
|
||||
import { drizzle } from 'drizzle-orm/better-sqlite3';
|
||||
import { AuditSourceApp, AuditSeverity, AuditTargetType, AuditLogEntry, HealthWorkerStatus, LbMode, HealthCheckType, HealthCheckProvider, IpHealthState, HealthCheckScope, ServiceBinding, Domain, Group, OriginHealthCheck, ServiceNode, Service, ServiceGroup, Subdomain, DnsRecord, ServiceBindingView, Certificate, GroupWithStats, IpHealthStatus, SyncJob, DomainListItem, HealthCheckTarget } from '@cfdm/shared';
|
||||
import { AuditSourceApp, AuditSeverity, AuditTargetType, AuditLogEntry, HealthWorkerStatus, LbMode, HealthCheckType, HealthCheckProvider, HealthCheckAggregate, IpHealthState, HealthStatusProvider, HealthCheckScope, ServiceBinding, Domain, Group, OriginHealthCheck, ServiceNode, Service, ServiceGroup, Subdomain, DnsRecord, ServiceBindingView, Certificate, GroupWithStats, IpHealthStatus, SyncJob, DomainListItem, HealthCheckTarget } from '@cfdm/shared';
|
||||
|
||||
declare const groups: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
||||
name: "groups";
|
||||
@@ -599,6 +599,44 @@ declare const serviceGroups: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
||||
}, {}, {
|
||||
length: number | undefined;
|
||||
}>;
|
||||
health_check_providers: drizzle_orm_sqlite_core.SQLiteColumn<{
|
||||
name: "health_check_providers";
|
||||
tableName: "service_groups";
|
||||
dataType: "string";
|
||||
columnType: "SQLiteText";
|
||||
data: string;
|
||||
driverParam: string;
|
||||
notNull: true;
|
||||
hasDefault: true;
|
||||
isPrimaryKey: false;
|
||||
isAutoincrement: false;
|
||||
hasRuntimeDefault: false;
|
||||
enumValues: [string, ...string[]];
|
||||
baseColumn: never;
|
||||
identity: undefined;
|
||||
generated: undefined;
|
||||
}, {}, {
|
||||
length: number | undefined;
|
||||
}>;
|
||||
health_check_aggregate: drizzle_orm_sqlite_core.SQLiteColumn<{
|
||||
name: "health_check_aggregate";
|
||||
tableName: "service_groups";
|
||||
dataType: "string";
|
||||
columnType: "SQLiteText";
|
||||
data: string;
|
||||
driverParam: string;
|
||||
notNull: true;
|
||||
hasDefault: true;
|
||||
isPrimaryKey: false;
|
||||
isAutoincrement: false;
|
||||
hasRuntimeDefault: false;
|
||||
enumValues: [string, ...string[]];
|
||||
baseColumn: never;
|
||||
identity: undefined;
|
||||
generated: undefined;
|
||||
}, {}, {
|
||||
length: number | undefined;
|
||||
}>;
|
||||
created_at: drizzle_orm_sqlite_core.SQLiteColumn<{
|
||||
name: "created_at";
|
||||
tableName: "service_groups";
|
||||
@@ -1537,6 +1575,44 @@ declare const serviceBindings: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
||||
}, {}, {
|
||||
length: number | undefined;
|
||||
}>;
|
||||
health_check_providers: drizzle_orm_sqlite_core.SQLiteColumn<{
|
||||
name: "health_check_providers";
|
||||
tableName: "service_bindings";
|
||||
dataType: "string";
|
||||
columnType: "SQLiteText";
|
||||
data: string;
|
||||
driverParam: string;
|
||||
notNull: true;
|
||||
hasDefault: true;
|
||||
isPrimaryKey: false;
|
||||
isAutoincrement: false;
|
||||
hasRuntimeDefault: false;
|
||||
enumValues: [string, ...string[]];
|
||||
baseColumn: never;
|
||||
identity: undefined;
|
||||
generated: undefined;
|
||||
}, {}, {
|
||||
length: number | undefined;
|
||||
}>;
|
||||
health_check_aggregate: drizzle_orm_sqlite_core.SQLiteColumn<{
|
||||
name: "health_check_aggregate";
|
||||
tableName: "service_bindings";
|
||||
dataType: "string";
|
||||
columnType: "SQLiteText";
|
||||
data: string;
|
||||
driverParam: string;
|
||||
notNull: true;
|
||||
hasDefault: true;
|
||||
isPrimaryKey: false;
|
||||
isAutoincrement: false;
|
||||
hasRuntimeDefault: false;
|
||||
enumValues: [string, ...string[]];
|
||||
baseColumn: never;
|
||||
identity: undefined;
|
||||
generated: undefined;
|
||||
}, {}, {
|
||||
length: number | undefined;
|
||||
}>;
|
||||
routing_strategy: drizzle_orm_sqlite_core.SQLiteColumn<{
|
||||
name: "routing_strategy";
|
||||
tableName: "service_bindings";
|
||||
@@ -3460,6 +3536,61 @@ declare const appSettings: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
||||
}, {}, {
|
||||
length: number | undefined;
|
||||
}>;
|
||||
globalping_token: drizzle_orm_sqlite_core.SQLiteColumn<{
|
||||
name: "globalping_token";
|
||||
tableName: "app_settings";
|
||||
dataType: "string";
|
||||
columnType: "SQLiteText";
|
||||
data: string;
|
||||
driverParam: string;
|
||||
notNull: false;
|
||||
hasDefault: false;
|
||||
isPrimaryKey: false;
|
||||
isAutoincrement: false;
|
||||
hasRuntimeDefault: false;
|
||||
enumValues: [string, ...string[]];
|
||||
baseColumn: never;
|
||||
identity: undefined;
|
||||
generated: undefined;
|
||||
}, {}, {
|
||||
length: number | undefined;
|
||||
}>;
|
||||
globalping_locations: drizzle_orm_sqlite_core.SQLiteColumn<{
|
||||
name: "globalping_locations";
|
||||
tableName: "app_settings";
|
||||
dataType: "string";
|
||||
columnType: "SQLiteText";
|
||||
data: string;
|
||||
driverParam: string;
|
||||
notNull: false;
|
||||
hasDefault: false;
|
||||
isPrimaryKey: false;
|
||||
isAutoincrement: false;
|
||||
hasRuntimeDefault: false;
|
||||
enumValues: [string, ...string[]];
|
||||
baseColumn: never;
|
||||
identity: undefined;
|
||||
generated: undefined;
|
||||
}, {}, {
|
||||
length: number | undefined;
|
||||
}>;
|
||||
globalping_limit: drizzle_orm_sqlite_core.SQLiteColumn<{
|
||||
name: "globalping_limit";
|
||||
tableName: "app_settings";
|
||||
dataType: "number";
|
||||
columnType: "SQLiteInteger";
|
||||
data: number;
|
||||
driverParam: number;
|
||||
notNull: false;
|
||||
hasDefault: false;
|
||||
isPrimaryKey: false;
|
||||
isAutoincrement: false;
|
||||
hasRuntimeDefault: false;
|
||||
enumValues: undefined;
|
||||
baseColumn: never;
|
||||
identity: undefined;
|
||||
generated: undefined;
|
||||
}, {}, {}>;
|
||||
created_at: drizzle_orm_sqlite_core.SQLiteColumn<{
|
||||
name: "created_at";
|
||||
tableName: "app_settings";
|
||||
@@ -5151,6 +5282,44 @@ declare const schema: {
|
||||
}, {}, {
|
||||
length: number | undefined;
|
||||
}>;
|
||||
health_check_providers: drizzle_orm_sqlite_core.SQLiteColumn<{
|
||||
name: "health_check_providers";
|
||||
tableName: "service_groups";
|
||||
dataType: "string";
|
||||
columnType: "SQLiteText";
|
||||
data: string;
|
||||
driverParam: string;
|
||||
notNull: true;
|
||||
hasDefault: true;
|
||||
isPrimaryKey: false;
|
||||
isAutoincrement: false;
|
||||
hasRuntimeDefault: false;
|
||||
enumValues: [string, ...string[]];
|
||||
baseColumn: never;
|
||||
identity: undefined;
|
||||
generated: undefined;
|
||||
}, {}, {
|
||||
length: number | undefined;
|
||||
}>;
|
||||
health_check_aggregate: drizzle_orm_sqlite_core.SQLiteColumn<{
|
||||
name: "health_check_aggregate";
|
||||
tableName: "service_groups";
|
||||
dataType: "string";
|
||||
columnType: "SQLiteText";
|
||||
data: string;
|
||||
driverParam: string;
|
||||
notNull: true;
|
||||
hasDefault: true;
|
||||
isPrimaryKey: false;
|
||||
isAutoincrement: false;
|
||||
hasRuntimeDefault: false;
|
||||
enumValues: [string, ...string[]];
|
||||
baseColumn: never;
|
||||
identity: undefined;
|
||||
generated: undefined;
|
||||
}, {}, {
|
||||
length: number | undefined;
|
||||
}>;
|
||||
created_at: drizzle_orm_sqlite_core.SQLiteColumn<{
|
||||
name: "created_at";
|
||||
tableName: "service_groups";
|
||||
@@ -6089,6 +6258,44 @@ declare const schema: {
|
||||
}, {}, {
|
||||
length: number | undefined;
|
||||
}>;
|
||||
health_check_providers: drizzle_orm_sqlite_core.SQLiteColumn<{
|
||||
name: "health_check_providers";
|
||||
tableName: "service_bindings";
|
||||
dataType: "string";
|
||||
columnType: "SQLiteText";
|
||||
data: string;
|
||||
driverParam: string;
|
||||
notNull: true;
|
||||
hasDefault: true;
|
||||
isPrimaryKey: false;
|
||||
isAutoincrement: false;
|
||||
hasRuntimeDefault: false;
|
||||
enumValues: [string, ...string[]];
|
||||
baseColumn: never;
|
||||
identity: undefined;
|
||||
generated: undefined;
|
||||
}, {}, {
|
||||
length: number | undefined;
|
||||
}>;
|
||||
health_check_aggregate: drizzle_orm_sqlite_core.SQLiteColumn<{
|
||||
name: "health_check_aggregate";
|
||||
tableName: "service_bindings";
|
||||
dataType: "string";
|
||||
columnType: "SQLiteText";
|
||||
data: string;
|
||||
driverParam: string;
|
||||
notNull: true;
|
||||
hasDefault: true;
|
||||
isPrimaryKey: false;
|
||||
isAutoincrement: false;
|
||||
hasRuntimeDefault: false;
|
||||
enumValues: [string, ...string[]];
|
||||
baseColumn: never;
|
||||
identity: undefined;
|
||||
generated: undefined;
|
||||
}, {}, {
|
||||
length: number | undefined;
|
||||
}>;
|
||||
routing_strategy: drizzle_orm_sqlite_core.SQLiteColumn<{
|
||||
name: "routing_strategy";
|
||||
tableName: "service_bindings";
|
||||
@@ -8012,6 +8219,61 @@ declare const schema: {
|
||||
}, {}, {
|
||||
length: number | undefined;
|
||||
}>;
|
||||
globalping_token: drizzle_orm_sqlite_core.SQLiteColumn<{
|
||||
name: "globalping_token";
|
||||
tableName: "app_settings";
|
||||
dataType: "string";
|
||||
columnType: "SQLiteText";
|
||||
data: string;
|
||||
driverParam: string;
|
||||
notNull: false;
|
||||
hasDefault: false;
|
||||
isPrimaryKey: false;
|
||||
isAutoincrement: false;
|
||||
hasRuntimeDefault: false;
|
||||
enumValues: [string, ...string[]];
|
||||
baseColumn: never;
|
||||
identity: undefined;
|
||||
generated: undefined;
|
||||
}, {}, {
|
||||
length: number | undefined;
|
||||
}>;
|
||||
globalping_locations: drizzle_orm_sqlite_core.SQLiteColumn<{
|
||||
name: "globalping_locations";
|
||||
tableName: "app_settings";
|
||||
dataType: "string";
|
||||
columnType: "SQLiteText";
|
||||
data: string;
|
||||
driverParam: string;
|
||||
notNull: false;
|
||||
hasDefault: false;
|
||||
isPrimaryKey: false;
|
||||
isAutoincrement: false;
|
||||
hasRuntimeDefault: false;
|
||||
enumValues: [string, ...string[]];
|
||||
baseColumn: never;
|
||||
identity: undefined;
|
||||
generated: undefined;
|
||||
}, {}, {
|
||||
length: number | undefined;
|
||||
}>;
|
||||
globalping_limit: drizzle_orm_sqlite_core.SQLiteColumn<{
|
||||
name: "globalping_limit";
|
||||
tableName: "app_settings";
|
||||
dataType: "number";
|
||||
columnType: "SQLiteInteger";
|
||||
data: number;
|
||||
driverParam: number;
|
||||
notNull: false;
|
||||
hasDefault: false;
|
||||
isPrimaryKey: false;
|
||||
isAutoincrement: false;
|
||||
hasRuntimeDefault: false;
|
||||
enumValues: undefined;
|
||||
baseColumn: never;
|
||||
identity: undefined;
|
||||
generated: undefined;
|
||||
}, {}, {}>;
|
||||
created_at: drizzle_orm_sqlite_core.SQLiteColumn<{
|
||||
name: "created_at";
|
||||
tableName: "app_settings";
|
||||
@@ -9176,6 +9438,9 @@ type AppSettingsDto = {
|
||||
healthWorkerError: string | null;
|
||||
healthWorkerDeployedAt: string | null;
|
||||
healthWorkerLastIngestAt: string | null;
|
||||
globalpingTokenSet: boolean;
|
||||
globalpingLocations: string;
|
||||
globalpingLimit: number;
|
||||
} & HealthEngineSettings;
|
||||
type AppSettingsPatch = {
|
||||
vpsTrackerUrl?: string;
|
||||
@@ -9194,6 +9459,9 @@ type AppSettingsPatch = {
|
||||
healthWorkerError?: string | null;
|
||||
healthWorkerDeployedAt?: string | null;
|
||||
healthWorkerLastIngestAt?: string | null;
|
||||
globalpingToken?: string;
|
||||
globalpingLocations?: string;
|
||||
globalpingLimit?: number;
|
||||
};
|
||||
type HealthEngineFallbacks = HealthEngineSettings & {
|
||||
healthWorkerUrl: string;
|
||||
@@ -9206,6 +9474,9 @@ declare function getAppSettingsSecrets(db: Db): {
|
||||
vpsTrackerSyncEnabled: boolean;
|
||||
healthWorkerUrl: string;
|
||||
healthWorkerToken: string;
|
||||
globalpingToken: string;
|
||||
globalpingLocations: string;
|
||||
globalpingLimit: number;
|
||||
};
|
||||
declare function updateAppSettings(db: Db, patch: AppSettingsPatch, fallbacks?: HealthEngineFallbacks): AppSettingsDto;
|
||||
declare function touchVpsTrackerSync(db: Db): void;
|
||||
@@ -9294,6 +9565,8 @@ interface ServiceGroupLbPatch {
|
||||
health_check_timeout_ms?: number;
|
||||
health_check_verify_tls?: boolean;
|
||||
health_check_provider?: HealthCheckProvider;
|
||||
health_check_providers?: HealthCheckProvider[];
|
||||
health_check_aggregate?: HealthCheckAggregate;
|
||||
}
|
||||
declare function createServiceGroup(db: Db, name: string, groupType: string, icon: string | null, domain: string | null, lbPatch?: ServiceGroupLbPatch): ServiceGroup;
|
||||
declare function updateServiceGroup(db: Db, id: number, name: string, groupType: string, icon: string | null, domain: string | null, lbPatch?: ServiceGroupLbPatch): ServiceGroup;
|
||||
@@ -9402,6 +9675,8 @@ interface BindingLbPatch {
|
||||
health_check_timeout_ms?: number;
|
||||
health_check_verify_tls?: boolean;
|
||||
health_check_provider?: HealthCheckProvider;
|
||||
health_check_providers?: HealthCheckProvider[];
|
||||
health_check_aggregate?: HealthCheckAggregate;
|
||||
}
|
||||
declare function updateBindingLbConfig(db: Db, bindingId: number, patch: BindingLbPatch): void;
|
||||
declare function setBindingCnameTarget(db: Db, bindingId: number, target: string | null): void;
|
||||
@@ -9453,7 +9728,7 @@ type ServiceIpHealthRow = {
|
||||
latency_ms: number | null;
|
||||
last_checked_at: string | null;
|
||||
last_error: string | null;
|
||||
provider: HealthCheckProvider;
|
||||
provider: HealthStatusProvider;
|
||||
colo: string | null;
|
||||
};
|
||||
/** Per-IP binding-scope health, worst status if the same IP is on several bindings. */
|
||||
@@ -9462,7 +9737,7 @@ declare function mergeHealthAggregates(parts: Array<HealthAggregate | undefined
|
||||
declare function getIpHealthStatusRow(db: Db, scope: HealthCheckScope, refId: number, ip: string): IpHealthStatus | null;
|
||||
declare function upsertIpHealthStatus(db: Db, scope: HealthCheckScope, refId: number, ip: string, status: string, latencyMs: number | null, consecutiveFailures: number, lastError: string | null, consecutiveSuccesses?: number, extras?: {
|
||||
colo?: string | null;
|
||||
provider?: HealthCheckProvider;
|
||||
provider?: HealthStatusProvider;
|
||||
}): void;
|
||||
declare function deleteIpHealthStatusForRef(db: Db, scope: HealthCheckScope, refId: number): void;
|
||||
declare function deleteIpHealthStatusForIp(db: Db, scope: HealthCheckScope, refId: number, ip: string): void;
|
||||
|
||||
Vendored
+126
-22
@@ -53,6 +53,8 @@ var serviceGroups = sqliteTable("service_groups", {
|
||||
health_check_timeout_ms: integer("health_check_timeout_ms").notNull().default(3e3),
|
||||
health_check_verify_tls: integer("health_check_verify_tls", { mode: "boolean" }).notNull().default(false),
|
||||
health_check_provider: text("health_check_provider").notNull().default("local"),
|
||||
health_check_providers: text("health_check_providers").notNull().default('["local"]'),
|
||||
health_check_aggregate: text("health_check_aggregate").notNull().default("majority"),
|
||||
created_at: text("created_at").notNull().default(sql`datetime('now')`),
|
||||
updated_at: text("updated_at").notNull().default(sql`datetime('now')`)
|
||||
});
|
||||
@@ -119,6 +121,8 @@ var serviceBindings = sqliteTable(
|
||||
mode: "boolean"
|
||||
}).notNull().default(false),
|
||||
health_check_provider: text("health_check_provider").notNull().default("local"),
|
||||
health_check_providers: text("health_check_providers").notNull().default('["local"]'),
|
||||
health_check_aggregate: text("health_check_aggregate").notNull().default("majority"),
|
||||
routing_strategy: text("routing_strategy").notNull().default("round_robin"),
|
||||
operation_version: integer("operation_version").notNull().default(0),
|
||||
created_at: text("created_at").notNull().default(sql`datetime('now')`),
|
||||
@@ -286,6 +290,9 @@ var appSettings = sqliteTable("app_settings", {
|
||||
health_worker_error: text("health_worker_error"),
|
||||
health_worker_deployed_at: text("health_worker_deployed_at"),
|
||||
health_worker_last_ingest_at: text("health_worker_last_ingest_at"),
|
||||
globalping_token: text("globalping_token"),
|
||||
globalping_locations: text("globalping_locations"),
|
||||
globalping_limit: integer("globalping_limit"),
|
||||
created_at: text("created_at").notNull().default(sql`datetime('now')`),
|
||||
updated_at: text("updated_at").notNull().default(sql`datetime('now')`)
|
||||
});
|
||||
@@ -577,7 +584,10 @@ function toDto(row, fallbacks) {
|
||||
healthWorkerError: row.health_worker_error?.trim() || null,
|
||||
healthWorkerDeployedAt: row.health_worker_deployed_at ?? null,
|
||||
healthWorkerLastIngestAt: row.health_worker_last_ingest_at ?? null,
|
||||
healthWorkerStatus: workerStatus(row, env.healthWorkerUrl)
|
||||
healthWorkerStatus: workerStatus(row, env.healthWorkerUrl),
|
||||
globalpingTokenSet: Boolean(row.globalping_token?.trim()),
|
||||
globalpingLocations: row.globalping_locations?.trim() || "World",
|
||||
globalpingLimit: row.globalping_limit == null || Number.isNaN(row.globalping_limit) || row.globalping_limit < 1 ? 3 : Math.min(10, row.globalping_limit)
|
||||
};
|
||||
}
|
||||
function getAppSettings(db, fallbacks) {
|
||||
@@ -593,12 +603,16 @@ function getAppSettings(db, fallbacks) {
|
||||
}
|
||||
function getAppSettingsSecrets(db) {
|
||||
const row = db.select().from(appSettings).where(eq2(appSettings.id, SETTINGS_ID)).get();
|
||||
const limit = row?.globalping_limit;
|
||||
return {
|
||||
vpsTrackerUrl: row?.vps_tracker_url?.trim() ?? "",
|
||||
vpsTrackerIntegrationToken: row?.vps_tracker_integration_token?.trim() ?? "",
|
||||
vpsTrackerSyncEnabled: Boolean(row?.vps_tracker_sync_enabled),
|
||||
healthWorkerUrl: row?.health_worker_url?.trim() ?? "",
|
||||
healthWorkerToken: row?.health_worker_token?.trim() ?? ""
|
||||
healthWorkerToken: row?.health_worker_token?.trim() ?? "",
|
||||
globalpingToken: row?.globalping_token?.trim() ?? "",
|
||||
globalpingLocations: row?.globalping_locations?.trim() || "World",
|
||||
globalpingLimit: limit == null || Number.isNaN(limit) || limit < 1 ? 3 : Math.min(10, limit)
|
||||
};
|
||||
}
|
||||
function updateAppSettings(db, patch, fallbacks) {
|
||||
@@ -624,6 +638,9 @@ function updateAppSettings(db, patch, fallbacks) {
|
||||
health_worker_error: patch.healthWorkerError !== void 0 ? patch.healthWorkerError?.trim() || null : current.health_worker_error,
|
||||
health_worker_deployed_at: patch.healthWorkerDeployedAt !== void 0 ? patch.healthWorkerDeployedAt : current.health_worker_deployed_at,
|
||||
health_worker_last_ingest_at: patch.healthWorkerLastIngestAt !== void 0 ? patch.healthWorkerLastIngestAt : current.health_worker_last_ingest_at,
|
||||
globalping_token: patch.globalpingToken !== void 0 && patch.globalpingToken.trim() !== "" ? patch.globalpingToken : current.globalping_token,
|
||||
globalping_locations: patch.globalpingLocations !== void 0 ? patch.globalpingLocations.trim() || "World" : current.globalping_locations,
|
||||
globalping_limit: patch.globalpingLimit !== void 0 ? Math.min(10, Math.max(1, patch.globalpingLimit)) : current.globalping_limit,
|
||||
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
||||
}).where(eq2(appSettings.id, SETTINGS_ID)).run();
|
||||
return getAppSettings(db, fallbacks);
|
||||
@@ -771,7 +788,15 @@ __export(repos_exports, {
|
||||
upsertIpHealthStatus: () => upsertIpHealthStatus,
|
||||
upsertSubdomain: () => upsertSubdomain
|
||||
});
|
||||
import { dnsRecordNamesMatch, isIpLiteral } from "@cfdm/shared";
|
||||
import {
|
||||
derivePrimaryProvider,
|
||||
dnsRecordNamesMatch,
|
||||
isIpLiteral,
|
||||
parseHealthAggregate,
|
||||
parseHealthProviders,
|
||||
serializeHealthProviders,
|
||||
normalizeStatusProvider
|
||||
} from "@cfdm/shared";
|
||||
import { and as and2, asc, count, eq as eq3, isNull, like, notInArray, or as or2, sql as sql2 } from "drizzle-orm";
|
||||
function listGroups(db) {
|
||||
return db.select().from(groups).orderBy(asc(groups.name)).all();
|
||||
@@ -1158,8 +1183,58 @@ function deleteService(db, id) {
|
||||
const result = db.delete(services).where(eq3(services.id, id)).run();
|
||||
if (result.changes === 0) throw new NotFoundError(`service ${id}`);
|
||||
}
|
||||
function normalizeHealthProvider(value) {
|
||||
return value === "cloudflare" ? "cloudflare" : "local";
|
||||
function healthProviderColumns(patch) {
|
||||
const out = {};
|
||||
if (patch.health_check_providers !== void 0) {
|
||||
const list = parseHealthProviders(patch.health_check_providers);
|
||||
out.health_check_providers = serializeHealthProviders(list);
|
||||
out.health_check_provider = derivePrimaryProvider(list);
|
||||
} else if (patch.health_check_provider !== void 0) {
|
||||
const list = parseHealthProviders(null, patch.health_check_provider);
|
||||
out.health_check_providers = serializeHealthProviders(list);
|
||||
out.health_check_provider = derivePrimaryProvider(list);
|
||||
}
|
||||
if (patch.health_check_aggregate !== void 0) {
|
||||
out.health_check_aggregate = parseHealthAggregate(
|
||||
patch.health_check_aggregate
|
||||
);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
function mapHealthFields(row) {
|
||||
const providers = parseHealthProviders(
|
||||
row.health_check_providers,
|
||||
row.health_check_provider
|
||||
);
|
||||
return {
|
||||
health_check_providers: providers,
|
||||
health_check_provider: derivePrimaryProvider(providers),
|
||||
health_check_aggregate: parseHealthAggregate(row.health_check_aggregate)
|
||||
};
|
||||
}
|
||||
function mapServiceBinding(row) {
|
||||
return {
|
||||
id: row.id,
|
||||
domain_id: row.domain_id,
|
||||
service_id: row.service_id,
|
||||
hostname: row.hostname,
|
||||
cname_target: row.cname_target,
|
||||
dns_record_id: row.dns_record_id,
|
||||
lb_mode: row.lb_mode,
|
||||
health_check_enabled: row.health_check_enabled,
|
||||
health_check_type: row.health_check_type,
|
||||
health_check_port: row.health_check_port,
|
||||
health_check_path: row.health_check_path,
|
||||
health_check_expected_status: row.health_check_expected_status,
|
||||
health_check_interval_sec: row.health_check_interval_sec,
|
||||
health_check_timeout_ms: row.health_check_timeout_ms,
|
||||
health_check_verify_tls: row.health_check_verify_tls,
|
||||
...mapHealthFields(row),
|
||||
routing_strategy: row.routing_strategy,
|
||||
operation_version: row.operation_version,
|
||||
created_at: row.created_at,
|
||||
updated_at: row.updated_at
|
||||
};
|
||||
}
|
||||
function mapServiceGroup(row) {
|
||||
return {
|
||||
@@ -1178,7 +1253,7 @@ function mapServiceGroup(row) {
|
||||
health_check_interval_sec: row.health_check_interval_sec,
|
||||
health_check_timeout_ms: row.health_check_timeout_ms,
|
||||
health_check_verify_tls: row.health_check_verify_tls,
|
||||
health_check_provider: normalizeHealthProvider(row.health_check_provider),
|
||||
...mapHealthFields(row),
|
||||
created_at: row.created_at,
|
||||
updated_at: row.updated_at
|
||||
};
|
||||
@@ -1206,7 +1281,11 @@ function createServiceGroup(db, name, groupType, icon, domain, lbPatch) {
|
||||
health_check_interval_sec: lbPatch?.health_check_interval_sec ?? 30,
|
||||
health_check_timeout_ms: lbPatch?.health_check_timeout_ms ?? 3e3,
|
||||
health_check_verify_tls: lbPatch?.health_check_verify_tls ?? false,
|
||||
health_check_provider: lbPatch?.health_check_provider ?? "local"
|
||||
...healthProviderColumns({
|
||||
health_check_provider: lbPatch?.health_check_provider ?? "local",
|
||||
health_check_providers: lbPatch?.health_check_providers,
|
||||
health_check_aggregate: lbPatch?.health_check_aggregate ?? "majority"
|
||||
})
|
||||
}).returning({ id: serviceGroups.id }).get().id;
|
||||
return getServiceGroup(db, id);
|
||||
}
|
||||
@@ -1236,8 +1315,7 @@ function updateServiceGroup(db, id, name, groupType, icon, domain, lbPatch) {
|
||||
update.health_check_timeout_ms = lbPatch.health_check_timeout_ms;
|
||||
if (lbPatch.health_check_verify_tls !== void 0)
|
||||
update.health_check_verify_tls = lbPatch.health_check_verify_tls;
|
||||
if (lbPatch.health_check_provider !== void 0)
|
||||
update.health_check_provider = lbPatch.health_check_provider;
|
||||
Object.assign(update, healthProviderColumns(lbPatch));
|
||||
}
|
||||
const result = db.update(serviceGroups).set(update).where(eq3(serviceGroups.id, id)).run();
|
||||
if (result.changes === 0) throw new NotFoundError(`service group ${id}`);
|
||||
@@ -1547,8 +1625,7 @@ function updateBindingLbConfig(db, bindingId, patch) {
|
||||
update.health_check_timeout_ms = patch.health_check_timeout_ms;
|
||||
if (patch.health_check_verify_tls !== void 0)
|
||||
update.health_check_verify_tls = patch.health_check_verify_tls;
|
||||
if (patch.health_check_provider !== void 0)
|
||||
update.health_check_provider = patch.health_check_provider;
|
||||
Object.assign(update, healthProviderColumns(patch));
|
||||
db.update(serviceBindings).set(update).where(eq3(serviceBindings.id, bindingId)).run();
|
||||
}
|
||||
function setBindingCnameTarget(db, bindingId, target) {
|
||||
@@ -1607,7 +1684,8 @@ function dnsRecordMatchesHostname(recordName, hostname, zoneName) {
|
||||
var SERVICE_BINDING_SELECT_COLUMNS = `sb.id, sb.domain_id, sb.service_id, sb.hostname, sb.dns_record_id,
|
||||
sb.lb_mode, sb.health_check_enabled, sb.health_check_type, sb.health_check_port,
|
||||
sb.health_check_path, sb.health_check_expected_status, sb.health_check_interval_sec,
|
||||
sb.health_check_timeout_ms, sb.health_check_verify_tls, sb.health_check_provider, sb.cname_target,
|
||||
sb.health_check_timeout_ms, sb.health_check_verify_tls, sb.health_check_provider,
|
||||
sb.health_check_providers, sb.health_check_aggregate, sb.cname_target,
|
||||
d.zone_name, d.group_id, g.name AS group_name,
|
||||
s.name AS service_name, s.slug AS service_slug,
|
||||
dr.content AS target_ip, dr.sync_status,
|
||||
@@ -1655,6 +1733,7 @@ function enrichServiceBindingView(db, row) {
|
||||
return {
|
||||
...row,
|
||||
cname_target: row.cname_target ?? null,
|
||||
...mapHealthFields(row),
|
||||
target_ips,
|
||||
target_ip: target_ips[0] ?? null,
|
||||
target_ip_weights,
|
||||
@@ -1695,7 +1774,7 @@ function listBindingsByService(db, serviceId) {
|
||||
function getBinding(db, id) {
|
||||
const row = db.select().from(serviceBindings).where(eq3(serviceBindings.id, id)).get();
|
||||
if (!row) throw new NotFoundError(`service binding ${id}`);
|
||||
return row;
|
||||
return mapServiceBinding(row);
|
||||
}
|
||||
function getBindingView(db, id) {
|
||||
const rows = db.all(sql2`
|
||||
@@ -1718,7 +1797,8 @@ function findBinding(db, serviceId, domainId, hostname) {
|
||||
eq3(serviceBindings.hostname, hostname)
|
||||
)
|
||||
).get();
|
||||
return row ?? null;
|
||||
if (!row) return null;
|
||||
return mapServiceBinding(row);
|
||||
}
|
||||
function insertBinding(db, domainId, serviceId, hostname, dnsRecordId) {
|
||||
const id = db.insert(serviceBindings).values({
|
||||
@@ -1744,7 +1824,7 @@ function setBindingDnsRecordId(db, bindingId, dnsRecordId) {
|
||||
}).where(eq3(serviceBindings.id, bindingId)).run();
|
||||
}
|
||||
function bindingsToRemove(db, serviceId, keepIds) {
|
||||
const all = db.select().from(serviceBindings).where(eq3(serviceBindings.service_id, serviceId)).all();
|
||||
const all = db.select().from(serviceBindings).where(eq3(serviceBindings.service_id, serviceId)).all().map(mapServiceBinding);
|
||||
return all.filter((b) => !keepIds.includes(b.id));
|
||||
}
|
||||
function deleteBindingsExcept(db, serviceId, keepIds) {
|
||||
@@ -1975,7 +2055,7 @@ function listIpHealthByServiceIds(db, serviceIds) {
|
||||
latency_ms: parsed.health_latency_ms,
|
||||
last_checked_at: row.last_checked_at,
|
||||
last_error: row.last_error,
|
||||
provider: normalizeHealthProvider(row.provider),
|
||||
provider: normalizeStatusProvider(row.provider),
|
||||
colo: row.colo
|
||||
});
|
||||
result.set(row.service_id, list);
|
||||
@@ -2101,6 +2181,8 @@ function listHealthCheckTargets(db) {
|
||||
sb.health_check_expected_status AS expected_status,
|
||||
sb.health_check_timeout_ms AS timeout_ms,
|
||||
sb.health_check_verify_tls AS verify_tls,
|
||||
sb.health_check_providers AS providers_json,
|
||||
COALESCE(sb.health_check_aggregate, 'majority') AS aggregate,
|
||||
COALESCE(sb.health_check_provider, 'local') AS provider
|
||||
FROM service_binding_ips sbi
|
||||
JOIN service_bindings sb ON sb.id = sbi.binding_id
|
||||
@@ -2116,6 +2198,8 @@ function listHealthCheckTargets(db) {
|
||||
sg.health_check_expected_status AS expected_status,
|
||||
sg.health_check_timeout_ms AS timeout_ms,
|
||||
sg.health_check_verify_tls AS verify_tls,
|
||||
sg.health_check_providers AS providers_json,
|
||||
COALESCE(sg.health_check_aggregate, 'majority') AS aggregate,
|
||||
COALESCE(sg.health_check_provider, 'local') AS provider
|
||||
FROM service_binding_ips sbi
|
||||
JOIN service_bindings sb ON sb.id = sbi.binding_id
|
||||
@@ -2137,6 +2221,8 @@ function listHealthCheckTargets(db) {
|
||||
sg.health_check_expected_status AS expected_status,
|
||||
sg.health_check_timeout_ms AS timeout_ms,
|
||||
sg.health_check_verify_tls AS verify_tls,
|
||||
sg.health_check_providers AS providers_json,
|
||||
COALESCE(sg.health_check_aggregate, 'majority') AS aggregate,
|
||||
COALESCE(sg.health_check_provider, 'local') AS provider
|
||||
FROM service_binding_ips sbi
|
||||
JOIN service_bindings sb ON sb.id = sbi.binding_id
|
||||
@@ -2158,6 +2244,8 @@ function listHealthCheckTargets(db) {
|
||||
sb.health_check_expected_status AS expected_status,
|
||||
sb.health_check_timeout_ms AS timeout_ms,
|
||||
sb.health_check_verify_tls AS verify_tls,
|
||||
sb.health_check_providers AS providers_json,
|
||||
COALESCE(sb.health_check_aggregate, 'majority') AS aggregate,
|
||||
COALESCE(sb.health_check_provider, 'local') AS provider
|
||||
FROM service_bindings sb
|
||||
JOIN domains d ON d.id = sb.domain_id
|
||||
@@ -2176,6 +2264,8 @@ function listHealthCheckTargets(db) {
|
||||
sg.health_check_expected_status AS expected_status,
|
||||
sg.health_check_timeout_ms AS timeout_ms,
|
||||
sg.health_check_verify_tls AS verify_tls,
|
||||
sg.health_check_providers AS providers_json,
|
||||
COALESCE(sg.health_check_aggregate, 'majority') AS aggregate,
|
||||
COALESCE(sg.health_check_provider, 'local') AS provider
|
||||
FROM service_bindings sb
|
||||
JOIN domains d ON d.id = sb.domain_id
|
||||
@@ -2195,11 +2285,25 @@ function listHealthCheckTargets(db) {
|
||||
...groupInheritedBindingTargets,
|
||||
...cnameBindingTargets,
|
||||
...groupInheritedCnameBindingTargets
|
||||
].map((t) => ({
|
||||
...t,
|
||||
verify_tls: Boolean(t.verify_tls),
|
||||
provider: normalizeHealthProvider(t.provider)
|
||||
}));
|
||||
].map((t) => {
|
||||
const row = t;
|
||||
const providers = parseHealthProviders(row.providers_json, row.provider);
|
||||
return {
|
||||
scope: row.scope,
|
||||
ref_id: row.ref_id,
|
||||
ip: row.ip,
|
||||
hostname: row.hostname,
|
||||
type: row.type,
|
||||
port: row.port,
|
||||
path: row.path,
|
||||
expected_status: row.expected_status,
|
||||
timeout_ms: row.timeout_ms,
|
||||
verify_tls: Boolean(row.verify_tls),
|
||||
providers,
|
||||
aggregate: parseHealthAggregate(row.aggregate),
|
||||
provider: derivePrimaryProvider(providers)
|
||||
};
|
||||
});
|
||||
}
|
||||
function listDomainTags(db, domainId) {
|
||||
return db.select({ tag: domainTags.tag }).from(domainTags).where(eq3(domainTags.domain_id, domainId)).all().map((r) => r.tag);
|
||||
@@ -2329,7 +2433,7 @@ function listHealthProbeLogForService(db, serviceId, limit = 50) {
|
||||
`);
|
||||
return rows.map((row) => ({
|
||||
...row,
|
||||
provider: normalizeHealthProvider(row.provider),
|
||||
provider: parseHealthProviders(null, row.provider)[0] ?? "local",
|
||||
ok: Boolean(row.ok)
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
ALTER TABLE service_bindings ADD COLUMN health_check_providers TEXT;
|
||||
ALTER TABLE service_bindings ADD COLUMN health_check_aggregate TEXT NOT NULL DEFAULT 'majority';
|
||||
UPDATE service_bindings
|
||||
SET health_check_providers = CASE
|
||||
WHEN health_check_provider = 'cloudflare' THEN '["cloudflare"]'
|
||||
ELSE '["local"]'
|
||||
END
|
||||
WHERE health_check_providers IS NULL;
|
||||
|
||||
ALTER TABLE service_groups ADD COLUMN health_check_providers TEXT;
|
||||
ALTER TABLE service_groups ADD COLUMN health_check_aggregate TEXT NOT NULL DEFAULT 'majority';
|
||||
UPDATE service_groups
|
||||
SET health_check_providers = CASE
|
||||
WHEN health_check_provider = 'cloudflare' THEN '["cloudflare"]'
|
||||
ELSE '["local"]'
|
||||
END
|
||||
WHERE health_check_providers IS NULL;
|
||||
|
||||
ALTER TABLE app_settings ADD COLUMN globalping_token TEXT;
|
||||
ALTER TABLE app_settings ADD COLUMN globalping_locations TEXT;
|
||||
ALTER TABLE app_settings ADD COLUMN globalping_limit INTEGER;
|
||||
+143
-22
@@ -5,10 +5,12 @@ import type {
|
||||
DomainListItem,
|
||||
Group,
|
||||
GroupWithStats,
|
||||
HealthCheckAggregate,
|
||||
HealthCheckProvider,
|
||||
HealthCheckScope,
|
||||
HealthCheckTarget,
|
||||
HealthCheckType,
|
||||
HealthStatusProvider,
|
||||
IpHealthState,
|
||||
IpHealthStatus,
|
||||
LbMode,
|
||||
@@ -21,7 +23,15 @@ import type {
|
||||
Subdomain,
|
||||
SyncJob,
|
||||
} from "@cfdm/shared";
|
||||
import { dnsRecordNamesMatch, isIpLiteral } from "@cfdm/shared";
|
||||
import {
|
||||
derivePrimaryProvider,
|
||||
dnsRecordNamesMatch,
|
||||
isIpLiteral,
|
||||
parseHealthAggregate,
|
||||
parseHealthProviders,
|
||||
serializeHealthProviders,
|
||||
normalizeStatusProvider,
|
||||
} from "@cfdm/shared";
|
||||
import { and, asc, count, eq, isNull, like, notInArray, or, sql } from "drizzle-orm";
|
||||
import type { Db } from "./client.js";
|
||||
import { ConflictError, NotFoundError } from "./errors.js";
|
||||
@@ -770,8 +780,82 @@ export function deleteService(db: Db, id: number): void {
|
||||
|
||||
// --- Service Groups ---
|
||||
|
||||
function normalizeHealthProvider(value: unknown): HealthCheckProvider {
|
||||
return value === "cloudflare" ? "cloudflare" : "local";
|
||||
function healthProviderColumns(patch: {
|
||||
health_check_provider?: HealthCheckProvider;
|
||||
health_check_providers?: HealthCheckProvider[];
|
||||
health_check_aggregate?: HealthCheckAggregate;
|
||||
}): {
|
||||
health_check_provider?: string;
|
||||
health_check_providers?: string;
|
||||
health_check_aggregate?: string;
|
||||
} {
|
||||
const out: {
|
||||
health_check_provider?: string;
|
||||
health_check_providers?: string;
|
||||
health_check_aggregate?: string;
|
||||
} = {};
|
||||
if (patch.health_check_providers !== undefined) {
|
||||
const list = parseHealthProviders(patch.health_check_providers);
|
||||
out.health_check_providers = serializeHealthProviders(list);
|
||||
out.health_check_provider = derivePrimaryProvider(list);
|
||||
} else if (patch.health_check_provider !== undefined) {
|
||||
const list = parseHealthProviders(null, patch.health_check_provider);
|
||||
out.health_check_providers = serializeHealthProviders(list);
|
||||
out.health_check_provider = derivePrimaryProvider(list);
|
||||
}
|
||||
if (patch.health_check_aggregate !== undefined) {
|
||||
out.health_check_aggregate = parseHealthAggregate(
|
||||
patch.health_check_aggregate,
|
||||
);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
function mapHealthFields(row: {
|
||||
health_check_provider?: unknown;
|
||||
health_check_providers?: unknown;
|
||||
health_check_aggregate?: unknown;
|
||||
}): {
|
||||
health_check_provider: HealthCheckProvider;
|
||||
health_check_providers: HealthCheckProvider[];
|
||||
health_check_aggregate: HealthCheckAggregate;
|
||||
} {
|
||||
const providers = parseHealthProviders(
|
||||
row.health_check_providers,
|
||||
row.health_check_provider,
|
||||
);
|
||||
return {
|
||||
health_check_providers: providers,
|
||||
health_check_provider: derivePrimaryProvider(providers),
|
||||
health_check_aggregate: parseHealthAggregate(row.health_check_aggregate),
|
||||
};
|
||||
}
|
||||
|
||||
function mapServiceBinding(
|
||||
row: typeof serviceBindings.$inferSelect,
|
||||
): ServiceBinding {
|
||||
return {
|
||||
id: row.id,
|
||||
domain_id: row.domain_id,
|
||||
service_id: row.service_id,
|
||||
hostname: row.hostname,
|
||||
cname_target: row.cname_target,
|
||||
dns_record_id: row.dns_record_id,
|
||||
lb_mode: row.lb_mode as LbMode,
|
||||
health_check_enabled: row.health_check_enabled,
|
||||
health_check_type: row.health_check_type as HealthCheckType,
|
||||
health_check_port: row.health_check_port,
|
||||
health_check_path: row.health_check_path,
|
||||
health_check_expected_status: row.health_check_expected_status,
|
||||
health_check_interval_sec: row.health_check_interval_sec,
|
||||
health_check_timeout_ms: row.health_check_timeout_ms,
|
||||
health_check_verify_tls: row.health_check_verify_tls,
|
||||
...mapHealthFields(row),
|
||||
routing_strategy: row.routing_strategy as LbMode,
|
||||
operation_version: row.operation_version,
|
||||
created_at: row.created_at,
|
||||
updated_at: row.updated_at,
|
||||
};
|
||||
}
|
||||
|
||||
function mapServiceGroup(row: typeof serviceGroups.$inferSelect): ServiceGroup {
|
||||
@@ -791,7 +875,7 @@ function mapServiceGroup(row: typeof serviceGroups.$inferSelect): ServiceGroup {
|
||||
health_check_interval_sec: row.health_check_interval_sec,
|
||||
health_check_timeout_ms: row.health_check_timeout_ms,
|
||||
health_check_verify_tls: row.health_check_verify_tls,
|
||||
health_check_provider: normalizeHealthProvider(row.health_check_provider),
|
||||
...mapHealthFields(row),
|
||||
created_at: row.created_at,
|
||||
updated_at: row.updated_at,
|
||||
};
|
||||
@@ -827,6 +911,8 @@ export interface ServiceGroupLbPatch {
|
||||
health_check_timeout_ms?: number;
|
||||
health_check_verify_tls?: boolean;
|
||||
health_check_provider?: HealthCheckProvider;
|
||||
health_check_providers?: HealthCheckProvider[];
|
||||
health_check_aggregate?: HealthCheckAggregate;
|
||||
}
|
||||
|
||||
export function createServiceGroup(
|
||||
@@ -853,7 +939,11 @@ export function createServiceGroup(
|
||||
health_check_interval_sec: lbPatch?.health_check_interval_sec ?? 30,
|
||||
health_check_timeout_ms: lbPatch?.health_check_timeout_ms ?? 3000,
|
||||
health_check_verify_tls: lbPatch?.health_check_verify_tls ?? false,
|
||||
health_check_provider: lbPatch?.health_check_provider ?? "local",
|
||||
...healthProviderColumns({
|
||||
health_check_provider: lbPatch?.health_check_provider ?? "local",
|
||||
health_check_providers: lbPatch?.health_check_providers,
|
||||
health_check_aggregate: lbPatch?.health_check_aggregate ?? "majority",
|
||||
}),
|
||||
})
|
||||
.returning({ id: serviceGroups.id })
|
||||
.get()!.id;
|
||||
@@ -894,8 +984,7 @@ export function updateServiceGroup(
|
||||
update.health_check_timeout_ms = lbPatch.health_check_timeout_ms;
|
||||
if (lbPatch.health_check_verify_tls !== undefined)
|
||||
update.health_check_verify_tls = lbPatch.health_check_verify_tls;
|
||||
if (lbPatch.health_check_provider !== undefined)
|
||||
update.health_check_provider = lbPatch.health_check_provider;
|
||||
Object.assign(update, healthProviderColumns(lbPatch));
|
||||
}
|
||||
const result = db
|
||||
.update(serviceGroups)
|
||||
@@ -1439,6 +1528,8 @@ export interface BindingLbPatch {
|
||||
health_check_timeout_ms?: number;
|
||||
health_check_verify_tls?: boolean;
|
||||
health_check_provider?: HealthCheckProvider;
|
||||
health_check_providers?: HealthCheckProvider[];
|
||||
health_check_aggregate?: HealthCheckAggregate;
|
||||
}
|
||||
|
||||
export function updateBindingLbConfig(
|
||||
@@ -1469,8 +1560,7 @@ export function updateBindingLbConfig(
|
||||
update.health_check_timeout_ms = patch.health_check_timeout_ms;
|
||||
if (patch.health_check_verify_tls !== undefined)
|
||||
update.health_check_verify_tls = patch.health_check_verify_tls;
|
||||
if (patch.health_check_provider !== undefined)
|
||||
update.health_check_provider = patch.health_check_provider;
|
||||
Object.assign(update, healthProviderColumns(patch));
|
||||
db.update(serviceBindings)
|
||||
.set(update)
|
||||
.where(eq(serviceBindings.id, bindingId))
|
||||
@@ -1578,7 +1668,8 @@ function dnsRecordMatchesHostname(
|
||||
const SERVICE_BINDING_SELECT_COLUMNS = `sb.id, sb.domain_id, sb.service_id, sb.hostname, sb.dns_record_id,
|
||||
sb.lb_mode, sb.health_check_enabled, sb.health_check_type, sb.health_check_port,
|
||||
sb.health_check_path, sb.health_check_expected_status, sb.health_check_interval_sec,
|
||||
sb.health_check_timeout_ms, sb.health_check_verify_tls, sb.health_check_provider, sb.cname_target,
|
||||
sb.health_check_timeout_ms, sb.health_check_verify_tls, sb.health_check_provider,
|
||||
sb.health_check_providers, sb.health_check_aggregate, sb.cname_target,
|
||||
d.zone_name, d.group_id, g.name AS group_name,
|
||||
s.name AS service_name, s.slug AS service_slug,
|
||||
dr.content AS target_ip, dr.sync_status,
|
||||
@@ -1642,6 +1733,7 @@ function enrichServiceBindingView(
|
||||
return {
|
||||
...row,
|
||||
cname_target: row.cname_target ?? null,
|
||||
...mapHealthFields(row),
|
||||
target_ips,
|
||||
target_ip: target_ips[0] ?? null,
|
||||
target_ip_weights,
|
||||
@@ -1694,7 +1786,7 @@ export function getBinding(db: Db, id: number): ServiceBinding {
|
||||
.where(eq(serviceBindings.id, id))
|
||||
.get();
|
||||
if (!row) throw new NotFoundError(`service binding ${id}`);
|
||||
return row as ServiceBinding;
|
||||
return mapServiceBinding(row);
|
||||
}
|
||||
|
||||
export function getBindingView(db: Db, id: number): ServiceBindingView {
|
||||
@@ -1728,7 +1820,8 @@ export function findBinding(
|
||||
),
|
||||
)
|
||||
.get();
|
||||
return (row as ServiceBinding) ?? null;
|
||||
if (!row) return null;
|
||||
return mapServiceBinding(row);
|
||||
}
|
||||
|
||||
export function insertBinding(
|
||||
@@ -1792,7 +1885,8 @@ export function bindingsToRemove(
|
||||
.select()
|
||||
.from(serviceBindings)
|
||||
.where(eq(serviceBindings.service_id, serviceId))
|
||||
.all() as ServiceBinding[];
|
||||
.all()
|
||||
.map(mapServiceBinding);
|
||||
return all.filter((b) => !keepIds.includes(b.id));
|
||||
}
|
||||
|
||||
@@ -2124,7 +2218,7 @@ export type ServiceIpHealthRow = {
|
||||
latency_ms: number | null;
|
||||
last_checked_at: string | null;
|
||||
last_error: string | null;
|
||||
provider: HealthCheckProvider;
|
||||
provider: HealthStatusProvider;
|
||||
colo: string | null;
|
||||
};
|
||||
|
||||
@@ -2175,7 +2269,7 @@ export function listIpHealthByServiceIds(
|
||||
latency_ms: parsed.health_latency_ms,
|
||||
last_checked_at: row.last_checked_at,
|
||||
last_error: row.last_error,
|
||||
provider: normalizeHealthProvider(row.provider),
|
||||
provider: normalizeStatusProvider(row.provider),
|
||||
colo: row.colo,
|
||||
});
|
||||
result.set(row.service_id, list);
|
||||
@@ -2243,7 +2337,7 @@ export function upsertIpHealthStatus(
|
||||
consecutiveFailures: number,
|
||||
lastError: string | null,
|
||||
consecutiveSuccesses = 0,
|
||||
extras?: { colo?: string | null; provider?: HealthCheckProvider },
|
||||
extras?: { colo?: string | null; provider?: HealthStatusProvider },
|
||||
): void {
|
||||
const colo = extras?.colo ?? null;
|
||||
const provider = extras?.provider ?? "local";
|
||||
@@ -2359,6 +2453,8 @@ export function listHealthCheckTargets(db: Db): HealthCheckTarget[] {
|
||||
sb.health_check_expected_status AS expected_status,
|
||||
sb.health_check_timeout_ms AS timeout_ms,
|
||||
sb.health_check_verify_tls AS verify_tls,
|
||||
sb.health_check_providers AS providers_json,
|
||||
COALESCE(sb.health_check_aggregate, 'majority') AS aggregate,
|
||||
COALESCE(sb.health_check_provider, 'local') AS provider
|
||||
FROM service_binding_ips sbi
|
||||
JOIN service_bindings sb ON sb.id = sbi.binding_id
|
||||
@@ -2378,6 +2474,8 @@ export function listHealthCheckTargets(db: Db): HealthCheckTarget[] {
|
||||
sg.health_check_expected_status AS expected_status,
|
||||
sg.health_check_timeout_ms AS timeout_ms,
|
||||
sg.health_check_verify_tls AS verify_tls,
|
||||
sg.health_check_providers AS providers_json,
|
||||
COALESCE(sg.health_check_aggregate, 'majority') AS aggregate,
|
||||
COALESCE(sg.health_check_provider, 'local') AS provider
|
||||
FROM service_binding_ips sbi
|
||||
JOIN service_bindings sb ON sb.id = sbi.binding_id
|
||||
@@ -2404,6 +2502,8 @@ export function listHealthCheckTargets(db: Db): HealthCheckTarget[] {
|
||||
sg.health_check_expected_status AS expected_status,
|
||||
sg.health_check_timeout_ms AS timeout_ms,
|
||||
sg.health_check_verify_tls AS verify_tls,
|
||||
sg.health_check_providers AS providers_json,
|
||||
COALESCE(sg.health_check_aggregate, 'majority') AS aggregate,
|
||||
COALESCE(sg.health_check_provider, 'local') AS provider
|
||||
FROM service_binding_ips sbi
|
||||
JOIN service_bindings sb ON sb.id = sbi.binding_id
|
||||
@@ -2427,6 +2527,8 @@ export function listHealthCheckTargets(db: Db): HealthCheckTarget[] {
|
||||
sb.health_check_expected_status AS expected_status,
|
||||
sb.health_check_timeout_ms AS timeout_ms,
|
||||
sb.health_check_verify_tls AS verify_tls,
|
||||
sb.health_check_providers AS providers_json,
|
||||
COALESCE(sb.health_check_aggregate, 'majority') AS aggregate,
|
||||
COALESCE(sb.health_check_provider, 'local') AS provider
|
||||
FROM service_bindings sb
|
||||
JOIN domains d ON d.id = sb.domain_id
|
||||
@@ -2448,6 +2550,8 @@ export function listHealthCheckTargets(db: Db): HealthCheckTarget[] {
|
||||
sg.health_check_expected_status AS expected_status,
|
||||
sg.health_check_timeout_ms AS timeout_ms,
|
||||
sg.health_check_verify_tls AS verify_tls,
|
||||
sg.health_check_providers AS providers_json,
|
||||
COALESCE(sg.health_check_aggregate, 'majority') AS aggregate,
|
||||
COALESCE(sg.health_check_provider, 'local') AS provider
|
||||
FROM service_bindings sb
|
||||
JOIN domains d ON d.id = sb.domain_id
|
||||
@@ -2468,11 +2572,28 @@ export function listHealthCheckTargets(db: Db): HealthCheckTarget[] {
|
||||
...groupInheritedBindingTargets,
|
||||
...cnameBindingTargets,
|
||||
...groupInheritedCnameBindingTargets,
|
||||
].map((t) => ({
|
||||
...t,
|
||||
verify_tls: Boolean(t.verify_tls),
|
||||
provider: normalizeHealthProvider(t.provider),
|
||||
}));
|
||||
].map((t) => {
|
||||
const row = t as HealthCheckTarget & {
|
||||
providers_json?: string | null;
|
||||
aggregate?: string | null;
|
||||
};
|
||||
const providers = parseHealthProviders(row.providers_json, row.provider);
|
||||
return {
|
||||
scope: row.scope,
|
||||
ref_id: row.ref_id,
|
||||
ip: row.ip,
|
||||
hostname: row.hostname,
|
||||
type: row.type,
|
||||
port: row.port,
|
||||
path: row.path,
|
||||
expected_status: row.expected_status,
|
||||
timeout_ms: row.timeout_ms,
|
||||
verify_tls: Boolean(row.verify_tls),
|
||||
providers,
|
||||
aggregate: parseHealthAggregate(row.aggregate),
|
||||
provider: derivePrimaryProvider(providers),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
// --- Domain tags ---
|
||||
@@ -2759,7 +2880,7 @@ export function listHealthProbeLogForService(
|
||||
`);
|
||||
return rows.map((row) => ({
|
||||
...row,
|
||||
provider: normalizeHealthProvider(row.provider),
|
||||
provider: parseHealthProviders(null, row.provider)[0] ?? "local",
|
||||
ok: Boolean(row.ok),
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -65,6 +65,8 @@ export const serviceGroups = sqliteTable("service_groups", {
|
||||
.notNull()
|
||||
.default(false),
|
||||
health_check_provider: text("health_check_provider").notNull().default("local"),
|
||||
health_check_providers: text("health_check_providers").notNull().default('["local"]'),
|
||||
health_check_aggregate: text("health_check_aggregate").notNull().default("majority"),
|
||||
created_at: text("created_at")
|
||||
.notNull()
|
||||
.default(sql`datetime('now')`),
|
||||
@@ -169,6 +171,12 @@ export const serviceBindings = sqliteTable(
|
||||
health_check_provider: text("health_check_provider")
|
||||
.notNull()
|
||||
.default("local"),
|
||||
health_check_providers: text("health_check_providers")
|
||||
.notNull()
|
||||
.default('["local"]'),
|
||||
health_check_aggregate: text("health_check_aggregate")
|
||||
.notNull()
|
||||
.default("majority"),
|
||||
routing_strategy: text("routing_strategy").notNull().default("round_robin"),
|
||||
operation_version: integer("operation_version").notNull().default(0),
|
||||
created_at: text("created_at")
|
||||
@@ -398,6 +406,9 @@ export const appSettings = sqliteTable("app_settings", {
|
||||
health_worker_error: text("health_worker_error"),
|
||||
health_worker_deployed_at: text("health_worker_deployed_at"),
|
||||
health_worker_last_ingest_at: text("health_worker_last_ingest_at"),
|
||||
globalping_token: text("globalping_token"),
|
||||
globalping_locations: text("globalping_locations"),
|
||||
globalping_limit: integer("globalping_limit"),
|
||||
created_at: text("created_at")
|
||||
.notNull()
|
||||
.default(sql`datetime('now')`),
|
||||
|
||||
@@ -28,6 +28,9 @@ export type AppSettingsDto = {
|
||||
healthWorkerError: string | null;
|
||||
healthWorkerDeployedAt: string | null;
|
||||
healthWorkerLastIngestAt: string | null;
|
||||
globalpingTokenSet: boolean;
|
||||
globalpingLocations: string;
|
||||
globalpingLimit: number;
|
||||
} & HealthEngineSettings;
|
||||
|
||||
export type AppSettingsPatch = {
|
||||
@@ -47,6 +50,9 @@ export type AppSettingsPatch = {
|
||||
healthWorkerError?: string | null;
|
||||
healthWorkerDeployedAt?: string | null;
|
||||
healthWorkerLastIngestAt?: string | null;
|
||||
globalpingToken?: string;
|
||||
globalpingLocations?: string;
|
||||
globalpingLimit?: number;
|
||||
};
|
||||
|
||||
export type HealthEngineFallbacks = HealthEngineSettings & {
|
||||
@@ -118,6 +124,14 @@ function toDto(
|
||||
healthWorkerDeployedAt: row.health_worker_deployed_at ?? null,
|
||||
healthWorkerLastIngestAt: row.health_worker_last_ingest_at ?? null,
|
||||
healthWorkerStatus: workerStatus(row, env.healthWorkerUrl),
|
||||
globalpingTokenSet: Boolean(row.globalping_token?.trim()),
|
||||
globalpingLocations: row.globalping_locations?.trim() || "World",
|
||||
globalpingLimit:
|
||||
row.globalping_limit == null ||
|
||||
Number.isNaN(row.globalping_limit) ||
|
||||
row.globalping_limit < 1
|
||||
? 3
|
||||
: Math.min(10, row.globalping_limit),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -146,12 +160,16 @@ export function getAppSettingsSecrets(db: Db): {
|
||||
vpsTrackerSyncEnabled: boolean;
|
||||
healthWorkerUrl: string;
|
||||
healthWorkerToken: string;
|
||||
globalpingToken: string;
|
||||
globalpingLocations: string;
|
||||
globalpingLimit: number;
|
||||
} {
|
||||
const row = db
|
||||
.select()
|
||||
.from(appSettings)
|
||||
.where(eq(appSettings.id, SETTINGS_ID))
|
||||
.get();
|
||||
const limit = row?.globalping_limit;
|
||||
return {
|
||||
vpsTrackerUrl: row?.vps_tracker_url?.trim() ?? "",
|
||||
vpsTrackerIntegrationToken:
|
||||
@@ -159,6 +177,12 @@ export function getAppSettingsSecrets(db: Db): {
|
||||
vpsTrackerSyncEnabled: Boolean(row?.vps_tracker_sync_enabled),
|
||||
healthWorkerUrl: row?.health_worker_url?.trim() ?? "",
|
||||
healthWorkerToken: row?.health_worker_token?.trim() ?? "",
|
||||
globalpingToken: row?.globalping_token?.trim() ?? "",
|
||||
globalpingLocations: row?.globalping_locations?.trim() || "World",
|
||||
globalpingLimit:
|
||||
limit == null || Number.isNaN(limit) || limit < 1
|
||||
? 3
|
||||
: Math.min(10, limit),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -249,6 +273,19 @@ export function updateAppSettings(
|
||||
patch.healthWorkerLastIngestAt !== undefined
|
||||
? patch.healthWorkerLastIngestAt
|
||||
: current.health_worker_last_ingest_at,
|
||||
globalping_token:
|
||||
patch.globalpingToken !== undefined &&
|
||||
patch.globalpingToken.trim() !== ""
|
||||
? patch.globalpingToken
|
||||
: current.globalping_token,
|
||||
globalping_locations:
|
||||
patch.globalpingLocations !== undefined
|
||||
? patch.globalpingLocations.trim() || "World"
|
||||
: current.globalping_locations,
|
||||
globalping_limit:
|
||||
patch.globalpingLimit !== undefined
|
||||
? Math.min(10, Math.max(1, patch.globalpingLimit))
|
||||
: current.globalping_limit,
|
||||
updated_at: new Date().toISOString(),
|
||||
})
|
||||
.where(eq(appSettings.id, SETTINGS_ID))
|
||||
|
||||
Vendored
+257
-20
@@ -15,6 +15,36 @@ declare const CERT_MONITOR_REQUIRED = "required";
|
||||
declare const CERT_MONITOR_SKIPPED = "skipped";
|
||||
declare const CERT_MONITORING_VALUES: readonly ["auto", "required", "skipped"];
|
||||
|
||||
declare const HEALTH_CHECK_PROVIDERS: readonly ["local", "cloudflare", "globalping"];
|
||||
type HealthCheckProvider = (typeof HEALTH_CHECK_PROVIDERS)[number];
|
||||
declare const HEALTH_STATUS_PROVIDERS: readonly ["local", "cloudflare", "globalping", "aggregate"];
|
||||
type HealthStatusProvider = (typeof HEALTH_STATUS_PROVIDERS)[number];
|
||||
declare const HEALTH_CHECK_AGGREGATES: readonly ["any", "all", "majority"];
|
||||
type HealthCheckAggregate = (typeof HEALTH_CHECK_AGGREGATES)[number];
|
||||
declare function normalizeProbeProvider(value: unknown): HealthCheckProvider;
|
||||
declare function normalizeStatusProvider(value: unknown): HealthStatusProvider;
|
||||
declare function uniqueHealthProviders(values: readonly unknown[]): HealthCheckProvider[];
|
||||
declare function parseHealthProviders(json: unknown, fallback?: unknown): HealthCheckProvider[];
|
||||
declare function serializeHealthProviders(providers: readonly HealthCheckProvider[]): string;
|
||||
declare function parseHealthAggregate(value: unknown): HealthCheckAggregate;
|
||||
declare function derivePrimaryProvider(providers: readonly HealthCheckProvider[]): HealthCheckProvider;
|
||||
declare function targetProviders(target: {
|
||||
providers?: readonly HealthCheckProvider[] | null;
|
||||
provider?: HealthCheckProvider | null;
|
||||
}): HealthCheckProvider[];
|
||||
declare function targetHasProvider(target: {
|
||||
providers?: readonly HealthCheckProvider[] | null;
|
||||
provider?: HealthCheckProvider | null;
|
||||
}, provider: HealthCheckProvider): boolean;
|
||||
/**
|
||||
* any — Down if at least one source is Down (ok only if all ok).
|
||||
* all — Down only if every source is Down (ok if any ok).
|
||||
* majority — Down if a strict majority of sources are Down (2 → both, 3 → ≥2).
|
||||
*/
|
||||
declare function aggregateHealthOk(oks: readonly boolean[], policy: HealthCheckAggregate): boolean;
|
||||
declare function clampGlobalpingLimit(value: unknown, fallback?: number): number;
|
||||
declare function parseGlobalpingLocations(value: unknown): string[];
|
||||
|
||||
interface ServiceGroup$1 {
|
||||
id: number;
|
||||
name: string;
|
||||
@@ -32,6 +62,8 @@ interface ServiceGroup$1 {
|
||||
health_check_timeout_ms: number;
|
||||
health_check_verify_tls: boolean;
|
||||
health_check_provider: HealthCheckProvider;
|
||||
health_check_providers: HealthCheckProvider[];
|
||||
health_check_aggregate: HealthCheckAggregate;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
@@ -62,6 +94,8 @@ interface ServiceBinding {
|
||||
health_check_timeout_ms: number;
|
||||
health_check_verify_tls: boolean;
|
||||
health_check_provider: HealthCheckProvider;
|
||||
health_check_providers: HealthCheckProvider[];
|
||||
health_check_aggregate: HealthCheckAggregate;
|
||||
routing_strategy: LbMode;
|
||||
operation_version: number;
|
||||
created_at: string;
|
||||
@@ -93,6 +127,8 @@ interface ServiceBindingView {
|
||||
health_check_timeout_ms: number;
|
||||
health_check_verify_tls: boolean;
|
||||
health_check_provider: HealthCheckProvider;
|
||||
health_check_providers: HealthCheckProvider[];
|
||||
health_check_aggregate: HealthCheckAggregate;
|
||||
sync_status: string | null;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
@@ -118,6 +154,8 @@ interface ServiceDomainBindingView {
|
||||
health_check_timeout_ms: number;
|
||||
health_check_verify_tls: boolean;
|
||||
health_check_provider: HealthCheckProvider;
|
||||
health_check_providers: HealthCheckProvider[];
|
||||
health_check_aggregate: HealthCheckAggregate;
|
||||
sync_status: string | null;
|
||||
}
|
||||
interface ServiceView$1 {
|
||||
@@ -189,7 +227,6 @@ 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;
|
||||
@@ -202,7 +239,7 @@ interface IpHealthStatus {
|
||||
last_checked_at: string | null;
|
||||
last_error: string | null;
|
||||
colo?: string | null;
|
||||
provider?: HealthCheckProvider;
|
||||
provider?: HealthStatusProvider;
|
||||
}
|
||||
interface ServiceIpHealth$1 {
|
||||
ip: string;
|
||||
@@ -210,7 +247,7 @@ interface ServiceIpHealth$1 {
|
||||
latency_ms: number | null;
|
||||
last_checked_at?: string | null;
|
||||
last_error?: string | null;
|
||||
provider?: HealthCheckProvider;
|
||||
provider?: HealthStatusProvider;
|
||||
colo?: string | null;
|
||||
}
|
||||
interface ServiceNode {
|
||||
@@ -290,6 +327,8 @@ interface HealthCheckTarget {
|
||||
timeout_ms: number;
|
||||
verify_tls: boolean;
|
||||
provider: HealthCheckProvider;
|
||||
providers?: HealthCheckProvider[];
|
||||
aggregate?: HealthCheckAggregate;
|
||||
}
|
||||
|
||||
declare class ValidationError extends Error {
|
||||
@@ -370,7 +409,24 @@ declare const nodeHealthStateSchema: z.ZodEnum<{
|
||||
declare const healthCheckProviderSchema: z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
globalping: "globalping";
|
||||
}>;
|
||||
declare const healthStatusProviderSchema: z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
globalping: "globalping";
|
||||
aggregate: "aggregate";
|
||||
}>;
|
||||
declare const healthCheckAggregateSchema: z.ZodEnum<{
|
||||
any: "any";
|
||||
all: "all";
|
||||
majority: "majority";
|
||||
}>;
|
||||
declare const healthCheckProvidersSchema: z.ZodPipe<z.ZodArray<z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
globalping: "globalping";
|
||||
}>>, z.ZodTransform<("local" | "cloudflare" | "globalping")[] | readonly ["local"], ("local" | "cloudflare" | "globalping")[]>>;
|
||||
declare const healthCheckScopeSchema: z.ZodEnum<{
|
||||
binding: "binding";
|
||||
group: "group";
|
||||
@@ -397,6 +453,8 @@ declare const ipHealthStatusSchema: z.ZodObject<{
|
||||
provider: z.ZodOptional<z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
globalping: "globalping";
|
||||
aggregate: "aggregate";
|
||||
}>>;
|
||||
}, z.core.$strip>;
|
||||
declare const serviceIpHealthSchema: z.ZodObject<{
|
||||
@@ -413,6 +471,8 @@ declare const serviceIpHealthSchema: z.ZodObject<{
|
||||
provider: z.ZodOptional<z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
globalping: "globalping";
|
||||
aggregate: "aggregate";
|
||||
}>>;
|
||||
colo: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
||||
}, z.core.$strip>;
|
||||
@@ -425,6 +485,7 @@ declare const healthProbeLogSchema: z.ZodObject<{
|
||||
provider: z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
globalping: "globalping";
|
||||
}>;
|
||||
status: z.ZodEnum<{
|
||||
unknown: "unknown";
|
||||
@@ -455,21 +516,21 @@ declare const groupWithStatsSchema: z.ZodObject<{
|
||||
domain_count: z.ZodNumber;
|
||||
}, z.core.$strip>;
|
||||
declare const serviceGroupTypeSchema: z.ZodEnum<{
|
||||
custom: "custom";
|
||||
vpn: "vpn";
|
||||
network: "network";
|
||||
internet: "internet";
|
||||
bgp: "bgp";
|
||||
custom: "custom";
|
||||
}>;
|
||||
declare const serviceGroupSchema: z.ZodObject<{
|
||||
id: z.ZodNumber;
|
||||
name: z.ZodString;
|
||||
type: z.ZodCatch<z.ZodEnum<{
|
||||
custom: "custom";
|
||||
vpn: "vpn";
|
||||
network: "network";
|
||||
internet: "internet";
|
||||
bgp: "bgp";
|
||||
custom: "custom";
|
||||
}>>;
|
||||
icon: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
||||
domain: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
||||
@@ -495,6 +556,17 @@ declare const serviceGroupSchema: z.ZodObject<{
|
||||
health_check_provider: z.ZodCatch<z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
globalping: "globalping";
|
||||
}>>;
|
||||
health_check_providers: z.ZodCatch<z.ZodPipe<z.ZodArray<z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
globalping: "globalping";
|
||||
}>>, z.ZodTransform<("local" | "cloudflare" | "globalping")[] | readonly ["local"], ("local" | "cloudflare" | "globalping")[]>>>;
|
||||
health_check_aggregate: z.ZodCatch<z.ZodEnum<{
|
||||
any: "any";
|
||||
all: "all";
|
||||
majority: "majority";
|
||||
}>>;
|
||||
created_at: z.ZodString;
|
||||
updated_at: z.ZodString;
|
||||
@@ -548,6 +620,17 @@ declare const serviceDomainBindingSchema: z.ZodPipe<z.ZodObject<{
|
||||
health_check_provider: z.ZodCatch<z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
globalping: "globalping";
|
||||
}>>;
|
||||
health_check_providers: z.ZodCatch<z.ZodPipe<z.ZodArray<z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
globalping: "globalping";
|
||||
}>>, z.ZodTransform<("local" | "cloudflare" | "globalping")[] | readonly ["local"], ("local" | "cloudflare" | "globalping")[]>>>;
|
||||
health_check_aggregate: z.ZodCatch<z.ZodEnum<{
|
||||
any: "any";
|
||||
all: "all";
|
||||
majority: "majority";
|
||||
}>>;
|
||||
sync_status: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
||||
}, z.core.$strip>, z.ZodTransform<{
|
||||
@@ -570,7 +653,9 @@ declare const serviceDomainBindingSchema: z.ZodPipe<z.ZodObject<{
|
||||
health_check_interval_sec: number;
|
||||
health_check_timeout_ms: number;
|
||||
health_check_verify_tls: boolean;
|
||||
health_check_provider: "local" | "cloudflare";
|
||||
health_check_provider: "local" | "cloudflare" | "globalping";
|
||||
health_check_providers: ("local" | "cloudflare" | "globalping")[] | readonly ["local"];
|
||||
health_check_aggregate: "any" | "all" | "majority";
|
||||
sync_status: string | null;
|
||||
target_ip?: string | null | undefined;
|
||||
}, {
|
||||
@@ -589,7 +674,9 @@ declare const serviceDomainBindingSchema: z.ZodPipe<z.ZodObject<{
|
||||
health_check_interval_sec: number;
|
||||
health_check_timeout_ms: number;
|
||||
health_check_verify_tls: boolean;
|
||||
health_check_provider: "local" | "cloudflare";
|
||||
health_check_provider: "local" | "cloudflare" | "globalping";
|
||||
health_check_providers: ("local" | "cloudflare" | "globalping")[] | readonly ["local"];
|
||||
health_check_aggregate: "any" | "all" | "majority";
|
||||
sync_status: string | null;
|
||||
target_ips?: string[] | undefined;
|
||||
target_ip?: string | null | undefined;
|
||||
@@ -646,6 +733,17 @@ declare const serviceViewSchema: z.ZodObject<{
|
||||
health_check_provider: z.ZodCatch<z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
globalping: "globalping";
|
||||
}>>;
|
||||
health_check_providers: z.ZodCatch<z.ZodPipe<z.ZodArray<z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
globalping: "globalping";
|
||||
}>>, z.ZodTransform<("local" | "cloudflare" | "globalping")[] | readonly ["local"], ("local" | "cloudflare" | "globalping")[]>>>;
|
||||
health_check_aggregate: z.ZodCatch<z.ZodEnum<{
|
||||
any: "any";
|
||||
all: "all";
|
||||
majority: "majority";
|
||||
}>>;
|
||||
sync_status: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
||||
}, z.core.$strip>, z.ZodTransform<{
|
||||
@@ -668,7 +766,9 @@ declare const serviceViewSchema: z.ZodObject<{
|
||||
health_check_interval_sec: number;
|
||||
health_check_timeout_ms: number;
|
||||
health_check_verify_tls: boolean;
|
||||
health_check_provider: "local" | "cloudflare";
|
||||
health_check_provider: "local" | "cloudflare" | "globalping";
|
||||
health_check_providers: ("local" | "cloudflare" | "globalping")[] | readonly ["local"];
|
||||
health_check_aggregate: "any" | "all" | "majority";
|
||||
sync_status: string | null;
|
||||
target_ip?: string | null | undefined;
|
||||
}, {
|
||||
@@ -687,7 +787,9 @@ declare const serviceViewSchema: z.ZodObject<{
|
||||
health_check_interval_sec: number;
|
||||
health_check_timeout_ms: number;
|
||||
health_check_verify_tls: boolean;
|
||||
health_check_provider: "local" | "cloudflare";
|
||||
health_check_provider: "local" | "cloudflare" | "globalping";
|
||||
health_check_providers: ("local" | "cloudflare" | "globalping")[] | readonly ["local"];
|
||||
health_check_aggregate: "any" | "all" | "majority";
|
||||
sync_status: string | null;
|
||||
target_ips?: string[] | undefined;
|
||||
target_ip?: string | null | undefined;
|
||||
@@ -716,6 +818,8 @@ declare const serviceViewSchema: z.ZodObject<{
|
||||
provider: z.ZodOptional<z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
globalping: "globalping";
|
||||
aggregate: "aggregate";
|
||||
}>>;
|
||||
colo: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
||||
}, z.core.$strip>>>;
|
||||
@@ -725,11 +829,11 @@ declare const serviceGroupViewSchema: z.ZodObject<{
|
||||
id: z.ZodNumber;
|
||||
name: z.ZodString;
|
||||
type: z.ZodCatch<z.ZodEnum<{
|
||||
custom: "custom";
|
||||
vpn: "vpn";
|
||||
network: "network";
|
||||
internet: "internet";
|
||||
bgp: "bgp";
|
||||
custom: "custom";
|
||||
}>>;
|
||||
icon: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
||||
domain: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
||||
@@ -755,6 +859,17 @@ declare const serviceGroupViewSchema: z.ZodObject<{
|
||||
health_check_provider: z.ZodCatch<z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
globalping: "globalping";
|
||||
}>>;
|
||||
health_check_providers: z.ZodCatch<z.ZodPipe<z.ZodArray<z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
globalping: "globalping";
|
||||
}>>, z.ZodTransform<("local" | "cloudflare" | "globalping")[] | readonly ["local"], ("local" | "cloudflare" | "globalping")[]>>>;
|
||||
health_check_aggregate: z.ZodCatch<z.ZodEnum<{
|
||||
any: "any";
|
||||
all: "all";
|
||||
majority: "majority";
|
||||
}>>;
|
||||
created_at: z.ZodString;
|
||||
updated_at: z.ZodString;
|
||||
@@ -807,6 +922,17 @@ declare const serviceGroupViewSchema: z.ZodObject<{
|
||||
health_check_provider: z.ZodCatch<z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
globalping: "globalping";
|
||||
}>>;
|
||||
health_check_providers: z.ZodCatch<z.ZodPipe<z.ZodArray<z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
globalping: "globalping";
|
||||
}>>, z.ZodTransform<("local" | "cloudflare" | "globalping")[] | readonly ["local"], ("local" | "cloudflare" | "globalping")[]>>>;
|
||||
health_check_aggregate: z.ZodCatch<z.ZodEnum<{
|
||||
any: "any";
|
||||
all: "all";
|
||||
majority: "majority";
|
||||
}>>;
|
||||
sync_status: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
||||
}, z.core.$strip>, z.ZodTransform<{
|
||||
@@ -829,7 +955,9 @@ declare const serviceGroupViewSchema: z.ZodObject<{
|
||||
health_check_interval_sec: number;
|
||||
health_check_timeout_ms: number;
|
||||
health_check_verify_tls: boolean;
|
||||
health_check_provider: "local" | "cloudflare";
|
||||
health_check_provider: "local" | "cloudflare" | "globalping";
|
||||
health_check_providers: ("local" | "cloudflare" | "globalping")[] | readonly ["local"];
|
||||
health_check_aggregate: "any" | "all" | "majority";
|
||||
sync_status: string | null;
|
||||
target_ip?: string | null | undefined;
|
||||
}, {
|
||||
@@ -848,7 +976,9 @@ declare const serviceGroupViewSchema: z.ZodObject<{
|
||||
health_check_interval_sec: number;
|
||||
health_check_timeout_ms: number;
|
||||
health_check_verify_tls: boolean;
|
||||
health_check_provider: "local" | "cloudflare";
|
||||
health_check_provider: "local" | "cloudflare" | "globalping";
|
||||
health_check_providers: ("local" | "cloudflare" | "globalping")[] | readonly ["local"];
|
||||
health_check_aggregate: "any" | "all" | "majority";
|
||||
sync_status: string | null;
|
||||
target_ips?: string[] | undefined;
|
||||
target_ip?: string | null | undefined;
|
||||
@@ -877,6 +1007,8 @@ declare const serviceGroupViewSchema: z.ZodObject<{
|
||||
provider: z.ZodOptional<z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
globalping: "globalping";
|
||||
aggregate: "aggregate";
|
||||
}>>;
|
||||
colo: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
||||
}, z.core.$strip>>>;
|
||||
@@ -895,11 +1027,11 @@ declare const serviceGroupsResponseSchema: z.ZodObject<{
|
||||
id: z.ZodNumber;
|
||||
name: z.ZodString;
|
||||
type: z.ZodCatch<z.ZodEnum<{
|
||||
custom: "custom";
|
||||
vpn: "vpn";
|
||||
network: "network";
|
||||
internet: "internet";
|
||||
bgp: "bgp";
|
||||
custom: "custom";
|
||||
}>>;
|
||||
icon: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
||||
domain: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
||||
@@ -925,6 +1057,17 @@ declare const serviceGroupsResponseSchema: z.ZodObject<{
|
||||
health_check_provider: z.ZodCatch<z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
globalping: "globalping";
|
||||
}>>;
|
||||
health_check_providers: z.ZodCatch<z.ZodPipe<z.ZodArray<z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
globalping: "globalping";
|
||||
}>>, z.ZodTransform<("local" | "cloudflare" | "globalping")[] | readonly ["local"], ("local" | "cloudflare" | "globalping")[]>>>;
|
||||
health_check_aggregate: z.ZodCatch<z.ZodEnum<{
|
||||
any: "any";
|
||||
all: "all";
|
||||
majority: "majority";
|
||||
}>>;
|
||||
created_at: z.ZodString;
|
||||
updated_at: z.ZodString;
|
||||
@@ -977,6 +1120,17 @@ declare const serviceGroupsResponseSchema: z.ZodObject<{
|
||||
health_check_provider: z.ZodCatch<z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
globalping: "globalping";
|
||||
}>>;
|
||||
health_check_providers: z.ZodCatch<z.ZodPipe<z.ZodArray<z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
globalping: "globalping";
|
||||
}>>, z.ZodTransform<("local" | "cloudflare" | "globalping")[] | readonly ["local"], ("local" | "cloudflare" | "globalping")[]>>>;
|
||||
health_check_aggregate: z.ZodCatch<z.ZodEnum<{
|
||||
any: "any";
|
||||
all: "all";
|
||||
majority: "majority";
|
||||
}>>;
|
||||
sync_status: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
||||
}, z.core.$strip>, z.ZodTransform<{
|
||||
@@ -999,7 +1153,9 @@ declare const serviceGroupsResponseSchema: z.ZodObject<{
|
||||
health_check_interval_sec: number;
|
||||
health_check_timeout_ms: number;
|
||||
health_check_verify_tls: boolean;
|
||||
health_check_provider: "local" | "cloudflare";
|
||||
health_check_provider: "local" | "cloudflare" | "globalping";
|
||||
health_check_providers: ("local" | "cloudflare" | "globalping")[] | readonly ["local"];
|
||||
health_check_aggregate: "any" | "all" | "majority";
|
||||
sync_status: string | null;
|
||||
target_ip?: string | null | undefined;
|
||||
}, {
|
||||
@@ -1018,7 +1174,9 @@ declare const serviceGroupsResponseSchema: z.ZodObject<{
|
||||
health_check_interval_sec: number;
|
||||
health_check_timeout_ms: number;
|
||||
health_check_verify_tls: boolean;
|
||||
health_check_provider: "local" | "cloudflare";
|
||||
health_check_provider: "local" | "cloudflare" | "globalping";
|
||||
health_check_providers: ("local" | "cloudflare" | "globalping")[] | readonly ["local"];
|
||||
health_check_aggregate: "any" | "all" | "majority";
|
||||
sync_status: string | null;
|
||||
target_ips?: string[] | undefined;
|
||||
target_ip?: string | null | undefined;
|
||||
@@ -1047,6 +1205,8 @@ declare const serviceGroupsResponseSchema: z.ZodObject<{
|
||||
provider: z.ZodOptional<z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
globalping: "globalping";
|
||||
aggregate: "aggregate";
|
||||
}>>;
|
||||
colo: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
||||
}, z.core.$strip>>>;
|
||||
@@ -1109,6 +1269,17 @@ declare const serviceGroupsResponseSchema: z.ZodObject<{
|
||||
health_check_provider: z.ZodCatch<z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
globalping: "globalping";
|
||||
}>>;
|
||||
health_check_providers: z.ZodCatch<z.ZodPipe<z.ZodArray<z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
globalping: "globalping";
|
||||
}>>, z.ZodTransform<("local" | "cloudflare" | "globalping")[] | readonly ["local"], ("local" | "cloudflare" | "globalping")[]>>>;
|
||||
health_check_aggregate: z.ZodCatch<z.ZodEnum<{
|
||||
any: "any";
|
||||
all: "all";
|
||||
majority: "majority";
|
||||
}>>;
|
||||
sync_status: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
||||
}, z.core.$strip>, z.ZodTransform<{
|
||||
@@ -1131,7 +1302,9 @@ declare const serviceGroupsResponseSchema: z.ZodObject<{
|
||||
health_check_interval_sec: number;
|
||||
health_check_timeout_ms: number;
|
||||
health_check_verify_tls: boolean;
|
||||
health_check_provider: "local" | "cloudflare";
|
||||
health_check_provider: "local" | "cloudflare" | "globalping";
|
||||
health_check_providers: ("local" | "cloudflare" | "globalping")[] | readonly ["local"];
|
||||
health_check_aggregate: "any" | "all" | "majority";
|
||||
sync_status: string | null;
|
||||
target_ip?: string | null | undefined;
|
||||
}, {
|
||||
@@ -1150,7 +1323,9 @@ declare const serviceGroupsResponseSchema: z.ZodObject<{
|
||||
health_check_interval_sec: number;
|
||||
health_check_timeout_ms: number;
|
||||
health_check_verify_tls: boolean;
|
||||
health_check_provider: "local" | "cloudflare";
|
||||
health_check_provider: "local" | "cloudflare" | "globalping";
|
||||
health_check_providers: ("local" | "cloudflare" | "globalping")[] | readonly ["local"];
|
||||
health_check_aggregate: "any" | "all" | "majority";
|
||||
sync_status: string | null;
|
||||
target_ips?: string[] | undefined;
|
||||
target_ip?: string | null | undefined;
|
||||
@@ -1179,6 +1354,8 @@ declare const serviceGroupsResponseSchema: z.ZodObject<{
|
||||
provider: z.ZodOptional<z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
globalping: "globalping";
|
||||
aggregate: "aggregate";
|
||||
}>>;
|
||||
colo: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
||||
}, z.core.$strip>>>;
|
||||
@@ -1387,6 +1564,17 @@ declare const healthCheckConfigSchema: z.ZodObject<{
|
||||
health_check_provider: z.ZodOptional<z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
globalping: "globalping";
|
||||
}>>;
|
||||
health_check_providers: z.ZodOptional<z.ZodPipe<z.ZodArray<z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
globalping: "globalping";
|
||||
}>>, z.ZodTransform<("local" | "cloudflare" | "globalping")[] | readonly ["local"], ("local" | "cloudflare" | "globalping")[]>>>;
|
||||
health_check_aggregate: z.ZodOptional<z.ZodEnum<{
|
||||
any: "any";
|
||||
all: "all";
|
||||
majority: "majority";
|
||||
}>>;
|
||||
}, z.core.$strip>;
|
||||
type HealthCheckConfig = z.infer<typeof healthCheckConfigSchema>;
|
||||
@@ -1418,6 +1606,17 @@ declare const createServiceWithConfigSchema: z.ZodObject<{
|
||||
health_check_provider: z.ZodOptional<z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
globalping: "globalping";
|
||||
}>>;
|
||||
health_check_providers: z.ZodOptional<z.ZodPipe<z.ZodArray<z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
globalping: "globalping";
|
||||
}>>, z.ZodTransform<("local" | "cloudflare" | "globalping")[] | readonly ["local"], ("local" | "cloudflare" | "globalping")[]>>>;
|
||||
health_check_aggregate: z.ZodOptional<z.ZodEnum<{
|
||||
any: "any";
|
||||
all: "all";
|
||||
majority: "majority";
|
||||
}>>;
|
||||
fqdn: z.ZodString;
|
||||
target_ips: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
||||
@@ -1610,6 +1809,17 @@ declare const updateServiceConfigSchema: z.ZodObject<{
|
||||
health_check_provider: z.ZodOptional<z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
globalping: "globalping";
|
||||
}>>;
|
||||
health_check_providers: z.ZodOptional<z.ZodPipe<z.ZodArray<z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
globalping: "globalping";
|
||||
}>>, z.ZodTransform<("local" | "cloudflare" | "globalping")[] | readonly ["local"], ("local" | "cloudflare" | "globalping")[]>>>;
|
||||
health_check_aggregate: z.ZodOptional<z.ZodEnum<{
|
||||
any: "any";
|
||||
all: "all";
|
||||
majority: "majority";
|
||||
}>>;
|
||||
fqdn: z.ZodString;
|
||||
target_ips: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
||||
@@ -1641,14 +1851,25 @@ declare const createServiceGroupSchema: z.ZodObject<{
|
||||
health_check_provider: z.ZodOptional<z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
globalping: "globalping";
|
||||
}>>;
|
||||
health_check_providers: z.ZodOptional<z.ZodPipe<z.ZodArray<z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
globalping: "globalping";
|
||||
}>>, z.ZodTransform<("local" | "cloudflare" | "globalping")[] | readonly ["local"], ("local" | "cloudflare" | "globalping")[]>>>;
|
||||
health_check_aggregate: z.ZodOptional<z.ZodEnum<{
|
||||
any: "any";
|
||||
all: "all";
|
||||
majority: "majority";
|
||||
}>>;
|
||||
name: z.ZodString;
|
||||
type: z.ZodDefault<z.ZodEnum<{
|
||||
custom: "custom";
|
||||
vpn: "vpn";
|
||||
network: "network";
|
||||
internet: "internet";
|
||||
bgp: "bgp";
|
||||
custom: "custom";
|
||||
}>>;
|
||||
icon: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
||||
domain: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
||||
@@ -1675,14 +1896,25 @@ declare const updateServiceGroupSchema: z.ZodObject<{
|
||||
health_check_provider: z.ZodOptional<z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
globalping: "globalping";
|
||||
}>>;
|
||||
health_check_providers: z.ZodOptional<z.ZodPipe<z.ZodArray<z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
globalping: "globalping";
|
||||
}>>, z.ZodTransform<("local" | "cloudflare" | "globalping")[] | readonly ["local"], ("local" | "cloudflare" | "globalping")[]>>>;
|
||||
health_check_aggregate: z.ZodOptional<z.ZodEnum<{
|
||||
any: "any";
|
||||
all: "all";
|
||||
majority: "majority";
|
||||
}>>;
|
||||
name: z.ZodOptional<z.ZodString>;
|
||||
type: z.ZodOptional<z.ZodEnum<{
|
||||
custom: "custom";
|
||||
vpn: "vpn";
|
||||
network: "network";
|
||||
internet: "internet";
|
||||
bgp: "bgp";
|
||||
custom: "custom";
|
||||
}>>;
|
||||
icon: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
||||
domain: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
||||
@@ -1776,6 +2008,7 @@ declare const originHealthCheckSchema: z.ZodObject<{
|
||||
provider: z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
globalping: "globalping";
|
||||
}>;
|
||||
cf_healthcheck_id: z.ZodNullable<z.ZodString>;
|
||||
cf_zone_id: z.ZodNullable<z.ZodString>;
|
||||
@@ -1797,6 +2030,7 @@ declare const createOriginHealthCheckSchema: z.ZodObject<{
|
||||
provider: z.ZodEnum<{
|
||||
local: "local";
|
||||
cloudflare: "cloudflare";
|
||||
globalping: "globalping";
|
||||
}>;
|
||||
name: z.ZodString;
|
||||
cf_zone_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
||||
@@ -1924,6 +2158,9 @@ declare const appSettingsPatchSchema: z.ZodObject<{
|
||||
healthSuccessRecoveries: z.ZodOptional<z.ZodNumber>;
|
||||
healthWorkerUrl: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodLiteral<"">]>>;
|
||||
healthWorkerToken: z.ZodOptional<z.ZodString>;
|
||||
globalpingToken: z.ZodOptional<z.ZodString>;
|
||||
globalpingLocations: z.ZodOptional<z.ZodString>;
|
||||
globalpingLimit: z.ZodOptional<z.ZodNumber>;
|
||||
}, z.core.$strip>;
|
||||
type AppSettingsPatch = z.infer<typeof appSettingsPatchSchema>;
|
||||
declare const vpsTrackerEventSchema: z.ZodObject<{
|
||||
@@ -2085,4 +2322,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 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, HEALTH_KV_CURSOR_KEY, HEALTH_KV_RESULTS_KEY, HEALTH_KV_TARGETS_KEY, HEALTH_PROBE_BATCH, HEALTH_PROBE_CONCURRENCY, HEALTH_PROBE_KV_TITLE, HEALTH_PROBE_SCRIPT_NAME, type HealthCheckConfig, type HealthCheckProvider, type HealthCheckScope, type HealthCheckTarget, type HealthCheckType, type HealthProbeLog, type HealthProbeResultItem, type HealthProbeResultsDoc, type HealthProbeTargetItem, type HealthProbeTargetsDoc, type HealthStatusQuery, type HealthWorkerStatus, 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 ServiceIpHealth, type ServiceNode, type ServiceNodeRecord, type ServiceOverview, type ServiceView, type Subdomain, type SubdomainRecord, type SyncJob, type ToggleEnabledInput, type ToggleServiceIpInput, 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, healthProbeLogSchema, healthStatusQuerySchema, ingestAuditEventSchema, ipHealthStateSchema, ipHealthStatusSchema, isIpLiteral, isValidIpv4, lbModeSchema, loginSchema, nodeHealthStateSchema, normalizeDnsRecordName, notificationLogSchema, originHealthCheckSchema, parseFqdn, reorderServicesSchema, serviceBindingSchema, serviceDomainBindingSchema, serviceGroupSchema, serviceGroupTypeSchema, serviceGroupViewSchema, serviceGroupsResponseSchema, serviceIpHealthSchema, serviceNodeSchema, serviceSchema, serviceViewSchema, shouldMonitorService, subdomainLabelToFqdn, subdomainSchema, toggleEnabledSchema, toggleServiceIpSchema, updateDomainGroupSchema, updateDomainSchema, updateServiceConfigSchema, updateServiceGroupSchema, updateServiceNodeSchema, 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, HEALTH_CHECK_AGGREGATES, HEALTH_CHECK_PROVIDERS, HEALTH_KV_CURSOR_KEY, HEALTH_KV_RESULTS_KEY, HEALTH_KV_TARGETS_KEY, HEALTH_PROBE_BATCH, HEALTH_PROBE_CONCURRENCY, HEALTH_PROBE_KV_TITLE, HEALTH_PROBE_SCRIPT_NAME, HEALTH_STATUS_PROVIDERS, type HealthCheckAggregate, type HealthCheckConfig, type HealthCheckProvider, type HealthCheckScope, type HealthCheckTarget, type HealthCheckType, type HealthProbeLog, type HealthProbeResultItem, type HealthProbeResultsDoc, type HealthProbeTargetItem, type HealthProbeTargetsDoc, type HealthStatusProvider, type HealthStatusQuery, type HealthWorkerStatus, 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 ServiceIpHealth, type ServiceNode, type ServiceNodeRecord, type ServiceOverview, type ServiceView, type Subdomain, type SubdomainRecord, type SyncJob, type ToggleEnabledInput, type ToggleServiceIpInput, type UpdateDomainInput, type UpdateServiceConfigInput, type UpdateServiceGroupInput, type UpdateServiceNodeInput, type UpdateSubdomainInput, ValidationError, type VpsTrackerEvent, aggregateHealthOk, appSettingsPatchSchema, appSwitcherConfigSchema, appSwitcherEntrySchema, appSwitcherIconSchema, auditListQuerySchema, auditLogEntrySchema, auditSeveritySchema, auditSourceAppSchema, auditTargetTypeSchema, bindingToFqdn, bulkUpdateDomainsSchema, certMonitoringSchema, certStatusFromExpiry, certificateSchema, cfdmBindingSyncItemSchema, cfdmSyncBindingsBodySchema, changeDomainSchema, changeIpSchema, clampGlobalpingLimit, createDnsRecordSchema, createDomainMonitorSchema, createDomainSchema, createGroupSchema, createOriginHealthCheckSchema, createServiceBindingSchema, createServiceGroupSchema, createServiceNodeSchema, createServiceSchema, createServiceWithConfigSchema, createSubdomainSchema, derivePrimaryProvider, dnsNameToSubdomainLabel, dnsRecordNamesMatch, dnsRecordSchema, domainEnvironmentSchema, domainListItemSchema, domainMonitorResultSchema, domainMonitorSchema, domainMonitorTypeSchema, domainSchema, fqdnToDisplay, groupSchema, groupWithStatsSchema, healthCheckAggregateSchema, healthCheckConfigSchema, healthCheckProviderSchema, healthCheckProvidersSchema, healthCheckScopeSchema, healthCheckTypeSchema, healthProbeLogSchema, healthStatusProviderSchema, healthStatusQuerySchema, ingestAuditEventSchema, ipHealthStateSchema, ipHealthStatusSchema, isIpLiteral, isValidIpv4, lbModeSchema, loginSchema, nodeHealthStateSchema, normalizeDnsRecordName, normalizeProbeProvider, normalizeStatusProvider, notificationLogSchema, originHealthCheckSchema, parseFqdn, parseGlobalpingLocations, parseHealthAggregate, parseHealthProviders, reorderServicesSchema, serializeHealthProviders, serviceBindingSchema, serviceDomainBindingSchema, serviceGroupSchema, serviceGroupTypeSchema, serviceGroupViewSchema, serviceGroupsResponseSchema, serviceIpHealthSchema, serviceNodeSchema, serviceSchema, serviceViewSchema, shouldMonitorService, subdomainLabelToFqdn, subdomainSchema, targetHasProvider, targetProviders, toggleEnabledSchema, toggleServiceIpSchema, uniqueHealthProviders, updateDomainGroupSchema, updateDomainSchema, updateServiceConfigSchema, updateServiceGroupSchema, updateServiceNodeSchema, updateSubdomainSchema, validateDnsRecord, vpsTrackerEventSchema };
|
||||
|
||||
Vendored
+132
-5
@@ -165,6 +165,100 @@ function bindingToFqdn(binding) {
|
||||
|
||||
// src/schemas.ts
|
||||
import { z } from "zod";
|
||||
|
||||
// src/health-providers.ts
|
||||
var HEALTH_CHECK_PROVIDERS = [
|
||||
"local",
|
||||
"cloudflare",
|
||||
"globalping"
|
||||
];
|
||||
var HEALTH_STATUS_PROVIDERS = [
|
||||
...HEALTH_CHECK_PROVIDERS,
|
||||
"aggregate"
|
||||
];
|
||||
var HEALTH_CHECK_AGGREGATES = ["any", "all", "majority"];
|
||||
var PROVIDER_SET = new Set(HEALTH_CHECK_PROVIDERS);
|
||||
var STATUS_SET = new Set(HEALTH_STATUS_PROVIDERS);
|
||||
var AGGREGATE_SET = new Set(HEALTH_CHECK_AGGREGATES);
|
||||
function normalizeProbeProvider(value) {
|
||||
return value === "cloudflare" || value === "globalping" || value === "local" ? value : "local";
|
||||
}
|
||||
function normalizeStatusProvider(value) {
|
||||
if (typeof value === "string" && STATUS_SET.has(value)) {
|
||||
return value;
|
||||
}
|
||||
return "local";
|
||||
}
|
||||
function uniqueHealthProviders(values) {
|
||||
const out = [];
|
||||
for (const value of values) {
|
||||
if (!PROVIDER_SET.has(String(value))) continue;
|
||||
const next = value;
|
||||
if (!out.includes(next)) out.push(next);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
function parseHealthProviders(json, fallback) {
|
||||
if (Array.isArray(json)) {
|
||||
const parsed = uniqueHealthProviders(json);
|
||||
if (parsed.length > 0) return parsed;
|
||||
}
|
||||
if (typeof json === "string" && json.trim()) {
|
||||
const trimmed = json.trim();
|
||||
if (trimmed.startsWith("[")) {
|
||||
try {
|
||||
const parsed = uniqueHealthProviders(JSON.parse(trimmed));
|
||||
if (parsed.length > 0) return parsed;
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
const one = uniqueHealthProviders(trimmed.split(","));
|
||||
if (one.length > 0) return one;
|
||||
}
|
||||
return [normalizeProbeProvider(fallback)];
|
||||
}
|
||||
function serializeHealthProviders(providers) {
|
||||
const unique = uniqueHealthProviders(providers);
|
||||
return JSON.stringify(unique.length > 0 ? unique : ["local"]);
|
||||
}
|
||||
function parseHealthAggregate(value) {
|
||||
if (typeof value === "string" && AGGREGATE_SET.has(value)) {
|
||||
return value;
|
||||
}
|
||||
return "majority";
|
||||
}
|
||||
function derivePrimaryProvider(providers) {
|
||||
return uniqueHealthProviders(providers)[0] ?? "local";
|
||||
}
|
||||
function targetProviders(target) {
|
||||
if (target.providers && target.providers.length > 0) {
|
||||
return uniqueHealthProviders(target.providers);
|
||||
}
|
||||
return [normalizeProbeProvider(target.provider)];
|
||||
}
|
||||
function targetHasProvider(target, provider) {
|
||||
return targetProviders(target).includes(provider);
|
||||
}
|
||||
function aggregateHealthOk(oks, policy) {
|
||||
const n = oks.length;
|
||||
if (n === 0) return false;
|
||||
const down = oks.filter((ok) => !ok).length;
|
||||
if (policy === "any") return down === 0;
|
||||
if (policy === "all") return down < n;
|
||||
return down < Math.floor(n / 2) + 1;
|
||||
}
|
||||
function clampGlobalpingLimit(value, fallback = 3) {
|
||||
const n = typeof value === "number" ? value : Number(value);
|
||||
if (!Number.isFinite(n)) return fallback;
|
||||
return Math.min(10, Math.max(1, Math.trunc(n)));
|
||||
}
|
||||
function parseGlobalpingLocations(value) {
|
||||
const raw = typeof value === "string" ? value : "";
|
||||
const parts = raw.split(",").map((part) => part.trim()).filter(Boolean);
|
||||
return parts.length > 0 ? parts : ["World"];
|
||||
}
|
||||
|
||||
// src/schemas.ts
|
||||
var certMonitoringSchema = z.enum(["auto", "required", "skipped"]);
|
||||
var lbModeSchema = z.enum(["round_robin", "failover", "weighted"]);
|
||||
var healthCheckTypeSchema = z.enum(["tcp", "http", "ping", "dns"]);
|
||||
@@ -179,7 +273,13 @@ var nodeHealthStateSchema = z.enum([
|
||||
"unhealthy",
|
||||
"disabled"
|
||||
]);
|
||||
var healthCheckProviderSchema = z.enum(["local", "cloudflare"]);
|
||||
var healthCheckProviderSchema = z.enum(HEALTH_CHECK_PROVIDERS);
|
||||
var healthStatusProviderSchema = z.enum(HEALTH_STATUS_PROVIDERS);
|
||||
var healthCheckAggregateSchema = z.enum(HEALTH_CHECK_AGGREGATES);
|
||||
var healthCheckProvidersSchema = z.array(healthCheckProviderSchema).min(1).transform((arr) => {
|
||||
const unique = uniqueHealthProviders(arr);
|
||||
return unique.length > 0 ? unique : ["local"];
|
||||
});
|
||||
var healthCheckScopeSchema = z.enum(["binding", "group"]);
|
||||
var ipHealthStatusSchema = z.object({
|
||||
scope: healthCheckScopeSchema,
|
||||
@@ -192,7 +292,7 @@ var ipHealthStatusSchema = z.object({
|
||||
last_checked_at: z.string().nullable(),
|
||||
last_error: z.string().nullable(),
|
||||
colo: z.string().nullable().optional(),
|
||||
provider: healthCheckProviderSchema.optional()
|
||||
provider: healthStatusProviderSchema.optional()
|
||||
});
|
||||
var serviceIpHealthSchema = z.object({
|
||||
ip: z.string(),
|
||||
@@ -200,7 +300,7 @@ var serviceIpHealthSchema = z.object({
|
||||
latency_ms: z.number().nullable(),
|
||||
last_checked_at: z.string().nullable().optional(),
|
||||
last_error: z.string().nullable().optional(),
|
||||
provider: healthCheckProviderSchema.optional(),
|
||||
provider: healthStatusProviderSchema.optional(),
|
||||
colo: z.string().nullable().optional()
|
||||
});
|
||||
var healthProbeLogSchema = z.object({
|
||||
@@ -250,6 +350,8 @@ var serviceGroupSchema = z.object({
|
||||
health_check_timeout_ms: z.number().default(3e3),
|
||||
health_check_verify_tls: z.coerce.boolean().default(false),
|
||||
health_check_provider: healthCheckProviderSchema.catch("local"),
|
||||
health_check_providers: healthCheckProvidersSchema.catch(["local"]),
|
||||
health_check_aggregate: healthCheckAggregateSchema.catch("majority"),
|
||||
created_at: z.string(),
|
||||
updated_at: z.string()
|
||||
});
|
||||
@@ -288,6 +390,8 @@ var serviceDomainBindingSchema = z.object({
|
||||
health_check_timeout_ms: z.number().default(3e3),
|
||||
health_check_verify_tls: z.coerce.boolean().default(false),
|
||||
health_check_provider: healthCheckProviderSchema.catch("local"),
|
||||
health_check_providers: healthCheckProvidersSchema.catch(["local"]),
|
||||
health_check_aggregate: healthCheckAggregateSchema.catch("majority"),
|
||||
sync_status: z.string().nullable().default(null)
|
||||
}).transform((binding) => ({
|
||||
...binding,
|
||||
@@ -414,7 +518,9 @@ var healthCheckConfigFields = {
|
||||
health_check_interval_sec: z.number().int().min(5).max(3600).optional(),
|
||||
health_check_timeout_ms: z.number().int().min(100).max(3e4).optional(),
|
||||
health_check_verify_tls: z.boolean().optional(),
|
||||
health_check_provider: healthCheckProviderSchema.optional()
|
||||
health_check_provider: healthCheckProviderSchema.optional(),
|
||||
health_check_providers: healthCheckProvidersSchema.optional(),
|
||||
health_check_aggregate: healthCheckAggregateSchema.optional()
|
||||
};
|
||||
var healthCheckConfigSchema = z.object(healthCheckConfigFields);
|
||||
var serviceDomainInputSchema = z.object({
|
||||
@@ -727,7 +833,10 @@ var appSettingsPatchSchema = z3.object({
|
||||
healthLatencyWarnMs: z3.number().int().min(50).max(6e4).optional(),
|
||||
healthSuccessRecoveries: z3.number().int().min(1).max(20).optional(),
|
||||
healthWorkerUrl: z3.string().url().or(z3.literal("")).optional(),
|
||||
healthWorkerToken: z3.string().optional()
|
||||
healthWorkerToken: z3.string().optional(),
|
||||
globalpingToken: z3.string().optional(),
|
||||
globalpingLocations: z3.string().trim().max(200).optional(),
|
||||
globalpingLimit: z3.number().int().min(1).max(10).optional()
|
||||
}).superRefine((data, ctx) => {
|
||||
if (data.healthDegradedFailures != null && data.healthDownFailures != null && data.healthDownFailures < data.healthDegradedFailures) {
|
||||
ctx.addIssue({
|
||||
@@ -829,6 +938,8 @@ export {
|
||||
CERT_OK,
|
||||
CERT_UNKNOWN,
|
||||
CERT_WARNING,
|
||||
HEALTH_CHECK_AGGREGATES,
|
||||
HEALTH_CHECK_PROVIDERS,
|
||||
HEALTH_KV_CURSOR_KEY,
|
||||
HEALTH_KV_RESULTS_KEY,
|
||||
HEALTH_KV_TARGETS_KEY,
|
||||
@@ -836,12 +947,14 @@ export {
|
||||
HEALTH_PROBE_CONCURRENCY,
|
||||
HEALTH_PROBE_KV_TITLE,
|
||||
HEALTH_PROBE_SCRIPT_NAME,
|
||||
HEALTH_STATUS_PROVIDERS,
|
||||
SYNC_CONFLICT,
|
||||
SYNC_ERROR,
|
||||
SYNC_PENDING_DELETE,
|
||||
SYNC_PENDING_PUSH,
|
||||
SYNC_SYNCED,
|
||||
ValidationError,
|
||||
aggregateHealthOk,
|
||||
appSettingsPatchSchema,
|
||||
appSwitcherConfigSchema,
|
||||
appSwitcherEntrySchema,
|
||||
@@ -860,6 +973,7 @@ export {
|
||||
cfdmSyncBindingsBodySchema,
|
||||
changeDomainSchema,
|
||||
changeIpSchema,
|
||||
clampGlobalpingLimit,
|
||||
createDnsRecordSchema,
|
||||
createDomainMonitorSchema,
|
||||
createDomainSchema,
|
||||
@@ -871,6 +985,7 @@ export {
|
||||
createServiceSchema,
|
||||
createServiceWithConfigSchema,
|
||||
createSubdomainSchema,
|
||||
derivePrimaryProvider,
|
||||
dnsNameToSubdomainLabel,
|
||||
dnsRecordNamesMatch,
|
||||
dnsRecordSchema,
|
||||
@@ -883,11 +998,14 @@ export {
|
||||
fqdnToDisplay,
|
||||
groupSchema,
|
||||
groupWithStatsSchema,
|
||||
healthCheckAggregateSchema,
|
||||
healthCheckConfigSchema,
|
||||
healthCheckProviderSchema,
|
||||
healthCheckProvidersSchema,
|
||||
healthCheckScopeSchema,
|
||||
healthCheckTypeSchema,
|
||||
healthProbeLogSchema,
|
||||
healthStatusProviderSchema,
|
||||
healthStatusQuerySchema,
|
||||
ingestAuditEventSchema,
|
||||
ipHealthStateSchema,
|
||||
@@ -898,10 +1016,16 @@ export {
|
||||
loginSchema,
|
||||
nodeHealthStateSchema,
|
||||
normalizeDnsRecordName,
|
||||
normalizeProbeProvider,
|
||||
normalizeStatusProvider,
|
||||
notificationLogSchema,
|
||||
originHealthCheckSchema,
|
||||
parseFqdn,
|
||||
parseGlobalpingLocations,
|
||||
parseHealthAggregate,
|
||||
parseHealthProviders,
|
||||
reorderServicesSchema,
|
||||
serializeHealthProviders,
|
||||
serviceBindingSchema,
|
||||
serviceDomainBindingSchema,
|
||||
serviceGroupSchema,
|
||||
@@ -915,8 +1039,11 @@ export {
|
||||
shouldMonitorService,
|
||||
subdomainLabelToFqdn,
|
||||
subdomainSchema,
|
||||
targetHasProvider,
|
||||
targetProviders,
|
||||
toggleEnabledSchema,
|
||||
toggleServiceIpSchema,
|
||||
uniqueHealthProviders,
|
||||
updateDomainGroupSchema,
|
||||
updateDomainSchema,
|
||||
updateServiceConfigSchema,
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
export const HEALTH_CHECK_PROVIDERS = [
|
||||
"local",
|
||||
"cloudflare",
|
||||
"globalping",
|
||||
] as const;
|
||||
|
||||
export type HealthCheckProvider = (typeof HEALTH_CHECK_PROVIDERS)[number];
|
||||
|
||||
export const HEALTH_STATUS_PROVIDERS = [
|
||||
...HEALTH_CHECK_PROVIDERS,
|
||||
"aggregate",
|
||||
] as const;
|
||||
|
||||
export type HealthStatusProvider = (typeof HEALTH_STATUS_PROVIDERS)[number];
|
||||
|
||||
export const HEALTH_CHECK_AGGREGATES = ["any", "all", "majority"] as const;
|
||||
|
||||
export type HealthCheckAggregate = (typeof HEALTH_CHECK_AGGREGATES)[number];
|
||||
|
||||
const PROVIDER_SET = new Set<string>(HEALTH_CHECK_PROVIDERS);
|
||||
const STATUS_SET = new Set<string>(HEALTH_STATUS_PROVIDERS);
|
||||
const AGGREGATE_SET = new Set<string>(HEALTH_CHECK_AGGREGATES);
|
||||
|
||||
export function normalizeProbeProvider(value: unknown): HealthCheckProvider {
|
||||
return value === "cloudflare" || value === "globalping" || value === "local"
|
||||
? value
|
||||
: "local";
|
||||
}
|
||||
|
||||
export function normalizeStatusProvider(value: unknown): HealthStatusProvider {
|
||||
if (typeof value === "string" && STATUS_SET.has(value)) {
|
||||
return value as HealthStatusProvider;
|
||||
}
|
||||
return "local";
|
||||
}
|
||||
|
||||
export function uniqueHealthProviders(
|
||||
values: readonly unknown[],
|
||||
): HealthCheckProvider[] {
|
||||
const out: HealthCheckProvider[] = [];
|
||||
for (const value of values) {
|
||||
if (!PROVIDER_SET.has(String(value))) continue;
|
||||
const next = value as HealthCheckProvider;
|
||||
if (!out.includes(next)) out.push(next);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
export function parseHealthProviders(
|
||||
json: unknown,
|
||||
fallback?: unknown,
|
||||
): HealthCheckProvider[] {
|
||||
if (Array.isArray(json)) {
|
||||
const parsed = uniqueHealthProviders(json);
|
||||
if (parsed.length > 0) return parsed;
|
||||
}
|
||||
if (typeof json === "string" && json.trim()) {
|
||||
const trimmed = json.trim();
|
||||
if (trimmed.startsWith("[")) {
|
||||
try {
|
||||
const parsed = uniqueHealthProviders(JSON.parse(trimmed) as unknown[]);
|
||||
if (parsed.length > 0) return parsed;
|
||||
} catch {
|
||||
// fall through to single-provider
|
||||
}
|
||||
}
|
||||
const one = uniqueHealthProviders(trimmed.split(","));
|
||||
if (one.length > 0) return one;
|
||||
}
|
||||
return [normalizeProbeProvider(fallback)];
|
||||
}
|
||||
|
||||
export function serializeHealthProviders(
|
||||
providers: readonly HealthCheckProvider[],
|
||||
): string {
|
||||
const unique = uniqueHealthProviders(providers);
|
||||
return JSON.stringify(unique.length > 0 ? unique : ["local"]);
|
||||
}
|
||||
|
||||
export function parseHealthAggregate(value: unknown): HealthCheckAggregate {
|
||||
if (typeof value === "string" && AGGREGATE_SET.has(value)) {
|
||||
return value as HealthCheckAggregate;
|
||||
}
|
||||
return "majority";
|
||||
}
|
||||
|
||||
export function derivePrimaryProvider(
|
||||
providers: readonly HealthCheckProvider[],
|
||||
): HealthCheckProvider {
|
||||
return uniqueHealthProviders(providers)[0] ?? "local";
|
||||
}
|
||||
|
||||
export function targetProviders(target: {
|
||||
providers?: readonly HealthCheckProvider[] | null;
|
||||
provider?: HealthCheckProvider | null;
|
||||
}): HealthCheckProvider[] {
|
||||
if (target.providers && target.providers.length > 0) {
|
||||
return uniqueHealthProviders(target.providers);
|
||||
}
|
||||
return [normalizeProbeProvider(target.provider)];
|
||||
}
|
||||
|
||||
export function targetHasProvider(
|
||||
target: {
|
||||
providers?: readonly HealthCheckProvider[] | null;
|
||||
provider?: HealthCheckProvider | null;
|
||||
},
|
||||
provider: HealthCheckProvider,
|
||||
): boolean {
|
||||
return targetProviders(target).includes(provider);
|
||||
}
|
||||
|
||||
/**
|
||||
* any — Down if at least one source is Down (ok only if all ok).
|
||||
* all — Down only if every source is Down (ok if any ok).
|
||||
* majority — Down if a strict majority of sources are Down (2 → both, 3 → ≥2).
|
||||
*/
|
||||
export function aggregateHealthOk(
|
||||
oks: readonly boolean[],
|
||||
policy: HealthCheckAggregate,
|
||||
): boolean {
|
||||
const n = oks.length;
|
||||
if (n === 0) return false;
|
||||
const down = oks.filter((ok) => !ok).length;
|
||||
if (policy === "any") return down === 0;
|
||||
if (policy === "all") return down < n;
|
||||
return down < Math.floor(n / 2) + 1;
|
||||
}
|
||||
|
||||
export function clampGlobalpingLimit(value: unknown, fallback = 3): number {
|
||||
const n = typeof value === "number" ? value : Number(value);
|
||||
if (!Number.isFinite(n)) return fallback;
|
||||
return Math.min(10, Math.max(1, Math.trunc(n)));
|
||||
}
|
||||
|
||||
export function parseGlobalpingLocations(value: unknown): string[] {
|
||||
const raw = typeof value === "string" ? value : "";
|
||||
const parts = raw
|
||||
.split(",")
|
||||
.map((part) => part.trim())
|
||||
.filter(Boolean);
|
||||
return parts.length > 0 ? parts : ["World"];
|
||||
}
|
||||
@@ -6,6 +6,7 @@ export * from "./schemas.js";
|
||||
export * from "./app-switcher.js";
|
||||
export * from "./integration-vps-tracker.js";
|
||||
export * from "./health-probe-mailbox.js";
|
||||
export * from "./health-providers.js";
|
||||
export * from "./audit.js";
|
||||
export type {
|
||||
CfZone,
|
||||
@@ -23,7 +24,6 @@ export type {
|
||||
HealthCheckType,
|
||||
IpHealthState,
|
||||
NodeHealthState,
|
||||
HealthCheckProvider,
|
||||
HealthCheckScope,
|
||||
IpHealthStatus,
|
||||
HealthCheckTarget,
|
||||
|
||||
@@ -37,6 +37,9 @@ export const appSettingsPatchSchema = z.object({
|
||||
healthSuccessRecoveries: z.number().int().min(1).max(20).optional(),
|
||||
healthWorkerUrl: z.string().url().or(z.literal("")).optional(),
|
||||
healthWorkerToken: z.string().optional(),
|
||||
globalpingToken: z.string().optional(),
|
||||
globalpingLocations: z.string().trim().max(200).optional(),
|
||||
globalpingLimit: z.number().int().min(1).max(10).optional(),
|
||||
}).superRefine((data, ctx) => {
|
||||
if (
|
||||
data.healthDegradedFailures != null &&
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
import { z } from 'zod'
|
||||
import {
|
||||
HEALTH_CHECK_AGGREGATES,
|
||||
HEALTH_CHECK_PROVIDERS,
|
||||
HEALTH_STATUS_PROVIDERS,
|
||||
uniqueHealthProviders,
|
||||
} from './health-providers.js'
|
||||
|
||||
export const certMonitoringSchema = z.enum(['auto', 'required', 'skipped'])
|
||||
|
||||
@@ -29,8 +35,19 @@ export const nodeHealthStateSchema = z.enum([
|
||||
])
|
||||
export type NodeHealthState = z.infer<typeof nodeHealthStateSchema>
|
||||
|
||||
export const healthCheckProviderSchema = z.enum(['local', 'cloudflare'])
|
||||
export type HealthCheckProvider = z.infer<typeof healthCheckProviderSchema>
|
||||
export const healthCheckProviderSchema = z.enum(HEALTH_CHECK_PROVIDERS)
|
||||
|
||||
export const healthStatusProviderSchema = z.enum(HEALTH_STATUS_PROVIDERS)
|
||||
|
||||
export const healthCheckAggregateSchema = z.enum(HEALTH_CHECK_AGGREGATES)
|
||||
|
||||
export const healthCheckProvidersSchema = z
|
||||
.array(healthCheckProviderSchema)
|
||||
.min(1)
|
||||
.transform((arr) => {
|
||||
const unique = uniqueHealthProviders(arr)
|
||||
return unique.length > 0 ? unique : (['local'] as const)
|
||||
})
|
||||
|
||||
export const healthCheckScopeSchema = z.enum(['binding', 'group'])
|
||||
export type HealthCheckScope = z.infer<typeof healthCheckScopeSchema>
|
||||
@@ -46,7 +63,7 @@ export const ipHealthStatusSchema = z.object({
|
||||
last_checked_at: z.string().nullable(),
|
||||
last_error: z.string().nullable(),
|
||||
colo: z.string().nullable().optional(),
|
||||
provider: healthCheckProviderSchema.optional(),
|
||||
provider: healthStatusProviderSchema.optional(),
|
||||
})
|
||||
|
||||
export type IpHealthStatus = z.infer<typeof ipHealthStatusSchema>
|
||||
@@ -57,7 +74,7 @@ export const serviceIpHealthSchema = z.object({
|
||||
latency_ms: z.number().nullable(),
|
||||
last_checked_at: z.string().nullable().optional(),
|
||||
last_error: z.string().nullable().optional(),
|
||||
provider: healthCheckProviderSchema.optional(),
|
||||
provider: healthStatusProviderSchema.optional(),
|
||||
colo: z.string().nullable().optional(),
|
||||
})
|
||||
|
||||
@@ -116,6 +133,8 @@ export const serviceGroupSchema = z.object({
|
||||
health_check_timeout_ms: z.number().default(3000),
|
||||
health_check_verify_tls: z.coerce.boolean().default(false),
|
||||
health_check_provider: healthCheckProviderSchema.catch('local'),
|
||||
health_check_providers: healthCheckProvidersSchema.catch(['local']),
|
||||
health_check_aggregate: healthCheckAggregateSchema.catch('majority'),
|
||||
created_at: z.string(),
|
||||
updated_at: z.string(),
|
||||
})
|
||||
@@ -157,6 +176,8 @@ export const serviceDomainBindingSchema = z
|
||||
health_check_timeout_ms: z.number().default(3000),
|
||||
health_check_verify_tls: z.coerce.boolean().default(false),
|
||||
health_check_provider: healthCheckProviderSchema.catch('local'),
|
||||
health_check_providers: healthCheckProvidersSchema.catch(['local']),
|
||||
health_check_aggregate: healthCheckAggregateSchema.catch('majority'),
|
||||
sync_status: z.string().nullable().default(null),
|
||||
})
|
||||
.transform((binding) => ({
|
||||
@@ -329,6 +350,8 @@ const healthCheckConfigFields = {
|
||||
health_check_timeout_ms: z.number().int().min(100).max(30000).optional(),
|
||||
health_check_verify_tls: z.boolean().optional(),
|
||||
health_check_provider: healthCheckProviderSchema.optional(),
|
||||
health_check_providers: healthCheckProvidersSchema.optional(),
|
||||
health_check_aggregate: healthCheckAggregateSchema.optional(),
|
||||
}
|
||||
|
||||
export const healthCheckConfigSchema = z.object(healthCheckConfigFields)
|
||||
|
||||
@@ -1,3 +1,15 @@
|
||||
import type {
|
||||
HealthCheckProvider,
|
||||
HealthCheckAggregate,
|
||||
HealthStatusProvider,
|
||||
} from "./health-providers.js";
|
||||
|
||||
export type {
|
||||
HealthCheckProvider,
|
||||
HealthCheckAggregate,
|
||||
HealthStatusProvider,
|
||||
} from "./health-providers.js";
|
||||
|
||||
export interface Group {
|
||||
id: number;
|
||||
name: string;
|
||||
@@ -23,6 +35,8 @@ export interface ServiceGroup {
|
||||
health_check_timeout_ms: number;
|
||||
health_check_verify_tls: boolean;
|
||||
health_check_provider: HealthCheckProvider;
|
||||
health_check_providers: HealthCheckProvider[];
|
||||
health_check_aggregate: HealthCheckAggregate;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
@@ -123,6 +137,8 @@ export interface ServiceBinding {
|
||||
health_check_timeout_ms: number;
|
||||
health_check_verify_tls: boolean;
|
||||
health_check_provider: HealthCheckProvider;
|
||||
health_check_providers: HealthCheckProvider[];
|
||||
health_check_aggregate: HealthCheckAggregate;
|
||||
routing_strategy: LbMode;
|
||||
operation_version: number;
|
||||
created_at: string;
|
||||
@@ -155,6 +171,8 @@ export interface ServiceBindingView {
|
||||
health_check_timeout_ms: number;
|
||||
health_check_verify_tls: boolean;
|
||||
health_check_provider: HealthCheckProvider;
|
||||
health_check_providers: HealthCheckProvider[];
|
||||
health_check_aggregate: HealthCheckAggregate;
|
||||
sync_status: string | null;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
@@ -181,6 +199,8 @@ export interface ServiceDomainBindingView {
|
||||
health_check_timeout_ms: number;
|
||||
health_check_verify_tls: boolean;
|
||||
health_check_provider: HealthCheckProvider;
|
||||
health_check_providers: HealthCheckProvider[];
|
||||
health_check_aggregate: HealthCheckAggregate;
|
||||
sync_status: string | null;
|
||||
}
|
||||
|
||||
@@ -284,8 +304,6 @@ export type NodeHealthState =
|
||||
| "unhealthy"
|
||||
| "disabled";
|
||||
|
||||
export type HealthCheckProvider = "local" | "cloudflare";
|
||||
|
||||
export type HealthCheckScope = "binding" | "group";
|
||||
|
||||
export interface IpHealthStatus {
|
||||
@@ -299,7 +317,7 @@ export interface IpHealthStatus {
|
||||
last_checked_at: string | null;
|
||||
last_error: string | null;
|
||||
colo?: string | null;
|
||||
provider?: HealthCheckProvider;
|
||||
provider?: HealthStatusProvider;
|
||||
}
|
||||
|
||||
export interface ServiceIpHealth {
|
||||
@@ -308,7 +326,7 @@ export interface ServiceIpHealth {
|
||||
latency_ms: number | null;
|
||||
last_checked_at?: string | null;
|
||||
last_error?: string | null;
|
||||
provider?: HealthCheckProvider;
|
||||
provider?: HealthStatusProvider;
|
||||
colo?: string | null;
|
||||
}
|
||||
|
||||
@@ -394,4 +412,6 @@ export interface HealthCheckTarget {
|
||||
timeout_ms: number;
|
||||
verify_tls: boolean;
|
||||
provider: HealthCheckProvider;
|
||||
providers?: HealthCheckProvider[];
|
||||
aggregate?: HealthCheckAggregate;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import { Toggle as TogglePrimitive } from "@base-ui/react/toggle"
|
||||
import { ToggleGroup as ToggleGroupPrimitive } from "@base-ui/react/toggle-group"
|
||||
import { type VariantProps } from "class-variance-authority"
|
||||
|
||||
import { cn } from "@cfdm/ui/lib/utils"
|
||||
import { toggleVariants } from "@cfdm/ui/components/toggle"
|
||||
|
||||
const ToggleGroupContext = React.createContext<
|
||||
VariantProps<typeof toggleVariants> & {
|
||||
spacing?: number
|
||||
orientation?: "horizontal" | "vertical"
|
||||
}
|
||||
>({
|
||||
size: "default",
|
||||
variant: "default",
|
||||
spacing: 2,
|
||||
orientation: "horizontal",
|
||||
})
|
||||
|
||||
function ToggleGroup({
|
||||
className,
|
||||
variant,
|
||||
size,
|
||||
spacing = 2,
|
||||
orientation = "horizontal",
|
||||
children,
|
||||
...props
|
||||
}: ToggleGroupPrimitive.Props &
|
||||
VariantProps<typeof toggleVariants> & {
|
||||
spacing?: number
|
||||
orientation?: "horizontal" | "vertical"
|
||||
}) {
|
||||
return (
|
||||
<ToggleGroupPrimitive
|
||||
data-slot="toggle-group"
|
||||
data-variant={variant}
|
||||
data-size={size}
|
||||
data-spacing={spacing}
|
||||
data-orientation={orientation}
|
||||
style={{ "--gap": spacing } as React.CSSProperties}
|
||||
className={cn(
|
||||
"group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-lg data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-vertical:flex-col data-vertical:items-stretch",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<ToggleGroupContext.Provider
|
||||
value={{ variant, size, spacing, orientation }}
|
||||
>
|
||||
{children}
|
||||
</ToggleGroupContext.Provider>
|
||||
</ToggleGroupPrimitive>
|
||||
)
|
||||
}
|
||||
|
||||
function ToggleGroupItem({
|
||||
className,
|
||||
children,
|
||||
variant = "default",
|
||||
size = "default",
|
||||
...props
|
||||
}: TogglePrimitive.Props & VariantProps<typeof toggleVariants>) {
|
||||
const context = React.useContext(ToggleGroupContext)
|
||||
|
||||
return (
|
||||
<TogglePrimitive
|
||||
data-slot="toggle-group-item"
|
||||
data-variant={context.variant || variant}
|
||||
data-size={context.size || size}
|
||||
data-spacing={context.spacing}
|
||||
className={cn(
|
||||
"shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-lg group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-lg group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-lg group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-lg group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t",
|
||||
toggleVariants({
|
||||
variant: context.variant || variant,
|
||||
size: context.size || size,
|
||||
}),
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</TogglePrimitive>
|
||||
)
|
||||
}
|
||||
|
||||
export { ToggleGroup, ToggleGroupItem }
|
||||
@@ -0,0 +1,43 @@
|
||||
import { Toggle as TogglePrimitive } from "@base-ui/react/toggle"
|
||||
import { cva, type VariantProps } from "class-variance-authority"
|
||||
|
||||
import { cn } from "@cfdm/ui/lib/utils"
|
||||
|
||||
const toggleVariants = cva(
|
||||
"group/toggle inline-flex items-center justify-center gap-1 rounded-lg text-sm font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default: "bg-transparent",
|
||||
outline: "border border-input bg-transparent hover:bg-muted",
|
||||
},
|
||||
size: {
|
||||
default:
|
||||
"h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
||||
sm: "h-7 min-w-7 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
|
||||
lg: "h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: "default",
|
||||
size: "default",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
function Toggle({
|
||||
className,
|
||||
variant = "default",
|
||||
size = "default",
|
||||
...props
|
||||
}: TogglePrimitive.Props & VariantProps<typeof toggleVariants>) {
|
||||
return (
|
||||
<TogglePrimitive
|
||||
data-slot="toggle"
|
||||
className={cn(toggleVariants({ variant, size, className }))}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export { Toggle, toggleVariants }
|
||||
Reference in New Issue
Block a user