Enhance CDN Manager: Add Cloudflare API token support, update documentation, and introduce new routes for managing nodes, aliases, and topology. Improve UI components and status badges for better user experience.
quality / commitlint (push) Skipped
quality / changes (push) Successful in 5s
quality / docker-check (push) Skipped
CD / update-wiki (push) Successful in 6s
quality / web (push) Successful in 53s
quality / api (push) Successful in 49s
CD / quality (push) Successful in 1m57s
CD / publish (push) Successful in 27s

This commit is contained in:
Denozordec
2026-09-04 12:49:51 +07:00
parent d480325357
commit 8700dc2957
47 changed files with 10550 additions and 69 deletions
+423 -1
View File
@@ -66,12 +66,434 @@ type LoginResponse = {
};
declare const appSettingsPatchSchema: z.ZodObject<{
showQuickActions: z.ZodOptional<z.ZodBoolean>;
defaultTtl: z.ZodOptional<z.ZodNumber>;
namingTemplate: z.ZodOptional<z.ZodString>;
proxiedLock: z.ZodOptional<z.ZodBoolean>;
}, z.core.$strip>;
type AppSettingsPatch = z.infer<typeof appSettingsPatchSchema>;
declare const appSettingsSchema: z.ZodObject<{
id: z.ZodString;
showQuickActions: z.ZodBoolean;
defaultTtl: z.ZodNumber;
namingTemplate: z.ZodString;
proxiedLock: z.ZodBoolean;
cloudflareConfigured: z.ZodOptional<z.ZodBoolean>;
}, z.core.$strip>;
type AppSettings = z.infer<typeof appSettingsSchema>;
export { type AppSettings, type AppSettingsPatch, type AppSwitcherConfig, type AppSwitcherEntry, type JwtClaims, type LoginInput, type LoginRequest, type LoginResponse, appSettingsPatchSchema, appSettingsSchema, appSwitcherConfigSchema, appSwitcherEntrySchema, appSwitcherIconSchema, loginSchema };
declare const nodeRoleSchema: z.ZodEnum<{
hub: "hub";
gw: "gw";
edge: "edge";
ix: "ix";
}>;
type NodeRole = z.infer<typeof nodeRoleSchema>;
declare const aliasPurposeSchema: z.ZodEnum<{
custom: "custom";
ix: "ix";
geo: "geo";
backup: "backup";
admin: "admin";
}>;
type AliasPurpose = z.infer<typeof aliasPurposeSchema>;
declare const aliasModeSchema: z.ZodEnum<{
primary: "primary";
pair: "pair";
}>;
type AliasMode = z.infer<typeof aliasModeSchema>;
declare const syncStatusSchema: z.ZodEnum<{
error: "error";
pending: "pending";
ok: "ok";
drift: "drift";
missing: "missing";
}>;
type SyncStatus = z.infer<typeof syncStatusSchema>;
declare const addressFamilySchema: z.ZodEnum<{
v4: "v4";
v6: "v6";
}>;
declare const cfZoneSchema: z.ZodObject<{
id: z.ZodString;
name: z.ZodString;
status: z.ZodOptional<z.ZodString>;
}, z.core.$strip>;
type CfZone = z.infer<typeof cfZoneSchema>;
declare const cfDnsRecordSchema: z.ZodObject<{
id: z.ZodOptional<z.ZodString>;
type: z.ZodString;
name: z.ZodString;
content: z.ZodString;
ttl: z.ZodNumber;
proxied: z.ZodOptional<z.ZodBoolean>;
priority: z.ZodOptional<z.ZodNumber>;
}, z.core.$strip>;
type CfDnsRecord = z.infer<typeof cfDnsRecordSchema>;
declare const createDnsRecordPayloadSchema: z.ZodObject<{
type: z.ZodString;
name: z.ZodString;
content: z.ZodString;
ttl: z.ZodNumber;
proxied: z.ZodOptional<z.ZodBoolean>;
priority: z.ZodOptional<z.ZodNumber>;
}, z.core.$strip>;
type CreateDnsRecordPayload = z.infer<typeof createDnsRecordPayloadSchema>;
declare const patchDnsRecordPayloadSchema: z.ZodObject<{
type: z.ZodOptional<z.ZodString>;
name: z.ZodOptional<z.ZodString>;
content: z.ZodOptional<z.ZodString>;
ttl: z.ZodOptional<z.ZodNumber>;
proxied: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
priority: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
}, z.core.$strip>;
type PatchDnsRecordPayload = z.infer<typeof patchDnsRecordPayloadSchema>;
declare const locationSchema: z.ZodObject<{
id: z.ZodString;
code: z.ZodString;
name: z.ZodString;
country: z.ZodNullable<z.ZodString>;
sortOrder: z.ZodNumber;
}, z.core.$strip>;
type Location = z.infer<typeof locationSchema>;
declare const zoneSchema: z.ZodObject<{
id: z.ZodString;
cfZoneId: z.ZodNullable<z.ZodString>;
name: z.ZodString;
role: z.ZodString;
namingTemplate: z.ZodString;
defaultTtl: z.ZodNumber;
lastSyncAt: z.ZodNullable<z.ZodString>;
createdAt: z.ZodString;
updatedAt: z.ZodString;
}, z.core.$strip>;
type Zone = z.infer<typeof zoneSchema>;
declare const zoneCreateSchema: z.ZodObject<{
name: z.ZodString;
cfZoneId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
role: z.ZodDefault<z.ZodString>;
namingTemplate: z.ZodOptional<z.ZodString>;
defaultTtl: z.ZodOptional<z.ZodNumber>;
}, z.core.$strip>;
type ZoneCreate = z.infer<typeof zoneCreateSchema>;
declare const zonePatchSchema: z.ZodObject<{
name: z.ZodOptional<z.ZodString>;
cfZoneId: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
role: z.ZodOptional<z.ZodDefault<z.ZodString>>;
namingTemplate: z.ZodOptional<z.ZodOptional<z.ZodString>>;
defaultTtl: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
}, z.core.$strip>;
type ZonePatch = z.infer<typeof zonePatchSchema>;
declare const nodeAddressSchema: z.ZodObject<{
id: z.ZodString;
family: z.ZodEnum<{
v4: "v4";
v6: "v6";
}>;
ip: z.ZodString;
}, z.core.$strip>;
type NodeAddress = z.infer<typeof nodeAddressSchema>;
declare const nodeSchema: z.ZodObject<{
id: z.ZodString;
zoneId: z.ZodString;
locationId: z.ZodString;
locationCode: z.ZodOptional<z.ZodString>;
locationName: z.ZodOptional<z.ZodString>;
hostname: z.ZodString;
role: z.ZodEnum<{
hub: "hub";
gw: "gw";
edge: "edge";
ix: "ix";
}>;
indexNum: z.ZodNumber;
providerTag: z.ZodNullable<z.ZodString>;
notes: z.ZodNullable<z.ZodString>;
syncStatus: z.ZodEnum<{
error: "error";
pending: "pending";
ok: "ok";
drift: "drift";
missing: "missing";
}>;
cfARecordId: z.ZodNullable<z.ZodString>;
cfAaaaRecordId: z.ZodNullable<z.ZodString>;
lastError: z.ZodNullable<z.ZodString>;
addresses: z.ZodDefault<z.ZodArray<z.ZodObject<{
id: z.ZodString;
family: z.ZodEnum<{
v4: "v4";
v6: "v6";
}>;
ip: z.ZodString;
}, z.core.$strip>>>;
aliasCount: z.ZodOptional<z.ZodNumber>;
createdAt: z.ZodString;
updatedAt: z.ZodString;
}, z.core.$strip>;
type Node = z.infer<typeof nodeSchema>;
declare const nodeCreateSchema: z.ZodObject<{
zoneId: z.ZodString;
locationId: z.ZodString;
role: z.ZodEnum<{
hub: "hub";
gw: "gw";
edge: "edge";
ix: "ix";
}>;
indexNum: z.ZodDefault<z.ZodNumber>;
hostname: z.ZodOptional<z.ZodString>;
providerTag: z.ZodNullable<z.ZodOptional<z.ZodString>>;
notes: z.ZodNullable<z.ZodOptional<z.ZodString>>;
ipv4: z.ZodString;
ipv6: z.ZodNullable<z.ZodOptional<z.ZodString>>;
}, z.core.$strip>;
type NodeCreate = z.infer<typeof nodeCreateSchema>;
declare const nodePatchSchema: z.ZodObject<{
locationId: z.ZodOptional<z.ZodString>;
role: z.ZodOptional<z.ZodEnum<{
hub: "hub";
gw: "gw";
edge: "edge";
ix: "ix";
}>>;
indexNum: z.ZodOptional<z.ZodNumber>;
hostname: z.ZodOptional<z.ZodString>;
providerTag: z.ZodNullable<z.ZodOptional<z.ZodString>>;
notes: z.ZodNullable<z.ZodOptional<z.ZodString>>;
ipv4: z.ZodOptional<z.ZodString>;
ipv6: z.ZodNullable<z.ZodOptional<z.ZodString>>;
}, z.core.$strip>;
type NodePatch = z.infer<typeof nodePatchSchema>;
declare const aliasSchema: z.ZodObject<{
id: z.ZodString;
zoneId: z.ZodString;
name: z.ZodString;
purpose: z.ZodEnum<{
custom: "custom";
ix: "ix";
geo: "geo";
backup: "backup";
admin: "admin";
}>;
mode: z.ZodEnum<{
primary: "primary";
pair: "pair";
}>;
targetNodeId: z.ZodString;
targetHostname: z.ZodOptional<z.ZodString>;
syncStatus: z.ZodEnum<{
error: "error";
pending: "pending";
ok: "ok";
drift: "drift";
missing: "missing";
}>;
cfRecordId: z.ZodNullable<z.ZodString>;
lastError: z.ZodNullable<z.ZodString>;
createdAt: z.ZodString;
updatedAt: z.ZodString;
}, z.core.$strip>;
type Alias = z.infer<typeof aliasSchema>;
declare const aliasCreateSchema: z.ZodObject<{
zoneId: z.ZodString;
name: z.ZodString;
purpose: z.ZodDefault<z.ZodEnum<{
custom: "custom";
ix: "ix";
geo: "geo";
backup: "backup";
admin: "admin";
}>>;
mode: z.ZodDefault<z.ZodEnum<{
primary: "primary";
pair: "pair";
}>>;
targetNodeId: z.ZodString;
}, z.core.$strip>;
type AliasCreate = z.infer<typeof aliasCreateSchema>;
declare const aliasPatchSchema: z.ZodObject<{
name: z.ZodOptional<z.ZodString>;
purpose: z.ZodOptional<z.ZodEnum<{
custom: "custom";
ix: "ix";
geo: "geo";
backup: "backup";
admin: "admin";
}>>;
mode: z.ZodOptional<z.ZodEnum<{
primary: "primary";
pair: "pair";
}>>;
targetNodeId: z.ZodOptional<z.ZodString>;
}, z.core.$strip>;
type AliasPatch = z.infer<typeof aliasPatchSchema>;
declare const aliasRetargetSchema: z.ZodObject<{
targetNodeId: z.ZodString;
}, z.core.$strip>;
type AliasRetarget = z.infer<typeof aliasRetargetSchema>;
declare const syncDiffOpSchema: z.ZodObject<{
id: z.ZodString;
kind: z.ZodEnum<{
create: "create";
update: "update";
delete: "delete";
orphan: "orphan";
proxy_violation: "proxy_violation";
noop: "noop";
}>;
entityType: z.ZodEnum<{
orphan: "orphan";
node_a: "node_a";
node_aaaa: "node_aaaa";
alias: "alias";
}>;
entityId: z.ZodNullable<z.ZodString>;
recordName: z.ZodString;
recordType: z.ZodString;
desired: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
observed: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
detail: z.ZodOptional<z.ZodString>;
}, z.core.$strip>;
type SyncDiffOp = z.infer<typeof syncDiffOpSchema>;
declare const syncJobSchema: z.ZodObject<{
id: z.ZodString;
zoneId: z.ZodString;
status: z.ZodEnum<{
pending: "pending";
running: "running";
done: "done";
failed: "failed";
}>;
diff: z.ZodOptional<z.ZodArray<z.ZodObject<{
id: z.ZodString;
kind: z.ZodEnum<{
create: "create";
update: "update";
delete: "delete";
orphan: "orphan";
proxy_violation: "proxy_violation";
noop: "noop";
}>;
entityType: z.ZodEnum<{
orphan: "orphan";
node_a: "node_a";
node_aaaa: "node_aaaa";
alias: "alias";
}>;
entityId: z.ZodNullable<z.ZodString>;
recordName: z.ZodString;
recordType: z.ZodString;
desired: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
observed: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
detail: z.ZodOptional<z.ZodString>;
}, z.core.$strip>>>;
error: z.ZodNullable<z.ZodString>;
createdAt: z.ZodString;
finishedAt: z.ZodNullable<z.ZodString>;
}, z.core.$strip>;
type SyncJob = z.infer<typeof syncJobSchema>;
declare const syncApplySchema: z.ZodObject<{
opIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
}, z.core.$strip>;
type SyncApply = z.infer<typeof syncApplySchema>;
declare const dashboardStatsSchema: z.ZodObject<{
nodes: z.ZodNumber;
aliases: z.ZodNumber;
syncOk: z.ZodNumber;
drift: z.ZodNumber;
proxyViolations: z.ZodNumber;
orphans: z.ZodNumber;
lastSyncAt: z.ZodNullable<z.ZodString>;
nodesWithoutIp: z.ZodNumber;
brokenAliases: z.ZodNumber;
}, z.core.$strip>;
type DashboardStats = z.infer<typeof dashboardStatsSchema>;
declare const topologyNodeSchema: z.ZodObject<{
id: z.ZodString;
hostname: z.ZodString;
role: z.ZodEnum<{
hub: "hub";
gw: "gw";
edge: "edge";
ix: "ix";
}>;
locationCode: z.ZodString;
ipv4: z.ZodNullable<z.ZodString>;
syncStatus: z.ZodEnum<{
error: "error";
pending: "pending";
ok: "ok";
drift: "drift";
missing: "missing";
}>;
}, z.core.$strip>;
declare const topologyEdgeSchema: z.ZodObject<{
id: z.ZodString;
aliasName: z.ZodString;
purpose: z.ZodEnum<{
custom: "custom";
ix: "ix";
geo: "geo";
backup: "backup";
admin: "admin";
}>;
fromNodeId: z.ZodString;
toHostname: z.ZodString;
}, z.core.$strip>;
declare const topologySchema: z.ZodObject<{
nodes: z.ZodArray<z.ZodObject<{
id: z.ZodString;
hostname: z.ZodString;
role: z.ZodEnum<{
hub: "hub";
gw: "gw";
edge: "edge";
ix: "ix";
}>;
locationCode: z.ZodString;
ipv4: z.ZodNullable<z.ZodString>;
syncStatus: z.ZodEnum<{
error: "error";
pending: "pending";
ok: "ok";
drift: "drift";
missing: "missing";
}>;
}, z.core.$strip>>;
edges: z.ZodArray<z.ZodObject<{
id: z.ZodString;
aliasName: z.ZodString;
purpose: z.ZodEnum<{
custom: "custom";
ix: "ix";
geo: "geo";
backup: "backup";
admin: "admin";
}>;
fromNodeId: z.ZodString;
toHostname: z.ZodString;
}, z.core.$strip>>;
locations: z.ZodArray<z.ZodObject<{
id: z.ZodString;
code: z.ZodString;
name: z.ZodString;
country: z.ZodNullable<z.ZodString>;
sortOrder: z.ZodNumber;
}, z.core.$strip>>;
}, z.core.$strip>;
type Topology = z.infer<typeof topologySchema>;
declare const bindExportSchema: z.ZodObject<{
zoneName: z.ZodString;
content: z.ZodString;
}, z.core.$strip>;
type BindExport = z.infer<typeof bindExportSchema>;
declare const orphanIgnoreSchema: z.ZodObject<{
recordName: z.ZodString;
recordType: z.ZodString;
}, z.core.$strip>;
declare class ValidationError extends Error {
constructor(message: string);
}
export { type Alias, type AliasCreate, type AliasMode, type AliasPatch, type AliasPurpose, type AliasRetarget, type AppSettings, type AppSettingsPatch, type AppSwitcherConfig, type AppSwitcherEntry, type BindExport, type CfDnsRecord, type CfZone, type CreateDnsRecordPayload, type DashboardStats, type JwtClaims, type Location, type LoginInput, type LoginRequest, type LoginResponse, type Node, type NodeAddress, type NodeCreate, type NodePatch, type NodeRole, type PatchDnsRecordPayload, type SyncApply, type SyncDiffOp, type SyncJob, type SyncStatus, type Topology, ValidationError, type Zone, type ZoneCreate, type ZonePatch, addressFamilySchema, aliasCreateSchema, aliasModeSchema, aliasPatchSchema, aliasPurposeSchema, aliasRetargetSchema, aliasSchema, appSettingsPatchSchema, appSettingsSchema, appSwitcherConfigSchema, appSwitcherEntrySchema, appSwitcherIconSchema, bindExportSchema, cfDnsRecordSchema, cfZoneSchema, createDnsRecordPayloadSchema, dashboardStatsSchema, locationSchema, loginSchema, nodeAddressSchema, nodeCreateSchema, nodePatchSchema, nodeRoleSchema, nodeSchema, orphanIgnoreSchema, patchDnsRecordPayloadSchema, syncApplySchema, syncDiffOpSchema, syncJobSchema, syncStatusSchema, topologyEdgeSchema, topologyNodeSchema, topologySchema, zoneCreateSchema, zonePatchSchema, zoneSchema };
+263 -3
View File
@@ -29,17 +29,277 @@ var loginSchema = z2.object({
password: z2.string().min(1)
});
var appSettingsPatchSchema = z2.object({
showQuickActions: z2.boolean().optional()
showQuickActions: z2.boolean().optional(),
defaultTtl: z2.number().int().min(60).max(86400).optional(),
namingTemplate: z2.string().min(1).optional(),
proxiedLock: z2.boolean().optional()
});
var appSettingsSchema = z2.object({
id: z2.string(),
showQuickActions: z2.boolean()
showQuickActions: z2.boolean(),
defaultTtl: z2.number(),
namingTemplate: z2.string(),
proxiedLock: z2.boolean(),
cloudflareConfigured: z2.boolean().optional()
});
// src/fleet.ts
import { z as z3 } from "zod";
var nodeRoleSchema = z3.enum(["hub", "gw", "edge", "ix"]);
var aliasPurposeSchema = z3.enum([
"geo",
"ix",
"backup",
"admin",
"custom"
]);
var aliasModeSchema = z3.enum(["primary", "pair"]);
var syncStatusSchema = z3.enum([
"pending",
"ok",
"drift",
"missing",
"error"
]);
var addressFamilySchema = z3.enum(["v4", "v6"]);
var cfZoneSchema = z3.object({
id: z3.string(),
name: z3.string(),
status: z3.string().optional()
});
var cfDnsRecordSchema = z3.object({
id: z3.string().optional(),
type: z3.string(),
name: z3.string(),
content: z3.string(),
ttl: z3.number(),
proxied: z3.boolean().optional(),
priority: z3.number().optional()
});
var createDnsRecordPayloadSchema = z3.object({
type: z3.string(),
name: z3.string(),
content: z3.string(),
ttl: z3.number(),
proxied: z3.boolean().optional(),
priority: z3.number().optional()
});
var patchDnsRecordPayloadSchema = createDnsRecordPayloadSchema.partial();
var locationSchema = z3.object({
id: z3.string(),
code: z3.string(),
name: z3.string(),
country: z3.string().nullable(),
sortOrder: z3.number()
});
var zoneSchema = z3.object({
id: z3.string(),
cfZoneId: z3.string().nullable(),
name: z3.string(),
role: z3.string(),
namingTemplate: z3.string(),
defaultTtl: z3.number(),
lastSyncAt: z3.string().nullable(),
createdAt: z3.string(),
updatedAt: z3.string()
});
var zoneCreateSchema = z3.object({
name: z3.string().min(1),
cfZoneId: z3.string().optional().nullable(),
role: z3.string().default("routing"),
namingTemplate: z3.string().optional(),
defaultTtl: z3.number().int().min(60).max(86400).optional()
});
var zonePatchSchema = zoneCreateSchema.partial();
var nodeAddressSchema = z3.object({
id: z3.string(),
family: addressFamilySchema,
ip: z3.string()
});
var nodeSchema = z3.object({
id: z3.string(),
zoneId: z3.string(),
locationId: z3.string(),
locationCode: z3.string().optional(),
locationName: z3.string().optional(),
hostname: z3.string(),
role: nodeRoleSchema,
indexNum: z3.number(),
providerTag: z3.string().nullable(),
notes: z3.string().nullable(),
syncStatus: syncStatusSchema,
cfARecordId: z3.string().nullable(),
cfAaaaRecordId: z3.string().nullable(),
lastError: z3.string().nullable(),
addresses: z3.array(nodeAddressSchema).default([]),
aliasCount: z3.number().optional(),
createdAt: z3.string(),
updatedAt: z3.string()
});
var nodeCreateSchema = z3.object({
zoneId: z3.string().min(1),
locationId: z3.string().min(1),
role: nodeRoleSchema,
indexNum: z3.number().int().min(1).max(99).default(1),
hostname: z3.string().min(1).optional(),
providerTag: z3.string().optional().nullable(),
notes: z3.string().optional().nullable(),
ipv4: z3.string().min(1),
ipv6: z3.string().optional().nullable()
});
var nodePatchSchema = z3.object({
locationId: z3.string().optional(),
role: nodeRoleSchema.optional(),
indexNum: z3.number().int().min(1).max(99).optional(),
hostname: z3.string().min(1).optional(),
providerTag: z3.string().optional().nullable(),
notes: z3.string().optional().nullable(),
ipv4: z3.string().min(1).optional(),
ipv6: z3.string().optional().nullable()
});
var aliasSchema = z3.object({
id: z3.string(),
zoneId: z3.string(),
name: z3.string(),
purpose: aliasPurposeSchema,
mode: aliasModeSchema,
targetNodeId: z3.string(),
targetHostname: z3.string().optional(),
syncStatus: syncStatusSchema,
cfRecordId: z3.string().nullable(),
lastError: z3.string().nullable(),
createdAt: z3.string(),
updatedAt: z3.string()
});
var aliasCreateSchema = z3.object({
zoneId: z3.string().min(1),
name: z3.string().min(1),
purpose: aliasPurposeSchema.default("geo"),
mode: aliasModeSchema.default("primary"),
targetNodeId: z3.string().min(1)
});
var aliasPatchSchema = z3.object({
name: z3.string().min(1).optional(),
purpose: aliasPurposeSchema.optional(),
mode: aliasModeSchema.optional(),
targetNodeId: z3.string().min(1).optional()
});
var aliasRetargetSchema = z3.object({
targetNodeId: z3.string().min(1)
});
var syncDiffOpSchema = z3.object({
id: z3.string(),
kind: z3.enum([
"create",
"update",
"delete",
"orphan",
"proxy_violation",
"noop"
]),
entityType: z3.enum(["node_a", "node_aaaa", "alias", "orphan"]),
entityId: z3.string().nullable(),
recordName: z3.string(),
recordType: z3.string(),
desired: z3.record(z3.string(), z3.unknown()).nullable(),
observed: z3.record(z3.string(), z3.unknown()).nullable(),
detail: z3.string().optional()
});
var syncJobSchema = z3.object({
id: z3.string(),
zoneId: z3.string(),
status: z3.enum(["pending", "running", "done", "failed"]),
diff: z3.array(syncDiffOpSchema).optional(),
error: z3.string().nullable(),
createdAt: z3.string(),
finishedAt: z3.string().nullable()
});
var syncApplySchema = z3.object({
opIds: z3.array(z3.string()).optional()
});
var dashboardStatsSchema = z3.object({
nodes: z3.number(),
aliases: z3.number(),
syncOk: z3.number(),
drift: z3.number(),
proxyViolations: z3.number(),
orphans: z3.number(),
lastSyncAt: z3.string().nullable(),
nodesWithoutIp: z3.number(),
brokenAliases: z3.number()
});
var topologyNodeSchema = z3.object({
id: z3.string(),
hostname: z3.string(),
role: nodeRoleSchema,
locationCode: z3.string(),
ipv4: z3.string().nullable(),
syncStatus: syncStatusSchema
});
var topologyEdgeSchema = z3.object({
id: z3.string(),
aliasName: z3.string(),
purpose: aliasPurposeSchema,
fromNodeId: z3.string(),
toHostname: z3.string()
});
var topologySchema = z3.object({
nodes: z3.array(topologyNodeSchema),
edges: z3.array(topologyEdgeSchema),
locations: z3.array(locationSchema)
});
var bindExportSchema = z3.object({
zoneName: z3.string(),
content: z3.string()
});
var orphanIgnoreSchema = z3.object({
recordName: z3.string().min(1),
recordType: z3.string().min(1)
});
// src/index.ts
var ValidationError = class extends Error {
constructor(message) {
super(message);
this.name = "ValidationError";
}
};
export {
ValidationError,
addressFamilySchema,
aliasCreateSchema,
aliasModeSchema,
aliasPatchSchema,
aliasPurposeSchema,
aliasRetargetSchema,
aliasSchema,
appSettingsPatchSchema,
appSettingsSchema,
appSwitcherConfigSchema,
appSwitcherEntrySchema,
appSwitcherIconSchema,
loginSchema
bindExportSchema,
cfDnsRecordSchema,
cfZoneSchema,
createDnsRecordPayloadSchema,
dashboardStatsSchema,
locationSchema,
loginSchema,
nodeAddressSchema,
nodeCreateSchema,
nodePatchSchema,
nodeRoleSchema,
nodeSchema,
orphanIgnoreSchema,
patchDnsRecordPayloadSchema,
syncApplySchema,
syncDiffOpSchema,
syncJobSchema,
syncStatusSchema,
topologyEdgeSchema,
topologyNodeSchema,
topologySchema,
zoneCreateSchema,
zonePatchSchema,
zoneSchema
};
+268
View File
@@ -0,0 +1,268 @@
import { z } from "zod";
export const nodeRoleSchema = z.enum(["hub", "gw", "edge", "ix"]);
export type NodeRole = z.infer<typeof nodeRoleSchema>;
export const aliasPurposeSchema = z.enum([
"geo",
"ix",
"backup",
"admin",
"custom",
]);
export type AliasPurpose = z.infer<typeof aliasPurposeSchema>;
export const aliasModeSchema = z.enum(["primary", "pair"]);
export type AliasMode = z.infer<typeof aliasModeSchema>;
export const syncStatusSchema = z.enum([
"pending",
"ok",
"drift",
"missing",
"error",
]);
export type SyncStatus = z.infer<typeof syncStatusSchema>;
export const addressFamilySchema = z.enum(["v4", "v6"]);
export const cfZoneSchema = z.object({
id: z.string(),
name: z.string(),
status: z.string().optional(),
});
export type CfZone = z.infer<typeof cfZoneSchema>;
export const cfDnsRecordSchema = z.object({
id: z.string().optional(),
type: z.string(),
name: z.string(),
content: z.string(),
ttl: z.number(),
proxied: z.boolean().optional(),
priority: z.number().optional(),
});
export type CfDnsRecord = z.infer<typeof cfDnsRecordSchema>;
export const createDnsRecordPayloadSchema = z.object({
type: z.string(),
name: z.string(),
content: z.string(),
ttl: z.number(),
proxied: z.boolean().optional(),
priority: z.number().optional(),
});
export type CreateDnsRecordPayload = z.infer<typeof createDnsRecordPayloadSchema>;
export const patchDnsRecordPayloadSchema = createDnsRecordPayloadSchema.partial();
export type PatchDnsRecordPayload = z.infer<typeof patchDnsRecordPayloadSchema>;
export const locationSchema = z.object({
id: z.string(),
code: z.string(),
name: z.string(),
country: z.string().nullable(),
sortOrder: z.number(),
});
export type Location = z.infer<typeof locationSchema>;
export const zoneSchema = z.object({
id: z.string(),
cfZoneId: z.string().nullable(),
name: z.string(),
role: z.string(),
namingTemplate: z.string(),
defaultTtl: z.number(),
lastSyncAt: z.string().nullable(),
createdAt: z.string(),
updatedAt: z.string(),
});
export type Zone = z.infer<typeof zoneSchema>;
export const zoneCreateSchema = z.object({
name: z.string().min(1),
cfZoneId: z.string().optional().nullable(),
role: z.string().default("routing"),
namingTemplate: z.string().optional(),
defaultTtl: z.number().int().min(60).max(86400).optional(),
});
export type ZoneCreate = z.infer<typeof zoneCreateSchema>;
export const zonePatchSchema = zoneCreateSchema.partial();
export type ZonePatch = z.infer<typeof zonePatchSchema>;
export const nodeAddressSchema = z.object({
id: z.string(),
family: addressFamilySchema,
ip: z.string(),
});
export type NodeAddress = z.infer<typeof nodeAddressSchema>;
export const nodeSchema = z.object({
id: z.string(),
zoneId: z.string(),
locationId: z.string(),
locationCode: z.string().optional(),
locationName: z.string().optional(),
hostname: z.string(),
role: nodeRoleSchema,
indexNum: z.number(),
providerTag: z.string().nullable(),
notes: z.string().nullable(),
syncStatus: syncStatusSchema,
cfARecordId: z.string().nullable(),
cfAaaaRecordId: z.string().nullable(),
lastError: z.string().nullable(),
addresses: z.array(nodeAddressSchema).default([]),
aliasCount: z.number().optional(),
createdAt: z.string(),
updatedAt: z.string(),
});
export type Node = z.infer<typeof nodeSchema>;
export const nodeCreateSchema = z.object({
zoneId: z.string().min(1),
locationId: z.string().min(1),
role: nodeRoleSchema,
indexNum: z.number().int().min(1).max(99).default(1),
hostname: z.string().min(1).optional(),
providerTag: z.string().optional().nullable(),
notes: z.string().optional().nullable(),
ipv4: z.string().min(1),
ipv6: z.string().optional().nullable(),
});
export type NodeCreate = z.infer<typeof nodeCreateSchema>;
export const nodePatchSchema = z.object({
locationId: z.string().optional(),
role: nodeRoleSchema.optional(),
indexNum: z.number().int().min(1).max(99).optional(),
hostname: z.string().min(1).optional(),
providerTag: z.string().optional().nullable(),
notes: z.string().optional().nullable(),
ipv4: z.string().min(1).optional(),
ipv6: z.string().optional().nullable(),
});
export type NodePatch = z.infer<typeof nodePatchSchema>;
export const aliasSchema = z.object({
id: z.string(),
zoneId: z.string(),
name: z.string(),
purpose: aliasPurposeSchema,
mode: aliasModeSchema,
targetNodeId: z.string(),
targetHostname: z.string().optional(),
syncStatus: syncStatusSchema,
cfRecordId: z.string().nullable(),
lastError: z.string().nullable(),
createdAt: z.string(),
updatedAt: z.string(),
});
export type Alias = z.infer<typeof aliasSchema>;
export const aliasCreateSchema = z.object({
zoneId: z.string().min(1),
name: z.string().min(1),
purpose: aliasPurposeSchema.default("geo"),
mode: aliasModeSchema.default("primary"),
targetNodeId: z.string().min(1),
});
export type AliasCreate = z.infer<typeof aliasCreateSchema>;
export const aliasPatchSchema = z.object({
name: z.string().min(1).optional(),
purpose: aliasPurposeSchema.optional(),
mode: aliasModeSchema.optional(),
targetNodeId: z.string().min(1).optional(),
});
export type AliasPatch = z.infer<typeof aliasPatchSchema>;
export const aliasRetargetSchema = z.object({
targetNodeId: z.string().min(1),
});
export type AliasRetarget = z.infer<typeof aliasRetargetSchema>;
export const syncDiffOpSchema = z.object({
id: z.string(),
kind: z.enum([
"create",
"update",
"delete",
"orphan",
"proxy_violation",
"noop",
]),
entityType: z.enum(["node_a", "node_aaaa", "alias", "orphan"]),
entityId: z.string().nullable(),
recordName: z.string(),
recordType: z.string(),
desired: z.record(z.string(), z.unknown()).nullable(),
observed: z.record(z.string(), z.unknown()).nullable(),
detail: z.string().optional(),
});
export type SyncDiffOp = z.infer<typeof syncDiffOpSchema>;
export const syncJobSchema = z.object({
id: z.string(),
zoneId: z.string(),
status: z.enum(["pending", "running", "done", "failed"]),
diff: z.array(syncDiffOpSchema).optional(),
error: z.string().nullable(),
createdAt: z.string(),
finishedAt: z.string().nullable(),
});
export type SyncJob = z.infer<typeof syncJobSchema>;
export const syncApplySchema = z.object({
opIds: z.array(z.string()).optional(),
});
export type SyncApply = z.infer<typeof syncApplySchema>;
export const dashboardStatsSchema = z.object({
nodes: z.number(),
aliases: z.number(),
syncOk: z.number(),
drift: z.number(),
proxyViolations: z.number(),
orphans: z.number(),
lastSyncAt: z.string().nullable(),
nodesWithoutIp: z.number(),
brokenAliases: z.number(),
});
export type DashboardStats = z.infer<typeof dashboardStatsSchema>;
export const topologyNodeSchema = z.object({
id: z.string(),
hostname: z.string(),
role: nodeRoleSchema,
locationCode: z.string(),
ipv4: z.string().nullable(),
syncStatus: syncStatusSchema,
});
export const topologyEdgeSchema = z.object({
id: z.string(),
aliasName: z.string(),
purpose: aliasPurposeSchema,
fromNodeId: z.string(),
toHostname: z.string(),
});
export const topologySchema = z.object({
nodes: z.array(topologyNodeSchema),
edges: z.array(topologyEdgeSchema),
locations: z.array(locationSchema),
});
export type Topology = z.infer<typeof topologySchema>;
export const bindExportSchema = z.object({
zoneName: z.string(),
content: z.string(),
});
export type BindExport = z.infer<typeof bindExportSchema>;
export const orphanIgnoreSchema = z.object({
recordName: z.string().min(1),
recordType: z.string().min(1),
});
+8
View File
@@ -1,2 +1,10 @@
export * from "./app-switcher.js";
export * from "./settings.js";
export * from "./fleet.js";
export class ValidationError extends Error {
constructor(message: string) {
super(message);
this.name = "ValidationError";
}
}
+7
View File
@@ -25,6 +25,9 @@ export type LoginResponse = {
export const appSettingsPatchSchema = z.object({
showQuickActions: z.boolean().optional(),
defaultTtl: z.number().int().min(60).max(86400).optional(),
namingTemplate: z.string().min(1).optional(),
proxiedLock: z.boolean().optional(),
});
export type AppSettingsPatch = z.infer<typeof appSettingsPatchSchema>;
@@ -32,6 +35,10 @@ export type AppSettingsPatch = z.infer<typeof appSettingsPatchSchema>;
export const appSettingsSchema = z.object({
id: z.string(),
showQuickActions: z.boolean(),
defaultTtl: z.number(),
namingTemplate: z.string(),
proxiedLock: z.boolean(),
cloudflareConfigured: z.boolean().optional(),
});
export type AppSettings = z.infer<typeof appSettingsSchema>;