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
|
|
@ -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>;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue