import { t as StandardSchemaV1 } from "../index-CeEtxDmK.mjs"; //#region src/utils/simple-schema.d.ts /** * A tiny, zero-dependency [Standard Schema](https://standardschema.dev/) * builder. * * ⚠️ **Discouraged for app code.** This is a deliberately minimal, * best-effort validator that exists only so devframe's own first-party * packages (recipes, built-in plugins) can declare `args`/`returns`/flag * schemas without taking on a validator dependency. It implements a small * subset of primitives and approximates refinements; it is not a * general-purpose validator. * * For your own code, prefer a real Standard Schema validator: **valibot**, * **zod**, or **arktype**. Devframe's RPC and CLI-flag layers accept any of * them; install the one you like and use it directly: * * ```ts * import * as v from 'valibot' // npm i valibot * * defineRpcFunction({ * name: 'greet', * args: [v.object({ name: v.string() })], * returns: v.string(), * handler: ({ name }) => `hi ${name}`, * }) * ``` */ /** * A Standard Schema produced by the {@link s} builder. It carries a * duck-typed `type` marker (and `wrapped` for wrappers) alongside the * standard `~standard` prop so the CLI-flags adapter can introspect the * schema kind without importing any validator. */ export interface SimpleSchema extends StandardSchemaV1 { /** Schema kind marker, e.g. `'string'`, `'boolean'`, `'optional'`. */ readonly type: string; /** Inner schema for wrapper kinds (`optional` / `nullable`). */ readonly wrapped?: StandardSchemaV1; /** Optional human description (surfaced as CLI option help). */ readonly description?: string; } /** Any string. */ export declare function string(): SimpleSchema; /** A finite number (rejects `NaN`). */ export declare function number(): SimpleSchema; /** A boolean. */ export declare function boolean(): SimpleSchema; /** `undefined`, mirroring valibot's `void`. */ export declare function voidType(): SimpleSchema; /** `null`. */ export declare function nullType(): SimpleSchema; /** One of a fixed set of literal values. */ export declare function picklist(values: T): SimpleSchema; /** A single literal value (string / number / boolean). */ export declare function literal(value: T): SimpleSchema; /** A value matching any one of the given schemas. */ export declare function union(options: T): SimpleSchema, StandardSchemaV1.InferOutput>; /** A record with string keys whose values each satisfy the value schema. */ export declare function record(_key: StandardSchemaV1, value: V): SimpleSchema>, Record>>; /** An array whose every element satisfies the item schema. */ export declare function array(item: T): SimpleSchema[], StandardSchemaV1.InferOutput[]>; /** Flatten an intersection into a single object literal for readable types. */ type Prettify = { [K in keyof T]: T[K]; } & {}; /** * Map a shape to its object type, turning fields whose type includes * `undefined` (i.e. `optional()`) into optional keys, mirroring how * valibot/zod render `optional` object entries. */ type InferField = Mode extends 'input' ? StandardSchemaV1.InferInput : StandardSchemaV1.InferOutput; type InferObject, Mode extends 'input' | 'output'> = Prettify<{ [K in keyof T as undefined extends InferField ? never : K]: InferField; } & { [K in keyof T as undefined extends InferField ? K : never]?: InferField; }>; /** An object whose known keys each satisfy their schema (extra keys are kept). */ export declare function object>(shape: T): SimpleSchema, InferObject>; /** Allow `undefined` in addition to the inner schema. */ export declare function optional(inner: T): SimpleSchema | undefined, StandardSchemaV1.InferOutput | undefined>; /** Allow `null` in addition to the inner schema. */ export declare function nullable(inner: T): SimpleSchema | null, StandardSchemaV1.InferOutput | null>; /** Attach a human-readable description (used for CLI option help). */ export declare function describe>(schema: T, description: string): T; /** * Grouped access to every builder: `s.string()`, `s.object({ ... })`, * `s.void()`, etc. Handy for a valibot-like `import { s } from * 'devframe/utils/simple-schema'` call site. */ export declare const s: { readonly string: typeof string; readonly number: typeof number; readonly boolean: typeof boolean; readonly void: typeof voidType; readonly null: typeof nullType; readonly literal: typeof literal; readonly picklist: typeof picklist; readonly union: typeof union; readonly record: typeof record; readonly array: typeof array; readonly object: typeof object; readonly optional: typeof optional; readonly nullable: typeof nullable; readonly describe: typeof describe; }; //#endregion export type { StandardSchemaV1 };