feat(db,schemas): add migration 004, runtime throttle profile, and v1.1 Zod schemas
This commit is contained in:
parent
d7c3e11d7e
commit
afc2d6358a
30 changed files with 792 additions and 118 deletions
|
|
@ -74,7 +74,7 @@ export interface ClientSecuritySettings {
|
|||
requireTotpOnLogin: boolean;
|
||||
passwordMode: 'any' | 'all';
|
||||
totpMode: 'any' | 'all';
|
||||
stepUpPolicy: 'off' | 'every-action' | '5m' | '1h' | '24h' | 'session';
|
||||
stepUpPolicy: 'off' | 'every-action' | '5m' | '15m' | '1h' | '24h' | 'session';
|
||||
stepUpMethod: 'totp' | 'password' | 'both' | 'passkey';
|
||||
elevateOnLogin: boolean;
|
||||
keepElevationOnSafeMode: boolean;
|
||||
|
|
|
|||
|
|
@ -771,9 +771,9 @@ export class AlertEngine {
|
|||
ts: number;
|
||||
},
|
||||
): Promise<{ ok: boolean; statusCode?: number; error?: string }> {
|
||||
const secret = this.readChannelSecret(channel.secretRef);
|
||||
const secret = channel.secretRef ? this.readChannelSecret(channel.secretRef) : null;
|
||||
if (!secret && !channel.url) {
|
||||
return { ok: false, error: `Missing vault secret "${channel.secretRef}"` };
|
||||
return { ok: false, error: `Missing vault secret "${channel.secretRef ?? ''}"` };
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -245,6 +245,13 @@ export class WorkflowEngine {
|
|||
return next ? next.getTime() : null;
|
||||
}
|
||||
|
||||
async triggerScheduledCron(workflowId: string): Promise<boolean> {
|
||||
const job = this.cronJobs.get(workflowId);
|
||||
if (!job) return false;
|
||||
await job.trigger();
|
||||
return true;
|
||||
}
|
||||
|
||||
listWorkflowsWithSummary(): Array<{
|
||||
workflow: WorkflowConfig;
|
||||
nextRunAt: number | null;
|
||||
|
|
@ -632,6 +639,18 @@ export class WorkflowEngine {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (step.type === 'http' || step.type === 'notify') {
|
||||
steps.push({
|
||||
stepId: step.id,
|
||||
type: step.type,
|
||||
wave,
|
||||
dependsOn: deps,
|
||||
targets: [],
|
||||
envKeys,
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
const matched = resolveTargetServers(step.target, allServers, baseCtx);
|
||||
const plan: DryRunStepPlan = {
|
||||
stepId: step.id,
|
||||
|
|
@ -1034,6 +1053,15 @@ export class WorkflowEngine {
|
|||
}
|
||||
}
|
||||
|
||||
if (step.type === 'http' || step.type === 'notify') {
|
||||
const msg = `Step type "${step.type}" handler not yet wired`;
|
||||
control.emitter.push('stderr', `[${step.id}] ${msg}\n`);
|
||||
this.recordStepLog(req.runId, step.id, 'hub', 1, 0, '', msg);
|
||||
stepOutputs.set(step.id, { stdout: '', exitCode: 1 });
|
||||
control.emitter.pushMeta({ event: 'step-exit', stepId: step.id, ok: false });
|
||||
return false;
|
||||
}
|
||||
|
||||
const targets = resolveTargetServers(step.target, allServers, makeCtx());
|
||||
if (targets.length === 0) {
|
||||
const msg = `No enabled target servers matched step "${step.id}"`;
|
||||
|
|
|
|||
|
|
@ -351,7 +351,7 @@ export class ConfigManager {
|
|||
const channelIds = new Set(this.alerts.channels.map((c) => c.id));
|
||||
if (this.vault && this.vault.isRuntimeReady) {
|
||||
for (const ch of this.alerts.channels) {
|
||||
if (!this.vault.hasCredential(ch.secretRef)) {
|
||||
if (ch.secretRef && !this.vault.hasCredential(ch.secretRef)) {
|
||||
next.push({
|
||||
filePath: 'alerts.json',
|
||||
code: 'MISSING_CHANNEL_SECRET',
|
||||
|
|
|
|||
132
src/server/config/runtime-limits.ts
Normal file
132
src/server/config/runtime-limits.ts
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
import type { ThrottleMode } from '../../shared/schemas/settings.schema.js';
|
||||
|
||||
export interface RuntimeLimits {
|
||||
mode: ThrottleMode;
|
||||
argon2MemoryCost: number;
|
||||
argon2Concurrency: number;
|
||||
argon2MaxQueue: number;
|
||||
scryptConcurrency: number;
|
||||
backupMaxGunzipBytes: number;
|
||||
backupMaxBodyBytes: number;
|
||||
sqliteCacheKb: number;
|
||||
sqliteMmapBytes: number;
|
||||
sqliteTempStore: 'FILE' | 'MEMORY';
|
||||
maxActivePtys: number;
|
||||
maxRetainedExitedPtys: number;
|
||||
defaultPtyScrollbackBytes: number;
|
||||
maxConcurrentMetricPolls: number;
|
||||
staggerPolls: boolean;
|
||||
maxParallelSystemInspect: number;
|
||||
maxSystemCacheEntries: number;
|
||||
maxConcurrentWorkflows: number;
|
||||
maxWorkflowStepTargets: number;
|
||||
maxWorkflowQueue: number;
|
||||
maxStepLogBytes: number;
|
||||
streamReplayBytes: number;
|
||||
maxRamBroadcastJobs: number;
|
||||
maxConcurrentAiStreams: number;
|
||||
maxTunnelSocketsPerTunnel: number;
|
||||
maxGlobalTunnelSockets: number;
|
||||
}
|
||||
|
||||
const PRESETS: Record<ThrottleMode, RuntimeLimits> = {
|
||||
'low-resource': {
|
||||
mode: 'low-resource',
|
||||
argon2MemoryCost: 32768,
|
||||
argon2Concurrency: 1,
|
||||
argon2MaxQueue: 8,
|
||||
scryptConcurrency: 1,
|
||||
backupMaxGunzipBytes: 16 * 1024 * 1024,
|
||||
backupMaxBodyBytes: 8 * 1024 * 1024,
|
||||
sqliteCacheKb: 8000,
|
||||
sqliteMmapBytes: 0,
|
||||
sqliteTempStore: 'FILE',
|
||||
maxActivePtys: 12,
|
||||
maxRetainedExitedPtys: 5,
|
||||
defaultPtyScrollbackBytes: 262144,
|
||||
maxConcurrentMetricPolls: 4,
|
||||
staggerPolls: true,
|
||||
maxParallelSystemInspect: 2,
|
||||
maxSystemCacheEntries: 64,
|
||||
maxConcurrentWorkflows: 2,
|
||||
maxWorkflowStepTargets: 4,
|
||||
maxWorkflowQueue: 10,
|
||||
maxStepLogBytes: 131072,
|
||||
streamReplayBytes: 65536,
|
||||
maxRamBroadcastJobs: 5,
|
||||
maxConcurrentAiStreams: 2,
|
||||
maxTunnelSocketsPerTunnel: 64,
|
||||
maxGlobalTunnelSockets: 256,
|
||||
},
|
||||
balanced: {
|
||||
mode: 'balanced',
|
||||
argon2MemoryCost: 65536,
|
||||
argon2Concurrency: 2,
|
||||
argon2MaxQueue: 16,
|
||||
scryptConcurrency: 2,
|
||||
backupMaxGunzipBytes: 32 * 1024 * 1024,
|
||||
backupMaxBodyBytes: 16 * 1024 * 1024,
|
||||
sqliteCacheKb: 32000,
|
||||
sqliteMmapBytes: 0,
|
||||
sqliteTempStore: 'FILE',
|
||||
maxActivePtys: 32,
|
||||
maxRetainedExitedPtys: 12,
|
||||
defaultPtyScrollbackBytes: 524288,
|
||||
maxConcurrentMetricPolls: 12,
|
||||
staggerPolls: true,
|
||||
maxParallelSystemInspect: 4,
|
||||
maxSystemCacheEntries: 128,
|
||||
maxConcurrentWorkflows: 6,
|
||||
maxWorkflowStepTargets: 12,
|
||||
maxWorkflowQueue: 25,
|
||||
maxStepLogBytes: 262144,
|
||||
streamReplayBytes: 131072,
|
||||
maxRamBroadcastJobs: 15,
|
||||
maxConcurrentAiStreams: 6,
|
||||
maxTunnelSocketsPerTunnel: 128,
|
||||
maxGlobalTunnelSockets: 512,
|
||||
},
|
||||
unthrottled: {
|
||||
mode: 'unthrottled',
|
||||
argon2MemoryCost: 65536,
|
||||
argon2Concurrency: 4,
|
||||
argon2MaxQueue: 32,
|
||||
scryptConcurrency: 4,
|
||||
backupMaxGunzipBytes: 64 * 1024 * 1024,
|
||||
backupMaxBodyBytes: 32 * 1024 * 1024,
|
||||
sqliteCacheKb: 64000,
|
||||
sqliteMmapBytes: 134217728,
|
||||
sqliteTempStore: 'MEMORY',
|
||||
maxActivePtys: 128,
|
||||
maxRetainedExitedPtys: 30,
|
||||
defaultPtyScrollbackBytes: 524288,
|
||||
maxConcurrentMetricPolls: 0,
|
||||
staggerPolls: false,
|
||||
maxParallelSystemInspect: 16,
|
||||
maxSystemCacheEntries: 512,
|
||||
maxConcurrentWorkflows: 32,
|
||||
maxWorkflowStepTargets: 0,
|
||||
maxWorkflowQueue: 100,
|
||||
maxStepLogBytes: 524288,
|
||||
streamReplayBytes: 262144,
|
||||
maxRamBroadcastJobs: 25,
|
||||
maxConcurrentAiStreams: 16,
|
||||
maxTunnelSocketsPerTunnel: 512,
|
||||
maxGlobalTunnelSockets: 2048,
|
||||
},
|
||||
};
|
||||
|
||||
export function normalizeThrottleMode(raw: string | undefined): ThrottleMode | undefined {
|
||||
if (raw === 'low-resource' || raw === 'balanced' || raw === 'unthrottled') {
|
||||
return raw;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function resolveRuntimeLimits(
|
||||
mode: ThrottleMode = 'low-resource',
|
||||
envOverride?: string,
|
||||
): RuntimeLimits {
|
||||
const effective = normalizeThrottleMode(envOverride) ?? mode;
|
||||
return PRESETS[effective] ?? PRESETS['low-resource'];
|
||||
}
|
||||
|
|
@ -1,26 +1,62 @@
|
|||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import Database from 'better-sqlite3';
|
||||
import type { RuntimeLimits } from '../config/runtime-limits.js';
|
||||
import { migration001Initial, type Migration } from './migrations/001_initial.js';
|
||||
import { migration002MultiAuth } from './migrations/002_multi_auth.js';
|
||||
import { migration003Phase4Meta } from './migrations/003_phase4_meta.js';
|
||||
import { migration004V11 } from './migrations/004_v1_1.js';
|
||||
|
||||
const MIGRATIONS: Migration[] = [
|
||||
migration001Initial,
|
||||
migration002MultiAuth,
|
||||
migration003Phase4Meta,
|
||||
migration004V11,
|
||||
];
|
||||
|
||||
function chmodBestEffort(targetPath: string, mode: number): void {
|
||||
try {
|
||||
if (fs.existsSync(targetPath)) {
|
||||
fs.chmodSync(targetPath, mode);
|
||||
}
|
||||
} catch {
|
||||
// Best effort on filesystems without POSIX permissions
|
||||
}
|
||||
}
|
||||
|
||||
export function applyDatabaseThrottlePragmas(
|
||||
db: Database.Database,
|
||||
limits: Pick<RuntimeLimits, 'sqliteCacheKb' | 'sqliteMmapBytes' | 'sqliteTempStore'>,
|
||||
): void {
|
||||
const cacheKb = Math.max(2000, Math.floor(limits.sqliteCacheKb));
|
||||
const mmapBytes = Math.max(0, Math.floor(limits.sqliteMmapBytes));
|
||||
const tempStore = limits.sqliteTempStore === 'MEMORY' ? 'MEMORY' : 'FILE';
|
||||
db.pragma(`cache_size = -${cacheKb}`);
|
||||
db.pragma(`mmap_size = ${mmapBytes}`);
|
||||
db.pragma(`temp_store = ${tempStore}`);
|
||||
}
|
||||
|
||||
export function openDatabase(dbPath: string): Database.Database {
|
||||
fs.mkdirSync(path.dirname(dbPath), { recursive: true });
|
||||
const parentDir = path.dirname(dbPath);
|
||||
fs.mkdirSync(parentDir, { recursive: true, mode: 0o700 });
|
||||
chmodBestEffort(parentDir, 0o700);
|
||||
const db = new Database(dbPath);
|
||||
|
||||
db.pragma('journal_mode = WAL');
|
||||
db.pragma('synchronous = NORMAL');
|
||||
db.pragma('foreign_keys = ON');
|
||||
db.pragma('busy_timeout = 5000');
|
||||
db.pragma('secure_delete = ON');
|
||||
db.pragma('cache_size = -8000');
|
||||
db.pragma('mmap_size = 0');
|
||||
db.pragma('temp_store = FILE');
|
||||
db.pragma('wal_autocheckpoint = 1000');
|
||||
db.pragma('journal_size_limit = 16777216');
|
||||
|
||||
runMigrations(db);
|
||||
chmodBestEffort(dbPath, 0o600);
|
||||
chmodBestEffort(`${dbPath}-wal`, 0o600);
|
||||
chmodBestEffort(`${dbPath}-shm`, 0o600);
|
||||
return db;
|
||||
}
|
||||
|
||||
|
|
|
|||
65
src/server/db/migrations/004_v1_1.ts
Normal file
65
src/server/db/migrations/004_v1_1.ts
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
import type Database from 'better-sqlite3';
|
||||
import type { Migration } from './001_initial.js';
|
||||
|
||||
export const migration004V11: Migration = {
|
||||
id: '004_v1_1',
|
||||
up(db: Database.Database) {
|
||||
db.exec(`
|
||||
ALTER TABLE admin_totps ADD COLUMN last_used_step INTEGER;
|
||||
ALTER TABLE admin_totps ADD COLUMN secret_enc TEXT;
|
||||
|
||||
UPDATE admin_totps
|
||||
SET last_used_step = CASE
|
||||
WHEN last_login_step IS NOT NULL AND last_stepup_step IS NOT NULL THEN MAX(last_login_step, last_stepup_step)
|
||||
WHEN last_login_step IS NOT NULL THEN last_login_step
|
||||
ELSE last_stepup_step
|
||||
END;
|
||||
|
||||
UPDATE admin_users
|
||||
SET password_hash = '', totp_secret = ''
|
||||
WHERE EXISTS (SELECT 1 FROM admin_passwords);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS rate_limits (
|
||||
scope_key TEXT PRIMARY KEY,
|
||||
failures INTEGER NOT NULL,
|
||||
locked_until INTEGER NOT NULL,
|
||||
updated_at INTEGER NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS known_hosts_v2 (
|
||||
host_port TEXT NOT NULL,
|
||||
algorithm TEXT NOT NULL,
|
||||
fingerprint TEXT NOT NULL,
|
||||
trusted_at INTEGER NOT NULL,
|
||||
updated_at INTEGER NOT NULL,
|
||||
PRIMARY KEY (host_port, algorithm)
|
||||
);
|
||||
|
||||
INSERT OR IGNORE INTO known_hosts_v2 (host_port, algorithm, fingerprint, trusted_at, updated_at)
|
||||
SELECT host_port, algorithm, fingerprint, trusted_at, updated_at FROM known_hosts;
|
||||
|
||||
DROP TABLE known_hosts;
|
||||
ALTER TABLE known_hosts_v2 RENAME TO known_hosts;
|
||||
|
||||
ALTER TABLE metrics_rollup ADD COLUMN net_rx_avg_bps REAL NOT NULL DEFAULT 0;
|
||||
ALTER TABLE metrics_rollup ADD COLUMN net_tx_avg_bps REAL NOT NULL DEFAULT 0;
|
||||
ALTER TABLE metrics_rollup ADD COLUMN disk_max_pct REAL NOT NULL DEFAULT 0;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS broadcast_jobs (
|
||||
job_id TEXT PRIMARY KEY,
|
||||
command TEXT NOT NULL,
|
||||
snippet_id TEXT,
|
||||
targets_json TEXT NOT NULL,
|
||||
status TEXT NOT NULL,
|
||||
started_at INTEGER NOT NULL,
|
||||
finished_at INTEGER,
|
||||
results_json TEXT NOT NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_broadcast_jobs_ts ON broadcast_jobs(started_at DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_audit_status ON audit_log(status);
|
||||
CREATE INDEX IF NOT EXISTS idx_audit_ip ON audit_log(actor_ip);
|
||||
CREATE INDEX IF NOT EXISTS idx_audit_target ON audit_log(target);
|
||||
`);
|
||||
},
|
||||
};
|
||||
|
|
@ -179,6 +179,8 @@ function computeElevatedUntil(
|
|||
return fromLogin ? null : nowMs + 60_000;
|
||||
case '5m':
|
||||
return nowMs + 5 * 60 * 1000;
|
||||
case '15m':
|
||||
return nowMs + 15 * 60 * 1000;
|
||||
case '1h':
|
||||
return nowMs + 60 * 60 * 1000;
|
||||
case '24h':
|
||||
|
|
|
|||
|
|
@ -296,8 +296,7 @@ export class KnownHostsService {
|
|||
.prepare(
|
||||
`INSERT INTO known_hosts (host_port, algorithm, fingerprint, trusted_at, updated_at)
|
||||
VALUES (?, ?, ?, ?, ?)
|
||||
ON CONFLICT(host_port) DO UPDATE SET
|
||||
algorithm = excluded.algorithm,
|
||||
ON CONFLICT(host_port, algorithm) DO UPDATE SET
|
||||
fingerprint = excluded.fingerprint,
|
||||
updated_at = excluded.updated_at`,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,16 +1,38 @@
|
|||
import { z } from 'zod';
|
||||
import { CronExpressionSchema, EntityIdSchema } from './common.js';
|
||||
import {
|
||||
CronExpressionSchema,
|
||||
EntityIdSchema,
|
||||
HttpUrlSchema,
|
||||
IanaTimezoneSchema,
|
||||
} from './common.js';
|
||||
|
||||
export const AlertChannelSchema = z.object({
|
||||
id: EntityIdSchema,
|
||||
name: z.string().min(1).max(120),
|
||||
type: z.enum(['discord', 'telegram', 'ntfy', 'generic']),
|
||||
url: z.string().url().optional(),
|
||||
secretRef: EntityIdSchema,
|
||||
chatId: z.string().optional(),
|
||||
topic: z.string().optional(),
|
||||
enabled: z.boolean().default(true),
|
||||
});
|
||||
export const AlertChannelSchema = z
|
||||
.object({
|
||||
id: EntityIdSchema,
|
||||
name: z.string().min(1).max(120),
|
||||
type: z.enum(['discord', 'telegram', 'ntfy', 'generic']),
|
||||
url: HttpUrlSchema.optional(),
|
||||
secretRef: EntityIdSchema.optional(),
|
||||
chatId: z.string().optional(),
|
||||
topic: z.string().optional(),
|
||||
enabled: z.boolean().default(true),
|
||||
})
|
||||
.superRefine((ch, ctx) => {
|
||||
if (!ch.url && !ch.secretRef) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
path: ['secretRef'],
|
||||
message: 'Alert channel must specify either url or secretRef',
|
||||
});
|
||||
}
|
||||
if ((ch.type === 'discord' || ch.type === 'telegram') && !ch.secretRef && !ch.url) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
path: ['secretRef'],
|
||||
message: `${ch.type} channel requires secretRef or url`,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
export const AlertRuleTargetSchema = z.object({
|
||||
serverId: EntityIdSchema.optional(),
|
||||
|
|
@ -30,6 +52,14 @@ const AlertRuleBase = {
|
|||
enabled: z.boolean().default(true),
|
||||
};
|
||||
|
||||
export const SecurityEventKindSchema = z.enum([
|
||||
'login_burst',
|
||||
'new_ip_login',
|
||||
'panic_lock',
|
||||
'key_rotation',
|
||||
'backup_restore',
|
||||
]);
|
||||
|
||||
export const AlertRuleSchema = z.discriminatedUnion('kind', [
|
||||
z.object({
|
||||
...AlertRuleBase,
|
||||
|
|
@ -60,26 +90,51 @@ export const AlertRuleSchema = z.discriminatedUnion('kind', [
|
|||
systemId: EntityIdSchema,
|
||||
item: z.string().optional(),
|
||||
}),
|
||||
z.object({
|
||||
...AlertRuleBase,
|
||||
kind: z.literal('security-event'),
|
||||
events: z.array(SecurityEventKindSchema).min(1),
|
||||
}),
|
||||
]);
|
||||
|
||||
export const MaintenanceWindowSchema = z.object({
|
||||
id: EntityIdSchema,
|
||||
name: z.string().min(1).max(120),
|
||||
cron: CronExpressionSchema,
|
||||
timezone: z.string().min(1).default('UTC'),
|
||||
timezone: IanaTimezoneSchema.default('UTC'),
|
||||
durationMinutes: z.number().int().min(1).max(1440),
|
||||
target: AlertRuleTargetSchema.default({ all: true }),
|
||||
enabled: z.boolean().default(true),
|
||||
});
|
||||
|
||||
export const AlertsFileSchema = z.object({
|
||||
version: z.literal(1).default(1),
|
||||
channels: z.array(AlertChannelSchema).default([]),
|
||||
rules: z.array(AlertRuleSchema).default([]),
|
||||
maintenanceWindows: z.array(MaintenanceWindowSchema).default([]),
|
||||
});
|
||||
export const AlertsFileSchema = z
|
||||
.object({
|
||||
version: z.literal(1).default(1),
|
||||
channels: z.array(AlertChannelSchema).default([]),
|
||||
rules: z.array(AlertRuleSchema).default([]),
|
||||
maintenanceWindows: z.array(MaintenanceWindowSchema).default([]),
|
||||
})
|
||||
.superRefine((doc, ctx) => {
|
||||
const checkDupes = (items: Array<{ id: string }>, arrPath: string) => {
|
||||
const seen = new Set<string>();
|
||||
items.forEach((item, idx) => {
|
||||
if (seen.has(item.id)) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
path: [arrPath, idx, 'id'],
|
||||
message: `Duplicate ${arrPath} id "${item.id}"`,
|
||||
});
|
||||
}
|
||||
seen.add(item.id);
|
||||
});
|
||||
};
|
||||
checkDupes(doc.channels, 'channels');
|
||||
checkDupes(doc.rules, 'rules');
|
||||
checkDupes(doc.maintenanceWindows, 'maintenanceWindows');
|
||||
});
|
||||
|
||||
export type AlertChannel = z.infer<typeof AlertChannelSchema>;
|
||||
export type AlertRule = z.infer<typeof AlertRuleSchema>;
|
||||
export type SecurityEventKind = z.infer<typeof SecurityEventKindSchema>;
|
||||
export type MaintenanceWindow = z.infer<typeof MaintenanceWindowSchema>;
|
||||
export type AlertsFile = z.infer<typeof AlertsFileSchema>;
|
||||
|
|
|
|||
|
|
@ -5,16 +5,44 @@ export const EntityIdSchema = z
|
|||
.string()
|
||||
.min(1, 'ID must not be empty')
|
||||
.max(64, 'ID must be at most 64 characters')
|
||||
.regex(/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,63}$/, 'ID must start with alphanumeric and contain only [a-zA-Z0-9._-]');
|
||||
.regex(/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,63}$/, 'ID must start with alphanumeric and contain only [a-zA-Z0-9._-]')
|
||||
.refine((v) => !v.includes('..'), 'ID cannot contain ".."');
|
||||
|
||||
export const PortSchema = z.number().int().min(1).max(65535);
|
||||
|
||||
export const HttpUrlSchema = z
|
||||
.string()
|
||||
.url()
|
||||
.refine((u) => /^https?:\/\//i.test(u), 'URL must use http:// or https://');
|
||||
|
||||
export const IanaTimezoneSchema = z
|
||||
.string()
|
||||
.min(1)
|
||||
.max(64)
|
||||
.refine((tz) => {
|
||||
try {
|
||||
Intl.DateTimeFormat(undefined, { timeZone: tz });
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}, 'Invalid IANA timezone');
|
||||
|
||||
export const CronExpressionSchema = z
|
||||
.string()
|
||||
.min(1)
|
||||
.superRefine((expr, ctx) => {
|
||||
const trimmed = expr.trim();
|
||||
const fields = trimmed.split(/\s+/);
|
||||
if (fields.length !== 5) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: 'Cron expression must have exactly 5 fields (minute hour day month weekday)',
|
||||
});
|
||||
return;
|
||||
}
|
||||
try {
|
||||
new CronPattern(expr);
|
||||
new CronPattern(trimmed);
|
||||
} catch (err) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
|
|
@ -25,7 +53,7 @@ export const CronExpressionSchema = z
|
|||
|
||||
export const InputDefSchema = z.object({
|
||||
name: EntityIdSchema,
|
||||
type: z.enum(['string', 'number', 'boolean', 'server', 'select']).default('string'),
|
||||
type: z.enum(['string', 'number', 'boolean', 'server', 'select', 'secret']).default('string'),
|
||||
label: z.string().min(1).optional(),
|
||||
description: z.string().optional(),
|
||||
required: z.boolean().default(false),
|
||||
|
|
|
|||
|
|
@ -1,22 +1,42 @@
|
|||
import { z } from 'zod';
|
||||
import { EntityIdSchema, PortSchema } from './common.js';
|
||||
import { EntityIdSchema, HttpUrlSchema, PortSchema } from './common.js';
|
||||
|
||||
export const SafeHostSchema = z
|
||||
.string()
|
||||
.min(1)
|
||||
.max(255)
|
||||
.regex(
|
||||
/^[A-Za-z0-9\[][A-Za-z0-9._:\[\]-]*$/,
|
||||
'Host cannot start with "-" or contain whitespace, "@", or control characters',
|
||||
);
|
||||
|
||||
export const SafeUsernameSchema = z
|
||||
.string()
|
||||
.min(1)
|
||||
.max(64)
|
||||
.regex(
|
||||
/^[A-Za-z0-9_][A-Za-z0-9._-]*$/,
|
||||
'Username cannot start with "-" or contain whitespace, "@", or ":"',
|
||||
);
|
||||
|
||||
export const HttpProbeSchema = z.object({
|
||||
id: EntityIdSchema,
|
||||
type: z.literal('http'),
|
||||
url: z.string().url(),
|
||||
url: HttpUrlSchema,
|
||||
from: z.enum(['hub', 'target']).default('target'),
|
||||
intervalSec: z.number().int().min(5).max(86400).default(30),
|
||||
timeoutMs: z.number().int().min(200).max(60000).default(5000),
|
||||
expectedStatus: z.number().int().min(100).max(599).default(200),
|
||||
bodyIncludes: z.string().optional(),
|
||||
tlsRejectUnauthorized: z.boolean().default(true),
|
||||
tlsCheckExpiryDays: z.number().int().min(1).max(365).optional(),
|
||||
enabled: z.boolean().default(true),
|
||||
});
|
||||
|
||||
export const TcpProbeSchema = z.object({
|
||||
id: EntityIdSchema,
|
||||
type: z.literal('tcp'),
|
||||
host: z.string().min(1).default('127.0.0.1'),
|
||||
host: SafeHostSchema.default('127.0.0.1'),
|
||||
port: PortSchema,
|
||||
from: z.enum(['hub', 'target']).default('target'),
|
||||
intervalSec: z.number().int().min(5).max(86400).default(30),
|
||||
|
|
@ -40,36 +60,71 @@ export const ServerSystemAttachmentSchema = z.object({
|
|||
.default({}),
|
||||
});
|
||||
|
||||
export const ServerTunnelSchema = z.object({
|
||||
id: EntityIdSchema,
|
||||
name: z.string().min(1).max(120),
|
||||
mode: z.enum(['http-proxy', 'local-tcp', 'remote-tcp']),
|
||||
bindHost: z.string().min(1).optional(),
|
||||
bindPort: PortSchema.optional(),
|
||||
targetHost: z.string().min(1).default('127.0.0.1'),
|
||||
targetPort: PortSchema,
|
||||
autoStart: z.boolean().default(false),
|
||||
});
|
||||
export const ServerTunnelSchema = z
|
||||
.object({
|
||||
id: EntityIdSchema,
|
||||
name: z.string().min(1).max(120),
|
||||
mode: z.enum(['http-proxy', 'local-tcp', 'remote-tcp', 'socks5']),
|
||||
bindHost: SafeHostSchema.optional(),
|
||||
bindPort: PortSchema.optional(),
|
||||
targetHost: SafeHostSchema.default('127.0.0.1'),
|
||||
targetPort: z.number().int().min(0).max(65535).default(0),
|
||||
targetProtocol: z.enum(['http', 'https']).default('http'),
|
||||
tlsRejectUnauthorized: z.boolean().default(true),
|
||||
tlsServerName: z.string().max(255).optional(),
|
||||
ttlSec: z.number().int().min(60).max(86400).optional(),
|
||||
autoStart: z.boolean().default(false),
|
||||
})
|
||||
.superRefine((tunnel, ctx) => {
|
||||
if (tunnel.mode !== 'socks5' && tunnel.targetPort < 1) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
path: ['targetPort'],
|
||||
message: 'targetPort must be between 1 and 65535',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
export const ServerConfigSchema = z.object({
|
||||
id: EntityIdSchema,
|
||||
name: z.string().min(1).max(120),
|
||||
host: z.string().min(1),
|
||||
port: PortSchema.default(22),
|
||||
username: z.string().min(1).max(64),
|
||||
credentialId: EntityIdSchema,
|
||||
jumpHostId: EntityIdSchema.optional(),
|
||||
sudoCredentialId: EntityIdSchema.optional(),
|
||||
hostKeyFingerprint: z.string().min(1).optional(),
|
||||
tags: z.array(z.string().min(1)).default([]),
|
||||
osHint: z.enum(['auto', 'linux', 'bsd', 'macos']).default('auto'),
|
||||
pollIntervalSec: z.number().int().min(2).max(3600).default(10),
|
||||
diskMountFilter: z.array(z.string().min(1)).optional(),
|
||||
probes: z.array(ServerProbeSchema).default([]),
|
||||
systems: z.array(ServerSystemAttachmentSchema).default([]),
|
||||
tunnels: z.array(ServerTunnelSchema).default([]),
|
||||
enabled: z.boolean().default(true),
|
||||
});
|
||||
export const ServerConfigSchema = z
|
||||
.object({
|
||||
id: EntityIdSchema,
|
||||
name: z.string().min(1).max(120),
|
||||
host: SafeHostSchema,
|
||||
port: PortSchema.default(22),
|
||||
username: SafeUsernameSchema,
|
||||
credentialId: EntityIdSchema,
|
||||
jumpHostId: EntityIdSchema.optional(),
|
||||
sudoCredentialId: EntityIdSchema.optional(),
|
||||
hostKeyFingerprint: z.string().min(1).optional(),
|
||||
tags: z.array(z.string().min(1)).default([]),
|
||||
osHint: z.enum(['auto', 'linux', 'bsd', 'macos']).default('auto'),
|
||||
pollIntervalSec: z.number().int().min(2).max(3600).default(10),
|
||||
diskMountFilter: z.array(z.string().min(1)).optional(),
|
||||
probes: z.array(ServerProbeSchema).default([]),
|
||||
systems: z.array(ServerSystemAttachmentSchema).default([]),
|
||||
tunnels: z.array(ServerTunnelSchema).default([]),
|
||||
enabled: z.boolean().default(true),
|
||||
})
|
||||
.superRefine((srv, ctx) => {
|
||||
const checkDupes = (items: Array<{ id?: string; systemId?: string }>, key: 'id' | 'systemId', arrPath: string) => {
|
||||
const seen = new Set<string>();
|
||||
items.forEach((item, idx) => {
|
||||
const val = item[key];
|
||||
if (!val) return;
|
||||
if (seen.has(val)) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
path: [arrPath, idx, key],
|
||||
message: `Duplicate ${arrPath} identifier "${val}"`,
|
||||
});
|
||||
}
|
||||
seen.add(val);
|
||||
});
|
||||
};
|
||||
checkDupes(srv.probes, 'id', 'probes');
|
||||
checkDupes(srv.systems, 'systemId', 'systems');
|
||||
checkDupes(srv.tunnels, 'id', 'tunnels');
|
||||
});
|
||||
|
||||
export type ServerProbe = z.infer<typeof ServerProbeSchema>;
|
||||
export type ServerSystemAttachment = z.infer<typeof ServerSystemAttachmentSchema>;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { z } from 'zod';
|
||||
import { EntityIdSchema } from './common.js';
|
||||
import { EntityIdSchema, HttpUrlSchema, IanaTimezoneSchema } from './common.js';
|
||||
|
||||
export const ThemeIdSchema = z.enum([
|
||||
'phosphor-green',
|
||||
|
|
@ -14,10 +14,13 @@ export const ThemeIdSchema = z.enum([
|
|||
|
||||
export const THEME_IDS = ThemeIdSchema.options;
|
||||
|
||||
export const ThrottleModeSchema = z.enum(['low-resource', 'balanced', 'unthrottled']);
|
||||
|
||||
export const StepUpPolicySchema = z.enum([
|
||||
'off',
|
||||
'every-action',
|
||||
'5m',
|
||||
'15m',
|
||||
'1h',
|
||||
'24h',
|
||||
'session',
|
||||
|
|
@ -29,11 +32,15 @@ export const SecuritySettingsSchema = z.object({
|
|||
requireTotpOnLogin: z.boolean().default(true),
|
||||
passwordMode: z.enum(['any', 'all']).default('any'),
|
||||
totpMode: z.enum(['any', 'all']).default('any'),
|
||||
stepUpPolicy: StepUpPolicySchema.default('1h'),
|
||||
stepUpPolicy: StepUpPolicySchema.default('15m'),
|
||||
stepUpMethod: StepUpMethodSchema.default('totp'),
|
||||
elevateOnLogin: z.boolean().default(true),
|
||||
elevateOnLogin: z.boolean().default(false),
|
||||
keepElevationOnSafeMode: z.boolean().default(true),
|
||||
enableEmergencySecretsBackup: z.boolean().default(true),
|
||||
enableEmergencySecretsBackup: z.boolean().default(false),
|
||||
allowSameOriginProxy: z.boolean().default(false),
|
||||
egressAllowedCidrs: z.array(z.string().min(1).max(64)).max(64).default([]),
|
||||
sessionTtlHours: z.number().int().min(1).max(720).default(168),
|
||||
sessionIdleTimeoutMin: z.number().int().min(0).max(10080).default(60),
|
||||
});
|
||||
|
||||
export const SettingsSchema = z.object({
|
||||
|
|
@ -42,29 +49,68 @@ export const SettingsSchema = z.object({
|
|||
defaultMobileSafeMode: z.boolean().default(true),
|
||||
rawRetentionHours: z.number().int().min(1).max(720).default(48),
|
||||
rollupRetentionDays: z.number().int().min(1).max(3650).default(30),
|
||||
auditRetentionDays: z.number().int().min(1).max(3650).default(90),
|
||||
workflowRunRetentionDays: z.number().int().min(1).max(3650).default(30),
|
||||
alertEventRetentionDays: z.number().int().min(1).max(3650).default(30),
|
||||
configRevisionLimit: z.number().int().min(5).max(500).default(50),
|
||||
ptyScrollbackBytes: z.number().int().min(16384).max(4194304).default(524288),
|
||||
ptyScrollbackBytes: z.number().int().min(16384).max(2097152).default(262144),
|
||||
ptyIdleTtlSec: z.number().int().min(60).max(604800).default(43200),
|
||||
sshKeepaliveMs: z.number().int().min(5000).max(120000).default(15000),
|
||||
sshReadyTimeoutMs: z.number().int().min(3000).max(120000).default(15000),
|
||||
runtime: z
|
||||
.object({
|
||||
throttleMode: ThrottleModeSchema.default('low-resource'),
|
||||
})
|
||||
.default({ throttleMode: 'low-resource' }),
|
||||
scheduledBackup: z
|
||||
.object({
|
||||
enabled: z.boolean().default(false),
|
||||
cron: z.string().min(1).default('0 3 * * *'),
|
||||
timezone: IanaTimezoneSchema.default('UTC'),
|
||||
destination: z.enum(['local', 'sftp']).default('local'),
|
||||
localDir: z.string().min(1).max(128).default('backups'),
|
||||
remoteServerId: EntityIdSchema.optional(),
|
||||
remotePath: z.string().min(1).max(256).optional(),
|
||||
retentionCount: z.number().int().min(1).max(100).default(7),
|
||||
passphraseSecretRef: EntityIdSchema.optional(),
|
||||
})
|
||||
.default({
|
||||
enabled: false,
|
||||
cron: '0 3 * * *',
|
||||
timezone: 'UTC',
|
||||
destination: 'local',
|
||||
localDir: 'backups',
|
||||
retentionCount: 7,
|
||||
}),
|
||||
metrics: z
|
||||
.object({
|
||||
prometheusEnabled: z.boolean().default(false),
|
||||
prometheusSecretRef: EntityIdSchema.optional(),
|
||||
})
|
||||
.default({ prometheusEnabled: false }),
|
||||
security: SecuritySettingsSchema.default({}),
|
||||
ai: z
|
||||
.object({
|
||||
enabled: z.boolean().default(false),
|
||||
baseUrl: z.string().url().default('http://127.0.0.1:11434'),
|
||||
baseUrl: HttpUrlSchema.default('http://127.0.0.1:11434'),
|
||||
model: z.string().min(1).default('qwen2.5-coder:7b'),
|
||||
secretRef: EntityIdSchema.optional(),
|
||||
maxContextChars: z.number().int().min(1000).max(128000).default(16000),
|
||||
timeoutSec: z.number().int().min(5).max(300).default(90),
|
||||
maxTokens: z.number().int().min(64).max(32768).default(2048),
|
||||
})
|
||||
.default({
|
||||
enabled: false,
|
||||
baseUrl: 'http://127.0.0.1:11434',
|
||||
model: 'qwen2.5-coder:7b',
|
||||
maxContextChars: 16000,
|
||||
timeoutSec: 90,
|
||||
maxTokens: 2048,
|
||||
}),
|
||||
});
|
||||
|
||||
export type ThemeId = z.infer<typeof ThemeIdSchema>;
|
||||
export type ThrottleMode = z.infer<typeof ThrottleModeSchema>;
|
||||
export type StepUpPolicy = z.infer<typeof StepUpPolicySchema>;
|
||||
export type StepUpMethod = z.infer<typeof StepUpMethodSchema>;
|
||||
export type SecuritySettings = z.infer<typeof SecuritySettingsSchema>;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ export const SnippetSchema = z.object({
|
|||
description: z.string().optional(),
|
||||
command: z.string().min(1),
|
||||
tags: z.array(z.string().min(1)).default([]),
|
||||
osFilter: z.array(z.enum(['linux', 'bsd', 'macos'])).optional(),
|
||||
inputs: z.array(InputDefSchema).default([]),
|
||||
sudo: z.boolean().default(false),
|
||||
confirm: z.boolean().default(false),
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { z } from 'zod';
|
||||
import { EntityIdSchema } from './common.js';
|
||||
import { EntityIdSchema, InputDefSchema } from './common.js';
|
||||
|
||||
export const SystemParamDefSchema = z.object({
|
||||
name: EntityIdSchema,
|
||||
|
|
@ -39,7 +39,19 @@ export const SystemStatusSchema = z.object({
|
|||
command: z.string().min(1),
|
||||
parser: z.enum(['json-lines', 'json', 'lines', 'regex', 'exit-code']),
|
||||
subItemField: z.string().min(1).optional(),
|
||||
regexPattern: z.string().min(1).optional(),
|
||||
regexPattern: z
|
||||
.string()
|
||||
.min(1)
|
||||
.max(512)
|
||||
.refine((pat) => {
|
||||
try {
|
||||
new RegExp(pat);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}, 'Invalid regular expression pattern')
|
||||
.optional(),
|
||||
health: SystemHealthRuleSchema.optional(),
|
||||
});
|
||||
|
||||
|
|
@ -49,22 +61,61 @@ export const SystemActionSchema = z.object({
|
|||
scope: z.enum(['system', 'item', 'subitem']),
|
||||
mode: z.enum(['oneshot', 'stream', 'interactive']),
|
||||
command: z.string().min(1),
|
||||
inputs: z.array(InputDefSchema).default([]),
|
||||
timeoutSec: z.number().int().min(5).max(3600).optional(),
|
||||
sudo: z.boolean().default(false),
|
||||
confirm: z.boolean().default(false),
|
||||
});
|
||||
|
||||
export const SystemConfigSchema = z.object({
|
||||
id: EntityIdSchema,
|
||||
name: z.string().min(1).max(120),
|
||||
description: z.string().optional(),
|
||||
cacheTtlSec: z.number().int().min(0).max(86400).default(45),
|
||||
backgroundCheckSec: z.number().int().min(10).max(86400).optional(),
|
||||
params: z.array(SystemParamDefSchema).default([]),
|
||||
discovery: SystemDiscoverySchema,
|
||||
status: SystemStatusSchema,
|
||||
actions: z.array(SystemActionSchema).default([]),
|
||||
editableFiles: z.array(z.string().min(1)).default([]),
|
||||
});
|
||||
export const SystemConfigSchema = z
|
||||
.object({
|
||||
id: EntityIdSchema,
|
||||
name: z.string().min(1).max(120),
|
||||
description: z.string().optional(),
|
||||
cacheTtlSec: z.number().int().min(0).max(86400).default(45),
|
||||
backgroundCheckSec: z.number().int().min(10).max(86400).optional(),
|
||||
params: z.array(SystemParamDefSchema).default([]),
|
||||
discovery: SystemDiscoverySchema,
|
||||
status: SystemStatusSchema,
|
||||
actions: z.array(SystemActionSchema).default([]),
|
||||
editableFiles: z.array(z.string().min(1)).default([]),
|
||||
})
|
||||
.superRefine((sys, ctx) => {
|
||||
const paramNames = new Set<string>();
|
||||
sys.params.forEach((p, idx) => {
|
||||
if (paramNames.has(p.name)) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
path: ['params', idx, 'name'],
|
||||
message: `Duplicate system param "${p.name}"`,
|
||||
});
|
||||
}
|
||||
paramNames.add(p.name);
|
||||
});
|
||||
|
||||
if (
|
||||
sys.discovery.type === 'folder-scan' &&
|
||||
!paramNames.has(sys.discovery.rootsParam)
|
||||
) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
path: ['discovery', 'rootsParam'],
|
||||
message: `rootsParam "${sys.discovery.rootsParam}" is not defined in params`,
|
||||
});
|
||||
}
|
||||
|
||||
const actionIds = new Set<string>();
|
||||
sys.actions.forEach((a, idx) => {
|
||||
if (actionIds.has(a.id)) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
path: ['actions', idx, 'id'],
|
||||
message: `Duplicate action id "${a.id}"`,
|
||||
});
|
||||
}
|
||||
actionIds.add(a.id);
|
||||
});
|
||||
});
|
||||
|
||||
export type SystemParamDef = z.infer<typeof SystemParamDefSchema>;
|
||||
export type SystemHealthRule = z.infer<typeof SystemHealthRuleSchema>;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,11 @@
|
|||
import { z } from 'zod';
|
||||
import { CronExpressionSchema, EntityIdSchema, InputDefSchema } from './common.js';
|
||||
import {
|
||||
CronExpressionSchema,
|
||||
EntityIdSchema,
|
||||
HttpUrlSchema,
|
||||
IanaTimezoneSchema,
|
||||
InputDefSchema,
|
||||
} from './common.js';
|
||||
|
||||
export const WorkflowTargetSchema = z
|
||||
.object({
|
||||
|
|
@ -23,12 +29,13 @@ export const StepDependencySchema = z.union([
|
|||
export const StepFailureActionSchema = z.union([
|
||||
z.literal('abort'),
|
||||
z.literal('continue'),
|
||||
z.string().min(1),
|
||||
z.object({
|
||||
action: z.enum(['abort', 'continue', 'notify', 'run-workflow']),
|
||||
channelId: z.string().min(1).optional(),
|
||||
workflowId: EntityIdSchema.optional(),
|
||||
}),
|
||||
EntityIdSchema,
|
||||
z.discriminatedUnion('action', [
|
||||
z.object({ action: z.literal('abort') }),
|
||||
z.object({ action: z.literal('continue') }),
|
||||
z.object({ action: z.literal('notify'), channelId: EntityIdSchema }),
|
||||
z.object({ action: z.literal('run-workflow'), workflowId: EntityIdSchema }),
|
||||
]),
|
||||
]);
|
||||
|
||||
const StepBaseFields = {
|
||||
|
|
@ -36,6 +43,9 @@ const StepBaseFields = {
|
|||
name: z.string().min(1).max(120).optional(),
|
||||
dependsOn: z.array(StepDependencySchema).default([]),
|
||||
timeoutSec: z.number().int().min(1).max(86400).optional(),
|
||||
retries: z.number().int().min(0).max(5).default(0),
|
||||
retryBackoffSec: z.number().int().min(1).max(300).default(5),
|
||||
when: z.string().min(1).max(256).optional(),
|
||||
sudo: z.boolean().default(false),
|
||||
captureAs: z.string().min(1).max(64).optional(),
|
||||
onFailure: StepFailureActionSchema.optional(),
|
||||
|
|
@ -80,6 +90,28 @@ export const TransferStepSchema = z.object({
|
|||
serverId: z.string().min(1),
|
||||
path: z.string().min(1),
|
||||
}),
|
||||
delete: z.boolean().optional(),
|
||||
exclude: z.array(z.string().min(1)).max(32).optional(),
|
||||
});
|
||||
|
||||
export const HttpStepSchema = z.object({
|
||||
...StepBaseFields,
|
||||
type: z.literal('http'),
|
||||
url: HttpUrlSchema,
|
||||
method: z.enum(['GET', 'POST', 'PUT', 'PATCH', 'DELETE']).default('POST'),
|
||||
headers: z.record(z.string()).optional(),
|
||||
body: z.string().optional(),
|
||||
secretRef: EntityIdSchema.optional(),
|
||||
expectedStatus: z.number().int().min(100).max(599).optional(),
|
||||
});
|
||||
|
||||
export const NotifyStepSchema = z.object({
|
||||
...StepBaseFields,
|
||||
type: z.literal('notify'),
|
||||
channelIds: z.array(EntityIdSchema).min(1),
|
||||
title: z.string().min(1).max(160),
|
||||
message: z.string().min(1).max(4000),
|
||||
severity: z.enum(['warn', 'critical']).default('warn'),
|
||||
});
|
||||
|
||||
export const WorkflowStepSchema = z.discriminatedUnion('type', [
|
||||
|
|
@ -87,6 +119,8 @@ export const WorkflowStepSchema = z.discriminatedUnion('type', [
|
|||
ReadFileStepSchema,
|
||||
SystemActionStepSchema,
|
||||
TransferStepSchema,
|
||||
HttpStepSchema,
|
||||
NotifyStepSchema,
|
||||
]);
|
||||
|
||||
export const WorkflowTriggerSchema = z.discriminatedUnion('type', [
|
||||
|
|
@ -94,7 +128,7 @@ export const WorkflowTriggerSchema = z.discriminatedUnion('type', [
|
|||
z.object({
|
||||
type: z.literal('cron'),
|
||||
expression: CronExpressionSchema,
|
||||
timezone: z.string().min(1).default('UTC'),
|
||||
timezone: IanaTimezoneSchema.default('UTC'),
|
||||
}),
|
||||
z.object({
|
||||
type: z.literal('event'),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { z } from 'zod';
|
||||
|
||||
export type VaultState = 'uninitialized' | 'locked' | 'unlocked';
|
||||
export type VaultSealState = 'uninitialized' | 'sealed' | 'write-locked' | 'unlocked';
|
||||
|
||||
export type ServerConnectionStatus =
|
||||
| 'disconnected'
|
||||
|
|
@ -133,6 +134,7 @@ export type ServerWsFrame =
|
|||
type: 'hello';
|
||||
vaultState: VaultState;
|
||||
vaultRuntimeReady?: boolean;
|
||||
vaultSealState?: VaultSealState;
|
||||
safeMode: boolean;
|
||||
elevatedUntil: number | null;
|
||||
}
|
||||
|
|
@ -140,6 +142,7 @@ export type ServerWsFrame =
|
|||
type: 'vault:state';
|
||||
vaultState: VaultState;
|
||||
vaultRuntimeReady: boolean;
|
||||
vaultSealState?: VaultSealState;
|
||||
isPanicLocked: boolean;
|
||||
}
|
||||
| {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue