import { z } from "zod";
import { NameResolverSerializedSchema, PKCParsedOptionsSchema, PKCUserOptionBaseSchema } from "../../schema.js";
import { ChallengeFileSchema } from "../../community/schema.js";
// Setting up WS
const WsServerClassOptions = z.object({
    port: z.number().int().positive().optional(),
    server: z.custom().optional()
});
export const CreatePKCWsServerOptionsSchema = z
    .object({
    pkcOptions: z.custom().optional(), // no need to validate here, will be validated with await PKC()
    authKey: z.string().optional(),
    startStartedCommunitiesOnStartup: z.boolean().optional(),
    // Controls how many communities are auto-started in parallel on boot.
    // 0 or 1 disables parallelism (sequential start). Default: 5
    autoStartConcurrency: z.number().int().nonnegative().optional(),
    // community.export() policy: when false, the server rejects exportCommunity calls with
    // includePrivateKey: true. Default true (private-RPC scope). Public-RPC operators set false.
    allowPrivateKeyExport: z.boolean().optional(),
    // Orphan export-file sweep: on server startup, export sqlite files in <pkcDataPath>/exports/
    // older than this many milliseconds are deleted. Default 86_400_000 (24h). Lower it to
    // reclaim disk sooner; raise it to retain never-downloaded exports for longer.
    // Set it to 0 to disable the sweep entirely — export files are then kept forever and pkc-js
    // never auto-removes them.
    exportFileMaxAgeMs: z.number().int().nonnegative().optional()
})
    .merge(WsServerClassOptions)
    .loose();
// rpc WS
export const SetNewSettingsPKCWsServerSchema = z.object({
    pkcOptions: PKCUserOptionBaseSchema.extend({
        nameResolvers: NameResolverSerializedSchema.array().optional()
    }).loose()
});
export const PKCWsServerSettingsSerializedSchema = z.object({
    pkcOptions: PKCParsedOptionsSchema.loose(),
    challenges: z.record(z.string(), ChallengeFileSchema.omit({ getChallenge: true }) // to avoid throwing because of recursive dependency
    )
});
//# sourceMappingURL=schema.js.map